nx 24.0.0-beta.0 → 24.0.0-beta.2

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 (90) hide show
  1. package/dist/nx-cloud-internals.d.ts +1 -0
  2. package/dist/nx-cloud-internals.js +7 -1
  3. package/dist/src/command-line/graph/graph.js +2 -1
  4. package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +1 -1
  5. package/dist/src/command-line/migrate/agentic/close-agent-session.js +4 -3
  6. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +19 -23
  7. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +16 -19
  8. package/dist/src/command-line/migrate/agentic/master/run-master-session.js +25 -13
  9. package/dist/src/command-line/migrate/agentic/master/spawn-master.js +82 -22
  10. package/dist/src/command-line/migrate/agentic/select.js +3 -3
  11. package/dist/src/command-line/migrate/agentic/types.js +1 -3
  12. package/dist/src/command-line/migrate/command-object.js +5 -9
  13. package/dist/src/command-line/migrate/execute-migration.d.ts +2 -2
  14. package/dist/src/command-line/migrate/execute-migration.js +18 -10
  15. package/dist/src/command-line/migrate/migrate-analytics.d.ts +6 -0
  16. package/dist/src/command-line/migrate/migrate-analytics.js +12 -0
  17. package/dist/src/command-line/migrate/migrate-commits.d.ts +4 -1
  18. package/dist/src/command-line/migrate/migrate-commits.js +10 -3
  19. package/dist/src/command-line/migrate/migrate-config.d.ts +6 -6
  20. package/dist/src/command-line/migrate/migrate-config.js +12 -6
  21. package/dist/src/command-line/migrate/migrate.d.ts +3 -30
  22. package/dist/src/command-line/migrate/migrate.js +206 -237
  23. package/dist/src/command-line/migrate/run/agent-output.d.ts +1 -0
  24. package/dist/src/command-line/migrate/run/agent-output.js +5 -0
  25. package/dist/src/command-line/migrate/run/broker.d.ts +14 -5
  26. package/dist/src/command-line/migrate/run/broker.js +68 -20
  27. package/dist/src/command-line/migrate/run/existing-run-report.d.ts +1 -1
  28. package/dist/src/command-line/migrate/run/existing-run-report.js +7 -5
  29. package/dist/src/command-line/migrate/run/index.d.ts +6 -5
  30. package/dist/src/command-line/migrate/run/index.js +12 -1
  31. package/dist/src/command-line/migrate/run/orchestrator.d.ts +21 -0
  32. package/dist/src/command-line/migrate/run/orchestrator.js +149 -32
  33. package/dist/src/command-line/migrate/run/run-state.d.ts +13 -0
  34. package/dist/src/command-line/migrate/run/run-state.js +21 -0
  35. package/dist/src/command-line/migrate/run/runbook.js +19 -0
  36. package/dist/src/command-line/migrate/run/state-machine.js +4 -1
  37. package/dist/src/command-line/migrate/run/util.d.ts +3 -0
  38. package/dist/src/command-line/migrate/run/util.js +7 -1
  39. package/dist/src/command-line/migrate/sort-migrations.d.ts +1 -7
  40. package/dist/src/command-line/migrate/sort-migrations.js +1 -12
  41. package/dist/src/command-line/show/show-target/info.js +1 -1
  42. package/dist/src/config/nx-json.d.ts +13 -4
  43. package/dist/src/config/task-graph.d.ts +1 -1
  44. package/dist/src/config/workspace-json-project-json.d.ts +72 -0
  45. package/dist/src/core/graph/main.js +1 -1
  46. package/dist/src/devkit-exports.d.ts +1 -1
  47. package/dist/src/hasher/check-task-files.js +4 -4
  48. package/dist/src/hasher/native-task-hasher-impl.js +3 -1
  49. package/dist/src/hasher/task-hasher.d.ts +2 -0
  50. package/dist/src/hasher/task-hasher.js +4 -1
  51. package/dist/src/native/index.d.ts +92 -14
  52. package/dist/src/native/native-bindings.js +3 -0
  53. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  54. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  55. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +6 -1
  56. package/dist/src/project-graph/utils/retrieve-workspace-files.js +27 -6
  57. package/dist/src/tasks-runner/create-task-graph.d.ts +7 -16
  58. package/dist/src/tasks-runner/create-task-graph.js +43 -57
  59. package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
  60. package/dist/src/tasks-runner/init-tasks-runner.js +13 -0
  61. package/dist/src/tasks-runner/life-cycle.d.ts +4 -1
  62. package/dist/src/tasks-runner/life-cycle.js +7 -0
  63. package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +5 -2
  64. package/dist/src/tasks-runner/life-cycles/performance-analysis.js +13 -7
  65. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.d.ts +4 -3
  66. package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +9 -2
  67. package/dist/src/tasks-runner/readiness/probes.d.ts +9 -0
  68. package/dist/src/tasks-runner/readiness/probes.js +62 -0
  69. package/dist/src/tasks-runner/readiness/ready-when.d.ts +38 -0
  70. package/dist/src/tasks-runner/readiness/ready-when.js +190 -0
  71. package/dist/src/tasks-runner/run-command.js +7 -6
  72. package/dist/src/tasks-runner/running-tasks/batch-process.js +6 -0
  73. package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -4
  74. package/dist/src/tasks-runner/task-graph-utils.d.ts +9 -6
  75. package/dist/src/tasks-runner/task-graph-utils.js +17 -12
  76. package/dist/src/tasks-runner/task-orchestrator.d.ts +37 -10
  77. package/dist/src/tasks-runner/task-orchestrator.js +459 -79
  78. package/dist/src/tasks-runner/tasks-runner.d.ts +1 -1
  79. package/dist/src/tasks-runner/tasks-schedule.d.ts +18 -1
  80. package/dist/src/tasks-runner/tasks-schedule.js +64 -6
  81. package/dist/src/tasks-runner/utils.js +6 -22
  82. package/dist/src/utils/child-process.js +1 -0
  83. package/dist/src/utils/git-utils.d.ts +6 -1
  84. package/dist/src/utils/git-utils.js +26 -5
  85. package/dist/src/utils/plugins/core-plugins.js +4 -0
  86. package/dist/src/utils/spawn-without-terminal.d.ts +27 -0
  87. package/dist/src/utils/spawn-without-terminal.js +110 -0
  88. package/package.json +12 -11
  89. package/schemas/nx-schema.json +93 -4
  90. package/schemas/project-schema.json +84 -2
