@nx/playwright 19.7.0-canary.20240821-2065033 → 19.7.0-canary.20240822-d6a0cfb
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/playwright",
|
3
|
-
"version": "19.7.0-canary.
|
3
|
+
"version": "19.7.0-canary.20240822-d6a0cfb",
|
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.7.0-canary.
|
39
|
-
"@nx/eslint": "19.7.0-canary.
|
40
|
-
"@nx/webpack": "19.7.0-canary.
|
41
|
-
"@nx/vite": "19.7.0-canary.
|
42
|
-
"@nx/js": "19.7.0-canary.
|
38
|
+
"@nx/devkit": "19.7.0-canary.20240822-d6a0cfb",
|
39
|
+
"@nx/eslint": "19.7.0-canary.20240822-d6a0cfb",
|
40
|
+
"@nx/webpack": "19.7.0-canary.20240822-d6a0cfb",
|
41
|
+
"@nx/vite": "19.7.0-canary.20240822-d6a0cfb",
|
42
|
+
"@nx/js": "19.7.0-canary.20240822-d6a0cfb",
|
43
43
|
"tslib": "^2.3.0",
|
44
44
|
"minimatch": "9.0.3"
|
45
45
|
},
|
@@ -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
|
}
|