nx 24.0.2 → 24.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.
Files changed (47) hide show
  1. package/dist/bin/nx-cloud.js +9 -0
  2. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +12 -1
  3. package/dist/src/command-line/migrate/migrate-analytics.js +2 -2
  4. package/dist/src/command-line/migrate/migrate.d.ts +3 -0
  5. package/dist/src/command-line/migrate/migrate.js +34 -15
  6. package/dist/src/command-line/migrate/workspace-installation.d.ts +15 -0
  7. package/dist/src/command-line/migrate/workspace-installation.js +73 -0
  8. package/dist/src/command-line/nx-cloud/complete-run/command-object.js +1 -1
  9. package/dist/src/command-line/nx-cloud/fix-ci/command-object.js +1 -1
  10. package/dist/src/command-line/nx-cloud/logout/command-object.js +11 -2
  11. package/dist/src/command-line/nx-cloud/record/command-object.js +1 -1
  12. package/dist/src/command-line/nx-cloud/start-ci-run/command-object.js +1 -1
  13. package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +1 -1
  14. package/dist/src/command-line/release/changelog.js +6 -2
  15. package/dist/src/command-line/release/version/version-actions.js +2 -1
  16. package/dist/src/command-line/show/show-target/info.d.ts +1 -1
  17. package/dist/src/command-line/show/show-target/info.js +4 -4
  18. package/dist/src/core/graph/favicon.ico +0 -0
  19. package/dist/src/core/graph/main.js +1 -1
  20. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +3 -1
  21. package/dist/src/executors/run-commands/running-tasks.js +7 -0
  22. package/dist/src/executors/run-commands/schema.json +1 -1
  23. package/dist/src/native/index.js +12 -17
  24. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  25. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  26. package/dist/src/nx-cloud/update-manager.d.ts +2 -0
  27. package/dist/src/nx-cloud/utilities/client.d.ts +1 -0
  28. package/dist/src/nx-cloud/utilities/client.js +5 -0
  29. package/dist/src/plugins/js/project-graph/build-dependencies/build-dependencies.js +2 -1
  30. package/dist/src/plugins/js/utils/register.js +3 -2
  31. package/dist/src/plugins/js/utils/typescript.js +3 -2
  32. package/dist/src/project-graph/utils/retrieve-workspace-files.js +2 -2
  33. package/dist/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +34 -13
  34. package/dist/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +26 -5
  35. package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +1 -1
  36. package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +1 -1
  37. package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +3 -3
  38. package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +76 -39
  39. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +2 -2
  40. package/dist/src/tasks-runner/running-tasks/batch-process.js +1 -1
  41. package/dist/src/tasks-runner/task-orchestrator.d.ts +6 -3
  42. package/dist/src/tasks-runner/task-orchestrator.js +61 -29
  43. package/dist/src/utils/installation-directory.d.ts +8 -0
  44. package/dist/src/utils/installation-directory.js +13 -0
  45. package/dist/src/utils/package-manager.d.ts +2 -1
  46. package/dist/src/utils/package-manager.js +42 -12
  47. package/package.json +12 -12
@@ -88,6 +88,9 @@ function kickOffRecompute() {
88
88
  return chainToSuccessor(myPromise);
89
89
  if (cachedSerializedProjectGraphPromise === myPromise &&
90
90
  result.projectGraph) {
91
+ if (result.projectFileMapCache) {
92
+ exports.currentProjectFileMapCache = result.projectFileMapCache;
93
+ }
91
94
  // The graph identity ties the candidate's generation to exactly this
92
95
  // result; a chained result never matches (its computation's kickoff
93
96
  // replaced the cached pointer, failing the identity check above).
@@ -606,7 +609,6 @@ async function createAndSerializeProjectGraph({ projects, externalNodes, sourceM
606
609
  const fileMap = copyFileMap(exports.fileMapWithFiles.fileMap);
607
610
  const rustReferences = exports.fileMapWithFiles.rustReferences;
608
611
  const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)(), await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot)), sourceMaps);
609
- exports.currentProjectFileMapCache = projectFileMapCache;
610
612
  exports.currentProjectGraph = projectGraph;
611
613
  exports.currentSourceMaps = sourceMaps;
612
614
  perf_hooks_1.performance.mark('create-project-graph-end');
