@nx/cypress 17.2.0-beta.6 → 17.2.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +0 -5
- package/package.json +5 -6
- package/plugins/cypress-preset.js +1 -0
- package/src/generators/configuration/configuration.js +7 -7
- package/src/plugins/plugin.js +1 -3
- package/src/utils/add-linter.js +0 -3
- package/src/migrations/update-17-2-0/add-dev-server-targets-to-cypress-configs.d.ts +0 -2
- package/src/migrations/update-17-2-0/add-dev-server-targets-to-cypress-configs.js +0 -125
package/migrations.json
CHANGED
|
@@ -47,11 +47,6 @@
|
|
|
47
47
|
"version": "16.8.0-beta.4",
|
|
48
48
|
"description": "Update to Cypress v13. Most noteable change is video recording is off by default. This migration will only update if the workspace is already on Cypress v12. https://docs.cypress.io/guides/references/migration-guide#Migrating-to-Cypress-130",
|
|
49
49
|
"implementation": "./src/migrations/update-16-8-0/cypress-13"
|
|
50
|
-
},
|
|
51
|
-
"add-nx-metadata": {
|
|
52
|
-
"version": "17.2.0-beta.0",
|
|
53
|
-
"description": "Add devServerTargets into cypress.config.ts files for @nx/cypress/plugin",
|
|
54
|
-
"implementation": "./src/migrations/update-17-2-0/add-dev-server-targets-to-cypress-configs"
|
|
55
50
|
}
|
|
56
51
|
},
|
|
57
52
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/cypress",
|
|
3
|
-
"version": "17.2.0-beta.
|
|
3
|
+
"version": "17.2.0-beta.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Cypress contains executors and generators allowing your workspace to use the powerful Cypress integration testing capabilities.",
|
|
6
6
|
"repository": {
|
|
@@ -34,15 +34,14 @@
|
|
|
34
34
|
"migrations": "./migrations.json"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nx/devkit": "17.2.0-beta.
|
|
38
|
-
"@nx/eslint": "17.2.0-beta.
|
|
39
|
-
"@nx/js": "17.2.0-beta.
|
|
37
|
+
"@nx/devkit": "17.2.0-beta.9",
|
|
38
|
+
"@nx/eslint": "17.2.0-beta.9",
|
|
39
|
+
"@nx/js": "17.2.0-beta.9",
|
|
40
40
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
41
41
|
"detect-port": "^1.5.1",
|
|
42
|
-
"string-argv": "^0.3.2",
|
|
43
42
|
"semver": "7.5.3",
|
|
44
43
|
"tslib": "^2.3.0",
|
|
45
|
-
"@nrwl/cypress": "17.2.0-beta.
|
|
44
|
+
"@nrwl/cypress": "17.2.0-beta.9"
|
|
46
45
|
},
|
|
47
46
|
"peerDependencies": {
|
|
48
47
|
"cypress": ">= 3 < 14"
|
|
@@ -62,6 +62,7 @@ function nxE2EPreset(pathToConfig, options) {
|
|
|
62
62
|
specPattern: `${basePath}/**/*.cy.{js,jsx,ts,tsx}`,
|
|
63
63
|
fixturesFolder: `${basePath}/fixtures`,
|
|
64
64
|
env: {
|
|
65
|
+
webServerCommand: options?.webServerCommands?.default,
|
|
65
66
|
webServerCommands: options?.webServerCommands,
|
|
66
67
|
ciWebServerCommand: options?.ciWebServerCommand,
|
|
67
68
|
},
|
|
@@ -148,13 +148,7 @@ function addTarget(tree, opts) {
|
|
|
148
148
|
testingType: 'e2e',
|
|
149
149
|
},
|
|
150
150
|
};
|
|
151
|
-
if (opts.
|
|
152
|
-
projectConfig.targets.e2e.options = {
|
|
153
|
-
...projectConfig.targets.e2e.options,
|
|
154
|
-
baseUrl: opts.baseUrl,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
else if (opts.devServerTarget) {
|
|
151
|
+
if (opts.devServerTarget) {
|
|
158
152
|
const parsedTarget = (0, devkit_1.parseTargetString)(opts.devServerTarget);
|
|
159
153
|
projectConfig.targets.e2e.options = {
|
|
160
154
|
...projectConfig.targets.e2e.options,
|
|
@@ -178,6 +172,12 @@ function addTarget(tree, opts) {
|
|
|
178
172
|
};
|
|
179
173
|
}
|
|
180
174
|
}
|
|
175
|
+
else if (opts.baseUrl) {
|
|
176
|
+
projectConfig.targets.e2e.options = {
|
|
177
|
+
...projectConfig.targets.e2e.options,
|
|
178
|
+
baseUrl: opts.baseUrl,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
181
|
(0, devkit_1.updateProjectConfiguration)(tree, opts.project, projectConfig);
|
|
182
182
|
}
|
|
183
183
|
exports.default = configurationGenerator;
|
package/src/plugins/plugin.js
CHANGED
|
@@ -120,8 +120,6 @@ function buildCypressTargets(configFilePath, projectRoot, options, context) {
|
|
|
120
120
|
targets[options.targetName].outputs = getOutputs(projectRoot, cypressConfig, 'e2e');
|
|
121
121
|
}
|
|
122
122
|
if (webServerCommands?.default) {
|
|
123
|
-
cypressConfig.e2e ??= {};
|
|
124
|
-
cypressConfig.e2e.webServerCommand ??= webServerCommands?.default;
|
|
125
123
|
delete webServerCommands.default;
|
|
126
124
|
}
|
|
127
125
|
if (Object.keys(webServerCommands ?? {}).length > 0) {
|
|
@@ -176,7 +174,7 @@ function buildCypressTargets(configFilePath, projectRoot, options, context) {
|
|
|
176
174
|
}
|
|
177
175
|
}
|
|
178
176
|
if ('component' in cypressConfig) {
|
|
179
|
-
const componentTestingTargetDefaults = (0, project_configuration_utils_1.readTargetDefaultsForTarget)(options.componentTestingTargetName, context.nxJsonConfiguration.targetDefaults, '
|
|
177
|
+
const componentTestingTargetDefaults = (0, project_configuration_utils_1.readTargetDefaultsForTarget)(options.componentTestingTargetName, context.nxJsonConfiguration.targetDefaults, 'nx:run-commands');
|
|
180
178
|
// This will not override the e2e target if it is the same
|
|
181
179
|
targets[options.componentTestingTargetName] ??= {
|
|
182
180
|
command: `cypress open --config-file ${relativeConfigPath} --component`,
|
package/src/utils/add-linter.js
CHANGED
|
@@ -20,9 +20,6 @@ async function addLinterToCyProject(tree, options) {
|
|
|
20
20
|
linter: options.linter,
|
|
21
21
|
skipFormat: true,
|
|
22
22
|
tsConfigPaths: [(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json')],
|
|
23
|
-
eslintFilePatterns: [
|
|
24
|
-
`${projectConfig.root}/**/*.${options.js ? 'js' : '{js,ts}'}`,
|
|
25
|
-
],
|
|
26
23
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
27
24
|
skipPackageJson: options.skipPackageJson,
|
|
28
25
|
rootProject: options.rootProject,
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
5
|
-
const typescript_1 = require("typescript");
|
|
6
|
-
function addDevServerTargets(tree, cypressConfig, devServerTargets) {
|
|
7
|
-
const contents = tree.read(cypressConfig, 'utf-8');
|
|
8
|
-
const sourceFile = (0, typescript_1.createSourceFile)(cypressConfig, contents, typescript_1.ScriptTarget.ESNext);
|
|
9
|
-
const ciDevServerTarget = devServerTargets.ci;
|
|
10
|
-
delete devServerTargets.ci;
|
|
11
|
-
const changes = [];
|
|
12
|
-
const visit = (node) => {
|
|
13
|
-
if ((0, typescript_1.isCallExpression)(node) &&
|
|
14
|
-
(0, typescript_1.isIdentifier)(node.expression) &&
|
|
15
|
-
node.expression.text === 'nxE2EPreset') {
|
|
16
|
-
const argumentContents = ', ' +
|
|
17
|
-
JSON.stringify({
|
|
18
|
-
devServerTargets,
|
|
19
|
-
ciDevServerTarget,
|
|
20
|
-
});
|
|
21
|
-
if (node.arguments.length === 1) {
|
|
22
|
-
changes.push({
|
|
23
|
-
type: devkit_1.ChangeType.Insert,
|
|
24
|
-
index: node.arguments[0].getEnd(),
|
|
25
|
-
text: argumentContents,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
const lastArgument = node.arguments[node.arguments.length - 1];
|
|
30
|
-
if ((0, typescript_1.isObjectLiteralExpression)(lastArgument)) {
|
|
31
|
-
const lastProperty = lastArgument.properties[lastArgument.properties.length - 1];
|
|
32
|
-
const trailingComma = lastArgument.properties.hasTrailingComma;
|
|
33
|
-
changes.push({
|
|
34
|
-
type: devkit_1.ChangeType.Insert,
|
|
35
|
-
index: lastProperty.getEnd(),
|
|
36
|
-
text: (trailingComma ? '' : ', ') +
|
|
37
|
-
'devServerTargets: ' +
|
|
38
|
-
JSON.stringify(devServerTargets) +
|
|
39
|
-
(ciDevServerTarget
|
|
40
|
-
? `, ciDevServerTarget: '${ciDevServerTarget}'`
|
|
41
|
-
: ''),
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
(0, typescript_1.forEachChild)(node, visit);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
(0, typescript_1.forEachChild)(sourceFile, visit);
|
|
51
|
-
tree.write(cypressConfig, (0, devkit_1.applyChangesToString)(contents, changes));
|
|
52
|
-
}
|
|
53
|
-
async function update(tree) {
|
|
54
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
|
55
|
-
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
|
56
|
-
const devServerTargetsMap = new Map();
|
|
57
|
-
(0, executor_options_utils_1.forEachExecutorOptionsInGraph)(graph, '@nx/cypress:cypress', (options, project, target, configuration) => {
|
|
58
|
-
const targetConfig = projects.get(project).targets?.[target];
|
|
59
|
-
if (!targetConfig) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const cypressConfig = options.cypressConfig ?? targetConfig.options?.cypressConfig;
|
|
63
|
-
if (!cypressConfig) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const devServerTargets = {};
|
|
67
|
-
devServerTargets.default = targetConfig.options?.devServerTarget;
|
|
68
|
-
for (const [configuration, configurationOptions] of Object.entries(targetConfig.configurations ?? {})) {
|
|
69
|
-
devServerTargets[configuration] = configurationOptions.devServerTarget;
|
|
70
|
-
}
|
|
71
|
-
devServerTargetsMap.set(cypressConfig, devServerTargets);
|
|
72
|
-
});
|
|
73
|
-
for (const [cypressConfig, devServerTargets] of devServerTargetsMap) {
|
|
74
|
-
addDevServerTargets(tree, cypressConfig, devServerTargets);
|
|
75
|
-
}
|
|
76
|
-
// const configFiles = glob(tree, [createNodes[0]]);
|
|
77
|
-
//
|
|
78
|
-
// const proj = Object.fromEntries(getProjects(tree).entries());
|
|
79
|
-
//
|
|
80
|
-
// const rootMappings = createProjectRootMappingsFromProjectConfigurations(proj);
|
|
81
|
-
//
|
|
82
|
-
// for (const configFile of configFiles) {
|
|
83
|
-
// const siblings = tree.children(dirname(configFile));
|
|
84
|
-
// if (!siblings.includes('project.json')) {
|
|
85
|
-
// continue;
|
|
86
|
-
// }
|
|
87
|
-
//
|
|
88
|
-
// const projectName = findProjectForPath(configFile, rootMappings);
|
|
89
|
-
// const projectConfig = readProjectConfiguration(tree, projectName);
|
|
90
|
-
// const e2eTarget: TargetConfiguration<CypressExecutorOptions> =
|
|
91
|
-
// projectConfig.targets?.e2e;
|
|
92
|
-
//
|
|
93
|
-
// if (!e2eTarget || e2eTarget.executor !== '@nx/cypress:cypress') {
|
|
94
|
-
// continue;
|
|
95
|
-
// }
|
|
96
|
-
//
|
|
97
|
-
// nxMetadata.devServerTarget = e2eTarget.options?.devServerTarget;
|
|
98
|
-
// nxMetadata.productionDevServerTarget =
|
|
99
|
-
// e2eTarget.configurations?.production?.devServerTarget;
|
|
100
|
-
// nxMetadata.ciDevServerTarget =
|
|
101
|
-
// e2eTarget.configurations?.ci?.devServerTarget;
|
|
102
|
-
//
|
|
103
|
-
// if (Object.values(nxMetadata).filter((v) => !!v).length > 0) {
|
|
104
|
-
// let contents = tree.read(configFile, 'utf-8');
|
|
105
|
-
//
|
|
106
|
-
// contents =
|
|
107
|
-
// `import type { NxCypressMetadata } from '@nx/cypress/plugin';\n` +
|
|
108
|
-
// contents +
|
|
109
|
-
// `
|
|
110
|
-
//
|
|
111
|
-
// /**
|
|
112
|
-
// * This is metadata for the @nx/cypress/plugin
|
|
113
|
-
// */
|
|
114
|
-
// export const nx: NxCypressMetadata = ${JSON.stringify(
|
|
115
|
-
// nxMetadata,
|
|
116
|
-
// null,
|
|
117
|
-
// 2
|
|
118
|
-
// )};`;
|
|
119
|
-
//
|
|
120
|
-
// tree.write(configFile, contents);
|
|
121
|
-
// }
|
|
122
|
-
// }
|
|
123
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
124
|
-
}
|
|
125
|
-
exports.default = update;
|