@canonical/summon-core 0.34.0 → 0.36.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 (177) 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 +24 -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/Wizard.js +44 -8
  52. package/dist/esm/prompt/ink/Wizard.js.map +1 -1
  53. package/dist/esm/prompt/ink/mount.js +20 -8
  54. package/dist/esm/prompt/ink/mount.js.map +1 -1
  55. package/dist/esm/prompt/ink/progressWindow.js +131 -3
  56. package/dist/esm/prompt/ink/progressWindow.js.map +1 -1
  57. package/dist/esm/prompt/ink/session.js +135 -14
  58. package/dist/esm/prompt/ink/session.js.map +1 -1
  59. package/dist/esm/prompt/inkPrompt.js +18 -2
  60. package/dist/esm/prompt/inkPrompt.js.map +1 -1
  61. package/dist/esm/prompt/mcpPrompt.js +1 -1
  62. package/dist/esm/prompt/mcpPrompt.js.map +1 -1
  63. package/dist/esm/stamp/applyStamp.js +50 -52
  64. package/dist/esm/stamp/applyStamp.js.map +1 -1
  65. package/dist/esm/stamp/createStampOnEffectStart.js +4 -1
  66. package/dist/esm/stamp/createStampOnEffectStart.js.map +1 -1
  67. package/dist/esm/stamp/runTaskWithStamp.js +8 -9
  68. package/dist/esm/stamp/runTaskWithStamp.js.map +1 -1
  69. package/dist/esm/template/index.js +2 -0
  70. package/dist/esm/template/index.js.map +1 -1
  71. package/dist/esm/template/loadTemplate.js +43 -0
  72. package/dist/esm/template/loadTemplate.js.map +1 -0
  73. package/dist/esm/template/prependStamp.js +11 -8
  74. package/dist/esm/template/prependStamp.js.map +1 -1
  75. package/dist/esm/template/rawFile.js +25 -0
  76. package/dist/esm/template/rawFile.js.map +1 -0
  77. package/dist/esm/template/tasks/template.js +12 -3
  78. package/dist/esm/template/tasks/template.js.map +1 -1
  79. package/dist/esm/template/tasks/templateDir.js +5 -0
  80. package/dist/esm/template/tasks/templateDir.js.map +1 -1
  81. package/dist/esm/testing/conformance/fixtures.js +0 -2
  82. package/dist/esm/testing/conformance/fixtures.js.map +1 -1
  83. package/dist/esm/testing/conformance/flagizeAnswers.js +91 -0
  84. package/dist/esm/testing/conformance/flagizeAnswers.js.map +1 -0
  85. package/dist/esm/testing/conformance/index.js +1 -0
  86. package/dist/esm/testing/conformance/index.js.map +1 -1
  87. package/dist/esm/testing/index.js +1 -1
  88. package/dist/esm/testing/index.js.map +1 -1
  89. package/dist/types/discovery/discoverGeneratorTree.d.ts +3 -3
  90. package/dist/types/discovery/discoverGeneratorTree.d.ts.map +1 -1
  91. package/dist/types/execute/collectAnswers.d.ts +4 -3
  92. package/dist/types/execute/collectAnswers.d.ts.map +1 -1
  93. package/dist/types/execute/execute.d.ts +27 -1
  94. package/dist/types/execute/execute.d.ts.map +1 -1
  95. package/dist/types/execute/index.d.ts +1 -1
  96. package/dist/types/execute/index.d.ts.map +1 -1
  97. package/dist/types/execute/validateAnswers.d.ts.map +1 -1
  98. package/dist/types/format/effects.d.ts +61 -7
  99. package/dist/types/format/effects.d.ts.map +1 -1
  100. package/dist/types/format/formatFlagName.d.ts +14 -0
  101. package/dist/types/format/formatFlagName.d.ts.map +1 -0
  102. package/dist/types/format/index.d.ts +21 -1
  103. package/dist/types/format/index.d.ts.map +1 -1
  104. package/dist/types/index.d.ts +5 -5
  105. package/dist/types/index.d.ts.map +1 -1
  106. package/dist/types/projection/answers.d.ts +54 -0
  107. package/dist/types/projection/answers.d.ts.map +1 -0
  108. package/dist/types/projection/buildOptionInfo.d.ts +25 -0
  109. package/dist/types/projection/buildOptionInfo.d.ts.map +1 -0
  110. package/dist/types/projection/commander/configureGroupedHelp.d.ts +29 -0
  111. package/dist/types/projection/commander/configureGroupedHelp.d.ts.map +1 -0
  112. package/dist/types/projection/commander/emitToProcess.d.ts +10 -0
  113. package/dist/types/projection/commander/emitToProcess.d.ts.map +1 -0
  114. package/dist/types/projection/commander/index.d.ts +21 -0
  115. package/dist/types/projection/commander/index.d.ts.map +1 -0
  116. package/dist/types/projection/commander/registerGeneratorCommands.d.ts +95 -0
  117. package/dist/types/projection/commander/registerGeneratorCommands.d.ts.map +1 -0
  118. package/dist/types/projection/decideInteraction.d.ts +70 -0
  119. package/dist/types/projection/decideInteraction.d.ts.map +1 -0
  120. package/dist/types/projection/extractAnswers.d.ts +23 -0
  121. package/dist/types/projection/extractAnswers.d.ts.map +1 -0
  122. package/dist/types/projection/groupedHelp.d.ts +25 -0
  123. package/dist/types/projection/groupedHelp.d.ts.map +1 -0
  124. package/dist/types/projection/index.d.ts +29 -0
  125. package/dist/types/projection/index.d.ts.map +1 -0
  126. package/dist/types/projection/kebab.d.ts +16 -0
  127. package/dist/types/projection/kebab.d.ts.map +1 -0
  128. package/dist/types/projection/projectGenerator.d.ts +22 -0
  129. package/dist/types/projection/projectGenerator.d.ts.map +1 -0
  130. package/dist/types/projection/types.d.ts +118 -0
  131. package/dist/types/projection/types.d.ts.map +1 -0
  132. package/dist/types/projection/usage.d.ts +92 -0
  133. package/dist/types/projection/usage.d.ts.map +1 -0
  134. package/dist/types/prompt/answerPromptWithDefaults.d.ts +5 -3
  135. package/dist/types/prompt/answerPromptWithDefaults.d.ts.map +1 -1
  136. package/dist/types/prompt/autoPrompt.d.ts.map +1 -1
  137. package/dist/types/prompt/index.d.ts +1 -1
  138. package/dist/types/prompt/index.d.ts.map +1 -1
  139. package/dist/types/prompt/ink/Wizard.d.ts.map +1 -1
  140. package/dist/types/prompt/ink/mount.d.ts +3 -2
  141. package/dist/types/prompt/ink/mount.d.ts.map +1 -1
  142. package/dist/types/prompt/ink/progressWindow.d.ts +98 -2
  143. package/dist/types/prompt/ink/progressWindow.d.ts.map +1 -1
  144. package/dist/types/prompt/ink/session.d.ts +87 -4
  145. package/dist/types/prompt/ink/session.d.ts.map +1 -1
  146. package/dist/types/prompt/inkPrompt.d.ts +36 -2
  147. package/dist/types/prompt/inkPrompt.d.ts.map +1 -1
  148. package/dist/types/stamp/applyStamp.d.ts +6 -2
  149. package/dist/types/stamp/applyStamp.d.ts.map +1 -1
  150. package/dist/types/stamp/createStampOnEffectStart.d.ts.map +1 -1
  151. package/dist/types/stamp/runTaskWithStamp.d.ts +3 -1
  152. package/dist/types/stamp/runTaskWithStamp.d.ts.map +1 -1
  153. package/dist/types/template/index.d.ts +4 -0
  154. package/dist/types/template/index.d.ts.map +1 -1
  155. package/dist/types/template/loadTemplate.d.ts +40 -0
  156. package/dist/types/template/loadTemplate.d.ts.map +1 -0
  157. package/dist/types/template/prependStamp.d.ts +5 -2
  158. package/dist/types/template/prependStamp.d.ts.map +1 -1
  159. package/dist/types/template/rawFile.d.ts +32 -0
  160. package/dist/types/template/rawFile.d.ts.map +1 -0
  161. package/dist/types/template/tasks/template.d.ts +8 -0
  162. package/dist/types/template/tasks/template.d.ts.map +1 -1
  163. package/dist/types/template/tasks/templateDir.d.ts.map +1 -1
  164. package/dist/types/template/tasks/types.d.ts +2 -0
  165. package/dist/types/template/tasks/types.d.ts.map +1 -1
  166. package/dist/types/testing/conformance/fixtures.d.ts.map +1 -1
  167. package/dist/types/testing/conformance/flagizeAnswers.d.ts +38 -0
  168. package/dist/types/testing/conformance/flagizeAnswers.d.ts.map +1 -0
  169. package/dist/types/testing/conformance/index.d.ts +1 -0
  170. package/dist/types/testing/conformance/index.d.ts.map +1 -1
  171. package/dist/types/testing/index.d.ts +1 -1
  172. package/dist/types/testing/index.d.ts.map +1 -1
  173. package/dist/types/types/GeneratorDefinition.d.ts +10 -1
  174. package/dist/types/types/GeneratorDefinition.d.ts.map +1 -1
  175. package/dist/types/types/ReservedOption.d.ts +1 -1
  176. package/dist/types/types/ReservedOption.d.ts.map +1 -1
  177. package/package.json +22 -9
