@canonical/summon-component 0.29.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 (153) hide show
  1. package/README.md +14 -26
  2. package/{src/index.ts → dist/esm/index.js} +5 -8
  3. package/dist/esm/index.js.map +1 -0
  4. package/dist/esm/lit/generator.js +152 -0
  5. package/dist/esm/lit/generator.js.map +1 -0
  6. package/dist/esm/lit/index.js +5 -0
  7. package/dist/esm/lit/index.js.map +1 -0
  8. package/dist/esm/lit/types.js +5 -0
  9. package/dist/esm/lit/types.js.map +1 -0
  10. package/dist/esm/react/generator.js +129 -0
  11. package/dist/esm/react/generator.js.map +1 -0
  12. package/dist/esm/react/index.js +5 -0
  13. package/dist/esm/react/index.js.map +1 -0
  14. package/dist/esm/react/types.js +5 -0
  15. package/dist/esm/react/types.js.map +1 -0
  16. package/dist/esm/shared/createComponentPathPrompt.js +23 -0
  17. package/dist/esm/shared/createComponentPathPrompt.js.map +1 -0
  18. package/dist/esm/shared/createTemplateContext.js +20 -0
  19. package/dist/esm/shared/createTemplateContext.js.map +1 -0
  20. package/dist/esm/shared/file-operations/appendExportToParentIndex.js +25 -0
  21. package/dist/esm/shared/file-operations/appendExportToParentIndex.js.map +1 -0
  22. package/dist/esm/shared/file-operations/dryRunWithFileState.js +25 -0
  23. package/dist/esm/shared/file-operations/dryRunWithFileState.js.map +1 -0
  24. package/{src/shared/file-operations/index.ts → dist/esm/shared/file-operations/index.js} +1 -0
  25. package/dist/esm/shared/file-operations/index.js.map +1 -0
  26. package/dist/esm/shared/file-operations/removeExportFromParentIndex.js +13 -0
  27. package/dist/esm/shared/file-operations/removeExportFromParentIndex.js.map +1 -0
  28. package/dist/esm/shared/file-operations/removeLineFromFile.js +19 -0
  29. package/dist/esm/shared/file-operations/removeLineFromFile.js.map +1 -0
  30. package/dist/esm/shared/index.js +11 -0
  31. package/dist/esm/shared/index.js.map +1 -0
  32. package/dist/esm/shared/loadTemplate.js +56 -0
  33. package/dist/esm/shared/loadTemplate.js.map +1 -0
  34. package/dist/esm/shared/packageName.js +11 -0
  35. package/dist/esm/shared/packageName.js.map +1 -0
  36. package/dist/esm/shared/sharedPrompts.js +28 -0
  37. package/dist/esm/shared/sharedPrompts.js.map +1 -0
  38. package/dist/esm/shared/string-helpers/getComponentName.js +8 -0
  39. package/dist/esm/shared/string-helpers/getComponentName.js.map +1 -0
  40. package/dist/esm/shared/string-helpers/getParentDir.js +8 -0
  41. package/dist/esm/shared/string-helpers/getParentDir.js.map +1 -0
  42. package/{src/shared/string-helpers/index.ts → dist/esm/shared/string-helpers/index.js} +1 -0
  43. package/dist/esm/shared/string-helpers/index.js.map +1 -0
  44. package/dist/esm/shared/types.js +5 -0
  45. package/dist/esm/shared/types.js.map +1 -0
  46. package/dist/esm/shared/validateComponentPath.js +16 -0
  47. package/dist/esm/shared/validateComponentPath.js.map +1 -0
  48. package/dist/esm/svelte/generator.js +165 -0
  49. package/dist/esm/svelte/generator.js.map +1 -0
  50. package/dist/esm/svelte/index.js +5 -0
  51. package/dist/esm/svelte/index.js.map +1 -0
  52. package/dist/esm/svelte/types.js +5 -0
  53. package/dist/esm/svelte/types.js.map +1 -0
  54. package/dist/types/index.d.ts +87 -0
  55. package/dist/types/index.d.ts.map +1 -0
  56. package/dist/types/lit/generator.d.ts +52 -0
  57. package/dist/types/lit/generator.d.ts.map +1 -0
  58. package/{src/lit/index.ts → dist/types/lit/index.d.ts} +1 -1
  59. package/dist/types/lit/index.d.ts.map +1 -0
  60. package/{src/lit/types.ts → dist/types/lit/types.d.ts} +1 -2
  61. package/dist/types/lit/types.d.ts.map +1 -0
  62. package/dist/types/react/generator.d.ts +28 -0
  63. package/dist/types/react/generator.d.ts.map +1 -0
  64. package/{src/react/index.ts → dist/types/react/index.d.ts} +1 -1
  65. package/dist/types/react/index.d.ts.map +1 -0
  66. package/{src/react/types.ts → dist/types/react/types.d.ts} +1 -2
  67. package/dist/types/react/types.d.ts.map +1 -0
  68. package/dist/types/shared/createComponentPathPrompt.d.ts +12 -0
  69. package/dist/types/shared/createComponentPathPrompt.d.ts.map +1 -0
  70. package/dist/types/shared/createTemplateContext.d.ts +9 -0
  71. package/dist/types/shared/createTemplateContext.d.ts.map +1 -0
  72. package/dist/types/shared/file-operations/appendExportToParentIndex.d.ts +8 -0
  73. package/dist/types/shared/file-operations/appendExportToParentIndex.d.ts.map +1 -0
  74. package/dist/types/shared/file-operations/dryRunWithFileState.d.ts +7 -0
  75. package/dist/types/shared/file-operations/dryRunWithFileState.d.ts.map +1 -0
  76. package/dist/types/shared/file-operations/index.d.ts +4 -0
  77. package/dist/types/shared/file-operations/index.d.ts.map +1 -0
  78. package/dist/types/shared/file-operations/removeExportFromParentIndex.d.ts +7 -0
  79. package/dist/types/shared/file-operations/removeExportFromParentIndex.d.ts.map +1 -0
  80. package/dist/types/shared/file-operations/removeLineFromFile.d.ts +7 -0
  81. package/dist/types/shared/file-operations/removeLineFromFile.d.ts.map +1 -0
  82. package/{src/shared/index.ts → dist/types/shared/index.d.ts} +2 -1
  83. package/dist/types/shared/index.d.ts.map +1 -0
  84. package/dist/types/shared/loadTemplate.d.ts +20 -0
  85. package/dist/types/shared/loadTemplate.d.ts.map +1 -0
  86. package/dist/types/shared/packageName.d.ts +11 -0
  87. package/dist/types/shared/packageName.d.ts.map +1 -0
  88. package/dist/types/shared/sharedPrompts.d.ts +7 -0
  89. package/dist/types/shared/sharedPrompts.d.ts.map +1 -0
  90. package/{src/shared/string-helpers/getComponentName.ts → dist/types/shared/string-helpers/getComponentName.d.ts} +2 -5
  91. package/dist/types/shared/string-helpers/getComponentName.d.ts.map +1 -0
  92. package/{src/shared/string-helpers/getParentDir.ts → dist/types/shared/string-helpers/getParentDir.d.ts} +2 -5
  93. package/dist/types/shared/string-helpers/getParentDir.d.ts.map +1 -0
  94. package/dist/types/shared/string-helpers/index.d.ts +4 -0
  95. package/dist/types/shared/string-helpers/index.d.ts.map +1 -0
  96. package/dist/types/shared/types.d.ts +34 -0
  97. package/dist/types/shared/types.d.ts.map +1 -0
  98. package/dist/types/shared/validateComponentPath.d.ts +5 -0
  99. package/dist/types/shared/validateComponentPath.d.ts.map +1 -0
  100. package/dist/types/svelte/generator.d.ts +52 -0
  101. package/dist/types/svelte/generator.d.ts.map +1 -0
  102. package/{src/svelte/index.ts → dist/types/svelte/index.d.ts} +1 -1
  103. package/dist/types/svelte/index.d.ts.map +1 -0
  104. package/{src/svelte/types.ts → dist/types/svelte/types.d.ts} +3 -4
  105. package/dist/types/svelte/types.d.ts.map +1 -0
  106. package/package.json +21 -10
  107. package/CHANGELOG.md +0 -245
  108. package/CONVENTIONS.md +0 -184
  109. package/biome.json +0 -6
  110. package/src/index.test.ts +0 -514
  111. package/src/lit/generator.ts +0 -190
  112. package/src/react/generator.ts +0 -176
  113. package/src/shared/createComponentPathPrompt.ts +0 -28
  114. package/src/shared/createTemplateContext.ts +0 -29
  115. package/src/shared/file-operations/appendExportToParentIndex.test.ts +0 -82
  116. package/src/shared/file-operations/appendExportToParentIndex.ts +0 -40
  117. package/src/shared/file-operations/dryRunWithFileState.ts +0 -28
  118. package/src/shared/file-operations/removeExportFromParentIndex.test.ts +0 -52
  119. package/src/shared/file-operations/removeExportFromParentIndex.ts +0 -21
  120. package/src/shared/file-operations/removeLineFromFile.test.ts +0 -66
  121. package/src/shared/file-operations/removeLineFromFile.ts +0 -29
  122. package/src/shared/loadTemplate.test.ts +0 -100
  123. package/src/shared/loadTemplate.ts +0 -70
  124. package/src/shared/sharedPrompts.ts +0 -30
  125. package/src/shared/string-helpers/getComponentName.test.ts +0 -18
  126. package/src/shared/string-helpers/getParentDir.test.ts +0 -16
  127. package/src/shared/types.ts +0 -36
  128. package/src/shared/validateComponentPath.test.ts +0 -40
  129. package/src/shared/validateComponentPath.ts +0 -16
  130. package/src/svelte/generator.ts +0 -224
  131. package/src/testing/integration/generators-undo.test.ts +0 -200
  132. package/tsconfig.json +0 -9
  133. package/vitest.config.ts +0 -18
  134. /package/{src → dist/esm}/templates/lit/component.ts.ejs +0 -0
  135. /package/{src → dist/esm}/templates/lit/index.ts.ejs +0 -0
  136. /package/{src → dist/esm}/templates/lit/stories.ts.ejs +0 -0
  137. /package/{src → dist/esm}/templates/lit/styles.css.ejs +0 -0
  138. /package/{src → dist/esm}/templates/lit/tests.ts.ejs +0 -0
  139. /package/{src → dist/esm}/templates/lit/types.ts.ejs +0 -0
  140. /package/{src → dist/esm}/templates/react/component.tsx.ejs +0 -0
  141. /package/{src → dist/esm}/templates/react/index.ts.ejs +0 -0
  142. /package/{src → dist/esm}/templates/react/ssr.test.tsx.ejs +0 -0
  143. /package/{src → dist/esm}/templates/react/stories.tsx.ejs +0 -0
  144. /package/{src → dist/esm}/templates/react/test.tsx.ejs +0 -0
  145. /package/{src → dist/esm}/templates/react/types.ts.ejs +0 -0
  146. /package/{src → dist/esm}/templates/shared/styles.css.ejs +0 -0
  147. /package/{src → dist/esm}/templates/svelte/component.svelte.ejs +0 -0
  148. /package/{src → dist/esm}/templates/svelte/index.ts.ejs +0 -0
  149. /package/{src → dist/esm}/templates/svelte/ssr.test.ts.ejs +0 -0
  150. /package/{src → dist/esm}/templates/svelte/stories.svelte.ejs +0 -0
  151. /package/{src → dist/esm}/templates/svelte/stories.ts.ejs +0 -0
  152. /package/{src → dist/esm}/templates/svelte/test.ts.ejs +0 -0
  153. /package/{src → dist/esm}/templates/svelte/types.ts.ejs +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createComponentPathPrompt.d.ts","sourceRoot":"","sources":["../../../src/shared/createComponentPathPrompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,SAAS,EAAE,SAAS,GACnB,gBAAgB,CAalB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Template context creation for component generators
