@nx/playwright 19.6.0 → 19.7.0-beta.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/package.json +6 -6
- package/src/executors/playwright/schema.json +1 -12
- package/src/generators/configuration/schema.d.ts +2 -2
- package/src/migrations/update-19-6-0/add-e2e-ci-target-defaults.js +2 -2
- package/src/migrations/update-19-6-0/use-serve-static-preview-for-command.js +17 -7
- package/src/utils/add-linter.d.ts +2 -2
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
|
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.
|
3
|
+
"version": "19.7.0-beta.0",
|
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.
|
39
|
-
"@nx/eslint": "19.
|
40
|
-
"@nx/webpack": "19.
|
41
|
-
"@nx/vite": "19.
|
42
|
-
"@nx/js": "19.
|
38
|
+
"@nx/devkit": "19.7.0-beta.0",
|
39
|
+
"@nx/eslint": "19.7.0-beta.0",
|
40
|
+
"@nx/webpack": "19.7.0-beta.0",
|
41
|
+
"@nx/vite": "19.7.0-beta.0",
|
42
|
+
"@nx/js": "19.7.0-beta.0",
|
43
43
|
"tslib": "^2.3.0",
|
44
44
|
"minimatch": "9.0.3"
|
45
45
|
},
|
@@ -105,18 +105,7 @@
|
|
105
105
|
},
|
106
106
|
"reporter": {
|
107
107
|
"type": "string",
|
108
|
-
"
|
109
|
-
"list",
|
110
|
-
"line",
|
111
|
-
"dot",
|
112
|
-
"json",
|
113
|
-
"junit",
|
114
|
-
"null",
|
115
|
-
"github",
|
116
|
-
"html",
|
117
|
-
"blob"
|
118
|
-
],
|
119
|
-
"description": "Reporter to use, comma-separated, can be 'list', 'line', 'dot', 'json', 'junit', 'null', 'github', 'html', 'blob'. To configure reporter options, use the playwright configuration."
|
108
|
+
"description": "Common Reporter values to use, comma-separated, 'list', 'line', 'dot', 'json', 'junit', 'null', 'github', 'html', 'blob'. To configure reporter options, use the playwright configuration."
|
120
109
|
},
|
121
110
|
"retries": {
|
122
111
|
"type": "number",
|
@@ -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
|
@@ -40,7 +40,7 @@ async function addE2eCiTargetDefaults(tree) {
|
|
40
40
|
if (!nodes.length) {
|
41
41
|
continue;
|
42
42
|
}
|
43
|
-
const ciWebServerCommand = nodes[0].getText();
|
43
|
+
const ciWebServerCommand = nodes[0].getText().replace(/['"]/g, '');
|
44
44
|
let serveStaticProject;
|
45
45
|
let serveStaticTarget;
|
46
46
|
let serveStaticConfiguration;
|
@@ -65,7 +65,7 @@ async function addE2eCiTargetDefaults(tree) {
|
|
65
65
|
serveStaticTarget = matches[1];
|
66
66
|
serveStaticProject = matches[2];
|
67
67
|
}
|
68
|
-
const resolvedServeStaticTarget = graph.nodes[serveStaticProject]
|
68
|
+
const resolvedServeStaticTarget = graph.nodes[serveStaticProject]?.data?.targets?.[serveStaticTarget];
|
69
69
|
if (!resolvedServeStaticTarget) {
|
70
70
|
continue;
|
71
71
|
}
|
@@ -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 =
|
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[
|
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 =
|
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[
|
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 =
|
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 =
|
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;
|