nx 17.0.3 → 17.0.5

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 (320) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -4
  3. package/bin/init-local.js +10 -60
  4. package/bin/nx-cloud.js +6 -0
  5. package/bin/nx.js +1 -9
  6. package/bin/post-install.js +5 -1
  7. package/bin/run-executor.js +1 -1
  8. package/migrations.json +18 -0
  9. package/package.json +21 -18
  10. package/plugins/package-json.js +1 -1
  11. package/{changelog-renderer → release/changelog-renderer}/index.d.ts +18 -3
  12. package/{changelog-renderer → release/changelog-renderer}/index.js +78 -34
  13. package/release/index.d.ts +4 -0
  14. package/release/index.js +11 -0
  15. package/schemas/nx-schema.json +203 -19
  16. package/schemas/project-schema.json +20 -0
  17. package/src/adapter/angular-json.js +28 -18
  18. package/src/adapter/compat.d.ts +2 -2
  19. package/src/adapter/compat.js +6 -1
  20. package/src/adapter/ngcli-adapter.d.ts +16 -4
  21. package/src/adapter/ngcli-adapter.js +85 -28
  22. package/src/command-line/add/add.d.ts +2 -0
  23. package/src/command-line/add/add.js +169 -0
  24. package/src/command-line/add/command-object.d.ts +7 -0
  25. package/src/command-line/add/command-object.js +24 -0
  26. package/src/command-line/affected/affected.js +0 -3
  27. package/src/command-line/affected/command-object.d.ts +4 -4
  28. package/src/command-line/affected/command-object.js +53 -26
  29. package/src/command-line/affected/print-affected.js +10 -1
  30. package/src/command-line/connect/command-object.d.ts +1 -2
  31. package/src/command-line/connect/command-object.js +3 -7
  32. package/src/command-line/connect/connect-to-nx-cloud.d.ts +4 -5
  33. package/src/command-line/connect/connect-to-nx-cloud.js +43 -31
  34. package/src/command-line/connect/view-logs.js +5 -21
  35. package/src/command-line/examples.js +18 -0
  36. package/src/command-line/exec/command-object.js +2 -1
  37. package/src/command-line/exec/exec.d.ts +1 -1
  38. package/src/command-line/exec/exec.js +78 -35
  39. package/src/command-line/format/format.js +13 -4
  40. package/src/command-line/generate/generate.js +9 -9
  41. package/src/command-line/generate/generator-utils.d.ts +3 -2
  42. package/src/command-line/generate/generator-utils.js +5 -5
  43. package/src/command-line/graph/graph.d.ts +1 -1
  44. package/src/command-line/graph/graph.js +82 -37
  45. package/src/command-line/init/command-object.js +70 -43
  46. package/src/command-line/init/implementation/add-nx-to-monorepo.d.ts +4 -2
  47. package/src/command-line/init/implementation/add-nx-to-monorepo.js +11 -2
  48. package/src/command-line/init/implementation/add-nx-to-nest.d.ts +1 -1
  49. package/src/command-line/init/implementation/add-nx-to-nest.js +9 -6
  50. package/src/command-line/init/implementation/add-nx-to-npm-repo.d.ts +4 -2
  51. package/src/command-line/init/implementation/add-nx-to-npm-repo.js +14 -4
  52. package/src/command-line/init/implementation/angular/index.js +4 -1
  53. package/src/command-line/init/implementation/angular/legacy-angular-versions.js +10 -5
  54. package/src/command-line/init/implementation/angular/standalone-workspace.js +1 -1
  55. package/src/command-line/init/implementation/angular/types.d.ts +1 -1
  56. package/src/command-line/init/implementation/dot-nx/nxw.js +47 -16
  57. package/src/command-line/init/implementation/react/index.d.ts +1 -1
  58. package/src/command-line/init/implementation/react/index.js +4 -2
  59. package/src/command-line/init/implementation/react/rename-js-to-jsx.js +4 -2
  60. package/src/command-line/init/implementation/utils.d.ts +5 -5
  61. package/src/command-line/init/implementation/utils.js +46 -44
  62. package/src/command-line/init/{init.js → init-v1.js} +5 -13
  63. package/src/command-line/init/init-v2.d.ts +7 -0
  64. package/src/command-line/init/init-v2.js +201 -0
  65. package/src/command-line/list/list.js +6 -5
  66. package/src/command-line/migrate/command-object.js +19 -4
  67. package/src/command-line/migrate/migrate.js +21 -17
  68. package/src/command-line/new/new.js +1 -1
  69. package/src/command-line/nx-commands.js +4 -1
  70. package/src/command-line/release/changelog.d.ts +22 -1
  71. package/src/command-line/release/changelog.js +459 -257
  72. package/src/command-line/release/command-object.d.ts +29 -7
  73. package/src/command-line/release/command-object.js +120 -20
  74. package/src/command-line/release/config/config.d.ts +26 -21
  75. package/src/command-line/release/config/config.js +416 -59
  76. package/src/command-line/release/config/conventional-commits.d.ts +2 -0
  77. package/src/command-line/release/config/conventional-commits.js +98 -0
  78. package/src/command-line/release/config/filter-release-groups.d.ts +1 -2
  79. package/src/command-line/release/config/filter-release-groups.js +38 -1
  80. package/src/command-line/release/index.d.ts +16 -0
  81. package/src/command-line/release/index.js +23 -0
  82. package/src/command-line/release/publish.d.ts +7 -3
  83. package/src/command-line/release/publish.js +89 -37
  84. package/src/command-line/release/release.d.ts +4 -0
  85. package/src/command-line/release/release.js +176 -0
  86. package/src/command-line/release/utils/batch-projects-by-generator-config.d.ts +7 -0
  87. package/src/command-line/release/utils/batch-projects-by-generator-config.js +37 -0
  88. package/src/command-line/release/utils/exec-command.d.ts +1 -0
  89. package/src/command-line/release/utils/exec-command.js +34 -0
  90. package/src/command-line/release/utils/git.d.ts +34 -1
  91. package/src/command-line/release/utils/git.js +238 -34
  92. package/src/command-line/release/utils/github.d.ts +5 -5
  93. package/src/command-line/release/utils/github.js +155 -8
  94. package/src/command-line/release/utils/markdown.js +6 -1
  95. package/src/command-line/release/utils/print-changes.d.ts +1 -1
  96. package/src/command-line/release/utils/print-changes.js +3 -3
  97. package/src/command-line/release/utils/resolve-nx-json-error-message.js +4 -1
  98. package/src/command-line/release/utils/resolve-semver-specifier.d.ts +4 -0
  99. package/src/command-line/release/utils/resolve-semver-specifier.js +58 -0
  100. package/src/command-line/release/utils/semver.d.ts +8 -0
  101. package/src/command-line/release/utils/semver.js +30 -1
  102. package/src/command-line/release/utils/shared.d.ts +39 -0
  103. package/src/command-line/release/utils/shared.js +213 -0
  104. package/src/command-line/release/version.d.ts +37 -3
  105. package/src/command-line/release/version.js +312 -117
  106. package/src/command-line/repair/repair.js +13 -9
  107. package/src/command-line/report/report.d.ts +3 -0
  108. package/src/command-line/report/report.js +22 -5
  109. package/src/command-line/run/command-object.d.ts +4 -0
  110. package/src/command-line/run/command-object.js +18 -2
  111. package/src/command-line/run/executor-utils.d.ts +2 -1
  112. package/src/command-line/run/executor-utils.js +4 -4
  113. package/src/command-line/run/run-one.js +3 -6
  114. package/src/command-line/run/run.js +34 -9
  115. package/src/command-line/run-many/command-object.js +4 -1
  116. package/src/command-line/run-many/run-many.js +0 -3
  117. package/src/command-line/show/command-object.d.ts +3 -0
  118. package/src/command-line/show/command-object.js +29 -2
  119. package/src/command-line/show/show.js +9 -0
  120. package/src/command-line/yargs-utils/shared-options.d.ts +4 -1
  121. package/src/command-line/yargs-utils/shared-options.js +23 -9
  122. package/src/commands-runner/command-graph.d.ts +13 -0
  123. package/src/commands-runner/command-graph.js +2 -0
  124. package/src/commands-runner/create-command-graph.d.ts +4 -0
  125. package/src/commands-runner/create-command-graph.js +44 -0
  126. package/src/commands-runner/get-command-projects.d.ts +3 -0
  127. package/src/commands-runner/get-command-projects.js +19 -0
  128. package/src/config/nx-json.d.ts +160 -25
  129. package/src/config/project-graph.d.ts +3 -3
  130. package/src/config/workspace-json-project-json.d.ts +23 -1
  131. package/src/config/workspaces.d.ts +1 -1
  132. package/src/config/workspaces.js +4 -6
  133. package/src/core/graph/3rdpartylicenses.txt +144 -74
  134. package/src/core/graph/environment.js +1 -1
  135. package/src/core/graph/index.html +4 -6
  136. package/src/core/graph/main.js +1 -1
  137. package/src/core/graph/runtime.js +1 -1
  138. package/src/core/graph/styles.css +3 -3
  139. package/src/core/graph/styles.js +1 -1
  140. package/src/daemon/client/client.d.ts +5 -1
  141. package/src/daemon/client/client.js +27 -8
  142. package/src/daemon/client/{socket-messenger.d.ts → daemon-socket-messenger.d.ts} +1 -1
  143. package/src/daemon/client/{socket-messenger.js → daemon-socket-messenger.js} +3 -3
  144. package/src/daemon/daemon-project-graph-error.d.ts +8 -0
  145. package/src/daemon/daemon-project-graph-error.js +13 -0
  146. package/src/daemon/server/handle-hash-tasks.js +12 -2
  147. package/src/daemon/server/handle-request-project-graph.js +1 -1
  148. package/src/daemon/server/project-graph-incremental-recomputation.d.ts +14 -13
  149. package/src/daemon/server/project-graph-incremental-recomputation.js +98 -33
  150. package/src/daemon/server/shutdown-utils.js +2 -4
  151. package/src/daemon/server/watcher.js +0 -3
  152. package/src/daemon/socket-utils.d.ts +2 -1
  153. package/src/daemon/socket-utils.js +15 -4
  154. package/src/daemon/tmp-dir.d.ts +1 -0
  155. package/src/daemon/tmp-dir.js +4 -4
  156. package/src/devkit-exports.d.ts +2 -2
  157. package/src/devkit-exports.js +3 -2
  158. package/src/devkit-internals.d.ts +3 -0
  159. package/src/devkit-internals.js +7 -1
  160. package/src/executors/noop/schema.json +1 -1
  161. package/src/executors/run-commands/run-commands.impl.d.ts +10 -2
  162. package/src/executors/run-commands/run-commands.impl.js +152 -48
  163. package/src/executors/run-commands/schema.json +11 -1
  164. package/src/executors/run-script/run-script.impl.js +43 -11
  165. package/src/executors/utils/convert-nx-executor.js +1 -1
  166. package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +3 -1
  167. package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +4 -2
  168. package/src/generators/testing-utils/create-tree-with-empty-workspace.js +0 -6
  169. package/src/generators/tree.d.ts +1 -0
  170. package/src/generators/utils/glob.js +2 -2
  171. package/src/generators/utils/project-configuration.js +28 -9
  172. package/src/hasher/create-task-hasher.d.ts +4 -0
  173. package/src/hasher/create-task-hasher.js +16 -0
  174. package/src/hasher/hash-task.js +9 -3
  175. package/src/hasher/native-task-hasher-impl.d.ts +19 -0
  176. package/src/hasher/native-task-hasher-impl.js +37 -0
  177. package/src/hasher/node-task-hasher-impl.d.ts +49 -0
  178. package/src/hasher/node-task-hasher-impl.js +431 -0
  179. package/src/hasher/task-hasher.d.ts +33 -21
  180. package/src/hasher/task-hasher.js +30 -428
  181. package/src/migrations/update-15-0-0/migrate-to-inputs.js +5 -5
  182. package/src/migrations/update-15-1-0/set-project-names.js +2 -1
  183. package/src/migrations/update-15-8-2/update-nxw.js +2 -6
  184. package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +3 -3
  185. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +49 -13
  186. package/src/migrations/update-17-2-0/move-default-base.d.ts +5 -0
  187. package/src/migrations/update-17-2-0/move-default-base.js +21 -0
  188. package/src/migrations/update-17-3-0/nx-release-path.d.ts +3 -0
  189. package/src/migrations/update-17-3-0/nx-release-path.js +48 -0
  190. package/src/migrations/update-17-3-0/update-nxw.d.ts +2 -0
  191. package/src/migrations/update-17-3-0/update-nxw.js +7 -0
  192. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +2 -0
  193. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +9 -0
  194. package/src/native/index.d.ts +65 -15
  195. package/src/native/index.js +6 -2
  196. package/src/native/transform-objects.js +2 -0
  197. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +1 -0
  198. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +13 -12
  199. package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +6 -1
  200. package/src/nx-cloud/update-manager.js +2 -1
  201. package/src/plugins/js/index.d.ts +1 -1
  202. package/src/plugins/js/index.js +3 -3
  203. package/src/plugins/js/lock-file/lock-file.d.ts +2 -2
  204. package/src/plugins/js/lock-file/lock-file.js +15 -3
  205. package/src/plugins/js/package-json/create-package-json.js +1 -1
  206. package/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +1 -1
  207. package/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +1 -1
  208. package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +1 -1
  209. package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +1 -1
  210. package/src/plugins/js/utils/register.d.ts +1 -1
  211. package/src/plugins/js/utils/register.js +28 -8
  212. package/src/plugins/js/versions.d.ts +1 -1
  213. package/src/plugins/js/versions.js +1 -1
  214. package/{plugins/package-json-workspaces.d.ts → src/plugins/package-json-workspaces/create-nodes.d.ts} +4 -4
  215. package/{plugins/package-json-workspaces.js → src/plugins/package-json-workspaces/create-nodes.js} +34 -12
  216. package/src/plugins/package-json-workspaces/index.d.ts +1 -0
  217. package/src/plugins/package-json-workspaces/index.js +4 -0
  218. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +2 -0
  219. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +47 -0
  220. package/src/plugins/project-json/build-nodes/project-json.d.ts +2 -5
  221. package/src/plugins/project-json/build-nodes/project-json.js +6 -44
  222. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +66 -0
  223. package/src/plugins/target-defaults/target-defaults-plugin.js +182 -0
  224. package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
  225. package/src/project-graph/affected/locators/workspace-projects.d.ts +0 -2
  226. package/src/project-graph/affected/locators/workspace-projects.js +16 -29
  227. package/src/project-graph/build-project-graph.d.ts +20 -1
  228. package/src/project-graph/build-project-graph.js +91 -33
  229. package/src/project-graph/file-map-utils.d.ts +9 -5
  230. package/src/project-graph/file-map-utils.js +16 -63
  231. package/src/project-graph/file-utils.d.ts +1 -1
  232. package/src/project-graph/file-utils.js +44 -2
  233. package/src/project-graph/nx-deps-cache.js +1 -1
  234. package/src/project-graph/project-graph-builder.d.ts +1 -1
  235. package/src/project-graph/project-graph-builder.js +1 -1
  236. package/src/project-graph/project-graph.d.ts +32 -1
  237. package/src/project-graph/project-graph.js +147 -23
  238. package/src/project-graph/utils/build-all-workspace-files.d.ts +2 -0
  239. package/src/project-graph/utils/build-all-workspace-files.js +15 -0
  240. package/src/project-graph/utils/normalize-project-nodes.d.ts +2 -3
  241. package/src/project-graph/utils/normalize-project-nodes.js +7 -33
  242. package/src/project-graph/utils/project-configuration-utils.d.ts +66 -4
  243. package/src/project-graph/utils/project-configuration-utils.js +509 -62
  244. package/src/project-graph/utils/retrieve-workspace-files.d.ts +12 -31
  245. package/src/project-graph/utils/retrieve-workspace-files.js +27 -90
  246. package/src/tasks-runner/batch/run-batch.js +3 -3
  247. package/src/tasks-runner/cache.js +6 -3
  248. package/src/tasks-runner/create-task-graph.js +1 -1
  249. package/src/tasks-runner/fork.d.ts +1 -0
  250. package/src/tasks-runner/fork.js +23 -0
  251. package/src/tasks-runner/forked-process-task-runner.d.ts +13 -5
  252. package/src/tasks-runner/forked-process-task-runner.js +112 -21
  253. package/src/tasks-runner/init-tasks-runner.js +1 -1
  254. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +28 -28
  255. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +19 -22
  256. package/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.js +1 -3
  257. package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +1 -3
  258. package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +2 -4
  259. package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +1 -0
  260. package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +11 -5
  261. package/src/tasks-runner/life-cycles/view-logs-utils.js +1 -1
  262. package/src/tasks-runner/pseudo-ipc.d.ts +49 -0
  263. package/src/tasks-runner/pseudo-ipc.js +140 -0
  264. package/src/tasks-runner/pseudo-terminal.d.ts +43 -0
  265. package/src/tasks-runner/pseudo-terminal.js +159 -0
  266. package/src/tasks-runner/run-command.d.ts +1 -1
  267. package/src/tasks-runner/run-command.js +13 -19
  268. package/src/tasks-runner/task-env.js +1 -2
  269. package/src/tasks-runner/task-graph-utils.d.ts +7 -3
  270. package/src/tasks-runner/task-graph-utils.js +15 -15
  271. package/src/tasks-runner/task-orchestrator.js +68 -12
  272. package/src/tasks-runner/tasks-schedule.js +3 -3
  273. package/src/tasks-runner/utils.d.ts +16 -7
  274. package/src/tasks-runner/utils.js +30 -16
  275. package/src/utils/ab-testing.d.ts +36 -2
  276. package/src/utils/ab-testing.js +34 -16
  277. package/src/utils/assert-workspace-validity.js +1 -1
  278. package/src/utils/cache-directory.d.ts +1 -0
  279. package/src/utils/cache-directory.js +5 -1
  280. package/src/utils/child-process.d.ts +15 -1
  281. package/src/utils/child-process.js +91 -1
  282. package/src/utils/command-line-utils.js +2 -1
  283. package/src/utils/exit-codes.d.ts +6 -0
  284. package/src/utils/exit-codes.js +20 -0
  285. package/src/utils/fileutils.d.ts +1 -0
  286. package/src/utils/find-matching-projects.js +5 -5
  287. package/src/utils/find-workspace-root.js +1 -0
  288. package/src/utils/ignore.js +8 -1
  289. package/src/utils/json-diff.d.ts +1 -0
  290. package/src/utils/json-diff.js +2 -1
  291. package/src/utils/json.js +3 -1
  292. package/src/utils/logger.js +1 -1
  293. package/src/utils/nx-cloud-utils.d.ts +1 -1
  294. package/src/utils/nx-cloud-utils.js +9 -4
  295. package/src/utils/nx-plugin.d.ts +32 -15
  296. package/src/utils/nx-plugin.deprecated.d.ts +10 -5
  297. package/src/utils/nx-plugin.deprecated.js +23 -0
  298. package/src/utils/nx-plugin.js +71 -80
  299. package/src/utils/output.d.ts +4 -2
  300. package/src/utils/output.js +44 -9
  301. package/src/utils/package-json.d.ts +4 -4
  302. package/src/utils/package-json.js +18 -12
  303. package/src/utils/package-manager.d.ts +7 -0
  304. package/src/utils/package-manager.js +24 -4
  305. package/src/utils/params.d.ts +12 -4
  306. package/src/utils/params.js +37 -4
  307. package/src/utils/plugins/core-plugins.js +8 -0
  308. package/src/utils/plugins/installed-plugins.d.ts +2 -1
  309. package/src/utils/plugins/installed-plugins.js +2 -2
  310. package/src/utils/plugins/local-plugins.js +1 -1
  311. package/src/utils/plugins/plugin-capabilities.d.ts +3 -2
  312. package/src/utils/plugins/plugin-capabilities.js +7 -7
  313. package/src/utils/typescript.js +1 -1
  314. package/src/utils/update-nxw.d.ts +2 -0
  315. package/src/utils/update-nxw.js +12 -0
  316. package/src/utils/workspace-configuration-check.js +1 -1
  317. package/src/utils/workspace-context.d.ts +6 -4
  318. package/src/utils/workspace-context.js +19 -9
  319. package/src/core/graph/polyfills.js +0 -1
  320. /package/src/command-line/init/{init.d.ts → init-v1.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHost = exports.scheduleTarget = exports.createBuilderContext = void 0;
3
+ exports.getLogger = exports.wrapAngularDevkitSchematic = exports.mockSchematicsForTesting = exports.runMigration = exports.generate = exports.NxScopeHostUsedForWrappedSchematics = exports.arrayBufferToString = exports.NxScopedHostForBuilders = exports.NxScopedHost = exports.scheduleTarget = exports.createBuilderContext = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const node_1 = require("@angular-devkit/core/node");
6
6
  const chalk = require("chalk");
@@ -22,10 +22,13 @@ const executor_utils_1 = require("../command-line/run/executor-utils");
22
22
  const nx_plugin_1 = require("../utils/nx-plugin");
23
23
  const schema_utils_1 = require("../config/schema-utils");
24
24
  async function createBuilderContext(builderInfo, context) {
25
- require('nx/src/adapter/compat');
26
- const fsHost = new NxScopedHost(context.root);
27
- const { workspace } = await core_1.workspaces.readWorkspace('angular.json', core_1.workspaces.createWorkspaceHost(fsHost));
28
- const architectHost = await getWrappedWorkspaceNodeModulesArchitectHost(workspace, context.root);
25
+ require('./compat');
26
+ const fsHost = new NxScopedHostForBuilders(context.root);
27
+ // the top level import is not patched because it is imported before the
28
+ // patching happens so we require it here to use the patched version below
29
+ const { workspaces } = require('@angular-devkit/core');
30
+ const { workspace } = await workspaces.readWorkspace('angular.json', workspaces.createWorkspaceHost(fsHost));
31
+ const architectHost = await getWrappedWorkspaceNodeModulesArchitectHost(workspace, context.root, context.projectsConfigurations.projects);
29
32
  const registry = new core_1.schema.CoreSchemaRegistry();
30
33
  registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
31
34
  registry.addSmartDefaultProvider('unparsed', () => {
@@ -41,6 +44,28 @@ async function createBuilderContext(builderInfo, context) {
41
44
  options,
42
45
  ]).output);
43
46
  const getProjectMetadata = (target) => toPromise(architect['_scheduler'].schedule('..getProjectMetadata', target).output);
47
+ const getBuilderNameForTarget = (target) => {
48
+ if (typeof target === 'string') {
49
+ return Promise.resolve(context.projectGraph.nodes[context.projectName].data.targets[target]
50
+ .executor);
51
+ }
52
+ return Promise.resolve(context.projectGraph.nodes[target.project].data.targets[target.target]
53
+ .executor);
54
+ };
55
+ const getTargetOptions = (target) => {
56
+ if (typeof target === 'string') {
57
+ return Promise.resolve({
58
+ ...context.projectGraph.nodes[context.projectName].data.targets[target]
59
+ .options,
60
+ });
61
+ }
62
+ return Promise.resolve({
63
+ ...context.projectGraph.nodes[target.project].data.targets[target.target]
64
+ .options,
65
+ ...context.projectGraph.nodes[target.project].data.targets[target.target]
66
+ .configurations[target.configuration],
67
+ });
68
+ };
44
69
  const builderContext = {
45
70
  workspaceRoot: context.root,
46
71
  target: {
@@ -55,9 +80,7 @@ async function createBuilderContext(builderInfo, context) {
55
80
  id: 1,
56
81
  currentDirectory: process.cwd(),
57
82
  scheduleTarget: architect.scheduleTarget,
58
- getBuilderNameForTarget: architectHost.getBuilderNameForTarget,
59
83
  scheduleBuilder: architect.scheduleBuilder,
60
- getTargetOptions: architectHost.getOptionsForTarget,
61
84
  addTeardown(teardown) {
62
85
  // No-op as Nx doesn't require an implementation of this function
63
86
  return;
@@ -74,8 +97,10 @@ async function createBuilderContext(builderInfo, context) {
74
97
  // No-op as Nx doesn't require an implementation of this function
75
98
  return;
76
99
  },
100
+ getBuilderNameForTarget,
77
101
  getProjectMetadata,
78
102
  validateOptions,
103
+ getTargetOptions,
79
104
  };
80
105
  return builderContext;
81
106
  }
@@ -83,7 +108,7 @@ exports.createBuilderContext = createBuilderContext;
83
108
  async function scheduleTarget(root, opts, verbose) {
84
109
  const { Architect } = require('@angular-devkit/architect');
85
110
  const logger = (0, exports.getLogger)(verbose);
86
- const fsHost = new NxScopedHost(root);
111
+ const fsHost = new NxScopedHostForBuilders(root);
87
112
  const { workspace } = await core_1.workspaces.readWorkspace('angular.json', core_1.workspaces.createWorkspaceHost(fsHost));
88
113
  const registry = new core_1.schema.CoreSchemaRegistry();
89
114
  registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
@@ -91,7 +116,7 @@ async function scheduleTarget(root, opts, verbose) {
91
116
  // This happens when context.scheduleTarget is used to run a target using nx:run-commands
92
117
  return [];
93
118
  });
94
- const architectHost = await getWrappedWorkspaceNodeModulesArchitectHost(workspace, root);
119
+ const architectHost = await getWrappedWorkspaceNodeModulesArchitectHost(workspace, root, opts.projects);
95
120
  const architect = new Architect(architectHost, registry);
96
121
  const run = await architect.scheduleTarget({
97
122
  project: opts.project,
@@ -105,7 +130,7 @@ async function scheduleTarget(root, opts, verbose) {
105
130
  }));
106
131
  }
107
132
  exports.scheduleTarget = scheduleTarget;
108
- function createNodeModulesEngineHost(resolvePaths) {
133
+ function createNodeModulesEngineHost(resolvePaths, projects) {
109
134
  const NodeModulesEngineHost = require('@angular-devkit/schematics/tools')
110
135
  .NodeModulesEngineHost;
111
136
  class NxNodeModulesEngineHost extends NodeModulesEngineHost {
@@ -121,7 +146,7 @@ function createNodeModulesEngineHost(resolvePaths) {
121
146
  collectionFilePath = require.resolve(name, { paths });
122
147
  }
123
148
  else {
124
- const { json: { generators, schematics }, path: packageJsonPath, } = (0, nx_plugin_1.readPluginPackageJson)(name, paths);
149
+ const { json: { generators, schematics }, path: packageJsonPath, } = (0, nx_plugin_1.readPluginPackageJson)(name, projects, paths);
125
150
  if (!schematics && !generators) {
126
151
  throw new Error(`The "${name}" package does not support Nx generators or Angular Devkit schematics.`);
127
152
  }
@@ -136,7 +161,7 @@ function createNodeModulesEngineHost(resolvePaths) {
136
161
  }
137
162
  return new NxNodeModulesEngineHost();
138
163
  }
139
- function createWorkflow(fsHost, root, opts) {
164
+ function createWorkflow(fsHost, root, opts, projects) {
140
165
  const NodeWorkflow = require('@angular-devkit/schematics/tools').NodeWorkflow;
141
166
  const workflow = new NodeWorkflow(fsHost, {
142
167
  force: false,
@@ -145,7 +170,7 @@ function createWorkflow(fsHost, root, opts) {
145
170
  root: (0, core_1.normalize)(root),
146
171
  registry: new core_1.schema.CoreSchemaRegistry(require('@angular-devkit/schematics').formats.standardFormats),
147
172
  resolvePaths: [process.cwd(), root],
148
- engineHostCreator: (options) => createNodeModulesEngineHost(options.resolvePaths),
173
+ engineHostCreator: (options) => createNodeModulesEngineHost(options.resolvePaths, projects),
149
174
  });
150
175
  workflow.registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
151
176
  workflow.engineHost.registerOptionsTransform(require('@angular-devkit/schematics/tools').validateOptionsWithSchema(workflow.registry));
@@ -200,7 +225,7 @@ async function runSchematic(host, root, workflow, logger, opts, schematic, print
200
225
  .toPromise();
201
226
  }
202
227
  catch (e) {
203
- console.log(e);
228
+ console.error(e);
204
229
  throw e;
205
230
  }
206
231
  if (!record.error) {
@@ -248,8 +273,8 @@ class NxScopedHost extends core_1.virtualFs.ScopedHost {
248
273
  return workspaceConfig;
249
274
  }));
250
275
  }), (0, operators_1.catchError)((err) => {
251
- console.log('Unable to read angular.json');
252
- console.log(err);
276
+ console.error('Unable to read angular.json');
277
+ console.error(err);
253
278
  process.exit(1);
254
279
  }));
255
280
  }
@@ -353,6 +378,30 @@ class NxScopedHost extends core_1.virtualFs.ScopedHost {
353
378
  }
354
379
  }
355
380
  exports.NxScopedHost = NxScopedHost;
381
+ /**
382
+ * Host used by Angular CLI builders. It reads the project configurations from
383
+ * the project graph to access the expanded targets.
384
+ */
385
+ class NxScopedHostForBuilders extends NxScopedHost {
386
+ readMergedWorkspaceConfiguration() {
387
+ return (0, rxjs_1.zip)((0, rxjs_1.from)((0, project_graph_1.createProjectGraphAsync)()), this.readExistingAngularJson(), this.readJson('nx.json')).pipe((0, operators_1.map)(([graph, angularJson, nxJson]) => {
388
+ const workspaceConfig = (angularJson || { projects: {} });
389
+ workspaceConfig.cli ??= nxJson.cli;
390
+ workspaceConfig.schematics ??= nxJson.generators;
391
+ for (const projectName of Object.keys(graph.nodes)) {
392
+ workspaceConfig.projects[projectName] ??= {
393
+ ...graph.nodes[projectName].data,
394
+ };
395
+ }
396
+ return workspaceConfig;
397
+ }), (0, operators_1.catchError)((err) => {
398
+ console.error('Unable to read angular.json');
399
+ console.error(err);
400
+ process.exit(1);
401
+ }));
402
+ }
403
+ }
404
+ exports.NxScopedHostForBuilders = NxScopedHostForBuilders;
356
405
  function arrayBufferToString(buffer) {
357
406
  const array = new Uint8Array(buffer);
358
407
  let result = '';
@@ -365,6 +414,10 @@ function arrayBufferToString(buffer) {
365
414
  return result;
366
415
  }
367
416
  exports.arrayBufferToString = arrayBufferToString;
417
+ /**
418
+ * Host used by Angular CLI schematics. It reads the project configurations from
419
+ * the project configuration files.
420
+ */
368
421
  class NxScopeHostUsedForWrappedSchematics extends NxScopedHost {
369
422
  constructor(root, host) {
370
423
  super(root);
@@ -446,10 +499,10 @@ function findMatchingFileChange(host, path) {
446
499
  .listChanges()
447
500
  .find((f) => f.type !== 'DELETE' && (0, core_1.normalize)(f.path) === targetPath);
448
501
  }
449
- async function generate(root, opts, verbose) {
502
+ async function generate(root, opts, projects, verbose) {
450
503
  const logger = (0, exports.getLogger)(verbose);
451
504
  const fsHost = new NxScopeHostUsedForWrappedSchematics(root, new tree_1.FsTree(root, verbose, `ng-cli generator: ${opts.collectionName}:${opts.generatorName}`));
452
- const workflow = createWorkflow(fsHost, root, opts);
505
+ const workflow = createWorkflow(fsHost, root, opts, projects);
453
506
  const collection = getCollection(workflow, opts.collectionName);
454
507
  const schematic = collection.createSchematic(opts.generatorName, true);
455
508
  return (await runSchematic(fsHost, root, workflow, logger, { ...opts, generatorName: schematic.description.name }, schematic)).status;
@@ -504,10 +557,10 @@ function createPromptProvider() {
504
557
  return require('enquirer').prompt(questions);
505
558
  };
506
559
  }
507
- async function runMigration(root, packageName, migrationName, isVerbose) {
560
+ async function runMigration(root, packageName, migrationName, projects, isVerbose) {
508
561
  const logger = (0, exports.getLogger)(isVerbose);
509
562
  const fsHost = new NxScopeHostUsedForWrappedSchematics(root, new tree_1.FsTree(root, isVerbose, `ng-cli migration: ${packageName}:${migrationName}`));
510
- const workflow = createWorkflow(fsHost, root, {});
563
+ const workflow = createWorkflow(fsHost, root, {}, projects);
511
564
  const collection = resolveMigrationsCollection(packageName);
512
565
  const record = { loggingQueue: [], error: false };
513
566
  workflow.reporter.subscribe(await createRecorder(fsHost, record, logger));
@@ -596,6 +649,8 @@ function wrapAngularDevkitSchematic(collectionName, generatorName) {
596
649
  // were written with Nx in mind, and may care about tags.
597
650
  require('./compat');
598
651
  return async (host, generatorOptions) => {
652
+ const graph = await (0, project_graph_1.createProjectGraphAsync)();
653
+ const { projects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(graph);
599
654
  if (mockedSchematics &&
600
655
  mockedSchematics[`${collectionName}:${generatorName}`]) {
601
656
  return await mockedSchematics[`${collectionName}:${generatorName}`](host, generatorOptions);
@@ -647,7 +702,7 @@ function wrapAngularDevkitSchematic(collectionName, generatorName) {
647
702
  defaults: false,
648
703
  quiet: false,
649
704
  };
650
- const workflow = createWorkflow(fsHost, host.root, options);
705
+ const workflow = createWorkflow(fsHost, host.root, options, projects);
651
706
  // used for testing
652
707
  if (collectionResolutionOverrides) {
653
708
  const r = workflow.engineHost.resolve;
@@ -723,36 +778,38 @@ function saveProjectsConfigurationsInWrappedSchematic(host, content) {
723
778
  host.write('angular.json', JSON.stringify((0, angular_json_1.toOldFormat)(newAngularJson), null, 2));
724
779
  }
725
780
  }
726
- async function getWrappedWorkspaceNodeModulesArchitectHost(workspace, root) {
781
+ async function getWrappedWorkspaceNodeModulesArchitectHost(workspace, root, projects) {
727
782
  const { WorkspaceNodeModulesArchitectHost: AngularWorkspaceNodeModulesArchitectHost, } = await Promise.resolve().then(() => require('@angular-devkit/architect/node'));
728
783
  class WrappedWorkspaceNodeModulesArchitectHost extends AngularWorkspaceNodeModulesArchitectHost {
729
- constructor(workspace, root) {
784
+ constructor(workspace, root, projects) {
730
785
  super(workspace, root);
731
786
  this.workspace = workspace;
732
787
  this.root = root;
788
+ this.projects = projects;
733
789
  }
734
790
  async resolveBuilder(builderStr) {
735
791
  const [packageName, builderName] = builderStr.split(':');
736
792
  const { executorsFilePath, executorConfig } = this.readExecutorsJson(packageName, builderName);
737
793
  const builderInfo = this.readExecutor(packageName, builderName);
794
+ const { builders, executors } = (0, fileutils_1.readJsonFile)(executorsFilePath);
738
795
  return {
739
796
  name: builderStr,
740
797
  builderName,
741
- description: (0, fileutils_1.readJsonFile)(executorsFilePath).builders[builderName]
742
- .description,
798
+ description: builders?.[builderName]?.description ??
799
+ executors?.[builderName]?.description,
743
800
  optionSchema: builderInfo.schema,
744
801
  import: (0, schema_utils_1.resolveImplementation)(executorConfig.implementation, (0, path_1.dirname)(executorsFilePath)),
745
802
  };
746
803
  }
747
804
  readExecutorsJson(nodeModule, builder) {
748
- const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(nodeModule, this.root ? [this.root, __dirname] : [__dirname]);
805
+ const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(nodeModule, this.projects, this.root ? [this.root, __dirname] : [__dirname]);
749
806
  const executorsFile = packageJson.executors ?? packageJson.builders;
750
807
  if (!executorsFile) {
751
808
  throw new Error(`The "${nodeModule}" package does not support Nx executors or Angular Devkit Builders.`);
752
809
  }
753
810
  const executorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), executorsFile));
754
811
  const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
755
- const executorConfig = executorsJson.builders?.[builder];
812
+ const executorConfig = executorsJson.builders?.[builder] ?? executorsJson.executors?.[builder];
756
813
  if (!executorConfig) {
757
814
  throw new Error(`Cannot find builder '${builder}' in ${executorsFilePath}.`);
758
815
  }
@@ -787,5 +844,5 @@ async function getWrappedWorkspaceNodeModulesArchitectHost(workspace, root) {
787
844
  return (0, schema_utils_1.getImplementationFactory)(implementation, executorsDir);
788
845
  }
789
846
  }
790
- return new WrappedWorkspaceNodeModulesArchitectHost(workspace, root);
847
+ return new WrappedWorkspaceNodeModulesArchitectHost(workspace, root, projects);
791
848
  }
@@ -0,0 +1,2 @@
1
+ import type { AddOptions } from './command-object';
2
+ export declare function addHandler(options: AddOptions): Promise<void>;
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addHandler = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const fs_1 = require("fs");
6
+ const ora = require("ora");
7
+ const angular_json_1 = require("../../adapter/angular-json");
8
+ const nx_json_1 = require("../../config/nx-json");
9
+ const child_process_2 = require("../../utils/child-process");
10
+ const fileutils_1 = require("../../utils/fileutils");
11
+ const logger_1 = require("../../utils/logger");
12
+ const output_1 = require("../../utils/output");
13
+ const package_manager_1 = require("../../utils/package-manager");
14
+ const params_1 = require("../../utils/params");
15
+ const plugins_1 = require("../../utils/plugins");
16
+ const versions_1 = require("../../utils/versions");
17
+ const workspace_root_1 = require("../../utils/workspace-root");
18
+ function addHandler(options) {
19
+ if (options.verbose) {
20
+ process.env.NX_VERBOSE_LOGGING = 'true';
21
+ }
22
+ const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
23
+ return (0, params_1.handleErrors)(isVerbose, async () => {
24
+ output_1.output.addNewline();
25
+ const [pkgName, version] = parsePackageSpecifier(options.packageSpecifier);
26
+ await installPackage(pkgName, version);
27
+ await initializePlugin(pkgName, options);
28
+ output_1.output.success({
29
+ title: `Package ${pkgName} added successfully.`,
30
+ });
31
+ });
32
+ }
33
+ exports.addHandler = addHandler;
34
+ async function installPackage(pkgName, version) {
35
+ const spinner = ora(`Installing ${pkgName}@${version}...`);
36
+ spinner.start();
37
+ if ((0, fs_1.existsSync)('package.json')) {
38
+ const pmc = (0, package_manager_1.getPackageManagerCommand)();
39
+ await new Promise((resolve) => (0, child_process_1.exec)(`${pmc.addDev} ${pkgName}@${version}`, (error, stdout) => {
40
+ if (error) {
41
+ spinner.fail();
42
+ output_1.output.addNewline();
43
+ logger_1.logger.error(stdout);
44
+ output_1.output.error({
45
+ title: `Failed to install ${pkgName}. Please check the error above for more details.`,
46
+ });
47
+ process.exit(1);
48
+ }
49
+ return resolve();
50
+ }));
51
+ }
52
+ else {
53
+ const nxJson = (0, nx_json_1.readNxJson)();
54
+ nxJson.installation.plugins ??= {};
55
+ nxJson.installation.plugins[pkgName] = version;
56
+ (0, fileutils_1.writeJsonFile)('nx.json', nxJson);
57
+ try {
58
+ await (0, child_process_2.runNxAsync)('--help', { silent: true });
59
+ }
60
+ catch (e) {
61
+ // revert adding the plugin to nx.json
62
+ nxJson.installation.plugins[pkgName] = undefined;
63
+ (0, fileutils_1.writeJsonFile)('nx.json', nxJson);
64
+ spinner.fail();
65
+ output_1.output.addNewline();
66
+ logger_1.logger.error(e.message);
67
+ output_1.output.error({
68
+ title: `Failed to install ${pkgName}. Please check the error above for more details.`,
69
+ });
70
+ process.exit(1);
71
+ }
72
+ }
73
+ spinner.succeed();
74
+ }
75
+ async function initializePlugin(pkgName, options) {
76
+ const capabilities = await (0, plugins_1.getPluginCapabilities)(workspace_root_1.workspaceRoot, pkgName, {});
77
+ const generators = capabilities?.generators;
78
+ if (!generators) {
79
+ output_1.output.log({
80
+ title: `No generators found in ${pkgName}. Skipping initialization.`,
81
+ });
82
+ return;
83
+ }
84
+ const initGenerator = findInitGenerator(generators);
85
+ if (!initGenerator) {
86
+ output_1.output.log({
87
+ title: `No "init" generator found in ${pkgName}. Skipping initialization.`,
88
+ });
89
+ return;
90
+ }
91
+ const spinner = ora(`Initializing ${pkgName}...`);
92
+ spinner.start();
93
+ try {
94
+ let updatePackageScripts;
95
+ if (options.updatePackageScripts !== undefined) {
96
+ updatePackageScripts = options.updatePackageScripts;
97
+ }
98
+ else {
99
+ updatePackageScripts =
100
+ (0, nx_json_1.readNxJson)().useInferencePlugins !== false &&
101
+ process.env.NX_ADD_PLUGINS !== 'false' &&
102
+ coreNxPlugins.includes(pkgName);
103
+ }
104
+ await (0, child_process_2.runNxAsync)(`g ${pkgName}:${initGenerator} --keepExistingVersions${updatePackageScripts ? ' --updatePackageScripts' : ''}`, {
105
+ silent: !options.verbose,
106
+ });
107
+ }
108
+ catch (e) {
109
+ spinner.fail();
110
+ output_1.output.addNewline();
111
+ logger_1.logger.error(e.message);
112
+ output_1.output.error({
113
+ title: `Failed to initialize ${pkgName}. Please check the error above for more details.`,
114
+ });
115
+ process.exit(1);
116
+ }
117
+ spinner.succeed();
118
+ }
119
+ function findInitGenerator(generators) {
120
+ if (generators['init']) {
121
+ return 'init';
122
+ }
123
+ const angularPluginInstalled = (0, angular_json_1.isAngularPluginInstalled)();
124
+ if (angularPluginInstalled && generators['ng-add']) {
125
+ return 'ng-add';
126
+ }
127
+ return Object.keys(generators).find((name) => generators[name].aliases?.includes('init') ||
128
+ (angularPluginInstalled && generators[name].aliases?.includes('ng-add')));
129
+ }
130
+ function parsePackageSpecifier(packageSpecifier) {
131
+ const i = packageSpecifier.lastIndexOf('@');
132
+ if (i <= 0) {
133
+ if (coreNxPlugins.includes(packageSpecifier)) {
134
+ return [packageSpecifier, versions_1.nxVersion];
135
+ }
136
+ return [packageSpecifier, 'latest'];
137
+ }
138
+ const pkgName = packageSpecifier.substring(0, i);
139
+ const version = packageSpecifier.substring(i + 1);
140
+ return [pkgName, version];
141
+ }
142
+ const coreNxPlugins = [
143
+ '@nx/angular',
144
+ '@nx/cypress',
145
+ '@nx/detox',
146
+ '@nx/devkit',
147
+ '@nx/esbuild',
148
+ '@nx/eslint',
149
+ '@nx/eslint-plugin',
150
+ '@nx/expo',
151
+ '@nx/express',
152
+ '@nx/jest',
153
+ '@nx/nest',
154
+ '@nx/next',
155
+ '@nx/node',
156
+ '@nx/nuxt',
157
+ '@nx/playwright',
158
+ '@nx/plugin',
159
+ '@nx/react',
160
+ '@nx/react-native',
161
+ '@nx/remix',
162
+ '@nx/rollup',
163
+ '@nx/storybook',
164
+ '@nx/vite',
165
+ '@nx/vue',
166
+ '@nx/web',
167
+ '@nx/webpack',
168
+ '@nx/workspace',
169
+ ];
@@ -0,0 +1,7 @@
1
+ import { CommandModule } from 'yargs';
2
+ export interface AddOptions {
3
+ packageSpecifier: string;
4
+ updatePackageScripts?: boolean;
5
+ verbose?: boolean;
6
+ }
7
+ export declare const yargsAddCommand: CommandModule<Record<string, unknown>, AddOptions>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.yargsAddCommand = void 0;
4
+ exports.yargsAddCommand = {
5
+ command: 'add <packageSpecifier>',
6
+ describe: 'Install a plugin and initialize it.',
7
+ builder: (yargs) => yargs
8
+ .positional('packageSpecifier', {
9
+ type: 'string',
10
+ description: 'The package name and optional version (e.g. `@nx/react` or `@nx/react@latest`) to install and initialize. If the version is not specified it will install the same version as the `nx` package for Nx core plugins or the latest version for other packages',
11
+ })
12
+ .option('updatePackageScripts', {
13
+ type: 'boolean',
14
+ description: 'Update `package.json` scripts with inferred targets. Defaults to `true` when the package is a core Nx plugin',
15
+ })
16
+ .option('verbose', {
17
+ type: 'boolean',
18
+ description: 'Prints additional information about the commands (e.g., stack traces)',
19
+ })
20
+ .example('$0 add @nx/react', 'Install the latest version of the `@nx/react` package and run its `@nx/react:init` generator')
21
+ .example('$0 add non-core-nx-plugin', 'Install the latest version of the `non-core-nx-plugin` package and run its `non-core-nx-plugin:init` generator if available')
22
+ .example('$0 add @nx/react@17.0.0', 'Install version `17.0.0` of the `@nx/react` package and run its `@nx/react:init` generator'),
23
+ handler: (args) => Promise.resolve().then(() => require('./add')).then((m) => m.addHandler(args)),
24
+ };
@@ -63,9 +63,6 @@ async function affected(command, args, extraTargetDependencies = {}) {
63
63
  }
64
64
  else {
65
65
  const status = await (0, run_command_1.runCommand)(projectsWithTarget, projectGraph, { nxJson }, nxArgs, overrides, null, extraTargetDependencies, { excludeTaskDependencies: false, loadDotEnvFiles: true });
66
- // fix for https://github.com/nrwl/nx/issues/1666
67
- if (process.stdin['unref'])
68
- process.stdin.unref();
69
66
  process.exit(status);
70
67
  }
71
68
  break;
@@ -4,13 +4,13 @@ export declare const yargsAffectedTestCommand: CommandModule;
4
4
  export declare const yargsAffectedBuildCommand: CommandModule;
5
5
  export declare const yargsAffectedLintCommand: CommandModule;
6
6
  export declare const yargsAffectedE2ECommand: CommandModule;
7
- export declare const affectedGraphDeprecationMessage = "Use `nx graph --affected`, or `nx affected --graph` instead depending on which best suits your use case. The `affected:graph` command will be removed in Nx 18.";
7
+ export declare const affectedGraphDeprecationMessage = "Use `nx graph --affected`, or `nx affected --graph` instead depending on which best suits your use case. The `affected:graph` command will be removed in Nx 19.";
8
8
  /**
9
- * @deprecated 'Use `nx graph --affected`, or` nx affected --graph` instead depending on which best suits your use case. The `affected:graph` command will be removed in Nx 18.'
9
+ * @deprecated 'Use `nx graph --affected`, or` nx affected --graph` instead depending on which best suits your use case. The `affected:graph` command will be removed in Nx 19.'
10
10
  */
11
11
  export declare const yargsAffectedGraphCommand: CommandModule;
12
- export declare const printAffectedDeprecationMessage = "Use `nx show projects --affected`, `nx affected --graph -t build` or `nx graph --affected` depending on which best suits your use case. The `print-affected` command will be removed in Nx 18.";
12
+ export declare const printAffectedDeprecationMessage = "Use `nx show projects --affected`, `nx affected --graph -t build` or `nx graph --affected` depending on which best suits your use case. The `print-affected` command will be removed in Nx 19.";
13
13
  /**
14
- * @deprecated 'Use `nx show --affected`, `nx affected --graph` or `nx graph --affected` depending on which best suits your use case. The `print-affected` command will be removed in Nx 18.'
14
+ * @deprecated 'Use `nx show --affected`, `nx affected --graph` or `nx graph --affected` depending on which best suits your use case. The `print-affected` command will be removed in Nx 19.'
15
15
  */
16
16
  export declare const yargsPrintAffectedCommand: CommandModule;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.yargsPrintAffectedCommand = exports.printAffectedDeprecationMessage = exports.yargsAffectedGraphCommand = exports.affectedGraphDeprecationMessage = exports.yargsAffectedE2ECommand = exports.yargsAffectedLintCommand = exports.yargsAffectedBuildCommand = exports.yargsAffectedTestCommand = exports.yargsAffectedCommand = void 0;
4
4
  const documentation_1 = require("../yargs-utils/documentation");
5
5
  const shared_options_1 = require("../yargs-utils/shared-options");
6
+ const params_1 = require("../../utils/params");
6
7
  exports.yargsAffectedCommand = {
7
8
  command: 'affected',
8
9
  describe: 'Run target for affected projects',
@@ -16,61 +17,85 @@ exports.yargsAffectedCommand = {
16
17
  throw new Error("The '--all' option has been removed for `nx affected`. Use 'nx run-many' instead.");
17
18
  }
18
19
  }), 'affected'),
19
- handler: async (args) => (await Promise.resolve().then(() => require('./affected'))).affected('affected', (0, shared_options_1.withOverrides)(args)),
20
+ handler: async (args) => {
21
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
22
+ return (await Promise.resolve().then(() => require('./affected'))).affected('affected', (0, shared_options_1.withOverrides)(args));
23
+ });
24
+ },
20
25
  };
21
26
  exports.yargsAffectedTestCommand = {
22
27
  command: 'affected:test',
23
28
  describe: false,
24
29
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
25
- handler: async (args) => (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
26
- ...(0, shared_options_1.withOverrides)(args),
27
- target: 'test',
28
- }),
30
+ handler: async (args) => {
31
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
32
+ return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
33
+ ...(0, shared_options_1.withOverrides)(args),
34
+ target: 'test',
35
+ });
36
+ });
37
+ },
29
38
  };
30
39
  exports.yargsAffectedBuildCommand = {
31
40
  command: 'affected:build',
32
41
  describe: false,
33
42
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
34
- handler: async (args) => (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
35
- ...(0, shared_options_1.withOverrides)(args),
36
- target: 'build',
37
- }),
43
+ handler: async (args) => {
44
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
45
+ return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
46
+ ...(0, shared_options_1.withOverrides)(args),
47
+ target: 'build',
48
+ });
49
+ });
50
+ },
38
51
  };
