@zokugun/artifact 0.3.0 → 0.4.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.
Files changed (36) hide show
  1. package/README.md +124 -37
  2. package/lib/cli.js +10 -2
  3. package/lib/commands/add.js +35 -41
  4. package/lib/commands/index.js +3 -1
  5. package/lib/commands/list.js +47 -0
  6. package/lib/commands/update.js +32 -17
  7. package/lib/compositors/compose.js +6 -10
  8. package/lib/configs/index.js +18 -0
  9. package/lib/configs/install/index.js +9 -0
  10. package/lib/configs/install/read-install-config.js +121 -0
  11. package/lib/configs/install/update-install-config.js +16 -0
  12. package/lib/{config/write-config.js → configs/install/write-install-config.js} +8 -8
  13. package/lib/configs/package/index.js +5 -0
  14. package/lib/{config/read-config.js → configs/package/read-package-config.js} +15 -32
  15. package/lib/journeys/config.ts/index.js +11 -0
  16. package/lib/journeys/index.js +2 -0
  17. package/lib/journeys/package/index.js +0 -1
  18. package/lib/parsers/jsonc/parse.js +1 -1
  19. package/lib/steps/apply-formatting.js +2 -2
  20. package/lib/steps/configure-branches.js +70 -0
  21. package/lib/steps/configure-install-file-actions.js +152 -0
  22. package/lib/steps/{validate-updatability.js → configure-update-file-actions.js} +10 -10
  23. package/lib/steps/copy-binary-files.js +19 -10
  24. package/lib/steps/execute-first-block.js +113 -0
  25. package/lib/steps/execute-next-block.js +23 -0
  26. package/lib/steps/index.js +45 -7
  27. package/lib/steps/merge-text-files.js +61 -31
  28. package/lib/steps/read-incoming-config.js +8 -3
  29. package/lib/steps/read-incoming-package.js +11 -2
  30. package/lib/steps/remove-files.js +41 -0
  31. package/lib/steps/validate-newer-package.js +1 -1
  32. package/lib/steps/validate-not-present-package.js +1 -1
  33. package/lib/utils/resolve-request.js +43 -0
  34. package/lib/utils/template.js +4 -3
  35. package/package.json +5 -3
  36. 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,148 @@ 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