3
+ */
4
+ import type { BaseComponentAnswers, Framework, TemplateContext } from "./types.js";
5
+ /**
6
+ * Create template context from answers
7
+ */
8
+ export default function createTemplateContext(answers: BaseComponentAnswers, framework: Framework): TemplateContext;
9
+ //# sourceMappingURL=createTemplateContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTemplateContext.d.ts","sourceRoot":"","sources":["../../../src/shared/createTemplateContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,oBAAoB,EACpB,SAAS,EACT,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,OAAO,EAAE,oBAAoB,EAC7B,SAAS,EAAE,SAAS,GACnB,eAAe,CAWjB"}
@@ -0,0 +1,8 @@
1
+ import { type Task } from "@canonical/task";
2
+ /**
3
+ * Append export to parent index.ts file (or create if not exists).
4
+ * Carries undo metadata: removes the export line (or deletes the index
5
+ * if it was created from scratch).
6
+ */
7
+ export default function appendExportToParentIndex(parentDir: string, componentName: string): Task<void>;
8
+ //# sourceMappingURL=appendExportToParentIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appendExportToParentIndex.d.ts","sourceRoot":"","sources":["../../../../src/shared/file-operations/appendExportToParentIndex.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,IAAI,EAEV,MAAM,iBAAiB,CAAC;AAGzB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,GACpB,IAAI,CAAC,IAAI,CAAC,CAkBZ"}
@@ -0,0 +1,7 @@
1
+ import { type Task } from "@canonical/task";
2
+ /**
3
+ * dryRunWith that mocks ReadFile and Exists to simulate file state.
4
+ * Test-only helper for file operation tests.
5
+ */
6
+ export default function dryRunWithFileState<A>(task: Task<A>, files: Record<string, string>): import("@canonical/task").DryRunResult<A>;
7
+ //# sourceMappingURL=dryRunWithFileState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dryRunWithFileState.d.ts","sourceRoot":"","sources":["../../../../src/shared/file-operations/dryRunWithFileState.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAErE;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,CAAC,EAC3C,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,6CAmB9B"}
@@ -0,0 +1,4 @@
1
+ export { default as appendExportToParentIndex } from "./appendExportToParentIndex.js";
2
+ export { default as removeExportFromParentIndex } from "./removeExportFromParentIndex.js";
3
+ export { default as removeLineFromFile } from "./removeLineFromFile.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shared/file-operations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type Task } from "@canonical/task";
2
+ /**
3
+ * Remove a component export from a parent index.ts.
4
+ * Idempotent — no-op if the export is not present or the file doesn't exist.
5
+ */
6
+ export default function removeExportFromParentIndex(parentDir: string, componentName: string): Task<void>;
7
+ //# sourceMappingURL=removeExportFromParentIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeExportFromParentIndex.d.ts","sourceRoot":"","sources":["../../../../src/shared/file-operations/removeExportFromParentIndex.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGnE;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,2BAA2B,CACjD,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,GACpB,IAAI,CAAC,IAAI,CAAC,CASZ"}
@@ -0,0 +1,7 @@
1
+ import { type Task } from "@canonical/task";
2
+ /**
3
+ * Remove a specific line from a file. If the file becomes empty,
4
+ * delete it entirely. Idempotent — no-op if the line is not present.
5
+ */
6
+ export default function removeLineFromFile(filePath: string, line: string): Task<void>;
7
+ //# sourceMappingURL=removeLineFromFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeLineFromFile.d.ts","sourceRoot":"","sources":["../../../../src/shared/file-operations/removeLineFromFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,IAAI,EAEV,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,IAAI,CAAC,IAAI,CAAC,CAaZ"}
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Shared utilities and types for component generators
3
3
  */