39
52
  exports.yargsAffectedLintCommand = {
40
53
  command: 'affected:lint',
41
54
  describe: false,
42
55
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
43
- handler: async (args) => (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
44
- ...(0, shared_options_1.withOverrides)(args),
45
- target: 'lint',
46
- }),
56
+ handler: async (args) => {
57
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
58
+ return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
59
+ ...(0, shared_options_1.withOverrides)(args),
60
+ target: 'lint',
61
+ });
62
+ });
63
+ },
47
64
  };
48
65
  exports.yargsAffectedE2ECommand = {
49
66
  command: 'affected:e2e',
50
67
  describe: false,
51
68
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
52
- handler: async (args) => (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
53
- ...(0, shared_options_1.withOverrides)(args),
54
- target: 'e2e',
55
- }),
69
+ handler: async (args) => {
70
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
71
+ return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
72
+ ...(0, shared_options_1.withOverrides)(args),
73
+ target: 'e2e',
74
+ });
75
+ });
76
+ },
56
77
  };
57
- exports.affectedGraphDeprecationMessage = 'Use `nx graph --affected`, or `nx affected --graph` instead depending on which best suits your use case. The `affected:graph` command will be removed in Nx 18.';
78
+ exports.affectedGraphDeprecationMessage = 'Use `nx graph --affected`, or `nx affected --graph` instead depending on which best suits your use case. The `affected:graph` command will be removed in Nx 19.';
58
79
  /**
59
- * @deprecated 'Use `nx graph --affected`, or` nx affected --graph` instead depending on which best suits your use case. The `affected:graph` command will be removed in Nx 18.'
80
+ * @deprecated 'Use `nx graph --affected`, or` nx affected --graph` instead depending on which best suits your use case. The `affected:graph` command will be removed in Nx 19.'
60
81
  */
