@canonical/summon-core 0.33.0 → 0.35.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/dist/esm/discovery/discoverGeneratorTree.js +14 -10
- package/dist/esm/discovery/discoverGeneratorTree.js.map +1 -1
- package/dist/esm/execute/collectAnswers.js +23 -17
- package/dist/esm/execute/collectAnswers.js.map +1 -1
- package/dist/esm/execute/execute.js +67 -22
- package/dist/esm/execute/execute.js.map +1 -1
- package/dist/esm/execute/index.js +1 -1
- package/dist/esm/execute/index.js.map +1 -1
- package/dist/esm/execute/validateAnswers.js +19 -5
- package/dist/esm/execute/validateAnswers.js.map +1 -1
- package/dist/esm/format/effects.js +199 -53
- package/dist/esm/format/effects.js.map +1 -1
- package/dist/esm/format/formatFlagName.js +17 -0
- package/dist/esm/format/formatFlagName.js.map +1 -0
- package/dist/esm/format/index.js +19 -1
- package/dist/esm/format/index.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/projection/answers.js +84 -0
- package/dist/esm/projection/answers.js.map +1 -0
- package/dist/esm/projection/buildOptionInfo.js +77 -0
- package/dist/esm/projection/buildOptionInfo.js.map +1 -0
- package/dist/esm/projection/commander/configureGroupedHelp.js +39 -0
- package/dist/esm/projection/commander/configureGroupedHelp.js.map +1 -0
- package/dist/esm/projection/commander/emitToProcess.js +15 -0
- package/dist/esm/projection/commander/emitToProcess.js.map +1 -0
- package/dist/esm/projection/commander/index.js +20 -0
- package/dist/esm/projection/commander/index.js.map +1 -0
- package/dist/esm/projection/commander/registerGeneratorCommands.js +222 -0
- package/dist/esm/projection/commander/registerGeneratorCommands.js.map +1 -0
- package/dist/esm/projection/decideInteraction.js +73 -0
- package/dist/esm/projection/decideInteraction.js.map +1 -0
- package/dist/esm/projection/extractAnswers.js +52 -0
- package/dist/esm/projection/extractAnswers.js.map +1 -0
- package/dist/esm/projection/groupedHelp.js +74 -0
- package/dist/esm/projection/groupedHelp.js.map +1 -0
- package/dist/esm/projection/index.js +26 -0
- package/dist/esm/projection/index.js.map +1 -0
- package/dist/esm/projection/kebab.js +18 -0
- package/dist/esm/projection/kebab.js.map +1 -0
- package/dist/esm/projection/projectGenerator.js +46 -0
- package/dist/esm/projection/projectGenerator.js.map +1 -0
- package/dist/esm/projection/types.js +16 -0
- package/dist/esm/projection/types.js.map +1 -0
- package/dist/esm/projection/usage.js +144 -0
- package/dist/esm/projection/usage.js.map +1 -0
- package/dist/esm/prompt/answerPromptWithDefaults.js +7 -5
- package/dist/esm/prompt/answerPromptWithDefaults.js.map +1 -1
- package/dist/esm/prompt/autoPrompt.js +2 -3
- package/dist/esm/prompt/autoPrompt.js.map +1 -1
- package/dist/esm/prompt/ink/mount.js +4 -2
- package/dist/esm/prompt/ink/mount.js.map +1 -1
- package/dist/esm/prompt/ink/session.js +78 -15
- package/dist/esm/prompt/ink/session.js.map +1 -1
- package/dist/esm/prompt/inkPrompt.js +13 -4
- package/dist/esm/prompt/inkPrompt.js.map +1 -1
- package/dist/esm/prompt/mcpPrompt.js +1 -1
- package/dist/esm/prompt/mcpPrompt.js.map +1 -1
- package/dist/esm/run/runGeneratorTask.js +3 -1
- package/dist/esm/run/runGeneratorTask.js.map +1 -1
- package/dist/esm/stamp/applyStamp.js +50 -52
- package/dist/esm/stamp/applyStamp.js.map +1 -1
- package/dist/esm/stamp/createStampOnEffectStart.js +4 -1
- package/dist/esm/stamp/createStampOnEffectStart.js.map +1 -1
- package/dist/esm/stamp/runTaskWithStamp.js +8 -9
- package/dist/esm/stamp/runTaskWithStamp.js.map +1 -1
- package/dist/esm/template/index.js +2 -0
- package/dist/esm/template/index.js.map +1 -1
- package/dist/esm/template/loadTemplate.js +43 -0
- package/dist/esm/template/loadTemplate.js.map +1 -0
- package/dist/esm/template/prependStamp.js +11 -8
- package/dist/esm/template/prependStamp.js.map +1 -1
- package/dist/esm/template/rawFile.js +25 -0
- package/dist/esm/template/rawFile.js.map +1 -0
- package/dist/esm/template/tasks/template.js +12 -3
- package/dist/esm/template/tasks/template.js.map +1 -1
- package/dist/esm/template/tasks/templateDir.js +5 -0
- package/dist/esm/template/tasks/templateDir.js.map +1 -1
- package/dist/esm/testing/conformance/diffTrees.js +61 -0
- package/dist/esm/testing/conformance/diffTrees.js.map +1 -0
- package/dist/esm/testing/conformance/fixtures.js +81 -0
- package/dist/esm/testing/conformance/fixtures.js.map +1 -0
- package/dist/esm/testing/conformance/flagizeAnswers.js +91 -0
- package/dist/esm/testing/conformance/flagizeAnswers.js.map +1 -0
- package/dist/esm/testing/conformance/index.js +18 -0
- package/dist/esm/testing/conformance/index.js.map +1 -0
- package/dist/esm/testing/conformance/produceReference.js +47 -0
- package/dist/esm/testing/conformance/produceReference.js.map +1 -0
- package/dist/esm/testing/conformance/snapshotTree.js +35 -0
- package/dist/esm/testing/conformance/snapshotTree.js.map +1 -0
- package/dist/esm/testing/index.js +10 -0
- package/dist/esm/testing/index.js.map +1 -0
- package/dist/types/discovery/discoverGeneratorTree.d.ts +3 -3
- package/dist/types/discovery/discoverGeneratorTree.d.ts.map +1 -1
- package/dist/types/execute/collectAnswers.d.ts +6 -4
- package/dist/types/execute/collectAnswers.d.ts.map +1 -1
- package/dist/types/execute/execute.d.ts +27 -1
- package/dist/types/execute/execute.d.ts.map +1 -1
- package/dist/types/execute/index.d.ts +1 -1
- package/dist/types/execute/index.d.ts.map +1 -1
- package/dist/types/execute/validateAnswers.d.ts.map +1 -1
- package/dist/types/format/effects.d.ts +63 -9
- package/dist/types/format/effects.d.ts.map +1 -1
- package/dist/types/format/formatFlagName.d.ts +14 -0
- package/dist/types/format/formatFlagName.d.ts.map +1 -0
- package/dist/types/format/index.d.ts +20 -1
- package/dist/types/format/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/projection/answers.d.ts +54 -0
- package/dist/types/projection/answers.d.ts.map +1 -0
- package/dist/types/projection/buildOptionInfo.d.ts +25 -0
- package/dist/types/projection/buildOptionInfo.d.ts.map +1 -0
- package/dist/types/projection/commander/configureGroupedHelp.d.ts +29 -0
- package/dist/types/projection/commander/configureGroupedHelp.d.ts.map +1 -0
- package/dist/types/projection/commander/emitToProcess.d.ts +10 -0
- package/dist/types/projection/commander/emitToProcess.d.ts.map +1 -0
- package/dist/types/projection/commander/index.d.ts +21 -0
- package/dist/types/projection/commander/index.d.ts.map +1 -0
- package/dist/types/projection/commander/registerGeneratorCommands.d.ts +95 -0
- package/dist/types/projection/commander/registerGeneratorCommands.d.ts.map +1 -0
- package/dist/types/projection/decideInteraction.d.ts +70 -0
- package/dist/types/projection/decideInteraction.d.ts.map +1 -0
- package/dist/types/projection/extractAnswers.d.ts +23 -0
- package/dist/types/projection/extractAnswers.d.ts.map +1 -0
- package/dist/types/projection/groupedHelp.d.ts +25 -0
- package/dist/types/projection/groupedHelp.d.ts.map +1 -0
- package/dist/types/projection/index.d.ts +29 -0
- package/dist/types/projection/index.d.ts.map +1 -0
- package/dist/types/projection/kebab.d.ts +16 -0
- package/dist/types/projection/kebab.d.ts.map +1 -0
- package/dist/types/projection/projectGenerator.d.ts +22 -0
- package/dist/types/projection/projectGenerator.d.ts.map +1 -0
- package/dist/types/projection/types.d.ts +118 -0
- package/dist/types/projection/types.d.ts.map +1 -0
- package/dist/types/projection/usage.d.ts +92 -0
- package/dist/types/projection/usage.d.ts.map +1 -0
- package/dist/types/prompt/answerPromptWithDefaults.d.ts +5 -3
- package/dist/types/prompt/answerPromptWithDefaults.d.ts.map +1 -1
- package/dist/types/prompt/autoPrompt.d.ts.map +1 -1
- package/dist/types/prompt/ink/mount.d.ts.map +1 -1
- package/dist/types/prompt/ink/session.d.ts +36 -1
- package/dist/types/prompt/ink/session.d.ts.map +1 -1
- package/dist/types/prompt/inkPrompt.d.ts +17 -3
- package/dist/types/prompt/inkPrompt.d.ts.map +1 -1
- package/dist/types/run/runGeneratorTask.d.ts +3 -1
- package/dist/types/run/runGeneratorTask.d.ts.map +1 -1
- package/dist/types/stamp/applyStamp.d.ts +6 -2
- package/dist/types/stamp/applyStamp.d.ts.map +1 -1
- package/dist/types/stamp/createStampOnEffectStart.d.ts.map +1 -1
- package/dist/types/stamp/runTaskWithStamp.d.ts +3 -1
- package/dist/types/stamp/runTaskWithStamp.d.ts.map +1 -1
- package/dist/types/template/index.d.ts +4 -0
- package/dist/types/template/index.d.ts.map +1 -1
- package/dist/types/template/loadTemplate.d.ts +40 -0
- package/dist/types/template/loadTemplate.d.ts.map +1 -0
- package/dist/types/template/prependStamp.d.ts +5 -2
- package/dist/types/template/prependStamp.d.ts.map +1 -1
- package/dist/types/template/rawFile.d.ts +32 -0
- package/dist/types/template/rawFile.d.ts.map +1 -0
- package/dist/types/template/tasks/template.d.ts +8 -0
- package/dist/types/template/tasks/template.d.ts.map +1 -1
- package/dist/types/template/tasks/templateDir.d.ts.map +1 -1
- package/dist/types/template/tasks/types.d.ts +2 -0
- package/dist/types/template/tasks/types.d.ts.map +1 -1
- package/dist/types/testing/conformance/diffTrees.d.ts +38 -0
- package/dist/types/testing/conformance/diffTrees.d.ts.map +1 -0
- package/dist/types/testing/conformance/fixtures.d.ts +39 -0
- package/dist/types/testing/conformance/fixtures.d.ts.map +1 -0
- package/dist/types/testing/conformance/flagizeAnswers.d.ts +38 -0
- package/dist/types/testing/conformance/flagizeAnswers.d.ts.map +1 -0
- package/dist/types/testing/conformance/index.d.ts +22 -0
- package/dist/types/testing/conformance/index.d.ts.map +1 -0
- package/dist/types/testing/conformance/produceReference.d.ts +35 -0
- package/dist/types/testing/conformance/produceReference.d.ts.map +1 -0
- package/dist/types/testing/conformance/snapshotTree.d.ts +21 -0
- package/dist/types/testing/conformance/snapshotTree.d.ts.map +1 -0
- package/dist/types/testing/index.d.ts +11 -0
- package/dist/types/testing/index.d.ts.map +1 -0
- package/dist/types/types/GeneratorDefinition.d.ts +10 -1
- package/dist/types/types/GeneratorDefinition.d.ts.map +1 -1
- package/dist/types/types/ReservedOption.d.ts +1 -1
- package/dist/types/types/ReservedOption.d.ts.map +1 -1
- package/package.json +27 -9
- package/spec/generator-definition.v1.schema.json +122 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answer-set arithmetic over a command's prompts: apply defaults, decide
|
|
3
|
+
* completeness, and derive the wizard's asking list. `applyDefaults` and
|
|
4
|
+
* `hasAllRequiredAnswers` are moved verbatim from the summon bin;
|
|
5
|
+
* `explicitAnswersComplete` and `pendingPrompts` are the two derived facts the
|
|
6
|
+
* shared interaction decision and the wizards stand on.
|
|
7
|
+
*
|
|
8
|
+
* `pendingPrompts` is the wizard-script parity anchor: BOTH products' wizards
|
|
9
|
+
* ask exactly this list (declared order, explicitly-answered prompts skipped,
|
|
10
|
+
* conditional prompts included — their `when` is evaluated live by the wizard).
|
|
11
|
+
*/
|
|
12
|
+
import type { PromptLike } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Check if all required prompts have answers.
|
|
15
|
+
*
|
|
16
|
+
* A prompt is required when it is unconditional and has no default; the check
|
|
17
|
+
* passes when every such prompt is present in `answers`.
|
|
18
|
+
*
|
|
19
|
+
* @param prompts - The command's prompts (live or projected).
|
|
20
|
+
* @param answers - The answer set to check (typically defaults already applied).
|
|
21
|
+
* @returns True when no required prompt is missing.
|
|
22
|
+
*/
|
|
23
|
+
export declare function hasAllRequiredAnswers(prompts: readonly PromptLike[], answers: Record<string, unknown>): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Apply defaults for prompts that don't have answers.
|
|
26
|
+
*
|
|
27
|
+
* @param prompts - The command's prompts (live or projected).
|
|
28
|
+
* @param answers - The provided answers (never mutated).
|
|
29
|
+
* @returns A new answer set with declared defaults filled in.
|
|
30
|
+
*/
|
|
31
|
+
export declare function applyDefaults(prompts: readonly PromptLike[], answers: Record<string, unknown>): Record<string, unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the EXPLICIT answers alone fully determine a run: every
|
|
34
|
+
* unconditional prompt is explicitly answered (defaults do not count).
|
|
35
|
+
* Conditional prompts are skipped — whether they even apply is a live-wizard
|
|
36
|
+
* question, and every input they could depend on is already pinned.
|
|
37
|
+
*
|
|
38
|
+
* @param prompts - The command's prompts (live or projected).
|
|
39
|
+
* @param explicit - The explicitly provided answers (no defaults).
|
|
40
|
+
* @returns True when nothing would need to be asked or defaulted.
|
|
41
|
+
*/
|
|
42
|
+
export declare function explicitAnswersComplete(prompts: readonly PromptLike[], explicit: Readonly<Record<string, unknown>>): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The prompts a wizard must still ask, in declared order: every prompt not
|
|
45
|
+
* explicitly answered. Conditional prompts are INCLUDED — the live wizard
|
|
46
|
+
* evaluates their `when` against the answers collected so far and skips the
|
|
47
|
+
* inapplicable ones itself.
|
|
48
|
+
*
|
|
49
|
+
* @param prompts - The command's prompts (live or projected).
|
|
50
|
+
* @param explicit - The explicitly provided answers (no defaults).
|
|
51
|
+
* @returns The asking list, a subsequence of `prompts`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function pendingPrompts<P extends PromptLike>(prompts: readonly P[], explicit: Readonly<Record<string, unknown>>): P[];
|
|
54
|
+
//# sourceMappingURL=answers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answers.d.ts","sourceRoot":"","sources":["../../../src/projection/answers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAO7C;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAQT;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC1C,OAAO,CAMT;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EACjD,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC1C,CAAC,EAAE,CAEL"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive the Commander option for one prompt — the single flag-shape authority
|
|
3
|
+
* both binaries register from (moved verbatim from the summon bin's
|
|
4
|
+
* registration layer).
|
|
5
|
+
*
|
|
6
|
+
* The shapes: a default-`true` confirm registers ONLY its `--no-<kebab>` form
|
|
7
|
+
* (the positive state is the default and needs no flag); a default-`false`
|
|
8
|
+
* confirm registers the positive `--<kebab>`; a select takes `<value>` with its
|
|
9
|
+
* choices listed in the description; a multiselect takes a comma-separated
|
|
10
|
+
* `<values>`; text takes `<value>`.
|
|
11
|
+
*
|
|
12
|
+
* NOTE: defaults are deliberately NOT passed to Commander (`defaultValue` stays
|
|
13
|
+
* unset). Defaults are applied by `applyDefaults()` after answer extraction, so
|
|
14
|
+
* the surface can distinguish "user didn't provide" from "user provided the
|
|
15
|
+
* default value" — which is what keeps explicit answers explicit.
|
|
16
|
+
*/
|
|
17
|
+
import type { OptionInfo, PromptLike } from "./types.js";
|
|
18
|
+
/**
|
|
19
|
+
* Build the Commander option metadata for a prompt.
|
|
20
|
+
*
|
|
21
|
+
* @param prompt - The prompt (live or projected).
|
|
22
|
+
* @returns The option's flags, help text, group and name mapping.
|
|
23
|
+
*/
|
|
24
|
+
export default function buildOptionInfo(prompt: PromptLike): OptionInfo;
|
|
25
|
+
//# sourceMappingURL=buildOptionInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildOptionInfo.d.ts","sourceRoot":"","sources":["../../../src/projection/buildOptionInfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAqDtE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The grouped-help INSTALLER — the Commander half of the split: reads the
|
|
3
|
+
* command's usage and description through Commander's help formatter and
|
|
4
|
+
* hands them to the data seam's pure {@link renderGroupedHelp}.
|
|
5
|
+
*
|
|
6
|
+
* Module-internal to the adapter (exported for its tests, never on the
|
|
7
|
+
* subpath index): both hosts reach it only through
|
|
8
|
+
* `registerGeneratorCommands`.
|
|
9
|
+
*/
|
|
10
|
+
import type { Command } from "commander";
|
|
11
|
+
import { renderGroupedHelp } from "../groupedHelp.js";
|
|
12
|
+
import type { HostFlags, PromptLike } from "../types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Configure custom help with grouped options for a command. Under the default
|
|
15
|
+
* presentation, a command whose prompts declare no groups (and collapse to at
|
|
16
|
+
* most one) keeps Commander's default help; a host renderer installs
|
|
17
|
+
* UNCONDITIONALLY — the host chose one help style for every leaf, and leaving
|
|
18
|
+
* its ungrouped generators on Commander's default would reintroduce exactly
|
|
19
|
+
* the inconsistency it supplied the renderer to remove.
|
|
20
|
+
*
|
|
21
|
+
* @param cmd - The command to configure.
|
|
22
|
+
* @param prompts - The command's prompts (live or projected).
|
|
23
|
+
* @param hostFlags - The host's standard-flag rows for the global block.
|
|
24
|
+
* @param renderHelp - The host's own presentation, when it supplies one
|
|
25
|
+
* (see `CommanderHost.renderHelp`); omitted means `renderGroupedHelp`.
|
|
26
|
+
* @note Impure — installs a `configureHelp` override on the command.
|
|
27
|
+
*/
|
|
28
|
+
export default function configureGroupedHelp(cmd: Command, prompts: readonly PromptLike[], hostFlags: HostFlags, renderHelp?: typeof renderGroupedHelp): void;
|
|
29
|
+
//# sourceMappingURL=configureGroupedHelp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureGroupedHelp.d.ts","sourceRoot":"","sources":["../../../../src/projection/commander/configureGroupedHelp.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAqB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,SAAS,EAAE,SAAS,EACpB,UAAU,CAAC,EAAE,OAAO,iBAAiB,GACpC,IAAI,CAsBN"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default {@link MountOutcome} presentation both bins share — the ONLY
|
|
3
|
+
* process-touching export in either projection seam: the parity bytes on
|
|
4
|
+
* stderr, the outcome's code on `process.exitCode`.
|
|
5
|
+
*
|
|
6
|
+
* @note Impure — writes stderr, sets the process exit code.
|
|
7
|
+
*/
|
|
8
|
+
import type { MountOutcome } from "./registerGeneratorCommands.js";
|
|
9
|
+
export default function emitToProcess(outcome: MountOutcome): void;
|
|
10
|
+
//# sourceMappingURL=emitToProcess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitToProcess.d.ts","sourceRoot":"","sources":["../../../../src/projection/commander/emitToProcess.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAOjE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@canonical/summon-core/projection/commander` — the Commander ADAPTER seam.
|
|
3
|
+
*
|
|
4
|
+
* The one registration path both binaries mount their generator grammar
|
|
5
|
+
* through. Everything Commander-shaped lives here; the parser-agnostic data
|
|
6
|
+
* half stays in `@canonical/summon-core/projection`. Every designed
|
|
7
|
+
* non-action outcome (the two usage errors, the bare-namespace help) is
|
|
8
|
+
* delivered to the host's required `emit` sink as a `MountOutcome` — the
|
|
9
|
+
* adapter decides the bytes and the exit code, the host effects them, and
|
|
10
|
+
* `emitToProcess` is the one shared default effect.
|
|
11
|
+
*
|
|
12
|
+
* IMPORT DISCIPLINE (pinned by `lazyGraph.test.ts`): this subpath's runtime
|
|
13
|
+
* graph reaches only `commander` and Node built-ins — never react/ink/ejs/
|
|
14
|
+
* chalk/@canonical/task, and never a summon-core module outside
|
|
15
|
+
* `src/projection/` — so a host may import it statically on its
|
|
16
|
+
* `--help`/`__complete` fast path.
|
|
17
|
+
*/
|
|
18
|
+
export { default as emitToProcess } from "./emitToProcess.js";
|
|
19
|
+
export type { CommanderHost, MountOutcome, } from "./registerGeneratorCommands.js";
|
|
20
|
+
export { default as registerGeneratorCommands } from "./registerGeneratorCommands.js";
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/projection/commander/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,aAAa,EACb,YAAY,GACb,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register a command barrel onto a Commander program — the ONE registration
|
|
3
|
+
* path both binaries mount the generator tree through. The projection owns
|
|
4
|
+
* everything derivable from the prompts: the command spec (`name
|
|
5
|
+
* [kebab-positional]`), the prompt-derived options, the grouped help, the
|
|
6
|
+
* usage line, and the namespace parents. The HOST owns everything host-shaped
|
|
7
|
+
* — its standard flags, its action body, its outcome effects, and
|
|
8
|
+
* (optionally) its namespace behavior — injected through
|
|
9
|
+
* {@link CommanderHost}.
|
|
10
|
+
*
|
|
11
|
+
* Every designed non-action outcome (the two usage errors, the bare-namespace
|
|
12
|
+
* help) is DECIDED here — content and exit code, the parity facts — and
|
|
13
|
+
* DELIVERED to the host's required `emit` sink as a {@link MountOutcome}.
|
|
14
|
+
* Not one write to `process.stderr` or `process.exitCode` happens in this
|
|
15
|
+
* module; the canonical effect both bins share is
|
|
16
|
+
* {@link import("./emitToProcess.js").default}.
|
|
17
|
+
*
|
|
18
|
+
* @note Impure — mutates the Commander program.
|
|
19
|
+
*/
|
|
20
|
+
import type { Command } from "commander";
|
|
21
|
+
import type GeneratorDefinition from "../../types/GeneratorDefinition.js";
|
|
22
|
+
import type { renderGroupedHelp } from "../groupedHelp.js";
|
|
23
|
+
import type { CommandEntry, HostFlags, SurfaceGenerator } from "../types.js";
|
|
24
|
+
import { type UsageError } from "../usage.js";
|
|
25
|
+
/**
|
|
26
|
+
* Every designed non-action outcome of the registered tree. The library
|
|
27
|
+
* DECIDES the content and the exit code (the parity facts); the host
|
|
28
|
+
* EFFECTS them. The exit codes are literals on purpose: a shipped bin
|
|
29
|
+
* applies them verbatim (`emitToProcess`), an in-process host maps them
|
|
30
|
+
* into its own result — neither re-encodes the parity fact.
|
|
31
|
+
*/
|
|
32
|
+
export type MountOutcome = {
|
|
33
|
+
readonly kind: "usage-error";
|
|
34
|
+
readonly error: UsageError;
|
|
35
|
+
readonly exitCode: 2;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "namespace-help";
|
|
38
|
+
readonly help: string;
|
|
39
|
+
readonly exitCode: 1;
|
|
40
|
+
};
|
|
41
|
+
/** The host seam: what a binary contributes to each registered command. */
|
|
42
|
+
export interface CommanderHost<G extends SurfaceGenerator = GeneratorDefinition> {
|
|
43
|
+
/** Register the host's standard flags on a leaf command. */
|
|
44
|
+
readonly registerFlags: (cmd: Command) => void;
|
|
45
|
+
/** The same flags as `--help` rows for the grouped-help global block. */
|
|
46
|
+
readonly helpFlags: HostFlags;
|
|
47
|
+
/**
|
|
48
|
+
* The leaf action. Receives the barrel entry, the positional's value when
|
|
49
|
+
* one was given, and Commander's parsed options.
|
|
50
|
+
*/
|
|
51
|
+
readonly action: (entry: CommandEntry<G>, positionalValue: string | undefined, options: Record<string, unknown>) => Promise<void>;
|
|
52
|
+
/** Optional hook run on every namespace (non-runnable) command created. */
|
|
53
|
+
readonly onNamespace?: (cmd: Command, entry: CommandEntry<G>) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Render a leaf's grouped help. Defaults to `renderGroupedHelp` — the
|
|
56
|
+
* shared presentation summon uses; a host with its own help style supplies
|
|
57
|
+
* an alternative implementation of the same function. Optional, unlike
|
|
58
|
+
* `emit`: Commander's `configureHelp` takes exactly one formatter, so an
|
|
59
|
+
* omitted member cannot double-write — it just means the default.
|
|
60
|
+
*/
|
|
61
|
+
readonly renderHelp?: typeof renderGroupedHelp;
|
|
62
|
+
/**
|
|
63
|
+
* REQUIRED. The ONE process seam. A host wanting the default presentation
|
|
64
|
+
* passes `emitToProcess`; a host reframing an outcome builds its own bytes
|
|
65
|
+
* from `outcome.error` and applies `outcome.exitCode`.
|
|
66
|
+
*/
|
|
67
|
+
readonly emit: (outcome: MountOutcome) => void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Normalize Commander's action calling convention: the positional value is the
|
|
71
|
+
* first argument only when the command spec declared one, and it counts only
|
|
72
|
+
* when actually given (a non-empty string).
|
|
73
|
+
*
|
|
74
|
+
* Module-internal to the adapter (exported for its tests, never on the
|
|
75
|
+
* subpath index): both hosts reach it only through
|
|
76
|
+
* {@link registerGeneratorCommands}.
|
|
77
|
+
*
|
|
78
|
+
* @param actionArgs - Commander's raw action arguments.
|
|
79
|
+
* @param hasPositional - Whether the command spec declared a positional.
|
|
80
|
+
* @returns The positional's value (if given) and the parsed options.
|
|
81
|
+
*/
|
|
82
|
+
export declare function splitGeneratorActionArgs(actionArgs: readonly unknown[], hasPositional: boolean): {
|
|
83
|
+
positionalValue: string | undefined;
|
|
84
|
+
options: Record<string, unknown>;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Register all commands from a command barrel onto a Commander program.
|
|
88
|
+
*
|
|
89
|
+
* @param rootCmd - The program (or parent command) to register onto.
|
|
90
|
+
* @param barrel - The flattened command entries, parents before children.
|
|
91
|
+
* @param host - The host seam (flags, action, namespace hook, emit sink).
|
|
92
|
+
* @note Impure — mutates the Commander program.
|
|
93
|
+
*/
|
|
94
|
+
export default function registerGeneratorCommands<G extends SurfaceGenerator>(rootCmd: Command, barrel: readonly CommandEntry<G>[], host: CommanderHost<G>): void;
|
|
95
|
+
//# sourceMappingURL=registerGeneratorCommands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerGeneratorCommands.d.ts","sourceRoot":"","sources":["../../../../src/projection/commander/registerGeneratorCommands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAC;AAE1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EAET,gBAAgB,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAGrB;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GACpB;IACE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;CACtB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;CACtB,CAAC;AAEN,2EAA2E;AAC3E,MAAM,WAAW,aAAa,CAC5B,CAAC,SAAS,gBAAgB,GAAG,mBAAmB;IAEhD,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,CACf,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EACtB,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACtE;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,iBAAiB,CAAC;IAC/C;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;CAChD;AA2CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,SAAS,OAAO,EAAE,EAC9B,aAAa,EAAE,OAAO,GACrB;IACD,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAQA;AAwGD;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,gBAAgB,EAC1E,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,EAClC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GACrB,IAAI,CAyEN"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE interaction decision (R2). Both products call this — the summon bin
|
|
3
|
+
* and pragma's `create` — so a given (flags, TTY, answers) state produces the
|
|
4
|
+
* same mode in either binary. The normative table lives in
|
|
5
|
+
* the cross-CLI matrix, which executes this module's decision; the exhaustive 32-cell
|
|
6
|
+
* test in `decideInteraction.test.ts` pins every row.
|
|
7
|
+
*
|
|
8
|
+
* Precedence: `--dry-run` > `--undo` > the rest. The batch modes ignore TTY —
|
|
9
|
+
* a dry-run or undo is a batch render wherever it runs. Then `--yes` means
|
|
10
|
+
* run-with-defaults; a TTY gets the wizard (which asks only `pendingPrompts`);
|
|
11
|
+
* a non-TTY with a fully-explicit answer set is a legitimate scripted run; and
|
|
12
|
+
* a non-TTY mutation with incomplete input REFUSES — exit 2 with recovery —
|
|
13
|
+
* rather than silently scaffolding from defaults.
|
|
14
|
+
*/
|
|
15
|
+
import type { PromptLike } from "./types.js";
|
|
16
|
+
/** The five interaction modes a CLI invocation resolves to. */
|
|
17
|
+
export type InteractionMode = "batch-dry-run" | "batch-undo" | "run" | "wizard" | "refuse";
|
|
18
|
+
/** The five inputs the decision reads — nothing else may influence it. */
|
|
19
|
+
export interface InteractionInput {
|
|
20
|
+
/** `--dry-run` (or a mode that implies it). */
|
|
21
|
+
readonly dryRun: boolean;
|
|
22
|
+
/** `--undo`. */
|
|
23
|
+
readonly undo: boolean;
|
|
24
|
+
/** `--yes` (or a mode that implies it). */
|
|
25
|
+
readonly yes: boolean;
|
|
26
|
+
/** The HOST's TTY fact (each host's definition is stated in the contract). */
|
|
27
|
+
readonly isTTY: boolean;
|
|
28
|
+
/** `explicitAnswersComplete(prompts, explicit)` — defaults do not count. */
|
|
29
|
+
readonly explicitComplete: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** The decision: the mode, with `refusal` set iff the mode is `refuse`. */
|
|
32
|
+
export interface InteractionDecision {
|
|
33
|
+
readonly mode: InteractionMode;
|
|
34
|
+
readonly refusal?: true;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Decide the interaction mode for one invocation.
|
|
38
|
+
*
|
|
39
|
+
* @param input - The five decision inputs.
|
|
40
|
+
* @returns The mode (and the `refusal` marker on row 6).
|
|
41
|
+
*/
|
|
42
|
+
export declare function decideInteraction(input: InteractionInput): InteractionDecision;
|
|
43
|
+
/**
|
|
44
|
+
* The PRIMARY registered long-form flag of each unconditional prompt absent
|
|
45
|
+
* from the explicit answers, in declared order — the `Missing:` list of the
|
|
46
|
+
* refusal message. Every token is derived through {@link buildOptionInfo},
|
|
47
|
+
* the single flag-shape authority both binaries register from, so every
|
|
48
|
+
* listed token is one the command actually answers to: a default-`true`
|
|
49
|
+
* confirm is listed as its only registered form `--no-<kebab>` (kebab-casing
|
|
50
|
+
* the prompt NAME advertised `--<kebab>`, a flag neither host registers —
|
|
51
|
+
* following the refusal's own instruction then exited 2), everything else as
|
|
52
|
+
* `--<kebab>`.
|
|
53
|
+
*
|
|
54
|
+
* @param prompts - The command's prompts (live or projected).
|
|
55
|
+
* @param explicit - The explicitly provided answers (no defaults).
|
|
56
|
+
* @returns Registered long-form flag tokens (`--` included).
|
|
57
|
+
*/
|
|
58
|
+
export declare function missingExplicitFlags(prompts: readonly PromptLike[], explicit: Readonly<Record<string, unknown>>): string[];
|
|
59
|
+
/**
|
|
60
|
+
* The refusal message — authored ONCE here, written verbatim by BOTH CLIs
|
|
61
|
+
* (stderr, exit 2). The tokens are rendered VERBATIM — they arrive as full
|
|
62
|
+
* registered flags (see {@link missingExplicitFlags}); re-prefixing here
|
|
63
|
+
* would double the dashes.
|
|
64
|
+
*
|
|
65
|
+
* @param missingFlags - The missing flag tokens (see
|
|
66
|
+
* {@link missingExplicitFlags}).
|
|
67
|
+
* @returns The complete refusal message.
|
|
68
|
+
*/
|
|
69
|
+
export declare function refusalMessage(missingFlags: readonly string[]): string;
|
|
70
|
+
//# sourceMappingURL=decideInteraction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decideInteraction.d.ts","sourceRoot":"","sources":["../../../src/projection/decideInteraction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,+DAA+D;AAC/D,MAAM,MAAM,eAAe,GACvB,eAAe,GACf,YAAY,GACZ,KAAK,GACL,QAAQ,GACR,QAAQ,CAAC;AAEb,0EAA0E;AAC1E,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,gBAAgB;IAChB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,2CAA2C;IAC3C,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AAED,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,gBAAgB,GACtB,mBAAmB,CAOrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC1C,MAAM,EAAE,CAQV;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAMtE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the EXPLICITLY provided answers from parsed Commander options —
|
|
3
|
+
* moved verbatim from the summon bin's registration layer. Explicit-only is
|
|
4
|
+
* the invariant: defaults never enter the result (Commander was registered
|
|
5
|
+
* without them — see `buildOptionInfo`), so downstream decisions can tell a
|
|
6
|
+
* typed flag from an untouched one.
|
|
7
|
+
*
|
|
8
|
+
* The one unavoidable ambiguity: Commander reports a default-`true` confirm's
|
|
9
|
+
* `--no-<kebab>` as `true` when the flag was NOT passed. Equality-vs-default
|
|
10
|
+
* filters that out — a confirm value equal to its declared default is treated
|
|
11
|
+
* as unprovided. (Typing the flag that restates the default is therefore
|
|
12
|
+
* indistinguishable from omitting it; every consumer inherits that fact.)
|
|
13
|
+
*/
|
|
14
|
+
import type { PromptLike } from "./types.js";
|
|
15
|
+
/**
|
|
16
|
+
* Extract answers from Commander options based on prompts.
|
|
17
|
+
*
|
|
18
|
+
* @param options - Commander's parsed option values.
|
|
19
|
+
* @param prompts - The command's prompts (live or projected).
|
|
20
|
+
* @returns Only the explicitly provided answers, keyed by prompt name.
|
|
21
|
+
*/
|
|
22
|
+
export default function extractAnswers(options: Record<string, unknown>, prompts: readonly PromptLike[]): Record<string, unknown>;
|
|
23
|
+
//# sourceMappingURL=extractAnswers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractAnswers.d.ts","sourceRoot":"","sources":["../../../src/projection/extractAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,EAAE,SAAS,UAAU,EAAE,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiCzB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grouped `--help` for a generator command — the PURE half of the split: the
|
|
3
|
+
* group bucketing and the rendered page, with the host's standard-flag block
|
|
4
|
+
* injected as {@link HostFlags} so each binary shows its own globals above
|
|
5
|
+
* the same generated prompt groups. The Commander installer (and its
|
|
6
|
+
* install-only-when-grouped guard) lives in the adapter seam
|
|
7
|
+
* (`projection/commander/configureGroupedHelp.ts`); this module never
|
|
8
|
+
* touches Commander, not even as types.
|
|
9
|
+
*/
|
|
10
|
+
import type { HostFlags, OptionInfo, PromptLike } from "./types.js";
|
|
11
|
+
/** Collect a command's prompt options by group, in declared order. */
|
|
12
|
+
export declare function buildOptionGroups(prompts: readonly PromptLike[]): Map<string, OptionInfo[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Render the grouped help text for a command: usage, description, the host's
|
|
15
|
+
* standard-flag block, then each prompt group.
|
|
16
|
+
*
|
|
17
|
+
* @param usage - The command's usage string (the adapter supplies
|
|
18
|
+
* Commander's).
|
|
19
|
+
* @param description - The command's description; `""` skips the block.
|
|
20
|
+
* @param groups - The prompt options by group (see {@link buildOptionGroups}).
|
|
21
|
+
* @param hostFlags - The host's standard-flag rows for the global block.
|
|
22
|
+
* @returns The complete help text.
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderGroupedHelp(usage: string, description: string, groups: ReadonlyMap<string, readonly OptionInfo[]>, hostFlags: HostFlags): string;
|
|
25
|
+
//# sourceMappingURL=groupedHelp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groupedHelp.d.ts","sourceRoot":"","sources":["../../../src/projection/groupedHelp.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAQpE,sEAAsE;AACtE,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,UAAU,EAAE,GAC7B,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAW3B;AAmBD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC,EAClD,SAAS,EAAE,SAAS,GACnB,MAAM,CA4BR"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@canonical/summon-core/projection` — the UI-free command-surface DATA seam.
|
|
3
|
+
*
|
|
4
|
+
* Everything a CLI derives from `GeneratorDefinition.prompts` lives here:
|
|
5
|
+
* flag shapes, answer extraction, defaults/completeness arithmetic, the
|
|
6
|
+
* usage-error structures and their parity rendering, and grouped help. Both
|
|
7
|
+
* binaries consume it — the summon bin at its root, pragma mounted under
|
|
8
|
+
* `create` — so the two surfaces cannot drift. The Commander ADAPTER — the
|
|
9
|
+
* registration path, the outcome sink, `emitToProcess` — lives beside it at
|
|
10
|
+
* `@canonical/summon-core/projection/commander`.
|
|
11
|
+
*
|
|
12
|
+
* IMPORT DISCIPLINE (pinned by `lazyGraph.test.ts`): this subpath is pure and
|
|
13
|
+
* parser-agnostic — its runtime graph reaches ZERO bare dependencies (Node
|
|
14
|
+
* built-ins only), never commander (not even as types), never react/ink/ejs/
|
|
15
|
+
* chalk/@canonical/task, and never the summon-core main barrel — so a host
|
|
16
|
+
* may import it statically on its `--help`/`__complete` fast path.
|
|
17
|
+
*/
|
|
18
|
+
export { applyDefaults, explicitAnswersComplete, hasAllRequiredAnswers, pendingPrompts, } from "./answers.js";
|
|
19
|
+
export { default as buildOptionInfo } from "./buildOptionInfo.js";
|
|
20
|
+
export type { InteractionDecision, InteractionInput, InteractionMode, } from "./decideInteraction.js";
|
|
21
|
+
export { decideInteraction, missingExplicitFlags, refusalMessage, } from "./decideInteraction.js";
|
|
22
|
+
export { default as extractAnswers } from "./extractAnswers.js";
|
|
23
|
+
export { buildOptionGroups, renderGroupedHelp } from "./groupedHelp.js";
|
|
24
|
+
export { default as toKebabCase } from "./kebab.js";
|
|
25
|
+
export { default as projectGenerator } from "./projectGenerator.js";
|
|
26
|
+
export type { CommandEntry, HostFlags, OptionInfo, ProjectedPrompt, PromptLike, SurfaceCommand, SurfaceGenerator, } from "./types.js";
|
|
27
|
+
export type { UsageError, UsageKind } from "./usage.js";
|
|
28
|
+
export { excessPositionalError, renderUsageError, unknownSegmentError, } from "./usage.js";
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/projection/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,YAAY,EACV,YAAY,EACZ,SAAS,EACT,UAAU,EACV,eAAe,EACf,UAAU,EACV,cAAc,EACd,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE kebab-case derivation for prompt names — the one function every flag
|
|
3
|
+
* name, refusal list, and validation message derives `--component-path` from
|
|
4
|
+
* `componentPath` with. It used to exist as three private copies (the summon
|
|
5
|
+
* bin's registration, `execute/validateAnswers`, `prompt/autoPrompt`); a
|
|
6
|
+
* message and a flag that disagree about the same prompt's spelling is the
|
|
7
|
+
* defect a single authoring point removes.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Convert a camelCase prompt name to its kebab-case CLI flag form.
|
|
11
|
+
*
|
|
12
|
+
* @param name - The prompt name (`withTests`, `componentPath`).
|
|
13
|
+
* @returns The kebab-case form (`with-tests`, `component-path`).
|
|
14
|
+
*/
|
|
15
|
+
export default function toKebabCase(name: string): string;
|
|
16
|
+
//# sourceMappingURL=kebab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kebab.d.ts","sourceRoot":"","sources":["../../../src/projection/kebab.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project a live {@link GeneratorDefinition} onto its serializable command
|
|
3
|
+
* surface — the one image both the summon bin (at run time) and a host's
|
|
4
|
+
* codegen (at build time) derive the SAME grammar from.
|
|
5
|
+
*
|
|
6
|
+
* What survives the projection is exactly what the CLI surface reads: name,
|
|
7
|
+
* type, message, default, choices, positional, group. A `when` condition
|
|
8
|
+
* collapses to `conditional: true` (only a live wizard evaluates the
|
|
9
|
+
* predicate); `validate` is dropped entirely (enforced at execute time by
|
|
10
|
+
* `validateAnswers`, identically for every front-end).
|
|
11
|
+
*/
|
|
12
|
+
import type GeneratorDefinition from "../types/GeneratorDefinition.js";
|
|
13
|
+
import type { SurfaceCommand } from "./types.js";
|
|
14
|
+
/**
|
|
15
|
+
* Project a generator onto its serializable {@link SurfaceCommand}.
|
|
16
|
+
*
|
|
17
|
+
* @param path - The command path the generator is mounted at.
|
|
18
|
+
* @param generator - The live generator definition.
|
|
19
|
+
* @returns The serializable command surface.
|
|
20
|
+
*/
|
|
21
|
+
export default function projectGenerator(path: readonly string[], generator: GeneratorDefinition): SurfaceCommand;
|
|
22
|
+
//# sourceMappingURL=projectGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectGenerator.d.ts","sourceRoot":"","sources":["../../../src/projection/projectGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,mBAAmB,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,YAAY,CAAC;AAuBlE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,SAAS,EAAE,mBAAmB,GAC7B,cAAc,CAMhB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command-surface projection's vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* A generator's CLI surface — its command path, its flags, its positional, its
|
|
5
|
+
* grouped help — DERIVES from `GeneratorDefinition.prompts`. This module names
|
|
6
|
+
* the shapes of that derivation: a {@link ProjectedPrompt} is the serializable
|
|
7
|
+
* image of a prompt (functions dropped), a {@link SurfaceCommand} is one
|
|
8
|
+
* command of the projected tree, and {@link CommandEntry}/{@link OptionInfo}
|
|
9
|
+
* are the registration shapes both binaries consume (moved here from the
|
|
10
|
+
* summon bin, which was their only owner).
|
|
11
|
+
*
|
|
12
|
+
* Everything here is data: no functions, so a {@link SurfaceCommand} can be
|
|
13
|
+
* emitted by a build step, committed, and compared against the live generators.
|
|
14
|
+
*/
|
|
15
|
+
import type GeneratorDefinition from "../types/GeneratorDefinition.js";
|
|
16
|
+
/**
|
|
17
|
+
* The serializable image of a {@link import("../types/PromptDefinition.js").default}:
|
|
18
|
+
* everything the CLI surface derives from, and nothing it cannot serialize.
|
|
19
|
+
* `validate` is dropped (enforced at execute time by `validateAnswers`);
|
|
20
|
+
* a `when` condition collapses to `conditional: true` (its predicate is
|
|
21
|
+
* evaluated only by a live wizard).
|
|
22
|
+
*/
|
|
23
|
+
export interface ProjectedPrompt {
|
|
24
|
+
/** Unique identifier, used as answer key and CLI flag name. */
|
|
25
|
+
readonly name: string;
|
|
26
|
+
/** Prompt kind, deciding flag shape and answer parsing. */
|
|
27
|
+
readonly type: "text" | "confirm" | "select" | "multiselect";
|
|
28
|
+
/** Question text displayed to the user (and used as flag help). */
|
|
29
|
+
readonly message: string;
|
|
30
|
+
/** Default value if the user provides no input. */
|
|
31
|
+
readonly default?: unknown;
|
|
32
|
+
/** Choices for select/multiselect prompts. */
|
|
33
|
+
readonly choices?: ReadonlyArray<{
|
|
34
|
+
readonly label: string;
|
|
35
|
+
readonly value: string;
|
|
36
|
+
}>;
|
|
37
|
+
/** True when the prompt can be provided as the command's one positional. */
|
|
38
|
+
readonly positional?: boolean;
|
|
39
|
+
/** Group name for organizing options in `--help` output. */
|
|
40
|
+
readonly group?: string;
|
|
41
|
+
/** True when the live prompt carries a `when` condition (wizard-evaluated). */
|
|
42
|
+
readonly conditional?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A prompt as the projection's helpers accept it: either a live
|
|
46
|
+
* `PromptDefinition` (whose `when`/`validate` are functions) or a
|
|
47
|
+
* {@link ProjectedPrompt} (where `when` collapsed to `conditional`). The
|
|
48
|
+
* helpers read only the projected fields plus the presence of `when`.
|
|
49
|
+
*/
|
|
50
|
+
export type PromptLike = ProjectedPrompt & {
|
|
51
|
+
readonly when?: unknown;
|
|
52
|
+
readonly validate?: unknown;
|
|
53
|
+
};
|
|
54
|
+
/** One command of the projected generator tree, fully serializable. */
|
|
55
|
+
export interface SurfaceCommand {
|
|
56
|
+
/** Path segments to this command (e.g. `["component", "react"]`). */
|
|
57
|
+
readonly path: readonly string[];
|
|
58
|
+
/** The generator's `meta.description`. */
|
|
59
|
+
readonly description: string;
|
|
60
|
+
/** The projected prompts, in declared (asking) order. */
|
|
61
|
+
readonly prompts: readonly ProjectedPrompt[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* What the registration path actually READS of a runnable entry: a
|
|
65
|
+
* description and the prompt list. A live {@link GeneratorDefinition}
|
|
66
|
+
* satisfies it directly. A build-time {@link SurfaceCommand} does NOT — it
|
|
67
|
+
* carries a top-level `description` where this needs `meta.description`,
|
|
68
|
+
* and its readonly `path` belongs to {@link CommandEntry} (which owns a
|
|
69
|
+
* mutable one) — so a host mounting the projected tree without loading a
|
|
70
|
+
* single generator wraps each surface command in a small adapter
|
|
71
|
+
* (`{ meta: { description: surface.description }, prompts: surface.prompts }`).
|
|
72
|
+
*/
|
|
73
|
+
export interface SurfaceGenerator {
|
|
74
|
+
readonly meta: {
|
|
75
|
+
readonly description: string;
|
|
76
|
+
};
|
|
77
|
+
readonly prompts: readonly PromptLike[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A flattened representation of a command to register.
|
|
81
|
+
* Separates command discovery from registration.
|
|
82
|
+
*
|
|
83
|
+
* Generic over the runnable payload: the summon bin carries live
|
|
84
|
+
* {@link GeneratorDefinition}s (the default), a build-time host carries
|
|
85
|
+
* projected {@link SurfaceGenerator}s.
|
|
86
|
+
*/
|
|
87
|
+
export interface CommandEntry<G extends SurfaceGenerator = GeneratorDefinition> {
|
|
88
|
+
/** Path segments to this command (e.g., ["component", "react"]) */
|
|
89
|
+
path: string[];
|
|
90
|
+
/** The generator definition if this is a runnable command */
|
|
91
|
+
generator?: G;
|
|
92
|
+
/** Description for namespace-only commands */
|
|
93
|
+
description?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Option metadata built from a prompt definition for Commander.
|
|
97
|
+
*/
|
|
98
|
+
export interface OptionInfo {
|
|
99
|
+
flags: string;
|
|
100
|
+
description: string;
|
|
101
|
+
defaultValue?: string;
|
|
102
|
+
group?: string;
|
|
103
|
+
/** The original camelCase prompt name */
|
|
104
|
+
promptName: string;
|
|
105
|
+
/** The kebab-case flag name (without --) */
|
|
106
|
+
kebabName: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A host's standard per-generator flag list, injected into grouped help: each
|
|
110
|
+
* entry is a `--help` row (`flags` column + description). The projection never
|
|
111
|
+
* hard-codes a host's flags — summon's nine and pragma's mutation trio are
|
|
112
|
+
* both just data handed in here.
|
|
113
|
+
*/
|
|
114
|
+
export type HostFlags = ReadonlyArray<{
|
|
115
|
+
readonly flags: string;
|
|
116
|
+
readonly description: string;
|
|
117
|
+
}>;
|
|
118
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/projection/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,mBAAmB,MAAM,iCAAiC,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC7D,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;QAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB,CAAC,CAAC;IACH,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY,CAC3B,CAAC,SAAS,gBAAgB,GAAG,mBAAmB;IAEhD,mEAAmE;IACnE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,6DAA6D;IAC7D,SAAS,CAAC,EAAE,CAAC,CAAC;IACd,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAC,CAAC"}
|