@nx/plugin 20.0.0-canary.20241002-1d10a19 → 20.0.0-rc.0

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/migrations.json CHANGED
@@ -1,22 +1,3 @@
1
1
  {
2
- "generators": {
3
- "update-remove-cli-prop": {
4
- "version": "16.0.0-beta.1",
5
- "cli": "nx",
6
- "description": "Removes CLI property within schema.json files and moves generators and schematics to the proper root node in migrations.json",
7
- "factory": "./src/migrations/update-16-0-0/cli-in-schema-json"
8
- },
9
- "update-16-0-0-add-nx-packages": {
10
- "cli": "nx",
11
- "version": "16.0.0-beta.1",
12
- "description": "Replace @nrwl/nx-plugin with @nx/plugin",
13
- "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
14
- },
15
- "update-16-2-0-replace-e2e-executor": {
16
- "cli": "nx",
17
- "version": "16.2.0-beta.0",
18
- "description": "Replace @nx/plugin:e2e with @nx/jest",
19
- "implementation": "./src/migrations/update-16-2-0/replace-e2e-executor"
20
- }
21
- }
2
+ "generators": {}
22
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/plugin",
3
- "version": "20.0.0-canary.20241002-1d10a19",
3
+ "version": "20.0.0-rc.0",
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": {
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "tslib": "^2.3.0",
31
- "@nx/devkit": "20.0.0-canary.20241002-1d10a19",
32
- "@nx/jest": "20.0.0-canary.20241002-1d10a19",
33
- "@nx/js": "20.0.0-canary.20241002-1d10a19",
34
- "@nx/eslint": "20.0.0-canary.20241002-1d10a19"
31
+ "@nx/devkit": "20.0.0-rc.0",
32
+ "@nx/jest": "20.0.0-rc.0",
33
+ "@nx/js": "20.0.0-rc.0",
34
+ "@nx/eslint": "20.0.0-rc.0"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
@@ -4,6 +4,7 @@ exports.createPackageGenerator = createPackageGenerator;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
6
  const add_tslib_dependencies_1 = require("@nx/js/src/utils/typescript/add-tslib-dependencies");
7
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
8
  const versions_1 = require("nx/src/utils/versions");
8
9
  const generator_1 = require("../generator/generator");
9
10
  const normalize_schema_1 = require("./utils/normalize-schema");
@@ -11,6 +12,7 @@ const has_generator_1 = require("../../utils/has-generator");
11
12
  const path_1 = require("path");
12
13
  const versions_2 = require("@nx/js/src/utils/versions");
13
14
  async function createPackageGenerator(host, schema) {
15
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'plugin', 'create-package');
14
16
  const tasks = [];
15
17
  const options = await (0, normalize_schema_1.normalizeSchema)(host, schema);
16
18
  const pluginPackageName = await addPresetGenerator(host, options);
@@ -8,6 +8,7 @@ const jest_1 = require("@nx/jest");
8
8
  const js_1 = require("@nx/js");
9
9
  const generator_1 = require("@nx/js/src/generators/setup-verdaccio/generator");
10
10
  const add_local_registry_scripts_1 = require("@nx/js/src/utils/add-local-registry-scripts");
11
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
11
12
  const eslint_1 = require("@nx/eslint");
12
13
  const path_1 = require("path");
13
14
  async function normalizeOptions(host, options) {
@@ -107,6 +108,7 @@ async function e2eProjectGenerator(host, schema) {
107
108
  });
108
109
  }
109
110
  async function e2eProjectGeneratorInternal(host, schema) {
111
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'plugin', 'e2e-project');
110
112
  const tasks = [];
111
113
  validatePlugin(host, schema.pluginName);
112
114
  const options = await normalizeOptions(host, schema);
@@ -8,6 +8,15 @@ const context: ExecutorContext = {
8
8
  root: '',
9
9
  cwd: process.cwd(),
10
10
  isVerbose: false,
11
+ projectGraph: {
12
+ nodes: {},
13
+ dependencies: {},
14
+ },
15
+ projectsConfigurations: {
16
+ projects: {},
17
+ version: 2,
18
+ },
19
+ nxJsonConfiguration: {},
11
20
  };
12
21
 
13
22
  describe('<%= className %> Executor', () => {
@@ -15,4 +24,4 @@ describe('<%= className %> Executor', () => {
15
24
  const output = await executor(options, context);
16
25
  expect(output.success).toBe(true);
17
26
  });
18
- });
27
+ });
@@ -4,6 +4,7 @@ exports.pluginGenerator = pluginGenerator;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
6
  const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