@@ -20,6 +20,9 @@ const deferred_output_1 = require("./deferred-output");
20
20
  // ignore rule that normally hides it goes missing mid-run (a checkout, a
21
21
  // .gitignore edit, or the migration's own changes).
22
22
  const MIGRATE_COMMIT_EXCLUDES = [types_1.MIGRATE_RUNS_RELATIVE_DIR];
23
+ // Without it the agent continues as the absorb guidance says, and a cause that
24
+ // fails every commit leaves the whole run uncommitted.
25
+ const AGENT_SESSION_COMMIT_FAILURE = "Commits in this session cannot ask for input, such as a signing passphrase or a hook's prompt, so later commits may fail the same way until the cause is fixed. Before the next step, tell the user what failed and ask whether to fix the cause first or to continue as is. Either way nx tries every later commit, and the first one that lands includes these changes.";
23
26
  /**
24
27
  * `pendingMigrations` are listed in the commit body so a `git log -p` reader
25
28
  * can see which earlier migrations' diffs this commit absorbed (their own
@@ -28,10 +31,14 @@ const MIGRATE_COMMIT_EXCLUDES = [types_1.MIGRATE_RUNS_RELATIVE_DIR];
28
31
  * The default `failureGuidance` describes the classic loop's absorb-and-recap
29
32
  * behavior; a caller with no later commit or recap to absorb the diff (the
30
33
  * standalone single-migration worker) passes its own.
34
+ *
35
+ * A `sink` collects the output for a caller sharing the terminal with an
36
+ * agent, and the commit then runs without the terminal.
31
37
  */
