@nx/cypress 0.0.0-pr-22179-271588f → 0.0.0-pr-26482-ebe2dba

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.
Files changed (58) hide show
  1. package/LICENSE +1 -1
  2. package/generators.json +5 -6
  3. package/index.d.ts +2 -9
  4. package/index.js +3 -12
  5. package/migrations.json +16 -24
  6. package/package.json +9 -8
  7. package/plugin.d.ts +1 -1
  8. package/plugin.js +2 -2
  9. package/plugins/cypress-preset.d.ts +2 -0
  10. package/src/executors/cypress/cypress.impl.d.ts +1 -0
  11. package/src/executors/cypress/cypress.impl.js +3 -0
  12. package/src/executors/cypress/schema.json +12 -0
  13. package/src/generators/configuration/configuration.js +4 -4
  14. package/src/generators/convert-to-inferred/convert-to-inferred.d.ts +8 -0
  15. package/src/generators/convert-to-inferred/convert-to-inferred.js +94 -0
  16. package/src/generators/convert-to-inferred/lib/add-dev-server-target-to-config.d.ts +12 -0
  17. package/src/generators/convert-to-inferred/lib/add-dev-server-target-to-config.js +76 -0
  18. package/src/generators/convert-to-inferred/lib/add-exclude-spec-pattern.d.ts +2 -0
  19. package/src/generators/convert-to-inferred/lib/add-exclude-spec-pattern.js +28 -0
  20. package/src/generators/convert-to-inferred/lib/target-options-map.d.ts +18 -0
  21. package/src/generators/convert-to-inferred/lib/target-options-map.js +21 -0
  22. package/src/generators/convert-to-inferred/lib/upsert-baseUrl.d.ts +2 -0
  23. package/src/generators/convert-to-inferred/lib/upsert-baseUrl.js +33 -0
  24. package/src/generators/convert-to-inferred/schema.json +19 -0
  25. package/src/generators/init/init.d.ts +2 -2
  26. package/src/generators/init/init.js +13 -25
  27. package/src/plugins/plugin.d.ts +7 -2
  28. package/src/plugins/plugin.js +89 -45
  29. package/src/utils/add-linter.js +2 -1
  30. package/src/utils/versions.d.ts +2 -3
  31. package/src/utils/versions.js +3 -4
  32. package/src/generators/cypress-project/cypress-project.d.ts +0 -16
  33. package/src/generators/cypress-project/cypress-project.js +0 -213
  34. package/src/generators/cypress-project/files/v10-and-after/cypress.config.ts__tmpl__ +0 -10
  35. package/src/generators/cypress-project/files/v10-and-after/src/e2e/app.cy.ts__tmpl__ +0 -13
  36. package/src/generators/cypress-project/files/v10-and-after/src/fixtures/example.json__tmpl__ +0 -4
  37. package/src/generators/cypress-project/files/v10-and-after/src/support/app.po.ts__tmpl__ +0 -1
  38. package/src/generators/cypress-project/files/v10-and-after/src/support/commands.ts__tmpl__ +0 -33
  39. package/src/generators/cypress-project/files/v10-and-after/src/support/e2e.ts__tmpl__ +0 -17
  40. package/src/generators/cypress-project/files/v10-and-after/tsconfig.json +0 -10
  41. package/src/generators/cypress-project/files/v9-and-under/cypress.json +0 -12
  42. package/src/generators/cypress-project/files/v9-and-under/src/fixtures/example.json__tmpl__ +0 -4
  43. package/src/generators/cypress-project/files/v9-and-under/src/integration/app.spec.ts__tmpl__ +0 -13
  44. package/src/generators/cypress-project/files/v9-and-under/src/plugins/index.js +0 -22
  45. package/src/generators/cypress-project/files/v9-and-under/src/support/app.po.ts__tmpl__ +0 -1
  46. package/src/generators/cypress-project/files/v9-and-under/src/support/commands.ts__tmpl__ +0 -33
  47. package/src/generators/cypress-project/files/v9-and-under/src/support/index.ts__tmpl__ +0 -17
  48. package/src/generators/cypress-project/files/v9-and-under/tsconfig.json +0 -10
  49. package/src/generators/cypress-project/schema.d.ts +0 -17
  50. package/src/generators/cypress-project/schema.json +0 -78
  51. package/src/migrations/update-15-0-0/add-cypress-inputs.d.ts +0 -2
  52. package/src/migrations/update-15-0-0/add-cypress-inputs.js +0 -42
  53. package/src/migrations/update-15-0-0/update-cy-mount-usage.d.ts +0 -5
  54. package/src/migrations/update-15-0-0/update-cy-mount-usage.js +0 -119
  55. package/src/migrations/update-15-1-0/cypress-11.d.ts +0 -6
  56. package/src/migrations/update-15-1-0/cypress-11.js +0 -114
  57. package/src/migrations/update-15-5-0/update-to-cypress-12.d.ts +0 -24
  58. package/src/migrations/update-15-5-0/update-to-cypress-12.js +0 -180
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2023 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2024 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/generators.json CHANGED
@@ -9,12 +9,6 @@
9
9
  "aliases": ["ng-add"],
