@canonical/summon-component 0.12.0-experimental.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.13.0](https://github.com/canonical/pragma/compare/v0.13.0-experimental.0...v0.13.0) (2026-02-10)
7
+
8
+ **Note:** Version bump only for package @canonical/summon-component
9
+
10
+
11
+
12
+
13
+
14
+ # [0.12.0](https://github.com/canonical/pragma/compare/v0.12.0-experimental.0...v0.12.0) (2026-02-06)
15
+
16
+ **Note:** Version bump only for package @canonical/summon-component
17
+
18
+
19
+
20
+
21
+
6
22
  # [0.12.0-experimental.0](https://github.com/canonical/pragma/compare/v0.11.0...v0.12.0-experimental.0) (2026-01-26)
7
23
 
8
24
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/summon-component",
3
3
  "description": "Component generators for Summon - React and Svelte component scaffolding",
4
- "version": "0.12.0-experimental.0",
4
+ "version": "0.13.0",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "author": {
@@ -29,15 +29,17 @@
29
29
  "test": "vitest run"
30
30
  },
31
31
  "devDependencies": {
32
- "@biomejs/biome": "2.3.11",
33
- "@canonical/biome-config": "^0.11.0",
34
- "@canonical/typescript-config-base": "^0.11.0",
35
- "bun-types": "^1.0.0",
32
+ "@biomejs/biome": "2.3.14",
33
+ "@canonical/biome-config": "^0.13.0",
34
+ "@canonical/typescript-config": "^0.13.0",
35
+ "@canonical/webarchitect": "^0.13.0",
36
+ "@types/bun": "^1.3.8",
37
+ "@types/node": "^24.10.13",
36
38
  "typescript": "^5.9.3",
37
- "vitest": "^3.2.4"
39
+ "vitest": "^4.0.18"
38
40
  },
39
41
  "peerDependencies": {
40
42
  "@canonical/summon": "^0.1.0"
41
43
  },
42
- "gitHead": "0e56eee8b9ff804c676811e1fe55e2716d11db5b"
44
+ "gitHead": "d3e94d6a33677afef24ba1b967920bc513e1681c"
43
45
  }
@@ -66,7 +66,7 @@ describe("component/react generator", () => {
66
66
 
67
67
  it("has examples", () => {
68
68
  expect(generator.meta.examples).toBeDefined();
69
- expect(generator.meta.examples!.length).toBeGreaterThan(0);
69
+ expect(generator.meta.examples?.length).toBeGreaterThan(0);
70
70
  });
71
71
  });
72
72
 
@@ -74,29 +74,29 @@ describe("component/react generator", () => {
74
74
  it("has componentPath prompt", () => {
75
75
  const prompt = generator.prompts.find((p) => p.name === "componentPath");
76
76
  expect(prompt).toBeDefined();
77
- expect(prompt!.type).toBe("text");
78
- expect(prompt!.default).toBe("src/components/MyComponent");
77
+ expect(prompt?.type).toBe("text");
78
+ expect(prompt?.default).toBe("src/components/MyComponent");
79
79
  });
80
80
 
81
81
  it("has withStyles prompt", () => {
82
82
  const prompt = generator.prompts.find((p) => p.name === "withStyles");
83
83
  expect(prompt).toBeDefined();
84
- expect(prompt!.type).toBe("confirm");
85
- expect(prompt!.default).toBe(true);
84
+ expect(prompt?.type).toBe("confirm");
85
+ expect(prompt?.default).toBe(true);
86
86
  });
87
87
 
88
88
  it("has withStories prompt", () => {
89
89
  const prompt = generator.prompts.find((p) => p.name === "withStories");
90
90
  expect(prompt).toBeDefined();
91
- expect(prompt!.type).toBe("confirm");
92
- expect(prompt!.default).toBe(true);
91
+ expect(prompt?.type).toBe("confirm");
92
+ expect(prompt?.default).toBe(true);
93
93
  });
94
94
 
95
95
  it("has withSsrTests prompt", () => {
96
96
  const prompt = generator.prompts.find((p) => p.name === "withSsrTests");
97
97
  expect(prompt).toBeDefined();
98
- expect(prompt!.type).toBe("confirm");
99
- expect(prompt!.default).toBe(true);
98
+ expect(prompt?.type).toBe("confirm");
99
+ expect(prompt?.default).toBe(true);
100
100
  });
101
101
  });
102
102
 
@@ -202,7 +202,7 @@ describe("component/react generator", () => {
202
202
 
203
203
  expect(parentIndex).toBeDefined();
204
204
  const content = (parentIndex as { content: string }).content;
205
- expect(content).toContain('export * from "./Card"');
205
+ expect(content).toContain('export * from "./Card/index.js"');
206
206
  });
207
207
  });
208
208
  });
@@ -228,14 +228,14 @@ describe("component/svelte generator", () => {
228
228
  it("has componentPath prompt with svelte default", () => {
229
229
  const prompt = generator.prompts.find((p) => p.name === "componentPath");
230
230
  expect(prompt).toBeDefined();
231
- expect(prompt!.default).toBe("src/lib/components/MyComponent");
231
+ expect(prompt?.default).toBe("src/lib/components/MyComponent");
232
232
  });
233
233
 
234
234
  it("has useTsStories prompt", () => {
235
235
  const prompt = generator.prompts.find((p) => p.name === "useTsStories");
236
236
  expect(prompt).toBeDefined();
237
- expect(prompt!.type).toBe("confirm");
238
- expect(prompt!.default).toBe(false);
237
+ expect(prompt?.type).toBe("confirm");
238
+ expect(prompt?.default).toBe(false);
239
239
  });
240
240
  });
