@nx/storybook 16.4.0 → 16.5.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.
- package/migrations.json +114 -0
- package/package.json +8 -8
- package/src/generators/configuration/configuration.js +5 -1
- package/src/generators/configuration/lib/util-functions.d.ts +3 -1
- package/src/generators/configuration/lib/util-functions.js +159 -16
- package/src/generators/configuration/project-files/.storybook/tsconfig.json__tmpl__ +4 -15
- package/src/generators/configuration/project-files-ts/.storybook/tsconfig.json__tmpl__ +5 -17
- package/src/migrations/update-14-0-0/migrate-defaults-5-to-6/migrate-defaults-5-to-6.js +2 -1
- package/src/migrations/update-16-5-0/move-storybook-tsconfig.d.ts +2 -0
- package/src/migrations/update-16-5-0/move-storybook-tsconfig.js +22 -0
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
package/migrations.json
CHANGED
|
@@ -59,9 +59,123 @@
|
|
|
59
59
|
"version": "16.1.0-beta.0",
|
|
60
60
|
"description": "Ignore @nx/react/plugins/storybook in Storybook eslint rules.",
|
|
61
61
|
"factory": "./src/migrations/update-16-1-0/eslint-ignore-react-plugin"
|
|
62
|
+
},
|
|
63
|
+
"update-16-5-0": {
|
|
64
|
+
"cli": "nx",
|
|
65
|
+
"version": "16.5.0-beta.0",
|
|
66
|
+
"description": "Move .storybook/tsconfig.json to tsconfig.storybook.json for non-Angular projects.",
|
|
67
|
+
"factory": "./src/migrations/update-16-5-0/move-storybook-tsconfig"
|
|
62
68
|
}
|
|
63
69
|
},
|
|
64
70
|
"packageJsonUpdates": {
|
|
71
|
+
"16.5.0": {
|
|
72
|
+
"version": "16.5.0-beta.0",
|
|
73
|
+
"requires": {
|
|
74
|
+
"@storybook/core-server": ">=7.0.0 <7.0.24"
|
|
75
|
+
},
|
|
76
|
+
"packages": {
|
|
77
|
+
"@storybook/core-server": {
|
|
78
|
+
"version": "^7.0.24",
|
|
79
|
+
"alwaysAddToPackageJson": false
|
|
80
|
+
},
|
|
81
|
+
"@storybook/angular": {
|
|
82
|
+
"version": "^7.0.24",
|
|
83
|
+
"alwaysAddToPackageJson": false
|
|
84
|
+
},
|
|
85
|
+
"@storybook/react": {
|
|
86
|
+
"version": "^7.0.24",
|
|
87
|
+
"alwaysAddToPackageJson": false
|
|
88
|
+
},
|
|
89
|
+
"@storybook/web-components-vite": {
|
|
90
|
+
"version": "^7.0.24",
|
|
91
|
+
"alwaysAddToPackageJson": false
|
|
92
|
+
},
|
|
93
|
+
"@storybook/web-components-webpack5": {
|
|
94
|
+
"version": "^7.0.24",
|
|
95
|
+
"alwaysAddToPackageJson": false
|
|
96
|
+
},
|
|
97
|
+
"@storybook/builder-vite": {
|
|
98
|
+
"version": "^7.0.24",
|
|
99
|
+
"alwaysAddToPackageJson": false
|
|
100
|
+
},
|
|
101
|
+
"@storybook/builder-webpack5": {
|
|
102
|
+
"version": "^7.0.24",
|
|
103
|
+
"alwaysAddToPackageJson": false
|
|
104
|
+
},
|
|
105
|
+
"@storybook/addon-a11y": {
|
|
106
|
+
"version": "^7.0.24",
|
|
107
|
+
"alwaysAddToPackageJson": false
|
|
108
|
+
},
|
|
109
|
+
"@storybook/addon-actions": {
|
|
110
|
+
"version": "^7.0.24",
|
|
111
|
+
"alwaysAddToPackageJson": false
|
|
112
|
+
},
|
|
113
|
+
"@storybook/addon-backgrounds": {
|
|
114
|
+
"version": "^7.0.24",
|
|
115
|
+
"alwaysAddToPackageJson": false
|
|
116
|
+
},
|
|
117
|
+
"@storybook/addon-controls": {
|
|
118
|
+
"version": "^7.0.24",
|
|
119
|
+
"alwaysAddToPackageJson": false
|
|
120
|
+
},
|
|
121
|
+
"@storybook/addon-docs": {
|
|
122
|
+
"version": "^7.0.24",
|
|
123
|
+
"alwaysAddToPackageJson": false
|
|
124
|
+
},
|
|
125
|
+
"@storybook/addon-essentials": {
|
|
126
|
+
"version": "^7.0.24",
|
|
127
|
+
"alwaysAddToPackageJson": false
|
|
128
|
+
},
|
|
129
|
+
"@storybook/addon-mdx-gfm": {
|
|
130
|
+
"version": "^7.0.24",
|
|
131
|
+
"alwaysAddToPackageJson": false
|
|
132
|
+
},
|
|
133
|
+
"@storybook/addon-highlight": {
|
|
134
|
+
"version": "^7.0.24",
|
|
135
|
+
"alwaysAddToPackageJson": false
|
|
136
|
+
},
|
|
137
|
+
"@storybook/addon-interactions": {
|
|
138
|
+
"version": "^7.0.24",
|
|
139
|
+
"alwaysAddToPackageJson": false
|
|
140
|
+
},
|
|
141
|
+
"@storybook/addon-jest": {
|
|
142
|
+
"version": "^7.0.24",
|
|
143
|
+
"alwaysAddToPackageJson": false
|
|
144
|
+
},
|
|
145
|
+
"@storybook/addon-links": {
|
|
146
|
+
"version": "^7.0.24",
|
|
147
|
+
"alwaysAddToPackageJson": false
|
|
148
|
+
},
|
|
149
|
+
"@storybook/addon-measure": {
|
|
150
|
+
"version": "^7.0.24",
|
|
151
|
+
"alwaysAddToPackageJson": false
|
|
152
|
+
},
|
|
153
|
+
"@storybook/addon-outline": {
|
|
154
|
+
"version": "^7.0.24",
|
|
155
|
+
"alwaysAddToPackageJson": false
|
|
156
|
+
},
|
|
157
|
+
"@storybook/addon-storyshots": {
|
|
158
|
+
"version": "^7.0.24",
|
|
159
|
+
"alwaysAddToPackageJson": false
|
|
160
|
+
},
|
|
161
|
+
"@storybook/addon-storyshots-puppeteer": {
|
|
162
|
+
"version": "^7.0.24",
|
|
163
|
+
"alwaysAddToPackageJson": false
|
|
164
|
+
},
|
|
165
|
+
"@storybook/addon-storysource": {
|
|
166
|
+
"version": "^7.0.24",
|
|
167
|
+
"alwaysAddToPackageJson": false
|
|
168
|
+
},
|
|
169
|
+
"@storybook/addon-toolbars": {
|
|
170
|
+
"version": "^7.0.24",
|
|
171
|
+
"alwaysAddToPackageJson": false
|
|
172
|
+
},
|
|
173
|
+
"@storybook/addon-viewport": {
|
|
174
|
+
"version": "^7.0.24",
|
|
175
|
+
"alwaysAddToPackageJson": false
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
65
179
|
"16.1.3": {
|
|
66
180
|
"version": "16.1.3-beta.0",
|
|
67
181
|
"requires": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.5.0-beta.0",
|
|
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.
|
|
34
|
-
"@nx/cypress": "16.
|
|
35
|
-
"@nx/devkit": "16.
|
|
36
|
-
"@nx/js": "16.
|
|
37
|
-
"@nx/linter": "16.
|
|
38
|
-
"@nx/workspace": "16.
|
|
33
|
+
"@nrwl/storybook": "16.5.0-beta.0",
|
|
34
|
+
"@nx/cypress": "16.5.0-beta.0",
|
|
35
|
+
"@nx/devkit": "16.5.0-beta.0",
|
|
36
|
+
"@nx/js": "16.5.0-beta.0",
|
|
37
|
+
"@nx/linter": "16.5.0-beta.0",
|
|
38
|
+
"@nx/workspace": "16.5.0-beta.0",
|
|
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": "
|
|
47
|
+
"gitHead": "376d656cfc7f6390ff1cd6d9de348baf7bccbf33"
|
|
48
48
|
}
|
|
@@ -43,7 +43,11 @@ function configurationGenerator(tree, rawSchema) {
|
|
|
43
43
|
js: schema.js,
|
|
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);
|
|
48
|
+
if (schema.uiFramework !== '@storybook/angular') {
|
|
49
|
+
(0, util_functions_1.createStorybookTsconfigFile)(tree, root, schema.uiFramework, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), mainDir);
|
|
50
|
+
}
|
|
47
51
|
(0, util_functions_1.configureTsProjectConfig)(tree, schema);
|
|
48
52
|
(0, util_functions_1.configureTsSolutionConfig)(tree, schema);
|
|
49
53
|
(0, util_functions_1.updateLintConfig)(tree, schema);
|
|
@@ -4,6 +4,7 @@ import { UiFramework7 } from '../../../utils/models';
|
|
|
4
4
|
export declare function addStorybookTask(tree: Tree, projectName: string, uiFramework: string, configureTestRunner: boolean): void;
|
|
5
5
|
export declare function addAngularStorybookTask(tree: Tree, projectName: string, configureTestRunner: boolean): void;
|
|
6
6
|
export declare function addStaticTarget(tree: Tree, opts: StorybookConfigureSchema): void;
|
|
7
|
+
export declare function createStorybookTsconfigFile(tree: Tree, projectRoot: string, uiFramework: UiFramework7, isRootProject: boolean, mainDir: 'components' | 'src'): void;
|
|
7
8
|
export declare function configureTsProjectConfig(tree: Tree, schema: StorybookConfigureSchema): void;
|
|
8
9
|
export declare function configureTsSolutionConfig(tree: Tree, schema: StorybookConfigureSchema): void;
|
|
9
10
|
/**
|
|
@@ -17,7 +18,7 @@ export declare function configureTsSolutionConfig(tree: Tree, schema: StorybookC
|
|
|
17
18
|
export declare function updateLintConfig(tree: Tree, schema: StorybookConfigureSchema): void;
|
|
18
19
|
export declare function normalizeSchema(schema: StorybookConfigureSchema): StorybookConfigureSchema;
|
|
19
20
|
export declare function addStorybookToNamedInputs(tree: Tree): void;
|
|
20
|
-
export declare function createProjectStorybookDir(tree: Tree, projectName: string, uiFramework: UiFramework7, js: boolean, tsConfiguration: boolean, root: string, projectType: string, projectIsRootProjectInStandaloneWorkspace: boolean, 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, mainDir?: string, isNextJs?: boolean, usesSwc?: boolean, usesVite?: boolean, viteConfigFilePath?: string): void;
|
|
21
22
|
export declare function getTsConfigPath(tree: Tree, projectName: string, path?: string): string;
|
|
22
23
|
export declare function addBuildStorybookToCacheableOperations(tree: Tree): void;
|
|
23
24
|
export declare function projectIsRootProjectInStandaloneWorkspace(projectRoot: string): boolean;
|
|
@@ -25,3 +26,4 @@ export declare function workspaceHasRootProject(tree: Tree): boolean;
|
|
|
25
26
|
export declare function rootFileIsTs(tree: Tree, rootFileName: string, tsConfiguration: boolean): boolean;
|
|
26
27
|
export declare function getE2EProjectName(tree: Tree, mainProject: string): Promise<string | undefined>;
|
|
27
28
|
export declare function getViteConfigFilePath(tree: Tree, projectRoot: string, configFile?: string): string | undefined;
|
|
29
|
+
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.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.addStaticTarget = exports.addAngularStorybookTask = exports.addStorybookTask = 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.createStorybookTsconfigFile = exports.addStaticTarget = exports.addAngularStorybookTask = exports.addStorybookTask = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
@@ -109,6 +109,67 @@ function addStaticTarget(tree, opts) {
|
|
|
109
109
|
(0, devkit_1.updateProjectConfiguration)(tree, opts.name, projectConfig);
|
|
110
110
|
}
|
|
111
111
|
exports.addStaticTarget = addStaticTarget;
|
|
112
|
+
function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProject, mainDir) {
|
|
113
|
+
// First let's check if old configuration file exists
|
|
114
|
+
// If it exists, let's rename it and move it to the new location
|
|
115
|
+
const oldStorybookTsConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, '.storybook/tsconfig.json');
|
|
116
|
+
if (tree.exists(oldStorybookTsConfigPath)) {
|
|
117
|
+
devkit_1.logger.warn(`.storybook/tsconfig.json already exists for this project`);
|
|
118
|
+
devkit_1.logger.warn(`It will be renamed and moved to tsconfig.storybook.json.
|
|
119
|
+
Please make sure all settings look correct after this change.
|
|
120
|
+
Also, please make sure to use "nx migrate" to move from one version of Nx to another.
|
|
121
|
+
`);
|
|
122
|
+
renameAndMoveOldTsConfig(projectRoot, oldStorybookTsConfigPath, tree);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const storybookTsConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.storybook.json');
|
|
126
|
+
if (tree.exists(storybookTsConfigPath)) {
|
|
127
|
+
devkit_1.logger.info(`tsconfig.storybook.json already exists for this project`);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const exclude = [`${mainDir}/**/*.spec.ts`, `${mainDir}/**/*.test.ts`];
|
|
131
|
+
if (uiFramework === '@storybook/react-webpack5' ||
|
|
132
|
+
uiFramework === '@storybook/react-vite') {
|
|
133
|
+
exclude.push(`${mainDir}/**/*.spec.js`, `${mainDir}/**/*.test.js`, `${mainDir}/**/*.spec.tsx`, `${mainDir}/**/*.test.tsx`, `${mainDir}/**/*.spec.jsx`, `${mainDir}/**/*.test.js`);
|
|
134
|
+
}
|
|
135
|
+
let files;
|
|
136
|
+
if (uiFramework === '@storybook/react-webpack5' ||
|
|
137
|
+
uiFramework === '@storybook/react-vite') {
|
|
138
|
+
const offset = (0, devkit_1.offsetFromRoot)(projectRoot);
|
|
139
|
+
files = [
|
|
140
|
+
`${!isRootProject ? offset : ''}node_modules/@nx/react/typings/styled-jsx.d.ts`,
|
|
141
|
+
`${!isRootProject ? offset : ''}node_modules/@nx/react/typings/cssmodule.d.ts`,
|
|
142
|
+
`${!isRootProject ? offset : ''}node_modules/@nx/react/typings/image.d.ts`,
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
const include = [
|
|
146
|
+
`${mainDir}/**/*.stories.ts`,
|
|
147
|
+
`${mainDir}/**/*.stories.js`,
|
|
148
|
+
`${mainDir}/**/*.stories.jsx`,
|
|
149
|
+
`${mainDir}/**/*.stories.tsx`,
|
|
150
|
+
`${mainDir}/**/*.stories.mdx`,
|
|
151
|
+
'.storybook/*.js',
|
|
152
|
+
'.storybook/*.ts',
|
|
153
|
+
];
|
|
154
|
+
if (uiFramework === '@storybook/react-native') {
|
|
155
|
+
include.push('*.ts', '*.tsx');
|
|
156
|
+
}
|
|
157
|
+
const storybookTsConfig = {
|
|
158
|
+
extends: './tsconfig.json',
|
|
159
|
+
compilerOptions: {
|
|
160
|
+
emitDecoratorMetadata: true,
|
|
161
|
+
outDir: uiFramework === '@storybook/react-webpack5' ||
|
|
162
|
+
uiFramework === '@storybook/react-vite'
|
|
163
|
+
? ''
|
|
164
|
+
: undefined,
|
|
165
|
+
},
|
|
166
|
+
files,
|
|
167
|
+
exclude,
|
|
168
|
+
include,
|
|
169
|
+
};
|
|
170
|
+
(0, devkit_1.writeJson)(tree, storybookTsConfigPath, storybookTsConfig);
|
|
171
|
+
}
|
|
172
|
+
exports.createStorybookTsconfigFile = createStorybookTsconfigFile;
|
|
112
173
|
function configureTsProjectConfig(tree, schema) {
|
|
113
174
|
var _a, _b, _c;
|
|
114
175
|
const { name: projectName } = schema;
|
|
@@ -143,18 +204,30 @@ function configureTsProjectConfig(tree, schema) {
|
|
|
143
204
|
}
|
|
144
205
|
exports.configureTsProjectConfig = configureTsProjectConfig;
|
|
145
206
|
function configureTsSolutionConfig(tree, schema) {
|
|
146
|
-
var _a, _b;
|
|
207
|
+
var _a, _b, _c, _d;
|
|
147
208
|
const { name: projectName } = schema;
|
|
148
209
|
const { root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
149
210
|
const tsConfigPath = (0, path_1.join)(root, 'tsconfig.json');
|
|
150
211
|
const tsConfigContent = (0, devkit_1.readJson)(tree, tsConfigPath);
|
|
151
|
-
if (
|
|
152
|
-
tsConfigContent.references
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
212
|
+
if (schema.uiFramework === '@storybook/angular') {
|
|
213
|
+
if (!((_b = (_a = tsConfigContent.references) === null || _a === void 0 ? void 0 : _a.map((reference) => reference.path)) === null || _b === void 0 ? void 0 : _b.includes('./.storybook/tsconfig.json'))) {
|
|
214
|
+
tsConfigContent.references = [
|
|
215
|
+
...(tsConfigContent.references || []),
|
|
216
|
+
{
|
|
217
|
+
path: './.storybook/tsconfig.json',
|
|
218
|
+
},
|
|
219
|
+
];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
if (!((_d = (_c = tsConfigContent.references) === null || _c === void 0 ? void 0 : _c.map((reference) => reference.path)) === null || _d === void 0 ? void 0 : _d.includes('./tsconfig.storybook.json'))) {
|
|
224
|
+
tsConfigContent.references = [
|
|
225
|
+
...(tsConfigContent.references || []),
|
|
226
|
+
{
|
|
227
|
+
path: './tsconfig.storybook.json',
|
|
228
|
+
},
|
|
229
|
+
];
|
|
230
|
+
}
|
|
158
231
|
}
|
|
159
232
|
(0, devkit_1.writeJson)(tree, tsConfigPath, tsConfigContent);
|
|
160
233
|
}
|
|
@@ -186,7 +259,9 @@ function updateLintConfig(tree, schema) {
|
|
|
186
259
|
if (Array.isArray((_b = json.parserOptions) === null || _b === void 0 ? void 0 : _b.project)) {
|
|
187
260
|
json.parserOptions.project = (0, utilities_1.dedupe)([
|
|
188
261
|
...json.parserOptions.project,
|
|
189
|
-
|
|
262
|
+
schema.uiFramework === '@storybook/angular'
|
|
263
|
+
? (0, path_1.join)(root, '.storybook/tsconfig.json')
|
|
264
|
+
: (0, path_1.join)(root, 'tsconfig.storybook.json'),
|
|
190
265
|
]);
|
|
191
266
|
}
|
|
192
267
|
const overrides = json.overrides || [];
|
|
@@ -197,7 +272,9 @@ function updateLintConfig(tree, schema) {
|
|
|
197
272
|
if (Array.isArray((_d = o.parserOptions) === null || _d === void 0 ? void 0 : _d.project)) {
|
|
198
273
|
o.parserOptions.project = (0, utilities_1.dedupe)([
|
|
199
274
|
...o.parserOptions.project,
|
|
200
|
-
|
|
275
|
+
schema.uiFramework === '@storybook/angular'
|
|
276
|
+
? (0, path_1.join)(root, '.storybook/tsconfig.json')
|
|
277
|
+
: (0, path_1.join)(root, 'tsconfig.storybook.json'),
|
|
201
278
|
]);
|
|
202
279
|
}
|
|
203
280
|
}
|
|
@@ -228,6 +305,9 @@ function addStorybookToNamedInputs(tree) {
|
|
|
228
305
|
if (!nxJson.namedInputs.production.includes('!{projectRoot}/.storybook/**/*')) {
|
|
229
306
|
nxJson.namedInputs.production.push('!{projectRoot}/.storybook/**/*');
|
|
230
307
|
}
|
|
308
|
+
if (!nxJson.namedInputs.production.includes('!{projectRoot}/tsconfig.storybook.json')) {
|
|
309
|
+
nxJson.namedInputs.production.push('!{projectRoot}/tsconfig.storybook.json');
|
|
310
|
+
}
|
|
231
311
|
}
|
|
232
312
|
(_b = nxJson.targetDefaults) !== null && _b !== void 0 ? _b : (nxJson.targetDefaults = {});
|
|
233
313
|
(_c = (_e = nxJson.targetDefaults)['build-storybook']) !== null && _c !== void 0 ? _c : (_e['build-storybook'] = {});
|
|
@@ -235,14 +315,23 @@ function addStorybookToNamedInputs(tree) {
|
|
|
235
315
|
'default',
|
|
236
316
|
hasProductionFileset ? '^production' : '^default',
|
|
237
317
|
]);
|
|
238
|
-
if (!nxJson.targetDefaults['build-storybook'].inputs.includes('
|
|
239
|
-
nxJson.targetDefaults['build-storybook'].inputs.push('
|
|
318
|
+
if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/.storybook/**/*')) {
|
|
319
|
+
nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/.storybook/**/*');
|
|
320
|
+
}
|
|
321
|
+
// Delete the !{projectRoot}/.storybook/**/* glob from build-storybook
|
|
322
|
+
// because we want to rebuild Storybook if the .storybook folder changes
|
|
323
|
+
const index = nxJson.targetDefaults['build-storybook'].inputs.indexOf('!{projectRoot}/.storybook/**/*');
|
|
324
|
+
if (index !== -1) {
|
|
325
|
+
nxJson.targetDefaults['build-storybook'].inputs.splice(index, 1);
|
|
326
|
+
}
|
|
327
|
+
if (!nxJson.targetDefaults['build-storybook'].inputs.includes('{projectRoot}/tsconfig.storybook.json')) {
|
|
328
|
+
nxJson.targetDefaults['build-storybook'].inputs.push('{projectRoot}/tsconfig.storybook.json');
|
|
240
329
|
}
|
|
241
330
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
242
331
|
}
|
|
243
332
|
}
|
|
244
333
|
exports.addStorybookToNamedInputs = addStorybookToNamedInputs;
|
|
245
|
-
function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, isNextJs, usesSwc, usesVite, viteConfigFilePath) {
|
|
334
|
+
function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath) {
|
|
246
335
|
const projectDirectory = projectType === 'application'
|
|
247
336
|
? isNextJs
|
|
248
337
|
? 'components'
|
|
@@ -256,7 +345,6 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
|
|
|
256
345
|
devkit_1.logger.warn(`Storybook configuration files already exist for ${projectName}!`);
|
|
257
346
|
return;
|
|
258
347
|
}
|
|
259
|
-
devkit_1.logger.debug(`adding .storybook folder to your ${projectType}`);
|
|
260
348
|
const templatePath = (0, path_1.join)(__dirname, `../project-files${tsConfiguration ? '-ts' : ''}`);
|
|
261
349
|
(0, devkit_1.generateFiles)(tree, templatePath, root, {
|
|
262
350
|
tmpl: '',
|
|
@@ -264,7 +352,7 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
|
|
|
264
352
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(root),
|
|
265
353
|
projectDirectory,
|
|
266
354
|
projectType,
|
|
267
|
-
mainDir
|
|
355
|
+
mainDir,
|
|
268
356
|
isNextJs: isNextJs && projectType === 'application',
|
|
269
357
|
usesSwc,
|
|
270
358
|
usesVite,
|
|
@@ -274,6 +362,15 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
|
|
|
274
362
|
if (js) {
|
|
275
363
|
(0, devkit_1.toJS)(tree);
|
|
276
364
|
}
|
|
365
|
+
if (uiFramework !== '@storybook/angular') {
|
|
366
|
+
// This file is only used for Angular
|
|
367
|
+
// For non-Angular projects, we generate a file
|
|
368
|
+
// called tsconfig.storybook.json at the root of the project
|
|
369
|
+
// using the createStorybookTsconfigFile function
|
|
370
|
+
// since Storybook is only taking into account .storybook/tsconfig.json
|
|
371
|
+
// for Angular projects
|
|
372
|
+
tree.delete((0, path_1.join)(root, '.storybook/tsconfig.json'));
|
|
373
|
+
}
|
|
277
374
|
}
|
|
278
375
|
exports.createProjectStorybookDir = createProjectStorybookDir;
|
|
279
376
|
function getTsConfigPath(tree, projectName, path) {
|
|
@@ -351,3 +448,49 @@ function getViteConfigFilePath(tree, projectRoot, configFile) {
|
|
|
351
448
|
: undefined;
|
|
352
449
|
}
|
|
353
450
|
exports.getViteConfigFilePath = getViteConfigFilePath;
|
|
451
|
+
function renameAndMoveOldTsConfig(projectRoot, pathToStorybookConfigFile, tree) {
|
|
452
|
+
if (pathToStorybookConfigFile) {
|
|
453
|
+
(0, devkit_1.updateJson)(tree, pathToStorybookConfigFile, (json) => {
|
|
454
|
+
var _a;
|
|
455
|
+
if ((_a = json.extends) === null || _a === void 0 ? void 0 : _a.startsWith('../')) {
|
|
456
|
+
// drop one level of nesting
|
|
457
|
+
json.extends = json.extends.replace('../', './');
|
|
458
|
+
}
|
|
459
|
+
for (let i = 0; i < json.files.length; i++) {
|
|
460
|
+
// drop one level of nesting
|
|
461
|
+
if (json.files[i].startsWith('../../../')) {
|
|
462
|
+
json.files[i] = json.files[i].replace('../../../', '../../');
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
for (let i = 0; i < json.include.length; i++) {
|
|
466
|
+
if (json.include[i].startsWith('../')) {
|
|
467
|
+
json.include[i] = json.include[i].replace('../', '');
|
|
468
|
+
}
|
|
469
|
+
if (json.include[i] === '*.js') {
|
|
470
|
+
json.include[i] = '.storybook/*.js';
|
|
471
|
+
}
|
|
472
|
+
if (json.include[i] === '*.ts') {
|
|
473
|
+
json.include[i] = '.storybook/*.ts';
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
for (let i = 0; i < json.exclude.length; i++) {
|
|
477
|
+
if (json.exclude[i].startsWith('../')) {
|
|
478
|
+
json.exclude[i] = json.exclude[i].replace('../', 'src/');
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return json;
|
|
482
|
+
});
|
|
483
|
+
tree.rename(pathToStorybookConfigFile, (0, devkit_1.joinPathFragments)(projectRoot, `tsconfig.storybook.json`));
|
|
484
|
+
}
|
|
485
|
+
const projectTsConfig = (0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.json');
|
|
486
|
+
(0, devkit_1.updateJson)(tree, projectTsConfig, (json) => {
|
|
487
|
+
for (let i = 0; i < json.references.length; i++) {
|
|
488
|
+
if (json.references[i].path === './.storybook/tsconfig.json') {
|
|
489
|
+
json.references[i].path = './tsconfig.storybook.json';
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return json;
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
exports.renameAndMoveOldTsConfig = renameAndMoveOldTsConfig;
|
|
@@ -2,25 +2,14 @@
|
|
|
2
2
|
"extends": "../tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"emitDecoratorMetadata": true
|
|
5
|
-
<% if(uiFramework === '@storybook/react-webpack5' || uiFramework === '@storybook/react-vite') { %>, "outDir": "" <% } %>
|
|
6
5
|
},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"<% if(!isRootProject) { %><%= offsetFromRoot %><% } %>../node_modules/@nx/react/typings/cssmodule.d.ts",
|
|
10
|
-
"<% if(!isRootProject) { %><%= offsetFromRoot %><% } %>../node_modules/@nx/react/typings/image.d.ts"
|
|
11
|
-
],<% } %>
|
|
12
|
-
"exclude": ["../**/*.spec.ts" <% if(uiFramework === '@storybook/react-webpack5' || uiFramework === '@storybook/react-vite') { %>, "../**/*.spec.js", "../**/*.spec.tsx", "../**/*.spec.jsx"<% } %>],
|
|
13
|
-
"include": [<% if(uiFramework === '@storybook/angular' && projectType === 'library') { %>
|
|
6
|
+
"exclude": ["../**/*.spec.ts"],
|
|
7
|
+
"include": [
|
|
14
8
|
"../src/**/*.stories.ts",
|
|
15
9
|
"../src/**/*.stories.js",
|
|
16
10
|
"../src/**/*.stories.jsx",
|
|
17
11
|
"../src/**/*.stories.tsx",
|
|
18
12
|
"../src/**/*.stories.mdx",
|
|
19
|
-
"*.js"
|
|
20
|
-
|
|
21
|
-
"../<%= mainDir %>/**/*.stories.js",
|
|
22
|
-
"../<%= mainDir %>/**/*.stories.jsx",
|
|
23
|
-
"../<%= mainDir %>/**/*.stories.tsx",
|
|
24
|
-
"../<%= mainDir %>/**/*.stories.mdx",
|
|
25
|
-
"*.js"<% if(uiFramework === '@storybook/react-native') { %>, "*.ts", "*.tsx"<% } %><% } %>]
|
|
13
|
+
"*.js"
|
|
14
|
+
]
|
|
26
15
|
}
|
|
@@ -2,27 +2,15 @@
|
|
|
2
2
|
"extends": "../tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"emitDecoratorMetadata": true
|
|
5
|
-
<% if(uiFramework === '@storybook/react-webpack5' || uiFramework === '@storybook/react-vite') { %>, "outDir": "" <% } %>
|
|
6
5
|
},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"<% if(!isRootProject) { %><%= offsetFromRoot %><% } %>../node_modules/@nx/react/typings/cssmodule.d.ts",
|
|
10
|
-
"<% if(!isRootProject) { %><%= offsetFromRoot %><% } %>../node_modules/@nx/react/typings/image.d.ts"
|
|
11
|
-
],<% } %>
|
|
12
|
-
"exclude": ["../**/*.spec.ts" <% if(uiFramework === '@storybook/react-webpack5' || uiFramework === '@storybook/react-vite') { %>, "../**/*.spec.js", "../**/*.spec.tsx", "../**/*.spec.jsx"<% } %>],
|
|
13
|
-
"include": [<% if(uiFramework === '@storybook/angular' && projectType === 'library') { %>
|
|
6
|
+
"exclude": ["../**/*.spec.ts"],
|
|
7
|
+
"include": [
|
|
14
8
|
"../src/**/*.stories.ts",
|
|
15
9
|
"../src/**/*.stories.js",
|
|
16
10
|
"../src/**/*.stories.jsx",
|
|
17
11
|
"../src/**/*.stories.tsx",
|
|
18
12
|
"../src/**/*.stories.mdx",
|
|
19
|
-
"*.
|
|
20
|
-
"*.
|
|
21
|
-
|
|
22
|
-
"../<%= mainDir %>/**/*.stories.js",
|
|
23
|
-
"../<%= mainDir %>/**/*.stories.jsx",
|
|
24
|
-
"../<%= mainDir %>/**/*.stories.tsx",
|
|
25
|
-
"../<%= mainDir %>/**/*.stories.mdx",
|
|
26
|
-
"*.ts",
|
|
27
|
-
"*.js"<% if(uiFramework === '@storybook/react-native') { %>, "*.tsx"<% } %><% } %>]
|
|
13
|
+
"*.js",
|
|
14
|
+
"*.ts"
|
|
15
|
+
]
|
|
28
16
|
}
|
|
@@ -109,7 +109,8 @@ function migrateProjectLevelStorybookInstance(tree, projectName, uiFramework, co
|
|
|
109
109
|
}
|
|
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
114
|
}
|
|
114
115
|
function moveDirectory(tree, from, to) {
|
|
115
116
|
(0, devkit_1.visitNotIgnoredFiles)(tree, from, (file) => {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const util_functions_1 = require("../../generators/configuration/lib/util-functions");
|
|
7
|
+
function default_1(tree) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/storybook:storybook', (options, projectName) => {
|
|
10
|
+
const projectConfiguration = (0, devkit_1.getProjects)(tree).get(projectName);
|
|
11
|
+
const projectRoot = projectConfiguration.root;
|
|
12
|
+
if ((options === null || options === void 0 ? void 0 : options['configDir']) === undefined) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const pathToStorybookConfigFile = (0, devkit_1.joinPathFragments)(options === null || options === void 0 ? void 0 : options['configDir'], 'tsconfig.json');
|
|
16
|
+
(0, util_functions_1.renameAndMoveOldTsConfig)(projectRoot, pathToStorybookConfigFile, tree);
|
|
17
|
+
});
|
|
18
|
+
(0, util_functions_1.addStorybookToNamedInputs)(tree);
|
|
19
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.default = default_1;
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export declare const reactNativeStorybookLoader = "^2.0.5";
|
|
|
4
4
|
export declare const storybookTestRunnerVersion = "^0.7.2";
|
|
5
5
|
export declare const litVersion = "^2.6.1";
|
|
6
6
|
export declare const tsNodeVersion = "10.9.1";
|
|
7
|
-
export declare const storybookVersion = "^7.0.
|
|
7
|
+
export declare const storybookVersion = "^7.0.24";
|
|
8
8
|
export declare const reactVersion = "^18.2.0";
|
|
9
9
|
export declare const viteVersion = "^4.3.4";
|
package/src/utils/versions.js
CHANGED
|
@@ -7,6 +7,6 @@ exports.reactNativeStorybookLoader = '^2.0.5';
|
|
|
7
7
|
exports.storybookTestRunnerVersion = '^0.7.2';
|
|
8
8
|
exports.litVersion = '^2.6.1';
|
|
9
9
|
exports.tsNodeVersion = '10.9.1';
|
|
10
|
-
exports.storybookVersion = '^7.0.
|
|
10
|
+
exports.storybookVersion = '^7.0.24';
|
|
11
11
|
exports.reactVersion = '^18.2.0';
|
|
12
12
|
exports.viteVersion = '^4.3.4';
|