@nx/cypress 17.2.0-beta.8 → 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
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,14 +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
42
|
"semver": "7.5.3",
|
|
43
43
|
"tslib": "^2.3.0",
|
|
44
|
-
"@nrwl/cypress": "17.2.0-beta.
|
|
44
|
+
"@nrwl/cypress": "17.2.0-beta.9"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"cypress": ">= 3 < 14"
|
package/src/plugins/plugin.js
CHANGED
|
@@ -174,7 +174,7 @@ function buildCypressTargets(configFilePath, projectRoot, options, context) {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
if ('component' in cypressConfig) {
|
|
177
|
-
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');
|
|
178
178
|
// This will not override the e2e target if it is the same
|
|
179
179
|
targets[options.componentTestingTargetName] ??= {
|
|
180
180
|
command: `cypress open --config-file ${relativeConfigPath} --component`,
|
|
@@ -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;
|