@canonical/summon-core 0.34.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.
Files changed (167) hide show
  1. package/dist/esm/discovery/discoverGeneratorTree.js +14 -10
  2. package/dist/esm/discovery/discoverGeneratorTree.js.map +1 -1
  3. package/dist/esm/execute/collectAnswers.js +21 -16
  4. package/dist/esm/execute/collectAnswers.js.map +1 -1
  5. package/dist/esm/execute/execute.js +67 -22
  6. package/dist/esm/execute/execute.js.map +1 -1
  7. package/dist/esm/execute/index.js +1 -1
  8. package/dist/esm/execute/index.js.map +1 -1
  9. package/dist/esm/execute/validateAnswers.js +19 -5
  10. package/dist/esm/execute/validateAnswers.js.map +1 -1
  11. package/dist/esm/format/effects.js +197 -51
  12. package/dist/esm/format/effects.js.map +1 -1
  13. package/dist/esm/format/formatFlagName.js +17 -0
  14. package/dist/esm/format/formatFlagName.js.map +1 -0
  15. package/dist/esm/format/index.js +19 -1
  16. package/dist/esm/format/index.js.map +1 -1
  17. package/dist/esm/index.js +3 -3
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/projection/answers.js +84 -0
  20. package/dist/esm/projection/answers.js.map +1 -0
  21. package/dist/esm/projection/buildOptionInfo.js +77 -0
  22. package/dist/esm/projection/buildOptionInfo.js.map +1 -0
  23. package/dist/esm/projection/commander/configureGroupedHelp.js +39 -0
  24. package/dist/esm/projection/commander/configureGroupedHelp.js.map +1 -0
  25. package/dist/esm/projection/commander/emitToProcess.js +15 -0
  26. package/dist/esm/projection/commander/emitToProcess.js.map +1 -0
  27. package/dist/esm/projection/commander/index.js +20 -0
  28. package/dist/esm/projection/commander/index.js.map +1 -0
  29. package/dist/esm/projection/commander/registerGeneratorCommands.js +222 -0
  30. package/dist/esm/projection/commander/registerGeneratorCommands.js.map +1 -0
  31. package/dist/esm/projection/decideInteraction.js +73 -0
  32. package/dist/esm/projection/decideInteraction.js.map +1 -0
  33. package/dist/esm/projection/extractAnswers.js +52 -0
  34. package/dist/esm/projection/extractAnswers.js.map +1 -0
  35. package/dist/esm/projection/groupedHelp.js +74 -0
  36. package/dist/esm/projection/groupedHelp.js.map +1 -0
  37. package/dist/esm/projection/index.js +26 -0
  38. package/dist/esm/projection/index.js.map +1 -0
  39. package/dist/esm/projection/kebab.js +18 -0
  40. package/dist/esm/projection/kebab.js.map +1 -0
  41. package/dist/esm/projection/projectGenerator.js +46 -0
  42. package/dist/esm/projection/projectGenerator.js.map +1 -0
  43. package/dist/esm/projection/types.js +16 -0
  44. package/dist/esm/projection/types.js.map +1 -0
  45. package/dist/esm/projection/usage.js +144 -0
  46. package/dist/esm/projection/usage.js.map +1 -0
  47. package/dist/esm/prompt/answerPromptWithDefaults.js +7 -5
  48. package/dist/esm/prompt/answerPromptWithDefaults.js.map +1 -1
  49. package/dist/esm/prompt/autoPrompt.js +2 -3
  50. package/dist/esm/prompt/autoPrompt.js.map +1 -1
  51. package/dist/esm/prompt/ink/mount.js +1 -1
  52. package/dist/esm/prompt/ink/mount.js.map +1 -1
  53. package/dist/esm/prompt/ink/session.js +21 -6
  54. package/dist/esm/prompt/ink/session.js.map +1 -1
  55. package/dist/esm/prompt/inkPrompt.js +10 -1
  56. package/dist/esm/prompt/inkPrompt.js.map +1 -1
  57. package/dist/esm/prompt/mcpPrompt.js +1 -1
  58. package/dist/esm/prompt/mcpPrompt.js.map +1 -1
  59. package/dist/esm/stamp/applyStamp.js +50 -52
  60. package/dist/esm/stamp/applyStamp.js.map +1 -1
  61. package/dist/esm/stamp/createStampOnEffectStart.js +4 -1
  62. package/dist/esm/stamp/createStampOnEffectStart.js.map +1 -1
  63. package/dist/esm/stamp/runTaskWithStamp.js +8 -9
  64. package/dist/esm/stamp/runTaskWithStamp.js.map +1 -1
  65. package/dist/esm/template/index.js +2 -0
  66. package/dist/esm/template/index.js.map +1 -1
  67. package/dist/esm/template/loadTemplate.js +43 -0
  68. package/dist/esm/template/loadTemplate.js.map +1 -0
  69. package/dist/esm/template/prependStamp.js +11 -8
  70. package/dist/esm/template/prependStamp.js.map +1 -1
  71. package/dist/esm/template/rawFile.js +25 -0
  72. package/dist/esm/template/rawFile.js.map +1 -0
  73. package/dist/esm/template/tasks/template.js +12 -3
  74. package/dist/esm/template/tasks/template.js.map +1 -1
  75. package/dist/esm/template/tasks/templateDir.js +5 -0
  76. package/dist/esm/template/tasks/templateDir.js.map +1 -1
  77. package/dist/esm/testing/conformance/fixtures.js +0 -2
  78. package/dist/esm/testing/conformance/fixtures.js.map +1 -1
  79. package/dist/esm/testing/conformance/flagizeAnswers.js +91 -0
  80. package/dist/esm/testing/conformance/flagizeAnswers.js.map +1 -0
  81. package/dist/esm/testing/conformance/index.js +1 -0
  82. package/dist/esm/testing/conformance/index.js.map +1 -1
  83. package/dist/esm/testing/index.js +1 -1
  84. package/dist/esm/testing/index.js.map +1 -1
  85. package/dist/types/discovery/discoverGeneratorTree.d.ts +3 -3
  86. package/dist/types/discovery/discoverGeneratorTree.d.ts.map +1 -1
  87. package/dist/types/execute/collectAnswers.d.ts +4 -3
  88. package/dist/types/execute/collectAnswers.d.ts.map +1 -1
  89. package/dist/types/execute/execute.d.ts +27 -1
  90. package/dist/types/execute/execute.d.ts.map +1 -1
  91. package/dist/types/execute/index.d.ts +1 -1
  92. package/dist/types/execute/index.d.ts.map +1 -1
  93. package/dist/types/execute/validateAnswers.d.ts.map +1 -1
  94. package/dist/types/format/effects.d.ts +61 -7
  95. package/dist/types/format/effects.d.ts.map +1 -1
  96. package/dist/types/format/formatFlagName.d.ts +14 -0
  97. package/dist/types/format/formatFlagName.d.ts.map +1 -0
  98. package/dist/types/format/index.d.ts +20 -1
  99. package/dist/types/format/index.d.ts.map +1 -1
  100. package/dist/types/index.d.ts +4 -4
  101. package/dist/types/index.d.ts.map +1 -1
  102. package/dist/types/projection/answers.d.ts +54 -0
  103. package/dist/types/projection/answers.d.ts.map +1 -0
  104. package/dist/types/projection/buildOptionInfo.d.ts +25 -0
  105. package/dist/types/projection/buildOptionInfo.d.ts.map +1 -0
  106. package/dist/types/projection/commander/configureGroupedHelp.d.ts +29 -0
  107. package/dist/types/projection/commander/configureGroupedHelp.d.ts.map +1 -0
  108. package/dist/types/projection/commander/emitToProcess.d.ts +10 -0
  109. package/dist/types/projection/commander/emitToProcess.d.ts.map +1 -0
  110. package/dist/types/projection/commander/index.d.ts +21 -0
  111. package/dist/types/projection/commander/index.d.ts.map +1 -0
  112. package/dist/types/projection/commander/registerGeneratorCommands.d.ts +95 -0
  113. package/dist/types/projection/commander/registerGeneratorCommands.d.ts.map +1 -0
  114. package/dist/types/projection/decideInteraction.d.ts +70 -0
  115. package/dist/types/projection/decideInteraction.d.ts.map +1 -0
  116. package/dist/types/projection/extractAnswers.d.ts +23 -0
  117. package/dist/types/projection/extractAnswers.d.ts.map +1 -0
  118. package/dist/types/projection/groupedHelp.d.ts +25 -0
  119. package/dist/types/projection/groupedHelp.d.ts.map +1 -0
  120. package/dist/types/projection/index.d.ts +29 -0
  121. package/dist/types/projection/index.d.ts.map +1 -0
  122. package/dist/types/projection/kebab.d.ts +16 -0
  123. package/dist/types/projection/kebab.d.ts.map +1 -0
  124. package/dist/types/projection/projectGenerator.d.ts +22 -0
  125. package/dist/types/projection/projectGenerator.d.ts.map +1 -0
  126. package/dist/types/projection/types.d.ts +118 -0
  127. package/dist/types/projection/types.d.ts.map +1 -0
  128. package/dist/types/projection/usage.d.ts +92 -0
  129. package/dist/types/projection/usage.d.ts.map +1 -0
  130. package/dist/types/prompt/answerPromptWithDefaults.d.ts +5 -3
  131. package/dist/types/prompt/answerPromptWithDefaults.d.ts.map +1 -1
  132. package/dist/types/prompt/autoPrompt.d.ts.map +1 -1
  133. package/dist/types/prompt/ink/mount.d.ts.map +1 -1
  134. package/dist/types/prompt/ink/session.d.ts +1 -1
  135. package/dist/types/prompt/ink/session.d.ts.map +1 -1
  136. package/dist/types/prompt/inkPrompt.d.ts +7 -0
  137. package/dist/types/prompt/inkPrompt.d.ts.map +1 -1
  138. package/dist/types/stamp/applyStamp.d.ts +6 -2
  139. package/dist/types/stamp/applyStamp.d.ts.map +1 -1
  140. package/dist/types/stamp/createStampOnEffectStart.d.ts.map +1 -1
  141. package/dist/types/stamp/runTaskWithStamp.d.ts +3 -1
  142. package/dist/types/stamp/runTaskWithStamp.d.ts.map +1 -1
  143. package/dist/types/template/index.d.ts +4 -0
  144. package/dist/types/template/index.d.ts.map +1 -1
  145. package/dist/types/template/loadTemplate.d.ts +40 -0
  146. package/dist/types/template/loadTemplate.d.ts.map +1 -0
  147. package/dist/types/template/prependStamp.d.ts +5 -2
  148. package/dist/types/template/prependStamp.d.ts.map +1 -1
  149. package/dist/types/template/rawFile.d.ts +32 -0
  150. package/dist/types/template/rawFile.d.ts.map +1 -0
  151. package/dist/types/template/tasks/template.d.ts +8 -0
  152. package/dist/types/template/tasks/template.d.ts.map +1 -1
  153. package/dist/types/template/tasks/templateDir.d.ts.map +1 -1
  154. package/dist/types/template/tasks/types.d.ts +2 -0
  155. package/dist/types/template/tasks/types.d.ts.map +1 -1
  156. package/dist/types/testing/conformance/fixtures.d.ts.map +1 -1
  157. package/dist/types/testing/conformance/flagizeAnswers.d.ts +38 -0
  158. package/dist/types/testing/conformance/flagizeAnswers.d.ts.map +1 -0
  159. package/dist/types/testing/conformance/index.d.ts +1 -0
  160. package/dist/types/testing/conformance/index.d.ts.map +1 -1
  161. package/dist/types/testing/index.d.ts +1 -1
  162. package/dist/types/testing/index.d.ts.map +1 -1
  163. package/dist/types/types/GeneratorDefinition.d.ts +10 -1
  164. package/dist/types/types/GeneratorDefinition.d.ts.map +1 -1
  165. package/dist/types/types/ReservedOption.d.ts +1 -1
  166. package/dist/types/types/ReservedOption.d.ts.map +1 -1
  167. package/package.json +21 -8
