nx 23.3.0-beta.2 → 23.3.0-beta.4

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 (58) hide show
  1. package/dist/bin/init-local.js +7 -1
  2. package/dist/src/command-line/add/add.js +5 -1
  3. package/dist/src/command-line/init/implementation/utils.js +6 -1
  4. package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +25 -0
  5. package/dist/src/command-line/migrate/agentic/capture-generator-output.js +121 -5
  6. package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +21 -0
  7. package/dist/src/command-line/migrate/agentic/close-agent-session.js +126 -0
  8. package/dist/src/command-line/migrate/agentic/definitions.d.ts +24 -0
  9. package/dist/src/command-line/migrate/agentic/definitions.js +5 -2
  10. package/dist/src/command-line/migrate/agentic/handoff.d.ts +23 -0
  11. package/dist/src/command-line/migrate/agentic/handoff.js +62 -3
  12. package/dist/src/command-line/migrate/agentic/master/invocations.d.ts +12 -0
  13. package/dist/src/command-line/migrate/agentic/master/invocations.js +54 -0
  14. package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +12 -0
  15. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +99 -0
  16. package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +31 -0
  17. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +217 -0
  18. package/dist/src/command-line/migrate/agentic/prompts/fragments.js +3 -0
  19. package/dist/src/command-line/migrate/agentic/runner.d.ts +0 -21
  20. package/dist/src/command-line/migrate/agentic/runner.js +12 -249
  21. package/dist/src/command-line/migrate/agentic/terminal-repair.d.ts +1 -0
  22. package/dist/src/command-line/migrate/agentic/terminal-repair.js +27 -0
  23. package/dist/src/command-line/migrate/agentic/windows-cmd.d.ts +33 -0
  24. package/dist/src/command-line/migrate/agentic/windows-cmd.js +88 -0
  25. package/dist/src/command-line/migrate/deferred-output.d.ts +44 -0
  26. package/dist/src/command-line/migrate/deferred-output.js +92 -0
  27. package/dist/src/command-line/migrate/execute-migration.d.ts +9 -3
  28. package/dist/src/command-line/migrate/execute-migration.js +53 -16
  29. package/dist/src/command-line/migrate/migrate-commits.d.ts +4 -4
  30. package/dist/src/command-line/migrate/migrate-commits.js +7 -6
  31. package/dist/src/command-line/migrate/migrate.js +28 -13
  32. package/dist/src/command-line/migrate/run/broker.d.ts +138 -0
  33. package/dist/src/command-line/migrate/run/broker.js +507 -0
  34. package/dist/src/command-line/migrate/run/clean-retry.d.ts +12 -0
  35. package/dist/src/command-line/migrate/run/clean-retry.js +98 -0
  36. package/dist/src/command-line/migrate/run/index.d.ts +4 -3
  37. package/dist/src/command-line/migrate/run/index.js +7 -1
  38. package/dist/src/command-line/migrate/run/issues.d.ts +8 -1
  39. package/dist/src/command-line/migrate/run/issues.js +40 -6
  40. package/dist/src/command-line/migrate/run/orchestrator.d.ts +18 -1
  41. package/dist/src/command-line/migrate/run/orchestrator.js +409 -377
  42. package/dist/src/command-line/migrate/run/run-state.d.ts +16 -0
  43. package/dist/src/command-line/migrate/run/run-state.js +33 -2
  44. package/dist/src/command-line/migrate/run/runbook.js +8 -4
  45. package/dist/src/command-line/migrate/run/state-machine.d.ts +24 -1
  46. package/dist/src/command-line/migrate/run/state-machine.js +112 -21
  47. package/dist/src/command-line/migrate/run/util.d.ts +2 -1
  48. package/dist/src/command-line/migrate/run/util.js +3 -3
  49. package/dist/src/command-line/migrate/run/worker.js +170 -164
  50. package/dist/src/core/graph/main.js +1 -1
  51. package/dist/src/daemon/server/server.js +11 -8
  52. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  53. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  54. package/dist/src/tasks-runner/run-command.js +3 -0
  55. package/dist/src/utils/git-utils.d.ts +12 -0
  56. package/dist/src/utils/git-utils.js +76 -30
  57. package/dist/src/utils/package-json.js +8 -0
  58. package/package.json +11 -11