10
10
  "hidden": true
11
11
  },
12
- "cypress-project": {
13
- "factory": "./src/generators/cypress-project/cypress-project#cypressProjectGeneratorInternal",
14
- "schema": "./src/generators/cypress-project/schema.json",
15
- "description": "Add a Cypress E2E Project.",
16
- "hidden": true
17
- },
18
12
  "configuration": {
19
13
  "aliases": ["cypress-e2e-configuration", "e2e", "e2e-config"],
20
14
  "factory": "./src/generators/configuration/configuration#configurationGeneratorInternal",
@@ -32,6 +26,11 @@
32
26
  "factory": "./src/generators/migrate-to-cypress-11/migrate-to-cypress-11#migrateCypressProject",
33
27
  "schema": "./src/generators/migrate-to-cypress-11/schema.json",
34
28
  "description": "Migrate existing Cypress e2e projects to Cypress v11"
29
+ },
30
+ "convert-to-inferred": {
31
+ "factory": "./src/generators/convert-to-inferred/convert-to-inferred",
32
+ "schema": "./src/generators/convert-to-inferred/schema.json",
33
+ "description": "Convert existing Cypress project(s) using `@nx/cypress:cypress` executor to use `@nx/cypress/plugin`."
35
34
  }
36
35
  }
37
36
  }
package/index.d.ts CHANGED
@@ -1,11 +1,4 @@
1
- import { configurationGenerator } from './src/generators/configuration/configuration';
2
- import { componentConfigurationGenerator } from './src/generators/component-configuration/component-configuration';
3
- import { cypressProjectGenerator as _cypressProjectGenerator } from './src/generators/cypress-project/cypress-project';
4
- export { configurationGenerator, componentConfigurationGenerator };
5
- /** @deprecated Use `configurationGenerator` instead. It will be removed in Nx 19. */
6
- export declare const cypressComponentConfiguration: typeof componentConfigurationGenerator;
7
- export { configurationGenerator as cypressE2EConfigurationGenerator };
8
- /** @deprecated Add a new project and call `configurationGenerator` instead. It will be removed in Nx 19. */
9
- export declare const cypressProjectGenerator: typeof _cypressProjectGenerator;
1
+ export { configurationGenerator } from './src/generators/configuration/configuration';
2
+ export { componentConfigurationGenerator } from './src/generators/component-configuration/component-configuration';
10
3
  export { cypressInitGenerator } from './src/generators/init/init';
11
4
  export { migrateCypressProject } from './src/generators/migrate-to-cypress-11/migrate-to-cypress-11';
package/index.js CHANGED
@@ -1,19 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.migrateCypressProject = exports.cypressInitGenerator = exports.cypressProjectGenerator = exports.cypressE2EConfigurationGenerator = exports.cypressComponentConfiguration = exports.componentConfigurationGenerator = exports.configurationGenerator = void 0;
4
- const configuration_1 = require("./src/generators/configuration/configuration");
3
+ exports.migrateCypressProject = exports.cypressInitGenerator = exports.componentConfigurationGenerator = exports.configurationGenerator = void 0;
4
+ var configuration_1 = require("./src/generators/configuration/configuration");
5
5
  Object.defineProperty(exports, "configurationGenerator", { enumerable: true, get: function () { return configuration_1.configurationGenerator; } });
6
- Object.defineProperty(exports, "cypressE2EConfigurationGenerator", { enumerable: true, get: function () { return configuration_1.configurationGenerator; } });
7
- const component_configuration_1 = require("./src/generators/component-configuration/component-configuration");
6
+ var component_configuration_1 = require("./src/generators/component-configuration/component-configuration");
8
7
  Object.defineProperty(exports, "componentConfigurationGenerator", { enumerable: true, get: function () { return component_configuration_1.componentConfigurationGenerator; } });
9
- const cypress_project_1 = require("./src/generators/cypress-project/cypress-project");
10
- // Maintain backwards compatibility with the old names in case community plugins used them.
11
- // TODO(v19): Remove old name
12
- /** @deprecated Use `configurationGenerator` instead. It will be removed in Nx 19. */
13
- exports.cypressComponentConfiguration = component_configuration_1.componentConfigurationGenerator;
14
- // TODO(v19): Remove project generator
15
- /** @deprecated Add a new project and call `configurationGenerator` instead. It will be removed in Nx 19. */
16
- exports.cypressProjectGenerator = cypress_project_1.cypressProjectGenerator;
17
8
  var init_1 = require("./src/generators/init/init");
