nx 21.0.0-beta.1 → 21.0.0-beta.11

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 (250) hide show
  1. package/.eslintrc.json +5 -1
  2. package/migrations.json +15 -35
  3. package/package.json +12 -12
  4. package/release/index.d.ts +1 -1
  5. package/release/index.js +2 -1
  6. package/schemas/nx-schema.json +187 -35
  7. package/schemas/project-schema.json +5 -0
  8. package/src/adapter/angular-json.js +11 -0
  9. package/src/adapter/compat.d.ts +1 -1
  10. package/src/adapter/compat.js +3 -0
  11. package/src/command-line/add/add.js +6 -16
  12. package/src/command-line/affected/command-object.js +6 -6
  13. package/src/command-line/examples.js +0 -4
  14. package/src/command-line/exec/command-object.js +1 -1
  15. package/src/command-line/generate/generator-utils.js +8 -3
  16. package/src/command-line/import/import.js +1 -1
  17. package/src/command-line/init/command-object.js +18 -6
  18. package/src/command-line/init/configure-plugins.d.ts +6 -7
  19. package/src/command-line/init/configure-plugins.js +52 -38
  20. package/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
  21. package/src/command-line/init/implementation/add-nx-to-turborepo.js +49 -0
  22. package/src/command-line/init/implementation/check-compatible-with-plugins.js +7 -1
  23. package/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
  24. package/src/command-line/init/implementation/deduce-default-base.js +53 -0
  25. package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +6 -4
  26. package/src/command-line/init/implementation/react/index.d.ts +1 -1
  27. package/src/command-line/init/implementation/react/index.js +32 -185
  28. package/src/command-line/init/implementation/react/write-vite-config.js +19 -3
  29. package/src/command-line/init/implementation/utils.d.ts +6 -2
  30. package/src/command-line/init/implementation/utils.js +110 -45
  31. package/src/command-line/init/init-v1.js +1 -1
  32. package/src/command-line/init/init-v2.d.ts +1 -0
  33. package/src/command-line/init/init-v2.js +70 -39
  34. package/src/command-line/migrate/migrate-ui-api.d.ts +58 -0
  35. package/src/command-line/migrate/migrate-ui-api.js +227 -0
  36. package/src/command-line/migrate/migrate.d.ts +23 -4
  37. package/src/command-line/migrate/migrate.js +138 -86
  38. package/src/command-line/nx-commands.js +19 -5
  39. package/src/command-line/register/command-object.d.ts +6 -0
  40. package/src/command-line/{activate-powerpack → register}/command-object.js +9 -9
  41. package/src/command-line/register/register.d.ts +2 -0
  42. package/src/command-line/register/register.js +9 -0
  43. package/src/command-line/release/changelog.js +18 -15
  44. package/src/command-line/release/command-object.d.ts +8 -0
  45. package/src/command-line/release/command-object.js +9 -0
  46. package/src/command-line/release/config/config.d.ts +8 -7
  47. package/src/command-line/release/config/config.js +139 -45
  48. package/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
  49. package/src/command-line/release/config/use-legacy-versioning.js +9 -0
  50. package/src/command-line/release/index.d.ts +4 -0
  51. package/src/command-line/release/index.js +6 -1
  52. package/src/command-line/release/plan-check.js +6 -3
  53. package/src/command-line/release/plan.js +7 -3
  54. package/src/command-line/release/publish.js +7 -3
  55. package/src/command-line/release/release.js +8 -3
  56. package/src/command-line/release/utils/batch-projects-by-generator-config.js +6 -3
  57. package/src/command-line/release/utils/git.d.ts +3 -2
  58. package/src/command-line/release/utils/git.js +65 -9
  59. package/src/command-line/release/utils/github.js +3 -1
  60. package/src/command-line/release/utils/resolve-semver-specifier.d.ts +2 -1
  61. package/src/command-line/release/utils/resolve-semver-specifier.js +2 -1
  62. package/src/command-line/release/utils/semver.d.ts +8 -0
  63. package/src/command-line/release/utils/semver.js +8 -0
  64. package/src/command-line/release/utils/shared-legacy.d.ts +25 -0
  65. package/src/command-line/release/utils/shared-legacy.js +2 -0
  66. package/src/command-line/release/utils/shared.d.ts +11 -17
  67. package/src/command-line/release/version/derive-specifier-from-conventional-commits.d.ts +7 -0
  68. package/src/command-line/release/version/derive-specifier-from-conventional-commits.js +47 -0
  69. package/src/command-line/release/version/deriver-specifier-from-version-plans.d.ts +8 -0
  70. package/src/command-line/release/version/deriver-specifier-from-version-plans.js +59 -0
  71. package/src/command-line/release/version/project-logger.d.ts +8 -0
  72. package/src/command-line/release/version/project-logger.js +45 -0
  73. package/src/command-line/release/version/release-group-processor.d.ts +252 -0
  74. package/src/command-line/release/version/release-group-processor.js +1057 -0
  75. package/src/command-line/release/version/resolve-current-version.d.ts +32 -0
  76. package/src/command-line/release/version/resolve-current-version.js +241 -0
  77. package/src/command-line/release/version/test-utils.d.ts +93 -0
  78. package/src/command-line/release/version/test-utils.js +415 -0
  79. package/src/command-line/release/version/topological-sort.d.ts +9 -0
  80. package/src/command-line/release/version/topological-sort.js +41 -0
  81. package/src/command-line/release/version/version-actions.d.ts +171 -0
  82. package/src/command-line/release/version/version-actions.js +195 -0
  83. package/src/command-line/release/version-legacy.d.ts +46 -0
  84. package/src/command-line/release/version-legacy.js +453 -0
  85. package/src/command-line/release/version.d.ts +0 -40
  86. package/src/command-line/release/version.js +84 -262
  87. package/src/command-line/repair/repair.js +8 -3
  88. package/src/command-line/report/report.d.ts +7 -3
  89. package/src/command-line/report/report.js +52 -18
  90. package/src/command-line/run/command-object.js +2 -2
  91. package/src/command-line/run/executor-utils.d.ts +6 -1
  92. package/src/command-line/run/executor-utils.js +10 -1
  93. package/src/command-line/run/run.js +2 -2
  94. package/src/command-line/run-many/command-object.js +2 -2
  95. package/src/command-line/yargs-utils/shared-options.d.ts +4 -0
  96. package/src/command-line/yargs-utils/shared-options.js +20 -0
  97. package/src/config/misc-interfaces.d.ts +20 -2
  98. package/src/config/nx-json.d.ts +158 -18
  99. package/src/config/project-graph.d.ts +4 -2
  100. package/src/config/project-graph.js +8 -0
  101. package/src/config/workspace-json-project-json.d.ts +2 -2
  102. package/src/core/graph/main.js +1 -1
  103. package/src/core/graph/runtime.js +1 -1
  104. package/src/core/graph/styles.css +2 -2
  105. package/src/core/graph/styles.js +1 -1
  106. package/src/daemon/client/client.d.ts +2 -0
  107. package/src/daemon/client/client.js +15 -0
  108. package/src/daemon/message-types/glob.d.ts +7 -0
  109. package/src/daemon/message-types/glob.js +9 -1
  110. package/src/daemon/message-types/hash-glob.d.ts +6 -0
  111. package/src/daemon/message-types/hash-glob.js +9 -1
  112. package/src/daemon/server/handle-glob.d.ts +1 -0
  113. package/src/daemon/server/handle-glob.js +8 -0
  114. package/src/daemon/server/handle-hash-glob.d.ts +1 -0
  115. package/src/daemon/server/handle-hash-glob.js +8 -0
  116. package/src/daemon/server/logger.js +2 -1
  117. package/src/daemon/server/server.js +7 -0
  118. package/src/devkit-exports.d.ts +1 -1
  119. package/src/devkit-internals.d.ts +3 -2
  120. package/src/devkit-internals.js +5 -1
  121. package/src/executors/run-commands/run-commands.impl.d.ts +2 -5
  122. package/src/executors/run-commands/run-commands.impl.js +14 -42
  123. package/src/executors/run-commands/running-tasks.d.ts +9 -4
  124. package/src/executors/run-commands/running-tasks.js +103 -30
  125. package/src/executors/run-script/run-script.impl.js +4 -3
  126. package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +8 -0
  127. package/src/generators/testing-utils/create-tree.js +5 -1
  128. package/src/migrations/update-21-0-0/release-version-config-changes.d.ts +2 -0
  129. package/src/migrations/update-21-0-0/release-version-config-changes.js +111 -0
  130. package/src/migrations/update-21-0-0/remove-custom-tasks-runner.d.ts +2 -0
  131. package/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +38 -0
  132. package/src/migrations/{update-18-0-0/disable-crystal-for-existing-workspaces.js → update-21-0-0/remove-legacy-cache.js} +10 -4
  133. package/src/native/index.d.ts +98 -19
  134. package/src/native/index.js +16 -2
  135. package/src/native/native-bindings.js +7 -0
  136. package/src/native/nx.wasi-browser.js +20 -19
  137. package/src/native/nx.wasi.cjs +20 -19
  138. package/src/native/nx.wasm32-wasi.wasm +0 -0
  139. package/src/nx-cloud/nx-cloud-tasks-runner-shell.js +3 -3
  140. package/src/plugins/js/index.d.ts +2 -1
  141. package/src/plugins/js/index.js +8 -1
  142. package/src/plugins/js/lock-file/lock-file.js +28 -13
  143. package/src/plugins/js/lock-file/utils/package-json.d.ts +1 -1
  144. package/src/plugins/js/lock-file/utils/package-json.js +8 -6
  145. package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -3
  146. package/src/plugins/js/lock-file/yarn-parser.js +85 -39
  147. package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
  148. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +1 -1
  149. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +10 -1
  150. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +59 -6
  151. package/src/plugins/js/utils/packages.js +22 -3
  152. package/src/plugins/js/utils/register.js +1 -0
  153. package/src/plugins/js/utils/typescript.js +3 -3
  154. package/src/plugins/package-json/create-nodes.d.ts +1 -1
  155. package/src/plugins/package-json/create-nodes.js +4 -2
  156. package/src/project-graph/affected/locators/project-glob-changes.js +2 -2
  157. package/src/project-graph/error-types.js +32 -2
  158. package/src/project-graph/file-utils.d.ts +1 -10
  159. package/src/project-graph/file-utils.js +2 -77
  160. package/src/project-graph/plugins/get-plugins.js +2 -1
  161. package/src/project-graph/plugins/in-process-loader.js +1 -1
  162. package/src/project-graph/plugins/isolation/plugin-worker.js +12 -6
  163. package/src/project-graph/plugins/loaded-nx-plugin.d.ts +2 -1
  164. package/src/project-graph/plugins/loaded-nx-plugin.js +1 -5
  165. package/src/project-graph/plugins/public-api.d.ts +1 -1
  166. package/src/project-graph/plugins/utils.d.ts +2 -2
  167. package/src/project-graph/plugins/utils.js +2 -2
  168. package/src/project-graph/project-graph.js +1 -1
  169. package/src/project-graph/utils/project-configuration-utils.d.ts +3 -3
  170. package/src/project-graph/utils/project-configuration-utils.js +54 -21
  171. package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
  172. package/src/project-graph/utils/retrieve-workspace-files.js +14 -18
  173. package/src/tasks-runner/batch/batch-messages.d.ts +2 -0
  174. package/src/tasks-runner/batch/run-batch.js +4 -5
  175. package/src/tasks-runner/cache.d.ts +21 -8
  176. package/src/tasks-runner/cache.js +106 -38
  177. package/src/tasks-runner/create-task-graph.d.ts +0 -1
  178. package/src/tasks-runner/create-task-graph.js +11 -11
  179. package/src/tasks-runner/default-tasks-runner.js +5 -14
  180. package/src/tasks-runner/forked-process-task-runner.d.ts +8 -3
  181. package/src/tasks-runner/forked-process-task-runner.js +59 -46
  182. package/src/tasks-runner/init-tasks-runner.d.ts +15 -1
  183. package/src/tasks-runner/init-tasks-runner.js +62 -2
  184. package/src/tasks-runner/is-tui-enabled.d.ts +2 -0
  185. package/src/tasks-runner/is-tui-enabled.js +64 -0
  186. package/src/tasks-runner/life-cycle.d.ts +14 -3
  187. package/src/tasks-runner/life-cycle.js +37 -2
  188. package/src/tasks-runner/life-cycles/task-history-life-cycle-old.d.ts +2 -0
  189. package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +15 -7
  190. package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +5 -0
  191. package/src/tasks-runner/life-cycles/task-history-life-cycle.js +35 -5
  192. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +18 -0
  193. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +230 -0
  194. package/src/tasks-runner/pseudo-terminal.d.ts +11 -7
  195. package/src/tasks-runner/pseudo-terminal.js +47 -35
  196. package/src/tasks-runner/run-command.d.ts +4 -1
  197. package/src/tasks-runner/run-command.js +219 -63
  198. package/src/tasks-runner/running-tasks/node-child-process.js +4 -11
  199. package/src/tasks-runner/running-tasks/running-task.d.ts +3 -0
  200. package/src/tasks-runner/running-tasks/shared-running-task.d.ts +14 -0
  201. package/src/tasks-runner/running-tasks/shared-running-task.js +30 -0
  202. package/src/tasks-runner/task-env.d.ts +1 -4
  203. package/src/tasks-runner/task-env.js +2 -0
  204. package/src/tasks-runner/task-graph-utils.d.ts +3 -0
  205. package/src/tasks-runner/task-graph-utils.js +31 -2
  206. package/src/tasks-runner/task-orchestrator.d.ts +26 -10
  207. package/src/tasks-runner/task-orchestrator.js +221 -57
  208. package/src/tasks-runner/tasks-runner.d.ts +1 -0
  209. package/src/tasks-runner/tasks-schedule.d.ts +1 -0
  210. package/src/tasks-runner/tasks-schedule.js +9 -0
  211. package/src/tasks-runner/utils.d.ts +2 -2
  212. package/src/tasks-runner/utils.js +18 -12
  213. package/src/utils/child-process.d.ts +4 -0
  214. package/src/utils/child-process.js +23 -30
  215. package/src/utils/command-line-utils.d.ts +1 -1
  216. package/src/utils/find-matching-projects.js +2 -2
  217. package/src/utils/git-utils.d.ts +1 -1
  218. package/src/utils/git-utils.js +8 -3
  219. package/src/utils/handle-errors.js +15 -0
  220. package/src/utils/is-ci.js +4 -1
  221. package/src/utils/is-using-prettier.d.ts +3 -0
  222. package/src/utils/is-using-prettier.js +62 -0
  223. package/src/utils/nx-key.d.ts +7 -0
  224. package/src/utils/nx-key.js +52 -0
  225. package/src/utils/package-json.d.ts +1 -1
  226. package/src/utils/package-json.js +16 -2
  227. package/src/utils/package-manager.js +2 -2
  228. package/src/utils/path.js +1 -1
  229. package/src/utils/require-nx-key.d.ts +1 -0
  230. package/src/utils/require-nx-key.js +22 -0
  231. package/src/utils/workspace-context.d.ts +2 -0
  232. package/src/utils/workspace-context.js +16 -0
  233. package/src/command-line/activate-powerpack/activate-powerpack.d.ts +0 -2
  234. package/src/command-line/activate-powerpack/activate-powerpack.js +0 -34
  235. package/src/command-line/activate-powerpack/command-object.d.ts +0 -6
  236. package/src/command-line/init/implementation/react/write-craco-config.d.ts +0 -1
  237. package/src/command-line/init/implementation/react/write-craco-config.js +0 -61
  238. package/src/migrations/update-17-0-0/move-cache-directory.d.ts +0 -2
  239. package/src/migrations/update-17-0-0/move-cache-directory.js +0 -35
  240. package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +0 -72
  241. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +0 -2
  242. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +0 -122
  243. package/src/migrations/update-17-2-0/move-default-base.d.ts +0 -5
  244. package/src/migrations/update-17-2-0/move-default-base.js +0 -21
  245. package/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
  246. package/src/migrations/update-17-3-0/nx-release-path.js +0 -47
  247. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +0 -2
  248. package/src/utils/powerpack.d.ts +0 -5
  249. package/src/utils/powerpack.js +0 -33
  250. /package/src/migrations/{update-17-0-0/rm-default-collection-npm-scope.d.ts → update-21-0-0/remove-legacy-cache.d.ts} +0 -0