@@ -1,50 +1,42 @@
1
- import * as path from "node:path";
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
- * Apply a stamp to file content based on file extension.
43
- * Returns the original content if the file type doesn't support comments.
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 ext = path.extname(filePath).toLowerCase();
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
- // Handle shebang - place stamp after it
63
- if (content.startsWith("#!")) {
64
- const firstNewline = content.indexOf("\n");
65
- if (firstNewline !== -1) {
66
- const shebang = content.slice(0, firstNewline + 1);
67
- const rest = content.slice(firstNewline + 1);
68
- return `${shebang}${stampLine}\n\n${rest}`;
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${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CAAC;IAEtB,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACvC,SAAS,GAAG,GAAG,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;IAC7C,CAAC;SAAM,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC9C,SAAS,GAAG,GAAG,KAAK,CAAC,UAAU,IAAI,SAAS,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;IACnE,CAAC;SAAM,CAAC;QACN,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,0EAA0E;IAC1E,yDAAyD;IACzD,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,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
- if (effect._tag === "WriteFile") {
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;YAC/B,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
+ {"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 applyStamp from "./applyStamp.js";
2
+ import createStampOnEffectStart from "./createStampOnEffectStart.js";
3
3
  /**
4
4
  * Run a task with stamp support. Wraps `runTask` from @canonical/task,
5
- * intercepting WriteFile effects to prepend generated-file stamps.
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
- const onEffectStart = (effect) => {
13
- if (effect._tag === "WriteFile") {
14
- effect.content = applyStamp(effect.path, effect.content, stamp);
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,UAAU,MAAM,iBAAiB,CAAC;AAGzC;;;GAGG;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,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,EAAE;QACvC,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAC/B,MAA8B,CAAC,OAAO,GAAG,UAAU,CAClD,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,OAAO,EACd,KAAK,CACN,CAAC;QACJ,CAAC;QACD,iBAAiB,EAAE,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,OAAO,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,WAAW,EAAE,aAAa,EAAE,CAAC,CAAC;AAC1D,CAAC"}
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/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGtE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/template/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGtE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * 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
- * Handles shebang lines (#!/...) by placing stamp after them.
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
- if (firstNewline !== -1) {
9
- const shebang = content.slice(0, firstNewline + 1);
10
- const rest = content.slice(firstNewline + 1);
11
- return `${shebang}${stamp}\n${rest}`;
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;;;GAGG;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,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;YACxB,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;YACnD,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;YAC7C,OAAO,GAAG,OAAO,GAAG,KAAK,KAAK,IAAI,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,GAAG,KAAK,KAAK,OAAO,EAAE,CAAC;AAChC,CAAC"}
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,CA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CAAC;SACxD,MAAM,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,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,OAA2B;IAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC;IA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QACd,CAAC,CAAC;aACD,GAAG,CAAC,CAAC,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"}
@@ -58,8 +58,6 @@ export const CONFORMANCE_FIXTURES = [
58
58
  generator: "application",
59
59
  answers: {
60
60
  appPath: "my-app",
61
- ssr: true,
62
- router: true,
63
61
  forms: true,
64
62
  relay: false,
65
63
  runInstall: false,
@@ -1 +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"}
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,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,91 @@
1
+ /**
2
+ * Turn a conformance fixture's ANSWER SET into the CLI argument vector that
3
+ * expresses it — the projection's flag grammar, driven backwards. The
4
+ * cross-CLI matrix derives each producer's argv from the SAME answers with
5
+ * this one function, so the two binaries are always handed identical inputs
6
+ * (modulo the mount prefix) and an argv hand-drift cannot fake parity.
7
+ *
8
+ * Rules (the inverse of `extractAnswers` + `buildOptionInfo`):
9
+ * - an answer equal to its prompt's default is OMITTED (it could never be
10
+ * expressed explicitly for a confirm anyway — the equality trick);
11
+ * - a confirm answers with `buildOptionInfo`'s PRIMARY registered long
12
+ * form — `--<kebab>` for `true` (registered exactly when the default is
13
+ * not `true`; a default-`true` confirm answered `true` was omitted
14
+ * above), `--no-<kebab>` for `false` (registered ONLY for a default-
15
+ * `true` confirm). PRECONDITION: a confirm answered `false` must
16
+ * declare `default: true` — a default-less (or default-`false`,
17
+ * non-omitted) confirm has NO registered spelling for `false`, and this
18
+ * helper THROWS naming the prompt rather than hand the matrix an argv
19
+ * both binaries reject as an unknown option;
20
+ * - the positional prompt's answer is emitted positionally, first;
21
+ * - text/select answers become `--<kebab>=<value>`;
22
+ * - a multiselect becomes `--<kebab>=<comma,list>`.
23
+ */
24
+ import buildOptionInfo from "../../projection/buildOptionInfo.js";
25
+ import toKebabCase from "../../projection/kebab.js";
26
+ /** Whether an answer equals the prompt's declared default. */
27
+ function sameAsDefault(value, defaultValue) {
28
+ if (Object.is(value, defaultValue))
29
+ return true;
30
+ if (Array.isArray(value) && Array.isArray(defaultValue)) {
31
+ return (value.length === defaultValue.length &&
32
+ value.every((item, index) => Object.is(item, defaultValue[index])));
33
+ }
34
+ return false;
35
+ }
36
+ /**
37
+ * Express an answer set as CLI arguments (positional first, flags in prompt
38
+ * order).
39
+ *
40
+ * @param prompts - The command's prompts (live or projected).
41
+ * @param answers - The answers to express.
42
+ * @returns The argument vector.
43
+ * @throws If a confirm answered `false` declares no `default: true` — no
44
+ * registered spelling exists for that answer (the module header's
45
+ * PRECONDITION), so the matrix must fail loudly rather than hand both
46
+ * binaries an argv they reject as an unknown option.
47
+ */
48
+ export function flagizeAnswers(prompts, answers) {
49
+ const positionals = [];
50
+ const flags = [];
51
+ for (const prompt of prompts) {
52
+ if (!Object.hasOwn(answers, prompt.name))
53
+ continue;
54
+ const value = answers[prompt.name];
55
+ if (sameAsDefault(value, prompt.default))
56
+ continue;
57
+ const kebab = toKebabCase(prompt.name);
58
+ if (prompt.type === "confirm") {
59
+ // The registered form, from the single flag-shape authority — never a
60
+ // kebab-cased guess (the round-14 F3 class: a spelling no host
61
+ // registers hands the matrix an argv both binaries reject).
62
+ const primary = buildOptionInfo(prompt).flags.split(" ")[0];
63
+ if (value === true) {
64
+ // `true` differs from the default here, so the default is not
65
+ // `true` and the registered form IS the positive `--<kebab>`.
66
+ flags.push(primary);
67
+ continue;
68
+ }
69
+ if (primary.startsWith("--no-")) {
70
+ flags.push(primary);
71
+ continue;
72
+ }
73
+ // `false` on a confirm whose registered form is the positive flag
74
+ // (no declared `default: true`): no spelling exists — fail loudly.
75
+ throw new Error(`flagizeAnswers: confirm "${prompt.name}" answered false has no ` +
76
+ `registered spelling (buildOptionInfo registers only "${primary}"` +
77
+ ") — declare `default: true` on the prompt or drop the answer");
78
+ }
79
+ if (prompt.positional === true) {
80
+ positionals.push(String(value));
81
+ continue;
82
+ }
83
+ if (prompt.type === "multiselect" && Array.isArray(value)) {
84
+ flags.push(`--${kebab}=${value.join(",")}`);
85
+ continue;
86
+ }
87
+ flags.push(`--${kebab}=${String(value)}`);
88
+ }
89
+ return [...positionals, ...flags];
90
+ }
91
+ //# sourceMappingURL=flagizeAnswers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flagizeAnswers.js","sourceRoot":"","sources":["../../../../src/testing/conformance/flagizeAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,eAAe,MAAM,qCAAqC,CAAC;AAClE,OAAO,WAAW,MAAM,2BAA2B,CAAC;AAGpD,8DAA8D;AAC9D,SAAS,aAAa,CAAC,KAAc,EAAE,YAAqB;IAC1D,IAAI,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC;QAAE,OAAO,IAAI,CAAC;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACxD,OAAO,CACL,KAAK,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM;YACpC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CACnE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAC5B,OAA8B,EAC9B,OAA0C;IAE1C,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,MAAM,CA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AAC,EAAE,CAAC,CAAC;YAC5C,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,KAAK,CAAC,CAAC;AACpC,CAAC"}
@@ -12,6 +12,7 @@
12
12
  */
13
13
  export { diffTrees, formatTreeDiff, isIdentical } from "./diffTrees.js";
14
14
  export { CONFORMANCE_FIXTURES, fixture } from "./fixtures.js";
15
+ export { flagizeAnswers } from "./flagizeAnswers.js";
15
16
  export { produceReference } from "./produceReference.js";
16
17
  export { snapshotTree } from "./snapshotTree.js";
17
18
  //# sourceMappingURL=index.js.map
@@ -1 +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"}
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;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -6,5 +6,5 @@
6
6
  * accident, and the main barrel is the runtime contract while this is a testing
7
7
  * contract that may move faster.
8
8
  */
9
- export { CONFORMANCE_FIXTURES, diffTrees, fixture, formatTreeDiff, isIdentical, produceReference, snapshotTree, } from "./conformance/index.js";
9
+ export { CONFORMANCE_FIXTURES, diffTrees, fixture, flagizeAnswers, formatTreeDiff, isIdentical, produceReference, snapshotTree, } from "./conformance/index.js";
10
10
  //# sourceMappingURL=index.js.map
@@ -1 +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"}
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,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,GACb,MAAM,wBAAwB,CAAC"}
@@ -11,7 +11,7 @@ import type { GeneratorNode } from "./types.js";
11
11
  interface DiscoverOptions {
12
12
  /** When set, ONLY load from this path (for testing). */
13
13
  explicitPath?: string;
14
- /** Directory containing built-in generators. Defaults to ../generators relative to this file. */
14
+ /** Directory containing built-in generators. When omitted, no built-ins are scanned. */
15
15
  builtinDir?: string;
16
16
  }
17
17
  /**
@@ -19,8 +19,8 @@ interface DiscoverOptions {
19
19
  *
20
20
  * When `explicitPath` is provided, ONLY load from that path (for testing).
21
21
  *
22
- * Otherwise, priority (highest to lowest, later overrides earlier):
23
- * 1. Built-in generators from \@canonical/summon
22
+ * Otherwise, priority (lowest to highest, later overrides earlier):
23
+ * 1. Built-in generators — only when the caller supplies `builtinDir`
24
24
  * 2. Global packages (bun link / npm link locations)
25
25
  * 3. Project ./node_modules/summon-* packages (highest priority)
26
26
  *
@@ -1 +1 @@
1
- {"version":3,"file":"discoverGeneratorTree.d.ts","sourceRoot":"","sources":["../../../src/discovery/discoverGeneratorTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAC;AAqYjE,UAAU,eAAe;IACvB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAA8B,qBAAqB,CACjD,qBAAqB,CAAC,EAAE,MAAM,GAAG,eAAe,GAC/C,OAAO,CAAC,aAAa,CAAC,CAuDxB"}
1
+ {"version":3,"file":"discoverGeneratorTree.d.ts","sourceRoot":"","sources":["../../../src/discovery/discoverGeneratorTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAC;AAuYjE,UAAU,eAAe;IACvB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wFAAwF;IACxF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAA8B,qBAAqB,CACjD,qBAAqB,CAAC,EAAE,MAAM,GAAG,eAAe,GAC/C,OAAO,CAAC,aAAa,CAAC,CAyDxB"}
@@ -41,9 +41,10 @@ export interface AnswerablePrompt {
41
41
  * Build a Task that collects answers for the given prompt definitions by
42
42
  * asking each unanswered, applicable one as a `Prompt` effect.
43
43
  *
44
- * The returned task is single-use (it is `gen`-based): build a fresh one per
45
- * run. Prompts whose `name` is already present in `partialAnswers` are not
46
- * asked; `when` predicates observe flags and earlier answers alike.
44
+ * The returned task is re-interpretable — every walk evaluates the chain's
45
+ * continuations fresh. Prompts whose `name` is already present in
46
+ * `partialAnswers` are not asked; `when` predicates observe flags and earlier
47
+ * answers alike.
47
48
  *
48
49
  * @param prompts - The prompt definitions, in asking order.
49
50
  * @param partialAnswers - Answers already provided (e.g. CLI flags / MCP args).
@@ -1 +1 @@
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"}
1
+ {"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