4
-
5
4
  export { default as createComponentPathPrompt } from "./createComponentPathPrompt.js";
6
5
  export { default as createTemplateContext } from "./createTemplateContext.js";
7
6
  export * from "./file-operations/index.js";
7
+ export { PACKAGE_NAME } from "./packageName.js";
8
8
  export { default as sharedPrompts } from "./sharedPrompts.js";
9
9
  export * from "./string-helpers/index.js";
10
10
  export type * from "./types.js";
11
11
  export { default as validateComponentPath } from "./validateComponentPath.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC9E,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,cAAc,2BAA2B,CAAC;AAC1C,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Load a template file eagerly, with compiled binary support.
3
+ *
4
+ * In interpreted mode, reads from the filesystem. In a compiled binary,
5
+ * falls back to `Bun.embeddedFiles` blobs (async, requires top-level await).
6
+ */
7
+ export interface LoadedTemplate {
8
+ /** Original source path (for diagnostics and dry-run display). */
9
+ readonly source: string;
10
+ /** Template content string. */
11
+ readonly content: string;
12
+ }
13
+ /**
14
+ * Load a template from disk or embedded files.
15
+ *
16
+ * @param source - Absolute path to the template file.
17
+ * @returns Loaded template with path and content.
18
+ */
19
+ export default function loadTemplate(source: string): Promise<LoadedTemplate>;
20
+ //# sourceMappingURL=loadTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadTemplate.d.ts","sourceRoot":"","sources":["../../../src/shared/loadTemplate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,cAAc;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAA8B,YAAY,CACxC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CA6CzB"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The published package name, used in generator `displayName` labels.
3
+ *
4
+ * Kept as a plain constant rather than a `package.json` JSON import: the import
5
+ * path (`../../package.json`) is relative to the source file, but after the
6
+ * `src → dist/esm` build it would resolve one level too shallow (`dist/` instead
7
+ * of the package root), breaking at runtime under Node. A constant sidesteps the
8
+ * build-layout coupling entirely.
9
+ */
10
+ export declare const PACKAGE_NAME = "@canonical/summon-component";
11
+ //# sourceMappingURL=packageName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageName.d.ts","sourceRoot":"","sources":["../../../src/shared/packageName.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,gCAAgC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { PromptDefinition } from "@canonical/summon-core";
2
+ /**
3
+ * Shared prompts for component generators (styles, stories, SSR tests)
4
+ */
5
+ declare const sharedPrompts: PromptDefinition[];
6
+ export default sharedPrompts;
7
+ //# sourceMappingURL=sharedPrompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedPrompts.d.ts","sourceRoot":"","sources":["../../../src/shared/sharedPrompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;GAEG;AACH,QAAA,MAAM,aAAa,EAAE,gBAAgB,EAsBpC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,8 +1,5 @@
1
- import * as path from "node:path";
2
-
3
1
  /**
4
2
  * Extract component name from path
5
3
  */
