@nx/devkit 19.2.0-beta.4 → 19.2.0-beta.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/devkit",
3
- "version": "19.2.0-beta.4",
3
+ "version": "19.2.0-beta.6",
4
4
  "private": false,
5
5
  "description": "The Nx Devkit is used to customize Nx for different technologies and use cases. It contains many utility functions for reading and writing files, updating configuration, working with Abstract Syntax Trees(ASTs), and more. Learn more about [extending Nx by leveraging the Nx Devkit](https://nx.dev/extending-nx/intro/getting-started) on our docs.",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "semver": "^7.5.3",
37
37
  "yargs-parser": "21.1.1",
38
38
  "minimatch": "9.0.3",
39
- "@nrwl/devkit": "19.2.0-beta.4"
39
+ "@nrwl/devkit": "19.2.0-beta.6"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "nx": ">= 17 <= 20"
@@ -1,9 +1,10 @@
1
- import { ProjectGraph, TargetConfiguration, Tree, CreateNodes } from 'nx/src/devkit-exports';
1
+ import { ProjectGraph, TargetConfiguration, Tree, CreateNodes, CreateNodesV2 } from 'nx/src/devkit-exports';
2
2
  type PluginOptionsBuilder<T> = (targetName: string) => T;
3
3
  type PostTargetTransformer = (targetConfiguration: TargetConfiguration, tree: Tree, projectDetails: {
4
4
  projectName: string;
5
5
  root: string;
6
6
  }, inferredTargetConfiguration: TargetConfiguration) => TargetConfiguration;
7
7
  type SkipTargetFilter = (targetConfiguration: TargetConfiguration) => [boolean, string];
8
- export declare function migrateExecutorToPlugin<T>(tree: Tree, projectGraph: ProjectGraph, executor: string, pluginPath: string, pluginOptionsBuilder: PluginOptionsBuilder<T>, postTargetTransformer: PostTargetTransformer, createNodes: CreateNodes<T>, specificProjectToMigrate?: string, skipTargetFilter?: SkipTargetFilter): Promise<Map<string, Set<string>>>;
8
+ export declare function migrateExecutorToPlugin<T>(tree: Tree, projectGraph: ProjectGraph, executor: string, pluginPath: string, pluginOptionsBuilder: PluginOptionsBuilder<T>, postTargetTransformer: PostTargetTransformer, createNodes: CreateNodesV2<T>, specificProjectToMigrate?: string, skipTargetFilter?: SkipTargetFilter): Promise<Map<string, Set<string>>>;
9
+ export declare function migrateExecutorToPluginV1<T>(tree: Tree, projectGraph: ProjectGraph, executor: string, pluginPath: string, pluginOptionsBuilder: PluginOptionsBuilder<T>, postTargetTransformer: PostTargetTransformer, createNodes: CreateNodes<T>, specificProjectToMigrate?: string, skipTargetFilter?: SkipTargetFilter): Promise<Map<string, Set<string>>>;
9
10
  export {};
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
- var _ExecutorToPluginMigrator_instances, _ExecutorToPluginMigrator_projectGraph, _ExecutorToPluginMigrator_executor, _ExecutorToPluginMigrator_pluginPath, _ExecutorToPluginMigrator_pluginOptionsBuilder, _ExecutorToPluginMigrator_postTargetTransformer, _ExecutorToPluginMigrator_skipTargetFilter, _ExecutorToPluginMigrator_specificProjectToMigrate, _ExecutorToPluginMigrator_nxJson, _ExecutorToPluginMigrator_targetDefaultsForExecutor, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, _ExecutorToPluginMigrator_pluginToAddForTarget, _ExecutorToPluginMigrator_createNodes, _ExecutorToPluginMigrator_configFiles, _ExecutorToPluginMigrator_createNodesResultsForTargets, _ExecutorToPluginMigrator_init, _ExecutorToPluginMigrator_migrateTarget, _ExecutorToPluginMigrator_migrateProject, _ExecutorToPluginMigrator_pluginRequiresIncludes, _ExecutorToPluginMigrator_addPlugins, _ExecutorToPluginMigrator_getTargetAndProjectsToMigrate, _ExecutorToPluginMigrator_getTargetDefaultsForExecutor, _ExecutorToPluginMigrator_getCreatedTargetForProjectRoot, _ExecutorToPluginMigrator_getCreateNodesResults;
2
+ var _ExecutorToPluginMigrator_instances, _ExecutorToPluginMigrator_projectGraph, _ExecutorToPluginMigrator_executor, _ExecutorToPluginMigrator_pluginPath, _ExecutorToPluginMigrator_pluginOptionsBuilder, _ExecutorToPluginMigrator_postTargetTransformer, _ExecutorToPluginMigrator_skipTargetFilter, _ExecutorToPluginMigrator_specificProjectToMigrate, _ExecutorToPluginMigrator_nxJson, _ExecutorToPluginMigrator_targetDefaultsForExecutor, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, _ExecutorToPluginMigrator_pluginToAddForTarget, _ExecutorToPluginMigrator_createNodes, _ExecutorToPluginMigrator_createNodesV2, _ExecutorToPluginMigrator_createNodesResultsForTargets, _ExecutorToPluginMigrator_init, _ExecutorToPluginMigrator_migrateTarget, _ExecutorToPluginMigrator_migrateProject, _ExecutorToPluginMigrator_mergeInputs, _ExecutorToPluginMigrator_pluginRequiresIncludes, _ExecutorToPluginMigrator_addPlugins, _ExecutorToPluginMigrator_getTargetAndProjectsToMigrate, _ExecutorToPluginMigrator_getTargetDefaultsForExecutor, _ExecutorToPluginMigrator_getCreatedTargetForProjectRoot, _ExecutorToPluginMigrator_getCreateNodesResults;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.migrateExecutorToPlugin = void 0;
4
+ exports.migrateExecutorToPluginV1 = exports.migrateExecutorToPlugin = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const minimatch_1 = require("minimatch");
7
+ const node_assert_1 = require("node:assert");
7
8
  const executor_options_utils_1 = require("../executor-options-utils");