241
241
 
@@ -22,13 +22,13 @@ export const appendExportToParentIndex = (
22
22
  componentName: string,
23
23
  ): Task<void> => {
24
24
  const indexPath = path.join(parentDir, "index.ts");
25
- const exportLine = `export * from "./${componentName}";\n`;
25
+ const exportLine = `export * from "./${componentName}/index.js";\n`;
26
26
 
27
27
  return ifElseM(
28
28
  exists(indexPath),
29
29
  // If exists, append (if not already exported)
30
30
  flatMap(readFile(indexPath), (content) => {
31
- if (content.includes(`"./${componentName}"`)) {
31
+ if (content.includes(`./${componentName}`)) {
32
32
  return pure(undefined); // Already exported
33
33
  }
34
34
  return appendFile(indexPath, exportLine);
@@ -1,24 +1,29 @@
1
1
  // Generated by <%= generatorName %> v<%= version %>
2
2
 
3
- import type { <%= name %>Props } from "./types";
3
+ import type React from "react";
4
+ import type { <%= name %>Props } from "./types.js";
4
5
  <% if (withStyles) { -%>
5
6
  import "./styles.css";
6
7
  <% } -%>
7
8
 
9
+ const componentCssClassName = "ds <%= kebabName %>";
10
+
8
11
  /**
9
12
  * <%= name %> component
10
13
  */
11
- export const <%= name %> = ({
14
+ const <%= name %> = ({
12
15
  className,
13
16
  children,
14
17
  ...props
15
- }: <%= name %>Props): JSX.Element => {
18
+ }: <%= name %>Props): React.ReactElement => {
16
19
  return (
17
20
  <div
18
- className={`<%= kebabName %>${className ? ` ${className}` : ""}`}
21
+ className={[componentCssClassName, className].filter(Boolean).join(" ")}
19
22
  {...props}
20
23
  >
21
24
  {children}
22
25
  </div>
23
26
  );
24
27
  };
28
+
29
+ export default <%= name %>;
@@ -1,4 +1,4 @@
1
1
  // Generated by <%= generatorName %> v<%= version %>
2
2
 
3
- export { <%= name %> } from "./<%= name %>";
4
- export type { <%= name %>Props } from "./types";
3
+ export { default } from "./<%= name %>.js";
4
+ export type * from "./types.js";
@@ -2,12 +2,12 @@
2
2
 
3
3
  import { describe, expect, it } from "vitest";
4
4
  import { renderToString } from "react-dom/server";
5
- import { <%= name %> } from "./<%= name %>";
5
+ import <%= name %> from "./<%= name %>.js";
6
6
 
7
7
  describe("<%= name %> SSR", () => {
8
8
  it("renders without hydration errors", () => {
9
9
  const html = renderToString(<<%= name %>>Test content</<%= name %>>);
10
10
  expect(html).toContain("Test content");
11
- expect(html).toContain("<%= kebabName %>");
11
+ expect(html).toContain("ds <%= kebabName %>");
12
12
  });
13
13
  });
@@ -1,7 +1,7 @@
1
1
  // Generated by <%= generatorName %> v<%= version %>
2
2
 
3
3
  import type { Meta, StoryObj } from "@storybook/react";
4
- import { <%= name %> } from "./<%= name %>";
4
+ import <%= name %> from "./<%= name %>.js";
5
5
 
6
6
  const meta: Meta<typeof <%= name %>> = {
7
7
  title: "Components/<%= name %>",
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { describe, expect, it } from "vitest";
4
4
  import { render, screen } from "@testing-library/react";
5
- import { <%= name %> } from "./<%= name %>";
5
+ import <%= name %> from "./<%= name %>.js";
6
6
 
7
7
  describe("<%= name %>", () => {
8
8
  it("renders children", () => {
@@ -13,8 +13,8 @@ describe("<%= name %>", () => {
13
13
  it("applies custom className", () => {
14
14
  render(<<%= name %> className="custom-class">Content</<%= name %>>);
15
15
  const element = screen.getByText("Content");
16
- expect(element).toHaveClass("<%= kebabName %>");
17
- expect(element).toHaveClass("custom-class");
16
+ expect(element.className).toContain("ds <%= kebabName %>");
17
+ expect(element.className).toContain("custom-class");
18
18
  });
19
19
 
20
20
  it("passes through additional props", () => {
@@ -1,5 +1,5 @@
1
1
  /* Generated by <%= generatorName %> v<%= version %> */
2
2
 
3
- .<%= kebabName %> {
3
+ .ds.<%= kebabName %> {
4
4
  /* Component styles */
5
5
  }
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
- "extends": "@canonical/typescript-config-base",
2
+ "extends": "@canonical/typescript-config",
3
3
  "compilerOptions": {
4
- "types": ["node", "bun-types"],
4
+ "types": ["node", "@types/bun"],
5
5
  "jsx": "react-jsx",
6
6
  "skipLibCheck": true
7
7
  },