7
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
8
  const eslint_1 = require("@nx/eslint");
8
9
  const path = require("path");
9
10
  const e2e_1 = require("../e2e-project/e2e");
@@ -51,6 +52,7 @@ function updatePluginConfig(host, options) {
51
52
  }
52
53
  }
53
54
  async function pluginGenerator(host, schema) {
55
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'plugin', 'plugin');
54
56
  const options = await (0, normalize_schema_1.normalizeOptions)(host, schema);
55
57
  const tasks = [];
56
58
  tasks.push(await (0, js_1.libraryGenerator)(host, {
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = default_1;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const eslint_1 = require("@nx/eslint");
6
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
7
  const plugin_1 = require("../plugin/plugin");
7
8
  const create_package_1 = require("../create-package/create-package");
8
9
  async function default_1(tree, options) {
10
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'plugin', 'preset');
9
11
  const tasks = [];
10
12
  const pluginProjectName = (0, devkit_1.names)(options.pluginName.includes('/')
11
13
  ? options.pluginName.split('/')[1]
@@ -1,3 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function updateCliPropsForPlugins(tree: Tree): void;
3
- export default updateCliPropsForPlugins;
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateCliPropsForPlugins = updateCliPropsForPlugins;
4
- const devkit_1 = require("@nx/devkit");
5
- const package_json_1 = require("nx/src/utils/package-json");
6
- const path_1 = require("path");
7
- function updateCliPropsForPlugins(tree) {
8
- const projects = (0, devkit_1.getProjects)(tree);
9
- for (const project of projects.values()) {
10
- if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'package.json'))) {
11
- const packageJson = (0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(project.root, 'package.json'));
12
- const migrateConfig = (0, package_json_1.readNxMigrateConfig)(packageJson);
13
- if (migrateConfig.migrations) {
14
- const migrationsPath = (0, devkit_1.joinPathFragments)(project.root, migrateConfig.migrations);
15
- if (tree.exists(migrationsPath)) {
16
- updateMigrationsJsonForPlugin(tree, migrationsPath);
17
- }
18
- else {
19
- devkit_1.output.warn({
20
- title: `Migrations file specified for ${packageJson.name} does not exist: ${migrationsPath}`,
21
- bodyLines: [
22
- 'Please ensure that migrations that use the Angular Devkit are placed inside the `schematics` property, and migrations that use the Nx Devkit are placed inside the `generators` property.',
23
- ],
24
- });
25
- }
26
- }
27
- if (packageJson.generators) {
28
- const generatorsPath = (0, devkit_1.joinPathFragments)(project.root, packageJson.generators);
29
- if (tree.exists(generatorsPath)) {
30
- removeCliFromGeneratorSchemaJsonFiles(tree, generatorsPath);
31
- }
32
- else {
33
- devkit_1.output.warn({
34
- title: `Generators file specified for ${packageJson.name} does not exist: ${generatorsPath}`,
35
- bodyLines: [
36
- "The `cli` property inside generator's `schema.json` files is no longer supported.",
37
- ],
38
- });
39
- }
40
- }
41
- if (packageJson.executors) {
42
- const executorsPath = (0, devkit_1.joinPathFragments)(project.root, packageJson.executors);
43
- if (tree.exists(executorsPath)) {
44
- removeCliFromExecutorSchemaJsonFiles(tree, executorsPath);
45
- }
46
- else {
47
- devkit_1.output.warn({
48
- title: `Executors file specified for ${packageJson.name} does not exist: ${executorsPath}`,
49
- bodyLines: [
50
- "The `cli` property inside executor's `schema.json` files is no longer supported.",
51
- ],
52
- });
53
- }
54
- }
55
- if (packageJson.builders) {
56
- const buildersPath = (0, devkit_1.joinPathFragments)(project.root, packageJson.builders);
57
- if (tree.exists(buildersPath)) {
58
- removeCliFromExecutorSchemaJsonFiles(tree, buildersPath);
59
- }
60
- else {
61
- devkit_1.output.warn({
62
- title: `Builders file specified for ${packageJson.name} does not exist: ${buildersPath}`,
63
- bodyLines: [
64
- "The `cli` property inside builder's `schema.json` files is no longer supported.",
65
- ],
66
- });
67
- }
68
- }
69
- if (packageJson.schematics) {
70
- const schematicsPath = (0, devkit_1.joinPathFragments)(project.root, packageJson.schematics);
71
- if (tree.exists(schematicsPath)) {
72
- removeCliFromGeneratorSchemaJsonFiles(tree, schematicsPath);
73
- }
74
- else {
75
- devkit_1.output.warn({
76
- title: `Schematics file specified for ${packageJson.name} does not exist: ${schematicsPath}`,
77
- bodyLines: [
78
- "The `cli` property inside schematic's `schema.json` files is no longer supported.",
79
- ],
80
- });
81
- }
82
- }
83
- }
84
- }
85
- }
86
- function removeCliFromExecutorSchemaJsonFiles(tree, collectionPath) {
87
- const collection = (0, devkit_1.readJson)(tree, collectionPath);
88
- for (const [name, entry] of Object.entries(collection.executors ?? {}).concat(Object.entries(collection.builders ?? {}))) {
89
- deleteCliPropFromSchemaFile(collectionPath, entry, tree);
90
- }
91
- }
92
- function removeCliFromGeneratorSchemaJsonFiles(tree, collectionPath) {
93
- const collection = (0, devkit_1.readJson)(tree, collectionPath);
94
- for (const [name, entry] of Object.entries(collection.generators ?? {}).concat(Object.entries(collection.schematics ?? {}))) {
95
- deleteCliPropFromSchemaFile(collectionPath, entry, tree);
96
- }
97
- }
98
- function updateMigrationsJsonForPlugin(tree, collectionPath) {
99
- (0, devkit_1.updateJson)(tree, collectionPath, (json) => {
100
- for (const migration in json.generators ?? {}) {
101
- if (!(json.generators[migration].cli === 'nx')) {
102
- json.schematics ??= {};
103
- json.schematics[migration] = json.generators[migration];
104
- delete json.generators[migration];
105
- }
106
- }
107
- for (const migration in json.schematics ?? {}) {
108
- if (json.schematics[migration].cli === 'nx') {
109
- json.generators ??= {};
110
- json.generators[migration] = json.schematics[migration];
111
- delete json.schematics[migration];
112
- }
113
- }
114
- return json;
115
- });
116
- }
117
- exports.default = updateCliPropsForPlugins;
118
- function deleteCliPropFromSchemaFile(collectionPath, entry, tree) {
119
- if (typeof entry === 'string' || !entry.schema) {
120
- return;
121
- }
122
- const schemaPath = (0, devkit_1.joinPathFragments)((0, path_1.dirname)(collectionPath), entry.schema);
123
- if (tree.exists(schemaPath)) {
124
- (0, devkit_1.updateJson)(tree, schemaPath, (json) => {
125
- if (json.cli) {
126
- delete json.cli;
127
- }
128
- return json;
129
- });
130
- }
131
- else {
132
- console.warn(`Could not find schema file ${schemaPath}`);
133
- }
134
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function replacePackage(tree: Tree): Promise<void>;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = replacePackage;
4
- const devkit_1 = require("@nx/devkit");
5
- const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
6
- async function replacePackage(tree) {
7
- await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/nx-plugin', '@nx/plugin');
8
- await (0, devkit_1.formatFiles)(tree);
9
- }
@@ -1,7 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import { JestExecutorOptions } from '@nx/jest/src/executors/jest/schema';
3
- export interface NxPluginE2EExecutorOptions extends JestExecutorOptions {
4
- target: string;
5
- jestConfig: string;
6
- }
7
- export default function replaceE2EExecutor(tree: Tree): Promise<void>;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = replaceE2EExecutor;
4
- const devkit_1 = require("@nx/devkit");
5
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
- async function replaceE2EExecutor(tree) {
7
- const projects = (0, devkit_1.getProjects)(tree);
8
- for (const executor of ['@nx/plugin:e2e', '@nrwl/nx-plugin:e2e']) {
9
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, executor, (options, project, target, configuration) => {
10
- const projectConfiguration = projects.get(project);
11
- const config = {
12
- ...options,
13
- target: undefined,
14
- runInBand: true,
15
- };
16
- if (configuration) {
17
- projectConfiguration.targets[target].configurations[configuration] =
18
- config;
19
- }
20
- else {
21
- projectConfiguration.targets[target].dependsOn = [
22
- ...(projectConfiguration.targets[target].dependsOn ?? []),
23
- options.target,
24
- ];
25
- projectConfiguration.targets[target].executor = '@nx/jest:jest';
26
- projectConfiguration.targets[target].options = config;
27
- }
28
- (0, devkit_1.updateProjectConfiguration)(tree, project, projectConfiguration);
29
- });
30
- }
31
- await (0, devkit_1.formatFiles)(tree);
32
- }