@zokugun/artifact 0.4.4 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/lib/cli.js +1 -1
  2. package/lib/commands/add.js +32 -44
  3. package/lib/commands/list.js +15 -27
  4. package/lib/commands/update.js +34 -46
  5. package/lib/compositors/compose.js +4 -5
  6. package/lib/compositors/fork.js +2 -2
  7. package/lib/compositors/json.js +1 -1
  8. package/lib/compositors/rc.js +1 -2
  9. package/lib/configs/install/read-install-config.js +74 -82
  10. package/lib/configs/install/write-install-config.js +21 -32
  11. package/lib/configs/package/read-package-config.js +33 -44
  12. package/lib/parsers/jsonc/stringify.js +11 -14
  13. package/lib/routes/command.js +26 -32
  14. package/lib/routes/lines-concat.js +1 -1
  15. package/lib/routes/list-concat.js +1 -1
  16. package/lib/routes/list-sort-concat.js +1 -1
  17. package/lib/routes/map-concat.js +2 -2
  18. package/lib/routes/overwrite.js +1 -1
  19. package/lib/routes/primitive.js +1 -1
  20. package/lib/steps/apply-formatting.js +7 -18
  21. package/lib/steps/configure-branches.js +43 -54
  22. package/lib/steps/configure-install-file-actions.js +52 -63
  23. package/lib/steps/configure-update-file-actions.js +63 -74
  24. package/lib/steps/copy-binary-files.js +29 -40
  25. package/lib/steps/execute-first-block.js +61 -75
  26. package/lib/steps/execute-next-block.js +6 -17
  27. package/lib/steps/index.js +23 -16
  28. package/lib/steps/insert-final-new-line.js +7 -18
  29. package/lib/steps/merge-text-files.js +70 -79
  30. package/lib/steps/read-editor-config.js +35 -46
  31. package/lib/steps/read-files.js +38 -48
  32. package/lib/steps/read-incoming-config.js +7 -18
  33. package/lib/steps/read-incoming-package.js +7 -18
  34. package/lib/steps/remove-files.js +18 -29
  35. package/lib/steps/replace-templates.js +15 -20
  36. package/lib/steps/validate-newer-package.js +8 -19
  37. package/lib/steps/validate-not-present-package.js +15 -26
  38. package/lib/steps/write-text-files.js +16 -27
  39. package/lib/utils/command/dedupe-strings.js +12 -0
  40. package/lib/utils/command/index.js +11 -1
  41. package/lib/utils/command/merge-and-chains.js +91 -0
  42. package/lib/utils/command/merge-command-records.js +82 -0
  43. package/lib/utils/command/merge-flag-tokens.js +14 -0
  44. package/lib/utils/command/merge-flags-as-string.js +10 -0
  45. package/lib/utils/command/merge-or-segments.js +85 -0
  46. package/lib/utils/command/merge-parts-by-prefix.js +25 -0
  47. package/lib/utils/command/merge-semicolon-segments.js +127 -0
  48. package/lib/utils/command/merge-with-semicolon-mix.js +48 -0
  49. package/lib/utils/command/prefix-of-command.js +7 -0
  50. package/lib/utils/command/split-chain.js +6 -0
  51. package/lib/utils/command/split-prefix-and-flags.js +29 -0
  52. package/lib/utils/command/split-segments.js +6 -0
  53. package/lib/utils/read-buffer.js +13 -24
  54. package/lib/utils/template.js +63 -31
  55. package/lib/utils/try-json.js +1 -1
  56. package/package.json +4 -4
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -33,45 +24,43 @@ const places = [
33
24
  name: '.artifactrc',
34
25
  },
35
26
  ];