6
- export default function getComponentName(componentPath: string): string {
7
- return path.basename(componentPath);
8
- }
4
+ export default function getComponentName(componentPath: string): string;
5
+ //# sourceMappingURL=getComponentName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getComponentName.d.ts","sourceRoot":"","sources":["../../../../src/shared/string-helpers/getComponentName.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEtE"}
@@ -1,8 +1,5 @@
1
- import * as path from "node:path";
2
-
3
1
  /**
4
2
  * Get parent directory of component
5
3
  */
6
- export default function getParentDir(componentPath: string): string {
7
- return path.dirname(componentPath);
8
- }
4
+ export default function getParentDir(componentPath: string): string;
5
+ //# sourceMappingURL=getParentDir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getParentDir.d.ts","sourceRoot":"","sources":["../../../../src/shared/string-helpers/getParentDir.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAElE"}
@@ -0,0 +1,4 @@
1
+ export { isPascalCase, toKebabCase as kebabCase } from "@canonical/utils";
2
+ export { default as getComponentName } from "./getComponentName.js";
3
+ export { default as getParentDir } from "./getParentDir.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shared/string-helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Shared types for component generators
3
+ */
4
+ export type Framework = "react" | "svelte" | "lit";
5
+ /** Base answers shared across component generators */
6
+ export interface BaseComponentAnswers {
7
+ /** Full path to the component directory (e.g., src/components/Button) */
8
+ componentPath: string;
9
+ /** Include CSS styles */
10
+ withStyles: boolean;
11
+ /** Include Storybook stories */
12
+ withStories: boolean;
13
+ /** Include SSR tests */
14
+ withSsrTests: boolean;
15
+ }
16
+ export interface TemplateContext {
17
+ /** Component name in PascalCase (e.g., MyComponent) */
18
+ name: string;
19
+ /** Component name in kebab-case (e.g., my-component) */
20
+ kebabName: string;
21
+ /** Generator name for comments */
22
+ generatorName: string;
23
+ /** Generator version */
24
+ version: string;
25
+ /** Include styles */
26
+ withStyles: boolean;
27
+ /** Include stories */
28
+ withStories: boolean;
29
+ /** Include SSR tests */
30
+ withSsrTests: boolean;
31
+ /** Index signature for compatibility with Record<string, unknown> */
32
+ [key: string]: unknown;
33
+ }
34
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEnD,sDAAsD;AACtD,MAAM,WAAW,oBAAoB;IACnC,yEAAyE;IACzE,aAAa,EAAE,MAAM,CAAC;IACtB,yBAAyB;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,gCAAgC;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,wBAAwB;IACxB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,sBAAsB;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,wBAAwB;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,qEAAqE;IACrE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Validate component path
3
+ */
4
+ export default function validateComponentPath(value: unknown): true | string;
5
+ //# sourceMappingURL=validateComponentPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateComponentPath.d.ts","sourceRoot":"","sources":["../../../src/shared/validateComponentPath.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,CAS3E"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Svelte Component Generator
3
+ *
4
+ * Generates a Svelte 5 component with a consistent file structure:
5
+ * - `ComponentName.svelte` - Main component file with Svelte 5 runes ($props)
6
+ * - `types.ts` - TypeScript types and props interface
7
+ * - `index.ts` - Barrel export
8
+ * - `ComponentName.svelte.test.ts` - Unit tests with @testing-library/svelte
9
+ * - `ComponentName.ssr.test.ts` - SSR tests (optional)
10
+ * - `ComponentName.stories.svelte` - Svelte CSF stories (optional)
11
+ * - `ComponentName.stories.ts` - TypeScript stories (optional, alternative to Svelte CSF)
12
+ * - `styles.css` - CSS styles (optional)
13
+ *
14
+ * @example
15
+ * ```bash
16
+ * summon component svelte --component-path=src/lib/components/Button
17
+ * summon component svelte --component-path=src/lib/components/Card --with-stories
18
+ * summon component svelte --component-path=src/lib/components/Modal --with-stories --use-ts-stories
19
+ * ```
20
+ *
21
+ * @module
22
+ */
23
+ import type { SvelteComponentAnswers } from "./types.js";
24
+ /**
25
+ * Svelte component generator definition.
26
+ *
27
+ * This generator creates a complete Svelte 5 component with TypeScript support,
28
+ * runes ($props), testing infrastructure, and optional Storybook stories.
29
+ *
30
+ * @see {@link https://summon.dev/generators/component/svelte} for documentation
31
+ */
32
+ declare const generator: {
33
+ readonly meta: {
34
+ readonly name: "component/svelte";
35
+ readonly displayName: "@canonical/summon-component:svelte";
36
+ readonly description: "Generate a Svelte 5 component with TypeScript, tests, stories, and styles";
37
+ readonly version: "0.1.0";
38
+ readonly help: "Generate a Svelte 5 component with TypeScript, tests, stories, and styles.\n\nFEATURES:\n - Svelte 5 with runes ($props)\n - TypeScript types and props interface\n - Unit tests with @testing-library/svelte\n - Storybook integration (Svelte CSF or TypeScript)\n - CSS styles (optional)\n - SSR tests (optional)\n - Auto-export from parent index.ts\n\nThe component name is extracted from the path and must be PascalCase.\nFor example, 'src/lib/components/Button' creates a 'Button' component.";
39
+ readonly examples: ["summon component svelte --component-path=src/lib/components/Button", "summon component svelte --component-path=src/lib/components/Card --with-styles --with-stories", "summon component svelte --component-path=src/lib/components/Modal --with-stories --use-ts-stories", "summon component svelte --component-path=src/lib/components/Button --dry-run"];
40
+ };
41
+ readonly prompts: [import("@canonical/summon-core").PromptDefinition, ...import("@canonical/summon-core").PromptDefinition[], {
42
+ readonly name: "useTsStories";
43
+ readonly type: "confirm";
44
+ readonly message: "Use TypeScript stories format? (otherwise Svelte CSF)";
45
+ readonly default: false;
46
+ readonly when: (answers: Record<string, unknown>) => boolean;
47
+ readonly group: "Options";
48
+ }];
49
+ readonly generate: (answers: SvelteComponentAnswers) => import("@canonical/task").Task<void>;
50
+ };
51
+ export default generator;
52
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/svelte/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAiBH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAkCzD;;;;;;;GAOG;AACH,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;CA6IiD,CAAC;AAEjE,eAAe,SAAS,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Svelte Component Generator - Barrel export
3
3
  */
