@nx/cypress 23.0.0-beta.12 → 23.0.0-beta.13
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 +5 -5
- package/plugins/cypress-preset.js +2 -2
- package/src/generators/base-setup/base-setup.js +2 -2
- package/src/generators/component-configuration/component-configuration.d.ts.map +1 -1
- package/src/generators/component-configuration/component-configuration.js +21 -10
- package/src/generators/configuration/configuration.js +5 -7
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +19 -8
- package/src/generators/migrate-to-cypress-11/conversion.util.d.ts.map +1 -1
- package/src/generators/migrate-to-cypress-11/conversion.util.js +5 -6
- package/src/migrations/update-20-8-0/remove-experimental-fetch-polyfill.js +2 -2
- package/src/migrations/update-20-8-0/replace-experimental-just-in-time-compile.js +2 -2
- package/src/migrations/update-20-8-0/set-inject-document-domain.js +2 -2
- package/src/migrations/update-20-8-0/update-component-testing-mount-imports.js +2 -2
- package/src/migrations/update-21-0-0/remove-tsconfig-and-copy-files-options-from-cypress-executor.d.ts.map +1 -1
- package/src/migrations/update-21-0-0/remove-tsconfig-and-copy-files-options-from-cypress-executor.js +27 -15
- package/src/migrations/update-22-1-0/rename-cy-exec-code-property.js +4 -4
- package/src/migrations/update-22-1-0/update-angular-component-testing-support.js +4 -4
- package/src/migrations/update-22-1-0/update-selector-playground-api.js +3 -3
- package/src/utils/config.js +3 -3
- package/src/utils/migrations.js +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/cypress",
|
|
3
|
-
"version": "23.0.0-beta.
|
|
3
|
+
"version": "23.0.0-beta.13",
|
|
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": {
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"migrations": "./migrations.json"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@nx/devkit": "23.0.0-beta.
|
|
41
|
-
"@nx/eslint": "23.0.0-beta.
|
|
42
|
-
"@nx/js": "23.0.0-beta.
|
|
40
|
+
"@nx/devkit": "23.0.0-beta.13",
|
|
41
|
+
"@nx/eslint": "23.0.0-beta.13",
|
|
42
|
+
"@nx/js": "23.0.0-beta.13",
|
|
43
43
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
44
44
|
"detect-port": "^2.1.0",
|
|
45
45
|
"semver": "^7.6.3",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"tslib": "^2.3.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"nx": "23.0.0-beta.
|
|
50
|
+
"nx": "23.0.0-beta.13"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"cypress": ">= 13 < 16"
|
|
@@ -4,7 +4,7 @@ exports.nxBaseCypressPreset = nxBaseCypressPreset;
|
|
|
4
4
|
exports.nxE2EPreset = nxE2EPreset;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const
|
|
7
|
+
const internal_1 = require("@nx/js/internal");
|
|
8
8
|
const child_process_1 = require("child_process");
|
|
9
9
|
const fs_1 = require("fs");
|
|
10
10
|
const http_1 = require("http");
|
|
@@ -24,7 +24,7 @@ function nxBaseCypressPreset(pathToConfig, options) {
|
|
|
24
24
|
: (0, path_1.dirname)(pathToConfig);
|
|
25
25
|
const projectPath = (0, path_1.relative)(devkit_1.workspaceRoot, normalizedPath);
|
|
26
26
|
const offset = (0, path_1.relative)(normalizedPath, devkit_1.workspaceRoot);
|
|
27
|
-
const isTsSolutionSetup = (0,
|
|
27
|
+
const isTsSolutionSetup = (0, internal_1.isUsingTsSolutionSetup)();
|
|
28
28
|
const videosFolder = isTsSolutionSetup
|
|
29
29
|
? (0, path_1.join)('test-output', 'cypress', 'videos')
|
|
30
30
|
: (0, path_1.join)(offset, 'dist', 'cypress', projectPath, 'videos');
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addBaseCypressSetup = addBaseCypressSetup;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const js_1 = require("@nx/js");
|
|
6
|
-
const
|
|
6
|
+
const internal_1 = require("@nx/js/internal");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
function addBaseCypressSetup(tree, options) {
|
|
9
9
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
@@ -12,7 +12,7 @@ function addBaseCypressSetup(tree, options) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
const opts = normalizeOptions(tree, projectConfig, options);
|
|
15
|
-
const isUsingTsSolutionConfig = (0,
|
|
15
|
+
const isUsingTsSolutionConfig = (0, internal_1.isUsingTsSolutionSetup)(tree);
|
|
16
16
|
const templateVars = {
|
|
17
17
|
...opts,
|
|
18
18
|
jsx: !!opts.jsx,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/component-configuration/component-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAGjB,oBAAoB,EAKpB,IAAI,EAIL,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"component-configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/component-configuration/component-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAGjB,oBAAoB,EAKpB,IAAI,EAIL,MAAM,YAAY,CAAC;AAWpB,OAAO,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAI/D,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,mCAAmC,8BAM7C;AAED,wBAAsB,uCAAuC,CAC3D,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,mCAAmC,8BA6C7C;AA2HD,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,oBAAoB,QAsDpC;AAOD,eAAe,+BAA+B,CAAC"}
|
|
@@ -5,7 +5,8 @@ exports.componentConfigurationGeneratorInternal = componentConfigurationGenerato
|
|
|
5
5
|
exports.updateTsConfigForComponentTesting = updateTsConfigForComponentTesting;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const
|
|
8
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
9
|
+
const internal_2 = require("@nx/js/internal");
|
|
9
10
|
const assert_supported_cypress_version_1 = require("../../utils/assert-supported-cypress-version");
|
|
10
11
|
const deprecation_1 = require("../../utils/deprecation");
|
|
11
12
|
const versions_1 = require("../../utils/versions");
|
|
@@ -19,7 +20,7 @@ function componentConfigurationGenerator(tree, options) {
|
|
|
19
20
|
}
|
|
20
21
|
async function componentConfigurationGeneratorInternal(tree, options) {
|
|
21
22
|
(0, assert_supported_cypress_version_1.assertSupportedCypressVersion)(tree);
|
|
22
|
-
(0,
|
|
23
|
+
(0, internal_2.assertNotUsingTsSolutionSetup)(tree, 'cypress', 'component-configuration');
|
|
23
24
|
const tasks = [];
|
|
24
25
|
const opts = normalizeOptions(tree, options);
|
|
25
26
|
if (!(0, versions_1.getInstalledCypressMajorVersion)(tree)) {
|
|
@@ -115,14 +116,24 @@ function updateNxJsonConfiguration(tree, hasPlugin) {
|
|
|
115
116
|
!cacheableOperations.includes('component-test')) {
|
|
116
117
|
cacheableOperations.push('component-test');
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
nxJson.targetDefaults
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
// Either a `target: 'component-test'` default or a default keyed on
|
|
120
|
+
// the executor we're scaffolding will apply to the new target — pick
|
|
121
|
+
// the more specific (target-keyed) when both are present.
|
|
122
|
+
const existingForTarget = (0, internal_1.findTargetDefault)(nxJson.targetDefaults, {
|
|
123
|
+
target: 'component-test',
|
|
124
|
+
});
|
|
125
|
+
const existingForExecutor = (0, internal_1.findTargetDefault)(nxJson.targetDefaults, {
|
|
126
|
+
executor: '@nx/cypress:cypress',
|
|
127
|
+
});
|
|
128
|
+
const existing = existingForTarget ?? existingForExecutor;
|
|
129
|
+
(0, internal_1.upsertTargetDefault)(tree, nxJson, {
|
|
130
|
+
target: 'component-test',
|
|
131
|
+
cache: existing?.cache ?? true,
|
|
132
|
+
inputs: existing?.inputs ?? [
|
|
133
|
+
'default',
|
|
134
|
+
productionFileSet ? '^production' : '^default',
|
|
135
|
+
],
|
|
136
|
+
});
|
|
126
137
|
}
|
|
127
138
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
128
139
|
}
|
|
@@ -6,9 +6,7 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const internal_1 = require("@nx/devkit/internal");
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
8
|
const js_1 = require("@nx/js");
|
|
9
|
-
const
|
|
10
|
-
const package_manager_workspaces_1 = require("@nx/js/src/utils/package-manager-workspaces");
|
|
11
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
9
|
+
const internal_2 = require("@nx/js/internal");
|
|
12
10
|
const path_1 = require("path");
|
|
13
11
|
const add_linter_1 = require("../../utils/add-linter");
|
|
14
12
|
const assert_supported_cypress_version_1 = require("../../utils/assert-supported-cypress-version");
|
|
@@ -62,7 +60,7 @@ async function configurationGeneratorInternal(tree, options) {
|
|
|
62
60
|
});
|
|
63
61
|
}
|
|
64
62
|
const { root: projectRoot } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
65
|
-
const isTsSolutionSetup = (0,
|
|
63
|
+
const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(tree);
|
|
66
64
|
if (isTsSolutionSetup) {
|
|
67
65
|
createPackageJson(tree, opts);
|
|
68
66
|
ignoreTestOutput(tree);
|
|
@@ -87,9 +85,9 @@ async function configurationGeneratorInternal(tree, options) {
|
|
|
87
85
|
await (0, devkit_1.formatFiles)(tree);
|
|
88
86
|
}
|
|
89
87
|
if (isTsSolutionSetup) {
|
|
90
|
-
const projectPackageManagerWorkspaceState = (0,
|
|
88
|
+
const projectPackageManagerWorkspaceState = (0, internal_2.getProjectPackageManagerWorkspaceState)(tree, projectRoot);
|
|
91
89
|
if (projectPackageManagerWorkspaceState !== 'included') {
|
|
92
|
-
tasks.push((0,
|
|
90
|
+
tasks.push((0, internal_2.getProjectPackageManagerWorkspaceStateWarningTask)(projectPackageManagerWorkspaceState, tree.root));
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
@@ -105,7 +103,7 @@ function ensureDependencies(tree, options) {
|
|
|
105
103
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, true);
|
|
106
104
|
}
|
|
107
105
|
async function normalizeOptions(tree, options) {
|
|
108
|
-
const linter = await (0,
|
|
106
|
+
const linter = await (0, internal_2.normalizeLinterOption)(tree, options.linter);
|
|
109
107
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
110
108
|
if (projectConfig?.targets?.e2e) {
|
|
111
109
|
throw new Error(`Project ${options.project} already has an e2e target.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/init/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/init/init.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,iBAAiB,EACjB,YAAY,EAMZ,IAAI,EAEL,MAAM,YAAY,CAAC;AAQpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA4DlC,wBAAgB,SAAS,CACvB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,YAAY,EACnB,oBAAoB,EAAE,OAAO,iBAmB9B;AAmBD,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,8BAErE;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,8BAgChB;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -14,15 +14,26 @@ function setupE2ETargetDefaults(tree) {
|
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
// E2e targets depend on all their project's sources + production sources of dependencies
|
|
17
|
-
nxJson.targetDefaults ??= {};
|
|
18
17
|
const productionFileSet = !!nxJson.namedInputs?.production;
|
|
19
|
-
nxJson.targetDefaults
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
const existing = findExistingE2eDefault(nxJson.targetDefaults);
|
|
19
|
+
const patch = {};
|
|
20
|
+
if (existing?.cache === undefined)
|
|
21
|
+
patch.cache = true;
|
|
22
|
+
if (existing?.inputs === undefined) {
|
|
23
|
+
patch.inputs = ['default', productionFileSet ? '^production' : '^default'];
|
|
24
|
+
}
|
|
25
|
+
if (Object.keys(patch).length > 0) {
|
|
26
|
+
(0, internal_1.upsertTargetDefault)(tree, nxJson, { target: 'e2e', ...patch });
|
|
27
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function findExistingE2eDefault(td) {
|
|
31
|
+
if (!td)
|
|
32
|
+
return undefined;
|
|
33
|
+
if (Array.isArray(td)) {
|
|
34
|
+
return td.find((e) => e.target === 'e2e' && e.projects === undefined && e.plugin === undefined);
|
|
35
|
+
}
|
|
36
|
+
return td['e2e'];
|
|
26
37
|
}
|
|
27
38
|
function updateDependencies(tree, options) {
|
|
28
39
|
const tasks = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion.util.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/migrate-to-cypress-11/conversion.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EAGpB,IAAI,EAGL,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"conversion.util.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/migrate-to-cypress-11/conversion.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EAGpB,IAAI,EAGL,MAAM,YAAY,CAAC;AAiBpB,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,oBAAoB,EACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb;IACD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CA4BA;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,oBAAoB,EACnC,qBAAqB,EAAE,MAAM,GAC5B;IACD,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACxC,CAoCA;AAED,wBAAgB,uBAAuB,CACrC,kBAAkB,EAAE,MAAM,EAC1B,kBAAkB,EAAE,MAAM,EAC1B,iBAAiB,EAAE,MAAM,GACxB;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAiC1D;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,oBAAoB,EACnC,EACE,eAAe,EACf,iBAAiB,GAClB,EAAE;IACD,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACxC,QAqGF;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,QA8BtB;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,mBAAmB,EAAE,MAAM,EAC3B,cAAc,EAAE;IACd,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACxC,QA+BF;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,MAAM,QAkB1B;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,oBAAoB,EACnC,cAAc,EAAE;IACd,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACxC;qBAFkB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;uBACjB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;;uBAAnB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;EAmCzC"}
|
|
@@ -9,8 +9,7 @@ exports.writeNewConfig = writeNewConfig;
|
|
|
9
9
|
exports.addConfigToTsConfig = addConfigToTsConfig;
|
|
10
10
|
exports.updatePluginFile = updatePluginFile;
|
|
11
11
|
const devkit_1 = require("@nx/devkit");
|
|
12
|
-
const
|
|
13
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
12
|
+
const internal_1 = require("@nx/js/internal");
|
|
14
13
|
const path_1 = require("path");
|
|
15
14
|
let tsModule;
|
|
16
15
|
let tsquery;
|
|
@@ -51,7 +50,7 @@ function createNewCypressConfig(tree, projectConfig, cypressConfigPathJson) {
|
|
|
51
50
|
const { modifyObstructiveCode = null, // no longer needed in configs
|
|
52
51
|
integrationFolder = 'src/e2e', // provide the new defaults if the value isn't present
|
|
53
52
|
supportFile = 'src/support/e2e.ts', ...restOfConfig } = cypressConfigJson;
|
|
54
|
-
const sourceRoot = (0,
|
|
53
|
+
const sourceRoot = (0, internal_1.getProjectSourceRoot)(projectConfig, tree);
|
|
55
54
|
const newIntegrationFolder = tree.exists((0, devkit_1.joinPathFragments)(sourceRoot, 'integration'))
|
|
56
55
|
? 'src/e2e'
|
|
57
56
|
: integrationFolder;
|
|
@@ -99,7 +98,7 @@ function createSupportFileImport(oldSupportFilePath, newSupportFilePath, project
|
|
|
99
98
|
}
|
|
100
99
|
function updateProjectPaths(tree, projectConfig, { cypressConfigTs, cypressConfigJson, }) {
|
|
101
100
|
const { integrationFolder, supportFile } = cypressConfigTs['e2e'];
|
|
102
|
-
const sourceRoot = (0,
|
|
101
|
+
const sourceRoot = (0, internal_1.getProjectSourceRoot)(projectConfig, tree);
|
|
103
102
|
const oldIntegrationFolder = (0, devkit_1.joinPathFragments)(projectConfig.root, cypressConfigJson.integrationFolder);
|
|
104
103
|
const newIntegrationFolder = (0, devkit_1.joinPathFragments)(projectConfig.root, integrationFolder);
|
|
105
104
|
let newSupportFile;
|
|
@@ -165,10 +164,10 @@ function updateProjectPaths(tree, projectConfig, { cypressConfigTs, cypressConfi
|
|
|
165
164
|
}
|
|
166
165
|
function updateImports(tree, filePath, oldImportPath, newImportPath) {
|
|
167
166
|
if (!tsModule) {
|
|
168
|
-
tsModule = (0,
|
|
167
|
+
tsModule = (0, internal_1.ensureTypescript)();
|
|
169
168
|
}
|
|
170
169
|
if (!tsquery) {
|
|
171
|
-
(0,
|
|
170
|
+
(0, internal_1.ensureTypescript)();
|
|
172
171
|
tsquery = require('@phenomnomnominal/tsquery').tsquery;
|
|
173
172
|
}
|
|
174
173
|
const { isCallExpression, isExportDeclaration, isImportDeclaration } = tsModule;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/js/internal");
|
|
6
6
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
7
|
const config_1 = require("../../utils/config");
|
|
8
8
|
const migrations_1 = require("../../utils/migrations");
|
|
@@ -15,7 +15,7 @@ async function default_1(tree) {
|
|
|
15
15
|
// cypress config file doesn't exist, so skip
|
|
16
16
|
continue;
|
|
17
17
|
}
|
|
18
|
-
ts ??= (0,
|
|
18
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
19
19
|
printer ??= ts.createPrinter();
|
|
20
20
|
const cypressConfig = tree.read(cypressConfigPath, 'utf-8');
|
|
21
21
|
const updatedConfig = removeExperimentalFetchPolyfill(cypressConfig);
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
-
const
|
|
6
|
+
const internal_2 = require("@nx/js/internal");
|
|
7
7
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
8
8
|
const node_path_1 = require("node:path");
|
|
9
9
|
const config_1 = require("../../utils/config");
|
|
@@ -33,7 +33,7 @@ async function updateCtJustInTimeCompile(tree, cypressConfigPath) {
|
|
|
33
33
|
// no component config, leave as is
|
|
34
34
|
return cypressConfig;
|
|
35
35
|
}
|
|
36
|
-
ts ??= (0,
|
|
36
|
+
ts ??= (0, internal_2.ensureTypescript)();
|
|
37
37
|
printer ??= ts.createPrinter();
|
|
38
38
|
const sourceFile = (0, tsquery_1.ast)(cypressConfig);
|
|
39
39
|
let updatedConfig = config;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/js/internal");
|
|
6
6
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
7
|
const config_1 = require("../../utils/config");
|
|
8
8
|
const migrations_1 = require("../../utils/migrations");
|
|
@@ -16,7 +16,7 @@ async function default_1(tree) {
|
|
|
16
16
|
// cypress config file doesn't exist, so skip
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
|
-
ts ??= (0,
|
|
19
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
20
20
|
printer ??= ts.createPrinter();
|
|
21
21
|
const cypressConfig = tree.read(cypressConfigPath, 'utf-8');
|
|
22
22
|
const updatedConfig = setInjectDocumentDomain(cypressConfig);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/js/internal");
|
|
6
6
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
7
|
const semver_1 = require("semver");
|
|
8
8
|
const config_1 = require("../../utils/config");
|
|
@@ -16,7 +16,7 @@ async function default_1(tree) {
|
|
|
16
16
|
// cypress config file doesn't exist, so skip
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
|
-
ts ??= (0,
|
|
19
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
20
20
|
printer ??= ts.createPrinter();
|
|
21
21
|
const migrationInfo = parseMigrationInfo(tree, cypressConfigPath, projectName, projectGraph);
|
|
22
22
|
if (!migrationInfo) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-tsconfig-and-copy-files-options-from-cypress-executor.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/migrations/update-21-0-0/remove-tsconfig-and-copy-files-options-from-cypress-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remove-tsconfig-and-copy-files-options-from-cypress-executor.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/migrations/update-21-0-0/remove-tsconfig-and-copy-files-options-from-cypress-executor.ts"],"names":[],"mappings":"AAKA,OAAO,EAML,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAKpB,yBAA+B,IAAI,EAAE,IAAI,iBAmExC"}
|
package/src/migrations/update-21-0-0/remove-tsconfig-and-copy-files-options-from-cypress-executor.js
CHANGED
|
@@ -22,25 +22,37 @@ async function default_1(tree) {
|
|
|
22
22
|
// update options from nx.json target defaults
|
|
23
23
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
24
24
|
if (nxJson.targetDefaults) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const originalShape = nxJson.targetDefaults;
|
|
26
|
+
const entries = (0, internal_1.normalizeTargetDefaults)(originalShape);
|
|
27
|
+
const remaining = [];
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
const matches = entry.executor === EXECUTOR_TO_MIGRATE ||
|
|
30
|
+
entry.target === EXECUTOR_TO_MIGRATE;
|
|
31
|
+
if (!matches) {
|
|
32
|
+
remaining.push(entry);
|
|
28
33
|
continue;
|
|
29
34
|
}
|
|
30
|
-
if (
|
|
31
|
-
updateOptions(
|
|
35
|
+
if (entry.options) {
|
|
36
|
+
updateOptions(entry);
|
|
32
37
|
}
|
|
33
|
-
Object.keys(
|
|
34
|
-
updateConfiguration(
|
|
38
|
+
Object.keys(entry.configurations ?? {}).forEach((config) => {
|
|
39
|
+
updateConfiguration(entry, config);
|
|
35
40
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const meaningfulKeys = Object.keys(entry).filter((k) => k !== 'target' &&
|
|
42
|
+
k !== 'executor' &&
|
|
43
|
+
k !== 'projects' &&
|
|
44
|
+
k !== 'plugin');
|
|
45
|
+
if (meaningfulKeys.length === 0)
|
|
46
|
+
continue;
|
|
47
|
+
remaining.push(entry);
|
|
48
|
+
}
|
|
49
|
+
if (remaining.length === 0) {
|
|
50
|
+
delete nxJson.targetDefaults;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
nxJson.targetDefaults = Array.isArray(originalShape)
|
|
54
|
+
? remaining
|
|
55
|
+
: (0, internal_1.downgradeTargetDefaults)(remaining);
|
|
44
56
|
}
|
|
45
57
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
46
58
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = renameCyExecCodeProperty;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/js/internal");
|
|
6
6
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
7
|
const migrations_1 = require("../../utils/migrations");
|
|
8
8
|
let ts;
|
|
@@ -28,7 +28,7 @@ function updateCyExecItsCalls(fileContent) {
|
|
|
28
28
|
!fileContent.includes('its(`code`)')) {
|
|
29
29
|
return fileContent;
|
|
30
30
|
}
|
|
31
|
-
ts ??= (0,
|
|
31
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
32
32
|
const sourceFile = (0, tsquery_1.ast)(fileContent);
|
|
33
33
|
const updates = [];
|
|
34
34
|
const callExpressions = (0, tsquery_1.query)(sourceFile, 'CallExpression:has(PropertyAccessExpression > Identifier[name="its"])');
|
|
@@ -62,7 +62,7 @@ function shouldUpdateCallExpression(node) {
|
|
|
62
62
|
if (!node.arguments.length) {
|
|
63
63
|
return false;
|
|
64
64
|
}
|
|
65
|
-
ts ??= (0,
|
|
65
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
66
66
|
const firstArg = node.arguments[0];
|
|
67
67
|
if (!(ts.isStringLiteral(firstArg) ||
|
|
68
68
|
ts.isNoSubstitutionTemplateLiteral(firstArg)) ||
|
|
@@ -78,7 +78,7 @@ function shouldUpdateCallExpression(node) {
|
|
|
78
78
|
return isDerivedFromCyExec(node.expression.expression);
|
|
79
79
|
}
|
|
80
80
|
function isDerivedFromCyExec(expression) {
|
|
81
|
-
ts ??= (0,
|
|
81
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
82
82
|
if (ts.isCallExpression(expression)) {
|
|
83
83
|
return isDerivedFromCyExec(expression.expression);
|
|
84
84
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = updateAngularComponentTestingSupport;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/js/internal");
|
|
6
6
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
7
|
const semver_1 = require("semver");
|
|
8
8
|
const config_1 = require("../../utils/config");
|
|
@@ -33,7 +33,7 @@ async function updateAngularComponentTestingSupport(tree) {
|
|
|
33
33
|
await (0, devkit_1.formatFiles)(tree);
|
|
34
34
|
}
|
|
35
35
|
async function getMigrationInfo(tree, cypressConfigPath, projectName, projectGraph) {
|
|
36
|
-
ts ??= (0,
|
|
36
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
37
37
|
const cypressConfig = tree.read(cypressConfigPath, 'utf-8');
|
|
38
38
|
const config = (0, config_1.resolveCypressConfigObject)(cypressConfig);
|
|
39
39
|
if (!config) {
|
|
@@ -54,7 +54,7 @@ async function getMigrationInfo(tree, cypressConfigPath, projectName, projectGra
|
|
|
54
54
|
return (0, semver_1.lt)(angularVersion, DEPRECATED_MAX_ANGULAR_VERSION);
|
|
55
55
|
}
|
|
56
56
|
function migrateProject(tree, projectConfig) {
|
|
57
|
-
ts ??= (0,
|
|
57
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
58
58
|
printer ??= ts.createPrinter();
|
|
59
59
|
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
|
|
60
60
|
if (!isJsTsFile(filePath) || !tree.exists(filePath)) {
|
|
@@ -76,7 +76,7 @@ function migrateProject(tree, projectConfig) {
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
function resolveFramework(cypressConfig, config, projectName, projectGraph) {
|
|
79
|
-
ts ??= (0,
|
|
79
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
80
80
|
const frameworkProperty = (0, tsquery_1.query)(config, 'PropertyAssignment:has(Identifier[name=component]) PropertyAssignment:has(Identifier[name=devServer]) PropertyAssignment:has(Identifier[name=framework])')[0];
|
|
81
81
|
if (frameworkProperty) {
|
|
82
82
|
return ts.isStringLiteral(frameworkProperty.initializer)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = updateSelectorPlaygroundApi;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/js/internal");
|
|
6
6
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
7
|
const migrations_1 = require("../../utils/migrations");
|
|
8
8
|
let printer;
|
|
@@ -31,7 +31,7 @@ function migrateSelectorPlaygroundApi(fileContent) {
|
|
|
31
31
|
!updated.includes('Cypress.SelectorPlayground')) {
|
|
32
32
|
return updated;
|
|
33
33
|
}
|
|
34
|
-
ts ??= (0,
|
|
34
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
35
35
|
printer ??= ts.createPrinter();
|
|
36
36
|
const sourceFile = (0, tsquery_1.ast)(updated);
|
|
37
37
|
let hasChanges = false;
|
|
@@ -85,7 +85,7 @@ function migrateSelectorPlaygroundApi(fileContent) {
|
|
|
85
85
|
return hasChanges ? result : updated;
|
|
86
86
|
}
|
|
87
87
|
function isOnElementProperty(name) {
|
|
88
|
-
ts ??= (0,
|
|
88
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
89
89
|
if (ts.isIdentifier(name)) {
|
|
90
90
|
return name.text === 'onElement';
|
|
91
91
|
}
|
package/src/utils/config.js
CHANGED
|
@@ -40,7 +40,7 @@ exports.addMountDefinition = addMountDefinition;
|
|
|
40
40
|
exports.getProjectCypressConfigPath = getProjectCypressConfigPath;
|
|
41
41
|
exports.resolveCypressConfigObject = resolveCypressConfigObject;
|
|
42
42
|
const devkit_1 = require("@nx/devkit");
|
|
43
|
-
const
|
|
43
|
+
const internal_1 = require("@nx/js/internal");
|
|
44
44
|
exports.CYPRESS_CONFIG_FILE_NAME_PATTERN = 'cypress.config.{js,ts,mjs,cjs}';
|
|
45
45
|
const TS_QUERY_COMMON_JS_EXPORT_SELECTOR = 'BinaryExpression:has(Identifier[name="module"]):has(Identifier[name="exports"])';
|
|
46
46
|
const TS_QUERY_EXPORT_CONFIG_PREFIX = `:matches(ExportAssignment, ${TS_QUERY_COMMON_JS_EXPORT_SELECTOR}) `;
|
|
@@ -153,7 +153,7 @@ function getProjectCypressConfigPath(tree, projectRoot) {
|
|
|
153
153
|
return cypressConfigPaths[0];
|
|
154
154
|
}
|
|
155
155
|
function resolveCypressConfigObject(cypressConfigContents) {
|
|
156
|
-
const ts = (0,
|
|
156
|
+
const ts = (0, internal_1.ensureTypescript)();
|
|
157
157
|
const { tsquery } = (require('@phenomnomnominal/tsquery'));
|
|
158
158
|
const sourceFile = tsquery.ast(cypressConfigContents);
|
|
159
159
|
const exportDefaultStatement = sourceFile.statements.find((statement) => ts.isExportAssignment(statement));
|
|
@@ -169,7 +169,7 @@ function resolveCypressConfigObject(cypressConfigContents) {
|
|
|
169
169
|
return null;
|
|
170
170
|
}
|
|
171
171
|
function resolveCypressConfigObjectFromExportExpression(exportExpression, sourceFile) {
|
|
172
|
-
const ts = (0,
|
|
172
|
+
const ts = (0, internal_1.ensureTypescript)();
|
|
173
173
|
if (ts.isObjectLiteralExpression(exportExpression)) {
|
|
174
174
|
return exportExpression;
|
|
175
175
|
}
|
package/src/utils/migrations.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.getObjectProperty = getObjectProperty;
|
|
|
5
5
|
exports.removeObjectProperty = removeObjectProperty;
|
|
6
6
|
exports.updateObjectProperty = updateObjectProperty;
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const
|
|
8
|
+
const internal_1 = require("@nx/js/internal");
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
const config_1 = require("./config");
|
|
11
11
|
let ts;
|
|
@@ -40,15 +40,15 @@ async function* cypressProjectConfigs(tree) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function getObjectProperty(config, name) {
|
|
43
|
-
ts ??= (0,
|
|
43
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
44
44
|
return config.properties.find((p) => ts.isPropertyAssignment(p) && p.name.getText() === name);
|
|
45
45
|
}
|
|
46
46
|
function removeObjectProperty(config, property) {
|
|
47
|
-
ts ??= (0,
|
|
47
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
48
48
|
return ts.factory.updateObjectLiteralExpression(config, config.properties.filter((p) => p !== property));
|
|
49
49
|
}
|
|
50
50
|
function updateObjectProperty(config, property, { newName, newValue }) {
|
|
51
|
-
ts ??= (0,
|
|
51
|
+
ts ??= (0, internal_1.ensureTypescript)();
|
|
52
52
|
if (!newName && !newValue) {
|
|
53
53
|
throw new Error('newName or newValue must be provided');
|
|
54
54
|
}
|