61
82
  exports.yargsAffectedGraphCommand = {
62
83
  command: 'affected:graph',
63
84
  describe: 'Graph dependencies affected by changes',
64
85
  aliases: ['affected:dep-graph'],
65
86
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withDepGraphOptions)(yargs)), 'affected:graph'),
66
- handler: async (args) => await (await Promise.resolve().then(() => require('./affected'))).affected('graph', {
67
- ...args,
68
- }),
87
+ handler: async (args) => {
88
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
89
+ return await (await Promise.resolve().then(() => require('./affected'))).affected('graph', {
90
+ ...args,
91
+ });
92
+ });
93
+ },
69
94
  deprecated: exports.affectedGraphDeprecationMessage,
70
95
  };
71
- exports.printAffectedDeprecationMessage = 'Use `nx show projects --affected`, `nx affected --graph -t build` or `nx graph --affected` depending on which best suits your use case. The `print-affected` command will be removed in Nx 18.';
96
+ exports.printAffectedDeprecationMessage = 'Use `nx show projects --affected`, `nx affected --graph -t build` or `nx graph --affected` depending on which best suits your use case. The `print-affected` command will be removed in Nx 19.';
72
97
  /**
73
- * @deprecated 'Use `nx show --affected`, `nx affected --graph` or `nx graph --affected` depending on which best suits your use case. The `print-affected` command will be removed in Nx 18.'
98
+ * @deprecated 'Use `nx show --affected`, `nx affected --graph` or `nx graph --affected` depending on which best suits your use case. The `print-affected` command will be removed in Nx 19.'
74
99
  */
75
100
  exports.yargsPrintAffectedCommand = {
76
101
  command: 'print-affected',
@@ -86,8 +111,10 @@ exports.yargsPrintAffectedCommand = {
86
111
  describe: 'Select the type of projects to be returned (e.g., --type=app)',
87
112
  }),
88
113
  handler: async (args) => {
89
- await (await Promise.resolve().then(() => require('./affected'))).affected('print-affected', (0, shared_options_1.withOverrides)(args));
90
- process.exit(0);
114
+ return (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
115
+ await (await Promise.resolve().then(() => require('./affected'))).affected('print-affected', (0, shared_options_1.withOverrides)(args));
116
+ process.exit(0);
117
+ });
91
118
  },
92
119
  deprecated: exports.printAffectedDeprecationMessage,
93
120
  };