4
-
5
4
  export { default as generator } from "./generator.js";
6
5
  export type { SvelteComponentAnswers } from "./types.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/svelte/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Types for Svelte component generator
3
3
  */
4
-
5
4
  import type { BaseComponentAnswers } from "../shared/index.js";
6
-
7
5
  /** Svelte component generator answers */
8
6
  export interface SvelteComponentAnswers extends BaseComponentAnswers {
9
- /** Use TypeScript stories format instead of Svelte CSF */
10
- useTsStories: boolean;
7
+ /** Use TypeScript stories format instead of Svelte CSF */
8
+ useTsStories: boolean;
11
9
  }
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/svelte/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,yCAAyC;AACzC,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAC;CACvB"}
package/package.json CHANGED
@@ -1,9 +1,20 @@
1
1
  {
2
2
  "name": "@canonical/summon-component",
3
3
  "description": "Component generators for Summon - React, Svelte and Lit component scaffolding",
4
- "version": "0.29.0",
4
+ "version": "0.30.0",
5
5
  "type": "module",
6
- "main": "src/index.ts",
6
+ "main": "dist/esm/index.js",
7
+ "module": "dist/esm/index.js",
8
+ "types": "dist/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/types/index.d.ts",
12
+ "import": "./dist/esm/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
7
18
  "author": {
8
19
  "email": "webteam@canonical.com",
9
20
  "name": "Canonical Webteam"
@@ -21,7 +32,7 @@
21
32
  "access": "public"
22
33
  },
23
34
  "scripts": {
24
- "build": "echo 'No build needed - runs directly from TypeScript'",
35
+ "build": "tsc -p tsconfig.build.json && bun ../../../scripts/copy-templates.ts src dist/esm",
25
36
  "build:all": "bun run build",
26
37
  "check": "bun run check:biome && bun run check:ts && bun run check:webarchitect",
27
38
  "check:fix": "bun run check:biome:fix && bun run check:ts",
@@ -35,20 +46,20 @@
35
46
  },
36
47
  "devDependencies": {
37
48
  "@biomejs/biome": "2.4.9",
38
- "@canonical/biome-config": "^0.29.0",
39
- "@canonical/typescript-config": "^0.29.0",
40
- "@canonical/webarchitect": "^0.29.0",
49
+ "@canonical/biome-config": "^0.30.0",
50
+ "@canonical/typescript-config": "^0.30.0",
51
+ "@canonical/webarchitect": "^0.30.0",
41
52
  "@types/bun": "^1.3.10",
42
53
  "@types/node": "^24.12.0",
43
54
  "typescript": "^5.9.3",
44
55
  "vitest": "^4.0.18"
45
56
  },
46
57
  "dependencies": {
47
- "@canonical/utils": "^0.29.0"
58
+ "@canonical/utils": "^0.30.0"
48
59
  },
49
60
  "peerDependencies": {
50
- "@canonical/summon-core": "^0.18.0 || ^0.20.0",
51
- "@canonical/task": "^0.18.0 || ^0.20.0"
61
+ "@canonical/summon-core": "^0.29.0",
62
+ "@canonical/task": "^0.29.0"
52
63
  },
53
- "gitHead": "535302c1e1e5dd8fa9bc2da4144de57ec4e63005"
64
+ "gitHead": "40fe86ac955473536ac14f074812a9821f5b65c0"
54
65
  }