32
- async function commitMigrationIfRequested(root, migration, shouldCreateCommits, commitPrefix, installDepsIfChanged, pendingMigrations = [], failureGuidance = 'Any uncommitted changes will be included in the next successful commit, which will reference this migration; if they remain uncommitted, the end-of-run output will list this migration so you can commit or revert them manually.', out = deferred_output_1.terminalOutput) {
38
+ async function commitMigrationIfRequested(root, migration, shouldCreateCommits, commitPrefix, installDepsIfChanged, pendingMigrations = [], failureGuidance = 'Any uncommitted changes will be included in the next successful commit, which will reference this migration; if they remain uncommitted, the end-of-run output will list this migration so you can commit or revert them manually.', sink) {
33
39
  if (!shouldCreateCommits)
34
40
  return { status: 'disabled' };
41
+ const out = sink ?? deferred_output_1.terminalOutput;
35
42
  await installDepsIfChanged();
36
43
  // Generator may have only touched gitignored paths or the excluded scratch
37
44
  // dir, or the prompt half made no change: log neutrally, not as an error.
@@ -42,7 +49,7 @@ async function commitMigrationIfRequested(root, migration, shouldCreateCommits,
42
49
  }
43
50
  const commitMessage = buildCommitMessage(`${commitPrefix}${migration.name}`, pendingMigrations);
44
51
  try {
45
- const sha = await (0, git_utils_1.tryCommitChangesAsync)(commitMessage, root, MIGRATE_COMMIT_EXCLUDES);
52
+ const sha = await (0, git_utils_1.tryCommitChangesAsync)(commitMessage, root, MIGRATE_COMMIT_EXCLUDES, { withoutTerminal: sink !== undefined });
46
53
  if (sha)
47
54
  return { status: 'committed', sha };
48
55
  // null = commit landed but `git rev-parse HEAD` failed (see
@@ -52,7 +59,7 @@ async function commitMigrationIfRequested(root, migration, shouldCreateCommits,
52
59
  }
53
60
  catch (err) {
54
61
  const reason = err instanceof Error ? err.message : String(err);
55
- out.line('red', `The commit for ${migration.name} failed:\n${reason}\nCheck \`git status\` and \`git log\`; the commit may have landed despite this error. ${failureGuidance}`);
62
+ out.line('red', `The commit for ${migration.name} failed:\n${reason}\nCheck \`git status\` and \`git log\`; the commit may have landed despite this error. ${failureGuidance}${sink ? ` ${AGENT_SESSION_COMMIT_FAILURE}` : ''}`);
56
63
  return { status: 'failed', reason };
57
64
  }
58
65
  }
@@ -9,12 +9,12 @@ import { type MigrateArgs } from './command-object';
9
9
  * config value never trips the mutually-exclusive-flag guards in
10
10
  * `parseMigrationsOptions`: `include` and `multiMajorMode` in the generate
11
11
  * phase only; `createCommits` / `commitPrefix` and `agentic` / `validate` when
12
- * running the whole migrations file or a standalone single migration. A
13
- * `--run-id` reconcile or recorded worker takes none of them: a recorded run
14
- * takes its commit config from run.json and is driven by the outer agent. A
15
- * `--run-migrations --run-id` continue takes `agentic` only, to select the
16
- * agent of the new session. A `--start-fresh` starts a new run and takes all
17
- * four.
12
+ * running the whole migrations file or a standalone single migration, and
13
+ * `finalValidation` for the whole file only. A `--run-id` reconcile or
14
+ * recorded worker takes none of them: a recorded run takes its commit config
15
+ * from run.json and is driven by the outer agent. A `--run-migrations
16
+ * --run-id` continue takes `agentic` only, to select the agent of the new
17
+ * session. A `--start-fresh` starts a new run and takes all five.
18
18
  *
19
19
  * `include` is carried as `includeFromConfig` so it is never mistaken for an
20
20
  * explicit `--include`: `resolveInclude` applies it only when the resolved
@@ -14,12 +14,12 @@ const MULTI_MAJOR_MODE_ENV = 'NX_MULTI_MAJOR_MODE';
14
14
  * config value never trips the mutually-exclusive-flag guards in
15
15
  * `parseMigrationsOptions`: `include` and `multiMajorMode` in the generate
16
16
  * phase only; `createCommits` / `commitPrefix` and `agentic` / `validate` when
17
- * running the whole migrations file or a standalone single migration. A
18
- * `--run-id` reconcile or recorded worker takes none of them: a recorded run
19
- * takes its commit config from run.json and is driven by the outer agent. A
20
- * `--run-migrations --run-id` continue takes `agentic` only, to select the
21
- * agent of the new session. A `--start-fresh` starts a new run and takes all
22
- * four.
17
+ * running the whole migrations file or a standalone single migration, and
18
+ * `finalValidation` for the whole file only. A `--run-id` reconcile or
19
+ * recorded worker takes none of them: a recorded run takes its commit config
20
+ * from run.json and is driven by the outer agent. A `--run-migrations
21
+ * --run-id` continue takes `agentic` only, to select the agent of the new
22
+ * session. A `--start-fresh` starts a new run and takes all five.
23
23
  *
24
24
  * `include` is carried as `includeFromConfig` so it is never mistaken for an
25
25
  * explicit `--include`: `resolveInclude` applies it only when the resolved
@@ -60,6 +60,12 @@ function applyNxJsonMigrateDefaults(args, migrateConfig, env = process.env) {
60
60
  assertType(migrateConfig.validate, 'boolean', 'validate');
61
61
  merged.validate = migrateConfig.validate;
62
62
  }
63
+ if (isRunMigrations &&
64
+ merged.finalValidation === undefined &&
65
+ migrateConfig.finalValidation !== undefined) {
66
+ assertType(migrateConfig.finalValidation, 'boolean', 'finalValidation');
67
+ merged.finalValidation = migrateConfig.finalValidation;
68
+ }
63
69
  }
64
70
  // A continue takes `agentic` too; the reconcile and the worker must not:
65
71
  // there it trips the `--agentic`/`--run-id` parse conflict.
@@ -196,7 +196,9 @@ export { filterDowngradedUpdates };
196
196
  export declare function generateMigrationsJsonAndUpdatePackageJson(root: string, opts: GenerateMigrations, fetch?: MigratorOptions['fetch']): Promise<void>;
197
197
  export { isPromptOnlyMigration, isHybridMigration };
198
198
  export declare function formatSkippedPromptsNextStep(skipped: PlannedMigration[]): string;
199
- export declare function executeMigrations(root: string, migrations: PlannedMigration[], isVerbose: boolean, shouldCreateCommits: boolean, commitPrefix: string, shouldSkipInstall?: boolean, agentic?: ResolvedAgentic, agenticHasDiffContext?: boolean, shouldRunValidation?: boolean): Promise<{
199
+ export declare function executeMigrations(root: string, migrations: PlannedMigration[], isVerbose: boolean, shouldCreateCommits: boolean, commitPrefix: string, shouldSkipInstall?: boolean, agentic?: Exclude<ResolvedAgentic, {
200
+ kind: 'enabled';
201
+ }>): Promise<{
200
202
  migrationsWithNoChanges: PlannedMigration[];
201
203
  skippedPromptsCount: number;
202
204
  notRunMigrationsCount: number;
@@ -213,33 +215,4 @@ export declare function migrate(root: string, args: {
213
215
  }, rawArgs: string[]): Promise<number>;
214
216
  export declare function readLocalNxVersion(root: string): string | undefined;
215
217
  export declare function runMigration(): Promise<number>;
216
- /**
217
- * Resolves a migration's collection once and derives everything the run loop
218
- * needs from that single read: the implementation context (`collection` +
219
- * `collectionPath`, handed to `runNxOrAngularMigration`) and, for agentic runs,
220
- * the workspace-relative documentation path handed to the agent.
221
- *
222
- * Read fresh per migration (not cached across the loop) so a prior migration's
223
- * reinstall is reflected, exactly as before. Error handling matches each field's
224
- * role:
225
- * - Migrations that run an implementation REQUIRE the collection; an unreadable
226
- * collection throws and aborts that migration (caught by the run loop).
227
- * - Prompt-only migrations don't run an implementation, so the collection is
228
- * read only to resolve documentation - a failure there is non-fatal: the
229
- * prompt still runs and the supplementary doc is skipped with a warning.
230
- */
231
- export declare function resolveMigrationForRun(root: string, migration: {
232
- package: string;
233
- name: string;
234
- documentation?: string;
235
- implementation?: string;
236
- factory?: string;
237
- prompt?: string;
238
- }, resolveDocumentation: boolean): {
239
- resolvedCollection?: {
240
- collection: MigrationsJson;
241
- collectionPath: string;
242
- };
243
- documentationPath?: string;
244
- };
245
218
  export declare function nxCliPath(nxWorkspaceRoot?: string): Promise<string>;