+ Artifact requires [Node.js](http://nodejs.org) 18+.
49
+
50
+ Quick Start
51
+ -----------
52
+
53
+ 1. **Install the CLI** (globally or locally as shown in [Installation](#installation)).
54
+ 2. **Add the artifacts you want to compose**:
55
+
56
+ ```bash
57
+ artifact add @daiyam/lang-js @daiyam/lang-ts @daiyam/npm @daiyam/npm-ts
58
+ ```
59
+
60
+ The command above installs the following packages:
61
+ - [@daiyam/artifact-lang-js](https://github.com/daiyam/artifact-configs/tree/master/packages/lang-js)
62
+ - [@daiyam/artifact-lang-ts](https://github.com/daiyam/artifact-configs/tree/master/packages/lang-ts)
63
+ - [@daiyam/artifact-npm](https://github.com/daiyam/artifact-configs/tree/master/packages/npm)
64
+ - [@daiyam/artifact-npm-ts](https://github.com/daiyam/artifact-configs/tree/master/packages/npm-ts)
65
+
66
+ 3. **Inspect the git diff** created by the install. Keep overrides you like, discard unwanted changes, then rerun `artifact update` whenever upstream packages change.
67
+
68
+ Artifacts published to npm must be prefixed with `artifact-`.
69
+
70
+ Command Reference
71
+ -----------------
72
+
73
+ ### `artifact add`
74
+
75
+ Registers and applies one or more artifacts in the current project.
76
+
77
+ - Syntax: `artifact add <artifact...> [options]`
78
+ - Useful flags: `-v, --verbose` to show detailed install output.
79
+ - Artifacts are stored in a `.artifactrc*` so subsequent updates know which packages to pull.
80
+
81
+ `<artifact>` can be `name` or `name:variant`.
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
+ ### `artifact list` / `artifact l`
42
84
 
43
- Like `yeoman`, a configuration package must be prefixed with `artifact-`.
85
+ Shows the artifacts currently tracked in `.artifactrc*`, including versions and, when available, requested variants.
44
86
 
45
- Configuration Package
46
- ---------------------
87
+ - Syntax: `artifact list`
88
+ - Alias: `artifact l`
89
+ - Output: prints each artifact as `name@version:variant`.
90
+
91
+ ### `artifact update` / `artifact up`
92
+
93
+ Applies or refreshes the files provided by each installed artifact. Re-run it whenever upstream packages change.
94
+
95
+ - Syntax: `artifact update [options]`
96
+ - Alias: `artifact up`
97
+ - Advanced: pass `-v, --verbose` for an execution trace of routes, variants, and branches.
98
+ - Artifact authors can control how updates behave via `.artifactrc` files shipped inside their artifacts.
99
+
100
+ #### Best practices
101
+
102
+ Inspect the git diff after running to keep intentional overrides and drop unwanted changes.
103
+
104
+ Core Concepts
105
+ -------------
106
+
107
+ The next sections dive deeper into the primitives that make `artifact` powerful: templating, variants, and branch overlays.
108
+
109
+ Artifact Layout
110
+ ---------------
47
111
 
48
112
  The configuration/boilerplate files must be put inside the folder `configs`.
49
113
 
50
- For example, the package [@daiyam/artifact-lang-js](https://github.com/daiyam/artifact-configs/tree/master/packages/lang-js):
114
+ For example, the package [@daiyam/artifact-npm-cli-ts](https://github.com/daiyam/artifact-configs/tree/master/packages/npm-cli-ts):
51
115
 
52
116
  ```
53
- artifact-configs/lang-js/
117
+ npm-cli-ts/
54
118
  ├── configs/
55
- │ ├── .commitlintrc.yml
56
- ├── .editorconfig
57
- │ ├── .lintstagedrc
58
- │ ├── gitignore
119
+ │ ├── bin/
120
+ │ └── #[[package.json.name]]
121
+ │ ├── bin/
122
+ ├── command/
123
+ │ │ │ └── hello.ts
124
+ │ │ └── cli.ts
125
+ │ ├── npmignore // => .npmignore
59
126
  │ ├── package.json
60
- │ └── ...
61
127
  ├── LICENSE
62
128
  ├── package.json
63
129
  └── README.md
64
130
  ```
65
131
 
66
- Update
67
- ------
132
+ Looking to build your own artifact? See [Authoring artifacts](docs/authoring-artifacts.md) for a step-by-step authoring guide.
68
133
 
69
- Update your configurations with the command:
134
+ Templating
135
+ ----------
70
136
 
71
- ```
72
- artifact update
73
- ```
137
+ During installs and updates, `artifact` runs every text file (and file name) through a template engine.
138
+ Anywhere you place `#[[path/to/file.ext.property]]`, the engine:
139
+ - loads that JSON/YAML file from the target project,
140
+ - reads the property,
141
+ - and substitutes the value—perfect for wiring the target's `package.json.name`, license, or runtime settings into generated files.
142
+
143
+ You can also emit timestamps with helpers like `#[[date.utc]]`.
144
+
145
+ Read [docs/templating.md](docs/templating.md) for full syntax.
146
+
147
+ Variants
148
+ --------
149
+
150
+ Variants let an artifact expose multiple named flavors of its configuration (for example `14`, `20`, `stable`, `next`).
151
+ Consumers can request a variant in their install config, while package authors declare defaults and remap keys via `.artifactrc`.
152
+
153
+ See [docs/variants.md](docs/variants.md) for a full walkthrough, including examples of how to structure the `variants` folder.
154
+
155
+ Branches
156
+ --------
74
157
 
75
- It is **recommended** to review the changes and manually revert any bad changes.
158
+ Branches are lightweight conditional overlays that live under `branches/[artifactName]` (or `[artifactName:variant]`).
159
+ 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
160
 
77
- Furthermore, a configuration package can control how to apply an update via the file `.artifactrc`.
161
+ Learn more in [docs/branches.md](docs/branches.md), including matching rules and best practices for layering branches after variants.
78
162
 
79
- Yeoman
80
- ------
163
+ More Documentation
164
+ ------------------
81
165
 
82
- `artifact` can be used in a yeoman generator. Ex: [@daiyam/generator-new-project](https://github.com/daiyam/generator-new-project)
166
+ - [Authoring artifacts](docs/authoring-artifacts.md)
167
+ - [Templating guide](docs/templating.md)
168
+ - [Variants guide](docs/variants.md)
169
+ - [Branches guide](docs/branches.md)
83
170
 
84
171
  Donations
85
172
  ---------
package/lib/cli.js CHANGED
@@ -7,7 +7,9 @@ const commander_1 = require("commander");
7
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
- program.version(package_json_1.default.version);
10
+ program
11
+ .version(package_json_1.default.version, '-V, --version')
12
+ .description(package_json_1.default.description);
11
13
  program
12
14
  .command('add')
13
15
  .description('add an artifact to the current project')
@@ -16,7 +18,13 @@ program
16
18
  .action(commands_1.add);
17
19
  program
18
20
  .command('update')
19
- .description('update the current project using the installed artifact')
21
+ .description('update the current project using the installed artifacts')
20
22
  .option('-v, --verbose', 'output more details')
23
+ .alias('up')
21
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);
22
30
  program.parse();
@@ -14,31 +14,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.add = void 0;
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
46
  var _a, _b, _c;
44
47
  return __awaiter(this, void 0, void 0, function* () {
@@ -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,26 +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
  }
@@ -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,47 @@
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 = void 0;
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
+ }
47
+ exports.list = list;
@@ -15,14 +15,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.update = void 0;
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.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
47
  var _a, _b;
28
48
  return __awaiter(this, void 0, void 0, function* () {
@@ -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,19 +73,14 @@ 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
  });
@@ -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
3
  exports.compose = void 0;
7
- const has_1 = __importDefault(require("lodash/has"));
8
- const without_1 = __importDefault(require("lodash/without"));
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);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./install"), exports);
18
+ __exportStar(require("./package"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateInstallConfig = exports.writeInstallConfig = exports.readInstallConfig = void 0;
4
+ var read_install_config_1 = require("./read-install-config");
5
+ Object.defineProperty(exports, "readInstallConfig", { enumerable: true, get: function () { return read_install_config_1.readInstallConfig; } });
6
+ var write_install_config_1 = require("./write-install-config");
7
+ Object.defineProperty(exports, "writeInstallConfig", { enumerable: true, get: function () { return write_install_config_1.writeInstallConfig; } });
8
+ var update_install_config_1 = require("./update-install-config");
9
+ Object.defineProperty(exports, "updateInstallConfig", { enumerable: true, get: function () { return update_install_config_1.updateInstallConfig; } });