@nx/storybook 17.0.4 → 17.0.6

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 (39) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -9
  3. package/generators.json +2 -2
  4. package/migrations.json +0 -140
  5. package/package.json +7 -7
  6. package/presets/cypress.d.ts +20 -1
  7. package/src/executors/build-storybook/build-storybook.impl.js +1 -1
  8. package/src/executors/storybook/storybook.impl.js +1 -1
  9. package/src/generators/configuration/configuration.d.ts +1 -2
  10. package/src/generators/configuration/configuration.js +32 -69
  11. package/src/generators/configuration/lib/util-functions.d.ts +5 -11
  12. package/src/generators/configuration/lib/util-functions.js +69 -88
  13. package/src/generators/configuration/project-files/.storybook/main.js__tmpl__ +3 -23
  14. package/src/generators/configuration/project-files-ts/.storybook/main.ts__tmpl__ +3 -22
  15. package/src/generators/configuration/schema.d.ts +3 -9
  16. package/src/generators/configuration/schema.json +13 -6
  17. package/src/generators/cypress-project/cypress-project.d.ts +3 -3
  18. package/src/generators/cypress-project/cypress-project.js +8 -3
  19. package/src/generators/cypress-project/schema.json +1 -1
  20. package/src/generators/init/init.d.ts +0 -1
  21. package/src/generators/init/init.js +117 -47
  22. package/src/generators/init/schema.d.ts +4 -5
  23. package/src/generators/init/schema.json +33 -18
  24. package/src/migrations/update-16-5-0/move-storybook-tsconfig.js +0 -1
  25. package/src/utils/models.d.ts +1 -1
  26. package/src/utils/utilities.d.ts +0 -1
  27. package/src/utils/utilities.js +8 -30
  28. package/src/utils/versions.d.ts +7 -6
  29. package/src/utils/versions.js +8 -7
  30. package/plugin.d.ts +0 -1
  31. package/plugin.js +0 -6
  32. package/src/generators/configuration/lib/edit-root-tsconfig.d.ts +0 -8
  33. package/src/generators/configuration/lib/edit-root-tsconfig.js +0 -35
  34. package/src/generators/configuration/lib/ensure-dependencies.d.ts +0 -6
  35. package/src/generators/configuration/lib/ensure-dependencies.js +0 -70
  36. package/src/generators/init/lib/update-gitignore.d.ts +0 -2
  37. package/src/generators/init/lib/update-gitignore.js +0 -16
  38. package/src/plugins/plugin.d.ts +0 -9
  39. package/src/plugins/plugin.js +0 -232
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renameAndMoveOldTsConfig = exports.findMetroConfig = exports.findNextConfig = exports.findViteConfig = exports.getE2EProjectName = exports.rootFileIsTs = exports.workspaceHasRootProject = exports.projectIsRootProjectInStandaloneWorkspace = exports.addBuildStorybookToCacheableOperations = exports.getTsConfigPath = exports.createProjectStorybookDir = exports.addStorybookToTargetDefaults = exports.addStorybookToNamedInputs = exports.normalizeSchema = exports.updateLintConfig = exports.configureTsSolutionConfig = exports.configureTsProjectConfig = exports.editTsconfigBaseJson = exports.createStorybookTsconfigFile = exports.addStaticTarget = exports.addAngularStorybookTarget = exports.addStorybookTarget = void 0;
3
+ exports.renameAndMoveOldTsConfig = exports.getViteConfigFilePath = exports.getE2EProjectName = exports.rootFileIsTs = exports.workspaceHasRootProject = exports.projectIsRootProjectInStandaloneWorkspace = exports.addBuildStorybookToCacheableOperations = exports.getTsConfigPath = exports.createProjectStorybookDir = exports.addStorybookToNamedInputs = exports.normalizeSchema = exports.updateLintConfig = exports.configureTsSolutionConfig = exports.configureTsProjectConfig = exports.editTsconfigBaseJson = exports.createStorybookTsconfigFile = exports.addStaticTarget = exports.addAngularStorybookTask = exports.addStorybookTask = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
6
  const eslint_1 = require("@nx/eslint");
@@ -10,7 +10,10 @@ const versions_1 = require("../../../utils/versions");
10
10
  const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