@@ -195,6 +195,13 @@ class SeriallyRunningTasks {
195
195
  this.run(options, context)
196
196
  .catch((e) => {
197
197
  this.error = e;
198
+ this.code = 1;
199
+ const message = e?.message ?? String(e);
200
+ this.terminalOutputChunks.push(message);
201
+ for (const cb of this.outputCallbacks) {
202
+ cb(message);
203
+ }
204
+ streamChunk(message, options.streamOutput, process.stderr);
198
205
  })
199
206
  .finally(() => {
200
207
  const terminalOutput = this.terminalOutputChunks.join('');
@@ -141,7 +141,7 @@
141
141
  "type": "string"
142
142
  }
143
143
  ],
144
- "description": "Extra arguments. You can pass them as follows: nx run project:target --args='--wait=100'. You can then use {args.wait} syntax to interpolate them in the workspace config file. See example [above](#chaining-commands-interpolating-args-and-setting-the-cwd)"
144
+ "description": "Extra arguments. You can pass them as follows: nx run project:target --args='--wait=100'. You can then use {args.wait} syntax to interpolate them in the workspace config file. See example [above](#interpolating-args)"
145
145
  },
146
146
  "envFile": {
147
147
  "type": "string",
@@ -77,10 +77,6 @@ function removeIfPresent(path) {
77
77
  }
78
78
  }
79
79
 
80
- function isNoExecError(e) {
81
- return e.code === 'EACCES' || e.code === 'EPERM';
82
- }
83
-
84
80
  // We override the _load function so that when a native file is required,
85
81
  // we copy it to a cache directory and require it from there.
86
82
  // This prevents the file being loaded from node_modules and causing file locking issues.
@@ -135,17 +131,24 @@ Module._load = function (request, parent, isMain) {
135
131
  existingFileStats?.size === expectedFileSize &&
136
132
  existingFileStats.mtimeMs >= sourceStats.mtimeMs;
137
133
 
138
- // If the file to be loaded already exists and is current, just load it
139
- if (isFresh) {
134
+ const loadFromCache = () => {
140
135
  try {
141
136
  return originalLoad.apply(this, [tmpFile, parent, isMain]);
142
137
  } catch (e) {
143
- // If loading from cache fails due to noexec, fall back to original location
144
- if (isNoExecError(e)) {
138
+ if (
139
+ e.code === 'EACCES' ||
140
+ e.code === 'EPERM' ||
141
+ e.code === 'MODULE_NOT_FOUND' ||
142
+ e.code === 'ERR_DLOPEN_FAILED'
143
+ ) {
145
144
  return originalLoad.apply(this, [nativeLocation, parent, isMain]);
146
145
  }
147
146
  throw e;
148
147
  }
148
+ };
149
+
150
+ if (isFresh) {
151
+ return loadFromCache();
149
152
  }
150
153
 
151
154
  // Retry copying up to 3 times, validating after each copy
@@ -177,15 +180,7 @@ Module._load = function (request, parent, isMain) {
177
180
  removeIfPresent(tmpTmpFile);
178
181
  break;
179
182
  }
180
- try {
181
- return originalLoad.apply(this, [tmpFile, parent, isMain]);
182
- } catch (e) {
183
- // If loading from cache fails due to noexec, fall back to original location
184
- if (isNoExecError(e)) {
185
- return originalLoad.apply(this, [nativeLocation, parent, isMain]);
186
- }
187
- throw e;
188
- }
183
+ return loadFromCache();
189
184
  }
190
185
 
191
186
  // Copy failed validation, clean up the malformed file
Binary file
@@ -27,6 +27,8 @@ export interface NxCloudClient {
27
27
  }) => Promise<{
28
28
  enabled: boolean;
29
29
  }>;
30
+ /** Clients that dispatch a whole `nx-cloud` command line; resolves to the exit code. */
31
+ runCLI?: (args: string[]) => Promise<number>;
30
32
  }
