@nx/plugin 23.2.0-beta.6 → 23.2.0-beta.8

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.
@@ -52,7 +52,9 @@ async function addPresetGenerator(host, schema) {
52
52
  path: (0, path_1.join)(projectRoot, 'src/generators/preset/generator'),
53
53
  unitTestRunner: schema.unitTestRunner,
54
54
  skipFormat: true,
55
- skipLintChecks: schema.linter === 'none',
55
+ // Lint checks are an ESLint-only feature; asking for them under any other
56
+ // linter makes `pluginLintCheckGenerator` log an error and do nothing.
57
+ skipLintChecks: schema.linter !== 'eslint',
56
58
  });
57
59
  }
58
60
  return (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))?.name;
@@ -3,7 +3,7 @@
3
3
  import { createWorkspace } from 'create-nx-workspace';
4
4
 
5
5
  async function main() {
6
- const name = process.argv[2]; // TODO: use libraries like yargs or enquirer to set your workspace name
6
+ const name = process.argv[2]; // TODO: use libraries like yargs, <%= unitTestRunner === 'jest' ? 'enquirer' : '@clack/prompts' %>, or another prompting library to set your workspace name
7
7
  if (!name) {
8
8
  throw new Error('Please provide a name for the workspace');
9
9
  }
@@ -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 CreatePackageSchema {
4
4
  name: string;
@@ -9,7 +9,7 @@ export interface CreatePackageSchema {
9
9
  skipFormat?: boolean;
10
10
  tags?: string;
11
11
  unitTestRunner?: 'jest' | 'vitest' | 'none';
12
- linter?: Linter | LinterType;
12
+ linter?: LinterType;
13
13
  compiler?: 'swc' | 'tsc';
14
14
 
15
15
  // options to create e2e project, passed to e2e project generator
@@ -37,9 +37,9 @@
37
37
  "description": "Test runner to use for unit tests."
38
38
  },
39
39
  "linter": {
40
- "description": "The tool to use for running lint checks.",
40
+ "description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
41
41
  "type": "string",
42
- "enum": ["none", "eslint"]
42
+ "enum": ["none", "eslint", "oxlint"]
43
43
  },
44
44
  "tags": {
45
45
  "type": "string",
@@ -1,5 +1,5 @@
1
1
  import { Tree } from '@nx/devkit';
2
- import type { LinterType } from '@nx/eslint';
2
+ import type { LinterType } from '@nx/js';
3
3
  import { CreatePackageSchema } from '../schema';
4
4
  export interface NormalizedSchema extends CreatePackageSchema {
5
5
  bundler: 'swc' | 'tsc';
@@ -4,7 +4,6 @@ exports.e2eProjectGenerator = e2eProjectGenerator;
4
4
  exports.e2eProjectGeneratorInternal = e2eProjectGeneratorInternal;
5
5
  const internal_1 = require("@nx/devkit/internal");
6
6
  const devkit_1 = require("@nx/devkit");
7
- const eslint_1 = require("@nx/eslint");
8
7
  const jest_1 = require("@nx/jest");
9
8
  const js_1 = require("@nx/js");
10
9
  const internal_2 = require("@nx/js/internal");
@@ -219,18 +218,16 @@ export { default as teardown } from './stop-local-registry';
219
218
  return vitestTask;
220
219
  }
221
220
  async function addLintingToApplication(tree, options) {
222
- const lintTask = await (0, eslint_1.lintProjectGenerator)(tree, {
221
+ return (0, internal_2.addLintingToProject)(tree, {
223
222
  linter: options.linter,
224
223
  project: options.projectName,
225
224
  tsConfigPaths: [
226
225
  (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'),
227
226
  ],
228
227
  unitTestRunner: options.testRunner ?? 'jest',
229
- skipFormat: true,
230
228
  enableTypedLinting: false,
231
229
  addPlugin: options.addPlugin,
232
230
  });
233
- return lintTask;
234
231
  }
235
232
  function updatePluginPackageJson(tree, options) {
236
233
  const { root } = (0, devkit_1.readProjectConfiguration)(tree, options.pluginName);
@@ -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 Schema {
4
4
  pluginName: string;
@@ -7,7 +7,7 @@ export interface Schema {
7
7
  pluginOutputPath?: string;
8
8
  jestConfig?: string;
9
9
  testRunner?: 'jest' | 'vitest';
10
- linter?: Linter | LinterType;
10
+ linter?: LinterType;
11
11
  skipFormat?: boolean;
12
12
  rootProject?: boolean;
13
13
  useProjectJson?: boolean;
@@ -37,9 +37,9 @@
37
37
  "default": "jest"
38
38
  },
39
39
  "linter": {
40
- "description": "The tool to use for running lint checks.",
40
+ "description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
41
41
  "type": "string",
42
- "enum": ["none", "eslint"]
42
+ "enum": ["none", "eslint", "oxlint"]
43
43
  },
44
44
  "minimal": {
45
45
  "type": "boolean",
@@ -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 Schema {
4
4
  directory: string;
@@ -11,7 +11,7 @@ export interface Schema {
11
11
  e2eProjectDirectory?: string;
12
12
  tags?: string;
13
13
  unitTestRunner?: 'jest' | 'vitest' | 'none';
14
- linter?: Linter | LinterType;
14
+ linter?: LinterType;
15
15
  enableTypedLinting?: boolean;
16
16
  /**
17
17
  * @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
@@ -32,9 +32,9 @@
32
32
  "x-priority": "important"
33
33
  },
34
34
  "linter": {
35
- "description": "The tool to use for running lint checks.",
35
+ "description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
36
36
  "type": "string",
37
- "enum": ["none", "eslint"],
37
+ "enum": ["none", "eslint", "oxlint"],
38
38
  "x-priority": "important"
39
39
  },
40
40
  "unitTestRunner": {
@@ -1,5 +1,5 @@
1
1
  import { type Tree } from '@nx/devkit';
2
- import type { LinterType } from '@nx/eslint';
2
+ import type { LinterType } from '@nx/js';
3
3
  import type { Schema } from '../schema';
4
4
  export interface NormalizedSchema extends Schema {
5
5
  projectName: string;
@@ -5,6 +5,7 @@ exports.presetGeneratorInternal = presetGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const create_package_1 = require("../create-package/create-package");
7
7
  const plugin_1 = require("../plugin/plugin");
8
+ const internal_1 = require("@nx/js/internal");
8
9
  async function presetGenerator(tree, rawOptions) {
9
10
  return await presetGeneratorInternal(tree, {
10
11
  addPlugin: false,
@@ -14,10 +15,10 @@ async function presetGenerator(tree, rawOptions) {
14
15
  }
15
16
  async function presetGeneratorInternal(tree, rawOptions) {
16
17
  const tasks = [];
17
- const options = normalizeOptions(rawOptions);
18
+ const options = await normalizeOptions(tree, rawOptions);
18
19
  const pluginTask = await (0, plugin_1.pluginGenerator)(tree, {
19
20
  compiler: 'tsc',
20
- linter: 'eslint',
21
+ linter: options.linter,
21
22
  skipFormat: true,
22
23
  unitTestRunner: 'jest',
23
24
  importPath: options.pluginName,
@@ -42,7 +43,7 @@ async function presetGeneratorInternal(tree, rawOptions) {
42
43
  project: options.pluginName,
43
44
  skipFormat: true,
44
45
  unitTestRunner: 'jest',
45
- linter: 'eslint',
46
+ linter: options.linter,
46
47
  compiler: 'tsc',
47
48
  useProjectJson: options.useProjectJson,
48
49
  addPlugin: options.addPlugin,
@@ -62,7 +63,7 @@ function moveNxPluginToDevDeps(tree) {
62
63
  return json;
63
64
  });
64
65
  }
65
- function normalizeOptions(options) {
66
+ async function normalizeOptions(tree, options) {
66
67
  return {
67
68
  ...options,
68
69
  pluginName: (0, devkit_1.names)(options.pluginName.includes('/')
@@ -71,6 +72,9 @@ function normalizeOptions(options) {
71
72
  createPackageName: options.createPackageName === 'false' // for command line in e2e, it is passed as a string
72
73
  ? undefined
73
74
  : options.createPackageName,
75
+ // Resolved once here rather than left to the two child generators, which
76
+ // each prompt on their own and would ask the same question twice.
77
+ linter: await (0, internal_1.normalizeLinterOption)(tree, options.linter),
74
78
  };
75
79
  }
76
80
  exports.default = presetGenerator;
@@ -1,11 +1,15 @@
1
+ import type { LinterType } from '@nx/js';
2
+
1
3
  export interface PresetGeneratorSchema {
2
4
  pluginName: string;
3
5
  createPackageName?: string;
4
6
  useProjectJson?: boolean;
5
7
  addPlugin?: boolean;
8
+ linter?: LinterType;
6
9
  }
7
10
 
8
11
  export interface NormalizedPresetGeneratorOptions
9
12
  extends PresetGeneratorSchema {
10
13
  createPackageName: string;
14
+ linter: LinterType;
11
15
  }
@@ -25,6 +25,11 @@
25
25
  "type": "string",
26
26
  "description": "Name of package which creates a workspace"
27
27
  },
28
+ "linter": {
29
+ "description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
30
+ "type": "string",
31
+ "enum": ["none", "eslint", "oxlint"]
32
+ },
28
33
  "useProjectJson": {
29
34
  "type": "boolean",
30
35
  "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
@@ -6,7 +6,6 @@ exports.runPackageManagerInstall = runPackageManagerInstall;
6
6
  exports.newNxProject = newNxProject;
7
7
  exports.ensureNxProject = ensureNxProject;
8
8
  const devkit_1 = require("@nx/devkit");
9
- const devkit_2 = require("@nx/devkit");
10
9
  const child_process_1 = require("child_process");
11
10
  const node_fs_1 = require("node:fs");
12
11
  const path_1 = require("path");
@@ -22,9 +21,9 @@ function runNxNewCommand(args, silent) {
22
21
  }
23
22
  function patchPackageJsonForPlugin(npmPackageName, distPath) {
24
23
  const path = (0, paths_1.tmpProjPath)('package.json');
25
- const json = (0, devkit_2.readJsonFile)(path);
24
+ const json = (0, devkit_1.readJsonFile)(path);
26
25
  json.devDependencies[npmPackageName] = `file:${devkit_1.workspaceRoot}/${distPath}`;
27
- (0, devkit_2.writeJsonFile)(path, json);
26
+ (0, devkit_1.writeJsonFile)(path, json);
28
27
  }
29
28
  /**
30
29
  * Generate a unique name for running CLI commands
@@ -41,7 +40,7 @@ function uniq(prefix) {
41
40
  */
42
41
  function runPackageManagerInstall(silent = true) {
43
42
  const cwd = (0, paths_1.tmpProjPath)();
44
- const pmc = (0, devkit_2.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
43
+ const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
45
44
  const install = (0, child_process_1.execSync)(pmc.install, {
46
45
  cwd,
47
46
  ...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/plugin",
3
- "version": "23.2.0-beta.6",
3
+ "version": "23.2.0-beta.8",
4
4
  "private": false,
5
5
  "description": "This plugin is used to create Nx plugins! It contains generators for generating common plugin features like generators, executors, migrations and more.",
6
6
  "repository": {
@@ -36,16 +36,16 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "tslib": "^2.3.0",
39
- "@nx/devkit": "23.2.0-beta.6",
40
- "@nx/jest": "23.2.0-beta.6",
41
- "@nx/eslint": "23.2.0-beta.6",
42
- "@nx/js": "23.2.0-beta.6"
39
+ "@nx/jest": "23.2.0-beta.8",
40
+ "@nx/js": "23.2.0-beta.8",
41
+ "@nx/devkit": "23.2.0-beta.8",
42
+ "@nx/eslint": "23.2.0-beta.8"
43
43
  },
44
44
  "devDependencies": {
45
- "nx": "23.2.0-beta.6"
45
+ "nx": "23.2.0-beta.8"
46
46
  },
47
47
  "peerDependencies": {
48
- "@nx/vitest": "23.2.0-beta.6"
48
+ "@nx/vitest": "23.2.0-beta.8"
49
49
  },
50
50
  "peerDependenciesMeta": {
51
51
  "@nx/vitest": {