@zokugun/artifact 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +122 -37
  2. package/lib/cli.js +8 -2
  3. package/lib/commands/add.js +37 -44
  4. package/lib/commands/index.js +3 -1
  5. package/lib/commands/list.js +46 -0
  6. package/lib/commands/update.js +34 -20
  7. package/lib/compositors/compose.js +7 -12
  8. package/lib/compositors/fork.js +1 -2
  9. package/lib/compositors/json.js +18 -9
  10. package/lib/compositors/map-sort.js +1 -2
  11. package/lib/compositors/rc.js +18 -9
  12. package/lib/compositors/yaml.js +18 -9
  13. package/lib/configs/index.js +18 -0
  14. package/lib/configs/install/index.js +9 -0
  15. package/lib/configs/install/read-install-config.js +120 -0
  16. package/lib/configs/install/update-install-config.js +15 -0
  17. package/lib/{config/write-config.js → configs/install/write-install-config.js} +8 -9
  18. package/lib/configs/package/index.js +5 -0
  19. package/lib/{config/read-config.js → configs/package/read-package-config.js} +14 -32
  20. package/lib/journeys/config.ts/index.js +11 -0
  21. package/lib/journeys/index.js +3 -2
  22. package/lib/journeys/package/index.js +0 -1
  23. package/lib/parsers/json.js +2 -3
  24. package/lib/parsers/jsonc/parse.js +2 -3
  25. package/lib/parsers/jsonc/stringify.js +1 -2
  26. package/lib/parsers/yaml.js +2 -3
  27. package/lib/routes/command.js +1 -2
  28. package/lib/routes/lines-concat.js +1 -2
  29. package/lib/routes/list-concat.js +1 -2
  30. package/lib/routes/list-sort-concat.js +1 -2
  31. package/lib/routes/map-concat.js +1 -2
  32. package/lib/routes/overwrite.js +1 -2
  33. package/lib/routes/primitive.js +1 -2
  34. package/lib/steps/apply-formatting.js +5 -6
  35. package/lib/steps/configure-branches.js +69 -0
  36. package/lib/steps/configure-install-file-actions.js +151 -0
  37. package/lib/steps/{validate-updatability.js → configure-update-file-actions.js} +9 -10
  38. package/lib/steps/copy-binary-files.js +21 -13
  39. package/lib/steps/execute-first-block.js +112 -0
  40. package/lib/steps/execute-next-block.js +22 -0
  41. package/lib/steps/index.js +47 -9
  42. package/lib/steps/insert-final-new-line.js +3 -4
  43. package/lib/steps/merge-text-files.js +65 -36
  44. package/lib/steps/read-editor-config.js +22 -13
  45. package/lib/steps/read-files.js +3 -4
  46. package/lib/steps/read-incoming-config.js +9 -5
  47. package/lib/steps/read-incoming-package.js +12 -4
  48. package/lib/steps/remove-files.js +40 -0
  49. package/lib/steps/replace-templates.js +3 -4
  50. package/lib/steps/validate-newer-package.js +4 -5
  51. package/lib/steps/validate-not-present-package.js +4 -5
  52. package/lib/steps/write-text-files.js +3 -4
  53. package/lib/types/format.js +1 -1
  54. package/lib/utils/build-journey-plan.js +1 -2
  55. package/lib/utils/build-travel-plan.js +1 -2
  56. package/lib/utils/command/join-command.js +1 -2
  57. package/lib/utils/command/split-command.js +1 -2
  58. package/lib/utils/dev-null.js +1 -2
  59. package/lib/utils/read-buffer.js +5 -8
  60. package/lib/utils/resolve-request.js +42 -0
  61. package/lib/utils/template.js +21 -10
  62. package/lib/utils/to-lines.js +1 -2
  63. package/lib/utils/trim-final-newline.js +1 -2
  64. package/lib/utils/try-json.js +1 -2
  65. package/package.json +6 -4
  66. package/lib/config/index.js +0 -7
