@nx/devkit 19.0.0-canary.20240502-5ded713 → 19.0.0-canary.20240503-dbad02a

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.0.0-canary.20240502-5ded713",
3
+ "version": "19.0.0-canary.20240503-dbad02a",
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.0.0-canary.20240502-5ded713"
39
+ "@nrwl/devkit": "19.0.0-canary.20240503-dbad02a"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "nx": ">= 17 <= 20"
@@ -33,9 +33,7 @@ function forEachProjectConfig(projects, executorName, callback) {
33
33
  if (executorName !== target.executor) {
34
34
  continue;
35
35
  }
36
- if (target.options) {
37
- callback(target.options, projectName, targetName);
38
- }
36
+ callback(target.options ?? {}, projectName, targetName);
39
37
  if (!target.configurations) {
40
38
  continue;
41
39
  }
@@ -2,5 +2,5 @@ import { ProjectGraph, TargetConfiguration, Tree, CreateNodes } from 'nx/src/dev
2
2
  type PluginOptionsBuilder<T> = (targetName: string) => T;
3
3
  type PostTargetTransformer = (targetConfiguration: TargetConfiguration, tree?: Tree) => TargetConfiguration;
4
4
  type SkipTargetFilter = (targetConfiguration: TargetConfiguration) => [boolean, string];
5
- 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<void>;
5
+ 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<number>;
6
6
  export {};
@@ -37,10 +37,13 @@ class ExecutorToPluginMigrator {
37
37
  }
38
38
  async run() {
39
39
  await tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_instances, "m", _ExecutorToPluginMigrator_init).call(this);
40
- for (const targetName of tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").keys()) {
41
- tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_instances, "m", _ExecutorToPluginMigrator_migrateTarget).call(this, targetName);
40
+ if (tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").size > 0) {
41
+ for (const targetName of tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").keys()) {
42
+ tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_instances, "m", _ExecutorToPluginMigrator_migrateTarget).call(this, targetName);
43
+ }
44
+ tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_instances, "m", _ExecutorToPluginMigrator_addPlugins).call(this);
42
45
  }
43
- tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_instances, "m", _ExecutorToPluginMigrator_addPlugins).call(this);
46
+ return tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f");
44
47
  }
45
48
  }
46
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() {
@@ -151,12 +154,6 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
151
154
  tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").set(targetName, new Set([projectName]));
152
155
  }
153
156
  });
154
- if (tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").size === 0) {
155
- const errorMsg = tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_specificProjectToMigrate, "f")
156
- ? `Project "${tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_specificProjectToMigrate, "f")}" does not contain any targets using the "${tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_executor, "f")}" executor. Please select a project that does.`
157
- : `Could not find any targets using the "${tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_executor, "f")}" executor.`;
158
- throw new Error(errorMsg);
159
- }
160
157
  }, _ExecutorToPluginMigrator_getTargetDefaultsForExecutor = function _ExecutorToPluginMigrator_getTargetDefaultsForExecutor() {
161
158
  tslib_1.__classPrivateFieldSet(this, _ExecutorToPluginMigrator_targetDefaultsForExecutor, tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_nxJson, "f").targetDefaults?.[tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_executor, "f")], "f");
162
159
  }, _ExecutorToPluginMigrator_getCreatedTargetForProjectRoot = function _ExecutorToPluginMigrator_getCreatedTargetForProjectRoot(targetName, projectRoot) {
@@ -166,6 +163,9 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
166
163
  delete createdTarget.options?.cwd;
167
164
  return createdTarget;
168
165
  }, _ExecutorToPluginMigrator_getCreateNodesResults = async function _ExecutorToPluginMigrator_getCreateNodesResults() {
166
+ if (tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").size === 0) {
167
+ return;
168
+ }
169
169
  for (const targetName of tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_targetAndProjectsToMigrate, "f").keys()) {
170
170
  const loadedPlugin = new devkit_internals_1.LoadedNxPlugin({
171
171
  createNodes: tslib_1.__classPrivateFieldGet(this, _ExecutorToPluginMigrator_createNodes, "f"),
@@ -192,6 +192,7 @@ _ExecutorToPluginMigrator_projectGraph = new WeakMap(), _ExecutorToPluginMigrato
192
192
  };
193
193
  async function migrateExecutorToPlugin(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, createNodes, specificProjectToMigrate, skipTargetFilter) {
194
194
  const migrator = new ExecutorToPluginMigrator(tree, projectGraph, executor, pluginPath, pluginOptionsBuilder, postTargetTransformer, createNodes, specificProjectToMigrate, skipTargetFilter);
195
- await migrator.run();
195
+ const migratedProjectsAndTargets = await migrator.run();
196
+ return migratedProjectsAndTargets.size;
196
197
  }
197
198
  exports.migrateExecutorToPlugin = migrateExecutorToPlugin;