36
- function readPackageConfig(targetPath) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- let content;
39
- let type;
40
- for (const place of places) {
41
- try {
42
- content = yield fs_extra_1.default.readFile(path_1.default.join(targetPath, place.name), 'utf-8');
43
- type = place.type;
44
- break;
45
- }
46
- catch (_a) {
47
- }
27
+ async function readPackageConfig(targetPath) {
28
+ let content;
29
+ let type;
30
+ for (const place of places) {
31
+ try {
32
+ content = await fs_extra_1.default.readFile(path_1.default.join(targetPath, place.name), 'utf-8');
33
+ type = place.type;
34
+ break;
48
35
  }
49
- if (!content) {
50
- return {
51
- install: {},
52
- update: {},
53
- };
36
+ catch {
54
37
  }
55
- let config;
56
- if (type === 'json') {
38
+ }
39
+ if (!content) {
40
+ return {
41
+ install: {},
42
+ update: {},
43
+ };
44
+ }
45
+ let config;
46
+ if (type === 'json') {
47
+ config = JSON.parse(content);
48
+ }
49
+ else if (type === 'yaml') {
50
+ config = yaml_1.default.parse(content);
51
+ }
52
+ else {
53
+ try {
57
54
  config = JSON.parse(content);
55
+ type = 'json';
58
56
  }
59
- else if (type === 'yaml') {
57
+ catch {
60
58
  config = yaml_1.default.parse(content);
59
+ type = 'yaml';
61
60
  }
62
- else {
63
- try {
64
- config = JSON.parse(content);
65
- type = 'json';
66
- }
67
- catch (_b) {
68
- config = yaml_1.default.parse(content);
69
- type = 'yaml';
70
- }
71
- }
72
- if (typeof config.update === 'undefined') {
73
- config.update = {};
74
- }
75
- return config;
76
- });
61
+ }
62
+ if (typeof config.update === 'undefined') {
63
+ config.update = {};
64
+ }
65
+ return config;
77
66
  }
@@ -7,7 +7,6 @@ function stringify(data, transform = {}) {
7
7
  return result;
8
8
  }
9
9
  function format(data, indentValue, transform, separator = false) {
10
- var _a;
11
10
  let result;
12
11
  if (Array.isArray(data)) {
13
12
  result = formatArray(data, indentValue, transform);
@@ -26,28 +25,27 @@ function format(data, indentValue, transform, separator = false) {
26
25
  if (separator) {
27
26
  result += ',';
28
27
  }
29
- if ((_a = transform.comments) === null || _a === void 0 ? void 0 : _a.right) {
28
+ if (transform.comments?.right) {
30
29
  result += transform.comments.right[0];
31
30
  }
32
31
  }
33
32
  return result;
34
33
  }
35
34
  function formatArray(data, indentValue, transform) {
36
- var _a, _b, _c, _d, _e;
37
35
  let result = '[';
38
- if ((_a = transform.comments) === null || _a === void 0 ? void 0 : _a.right) {
36
+ if (transform.comments?.right) {
39
37
  result += transform.comments.right[0];
40
38
  }
41
39
  result += '\n';
42
40
  const indent = indentValue + '\t';
43
41
  const lastIndex = data.length - 1;
44
- const children = (_b = transform.children) !== null && _b !== void 0 ? _b : {};
42
+ const children = transform.children ?? {};
45
43
  for (const [index, value] of data.entries()) {
46
- const transform = (_c = children[index]) !== null && _c !== void 0 ? _c : {};
44
+ const transform = children[index] ?? {};
47
45
  if (transform.emptyLines) {
48
46
  result += '\n'.repeat(transform.emptyLines);
49
47
  }
50
- if ((_d = transform.comments) === null || _d === void 0 ? void 0 : _d.top) {
48
+ if (transform.comments?.top) {
51
49
  for (const line of transform.comments.top) {
52
50
  result += `${indent}${line}\n`;
53
51
  }
@@ -55,7 +53,7 @@ function formatArray(data, indentValue, transform) {
55
53
  result += `${indent}`;
56
54
  result += format(value, indent, transform, index !== lastIndex || transform.separator);
57
55
  result += '\n';
58
- if ((_e = transform.comments) === null || _e === void 0 ? void 0 : _e.bottom) {
56
+ if (transform.comments?.bottom) {
59
57
  for (const line of transform.comments.bottom) {
60
58
  result += `${indent}${line}\n`;
61
59
  }
@@ -65,22 +63,21 @@ function formatArray(data, indentValue, transform) {
65
63
  return result;
66
64
  }
67
65
  function formatObject(data, indentValue, transform) {
68
- var _a, _b, _c, _d, _e;
69
66
  let result = '{';
70
- if ((_a = transform.comments) === null || _a === void 0 ? void 0 : _a.right) {
67
+ if (transform.comments?.right) {
71
68
  result += transform.comments.right[0];
72
69
  }
73
70
  result += '\n';
74
71
  const indent = indentValue + '\t';
75
72
  const values = Object.entries(data);
76
73
  const lastIndex = values.length - 1;
77
- const children = (_b = transform.children) !== null && _b !== void 0 ? _b : {};
74
+ const children = transform.children ?? {};
78
75
  for (const [index, [key, value]] of values.entries()) {
79
- const transform = (_c = children[key]) !== null && _c !== void 0 ? _c : {};
76
+ const transform = children[key] ?? {};
80
77
  if (transform.emptyLines) {
81
78
  result += '\n'.repeat(transform.emptyLines);
82
79
  }
83
- if ((_d = transform.comments) === null || _d === void 0 ? void 0 : _d.top) {
80
+ if (transform.comments?.top) {
84
81
  for (const line of transform.comments.top) {
85
82
  result += `${indent}${line}\n`;
86
83
  }
@@ -88,7 +85,7 @@ function formatObject(data, indentValue, transform) {
88
85
  result += `${indent}"${key}": `;
89
86
  result += format(value, indent, transform, index !== lastIndex || transform.separator);
90
87
  result += '\n';
91
- if ((_e = transform.comments) === null || _e === void 0 ? void 0 : _e.bottom) {
88
+ if (transform.comments?.bottom) {
92
89
  for (const line of transform.comments.bottom) {
93
90
  result += `${indent}${line}\n`;
94
91
  }
@@ -2,44 +2,38 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = command;
4
4
  const command_1 = require("../utils/command");
5
- const list_concat_1 = require("./list-concat");
6
5
  function command({ current, incoming }) {
7
- var _a;
8
6
  if (!incoming) {
9
- return current !== null && current !== void 0 ? current : '';
7
+ return current ?? '';
10
8
  }
11
9
  if (!current) {
12
10
  return incoming;
13
11
  }
12
+ const trueAndMatch = /^true\s*&&\s*(.+)$/.exec(incoming);
13
+ const currentSegments = new Set(current.split(/;|&&|\|\|/).map((s) => s.trim()).filter(Boolean));
14
+ if (currentSegments.has(incoming)) {
15
+ return current;
16
+ }
17
+ if (trueAndMatch) {
18
+ const incomingCommand = trueAndMatch[1].trim();
19
+ return currentSegments.has(incomingCommand) ? current : `${current} && ${incomingCommand}`;
20
+ }
21
+ const mixed = (0, command_1.mergeWithSemicolonMix)(current, incoming);
22
+ if (mixed) {
23
+ return mixed;
24
+ }
25
+ const andMerged = (0, command_1.mergeAndChains)(current, incoming);
26
+ if (andMerged) {
27
+ return andMerged;
28
+ }
29
+ if (incoming.includes('||')) {
30
+ return (0, command_1.mergeOrSegments)(current, incoming);
31
+ }
32
+ if (incoming.includes(';')) {
33
+ return (0, command_1.mergeSemicolonSegments)(current, incoming);
34
+ }
14
35
  const currentCommand = (0, command_1.splitCommand)(current);
15
36
  const incomingCommand = (0, command_1.splitCommand)(incoming);
16
- const result = {};
17
- for (const [name, instances] of Object.entries(incomingCommand)) {
18
- if (currentCommand[name]) {
19
- result[name] = [];
20
- for (const [index, instance] of instances.entries()) {
21
- if (currentCommand[name][index]) {
22
- const currentInstance = currentCommand[name][index];
23
- result[name].push({
24
- args: (0, list_concat_1.listConcat)({
25
- current: currentInstance.args,
26
- incoming: instance.args,
27
- }),
28
- env: (0, list_concat_1.listConcat)({
29
- current: currentInstance.env,
30
- incoming: instance.env,
31
- }),
32
- separator: (_a = instance.separator) !== null && _a !== void 0 ? _a : currentInstance.separator,
33
- });
34
- }
35
- else {
36
- result[name].push(instance);
37
- }
38
- }
39
- }
40
- else {
41
- result[name] = instances;
42
- }
43
- }
44
- return (0, command_1.joinCommand)(result);
37
+ const merged = (0, command_1.mergeCommandRecords)(currentCommand, incomingCommand, current);
38
+ return (0, command_1.joinCommand)(merged);
45
39
  }
@@ -6,7 +6,7 @@ const trim_final_newline_1 = require("../utils/trim-final-newline");
6
6
  const list_concat_1 = require("./list-concat");
7
7
  function linesConcat({ current, incoming }) {
8
8
  if (!incoming) {
9
- return current !== null && current !== void 0 ? current : '';
9
+ return current ?? '';
10
10
  }
11
11
  if (!current) {
12
12
  return incoming;
@@ -8,7 +8,7 @@ const isEqual_1 = __importDefault(require("lodash/isEqual"));
8
8
  const uniqWith_1 = __importDefault(require("lodash/uniqWith"));
9
9
  function listConcat({ current, incoming }) {
10
10
  if (!incoming) {
11
- return current !== null && current !== void 0 ? current : [];
11
+ return current ?? [];
12
12
  }
13
13
  if (!current) {
14
14
  return incoming;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listSortConcat = listSortConcat;
4
4
  function listSortConcat({ current, incoming }) {
5
5
  if (!incoming) {
6
- return current !== null && current !== void 0 ? current : [];
6
+ return current ?? [];
7
7
  }
8
8
  if (!current) {
9
9
  return incoming;
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapConcat = mapConcat;
4
4
  function mapConcat({ current, incoming }) {
5
5
  if (!incoming) {
6
- return current !== null && current !== void 0 ? current : {};
6
+ return current ?? {};
7
7
  }
8
8
  if (!current) {
9
9
  return incoming;
10
10
  }
11
- return Object.assign(Object.assign({}, current), incoming);
11
+ return { ...current, ...incoming };
12
12
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.overwrite = overwrite;
4
4
  function overwrite({ current, incoming }) {
5
5
  if (typeof incoming === 'undefined') {
6
- return current !== null && current !== void 0 ? current : [];
6
+ return current ?? [];
7
7
  }
8
8
  else {
9
9
  return incoming;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.primitive = primitive;
4
4
  function primitive({ current, incoming }) {
5
5
  if (typeof incoming === 'undefined') {
6
- return current !== null && current !== void 0 ? current : [];
6
+ return current ?? [];
7
7
  }
8
8
  if (typeof current === 'undefined') {
9
9
  return incoming;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -63,15 +54,13 @@ function indentWithTab(data) {
63
54
  return data;
64
55
  }
65
56
  } // }}}
66
- function applyFormatting(_a) {
67
- return __awaiter(this, arguments, void 0, function* ({ mergedTextFiles, formats }) {
68
- for (const file of mergedTextFiles) {
69
- for (const format of formats) {
70
- if (fnmatch(file.name, format.glob)) {
71
- applyFormat(file, format);
72
- break;
73
- }
57
+ async function applyFormatting({ mergedTextFiles, formats }) {
58
+ for (const file of mergedTextFiles) {
59
+ for (const format of formats) {
60
+ if (fnmatch(file.name, format.glob)) {
61
+ applyFormat(file, format);
62
+ break;
74
63
  }
75
64
  }
76
- });
65
+ }
77
66
  }
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -16,35 +7,30 @@ exports.configureBranches = configureBranches;
16
7
  const node_path_1 = __importDefault(require("node:path"));
17
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
18
9
  const globby_1 = __importDefault(require("globby"));
19
- function configureBranches(context) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- const cwd = node_path_1.default.join(context.incomingPath, 'branches');
22
- if (yield fs_extra_1.default.pathExists(cwd)) {
23
- const directories = yield (0, globby_1.default)('*', {
24
- cwd,
25
- onlyDirectories: true,
26
- });
27
- const bucket = [];
28
- for (const directory of directories) {
29
- const match = /^\[(@[\w-]+:[\w-]+|[\w-]+)(?::([\w-]+))?]$/.exec(directory);
30
- if (match) {
31
- const [branch, name, variant] = match;
32
- const packageName = name.replace(/:(artifact-)?/g, '/artifact-');
33
- const artifact = context.config.artifacts[packageName];
34
- let found = false;
35
- if (artifact) {
36
- if (variant) {
37
- if (Array.isArray(artifact.requires)) {
38
- if (artifact.requires.includes(variant)) {
39
- found = true;
40
- }
41
- }
42
- else if (Array.isArray(artifact.provides)) {
43
- if (artifact.provides.includes(variant)) {
44
- found = true;
45
- }
10
+ async function configureBranches(context) {
11
+ const cwd = node_path_1.default.join(context.incomingPath, 'branches');
12
+ if (await fs_extra_1.default.pathExists(cwd)) {
13
+ const directories = await (0, globby_1.default)('*', {
14
+ cwd,
15
+ onlyDirectories: true,
16
+ });
17
+ const bucket = [];
18
+ for (const directory of directories) {
19
+ const match = /^\[(@[\w-]+:[\w-]+|[\w-]+)(?::([\w-]+))?]$/.exec(directory);
20
+ if (match) {
21
+ const [branch, name, variant] = match;
22
+ const packageName = name.replace(/:(artifact-)?/g, '/artifact-');
23
+ const artifact = context.config.artifacts[packageName];
24
+ let found = false;
25
+ if (artifact) {
26
+ if (variant) {
27
+ if (Array.isArray(artifact.requires)) {
28
+ if (artifact.requires.includes(variant)) {
29
+ found = true;
46
30
  }
47
- else {
31
+ }
32
+ else if (Array.isArray(artifact.provides)) {
33
+ if (artifact.provides.includes(variant)) {
48
34
  found = true;
49
35
  }
50
36
  }
@@ -52,26 +38,29 @@ function configureBranches(context) {
52
38
  found = true;
53
39
  }
54
40
  }
55
- if (found) {
56
- if (context.options.verbose) {
57
- console.log(`- branch: ${name}${variant ? `:${variant}` : ''} has been matched`);
58
- }
59
- bucket.push({
60
- name: context.incomingName,
61
- version: context.incomingVersion,
62
- variant: context.incomingVariant,
63
- branch,
64
- incomingPath: node_path_1.default.join(cwd, directory),
65
- });
66
- }
67
41
  else {
68
- if (context.options.verbose) {
69
- console.log(`- branch: ${name}${variant ? `:${variant}` : ''} hasn't been matched (${artifact ? 'variant' : 'artifact'} not found)`);
70
- }
42
+ found = true;
43
+ }
44
+ }
45
+ if (found) {
46
+ if (context.options.verbose) {
47
+ console.log(`- branch: ${name}${variant ? `:${variant}` : ''} has been matched`);
48
+ }
49
+ bucket.push({
50
+ name: context.incomingName,
51
+ version: context.incomingVersion,
52
+ variant: context.incomingVariant,
53
+ branch,
54
+ incomingPath: node_path_1.default.join(cwd, directory),
55
+ });
56
+ }
57
+ else {
58
+ if (context.options.verbose) {
59
+ console.log(`- branch: ${name}${variant ? `:${variant}` : ''} hasn't been matched (${artifact ? 'variant' : 'artifact'} not found)`);
71
60
  }
72
61
  }
73
62
  }
74
- context.blocks.unshift(...bucket);
75
63
  }
76
- });
64
+ context.blocks.unshift(...bucket);
65
+ }
77
66
  }
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.configureInstallFileActions = configureInstallFileActions;
13
4
  const lodash_1 = require("lodash");
@@ -88,64 +79,62 @@ function buildTravel(route) {
88
79
  throw new Error('Can\'t build route');
89
80
  }
90
81
  } // }}}
91
- function configureInstallFileActions(context) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const { install } = context.incomingConfig;
94
- if (!install) {
95
- return;
82
+ async function configureInstallFileActions(context) {
83
+ const { install } = context.incomingConfig;
84
+ if (!install) {
85
+ return;
86
+ }
87
+ const overwrites = [];
88
+ const filters = {};
89
+ const routes = {};
90
+ for (const [file, fileUpdate] of Object.entries(install)) {
91
+ const { overwrite, remove, filter, route } = fileUpdate;
92
+ if (remove) {
93
+ context.removedPatterns.push(file);
94
+ continue;
96
95
  }
97
- const overwrites = [];
98
- const filters = {};
99
- const routes = {};
100
- for (const [file, fileUpdate] of Object.entries(install)) {
101
- const { overwrite, remove, filter, route } = fileUpdate;
102
- if (remove) {
103
- context.removedPatterns.push(file);
104
- continue;
105
- }
106
- if (overwrite) {
107
- overwrites.push(file);
108
- }
109
- if (filter) {
110
- filters[file] = filter;
96
+ if (overwrite) {
97
+ overwrites.push(file);
98
+ }
99
+ if (filter) {
100
+ filters[file] = filter;
101
+ }
102
+ if (route) {
103
+ const { alias } = route;
104
+ if (alias) {
105
+ routes[file] = {
106
+ alias,
107
+ travel: buildTravel(route),
108
+ };
111
109
  }
112
- if (route) {
113
- const { alias } = route;
114
- if (alias) {
115
- routes[file] = {
116
- alias,
117
- travel: buildTravel(route),
118
- };
119
- }
120
- else {
121
- routes[file] = {
122
- travel: buildTravel(route),
123
- };
124
- }
110
+ else {
111
+ routes[file] = {
112
+ travel: buildTravel(route),
113
+ };
125
114
  }
126
115
  }
127
- if (overwrites.length > 0) {
128
- context.onExisting = (file) => (0, micromatch_1.isMatch)(file, overwrites) ? 'overwrite' : 'merge';
129
- }
130
- if (!(0, lodash_1.isEmpty)(filters)) {
131
- context.filters = (file) => {
132
- for (const [pattern, value] of Object.entries(filters)) {
133
- if ((0, micromatch_1.isMatch)(file, pattern)) {
134
- return value;
135
- }
116
+ }
117
+ if (overwrites.length > 0) {
118
+ context.onExisting = (file) => (0, micromatch_1.isMatch)(file, overwrites) ? 'overwrite' : 'merge';
119
+ }
120
+ if (!(0, lodash_1.isEmpty)(filters)) {
121
+ context.filters = (file) => {
122
+ for (const [pattern, value] of Object.entries(filters)) {
123
+ if ((0, micromatch_1.isMatch)(file, pattern)) {
124
+ return value;
136
125
  }
137
- return undefined;
138
- };
139
- }
140
- if (!(0, lodash_1.isEmpty)(routes)) {
141
- context.routes = (file) => {
142
- for (const [pattern, route] of Object.entries(routes)) {
143
- if ((0, micromatch_1.isMatch)(file, pattern)) {
144
- return route;
145
- }
126
+ }
127
+ return undefined;
128
+ };
129
+ }
130
+ if (!(0, lodash_1.isEmpty)(routes)) {
131
+ context.routes = (file) => {
132
+ for (const [pattern, route] of Object.entries(routes)) {
133
+ if ((0, micromatch_1.isMatch)(file, pattern)) {
134
+ return route;
146
135
  }
147
- return undefined;
148
- };
149
- }
150
- });
136
+ }
137
+ return undefined;
138
+ };
139
+ }
151
140
  }