@nx/playwright 23.2.0-beta.1 → 23.2.0-beta.11

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.
@@ -149,7 +149,7 @@ async function configurationGeneratorInternal(tree, rawOptions) {
149
149
  skipPackageJson: options.skipPackageJson,
150
150
  js: options.js,
151
151
  directory: options.directory,
152
- setParserOptionsProject: options.setParserOptionsProject,
152
+ enableTypedLinting: (0, internal_3.isTypedLintingEnabled)(options),
153
153
  rootProject: options.rootProject ?? projectConfig.root === '.',
154
154
  addPlugin: options.addPlugin,
155
155
  }));
@@ -197,23 +197,23 @@ async function normalizeOptions(tree, options) {
197
197
  };
198
198
  }
199
199
  async function promptForMissingServeData(projectName) {
200
- const { command, port } = await (0, internal_1.promptWhenInteractive)([
201
- {
202
- type: 'input',
203
- name: 'command',
204
- message: 'What command should be run to serve the application locally?',
205
- initial: `npx nx serve ${projectName}`,
206
- },
207
- {
208
- type: 'numeral',
209
- name: 'port',
210
- message: 'What port will the application be served on?',
211
- initial: 3000,
212
- },
213
- ], {
214
- command: `npx nx serve ${projectName}`,
215
- port: 3000,
200
+ if (!(0, internal_1.isInteractive)()) {
201
+ return {
202
+ webServerCommand: `npx nx serve ${projectName}`,
203
+ webServerAddress: 'http://localhost:3000',
204
+ };
205
+ }
206
+ const command = await (0, internal_1.textPrompt)({
207
+ message: 'What command should be run to serve the application locally?',
208
+ initialValue: `npx nx serve ${projectName}`,
216
209
  });
210
+ const port = Number(await (0, internal_1.textPrompt)({
211
+ message: 'What port will the application be served on?',
212
+ initialValue: '3000',
213
+ validate: (value) => value !== '' && !Number.isNaN(Number(value))
214
+ ? undefined
215
+ : 'Please enter a number',
216
+ }));
217
217
  return {
218
218
  webServerCommand: command,
219
219
  webServerAddress: `http://localhost:${port}`,
@@ -1,4 +1,4 @@
1
- import type { Linter, LinterType } from '@nx/eslint';
1
+ import type { LinterType } from '@nx/js';
2
2
 
3
3
  export interface ConfigurationGeneratorSchema {
4
4
  project: string;
@@ -10,7 +10,11 @@ export interface ConfigurationGeneratorSchema {
10
10
  skipFormat?: boolean;
11
11
  skipPackageJson?: boolean;
12
12
  skipInstall?: boolean;
13
- linter?: Linter | LinterType;
13
+ linter?: LinterType;
14
+ enableTypedLinting?: boolean; // default is false
15
+ /**
16
+ * @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
17
+ */
14
18
  setParserOptionsProject?: boolean; // default is false
15
19
  /**
16
20
  * command to give playwright to run the web server
@@ -26,9 +30,8 @@ export interface ConfigurationGeneratorSchema {
26
30
  addPlugin?: boolean;
27
31
  }
28
32
 
29
- export interface NormalizedGeneratorOptions
30
- extends ConfigurationGeneratorSchema {
33
+ export interface NormalizedGeneratorOptions extends ConfigurationGeneratorSchema {
31
34
  addPlugin: boolean;
32
35
  directory: string;
33
- linter: Linter | LinterType;
36
+ linter: LinterType;
34
37
  }
@@ -21,9 +21,9 @@
21
21
  "default": "e2e"
22
22
  },
23
23
  "linter": {
24
- "description": "The tool to use for running lint checks.",
24
+ "description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
25
25
  "type": "string",
26
- "enum": ["none", "eslint"],
26
+ "enum": ["none", "eslint", "oxlint"],
27
27
  "x-priority": "important"
28
28
  },
29
29
  "js": {
@@ -39,11 +39,17 @@
39
39
  "type": "string",
40
40
  "description": "The address of the web server."
41
41
  },
42
- "setParserOptionsProject": {
42
+ "enableTypedLinting": {
43
43
  "type": "boolean",
44
- "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
44
+ "description": "Whether to enable typed linting. For flat configs, this configures the recommended `parserOptions.projectService` and `tsconfigRootDir`. For legacy `.eslintrc` configs, this configures `parserOptions.project`. We do not enable this by default for lint performance reasons.",
45
45
  "default": false
46
46
  },
47
+ "setParserOptionsProject": {
48
+ "type": "boolean",
49
+ "description": "Deprecated alias for `enableTypedLinting`.",
50
+ "default": false,
51
+ "x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
52
+ },
47
53
  "skipFormat": {
48
54
  "description": "Skip formatting files.",
49
55
  "type": "boolean",
@@ -8,18 +8,14 @@ const internal_2 = require("@nx/js/internal");
8
8
  const minimatch_1 = require("minimatch");
9
9
  const node_fs_1 = require("node:fs");
10
10
  const node_path_1 = require("node:path");
11
- const file_hasher_1 = require("nx/src/hasher/file-hasher");
12
- const cache_directory_1 = require("nx/src/utils/cache-directory");
13
- const plugin_cache_utils_1 = require("nx/src/utils/plugin-cache-utils");
14
- const workspace_context_1 = require("nx/src/utils/workspace-context");
15
11
  const reporters_1 = require("../utils/reporters");
16
12
  const playwrightConfigGlob = '**/playwright.config.{js,ts,cjs,cts,mjs,mts}';
17
13
  exports.createNodes = [
18
14
  playwrightConfigGlob,
19
15
  async (configFilePaths, options, context) => {
20
- const optionsHash = (0, file_hasher_1.hashObject)(options);
21
- const cachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `playwright-${optionsHash}.hash`);
22
- const pluginCache = new plugin_cache_utils_1.PluginCache(cachePath);
16
+ const optionsHash = (0, internal_1.hashObject)(options);
17
+ const cachePath = (0, node_path_1.join)(internal_1.workspaceDataDirectory, `playwright-${optionsHash}.hash`);
18
+ const pluginCache = new internal_1.PluginCache(cachePath);
23
19
  const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
24
20
  const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
25
21
  const lockFileName = (0, js_1.getLockFileName)(packageManager);
@@ -249,7 +245,7 @@ async function buildPlaywrightTargets(configFilePath, projectRoot, options, cont
249
245
  return { targets, metadata };
250
246
  }
251
247
  async function getAllTestFiles(opts) {
252
- const files = await (0, workspace_context_1.getFilesInDirectoryUsingContext)(opts.context.workspaceRoot, opts.path);
248
+ const files = await (0, internal_1.getFilesInDirectoryUsingContext)(opts.context.workspaceRoot, opts.path);
253
249
  const matcher = createMatcher(opts.config.testMatch);
254
250
  const ignoredMatcher = opts.config.testIgnore
255
251
  ? createMatcher(opts.config.testIgnore)
@@ -1,9 +1,13 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
- import { Linter, LinterType } from '@nx/eslint';
2
+ import { LinterType } from '@nx/js';
3
3
  export interface PlaywrightLinterOptions {
4
4
  project: string;
5
- linter: Linter | LinterType;
6
- setParserOptionsProject: boolean;
5
+ linter: LinterType;
6
+ enableTypedLinting?: boolean;
7
+ /**
8
+ * @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
9
+ */
10
+ setParserOptionsProject?: boolean;
7
11
  skipPackageJson: boolean;
8
12
  rootProject: boolean;
9
13
  js?: boolean;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLinterToPlaywrightProject = addLinterToPlaywrightProject;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const eslint_1 = require("@nx/eslint");
6
5
  const internal_1 = require("@nx/eslint/internal");
7
6
  const versions_1 = require("./versions");
7
+ const internal_2 = require("@nx/js/internal");
8
8
  async function addLinterToPlaywrightProject(tree, options) {
9
9
  if (options.linter === 'none') {
10
10
  return () => { };
@@ -12,19 +12,23 @@ async function addLinterToPlaywrightProject(tree, options) {
12
12
  const tasks = [];
13
13
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
14
14
  const eslintFile = (0, internal_1.findEslintFile)(tree, projectConfig.root);
15
- if (!eslintFile) {
16
- tasks.push(await (0, eslint_1.lintProjectGenerator)(tree, {
15
+ const enableTypedLinting = (0, internal_1.isTypedLintingEnabled)(options);
16
+ // An existing ESLint config means the project is already registered, so skip
17
+ // straight to the Playwright-specific shaping below.
18
+ if (options.linter !== 'eslint' || !eslintFile) {
19
+ tasks.push(await (0, internal_2.addLintingToProject)(tree, {
17
20
  project: options.project,
18
21
  linter: options.linter,
19
- skipFormat: true,
20
22
  tsConfigPaths: [(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json')],
21
- setParserOptionsProject: options.setParserOptionsProject,
23
+ enableTypedLinting,
22
24
  skipPackageJson: options.skipPackageJson,
23
25
  rootProject: options.rootProject,
24
26
  addPlugin: options.addPlugin,
25
27
  }));
26
28
  }
27
- if (!options.linter || options.linter !== 'eslint') {
29
+ // Everything below configures ESLint — predefined configs, `extends`, ignore
30
+ // entries — which have no equivalent in other linters.
31
+ if (options.linter !== 'eslint') {
28
32
  return (0, devkit_1.runTasksInSerial)(...tasks);
29
33
  }
30
34
  tasks.push(!options.skipPackageJson
@@ -43,6 +47,13 @@ async function addLinterToPlaywrightProject(tree, options) {
43
47
  files: ['*.ts', '*.js'],
44
48
  rules: {},
45
49
  });
50
+ // `lintProjectGenerator` only runs when the project has no ESLint config
51
+ // (it already emits the projectService block in that case). For an
52
+ // existing flat config it didn't run, so emit the block here when typed
53
+ // linting is requested.
54
+ if (eslintFile && enableTypedLinting) {
55
+ (0, internal_1.addTypedLintingToFlatConfig)(tree, projectConfig.root);
56
+ }
46
57
  }
47
58
  else {
48
59
  const addExtendsTask = (0, internal_1.addExtendsToLintConfig)(tree, projectConfig.root, 'plugin:playwright/recommended');
@@ -53,11 +64,12 @@ async function addLinterToPlaywrightProject(tree, options) {
53
64
  }
54
65
  (0, internal_1.addOverrideToLintConfig)(tree, projectConfig.root, {
55
66
  files: [`${options.directory}/**/*.{ts,js,tsx,jsx}`],
56
- parserOptions: !options.setParserOptionsProject
57
- ? undefined
58
- : {
59
- project: `${projectConfig.root}/tsconfig.*?.json`,
60
- },
67
+ // Only emit `parserOptions.project` here on the legacy `.eslintrc`
68
+ // stack. Flat configs use `parserOptions.projectService` emitted by
69
+ // `lintProjectGenerator`.
70
+ parserOptions: enableTypedLinting
71
+ ? { project: `${projectConfig.root}/tsconfig.*?.json` }
72
+ : undefined,
61
73
  rules: {},
62
74
  });
63
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/playwright",
3
- "version": "23.2.0-beta.1",
3
+ "version": "23.2.0-beta.11",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -78,12 +78,12 @@
78
78
  "tslib": "^2.3.0",
79
79
  "minimatch": "10.2.5",
80
80
  "semver": "^7.6.3",
81
- "@nx/devkit": "23.2.0-beta.1",
82
- "@nx/eslint": "23.2.0-beta.1",
83
- "@nx/js": "23.2.0-beta.1"
81
+ "@nx/devkit": "23.2.0-beta.11",
82
+ "@nx/eslint": "23.2.0-beta.11",
83
+ "@nx/js": "23.2.0-beta.11"
84
84
  },
85
85
  "devDependencies": {
86
- "nx": "23.2.0-beta.1"
86
+ "nx": "23.2.0-beta.11"
87
87
  },
88
88
  "peerDependencies": {
89
89
  "@playwright/test": "^1.36.0"