@@ -67,6 +67,7 @@ const project_graph_listener_sockets_1 = require("./project-graph-listener-socke
67
67
  const shutdown_utils_1 = require("./shutdown-utils");
68
68
  const sync_generators_1 = require("./sync-generators");
69
69
  const workspace_context_1 = require("../../utils/workspace-context");
70
+ const is_ci_1 = require("../../utils/is-ci");
70
71
  let workspaceWatcherError;
71
72
  global.NX_DAEMON = true;
72
73
  process.env.NX_DAEMON_PROCESS = 'true';
@@ -458,14 +459,16 @@ async function startServer() {
458
459
  // register file change listener to invalidate sync generator cache
459
460
  (0, file_change_events_1.registerFileChangeListener)(sync_generators_1.clearSyncGeneratorsCache);
460
461
  (0, project_graph_incremental_recomputation_1.scheduleInitialProjectGraphComputation)();
461
- // Kick off Nx Console check in background to prime the cache
462
- (0, handle_nx_console_1.handleGetNxConsoleStatus)().catch(() => {
463
- // Ignore errors, this is a background operation
464
- });
465
- // Kick off AI agents outdated check in background to prime the cache
466
- (0, handle_configure_ai_agents_1.handleGetConfigureAiAgentsStatus)().catch(() => {
467
- // Ignore errors, this is a background operation
468
- });
462
+ // Prime the Nx Console and AI agents caches in the background. Both
463
+ // pull nx@latest, and the CLI never shows their results in CI.
464
+ if (!(0, is_ci_1.isCI)()) {
465
+ (0, handle_nx_console_1.handleGetNxConsoleStatus)().catch(() => {
466
+ // Ignore errors, this is a background operation
467
+ });
468
+ (0, handle_configure_ai_agents_1.handleGetConfigureAiAgentsStatus)().catch(() => {
469
+ // Ignore errors, this is a background operation
470
+ });
471
+ }
469
472
  return resolve(server);
470
473
  }
471
474
  catch (err) {
Binary file
@@ -418,6 +418,9 @@ async function runCommandForTasks(projectsToRun, currentProjectGraph, { nxJson }
418
418
  }
419
419
  async function printConfigureAiAgentsDisclaimer() {
420
420
  try {
421
+ if ((0, is_ci_1.isCI)()) {
422
+ return;
423
+ }
421
424
  if (!client_1.daemonClient.enabled() || !(await client_1.daemonClient.isServerAvailable())) {
422
425
  return;
423
426
  }
@@ -90,6 +90,18 @@ export declare function commitChanges(commitMessage: string, directory?: string)
90
90
  * callers' own constants, never from user input.
91
91
  */
92
92
  export declare function tryCommitChanges(commitMessage: string, directory: string, excludePaths?: string[]): string | null;
93
+ /**
94
+ * `tryCommitChanges` for a process that has to stay responsive while git
95
+ * runs: a signing prompt or a hook can hold the commit for minutes.
96
+ */
97
+ export declare function tryCommitChangesAsync(commitMessage: string, directory: string, excludePaths?: string[]): Promise<string | null>;
98
+ /**
99
+ * `git reset --hard <ref>` then `git clean -fd`, keeping `keepPaths` (git
100
+ * exclusion patterns, repo-relative) out of the clean. Throws with git's
101
+ * stderr when either fails. `ref` is a sha a caller validated with `GIT_SHA`,
102
+ * never user input.
103
+ */
104
+ export declare function resetWorkingTree(ref: string, keepPaths: string[], directory: string): void;
93
105
  export declare function getLatestCommitSha(directory?: string): string | null;
94
106
  /**
95
107
  * The shape of a recorded `git rev-parse` output: 40 hex chars, or 64 in a
@@ -19,6 +19,8 @@ exports.getPathCommitExposure = getPathCommitExposure;
19
19
  exports.getUncommittedChangesSnapshot = getUncommittedChangesSnapshot;
20
20
  exports.commitChanges = commitChanges;
21
21
  exports.tryCommitChanges = tryCommitChanges;
22
+ exports.tryCommitChangesAsync = tryCommitChangesAsync;
23
+ exports.resetWorkingTree = resetWorkingTree;
22
24
  exports.getLatestCommitSha = getLatestCommitSha;
23
25
  exports.isAncestorCommit = isAncestorCommit;
24
26
  const tslib_1 = require("tslib");
@@ -849,47 +851,91 @@ function commitChanges(commitMessage, directory) {
849
851
  */
850
852
  function tryCommitChanges(commitMessage, directory, excludePaths = []) {
851
853
  try {
852
- (0, child_process_1.execSync)('git add -A', {
853
- encoding: 'utf8',
854
- stdio: 'pipe',
855
- cwd: directory,
856
- windowsHide: true,
857
- });
858
- // Exclusion happens as an unstage rather than an add-time pathspec:
859
- // `git add` refuses a pathspec naming an ignored directory (exit 1) even
860
- // as an exclusion, and an add-time pathspec cannot cover entries that
861
- // were already staged before this call. The reset is relative to cwd, so
862
- // a workspace nested inside a larger repo excludes its own path; a path
863
- // with no index entry is a quiet no-op, unborn HEAD included.
864
- for (const excludePath of excludePaths) {
865
- (0, child_process_1.execSync)(`git reset -q -- "${excludePath}"`, {
854
+ for (const { command, input } of commitCommands(commitMessage, excludePaths)) {
855
+ (0, child_process_1.execSync)(command, {
866
856
  encoding: 'utf8',
867
857
  stdio: 'pipe',
858
+ input,
868
859
  cwd: directory,
869
860
  windowsHide: true,
870
861
  });
871
862
  }
872
- (0, child_process_1.execSync)('git commit --no-verify -F -', {
873
- encoding: 'utf8',
874
- stdio: 'pipe',
875
- input: commitMessage,
876
- cwd: directory,
877
- windowsHide: true,
878
- });
879
863
  }
880
864
  catch (err) {
881
- const stderr = err?.stderr?.toString();
882
- const stdout = err?.stdout?.toString();
883
- const detail = [stderr, stdout]
884
- .map((s) => s?.trim())
885
- .filter(Boolean)
886
- .join('\n');
887
- // `{ cause }` preserves structured fields (.signal, .status, .code)
888
- // for callers to inspect; otherwise only stderr/stdout text survives.
889
- throw new Error(detail || (err instanceof Error ? err.message : String(err)), { cause: err });
865
+ throw commitFailure(err);
890
866
  }
891
867
  return getLatestCommitSha(directory);
892
868
  }
869
+ /**
870
+ * `tryCommitChanges` for a process that has to stay responsive while git
871
+ * runs: a signing prompt or a hook can hold the commit for minutes.
872
+ */
873
+ async function tryCommitChangesAsync(commitMessage, directory, excludePaths = []) {
874
+ try {
875
+ for (const { command, input } of commitCommands(commitMessage, excludePaths)) {
876
+ await execAsync(command, directory, input);
877
+ }
878
+ }
879
+ catch (err) {
880
+ throw commitFailure(err);
881
+ }
882
+ return getLatestCommitSha(directory);
883
+ }
884
+ function commitCommands(commitMessage, excludePaths) {
885
+ return [
886
+ { command: 'git add -A' },
887
+ // Exclusion happens as an unstage rather than an add-time pathspec:
888
+ // `git add` refuses a pathspec naming an ignored directory (exit 1) even
889
+ // as an exclusion, and an add-time pathspec cannot cover entries that
890
+ // were already staged before this call. The reset is relative to cwd, so
891
+ // a workspace nested inside a larger repo excludes its own path; a path
892
+ // with no index entry is a quiet no-op, unborn HEAD included.
893
+ ...excludePaths.map((excludePath) => ({
894
+ command: `git reset -q -- "${excludePath}"`,
895
+ })),
896
+ { command: 'git commit --no-verify -F -', input: commitMessage },
897
+ ];
898
+ }
899
+ function commitFailure(err) {
900
+ const stderr = err?.stderr?.toString();
901
+ const stdout = err?.stdout?.toString();
902
+ const detail = [stderr, stdout]
903
+ .map((s) => s?.trim())
904
+ .filter(Boolean)
905
+ .join('\n');
906
+ // `{ cause }` preserves structured fields (.signal, .status, .code)
907
+ // for callers to inspect; otherwise only stderr/stdout text survives.
908
+ return new Error(detail || (err instanceof Error ? err.message : String(err)), { cause: err });
909
+ }
910
+ function execAsync(command, cwd, input) {
911
+ return new Promise((res, rej) => {
912
+ const child = (0, child_process_1.exec)(command, { encoding: 'utf8', cwd, windowsHide: true },
913
+ // The streams ride on the error as `execSync` reports them, so
914
+ // `commitFailure` shapes both the same way.
915
+ (err, stdout, stderr) => err ? rej(Object.assign(err, { stdout, stderr })) : res());
916
+ // Closed for every command, since `git commit -F -` reads to end of
917
+ // input. A child that exits before reading raises EPIPE here, which the
918
+ // exit callback already reports.
919
+ child.stdin?.on('error', () => { });
920
+ child.stdin?.end(input ?? '');
921
+ });
922
+ }
923
+ /**
924
+ * `git reset --hard <ref>` then `git clean -fd`, keeping `keepPaths` (git
925
+ * exclusion patterns, repo-relative) out of the clean. Throws with git's
926
+ * stderr when either fails. `ref` is a sha a caller validated with `GIT_SHA`,
927
+ * never user input.
928
+ */
929
+ function resetWorkingTree(ref, keepPaths, directory) {
930
+ const options = {
931
+ encoding: 'utf8',
932
+ stdio: 'pipe',
933
+ cwd: directory,
934
+ windowsHide: true,
935
+ };
936
+ (0, child_process_1.execFileSync)('git', ['reset', '--hard', ref], options);
937
+ (0, child_process_1.execFileSync)('git', ['clean', '-fd', ...keepPaths.flatMap((keepPath) => ['-e', keepPath])], options);
938
+ }
893
939
  function getLatestCommitSha(directory) {
894
940
  try {
895
941
  return (0, child_process_1.execSync)('git rev-parse HEAD', {
@@ -279,11 +279,18 @@ function preparePackageInstallation(pkg, requiredVersion, packageManager) {
279
279
  // npm needs `--legacy-peer-deps` rather than `--omit=peer`: npm marks a package
280
280
  // as a peer if anything in the tree peer-depends on it, so `--omit=peer` also
281
281
  // prunes packages that are real dependencies. Bun's `--omit=peer` does not.
282
+ //
283
+ // pnpm has no plain flag for it. Up to 11 it takes `--config.<setting>`;
284
+ // pnpm 12 gave `--config` a meaning of its own and takes the setting from
285
+ // the environment instead.
282
286
  const skipPeerDependenciesFlags = {
283
287
  npm: '--legacy-peer-deps',
284
288
  bun: '--omit=peer',
285
289
  pnpm: '--config.auto-install-peers=false',
286
290
  };
291
+ const skipPeerDependenciesEnv = packageManager === 'pnpm'
292
+ ? { PNPM_CONFIG_AUTO_INSTALL_PEERS: 'false' }
293
+ : {};
287
294
  const installCommand = [
288
295
  pmCommands.addDev,
289
296
  `${pkg}@${requiredVersion}`,
@@ -301,6 +308,7 @@ function preparePackageInstallation(pkg, requiredVersion, packageManager) {
301
308
  env: {
302
309
  ...process.env,
303
310
  YARN_ENABLE_SCRIPTS: 'false',
311
+ ...skipPeerDependenciesEnv,
304
312
  },
305
313
  };
306
314
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "23.3.0-beta.2",
3
+ "version": "23.3.0-beta.4",
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.",
@@ -184,16 +184,16 @@
184
184
  }
185
185
  },
186
186
  "optionalDependencies": {
187
- "@nx/nx-darwin-arm64": "23.3.0-beta.2",
188
- "@nx/nx-darwin-x64": "23.3.0-beta.2",
189
- "@nx/nx-freebsd-x64": "23.3.0-beta.2",
190
- "@nx/nx-linux-arm-gnueabihf": "23.3.0-beta.2",
191
- "@nx/nx-linux-arm64-gnu": "23.3.0-beta.2",
192
- "@nx/nx-linux-arm64-musl": "23.3.0-beta.2",
193
- "@nx/nx-linux-x64-gnu": "23.3.0-beta.2",
194
- "@nx/nx-linux-x64-musl": "23.3.0-beta.2",
195
- "@nx/nx-win32-arm64-msvc": "23.3.0-beta.2",
196
- "@nx/nx-win32-x64-msvc": "23.3.0-beta.2"
187
+ "@nx/nx-darwin-arm64": "23.3.0-beta.4",
188
+ "@nx/nx-darwin-x64": "23.3.0-beta.4",
189
+ "@nx/nx-freebsd-x64": "23.3.0-beta.4",
190
+ "@nx/nx-linux-arm-gnueabihf": "23.3.0-beta.4",
191
+ "@nx/nx-linux-arm64-gnu": "23.3.0-beta.4",
192
+ "@nx/nx-linux-arm64-musl": "23.3.0-beta.4",
193
+ "@nx/nx-linux-x64-gnu": "23.3.0-beta.4",
194
+ "@nx/nx-linux-x64-musl": "23.3.0-beta.4",
195
+ "@nx/nx-win32-arm64-msvc": "23.3.0-beta.4",
196
+ "@nx/nx-win32-x64-msvc": "23.3.0-beta.4"
197
197
  },
198
198
  "nx-migrations": {
199
199
  "migrations": "./migrations.json",