harness-config-manager 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1547 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +584 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/config.d.ts +7 -0
- package/dist/commands/config.js +49 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/context.d.ts +24 -0
- package/dist/commands/context.js +329 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/export.d.ts +19 -0
- package/dist/commands/export.js +116 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/import.d.ts +33 -0
- package/dist/commands/import.js +81 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/info.d.ts +19 -0
- package/dist/commands/info.js +235 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.js +116 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.d.ts +119 -0
- package/dist/commands/install.js +533 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/list.d.ts +9 -0
- package/dist/commands/list.js +102 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/params.d.ts +58 -0
- package/dist/commands/params.js +366 -0
- package/dist/commands/params.js.map +1 -0
- package/dist/commands/refs.d.ts +60 -0
- package/dist/commands/refs.js +329 -0
- package/dist/commands/refs.js.map +1 -0
- package/dist/commands/registry.d.ts +18 -0
- package/dist/commands/registry.js +173 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/status.d.ts +10 -0
- package/dist/commands/status.js +83 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/targets.d.ts +8 -0
- package/dist/commands/targets.js +61 -0
- package/dist/commands/targets.js.map +1 -0
- package/dist/commands/uninstall.d.ts +71 -0
- package/dist/commands/uninstall.js +322 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +66 -0
- package/dist/commands/update.js +384 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.js +38 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/core/bundle.d.ts +49 -0
- package/dist/core/bundle.js +326 -0
- package/dist/core/bundle.js.map +1 -0
- package/dist/core/config.d.ts +65 -0
- package/dist/core/config.js +112 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/conflicts.d.ts +67 -0
- package/dist/core/conflicts.js +300 -0
- package/dist/core/conflicts.js.map +1 -0
- package/dist/core/context.d.ts +139 -0
- package/dist/core/context.js +432 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/deps.d.ts +62 -0
- package/dist/core/deps.js +339 -0
- package/dist/core/deps.js.map +1 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.js +26 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/executor.d.ts +9 -0
- package/dist/core/executor.js +139 -0
- package/dist/core/executor.js.map +1 -0
- package/dist/core/flavors.d.ts +128 -0
- package/dist/core/flavors.js +386 -0
- package/dist/core/flavors.js.map +1 -0
- package/dist/core/frontmatter.d.ts +6 -0
- package/dist/core/frontmatter.js +20 -0
- package/dist/core/frontmatter.js.map +1 -0
- package/dist/core/fsx.d.ts +40 -0
- package/dist/core/fsx.js +180 -0
- package/dist/core/fsx.js.map +1 -0
- package/dist/core/github.d.ts +37 -0
- package/dist/core/github.js +157 -0
- package/dist/core/github.js.map +1 -0
- package/dist/core/harnesses.d.ts +142 -0
- package/dist/core/harnesses.js +215 -0
- package/dist/core/harnesses.js.map +1 -0
- package/dist/core/hash.d.ts +12 -0
- package/dist/core/hash.js +34 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/logger.d.ts +16 -0
- package/dist/core/logger.js +36 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/overlap.d.ts +79 -0
- package/dist/core/overlap.js +155 -0
- package/dist/core/overlap.js.map +1 -0
- package/dist/core/parameters.d.ts +249 -0
- package/dist/core/parameters.js +944 -0
- package/dist/core/parameters.js.map +1 -0
- package/dist/core/paths.d.ts +20 -0
- package/dist/core/paths.js +35 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/planner.d.ts +36 -0
- package/dist/core/planner.js +364 -0
- package/dist/core/planner.js.map +1 -0
- package/dist/core/prompt.d.ts +52 -0
- package/dist/core/prompt.js +197 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/refmap.d.ts +91 -0
- package/dist/core/refmap.js +331 -0
- package/dist/core/refmap.js.map +1 -0
- package/dist/core/refs.d.ts +297 -0
- package/dist/core/refs.js +801 -0
- package/dist/core/refs.js.map +1 -0
- package/dist/core/registry.d.ts +119 -0
- package/dist/core/registry.js +363 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/rename.d.ts +36 -0
- package/dist/core/rename.js +74 -0
- package/dist/core/rename.js.map +1 -0
- package/dist/core/rollback.d.ts +38 -0
- package/dist/core/rollback.js +226 -0
- package/dist/core/rollback.js.map +1 -0
- package/dist/core/semver.d.ts +56 -0
- package/dist/core/semver.js +214 -0
- package/dist/core/semver.js.map +1 -0
- package/dist/core/state.d.ts +99 -0
- package/dist/core/state.js +196 -0
- package/dist/core/state.js.map +1 -0
- package/dist/core/store.d.ts +30 -0
- package/dist/core/store.js +54 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/types.d.ts +515 -0
- package/dist/core/types.js +49 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/merge/blocks.d.ts +48 -0
- package/dist/merge/blocks.js +0 -0
- package/dist/merge/blocks.js.map +1 -0
- package/dist/merge/json-merge.d.ts +66 -0
- package/dist/merge/json-merge.js +176 -0
- package/dist/merge/json-merge.js.map +1 -0
- package/dist/merge/toml.d.ts +48 -0
- package/dist/merge/toml.js +118 -0
- package/dist/merge/toml.js.map +1 -0
- package/dist/targets/claude-code.d.ts +11 -0
- package/dist/targets/claude-code.js +94 -0
- package/dist/targets/claude-code.js.map +1 -0
- package/dist/targets/copilot.d.ts +13 -0
- package/dist/targets/copilot.js +126 -0
- package/dist/targets/copilot.js.map +1 -0
- package/dist/targets/index.d.ts +20 -0
- package/dist/targets/index.js +60 -0
- package/dist/targets/index.js.map +1 -0
- package/dist/targets/opencode.d.ts +32 -0
- package/dist/targets/opencode.js +172 -0
- package/dist/targets/opencode.js.map +1 -0
- package/dist/targets/pi.d.ts +42 -0
- package/dist/targets/pi.js +134 -0
- package/dist/targets/pi.js.map +1 -0
- package/dist/targets/reasonix.d.ts +27 -0
- package/dist/targets/reasonix.js +192 -0
- package/dist/targets/reasonix.js.map +1 -0
- package/dist/targets/shared.d.ts +33 -0
- package/dist/targets/shared.js +109 -0
- package/dist/targets/shared.js.map +1 -0
- package/dist/targets/types.d.ts +40 -0
- package/dist/targets/types.js +17 -0
- package/dist/targets/types.js.map +1 -0
- package/docs/authoring-bundles.md +828 -0
- package/package.json +74 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { flavorNames } from '../core/flavors.js';
|
|
2
|
+
import { parameterNames } from '../core/parameters.js';
|
|
3
|
+
import { describeSource } from '../core/github.js';
|
|
4
|
+
import { color, log } from '../core/logger.js';
|
|
5
|
+
import { liveEntries, readRegistry } from '../core/registry.js';
|
|
6
|
+
import { readState } from '../core/state.js';
|
|
7
|
+
export async function listCommand(options) {
|
|
8
|
+
if (options.installed)
|
|
9
|
+
return listInstalled(options);
|
|
10
|
+
return listAvailable(options);
|
|
11
|
+
}
|
|
12
|
+
async function listAvailable(options) {
|
|
13
|
+
const registry = await readRegistry();
|
|
14
|
+
// A dev entry is a pointer at a working copy, not a copy of it, so what it
|
|
15
|
+
// offers today is in its manifest rather than in the registry. See liveEntry.
|
|
16
|
+
const entries = await liveEntries(registry.entries);
|
|
17
|
+
// Mark which registered bundles are installed somewhere, so one listing answers
|
|
18
|
+
// both "what can I install?" and "what is already here?".
|
|
19
|
+
const installed = new Set();
|
|
20
|
+
for (const scope of ['project', 'user']) {
|
|
21
|
+
const state = await readState(scope, options.cwd);
|
|
22
|
+
for (const record of state.installations)
|
|
23
|
+
installed.add(record.bundle);
|
|
24
|
+
}
|
|
25
|
+
if (options.json) {
|
|
26
|
+
log.plain(JSON.stringify(entries.map((entry) => ({ ...entry, installed: installed.has(entry.name) })), null, 2));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (entries.length === 0) {
|
|
30
|
+
log.info('No bundles registered.');
|
|
31
|
+
log.info(color.dim('Add one with: hcm registry add <path|owner/repo>'));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const nameWidth = Math.max(...entries.map((entry) => entry.name.length));
|
|
35
|
+
const idWidth = Math.max(...entries.map((entry) => entry.id.length));
|
|
36
|
+
for (const entry of entries) {
|
|
37
|
+
const marker = installed.has(entry.name) ? color.green('●') : color.dim('○');
|
|
38
|
+
const version = entry.version ? color.dim(` v${entry.version}`) : '';
|
|
39
|
+
const mode = entry.dev ? color.yellow(' [dev]') : '';
|
|
40
|
+
log.plain(`${marker} ${color.dim(entry.id.padStart(idWidth))} ` +
|
|
41
|
+
`${color.bold(entry.name.padEnd(nameWidth))}${version}${mode}`);
|
|
42
|
+
const indent = ' '.repeat(idWidth + 4);
|
|
43
|
+
if (options.descriptions && entry.description) {
|
|
44
|
+
log.plain(`${indent}${color.dim(entry.description)}`);
|
|
45
|
+
}
|
|
46
|
+
log.plain(`${indent}${color.dim(describeSource(entry.source))}`);
|
|
47
|
+
// The parts it can be installed as -- "what can I install?" has a longer
|
|
48
|
+
// answer than the name for a bundle that offers flavors.
|
|
49
|
+
if (entry.flavors?.length) {
|
|
50
|
+
log.plain(`${indent}${color.dim(`flavors: ${flavorNames(entry.flavors)}`)}`);
|
|
51
|
+
}
|
|
52
|
+
// And what installing it will ask for, for the same reason.
|
|
53
|
+
if (entry.parameters?.length) {
|
|
54
|
+
log.plain(`${indent}${color.dim(`parameters: ${parameterNames(entry.parameters)}`)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function listInstalled(options) {
|
|
59
|
+
const scopes = options.scope === 'all' || options.scope === undefined ? ['project', 'user'] : [options.scope];
|
|
60
|
+
const rows = [];
|
|
61
|
+
for (const scope of scopes) {
|
|
62
|
+
const state = await readState(scope, options.cwd);
|
|
63
|
+
rows.push(...state.installations);
|
|
64
|
+
}
|
|
65
|
+
if (options.json) {
|
|
66
|
+
log.plain(JSON.stringify(rows, null, 2));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (rows.length === 0) {
|
|
70
|
+
log.info(`No bundles installed in ${scopes.join(' or ')} scope.`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
for (const scope of scopes) {
|
|
74
|
+
const scoped = rows.filter((record) => record.scope === scope);
|
|
75
|
+
if (scoped.length === 0)
|
|
76
|
+
continue;
|
|
77
|
+
log.plain(color.bold(`\n${scope} scope`));
|
|
78
|
+
for (const record of scoped) {
|
|
79
|
+
const when = record.installedAt.slice(0, 10);
|
|
80
|
+
// A bundle nobody asked for by name is here for something else's sake,
|
|
81
|
+
// and goes when that something else does.
|
|
82
|
+
const why = record.auto ? color.dim(' [dependency]') : '';
|
|
83
|
+
const needs = record.dependencies?.length
|
|
84
|
+
? color.dim(` · requires ${record.dependencies.map((d) => d.name).join(', ')}`)
|
|
85
|
+
: '';
|
|
86
|
+
// Part of a bundle rather than all of it: without this the item count is
|
|
87
|
+
// the only clue, and it is not one anybody can read.
|
|
88
|
+
const part = record.flavors?.length
|
|
89
|
+
? color.yellow(` [${record.flavors.join(', ')}]`)
|
|
90
|
+
: '';
|
|
91
|
+
log.plain(` ${color.green('●')} ${color.bold(record.bundle)} ${color.dim(`v${record.version}`)}${why}${part} ` +
|
|
92
|
+
`→ ${record.target} ${color.dim(`· ${record.receipts.length} item(s) · ${when}`)}${needs}`);
|
|
93
|
+
// The values its templates were rendered with, and what `hcm update`
|
|
94
|
+
// will render the next version with unless it is told otherwise.
|
|
95
|
+
const parameters = Object.entries(record.parameters ?? {});
|
|
96
|
+
if (parameters.length > 0) {
|
|
97
|
+
log.plain(color.dim(` ${parameters.map(([name, value]) => `${name}=${value}`).join(' ')}`));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAW7C,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAoB;IACpD,IAAI,OAAO,CAAC,SAAS;QAAE,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;IACrD,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,OAAoB;IAC/C,MAAM,QAAQ,GAAG,MAAM,YAAY,EAAE,CAAC;IACtC,2EAA2E;IAC3E,8EAA8E;IAC9E,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAEpD,gFAAgF;IAChF,0DAA0D;IAC1D,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,KAAK,MAAM,KAAK,IAAI,CAAC,SAAS,EAAE,MAAM,CAAY,EAAE,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM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IAAI,EAAE,CAAC,GAAG,KAAK,EAAE,CAC7F,CAAC;YACF,qEAAqE;YACrE,iEAAiE;YACjE,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;YAC3D,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,GAAG,CAAC,KAAK,CACP,KAAK,CAAC,GAAG,CACP,SAAS,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC5E,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hcm params` — the values bundles are customised with.
|
|
3
|
+
*
|
|
4
|
+
* Two halves. `list` reports what each installation was rendered with, and is
|
|
5
|
+
* read-only on purpose: the values live in the installation ledger because that
|
|
6
|
+
* is the thing they belong to, and editing them there would leave the ledger
|
|
7
|
+
* describing an install that does not exist. Changing one means rendering the
|
|
8
|
+
* bundle again, which is what `hcm install --param` and `hcm update --param` do.
|
|
9
|
+
*
|
|
10
|
+
* `init` writes the other end of the same story: a file with every question a
|
|
11
|
+
* set of bundles will ask, each with whatever answer hcm can already work out,
|
|
12
|
+
* for you to fill in the rest of and hand back with `--params-file`.
|
|
13
|
+
*
|
|
14
|
+
* See `core/parameters.ts` for what a parameter is.
|
|
15
|
+
*/
|
|
16
|
+
import type { Scope } from '../core/types.js';
|
|
17
|
+
export interface ParamsOptions {
|
|
18
|
+
targets?: string[];
|
|
19
|
+
scope?: Scope | 'all';
|
|
20
|
+
json?: boolean;
|
|
21
|
+
cwd: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function paramsListCommand(references: string | string[] | undefined, options: ParamsOptions): Promise<void>;
|
|
24
|
+
export declare const DEFAULT_PARAMS_FILE = "params.yaml";
|
|
25
|
+
export interface ParamsInitOptions {
|
|
26
|
+
/** Which harnesses the file should cover. Defaults to what is in play. */
|
|
27
|
+
targets?: string[];
|
|
28
|
+
/** Narrow to what an install of these flavors would ask for. */
|
|
29
|
+
flavors?: string[];
|
|
30
|
+
scope: Scope;
|
|
31
|
+
/** Where to write. Defaults to `params.yaml` in the working directory. */
|
|
32
|
+
output?: string;
|
|
33
|
+
/** Print it instead of writing a file. */
|
|
34
|
+
stdout?: boolean;
|
|
35
|
+
/** Replace a file that is already there. */
|
|
36
|
+
force?: boolean;
|
|
37
|
+
cwd: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Write a parameters file for a set of bundles: every question they will ask,
|
|
41
|
+
* each with the best answer hcm can already give.
|
|
42
|
+
*
|
|
43
|
+
* The point is the round trip. `--params-file` is the only way to install a
|
|
44
|
+
* customised bundle with nothing to type and nobody to ask, and working out
|
|
45
|
+
* what belongs in one means reading every manifest by hand. So hcm writes the
|
|
46
|
+
* questions and you write the answers:
|
|
47
|
+
*
|
|
48
|
+
* hcm params init my-kit # writes params.yaml
|
|
49
|
+
* $EDITOR params.yaml # fill in the blanks
|
|
50
|
+
* hcm install my-kit --params-file params.yaml
|
|
51
|
+
*
|
|
52
|
+
* Values already known are filled in rather than left blank -- what this
|
|
53
|
+
* project recorded at its last install, or failing that the parameter's own
|
|
54
|
+
* default. Running it against an installed setup therefore produces a file that
|
|
55
|
+
* *reproduces* that setup, which is the form worth committing or handing to
|
|
56
|
+
* somebody setting up the same project.
|
|
57
|
+
*/
|
|
58
|
+
export declare function paramsInitCommand(references: string | string[] | undefined, options: ParamsInitOptions): Promise<void>;
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hcm params` — the values bundles are customised with.
|
|
3
|
+
*
|
|
4
|
+
* Two halves. `list` reports what each installation was rendered with, and is
|
|
5
|
+
* read-only on purpose: the values live in the installation ledger because that
|
|
6
|
+
* is the thing they belong to, and editing them there would leave the ledger
|
|
7
|
+
* describing an install that does not exist. Changing one means rendering the
|
|
8
|
+
* bundle again, which is what `hcm install --param` and `hcm update --param` do.
|
|
9
|
+
*
|
|
10
|
+
* `init` writes the other end of the same story: a file with every question a
|
|
11
|
+
* set of bundles will ask, each with whatever answer hcm can already work out,
|
|
12
|
+
* for you to fill in the rest of and hand back with `--params-file`.
|
|
13
|
+
*
|
|
14
|
+
* See `core/parameters.ts` for what a parameter is.
|
|
15
|
+
*/
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import YAML from 'yaml';
|
|
18
|
+
import { HcmError } from '../core/errors.js';
|
|
19
|
+
import { pathExists, writeText } from '../core/fsx.js';
|
|
20
|
+
import { appliesTo } from '../core/parameters.js';
|
|
21
|
+
import { expandTargets } from '../core/harnesses.js';
|
|
22
|
+
import { color, log } from '../core/logger.js';
|
|
23
|
+
import { asList, resolveBundles } from '../core/registry.js';
|
|
24
|
+
import { readState } from '../core/state.js';
|
|
25
|
+
import { TARGET_IDS } from '../targets/index.js';
|
|
26
|
+
export async function paramsListCommand(references, options) {
|
|
27
|
+
const wanted = references === undefined ? [] : asList(references);
|
|
28
|
+
const names = new Set(wanted);
|
|
29
|
+
const targets = expandTargets(options.targets);
|
|
30
|
+
const scopes = options.scope === undefined || options.scope === 'all'
|
|
31
|
+
? ['project', 'user']
|
|
32
|
+
: [options.scope];
|
|
33
|
+
const rows = [];
|
|
34
|
+
for (const scope of scopes) {
|
|
35
|
+
const state = await readState(scope, options.cwd);
|
|
36
|
+
rows.push(...state.installations.filter((record) => (names.size === 0 || names.has(record.bundle)) &&
|
|
37
|
+
(!targets || targets.includes(record.target))));
|
|
38
|
+
}
|
|
39
|
+
if (options.json) {
|
|
40
|
+
log.plain(JSON.stringify(rows.map((record) => ({
|
|
41
|
+
bundle: record.bundle,
|
|
42
|
+
target: record.target,
|
|
43
|
+
scope: record.scope,
|
|
44
|
+
parameters: record.parameters ?? {},
|
|
45
|
+
})), null, 2));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const withValues = rows.filter((record) => Object.keys(record.parameters ?? {}).length > 0);
|
|
49
|
+
if (withValues.length === 0) {
|
|
50
|
+
log.info(rows.length === 0
|
|
51
|
+
? `Nothing installed in ${scopes.join(' or ')} scope.`
|
|
52
|
+
: 'No installation here was customised with parameters.');
|
|
53
|
+
log.info(color.dim('A bundle declares them in its manifest; see "hcm info <bundle>".'));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
for (const scope of scopes) {
|
|
57
|
+
const scoped = withValues.filter((record) => record.scope === scope);
|
|
58
|
+
if (scoped.length === 0)
|
|
59
|
+
continue;
|
|
60
|
+
log.plain(color.bold(`\n${scope} scope`));
|
|
61
|
+
for (const record of scoped) {
|
|
62
|
+
log.plain(` ${color.bold(record.bundle)} ${color.dim(`→ ${record.target}`)}`);
|
|
63
|
+
const entries = Object.entries(record.parameters ?? {});
|
|
64
|
+
const width = Math.max(...entries.map(([name]) => name.length));
|
|
65
|
+
for (const [name, value] of entries) {
|
|
66
|
+
log.plain(` ${name.padEnd(width)} ${color.dim('=')} ${value}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
log.plain('');
|
|
71
|
+
log.info(color.dim('These are what "hcm update" will render the next version with. Change one with: ' +
|
|
72
|
+
`hcm update ${describeOne(withValues[0])} --param NAME=value`));
|
|
73
|
+
log.info(color.dim('Parameters declared "secret" are not recorded, and have to be given again.'));
|
|
74
|
+
}
|
|
75
|
+
/** A bundle name and, where it matters, the harness -- for the example command. */
|
|
76
|
+
function describeOne(record) {
|
|
77
|
+
const target = record.target;
|
|
78
|
+
return `${record.bundle} -t ${target}`;
|
|
79
|
+
}
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Writing a file to fill in
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
export const DEFAULT_PARAMS_FILE = 'params.yaml';
|
|
84
|
+
/**
|
|
85
|
+
* Write a parameters file for a set of bundles: every question they will ask,
|
|
86
|
+
* each with the best answer hcm can already give.
|
|
87
|
+
*
|
|
88
|
+
* The point is the round trip. `--params-file` is the only way to install a
|
|
89
|
+
* customised bundle with nothing to type and nobody to ask, and working out
|
|
90
|
+
* what belongs in one means reading every manifest by hand. So hcm writes the
|
|
91
|
+
* questions and you write the answers:
|
|
92
|
+
*
|
|
93
|
+
* hcm params init my-kit # writes params.yaml
|
|
94
|
+
* $EDITOR params.yaml # fill in the blanks
|
|
95
|
+
* hcm install my-kit --params-file params.yaml
|
|
96
|
+
*
|
|
97
|
+
* Values already known are filled in rather than left blank -- what this
|
|
98
|
+
* project recorded at its last install, or failing that the parameter's own
|
|
99
|
+
* default. Running it against an installed setup therefore produces a file that
|
|
100
|
+
* *reproduces* that setup, which is the form worth committing or handing to
|
|
101
|
+
* somebody setting up the same project.
|
|
102
|
+
*/
|
|
103
|
+
export async function paramsInitCommand(references, options) {
|
|
104
|
+
const wanted = references === undefined ? [] : asList(references);
|
|
105
|
+
const chosen = expandTargets(options.targets);
|
|
106
|
+
const installed = (await readState(options.scope, options.cwd)).installations;
|
|
107
|
+
const bundles = await gather(wanted, installed, options);
|
|
108
|
+
if (bundles.length === 0)
|
|
109
|
+
return;
|
|
110
|
+
const sections = bundles.map((bundle) => describeSection(bundle, installed, chosen, options.flavors ?? []));
|
|
111
|
+
const asking = sections.filter((section) => section.entries.length > 0);
|
|
112
|
+
if (asking.length === 0) {
|
|
113
|
+
log.info(`${bundles.map((bundle) => bundle.manifest.name).join(', ')} ` +
|
|
114
|
+
`${bundles.length === 1 ? 'asks' : 'ask'} for no parameters; there is nothing to fill in.`);
|
|
115
|
+
log.info(color.dim('A bundle declares them under "parameters:" in its manifest.'));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const contents = render(asking, wanted);
|
|
119
|
+
if (options.stdout) {
|
|
120
|
+
log.plain(contents.trimEnd());
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const target = path.resolve(options.cwd, options.output ?? DEFAULT_PARAMS_FILE);
|
|
124
|
+
if (!options.force && (await pathExists(target))) {
|
|
125
|
+
throw new HcmError(`${target} already exists`, 'Pass --force to replace it, --output to write somewhere else, or --stdout to print it.');
|
|
126
|
+
}
|
|
127
|
+
await writeText(target, contents);
|
|
128
|
+
const total = asking.reduce((count, section) => count + section.entries.length, 0);
|
|
129
|
+
log.success(`Wrote ${total} parameter(s) for ${asking.length} bundle(s) to ${target}`);
|
|
130
|
+
}
|
|
131
|
+
reportBlanks(asking);
|
|
132
|
+
const names = asking.map((section) => section.bundle).join(' ');
|
|
133
|
+
log.info(color.dim(`Fill it in, then: hcm install ${names} --params-file ` +
|
|
134
|
+
`${options.stdout ? DEFAULT_PARAMS_FILE : options.output ?? DEFAULT_PARAMS_FILE}`));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The bundles the file should cover: the ones named, or -- naming none -- the
|
|
138
|
+
* ones installed here, which is the "write down what this project is already
|
|
139
|
+
* set up as" case.
|
|
140
|
+
*
|
|
141
|
+
* An installed bundle with no registry entry is reported and skipped rather
|
|
142
|
+
* than thrown from: its parameters are only knowable by reading it, and one
|
|
143
|
+
* unreachable bundle must not cost you the file for all the others.
|
|
144
|
+
*/
|
|
145
|
+
async function gather(wanted, installed, options) {
|
|
146
|
+
if (wanted.length > 0) {
|
|
147
|
+
const bundles = [];
|
|
148
|
+
for (const reference of wanted) {
|
|
149
|
+
bundles.push(...(await resolveBundles(reference, options.cwd)));
|
|
150
|
+
}
|
|
151
|
+
return bundles;
|
|
152
|
+
}
|
|
153
|
+
const names = [...new Set(installed.map((record) => record.bundle))].sort();
|
|
154
|
+
if (names.length === 0) {
|
|
155
|
+
log.info(`Nothing installed in ${options.scope} scope, and no bundle named.`);
|
|
156
|
+
log.info(color.dim('Name one: hcm params init <bundle...>'));
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
const bundles = [];
|
|
160
|
+
for (const name of names) {
|
|
161
|
+
const found = await readInstalled(name, installed, options.cwd);
|
|
162
|
+
if (found.length > 0) {
|
|
163
|
+
bundles.push(...found);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
log.warn(`${name} is installed here but cannot be read; leaving it out of the file`);
|
|
167
|
+
log.warn(color.dim(' register its source with: hcm registry add <path|owner/repo>'));
|
|
168
|
+
}
|
|
169
|
+
return bundles;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Read an installed bundle, to find out what it asks for.
|
|
173
|
+
*
|
|
174
|
+
* The registry first, since that is the copy `hcm update` would reinstall from
|
|
175
|
+
* and therefore the one whose questions matter. Failing that, the source the
|
|
176
|
+
* installation itself recorded -- a bundle installed straight from a path was
|
|
177
|
+
* never registered, and refusing to write its parameters down would be a
|
|
178
|
+
* strange way to reward the shorter command.
|
|
179
|
+
*/
|
|
180
|
+
async function readInstalled(name, installed, cwd) {
|
|
181
|
+
try {
|
|
182
|
+
return await resolveBundles(name, cwd);
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
// Fall through to the recorded source.
|
|
186
|
+
}
|
|
187
|
+
const source = installed.find((record) => record.bundle === name)?.source;
|
|
188
|
+
if (source?.type !== 'local')
|
|
189
|
+
return [];
|
|
190
|
+
try {
|
|
191
|
+
return await resolveBundles(source.path, cwd);
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* What one bundle contributes, and what each of its parameters should say.
|
|
199
|
+
*
|
|
200
|
+
* A value already settled is written rather than blanked: what this project
|
|
201
|
+
* recorded last time, then the parameter's own default. A secret is always
|
|
202
|
+
* blank -- it was deliberately never recorded, so pretending to know it would
|
|
203
|
+
* be the one lie this file could tell.
|
|
204
|
+
*/
|
|
205
|
+
function describeSection(bundle, installed, chosen, flavors) {
|
|
206
|
+
const records = installed.filter((record) => record.bundle === bundle.manifest.name);
|
|
207
|
+
const targets = targetsInPlay(bundle, records, chosen);
|
|
208
|
+
const entries = [];
|
|
209
|
+
for (const parameter of bundle.parameters) {
|
|
210
|
+
// Narrowing by flavor here answers "what will *this* install ask me",
|
|
211
|
+
// which is the file you want when you already know how you are installing.
|
|
212
|
+
if (flavors.length > 0 && !appliesTo(parameter, { target: targets[0], flavors })) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (parameter.targets.length === 0) {
|
|
216
|
+
entries.push({ parameter, ...blankOr(recorded(records, parameter.name), parameter) });
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
// A harness-scoped parameter is a fact about a harness, so it gets one
|
|
220
|
+
// entry per harness it applies to -- which is also where a reader learns
|
|
221
|
+
// that any parameter can be given a different value per harness.
|
|
222
|
+
for (const target of targets) {
|
|
223
|
+
if (!parameter.targets.includes(target))
|
|
224
|
+
continue;
|
|
225
|
+
const from = records.find((record) => record.target === target);
|
|
226
|
+
entries.push({
|
|
227
|
+
parameter,
|
|
228
|
+
target,
|
|
229
|
+
...blankOr(from?.parameters?.[parameter.name], parameter),
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return { bundle: bundle.manifest.name, entries };
|
|
234
|
+
}
|
|
235
|
+
/** The value to write for one entry: what is known, or nothing at all. */
|
|
236
|
+
function blankOr(known, parameter) {
|
|
237
|
+
if (parameter.secret)
|
|
238
|
+
return {};
|
|
239
|
+
const value = known ?? parameter.default;
|
|
240
|
+
return value === undefined ? {} : { value };
|
|
241
|
+
}
|
|
242
|
+
/** What any installation of this bundle recorded for a name, whichever harness. */
|
|
243
|
+
function recorded(records, name) {
|
|
244
|
+
for (const record of records) {
|
|
245
|
+
const value = record.parameters?.[name];
|
|
246
|
+
if (value !== undefined)
|
|
247
|
+
return value;
|
|
248
|
+
}
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The harnesses the file should have sections for: the ones asked for, else the
|
|
253
|
+
* ones this bundle is already installed into, else the ones it supports.
|
|
254
|
+
*/
|
|
255
|
+
function targetsInPlay(bundle, records, chosen) {
|
|
256
|
+
if (chosen?.length)
|
|
257
|
+
return chosen;
|
|
258
|
+
const installed = [...new Set(records.map((record) => record.target))];
|
|
259
|
+
if (installed.length > 0)
|
|
260
|
+
return installed;
|
|
261
|
+
return bundle.manifest.targets?.length ? bundle.manifest.targets : [...TARGET_IDS];
|
|
262
|
+
}
|
|
263
|
+
// ---------------------------------------------------------------------------
|
|
264
|
+
// Rendering
|
|
265
|
+
// ---------------------------------------------------------------------------
|
|
266
|
+
/**
|
|
267
|
+
* The file itself.
|
|
268
|
+
*
|
|
269
|
+
* Written by hand rather than by `YAML.stringify`, because the comments are
|
|
270
|
+
* most of the value: what each parameter is for, whether it has to be answered,
|
|
271
|
+
* what it will accept. Only the scalars go through the YAML writer, which is
|
|
272
|
+
* what keeps a value with a colon in it from breaking the file.
|
|
273
|
+
*/
|
|
274
|
+
function render(sections, wanted) {
|
|
275
|
+
const lines = [
|
|
276
|
+
'# hcm parameters file',
|
|
277
|
+
`# generated ${new Date().toISOString()}`,
|
|
278
|
+
'#',
|
|
279
|
+
'# Fill in the blanks, then install with:',
|
|
280
|
+
`# hcm install ${sections.map((section) => section.bundle).join(' ')} --params-file <this file>`,
|
|
281
|
+
'#',
|
|
282
|
+
'# A blank means "not said": hcm falls back to the default, or asks. Write',
|
|
283
|
+
'# KEY: "" to mean the value really is empty.',
|
|
284
|
+
'#',
|
|
285
|
+
'# Values can be given at three levels, the narrowest winning:',
|
|
286
|
+
'# at the top of this file any bundle that asks for that name',
|
|
287
|
+
'# under bundles.<name> that bundle',
|
|
288
|
+
'# under bundles.<name>.targets.<harness> that bundle, in one harness',
|
|
289
|
+
...(wanted.length === 0
|
|
290
|
+
? ['#', '# Prefilled from what this project is installed as.']
|
|
291
|
+
: []),
|
|
292
|
+
'',
|
|
293
|
+
'bundles:',
|
|
294
|
+
];
|
|
295
|
+
for (const [index, section] of sections.entries()) {
|
|
296
|
+
if (index > 0)
|
|
297
|
+
lines.push('');
|
|
298
|
+
lines.push(` ${section.bundle}:`);
|
|
299
|
+
for (const entry of section.entries.filter((one) => one.target === undefined)) {
|
|
300
|
+
lines.push(...entryLines(entry, ' '));
|
|
301
|
+
}
|
|
302
|
+
const scoped = section.entries.filter((one) => one.target !== undefined);
|
|
303
|
+
if (scoped.length === 0)
|
|
304
|
+
continue;
|
|
305
|
+
lines.push(' # Values for one harness only. Any parameter above can be moved');
|
|
306
|
+
lines.push(' # in here to give it a different value per harness.');
|
|
307
|
+
lines.push(' targets:');
|
|
308
|
+
for (const target of [...new Set(scoped.map((one) => one.target))]) {
|
|
309
|
+
lines.push(` ${target}:`);
|
|
310
|
+
for (const entry of scoped.filter((one) => one.target === target)) {
|
|
311
|
+
lines.push(...entryLines(entry, ' '));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return `${lines.join('\n')}\n`;
|
|
316
|
+
}
|
|
317
|
+
/** One parameter: its notes, then the key and whatever value we could supply. */
|
|
318
|
+
function entryLines(entry, indent) {
|
|
319
|
+
const { parameter } = entry;
|
|
320
|
+
const lines = [];
|
|
321
|
+
if (parameter.description)
|
|
322
|
+
lines.push(`${indent}# ${parameter.description}`);
|
|
323
|
+
const notes = [
|
|
324
|
+
...(entry.value === undefined && parameter.required ? ['REQUIRED — no default'] : []),
|
|
325
|
+
...(parameter.secret ? ['secret — never recorded, so it must be given every time'] : []),
|
|
326
|
+
...(parameter.choices ? [`one of: ${parameter.choices.join(', ')}`] : []),
|
|
327
|
+
...(parameter.pattern ? [`must match: ${parameter.pattern}`] : []),
|
|
328
|
+
...(parameter.flavors.length > 0
|
|
329
|
+
? [`only asked for with --flavor ${parameter.flavors.join(' ')}`]
|
|
330
|
+
: []),
|
|
331
|
+
];
|
|
332
|
+
for (const note of notes)
|
|
333
|
+
lines.push(`${indent}# ${note}`);
|
|
334
|
+
lines.push(`${indent}${parameter.name}:${entry.value === undefined ? '' : ` ${scalar(entry.value)}`}`);
|
|
335
|
+
return lines;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* One value, quoted the way YAML needs it. Folding is off: a long value broken
|
|
339
|
+
* across lines would still parse, but nobody wants to edit that.
|
|
340
|
+
*/
|
|
341
|
+
function scalar(value) {
|
|
342
|
+
return YAML.stringify(value, { lineWidth: 0 }).trimEnd();
|
|
343
|
+
}
|
|
344
|
+
/** Say how many blanks are left, since that is what the file is for. */
|
|
345
|
+
function reportBlanks(sections) {
|
|
346
|
+
const blanks = sections.flatMap((section) => section.entries
|
|
347
|
+
.filter((entry) => entry.value === undefined)
|
|
348
|
+
.map((entry) => ({ bundle: section.bundle, entry })));
|
|
349
|
+
if (blanks.length === 0) {
|
|
350
|
+
log.info(color.dim('Every value was already known; nothing is left blank.'));
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const required = blanks.filter(({ entry }) => entry.parameter.required);
|
|
354
|
+
log.warn(`${blanks.length} value(s) left blank` +
|
|
355
|
+
(required.length > 0 ? `, ${required.length} of which must be filled in:` : ':'));
|
|
356
|
+
for (const { bundle, entry } of blanks) {
|
|
357
|
+
const where = entry.target ? color.dim(` (${entry.target})`) : '';
|
|
358
|
+
const why = entry.parameter.secret
|
|
359
|
+
? color.dim(' — secret')
|
|
360
|
+
: entry.parameter.required
|
|
361
|
+
? color.yellow(' — required')
|
|
362
|
+
: color.dim(' — optional');
|
|
363
|
+
log.plain(` ${color.dim(`${bundle}.`)}${entry.parameter.name}${where}${why}`);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
//# sourceMappingURL=params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../src/commands/params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC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*
|
|
6
|
+
* 1. scan, and for every broken reference work out what it probably meant
|
|
7
|
+
* 2. write that out as JSON -- one entry per broken reference, each with the
|
|
8
|
+
* candidates ranked best first
|
|
9
|
+
* 3. the user deletes the wrong ones, leaving exactly one per entry
|
|
10
|
+
* 4. on save and close, every entry with one candidate left is applied
|
|
11
|
+
*
|
|
12
|
+
* The list-of-candidates shape is the point. A rename that broke twenty
|
|
13
|
+
* references usually broke them in two or three distinct ways, and picking from
|
|
14
|
+
* a ranked list is a keystroke where typing the path is a fresh chance to get
|
|
15
|
+
* it wrong. Entries left with more than one candidate are not guessed at; they
|
|
16
|
+
* are reported and left alone, so an unfinished pass through the file cannot
|
|
17
|
+
* quietly write something nobody chose.
|
|
18
|
+
*/
|
|
19
|
+
import { type RefScope, type ScanResult } from '../core/refs.js';
|
|
20
|
+
export interface RefsCheckOptions extends RefScope {
|
|
21
|
+
path?: string;
|
|
22
|
+
json?: boolean;
|
|
23
|
+
cwd: string;
|
|
24
|
+
}
|
|
25
|
+
export interface RefsFixOptions extends RefScope {
|
|
26
|
+
path?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Write the fix file and stop, instead of opening an editor. Takes an
|
|
29
|
+
* optional path; `true` means the default name in the working directory.
|
|
30
|
+
*/
|
|
31
|
+
write?: boolean | string;
|
|
32
|
+
/** Apply an already-edited fix file rather than producing a new one. */
|
|
33
|
+
file?: string;
|
|
34
|
+
dryRun?: boolean;
|
|
35
|
+
/** Test seam: stands in for the user's editor. */
|
|
36
|
+
edit?: (file: string) => Promise<void>;
|
|
37
|
+
cwd: string;
|
|
38
|
+
}
|
|
39
|
+
/** The shape written to disk, exactly as documented. */
|
|
40
|
+
export interface FixEntry {
|
|
41
|
+
original_ref: string;
|
|
42
|
+
new: string[];
|
|
43
|
+
}
|
|
44
|
+
export type FixFile = Record<string, FixEntry>;
|
|
45
|
+
export declare function refsCheckCommand(options: RefsCheckOptions): Promise<boolean>;
|
|
46
|
+
export declare function refsFixCommand(options: RefsFixOptions): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* One entry per broken reference.
|
|
49
|
+
*
|
|
50
|
+
* The key is the file the reference is in, which is what makes the file
|
|
51
|
+
* readable -- but a file may well have broken several references at once, and
|
|
52
|
+
* JSON objects do not keep duplicate keys. Later entries for the same file get
|
|
53
|
+
* a `#2`, `#3` suffix; `original_ref` is what actually identifies the
|
|
54
|
+
* reference, so nothing depends on the suffix.
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildFixFile(result: ScanResult): FixFile;
|
|
57
|
+
export declare function editorCommand(configured: string | undefined, file: string): {
|
|
58
|
+
command: string;
|
|
59
|
+
args: string[];
|
|
60
|
+
};
|