@nx/playwright 19.6.1 → 19.6.2

Sign up to get free protection for your applications and to get access to all the features.
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
  ## Getting Started
28
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/playwright",
3
- "version": "19.6.1",
3
+ "version": "19.6.2",
4
4
  "type": "commonjs",
5
5
  "homepage": "https://nx.dev",
6
6
  "private": false,
@@ -35,11 +35,11 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@phenomnomnominal/tsquery": "~5.0.1",
38
- "@nx/devkit": "19.6.1",
39
- "@nx/eslint": "19.6.1",
40
- "@nx/webpack": "19.6.1",
41
- "@nx/vite": "19.6.1",
42
- "@nx/js": "19.6.1",
38
+ "@nx/devkit": "19.6.2",
39
+ "@nx/eslint": "19.6.2",
40
+ "@nx/webpack": "19.6.2",
41
+ "@nx/vite": "19.6.2",
42
+ "@nx/js": "19.6.2",
43
43
  "tslib": "^2.3.0",
44
44
  "minimatch": "9.0.3"
45
45
  },
@@ -1,4 +1,4 @@
1
- import type { Linter } from '@nx/eslint';
1
+ import type { Linter, LinterType } from '@nx/eslint';
2
2
 
3
3
  export interface ConfigurationGeneratorSchema {
4
4
  project: string;
@@ -10,7 +10,7 @@ export interface ConfigurationGeneratorSchema {
10
10
  skipFormat: boolean;
11
11
  skipPackageJson: boolean;
12
12
  skipInstall?: boolean;
13
- linter: Linter;
13
+ linter: Linter | LinterType;
14
14
  setParserOptionsProject: boolean; // default is false
15
15
  /**
16
16
  * command to give playwright to run the web server
@@ -28,27 +28,33 @@ async function default_1(tree) {
28
28
  const commandValueNode = nodes[0];
29
29
  const command = commandValueNode.getText();
30
30
  let project;
31
+ let portFlagValue;
31
32
  if (command.includes('nx run')) {
32
- const NX_RUN_TARGET_REGEX = "(?<=nx run )[^']+";
33
+ const NX_RUN_TARGET_REGEX = /(?<=nx run )([^' ]+)(?: [^']*--port[= ](\d+))?/;
33
34
  const matches = command.match(NX_RUN_TARGET_REGEX);
34
35
  if (!matches) {
35
36
  return;
36
37
  }
37
- const targetString = matches[0];
38
+ const targetString = matches[1];
38
39
  const parsedTargetString = (0, devkit_1.parseTargetString)(targetString, graph);
39
40
  if (parsedTargetString.target === 'serve-static' ||
40
41
  parsedTargetString.target === 'preview') {
41
42
  return;
42
43
  }
43
44
  project = parsedTargetString.project;
45
+ portFlagValue = matches[2];
44
46
  }
45
47
  else {
46
- const NX_PROJECT_REGEX = "(?<=nx [^ ]+ )[^']+";
48
+ const NX_PROJECT_REGEX = /(?<=nx [^ ]+ )([^' ]+)(?: [^']*--port[= ](\d+))?/;
47
49
  const matches = command.match(NX_PROJECT_REGEX);
48
50
  if (!matches) {
49
51
  return;
50
52
  }
51
- project = matches[0];
53
+ project = matches[1];
54
+ portFlagValue = matches[2];
55
+ }
56
+ if (!project || !graph.nodes[project]) {
57
+ return;
52
58
  }
53
59
  const pathToViteConfig = [
54
60
  (0, devkit_1.joinPathFragments)(graph.nodes[project].data.root, 'vite.config.ts'),
@@ -67,6 +73,7 @@ async function default_1(tree) {
67
73
  configFileType: pathToWebpackConfig ? 'webpack' : 'vite',
68
74
  playwrightConfigFile: path,
69
75
  commandValueNode,
76
+ portFlagValue,
70
77
  });
71
78
  }
72
79
  });
@@ -88,7 +95,9 @@ async function default_1(tree) {
88
95
  continue;
89
96
  }
90
97
  const oldCommand = projectToMigrate.commandValueNode.getText();
91
- const newCommand = oldCommand.replace(/nx.*[^"']/, `nx run ${projectToMigrate.projectName}:${targetName}`);
98
+ const newCommand = oldCommand.replace(/nx.*[^"']/, `nx run ${projectToMigrate.projectName}:${targetName}${projectToMigrate.portFlagValue
99
+ ? ` --port=${projectToMigrate.portFlagValue}`
100
+ : ''}`);
92
101
  if (projectToMigrate.configFileType === 'webpack') {
93
102
  tree.write(projectToMigrate.playwrightConfigFile, `${playwrightConfigFileContents.slice(0, projectToMigrate.commandValueNode.getStart())}${newCommand}${playwrightConfigFileContents.slice(projectToMigrate.commandValueNode.getEnd())}`);
94
103
  }
@@ -103,8 +112,9 @@ async function default_1(tree) {
103
112
  if (!baseUrlNodes.length) {
104
113
  return;
105
114
  }
115
+ const serverUrl = `http://localhost:${projectToMigrate.portFlagValue ?? '4300'}`;
106
116
  const baseUrlNode = baseUrlNodes[0];
107
- const newBaseUrlVariableDeclaration = "baseURL = process.env['BASE_URL'] || 'http://localhost:4300';";
117
+ const newBaseUrlVariableDeclaration = `baseURL = process.env['BASE_URL'] || '${serverUrl}';`;
108
118
  tree.write(projectToMigrate.playwrightConfigFile, `${playwrightConfigFileContents.slice(0, baseUrlNode.getStart())}${newBaseUrlVariableDeclaration}${playwrightConfigFileContents.slice(baseUrlNode.getEnd())}`);
109
119
  playwrightConfigFileContents = tree.read(projectToMigrate.playwrightConfigFile, 'utf-8');
110
120
  ast = tsquery_1.tsquery.ast(playwrightConfigFileContents);
@@ -116,7 +126,7 @@ async function default_1(tree) {
116
126
  return;
117
127
  }
118
128
  const webServerUrlNode = webServerUrlNodes[0];
119
- const newWebServerUrl = "'http://localhost:4300'";
129
+ const newWebServerUrl = `'${serverUrl}'`;
120
130
  tree.write(projectToMigrate.playwrightConfigFile, `${playwrightConfigFileContents.slice(0, webServerUrlNode.getStart())}${newWebServerUrl}${playwrightConfigFileContents.slice(webServerUrlNode.getEnd())}`);
121
131
  }
122
132
  }
@@ -1,8 +1,8 @@
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 PlaywrightLinterOptions {
4
4
  project: string;
5
- linter: Linter;
5
+ linter: Linter | LinterType;
6
6
  setParserOptionsProject: boolean;
7
7
  skipPackageJson: boolean;
8
8
  rootProject: boolean;