@nx/playwright 19.6.0-canary.20240803-bd7a2c9 → 19.6.0-canary.20240808-333ab77
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/playwright",
|
|
3
|
-
"version": "19.6.0-canary.
|
|
3
|
+
"version": "19.6.0-canary.20240808-333ab77",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"homepage": "https://nx.dev",
|
|
6
6
|
"private": false,
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
38
|
-
"@nx/devkit": "19.6.0-canary.
|
|
39
|
-
"@nx/eslint": "19.6.0-canary.
|
|
40
|
-
"@nx/js": "19.6.0-canary.
|
|
38
|
+
"@nx/devkit": "19.6.0-canary.20240808-333ab77",
|
|
39
|
+
"@nx/eslint": "19.6.0-canary.20240808-333ab77",
|
|
40
|
+
"@nx/js": "19.6.0-canary.20240808-333ab77",
|
|
41
41
|
"tslib": "^2.3.0",
|
|
42
42
|
"minimatch": "9.0.3"
|
|
43
43
|
},
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = addE2eCiTargetDefaults;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
6
|
+
const internal_api_1 = require("nx/src/project-graph/plugins/internal-api");
|
|
7
|
+
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
8
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
9
|
+
async function addE2eCiTargetDefaults(tree) {
|
|
10
|
+
const pluginName = '@nx/playwright/plugin';
|
|
11
|
+
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
|
12
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
13
|
+
const matchingPluginRegistrations = nxJson.plugins?.filter((p) => typeof p === 'string' ? p === pluginName : p.plugin === pluginName);
|
|
14
|
+
if (!matchingPluginRegistrations) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const { createNodesV2, } = await Promise.resolve(`${pluginName}`).then(s => require(s));
|
|
18
|
+
for (const plugin of matchingPluginRegistrations) {
|
|
19
|
+
let projectConfigs;
|
|
20
|
+
try {
|
|
21
|
+
const loadedPlugin = new internal_api_1.LoadedNxPlugin({ createNodesV2, name: pluginName }, plugin);
|
|
22
|
+
projectConfigs = await (0, devkit_internals_1.retrieveProjectConfigurations)([loadedPlugin], tree.root, nxJson);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
if (e instanceof devkit_internals_1.ProjectConfigurationsError) {
|
|
26
|
+
projectConfigs = e.partialProjectConfigurationsResult;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
for (const configFile of projectConfigs.matchingProjectFiles) {
|
|
33
|
+
const configFileContents = tree.read(configFile, 'utf-8');
|
|
34
|
+
const ast = tsquery_1.tsquery.ast(configFileContents);
|
|
35
|
+
const CI_WEBSERVER_COMMAND_SELECTOR = 'PropertyAssignment:has(Identifier[name=webServer]) PropertyAssignment:has(Identifier[name=command]) > StringLiteral';
|
|
36
|
+
const nodes = (0, tsquery_1.tsquery)(ast, CI_WEBSERVER_COMMAND_SELECTOR, {
|
|
37
|
+
visitAllChildren: true,
|
|
38
|
+
});
|
|
39
|
+
if (!nodes.length) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const ciWebServerCommand = nodes[0].getText();
|
|
43
|
+
let serveStaticProject;
|
|
44
|
+
let serveStaticTarget;
|
|
45
|
+
let serveStaticConfiguration;
|
|
46
|
+
if (ciWebServerCommand.includes('nx run')) {
|
|
47
|
+
const NX_TARGET_REGEX = "(?<=nx run )[^']+";
|
|
48
|
+
const matches = ciWebServerCommand.match(NX_TARGET_REGEX);
|
|
49
|
+
if (!matches) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const targetString = matches[0];
|
|
53
|
+
const { project, target, configuration } = (0, devkit_1.parseTargetString)(targetString, graph);
|
|
54
|
+
serveStaticProject = project;
|
|
55
|
+
serveStaticTarget = target;
|
|
56
|
+
serveStaticConfiguration = configuration;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const NX_PROJECT_REGEX = 'nx\\s+([^ ]+)\\s+([^ ]+)';
|
|
60
|
+
const matches = ciWebServerCommand.match(NX_PROJECT_REGEX);
|
|
61
|
+
if (!matches) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
serveStaticTarget = matches[1];
|
|
65
|
+
serveStaticProject = matches[2];
|
|
66
|
+
}
|
|
67
|
+
const resolvedServeStaticTarget = graph.nodes[serveStaticProject].data.targets[serveStaticTarget];
|
|
68
|
+
let resolvedBuildTarget;
|
|
69
|
+
if (resolvedServeStaticTarget.dependsOn) {
|
|
70
|
+
resolvedBuildTarget = resolvedServeStaticTarget.dependsOn.join(',');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
resolvedBuildTarget =
|
|
74
|
+
(serveStaticConfiguration
|
|
75
|
+
? resolvedServeStaticTarget.configurations[serveStaticConfiguration]
|
|
76
|
+
.buildTarget
|
|
77
|
+
: resolvedServeStaticTarget.options.buildTarget) ?? 'build';
|
|
78
|
+
}
|
|
79
|
+
const buildTarget = `^${resolvedBuildTarget}`;
|
|
80
|
+
await (0, target_defaults_utils_1.addE2eCiTargetDefaults)(tree, pluginName, buildTarget, configFile);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
+
const add_e2e_ci_target_defaults_1 = require("./add-e2e-ci-target-defaults");
|
|
6
7
|
async function default_1(tree) {
|
|
7
8
|
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
|
8
9
|
(0, devkit_1.visitNotIgnoredFiles)(tree, '', (path) => {
|
|
@@ -80,5 +81,6 @@ async function default_1(tree) {
|
|
|
80
81
|
tree.write(path, `${playwrightConfigFileContents.slice(0, webServerUrlNode.getStart())}${newWebServerUrl}${playwrightConfigFileContents.slice(webServerUrlNode.getEnd())}`);
|
|
81
82
|
}
|
|
82
83
|
});
|
|
84
|
+
await (0, add_e2e_ci_target_defaults_1.default)(tree);
|
|
83
85
|
await (0, devkit_1.formatFiles)(tree);
|
|
84
86
|
}
|