@nx/cypress 21.2.1 → 21.2.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/cypress",
|
|
3
|
-
"version": "21.2.
|
|
3
|
+
"version": "21.2.3",
|
|
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": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"migrations": "./migrations.json"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@nx/devkit": "21.2.
|
|
40
|
-
"@nx/eslint": "21.2.
|
|
41
|
-
"@nx/js": "21.2.
|
|
39
|
+
"@nx/devkit": "21.2.3",
|
|
40
|
+
"@nx/eslint": "21.2.3",
|
|
41
|
+
"@nx/js": "21.2.3",
|
|
42
42
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
43
43
|
"detect-port": "^1.5.1",
|
|
44
44
|
"semver": "^7.6.3",
|
|
@@ -9,8 +9,9 @@ exports.writeNewConfig = writeNewConfig;
|
|
|
9
9
|
exports.addConfigToTsConfig = addConfigToTsConfig;
|
|
10
10
|
exports.updatePluginFile = updatePluginFile;
|
|
11
11
|
const devkit_1 = require("@nx/devkit");
|
|
12
|
-
const path_1 = require("path");
|
|
13
12
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
13
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
14
|
+
const path_1 = require("path");
|
|
14
15
|
let tsModule;
|
|
15
16
|
let tsquery;
|
|
16
17
|
const validFilesEndingsToUpdate = [
|
|
@@ -50,7 +51,8 @@ function createNewCypressConfig(tree, projectConfig, cypressConfigPathJson) {
|
|
|
50
51
|
const { modifyObstructiveCode = null, // no longer needed in configs
|
|
51
52
|
integrationFolder = 'src/e2e', // provide the new defaults if the value isn't present
|
|
52
53
|
supportFile = 'src/support/e2e.ts', ...restOfConfig } = cypressConfigJson;
|
|
53
|
-
const
|
|
54
|
+
const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(projectConfig, tree);
|
|
55
|
+
const newIntegrationFolder = tree.exists((0, devkit_1.joinPathFragments)(sourceRoot, 'integration'))
|
|
54
56
|
? 'src/e2e'
|
|
55
57
|
: integrationFolder;
|
|
56
58
|
const cypressConfigTs = {
|
|
@@ -61,8 +63,8 @@ function createNewCypressConfig(tree, projectConfig, cypressConfigPathJson) {
|
|
|
61
63
|
// then use the new default location.
|
|
62
64
|
// otherwise we will use the existing folder location/falsey value
|
|
63
65
|
supportFile: (supportFile &&
|
|
64
|
-
tree.exists((0, devkit_1.joinPathFragments)(
|
|
65
|
-
tree.exists((0, devkit_1.joinPathFragments)(
|
|
66
|
+
tree.exists((0, devkit_1.joinPathFragments)(sourceRoot, 'support', 'index.ts'))) ||
|
|
67
|
+
tree.exists((0, devkit_1.joinPathFragments)(sourceRoot, 'support', 'e2e.ts'))
|
|
66
68
|
? 'src/support/e2e.ts'
|
|
67
69
|
: supportFile,
|
|
68
70
|
// if the default location is used then will update to the new location otherwise keep the custom location
|
|
@@ -97,6 +99,7 @@ function createSupportFileImport(oldSupportFilePath, newSupportFilePath, project
|
|
|
97
99
|
}
|
|
98
100
|
function updateProjectPaths(tree, projectConfig, { cypressConfigTs, cypressConfigJson, }) {
|
|
99
101
|
const { integrationFolder, supportFile } = cypressConfigTs['e2e'];
|
|
102
|
+
const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(projectConfig, tree);
|
|
100
103
|
const oldIntegrationFolder = (0, devkit_1.joinPathFragments)(projectConfig.root, cypressConfigJson.integrationFolder);
|
|
101
104
|
const newIntegrationFolder = (0, devkit_1.joinPathFragments)(projectConfig.root, integrationFolder);
|
|
102
105
|
let newSupportFile;
|
|
@@ -121,9 +124,9 @@ function updateProjectPaths(tree, projectConfig, { cypressConfigTs, cypressConfi
|
|
|
121
124
|
shouldUpdateSupportFileImports = false;
|
|
122
125
|
newSupportFile = supportFile;
|
|
123
126
|
// rename the default support file even if not in use to keep the system in sync with cypress v10
|
|
124
|
-
const defaultSupportFile = (0, devkit_1.joinPathFragments)(
|
|
127
|
+
const defaultSupportFile = (0, devkit_1.joinPathFragments)(sourceRoot, 'support', 'index.ts');
|
|
125
128
|
if (tree.exists(defaultSupportFile)) {
|
|
126
|
-
const newSupportDefaultPath = (0, devkit_1.joinPathFragments)(
|
|
129
|
+
const newSupportDefaultPath = (0, devkit_1.joinPathFragments)(sourceRoot, 'support', 'e2e.ts');
|
|
127
130
|
if (defaultSupportFile !== newSupportDefaultPath &&
|
|
128
131
|
tree.exists(defaultSupportFile)) {
|
|
129
132
|
tree.rename(defaultSupportFile, newSupportDefaultPath);
|
|
@@ -131,13 +134,13 @@ function updateProjectPaths(tree, projectConfig, { cypressConfigTs, cypressConfi
|
|
|
131
134
|
}
|
|
132
135
|
}
|
|
133
136
|
if (shouldUpdateSupportFileImports) {
|
|
134
|
-
const newImportPaths = createSupportFileImport(oldSupportFile, newSupportFile,
|
|
137
|
+
const newImportPaths = createSupportFileImport(oldSupportFile, newSupportFile, sourceRoot);
|
|
135
138
|
oldImportLeafPath = newImportPaths.oldImportPathLeaf;
|
|
136
139
|
newImportLeafPath = newImportPaths.newImportPathLeaf;
|
|
137
140
|
}
|
|
138
141
|
// tree.rename doesn't work on directories must update each file within
|
|
139
142
|
// the directory to the new directory
|
|
140
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree,
|
|
143
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, sourceRoot, (path) => {
|
|
141
144
|
const normalizedPath = (0, devkit_1.normalizePath)(path);
|
|
142
145
|
if (!normalizedPath.includes(oldIntegrationFolder)) {
|
|
143
146
|
return;
|
|
@@ -32,7 +32,9 @@ function setInjectDocumentDomain(cypressConfig) {
|
|
|
32
32
|
}
|
|
33
33
|
const sourceFile = tsquery_1.tsquery.ast(cypressConfig);
|
|
34
34
|
let e2eProperty = (0, migrations_1.getObjectProperty)(config, 'e2e');
|
|
35
|
-
let
|
|
35
|
+
let hasOtherTopLevelProperties = config.properties.some((p) => ts.isPropertyAssignment(p) &&
|
|
36
|
+
p.name.getText() !== 'e2e' &&
|
|
37
|
+
p.name.getText() !== 'component');
|
|
36
38
|
let updatedConfig = config;
|
|
37
39
|
const topLevelExperimentalSkipDomainInjectionProperty = (0, migrations_1.getObjectProperty)(updatedConfig, 'experimentalSkipDomainInjection');
|
|
38
40
|
const topLevelSkipDomainState = !topLevelExperimentalSkipDomainInjectionProperty
|
|
@@ -76,43 +78,9 @@ function setInjectDocumentDomain(cypressConfig) {
|
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
|
-
let componentSkipDomainState = 'not-set';
|
|
80
|
-
if (componentProperty) {
|
|
81
|
-
let experimentalSkipDomainInjectionProperty;
|
|
82
|
-
let isObjectLiteral = false;
|
|
83
|
-
if (ts.isObjectLiteralExpression(componentProperty.initializer)) {
|
|
84
|
-
experimentalSkipDomainInjectionProperty = (0, migrations_1.getObjectProperty)(componentProperty.initializer, 'experimentalSkipDomainInjection');
|
|
85
|
-
isObjectLiteral = true;
|
|
86
|
-
}
|
|
87
|
-
if (experimentalSkipDomainInjectionProperty) {
|
|
88
|
-
componentSkipDomainState =
|
|
89
|
-
!ts.isArrayLiteralExpression(experimentalSkipDomainInjectionProperty.initializer) ||
|
|
90
|
-
experimentalSkipDomainInjectionProperty.initializer.elements.length > 0
|
|
91
|
-
? 'skipping'
|
|
92
|
-
: 'not-skipping';
|
|
93
|
-
}
|
|
94
|
-
if (componentSkipDomainState === 'not-set' &&
|
|
95
|
-
topLevelSkipDomainState === 'not-set') {
|
|
96
|
-
updatedConfig = (0, migrations_1.updateObjectProperty)(updatedConfig, componentProperty, {
|
|
97
|
-
newValue: setInjectDocumentDomainInObject(componentProperty.initializer),
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
else if (componentSkipDomainState === 'not-skipping') {
|
|
101
|
-
updatedConfig = (0, migrations_1.updateObjectProperty)(updatedConfig, componentProperty, {
|
|
102
|
-
newValue: replaceExperimentalSkipDomainInjectionInObject(componentProperty.initializer),
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
else if (componentSkipDomainState === 'skipping') {
|
|
106
|
-
updatedConfig = (0, migrations_1.updateObjectProperty)(updatedConfig, componentProperty, {
|
|
107
|
-
newValue: (0, migrations_1.removeObjectProperty)(
|
|
108
|
-
// we only determine that it's skipping if it's an object literal
|
|
109
|
-
componentProperty.initializer, (0, migrations_1.getObjectProperty)(componentProperty.initializer, 'experimentalSkipDomainInjection')),
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
81
|
if (topLevelSkipDomainState === 'not-set' &&
|
|
114
82
|
!e2eProperty &&
|
|
115
|
-
|
|
83
|
+
hasOtherTopLevelProperties) {
|
|
116
84
|
updatedConfig = setInjectDocumentDomainInObject(updatedConfig);
|
|
117
85
|
}
|
|
118
86
|
else if (topLevelSkipDomainState === 'not-skipping') {
|
package/src/plugins/plugin.js
CHANGED
|
@@ -327,7 +327,10 @@ async function buildCypressTargets(configFilePath, projectRoot, options, context
|
|
|
327
327
|
}
|
|
328
328
|
targets[options.openTargetName] = {
|
|
329
329
|
command: `cypress open`,
|
|
330
|
-
options: {
|
|
330
|
+
options: {
|
|
331
|
+
cwd: projectRoot,
|
|
332
|
+
env: { TS_NODE_COMPILER_OPTIONS: tsNodeCompilerOptions },
|
|
333
|
+
},
|
|
331
334
|
metadata: {
|
|
332
335
|
technologies: ['cypress'],
|
|
333
336
|
description: 'Opens Cypress',
|