8
9
  const plugin_migration_utils_1 = require("./plugin-migration-utils");
9
10
  const devkit_exports_1 = require("nx/src/devkit-exports");
10
11
  const devkit_internals_1 = require("nx/src/devkit-internals");
11
12
  class ExecutorToPluginMigrator {
12
- constructor(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, createNodes, specificProjectToMigrate, skipTargetFilter) {
13
+ constructor(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, createNodes, createNodesV2, specificProjectToMigrate, skipTargetFilter) {
13
14
  _ExecutorToPluginMigrator_instances.add(this);
14
15
  _ExecutorToPluginMigrator_projectGraph.set(this, void 0);
15
16
  _ExecutorToPluginMigrator_executor.set(this, void 0);
@@ -23,7 +24,7 @@ class ExecutorToPluginMigrator {
23
24
  _ExecutorToPluginMigrator_targetAndProjectsToMigrate.set(this, void 0);
24
25
  _ExecutorToPluginMigrator_pluginToAddForTarget.set(this, void 0);
25
26
  _ExecutorToPluginMigrator_createNodes.set(this, void 0);
26
- _ExecutorToPluginMigrator_configFiles.set(this, void 0);
27
+ _ExecutorToPluginMigrator_createNodesV2.set(this, void 0);
27
28
  _ExecutorToPluginMigrator_createNodesResultsForTargets.set(this, void 0);
28
29
  this.tree = tree;
29
30
  tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_projectGraph, projectGraph, "f");
@@ -32,6 +33,7 @@ class ExecutorToPluginMigrator {
32
33
  tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_pluginOptionsBuilder, pluginOptionsBuilder, "f");
33
34
  tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_postTargetTransformer, postTargetTransformer, "f");
34
35
  tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_createNodes, createNodes, "f");
36
+ tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_createNodesV2, createNodesV2, "f");
35
37
  tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_specificProjectToMigrate, specificProjectToMigrate, "f");
36
38
  tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_skipTargetFilter, skipTargetFilter ?? ((...args) => [false, '']), "f");
37
39
  }
@@ -46,7 +48,7 @@ class ExecutorToPluginMigrator {
46
48
  return tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f");
47
49
  }
48
50
  }
