@zokugun/artifact 0.5.1 → 0.6.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/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 +123 -80
- 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 +17 -9
- 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 +159 -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 +68 -0
- package/lib/configs/utils/normalize-file-always.d.ts +3 -0
- package/lib/configs/utils/normalize-file-always.js +28 -0
- package/lib/configs/utils/normalize-file-uninstall.d.ts +3 -0
- package/lib/configs/utils/normalize-file-uninstall.js +31 -0
- package/lib/configs/utils/normalize-file-upsert.d.ts +3 -0
- package/lib/configs/utils/normalize-file-upsert.js +54 -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 +19 -15
- 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 +41 -86
- package/lib/steps/configure-uninstall-file-actions.d.ts +3 -0
- package/lib/steps/configure-uninstall-file-actions.js +53 -0
- package/lib/steps/configure-update-file-actions.d.ts +3 -0
- package/lib/steps/configure-update-file-actions.js +64 -97
- 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 +41 -27
- 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 +19 -8
- 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 +73 -0
- package/lib/steps/unmerge-text-files.d.ts +3 -0
- package/lib/steps/unmerge-text-files.js +63 -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 +58 -0
- package/lib/types/context.d.ts +56 -0
- package/lib/types/format.d.ts +10 -0
- package/lib/types/step.d.ts +3 -0
- package/lib/types/text-file.d.ts +7 -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 +34 -25
- 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 +5 -0
- package/lib/utils/detect-indent.js +60 -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 +123 -101
- package/lib/utils/dev-null.js +0 -7
|
@@ -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
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AsyncDResult } from '@zokugun/xtry';
|
|
2
|
+
import { type TextFile } from '../types/text-file.js';
|
|
3
|
+
export declare function insertFinalNewLine({ mergedTextFiles, transformedFiles }: {
|
|
4
|
+
mergedTextFiles: TextFile[];
|
|
5
|
+
transformedFiles?: TextFile[];
|
|
6
|
+
}): AsyncDResult;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.insertFinalNewLine = insertFinalNewLine;
|
|
4
|
-
|
|
4
|
+
const xtry_1 = require("@zokugun/xtry");
|
|
5
|
+
async function insertFinalNewLine({ mergedTextFiles, transformedFiles }) {
|
|
5
6
|
for (const file of mergedTextFiles) {
|
|
6
7
|
if (file.finalNewLine) {
|
|
7
8
|
const withFinalNewLine = file.data.endsWith('\n');
|
|
@@ -10,4 +11,15 @@ async function insertFinalNewLine({ mergedTextFiles }) {
|
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
}
|
|
14
|
+
if (transformedFiles) {
|
|
15
|
+
for (const file of transformedFiles) {
|
|
16
|
+
if (file.finalNewLine) {
|
|
17
|
+
const withFinalNewLine = file.data.endsWith('\n');
|
|
18
|
+
if (!withFinalNewLine) {
|
|
19
|
+
file.data = `${file.data}\n`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return xtry_1.OK;
|
|
13
25
|
}
|
|
@@ -5,58 +5,67 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.mergeTextFiles = mergeTextFiles;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
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");
|
|
11
|
+
const index_js_1 = require("../journeys/index.js");
|
|
12
|
+
async function mergeTextFiles({ targetPath, textFiles, mergedTextFiles, onExisting, onMissing, filters, routes, transforms, options }) {
|
|
11
13
|
for (const file of textFiles) {
|
|
12
14
|
if (options.verbose) {
|
|
13
|
-
|
|
15
|
+
cli_utils_1.logger.debug(`${file.name} is going to be merged`);
|
|
14
16
|
}
|
|
15
|
-
const journey = routes(file.name) ?? (0,
|
|
17
|
+
const journey = routes(file.name) ?? (0, index_js_1.getJourney)(file.name);
|
|
16
18
|
if (!journey) {
|
|
17
19
|
if (options.verbose) {
|
|
18
|
-
|
|
20
|
+
cli_utils_1.logger.debug(`${file.name}, no merger has been found`);
|
|
19
21
|
}
|
|
20
22
|
const filePath = path_1.default.join(targetPath, file.name);
|
|
21
|
-
|
|
22
|
-
if (exists) {
|
|
23
|
+
if (await async_1.default.isExisting(filePath)) {
|
|
23
24
|
switch (onExisting(file.name)) {
|
|
24
|
-
case 'merge':
|
|
25
|
+
case 'merge': {
|
|
25
26
|
break;
|
|
26
|
-
|
|
27
|
+
}
|
|
28
|
+
case 'overwrite': {
|
|
27
29
|
break;
|
|
28
|
-
|
|
30
|
+
}
|
|
31
|
+
case 'skip': {
|
|
29
32
|
continue;
|
|
33
|
+
}
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
else {
|
|
33
37
|
switch (onMissing(file.name)) {
|
|
34
|
-
case 'continue':
|
|
38
|
+
case 'continue': {
|
|
35
39
|
break;
|
|
36
|
-
|
|
40
|
+
}
|
|
41
|
+
case 'skip': {
|
|
37
42
|
continue;
|
|
43
|
+
}
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
mergedTextFiles.push(file);
|
|
41
47
|
if (options.verbose) {
|
|
42
|
-
|
|
48
|
+
cli_utils_1.logger.debug(`${file.name} has been copied`);
|
|
43
49
|
}
|
|
44
50
|
continue;
|
|
45
51
|
}
|
|
46
52
|
if (options.verbose) {
|
|
47
|
-
|
|
53
|
+
cli_utils_1.logger.debug(`${file.name}, a merger has been found`);
|
|
48
54
|
}
|
|
49
55
|
const fileName = journey.alias ? path_1.default.join(path_1.default.dirname(file.name), journey.alias) : file.name;
|
|
50
56
|
const filePath = path_1.default.join(targetPath, fileName);
|
|
51
|
-
|
|
52
|
-
if (exists) {
|
|
57
|
+
if (await async_1.default.isExisting(filePath)) {
|
|
53
58
|
switch (onExisting(file.name)) {
|
|
54
59
|
case 'merge': {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
const current = await async_1.default.readFile(filePath, 'utf8');
|
|
61
|
+
if (current.fails) {
|
|
62
|
+
return (0, xtry_1.err)((0, xtry_1.stringifyError)(current.error));
|
|
63
|
+
}
|
|
64
|
+
const data = await journey.travel({
|
|
65
|
+
current: current.value,
|
|
58
66
|
incoming: file.data,
|
|
59
67
|
filters: filters(file.name),
|
|
68
|
+
transforms: transforms(file.name),
|
|
60
69
|
});
|
|
61
70
|
mergedTextFiles.push({
|
|
62
71
|
name: fileName,
|
|
@@ -65,34 +74,39 @@ async function mergeTextFiles({ targetPath, textFiles, mergedTextFiles, onExisti
|
|
|
65
74
|
mode: file.mode,
|
|
66
75
|
});
|
|
67
76
|
if (options.verbose) {
|
|
68
|
-
|
|
77
|
+
cli_utils_1.logger.debug(`${file.name} has been merged`);
|
|
69
78
|
}
|
|
70
79
|
break;
|
|
71
80
|
}
|
|
72
|
-
case 'overwrite':
|
|
81
|
+
case 'overwrite': {
|
|
73
82
|
mergedTextFiles.push(file);
|
|
74
83
|
if (options.verbose) {
|
|
75
|
-
|
|
84
|
+
cli_utils_1.logger.debug(`${file.name} has been overwritten`);
|
|
76
85
|
}
|
|
77
86
|
continue;
|
|
78
|
-
|
|
87
|
+
}
|
|
88
|
+
case 'skip': {
|
|
79
89
|
continue;
|
|
90
|
+
}
|
|
80
91
|
}
|
|
81
92
|
}
|
|
82
93
|
else {
|
|
83
94
|
switch (onMissing(file.name)) {
|
|
84
|
-
case 'continue':
|
|
95
|
+
case 'continue': {
|
|
85
96
|
mergedTextFiles.push({
|
|
86
97
|
...file,
|
|
87
98
|
name: fileName,
|
|
88
99
|
});
|
|
89
100
|
if (options.verbose) {
|
|
90
|
-
|
|
101
|
+
cli_utils_1.logger.debug(`${file.name} has been copied`);
|
|
91
102
|
}
|
|
92
103
|
continue;
|
|
93
|
-
|
|
104
|
+
}
|
|
105
|
+
case 'skip': {
|
|
94
106
|
continue;
|
|
107
|
+
}
|
|
95
108
|
}
|
|
96
109
|
}
|
|
97
110
|
}
|
|
111
|
+
return xtry_1.OK;
|
|
98
112
|
}
|