31
33
  export declare function verifyOrUpdateNxCloudClient(options?: {
32
34
  url?: string;
@@ -7,4 +7,5 @@ export declare class UnknownCommandError extends Error {
7
7
  export declare function getCloudClient(options: CloudTaskRunnerOptions): Promise<{
8
8
  invoke: (command: string, exit?: boolean) => Promise<void>;
9
9
  availableCommands: string[];
10
+ runCLI: (args: string[]) => Promise<number>;
10
11
  }>;
@@ -38,5 +38,10 @@ async function getCloudClient(options) {
38
38
  }
39
39
  },
40
40
  availableCommands: Object.keys(nxCloudClient.commands),
41
+ // Bundles that export runCLI own dispatch, help, output and the exit code.
42
+ // Older bundles only export `commands`.
43
+ runCLI: typeof nxCloudClient.runCLI === 'function'
44
+ ? (args) => nxCloudClient.runCLI(args)
45
+ : undefined,
41
46
  };
42
47
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildExplicitDependencies = buildExplicitDependencies;
4
+ const installation_directory_1 = require("../../../../utils/installation-directory");
4
5
  const explicit_package_json_dependencies_1 = require("./explicit-package-json-dependencies");
5
6
  const explicit_project_dependencies_1 = require("./explicit-project-dependencies");
6
7
  const target_project_locator_1 = require("./target-project-locator");
@@ -24,7 +25,7 @@ function buildExplicitDependencies(jsPluginConfig, ctx) {
24
25
  jsPluginConfig.analyzeSourceFiles === true) {
25
26
  let tsExists = false;
26
27
  try {
27
- require.resolve('typescript');
28
+ (0, installation_directory_1.resolveFromWorkspace)('typescript');
28
29
  tsExists = true;
29
30
  }
30
31
  catch { }
@@ -25,6 +25,7 @@ exports.getTsNodeCompilerOptions = getTsNodeCompilerOptions;
25
25
  const path_1 = require("path");
26
26
  const fs_1 = require("fs");
27
27
  const fileutils_1 = require("../../../utils/fileutils");
28
+ const installation_directory_1 = require("../../../utils/installation-directory");
28
29
  const logger_1 = require("../../../utils/logger");
29
30
  const workspace_root_1 = require("../../../utils/workspace-root");
30
31
  const typescript_1 = require("./typescript");
@@ -664,7 +665,7 @@ const registered = new Map();
664
665
  function getTranspiler(compilerOptions, tsConfigRaw) {
665
666
  const preferTsNode = process.env.NX_PREFER_TS_NODE === 'true';
666
667
  if (!ts) {
667
- ts = require('typescript');
668
+ ts = require((0, installation_directory_1.resolveFromWorkspace)('typescript'));
668
669
  }
669
670
  compilerOptions.lib = ['es2021'];
670
671
  compilerOptions.module = ts.ModuleKind.CommonJS;
@@ -1181,7 +1182,7 @@ function packageIsInstalled(m) {
1181
1182
  */
1182
1183
  function getTsNodeCompilerOptions(compilerOptions) {
1183
1184
  if (!ts) {
1184
- ts = require('typescript');
1185
+ ts = require((0, installation_directory_1.resolveFromWorkspace)('typescript'));
1185
1186
  }
1186
1187
  const flagMap = {
1187
1188
  module: 'ModuleKind',
@@ -10,6 +10,7 @@ exports.getRootTsConfigCustomConditions = getRootTsConfigCustomConditions;
10
10
  exports.getRootTsConfigResolveExportsConditions = getRootTsConfigResolveExportsConditions;
11
11
  exports.getPluginResolveConditionNodeArgs = getPluginResolveConditionNodeArgs;
12
12
  exports.findNodes = findNodes;
13
+ const installation_directory_1 = require("../../../utils/installation-directory");
13
14
  const workspace_root_1 = require("../../../utils/workspace-root");
14
15
  const fs_1 = require("fs");
15
16
  const path_1 = require("path");
@@ -17,7 +18,7 @@ const normalizedAppRoot = workspace_root_1.workspaceRoot.replace(/\\/g, '/');
17
18
  let tsModule;
18
19
  function readTsConfig(tsConfigPath, sys) {
19
20
  if (!tsModule) {
20
- tsModule = require('typescript');
21
+ tsModule = require((0, installation_directory_1.resolveFromWorkspace)('typescript'));
21
22
  }
22
23
  sys ??= tsModule.sys;
23
24
  const readResult = tsModule.readConfigFile(tsConfigPath, sys.readFile);
@@ -25,7 +26,7 @@ function readTsConfig(tsConfigPath, sys) {
25
26
  }
26
27
  function readTsConfigWithoutFiles(tsConfigPath) {
27
28
  if (!tsModule) {
28
- tsModule = require('typescript');
29
+ tsModule = require((0, installation_directory_1.resolveFromWorkspace)('typescript'));
29
30
  }
30
31
  // We only care about options, so we don't need to scan source files, and thus
31
32
  // `readDirectory` is stubbed for performance.
@@ -59,13 +59,13 @@ async function retrieveProjectConfigurations(separatedPlugins, workspaceRoot, nx
59
59
  });
60
60
  }
61
61
  async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson) {
62
- const pluginsToLoad = nxJson?.plugins ?? [];
62
+ const pluginsToLoad = [...(nxJson?.plugins ?? [])];
63
63
  if ((0, angular_json_1.shouldMergeAngularProjects)(workspaceRoot, true) &&
64
64
  !pluginsToLoad.some((p) => p === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME ||
65
65
  (typeof p === 'object' && p.plugin === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME))) {
66
66
  pluginsToLoad.push((0, path_1.join)(__dirname, '../../adapter/angular-json'));
67
67
  }
68
- const separatedPlugins = await (0, get_plugins_1.getPluginsSeparated)(nxJson, workspaceRoot);
68
+ const separatedPlugins = await (0, get_plugins_1.getPluginsSeparated)({ ...nxJson, plugins: pluginsToLoad }, workspaceRoot);
69
69
  const res = await retrieveProjectConfigurations(separatedPlugins, workspaceRoot, nxJson);
70
70
  return res;
71
71
  }
@@ -41,10 +41,15 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
41
41
  clearInterval(renderIntervalId);
42
42
  }
43
43
  }
44
+ let stoppedBySignal = false;
45
+ const onSignal = () => {
46
+ stoppedBySignal = true;
47
+ clearRenderInterval();
48
+ };
44
49
  process.on('exit', () => clearRenderInterval());
45
- process.on('SIGINT', () => clearRenderInterval());
46
- process.on('SIGTERM', () => clearRenderInterval());
47
- process.on('SIGHUP', () => clearRenderInterval());
50
+ process.on('SIGINT', onSignal);
51
+ process.on('SIGTERM', onSignal);
52
+ process.on('SIGHUP', onSignal);
48
53
  const lifeCycle = {};
49
54
  const isVerbose = overrides.verbose === true;
50
55
  const start = process.hrtime();
@@ -58,6 +63,7 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
58
63
  };
59
64
  });
