@nx/cypress 23.0.0-beta.2 → 23.0.0-beta.20
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/{index.d.ts → dist/index.d.ts} +0 -1
- package/dist/internal.d.ts +5 -0
- package/dist/internal.js +12 -0
- package/{plugin.d.ts → dist/plugin.d.ts} +0 -1
- package/{plugins → dist/plugins}/cypress-preset.d.ts +0 -1
- package/{plugins → dist/plugins}/cypress-preset.js +15 -5
- package/{src → dist/src}/executors/cypress/cypress.impl.d.ts +0 -1
- package/{src → dist/src}/executors/cypress/cypress.impl.js +2 -0
- package/{src → dist/src}/executors/cypress/schema.json +1 -0
- package/{src → dist/src}/generators/base-setup/base-setup.d.ts +0 -1
- package/{src → dist/src}/generators/base-setup/base-setup.js +5 -19
- package/dist/src/generators/base-setup/files/config-ts-cjs/cypress.config.ts__ext__ +3 -0
- package/dist/src/generators/base-setup/files/config-ts-esm/__directory__/support/commands.ts__ext__ +35 -0
- package/{src → dist/src}/generators/component-configuration/component-configuration.d.ts +0 -1
- package/{src → dist/src}/generators/component-configuration/component-configuration.js +25 -22
- package/{src → dist/src}/generators/configuration/configuration.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/configuration.js +12 -11
- package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.js +7 -6
- package/{src → dist/src}/generators/convert-to-inferred/lib/add-dev-server-target-to-config.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/lib/add-exclude-spec-pattern.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/lib/target-options-map.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/lib/upsert-baseUrl.d.ts +0 -1
- package/{src → dist/src}/generators/init/init.d.ts +0 -1
- package/{src → dist/src}/generators/init/init.js +24 -11
- package/{src → dist/src}/generators/init/schema.json +1 -1
- package/{src → dist/src}/generators/migrate-to-cypress-11/conversion.util.d.ts +0 -1
- package/{src → dist/src}/generators/migrate-to-cypress-11/conversion.util.js +5 -6
- package/{src → dist/src}/generators/migrate-to-cypress-11/migrate-to-cypress-11.d.ts +0 -1
- package/{src → dist/src}/generators/migrate-to-cypress-11/migrate-to-cypress-11.js +3 -3
- package/{src → dist/src}/migrations/update-20-8-0/remove-experimental-fetch-polyfill.d.ts +0 -1
- package/{src → dist/src}/migrations/update-20-8-0/remove-experimental-fetch-polyfill.js +2 -2
- package/{src → dist/src}/migrations/update-20-8-0/replace-experimental-just-in-time-compile.d.ts +0 -1
- package/{src → dist/src}/migrations/update-20-8-0/replace-experimental-just-in-time-compile.js +4 -4
- package/{src → dist/src}/migrations/update-20-8-0/set-inject-document-domain.d.ts +0 -1
- package/{src → dist/src}/migrations/update-20-8-0/set-inject-document-domain.js +2 -2
- package/{src → dist/src}/migrations/update-20-8-0/update-component-testing-mount-imports.d.ts +0 -1
- package/{src → dist/src}/migrations/update-20-8-0/update-component-testing-mount-imports.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-tsconfig-and-copy-files-options-from-cypress-executor.d.ts +2 -0
- package/{src → dist/src}/migrations/update-21-0-0/remove-tsconfig-and-copy-files-options-from-cypress-executor.js +29 -17
- package/{src → dist/src}/migrations/update-22-1-0/rename-cy-exec-code-property.d.ts +0 -1
- package/{src → dist/src}/migrations/update-22-1-0/rename-cy-exec-code-property.js +4 -4
- package/{src → dist/src}/migrations/update-22-1-0/update-angular-component-testing-support.d.ts +0 -1
- package/{src → dist/src}/migrations/update-22-1-0/update-angular-component-testing-support.js +4 -4
- package/{src → dist/src}/migrations/update-22-1-0/update-selector-playground-api.d.ts +0 -1
- package/{src → dist/src}/migrations/update-22-1-0/update-selector-playground-api.js +3 -3
- package/dist/src/migrations/update-23-0-0/remove-experimental-prompt-command.d.ts +2 -0
- package/dist/src/migrations/update-23-0-0/remove-experimental-prompt-command.js +47 -0
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +199 -0
- package/{src → dist/src}/plugins/plugin.d.ts +0 -1
- package/{src → dist/src}/plugins/plugin.js +88 -40
- package/{src → dist/src}/plugins/preprocessor-vite.d.ts +0 -1
- package/{src → dist/src}/utils/add-linter.d.ts +0 -1
- package/{src → dist/src}/utils/add-linter.js +16 -18
- package/dist/src/utils/assert-supported-cypress-version.d.ts +2 -0
- package/dist/src/utils/assert-supported-cypress-version.js +8 -0
- package/{src → dist/src}/utils/config.d.ts +10 -5
- package/{src → dist/src}/utils/config.js +52 -48
- package/{src → dist/src}/utils/constants.d.ts +0 -1
- package/{src → dist/src}/utils/ct-helpers.d.ts +0 -1
- package/dist/src/utils/deprecation.d.ts +3 -0
- package/dist/src/utils/deprecation.js +20 -0
- package/{src → dist/src}/utils/find-target-options.d.ts +0 -1
- package/{src → dist/src}/utils/migrations.d.ts +0 -1
- package/{src → dist/src}/utils/migrations.js +4 -4
- package/{src → dist/src}/utils/project-name.d.ts +0 -1
- package/{src → dist/src}/utils/start-dev-server.d.ts +0 -1
- package/{src → dist/src}/utils/versions.d.ts +5 -5
- package/{src → dist/src}/utils/versions.js +14 -51
- package/executors.json +2 -2
- package/generators.json +10 -10
- package/migrations.json +45 -8
- package/package.json +59 -12
- package/index.d.ts.map +0 -1
- package/plugin.d.ts.map +0 -1
- package/plugins/cypress-preset.d.ts.map +0 -1
- package/src/executors/cypress/cypress.impl.d.ts.map +0 -1
- package/src/generators/base-setup/base-setup.d.ts.map +0 -1
- package/src/generators/component-configuration/component-configuration.d.ts.map +0 -1
- package/src/generators/configuration/configuration.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/add-dev-server-target-to-config.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/add-exclude-spec-pattern.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/target-options-map.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/upsert-baseUrl.d.ts.map +0 -1
- package/src/generators/init/init.d.ts.map +0 -1
- package/src/generators/migrate-to-cypress-11/conversion.util.d.ts.map +0 -1
- package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.d.ts.map +0 -1
- package/src/migrations/update-20-8-0/remove-experimental-fetch-polyfill.d.ts.map +0 -1
- package/src/migrations/update-20-8-0/replace-experimental-just-in-time-compile.d.ts.map +0 -1
- package/src/migrations/update-20-8-0/set-inject-document-domain.d.ts.map +0 -1
- package/src/migrations/update-20-8-0/update-component-testing-mount-imports.d.ts.map +0 -1
- package/src/migrations/update-21-0-0/remove-tsconfig-and-copy-files-options-from-cypress-executor.d.ts +0 -3
- package/src/migrations/update-21-0-0/remove-tsconfig-and-copy-files-options-from-cypress-executor.d.ts.map +0 -1
- package/src/migrations/update-22-1-0/rename-cy-exec-code-property.d.ts.map +0 -1
- package/src/migrations/update-22-1-0/update-angular-component-testing-support.d.ts.map +0 -1
- package/src/migrations/update-22-1-0/update-selector-playground-api.d.ts.map +0 -1
- package/src/plugins/plugin.d.ts.map +0 -1
- package/src/plugins/preprocessor-vite.d.ts.map +0 -1
- package/src/utils/add-linter.d.ts.map +0 -1
- package/src/utils/config.d.ts.map +0 -1
- package/src/utils/constants.d.ts.map +0 -1
- package/src/utils/ct-helpers.d.ts.map +0 -1
- package/src/utils/cypress-version.d.ts +0 -12
- package/src/utils/cypress-version.d.ts.map +0 -1
- package/src/utils/cypress-version.js +0 -38
- package/src/utils/find-target-options.d.ts.map +0 -1
- package/src/utils/migrations.d.ts.map +0 -1
- package/src/utils/project-name.d.ts.map +0 -1
- package/src/utils/start-dev-server.d.ts.map +0 -1
- package/src/utils/versions.d.ts.map +0 -1
- /package/{LICENSE → dist/LICENSE} +0 -0
- /package/{PLUGIN.md → dist/PLUGIN.md} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{plugin.js → dist/plugin.js} +0 -0
- /package/{src → dist/src}/generators/base-setup/files/common/__directory__/fixtures/example.json +0 -0
- /package/{src → dist/src}/generators/base-setup/files/common/__directory__/support/commands.ts__ext__ +0 -0
- /package/{src → dist/src}/generators/base-setup/files/config-js-cjs/__directory__/support/commands.js__ext__ +0 -0
- /package/{src → dist/src}/generators/base-setup/files/config-js-cjs/cypress.config.js__ext__ +0 -0
- /package/{src → dist/src}/generators/base-setup/files/config-js-esm/__directory__/support/commands.js__ext__ +0 -0
- /package/{src → dist/src}/generators/base-setup/files/config-js-esm/cypress.config.js__ext__ +0 -0
- /package/{src/generators/base-setup/files/config-ts → dist/src/generators/base-setup/files/config-ts-cjs}/__directory__/support/commands.ts__ext__ +0 -0
- /package/{src/generators/base-setup/files/config-ts → dist/src/generators/base-setup/files/config-ts-esm}/cypress.config.ts__ext__ +0 -0
- /package/{src → dist/src}/generators/base-setup/files/tsconfig/non-ts-solution/__directory__/tsconfig.json__ext__ +0 -0
- /package/{src → dist/src}/generators/base-setup/files/tsconfig/ts-solution/__directory__/tsconfig.json__ext__ +0 -0
- /package/{src → dist/src}/generators/component-configuration/files/__directory__/support/component-index.html +0 -0
- /package/{src → dist/src}/generators/component-configuration/files/__directory__/support/component.ts__ext__ +0 -0
- /package/{src → dist/src}/generators/component-configuration/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/component-configuration/schema.json +0 -0
- /package/{src → dist/src}/generators/configuration/files/__directory__/e2e/app.cy.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/__directory__/support/app.po.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/__directory__/support/e2e.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/schema.json +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/add-dev-server-target-to-config.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/add-exclude-spec-pattern.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/target-options-map.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/upsert-baseUrl.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/schema.json +0 -0
- /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/migrate-to-cypress-11/schema.json +0 -0
- /package/{src → dist/src}/plugins/preprocessor-vite.js +0 -0
- /package/{src → dist/src}/utils/constants.js +0 -0
- /package/{src → dist/src}/utils/ct-helpers.js +0 -0
- /package/{src → dist/src}/utils/find-target-options.js +0 -0
- /package/{src → dist/src}/utils/project-name.js +0 -0
- /package/{src → dist/src}/utils/start-dev-server.js +0 -0
|
@@ -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);
|
package/{src → dist/src}/migrations/update-20-8-0/replace-experimental-just-in-time-compile.js
RENAMED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
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;
|
|
@@ -85,7 +85,7 @@ async function resolveBundler(config, cypressConfigPath) {
|
|
|
85
85
|
}
|
|
86
86
|
try {
|
|
87
87
|
// we can't statically resolve the bundler from the config, so we load the config
|
|
88
|
-
const cypressConfig = await (0,
|
|
88
|
+
const cypressConfig = await (0, internal_1.loadConfigFile)((0, node_path_1.join)(devkit_1.workspaceRoot, cypressConfigPath));
|
|
89
89
|
return cypressConfig.component?.devServer?.bundler;
|
|
90
90
|
}
|
|
91
91
|
catch {
|
|
@@ -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,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = default_1;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
6
|
const EXECUTOR_TO_MIGRATE = '@nx/cypress:cypress';
|
|
7
7
|
async function default_1(tree) {
|
|
8
8
|
// update options from project configs
|
|
9
|
-
(0,
|
|
9
|
+
(0, internal_1.forEachExecutorOptions)(tree, EXECUTOR_TO_MIGRATE, (options, project, target, configuration) => {
|
|
10
10
|
if (options.tsConfig === undefined && options.copyFiles === undefined) {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
@@ -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
|
}
|
package/{src → dist/src}/migrations/update-22-1-0/update-angular-component-testing-support.js
RENAMED
|
@@ -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
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = removeExperimentalPromptCommand;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
+
const migrations_1 = require("../../utils/migrations");
|
|
7
|
+
// Match both `experimentalPromptCommand: true` and `'experimentalPromptCommand': true`
|
|
8
|
+
// (string-literal keys appear in JSON-style configs and after some formatters).
|
|
9
|
+
const SELECTOR = 'PropertyAssignment:has(Identifier[name=experimentalPromptCommand]),' +
|
|
10
|
+
'PropertyAssignment:has(StringLiteral[value=experimentalPromptCommand])';
|
|
11
|
+
async function removeExperimentalPromptCommand(tree) {
|
|
12
|
+
for await (const { cypressConfigPath } of (0, migrations_1.cypressProjectConfigs)(tree)) {
|
|
13
|
+
if (!tree.exists(cypressConfigPath)) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const contents = tree.read(cypressConfigPath, 'utf-8');
|
|
17
|
+
if (!contents.includes('experimentalPromptCommand')) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const sourceFile = (0, tsquery_1.ast)(contents);
|
|
21
|
+
// `:has()` may match nested PropertyAssignments (e.g. an outer object whose
|
|
22
|
+
// value contains the flag). Restrict to ones whose own `name` is the flag.
|
|
23
|
+
const propAssigns = (0, tsquery_1.query)(sourceFile, SELECTOR).filter((p) => {
|
|
24
|
+
const name = p.name;
|
|
25
|
+
return (
|
|
26
|
+
// Identifier name has `.text`; StringLiteral name does too.
|
|
27
|
+
'text' in name && name.text === 'experimentalPromptCommand');
|
|
28
|
+
});
|
|
29
|
+
if (propAssigns.length === 0) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
let updated = contents;
|
|
33
|
+
// Walk end-to-start so positions remain valid as we slice.
|
|
34
|
+
for (let i = propAssigns.length - 1; i >= 0; i--) {
|
|
35
|
+
const propAssign = propAssigns[i];
|
|
36
|
+
const start = propAssign.getStart(sourceFile);
|
|
37
|
+
let end = propAssign.getEnd();
|
|
38
|
+
// Eat a single trailing comma if present (prettier handles whitespace).
|
|
39
|
+
if (updated[end] === ',') {
|
|
40
|
+
end++;
|
|
41
|
+
}
|
|
42
|
+
updated = updated.slice(0, start) + updated.slice(end);
|
|
43
|
+
}
|
|
44
|
+
tree.write(cypressConfigPath, updated);
|
|
45
|
+
}
|
|
46
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
47
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = rewriteInternalSubpathImports;
|
|
4
|
+
exports.rewriteSubpathImports = rewriteSubpathImports;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const TS_EXTENSIONS = ['.ts', '.tsx', '.cts', '.mts'];
|
|
7
|
+
const FROM_PREFIX = '@nx/cypress/src/';
|
|
8
|
+
const TO_PUBLIC = '@nx/cypress';
|
|
9
|
+
const TO_INTERNAL = '@nx/cypress/internal';
|
|
10
|
+
// Symbols exported from `@nx/cypress`'s public entry (packages/cypress/index.ts).
|
|
11
|
+
// A named import/export of one of these from `@nx/cypress/src/*` is routed to
|
|
12
|
+
// the public `@nx/cypress` entry; everything else goes to `@nx/cypress/internal`.
|
|
13
|
+
const PUBLIC_SYMBOLS = new Set([
|
|
14
|
+
'configurationGenerator',
|
|
15
|
+
'componentConfigurationGenerator',
|
|
16
|
+
'cypressInitGenerator',
|
|
17
|
+
'migrateCypressProject',
|
|
18
|
+
]);
|
|
19
|
+
// Methods on `jest` and `vi` that take a module specifier as their first arg.
|
|
20
|
+
const MOCK_HELPER_METHODS = new Set([
|
|
21
|
+
'mock',
|
|
22
|
+
'unmock',
|
|
23
|
+
'doMock',
|
|
24
|
+
'dontMock',
|
|
25
|
+
'requireActual',
|
|
26
|
+
'requireMock',
|
|
27
|
+
'importActual',
|
|
28
|
+
'importMock',
|
|
29
|
+
]);
|
|
30
|
+
let ts;
|
|
31
|
+
async function rewriteInternalSubpathImports(tree) {
|
|
32
|
+
let touchedCount = 0;
|
|
33
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
34
|
+
if (!TS_EXTENSIONS.some((ext) => filePath.endsWith(ext))) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const original = tree.read(filePath, 'utf-8');
|
|
38
|
+
if (!original || !original.includes(FROM_PREFIX)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const updated = rewriteSubpathImports(original);
|
|
42
|
+
if (updated !== original) {
|
|
43
|
+
tree.write(filePath, updated);
|
|
44
|
+
touchedCount += 1;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (touchedCount > 0) {
|
|
48
|
+
devkit_1.logger.info(`Rewrote @nx/cypress/src/* imports in ${touchedCount} file(s) ` +
|
|
49
|
+
`(public symbols to @nx/cypress, internals to @nx/cypress/internal).`);
|
|
50
|
+
}
|
|
51
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
52
|
+
}
|
|
53
|
+
function rewriteSubpathImports(source) {
|
|
54
|
+
ts ??= (0, devkit_1.ensurePackage)('typescript', '*');
|
|
55
|
+
const sourceFile = ts.createSourceFile('tmp.ts', source, ts.ScriptTarget.Latest,
|
|
56
|
+
/* setParentNodes */ true, ts.ScriptKind.TSX);
|
|
57
|
+
const changes = [];
|
|
58
|
+
for (const stmt of sourceFile.statements) {
|
|
59
|
+
if (ts.isImportDeclaration(stmt)) {
|
|
60
|
+
collectImportRewrite(sourceFile, stmt, changes);
|
|
61
|
+
}
|
|
62
|
+
else if (ts.isExportDeclaration(stmt)) {
|
|
63
|
+
collectExportRewrite(sourceFile, stmt, changes);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
collectCallExpressionRewrites(sourceFile, changes);
|
|
67
|
+
return changes.length > 0 ? (0, devkit_1.applyChangesToString)(source, changes) : source;
|
|
68
|
+
}
|
|
69
|
+
function isSubpathSpecifier(node) {
|
|
70
|
+
return ts.isStringLiteral(node) && node.text.startsWith(FROM_PREFIX);
|
|
71
|
+
}
|
|
72
|
+
function collectImportRewrite(sourceFile, stmt, changes) {
|
|
73
|
+
if (!isSubpathSpecifier(stmt.moduleSpecifier)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const clause = stmt.importClause;
|
|
77
|
+
// Pure named imports (`import { a, b } from '...'`) can be split by symbol.
|
|
78
|
+
// A default or namespace import grabs the whole module, so it can't be
|
|
79
|
+
// split — route it wholesale to the internal entry.
|
|
80
|
+
if (clause &&
|
|
81
|
+
!clause.name &&
|
|
82
|
+
clause.namedBindings &&
|
|
83
|
+
ts.isNamedImports(clause.namedBindings)) {
|
|
84
|
+
rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, clause.isTypeOnly, clause.namedBindings.elements, 'import', changes);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
|
|
88
|
+
}
|
|
89
|
+
function collectExportRewrite(sourceFile, stmt, changes) {
|
|
90
|
+
if (!stmt.moduleSpecifier || !isSubpathSpecifier(stmt.moduleSpecifier)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// `export { a, b } from '...'` can be split; `export * from '...'` cannot.
|
|
94
|
+
if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {
|
|
95
|
+
rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, stmt.isTypeOnly, stmt.exportClause.elements, 'export', changes);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Partition the named bindings of an import/export declaration into the ones
|
|
102
|
+
* that resolve to `@nx/cypress`'s public entry and the ones that don't. If both
|
|
103
|
+
* groups are non-empty, the single declaration is split into two.
|
|
104
|
+
*/
|
|
105
|
+
function rewriteNamedDeclaration(sourceFile, decl, specifier, isTypeOnly, elements, keyword, changes) {
|
|
106
|
+
const publicEls = [];
|
|
107
|
+
const internalEls = [];
|
|
108
|
+
for (const el of elements) {
|
|
109
|
+
// `propertyName` is the original name in `orig as alias`; fall back to
|
|
110
|
+
// `name` for the plain `orig` form.
|
|
111
|
+
const importedName = (el.propertyName ?? el.name).text;
|
|
112
|
+
(PUBLIC_SYMBOLS.has(importedName) ? publicEls : internalEls).push(el);
|
|
113
|
+
}
|
|
114
|
+
if (publicEls.length === 0) {
|
|
115
|
+
replaceSpecifier(sourceFile, specifier, TO_INTERNAL, changes);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (internalEls.length === 0) {
|
|
119
|
+
replaceSpecifier(sourceFile, specifier, TO_PUBLIC, changes);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// Mixed — replace the whole declaration with one statement per target.
|
|
123
|
+
const quote = sourceFile.text.charAt(specifier.getStart(sourceFile));
|
|
124
|
+
const start = decl.getStart(sourceFile);
|
|
125
|
+
const end = decl.getEnd();
|
|
126
|
+
const semicolon = sourceFile.text.charAt(end - 1) === ';' ? ';' : '';
|
|
127
|
+
const prefix = isTypeOnly ? `${keyword} type` : keyword;
|
|
128
|
+
const render = (els, target) => `${prefix} { ${els
|
|
129
|
+
.map((el) => el.getText(sourceFile))
|
|
130
|
+
.join(', ')} } from ${quote}${target}${quote}${semicolon}`;
|
|
131
|
+
changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
|
|
132
|
+
type: devkit_1.ChangeType.Insert,
|
|
133
|
+
index: start,
|
|
134
|
+
text: `${render(publicEls, TO_PUBLIC)}\n${render(internalEls, TO_INTERNAL)}`,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function collectCallExpressionRewrites(sourceFile, changes) {
|
|
138
|
+
const visit = (node) => {
|
|
139
|
+
if (ts.isCallExpression(node) &&
|
|
140
|
+
shouldRewriteCallExpression(node) &&
|
|
141
|
+
node.arguments.length >= 1 &&
|
|
142
|
+
isSubpathSpecifier(node.arguments[0])) {
|
|
143
|
+
// `require(...)`, dynamic `import(...)` and `jest.mock(...)` reference
|
|
144
|
+
// the module as a whole and can't be symbol-split, so they go to the
|
|
145
|
+
// internal entry.
|
|
146
|
+
replaceSpecifier(sourceFile, node.arguments[0], TO_INTERNAL, changes);
|
|
147
|
+
}
|
|
148
|
+
else if (ts.isImportTypeNode(node)) {
|
|
149
|
+
// `typeof import('...')` parses as an `ImportTypeNode`, not a
|
|
150
|
+
// CallExpression — its argument is `LiteralTypeNode<StringLiteral>`.
|
|
151
|
+
// The whole module is referenced, so it can't be symbol-split.
|
|
152
|
+
const literal = getImportTypeStringLiteral(node);
|
|
153
|
+
if (literal && literal.text.startsWith(FROM_PREFIX)) {
|
|
154
|
+
replaceSpecifier(sourceFile, literal, TO_INTERNAL, changes);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
ts.forEachChild(node, visit);
|
|
158
|
+
};
|
|
159
|
+
visit(sourceFile);
|
|
160
|
+
}
|
|
161
|
+
function getImportTypeStringLiteral(node) {
|
|
162
|
+
const arg = node.argument;
|
|
163
|
+
if (arg && ts.isLiteralTypeNode(arg) && ts.isStringLiteral(arg.literal)) {
|
|
164
|
+
return arg.literal;
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
function shouldRewriteCallExpression(call) {
|
|
169
|
+
const callee = call.expression;
|
|
170
|
+
// `require('...')`
|
|
171
|
+
if (ts.isIdentifier(callee) && callee.text === 'require')
|
|
172
|
+
return true;
|
|
173
|
+
// dynamic `import('...')` (runtime form parses as a CallExpression whose
|
|
174
|
+
// callee is the `import` keyword). The type-position form
|
|
175
|
+
// (`typeof import('...')`) is an `ImportTypeNode`, not a CallExpression, so
|
|
176
|
+
// we don't touch it.
|
|
177
|
+
if (callee.kind === ts.SyntaxKind.ImportKeyword)
|
|
178
|
+
return true;
|
|
179
|
+
// `jest.mock(...)` / `vi.mock(...)` and friends.
|
|
180
|
+
if (ts.isPropertyAccessExpression(callee)) {
|
|
181
|
+
const obj = callee.expression;
|
|
182
|
+
if (ts.isIdentifier(obj) &&
|
|
183
|
+
(obj.text === 'jest' || obj.text === 'vi') &&
|
|
184
|
+
MOCK_HELPER_METHODS.has(callee.name.text)) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
function replaceSpecifier(sourceFile, literal, target, changes) {
|
|
191
|
+
const start = literal.getStart(sourceFile);
|
|
192
|
+
const end = literal.getEnd();
|
|
193
|
+
const quote = sourceFile.text.charAt(start);
|
|
194
|
+
changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
|
|
195
|
+
type: devkit_1.ChangeType.Insert,
|
|
196
|
+
index: start,
|
|
197
|
+
text: `${quote}${target}${quote}`,
|
|
198
|
+
});
|
|
199
|
+
}
|