nx 21.0.0-canary.20250502-110614d → 21.0.0-rc.1

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",
3
- "version": "21.0.0-canary.20250502-110614d",
3
+ "version": "21.0.0-rc.1",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -83,16 +83,16 @@
83
83
  }
84
84
  },
85
85
  "optionalDependencies": {
86
- "@nx/nx-darwin-arm64": "21.0.0-canary.20250502-110614d",
87
- "@nx/nx-darwin-x64": "21.0.0-canary.20250502-110614d",
88
- "@nx/nx-freebsd-x64": "21.0.0-canary.20250502-110614d",
89
- "@nx/nx-linux-arm-gnueabihf": "21.0.0-canary.20250502-110614d",
90
- "@nx/nx-linux-arm64-gnu": "21.0.0-canary.20250502-110614d",
91
- "@nx/nx-linux-arm64-musl": "21.0.0-canary.20250502-110614d",
92
- "@nx/nx-linux-x64-gnu": "21.0.0-canary.20250502-110614d",
93
- "@nx/nx-linux-x64-musl": "21.0.0-canary.20250502-110614d",
94
- "@nx/nx-win32-arm64-msvc": "21.0.0-canary.20250502-110614d",
95
- "@nx/nx-win32-x64-msvc": "21.0.0-canary.20250502-110614d"
86
+ "@nx/nx-darwin-arm64": "21.0.0-rc.1",
87
+ "@nx/nx-darwin-x64": "21.0.0-rc.1",
88
+ "@nx/nx-freebsd-x64": "21.0.0-rc.1",
89
+ "@nx/nx-linux-arm-gnueabihf": "21.0.0-rc.1",
90
+ "@nx/nx-linux-arm64-gnu": "21.0.0-rc.1",
91
+ "@nx/nx-linux-arm64-musl": "21.0.0-rc.1",
92
+ "@nx/nx-linux-x64-gnu": "21.0.0-rc.1",
93
+ "@nx/nx-linux-x64-musl": "21.0.0-rc.1",
94
+ "@nx/nx-win32-arm64-msvc": "21.0.0-rc.1",
95
+ "@nx/nx-win32-x64-msvc": "21.0.0-rc.1"
96
96
  },
97
97
  "nx-migrations": {
98
98
  "migrations": "./migrations.json",
Binary file
@@ -18,10 +18,5 @@ export declare function initTasksRunner(nxArgs: NxArgs): Promise<{
18
18
  taskResults: Record<string, TaskResult>;
19
19
  }>;
20
20
  }>;
21
- export declare function runDiscreteTasks(tasks: Task[], projectGraph: ProjectGraph, taskGraphForHashing: TaskGraph, nxJson: NxJsonConfiguration, lifeCycle: LifeCycle): Promise<Promise<{
22
- task: Task;
23
- code: number;
24
- status: import("./tasks-runner").TaskStatus;
25
- terminalOutput?: string;
26
- }>[]>;
21
+ export declare function runDiscreteTasks(tasks: Task[], projectGraph: ProjectGraph, taskGraphForHashing: TaskGraph, nxJson: NxJsonConfiguration, lifeCycle: LifeCycle): Promise<Array<Promise<TaskResult[]>>>;
27
22
  export declare function runContinuousTasks(tasks: Task[], projectGraph: ProjectGraph, taskGraphForHashing: TaskGraph, nxJson: NxJsonConfiguration, lifeCycle: LifeCycle): Promise<Record<string, Promise<RunningTask>>>;
@@ -107,12 +107,32 @@ async function createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJs
107
107
  (0, run_command_1.setEnvVarsBasedOnArgs)(nxArgs, true);
108
108
  const orchestrator = new task_orchestrator_1.TaskOrchestrator(hasher, null, [], projectGraph, taskGraph, nxJson, nxArgs, false, client_1.daemonClient, undefined, taskGraphForHashing);
109
109
  await orchestrator.init();
110
- orchestrator.processTasks(tasks.map((task) => task.id));
110
+ orchestrator.processAllScheduledTasks();
111
111
  return orchestrator;
112
112
  }
113
113
  async function runDiscreteTasks(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
114
114
  const orchestrator = await createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle);
115
- return tasks.map((task, index) => orchestrator.applyFromCacheOrRunTask(true, task, index));
115
+ let groupId = 0;
116
+ let nextBatch = orchestrator.nextBatch();
117
+ let batchResults = [];
118
+ /**
119
+ * Set of task ids that were part of batches
120
+ */
121
+ const batchTasks = new Set();
122
+ while (nextBatch) {
123
+ for (const task in nextBatch.taskGraph.tasks) {
124
+ batchTasks.add(task);
125
+ }
126
+ batchResults.push(orchestrator.applyFromCacheOrRunBatch(true, nextBatch, groupId++));
127
+ nextBatch = orchestrator.nextBatch();
128
+ }
129
+ const taskResults = tasks
130
+ // Filter out tasks which were not part of batches
131
+ .filter((task) => !batchTasks.has(task.id))
132
+ .map((task) => orchestrator
133
+ .applyFromCacheOrRunTask(true, task, groupId++)
134
+ .then((r) => [r]));
135
+ return [...batchResults, ...taskResults];
116
136
  }
117
137
  async function runContinuousTasks(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
118
138
  const orchestrator = await createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle);
@@ -5,8 +5,10 @@ import { DaemonClient } from '../daemon/client/client';
5
5
  import { TaskHasher } from '../hasher/task-hasher';
6
6
  import { NxArgs } from '../utils/command-line-utils';
7
7
  import { DefaultTasksRunnerOptions } from './default-tasks-runner';
8
+ import { TaskResult } from './life-cycle';
8
9
  import { RunningTask } from './running-tasks/running-task';
