@zokugun/artifact 0.5.2 → 0.6.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.
- package/bin/artifact +1 -1
- package/lib/cli.d.ts +1 -0
- package/lib/cli.js +12 -4
- package/lib/commands/add.d.ts +6 -0
- package/lib/commands/add.js +47 -36
- package/lib/commands/index.d.ts +4 -0
- package/lib/commands/index.js +9 -7
- package/lib/commands/list.d.ts +1 -0
- package/lib/commands/list.js +13 -8
- package/lib/commands/remove.d.ts +6 -0
- package/lib/commands/remove.js +79 -0
- package/lib/commands/update.d.ts +5 -0
- package/lib/commands/update.js +43 -39
- package/lib/compositors/compose.d.ts +7 -0
- package/lib/compositors/compose.js +13 -13
- package/lib/compositors/fork.d.ts +3 -0
- package/lib/compositors/fork.js +4 -4
- package/lib/compositors/index.d.ts +6 -0
- package/lib/compositors/index.js +12 -12
- package/lib/compositors/json.d.ts +2 -0
- package/lib/compositors/json.js +14 -12
- package/lib/compositors/map-sort.d.ts +2 -0
- package/lib/compositors/map-sort.js +2 -2
- package/lib/compositors/rc.d.ts +2 -0
- package/lib/compositors/rc.js +13 -10
- package/lib/compositors/yaml.d.ts +2 -0
- package/lib/compositors/yaml.js +8 -11
- package/lib/configs/index.d.ts +3 -0
- package/lib/configs/index.js +3 -2
- package/lib/configs/install/index.d.ts +3 -0
- package/lib/configs/install/index.js +6 -6
- package/lib/configs/install/read-install-config.d.ts +6 -0
- package/lib/configs/install/read-install-config.js +128 -81
- package/lib/configs/install/update-install-config.d.ts +2 -0
- package/lib/configs/install/write-install-config.d.ts +5 -0
- package/lib/configs/install/write-install-config.js +25 -10
- package/lib/configs/package/index.d.ts +1 -0
- package/lib/configs/package/index.js +2 -2
- package/lib/configs/package/read-package-config.d.ts +3 -0
- package/lib/configs/package/read-package-config.js +160 -40
- package/lib/configs/uninstall/index.d.ts +1 -0
- package/lib/configs/uninstall/index.js +5 -0
- package/lib/configs/uninstall/update-uninstall-config.d.ts +2 -0
- package/lib/configs/uninstall/update-uninstall-config.js +6 -0
- package/lib/configs/utils/constants.d.ts +11 -0
- package/lib/configs/utils/constants.js +24 -0
- package/lib/configs/utils/is-transform.d.ts +2 -0
- package/lib/configs/utils/is-transform.js +16 -0
- package/lib/configs/utils/merge-upsert-property.d.ts +3 -0
- package/lib/configs/utils/merge-upsert-property.js +78 -0
- package/lib/configs/utils/normalize-file-always.d.ts +3 -0
- package/lib/configs/utils/normalize-file-always.js +29 -0
- package/lib/configs/utils/normalize-file-uninstall.d.ts +3 -0
- package/lib/configs/utils/normalize-file-uninstall.js +32 -0
- package/lib/configs/utils/normalize-file-upsert.d.ts +3 -0
- package/lib/configs/utils/normalize-file-upsert.js +55 -0
- package/lib/journeys/commitlint/index.d.ts +2 -0
- package/lib/journeys/commitlint/index.js +15 -15
- package/lib/journeys/config.ts/index.d.ts +2 -0
- package/lib/journeys/config.ts/index.js +5 -5
- package/lib/journeys/default/index.d.ts +2 -0
- package/lib/journeys/default/index.js +11 -14
- package/lib/journeys/fixpack/index.d.ts +2 -0
- package/lib/journeys/fixpack/index.js +13 -13
- package/lib/journeys/gitignore/index.d.ts +2 -0
- package/lib/journeys/gitignore/index.js +5 -5
- package/lib/journeys/ignore/index.d.ts +2 -0
- package/lib/journeys/ignore/index.js +5 -5
- package/lib/journeys/index.d.ts +2 -0
- package/lib/journeys/index.js +20 -20
- package/lib/journeys/npmignore/index.d.ts +2 -0
- package/lib/journeys/npmignore/index.js +5 -5
- package/lib/journeys/package/index.d.ts +2 -0
- package/lib/journeys/package/index.js +27 -30
- package/lib/journeys/rc/index.d.ts +2 -0
- package/lib/journeys/rc/index.js +12 -12
- package/lib/journeys/tsconfig/index.d.ts +2 -0
- package/lib/journeys/tsconfig/index.js +13 -16
- package/lib/parsers/json.d.ts +2 -0
- package/lib/parsers/jsonc/index.d.ts +2 -0
- package/lib/parsers/jsonc/index.js +4 -4
- package/lib/parsers/jsonc/parse.d.ts +5 -0
- package/lib/parsers/jsonc/parse.js +1 -13
- package/lib/parsers/jsonc/stringify.d.ts +2 -0
- package/lib/parsers/jsonc/stringify.js +2 -2
- package/lib/parsers/jsonc/transform.d.ts +10 -0
- package/lib/parsers/yaml.d.ts +2 -0
- package/lib/routes/command.d.ts +4 -0
- package/lib/routes/command.js +10 -10
- package/lib/routes/index.d.ts +8 -0
- package/lib/routes/index.js +17 -15
- package/lib/routes/lines-concat.d.ts +4 -0
- package/lib/routes/lines-concat.js +7 -7
- package/lib/routes/list-concat.d.ts +4 -0
- package/lib/routes/list-concat.js +3 -7
- package/lib/routes/list-sort-concat.d.ts +4 -0
- package/lib/routes/list-sort-concat.js +1 -1
- package/lib/routes/map-concat.d.ts +4 -0
- package/lib/routes/map-concat.js +1 -1
- package/lib/routes/map-delete.d.ts +4 -0
- package/lib/routes/map-delete.js +32 -0
- package/lib/routes/overwrite.d.ts +4 -0
- package/lib/routes/overwrite.js +2 -2
- package/lib/routes/primitive.d.ts +4 -0
- package/lib/routes/primitive.js +3 -3
- package/lib/steps/apply-formatting.d.ts +8 -0
- package/lib/steps/apply-formatting.js +50 -25
- package/lib/steps/configure-branches.d.ts +3 -0
- package/lib/steps/configure-branches.js +8 -5
- package/lib/steps/configure-install-file-actions.d.ts +3 -0
- package/lib/steps/configure-install-file-actions.js +59 -94
- package/lib/steps/configure-uninstall-file-actions.d.ts +3 -0
- package/lib/steps/configure-uninstall-file-actions.js +57 -0
- package/lib/steps/configure-update-file-actions.d.ts +3 -0
- package/lib/steps/configure-update-file-actions.js +65 -102
- package/lib/steps/copy-binary-files.d.ts +3 -0
- package/lib/steps/copy-binary-files.js +24 -11
- package/lib/steps/execute-first-block.d.ts +3 -0
- package/lib/steps/execute-first-block.js +35 -14
- package/lib/steps/execute-next-block.d.ts +3 -0
- package/lib/steps/execute-next-block.js +8 -3
- package/lib/steps/index.d.ts +54 -0
- package/lib/steps/index.js +76 -54
- package/lib/steps/insert-final-new-line.d.ts +6 -0
- package/lib/steps/insert-final-new-line.js +13 -1
- package/lib/steps/merge-text-files.d.ts +3 -0
- package/lib/steps/merge-text-files.js +47 -28
- package/lib/steps/read-editor-config.d.ts +3 -0
- package/lib/steps/read-editor-config.js +21 -26
- package/lib/steps/read-files.d.ts +3 -0
- package/lib/steps/read-files.js +26 -10
- package/lib/steps/read-incoming-config.d.ts +3 -0
- package/lib/steps/read-incoming-config.js +7 -5
- package/lib/steps/read-incoming-package.d.ts +3 -0
- package/lib/steps/read-incoming-package.js +12 -7
- package/lib/steps/remove-files.d.ts +3 -0
- package/lib/steps/remove-files.js +10 -4
- package/lib/steps/rename-files.d.ts +3 -0
- package/lib/steps/rename-files.js +25 -0
- package/lib/steps/replace-templates.d.ts +3 -0
- package/lib/steps/replace-templates.js +19 -5
- package/lib/steps/transform-untouched-files.d.ts +3 -0
- package/lib/steps/transform-untouched-files.js +64 -0
- package/lib/steps/unmerge-text-files.d.ts +3 -0
- package/lib/steps/unmerge-text-files.js +64 -0
- package/lib/steps/validate-newer-package.d.ts +3 -0
- package/lib/steps/validate-newer-package.js +4 -2
- package/lib/steps/validate-not-present-package.d.ts +3 -0
- package/lib/steps/validate-not-present-package.js +7 -4
- package/lib/steps/validate-present-package.d.ts +3 -0
- package/lib/steps/validate-present-package.js +24 -0
- package/lib/steps/write-text-files.d.ts +3 -0
- package/lib/steps/write-text-files.js +16 -7
- package/lib/types/binary-file.d.ts +4 -0
- package/lib/types/command.d.ts +5 -0
- package/lib/types/config.d.ts +59 -0
- package/lib/types/context.d.ts +62 -0
- package/lib/types/context.js +4 -0
- package/lib/types/format.d.ts +14 -0
- package/lib/types/step.d.ts +3 -0
- package/lib/types/travel.d.ts +14 -0
- package/lib/utils/apply-transforms.d.ts +2 -0
- package/lib/utils/apply-transforms.js +48 -0
- package/lib/utils/build-journey-plan.d.ts +2 -0
- package/lib/utils/build-route.d.ts +3 -0
- package/lib/utils/build-route.js +92 -0
- package/lib/utils/build-travel-plan.d.ts +2 -0
- package/lib/utils/build-travel.d.ts +3 -0
- package/lib/utils/build-travel.js +32 -0
- package/lib/utils/command/dedupe-strings.d.ts +1 -0
- package/lib/utils/command/index.d.ts +8 -0
- package/lib/utils/command/index.js +14 -14
- package/lib/utils/command/join-command.d.ts +2 -0
- package/lib/utils/command/merge-and-chains.d.ts +1 -0
- package/lib/utils/command/merge-and-chains.js +21 -21
- package/lib/utils/command/merge-command-records.d.ts +2 -0
- package/lib/utils/command/merge-command-records.js +43 -22
- package/lib/utils/command/merge-flag-tokens.d.ts +1 -0
- package/lib/utils/command/merge-flag-tokens.js +1 -1
- package/lib/utils/command/merge-flags-as-string.d.ts +4 -0
- package/lib/utils/command/merge-flags-as-string.js +4 -4
- package/lib/utils/command/merge-or-segments.d.ts +1 -0
- package/lib/utils/command/merge-or-segments.js +28 -28
- package/lib/utils/command/merge-parts-by-prefix.d.ts +1 -0
- package/lib/utils/command/merge-parts-by-prefix.js +6 -6
- package/lib/utils/command/merge-semicolon-segments.d.ts +1 -0
- package/lib/utils/command/merge-semicolon-segments.js +35 -35
- package/lib/utils/command/merge-with-semicolon-mix.d.ts +1 -0
- package/lib/utils/command/merge-with-semicolon-mix.js +12 -12
- package/lib/utils/command/prefix-of-command.d.ts +1 -0
- package/lib/utils/command/prefix-of-command.js +2 -2
- package/lib/utils/command/split-chain.d.ts +1 -0
- package/lib/utils/command/split-command.d.ts +2 -0
- package/lib/utils/command/split-command.js +8 -8
- package/lib/utils/command/split-prefix-and-flags.d.ts +4 -0
- package/lib/utils/command/split-prefix-and-flags.js +5 -5
- package/lib/utils/command/split-segments.d.ts +1 -0
- package/lib/utils/detect-indent.d.ts +2 -0
- package/lib/utils/detect-indent.js +63 -0
- package/lib/utils/flow.d.ts +3 -0
- package/lib/utils/flow.js +12 -0
- package/lib/utils/get-format.d.ts +2 -0
- package/lib/utils/get-format.js +19 -0
- package/lib/utils/has-final-new-line.d.ts +1 -0
- package/lib/utils/has-final-new-line.js +7 -0
- package/lib/utils/read-buffer.d.ts +2 -0
- package/lib/utils/resolve-request.d.ts +3 -0
- package/lib/utils/resolve-request.js +4 -3
- package/lib/utils/template.d.ts +17 -0
- package/lib/utils/template.js +79 -57
- package/lib/utils/to-lines.d.ts +1 -0
- package/lib/utils/trim-final-newline.d.ts +1 -0
- package/lib/utils/try-json.d.ts +1 -0
- package/lib/utils/try-json.js +2 -2
- package/package.json +74 -51
- package/lib/types/text-file.js +0 -2
- package/lib/utils/dev-null.js +0 -7
|
@@ -1,134 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configureUpdateFileActions = configureUpdateFileActions;
|
|
4
|
-
const
|
|
4
|
+
const is_it_type_1 = require("@zokugun/is-it-type");
|
|
5
|
+
const xtry_1 = require("@zokugun/xtry");
|
|
5
6
|
const micromatch_1 = require("micromatch");
|
|
6
|
-
const
|
|
7
|
-
const routes_1 = require("../routes");
|
|
8
|
-
function buildRoute(route) {
|
|
9
|
-
if (Array.isArray(route) && route.length > 0) {
|
|
10
|
-
let result = buildRoute(route[0]);
|
|
11
|
-
for (let i = 1; i < route.length; i++) {
|
|
12
|
-
if (route[i] === 'mapSort') {
|
|
13
|
-
result = (0, compositors_1.mapSort)(result);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
throw new Error('Can\'t build route');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
else if ((0, lodash_1.isPlainObject)(route)) {
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
23
|
-
const { compose: rtCompose, fork: rtFork, mapSort: rtMapSort } = route;
|
|
24
|
-
if (rtCompose) {
|
|
25
|
-
const map = {};
|
|
26
|
-
for (const [name, route] of Object.entries(rtCompose)) {
|
|
27
|
-
map[name] = buildRoute(route);
|
|
28
|
-
}
|
|
29
|
-
return (0, compositors_1.compose)(map);
|
|
30
|
-
}
|
|
31
|
-
else if (rtFork) {
|
|
32
|
-
const map = [];
|
|
33
|
-
if (rtFork.array) {
|
|
34
|
-
map.push([Array.isArray, buildRoute(rtFork.array)]);
|
|
35
|
-
}
|
|
36
|
-
if (rtFork.object) {
|
|
37
|
-
map.push([lodash_1.isPlainObject, buildRoute(rtFork.object)]);
|
|
38
|
-
}
|
|
39
|
-
if (rtFork.default) {
|
|
40
|
-
map.push(buildRoute(rtFork.default));
|
|
41
|
-
}
|
|
42
|
-
return (0, compositors_1.fork)(...map);
|
|
43
|
-
}
|
|
44
|
-
else if (rtMapSort) {
|
|
45
|
-
return (0, compositors_1.mapSort)(buildRoute(rtMapSort));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else if (route === 'command') {
|
|
49
|
-
return routes_1.command;
|
|
50
|
-
}
|
|
51
|
-
else if (route === 'linesConcat') {
|
|
52
|
-
return routes_1.linesConcat;
|
|
53
|
-
}
|
|
54
|
-
else if (route === 'listConcat') {
|
|
55
|
-
return routes_1.listConcat;
|
|
56
|
-
}
|
|
57
|
-
else if (route === 'mapConcat') {
|
|
58
|
-
return routes_1.mapConcat;
|
|
59
|
-
}
|
|
60
|
-
else if (route === 'overwrite') {
|
|
61
|
-
return routes_1.overwrite;
|
|
62
|
-
}
|
|
63
|
-
else if (route === 'primitive') {
|
|
64
|
-
return routes_1.primitive;
|
|
65
|
-
}
|
|
66
|
-
throw new Error('Can\'t build route');
|
|
67
|
-
} // }}}
|
|
68
|
-
function buildTravel(route) {
|
|
69
|
-
if (route.json) {
|
|
70
|
-
return (0, compositors_1.json)(buildRoute(route.json));
|
|
71
|
-
}
|
|
72
|
-
else if (route.rc) {
|
|
73
|
-
return (0, compositors_1.rc)(buildRoute(route.rc));
|
|
74
|
-
}
|
|
75
|
-
else if (route.yaml) {
|
|
76
|
-
return (0, compositors_1.yaml)(buildRoute(route.yaml));
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
throw new Error('Can\'t build route');
|
|
80
|
-
}
|
|
81
|
-
} // }}}
|
|
7
|
+
const build_travel_js_1 = require("../utils/build-travel.js");
|
|
82
8
|
async function configureUpdateFileActions(context) {
|
|
83
9
|
const { update } = context.incomingConfig;
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
context.onMissing = () => 'skip';
|
|
88
|
-
}
|
|
10
|
+
if (update === false) {
|
|
11
|
+
context.onExisting = () => 'skip';
|
|
12
|
+
context.onMissing = () => 'skip';
|
|
89
13
|
}
|
|
90
|
-
else
|
|
91
|
-
const
|
|
92
|
-
const skipExistings = [];
|
|
14
|
+
else {
|
|
15
|
+
const existingActions = [];
|
|
93
16
|
const skipMissings = [];
|
|
94
17
|
const filters = {};
|
|
95
18
|
const routes = {};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
19
|
+
const transformations = {};
|
|
20
|
+
for (const file of update) {
|
|
21
|
+
const { filter, ifExists, ifMissing, pattern, rename, route, transforms } = file;
|
|
22
|
+
if (rename) {
|
|
23
|
+
context.renamedPatterns.push({
|
|
24
|
+
from: pattern,
|
|
25
|
+
to: rename,
|
|
26
|
+
});
|
|
27
|
+
continue;
|
|
100
28
|
}
|
|
101
|
-
if (
|
|
102
|
-
|
|
29
|
+
if (ifMissing === 'skip') {
|
|
30
|
+
skipMissings.push(pattern);
|
|
103
31
|
}
|
|
104
|
-
|
|
105
|
-
|
|
32
|
+
if (ifExists === 'force-merge') {
|
|
33
|
+
existingActions.push({ pattern, action: 'merge' });
|
|
34
|
+
}
|
|
35
|
+
else if (ifExists === 'overwrite') {
|
|
36
|
+
existingActions.push({ pattern, action: 'overwrite' });
|
|
37
|
+
}
|
|
38
|
+
else if (ifExists === 'remove') {
|
|
39
|
+
context.removedPatterns.push(pattern);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
else if (ifExists === 'skip') {
|
|
43
|
+
existingActions.push({ pattern, action: 'skip' });
|
|
106
44
|
}
|
|
107
45
|
if (filter) {
|
|
108
|
-
filters[
|
|
46
|
+
filters[pattern] = filter;
|
|
109
47
|
}
|
|
110
48
|
if (route) {
|
|
111
49
|
const { alias } = route;
|
|
50
|
+
const travel = (0, build_travel_js_1.buildTravel)(route);
|
|
51
|
+
if (travel.fails) {
|
|
52
|
+
return travel;
|
|
53
|
+
}
|
|
112
54
|
if (alias) {
|
|
113
|
-
routes[
|
|
55
|
+
routes[pattern] = {
|
|
114
56
|
alias,
|
|
115
|
-
travel:
|
|
57
|
+
travel: travel.value,
|
|
116
58
|
};
|
|
117
59
|
}
|
|
118
60
|
else {
|
|
119
|
-
routes[
|
|
120
|
-
travel:
|
|
61
|
+
routes[pattern] = {
|
|
62
|
+
travel: travel.value,
|
|
121
63
|
};
|
|
122
64
|
}
|
|
123
65
|
}
|
|
66
|
+
if (transforms) {
|
|
67
|
+
transformations[pattern] = transforms;
|
|
68
|
+
}
|
|
124
69
|
}
|
|
125
70
|
if (skipMissings.length > 0) {
|
|
126
71
|
context.onMissing = (file) => (0, micromatch_1.isMatch)(file, skipMissings) ? 'skip' : 'continue';
|
|
127
72
|
}
|
|
128
|
-
if (
|
|
129
|
-
context.onExisting = (file) =>
|
|
73
|
+
if (existingActions.length > 0) {
|
|
74
|
+
context.onExisting = (file) => {
|
|
75
|
+
for (const { pattern, action } of existingActions) {
|
|
76
|
+
if ((0, micromatch_1.isMatch)(file, pattern)) {
|
|
77
|
+
return action;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return 'merge';
|
|
81
|
+
};
|
|
130
82
|
}
|
|
131
|
-
if (
|
|
83
|
+
if ((0, is_it_type_1.isNonEmptyRecord)(filters)) {
|
|
132
84
|
context.filters = (file) => {
|
|
133
85
|
for (const [pattern, value] of Object.entries(filters)) {
|
|
134
86
|
if ((0, micromatch_1.isMatch)(file, pattern)) {
|
|
@@ -138,7 +90,7 @@ async function configureUpdateFileActions(context) {
|
|
|
138
90
|
return undefined;
|
|
139
91
|
};
|
|
140
92
|
}
|
|
141
|
-
if (
|
|
93
|
+
if ((0, is_it_type_1.isNonEmptyRecord)(routes)) {
|
|
142
94
|
context.routes = (file) => {
|
|
143
95
|
for (const [pattern, route] of Object.entries(routes)) {
|
|
144
96
|
if ((0, micromatch_1.isMatch)(file, pattern)) {
|
|
@@ -148,5 +100,16 @@ async function configureUpdateFileActions(context) {
|
|
|
148
100
|
return undefined;
|
|
149
101
|
};
|
|
150
102
|
}
|
|
103
|
+
if ((0, is_it_type_1.isNonEmptyRecord)(transformations)) {
|
|
104
|
+
context.transforms = (file) => {
|
|
105
|
+
for (const [pattern, transforms] of Object.entries(transformations)) {
|
|
106
|
+
if ((0, micromatch_1.isMatch)(file, pattern)) {
|
|
107
|
+
return transforms;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
151
113
|
}
|
|
114
|
+
return xtry_1.OK;
|
|
152
115
|
}
|
|
@@ -5,37 +5,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.copyBinaryFiles = copyBinaryFiles;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const
|
|
8
|
+
const cli_utils_1 = require("@zokugun/cli-utils");
|
|
9
|
+
const async_1 = __importDefault(require("@zokugun/fs-extra-plus/async"));
|
|
10
|
+
const xtry_1 = require("@zokugun/xtry");
|
|
9
11
|
async function copyBinaryFiles({ binaryFiles, incomingPath, targetPath, onExisting, onMissing, options }) {
|
|
10
12
|
const cwd = path_1.default.join(incomingPath, 'configs');
|
|
11
13
|
for (const file of binaryFiles) {
|
|
12
14
|
const source = path_1.default.join(cwd, file.source);
|
|
13
15
|
const target = path_1.default.join(targetPath, file.target);
|
|
14
|
-
|
|
15
|
-
if (exists) {
|
|
16
|
+
if (await async_1.default.isExisting(target)) {
|
|
16
17
|
switch (onExisting(file.source)) {
|
|
17
|
-
case 'merge':
|
|
18
|
+
case 'merge': {
|
|
18
19
|
break;
|
|
19
|
-
|
|
20
|
+
}
|
|
21
|
+
case 'overwrite': {
|
|
20
22
|
break;
|
|
21
|
-
|
|
23
|
+
}
|
|
24
|
+
case 'skip': {
|
|
22
25
|
continue;
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
else {
|
|
26
30
|
switch (onMissing(file.source)) {
|
|
27
|
-
case 'continue':
|
|
31
|
+
case 'continue': {
|
|
28
32
|
break;
|
|
29
|
-
|
|
33
|
+
}
|
|
34
|
+
case 'skip': {
|
|
30
35
|
continue;
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
if (!options.dryRun) {
|
|
34
|
-
await
|
|
35
|
-
|
|
40
|
+
const ensureResult = await async_1.default.ensureFile(target);
|
|
41
|
+
if (ensureResult.fails) {
|
|
42
|
+
return (0, xtry_1.err)((0, xtry_1.stringifyError)(ensureResult.error));
|
|
43
|
+
}
|
|
44
|
+
const copyResult = await async_1.default.copyFile(source, target);
|
|
45
|
+
if (copyResult.fails) {
|
|
46
|
+
return (0, xtry_1.err)((0, xtry_1.stringifyError)(copyResult.error));
|
|
47
|
+
}
|
|
36
48
|
}
|
|
37
49
|
if (options.verbose) {
|
|
38
|
-
|
|
50
|
+
cli_utils_1.logger.debug(`${file.target} has been written as a binary file`);
|
|
39
51
|
}
|
|
40
52
|
}
|
|
53
|
+
return xtry_1.OK;
|
|
41
54
|
}
|
|
@@ -5,28 +5,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.executeFirstBlock = executeFirstBlock;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const xtry_1 = require("@zokugun/xtry");
|
|
9
|
+
const lodash_es_1 = require("lodash-es");
|
|
10
|
+
const index_js_1 = require("../configs/index.js");
|
|
10
11
|
async function executeFirstBlock(context) {
|
|
11
12
|
const { name, version } = context.incomingPackage;
|
|
12
13
|
const root = String(context.incomingConfig.variants?.root ?? '');
|
|
13
14
|
if (context.incomingVariant) {
|
|
14
15
|
let variant;
|
|
15
16
|
let alias;
|
|
16
|
-
if ((0,
|
|
17
|
+
if ((0, lodash_es_1.isNil)(context.incomingConfig.variants[context.incomingVariant])) {
|
|
17
18
|
variant = context.incomingVariant;
|
|
18
19
|
alias = false;
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
21
|
-
variant =
|
|
22
|
+
variant = context.incomingConfig.variants[context.incomingVariant];
|
|
22
23
|
alias = true;
|
|
23
24
|
}
|
|
24
25
|
const variantPath = node_path_1.default.join(context.packagePath, 'variants', variant);
|
|
25
|
-
const
|
|
26
|
+
const configResult = await (0, index_js_1.readPackageConfig)(variantPath);
|
|
27
|
+
if (configResult.fails) {
|
|
28
|
+
return configResult;
|
|
29
|
+
}
|
|
30
|
+
const variantConfig = configResult.value;
|
|
26
31
|
if (variantConfig.orphan) {
|
|
27
32
|
pushToResult(name, version, variant, alias, context);
|
|
28
33
|
context.incomingConfig = variantConfig;
|
|
29
|
-
await context.commonFlow(name, version, variant, undefined, variantPath, context);
|
|
34
|
+
const result = await context.commonFlow(name, version, variant, undefined, variantPath, context);
|
|
35
|
+
if (result.fails) {
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
39
|
else if (variantConfig.extends) {
|
|
32
40
|
context.blocks.unshift({
|
|
@@ -36,21 +44,24 @@ async function executeFirstBlock(context) {
|
|
|
36
44
|
incomingPath: node_path_1.default.join(context.packagePath, 'variants', variant),
|
|
37
45
|
});
|
|
38
46
|
pushToResult(name, version, variant, alias, context);
|
|
39
|
-
const extend =
|
|
47
|
+
const extend = context.incomingConfig.variants[variantConfig.extends] ?? variantConfig.extends;
|
|
40
48
|
context.incomingVariant = extend;
|
|
41
49
|
return executeFirstBlock(context);
|
|
42
50
|
}
|
|
43
51
|
else {
|
|
44
52
|
if (root.length === 0) {
|
|
45
|
-
|
|
53
|
+
return (0, xtry_1.err)('No root variant has been defined');
|
|
46
54
|
}
|
|
47
55
|
if (root === variant) {
|
|
48
56
|
pushToResult(name, version, variant, alias, context);
|
|
49
57
|
context.incomingConfig = variantConfig;
|
|
50
|
-
await context.commonFlow(name, version, variant, undefined, variantPath, context);
|
|
58
|
+
const result = await context.commonFlow(name, version, variant, undefined, variantPath, context);
|
|
59
|
+
if (result.fails) {
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
51
62
|
}
|
|
52
63
|
else {
|
|
53
|
-
const variant =
|
|
64
|
+
const variant = context.incomingConfig.variants[context.request.variant] ?? context.request.variant;
|
|
54
65
|
context.blocks.unshift({
|
|
55
66
|
name,
|
|
56
67
|
version,
|
|
@@ -60,7 +71,10 @@ async function executeFirstBlock(context) {
|
|
|
60
71
|
pushToResult(name, version, variant, alias, context);
|
|
61
72
|
const incomingPath = node_path_1.default.join(context.packagePath, 'variants', root);
|
|
62
73
|
context.incomingConfig = undefined;
|
|
63
|
-
await context.commonFlow(name, version, root, undefined, incomingPath, context);
|
|
74
|
+
const result = await context.commonFlow(name, version, root, undefined, incomingPath, context);
|
|
75
|
+
if (result.fails) {
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
64
78
|
}
|
|
65
79
|
}
|
|
66
80
|
}
|
|
@@ -68,16 +82,23 @@ async function executeFirstBlock(context) {
|
|
|
68
82
|
context.result = {
|
|
69
83
|
name,
|
|
70
84
|
version,
|
|
71
|
-
|
|
85
|
+
requires: [root],
|
|
72
86
|
};
|
|
73
87
|
const incomingPath = node_path_1.default.join(context.packagePath, 'variants', root);
|
|
74
88
|
context.incomingConfig = undefined;
|
|
75
|
-
await context.commonFlow(name, version, root, undefined, incomingPath, context);
|
|
89
|
+
const result = await context.commonFlow(name, version, root, undefined, incomingPath, context);
|
|
90
|
+
if (result.fails) {
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
76
93
|
}
|
|
77
94
|
else {
|
|
78
95
|
context.result = { name, version };
|
|
79
|
-
await context.commonFlow(name, version, undefined, undefined, context.incomingPath, context);
|
|
96
|
+
const result = await context.commonFlow(name, version, undefined, undefined, context.incomingPath, context);
|
|
97
|
+
if (result.fails) {
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
80
100
|
}
|
|
101
|
+
return xtry_1.OK;
|
|
81
102
|
}
|
|
82
103
|
function pushToResult(name, version, variant, alias, context) {
|
|
83
104
|
context.result ??= {
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeNextBlock = executeNextBlock;
|
|
4
|
-
const
|
|
4
|
+
const xtry_1 = require("@zokugun/xtry");
|
|
5
|
+
const lodash_es_1 = require("lodash-es");
|
|
5
6
|
async function executeNextBlock(context) {
|
|
6
7
|
const block = context.blocks.shift();
|
|
7
|
-
if (!(0,
|
|
8
|
+
if (!(0, lodash_es_1.isNil)(block)) {
|
|
8
9
|
const { name, version, variant, branch, incomingPath } = block;
|
|
9
|
-
await context.commonFlow(name, version, variant, branch, incomingPath, context);
|
|
10
|
+
const result = await context.commonFlow(name, version, variant, branch, incomingPath, context);
|
|
11
|
+
if (result.fails) {
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
10
14
|
}
|
|
15
|
+
return xtry_1.OK;
|
|
11
16
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type CommonFlow, type MainFlow } from '../types/context.js';
|
|
2
|
+
import { type Step } from '../types/step.js';
|
|
3
|
+
import { applyFormatting } from './apply-formatting.js';
|
|
4
|
+
import { configureBranches } from './configure-branches.js';
|
|
5
|
+
import { configureInstallFileActions } from './configure-install-file-actions.js';
|
|
6
|
+
import { configureUninstallFileActions } from './configure-uninstall-file-actions.js';
|
|
7
|
+
import { configureUpdateFileActions } from './configure-update-file-actions.js';
|
|
8
|
+
import { copyBinaryFiles } from './copy-binary-files.js';
|
|
9
|
+
import { executeFirstBlock } from './execute-first-block.js';
|
|
10
|
+
import { executeNextBlock } from './execute-next-block.js';
|
|
11
|
+
import { insertFinalNewLine } from './insert-final-new-line.js';
|
|
12
|
+
import { mergeTextFiles } from './merge-text-files.js';
|
|
13
|
+
import { readEditorConfig } from './read-editor-config.js';
|
|
14
|
+
import { readFiles } from './read-files.js';
|
|
15
|
+
import { readIncomingConfig } from './read-incoming-config.js';
|
|
16
|
+
import { readIncomingPackage } from './read-incoming-package.js';
|
|
17
|
+
import { removeFiles } from './remove-files.js';
|
|
18
|
+
import { renameFiles } from './rename-files.js';
|
|
19
|
+
import { replaceTemplates } from './replace-templates.js';
|
|
20
|
+
import { transformUntouchedFiles } from './transform-untouched-files.js';
|
|
21
|
+
import { unmergeTextFiles } from './unmerge-text-files.js';
|
|
22
|
+
import { validateNewerPackage } from './validate-newer-package.js';
|
|
23
|
+
import { validateNotPresentPackage } from './validate-not-present-package.js';
|
|
24
|
+
import { validatePresentPackage } from './validate-present-package.js';
|
|
25
|
+
import { writeTextFiles } from './write-text-files.js';
|
|
26
|
+
export declare const steps: {
|
|
27
|
+
applyFormatting: typeof applyFormatting;
|
|
28
|
+
configureBranches: typeof configureBranches;
|
|
29
|
+
configureInstallFileActions: typeof configureInstallFileActions;
|
|
30
|
+
configureUninstallFileActions: typeof configureUninstallFileActions;
|
|
31
|
+
configureUpdateFileActions: typeof configureUpdateFileActions;
|
|
32
|
+
copyBinaryFiles: typeof copyBinaryFiles;
|
|
33
|
+
executeFirstBlock: typeof executeFirstBlock;
|
|
34
|
+
executeNextBlock: typeof executeNextBlock;
|
|
35
|
+
insertFinalNewLine: typeof insertFinalNewLine;
|
|
36
|
+
mergeTextFiles: typeof mergeTextFiles;
|
|
37
|
+
readEditorConfig: typeof readEditorConfig;
|
|
38
|
+
readFiles: typeof readFiles;
|
|
39
|
+
readIncomingConfig: typeof readIncomingConfig;
|
|
40
|
+
readIncomingPackage: typeof readIncomingPackage;
|
|
41
|
+
removeFiles: typeof removeFiles;
|
|
42
|
+
renameFiles: typeof renameFiles;
|
|
43
|
+
replaceTemplates: typeof replaceTemplates;
|
|
44
|
+
transformUntouchedFiles: typeof transformUntouchedFiles;
|
|
45
|
+
unmergeTextFiles: typeof unmergeTextFiles;
|
|
46
|
+
validateNewerPackage: typeof validateNewerPackage;
|
|
47
|
+
validateNotPresentPackage: typeof validateNotPresentPackage;
|
|
48
|
+
validatePresentPackage: typeof validatePresentPackage;
|
|
49
|
+
writeTextFiles: typeof writeTextFiles;
|
|
50
|
+
};
|
|
51
|
+
export declare function composeSteps(validations: Step[], processes: Step[]): {
|
|
52
|
+
mainFlow: MainFlow;
|
|
53
|
+
commonFlow: CommonFlow;
|
|
54
|
+
};
|
package/lib/steps/index.js
CHANGED
|
@@ -2,75 +2,93 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.steps = void 0;
|
|
4
4
|
exports.composeSteps = composeSteps;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
5
|
+
const cli_utils_1 = require("@zokugun/cli-utils");
|
|
6
|
+
const xtry_1 = require("@zokugun/xtry");
|
|
7
|
+
const apply_formatting_js_1 = require("./apply-formatting.js");
|
|
8
|
+
const configure_branches_js_1 = require("./configure-branches.js");
|
|
9
|
+
const configure_install_file_actions_js_1 = require("./configure-install-file-actions.js");
|
|
10
|
+
const configure_uninstall_file_actions_js_1 = require("./configure-uninstall-file-actions.js");
|
|
11
|
+
const configure_update_file_actions_js_1 = require("./configure-update-file-actions.js");
|
|
12
|
+
const copy_binary_files_js_1 = require("./copy-binary-files.js");
|
|
13
|
+
const execute_first_block_js_1 = require("./execute-first-block.js");
|
|
14
|
+
const execute_next_block_js_1 = require("./execute-next-block.js");
|
|
15
|
+
const insert_final_new_line_js_1 = require("./insert-final-new-line.js");
|
|
16
|
+
const merge_text_files_js_1 = require("./merge-text-files.js");
|
|
17
|
+
const read_editor_config_js_1 = require("./read-editor-config.js");
|
|
18
|
+
const read_files_js_1 = require("./read-files.js");
|
|
19
|
+
const read_incoming_config_js_1 = require("./read-incoming-config.js");
|
|
20
|
+
const read_incoming_package_js_1 = require("./read-incoming-package.js");
|
|
21
|
+
const remove_files_js_1 = require("./remove-files.js");
|
|
22
|
+
const rename_files_js_1 = require("./rename-files.js");
|
|
23
|
+
const replace_templates_js_1 = require("./replace-templates.js");
|
|
24
|
+
const transform_untouched_files_js_1 = require("./transform-untouched-files.js");
|
|
25
|
+
const unmerge_text_files_js_1 = require("./unmerge-text-files.js");
|
|
26
|
+
const validate_newer_package_js_1 = require("./validate-newer-package.js");
|
|
27
|
+
const validate_not_present_package_js_1 = require("./validate-not-present-package.js");
|
|
28
|
+
const validate_present_package_js_1 = require("./validate-present-package.js");
|
|
29
|
+
const write_text_files_js_1 = require("./write-text-files.js");
|
|
24
30
|
exports.steps = {
|
|
25
|
-
applyFormatting:
|
|
26
|
-
configureBranches:
|
|
27
|
-
configureInstallFileActions:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
applyFormatting: apply_formatting_js_1.applyFormatting,
|
|
32
|
+
configureBranches: configure_branches_js_1.configureBranches,
|
|
33
|
+
configureInstallFileActions: configure_install_file_actions_js_1.configureInstallFileActions,
|
|
34
|
+
configureUninstallFileActions: configure_uninstall_file_actions_js_1.configureUninstallFileActions,
|
|
35
|
+
configureUpdateFileActions: configure_update_file_actions_js_1.configureUpdateFileActions,
|
|
36
|
+
copyBinaryFiles: copy_binary_files_js_1.copyBinaryFiles,
|
|
37
|
+
executeFirstBlock: execute_first_block_js_1.executeFirstBlock,
|
|
38
|
+
executeNextBlock: execute_next_block_js_1.executeNextBlock,
|
|
39
|
+
insertFinalNewLine: insert_final_new_line_js_1.insertFinalNewLine,
|
|
40
|
+
mergeTextFiles: merge_text_files_js_1.mergeTextFiles,
|
|
41
|
+
readEditorConfig: read_editor_config_js_1.readEditorConfig,
|
|
42
|
+
readFiles: read_files_js_1.readFiles,
|
|
43
|
+
readIncomingConfig: read_incoming_config_js_1.readIncomingConfig,
|
|
44
|
+
readIncomingPackage: read_incoming_package_js_1.readIncomingPackage,
|
|
45
|
+
removeFiles: remove_files_js_1.removeFiles,
|
|
46
|
+
renameFiles: rename_files_js_1.renameFiles,
|
|
47
|
+
replaceTemplates: replace_templates_js_1.replaceTemplates,
|
|
48
|
+
transformUntouchedFiles: transform_untouched_files_js_1.transformUntouchedFiles,
|
|
49
|
+
unmergeTextFiles: unmerge_text_files_js_1.unmergeTextFiles,
|
|
50
|
+
validateNewerPackage: validate_newer_package_js_1.validateNewerPackage,
|
|
51
|
+
validateNotPresentPackage: validate_not_present_package_js_1.validateNotPresentPackage,
|
|
52
|
+
validatePresentPackage: validate_present_package_js_1.validatePresentPackage,
|
|
53
|
+
writeTextFiles: write_text_files_js_1.writeTextFiles,
|
|
43
54
|
};
|
|
44
55
|
function composeSteps(validations, processes) {
|
|
45
56
|
const mainFlow = async (targetPath, incomingPath, request, config, options) => {
|
|
46
57
|
const context = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
binaryFiles: [],
|
|
59
|
+
blocks: [],
|
|
60
|
+
commonFlow,
|
|
61
|
+
config,
|
|
62
|
+
filters: () => undefined,
|
|
63
|
+
formats: [],
|
|
50
64
|
incomingPath,
|
|
51
65
|
incomingVariant: request.variant,
|
|
66
|
+
mergedTextFiles: [],
|
|
52
67
|
onExisting: () => 'merge',
|
|
53
68
|
onMissing: () => 'continue',
|
|
54
|
-
|
|
69
|
+
options,
|
|
70
|
+
packagePath: incomingPath,
|
|
71
|
+
removedPatterns: [],
|
|
72
|
+
renamedPatterns: [],
|
|
73
|
+
request,
|
|
55
74
|
routes: () => undefined,
|
|
56
|
-
|
|
75
|
+
targetPath,
|
|
57
76
|
textFiles: [],
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
formats: [],
|
|
61
|
-
config,
|
|
62
|
-
options,
|
|
63
|
-
commonFlow,
|
|
64
|
-
blocks: [],
|
|
77
|
+
transformedFiles: [],
|
|
78
|
+
transforms: () => undefined,
|
|
65
79
|
};
|
|
66
80
|
let skipped = false;
|
|
67
81
|
for (const step of validations) {
|
|
68
|
-
|
|
82
|
+
const result = await step(context);
|
|
83
|
+
if (result.fails) {
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
if (result.value) {
|
|
69
87
|
skipped = true;
|
|
70
88
|
break;
|
|
71
89
|
}
|
|
72
90
|
}
|
|
73
|
-
return skipped ?
|
|
91
|
+
return skipped ? xtry_1.OK_UNDEFINED : (0, xtry_1.ok)(context);
|
|
74
92
|
};
|
|
75
93
|
const commonFlow = async (name, version, variant, branch, incomingPath, mainContext) => {
|
|
76
94
|
if (mainContext.options.verbose) {
|
|
@@ -81,7 +99,7 @@ function composeSteps(validations, processes) {
|
|
|
81
99
|
if (branch) {
|
|
82
100
|
message += ` branch=${branch}`;
|
|
83
101
|
}
|
|
84
|
-
|
|
102
|
+
cli_utils_1.logger.print(cli_utils_1.c.bgBlue(`\n=== ${message} ===\n`));
|
|
85
103
|
}
|
|
86
104
|
const context = {
|
|
87
105
|
...mainContext,
|
|
@@ -102,12 +120,16 @@ function composeSteps(validations, processes) {
|
|
|
102
120
|
};
|
|
103
121
|
let skipped = false;
|
|
104
122
|
for (const step of processes) {
|
|
105
|
-
|
|
123
|
+
const result = await step(context);
|
|
124
|
+
if (result.fails) {
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
if (result.value) {
|
|
106
128
|
skipped = true;
|
|
107
129
|
break;
|
|
108
130
|
}
|
|
109
131
|
}
|
|
110
|
-
return skipped ?
|
|
132
|
+
return skipped ? xtry_1.OK_UNDEFINED : (0, xtry_1.ok)(context);
|
|
111
133
|
};
|
|
112
134
|
return { mainFlow, commonFlow };
|
|
113
135
|
}
|