nx 23.0.0-beta.21 → 23.0.0-beta.23

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.
Files changed (82) hide show
  1. package/dist/plugins/package-json.js +1 -1
  2. package/dist/src/adapter/angular-json.d.ts +2 -2
  3. package/dist/src/adapter/angular-json.js +0 -1
  4. package/dist/src/adapter/compat.d.ts +1 -1
  5. package/dist/src/adapter/compat.js +1 -0
  6. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +2 -1
  7. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +1 -1
  8. package/dist/src/command-line/examples.js +4 -4
  9. package/dist/src/command-line/graph/graph.js +1 -1
  10. package/dist/src/command-line/init/init-v2.js +1 -1
  11. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +5 -0
  12. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +1 -0
  13. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +5 -0
  14. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +1 -0
  15. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +5 -0
  16. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +1 -0
  17. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +1 -0
  18. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +15 -0
  19. package/dist/src/command-line/migrate/agentic/run-step.d.ts +7 -0
  20. package/dist/src/command-line/migrate/agentic/run-step.js +3 -1
  21. package/dist/src/command-line/migrate/agentic/select.js +120 -32
  22. package/dist/src/command-line/migrate/command-object.d.ts +42 -0
  23. package/dist/src/command-line/migrate/command-object.js +38 -8
  24. package/dist/src/command-line/migrate/migrate-config.d.ts +27 -0
  25. package/dist/src/command-line/migrate/migrate-config.js +103 -0
  26. package/dist/src/command-line/migrate/migrate.d.ts +39 -2
  27. package/dist/src/command-line/migrate/migrate.js +203 -41
  28. package/dist/src/command-line/migrate/multi-major.js +5 -2
  29. package/dist/src/command-line/release/changelog/version-plan-filtering.d.ts +3 -1
  30. package/dist/src/command-line/release/changelog/version-plan-filtering.js +7 -3
  31. package/dist/src/command-line/release/changelog.d.ts +7 -0
  32. package/dist/src/command-line/release/changelog.js +22 -9
  33. package/dist/src/command-line/release/release.js +65 -55
  34. package/dist/src/command-line/release/utils/git.d.ts +6 -0
  35. package/dist/src/command-line/release/utils/git.js +33 -0
  36. package/dist/src/command-line/release/version/derive-specifier-from-conventional-commits.js +3 -2
  37. package/dist/src/command-line/release/version.d.ts +3 -0
  38. package/dist/src/command-line/release/version.js +13 -3
  39. package/dist/src/config/misc-interfaces.d.ts +8 -0
  40. package/dist/src/config/nx-json.d.ts +49 -0
  41. package/dist/src/core/graph/main.js +1 -1
  42. package/dist/src/daemon/server/latest-nx.js +3 -1
  43. package/dist/src/devkit-exports.d.ts +11 -11
  44. package/dist/src/devkit-exports.js +7 -4
  45. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  46. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  47. package/dist/src/plugins/js/index.d.ts +2 -2
  48. package/dist/src/plugins/js/index.js +4 -4
  49. package/dist/src/plugins/js/lock-file/lock-file.d.ts +7 -2
  50. package/dist/src/plugins/js/lock-file/lock-file.js +35 -25
  51. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +2 -4
  52. package/dist/src/plugins/js/project-graph/affected/lock-file-changes.js +121 -43
  53. package/dist/src/plugins/js/utils/register.d.ts +52 -0
  54. package/dist/src/plugins/js/utils/register.js +195 -0
  55. package/dist/src/plugins/package-json/create-nodes.d.ts +2 -2
  56. package/dist/src/plugins/package-json/create-nodes.js +2 -2
  57. package/dist/src/plugins/project-json/build-nodes/project-json.d.ts +2 -2
  58. package/dist/src/plugins/project-json/build-nodes/project-json.js +1 -1
  59. package/dist/src/project-graph/error-types.d.ts +6 -6
  60. package/dist/src/project-graph/error-types.js +1 -1
  61. package/dist/src/project-graph/file-utils.d.ts +7 -0
  62. package/dist/src/project-graph/file-utils.js +78 -10
  63. package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +2 -2
  64. package/dist/src/project-graph/plugins/isolation/messaging.d.ts +2 -2
  65. package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +3 -3
  66. package/dist/src/project-graph/plugins/loaded-nx-plugin.js +6 -4
  67. package/dist/src/project-graph/plugins/public-api.d.ts +31 -12
  68. package/dist/src/project-graph/plugins/transpiler.js +11 -0
  69. package/dist/src/project-graph/plugins/utils.d.ts +3 -3
  70. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +1 -1
  71. package/dist/src/project-graph/utils/project-configuration-utils.js +6 -17
  72. package/dist/src/tasks-runner/init-tasks-runner.d.ts +2 -2
  73. package/dist/src/tasks-runner/init-tasks-runner.js +6 -6
  74. package/dist/src/tasks-runner/task-orchestrator.d.ts +2 -2
  75. package/dist/src/tasks-runner/task-orchestrator.js +6 -6
  76. package/dist/src/utils/package-json.d.ts +3 -3
  77. package/dist/src/utils/package-json.js +9 -11
  78. package/dist/src/utils/package-manager.d.ts +13 -0
  79. package/dist/src/utils/package-manager.js +27 -0
  80. package/migrations.json +18 -9
  81. package/package.json +11 -11
  82. package/schemas/nx-schema.json +41 -0
