@zokugun/artifact 0.4.4 → 0.5.0
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.
- package/lib/commands/add.js +32 -44
- package/lib/commands/list.js +15 -27
- package/lib/commands/update.js +34 -46
- package/lib/compositors/compose.js +4 -5
- package/lib/compositors/fork.js +2 -2
- package/lib/compositors/json.js +1 -1
- package/lib/compositors/rc.js +1 -2
- package/lib/configs/install/read-install-config.js +74 -82
- package/lib/configs/install/write-install-config.js +21 -32
- package/lib/configs/package/read-package-config.js +33 -44
- package/lib/parsers/jsonc/stringify.js +11 -14
- package/lib/routes/command.js +2 -3
- package/lib/routes/lines-concat.js +1 -1
- package/lib/routes/list-concat.js +1 -1
- package/lib/routes/list-sort-concat.js +1 -1
- package/lib/routes/map-concat.js +2 -2
- package/lib/routes/overwrite.js +1 -1
- package/lib/routes/primitive.js +1 -1
- package/lib/steps/apply-formatting.js +7 -18
- package/lib/steps/configure-branches.js +43 -54
- package/lib/steps/configure-install-file-actions.js +52 -63
- package/lib/steps/configure-update-file-actions.js +63 -74
- package/lib/steps/copy-binary-files.js +29 -40
- package/lib/steps/execute-first-block.js +61 -75
- package/lib/steps/execute-next-block.js +6 -17
- package/lib/steps/index.js +23 -16
- package/lib/steps/insert-final-new-line.js +7 -18
- package/lib/steps/merge-text-files.js +70 -79
- package/lib/steps/read-editor-config.js +35 -46
- package/lib/steps/read-files.js +37 -48
- package/lib/steps/read-incoming-config.js +7 -18
- package/lib/steps/read-incoming-package.js +7 -18
- package/lib/steps/remove-files.js +18 -29
- package/lib/steps/replace-templates.js +15 -20
- package/lib/steps/validate-newer-package.js +8 -19
- package/lib/steps/validate-not-present-package.js +15 -26
- package/lib/steps/write-text-files.js +16 -27
- package/lib/utils/read-buffer.js +13 -24
- package/lib/utils/template.js +63 -31
- package/lib/utils/try-json.js +1 -1
- package/package.json +3 -3
|
@@ -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 (
|
|
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 (
|
|
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 =
|
|
42
|
+
const children = transform.children ?? {};
|
|
45
43
|
for (const [index, value] of data.entries()) {
|
|
46
|
-
const transform =
|
|
44
|
+
const transform = children[index] ?? {};
|
|
47
45
|
if (transform.emptyLines) {
|
|
48
46
|
result += '\n'.repeat(transform.emptyLines);
|
|
49
47
|
}
|
|
50
|
-
if (
|
|
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 (
|
|
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 (
|
|
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 =
|
|
74
|
+
const children = transform.children ?? {};
|
|
78
75
|
for (const [index, [key, value]] of values.entries()) {
|
|
79
|
-
const transform =
|
|
76
|
+
const transform = children[key] ?? {};
|
|
80
77
|
if (transform.emptyLines) {
|
|
81
78
|
result += '\n'.repeat(transform.emptyLines);
|
|
82
79
|
}
|
|
83
|
-
if (
|
|
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 (
|
|
88
|
+
if (transform.comments?.bottom) {
|
|
92
89
|
for (const line of transform.comments.bottom) {
|
|
93
90
|
result += `${indent}${line}\n`;
|
|
94
91
|
}
|
package/lib/routes/command.js
CHANGED
|
@@ -4,9 +4,8 @@ exports.command = command;
|
|
|
4
4
|
const command_1 = require("../utils/command");
|
|
5
5
|
const list_concat_1 = require("./list-concat");
|
|
6
6
|
function command({ current, incoming }) {
|
|
7
|
-
var _a;
|
|
8
7
|
if (!incoming) {
|
|
9
|
-
return current
|
|
8
|
+
return current ?? '';
|
|
10
9
|
}
|
|
11
10
|
if (!current) {
|
|
12
11
|
return incoming;
|
|
@@ -29,7 +28,7 @@ function command({ current, incoming }) {
|
|
|
29
28
|
current: currentInstance.env,
|
|
30
29
|
incoming: instance.env,
|
|
31
30
|
}),
|
|
32
|
-
separator:
|
|
31
|
+
separator: instance.separator ?? currentInstance.separator,
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
34
|
else {
|
|
@@ -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
|
|
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
|
|
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
|
|
6
|
+
return current ?? [];
|
|
7
7
|
}
|
|
8
8
|
if (!current) {
|
|
9
9
|
return incoming;
|
package/lib/routes/map-concat.js
CHANGED
|
@@ -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
|
|
6
|
+
return current ?? {};
|
|
7
7
|
}
|
|
8
8
|
if (!current) {
|
|
9
9
|
return incoming;
|
|
10
10
|
}
|
|
11
|
-
return
|
|
11
|
+
return { ...current, ...incoming };
|
|
12
12
|
}
|
package/lib/routes/overwrite.js
CHANGED
|
@@ -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
|
|
6
|
+
return current ?? [];
|
|
7
7
|
}
|
|
8
8
|
else {
|
|
9
9
|
return incoming;
|
package/lib/routes/primitive.js
CHANGED
|
@@ -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
|
|
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(
|
|
67
|
-
|
|
68
|
-
for (const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
if (
|
|
37
|
-
if (
|
|
38
|
-
|
|
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
|
-
|
|
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
|
-
|
|
69
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
}
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
151
140
|
}
|
|
@@ -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.configureUpdateFileActions = configureUpdateFileActions;
|
|
13
4
|
const lodash_1 = require("lodash");
|
|
@@ -88,76 +79,74 @@ function buildTravel(route) {
|
|
|
88
79
|
throw new Error('Can\'t build route');
|
|
89
80
|
}
|
|
90
81
|
} // }}}
|
|
91
|
-
function configureUpdateFileActions(context) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
context.onMissing = () => 'skip';
|
|
98
|
-
}
|
|
82
|
+
async function configureUpdateFileActions(context) {
|
|
83
|
+
const { update } = context.incomingConfig;
|
|
84
|
+
if (typeof update === 'boolean') {
|
|
85
|
+
if (!update) {
|
|
86
|
+
context.onExisting = () => 'skip';
|
|
87
|
+
context.onMissing = () => 'skip';
|
|
99
88
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (update === false) {
|
|
112
|
-
skipExistings.push(file);
|
|
113
|
-
}
|
|
114
|
-
else if (overwrite) {
|
|
115
|
-
overwriteExistings.push(file);
|
|
116
|
-
}
|
|
117
|
-
if (filter) {
|
|
118
|
-
filters[file] = filter;
|
|
119
|
-
}
|
|
120
|
-
if (route) {
|
|
121
|
-
const { alias } = route;
|
|
122
|
-
if (alias) {
|
|
123
|
-
routes[file] = {
|
|
124
|
-
alias,
|
|
125
|
-
travel: buildTravel(route),
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
routes[file] = {
|
|
130
|
-
travel: buildTravel(route),
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
89
|
+
}
|
|
90
|
+
else if ((0, lodash_1.isPlainObject)(update)) {
|
|
91
|
+
const overwriteExistings = [];
|
|
92
|
+
const skipExistings = [];
|
|
93
|
+
const skipMissings = [];
|
|
94
|
+
const filters = {};
|
|
95
|
+
const routes = {};
|
|
96
|
+
for (const [file, fileUpdate] of Object.entries(update)) {
|
|
97
|
+
const { missing, update, overwrite, filter, route } = fileUpdate;
|
|
98
|
+
if (missing === false) {
|
|
99
|
+
skipMissings.push(file);
|
|
134
100
|
}
|
|
135
|
-
if (
|
|
136
|
-
|
|
101
|
+
if (update === false) {
|
|
102
|
+
skipExistings.push(file);
|
|
137
103
|
}
|
|
138
|
-
if (
|
|
139
|
-
|
|
104
|
+
else if (overwrite) {
|
|
105
|
+
overwriteExistings.push(file);
|
|
140
106
|
}
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
for (const [pattern, value] of Object.entries(filters)) {
|
|
144
|
-
if ((0, micromatch_1.isMatch)(file, pattern)) {
|
|
145
|
-
return value;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return undefined;
|
|
149
|
-
};
|
|
107
|
+
if (filter) {
|
|
108
|
+
filters[file] = filter;
|
|
150
109
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
110
|
+
if (route) {
|
|
111
|
+
const { alias } = route;
|
|
112
|
+
if (alias) {
|
|
113
|
+
routes[file] = {
|
|
114
|
+
alias,
|
|
115
|
+
travel: buildTravel(route),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
routes[file] = {
|
|
120
|
+
travel: buildTravel(route),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
160
123
|
}
|
|
161
124
|
}
|
|
162
|
-
|
|
125
|
+
if (skipMissings.length > 0) {
|
|
126
|
+
context.onMissing = (file) => (0, micromatch_1.isMatch)(file, skipMissings) ? 'skip' : 'continue';
|
|
127
|
+
}
|
|
128
|
+
if (skipExistings.length > 0 || overwriteExistings.length > 0) {
|
|
129
|
+
context.onExisting = (file) => (0, micromatch_1.isMatch)(file, skipExistings) ? 'skip' : ((0, micromatch_1.isMatch)(file, overwriteExistings) ? 'overwrite' : 'merge');
|
|
130
|
+
}
|
|
131
|
+
if (!(0, lodash_1.isEmpty)(filters)) {
|
|
132
|
+
context.filters = (file) => {
|
|
133
|
+
for (const [pattern, value] of Object.entries(filters)) {
|
|
134
|
+
if ((0, micromatch_1.isMatch)(file, pattern)) {
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return undefined;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (!(0, lodash_1.isEmpty)(routes)) {
|
|
142
|
+
context.routes = (file) => {
|
|
143
|
+
for (const [pattern, route] of Object.entries(routes)) {
|
|
144
|
+
if ((0, micromatch_1.isMatch)(file, pattern)) {
|
|
145
|
+
return route;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return undefined;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
163
152
|
}
|