nx 23.0.0-beta.2 → 23.0.0-beta.21

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 (274) hide show
  1. package/dist/bin/init-local.js +11 -20
  2. package/dist/bin/nx.d.ts +1 -0
  3. package/dist/bin/nx.js +28 -2
  4. package/dist/plugins/package-json.js +4 -2
  5. package/dist/src/adapter/ngcli-adapter.d.ts +2 -1
  6. package/dist/src/adapter/ngcli-adapter.js +25 -2
  7. package/dist/src/ai/clone-ai-config-repo.js +20 -3
  8. package/dist/src/analytics/analytics.js +10 -1
  9. package/dist/src/command-line/add/completion.d.ts +1 -0
  10. package/dist/src/command-line/add/completion.js +15 -0
  11. package/dist/src/command-line/affected/completion.d.ts +1 -0
  12. package/dist/src/command-line/affected/completion.js +15 -0
  13. package/dist/src/command-line/completion/argv-layout.d.ts +6 -0
  14. package/dist/src/command-line/completion/argv-layout.js +19 -0
  15. package/dist/src/command-line/completion/command-completions.d.ts +19 -0
  16. package/dist/src/command-line/completion/command-completions.js +120 -0
  17. package/dist/src/command-line/completion/command-handlers.d.ts +30 -0
  18. package/dist/src/command-line/completion/command-handlers.js +69 -0
  19. package/dist/src/command-line/completion/command-object.d.ts +10 -0
  20. package/dist/src/command-line/completion/command-object.js +95 -0
  21. package/dist/src/command-line/completion/completion-providers.d.ts +21 -0
  22. package/dist/src/command-line/completion/completion-providers.js +194 -0
  23. package/dist/src/command-line/completion/infix-targets.d.ts +1 -0
  24. package/dist/src/command-line/completion/infix-targets.js +48 -0
  25. package/dist/src/command-line/completion/metadata.d.ts +22 -0
  26. package/dist/src/command-line/completion/metadata.js +71 -0
  27. package/dist/src/command-line/completion/registrations.d.ts +9 -0
  28. package/dist/src/command-line/completion/registrations.js +16 -0
  29. package/dist/src/command-line/completion/scripts/bash.sh +51 -0
  30. package/dist/src/command-line/completion/scripts/fish.fish +47 -0
  31. package/dist/src/command-line/completion/scripts/powershell.ps1 +52 -0
  32. package/dist/src/command-line/completion/scripts/zsh.zsh +69 -0
  33. package/dist/src/command-line/completion/scripts.d.ts +18 -0
  34. package/dist/src/command-line/completion/scripts.js +140 -0
  35. package/dist/src/command-line/completion/trigger.d.ts +3 -0
  36. package/dist/src/command-line/completion/trigger.js +21 -0
  37. package/dist/src/command-line/completion/value-completions.d.ts +3 -0
  38. package/dist/src/command-line/completion/value-completions.js +21 -0
  39. package/dist/src/command-line/examples.js +1 -1
  40. package/dist/src/command-line/format/format.js +15 -5
  41. package/dist/src/command-line/generate/completion.d.ts +1 -0
  42. package/dist/src/command-line/generate/completion.js +9 -0
  43. package/dist/src/command-line/graph/completion.d.ts +1 -0
  44. package/dist/src/command-line/graph/completion.js +13 -0
  45. package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +14 -18
  46. package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +1 -0
  47. package/dist/src/command-line/init/implementation/utils.d.ts +7 -1
  48. package/dist/src/command-line/init/implementation/utils.js +51 -14
  49. package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +22 -0
  50. package/dist/src/command-line/migrate/agentic/capture-generator-output.js +100 -0
  51. package/dist/src/command-line/migrate/agentic/cli-args.d.ts +12 -0
  52. package/dist/src/command-line/migrate/agentic/cli-args.js +38 -0
  53. package/dist/src/command-line/migrate/agentic/definitions.d.ts +6 -0
  54. package/dist/src/command-line/migrate/agentic/definitions.js +98 -0
  55. package/dist/src/command-line/migrate/agentic/detect-installed.d.ts +10 -0
  56. package/dist/src/command-line/migrate/agentic/detect-installed.js +68 -0
  57. package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +46 -0
  58. package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +87 -0
  59. package/dist/src/command-line/migrate/agentic/handoff.d.ts +63 -0
  60. package/dist/src/command-line/migrate/agentic/handoff.js +183 -0
  61. package/dist/src/command-line/migrate/agentic/inception.d.ts +9 -0
  62. package/dist/src/command-line/migrate/agentic/inception.js +15 -0
  63. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +22 -0
  64. package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +50 -0
  65. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +51 -0
  66. package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +65 -0
  67. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +44 -0
  68. package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +52 -0
  69. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +21 -0
  70. package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +26 -0
  71. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +18 -0
  72. package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +130 -0
  73. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +46 -0
  74. package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +88 -0
  75. package/dist/src/command-line/migrate/agentic/run-step.d.ts +51 -0
  76. package/dist/src/command-line/migrate/agentic/run-step.js +121 -0
  77. package/dist/src/command-line/migrate/agentic/runner.d.ts +33 -0
  78. package/dist/src/command-line/migrate/agentic/runner.js +442 -0
  79. package/dist/src/command-line/migrate/agentic/select.d.ts +14 -0
  80. package/dist/src/command-line/migrate/agentic/select.js +150 -0
  81. package/dist/src/command-line/migrate/agentic/types.d.ts +102 -0
  82. package/dist/src/command-line/migrate/agentic/types.js +2 -0
  83. package/dist/src/command-line/migrate/command-object.d.ts +1 -0
  84. package/dist/src/command-line/migrate/command-object.js +32 -7
  85. package/dist/src/command-line/migrate/migrate-commits.d.ts +50 -0
  86. package/dist/src/command-line/migrate/migrate-commits.js +102 -0
  87. package/dist/src/command-line/migrate/migrate-output.d.ts +180 -0
  88. package/dist/src/command-line/migrate/migrate-output.js +258 -0
  89. package/dist/src/command-line/migrate/migrate.d.ts +122 -12
  90. package/dist/src/command-line/migrate/migrate.js +1036 -217
  91. package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
  92. package/dist/src/command-line/migrate/migration-shape.js +13 -0
  93. package/dist/src/command-line/migrate/multi-major.d.ts +30 -0
  94. package/dist/src/command-line/migrate/multi-major.js +185 -0
  95. package/dist/src/command-line/migrate/prompt-files.d.ts +31 -0
  96. package/dist/src/command-line/migrate/prompt-files.js +141 -0
  97. package/dist/src/command-line/migrate/run-migration-process.js +28 -6
  98. package/dist/src/command-line/migrate/safe-prompt.d.ts +28 -0
  99. package/dist/src/command-line/migrate/safe-prompt.js +49 -0
  100. package/dist/src/command-line/migrate/update-filters.d.ts +11 -0
  101. package/dist/src/command-line/migrate/update-filters.js +44 -0
  102. package/dist/src/command-line/migrate/version-utils.d.ts +6 -0
  103. package/dist/src/command-line/migrate/version-utils.js +59 -0
  104. package/dist/src/command-line/nx-commands.js +9 -0
  105. package/dist/src/command-line/release/config/config.d.ts +3 -6
  106. package/dist/src/command-line/release/config/config.js +77 -45
  107. package/dist/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
  108. package/dist/src/command-line/release/config/use-legacy-versioning.js +8 -0
  109. package/dist/src/command-line/release/utils/release-graph.js +2 -3
  110. package/dist/src/command-line/release/utils/repository-git-tags.js +1 -1
  111. package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +7 -19
  112. package/dist/src/command-line/release/version/resolve-current-version.js +1 -1
  113. package/dist/src/command-line/release/version/version-actions.js +3 -7
  114. package/dist/src/command-line/report/report.js +2 -2
  115. package/dist/src/command-line/run/completion.d.ts +1 -0
  116. package/dist/src/command-line/run/completion.js +7 -0
  117. package/dist/src/command-line/run-many/completion.d.ts +1 -0
  118. package/dist/src/command-line/run-many/completion.js +13 -0
  119. package/dist/src/command-line/show/completion.d.ts +1 -0
  120. package/dist/src/command-line/show/completion.js +27 -0
  121. package/dist/src/command-line/show/show-target/info.d.ts +1 -0
  122. package/dist/src/command-line/show/show-target/info.js +100 -19
  123. package/dist/src/command-line/watch/command-object.js +24 -4
  124. package/dist/src/command-line/watch/completion.d.ts +1 -0
  125. package/dist/src/command-line/watch/completion.js +10 -0
  126. package/dist/src/command-line/watch/watch.d.ts +7 -0
  127. package/dist/src/command-line/watch/watch.js +1 -1
  128. package/dist/src/config/misc-interfaces.d.ts +25 -2
  129. package/dist/src/config/nx-json.d.ts +43 -56
  130. package/dist/src/config/schema-utils.d.ts +21 -0
  131. package/dist/src/config/schema-utils.js +92 -18
  132. package/dist/src/config/task-graph.d.ts +4 -107
  133. package/dist/src/core/graph/main.js +1 -1
  134. package/dist/src/core/graph/styles.css +2 -3
  135. package/dist/src/core/graph/styles.js +1 -1
  136. package/dist/src/daemon/client/client.d.ts +1 -1
  137. package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +1 -1
  138. package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +1 -1
  139. package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +9 -0
  140. package/dist/src/daemon/server/file-watching/route-workspace-changes.js +76 -0
  141. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +45 -11
  142. package/dist/src/daemon/server/server.js +4 -43
  143. package/dist/src/daemon/server/start.d.ts +1 -1
  144. package/dist/src/daemon/server/start.js +2 -0
  145. package/dist/src/devkit-exports.d.ts +2 -2
  146. package/dist/src/devkit-internals.d.ts +5 -1
  147. package/dist/src/devkit-internals.js +17 -1
  148. package/dist/src/executors/run-commands/running-tasks.d.ts +7 -0
  149. package/dist/src/executors/run-commands/running-tasks.js +178 -105
  150. package/dist/src/executors/run-script/run-script.impl.js +3 -10
  151. package/dist/src/executors/utils/convert-nx-executor.js +1 -1
  152. package/dist/src/hasher/hash-plan-inspector.d.ts +1 -1
  153. package/dist/src/hasher/task-hasher.js +6 -4
  154. package/dist/src/index.d.ts +1 -1
  155. package/dist/src/index.js +0 -3
  156. package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +6 -2
  157. package/dist/src/migrations/update-17-0-0/move-cache-directory.md +31 -0
  158. package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +20 -4
  159. package/dist/src/migrations/update-20-0-0/move-use-daemon-process.md +27 -0
  160. package/dist/src/migrations/update-20-0-1/use-legacy-cache.md +24 -0
  161. package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.md +49 -0
  162. package/dist/src/migrations/update-21-0-0/release-version-config-changes.md +54 -0
  163. package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.md +28 -0
  164. package/dist/src/migrations/update-21-0-0/remove-legacy-cache.md +22 -0
  165. package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.md +11 -0
  166. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.d.ts +2 -0
  167. package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +16 -0
  168. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +9 -0
  169. package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +18 -0
  170. package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.d.ts +35 -0
  171. package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.js +139 -0
  172. package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.md +66 -0
  173. package/dist/src/native/index.d.ts +79 -2
  174. package/dist/src/native/native-bindings.js +3 -0
  175. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  176. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  177. package/dist/src/plugins/js/lock-file/npm-parser.js +37 -19
  178. package/dist/src/plugins/js/lock-file/pnpm-parser.js +51 -4
  179. package/dist/src/plugins/js/lock-file/project-graph-pruning.js +12 -4
  180. package/dist/src/plugins/js/utils/packages.js +1 -1
  181. package/dist/src/plugins/js/utils/register.d.ts +103 -14
  182. package/dist/src/plugins/js/utils/register.js +434 -39
  183. package/dist/src/plugins/js/utils/typescript.d.ts +7 -0
  184. package/dist/src/plugins/js/utils/typescript.js +39 -0
  185. package/dist/src/plugins/package-json/create-nodes.d.ts +3 -2
  186. package/dist/src/plugins/package-json/create-nodes.js +7 -5
  187. package/dist/src/project-graph/affected/locators/project-glob-changes.js +2 -1
  188. package/dist/src/project-graph/build-project-graph.d.ts +5 -0
  189. package/dist/src/project-graph/build-project-graph.js +6 -2
  190. package/dist/src/project-graph/file-map-utils.d.ts +5 -0
  191. package/dist/src/project-graph/file-map-utils.js +10 -1
  192. package/dist/src/project-graph/plugins/get-plugins.d.ts +7 -2
  193. package/dist/src/project-graph/plugins/get-plugins.js +8 -5
  194. package/dist/src/project-graph/plugins/isolation/plugin-worker.d.ts +1 -0
  195. package/dist/src/project-graph/plugins/isolation/plugin-worker.js +2 -0
  196. package/dist/src/project-graph/plugins/resolve-plugin.d.ts +7 -4
  197. package/dist/src/project-graph/plugins/resolve-plugin.js +152 -33
  198. package/dist/src/project-graph/plugins/tasks-execution-hooks.js +4 -2
  199. package/dist/src/project-graph/plugins/transpiler.d.ts +12 -0
  200. package/dist/src/project-graph/plugins/transpiler.js +37 -0
  201. package/dist/src/project-graph/plugins/utils.js +13 -7
  202. package/dist/src/project-graph/project-graph.js +1 -1
  203. package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +95 -4
  204. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +515 -68
  205. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +13 -5
  206. package/dist/src/project-graph/utils/project-configuration-utils.js +14 -6
  207. package/dist/src/project-graph/utils/retrieve-workspace-files.js +1 -1
  208. package/dist/src/tasks-runner/create-task-graph.d.ts +4 -4
  209. package/dist/src/tasks-runner/create-task-graph.js +1 -1
  210. package/dist/src/tasks-runner/default-tasks-runner.d.ts +0 -2
  211. package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
  212. package/dist/src/tasks-runner/forked-process-task-runner.js +11 -6
  213. package/dist/src/tasks-runner/init-tasks-runner.d.ts +0 -15
  214. package/dist/src/tasks-runner/init-tasks-runner.js +0 -63
  215. package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +18 -0
  216. package/dist/src/tasks-runner/legacy-depends-on-warning.js +109 -0
  217. package/dist/src/tasks-runner/life-cycle.d.ts +7 -8
  218. package/dist/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +6 -6
  219. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +13 -2
  220. package/dist/src/tasks-runner/life-cycles/task-history-life-cycle.js +16 -5
  221. package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +11 -2
  222. package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
  223. package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
  224. package/dist/src/tasks-runner/run-command.js +8 -11
  225. package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +1 -1
  226. package/dist/src/tasks-runner/running-tasks/batch-process.js +3 -5
  227. package/dist/src/tasks-runner/running-tasks/node-child-process.d.ts +2 -2
  228. package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -7
  229. package/dist/src/tasks-runner/task-env.d.ts +1 -1
  230. package/dist/src/tasks-runner/task-env.js +6 -1
  231. package/dist/src/tasks-runner/task-orchestrator.d.ts +11 -1
  232. package/dist/src/tasks-runner/task-orchestrator.js +112 -38
  233. package/dist/src/tasks-runner/tasks-schedule.js +3 -3
  234. package/dist/src/tasks-runner/utils.d.ts +7 -8
  235. package/dist/src/tasks-runner/utils.js +23 -27
  236. package/dist/src/utils/child-process.js +2 -2
  237. package/dist/src/utils/compile-cache.d.ts +24 -0
  238. package/dist/src/utils/compile-cache.js +49 -0
  239. package/dist/src/utils/enable-compile-cache.d.ts +1 -0
  240. package/dist/src/utils/enable-compile-cache.js +7 -0
  241. package/dist/src/utils/fileutils.d.ts +0 -8
  242. package/dist/src/utils/fileutils.js +0 -40
  243. package/dist/src/utils/git-utils.d.ts +15 -0
  244. package/dist/src/utils/git-utils.js +138 -0
  245. package/dist/src/utils/handle-import.d.ts +4 -1
  246. package/dist/src/utils/handle-import.js +56 -2
  247. package/dist/src/utils/has-nx-js-plugin.d.ts +9 -0
  248. package/dist/src/utils/has-nx-js-plugin.js +24 -0
  249. package/dist/src/utils/installed-nx-version.d.ts +14 -4
  250. package/dist/src/utils/installed-nx-version.js +54 -7
  251. package/dist/src/utils/logger.d.ts +12 -1
  252. package/dist/src/utils/logger.js +57 -36
  253. package/dist/src/utils/nx-key.d.ts +0 -1
  254. package/dist/src/utils/nx-key.js +20 -23
  255. package/dist/src/utils/nx-package-group.d.ts +8 -0
  256. package/dist/src/utils/nx-package-group.js +15 -0
  257. package/dist/src/utils/output.d.ts +3 -2
  258. package/dist/src/utils/output.js +29 -28
  259. package/dist/src/utils/package-json.d.ts +14 -1
  260. package/dist/src/utils/package-json.js +20 -21
  261. package/dist/src/utils/perf-logging.js +3 -1
  262. package/dist/src/utils/plugin-cache-utils.d.ts +13 -4
  263. package/dist/src/utils/plugin-cache-utils.js +23 -13
  264. package/dist/src/utils/plugins/local-plugins.d.ts +18 -0
  265. package/dist/src/utils/plugins/local-plugins.js +30 -0
  266. package/dist/src/utils/tar.d.ts +8 -0
  267. package/dist/src/utils/tar.js +44 -0
  268. package/migrations.json +16 -0
  269. package/package.json +28 -28
  270. package/schemas/nx-schema.json +114 -80
  271. package/dist/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +0 -7
  272. package/dist/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +0 -155
  273. package/dist/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +0 -16
  274. package/dist/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +0 -121
