nx 21.0.0-canary.20250501-8f50358 → 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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/bin/nx.js +6 -0
  3. package/package.json +14 -11
  4. package/src/command-line/format/command-object.js +1 -1
  5. package/src/command-line/init/configure-plugins.js +9 -7
  6. package/src/command-line/nx-commands.d.ts +1 -1
  7. package/src/command-line/nx-commands.js +1 -1
  8. package/src/command-line/release/version/release-group-processor.js +21 -5
  9. package/src/command-line/release/version/test-utils.d.ts +1 -1
  10. package/src/command-line/release/version/test-utils.js +4 -4
  11. package/src/command-line/release/version/version-actions.d.ts +2 -2
  12. package/src/command-line/release/version/version-actions.js +12 -6
  13. package/src/command-line/report/report.js +1 -29
  14. package/src/command-line/reset/reset.js +17 -1
  15. package/src/command-line/yargs-utils/shared-options.d.ts +6 -4
  16. package/src/command-line/yargs-utils/shared-options.js +28 -16
  17. package/src/core/graph/main.js +1 -1
  18. package/src/daemon/server/watcher.js +0 -6
  19. package/src/executors/run-commands/running-tasks.d.ts +2 -2
  20. package/src/executors/run-commands/running-tasks.js +15 -5
  21. package/src/generators/utils/nx-json.d.ts +1 -2
  22. package/src/generators/utils/nx-json.js +6 -12
  23. package/src/native/index.d.ts +3 -3
  24. package/src/native/nx.wasm32-wasi.wasm +0 -0
  25. package/src/nx-cloud/update-manager.d.ts +1 -0
  26. package/src/nx-cloud/update-manager.js +1 -0
  27. package/src/nx-cloud/utilities/client.d.ts +1 -1
  28. package/src/nx-cloud/utilities/client.js +10 -3
  29. package/src/tasks-runner/fork.js +15 -0
  30. package/src/tasks-runner/forked-process-task-runner.js +1 -0
  31. package/src/tasks-runner/init-tasks-runner.d.ts +1 -6
  32. package/src/tasks-runner/init-tasks-runner.js +22 -2
  33. package/src/tasks-runner/is-tui-enabled.js +13 -7
  34. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +12 -16
  35. package/src/tasks-runner/pseudo-terminal.d.ts +4 -3
  36. package/src/tasks-runner/pseudo-terminal.js +9 -9
  37. package/src/tasks-runner/run-command.js +15 -9
  38. package/src/tasks-runner/running-tasks/batch-process.d.ts +1 -1
  39. package/src/tasks-runner/running-tasks/node-child-process.d.ts +2 -2
  40. package/src/tasks-runner/running-tasks/running-task.d.ts +1 -1
  41. package/src/tasks-runner/task-orchestrator.d.ts +7 -9
  42. package/src/tasks-runner/task-orchestrator.js +13 -5
  43. package/src/utils/ignore.d.ts +0 -6
  44. package/src/utils/ignore.js +0 -63
  45. package/src/utils/params.js +22 -16
@@ -5,16 +5,10 @@ exports.watchOutputFiles = watchOutputFiles;
5
5
  exports.convertChangeEventsToLogMessage = convertChangeEventsToLogMessage;
6
6
  const workspace_root_1 = require("../../utils/workspace-root");
7
7
  const path_1 = require("path");
8
- const socket_utils_1 = require("../socket-utils");
9
8
  const shutdown_utils_1 = require("./shutdown-utils");
10
9
  const path_2 = require("../../utils/path");
11
- const ignore_1 = require("../../utils/ignore");
12
10
  const cache_1 = require("../cache");
13
11
  const server_1 = require("./server");
14
- const ALWAYS_IGNORE = [
15
- ...(0, ignore_1.getAlwaysIgnore)(workspace_root_1.workspaceRoot),
16
- (0, socket_utils_1.getFullOsSocketPath)(),
17
- ];
18
12
  async function watchWorkspace(server, cb) {
19
13
  const { Watcher } = await Promise.resolve().then(() => require('../../native'));
20
14
  const watcher = new Watcher(workspace_root_1.workspaceRoot);
@@ -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 | number): Promise<void>;
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 | number): void | Promise<void>;
39
+ kill(signal?: NodeJS.Signals): void | Promise<void>;
40
40
  private run;
41
41
  private createProcess;
42
42
  }
@@ -231,14 +231,24 @@ class RunningNodeProcess {
231
231
  }
