@nx/storybook 16.6.0-beta.0 → 16.6.0-beta.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/storybook",
3
- "version": "16.6.0-beta.0",
3
+ "version": "16.6.0-beta.2",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Storybook contains executors and generators for allowing your workspace to use the powerful Storybook integration testing & documenting capabilities.",
6
6
  "repository": {
@@ -30,12 +30,12 @@
30
30
  "migrations": "./migrations.json"
31
31
  },
32
32
  "dependencies": {
33
- "@nrwl/storybook": "16.6.0-beta.0",
34
- "@nx/cypress": "16.6.0-beta.0",
35
- "@nx/devkit": "16.6.0-beta.0",
36
- "@nx/js": "16.6.0-beta.0",
37
- "@nx/linter": "16.6.0-beta.0",
38
- "@nx/workspace": "16.6.0-beta.0",
33
+ "@nrwl/storybook": "16.6.0-beta.2",
34
+ "@nx/cypress": "16.6.0-beta.2",
35
+ "@nx/devkit": "16.6.0-beta.2",
36
+ "@nx/js": "16.6.0-beta.2",
37
+ "@nx/linter": "16.6.0-beta.2",
38
+ "@nx/workspace": "16.6.0-beta.2",
39
39
  "@phenomnomnominal/tsquery": "~5.0.1",
40
40
  "dotenv": "~10.0.0",
41
41
  "semver": "7.5.3"
@@ -44,5 +44,5 @@
44
44
  "access": "public"
45
45
  },
46
46
  "types": "./index.d.ts",
47
- "gitHead": "5a7ffb93c9e84bffbf52f6ae9c6c1e3b8edb9d35"
47
+ "gitHead": "c3d31711b71d648cedeff688fce9334d393b586b"
48
48
  }
@@ -44,7 +44,7 @@ function configurationGenerator(tree, rawSchema) {
44
44
  });
45
45
  tasks.push(initTask);
46
46
  const mainDir = !!nextBuildTarget && projectType === 'application' ? 'components' : 'src';
47
- (0, util_functions_1.createProjectStorybookDir)(tree, schema.name, schema.uiFramework, schema.js, schema.tsConfiguration, root, projectType, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), mainDir, !!nextBuildTarget, compiler === 'swc', !!viteBuildTarget || schema.uiFramework.endsWith('-vite'), viteConfigFilePath);
47
+ (0, util_functions_1.createProjectStorybookDir)(tree, schema.name, schema.uiFramework, schema.js, schema.tsConfiguration, root, projectType, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), schema.interactionTests, mainDir, !!nextBuildTarget, compiler === 'swc', !!viteBuildTarget || schema.uiFramework.endsWith('-vite'), viteConfigFilePath);
48
48
  if (schema.uiFramework !== '@storybook/angular') {
49
49
  (0, util_functions_1.createStorybookTsconfigFile)(tree, root, schema.uiFramework, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), mainDir);
50
50
  }