9
10
  import { TaskStatus } from './tasks-runner';
11
+ import { Batch } from './tasks-schedule';
10
12
  import { SharedRunningTask } from './running-tasks/shared-running-task';
11
13
  export declare class TaskOrchestrator {
12
14
  private readonly hasher;
@@ -41,21 +43,17 @@ export declare class TaskOrchestrator {
41
43
  run(): Promise<{
42
44
  [id: string]: TaskStatus;
43
45
  }>;
46
+ nextBatch(): Batch;
44
47
  private executeNextBatchOfTasksUsingTaskSchedule;
45
- processTasks(taskIds: string[]): void;
48
+ private processTasks;
46
49
  private processTask;
47
50
  private processScheduledBatch;
48
- private processAllScheduledTasks;
51
+ processAllScheduledTasks(): void;
49
52
  private applyCachedResults;
50
53
  private applyCachedResult;
51
- private applyFromCacheOrRunBatch;
54
+ applyFromCacheOrRunBatch(doNotSkipCache: boolean, batch: Batch, groupId: number): Promise<TaskResult[]>;
52
55
  private runBatch;
53
- applyFromCacheOrRunTask(doNotSkipCache: boolean, task: Task, groupId: number): Promise<{
54
- task: Task;
55
- code: number;
56
- status: TaskStatus;
57
- terminalOutput?: string;
58
- }>;
56
+ applyFromCacheOrRunTask(doNotSkipCache: boolean, task: Task, groupId: number): Promise<TaskResult>;
59
57
  private runTask;
60
58
  private runTaskInForkedProcess;
61
59
  startContinuousTask(task: Task, groupId: number): Promise<RunningTask | SharedRunningTask>;
@@ -60,14 +60,14 @@ class TaskOrchestrator {
60
60
  // Init the ForkedProcessTaskRunner, TasksSchedule, and Cache
61
61
  await Promise.all([
62
62
  this.forkedProcessTaskRunner.init(),
63
- this.tasksSchedule.init(),
63
+ this.tasksSchedule.init().then(() => {
64
+ return this.tasksSchedule.scheduleNextTasks();
65
+ }),
64
66
  'init' in this.cache ? this.cache.init() : null,
65
67
  ]);
66
68
  }
67
69
  async run() {
68
70
  await this.init();
69
- // initial scheduling
70
- await this.tasksSchedule.scheduleNextTasks();
71
71
  perf_hooks_1.performance.mark('task-execution:start');
72
72
  const threadCount = getThreadCount(this.options, this.taskGraph);
73
73
  const threads = [];
@@ -96,6 +96,9 @@ class TaskOrchestrator {
96
96
  await this.cleanup();
97
97
  return this.completedTasks;
98
98
  }
99
+ nextBatch() {
100
+ return this.tasksSchedule.nextBatch();
101
+ }
99
102
  async executeNextBatchOfTasksUsingTaskSchedule() {
100
103
  // completed all the tasks
101
104
  if (!this.tasksSchedule.hasTasks() || this.bailed) {
@@ -104,7 +107,7 @@ class TaskOrchestrator {
104
107
  const doNotSkipCache = this.options.skipNxCache === false ||
105
108
  this.options.skipNxCache === undefined;
106
109
  this.processAllScheduledTasks();
107
- const batch = this.tasksSchedule.nextBatch();
110
+ const batch = this.nextBatch();
108
111
  if (batch) {
109
112
  const groupId = this.closeGroup();
110
113
  await this.applyFromCacheOrRunBatch(doNotSkipCache, batch, groupId);
@@ -202,7 +205,9 @@ class TaskOrchestrator {
202
205
  // Wait for batch to be processed
203
206
  await this.processedBatches.get(batch);
204
207
  await this.preRunSteps(tasks, { groupId });
205
- let results = doNotSkipCache ? await this.applyCachedResults(tasks) : [];
208
+ let results = doNotSkipCache
209
+ ? await this.applyCachedResults(tasks)
210
+ : [];
206
211
  // Run tasks that were not cached
207
212
  if (results.length !== taskEntries.length) {
208
213
  const unrunTaskGraph = (0, utils_1.removeTasksFromTaskGraph)(batch.taskGraph, results.map(({ task }) => task.id));
@@ -225,6 +230,7 @@ class TaskOrchestrator {
225
230
  // Batch is done, mark it as completed
226
231
  const applyFromCacheOrRunBatchEnd = perf_hooks_1.performance.mark('TaskOrchestrator-apply-from-cache-or-run-batch:end');
227
232
  perf_hooks_1.performance.measure('TaskOrchestrator-apply-from-cache-or-run-batch', applyFromCacheOrRunBatchStart.name, applyFromCacheOrRunBatchEnd.name);
233
+ return results;
228
234
  }
229
235
  async runBatch(batch, env) {
230
236
  const runBatchStart = perf_hooks_1.performance.mark('TaskOrchestrator-run-batch:start');
@@ -234,6 +240,7 @@ class TaskOrchestrator {
234
240
  const batchResultEntries = Object.entries(results);
235
241
  return batchResultEntries.map(([taskId, result]) => ({
236
242
  ...result,
243
+ code: result.success ? 0 : 1,
237
244
  task: {
238
245
  ...this.taskGraph.tasks[taskId],
239
246
  startTime: result.startTime,
@@ -246,6 +253,7 @@ class TaskOrchestrator {
246
253
  catch (e) {
247
254
  return batch.taskGraph.roots.map((rootTaskId) => ({
248
255
  task: this.taskGraph.tasks[rootTaskId],
256
+ code: 1,
249
257
  status: 'failure',
250
258
  }));
251
259
  }