232
232
  kill(signal) {
233
233
  return new Promise((res, rej) => {
234
- treeKill(this.childProcess.pid, signal, (err) => {
235
- if (err) {
236
- rej(err);
234
+ if (process.platform === 'win32' || process.platform === 'darwin') {
235
+ if (this.childProcess.kill(signal)) {
236
+ res();
237
237
  }
238
238
  else {
239
- res();
239
+ rej('Unable to kill process');
240
240
  }
241
- });
241
+ }
242
+ else {
243
+ treeKill(this.childProcess.pid, signal, (err) => {
244
+ if (err) {
245
+ rej(err);
246
+ }
247
+ else {
248
+ res();
249
+ }
250
+ });
251
+ }
242
252
  });
243
253
  }
244
254
  triggerOutputListeners(output) {
@@ -1,9 +1,8 @@
1
1
  import type { NxJsonConfiguration } from '../../config/nx-json';
2
2
  import type { Tree } from '../tree';
3
3
  /**
4
- * @deprecated You must pass a {@link Tree}. This will be removed in Nx 21.
4
+ * Reads nx.json
5
5
  */
6
- export declare function readNxJson(): NxJsonConfiguration | null;
7
6
  export declare function readNxJson(tree: Tree): NxJsonConfiguration | null;
8
7
  /**
9
8
  * Update nx.json
@@ -4,24 +4,18 @@ exports.readNxJson = readNxJson;
4
4
  exports.updateNxJson = updateNxJson;
5
5
  const path_1 = require("path");
6
6
  const json_1 = require("./json");
7
- const nx_json_1 = require("../../config/nx-json");
8
7
  /**
9
8
  * Reads nx.json
10
9
  */
11
10
  function readNxJson(tree) {
12
- if (tree) {
13
- if (!tree.exists('nx.json')) {
14
- return null;
15
- }
16
- let nxJson = (0, json_1.readJson)(tree, 'nx.json');
17
- if (nxJson.extends) {
18
- nxJson = { ...readNxJsonExtends(tree, nxJson.extends), ...nxJson };
19
- }
20
- return nxJson;
11
+ if (!tree.exists('nx.json')) {
12
+ return null;
21
13
  }
22
- else {
23
- return (0, nx_json_1.readNxJson)();
14
+ let nxJson = (0, json_1.readJson)(tree, 'nx.json');
15
+ if (nxJson.extends) {
16
+ nxJson = { ...readNxJsonExtends(tree, nxJson.extends), ...nxJson };
24
17
  }
18
+ return nxJson;
25
19
  }
26
20
  /**
27
21
  * Update nx.json
@@ -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
@@ -89,12 +89,12 @@ export declare class RunningTasksService {
89
89
 
90
90
  export declare class RustPseudoTerminal {
91
91
  constructor()
92
- runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, execArgv?: Array<string> | undefined | null, quiet?: boolean | undefined | null, tty?: boolean | undefined | null): ChildProcess
92
+ runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, execArgv?: Array<string> | undefined | null, quiet?: boolean | undefined | null, tty?: boolean | undefined | null, commandLabel?: string | undefined | null): ChildProcess
93
93
  /**
94
94
  * This allows us to run a pseudoterminal with a fake node ipc channel
95
95
  * this makes it possible to be backwards compatible with the old implementation
96
96
  */
97
- fork(id: string, forkScript: string, pseudoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record<string, string> | undefined | null, execArgv: Array<string> | undefined | null, quiet: boolean): ChildProcess
97
+ fork(id: string, forkScript: string, pseudoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record<string, string> | undefined | null, execArgv: Array<string> | undefined | null, quiet: boolean, commandLabel?: string | undefined | null): ChildProcess
98
98
  }
99
99
 
100
100
  export declare class TaskDetails {
Binary file
@@ -17,3 +17,4 @@ export declare function verifyOrUpdateNxCloudClient(options: CloudTaskRunnerOpti
17
17
  nxCloudClient: NxCloudClient;
18
18
  version: string;
19
19
  } | null>;
20
+ export declare function getBundleInstallDefaultLocation(): string;
@@ -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(() => process.exit(0))
23
+ .then(() => {
24
+ if (exit) {
25
+ process.exit(0);
26
+ }
27
+ })
24
28
  .catch((e) => {
25
29
  console.error(e);
26
- process.exit(1);
30
+ if (exit) {
31
+ process.exit(1);
32
+ }
33
+ throw e;
27
34
  });
28
35
  }
29
36
  else {
@@ -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
+ });
@@ -122,6 +122,7 @@ class ForkedProcessTaskRunner {
122
122
  execArgv: process.execArgv,
123
123
  jsEnv: env,
124
124
  quiet: !streamOutput,
125
+ commandLabel: `nx run ${task.id}`,
125
126
  });
126
127
  p.send({
127
128
  targetDescription: task.target,
@@ -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);
@@ -28,14 +28,23 @@ function shouldUseTui(nxJson, nxArgs, skipCapabilityCheck = process.env.NX_TUI_S
28
28
  if (!isCapable) {
29
29
  return false;
30
30
  }
31
- // The environment variable takes precedence over the nx.json config
32
- if (typeof process.env.NX_TUI === 'string') {
33
- return process.env.NX_TUI === 'true';
34
- }
35
31
  if (['static', 'stream', 'dynamic-legacy'].includes(nxArgs.outputStyle)) {
36
32
  // If the user has specified a non-TUI output style, we disable the TUI
37
33
  return false;
38
34
  }
35
+ if (nxArgs.outputStyle === 'dynamic' || nxArgs.outputStyle === 'tui') {
36
+ return true;
37
+ }
38
+ // The environment variable takes precedence over the nx.json config, but
39
+ // are lower priority than the CLI args as they are less likely to change
40
+ // between runs, whereas the CLI args are specified by the user for each run.
41
+ if (typeof process.env.NX_TUI === 'string') {
42
+ return process.env.NX_TUI === 'true';
43
+ }
44
+ // BELOW THIS LINE ARE "repo specific" checks, instead of "user specific" checks.
45
+ // "user specific" checks are specified by the current user rather than the repo
46
+ // settings which are applied for all users of the repo... so they are more specific
47
+ // and take priority.
39
48
  if (
40
49
  // Interactive TUI doesn't make sense on CI
41
50
  (0, is_ci_1.isCI)() ||
@@ -46,9 +55,6 @@ function shouldUseTui(nxJson, nxArgs, skipCapabilityCheck = process.env.NX_TUI_S
46
55
  native_1.IS_WASM) {
47
56
  return false;
48
57
  }
49
- if (nxArgs.outputStyle === 'dynamic' || nxArgs.outputStyle === 'tui') {
50
- return true;
51
- }
52
58
  // Respect user config
53
59
  if (typeof nxJson.tui?.enabled === 'boolean') {
54
60
  return Boolean(nxJson.tui?.enabled);
@@ -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 (totalCompletedTasks + stoppedTasks.size === totalTasks) {
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
- output_1.output.applyNxPrefix('red', output_1.output.colors.red(text) + output_1.output.dim(` (${timeTakenText})`)),
128
- ...taskOverridesLines,
129
- '',
130
- `${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
131
- `${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`,
132
- ...viewLogs,
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 {
@@ -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[];
@@ -20,11 +20,12 @@ export declare class PseudoTerminal {
20
20
  quiet?: boolean;
21
21
  tty?: boolean;
22
22
  }): PseudoTtyProcess;
23
- fork(id: string, script: string, { cwd, execArgv, jsEnv, quiet, }: {
23
+ fork(id: string, script: string, { cwd, execArgv, jsEnv, quiet, commandLabel, }: {
24
24
  cwd?: string;
25
25
  execArgv?: string[];
26
26
  jsEnv?: Record<string, string>;
27
27
  quiet?: boolean;
28
+ commandLabel?: string;
28
29
  }): Promise<PseudoTtyProcessWithSend>;
29
30
  sendMessageToChildren(message: Serializable): void;
30
31
  onMessageFromChildren(callback: (message: Serializable) => void): void;
@@ -43,7 +44,7 @@ export declare class PseudoTtyProcess implements RunningTask {
43
44
  }>;
44
45
  onExit(callback: (code: number) => void): void;
45
46
  onOutput(callback: (message: string) => void): void;
46
- kill(): void;
47
+ kill(s?: NodeJS.Signals): void;
47
48
  getParserAndWriter(): import("../native").ExternalObject<[ParserArc, WriterArc]>;
48
49
  }
49
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
  }
@@ -63,11 +63,11 @@ class PseudoTerminal {
63
63
  this.childProcesses.add(cp);
64
64
  return cp;
65
65
  }
66
- async fork(id, script, { cwd, execArgv, jsEnv, quiet, }) {
66
+ async fork(id, script, { cwd, execArgv, jsEnv, quiet, commandLabel, }) {
67
67
  if (!this.initialized) {
68
68
  throw new Error('Call init() before forking processes');
69
69
  }
70
- const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal, this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, execArgv, quiet), id, this.pseudoIPC);
70
+ const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal, this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, execArgv, quiet, commandLabel), id, this.pseudoIPC);
71
71
  this.childProcesses.add(cp);
72
72
  await this.pseudoIPC.waitForChildReady(id);
73
73
  return cp;
@@ -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
@@ -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
- renderIsDone = new Promise((resolve) => {
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: nxArgs.outputStyle === 'compact' ? null : initiatingProject,
584
+ initiatingProject,
579
585
  initiatingTasks,
580
586
  projectGraph,
581
587
  nxJson,
@@ -10,5 +10,5 @@ export declare class BatchProcess {
10
10
  onResults(cb: (results: BatchResults) => void): void;
11
11
  getResults(): Promise<BatchResults>;
12
12
  send(message: Serializable): void;
13
- kill(signal?: NodeJS.Signals | number): void;
13
+ kill(signal?: NodeJS.Signals): void;
14
14
  }
@@ -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 | number): void;
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 | number): void;
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 | number): Promise<void> | void;
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(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
  }