@storybook/cli 10.4.0-alpha.11 → 10.4.0-alpha.13
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/dist/_node-chunks/{block-dependencies-versions-2BVSMHVR.js → block-dependencies-versions-RWNRI4GB.js} +11 -11
- package/dist/_node-chunks/{block-experimental-addon-test-YTJO53FI.js → block-experimental-addon-test-PUHJ3NL6.js} +9 -9
- package/dist/_node-chunks/{block-major-version-LCXD4EE5.js → block-major-version-I3E62CBN.js} +9 -9
- package/dist/_node-chunks/{block-node-version-WZF6U3TL.js → block-node-version-NOND3SUE.js} +9 -9
- package/dist/_node-chunks/{block-webpack5-frameworks-EI3U2F35.js → block-webpack5-frameworks-22ZJLQUS.js} +11 -11
- package/dist/_node-chunks/{chunk-KSVLT5Q6.js → chunk-47LRJSKF.js} +6 -6
- package/dist/_node-chunks/{chunk-WCEKSVGD.js → chunk-6KUBKUXA.js} +7 -7
- package/dist/_node-chunks/{chunk-F3OYUBSA.js → chunk-M4GFZIKM.js} +7 -7
- package/dist/_node-chunks/chunk-OIPZEDTL.js +11 -0
- package/dist/_node-chunks/{chunk-6BWYOUU7.js → chunk-X5LJ3DDJ.js} +28 -17
- package/dist/_node-chunks/{globby-XYA3TN25.js → globby-KNFCECZ3.js} +8 -8
- package/dist/_node-chunks/{p-limit-U3C7RBHQ.js → p-limit-MF6JQ6VU.js} +7 -7
- package/dist/_node-chunks/{run-DB2FPOMF.js → run-OIEKD62P.js} +1302 -117
- package/dist/_node-chunks/setup-BYVI7PM2.js +281 -0
- package/dist/bin/index.js +7 -7
- package/package.json +4 -4
- package/dist/_node-chunks/chunk-6L6KWHQV.js +0 -11
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_k1889y8tin from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_k1889y8tin from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_k1889y8tin from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_k1889y8tin.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_k1889y8tin.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_k1889y8tin.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import "./chunk-47LRJSKF.js";
|
|
13
|
+
|
|
14
|
+
// src/ai/setup-prompts/setup.ts
|
|
15
|
+
import { dedent } from "ts-dedent";
|
|
16
|
+
function getTypeImportSource(projectInfo) {
|
|
17
|
+
return projectInfo.framework || projectInfo.rendererPackage || "@storybook/react";
|
|
18
|
+
}
|
|
19
|
+
function getPreviewDecoratorExample(projectInfo) {
|
|
20
|
+
let configDir = projectInfo.configDir;
|
|
21
|
+
if (projectInfo.hasCsfFactoryPreview)
|
|
22
|
+
return dedent`
|
|
23
|
+
\`\`\`tsx
|
|
24
|
+
// ${configDir}/preview.tsx
|
|
25
|
+
import '../src/index.css'; // import global styles
|
|
26
|
+
|
|
27
|
+
import { definePreview } from 'storybook/preview';
|
|
28
|
+
|
|
29
|
+
export default definePreview({
|
|
30
|
+
decorators: [
|
|
31
|
+
(Story) => (
|
|
32
|
+
<ThemeProvider theme={theme}>
|
|
33
|
+
<MemoryRouter>
|
|
34
|
+
<Story />
|
|
35
|
+
</MemoryRouter>
|
|
36
|
+
</ThemeProvider>
|
|
37
|
+
),
|
|
38
|
+
],
|
|
39
|
+
});
|
|
40
|
+
\`\`\`
|
|
41
|
+
`;
|
|
42
|
+
let typeImport = getTypeImportSource(projectInfo);
|
|
43
|
+
return dedent`
|
|
44
|
+
\`\`\`tsx
|
|
45
|
+
// ${configDir}/preview.tsx
|
|
46
|
+
import type { Preview } from '${typeImport}';
|
|
47
|
+
import '../src/index.css'; // import global styles
|
|
48
|
+
|
|
49
|
+
const preview: Preview = {
|
|
50
|
+
decorators: [
|
|
51
|
+
(Story) => (
|
|
52
|
+
<ThemeProvider theme={theme}>
|
|
53
|
+
<MemoryRouter>
|
|
54
|
+
<Story />
|
|
55
|
+
</MemoryRouter>
|
|
56
|
+
</ThemeProvider>
|
|
57
|
+
),
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default preview;
|
|
62
|
+
\`\`\`
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
function getSimpleStoryExample(projectInfo) {
|
|
66
|
+
if (projectInfo.hasCsfFactoryPreview)
|
|
67
|
+
return dedent`
|
|
68
|
+
\`\`\`tsx
|
|
69
|
+
import preview from '#.storybook/preview';
|
|
70
|
+
import { Button } from './Button';
|
|
71
|
+
|
|
72
|
+
const meta = preview.meta({
|
|
73
|
+
title: 'AI Generated/Simple/Button',
|
|
74
|
+
component: Button,
|
|
75
|
+
tags: ['ai-generated'],
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export const Default = meta.story({
|
|
79
|
+
args: {
|
|
80
|
+
label: 'Click me',
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export const Disabled = meta.story({
|
|
85
|
+
args: {
|
|
86
|
+
label: 'Disabled',
|
|
87
|
+
disabled: true,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
\`\`\`
|
|
91
|
+
`;
|
|
92
|
+
let typeImport = getTypeImportSource(projectInfo);
|
|
93
|
+
return dedent`
|
|
94
|
+
\`\`\`tsx
|
|
95
|
+
import type { Meta, StoryObj } from '${typeImport}';
|
|
96
|
+
import { Button } from './Button';
|
|
97
|
+
|
|
98
|
+
const meta = {
|
|
99
|
+
title: 'AI Generated/Simple/Button',
|
|
100
|
+
component: Button,
|
|
101
|
+
tags: ['ai-generated'],
|
|
102
|
+
} satisfies Meta<typeof Button>;
|
|
103
|
+
|
|
104
|
+
export default meta;
|
|
105
|
+
type Story = StoryObj<typeof meta>;
|
|
106
|
+
|
|
107
|
+
export const Default: Story = {
|
|
108
|
+
args: {
|
|
109
|
+
label: 'Click me',
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const Disabled: Story = {
|
|
114
|
+
args: {
|
|
115
|
+
label: 'Disabled',
|
|
116
|
+
disabled: true,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
\`\`\`
|
|
120
|
+
`;
|
|
121
|
+
}
|
|
122
|
+
function getNeedsWorkTagExample(projectInfo) {
|
|
123
|
+
return projectInfo.hasCsfFactoryPreview ? dedent`
|
|
124
|
+
\`\`\`ts
|
|
125
|
+
const meta = preview.meta({
|
|
126
|
+
title: 'AI Generated/Simple/Button',
|
|
127
|
+
component: Button,
|
|
128
|
+
tags: ['ai-generated', 'needs-work'],
|
|
129
|
+
});
|
|
130
|
+
\`\`\`
|
|
131
|
+
` : dedent`
|
|
132
|
+
\`\`\`ts
|
|
133
|
+
const meta = {
|
|
134
|
+
title: 'AI Generated/Simple/Button',
|
|
135
|
+
component: Button,
|
|
136
|
+
tags: ['ai-generated', 'needs-work'],
|
|
137
|
+
} satisfies Meta<typeof Button>;
|
|
138
|
+
\`\`\`
|
|
139
|
+
`;
|
|
140
|
+
}
|
|
141
|
+
function instructions(projectInfo) {
|
|
142
|
+
let configDir = projectInfo.configDir;
|
|
143
|
+
return dedent`
|
|
144
|
+
Attention: The following instructions must be followed in order to successfully set up Storybook in this project. Do not skip steps or attempt to do them out of order.
|
|
145
|
+
|
|
146
|
+
Your goal is to make Storybook fully functional in this project by analyzing the codebase,
|
|
147
|
+
configuring the preview with the right decorators, and writing example stories for 9 components.
|
|
148
|
+
|
|
149
|
+
Work through these steps in order. After each story file, run Vitest to verify it renders.
|
|
150
|
+
If the test fails, read the error, fix the issue, and re-run until it passes before moving on.
|
|
151
|
+
|
|
152
|
+
### Step 1: Analyze the codebase
|
|
153
|
+
|
|
154
|
+
Before writing any stories, understand what the components need to render:
|
|
155
|
+
|
|
156
|
+
- Scan the project for context providers, theme systems, routers, stores, and i18n setups.
|
|
157
|
+
Look at the app's entry point (e.g. \`App.tsx\`, \`main.tsx\`, \`layout.tsx\`) to see what
|
|
158
|
+
providers wrap the component tree.
|
|
159
|
+
- Identify global CSS or style imports required for components to look correct.
|
|
160
|
+
- Note any path aliases configured in tsconfig or bundler config.
|
|
161
|
+
- Read \`${configDir}/main.ts\` (or \`main.js\`) to find the \`stories\` glob patterns.
|
|
162
|
+
Your story files must match those patterns to be picked up by Storybook.
|
|
163
|
+
|
|
164
|
+
### Step 2: Configure \`${configDir}/preview.tsx\` with decorators
|
|
165
|
+
|
|
166
|
+
Add decorators that wrap every story with the providers your components need.
|
|
167
|
+
Without this, most non-trivial components will crash.
|
|
168
|
+
|
|
169
|
+
${getPreviewDecoratorExample(projectInfo)}
|
|
170
|
+
|
|
171
|
+
Common decorators to add:
|
|
172
|
+
|
|
173
|
+
- **Theme providers** (e.g. ThemeProvider, MUI ThemeProvider, styled-components, Tailwind)
|
|
174
|
+
- **Router** (e.g. MemoryRouter, BrowserRouter mock)
|
|
175
|
+
- **State stores** (e.g. Redux Provider, Zustand, Jotai)
|
|
176
|
+
- **i18n** (e.g. IntlProvider, I18nextProvider)
|
|
177
|
+
- **Global CSS** — import global stylesheets at the top of \`preview.tsx\`
|
|
178
|
+
|
|
179
|
+
### Step 3: Write stories for 9 components
|
|
180
|
+
|
|
181
|
+
Pick 9 real components from the codebase, 3 of each complexity level.
|
|
182
|
+
Use the title prefix \`AI Generated/<Complexity>/<ComponentName>\` so they are grouped
|
|
183
|
+
together in the Storybook sidebar.
|
|
184
|
+
|
|
185
|
+
**Simple (3 components)** — Presentational with few props, no internal state.
|
|
186
|
+
Examples: Button, Badge, Avatar, Icon, Label, Chip.
|
|
187
|
+
Title format: \`AI Generated/Simple/<ComponentName>\`
|
|
188
|
+
|
|
189
|
+
**Medium (3 components)** — Multiple visual variants or composed from simpler components.
|
|
190
|
+
Examples: Card, Alert, Input, Select, Tooltip, Tabs.
|
|
191
|
+
Title format: \`AI Generated/Medium/<ComponentName>\`
|
|
192
|
+
|
|
193
|
+
**Complex (3 components)** — Internal state, side effects, or deep composition.
|
|
194
|
+
Examples: Modal, DataTable, Form, Dropdown, Accordion, Sidebar.
|
|
195
|
+
Title format: \`AI Generated/Complex/<ComponentName>\`
|
|
196
|
+
|
|
197
|
+
For each component, create a \`<ComponentName>.stories.tsx\` file next to the component.
|
|
198
|
+
Each file must have at least 2 story exports covering the component's main states.
|
|
199
|
+
Make sure the file location and naming matches the \`stories\` patterns in \`${configDir}/main.ts\`.
|
|
200
|
+
|
|
201
|
+
#### Story tags
|
|
202
|
+
|
|
203
|
+
Every story meta must include the \`ai-generated\` tag to identify AI-created stories:
|
|
204
|
+
|
|
205
|
+
${getSimpleStoryExample(projectInfo)}
|
|
206
|
+
|
|
207
|
+
If a story could not be fully fixed after the self-healing loop (the test still fails
|
|
208
|
+
or the rendering is incomplete), add the \`needs-work\` tag alongside \`ai-generated\`:
|
|
209
|
+
|
|
210
|
+
${getNeedsWorkTagExample(projectInfo)}
|
|
211
|
+
|
|
212
|
+
Rules:
|
|
213
|
+
|
|
214
|
+
- Every named export is a story. Use \`args\` to set props.
|
|
215
|
+
- Provide all required props via \`args\` — check the component's types.
|
|
216
|
+
- If a component needs per-story decorators (beyond the global ones), add them in the meta.
|
|
217
|
+
- Do NOT use \`any\` types. Use the component's prop types for type safety.
|
|
218
|
+
|
|
219
|
+
Reference: https://storybook.js.org/docs/writing-stories
|
|
220
|
+
|
|
221
|
+
### Step 4: Verify each story with Vitest
|
|
222
|
+
|
|
223
|
+
After writing each story file, immediately verify it:
|
|
224
|
+
|
|
225
|
+
\`\`\`bash
|
|
226
|
+
npx vitest --project storybook <path-to-story-file>
|
|
227
|
+
\`\`\`
|
|
228
|
+
|
|
229
|
+
**Self-healing loop — repeat for every story file:**
|
|
230
|
+
|
|
231
|
+
1. Write/update the story file
|
|
232
|
+
2. Run \`npx vitest --project storybook <path-to-story-file>\`
|
|
233
|
+
3. If it fails: read the error output carefully
|
|
234
|
+
- Missing provider → add a decorator in \`${configDir}/preview.tsx\` or in the story meta
|
|
235
|
+
- Missing prop → add the required prop to \`args\`
|
|
236
|
+
- Import error → fix the import path
|
|
237
|
+
- CSS/asset error → add static dirs or import the stylesheet
|
|
238
|
+
4. Fix the issue and go back to step 2
|
|
239
|
+
5. Once the test passes, move to the next component
|
|
240
|
+
|
|
241
|
+
After all 9 story files pass individually, run the full suite:
|
|
242
|
+
|
|
243
|
+
\`\`\`bash
|
|
244
|
+
npx vitest --project storybook
|
|
245
|
+
\`\`\`
|
|
246
|
+
|
|
247
|
+
Once all stories pass, run a full Storybook build as a final check:
|
|
248
|
+
|
|
249
|
+
\`\`\`bash
|
|
250
|
+
npx storybook build
|
|
251
|
+
\`\`\`
|
|
252
|
+
|
|
253
|
+
If the build fails, fix the issue before finishing.
|
|
254
|
+
|
|
255
|
+
Finally, run \`npx storybook doctor\` to check for common issues
|
|
256
|
+
(version mismatches, duplicated deps, etc.) and fix anything it reports.
|
|
257
|
+
|
|
258
|
+
### Checklist
|
|
259
|
+
|
|
260
|
+
- [ ] Analyzed codebase for providers, global styles, and path aliases
|
|
261
|
+
- [ ] Read story patterns from \`${configDir}/main.ts\`
|
|
262
|
+
- [ ] Configured \`${configDir}/preview.tsx\` with necessary decorators
|
|
263
|
+
- [ ] Simple component 1: story written and passing
|
|
264
|
+
- [ ] Simple component 2: story written and passing
|
|
265
|
+
- [ ] Simple component 3: story written and passing
|
|
266
|
+
- [ ] Medium component 1: story written and passing
|
|
267
|
+
- [ ] Medium component 2: story written and passing
|
|
268
|
+
- [ ] Medium component 3: story written and passing
|
|
269
|
+
- [ ] Complex component 1: story written and passing
|
|
270
|
+
- [ ] Complex component 2: story written and passing
|
|
271
|
+
- [ ] Complex component 3: story written and passing
|
|
272
|
+
- [ ] Full Vitest suite passes: \`npx vitest --project storybook\`
|
|
273
|
+
- [ ] \`npx storybook build\` succeeds
|
|
274
|
+
- [ ] \`npx storybook doctor\` reports no remaining issues
|
|
275
|
+
- [ ] All passing stories have \`tags: ['ai-generated']\` in their meta
|
|
276
|
+
- [ ] Any stories that still need work have \`tags: ['ai-generated', 'needs-work']\` in their meta
|
|
277
|
+
`;
|
|
278
|
+
}
|
|
279
|
+
export {
|
|
280
|
+
instructions
|
|
281
|
+
};
|
package/dist/bin/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import CJS_COMPAT_NODE_URL_k1889y8tin from 'node:url';
|
|
3
|
+
import CJS_COMPAT_NODE_PATH_k1889y8tin from 'node:path';
|
|
4
|
+
import CJS_COMPAT_NODE_MODULE_k1889y8tin from "node:module";
|
|
5
5
|
|
|
6
|
-
var __filename =
|
|
7
|
-
var __dirname =
|
|
8
|
-
var require =
|
|
6
|
+
var __filename = CJS_COMPAT_NODE_URL_k1889y8tin.fileURLToPath(import.meta.url);
|
|
7
|
+
var __dirname = CJS_COMPAT_NODE_PATH_k1889y8tin.dirname(__filename);
|
|
8
|
+
var require = CJS_COMPAT_NODE_MODULE_k1889y8tin.createRequire(import.meta.url);
|
|
9
9
|
|
|
10
10
|
// ------------------------------------------------------------
|
|
11
11
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -20,4 +20,4 @@ isNodeVersionSupported(major, minor, patch) || (logger.error(
|
|
|
20
20
|
dedent`To run Storybook, you need Node.js version ${MIN_SUPPORTED_NODE_DESCRIPTION}.
|
|
21
21
|
You are currently running Node.js ${process.version}. Please upgrade your Node.js installation.`
|
|
22
22
|
), process.exit(1));
|
|
23
|
-
import("../_node-chunks/run-
|
|
23
|
+
import("../_node-chunks/run-OIEKD62P.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/cli",
|
|
3
|
-
"version": "10.4.0-alpha.
|
|
3
|
+
"version": "10.4.0-alpha.13",
|
|
4
4
|
"description": "Storybook CLI: Develop, document, and test UI components in isolation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"!src/**/*"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@storybook/codemod": "10.4.0-alpha.
|
|
40
|
+
"@storybook/codemod": "10.4.0-alpha.13",
|
|
41
41
|
"@types/semver": "^7.7.1",
|
|
42
42
|
"commander": "^14.0.2",
|
|
43
|
-
"create-storybook": "10.4.0-alpha.
|
|
43
|
+
"create-storybook": "10.4.0-alpha.13",
|
|
44
44
|
"jscodeshift": "^0.15.1",
|
|
45
|
-
"storybook": "10.4.0-alpha.
|
|
45
|
+
"storybook": "10.4.0-alpha.13",
|
|
46
46
|
"ts-dedent": "^2.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ss6g9koxy4s from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ss6g9koxy4s from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ss6g9koxy4s from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ss6g9koxy4s.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ss6g9koxy4s.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ss6g9koxy4s.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|