60
65
  const failedTasks = new Set();
66
+ const stoppedTasks = new Set();
61
67
  const tasksToTerminalOutputs = {};
62
68
  const tasksToProcessStartTimes = {};
63
69
  let hasTaskOutput = false;
@@ -273,20 +279,32 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
273
279
  }
274
280
  const numFailedToPrint = 5;
275
281
  const failedTasksForPrinting = Array.from(failedTasks).slice(0, numFailedToPrint);
282
+ const taskIdRows = (taskIds) => taskIds
283
+ .map((t) => `${EXTENDED_LEFT_PAD}${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t)}`)
284
+ .join('\n');
276
285
  const failureSummaryRows = [
277
286
  output_1.output.applyNxPrefix('red', output_1.output.colors.red(text) + pc.dim(pc.white(` (${timeTakenText})`))),
278
287
  ...taskOverridesRows,
279
- '',
280
- output_1.output.dim(`${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`),
281
- '',
282
- `${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} targets failed, including the following:`,
283
- '',
284
- `${failedTasksForPrinting
285
- .map((t) => `${EXTENDED_LEFT_PAD}${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t.toString())}`)
286
- .join('\n')}`,
287
288
  ];
288
- if (failedTasks.size > numFailedToPrint) {
289
- failureSummaryRows.push(output_1.output.dim(`${EXTENDED_LEFT_PAD}...and ${failedTasks.size - numFailedToPrint} more...`));
289
+ if (totalSuccessfulTasks > 0) {
290
+ failureSummaryRows.push('', output_1.output.dim(`${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`));
291
+ }
292
+ if (totalFailedTasks > 0) {
293
+ failureSummaryRows.push('', `${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalTasks}`} targets failed, including the following:`, '', taskIdRows(failedTasksForPrinting));
294
+ if (failedTasks.size > numFailedToPrint) {
295
+ failureSummaryRows.push(output_1.output.dim(`${EXTENDED_LEFT_PAD}...and ${failedTasks.size - numFailedToPrint} more...`));
296
+ }
297
+ }
298
+ if (stoppedTasks.size > 0) {
299
+ failureSummaryRows.push('', `${LEFT_PAD}${output_1.output.colors.red(figures.ellipsis)}${SPACER}${stoppedTasks.size}/${totalTasks} targets were in progress, including the following:`, '', taskIdRows(Array.from(stoppedTasks)));
300
+ }
301
+ const notRunTasks = totalTasks - totalCompletedTasks;
302
+ // After a signal, the tasks that never ran include ones the run
303
+ // stopped before reaching, which "skipped" would mislabel
304
+ if (notRunTasks > 0) {
305
+ failureSummaryRows.push('', output_1.output.dim(stoppedBySignal
306
+ ? `${LEFT_PAD}${output_1.output.colors.red(figures.ellipsis)}${SPACER}${notRunTasks}/${totalTasks} targets had not started.`
307
+ : `${LEFT_PAD}${pc.yellow('⏭')}${SPACER}${notRunTasks}/${totalTasks} targets were skipped.`));
290
308
  }
291
309
  failureSummaryRows.push(...(0, view_logs_utils_1.viewLogsFooterRows)(failedTasks.size));
292
310
  renderPinnedFooter(failureSummaryRows, 'red');
@@ -330,6 +348,9 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
330
348
  totalFailedTasks++;
331
349
  failedTasks.add(t.task.id);
332
350
  break;
351
+ case 'stopped':
352
+ stoppedTasks.add(t.task.id);
353
+ break;
333
354
  }
334
355
  printTaskResult(t.task, t.status);
335
356
  }
@@ -41,10 +41,15 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
41
41
  clearInterval(renderDependentTargetsIntervalId);
42
42
  }
43
43
  }
44
+ let stoppedBySignal = false;
45
+ const onSignal = () => {
46
+ stoppedBySignal = true;
47
+ clearRenderInterval();
48
+ };
44
49
  process.on('exit', () => clearRenderInterval());
45
- process.on('SIGINT', () => clearRenderInterval());
46
- process.on('SIGTERM', () => clearRenderInterval());
47
- process.on('SIGHUP', () => clearRenderInterval());
50
+ process.on('SIGINT', onSignal);
51
+ process.on('SIGTERM', onSignal);
52
+ process.on('SIGHUP', onSignal);
48
53
  const lifeCycle = {};
49
54
  const start = process.hrtime();
50
55
  const figures = await (0, handle_import_1.handleImport)('figures');
@@ -60,6 +65,7 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
60
65
  let totalCompletedTasks = 0;
61
66
  let totalSuccessfulTasks = 0;
62
67
  let totalFailedTasks = 0;
68
+ let totalStoppedTasks = 0;
63
69
  let totalCachedTasks = 0;
64
70
  // Used to control the rendering of the spinner
65
71
  let dependentTargetsCurrentFrame = 0;
@@ -175,6 +181,9 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
175
181
  output_1.output.logCommandOutput(t.task.id, t.status, tasksToTerminalOutputs[t.task.id]);
176
182
  }
177
183
  break;
184
+ case 'stopped':
185
+ totalStoppedTasks++;
186
+ break;
178
187
  }
179
188
  delete tasksToTerminalOutputs[t.task.id];
180
189
  }
@@ -223,12 +232,24 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
223
232
  .forEach((arg) => taskOverridesLines.push(arg));
224
233
  }
225
234
  const viewLogs = (0, view_logs_utils_1.viewLogsFooterRows)(totalFailedTasks);
235
+ const notRunTasks = totalTasks - totalCompletedTasks;
236
+ // After a signal, the tasks that never ran include ones the run
237
+ // stopped before reaching, which "skipped" would mislabel
238
+ const notRunLine = stoppedBySignal
239
+ ? `${LEFT_PAD}${output_1.output.colors.red(figures.ellipsis)}${SPACER}${notRunTasks}/${totalTasks} had not started`
240
+ : `${LEFT_PAD}${pc.yellow('⏭')}${SPACER}${notRunTasks}/${totalTasks} skipped`;
226
241
  renderLines([
227
242
  output_1.output.applyNxPrefix('red', output_1.output.colors.red(text) + output_1.output.dim(` (${timeTakenText})`)),
228
243
  ...taskOverridesLines,
229
244
  '',
230
- `${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
231
- `${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`,
245
+ `${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalTasks}`} failed`,
246
+ `${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`,
247
+ ...(totalStoppedTasks > 0
248
+ ? [
249
+ `${LEFT_PAD}${output_1.output.colors.red(figures.ellipsis)}${SPACER}${totalStoppedTasks}/${totalTasks} were in progress`,
250
+ ]
251
+ : []),
252
+ ...(notRunTasks > 0 ? [notRunLine] : []),
232
253
  ...viewLogs,
233
254
  ], 'red');
234
255
  }
@@ -84,7 +84,7 @@ class StaticRunManyTerminalOutputLifeCycle {
84
84
  const bodyLines = [];
85
85
  const skippedTasks = this.skippedTasks();
86
86
  if (skippedTasks.length > 0) {
87
- bodyLines.push(output_1.output.dim('Tasks not run because their dependencies failed or --nx-bail=true:'), '', ...skippedTasks.map((task) => `${output_1.output.dim('-')} ${task.id}`), '');
87
+ bodyLines.push(output_1.output.dim('Tasks not run because their dependencies failed, --nx-bail=true, or their batch ended before reaching them:'), '', ...skippedTasks.map((task) => `${output_1.output.dim('-')} ${task.id}`), '');
88
88
  }
89
89
  if (this.stoppedTasks.length > 0) {
90
90
  bodyLines.push(output_1.output.dim('Tasks stopped before they finished:'), '', ...this.stoppedTasks.map((task) => `${output_1.output.dim('-')} ${task.id}`), '');
@@ -93,7 +93,7 @@ class StaticRunOneTerminalOutputLifeCycle {
93
93
  const bodyLines = [];
94
94
  const skippedTasks = this.skippedTasks();
95
95
  if (skippedTasks.length > 0) {
96
- bodyLines.push(output_1.output.dim('Tasks not run because their dependencies failed or --nx-bail=true:'), '', ...skippedTasks.map((task) => `${output_1.output.dim('-')} ${task.id}`), '');
96
+ bodyLines.push(output_1.output.dim('Tasks not run because their dependencies failed, --nx-bail=true, or their batch ended before reaching them:'), '', ...skippedTasks.map((task) => `${output_1.output.dim('-')} ${task.id}`), '');
97
97
  }
98
98
  if (this.stoppedTasks.length > 0) {
99
99
  bodyLines.push(output_1.output.dim('Tasks stopped before they finished:'), '', ...this.stoppedTasks.map((task) => `${output_1.output.dim('-')} ${task.id}`), '');
@@ -22,13 +22,13 @@ class SummaryTerminalOutputLifeCycle {
22
22
  this.completed = new Set();
23
23
  this.succeeded = 0;
24
24
  this.cached = 0;
25
- this.batchLogs = new Map();
25
+ this.batchLogs = [];
26
26
  }
27
27
  setCloudLink(label, url) {
28
28
  this.cloudLink = { label, url };
29
29
  }
30
30
  batchOutputAvailable(batchId, path) {
31
- this.batchLogs.set(batchId, path);
31
+ this.batchLogs.push([batchId, path]);
32
32
  }
33
33
  /**
34
34
  * Nothing is printed as tasks complete. A summary that interleaved with
@@ -87,7 +87,7 @@ class SummaryTerminalOutputLifeCycle {
87
87
  : [line];
88
88
  }));
89
89
  }
90
- if (this.batchLogs.size > 0) {
90
+ if (this.batchLogs.length > 0) {
91
91
  // One line per worker, not per task: a batch's log explains the whole
92
92
  // batch, and no task's own output file contains it.
93
93
  bodyLines.push('', output_1.output.dim('Batch worker logs:'));
@@ -25,6 +25,7 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
25
25
  let totalCompletedTasks = 0;
26
26
  let timeTakenText;
27
27
  const failedTasks = new Set();
28
+ const skippedTasks = new Set();
28
29
  const inProgressTasks = new Set();
29
30
  // Tasks ended with 'stopped' status (interrupted, didn't finish — counts as failure)
30
31
  const stoppedTasks = new Set();
@@ -35,12 +36,13 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
35
36
  // Finalized output strings set on task completion — read by summary print functions
36
37
  const tasksToTerminalOutputs = {};
37
38
  const tasksToTaskStatus = {};
38
- const taskIdsInTheOrderTheyStart = [];
39
+ const batchWorkerLogs = [];
40
+ const taskIdsInTheOrderTheyStart = new Set();
39
41
  const getTerminalOutput = (taskId) => tasksToTerminalOutputs[taskId] ?? taskOutputChunks[taskId]?.join('') ?? '';
40
42
  lifeCycle.startTasks = (tasks) => {
41
43
  for (let t of tasks) {
42
44
  taskOutputChunks[t.id] ??= [];
43
- taskIdsInTheOrderTheyStart.push(t.id);
45
+ taskIdsInTheOrderTheyStart.add(t.id);
44
46
  inProgressTasks.add(t.id);
45
47
  }
46
48
  };
@@ -71,6 +73,7 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
71
73
  // Skipped tasks don't get an endTasks() call; clear them here so the run
72
74
  // summary doesn't treat them as still-in-progress and report Cancelled.
73
75
  tasksToTaskStatus[taskId] = 'skipped';
76
+ skippedTasks.add(taskId);
74
77
  inProgressTasks.delete(taskId);
75
78
  }
76
79
  };
@@ -78,6 +81,9 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
78
81
  for (const { task, status, terminalOutput } of taskResults) {
79
82
  totalCompletedTasks++;
80
83
  inProgressTasks.delete(task.id);
84
+ // A batch that crashes after reporting the task skipped still ends it
85
+ // here, as failed or stopped
86
+ skippedTasks.delete(task.id);
81
87
  tasksToTaskStatus[task.id] = status;
82
88
  if (status === 'stopped') {
83
89
  stoppedTasks.add(task.id);
@@ -107,10 +113,18 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
107
113
  }
108
114
  }
109
115
  };
116
+ lifeCycle.batchOutputAvailable = (batchId, path) => {
117
+ batchWorkerLogs.push([batchId, path]);
118
+ };
110
119
  lifeCycle.endCommand = () => {
111
120
  timeTakenText = (0, pretty_time_1.prettyTime)(process.hrtime(start));
112
121
  resolveRenderIsDonePromise();
113
122
  };
123
+ const batchWorkerLogRows = () => [
124
+ `${LEFT_PAD}${output_1.output.dim('Batch worker logs:')}`,
125
+ '',
126
+ ...batchWorkerLogs.map(([batchId, path]) => `${EXTENDED_LEFT_PAD}${output_1.output.dim(`- ${batchId}: ${path}`)}`),
127
+ ];
114
128
  const printSummary = () => {
115
129
  const isRunOne = initiatingProject && targets?.length === 1;
116
130
  // Handles when the user interrupts the process
@@ -138,7 +152,7 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
138
152
  (0, task_history_life_cycle_1.getTasksHistoryLifeCycle)().printFlakyTasksMessage();
139
153
  };
140
154
  const printRunOneSummary = ({ failure, cancelled, }) => {
141
- // Print task outputs in completion order above the summary.
155
+ // Print task outputs in start order above the summary.
142
156
  for (const taskId of taskIdsInTheOrderTheyStart) {
143
157
  const taskStatus = tasksToTaskStatus[taskId];
144
158
  // Skipped tasks never ran; don't print a misleading `> nx run` header.
@@ -195,15 +209,27 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
195
209
  .forEach((arg) => messageLines.push(arg));
196
210
  }
197
211
  messageLines.push('');
198
- messageLines.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} failed`);
199
- messageLines.push(`${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`);
212
+ messageLines.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalTasks}`} failed`);
213
+ messageLines.push(`${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`);
214
+ if (skippedTasks.size > 0) {
215
+ messageLines.push(`${LEFT_PAD}${pc.yellow('⏭')}${SPACER}${skippedTasks.size}/${totalTasks} skipped`);
216
+ }
217
+ if (batchWorkerLogs.length > 0) {
218
+ messageLines.push('', ...batchWorkerLogRows());
219
+ }
200
220
  const viewLogs = (0, view_logs_utils_1.viewLogsFooterRows)(totalFailedTasks);
