nx 21.0.1 → 21.0.3
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/bin/nx.js +1 -20
- package/package.json +11 -11
- package/src/command-line/affected/command-object.js +1 -1
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/executors/run-script/run-script.impl.js +2 -1
- package/src/native/index.d.ts +1 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +1 -1
- package/src/tasks-runner/forked-process-task-runner.js +1 -1
- package/src/tasks-runner/life-cycle.d.ts +2 -2
- package/src/tasks-runner/life-cycle.js +2 -2
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +23 -9
- package/src/tasks-runner/pseudo-terminal.d.ts +1 -1
- package/src/tasks-runner/pseudo-terminal.js +5 -13
- package/src/tasks-runner/task-orchestrator.js +8 -2
- package/src/utils/exit-codes.d.ts +4 -0
- package/src/utils/exit-codes.js +16 -0
package/src/core/graph/styles.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[869],{
|
1
|
+
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[869],{4941:()=>{}},s=>{var e;e=4941,s(s.s=e)}]);
|
@@ -38,11 +38,12 @@ function nodeProcess(command, cwd, env) {
|
|
38
38
|
windowsHide: false,
|
39
39
|
});
|
40
40
|
}
|
41
|
+
let cp;
|
41
42
|
async function ptyProcess(command, cwd, env) {
|
42
43
|
const terminal = (0, pseudo_terminal_1.createPseudoTerminal)();
|
43
44
|
await terminal.init();
|
44
45
|
return new Promise((res, rej) => {
|
45
|
-
|
46
|
+
cp = terminal.runCommand(command, { cwd, jsEnv: env });
|
46
47
|
cp.onExit((code) => {
|
47
48
|
if (code === 0) {
|
48
49
|
res();
|
package/src/native/index.d.ts
CHANGED
@@ -18,7 +18,7 @@ export declare class AppLifeCycle {
|
|
18
18
|
__init(doneCallback: () => any): void
|
19
19
|
registerRunningTask(taskId: string, parserAndWriter: ExternalObject<[ParserArc, WriterArc]>): void
|
20
20
|
registerRunningTaskWithEmptyParser(taskId: string): void
|
21
|
-
appendTaskOutput(taskId: string, output: string): void
|
21
|
+
appendTaskOutput(taskId: string, output: string, isPtyOutput: boolean): void
|
22
22
|
setTaskStatus(taskId: string, status: TaskStatus): void
|
23
23
|
registerForcedShutdownCallback(forcedShutdownCallback: () => any): void
|
24
24
|
__setCloudMessage(message: string): Promise<void>
|
Binary file
|
@@ -273,7 +273,7 @@ class TargetProjectLocator {
|
|
273
273
|
return;
|
274
274
|
}
|
275
275
|
resolveImportWithRequire(normalizedImportExpr, filePath) {
|
276
|
-
return node_path_1.
|
276
|
+
return (0, node_path_1.relative)(workspace_root_1.workspaceRoot, require.resolve(normalizedImportExpr, {
|
277
277
|
paths: [(0, node_path_1.dirname)(filePath)],
|
278
278
|
}));
|
279
279
|
}
|
@@ -38,7 +38,7 @@ export interface LifeCycle {
|
|
38
38
|
printTaskTerminalOutput?(task: Task, status: TaskStatus, output: string): void;
|
39
39
|
registerRunningTask?(taskId: string, parserAndWriter: ExternalObject<[any, any]>): void;
|
40
40
|
registerRunningTaskWithEmptyParser?(taskId: string): void;
|
41
|
-
appendTaskOutput?(taskId: string, output: string): void;
|
41
|
+
appendTaskOutput?(taskId: string, output: string, isPtyTask: boolean): void;
|
42
42
|
setTaskStatus?(taskId: string, status: NativeTaskStatus): void;
|
43
43
|
registerForcedShutdownCallback?(callback: () => void): void;
|
44
44
|
}
|
@@ -55,7 +55,7 @@ export declare class CompositeLifeCycle implements LifeCycle {
|
|
55
55
|
printTaskTerminalOutput(task: Task, status: TaskStatus, output: string): void;
|
56
56
|
registerRunningTask(taskId: string, parserAndWriter: ExternalObject<[any, any]>): void;
|
57
57
|
registerRunningTaskWithEmptyParser(taskId: string): void;
|
58
|
-
appendTaskOutput(taskId: string, output: string): void;
|
58
|
+
appendTaskOutput(taskId: string, output: string, isPtyTask: boolean): void;
|
59
59
|
setTaskStatus(taskId: string, status: NativeTaskStatus): void;
|
60
60
|
registerForcedShutdownCallback(callback: () => void): void;
|
61
61
|
}
|
@@ -81,10 +81,10 @@ class CompositeLifeCycle {
|
|
81
81
|
}
|
82
82
|
}
|
83
83
|
}
|
84
|
-
appendTaskOutput(taskId, output) {
|
84
|
+
appendTaskOutput(taskId, output, isPtyTask) {
|
85
85
|
for (let l of this.lifeCycles) {
|
86
86
|
if (l.appendTaskOutput) {
|
87
|
-
l.appendTaskOutput(taskId, output);
|
87
|
+
l.appendTaskOutput(taskId, output, isPtyTask);
|
88
88
|
}
|
89
89
|
}
|
90
90
|
}
|
@@ -26,15 +26,21 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
|
|
26
26
|
const inProgressTasks = new Set();
|
27
27
|
const stoppedTasks = new Set();
|
28
28
|
const tasksToTerminalOutputs = {};
|
29
|
-
const
|
29
|
+
const tasksToTaskStatus = {};
|
30
|
+
const taskIdsInTheOrderTheyStart = [];
|
30
31
|
lifeCycle.startTasks = (tasks) => {
|
31
32
|
for (let t of tasks) {
|
33
|
+
tasksToTerminalOutputs[t.id] ??= '';
|
34
|
+
taskIdsInTheOrderTheyStart.push(t.id);
|
32
35
|
inProgressTasks.add(t.id);
|
33
36
|
}
|
34
37
|
};
|
35
|
-
lifeCycle.
|
36
|
-
|
37
|
-
|
38
|
+
lifeCycle.appendTaskOutput = (taskId, output) => {
|
39
|
+
tasksToTerminalOutputs[taskId] += output;
|
40
|
+
};
|
41
|
+
// TODO(@AgentEnder): The following 2 methods should be one but will need more refactoring
|
42
|
+
lifeCycle.printTaskTerminalOutput = (task, taskStatus) => {
|
43
|
+
tasksToTaskStatus[task.id] = taskStatus;
|
38
44
|
};
|
39
45
|
lifeCycle.setTaskStatus = (taskId, taskStatus) => {
|
40
46
|
if (taskStatus === 9 /* NativeTaskStatus.Stopped */) {
|
@@ -103,8 +109,9 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
|
|
103
109
|
let lines = [];
|
104
110
|
// Prints task outputs in the order they were completed
|
105
111
|
// above the summary, since run-one should print all task results.
|
106
|
-
for (const taskId of
|
107
|
-
const
|
112
|
+
for (const taskId of taskIdsInTheOrderTheyStart) {
|
113
|
+
const taskStatus = tasksToTaskStatus[taskId];
|
114
|
+
const terminalOutput = tasksToTerminalOutputs[taskId];
|
108
115
|
output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
|
109
116
|
}
|
110
117
|
lines.push(...output_1.output.getVerticalSeparatorLines(failure ? 'red' : 'green'));
|
@@ -157,9 +164,16 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
|
|
157
164
|
const printRunManySummary = ({ failure, cancelled, }) => {
|
158
165
|
console.log('');
|
159
166
|
const lines = [''];
|
160
|
-
for (const taskId of
|
161
|
-
const
|
162
|
-
|
167
|
+
for (const taskId of taskIdsInTheOrderTheyStart) {
|
168
|
+
const taskStatus = tasksToTaskStatus[taskId];
|
169
|
+
const terminalOutput = tasksToTerminalOutputs[taskId];
|
170
|
+
// Task Status is null?
|
171
|
+
if (!taskStatus) {
|
172
|
+
output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
|
173
|
+
output_1.output.addNewline();
|
174
|
+
lines.push(`${LEFT_PAD}${output_1.output.colors.cyan(figures.squareSmallFilled)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
|
175
|
+
}
|
176
|
+
else if (taskStatus === 'failure') {
|
163
177
|
output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
|
164
178
|
output_1.output.addNewline();
|
165
179
|
lines.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
|
@@ -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(
|
15
|
+
shutdown(code: number): void;
|
16
16
|
runCommand(command: string, { cwd, execArgv, jsEnv, quiet, tty, }?: {
|
17
17
|
cwd?: string;
|
18
18
|
execArgv?: string[];
|
@@ -6,19 +6,11 @@ const os = require("os");
|
|
6
6
|
const socket_utils_1 = require("../daemon/socket-utils");
|
7
7
|
const native_1 = require("../native");
|
8
8
|
const pseudo_ipc_1 = require("./pseudo-ipc");
|
9
|
+
const exit_codes_1 = require("../utils/exit-codes");
|
9
10
|
// Register single event listeners for all pseudo-terminal instances
|
10
11
|
const pseudoTerminalShutdownCallbacks = [];
|
11
|
-
process.on('
|
12
|
-
pseudoTerminalShutdownCallbacks.forEach((cb) => cb(
|
13
|
-
});
|
14
|
-
process.on('SIGTERM', () => {
|
15
|
-
pseudoTerminalShutdownCallbacks.forEach((cb) => cb('SIGTERM'));
|
16
|
-
});
|
17
|
-
process.on('SIGHUP', () => {
|
18
|
-
pseudoTerminalShutdownCallbacks.forEach((cb) => cb('SIGHUP'));
|
19
|
-
});
|
20
|
-
process.on('exit', () => {
|
21
|
-
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
12
|
+
process.on('exit', (code) => {
|
13
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb(code));
|
22
14
|
});
|
23
15
|
function createPseudoTerminal(skipSupportCheck = false) {
|
24
16
|
if (!skipSupportCheck && !PseudoTerminal.isSupported()) {
|
@@ -47,10 +39,10 @@ class PseudoTerminal {
|
|
47
39
|
await this.pseudoIPC.init();
|
48
40
|
this.initialized = true;
|
49
41
|
}
|
50
|
-
shutdown(
|
42
|
+
shutdown(code) {
|
51
43
|
for (const cp of this.childProcesses) {
|
52
44
|
try {
|
53
|
-
cp.kill(
|
45
|
+
cp.kill((0, exit_codes_1.codeToSignal)(code));
|
54
46
|
}
|
55
47
|
catch { }
|
56
48
|
}
|
@@ -333,11 +333,14 @@ class TaskOrchestrator {
|
|
333
333
|
if (runningTask instanceof pseudo_terminal_1.PseudoTtyProcess) {
|
334
334
|
// This is an external of a the pseudo terminal where a task is running and can be passed to the TUI
|
335
335
|
this.options.lifeCycle.registerRunningTask(task.id, runningTask.getParserAndWriter());
|
336
|
+
runningTask.onOutput((output) => {
|
337
|
+
this.options.lifeCycle.appendTaskOutput(task.id, output, true);
|
338
|
+
});
|
336
339
|
}
|
337
340
|
else {
|
338
341
|
this.options.lifeCycle.registerRunningTaskWithEmptyParser(task.id);
|
339
342
|
runningTask.onOutput((output) => {
|
340
|
-
this.options.lifeCycle.appendTaskOutput(task.id, output);
|
343
|
+
this.options.lifeCycle.appendTaskOutput(task.id, output, false);
|
341
344
|
});
|
342
345
|
}
|
343
346
|
}
|
@@ -391,11 +394,14 @@ class TaskOrchestrator {
|
|
391
394
|
if (runningTask instanceof pseudo_terminal_1.PseudoTtyProcess) {
|
392
395
|
// This is an external of a the pseudo terminal where a task is running and can be passed to the TUI
|
393
396
|
this.options.lifeCycle.registerRunningTask(task.id, runningTask.getParserAndWriter());
|
397
|
+
runningTask.onOutput((output) => {
|
398
|
+
this.options.lifeCycle.appendTaskOutput(task.id, output, true);
|
399
|
+
});
|
394
400
|
}
|
395
401
|
else if ('onOutput' in runningTask) {
|
396
402
|
this.options.lifeCycle.registerRunningTaskWithEmptyParser(task.id);
|
397
403
|
runningTask.onOutput((output) => {
|
398
|
-
this.options.lifeCycle.appendTaskOutput(task.id, output);
|
404
|
+
this.options.lifeCycle.appendTaskOutput(task.id, output, false);
|
399
405
|
});
|
400
406
|
}
|
401
407
|
}
|
package/src/utils/exit-codes.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.signalToCode = signalToCode;
|
4
|
+
exports.codeToSignal = codeToSignal;
|
4
5
|
/**
|
5
6
|
* Translates NodeJS signals to numeric exit code
|
6
7
|
* @param signal
|
@@ -17,3 +18,18 @@ function signalToCode(signal) {
|
|
17
18
|
return 128;
|
18
19
|
}
|
19
20
|
}
|
21
|
+
/**
|
22
|
+
* Translates numeric exit codes to NodeJS signals
|
23
|
+
*/
|
24
|
+
function codeToSignal(code) {
|
25
|
+
switch (code) {
|
26
|
+
case 128 + 1:
|
27
|
+
return 'SIGHUP';
|
28
|
+
case 128 + 2:
|
29
|
+
return 'SIGINT';
|
30
|
+
case 128 + 15:
|
31
|
+
return 'SIGTERM';
|
32
|
+
default:
|
33
|
+
return 'SIGTERM';
|
34
|
+
}
|
35
|
+
}
|