@nx/playwright 20.4.0-rc.0 → 20.4.1

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/generators.json CHANGED
@@ -10,7 +10,8 @@
10
10
  "init": {
11
11
  "factory": "./src/generators/init/init#initGeneratorInternal",
12
12
  "schema": "./src/generators/init/schema.json",
13
- "description": "Initializes a Playwright project in the current workspace"
13
+ "description": "Initializes a Playwright project in the current workspace",
14
+ "hidden": true
14
15
  },
15
16
  "convert-to-inferred": {
16
17
  "factory": "./src/generators/convert-to-inferred/convert-to-inferred",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/playwright",
3
- "version": "20.4.0-rc.0",
3
+ "version": "20.4.1",
4
4
  "type": "commonjs",
5
5
  "homepage": "https://nx.dev",
6
6
  "private": false,
@@ -35,20 +35,26 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@phenomnomnominal/tsquery": "~5.0.1",
38
- "@nx/devkit": "20.4.0-rc.0",
39
- "@nx/eslint": "20.4.0-rc.0",
40
- "@nx/webpack": "20.4.0-rc.0",
41
- "@nx/vite": "20.4.0-rc.0",
42
- "@nx/js": "20.4.0-rc.0",
38
+ "@nx/devkit": "20.4.1",
39
+ "@nx/eslint": "20.4.1",
40
+ "@nx/js": "20.4.1",
43
41
  "tslib": "^2.3.0",
44
42
  "minimatch": "9.0.3"
45
43
  },
46
44
  "peerDependencies": {
47
- "@playwright/test": "^1.36.0"
45
+ "@playwright/test": "^1.36.0",
46
+ "@nx/webpack": "file:../webpack",
47
+ "@nx/vite": "file:../vite"
48
48
  },
49
49
  "peerDependenciesMeta": {
50
50
  "@playwright/test": {
51
51
  "optional": true
52
+ },
53
+ "@nx/webpack": {
54
+ "optional": true
55
+ },
56
+ "@nx/vite": {
57
+ "optional": true
52
58
  }
53
59
  },
54
60
  "executors": "./executors.json",
@@ -7,8 +7,6 @@ const add_e2e_ci_target_defaults_1 = require("./add-e2e-ci-target-defaults");
7
7
  const loaded_nx_plugin_1 = require("nx/src/project-graph/plugins/loaded-nx-plugin");
8
8
  const retrieve_workspace_files_1 = require("nx/src/project-graph/utils/retrieve-workspace-files");
9
9
  const error_types_1 = require("nx/src/project-graph/error-types");
10
- const plugin_1 = require("@nx/webpack/src/plugins/plugin");
11
- const plugin_2 = require("@nx/vite/plugin");
12
10
  async function default_1(tree) {
13
11
  const graph = await (0, devkit_1.createProjectGraphAsync)();
14
12
  const collectedProjects = [];
@@ -86,8 +84,8 @@ async function default_1(tree) {
86
84
  : 'preview', projectToMigrate.configFileType === 'webpack'
87
85
  ? 'serveStaticTargetName'
88
86
  : 'previewTargetName', projectToMigrate.configFileType === 'webpack'
89
- ? plugin_1.createNodesV2
90
- : plugin_2.createNodesV2)) ??
87
+ ? (await getDynamicImportedModule('@nx/webpack/src/plugins/plugin', '@nx/webpack should be installed when attempting to setup @nx/playwright with a webpack config file.')).createNodesV2
88
+ : (await getDynamicImportedModule('@nx/vite/plugin', '@nx/vite should be installed when attempting to setup @nx/playwright with a vite config file.')).createNodesV2)) ??
91
89
  getServeStaticLikeTarget(tree, graph, projectToMigrate.projectName, projectToMigrate.configFileType === 'webpack'
92
90
  ? '@nx/web:file-server'
93
91
  : '@nx/vite:preview-server');
@@ -133,6 +131,14 @@ async function default_1(tree) {
133
131
  await (0, add_e2e_ci_target_defaults_1.default)(tree);
134
132
  await (0, devkit_1.formatFiles)(tree);
135
133
  }
134
+ async function getDynamicImportedModule(moduleName, error) {
135
+ try {
136
+ return (await Promise.resolve(`${moduleName}`).then(s => require(s)));
137
+ }
138
+ catch {
139
+ throw new Error(error);
140
+ }
141
+ }
136
142
  async function getServeStaticTargetNameForConfigFile(tree, pluginName, configFile, defaultTargetName, targetNamePluginOption, createNodesV2) {
137
143
  const nxJson = (0, devkit_1.readNxJson)(tree);
138
144
  const matchingPluginRegistrations = nxJson.plugins?.filter((p) => typeof p === 'string' ? p === pluginName : p.plugin === pluginName);
@@ -273,14 +273,23 @@ function getReporterOutputs(playwrightConfig) {
273
273
  }
274
274
  return outputs;
275
275
  }
276
- function getTargetOutputs(testOutput, reporterOutputs, workspaceRoot, projectRoot, scope) {
276
+ function getTargetOutputs(testOutput, reporterOutputs, workspaceRoot, projectRoot, subFolder) {
277
277
  const outputs = new Set();
278
- outputs.add(normalizeOutput(scope ? (0, node_path_1.join)(testOutput, scope) : testOutput, workspaceRoot, projectRoot));
278
+ outputs.add(normalizeOutput(addSubfolderToOutput(testOutput, subFolder), workspaceRoot, projectRoot));
279
279
  for (const [, output] of reporterOutputs) {
280
- outputs.add(normalizeOutput(scope ? (0, node_path_1.join)(output, scope) : output, workspaceRoot, projectRoot));
280
+ outputs.add(normalizeOutput(addSubfolderToOutput(output, subFolder), workspaceRoot, projectRoot));
281
281
  }
282
282
  return Array.from(outputs);
283
283
  }
284
+ function addSubfolderToOutput(output, subfolder) {
285
+ if (!subfolder)
286
+ return output;
287
+ const parts = (0, node_path_1.parse)(output);
288
+ if (parts.ext !== '') {
289
+ return (0, node_path_1.join)(parts.dir, subfolder, parts.base);
290
+ }
291
+ return (0, node_path_1.join)(output, subfolder);
292
+ }
284
293
  function normalizeOutput(path, workspaceRoot, projectRoot) {
285
294
  const fullProjectRoot = (0, node_path_1.resolve)(workspaceRoot, projectRoot);
286
295
  const fullPath = (0, node_path_1.resolve)(fullProjectRoot, path);
@@ -296,7 +305,7 @@ function getOutputEnvVars(reporterOutputs, outputSubfolder) {
296
305
  if (outputSubfolder) {
297
306
  const isFile = (0, node_path_1.parse)(output).ext !== '';
298
307
  const envVarName = `PLAYWRIGHT_${reporter.toUpperCase()}_OUTPUT_${isFile ? 'FILE' : 'DIR'}`;
299
- env[envVarName] = (0, node_path_1.join)(output, outputSubfolder);
308
+ env[envVarName] = addSubfolderToOutput(output, outputSubfolder);
300
309
  // Also set PLAYWRIGHT_HTML_REPORT for Playwright prior to 1.45.0.
301
310
  // HTML prior to this version did not follow the pattern of "PLAYWRIGHT_<REPORTER>_OUTPUT_<FILE|DIR>".
302
311
  if (reporter === 'html') {