@ohos-ports/nx 17.3.2-beta.0

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 (671) hide show
  1. package/.eslintrc.json +106 -0
  2. package/LICENSE +22 -0
  3. package/README.md +66 -0
  4. package/bin/init-local.d.ts +8 -0
  5. package/bin/init-local.js +175 -0
  6. package/bin/nx-cloud.d.ts +2 -0
  7. package/bin/nx-cloud.js +55 -0
  8. package/bin/nx.d.ts +2 -0
  9. package/bin/nx.js +230 -0
  10. package/bin/post-install.d.ts +1 -0
  11. package/bin/post-install.js +55 -0
  12. package/bin/run-executor.d.ts +1 -0
  13. package/bin/run-executor.js +66 -0
  14. package/executors.json +19 -0
  15. package/generators.json +10 -0
  16. package/migrations.json +87 -0
  17. package/package.json +186 -0
  18. package/plugins/package-json.d.ts +1 -0
  19. package/plugins/package-json.js +12 -0
  20. package/presets/core.json +1 -0
  21. package/presets/npm.json +7 -0
  22. package/release/changelog-renderer/index.d.ts +56 -0
  23. package/release/changelog-renderer/index.js +238 -0
  24. package/release/index.d.ts +4 -0
  25. package/release/index.js +11 -0
  26. package/schemas/nx-schema.json +623 -0
  27. package/schemas/project-schema.json +244 -0
  28. package/schemas/workspace-schema.json +185 -0
  29. package/src/adapter/angular-json.d.ts +9 -0
  30. package/src/adapter/angular-json.js +127 -0
  31. package/src/adapter/compat.d.ts +2 -0
  32. package/src/adapter/compat.js +136 -0
  33. package/src/adapter/decorate-cli.d.ts +1 -0
  34. package/src/adapter/decorate-cli.js +25 -0
  35. package/src/adapter/ngcli-adapter.d.ts +90 -0
  36. package/src/adapter/ngcli-adapter.js +848 -0
  37. package/src/adapter/rxjs-for-await.d.ts +109 -0
  38. package/src/adapter/rxjs-for-await.js +362 -0
  39. package/src/command-line/add/add.d.ts +2 -0
  40. package/src/command-line/add/add.js +165 -0
  41. package/src/command-line/add/command-object.d.ts +7 -0
  42. package/src/command-line/add/command-object.js +24 -0
  43. package/src/command-line/affected/affected.d.ts +7 -0
  44. package/src/command-line/affected/affected.js +105 -0
  45. package/src/command-line/affected/command-object.d.ts +16 -0
  46. package/src/command-line/affected/command-object.js +93 -0
  47. package/src/command-line/affected/print-affected.d.ts +11 -0
  48. package/src/command-line/affected/print-affected.js +108 -0
  49. package/src/command-line/connect/command-object.d.ts +3 -0
  50. package/src/command-line/connect/command-object.js +19 -0
  51. package/src/command-line/connect/connect-to-nx-cloud.d.ts +8 -0
  52. package/src/command-line/connect/connect-to-nx-cloud.js +96 -0
  53. package/src/command-line/connect/view-logs.d.ts +1 -0
  54. package/src/command-line/connect/view-logs.js +53 -0
  55. package/src/command-line/daemon/command-object.d.ts +2 -0
  56. package/src/command-line/daemon/command-object.js +21 -0
  57. package/src/command-line/daemon/daemon.d.ts +2 -0
  58. package/src/command-line/daemon/daemon.js +27 -0
  59. package/src/command-line/examples.d.ts +5 -0
  60. package/src/command-line/examples.js +347 -0
  61. package/src/command-line/exec/command-object.d.ts +2 -0
  62. package/src/command-line/exec/command-object.js +19 -0
  63. package/src/command-line/exec/exec.d.ts +1 -0
  64. package/src/command-line/exec/exec.js +141 -0
  65. package/src/command-line/format/command-object.d.ts +3 -0
  66. package/src/command-line/format/command-object.js +46 -0
  67. package/src/command-line/format/format.d.ts +2 -0
  68. package/src/command-line/format/format.js +155 -0
  69. package/src/command-line/generate/command-object.d.ts +2 -0
  70. package/src/command-line/generate/command-object.js +70 -0
  71. package/src/command-line/generate/generate.d.ts +21 -0
  72. package/src/command-line/generate/generate.js +266 -0
  73. package/src/command-line/generate/generator-utils.d.ts +17 -0
  74. package/src/command-line/generate/generator-utils.js +87 -0
  75. package/src/command-line/graph/command-object.d.ts +2 -0
  76. package/src/command-line/graph/command-object.js +21 -0
  77. package/src/command-line/graph/graph.d.ts +39 -0
  78. package/src/command-line/graph/graph.js +661 -0
  79. package/src/command-line/init/command-object.d.ts +2 -0
  80. package/src/command-line/init/command-object.js +81 -0
  81. package/src/command-line/init/implementation/add-nx-to-monorepo.d.ts +4 -0
  82. package/src/command-line/init/implementation/add-nx-to-monorepo.js +133 -0
  83. package/src/command-line/init/implementation/add-nx-to-nest.d.ts +5 -0
  84. package/src/command-line/init/implementation/add-nx-to-nest.js +346 -0
  85. package/src/command-line/init/implementation/add-nx-to-npm-repo.d.ts +4 -0
  86. package/src/command-line/init/implementation/add-nx-to-npm-repo.js +66 -0
  87. package/src/command-line/init/implementation/angular/index.d.ts +2 -0
  88. package/src/command-line/init/implementation/angular/index.js +128 -0
  89. package/src/command-line/init/implementation/angular/integrated-workspace.d.ts +1 -0
  90. package/src/command-line/init/implementation/angular/integrated-workspace.js +10 -0
  91. package/src/command-line/init/implementation/angular/legacy-angular-versions.d.ts +2 -0
  92. package/src/command-line/init/implementation/angular/legacy-angular-versions.js +125 -0
  93. package/src/command-line/init/implementation/angular/standalone-workspace.d.ts +1 -0
  94. package/src/command-line/init/implementation/angular/standalone-workspace.js +178 -0
  95. package/src/command-line/init/implementation/angular/types.d.ts +20 -0
  96. package/src/command-line/init/implementation/angular/types.js +2 -0
  97. package/src/command-line/init/implementation/dot-nx/add-nx-scripts.d.ts +7 -0
  98. package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +91 -0
  99. package/src/command-line/init/implementation/dot-nx/nxw.d.ts +1 -0
  100. package/src/command-line/init/implementation/dot-nx/nxw.js +116 -0
  101. package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.d.ts +1 -0
  102. package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.js +22 -0
  103. package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.d.ts +1 -0
  104. package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +19 -0
  105. package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.d.ts +1 -0
  106. package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.js +18 -0
  107. package/src/command-line/init/implementation/react/check-for-uncommitted-changes.d.ts +1 -0
  108. package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +16 -0
  109. package/src/command-line/init/implementation/react/clean-up-files.d.ts +1 -0
  110. package/src/command-line/init/implementation/react/clean-up-files.js +31 -0
  111. package/src/command-line/init/implementation/react/index.d.ts +4 -0
  112. package/src/command-line/init/implementation/react/index.js +230 -0
  113. package/src/command-line/init/implementation/react/read-name-from-package-json.d.ts +1 -0
  114. package/src/command-line/init/implementation/react/read-name-from-package-json.js +17 -0
  115. package/src/command-line/init/implementation/react/rename-js-to-jsx.d.ts +1 -0
  116. package/src/command-line/init/implementation/react/rename-js-to-jsx.js +23 -0
  117. package/src/command-line/init/implementation/react/tsconfig-setup.d.ts +1 -0
  118. package/src/command-line/init/implementation/react/tsconfig-setup.js +109 -0
  119. package/src/command-line/init/implementation/react/write-craco-config.d.ts +1 -0
  120. package/src/command-line/init/implementation/react/write-craco-config.js +62 -0
  121. package/src/command-line/init/implementation/react/write-vite-config.d.ts +1 -0
  122. package/src/command-line/init/implementation/react/write-vite-config.js +38 -0
  123. package/src/command-line/init/implementation/react/write-vite-index-html.d.ts +1 -0
  124. package/src/command-line/init/implementation/react/write-vite-index-html.js +25 -0
  125. package/src/command-line/init/implementation/utils.d.ts +16 -0
  126. package/src/command-line/init/implementation/utils.js +176 -0
  127. package/src/command-line/init/init-v1.d.ts +11 -0
  128. package/src/command-line/init/init-v1.js +118 -0
  129. package/src/command-line/init/init-v2.d.ts +7 -0
  130. package/src/command-line/init/init-v2.js +165 -0
  131. package/src/command-line/list/command-object.d.ts +2 -0
  132. package/src/command-line/list/command-object.js +15 -0
  133. package/src/command-line/list/list.d.ts +13 -0
  134. package/src/command-line/list/list.js +47 -0
  135. package/src/command-line/migrate/command-object.d.ts +3 -0
  136. package/src/command-line/migrate/command-object.js +150 -0
  137. package/src/command-line/migrate/migrate.d.ts +114 -0
  138. package/src/command-line/migrate/migrate.js +1115 -0
  139. package/src/command-line/new/command-object.d.ts +2 -0
  140. package/src/command-line/new/command-object.js +25 -0
  141. package/src/command-line/new/new.d.ts +3 -0
  142. package/src/command-line/new/new.js +30 -0
  143. package/src/command-line/nx-commands.d.ts +10 -0
  144. package/src/command-line/nx-commands.js +77 -0
  145. package/src/command-line/release/changelog.d.ts +8 -0
  146. package/src/command-line/release/changelog.js +696 -0
  147. package/src/command-line/release/command-object.d.ts +45 -0
  148. package/src/command-line/release/command-object.js +237 -0
  149. package/src/command-line/release/config/config.d.ts +56 -0
  150. package/src/command-line/release/config/config.js +501 -0
  151. package/src/command-line/release/config/filter-release-groups.d.ts +13 -0
  152. package/src/command-line/release/config/filter-release-groups.js +150 -0
  153. package/src/command-line/release/index.d.ts +16 -0
  154. package/src/command-line/release/index.js +23 -0
  155. package/src/command-line/release/publish.d.ts +8 -0
  156. package/src/command-line/release/publish.js +149 -0
  157. package/src/command-line/release/release.d.ts +4 -0
  158. package/src/command-line/release/release.js +124 -0
  159. package/src/command-line/release/utils/batch-projects-by-generator-config.d.ts +7 -0
  160. package/src/command-line/release/utils/batch-projects-by-generator-config.js +37 -0
  161. package/src/command-line/release/utils/exec-command.d.ts +1 -0
  162. package/src/command-line/release/utils/exec-command.js +34 -0
  163. package/src/command-line/release/utils/git.d.ts +55 -0
  164. package/src/command-line/release/utils/git.js +261 -0
  165. package/src/command-line/release/utils/github.d.ts +27 -0
  166. package/src/command-line/release/utils/github.js +229 -0
  167. package/src/command-line/release/utils/launch-editor.d.ts +1 -0
  168. package/src/command-line/release/utils/launch-editor.js +42 -0
  169. package/src/command-line/release/utils/markdown.d.ts +6 -0
  170. package/src/command-line/release/utils/markdown.js +29 -0
  171. package/src/command-line/release/utils/print-changes.d.ts +7 -0
  172. package/src/command-line/release/utils/print-changes.js +60 -0
  173. package/src/command-line/release/utils/resolve-nx-json-error-message.d.ts +1 -0
  174. package/src/command-line/release/utils/resolve-nx-json-error-message.js +52 -0
  175. package/src/command-line/release/utils/resolve-semver-specifier.d.ts +3 -0
  176. package/src/command-line/release/utils/resolve-semver-specifier.js +69 -0
  177. package/src/command-line/release/utils/semver.d.ts +17 -0
  178. package/src/command-line/release/utils/semver.js +56 -0
  179. package/src/command-line/release/utils/shared.d.ts +34 -0
  180. package/src/command-line/release/utils/shared.js +211 -0
  181. package/src/command-line/release/version.d.ts +42 -0
  182. package/src/command-line/release/version.js +347 -0
  183. package/src/command-line/repair/command-object.d.ts +2 -0
  184. package/src/command-line/repair/command-object.js +22 -0
  185. package/src/command-line/repair/repair.d.ts +3 -0
  186. package/src/command-line/repair/repair.js +37 -0
  187. package/src/command-line/repair.d.ts +4 -0
  188. package/src/command-line/repair.js +7 -0
  189. package/src/command-line/report/command-object.d.ts +2 -0
  190. package/src/command-line/report/command-object.js +11 -0
  191. package/src/command-line/report/report.d.ts +48 -0
  192. package/src/command-line/report/report.js +232 -0
  193. package/src/command-line/reset/command-object.d.ts +2 -0
  194. package/src/command-line/reset/command-object.js +9 -0
  195. package/src/command-line/reset/reset.d.ts +1 -0
  196. package/src/command-line/reset/reset.js +23 -0
  197. package/src/command-line/run/command-object.d.ts +6 -0
  198. package/src/command-line/run/command-object.js +25 -0
  199. package/src/command-line/run/executor-utils.d.ts +7 -0
  200. package/src/command-line/run/executor-utils.js +73 -0
  201. package/src/command-line/run/run-one.d.ts +7 -0
  202. package/src/command-line/run/run-one.js +117 -0
  203. package/src/command-line/run/run.d.ts +51 -0
  204. package/src/command-line/run/run.js +172 -0
  205. package/src/command-line/run-many/command-object.d.ts +2 -0
  206. package/src/command-line/run-many/command-object.js +11 -0
  207. package/src/command-line/run-many/run-many.d.ts +10 -0
  208. package/src/command-line/run-many/run-many.js +90 -0
  209. package/src/command-line/run-many.d.ts +4 -0
  210. package/src/command-line/run-many.js +7 -0
  211. package/src/command-line/run-one.d.ts +4 -0
  212. package/src/command-line/run-one.js +7 -0
  213. package/src/command-line/run.d.ts +4 -0
  214. package/src/command-line/run.js +7 -0
  215. package/src/command-line/show/command-object.d.ts +22 -0
  216. package/src/command-line/show/command-object.js +84 -0
  217. package/src/command-line/show/show.d.ts +3 -0
  218. package/src/command-line/show/show.js +126 -0
  219. package/src/command-line/watch/command-object.d.ts +2 -0
  220. package/src/command-line/watch/command-object.js +64 -0
  221. package/src/command-line/watch/watch.d.ts +23 -0
  222. package/src/command-line/watch/watch.js +169 -0
  223. package/src/command-line/watch.d.ts +4 -0
  224. package/src/command-line/watch.js +7 -0
  225. package/src/command-line/yargs-utils/documentation.d.ts +2 -0
  226. package/src/command-line/yargs-utils/documentation.js +12 -0
  227. package/src/command-line/yargs-utils/shared-options.d.ts +89 -0
  228. package/src/command-line/yargs-utils/shared-options.js +284 -0
  229. package/src/commands-runner/command-graph.d.ts +13 -0
  230. package/src/commands-runner/command-graph.js +2 -0
  231. package/src/commands-runner/create-command-graph.d.ts +4 -0
  232. package/src/commands-runner/create-command-graph.js +44 -0
  233. package/src/commands-runner/get-command-projects.d.ts +3 -0
  234. package/src/commands-runner/get-command-projects.js +19 -0
  235. package/src/config/calculate-default-project-name.d.ts +4 -0
  236. package/src/config/calculate-default-project-name.js +42 -0
  237. package/src/config/configuration.d.ts +8 -0
  238. package/src/config/configuration.js +17 -0
  239. package/src/config/misc-interfaces.d.ts +199 -0
  240. package/src/config/misc-interfaces.js +2 -0
  241. package/src/config/nx-json.d.ts +372 -0
  242. package/src/config/nx-json.js +40 -0
  243. package/src/config/project-graph.d.ts +137 -0
  244. package/src/config/project-graph.js +37 -0
  245. package/src/config/schema-utils.d.ts +15 -0
  246. package/src/config/schema-utils.js +59 -0
  247. package/src/config/task-graph.d.ts +100 -0
  248. package/src/config/task-graph.js +2 -0
  249. package/src/config/workspace-json-project-json.d.ts +189 -0
  250. package/src/config/workspace-json-project-json.js +2 -0
  251. package/src/config/workspaces.d.ts +18 -0
  252. package/src/config/workspaces.js +35 -0
  253. package/src/core/graph/3rdpartylicenses.txt +833 -0
  254. package/src/core/graph/environment.js +1 -0
  255. package/src/core/graph/favicon.ico +0 -0
  256. package/src/core/graph/index.html +31 -0
  257. package/src/core/graph/main.js +1 -0
  258. package/src/core/graph/polyfills.js +1 -0
  259. package/src/core/graph/runtime.js +1 -0
  260. package/src/core/graph/styles.css +3 -0
  261. package/src/core/graph/styles.js +1 -0
  262. package/src/daemon/cache.d.ts +9 -0
  263. package/src/daemon/cache.js +52 -0
  264. package/src/daemon/client/client.d.ts +56 -0
  265. package/src/daemon/client/client.js +359 -0
  266. package/src/daemon/client/daemon-socket-messenger.d.ts +13 -0
  267. package/src/daemon/client/daemon-socket-messenger.js +26 -0
  268. package/src/daemon/client/exec-is-server-available.d.ts +1 -0
  269. package/src/daemon/client/exec-is-server-available.js +11 -0
  270. package/src/daemon/client/generate-help-output.d.ts +1 -0
  271. package/src/daemon/client/generate-help-output.js +26 -0
  272. package/src/daemon/server/file-watching/changed-projects.d.ts +10 -0
  273. package/src/daemon/server/file-watching/changed-projects.js +45 -0
  274. package/src/daemon/server/file-watching/file-watcher-sockets.d.ts +13 -0
  275. package/src/daemon/server/file-watching/file-watcher-sockets.js +66 -0
  276. package/src/daemon/server/handle-hash-tasks.d.ts +10 -0
  277. package/src/daemon/server/handle-hash-tasks.js +26 -0
  278. package/src/daemon/server/handle-outputs-tracking.d.ts +15 -0
  279. package/src/daemon/server/handle-outputs-tracking.js +36 -0
  280. package/src/daemon/server/handle-process-in-background.d.ts +6 -0
  281. package/src/daemon/server/handle-process-in-background.js +33 -0
  282. package/src/daemon/server/handle-request-file-data.d.ts +4 -0
  283. package/src/daemon/server/handle-request-file-data.js +13 -0
  284. package/src/daemon/server/handle-request-project-graph.d.ts +2 -0
  285. package/src/daemon/server/handle-request-project-graph.js +37 -0
  286. package/src/daemon/server/handle-request-shutdown.d.ts +6 -0
  287. package/src/daemon/server/handle-request-shutdown.js +26 -0
  288. package/src/daemon/server/logger.d.ts +18 -0
  289. package/src/daemon/server/logger.js +37 -0
  290. package/src/daemon/server/outputs-tracking.d.ts +8 -0
  291. package/src/daemon/server/outputs-tracking.js +94 -0
  292. package/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -0
  293. package/src/daemon/server/project-graph-incremental-recomputation.js +227 -0
  294. package/src/daemon/server/server.d.ts +9 -0
  295. package/src/daemon/server/server.js +303 -0
  296. package/src/daemon/server/shutdown-utils.d.ts +17 -0
  297. package/src/daemon/server/shutdown-utils.js +77 -0
  298. package/src/daemon/server/start.d.ts +1 -0
  299. package/src/daemon/server/start.js +17 -0
  300. package/src/daemon/server/watcher.d.ts +12 -0
  301. package/src/daemon/server/watcher.js +96 -0
  302. package/src/daemon/socket-utils.d.ts +11 -0
  303. package/src/daemon/socket-utils.js +42 -0
  304. package/src/daemon/tmp-dir.d.ts +8 -0
  305. package/src/daemon/tmp-dir.js +68 -0
  306. package/src/devkit-exports.d.ts +135 -0
  307. package/src/devkit-exports.js +140 -0
  308. package/src/devkit-internals.d.ts +19 -0
  309. package/src/devkit-internals.js +37 -0
  310. package/src/devkit-testing-exports.d.ts +2 -0
  311. package/src/devkit-testing-exports.js +8 -0
  312. package/src/executors/noop/noop.impl.d.ts +3 -0
  313. package/src/executors/noop/noop.impl.js +6 -0
  314. package/src/executors/noop/schema.json +10 -0
  315. package/src/executors/run-commands/run-commands.impl.d.ts +42 -0
  316. package/src/executors/run-commands/run-commands.impl.js +247 -0
  317. package/src/executors/run-commands/schema.json +150 -0
  318. package/src/executors/run-script/run-script.impl.d.ts +8 -0
  319. package/src/executors/run-script/run-script.impl.js +56 -0
  320. package/src/executors/run-script/schema.json +28 -0
  321. package/src/executors/utils/convert-nx-executor.d.ts +10 -0
  322. package/src/executors/utils/convert-nx-executor.js +82 -0
  323. package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +8 -0
  324. package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +49 -0
  325. package/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +11 -0
  326. package/src/generators/testing-utils/create-tree-with-empty-workspace.js +46 -0
  327. package/src/generators/testing-utils/create-tree.d.ts +5 -0
  328. package/src/generators/testing-utils/create-tree.js +11 -0
  329. package/src/generators/tree.d.ts +128 -0
  330. package/src/generators/tree.js +309 -0
  331. package/src/generators/utils/glob.d.ts +11 -0
  332. package/src/generators/utils/glob.js +35 -0
  333. package/src/generators/utils/json.d.ts +28 -0
  334. package/src/generators/utils/json.js +48 -0
  335. package/src/generators/utils/nx-json.d.ts +11 -0
  336. package/src/generators/utils/nx-json.js +59 -0
  337. package/src/generators/utils/project-configuration.d.ts +42 -0
  338. package/src/generators/utils/project-configuration.js +239 -0
  339. package/src/hasher/create-task-hasher.d.ts +4 -0
  340. package/src/hasher/create-task-hasher.js +16 -0
  341. package/src/hasher/file-hasher.d.ts +2 -0
  342. package/src/hasher/file-hasher.js +19 -0
  343. package/src/hasher/hash-task.d.ts +7 -0
  344. package/src/hasher/hash-task.js +54 -0
  345. package/src/hasher/native-task-hasher-impl.d.ts +19 -0
  346. package/src/hasher/native-task-hasher-impl.js +37 -0
  347. package/src/hasher/node-task-hasher-impl.d.ts +49 -0
  348. package/src/hasher/node-task-hasher-impl.js +431 -0
  349. package/src/hasher/task-hasher.d.ts +129 -0
  350. package/src/hasher/task-hasher.js +266 -0
  351. package/src/index.d.ts +1 -0
  352. package/src/index.js +5 -0
  353. package/src/migrations/update-15-0-0/migrate-to-inputs.d.ts +2 -0
  354. package/src/migrations/update-15-0-0/migrate-to-inputs.js +102 -0
  355. package/src/migrations/update-15-0-0/prefix-outputs.d.ts +2 -0
  356. package/src/migrations/update-15-0-0/prefix-outputs.js +64 -0
  357. package/src/migrations/update-15-1-0/set-project-names.d.ts +2 -0
  358. package/src/migrations/update-15-1-0/set-project-names.js +32 -0
  359. package/src/migrations/update-15-8-2/update-nxw.d.ts +2 -0
  360. package/src/migrations/update-15-8-2/update-nxw.js +7 -0
  361. package/src/migrations/update-16-0-0/remove-nrwl-cli.d.ts +2 -0
  362. package/src/migrations/update-16-0-0/remove-nrwl-cli.js +16 -0
  363. package/src/migrations/update-16-0-0/update-depends-on-to-tokens.d.ts +2 -0
  364. package/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +97 -0
  365. package/src/migrations/update-16-0-0/update-nx-cloud-runner.d.ts +2 -0
  366. package/src/migrations/update-16-0-0/update-nx-cloud-runner.js +27 -0
  367. package/src/migrations/update-16-2-0/remove-run-commands-output-path.d.ts +2 -0
  368. package/src/migrations/update-16-2-0/remove-run-commands-output-path.js +45 -0
  369. package/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.d.ts +12 -0
  370. package/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.js +60 -0
  371. package/src/migrations/update-16-9-0/remove-project-name-and-root-format.d.ts +2 -0
  372. package/src/migrations/update-16-9-0/remove-project-name-and-root-format.js +21 -0
  373. package/src/migrations/update-17-0-0/move-cache-directory.d.ts +2 -0
  374. package/src/migrations/update-17-0-0/move-cache-directory.js +35 -0
  375. package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.d.ts +2 -0
  376. package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +72 -0
  377. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +2 -0
  378. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +122 -0
  379. package/src/migrations/update-17-3-0/nx-release-path.d.ts +3 -0
  380. package/src/migrations/update-17-3-0/nx-release-path.js +49 -0
  381. package/src/migrations/update-17-3-0/update-nxw.d.ts +2 -0
  382. package/src/migrations/update-17-3-0/update-nxw.js +7 -0
  383. package/src/native/assert-supported-platform.d.ts +1 -0
  384. package/src/native/assert-supported-platform.js +39 -0
  385. package/src/native/index.d.ts +192 -0
  386. package/src/native/index.js +289 -0
  387. package/src/native/transform-objects.d.ts +3 -0
  388. package/src/native/transform-objects.js +50 -0
  389. package/src/nx-cloud/debug-logger.d.ts +1 -0
  390. package/src/nx-cloud/debug-logger.js +9 -0
  391. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +8 -0
  392. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +107 -0
  393. package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +27 -0
  394. package/src/nx-cloud/nx-cloud-tasks-runner-shell.d.ts +15 -0
  395. package/src/nx-cloud/nx-cloud-tasks-runner-shell.js +41 -0
  396. package/src/nx-cloud/resolution-helpers.d.ts +1 -0
  397. package/src/nx-cloud/resolution-helpers.js +20 -0
  398. package/src/nx-cloud/update-manager.d.ts +17 -0
  399. package/src/nx-cloud/update-manager.js +240 -0
  400. package/src/nx-cloud/utilities/axios.d.ts +2 -0
  401. package/src/nx-cloud/utilities/axios.js +24 -0
  402. package/src/nx-cloud/utilities/environment.d.ts +3 -0
  403. package/src/nx-cloud/utilities/environment.js +47 -0
  404. package/src/nx-cloud/utilities/get-cloud-options.d.ts +2 -0
  405. package/src/nx-cloud/utilities/get-cloud-options.js +11 -0
  406. package/src/plugins/js/hasher/hasher.d.ts +5 -0
  407. package/src/plugins/js/hasher/hasher.js +52 -0
  408. package/src/plugins/js/index.d.ts +4 -0
  409. package/src/plugins/js/index.js +96 -0
  410. package/src/plugins/js/lock-file/lock-file.d.ts +34 -0
  411. package/src/plugins/js/lock-file/lock-file.js +169 -0
  412. package/src/plugins/js/lock-file/npm-parser.d.ts +7 -0
  413. package/src/plugins/js/lock-file/npm-parser.js +463 -0
  414. package/src/plugins/js/lock-file/pnpm-parser.d.ts +7 -0
  415. package/src/plugins/js/lock-file/pnpm-parser.js +294 -0
  416. package/src/plugins/js/lock-file/project-graph-pruning.d.ts +7 -0
  417. package/src/plugins/js/lock-file/project-graph-pruning.js +155 -0
  418. package/src/plugins/js/lock-file/utils/package-json.d.ts +10 -0
  419. package/src/plugins/js/lock-file/utils/package-json.js +34 -0
  420. package/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +38 -0
  421. package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +575 -0
  422. package/src/plugins/js/lock-file/yarn-parser.d.ts +7 -0
  423. package/src/plugins/js/lock-file/yarn-parser.js +437 -0
  424. package/src/plugins/js/package-json/create-package-json.d.ts +27 -0
  425. package/src/plugins/js/package-json/create-package-json.js +207 -0
  426. package/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +4 -0
  427. package/src/plugins/js/project-graph/affected/lock-file-changes.js +16 -0
  428. package/src/plugins/js/project-graph/affected/npm-packages.d.ts +4 -0
  429. package/src/plugins/js/project-graph/affected/npm-packages.js +56 -0
  430. package/src/plugins/js/project-graph/affected/touched-projects.d.ts +2 -0
  431. package/src/plugins/js/project-graph/affected/touched-projects.js +18 -0
  432. package/src/plugins/js/project-graph/affected/tsconfig-json-changes.d.ts +4 -0
  433. package/src/plugins/js/project-graph/affected/tsconfig-json-changes.js +63 -0
  434. package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +6 -0
  435. package/src/plugins/js/project-graph/build-dependencies/build-dependencies.js +33 -0
  436. package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +3 -0
  437. package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.js +82 -0
  438. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +3 -0
  439. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +94 -0
  440. package/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +7 -0
  441. package/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +156 -0
  442. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +32 -0
  443. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +183 -0
  444. package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +16 -0
  445. package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +120 -0
  446. package/src/plugins/js/project-graph/build-nodes/build-npm-package-nodes.d.ts +2 -0
  447. package/src/plugins/js/project-graph/build-nodes/build-npm-package-nodes.js +32 -0
  448. package/src/plugins/js/utils/config.d.ts +2 -0
  449. package/src/plugins/js/utils/config.js +65 -0
  450. package/src/plugins/js/utils/register.d.ts +151 -0
  451. package/src/plugins/js/utils/register.js +215 -0
  452. package/src/plugins/js/utils/typescript.d.ts +14 -0
  453. package/src/plugins/js/utils/typescript.js +98 -0
  454. package/src/plugins/js/versions.d.ts +1 -0
  455. package/src/plugins/js/versions.js +4 -0
  456. package/src/plugins/package-json-workspaces/create-nodes.d.ts +19 -0
  457. package/src/plugins/package-json-workspaces/create-nodes.js +130 -0
  458. package/src/plugins/package-json-workspaces/index.d.ts +1 -0
  459. package/src/plugins/package-json-workspaces/index.js +4 -0
  460. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +2 -0
  461. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +47 -0
  462. package/src/plugins/project-json/build-nodes/project-json.d.ts +4 -0
  463. package/src/plugins/project-json/build-nodes/project-json.js +29 -0
  464. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +8 -0
  465. package/src/plugins/target-defaults/target-defaults-plugin.js +103 -0
  466. package/src/project-graph/affected/affected-project-graph-models.d.ts +11 -0
  467. package/src/project-graph/affected/affected-project-graph-models.js +2 -0
  468. package/src/project-graph/affected/affected-project-graph.d.ts +4 -0
  469. package/src/project-graph/affected/affected-project-graph.js +83 -0
  470. package/src/project-graph/affected/locators/project-glob-changes.d.ts +2 -0
  471. package/src/project-graph/affected/locators/project-glob-changes.js +31 -0
  472. package/src/project-graph/affected/locators/workspace-json-changes.d.ts +4 -0
  473. package/src/project-graph/affected/locators/workspace-json-changes.js +47 -0
  474. package/src/project-graph/affected/locators/workspace-projects.d.ts +5 -0
  475. package/src/project-graph/affected/locators/workspace-projects.js +85 -0
  476. package/src/project-graph/build-project-graph.d.ts +14 -0
  477. package/src/project-graph/build-project-graph.js +219 -0
  478. package/src/project-graph/file-map-utils.d.ts +15 -0
  479. package/src/project-graph/file-map-utils.js +63 -0
  480. package/src/project-graph/file-utils.d.ts +31 -0
  481. package/src/project-graph/file-utils.js +181 -0
  482. package/src/project-graph/nx-deps-cache.d.ts +48 -0
  483. package/src/project-graph/nx-deps-cache.js +228 -0
  484. package/src/project-graph/operators.d.ts +12 -0
  485. package/src/project-graph/operators.js +114 -0
  486. package/src/project-graph/project-graph-builder.d.ts +133 -0
  487. package/src/project-graph/project-graph-builder.js +379 -0
  488. package/src/project-graph/project-graph.d.ts +48 -0
  489. package/src/project-graph/project-graph.js +188 -0
  490. package/src/project-graph/utils/build-all-workspace-files.d.ts +2 -0
  491. package/src/project-graph/utils/build-all-workspace-files.js +15 -0
  492. package/src/project-graph/utils/find-project-for-path.d.ts +20 -0
  493. package/src/project-graph/utils/find-project-for-path.js +57 -0
  494. package/src/project-graph/utils/implicit-project-dependencies.d.ts +3 -0
  495. package/src/project-graph/utils/implicit-project-dependencies.js +19 -0
  496. package/src/project-graph/utils/normalize-project-nodes.d.ts +10 -0
  497. package/src/project-graph/utils/normalize-project-nodes.js +92 -0
  498. package/src/project-graph/utils/project-configuration-utils.d.ts +53 -0
  499. package/src/project-graph/utils/project-configuration-utils.js +456 -0
  500. package/src/project-graph/utils/retrieve-workspace-files.d.ts +37 -0
  501. package/src/project-graph/utils/retrieve-workspace-files.js +109 -0
  502. package/src/tasks-runner/batch/batch-messages.d.ts +33 -0
  503. package/src/tasks-runner/batch/batch-messages.js +9 -0
  504. package/src/tasks-runner/batch/run-batch.d.ts +1 -0
  505. package/src/tasks-runner/batch/run-batch.js +77 -0
  506. package/src/tasks-runner/cache.d.ts +36 -0
  507. package/src/tasks-runner/cache.js +236 -0
  508. package/src/tasks-runner/create-task-graph.d.ts +25 -0
  509. package/src/tasks-runner/create-task-graph.js +225 -0
  510. package/src/tasks-runner/default-tasks-runner.d.ts +20 -0
  511. package/src/tasks-runner/default-tasks-runner.js +29 -0
  512. package/src/tasks-runner/fork.d.ts +1 -0
  513. package/src/tasks-runner/fork.js +23 -0
  514. package/src/tasks-runner/forked-process-task-runner.d.ts +44 -0
  515. package/src/tasks-runner/forked-process-task-runner.js +396 -0
  516. package/src/tasks-runner/init-tasks-runner.d.ts +11 -0
  517. package/src/tasks-runner/init-tasks-runner.js +57 -0
  518. package/src/tasks-runner/life-cycle.d.ts +43 -0
  519. package/src/tasks-runner/life-cycle.js +71 -0
  520. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.d.ts +25 -0
  521. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +345 -0
  522. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.d.ts +24 -0
  523. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +224 -0
  524. package/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.d.ts +5 -0
  525. package/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.js +16 -0
  526. package/src/tasks-runner/life-cycles/formatting-utils.d.ts +3 -0
  527. package/src/tasks-runner/life-cycles/formatting-utils.js +44 -0
  528. package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.d.ts +17 -0
  529. package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +67 -0
  530. package/src/tasks-runner/life-cycles/pretty-time.d.ts +4 -0
  531. package/src/tasks-runner/life-cycles/pretty-time.js +74 -0
  532. package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +33 -0
  533. package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -0
  534. package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +31 -0
  535. package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +89 -0
  536. package/src/tasks-runner/life-cycles/store-run-information-life-cycle.d.ts +22 -0
  537. package/src/tasks-runner/life-cycles/store-run-information-life-cycle.js +87 -0
  538. package/src/tasks-runner/life-cycles/task-profiling-life-cycle.d.ts +19 -0
  539. package/src/tasks-runner/life-cycles/task-profiling-life-cycle.js +73 -0
  540. package/src/tasks-runner/life-cycles/task-timings-life-cycle.d.ts +13 -0
  541. package/src/tasks-runner/life-cycles/task-timings-life-cycle.js +39 -0
  542. package/src/tasks-runner/life-cycles/view-logs-utils.d.ts +1 -0
  543. package/src/tasks-runner/life-cycles/view-logs-utils.js +16 -0
  544. package/src/tasks-runner/psuedo-ipc.d.ts +49 -0
  545. package/src/tasks-runner/psuedo-ipc.js +140 -0
  546. package/src/tasks-runner/remove-old-cache-records.d.ts +1 -0
  547. package/src/tasks-runner/remove-old-cache-records.js +61 -0
  548. package/src/tasks-runner/run-command.d.ts +28 -0
  549. package/src/tasks-runner/run-command.js +353 -0
  550. package/src/tasks-runner/task-env.d.ts +8 -0
  551. package/src/tasks-runner/task-env.js +144 -0
  552. package/src/tasks-runner/task-graph-utils.d.ts +7 -0
  553. package/src/tasks-runner/task-graph-utils.js +55 -0
  554. package/src/tasks-runner/task-orchestrator.d.ts +50 -0
  555. package/src/tasks-runner/task-orchestrator.js +375 -0
  556. package/src/tasks-runner/tasks-runner.d.ts +23 -0
  557. package/src/tasks-runner/tasks-runner.js +2 -0
  558. package/src/tasks-runner/tasks-schedule.d.ts +36 -0
  559. package/src/tasks-runner/tasks-schedule.js +142 -0
  560. package/src/tasks-runner/utils.d.ts +51 -0
  561. package/src/tasks-runner/utils.js +293 -0
  562. package/src/utils/ab-testing.d.ts +51 -0
  563. package/src/utils/ab-testing.js +91 -0
  564. package/src/utils/all-file-data.d.ts +2 -0
  565. package/src/utils/all-file-data.js +15 -0
  566. package/src/utils/app-root.d.ts +8 -0
  567. package/src/utils/app-root.js +12 -0
  568. package/src/utils/assert-workspace-validity.d.ts +3 -0
  569. package/src/utils/assert-workspace-validity.js +84 -0
  570. package/src/utils/async-iterator.d.ts +2 -0
  571. package/src/utils/async-iterator.js +17 -0
  572. package/src/utils/cache-directory.d.ts +6 -0
  573. package/src/utils/cache-directory.js +60 -0
  574. package/src/utils/child-process.d.ts +19 -0
  575. package/src/utils/child-process.js +117 -0
  576. package/src/utils/chunkify.d.ts +1 -0
  577. package/src/utils/chunkify.js +38 -0
  578. package/src/utils/code-frames.d.ts +14 -0
  579. package/src/utils/code-frames.js +119 -0
  580. package/src/utils/collapse-expanded-outputs.d.ts +1 -0
  581. package/src/utils/collapse-expanded-outputs.js +41 -0
  582. package/src/utils/command-line-utils.d.ts +48 -0
  583. package/src/utils/command-line-utils.js +254 -0
  584. package/src/utils/consume-messages-from-socket.d.ts +1 -0
  585. package/src/utils/consume-messages-from-socket.js +22 -0
  586. package/src/utils/default-base.d.ts +1 -0
  587. package/src/utils/default-base.js +15 -0
  588. package/src/utils/exit-codes.d.ts +6 -0
  589. package/src/utils/exit-codes.js +20 -0
  590. package/src/utils/fileutils.d.ts +69 -0
  591. package/src/utils/fileutils.js +135 -0
  592. package/src/utils/find-matching-projects.d.ts +10 -0
  593. package/src/utils/find-matching-projects.js +198 -0
  594. package/src/utils/find-workspace-root.d.ts +11 -0
  595. package/src/utils/find-workspace-root.js +34 -0
  596. package/src/utils/globs.d.ts +1 -0
  597. package/src/utils/globs.js +8 -0
  598. package/src/utils/ignore.d.ts +8 -0
  599. package/src/utils/ignore.js +68 -0
  600. package/src/utils/installation-directory.d.ts +2 -0
  601. package/src/utils/installation-directory.js +13 -0
  602. package/src/utils/is-ci.d.ts +1 -0
  603. package/src/utils/is-ci.js +20 -0
  604. package/src/utils/json-diff.d.ts +18 -0
  605. package/src/utils/json-diff.js +112 -0
  606. package/src/utils/json.d.ts +44 -0
  607. package/src/utils/json.js +60 -0
  608. package/src/utils/logger.d.ts +11 -0
  609. package/src/utils/logger.js +47 -0
  610. package/src/utils/nx-cloud-utils.d.ts +4 -0
  611. package/src/utils/nx-cloud-utils.js +27 -0
  612. package/src/utils/nx-plugin.d.ts +119 -0
  613. package/src/utils/nx-plugin.deprecated.d.ts +31 -0
  614. package/src/utils/nx-plugin.deprecated.js +25 -0
  615. package/src/utils/nx-plugin.js +293 -0
  616. package/src/utils/object-sort.d.ts +1 -0
  617. package/src/utils/object-sort.js +10 -0
  618. package/src/utils/output.d.ts +72 -0
  619. package/src/utils/output.js +239 -0
  620. package/src/utils/package-json.d.ts +98 -0
  621. package/src/utils/package-json.js +134 -0
  622. package/src/utils/package-manager.d.ts +93 -0
  623. package/src/utils/package-manager.js +300 -0
  624. package/src/utils/params.d.ts +138 -0
  625. package/src/utils/params.js +684 -0
  626. package/src/utils/path.d.ts +19 -0
  627. package/src/utils/path.js +38 -0
  628. package/src/utils/perf-logging.d.ts +1 -0
  629. package/src/utils/perf-logging.js +11 -0
  630. package/src/utils/plugins/community-plugins.d.ts +2 -0
  631. package/src/utils/plugins/community-plugins.js +29 -0
  632. package/src/utils/plugins/core-plugins.d.ts +3 -0
  633. package/src/utils/plugins/core-plugins.js +114 -0
  634. package/src/utils/plugins/index.d.ts +4 -0
  635. package/src/utils/plugins/index.js +14 -0
  636. package/src/utils/plugins/installed-plugins.d.ts +6 -0
  637. package/src/utils/plugins/installed-plugins.js +104 -0
  638. package/src/utils/plugins/local-plugins.d.ts +5 -0
  639. package/src/utils/plugins/local-plugins.js +58 -0
  640. package/src/utils/plugins/models.d.ts +22 -0
  641. package/src/utils/plugins/models.js +2 -0
  642. package/src/utils/plugins/plugin-capabilities.d.ts +4 -0
  643. package/src/utils/plugins/plugin-capabilities.js +124 -0
  644. package/src/utils/plugins/shared.d.ts +1 -0
  645. package/src/utils/plugins/shared.js +8 -0
  646. package/src/utils/print-help.d.ts +11 -0
  647. package/src/utils/print-help.js +265 -0
  648. package/src/utils/project-graph-utils.d.ts +13 -0
  649. package/src/utils/project-graph-utils.js +74 -0
  650. package/src/utils/promised-based-queue.d.ts +6 -0
  651. package/src/utils/promised-based-queue.js +43 -0
  652. package/src/utils/serialize-overrides-into-command-line.d.ts +3 -0
  653. package/src/utils/serialize-overrides-into-command-line.js +43 -0
  654. package/src/utils/split-target.d.ts +3 -0
  655. package/src/utils/split-target.js +49 -0
  656. package/src/utils/strip-indents.d.ts +14 -0
  657. package/src/utils/strip-indents.js +24 -0
  658. package/src/utils/typescript.d.ts +1 -0
  659. package/src/utils/typescript.js +5 -0
  660. package/src/utils/update-nxw.d.ts +2 -0
  661. package/src/utils/update-nxw.js +12 -0
  662. package/src/utils/versions.d.ts +1 -0
  663. package/src/utils/versions.js +4 -0
  664. package/src/utils/workspace-configuration-check.d.ts +1 -0
  665. package/src/utils/workspace-configuration-check.js +37 -0
  666. package/src/utils/workspace-context.d.ts +10 -0
  667. package/src/utils/workspace-context.js +56 -0
  668. package/src/utils/workspace-root.d.ts +6 -0
  669. package/src/utils/workspace-root.js +39 -0
  670. package/tasks-runners/default.d.ts +1 -0
  671. package/tasks-runners/default.js +5 -0