@@ -1,15 +1,18 @@
1
+ import { Serializable } from 'child_process';
1
2
  import { ChildProcess, RustPseudoTerminal } from '../native';
2
3
  import { PseudoIPCServer } from './pseudo-ipc';
3
- import { Serializable } from 'child_process';
4
- export declare function getPseudoTerminal(skipSupportCheck?: boolean): PseudoTerminal;
4
+ import { RunningTask } from './running-tasks/running-task';
5
+ export declare function createPseudoTerminal(skipSupportCheck?: boolean): PseudoTerminal;
5
6
  export declare class PseudoTerminal {
6
7
  private rustPseudoTerminal;
7
8
  private pseudoIPCPath;
8
9
  private pseudoIPC;
9
10
  private initialized;
11
+ private childProcesses;
10
12
  static isSupported(): boolean;
11
13
  constructor(rustPseudoTerminal: RustPseudoTerminal);
12
14
  init(): Promise<void>;
15
+ shutdown(): void;
13
16
  runCommand(command: string, { cwd, execArgv, jsEnv, quiet, tty, }?: {
14
17
  cwd?: string;
15
18
  execArgv?: string[];
@@ -25,16 +28,15 @@ export declare class PseudoTerminal {
25
28
  }): Promise<PseudoTtyProcessWithSend>;
26
29
  sendMessageToChildren(message: Serializable): void;
27
30
  onMessageFromChildren(callback: (message: Serializable) => void): void;
28
- private setupProcessListeners;
29
- private shutdownPseudoIPC;
30
31
  }
31
- export declare class PseudoTtyProcess {
32
+ export declare class PseudoTtyProcess implements RunningTask {
33
+ rustPseudoTerminal: RustPseudoTerminal;
32
34
  private childProcess;
33
35
  isAlive: boolean;
34
36
  private exitCallbacks;
35
37
  private outputCallbacks;
36
38
  private terminalOutput;
37
- constructor(childProcess: ChildProcess);
39
+ constructor(rustPseudoTerminal: RustPseudoTerminal, childProcess: ChildProcess);
38
40
  getResults(): Promise<{
39
41
  code: number;
40
42
  terminalOutput: string;
@@ -42,10 +44,12 @@ export declare class PseudoTtyProcess {
42
44
  onExit(callback: (code: number) => void): void;
43
45
  onOutput(callback: (message: string) => void): void;
44
46
  kill(): void;
47
+ getParserAndWriter(): import("../native").ExternalObject<[ParserArc, WriterArc]>;
45
48
  }
46
49
  export declare class PseudoTtyProcessWithSend extends PseudoTtyProcess {
50
+ rustPseudoTerminal: RustPseudoTerminal;
47
51
  private id;
48
52
  private pseudoIpc;
49
- constructor(_childProcess: ChildProcess, id: string, pseudoIpc: PseudoIPCServer);
53
+ constructor(rustPseudoTerminal: RustPseudoTerminal, _childProcess: ChildProcess, id: string, pseudoIpc: PseudoIPCServer);
50
54
  send(message: Serializable): void;
51
55
  }
@@ -1,29 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PseudoTtyProcessWithSend = exports.PseudoTtyProcess = exports.PseudoTerminal = void 0;
4
- exports.getPseudoTerminal = getPseudoTerminal;
4
+ exports.createPseudoTerminal = createPseudoTerminal;
5
+ const os = require("os");
6
+ const socket_utils_1 = require("../daemon/socket-utils");
5
7
  const native_1 = require("../native");
6
8
  const pseudo_ipc_1 = require("./pseudo-ipc");
7
- const socket_utils_1 = require("../daemon/socket-utils");
8
- const os = require("os");
9
- let pseudoTerminal;
10
- function getPseudoTerminal(skipSupportCheck = false) {
9
+ // Register single event listeners for all pseudo-terminal instances
10
+ const pseudoTerminalShutdownCallbacks = [];
11
+ process.on('SIGINT', () => {
12
+ pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
13
+ });
14
+ process.on('SIGTERM', () => {
15
+ pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
16
+ });
17
+ process.on('SIGHUP', () => {
18
+ pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
19
+ });
20
+ process.on('exit', () => {
21
+ pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
22
+ });
23
+ function createPseudoTerminal(skipSupportCheck = false) {
11
24
  if (!skipSupportCheck && !PseudoTerminal.isSupported()) {
12
25
  throw new Error('Pseudo terminal is not supported on this platform.');
13
26
  }
14
- pseudoTerminal ??= new PseudoTerminal(new native_1.RustPseudoTerminal());
27
+ const pseudoTerminal = new PseudoTerminal(new native_1.RustPseudoTerminal());
28
+ pseudoTerminalShutdownCallbacks.push(pseudoTerminal.shutdown.bind(pseudoTerminal));
15
29
  return pseudoTerminal;
16
30
  }
31
+ let id = 0;
17
32
  class PseudoTerminal {
18
33
  static isSupported() {
19
34
  return process.stdout.isTTY && supportedPtyPlatform();
20
35
  }
21
36
  constructor(rustPseudoTerminal) {
22
37
  this.rustPseudoTerminal = rustPseudoTerminal;
23
- this.pseudoIPCPath = (0, socket_utils_1.getForkedProcessOsSocketPath)(process.pid.toString());
38
+ this.pseudoIPCPath = (0, socket_utils_1.getForkedProcessOsSocketPath)(process.pid.toString() + '-' + id++);
24
39
  this.pseudoIPC = new pseudo_ipc_1.PseudoIPCServer(this.pseudoIPCPath);
25
40
  this.initialized = false;
26
- this.setupProcessListeners();
41
+ this.childProcesses = new Set();
27
42
  }
28
43
  async init() {
29
44
  if (this.initialized) {
@@ -32,14 +47,28 @@ class PseudoTerminal {
32
47
  await this.pseudoIPC.init();
33
48
  this.initialized = true;
34
49
  }
50
+ shutdown() {
51
+ for (const cp of this.childProcesses) {
52
+ try {
53
+ cp.kill();
54
+ }
55
+ catch { }
56
+ }
57
+ if (this.initialized) {
58
+ this.pseudoIPC.close();
59
+ }
60
+ }
35
61
  runCommand(command, { cwd, execArgv, jsEnv, quiet, tty, } = {}) {
36
- return new PseudoTtyProcess(this.rustPseudoTerminal.runCommand(command, cwd, jsEnv, execArgv, quiet, tty));
62
+ const cp = new PseudoTtyProcess(this.rustPseudoTerminal, this.rustPseudoTerminal.runCommand(command, cwd, jsEnv, execArgv, quiet, tty));
63
+ this.childProcesses.add(cp);
64
+ return cp;
37
65
  }
38
66
  async fork(id, script, { cwd, execArgv, jsEnv, quiet, }) {
39
67
  if (!this.initialized) {
40
68
  throw new Error('Call init() before forking processes');
41
69
  }
42
- const cp = new PseudoTtyProcessWithSend(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), id, this.pseudoIPC);
71
+ this.childProcesses.add(cp);
43
72
  await this.pseudoIPC.waitForChildReady(id);
44
73
  return cp;
45
74
  }
@@ -49,32 +78,11 @@ class PseudoTerminal {
49
78
  onMessageFromChildren(callback) {
50
79
  this.pseudoIPC.onMessageFromChildren(callback);
51
80
  }
52
- setupProcessListeners() {
53
- const shutdown = () => {
54
- this.shutdownPseudoIPC();
55
- };
56
- process.on('SIGINT', () => {
57
- this.shutdownPseudoIPC();
58
- });
59
- process.on('SIGTERM', () => {
60
- this.shutdownPseudoIPC();
61
- });
62
- process.on('SIGHUP', () => {
63
- this.shutdownPseudoIPC();
64
- });
65
- process.on('exit', () => {
66
- this.shutdownPseudoIPC();
67
- });
68
- }
69
- shutdownPseudoIPC() {
70
- if (this.initialized) {
71
- this.pseudoIPC.close();
72
- }
73
- }
74
81
  }
75
82
  exports.PseudoTerminal = PseudoTerminal;
76
83
  class PseudoTtyProcess {
77
- constructor(childProcess) {
84
+ constructor(rustPseudoTerminal, childProcess) {
85
+ this.rustPseudoTerminal = rustPseudoTerminal;
78
86
  this.childProcess = childProcess;
79
87
  this.isAlive = true;
80
88
  this.exitCallbacks = [];
@@ -118,11 +126,15 @@ class PseudoTtyProcess {
118
126
  }
119
127
  }
120
128
  }
129
+ getParserAndWriter() {
130
+ return this.childProcess.getParserAndWriter();
131
+ }
121
132
  }
122
133
  exports.PseudoTtyProcess = PseudoTtyProcess;
123
134
  class PseudoTtyProcessWithSend extends PseudoTtyProcess {
124
- constructor(_childProcess, id, pseudoIpc) {
125
- super(_childProcess);
135
+ constructor(rustPseudoTerminal, _childProcess, id, pseudoIpc) {
136
+ super(rustPseudoTerminal, _childProcess);
137
+ this.rustPseudoTerminal = rustPseudoTerminal;
126
138
  this.id = id;
127
139
  this.pseudoIpc = pseudoIpc;
128
140
  }
@@ -17,7 +17,8 @@ export declare function runCommandForTasks(projectsToRun: ProjectGraphProjectNod
17
17
  excludeTaskDependencies: boolean;
18
18
  loadDotEnvFiles: boolean;
19
19
  }): Promise<TaskResults>;
20
- export declare function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nxJson, nxArgs, loadDotEnvFiles, initiatingProject, }: {
20
+ export declare function setEnvVarsBasedOnArgs(nxArgs: NxArgs, loadDotEnvFiles: boolean): void;
21
+ export declare function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nxJson, nxArgs, loadDotEnvFiles, initiatingProject, initiatingTasks, }: {
21
22
  tasks: Task[];
22
23
  projectGraph: ProjectGraph;
23
24
  taskGraph: TaskGraph;
@@ -26,9 +27,11 @@ export declare function invokeTasksRunner({ tasks, projectGraph, taskGraph, life
26
27
  nxArgs: NxArgs;
27
28
  loadDotEnvFiles: boolean;
28
29
  initiatingProject: string | null;
30
+ initiatingTasks: Task[];
29
31
  }): Promise<{
30
32
  [id: string]: TaskResult;
31
33
  }>;
34
+ export declare function constructLifeCycles(lifeCycle: LifeCycle): LifeCycle[];
32
35
  export declare function getRunner(nxArgs: NxArgs, nxJson: NxJsonConfiguration): {
33
36
  tasksRunner: TasksRunner;
34
37
  runnerOptions: any;
@@ -2,26 +2,30 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runCommand = runCommand;
4
4
  exports.runCommandForTasks = runCommandForTasks;
5
+ exports.setEnvVarsBasedOnArgs = setEnvVarsBasedOnArgs;
5
6
  exports.invokeTasksRunner = invokeTasksRunner;
7
+ exports.constructLifeCycles = constructLifeCycles;
6
8
  exports.getRunner = getRunner;
7
9
  exports.getRunnerOptions = getRunnerOptions;
8
10
  const enquirer_1 = require("enquirer");
11
+ const node_path_1 = require("node:path");
12
+ const node_util_1 = require("node:util");
9
13
  const ora = require("ora");
10
- const path_1 = require("path");
11
14
  const nx_json_1 = require("../config/nx-json");
12
15
  const client_1 = require("../daemon/client/client");
13
16
  const create_task_hasher_1 = require("../hasher/create-task-hasher");
14
17
  const hash_task_1 = require("../hasher/hash-task");
15
- const native_1 = require("../native");
18
+ const tasks_execution_hooks_1 = require("../project-graph/plugins/tasks-execution-hooks");
16
19
  const project_graph_1 = require("../project-graph/project-graph");
17
- const fileutils_1 = require("../utils/fileutils");
20
+ const handle_errors_1 = require("../utils/handle-errors");
18
21
  const is_ci_1 = require("../utils/is-ci");
19
22
  const nx_cloud_utils_1 = require("../utils/nx-cloud-utils");
23
+ const nx_key_1 = require("../utils/nx-key");
20
24
  const output_1 = require("../utils/output");
21
- const handle_errors_1 = require("../utils/handle-errors");
22
25
  const sync_generators_1 = require("../utils/sync-generators");
23
26
  const workspace_root_1 = require("../utils/workspace-root");
24
27
  const create_task_graph_1 = require("./create-task-graph");
28
+ const is_tui_enabled_1 = require("./is-tui-enabled");
25
29
  const life_cycle_1 = require("./life-cycle");
26
30
  const dynamic_run_many_terminal_output_life_cycle_1 = require("./life-cycles/dynamic-run-many-terminal-output-life-cycle");
27
31
  const dynamic_run_one_terminal_output_life_cycle_1 = require("./life-cycles/dynamic-run-one-terminal-output-life-cycle");
@@ -29,21 +33,180 @@ const static_run_many_terminal_output_life_cycle_1 = require("./life-cycles/stat
29
33
  const static_run_one_terminal_output_life_cycle_1 = require("./life-cycles/static-run-one-terminal-output-life-cycle");
30
34
  const store_run_information_life_cycle_1 = require("./life-cycles/store-run-information-life-cycle");
31
35
  const task_history_life_cycle_1 = require("./life-cycles/task-history-life-cycle");
32
- const task_history_life_cycle_old_1 = require("./life-cycles/task-history-life-cycle-old");
33
36
  const task_profiling_life_cycle_1 = require("./life-cycles/task-profiling-life-cycle");
34
- const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
35
37
  const task_results_life_cycle_1 = require("./life-cycles/task-results-life-cycle");
38
+ const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
39
+ const tui_summary_life_cycle_1 = require("./life-cycles/tui-summary-life-cycle");
36
40
  const task_graph_utils_1 = require("./task-graph-utils");
37
41
  const utils_1 = require("./utils");
38
42
  const chalk = require("chalk");
39
- const powerpack_1 = require("../utils/powerpack");
40
- const tasks_execution_hooks_1 = require("../project-graph/plugins/tasks-execution-hooks");
41
- async function getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks, nxArgs, nxJson, overrides) {
43
+ const originalStdoutWrite = process.stdout.write.bind(process.stdout);
44
+ const originalStderrWrite = process.stderr.write.bind(process.stderr);
45
+ const originalConsoleLog = console.log.bind(console);
46
+ const originalConsoleError = console.error.bind(console);
47
+ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, projectNames, tasks, taskGraph, nxArgs, nxJson, overrides) {
48
+ const overridesWithoutHidden = { ...overrides };
49
+ delete overridesWithoutHidden['__overrides_unparsed__'];
50
+ if ((0, is_tui_enabled_1.isTuiEnabled)(nxJson)) {
51
+ const interceptedNxCloudLogs = [];
52
+ const createPatchedConsoleMethod = (originalMethod) => {
53
+ return (...args) => {
54
+ // Check if the log came from the Nx Cloud client, otherwise invoke the original write method
55
+ const stackTrace = new Error().stack;
56
+ const isNxCloudLog = stackTrace.includes((0, node_path_1.join)(workspace_root_1.workspaceRoot, '.nx', 'cache', 'cloud'));
57
+ if (!isNxCloudLog) {
58
+ return originalMethod(...args);
59
+ }
60
+ // No-op the Nx Cloud client logs
61
+ };
62
+ };
63
+ // The cloud client calls console.log when NX_VERBOSE_LOGGING is set to true
64
+ console.log = createPatchedConsoleMethod(originalConsoleLog);
65
+ console.error = createPatchedConsoleMethod(originalConsoleError);
66
+ const patchedWrite = (_chunk, _encoding, callback) => {
67
+ // Preserve original behavior around callback and return value, just in case
68
+ if (callback) {
69
+ callback();
70
+ }
71
+ return true;
72
+ };
73
+ process.stdout.write = patchedWrite;
74
+ process.stderr.write = patchedWrite;
75
+ const { AppLifeCycle, restoreTerminal } = await Promise.resolve().then(() => require('../native'));
76
+ let appLifeCycle;
77
+ const isRunOne = initiatingProject != null;
78
+ const pinnedTasks = [];
79
+ const taskText = tasks.length === 1 ? 'task' : 'tasks';
80
+ const projectText = projectNames.length === 1 ? 'project' : 'projects';
81
+ let titleText = '';
82
+ if (isRunOne) {
83
+ const mainTaskId = initiatingTasks[0].id;
84
+ pinnedTasks.push(mainTaskId);
85
+ const mainContinuousDependencies = taskGraph.continuousDependencies[mainTaskId];
86
+ if (mainContinuousDependencies.length > 0) {
87
+ pinnedTasks.push(mainContinuousDependencies[0]);
88
+ }
89
+ const [project, target] = mainTaskId.split(':');
90
+ titleText = `${target} ${project}`;
91
+ if (tasks.length > 1) {
92
+ titleText += `, and ${tasks.length - 1} requisite ${taskText}`;
93
+ }
94
+ }
95
+ else {
96
+ titleText =
97
+ nxArgs.targets.join(', ') +
98
+ ` for ${projectNames.length} ${projectText}`;
99
+ if (tasks.length > projectNames.length) {
100
+ titleText += `, and ${tasks.length - projectNames.length} requisite ${taskText}`;
101
+ }
102
+ }
103
+ let resolveRenderIsDonePromise;
104
+ // Default renderIsDone that will be overridden if the TUI is used
105
+ let renderIsDone = new Promise((resolve) => (resolveRenderIsDonePromise = resolve));
106
+ const { lifeCycle: tsLifeCycle, printSummary } = (0, tui_summary_life_cycle_1.getTuiTerminalSummaryLifeCycle)({
107
+ projectNames,
108
+ tasks,
109
+ args: nxArgs,
110
+ overrides: overridesWithoutHidden,
111
+ initiatingProject,
112
+ initiatingTasks,
113
+ resolveRenderIsDonePromise,
114
+ });
115
+ if (tasks.length === 0) {
116
+ renderIsDone = renderIsDone.then(() => {
117
+ // Revert the patched methods
118
+ process.stdout.write = originalStdoutWrite;
119
+ process.stderr.write = originalStderrWrite;
120
+ console.log = originalConsoleLog;
121
+ console.error = originalConsoleError;
122
+ });
123
+ }
124
+ const lifeCycles = [tsLifeCycle];
125
+ // Only run the TUI if there are tasks to run
126
+ if (tasks.length > 0) {
127
+ appLifeCycle = new AppLifeCycle(tasks, pinnedTasks, nxArgs ?? {}, nxJson.tui ?? {}, titleText);
128
+ lifeCycles.unshift(appLifeCycle);
129
+ /**
130
+ * Patch stdout.write and stderr.write methods to pass Nx Cloud client logs to the TUI via the lifecycle
131
+ */
132
+ const createPatchedLogWrite = (originalWrite) => {
133
+ // @ts-ignore
134
+ return (chunk, encoding, callback) => {
135
+ // Check if the log came from the Nx Cloud client, otherwise invoke the original write method
136
+ const stackTrace = new Error().stack;
137
+ const isNxCloudLog = stackTrace.includes((0, node_path_1.join)(workspace_root_1.workspaceRoot, '.nx', 'cache', 'cloud'));
138
+ if (isNxCloudLog) {
139
+ interceptedNxCloudLogs.push(chunk);
140
+ // Do not bother to store logs with only whitespace characters, they aren't relevant for the TUI
141
+ const trimmedChunk = chunk.toString().trim();
142
+ if (trimmedChunk.length) {
143
+ // Remove ANSI escape codes, the TUI will control the formatting
144
+ appLifeCycle?.__setCloudMessage((0, node_util_1.stripVTControlCharacters)(trimmedChunk));
145
+ }
146
+ }
147
+ // Preserve original behavior around callback and return value, just in case
148
+ if (callback) {
149
+ callback();
150
+ }
151
+ return true;
152
+ };
153
+ };
154
+ const createPatchedConsoleMethod = (originalMethod) => {
155
+ return (...args) => {
156
+ // Check if the log came from the Nx Cloud client, otherwise invoke the original write method
157
+ const stackTrace = new Error().stack;
158
+ const isNxCloudLog = stackTrace.includes((0, node_path_1.join)(workspace_root_1.workspaceRoot, '.nx', 'cache', 'cloud'));
159
+ if (!isNxCloudLog) {
160
+ return originalMethod(...args);
161
+ }
162
+ // No-op the Nx Cloud client logs
163
+ };
164
+ };
165
+ process.stdout.write = createPatchedLogWrite(originalStdoutWrite);
166
+ process.stderr.write = createPatchedLogWrite(originalStderrWrite);
167
+ // The cloud client calls console.log when NX_VERBOSE_LOGGING is set to true
168
+ console.log = createPatchedConsoleMethod(originalConsoleLog);
169
+ console.error = createPatchedConsoleMethod(originalConsoleError);
170
+ renderIsDone = new Promise((resolve) => {
171
+ appLifeCycle.__init(() => {
172
+ resolve();
173
+ });
174
+ })
175
+ .then(() => {
176
+ restoreTerminal();
177
+ })
178
+ .finally(() => {
179
+ // Revert the patched methods
180
+ process.stdout.write = originalStdoutWrite;
181
+ process.stderr.write = originalStderrWrite;
182
+ console.log = originalConsoleLog;
183
+ console.error = originalConsoleError;
184
+ // Print the intercepted Nx Cloud logs
185
+ for (const log of interceptedNxCloudLogs) {
186
+ const logString = log.toString().trimStart();
187
+ process.stdout.write(logString);
188
+ if (logString) {
189
+ process.stdout.write('\n');
190
+ }
191
+ }
192
+ });
193
+ }
194
+ return {
195
+ lifeCycle: new life_cycle_1.CompositeLifeCycle(lifeCycles),
196
+ restoreTerminal: () => {
197
+ process.stdout.write = originalStdoutWrite;
198
+ process.stderr.write = originalStderrWrite;
199
+ console.log = originalConsoleLog;
200
+ console.error = originalConsoleError;
201
+ restoreTerminal();
202
+ },
203
+ printSummary,
204
+ renderIsDone,
205
+ };
206
+ }
42
207
  const { runnerOptions } = getRunner(nxArgs, nxJson);
43
208
  const isRunOne = initiatingProject != null;
44
209
  const useDynamicOutput = shouldUseDynamicLifeCycle(tasks, runnerOptions, nxArgs.outputStyle);
45
- const overridesWithoutHidden = { ...overrides };
46
- delete overridesWithoutHidden['__overrides_unparsed__'];
47
210
  if (isRunOne) {
48
211
  if (useDynamicOutput) {
49
212
  return await (0, dynamic_run_one_terminal_output_life_cycle_1.createRunOneDynamicOutputRenderer)({
@@ -77,6 +240,7 @@ async function getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks
77
240
  }
78
241
  function createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies, projectNames, nxArgs, overrides, extraOptions) {
79
242
  const taskGraph = (0, create_task_graph_1.createTaskGraph)(projectGraph, extraTargetDependencies, projectNames, nxArgs.targets, nxArgs.configuration, overrides, extraOptions.excludeTaskDependencies);
243
+ (0, task_graph_utils_1.assertTaskGraphDoesNotContainInvalidTargets)(taskGraph);
80
244
  const cycle = (0, task_graph_utils_1.findCycle)(taskGraph);
81
245
  if (cycle) {
82
246
  if (process.env.NX_IGNORE_CYCLES === 'true' || nxArgs.nxIgnoreCycles) {
@@ -127,26 +291,41 @@ async function runCommand(projectsToRun, currentProjectGraph, { nxJson }, nxArgs
127
291
  }
128
292
  async function runCommandForTasks(projectsToRun, currentProjectGraph, { nxJson }, nxArgs, overrides, initiatingProject, extraTargetDependencies, extraOptions) {
129
293
  const projectNames = projectsToRun.map((t) => t.name);
294
+ const projectNameSet = new Set(projectNames);
130
295
  const { projectGraph, taskGraph } = await ensureWorkspaceIsInSyncAndGetGraphs(currentProjectGraph, nxJson, projectNames, nxArgs, overrides, extraTargetDependencies, extraOptions);
131
296
  const tasks = Object.values(taskGraph.tasks);
132
- const { lifeCycle, renderIsDone } = await getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks, nxArgs, nxJson, overrides);
133
- const taskResults = await invokeTasksRunner({
134
- tasks,
135
- projectGraph,
136
- taskGraph,
137
- lifeCycle,
138
- nxJson,
139
- nxArgs,
140
- loadDotEnvFiles: extraOptions.loadDotEnvFiles,
141
- initiatingProject,
142
- });
143
- await renderIsDone;
144
- await (0, powerpack_1.printPowerpackLicense)();
145
- return taskResults;
297
+ const initiatingTasks = tasks.filter((t) => projectNameSet.has(t.target.project) &&
298
+ nxArgs.targets.includes(t.target.target));
299
+ const { lifeCycle, renderIsDone, printSummary, restoreTerminal } = await getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, projectNames, tasks, taskGraph, nxArgs, nxJson, overrides);
300
+ try {
301
+ const taskResults = await invokeTasksRunner({
302
+ tasks,
303
+ projectGraph,
304
+ taskGraph,
305
+ lifeCycle,
306
+ nxJson,
307
+ nxArgs,
308
+ loadDotEnvFiles: extraOptions.loadDotEnvFiles,
309
+ initiatingProject,
310
+ initiatingTasks,
311
+ });
312
+ await renderIsDone;
313
+ if (printSummary) {
314
+ printSummary();
315
+ }
316
+ await (0, nx_key_1.printNxKey)();
317
+ return taskResults;
318
+ }
319
+ catch (e) {
320
+ if (restoreTerminal) {
321
+ restoreTerminal();
322
+ }
323
+ throw e;
324
+ }
146
325
  }
147
326
  async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, projectNames, nxArgs, overrides, extraTargetDependencies, extraOptions) {
148
327
  let taskGraph = createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies ?? {}, projectNames, nxArgs, overrides, extraOptions);
149
- if (nxArgs.skipSync) {
328
+ if (nxArgs.skipSync || (0, is_ci_1.isCI)()) {
150
329
  return { projectGraph, taskGraph };
151
330
  }
152
331
  // collect unique syncGenerators from the tasks
@@ -166,9 +345,8 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, project
166
345
  const outOfSyncTitle = 'The workspace is out of sync';
167
346
  const resultBodyLines = (0, sync_generators_1.getSyncGeneratorSuccessResultsMessageLines)(results);
168
347
  const fixMessage = 'Make sure to run `nx sync` to apply the identified changes or set `sync.applyChanges` to `true` in your `nx.json` to apply them automatically when running tasks in interactive environments.';
169
- const willErrorOnCiMessage = 'This will result in an error in CI.';
170
- if ((0, is_ci_1.isCI)() || !process.stdout.isTTY) {
171
- // If the user is running in CI or is running in a non-TTY environment we
348
+ if (!process.stdout.isTTY) {
349
+ // If the user is running a non-TTY environment we
172
350
  // throw an error to stop the execution of the tasks.
173
351
  if (areAllResultsFailures) {
174
352
  output_1.output.error({
@@ -216,7 +394,6 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, project
216
394
  ...resultBodyLines,
217
395
  '',
218
396
  'Your workspace is set to not apply the identified changes automatically (`sync.applyChanges` is set to `false` in your `nx.json`).',
219
- willErrorOnCiMessage,
220
397
  fixMessage,
221
398
  ],
222
399
  });
@@ -235,10 +412,12 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, project
235
412
  title: outOfSyncTitle,
236
413
  bodyLines: [
237
414
  ...resultBodyLines,
238
- '',
239
- nxJson.sync?.applyChanges === true
240
- ? 'Proceeding to sync the identified changes automatically (`sync.applyChanges` is set to `true` in your `nx.json`).'
241
- : willErrorOnCiMessage,
415
+ ...(nxJson.sync?.applyChanges === true
416
+ ? [
417
+ '',
418
+ 'Proceeding to sync the identified changes automatically (`sync.applyChanges` is set to `true` in your `nx.json`).',
419
+ ]
420
+ : []),
242
421
  ],
243
422
  });
244
423
  const applyChanges = nxJson.sync?.applyChanges === true ||
@@ -377,7 +556,7 @@ function setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles) {
377
556
  process.env.NX_LOAD_DOT_ENV_FILES = 'true';
378
557
  }
379
558
  }
380
- async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nxJson, nxArgs, loadDotEnvFiles, initiatingProject, }) {
559
+ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nxJson, nxArgs, loadDotEnvFiles, initiatingProject, initiatingTasks, }) {
381
560
  setEnvVarsBasedOnArgs(nxArgs, loadDotEnvFiles);
382
561
  // this needs to be done before we start to run the tasks
383
562
  const taskDetails = (0, hash_task_1.getTaskDetails)();
@@ -397,6 +576,7 @@ async function invokeTasksRunner({ tasks, projectGraph, taskGraph, lifeCycle, nx
397
576
  lifeCycle: compositedLifeCycle,
398
577
  }, {
399
578
  initiatingProject: nxArgs.outputStyle === 'compact' ? null : initiatingProject,
579
+ initiatingTasks,
400
580
  projectGraph,
401
581
  nxJson,
402
582
  nxArgs,
@@ -467,10 +647,9 @@ function constructLifeCycles(lifeCycle) {
467
647
  if (process.env.NX_PROFILE) {
468
648
  lifeCycles.push(new task_profiling_life_cycle_1.TaskProfilingLifeCycle(process.env.NX_PROFILE));
469
649
  }
470
- if (!(0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)())) {
471
- lifeCycles.push(process.env.NX_DISABLE_DB !== 'true' && !native_1.IS_WASM
472
- ? new task_history_life_cycle_1.TaskHistoryLifeCycle()
473
- : new task_history_life_cycle_old_1.LegacyTaskHistoryLifeCycle());
650
+ const historyLifeCycle = (0, task_history_life_cycle_1.getTasksHistoryLifeCycle)();
651
+ if (historyLifeCycle) {
652
+ lifeCycles.push(historyLifeCycle);
474
653
  }
475
654
  return lifeCycles;
476
655
  }
@@ -533,15 +712,6 @@ function getRunner(nxArgs, nxJson) {
533
712
  }
534
713
  const modulePath = getTasksRunnerPath(runner, nxJson);
535
714
  try {
536
- if (isCustomRunnerPath(modulePath)) {
537
- output_1.output.warn({
538
- title: `Custom task runners will no longer be supported in Nx 21.`,
539
- bodyLines: [
540
- `Use Nx Cloud or the Nx Powerpack caches instead.`,
541
- `For more information, see https://nx.dev/nx-enterprise/powerpack/custom-caching`,
542
- ],
543
- });
544
- }
545
715
  const tasksRunner = loadTasksRunner(modulePath);
546
716
  return {
547
717
  tasksRunner,
@@ -554,18 +724,12 @@ function getRunner(nxArgs, nxJson) {
554
724
  }
555
725
  const defaultTasksRunnerPath = require.resolve('./default-tasks-runner');
556
726
  function getTasksRunnerPath(runner, nxJson) {
557
- let modulePath = nxJson.tasksRunnerOptions?.[runner]?.runner;
558
- if (modulePath) {
559
- if ((0, fileutils_1.isRelativePath)(modulePath)) {
560
- return (0, path_1.join)(workspace_root_1.workspaceRoot, modulePath);
561
- }
562
- return modulePath;
563
- }
564
727
  const isCloudRunner =
565
728
  // No tasksRunnerOptions for given --runner
566
729
  nxJson.nxCloudAccessToken ||
567
730
  // No runner prop in tasks runner options, check if access token is set.
568
731
  nxJson.tasksRunnerOptions?.[runner]?.options?.accessToken ||
732
+ ['nx-cloud', '@nrwl/nx-cloud'].includes(nxJson.tasksRunnerOptions?.[runner]?.runner) ||
569
733
  // Cloud access token specified in env var.
570
734
  process.env.NX_CLOUD_ACCESS_TOKEN ||
571
735
  // Nx Cloud ID specified in nxJson
@@ -614,11 +778,3 @@ function getRunnerOptions(runner, nxJson, nxArgs, isCloudDefault) {
614
778
  }
615
779
  return result;
616
780
  }
617
- function isCustomRunnerPath(modulePath) {
618
- return ![
619
- 'nx-cloud',
620
- '@nrwl/nx-cloud',
621
- 'nx/tasks-runners/default',
622
- defaultTasksRunnerPath,
623
- ].includes(modulePath);
624
- }
@@ -153,18 +153,11 @@ class NodeChildProcessWithDirectOutput {
153
153
  this.exitCallbacks.push(cb);
154
154
  }
155
155
  async getResults() {
156
- const terminalOutput = this.getTerminalOutput();
157
- if (this.exited) {
158
- return Promise.resolve({
159
- code: this.exitCode,
160
- terminalOutput,
161
- });
156
+ if (!this.exited) {
157
+ await this.waitForExit();
162
158
  }
163
- await this.waitForExit();
164
- return Promise.resolve({
165
- code: this.exitCode,
166
- terminalOutput,
167
- });
159
+ const terminalOutput = this.getTerminalOutput();
160
+ return { code: this.exitCode, terminalOutput };
168
161
  }
169
162
  waitForExit() {
170
163
  return new Promise((res) => {
@@ -1,3 +1,4 @@
1
+ import type { Serializable } from 'child_process';
1
2
  export declare abstract class RunningTask {
2
3
  abstract getResults(): Promise<{
3
4
  code: number;
@@ -5,4 +6,6 @@ export declare abstract class RunningTask {
5
6
  }>;
6
7
  abstract onExit(cb: (code: number) => void): void;
7
8
  abstract kill(signal?: NodeJS.Signals | number): Promise<void> | void;
9
+ abstract onOutput?(cb: (output: string) => void): void;
10
+ abstract send?(message: Serializable): void;
8
11
  }
@@ -0,0 +1,14 @@
1
+ import { RunningTask } from './running-task';
2
+ import { RunningTasksService } from '../../native';
3
+ export declare class SharedRunningTask implements RunningTask {
4
+ private runningTasksService;
5
+ private exitCallbacks;
6
+ constructor(runningTasksService: RunningTasksService, taskId: string);
7
+ getResults(): Promise<{
8
+ code: number;
9
+ terminalOutput: string;
10
+ }>;
11
+ kill(): void;
12
+ onExit(cb: (code: number) => void): void;
13
+ private waitForTaskToFinish;
14
+ }