@nx/storybook 19.0.1 → 19.0.3
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 -1
- package/package.json +6 -6
- package/presets/cypress.d.ts +2 -1
- package/presets/cypress.js +2 -2
- package/src/generators/configuration/schema.d.ts +2 -2
- package/src/generators/configuration/schema.json +2 -2
- package/src/generators/cypress-project/cypress-project.js +46 -14
- package/src/generators/cypress-project/files/inferred-target/cypress.config.ts__tpl__ +13 -0
- package/src/generators/cypress-project/schema.json +1 -0
- package/src/generators/init/init.js +1 -1
- /package/src/generators/cypress-project/files/{cypress.config.ts__tpl__ → explicit-target/cypress.config.ts__tpl__} +0 -0
package/generators.json
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"cypress-project": {
|
|
19
19
|
"factory": "./src/generators/cypress-project/cypress-project",
|
|
20
20
|
"schema": "./src/generators/cypress-project/schema.json",
|
|
21
|
-
"description": "Add cypress
|
|
21
|
+
"description": "Add cypress E2E app to test a ui library that is set up for Storybook.",
|
|
22
|
+
"x-deprecated": "Deprecated: Use 'interactionTests' instead when running '@nx/storybook:configuration'. This generator will be removed in v21.",
|
|
22
23
|
"hidden": false
|
|
23
24
|
},
|
|
24
25
|
"migrate-7": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.3",
|
|
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": "19.0.
|
|
33
|
+
"@nx/devkit": "19.0.3",
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
35
|
"semver": "^7.5.3",
|
|
36
36
|
"tslib": "^2.3.0",
|
|
37
|
-
"@nx/cypress": "19.0.
|
|
38
|
-
"@nx/js": "19.0.
|
|
39
|
-
"@nx/eslint": "19.0.
|
|
40
|
-
"@nrwl/storybook": "19.0.
|
|
37
|
+
"@nx/cypress": "19.0.3",
|
|
38
|
+
"@nx/js": "19.0.3",
|
|
39
|
+
"@nx/eslint": "19.0.3",
|
|
40
|
+
"@nrwl/storybook": "19.0.3"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
package/presets/cypress.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { NxCypressE2EPresetOptions } from '@nx/cypress/plugins/cypress-preset';
|
|
2
|
+
export declare function nxE2EStorybookPreset(filePath: string, options?: NxCypressE2EPresetOptions): any;
|
package/presets/cypress.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
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
|
-
function nxE2EStorybookPreset(filePath) {
|
|
5
|
+
function nxE2EStorybookPreset(filePath, options) {
|
|
6
6
|
return {
|
|
7
|
-
...(0, cypress_preset_1.nxE2EPreset)(filePath),
|
|
7
|
+
...(0, cypress_preset_1.nxE2EPreset)(filePath, options),
|
|
8
8
|
baseUrl: 'http://localhost:4400',
|
|
9
9
|
};
|
|
10
10
|
}
|
|
@@ -12,11 +12,11 @@ export interface StorybookConfigureSchema {
|
|
|
12
12
|
configureStaticServe?: boolean;
|
|
13
13
|
skipFormat?: boolean;
|
|
14
14
|
/**
|
|
15
|
-
* @deprecated Use interactionTests instead. This option will be removed in
|
|
15
|
+
* @deprecated Use interactionTests instead. This option will be removed in v20.
|
|
16
16
|
*/
|
|
17
17
|
configureCypress?: boolean;
|
|
18
18
|
/**
|
|
19
|
-
* @deprecated Use interactionTests instead. This option will be removed in
|
|
19
|
+
* @deprecated Use interactionTests instead. This option will be removed in v20.
|
|
20
20
|
*/
|
|
21
21
|
cypressDirectory?: string;
|
|
22
22
|
addPlugin?: boolean;
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"configureCypress": {
|
|
29
29
|
"type": "boolean",
|
|
30
30
|
"description": "Run the cypress-configure generator.",
|
|
31
|
-
"x-deprecated": "Use interactionTests instead. This option will be removed in
|
|
31
|
+
"x-deprecated": "Use interactionTests instead. This option will be removed in v20."
|
|
32
32
|
},
|
|
33
33
|
"cypressDirectory": {
|
|
34
34
|
"type": "string",
|
|
35
35
|
"description": "A directory where the Cypress project will be placed. Added at root by default.",
|
|
36
|
-
"x-deprecated": "Use interactionTests instead. This option will be removed in
|
|
36
|
+
"x-deprecated": "Use interactionTests instead. This option will be removed in v20."
|
|
37
37
|
},
|
|
38
38
|
"linter": {
|
|
39
39
|
"description": "The tool to use for running lint checks.",
|
|
@@ -15,6 +15,7 @@ async function cypressProjectGenerator(tree, schema) {
|
|
|
15
15
|
}
|
|
16
16
|
exports.cypressProjectGenerator = cypressProjectGenerator;
|
|
17
17
|
async function cypressProjectGeneratorInternal(tree, schema) {
|
|
18
|
+
devkit_1.logger.warn(`Use 'interactionTests' instead when running '@nx/storybook:configuration'. This generator will be removed in v21.`);
|
|
18
19
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
19
20
|
const e2eName = schema.name ? `${schema.name}-e2e` : undefined;
|
|
20
21
|
const { projectName, projectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
@@ -37,28 +38,42 @@ async function cypressProjectGeneratorInternal(tree, schema) {
|
|
|
37
38
|
project: projectName,
|
|
38
39
|
js: schema.js,
|
|
39
40
|
linter: schema.linter,
|
|
40
|
-
directory: projectRoot,
|
|
41
41
|
devServerTarget: `${schema.name}:storybook`,
|
|
42
42
|
skipFormat: true,
|
|
43
43
|
});
|
|
44
44
|
const generatedCypressProjectName = (0, project_name_1.getE2eProjectName)(schema.name, libRoot, schema.directory);
|
|
45
45
|
removeUnneededFiles(tree, generatedCypressProjectName, schema.js);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, generatedCypressProjectName);
|
|
47
|
+
if (project.targets.e2e && project.targets.e2e.options) {
|
|
48
|
+
addBaseUrlToCypressConfig(tree, generatedCypressProjectName, project.root);
|
|
49
|
+
updateAngularJsonBuilder(tree, {
|
|
50
|
+
e2eProjectName: generatedCypressProjectName,
|
|
51
|
+
targetProjectName: schema.name,
|
|
52
|
+
ciTargetName: schema.ciTargetName,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else if (hasCypressPlugin(tree)) {
|
|
56
|
+
generateCypressConfigForInferredPlugin(tree, generatedCypressProjectName, project.root, schema.name, schema.ciTargetName);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
throw new Error(`Unable to generate Cypress Project for Storybook project. Please report this issue at https://github.com/nrwl/nx/issues/new/choose`);
|
|
60
|
+
}
|
|
52
61
|
if (!schema.skipFormat) {
|
|
53
62
|
await (0, devkit_1.formatFiles)(tree);
|
|
54
63
|
}
|
|
55
64
|
return cypressTask;
|
|
56
65
|
}
|
|
57
66
|
exports.cypressProjectGeneratorInternal = cypressProjectGeneratorInternal;
|
|
67
|
+
function hasCypressPlugin(tree) {
|
|
68
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
69
|
+
return nxJson.plugins?.some((p) => typeof p === 'string'
|
|
70
|
+
? p === '@nx/cypress/plugin'
|
|
71
|
+
: p.plugin === '@nx/cypress/plugin');
|
|
72
|
+
}
|
|
58
73
|
function removeUnneededFiles(tree, projectName, js) {
|
|
59
74
|
const { sourceRoot, root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
60
75
|
const fileType = js ? 'js' : 'ts';
|
|
61
|
-
if (tree.exists((0,
|
|
76
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(root, 'cypress.config.ts'))) {
|
|
62
77
|
(0, utilities_1.safeFileDelete)(tree, `${sourceRoot}/e2e/app.cy.${fileType}`);
|
|
63
78
|
(0, utilities_1.safeFileDelete)(tree, `${sourceRoot}/support/app.po.${fileType}`);
|
|
64
79
|
}
|
|
@@ -67,10 +82,27 @@ function removeUnneededFiles(tree, projectName, js) {
|
|
|
67
82
|
(0, utilities_1.safeFileDelete)(tree, `${sourceRoot}/support/app.po.${fileType}`);
|
|
68
83
|
}
|
|
69
84
|
}
|
|
70
|
-
function
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
85
|
+
function generateCypressConfigForInferredPlugin(tree, projectName, projectRoot, targetProjectName, ciTargetName) {
|
|
86
|
+
const cypressJson = (0, devkit_1.joinPathFragments)(projectRoot, 'cypress.json');
|
|
87
|
+
const cypressTs = (0, devkit_1.joinPathFragments)(projectRoot, 'cypress.config.ts');
|
|
88
|
+
if (tree.exists(cypressJson)) {
|
|
89
|
+
tree.delete(cypressJson);
|
|
90
|
+
}
|
|
91
|
+
if (tree.exists(cypressTs)) {
|
|
92
|
+
// cypress >= v10
|
|
93
|
+
tree.delete(cypressTs);
|
|
94
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'inferred-target'), projectRoot, {
|
|
95
|
+
defaultWebServerCommand: `npx nx run ${targetProjectName}:storybook`,
|
|
96
|
+
ciWebServerCommand: ciTargetName
|
|
97
|
+
? `npx nx run ${targetProjectName}:${ciTargetName}:ci`
|
|
98
|
+
: `npx nx run ${targetProjectName}:storybook:ci`,
|
|
99
|
+
tpl: '',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function addBaseUrlToCypressConfig(tree, projectName, projectRoot) {
|
|
104
|
+
const cypressJson = (0, devkit_1.joinPathFragments)(projectRoot, 'cypress.json');
|
|
105
|
+
const cypressTs = (0, devkit_1.joinPathFragments)(projectRoot, 'cypress.config.ts');
|
|
74
106
|
// TODO(caleb): remove this when cypress < v10 is deprecated
|
|
75
107
|
if (tree.exists(cypressJson)) {
|
|
76
108
|
// cypress < v10
|
|
@@ -82,14 +114,14 @@ function addBaseUrlToCypressConfig(tree, projectName) {
|
|
|
82
114
|
else if (tree.exists(cypressTs)) {
|
|
83
115
|
// cypress >= v10
|
|
84
116
|
tree.delete(cypressTs);
|
|
85
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), projectRoot, {
|
|
117
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'explicit-target'), projectRoot, {
|
|
86
118
|
tpl: '',
|
|
87
119
|
});
|
|
88
120
|
}
|
|
89
121
|
}
|
|
90
122
|
function updateAngularJsonBuilder(tree, opts) {
|
|
91
123
|
const project = (0, devkit_1.readProjectConfiguration)(tree, opts.e2eProjectName);
|
|
92
|
-
const e2eTarget = project.targets.e2e;
|
|
124
|
+
const e2eTarget = project.targets.e2e ?? {};
|
|
93
125
|
project.targets.e2e = {
|
|
94
126
|
...e2eTarget,
|
|
95
127
|
options: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from 'cypress';
|
|
2
|
+
import { nxE2EStorybookPreset } from '@nx/storybook/presets/cypress';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
e2e: nxE2EStorybookPreset(__dirname, {
|
|
6
|
+
cypressDir: 'src',
|
|
7
|
+
webServerCommands: {
|
|
8
|
+
default: "<%= defaultWebServerCommand %>",
|
|
9
|
+
ci: "<%= ciWebServerCommand %>"
|
|
10
|
+
},
|
|
11
|
+
ciWebServerCommand: "<%= ciWebServerCommand %>"
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"$id": "cypress-configure",
|
|
5
5
|
"title": "Cypress Configuration",
|
|
6
6
|
"description": "Add cypress E2E app to test a ui library that is set up for Storybook.",
|
|
7
|
+
"x-deprecated": "Use 'interactionTests' instead when running '@nx/storybook:configuration'. This generator will be removed in v21.",
|
|
7
8
|
"type": "object",
|
|
8
9
|
"properties": {
|
|
9
10
|
"name": {
|
|
@@ -60,7 +60,7 @@ async function initGeneratorInternal(tree, schema) {
|
|
|
60
60
|
nxJson.useInferencePlugins !== false;
|
|
61
61
|
schema.addPlugin ??= addPluginDefault;
|
|
62
62
|
if (schema.addPlugin) {
|
|
63
|
-
await (0, add_plugin_1.addPlugin)(tree,
|
|
63
|
+
await (0, add_plugin_1.addPlugin)(tree, '@nx/storybook/plugin', plugin_1.createNodes, {
|
|
64
64
|
serveStorybookTargetName: [
|
|
65
65
|
'storybook',
|
|
66
66
|
'serve:storybook',
|
|
File without changes
|