@nx/cypress 20.0.0-beta.4 → 20.0.0-beta.6

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
@@ -1,29 +1,5 @@
1
1
  {
2
2
  "generators": {
3
- "update-16-0-0-add-nx-packages": {
4
- "cli": "nx",
5
- "version": "16.0.0-beta.1",
6
- "description": "Replace @nrwl/cypress with @nx/cypress",
7
- "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
8
- },
9
- "update-16-2-0-normalize-tsconfigs": {
10
- "cli": "nx",
11
- "version": "16.2.0-beta.0",
12
- "description": "Normalize tsconfig.cy.json files to be located at '<projectRoot>/cypress/tsconfig.json'",
13
- "implementation": "./src/migrations/update-16-2-0/update-cy-tsconfig"
14
- },
15
- "update-16-3-0-remove-old-tsconfigs": {
16
- "cli": "nx",
17
- "version": "16.4.0-beta.10",
18
- "description": "Remove tsconfig.e2e.json and add settings to project tsconfig.json. tsConfigs executor option is now deprecated. The project level tsconfig.json file should be used instead.",
19
- "implementation": "./src/migrations/update-16-4-0/tsconfig-sourcemaps"
20
- },
21
- "update-16-8-0-cypress-13": {
22
- "cli": "nx",
23
- "version": "16.8.0-beta.4",
24
- "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",
25
- "implementation": "./src/migrations/update-16-8-0/cypress-13"
26
- },
27
3
  "update-cypress-version-13-6-6": {
28
4
  "cli": "nx",
29
5
  "version": "18.1.0-beta.3",
@@ -38,39 +14,6 @@
38
14
  }
39
15
  },
40
16
  "packageJsonUpdates": {
41
- "16.1.0": {
42
- "version": "16.1.0-beta.0",
43
- "requires": {
44
- "cypress": ">=12.0.0 <12.11.0"
45
- },
46
- "packages": {
47
- "cypress": {
48
- "version": "^12.11.0",
49
- "alwaysAddToPackageJson": false
50
- }
51
- }
52
- },
53
- "16.5.0": {
54
- "version": "16.5.0-beta.0",
55
- "requires": {
56
- "cypress": ">=12.0.0 <12.16.0"
57
- },
58
- "packages": {
59
- "cypress": {
60
- "version": "^12.16.0",
61
- "alwaysAddToPackageJson": false
62
- }
63
- }
64
- },
65
- "16.7.0": {
66
- "version": "16.7.0-beta.3",
67
- "packages": {
68
- "eslint-plugin-cypress": {
69
- "version": "^2.13.4",
70
- "alwaysAddToPackageJson": false
71
- }
72
- }
73
- },
74
17
  "17.2.0-beta.2": {
75
18
  "version": "17.2.0-beta.2",
76
19
  "packages": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/cypress",
3
- "version": "20.0.0-beta.4",
3
+ "version": "20.0.0-beta.6",
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,13 +36,12 @@
36
36
  "migrations": "./migrations.json"
37
37
  },
38
38
  "dependencies": {
39
- "@nx/devkit": "20.0.0-beta.4",
40
- "@nx/eslint": "20.0.0-beta.4",
41
- "@nx/js": "20.0.0-beta.4",
39
+ "@nx/devkit": "20.0.0-beta.6",
40
+ "@nx/eslint": "20.0.0-beta.6",
41
+ "@nx/js": "20.0.0-beta.6",
42
42
  "@phenomnomnominal/tsquery": "~5.0.1",
43
43
  "detect-port": "^1.5.1",
44
- "tslib": "^2.3.0",
45
- "@nrwl/cypress": "20.0.0-beta.4"
44
+ "tslib": "^2.3.0"
46
45
  },
47
46
  "peerDependencies": {
48
47
  "cypress": ">= 3 < 14"
@@ -4,6 +4,7 @@ exports.componentConfigurationGenerator = componentConfigurationGenerator;
4
4
  exports.componentConfigurationGeneratorInternal = componentConfigurationGeneratorInternal;
5
5
  exports.updateTsConfigForComponentTesting = updateTsConfigForComponentTesting;
6
6
  const devkit_1 = require("@nx/devkit");
7
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
8
  const cypress_version_1 = require("../../utils/cypress-version");
8
9
  const versions_1 = require("../../utils/versions");
9
10
  const base_setup_1 = require("../base-setup/base-setup");
@@ -15,6 +16,7 @@ function componentConfigurationGenerator(tree, options) {
15
16
  });
16
17
  }
17
18
  async function componentConfigurationGeneratorInternal(tree, options) {
19
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'cypress', 'component-configuration');
18
20
  const tasks = [];
19
21
  const opts = normalizeOptions(tree, options);
20
22
  tasks.push(await (0, init_1.default)(tree, {
@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configurationGenerator = configurationGenerator;
4
4
  exports.configurationGeneratorInternal = configurationGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
- const js_1 = require("@nx/js");
7
6
  const eslint_1 = require("@nx/eslint");
7
+ const js_1 = require("@nx/js");
8
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
9
  const path_1 = require("path");
9
10
  const add_linter_1 = require("../../utils/add-linter");
10
11
  const config_1 = require("../../utils/config");
11
12
  const cypress_version_1 = require("../../utils/cypress-version");
12
13
  const versions_1 = require("../../utils/versions");
13
- const init_1 = require("../init/init");
14
14
  const base_setup_1 = require("../base-setup/base-setup");
15
+ const init_1 = require("../init/init");
15
16
  function configurationGenerator(tree, options) {
16
17
  return configurationGeneratorInternal(tree, {
17
18
  addPlugin: false,
@@ -19,6 +20,7 @@ function configurationGenerator(tree, options) {
19
20
  });
20
21
  }
21
22
  async function configurationGeneratorInternal(tree, options) {
23
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'cypress', 'configuration');
22
24
  const opts = normalizeOptions(tree, options);
23
25
  opts.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
24
26
  const tasks = [];
@@ -5,6 +5,7 @@ exports.cypressInitGenerator = cypressInitGenerator;
5
5
  exports.cypressInitGeneratorInternal = cypressInitGeneratorInternal;
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
8
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
9
  const plugin_1 = require("../../plugins/plugin");
9
10
  const versions_1 = require("../../utils/versions");
10
11
  function setupE2ETargetDefaults(tree) {
@@ -61,6 +62,7 @@ async function cypressInitGenerator(tree, options) {
61
62
  return cypressInitGeneratorInternal(tree, { addPlugin: false, ...options });
62
63
  }
63
64
  async function cypressInitGeneratorInternal(tree, options) {
65
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'cypress', 'init');
64
66
  updateProductionFileset(tree);
65
67
  const nxJson = (0, devkit_1.readNxJson)(tree);
66
68
  options.addPlugin ??=
@@ -1,4 +1,3 @@
1
- import { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  export declare function getUnscopedLibName(libRoot: string): string;
3
- export declare function getE2eProjectName(targetProjectName: string, targetLibRoot: string, cypressDirectory?: string, nameAndProjectRootFormat?: ProjectNameAndRootFormat): string;
2
+ export declare function getE2eProjectName(targetProjectName: string, targetLibRoot: string, cypressDirectory?: string): string;
4
3
  export declare function filePathPrefix(directory: string): string;
@@ -7,8 +7,8 @@ const devkit_1 = require("@nx/devkit");
7
7
  function getUnscopedLibName(libRoot) {
8
8
  return libRoot.slice(libRoot.lastIndexOf('/') + 1);
9
9
  }
10
- function getE2eProjectName(targetProjectName, targetLibRoot, cypressDirectory, nameAndProjectRootFormat = 'as-provided') {
11
- if (cypressDirectory && nameAndProjectRootFormat !== 'as-provided') {
10
+ function getE2eProjectName(targetProjectName, targetLibRoot, cypressDirectory) {
11
+ if (cypressDirectory) {
12
12
  return `${filePathPrefix(cypressDirectory)}-${getUnscopedLibName(targetLibRoot)}-e2e`;
13
13
  }
14
14
  return `${targetProjectName}-e2e`;
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function replacePackage(tree: Tree): Promise<void>;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = replacePackage;
4
- const devkit_1 = require("@nx/devkit");
5
- const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
6
- async function replacePackage(tree) {
7
- await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/cypress', '@nx/cypress');
8
- await (0, devkit_1.formatFiles)(tree);
9
- }
@@ -1,3 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function normalizeCyTsConfigNames(tree: Tree): Promise<void>;
3
- export default normalizeCyTsConfigNames;
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeCyTsConfigNames = normalizeCyTsConfigNames;
4
- const devkit_1 = require("@nx/devkit");
5
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
- async function normalizeCyTsConfigNames(tree) {
7
- const projects = (0, devkit_1.getProjects)(tree);
8
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/cypress:cypress', (_, projectName) => {
9
- const projectConfig = projects.get(projectName);
10
- const newTsConfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'tsconfig.json');
11
- // if there is already a tsconfig.json in the cypress folder, then assume things are setup already
12
- if (!tree.exists(newTsConfigPath)) {
13
- moveProjectTsCyConfig(tree, projectConfig, newTsConfigPath);
14
- moveCyDirTsCyConfig(tree, projectConfig, newTsConfigPath);
15
- updateCyDirTsConfigReferences(tree, projectConfig);
16
- }
17
- });
18
- await (0, devkit_1.formatFiles)(tree);
19
- }
20
- function moveProjectTsCyConfig(tree, projectConfig, newTsConfigPath) {
21
- if (tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.cy.json'))) {
22
- tree.rename((0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.cy.json'), newTsConfigPath);
23
- (0, devkit_1.updateJson)(tree, newTsConfigPath, (json) => {
24
- json.extends = '../tsconfig.json';
25
- json.compilerOptions ??= {};
26
- json.compilerOptions = {
27
- ...json.compilerOptions,
28
- sourceMap: false,
29
- outDir: '../../../dist/out-tsc',
30
- };
31
- json.include ??= [];
32
- json.include = json.include.map((p) => {
33
- if (p.startsWith('cypress/')) {
34
- return p.replace('cypress/', '');
35
- }
36
- return `../${p}`;
37
- });
38
- return json;
39
- });
40
- }
41
- }
42
- function moveCyDirTsCyConfig(tree, projectConfig, newTsConfigPath) {
43
- if (tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'tsconfig.cy.json'))) {
44
- tree.rename((0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'tsconfig.cy.json'), newTsConfigPath);
45
- (0, devkit_1.updateJson)(tree, newTsConfigPath, (json) => {
46
- json.compilerOptions ??= {};
47
- json.compilerOptions = {
48
- ...json.compilerOptions,
49
- sourceMap: false,
50
- };
51
- return json;
52
- });
53
- }
54
- }
55
- function updateCyDirTsConfigReferences(tree, projectConfig) {
56
- if (!tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'tsconfig.json'))) {
57
- return;
58
- }
59
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'), (json) => {
60
- json.references ??= [];
61
- if (!json.references) {
62
- return json;
63
- }
64
- const cyFile = json.references.find((p) => p.path.includes('tsconfig.cy.json'));
65
- if (cyFile) {
66
- json.references.splice(json.references.indexOf(cyFile), 1);
67
- }
68
- if (!json.references.some((r) => r.path === './cypress/tsconfig.json')) {
69
- json.references.push({
70
- path: './cypress/tsconfig.json',
71
- });
72
- }
73
- return json;
74
- });
75
- }
76
- exports.default = normalizeCyTsConfigNames;
@@ -1,3 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function fixLegacyCypressTsconfig(tree: Tree): Promise<void>;
3
- export default fixLegacyCypressTsconfig;
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fixLegacyCypressTsconfig = fixLegacyCypressTsconfig;
4
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
5
- const devkit_1 = require("@nx/devkit");
6
- const path_1 = require("path");
7
- async function fixLegacyCypressTsconfig(tree) {
8
- const projects = (0, devkit_1.getProjects)(tree);
9
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/cypress:cypress', (options, projectName, targetName, configName) => {
10
- const projectConfig = projects.get(projectName);
11
- if (options.testingType !== 'e2e' &&
12
- projectConfig.targets[targetName]?.options?.testingType !== 'e2e') {
13
- return;
14
- }
15
- const tsconfigToRemove = options.tsConfig ??
16
- (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.e2e.json');
17
- const projectLevelConfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json');
18
- if (!tree.exists(projectLevelConfigPath) ||
19
- !tree.exists(tsconfigToRemove)) {
20
- return;
21
- }
22
- if (tsconfigToRemove === projectLevelConfigPath) {
23
- (0, devkit_1.updateJson)(tree, projectLevelConfigPath, (json) => {
24
- json.compilerOptions = {
25
- sourceMap: false,
26
- ...json.compilerOptions,
27
- };
28
- return json;
29
- });
30
- }
31
- else {
32
- const e2eConfig = (0, devkit_1.readJson)(tree, tsconfigToRemove);
33
- (0, devkit_1.updateJson)(tree, projectLevelConfigPath, (json) => {
34
- json.compilerOptions = {
35
- sourceMap: false,
36
- ...json.compilerOptions,
37
- ...e2eConfig.compilerOptions,
38
- };
39
- json.files = Array.from(new Set([...(json.files ?? []), ...(e2eConfig.files ?? [])]));
40
- json.include = Array.from(new Set([...(json.include ?? []), ...(e2eConfig.include ?? [])]));
41
- json.exclude = Array.from(new Set([...(json.exclude ?? []), ...(e2eConfig.exclude ?? [])]));
42
- // these paths will always be 'unix style'
43
- // and on windows relative will not work on these paths
44
- const tsConfigFromProjRoot = path_1.posix.relative(projectConfig.root, tsconfigToRemove);
45
- json.references = (json.references ?? []).filter(({ path }) => !path.includes(tsConfigFromProjRoot));
46
- return json;
47
- });
48
- tree.delete(tsconfigToRemove);
49
- }
50
- if (configName) {
51
- delete projectConfig.targets[targetName].configurations[configName]
52
- .tsConfig;
53
- }
54
- else {
55
- delete projectConfig.targets[targetName].options.tsConfig;
56
- }
57
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
58
- });
59
- await (0, devkit_1.formatFiles)(tree);
60
- }
61
- exports.default = fixLegacyCypressTsconfig;
@@ -1,7 +0,0 @@
1
- import { type Tree } from '@nx/devkit';
2
- export declare function updateToCypress13(tree: Tree): Promise<void>;
3
- /**
4
- * leave a comment on all usages of overriding built-ins that are now banned
5
- **/
6
- export declare function shouldNotOverrideReadFile(tree: Tree, filePath: string): void;
7
- export default updateToCypress13;
@@ -1,178 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateToCypress13 = updateToCypress13;
4
- exports.shouldNotOverrideReadFile = shouldNotOverrideReadFile;
5
- const devkit_1 = require("@nx/devkit");
6
- const cypress_version_1 = require("../../utils/cypress-version");
7
- const typescript_1 = require("typescript");
8
- const tsquery_1 = require("@phenomnomnominal/tsquery");
9
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
10
- const JS_TS_FILE_MATCHER = /\.[jt]sx?$/;
11
- async function updateToCypress13(tree) {
12
- if ((0, cypress_version_1.installedCypressVersion)() < 12) {
13
- return;
14
- }
15
- const projects = (0, devkit_1.getProjects)(tree);
16
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/cypress:cypress', (options, projectName) => {
17
- if (!options.cypressConfig || !tree.exists(options.cypressConfig)) {
18
- return;
19
- }
20
- const projectConfig = projects.get(projectName);
21
- removeNodeVersionOption(tree, options.cypressConfig);
22
- removeVideoUploadOnPassesOption(tree, options.cypressConfig);
23
- (0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
24
- if (!JS_TS_FILE_MATCHER.test(filePath)) {
25
- return;
26
- }
27
- shouldNotOverrideReadFile(tree, filePath);
28
- });
29
- });
30
- (0, devkit_1.updateJson)(tree, 'package.json', (json) => {
31
- json.devDependencies ??= {};
32
- json.devDependencies.cypress = '^13.0.0';
33
- return json;
34
- });
35
- await (0, devkit_1.formatFiles)(tree);
36
- }
37
- function removeVideoUploadOnPassesOption(tree, configPath) {
38
- const config = tree.read(configPath, 'utf-8');
39
- const isUsingDeprecatedOption = tsquery_1.tsquery.query(config, getPropertyQuery('videoUploadOnPasses'))?.length > 0;
40
- if (!isUsingDeprecatedOption) {
41
- return;
42
- }
43
- const importStatement = configPath.endsWith('.ts')
44
- ? "import fs from 'fs';"
45
- : "const fs = require('fs');";
46
- const replacementFunction = `/**
47
- * Delete videos for specs that do not contain failing or retried tests.
48
- * This function is to be used in the 'setupNodeEvents' configuration option as a replacement to
49
- * 'videoUploadOnPasses' which has been removed.
50
- *
51
- * https://docs.cypress.io/guides/guides/screenshots-and-videos#Delete-videos-for-specs-without-failing-or-retried-tests
52
- **/
53
- function removePassedSpecs(on) {
54
- on('after:spec', (spec, results) => {
55
- if(results && results.vide) {
56
- const hasFailures = results.tests.some(t => t.attempts.some(a => a.state === 'failed'));
57
-
58
- if(!hasFailures) {
59
- fs.unlinkSync(results.video);
60
- }
61
- }
62
- })
63
- }`;
64
- const withReplacementFn = `${importStatement}\n${config}\n${replacementFunction}`;
65
- // setupNodeEvents can be a property or method.
66
- const setupNodeEventsQuery = 'ExportAssignment ObjectLiteralExpression > :matches(PropertyAssignment:has(Identifier[name="setupNodeEvents"]), MethodDeclaration:has(Identifier[name="setupNodeEvents"]))';
67
- const hasSetupNodeEvents = tsquery_1.tsquery.query(withReplacementFn, setupNodeEventsQuery)?.length > 0;
68
- let updatedWithSetupNodeEvents = withReplacementFn;
69
- if (hasSetupNodeEvents) {
70
- // if have setupNodeEvents, update existing fn to use removePassedSpecs helper and remove videoUploadOnPasses
71
- const noVideoUploadOption = tsquery_1.tsquery.replace(withReplacementFn, getPropertyQuery('videoUploadOnPasses'), (node) => {
72
- if ((0, typescript_1.isObjectLiteralExpression)(node.initializer)) {
73
- // is a nested config object
74
- const key = node.name.getText().trim();
75
- const listOfProperties = node.initializer.properties
76
- .map((j) => j.getText())
77
- .filter((j) => !j.includes('videoUploadOnPasses'))
78
- .join(',\n');
79
- return `${key}: {
80
- ${listOfProperties}
81
- }
82
- `;
83
- }
84
- else {
85
- if (isPropertyTopLevel(node)) {
86
- return `// ${node.getText()} `;
87
- }
88
- }
89
- });
90
- updatedWithSetupNodeEvents = tsquery_1.tsquery.replace(noVideoUploadOption, `${setupNodeEventsQuery} Block`, (node) => {
91
- const blockWithoutBraces = node
92
- .getFullText()
93
- .trim()
94
- .slice(1, -1)
95
- .trim();
96
- return `{
97
- ${blockWithoutBraces}
98
- removePassedSpecs(on);
99
- }
100
- `;
101
- }, { visitAllChildren: false });
102
- }
103
- else {
104
- // if don't have setupNodeEvents, replace videoUploadOnPasses with setupNodeEvents method
105
- updatedWithSetupNodeEvents = tsquery_1.tsquery.replace(withReplacementFn, getPropertyQuery('videoUploadOnPasses'), () => {
106
- return `setupNodeEvents(on, config) {
107
- removePassedSpecs(on);
108
- }`;
109
- });
110
- }
111
- tree.write(configPath, updatedWithSetupNodeEvents);
112
- }
113
- /**
114
- * remove the nodeVersion option from the config file
115
- **/
116
- function removeNodeVersionOption(tree, configPath) {
117
- const config = tree.read(configPath, 'utf-8');
118
- const updated = tsquery_1.tsquery.replace(config, getPropertyQuery('nodeVersion'), (node) => {
119
- if ((0, typescript_1.isObjectLiteralExpression)(node.initializer)) {
120
- // is a nested config object
121
- const key = node.name.getText().trim();
122
- const listOfProperties = node.initializer.properties
123
- .map((j) => j.getFullText())
124
- .filter((j) => !j.includes('nodeVersion'))
125
- .join(', ');
126
- return `${key}: {
127
- ${listOfProperties}
128
- }`;
129
- }
130
- else {
131
- if (isPropertyTopLevel(node)) {
132
- return `// ${node.getText()}`;
133
- }
134
- }
135
- });
136
- if (updated !== config) {
137
- tree.write(configPath, updated);
138
- }
139
- }
140
- /**
141
- * leave a comment on all usages of overriding built-ins that are now banned
142
- **/
143
- function shouldNotOverrideReadFile(tree, filePath) {
144
- const content = tree.read(filePath, 'utf-8');
145
- const markedOverrideUsage = tsquery_1.tsquery.replace(content, 'PropertyAccessExpression:has(Identifier[name="overwrite"]):has(Identifier[name="Cypress"])', (node) => {
146
- if (isAlreadyCommented(node)) {
147
- return;
148
- }
149
- const expression = node.expression.getText().trim();
150
- // prevent grabbing other Cypress.<something>.defaults
151
- if (expression === 'Cypress.Commands') {
152
- // get value.
153
- const overwriteExpression = node.parent;
154
- const command = overwriteExpression.arguments?.[0]?.text; // need string without quotes
155
- if (command === 'readFile') {
156
- // overwrite
157
- return `/**
158
- * TODO(@nx/cypress): This command can no longer be overridden
159
- * Consider using a different name like 'custom_${command}'
160
- * More info: https://docs.cypress.io/guides/references/migration-guide#readFile-can-no-longer-be-overwritten-with-CypressCommandsoverwrite
161
- **/
162
- ${node.getText()}`;
163
- }
164
- }
165
- });
166
- tree.write(filePath, markedOverrideUsage);
167
- }
168
- function isAlreadyCommented(node) {
169
- return node.getFullText().includes('TODO(@nx/cypress)');
170
- }
171
- function isPropertyTopLevel(node) {
172
- return (node.parent &&
173
- (0, typescript_1.isObjectLiteralExpression)(node.parent) &&
174
- node.parent.parent &&
175
- (0, typescript_1.isCallExpression)(node.parent.parent));
176
- }
177
- const getPropertyQuery = (propertyName) => `ExportAssignment ObjectLiteralExpression > PropertyAssignment:has(Identifier[name="${propertyName}"])`;
178
- exports.default = updateToCypress13;