201
221
  messageLines.push(...viewLogs);
202
222
  // Print the entire failure message block with red color
203
223
  console.log(output_1.output.colors.red(messageLines.join(node_os_1.EOL)));
204
224
  }
205
225
  else {
206
- console.log(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})`)));
226
+ const messageLines = [
227
+ 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})`)),
228
+ ];
229
+ if (batchWorkerLogs.length > 0) {
230
+ messageLines.push('', ...batchWorkerLogRows());
231
+ }
232
+ console.log(messageLines.join(node_os_1.EOL));
207
233
  }
208
234
  // adds some vertical space after the summary to avoid bunching against terminal
209
235
  console.log('');
@@ -212,8 +238,11 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
212
238
  console.log('');
213
239
  // Collect checklist lines to print after task outputs
214
240
  const checklistLines = [];
215
- // Sort tasks by status: successful tasks first, failed tasks at the end
216
- const sortedTaskIds = [...taskIdsInTheOrderTheyStart].sort((a, b) => {
241
+ // Sort tasks by status: successful tasks first, failed tasks at the end.
242
+ // A task skipped before it started never reached startTasks.
243
+ const sortedTaskIds = [
244
+ ...new Set([...taskIdsInTheOrderTheyStart, ...skippedTasks]),
245
+ ].sort((a, b) => {
217
246
  const statusA = tasksToTaskStatus[a];
218
247
  const statusB = tasksToTaskStatus[b];
219
248
  const isFailureA = statusA === 'failure' || !statusA ? 1 : 0;
@@ -224,7 +253,9 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
224
253
  for (const taskId of sortedTaskIds) {
225
254
  const taskStatus = tasksToTaskStatus[taskId];
226
255
  const terminalOutput = getTerminalOutput(taskId);
227
- if (displayStoppedTasks.has(taskId) || !taskStatus) {
256
+ if (displayStoppedTasks.has(taskId) ||
257
+ !taskStatus ||
258
+ taskStatus === 'stopped') {
228
259
  output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
229
260
  output_1.output.addNewline();
230
261
  checklistLines.push(`${LEFT_PAD}${output_1.output.colors.cyan(figures.squareSmallFilled)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
@@ -246,8 +277,13 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
246
277
  else if (taskStatus === 'success') {
247
278
  checklistLines.push(`${LEFT_PAD}${output_1.output.colors.green(figures.tick)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
248
279
  }
280
+ else if (taskStatus === 'skipped') {
281
+ checklistLines.push(`${LEFT_PAD}${pc.yellow('⏭')}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
282
+ }
249
283
  else {
250
- checklistLines.push(`${LEFT_PAD}${output_1.output.colors.green(figures.tick)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
284
+ const unhandled = taskStatus;
285
+ void unhandled;
286
+ checklistLines.push(`${LEFT_PAD}${output_1.output.colors.cyan(figures.squareSmallFilled)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
251
287
  }
252
288
  }
253
289
  // Print all checklist lines together
@@ -296,40 +332,41 @@ function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, taskGraph, args,
296
332
  .forEach((arg) => failureSummaryRows.push(arg));
297
333
  }
298
334
  failureSummaryRows.push('');
299
- if (totalCompletedTasks > 0) {
300
- // For display purposes, treat stopped tasks as in-progress
301
- // (they were running when the process was interrupted)
302
- const displayCompleted = totalCompletedTasks - stoppedTasks.size;
303
- const displayInProgress = new Set([
304
- ...inProgressTasks,
305
- ...stoppedTasks,
306
- ]);
307
- if (totalSuccessfulTasks > 0) {
308
- failureSummaryRows.push(output_1.output.dim(`${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${displayCompleted}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`), '');
335
+ // For display purposes, treat stopped tasks as in-progress
336
+ // (they were running when the process was interrupted)
337
+ const displayCompleted = totalCompletedTasks - stoppedTasks.size;
338
+ const displayInProgress = new Set([...inProgressTasks, ...stoppedTasks]);
339
+ if (totalSuccessfulTasks > 0) {
340
+ failureSummaryRows.push(output_1.output.dim(`${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`), '');
341
+ }
342
+ if (totalFailedTasks > 0) {
343
+ const numFailedToPrint = 5;
344
+ const failedTasksForPrinting = Array.from(failedTasks).slice(0, numFailedToPrint);
345
+ failureSummaryRows.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalTasks}`} targets failed, including the following:`, '', `${failedTasksForPrinting
346
+ .map((t) => `${EXTENDED_LEFT_PAD}${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t.toString())}`)
347
+ .join('\n')}`, '');
348
+ if (failedTasks.size > numFailedToPrint) {
349
+ failureSummaryRows.push(output_1.output.dim(`${EXTENDED_LEFT_PAD}...and ${failedTasks.size - numFailedToPrint} more...`));
309
350
  }
310
- if (totalFailedTasks > 0) {
311
- const numFailedToPrint = 5;
312
- const failedTasksForPrinting = Array.from(failedTasks).slice(0, numFailedToPrint);
313
- failureSummaryRows.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${displayCompleted}`} targets failed, including the following:`, '', `${failedTasksForPrinting
351
+ }
352
+ if (skippedTasks.size > 0) {
353
+ failureSummaryRows.push(output_1.output.dim(`${LEFT_PAD}${pc.yellow('⏭')}${SPACER}${skippedTasks.size}/${totalTasks} targets were skipped.`), '');
354
+ }
355
+ if (displayCompleted !== totalTasks) {
356
+ const remainingTasks = totalTasks - displayCompleted - skippedTasks.size;
357
+ if (displayInProgress.size) {
358
+ failureSummaryRows.push(`${LEFT_PAD}${output_1.output.colors.red(figures.ellipsis)}${SPACER}${displayInProgress.size}${`/${totalTasks}`} targets were in progress, including the following:`, '', `${Array.from(displayInProgress)
314
359
  .map((t) => `${EXTENDED_LEFT_PAD}${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t.toString())}`)
315
- .join('\n')}`, '');
316
- if (failedTasks.size > numFailedToPrint) {
317
- failureSummaryRows.push(output_1.output.dim(`${EXTENDED_LEFT_PAD}...and ${failedTasks.size - numFailedToPrint} more...`));
318
- }
360
+ .join(node_os_1.EOL)}`, '');
319
361
  }
320
- if (displayCompleted !== totalTasks) {
321
- const remainingTasks = totalTasks - displayCompleted;
322
- if (displayInProgress.size) {
323
- failureSummaryRows.push(`${LEFT_PAD}${output_1.output.colors.red(figures.ellipsis)}${SPACER}${displayInProgress.size}${`/${totalTasks}`} targets were in progress, including the following:`, '', `${Array.from(displayInProgress)
324
- .map((t) => `${EXTENDED_LEFT_PAD}${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t.toString())}`)
325
- .join(node_os_1.EOL)}`, '');
326
- }
327
- if (remainingTasks - displayInProgress.size > 0) {
328
- failureSummaryRows.push(output_1.output.dim(`${LEFT_PAD}${output_1.output.colors.red(figures.ellipsis)}${SPACER}${remainingTasks - displayInProgress.size}${`/${totalTasks}`} targets had not started.`), '');
329
- }
362
+ if (remainingTasks - displayInProgress.size > 0) {
363
+ failureSummaryRows.push(output_1.output.dim(`${LEFT_PAD}${output_1.output.colors.red(figures.ellipsis)}${SPACER}${remainingTasks - displayInProgress.size}${`/${totalTasks}`} targets had not started.`), '');
330
364
  }
331
- failureSummaryRows.push(...(0, view_logs_utils_1.viewLogsFooterRows)(failedTasks.size));
332
365
  }
366
+ if (batchWorkerLogs.length > 0) {
367
+ failureSummaryRows.push(...batchWorkerLogRows(), '');
368
+ }
369
+ failureSummaryRows.push(...(0, view_logs_utils_1.viewLogsFooterRows)(failedTasks.size));
333
370
  console.log(output_1.output.colors.red(failureSummaryRows.join(node_os_1.EOL)));
334
371
  }
335
372
  // adds some vertical space after the summary to avoid bunching against terminal