@@ -54,14 +54,15 @@ function configurationGenerator(tree, rawSchema) {
54
54
  (0, util_functions_1.addBuildStorybookToCacheableOperations)(tree);
55
55
  (0, util_functions_1.addStorybookToNamedInputs)(tree);
56
56
  if (schema.uiFramework === '@storybook/angular') {
57
- (0, util_functions_1.addAngularStorybookTask)(tree, schema.name, schema.configureTestRunner);
57
+ (0, util_functions_1.addAngularStorybookTask)(tree, schema.name, schema.interactionTests);
58
58
  }
59
59
  else {
60
- (0, util_functions_1.addStorybookTask)(tree, schema.name, schema.uiFramework, schema.configureTestRunner);
60
+ (0, util_functions_1.addStorybookTask)(tree, schema.name, schema.uiFramework, schema.interactionTests);
61
61
  }
62
62
  if (schema.configureStaticServe) {
63
63
  (0, util_functions_1.addStaticTarget)(tree, schema);
64
64
  }
65
+ // TODO(katerina): remove Cypress for Nx 18
65
66
  if (schema.configureCypress) {
66
67
  const e2eProject = yield (0, util_functions_1.getE2EProjectName)(tree, schema.name);
67
68
  if (!e2eProject) {
@@ -87,8 +88,11 @@ function configurationGenerator(tree, rawSchema) {
87
88
  devDeps['@storybook/core-common'] = versions_1.storybookVersion;
88
89
  devDeps['ts-node'] = versions_1.tsNodeVersion;
89
90
  }
90
- if (schema.configureTestRunner === true) {
91
+ if (schema.interactionTests) {
91
92
  devDeps['@storybook/test-runner'] = versions_1.storybookTestRunnerVersion;
93
+ devDeps['@storybook/addon-interactions'] = versions_1.storybookVersion;
94
+ devDeps['@storybook/testing-library'] = versions_1.storybookTestingLibraryVersion;
95
+ devDeps['@storybook/jest'] = versions_1.storybookJestVersion;
92
96
  }
93
97
  if (schema.configureStaticServe) {
94
98
  devDeps['@nx/web'] = versions_1.nxVersion;
@@ -103,9 +107,10 @@ function configurationGenerator(tree, rawSchema) {
103
107
  exports.configurationGenerator = configurationGenerator;
104
108
  function normalizeSchema(schema) {
105
109
  const defaults = {
106
- configureCypress: true,
110
+ interactionTests: true,
107
111
  linter: linter_1.Linter.EsLint,
108
112
  js: false,
113
+ tsConfiguration: true,
109
114
  };
110
115
  return Object.assign(Object.assign({}, defaults), schema);
111
116
  }
@@ -1,8 +1,8 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { StorybookConfigureSchema } from '../schema';
3
3
  import { UiFramework7 } from '../../../utils/models';
4
- export declare function addStorybookTask(tree: Tree, projectName: string, uiFramework: string, configureTestRunner: boolean): void;
5
- export declare function addAngularStorybookTask(tree: Tree, projectName: string, configureTestRunner: boolean): void;
4
+ export declare function addStorybookTask(tree: Tree, projectName: string, uiFramework: string, interactionTests: boolean): void;
5
+ export declare function addAngularStorybookTask(tree: Tree, projectName: string, interactionTests: boolean): void;
6
6
  export declare function addStaticTarget(tree: Tree, opts: StorybookConfigureSchema): void;
7
7
  export declare function createStorybookTsconfigFile(tree: Tree, projectRoot: string, uiFramework: UiFramework7, isRootProject: boolean, mainDir: 'components' | 'src'): void;
8
8
  export declare function configureTsProjectConfig(tree: Tree, schema: StorybookConfigureSchema): void;
@@ -18,7 +18,7 @@ export declare function configureTsSolutionConfig(tree: Tree, schema: StorybookC
18
18
  export declare function updateLintConfig(tree: Tree, schema: StorybookConfigureSchema): void;
19
19
  export declare function normalizeSchema(schema: StorybookConfigureSchema): StorybookConfigureSchema;
20
20
  export declare function addStorybookToNamedInputs(tree: Tree): void;
21
- export declare function createProjectStorybookDir(tree: Tree, projectName: string, uiFramework: UiFramework7, js: boolean, tsConfiguration: boolean, root: string, projectType: string, projectIsRootProjectInStandaloneWorkspace: boolean, mainDir?: string, isNextJs?: boolean, usesSwc?: boolean, usesVite?: boolean, viteConfigFilePath?: string): void;
21
+ export declare function createProjectStorybookDir(tree: Tree, projectName: string, uiFramework: UiFramework7, js: boolean, tsConfiguration: boolean, root: string, projectType: string, projectIsRootProjectInStandaloneWorkspace: boolean, interactionTests: boolean, mainDir?: string, isNextJs?: boolean, usesSwc?: boolean, usesVite?: boolean, viteConfigFilePath?: string): void;
22
22
  export declare function getTsConfigPath(tree: Tree, projectName: string, path?: string): string;
23
23
  export declare function addBuildStorybookToCacheableOperations(tree: Tree): void;
24
24
  export declare function projectIsRootProjectInStandaloneWorkspace(projectRoot: string): boolean;
@@ -9,7 +9,7 @@ const path_1 = require("path");
9
9
  const utilities_1 = require("../../../utils/utilities");
10
10
  const versions_1 = require("../../../utils/versions");
11
11
  const DEFAULT_PORT = 4400;
12
- function addStorybookTask(tree, projectName, uiFramework, configureTestRunner) {
12
+ function addStorybookTask(tree, projectName, uiFramework, interactionTests) {
13
13
  if (uiFramework === '@storybook/react-native') {
14
14
  return;
15
15
  }
@@ -39,7 +39,7 @@ function addStorybookTask(tree, projectName, uiFramework, configureTestRunner) {
39
39
  },
40
40
  },
41
41
  };
42
- if (configureTestRunner === true) {
42
+ if (interactionTests === true) {
43
43
  projectConfig.targets['test-storybook'] = {
44
44
  executor: 'nx:run-commands',
45
45
  options: {
@@ -50,7 +50,7 @@ function addStorybookTask(tree, projectName, uiFramework, configureTestRunner) {
50
50
  (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
51
51
  }
52
52
  exports.addStorybookTask = addStorybookTask;
53
- function addAngularStorybookTask(tree, projectName, configureTestRunner) {
53
+ function addAngularStorybookTask(tree, projectName, interactionTests) {
54
54
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
55
55
  const { ngBuildTarget } = (0, utilities_1.findStorybookAndBuildTargetsAndCompiler)(projectConfig.targets);
56
56
  projectConfig.targets['storybook'] = {
@@ -82,7 +82,7 @@ function addAngularStorybookTask(tree, projectName, configureTestRunner) {
82
82
  },
83
83
  },
84
84
  };
85
- if (configureTestRunner === true) {
85
+ if (interactionTests === true) {
86
86
  projectConfig.targets['test-storybook'] = {
87
87
  executor: 'nx:run-commands',
88
88
  options: {
@@ -331,7 +331,7 @@ function addStorybookToNamedInputs(tree) {
331
331
  }
332
332
  }
333
333
  exports.addStorybookToNamedInputs = addStorybookToNamedInputs;
334
- function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath) {
334
+ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath) {
335
335
  const projectDirectory = projectType === 'application'
336
336
  ? isNextJs
337
337
  ? 'components'
@@ -352,6 +352,7 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
352
352
  offsetFromRoot: (0, devkit_1.offsetFromRoot)(root),
353
353
  projectDirectory,
354
354
  projectType,
355
+ interactionTests,
355
356
  mainDir,
356
357
  isNextJs: isNextJs && projectType === 'application',
357
358
  usesSwc,
@@ -450,7 +451,7 @@ function getViteConfigFilePath(tree, projectRoot, configFile) {
450
451
  }
451
452
  exports.getViteConfigFilePath = getViteConfigFilePath;
452
453
  function renameAndMoveOldTsConfig(projectRoot, pathToStorybookConfigFile, tree) {
453
- if (pathToStorybookConfigFile) {
454
+ if (pathToStorybookConfigFile && tree.exists(pathToStorybookConfigFile)) {
454
455
  (0, devkit_1.updateJson)(tree, pathToStorybookConfigFile, (json) => {
455
456
  var _a, _b, _c, _d;
456
457
  if ((_a = json.extends) === null || _a === void 0 ? void 0 : _a.startsWith('../')) {
@@ -484,15 +485,26 @@ function renameAndMoveOldTsConfig(projectRoot, pathToStorybookConfigFile, tree)
484
485
  tree.rename(pathToStorybookConfigFile, (0, devkit_1.joinPathFragments)(projectRoot, `tsconfig.storybook.json`));
485
486
  }
486
487
  const projectTsConfig = (0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.json');
487
- (0, devkit_1.updateJson)(tree, projectTsConfig, (json) => {
488
- var _a;
489
- for (let i = 0; i < ((_a = json.references) === null || _a === void 0 ? void 0 : _a.length); i++) {
490
- if (json.references[i].path === './.storybook/tsconfig.json') {
491
- json.references[i].path = './tsconfig.storybook.json';
492
- break;
488
+ if (tree.exists(projectTsConfig)) {
489
+ (0, devkit_1.updateJson)(tree, projectTsConfig, (json) => {
490
+ var _a;
491
+ for (let i = 0; i < ((_a = json.references) === null || _a === void 0 ? void 0 : _a.length); i++) {
492
+ if (json.references[i].path === './.storybook/tsconfig.json') {
493
+ json.references[i].path = './tsconfig.storybook.json';
494
+ break;
495
+ }
493
496
  }
494
- }
495
- return json;
496
- });
497
+ return json;
498
+ });
499
+ }
500
+ const projectEsLintFile = (0, devkit_1.joinPathFragments)(projectRoot, '.eslintrc.json');
501
+ if (tree.exists(projectEsLintFile)) {
502
+ (0, devkit_1.updateJson)(tree, projectEsLintFile, (json) => {
503
+ const jsonString = JSON.stringify(json);
504
+ const newJsonString = jsonString.replace(/\.storybook\/tsconfig\.json/g, 'tsconfig.storybook.json');
505
+ json = JSON.parse(newJsonString);
506
+ return json;
507
+ });
508
+ }
497
509
  }
498
510
  exports.renameAndMoveOldTsConfig = renameAndMoveOldTsConfig;
@@ -4,7 +4,7 @@ const config = {
4
4
  '../**/*.stories.@(js|jsx|ts|tsx|mdx)' <% } else { %>
5
5
  '../<%= projectDirectory %>/**/*.stories.@(js|jsx|ts|tsx|mdx)'
6
6
  <% } %>],
7
- addons: ['@storybook/addon-essentials' <% 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' <% } %>],
7
+ 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' <% } %>],
8
8
  framework: {
9
9
  name: '<%= uiFramework %>',
10
10
  options: {
@@ -6,7 +6,7 @@ const config: StorybookConfig = {
6
6
  '../**/*.stories.@(js|jsx|ts|tsx|mdx)' <% } else { %>
7
7
  '../<%= projectDirectory %>/**/*.stories.@(js|jsx|ts|tsx|mdx)'
8
8
  <% } %>],
9
- addons: ['@storybook/addon-essentials' <% 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' <% } %>],
9
+ 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' <% } %>],
10
10
  framework: {
11
11
  name: '<%= uiFramework %>',
12
12
  options: {
@@ -7,10 +7,10 @@ export interface StorybookConfigureSchema {
7
7
  configureCypress?: boolean;
8
8
  linter?: Linter;
9
9
  js?: boolean;
10
+ interactionTests?: boolean;
10
11
  tsConfiguration?: boolean;
11
12
  cypressDirectory?: string;
12
13
  standaloneConfig?: boolean;
13
- configureTestRunner?: boolean;
14
14
  configureStaticServe?: boolean;
15
15
  skipFormat?: boolean;
16
16
  }
@@ -18,15 +18,22 @@
18
18
  "x-dropdown": "projects",
19
19
  "x-priority": "important"
20
20
  },
21
+ "interactionTests": {
22
+ "type": "boolean",
23
+ "description": "Set up Storybook interaction tests.",
24
+ "x-prompt": "Do you want to set up Storybook interaction tests?",
25
+ "alias": ["configureTestRunner"],
26
+ "default": true
27
+ },
21
28
  "configureCypress": {
22
29
  "type": "boolean",
23
30
  "description": "Run the cypress-configure generator.",
24
- "x-prompt": "Configure a cypress e2e app to run against the storybook instance?",
25
- "x-priority": "important"
31
+ "x-deprecated": "Please use Storybook interaction tests instead."
26
32
  },
27
33
  "cypressDirectory": {
28
34
  "type": "string",
29
- "description": "A directory where the Cypress project will be placed. Added at root by default."
35
+ "description": "A directory where the Cypress project will be placed. Added at root by default.",
36
+ "x-deprecated": "Please use Storybook interaction tests instead."
30
37
  },
31
38
  "linter": {
32
39
  "description": "The tool to use for running lint checks.",
@@ -56,10 +63,6 @@
56
63
  "description": "Add a static-storybook to serve the static storybook built files.",
57
64
  "default": false
58
65
  },
59
- "configureTestRunner": {
60
- "type": "boolean",
61
- "description": "Add a Storybook Test-Runner target."
62
- },
63
66
  "bundler": {
64
67
  "description": "The Storybook builder to use.",
65
68
  "type": "string",
@@ -110,7 +110,7 @@ function migrateProjectLevelStorybookInstance(tree, projectName, uiFramework, co
110
110
  const { projectType, targets, root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
111
111
  const { nextBuildTarget, compiler } = (0, utilities_1.findStorybookAndBuildTargetsAndCompiler)(targets);
112
112
  const mainDir = !!nextBuildTarget && projectType === 'application' ? 'components' : 'src';
113
- (0, util_functions_1.createProjectStorybookDir)(tree, projectName, uiFramework, false, false, root, projectType, false, mainDir, !!nextBuildTarget, compiler === 'swc');
113
+ (0, util_functions_1.createProjectStorybookDir)(tree, projectName, uiFramework, false, false, root, projectType, false, false, mainDir, !!nextBuildTarget, compiler === 'swc');
114
114
  }
115
115
  function moveDirectory(tree, from, to) {
116
116
  (0, devkit_1.visitNotIgnoredFiles)(tree, from, (file) => {
@@ -1,7 +1,9 @@
1
1
  export declare const nxVersion: any;
2
2
  export declare const storybookReactNativeVersion = "^6.5.3";
3
3
  export declare const reactNativeStorybookLoader = "^2.0.5";
4
- export declare const storybookTestRunnerVersion = "^0.7.2";
4
+ export declare const storybookTestRunnerVersion = "^0.11.0";
5
+ export declare const storybookTestingLibraryVersion = "~0.2.0";
6
+ export declare const storybookJestVersion = "~0.1.0";
5
7
  export declare const litVersion = "^2.6.1";
6
8
  export declare const tsNodeVersion = "10.9.1";
7
9
  export declare const storybookVersion = "^7.0.24";
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.viteVersion = exports.reactVersion = exports.storybookVersion = exports.tsNodeVersion = exports.litVersion = exports.storybookTestRunnerVersion = exports.reactNativeStorybookLoader = exports.storybookReactNativeVersion = exports.nxVersion = void 0;
3
+ exports.viteVersion = exports.reactVersion = exports.storybookVersion = exports.tsNodeVersion = exports.litVersion = exports.storybookJestVersion = exports.storybookTestingLibraryVersion = exports.storybookTestRunnerVersion = exports.reactNativeStorybookLoader = exports.storybookReactNativeVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  exports.storybookReactNativeVersion = '^6.5.3';
6
6
  exports.reactNativeStorybookLoader = '^2.0.5';
7
- exports.storybookTestRunnerVersion = '^0.7.2';
7
+ exports.storybookTestRunnerVersion = '^0.11.0';
8
+ exports.storybookTestingLibraryVersion = '~0.2.0';
9
+ exports.storybookJestVersion = '~0.1.0';
8
10
  exports.litVersion = '^2.6.1';
9
11
  exports.tsNodeVersion = '10.9.1';
10
12
  exports.storybookVersion = '^7.0.24';