@@ -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,I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QAAQ,CAAC,CAAC,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,I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,OAAO,IAAI,CAAC;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,M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IAAI,CAAC,GAAG,CAAC,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
+ {"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;;;;;;;;;;;;GAYG;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,CAyB/B"}
@@ -22,7 +22,7 @@
22
22
  * the single signal that answer collection is complete — which a streaming
23
23
  * per-question handler otherwise cannot know.
24
24
  */
25
- import { type Task } from "@canonical/task";
25
+ import { type Task, TaskExecutionError } from "@canonical/task";
26
26
  import type { PromptHandler } from "../prompt/types.js";
27
27
  import type GeneratorDefinition from "../types/GeneratorDefinition.js";
28
28
  import type { GeneratorResult } from "./GeneratorResult.js";
@@ -32,6 +32,32 @@ export declare const CONFIRM_ANSWER_KEY = "__summon_proceed__";
32
32
  export declare const GENERATOR_INVALID_ANSWER = "GENERATOR_INVALID_ANSWER";
33
33
  /** Task-error code for a run cancelled at the interactive confirm gate. */
34
34
  export declare const GENERATOR_CANCELLED = "GENERATOR_CANCELLED";
35
+ /**
36
+ * Build the typed error a generator's `generate` throws for a CROSS-answer
37
+ * constraint no single prompt's `validate` can see — two answers only valid
38
+ * together. No shipped generator declares one today (application/react's
39
+ * former ssr+router guard is gone with its prompts); the `guarded` fixture
40
+ * in cli/summon's interaction tests shows the shape. It carries the same
41
+ * {@link GENERATOR_INVALID_ANSWER} code the validation failure inside
42
+ * {@link execute} raises, so a host routes it down its existing invalid-input
43
+ * pathway — pragma maps the code to `INVALID_INPUT` (exit 2), the summon bin
44
+ * prints the bare message (exit 2 in a batch mode, the App's error phase in a
45
+ * wizard) — instead of collapsing it into an internal error with a stack.
46
+ *
47
+ * @param message - The human-readable constraint, naming REGISTERED flag
48
+ * spellings (what a user can actually type).
49
+ * @returns The typed error for `generate` to `throw`.
50
+ */
51
+ export declare function invalidAnswersError(message: string): TaskExecutionError;
52
+ /**
53
+ * True when a thrown value is a generator-raised invalid answer — matched by
54
+ * the {@link GENERATOR_INVALID_ANSWER} code, never by class identity, so the
55
+ * check survives a duplicate module instance across build outputs.
56
+ *
57
+ * @param error - The caught value.
58
+ * @returns Whether the value is an {@link invalidAnswersError} throw.
59
+ */
60
+ export declare function isInvalidAnswersError(error: unknown): error is Error;
35
61
  /** The context {@link execute} builds its task from. */
