@canonical/summon-core 0.33.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/mount.js +4 -2
- package/dist/esm/prompt/ink/mount.js.map +1 -1
- 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/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 +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
|
* 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 { $, gen, prompt, } from "@canonical/task";
|
|
16
17
|
/** Map one definition onto the task alphabet's question for its type. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectAnswers.js","sourceRoot":"","sources":["../../../src/execute/collectAnswers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"collectAnswers.js","sourceRoot":"","sources":["../../../src/execute/collectAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,CAAC,EACD,GAAG,EAEH,MAAM,GAEP,MAAM,iBAAiB,CAAC;AA0BzB,yEAAyE;AACzE,SAAS,UAAU,CAAC,UAA4B;IAC9C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IACrC,QAAQ,UAAU,CAAC,IAAI,EA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9B,CAAC;IACN,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,OAAoC,EACpC,iBAAoD,EAAE;IAEtD,OAAO,GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,OAAO,GAA4B,EAAE,GAAG,cAAc,EAAE,CAAC;QAC/D,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;YACjC,IAAI,UAAU,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;gBAC/B,SAAS;YACX,CAAC;YACD,IAAI,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;gBACzD,SAAS;YACX,CAAC;YACD,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -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 * as path from "node:path";
|
|
11
11
|
import chalk from "chalk";
|
|
@@ -12,8 +12,10 @@ import { Wizard } from "./Wizard.js";
|
|
|
12
12
|
*/
|
|
13
13
|
export function mountPromptSession(generator, options = {}) {
|
|
14
14
|
// Thread the run's cancel (H2): an in-Ink Ctrl-C/escape calls
|
|
15
|
-
// controller.cancel(), which invokes this to abort the interpreter.
|
|
16
|
-
|
|
15
|
+
// controller.cancel(), which invokes this to abort the interpreter. `cwd` is
|
|
16
|
+
// the write root the confirm gate's preview reads against, so the pane shows
|
|
17
|
+
// the plan for the tree the run will actually write into.
|
|
18
|
+
const controller = new SessionController(generator, options.onCancel, options.cwd);
|
|
17
19
|
const instance = render(_jsx(Wizard, { controller: controller }), {
|
|
18
20
|
stdout: process.stderr,
|
|
19
21
|
stdin: process.stdin,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../../../src/prompt/ink/mount.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAI7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAWrC;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAA8B,EAC9B,UAA4B,EAAE;IAE9B,8DAA8D;IAC9D,
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../../../src/prompt/ink/mount.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAI7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAWrC;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAA8B,EAC9B,UAA4B,EAAE;IAE9B,8DAA8D;IAC9D,6EAA6E;IAC7E,6EAA6E;IAC7E,0DAA0D;IAC1D,MAAM,UAAU,GAAG,IAAI,iBAAiB,CACtC,SAAS,EACT,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,GAAG,CACZ,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAC,MAAM,IAAC,UAAU,EAAE,UAAU,GAAI,EAAE;QAC1D,MAAM,EAAE,OAAO,CAAC,MAAuC;QACvD,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW,EAAE,KAAK;KACnB,CAAC,CAAC;IAEH,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,OAAO,GAAG,GAAS,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;IAChD,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE3C,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,OAAO;QACL,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC;QACpD,iBAAiB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC;QACnE,oBAAoB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CACzC,UAAU,CAAC,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC;QACnD,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC;QACnE,OAAO,EAAE,GAAG,EAAE;YACZ,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,UAAU,CAAC,YAAY,EAAE,CAAC;YAC1B,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -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,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;SACxE,MAAM,CAAC;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,iBAAiB;IA6BT;IACA;IA7BX,OAAO,CAAc;IAC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mB;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,IAAI,EAAE;QAC/B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE;QACjC,gBAAgB,EAAE,gBAAgB,CAAC,IAAI,EAAE;KAC1C,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CAAC,IAAc;IACxC,OAAO,CACL,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;QAC7B,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC;QAC9B,IAAI,CAAC,gBAAgB,CAAC,MAAM,KAAK,CAAC,CACnC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAc,EACd,UAAkB,EAClB,WAAmB;IAEnB,IAAI,WAAW,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,QAAQ,UAAU,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC,QAAQ,WAAW,WAAW,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 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,iBAAiB;QAC5B,OAAO,EAAE,EAAE,aAAa,EAAE,uBAAuB,EAAE,GAAG,iBAAiB,EAAE;KAC1E;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,SAAS,EAAE,kBAAkB;QAC7B,OAAO,EAAE,EAAE,aAAa,EAAE,gBAAgB,EAAE,GAAG,iBAAiB,EAAE;KACnE;IACD;QACE,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE,eAAe;QAC1B,OAAO,EAAE,EAAE,aAAa,EAAE,gBAAgB,EAAE,GAAG,iBAAiB,EAAE;KACnE;IACD;QACE,IAAI,EAAE,SAAS;QACf,SAAS,EAAE,SAAS;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,YAAY;YACzB,SAAS,EAAE,KAAK;YAChB,aAAa,EAAE,KAAK;YACpB,OAAO,EAAE,KAAK;YACd,cAAc,EAAE,KAAK;YACrB,UAAU,EAAE,KAAK;SAClB;KACF;IACD;QACE,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,aAAa;QACxB,OAAO,EAAE;YACP,OAAO,EAAE,QAAQ;YACjB,GAAG,EAAE,IAAI;YACT,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,KAAK;YACZ,UAAU,EAAE,KAAK;SAClB;KACF;CACF,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,MAAM,KAAK,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACxE,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,GAAG,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The byte-equality conformance suite: the seam's definition, 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/produceRe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ree 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":"mount.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/mount.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,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AC5C,oBAAoB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACjE,SAAS,EAAE,CAAC,KAAK,EAAE,QAAQ,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"}
|
|
@@ -43,10 +43,13 @@ export interface WizardState {
|
|
|
43
43
|
*/
|
|
44
44
|
export declare class SessionController {
|
|
45
45
|
private readonly onUserCancel?;
|
|
46
|
+
private readonly cwd?;
|
|
46
47
|
private current;
|
|
47
48
|
private readonly listeners;
|
|
48
49
|
private pending?;
|
|
49
50
|
private executionStart;
|
|
51
|
+
/** The confirm gate's in-flight preview, awaited only by {@link previewSettled}. */
|
|
52
|
+
private previewInFlight?;
|
|
50
53
|
/**
|
|
51
54
|
* @param generator - The generator being run.
|
|
52
55
|
* @param onUserCancel - Invoked once when the user cancels (Ctrl-C / escape).
|
|
@@ -55,8 +58,12 @@ export declare class SessionController {
|
|
|
55
58
|
* `checkInterrupted` fires between effects) instead of only rejecting a
|
|
56
59
|
* — by then non-existent — pending prompt. `abort()` is idempotent, so the
|
|
57
60
|
* signal→cancel→abort path cannot loop.
|
|
61
|
+
* @param cwd - The write root the run will resolve relative effect paths
|
|
62
|
+
* against. The preview reads the SAME tree, so the gate's plan is the plan
|
|
63
|
+
* the run produces. Omitted falls back to the process cwd, matching a run
|
|
64
|
+
* whose interpreter was given no `cwd`.
|
|
58
65
|
*/
|
|
59
|
-
constructor(generator: GeneratorDefinition, onUserCancel?: (() => void) | undefined);
|
|
66
|
+
constructor(generator: GeneratorDefinition, onUserCancel?: (() => void) | undefined, cwd?: string | undefined);
|
|
60
67
|
/** Subscribe to state changes; returns an unsubscribe function. */
|
|
61
68
|
subscribe: (listener: () => void) => (() => void);
|
|
62
69
|
/** The current immutable snapshot (stable identity between changes). */
|
|
@@ -67,6 +74,34 @@ export declare class SessionController {
|
|
|
67
74
|
* view resolves once the user answers (or the run is cancelled).
|
|
68
75
|
*/
|
|
69
76
|
request(effect: PromptEffect): Promise<unknown>;
|
|
77
|
+
/**
|
|
78
|
+
* Fill the confirm gate's preview pane with the HONEST plan.
|
|
79
|
+
*
|
|
80
|
+
* `runPreview` reads the real filesystem (through a virtual write overlay, so
|
|
81
|
+
* a step sees what the step before it planned) and records writes without
|
|
82
|
+
* performing them — the gate is shown BEFORE the user consents, so it must
|
|
83
|
+
* not touch the disk, and it must not lie about what will happen. The mock it
|
|
84
|
+
* replaces answered every read with a placeholder and `Exists` with `true`,
|
|
85
|
+
* so the pane could promise files a run would never reach.
|
|
86
|
+
*
|
|
87
|
+
* Failure shows an EMPTY pane rather than a fictional one: the generator's
|
|
88
|
+
* own error belongs to the run, which reports it with its real message, and
|
|
89
|
+
* the decision at the gate stays the user's. A result that arrives after the
|
|
90
|
+
* gate is gone — the user answered or cancelled while the reads were in
|
|
91
|
+
* flight — is dropped, so a slow preview can never repaint a pane the wizard
|
|
92
|
+
* has already left.
|
|
93
|
+
*/
|
|
94
|
+
private loadPreview;
|
|
95
|
+
/**
|
|
96
|
+
* Resolves once the confirm gate's preview has been applied (or dropped as
|
|
97
|
+
* stale). The wizard itself never awaits this — the pane repaints when the
|
|
98
|
+
* preview lands, which is the whole point of making it async — but a caller
|
|
99
|
+
* that asserts ON the pane has to synchronise with the real filesystem reads
|
|
100
|
+
* the preview performs, and a wall-clock delay would only be flaky.
|
|
101
|
+
*
|
|
102
|
+
* @returns A promise for the in-flight preview, already resolved when none is.
|
|
103
|
+
*/
|
|
104
|
+
previewSettled(): Promise<void>;
|
|
70
105
|
/** Feed effect start (kept for seam symmetry; progress rides completion). */
|
|
71
106
|
reportEffectStart(_effect: Effect): void;
|
|
72
107
|
/** Record a completed effect for the live progress view. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ink/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,SAAS,EAEf,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,2CAA2C;AAC3C,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,WAAW,GACX,YAAY,GACZ,WAAW,GACX,UAAU,GACV,OAAO,GACP,WAAW,CAAC;AAEhB,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,mEAAmE;IACnE,QAAQ,CAAC,cAAc,CAAC,EAAE,YAAY,CAAC;IACvC,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C,2CAA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YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAgBlC,0CAA0C;IAC1C,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IASrC;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,IAAI,IAAI;CAYf"}
|
|
@@ -31,6 +31,13 @@ export interface InkPromptOptions {
|
|
|
31
31
|
* way (an external abort tears the render down).
|
|
32
32
|
*/
|
|
33
33
|
readonly onCancel?: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* The write root the run resolves relative effect paths against — pass the
|
|
36
|
+
* same value the interpreter will receive. The confirm gate's preview reads
|
|
37
|
+
* that tree, so the pane's plan is the plan the run produces. Omitted falls
|
|
38
|
+
* back to the process cwd, matching a run given no `cwd` of its own.
|
|
39
|
+
*/
|
|
40
|
+
readonly cwd?: string;
|
|
34
41
|
}
|
|
35
42
|
/**
|
|
36
43
|
* A running Ink session's seam surface: the prompt handler plus the effect
|
|
@@ -55,9 +62,9 @@ export interface InkSession {
|
|
|
55
62
|
* dynamically imports the React UI), so picking this strategy on a fast path
|
|
56
63
|
* that never prompts costs nothing and loads no React.
|
|
57
64
|
*
|
|
58
|
-
* @param generator - The generator being run (the session
|
|
59
|
-
* the confirm gate's
|
|
60
|
-
* @param options - The abort signal.
|
|
65
|
+
* @param generator - The generator being run (the session previews it to build
|
|
66
|
+
* the confirm gate's plan).
|
|
67
|
+
* @param options - The abort signal, cancel callback, and preview write root.
|
|
61
68
|
* @returns The {@link InkSession} the `create` verb wires into `runtime.exec`.
|
|
62
69
|
*/
|
|
63
70
|
export default function inkPrompt(generator: GeneratorDefinition, options?: InkPromptOptions): InkSession;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inkPrompt.d.ts","sourceRoot":"","sources":["../../../src/prompt/inkPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC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M,KAAK,IAAI,CAAC;IAC3D,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAWD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,SAAS,EAAE,mBAAmB,EAC9B,OAAO,GAAE,gBAAqB,GAC7B,UAAU,CA4BZ"}
|
|
@@ -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 type { Task } from "@canonical/task";
|
|
17
19
|
import { type RunTaskOptions } from "@canonical/task/node";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runGeneratorTask.d.ts","sourceRoot":"","sources":["../../../src/run/runGeneratorTask.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"runGeneratorTask.d.ts","sourceRoot":"","sources":["../../../src/run/runGeneratorTask.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,cAAc,EAAW,MAAM,sBAAsB,CAAC;AAEpE,wEAAwE;AACxE,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,QAAQ,CAAC,aAAa,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IACzD,kEAAkE;IAClE,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IACzC,6CAA6C;IAC7C,QAAQ,CAAC,aAAa,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IACzD,0CAA0C;IAC1C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAC/D,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAaD;;;;;;;;;;;;GAYG;AACH,wBAA8B,gBAAgB,CAAC,CAAC,EAC9C,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EACb,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,CAAC,CAAC,CA0BZ"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
import type { TreeSnapshot } from "./snapshotTree.js";
|
|
10
|
+
/** How two trees differ. Empty in all three fields means byte-identical. */
|
|
11
|
+
export interface TreeDiff {
|
|
12
|
+
/** Paths the first tree has and the second does not. */
|
|
13
|
+
readonly onlyInFirst: readonly string[];
|
|
14
|
+
/** Paths the second tree has and the first does not. */
|
|
15
|
+
readonly onlyInSecond: readonly string[];
|
|
16
|
+
/** Paths both trees have, whose contents differ. */
|
|
17
|
+
readonly differingContent: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Diff two snapshots.
|
|
21
|
+
*
|
|
22
|
+
* @param first - One producer's tree.
|
|
23
|
+
* @param second - The other producer's tree.
|
|
24
|
+
* @returns The three divergence sets, each sorted.
|
|
25
|
+
*/
|
|
26
|
+
export declare function diffTrees(first: TreeSnapshot, second: TreeSnapshot): TreeDiff;
|
|
27
|
+
/** Whether a diff reports no divergence at all — the conformance condition. */
|
|
28
|
+
export declare function isIdentical(diff: TreeDiff): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Render a diff as an assertion message.
|
|
31
|
+
*
|
|
32
|
+
* @param diff - The divergence to describe.
|
|
33
|
+
* @param firstLabel - What produced the first tree (e.g. the bin's name).
|
|
34
|
+
* @param secondLabel - What produced the second tree.
|
|
35
|
+
* @returns A multi-line message, or the empty string when the trees match.
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatTreeDiff(diff: TreeDiff, firstLabel: string, secondLabel: string): string;
|
|
38
|
+
//# sourceMappingURL=diffTrees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffTrees.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance/diffTrees.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,4EAA4E;AAC5E,MAAM,WAAW,QAAQ;IACvB,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,oDAAoD;IACpD,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,QAAQ,CAa7E;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAMnD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAaR"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 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
|
+
/** One conformance case: which generator, and the complete answers for it. */
|
|
17
|
+
export interface ConformanceFixture {
|
|
18
|
+
/** Human-readable case name, used in test titles. */
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/** Logical generator id the consuming package resolves (e.g. `component/react`). */
|
|
21
|
+
readonly generator: string;
|
|
22
|
+
/** A COMPLETE answer set — every prompt answered, so no interaction occurs. */
|
|
23
|
+
readonly answers: Readonly<Record<string, unknown>>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The design-system generator fixtures — the five trees pragma's `create` verbs
|
|
27
|
+
* and summon's `execute` must agree on byte for byte.
|
|
28
|
+
*/
|
|
29
|
+
export declare const CONFORMANCE_FIXTURES: readonly ConformanceFixture[];
|
|
30
|
+
/**
|
|
31
|
+
* Look up a fixture by name.
|
|
32
|
+
*
|
|
33
|
+
* @param name - The fixture's {@link ConformanceFixture.name}.
|
|
34
|
+
* @returns The fixture.
|
|
35
|
+
* @throws If no fixture carries that name — a typo must fail loudly rather
|
|
36
|
+
* than silently skip a conformance case.
|
|
37
|
+
*/
|
|
38
|
+
export declare function fixture(name: string): ConformanceFixture;
|
|
39
|
+
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance/fixtures.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrD;AASD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,kBAAkB,EA0C7D,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAIxD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The byte-equality conformance suite: the seam's definition, 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 type { TreeDiff } from "./diffTrees.js";
|
|
14
|
+
export { diffTrees, formatTreeDiff, isIdentical } from "./diffTrees.js";
|
|
15
|
+
export type { ConformanceFixture } from "./fixtures.js";
|
|
16
|
+
export { CONFORMANCE_FIXTURES, fixture } from "./fixtures.js";
|
|
17
|
+
export type { ReferenceRun } from "./produceReference.js";
|
|
18
|
+
export { produceReference } from "./produceReference.js";
|
|
19
|
+
export type { TreeSnapshot } from "./snapshotTree.js";
|
|
20
|
+
export { snapshotTree } from "./snapshotTree.js";
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC9D,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 type GeneratorDefinition from "../../types/GeneratorDefinition.js";
|
|
17
|
+
import { type TreeSnapshot } from "./snapshotTree.js";
|
|
18
|
+
/** One reference run: a generator, the answers to feed it, and where to write. */
|
|
19
|
+
export interface ReferenceRun {
|
|
20
|
+
/** The generator definition under test — supplied by the CALLER's package. */
|
|
21
|
+
readonly generator: GeneratorDefinition<any>;
|
|
22
|
+
/** The complete answer set; every prompt must be answered (no interaction). */
|
|
23
|
+
readonly answers: Readonly<Record<string, unknown>>;
|
|
24
|
+
/** Where to generate. Defaults to a fresh temp directory. */
|
|
25
|
+
readonly cwd?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Produce the reference tree for one generator + answer set.
|
|
29
|
+
*
|
|
30
|
+
* @param run - The generator, its answers, and an optional target directory.
|
|
31
|
+
* @returns The generated tree, snapshotted.
|
|
32
|
+
* @note Impure — writes files and reads them back.
|
|
33
|
+
*/
|
|
34
|
+
export declare function produceReference(run: ReferenceRun): Promise<TreeSnapshot>;
|
|
35
|
+
//# sourceMappingURL=produceReference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"produceReference.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance/produceReference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,OAAO,KAAK,mBAAmB,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEpE,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAE9E,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAC7C,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpD,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAOD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,YAAY,GAChB,OAAO,CAAC,YAAY,CAAC,CAevB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
/** A generated tree: relative path → file contents, in sorted path order. */
|
|
12
|
+
export type TreeSnapshot = ReadonlyMap<string, string>;
|
|
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 declare function snapshotTree(dir: string): TreeSnapshot;
|
|
21
|
+
//# sourceMappingURL=snapshotTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotTree.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance/snapshotTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,6EAA6E;AAC7E,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CActD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 type { ConformanceFixture, ReferenceRun, TreeDiff, TreeSnapshot, } from "./conformance/index.js";
|
|
10
|
+
export { CONFORMANCE_FIXTURES, diffTrees, fixture, formatTreeDiff, isIdentical, produceReference, snapshotTree, } from "./conformance/index.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACV,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EACR,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oBAAoB,EACpB,SAAS,EACT,OAAO,EACP,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,GACb,MAAM,wBAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/summon-core",
|
|
3
3
|
"description": "Code generation framework: generator definitions, templates, stamps, discovery. Built on @canonical/task.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.34.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
@@ -9,10 +9,15 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/types/index.d.ts",
|
|
11
11
|
"import": "./dist/esm/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./testing": {
|
|
14
|
+
"types": "./dist/types/testing/index.d.ts",
|
|
15
|
+
"import": "./dist/esm/testing/index.js"
|
|
12
16
|
}
|
|
13
17
|
},
|
|
14
18
|
"files": [
|
|
15
|
-
"dist"
|
|
19
|
+
"dist",
|
|
20
|
+
"spec"
|
|
16
21
|
],
|
|
17
22
|
"author": {
|
|
18
23
|
"email": "webteam@canonical.com",
|
|
@@ -46,9 +51,9 @@
|
|
|
46
51
|
},
|
|
47
52
|
"devDependencies": {
|
|
48
53
|
"@biomejs/biome": "2.4.9",
|
|
49
|
-
"@canonical/biome-config": "^0.
|
|
50
|
-
"@canonical/typescript-config": "^0.
|
|
51
|
-
"@canonical/webarchitect": "^0.
|
|
54
|
+
"@canonical/biome-config": "^0.34.0",
|
|
55
|
+
"@canonical/typescript-config": "^0.34.0",
|
|
56
|
+
"@canonical/webarchitect": "^0.34.0",
|
|
52
57
|
"@types/bun": "^1.3.10",
|
|
53
58
|
"@types/ejs": "^3.1.5",
|
|
54
59
|
"@types/node": "^24.12.0",
|
|
@@ -58,8 +63,8 @@
|
|
|
58
63
|
"vitest": "^4.0.18"
|
|
59
64
|
},
|
|
60
65
|
"dependencies": {
|
|
61
|
-
"@canonical/task": "^0.
|
|
62
|
-
"@canonical/utils": "^0.
|
|
66
|
+
"@canonical/task": "^0.34.0",
|
|
67
|
+
"@canonical/utils": "^0.34.0",
|
|
63
68
|
"chalk": "^5.6.2",
|
|
64
69
|
"ejs": "^5.0.0",
|
|
65
70
|
"ink": "^6.8.0",
|
|
@@ -67,5 +72,5 @@
|
|
|
67
72
|
"ink-text-input": "^6.0.0",
|
|
68
73
|
"react": "^19.2.4"
|
|
69
74
|
},
|
|
70
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "e8d25fecbe6e70edfc4cb300bad65f691dbbd26e"
|
|
71
76
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://canonical.com/schemas/summon/generator-definition.v1.schema.json",
|
|
4
|
+
"$comment": "Owner ruling (2026-07-31), verbatim: the shared contract is not the generator definition (which arguably belongs in summon) — it is the general command types seam and the compositional logic. So THIS file is summon's own DOMAIN spec: what a generator is, in summon's terms, versioned so a change to it is visible. It does not describe, and must not be taken to describe, the contract between a CLI kernel and its commands; extracting that seam is a separate program with its own ADR. v1 is the shape summon-core ships today. A backwards-incompatible change gets a v2 file beside this one, not an edit here.",
|
|
5
|
+
"title": "Summon generator definition (v1)",
|
|
6
|
+
"description": "The DECLARATIVE projection of a GeneratorDefinition — the parts expressible as data. `generate`, and a prompt's `when`/`validate`, are functions carried by the module and cannot appear in JSON; they are documented here as code-carried so that a reader of this schema is not misled into thinking a JSON document alone is a generator.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"required": ["meta", "prompts"],
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"meta": { "$ref": "#/$defs/meta" },
|
|
12
|
+
"prompts": {
|
|
13
|
+
"description": "The questions whose answers `generate` receives, in ask order.",
|
|
14
|
+
"type": "array",
|
|
15
|
+
"items": { "$ref": "#/$defs/prompt" }
|
|
16
|
+
},
|
|
17
|
+
"generate": {
|
|
18
|
+
"$comment": "CODE-CARRIED, not data: a pure function `(answers) => Task<void>`. Present on every real generator; absent from any JSON projection of one.",
|
|
19
|
+
"description": "Declared here for completeness only — a JSON document cannot carry it.",
|
|
20
|
+
"type": "null"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"$defs": {
|
|
24
|
+
"meta": {
|
|
25
|
+
"title": "Generator metadata",
|
|
26
|
+
"description": "What discovery, help and the generated-file stamp read.",
|
|
27
|
+
"type": "object",
|
|
28
|
+
"required": ["name", "displayName", "description", "version"],
|
|
29
|
+
"additionalProperties": false,
|
|
30
|
+
"properties": {
|
|
31
|
+
"name": {
|
|
32
|
+
"description": "Generator name, used in the CLI path (e.g. `component/react`).",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"minLength": 1
|
|
35
|
+
},
|
|
36
|
+
"displayName": {
|
|
37
|
+
"description": "The name written into generated-file stamp comments. Distinct from `name` when the stamp should not be the CLI path (e.g. `@canonical/summon-component:react`). Load-bearing for byte equality: two bins agree on a tree only if they agree on this.",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"minLength": 1
|
|
40
|
+
},
|
|
41
|
+
"description": {
|
|
42
|
+
"description": "One-line description shown in generator listings.",
|
|
43
|
+
"type": "string"
|
|
44
|
+
},
|
|
45
|
+
"version": {
|
|
46
|
+
"description": "Semantic version of the generator. Also written into the stamp.",
|
|
47
|
+
"type": "string",
|
|
48
|
+
"minLength": 1
|
|
49
|
+
},
|
|
50
|
+
"author": {
|
|
51
|
+
"description": "Author name or email.",
|
|
52
|
+
"type": "string"
|
|
53
|
+
},
|
|
54
|
+
"help": {
|
|
55
|
+
"description": "Extended help text shown for `summon <topic>` and `--help`.",
|
|
56
|
+
"type": "string"
|
|
57
|
+
},
|
|
58
|
+
"examples": {
|
|
59
|
+
"description": "Usage examples shown in help; each one a common invocation.",
|
|
60
|
+
"type": "array",
|
|
61
|
+
"items": { "type": "string" }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"prompt": {
|
|
66
|
+
"title": "Prompt definition",
|
|
67
|
+
"description": "One question. Each prompt also becomes a CLI flag, kebab-cased from `name` (`componentPath` → `--component-path`).",
|
|
68
|
+
"type": "object",
|
|
69
|
+
"required": ["name", "message", "type"],
|
|
70
|
+
"additionalProperties": false,
|
|
71
|
+
"properties": {
|
|
72
|
+
"name": {
|
|
73
|
+
"description": "Unique identifier — the answer key and the flag name.",
|
|
74
|
+
"type": "string",
|
|
75
|
+
"minLength": 1
|
|
76
|
+
},
|
|
77
|
+
"message": {
|
|
78
|
+
"description": "Question text displayed to the user.",
|
|
79
|
+
"type": "string"
|
|
80
|
+
},
|
|
81
|
+
"type": {
|
|
82
|
+
"description": "Kind of input.",
|
|
83
|
+
"enum": ["text", "confirm", "select", "multiselect"]
|
|
84
|
+
},
|
|
85
|
+
"default": {
|
|
86
|
+
"$comment": "Unconstrained on purpose: the value's type follows `type` (string for text/select, boolean for confirm, array for multiselect), and pinning that here would duplicate a rule `validateAnswers` already owns."
|
|
87
|
+
},
|
|
88
|
+
"choices": {
|
|
89
|
+
"description": "Options for `select`/`multiselect` prompts.",
|
|
90
|
+
"type": "array",
|
|
91
|
+
"items": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"required": ["label", "value"],
|
|
94
|
+
"additionalProperties": false,
|
|
95
|
+
"properties": {
|
|
96
|
+
"label": { "type": "string" },
|
|
97
|
+
"value": { "type": "string" }
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"when": {
|
|
102
|
+
"$comment": "CODE-CARRIED, not data: `(answers) => boolean`, evaluated against the answers collected so far.",
|
|
103
|
+
"description": "Declared here for completeness only — a JSON document cannot carry it.",
|
|
104
|
+
"type": "null"
|
|
105
|
+
},
|
|
106
|
+
"validate": {
|
|
107
|
+
"$comment": "CODE-CARRIED, not data: `(value) => boolean | string`, returning true or an error message.",
|
|
108
|
+
"description": "Declared here for completeness only — a JSON document cannot carry it.",
|
|
109
|
+
"type": "null"
|
|
110
|
+
},
|
|
111
|
+
"group": {
|
|
112
|
+
"description": "Group name for organizing options in `--help`. Ungrouped prompts appear under \"Options\".",
|
|
113
|
+
"type": "string"
|
|
114
|
+
},
|
|
115
|
+
"positional": {
|
|
116
|
+
"description": "Whether this prompt can be given as a positional argument. At most one per generator, and only a `text` prompt.",
|
|
117
|
+
"type": "boolean"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|