18
9
  Object.defineProperty(exports, "cypressInitGenerator", { enumerable: true, get: function () { return init_1.cypressInitGenerator; } });
19
10
  var migrate_to_cypress_11_1 = require("./src/generators/migrate-to-cypress-11/migrate-to-cypress-11");
package/migrations.json CHANGED
@@ -1,29 +1,5 @@
1
1
  {
2
2
  "generators": {
3
- "add-cypress-inputs": {
4
- "cli": "nx",
5
- "version": "15.0.0-beta.0",
6
- "description": "Stop hashing cypress spec files and config files for build targets and dependent tasks",
7
- "factory": "./src/migrations/update-15-0-0/add-cypress-inputs"
8
- },
9
- "update-cy-mount-usage": {
10
- "cli": "nx",
11
- "version": "15.0.0-beta.4",
12
- "description": "Update to using cy.mount in the commands.ts file instead of importing mount for each component test file",
13
- "factory": "./src/migrations/update-15-0-0/update-cy-mount-usage"
14
- },
15
- "update-to-cypress-11": {
16
- "cli": "nx",
17
- "version": "15.1.0-beta.0",
18
- "description": "Update to Cypress v11. This migration will only update if the workspace is already on v10. https://www.cypress.io/blog/2022/11/04/upcoming-changes-to-component-testing/",
19
- "factory": "./src/migrations/update-15-1-0/cypress-11"
20
- },
21
- "update-to-cypress-12": {
22
- "cli": "nx",
23
- "version": "15.5.0-beta.0",
24
- "description": "Update to Cypress v12. Cypress 12 contains a handful of breaking changes that might causes tests to start failing that nx cannot directly fix. Read more Cypress 12 changes: https://docs.cypress.io/guides/references/migration-guide#Migrating-to-Cypress-12-0.This migration will only run if you are already using Cypress v11.",
25
- "factory": "./src/migrations/update-15-5-0/update-to-cypress-12"
26
- },
27
3
  "update-16-0-0-add-nx-packages": {
28
4
  "cli": "nx",
29
5
  "version": "16.0.0-beta.1",
@@ -106,6 +82,22 @@
106
82
  "alwaysAddToPackageJson": false
107
83
  }
108
84
  }
85
+ },
86
+ "19.1.0": {
87
+ "version": "19.1.0-beta.0",
88
+ "requires": {
89
+ "cypress": "^13.0.0"
90
+ },
91
+ "packages": {
92
+ "cypress": {
93
+ "version": "^13.8.0",
94
+ "alwaysAddToPackageJson": false
95
+ },
96
+ "@cypress/webpack-dev-server": {
97
+ "version": "^3.8.0",
98
+ "alwaysAddToPackageJson": false
99
+ }
100
+ }
109
101
  }
110
102
  }
111
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/cypress",
3
- "version": "0.0.0-pr-22179-271588f",
3
+ "version": "0.0.0-pr-26482-ebe2dba",
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": {
@@ -17,9 +17,11 @@
17
17
  "Nest",
18
18
  "Jest",
19
19
  "Cypress",
20
- "CLI"
20
+ "CLI",
21
+ "Front-end",
22
+ "Testing"
21
23
  ],
22
- "main": "./index.js",
24
+ "main": "./index",
23
25
  "typings": "./index.d.ts",
24
26
  "author": "Victor Savkin",
25
27
  "license": "MIT",
@@ -34,14 +36,13 @@
34
36
  "migrations": "./migrations.json"
35
37
  },
36
38
  "dependencies": {
37
- "@nx/devkit": "0.0.0-pr-22179-271588f",
38
- "@nx/eslint": "0.0.0-pr-22179-271588f",
39
- "@nx/js": "0.0.0-pr-22179-271588f",
39
+ "@nx/devkit": "0.0.0-pr-26482-ebe2dba",
40
+ "@nx/eslint": "0.0.0-pr-26482-ebe2dba",
41
+ "@nx/js": "0.0.0-pr-26482-ebe2dba",
40
42
  "@phenomnomnominal/tsquery": "~5.0.1",
41
43
  "detect-port": "^1.5.1",
42
- "semver": "^7.5.3",
43
44
  "tslib": "^2.3.0",
44
- "@nrwl/cypress": "0.0.0-pr-22179-271588f"
45
+ "@nrwl/cypress": "0.0.0-pr-26482-ebe2dba"
45
46
  },
