@canonical/summon-core 0.29.0-experimental.0 → 0.30.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 (174) hide show
  1. package/README.md +20 -6
  2. package/dist/esm/discovery/discoverGeneratorTree.js +383 -0
  3. package/dist/esm/discovery/discoverGeneratorTree.js.map +1 -0
  4. package/dist/esm/discovery/generatorCache.js +14 -0
  5. package/dist/esm/discovery/generatorCache.js.map +1 -0
  6. package/dist/esm/discovery/index.js +3 -0
  7. package/dist/esm/discovery/index.js.map +1 -0
  8. package/dist/esm/discovery/types.js +2 -0
  9. package/dist/esm/discovery/types.js.map +1 -0
  10. package/dist/esm/index.js +17 -0
  11. package/dist/esm/index.js.map +1 -0
  12. package/dist/esm/stamp/applyStamp.js +73 -0
  13. package/dist/esm/stamp/applyStamp.js.map +1 -0
  14. package/dist/esm/stamp/index.js +3 -0
  15. package/dist/esm/stamp/index.js.map +1 -0
  16. package/dist/esm/stamp/runTaskWithStamp.js +20 -0
  17. package/dist/esm/stamp/runTaskWithStamp.js.map +1 -0
  18. package/dist/esm/stamp/types.js +2 -0
  19. package/dist/esm/stamp/types.js.map +1 -0
  20. package/dist/esm/template/TemplatingEngine.js +2 -0
  21. package/dist/esm/template/TemplatingEngine.js.map +1 -0
  22. package/dist/esm/template/ejsEngine.js +17 -0
  23. package/dist/esm/template/ejsEngine.js.map +1 -0
  24. package/dist/esm/template/generateStamp.js +23 -0
  25. package/dist/esm/template/generateStamp.js.map +1 -0
  26. package/dist/esm/template/generatorComment.js +21 -0
  27. package/dist/esm/template/generatorComment.js.map +1 -0
  28. package/dist/esm/template/getCommentStyle.js +51 -0
  29. package/dist/esm/template/getCommentStyle.js.map +1 -0
  30. package/dist/esm/template/index.js +12 -0
  31. package/dist/esm/template/index.js.map +1 -0
  32. package/dist/esm/template/prependStamp.js +16 -0
  33. package/dist/esm/template/prependStamp.js.map +1 -0
  34. package/dist/esm/template/renderFile.js +8 -0
  35. package/dist/esm/template/renderFile.js.map +1 -0
  36. package/dist/esm/template/renderString.js +8 -0
  37. package/dist/esm/template/renderString.js.map +1 -0
  38. package/dist/esm/template/renderStringAsync.js +8 -0
  39. package/dist/esm/template/renderStringAsync.js.map +1 -0
  40. package/dist/esm/template/tasks/index.js +3 -0
  41. package/dist/esm/template/tasks/index.js.map +1 -0
  42. package/dist/esm/template/tasks/template.js +29 -0
  43. package/dist/esm/template/tasks/template.js.map +1 -0
  44. package/dist/esm/template/tasks/templateDir.js +51 -0
  45. package/dist/esm/template/tasks/templateDir.js.map +1 -0
  46. package/dist/esm/template/tasks/types.js +2 -0
  47. package/dist/esm/template/tasks/types.js.map +1 -0
  48. package/dist/esm/template/templateHelpers.js +21 -0
  49. package/dist/esm/template/templateHelpers.js.map +1 -0
  50. package/dist/esm/template/withHelpers.js +8 -0
  51. package/dist/esm/template/withHelpers.js.map +1 -0
  52. package/dist/esm/types/AnyGenerator.js +2 -0
  53. package/dist/esm/types/AnyGenerator.js.map +1 -0
  54. package/dist/esm/types/ForbidReserved.js +2 -0
  55. package/dist/esm/types/ForbidReserved.js.map +1 -0
  56. package/dist/esm/types/GeneratorDefinition.js +2 -0
  57. package/dist/esm/types/GeneratorDefinition.js.map +1 -0
  58. package/dist/esm/types/GeneratorMeta.js +2 -0
  59. package/dist/esm/types/GeneratorMeta.js.map +1 -0
  60. package/dist/esm/types/PromptDefinition.js +2 -0
  61. package/dist/esm/types/PromptDefinition.js.map +1 -0
  62. package/dist/esm/types/ReservedOption.js +2 -0
  63. package/dist/esm/types/ReservedOption.js.map +1 -0
  64. package/dist/esm/types/StampConfig.js +2 -0
  65. package/dist/esm/types/StampConfig.js.map +1 -0
  66. package/dist/esm/types/index.js +2 -0
  67. package/dist/esm/types/index.js.map +1 -0
  68. package/dist/types/discovery/discoverGeneratorTree.d.ts +31 -0
  69. package/dist/types/discovery/discoverGeneratorTree.d.ts.map +1 -0
  70. package/{src/discovery/generatorCache.ts → dist/types/discovery/generatorCache.d.ts} +2 -3
  71. package/dist/types/discovery/generatorCache.d.ts.map +1 -0
  72. package/{src/discovery/index.ts → dist/types/discovery/index.d.ts} +1 -0
  73. package/dist/types/discovery/index.d.ts.map +1 -0
  74. package/dist/types/discovery/types.d.ts +18 -0
  75. package/dist/types/discovery/types.d.ts.map +1 -0
  76. package/dist/types/index.d.ts +18 -0
  77. package/dist/types/index.d.ts.map +1 -0
  78. package/dist/types/stamp/applyStamp.d.ts +7 -0
  79. package/dist/types/stamp/applyStamp.d.ts.map +1 -0
  80. package/{src/stamp/index.ts → dist/types/stamp/index.d.ts} +1 -0
  81. package/dist/types/stamp/index.d.ts.map +1 -0
  82. package/dist/types/stamp/runTaskWithStamp.d.ts +8 -0
  83. package/dist/types/stamp/runTaskWithStamp.d.ts.map +1 -0
  84. package/dist/types/stamp/types.d.ts +7 -0
  85. package/dist/types/stamp/types.d.ts.map +1 -0
  86. package/dist/types/template/TemplatingEngine.d.ts +15 -0
  87. package/dist/types/template/TemplatingEngine.d.ts.map +1 -0
  88. package/dist/types/template/ejsEngine.d.ts +7 -0
  89. package/dist/types/template/ejsEngine.d.ts.map +1 -0
  90. package/dist/types/template/generateStamp.d.ts +7 -0
  91. package/dist/types/template/generateStamp.d.ts.map +1 -0
  92. package/dist/types/template/generatorComment.d.ts +15 -0
  93. package/dist/types/template/generatorComment.d.ts.map +1 -0
  94. package/dist/types/template/getCommentStyle.d.ts +12 -0
  95. package/dist/types/template/getCommentStyle.d.ts.map +1 -0
  96. package/{src/template/index.ts → dist/types/template/index.d.ts} +1 -0
  97. package/dist/types/template/index.d.ts.map +1 -0
  98. package/dist/types/template/prependStamp.d.ts +6 -0
  99. package/dist/types/template/prependStamp.d.ts.map +1 -0
  100. package/dist/types/template/renderFile.d.ts +6 -0
  101. package/dist/types/template/renderFile.d.ts.map +1 -0
  102. package/dist/types/template/renderString.d.ts +6 -0
  103. package/dist/types/template/renderString.d.ts.map +1 -0
  104. package/dist/types/template/renderStringAsync.d.ts +6 -0
  105. package/dist/types/template/renderStringAsync.d.ts.map +1 -0
  106. package/{src/template/tasks/index.ts → dist/types/template/tasks/index.d.ts} +1 -0
  107. package/dist/types/template/tasks/index.d.ts.map +1 -0
  108. package/dist/types/template/tasks/template.d.ts +11 -0
  109. package/dist/types/template/tasks/template.d.ts.map +1 -0
  110. package/dist/types/template/tasks/templateDir.d.ts +7 -0
  111. package/dist/types/template/tasks/templateDir.d.ts.map +1 -0
  112. package/dist/types/template/tasks/types.d.ts +33 -0
  113. package/dist/types/template/tasks/types.d.ts.map +1 -0
  114. package/dist/types/template/templateHelpers.d.ts +19 -0
  115. package/dist/types/template/templateHelpers.d.ts.map +1 -0
  116. package/dist/types/template/withHelpers.d.ts +5 -0
  117. package/dist/types/template/withHelpers.d.ts.map +1 -0
  118. package/{src/types/AnyGenerator.ts → dist/types/types/AnyGenerator.d.ts} +1 -3
  119. package/dist/types/types/AnyGenerator.d.ts.map +1 -0
  120. package/{src/types/ForbidReserved.ts → dist/types/types/ForbidReserved.d.ts} +2 -5
  121. package/dist/types/types/ForbidReserved.d.ts.map +1 -0
  122. package/dist/types/types/GeneratorDefinition.d.ts +17 -0
  123. package/dist/types/types/GeneratorDefinition.d.ts.map +1 -0
  124. package/dist/types/types/GeneratorMeta.d.ts +30 -0
  125. package/dist/types/types/GeneratorMeta.d.ts.map +1 -0
  126. package/dist/types/types/PromptDefinition.d.ts +37 -0
  127. package/dist/types/types/PromptDefinition.d.ts.map +1 -0
  128. package/dist/types/types/ReservedOption.d.ts +7 -0
  129. package/dist/types/types/ReservedOption.d.ts.map +1 -0
  130. package/dist/types/types/StampConfig.d.ts +7 -0
  131. package/dist/types/types/StampConfig.d.ts.map +1 -0
  132. package/{src/types/index.ts → dist/types/types/index.d.ts} +1 -0
  133. package/dist/types/types/index.d.ts.map +1 -0
  134. package/package.json +14 -20
  135. package/src/discovery/discoverGeneratorTree.test.ts +0 -926
  136. package/src/discovery/discoverGeneratorTree.ts +0 -460
  137. package/src/discovery/types.ts +0 -18
  138. package/src/index.ts +0 -65
  139. package/src/stamp/applyStamp.test.ts +0 -252
  140. package/src/stamp/applyStamp.ts +0 -90
  141. package/src/stamp/runTaskWithStamp.ts +0 -31
  142. package/src/stamp/types.ts +0 -7
  143. package/src/template/TemplatingEngine.ts +0 -17
  144. package/src/template/ejsEngine.test.ts +0 -30
  145. package/src/template/ejsEngine.ts +0 -21
  146. package/src/template/generateStamp.test.ts +0 -45
  147. package/src/template/generateStamp.ts +0 -29
  148. package/src/template/generatorComment.test.ts +0 -81
  149. package/src/template/generatorComment.ts +0 -32
  150. package/src/template/getCommentStyle.test.ts +0 -112
  151. package/src/template/getCommentStyle.ts +0 -59
  152. package/src/template/prependStamp.test.ts +0 -30
  153. package/src/template/prependStamp.ts +0 -16
  154. package/src/template/renderFile.test.ts +0 -27
  155. package/src/template/renderFile.ts +0 -13
  156. package/src/template/renderString.test.ts +0 -107
  157. package/src/template/renderString.ts +0 -13
  158. package/src/template/renderStringAsync.test.ts +0 -28
  159. package/src/template/renderStringAsync.ts +0 -13
  160. package/src/template/tasks/template.test.ts +0 -88
  161. package/src/template/tasks/template.ts +0 -41
  162. package/src/template/tasks/templateDir.test.ts +0 -126
  163. package/src/template/tasks/templateDir.ts +0 -60
  164. package/src/template/tasks/types.ts +0 -34
  165. package/src/template/templateHelpers.test.ts +0 -227
  166. package/src/template/templateHelpers.ts +0 -35
  167. package/src/template/withHelpers.test.ts +0 -41
  168. package/src/template/withHelpers.ts +0 -10
  169. package/src/testing/integration/template-rendering.test.ts +0 -69
  170. package/src/types/GeneratorDefinition.ts +0 -19
  171. package/src/types/GeneratorMeta.ts +0 -29
  172. package/src/types/PromptDefinition.ts +0 -33
  173. package/src/types/ReservedOption.ts +0 -23
  174. package/src/types/StampConfig.ts +0 -6
