@canonical/summon-core 0.32.0 → 0.34.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/execute/collectAnswers.js +2 -1
- package/dist/esm/execute/collectAnswers.js.map +1 -1
- package/dist/esm/format/effects.js +2 -2
- package/dist/esm/prompt/ink/Wizard.js +15 -6
- package/dist/esm/prompt/ink/Wizard.js.map +1 -1
- package/dist/esm/prompt/ink/answerValidation.js +32 -0
- package/dist/esm/prompt/ink/answerValidation.js.map +1 -0
- package/dist/esm/prompt/ink/mount.js +4 -2
- package/dist/esm/prompt/ink/mount.js.map +1 -1
- package/dist/esm/prompt/ink/progressWindow.js +143 -0
- package/dist/esm/prompt/ink/progressWindow.js.map +1 -0
- package/dist/esm/prompt/ink/prompts.js +96 -21
- package/dist/esm/prompt/ink/prompts.js.map +1 -1
- package/dist/esm/prompt/ink/selectChoices.js +28 -0
- package/dist/esm/prompt/ink/selectChoices.js.map +1 -0
- package/dist/esm/prompt/ink/session.js +58 -10
- package/dist/esm/prompt/ink/session.js.map +1 -1
- package/dist/esm/prompt/inkPrompt.js +3 -3
- package/dist/esm/prompt/inkPrompt.js.map +1 -1
- package/dist/esm/run/runGeneratorTask.js +3 -1
- package/dist/esm/run/runGeneratorTask.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 +83 -0
- package/dist/esm/testing/conformance/fixtures.js.map +1 -0
- package/dist/esm/testing/conformance/index.js +17 -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/execute/collectAnswers.d.ts +2 -1
- package/dist/types/execute/collectAnswers.d.ts.map +1 -1
- package/dist/types/format/effects.d.ts +2 -2
- package/dist/types/prompt/ink/Wizard.d.ts.map +1 -1
- package/dist/types/prompt/ink/answerValidation.d.ts +31 -0
- package/dist/types/prompt/ink/answerValidation.d.ts.map +1 -0
- package/dist/types/prompt/ink/mount.d.ts.map +1 -1
- package/dist/types/prompt/ink/progressWindow.d.ts +48 -0
- package/dist/types/prompt/ink/progressWindow.d.ts.map +1 -0
- package/dist/types/prompt/ink/prompts.d.ts +11 -2
- package/dist/types/prompt/ink/prompts.d.ts.map +1 -1
- package/dist/types/prompt/ink/selectChoices.d.ts +42 -0
- package/dist/types/prompt/ink/selectChoices.d.ts.map +1 -0
- 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 +10 -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/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/index.d.ts +21 -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/package.json +13 -8
- package/spec/generator-definition.v1.schema.json +122 -0
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* `import("./mount.js")` boundary — it never lands in summon-core's static
|
|
11
11
|
* graph, even though it carries no JSX itself.
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
13
|
+
import { TaskExecutionError, } from "@canonical/task";
|
|
14
|
+
import { runPreview } from "@canonical/task/node";
|
|
14
15
|
import { CONFIRM_ANSWER_KEY, GENERATOR_CANCELLED, } from "../../execute/execute.js";
|
|
15
16
|
/** Count the prompts that apply given the answers so far (respecting `when`). */
|
|
16
17
|
function countApplicable(generator, answers) {
|
|
@@ -22,10 +23,13 @@ function countApplicable(generator, answers) {
|
|
|
22
23
|
*/
|
|
23
24
|
export class SessionController {
|
|
24
25
|
onUserCancel;
|
|
26
|
+
cwd;
|
|
25
27
|
current;
|
|
26
28
|
listeners = new Set();
|
|
27
29
|
pending;
|
|
28
30
|
executionStart = 0;
|
|
31
|
+
/** The confirm gate's in-flight preview, awaited only by {@link previewSettled}. */
|
|
32
|
+
previewInFlight;
|
|
29
33
|
/**
|
|
30
34
|
* @param generator - The generator being run.
|
|
31
35
|
* @param onUserCancel - Invoked once when the user cancels (Ctrl-C / escape).
|
|
@@ -34,9 +38,14 @@ export class SessionController {
|
|
|
34
38
|
* `checkInterrupted` fires between effects) instead of only rejecting a
|
|
35
39
|
* — by then non-existent — pending prompt. `abort()` is idempotent, so the
|
|
36
40
|
* signal→cancel→abort path cannot loop.
|
|
41
|
+
* @param cwd - The write root the run will resolve relative effect paths
|
|
42
|
+
* against. The preview reads the SAME tree, so the gate's plan is the plan
|
|
43
|
+
* the run produces. Omitted falls back to the process cwd, matching a run
|
|
44
|
+
* whose interpreter was given no `cwd`.
|
|
37
45
|
*/
|
|
38
|
-
constructor(generator, onUserCancel) {
|
|
46
|
+
constructor(generator, onUserCancel, cwd) {
|
|
39
47
|
this.onUserCancel = onUserCancel;
|
|
48
|
+
this.cwd = cwd;
|
|
40
49
|
this.current = {
|
|
41
50
|
phase: "idle",
|
|
42
51
|
generator,
|
|
@@ -71,14 +80,11 @@ export class SessionController {
|
|
|
71
80
|
const isConfirm = effect.question.name === CONFIRM_ANSWER_KEY;
|
|
72
81
|
this.pending = { effect, isConfirm, resolve, reject };
|
|
73
82
|
if (isConfirm) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
previewEffects = [];
|
|
80
|
-
}
|
|
81
|
-
this.set({ phase: "confirming", previewEffects });
|
|
83
|
+
// The gate renders AT ONCE with an empty pane, then re-renders when the
|
|
84
|
+
// honest preview resolves — the pane is ordinary Ink state, so there is
|
|
85
|
+
// no synchronous constraint to satisfy.
|
|
86
|
+
this.set({ phase: "confirming", previewEffects: [] });
|
|
87
|
+
this.previewInFlight = this.loadPreview();
|
|
82
88
|
}
|
|
83
89
|
else {
|
|
84
90
|
const answered = Object.keys(this.current.answers).length;
|
|
@@ -91,6 +97,48 @@ export class SessionController {
|
|
|
91
97
|
}
|
|
92
98
|
});
|
|
93
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Fill the confirm gate's preview pane with the HONEST plan.
|
|
102
|
+
*
|
|
103
|
+
* `runPreview` reads the real filesystem (through a virtual write overlay, so
|
|
104
|
+
* a step sees what the step before it planned) and records writes without
|
|
105
|
+
* performing them — the gate is shown BEFORE the user consents, so it must
|
|
106
|
+
* not touch the disk, and it must not lie about what will happen. The mock it
|
|
107
|
+
* replaces answered every read with a placeholder and `Exists` with `true`,
|
|
108
|
+
* so the pane could promise files a run would never reach.
|
|
109
|
+
*
|
|
110
|
+
* Failure shows an EMPTY pane rather than a fictional one: the generator's
|
|
111
|
+
* own error belongs to the run, which reports it with its real message, and
|
|
112
|
+
* the decision at the gate stays the user's. A result that arrives after the
|
|
113
|
+
* gate is gone — the user answered or cancelled while the reads were in
|
|
114
|
+
* flight — is dropped, so a slow preview can never repaint a pane the wizard
|
|
115
|
+
* has already left.
|
|
116
|
+
*/
|
|
117
|
+
async loadPreview() {
|
|
118
|
+
let previewEffects = [];
|
|
119
|
+
try {
|
|
120
|
+
const preview = await runPreview(this.current.generator.generate(this.current.answers), { cwd: this.cwd });
|
|
121
|
+
previewEffects = preview.effects;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
previewEffects = [];
|
|
125
|
+
}
|
|
126
|
+
if (this.current.phase !== "confirming")
|
|
127
|
+
return;
|
|
128
|
+
this.set({ previewEffects });
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Resolves once the confirm gate's preview has been applied (or dropped as
|
|
132
|
+
* stale). The wizard itself never awaits this — the pane repaints when the
|
|
133
|
+
* preview lands, which is the whole point of making it async — but a caller
|
|
134
|
+
* that asserts ON the pane has to synchronise with the real filesystem reads
|
|
135
|
+
* the preview performs, and a wall-clock delay would only be flaky.
|
|
136
|
+
*
|
|
137
|
+
* @returns A promise for the in-flight preview, already resolved when none is.
|
|
138
|
+
*/
|
|
139
|
+
previewSettled() {
|
|
140
|
+
return this.previewInFlight ?? Promise.resolve();
|
|
141
|
+
}
|
|
94
142
|
/** Feed effect start (kept for seam symmetry; progress rides completion). */
|
|
95
143
|
reportEffectStart(_effect) {
|
|
96
144
|
// No-op: the live view is driven by reportEffectComplete.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/prompt/ink/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/prompt/ink/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAIL,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAuClC,iFAAiF;AACjF,SAAS,eAAe,CACtB,SAA8B,EAC9B,OAAgC;IAEhC,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC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IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QACtB,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QACjC,OAAO,EAAE,MAAM,CACb,IAAI,kBAAkB,CAAC;YACrB,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,YAAY;SACtB,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
* dynamically imports the React UI), so picking this strategy on a fast path
|
|
23
23
|
* that never prompts costs nothing and loads no React.
|
|
24
24
|
*
|
|
25
|
-
* @param generator - The generator being run (the session
|
|
26
|
-
* the confirm gate's
|
|
27
|
-
* @param options - The abort signal.
|
|
25
|
+
* @param generator - The generator being run (the session previews it to build
|
|
26
|
+
* the confirm gate's plan).
|
|
27
|
+
* @param options - The abort signal, cancel callback, and preview write root.
|
|
28
28
|
* @returns The {@link InkSession} the `create` verb wires into `runtime.exec`.
|
|
29
29
|
*/
|
|
30
30
|
export default function inkPrompt(generator, options = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inkPrompt.js","sourceRoot":"","sources":["../../../src/prompt/inkPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"inkPrompt.js","sourceRoot":"","sources":["../../../src/prompt/inkPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAsDH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,SAA8B,EAC9B,UAA4B,EAAE;IAE9B,IAAI,MAA2C,CAAC;IAChD,IAAI,OAAmC,CAAC;IAExC,MAAM,MAAM,GAAG,GAA4B,EAAE;QAC3C,MAAM,KAAK,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/C,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,wEAAwE;IACxE,4EAA4E;IAC5E,uDAAuD;IACvD,MAAM,aAAa,GAAkB,KAAK,EAAE,MAAM,EAAE,EAAE;QACpD,MAAM,OAAO,GAAG,MAAM,MAAM,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,OAAO;QACL,aAAa;QACb,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,MAAM,CAAC;QAC7D,gBAAgB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CACrC,OAAO,EAAE,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC;QACjD,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC;QAC7D,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Moved into summon-core (from the v1 cli-core) so it sits below both the
|
|
13
13
|
* summon bin and the pragma kernel — the shared seam the byte-equality
|
|
14
|
-
* guarantee rests on
|
|
14
|
+
* guarantee rests on, and the one `testing/conformance/produceReference` runs.
|
|
15
|
+
* Both bins import it from HERE; the cli-core re-export shim is gone with that
|
|
16
|
+
* package.
|
|
15
17
|
*/
|
|
16
18
|
import { runTask } from "@canonical/task/node";
|
|
17
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runGeneratorTask.js","sourceRoot":"","sources":["../../../src/run/runGeneratorTask.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"runGeneratorTask.js","sourceRoot":"","sources":["../../../src/run/runGeneratorTask.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAuB,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAsBpE;;;;;;;;GAQG;AACH,IAAI,QAAQ,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAC5C,IAAa,EACb,UAAmC,EAAE;IAErC,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;QACnC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,GAAG,KAAK,WAAW,CAAC;QACxC,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACzC,CAAC;gBAAS,CAAC;YACT,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,QAAQ,GAAG,GAAG,CAAC,IAAI,CACjB,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two generated trees and say precisely how they differ.
|
|
3
|
+
*
|
|
4
|
+
* A bare `expect(a).toEqual(b)` over two trees reports "objects differ" and
|
|
5
|
+
* leaves the reader to find the byte. This returns the three ways a tree can
|
|
6
|
+
* diverge — a path only one side wrote, and a path both wrote with different
|
|
7
|
+
* contents — so a conformance failure names the file that broke the seam.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Diff two snapshots.
|
|
11
|
+
*
|
|
12
|
+
* @param first - One producer's tree.
|
|
13
|
+
* @param second - The other producer's tree.
|
|
14
|
+
* @returns The three divergence sets, each sorted.
|
|
15
|
+
*/
|
|
16
|
+
export function diffTrees(first, second) {
|
|
17
|
+
const onlyInFirst = [];
|
|
18
|
+
const differingContent = [];
|
|
19
|
+
for (const [path, content] of first) {
|
|
20
|
+
if (!second.has(path))
|
|
21
|
+
onlyInFirst.push(path);
|
|
22
|
+
else if (second.get(path) !== content)
|
|
23
|
+
differingContent.push(path);
|
|
24
|
+
}
|
|
25
|
+
const onlyInSecond = [...second.keys()].filter((path) => !first.has(path));
|
|
26
|
+
return {
|
|
27
|
+
onlyInFirst: onlyInFirst.sort(),
|
|
28
|
+
onlyInSecond: onlyInSecond.sort(),
|
|
29
|
+
differingContent: differingContent.sort(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Whether a diff reports no divergence at all — the conformance condition. */
|
|
33
|
+
export function isIdentical(diff) {
|
|
34
|
+
return (diff.onlyInFirst.length === 0 &&
|
|
35
|
+
diff.onlyInSecond.length === 0 &&
|
|
36
|
+
diff.differingContent.length === 0);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Render a diff as an assertion message.
|
|
40
|
+
*
|
|
41
|
+
* @param diff - The divergence to describe.
|
|
42
|
+
* @param firstLabel - What produced the first tree (e.g. the bin's name).
|
|
43
|
+
* @param secondLabel - What produced the second tree.
|
|
44
|
+
* @returns A multi-line message, or the empty string when the trees match.
|
|
45
|
+
*/
|
|
46
|
+
export function formatTreeDiff(diff, firstLabel, secondLabel) {
|
|
47
|
+
if (isIdentical(diff))
|
|
48
|
+
return "";
|
|
49
|
+
const lines = [];
|
|
50
|
+
if (diff.onlyInFirst.length > 0) {
|
|
51
|
+
lines.push(`only ${firstLabel} wrote: ${diff.onlyInFirst.join(", ")}`);
|
|
52
|
+
}
|
|
53
|
+
if (diff.onlyInSecond.length > 0) {
|
|
54
|
+
lines.push(`only ${secondLabel} wrote: ${diff.onlyInSecond.join(", ")}`);
|
|
55
|
+
}
|
|
56
|
+
if (diff.differingContent.length > 0) {
|
|
57
|
+
lines.push(`contents differ: ${diff.differingContent.join(", ")}`);
|
|
58
|
+
}
|
|
59
|
+
return lines.join("\n");
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=diffTrees.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffTrees.js","sourceRoot":"","sources":["../../../../src/testing/conformance/diffTrees.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,KAAmB,EAAE,MAAoB;IACjE,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,gBAAgB,GAAa,EAAE,CAAC;IACtC,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,KAAK,EAAE,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACzC,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,OAAO;YAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,YAAY,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,OAAO;QACL,WAAW,EAAE,WAAW,CAAC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
|
+
* The shared answer sets both binaries run their conformance cases from.
|
|
3
|
+
*
|
|
4
|
+
* DATA ONLY — this module imports no generator, by design. summon-core sits
|
|
5
|
+
* BELOW both bins, so reaching up for `@canonical/summon`'s `example/hello` or
|
|
6
|
+
* for pragma's bundled component/package/application generators would invert
|
|
7
|
+
* the dependency direction the whole fold rests on. A fixture therefore names
|
|
8
|
+
* its generator by a logical id and carries the answers; the CONSUMING package
|
|
9
|
+
* resolves that id to a real `GeneratorDefinition` it already owns and hands it
|
|
10
|
+
* to {@link produceReference}.
|
|
11
|
+
*
|
|
12
|
+
* The ids are conventional, not enforced: a consumer covers the ones it ships
|
|
13
|
+
* and ignores the rest, and adds its own fixtures where it has generators no
|
|
14
|
+
* one else does.
|
|
15
|
+
*/
|
|
16
|
+
/** The answers every component framework shares (the three optional artifacts). */
|
|
17
|
+
const COMPONENT_ANSWERS = {
|
|
18
|
+
withStyles: true,
|
|
19
|
+
withStories: true,
|
|
20
|
+
withSsrTests: false,
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The design-system generator fixtures — the five trees pragma's `create` verbs
|
|
24
|
+
* and summon's `execute` must agree on byte for byte.
|
|
25
|
+
*/
|
|
26
|
+
export const CONFORMANCE_FIXTURES = [
|
|
27
|
+
{
|
|
28
|
+
name: "component/react",
|
|
29
|
+
generator: "component/react",
|
|
30
|
+
answers: { componentPath: "src/components/Button", ...COMPONENT_ANSWERS },
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "component/svelte",
|
|
34
|
+
generator: "component/svelte",
|
|
35
|
+
answers: { componentPath: "src/lib/Button", ...COMPONENT_ANSWERS },
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "component/lit",
|
|
39
|
+
generator: "component/lit",
|
|
40
|
+
answers: { componentPath: "src/lib/Button", ...COMPONENT_ANSWERS },
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "package",
|
|
44
|
+
generator: "package",
|
|
45
|
+
answers: {
|
|
46
|
+
name: "@canonical/my-lib",
|
|
47
|
+
type: "library",
|
|
48
|
+
description: "A library.",
|
|
49
|
+
withReact: false,
|
|
50
|
+
withStorybook: false,
|
|
51
|
+
withCli: false,
|
|
52
|
+
withPrTemplate: false,
|
|
53
|
+
runInstall: false,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "application",
|
|
58
|
+
generator: "application",
|
|
59
|
+
answers: {
|
|
60
|
+
appPath: "my-app",
|
|
61
|
+
ssr: true,
|
|
62
|
+
router: true,
|
|
63
|
+
forms: true,
|
|
64
|
+
relay: false,
|
|
65
|
+
runInstall: false,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
/**
|
|
70
|
+
* Look up a fixture by name.
|
|
71
|
+
*
|
|
72
|
+
* @param name - The fixture's {@link ConformanceFixture.name}.
|
|
73
|
+
* @returns The fixture.
|
|
74
|
+
* @throws If no fixture carries that name — a typo must fail loudly rather
|
|
75
|
+
* than silently skip a conformance case.
|
|
76
|
+
*/
|
|
77
|
+
export function fixture(name) {
|
|
78
|
+
const found = CONFORMANCE_FIXTURES.find((entry) => entry.name === name);
|
|
79
|
+
if (!found)
|
|
80
|
+
throw new Error(`no conformance fixture named "${name}"`);
|
|
81
|
+
return found;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../../src/testing/conformance/fixtures.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH,mFAAmF;AACnF,MAAM,iBAAiB,GAAG;IACxB,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,KAAK;CACX,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAkC;IACjE;QACE,IAAI,EAAE,iBAAiB;QACvB,SAAS,EAAE,iB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, plus the tools to
|
|
3
|
+
* assert against it.
|
|
4
|
+
*
|
|
5
|
+
* Both binaries generate the same trees from the same generators. That was a
|
|
6
|
+
* guarantee asserted inside ONE bin's test file, which meant the other bin
|
|
7
|
+
* could drift with nothing to catch it. Here it is a named suite that either
|
|
8
|
+
* bin runs: {@link produceReference} IS the definition (summon-core `execute` +
|
|
9
|
+
* `autoPrompt` + `runGeneratorTask` + the shared stamp), {@link snapshotTree}
|
|
10
|
+
* and {@link diffTrees} make "the same tree" a value comparison with a legible
|
|
11
|
+
* failure, and {@link CONFORMANCE_FIXTURES} keeps the answer sets in one place.
|
|
12
|
+
*/
|
|
13
|
+
export { diffTrees, formatTreeDiff, isIdentical } from "./diffTrees.js";
|
|
14
|
+
export { CONFORMANCE_FIXTURES, fixture } from "./fixtures.js";
|
|
15
|
+
export { produceReference } from "./produceReference.js";
|
|
16
|
+
export { snapshotTree } from "./snapshotTree.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/testing/conformance/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE definition of the seam a conforming binary must match.
|
|
3
|
+
*
|
|
4
|
+
* A binary conforms iff, for a given generator and answer set, the tree it
|
|
5
|
+
* writes byte-equals the tree produced HERE: summon-core's `execute` with
|
|
6
|
+
* `autoPrompt`, run through `runGeneratorTask` with the shared stamp
|
|
7
|
+
* (`createStampOnEffectStart(createGeneratorStamp(generator))`). Every other
|
|
8
|
+
* path — the summon bin's Ink front-end, the pragma kernel's `create` verbs —
|
|
9
|
+
* is a UI over exactly this, so the reference is not "one more implementation
|
|
10
|
+
* to keep in sync"; it is the implementation, called without a front-end.
|
|
11
|
+
*
|
|
12
|
+
* Writing that definition down once is the point. Before this module, the
|
|
13
|
+
* guarantee lived only inside one bin's test file, so the OTHER bin could drift
|
|
14
|
+
* and nothing would notice.
|
|
15
|
+
*/
|
|
16
|
+
import { mkdtempSync } from "node:fs";
|
|
17
|
+
import { tmpdir } from "node:os";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
import execute from "../../execute/execute.js";
|
|
20
|
+
import autoPrompt from "../../prompt/autoPrompt.js";
|
|
21
|
+
import runGeneratorTask from "../../run/runGeneratorTask.js";
|
|
22
|
+
import createGeneratorStamp from "../../stamp/createGeneratorStamp.js";
|
|
23
|
+
import createStampOnEffectStart from "../../stamp/createStampOnEffectStart.js";
|
|
24
|
+
import { snapshotTree } from "./snapshotTree.js";
|
|
25
|
+
/** Create the throwaway directory a reference run writes into by default. */
|
|
26
|
+
function freshCwd() {
|
|
27
|
+
return mkdtempSync(join(tmpdir(), "summon-conformance-"));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Produce the reference tree for one generator + answer set.
|
|
31
|
+
*
|
|
32
|
+
* @param run - The generator, its answers, and an optional target directory.
|
|
33
|
+
* @returns The generated tree, snapshotted.
|
|
34
|
+
* @note Impure — writes files and reads them back.
|
|
35
|
+
*/
|
|
36
|
+
export async function produceReference(run) {
|
|
37
|
+
const cwd = run.cwd ?? freshCwd();
|
|
38
|
+
const answers = { ...run.answers };
|
|
39
|
+
await runGeneratorTask(execute(run.generator, { prompt: autoPrompt(answers), params: answers }), {
|
|
40
|
+
cwd,
|
|
41
|
+
promptHandler: autoPrompt(answers),
|
|
42
|
+
onEffectStart: createStampOnEffectStart(createGeneratorStamp(run.generator)),
|
|
43
|
+
onLog: () => { },
|
|
44
|
+
});
|
|
45
|
+
return snapshotTree(cwd);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=produceReference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"produceReference.js","sourceRoot":"","sources":["../../../../src/testing/conformance/produceReference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,UAAU,MAAM,4BAA4B,CAAC;AACpD,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,oBAAoB,MAAM,qCAAqC,CAAC;AACvE,OAAO,wBAAwB,MAAM,yCAAyC,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAqB,MAAM,mBAAmB,CAAC;AAapE,6EAA6E;AAC7E,SAAS,QAAQ;IACf,OAAO,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAiB;IAEjB,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,QAAQ,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACnC,MAAM,gBAAgB,CACpB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EACxE;QACE,GAAG;QACH,aAAa,EAAE,UAAU,CAAC,OAAO,CAAC;QAClC,aAAa,EAAE,wBAAwB,CACrC,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,CACpC;QACD,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;KAChB,CACF,CAAC;IACF,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a generated directory tree into a comparable value.
|
|
3
|
+
*
|
|
4
|
+
* The conformance suite's unit of comparison. A tree is a sorted map of
|
|
5
|
+
* POSIX-style relative path → file contents, which makes "the same tree" an
|
|
6
|
+
* ordinary value equality rather than a filesystem walk each caller reinvents.
|
|
7
|
+
* Directory entries are not recorded: an empty directory a generator creates and
|
|
8
|
+
* never fills is not part of what a consumer sees, and recording it would make
|
|
9
|
+
* two conforming bins differ over a `mkdir` neither materialized.
|
|
10
|
+
*/
|
|
11
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
/**
|
|
14
|
+
* Snapshot a directory tree.
|
|
15
|
+
*
|
|
16
|
+
* @param dir - The root to walk. Every file below it is read as UTF-8.
|
|
17
|
+
* @returns The tree as a sorted path → contents map.
|
|
18
|
+
* @note Impure — reads the filesystem.
|
|
19
|
+
*/
|
|
20
|
+
export function snapshotTree(dir) {
|
|
21
|
+
const out = new Map();
|
|
22
|
+
const walk = (current, base) => {
|
|
23
|
+
const entries = readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
24
|
+
for (const entry of entries) {
|
|
25
|
+
const rel = base ? `${base}/${entry.name}` : entry.name;
|
|
26
|
+
if (entry.isDirectory())
|
|
27
|
+
walk(join(current, entry.name), rel);
|
|
28
|
+
else
|
|
29
|
+
out.set(rel, readFileSync(join(current, entry.name), "utf-8"));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
walk(dir, "");
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=snapshotTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotTree.js","sourceRoot":"","sources":["../../../../src/testing/conformance/snapshotTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAKjC;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtC,MAAM,IAAI,GAAG,CAAC,OAAe,EAAE,IAAY,EAAQ,EAAE;QACnD,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAC1E,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAC7B,CAAC;QACF,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;YACxD,IAAI,KAAK,CAAC,WAAW,EAAE;gBAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;;gBACzD,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACd,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@canonical/summon-core/testing` — test-only helpers a CONSUMER runs.
|
|
3
|
+
*
|
|
4
|
+
* A separate subpath, not part of the main barrel, for two reasons: nothing on
|
|
5
|
+
* a production path should be able to import a temp-directory writer by
|
|
6
|
+
* accident, and the main barrel is the runtime contract while this is a testing
|
|
7
|
+
* contract that may move faster.
|
|
8
|
+
*/
|
|
9
|
+
export { CONFORMANCE_FIXTURES, diffTrees, fixture, formatTreeDiff, isIdentical, produceReference, snapshotTree, } from "./conformance/index.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,EACL,oBAAoB,EACpB,SAAS,EACT,OAAO,EACP,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,GACb,MAAM,wBAAwB,CAAC"}
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* remaining definition maps onto the task alphabet's `PromptQuestion`.
|
|
11
11
|
*
|
|
12
12
|
* Moved into summon-core (from the v1 cli-core `promptForAnswers`) as the
|
|
13
|
-
* answer-collection phase of {@link execute}.
|
|
13
|
+
* answer-collection phase of {@link execute}. The cli-core export that kept the
|
|
14
|
+
* old name alive is gone with that package.
|
|
14
15
|
*/
|
|
15
16
|
import { type Task } from "@canonical/task";
|
|
16
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectAnswers.d.ts","sourceRoot":"","sources":["../../../src/execute/collectAnswers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"collectAnswers.d.ts","sourceRoot":"","sources":["../../../src/execute/collectAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAKL,KAAK,IAAI,EACV,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC7D,qDAAqD;IACrD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,wDAAwD;IACxD,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,yEAAyE;IACzE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;IAC9D,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAAC;CACzD;AAuDD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,cAAc,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM,GACrD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAc/B"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Moved into summon-core (from the v1 cli-core `formatEffects`) so both the
|
|
5
5
|
* summon bin and the pragma kernel share one effect-formatting surface without
|
|
6
6
|
* either importing the other. The pragma `create` render layer reuses these
|
|
7
|
-
* helpers to project a {@link GeneratorResult}
|
|
8
|
-
*
|
|
7
|
+
* helpers to project a {@link GeneratorResult}. Both bins now import them from
|
|
8
|
+
* HERE — the cli-core re-export shim went with that package.
|
|
9
9
|
*/
|
|
10
10
|
import type { Effect } from "@canonical/task";
|
|
11
11
|
import type GeneratorDefinition from "../types/GeneratorDefinition.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Wizard.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/Wizard.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"Wizard.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/Wizard.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAE,iBAAiB,EAAe,MAAM,cAAc,CAAC;AA+GnE,MAAM,WAAW,WAAW;IAC1B,oDAAoD;IACpD,UAAU,EAAE,iBAAiB,CAAC;CAC/B;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,GAAI,gBAAgB,WAAW,4CAsGjD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure evaluation of a prompt's `validate` for the Ink widgets, so
|
|
3
|
+
* select/multiselect/confirm can run it INLINE with recovery (C6/M5) exactly as
|
|
4
|
+
* the text widget already does — instead of only catching a bad answer
|
|
5
|
+
* post-collection in `validateAnswers`, which fails the whole run with no chance
|
|
6
|
+
* to correct it in place. This is also the mechanism a multiselect uses to
|
|
7
|
+
* enforce a minimum selection (C-lo3): a validator that rejects an empty array.
|
|
8
|
+
*
|
|
9
|
+
* A `.ts` sibling of the JSX widgets so the accept/reject decision is unit
|
|
10
|
+
* testable without an Ink render.
|
|
11
|
+
*/
|
|
12
|
+
/** A prompt's own value constraint: `true` accepts, a string is the error text. */
|
|
13
|
+
export type ValidateFn = (value: unknown) => boolean | string;
|
|
14
|
+
/** The outcome of running a {@link ValidateFn}: accepted, or a message to show. */
|
|
15
|
+
export type ValidationResult = {
|
|
16
|
+
readonly ok: true;
|
|
17
|
+
} | {
|
|
18
|
+
readonly ok: false;
|
|
19
|
+
readonly message: string;
|
|
20
|
+
};
|
|
21
|
+
/** The fallback message when a validator rejects without its own string. */
|
|
22
|
+
export declare const DEFAULT_INVALID_MESSAGE = "Invalid input";
|
|
23
|
+
/**
|
|
24
|
+
* Run a prompt's optional `validate` against a candidate answer.
|
|
25
|
+
*
|
|
26
|
+
* @param validate - The prompt's validator, or `undefined` (always accepts).
|
|
27
|
+
* @param value - The candidate answer to check.
|
|
28
|
+
* @returns A {@link ValidationResult} — `ok` when accepted, else the message.
|
|
29
|
+
*/
|
|
30
|
+
export declare function evaluateValidation(validate: ValidateFn | undefined, value: unknown): ValidationResult;
|
|
31
|
+
//# sourceMappingURL=answerValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answerValidation.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/answerValidation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mFAAmF;AACnF,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,MAAM,CAAC;AAE9D,mFAAmF;AACnF,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;CAAE,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,UAAU,GAAG,SAAS,EAChC,KAAK,EAAE,OAAO,GACb,gBAAgB,CAQlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/mount.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,M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Q,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,mBAAmB,EAC9B,OAAO,GAAE,gBAAqB,GAC7B,cAAc,CAmChB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for the wizard's live progress view (C7/M7): keep each completed
|
|
3
|
+
* effect on ONE line by middle-truncating long paths, so a big application
|
|
4
|
+
* scaffold's progress does not wrap and jitter. Paired with rendering the
|
|
5
|
+
* completed lines under Ink's `<Static>` in `Wizard.tsx` — which is what
|
|
6
|
+
* actually stops the full-history re-render on every effect (the flicker/scroll
|
|
7
|
+
* root) — this keeps the live frame to a bounded, single-line-per-effect window.
|
|
8
|
+
*
|
|
9
|
+
* Truncation is DISPLAY-WIDTH aware, not UTF-16-code-unit aware. It iterates
|
|
10
|
+
* whole Unicode code points (so a supplementary-plane character is never sliced
|
|
11
|
+
* between its surrogate halves into a lone-surrogate `�`), and it counts East
|
|
12
|
+
* Asian Wide / Fullwidth / emoji code points as two terminal columns — because
|
|
13
|
+
* Ink lays the line out by cell width, so a code-unit cap alone would still let
|
|
14
|
+
* wide glyphs overflow and wrap. {@link measureDisplayWidth} is the shared
|
|
15
|
+
* width approximation both concerns rely on.
|
|
16
|
+
*
|
|
17
|
+
* A `.ts` sibling of the JSX view so the string math is unit testable.
|
|
18
|
+
*/
|
|
19
|
+
/** Max display columns a single progress line may occupy before it is truncated. */
|
|
20
|
+
export declare const MAX_PROGRESS_LINE = 72;
|
|
21
|
+
/** The single-column marker inserted where a truncated middle was elided. */
|
|
22
|
+
export declare const TRUNCATION_MARKER = "\u2026";
|
|
23
|
+
/**
|
|
24
|
+
* Measure the terminal-column width of a string, summing per-code-point widths:
|
|
25
|
+
* one column for most code points, two for East Asian Wide / emoji ones (see
|
|
26
|
+
* {@link isWideCodePoint}). Iterating code points rather than UTF-16 code units
|
|
27
|
+
* means a surrogate pair counts once, as the single glyph it renders to.
|
|
28
|
+
*
|
|
29
|
+
* @param text - The string to measure.
|
|
30
|
+
* @returns The approximate number of terminal columns `text` occupies.
|
|
31
|
+
*/
|
|
32
|
+
export declare function measureDisplayWidth(text: string): number;
|
|
33
|
+
/**
|
|
34
|
+
* Middle-truncate a progress line to `max` DISPLAY columns, preserving BOTH
|
|
35
|
+
* ends — a described effect's verb prefix (e.g. `Write file:`) and the tail of
|
|
36
|
+
* its path (the most identifying part) — and eliding the middle with
|
|
37
|
+
* {@link TRUNCATION_MARKER}.
|
|
38
|
+
*
|
|
39
|
+
* Width is measured and cut by {@link measureDisplayWidth}, iterating whole
|
|
40
|
+
* code points, so the one-row guarantee holds for multibyte and wide (CJK /
|
|
41
|
+
* emoji) paths and a surrogate pair is never split into a lone-surrogate `�`.
|
|
42
|
+
*
|
|
43
|
+
* @param line - The described-effect line (e.g. `Write file: a/b/c.ts (12 bytes)`).
|
|
44
|
+
* @param max - The width cap, in columns; defaults to {@link MAX_PROGRESS_LINE}.
|
|
45
|
+
* @returns The line unchanged when within the cap, else its truncated form.
|
|
46
|
+
*/
|
|
47
|
+
export declare function truncateMiddle(line: string, max?: number): string;
|
|
48
|
+
//# sourceMappingURL=progressWindow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progressWindow.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/progressWindow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,WAAM,CAAC;AAyDrC;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD;AAwBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,MAA0B,GAC9B,MAAM,CAYR"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { PromptQuestion } from "@canonical/task";
|
|
7
7
|
import type PromptDefinition from "../../types/PromptDefinition.js";
|
|
8
|
+
import { type ValidateFn } from "./answerValidation.js";
|
|
8
9
|
/** Format an answer value for the completed-answers table. */
|
|
9
10
|
export declare const formatAnswerValue: (value: unknown, prompt: Pick<PromptDefinition, "type" | "choices">) => string;
|
|
10
11
|
/** The completed-answers table (aligned, borderless). */
|
|
@@ -17,9 +18,17 @@ export declare const ProgressHeader: ({ current, total, }: {
|
|
|
17
18
|
current: number;
|
|
18
19
|
total: number;
|
|
19
20
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
/**
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Render the widget for a single {@link PromptQuestion}.
|
|
23
|
+
*
|
|
24
|
+
* `validate` is the prompt definition's own constraint (looked up by the wizard
|
|
25
|
+
* from `generator.prompts`), threaded into the non-text widgets so they run it
|
|
26
|
+
* INLINE with recovery (C6) — the `text` widget already validates via its own
|
|
27
|
+
* question field.
|
|
28
|
+
*/
|
|
29
|
+
export declare const QuestionView: ({ question, validate, onSubmit, onCancel, }: {
|
|
22
30
|
question: PromptQuestion;
|
|
31
|
+
validate?: ValidateFn;
|
|
23
32
|
onSubmit: (value: unknown) => void;
|
|
24
33
|
onCancel: () => void;
|
|
25
34
|
}) => import("react/jsx-runtime").JSX.Element;
|