@@ -13,7 +13,7 @@ export type { WorkspaceJsonConfiguration, ProjectsConfigurations, TargetDependen
13
13
  /**
14
14
  * @category Workspace
15
15
  */
16
- export type { Generator, Migration, GeneratorCallback, PromiseExecutor, AsyncIteratorExecutor, Executor, ExecutorContext, TaskGraphExecutor, GeneratorsJson, ExecutorsJson, MigrationsJson, CustomHasher, HasherContext, } from './config/misc-interfaces';
16
+ export type { Generator, Migration, MigrationReturnObject, GeneratorCallback, PromiseExecutor, AsyncIteratorExecutor, Executor, ExecutorContext, TaskGraphExecutor, GeneratorsJson, ExecutorsJson, MigrationsJson, CustomHasher, HasherContext, } from './config/misc-interfaces';
17
17
  export { workspaceLayout } from './config/configuration';
18
18
  export type { NxPlugin, NxPluginV2, CreateNodesResult, CreateNodesContextV2, CreateNodesFunctionV2, CreateNodesResultV2, CreateNodesV2, CreateDependencies, CreateDependenciesContext, CreateMetadata, CreateMetadataContext, ProjectsMetadata, PreTasksExecution, PreTasksExecutionContext, PostTasksExecution, PostTasksExecutionContext, } from './project-graph/plugins';
19
19
  export { AggregateCreateNodesError, StaleProjectGraphCacheError, } from './project-graph/error-types';
@@ -29,7 +29,7 @@ export type { TaskResult, TaskResults } from './tasks-runner/life-cycle';
29
29
  /**
30
30
  * @category Workspace
31
31
  */
32
- export type { ImplicitDependencyEntry, ImplicitJsonSubsetDependency, NxJsonConfiguration, PluginConfiguration, ExpandedPluginConfiguration, TargetDefaults, NxAffectedConfig, } from './config/nx-json';
32
+ export type { ImplicitDependencyEntry, ImplicitJsonSubsetDependency, NxJsonConfiguration, PluginConfiguration, ExpandedPluginConfiguration, TargetDefaults, TargetDefaultEntry, TargetDefaultsRecord, NxAffectedConfig, } from './config/nx-json';
33
33
  /**
34
34
  * @category Logger
35
35
  */
@@ -11,6 +11,7 @@ export { retrieveProjectConfigurationsWithAngularProjects } from './project-grap
11
11
  export { mergeTargetConfigurations } from './project-graph/utils/project-configuration/target-merging';
12
12
  export { readProjectConfigurationsFromRootMap } from './project-graph/utils/project-configuration/project-nodes-manager';
13
13
  export { findMatchingConfigFiles } from './project-graph/utils/project-configuration-utils';
14
+ export { readTargetDefaultsForTarget, normalizeTargetDefaultsAgainstRootMaps, } from './project-graph/utils/project-configuration/target-defaults';
14
15
  export { getIgnoreObjectForTree } from './utils/ignore';
15
16
  export { splitTarget } from './utils/split-target';
16
17
  export { combineOptionsForExecutor } from './utils/params';
@@ -24,7 +25,7 @@ export { createProjectRootMappingsFromProjectConfigurations, createProjectRootMa
24
25
  export { retrieveProjectConfigurations } from './project-graph/utils/retrieve-workspace-files';
25
26
  export { LoadedNxPlugin } from './project-graph/plugins/loaded-nx-plugin';
26
27
  export * from './project-graph/error-types';
27
- export { registerTsProject } from './plugins/js/utils/register';
28
+ export { registerTsProject, loadTsFile, forceRegisterEsmLoader, requireWithTsconfigFallback, } from './plugins/js/utils/register';
28
29
  export { interpolate } from './tasks-runner/utils';
29
30
  export { isCI } from './utils/is-ci';
30
31
  export { isUsingPrettierInTree } from './utils/is-using-prettier';
@@ -33,3 +34,6 @@ export { globalSpinner } from './utils/spinner';
33
34
  export { signalToCode } from './utils/exit-codes';
34
35
  export { handleImport } from './utils/handle-import';
35
36
  export { PluginCache, safeWriteFileCache } from './utils/plugin-cache-utils';
37
+ export { emitPluginWorkerLog } from './project-graph/plugins/isolation/worker-streaming';
38
+ export { resolveImplementation, resolveSchema, ImplementationResolutionError, SchemaResolutionError, } from './config/schema-utils';
39
+ export { resolvePrompt, PromptResolutionError, } from './command-line/migrate/prompt-files';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.safeWriteFileCache = exports.PluginCache = exports.handleImport = exports.signalToCode = exports.globalSpinner = exports.readYamlFile = exports.isUsingPrettierInTree = exports.isCI = exports.interpolate = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappings = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashMultiGlobWithWorkspaceContext = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.installPackageToTmpAsync = exports.installPackageToTmp = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.getIgnoreObjectForTree = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.parseExecutor = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
3
+ exports.PromptResolutionError = exports.resolvePrompt = exports.SchemaResolutionError = exports.ImplementationResolutionError = exports.resolveSchema = exports.resolveImplementation = exports.emitPluginWorkerLog = exports.safeWriteFileCache = exports.PluginCache = exports.handleImport = exports.signalToCode = exports.globalSpinner = exports.readYamlFile = exports.isUsingPrettierInTree = exports.isCI = exports.interpolate = exports.requireWithTsconfigFallback = exports.forceRegisterEsmLoader = exports.loadTsFile = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappings = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashMultiGlobWithWorkspaceContext = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.installPackageToTmpAsync = exports.installPackageToTmp = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.getIgnoreObjectForTree = exports.normalizeTargetDefaultsAgainstRootMaps = exports.readTargetDefaultsForTarget = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.parseExecutor = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  /**
6
6
  * Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
@@ -24,6 +24,9 @@ var project_nodes_manager_1 = require("./project-graph/utils/project-configurati
24
24
  Object.defineProperty(exports, "readProjectConfigurationsFromRootMap", { enumerable: true, get: function () { return project_nodes_manager_1.readProjectConfigurationsFromRootMap; } });
25
25
  var project_configuration_utils_1 = require("./project-graph/utils/project-configuration-utils");
26
26
  Object.defineProperty(exports, "findMatchingConfigFiles", { enumerable: true, get: function () { return project_configuration_utils_1.findMatchingConfigFiles; } });
27
+ var target_defaults_1 = require("./project-graph/utils/project-configuration/target-defaults");
28
+ Object.defineProperty(exports, "readTargetDefaultsForTarget", { enumerable: true, get: function () { return target_defaults_1.readTargetDefaultsForTarget; } });
29
+ Object.defineProperty(exports, "normalizeTargetDefaultsAgainstRootMaps", { enumerable: true, get: function () { return target_defaults_1.normalizeTargetDefaultsAgainstRootMaps; } });
27
30
  var ignore_1 = require("./utils/ignore");
28
31
  Object.defineProperty(exports, "getIgnoreObjectForTree", { enumerable: true, get: function () { return ignore_1.getIgnoreObjectForTree; } });
29
32
  var split_target_1 = require("./utils/split-target");
@@ -56,6 +59,9 @@ Object.defineProperty(exports, "LoadedNxPlugin", { enumerable: true, get: functi
56
59
  tslib_1.__exportStar(require("./project-graph/error-types"), exports);
57
60
  var register_1 = require("./plugins/js/utils/register");
58
61
  Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return register_1.registerTsProject; } });
62
+ Object.defineProperty(exports, "loadTsFile", { enumerable: true, get: function () { return register_1.loadTsFile; } });
63
+ Object.defineProperty(exports, "forceRegisterEsmLoader", { enumerable: true, get: function () { return register_1.forceRegisterEsmLoader; } });
64
+ Object.defineProperty(exports, "requireWithTsconfigFallback", { enumerable: true, get: function () { return register_1.requireWithTsconfigFallback; } });
59
65
  var utils_1 = require("./tasks-runner/utils");
60
66
  Object.defineProperty(exports, "interpolate", { enumerable: true, get: function () { return utils_1.interpolate; } });
61
67
  var is_ci_1 = require("./utils/is-ci");
@@ -73,3 +79,13 @@ Object.defineProperty(exports, "handleImport", { enumerable: true, get: function
73
79
  var plugin_cache_utils_1 = require("./utils/plugin-cache-utils");
74
80
  Object.defineProperty(exports, "PluginCache", { enumerable: true, get: function () { return plugin_cache_utils_1.PluginCache; } });
75
81
  Object.defineProperty(exports, "safeWriteFileCache", { enumerable: true, get: function () { return plugin_cache_utils_1.safeWriteFileCache; } });
82
+ var worker_streaming_1 = require("./project-graph/plugins/isolation/worker-streaming");
83
+ Object.defineProperty(exports, "emitPluginWorkerLog", { enumerable: true, get: function () { return worker_streaming_1.emitPluginWorkerLog; } });
84
+ var schema_utils_1 = require("./config/schema-utils");
85
+ Object.defineProperty(exports, "resolveImplementation", { enumerable: true, get: function () { return schema_utils_1.resolveImplementation; } });
86
+ Object.defineProperty(exports, "resolveSchema", { enumerable: true, get: function () { return schema_utils_1.resolveSchema; } });
87
+ Object.defineProperty(exports, "ImplementationResolutionError", { enumerable: true, get: function () { return schema_utils_1.ImplementationResolutionError; } });
88
+ Object.defineProperty(exports, "SchemaResolutionError", { enumerable: true, get: function () { return schema_utils_1.SchemaResolutionError; } });
89
+ var prompt_files_1 = require("./command-line/migrate/prompt-files");
90
+ Object.defineProperty(exports, "resolvePrompt", { enumerable: true, get: function () { return prompt_files_1.resolvePrompt; } });
91
+ Object.defineProperty(exports, "PromptResolutionError", { enumerable: true, get: function () { return prompt_files_1.PromptResolutionError; } });
@@ -9,6 +9,9 @@ export declare class ParallelRunningTasks implements RunningTask {
9
9
  private readonly streamOutput;
10
10
  private exitCallbacks;
11
11
  private outputCallbacks;
12
+ private exited;
13
+ private exitCode;
14
+ private exitTerminalOutput;
12
15
  constructor(options: NormalizedRunCommandsOptions, context: ExecutorContext, taskId: string);
13
16
  getResults(): Promise<{
14
17
  code: number;
@@ -18,6 +21,7 @@ export declare class ParallelRunningTasks implements RunningTask {
18
21
  onExit(cb: (code: number, terminalOutput: string) => void): void;
19
22
  send(message: Serializable): void;
20
23
  kill(signal?: NodeJS.Signals): Promise<void>;
24
+ private emitExit;
21
25
  private run;
22
26
  private terminateRemainingProcesses;
23
27
  }
@@ -30,7 +34,10 @@ export declare class SeriallyRunningTasks implements RunningTask {
30
34
  private code;
31
35
  private error;
32
36
  private outputCallbacks;
37
+ private exited;
38
+ private exitTerminalOutput;
33
39
  constructor(options: NormalizedRunCommandsOptions, context: ExecutorContext, tuiEnabled: boolean, taskId: string);
40
+ private emitExit;
34
41
  getResults(): Promise<{
35
42
  code: number;
36
43
  terminalOutput: string;
@@ -7,7 +7,7 @@ const pc = tslib_1.__importStar(require("picocolors"));
7
7
  const child_process_1 = require("child_process");
8
8
  const npm_run_path_1 = require("npm-run-path");
9
9
  const path_1 = require("path");
10
- const tree_kill_1 = tslib_1.__importDefault(require("tree-kill"));
10
+ const native_1 = require("../../native");
11
11
  const pseudo_terminal_1 = require("../../tasks-runner/pseudo-terminal");
12
12
  const task_env_1 = require("../../tasks-runner/task-env");
13
13
  const task_io_service_1 = require("../../tasks-runner/task-io-service");
@@ -16,12 +16,19 @@ class ParallelRunningTasks {
16
16
  constructor(options, context, taskId) {
17
17
  this.exitCallbacks = [];
18
18
  this.outputCallbacks = [];
19
+ // Memoized exit so late getResults()/onExit() callers don't hang.
20
+ this.exited = false;
21
+ this.exitCode = 0;
22
+ this.exitTerminalOutput = '';
19
23
  this.childProcesses = options.commands.map((commandConfig) => new RunningNodeProcess(commandConfig, options.color, calculateCwd(options.cwd, context), options.env ?? {}, options.readyWhenStatus, options.streamOutput, options.envFile, taskId));
20
24
  this.readyWhenStatus = options.readyWhenStatus;
21
25
  this.streamOutput = options.streamOutput;
22
26
  this.run();
23
27
  }
24
28
  async getResults() {
29
+ if (this.exited) {
30
+ return { code: this.exitCode, terminalOutput: this.exitTerminalOutput };
31
+ }
25
32
  return new Promise((res) => {
26
33
  this.onExit((code, terminalOutput) => {
27
34
  res({ code, terminalOutput });
@@ -32,6 +39,10 @@ class ParallelRunningTasks {
32
39
  this.outputCallbacks.push(cb);
33
40
  }
34
41
  onExit(cb) {
42
+ if (this.exited) {
43
+ cb(this.exitCode, this.exitTerminalOutput);
44
+ return;
45
+ }
35
46
  this.exitCallbacks.push(cb);
36
47
  }
37
48
  send(message) {
@@ -40,14 +51,17 @@ class ParallelRunningTasks {
40
51
  }
41
52
  }
42
53
  async kill(signal) {
43
- await Promise.all(this.childProcesses.map(async (p) => {
44
- try {
45
- return p.kill();
46
- }
47
- catch (e) {
48
- console.error(`Unable to terminate "${p.command}"\nError:`, e);
49
- }
50
- }));
54
+ await Promise.allSettled(this.childProcesses.map((p) => p.kill(signal)));
55
+ }
56
+ emitExit(code, terminalOutput) {
57
+ if (this.exited)
58
+ return;
59
+ this.exited = true;
60
+ this.exitCode = code;
61
+ this.exitTerminalOutput = terminalOutput;
62
+ for (const cb of this.exitCallbacks) {
63
+ cb(code, terminalOutput);
64
+ }
51
65
  }
52
66
  async run() {
53
67
  if (this.readyWhenStatus.length) {
@@ -71,9 +85,7 @@ class ParallelRunningTasks {
71
85
  process.stderr.write(output);
72
86
  }
73
87
  }
74
- for (const cb of this.exitCallbacks) {
75
- cb(code, terminalOutput);
76
- }
88
+ this.emitExit(code, terminalOutput);
77
89
  }
78
90
  else {
79
91
  const runningProcesses = new Set();
@@ -93,7 +105,7 @@ class ParallelRunningTasks {
93
105
  hasFailure = true;
94
106
  failureDetails = { childProcess, code, terminalOutput };
95
107
  // Immediately terminate all other running processes
96
- await this.terminateRemainingProcesses(runningProcesses, childProcess);
108
+ this.terminateRemainingProcesses(runningProcesses, childProcess);
97
109
  }
98
110
  runningProcesses.delete(childProcess);
99
111
  }));
@@ -105,36 +117,18 @@ class ParallelRunningTasks {
105
117
  if (this.streamOutput) {
106
118
  process.stderr.write(output);
107
119
  }
108
- for (const cb of this.exitCallbacks) {
109
- cb(1, terminalOutput);
110
- }
120
+ this.emitExit(1, terminalOutput);
111
121
  }
112
122
  else {
113
- for (const cb of this.exitCallbacks) {
114
- cb(0, terminalOutput);
115
- }
123
+ this.emitExit(0, terminalOutput);
116
124
  }
117
125
  }
118
126
  }
119
- async terminateRemainingProcesses(runningProcesses, failedProcess) {
120
- const terminationPromises = [];
127
+ terminateRemainingProcesses(runningProcesses, failedProcess) {
121
128
  const processesToTerminate = [...runningProcesses].filter((p) => p !== failedProcess);
122
129
  for (const process of processesToTerminate) {
123
130
  runningProcesses.delete(process);
124
- // Terminate the process
125
- terminationPromises.push(process.kill('SIGTERM').catch((err) => {
126
- // Log error but don't fail the entire operation
127
- if (this.streamOutput) {
128
- console.error(`Failed to terminate process "${process.command}":`, err);
129
- }
130
- }));
131
- }
132
- // Wait for all terminations to complete with a timeout
133
- if (terminationPromises.length > 0) {
134
- await Promise.race([
135
- Promise.all(terminationPromises),
136
- new Promise((resolve) => setTimeout(resolve, 5_000)),
137
- ]);
131
+ process.kill('SIGTERM').catch(() => { });
138
132
  }
139
133
  }
140
134
  }
@@ -148,6 +142,9 @@ class SeriallyRunningTasks {
148
142
  this.exitCallbacks = [];
149
143
  this.code = 0;
150
144
  this.outputCallbacks = [];
145
+ // Memoized exit so late getResults()/onExit() callers don't hang.
146
+ this.exited = false;
147
+ this.exitTerminalOutput = '';
151
148
  this.run(options, context)
152
149
  .catch((e) => {
153
150
  this.error = e;
@@ -155,12 +152,28 @@ class SeriallyRunningTasks {
155
152
  .finally(() => {
156
153
  const terminalOutput = this.terminalOutputChunks.join('');
157
154
  this.terminalOutputChunks = [];
158
- for (const cb of this.exitCallbacks) {
159
- cb(this.code, terminalOutput);
160
- }
155
+ this.emitExit(terminalOutput);
161
156
  });
162
157
  }
158
+ emitExit(terminalOutput) {
159
+ if (this.exited)
160
+ return;
161
+ this.exited = true;
162
+ this.exitTerminalOutput = terminalOutput;
163
+ for (const cb of this.exitCallbacks) {
164
+ cb(this.code, terminalOutput);
165
+ }
166
+ }
163
167
  getResults() {
168
+ if (this.exited) {
169
+ if (this.error) {
170
+ return Promise.reject(this.error);
171
+ }
172
+ return Promise.resolve({
173
+ code: this.code,
174
+ terminalOutput: this.exitTerminalOutput,
175
+ });
176
+ }
164
177
  return new Promise((res, rej) => {
165
178
  this.onExit((code, terminalOutput) => {
166
179
  if (this.error) {
@@ -173,6 +186,10 @@ class SeriallyRunningTasks {
173
186
  });
174
187
  }
175
188
  onExit(cb) {
189
+ if (this.exited) {
190
+ cb(this.code, this.exitTerminalOutput);
191
+ return;
192
+ }
176
193
  this.exitCallbacks.push(cb);
177
194
  }
178
195
  onOutput(cb) {
@@ -182,7 +199,7 @@ class SeriallyRunningTasks {
182
199
  throw new Error('Not implemented');
183
200
  }
184
201
  kill(signal) {
185
- return this.currentProcess.kill(signal);
202
+ return this.currentProcess?.kill(signal);
186
203
  }
187
204
  async run(options, context) {
188
205
  for (const c of options.commands) {
@@ -236,6 +253,11 @@ class RunningNodeProcess {
236
253
  this.terminalOutputChunks = [];
237
254
  this.exitCallbacks = [];
238
255
  this.outputCallbacks = [];
256
+ this.killPromise = null;
257
+ // Memoized exit so late getResults()/onExit() callers don't hang.
258
+ this.exited = false;
259
+ this.exitCode = 0;
260
+ this.exitTerminalOutput = '';
239
261
  env = processEnv(color, cwd, env, envFile);
240
262
  this.command = commandConfig.command;
241
263
  const header = pc.dim('> ') + commandConfig.command + '\r\n\r\n';
@@ -245,9 +267,14 @@ class RunningNodeProcess {
245
267
  }
246
268
  this.childProcess = (0, child_process_1.spawn)(commandConfig.command, [], {
247
269
  shell: true,
270
+ detached: process.platform !== 'win32',
248
271
  env,
249
272
  cwd,
250
273
  windowsHide: true,
274
+ stdio: ['inherit', 'pipe', 'pipe'],
275
+ });
276
+ this.closedPromise = new Promise((resolve) => {
277
+ this.childProcess.on('close', resolve);
251
278
  });
252
279
  this.childProcess.stdout?.setEncoding('utf8');
253
280
  this.childProcess.stderr?.setEncoding('utf8');
@@ -259,6 +286,12 @@ class RunningNodeProcess {
259
286
  this.addListeners(commandConfig, streamOutput);
260
287
  }
261
288
  getResults() {
289
+ if (this.exited) {
290
+ return Promise.resolve({
291
+ code: this.exitCode,
292
+ terminalOutput: this.exitTerminalOutput,
293
+ });
294
+ }
262
295
  return new Promise((res) => {
263
296
  this.onExit((code, terminalOutput) => {
264
297
  res({ code, terminalOutput });
@@ -269,24 +302,41 @@ class RunningNodeProcess {
269
302
  this.outputCallbacks.push(cb);
270
303
  }
271
304
  onExit(cb) {
305
+ if (this.exited) {
306
+ cb(this.exitCode, this.exitTerminalOutput);
307
+ return;
308
+ }
272
309
  this.exitCallbacks.push(cb);
273
310
  }
274
311
  send(message) {
275
312
  this.childProcess.send(message);
276
313
  }
314
+ emitExit(code, terminalOutput) {
315
+ if (this.exited)
316
+ return;
317
+ this.exited = true;
318
+ this.exitCode = code;
319
+ this.exitTerminalOutput = terminalOutput;
320
+ for (const cb of this.exitCallbacks) {
321
+ cb(code, terminalOutput);
322
+ }
323
+ }
277
324
  kill(signal) {
278
- return new Promise((res, rej) => {
279
- (0, tree_kill_1.default)(this.childProcess.pid, signal, (err) => {
280
- // On Windows, tree-kill (which uses taskkill) may fail when the process or its child process is already terminated.
281
- // Ignore the errors, otherwise we will log them unnecessarily.
282
- if (err && process.platform !== 'win32') {
283
- rej(err);
284
- }
285
- else {
286
- res();
287
- }
288
- });
289
- });
325
+ if (this.killPromise)
326
+ return this.killPromise;
327
+ if (!this.childProcess.pid)
328
+ return Promise.resolve();
329
+ // Cache the promise so concurrent callers (e.g. cleanup() after a
330
+ // fire-and-forget kill from cleanUpUnneededContinuousTasks) await the
331
+ // same in-progress operation instead of no-oping.
332
+ this.killPromise = (0, native_1.killProcessTreeGraceful)(this.childProcess.pid, signal).then(() =>
333
+ // Wait for stdio drain and close events before the orchestrator
334
+ // tears down the event loop via process.exit().
335
+ Promise.race([
336
+ this.closedPromise,
337
+ new Promise((resolve) => setTimeout(resolve, 1000)),
338
+ ]));
339
+ return this.killPromise;
290
340
  }
291
341
  triggerOutputListeners(output) {
292
342
  for (const cb of this.outputCallbacks) {
@@ -294,6 +344,34 @@ class RunningNodeProcess {
294
344
  }
295
345
  }
296
346
  addListeners(commandConfig, streamOutput) {
347
+ // Named handlers so they can be removed when the child exits.
348
+ // Otherwise each RunningNodeProcess leaks process listeners; with
349
+ // many run-commands tasks this triggers MaxListenersExceededWarning.
350
+ const isForked = !!process.env.NX_FORKED_TASK_EXECUTOR;
351
+ const onProcessExit = () => {
352
+ if (this.childProcess.pid && !this.killPromise) {
353
+ (0, native_1.killProcessTree)(this.childProcess.pid);
354
+ }
355
+ };
356
+ const onSigInt = () => {
357
+ this.kill('SIGTERM');
358
+ };
359
+ const onSigTerm = () => {
360
+ this.kill('SIGTERM');
361
+ };
362
+ const onSigHup = () => {
363
+ this.kill('SIGTERM');
364
+ };
365
+ const removeProcessListeners = () => {
366
+ process.removeListener('exit', onProcessExit);
367
+ if (isForked) {
368
+ process.removeListener('SIGINT', onSigInt);
369
+ process.removeListener('SIGTERM', onSigTerm);
370
+ process.removeListener('SIGHUP', onSigHup);
371
+ }
372
+ };
373
+ this.childProcess.stdout.setEncoding('utf8');
374
+ this.childProcess.stderr.setEncoding('utf8');
297
375
  this.childProcess.stdout.on('data', (data) => {
298
376
  const output = addColorAndPrefix(data, commandConfig);
299
377
  this.terminalOutputChunks.push(output);
@@ -301,8 +379,7 @@ class RunningNodeProcess {
301
379
  if (streamOutput) {
302
380
  process.stdout.write(output);
303
381
  }
304
- if (this.readyWhenStatus.length &&
305
- isReady(this.readyWhenStatus, data.toString())) {
382
+ if (this.readyWhenStatus.length && isReady(this.readyWhenStatus, data)) {
306
383
  for (const cb of this.exitCallbacks) {
307
384
  cb(0, this.terminalOutputChunks.join(''));
308
385
  }
@@ -315,8 +392,7 @@ class RunningNodeProcess {
315
392
  if (streamOutput) {
316
393
  process.stderr.write(output);
317
394
  }
318
- if (this.readyWhenStatus.length &&
319
- isReady(this.readyWhenStatus, err.toString())) {
395
+ if (this.readyWhenStatus.length && isReady(this.readyWhenStatus, err)) {
320
396
  for (const cb of this.exitCallbacks) {
321
397
  cb(1, this.terminalOutputChunks.join(''));
322
398
  }
@@ -331,51 +407,38 @@ class RunningNodeProcess {
331
407
  const terminalOutput = this.terminalOutputChunks.join('');
332
408
  this.terminalOutputChunks = [];
333
409
  removeProcessListeners();
334
- for (const cb of this.exitCallbacks) {
335
- cb(1, terminalOutput);
336
- }
410
+ this.emitExit(1, terminalOutput);
337
411
  });
338
- // Store signal/exit handlers so they can be removed when the child exits.
339
- // Without cleanup, each RunningNodeProcess leaks 4 process listeners.
340
- // In a large monorepo (2600+ run-commands tasks), these accumulate and
341
- // cause a multi-minute synchronous hang at process.exit() as each handler
342
- // calls treeKill on an already-dead PID.
343
- const onExit = () => {
344
- this.kill();
345
- };
346
- const onSigInt = () => {
347
- this.kill('SIGTERM');
348
- };
349
- const onSigTerm = () => {
350
- this.kill('SIGTERM');
351
- };
352
- const onSigHup = () => {
353
- this.kill('SIGTERM');
354
- };
355
- const removeProcessListeners = () => {
356
- process.removeListener('exit', onExit);
357
- process.removeListener('SIGINT', onSigInt);
358
- process.removeListener('SIGTERM', onSigTerm);
359
- process.removeListener('SIGHUP', onSigHup);
360
- };
361
412
  this.childProcess.on('exit', (code, signal) => {
362
413
  if (code === null) {
363
414
  code = (0, exit_codes_1.signalToCode)(signal);
364
415
  }
365
416
  removeProcessListeners();
417
+ const terminalOutput = this.terminalOutputChunks.join('');
418
+ this.terminalOutputChunks = [];
366
419
  if (!this.readyWhenStatus.length || isReady(this.readyWhenStatus)) {
367
- const terminalOutput = this.terminalOutputChunks.join('');
368
- this.terminalOutputChunks = [];
369
- for (const cb of this.exitCallbacks) {
370
- cb(code, terminalOutput);
371
- }
420
+ this.emitExit(code, terminalOutput);
421
+ }
422
+ else if (code !== 0) {
423
+ // Process crashed before readyWhen matched; surface the failure so
424
+ // awaiters unblock. A clean exit (code 0) is left as-is — a parallel
425
+ // companion command may still produce the readyWhen output.
426
+ this.emitExit(code, terminalOutput);
372
427
  }
373
428
  });
374
- // Terminate any task processes on exit
375
- process.on('exit', onExit);
376
- process.on('SIGINT', onSigInt);
377
- process.on('SIGTERM', onSigTerm);
378
- process.on('SIGHUP', onSigHup);
429
+ // Terminate any task processes on exit (sync, last resort).
430
+ // Skip if graceful kill is already in progress — it tracks cleanup
431
+ // subprocesses and we must not interfere with them.
432
+ process.on('exit', onProcessExit);
433
+ // In the direct path, detached children don't get OS SIGINT (own process
434
+ // group via setsid); the orchestrator's cleanup() sends SIGTERM via
435
+ // killProcessTreeGraceful. Signal handlers here are only needed in the
436
+ // forked path where there's no orchestrator to dispatch signals.
437
+ if (isForked) {
438
+ process.on('SIGINT', onSigInt);
439
+ process.on('SIGTERM', onSigTerm);
440
+ process.on('SIGHUP', onSigHup);
441
+ }
379
442
  }
380
443
  }
381
444
  async function runSingleCommandWithPseudoTerminal(normalized, context, taskId) {
@@ -493,21 +556,31 @@ function registerProcessListener(runningTask, pseudoTerminal) {
493
556
  runningTask.send(message);
494
557
  }
495
558
  });
496
- // Terminate any task processes on exit
559
+ // Terminate any task processes on exit (sync, last resort).
560
+ // The per-child exit handlers and PseudoTerminal.shutdown() use the
561
+ // sync killProcessTree for this path. We call kill() here as a
562
+ // best-effort fallback — it returns a Promise but on 'exit' only
563
+ // synchronous work runs, so the initial signal is sent but the
564
+ // grace period won't be awaited. That's acceptable: 'exit' is the
565
+ // last resort after SIGINT/SIGTERM handlers have already had their
566
+ // chance to do graceful shutdown.
497
567
  process.on('exit', () => {
498
568
  runningTask.kill();
499
569
  });
500
- process.on('SIGINT', () => {
501
- runningTask.kill('SIGTERM');
502
- });
503
- process.on('SIGTERM', () => {
504
- runningTask.kill('SIGTERM');
505
- // no exit here because we expect child processes to terminate which
506
- // will store results to the cache and will terminate this process
507
- });
508
- process.on('SIGHUP', () => {
509
- runningTask.kill('SIGTERM');
510
- // no exit here because we expect child processes to terminate which
511
- // will store results to the cache and will terminate this process
512
- });
570
+ // In the direct path, the orchestrator handles signal dispatch to children.
571
+ // These handlers are only needed in the forked path where there's no
572
+ // orchestrator.
573
+ if (process.env.NX_FORKED_TASK_EXECUTOR) {
574
+ process.on('SIGINT', () => {
575
+ Promise.resolve(runningTask.kill('SIGTERM')).finally(() => {
576
+ process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
577
+ });
578
+ });
579
+ process.on('SIGTERM', () => {
580
+ runningTask.kill('SIGTERM');
581
+ });
582
+ process.on('SIGHUP', () => {
583
+ runningTask.kill('SIGTERM');
584
+ });
585
+ }
513
586
  }
@@ -4,7 +4,7 @@ exports.default = default_1;
4
4
  const tslib_1 = require("tslib");
5
5
  const child_process_1 = require("child_process");
6
6
  const path = tslib_1.__importStar(require("path"));
7
- const tree_kill_1 = tslib_1.__importDefault(require("tree-kill"));
7
+ const native_1 = require("../../native");
8
8
  const pseudo_terminal_1 = require("../../tasks-runner/pseudo-terminal");
9
9
  const package_manager_1 = require("../../utils/package-manager");
10
10
  async function default_1(options, context) {
@@ -56,15 +56,8 @@ function nodeProcess(command, cwd, env) {
56
56
  });
57
57
  const exitHandler = (signal) => {
58
58
  if (cp && cp.pid && !cp.killed) {
59
- (0, tree_kill_1.default)(cp.pid, signal, (error) => {
60
- // On Windows, tree-kill (which uses taskkill) may fail when the process or its child process is already terminated.
61
- // Ignore the errors, otherwise we will log them unnecessarily.
62
- if (error && process.platform !== 'win32') {
63
- rej(error);
64
- }
65
- else {
66
- res();
67
- }
59
+ (0, native_1.killProcessTreeGraceful)(cp.pid, signal).finally(() => {
60
+ res();
68
61
  });
69
62
  }
70
63
  };
@@ -17,7 +17,7 @@ function convertNxExecutor(executor) {
17
17
  const builderFunction = (options, builderContext) => {
18
18
  const promise = async () => {
19
19
  const nxJsonConfiguration = (0, nx_json_1.readNxJson)(builderContext.workspaceRoot);
20
- const separatedPlugins = await (0, get_plugins_1.getPluginsSeparated)();
20
+ const separatedPlugins = await (0, get_plugins_1.getPluginsSeparated)(nxJsonConfiguration);
21
21
  const projectsConfigurations = {
22
22
  version: 2,
23
23
  projects: (0, project_nodes_manager_1.readProjectConfigurationsFromRootMap)((await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(separatedPlugins, builderContext.workspaceRoot, nxJsonConfiguration)).projects),
@@ -15,7 +15,7 @@ export declare class HashPlanInspector {
15
15
  /**
16
16
  * This is a lower level method which will inspect the hash plan for a set of tasks.
17
17
  */
18
- inspectHashPlan(projectNames: string[], targets: string[], configuration?: string, overrides?: Object, extraTargetDependencies?: TargetDependencies, excludeTaskDependencies?: boolean): Record<string, string[]>;
18
+ inspectHashPlan(projectNames: string[], targets: string[], configuration?: string, overrides?: Record<string, unknown>, extraTargetDependencies?: TargetDependencies, excludeTaskDependencies?: boolean): Record<string, string[]>;
19
19
  /**
20
20
  * This inspects tasks involved in the execution of a task, including its dependencies by default.
21
21
  * @deprecated Prefer inspectTaskInputs
@@ -125,8 +125,7 @@ function getNamedInputs(nxJson, project) {
125
125
  function getTargetInputs(nxJson, projectNode, target) {
126
126
  const namedInputs = getNamedInputs(nxJson, projectNode);
127
127
  const targetData = projectNode.data.targets[target];
128
- const targetDefaults = (nxJson.targetDefaults || {})[target];
129
- const inputs = splitInputsIntoSelfAndDependencies(targetData.inputs || targetDefaults?.inputs || DEFAULT_INPUTS, namedInputs);
128
+ const inputs = splitInputsIntoSelfAndDependencies(targetData.inputs || DEFAULT_INPUTS, namedInputs);
130
129
  const selfInputs = extractPatternsFromFileSets(inputs.selfInputs);
131
130
  const dependencyInputs = [
132
131
  ...extractPatternsFromFileSets(inputs.depsInputs
@@ -145,8 +144,11 @@ function getInputs(task, projectGraph, nxJson) {
145
144
  const projectNode = projectGraph.nodes[task.target.project];
146
145
  const namedInputs = getNamedInputs(nxJson, projectNode);
147
146
  const targetData = projectNode.data.targets[task.target.target];
148
- const targetDefaults = (nxJson.targetDefaults || {})[task.target.target];
149
- const { selfInputs, depsInputs, depsOutputs, projectInputs, depsFilesets } = splitInputsIntoSelfAndDependencies(targetData.inputs || targetDefaults?.inputs || DEFAULT_INPUTS, namedInputs);
147
+ // See `getTargetInputs` graph construction already merged any
148
+ // matching target-default's `inputs` onto `targetData.inputs`, so a
149
+ // separate `targetDefaults` lookup here would either repeat that
150
+ // work or drift from it.
151
+ const { selfInputs, depsInputs, depsOutputs, projectInputs, depsFilesets } = splitInputsIntoSelfAndDependencies(targetData.inputs || DEFAULT_INPUTS, namedInputs);
150
152
  return { selfInputs, depsInputs, depsOutputs, projectInputs, depsFilesets };
151
153
  }
152
154
  function splitInputsIntoSelfAndDependencies(inputs, namedInputs) {
@@ -1 +1 @@
1
- export { initTasksRunner } from './tasks-runner/init-tasks-runner';
1
+ export {};