@@ -0,0 +1,17 @@
1
+ import ejs from "ejs";
2
+ /**
3
+ * Default EJS templating engine implementation.
4
+ */
5
+ const ejsEngine = {
6
+ render(template, vars) {
7
+ return ejs.render(template, vars, { async: false });
8
+ },
9
+ async renderAsync(template, vars) {
10
+ return ejs.render(template, vars, { async: true });
11
+ },
12
+ async renderFile(templatePath, vars) {
13
+ return ejs.renderFile(templatePath, vars, { async: true });
14
+ },
15
+ };
16
+ export default ejsEngine;
17
+ //# sourceMappingURL=ejsEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ejsEngine.js","sourceRoot":"","sources":["../../../src/template/ejsEngine.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAGtB;;GAEG;AACH,MAAM,SAAS,GAAqB;IAClC,MAAM,CAAC,QAAQ,EAAE,IAAI;QACnB,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI;QAC9B,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAoB,CAAC;IACxE,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI;QACjC,OAAO,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,23 @@
1
+ import getCommentStyle from "./getCommentStyle.js";
2
+ /**
3
+ * Generate a stamp comment for a generated file.
4
+ * Returns null if the file type doesn't support comments.
5
+ */
6
+ export default function generateStamp(filePath, options) {
7
+ const style = getCommentStyle(filePath);
8
+ if (!style)
9
+ return null;
10
+ if (!style.single && !style.blockStart)
11
+ return null;
12
+ const stampText = `Generated by ${options.generator} v${options.version}`;
13
+ if (style.preferBlock || (!style.single && style.blockStart)) {
14
+ return `${style.blockStart} ${stampText} ${style.blockEnd}`;
15
+ }
16
+ /* v8 ignore next -- unreachable false branch: if we reach here, style.single is always truthy */
17
+ if (style.single) {
18
+ return `${style.single} ${stampText}`;
19
+ }
20
+ /* v8 ignore next -- structurally unreachable: line 14 guards !style.single && !style.blockStart */
21
+ throw new Error(`No comment syntax for stamp in ${filePath}`);
22
+ }
23
+ //# sourceMappingURL=generateStamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateStamp.js","sourceRoot":"","sources":["../../../src/template/generateStamp.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,QAAgB,EAChB,OAAoB;IAEpB,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAEpD,MAAM,SAAS,GAAG,gBAAgB,OAAO,CAAC,SAAS,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC;IAE1E,IAAI,KAAK,CAAC,WAAW,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7D,OAAO,GAAG,KAAK,CAAC,UAAU,IAAI,SAAS,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC9D,CAAC;IAED,iGAAiG;IACjG,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO,GAAG,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;IACxC,CAAC;IAED,mGAAmG;IACnG,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,EAAE,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,21 @@
1
+ const DELIMITERS = {
2
+ line: { start: "// ", end: "" },
3
+ html: { start: "<!-- ", end: " -->" },
4
+ jsx: { start: "{/* ", end: " */}" },
5
+ };
6
+ /**
7
+ * Generate a metadata comment for generated files.
8
+ *
9
+ * @param format - "line" for `// ...`, "html" for `<!-- ... -->`, "jsx" for `{/* ... * /}`
10
+ */
11
+ export default function generatorComment(generatorName, options) {
12
+ const parts = [`Generated by ${generatorName}`];
13
+ if (options?.version)
14
+ parts.push(`v${options.version}`);
15
+ if (options?.timestamp)
16
+ parts.push(`on ${new Date().toISOString()}`);
17
+ const format = options?.format ?? "line";
18
+ const { start, end } = DELIMITERS[format];
19
+ return `${start}${parts.join(" ")}${end}`;
20
+ }
21
+ //# sourceMappingURL=generatorComment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generatorComment.js","sourceRoot":"","sources":["../../../src/template/generatorComment.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,GAA0D;IACxE,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE;IAC/B,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE;IACrC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;CACpC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,aAAqB,EACrB,OAAiC;IAEjC,MAAM,KAAK,GAAG,CAAC,gBAAgB,aAAa,EAAE,CAAC,CAAC;IAChD,IAAI,OAAO,EAAE,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACxD,IAAI,OAAO,EAAE,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAErE,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,MAAM,CAAC;IACzC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,GAAG,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,51 @@
1
+ import * as path from "node:path";
2
+ const COMMENT_STYLES = {
3
+ ".ts": { single: "//", blockStart: "/*", blockEnd: "*/" },
4
+ ".tsx": { single: "//", blockStart: "/*", blockEnd: "*/" },
5
+ ".js": { single: "//", blockStart: "/*", blockEnd: "*/" },
6
+ ".jsx": { single: "//", blockStart: "/*", blockEnd: "*/" },
7
+ ".mjs": { single: "//", blockStart: "/*", blockEnd: "*/" },
8
+ ".cjs": { single: "//", blockStart: "/*", blockEnd: "*/" },
9
+ ".css": { blockStart: "/*", blockEnd: "*/", preferBlock: true },
10
+ ".scss": { single: "//", blockStart: "/*", blockEnd: "*/" },
11
+ ".sass": { single: "//" },
12
+ ".less": { single: "//", blockStart: "/*", blockEnd: "*/" },
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
+ ".json": {},
20
+ ".yaml": { single: "#" },
21
+ ".yml": { single: "#" },
22
+ ".toml": { single: "#" },
23
+ ".sh": { single: "#" },
24
+ ".bash": { single: "#" },
25
+ ".zsh": { single: "#" },
26
+ ".fish": { single: "#" },
27
+ ".py": { single: "#" },
28
+ ".rb": { single: "#" },
29
+ ".pl": { single: "#" },
30
+ ".go": { single: "//", blockStart: "/*", blockEnd: "*/" },
31
+ ".rs": { single: "//", blockStart: "/*", blockEnd: "*/" },
32
+ ".java": { single: "//", blockStart: "/*", blockEnd: "*/" },
33
+ ".kt": { single: "//", blockStart: "/*", blockEnd: "*/" },
34
+ ".swift": { single: "//", blockStart: "/*", blockEnd: "*/" },
35
+ ".c": { single: "//", blockStart: "/*", blockEnd: "*/" },
36
+ ".cpp": { single: "//", blockStart: "/*", blockEnd: "*/" },
37
+ ".h": { single: "//", blockStart: "/*", blockEnd: "*/" },
38
+ ".hpp": { single: "//", blockStart: "/*", blockEnd: "*/" },
39
+ ".php": { single: "//", blockStart: "/*", blockEnd: "*/" },
40
+ ".md": { blockStart: "<!--", blockEnd: "-->" },
41
+ ".mdx": { blockStart: "{/*", blockEnd: "*/}" },
42
+ ".sql": { single: "--", blockStart: "/*", blockEnd: "*/" },
43
+ };
44
+ /**
45
+ * Get the comment style for a given file path.
46
+ */
47
+ export default function getCommentStyle(filePath) {
48
+ const ext = path.extname(filePath).toLowerCase();
49
+ return COMMENT_STYLES[ext] ?? null;
50
+ }
51
+ //# sourceMappingURL=getCommentStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCommentStyle.js","sourceRoot":"","sources":["../../../src/template/getCommentStyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AASlC,MAAM,cAAc,GAAiC;IACnD,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACzD,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC1D,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACzD,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC1D,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC1D,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,E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E;IAC9C,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;CAC3D,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,QAAgB;IACtD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IACjD,OAAO,cAAc,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;AACrC,CAAC"}
@@ -0,0 +1,12 @@
1
+ export { default as ejsEngine } from "./ejsEngine.js";
2
+ export { default as generateStamp } from "./generateStamp.js";
3
+ export { default as generatorComment } from "./generatorComment.js";
4
+ export { default as getCommentStyle } from "./getCommentStyle.js";
5
+ export { default as prependStamp } from "./prependStamp.js";
6
+ export { default as renderFile } from "./renderFile.js";
7
+ export { default as renderString } from "./renderString.js";
8
+ export { default as renderStringAsync } from "./renderStringAsync.js";
9
+ export { template, templateDir } from "./tasks/index.js";
10
+ export { default as templateHelpers } from "./templateHelpers.js";
11
+ export { default as withHelpers } from "./withHelpers.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Prepend a stamp to file content.
3
+ * Handles shebang lines (#!/...) by placing stamp after them.
4
+ */
5
+ export default function prependStamp(content, stamp) {
6
+ if (content.startsWith("#!")) {
7
+ 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
+ }
13
+ }
14
+ return `${stamp}\n${content}`;
15
+ }
16
+ //# sourceMappingURL=prependStamp.js.map
@@ -0,0 +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"}
@@ -0,0 +1,8 @@
1
+ import ejsEngine from "./ejsEngine.js";
2
+ /**
3
+ * Render a template file with variables.
4
+ */
5
+ export default async function renderFile(templatePath, vars, engine = ejsEngine) {
6
+ return engine.renderFile(templatePath, vars);
7
+ }
8
+ //# sourceMappingURL=renderFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderFile.js","sourceRoot":"","sources":["../../../src/template/renderFile.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAGvC;;GAEG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,UAAU,CACtC,YAAoB,EACpB,IAA6B,EAC7B,SAA2B,SAAS;IAEpC,OAAO,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,8 @@
1
+ import ejsEngine from "./ejsEngine.js";
2
+ /**
3
+ * Render a template string with variables.
4
+ */
5
+ export default function renderString(template, vars, engine = ejsEngine) {
6
+ return engine.render(template, vars);
7
+ }
8
+ //# sourceMappingURL=renderString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderString.js","sourceRoot":"","sources":["../../../src/template/renderString.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAGvC;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,QAAgB,EAChB,IAA6B,EAC7B,SAA2B,SAAS;IAEpC,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import ejsEngine from "./ejsEngine.js";
2
+ /**
3
+ * Render a template string asynchronously.
4
+ */
5
+ export default async function renderStringAsync(template, vars, engine = ejsEngine) {
6
+ return engine.renderAsync(template, vars);
7
+ }
8
+ //# sourceMappingURL=renderStringAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderStringAsync.js","sourceRoot":"","sources":["../../../src/template/renderStringAsync.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAGvC;;GAEG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,iBAAiB,CAC7C,QAAgB,EAChB,IAA6B,EAC7B,SAA2B,SAAS;IAEpC,OAAO,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { default as template } from "./template.js";
2
+ export { default as templateDir } from "./templateDir.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/template/tasks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,29 @@
1
+ import * as path from "node:path";
2
+ import { mkdir, pure, readFile, task, writeFile, } from "@canonical/task";
3
+ import ejsEngine from "../ejsEngine.js";
4
+ import renderString from "../renderString.js";
5
+ /**
6
+ * Render a single template file to a destination.
7
+ *
8
+ * When `options.content` is provided, uses it directly instead of
9
+ * reading from `options.source`. This supports compiled binaries
10
+ * where template files are embedded and pre-loaded.
11
+ */
12
+ export default function template(options) {
13
+ const engine = options.engine ?? ejsEngine;
14
+ // Render destination path with variables
15
+ const destPath = renderString(options.dest, options.vars, engine);
16
+ const destDir = path.dirname(destPath);
17
+ // Key off `undefined`, not truthiness: a legitimately empty embedded
18
+ // template ("") must still use the provided content rather than falling
19
+ // back to reading from disk (which fails in compiled-binary mode).
20
+ const readSource = options.content !== undefined
21
+ ? task(pure(options.content))
22
+ : task(readFile(options.source));
23
+ return task(mkdir(destDir))
24
+ .chain(() => readSource)
25
+ .map((content) => renderString(content, options.vars, engine))
26
+ .chain((rendered) => task(writeFile(destPath, rendered)))
27
+ .unwrap();
28
+ }
29
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../src/template/tasks/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EAER,IAAI,EACJ,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAG9C;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,OAAwB;IACvD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC;IAE3C,yCAAyC;IACzC,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAClE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEvC,qEAAqE;IACrE,wEAAwE;IACxE,mEAAmE;IACnE,MAAM,UAAU,GACd,OAAO,CAAC,OAAO,KAAK,SAAS;QAC3B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAErC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SACxB,KAAK,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC;SACvB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;SAC7D,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;SACxD,MAAM,EAAE,CAAC;AACd,CAAC"}
@@ -0,0 +1,51 @@
1
+ import * as path from "node:path";
2
+ import { glob, sequence_, task } from "@canonical/task";
3
+ import ejsEngine from "../ejsEngine.js";
4
+ import renderString from "../renderString.js";
5
+ import template from "./template.js";
6
+ /**
7
+ * Simple minimatch implementation for common patterns.
8
+ */
9
+ const minimatch = (filepath, pattern) => {
10
+ const regex = pattern
11
+ .replace(/\./g, "\\.")
12
+ .replace(/\*\*/g, "<<GLOBSTAR>>")
13
+ .replace(/\*/g, "[^/]*")
14
+ .replace(/<<GLOBSTAR>>/g, ".*");
15
+ return new RegExp(`^${regex}$`).test(filepath);
16
+ };
17
+ /**
18
+ * Render a directory of templates to a destination.
19
+ */
20
+ export default function templateDir(options) {
21
+ const engine = options.engine ?? ejsEngine;
22
+ return task(glob("**/*", options.source))
23
+ .chain((files) => {
24
+ const tasks = files
25
+ .filter((file) => {
26
+ if (options.ignore) {
27
+ return !options.ignore.some((pattern) => minimatch(file, pattern));
28
+ }
29
+ return true;
30
+ })
31
+ .map((file) => {
32
+ const sourcePath = path.join(options.source, file);
33
+ let destFile = file.replace(/\.ejs$/, "");
34
+ const renamed = options.rename?.[destFile];
35
+ if (renamed) {
36
+ destFile = renamed;
37
+ }
38
+ destFile = renderString(destFile, options.vars, engine);
39
+ const destPath = path.join(options.dest, destFile);
40
+ return template({
41
+ source: sourcePath,
42
+ dest: destPath,
43
+ vars: options.vars,
44
+ engine,
45
+ });
46
+ });
47
+ return task(sequence_(tasks));
48
+ })
49
+ .unwrap();
50
+ }
51
+ //# sourceMappingURL=templateDir.js.map
@@ -0,0 +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,E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AI,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,OAAO,QAAQ,CAAC;gBACd,MAAM,EAAE,UAAU;gBAClB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM;aACP,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEL,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAChC,CAAC,CAAC;SACD,MAAM,EAAE,CAAC;AACd,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/template/tasks/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Common template helpers that can be passed to templates.
3
+ */
4
+ import { capitalize, indent, join, toCamelCase, toConstantCase, toKebabCase, toPascalCase, toSnakeCase, } from "@canonical/utils";
5
+ const templateHelpers = {
6
+ camelCase: toCamelCase,
7
+ pascalCase: toPascalCase,
8
+ kebabCase: toKebabCase,
9
+ snakeCase: toSnakeCase,
10
+ constantCase: toConstantCase,
11
+ capitalize,
12
+ indent,
13
+ join,
14
+ isoDate: () => new Date().toISOString(),
15
+ year: () => new Date().getFullYear(),
16
+ pluralize: (word, count) => {
17
+ return count === 1 ? word : `${word}s`;
18
+ },
19
+ };
20
+ export default templateHelpers;
21
+ //# sourceMappingURL=templateHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateHelpers.js","sourceRoot":"","sources":["../../../src/template/templateHelpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,UAAU,EACV,MAAM,EACN,IAAI,EACJ,WAAW,EACX,cAAc,EACd,WAAW,EACX,YAAY,EACZ,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,MAAM,eAAe,GAAG;IACtB,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,YAAY;IACxB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,UAAU;IACV,MAAM;IACN,IAAI;IAEJ,OAAO,EAAE,GAAW,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;IAE/C,IAAI,EAAE,GAAW,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;IAE5C,SAAS,EAAE,CAAC,IAAY,EAAE,KAAa,EAAU,EAAE;QACjD,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC;IACzC,CAAC;CACF,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,8 @@
1
+ import templateHelpers from "./templateHelpers.js";
2
+ /**
3
+ * Create a vars object with helpers included.
4
+ */
5
+ export default function withHelpers(vars) {
6
+ return { ...templateHelpers, ...vars };
7
+ }
8
+ //# sourceMappingURL=withHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withHelpers.js","sourceRoot":"","sources":["../../../src/template/withHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,IAA6B;IAE7B,OAAO,EAAE,GAAG,eAAe,EAAE,GAAG,IAAI,EAAE,CAAC;AACzC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AnyGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnyGenerator.js","sourceRoot":"","sources":["../../../src/types/AnyGenerator.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ForbidReserved.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForbidReserved.js","sourceRoot":"","sources":["../../../src/types/ForbidReserved.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GeneratorDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeneratorDefinition.js","sourceRoot":"","sources":["../../../src/types/GeneratorDefinition.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GeneratorMeta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeneratorMeta.js","sourceRoot":"","sources":["../../../src/types/GeneratorMeta.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PromptDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromptDefinition.js","sourceRoot":"","sources":["../../../src/types/PromptDefinition.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ReservedOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReservedOption.js","sourceRoot":"","sources":["../../../src/types/ReservedOption.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=StampConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StampConfig.js","sourceRoot":"","sources":["../../../src/types/StampConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Discover available generators from the filesystem.
3
+ *
4
+ * Scans local directories, global package manager locations, and
5
+ * project node_modules for summon-* packages, building a tree of
6
+ * {@link GeneratorNode} entries.
7
+ *
8
+ * @note Impure — performs filesystem I/O (readdir, stat, access, import).
9
+ */
10
+ import type { GeneratorNode } from "./types.js";
11
+ interface DiscoverOptions {
12
+ /** When set, ONLY load from this path (for testing). */
13
+ explicitPath?: string;
14
+ /** Directory containing built-in generators. Defaults to ../generators relative to this file. */
15
+ builtinDir?: string;
16
+ }
17
+ /**
18
+ * Create the root generator tree from all sources.
19
+ *
20
+ * When `explicitPath` is provided, ONLY load from that path (for testing).
21
+ *
22
+ * Otherwise, priority (highest to lowest, later overrides earlier):
23
+ * 1. Built-in generators from \@canonical/summon
24
+ * 2. Global packages (bun link / npm link locations)
25
+ * 3. Project ./node_modules/summon-* packages (highest priority)
26
+ *
27
+ * @note Impure — scans the filesystem and imports generator modules.
28
+ */
29
+ export default function discoverGeneratorTree(explicitPathOrOptions?: string | DiscoverOptions): Promise<GeneratorNode>;
30
+ export {};
31
+ //# sourceMappingURL=discoverGeneratorTree.d.ts.map
@@ -0,0 +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"}
@@ -5,12 +5,11 @@
5
5
  * (library) and `loadGenerator` (binary) can access the same Map instance