11
11
  const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
12
12
  const DEFAULT_PORT = 4400;
13
- function addStorybookTarget(tree, projectName, uiFramework, interactionTests) {
13
+ function addStorybookTask(tree, projectName, uiFramework, interactionTests) {
14
+ if (uiFramework === '@storybook/react-native') {
15
+ return;
16
+ }
14
17
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
15
18
  projectConfig.targets['storybook'] = {
16
19
  executor: '@nx/storybook:storybook',
@@ -47,8 +50,8 @@ function addStorybookTarget(tree, projectName, uiFramework, interactionTests) {
47
50
  }
48
51
  (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
49
52
  }
50
- exports.addStorybookTarget = addStorybookTarget;
51
- function addAngularStorybookTarget(tree, projectName, interactionTests) {
53
+ exports.addStorybookTask = addStorybookTask;
54
+ function addAngularStorybookTask(tree, projectName, interactionTests) {
52
55
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
53
56
  const { ngBuildTarget } = (0, utilities_1.findStorybookAndBuildTargetsAndCompiler)(projectConfig.targets);
54
57
  projectConfig.targets['storybook'] = {
@@ -90,21 +93,21 @@ function addAngularStorybookTarget(tree, projectName, interactionTests) {
90
93
  }
91
94
  (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
92
95
  }
93
- exports.addAngularStorybookTarget = addAngularStorybookTarget;
94
- async function addStaticTarget(tree, opts) {
95
- const { webStaticServeGenerator } = (0, devkit_1.ensurePackage)('@nx/web', versions_1.nxVersion);
96
- await webStaticServeGenerator(tree, {
97
- buildTarget: `${opts.project}:build-storybook`,
98
- outputPath: (0, devkit_1.joinPathFragments)('dist/storybook', opts.project),
96
+ exports.addAngularStorybookTask = addAngularStorybookTask;
97
+ function addStaticTarget(tree, opts) {
98
+ const nrwlWeb = (0, devkit_1.ensurePackage)('@nx/web', versions_1.nxVersion);
99
+ nrwlWeb.webStaticServeGenerator(tree, {
100
+ buildTarget: `${opts.name}:build-storybook`,
101
+ outputPath: (0, devkit_1.joinPathFragments)('dist/storybook', opts.name),
99
102
  targetName: 'static-storybook',
100
103
  });
101
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, opts.project);
104
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, opts.name);
102
105
  projectConfig.targets['static-storybook'].configurations = {
103
106
  ci: {
104
- buildTarget: `${opts.project}:build-storybook:ci`,
107
+ buildTarget: `${opts.name}:build-storybook:ci`,
105
108
  },
106
109
  };
107
- (0, devkit_1.updateProjectConfiguration)(tree, opts.project, projectConfig);
110
+ (0, devkit_1.updateProjectConfiguration)(tree, opts.name, projectConfig);
108
111
  }
109
112
  exports.addStaticTarget = addStaticTarget;
110
113
  function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProject, mainDir) {
@@ -149,6 +152,9 @@ function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProje
149
152
  '.storybook/*.js',
150
153
  '.storybook/*.ts',
151
154
  ];
155
+ if (uiFramework === '@storybook/react-native') {
156
+ include.push('*.ts', '*.tsx');
157
+ }
152
158
  const storybookTsConfig = {
153
159
  extends: './tsconfig.json',
154
160
  compilerOptions: {
@@ -180,7 +186,7 @@ function editTsconfigBaseJson(tree) {
180
186
  }
181
187
  exports.editTsconfigBaseJson = editTsconfigBaseJson;
182
188
  function configureTsProjectConfig(tree, schema) {
183
- const { project: projectName } = schema;
189
+ const { name: projectName } = schema;
184
190
  let tsConfigPath;
185
191
  let tsConfigContent;
186
192
  try {
@@ -202,7 +208,8 @@ function configureTsProjectConfig(tree, schema) {
202
208
  ...(tsConfigContent.exclude || []),
203
209
  '**/*.stories.ts',
204
210
  '**/*.stories.js',
205
- ...(schema.uiFramework?.startsWith('@storybook/react')
211
+ ...(schema.uiFramework === '@storybook/react-native' ||
212
+ schema.uiFramework?.startsWith('@storybook/react')
206
213
  ? ['**/*.stories.jsx', '**/*.stories.tsx']
207
214
  : []),
208
215
  ];
@@ -211,7 +218,7 @@ function configureTsProjectConfig(tree, schema) {
211
218
  }
212
219
  exports.configureTsProjectConfig = configureTsProjectConfig;
213
220
  function configureTsSolutionConfig(tree, schema) {
214
- const { project: projectName } = schema;
221
+ const { name: projectName } = schema;
215
222
  const { root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
216
223
  const tsConfigPath = (0, path_1.join)(root, 'tsconfig.json');
217
224
  const tsConfigContent = (0, devkit_1.readJson)(tree, tsConfigPath);
@@ -250,7 +257,7 @@ exports.configureTsSolutionConfig = configureTsSolutionConfig;
250
257
  * This is done within the eslint config file.
251
258
  */
252
259
  function updateLintConfig(tree, schema) {
253
- const { project: projectName } = schema;
260
+ const { name: projectName } = schema;
254
261
  const { root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
255
262
  const eslintFile = (0, eslint_file_1.findEslintFile)(tree, root);
256
263
  if (!eslintFile) {
@@ -299,10 +306,6 @@ function updateLintConfig(tree, schema) {
299
306
  ]);
300
307
  }
301
308
  }
302
- const ignorePatterns = json.ignorePatterns || [];
303
- if (!ignorePatterns.includes('storybook-static')) {
304
- ignorePatterns.push('storybook-static');
305
- }
306
309
  return json;
307
310
  });
308
311
  }
@@ -335,39 +338,29 @@ function addStorybookToNamedInputs(tree) {
335
338
  nxJson.namedInputs.production.push('!{projectRoot}/tsconfig.storybook.json');
336
339
  }
337
340
  }
341
+ nxJson.targetDefaults ??= {};
342
+ nxJson.targetDefaults['build-storybook'] ??= {};
343
+ nxJson.targetDefaults['build-storybook'].inputs ??= [
344
+ 'default',
345
+ hasProductionFileset ? '^production' : '^default',
346
+ ];
347
+ if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/.storybook/**/*')) {
348
+ nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/.storybook/**/*');
349
+ }
350
+ // Delete the !{projectRoot}/.storybook/**/* glob from build-storybook
351
+ // because we want to rebuild Storybook if the .storybook folder changes
352
+ const index = nxJson.targetDefaults['build-storybook'].inputs.indexOf('!{projectRoot}/.storybook/**/*');
353
+ if (index !== -1) {
354
+ nxJson.targetDefaults['build-storybook'].inputs.splice(index, 1);
355
+ }
356
+ if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/tsconfig.storybook.json')) {
357
+ nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/tsconfig.storybook.json');
358
+ }
338
359
  (0, devkit_1.updateNxJson)(tree, nxJson);
339
360
  }
340
361
  }
341
362
  exports.addStorybookToNamedInputs = addStorybookToNamedInputs;
342
- function addStorybookToTargetDefaults(tree, setCache = true) {
343
- const nxJson = (0, devkit_1.readNxJson)(tree);
344
- nxJson.targetDefaults ??= {};
345
- nxJson.targetDefaults['build-storybook'] ??= {};
346
- if (setCache) {
347
- nxJson.targetDefaults['build-storybook'].cache ??= true;
348
- }
349
- nxJson.targetDefaults['build-storybook'].inputs ??= [
350
- 'default',
351
- nxJson.namedInputs && 'production' in nxJson.namedInputs
352
- ? '^production'
353
- : '^default',
354
- ];
355
- if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/.storybook/**/*')) {
356
- nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/.storybook/**/*');
357
- }
358
- // Delete the !{projectRoot}/.storybook/**/* glob from build-storybook
359
- // because we want to rebuild Storybook if the .storybook folder changes
360
- const index = nxJson.targetDefaults['build-storybook'].inputs.indexOf('!{projectRoot}/.storybook/**/*');
361
- if (index !== -1) {
362
- nxJson.targetDefaults['build-storybook'].inputs.splice(index, 1);
363
- }
364
- if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/tsconfig.storybook.json')) {
365
- nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/tsconfig.storybook.json');
366
- }
367
- (0, devkit_1.updateNxJson)(tree, nxJson);
368
- }
369
- exports.addStorybookToTargetDefaults = addStorybookToTargetDefaults;
370
- function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName, useReactNative) {
363
+ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath) {
371
364
  let projectDirectory = projectType === 'application'
372
365
  ? isNextJs
373
366
  ? 'components'
@@ -398,9 +391,6 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
398
391
  usesVite,
399
392
  isRootProject: projectIsRootProjectInStandaloneWorkspace,
400
393
  viteConfigFilePath,
401
- hasPlugin,
402
- viteConfigFileName,
403
- useReactNative,
404
394
  });
405
395
  if (js) {
406
396
  (0, devkit_1.toJS)(tree);
@@ -426,12 +416,23 @@ function getTsConfigPath(tree, projectName, path) {
426
416
  }
427
417
  exports.getTsConfigPath = getTsConfigPath;
428
418
  function addBuildStorybookToCacheableOperations(tree) {
429
- const nxJson = (0, devkit_1.readNxJson)(tree);
430
- if (nxJson.tasksRunnerOptions?.default?.options?.cacheableOperations &&
431
- !nxJson.tasksRunnerOptions.default.options.cacheableOperations.includes('build-storybook')) {
432
- nxJson.tasksRunnerOptions.default.options.cacheableOperations.push('build-storybook');
433
- (0, devkit_1.updateNxJson)(tree, nxJson);
434
- }
419
+ (0, devkit_1.updateJson)(tree, 'nx.json', (json) => ({
420
+ ...json,
421
+ tasksRunnerOptions: {
422
+ ...(json.tasksRunnerOptions ?? {}),
423
+ default: {
424
+ ...(json.tasksRunnerOptions?.default ?? {}),
425
+ options: {
426
+ ...(json.tasksRunnerOptions?.default?.options ?? {}),
427
+ cacheableOperations: Array.from(new Set([
428
+ ...(json.tasksRunnerOptions?.default?.options
429
+ ?.cacheableOperations ?? []),
430
+ 'build-storybook',
431
+ ])),
432
+ },
433
+ },
434
+ },
435
+ }));
435
436
  }
436
437
  exports.addBuildStorybookToCacheableOperations = addBuildStorybookToCacheableOperations;
437
438
  function projectIsRootProjectInStandaloneWorkspace(projectRoot) {
@@ -478,36 +479,16 @@ async function getE2EProjectName(tree, mainProject) {
478
479
  return e2eProject;
479
480
  }
480
481
  exports.getE2EProjectName = getE2EProjectName;
481
- function findViteConfig(tree, projectRoot) {
482
- const allowsExt = ['js', 'mjs', 'ts', 'cjs', 'mts', 'cts'];
483
- for (const ext of allowsExt) {
484
- const viteConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, `vite.config.${ext}`);
485
- if (tree.exists(viteConfigPath)) {
486
- return {
487
- fullConfigPath: viteConfigPath,
488
- viteConfigFileName: `vite.config.${ext}`,
489
- };
490
- }
491
- }
492
- }
493
- exports.findViteConfig = findViteConfig;
494
- function findNextConfig(tree, projectRoot) {
495
- const allowsExt = ['js', 'mjs', 'cjs'];
496
- for (const ext of allowsExt) {
497
- const nextConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, `next.config.${ext}`);
498
- if (tree.exists(nextConfigPath)) {
499
- return nextConfigPath;
500
- }
501
- }
502
- }
503
- exports.findNextConfig = findNextConfig;
504
- function findMetroConfig(tree, projectRoot) {
505
- const nextConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, `metro.config.js`);
506
- if (tree.exists(nextConfigPath)) {
507
- return nextConfigPath;
508
- }
482
+ function getViteConfigFilePath(tree, projectRoot, configFile) {
483
+ return configFile && tree.exists(configFile)
484
+ ? configFile
485
+ : tree.exists((0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.ts`))
486
+ ? (0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.ts`)
487
+ : tree.exists((0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.js`))
488
+ ? (0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.js`)
489
+ : undefined;
509
490
  }
510
- exports.findMetroConfig = findMetroConfig;
491
+ exports.getViteConfigFilePath = getViteConfigFilePath;
511
492
  function renameAndMoveOldTsConfig(projectRoot, pathToStorybookConfigFile, tree) {
512
493
  if (pathToStorybookConfigFile && tree.exists(pathToStorybookConfigFile)) {
513
494
  (0, devkit_1.updateJson)(tree, pathToStorybookConfigFile, (json) => {
@@ -9,38 +9,18 @@ const config = {
9
9
  '../**/*.stories.@(js|jsx|ts|tsx|mdx)' <% } else { %>
10
10
  '../<%= projectDirectory %>/**/*.stories.@(js|jsx|ts|tsx|mdx)'
11
11
  <% } %>],
12
- addons: ['@storybook/addon-essentials' <% if(interactionTests) { %>, '@storybook/addon-interactions' <% } %><% if(uiFramework === '@storybook/react-webpack5') { %>, '@nx/react/plugins/storybook' <% } %>],
12
+ addons: ['@storybook/addon-essentials' <% if(interactionTests) { %>, '@storybook/addon-interactions' <% } %><% if(uiFramework === '@storybook/react-webpack5') { %>, '@nx/react/plugins/storybook' <% } %><% if(uiFramework === '@storybook/react-native') { %>, '@storybook/addon-ondevice-actions', '@storybook/addon-ondevice-backgrounds', '@storybook/addon-ondevice-controls', '@storybook/addon-ondevice-notes' <% } %>],
13
13
  framework: {
14
14
  name: '<%= uiFramework %>',
15
15
  options: {
16
- <% if (usesVite && viteConfigFilePath && hasPlugin) { %>
17
- builder: {
18
- viteConfigPath: '<%= viteConfigFileName %>',
19
- },
20
- <% } %>
21
- <% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
16
+ <% if (usesVite && viteConfigFilePath) { %>
22
17
  builder: {
23
18
  viteConfigPath: '<%= viteConfigFilePath %>',
24
19
  },
25
20
  <% } %>
26
21
  },
27
22
  },
28
- <% if (useReactNative && uiFramework === '@storybook/react-webpack5') { %>webpackFinal: async (config) => {
29
- if (config.resolve) {
30
- config.resolve.alias = {
31
- ...config.resolve.alias,
32
- 'react-native$': 'react-native-web',
33
- };
34
- config.resolve.extensions = [
35
- '.web.tsx',
36
- '.web.ts',
37
- '.web.jsx',
38
- '.web.js',
39
- ...(config.resolve.extensions ?? []),
40
- ];
41
- }
42
- return config;
43
- },<% } %><% if (usesVite && !viteConfigFilePath) { %>
23
+ <% if (usesVite && !viteConfigFilePath) { %>
44
24
  viteFinal: async (config) =>
45
25
  mergeConfig(config, {
46
26
  plugins: [nxViteTsPaths()],
@@ -10,37 +10,18 @@ const config: StorybookConfig = {
10
10
  '../**/*.stories.@(js|jsx|ts|tsx|mdx)' <% } else { %>
11
11
  '../<%= projectDirectory %>/**/*.stories.@(js|jsx|ts|tsx|mdx)'
12
12
  <% } %>],
13
- addons: ['@storybook/addon-essentials' <% if(interactionTests) { %>, '@storybook/addon-interactions' <% } %><% if(uiFramework === '@storybook/react-webpack5') { %>, '@nx/react/plugins/storybook' <% } %>],
13
+ addons: ['@storybook/addon-essentials' <% if(interactionTests) { %>, '@storybook/addon-interactions' <% } %><% if(uiFramework === '@storybook/react-webpack5') { %>, '@nx/react/plugins/storybook' <% } %><% if(uiFramework === '@storybook/react-native') { %>, '@storybook/addon-ondevice-actions', '@storybook/addon-ondevice-backgrounds', '@storybook/addon-ondevice-controls', '@storybook/addon-ondevice-notes' <% } %>],
14
14
  framework: {
15
15
  name: '<%= uiFramework %>',
16
16
  options: {
17
- <% if (usesVite && viteConfigFilePath && hasPlugin) { %>
18
- builder: {
19
- viteConfigPath: '<%= viteConfigFileName %>',
20
- },
21
- <% } %><% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
17
+ <% if (usesVite && viteConfigFilePath) { %>
22
18
  builder: {
23
19
  viteConfigPath: '<%= viteConfigFilePath %>',
24
20
  },
25
21
  <% } %>
26
22
  },
27
23
  },
28
- <% if (useReactNative && uiFramework === '@storybook/react-webpack5') { %>webpackFinal: async (config) => {
29
- if (config.resolve) {
30
- config.resolve.alias = {
31
- ...config.resolve.alias,
32
- 'react-native$': 'react-native-web',
33
- };
34
- config.resolve.extensions = [
35
- '.web.tsx',
36
- '.web.ts',
37
- '.web.jsx',
38
- '.web.js',
39
- ...(config.resolve.extensions ?? []),
40
- ];
41
- }
42
- return config;
43
- },<% } %><% if (usesVite && !viteConfigFilePath) { %>
24
+ <% if (usesVite && !viteConfigFilePath) { %>
44
25
  viteFinal: async (config) =>
45
26
  mergeConfig(config, {
46
27
  plugins: [nxViteTsPaths()],
@@ -2,7 +2,7 @@ import { Linter } from '@nx/eslint';
2
2
  import { UiFramework } from '../../utils/models';
3
3
 
4
4
  export interface StorybookConfigureSchema {
5
- project: string;
5
+ name: string;
6
6
  uiFramework?: UiFramework;
7
7
  linter?: Linter;
8
8
  js?: boolean;
@@ -12,17 +12,11 @@ export interface StorybookConfigureSchema {
12
12
  configureStaticServe?: boolean;
13
13
  skipFormat?: boolean;
14
14
  /**
15
- * @deprecated Use interactionTests instead. This option will be removed in v19.
15
+ * @deprecated Use interactionTests instead. This option will be removed in v18.
16
16
  */
17
17
  configureCypress?: boolean;
18
18
  /**
19
- * @deprecated Use interactionTests instead. This option will be removed in v19.
19
+ * @deprecated Use interactionTests instead. This option will be removed in v18.
20
20
  */
21
21
  cypressDirectory?: string;
22
- addPlugin?: boolean;
23
-
24
- /**
25
- * @internal
26
- */
27
- addExplicitTargets?: boolean;
28
22
  }
@@ -1,14 +1,14 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxStorybookConfigure",
5
5
  "title": "Storybook Configuration",
6
6
  "description": "Add Storybook configuration to a UI library or an application.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "project": {
9
+ "name": {
10
10
  "type": "string",
11
- "aliases": ["name", "projectName"],
11
+ "aliases": ["project", "projectName"],
12
12
  "description": "Project for which to generate Storybook configuration.",
13
13
  "$default": {
14
14
  "$source": "argv",
@@ -28,12 +28,12 @@
28
28
  "configureCypress": {
29
29
  "type": "boolean",
30
30
  "description": "Run the cypress-configure generator.",
31
- "x-deprecated": "Use interactionTests instead. This option will be removed in v19."
31
+ "x-deprecated": "Use interactionTests instead. This option will be removed in v18."
32
32
  },
33
33
  "cypressDirectory": {
34
34
  "type": "string",
35
35
  "description": "A directory where the Cypress project will be placed. Added at root by default.",
36
- "x-deprecated": "Use interactionTests instead. This option will be removed in v19."
36
+ "x-deprecated": "Use interactionTests instead. This option will be removed in v18."
37
37
  },
38
38
  "linter": {
39
39
  "description": "The tool to use for running lint checks.",
@@ -63,6 +63,13 @@
63
63
  "description": "Add a static-storybook to serve the static storybook built files.",
64
64
  "default": false
65
65
  },
66
+ "bundler": {
67
+ "description": "The Storybook builder to use.",
68
+ "type": "string",
69
+ "enum": ["vite", "webpack"],
70
+ "default": "webpack",
71
+ "x-priority": "important"
72
+ },
66
73
  "uiFramework": {
67
74
  "type": "string",
68
75
  "description": "Storybook UI Framework to use.",
@@ -96,6 +103,6 @@
96
103
  "x-priority": "internal"
97
104
  }
98
105
  },
99
- "required": ["project", "uiFramework"],
106
+ "required": ["name", "uiFramework"],
100
107
  "examplesFile": "../../../docs/configuration-generator-examples.md"
101
108
  }
@@ -1,4 +1,4 @@
1
- import { Tree } from '@nx/devkit';
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Linter } from '@nx/eslint';
3
3
  export interface CypressConfigureSchema {
4
4
  name: string;
@@ -10,6 +10,6 @@ export interface CypressConfigureSchema {
10
10
  skipFormat?: boolean;
11
11
  projectNameAndRootFormat?: 'as-provided' | 'derived';
12
12
  }
13
- export declare function cypressProjectGenerator(tree: Tree, schema: CypressConfigureSchema): Promise<import("@nx/devkit").GeneratorCallback>;
14
- export declare function cypressProjectGeneratorInternal(tree: Tree, schema: CypressConfigureSchema): Promise<import("@nx/devkit").GeneratorCallback>;
13
+ export declare function cypressProjectGenerator(tree: Tree, schema: CypressConfigureSchema): Promise<GeneratorCallback>;
14
+ export declare function cypressProjectGeneratorInternal(tree: Tree, schema: CypressConfigureSchema): Promise<GeneratorCallback>;
15
15
  export default cypressProjectGenerator;
@@ -15,7 +15,7 @@ async function cypressProjectGenerator(tree, schema) {
15
15
  }
16
16
  exports.cypressProjectGenerator = cypressProjectGenerator;
17
17
  async function cypressProjectGeneratorInternal(tree, schema) {
18
- const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
18
+ const { configurationGenerator, cypressInitGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
19
19
  const e2eName = schema.name ? `${schema.name}-e2e` : undefined;
20
20
  const { projectName, projectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
21
21
  name: e2eName,
@@ -26,6 +26,10 @@ async function cypressProjectGeneratorInternal(tree, schema) {
26
26
  });
27
27
  const libConfig = (0, devkit_1.readProjectConfiguration)(tree, schema.name);
28
28
  const libRoot = libConfig.root;
29
+ const tasks = [];
30
+ if (!projectAlreadyHasCypress(tree)) {
31
+ tasks.push(await cypressInitGenerator(tree, {}));
32
+ }
29
33
  (0, devkit_1.addProjectConfiguration)(tree, projectName, {
30
34
  root: projectRoot,
31
35
  projectType: 'application',
@@ -33,7 +37,7 @@ async function cypressProjectGeneratorInternal(tree, schema) {
33
37
  targets: {},
34
38
  implicitDependencies: [projectName],
35
39
  });
36
- const cypressTask = await configurationGenerator(tree, {
40
+ const installTask = await configurationGenerator(tree, {
37
41
  project: projectName,
38
42
  js: schema.js,
39
43
  linter: schema.linter,
@@ -41,6 +45,7 @@ async function cypressProjectGeneratorInternal(tree, schema) {
41
45
  devServerTarget: `${schema.name}:storybook`,
42
46
  skipFormat: true,
43
47
  });
48
+ tasks.push(installTask);
44
49
  const generatedCypressProjectName = (0, project_name_1.getE2eProjectName)(schema.name, libRoot, schema.directory);
45
50
  removeUnneededFiles(tree, generatedCypressProjectName, schema.js);
46
51
  addBaseUrlToCypressConfig(tree, generatedCypressProjectName);
@@ -52,7 +57,7 @@ async function cypressProjectGeneratorInternal(tree, schema) {
52
57
  if (!schema.skipFormat) {
53
58
  await (0, devkit_1.formatFiles)(tree);
54
59
  }
55
- return cypressTask;
60
+ return (0, devkit_1.runTasksInSerial)(...tasks);
56
61
  }
57
62
  exports.cypressProjectGeneratorInternal = cypressProjectGeneratorInternal;
58
63
  function removeUnneededFiles(tree, projectName, js) {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "cypress-configure",
5
5
  "title": "Cypress Configuration",
@@ -1,5 +1,4 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
3
  export declare function initGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
- export declare function initGeneratorInternal(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
5
4
  export default initGenerator;