@nx/cypress 19.6.0 → 19.6.2

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/README.md CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # Nx: Smart Monorepos · Fast CI
24
24
 
25
- Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
25
+ Nx is a build system, optimized for monorepos, with plugins for popular frameworks and tools and advanced CI capabilities including caching and distribution.
26
26
 
27
27
  This package is a [Cypress plugin for Nx](https://nx.dev/cypress/overview).
28
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/cypress",
3
- "version": "19.6.0",
3
+ "version": "19.6.2",
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,13 @@
36
36
  "migrations": "./migrations.json"
37
37
  },
38
38
  "dependencies": {
39
- "@nx/devkit": "19.6.0",
40
- "@nx/eslint": "19.6.0",
41
- "@nx/js": "19.6.0",
39
+ "@nx/devkit": "19.6.2",
40
+ "@nx/eslint": "19.6.2",
41
+ "@nx/js": "19.6.2",
42
42
  "@phenomnomnominal/tsquery": "~5.0.1",
43
43
  "detect-port": "^1.5.1",
44
44
  "tslib": "^2.3.0",
45
- "@nrwl/cypress": "19.6.0"
45
+ "@nrwl/cypress": "19.6.2"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "cypress": ">= 3 < 14"
@@ -1,5 +1,5 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
- import { Linter } from '@nx/eslint';
2
+ import { Linter, LinterType } from '@nx/eslint';
3
3
  export interface CypressE2EConfigSchema {
4
4
  project: string;
5
5
  baseUrl?: string;
@@ -10,7 +10,7 @@ export interface CypressE2EConfigSchema {
10
10
  skipPackageJson?: boolean;
11
11
  bundler?: 'webpack' | 'vite' | 'none';
12
12
  devServerTarget?: string;
13
- linter?: Linter;
13
+ linter?: Linter | LinterType;
14
14
  port?: number | 'cypress-auto';
15
15
  jsx?: boolean;
16
16
  rootProject?: boolean;
@@ -10,6 +10,9 @@ async function default_1(tree) {
10
10
  const graph = await (0, devkit_1.createProjectGraphAsync)();
11
11
  const nxJson = (0, devkit_1.readNxJson)(tree);
12
12
  const matchingPluginRegistrations = nxJson.plugins?.filter((p) => typeof p === 'string' ? p === pluginName : p.plugin === pluginName);
13
+ if (!matchingPluginRegistrations?.length) {
14
+ return;
15
+ }
13
16
  const { createNodesV2, } = await Promise.resolve(`${pluginName}`).then(s => require(s));
14
17
  for (const plugin of matchingPluginRegistrations) {
15
18
  let projectConfigs;
@@ -39,13 +42,30 @@ async function default_1(tree) {
39
42
  continue;
40
43
  }
41
44
  const ciWebServerCommand = nodes[0].getText();
42
- const NX_TARGET_REGEX = "(?<=nx run )[^']+";
43
- const matches = ciWebServerCommand.match(NX_TARGET_REGEX);
44
- if (!matches) {
45
+ let project;
46
+ let portFlagValue;
47
+ if (ciWebServerCommand.includes('nx run')) {
48
+ const NX_TARGET_REGEX = /(?<=nx run )([^' ]+)(?: [^']*--port[= ](\d+))?/;
49
+ const matches = ciWebServerCommand.match(NX_TARGET_REGEX);
50
+ if (!matches) {
51
+ continue;
52
+ }
53
+ const targetString = matches[1];
54
+ project = (0, devkit_1.parseTargetString)(targetString, graph).project;
55
+ portFlagValue = matches[2];
56
+ }
57
+ else {
58
+ const NX_PROJECT_REGEX = /(?<=nx [^ ]+ )([^' ]+)(?: [^']*--port[= ](\d+))?/;
59
+ const matches = ciWebServerCommand.match(NX_PROJECT_REGEX);
60
+ if (!matches) {
61
+ continue;
62
+ }
63
+ project = matches[1];
64
+ portFlagValue = matches[2];
65
+ }
66
+ if (!project || !graph.nodes[project]) {
45
67
  continue;
46
68
  }
47
- const targetString = matches[0];
48
- const { project, target, configuration } = (0, devkit_1.parseTargetString)(targetString, graph);
49
69
  const pathToViteConfig = [
50
70
  (0, devkit_1.joinPathFragments)(graph.nodes[project].data.root, 'vite.config.ts'),
51
71
  (0, devkit_1.joinPathFragments)(graph.nodes[project].data.root, 'vite.config.js'),
@@ -68,7 +88,7 @@ async function default_1(tree) {
68
88
  if (!serveStaticTargetName) {
69
89
  continue;
70
90
  }
71
- const newCommand = ciWebServerCommand.replace(/nx.*[^"']/, `nx run ${project}:${serveStaticTargetName}`);
91
+ const newCommand = ciWebServerCommand.replace(/nx.*[^"']/, `nx run ${project}:${serveStaticTargetName}${portFlagValue ? ` --port=${portFlagValue}` : ''}`);
72
92
  tree.write(configFile, `${configFileContents.slice(0, nodes[0].getStart())}${newCommand}${configFileContents.slice(nodes[0].getEnd())}`);
73
93
  }
74
94
  else if (pathToViteConfig) {
@@ -86,9 +106,9 @@ async function default_1(tree) {
86
106
  if (!previewTargetName) {
87
107
  continue;
88
108
  }
89
- const newCommand = ciWebServerCommand.replace(/nx.*[^"']/, `nx run ${project}:${previewTargetName}`);
109
+ const newCommand = ciWebServerCommand.replace(/nx.*[^"']/, `nx run ${project}:${previewTargetName}${portFlagValue ? ` --port=${portFlagValue}` : ''}`);
90
110
  tree.write(configFile, `${configFileContents.slice(0, nodes[0].getStart())}${newCommand},
91
- ciBaseUrl: "http://localhost:4300"${configFileContents.slice(nodes[0].getEnd())}`);
111
+ ciBaseUrl: "http://localhost:${portFlagValue ?? '4300'}"${configFileContents.slice(nodes[0].getEnd())}`);
92
112
  }
93
113
  }
94
114
  }
@@ -1,8 +1,8 @@
1
1
  import { Tree } from '@nx/devkit';
2
- import { Linter } from '@nx/eslint';
2
+ import { Linter, LinterType } from '@nx/eslint';
3
3
  export interface CyLinterOptions {
4
4
  project: string;
5
- linter: Linter;
5
+ linter: Linter | LinterType;
6
6
  setParserOptionsProject?: boolean;
7
7
  skipPackageJson?: boolean;
8
8
  rootProject?: boolean;