36
62
  export interface ExecuteContext {
37
63
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/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,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,6EAA6E;AAC7E,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAEnE,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAEvE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAKpE;AAED,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,mFAAmF;IACnF,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,iEAAiE;IACjE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAC7B,SAAS,EAAE,mBAAmB,EAC9B,GAAG,EAAE,cAAc,GAClB,IAAI,CAAC,eAAe,CAAC,CAsDvB"}
@@ -1,6 +1,6 @@
1
1
  export type { AnswerablePrompt } from "./collectAnswers.js";
2
2
  export { default as collectAnswers } from "./collectAnswers.js";
3
- export { CONFIRM_ANSWER_KEY, default as execute, type ExecuteContext, GENERATOR_CANCELLED, GENERATOR_INVALID_ANSWER, } from "./execute.js";
3
+ export { CONFIRM_ANSWER_KEY, default as execute, type ExecuteContext, GENERATOR_CANCELLED, GENERATOR_INVALID_ANSWER, invalidAnswersError, isInvalidAnswersError, } from "./execute.js";
4
4
  export type { GeneratorResult } from "./GeneratorResult.js";
5
5
  export { default as validateAnswers } from "./validateAnswers.js";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/execute/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACL,kBAAkB,EAClB,OAAO,IAAI,OAAO,EAClB,KAAK,cAAc,EACnB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/execute/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACL,kBAAkB,EAClB,OAAO,IAAI,OAAO,EAClB,KAAK,cAAc,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateAnswers.d.ts","sourceRoot":"","sources":["../../../src/execute/validateAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,gBAAgB,MAAM,8BAA8B,CAAC;AAMjE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,GAAG,IAAI,CAyBf"}
1
+ {"version":3,"file":"validateAnswers.d.ts","sourceRoot":"","sources":["../../../src/execute/validateAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,gBAAgB,MAAM,8BAA8B,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,GAAG,IAAI,CA+Cf"}