@nx/plugin 18.0.0-beta.0 → 18.0.0-beta.2

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/executors.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "implementation": "./src/executors/e2e/e2e.impl",
5
5
  "schema": "./src/executors/e2e/schema.json",
6
6
  "description": "Creates and runs the E2E tests for an Nx Plugin.",
7
- "x-deprecated": "@nx/plugin:e2e is deprecated and will be removed in Nx 18. Use @nx/jest:jest instead."
7
+ "x-deprecated": "@nx/plugin:e2e is deprecated and will be removed in Nx v19. Use @nx/jest:jest instead."
8
8
  }
9
9
  }
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/plugin",
3
- "version": "18.0.0-beta.0",
3
+ "version": "18.0.0-beta.2",
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": {
@@ -31,11 +31,11 @@
31
31
  "@phenomnomnominal/tsquery": "~5.0.1",
32
32
  "fs-extra": "^11.1.0",
33
33
  "tslib": "^2.3.0",
34
- "@nx/devkit": "18.0.0-beta.0",
35
- "@nx/jest": "18.0.0-beta.0",
36
- "@nx/js": "18.0.0-beta.0",
37
- "@nx/eslint": "18.0.0-beta.0",
38
- "@nrwl/nx-plugin": "18.0.0-beta.0"
34
+ "@nx/devkit": "18.0.0-beta.2",
35
+ "@nx/jest": "18.0.0-beta.2",
36
+ "@nx/js": "18.0.0-beta.2",
37
+ "@nx/eslint": "18.0.0-beta.2",
38
+ "@nrwl/nx-plugin": "18.0.0-beta.2"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nxPluginE2EExecutor = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const jest_impl_1 = require("@nx/jest/src/executors/jest/jest.impl");
6
- // TODO(v18): remove this
6
+ // TODO(v19): remove this
7
7
  async function* nxPluginE2EExecutor(options, context) {
8
8
  const { target, ...jestOptions } = options;
9
9
  devkit_1.output.warn({
10
- title: `"@nx/plugin:e2e" is deprecated and will be removed in Nx 18`,
10
+ title: `"@nx/plugin:e2e" is deprecated and will be removed in Nx 19`,
11
11
  bodyLines: [
12
12
  'Use the "@nx/jest:jest" executor instead and set the following:',
13
13
  `"dependsOn": ["${target}"]`,
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxPluginCreatePackage",
5
5
  "title": "Create a framework package",
@@ -11,6 +11,7 @@ const eslint_1 = require("@nx/eslint");
11
11
  const path_1 = require("path");
12
12
  async function normalizeOptions(host, options) {
13
13
  const projectName = options.rootProject ? 'e2e' : `${options.pluginName}-e2e`;
14
+ options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
14
15
  let projectRoot;
15
16
  if (options.projectNameAndRootFormat === 'as-provided') {
16
17
  const projectNameAndRootOptions = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
@@ -72,26 +73,26 @@ async function addJest(host, options) {
72
73
  });
73
74
  const jestTask = await (0, jest_1.configurationGenerator)(host, {
74
75
  project: options.projectName,
76
+ targetName: 'e2e',
75
77
  setupFile: 'none',
76
78
  supportTsx: false,
77
79
  skipSerializers: true,
78
80
  skipFormat: true,
81
+ addPlugin: options.addPlugin,
79
82
  });
80
83
  const { startLocalRegistryPath, stopLocalRegistryPath } = (0, add_local_registry_scripts_1.addLocalRegistryScripts)(host);
81
84
  (0, jest_1.addPropertyToJestConfig)(host, (0, path_1.join)(options.projectRoot, 'jest.config.ts'), 'globalSetup', (0, path_1.join)((0, devkit_1.offsetFromRoot)(options.projectRoot), startLocalRegistryPath));
82
85
  (0, jest_1.addPropertyToJestConfig)(host, (0, path_1.join)(options.projectRoot, 'jest.config.ts'), 'globalTeardown', (0, path_1.join)((0, devkit_1.offsetFromRoot)(options.projectRoot), stopLocalRegistryPath));
83
86
  const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
84
- const testTarget = project.targets.test;
87
+ const e2eTarget = project.targets.e2e;
85
88
  project.targets.e2e = {
86
- ...testTarget,
89
+ ...e2eTarget,
87
90
  dependsOn: [`^build`],
88
91
  options: {
89
- ...testTarget.options,
92
+ ...e2eTarget.options,
90
93
  runInBand: true,
91
94
  },
92
95
  };
93
- // remove the jest build target
94
- delete project.targets.test;
95
96
  (0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
96
97
  return jestTask;
97
98
  }
@@ -105,11 +106,13 @@ async function addLintingToApplication(tree, options) {
105
106
  unitTestRunner: 'jest',
106
107
  skipFormat: true,
107
108
  setParserOptionsProject: false,
109
+ addPlugin: options.addPlugin,
108
110
  });
109
111
  return lintTask;
110
112
  }
111
113
  async function e2eProjectGenerator(host, schema) {
112
114
  return await e2eProjectGeneratorInternal(host, {
115
+ addPlugin: false,
113
116
  projectNameAndRootFormat: 'derived',
114
117
  ...schema,
115
118
  });
@@ -11,4 +11,5 @@ export interface Schema {
11
11
  linter?: Linter;
12
12
  skipFormat?: boolean;
13
13
  rootProject?: boolean;
14
+ addPlugin?: boolean;
14
15
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxPluginE2E",
5
5
  "title": "Create an E2E app for a Nx Plugin",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "version": 2,
4
4
  "title": "<%= className %> executor",
5
5
  "description": "",
@@ -11,7 +11,7 @@ export interface Schema {
11
11
  skipFormat?: boolean;
12
12
 
13
13
  /**
14
- * @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v18.
14
+ * @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
15
15
  */
16
16
  project?: string;
17
17
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxPluginExecutor",
5
5
  "title": "Create an Executor for an Nx Plugin",
@@ -62,7 +62,7 @@
62
62
  "$default": {
63
63
  "$source": "projectName"
64
64
  },
65
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18."
65
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
66
66
  },
67
67
  "skipFormat": {
68
68
  "type": "boolean",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "<%= className %>",
4
4
  "title": "",
5
5
  "type": "object",
@@ -10,7 +10,7 @@ export interface Schema {
10
10
  nameAndDirectoryFormat?: NameAndDirectoryFormat;
11
11
 
12
12
  /**
13
- * @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v18.
13
+ * @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
14
14
  */
15
15
  project?: string;
16
16
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxPluginGenerator",
5
5
  "title": "Create a Generator for an Nx Plugin",
@@ -51,7 +51,7 @@
51
51
  "$default": {
52
52
  "$source": "projectName"
53
53
  },
54
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18."
54
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
55
55
  },
56
56
  "skipFormat": {
57
57
  "type": "boolean",
@@ -10,7 +10,7 @@ async function pluginLintCheckGenerator(host, options) {
10
10
  const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
11
11
  const packageJson = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(project.root, 'package.json'));
12
12
  // This rule is eslint **only**
13
- if (projectIsEsLintEnabled(project)) {
13
+ if (projectIsEsLintEnabled(host, project)) {
14
14
  updateRootEslintConfig(host);
15
15
  updateProjectEslintConfig(host, project, packageJson);
16
16
  updateProjectTarget(host, options, packageJson);
@@ -18,12 +18,6 @@ async function pluginLintCheckGenerator(host, options) {
18
18
  if (host.exists('.vscode')) {
19
19
  setupVsCodeLintingForJsonFiles(host);
20
20
  }
21
- // Project contains migrations.json
22
- const migrationsPath = (0, package_json_1.readNxMigrateConfig)(packageJson).migrations;
23
- if (migrationsPath &&
24
- host.exists((0, devkit_1.joinPathFragments)(project.root, migrationsPath))) {
25
- addMigrationJsonChecks(host, options, packageJson);
26
- }
27
21
  }
28
22
  else {
29
23
  devkit_1.logger.error(`${logger_1.NX_PREFIX} plugin lint checks can only be added to plugins which use eslint for linting`);
@@ -35,10 +29,10 @@ async function pluginLintCheckGenerator(host, options) {
35
29
  exports.default = pluginLintCheckGenerator;
36
30
  function addMigrationJsonChecks(host, options, packageJson) {
37
31
  const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
38
- if (!projectIsEsLintEnabled(projectConfiguration)) {
32
+ if (!projectIsEsLintEnabled(host, projectConfiguration)) {
39
33
  return;
40
34
  }
41
- const [eslintTarget, eslintTargetConfiguration] = getEsLintOptions(projectConfiguration);
35
+ const [eslintTarget, eslintTargetConfiguration] = getEsLintOptions(projectConfiguration) ?? [];
42
36
  const relativeMigrationsJsonPath = (0, package_json_1.readNxMigrateConfig)(packageJson).migrations;
43
37
  if (!relativeMigrationsJsonPath) {
44
38
  return;
@@ -107,6 +101,7 @@ function updateProjectEslintConfig(host, options, packageJson) {
107
101
  packageJson.executors,
108
102
  packageJson.schematics,
109
103
  packageJson.builders,
104
+ (0, package_json_1.readNxMigrateConfig)(packageJson).migrations,
110
105
  ].filter((f) => !!f);
111
106
  const parser = (0, flat_config_1.useFlatConfig)(host)
112
107
  ? { languageOptions: { parser: 'jsonc-eslint-parser' } }
@@ -181,8 +176,8 @@ function setupVsCodeLintingForJsonFiles(host) {
181
176
  }
182
177
  (0, devkit_1.writeJson)(host, '.vscode/settings.json', existing);
183
178
  }
184
- function projectIsEsLintEnabled(project) {
185
- return !!getEsLintOptions(project);
179
+ function projectIsEsLintEnabled(tree, project) {
180
+ return !!(0, eslint_file_1.findEslintFile)(tree, project.root);
186
181
  }
187
182
  function getEsLintOptions(project) {
188
183
  return Object.entries(project.targets || {}).find(([, x]) => x.executor === '@nx/eslint:lint' ||
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "PluginLint",
5
5
  "title": "",
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migrationGeneratorInternal = exports.migrationGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const path = require("path");
6
+ const path_1 = require("path");
6
7
  const generator_1 = require("../lint-checks/generator");
7
8
  const package_json_1 = require("nx/src/utils/package-json");
8
9
  const versions_1 = require("../../utils/versions");
9
10
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
10
- const path_1 = require("path");
11
11
  async function normalizeOptions(tree, options) {
12
12
  let name;
13
13
  if (options.name) {
@@ -10,7 +10,7 @@ export interface Schema {
10
10
  nameAndDirectoryFormat?: NameAndDirectoryFormat;
11
11
 
12
12
  /**
13
- * @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v18.
13
+ * @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
14
14
  */
15
15
  project?: string;
16
16
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxPluginMigration",
5
5
  "title": "Create a Migration for an Nx Plugin",
@@ -44,7 +44,7 @@
44
44
  "$default": {
45
45
  "$source": "projectName"
46
46
  },
47
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18."
47
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
48
48
  },
49
49
  "packageJsonUpdates": {
50
50
  "type": "boolean",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxPluginPlugin",
5
5
  "title": "Create a Plugin for Nx",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxPluginPreset",
5
5
  "title": "Generator ran by create-nx-plugin",