nx 21.0.0-canary.20250502-110614d → 21.0.0-canary.20250503-675e6ed
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/README.md +1 -1
- package/bin/nx.js +6 -0
- package/package.json +11 -11
- package/src/command-line/init/configure-plugins.js +9 -7
- package/src/command-line/release/version/release-group-processor.js +21 -5
- package/src/command-line/release/version/test-utils.d.ts +1 -1
- package/src/command-line/release/version/test-utils.js +4 -4
- package/src/command-line/release/version/version-actions.d.ts +2 -2
- package/src/command-line/release/version/version-actions.js +12 -6
- package/src/command-line/reset/reset.js +17 -1
- package/src/command-line/yargs-utils/shared-options.d.ts +6 -4
- package/src/command-line/yargs-utils/shared-options.js +1 -2
- package/src/core/graph/main.js +1 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/update-manager.d.ts +1 -0
- package/src/nx-cloud/update-manager.js +1 -0
- package/src/nx-cloud/utilities/client.d.ts +1 -1
- package/src/nx-cloud/utilities/client.js +10 -3
- package/src/tasks-runner/fork.js +15 -0
- package/src/tasks-runner/init-tasks-runner.d.ts +1 -6
- package/src/tasks-runner/init-tasks-runner.js +22 -2
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +12 -16
- package/src/tasks-runner/run-command.js +15 -9
- package/src/tasks-runner/task-orchestrator.d.ts +7 -9
- package/src/tasks-runner/task-orchestrator.js +13 -5
Binary file
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.NxCloudClientUnavailableError = exports.NxCloudEnterpriseOutdatedError = void 0;
|
4
4
|
exports.verifyOrUpdateNxCloudClient = verifyOrUpdateNxCloudClient;
|
5
|
+
exports.getBundleInstallDefaultLocation = getBundleInstallDefaultLocation;
|
5
6
|
const fs_1 = require("fs");
|
6
7
|
const zlib_1 = require("zlib");
|
7
8
|
const path_1 = require("path");
|
@@ -5,6 +5,6 @@ export declare class UnknownCommandError extends Error {
|
|
5
5
|
constructor(command: string, availableCommands: string[]);
|
6
6
|
}
|
7
7
|
export declare function getCloudClient(options: CloudTaskRunnerOptions): Promise<{
|
8
|
-
invoke: (command: string) => void;
|
8
|
+
invoke: (command: string, exit?: boolean) => void;
|
9
9
|
availableCommands: string[];
|
10
10
|
}>;
|
@@ -17,13 +17,20 @@ async function getCloudClient(options) {
|
|
17
17
|
const paths = (0, resolution_helpers_1.findAncestorNodeModules)(__dirname, []);
|
18
18
|
nxCloudClient.configureLightClientRequire()(paths);
|
19
19
|
return {
|
20
|
-
invoke: (command) => {
|
20
|
+
invoke: (command, exit = true) => {
|
21
21
|
if (command in nxCloudClient.commands) {
|
22
22
|
nxCloudClient.commands[command]()
|
23
|
-
.then(() =>
|
23
|
+
.then(() => {
|
24
|
+
if (exit) {
|
25
|
+
process.exit(0);
|
26
|
+
}
|
27
|
+
})
|
24
28
|
.catch((e) => {
|
25
29
|
console.error(e);
|
26
|
-
|
30
|
+
if (exit) {
|
31
|
+
process.exit(1);
|
32
|
+
}
|
33
|
+
throw e;
|
27
34
|
});
|
28
35
|
}
|
29
36
|
else {
|
package/src/tasks-runner/fork.js
CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const child_process_1 = require("child_process");
|
4
4
|
const path_1 = require("path");
|
5
5
|
const pseudo_ipc_1 = require("./pseudo-ipc");
|
6
|
+
const exit_codes_1 = require("../utils/exit-codes");
|
6
7
|
const pseudoIPCPath = process.argv[2];
|
7
8
|
const forkId = process.argv[3];
|
8
9
|
const script = (0, path_1.join)(__dirname, '../../bin/run-executor.js');
|
@@ -28,3 +29,17 @@ childProcess.on('exit', (code) => {
|
|
28
29
|
pseudoIPC.close();
|
29
30
|
process.exit(code);
|
30
31
|
});
|
32
|
+
// Terminate the child process when exiting
|
33
|
+
process.on('exit', () => {
|
34
|
+
childProcess.kill();
|
35
|
+
});
|
36
|
+
process.on('SIGINT', () => {
|
37
|
+
childProcess.kill('SIGTERM');
|
38
|
+
process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
|
39
|
+
});
|
40
|
+
process.on('SIGTERM', () => {
|
41
|
+
childProcess.kill('SIGTERM');
|
42
|
+
});
|
43
|
+
process.on('SIGHUP', () => {
|
44
|
+
childProcess.kill('SIGTERM');
|
45
|
+
});
|
@@ -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.
|
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
|
-
|
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);
|
@@ -108,7 +108,7 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, args, overrides,
|
|
108
108
|
}
|
109
109
|
lines = [output_1.output.colors.green(lines.join(node_os_1.EOL))];
|
110
110
|
}
|
111
|
-
else if (
|
111
|
+
else if (inProgressTasks.size === 0) {
|
112
112
|
let text = `Ran target ${output_1.output.bold(targets[0])} for project ${output_1.output.bold(initiatingProject)}`;
|
113
113
|
if (tasks.length > 1) {
|
114
114
|
text += ` and ${output_1.output.bold(tasks.length - 1)} task(s) they depend on`;
|
@@ -122,22 +122,17 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, args, overrides,
|
|
122
122
|
.forEach((arg) => taskOverridesLines.push(arg));
|
123
123
|
}
|
124
124
|
const viewLogs = (0, view_logs_utils_1.viewLogsFooterRows)(totalFailedTasks);
|
125
|
-
lines
|
126
|
-
output_1.output.colors.red(
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
].join(node_os_1.EOL)),
|
134
|
-
];
|
125
|
+
lines.push(output_1.output.colors.red([
|
126
|
+
output_1.output.applyNxPrefix('red', output_1.output.colors.red(text) + output_1.output.dim(` (${timeTakenText})`)),
|
127
|
+
...taskOverridesLines,
|
128
|
+
'',
|
129
|
+
`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
|
130
|
+
`${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`,
|
131
|
+
...viewLogs,
|
132
|
+
].join(node_os_1.EOL)));
|
135
133
|
}
|
136
134
|
else {
|
137
|
-
lines
|
138
|
-
...output_1.output.getVerticalSeparatorLines('red'),
|
139
|
-
output_1.output.applyNxPrefix('red', output_1.output.colors.red(`Cancelled running target ${output_1.output.bold(targets[0])} for project ${output_1.output.bold(initiatingProject)}`) + output_1.output.dim(` (${timeTakenText})`)),
|
140
|
-
];
|
135
|
+
lines.push(output_1.output.applyNxPrefix('red', output_1.output.colors.red(`Cancelled running target ${output_1.output.bold(targets[0])} for project ${output_1.output.bold(initiatingProject)}`) + output_1.output.dim(` (${timeTakenText})`)));
|
141
136
|
}
|
142
137
|
// adds some vertical space after the summary to avoid bunching against terminal
|
143
138
|
lines.push('');
|
@@ -145,12 +140,13 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, args, overrides,
|
|
145
140
|
};
|
146
141
|
const printRunManySummary = () => {
|
147
142
|
console.log('');
|
148
|
-
const lines = [];
|
143
|
+
const lines = [''];
|
149
144
|
const failure = totalSuccessfulTasks + stoppedTasks.size !== totalTasks;
|
150
145
|
for (const taskId of taskIdsInOrderOfCompletion) {
|
151
146
|
const { terminalOutput, taskStatus } = tasksToTerminalOutputs[taskId];
|
152
147
|
if (taskStatus === 'failure') {
|
153
148
|
output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
|
149
|
+
output_1.output.addNewline();
|
154
150
|
lines.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
|
155
151
|
}
|
156
152
|
else {
|
@@ -168,20 +168,14 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
|
|
168
168
|
// The cloud client calls console.log when NX_VERBOSE_LOGGING is set to true
|
169
169
|
console.log = createPatchedConsoleMethod(originalConsoleLog);
|
170
170
|
console.error = createPatchedConsoleMethod(originalConsoleError);
|
171
|
-
|
172
|
-
appLifeCycle.__init(() => {
|
173
|
-
resolve();
|
174
|
-
});
|
175
|
-
})
|
176
|
-
.then(() => {
|
171
|
+
globalThis.tuiOnProcessExit = () => {
|
177
172
|
restoreTerminal();
|
178
|
-
})
|
179
|
-
.finally(() => {
|
180
173
|
// Revert the patched methods
|
181
174
|
process.stdout.write = originalStdoutWrite;
|
182
175
|
process.stderr.write = originalStderrWrite;
|
183
176
|
console.log = originalConsoleLog;
|
184
177
|
console.error = originalConsoleError;
|
178
|
+
process.stdout.write('\n');
|
185
179
|
// Print the intercepted Nx Cloud logs
|
186
180
|
for (const log of interceptedNxCloudLogs) {
|
187
181
|
const logString = log.toString().trimStart();
|
@@ -190,6 +184,18 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
|
|
190
184
|
process.stdout.write('\n');
|
191
185
|
}
|
192
186
|
}
|
187
|
+
};
|
188
|
+
renderIsDone = new Promise((resolve) => {
|
189
|
+
appLifeCycle.__init(() => {
|
190
|
+
resolve();
|
191
|
+
});
|
192
|
+
}).finally(() => {
|
193
|
+
restoreTerminal();
|
194
|
+
// Revert the patched methods
|
195
|
+
process.stdout.write = originalStdoutWrite;
|
196
|
+
process.stderr.write = originalStderrWrite;
|
197
|
+
console.log = originalConsoleLog;
|
198
|
+
console.error = originalConsoleError;
|
193
199
|
});
|
194
200
|
}
|
195
201
|
return {
|
@@ -575,7 +581,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
|
|
575
581
|
...runnerOptions,
|
576
582
|
lifeCycle: compositedLifeCycle,
|
577
583
|
}, {
|
578
|
-
initiatingProject
|
584
|
+
initiatingProject,
|
579
585
|
initiatingTasks,
|
580
586
|
projectGraph,
|
581
587
|
nxJson,
|
@@ -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
|
48
|
+
private processTasks;
|
46
49
|
private processTask;
|
47
50
|
private processScheduledBatch;
|
48
|
-
|
51
|
+
processAllScheduledTasks(): void;
|
49
52
|
private applyCachedResults;
|
50
53
|
private applyCachedResult;
|
51
|
-
|
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.
|
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
|
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
|
}
|