@nx/cypress 16.8.0-beta.3 → 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 +6 -6
- package/plugins/cypress-preset.js +15 -6
- package/src/executors/cypress/cypress.impl.js +179 -210
- package/src/generators/base-setup/base-setup.js +15 -5
- package/src/generators/component-configuration/component-configuration.js +42 -30
- package/src/generators/configuration/configuration.js +87 -70
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js +75 -78
- package/src/generators/cypress-project/cypress-project.js +76 -63
- package/src/generators/init/init.js +16 -18
- package/src/generators/migrate-to-cypress-11/conversion.util.js +22 -16
- package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.js +38 -35
- package/src/migrations/update-12-8-0/remove-typescript-plugin.js +23 -26
- package/src/migrations/update-14-6-1/update-cypress-configs-presets.js +79 -68
- package/src/migrations/update-14-7-0/update-cypress-version-if-10.js +1 -2
- package/src/migrations/update-15-0-0/add-cypress-inputs.js +24 -29
- package/src/migrations/update-15-0-0/update-cy-mount-usage.js +25 -29
- package/src/migrations/update-15-1-0/cypress-11.js +34 -37
- package/src/migrations/update-15-5-0/update-to-cypress-12.js +3 -5
- 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-2-0/update-cy-tsconfig.js +25 -24
- package/src/migrations/update-16-4-0/tsconfig-sourcemaps.js +52 -49
- package/src/plugins/preprocessor-vite.js +7 -5
- package/src/utils/add-linter.js +78 -81
- package/src/utils/config.js +54 -62
- package/src/utils/ct-helpers.js +6 -8
- package/src/utils/cypress-version.js +1 -1
- package/src/utils/find-target-options.js +37 -43
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cypressProjectSchematic = exports.cypressProjectGeneratorInternal = exports.cypressProjectGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
7
6
|
const semver_1 = require("@nx/devkit/src/utils/semver");
|
|
@@ -18,7 +17,15 @@ function createFiles(tree, options) {
|
|
|
18
17
|
// else use v9 folder
|
|
19
18
|
const cypressVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
20
19
|
const cypressFiles = cypressVersion && cypressVersion < 10 ? 'v9-and-under' : 'v10-and-after';
|
|
21
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files', cypressFiles), options.projectRoot,
|
|
20
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files', cypressFiles), options.projectRoot, {
|
|
21
|
+
tmpl: '',
|
|
22
|
+
...options,
|
|
23
|
+
project: options.project || 'Project',
|
|
24
|
+
ext: options.js ? 'js' : 'ts',
|
|
25
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
26
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.projectRoot),
|
|
27
|
+
bundler: options.bundler,
|
|
28
|
+
});
|
|
22
29
|
if (cypressVersion && cypressVersion < 7) {
|
|
23
30
|
(0, devkit_1.updateJson)(tree, (0, path_1.join)(options.projectRoot, 'cypress.json'), (json) => {
|
|
24
31
|
json.pluginsFile = './src/plugins/index';
|
|
@@ -36,9 +43,9 @@ function createFiles(tree, options) {
|
|
|
36
43
|
}
|
|
37
44
|
}
|
|
38
45
|
function addProject(tree, options) {
|
|
39
|
-
var _a, _b, _c, _d, _e;
|
|
40
46
|
let e2eProjectConfig;
|
|
41
|
-
const detectedCypressVersion = (
|
|
47
|
+
const detectedCypressVersion = (0, cypress_version_1.installedCypressVersion)() ??
|
|
48
|
+
(0, semver_2.major)((0, semver_1.checkAndCleanWithSemver)('cypress', versions_1.cypressVersion));
|
|
42
49
|
const cypressConfig = detectedCypressVersion < 10 ? 'cypress.json' : 'cypress.config.ts';
|
|
43
50
|
if (options.baseUrl) {
|
|
44
51
|
e2eProjectConfig = {
|
|
@@ -67,7 +74,7 @@ function addProject(tree, options) {
|
|
|
67
74
|
"${options.project}:serve" as the devServerTarget. But you may need to define this target within the project, "${options.project}".
|
|
68
75
|
`);
|
|
69
76
|
}
|
|
70
|
-
const devServerTarget =
|
|
77
|
+
const devServerTarget = project.targets?.serve && project.targets?.serve?.defaultConfiguration
|
|
71
78
|
? `${options.project}:serve:${project.targets.serve.defaultConfiguration}`
|
|
72
79
|
: `${options.project}:serve`;
|
|
73
80
|
e2eProjectConfig = {
|
|
@@ -92,7 +99,7 @@ function addProject(tree, options) {
|
|
|
92
99
|
tags: [],
|
|
93
100
|
implicitDependencies: options.project ? [options.project] : undefined,
|
|
94
101
|
};
|
|
95
|
-
if (
|
|
102
|
+
if (project.targets?.['serve-static']) {
|
|
96
103
|
e2eProjectConfig.targets.e2e.configurations.ci = {
|
|
97
104
|
devServerTarget: `${options.project}:serve-static`,
|
|
98
105
|
};
|
|
@@ -109,73 +116,79 @@ function addProject(tree, options) {
|
|
|
109
116
|
/**
|
|
110
117
|
* @deprecated use cypressE2EConfigurationGenerator instead
|
|
111
118
|
**/
|
|
112
|
-
function cypressProjectGenerator(host, schema) {
|
|
113
|
-
return
|
|
114
|
-
|
|
119
|
+
async function cypressProjectGenerator(host, schema) {
|
|
120
|
+
return await cypressProjectGeneratorInternal(host, {
|
|
121
|
+
projectNameAndRootFormat: 'derived',
|
|
122
|
+
...schema,
|
|
115
123
|
});
|
|
116
124
|
}
|
|
117
125
|
exports.cypressProjectGenerator = cypressProjectGenerator;
|
|
118
126
|
/**
|
|
119
127
|
* @deprecated use cypressE2EConfigurationGenerator instead
|
|
120
128
|
**/
|
|
121
|
-
function cypressProjectGeneratorInternal(host, schema) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
129
|
+
async function cypressProjectGeneratorInternal(host, schema) {
|
|
130
|
+
const options = await normalizeOptions(host, schema);
|
|
131
|
+
const tasks = [];
|
|
132
|
+
const cypressVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
133
|
+
// if there is an installed cypress version, then we don't call
|
|
134
|
+
// init since we want to keep the existing version that is installed
|
|
135
|
+
if (!cypressVersion) {
|
|
136
|
+
tasks.push(await (0, init_1.cypressInitGenerator)(host, options));
|
|
137
|
+
}
|
|
138
|
+
if (schema.bundler === 'vite') {
|
|
139
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
140
|
+
vite: versions_1.viteVersion,
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
createFiles(host, options);
|
|
144
|
+
addProject(host, options);
|
|
145
|
+
const installTask = await (0, add_linter_1.addLinterToCyProject)(host, {
|
|
146
|
+
...options,
|
|
147
|
+
cypressDir: 'src',
|
|
148
|
+
linter: schema.linter,
|
|
149
|
+
project: options.projectName,
|
|
150
|
+
overwriteExisting: true,
|
|
144
151
|
});
|
|
152
|
+
tasks.push(installTask);
|
|
153
|
+
if (!options.skipFormat) {
|
|
154
|
+
await (0, devkit_1.formatFiles)(host);
|
|
155
|
+
}
|
|
156
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
145
157
|
}
|
|
146
158
|
exports.cypressProjectGeneratorInternal = cypressProjectGeneratorInternal;
|
|
147
|
-
function normalizeOptions(host, options) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
callingGenerator: '@nx/cypress:cypress-project',
|
|
171
|
-
});
|
|
172
|
-
options.linter = options.linter || linter_1.Linter.EsLint;
|
|
173
|
-
options.bundler = options.bundler || 'webpack';
|
|
174
|
-
return Object.assign(Object.assign({}, options), {
|
|
175
|
-
// other generators depend on the rootProject flag down stream
|
|
176
|
-
rootProject: isRootProject, projectName,
|
|
177
|
-
projectRoot });
|
|
159
|
+
async function normalizeOptions(host, options) {
|
|
160
|
+
let maybeRootProject;
|
|
161
|
+
let isRootProject = false;
|
|
162
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
163
|
+
// nx will set the project option for generators when ran within a project.
|
|
164
|
+
// since the root project will always be set for standalone projects we can just check it here.
|
|
165
|
+
if (options.project) {
|
|
166
|
+
maybeRootProject = projects.get(options.project);
|
|
167
|
+
}
|
|
168
|
+
if (maybeRootProject?.root === '.' ||
|
|
169
|
+
// should still check to see if we are in a standalone based workspace
|
|
170
|
+
(!maybeRootProject &&
|
|
171
|
+
Array.from(projects.values()).some((config) => config.root === '.'))) {
|
|
172
|
+
isRootProject = true;
|
|
173
|
+
}
|
|
174
|
+
let { projectName, projectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
175
|
+
name: options.name,
|
|
176
|
+
projectType: 'application',
|
|
177
|
+
directory: isRootProject ? options.name : options.directory,
|
|
178
|
+
projectNameAndRootFormat: isRootProject
|
|
179
|
+
? 'as-provided'
|
|
180
|
+
: options.projectNameAndRootFormat,
|
|
181
|
+
callingGenerator: '@nx/cypress:cypress-project',
|
|
178
182
|
});
|
|
183
|
+
options.linter = options.linter || linter_1.Linter.EsLint;
|
|
184
|
+
options.bundler = options.bundler || 'webpack';
|
|
185
|
+
return {
|
|
186
|
+
...options,
|
|
187
|
+
// other generators depend on the rootProject flag down stream
|
|
188
|
+
rootProject: isRootProject,
|
|
189
|
+
projectName,
|
|
190
|
+
projectRoot,
|
|
191
|
+
};
|
|
179
192
|
}
|
|
180
193
|
exports.default = cypressProjectGenerator;
|
|
181
194
|
exports.cypressProjectSchematic = (0, devkit_1.convertNxGenerator)(cypressProjectGenerator);
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cypressInitSchematic = exports.cypressInitGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const versions_1 = require("../../utils/versions");
|
|
7
6
|
const js_1 = require("@nx/js");
|
|
8
7
|
function setupE2ETargetDefaults(tree) {
|
|
9
|
-
var _a, _b, _c, _d;
|
|
10
|
-
var _e, _f;
|
|
11
8
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
12
9
|
if (!nxJson.namedInputs) {
|
|
13
10
|
return;
|
|
14
11
|
}
|
|
15
12
|
// E2e targets depend on all their project's sources + production sources of dependencies
|
|
16
|
-
|
|
17
|
-
const productionFileSet = !!
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
nxJson.targetDefaults ??= {};
|
|
14
|
+
const productionFileSet = !!nxJson.namedInputs?.production;
|
|
15
|
+
nxJson.targetDefaults.e2e ??= {};
|
|
16
|
+
nxJson.targetDefaults.e2e.inputs ??= [
|
|
20
17
|
'default',
|
|
21
18
|
productionFileSet ? '^production' : '^default',
|
|
22
|
-
]
|
|
19
|
+
];
|
|
23
20
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
24
21
|
}
|
|
25
22
|
function updateDependencies(tree) {
|
|
@@ -30,16 +27,17 @@ function updateDependencies(tree) {
|
|
|
30
27
|
'@types/node': versions_1.typesNodeVersion,
|
|
31
28
|
});
|
|
32
29
|
}
|
|
33
|
-
function cypressInitGenerator(tree, options) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
30
|
+
async function cypressInitGenerator(tree, options) {
|
|
31
|
+
setupE2ETargetDefaults(tree);
|
|
32
|
+
const tasks = [];
|
|
33
|
+
tasks.push(await (0, js_1.initGenerator)(tree, {
|
|
34
|
+
...options,
|
|
35
|
+
skipFormat: true,
|
|
36
|
+
}));
|
|
37
|
+
if (!options.skipPackageJson) {
|
|
38
|
+
tasks.push(updateDependencies(tree));
|
|
39
|
+
}
|
|
40
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
43
41
|
}
|
|
44
42
|
exports.cypressInitGenerator = cypressInitGenerator;
|
|
45
43
|
exports.default = cypressInitGenerator;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updatePluginFile = exports.addConfigToTsConfig = exports.writeNewConfig = exports.updateImports = exports.updateProjectPaths = exports.createSupportFileImport = exports.createNewCypressConfig = exports.findCypressConfigs = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const path_1 = require("path");
|
|
7
6
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
@@ -16,9 +15,8 @@ const validFilesEndingsToUpdate = [
|
|
|
16
15
|
'.cjs',
|
|
17
16
|
];
|
|
18
17
|
function findCypressConfigs(tree, projectConfig, target, config) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
((_e = (_d = projectConfig.targets[target]) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.cypressConfig);
|
|
18
|
+
const cypressConfigPathJson = projectConfig.targets[target]?.configurations?.[config]?.cypressConfig ||
|
|
19
|
+
projectConfig.targets[target]?.options?.cypressConfig;
|
|
22
20
|
// make sure it's a json file, since it could have been updated to ts file from previous configuration migration
|
|
23
21
|
if (!cypressConfigPathJson || (0, path_1.extname)(cypressConfigPathJson) !== '.json') {
|
|
24
22
|
return {
|
|
@@ -28,7 +26,7 @@ function findCypressConfigs(tree, projectConfig, target, config) {
|
|
|
28
26
|
}
|
|
29
27
|
const cypressConfigPathTs = (0, devkit_1.joinPathFragments)((0, path_1.dirname)(cypressConfigPathJson),
|
|
30
28
|
// create matching ts config for custom cypress config if present
|
|
31
|
-
|
|
29
|
+
cypressConfigPathJson?.endsWith('cypress.json')
|
|
32
30
|
? 'cypress.config.ts' //default
|
|
33
31
|
: `${(0, path_1.basename)(cypressConfigPathJson, (0, path_1.extname)(cypressConfigPathJson))}.config.ts`);
|
|
34
32
|
return {
|
|
@@ -45,12 +43,14 @@ function createNewCypressConfig(tree, projectConfig, cypressConfigPathJson) {
|
|
|
45
43
|
const cypressConfigJson = (0, devkit_1.readJson)(tree, cypressConfigPathJson);
|
|
46
44
|
const { modifyObstructiveCode = null, // no longer needed in configs
|
|
47
45
|
integrationFolder = 'src/e2e', // provide the new defaults if the value isn't present
|
|
48
|
-
supportFile = 'src/support/e2e.ts'
|
|
46
|
+
supportFile = 'src/support/e2e.ts', ...restOfConfig } = cypressConfigJson;
|
|
49
47
|
const newIntegrationFolder = tree.exists((0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'integration'))
|
|
50
48
|
? 'src/e2e'
|
|
51
49
|
: integrationFolder;
|
|
52
50
|
const cypressConfigTs = {
|
|
53
|
-
e2e:
|
|
51
|
+
e2e: {
|
|
52
|
+
...restOfConfig,
|
|
53
|
+
specPattern: `${newIntegrationFolder}/**/*.cy.{js,jsx,ts,tsx}`,
|
|
54
54
|
// if supportFile is defined (can be false if not using it) and in the default location (or in the new default location),
|
|
55
55
|
// then use the new default location.
|
|
56
56
|
// otherwise we will use the existing folder location/falsey value
|
|
@@ -58,10 +58,11 @@ function createNewCypressConfig(tree, projectConfig, cypressConfigPathJson) {
|
|
|
58
58
|
tree.exists((0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'support', 'index.ts'))) ||
|
|
59
59
|
tree.exists((0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'support', 'e2e.ts'))
|
|
60
60
|
? 'src/support/e2e.ts'
|
|
61
|
-
: supportFile,
|
|
61
|
+
: supportFile,
|
|
62
62
|
// if the default location is used then will update to the new location otherwise keep the custom location
|
|
63
63
|
// this is used down the line, but won't be in the final config file since it's a deprecated option
|
|
64
|
-
integrationFolder: newIntegrationFolder
|
|
64
|
+
integrationFolder: newIntegrationFolder,
|
|
65
|
+
},
|
|
65
66
|
};
|
|
66
67
|
return { cypressConfigTs, cypressConfigJson };
|
|
67
68
|
}
|
|
@@ -169,7 +170,7 @@ function updateImports(tree, filePath, oldImportPath, newImportPath) {
|
|
|
169
170
|
const fileContent = tree.read(filePath, 'utf-8');
|
|
170
171
|
const newContent = tsquery.replace(fileContent, endOfImportSelector, (node) => {
|
|
171
172
|
// if node.parent is an CallExpression require() ||ImportDeclaration
|
|
172
|
-
if (
|
|
173
|
+
if (node?.parent &&
|
|
173
174
|
(isCallExpression(node.parent) ||
|
|
174
175
|
isImportDeclaration(node.parent) ||
|
|
175
176
|
isExportDeclaration(node.parent))) {
|
|
@@ -182,7 +183,7 @@ function updateImports(tree, filePath, oldImportPath, newImportPath) {
|
|
|
182
183
|
exports.updateImports = updateImports;
|
|
183
184
|
function writeNewConfig(tree, cypressConfigPathTs, cypressConfigs) {
|
|
184
185
|
// remove deprecated configs options
|
|
185
|
-
const
|
|
186
|
+
const { pluginsFile = false, integrationFolder = '', ...restOfConfig } = cypressConfigs.cypressConfigTs.e2e;
|
|
186
187
|
const pluginImport = pluginsFile
|
|
187
188
|
? `import setupNodeEvents from '${pluginsFile}';`
|
|
188
189
|
: '';
|
|
@@ -216,18 +217,23 @@ function addConfigToTsConfig(tree, tsconfigPath, cypressConfigPath) {
|
|
|
216
217
|
}
|
|
217
218
|
exports.addConfigToTsConfig = addConfigToTsConfig;
|
|
218
219
|
function updatePluginFile(tree, projectConfig, cypressConfigs) {
|
|
219
|
-
var _a, _b;
|
|
220
220
|
// if ts file change module.exports = to export default
|
|
221
221
|
// if js file don't do anything
|
|
222
222
|
// update cypressConfigTs.e2e to remove file extension
|
|
223
|
-
const pluginsFile =
|
|
223
|
+
const pluginsFile = cypressConfigs.cypressConfigTs?.e2e?.pluginsFile;
|
|
224
224
|
if (!pluginsFile) {
|
|
225
225
|
return cypressConfigs;
|
|
226
226
|
}
|
|
227
227
|
const ext = (0, path_1.extname)(pluginsFile);
|
|
228
|
-
const updatedCypressConfigs =
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
const updatedCypressConfigs = {
|
|
229
|
+
...cypressConfigs,
|
|
230
|
+
cypressConfigTs: {
|
|
231
|
+
e2e: {
|
|
232
|
+
...cypressConfigs.cypressConfigTs.e2e,
|
|
233
|
+
pluginsFile: pluginsFile.replace(ext, ''),
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
};
|
|
231
237
|
const pluginFilePath = (0, devkit_1.joinPathFragments)(projectConfig.root, pluginsFile);
|
|
232
238
|
if (ext === '.ts' && tree.exists(pluginFilePath)) {
|
|
233
239
|
const pluginFileContent = tree.read(pluginFilePath, 'utf-8');
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateCypressProject = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const cypress_version_1 = require("../../utils/cypress-version");
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
6
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
8
7
|
const conversion_util_1 = require("./conversion.util");
|
|
9
8
|
function migrateCypressExecutorOptions(tree, projectName, target, configuration, previousCypressConfigs) {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
11
9
|
try {
|
|
12
10
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
13
11
|
const { cypressConfigPathJson, cypressConfigPathTs } = (0, conversion_util_1.findCypressConfigs)(tree, projectConfig, target, configuration);
|
|
@@ -29,14 +27,21 @@ function migrateCypressExecutorOptions(tree, projectName, target, configuration,
|
|
|
29
27
|
const cypressConfigs = previousCypressConfigs.get(cypressConfigPathJson);
|
|
30
28
|
(0, conversion_util_1.updateProjectPaths)(tree, projectConfig, cypressConfigs);
|
|
31
29
|
(0, conversion_util_1.addConfigToTsConfig)(tree, (configuration
|
|
32
|
-
?
|
|
33
|
-
|
|
30
|
+
? projectConfig.targets?.[target]?.configurations?.[configuration]
|
|
31
|
+
?.tsConfig
|
|
32
|
+
: projectConfig.targets?.[target]?.options?.tsConfig) ||
|
|
34
33
|
(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'), cypressConfigPathTs);
|
|
35
34
|
if (configuration) {
|
|
36
|
-
projectConfig.targets[target].configurations[configuration] =
|
|
35
|
+
projectConfig.targets[target].configurations[configuration] = {
|
|
36
|
+
...projectConfig.targets[target].configurations[configuration],
|
|
37
|
+
cypressConfig: cypressConfigPathTs,
|
|
38
|
+
};
|
|
37
39
|
}
|
|
38
40
|
else {
|
|
39
|
-
projectConfig.targets[target].options =
|
|
41
|
+
projectConfig.targets[target].options = {
|
|
42
|
+
...projectConfig.targets[target].options,
|
|
43
|
+
cypressConfig: cypressConfigPathTs,
|
|
44
|
+
};
|
|
40
45
|
}
|
|
41
46
|
projectConfig.targets[target].options.testingType = 'e2e';
|
|
42
47
|
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
@@ -51,40 +56,38 @@ https://nx.dev/cypress/v10-migration-guide
|
|
|
51
56
|
throw e;
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
|
-
function migrateCypressProject(tree) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
devkit_1.logger.warn((0, devkit_1.stripIndents) `A root cypress.json file was found.
|
|
59
|
+
async function migrateCypressProject(tree) {
|
|
60
|
+
(0, cypress_version_1.assertMinimumCypressVersion)(8);
|
|
61
|
+
if ((0, cypress_version_1.installedCypressVersion)() >= 10) {
|
|
62
|
+
devkit_1.logger.info('NX This workspace is already using Cypress v10+');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// keep history of cypress configs as some workspaces share configs
|
|
66
|
+
// if we don't have the already migrated configs
|
|
67
|
+
// it prevents us from being able to rename files for those projects
|
|
68
|
+
const previousCypressConfigs = new Map();
|
|
69
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/cypress:cypress', (currentValue, projectName, target, configuration) => {
|
|
70
|
+
migrateCypressExecutorOptions(tree, projectName, target, configuration, previousCypressConfigs);
|
|
71
|
+
});
|
|
72
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/cypress:cypress', (currentValue, projectName, target, configuration) => {
|
|
73
|
+
migrateCypressExecutorOptions(tree, projectName, target, configuration, previousCypressConfigs);
|
|
74
|
+
});
|
|
75
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (json) => {
|
|
76
|
+
json.devDependencies['cypress'] = '^11.2.0';
|
|
77
|
+
return json;
|
|
78
|
+
});
|
|
79
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
80
|
+
if (tree.exists('cypress.json')) {
|
|
81
|
+
devkit_1.logger.warn((0, devkit_1.stripIndents) `A root cypress.json file was found.
|
|
78
82
|
You should remove this file as it will cause an error when running Cypress.
|
|
79
83
|
If you want to share options between Cypress projects.
|
|
80
84
|
You can create a root ts file and import it into each project's cypress config file.
|
|
81
85
|
More Info: https://github.com/nrwl/nx/issues/11512#issuecomment-1213420638
|
|
82
86
|
`);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
87
|
+
}
|
|
88
|
+
return () => {
|
|
89
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
90
|
+
};
|
|
88
91
|
}
|
|
89
92
|
exports.migrateCypressProject = migrateCypressProject;
|
|
90
93
|
exports.default = migrateCypressProject;
|
|
@@ -1,40 +1,37 @@
|
|
|
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 typescript_1 = require("typescript");
|
|
6
5
|
const path_1 = require("path");
|
|
7
6
|
const cypress_version_1 = require("../../utils/cypress-version");
|
|
8
|
-
function removeTypescriptPlugin(tree) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
async function removeTypescriptPlugin(tree) {
|
|
8
|
+
const cypressVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
9
|
+
if (cypressVersion < 7) {
|
|
10
|
+
console.warn(`Cypress v${cypressVersion} is installed. This migration was skipped. Please rerun this migration after updating to Cypress 7.`);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
for (const [_, proj] of (0, devkit_1.getProjects)(tree)) {
|
|
14
|
+
const cypressTargets = getCypressTargets(proj);
|
|
15
|
+
if (cypressTargets.length <= 0) {
|
|
16
|
+
continue;
|
|
14
17
|
}
|
|
15
|
-
for (const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let pluginPath = (0, path_1.join)((0, path_1.dirname)(config), cypressConfig.pluginsFile);
|
|
26
|
-
if (!tree.exists(pluginPath)) {
|
|
27
|
-
pluginPath = ['.js', '.ts']
|
|
28
|
-
.map((ext) => pluginPath + ext)
|
|
29
|
-
.find((path) => tree.exists(path));
|
|
30
|
-
}
|
|
31
|
-
removePreprocessor(tree, pluginPath);
|
|
18
|
+
for (const target of cypressTargets) {
|
|
19
|
+
const cypressConfigs = getCypressConfigs(target);
|
|
20
|
+
for (const config of cypressConfigs) {
|
|
21
|
+
const cypressConfig = (0, devkit_1.readJson)(tree, config);
|
|
22
|
+
if (cypressConfig.pluginsFile) {
|
|
23
|
+
let pluginPath = (0, path_1.join)((0, path_1.dirname)(config), cypressConfig.pluginsFile);
|
|
24
|
+
if (!tree.exists(pluginPath)) {
|
|
25
|
+
pluginPath = ['.js', '.ts']
|
|
26
|
+
.map((ext) => pluginPath + ext)
|
|
27
|
+
.find((path) => tree.exists(path));
|
|
32
28
|
}
|
|
29
|
+
removePreprocessor(tree, pluginPath);
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
}
|
|
34
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
38
35
|
}
|
|
39
36
|
exports.default = removeTypescriptPlugin;
|
|
40
37
|
function removePreprocessor(tree, pluginPath) {
|