package/README.md CHANGED
@@ -7,10 +7,15 @@
7
7
  [![License](https://img.shields.io/badge/donate-liberapay-green)](https://liberapay.com/daiyam/donate)
8
8
  [![License](https://img.shields.io/badge/donate-paypal-green)](https://paypal.me/daiyam99)
9
9
 
10
- `artifact` is a command-line interface which allows you:
11
- - to boilerplate your project from multiple packages
12
- - to merge the duplicated configuration files found across the packages
13
- - to keep your configurations up to date
10
+ `artifact` is a CLI for boilerplating your project by composing reusable config packages, merging overlapping files, and keeping every artifact in sync with a single update command.
11
+
12
+ Why artifact
13
+ ------------
14
+
15
+ - Compose curated configuration packages ("artifacts") published on npm and mix several of them into a single repo.
16
+ - Merge overlapping files intelligently using the built-in routes/steps pipeline.
17
+ - Keep artifacts synchronized by running `artifact update`, optionally in CI with `--verbose` for traceability.
18
+ - Support variant-aware installs and branch overlays so packages can expose multiple flavors while staying DRY.
14
19
 
15
20
  Mergeable Files
16
21
  ---------------
@@ -20,66 +25,146 @@ Mergeable Files
20
25
  - `*.yaml`
21
26
  - `*ignore`
22
27
  - `*rc` (YAML, JSON or JSONC)
28
+ - `*.config.ts`
23
29
 
24
- Getting Started
25
- ---------------
30
+ Installation
31
+ ------------
26
32
 
27
- With [node](http://nodejs.org) previously installed:
33
+ Choose the install mode that fits your workflow:
28
34
 
29
- npm install -g @zokugun/artifact
35
+ - **Global CLI** (recommended when you apply artifacts across many repos):
30
36
 
37
+ ```bash
38
+ npm install -g @zokugun/artifact
39
+ ```
31
40
 
32
- Add the configuration packages:
41
+ - **Project-local CLI** (handy for repo-specific automation):
33
42
 
34
- ```
35
- artifact add @daiyam/lang-js @daiyam/lang-ts @daiyam/npm-ts
36
- ```
43
+ ```bash
44
+ npm install -D @zokugun/artifact
45
+ npx artifact --help
46
+ ```
47
+
48
+ Quick Start
49
+ -----------
50
+
51
+ 1. **Install the CLI** (globally or locally as shown in [Installation](#installation)).
52
+ 2. **Add the artifacts you want to compose**:
53
+
54
+ ```bash
55
+ artifact add @daiyam/lang-js @daiyam/lang-ts @daiyam/npm @daiyam/npm-ts
56
+ ```
57
+
58
+ The command above installs the following packages:
59
+ - [@daiyam/artifact-lang-js](https://github.com/daiyam/artifact-configs/tree/master/packages/lang-js)
60
+ - [@daiyam/artifact-lang-ts](https://github.com/daiyam/artifact-configs/tree/master/packages/lang-ts)
61
+ - [@daiyam/artifact-npm](https://github.com/daiyam/artifact-configs/tree/master/packages/npm)
62
+ - [@daiyam/artifact-npm-ts](https://github.com/daiyam/artifact-configs/tree/master/packages/npm-ts)
63
+
64
+ 3. **Inspect the git diff** created by the install. Keep overrides you like, discard unwanted changes, then rerun `artifact update` whenever upstream packages change.
65
+
66
+ Artifacts published to npm must be prefixed with `artifact-`.
67
+
68
+ Command Reference
69
+ -----------------
70
+
71
+ ### `artifact add`
72
+
73
+ Registers and applies one or more artifacts in the current project.
74
+
75
+ - Syntax: `artifact add <artifact...> [options]`
76
+ - Useful flags: `-v, --verbose` to show detailed install output.
77
+ - Artifacts are stored in a `.artifactrc*` so subsequent updates know which packages to pull.
78
+
79
+ `<artifact>` can be `name` or `name:variant`.
80
+
81
+ ### `artifact list` / `artifact l`
37
82
 
38
- With the previous command, `artifact` will pull the following packages:
39
- - [@daiyam/artifact-lang-js](https://github.com/daiyam/artifact-configs/tree/master/packages/lang-js)
40
- - [@daiyam/artifact-lang-ts](https://github.com/daiyam/artifact-configs/tree/master/packages/lang-ts)
41
- - [@daiyam/artifact-npm-ts](https://github.com/daiyam/artifact-configs/tree/master/packages/npm-ts)
83
+ Shows the artifacts currently tracked in `.artifactrc*`, including versions and, when available, requested variants.
42
84
 
43
- Like `yeoman`, a configuration package must be prefixed with `artifact-`.
85
+ - Syntax: `artifact list`
86
+ - Alias: `artifact l`
87
+ - Output: prints each artifact as `name@version:variant`.
44
88
 
45
- Configuration Package
46
- ---------------------
89
+ ### `artifact update` / `artifact up`
90
+
91
+ Applies or refreshes the files provided by each installed artifact. Re-run it whenever upstream packages change.
92
+
93
+ - Syntax: `artifact update [options]`
94
+ - Alias: `artifact up`
95
+ - Advanced: pass `-v, --verbose` for an execution trace of routes, variants, and branches.
96
+ - Artifact authors can control how updates behave via `.artifactrc` files shipped inside their artifacts.
97
+
98
+ #### Best practices
99
+
100
+ Inspect the git diff after running to keep intentional overrides and drop unwanted changes.
101
+
102
+ Core Concepts
103
+ -------------
104
+
105
+ The next sections dive deeper into the primitives that make `artifact` powerful: templating, variants, and branch overlays.
106
+
107
+ Artifact Layout
108
+ ---------------
47
109
 
48
110
  The configuration/boilerplate files must be put inside the folder `configs`.
49
111
 
50
- For example, the package [@daiyam/artifact-lang-js](https://github.com/daiyam/artifact-configs/tree/master/packages/lang-js):
112
+ For example, the package [@daiyam/artifact-npm-cli-ts](https://github.com/daiyam/artifact-configs/tree/master/packages/npm-cli-ts):
51
113
 
52
114
  ```
53
- artifact-configs/lang-js/
115
+ npm-cli-ts/
54
116
  ├── configs/
55
- │ ├── .commitlintrc.yml
56
- ├── .editorconfig
57
- │ ├── .lintstagedrc
58
- │ ├── gitignore
117
+ │ ├── bin/
118
+ │ └── #[[package.json.name]]
119
+ │ ├── bin/
120
+ ├── command/
121
+ │ │ │ └── hello.ts
122
+ │ │ └── cli.ts
123
+ │ ├── npmignore // => .npmignore
59
124
  │ ├── package.json
60
- │ └── ...
61
125
  ├── LICENSE
62
126
  ├── package.json
63
127
  └── README.md
64
128
  ```
65
129
 
66
- Update
67
- ------
130
+ Looking to build your own artifact? See [Authoring artifacts](docs/authoring-artifacts.md) for a step-by-step authoring guide.
68
131
 
69
- Update your configurations with the command:
132
+ Templating
133
+ ----------
70
134
 
71
- ```
72
- artifact update
73
- ```
135
+ During installs and updates, `artifact` runs every text file (and file name) through a template engine.
136
+ Anywhere you place `#[[path/to/file.ext.property]]`, the engine:
137
+ - loads that JSON/YAML file from the target project,
138
+ - reads the property,
139
+ - and substitutes the value—perfect for wiring the target's `package.json.name`, license, or runtime settings into generated files.
140
+
141
+ You can also emit timestamps with helpers like `#[[date.utc]]`.
142
+
143
+ Read [docs/templating.md](docs/templating.md) for full syntax.
144
+
145
+ Variants
146
+ --------
147
+
148
+ Variants let an artifact expose multiple named flavors of its configuration (for example `14`, `20`, `stable`, `next`).
149
+ Consumers can request a variant in their install config, while package authors declare defaults and remap keys via `.artifactrc`.
150
+
151
+ See [docs/variants.md](docs/variants.md) for a full walkthrough, including examples of how to structure the `variants` folder.
152
+
153
+ Branches
154
+ --------
74
155
 
75
- It is **recommended** to review the changes and manually revert any bad changes.
156
+ Branches are lightweight conditional overlays that live under `branches/[artifactName]` (or `[artifactName:variant]`).
157
+ They activate only when the matching artifact (and optional variant) is present, letting you ship targeted tweaks like per-language `.nvmrc` files without duplicating whole packages.
76
158
 
77
- Furthermore, a configuration package can control how to apply an update via the file `.artifactrc`.
159
+ Learn more in [docs/branches.md](docs/branches.md), including matching rules and best practices for layering branches after variants.
78
160
 
79
- Yeoman
80
- ------
161
+ More Documentation
162
+ ------------------
81
163
 
82
- `artifact` can be used in a yeoman generator. Ex: [@daiyam/generator-new-project](https://github.com/daiyam/generator-new-project)
164
+ - [Authoring artifacts](docs/authoring-artifacts.md)
165
+ - [Templating guide](docs/templating.md)
166
+ - [Variants guide](docs/variants.md)
167
+ - [Branches guide](docs/branches.md)
83
168
 
84
169
  Donations
85
170
  ---------
package/lib/cli.js CHANGED
@@ -8,7 +8,7 @@ const package_json_1 = __importDefault(require("../package.json"));
8
8
  const commands_1 = require("./commands");
9
9
  const program = new commander_1.Command();
10
10
  program
11
- .version(package_json_1.default.version, '-v, --version')
11
+ .version(package_json_1.default.version, '-V, --version')
12
12
  .description(package_json_1.default.description);
13
13
  program
14
14
  .command('add')
@@ -18,7 +18,13 @@ program
18
18
  .action(commands_1.add);
19
19
  program
20
20
  .command('update')
21
- .description('update the current project using the installed artifact')
21
+ .description('update the current project using the installed artifacts')
22
22
  .option('-v, --verbose', 'output more details')
23
+ .alias('up')
23
24
  .action(commands_1.update);
25
+ program
26
+ .command('list')
27
+ .description('list the installed artifacts in the project')
28
+ .alias('l')
29
+ .action(commands_1.list);
24
30
  program.parse();
@@ -12,36 +12,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.add = void 0;
15
+ exports.add = add;
16
16
  const process_1 = __importDefault(require("process"));
17
+ const ansi_colors_1 = require("ansi-colors");
17
18
  const npm_1 = __importDefault(require("npm"));
19
+ const ora_1 = __importDefault(require("ora"));
18
20
  const pacote_1 = __importDefault(require("pacote"));
19
21
  const tempy_1 = __importDefault(require("tempy"));
20
- const config_1 = require("../config");
22
+ const configs_1 = require("../configs");
21
23
  const steps_1 = require("../steps");
22
- const commonFlow = (0, steps_1.composeSteps)(steps_1.steps.readIncomingPackage, steps_1.steps.validateNotPresentPackage, steps_1.steps.readFiles, steps_1.steps.readEditorConfig, steps_1.steps.replaceTemplates, steps_1.steps.mergeTextFiles, steps_1.steps.insertFinalNewLine, steps_1.steps.applyFormatting, steps_1.steps.copyBinaryFiles, steps_1.steps.writeTextFiles);
23
- function expandSpec(spec) {
24
- if (spec.includes('/')) {
25
- const [scope, name] = spec.split('/');
26
- if (name.startsWith('artifact-')) {
27
- return spec;
28
- }
29
- else {
30
- return `${scope}/artifact-${name}`;
31
- }
32
- }
33
- else {
34
- if (spec.startsWith('artifact-')) {
35
- return spec;
36
- }
37
- else {
38
- return `artifact-${spec}`;
39
- }
40
- }
41
- } // }}}
24
+ const resolve_request_1 = require("../utils/resolve-request");
25
+ const { mainFlow } = (0, steps_1.composeSteps)([
26
+ steps_1.steps.readIncomingPackage,
27
+ steps_1.steps.validateNotPresentPackage,
28
+ steps_1.steps.readIncomingConfig,
29
+ steps_1.steps.executeFirstBlock,
30
+ ], [
31
+ steps_1.steps.readIncomingConfig,
32
+ steps_1.steps.configureBranches,
33
+ steps_1.steps.configureInstallFileActions,
34
+ steps_1.steps.readFiles,
35
+ steps_1.steps.readEditorConfig,
36
+ steps_1.steps.replaceTemplates,
37
+ steps_1.steps.mergeTextFiles,
38
+ steps_1.steps.insertFinalNewLine,
39
+ steps_1.steps.applyFormatting,
40
+ steps_1.steps.copyBinaryFiles,
41
+ steps_1.steps.writeTextFiles,
42
+ steps_1.steps.removeFiles,
43
+ steps_1.steps.executeNextBlock,
44
+ ]);
42
45
  function add(specs, inputOptions) {
43
- var _a, _b, _c;
44
46
  return __awaiter(this, void 0, void 0, function* () {
47
+ var _a, _b, _c;
45
48
  yield npm_1.default.load();
46
49
  const registry = npm_1.default.config.get('registry');
47
50
  const targetPath = process_1.default.env.INIT_CWD;
@@ -50,12 +53,15 @@ function add(specs, inputOptions) {
50
53
  skip: (_b = inputOptions === null || inputOptions === void 0 ? void 0 : inputOptions.skip) !== null && _b !== void 0 ? _b : false,
51
54
  verbose: (_c = inputOptions === null || inputOptions === void 0 ? void 0 : inputOptions.verbose) !== null && _c !== void 0 ? _c : false,
52
55
  };
53
- const [config, configStats] = yield (0, config_1.readConfig)(targetPath);
56
+ const { config, configStats } = yield (0, configs_1.readInstallConfig)(targetPath);
54
57
  for (const spec of specs) {
58
+ const request = (0, resolve_request_1.resolveRequest)(spec);
59
+ const spinner = (0, ora_1.default)(`${ansi_colors_1.cyan.bold(request.name)}`).start();
55
60
  const dir = tempy_1.default.directory();
56
- const pkgResult = yield pacote_1.default.extract(expandSpec(spec), dir, { registry });
61
+ const pkgResult = yield pacote_1.default.extract(request.name, dir, { registry });
57
62
  if (!pkgResult.resolved) {
58
63
  if (options.force || options.skip) {
64
+ spinner.fail();
59
65
  if (options.verbose) {
60
66
  console.log(`The artifact '${spec}' couldn't be found, skipping...`);
61
67
  }
@@ -65,27 +71,14 @@ function add(specs, inputOptions) {
65
71
  throw new Error(pkgResult.from);
66
72
  }
67
73
  }
68
- const flowResult = yield commonFlow(targetPath, dir, config, options);
69
- if (!flowResult) {
74
+ const flowResult = yield mainFlow(targetPath, dir, request, config, options);
75
+ if (!flowResult || !flowResult.result) {
76
+ spinner.succeed();
70
77
  continue;
71
78
  }
72
- const { name, version } = flowResult.incomingPackage;
73
- let nf = true;
74
- for (const artifact of config.artifacts) {
75
- if (artifact.name === name) {
76
- artifact.version = version;
77
- nf = false;
78
- break;
79
- }
80
- }
81
- if (nf) {
82
- config.artifacts.push({
83
- name,
84
- version,
85
- });
86
- }
87
- yield (0, config_1.writeConfig)(config, configStats, flowResult.formats, targetPath, options);
79
+ (0, configs_1.updateInstallConfig)(config, flowResult.result);
80
+ yield (0, configs_1.writeInstallConfig)(config, configStats, flowResult.formats, targetPath, options);
81
+ spinner.succeed();
88
82
  }
89
83
  });
90
84
  }
91
- exports.add = add;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.update = exports.add = void 0;
3
+ exports.update = exports.list = exports.add = void 0;
4
4
  var add_1 = require("./add");
5
5
  Object.defineProperty(exports, "add", { enumerable: true, get: function () { return add_1.add; } });
6
+ var list_1 = require("./list");
7
+ Object.defineProperty(exports, "list", { enumerable: true, get: function () { return list_1.list; } });
6
8
  var update_1 = require("./update");
7
9
  Object.defineProperty(exports, "update", { enumerable: true, get: function () { return update_1.update; } });
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.list = list;
16
+ const process_1 = __importDefault(require("process"));
17
+ const lodash_1 = require("lodash");
18
+ const configs_1 = require("../configs");
19
+ function formatVariant(artifact) {
20
+ var _a;
21
+ const variant = Array.isArray(artifact.requires) ? (_a = (0, lodash_1.last)(artifact.requires)) !== null && _a !== void 0 ? _a : '' : '';
22
+ if (variant.length > 0) {
23
+ return `:${variant}`;
24
+ }
25
+ else {
26
+ return '';
27
+ }
28
+ }
29
+ function list() {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const targetPath = process_1.default.env.INIT_CWD;
32
+ const { config, configStats } = yield (0, configs_1.readInstallConfig)(targetPath);
33
+ const artifacts = Object.entries(config.artifacts);
34
+ if (artifacts.length === 0) {
35
+ console.log('No artifacts have been installed.');
36
+ }
37
+ else {
38
+ console.log(`List of installed artifacts (${configStats.name}):\n`);
39
+ for (const [name, artifact] of artifacts) {
40
+ const version = artifact.version ? `@${artifact.version}` : '';
41
+ console.log(`- ${name}${version}${formatVariant(artifact)}`);
42
+ }
43
+ }
44
+ console.log();
45
+ });
46
+ }
@@ -12,20 +12,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.update = void 0;
15
+ exports.update = update;
16
16
  const process_1 = __importDefault(require("process"));
17
17
  const ansi_colors_1 = require("ansi-colors");
18
+ const lodash_1 = require("lodash");
18
19
  const npm_1 = __importDefault(require("npm"));
19
20
  const ora_1 = __importDefault(require("ora"));
20
21
  const pacote_1 = __importDefault(require("pacote"));
21
22
  const tempy_1 = __importDefault(require("tempy"));
22
- const config_1 = require("../config");
23
+ const configs_1 = require("../configs");
23
24
  const steps_1 = require("../steps");
24
25
  const dev_null_1 = require("../utils/dev-null");
25
- const commonFlow = (0, steps_1.composeSteps)(steps_1.steps.readIncomingPackage, steps_1.steps.validateNewerPackage, steps_1.steps.readIncomingConfig, steps_1.steps.validateUpdatability, steps_1.steps.readFiles, steps_1.steps.readEditorConfig, steps_1.steps.replaceTemplates, steps_1.steps.mergeTextFiles, steps_1.steps.insertFinalNewLine, steps_1.steps.applyFormatting, steps_1.steps.copyBinaryFiles, steps_1.steps.writeTextFiles);
26
+ const { mainFlow } = (0, steps_1.composeSteps)([
27
+ steps_1.steps.readIncomingPackage,
28
+ steps_1.steps.validateNewerPackage,
29
+ steps_1.steps.readIncomingConfig,
30
+ steps_1.steps.executeFirstBlock,
31
+ ], [
32
+ steps_1.steps.readIncomingConfig,
33
+ steps_1.steps.configureBranches,
34
+ steps_1.steps.configureUpdateFileActions,
35
+ steps_1.steps.readFiles,
36
+ steps_1.steps.readEditorConfig,
37
+ steps_1.steps.replaceTemplates,
38
+ steps_1.steps.mergeTextFiles,
39
+ steps_1.steps.insertFinalNewLine,
40
+ steps_1.steps.applyFormatting,
41
+ steps_1.steps.copyBinaryFiles,
42
+ steps_1.steps.writeTextFiles,
43
+ steps_1.steps.removeFiles,
44
+ steps_1.steps.executeNextBlock,
45
+ ]);
26
46
  function update(inputOptions) {
27
- var _a, _b;
28
47
  return __awaiter(this, void 0, void 0, function* () {
48
+ var _a, _b;
29
49
  // @ts-expect-error log property isn't exposed
30
50
  npm_1.default.log.stream = (0, dev_null_1.createDevNull)();
31
51
  yield npm_1.default.load();
@@ -36,16 +56,16 @@ function update(inputOptions) {
36
56
  skip: false,
37
57
  verbose: (_b = inputOptions === null || inputOptions === void 0 ? void 0 : inputOptions.verbose) !== null && _b !== void 0 ? _b : false,
38
58
  };
39
- const [config, configStats] = yield (0, config_1.readConfig)(targetPath);
40
- for (const artifact of config.artifacts) {
41
- const spinner = (0, ora_1.default)(`${ansi_colors_1.cyan.bold(artifact.name)}`).start();
59
+ const { config, configStats } = yield (0, configs_1.readInstallConfig)(targetPath);
60
+ for (const [name, artifact] of Object.entries(config.artifacts)) {
61
+ const spinner = (0, ora_1.default)(`${ansi_colors_1.cyan.bold(name)}`).start();
42
62
  const dir = tempy_1.default.directory();
43
- const pkgResult = yield pacote_1.default.extract(artifact.name, dir, { registry });
63
+ const pkgResult = yield pacote_1.default.extract(name, dir, { registry });
44
64
  if (!pkgResult.resolved) {
45
65
  if (options.force) {
46
66
  spinner.fail();
47
67
  if (options.verbose) {
48
- console.log(`The artifact '${artifact.name}' couldn't be found, skipping...`);
68
+ console.log(`The artifact '${name}' couldn't be found, skipping...`);
49
69
  }
50
70
  continue;
51
71
  }
@@ -53,21 +73,15 @@ function update(inputOptions) {
53
73
  throw new Error(pkgResult.from);
54
74
  }
55
75
  }
56
- const flowResult = yield commonFlow(targetPath, dir, config, options);
57
- if (!flowResult) {
76
+ const request = artifact.requires ? { name, variant: (0, lodash_1.last)(artifact.requires) } : { name };
77
+ const flowResult = yield mainFlow(targetPath, dir, request, config, options);
78
+ if (!flowResult || !flowResult.result) {
58
79
  spinner.succeed();
59
80
  continue;
60
81
  }
61
- const { name, version } = flowResult.incomingPackage;
62
- for (const artifact of config.artifacts) {
63
- if (artifact.name === name) {
64
- artifact.version = version;
65
- break;
66
- }
67
- }
68
- yield (0, config_1.writeConfig)(config, configStats, flowResult.formats, targetPath, options);
82
+ (0, configs_1.updateInstallConfig)(config, flowResult.result);
83
+ yield (0, configs_1.writeInstallConfig)(config, configStats, flowResult.formats, targetPath, options);
69
84
  spinner.succeed();
70
85
  }
71
86
  });
72
87
  }
73
- exports.update = update;
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.compose = void 0;
7
- const has_1 = __importDefault(require("lodash/has"));
8
- const without_1 = __importDefault(require("lodash/without"));
3
+ exports.compose = compose;
4
+ const lodash_1 = require("lodash");
9
5
  function apply(map, keys, current, incoming, result) {
10
6
  var _a, _b;
11
7
  if (keys.length === 0) {
@@ -15,8 +11,8 @@ function apply(map, keys, current, incoming, result) {
15
11
  for (const key of keys) {
16
12
  const currentValue = current[key];
17
13
  const transform = (_b = map[key]) !== null && _b !== void 0 ? _b : map.$$default;
18
- if (!transform || !(0, has_1.default)(incoming, key) || ignores.includes(key)) {
19
- if (currentValue !== undefined) {
14
+ if (!transform || !(0, lodash_1.has)(incoming, key) || ignores.includes(key)) {
15
+ if (!(0, lodash_1.isNil)(currentValue)) {
20
16
  result[key] = currentValue;
21
17
  }
22
18
  continue;
@@ -31,15 +27,15 @@ function apply(map, keys, current, incoming, result) {
31
27
  }
32
28
  function compose(map) {
33
29
  return ({ current, incoming, filters }) => {
34
- if (incoming === undefined) {
30
+ if ((0, lodash_1.isNil)(incoming)) {
35
31
  return current !== null && current !== void 0 ? current : {};
36
32
  }
37
- if (current === undefined || typeof current !== typeof incoming) {
33
+ if ((0, lodash_1.isNil)(current) || typeof current !== typeof incoming) {
38
34
  return incoming;
39
35
  }
40
36
  const currentKeys = Object.keys(current);
41
37
  const incomingKeys = Object.keys(incoming);
42
- const newKeys = (0, without_1.default)(incomingKeys, ...currentKeys);
38
+ const newKeys = (0, lodash_1.without)(incomingKeys, ...currentKeys);
43
39
  if (filters) {
44
40
  const result = Object.assign({}, current);
45
41
  apply(map, filters, current, incoming, result);
@@ -54,4 +50,3 @@ function compose(map) {
54
50
  }
55
51
  };
56
52
  }
57
- exports.compose = compose;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fork = void 0;
3
+ exports.fork = fork;
4
4
  function fork(...cases) {
5
5
  return ({ current, incoming }) => {
6
6
  const targetCase = cases.find((c) => {
@@ -18,4 +18,3 @@ function fork(...cases) {
18
18
  return targetMerge({ current, incoming });
19
19
  };
20
20
  }
21
- exports.fork = fork;
@@ -15,15 +15,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.json = void 0;
36
+ exports.json = json;
27
37
  const lodash_1 = require("lodash");
28
38
  const JSON = __importStar(require("../parsers/json"));
29
39
  const JSONC = __importStar(require("../parsers/jsonc"));
@@ -57,4 +67,3 @@ function json(...routes) {
57
67
  }
58
68
  };
59
69
  }
60
- exports.json = json;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapSort = void 0;
3
+ exports.mapSort = mapSort;
4
4
  const { compare } = new Intl.Collator('en');
5
5
  function mapSort(route) {
6
6
  return (args) => {
@@ -13,4 +13,3 @@ function mapSort(route) {
13
13
  return sorted;
14
14
  };
15
15
  }
16
- exports.mapSort = mapSort;
@@ -15,15 +15,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.rc = void 0;
36
+ exports.rc = rc;
27
37
  const lodash_1 = require("lodash");
28
38
  const JSON = __importStar(require("../parsers/json"));
29
39
  const YAML = __importStar(require("../parsers/yaml"));
@@ -47,4 +57,3 @@ function rc(...routes) {
47
57
  }
48
58
  };
49
59
  }
50
- exports.rc = rc;