storybook-addon-dependency-previews 0.3.0 → 0.4.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +18 -360
  2. package/dist/blocks/DependencyPreviews.d.cts +2 -2
  3. package/dist/blocks/DependencyPreviews.d.mts +2 -2
  4. package/dist/cli/sb-deps.cjs +15 -7
  5. package/dist/cli/sb-deps.cjs.map +1 -1
  6. package/dist/cli/sb-deps.mjs +15 -7
  7. package/dist/cli/sb-deps.mjs.map +1 -1
  8. package/dist/cli/setup/detect.cjs +124 -0
  9. package/dist/cli/setup/detect.cjs.map +1 -0
  10. package/dist/cli/setup/detect.d.cts +28 -0
  11. package/dist/cli/setup/detect.d.mts +28 -0
  12. package/dist/cli/setup/detect.mjs +120 -0
  13. package/dist/cli/setup/detect.mjs.map +1 -0
  14. package/dist/cli/setup/index.cjs +225 -0
  15. package/dist/cli/setup/index.cjs.map +1 -0
  16. package/dist/cli/setup/index.d.cts +5 -0
  17. package/dist/cli/setup/index.d.mts +5 -0
  18. package/dist/cli/setup/index.mjs +222 -0
  19. package/dist/cli/setup/index.mjs.map +1 -0
  20. package/dist/cli/setup/install.cjs +76 -0
  21. package/dist/cli/setup/install.cjs.map +1 -0
  22. package/dist/cli/setup/install.d.cts +33 -0
  23. package/dist/cli/setup/install.d.mts +33 -0
  24. package/dist/cli/setup/install.mjs +74 -0
  25. package/dist/cli/setup/install.mjs.map +1 -0
  26. package/dist/cli/setup/patchers/main.cjs +151 -0
  27. package/dist/cli/setup/patchers/main.cjs.map +1 -0
  28. package/dist/cli/setup/patchers/main.d.cts +17 -0
  29. package/dist/cli/setup/patchers/main.d.mts +17 -0
  30. package/dist/cli/setup/patchers/main.mjs +149 -0
  31. package/dist/cli/setup/patchers/main.mjs.map +1 -0
  32. package/dist/cli/setup/patchers/packageJson.cjs +115 -0
  33. package/dist/cli/setup/patchers/packageJson.cjs.map +1 -0
  34. package/dist/cli/setup/patchers/packageJson.d.cts +25 -0
  35. package/dist/cli/setup/patchers/packageJson.d.mts +25 -0
  36. package/dist/cli/setup/patchers/packageJson.mjs +111 -0
  37. package/dist/cli/setup/patchers/packageJson.mjs.map +1 -0
  38. package/dist/cli/setup/patchers/preview.cjs +372 -0
  39. package/dist/cli/setup/patchers/preview.cjs.map +1 -0
  40. package/dist/cli/setup/patchers/preview.d.cts +55 -0
  41. package/dist/cli/setup/patchers/preview.d.mts +55 -0
  42. package/dist/cli/setup/patchers/preview.mjs +369 -0
  43. package/dist/cli/setup/patchers/preview.mjs.map +1 -0
  44. package/dist/cli/setup/prompt.cjs +48 -0
  45. package/dist/cli/setup/prompt.cjs.map +1 -0
  46. package/dist/cli/setup/prompt.d.cts +10 -0
  47. package/dist/cli/setup/prompt.d.mts +10 -0
  48. package/dist/cli/setup/prompt.mjs +44 -0
  49. package/dist/cli/setup/prompt.mjs.map +1 -0
  50. package/dist/cli/setup/util.cjs +355 -0
  51. package/dist/cli/setup/util.cjs.map +1 -0
  52. package/dist/cli/setup/util.d.cts +60 -0
  53. package/dist/cli/setup/util.d.mts +60 -0
  54. package/dist/cli/setup/util.mjs +349 -0
  55. package/dist/cli/setup/util.mjs.map +1 -0
  56. package/dist/panels/DefaultAutoDocsLayout.cjs +18 -1
  57. package/dist/panels/DefaultAutoDocsLayout.cjs.map +1 -1
  58. package/dist/panels/DefaultAutoDocsLayout.d.cts +2 -2
  59. package/dist/panels/DefaultAutoDocsLayout.d.mts +2 -2
  60. package/dist/panels/DefaultAutoDocsLayout.mjs +18 -2
  61. package/dist/panels/DefaultAutoDocsLayout.mjs.map +1 -1
  62. package/dist/types.d.cts +5 -3
  63. package/dist/types.d.mts +5 -3
  64. package/package.json +1 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  A plugin for [Storybook](https://storybook.js.org/) that shows the full dependency tree in both directions (built with and used by) the components in your application.
10
10
 
11
- Currently works with **React**, **Svelte**, and **Angular**.
11
+ Currently works with **React**, **Svelte**, **Angular**, and **Next.js**. The automated `sb-deps setup` wizard handles Vite-based projects (React, Svelte) end-to-end. Webpack-based projects (Angular, Next.js) need a one-time manual setup — see the [manual-setup-webpack guide](https://github.com/Dan503/storybook-addon-dependency-previews/blob/main/storybook-addon-package/docs/manual-setup-webpack.md) below.
12
12
 
13
13
  This is what you will see in Storybook after Dependency Previews have been installed and configured:
14
14
 
@@ -42,375 +42,33 @@ The below image demonstrates what you will see when you open up some of the depe
42
42
 
43
43
  ## Installation guide
44
44
 
45
- ### Package download
45
+ ### Quick start (React and Svelte)
46
46
 
47
- First you will need to install the plugin via npm as well as [dependency-cruiser](https://www.npmjs.com/package/dependency-cruiser)
47
+ After running `npx storybook@latest init` in your project, run the setup wizard:
48
48
 
49
+ ```sh
50
+ npx --package storybook-addon-dependency-previews sb-deps setup
49
51
  ```
50
- npm install -D storybook-addon-dependency-previews dependency-cruiser
51
- ```
52
-
53
- <details>
54
- <summary>Other package managers</summary>
55
- <p><pre><code>pnpm add -D storybook-addon-dependency-previews dependency-cruiser</code></pre></p>
56
- <p><pre><code>yarn add -D storybook-addon-dependency-previews dependency-cruiser</code></pre></p>
57
- <p><pre><code>bun add -D storybook-addon-dependency-previews dependency-cruiser</code></pre></p>
58
- <p><pre><code>deno add --dev npm:storybook-addon-dependency-previews npm:dependency-cruiser</code></pre></p>
59
- </details>
60
-
61
- ### Register the add-on
62
-
63
- From your root folder, open your `.storybook/main.ts` file.
64
-
65
- Edit the `main.ts` to contain the following values or copy/paste the below to replace the full contents of the main.ts file.
66
-
67
- #### Register with React
68
-
69
- ```ts
70
- import type { StorybookConfig } from '@storybook/react-vite'
71
-
72
- const config: StorybookConfig = {
73
- stories: ['../src/**/*.stories.@(ts|tsx|mdx)'],
74
- addons: [
75
- // autodocs is required for this addon to work
76
- '@storybook/addon-docs',
77
- // the storybook dependency previews addon registration
78
- 'storybook-addon-dependency-previews/addon',
79
- ],
80
- framework: {
81
- name: '@storybook/react-vite',
82
- options: {},
83
- },
84
- }
85
-
86
- export default config
87
- ```
88
-
89
- #### Register with Svelte
90
-
91
- ```ts
92
- import type { StorybookConfig } from '@storybook/sveltekit'
93
-
94
- const config: StorybookConfig = {
95
- stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|ts|svelte)'],
96
- addons: [
97
- // autodocs is required for this addon to work
98
- '@storybook/addon-docs',
99
- // required for .stories.svelte CSF format
100
- '@storybook/addon-svelte-csf',
101
- // the storybook dependency previews addon registration
102
- 'storybook-addon-dependency-previews/addon',
103
- ],
104
- framework: '@storybook/sveltekit',
105
- }
106
-
107
- export default config
108
- ```
109
-
110
- #### Register with Angular
111
-
112
- `@storybook/angular` uses webpack5 exclusively. The addon requires two webpack additions in `webpackFinal`: a `DefinePlugin` to inject `__PROJECT_ROOT__` (needed for the VS Code "open file" feature), and a `NormalModuleFactory` plugin to handle the addon's CSS modules correctly.
113
-
114
- You will also need a `css-modules-loader.cjs` file alongside your `.storybook/main.ts`. Copy it from the [Angular example source](https://github.com/Dan503/storybook-addon-dependency-previews/blob/main/example-site/angular/.storybook/css-modules-loader.cjs).
115
-
116
- ```ts
117
- import type { StorybookConfig } from '@storybook/angular'
118
- import { createRequire } from 'module'
119
- import { fileURLToPath } from 'url'
120
- import path from 'path'
121
-
122
- const require = createRequire(import.meta.url)
123
-
124
- const config: StorybookConfig = {
125
- stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
126
- addons: [
127
- // autodocs is required for this addon to work
128
- '@storybook/addon-docs',
129
- // the storybook dependency previews addon registration
130
- 'storybook-addon-dependency-previews/addon',
131
- ],
132
- framework: {
133
- name: '@storybook/angular',
134
- options: {},
135
- },
136
- webpackFinal: async (config) => {
137
- const sbAngularRequire = createRequire(
138
- import.meta.resolve('@storybook/angular'),
139
- )
140
- const webpack = sbAngularRequire('webpack') as any
141
-
142
- // Path to the css-modules-loader.cjs file (copy from the Angular example source)
143
- const cssModulesLoader = fileURLToPath(
144
- new URL('./css-modules-loader.cjs', import.meta.url),
145
- )
146
-
147
- config.plugins = config.plugins ?? []
148
-
149
- // Inject __PROJECT_ROOT__ so preview.ts can pass it to projectRootPath
150
- config.plugins.push(
151
- new webpack.DefinePlugin({
152
- __PROJECT_ROOT__: JSON.stringify(
153
- path.resolve(fileURLToPath(new URL('..', import.meta.url))),
154
- ),
155
- }),
156
- )
157
-
158
- // Handle CSS modules for the addon's dist files
159
- config.plugins.push({
160
- apply(compiler: any) {
161
- compiler.hooks.normalModuleFactory.tap(
162
- 'AddonCssModules',
163
- (factory: any) => {
164
- factory.hooks.afterResolve.tap(
165
- 'AddonCssModules',
166
- (resolveData: any) => {
167
- const resource: string =
168
- resolveData.createData?.resource ?? ''
169
- if (
170
- resource.endsWith('.module.css') &&
171
- resource.includes(
172
- 'storybook-addon-dependency-previews',
173
- )
174
- ) {
175
- resolveData.createData.loaders = [
176
- {
177
- loader: cssModulesLoader,
178
- options: {},
179
- },
180
- ]
181
- }
182
- },
183
- )
184
- },
185
- )
186
- },
187
- })
188
-
189
- return config
190
- },
191
- }
192
- export default config
193
- ```
194
-
195
- ### Bare minimum storybook story example
196
-
197
- Get a story ready so you have something to test with.
198
-
199
- Below is the bare minimum needed to generate a viable story that is compatible with the add-on.
200
-
201
- #### React `.stories.tsx` file example
202
-
203
- ```ts
204
- import type { Meta, StoryObj } from '@storybook/react-vite'
205
- import { ComponentName } from './ComponentName'
206
-
207
- const meta: Meta<typeof ComponentName> = {
208
- // You can use spaces here to make the title of the story page more human readable
209
- title: 'Component Name',
210
- component: ComponentName,
211
- // autodocs tag is required
212
- tags: ['autodocs'],
213
- // The `__filePath` property must be applied to every story file
214
- // for the addon to track dependencies effectively
215
- // `import.meta.url` is a Vite specific value that automatically generates the path for you
216
- parameters: {
217
- __filePath: import.meta.url,
218
- },
219
- }
220
-
221
- export default meta
222
-
223
- type Story = StoryObj<typeof meta>
224
52
 
225
- export const Primary: Story = {
226
- args: {},
227
- }
228
- ```
229
-
230
- #### Svelte `.stories.svelte` file using [Svelte CSF](https://github.com/storybookjs/addon-svelte-csf)
231
-
232
- ```svelte
233
- <script module>
234
- import { defineMeta } from '@storybook/addon-svelte-csf'
235
- import ComponentName from './ComponentName.svelte'
236
-
237
- const { Story } = defineMeta({
238
- title: 'Component Name',
239
- component: ComponentName,
240
- // autodocs tag is required
241
- tags: ['autodocs'],
242
- // The `__filePath` property must be applied to every story file
243
- parameters: {
244
- __filePath: import.meta.url,
245
- },
246
- })
247
- </script>
248
-
249
- <Story name="Primary" />
250
- ```
251
-
252
- #### Angular `.stories.ts` file example
253
-
254
- ```ts
255
- import type { Meta, StoryObj } from '@storybook/angular'
256
- import type { StoryParameters } from 'storybook-addon-dependency-previews'
257
- import { ComponentName } from './ComponentName.component'
258
-
259
- const meta: Meta<ComponentName> = {
260
- // You can use spaces here to make the title of the story page more human readable
261
- title: 'Component Name',
262
- component: ComponentName,
263
- // autodocs tag is required
264
- tags: ['autodocs'],
265
- // The `__filePath` property must be applied to every story file
266
- // for the addon to track dependencies effectively
267
- // `import.meta.url` is a webpack feature available in Angular Storybook
268
- parameters: {
269
- __filePath: import.meta.url,
270
- } satisfies StoryParameters,
271
- }
272
-
273
- export default meta
274
-
275
- type Story = StoryObj<ComponentName>
276
-
277
- export const Primary: Story = {}
278
- ```
279
-
280
- ### package.json scripts
281
-
282
- You will need the following scripts in your `package.json` file:
283
-
284
- ```json
285
- // package.json
286
- {
287
- ...
288
- "scripts": {
289
- ...
290
- "sb": "sb-deps --watch --run-storybook",
291
- "sb:build": "sb-deps && storybook build",
292
- "sb:deps": "sb-deps",
293
- "sb:alt-port": "sb-deps --watch --run-storybook --sb-port 7020"
294
- }
295
- ...
296
- }
297
- ```
298
-
299
- Don't run any of these yet, you are not finished with the installation.
300
-
301
- `npm run sb` will run storybook in watch mode. It will update the dependency-previews.json file whenever a story file changes, is added, or removed. Use this instead of the `storybook` command to take advantage of automatic dependency tracking while you work and auto scaffolding of stories when new story files are created.
302
-
303
- `npm run sb:build` will do a one off compile of your storybook website
304
-
305
- `npm run sb:deps` will generate a fresh dependency-previews.json on demand
306
-
307
- `npm run sb:alt-port` (optional) will run storybook in watch mode and run it using a specific port number.
308
-
309
- #### Angular projects
310
-
311
- `@storybook/angular@10+` requires Storybook to be launched through the Angular CLI builder rather than the default `storybook dev` command. Pass the Angular CLI target as an argument to `--run-storybook`:
312
-
313
- ```json
314
- "sb": "sb-deps --watch --run-storybook \"ng run <project-name>:storybook\""
315
- ```
316
-
317
- Replace `<project-name>` with the name of your Angular project as defined in `angular.json`.
318
-
319
- ### Create the preview file
320
-
321
- First run `npm run sb:deps` to generate a fresh `dependency-previews.json` file in the `.storybook` folder.
322
-
323
- Make sure that the `"resolveJsonModule"` tsConfig.json setting is set to `true` to import this file.
324
-
325
- Now create a `.storybook/preview.ts` file (or `preview.tsx` if your framework requires JSX) with the following content:
326
-
327
- ```ts
328
- /// <reference types="vite/client" />
329
-
330
- import {
331
- defaultPreviewParameters,
332
- dependencyPreviewDecorators,
333
- type StorybookPreviewConfig,
334
- } from 'storybook-addon-dependency-previews'
335
-
336
- // Import the generated dependency-previews.json file
337
- import dependenciesJson from './dependency-previews.json'
338
-
339
- // Global styles are imported here (optional)
340
- import '../src/styles.css'
341
-
342
- const previewConfig: StorybookPreviewConfig = {
343
- decorators: [...dependencyPreviewDecorators],
344
- parameters: {
345
- ...defaultPreviewParameters,
346
- dependencyPreviews: {
347
- dependenciesJson,
348
- storyModules: import.meta.glob(
349
- '/src/**/*.stories.@(tsx|ts|jsx|js|svelte)',
350
- { eager: false },
351
- ),
352
- // Replace this with the URL to your src folder in your git repository.
353
- // This enables the addon to link to the source code of the component.
354
- sourceRootUrl:
355
- 'https://github.com/your-org/your-repo/blob/main/src',
356
- // This allows Source File Path to open the
357
- // component file directly in VS Code when
358
- // running in a local host environment.
359
- // `import.meta.url` is a Vite specific feature
360
- projectRootPath: new URL('..', import.meta.url).pathname,
361
- },
362
- },
363
- }
364
-
365
- export default previewConfig
366
- ```
367
-
368
- #### Angular `preview.ts`
369
-
370
- Angular uses webpack, so `import.meta.glob` and Vite-specific APIs are not available. Use the `__PROJECT_ROOT__` value injected via `DefinePlugin` in `main.ts` instead:
371
-
372
- ```ts
373
- import type { Preview } from '@storybook/angular'
374
- import {
375
- defaultPreviewParameters,
376
- dependencyPreviewDecorators,
377
- } from 'storybook-addon-dependency-previews'
378
- import dependenciesJson from './dependency-previews.json'
379
-
380
- declare const __PROJECT_ROOT__: string
381
-
382
- const preview: Preview = {
383
- parameters: {
384
- ...defaultPreviewParameters,
385
- dependencyPreviews: {
386
- dependenciesJson,
387
- // Replace this with the URL to your src folder in your git repository.
388
- // This enables the addon to link to the source code of the component.
389
- sourceRootUrl:
390
- 'https://github.com/your-org/your-repo/blob/main/src',
391
- // __PROJECT_ROOT__ is injected by DefinePlugin in main.ts.
392
- // This allows Source File Path to open the component file
393
- // directly in VS Code when running in a local host environment.
394
- projectRootPath: __PROJECT_ROOT__,
395
- },
396
- },
397
- decorators: [...dependencyPreviewDecorators],
398
- }
399
-
400
- export default preview
401
- ```
53
+ (The package's bin is `sb-deps`, but the published package name is `storybook-addon-dependency-previews`. The explicit `--package` form makes `npx` install the right package on the first run; once the wizard has installed the addon, you can use the shorter `npx sb-deps …` form for subsequent calls.)
402
54
 
403
- > **Note:** Angular does not use `storyModules` (no `import.meta.glob`). The addon still generates the full dependency tree via the CLI — only the VS Code "open file" shortcut needs `projectRootPath`.
55
+ The wizard:
404
56
 
405
- ### Run it!
57
+ - detects your framework, package manager, and existing Storybook config,
58
+ - installs `storybook-addon-dependency-previews` and `dependency-cruiser`,
59
+ - registers the addon in `.storybook/main.ts`,
60
+ - patches (or creates) `.storybook/preview.ts` with the addon's parameters and decorators,
61
+ - adds the `sb`, `sb:deps`, and `sb:build` scripts to your `package.json`,
62
+ - generates the initial `.storybook/dependency-previews.json`.
406
63
 
407
- You should be all set now.
64
+ When it finishes, run `npm run sb` (or your package manager's equivalent) to start Storybook with dependency watching.
408
65
 
409
- Try running `npm run sb` to boot up storybook, leave it running as you work.
66
+ ### Manual setup
410
67
 
411
- As you create new component files, the component will be auto-scaffolded for you and a matching story file will be created for it automatically. The dependency previews json file will also be auto-updated.
68
+ The wizard supports React (`@storybook/react-vite`) and Svelte (`@storybook/sveltekit`, `@storybook/svelte-vite`) — all Vite-based. **Angular (`@storybook/angular`) and Next.js (`@storybook/nextjs`) projects are both webpack-based and require manual setup** — the wizard's preview-patcher relies on Vite's `import.meta.glob`, which webpack doesn't expose. Follow the matching guide below:
412
69
 
413
- This workflow allows you to focus on what matters instead of having to waste time writing lots of boilerplate code every time you want to create a new component.
70
+ - [Manual setup — Vite (React, Svelte)](https://github.com/Dan503/storybook-addon-dependency-previews/blob/main/storybook-addon-package/docs/manual-setup-vite.md)
71
+ - [Manual setup — webpack (`@storybook/angular`, `@storybook/nextjs`)](https://github.com/Dan503/storybook-addon-dependency-previews/blob/main/storybook-addon-package/docs/manual-setup-webpack.md)
414
72
 
415
73
  ## Configuration file (optional)
416
74
 
@@ -1,7 +1,7 @@
1
- import * as react_jsx_runtime1 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
2
 
3
3
  //#region src/blocks/DependencyPreviews.d.ts
4
- declare function DependencyPreviews(): react_jsx_runtime1.JSX.Element;
4
+ declare function DependencyPreviews(): react_jsx_runtime0.JSX.Element;
5
5
  //#endregion
6
6
  export { DependencyPreviews };
7
7
  //# sourceMappingURL=DependencyPreviews.d.cts.map
@@ -1,7 +1,7 @@
1
- import * as react_jsx_runtime1 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
2
 
3
3
  //#region src/blocks/DependencyPreviews.d.ts
4
- declare function DependencyPreviews(): react_jsx_runtime1.JSX.Element;
4
+ declare function DependencyPreviews(): react_jsx_runtime0.JSX.Element;
5
5
  //#endregion
6
6
  export { DependencyPreviews };
7
7
  //# sourceMappingURL=DependencyPreviews.d.mts.map
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
+ const require_cli_setup_index = require('./setup/index.cjs');
3
4
  let node_fs = require("node:fs");
4
5
  node_fs = require_rolldown_runtime.__toESM(node_fs);
5
6
  let node_path = require("node:path");
@@ -17,18 +18,19 @@ node_url = require_rolldown_runtime.__toESM(node_url);
17
18
 
18
19
  //#region cli/sb-deps.ts
19
20
  const argv = process.argv.slice(2);
21
+ const SUBCOMMAND = argv[0] && !argv[0].startsWith("--") ? argv[0] : null;
20
22
  const WATCH = argv.includes("--watch");
21
23
  const RUN_SB_IDX = argv.indexOf("--run-storybook");
22
24
  const RUN_SB = RUN_SB_IDX !== -1;
23
25
  const _RUN_SB_NEXT = RUN_SB ? argv[RUN_SB_IDX + 1] : undefined;
24
26
  const SB_CUSTOM_CMD = _RUN_SB_NEXT && !_RUN_SB_NEXT.startsWith("--") ? _RUN_SB_NEXT : undefined;
25
- const PORT_ARGI = Math.max(argv.indexOf("--sb-port"), 0);
26
- const SB_PORT = PORT_ARGI && argv[PORT_ARGI + 1] ? Number(argv[PORT_ARGI + 1]) || 6006 : 6006;
27
+ const PORT_ARGI = argv.indexOf("--sb-port");
28
+ const SB_PORT = PORT_ARGI !== -1 && argv[PORT_ARGI + 1] ? Number(argv[PORT_ARGI + 1]) || 6006 : 6006;
27
29
  const projectRoot = process.cwd();
28
30
  const outDir = (0, node_path.resolve)(projectRoot, ".storybook");
29
31
  const rawPath = (0, node_path.join)(outDir, "dependency-previews.raw.json");
30
32
  const cookedPath = (0, node_path.join)(outDir, "dependency-previews.json");
31
- if (!(0, node_fs.existsSync)(outDir)) (0, node_fs.mkdirSync)(outDir, { recursive: true });
33
+ if (SUBCOMMAND !== "setup" && !(0, node_fs.existsSync)(outDir)) (0, node_fs.mkdirSync)(outDir, { recursive: true });
32
34
  const __filename$1 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
33
35
  const __dirname$1 = (0, node_path.dirname)(__filename$1);
34
36
  const pkgDefault = (0, node_path.resolve)(__dirname$1, "scripts", "depcruise.config.cjs");
@@ -681,10 +683,11 @@ async function startStorybook() {
681
683
  const isWin = process.platform === "win32";
682
684
  let cmd;
683
685
  let args;
686
+ let shellMode;
684
687
  if (SB_CUSTOM_CMD) {
685
- const parts = SB_CUSTOM_CMD.split(" ");
686
- cmd = parts[0];
687
- args = parts.slice(1);
688
+ cmd = SB_CUSTOM_CMD;
689
+ args = [];
690
+ shellMode = true;
688
691
  } else {
689
692
  cmd = "npx";
690
693
  args = [
@@ -694,12 +697,13 @@ async function startStorybook() {
694
697
  "-p",
695
698
  String(SB_PORT)
696
699
  ];
700
+ shellMode = isWin;
697
701
  }
698
702
  info(`[sb-deps] launching: ${cmd} ${args.join(" ")}`);
699
703
  sbChild = (0, node_child_process.spawn)(cmd, args, {
700
704
  cwd: projectRoot,
701
705
  stdio: "inherit",
702
- shell: isWin,
706
+ shell: shellMode,
703
707
  env: process.env
704
708
  });
705
709
  sbChild.on("error", (err) => {
@@ -713,6 +717,10 @@ async function startStorybook() {
713
717
  }
714
718
  ;
715
719
  (async () => {
720
+ if (SUBCOMMAND === "setup") {
721
+ await require_cli_setup_index.runSetup(argv.slice(1));
722
+ return;
723
+ }
716
724
  const cfg = await loadSbDepsConfig();
717
725
  ANGULAR_SELECTOR_PREFIX = cfg.angularSelectorPrefix ?? "app-";
718
726
  SCAFFOLD_CONFIG = cfg.scaffold ?? {};