6
6
  * without coupling library code to binary-only modules.
7
7
  */
8
-
9
8
  import type { GeneratorDefinition } from "../types/index.js";
10
-
11
9
  /**
12
10
  * Key is the command path (e.g., "component/react").
13
11
  * Populated by {@link discoverGeneratorTree} when processing package barrels.
14
12
  * Read by `loadGenerator` when resolving `cache:` prefixed paths.
15
13
  */
16
- export const generatorCache = new Map<string, GeneratorDefinition>();
14
+ export declare const generatorCache: Map<string, GeneratorDefinition<Record<string, unknown>>>;
15
+ //# sourceMappingURL=generatorCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generatorCache.d.ts","sourceRoot":"","sources":["../../../src/discovery/generatorCache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,cAAc,2DAAyC,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { default as discoverGeneratorTree } from "./discoverGeneratorTree.js";
2
2
  export { generatorCache } from "./generatorCache.js";
3
3
  export type { GeneratorNode, GeneratorOrigin } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/discovery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,18 @@
1
+ /** Origin of a generator (for display purposes). */
2
+ export type GeneratorOrigin = "local" | "global" | "package" | "builtin";
3
+ /** A node in the generator discovery tree. */
4
+ export interface GeneratorNode {
5
+ name: string;
6
+ /** Directory path */
7
+ path: string;
8
+ /** Path to index.ts if this is a runnable generator */
9
+ indexPath?: string;
10
+ children: Map<string, GeneratorNode>;
11
+ origin?: GeneratorOrigin;
12
+ meta?: {
13
+ name: string;
14
+ description: string;
15
+ version: string;
16
+ };
17
+ }
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/discovery/types.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAEzE,8CAA8C;AAC9C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,IAAI,CAAC,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Summon - A Monadic Task-Centric Code Generator Framework
3
+ *
4
+ * The effect framework (Task, Effect, combinators, primitives, interpreter,
5
+ * dry-run) lives in @canonical/task. This package provides the generation
6
+ * layer on top: generator definitions, templates, stamps, and CLI types.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export type { AnyGenerator, ForbidReserved, GeneratorDefinition, GeneratorMeta, PromptDefinition, ReservedOption, StampConfig, } from "./types/index.js";
11
+ export type { RunTaskWithStampOptions } from "./stamp/index.js";
12
+ export { applyStamp, runTaskWithStamp, } from "./stamp/index.js";
13
+ export type { TemplateDirOptions, TemplateOptions, TemplatingEngine, } from "./template/index.js";
14
+ export { ejsEngine, generateStamp, generatorComment, getCommentStyle, prependStamp, renderFile, renderString, renderStringAsync, template, templateDir, templateHelpers, withHelpers, } from "./template/index.js";
15
+ export { default as discoverGeneratorTree } from "./discovery/discoverGeneratorTree.js";
16
+ export { generatorCache } from "./discovery/generatorCache.js";
17
+ export type { GeneratorNode, GeneratorOrigin } from "./discovery/types.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,YAAY,EACV,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAM1B,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EACL,UAAU,EACV,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAM1B,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,eAAe,EACf,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type StampConfig from "../types/StampConfig.js";
2
+ /**
3
+ * Apply a stamp to file content based on file extension.
4
+ * Returns the original content if the file type doesn't support comments.
5
+ */
6
+ export default function applyStamp(filePath: string, content: string, stamp: StampConfig): string;
7
+ //# sourceMappingURL=applyStamp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyStamp.d.ts","sourceRoot":"","sources":["../../../src/stamp/applyStamp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAkDvD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,WAAW,GACjB,MAAM,CA8BR"}
@@ -1,3 +1,4 @@
1
1
  export { default as applyStamp } from "./applyStamp.js";
