@nx/storybook 18.0.0-beta.1 → 18.0.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/generators.json +2 -2
- package/package.json +6 -6
- package/src/generators/configuration/configuration.d.ts +2 -1
- package/src/generators/configuration/configuration.js +15 -5
- package/src/generators/configuration/lib/ensure-dependencies.js +9 -25
- package/src/generators/configuration/lib/util-functions.d.ts +2 -1
- package/src/generators/configuration/lib/util-functions.js +11 -10
- package/src/generators/configuration/project-files/.storybook/main.js__tmpl__ +17 -2
- package/src/generators/configuration/project-files-ts/.storybook/main.ts__tmpl__ +17 -2
- package/src/generators/configuration/schema.d.ts +1 -0
- package/src/generators/configuration/schema.json +0 -7
- package/src/generators/init/init.d.ts +1 -0
- package/src/generators/init/init.js +10 -5
- package/src/generators/init/schema.d.ts +1 -0
- package/src/plugins/plugin.js +7 -7
- package/src/utils/models.d.ts +1 -1
- package/src/utils/utilities.js +0 -6
- package/src/utils/versions.d.ts +0 -2
- package/src/utils/versions.js +1 -3
package/generators.json
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
"version": "0.1",
|
|
4
4
|
"generators": {
|
|
5
5
|
"init": {
|
|
6
|
-
"factory": "./src/generators/init/init",
|
|
6
|
+
"factory": "./src/generators/init/init#initGeneratorInternal",
|
|
7
7
|
"schema": "./src/generators/init/schema.json",
|
|
8
8
|
"description": "Add Storybook configuration to the workspace.",
|
|
9
9
|
"aliases": ["ng-add"],
|
|
10
10
|
"hidden": true
|
|
11
11
|
},
|
|
12
12
|
"configuration": {
|
|
13
|
-
"factory": "./src/generators/configuration/configuration",
|
|
13
|
+
"factory": "./src/generators/configuration/configuration#configurationGeneratorInternal",
|
|
14
14
|
"schema": "./src/generators/configuration/schema.json",
|
|
15
15
|
"description": "Add Storybook configuration to a UI library or an application.",
|
|
16
16
|
"hidden": false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "18.0.0-beta.
|
|
3
|
+
"version": "18.0.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,14 +30,14 @@
|
|
|
30
30
|
"migrations": "./migrations.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nx/devkit": "18.0.0-beta.
|
|
33
|
+
"@nx/devkit": "18.0.0-beta.2",
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
35
|
"semver": "^7.5.3",
|
|
36
36
|
"tslib": "^2.3.0",
|
|
37
|
-
"@nx/cypress": "18.0.0-beta.
|
|
38
|
-
"@nx/js": "18.0.0-beta.
|
|
39
|
-
"@nx/eslint": "18.0.0-beta.
|
|
40
|
-
"@nrwl/storybook": "18.0.0-beta.
|
|
37
|
+
"@nx/cypress": "18.0.0-beta.2",
|
|
38
|
+
"@nx/js": "18.0.0-beta.2",
|
|
39
|
+
"@nx/eslint": "18.0.0-beta.2",
|
|
40
|
+
"@nrwl/storybook": "18.0.0-beta.2"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { StorybookConfigureSchema } from './schema';
|
|
3
|
-
export declare function configurationGenerator(tree: Tree,
|
|
3
|
+
export declare function configurationGenerator(tree: Tree, schema: StorybookConfigureSchema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function configurationGeneratorInternal(tree: Tree, rawSchema: StorybookConfigureSchema): Promise<GeneratorCallback>;
|
|
4
5
|
export default configurationGenerator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configurationGenerator = void 0;
|
|
3
|
+
exports.configurationGeneratorInternal = exports.configurationGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const js_1 = require("@nx/js");
|
|
6
6
|
const cypress_project_1 = require("../cypress-project/cypress-project");
|
|
@@ -12,7 +12,11 @@ const versions_1 = require("../../utils/versions");
|
|
|
12
12
|
const interaction_testing_utils_1 = require("./lib/interaction-testing.utils");
|
|
13
13
|
const ensure_dependencies_1 = require("./lib/ensure-dependencies");
|
|
14
14
|
const edit_root_tsconfig_1 = require("./lib/edit-root-tsconfig");
|
|
15
|
-
|
|
15
|
+
function configurationGenerator(tree, schema) {
|
|
16
|
+
return configurationGeneratorInternal(tree, { addPlugin: false, ...schema });
|
|
17
|
+
}
|
|
18
|
+
exports.configurationGenerator = configurationGenerator;
|
|
19
|
+
async function configurationGeneratorInternal(tree, rawSchema) {
|
|
16
20
|
if ((0, utilities_1.storybookMajorVersion)() === 6) {
|
|
17
21
|
throw new Error((0, utilities_1.pleaseUpgrade)());
|
|
18
22
|
}
|
|
@@ -24,6 +28,7 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
24
28
|
const viteConfigFilePath = viteConfig?.fullConfigPath;
|
|
25
29
|
const viteConfigFileName = viteConfig?.viteConfigFileName;
|
|
26
30
|
const nextConfigFilePath = (0, util_functions_1.findNextConfig)(tree, root);
|
|
31
|
+
const metroConfigFilePath = (0, util_functions_1.findMetroConfig)(tree, root);
|
|
27
32
|
if (viteConfigFilePath) {
|
|
28
33
|
if (schema.uiFramework === '@storybook/react-webpack5') {
|
|
29
34
|
devkit_1.logger.info(`Your project ${schema.project} uses Vite as a bundler.
|
|
@@ -44,7 +49,10 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
44
49
|
skipFormat: true,
|
|
45
50
|
});
|
|
46
51
|
tasks.push(jsInitTask);
|
|
47
|
-
const initTask = await (0, init_1.initGenerator)(tree, {
|
|
52
|
+
const initTask = await (0, init_1.initGenerator)(tree, {
|
|
53
|
+
skipFormat: true,
|
|
54
|
+
addPlugin: schema.addPlugin,
|
|
55
|
+
});
|
|
48
56
|
tasks.push(initTask);
|
|
49
57
|
tasks.push((0, ensure_dependencies_1.ensureDependencies)(tree, { uiFramework: schema.uiFramework }));
|
|
50
58
|
(0, edit_root_tsconfig_1.editRootTsConfig)(tree);
|
|
@@ -56,7 +64,8 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
56
64
|
? 'components'
|
|
57
65
|
: 'src';
|
|
58
66
|
const usesVite = !!viteConfigFilePath || schema.uiFramework?.endsWith('-vite');
|
|
59
|
-
|
|
67
|
+
const useReactNative = !!metroConfigFilePath;
|
|
68
|
+
(0, util_functions_1.createProjectStorybookDir)(tree, schema.project, schema.uiFramework, schema.js, schema.tsConfiguration, root, projectType, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), schema.interactionTests, mainDir, !!nextConfigFilePath, compiler === 'swc', usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName, useReactNative);
|
|
60
69
|
if (schema.uiFramework !== '@storybook/angular') {
|
|
61
70
|
(0, util_functions_1.createStorybookTsconfigFile)(tree, root, schema.uiFramework, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), mainDir);
|
|
62
71
|
}
|
|
@@ -137,13 +146,14 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
137
146
|
}
|
|
138
147
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
139
148
|
}
|
|
140
|
-
exports.
|
|
149
|
+
exports.configurationGeneratorInternal = configurationGeneratorInternal;
|
|
141
150
|
function normalizeSchema(schema) {
|
|
142
151
|
const defaults = {
|
|
143
152
|
interactionTests: true,
|
|
144
153
|
linter: eslint_1.Linter.EsLint,
|
|
145
154
|
js: false,
|
|
146
155
|
tsConfiguration: true,
|
|
156
|
+
addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
|
|
147
157
|
};
|
|
148
158
|
return {
|
|
149
159
|
...defaults,
|
|
@@ -31,21 +31,15 @@ function ensureDependencies(tree, options) {
|
|
|
31
31
|
dependencies['react-dom'] = versions_1.reactVersion;
|
|
32
32
|
}
|
|
33
33
|
if (options.uiFramework) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const matchResult = options.uiFramework?.match(/^@storybook\/(\w+)/);
|
|
44
|
-
const uiFrameworkWithoutBuilder = matchResult ? matchResult[0] : null;
|
|
45
|
-
if (uiFrameworkWithoutBuilder) {
|
|
46
|
-
devDependencies[uiFrameworkWithoutBuilder] =
|
|
47
|
-
storybook7VersionToInstall;
|
|
48
|
-
}
|
|
34
|
+
devDependencies[options.uiFramework] = storybook7VersionToInstall;
|
|
35
|
+
const isPnpm = (0, devkit_1.detectPackageManager)(tree.root) === 'pnpm';
|
|
36
|
+
if (isPnpm) {
|
|
37
|
+
// If it's pnpm, it needs the framework without the builder
|
|
38
|
+
// as a dependency too (eg. @storybook/react)
|
|
39
|
+
const matchResult = options.uiFramework?.match(/^@storybook\/(\w+)/);
|
|
40
|
+
const uiFrameworkWithoutBuilder = matchResult ? matchResult[0] : null;
|
|
41
|
+
if (uiFrameworkWithoutBuilder) {
|
|
42
|
+
devDependencies[uiFrameworkWithoutBuilder] = storybook7VersionToInstall;
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
45
|
if (options.uiFramework === '@storybook/vue3-vite') {
|
|
@@ -64,16 +58,6 @@ function ensureDependencies(tree, options) {
|
|
|
64
58
|
options.uiFramework === '@storybook/web-components-webpack5') {
|
|
65
59
|
devDependencies['lit'] = versions_1.litVersion;
|
|
66
60
|
}
|
|
67
|
-
if (options.uiFramework === '@storybook/react-native') {
|
|
68
|
-
devDependencies['@storybook/addon-ondevice-actions'] =
|
|
69
|
-
versions_1.storybookReactNativeVersion;
|
|
70
|
-
devDependencies['@storybook/addon-ondevice-backgrounds'] =
|
|
71
|
-
versions_1.storybookReactNativeVersion;
|
|
72
|
-
devDependencies['@storybook/addon-ondevice-controls'] =
|
|
73
|
-
versions_1.storybookReactNativeVersion;
|
|
74
|
-
devDependencies['@storybook/addon-ondevice-notes'] =
|
|
75
|
-
versions_1.storybookReactNativeVersion;
|
|
76
|
-
}
|
|
77
61
|
if (options.uiFramework.endsWith('-vite')) {
|
|
78
62
|
if (!packageJson.dependencies['vite'] &&
|
|
79
63
|
!packageJson.devDependencies['vite']) {
|
|
@@ -19,7 +19,7 @@ export declare function updateLintConfig(tree: Tree, schema: StorybookConfigureS
|
|
|
19
19
|
export declare function normalizeSchema(schema: StorybookConfigureSchema): StorybookConfigureSchema;
|
|
20
20
|
export declare function addStorybookToNamedInputs(tree: Tree): void;
|
|
21
21
|
export declare function addStorybookToTargetDefaults(tree: Tree): void;
|
|
22
|
-
export declare function createProjectStorybookDir(tree: Tree, projectName: string, uiFramework: UiFramework, js: boolean, tsConfiguration: boolean, root: string, projectType: string, projectIsRootProjectInStandaloneWorkspace: boolean, interactionTests: boolean, mainDir?: string, isNextJs?: boolean, usesSwc?: boolean, usesVite?: boolean, viteConfigFilePath?: string, hasPlugin?: boolean, viteConfigFileName?: string): void;
|
|
22
|
+
export declare function createProjectStorybookDir(tree: Tree, projectName: string, uiFramework: UiFramework, js: boolean, tsConfiguration: boolean, root: string, projectType: string, projectIsRootProjectInStandaloneWorkspace: boolean, interactionTests: boolean, mainDir?: string, isNextJs?: boolean, usesSwc?: boolean, usesVite?: boolean, viteConfigFilePath?: string, hasPlugin?: boolean, viteConfigFileName?: string, useReactNative?: boolean): void;
|
|
23
23
|
export declare function getTsConfigPath(tree: Tree, projectName: string, path?: string): string;
|
|
24
24
|
export declare function addBuildStorybookToCacheableOperations(tree: Tree): void;
|
|
25
25
|
export declare function projectIsRootProjectInStandaloneWorkspace(projectRoot: string): boolean;
|
|
@@ -31,4 +31,5 @@ export declare function findViteConfig(tree: Tree, projectRoot: string): {
|
|
|
31
31
|
viteConfigFileName: string | undefined;
|
|
32
32
|
};
|
|
33
33
|
export declare function findNextConfig(tree: Tree, projectRoot: string): string | undefined;
|
|
34
|
+
export declare function findMetroConfig(tree: Tree, projectRoot: string): string | undefined;
|
|
34
35
|
export declare function renameAndMoveOldTsConfig(projectRoot: string, pathToStorybookConfigFile: string, tree: Tree): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renameAndMoveOldTsConfig = 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.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;
|
|
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");
|
|
@@ -11,9 +11,6 @@ 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
13
|
function addStorybookTarget(tree, projectName, uiFramework, interactionTests) {
|
|
14
|
-
if (uiFramework === '@storybook/react-native') {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
14
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
18
15
|
projectConfig.targets['storybook'] = {
|
|
19
16
|
executor: '@nx/storybook:storybook',
|
|
@@ -152,9 +149,6 @@ function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProje
|
|
|
152
149
|
'.storybook/*.js',
|
|
153
150
|
'.storybook/*.ts',
|
|
154
151
|
];
|
|
155
|
-
if (uiFramework === '@storybook/react-native') {
|
|
156
|
-
include.push('*.ts', '*.tsx');
|
|
157
|
-
}
|
|
158
152
|
const storybookTsConfig = {
|
|
159
153
|
extends: './tsconfig.json',
|
|
160
154
|
compilerOptions: {
|
|
@@ -208,8 +202,7 @@ function configureTsProjectConfig(tree, schema) {
|
|
|
208
202
|
...(tsConfigContent.exclude || []),
|
|
209
203
|
'**/*.stories.ts',
|
|
210
204
|
'**/*.stories.js',
|
|
211
|
-
...(schema.uiFramework
|
|
212
|
-
schema.uiFramework?.startsWith('@storybook/react')
|
|
205
|
+
...(schema.uiFramework?.startsWith('@storybook/react')
|
|
213
206
|
? ['**/*.stories.jsx', '**/*.stories.tsx']
|
|
214
207
|
: []),
|
|
215
208
|
];
|
|
@@ -367,7 +360,7 @@ function addStorybookToTargetDefaults(tree) {
|
|
|
367
360
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
368
361
|
}
|
|
369
362
|
exports.addStorybookToTargetDefaults = addStorybookToTargetDefaults;
|
|
370
|
-
function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName) {
|
|
363
|
+
function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName, useReactNative) {
|
|
371
364
|
let projectDirectory = projectType === 'application'
|
|
372
365
|
? isNextJs
|
|
373
366
|
? 'components'
|
|
@@ -400,6 +393,7 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
|
|
|
400
393
|
viteConfigFilePath,
|
|
401
394
|
hasPlugin,
|
|
402
395
|
viteConfigFileName,
|
|
396
|
+
useReactNative,
|
|
403
397
|
});
|
|
404
398
|
if (js) {
|
|
405
399
|
(0, devkit_1.toJS)(tree);
|
|
@@ -511,6 +505,13 @@ function findNextConfig(tree, projectRoot) {
|
|
|
511
505
|
}
|
|
512
506
|
}
|
|
513
507
|
exports.findNextConfig = findNextConfig;
|
|
508
|
+
function findMetroConfig(tree, projectRoot) {
|
|
509
|
+
const nextConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, `metro.config.js`);
|
|
510
|
+
if (tree.exists(nextConfigPath)) {
|
|
511
|
+
return nextConfigPath;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
exports.findMetroConfig = findMetroConfig;
|
|
514
515
|
function renameAndMoveOldTsConfig(projectRoot, pathToStorybookConfigFile, tree) {
|
|
515
516
|
if (pathToStorybookConfigFile && tree.exists(pathToStorybookConfigFile)) {
|
|
516
517
|
(0, devkit_1.updateJson)(tree, pathToStorybookConfigFile, (json) => {
|
|
@@ -9,7 +9,7 @@ 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' <% } %>],
|
|
13
13
|
framework: {
|
|
14
14
|
name: '<%= uiFramework %>',
|
|
15
15
|
options: {
|
|
@@ -25,7 +25,22 @@ const config = {
|
|
|
25
25
|
<% } %>
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
|
-
<% if (
|
|
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) { %>
|
|
29
44
|
viteFinal: async (config) =>
|
|
30
45
|
mergeConfig(config, {
|
|
31
46
|
plugins: [nxViteTsPaths()],
|
|
@@ -10,7 +10,7 @@ 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' <% } %>],
|
|
14
14
|
framework: {
|
|
15
15
|
name: '<%= uiFramework %>',
|
|
16
16
|
options: {
|
|
@@ -25,7 +25,22 @@ const config: StorybookConfig = {
|
|
|
25
25
|
<% } %>
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
|
-
<% if (
|
|
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) { %>
|
|
29
44
|
viteFinal: async (config) =>
|
|
30
45
|
mergeConfig(config, {
|
|
31
46
|
plugins: [nxViteTsPaths()],
|
|
@@ -63,13 +63,6 @@
|
|
|
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
|
-
},
|
|
73
66
|
"uiFramework": {
|
|
74
67
|
"type": "string",
|
|
75
68
|
"description": "Storybook UI Framework to use.",
|
|
@@ -1,4 +1,5 @@
|
|
|
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>;
|
|
4
5
|
export default initGenerator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initGenerator = void 0;
|
|
3
|
+
exports.initGeneratorInternal = exports.initGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
|
|
6
6
|
const semver_1 = require("semver");
|
|
@@ -13,7 +13,7 @@ function checkDependenciesInstalled(host, schema) {
|
|
|
13
13
|
'@nx/storybook': versions_1.nxVersion,
|
|
14
14
|
'@nx/web': versions_1.nxVersion,
|
|
15
15
|
};
|
|
16
|
-
if (
|
|
16
|
+
if (schema.addPlugin) {
|
|
17
17
|
let storybook7VersionToInstall = versions_1.storybookVersion;
|
|
18
18
|
if ((0, utilities_1.storybookMajorVersion)() >= 7 &&
|
|
19
19
|
(0, utilities_1.getInstalledStorybookVersion)() &&
|
|
@@ -50,8 +50,13 @@ function moveToDevDependencies(tree) {
|
|
|
50
50
|
});
|
|
51
51
|
return updated ? () => (0, devkit_1.installPackagesTask)(tree) : () => { };
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
function initGenerator(tree, schema) {
|
|
54
|
+
return initGeneratorInternal(tree, { addPlugin: false, ...schema });
|
|
55
|
+
}
|
|
56
|
+
exports.initGenerator = initGenerator;
|
|
57
|
+
async function initGeneratorInternal(tree, schema) {
|
|
58
|
+
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
59
|
+
if (schema.addPlugin) {
|
|
55
60
|
(0, utilities_1.addPlugin)(tree);
|
|
56
61
|
(0, update_gitignore_1.updateGitignore)(tree);
|
|
57
62
|
}
|
|
@@ -71,5 +76,5 @@ async function initGenerator(tree, schema) {
|
|
|
71
76
|
}
|
|
72
77
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
73
78
|
}
|
|
74
|
-
exports.
|
|
79
|
+
exports.initGeneratorInternal = initGeneratorInternal;
|
|
75
80
|
exports.default = initGenerator;
|
package/src/plugins/plugin.js
CHANGED
|
@@ -86,7 +86,7 @@ function buildTarget(namedInputs, outputs, projectRoot, frameworkIsAngular, proj
|
|
|
86
86
|
configDir: `${(0, path_1.dirname)(configFilePath)}`,
|
|
87
87
|
browserTarget: `${projectName}:build-storybook`,
|
|
88
88
|
compodoc: false,
|
|
89
|
-
outputDir: (0, devkit_1.joinPathFragments)(projectRoot, 'static
|
|
89
|
+
outputDir: (0, devkit_1.joinPathFragments)(projectRoot, 'storybook-static'),
|
|
90
90
|
},
|
|
91
91
|
cache: true,
|
|
92
92
|
outputs,
|
|
@@ -157,7 +157,7 @@ function serveStaticTarget(options, projectRoot) {
|
|
|
157
157
|
executor: '@nx/web:file-server',
|
|
158
158
|
options: {
|
|
159
159
|
buildTarget: `${options.buildStorybookTargetName}`,
|
|
160
|
-
staticFilePath: (0, devkit_1.joinPathFragments)(projectRoot, 'static
|
|
160
|
+
staticFilePath: (0, devkit_1.joinPathFragments)(projectRoot, 'storybook-static'),
|
|
161
161
|
},
|
|
162
162
|
};
|
|
163
163
|
return targetConfig;
|
|
@@ -192,8 +192,8 @@ function getStorybookConfig(configFilePath, context) {
|
|
|
192
192
|
}
|
|
193
193
|
return frameworkName;
|
|
194
194
|
}
|
|
195
|
-
function getOutputs(
|
|
196
|
-
const normalizedOutputPath = normalizeOutputPath(
|
|
195
|
+
function getOutputs(projectRoot) {
|
|
196
|
+
const normalizedOutputPath = normalizeOutputPath(projectRoot);
|
|
197
197
|
const outputs = [
|
|
198
198
|
normalizedOutputPath,
|
|
199
199
|
`{options.output-dir}`,
|
|
@@ -202,12 +202,12 @@ function getOutputs(_projectRoot) {
|
|
|
202
202
|
];
|
|
203
203
|
return outputs;
|
|
204
204
|
}
|
|
205
|
-
function normalizeOutputPath(
|
|
205
|
+
function normalizeOutputPath(projectRoot) {
|
|
206
206
|
if (projectRoot === '.') {
|
|
207
|
-
return `{projectRoot}/static
|
|
207
|
+
return `{projectRoot}/storybook-static`;
|
|
208
208
|
}
|
|
209
209
|
else {
|
|
210
|
-
return `{workspaceRoot}/{projectRoot}/static
|
|
210
|
+
return `{workspaceRoot}/{projectRoot}/storybook-static`;
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
function normalizeOptions(options) {
|
package/src/utils/models.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type UiFramework = '@storybook/angular' | '@storybook/html-webpack5' | '@storybook/nextjs' | '@storybook/preact-webpack5' | '@storybook/react-webpack5' | '@storybook/react-vite' | '@storybook/server-webpack5' | '@storybook/svelte-webpack5' | '@storybook/svelte-vite' | '@storybook/sveltekit' | '@storybook/vue-webpack5' | '@storybook/vue-vite' | '@storybook/vue3-webpack5' | '@storybook/vue3-vite' | '@storybook/web-components-webpack5' | '@storybook/web-components-vite'
|
|
1
|
+
export type UiFramework = '@storybook/angular' | '@storybook/html-webpack5' | '@storybook/nextjs' | '@storybook/preact-webpack5' | '@storybook/react-webpack5' | '@storybook/react-vite' | '@storybook/server-webpack5' | '@storybook/svelte-webpack5' | '@storybook/svelte-vite' | '@storybook/sveltekit' | '@storybook/vue-webpack5' | '@storybook/vue-vite' | '@storybook/vue3-webpack5' | '@storybook/vue3-vite' | '@storybook/web-components-webpack5' | '@storybook/web-components-vite';
|
package/src/utils/utilities.js
CHANGED
|
@@ -93,9 +93,6 @@ function findStorybookAndBuildTargetsAndCompiler(targets) {
|
|
|
93
93
|
'@nx/angular:webpack-browser',
|
|
94
94
|
'@nx/esbuild:esbuild',
|
|
95
95
|
'@nx/next:build',
|
|
96
|
-
'@nx/react-native:bundle',
|
|
97
|
-
'@nx/react-native:build-android',
|
|
98
|
-
'@nx/react-native:bundle',
|
|
99
96
|
'@nrwl/js:babel',
|
|
100
97
|
'@nrwl/js:swc',
|
|
101
98
|
'@nrwl/js:tsc',
|
|
@@ -108,9 +105,6 @@ function findStorybookAndBuildTargetsAndCompiler(targets) {
|
|
|
108
105
|
'@nrwl/angular:webpack-browser',
|
|
109
106
|
'@nrwl/esbuild:esbuild',
|
|
110
107
|
'@nrwl/next:build',
|
|
111
|
-
'@nrwl/react-native:bundle',
|
|
112
|
-
'@nrwl/react-native:build-android',
|
|
113
|
-
'@nrwl/react-native:bundle',
|
|
114
108
|
'@nxext/vite:build',
|
|
115
109
|
'@angular-devkit/build-angular:browser',
|
|
116
110
|
];
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export declare const nxVersion: any;
|
|
2
|
-
export declare const storybookReactNativeVersion = "^6.5.3";
|
|
3
|
-
export declare const reactNativeStorybookLoader = "^2.0.5";
|
|
4
2
|
export declare const storybookTestRunnerVersion = "^0.13.0";
|
|
5
3
|
export declare const storybookTestingLibraryVersion = "^0.2.2";
|
|
6
4
|
export declare const storybookJestVersion = "^0.2.3";
|
package/src/utils/versions.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.coreJsVersion = exports.viteVersion = exports.reactVersion = exports.storybookVersion = exports.tsLibVersion = exports.tsNodeVersion = exports.litVersion = exports.storybookJestVersion = exports.storybookTestingLibraryVersion = exports.storybookTestRunnerVersion = exports.
|
|
3
|
+
exports.coreJsVersion = exports.viteVersion = exports.reactVersion = exports.storybookVersion = exports.tsLibVersion = exports.tsNodeVersion = exports.litVersion = exports.storybookJestVersion = exports.storybookTestingLibraryVersion = exports.storybookTestRunnerVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
|
-
exports.storybookReactNativeVersion = '^6.5.3';
|
|
6
|
-
exports.reactNativeStorybookLoader = '^2.0.5';
|
|
7
5
|
exports.storybookTestRunnerVersion = '^0.13.0';
|
|
8
6
|
exports.storybookTestingLibraryVersion = '^0.2.2';
|
|
9
7
|
exports.storybookJestVersion = '^0.2.3';
|