@nx/cypress 18.0.4 → 18.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/cypress",
3
- "version": "18.0.4",
3
+ "version": "18.1.0-beta.1",
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": {
@@ -34,14 +34,14 @@
34
34
  "migrations": "./migrations.json"
35
35
  },
36
36
  "dependencies": {
37
- "@nx/devkit": "18.0.4",
38
- "@nx/eslint": "18.0.4",
39
- "@nx/js": "18.0.4",
37
+ "@nx/devkit": "18.1.0-beta.1",
38
+ "@nx/eslint": "18.1.0-beta.1",
39
+ "@nx/js": "18.1.0-beta.1",
40
40
  "@phenomnomnominal/tsquery": "~5.0.1",
41
41
  "detect-port": "^1.5.1",
42
42
  "semver": "^7.5.3",
43
43
  "tslib": "^2.3.0",
44
- "@nrwl/cypress": "18.0.4"
44
+ "@nrwl/cypress": "18.1.0-beta.1"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "cypress": ">= 3 < 14"
@@ -61,12 +61,21 @@ function startWebServer(webServerCommand) {
61
61
  */
62
62
  function nxE2EPreset(pathToConfig, options) {
63
63
  const basePath = options?.cypressDir || 'src';
64
+ const dir = (0, path_1.dirname)(pathToConfig);
65
+ let supportFile = undefined;
66
+ for (const f of ['e2e.ts', 'e2e.js']) {
67
+ const candidate = (0, path_1.join)(dir, basePath, 'support', f);
68
+ if ((0, fs_1.existsSync)(candidate)) {
69
+ supportFile = candidate;
70
+ break;
71
+ }
72
+ }
64
73
  const baseConfig /*Cypress.EndToEndConfigOptions & {
65
74
  [NX_PLUGIN_OPTIONS]: unknown;
66
75
  }*/ = {
67
76
  ...nxBaseCypressPreset(pathToConfig),
68
77
  fileServerFolder: '.',
69
- supportFile: `${basePath}/support/e2e.{js,ts}`,
78
+ supportFile,
70
79
  specPattern: `${basePath}/**/*.cy.{js,jsx,ts,tsx}`,
71
80
  fixturesFolder: `${basePath}/fixtures`,
72
81
  [constants_1.NX_PLUGIN_OPTIONS]: {
@@ -27,7 +27,7 @@ async function componentConfigurationGeneratorInternal(tree, options) {
27
27
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, opts.project);
28
28
  tasks.push(updateDeps(tree, opts));
29
29
  addProjectFiles(tree, projectConfig, opts);
30
- if (!hasPlugin) {
30
+ if (!hasPlugin || opts.addExplicitTargets) {
31
31
  addTargetToProject(tree, projectConfig, opts);
32
32
  }
33
33
  updateNxJsonConfiguration(tree, hasPlugin);
@@ -5,4 +5,9 @@ export interface CypressComponentConfigurationSchema {
5
5
  bundler?: 'webpack' | 'vite';
6
6
  jsx?: boolean;
7
7
  addPlugin?: boolean;
8
+
9
+ /**
10
+ * @internal
11
+ */
12
+ addExplicitTargets?: boolean;
8
13
  }
@@ -12,7 +12,10 @@ const versions_1 = require("../../utils/versions");
12
12
  const init_1 = require("../init/init");
13
13
  const base_setup_1 = require("../base-setup/base-setup");
14
14
  function configurationGenerator(tree, options) {
15
- return configurationGeneratorInternal(tree, { addPlugin: false, ...options });
15
+ return configurationGeneratorInternal(tree, {
16
+ addPlugin: false,
17
+ ...options,
18
+ });
16
19
  }
17
20
  exports.configurationGenerator = configurationGenerator;
18
21
  async function configurationGeneratorInternal(tree, options) {
@@ -38,6 +41,7 @@ async function configurationGeneratorInternal(tree, options) {
38
41
  const linterTask = await (0, add_linter_1.addLinterToCyProject)(tree, {
39
42
  ...opts,
40
43
  cypressDir: opts.directory,
44
+ addPlugin: opts.addPlugin,
41
45
  });
42
46
  tasks.push(linterTask);
43
47
  if (!opts.skipPackageJson) {
@@ -128,11 +132,12 @@ async function addFiles(tree, options, projectGraph, hasPlugin) {
128
132
  const devServerProjectConfig = (0, devkit_1.readProjectConfiguration)(tree, parsedTarget.project);
129
133
  // Add production e2e target if serve target is found
130
134
  if (parsedTarget.configuration !== 'production' &&
131
- devServerProjectConfig.targets[parsedTarget.target]?.configurations?.['production']) {
135
+ devServerProjectConfig?.targets?.[parsedTarget.target]
136
+ ?.configurations?.['production']) {
132
137
  webServerCommands.production = `nx run ${parsedTarget.project}:${parsedTarget.target}:production`;
133
138
  }
134
139
  // Add ci/static e2e target if serve target is found
135
- if (devServerProjectConfig.targets?.['serve-static']) {
140
+ if (devServerProjectConfig?.targets?.['serve-static']) {
136
141
  ciWebServerCommand = `nx run ${parsedTarget.project}:serve-static`;
137
142
  }
138
143
  }
@@ -165,6 +170,7 @@ async function addFiles(tree, options, projectGraph, hasPlugin) {
165
170
  function addTarget(tree, opts) {
166
171
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, opts.project);
167
172
  const cyVersion = (0, cypress_version_1.installedCypressVersion)();
173
+ projectConfig.targets ??= {};
168
174
  projectConfig.targets.e2e = {
169
175
  executor: '@nx/cypress:cypress',
170
176
  options: {
@@ -17,5 +17,6 @@ export interface CyLinterOptions {
17
17
  * This is useful when adding linting to a brand new project vs an existing one
18
18
  **/
19
19
  overwriteExisting?: boolean;
20
+ addPlugin?: boolean;
20
21
  }
21
22
  export declare function addLinterToCyProject(tree: Tree, options: CyLinterOptions): Promise<() => void>;
@@ -23,6 +23,7 @@ async function addLinterToCyProject(tree, options) {
23
23
  setParserOptionsProject: options.setParserOptionsProject,
24
24
  skipPackageJson: options.skipPackageJson,
25
25
  rootProject: options.rootProject,
26
+ addPlugin: options.addPlugin,
26
27
  }));
27
28
  }
28
29
  if (!options.linter || options.linter !== eslint_1.Linter.EsLint) {