@nx/storybook 17.0.2 → 17.0.4
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/LICENSE +1 -1
- package/README.md +9 -4
- package/generators.json +2 -2
- package/migrations.json +140 -0
- package/package.json +7 -7
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/presets/cypress.d.ts +1 -20
- package/src/executors/build-storybook/build-storybook.impl.js +1 -1
- package/src/executors/storybook/storybook.impl.js +1 -1
- package/src/generators/configuration/configuration.d.ts +2 -1
- package/src/generators/configuration/configuration.js +69 -32
- package/src/generators/configuration/lib/edit-root-tsconfig.d.ts +8 -0
- package/src/generators/configuration/lib/edit-root-tsconfig.js +35 -0
- package/src/generators/configuration/lib/ensure-dependencies.d.ts +6 -0
- package/src/generators/configuration/lib/ensure-dependencies.js +70 -0
- package/src/generators/configuration/lib/util-functions.d.ts +11 -5
- package/src/generators/configuration/lib/util-functions.js +88 -69
- package/src/generators/configuration/project-files/.storybook/main.js__tmpl__ +23 -3
- package/src/generators/configuration/project-files-ts/.storybook/main.ts__tmpl__ +22 -3
- package/src/generators/configuration/schema.d.ts +9 -3
- package/src/generators/configuration/schema.json +6 -13
- package/src/generators/cypress-project/cypress-project.d.ts +3 -3
- package/src/generators/cypress-project/cypress-project.js +3 -8
- package/src/generators/cypress-project/schema.json +1 -1
- package/src/generators/init/init.d.ts +1 -0
- package/src/generators/init/init.js +47 -117
- package/src/generators/init/lib/update-gitignore.d.ts +2 -0
- package/src/generators/init/lib/update-gitignore.js +16 -0
- package/src/generators/init/schema.d.ts +5 -4
- package/src/generators/init/schema.json +18 -33
- package/src/generators/migrate-7/calling-storybook-cli.js +2 -2
- package/src/migrations/update-16-5-0/move-storybook-tsconfig.js +1 -0
- package/src/plugins/plugin.d.ts +9 -0
- package/src/plugins/plugin.js +232 -0
- package/src/utils/models.d.ts +1 -1
- package/src/utils/utilities.d.ts +1 -0
- package/src/utils/utilities.js +30 -8
- package/src/utils/versions.d.ts +6 -7
- package/src/utils/versions.js +7 -8
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<p style="text-align: center;"
|
|
1
|
+
<p style="text-align: center;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
+
<img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
2
7
|
|
|
3
8
|
<div style="text-align: center;">
|
|
4
9
|
|
|
@@ -15,9 +20,9 @@
|
|
|
15
20
|
|
|
16
21
|
<hr>
|
|
17
22
|
|
|
18
|
-
# Nx: Smart
|
|
23
|
+
# Nx: Smart Monorepos · Fast CI
|
|
19
24
|
|
|
20
|
-
Nx is a
|
|
25
|
+
Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
|
|
21
26
|
|
|
22
27
|
This package is a [Storybook plugin for Nx](https://nx.dev/packages/storybook).
|
|
23
28
|
|
|
@@ -59,5 +64,5 @@ npx nx@latest init
|
|
|
59
64
|
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
60
65
|
|
|
61
66
|
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
62
|
-
width="100%" alt="Nx - Smart
|
|
67
|
+
width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
|
|
63
68
|
|
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/migrations.json
CHANGED
|
@@ -50,6 +50,137 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"packageJsonUpdates": {
|
|
53
|
+
"17.2.0-beta.2": {
|
|
54
|
+
"version": "17.2.0-beta.2",
|
|
55
|
+
"packages": {
|
|
56
|
+
"vite": {
|
|
57
|
+
"version": "^5.0.0",
|
|
58
|
+
"alwaysAddToPackageJson": false
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"17.1.0-beta.4": {
|
|
63
|
+
"version": "17.1.0-beta.4",
|
|
64
|
+
"packages": {
|
|
65
|
+
"@storybook/testing-library": {
|
|
66
|
+
"version": "^0.2.2",
|
|
67
|
+
"alwaysAddToPackageJson": false
|
|
68
|
+
},
|
|
69
|
+
"@storybook/jest": {
|
|
70
|
+
"version": "^0.2.3",
|
|
71
|
+
"alwaysAddToPackageJson": false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"17.1.0": {
|
|
76
|
+
"version": "17.1.0-beta.3",
|
|
77
|
+
"packages": {
|
|
78
|
+
"@storybook/test-runner": {
|
|
79
|
+
"version": "^0.13.0",
|
|
80
|
+
"alwaysAddToPackageJson": false
|
|
81
|
+
},
|
|
82
|
+
"@storybook/core-server": {
|
|
83
|
+
"version": "^7.5.3",
|
|
84
|
+
"alwaysAddToPackageJson": false
|
|
85
|
+
},
|
|
86
|
+
"@storybook/angular": {
|
|
87
|
+
"version": "^7.5.3",
|
|
88
|
+
"alwaysAddToPackageJson": false
|
|
89
|
+
},
|
|
90
|
+
"@storybook/react": {
|
|
91
|
+
"version": "^7.5.3",
|
|
92
|
+
"alwaysAddToPackageJson": false
|
|
93
|
+
},
|
|
94
|
+
"@storybook/react-vite": {
|
|
95
|
+
"version": "^7.5.3",
|
|
96
|
+
"alwaysAddToPackageJson": false
|
|
97
|
+
},
|
|
98
|
+
"@storybook/react-webpack5": {
|
|
99
|
+
"version": "^7.5.3",
|
|
100
|
+
"alwaysAddToPackageJson": false
|
|
101
|
+
},
|
|
102
|
+
"@storybook/web-components-vite": {
|
|
103
|
+
"version": "^7.5.3",
|
|
104
|
+
"alwaysAddToPackageJson": false
|
|
105
|
+
},
|
|
106
|
+
"@storybook/web-components-webpack5": {
|
|
107
|
+
"version": "^7.5.3",
|
|
108
|
+
"alwaysAddToPackageJson": false
|
|
109
|
+
},
|
|
110
|
+
"@storybook/addon-a11y": {
|
|
111
|
+
"version": "^7.5.3",
|
|
112
|
+
"alwaysAddToPackageJson": false
|
|
113
|
+
},
|
|
114
|
+
"@storybook/addon-actions": {
|
|
115
|
+
"version": "^7.5.3",
|
|
116
|
+
"alwaysAddToPackageJson": false
|
|
117
|
+
},
|
|
118
|
+
"@storybook/addon-backgrounds": {
|
|
119
|
+
"version": "^7.5.3",
|
|
120
|
+
"alwaysAddToPackageJson": false
|
|
121
|
+
},
|
|
122
|
+
"@storybook/addon-controls": {
|
|
123
|
+
"version": "^7.5.3",
|
|
124
|
+
"alwaysAddToPackageJson": false
|
|
125
|
+
},
|
|
126
|
+
"@storybook/addon-docs": {
|
|
127
|
+
"version": "^7.5.3",
|
|
128
|
+
"alwaysAddToPackageJson": false
|
|
129
|
+
},
|
|
130
|
+
"@storybook/addon-essentials": {
|
|
131
|
+
"version": "^7.5.3",
|
|
132
|
+
"alwaysAddToPackageJson": false
|
|
133
|
+
},
|
|
134
|
+
"@storybook/addon-interactions": {
|
|
135
|
+
"version": "^7.5.3",
|
|
136
|
+
"alwaysAddToPackageJson": false
|
|
137
|
+
},
|
|
138
|
+
"@storybook/addon-mdx-gfm": {
|
|
139
|
+
"version": "^7.5.3",
|
|
140
|
+
"alwaysAddToPackageJson": false
|
|
141
|
+
},
|
|
142
|
+
"@storybook/addon-highlight": {
|
|
143
|
+
"version": "^7.5.3",
|
|
144
|
+
"alwaysAddToPackageJson": false
|
|
145
|
+
},
|
|
146
|
+
"@storybook/addon-jest": {
|
|
147
|
+
"version": "^7.5.3",
|
|
148
|
+
"alwaysAddToPackageJson": false
|
|
149
|
+
},
|
|
150
|
+
"@storybook/addon-links": {
|
|
151
|
+
"version": "^7.5.3",
|
|
152
|
+
"alwaysAddToPackageJson": false
|
|
153
|
+
},
|
|
154
|
+
"@storybook/addon-measure": {
|
|
155
|
+
"version": "^7.5.3",
|
|
156
|
+
"alwaysAddToPackageJson": false
|
|
157
|
+
},
|
|
158
|
+
"@storybook/addon-outline": {
|
|
159
|
+
"version": "^7.5.3",
|
|
160
|
+
"alwaysAddToPackageJson": false
|
|
161
|
+
},
|
|
162
|
+
"@storybook/addon-storyshots": {
|
|
163
|
+
"version": "^7.5.3",
|
|
164
|
+
"alwaysAddToPackageJson": false
|
|
165
|
+
},
|
|
166
|
+
"@storybook/addon-storyshots-puppeteer": {
|
|
167
|
+
"version": "^7.5.3",
|
|
168
|
+
"alwaysAddToPackageJson": false
|
|
169
|
+
},
|
|
170
|
+
"@storybook/addon-storysource": {
|
|
171
|
+
"version": "^7.5.3",
|
|
172
|
+
"alwaysAddToPackageJson": false
|
|
173
|
+
},
|
|
174
|
+
"@storybook/addon-toolbars": {
|
|
175
|
+
"version": "^7.5.3",
|
|
176
|
+
"alwaysAddToPackageJson": false
|
|
177
|
+
},
|
|
178
|
+
"@storybook/addon-viewport": {
|
|
179
|
+
"version": "^7.5.3",
|
|
180
|
+
"alwaysAddToPackageJson": false
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
53
184
|
"17.0.0": {
|
|
54
185
|
"version": "17.0.0-rc.3",
|
|
55
186
|
"packages": {
|
|
@@ -832,6 +963,15 @@
|
|
|
832
963
|
"alwaysAddToPackageJson": false
|
|
833
964
|
}
|
|
834
965
|
}
|
|
966
|
+
},
|
|
967
|
+
"18.2.0": {
|
|
968
|
+
"version": "18.2.0-beta.1",
|
|
969
|
+
"packages": {
|
|
970
|
+
"core-js": {
|
|
971
|
+
"version": "3.36.1",
|
|
972
|
+
"alwaysAddToPackageJson": false
|
|
973
|
+
}
|
|
974
|
+
}
|
|
835
975
|
}
|
|
836
976
|
}
|
|
837
977
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.4",
|
|
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": "17.0.4",
|
|
33
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
34
|
-
"semver": "7.5.3",
|
|
35
|
+
"semver": "^7.5.3",
|
|
35
36
|
"tslib": "^2.3.0",
|
|
36
|
-
"@nx/cypress": "17.0.
|
|
37
|
-
"@nx/
|
|
38
|
-
"@nx/
|
|
39
|
-
"@
|
|
40
|
-
"@nrwl/storybook": "17.0.2"
|
|
37
|
+
"@nx/cypress": "17.0.4",
|
|
38
|
+
"@nx/js": "17.0.4",
|
|
39
|
+
"@nx/eslint": "17.0.4",
|
|
40
|
+
"@nrwl/storybook": "17.0.4"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
package/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createNodes, StorybookPluginOptions, createDependencies, } from './src/plugins/plugin';
|
package/plugin.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDependencies = exports.createNodes = void 0;
|
|
4
|
+
var plugin_1 = require("./src/plugins/plugin");
|
|
5
|
+
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
6
|
+
Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
|
package/presets/cypress.d.ts
CHANGED
|
@@ -1,20 +1 @@
|
|
|
1
|
-
export declare function nxE2EStorybookPreset(filePath: string):
|
|
2
|
-
baseUrl: string;
|
|
3
|
-
fileServerFolder: string;
|
|
4
|
-
supportFile: string;
|
|
5
|
-
specPattern: string;
|
|
6
|
-
fixturesFolder: string;
|
|
7
|
-
videosFolder: string;
|
|
8
|
-
screenshotsFolder: string;
|
|
9
|
-
chromeWebSecurity: boolean;
|
|
10
|
-
} | {
|
|
11
|
-
baseUrl: string;
|
|
12
|
-
setupNodeEvents(on: any): void;
|
|
13
|
-
fileServerFolder: string;
|
|
14
|
-
supportFile: string;
|
|
15
|
-
specPattern: string;
|
|
16
|
-
fixturesFolder: string;
|
|
17
|
-
videosFolder: string;
|
|
18
|
-
screenshotsFolder: string;
|
|
19
|
-
chromeWebSecurity: boolean;
|
|
20
|
-
};
|
|
1
|
+
export declare function nxE2EStorybookPreset(filePath: string): any;
|
|
@@ -5,7 +5,7 @@ const build = require("@storybook/core-server");
|
|
|
5
5
|
const utilities_1 = require("../../utils/utilities");
|
|
6
6
|
async function buildStorybookExecutor(options, context) {
|
|
7
7
|
(0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
|
|
8
|
-
const storybook7 = (0, utilities_1.storybookMajorVersion)()
|
|
8
|
+
const storybook7 = (0, utilities_1.storybookMajorVersion)() >= 7;
|
|
9
9
|
if (!storybook7) {
|
|
10
10
|
throw (0, utilities_1.pleaseUpgrade)();
|
|
11
11
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const build = require("@storybook/core-server");
|
|
4
4
|
const utilities_1 = require("../../utils/utilities");
|
|
5
5
|
async function* storybookExecutor(options, context) {
|
|
6
|
-
const storybook7 = (0, utilities_1.storybookMajorVersion)()
|
|
6
|
+
const storybook7 = (0, utilities_1.storybookMajorVersion)() >= 7;
|
|
7
7
|
if (!storybook7) {
|
|
8
8
|
throw (0, utilities_1.pleaseUpgrade)();
|
|
9
9
|
}
|
|
@@ -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,7 +1,8 @@
|
|
|
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
|
+
const js_1 = require("@nx/js");
|
|
5
6
|
const cypress_project_1 = require("../cypress-project/cypress-project");
|
|
6
7
|
const init_1 = require("../init/init");
|
|
7
8
|
const util_functions_1 = require("./lib/util-functions");
|
|
@@ -9,40 +10,62 @@ const eslint_1 = require("@nx/eslint");
|
|
|
9
10
|
const utilities_1 = require("../../utils/utilities");
|
|
10
11
|
const versions_1 = require("../../utils/versions");
|
|
11
12
|
const interaction_testing_utils_1 = require("./lib/interaction-testing.utils");
|
|
12
|
-
|
|
13
|
+
const ensure_dependencies_1 = require("./lib/ensure-dependencies");
|
|
14
|
+
const edit_root_tsconfig_1 = require("./lib/edit-root-tsconfig");
|
|
15
|
+
function configurationGenerator(tree, schema) {
|
|
16
|
+
return configurationGeneratorInternal(tree, { addPlugin: false, ...schema });
|
|
17
|
+
}
|
|
18
|
+
exports.configurationGenerator = configurationGenerator;
|
|
19
|
+
async function configurationGeneratorInternal(tree, rawSchema) {
|
|
13
20
|
if ((0, utilities_1.storybookMajorVersion)() === 6) {
|
|
14
21
|
throw new Error((0, utilities_1.pleaseUpgrade)());
|
|
15
22
|
}
|
|
16
|
-
const schema = normalizeSchema(rawSchema);
|
|
23
|
+
const schema = normalizeSchema(tree, rawSchema);
|
|
17
24
|
const tasks = [];
|
|
18
|
-
const { projectType, targets, root } = (0, devkit_1.readProjectConfiguration)(tree, schema.
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
const { projectType, targets, root } = (0, devkit_1.readProjectConfiguration)(tree, schema.project);
|
|
26
|
+
const { compiler } = (0, utilities_1.findStorybookAndBuildTargetsAndCompiler)(targets);
|
|
27
|
+
const viteConfig = (0, util_functions_1.findViteConfig)(tree, root);
|
|
28
|
+
const viteConfigFilePath = viteConfig?.fullConfigPath;
|
|
29
|
+
const viteConfigFileName = viteConfig?.viteConfigFileName;
|
|
30
|
+
const nextConfigFilePath = (0, util_functions_1.findNextConfig)(tree, root);
|
|
31
|
+
const metroConfigFilePath = (0, util_functions_1.findMetroConfig)(tree, root);
|
|
32
|
+
if (viteConfigFilePath) {
|
|
25
33
|
if (schema.uiFramework === '@storybook/react-webpack5') {
|
|
26
|
-
devkit_1.logger.info(`Your project ${schema.
|
|
34
|
+
devkit_1.logger.info(`Your project ${schema.project} uses Vite as a bundler.
|
|
27
35
|
Nx will configure Storybook for this project to use Vite as well.`);
|
|
28
36
|
schema.uiFramework = '@storybook/react-vite';
|
|
29
37
|
}
|
|
30
38
|
if (schema.uiFramework === '@storybook/web-components-webpack5') {
|
|
31
|
-
devkit_1.logger.info(`Your project ${schema.
|
|
39
|
+
devkit_1.logger.info(`Your project ${schema.project} uses Vite as a bundler.
|
|
32
40
|
Nx will configure Storybook for this project to use Vite as well.`);
|
|
33
41
|
schema.uiFramework = '@storybook/web-components-vite';
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
|
-
if (
|
|
44
|
+
if (nextConfigFilePath) {
|
|
37
45
|
schema.uiFramework = '@storybook/nextjs';
|
|
38
46
|
}
|
|
47
|
+
const jsInitTask = await (0, js_1.initGenerator)(tree, {
|
|
48
|
+
...schema,
|
|
49
|
+
skipFormat: true,
|
|
50
|
+
});
|
|
51
|
+
tasks.push(jsInitTask);
|
|
39
52
|
const initTask = await (0, init_1.initGenerator)(tree, {
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
skipFormat: true,
|
|
54
|
+
addPlugin: schema.addPlugin,
|
|
42
55
|
});
|
|
43
56
|
tasks.push(initTask);
|
|
44
|
-
|
|
45
|
-
(0,
|
|
57
|
+
tasks.push((0, ensure_dependencies_1.ensureDependencies)(tree, { uiFramework: schema.uiFramework }));
|
|
58
|
+
(0, edit_root_tsconfig_1.editRootTsConfig)(tree);
|
|
59
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
60
|
+
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
61
|
+
? p === '@nx/storybook/plugin'
|
|
62
|
+
: p.plugin === '@nx/storybook/plugin');
|
|
63
|
+
const mainDir = !!nextConfigFilePath && projectType === 'application'
|
|
64
|
+
? 'components'
|
|
65
|
+
: 'src';
|
|
66
|
+
const usesVite = !!viteConfigFilePath || schema.uiFramework?.endsWith('-vite');
|
|
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);
|
|
46
69
|
if (schema.uiFramework !== '@storybook/angular') {
|
|
47
70
|
(0, util_functions_1.createStorybookTsconfigFile)(tree, root, schema.uiFramework, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), mainDir);
|
|
48
71
|
}
|
|
@@ -52,21 +75,30 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
52
75
|
(0, util_functions_1.updateLintConfig)(tree, schema);
|
|
53
76
|
(0, util_functions_1.addBuildStorybookToCacheableOperations)(tree);
|
|
54
77
|
(0, util_functions_1.addStorybookToNamedInputs)(tree);
|
|
55
|
-
if (
|
|
56
|
-
(0, util_functions_1.
|
|
78
|
+
if (!hasPlugin) {
|
|
79
|
+
(0, util_functions_1.addStorybookToTargetDefaults)(tree);
|
|
57
80
|
}
|
|
58
|
-
|
|
59
|
-
|
|
81
|
+
let devDeps = {};
|
|
82
|
+
if (!hasPlugin || schema.addExplicitTargets) {
|
|
83
|
+
if (schema.uiFramework === '@storybook/angular') {
|
|
84
|
+
(0, util_functions_1.addAngularStorybookTarget)(tree, schema.project, schema.interactionTests);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
(0, util_functions_1.addStorybookTarget)(tree, schema.project, schema.uiFramework, schema.interactionTests);
|
|
88
|
+
}
|
|
89
|
+
if (schema.configureStaticServe) {
|
|
90
|
+
await (0, util_functions_1.addStaticTarget)(tree, schema);
|
|
91
|
+
}
|
|
60
92
|
}
|
|
61
|
-
|
|
62
|
-
|
|
93
|
+
else {
|
|
94
|
+
devDeps['storybook'] = versions_1.storybookVersion;
|
|
63
95
|
}
|
|
64
|
-
// TODO(katerina): Nx
|
|
96
|
+
// TODO(katerina): Nx 19 -> remove Cypress
|
|
65
97
|
if (schema.configureCypress) {
|
|
66
|
-
const e2eProject = await (0, util_functions_1.getE2EProjectName)(tree, schema.
|
|
98
|
+
const e2eProject = await (0, util_functions_1.getE2EProjectName)(tree, schema.project);
|
|
67
99
|
if (!e2eProject) {
|
|
68
100
|
const cypressTask = await (0, cypress_project_1.cypressProjectGenerator)(tree, {
|
|
69
|
-
name: schema.
|
|
101
|
+
name: schema.project,
|
|
70
102
|
js: schema.js,
|
|
71
103
|
linter: schema.linter,
|
|
72
104
|
directory: schema.cypressDirectory,
|
|
@@ -79,13 +111,15 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
79
111
|
tasks.push(cypressTask);
|
|
80
112
|
}
|
|
81
113
|
else {
|
|
82
|
-
devkit_1.logger.warn(`There is already an e2e project setup for ${schema.
|
|
114
|
+
devkit_1.logger.warn(`There is already an e2e project setup for ${schema.project}, called ${e2eProject}.`);
|
|
83
115
|
}
|
|
84
116
|
}
|
|
85
|
-
let devDeps = {};
|
|
86
117
|
if (schema.tsConfiguration) {
|
|
87
118
|
devDeps['ts-node'] = versions_1.tsNodeVersion;
|
|
88
119
|
}
|
|
120
|
+
if (usesVite && !viteConfigFilePath) {
|
|
121
|
+
devDeps['tslib'] = versions_1.tsLibVersion;
|
|
122
|
+
}
|
|
89
123
|
if (schema.interactionTests) {
|
|
90
124
|
devDeps = {
|
|
91
125
|
...devDeps,
|
|
@@ -99,8 +133,7 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
99
133
|
schema.uiFramework === '@storybook/react-webpack5') {
|
|
100
134
|
devDeps['core-js'] = versions_1.coreJsVersion;
|
|
101
135
|
}
|
|
102
|
-
if (schema.uiFramework
|
|
103
|
-
(!viteBuildTarget || !viteConfigFilePath)) {
|
|
136
|
+
if (schema.uiFramework?.endsWith('-vite') && !viteConfigFilePath) {
|
|
104
137
|
// This means that the user has selected a Vite framework
|
|
105
138
|
// but the project does not have Vite configuration.
|
|
106
139
|
// We need to install the @nx/vite plugin in order to be able to use
|
|
@@ -113,13 +146,17 @@ async function configurationGenerator(tree, rawSchema) {
|
|
|
113
146
|
}
|
|
114
147
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
115
148
|
}
|
|
116
|
-
exports.
|
|
117
|
-
function normalizeSchema(schema) {
|
|
149
|
+
exports.configurationGeneratorInternal = configurationGeneratorInternal;
|
|
150
|
+
function normalizeSchema(tree, schema) {
|
|
151
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
152
|
+
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
153
|
+
nxJson.useInferencePlugins !== false;
|
|
118
154
|
const defaults = {
|
|
119
155
|
interactionTests: true,
|
|
120
156
|
linter: eslint_1.Linter.EsLint,
|
|
121
157
|
js: false,
|
|
122
158
|
tsConfiguration: true,
|
|
159
|
+
addPlugin,
|
|
123
160
|
};
|
|
124
161
|
return {
|
|
125
162
|
...defaults,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* This is a temporary fix for Storybook to support TypeScript configuration files.
|
|
4
|
+
* The issue is that if there is a root tsconfig.json file, Storybook will use it, and
|
|
5
|
+
* ignore the tsconfig.json file in the .storybook folder. This results in module being set
|
|
6
|
+
* to esnext, and Storybook does not recognise the main.ts code as a module.
|
|
7
|
+
*/
|
|
8
|
+
export declare function editRootTsConfig(tree: Tree): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.editRootTsConfig = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
/**
|
|
6
|
+
* This is a temporary fix for Storybook to support TypeScript configuration files.
|
|
7
|
+
* The issue is that if there is a root tsconfig.json file, Storybook will use it, and
|
|
8
|
+
* ignore the tsconfig.json file in the .storybook folder. This results in module being set
|
|
9
|
+
* to esnext, and Storybook does not recognise the main.ts code as a module.
|
|
10
|
+
*/
|
|
11
|
+
function editRootTsConfig(tree) {
|
|
12
|
+
if (!tree.exists('tsconfig.json')) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
(0, devkit_1.updateJson)(tree, 'tsconfig.json', (json) => {
|
|
16
|
+
if (json['ts-node']) {
|
|
17
|
+
json['ts-node'] = {
|
|
18
|
+
...json['ts-node'],
|
|
19
|
+
compilerOptions: {
|
|
20
|
+
...(json['ts-node'].compilerOptions ?? {}),
|
|
21
|
+
module: 'commonjs',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
json['ts-node'] = {
|
|
27
|
+
compilerOptions: {
|
|
28
|
+
module: 'commonjs',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return json;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.editRootTsConfig = editRootTsConfig;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import type { StorybookConfigureSchema } from '../schema';
|
|
3
|
+
export type EnsureDependenciesOptions = {
|
|
4
|
+
uiFramework?: StorybookConfigureSchema['uiFramework'];
|
|
5
|
+
};
|
|
6
|
+
export declare function ensureDependencies(tree: Tree, options: EnsureDependenciesOptions): import("@nx/devkit").GeneratorCallback;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureDependencies = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
const utilities_1 = require("../../../utils/utilities");
|
|
7
|
+
const versions_1 = require("../../../utils/versions");
|
|
8
|
+
function ensureDependencies(tree, options) {
|
|
9
|
+
let storybook7VersionToInstall = versions_1.storybookVersion;
|
|
10
|
+
if ((0, utilities_1.storybookMajorVersion)() >= 7 &&
|
|
11
|
+
(0, utilities_1.getInstalledStorybookVersion)() &&
|
|
12
|
+
(0, semver_1.gte)((0, utilities_1.getInstalledStorybookVersion)(), '7.0.0')) {
|
|
13
|
+
storybook7VersionToInstall = (0, utilities_1.getInstalledStorybookVersion)();
|
|
14
|
+
}
|
|
15
|
+
const dependencies = {};
|
|
16
|
+
const devDependencies = {
|
|
17
|
+
'@storybook/core-server': storybook7VersionToInstall,
|
|
18
|
+
'@storybook/addon-essentials': storybook7VersionToInstall,
|
|
19
|
+
};
|
|
20
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
21
|
+
packageJson.dependencies ??= {};
|
|
22
|
+
packageJson.devDependencies ??= {};
|
|
23
|
+
// Needed for Storybook 7
|
|
24
|
+
// https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#react-peer-dependencies-required
|
|
25
|
+
if (!packageJson.dependencies['react'] &&
|
|
26
|
+
!packageJson.devDependencies['react']) {
|
|
27
|
+
dependencies['react'] = versions_1.reactVersion;
|
|
28
|
+
}
|
|
29
|
+
if (!packageJson.dependencies['react-dom'] &&
|
|
30
|
+
!packageJson.devDependencies['react-dom']) {
|
|
31
|
+
dependencies['react-dom'] = versions_1.reactVersion;
|
|
32
|
+
}
|
|
33
|
+
if (options.uiFramework) {
|
|
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;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (options.uiFramework === '@storybook/vue3-vite') {
|
|
46
|
+
if (!packageJson.dependencies['@storybook/vue3'] &&
|
|
47
|
+
!packageJson.devDependencies['@storybook/vue3']) {
|
|
48
|
+
devDependencies['@storybook/vue3'] = storybook7VersionToInstall;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (options.uiFramework === '@storybook/angular') {
|
|
52
|
+
if (!packageJson.dependencies['@angular/forms'] &&
|
|
53
|
+
!packageJson.devDependencies['@angular/forms']) {
|
|
54
|
+
devDependencies['@angular/forms'] = '*';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (options.uiFramework === '@storybook/web-components-vite' ||
|
|
58
|
+
options.uiFramework === '@storybook/web-components-webpack5') {
|
|
59
|
+
devDependencies['lit'] = versions_1.litVersion;
|
|
60
|
+
}
|
|
61
|
+
if (options.uiFramework.endsWith('-vite')) {
|
|
62
|
+
if (!packageJson.dependencies['vite'] &&
|
|
63
|
+
!packageJson.devDependencies['vite']) {
|
|
64
|
+
devDependencies['vite'] = versions_1.viteVersion;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, dependencies, devDependencies);
|
|
69
|
+
}
|
|
70
|
+
exports.ensureDependencies = ensureDependencies;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { StorybookConfigureSchema } from '../schema';
|
|
3
3
|
import { UiFramework } from '../../../utils/models';
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function addStaticTarget(tree: Tree, opts: StorybookConfigureSchema): void
|
|
4
|
+
export declare function addStorybookTarget(tree: Tree, projectName: string, uiFramework: UiFramework, interactionTests: boolean): void;
|
|
5
|
+
export declare function addAngularStorybookTarget(tree: Tree, projectName: string, interactionTests: boolean): void;
|
|
6
|
+
export declare function addStaticTarget(tree: Tree, opts: StorybookConfigureSchema): Promise<void>;
|
|
7
7
|
export declare function createStorybookTsconfigFile(tree: Tree, projectRoot: string, uiFramework: UiFramework, isRootProject: boolean, mainDir: 'components' | 'src'): void;
|
|
8
8
|
export declare function editTsconfigBaseJson(tree: Tree): void;
|
|
9
9
|
export declare function configureTsProjectConfig(tree: Tree, schema: StorybookConfigureSchema): void;
|
|
@@ -18,12 +18,18 @@ 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
|
|
21
|
+
export declare function addStorybookToTargetDefaults(tree: Tree, setCache?: boolean): 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;
|
|
22
23
|
export declare function getTsConfigPath(tree: Tree, projectName: string, path?: string): string;
|
|
23
24
|
export declare function addBuildStorybookToCacheableOperations(tree: Tree): void;
|
|
24
25
|
export declare function projectIsRootProjectInStandaloneWorkspace(projectRoot: string): boolean;
|
|
25
26
|
export declare function workspaceHasRootProject(tree: Tree): boolean;
|
|
26
27
|
export declare function rootFileIsTs(tree: Tree, rootFileName: string, tsConfiguration: boolean): boolean;
|
|
27
28
|
export declare function getE2EProjectName(tree: Tree, mainProject: string): Promise<string | undefined>;
|
|
28
|
-
export declare function
|
|
29
|
+
export declare function findViteConfig(tree: Tree, projectRoot: string): {
|
|
30
|
+
fullConfigPath: string | undefined;
|
|
31
|
+
viteConfigFileName: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
export declare function findNextConfig(tree: Tree, projectRoot: string): string | undefined;
|
|
34
|
+
export declare function findMetroConfig(tree: Tree, projectRoot: string): string | undefined;
|
|
29
35
|
export declare function renameAndMoveOldTsConfig(projectRoot: string, pathToStorybookConfigFile: string, tree: Tree): void;
|