49
- _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrator_executor = new WeakMap(), _ExecutorToPluginMigrator_pluginPath = new WeakMap(), _ExecutorToPluginMigrator_pluginOptionsBuilder = new WeakMap(), _ExecutorToPluginMigrator_postTargetTransformer = new WeakMap(), _ExecutorToPluginMigrator_skipTargetFilter = new WeakMap(), _ExecutorToPluginMigrator_specificProjectToMigrate = new WeakMap(), _ExecutorToPluginMigrator_nxJson = new WeakMap(), _ExecutorToPluginMigrator_targetDefaultsForExecutor = new WeakMap(), _ExecutorToPluginMigrator_targetAndProjectsToMigrate = new WeakMap(), _ExecutorToPluginMigrator_pluginToAddForTarget = new WeakMap(), _ExecutorToPluginMigrator_createNodes = new WeakMap(), _ExecutorToPluginMigrator_configFiles = new WeakMap(), _ExecutorToPluginMigrator_createNodesResultsForTargets = new WeakMap(), _ExecutorToPluginMigrator_instances = new WeakSet(), _ExecutorToPluginMigrator_init = async function _ExecutorToPluginMigrator_init() {
51
+ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrator_executor = new WeakMap(), _ExecutorToPluginMigrator_pluginPath = new WeakMap(), _ExecutorToPluginMigrator_pluginOptionsBuilder = new WeakMap(), _ExecutorToPluginMigrator_postTargetTransformer = new WeakMap(), _ExecutorToPluginMigrator_skipTargetFilter = new WeakMap(), _ExecutorToPluginMigrator_specificProjectToMigrate = new WeakMap(), _ExecutorToPluginMigrator_nxJson = new WeakMap(), _ExecutorToPluginMigrator_targetDefaultsForExecutor = new WeakMap(), _ExecutorToPluginMigrator_targetAndProjectsToMigrate = new WeakMap(), _ExecutorToPluginMigrator_pluginToAddForTarget = new WeakMap(), _ExecutorToPluginMigrator_createNodes = new WeakMap(), _ExecutorToPluginMigrator_createNodesV2 = new WeakMap(), _ExecutorToPluginMigrator_createNodesResultsForTargets = new WeakMap(), _ExecutorToPluginMigrator_instances = new WeakSet(), _ExecutorToPluginMigrator_init = async function _ExecutorToPluginMigrator_init() {
50
52
  const nxJson = (0, devkit_exports_1.readNxJson)(this.tree);
51
53
  nxJson.plugins ??= [];
52
54
  tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_nxJson, nxJson, "f");
@@ -74,6 +76,9 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
74
76
  projectTarget = (0, devkit_internals_1.mergeTargetConfigurations)(projectTarget, tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetDefaultsForExecutor, "f"));
75
77
  delete projectTarget.executor;
76
78
  (0, plugin_migration_utils_1.deleteMatchingProperties)(projectTarget, createdTarget);
79
+ if (projectTarget.inputs && createdTarget.inputs) {
80
+ tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_instances, "m", _ExecutorToPluginMigrator_mergeInputs).call(this, projectTarget, createdTarget);
81
+ }
77
82
  projectTarget = tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_postTargetTransformer, "f").call(this, projectTarget, this.tree, { projectName, root: projectFromGraph.data.root }, createdTarget);
78
83
  if (projectTarget.options &&
79
84
  Object.keys(projectTarget.options).length === 0) {
@@ -90,8 +95,44 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
90
95
  }
91
96
  (0, devkit_exports_1.updateProjectConfiguration)(this.tree, projectName, projectConfig);
92
97
  return `${projectFromGraph.data.root}/**/*`;
98
+ }, _ExecutorToPluginMigrator_mergeInputs = function _ExecutorToPluginMigrator_mergeInputs(target, inferredTarget) {
99
+ const isInputInferred = (input) => {
100
+ return inferredTarget.inputs.some((inferredInput) => {
101
+ try {
102
+ (0, node_assert_1.deepStrictEqual)(input, inferredInput);
103
+ return true;
104
+ }
105
+ catch {
106
+ return false;
107
+ }
108
+ });
109
+ };
110
+ if (target.inputs.every(isInputInferred)) {
111
+ delete target.inputs;
112
+ return;
113
+ }
114
+ const inferredTargetExternalDependencyInput = inferredTarget.inputs.find((i) => typeof i !== 'string' && 'externalDependencies' in i);
115
+ if (!inferredTargetExternalDependencyInput) {
116
+ // plugins should normally have an externalDependencies input, but if it
117
+ // doesn't, there's nothing to merge
118
+ return;
119
+ }
120
+ const targetExternalDependencyInput = target.inputs.find((i) => typeof i !== 'string' && 'externalDependencies' in i);
121
+ if (!targetExternalDependencyInput) {
122
+ // the target doesn't have an externalDependencies input, so we can just
123
+ // add the inferred one
124
+ target.inputs.push(inferredTargetExternalDependencyInput);
125
+ }
126
+ else {
127
+ // the target has an externalDependencies input, so we need to merge them
128
+ targetExternalDependencyInput.externalDependencies = Array.from(new Set([
129
+ ...targetExternalDependencyInput.externalDependencies,
130
+ ...inferredTargetExternalDependencyInput.externalDependencies,
131
+ ]));
132
+ }
93
133
  }, _ExecutorToPluginMigrator_pluginRequiresIncludes = async function _ExecutorToPluginMigrator_pluginRequiresIncludes(targetName, plugin) {
94
134
  const loadedPlugin = new devkit_internals_1.LoadedNxPlugin({
135
+ createNodesV2: tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_createNodesV2, "f"),
95
136
  createNodes: tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_createNodes, "f"),
96
137
  name: tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_pluginPath, "f"),
