nx 21.0.0-rc.0 → 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 +11 -11
- package/src/executors/run-commands/running-tasks.d.ts +2 -2
- package/src/native/index.d.ts +1 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -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/pseudo-terminal.d.ts +2 -2
- package/src/tasks-runner/pseudo-terminal.js +7 -7
- package/src/tasks-runner/running-tasks/batch-process.d.ts +1 -1
- package/src/tasks-runner/running-tasks/node-child-process.d.ts +2 -2
- package/src/tasks-runner/running-tasks/running-task.d.ts +1 -1
- package/src/tasks-runner/task-orchestrator.d.ts +7 -9
- package/src/tasks-runner/task-orchestrator.js +13 -5
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "21.0.0-rc.
|
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-rc.
|
87
|
-
"@nx/nx-darwin-x64": "21.0.0-rc.
|
88
|
-
"@nx/nx-freebsd-x64": "21.0.0-rc.
|
89
|
-
"@nx/nx-linux-arm-gnueabihf": "21.0.0-rc.
|
90
|
-
"@nx/nx-linux-arm64-gnu": "21.0.0-rc.
|
91
|
-
"@nx/nx-linux-arm64-musl": "21.0.0-rc.
|
92
|
-
"@nx/nx-linux-x64-gnu": "21.0.0-rc.
|
93
|
-
"@nx/nx-linux-x64-musl": "21.0.0-rc.
|
94
|
-
"@nx/nx-win32-arm64-msvc": "21.0.0-rc.
|
95
|
-
"@nx/nx-win32-x64-msvc": "21.0.0-rc.
|
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",
|
@@ -17,7 +17,7 @@ export declare class ParallelRunningTasks implements RunningTask {
|
|
17
17
|
onOutput(cb: (terminalOutput: string) => void): void;
|
18
18
|
onExit(cb: (code: number, terminalOutput: string) => void): void;
|
19
19
|
send(message: Serializable): void;
|
20
|
-
kill(signal?: NodeJS.Signals
|
20
|
+
kill(signal?: NodeJS.Signals): Promise<void>;
|
21
21
|
private run;
|
22
22
|
}
|
23
23
|
export declare class SeriallyRunningTasks implements RunningTask {
|
@@ -36,7 +36,7 @@ export declare class SeriallyRunningTasks implements RunningTask {
|
|
36
36
|
onExit(cb: (code: number, terminalOutput: string) => void): void;
|
37
37
|
onOutput(cb: (terminalOutput: string) => void): void;
|
38
38
|
send(message: Serializable): void;
|
39
|
-
kill(signal?: NodeJS.Signals
|
39
|
+
kill(signal?: NodeJS.Signals): void | Promise<void>;
|
40
40
|
private run;
|
41
41
|
private createProcess;
|
42
42
|
}
|
package/src/native/index.d.ts
CHANGED
@@ -26,7 +26,7 @@ export declare class AppLifeCycle {
|
|
26
26
|
|
27
27
|
export declare class ChildProcess {
|
28
28
|
getParserAndWriter(): ExternalObject<[ParserArc, WriterArc]>
|
29
|
-
kill(): void
|
29
|
+
kill(signal?: NodeJS.Signals): void
|
30
30
|
onExit(callback: (message: string) => void): void
|
31
31
|
onOutput(callback: (message: string) => void): void
|
32
32
|
cleanup(): void
|
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.
|
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);
|
@@ -12,7 +12,7 @@ export declare class PseudoTerminal {
|
|
12
12
|
static isSupported(): boolean;
|
13
13
|
constructor(rustPseudoTerminal: RustPseudoTerminal);
|
14
14
|
init(): Promise<void>;
|
15
|
-
shutdown(): void;
|
15
|
+
shutdown(s?: NodeJS.Signals): void;
|
16
16
|
runCommand(command: string, { cwd, execArgv, jsEnv, quiet, tty, }?: {
|
17
17
|
cwd?: string;
|
18
18
|
execArgv?: string[];
|
@@ -44,7 +44,7 @@ export declare class PseudoTtyProcess implements RunningTask {
|
|
44
44
|
}>;
|
45
45
|
onExit(callback: (code: number) => void): void;
|
46
46
|
onOutput(callback: (message: string) => void): void;
|
47
|
-
kill(): void;
|
47
|
+
kill(s?: NodeJS.Signals): void;
|
48
48
|
getParserAndWriter(): import("../native").ExternalObject<[ParserArc, WriterArc]>;
|
49
49
|
}
|
50
50
|
export declare class PseudoTtyProcessWithSend extends PseudoTtyProcess {
|
@@ -9,13 +9,13 @@ const pseudo_ipc_1 = require("./pseudo-ipc");
|
|
9
9
|
// Register single event listeners for all pseudo-terminal instances
|
10
10
|
const pseudoTerminalShutdownCallbacks = [];
|
11
11
|
process.on('SIGINT', () => {
|
12
|
-
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
12
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb('SIGINT'));
|
13
13
|
});
|
14
14
|
process.on('SIGTERM', () => {
|
15
|
-
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
15
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb('SIGTERM'));
|
16
16
|
});
|
17
17
|
process.on('SIGHUP', () => {
|
18
|
-
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
18
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb('SIGHUP'));
|
19
19
|
});
|
20
20
|
process.on('exit', () => {
|
21
21
|
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
@@ -47,10 +47,10 @@ class PseudoTerminal {
|
|
47
47
|
await this.pseudoIPC.init();
|
48
48
|
this.initialized = true;
|
49
49
|
}
|
50
|
-
shutdown() {
|
50
|
+
shutdown(s) {
|
51
51
|
for (const cp of this.childProcesses) {
|
52
52
|
try {
|
53
|
-
cp.kill();
|
53
|
+
cp.kill(s);
|
54
54
|
}
|
55
55
|
catch { }
|
56
56
|
}
|
@@ -112,10 +112,10 @@ class PseudoTtyProcess {
|
|
112
112
|
onOutput(callback) {
|
113
113
|
this.outputCallbacks.push(callback);
|
114
114
|
}
|
115
|
-
kill() {
|
115
|
+
kill(s) {
|
116
116
|
if (this.isAlive) {
|
117
117
|
try {
|
118
|
-
this.childProcess.kill();
|
118
|
+
this.childProcess.kill(s);
|
119
119
|
}
|
120
120
|
catch {
|
121
121
|
// when the child process completes before we explicitly call kill, this will throw
|
@@ -15,7 +15,7 @@ export declare class NodeChildProcessWithNonDirectOutput implements RunningTask
|
|
15
15
|
terminalOutput: string;
|
16
16
|
}>;
|
17
17
|
send(message: Serializable): void;
|
18
|
-
kill(signal?: NodeJS.Signals
|
18
|
+
kill(signal?: NodeJS.Signals): void;
|
19
19
|
}
|
20
20
|
export declare class NodeChildProcessWithDirectOutput implements RunningTask {
|
21
21
|
private childProcess;
|
@@ -33,5 +33,5 @@ export declare class NodeChildProcessWithDirectOutput implements RunningTask {
|
|
33
33
|
}>;
|
34
34
|
waitForExit(): Promise<void>;
|
35
35
|
getTerminalOutput(): string;
|
36
|
-
kill(signal?: NodeJS.Signals
|
36
|
+
kill(signal?: NodeJS.Signals): void;
|
37
37
|
}
|
@@ -5,7 +5,7 @@ export declare abstract class RunningTask {
|
|
5
5
|
terminalOutput: string;
|
6
6
|
}>;
|
7
7
|
abstract onExit(cb: (code: number) => void): void;
|
8
|
-
abstract kill(signal?: NodeJS.Signals
|
8
|
+
abstract kill(signal?: NodeJS.Signals): Promise<void> | void;
|
9
9
|
abstract onOutput?(cb: (output: string) => void): void;
|
10
10
|
abstract send?(message: Serializable): void;
|
11
11
|
}
|
@@ -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
|
}
|