@canonical/summon-component 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -21
- package/dist/esm/lit/generator.js +15 -26
- package/dist/esm/lit/generator.js.map +1 -1
- package/dist/esm/react/generator.js +10 -8
- package/dist/esm/react/generator.js.map +1 -1
- package/dist/esm/shared/createTemplateContext.js +5 -5
- package/dist/esm/shared/createTemplateContext.js.map +1 -1
- package/dist/esm/shared/failIfComponentExists.js +20 -0
- package/dist/esm/shared/failIfComponentExists.js.map +1 -0
- package/dist/esm/shared/file-operations/appendExportToParentIndex.js +24 -3
- package/dist/esm/shared/file-operations/appendExportToParentIndex.js.map +1 -1
- package/dist/esm/shared/file-operations/removeLineFromFile.js +25 -8
- package/dist/esm/shared/file-operations/removeLineFromFile.js.map +1 -1
- package/dist/esm/shared/index.js +2 -0
- package/dist/esm/shared/index.js.map +1 -1
- package/dist/esm/shared/loadTemplate.js +6 -2
- package/dist/esm/shared/loadTemplate.js.map +1 -1
- package/dist/esm/shared/packageVersion.js +50 -0
- package/dist/esm/shared/packageVersion.js.map +1 -0
- package/dist/esm/svelte/generator.js +11 -9
- package/dist/esm/svelte/generator.js.map +1 -1
- package/dist/types/index.d.ts +9 -21
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lit/generator.d.ts +8 -19
- package/dist/types/lit/generator.d.ts.map +1 -1
- package/dist/types/lit/types.d.ts +6 -2
- package/dist/types/lit/types.d.ts.map +1 -1
- package/dist/types/react/generator.d.ts +2 -2
- package/dist/types/react/generator.d.ts.map +1 -1
- package/dist/types/shared/createTemplateContext.d.ts +5 -3
- package/dist/types/shared/createTemplateContext.d.ts.map +1 -1
- package/dist/types/shared/failIfComponentExists.d.ts +11 -0
- package/dist/types/shared/failIfComponentExists.d.ts.map +1 -0
- package/dist/types/shared/file-operations/appendExportToParentIndex.d.ts.map +1 -1
- package/dist/types/shared/file-operations/removeLineFromFile.d.ts +5 -2
- package/dist/types/shared/file-operations/removeLineFromFile.d.ts.map +1 -1
- package/dist/types/shared/index.d.ts +2 -0
- package/dist/types/shared/index.d.ts.map +1 -1
- package/dist/types/shared/loadTemplate.d.ts.map +1 -1
- package/dist/types/shared/packageVersion.d.ts +15 -0
- package/dist/types/shared/packageVersion.d.ts.map +1 -0
- package/dist/types/shared/types.d.ts +0 -4
- package/dist/types/shared/types.d.ts.map +1 -1
- package/dist/types/svelte/generator.d.ts +4 -4
- package/dist/types/svelte/generator.d.ts.map +1 -1
- package/package.json +9 -13
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ src/components/Button/
|
|
|
91
91
|
And appends to `src/components/index.ts`:
|
|
92
92
|
|
|
93
93
|
```typescript
|
|
94
|
-
export * from "./Button";
|
|
94
|
+
export * from "./Button/index.js";
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
#### Generated Component
|
|
@@ -198,7 +198,7 @@ src/lib/Button/
|
|
|
198
198
|
├── Button.ts # Lit element implementation
|
|
199
199
|
├── types.ts # Props interface
|
|
200
200
|
├── index.ts # Barrel export
|
|
201
|
-
├── Button.
|
|
201
|
+
├── Button.test.ts # Unit tests (Vitest + shadow DOM)
|
|
202
202
|
├── Button.stories.ts # Storybook stories (optional)
|
|
203
203
|
└── styles.css # Component styles as CSSResult (optional)
|
|
204
204
|
```
|
|
@@ -271,7 +271,7 @@ export interface ButtonProps {
|
|
|
271
271
|
#### Generated Test
|
|
272
272
|
|
|
273
273
|
```typescript
|
|
274
|
-
// Button.
|
|
274
|
+
// Button.test.ts
|
|
275
275
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
276
276
|
import "./Button.js";
|
|
277
277
|
import type Button from "./Button.js";
|
|
@@ -332,25 +332,19 @@ export const Default: Story = {
|
|
|
332
332
|
| Flag | Description | Default |
|
|
333
333
|
|------|-------------|---------|
|
|
334
334
|
| `--component-path` | Full path for the component (e.g., `src/components/Button`) | Interactive prompt |
|
|
335
|
-
| `--with-styles` |
|
|
336
|
-
| `--no-with-
|
|
337
|
-
| `--with-
|
|
338
|
-
| `--no-with-stories` | Skip stories file | — |
|
|
339
|
-
| `--with-ssr-tests` | Include SSR test file | `true` |
|
|
340
|
-
| `--no-with-ssr-tests` | Skip SSR tests | — |
|
|
335
|
+
| `--no-with-styles` | Skip the `styles.css` file (included by default) | styles on |
|
|
336
|
+
| `--no-with-stories` | Skip the Storybook stories (included by default) | stories on |
|
|
337
|
+
| `--no-with-ssr-tests` | Skip the SSR test file (included by default) | SSR tests on |
|
|
341
338
|
|
|
342
339
|
### Svelte Options
|
|
343
340
|
|
|
344
341
|
| Flag | Description | Default |
|
|
345
342
|
|------|-------------|---------|
|
|
346
343
|
| `--component-path` | Full path for the component (e.g., `src/lib/components/Card`) | Interactive prompt |
|
|
347
|
-
| `--with-styles` |
|
|
348
|
-
| `--no-with-
|
|
349
|
-
| `--with-stories` | Include Storybook stories | `true` |
|
|
350
|
-
| `--no-with-stories` | Skip stories | — |
|
|
344
|
+
| `--no-with-styles` | Skip the external `styles.css` import (included by default) | styles on |
|
|
345
|
+
| `--no-with-stories` | Skip the Storybook stories (included by default) | stories on |
|
|
351
346
|
| `--use-ts-stories` | Use `.stories.ts` instead of `.stories.svelte` | `false` |
|
|
352
|
-
| `--with-ssr-tests` |
|
|
353
|
-
| `--no-with-ssr-tests` | Skip SSR tests | — |
|
|
347
|
+
| `--no-with-ssr-tests` | Skip the SSR test file (included by default) | SSR tests on |
|
|
354
348
|
|
|
355
349
|
### Global Options
|
|
356
350
|
|
|
@@ -366,10 +360,8 @@ export const Default: Story = {
|
|
|
366
360
|
| Flag | Description | Default |
|
|
367
361
|
|------|-------------|---------|
|
|
368
362
|
| `--component-path` | Full path for the component (e.g., `src/lib/Button`) | Interactive prompt |
|
|
369
|
-
| `--with-styles` |
|
|
370
|
-
| `--no-with-
|
|
371
|
-
| `--with-stories` | Include Storybook stories | `true` |
|
|
372
|
-
| `--no-with-stories` | Skip stories file | — |
|
|
363
|
+
| `--no-with-styles` | Skip the `styles.css` file (included by default) | styles on |
|
|
364
|
+
| `--no-with-stories` | Skip the Storybook stories (included by default) | stories on |
|
|
373
365
|
|
|
374
366
|
---
|
|
375
367
|
|
|
@@ -403,7 +395,7 @@ summon component react --component-path=src/components/Button
|
|
|
403
395
|
Appends to `src/components/index.ts`:
|
|
404
396
|
|
|
405
397
|
```typescript
|
|
406
|
-
export * from "./Button";
|
|
398
|
+
export * from "./Button/index.js";
|
|
407
399
|
```
|
|
408
400
|
|
|
409
401
|
If the barrel file doesn't exist, it's created.
|
|
@@ -471,7 +463,7 @@ export const generators = {
|
|
|
471
463
|
|
|
472
464
|
### Modify Templates
|
|
473
465
|
|
|
474
|
-
Fork the package and edit templates in `src/react/templates
|
|
466
|
+
Fork the package and edit templates in `src/templates/react/`, `src/templates/svelte/`, or `src/templates/lit/` — plus `src/templates/shared/`, which holds the framework-agnostic templates (currently `styles.css.ejs`, the generated stylesheet rendered by the React and Svelte generators; Lit ships its own). Templates use [EJS syntax](https://ejs.co/).
|
|
475
467
|
|
|
476
468
|
---
|
|
477
469
|
|
|
@@ -4,24 +4,23 @@
|
|
|
4
4
|
* Generates a Lit web component with a consistent file structure:
|
|
5
5
|
* - `ComponentName.ts` - Main component file (Lit element)
|
|
6
6
|
* - `index.ts` - Barrel export
|
|
7
|
-
* - `ComponentName.
|
|
7
|
+
* - `ComponentName.test.ts` - Unit tests with Vitest
|
|
8
8
|
* - `ComponentName.stories.ts` - Storybook stories (optional)
|
|
9
9
|
* - `styles.css` - CSS styles (optional)
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```bash
|
|
13
13
|
* summon component lit --component-path=src/lib/components/Button
|
|
14
|
-
* summon component lit --component-path=src/lib/components/Card --with-styles --with-stories
|
|
14
|
+
* summon component lit --component-path=src/lib/components/Card --no-with-styles --no-with-stories
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
19
|
import * as path from "node:path";
|
|
20
20
|
import { fileURLToPath } from "node:url";
|
|
21
|
-
import { template } from "@canonical/summon-core";
|
|
21
|
+
import { loadTemplateSync, template, } from "@canonical/summon-core";
|
|
22
22
|
import { debug, info, mkdir, sequence_, when } from "@canonical/task";
|
|
23
|
-
import { appendExportToParentIndex, createComponentPathPrompt, createTemplateContext, getComponentName, getParentDir, PACKAGE_NAME, } from "../shared/index.js";
|
|
24
|
-
import { loadTemplateSync } from "../shared/loadTemplate.js";
|
|
23
|
+
import { appendExportToParentIndex, createComponentPathPrompt, createTemplateContext, failIfComponentExists, getComponentName, getParentDir, PACKAGE_NAME, packageVersion, sharedPrompts, } from "../shared/index.js";
|
|
25
24
|
// =============================================================================
|
|
26
25
|
// Template Paths & Content (loaded LAZILY on first generate())
|
|
27
26
|
// =============================================================================
|
|
@@ -52,22 +51,9 @@ function litTemplates() {
|
|
|
52
51
|
// =============================================================================
|
|
53
52
|
// Custom Prompts (without SSR tests)
|
|
54
53
|
// =============================================================================
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
type: "confirm",
|
|
59
|
-
message: "Include styles?",
|
|
60
|
-
default: true,
|
|
61
|
-
group: "Options",
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: "withStories",
|
|
65
|
-
type: "confirm",
|
|
66
|
-
message: "Include Storybook stories?",
|
|
67
|
-
default: true,
|
|
68
|
-
group: "Options",
|
|
69
|
-
},
|
|
70
|
-
];
|
|
54
|
+
// Reuse the shared prompt definitions rather than duplicating them; lit only
|
|
55
|
+
// drops the SSR-tests flag it never acts on.
|
|
56
|
+
const litPrompts = sharedPrompts.filter((prompt) => prompt.name !== "withSsrTests");
|
|
71
57
|
// =============================================================================
|
|
72
58
|
// Generator Definition
|
|
73
59
|
// =============================================================================
|
|
@@ -84,7 +70,7 @@ const generator = {
|
|
|
84
70
|
name: "component/lit",
|
|
85
71
|
displayName: `${PACKAGE_NAME}:lit`,
|
|
86
72
|
description: "Generate a Lit web component with TypeScript, tests, stories, and styles",
|
|
87
|
-
version:
|
|
73
|
+
version: packageVersion(),
|
|
88
74
|
help: `Generate a Lit web component with TypeScript, tests, stories, and styles.
|
|
89
75
|
|
|
90
76
|
FEATURES:
|
|
@@ -96,10 +82,10 @@ FEATURES:
|
|
|
96
82
|
|
|
97
83
|
The component name is extracted from the path and must be PascalCase.
|
|
98
84
|
For example, 'src/lib/components/Button' creates a 'Button' component
|
|
99
|
-
with the custom element tag 'button'.`,
|
|
85
|
+
with the custom element tag 'ds-button'.`,
|
|
100
86
|
examples: [
|
|
101
87
|
"summon component lit --component-path=src/lib/components/Button",
|
|
102
|
-
"summon component lit --component-path=src/lib/components/Card --with-styles --with-stories",
|
|
88
|
+
"summon component lit --component-path=src/lib/components/Card --no-with-styles --no-with-stories",
|
|
103
89
|
"summon component lit --component-path=src/lib/components/Modal --no-with-styles",
|
|
104
90
|
"summon component lit --component-path=src/lib/components/Button --dry-run",
|
|
105
91
|
],
|
|
@@ -109,10 +95,13 @@ with the custom element tag 'button'.`,
|
|
|
109
95
|
const componentName = getComponentName(answers.componentPath);
|
|
110
96
|
const componentDir = answers.componentPath;
|
|
111
97
|
const parentDir = getParentDir(answers.componentPath);
|
|
112
|
-
const ctx = createTemplateContext(answers
|
|
98
|
+
const ctx = createTemplateContext(answers);
|
|
113
99
|
const t = litTemplates();
|
|
114
100
|
return sequence_([
|
|
115
101
|
info(`Generating Lit web component: ${componentName}`),
|
|
102
|
+
// Refuse to scaffold over an existing component: the writes' delete
|
|
103
|
+
// undos would otherwise let --undo destroy pre-existing files.
|
|
104
|
+
failIfComponentExists(componentDir),
|
|
116
105
|
debug("Creating component directory"),
|
|
117
106
|
mkdir(componentDir),
|
|
118
107
|
debug("Creating main component file"),
|
|
@@ -140,7 +129,7 @@ with the custom element tag 'button'.`,
|
|
|
140
129
|
template({
|
|
141
130
|
source: t.tests.source,
|
|
142
131
|
content: t.tests.content,
|
|
143
|
-
dest: path.join(componentDir, `${componentName}.
|
|
132
|
+
dest: path.join(componentDir, `${componentName}.test.ts`),
|
|
144
133
|
vars: ctx,
|
|
145
134
|
}),
|
|
146
135
|
when(answers.withStories, debug("Creating stories file")),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/lit/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/lit/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAEL,gBAAgB,EAChB,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,GACd,MAAM,oBAAoB,CAAC;AAG5B,gFAAgF;AAChF,+DAA+D;AAC/D,gFAAgF;AAEhF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAE7D,oEAAoE;AACpE,SAAS,gBAAgB;IACvB,OAAO;QACL,SAAS,EAAE,gBAAgB,CACzB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,KA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AC9D,CAAC,CAAC;IACL,CAAC;CACiD,CAAC;AAErD,eAAe,SAAS,CAAC"}
|
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import * as path from "node:path";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
17
|
-
import { template } from "@canonical/summon-core";
|
|
17
|
+
import { loadTemplateSync, template, } from "@canonical/summon-core";
|
|
18
18
|
import { debug, info, mkdir, sequence_, when } from "@canonical/task";
|
|
19
|
-
import { appendExportToParentIndex, createComponentPathPrompt, createTemplateContext, getComponentName, getParentDir, PACKAGE_NAME, sharedPrompts, } from "../shared/index.js";
|
|
20
|
-
import { loadTemplateSync } from "../shared/loadTemplate.js";
|
|
19
|
+
import { appendExportToParentIndex, createComponentPathPrompt, createTemplateContext, failIfComponentExists, getComponentName, getParentDir, PACKAGE_NAME, packageVersion, sharedPrompts, } from "../shared/index.js";
|
|
21
20
|
// =============================================================================
|
|
22
21
|
// Template Paths & Content (loaded LAZILY on first generate())
|
|
23
22
|
// =============================================================================
|
|
@@ -55,7 +54,7 @@ const generator = {
|
|
|
55
54
|
name: "component/react",
|
|
56
55
|
displayName: `${PACKAGE_NAME}:react`,
|
|
57
56
|
description: "Generate a React component with TypeScript, tests, stories, and styles",
|
|
58
|
-
version:
|
|
57
|
+
version: packageVersion(),
|
|
59
58
|
help: `Generate a React component with TypeScript, tests, stories, and styles.
|
|
60
59
|
|
|
61
60
|
FEATURES:
|
|
@@ -70,7 +69,7 @@ The component name is extracted from the path and must be PascalCase.
|
|
|
70
69
|
For example, 'src/components/Button' creates a 'Button' component.`,
|
|
71
70
|
examples: [
|
|
72
71
|
"summon component react --component-path=src/components/Button",
|
|
73
|
-
"summon component react --component-path=src/components/Card --with-styles --with-stories",
|
|
72
|
+
"summon component react --component-path=src/components/Card --no-with-styles --no-with-stories",
|
|
74
73
|
"summon component react --component-path=src/components/Modal --no-with-ssr-tests",
|
|
75
74
|
"summon component react --component-path=src/components/Button --dry-run",
|
|
76
75
|
],
|
|
@@ -80,10 +79,13 @@ For example, 'src/components/Button' creates a 'Button' component.`,
|
|
|
80
79
|
const componentName = getComponentName(answers.componentPath);
|
|
81
80
|
const componentDir = answers.componentPath;
|
|
82
81
|
const parentDir = getParentDir(answers.componentPath);
|
|
83
|
-
const ctx = createTemplateContext(answers
|
|
82
|
+
const ctx = createTemplateContext(answers);
|
|
84
83
|
const t = reactTemplates();
|
|
85
84
|
return sequence_([
|
|
86
85
|
info(`Generating React component: ${componentName}`),
|
|
86
|
+
// Refuse to scaffold over an existing component: the writes' delete
|
|
87
|
+
// undos would otherwise let --undo destroy pre-existing files.
|
|
88
|
+
failIfComponentExists(componentDir),
|
|
87
89
|
debug("Creating component directory"),
|
|
88
90
|
mkdir(componentDir),
|
|
89
91
|
debug("Creating main component file"),
|
|
@@ -111,14 +113,14 @@ For example, 'src/components/Button' creates a 'Button' component.`,
|
|
|
111
113
|
template({
|
|
112
114
|
source: t.test.source,
|
|
113
115
|
content: t.test.content,
|
|
114
|
-
dest: path.join(componentDir, `${componentName}.
|
|
116
|
+
dest: path.join(componentDir, `${componentName}.test.tsx`),
|
|
115
117
|
vars: ctx,
|
|
116
118
|
}),
|
|
117
119
|
when(answers.withSsrTests, debug("Creating SSR test file")),
|
|
118
120
|
when(answers.withSsrTests, template({
|
|
119
121
|
source: t.ssrTest.source,
|
|
120
122
|
content: t.ssrTest.content,
|
|
121
|
-
dest: path.join(componentDir, `${componentName}.ssr.
|
|
123
|
+
dest: path.join(componentDir, `${componentName}.ssr.test.tsx`),
|
|
122
124
|
vars: ctx,
|
|
123
125
|
})),
|
|
124
126
|
when(answers.withStories, debug("Creating stories file")),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/react/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,U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@
|
|
|
3
3
|
*/
|
|
4
4
|
import { getComponentName, kebabCase } from "./string-helpers/index.js";
|
|
5
5
|
/**
|
|
6
|
-
* Create template context from answers
|
|
6
|
+
* Create template context from answers. `withSsrTests` is optional so
|
|
7
|
+
* generators that do not offer SSR tests (lit) can pass their honest answer
|
|
8
|
+
* shape; the context defaults it to false.
|
|
7
9
|
*/
|
|
8
|
-
export default function createTemplateContext(answers
|
|
10
|
+
export default function createTemplateContext(answers) {
|
|
9
11
|
const name = getComponentName(answers.componentPath);
|
|
10
12
|
return {
|
|
11
13
|
name,
|
|
12
14
|
kebabName: kebabCase(name),
|
|
13
|
-
generatorName: `@canonical/summon:component-${framework}`,
|
|
14
|
-
version: "0.1.0",
|
|
15
15
|
withStyles: answers.withStyles,
|
|
16
16
|
withStories: answers.withStories,
|
|
17
|
-
withSsrTests: answers.withSsrTests,
|
|
17
|
+
withSsrTests: answers.withSsrTests ?? false,
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=createTemplateContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTemplateContext.js","sourceRoot":"","sources":["../../../src/shared/createTemplateContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"createTemplateContext.js","sourceRoot":"","sources":["../../../src/shared/createTemplateContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAGxE;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,OACqD;IAErD,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACrD,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC;QAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { exists, fail, flatMap, pure } from "@canonical/task";
|
|
2
|
+
/**
|
|
3
|
+
* Refuse to scaffold over an existing component directory.
|
|
4
|
+
*
|
|
5
|
+
* Every generated write carries a delete as its default undo, so scaffolding
|
|
6
|
+
* over an existing directory and then running `--undo` would destroy files
|
|
7
|
+
* the user owned before the run. The domain/wrapper generators in
|
|
8
|
+
* summon-application guard the same way for the same reason.
|
|
9
|
+
*/
|
|
10
|
+
export default function failIfComponentExists(componentDir) {
|
|
11
|
+
return flatMap(exists(componentDir), (present) => present
|
|
12
|
+
? fail({
|
|
13
|
+
code: "COMPONENT_EXISTS",
|
|
14
|
+
message: `"${componentDir}" already exists. Scaffolding over it would let ` +
|
|
15
|
+
"--undo delete pre-existing files. Choose a different path or " +
|
|
16
|
+
"remove the directory first.",
|
|
17
|
+
})
|
|
18
|
+
: pure(undefined));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=failIfComponentExists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failIfComponentExists.js","sourceRoot":"","sources":["../../../src/shared/failIfComponentExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAa,MAAM,iBAAiB,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,YAAoB;IAEpB,OAAO,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAC/C,OAAO;QACL,CAAC,CAAC,IAAI,CAAC;YACH,IAAI,EAAE,kBAAkB;YACxB,OAAO,EACL,IAAI,YAAY,kDAAkD;gBAClE,+DAA+D;gBAC/D,6BAA6B;SAChC,CAAC;QACJ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CACpB,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import { appendFile, exists, flatMap, ifElseM, pure, readFile, writeFile, } from "@canonical/task";
|
|
3
3
|
import removeLineFromFile from "./removeLineFromFile.js";
|
|
4
|
+
/**
|
|
5
|
+
* A whole star-export line, capturing its module path: either quote style,
|
|
6
|
+
* flexible inner whitespace, optional semicolon.
|
|
7
|
+
*/
|
|
8
|
+
const STAR_EXPORT_LINE = /^export\s*\*\s*from\s*(["'])(.+)\1\s*;?$/;
|
|
4
9
|
/**
|
|
5
10
|
* Append export to parent index.ts file (or create if not exists).
|
|
6
11
|
* Carries undo metadata: removes the export line (or deletes the index
|
|
@@ -8,14 +13,30 @@ import removeLineFromFile from "./removeLineFromFile.js";
|
|
|
8
13
|
*/
|
|
9
14
|
export default function appendExportToParentIndex(parentDir, componentName) {
|
|
10
15
|
const indexPath = path.join(parentDir, "index.ts");
|
|
11
|
-
const
|
|
16
|
+
const modulePath = `./${componentName}/index.js`;
|
|
17
|
+
const exportLine = `export * from "${modulePath}";\n`;
|
|
12
18
|
return ifElseM(exists(indexPath),
|
|
13
19
|
// If exists, append (if not already exported)
|
|
14
20
|
flatMap(readFile(indexPath), (content) => {
|
|
15
|
-
|
|
21
|
+
// Whole-line match on the parsed module path — a substring check on
|
|
22
|
+
// `./${componentName}` would false-positive on prefix-named siblings
|
|
23
|
+
// (adding Button next to an existing ButtonGroup export), while exact
|
|
24
|
+
// string equality would miss a hand-written equivalent in the other
|
|
25
|
+
// quote style or without the semicolon and append a duplicate.
|
|
26
|
+
const alreadyExported = content.split("\n").some((existingLine) => {
|
|
27
|
+
const match = existingLine.trim().match(STAR_EXPORT_LINE);
|
|
28
|
+
return match !== null && match[2] === modulePath;
|
|
29
|
+
});
|
|
30
|
+
if (alreadyExported) {
|
|
16
31
|
return pure(undefined); // Already exported
|
|
17
32
|
}
|
|
18
|
-
|
|
33
|
+
// AppendFile inserts no separator: when the existing content does not
|
|
34
|
+
// end in a newline, lead with one so the export lands on its own line
|
|
35
|
+
// (and the line-based undo below can always match it).
|
|
36
|
+
const chunk = content.length > 0 && !content.endsWith("\n")
|
|
37
|
+
? `\n${exportLine}`
|
|
38
|
+
: exportLine;
|
|
39
|
+
return appendFile(indexPath, chunk, true, {
|
|
19
40
|
undo: removeLineFromFile(indexPath, exportLine),
|
|
20
41
|
});
|
|
21
42
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appendExportToParentIndex.js","sourceRoot":"","sources":["../../../../src/shared/file-operations/appendExportToParentIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,UAAU,EACV,MAAM,EACN,OAAO,EACP,OAAO,EACP,IAAI,EACJ,QAAQ,EAER,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,SAAiB,EACjB,aAAqB;IAErB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"appendExportToParentIndex.js","sourceRoot":"","sources":["../../../../src/shared/file-operations/appendExportToParentIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,UAAU,EACV,MAAM,EACN,OAAO,EACP,OAAO,EACP,IAAI,EACJ,QAAQ,EAER,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AAEzD;;;GAGG;AACH,MAAM,gBAAgB,GAAG,0CAA0C,CAAC;AAEpE;;;;GAIG;AACH,MAAM,CAA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AAE,UAAU,CAAC,CACjC,CAAC;AACJ,CAAC"}
|
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
import { deleteFile, flatMap, readFile, writeFile, } from "@canonical/task";
|
|
1
|
+
import { deleteFile, flatMap, pure, readFile, writeFile, } from "@canonical/task";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Whether every non-blank line is a generator-stamp comment (the header the
|
|
4
|
+
* runner prepends to generated files: `<comment> Generated by <name> v<ver>`).
|
|
5
|
+
* Such a remainder carries no exports of its own, so the file counts as empty
|
|
6
|
+
* when deciding whether to delete it. Vacuously true for a blank remainder.
|
|
7
|
+
*/
|
|
8
|
+
const isEffectivelyEmpty = (content) => content
|
|
9
|
+
.split("\n")
|
|
10
|
+
.map((line) => line.trim())
|
|
11
|
+
.filter((line) => line !== "")
|
|
12
|
+
.every((line) => /^(?:\/\/|\/\*+|\*|#|<!--)\s*Generated by /.test(line));
|
|
13
|
+
/**
|
|
14
|
+
* Remove a specific line from a file (all occurrences, matched by trimmed
|
|
15
|
+
* content). Truly idempotent: when the line is not present the file is left
|
|
16
|
+
* untouched — no rewrite, and a file that was already empty is never deleted.
|
|
17
|
+
* When the removal leaves the file effectively empty (blank, or only
|
|
18
|
+
* generator-stamp comment lines), the file is deleted entirely.
|
|
5
19
|
*/
|
|
6
20
|
export default function removeLineFromFile(filePath, line) {
|
|
7
21
|
return flatMap(readFile(filePath), (content) => {
|
|
8
22
|
const trimmedLine = line.trim();
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.
|
|
13
|
-
|
|
23
|
+
const lines = content.split("\n");
|
|
24
|
+
const kept = lines.filter((l) => l.trim() !== trimmedLine);
|
|
25
|
+
if (kept.length === lines.length) {
|
|
26
|
+
// Line not present: leave the file exactly as it was.
|
|
27
|
+
return pure(undefined);
|
|
28
|
+
}
|
|
29
|
+
const filtered = kept.join("\n");
|
|
30
|
+
if (isEffectivelyEmpty(filtered)) {
|
|
14
31
|
return deleteFile(filePath, { undo: null });
|
|
15
32
|
}
|
|
16
33
|
return writeFile(filePath, filtered, { undo: null });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeLineFromFile.js","sourceRoot":"","sources":["../../../../src/shared/file-operations/removeLineFromFile.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,QAAQ,EAER,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB
|
|
1
|
+
{"version":3,"file":"removeLineFromFile.js","sourceRoot":"","sources":["../../../../src/shared/file-operations/removeLineFromFile.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,IAAI,EACJ,QAAQ,EAER,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAW,EAAE,CACtD,OAAO;KACJ,KAAK,CAAC,IAAI,CAAC;KACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;KAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;KAC7B,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,2CAA2C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,QAAgB,EAChB,IAAY;IAEZ,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE;QAC7C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,WAAW,CAAC,CAAC;QAE3D,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;YACjC,sDAAsD;YACtD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjC,OAAO,UAAU,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/esm/shared/index.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { default as createComponentPathPrompt } from "./createComponentPathPrompt.js";
|
|
5
5
|
export { default as createTemplateContext } from "./createTemplateContext.js";
|
|
6
|
+
export { default as failIfComponentExists } from "./failIfComponentExists.js";
|
|
6
7
|
export * from "./file-operations/index.js";
|
|
7
8
|
export { PACKAGE_NAME } from "./packageName.js";
|
|
9
|
+
export { packageVersion } from "./packageVersion.js";
|
|
8
10
|
export { default as sharedPrompts } from "./sharedPrompts.js";
|
|
9
11
|
export * from "./string-helpers/index.js";
|
|
10
12
|
export { default as validateComponentPath } from "./validateComponentPath.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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;AAE1C,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","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,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC9E,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,cAAc,2BAA2B,CAAC;AAE1C,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -48,11 +48,15 @@ export function setEmbeddedTemplates(manifest) {
|
|
|
48
48
|
* `template()` and read from disk, so no manifest entry could serve them.
|
|
49
49
|
*/
|
|
50
50
|
function qualifiedKey(source) {
|
|
51
|
+
// Manifest keys are always forward-slash; sources are built with path.join,
|
|
52
|
+
// which yields backslashes on Windows — normalize before matching so a
|
|
53
|
+
// compiled binary resolves its templates there too.
|
|
54
|
+
const normalized = source.replaceAll("\\", "/");
|
|
51
55
|
const marker = "/templates/";
|
|
52
|
-
const at =
|
|
56
|
+
const at = normalized.lastIndexOf(marker);
|
|
53
57
|
if (at === -1)
|
|
54
58
|
return undefined;
|
|
55
|
-
return `component/${
|
|
59
|
+
return `component/${normalized.slice(at + marker.length)}`;
|
|
56
60
|
}
|
|
57
61
|
/**
|
|
58
62
|
* Load a template from disk, or — when the disk read fails (a compiled binary) —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadTemplate.js","sourceRoot":"","sources":["../../../src/shared/loadTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AASvC;;;;;GAKG;AACH,IAAI,iBAAiB,GAAqC,EAAE,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAA0C;IAE1C,iBAAiB,GAAG,QAAQ,CAAC;AAC/B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,YAAY,CAAC,MAAc;IAClC,MAAM,MAAM,GAAG,aAAa,CAAC;IAC7B,MAAM,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"loadTemplate.js","sourceRoot":"","sources":["../../../src/shared/loadTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AASvC;;;;;GAKG;AACH,IAAI,iBAAiB,GAAqC,EAAE,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAA0C;IAE1C,iBAAiB,GAAG,QAAQ,CAAC;AAC/B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,YAAY,CAAC,MAAc;IAClC,4EAA4E;IAC5E,uEAAuE;IACvE,oDAAoD;IACpD,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,aAAa,CAAC;IAC7B,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,EAAE,KAAK,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IAChC,OAAO,aAAa,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,0CAA0C;IAC1C,IAAI,CAAC;QACH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,yEAAyE;IAC3E,CAAC;IAED,gEAAgE;IAChE,8EAA8E;IAC9E,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,IAAI,KAAK,CACb,uBAAuB,MAAM,+CAC3B,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,GAC3C,IAAI,CACL,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CACxC,MAAc;IAEd,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { PACKAGE_NAME } from "./packageName.js";
|
|
5
|
+
/**
|
|
6
|
+
* Walk up from `from` until a `package.json` names this package, and return
|
|
7
|
+
* its `version`. Exported for tests; production callers use
|
|
8
|
+
* {@link packageVersion}.
|
|
9
|
+
*
|
|
10
|
+
* A manifest that is unreadable, is not JSON, names another package, or
|
|
11
|
+
* carries no version is not a failure — it is an ancestor directory that
|
|
12
|
+
* happens to have a `package.json` (the workspace root, say), so the walk
|
|
13
|
+
* continues. Only running out of parents throws.
|
|
14
|
+
*
|
|
15
|
+
* @note Impure — reads the filesystem.
|
|
16
|
+
*/
|
|
17
|
+
export function findOwnVersion(from) {
|
|
18
|
+
let dir = from;
|
|
19
|
+
for (;;) {
|
|
20
|
+
try {
|
|
21
|
+
const manifest = JSON.parse(readFileSync(path.join(dir, "package.json"), "utf-8"));
|
|
22
|
+
if (manifest.name === PACKAGE_NAME && manifest.version) {
|
|
23
|
+
return manifest.version;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// No readable manifest at this level — keep walking.
|
|
28
|
+
}
|
|
29
|
+
const parent = path.dirname(dir);
|
|
30
|
+
if (parent === dir) {
|
|
31
|
+
throw new Error(`packageVersion: no package.json naming ${PACKAGE_NAME} above ${from}`);
|
|
32
|
+
}
|
|
33
|
+
dir = parent;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* This package's own published version, used as the generators' meta.version
|
|
38
|
+
* — which is also the stamp version core writes into every generated file.
|
|
39
|
+
* The metas previously froze "0.1.0", so stamps could never distinguish
|
|
40
|
+
* releases. Same shape as summon-package's packageVersion: not a JSON import
|
|
41
|
+
* (build-layout coupling), lazy and cached (no IO at module load).
|
|
42
|
+
*
|
|
43
|
+
* @note Impure on first call — reads the filesystem, then caches.
|
|
44
|
+
*/
|
|
45
|
+
let cached;
|
|
46
|
+
export function packageVersion() {
|
|
47
|
+
cached ??= findOwnVersion(path.dirname(fileURLToPath(import.meta.url)));
|
|
48
|
+
return cached;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../../../src/shared/packageVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,SAAS,CAAC;QACR,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CACzB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CACf,CAAC;YACzC,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACvD,OAAO,QAAQ,CAAC,OAAO,CAAC;YAC1B,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,qDAAqD;QACvD,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CACb,0CAA0C,YAAY,UAAU,IAAI,EAAE,CACvE,CAAC;QACJ,CAAC;QACD,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,IAAI,MAA0B,CAAC;AAC/B,MAAM,UAAU,cAAc;IAC5B,MAAM,KAAK,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACxE,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -14,18 +14,17 @@
|
|
|
14
14
|
* @example
|
|
15
15
|
* ```bash
|
|
16
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 --
|
|
17
|
+
* summon component svelte --component-path=src/lib/components/Card --no-with-stories
|
|
18
|
+
* summon component svelte --component-path=src/lib/components/Modal --use-ts-stories
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
21
|
* @module
|
|
22
22
|
*/
|
|
23
23
|
import * as path from "node:path";
|
|
24
24
|
import { fileURLToPath } from "node:url";
|
|
25
|
-
import { template } from "@canonical/summon-core";
|
|
25
|
+
import { loadTemplateSync, template, } from "@canonical/summon-core";
|
|
26
26
|
import { debug, info, mkdir, sequence_, when } from "@canonical/task";
|
|
27
|
-
import { appendExportToParentIndex, createComponentPathPrompt, createTemplateContext, getComponentName, getParentDir, PACKAGE_NAME, sharedPrompts, } from "../shared/index.js";
|
|
28
|
-
import { loadTemplateSync } from "../shared/loadTemplate.js";
|
|
27
|
+
import { appendExportToParentIndex, createComponentPathPrompt, createTemplateContext, failIfComponentExists, getComponentName, getParentDir, PACKAGE_NAME, packageVersion, sharedPrompts, } from "../shared/index.js";
|
|
29
28
|
// =============================================================================
|
|
30
29
|
// Template Paths & Content (loaded LAZILY on first generate())
|
|
31
30
|
// =============================================================================
|
|
@@ -71,7 +70,7 @@ const generator = {
|
|
|
71
70
|
name: "component/svelte",
|
|
72
71
|
displayName: `${PACKAGE_NAME}:svelte`,
|
|
73
72
|
description: "Generate a Svelte 5 component with TypeScript, tests, stories, and styles",
|
|
74
|
-
version:
|
|
73
|
+
version: packageVersion(),
|
|
75
74
|
help: `Generate a Svelte 5 component with TypeScript, tests, stories, and styles.
|
|
76
75
|
|
|
77
76
|
FEATURES:
|
|
@@ -87,8 +86,8 @@ The component name is extracted from the path and must be PascalCase.
|
|
|
87
86
|
For example, 'src/lib/components/Button' creates a 'Button' component.`,
|
|
88
87
|
examples: [
|
|
89
88
|
"summon component svelte --component-path=src/lib/components/Button",
|
|
90
|
-
"summon component svelte --component-path=src/lib/components/Card --with-styles --with-stories",
|
|
91
|
-
"summon component svelte --component-path=src/lib/components/Modal --
|
|
89
|
+
"summon component svelte --component-path=src/lib/components/Card --no-with-styles --no-with-stories",
|
|
90
|
+
"summon component svelte --component-path=src/lib/components/Modal --use-ts-stories",
|
|
92
91
|
"summon component svelte --component-path=src/lib/components/Button --dry-run",
|
|
93
92
|
],
|
|
94
93
|
},
|
|
@@ -108,10 +107,13 @@ For example, 'src/lib/components/Button' creates a 'Button' component.`,
|
|
|
108
107
|
const componentName = getComponentName(answers.componentPath);
|
|
109
108
|
const componentDir = answers.componentPath;
|
|
110
109
|
const parentDir = getParentDir(answers.componentPath);
|
|
111
|
-
const ctx = createTemplateContext(answers
|
|
110
|
+
const ctx = createTemplateContext(answers);
|
|
112
111
|
const t = svelteTemplates();
|
|
113
112
|
return sequence_([
|
|
114
113
|
info(`Generating Svelte component: ${componentName}`),
|
|
114
|
+
// Refuse to scaffold over an existing component: the writes' delete
|
|
115
|
+
// undos would otherwise let --undo destroy pre-existing files.
|
|
116
|
+
failIfComponentExists(componentDir),
|
|
115
117
|
debug("Creating component directory"),
|
|
116
118
|
mkdir(componentDir),
|
|
117
119
|
debug("Creating main component file"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/svelte/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/svelte/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAEL,gBAAgB,EAChB,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,IAA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AAI,CACF,OAAO,CAAC,UAAU,EAClB,QAAQ,CAAC;gBACP,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM;gBACvB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO;gBACzB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC;gBAC3C,IAAI,EAAE,GAAG;aACV,CAAC,CACH;YAED,KAAK,CAAC,sCAAsC,CAAC;YAC7C,yBAAyB,CAAC,SAAS,EAAE,aAAa,CAAC;YAEnD,IAAI,CAAC,WAAW,aAAa,iBAAiB,YAAY,EAAE,CAAC;SAC9D,CAAC,CAAC;IACL,CAAC;CAC6D,CAAC;AAEjE,eAAe,SAAS,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -32,9 +32,9 @@ export declare const generators: {
|
|
|
32
32
|
readonly name: "component/react";
|
|
33
33
|
readonly displayName: "@canonical/summon-component:react";
|
|
34
34
|
readonly description: "Generate a React component with TypeScript, tests, stories, and styles";
|
|
35
|
-
readonly version:
|
|
35
|
+
readonly version: string;
|
|
36
36
|
readonly help: "Generate a React component with TypeScript, tests, stories, and styles.\n\nFEATURES:\n - TypeScript types and props interface\n - Unit tests with @testing-library/react\n - Storybook integration (optional)\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/components/Button' creates a 'Button' component.";
|
|
37
|
-
readonly examples: ["summon component react --component-path=src/components/Button", "summon component react --component-path=src/components/Card --with-styles --with-stories", "summon component react --component-path=src/components/Modal --no-with-ssr-tests", "summon component react --component-path=src/components/Button --dry-run"];
|
|
37
|
+
readonly examples: ["summon component react --component-path=src/components/Button", "summon component react --component-path=src/components/Card --no-with-styles --no-with-stories", "summon component react --component-path=src/components/Modal --no-with-ssr-tests", "summon component react --component-path=src/components/Button --dry-run"];
|
|
38
38
|
};
|
|
39
39
|
readonly prompts: [import("@canonical/summon-core").PromptDefinition, ...import("@canonical/summon-core").PromptDefinition[]];
|
|
40
40
|
readonly generate: (answers: import("./shared/types.js").BaseComponentAnswers) => import("@canonical/task").Task<void>;
|
|
@@ -44,9 +44,9 @@ export declare const generators: {
|
|
|
44
44
|
readonly name: "component/svelte";
|
|
45
45
|
readonly displayName: "@canonical/summon-component:svelte";
|
|
46
46
|
readonly description: "Generate a Svelte 5 component with TypeScript, tests, stories, and styles";
|
|
47
|
-
readonly version:
|
|
47
|
+
readonly version: string;
|
|
48
48
|
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.";
|
|
49
|
-
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 --
|
|
49
|
+
readonly examples: ["summon component svelte --component-path=src/lib/components/Button", "summon component svelte --component-path=src/lib/components/Card --no-with-styles --no-with-stories", "summon component svelte --component-path=src/lib/components/Modal --use-ts-stories", "summon component svelte --component-path=src/lib/components/Button --dry-run"];
|
|
50
50
|
};
|
|
51
51
|
readonly prompts: [import("@canonical/summon-core").PromptDefinition, ...import("@canonical/summon-core").PromptDefinition[], {
|
|
52
52
|
readonly name: "useTsStories";
|
|
@@ -63,24 +63,12 @@ export declare const generators: {
|
|
|
63
63
|
readonly name: "component/lit";
|
|
64
64
|
readonly displayName: "@canonical/summon-component:lit";
|
|
65
65
|
readonly description: "Generate a Lit web component with TypeScript, tests, stories, and styles";
|
|
66
|
-
readonly version:
|
|
67
|
-
readonly help: "Generate a Lit web component with TypeScript, tests, stories, and styles.\n\nFEATURES:\n - Lit element with TypeScript decorators\n - Unit tests with Vitest and shadow DOM testing\n - Storybook integration with @storybook/web-components-vite (optional)\n - CSS styles (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\nwith the custom element tag 'button'.";
|
|
68
|
-
readonly examples: ["summon component lit --component-path=src/lib/components/Button", "summon component lit --component-path=src/lib/components/Card --with-styles --with-stories", "summon component lit --component-path=src/lib/components/Modal --no-with-styles", "summon component lit --component-path=src/lib/components/Button --dry-run"];
|
|
66
|
+
readonly version: string;
|
|
67
|
+
readonly help: "Generate a Lit web component with TypeScript, tests, stories, and styles.\n\nFEATURES:\n - Lit element with TypeScript decorators\n - Unit tests with Vitest and shadow DOM testing\n - Storybook integration with @storybook/web-components-vite (optional)\n - CSS styles (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\nwith the custom element tag 'ds-button'.";
|
|
68
|
+
readonly examples: ["summon component lit --component-path=src/lib/components/Button", "summon component lit --component-path=src/lib/components/Card --no-with-styles --no-with-stories", "summon component lit --component-path=src/lib/components/Modal --no-with-styles", "summon component lit --component-path=src/lib/components/Button --dry-run"];
|
|
69
69
|
};
|
|
70
|
-
readonly prompts: [import("@canonical/summon-core").PromptDefinition,
|
|
71
|
-
|
|
72
|
-
readonly type: "confirm";
|
|
73
|
-
readonly message: "Include styles?";
|
|
74
|
-
readonly default: true;
|
|
75
|
-
readonly group: "Options";
|
|
76
|
-
}, {
|
|
77
|
-
readonly name: "withStories";
|
|
78
|
-
readonly type: "confirm";
|
|
79
|
-
readonly message: "Include Storybook stories?";
|
|
80
|
-
readonly default: true;
|
|
81
|
-
readonly group: "Options";
|
|
82
|
-
}];
|
|
83
|
-
readonly generate: (answers: import("./shared/types.js").BaseComponentAnswers) => import("@canonical/task").Task<void>;
|
|
70
|
+
readonly prompts: [import("@canonical/summon-core").PromptDefinition, ...import("@canonical/summon-core").PromptDefinition[]];
|
|
71
|
+
readonly generate: (answers: import("./lit/types.js").LitAnswers) => import("@canonical/task").Task<void>;
|
|
84
72
|
};
|
|
85
73
|
};
|
|
86
74
|
export default generators;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH;;;;;GAKG;AACH,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAI0B,CAAC;AAElD,eAAe,UAAU,CAAC"}
|
|
@@ -4,18 +4,19 @@
|
|
|
4
4
|
* Generates a Lit web component with a consistent file structure:
|
|
5
5
|
* - `ComponentName.ts` - Main component file (Lit element)
|
|
6
6
|
* - `index.ts` - Barrel export
|
|
7
|
-
* - `ComponentName.
|
|
7
|
+
* - `ComponentName.test.ts` - Unit tests with Vitest
|
|
8
8
|
* - `ComponentName.stories.ts` - Storybook stories (optional)
|
|
9
9
|
* - `styles.css` - CSS styles (optional)
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```bash
|
|
13
13
|
* summon component lit --component-path=src/lib/components/Button
|
|
14
|
-
* summon component lit --component-path=src/lib/components/Card --with-styles --with-stories
|
|
14
|
+
* summon component lit --component-path=src/lib/components/Card --no-with-styles --no-with-stories
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
|
+
import type { LitAnswers } from "./types.js";
|
|
19
20
|
/**
|
|
20
21
|
* Web components generator definition.
|
|
21
22
|
*
|
|
@@ -29,24 +30,12 @@ declare const generator: {
|
|
|
29
30
|
readonly name: "component/lit";
|
|
30
31
|
readonly displayName: "@canonical/summon-component:lit";
|
|
31
32
|
readonly description: "Generate a Lit web component with TypeScript, tests, stories, and styles";
|
|
32
|
-
readonly version:
|
|
33
|
-
readonly help: "Generate a Lit web component with TypeScript, tests, stories, and styles.\n\nFEATURES:\n - Lit element with TypeScript decorators\n - Unit tests with Vitest and shadow DOM testing\n - Storybook integration with @storybook/web-components-vite (optional)\n - CSS styles (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\nwith the custom element tag 'button'.";
|
|
34
|
-
readonly examples: ["summon component lit --component-path=src/lib/components/Button", "summon component lit --component-path=src/lib/components/Card --with-styles --with-stories", "summon component lit --component-path=src/lib/components/Modal --no-with-styles", "summon component lit --component-path=src/lib/components/Button --dry-run"];
|
|
33
|
+
readonly version: string;
|
|
34
|
+
readonly help: "Generate a Lit web component with TypeScript, tests, stories, and styles.\n\nFEATURES:\n - Lit element with TypeScript decorators\n - Unit tests with Vitest and shadow DOM testing\n - Storybook integration with @storybook/web-components-vite (optional)\n - CSS styles (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\nwith the custom element tag 'ds-button'.";
|
|
35
|
+
readonly examples: ["summon component lit --component-path=src/lib/components/Button", "summon component lit --component-path=src/lib/components/Card --no-with-styles --no-with-stories", "summon component lit --component-path=src/lib/components/Modal --no-with-styles", "summon component lit --component-path=src/lib/components/Button --dry-run"];
|
|
35
36
|
};
|
|
36
|
-
readonly prompts: [import("@canonical/summon-core").PromptDefinition,
|
|
37
|
-
|
|
38
|
-
readonly type: "confirm";
|
|
39
|
-
readonly message: "Include styles?";
|
|
40
|
-
readonly default: true;
|
|
41
|
-
readonly group: "Options";
|
|
42
|
-
}, {
|
|
43
|
-
readonly name: "withStories";
|
|
44
|
-
readonly type: "confirm";
|
|
45
|
-
readonly message: "Include Storybook stories?";
|
|
46
|
-
readonly default: true;
|
|
47
|
-
readonly group: "Options";
|
|
48
|
-
}];
|
|
49
|
-
readonly generate: (answers: import("../shared/types.js").BaseComponentAnswers) => import("@canonical/task").Task<void>;
|
|
37
|
+
readonly prompts: [import("@canonical/summon-core").PromptDefinition, ...import("@canonical/summon-core").PromptDefinition[]];
|
|
38
|
+
readonly generate: (answers: LitAnswers) => import("@canonical/task").Task<void>;
|
|
50
39
|
};
|
|
51
40
|
export default generator;
|
|
52
41
|
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/lit/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/lit/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAqBH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAiD7C;;;;;;;GAOG;AACH,QAAA,MAAM,SAAS;;;;;;;;;;;CA0GqC,CAAC;AAErD,eAAe,SAAS,CAAC"}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Types for Lit web component generator
|
|
3
3
|
*/
|
|
4
4
|
import type { BaseComponentAnswers } from "../shared/index.js";
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Lit web component generator answers — the base answers minus SSR tests,
|
|
7
|
+
* which the lit generator does not offer (its prompts never collect the flag,
|
|
8
|
+
* so the type must not promise it).
|
|
9
|
+
*/
|
|
10
|
+
export type LitAnswers = Omit<BaseComponentAnswers, "withSsrTests">;
|
|
7
11
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lit/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lit/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAAC"}
|
|
@@ -17,9 +17,9 @@ declare const generator: {
|
|
|
17
17
|
readonly name: "component/react";
|
|
18
18
|
readonly displayName: "@canonical/summon-component:react";
|
|
19
19
|
readonly description: "Generate a React component with TypeScript, tests, stories, and styles";
|
|
20
|
-
readonly version:
|
|
20
|
+
readonly version: string;
|
|
21
21
|
readonly help: "Generate a React component with TypeScript, tests, stories, and styles.\n\nFEATURES:\n - TypeScript types and props interface\n - Unit tests with @testing-library/react\n - Storybook integration (optional)\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/components/Button' creates a 'Button' component.";
|
|
22
|
-
readonly examples: ["summon component react --component-path=src/components/Button", "summon component react --component-path=src/components/Card --with-styles --with-stories", "summon component react --component-path=src/components/Modal --no-with-ssr-tests", "summon component react --component-path=src/components/Button --dry-run"];
|
|
22
|
+
readonly examples: ["summon component react --component-path=src/components/Button", "summon component react --component-path=src/components/Card --no-with-styles --no-with-stories", "summon component react --component-path=src/components/Modal --no-with-ssr-tests", "summon component react --component-path=src/components/Button --dry-run"];
|
|
23
23
|
};
|
|
24
24
|
readonly prompts: [import("@canonical/summon-core").PromptDefinition, ...import("@canonical/summon-core").PromptDefinition[]];
|
|
25
25
|
readonly generate: (answers: import("../shared/types.js").BaseComponentAnswers) => import("@canonical/task").Task<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/react/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/react/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAoEH,QAAA,MAAM,SAAS;;;;;;;;;;;CAqHgD,CAAC;AAEhE,eAAe,SAAS,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Template context creation for component generators
|
|
3
3
|
*/
|
|
4
|
-
import type { BaseComponentAnswers,
|
|
4
|
+
import type { BaseComponentAnswers, TemplateContext } from "./types.js";
|
|
5
5
|
/**
|
|
6
|
-
* Create template context from answers
|
|
6
|
+
* Create template context from answers. `withSsrTests` is optional so
|
|
7
|
+
* generators that do not offer SSR tests (lit) can pass their honest answer
|
|
8
|
+
* shape; the context defaults it to false.
|
|
7
9
|
*/
|
|
8
|
-
export default function createTemplateContext(answers: BaseComponentAnswers,
|
|
10
|
+
export default function createTemplateContext(answers: Omit<BaseComponentAnswers, "withSsrTests"> & Partial<Pick<BaseComponentAnswers, "withSsrTests">>): TemplateContext;
|
|
9
11
|
//# sourceMappingURL=createTemplateContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTemplateContext.d.ts","sourceRoot":"","sources":["../../../src/shared/createTemplateContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"createTemplateContext.d.ts","sourceRoot":"","sources":["../../../src/shared/createTemplateContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAExE;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,cAAc,CAAC,GACjD,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAAC,GACpD,eAAe,CASjB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Task } from "@canonical/task";
|
|
2
|
+
/**
|
|
3
|
+
* Refuse to scaffold over an existing component directory.
|
|
4
|
+
*
|
|
5
|
+
* Every generated write carries a delete as its default undo, so scaffolding
|
|
6
|
+
* over an existing directory and then running `--undo` would destroy files
|
|
7
|
+
* the user owned before the run. The domain/wrapper generators in
|
|
8
|
+
* summon-application guard the same way for the same reason.
|
|
9
|
+
*/
|
|
10
|
+
export default function failIfComponentExists(componentDir: string): Task<void>;
|
|
11
|
+
//# sourceMappingURL=failIfComponentExists.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failIfComponentExists.d.ts","sourceRoot":"","sources":["../../../src/shared/failIfComponentExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,YAAY,EAAE,MAAM,GACnB,IAAI,CAAC,IAAI,CAAC,CAYZ"}
|
|
@@ -1 +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;
|
|
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;AASzB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,GACpB,IAAI,CAAC,IAAI,CAAC,CAmCZ"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type Task } from "@canonical/task";
|
|
2
2
|
/**
|
|
3
|
-
* Remove a specific line from a file
|
|
4
|
-
*
|
|
3
|
+
* Remove a specific line from a file (all occurrences, matched by trimmed
|
|
4
|
+
* content). Truly idempotent: when the line is not present the file is left
|
|
5
|
+
* untouched — no rewrite, and a file that was already empty is never deleted.
|
|
6
|
+
* When the removal leaves the file effectively empty (blank, or only
|
|
7
|
+
* generator-stamp comment lines), the file is deleted entirely.
|
|
5
8
|
*/
|
|
6
9
|
export default function removeLineFromFile(filePath: string, line: string): Task<void>;
|
|
7
10
|
//# sourceMappingURL=removeLineFromFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeLineFromFile.d.ts","sourceRoot":"","sources":["../../../../src/shared/file-operations/removeLineFromFile.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"removeLineFromFile.d.ts","sourceRoot":"","sources":["../../../../src/shared/file-operations/removeLineFromFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,IAAI,EAEV,MAAM,iBAAiB,CAAC;AAezB;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,IAAI,CAAC,IAAI,CAAC,CAiBZ"}
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { default as createComponentPathPrompt } from "./createComponentPathPrompt.js";
|
|
5
5
|
export { default as createTemplateContext } from "./createTemplateContext.js";
|
|
6
|
+
export { default as failIfComponentExists } from "./failIfComponentExists.js";
|
|
6
7
|
export * from "./file-operations/index.js";
|
|
7
8
|
export { PACKAGE_NAME } from "./packageName.js";
|
|
9
|
+
export { packageVersion } from "./packageVersion.js";
|
|
8
10
|
export { default as sharedPrompts } from "./sharedPrompts.js";
|
|
9
11
|
export * from "./string-helpers/index.js";
|
|
10
12
|
export type * from "./types.js";
|
|
@@ -1 +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"}
|
|
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,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC9E,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadTemplate.d.ts","sourceRoot":"","sources":["../../../src/shared/loadTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;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;AAUD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACzC,IAAI,CAEN;
|
|
1
|
+
{"version":3,"file":"loadTemplate.d.ts","sourceRoot":"","sources":["../../../src/shared/loadTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;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;AAUD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACzC,IAAI,CAEN;AAyBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAqB/D;AAED;;;;;;GAMG;AACH,wBAA8B,YAAY,CACxC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAEzB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walk up from `from` until a `package.json` names this package, and return
|
|
3
|
+
* its `version`. Exported for tests; production callers use
|
|
4
|
+
* {@link packageVersion}.
|
|
5
|
+
*
|
|
6
|
+
* A manifest that is unreadable, is not JSON, names another package, or
|
|
7
|
+
* carries no version is not a failure — it is an ancestor directory that
|
|
8
|
+
* happens to have a `package.json` (the workspace root, say), so the walk
|
|
9
|
+
* continues. Only running out of parents throws.
|
|
10
|
+
*
|
|
11
|
+
* @note Impure — reads the filesystem.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findOwnVersion(from: string): string;
|
|
14
|
+
export declare function packageVersion(): string;
|
|
15
|
+
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../../../src/shared/packageVersion.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBnD;AAYD,wBAAgB,cAAc,IAAI,MAAM,CAGvC"}
|
|
@@ -18,10 +18,6 @@ export interface TemplateContext {
|
|
|
18
18
|
name: string;
|
|
19
19
|
/** Component name in kebab-case (e.g., my-component) */
|
|
20
20
|
kebabName: string;
|
|
21
|
-
/** Generator name for comments */
|
|
22
|
-
generatorName: string;
|
|
23
|
-
/** Generator version */
|
|
24
|
-
version: string;
|
|
25
21
|
/** Include styles */
|
|
26
22
|
withStyles: boolean;
|
|
27
23
|
/** Include stories */
|
|
@@ -1 +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,
|
|
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,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"}
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* @example
|
|
15
15
|
* ```bash
|
|
16
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 --
|
|
17
|
+
* summon component svelte --component-path=src/lib/components/Card --no-with-stories
|
|
18
|
+
* summon component svelte --component-path=src/lib/components/Modal --use-ts-stories
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
21
|
* @module
|
|
@@ -34,9 +34,9 @@ declare const generator: {
|
|
|
34
34
|
readonly name: "component/svelte";
|
|
35
35
|
readonly displayName: "@canonical/summon-component:svelte";
|
|
36
36
|
readonly description: "Generate a Svelte 5 component with TypeScript, tests, stories, and styles";
|
|
37
|
-
readonly version:
|
|
37
|
+
readonly version: string;
|
|
38
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 --
|
|
39
|
+
readonly examples: ["summon component svelte --component-path=src/lib/components/Button", "summon component svelte --component-path=src/lib/components/Card --no-with-styles --no-with-stories", "summon component svelte --component-path=src/lib/components/Modal --use-ts-stories", "summon component svelte --component-path=src/lib/components/Button --dry-run"];
|
|
40
40
|
};
|
|
41
41
|
readonly prompts: [import("@canonical/summon-core").PromptDefinition, ...import("@canonical/summon-core").PromptDefinition[], {
|
|
42
42
|
readonly name: "useTsStories";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/svelte/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/svelte/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAqBH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAiDzD;;;;;;;GAOG;AACH,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;CAkJiD,CAAC;AAEjE,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/summon-component",
|
|
3
3
|
"description": "Component generators for Summon - React, Svelte and Lit component scaffolding",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.35.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
@@ -10,10 +10,6 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/types/index.d.ts",
|
|
12
12
|
"import": "./dist/esm/index.js"
|
|
13
|
-
},
|
|
14
|
-
"./embedded": {
|
|
15
|
-
"types": "./dist/types/shared/loadTemplate.d.ts",
|
|
16
|
-
"import": "./dist/esm/shared/loadTemplate.js"
|
|
17
13
|
}
|
|
18
14
|
},
|
|
19
15
|
"files": [
|
|
@@ -50,20 +46,20 @@
|
|
|
50
46
|
},
|
|
51
47
|
"devDependencies": {
|
|
52
48
|
"@biomejs/biome": "2.4.9",
|
|
53
|
-
"@canonical/biome-config": "^0.
|
|
54
|
-
"@canonical/typescript-config": "^0.
|
|
55
|
-
"@canonical/webarchitect": "^0.
|
|
49
|
+
"@canonical/biome-config": "^0.35.0",
|
|
50
|
+
"@canonical/typescript-config": "^0.35.0",
|
|
51
|
+
"@canonical/webarchitect": "^0.35.0",
|
|
56
52
|
"@types/bun": "^1.3.10",
|
|
57
|
-
"@types/node": "^
|
|
53
|
+
"@types/node": "^26.0.0",
|
|
58
54
|
"typescript": "^5.9.3",
|
|
59
55
|
"vitest": "^4.0.18"
|
|
60
56
|
},
|
|
61
57
|
"dependencies": {
|
|
62
|
-
"@canonical/utils": "^0.
|
|
58
|
+
"@canonical/utils": "^0.35.0"
|
|
63
59
|
},
|
|
64
60
|
"peerDependencies": {
|
|
65
|
-
"@canonical/summon-core": "^0.
|
|
66
|
-
"@canonical/task": "^0.
|
|
61
|
+
"@canonical/summon-core": "^0.34.0",
|
|
62
|
+
"@canonical/task": "^0.34.0"
|
|
67
63
|
},
|
|
68
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "5198c5399ef657959272c0e35924391573d81146"
|
|
69
65
|
}
|