@g3nomaly/core 0.3.0 → 0.3.2
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/LICENSE +95 -0
- package/dist/cli/commands/add.d.ts +37 -0
- package/dist/cli/commands/add.d.ts.map +1 -0
- package/dist/cli/commands/add.js +99 -0
- package/dist/cli/commands/add.js.map +1 -0
- package/dist/cli/commands/conflict.d.ts +52 -0
- package/dist/cli/commands/conflict.d.ts.map +1 -0
- package/dist/cli/commands/conflict.js +88 -0
- package/dist/cli/commands/conflict.js.map +1 -0
- package/dist/cli/commands/installFromSources.d.ts +78 -0
- package/dist/cli/commands/installFromSources.d.ts.map +1 -0
- package/dist/cli/commands/installFromSources.js +187 -0
- package/dist/cli/commands/installFromSources.js.map +1 -0
- package/dist/cli/commands/ls.d.ts +26 -0
- package/dist/cli/commands/ls.d.ts.map +1 -0
- package/dist/cli/commands/ls.js +85 -0
- package/dist/cli/commands/ls.js.map +1 -0
- package/dist/cli/commands/remove.d.ts +19 -0
- package/dist/cli/commands/remove.d.ts.map +1 -0
- package/dist/cli/commands/remove.js +123 -0
- package/dist/cli/commands/remove.js.map +1 -0
- package/dist/cli/commands/sources.d.ts +69 -0
- package/dist/cli/commands/sources.d.ts.map +1 -0
- package/dist/cli/commands/sources.js +103 -0
- package/dist/cli/commands/sources.js.map +1 -0
- package/dist/cli/commands/update.d.ts +17 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +110 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/dialogue.d.ts +126 -0
- package/dist/cli/dialogue.d.ts.map +1 -0
- package/dist/cli/dialogue.js +156 -0
- package/dist/cli/dialogue.js.map +1 -0
- package/dist/cli/index.d.ts +19 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +16 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/installDialogues.d.ts +23 -0
- package/dist/cli/installDialogues.d.ts.map +1 -0
- package/dist/cli/installDialogues.js +89 -0
- package/dist/cli/installDialogues.js.map +1 -0
- package/dist/cli/pick.d.ts +23 -0
- package/dist/cli/pick.d.ts.map +1 -0
- package/dist/cli/pick.js +44 -0
- package/dist/cli/pick.js.map +1 -0
- package/dist/cli/report.d.ts +58 -0
- package/dist/cli/report.d.ts.map +1 -0
- package/dist/cli/report.js +92 -0
- package/dist/cli/report.js.map +1 -0
- package/dist/cli/theme.d.ts +27 -0
- package/dist/cli/theme.d.ts.map +1 -0
- package/dist/cli/theme.js +29 -0
- package/dist/cli/theme.js.map +1 -0
- package/dist/cli/types.d.ts +96 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/config/config.d.ts +55 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +107 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/types.d.ts +182 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +51 -0
- package/dist/config/types.js.map +1 -0
- package/dist/hash/hash.d.ts +23 -0
- package/dist/hash/hash.d.ts.map +1 -0
- package/dist/hash/hash.js +43 -0
- package/dist/hash/hash.js.map +1 -0
- package/dist/hash/index.d.ts +2 -0
- package/dist/hash/index.d.ts.map +1 -0
- package/dist/hash/index.js +3 -0
- package/dist/hash/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/classify.d.ts +33 -0
- package/dist/installer/classify.d.ts.map +1 -0
- package/dist/installer/classify.js +82 -0
- package/dist/installer/classify.js.map +1 -0
- package/dist/installer/files.d.ts +19 -0
- package/dist/installer/files.d.ts.map +1 -0
- package/dist/installer/files.js +23 -0
- package/dist/installer/files.js.map +1 -0
- package/dist/installer/index.d.ts +19 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +14 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/install.d.ts +25 -0
- package/dist/installer/install.d.ts.map +1 -0
- package/dist/installer/install.js +74 -0
- package/dist/installer/install.js.map +1 -0
- package/dist/installer/io.d.ts +9 -0
- package/dist/installer/io.d.ts.map +1 -0
- package/dist/installer/io.js +23 -0
- package/dist/installer/io.js.map +1 -0
- package/dist/installer/manifest.d.ts +69 -0
- package/dist/installer/manifest.d.ts.map +1 -0
- package/dist/installer/manifest.js +70 -0
- package/dist/installer/manifest.js.map +1 -0
- package/dist/installer/manifestSources.d.ts +32 -0
- package/dist/installer/manifestSources.d.ts.map +1 -0
- package/dist/installer/manifestSources.js +50 -0
- package/dist/installer/manifestSources.js.map +1 -0
- package/dist/installer/marketplace.d.ts +46 -0
- package/dist/installer/marketplace.d.ts.map +1 -0
- package/dist/installer/marketplace.js +72 -0
- package/dist/installer/marketplace.js.map +1 -0
- package/dist/installer/origin.d.ts +59 -0
- package/dist/installer/origin.d.ts.map +1 -0
- package/dist/installer/origin.js +29 -0
- package/dist/installer/origin.js.map +1 -0
- package/dist/installer/remove.d.ts +26 -0
- package/dist/installer/remove.d.ts.map +1 -0
- package/dist/installer/remove.js +49 -0
- package/dist/installer/remove.js.map +1 -0
- package/dist/installer/resolve.d.ts +127 -0
- package/dist/installer/resolve.d.ts.map +1 -0
- package/dist/installer/resolve.js +251 -0
- package/dist/installer/resolve.js.map +1 -0
- package/dist/installer/sourceRegistry.d.ts +96 -0
- package/dist/installer/sourceRegistry.d.ts.map +1 -0
- package/dist/installer/sourceRegistry.js +86 -0
- package/dist/installer/sourceRegistry.js.map +1 -0
- package/dist/installer/types.d.ts +133 -0
- package/dist/installer/types.d.ts.map +1 -0
- package/dist/installer/types.js +31 -0
- package/dist/installer/types.js.map +1 -0
- package/dist/registry/index.d.ts +8 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +9 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/registry.handlers.d.ts +16 -0
- package/dist/registry/registry.handlers.d.ts.map +1 -0
- package/dist/registry/registry.handlers.js +13 -0
- package/dist/registry/registry.handlers.js.map +1 -0
- package/dist/registry/registry.io.d.ts +38 -0
- package/dist/registry/registry.io.d.ts.map +1 -0
- package/dist/registry/registry.io.js +101 -0
- package/dist/registry/registry.io.js.map +1 -0
- package/dist/registry/registry.mutations.d.ts +19 -0
- package/dist/registry/registry.mutations.d.ts.map +1 -0
- package/dist/registry/registry.mutations.js +29 -0
- package/dist/registry/registry.mutations.js.map +1 -0
- package/dist/registry/registry.selectors.d.ts +68 -0
- package/dist/registry/registry.selectors.d.ts.map +1 -0
- package/dist/registry/registry.selectors.js +91 -0
- package/dist/registry/registry.selectors.js.map +1 -0
- package/dist/registry/registry.store.d.ts +47 -0
- package/dist/registry/registry.store.d.ts.map +1 -0
- package/dist/registry/registry.store.js +36 -0
- package/dist/registry/registry.store.js.map +1 -0
- package/dist/registry/registry.template.d.ts +29 -0
- package/dist/registry/registry.template.d.ts.map +1 -0
- package/dist/registry/registry.template.js +70 -0
- package/dist/registry/registry.template.js.map +1 -0
- package/dist/registry/types.d.ts +47 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +35 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +3 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/securityParser.d.ts +15 -0
- package/dist/security/securityParser.d.ts.map +1 -0
- package/dist/security/securityParser.js +79 -0
- package/dist/security/securityParser.js.map +1 -0
- package/dist/security/securityWorker.d.ts +19 -0
- package/dist/security/securityWorker.d.ts.map +1 -0
- package/dist/security/securityWorker.js +137 -0
- package/dist/security/securityWorker.js.map +1 -0
- package/dist/sources/checkout.d.ts +20 -0
- package/dist/sources/checkout.d.ts.map +1 -0
- package/dist/sources/checkout.js +33 -0
- package/dist/sources/checkout.js.map +1 -0
- package/dist/sources/git.d.ts +11 -0
- package/dist/sources/git.d.ts.map +1 -0
- package/dist/sources/git.js +24 -0
- package/dist/sources/git.js.map +1 -0
- package/dist/sources/index.d.ts +5 -0
- package/dist/sources/index.d.ts.map +1 -0
- package/dist/sources/index.js +6 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/sources/local.d.ts +12 -0
- package/dist/sources/local.d.ts.map +1 -0
- package/dist/sources/local.js +22 -0
- package/dist/sources/local.js.map +1 -0
- package/dist/sources/npm.d.ts +16 -0
- package/dist/sources/npm.d.ts.map +1 -0
- package/dist/sources/npm.js +162 -0
- package/dist/sources/npm.js.map +1 -0
- package/dist/sources/packageJson.d.ts +3 -0
- package/dist/sources/packageJson.d.ts.map +1 -0
- package/dist/sources/packageJson.js +13 -0
- package/dist/sources/packageJson.js.map +1 -0
- package/dist/sources/parse.d.ts +42 -0
- package/dist/sources/parse.d.ts.map +1 -0
- package/dist/sources/parse.js +114 -0
- package/dist/sources/parse.js.map +1 -0
- package/dist/sources/process.d.ts +21 -0
- package/dist/sources/process.d.ts.map +1 -0
- package/dist/sources/process.js +46 -0
- package/dist/sources/process.js.map +1 -0
- package/dist/sources/register.d.ts +31 -0
- package/dist/sources/register.d.ts.map +1 -0
- package/dist/sources/register.js +52 -0
- package/dist/sources/register.js.map +1 -0
- package/dist/sources/types.d.ts +108 -0
- package/dist/sources/types.d.ts.map +1 -0
- package/dist/sources/types.js +53 -0
- package/dist/sources/types.js.map +1 -0
- package/dist/utils/errors.d.ts +8 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +11 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/merge.d.ts +12 -0
- package/dist/utils/merge.d.ts.map +1 -0
- package/dist/utils/merge.js +28 -0
- package/dist/utils/merge.js.map +1 -0
- package/dist/utils/packageMeta.d.ts +26 -0
- package/dist/utils/packageMeta.d.ts.map +1 -0
- package/dist/utils/packageMeta.js +24 -0
- package/dist/utils/packageMeta.js.map +1 -0
- package/dist/utils/paths.d.ts +27 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +51 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/prompt.d.ts +8 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +13 -0
- package/dist/utils/prompt.js.map +1 -0
- package/dist/utils/version.d.ts +14 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +140 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +64 -3
- package/README.md +0 -3
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// packages/core/src/cli/commands/sources.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { installedEntries, saveInstallManifest } from "../../installer/manifest";
|
|
4
|
+
import { manifestSources, registerSource, unregisterSource } from "../../installer/manifestSources";
|
|
5
|
+
import { loadSourceRegistry } from "../../installer/sourceRegistry";
|
|
6
|
+
import { describeSource } from "../../sources/checkout";
|
|
7
|
+
import { anchorLocalSpec, defaultSourceName, parseSourceSpec } from "../../sources/parse";
|
|
8
|
+
import { orExit, reportSourceRegistry } from "../report";
|
|
9
|
+
import { c, lineError, lineInfo, lineSuccess } from "../theme";
|
|
10
|
+
/**
|
|
11
|
+
* @brief Registers a git repository, npm package or local folder as a source in
|
|
12
|
+
* every manifest, after checking it can be read and offers at least one entry.
|
|
13
|
+
*
|
|
14
|
+
* @param manifests - Manifests to register the source in.
|
|
15
|
+
* @param input - The source as typed, e.g. `owner/repo`, `npm:@scope/pkg` or `./folder`
|
|
16
|
+
* @param options - Name, ref and path handling for the source.
|
|
17
|
+
* @param context - What the installer calls itself.
|
|
18
|
+
*/
|
|
19
|
+
export async function addSourceEntries(manifests, input, options, context) {
|
|
20
|
+
const parsed = orExit(() => parseSourceSpec(input, { ref: options.ref }));
|
|
21
|
+
const spec = anchorLocalSpec(parsed, process.cwd(), options.absolutePaths === true ? null : context.projectRoot);
|
|
22
|
+
const name = options.name ?? orExit(() => defaultSourceName(spec));
|
|
23
|
+
const files = manifests.map((m) => m.manifest);
|
|
24
|
+
// A dry run on copies rejects a taken name before the source is fetched.
|
|
25
|
+
orExit(() => registerSource(files.map((m) => ({ ...m })), name, spec, context.builtins));
|
|
26
|
+
const registry = await loadSourceRegistry([{ name, spec, builtin: false }], context.projectRoot, context.readSource);
|
|
27
|
+
try {
|
|
28
|
+
reportSourceRegistry(registry);
|
|
29
|
+
const keys = Object.keys(registry.sources.get(name)?.store.state ?? {}).sort();
|
|
30
|
+
if (registry.failed.length > 0)
|
|
31
|
+
process.exit(1);
|
|
32
|
+
if (keys.length === 0) {
|
|
33
|
+
console.error(lineError(`${c.key(name)} offers no ${context.noun}s, nothing registered`));
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
registerSource(files, name, spec, context.builtins);
|
|
37
|
+
for (const manifest of files)
|
|
38
|
+
saveInstallManifest(manifest, context.entrySchema);
|
|
39
|
+
console.log(lineSuccess(`Registered ${c.key(name)} ${chalk.dim(`(${describeSource(spec)})`)} with ${keys.length} ${context.noun}(s): ${keys.map((k) => c.key(k)).join(", ")}`));
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
registry.dispose();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @brief Lists each manifest's sources, built-in ones first, with how many installed entries came from each.
|
|
47
|
+
*
|
|
48
|
+
* @param manifests - Manifests to list, one target each.
|
|
49
|
+
* @param options - Prints JSON when `json` is set.
|
|
50
|
+
* @param context - Built-in sources and the entry schema.
|
|
51
|
+
*/
|
|
52
|
+
export function lsSources(manifests, options, context) {
|
|
53
|
+
const listing = manifests.map(({ label, manifest }) => {
|
|
54
|
+
const installed = Object.values(installedEntries(manifest, context.entrySchema));
|
|
55
|
+
return {
|
|
56
|
+
target: label,
|
|
57
|
+
sources: manifestSources([manifest], context.builtins).map((source) => ({
|
|
58
|
+
...source,
|
|
59
|
+
installed: installed.filter((entry) => entry.origin.source === source.name).length,
|
|
60
|
+
})),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
if (options.json === true) {
|
|
64
|
+
console.log(JSON.stringify(listing, null, 2));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
for (const { target, sources } of listing) {
|
|
68
|
+
if (listing.length > 1)
|
|
69
|
+
console.log(c.header(target));
|
|
70
|
+
for (const source of sources) {
|
|
71
|
+
const tag = source.builtin ? chalk.dim(" (built in)") : "";
|
|
72
|
+
console.log(` ${c.key(source.name.padEnd(20))} ${describeSource(source.spec)}${tag} ${chalk.dim(`${source.installed} installed`)}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @brief Unregisters a source from every manifest that has it. Refused for built-in
|
|
78
|
+
* sources, and while installed entries came from it unless `force` is set;
|
|
79
|
+
* forced, those entries stay installed but can no longer be updated.
|
|
80
|
+
*
|
|
81
|
+
* @param manifests - Manifests to unregister the source from.
|
|
82
|
+
* @param name - Name of the source to unregister.
|
|
83
|
+
* @param options - Force flag, keeping installed entries without updates.
|
|
84
|
+
* @param context - What the installer calls itself.
|
|
85
|
+
*/
|
|
86
|
+
export function removeSourceEntries(manifests, name, options, context) {
|
|
87
|
+
const files = manifests.map((m) => m.manifest);
|
|
88
|
+
// A dry run on copies rejects a built-in or unknown name before the installed entries are checked.
|
|
89
|
+
orExit(() => unregisterSource(files.map((m) => ({ ...m })), name, context.builtins));
|
|
90
|
+
const fromSource = [...new Set(files.flatMap((manifest) => Object.entries(installedEntries(manifest, context.entrySchema)).filter(([, entry]) => entry.origin.source === name).map(([key]) => key)))].sort();
|
|
91
|
+
if (fromSource.length > 0 && options.force !== true) {
|
|
92
|
+
console.error(lineError(`Installed from ${c.key(name)}: ${fromSource.map((k) => c.key(k)).join(", ")}. ` +
|
|
93
|
+
`Remove those ${context.noun}s first with ${c.cmd(`${context.bin} remove ${fromSource.join(" ")}`)}, or pass ${c.flag("-f")} to keep them without updates.`));
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
unregisterSource(files, name, context.builtins);
|
|
97
|
+
for (const manifest of files)
|
|
98
|
+
saveInstallManifest(manifest, context.entrySchema);
|
|
99
|
+
console.log(lineSuccess(`Unregistered ${c.key(name)}`));
|
|
100
|
+
if (fromSource.length > 0)
|
|
101
|
+
console.log(lineInfo(`Still installed, without updates: ${fromSource.map((k) => c.key(k)).join(", ")}`));
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=sources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sources.js","sourceRoot":"","sources":["../../../src/cli/commands/sources.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE1F,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAkC/D;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,SAAoC,EACpC,KAAa,EACb,OAAyB,EACzB,OAAgC;IAEhC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,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAC5J,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChD,KAAK,MAAM,QAAQ,IAAI,KAAK;QAAE,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACjF,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACxD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,qCAAqC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACtI,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BaseRegistry } from "../../registry/types";
|
|
2
|
+
import type { EntrySource, InstallOptions, InstallTarget, UpdateDialogues } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @brief Re-installs entries already present in a target's manifest; with no keys
|
|
5
|
+
* everything installed is updated, forks excepted. Local changes prompt
|
|
6
|
+
* restore/fork/skip through `onCollision` unless `--force`. The caller
|
|
7
|
+
* resolves keys before and saves each target's store after.
|
|
8
|
+
*
|
|
9
|
+
* @param registry - Entries available to install, by key.
|
|
10
|
+
* @param targets - Destinations to update.
|
|
11
|
+
* @param source - Source of each entry's files.
|
|
12
|
+
* @param keys - Keys to update; empty to update everything installed.
|
|
13
|
+
* @param options - Force, dry run and preset answers.
|
|
14
|
+
* @param dialogues - Dialogue for local changes.
|
|
15
|
+
*/
|
|
16
|
+
export declare function updateEntries(registry: BaseRegistry, targets: InstallTarget[], source: EntrySource, keys: string[], options?: InstallOptions, dialogues?: UpdateDialogues): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKzD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAwB5F;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,aAAa,EAAE,EACxB,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,cAAmB,EAC5B,SAAS,GAAE,eAAoB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA4Ef"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// packages/core/src/cli/commands/update.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { entries as storeEntries, get } from "../../registry/registry.selectors";
|
|
5
|
+
import { register } from "../../registry/registry.mutations";
|
|
6
|
+
import { applyClassifications, classifyFiles, recordedHashes, removeInstalledFiles } from "../../installer";
|
|
7
|
+
import { createInstallerIO } from "../../installer/io";
|
|
8
|
+
import { ConflictDecision, FileState } from "../../installer/types";
|
|
9
|
+
import { c, lineSuccess, lineWarn, lineInfo } from "../theme";
|
|
10
|
+
import { latestHashFrom } from "./add";
|
|
11
|
+
import { chooseConflict, forkedFrom, forkEntry } from "./conflict";
|
|
12
|
+
const DRY_RUN_LABELS = {
|
|
13
|
+
[FileState.UpToDate]: chalk.dim("up to date"),
|
|
14
|
+
[FileState.SafeUpdate]: chalk.cyan("would update") + chalk.dim(" (package changed, file unmodified)"),
|
|
15
|
+
[FileState.UserOnly]: chalk.yellow("would keep") + chalk.dim(" — local changes"),
|
|
16
|
+
[FileState.Conflict]: chalk.red("conflict") + chalk.dim(" — restore, fork or skip"),
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @brief Prints one dry-run line per file with its state.
|
|
20
|
+
*
|
|
21
|
+
* @param classifications - Files to print, each with its state.
|
|
22
|
+
*/
|
|
23
|
+
function printDryRun(classifications) {
|
|
24
|
+
for (const cl of classifications) {
|
|
25
|
+
const rel = c.file(path.relative(process.cwd(), cl.destPath));
|
|
26
|
+
console.log(` ${rel.padEnd(50)} ${DRY_RUN_LABELS[cl.state]}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @brief Re-installs entries already present in a target's manifest; with no keys
|
|
31
|
+
* everything installed is updated, forks excepted. Local changes prompt
|
|
32
|
+
* restore/fork/skip through `onCollision` unless `--force`. The caller
|
|
33
|
+
* resolves keys before and saves each target's store after.
|
|
34
|
+
*
|
|
35
|
+
* @param registry - Entries available to install, by key.
|
|
36
|
+
* @param targets - Destinations to update.
|
|
37
|
+
* @param source - Source of each entry's files.
|
|
38
|
+
* @param keys - Keys to update; empty to update everything installed.
|
|
39
|
+
* @param options - Force, dry run and preset answers.
|
|
40
|
+
* @param dialogues - Dialogue for local changes.
|
|
41
|
+
*/
|
|
42
|
+
export async function updateEntries(registry, targets, source, keys, options = {}, dialogues = {}) {
|
|
43
|
+
const io = createInstallerIO();
|
|
44
|
+
for (const target of targets) {
|
|
45
|
+
if (targets.length > 1)
|
|
46
|
+
console.log(c.header(target.label));
|
|
47
|
+
const targetKeys = Object.keys(storeEntries(target.store)).sort();
|
|
48
|
+
const wanted = keys.length > 0 ? targetKeys.filter((k) => keys.includes(k)) : targetKeys;
|
|
49
|
+
if (wanted.length === 0) {
|
|
50
|
+
console.log(lineInfo("Nothing to update."));
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
for (const key of wanted) {
|
|
54
|
+
const installed = get(target.store, key);
|
|
55
|
+
const original = installed === undefined ? undefined : forkedFrom(installed);
|
|
56
|
+
if (original !== undefined) {
|
|
57
|
+
console.log(lineInfo(`${c.key(key)} is a fork of ${c.key(original)} — not updated`));
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const meta = registry[key];
|
|
61
|
+
if (!meta) {
|
|
62
|
+
console.log(lineWarn(`${c.key(key)} is installed but no longer in the package — leaving as is`));
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const fileSource = await source(meta);
|
|
66
|
+
const classifications = await classifyFiles(meta.files, target.installDir, recordedHashes(installed), io, latestHashFrom(fileSource, io));
|
|
67
|
+
const stale = (installed?.files ?? []).filter((f) => !meta.files.some((m) => m.path === f.path));
|
|
68
|
+
if (options.dryRun) {
|
|
69
|
+
console.log(chalk.bold(c.key(key)));
|
|
70
|
+
printDryRun(classifications);
|
|
71
|
+
for (const file of stale) {
|
|
72
|
+
console.log(` ${c.file(file.path).padEnd(50)} ${chalk.red("would remove")}${chalk.dim(" — no longer in the package")}`);
|
|
73
|
+
}
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const hasLocalChanges = classifications.some((cl) => cl.state >= FileState.UserOnly);
|
|
77
|
+
const choice = hasLocalChanges
|
|
78
|
+
? await chooseConflict(dialogues.onCollision, key, installed ?? meta, target, options)
|
|
79
|
+
: { decision: ConflictDecision.Keep };
|
|
80
|
+
if (choice.decision === ConflictDecision.Fork) {
|
|
81
|
+
await forkEntry(target, key, installed ?? meta, choice.forkKey, io);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const result = await applyClassifications(classifications, fileSource, { decision: choice.decision, force: options.force ?? false }, io);
|
|
85
|
+
if (stale.length > 0) {
|
|
86
|
+
const removal = await removeInstalledFiles(stale, target.installDir, { force: options.force }, io);
|
|
87
|
+
for (const file of removal.kept) {
|
|
88
|
+
console.log(lineWarn(`${c.file(file)} left the package but has local changes — kept ${chalk.dim(`(use ${c.flag("-f")} to remove)`)}`));
|
|
89
|
+
}
|
|
90
|
+
if (removal.removed.length > 0) {
|
|
91
|
+
console.log(lineInfo(`Removed ${removal.removed.length} file${removal.removed.length === 1 ? "" : "s"} no longer in ${c.key(key)}`));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (const file of result.missingSource) {
|
|
95
|
+
console.log(lineWarn(`No content for ${c.file(file)} in the package source — skipped`));
|
|
96
|
+
}
|
|
97
|
+
if (result.kept.length > 0) {
|
|
98
|
+
console.log(lineWarn(`${c.key(key)} — skipped ${result.kept.map((f) => c.file(f)).join(", ")} ${chalk.dim("(local changes, asked again next update)")}`));
|
|
99
|
+
}
|
|
100
|
+
if (result.written.length > 0) {
|
|
101
|
+
console.log(lineSuccess(`Updated ${c.key(key)} ${chalk.dim(`(${result.written.length} file${result.written.length === 1 ? "" : "s"})`)}`));
|
|
102
|
+
}
|
|
103
|
+
else if (result.kept.length === 0) {
|
|
104
|
+
console.log(lineInfo(`${c.key(key)} — already up to date`));
|
|
105
|
+
}
|
|
106
|
+
register(target.store, key, { ...meta, files: result.files.map((f) => ({ ...f, version: meta.version })) });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,GAAG,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CA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AC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7I,CAAC;iBAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC;YAC9D,CAAC;YAED,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAC9G,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export declare const StepKind: {
|
|
2
|
+
readonly Select: 0;
|
|
3
|
+
readonly MultiSelect: 1;
|
|
4
|
+
readonly Confirm: 2;
|
|
5
|
+
readonly Text: 3;
|
|
6
|
+
};
|
|
7
|
+
/** Kind of a dialogue step: select, multi-select, confirm or text. */
|
|
8
|
+
export type StepKind = (typeof StepKind)[keyof typeof StepKind];
|
|
9
|
+
/** Answers a dialogue collects, keyed by step id. */
|
|
10
|
+
export type DialogueAnswers = Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* @brief One choice of a select or multi-select step.
|
|
13
|
+
*
|
|
14
|
+
* @property value - Value the step answers with.
|
|
15
|
+
* @property label - Text shown for the choice, with `{name}` placeholders filled from the input.
|
|
16
|
+
*/
|
|
17
|
+
export interface StepChoice<V = unknown> {
|
|
18
|
+
value: V;
|
|
19
|
+
label: string;
|
|
20
|
+
}
|
|
21
|
+
/** A literal value, or a function deriving it from the walk's input. */
|
|
22
|
+
export type Resolvable<Input, V> = V | ((input: Input) => V);
|
|
23
|
+
/**
|
|
24
|
+
* @brief One question of a dialogue, shared by every kind of step.
|
|
25
|
+
*
|
|
26
|
+
* `{name}` placeholders in messages and labels are filled from the walk's input.
|
|
27
|
+
*
|
|
28
|
+
* @property message - Question shown to the user.
|
|
29
|
+
* @property when - Decides whether the step runs at all; a skipped step records no answer and falls through to `next`.
|
|
30
|
+
* @property next - Following step: a step id for linear flow, a function of the answer for branching, absent to end.
|
|
31
|
+
*/
|
|
32
|
+
interface StepBase<Input> {
|
|
33
|
+
message: string;
|
|
34
|
+
when?: (input: Input, answers: DialogueAnswers) => boolean;
|
|
35
|
+
next?: string | ((answer: unknown, answers: DialogueAnswers, input: Input) => string | null);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @brief A step that asks the user to pick one of its choices.
|
|
39
|
+
*
|
|
40
|
+
* @property kind - Always `StepKind.Select`.
|
|
41
|
+
* @property choices - Choices offered, literal or derived from the input.
|
|
42
|
+
* @property initial - Choice preselected, literal or derived from the input.
|
|
43
|
+
*/
|
|
44
|
+
export interface SelectStep<Input = DialogueAnswers> extends StepBase<Input> {
|
|
45
|
+
kind: typeof StepKind.Select;
|
|
46
|
+
choices: Resolvable<Input, StepChoice[]>;
|
|
47
|
+
initial?: Resolvable<Input, string | number | boolean>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @brief A step that asks the user to pick any number of its choices.
|
|
51
|
+
*
|
|
52
|
+
* @property kind - Always `StepKind.MultiSelect`.
|
|
53
|
+
* @property choices - Choices offered, literal or derived from the input.
|
|
54
|
+
* @property initial - Choices preselected, literal or derived from the input.
|
|
55
|
+
* @property required - Whether at least one choice must be picked.
|
|
56
|
+
*/
|
|
57
|
+
export interface MultiSelectStep<Input = DialogueAnswers> extends StepBase<Input> {
|
|
58
|
+
kind: typeof StepKind.MultiSelect;
|
|
59
|
+
choices: Resolvable<Input, StepChoice[]>;
|
|
60
|
+
initial?: Resolvable<Input, unknown[]>;
|
|
61
|
+
required?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @brief A step that asks a yes or no question.
|
|
65
|
+
*
|
|
66
|
+
* @property kind - Always `StepKind.Confirm`.
|
|
67
|
+
* @property initial - Starting answer, literal or derived from the input.
|
|
68
|
+
*/
|
|
69
|
+
export interface ConfirmStep<Input = DialogueAnswers> extends StepBase<Input> {
|
|
70
|
+
kind: typeof StepKind.Confirm;
|
|
71
|
+
initial?: Resolvable<Input, boolean>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @brief A step that asks for free text.
|
|
75
|
+
*
|
|
76
|
+
* @property kind - Always `StepKind.Text`.
|
|
77
|
+
* @property initial - Starting text, literal or derived from the input.
|
|
78
|
+
* @property validate - Returns an error message for an invalid value, or `undefined` when it is valid.
|
|
79
|
+
*/
|
|
80
|
+
export interface TextStep<Input = DialogueAnswers> extends StepBase<Input> {
|
|
81
|
+
kind: typeof StepKind.Text;
|
|
82
|
+
initial?: Resolvable<Input, string>;
|
|
83
|
+
validate?: (value: string | undefined) => string | undefined;
|
|
84
|
+
}
|
|
85
|
+
/** One step of a dialogue, of any kind. */
|
|
86
|
+
export type DialogueStep<Input = DialogueAnswers> = SelectStep<Input> | MultiSelectStep<Input> | ConfirmStep<Input> | TextStep<Input>;
|
|
87
|
+
/**
|
|
88
|
+
* @brief A command's interaction with the user: a graph of steps keyed by id,
|
|
89
|
+
* entered at the first key and linked through each step's `next`. Commands
|
|
90
|
+
* take dialogues through named slots (e.g. `onNoValue`, `onCollision`) and
|
|
91
|
+
* run them with `runDialogueValue`; init flows are linked lists run with
|
|
92
|
+
* `runDialogue`. Preset answers (`options.answers`, keyed by step id) skip
|
|
93
|
+
* the terminal prompt — that is how tests and non-interactive runs answer.
|
|
94
|
+
*
|
|
95
|
+
* @property steps - Steps keyed by id; the walk enters at the first key.
|
|
96
|
+
*/
|
|
97
|
+
export interface Dialogue<Input = DialogueAnswers> {
|
|
98
|
+
steps: Record<string, DialogueStep<Input>>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @brief Walks a dialogue from its first step and collects answers by step id.
|
|
102
|
+
*
|
|
103
|
+
* Skips steps whose `when` is false. A preset answer in `answers` is
|
|
104
|
+
* recorded without prompting; anything else renders in the terminal.
|
|
105
|
+
* Returns the cancel symbol as soon as any step is cancelled.
|
|
106
|
+
*
|
|
107
|
+
* @param dialogue - Dialogue to walk.
|
|
108
|
+
* @param input - Input the steps read.
|
|
109
|
+
* @param answers - Preset answers by step id.
|
|
110
|
+
* @returns Answers by step id, or the cancel symbol.
|
|
111
|
+
* @throws {Error} When the walk reaches a step id that is not in the dialogue.
|
|
112
|
+
*/
|
|
113
|
+
export declare function runDialogue<Input>(dialogue: Dialogue<Input>, input: Input, answers?: DialogueAnswers): Promise<DialogueAnswers | symbol>;
|
|
114
|
+
/**
|
|
115
|
+
* @brief Runs a dialogue and returns the answer of its last executed step.
|
|
116
|
+
*
|
|
117
|
+
* This is the contract for the commands' named dialogue slots.
|
|
118
|
+
*
|
|
119
|
+
* @param dialogue - Dialogue to run.
|
|
120
|
+
* @param input - Input the steps read.
|
|
121
|
+
* @param answers - Preset answers by step id.
|
|
122
|
+
* @returns The answer of the last step that ran, `undefined` when no step ran, or the cancel symbol.
|
|
123
|
+
*/
|
|
124
|
+
export declare function runDialogueValue<Input>(dialogue: Dialogue<Input>, input: Input, answers?: DialogueAnswers): Promise<unknown>;
|
|
125
|
+
export {};
|
|
126
|
+
//# sourceMappingURL=dialogue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogue.d.ts","sourceRoot":"","sources":["../../src/cli/dialogue.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ;aACnB,MAAM,EAAO,CAAC;aACd,WAAW,EAAE,CAAC;aACd,OAAO,EAAM,CAAC;aACd,IAAI,EAAS,CAAC;CACN,CAAC;AACX,sEAAsE;AACtE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO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AC,CAoBnC;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAC1C,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,EACzB,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC,CAKlB"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// packages/core/src/cli/dialogue.ts
|
|
2
|
+
import * as p from "@clack/prompts";
|
|
3
|
+
export const StepKind = {
|
|
4
|
+
Select: 0,
|
|
5
|
+
MultiSelect: 1,
|
|
6
|
+
Confirm: 2,
|
|
7
|
+
Text: 3,
|
|
8
|
+
};
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Resolving
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
/**
|
|
13
|
+
* @brief Fills the `{name}` placeholders of a template from the fields of the input.
|
|
14
|
+
*
|
|
15
|
+
* @param template - Text with `{name}` placeholders.
|
|
16
|
+
* @param input - Object whose fields fill the placeholders; a placeholder without a field stays as written.
|
|
17
|
+
* @returns The text with its placeholders filled.
|
|
18
|
+
*/
|
|
19
|
+
function interpolate(template, input) {
|
|
20
|
+
const record = (typeof input === "object" && input !== null ? input : {});
|
|
21
|
+
return template.replace(/\{(\w+)\}/g, (match, name) => {
|
|
22
|
+
const value = record[name];
|
|
23
|
+
return value === undefined ? match : String(value);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @brief Resolves a value that is literal or a function of the input.
|
|
28
|
+
*
|
|
29
|
+
* @param value - Literal value, or a function of `input`; `undefined` passes through.
|
|
30
|
+
* @param input - Input the function is called with.
|
|
31
|
+
* @returns The literal, or the function's result.
|
|
32
|
+
*/
|
|
33
|
+
function resolveValue(value, input) {
|
|
34
|
+
return typeof value === "function" ? value(input) : value;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @brief Resolves every field of a step against the input, ready to render.
|
|
38
|
+
*
|
|
39
|
+
* @param id - Id of the step.
|
|
40
|
+
* @param step - Step to resolve.
|
|
41
|
+
* @param input - Input the placeholders and functions read.
|
|
42
|
+
* @returns The resolved step.
|
|
43
|
+
*/
|
|
44
|
+
function resolveStep(id, step, input) {
|
|
45
|
+
const resolved = { id, kind: step.kind, message: interpolate(step.message, input) };
|
|
46
|
+
switch (step.kind) {
|
|
47
|
+
case StepKind.Select:
|
|
48
|
+
case StepKind.MultiSelect: {
|
|
49
|
+
const choices = resolveValue(step.choices, input) ?? [];
|
|
50
|
+
resolved.choices = choices.map((choice) => ({ ...choice, label: interpolate(choice.label, input) }));
|
|
51
|
+
resolved.initial = resolveValue(step.initial, input);
|
|
52
|
+
if (step.kind === StepKind.MultiSelect)
|
|
53
|
+
resolved.required = step.required;
|
|
54
|
+
return resolved;
|
|
55
|
+
}
|
|
56
|
+
case StepKind.Confirm:
|
|
57
|
+
resolved.initial = resolveValue(step.initial, input);
|
|
58
|
+
return resolved;
|
|
59
|
+
case StepKind.Text:
|
|
60
|
+
resolved.initial = resolveValue(step.initial, input);
|
|
61
|
+
resolved.validate = step.validate;
|
|
62
|
+
return resolved;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// Rendering
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
/**
|
|
69
|
+
* @brief Renders one resolved step in the terminal and returns the answer.
|
|
70
|
+
*
|
|
71
|
+
* @param step - Step to render.
|
|
72
|
+
* @returns The user's answer, or the cancel symbol.
|
|
73
|
+
*/
|
|
74
|
+
async function render(step) {
|
|
75
|
+
switch (step.kind) {
|
|
76
|
+
case StepKind.Select:
|
|
77
|
+
return p.select({
|
|
78
|
+
message: step.message,
|
|
79
|
+
options: step.choices ?? [],
|
|
80
|
+
initialValue: step.initial,
|
|
81
|
+
});
|
|
82
|
+
case StepKind.MultiSelect:
|
|
83
|
+
return p.multiselect({
|
|
84
|
+
message: step.message,
|
|
85
|
+
options: step.choices ?? [],
|
|
86
|
+
initialValues: step.initial,
|
|
87
|
+
required: step.required,
|
|
88
|
+
});
|
|
89
|
+
case StepKind.Confirm:
|
|
90
|
+
return p.confirm({
|
|
91
|
+
message: step.message,
|
|
92
|
+
initialValue: step.initial ?? false,
|
|
93
|
+
});
|
|
94
|
+
case StepKind.Text:
|
|
95
|
+
return p.text({
|
|
96
|
+
message: step.message,
|
|
97
|
+
initialValue: step.initial,
|
|
98
|
+
validate: step.validate,
|
|
99
|
+
});
|
|
100
|
+
default:
|
|
101
|
+
throw new Error(`unknown step kind ${String(step.kind)}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Walking
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
/**
|
|
108
|
+
* @brief Walks a dialogue from its first step and collects answers by step id.
|
|
109
|
+
*
|
|
110
|
+
* Skips steps whose `when` is false. A preset answer in `answers` is
|
|
111
|
+
* recorded without prompting; anything else renders in the terminal.
|
|
112
|
+
* Returns the cancel symbol as soon as any step is cancelled.
|
|
113
|
+
*
|
|
114
|
+
* @param dialogue - Dialogue to walk.
|
|
115
|
+
* @param input - Input the steps read.
|
|
116
|
+
* @param answers - Preset answers by step id.
|
|
117
|
+
* @returns Answers by step id, or the cancel symbol.
|
|
118
|
+
* @throws {Error} When the walk reaches a step id that is not in the dialogue.
|
|
119
|
+
*/
|
|
120
|
+
export async function runDialogue(dialogue, input, answers = {}) {
|
|
121
|
+
const collected = {};
|
|
122
|
+
let id = Object.keys(dialogue.steps)[0] ?? null;
|
|
123
|
+
while (id !== null) {
|
|
124
|
+
const step = dialogue.steps[id];
|
|
125
|
+
if (step === undefined)
|
|
126
|
+
throw new Error(`dialogue has no step "${id}"`);
|
|
127
|
+
let answer = undefined;
|
|
128
|
+
if (step.when === undefined || step.when(input, collected)) {
|
|
129
|
+
const preset = answers[id];
|
|
130
|
+
answer = preset !== undefined ? preset : await render(resolveStep(id, step, input));
|
|
131
|
+
if (typeof answer === "symbol")
|
|
132
|
+
return answer;
|
|
133
|
+
collected[id] = answer;
|
|
134
|
+
}
|
|
135
|
+
id = typeof step.next === "function" ? step.next(answer, collected, input) : step.next ?? null;
|
|
136
|
+
}
|
|
137
|
+
return collected;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @brief Runs a dialogue and returns the answer of its last executed step.
|
|
141
|
+
*
|
|
142
|
+
* This is the contract for the commands' named dialogue slots.
|
|
143
|
+
*
|
|
144
|
+
* @param dialogue - Dialogue to run.
|
|
145
|
+
* @param input - Input the steps read.
|
|
146
|
+
* @param answers - Preset answers by step id.
|
|
147
|
+
* @returns The answer of the last step that ran, `undefined` when no step ran, or the cancel symbol.
|
|
148
|
+
*/
|
|
149
|
+
export async function runDialogueValue(dialogue, input, answers = {}) {
|
|
150
|
+
const record = await runDialogue(dialogue, input, answers);
|
|
151
|
+
if (typeof record === "symbol")
|
|
152
|
+
return record;
|
|
153
|
+
const last = Object.keys(record).at(-1);
|
|
154
|
+
return last === undefined ? undefined : record[last];
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=dialogue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogue.js","sourceRoot":"","sources":["../../src/cli/dialogue.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,MAAM,EAAO,CAAC;IACd,WAAW,EAAE,CAAC;IACd,OAAO,EAAM,CAAC;IACd,IAAI,EAAS,CAAC;CACN,CAAC;AA8HX,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,QAAgB,EAAE,KAAc;IACnD,MAAM,MAAM,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC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C,CAAC,CAAC;YACpF,IAAI,OAAO,MAAM,KAAK,QAAQ;gBAAE,OAAO,MAAM,CAAC;YAC9C,SAAS,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACzB,CAAC;QAED,EAAE,GAAG,OAAO,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;IACjG,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAyB,EACzB,KAAY,EACZ,OAAO,GAAoB,EAAE;IAE7B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3D,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export { ConflictDecision, FileState } from "../installer/types";
|
|
3
|
+
export { StepKind, runDialogue, runDialogueValue } from "./dialogue";
|
|
4
|
+
export type { Dialogue, DialogueStep, DialogueAnswers, StepChoice, Resolvable, SelectStep, MultiSelectStep, ConfirmStep, TextStep, } from "./dialogue";
|
|
5
|
+
export { addEntries } from "./commands/add";
|
|
6
|
+
export { updateEntries } from "./commands/update";
|
|
7
|
+
export { removeEntries } from "./commands/remove";
|
|
8
|
+
export { lsEntries } from "./commands/ls";
|
|
9
|
+
export { c, sym, lineSuccess, lineWarn, lineInfo, lineError } from "./theme";
|
|
10
|
+
export { reportSourceRegistry, orExit, reportResolution, entryNotFoundDialogue, narrowSources } from "./report";
|
|
11
|
+
export type { ResolutionContext } from "./report";
|
|
12
|
+
export { lsSourceRegistry } from "./commands/ls";
|
|
13
|
+
export { addSourceEntries, lsSources, removeSourceEntries } from "./commands/sources";
|
|
14
|
+
export type { SourceCommandContext, SourceAddOptions } from "./commands/sources";
|
|
15
|
+
export { pickOffers, selectEntriesDialogue } from "./pick";
|
|
16
|
+
export { conflictDialogue, removeChangedDialogue, cascadeDialogue, incompleteDialogue, selectRemovalDialogue, notInstalledDialogue } from "./installDialogues";
|
|
17
|
+
export { addFromSources, updateFromSources, removeFromTargets } from "./commands/installFromSources";
|
|
18
|
+
export type { ManifestTarget, InstallCommandContext, AfterTarget } from "./commands/installFromSources";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AACpE,YAAY,EACV,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAC/D,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,GACnD,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC/G,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACrF,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAChF,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,eAAe,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAC9J,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACpG,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// packages/core/src/cli/index.ts
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export { ConflictDecision, FileState } from "../installer/types";
|
|
4
|
+
export { StepKind, runDialogue, runDialogueValue } from "./dialogue";
|
|
5
|
+
export { addEntries } from "./commands/add";
|
|
6
|
+
export { updateEntries } from "./commands/update";
|
|
7
|
+
export { removeEntries } from "./commands/remove";
|
|
8
|
+
export { lsEntries } from "./commands/ls";
|
|
9
|
+
export { c, sym, lineSuccess, lineWarn, lineInfo, lineError } from "./theme";
|
|
10
|
+
export { reportSourceRegistry, orExit, reportResolution, entryNotFoundDialogue, narrowSources } from "./report";
|
|
11
|
+
export { lsSourceRegistry } from "./commands/ls";
|
|
12
|
+
export { addSourceEntries, lsSources, removeSourceEntries } from "./commands/sources";
|
|
13
|
+
export { pickOffers, selectEntriesDialogue } from "./pick";
|
|
14
|
+
export { conflictDialogue, removeChangedDialogue, cascadeDialogue, incompleteDialogue, selectRemovalDialogue, notInstalledDialogue } from "./installDialogues";
|
|
15
|
+
export { addFromSources, updateFromSources, removeFromTargets } from "./commands/installFromSources";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAKpE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE/G,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAErF,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,eAAe,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAC9J,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Dialogue } from "./dialogue";
|
|
2
|
+
import type { InstallInput } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* @brief Restore, fork or skip an entry with local changes, for `add` and `update`; step id `conflict`, then
|
|
5
|
+
* `forkName` for the key of the fork.
|
|
6
|
+
*/
|
|
7
|
+
export declare const conflictDialogue: Dialogue<InstallInput>;
|
|
8
|
+
/** Keep or remove an entry with local changes, for `remove`; step id `conflict`. */
|
|
9
|
+
export declare const removeChangedDialogue: Dialogue<InstallInput>;
|
|
10
|
+
/** Whether to remove the installed entries that depend on one being removed; step id `cascade`. */
|
|
11
|
+
export declare const cascadeDialogue: Dialogue<InstallInput>;
|
|
12
|
+
/** Whether to remove an entry with files already missing on disk; step id `incomplete`. */
|
|
13
|
+
export declare const incompleteDialogue: Dialogue<InstallInput>;
|
|
14
|
+
/**
|
|
15
|
+
* @brief Builds the picker that asks which installed entries to remove.
|
|
16
|
+
*
|
|
17
|
+
* @param noun - What one entry is called, e.g. `skill`.
|
|
18
|
+
* @returns Dialogue with the step `selectEntries`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function selectRemovalDialogue(noun: string): Dialogue<InstallInput>;
|
|
21
|
+
/** Whether to go on when some names given to `update` are not installed; step id `entryNotFound`. */
|
|
22
|
+
export declare const notInstalledDialogue: Dialogue<InstallInput>;
|
|
23
|
+
//# sourceMappingURL=installDialogues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installDialogues.d.ts","sourceRoot":"","sources":["../../src/cli/installDialogues.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,YAAY,CAoBnD,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,YAAY,CAWxD,CAAC;AAEF,mGAAmG;AACnG,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,YAAY,CAQlD,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,YAAY,CAQrD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,CAU1E;AAED,qGAAqG;AACrG,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,YAAY,CAQvD,CAAC"}
|