package/CHANGELOG.md DELETED
@@ -1,245 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [0.29.0](https://github.com/canonical/pragma/compare/v0.29.0-experimental.0...v0.29.0) (2026-07-03)
7
-
8
- **Note:** Version bump only for package @canonical/summon-component
9
-
10
-
11
-
12
-
13
-
14
- # [0.29.0-experimental.0](https://github.com/canonical/pragma/compare/v0.28.0...v0.29.0-experimental.0) (2026-06-24)
15
-
16
- **Note:** Version bump only for package @canonical/summon-component
17
-
18
-
19
-
20
-
21
-
22
- # [0.28.0](https://github.com/canonical/pragma/compare/v0.27.1-experimental.0...v0.28.0) (2026-06-16)
23
-
24
-
25
- ### Bug Fixes
26
-
27
- * **summon-component:** Fix Svelte component output failing type-checking ([#642](https://github.com/canonical/pragma/issues/642)) ([1331c96](https://github.com/canonical/pragma/commit/1331c963a5691f20b826bbb8b081ab283bde8584))
28
-
29
-
30
- ### Features
31
-
32
- * **pragma:** trace, MCP resources, summon template loading, framework config ([#645](https://github.com/canonical/pragma/issues/645)) ([4f0a341](https://github.com/canonical/pragma/commit/4f0a341a050facbf3a87419ed7a9b3c29c0a9ade)), closes [#1](https://github.com/canonical/pragma/issues/1) [#551](https://github.com/canonical/pragma/issues/551) [#569](https://github.com/canonical/pragma/issues/569) [#641](https://github.com/canonical/pragma/issues/641) [#641](https://github.com/canonical/pragma/issues/641)
33
-
34
-
35
-
36
-
37
-
38
- ## [0.27.1-experimental.0](https://github.com/canonical/pragma/compare/v0.28.0-experimental.0...v0.27.1-experimental.0) (2026-05-21)
39
-
40
-
41
- ### Bug Fixes
42
-
43
- * **release:** unblock lerna 9 publish (access via publishConfig) ([#637](https://github.com/canonical/pragma/issues/637)) ([acc1185](https://github.com/canonical/pragma/commit/acc1185b43290c1edd88da25c000f7d9494caee6))
44
-
45
-
46
-
47
-
48
-
49
- # [0.27.0](https://github.com/canonical/pragma/compare/v0.26.0...v0.27.0) (2026-04-29)
50
-
51
- **Note:** Version bump only for package @canonical/summon-component
52
-
53
-
54
-
55
-
56
-
57
- # [0.26.0](https://github.com/canonical/pragma/compare/v0.25.0...v0.26.0) (2026-04-24)
58
-
59
- **Note:** Version bump only for package @canonical/summon-component
60
-
61
-
62
-
63
-
64
-
65
- # [0.25.0](https://github.com/canonical/pragma/compare/v0.24.0...v0.25.0) (2026-04-17)
66
-
67
- **Note:** Version bump only for package @canonical/summon-component
68
-
69
-
70
-
71
-
72
-
73
- # [0.24.0](https://github.com/canonical/pragma/compare/v0.23.0...v0.24.0) (2026-04-13)
74
-
75
- **Note:** Version bump only for package @canonical/summon-component
76
-
77
-
78
-
79
-
80
-
81
- # [0.23.0](https://github.com/canonical/pragma/compare/v0.22.1...v0.23.0) (2026-04-07)
82
-
83
- **Note:** Version bump only for package @canonical/summon-component
84
-
85
-
86
-
87
-
88
-
89
- # [0.22.0](https://github.com/canonical/pragma/compare/v0.22.0-experimental.0...v0.22.0) (2026-04-03)
90
-
91
- **Note:** Version bump only for package @canonical/summon-component
92
-
93
-
94
-
95
-
96
-
97
- # [0.21.0](https://github.com/canonical/pragma/compare/v0.20.1...v0.21.0) (2026-04-01)
98
-
99
- **Note:** Version bump only for package @canonical/summon-component
100
-
101
-
102
-
103
-
104
-
105
- # [0.20.0](https://github.com/canonical/pragma/compare/v0.19.0...v0.20.0) (2026-03-26)
106
-
107
- **Note:** Version bump only for package @canonical/summon-component
108
-
109
-
110
-
111
-
112
-
113
- # [0.19.0](https://github.com/canonical/pragma/compare/v0.18.0...v0.19.0) (2026-03-26)
114
-
115
-
116
- ### Bug Fixes
117
-
118
- * **summon-component:** duplication of "generated by" comment ([#495](https://github.com/canonical/pragma/issues/495)) ([c52a374](https://github.com/canonical/pragma/commit/c52a374a85a9f703d0ff04b3fc3fd6d18370c458))
119
-
120
-
121
- ### Features
122
-
123
- * **react-ds-global:** announcement component ([#554](https://github.com/canonical/pragma/issues/554)) ([e5434d0](https://github.com/canonical/pragma/commit/e5434d05421090cb77c227ccaa6025983c9a292c))
124
- * **task,summon-core:** extract @canonical/task, restructure summon as @canonical/summon-core (v0.1-P1+P2) ([#484](https://github.com/canonical/pragma/issues/484)) ([1493baf](https://github.com/canonical/pragma/commit/1493baf6b28a9d5cbd7e4e13009f105945df72a9))
125
- * **task:** add undo interpreter and --undo flag across CLI ([#538](https://github.com/canonical/pragma/issues/538)) ([8c2fff5](https://github.com/canonical/pragma/commit/8c2fff58eb4e5527e4ca2aa1bd7e9f42b3cf70ee))
126
-
127
-
128
-
129
-
130
-
131
- # [0.18.0](https://github.com/canonical/pragma/compare/v0.17.1...v0.18.0) (2026-03-11)
132
-
133
- **Note:** Version bump only for package @canonical/summon-component
134
-
135
-
136
-
137
-
138
-
139
- ## [0.17.1](https://github.com/canonical/pragma/compare/v0.17.0...v0.17.1) (2026-03-04)
140
-
141
- **Note:** Version bump only for package @canonical/summon-component
142
-
143
-
144
-
145
-
146
-
147
- # [0.17.0](https://github.com/canonical/pragma/compare/v0.16.0...v0.17.0) (2026-03-04)
148
-
149
-
150
- ### Features
151
-
152
- * **summon:** summon component webcomponents ([#448](https://github.com/canonical/pragma/issues/448)) ([ae5d33d](https://github.com/canonical/pragma/commit/ae5d33d052f7c05be292e6a565cf371f47868274))
153
-
154
-
155
-
156
-
157
-
158
- # [0.16.0](https://github.com/canonical/pragma/compare/v0.16.0-experimental.1...v0.16.0) (2026-03-03)
159
-
160
- **Note:** Version bump only for package @canonical/summon-component
161
-
162
-
163
-
164
-
165
-
166
- # [0.16.0-experimental.1](https://github.com/canonical/pragma/compare/v0.16.0-experimental.0...v0.16.0-experimental.1) (2026-03-03)
167
-
168
- **Note:** Version bump only for package @canonical/summon-component
169
-
170
-
171
-
172
-
173
-
174
- # [0.16.0-experimental.0](https://github.com/canonical/pragma/compare/v0.15.1...v0.16.0-experimental.0) (2026-02-24)
175
-
176
-
177
- ### Features
178
-
179
- * **svelte-ds-app-launchpad:** upstream Chip component and update styles ([#423](https://github.com/canonical/pragma/issues/423)) ([26d1047](https://github.com/canonical/pragma/commit/26d104771a0df4ece538bd268b2141c30267b60c))
180
-
181
-
182
-
183
-
184
-
185
- ## [0.15.1](https://github.com/canonical/pragma/compare/v0.15.0...v0.15.1) (2026-02-23)
186
-
187
- **Note:** Version bump only for package @canonical/summon-component
188
-
189
-
190
-
191
-
192
-
193
- # [0.15.0](https://github.com/canonical/pragma/compare/v0.15.0-experimental.0...v0.15.0) (2026-02-20)
194
-
195
-
196
- ### Bug Fixes
197
-
198
- * **react-ds-global:** Fixes transitional export patterns for components ([#426](https://github.com/canonical/pragma/issues/426)) ([db8a1db](https://github.com/canonical/pragma/commit/db8a1dba10419153f6be82ffee570c9db929dff7))
199
-
200
-
201
-
202
-
203
-
204
- # [0.15.0-experimental.0](https://github.com/canonical/pragma/compare/v0.14.0...v0.15.0-experimental.0) (2026-02-17)
205
-
206
-
207
- ### Features
208
-
209
- * **svelte-generator:** update Svelte component templates ([#422](https://github.com/canonical/pragma/issues/422)) ([f1fb13f](https://github.com/canonical/pragma/commit/f1fb13fa08463b844e611ae5cd0f94a06b13ff30))
210
-
211
-
212
-
213
-
214
-
215
- # [0.14.0](https://github.com/canonical/pragma/compare/v0.13.0...v0.14.0) (2026-02-16)
216
-
217
- **Note:** Version bump only for package @canonical/summon-component
218
-
219
-
220
-
221
-
222
-
223
- # [0.13.0](https://github.com/canonical/pragma/compare/v0.13.0-experimental.0...v0.13.0) (2026-02-10)
224
-
225
- **Note:** Version bump only for package @canonical/summon-component
226
-
227
-
228
-
229
-
230
-
231
- # [0.12.0](https://github.com/canonical/pragma/compare/v0.12.0-experimental.0...v0.12.0) (2026-02-06)
232
-
233
- **Note:** Version bump only for package @canonical/summon-component
234
-
235
-
236
-
237
-
238
-
239
- # [0.12.0-experimental.0](https://github.com/canonical/pragma/compare/v0.11.0...v0.12.0-experimental.0) (2026-01-26)
240
-
241
-
242
- ### Features
243
-
244
- * **components:** Ft components ([#393](https://github.com/canonical/pragma/issues/393)) ([abbe615](https://github.com/canonical/pragma/commit/abbe6150c52deefffb7e9e7fbfee8a3b6ffb94c6))
245
- * **summon:** new codegen ([#388](https://github.com/canonical/pragma/issues/388)) ([bcd1f35](https://github.com/canonical/pragma/commit/bcd1f350fd8799a580511e783a4292911fd5cc33))