97
138
  }, plugin);
@@ -171,7 +212,7 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
171
212
  }
172
213
  });
173
214
  }, _ExecutorToPluginMigrator_getTargetDefaultsForExecutor = function _ExecutorToPluginMigrator_getTargetDefaultsForExecutor() {
174
- tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_targetDefaultsForExecutor, tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_nxJson, "f").targetDefaults?.[tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_executor, "f")], "f");
215
+ tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_targetDefaultsForExecutor, structuredClone(tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_nxJson, "f").targetDefaults?.[tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_executor, "f")]), "f");
175
216
  }, _ExecutorToPluginMigrator_getCreatedTargetForProjectRoot = function _ExecutorToPluginMigrator_getCreatedTargetForProjectRoot(targetName, projectRoot) {
176
217
  const entry = Object.entries(tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_createNodesResultsForTargets, "f").get(targetName)?.projects ?? {}).find(([root]) => root === projectRoot);
177
218
  if (!entry) {
@@ -188,6 +229,7 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
188
229
  }
189
230
  for (const targetName of tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").keys()) {
190
231
  const loadedPlugin = new devkit_internals_1.LoadedNxPlugin({
232
+ createNodesV2: tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_createNodesV2, "f"),
191
233
  createNodes: tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_createNodes, "f"),
192
234
  name: tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_pluginPath, "f"),
193
235
  }, {
@@ -206,15 +248,19 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
206
248
  throw e;
207
249
  }
208
250
  }
209
- tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_configFiles, Array.from(projectConfigs.matchingProjectFiles), "f");
210
251
  tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_createNodesResultsForTargets, "f").set(targetName, projectConfigs);
211
252
  }
212
253
  };
213
254
  async function migrateExecutorToPlugin(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, createNodes, specificProjectToMigrate, skipTargetFilter) {
214
- const migrator = new ExecutorToPluginMigrator(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, createNodes, specificProjectToMigrate, skipTargetFilter);
255
+ const migrator = new ExecutorToPluginMigrator(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, undefined, createNodes, specificProjectToMigrate, skipTargetFilter);
215
256
  return await migrator.run();
216
257
  }
217
258
  exports.migrateExecutorToPlugin = migrateExecutorToPlugin;
259
+ async function migrateExecutorToPluginV1(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, createNodes, specificProjectToMigrate, skipTargetFilter) {
260
+ const migrator = new ExecutorToPluginMigrator(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, createNodes, undefined, specificProjectToMigrate, skipTargetFilter);
261
+ return await migrator.run();
262
+ }
263
+ exports.migrateExecutorToPluginV1 = migrateExecutorToPluginV1;
218
264
  // Checks if two objects are structurely equal, without caring
219
265
  // about the order of the keys.
220
266
  function deepEqual(a, b, logKey = '') {
@@ -1,2 +1,2 @@
1
1
  import { CreateNodesContext } from 'nx/src/devkit-exports';
2
- export declare function calculateHashForCreateNodes(projectRoot: string, options: object, context: CreateNodesContext, additionalGlobs?: string[]): string;
2
+ export declare function calculateHashForCreateNodes(projectRoot: string, options: object, context: CreateNodesContext, additionalGlobs?: string[]): Promise<string>;
@@ -4,9 +4,9 @@ exports.calculateHashForCreateNodes = void 0;
4
4
  const path_1 = require("path");
5
5
  const devkit_exports_1 = require("nx/src/devkit-exports");
6
6
  const devkit_internals_1 = require("nx/src/devkit-internals");
7
- function calculateHashForCreateNodes(projectRoot, options, context, additionalGlobs = []) {
7
+ async function calculateHashForCreateNodes(projectRoot, options, context, additionalGlobs = []) {
8
8
  return (0, devkit_exports_1.hashArray)([
9
- (0, devkit_internals_1.hashWithWorkspaceContext)(context.workspaceRoot, [
9
+ await (0, devkit_internals_1.hashWithWorkspaceContext)(context.workspaceRoot, [
10
10
  (0, path_1.join)(projectRoot, '**/*'),
11
11
  ...additionalGlobs,
12
12
  ]),