@canonical/summon-core 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/discovery/discoverGeneratorTree.js +14 -10
- package/dist/esm/discovery/discoverGeneratorTree.js.map +1 -1
- package/dist/esm/execute/collectAnswers.js +23 -17
- package/dist/esm/execute/collectAnswers.js.map +1 -1
- package/dist/esm/execute/execute.js +67 -22
- package/dist/esm/execute/execute.js.map +1 -1
- package/dist/esm/execute/index.js +1 -1
- package/dist/esm/execute/index.js.map +1 -1
- package/dist/esm/execute/validateAnswers.js +19 -5
- package/dist/esm/execute/validateAnswers.js.map +1 -1
- package/dist/esm/format/effects.js +199 -53
- package/dist/esm/format/effects.js.map +1 -1
- package/dist/esm/format/formatFlagName.js +17 -0
- package/dist/esm/format/formatFlagName.js.map +1 -0
- package/dist/esm/format/index.js +19 -1
- package/dist/esm/format/index.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/projection/answers.js +84 -0
- package/dist/esm/projection/answers.js.map +1 -0
- package/dist/esm/projection/buildOptionInfo.js +77 -0
- package/dist/esm/projection/buildOptionInfo.js.map +1 -0
- package/dist/esm/projection/commander/configureGroupedHelp.js +39 -0
- package/dist/esm/projection/commander/configureGroupedHelp.js.map +1 -0
- package/dist/esm/projection/commander/emitToProcess.js +15 -0
- package/dist/esm/projection/commander/emitToProcess.js.map +1 -0
- package/dist/esm/projection/commander/index.js +20 -0
- package/dist/esm/projection/commander/index.js.map +1 -0
- package/dist/esm/projection/commander/registerGeneratorCommands.js +222 -0
- package/dist/esm/projection/commander/registerGeneratorCommands.js.map +1 -0
- package/dist/esm/projection/decideInteraction.js +73 -0
- package/dist/esm/projection/decideInteraction.js.map +1 -0
- package/dist/esm/projection/extractAnswers.js +52 -0
- package/dist/esm/projection/extractAnswers.js.map +1 -0
- package/dist/esm/projection/groupedHelp.js +74 -0
- package/dist/esm/projection/groupedHelp.js.map +1 -0
- package/dist/esm/projection/index.js +26 -0
- package/dist/esm/projection/index.js.map +1 -0
- package/dist/esm/projection/kebab.js +18 -0
- package/dist/esm/projection/kebab.js.map +1 -0
- package/dist/esm/projection/projectGenerator.js +46 -0
- package/dist/esm/projection/projectGenerator.js.map +1 -0
- package/dist/esm/projection/types.js +16 -0
- package/dist/esm/projection/types.js.map +1 -0
- package/dist/esm/projection/usage.js +144 -0
- package/dist/esm/projection/usage.js.map +1 -0
- package/dist/esm/prompt/answerPromptWithDefaults.js +7 -5
- package/dist/esm/prompt/answerPromptWithDefaults.js.map +1 -1
- package/dist/esm/prompt/autoPrompt.js +2 -3
- package/dist/esm/prompt/autoPrompt.js.map +1 -1
- package/dist/esm/prompt/ink/mount.js +4 -2
- package/dist/esm/prompt/ink/mount.js.map +1 -1
- package/dist/esm/prompt/ink/session.js +78 -15
- package/dist/esm/prompt/ink/session.js.map +1 -1
- package/dist/esm/prompt/inkPrompt.js +13 -4
- package/dist/esm/prompt/inkPrompt.js.map +1 -1
- package/dist/esm/prompt/mcpPrompt.js +1 -1
- package/dist/esm/prompt/mcpPrompt.js.map +1 -1
- package/dist/esm/run/runGeneratorTask.js +3 -1
- package/dist/esm/run/runGeneratorTask.js.map +1 -1
- package/dist/esm/stamp/applyStamp.js +50 -52
- package/dist/esm/stamp/applyStamp.js.map +1 -1
- package/dist/esm/stamp/createStampOnEffectStart.js +4 -1
- package/dist/esm/stamp/createStampOnEffectStart.js.map +1 -1
- package/dist/esm/stamp/runTaskWithStamp.js +8 -9
- package/dist/esm/stamp/runTaskWithStamp.js.map +1 -1
- package/dist/esm/template/index.js +2 -0
- package/dist/esm/template/index.js.map +1 -1
- package/dist/esm/template/loadTemplate.js +43 -0
- package/dist/esm/template/loadTemplate.js.map +1 -0
- package/dist/esm/template/prependStamp.js +11 -8
- package/dist/esm/template/prependStamp.js.map +1 -1
- package/dist/esm/template/rawFile.js +25 -0
- package/dist/esm/template/rawFile.js.map +1 -0
- package/dist/esm/template/tasks/template.js +12 -3
- package/dist/esm/template/tasks/template.js.map +1 -1
- package/dist/esm/template/tasks/templateDir.js +5 -0
- package/dist/esm/template/tasks/templateDir.js.map +1 -1
- package/dist/esm/testing/conformance/diffTrees.js +61 -0
- package/dist/esm/testing/conformance/diffTrees.js.map +1 -0
- package/dist/esm/testing/conformance/fixtures.js +81 -0
- package/dist/esm/testing/conformance/fixtures.js.map +1 -0
- package/dist/esm/testing/conformance/flagizeAnswers.js +91 -0
- package/dist/esm/testing/conformance/flagizeAnswers.js.map +1 -0
- package/dist/esm/testing/conformance/index.js +18 -0
- package/dist/esm/testing/conformance/index.js.map +1 -0
- package/dist/esm/testing/conformance/produceReference.js +47 -0
- package/dist/esm/testing/conformance/produceReference.js.map +1 -0
- package/dist/esm/testing/conformance/snapshotTree.js +35 -0
- package/dist/esm/testing/conformance/snapshotTree.js.map +1 -0
- package/dist/esm/testing/index.js +10 -0
- package/dist/esm/testing/index.js.map +1 -0
- package/dist/types/discovery/discoverGeneratorTree.d.ts +3 -3
- package/dist/types/discovery/discoverGeneratorTree.d.ts.map +1 -1
- package/dist/types/execute/collectAnswers.d.ts +6 -4
- package/dist/types/execute/collectAnswers.d.ts.map +1 -1
- package/dist/types/execute/execute.d.ts +27 -1
- package/dist/types/execute/execute.d.ts.map +1 -1
- package/dist/types/execute/index.d.ts +1 -1
- package/dist/types/execute/index.d.ts.map +1 -1
- package/dist/types/execute/validateAnswers.d.ts.map +1 -1
- package/dist/types/format/effects.d.ts +63 -9
- package/dist/types/format/effects.d.ts.map +1 -1
- package/dist/types/format/formatFlagName.d.ts +14 -0
- package/dist/types/format/formatFlagName.d.ts.map +1 -0
- package/dist/types/format/index.d.ts +20 -1
- package/dist/types/format/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/projection/answers.d.ts +54 -0
- package/dist/types/projection/answers.d.ts.map +1 -0
- package/dist/types/projection/buildOptionInfo.d.ts +25 -0
- package/dist/types/projection/buildOptionInfo.d.ts.map +1 -0
- package/dist/types/projection/commander/configureGroupedHelp.d.ts +29 -0
- package/dist/types/projection/commander/configureGroupedHelp.d.ts.map +1 -0
- package/dist/types/projection/commander/emitToProcess.d.ts +10 -0
- package/dist/types/projection/commander/emitToProcess.d.ts.map +1 -0
- package/dist/types/projection/commander/index.d.ts +21 -0
- package/dist/types/projection/commander/index.d.ts.map +1 -0
- package/dist/types/projection/commander/registerGeneratorCommands.d.ts +95 -0
- package/dist/types/projection/commander/registerGeneratorCommands.d.ts.map +1 -0
- package/dist/types/projection/decideInteraction.d.ts +70 -0
- package/dist/types/projection/decideInteraction.d.ts.map +1 -0
- package/dist/types/projection/extractAnswers.d.ts +23 -0
- package/dist/types/projection/extractAnswers.d.ts.map +1 -0
- package/dist/types/projection/groupedHelp.d.ts +25 -0
- package/dist/types/projection/groupedHelp.d.ts.map +1 -0
- package/dist/types/projection/index.d.ts +29 -0
- package/dist/types/projection/index.d.ts.map +1 -0
- package/dist/types/projection/kebab.d.ts +16 -0
- package/dist/types/projection/kebab.d.ts.map +1 -0
- package/dist/types/projection/projectGenerator.d.ts +22 -0
- package/dist/types/projection/projectGenerator.d.ts.map +1 -0
- package/dist/types/projection/types.d.ts +118 -0
- package/dist/types/projection/types.d.ts.map +1 -0
- package/dist/types/projection/usage.d.ts +92 -0
- package/dist/types/projection/usage.d.ts.map +1 -0
- package/dist/types/prompt/answerPromptWithDefaults.d.ts +5 -3
- package/dist/types/prompt/answerPromptWithDefaults.d.ts.map +1 -1
- package/dist/types/prompt/autoPrompt.d.ts.map +1 -1
- package/dist/types/prompt/ink/mount.d.ts.map +1 -1
- package/dist/types/prompt/ink/session.d.ts +36 -1
- package/dist/types/prompt/ink/session.d.ts.map +1 -1
- package/dist/types/prompt/inkPrompt.d.ts +17 -3
- package/dist/types/prompt/inkPrompt.d.ts.map +1 -1
- package/dist/types/run/runGeneratorTask.d.ts +3 -1
- package/dist/types/run/runGeneratorTask.d.ts.map +1 -1
- package/dist/types/stamp/applyStamp.d.ts +6 -2
- package/dist/types/stamp/applyStamp.d.ts.map +1 -1
- package/dist/types/stamp/createStampOnEffectStart.d.ts.map +1 -1
- package/dist/types/stamp/runTaskWithStamp.d.ts +3 -1
- package/dist/types/stamp/runTaskWithStamp.d.ts.map +1 -1
- package/dist/types/template/index.d.ts +4 -0
- package/dist/types/template/index.d.ts.map +1 -1
- package/dist/types/template/loadTemplate.d.ts +40 -0
- package/dist/types/template/loadTemplate.d.ts.map +1 -0
- package/dist/types/template/prependStamp.d.ts +5 -2
- package/dist/types/template/prependStamp.d.ts.map +1 -1
- package/dist/types/template/rawFile.d.ts +32 -0
- package/dist/types/template/rawFile.d.ts.map +1 -0
- package/dist/types/template/tasks/template.d.ts +8 -0
- package/dist/types/template/tasks/template.d.ts.map +1 -1
- package/dist/types/template/tasks/templateDir.d.ts.map +1 -1
- package/dist/types/template/tasks/types.d.ts +2 -0
- package/dist/types/template/tasks/types.d.ts.map +1 -1
- package/dist/types/testing/conformance/diffTrees.d.ts +38 -0
- package/dist/types/testing/conformance/diffTrees.d.ts.map +1 -0
- package/dist/types/testing/conformance/fixtures.d.ts +39 -0
- package/dist/types/testing/conformance/fixtures.d.ts.map +1 -0
- package/dist/types/testing/conformance/flagizeAnswers.d.ts +38 -0
- package/dist/types/testing/conformance/flagizeAnswers.d.ts.map +1 -0
- package/dist/types/testing/conformance/index.d.ts +22 -0
- package/dist/types/testing/conformance/index.d.ts.map +1 -0
- package/dist/types/testing/conformance/produceReference.d.ts +35 -0
- package/dist/types/testing/conformance/produceReference.d.ts.map +1 -0
- package/dist/types/testing/conformance/snapshotTree.d.ts +21 -0
- package/dist/types/testing/conformance/snapshotTree.d.ts.map +1 -0
- package/dist/types/testing/index.d.ts +11 -0
- package/dist/types/testing/index.d.ts.map +1 -0
- package/dist/types/types/GeneratorDefinition.d.ts +10 -1
- package/dist/types/types/GeneratorDefinition.d.ts.map +1 -1
- package/dist/types/types/ReservedOption.d.ts +1 -1
- package/dist/types/types/ReservedOption.d.ts.map +1 -1
- package/package.json +27 -9
- package/spec/generator-definition.v1.schema.json +122 -0
|
@@ -22,18 +22,27 @@
|
|
|
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 = {}) {
|
|
31
31
|
let mountP;
|
|
32
32
|
let mounted;
|
|
33
33
|
const ensure = () => {
|
|
34
|
-
mountP ??= import("./ink/mount.js")
|
|
34
|
+
mountP ??= import("./ink/mount.js")
|
|
35
|
+
.then((mod) => {
|
|
35
36
|
mounted = mod.mountPromptSession(generator, options);
|
|
36
37
|
return mounted;
|
|
38
|
+
})
|
|
39
|
+
.catch((error) => {
|
|
40
|
+
// Do not cache a failure — a trailing catch, so BOTH a failed dynamic
|
|
41
|
+
// import and a throw from mountPromptSession itself (e.g. Ink render)
|
|
42
|
+
// reset the memo; otherwise every later prompt in the session would
|
|
43
|
+
// reuse the same stale rejection.
|
|
44
|
+
mountP = undefined;
|
|
45
|
+
throw error;
|
|
37
46
|
});
|
|
38
47
|
return mountP;
|
|
39
48
|
};
|
|
@@ -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;;;;;;;;;;;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;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -19,7 +19,7 @@ import { missingRequiredError } from "./autoPrompt.js";
|
|
|
19
19
|
export default function mcpPrompt(params = {}) {
|
|
20
20
|
return (effect) => {
|
|
21
21
|
const q = effect.question;
|
|
22
|
-
if (q.name
|
|
22
|
+
if (Object.hasOwn(params, q.name))
|
|
23
23
|
return Promise.resolve(params[q.name]);
|
|
24
24
|
if (q.default !== undefined)
|
|
25
25
|
return Promise.resolve(q.default);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpPrompt.js","sourceRoot":"","sources":["../../../src/prompt/mcpPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGvD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,SAA4C,EAAE;IAE9C,OAAO,CAAC,MAAoB,EAAE,EAAE;QAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC1B,IAAI,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"mcpPrompt.js","sourceRoot":"","sources":["../../../src/prompt/mcpPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGvD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,SAA4C,EAAE;IAE9C,OAAO,CAAC,MAAoB,EAAE,EAAE;QAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC1B,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1E,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC/D,OAAO,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAClE,CAAC,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"}
|
|
@@ -1,50 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
const COMMENT_STYLES = {
|
|
3
|
-
".ts": { single: "//" },
|
|
4
|
-
".tsx": { single: "//" },
|
|
5
|
-
".js": { single: "//" },
|
|
6
|
-
".jsx": { single: "//" },
|
|
7
|
-
".mjs": { single: "//" },
|
|
8
|
-
".cjs": { single: "//" },
|
|
9
|
-
".css": { blockStart: "/*", blockEnd: "*/", preferBlock: true },
|
|
10
|
-
".scss": { single: "//" },
|
|
11
|
-
".sass": { single: "//" },
|
|
12
|
-
".less": { single: "//" },
|
|
13
|
-
".html": { blockStart: "<!--", blockEnd: "-->" },
|
|
14
|
-
".htm": { blockStart: "<!--", blockEnd: "-->" },
|
|
15
|
-
".xml": { blockStart: "<!--", blockEnd: "-->" },
|
|
16
|
-
".svg": { blockStart: "<!--", blockEnd: "-->" },
|
|
17
|
-
".vue": { blockStart: "<!--", blockEnd: "-->" },
|
|
18
|
-
".svelte": { blockStart: "<!--", blockEnd: "-->" },
|
|
19
|
-
".yaml": { single: "#" },
|
|
20
|
-
".yml": { single: "#" },
|
|
21
|
-
".toml": { single: "#" },
|
|
22
|
-
".sh": { single: "#" },
|
|
23
|
-
".bash": { single: "#" },
|
|
24
|
-
".zsh": { single: "#" },
|
|
25
|
-
".py": { single: "#" },
|
|
26
|
-
".rb": { single: "#" },
|
|
27
|
-
".go": { single: "//" },
|
|
28
|
-
".rs": { single: "//" },
|
|
29
|
-
".java": { single: "//" },
|
|
30
|
-
".kt": { single: "//" },
|
|
31
|
-
".swift": { single: "//" },
|
|
32
|
-
".c": { single: "//" },
|
|
33
|
-
".cpp": { single: "//" },
|
|
34
|
-
".h": { single: "//" },
|
|
35
|
-
".php": { single: "//" },
|
|
36
|
-
".md": { blockStart: "<!--", blockEnd: "-->" },
|
|
37
|
-
".mdx": { blockStart: "{/*", blockEnd: "*/}" },
|
|
38
|
-
".sql": { single: "--" },
|
|
39
|
-
".json": {},
|
|
40
|
-
};
|
|
1
|
+
import getCommentStyle from "../template/getCommentStyle.js";
|
|
41
2
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
3
|
+
* The prologue a stamp must stay BELOW: a shebang, a PHP open tag, or an XML
|
|
4
|
+
* declaration must remain the file's first bytes or the file stops working
|
|
5
|
+
* (interpreter selection, PHP emitting the comment as page text, ill-formed
|
|
6
|
+
* XML). Returns the offset just past the prologue (including its newline when
|
|
7
|
+
* present), or null when the content has no prologue.
|
|
8
|
+
*/
|
|
9
|
+
function prologueEnd(content) {
|
|
10
|
+
if (content.startsWith("#!")) {
|
|
11
|
+
const newline = content.indexOf("\n");
|
|
12
|
+
return newline === -1 ? content.length : newline + 1;
|
|
13
|
+
}
|
|
14
|
+
if (content.startsWith("<?php")) {
|
|
15
|
+
// Protect the opening TOKEN, not the whole first line: a one-line
|
|
16
|
+
// template (`<?php echo 'hi'; ?>`) must get the stamp right after the
|
|
17
|
+
// tag — advancing to the newline would land it after `?>`, as page text.
|
|
18
|
+
const afterTag = "<?php".length;
|
|
19
|
+
return content.charAt(afterTag) === "\n" ? afterTag + 1 : afterTag;
|
|
20
|
+
}
|
|
21
|
+
if (content.startsWith("<?xml")) {
|
|
22
|
+
const close = content.indexOf("?>");
|
|
23
|
+
if (close !== -1) {
|
|
24
|
+
const after = close + 2;
|
|
25
|
+
return content.charAt(after) === "\n" ? after + 1 : after;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Apply a stamp to file content based on file extension. Uses the same
|
|
32
|
+
* comment-style table as {@link getCommentStyle} — one source, no drift.
|
|
33
|
+
* Returns the original content when the file type doesn't support comments,
|
|
34
|
+
* and is IDEMPOTENT: content already carrying this exact stamp line is
|
|
35
|
+
* returned unchanged, so driving the same WriteFile effect twice (preview
|
|
36
|
+
* then run, or a re-drive) cannot stack stamps.
|
|
44
37
|
*/
|
|
45
38
|
export default function applyStamp(filePath, content, stamp) {
|
|
46
|
-
const
|
|
47
|
-
const style = COMMENT_STYLES[ext];
|
|
39
|
+
const style = getCommentStyle(filePath);
|
|
48
40
|
if (!style) {
|
|
49
41
|
return content;
|
|
50
42
|
}
|
|
@@ -59,14 +51,20 @@ export default function applyStamp(filePath, content, stamp) {
|
|
|
59
51
|
else {
|
|
60
52
|
return content;
|
|
61
53
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
if (content.includes(stampLine)) {
|
|
55
|
+
return content;
|
|
56
|
+
}
|
|
57
|
+
// A short-echo opener (`<?=`) takes an expression, not statements — there
|
|
58
|
+
// is no safe line to claim, so leave the file unstamped.
|
|
59
|
+
if (content.startsWith("<?=")) {
|
|
60
|
+
return content;
|
|
61
|
+
}
|
|
62
|
+
const at = prologueEnd(content);
|
|
63
|
+
if (at !== null) {
|
|
64
|
+
const head = content.slice(0, at);
|
|
65
|
+
const rest = content.slice(at);
|
|
66
|
+
const separator = head.endsWith("\n") ? "" : "\n";
|
|
67
|
+
return `${head}${separator}${stampLine}\n\n${rest}`;
|
|
70
68
|
}
|
|
71
69
|
return `${stampLine}\n\n${content}`;
|
|
72
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyStamp.js","sourceRoot":"","sources":["../../../src/stamp/applyStamp.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"applyStamp.js","sourceRoot":"","sources":["../../../src/stamp/applyStamp.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,gCAAgC,CAAC;AAG7D;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,OAAe;IAClC,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;IACvD,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,kEAAkE;QAClE,sEAAsE;QACtE,yEAAyE;QACzE,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;QAChC,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACrE,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;YACxB,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CA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C,EAAE,CAAC,CAAC;QAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAClD,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,OAAO,IAAI,EAAE,CAAC;IACtD,CAAC;IAED,OAAO,GAAG,SAAS,OAAO,OAAO,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -14,7 +14,10 @@ import applyStamp from "./applyStamp.js";
|
|
|
14
14
|
*/
|
|
15
15
|
export default function createStampOnEffectStart(stamp, next) {
|
|
16
16
|
return (effect) => {
|
|
17
|
-
|
|
17
|
+
// A verbatim write is a CARRIED COPY (see `rawFile`): its bytes must land
|
|
18
|
+
// exactly as loaded, so the stamp skips it — a stamped copy would differ
|
|
19
|
+
// from the CopyFile it replaced and corrupt carried artifacts.
|
|
20
|
+
if (effect._tag === "WriteFile" && effect.verbatim !== true) {
|
|
18
21
|
effect.content = applyStamp(effect.path, effect.content, stamp);
|
|
19
22
|
}
|
|
20
23
|
next?.(effect);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createStampOnEffectStart.js","sourceRoot":"","sources":["../../../src/stamp/createStampOnEffectStart.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,KAAkB,EAClB,IAA+B;IAE/B,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"createStampOnEffectStart.js","sourceRoot":"","sources":["../../../src/stamp/createStampOnEffectStart.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,KAAkB,EAClB,IAA+B;IAE/B,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,0EAA0E;QAC1E,yEAAyE;QACzE,+DAA+D;QAC/D,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3D,MAA8B,CAAC,OAAO,GAAG,UAAU,CAClD,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,OAAO,EACd,KAAK,CACN,CAAC;QACJ,CAAC;QACD,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { runTask } from "@canonical/task/node";
|
|
2
|
-
import
|
|
2
|
+
import createStampOnEffectStart from "./createStampOnEffectStart.js";
|
|
3
3
|
/**
|
|
4
4
|
* Run a task with stamp support. Wraps `runTask` from @canonical/task,
|
|
5
|
-
*
|
|
5
|
+
* routing every WriteFile through THE stamping transform
|
|
6
|
+
* ({@link createStampOnEffectStart}) — one transform for both stamping seams,
|
|
7
|
+
* so the verbatim (carried-copy) skip can never diverge between them.
|
|
6
8
|
*/
|
|
7
9
|
export default async function runTaskWithStamp(task, options = {}) {
|
|
8
10
|
const { stamp, onEffectStart: userOnEffectStart, ...restOptions } = options;
|
|
9
11
|
if (!stamp) {
|
|
10
12
|
return runTask(task, options);
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
userOnEffectStart?.(effect);
|
|
17
|
-
};
|
|
18
|
-
return runTask(task, { ...restOptions, onEffectStart });
|
|
14
|
+
return runTask(task, {
|
|
15
|
+
...restOptions,
|
|
16
|
+
onEffectStart: createStampOnEffectStart(stamp, userOnEffectStart),
|
|
17
|
+
});
|
|
19
18
|
}
|
|
20
19
|
//# sourceMappingURL=runTaskWithStamp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runTaskWithStamp.js","sourceRoot":"","sources":["../../../src/stamp/runTaskWithStamp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"runTaskWithStamp.js","sourceRoot":"","sources":["../../../src/stamp/runTaskWithStamp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,wBAAwB,MAAM,+BAA+B,CAAC;AAGrE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAC5C,IAAa,EACb,UAAmC,EAAE;IAErC,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC;IAE5E,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,EAAE;QACnB,GAAG,WAAW;QACd,aAAa,EAAE,wBAAwB,CAAC,KAAK,EAAE,iBAAiB,CAAC;KAClE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -2,7 +2,9 @@ export { default as ejsEngine } from "./ejsEngine.js";
|
|
|
2
2
|
export { default as generateStamp } from "./generateStamp.js";
|
|
3
3
|
export { default as generatorComment } from "./generatorComment.js";
|
|
4
4
|
export { default as getCommentStyle } from "./getCommentStyle.js";
|
|
5
|
+
export { loadTemplate, loadTemplateSync } from "./loadTemplate.js";
|
|
5
6
|
export { default as prependStamp } from "./prependStamp.js";
|
|
7
|
+
export { default as rawFile } from "./rawFile.js";
|
|
6
8
|
export { default as renderFile } from "./renderFile.js";
|
|
7
9
|
export { default as renderString } from "./renderString.js";
|
|
8
10
|
export { default as renderStringAsync } from "./renderStringAsync.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/template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Template loading: read a generator's template file from its own package.
|
|
3
|
+
*
|
|
4
|
+
* A generator's templates ship beside it — `copy-templates.ts` puts each
|
|
5
|
+
* package's `templates/` tree into its `dist/esm`, and the generator resolves
|
|
6
|
+
* them `__dirname`-relative. So a load is a file read, and a miss is a hard
|
|
7
|
+
* error naming the path: callers do not guard against empty content, and a
|
|
8
|
+
* silent `""` would write blank files.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately SYNCHRONOUS, so a generator can load its templates lazily inside
|
|
11
|
+
* its synchronous `generate(answers)` call rather than at module eval. That is
|
|
12
|
+
* what keeps READ commands template-free: `--help` and completion never touch a
|
|
13
|
+
* template because they never reach a `generate`.
|
|
14
|
+
*/
|
|
15
|
+
import { readFileSync } from "node:fs";
|
|
16
|
+
/**
|
|
17
|
+
* Read a template from disk.
|
|
18
|
+
*
|
|
19
|
+
* @param source - Absolute path to the template file.
|
|
20
|
+
* @returns The loaded template.
|
|
21
|
+
* @throws If the file cannot be read, naming the path.
|
|
22
|
+
* @note Impure — reads the filesystem.
|
|
23
|
+
*/
|
|
24
|
+
export function loadTemplateSync(source) {
|
|
25
|
+
try {
|
|
26
|
+
return { source, content: readFileSync(source, "utf-8") };
|
|
27
|
+
}
|
|
28
|
+
catch (cause) {
|
|
29
|
+
throw new Error(`Template not found: ${source}`, { cause });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Async wrapper over {@link loadTemplateSync}, for callers that await a load.
|
|
34
|
+
* The body is fully synchronous.
|
|
35
|
+
*
|
|
36
|
+
* @param source - Absolute path to the template file.
|
|
37
|
+
* @returns The loaded template.
|
|
38
|
+
* @note Impure — reads the filesystem.
|
|
39
|
+
*/
|
|
40
|
+
export async function loadTemplate(source) {
|
|
41
|
+
return loadTemplateSync(source);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=loadTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadTemplate.js","sourceRoot":"","sources":["../../../src/template/loadTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAUvC;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,IAAI,CAAC;QACH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAC5D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAc;IAC/C,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Prepend a stamp to file content
|
|
3
|
-
*
|
|
2
|
+
* Prepend a stamp comment to file content: the stamp, a blank line, then the
|
|
3
|
+
* content — the same byte shape {@link applyStamp} (the canonical runtime
|
|
4
|
+
* stamping path) produces, so output does not depend on which helper a
|
|
5
|
+
* caller reached for. Handles shebang lines (#!/...) by placing the stamp
|
|
6
|
+
* after them, even when the shebang has no trailing newline yet.
|
|
4
7
|
*/
|
|
5
8
|
export default function prependStamp(content, stamp) {
|
|
6
9
|
if (content.startsWith("#!")) {
|
|
7
10
|
const firstNewline = content.indexOf("\n");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
11
|
+
const end = firstNewline === -1 ? content.length : firstNewline + 1;
|
|
12
|
+
const shebang = content.slice(0, end);
|
|
13
|
+
const rest = content.slice(end);
|
|
14
|
+
const separator = shebang.endsWith("\n") ? "" : "\n";
|
|
15
|
+
return `${shebang}${separator}${stamp}\n\n${rest}`;
|
|
13
16
|
}
|
|
14
|
-
return `${stamp}\n${content}`;
|
|
17
|
+
return `${stamp}\n\n${content}`;
|
|
15
18
|
}
|
|
16
19
|
//# sourceMappingURL=prependStamp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prependStamp.js","sourceRoot":"","sources":["../../../src/template/prependStamp.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prependStamp.js","sourceRoot":"","sources":["../../../src/template/prependStamp.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,OAAe,EAAE,KAAa;IACjE,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC;QACpE,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACrD,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,OAAO,IAAI,EAAE,CAAC;IACrD,CAAC;IAED,OAAO,GAAG,KAAK,OAAO,OAAO,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The copy-analog that CARRIES its content: rather than `copyFile(src, dest)`,
|
|
3
|
+
* a generator loads the bytes and writes them VERBATIM. The `verbatim` marker
|
|
4
|
+
* keeps the stamping transform off them
|
|
5
|
+
* ({@link import("../stamp/createStampOnEffectStart.js").default} skips it), so
|
|
6
|
+
* a carried `.ts`/`.css` asset lands byte-identical — including relay
|
|
7
|
+
* `__generated__` artifacts a stamp would corrupt.
|
|
8
|
+
*
|
|
9
|
+
* Carrying rather than copying also keeps the write on ONE effect seam, so a
|
|
10
|
+
* `--dry-run` describes it and `--undo` reverses it like every other write.
|
|
11
|
+
*
|
|
12
|
+
* The node interpreter creates the dest's parent directories, exactly as it
|
|
13
|
+
* does for any write.
|
|
14
|
+
*/
|
|
15
|
+
import { writeFile } from "@canonical/task";
|
|
16
|
+
/**
|
|
17
|
+
* Write a carried file verbatim (never stamped).
|
|
18
|
+
*
|
|
19
|
+
* @param options - Source id, content, and destination.
|
|
20
|
+
* @returns The write task.
|
|
21
|
+
*/
|
|
22
|
+
export default function rawFile(options) {
|
|
23
|
+
return writeFile(options.dest, options.content, { verbatim: true });
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=rawFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rawFile.js","sourceRoot":"","sources":["../../../src/template/rawFile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAa,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAYvD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAuB;IACrD,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -8,6 +8,14 @@ import renderString from "../renderString.js";
|
|
|
8
8
|
* When `options.content` is provided, uses it directly instead of
|
|
9
9
|
* reading from `options.source`. This supports compiled binaries
|
|
10
10
|
* where template files are embedded and pre-loaded.
|
|
11
|
+
*
|
|
12
|
+
* The silent `readFile(options.source)` fallback survives ONLY outside
|
|
13
|
+
* embedded context: once a host has injected an embedded manifest
|
|
14
|
+
* ({@link hasEmbeddedTemplates}), a content-less call FAILS with a named
|
|
15
|
+
* error instead of falling through to a disk read that would die with a raw
|
|
16
|
+
* `ENOENT … /$bunfs/…` mid-generation, after directories were already made.
|
|
17
|
+
* Source runs (empty manifest — the summon bin, tests) are byte-identical to
|
|
18
|
+
* before.
|
|
11
19
|
*/
|
|
12
20
|
export default function template(options) {
|
|
13
21
|
const engine = options.engine ?? ejsEngine;
|
|
@@ -18,11 +26,12 @@ export default function template(options) {
|
|
|
18
26
|
// template ("") must still use the provided content rather than falling
|
|
19
27
|
// back to reading from disk (which fails in compiled-binary mode).
|
|
20
28
|
const readSource = options.content !== undefined
|
|
21
|
-
? task(pure(options.content))
|
|
22
|
-
: task(readFile(options.source));
|
|
29
|
+
? task(pure(options.content)).unwrap()
|
|
30
|
+
: task(readFile(options.source)).unwrap();
|
|
23
31
|
return task(mkdir(destDir))
|
|
24
|
-
.chain(() => readSource)
|
|
32
|
+
.chain(() => task(readSource))
|
|
25
33
|
.map((content) => renderString(content, options.vars, engine))
|
|
34
|
+
.map((rendered) => options.transform?.(rendered) ?? rendered)
|
|
26
35
|
.chain((rendered) => task(writeFile(destPath, rendered)))
|
|
27
36
|
.unwrap();
|
|
28
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../src/template/tasks/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EAER,IAAI,EACJ,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAG9C
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../src/template/tasks/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,KAAK,EAC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,EAAE,CAAC;AACd,CAAC"}
|
|
@@ -37,11 +37,16 @@ export default function templateDir(options) {
|
|
|
37
37
|
}
|
|
38
38
|
destFile = renderString(destFile, options.vars, engine);
|
|
39
39
|
const destPath = path.join(options.dest, destFile);
|
|
40
|
+
// Resolve the declared content transformer for this file: an exact
|
|
41
|
+
// (post-`.ejs`-strip) basename entry wins over an extension entry.
|
|
42
|
+
const transform = options.transform?.[path.basename(destFile)] ??
|
|
43
|
+
options.transform?.[path.extname(destFile)];
|
|
40
44
|
return template({
|
|
41
45
|
source: sourcePath,
|
|
42
46
|
dest: destPath,
|
|
43
47
|
vars: options.vars,
|
|
44
48
|
engine,
|
|
49
|
+
transform,
|
|
45
50
|
});
|
|
46
51
|
});
|
|
47
52
|
return task(sequence_(tasks));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateDir.js","sourceRoot":"","sources":["../../../../src/template/tasks/templateDir.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAa,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,QAAQ,MAAM,eAAe,CAAC;AAGrC;;GAEG;AACH,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAW,EAAE;IAC/D,MAAM,KAAK,GAAG,OAAO;SAClB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC;SAChC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC;SACvB,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;IAElC,OAAO,IAAI,MAAM,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF;;GAEG;AACH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C,IAAI,EAAE,EAAE;YACZ,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAEnD,IAAI,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAE1C,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC;YAC3C,IAAI,OAAO,EAAE,CAAC;gBACZ,QAAQ,GAAG,OAAO,CAAC;YACrB,CAAC;YAED,QAAQ,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAEnD,mEAAmE;YACnE,mEAAmE;YACnE,MAAM,SAAS,GACb,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAC5C,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;YAE9C,OAAO,QAAQ,CAAC;gBACd,MAAM,EAAE,UAAU;gBAClB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM;gBACN,SAAS;aACV,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEL,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAChC,CAAC,CAAC;SACD,MAAM,EAAE,CAAC;AACd,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,81 @@
|
|
|
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
|
+
forms: true,
|
|
62
|
+
relay: false,
|
|
63
|
+
runInstall: false,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
/**
|
|
68
|
+
* Look up a fixture by name.
|
|
69
|
+
*
|
|
70
|
+
* @param name - The fixture's {@link ConformanceFixture.name}.
|
|
71
|
+
* @returns The fixture.
|
|
72
|
+
* @throws If no fixture carries that name — a typo must fail loudly rather
|
|
73
|
+
* than silently skip a conformance case.
|
|
74
|
+
*/
|
|
75
|
+
export function fixture(name) {
|
|
76
|
+
const found = CONFORMANCE_FIXTURES.find((entry) => entry.name === name);
|
|
77
|
+
if (!found)
|
|
78
|
+
throw new Error(`no conformance fixture named "${name}"`);
|
|
79
|
+
return found;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=fixtures.js.map
|