@@ -0,0 +1,848 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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
+ const core_1 = require("@angular-devkit/core");
5
+ const node_1 = require("@angular-devkit/core/node");
6
+ const chalk = require("chalk");
7
+ const path_1 = require("path");
8
+ const rxjs_1 = require("rxjs");
9
+ const operators_1 = require("rxjs/operators");
10
+ const tree_1 = require("../generators/tree");
11
+ const json_1 = require("../generators/utils/json");
12
+ const project_configuration_1 = require("../generators/utils/project-configuration");
13
+ const project_graph_1 = require("../project-graph/project-graph");
14
+ const fileutils_1 = require("../utils/fileutils");
15
+ const installation_directory_1 = require("../utils/installation-directory");
16
+ const json_2 = require("../utils/json");
17
+ const logger_1 = require("../utils/logger");
18
+ const package_json_1 = require("../utils/package-json");
19
+ const package_manager_1 = require("../utils/package-manager");
20
+ const angular_json_1 = require("./angular-json");
21
+ const executor_utils_1 = require("../command-line/run/executor-utils");
22
+ const nx_plugin_1 = require("../utils/nx-plugin");
23
+ const schema_utils_1 = require("../config/schema-utils");
24
+ async function createBuilderContext(builderInfo, context) {
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);
32
+ const registry = new core_1.schema.CoreSchemaRegistry();
33
+ registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
34
+ registry.addSmartDefaultProvider('unparsed', () => {
35
+ // This happens when context.scheduleTarget is used to run a target using nx:run-commands
36
+ return [];
37
+ });
38
+ const { Architect } = require('@angular-devkit/architect');
39
+ const architect = new Architect(architectHost, registry);
40
+ const { firstValueFrom } = require('rxjs');
41
+ const toPromise = (obs) => firstValueFrom ? firstValueFrom(obs) : obs.toPromise();
42
+ const validateOptions = (options, builderName) => toPromise(architect['_scheduler'].schedule('..validateOptions', [
43
+ builderName,
44
+ options,
45
+ ]).output);
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
+ };
69
+ const builderContext = {
70
+ workspaceRoot: context.root,
71
+ target: {
72
+ project: context.projectName,
73
+ target: context.targetName,
74
+ configuration: context.configurationName,
75
+ },
76
+ builder: {
77
+ ...builderInfo,
78
+ },
79
+ logger: (0, exports.getLogger)(),
80
+ id: 1,
81
+ currentDirectory: process.cwd(),
82
+ scheduleTarget: architect.scheduleTarget,
83
+ scheduleBuilder: architect.scheduleBuilder,
84
+ addTeardown(teardown) {
85
+ // No-op as Nx doesn't require an implementation of this function
86
+ return;
87
+ },
88
+ reportProgress(...args) {
89
+ // No-op as Nx doesn't require an implementation of this function
90
+ return;
91
+ },
92
+ reportRunning(...args) {
93
+ // No-op as Nx doesn't require an implementation of this function
94
+ return;
95
+ },
96
+ reportStatus(status) {
97
+ // No-op as Nx doesn't require an implementation of this function
98
+ return;
99
+ },
100
+ getBuilderNameForTarget,
101
+ getProjectMetadata,
102
+ validateOptions,
103
+ getTargetOptions,
104
+ };
105
+ return builderContext;
106
+ }
107
+ exports.createBuilderContext = createBuilderContext;
108
+ async function scheduleTarget(root, opts, verbose) {
109
+ const { Architect } = require('@angular-devkit/architect');
110
+ const logger = (0, exports.getLogger)(verbose);
111
+ const fsHost = new NxScopedHostForBuilders(root);
112
+ const { workspace } = await core_1.workspaces.readWorkspace('angular.json', core_1.workspaces.createWorkspaceHost(fsHost));
113
+ const registry = new core_1.schema.CoreSchemaRegistry();
114
+ registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
115
+ registry.addSmartDefaultProvider('unparsed', () => {
116
+ // This happens when context.scheduleTarget is used to run a target using nx:run-commands
117
+ return [];
118
+ });
119
+ const architectHost = await getWrappedWorkspaceNodeModulesArchitectHost(workspace, root, opts.projects);
120
+ const architect = new Architect(architectHost, registry);
121
+ const run = await architect.scheduleTarget({
122
+ project: opts.project,
123
+ target: opts.target,
124
+ configuration: opts.configuration,
125
+ }, opts.runOptions, { logger });
126
+ let lastOutputError;
127
+ return run.output.pipe((0, operators_1.tap)((output) => (lastOutputError = !output.success ? output.error : undefined), (error) => { }, // do nothing, this could be an intentional error
128
+ () => {
129
+ lastOutputError ? logger.error(lastOutputError) : 0;
130
+ }));
131
+ }
132
+ exports.scheduleTarget = scheduleTarget;
133
+ function createNodeModulesEngineHost(resolvePaths, projects) {
134
+ const NodeModulesEngineHost = require('@angular-devkit/schematics/tools')
135
+ .NodeModulesEngineHost;
136
+ class NxNodeModulesEngineHost extends NodeModulesEngineHost {
137
+ constructor() {
138
+ super(resolvePaths);
139
+ }
140
+ _resolveCollectionPath(name, requester) {
141
+ let collectionFilePath;
142
+ const paths = requester
143
+ ? [(0, path_1.dirname)(requester), ...(resolvePaths || [])]
144
+ : resolvePaths || [];
145
+ if (name.endsWith('.json')) {
146
+ collectionFilePath = require.resolve(name, { paths });
147
+ }
148
+ else {
149
+ const { json: { generators, schematics }, path: packageJsonPath, } = (0, nx_plugin_1.readPluginPackageJson)(name, projects, paths);
150
+ if (!schematics && !generators) {
151
+ throw new Error(`The "${name}" package does not support Nx generators or Angular Devkit schematics.`);
152
+ }
153
+ collectionFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), schematics ?? generators));
154
+ }
155
+ return collectionFilePath;
156
+ }
157
+ _transformCollectionDescription(name, desc) {
158
+ desc.schematics ??= desc.generators;
159
+ return super._transformCollectionDescription(name, desc);
160
+ }
161
+ }
162
+ return new NxNodeModulesEngineHost();
163
+ }
164
+ function createWorkflow(fsHost, root, opts, projects) {
165
+ const NodeWorkflow = require('@angular-devkit/schematics/tools').NodeWorkflow;
166
+ const workflow = new NodeWorkflow(fsHost, {
167
+ force: false,
168
+ dryRun: opts.dryRun,
169
+ packageManager: (0, package_manager_1.detectPackageManager)(),
170
+ root: (0, core_1.normalize)(root),
171
+ registry: new core_1.schema.CoreSchemaRegistry(require('@angular-devkit/schematics').formats.standardFormats),
172
+ resolvePaths: [process.cwd(), root],
173
+ engineHostCreator: (options) => createNodeModulesEngineHost(options.resolvePaths, projects),
174
+ });
175
+ workflow.registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
176
+ workflow.engineHost.registerOptionsTransform(require('@angular-devkit/schematics/tools').validateOptionsWithSchema(workflow.registry));
177
+ if (opts.interactive) {
178
+ workflow.registry.usePromptProvider(createPromptProvider());
179
+ }
180
+ return workflow;
181
+ }
182
+ function getCollection(workflow, name) {
183
+ const collection = workflow.engine.createCollection(name);
184
+ if (!collection)
185
+ throw new Error(`Cannot find collection '${name}'`);
186
+ return collection;
187
+ }
188
+ async function createRecorder(host, record, logger) {
189
+ return (event) => {
190
+ let eventPath = event.path.startsWith('/')
191
+ ? event.path.slice(1)
192
+ : event.path;
193
+ if (event.kind === 'error') {
194
+ record.error = true;
195
+ logger.warn(`ERROR! ${eventPath} ${event.description == 'alreadyExist'
196
+ ? 'already exists'
197
+ : 'does not exist.'}.`);
198
+ }
199
+ else if (event.kind === 'update') {
200
+ record.loggingQueue.push(core_1.tags.oneLine `${chalk.white('UPDATE')} ${eventPath}`);
201
+ }
202
+ else if (event.kind === 'create') {
203
+ record.loggingQueue.push(core_1.tags.oneLine `${chalk.green('CREATE')} ${eventPath}`);
204
+ }
205
+ else if (event.kind === 'delete') {
206
+ record.loggingQueue.push(`${chalk.yellow('DELETE')} ${eventPath}`);
207
+ }
208
+ else if (event.kind === 'rename') {
209
+ record.loggingQueue.push(`${chalk.blue('RENAME')} ${eventPath} => ${event.to}`);
210
+ }
211
+ };
212
+ }
213
+ async function runSchematic(host, root, workflow, logger, opts, schematic, printDryRunMessage = true, recorder = null) {
214
+ const record = { loggingQueue: [], error: false };
215
+ workflow.reporter.subscribe(recorder || (await createRecorder(host, record, logger)));
216
+ try {
217
+ await workflow
218
+ .execute({
219
+ collection: opts.collectionName,
220
+ schematic: opts.generatorName,
221
+ options: opts.generatorOptions,
222
+ debug: false,
223
+ logger,
224
+ })
225
+ .toPromise();
226
+ }
227
+ catch (e) {
228
+ console.error(e);
229
+ throw e;
230
+ }
231
+ if (!record.error) {
232
+ record.loggingQueue.forEach((log) => logger.info(log));
233
+ }
234
+ if (opts.dryRun && printDryRunMessage) {
235
+ logger.warn(`\nNOTE: The "dryRun" flag means no changes were made.`);
236
+ }
237
+ return { status: 0, loggingQueue: record.loggingQueue };
238
+ }
239
+ class NxScopedHost extends core_1.virtualFs.ScopedHost {
240
+ constructor(root) {
241
+ super(new node_1.NodeJsSyncHost(), (0, core_1.normalize)(root));
242
+ this.root = root;
243
+ }
244
+ read(path) {
245
+ if ((path === 'angular.json' || path === '/angular.json') &&
246
+ (0, angular_json_1.isAngularPluginInstalled)()) {
247
+ return this.readMergedWorkspaceConfiguration().pipe((0, operators_1.map)((r) => Buffer.from(JSON.stringify((0, angular_json_1.toOldFormat)(r)))));
248
+ }
249
+ else {
250
+ return super.read(path);
251
+ }
252
+ }
253
+ readMergedWorkspaceConfiguration() {
254
+ return (0, rxjs_1.zip)((0, rxjs_1.from)((0, project_graph_1.createProjectGraphAsync)()), this.readExistingAngularJson(), this.readJson('nx.json')).pipe((0, operators_1.concatMap)(([graph, angularJson, nxJson]) => {
255
+ const workspaceConfig = (angularJson || { projects: {} });
256
+ workspaceConfig.cli ??= nxJson.cli;
257
+ workspaceConfig.schematics ??= nxJson.generators;
258
+ const projectJsonReads = [];
259
+ for (let projectName of Object.keys(graph.nodes)) {
260
+ if (!workspaceConfig.projects[projectName]) {
261
+ projectJsonReads.push((0, rxjs_1.zip)((0, rxjs_1.of)(projectName), this.readJson((0, path_1.join)(graph.nodes[projectName].data.root, 'project.json'))));
262
+ }
263
+ }
264
+ return (0, rxjs_1.zip)(...projectJsonReads).pipe((0, operators_1.map)((reads) => {
265
+ reads
266
+ .filter(([, p]) => p !== null)
267
+ .forEach(([projectName, project]) => {
268
+ workspaceConfig.projects[projectName] = {
269
+ ...project,
270
+ root: graph.nodes[projectName].data.root,
271
+ };
272
+ });
273
+ return workspaceConfig;
274
+ }));
275
+ }), (0, operators_1.catchError)((err) => {
276
+ console.error('Unable to read angular.json');
277
+ console.error(err);
278
+ process.exit(1);
279
+ }));
280
+ }
281
+ write(path, content) {
282
+ if (path === 'angular.json' || path === '/angular.json') {
283
+ const configV2 = (0, angular_json_1.toNewFormat)((0, json_2.parseJson)(content.toString()));
284
+ const root = this.root;
285
+ return (0, rxjs_1.zip)(this.readMergedWorkspaceConfiguration(), this.readExistingAngularJson()).pipe((0, operators_1.concatMap)((arg) => {
286
+ const existingConfig = arg[0];
287
+ const existingAngularJson = arg[1];
288
+ const projectsInAngularJson = existingAngularJson
289
+ ? Object.keys(existingAngularJson.projects)
290
+ : [];
291
+ const projects = configV2.projects;
292
+ const allObservables = [];
293
+ Object.keys(projects).forEach((projectName) => {
294
+ if (projectsInAngularJson.includes(projectName)) {
295
+ // ignore updates to angular.json
296
+ }
297
+ else {
298
+ (0, project_configuration_1.updateProjectConfiguration)({
299
+ root,
300
+ exists: () => true,
301
+ write: (path, content) => {
302
+ if (existingConfig.projects[projectName]) {
303
+ const updatedContent = this.mergeProjectConfiguration(existingConfig.projects[projectName], projects[projectName], projectName);
304
+ if (updatedContent) {
305
+ delete updatedContent.root;
306
+ allObservables.push(super.write(path, Buffer.from(JSON.stringify(updatedContent, null, 2))));
307
+ }
308
+ }
309
+ else {
310
+ allObservables.push(super.write(path, Buffer.from(content)));
311
+ }
312
+ },
313
+ }, projectName, projects[projectName]);
314
+ }
315
+ });
316
+ return (0, rxjs_1.concat)(...allObservables);
317
+ }));
318
+ }
319
+ else {
320
+ return super.write(path, content);
321
+ }
322
+ }
323
+ isFile(path) {
324
+ if (path === 'angular.json' || path === '/angular.json') {
325
+ return (0, rxjs_1.of)(true);
326
+ }
327
+ else {
328
+ return super.isFile(path);
329
+ }
330
+ }
331
+ exists(path) {
332
+ if (path === 'angular.json' || path === '/angular.json') {
333
+ return (0, rxjs_1.of)(true);
334
+ }
335
+ else {
336
+ return super.exists(path);
337
+ }
338
+ }
339
+ mergeProjectConfiguration(existing, updated, projectName) {
340
+ const res = { ...existing };
341
+ let modified = false;
342
+ function updatePropertyIfDifferent(property) {
343
+ if (typeof res[property] === 'string') {
344
+ if (res[property] !== updated[property]) {
345
+ res[property] = updated[property];
346
+ modified = true;
347
+ }
348
+ }
349
+ else if (JSON.stringify(res[property]) !== JSON.stringify(updated[property])) {
350
+ res[property] = updated[property];
351
+ modified = true;
352
+ }
353
+ }
354
+ if (!res.name || (updated.name && res.name !== updated.name)) {
355
+ res.name ??= updated.name || projectName;
356
+ modified = true;
357
+ }
358
+ updatePropertyIfDifferent('projectType');
359
+ updatePropertyIfDifferent('sourceRoot');
360
+ updatePropertyIfDifferent('prefix');
361
+ updatePropertyIfDifferent('targets');
362
+ updatePropertyIfDifferent('generators');
363
+ updatePropertyIfDifferent('implicitDependencies');
364
+ updatePropertyIfDifferent('tags');
365
+ return modified ? res : null;
366
+ }
367
+ readExistingAngularJson() {
368
+ return this.readJson('angular.json');
369
+ }
370
+ readJson(path) {
371
+ return super
372
+ .exists(path)
373
+ .pipe((0, operators_1.concatMap)((r) => r
374
+ ? super
375
+ .read(path)
376
+ .pipe((0, operators_1.map)((r) => (0, json_2.parseJson)(arrayBufferToString(r))))
377
+ : (0, rxjs_1.of)(null)));
378
+ }
379
+ }
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;
405
+ function arrayBufferToString(buffer) {
406
+ const array = new Uint8Array(buffer);
407
+ let result = '';
408
+ const chunkSize = 8 * 1024;
409
+ let i = 0;
410
+ for (i = 0; i < array.length / chunkSize; i++) {
411
+ result += String.fromCharCode.apply(null, array.subarray(i * chunkSize, (i + 1) * chunkSize));
412
+ }
413
+ result += String.fromCharCode.apply(null, array.subarray(i * chunkSize));
414
+ return result;
415
+ }
416
+ exports.arrayBufferToString = arrayBufferToString;
417
+ /**
418
+ * Host used by Angular CLI schematics. It reads the project configurations from
419
+ * the project configuration files.
420
+ */
421
+ class NxScopeHostUsedForWrappedSchematics extends NxScopedHost {
422
+ constructor(root, host) {
423
+ super(root);
424
+ this.host = host;
425
+ }
426
+ read(path) {
427
+ if ((path === 'angular.json' || path === '/angular.json') &&
428
+ (0, angular_json_1.isAngularPluginInstalled)()) {
429
+ const projectJsonConfig = (0, angular_json_1.toOldFormat)({
430
+ projects: Object.fromEntries((0, project_configuration_1.getProjects)(this.host)),
431
+ });
432
+ return super.readExistingAngularJson().pipe((0, operators_1.map)((angularJson) => {
433
+ if (angularJson) {
434
+ return Buffer.from(JSON.stringify({
435
+ version: 1,
436
+ projects: {
437
+ ...projectJsonConfig.projects,
438
+ ...angularJson.projects,
439
+ },
440
+ }));
441
+ }
442
+ else {
443
+ return Buffer.from(JSON.stringify(projectJsonConfig));
444
+ }
445
+ }));
446
+ }
447
+ else {
448
+ const match = findMatchingFileChange(this.host, path);
449
+ if (match) {
450
+ return (0, rxjs_1.of)(Buffer.from(match.content));
451
+ }
452
+ else {
453
+ return super.read(path);
454
+ }
455
+ }
456
+ }
457
+ exists(path) {
458
+ if (this.host.exists(path)) {
459
+ return (0, rxjs_1.of)(true);
460
+ }
461
+ else if (path === 'angular.json' || path === '/angular.json') {
462
+ return (0, rxjs_1.of)(true);
463
+ }
464
+ else {
465
+ return super.exists(path);
466
+ }
467
+ }
468
+ isDirectory(path) {
469
+ if (this.host.exists(path) && !this.host.isFile(path)) {
470
+ return (0, rxjs_1.of)(true);
471
+ }
472
+ else if (path === 'angular.json' || path === '/angular.json') {
473
+ return (0, rxjs_1.of)(false);
474
+ }
475
+ else {
476
+ return super.isDirectory(path);
477
+ }
478
+ }
479
+ isFile(path) {
480
+ if (this.host.isFile(path)) {
481
+ return (0, rxjs_1.of)(true);
482
+ }
483
+ else if (path === 'angular.json' || path === '/angular.json') {
484
+ return (0, rxjs_1.of)(true);
485
+ }
486
+ else {
487
+ return super.isFile(path);
488
+ }
489
+ }
490
+ list(path) {
491
+ const fragments = this.host.children(path).map((child) => (0, core_1.fragment)(child));
492
+ return (0, rxjs_1.of)(fragments);
493
+ }
494
+ }
495
+ exports.NxScopeHostUsedForWrappedSchematics = NxScopeHostUsedForWrappedSchematics;
496
+ function findMatchingFileChange(host, path) {
497
+ const targetPath = (0, core_1.normalize)(path.startsWith('/') ? path.substring(1) : path.toString());
498
+ return host
499
+ .listChanges()
500
+ .find((f) => f.type !== 'DELETE' && (0, core_1.normalize)(f.path) === targetPath);
501
+ }
502
+ async function generate(root, opts, projects, verbose) {
503
+ const logger = (0, exports.getLogger)(verbose);
504
+ const fsHost = new NxScopeHostUsedForWrappedSchematics(root, new tree_1.FsTree(root, verbose, `ng-cli generator: ${opts.collectionName}:${opts.generatorName}`));
505
+ const workflow = createWorkflow(fsHost, root, opts, projects);
506
+ const collection = getCollection(workflow, opts.collectionName);
507
+ const schematic = collection.createSchematic(opts.generatorName, true);
508
+ return (await runSchematic(fsHost, root, workflow, logger, { ...opts, generatorName: schematic.description.name }, schematic)).status;
509
+ }
510
+ exports.generate = generate;
511
+ function createPromptProvider() {
512
+ return (definitions) => {
513
+ const questions = definitions.map((definition) => {
514
+ const question = {
515
+ name: definition.id,
516
+ message: definition.message,
517
+ };
518
+ if (definition.default) {
519
+ question.initial = definition.default;
520
+ }
521
+ const validator = definition.validator;
522
+ if (validator) {
523
+ question.validate = (input) => validator(input);
524
+ }
525
+ switch (definition.type) {
526
+ case 'string':
527
+ case 'input':
528
+ return { ...question, type: 'input' };
529
+ case 'boolean':
530
+ case 'confirmation':
531
+ case 'confirm':
532
+ return { ...question, type: 'confirm' };
533
+ case 'number':
534
+ case 'numeral':
535
+ return { ...question, type: 'numeral' };
536
+ case 'list':
537
+ return {
538
+ ...question,
539
+ type: !!definition.multiselect ? 'multiselect' : 'select',
540
+ choices: definition.items &&
541
+ definition.items.map((item) => {
542
+ if (typeof item == 'string') {
543
+ return item;
544
+ }
545
+ else {
546
+ return {
547
+ message: item.label,
548
+ name: item.value,
549
+ };
550
+ }
551
+ }),
552
+ };
553
+ default:
554
+ return { ...question, type: definition.type };
555
+ }
556
+ });
557
+ return require('enquirer').prompt(questions);
558
+ };
559
+ }
560
+ async function runMigration(root, packageName, migrationName, projects, isVerbose) {
561
+ const logger = (0, exports.getLogger)(isVerbose);
562
+ const fsHost = new NxScopeHostUsedForWrappedSchematics(root, new tree_1.FsTree(root, isVerbose, `ng-cli migration: ${packageName}:${migrationName}`));
563
+ const workflow = createWorkflow(fsHost, root, {}, projects);
564
+ const collection = resolveMigrationsCollection(packageName);
565
+ const record = { loggingQueue: [], error: false };
566
+ workflow.reporter.subscribe(await createRecorder(fsHost, record, logger));
567
+ await workflow
568
+ .execute({
569
+ collection,
570
+ schematic: migrationName,
571
+ options: {},
572
+ debug: false,
573
+ logger: logger,
574
+ })
575
+ .toPromise();
576
+ return {
577
+ loggingQueue: record.loggingQueue,
578
+ madeChanges: record.loggingQueue.length > 0,
579
+ };
580
+ }
581
+ exports.runMigration = runMigration;
582
+ function resolveMigrationsCollection(name) {
583
+ let collectionPath = undefined;
584
+ if (name.startsWith('.') || name.startsWith('/')) {
585
+ name = (0, path_1.resolve)(name);
586
+ }
587
+ if ((0, path_1.extname)(name)) {
588
+ collectionPath = require.resolve(name);
589
+ }
590
+ else {
591
+ const { path: packageJsonPath, packageJson } = (0, package_json_1.readModulePackageJson)(name, (0, installation_directory_1.getNxRequirePaths)(process.cwd()));
592
+ let pkgJsonSchematics = packageJson['nx-migrations'] ?? packageJson['ng-update'];
593
+ if (!pkgJsonSchematics) {
594
+ throw new Error(`Could not find migrations in package: "${name}"`);
595
+ }
596
+ if (typeof pkgJsonSchematics != 'string') {
597
+ pkgJsonSchematics = pkgJsonSchematics.migrations;
598
+ }
599
+ collectionPath = require.resolve(pkgJsonSchematics, {
600
+ paths: [(0, path_1.dirname)(packageJsonPath)],
601
+ });
602
+ }
603
+ try {
604
+ if (collectionPath) {
605
+ (0, fileutils_1.readJsonFile)(collectionPath);
606
+ return collectionPath;
607
+ }
608
+ }
609
+ catch {
610
+ throw new Error(`Invalid migration file in package: "${name}"`);
611
+ }
612
+ throw new Error(`Collection cannot be resolved: "${name}"`);
613
+ }
614
+ let collectionResolutionOverrides = null;
615
+ let mockedSchematics = null;
616
+ /**
617
+ * If you have an Nx Devkit generator invoking the wrapped Angular Devkit schematic,
618
+ * and you don't want the Angular Devkit schematic to run, you can mock it up using this function.
619
+ *
620
+ * Unfortunately, there are some edge cases in the Nx-Angular devkit integration that
621
+ * can be seen in the unit tests context. This function is useful for handling that as well.
622
+ *
623
+ * In this case, you can mock it up.
624
+ *
625
+ * Example:
626
+ *
627
+ * ```typescript
628
+ * mockSchematicsForTesting({
629
+ * 'mycollection:myschematic': (tree, params) => {
630
+ * tree.write("README.md");
631
+ * }
632
+ * });
633
+ *
634
+ * ```
635
+ */
636
+ function mockSchematicsForTesting(schematics) {
637
+ mockedSchematics = schematics;
638
+ }
639
+ exports.mockSchematicsForTesting = mockSchematicsForTesting;
640
+ function wrapAngularDevkitSchematic(collectionName, generatorName) {
641
+ // This is idempotent, if it happens to get called
642
+ // multiple times its no big deal. It ensures that some
643
+ // patches are applied to @angular-devkit code which
644
+ // are necessary. For the most part, our wrapped host hits
645
+ // the necessary areas, but for some things it wouldn't make
646
+ // sense for the adapter to be 100% accurate.
647
+ //
648
+ // e.g. Angular warns about tags, but some angular CLI schematics
649
+ // were written with Nx in mind, and may care about tags.
650
+ require('./compat');
651
+ return async (host, generatorOptions) => {
652
+ const graph = await (0, project_graph_1.createProjectGraphAsync)();
653
+ const { projects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(graph);
654
+ if (mockedSchematics &&
655
+ mockedSchematics[`${collectionName}:${generatorName}`]) {
656
+ return await mockedSchematics[`${collectionName}:${generatorName}`](host, generatorOptions);
657
+ }
658
+ const emptyLogger = {
659
+ log: (e) => { },
660
+ info: (e) => { },
661
+ warn: (e) => { },
662
+ debug: () => { },
663
+ error: (e) => { },
664
+ fatal: (e) => { },
665
+ };
666
+ emptyLogger.createChild = () => emptyLogger;
667
+ const recorder = (event) => {
668
+ let eventPath = event.path.startsWith('/')
669
+ ? event.path.slice(1)
670
+ : event.path;
671
+ if (event.kind === 'error') {
672
+ }
673
+ else if (event.kind === 'update') {
674
+ // Apply special handling for the angular.json file, but only when in an Nx workspace
675
+ if (eventPath === 'angular.json' && (0, angular_json_1.isAngularPluginInstalled)()) {
676
+ saveProjectsConfigurationsInWrappedSchematic(host, event.content.toString());
677
+ }
678
+ else {
679
+ host.write(eventPath, event.content);
680
+ }
681
+ }
682
+ else if (event.kind === 'create') {
683
+ host.write(eventPath, event.content);
684
+ }
685
+ else if (event.kind === 'delete') {
686
+ host.delete(eventPath);
687
+ }
688
+ else if (event.kind === 'rename') {
689
+ host.rename(eventPath, event.to);
690
+ }
691
+ };
692
+ const fsHost = new NxScopeHostUsedForWrappedSchematics(host.root, host);
693
+ const options = {
694
+ generatorOptions,
695
+ dryRun: true,
696
+ interactive: false,
697
+ help: false,
698
+ debug: false,
699
+ collectionName,
700
+ generatorName,
701
+ force: false,
702
+ defaults: false,
703
+ quiet: false,
704
+ };
705
+ const workflow = createWorkflow(fsHost, host.root, options, projects);
706
+ // used for testing
707
+ if (collectionResolutionOverrides) {
708
+ const r = workflow.engineHost.resolve;
709
+ workflow.engineHost.resolve = (collection, b, c) => {
710
+ if (collectionResolutionOverrides[collection]) {
711
+ return collectionResolutionOverrides[collection];
712
+ }
713
+ else {
714
+ return r.apply(workflow.engineHost, [collection, b, c]);
715
+ }
716
+ };
717
+ }
718
+ const collection = getCollection(workflow, collectionName);
719
+ const schematic = collection.createSchematic(generatorName, true);
720
+ const res = await runSchematic(fsHost, host.root, workflow, emptyLogger, options, schematic, false, recorder);
721
+ if (res.status !== 0) {
722
+ throw new Error(res.loggingQueue.join('\n'));
723
+ }
724
+ };
725
+ }
726
+ exports.wrapAngularDevkitSchematic = wrapAngularDevkitSchematic;
727
+ let logger;
728
+ const getLogger = (isVerbose = false) => {
729
+ if (!logger) {
730
+ logger = (0, node_1.createConsoleLogger)(isVerbose, process.stdout, process.stderr, {
731
+ warn: (s) => chalk.bold(chalk.yellow(s)),
732
+ error: (s) => {
733
+ if (s.startsWith('NX ')) {
734
+ return `\n${logger_1.NX_ERROR} ${chalk.bold(chalk.red(s.slice(3)))}\n`;
735
+ }
736
+ return chalk.bold(chalk.red(s));
737
+ },
738
+ info: (s) => {
739
+ if (s.startsWith('NX ')) {
740
+ return `\n${logger_1.NX_PREFIX} ${chalk.bold(s.slice(3))}\n`;
741
+ }
742
+ return chalk.white(s);
743
+ },
744
+ });
745
+ }
746
+ return logger;
747
+ };
748
+ exports.getLogger = getLogger;
749
+ function saveProjectsConfigurationsInWrappedSchematic(host, content) {
750
+ const projects = (0, angular_json_1.toNewFormat)((0, json_2.parseJson)(content)).projects;
751
+ const existingProjects = (0, project_configuration_1.getProjects)(host);
752
+ const existingAngularJson = host.exists('angular.json')
753
+ ? (0, json_1.readJson)(host, 'angular.json')
754
+ : null;
755
+ const projectsInAngularJson = existingAngularJson
756
+ ? Object.keys(existingAngularJson.projects)
757
+ : [];
758
+ const newAngularJson = existingAngularJson || {};
759
+ // Reset projects in order to rebuild them, but leave other properties untouched
760
+ newAngularJson.projects = {};
761
+ Object.keys(projects).forEach((projectName) => {
762
+ if (projectsInAngularJson.includes(projectName)) {
763
+ newAngularJson.projects[projectName] = projects[projectName];
764
+ }
765
+ else {
766
+ if (existingProjects.has(projectName)) {
767
+ if (JSON.stringify(existingProjects.get(projectName)) !==
768
+ JSON.stringify(projects[projectName])) {
769
+ (0, project_configuration_1.updateProjectConfiguration)(host, projectName, projects[projectName]);
770
+ }
771
+ }
772
+ else {
773
+ (0, project_configuration_1.addProjectConfiguration)(host, projectName, projects[projectName]);
774
+ }
775
+ }
776
+ });
777
+ if (Object.keys(newAngularJson.projects).length > 0) {
778
+ host.write('angular.json', JSON.stringify((0, angular_json_1.toOldFormat)(newAngularJson), null, 2));
779
+ }
780
+ }
781
+ async function getWrappedWorkspaceNodeModulesArchitectHost(workspace, root, projects) {
782
+ const { WorkspaceNodeModulesArchitectHost: AngularWorkspaceNodeModulesArchitectHost, } = await Promise.resolve().then(() => require('@angular-devkit/architect/node'));
783
+ class WrappedWorkspaceNodeModulesArchitectHost extends AngularWorkspaceNodeModulesArchitectHost {
784
+ constructor(workspace, root, projects) {
785
+ super(workspace, root);
786
+ this.workspace = workspace;
787
+ this.root = root;
788
+ this.projects = projects;
789
+ }
790
+ async resolveBuilder(builderStr) {
791
+ const [packageName, builderName] = builderStr.split(':');
792
+ const { executorsFilePath, executorConfig } = this.readExecutorsJson(packageName, builderName);
793
+ const builderInfo = this.readExecutor(packageName, builderName);
794
+ const { builders, executors } = (0, fileutils_1.readJsonFile)(executorsFilePath);
795
+ return {
796
+ name: builderStr,
797
+ builderName,
798
+ description: builders?.[builderName]?.description ??
799
+ executors?.[builderName]?.description,
800
+ optionSchema: builderInfo.schema,
801
+ import: (0, schema_utils_1.resolveImplementation)(executorConfig.implementation, (0, path_1.dirname)(executorsFilePath)),
802
+ };
803
+ }
804
+ readExecutorsJson(nodeModule, builder) {
805
+ const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(nodeModule, this.projects, this.root ? [this.root, __dirname] : [__dirname]);
806
+ const executorsFile = packageJson.executors ?? packageJson.builders;
807
+ if (!executorsFile) {
808
+ throw new Error(`The "${nodeModule}" package does not support Nx executors or Angular Devkit Builders.`);
809
+ }
810
+ const executorsFilePath = require.resolve((0, path_1.join)((0, path_1.dirname)(packageJsonPath), executorsFile));
811
+ const executorsJson = (0, fileutils_1.readJsonFile)(executorsFilePath);
812
+ const executorConfig = executorsJson.builders?.[builder] ?? executorsJson.executors?.[builder];
813
+ if (!executorConfig) {
814
+ throw new Error(`Cannot find builder '${builder}' in ${executorsFilePath}.`);
815
+ }
816
+ return { executorsFilePath, executorConfig, isNgCompat: true };
817
+ }
818
+ readExecutor(nodeModule, executor) {
819
+ try {
820
+ const { executorsFilePath, executorConfig, isNgCompat } = this.readExecutorsJson(nodeModule, executor);
821
+ const executorsDir = (0, path_1.dirname)(executorsFilePath);
822
+ const schemaPath = (0, schema_utils_1.resolveSchema)(executorConfig.schema, executorsDir);
823
+ const schema = (0, executor_utils_1.normalizeExecutorSchema)((0, fileutils_1.readJsonFile)(schemaPath));
824
+ const implementationFactory = this.getImplementationFactory(executorConfig.implementation, executorsDir);
825
+ const batchImplementationFactory = executorConfig.batchImplementation
826
+ ? this.getImplementationFactory(executorConfig.batchImplementation, executorsDir)
827
+ : null;
828
+ const hasherFactory = executorConfig.hasher
829
+ ? this.getImplementationFactory(executorConfig.hasher, executorsDir)
830
+ : null;
831
+ return {
832
+ schema,
833
+ implementationFactory,
834
+ batchImplementationFactory,
835
+ hasherFactory,
836
+ isNgCompat,
837
+ };
838
+ }
839
+ catch (e) {
840
+ throw new Error(`Unable to resolve ${nodeModule}:${executor}.\n${e.message}`);
841
+ }
842
+ }
843
+ getImplementationFactory(implementation, executorsDir) {
844
+ return (0, schema_utils_1.getImplementationFactory)(implementation, executorsDir);
845
+ }
846
+ }
847
+ return new WrappedWorkspaceNodeModulesArchitectHost(workspace, root, projects);
848
+ }