@@ -26,6 +26,14 @@ function registerPluginTSTranspiler() {
26
26
  return;
27
27
  }
28
28
  if ((0, register_1.isNativeStripPreferred)()) {
29
+ // Native strip handles `.ts` syntax but doesn't rewrite NodeNext-style
30
+ // `.js` relative specifiers to their `.ts` sources. Patch the CJS resolver
31
+ // so `require('./foo.js')` from a `.ts` plugin source falls back to
32
+ // `./foo.ts`, and register an ESM resolution hook so the same rewrite
33
+ // happens on the dynamic-import path (the CJS patch can't reach ESM
34
+ // resolution). Both are idempotent and best-effort.
35
+ (0, register_1.ensureCjsResolverPatched)();
36
+ (0, register_1.ensureNodeNextEsmResolverRegistered)();
29
37
  // Sentinel so pluginTranspilerIsRegistered() reports true and callers
30
38
  // don't keep retrying. The actual transpiler stays unregistered until
31
39
  // a fallback forces it.
@@ -71,6 +79,9 @@ function doRegisterPluginTSTranspiler() {
71
79
  ...tsConfig.options,
72
80
  }, tsConfig.raw),
73
81
  ];
82
+ // Fall back from NodeNext `.js` specifiers to their `.ts` sources when a
83
+ // `.ts` plugin source require()s a sibling. Idempotent.
84
+ (0, register_1.ensureCjsResolverPatched)();
74
85
  exports.unregisterPluginTSTranspiler = () => {
75
86
  cleanupFns.forEach((fn) => fn?.());
76
87
  };
@@ -1,4 +1,4 @@
1
- import { CreateNodesContextV2, CreateNodesResult } from './public-api';
2
- export declare function createNodesFromFiles<T = unknown>(createNodes: (projectConfigurationFile: string, options: T | undefined, context: CreateNodesContextV2 & {
1
+ import { CreateNodesContext, CreateNodesResult } from './public-api';
2
+ export declare function createNodesFromFiles<T = unknown>(createNodes: (projectConfigurationFile: string, options: T | undefined, context: CreateNodesContext & {
3
3
  configFiles: readonly string[];
4
- }, idx: number) => CreateNodesResult | Promise<CreateNodesResult>, configFiles: readonly string[], options: T, context: CreateNodesContextV2): Promise<[file: string, value: CreateNodesResult][]>;
4
+ }, idx: number) => CreateNodesResult | Promise<CreateNodesResult>, configFiles: readonly string[], options: T, context: CreateNodesContext): Promise<[file: string, value: CreateNodesResult][]>;
@@ -80,4 +80,4 @@ export declare function mergeCreateNodesResults(specifiedResults: CreateNodesRes
80
80
  rootMap: Record<string, string>;
81
81
  configurationSourceMaps: ConfigurationSourceMaps;
82
82
  };
