@nx/storybook 16.8.0-beta.4 → 16.8.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/presets/cypress.js +4 -1
- package/src/executors/build-storybook/build-storybook.impl.js +38 -32
- package/src/executors/storybook/storybook.impl.js +41 -35
- package/src/executors/utils.js +6 -4
- package/src/generators/configuration/configuration.js +101 -99
- package/src/generators/configuration/lib/interaction-testing.utils.js +4 -6
- package/src/generators/configuration/lib/util-functions.js +62 -56
- package/src/generators/cypress-project/cypress-project.js +44 -41
- package/src/generators/init/init.js +20 -17
- package/src/generators/migrate-7/helper-functions.js +53 -56
- package/src/generators/migrate-7/migrate-7.js +51 -54
- package/src/migrations/update-13-4-6/set-project-build-config.js +37 -41
- package/src/migrations/update-14-0-0/migrate-defaults-5-to-6/migrate-defaults-5-to-6.js +7 -10
- package/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.js +184 -161
- package/src/migrations/update-14-0-0/migrate-to-storybook-6.js +3 -6
- package/src/migrations/update-14-1-8/change-storybook-targets-generator.js +39 -39
- package/src/migrations/update-14-1-8/change-storybook-targets.js +2 -5
- package/src/migrations/update-15-0-0/add-storybook-inputs.js +24 -29
- package/src/migrations/update-15-4-6/refactor-executor-options.js +13 -14
- package/src/migrations/update-15-5-3/ensure-webpack-package.js +19 -22
- package/src/migrations/update-15-7-0/add-addon-essentials-to-all.js +48 -54
- package/src/migrations/update-15-7-0/remove-root-config.js +10 -14
- package/src/migrations/update-16-0-0/update-sb-7.js +22 -25
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-1-0/eslint-ignore-react-plugin.js +31 -35
- package/src/migrations/update-16-5-0/move-storybook-tsconfig.js +11 -14
- package/src/utils/testing.js +8 -11
- package/src/utils/utilities.js +6 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "16.8.0-beta.
|
|
3
|
+
"version": "16.8.0-beta.5",
|
|
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.8.0-beta.
|
|
34
|
-
"@nx/cypress": "16.8.0-beta.
|
|
35
|
-
"@nx/devkit": "16.8.0-beta.
|
|
36
|
-
"@nx/js": "16.8.0-beta.
|
|
37
|
-
"@nx/linter": "16.8.0-beta.
|
|
38
|
-
"@nx/workspace": "16.8.0-beta.
|
|
33
|
+
"@nrwl/storybook": "16.8.0-beta.5",
|
|
34
|
+
"@nx/cypress": "16.8.0-beta.5",
|
|
35
|
+
"@nx/devkit": "16.8.0-beta.5",
|
|
36
|
+
"@nx/js": "16.8.0-beta.5",
|
|
37
|
+
"@nx/linter": "16.8.0-beta.5",
|
|
38
|
+
"@nx/workspace": "16.8.0-beta.5",
|
|
39
39
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
40
40
|
"semver": "7.5.3",
|
|
41
41
|
"tslib": "^2.3.0"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"type": "commonjs",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "ad2d1e8a55b2d1b358bb5e7483343d9757ff2c53"
|
|
48
48
|
}
|
package/presets/cypress.js
CHANGED
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.nxE2EStorybookPreset = void 0;
|
|
4
4
|
const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
|
|
5
5
|
function nxE2EStorybookPreset(filePath) {
|
|
6
|
-
return
|
|
6
|
+
return {
|
|
7
|
+
...(0, cypress_preset_1.nxE2EPreset)(filePath),
|
|
8
|
+
baseUrl: 'http://localhost:4400',
|
|
9
|
+
};
|
|
7
10
|
}
|
|
8
11
|
exports.nxE2EStorybookPreset = nxE2EStorybookPreset;
|
|
@@ -1,45 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const build = require("@storybook/core-server");
|
|
6
5
|
const utilities_1 = require("../../utils/utilities");
|
|
7
6
|
const utils_1 = require("../utils");
|
|
8
|
-
function buildStorybookExecutor(options, context) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
7
|
+
async function buildStorybookExecutor(options, context) {
|
|
8
|
+
(0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
|
|
9
|
+
const storybook7 = (0, utilities_1.storybookMajorVersion)() === 7;
|
|
10
|
+
if (storybook7) {
|
|
11
|
+
const buildOptions = options;
|
|
12
|
+
devkit_1.logger.info(`NX Storybook builder starting ...`);
|
|
13
|
+
await runInstance(buildOptions, storybook7);
|
|
14
|
+
devkit_1.logger.info(`NX Storybook builder finished ...`);
|
|
15
|
+
devkit_1.logger.info(`NX Storybook files available in ${buildOptions.outputDir}`);
|
|
16
|
+
return { success: true };
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
// TODO(katerina): Remove Nx17
|
|
20
|
+
// print warnings
|
|
21
|
+
(0, utils_1.runStorybookSetupCheck)(options);
|
|
22
|
+
devkit_1.logger.error((0, utilities_1.pleaseUpgrade)());
|
|
23
|
+
const frameworkPath = (0, utils_1.getStorybookFrameworkPath)(options.uiFramework);
|
|
24
|
+
const { default: frameworkOptions } = await Promise.resolve(`${frameworkPath}`).then(s => require(s));
|
|
25
|
+
const buildOptions = {
|
|
26
|
+
...options,
|
|
27
|
+
...frameworkOptions,
|
|
28
|
+
frameworkPresets: [...(frameworkOptions.frameworkPresets || [])],
|
|
29
|
+
};
|
|
30
|
+
devkit_1.logger.info(`NX Storybook builder starting ...`);
|
|
31
|
+
await runInstance(buildOptions, storybook7);
|
|
32
|
+
devkit_1.logger.info(`NX Storybook builder finished ...`);
|
|
33
|
+
devkit_1.logger.info(`NX Storybook files available in ${buildOptions.outputDir}`);
|
|
34
|
+
return { success: true };
|
|
35
|
+
}
|
|
35
36
|
}
|
|
36
37
|
exports.default = buildStorybookExecutor;
|
|
37
38
|
function runInstance(options, storybook7) {
|
|
38
|
-
|
|
39
|
-
const env = (_a = process.env.NODE_ENV) !== null && _a !== void 0 ? _a : 'production';
|
|
39
|
+
const env = process.env.NODE_ENV ?? 'production';
|
|
40
40
|
process.env.NODE_ENV = env;
|
|
41
41
|
if (storybook7) {
|
|
42
|
-
return build.build(
|
|
42
|
+
return build.build({
|
|
43
|
+
...options,
|
|
44
|
+
mode: 'static',
|
|
45
|
+
});
|
|
43
46
|
}
|
|
44
47
|
else {
|
|
45
48
|
// TODO(katerina): Remove Nx17
|
|
@@ -50,6 +53,9 @@ function runInstance(options, storybook7) {
|
|
|
50
53
|
Please use Node 16 if you are using @storybook/builder-vite.
|
|
51
54
|
`);
|
|
52
55
|
}
|
|
53
|
-
return build.buildStaticStandalone(
|
|
56
|
+
return build.buildStaticStandalone({
|
|
57
|
+
...options,
|
|
58
|
+
ci: true,
|
|
59
|
+
});
|
|
54
60
|
}
|
|
55
61
|
}
|
|
@@ -1,51 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const build = require("@storybook/core-server");
|
|
6
5
|
const utilities_1 = require("../../utils/utilities");
|
|
7
6
|
const utils_1 = require("../utils");
|
|
8
|
-
function storybookExecutor(options, context) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
7
|
+
async function* storybookExecutor(options, context) {
|
|
8
|
+
const storybook7 = (0, utilities_1.storybookMajorVersion)() === 7;
|
|
9
|
+
(0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
|
|
10
|
+
if (storybook7) {
|
|
11
|
+
const buildOptions = options;
|
|
12
|
+
const result = await runInstance(buildOptions, storybook7);
|
|
13
|
+
yield {
|
|
14
|
+
success: true,
|
|
15
|
+
info: {
|
|
16
|
+
port: result?.['port'],
|
|
17
|
+
baseUrl: `${options.https ? 'https' : 'http'}://${options.host ?? 'localhost'}:${result?.['port']}`,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
await new Promise(() => { });
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// TODO(katerina): Remove Nx17
|
|
24
|
+
// print warnings
|
|
25
|
+
(0, utils_1.runStorybookSetupCheck)(options);
|
|
26
|
+
devkit_1.logger.error((0, utilities_1.pleaseUpgrade)());
|
|
27
|
+
let frameworkPath = (0, utils_1.getStorybookFrameworkPath)(options.uiFramework);
|
|
28
|
+
const frameworkOptions = (await Promise.resolve(`${frameworkPath}`).then(s => require(s))).default;
|
|
29
|
+
const buildOptions = {
|
|
30
|
+
...options,
|
|
31
|
+
...frameworkOptions,
|
|
32
|
+
frameworkPresets: [...(frameworkOptions.frameworkPresets || [])],
|
|
33
|
+
};
|
|
34
|
+
await runInstance(buildOptions, storybook7);
|
|
35
|
+
yield { success: true };
|
|
36
|
+
await new Promise(() => { });
|
|
37
|
+
}
|
|
38
38
|
}
|
|
39
39
|
exports.default = storybookExecutor;
|
|
40
40
|
function runInstance(options, storybook7) {
|
|
41
|
-
|
|
42
|
-
const env = (_a = process.env.NODE_ENV) !== null && _a !== void 0 ? _a : 'development';
|
|
41
|
+
const env = process.env.NODE_ENV ?? 'development';
|
|
43
42
|
process.env.NODE_ENV = env;
|
|
44
43
|
if (storybook7) {
|
|
45
|
-
return build.build(
|
|
44
|
+
return build.build({
|
|
45
|
+
...options,
|
|
46
|
+
mode: 'dev',
|
|
47
|
+
});
|
|
46
48
|
}
|
|
47
49
|
else {
|
|
48
50
|
// TODO(katerina): Remove Nx17
|
|
49
|
-
return build['buildDev'](
|
|
51
|
+
return build['buildDev']({
|
|
52
|
+
...options,
|
|
53
|
+
configType: env.toUpperCase(),
|
|
54
|
+
mode: 'dev',
|
|
55
|
+
});
|
|
50
56
|
}
|
|
51
57
|
}
|
package/src/executors/utils.js
CHANGED
|
@@ -94,7 +94,10 @@ function webpackFinalPropertyCheck(options) {
|
|
|
94
94
|
];
|
|
95
95
|
placesToCheck = placesToCheck
|
|
96
96
|
.map((entry) => {
|
|
97
|
-
return
|
|
97
|
+
return {
|
|
98
|
+
...entry,
|
|
99
|
+
result: (0, fs_1.existsSync)(entry.path),
|
|
100
|
+
};
|
|
98
101
|
})
|
|
99
102
|
.filter((x) => x.result === true);
|
|
100
103
|
if (placesToCheck.length > 0) {
|
|
@@ -115,11 +118,10 @@ function builderIsWebpackButNotWebpack5(storybookConfig) {
|
|
|
115
118
|
]);
|
|
116
119
|
let builderIsWebpackNot5 = false;
|
|
117
120
|
importArray.forEach((parent) => {
|
|
118
|
-
var _a, _b, _c;
|
|
119
121
|
const identifier = (0, js_1.findNodes)(parent, ts.SyntaxKind.Identifier);
|
|
120
122
|
const sbBuilder = (0, js_1.findNodes)(parent, ts.SyntaxKind.StringLiteral);
|
|
121
|
-
const builderText =
|
|
122
|
-
if (
|
|
123
|
+
const builderText = sbBuilder?.[0]?.getText() ?? '';
|
|
124
|
+
if (identifier?.[0]?.getText() === 'builder' &&
|
|
123
125
|
builderText.includes('webpack') &&
|
|
124
126
|
!builderText.includes('webpack5')) {
|
|
125
127
|
builderIsWebpackNot5 = true;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configurationSchematic = exports.configurationGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const cypress_project_1 = require("../cypress-project/cypress-project");
|
|
7
6
|
const init_1 = require("../init/init");
|
|
@@ -10,109 +9,109 @@ const linter_1 = require("@nx/linter");
|
|
|
10
9
|
const utilities_1 = require("../../utils/utilities");
|
|
11
10
|
const versions_1 = require("../../utils/versions");
|
|
12
11
|
const interaction_testing_utils_1 = require("./lib/interaction-testing.utils");
|
|
13
|
-
function configurationGenerator(tree, rawSchema) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (schema.uiFramework === '@storybook/react-webpack5') {
|
|
29
|
-
devkit_1.logger.info(`Your project ${schema.name} uses Vite as a bundler.
|
|
12
|
+
async function configurationGenerator(tree, rawSchema) {
|
|
13
|
+
if ((0, utilities_1.storybookMajorVersion)() === 6) {
|
|
14
|
+
throw new Error((0, utilities_1.pleaseUpgrade)());
|
|
15
|
+
}
|
|
16
|
+
const schema = normalizeSchema(rawSchema);
|
|
17
|
+
const tasks = [];
|
|
18
|
+
const { projectType, targets, root } = (0, devkit_1.readProjectConfiguration)(tree, schema.name);
|
|
19
|
+
const { nextBuildTarget, compiler, viteBuildTarget } = (0, utilities_1.findStorybookAndBuildTargetsAndCompiler)(targets);
|
|
20
|
+
let viteConfigFilePath;
|
|
21
|
+
if (viteBuildTarget) {
|
|
22
|
+
viteConfigFilePath = (0, util_functions_1.getViteConfigFilePath)(tree, root, targets[viteBuildTarget]?.options?.configFile);
|
|
23
|
+
}
|
|
24
|
+
if (viteBuildTarget) {
|
|
25
|
+
if (schema.uiFramework === '@storybook/react-webpack5') {
|
|
26
|
+
devkit_1.logger.info(`Your project ${schema.name} uses Vite as a bundler.
|
|
30
27
|
Nx will configure Storybook for this project to use Vite as well.`);
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
if (schema.uiFramework === '@storybook/web-components-webpack5') {
|
|
34
|
-
devkit_1.logger.info(`Your project ${schema.name} uses Vite as a bundler.
|
|
35
|
-
Nx will configure Storybook for this project to use Vite as well.`);
|
|
36
|
-
schema.uiFramework = '@storybook/web-components-vite';
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (nextBuildTarget) {
|
|
40
|
-
schema.uiFramework = '@storybook/nextjs';
|
|
28
|
+
schema.uiFramework = '@storybook/react-vite';
|
|
41
29
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
tasks.push(initTask);
|
|
47
|
-
const mainDir = !!nextBuildTarget && projectType === 'application' ? 'components' : 'src';
|
|
48
|
-
(0, util_functions_1.createProjectStorybookDir)(tree, schema.name, schema.uiFramework, schema.js, schema.tsConfiguration, root, projectType, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), schema.interactionTests, mainDir, !!nextBuildTarget, compiler === 'swc', !!viteBuildTarget || schema.uiFramework.endsWith('-vite'), viteConfigFilePath);
|
|
49
|
-
if (schema.uiFramework !== '@storybook/angular') {
|
|
50
|
-
(0, util_functions_1.createStorybookTsconfigFile)(tree, root, schema.uiFramework, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), mainDir);
|
|
30
|
+
if (schema.uiFramework === '@storybook/web-components-webpack5') {
|
|
31
|
+
devkit_1.logger.info(`Your project ${schema.name} uses Vite as a bundler.
|
|
32
|
+
Nx will configure Storybook for this project to use Vite as well.`);
|
|
33
|
+
schema.uiFramework = '@storybook/web-components-vite';
|
|
51
34
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
35
|
+
}
|
|
36
|
+
if (nextBuildTarget) {
|
|
37
|
+
schema.uiFramework = '@storybook/nextjs';
|
|
38
|
+
}
|
|
39
|
+
const initTask = await (0, init_1.initGenerator)(tree, {
|
|
40
|
+
uiFramework: schema.uiFramework,
|
|
41
|
+
js: schema.js,
|
|
42
|
+
});
|
|
43
|
+
tasks.push(initTask);
|
|
44
|
+
const mainDir = !!nextBuildTarget && projectType === 'application' ? 'components' : 'src';
|
|
45
|
+
(0, util_functions_1.createProjectStorybookDir)(tree, schema.name, schema.uiFramework, schema.js, schema.tsConfiguration, root, projectType, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), schema.interactionTests, mainDir, !!nextBuildTarget, compiler === 'swc', !!viteBuildTarget || schema.uiFramework.endsWith('-vite'), viteConfigFilePath);
|
|
46
|
+
if (schema.uiFramework !== '@storybook/angular') {
|
|
47
|
+
(0, util_functions_1.createStorybookTsconfigFile)(tree, root, schema.uiFramework, (0, util_functions_1.projectIsRootProjectInStandaloneWorkspace)(root), mainDir);
|
|
48
|
+
}
|
|
49
|
+
(0, util_functions_1.configureTsProjectConfig)(tree, schema);
|
|
50
|
+
(0, util_functions_1.editTsconfigBaseJson)(tree);
|
|
51
|
+
(0, util_functions_1.configureTsSolutionConfig)(tree, schema);
|
|
52
|
+
(0, util_functions_1.updateLintConfig)(tree, schema);
|
|
53
|
+
(0, util_functions_1.addBuildStorybookToCacheableOperations)(tree);
|
|
54
|
+
(0, util_functions_1.addStorybookToNamedInputs)(tree);
|
|
55
|
+
if (schema.uiFramework === '@storybook/angular') {
|
|
56
|
+
(0, util_functions_1.addAngularStorybookTask)(tree, schema.name, schema.interactionTests);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
(0, util_functions_1.addStorybookTask)(tree, schema.name, schema.uiFramework, schema.interactionTests);
|
|
60
|
+
}
|
|
61
|
+
if (schema.configureStaticServe) {
|
|
62
|
+
(0, util_functions_1.addStaticTarget)(tree, schema);
|
|
63
|
+
}
|
|
64
|
+
// TODO(v18): remove Cypress
|
|
65
|
+
if (schema.configureCypress) {
|
|
66
|
+
const e2eProject = await (0, util_functions_1.getE2EProjectName)(tree, schema.name);
|
|
67
|
+
if (!e2eProject) {
|
|
68
|
+
const cypressTask = await (0, cypress_project_1.cypressProjectGenerator)(tree, {
|
|
69
|
+
name: schema.name,
|
|
70
|
+
js: schema.js,
|
|
71
|
+
linter: schema.linter,
|
|
72
|
+
directory: schema.cypressDirectory,
|
|
73
|
+
standaloneConfig: schema.standaloneConfig,
|
|
74
|
+
ciTargetName: schema.configureStaticServe
|
|
75
|
+
? 'static-storybook'
|
|
76
|
+
: undefined,
|
|
77
|
+
skipFormat: true,
|
|
78
|
+
});
|
|
79
|
+
tasks.push(cypressTask);
|
|
60
80
|
}
|
|
61
81
|
else {
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
if (schema.configureStaticServe) {
|
|
65
|
-
(0, util_functions_1.addStaticTarget)(tree, schema);
|
|
66
|
-
}
|
|
67
|
-
// TODO(v18): remove Cypress
|
|
68
|
-
if (schema.configureCypress) {
|
|
69
|
-
const e2eProject = yield (0, util_functions_1.getE2EProjectName)(tree, schema.name);
|
|
70
|
-
if (!e2eProject) {
|
|
71
|
-
const cypressTask = yield (0, cypress_project_1.cypressProjectGenerator)(tree, {
|
|
72
|
-
name: schema.name,
|
|
73
|
-
js: schema.js,
|
|
74
|
-
linter: schema.linter,
|
|
75
|
-
directory: schema.cypressDirectory,
|
|
76
|
-
standaloneConfig: schema.standaloneConfig,
|
|
77
|
-
ciTargetName: schema.configureStaticServe
|
|
78
|
-
? 'static-storybook'
|
|
79
|
-
: undefined,
|
|
80
|
-
skipFormat: true,
|
|
81
|
-
});
|
|
82
|
-
tasks.push(cypressTask);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
devkit_1.logger.warn(`There is already an e2e project setup for ${schema.name}, called ${e2eProject}.`);
|
|
86
|
-
}
|
|
82
|
+
devkit_1.logger.warn(`There is already an e2e project setup for ${schema.name}, called ${e2eProject}.`);
|
|
87
83
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
84
|
+
}
|
|
85
|
+
let devDeps = {};
|
|
86
|
+
if (schema.tsConfiguration) {
|
|
87
|
+
devDeps['ts-node'] = versions_1.tsNodeVersion;
|
|
88
|
+
}
|
|
89
|
+
if (schema.interactionTests) {
|
|
90
|
+
devDeps = {
|
|
91
|
+
...devDeps,
|
|
92
|
+
...(0, interaction_testing_utils_1.interactionTestsDependencies)(),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (schema.configureStaticServe) {
|
|
96
|
+
devDeps['@nx/web'] = versions_1.nxVersion;
|
|
97
|
+
}
|
|
98
|
+
if (projectType !== 'application' &&
|
|
99
|
+
schema.uiFramework === '@storybook/react-webpack5') {
|
|
100
|
+
devDeps['core-js'] = versions_1.coreJsVersion;
|
|
101
|
+
}
|
|
102
|
+
if (schema.uiFramework.endsWith('-vite') &&
|
|
103
|
+
(!viteBuildTarget || !viteConfigFilePath)) {
|
|
104
|
+
// This means that the user has selected a Vite framework
|
|
105
|
+
// but the project does not have Vite configuration.
|
|
106
|
+
// We need to install the @nx/vite plugin in order to be able to use
|
|
107
|
+
// the nxViteTsPaths plugin to register the tsconfig paths in Vite.
|
|
108
|
+
devDeps['@nx/vite'] = versions_1.nxVersion;
|
|
109
|
+
}
|
|
110
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDeps));
|
|
111
|
+
if (!schema.skipFormat) {
|
|
112
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
113
|
+
}
|
|
114
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
116
115
|
}
|
|
117
116
|
exports.configurationGenerator = configurationGenerator;
|
|
118
117
|
function normalizeSchema(schema) {
|
|
@@ -122,7 +121,10 @@ function normalizeSchema(schema) {
|
|
|
122
121
|
js: false,
|
|
123
122
|
tsConfiguration: true,
|
|
124
123
|
};
|
|
125
|
-
return
|
|
124
|
+
return {
|
|
125
|
+
...defaults,
|
|
126
|
+
...schema,
|
|
127
|
+
};
|
|
126
128
|
}
|
|
127
129
|
exports.default = configurationGenerator;
|
|
128
130
|
exports.configurationSchematic = (0, devkit_1.convertNxGenerator)(configurationGenerator);
|
|
@@ -14,7 +14,6 @@ function interactionTestsDependencies() {
|
|
|
14
14
|
}
|
|
15
15
|
exports.interactionTestsDependencies = interactionTestsDependencies;
|
|
16
16
|
function addInteractionsInAddons(tree, projectConfig) {
|
|
17
|
-
var _a, _b, _c;
|
|
18
17
|
const mainJsTsPath = getMainTsJsPath(tree, projectConfig);
|
|
19
18
|
if (!mainJsTsPath)
|
|
20
19
|
return;
|
|
@@ -22,17 +21,17 @@ function addInteractionsInAddons(tree, projectConfig) {
|
|
|
22
21
|
if (!mainJsTs)
|
|
23
22
|
return;
|
|
24
23
|
// Find addons array
|
|
25
|
-
const addonsArray =
|
|
24
|
+
const addonsArray = tsquery_1.tsquery.query(mainJsTs, `PropertyAssignment:has(Identifier:has([name="addons"]))`)?.[0];
|
|
26
25
|
// if there's no addons array don't do anything
|
|
27
26
|
// they may be setting up storybook in another project
|
|
28
27
|
if (!addonsArray)
|
|
29
28
|
return;
|
|
30
29
|
// Check if addons array already has addon-interactions
|
|
31
|
-
const addonsArrayHasAddonInteractions =
|
|
30
|
+
const addonsArrayHasAddonInteractions = tsquery_1.tsquery.query(addonsArray, `StringLiteral:has([text="@storybook/addon-interactions"])`)?.[0];
|
|
32
31
|
if (addonsArrayHasAddonInteractions)
|
|
33
32
|
return;
|
|
34
33
|
// get the array of the addons
|
|
35
|
-
const arrayLiteralExpression =
|
|
34
|
+
const arrayLiteralExpression = tsquery_1.tsquery.query(addonsArray, `ArrayLiteralExpression`)?.[0];
|
|
36
35
|
if (!arrayLiteralExpression)
|
|
37
36
|
return;
|
|
38
37
|
mainJsTs = (0, devkit_1.applyChangesToString)(mainJsTs, [
|
|
@@ -48,10 +47,9 @@ exports.addInteractionsInAddons = addInteractionsInAddons;
|
|
|
48
47
|
function getMainTsJsPath(host, projectConfig) {
|
|
49
48
|
let mainJsTsPath = undefined;
|
|
50
49
|
Object.entries(projectConfig.targets).forEach(([_targetName, targetConfig]) => {
|
|
51
|
-
var _a;
|
|
52
50
|
if (targetConfig.executor === '@nx/storybook:storybook' ||
|
|
53
51
|
targetConfig.executor === '@storybook/angular:start-storybook') {
|
|
54
|
-
const configDir =
|
|
52
|
+
const configDir = targetConfig.options?.configDir;
|
|
55
53
|
if (host.exists(`${configDir}/main.js`)) {
|
|
56
54
|
mainJsTsPath = `${configDir}/main.js`;
|
|
57
55
|
}
|