46
47
  "peerDependencies": {
47
48
  "cypress": ">= 3 < 14"
package/plugin.d.ts CHANGED
@@ -1 +1 @@
1
- export { createNodes, createDependencies } from './src/plugins/plugin';
1
+ export { createNodesV2, createNodes } from './src/plugins/plugin';
package/plugin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDependencies = exports.createNodes = void 0;
3
+ exports.createNodes = exports.createNodesV2 = void 0;
4
4
  var plugin_1 = require("./src/plugins/plugin");
5
+ Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
5
6
  Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
6
- Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
@@ -14,6 +14,8 @@ export interface NxComponentTestingOptions {
14
14
  bundler?: 'vite' | 'webpack';
15
15
  compiler?: 'swc' | 'babel';
16
16
  }
17
+ export interface NxComponentTestingPresetOptions extends Omit<NxComponentTestingOptions, 'bundler'> {
18
+ }
17
19
  export declare function nxBaseCypressPreset(pathToConfig: string, options?: {
18
20
  testingType: 'component' | 'e2e';
19
21
  }): BaseCypressPreset;
@@ -34,6 +34,7 @@ export interface CypressExecutorOptions extends Json {
34
34
  port?: number | 'cypress-auto';
35
35
  quiet?: boolean;
36
36
  runnerUi?: boolean;
37
+ autoCancelAfterFailures?: boolean | number;
37
38
  }
38
39
  export default function cypressExecutor(options: CypressExecutorOptions, context: ExecutorContext): Promise<{
39
40
  success: any;
@@ -149,6 +149,9 @@ async function runCypress(baseUrl, opts) {
149
149
  if (opts.quiet) {
150
150
  options.quiet = opts.quiet;
151
151
  }
152
+ if (opts.autoCancelAfterFailures !== undefined) {
153
+ options.autoCancelAfterFailures = opts.autoCancelAfterFailures;
154
+ }
152
155
  options.testingType = opts.testingType;
153
156
  const result = await (opts.watch
154
157
  ? Cypress.open(options)
@@ -178,6 +178,18 @@
178
178
  "runnerUi": {
179
179
  "type": "boolean",
180
180
  "description": "Displays the Cypress Runner UI. Useful for when Test Replay is enabled and you would still like the Cypress Runner UI to be displayed for screenshots and video."
181
+ },
182
+ "autoCancelAfterFailures": {
183
+ "oneOf": [
184
+ {
185
+ "type": "number"
186
+ },
187
+ {
188
+ "type": "boolean",
189
+ "const": false
190
+ }
191
+ ],
192
+ "description": "Specify the number of failures to cancel a run being recorded to the Cypress Cloud or `false` to disable auto-cancellation."
181
193
  }
182
194
  },
183
195
  "additionalProperties": true,
@@ -22,6 +22,7 @@ async function configurationGeneratorInternal(tree, options) {
22
22
  const opts = normalizeOptions(tree, options);
23
23
  opts.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
24
24
  const tasks = [];
25
+ const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
25
26
  if (!(0, cypress_version_1.installedCypressVersion)()) {
26
27
  tasks.push(await (0, js_1.initGenerator)(tree, { ...options, skipFormat: true }));
27
28
  tasks.push(await (0, init_1.default)(tree, {
@@ -30,9 +31,8 @@ async function configurationGeneratorInternal(tree, options) {
30
31
  }));
31
32
  }
32
33
  else if (opts.addPlugin) {
33
- (0, init_1.addPlugin)(tree);
34
+ await (0, init_1.addPlugin)(tree, projectGraph, false);
34
35
  }
35
- const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
36
36
  const nxJson = (0, devkit_1.readNxJson)(tree);
37
37
  const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
38
38
  ? p === '@nx/cypress/plugin'
@@ -72,13 +72,13 @@ Rename or remove the existing e2e target.`);
72
72
  }
73
73
  if (!options.baseUrl &&
74
74
  !options.devServerTarget &&
75
- !projectConfig.targets.serve) {
75
+ !projectConfig?.targets?.serve) {
76
76
  throw new Error(`The project ${options.project} does not have a 'serve' target.
77
77
  In this case you need to provide a devServerTarget,'<projectName>:<targetName>[:<configName>]', or a baseUrl option`);
78
78
  }
79
79
  options.directory ??= 'src';
80
80
  const devServerTarget = options.devServerTarget ??
81
- (projectConfig.targets.serve ? `${options.project}:serve` : undefined);
81
+ (projectConfig?.targets?.serve ? `${options.project}:serve` : undefined);
82
82
  if (!options.baseUrl && !devServerTarget) {
83
83
  throw new Error('Either baseUrl or devServerTarget must be provided');
84
84
  }
@@ -0,0 +1,8 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ interface Schema {
3
+ project?: string;
4
+ all?: boolean;
5
+ skipFormat?: boolean;
6
+ }
7
+ export declare function convertToInferred(tree: Tree, options: Schema): Promise<void>;
8
+ export default convertToInferred;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertToInferred = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
6
+ const plugin_1 = require("../../plugins/plugin");
7
+ const target_options_map_1 = require("./lib/target-options-map");
8
+ const upsert_baseUrl_1 = require("./lib/upsert-baseUrl");
9
+ const add_dev_server_target_to_config_1 = require("./lib/add-dev-server-target-to-config");
10
+ const add_exclude_spec_pattern_1 = require("./lib/add-exclude-spec-pattern");
11
+ async function convertToInferred(tree, options) {
12
+ const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
13
+ const migratedProjectsModern = await (0, executor_to_plugin_migrator_1.migrateExecutorToPlugin)(tree, projectGraph, '@nx/cypress:cypress', '@nx/cypress/plugin', (targetName) => ({
14
+ targetName,
15
+ ciTargetName: 'e2e-ci',
16
+ }), postTargetTransformer, plugin_1.createNodesV2, options.project);
17
+ const migratedProjectsLegacy = await (0, executor_to_plugin_migrator_1.migrateExecutorToPlugin)(tree, projectGraph, '@nrwl/cypress:cypress', '@nx/cypress/plugin', (targetName) => ({
18
+ targetName,
19
+ ciTargetName: 'e2e-ci',
20
+ }), postTargetTransformer, plugin_1.createNodesV2, options.project);
21
+ const migratedProjects = migratedProjectsModern.size + migratedProjectsLegacy.size;
22
+ if (migratedProjects === 0) {
23
+ throw new Error('Could not find any targets to migrate.');
24
+ }
25
+ if (!options.skipFormat) {
26
+ await (0, devkit_1.formatFiles)(tree);
27
+ }
28
+ }
29
+ exports.convertToInferred = convertToInferred;
30
+ function postTargetTransformer(target, tree) {
31
+ if (target.options) {
32
+ const configFilePath = target.options.cypressConfig;
33
+ delete target.options.cypressConfig;
34
+ delete target.options.copyFiles;
35
+ delete target.options.skipServe;
36
+ for (const key in target_options_map_1.targetOptionsToCliMap) {
37
+ if (target.options[key]) {
38
+ target.options[target_options_map_1.targetOptionsToCliMap[key]] = target.options[key];
39
+ delete target.options[key];
40
+ }
41
+ }
42
+ if ('exit' in target.options && !target.options.exit) {
43
+ delete target.options.exit;
44
+ target.options['no-exit'] = true;
45
+ }
46
+ if (target.options.testingType) {
47
+ delete target.options.testingType;
48
+ }
49
+ if (target.options.watch) {
50
+ target.options.headed = true;
51
+ target.options['no-exit'] = true;
52
+ delete target.options.watch;
53
+ }
54
+ if (target.options.baseUrl) {
55
+ (0, upsert_baseUrl_1.upsertBaseUrl)(tree, configFilePath, target.options.baseUrl);
56
+ delete target.options.baseUrl;
57
+ }
58
+ if (target.options.devServerTarget) {
59
+ const webServerCommands = {
60
+ default: `npx nx run ${target.options.devServerTarget}`,
61
+ };
62
+ delete target.options.devServerTarget;
63
+ if (target.configurations) {
64
+ for (const configuration in target.configurations) {
65
+ if (target.configurations[configuration]?.devServerTarget) {
66
+ webServerCommands[configuration] = `npx nx run ${target.configurations[configuration].devServerTarget}`;
67
+ delete target.configurations[configuration].devServerTarget;
68
+ }
69
+ }
70
+ }
71
+ (0, add_dev_server_target_to_config_1.addDevServerTargetToConfig)(tree, configFilePath, webServerCommands, webServerCommands?.['ci']);
72
+ }
73
+ if (target.options.ignoreTestFiles) {
74
+ (0, add_exclude_spec_pattern_1.addExcludeSpecPattern)(tree, configFilePath, target.options.ignoreTestFiles);
75
+ delete target.options.ignoreTestFiles;
76
+ }
77
+ if (Object.keys(target.options).length === 0) {
78
+ delete target.options;
79
+ }
80
+ if (target.configurations &&
81
+ Object.keys(target.configurations).length !== 0) {
82
+ for (const configuration in target.configurations) {
83
+ if (Object.keys(target.configurations[configuration]).length === 0) {
84
+ delete target.configurations[configuration];
85
+ }
86
+ }
87
+ if (Object.keys(target.configurations).length === 0) {
88
+ delete target.configurations;
89
+ }
90
+ }
91
+ }
92
+ return target;
93
+ }
94
+ exports.default = convertToInferred;
@@ -0,0 +1,12 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ /**
3
+ * Add or update the webServerCommands and ciWebServerCommand options in the Cypress Config
4
+ * Scenarios Covered:
5
+ * 1. Only devServerTarget Exists
6
+ * 2. devServerTarget and configuration.ci.devServerTarget Exists
7
+ *
8
+ * For each, the following scenarios are covered:
9
+ * a. The command is not listed in the config, so it is added
10
+ * b. Replace the existing webServerCommands with the value passed in
11
+ */
12
+ export declare function addDevServerTargetToConfig(tree: Tree, configFilePath: string, webServerCommands: Record<string, string>, ciDevServerTarget?: string): void;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addDevServerTargetToConfig = void 0;
4
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
5
+ /**
6
+ * Add or update the webServerCommands and ciWebServerCommand options in the Cypress Config
7
+ * Scenarios Covered:
8
+ * 1. Only devServerTarget Exists
9
+ * 2. devServerTarget and configuration.ci.devServerTarget Exists
10
+ *
11
+ * For each, the following scenarios are covered:
12
+ * a. The command is not listed in the config, so it is added
13
+ * b. Replace the existing webServerCommands with the value passed in
14
+ */
15
+ function addDevServerTargetToConfig(tree, configFilePath, webServerCommands, ciDevServerTarget) {
16
+ let configFileContents = tree.read(configFilePath, 'utf-8');
17
+ let ast = tsquery_1.tsquery.ast(configFileContents);
18
+ const NX_E2E_PRESET_SELECTOR = 'PropertyAssignment:has(Identifier[name=e2e]) CallExpression:has(Identifier[name=nxE2EPreset])';
19
+ const nxE2ePresetOptionsNodes = (0, tsquery_1.tsquery)(ast, NX_E2E_PRESET_SELECTOR, {
20
+ visitAllChildren: true,
21
+ });
22
+ if (nxE2ePresetOptionsNodes.length !== 0) {
23
+ const NX_E2E_PRESET_OPTIONS_SELECTOR = 'PropertyAssignment:has(Identifier[name=e2e]) CallExpression:has(Identifier[name=nxE2EPreset]) > ObjectLiteralExpression';
24
+ const optionsObjectNodes = (0, tsquery_1.tsquery)(ast, NX_E2E_PRESET_OPTIONS_SELECTOR, {
25
+ visitAllChildren: true,
26
+ });
27
+ const hasObjectDefinition = optionsObjectNodes?.length > 0;
28
+ let nxE2ePresetOptionsNode = nxE2ePresetOptionsNodes[0];
29
+ const WEB_SERVER_COMMANDS_SELECTOR = 'PropertyAssignment:has(Identifier[name=webServerCommands])';
30
+ const webServerCommandsNodes = (0, tsquery_1.tsquery)(nxE2ePresetOptionsNode, WEB_SERVER_COMMANDS_SELECTOR, { visitAllChildren: true });
31
+ if (webServerCommandsNodes.length !== 0) {
32
+ // Already exists, replace it
33
+ tree.write(configFilePath, `${configFileContents.slice(0, webServerCommandsNodes[0].getStart())}webServerCommands: ${JSON.stringify(webServerCommands)}${configFileContents.slice(webServerCommandsNodes[0].getEnd())}`);
34
+ }
35
+ else {
36
+ if (hasObjectDefinition) {
37
+ tree.write(configFilePath, `${configFileContents.slice(0, optionsObjectNodes[0].getStart() + 1)}webServerCommands: ${JSON.stringify(webServerCommands)},${configFileContents.slice(optionsObjectNodes[0].getStart() + 1)}`);
38
+ }
39
+ else {
40
+ tree.write(configFilePath, `${configFileContents.slice(0, nxE2ePresetOptionsNode.getEnd() - 1)},{ webServerCommands: ${JSON.stringify(webServerCommands)},}${configFileContents.slice(nxE2ePresetOptionsNode.getEnd() - 1)}`);
41
+ }
42
+ }
43
+ if (ciDevServerTarget) {
44
+ configFileContents = tree.read(configFilePath, 'utf-8');
45
+ ast = tsquery_1.tsquery.ast(configFileContents);
46
+ nxE2ePresetOptionsNode = (0, tsquery_1.tsquery)(ast, NX_E2E_PRESET_SELECTOR, {
47
+ visitAllChildren: true,
48
+ })[0];
49
+ const NX_E2E_PRESET_OPTIONS_SELECTOR = 'PropertyAssignment:has(Identifier[name=e2e]) CallExpression:has(Identifier[name=nxE2EPreset]) > ObjectLiteralExpression';
50
+ const optionsObjectNodes = (0, tsquery_1.tsquery)(ast, NX_E2E_PRESET_OPTIONS_SELECTOR, {
51
+ visitAllChildren: true,
52
+ });
53
+ const hasObjectDefinition = optionsObjectNodes?.length > 0;
54
+ const CI_WEB_SERVER_COMMANDS_SELECTOR = 'PropertyAssignment:has(Identifier[name=ciWebServerCommand])';
55
+ const ciWebServerCommandsNodes = (0, tsquery_1.tsquery)(nxE2ePresetOptionsNode, CI_WEB_SERVER_COMMANDS_SELECTOR, { visitAllChildren: true });
56
+ if (ciWebServerCommandsNodes.length !== 0) {
57
+ const ciWebServerCommandNode = ciWebServerCommandsNodes[0].getChildAt(2);
58
+ const ciWebServerCommand = ciWebServerCommandNode
59
+ .getText()
60
+ .replace(/["']/g, '');
61
+ if (!ciWebServerCommand.includes(ciDevServerTarget)) {
62
+ tree.write(configFilePath, `${configFileContents.slice(0, ciWebServerCommandNode.getStart())}"${ciDevServerTarget}"${configFileContents.slice(ciWebServerCommandNode.getEnd())}`);
63
+ }
64
+ }
65
+ else {
66
+ if (hasObjectDefinition) {
67
+ tree.write(configFilePath, `${configFileContents.slice(0, optionsObjectNodes[0].getStart() + 1)}ciWebServerCommand: "${ciDevServerTarget}",${configFileContents.slice(optionsObjectNodes[0].getStart() + 1)}`);
68
+ }
69
+ else {
70
+ tree.write(configFilePath, `${configFileContents.slice(0, nxE2ePresetOptionsNode.getEnd() - 1)},{ ciWebServerCommand: "${ciDevServerTarget}",}${configFileContents.slice(nxE2ePresetOptionsNode.getEnd() - 1)}`);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
76
+ exports.addDevServerTargetToConfig = addDevServerTargetToConfig;
@@ -0,0 +1,2 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export declare function addExcludeSpecPattern(tree: Tree, configFilePath: string, excludeSpecPattern: string | string[]): void;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addExcludeSpecPattern = void 0;
4
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
5
+ function addExcludeSpecPattern(tree, configFilePath, excludeSpecPattern) {
6
+ let configFileContents = tree.read(configFilePath, 'utf-8');
7
+ let ast = tsquery_1.tsquery.ast(configFileContents);
8
+ const E2E_CONFIG_SELECTOR = 'PropertyAssignment:has(Identifier[name=e2e]) > ObjectLiteralExpression';
9
+ const e2eConfigNodes = (0, tsquery_1.tsquery)(ast, E2E_CONFIG_SELECTOR, {
10
+ visitAllChildren: true,
11
+ });
12
+ if (e2eConfigNodes.length !== 0) {
13
+ const e2eConfigNode = e2eConfigNodes[0];
14
+ const EXCLUDE_SPEC_PATTERN_SELECTOR = 'PropertyAssignment:has(Identifier[name="excludeSpecPattern"])';
15
+ const excludeSpecPatternNodes = (0, tsquery_1.tsquery)(e2eConfigNode, EXCLUDE_SPEC_PATTERN_SELECTOR, { visitAllChildren: true });
16
+ if (excludeSpecPatternNodes.length !== 0) {
17
+ const excludeSpecPatternNode = excludeSpecPatternNodes[0];
18
+ let updatedExcludePattern = Array.isArray(excludeSpecPattern)
19
+ ? excludeSpecPattern
20
+ : [excludeSpecPattern];
21
+ tree.write(configFilePath, `${configFileContents.slice(0, excludeSpecPatternNode.getStart())}excludeSpecPattern: ${JSON.stringify(updatedExcludePattern)}${configFileContents.slice(excludeSpecPatternNode.getEnd())}`);
22
+ }
23
+ else {
24
+ tree.write(configFilePath, `${configFileContents.slice(0, e2eConfigNode.getStart() + 1)}excludeSpecPattern: ${JSON.stringify(excludeSpecPattern)},${configFileContents.slice(e2eConfigNode.getStart() + 1)}`);
25
+ }
26
+ }
27
+ }
28
+ exports.addExcludeSpecPattern = addExcludeSpecPattern;
@@ -0,0 +1,18 @@
1
+ export declare const targetOptionsToCliMap: {
2
+ headed: string;
3
+ headless: string;
4
+ key: string;
5
+ record: string;
6
+ parallel: string;
7
+ browser: string;
8
+ env: string;
9
+ spec: string;
10
+ ciBuildId: string;
11
+ group: string;
12
+ reporter: string;
13
+ reporterOptions: string;
14
+ tag: string;
15
+ port: string;
16
+ quiet: string;
17
+ runnerUi: string;
18
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.targetOptionsToCliMap = void 0;
4
+ exports.targetOptionsToCliMap = {
5
+ headed: 'headed',
6
+ headless: 'headless',
7
+ key: 'key',
8
+ record: 'record',
9
+ parallel: 'parallel',
10
+ browser: 'browser',
11
+ env: 'env',
12
+ spec: 'spec',
13
+ ciBuildId: 'ci-build-id',
14
+ group: 'group',
15
+ reporter: 'reporter',
16
+ reporterOptions: 'reporter-options',
17
+ tag: 'tag',
18
+ port: 'port',
19
+ quiet: 'quiet',
20
+ runnerUi: 'runner-ui',
21
+ };
@@ -0,0 +1,2 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export declare function upsertBaseUrl(tree: Tree, configFilePath: string, baseUrlValueInProject: string): void;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.upsertBaseUrl = void 0;
4
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
5
+ function upsertBaseUrl(tree, configFilePath, baseUrlValueInProject) {
6
+ const configFileContents = tree.read(configFilePath, 'utf-8');
7
+ const ast = tsquery_1.tsquery.ast(configFileContents);
8
+ const BASE_URL_SELECTOR = 'PropertyAssignment:has(Identifier[name=e2e]) PropertyAssignment:has(Identifier[name="baseUrl"])';
9
+ const baseUrlNodes = (0, tsquery_1.tsquery)(ast, BASE_URL_SELECTOR, {
10
+ visitAllChildren: true,
11
+ });
12
+ if (baseUrlNodes.length !== 0) {
13
+ // The property exists in the config
14
+ const baseUrlValueNode = baseUrlNodes[0].getChildAt(2);
15
+ const baseUrlValue = baseUrlValueNode.getText().replace(/(["'])/, '');
16
+ if (baseUrlValue === baseUrlValueInProject) {
17
+ return;
18
+ }
19
+ tree.write(configFilePath, `${configFileContents.slice(0, baseUrlValueNode.getStart())}"${baseUrlValueInProject}"${configFileContents.slice(baseUrlValueNode.getEnd())}`);
20
+ }
21
+ else {
22
+ const E2E_OBJECT_SELECTOR = 'PropertyAssignment:has(Identifier[name=e2e]) ObjectLiteralExpression';
23
+ const e2eConfigNodes = (0, tsquery_1.tsquery)(ast, E2E_OBJECT_SELECTOR, {
24
+ visitAllChildren: true,
25
+ });
26
+ if (e2eConfigNodes.length !== 0) {
27
+ const e2eConfigNode = e2eConfigNodes[0];
28
+ tree.write(configFilePath, `${configFileContents.slice(0, e2eConfigNode.getEnd() - 1)}baseUrl: "${baseUrlValueInProject}",
29
+ ${configFileContents.slice(e2eConfigNode.getEnd() - 1)}`);
30
+ }
31
+ }
32
+ }
33
+ exports.upsertBaseUrl = upsertBaseUrl;
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "NxCypressConvertToInferred",
4
+ "description": "Convert existing Cypress project(s) using `@nx/cypress:cypress` executor to use `@nx/cypress/plugin`.",
5
+ "title": "Convert Cypress project from executor to plugin",
6
+ "type": "object",
7
+ "properties": {
8
+ "project": {
9
+ "type": "string",
10
+ "description": "The project to convert from using the `@nx/cypress:cypress` executor to use `@nx/cypress/plugin`.",
11
+ "x-priority": "important"
12
+ },
13
+ "skipFormat": {
14
+ "type": "boolean",
15
+ "description": "Whether to format files at the end of the migration.",
16
+ "default": false
17
+ }
18
+ }
19
+ }
@@ -1,6 +1,6 @@
1
- import { GeneratorCallback, Tree } from '@nx/devkit';
1
+ import { GeneratorCallback, ProjectGraph, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
- export declare function addPlugin(tree: Tree): void;
3
+ export declare function addPlugin(tree: Tree, graph: ProjectGraph, updatePackageScripts: boolean): Promise<void>;
4
4
  export declare function cypressInitGenerator(tree: Tree, options: Schema): Promise<GeneratorCallback>;
5
5
  export declare function cypressInitGeneratorInternal(tree: Tree, options: Schema): Promise<GeneratorCallback>;
6
6
  export default cypressInitGenerator;