@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
package/bin/artifact
CHANGED
package/lib/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const commander_1 = require("@zokugun/cli-utils/commander");
|
|
7
7
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
8
|
-
const
|
|
8
|
+
const index_js_1 = require("./commands/index.js");
|
|
9
9
|
const program = new commander_1.Command();
|
|
10
10
|
program
|
|
11
11
|
.version(package_json_1.default.version, '-V, --version')
|
|
@@ -16,17 +16,25 @@ program
|
|
|
16
16
|
.option('-d, --dry-run', 'fake install')
|
|
17
17
|
.option('-v, --verbose', 'output more details')
|
|
18
18
|
.argument('<artifacts...>')
|
|
19
|
-
.action(
|
|
19
|
+
.action(index_js_1.add);
|
|
20
20
|
program
|
|
21
21
|
.command('update')
|
|
22
22
|
.description('update the current project using the installed artifacts')
|
|
23
23
|
.option('-d, --dry-run', 'fake update')
|
|
24
24
|
.option('-v, --verbose', 'output more details')
|
|
25
25
|
.alias('up')
|
|
26
|
-
.action(
|
|
26
|
+
.action(index_js_1.update);
|
|
27
|
+
program
|
|
28
|
+
.command('remove')
|
|
29
|
+
.description('remove an artifact from the current project')
|
|
30
|
+
.option('-d, --dry-run', 'fake uninstall')
|
|
31
|
+
.option('-v, --verbose', 'output more details')
|
|
32
|
+
.argument('<artifacts...>')
|
|
33
|
+
.alias('rm')
|
|
34
|
+
.action(index_js_1.remove);
|
|
27
35
|
program
|
|
28
36
|
.command('list')
|
|
29
37
|
.description('list the installed artifacts in the project')
|
|
30
38
|
.alias('l')
|
|
31
|
-
.action(
|
|
39
|
+
.action(index_js_1.list);
|
|
32
40
|
program.parse();
|
package/lib/commands/add.js
CHANGED
|
@@ -5,69 +5,80 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.add = add;
|
|
7
7
|
const process_1 = __importDefault(require("process"));
|
|
8
|
-
const
|
|
9
|
-
const npm_1 = __importDefault(require("npm"));
|
|
10
|
-
const ora_1 = __importDefault(require("ora"));
|
|
8
|
+
const cli_utils_1 = require("@zokugun/cli-utils");
|
|
11
9
|
const pacote_1 = __importDefault(require("pacote"));
|
|
12
10
|
const tempy_1 = __importDefault(require("tempy"));
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const { mainFlow } = (0,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const index_js_1 = require("../configs/index.js");
|
|
12
|
+
const index_js_2 = require("../steps/index.js");
|
|
13
|
+
const resolve_request_js_1 = require("../utils/resolve-request.js");
|
|
14
|
+
const { mainFlow } = (0, index_js_2.composeSteps)([
|
|
15
|
+
index_js_2.steps.readIncomingPackage,
|
|
16
|
+
index_js_2.steps.validateNotPresentPackage,
|
|
17
|
+
index_js_2.steps.readIncomingConfig,
|
|
18
|
+
index_js_2.steps.executeFirstBlock,
|
|
21
19
|
], [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
index_js_2.steps.readIncomingConfig,
|
|
21
|
+
index_js_2.steps.configureBranches,
|
|
22
|
+
index_js_2.steps.configureInstallFileActions,
|
|
23
|
+
index_js_2.steps.renameFiles,
|
|
24
|
+
index_js_2.steps.readFiles,
|
|
25
|
+
index_js_2.steps.readEditorConfig,
|
|
26
|
+
index_js_2.steps.replaceTemplates,
|
|
27
|
+
index_js_2.steps.mergeTextFiles,
|
|
28
|
+
index_js_2.steps.transformUntouchedFiles,
|
|
29
|
+
index_js_2.steps.insertFinalNewLine,
|
|
30
|
+
index_js_2.steps.applyFormatting,
|
|
31
|
+
index_js_2.steps.copyBinaryFiles,
|
|
32
|
+
index_js_2.steps.writeTextFiles,
|
|
33
|
+
index_js_2.steps.removeFiles,
|
|
34
|
+
index_js_2.steps.executeNextBlock,
|
|
35
35
|
]);
|
|
36
36
|
async function add(specs, inputOptions) {
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const targetPath = process_1.default.env.INIT_CWD;
|
|
37
|
+
cli_utils_1.logger.beginTimer();
|
|
38
|
+
const targetPath = process_1.default.cwd();
|
|
40
39
|
const options = {
|
|
41
40
|
force: inputOptions?.force ?? false,
|
|
42
41
|
skip: inputOptions?.skip ?? false,
|
|
43
42
|
verbose: inputOptions?.verbose ?? false,
|
|
44
43
|
dryRun: inputOptions?.dryRun ?? false,
|
|
45
44
|
};
|
|
46
|
-
const
|
|
45
|
+
const configResult = await (0, index_js_1.readInstallConfig)(targetPath);
|
|
46
|
+
if (configResult.fails) {
|
|
47
|
+
cli_utils_1.logger.fatal(configResult.error);
|
|
48
|
+
}
|
|
49
|
+
const { config, configStats } = configResult.value;
|
|
47
50
|
for (const spec of specs) {
|
|
48
|
-
const
|
|
49
|
-
|
|
51
|
+
const requestResult = (0, resolve_request_js_1.resolveRequest)(spec);
|
|
52
|
+
if (requestResult.fails) {
|
|
53
|
+
cli_utils_1.logger.fatal(requestResult.error);
|
|
54
|
+
}
|
|
55
|
+
const request = requestResult.value;
|
|
56
|
+
const spinner = cli_utils_1.logger.createSpinner(`${cli_utils_1.c.cyan.bold(request.name)}`);
|
|
50
57
|
const dir = tempy_1.default.directory();
|
|
51
|
-
const pkgResult = await pacote_1.default.extract(request.name, dir
|
|
58
|
+
const pkgResult = await pacote_1.default.extract(request.name, dir);
|
|
52
59
|
if (!pkgResult.resolved) {
|
|
53
60
|
if (options.force || options.skip) {
|
|
54
61
|
spinner.fail();
|
|
55
62
|
if (options.verbose) {
|
|
56
|
-
|
|
63
|
+
cli_utils_1.logger.warn(`The artifact '${spec}' couldn't be found, skipping...`);
|
|
57
64
|
}
|
|
58
65
|
continue;
|
|
59
66
|
}
|
|
60
67
|
else {
|
|
61
|
-
|
|
68
|
+
cli_utils_1.logger.fatal(pkgResult.from);
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
71
|
const flowResult = await mainFlow(targetPath, dir, request, config, options);
|
|
65
|
-
if (
|
|
72
|
+
if (flowResult.fails) {
|
|
73
|
+
cli_utils_1.logger.fatal(flowResult.error);
|
|
74
|
+
}
|
|
75
|
+
if (!flowResult.value?.result) {
|
|
66
76
|
spinner.succeed();
|
|
67
77
|
continue;
|
|
68
78
|
}
|
|
69
|
-
(0,
|
|
70
|
-
await (0,
|
|
79
|
+
(0, index_js_1.updateInstallConfig)(config, flowResult.value.result);
|
|
80
|
+
await (0, index_js_1.writeInstallConfig)(config, configStats, flowResult.value.formats, targetPath, options);
|
|
71
81
|
spinner.succeed();
|
|
72
82
|
}
|
|
83
|
+
cli_utils_1.logger.finishTimer();
|
|
73
84
|
}
|
package/lib/commands/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.update = exports.list = exports.add = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "add", { enumerable: true, get: function () { return
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "list", { enumerable: true, get: function () { return
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "
|
|
3
|
+
exports.update = exports.remove = exports.list = exports.add = void 0;
|
|
4
|
+
var add_js_1 = require("./add.js");
|
|
5
|
+
Object.defineProperty(exports, "add", { enumerable: true, get: function () { return add_js_1.add; } });
|
|
6
|
+
var list_js_1 = require("./list.js");
|
|
7
|
+
Object.defineProperty(exports, "list", { enumerable: true, get: function () { return list_js_1.list; } });
|
|
8
|
+
var remove_js_1 = require("./remove.js");
|
|
9
|
+
Object.defineProperty(exports, "remove", { enumerable: true, get: function () { return remove_js_1.remove; } });
|
|
10
|
+
var update_js_1 = require("./update.js");
|
|
11
|
+
Object.defineProperty(exports, "update", { enumerable: true, get: function () { return update_js_1.update; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function list(): Promise<void>;
|
package/lib/commands/list.js
CHANGED
|
@@ -5,10 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.list = list;
|
|
7
7
|
const process_1 = __importDefault(require("process"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const cli_utils_1 = require("@zokugun/cli-utils");
|
|
9
|
+
const lodash_es_1 = require("lodash-es");
|
|
10
|
+
const index_js_1 = require("../configs/index.js");
|
|
10
11
|
function formatVariant(artifact) {
|
|
11
|
-
const variant = Array.isArray(artifact.requires) ? (0,
|
|
12
|
+
const variant = Array.isArray(artifact.requires) ? (0, lodash_es_1.last)(artifact.requires) ?? '' : '';
|
|
12
13
|
if (variant.length > 0) {
|
|
13
14
|
return `:${variant}`;
|
|
14
15
|
}
|
|
@@ -18,17 +19,21 @@ function formatVariant(artifact) {
|
|
|
18
19
|
}
|
|
19
20
|
async function list() {
|
|
20
21
|
const targetPath = process_1.default.env.INIT_CWD;
|
|
21
|
-
const
|
|
22
|
+
const configResult = await (0, index_js_1.readInstallConfig)(targetPath);
|
|
23
|
+
if (configResult.fails) {
|
|
24
|
+
cli_utils_1.logger.fatal(configResult.error);
|
|
25
|
+
}
|
|
26
|
+
const { config, configStats } = configResult.value;
|
|
22
27
|
const artifacts = Object.entries(config.artifacts);
|
|
23
28
|
if (artifacts.length === 0) {
|
|
24
|
-
|
|
29
|
+
cli_utils_1.logger.info('No artifacts have been installed.');
|
|
25
30
|
}
|
|
26
31
|
else {
|
|
27
|
-
|
|
32
|
+
cli_utils_1.logger.info(`List of installed artifacts (${configStats.name}):\n`);
|
|
28
33
|
for (const [name, artifact] of artifacts) {
|
|
29
34
|
const version = artifact.version ? `@${artifact.version}` : '';
|
|
30
|
-
|
|
35
|
+
cli_utils_1.logger.info(`- ${name}${version}${formatVariant(artifact)}`);
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
|
-
|
|
38
|
+
cli_utils_1.logger.newLine();
|
|
34
39
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.remove = remove;
|
|
7
|
+
const process_1 = __importDefault(require("process"));
|
|
8
|
+
const cli_utils_1 = require("@zokugun/cli-utils");
|
|
9
|
+
const pacote_1 = __importDefault(require("pacote"));
|
|
10
|
+
const tempy_1 = __importDefault(require("tempy"));
|
|
11
|
+
const index_js_1 = require("../configs/index.js");
|
|
12
|
+
const index_js_2 = require("../steps/index.js");
|
|
13
|
+
const resolve_request_js_1 = require("../utils/resolve-request.js");
|
|
14
|
+
const { mainFlow } = (0, index_js_2.composeSteps)([
|
|
15
|
+
index_js_2.steps.readIncomingPackage,
|
|
16
|
+
index_js_2.steps.validatePresentPackage,
|
|
17
|
+
index_js_2.steps.readIncomingConfig,
|
|
18
|
+
index_js_2.steps.executeFirstBlock,
|
|
19
|
+
], [
|
|
20
|
+
index_js_2.steps.readIncomingConfig,
|
|
21
|
+
index_js_2.steps.configureBranches,
|
|
22
|
+
index_js_2.steps.configureUninstallFileActions,
|
|
23
|
+
index_js_2.steps.unmergeTextFiles,
|
|
24
|
+
index_js_2.steps.transformUntouchedFiles,
|
|
25
|
+
index_js_2.steps.insertFinalNewLine,
|
|
26
|
+
index_js_2.steps.applyFormatting,
|
|
27
|
+
index_js_2.steps.writeTextFiles,
|
|
28
|
+
index_js_2.steps.removeFiles,
|
|
29
|
+
index_js_2.steps.executeNextBlock,
|
|
30
|
+
]);
|
|
31
|
+
async function remove(specs, inputOptions) {
|
|
32
|
+
cli_utils_1.logger.beginTimer();
|
|
33
|
+
const targetPath = process_1.default.cwd();
|
|
34
|
+
const options = {
|
|
35
|
+
force: inputOptions?.force ?? false,
|
|
36
|
+
skip: inputOptions?.skip ?? false,
|
|
37
|
+
verbose: inputOptions?.verbose ?? false,
|
|
38
|
+
dryRun: inputOptions?.dryRun ?? false,
|
|
39
|
+
};
|
|
40
|
+
const configResult = await (0, index_js_1.readInstallConfig)(targetPath);
|
|
41
|
+
if (configResult.fails) {
|
|
42
|
+
cli_utils_1.logger.fatal(configResult.error);
|
|
43
|
+
}
|
|
44
|
+
const { config, configStats } = configResult.value;
|
|
45
|
+
for (const spec of specs) {
|
|
46
|
+
const requestResult = (0, resolve_request_js_1.resolveRequest)(spec);
|
|
47
|
+
if (requestResult.fails) {
|
|
48
|
+
cli_utils_1.logger.fatal(requestResult.error);
|
|
49
|
+
}
|
|
50
|
+
const request = requestResult.value;
|
|
51
|
+
const spinner = cli_utils_1.logger.createSpinner(`${cli_utils_1.c.cyan.bold(request.name)}`);
|
|
52
|
+
const dir = tempy_1.default.directory();
|
|
53
|
+
const pkgResult = await pacote_1.default.extract(request.name, dir);
|
|
54
|
+
if (!pkgResult.resolved) {
|
|
55
|
+
if (options.force || options.skip) {
|
|
56
|
+
spinner.fail();
|
|
57
|
+
if (options.verbose) {
|
|
58
|
+
cli_utils_1.logger.debug(`The artifact '${spec}' couldn't be found, skipping...`);
|
|
59
|
+
}
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
cli_utils_1.logger.fatal(pkgResult.from);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const flowResult = await mainFlow(targetPath, dir, request, config, options);
|
|
67
|
+
if (flowResult.fails) {
|
|
68
|
+
cli_utils_1.logger.fatal(flowResult.error);
|
|
69
|
+
}
|
|
70
|
+
if (!flowResult.value?.result) {
|
|
71
|
+
spinner.succeed();
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
(0, index_js_1.updateUninstallConfig)(config, flowResult.value.result);
|
|
75
|
+
await (0, index_js_1.writeInstallConfig)(config, configStats, flowResult.value.formats, targetPath, options);
|
|
76
|
+
spinner.succeed();
|
|
77
|
+
}
|
|
78
|
+
cli_utils_1.logger.finishTimer();
|
|
79
|
+
}
|
package/lib/commands/update.js
CHANGED
|
@@ -5,72 +5,76 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.update = update;
|
|
7
7
|
const process_1 = __importDefault(require("process"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const npm_1 = __importDefault(require("npm"));
|
|
11
|
-
const ora_1 = __importDefault(require("ora"));
|
|
8
|
+
const cli_utils_1 = require("@zokugun/cli-utils");
|
|
9
|
+
const lodash_es_1 = require("lodash-es");
|
|
12
10
|
const pacote_1 = __importDefault(require("pacote"));
|
|
13
11
|
const tempy_1 = __importDefault(require("tempy"));
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
steps_1.steps.executeFirstBlock,
|
|
12
|
+
const index_js_1 = require("../configs/index.js");
|
|
13
|
+
const index_js_2 = require("../steps/index.js");
|
|
14
|
+
const { mainFlow } = (0, index_js_2.composeSteps)([
|
|
15
|
+
index_js_2.steps.readIncomingPackage,
|
|
16
|
+
index_js_2.steps.validateNewerPackage,
|
|
17
|
+
index_js_2.steps.readIncomingConfig,
|
|
18
|
+
index_js_2.steps.executeFirstBlock,
|
|
22
19
|
], [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
index_js_2.steps.readIncomingConfig,
|
|
21
|
+
index_js_2.steps.configureBranches,
|
|
22
|
+
index_js_2.steps.configureUpdateFileActions,
|
|
23
|
+
index_js_2.steps.renameFiles,
|
|
24
|
+
index_js_2.steps.readFiles,
|
|
25
|
+
index_js_2.steps.readEditorConfig,
|
|
26
|
+
index_js_2.steps.replaceTemplates,
|
|
27
|
+
index_js_2.steps.mergeTextFiles,
|
|
28
|
+
index_js_2.steps.transformUntouchedFiles,
|
|
29
|
+
index_js_2.steps.insertFinalNewLine,
|
|
30
|
+
index_js_2.steps.applyFormatting,
|
|
31
|
+
index_js_2.steps.copyBinaryFiles,
|
|
32
|
+
index_js_2.steps.writeTextFiles,
|
|
33
|
+
index_js_2.steps.removeFiles,
|
|
34
|
+
index_js_2.steps.executeNextBlock,
|
|
36
35
|
]);
|
|
37
36
|
async function update(inputOptions) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
await npm_1.default.load();
|
|
41
|
-
const registry = npm_1.default.config.get('registry');
|
|
42
|
-
const targetPath = process_1.default.env.INIT_CWD;
|
|
37
|
+
cli_utils_1.logger.beginTimer();
|
|
38
|
+
const targetPath = process_1.default.cwd();
|
|
43
39
|
const options = {
|
|
44
40
|
force: inputOptions?.force ?? false,
|
|
45
41
|
skip: false,
|
|
46
42
|
verbose: inputOptions?.verbose ?? false,
|
|
47
43
|
dryRun: inputOptions?.dryRun ?? false,
|
|
48
44
|
};
|
|
49
|
-
const
|
|
45
|
+
const configResult = await (0, index_js_1.readInstallConfig)(targetPath);
|
|
46
|
+
if (configResult.fails) {
|
|
47
|
+
cli_utils_1.logger.fatal(configResult.error);
|
|
48
|
+
}
|
|
49
|
+
const { config, configStats } = configResult.value;
|
|
50
50
|
for (const [name, artifact] of Object.entries(config.artifacts)) {
|
|
51
|
-
const spinner =
|
|
51
|
+
const spinner = cli_utils_1.logger.createSpinner(`${cli_utils_1.c.cyan.bold(name)}`);
|
|
52
52
|
const dir = tempy_1.default.directory();
|
|
53
|
-
const pkgResult = await pacote_1.default.extract(name, dir
|
|
53
|
+
const pkgResult = await pacote_1.default.extract(name, dir);
|
|
54
54
|
if (!pkgResult.resolved) {
|
|
55
55
|
if (options.force) {
|
|
56
56
|
spinner.fail();
|
|
57
57
|
if (options.verbose) {
|
|
58
|
-
|
|
58
|
+
cli_utils_1.logger.debug(`The artifact '${name}' couldn't be found, skipping...`);
|
|
59
59
|
}
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
|
|
63
|
+
cli_utils_1.logger.fatal(pkgResult.from);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
const request = artifact.requires ? { name, variant: (0,
|
|
66
|
+
const request = artifact.requires ? { name, variant: (0, lodash_es_1.last)(artifact.requires) } : { name };
|
|
67
67
|
const flowResult = await mainFlow(targetPath, dir, request, config, options);
|
|
68
|
-
if (
|
|
68
|
+
if (flowResult.fails) {
|
|
69
|
+
cli_utils_1.logger.fatal(flowResult.error);
|
|
70
|
+
}
|
|
71
|
+
if (!flowResult.value?.result) {
|
|
69
72
|
spinner.succeed();
|
|
70
73
|
continue;
|
|
71
74
|
}
|
|
72
|
-
(0,
|
|
73
|
-
await (0,
|
|
75
|
+
(0, index_js_1.updateInstallConfig)(config, flowResult.value.result);
|
|
76
|
+
await (0, index_js_1.writeInstallConfig)(config, configStats, flowResult.value.formats, targetPath, options);
|
|
74
77
|
spinner.succeed();
|
|
75
78
|
}
|
|
79
|
+
cli_utils_1.logger.finishTimer();
|
|
76
80
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compose = compose;
|
|
4
|
-
const
|
|
5
|
-
function apply(map, keys, current, incoming, result) {
|
|
4
|
+
const lodash_es_1 = require("lodash-es");
|
|
5
|
+
async function apply(map, keys, current, incoming, result) {
|
|
6
6
|
if (keys.length === 0) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
@@ -10,14 +10,14 @@ function apply(map, keys, current, incoming, result) {
|
|
|
10
10
|
for (const key of keys) {
|
|
11
11
|
const currentValue = current[key];
|
|
12
12
|
const transform = map[key] ?? map.$$default;
|
|
13
|
-
if (!transform || !(0,
|
|
14
|
-
if (!(0,
|
|
13
|
+
if (!transform || !(0, lodash_es_1.has)(incoming, key) || ignores.includes(key)) {
|
|
14
|
+
if (!(0, lodash_es_1.isNil)(currentValue)) {
|
|
15
15
|
result[key] = currentValue;
|
|
16
16
|
}
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
19
|
const incomingValue = incoming[key];
|
|
20
|
-
result[key] = transform({
|
|
20
|
+
result[key] = await transform({
|
|
21
21
|
current: currentValue,
|
|
22
22
|
incoming: incomingValue,
|
|
23
23
|
ignores: map.$$ignore,
|
|
@@ -25,26 +25,26 @@ function apply(map, keys, current, incoming, result) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function compose(map) {
|
|
28
|
-
return ({ current, incoming, filters }) => {
|
|
29
|
-
if ((0,
|
|
28
|
+
return async ({ current, incoming, filters }) => {
|
|
29
|
+
if ((0, lodash_es_1.isNil)(incoming)) {
|
|
30
30
|
return current ?? {};
|
|
31
31
|
}
|
|
32
|
-
if ((0,
|
|
32
|
+
if ((0, lodash_es_1.isNil)(current) || typeof current !== typeof incoming) {
|
|
33
33
|
return incoming;
|
|
34
34
|
}
|
|
35
35
|
const currentKeys = Object.keys(current);
|
|
36
36
|
const incomingKeys = Object.keys(incoming);
|
|
37
|
-
const newKeys = (0,
|
|
37
|
+
const newKeys = (0, lodash_es_1.without)(incomingKeys, ...currentKeys);
|
|
38
38
|
if (filters) {
|
|
39
39
|
const result = { ...current };
|
|
40
|
-
apply(map, filters, current, incoming, result);
|
|
41
|
-
apply(map, newKeys, current, incoming, result);
|
|
40
|
+
await apply(map, filters, current, incoming, result);
|
|
41
|
+
await apply(map, newKeys, current, incoming, result);
|
|
42
42
|
return result;
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
45
|
const result = {};
|
|
46
|
-
apply(map, currentKeys, current, incoming, result);
|
|
47
|
-
apply(map, newKeys, current, incoming, result);
|
|
46
|
+
await apply(map, currentKeys, current, incoming, result);
|
|
47
|
+
await apply(map, newKeys, current, incoming, result);
|
|
48
48
|
return result;
|
|
49
49
|
}
|
|
50
50
|
};
|
package/lib/compositors/fork.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fork = fork;
|
|
4
4
|
function fork(...cases) {
|
|
5
|
-
return ({ current, incoming }) => {
|
|
5
|
+
return async ({ current, incoming }) => {
|
|
6
6
|
const targetCase = cases.find((c) => {
|
|
7
|
-
if (
|
|
8
|
-
return c;
|
|
7
|
+
if (Array.isArray(c)) {
|
|
8
|
+
return c[0](current ?? incoming);
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
|
-
return c
|
|
11
|
+
return c;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
if (!targetCase) {
|
package/lib/compositors/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.yaml = exports.rc = exports.mapSort = exports.json = exports.fork = exports.compose = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "fork", { enumerable: true, get: function () { return
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "json", { enumerable: true, get: function () { return
|
|
10
|
-
var
|
|
11
|
-
Object.defineProperty(exports, "mapSort", { enumerable: true, get: function () { return
|
|
12
|
-
var
|
|
13
|
-
Object.defineProperty(exports, "rc", { enumerable: true, get: function () { return
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "yaml", { enumerable: true, get: function () { return
|
|
4
|
+
var compose_js_1 = require("./compose.js");
|
|
5
|
+
Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return compose_js_1.compose; } });
|
|
6
|
+
var fork_js_1 = require("./fork.js");
|
|
7
|
+
Object.defineProperty(exports, "fork", { enumerable: true, get: function () { return fork_js_1.fork; } });
|
|
8
|
+
var json_js_1 = require("./json.js");
|
|
9
|
+
Object.defineProperty(exports, "json", { enumerable: true, get: function () { return json_js_1.json; } });
|
|
10
|
+
var map_sort_js_1 = require("./map-sort.js");
|
|
11
|
+
Object.defineProperty(exports, "mapSort", { enumerable: true, get: function () { return map_sort_js_1.mapSort; } });
|
|
12
|
+
var rc_js_1 = require("./rc.js");
|
|
13
|
+
Object.defineProperty(exports, "rc", { enumerable: true, get: function () { return rc_js_1.rc; } });
|
|
14
|
+
var yaml_js_1 = require("./yaml.js");
|
|
15
|
+
Object.defineProperty(exports, "yaml", { enumerable: true, get: function () { return yaml_js_1.yaml; } });
|