2
2
  export { default as runTaskWithStamp } from "./runTaskWithStamp.js";
3
3
  export type { RunTaskWithStampOptions } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stamp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Task } from "@canonical/task";
2
+ import type { RunTaskWithStampOptions } from "./types.js";
3
+ /**
4
+ * Run a task with stamp support. Wraps `runTask` from @canonical/task,
5
+ * intercepting WriteFile effects to prepend generated-file stamps.
6
+ */
7
+ export default function runTaskWithStamp<A>(task: Task<A>, options?: RunTaskWithStampOptions): Promise<A>;
8
+ //# sourceMappingURL=runTaskWithStamp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runTaskWithStamp.d.ts","sourceRoot":"","sources":["../../../src/stamp/runTaskWithStamp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;GAGG;AACH,wBAA8B,gBAAgB,CAAC,CAAC,EAC9C,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EACb,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,CAAC,CAAC,CAmBZ"}
@@ -0,0 +1,7 @@
1
+ import type { RunTaskOptions } from "@canonical/task/node";
2
+ import type StampConfig from "../types/StampConfig.js";
3
+ export interface RunTaskWithStampOptions extends RunTaskOptions {
4
+ /** Stamp configuration for generated files. If provided, all written files get a stamp comment. */
5
+ stamp?: StampConfig;
6
+ }
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/stamp/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD,MAAM,WAAW,uBAAwB,SAAQ,cAAc;IAC7D,mGAAmG;IACnG,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB"}