83
- export declare function findMatchingConfigFiles(projectFiles: string[], pattern: string, include: string[], exclude: string[]): string[];
83
+ export declare function findMatchingConfigFiles(projectFiles: string[], include: string[], exclude: string[]): string[];
@@ -58,8 +58,8 @@ async function createProjectConfigurationsWithPlugins(root = workspace_root_1.wo
58
58
  const errors = [];
59
59
  // We iterate over plugins first - this ensures that plugins specified first take precedence.
60
60
  for (const [index, { index: pluginIndex, createNodes: createNodesTuple, include, exclude, name: pluginName, },] of allCreateNodesPlugins.entries()) {
61
- const [pattern, createNodes] = createNodesTuple;
62
- const matchingConfigFiles = findMatchingConfigFiles(allProjectFiles[index], pattern, include, exclude);
61
+ const [, createNodes] = createNodesTuple;
62
+ const matchingConfigFiles = findMatchingConfigFiles(allProjectFiles[index], include, exclude);
63
63
  inProgressPlugins.add(pluginName);
64
64
  let r = createNodes(matchingConfigFiles, {
65
65
  nxJsonConfiguration: nxJson,
@@ -313,22 +313,11 @@ function createMatcher(patterns, emptyValue) {
313
313
  ? (file) => matchesNegationPatterns(file, patterns)
314
314
  : (file) => matchesSimplePatterns(file, patterns);
315
315
  }
316
- function findMatchingConfigFiles(projectFiles, pattern, include, exclude) {
317
- const matchingConfigFiles = [];
318
- // Create matchers once, outside the loop
316
+ function findMatchingConfigFiles(projectFiles, include, exclude) {
317
+ // projectFiles already comes from multiGlobWithWorkspaceContext for the
318
+ // plugin's createNodes pattern, so only include/exclude filters remain here.
319
319
  // Empty include means include everything, empty exclude means exclude nothing
320
320
  const includes = createMatcher(include, true);
321
321
  const excludes = createMatcher(exclude, false);
322
- for (const file of projectFiles) {
323
- if ((0, minimatch_1.minimatch)(file, pattern, { dot: true })) {
324
- if (!includes(file)) {
325
- continue;
326
- }
327
- if (excludes(file)) {
328
- continue;
329
- }
330
- matchingConfigFiles.push(file);
331
- }
332
- }
333
- return matchingConfigFiles;
322
+ return projectFiles.filter((file) => includes(file) && !excludes(file));
334
323
  }
@@ -3,5 +3,5 @@ import { Task, TaskGraph } from '../config/task-graph';
3
3
  import { LifeCycle, TaskResult } from './life-cycle';
4
4
  import type { ProjectGraph } from '../config/project-graph';
5
5
  import { RunningTask } from './running-tasks/running-task';
6
- export declare function runDiscreteTasks(tasks: Task[], projectGraph: ProjectGraph, taskGraphForHashing: TaskGraph, nxJson: NxJsonConfiguration, lifeCycle: LifeCycle): Promise<Array<Promise<TaskResult[]>>>;
7
- export declare function runContinuousTasks(tasks: Task[], projectGraph: ProjectGraph, taskGraphForHashing: TaskGraph, nxJson: NxJsonConfiguration, lifeCycle: LifeCycle): Promise<Record<string, Promise<RunningTask>>>;
6
+ export declare function runDiscreteTasks(tasks: Task[], projectGraph: ProjectGraph, fullTaskGraph: TaskGraph, nxJson: NxJsonConfiguration, lifeCycle: LifeCycle): Promise<Array<Promise<TaskResult[]>>>;
7
+ export declare function runContinuousTasks(tasks: Task[], projectGraph: ProjectGraph, fullTaskGraph: TaskGraph, nxJson: NxJsonConfiguration, lifeCycle: LifeCycle): Promise<Record<string, Promise<RunningTask>>>;
@@ -10,7 +10,7 @@ const task_orchestrator_1 = require("./task-orchestrator");
10
10
  const create_task_hasher_1 = require("../hasher/create-task-hasher");
11
11
  const client_1 = require("../daemon/client/client");
12
12
  const task_results_life_cycle_1 = require("./life-cycles/task-results-life-cycle");
13
- async function createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
13
+ async function createOrchestrator(tasks, projectGraph, fullTaskGraph, nxJson, lifeCycle) {
14
14
  (0, dotenv_1.loadRootEnvFiles)();
15
15
  const invokeRunnerTerminalLifecycle = new invoke_runner_terminal_output_life_cycle_1.InvokeRunnerTerminalOutputLifeCycle(tasks);
16
16
  const taskResultsLifecycle = new task_results_life_cycle_1.TaskResultsLifeCycle();
@@ -42,13 +42,13 @@ async function createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJs
42
42
  lifeCycle: compositedLifeCycle,
43
43
  };
44
44
  (0, run_command_1.setEnvVarsBasedOnArgs)(nxArgs, true);
45
- const orchestrator = new task_orchestrator_1.TaskOrchestrator(hasher, null, tasks, projectGraph, taskGraph, nxJson, nxArgs, false, client_1.daemonClient, undefined, taskGraphForHashing);
45
+ const orchestrator = new task_orchestrator_1.TaskOrchestrator(hasher, null, tasks, projectGraph, taskGraph, nxJson, nxArgs, false, client_1.daemonClient, undefined, fullTaskGraph);
46
46
  await orchestrator.init();
47
47
  orchestrator.processAllScheduledTasks();
48
48
  return orchestrator;
49
49
  }
50
- async function runDiscreteTasks(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
51
- const orchestrator = await createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle);
50
+ async function runDiscreteTasks(tasks, projectGraph, fullTaskGraph, nxJson, lifeCycle) {
51
+ const orchestrator = await createOrchestrator(tasks, projectGraph, fullTaskGraph, nxJson, lifeCycle);
52
52
  let groupId = 0;
53
53
  let nextBatch = orchestrator.nextBatch();
54
54
  const batchResults = [];
@@ -77,8 +77,8 @@ async function runDiscreteTasks(tasks, projectGraph, taskGraphForHashing, nxJson
77
77
  });
78
78
  return [...batchResults, ...taskResults];
79
79
  }
80
- async function runContinuousTasks(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
81
- const orchestrator = await createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle);
80
+ async function runContinuousTasks(tasks, projectGraph, fullTaskGraph, nxJson, lifeCycle) {
81
+ const orchestrator = await createOrchestrator(tasks, projectGraph, fullTaskGraph, nxJson, lifeCycle);
82
82
  return tasks.reduce((current, task, index) => {
83
83
  current[task.id] = orchestrator.startContinuousTask(task, index);
84
84
  return current;
@@ -21,7 +21,7 @@ export declare class TaskOrchestrator {
21
21
  private readonly bail;
22
22
  private readonly daemon;
23
23
  private readonly outputStyle;
24
- private readonly taskGraphForHashing;
24
+ private readonly fullTaskGraph;
25
25
  private taskDetails;
26
26
  private cache;
27
27
  private readonly tuiEnabled;
@@ -49,7 +49,7 @@ export declare class TaskOrchestrator {
49
49
  private discreteTaskExitHandled;
50
50
  private continuousTaskExitHandled;
51
51
  private cleanupPromise;
52
- constructor(hasher: TaskHasher, initiatingProject: string | undefined, initiatingTasks: Task[], projectGraph: ProjectGraph, taskGraph: TaskGraph, nxJson: NxJsonConfiguration, options: NxArgs & DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient, outputStyle: string, taskGraphForHashing?: TaskGraph);
52
+ constructor(hasher: TaskHasher, initiatingProject: string | undefined, initiatingTasks: Task[], projectGraph: ProjectGraph, taskGraph: TaskGraph, nxJson: NxJsonConfiguration, options: NxArgs & DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient, outputStyle: string, fullTaskGraph?: TaskGraph);
53
53
  init(): Promise<void>;
54
54
  run(): Promise<{
55
55
  [k: string]: TaskStatus;
@@ -39,7 +39,7 @@ function resolveBatchTaskStatus(result) {
39
39
  }
40
40
  class TaskOrchestrator {
41
41
  // endregion internal state
42
- constructor(hasher, initiatingProject, initiatingTasks, projectGraph, taskGraph, nxJson, options, bail, daemon, outputStyle, taskGraphForHashing = taskGraph) {
42
+ constructor(hasher, initiatingProject, initiatingTasks, projectGraph, taskGraph, nxJson, options, bail, daemon, outputStyle, fullTaskGraph = taskGraph) {
43
43
  this.hasher = hasher;
44
44
  this.initiatingProject = initiatingProject;
45
45
  this.initiatingTasks = initiatingTasks;
@@ -50,7 +50,7 @@ class TaskOrchestrator {
50
50
  this.bail = bail;
51
51
  this.daemon = daemon;
52
52
  this.outputStyle = outputStyle;
53
- this.taskGraphForHashing = taskGraphForHashing;
53
+ this.fullTaskGraph = fullTaskGraph;
54
54
  this.taskDetails = (0, hash_task_1.getTaskDetails)();
55
55
  this.cache = (0, cache_1.getCache)(this.options);
56
56
  this.tuiEnabled = (0, is_tui_enabled_1.isTuiEnabled)();
@@ -185,7 +185,7 @@ class TaskOrchestrator {
185
185
  for (const task of unhashed) {
186
186
  perTaskEnvs[task.id] = (0, task_env_1.getTaskSpecificEnv)(task, this.projectGraph);
187
187
  }
188
- await (0, hash_task_1.hashTasks)(this.hasher, this.projectGraph, this.taskGraphForHashing, perTaskEnvs, this.taskDetails, unhashed);
188
+ await (0, hash_task_1.hashTasks)(this.hasher, this.projectGraph, this.fullTaskGraph, perTaskEnvs, this.taskDetails, unhashed);
189
189
  }
190
190
  }
191
191
  // 2. Bulk-resolve cache hits before processTask — avoids N
@@ -257,7 +257,7 @@ class TaskOrchestrator {
257
257
  const task = this.taskGraph.tasks[taskId];
258
258
  const taskSpecificEnv = (0, task_env_1.getTaskSpecificEnv)(task, this.projectGraph);
259
259
  if (!task.hash) {
260
- await (0, hash_task_1.hashTask)(this.hasher, this.projectGraph, this.taskGraphForHashing, task, taskSpecificEnv, this.taskDetails);
260
+ await (0, hash_task_1.hashTask)(this.hasher, this.projectGraph, this.fullTaskGraph, task, taskSpecificEnv, this.taskDetails);
261
261
  }
262
262
  await this.options.lifeCycle.scheduleTask(task);
263
263
  return taskSpecificEnv;
@@ -474,7 +474,7 @@ class TaskOrchestrator {
474
474
  for (const task of tasks) {
475
475
  perTaskEnvs[task.id] = (0, task_env_1.getTaskSpecificEnv)(task, this.projectGraph);
476
476
  }
477
- await (0, hash_task_1.hashTasks)(this.hasher, this.projectGraph, this.taskGraphForHashing, perTaskEnvs, this.taskDetails, tasks);
477
+ await (0, hash_task_1.hashTasks)(this.hasher, this.projectGraph, this.fullTaskGraph, perTaskEnvs, this.taskDetails, tasks);
478
478
  }
479
479
  async applyFromCacheOrRunBatch(doNotSkipCache, batch, groupId) {
480
480
  const applyFromCacheOrRunBatchStart = perf_hooks_1.performance.mark('TaskOrchestrator-apply-from-cache-or-run-batch:start');
@@ -542,7 +542,7 @@ class TaskOrchestrator {
542
542
  async runBatch(batch, env, groupId) {
543
543
  const runBatchStart = perf_hooks_1.performance.mark('TaskOrchestrator-run-batch:start');
544
544
  try {
545
- const batchProcess = await this.forkedProcessTaskRunner.forkProcessForBatch(batch, this.projectGraph, this.taskGraph, env);
545
+ const batchProcess = await this.forkedProcessTaskRunner.forkProcessForBatch(batch, this.projectGraph, this.fullTaskGraph, env);
546
546
  // Stream output from batch process to the batch
547
547
  batchProcess.onOutput((output) => {
548
548
  this.options.lifeCycle.appendBatchOutput?.(batch.id, output);
@@ -1,7 +1,7 @@
1
1
  import { NxJsonConfiguration } from '../config/nx-json';
2
2
  import { ProjectConfiguration, ProjectMetadata, TargetConfiguration } from '../config/workspace-json-project-json';
3
3
  import type { Tree } from '../generators/tree';
4
- import { PackageManagerCommands } from './package-manager';
4
+ import { PackageManager, PackageManagerCommands } from './package-manager';
5
5
  export interface NxProjectPackageJsonConfiguration extends Partial<ProjectConfiguration> {
6
6
  includedScripts?: string[];
7
7
  }
@@ -137,11 +137,11 @@ export declare function readModulePackageJson(moduleSpecifier: string, requirePa
137
137
  packageJson: PackageJson;
138
138
  path: string;
139
139
  };
140
- export declare function installPackageToTmp(pkg: string, requiredVersion: string): {
140
+ export declare function installPackageToTmp(pkg: string, requiredVersion: string, packageManager: PackageManager): {
141
141
  tempDir: string;
142
142
  cleanup: () => void;
143
143
  };
144
- export declare function installPackageToTmpAsync(pkg: string, requiredVersion: string): Promise<{
144
+ export declare function installPackageToTmpAsync(pkg: string, requiredVersion: string, packageManager: PackageManager): Promise<{
145
145
  tempDir: string;
146
146
  cleanup: () => void;
147
147
  }>;
@@ -214,22 +214,20 @@ function readModulePackageJson(moduleSpecifier, requirePaths = (0, installation_
214
214
  * Prepares all necessary information for installing a package to a temporary directory.
215
215
  * This is used by both sync and async installation functions.
216
216
  */
217
- function preparePackageInstallation(pkg, requiredVersion) {
217
+ function preparePackageInstallation(pkg, requiredVersion, packageManager) {
218
218
  const { dir: tempDir, cleanup } = (0, package_manager_1.createTempNpmDirectory)?.() ?? {
219
219
  dir: (0, tmp_1.dirSync)().name,
220
220
  cleanup: () => { },
221
221
  };
222
222
  console.log(`Fetching ${pkg}...`);
223
- const packageManager = (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot);
224
223
  const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
225
224
  generatePackageManagerFiles(tempDir, packageManager);
225
+ // For pnpm, `addDev` is `pnpm add -Dw` when the workspace has a
226
+ // pnpm-workspace.yaml. `createTempNpmDirectory` copies a sanitized copy of
227
+ // it into the temp dir, so the `-w` here resolves to the temp dir.
226
228
  const pmCommands = (0, package_manager_1.getPackageManagerCommand)(packageManager);
227
229
  const preInstallCommand = pmCommands.preInstall;
228
- let addCommand = pmCommands.addDev;
229
- if (packageManager === 'pnpm') {
230
- addCommand = 'pnpm add -D'; // we need to ensure that we are not using workspace command
231
- }
232
- const installCommand = `${addCommand} ${pkg}@${requiredVersion} ${pmCommands.ignoreScriptsFlag ?? ''}`;
230
+ const installCommand = `${pmCommands.addDev} ${pkg}@${requiredVersion} ${pmCommands.ignoreScriptsFlag ?? ''}`;
233
231
  const execOptions = {
234
232
  cwd: tempDir,
235
233
  stdio: isVerbose ? 'inherit' : 'ignore',
@@ -249,8 +247,8 @@ function preparePackageInstallation(pkg, requiredVersion) {
249
247
  execOptions,
250
248
  };
251
249
  }
252
- function installPackageToTmp(pkg, requiredVersion) {
253
- const { tempDir, cleanup, preInstallCommand, installCommand, execOptions } = preparePackageInstallation(pkg, requiredVersion);
250
+ function installPackageToTmp(pkg, requiredVersion, packageManager) {
251
+ const { tempDir, cleanup, preInstallCommand, installCommand, execOptions } = preparePackageInstallation(pkg, requiredVersion, packageManager);
254
252
  if (preInstallCommand) {
255
253
  // ensure package.json and repo in tmp folder is set to a proper package manager state
256
254
  (0, child_process_1.execSync)(preInstallCommand, execOptions);
@@ -261,8 +259,8 @@ function installPackageToTmp(pkg, requiredVersion) {
261
259
  cleanup,
262
260
  };
263
261
  }
264
- async function installPackageToTmpAsync(pkg, requiredVersion) {
265
- const { tempDir, cleanup, preInstallCommand, installCommand, execOptions } = preparePackageInstallation(pkg, requiredVersion);
262
+ async function installPackageToTmpAsync(pkg, requiredVersion, packageManager) {
263
+ const { tempDir, cleanup, preInstallCommand, installCommand, execOptions } = preparePackageInstallation(pkg, requiredVersion, packageManager);
266
264
  try {
267
265
  if (preInstallCommand) {
268
266
  // ensure package.json and repo in tmp folder is set to a proper package manager state
@@ -75,6 +75,19 @@ export declare function modifyYarnRcYmlToFitNewDirectory(contents: string): stri
75
75
  * @returns Updated string contents of the yarnrc.yml file
76
76
  */
77
77
  export declare function modifyYarnRcToFitNewDirectory(contents: string): string;
78
+ /**
79
+ * We copy pnpm-workspace.yaml to the temporary directory so the workspace's
80
+ * registry, auth and release-age settings still apply, and so `pnpm add -w`
81
+ * recognizes the directory as a workspace root. `packages` (member globs) and
82
+ * `patchedDependencies` (relative patch paths) only resolve in the real
83
+ * workspace, so they are dropped.
84
+ *
85
+ * Exported for testing - not meant to be used outside of this file.
86
+ *
87
+ * @param contents The string contents of the pnpm-workspace.yaml file
88
+ * @returns Updated string contents of the pnpm-workspace.yaml file
89
+ */
90
+ export declare function modifyPnpmWorkspaceYamlToFitNewDirectory(contents: string): string;
78
91
  export declare function copyPackageManagerConfigurationFiles(root: string, destination: string): void;
79
92
  /**
80
93
  * Creates a temporary directory where you can run package manager commands safely.
@@ -8,6 +8,7 @@ exports.parseVersionFromPackageManagerField = parseVersionFromPackageManagerFiel
8
8
  exports.findFileInPackageJsonDirectory = findFileInPackageJsonDirectory;
9
9
  exports.modifyYarnRcYmlToFitNewDirectory = modifyYarnRcYmlToFitNewDirectory;
10
10
  exports.modifyYarnRcToFitNewDirectory = modifyYarnRcToFitNewDirectory;
11
+ exports.modifyPnpmWorkspaceYamlToFitNewDirectory = modifyPnpmWorkspaceYamlToFitNewDirectory;
11
12
  exports.copyPackageManagerConfigurationFiles = copyPackageManagerConfigurationFiles;
12
13
  exports.createTempNpmDirectory = createTempNpmDirectory;
13
14
  exports.resolvePackageVersionUsingRegistry = resolvePackageVersionUsingRegistry;
@@ -322,12 +323,33 @@ function modifyYarnRcToFitNewDirectory(contents) {
322
323
  }
323
324
  return lines.join('\n');
324
325
  }
326
+ /**
327
+ * We copy pnpm-workspace.yaml to the temporary directory so the workspace's
328
+ * registry, auth and release-age settings still apply, and so `pnpm add -w`
329
+ * recognizes the directory as a workspace root. `packages` (member globs) and
330
+ * `patchedDependencies` (relative patch paths) only resolve in the real
331
+ * workspace, so they are dropped.
332
+ *
333
+ * Exported for testing - not meant to be used outside of this file.
334
+ *
335
+ * @param contents The string contents of the pnpm-workspace.yaml file
336
+ * @returns Updated string contents of the pnpm-workspace.yaml file
337
+ */
338
+ function modifyPnpmWorkspaceYamlToFitNewDirectory(contents) {
339
+ const doc = (0, yaml_1.parseDocument)(contents);
340
+ if (doc.contents) {
341
+ doc.delete('packages');
342
+ doc.delete('patchedDependencies');
343
+ }
344
+ return doc.toString();
345
+ }
325
346
  function copyPackageManagerConfigurationFiles(root, destination) {
326
347
  for (const packageManagerConfigFile of [
327
348
  '.npmrc',
328
349
  '.yarnrc',
329
350
  '.yarnrc.yml',
330
351
  'bunfig.toml',
352
+ 'pnpm-workspace.yaml',
331
353
  ]) {
332
354
  // f is an absolute path, including the {workspaceRoot}.
333
355
  const f = findFileInPackageJsonDirectory(packageManagerConfigFile, root);
@@ -355,6 +377,11 @@ function copyPackageManagerConfigurationFiles(root, destination) {
355
377
  (0, fs_1.copyFileSync)(f, destinationPath);
356
378
  break;
357
379
  }
380
+ case 'pnpm-workspace.yaml': {
381
+ const updated = modifyPnpmWorkspaceYamlToFitNewDirectory((0, fileutils_1.readFileIfExisting)(f));
382
+ (0, fs_1.writeFileSync)(destinationPath, updated);
383
+ break;
384
+ }
358
385
  }
359
386
  }
360
387
  }
package/migrations.json CHANGED
@@ -41,7 +41,8 @@
41
41
  "cli": "nx",
42
42
  "version": "17.0.0-beta.1",
43
43
  "description": "Updates the default cache directory to .nx/cache",
44
- "implementation": "./dist/src/migrations/update-17-0-0/move-cache-directory"
44
+ "implementation": "./dist/src/migrations/update-17-0-0/move-cache-directory",
45
+ "documentation": "./dist/src/migrations/update-17-0-0/move-cache-directory.md"
45
46
  },
46
47
  "17.0.0-use-minimal-config-for-tasks-runner-options": {
47
48
  "cli": "nx",
@@ -93,33 +94,39 @@
93
94
  "move-use-daemon-process": {
94
95
  "version": "20.0.0-beta.7",
95
96
  "description": "Migration for v20.0.0-beta.7",
96
- "implementation": "./dist/src/migrations/update-20-0-0/move-use-daemon-process"
97
+ "implementation": "./dist/src/migrations/update-20-0-0/move-use-daemon-process",
98
+ "documentation": "./dist/src/migrations/update-20-0-0/move-use-daemon-process.md"
97
99
  },
98
100
  "use-legacy-cache": {
99
101
  "version": "20.0.1",
100
102
  "description": "Set `useLegacyCache` to true for migrating workspaces",
101
103
  "implementation": "./dist/src/migrations/update-20-0-1/use-legacy-cache",
102
- "x-repair-skip": true
104
+ "x-repair-skip": true,
105
+ "documentation": "./dist/src/migrations/update-20-0-1/use-legacy-cache.md"
103
106
  },
104
107
  "remove-legacy-cache": {
105
108
  "version": "21.0.0-beta.8",
106
109
  "description": "Removes the legacy cache configuration from nx.json",
107
- "implementation": "./dist/src/migrations/update-21-0-0/remove-legacy-cache"
110
+ "implementation": "./dist/src/migrations/update-21-0-0/remove-legacy-cache",
111
+ "documentation": "./dist/src/migrations/update-21-0-0/remove-legacy-cache.md"
108
112
  },
109
113
  "remove-custom-tasks-runner": {
110
114
  "version": "21.0.0-beta.8",
111
115
  "description": "Removes the legacy cache configuration from nx.json",
112
- "implementation": "./dist/src/migrations/update-21-0-0/remove-custom-tasks-runner"
116
+ "implementation": "./dist/src/migrations/update-21-0-0/remove-custom-tasks-runner",
117
+ "documentation": "./dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.md"
113
118
  },
114
119
  "release-version-config-changes": {
115
120
  "version": "21.0.0-beta.11",
116
121
  "description": "Updates release version config based on the breaking changes in Nx v21",
117
- "implementation": "./dist/src/migrations/update-21-0-0/release-version-config-changes"
122
+ "implementation": "./dist/src/migrations/update-21-0-0/release-version-config-changes",
123
+ "documentation": "./dist/src/migrations/update-21-0-0/release-version-config-changes.md"
118
124
  },
119
125
  "release-changelog-config-changes": {
120
126
  "version": "21.0.0-beta.11",
121
127
  "description": "Updates release changelog config based on the breaking changes in Nx v21",
122
- "implementation": "./dist/src/migrations/update-21-0-0/release-changelog-config-changes"
128
+ "implementation": "./dist/src/migrations/update-21-0-0/release-changelog-config-changes",
129
+ "documentation": "./dist/src/migrations/update-21-0-0/release-changelog-config-changes.md"
123
130
  },
124
131
  "22-0-0-release-version-config-changes": {
125
132
  "version": "22.0.0-beta.1",
@@ -159,7 +166,8 @@
159
166
  "cli": "nx",
160
167
  "version": "22.7.0-beta.0",
161
168
  "description": "Adds .nx/self-healing to .gitignore",
162
- "implementation": "./dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore"
169
+ "implementation": "./dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore",
170
+ "documentation": "./dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.md"
163
171
  },
164
172
  "23-0-0-consolidate-release-tag-config": {
165
173
  "version": "23.0.0-beta.16",
@@ -170,7 +178,8 @@
170
178
  "cli": "nx",
171
179
  "version": "23.0.0-beta.13",
172
180
  "description": "Converts nx.json `targetDefaults` from the legacy record shape to the new filtered array shape.",
173
- "implementation": "./dist/src/migrations/update-23-0-0/convert-target-defaults-to-array"
181
+ "implementation": "./dist/src/migrations/update-23-0-0/convert-target-defaults-to-array",
182
+ "documentation": "./dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.md"
174
183
  },
175
184
  "23-0-0-add-migrate-runs-to-git-ignore": {
176
185
  "version": "23.0.0-beta.18",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "23.0.0-beta.21",
3
+ "version": "23.0.0-beta.23",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
@@ -172,16 +172,16 @@
172
172
  }
173
173
  },
174
174
  "optionalDependencies": {
175
- "@nx/nx-darwin-arm64": "23.0.0-beta.21",
176
- "@nx/nx-darwin-x64": "23.0.0-beta.21",
177
- "@nx/nx-freebsd-x64": "23.0.0-beta.21",
178
- "@nx/nx-linux-arm-gnueabihf": "23.0.0-beta.21",
179
- "@nx/nx-linux-arm64-gnu": "23.0.0-beta.21",
180
- "@nx/nx-linux-arm64-musl": "23.0.0-beta.21",
181
- "@nx/nx-linux-x64-gnu": "23.0.0-beta.21",
182
- "@nx/nx-linux-x64-musl": "23.0.0-beta.21",
183
- "@nx/nx-win32-arm64-msvc": "23.0.0-beta.21",
184
- "@nx/nx-win32-x64-msvc": "23.0.0-beta.21"
175
+ "@nx/nx-darwin-arm64": "23.0.0-beta.23",
176
+ "@nx/nx-darwin-x64": "23.0.0-beta.23",
177
+ "@nx/nx-freebsd-x64": "23.0.0-beta.23",
178
+ "@nx/nx-linux-arm-gnueabihf": "23.0.0-beta.23",
179
+ "@nx/nx-linux-arm64-gnu": "23.0.0-beta.23",
180
+ "@nx/nx-linux-arm64-musl": "23.0.0-beta.23",
181
+ "@nx/nx-linux-x64-gnu": "23.0.0-beta.23",
182
+ "@nx/nx-linux-x64-musl": "23.0.0-beta.23",
183
+ "@nx/nx-win32-arm64-msvc": "23.0.0-beta.23",
184
+ "@nx/nx-win32-x64-msvc": "23.0.0-beta.23"
185
185
  },
186
186
  "nx-migrations": {
187
187
  "migrations": "./migrations.json",
@@ -421,6 +421,47 @@
421
421
  },
422
422
  "additionalProperties": false
423
423
  },
424
+ "migrate": {
425
+ "type": "object",
426
+ "description": "Configuration for the `nx migrate` command",
427
+ "properties": {
428
+ "createCommits": {
429
+ "type": "boolean",
430
+ "description": "Whether to automatically create a git commit after each migration runs. Equivalent to the `--create-commits` flag. Defaults to `false`."
431
+ },
432
+ "commitPrefix": {
433
+ "type": "string",
434
+ "description": "Commit message prefix applied to each migration commit when commits are enabled. Equivalent to the `--commit-prefix` flag. Defaults to `\"chore: [nx migration] \"`."
435
+ },
436
+ "mode": {
437
+ "type": "string",
438
+ "enum": ["first-party", "third-party", "all"],
439
+ "description": "Restricts which packages to migrate when migrating Nx itself. Equivalent to the `--mode` flag. Defaults to `all`."
440
+ },
441
+ "multiMajorMode": {
442
+ "type": "string",
443
+ "enum": ["direct", "gradual"],
444
+ "description": "How to handle a migration that crosses more than one major version. Equivalent to the `--multi-major-mode` flag. The `NX_MULTI_MAJOR_MODE` environment variable takes precedence over this setting."
445
+ },
446
+ "agentic": {
447
+ "oneOf": [
448
+ {
449
+ "type": "boolean"
450
+ },
451
+ {
452
+ "type": "string",
453
+ "enum": ["claude-code", "codex", "opencode"]
454
+ }
455
+ ],
456
+ "description": "Default for the agentic flow used by `nx migrate --run-migrations`. Equivalent to the `--agentic` flag. `false` never uses the agentic flow, `true` uses it and resolves the installed agent, and an agent id always uses that agent."
457
+ },
458
+ "validate": {
459
+ "type": "boolean",
460
+ "description": "Whether to run agent-driven validation after generator-only migrations when the agentic flow is enabled. Equivalent to the `--validate` flag. Defaults to `true` when the agentic flow is enabled."
461
+ }
462
+ },
463
+ "additionalProperties": false
464
+ },
424
465
  "conformance": {
425
466
  "type": "object",
426
467
  "description": "Configuration for Nx Conformance",