@nx/playwright 20.3.1 → 20.3.3

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2024 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2025 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/playwright",
3
- "version": "20.3.1",
3
+ "version": "20.3.3",
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": "20.3.1",
39
- "@nx/eslint": "20.3.1",
40
- "@nx/webpack": "20.3.1",
41
- "@nx/vite": "20.3.1",
42
- "@nx/js": "20.3.1",
38
+ "@nx/devkit": "20.3.3",
39
+ "@nx/eslint": "20.3.3",
40
+ "@nx/webpack": "20.3.3",
41
+ "@nx/vite": "20.3.3",
42
+ "@nx/js": "20.3.3",
43
43
  "tslib": "^2.3.0",
44
44
  "minimatch": "9.0.3"
45
45
  },
@@ -4,6 +4,7 @@ exports.configurationGenerator = configurationGenerator;
4
4
  exports.configurationGeneratorInternal = configurationGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
7
+ const prompt_1 = require("@nx/devkit/src/generators/prompt");
7
8
  const js_1 = require("@nx/js");
8
9
  const generator_prompts_1 = require("@nx/js/src/utils/generator-prompts");
9
10
  const package_manager_workspaces_1 = require("@nx/js/src/utils/package-manager-workspaces");
@@ -141,6 +142,11 @@ async function normalizeOptions(tree, options) {
141
142
  (process.env.NX_ADD_PLUGINS !== 'false' &&
142
143
  nxJson.useInferencePlugins !== false);
143
144
  const linter = await (0, generator_prompts_1.normalizeLinterOption)(tree, options.linter);
145
+ if (!options.webServerCommand || !options.webServerAddress) {
146
+ const { webServerCommand, webServerAddress } = await promptForMissingServeData(options.project);
147
+ options.webServerCommand = webServerCommand;
148
+ options.webServerAddress = webServerAddress;
149
+ }
144
150
  return {
145
151
  ...options,
146
152
  addPlugin,
@@ -148,6 +154,29 @@ async function normalizeOptions(tree, options) {
148
154
  directory: options.directory ?? 'e2e',
149
155
  };
150
156
  }
157
+ async function promptForMissingServeData(projectName) {
158
+ const { command, port } = await (0, prompt_1.promptWhenInteractive)([
159
+ {
160
+ type: 'input',
161
+ name: 'command',
162
+ message: 'What command should be run to serve the application locally?',
163
+ initial: `npx nx serve ${projectName}`,
164
+ },
165
+ {
166
+ type: 'numeral',
167
+ name: 'port',
168
+ message: 'What port will the application be served on?',
169
+ initial: 3000,
170
+ },
171
+ ], {
172
+ command: `npx nx serve ${projectName}`,
173
+ port: 3000,
174
+ });
175
+ return {
176
+ webServerCommand: command,
177
+ webServerAddress: `http://localhost:${port}`,
178
+ };
179
+ }
151
180
  function getBrowsersInstallTask() {
152
181
  return () => {
153
182
  devkit_1.output.log({
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = addE2eCiTargetDefaults;
4
4
  const devkit_1 = require("@nx/devkit");
5
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");
6
+ const loaded_nx_plugin_1 = require("nx/src/project-graph/plugins/loaded-nx-plugin");
7
7
  const devkit_internals_1 = require("nx/src/devkit-internals");
8
8
  const tsquery_1 = require("@phenomnomnominal/tsquery");
9
9
  const path_1 = require("path");
@@ -19,7 +19,7 @@ async function addE2eCiTargetDefaults(tree) {
19
19
  for (const plugin of matchingPluginRegistrations) {
20
20
  let projectConfigs;
21
21
  try {
22
- const loadedPlugin = new internal_api_1.LoadedNxPlugin({ createNodesV2, name: pluginName }, plugin);
22
+ const loadedPlugin = new loaded_nx_plugin_1.LoadedNxPlugin({ createNodesV2, name: pluginName }, plugin);
23
23
  projectConfigs = await (0, devkit_internals_1.retrieveProjectConfigurations)([loadedPlugin], tree.root, nxJson);
24
24
  }
25
25
  catch (e) {
@@ -4,7 +4,7 @@ exports.default = default_1;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const tsquery_1 = require("@phenomnomnominal/tsquery");
6
6
  const add_e2e_ci_target_defaults_1 = require("./add-e2e-ci-target-defaults");
7
- const internal_api_1 = require("nx/src/project-graph/plugins/internal-api");
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
10
  const plugin_1 = require("@nx/webpack/src/plugins/plugin");
@@ -143,7 +143,7 @@ async function getServeStaticTargetNameForConfigFile(tree, pluginName, configFil
143
143
  for (const plugin of matchingPluginRegistrations) {
144
144
  let projectConfigs;
145
145
  try {
146
- const loadedPlugin = new internal_api_1.LoadedNxPlugin({ createNodesV2, name: pluginName }, plugin);
146
+ const loadedPlugin = new loaded_nx_plugin_1.LoadedNxPlugin({ createNodesV2, name: pluginName }, plugin);
147
147
  projectConfigs = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)([loadedPlugin], tree.root, nxJson);
148
148
  }
149
149
  catch (e) {
@@ -106,7 +106,7 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
106
106
  : ['default', '^default']),
107
107
  { externalDependencies: ['@playwright/test'] },
108
108
  ],
109
- outputs: getTargetOutputs(testOutput, reporterOutputs, projectRoot),
109
+ outputs: getTargetOutputs(testOutput, reporterOutputs, context.workspaceRoot, projectRoot),
110
110
  };
111
111
  if (options.ciTargetName) {
112
112
  const ciBaseTargetConfig = {
@@ -118,7 +118,7 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
118
118
  : ['default', '^default']),
119
119
  { externalDependencies: ['@playwright/test'] },
120
120
  ],
121
- outputs: getTargetOutputs(testOutput, reporterOutputs, projectRoot),
121
+ outputs: getTargetOutputs(testOutput, reporterOutputs, context.workspaceRoot, projectRoot),
122
122
  };
123
123
  const groupName = 'E2E (CI)';
124
124
  metadata = { targetGroups: { [groupName]: [] } };
@@ -142,7 +142,7 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
142
142
  ...ciBaseTargetConfig.options,
143
143
  env: getOutputEnvVars(reporterOutputs, outputSubfolder),
144
144
  },
145
- outputs: getTargetOutputs(testOutput, reporterOutputs, projectRoot, outputSubfolder),
145
+ outputs: getTargetOutputs(testOutput, reporterOutputs, context.workspaceRoot, projectRoot, outputSubfolder),
146
146
  command: `${baseTargetConfig.command} ${relativeSpecFilePath} --output=${(0, node_path_1.join)(testOutput, outputSubfolder)}`,
147
147
  metadata: {
148
148
  technologies: ['playwright'],
@@ -273,21 +273,22 @@ function getReporterOutputs(playwrightConfig) {
273
273
  }
274
274
  return outputs;
275
275
  }
276
- function getTargetOutputs(testOutput, reporterOutputs, projectRoot, scope) {
276
+ function getTargetOutputs(testOutput, reporterOutputs, workspaceRoot, projectRoot, scope) {
277
277
  const outputs = new Set();
278
- outputs.add(normalizeOutput(projectRoot, scope ? (0, node_path_1.join)(testOutput, scope) : testOutput));
278
+ outputs.add(normalizeOutput(scope ? (0, node_path_1.join)(testOutput, scope) : testOutput, workspaceRoot, projectRoot));
279
279
  for (const [, output] of reporterOutputs) {
280
- outputs.add(normalizeOutput(projectRoot, scope ? (0, node_path_1.join)(output, scope) : output));
280
+ outputs.add(normalizeOutput(scope ? (0, node_path_1.join)(output, scope) : output, workspaceRoot, projectRoot));
281
281
  }
282
282
  return Array.from(outputs);
283
283
  }
284
- function normalizeOutput(projectRoot, path) {
285
- if (path.startsWith('..')) {
286
- return (0, node_path_1.join)('{workspaceRoot}', (0, node_path_1.join)(projectRoot, path));
287
- }
288
- else {
289
- return (0, node_path_1.join)('{projectRoot}', path);
284
+ function normalizeOutput(path, workspaceRoot, projectRoot) {
285
+ const fullProjectRoot = (0, node_path_1.resolve)(workspaceRoot, projectRoot);
286
+ const fullPath = (0, node_path_1.resolve)(fullProjectRoot, path);
287
+ const pathRelativeToProjectRoot = (0, devkit_1.normalizePath)((0, node_path_1.relative)(fullProjectRoot, fullPath));
288
+ if (pathRelativeToProjectRoot.startsWith('..')) {
289
+ return (0, devkit_1.joinPathFragments)('{workspaceRoot}', (0, node_path_1.relative)(workspaceRoot, fullPath));
290
290
  }
291
+ return (0, devkit_1.joinPathFragments)('{projectRoot}', pathRelativeToProjectRoot);
291
292
  }
292
293
  function getOutputEnvVars(reporterOutputs, outputSubfolder) {
293
294
  const env = {};