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,14 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.mergeTargetConfigurations = exports.readProjectConfigurationsFromRootMap = exports.buildProjectsConfigurationsFromProjectPathsAndPlugins = exports.mergeProjectConfigurationIntoRootMap = void 0;
3
+ exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.MergeNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.readProjectConfigurationsFromRootMap = exports.createProjectConfigurations = exports.mergeProjectConfigurationIntoRootMap = void 0;
4
4
  const logger_1 = require("../../utils/logger");
5
+ const fileutils_1 = require("../../utils/fileutils");
5
6
  const workspace_root_1 = require("../../utils/workspace-root");
6
- const minimatch = require("minimatch");
7
- function mergeProjectConfigurationIntoRootMap(projectRootMap, project) {
8
- const matchingProject = projectRootMap.get(project.root);
7
+ const target_defaults_plugin_1 = require("../../plugins/target-defaults/target-defaults-plugin");
8
+ const minimatch_1 = require("minimatch");
9
+ const path_1 = require("path");
10
+ const perf_hooks_1 = require("perf_hooks");
11
+ function mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInformation,
12
+ // This function is used when reading project configuration
13
+ // in generators, where we don't want to do this.
14
+ skipCommandNormalization) {
15
+ if (configurationSourceMaps && !configurationSourceMaps[project.root]) {
16
+ configurationSourceMaps[project.root] = {};
17
+ }
18
+ const sourceMap = configurationSourceMaps?.[project.root];
19
+ let matchingProject = projectRootMap.get(project.root);
9
20
  if (!matchingProject) {
10
- projectRootMap.set(project.root, project);
11
- return;
21
+ projectRootMap.set(project.root, {
22
+ root: project.root,
23
+ });
24
+ matchingProject = projectRootMap.get(project.root);
25
+ if (sourceMap) {
26
+ sourceMap[`root`] = sourceInformation;
27
+ }
12
28
  }
13
29
  // This handles top level properties that are overwritten.
14
30
  // e.g. `srcRoot`, `projectType`, or other fields that shouldn't be extended
@@ -17,61 +33,326 @@ function mergeProjectConfigurationIntoRootMap(projectRootMap, project) {
17
33
  // a project.json in which case it was already updated above.
18
34
  const updatedProjectConfiguration = {
19
35
  ...matchingProject,
20
- ...project,
21
36
  };
37
+ for (const k in project) {
38
+ if (![
39
+ 'tags',
40
+ 'implicitDependencies',
41
+ 'generators',
42
+ 'targets',
43
+ 'metadata',
44
+ 'namedInputs',
45
+ ].includes(k)) {
46
+ updatedProjectConfiguration[k] = project[k];
47
+ if (sourceMap) {
48
+ sourceMap[`${k}`] = sourceInformation;
49
+ }
50
+ }
51
+ }
22
52
  // The next blocks handle properties that should be themselves merged (e.g. targets, tags, and implicit dependencies)
23
- if (project.tags && matchingProject.tags) {
24
- updatedProjectConfiguration.tags = matchingProject.tags.concat(project.tags);
53
+ if (project.tags) {
54
+ updatedProjectConfiguration.tags = Array.from(new Set((matchingProject.tags ?? []).concat(project.tags)));
55
+ if (sourceMap) {
56
+ sourceMap['tags'] ??= sourceInformation;
57
+ project.tags.forEach((tag) => {
58
+ sourceMap[`tags.${tag}`] = sourceInformation;
59
+ });
60
+ }
25
61
  }
26
- if (project.implicitDependencies && matchingProject.implicitDependencies) {
27
- updatedProjectConfiguration.implicitDependencies =
28
- matchingProject.implicitDependencies.concat(project.implicitDependencies);
62
+ if (project.implicitDependencies) {
63
+ updatedProjectConfiguration.implicitDependencies = (matchingProject.implicitDependencies ?? []).concat(project.implicitDependencies);
64
+ if (sourceMap) {
65
+ sourceMap['implicitDependencies'] ??= sourceInformation;
66
+ project.implicitDependencies.forEach((implicitDependency) => {
67
+ sourceMap[`implicitDependencies.${implicitDependency}`] =
68
+ sourceInformation;
69
+ });
70
+ }
29
71
  }
30
- if (project.generators && matchingProject.generators) {
31
- updatedProjectConfiguration.generators = {
32
- ...matchingProject.generators,
33
- ...project.generators,
34
- };
72
+ if (project.generators) {
73
+ // Start with generators config in new project.
74
+ updatedProjectConfiguration.generators = { ...project.generators };
75
+ if (sourceMap) {
76
+ sourceMap['generators'] ??= sourceInformation;
77
+ for (const generator in project.generators) {
78
+ sourceMap[`generators.${generator}`] = sourceInformation;
79
+ for (const property in project.generators[generator]) {
80
+ sourceMap[`generators.${generator}.${property}`] = sourceInformation;
81
+ }
82
+ }
83
+ }
84
+ if (matchingProject.generators) {
85
+ // For each generator that was already defined, shallow merge the options.
86
+ // Project contains the new info, so it has higher priority.
87
+ for (const generator in matchingProject.generators) {
88
+ updatedProjectConfiguration.generators[generator] = {
89
+ ...matchingProject.generators[generator],
90
+ ...project.generators[generator],
91
+ };
92
+ }
93
+ }
35
94
  }
36
- if (project.targets && matchingProject.targets) {
37
- updatedProjectConfiguration.targets = {
38
- ...matchingProject.targets,
39
- ...project.targets,
95
+ if (project.namedInputs) {
96
+ updatedProjectConfiguration.namedInputs = {
97
+ ...matchingProject.namedInputs,
98
+ ...project.namedInputs,
40
99
  };
100
+ if (sourceMap) {
101
+ sourceMap['namedInputs'] ??= sourceInformation;
102
+ for (const namedInput in project.namedInputs) {
103
+ sourceMap[`namedInputs.${namedInput}`] = sourceInformation;
104
+ }
105
+ }
106
+ }
107
+ if (project.metadata) {
108
+ updatedProjectConfiguration.metadata = mergeMetadata(sourceMap, sourceInformation, 'metadata', project.metadata, matchingProject.metadata);
109
+ }
110
+ if (project.targets) {
111
+ // We merge the targets with special handling, so clear this back to the
112
+ // targets as defined originally before merging.
113
+ updatedProjectConfiguration.targets = matchingProject?.targets ?? {};
114
+ if (sourceMap) {
115
+ sourceMap['targets'] ??= sourceInformation;
116
+ }
117
+ // For each target defined in the new config
118
+ for (const targetName in project.targets) {
119
+ // Always set source map info for the target, but don't overwrite info already there
120
+ // if augmenting an existing target.
121
+ const target = project.targets?.[targetName];
122
+ if (sourceMap && !target?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET]) {
123
+ sourceMap[`targets.${targetName}`] = sourceInformation;
124
+ }
125
+ // If ONLY_MODIFIES_EXISTING_TARGET is true, and its not on the matching project
126
+ // we shouldn't merge its info into the graph
127
+ if (target?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET] &&
128
+ !matchingProject.targets?.[targetName]) {
129
+ continue;
130
+ }
131
+ const mergedTarget = mergeTargetConfigurations(skipCommandNormalization
132
+ ? target
133
+ : resolveCommandSyntacticSugar(target, project.root), matchingProject.targets?.[targetName], sourceMap, sourceInformation, `targets.${targetName}`);
134
+ // We don't want the symbol to live on past the merge process
135
+ if (mergedTarget?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET])
136
+ delete mergedTarget?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET];
137
+ updatedProjectConfiguration.targets[targetName] = mergedTarget;
138
+ }
41
139
  }
42
140
  projectRootMap.set(updatedProjectConfiguration.root, updatedProjectConfiguration);
43
141
  }
44
142
  exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
45
- function buildProjectsConfigurationsFromProjectPathsAndPlugins(nxJson, projectFiles, // making this parameter allows devkit to pick up newly created projects
46
- plugins, root = workspace_root_1.workspaceRoot) {
47
- const projectRootMap = new Map();
48
- const externalNodes = {};
143
+ function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata, matchingMetadata) {
144
+ const result = {
145
+ ...(matchingMetadata ?? {}),
146
+ };
147
+ for (const [metadataKey, value] of Object.entries(metadata)) {
148
+ const existingValue = matchingMetadata?.[metadataKey];
149
+ if (Array.isArray(value) && Array.isArray(existingValue)) {
150
+ for (const item of [...value]) {
151
+ const newLength = result[metadataKey].push(item);
152
+ if (sourceMap) {
153
+ sourceMap[`${baseSourceMapPath}.${metadataKey}.${newLength - 1}`] =
154
+ sourceInformation;
155
+ }
156
+ }
157
+ }
158
+ else if (Array.isArray(value) && existingValue === undefined) {
159
+ result[metadataKey] ??= value;
160
+ if (sourceMap) {
161
+ sourceMap[`${baseSourceMapPath}.${metadataKey}`] = sourceInformation;
162
+ }
163
+ for (let i = 0; i < value.length; i++) {
164
+ if (sourceMap) {
165
+ sourceMap[`${baseSourceMapPath}.${metadataKey}.${i}`] =
166
+ sourceInformation;
167
+ }
168
+ }
169
+ }
170
+ else if (typeof value === 'object' && typeof existingValue === 'object') {
171
+ for (const key in value) {
172
+ const existingValue = matchingMetadata?.[metadataKey]?.[key];
173
+ if (Array.isArray(value[key]) && Array.isArray(existingValue)) {
174
+ for (const item of value[key]) {
175
+ const i = result[metadataKey][key].push(item);
176
+ if (sourceMap) {
177
+ sourceMap[`${baseSourceMapPath}.${metadataKey}.${key}.${i - 1}`] =
178
+ sourceInformation;
179
+ }
180
+ }
181
+ }
182
+ else {
183
+ result[metadataKey] = value;
184
+ if (sourceMap) {
185
+ sourceMap[`${baseSourceMapPath}.${metadataKey}`] =
186
+ sourceInformation;
187
+ }
188
+ }
189
+ }
190
+ }
191
+ else {
192
+ result[metadataKey] = value;
193
+ if (sourceMap) {
194
+ sourceMap[`${baseSourceMapPath}.${metadataKey}`] = sourceInformation;
195
+ if (typeof value === 'object') {
196
+ for (const k in value) {
197
+ sourceMap[`${baseSourceMapPath}.${metadataKey}.${k}`] =
198
+ sourceInformation;
199
+ if (Array.isArray(value[k])) {
200
+ for (let i = 0; i < value[k].length; i++) {
201
+ sourceMap[`${baseSourceMapPath}.${metadataKey}.${k}.${i}`] =
202
+ sourceInformation;
203
+ }
204
+ }
205
+ }
206
+ }
207
+ }
208
+ }
209
+ }
210
+ return result;
211
+ }
212
+ /**
213
+ * Transforms a list of project paths into a map of project configurations.
214
+ *
215
+ * @param root The workspace root
216
+ * @param nxJson The NxJson configuration
217
+ * @param workspaceFiles A list of non-ignored workspace files
218
+ * @param plugins The plugins that should be used to infer project configuration
219
+ */
220
+ function createProjectConfigurations(root = workspace_root_1.workspaceRoot, nxJson, workspaceFiles, // making this parameter allows devkit to pick up newly created projects
221
+ plugins) {
222
+ perf_hooks_1.performance.mark('build-project-configs:start');
223
+ const results = [];
224
+ const errors = [];
49
225
  // We iterate over plugins first - this ensures that plugins specified first take precedence.
50
- for (const { plugin, options } of plugins) {
226
+ for (const { plugin, options, include, exclude } of plugins) {
51
227
  const [pattern, createNodes] = plugin.createNodes ?? [];
228
+ const pluginResults = [];
229
+ perf_hooks_1.performance.mark(`${plugin.name}:createNodes - start`);
52
230
  if (!pattern) {
53
231
  continue;
54
232
  }
55
- for (const file of projectFiles) {
56
- if (minimatch(file, pattern, { dot: true })) {
57
- const { projects: projectNodes, externalNodes: pluginExternalNodes } = createNodes(file, options, {
233
+ const matchingConfigFiles = [];
234
+ for (const file of workspaceFiles) {
235
+ if ((0, minimatch_1.minimatch)(file, pattern, { dot: true })) {
236
+ if (include) {
237
+ const included = include.some((includedPattern) => (0, minimatch_1.minimatch)(file, includedPattern, { dot: true }));
238
+ if (!included) {
239
+ continue;
240
+ }
241
+ }
242
+ if (exclude) {
243
+ const excluded = include.some((excludedPattern) => (0, minimatch_1.minimatch)(file, excludedPattern, { dot: true }));
244
+ if (excluded) {
245
+ continue;
246
+ }
247
+ }
248
+ matchingConfigFiles.push(file);
249
+ }
250
+ }
251
+ for (const file of matchingConfigFiles) {
252
+ perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - start`);
253
+ try {
254
+ let r = createNodes(file, options, {
58
255
  nxJsonConfiguration: nxJson,
59
256
  workspaceRoot: root,
257
+ configFiles: matchingConfigFiles,
60
258
  });
61
- for (const node in projectNodes) {
62
- projectNodes[node].name ??= node;
63
- mergeProjectConfigurationIntoRootMap(projectRootMap, projectNodes[node]);
259
+ if (r instanceof Promise) {
260
+ pluginResults.push(r
261
+ .catch((error) => {
262
+ perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
263
+ errors.push(new CreateNodesError({
264
+ file,
265
+ pluginName: plugin.name,
266
+ error,
267
+ }));
268
+ return {
269
+ projects: {},
270
+ };
271
+ })
272
+ .then((r) => {
273
+ perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
274
+ perf_hooks_1.performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
275
+ return { ...r, file, pluginName: plugin.name };
276
+ }));
277
+ }
278
+ else {
279
+ perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
280
+ perf_hooks_1.performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
281
+ pluginResults.push({
282
+ ...r,
283
+ file,
284
+ pluginName: plugin.name,
285
+ });
64
286
  }
65
- Object.assign(externalNodes, pluginExternalNodes);
287
+ }
288
+ catch (error) {
289
+ errors.push(new CreateNodesError({
290
+ file,
291
+ pluginName: plugin.name,
292
+ error,
293
+ }));
66
294
  }
67
295
  }
296
+ results.push(Promise.all(pluginResults).then((results) => {
297
+ perf_hooks_1.performance.mark(`${plugin.name}:createNodes - end`);
298
+ perf_hooks_1.performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
299
+ return results;
300
+ }));
68
301
  }
69
- return {
70
- projects: readProjectConfigurationsFromRootMap(projectRootMap),
71
- externalNodes,
72
- };
302
+ return Promise.all(results).then((results) => {
303
+ perf_hooks_1.performance.mark('createNodes:merge - start');
304
+ const projectRootMap = new Map();
305
+ const externalNodes = {};
306
+ const configurationSourceMaps = {};
307
+ for (const result of results.flat()) {
308
+ const { projects: projectNodes, externalNodes: pluginExternalNodes, file, pluginName, } = result;
309
+ const sourceInfo = [file, pluginName];
310
+ if (result[target_defaults_plugin_1.OVERRIDE_SOURCE_FILE]) {
311
+ sourceInfo[0] = result[target_defaults_plugin_1.OVERRIDE_SOURCE_FILE];
312
+ }
313
+ for (const node in projectNodes) {
314
+ const project = {
315
+ root: node,
316
+ ...projectNodes[node],
317
+ };
318
+ try {
319
+ mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInfo);
320
+ }
321
+ catch (error) {
322
+ errors.push(new MergeNodesError({
323
+ file,
324
+ pluginName,
325
+ error,
326
+ }));
327
+ }
328
+ }
329
+ Object.assign(externalNodes, pluginExternalNodes);
330
+ }
331
+ const projects = readProjectConfigurationsFromRootMap(projectRootMap);
332
+ const rootMap = createRootMap(projectRootMap);
333
+ perf_hooks_1.performance.mark('createNodes:merge - end');
334
+ perf_hooks_1.performance.measure('createNodes:merge', 'createNodes:merge - start', 'createNodes:merge - end');
335
+ perf_hooks_1.performance.mark('build-project-configs:end');
336
+ perf_hooks_1.performance.measure('build-project-configs', 'build-project-configs:start', 'build-project-configs:end');
337
+ if (errors.length === 0) {
338
+ return {
339
+ projects,
340
+ externalNodes,
341
+ projectRootMap: rootMap,
342
+ sourceMaps: configurationSourceMaps,
343
+ };
344
+ }
345
+ else {
346
+ throw new ProjectConfigurationsError(errors, {
347
+ projects,
348
+ externalNodes,
349
+ projectRootMap: rootMap,
350
+ sourceMaps: configurationSourceMaps,
351
+ });
352
+ }
353
+ });
73
354
  }
74
- exports.buildProjectsConfigurationsFromProjectPathsAndPlugins = buildProjectsConfigurationsFromProjectPathsAndPlugins;
355
+ exports.createProjectConfigurations = createProjectConfigurations;
75
356
  function readProjectConfigurationsFromRootMap(projectRootMap) {
76
357
  const projects = {};
77
358
  // If there are projects that have the same name, that is an error.
@@ -79,10 +360,20 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
79
360
  // to provide better error messaging.
80
361
  const errors = new Map();
81
362
  for (const [root, configuration] of projectRootMap.entries()) {
363
+ // We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
364
+ // Strip it before returning configuration for usage.
365
+ if (configuration['// targets'])
366
+ delete configuration['// targets'];
82
367
  if (!configuration.name) {
83
- throw new Error(`Project at ${root} has no name provided.`);
368
+ try {
369
+ const { name } = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
370
+ configuration.name = name;
371
+ }
372
+ catch {
373
+ throw new Error(`Project at ${root} has no name provided.`);
374
+ }
84
375
  }
85
- else if (configuration.name in projects) {
376
+ if (configuration.name in projects) {
86
377
  let rootErrors = errors.get(configuration.name) ?? [
87
378
  projects[configuration.name].root,
88
379
  ];
@@ -104,40 +395,170 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
104
395
  return projects;
105
396
  }
106
397
  exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
107
- function mergeTargetConfigurations(projectConfiguration, target, targetDefaults) {
108
- const targetConfiguration = projectConfiguration.targets?.[target];
109
- if (!targetConfiguration) {
110
- throw new Error(`Attempted to merge targetDefaults for ${projectConfiguration.name}.${target}, which doesn't exist.`);
398
+ class ProjectConfigurationsError extends Error {
399
+ constructor(errors, partialProjectConfigurationsResult) {
400
+ super('Failed to create project configurations');
401
+ this.errors = errors;
402
+ this.partialProjectConfigurationsResult = partialProjectConfigurationsResult;
403
+ this.name = this.constructor.name;
111
404
  }
112
- const { configurations: defaultConfigurations, options: defaultOptions, ...defaults } = targetDefaults;
405
+ }
406
+ exports.ProjectConfigurationsError = ProjectConfigurationsError;
407
+ class CreateNodesError extends Error {
408
+ constructor({ file, pluginName, error, }) {
409
+ const msg = `The "${pluginName}" plugin threw an error while creating nodes from ${file}:`;
410
+ super(msg, { cause: error });
411
+ this.name = this.constructor.name;
412
+ this.file = file;
413
+ this.pluginName = pluginName;
414
+ this.stack = `${this.message}\n ${error.stack.split('\n').join('\n ')}`;
415
+ }
416
+ }
417
+ exports.CreateNodesError = CreateNodesError;
418
+ class MergeNodesError extends Error {
419
+ constructor({ file, pluginName, error, }) {
420
+ const msg = `The nodes created from ${file} by the "${pluginName}" could not be merged into the project graph:`;
421
+ super(msg, { cause: error });
422
+ this.name = this.constructor.name;
423
+ this.file = file;
424
+ this.pluginName = pluginName;
425
+ this.stack = `${this.message}\n ${error.stack.split('\n').join('\n ')}`;
426
+ }
427
+ }
428
+ exports.MergeNodesError = MergeNodesError;
429
+ /**
430
+ * Merges two targets.
431
+ *
432
+ * Most properties from `target` will overwrite any properties from `baseTarget`.
433
+ * Options and configurations are treated differently - they are merged together if the executor definition is compatible.
434
+ *
435
+ * @param target The target definition with higher priority
436
+ * @param baseTarget The target definition that should be overwritten. Can be undefined, in which case the target is returned as-is.
437
+ * @param projectConfigSourceMap The source map to be filled with metadata about where each property came from
438
+ * @param sourceInformation The metadata about where the new target was defined
439
+ * @param targetIdentifier The identifier for the target to merge, used for source map
440
+ * @returns A merged target configuration
441
+ */
442
+ function mergeTargetConfigurations(target, baseTarget, projectConfigSourceMap, sourceInformation, targetIdentifier) {
443
+ const { configurations: defaultConfigurations, options: defaultOptions, ...baseTargetProperties } = baseTarget ?? {};
444
+ // Target is "compatible", e.g. executor is defined only once or is the same
445
+ // in both places. This means that it is likely safe to merge
446
+ const isCompatible = isCompatibleTarget(baseTargetProperties, target);
447
+ // If the targets are not compatible, we would normally overwrite the old target
448
+ // with the new one. However, we have a special case for targets that have the
449
+ // ONLY_MODIFIES_EXISTING_TARGET symbol set. This prevents the merged target
450
+ // equaling info that should have only been used to modify the existing target.
451
+ if (!isCompatible && target[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET]) {
452
+ return baseTarget;
453
+ }
454
+ if (!isCompatible && projectConfigSourceMap) {
455
+ // if the target is not compatible, we will simply override the options
456
+ // we have to delete old entries from the source map
457
+ for (const key in projectConfigSourceMap) {
458
+ if (key.startsWith(`${targetIdentifier}`)) {
459
+ delete projectConfigSourceMap[key];
460
+ }
461
+ }
462
+ }
463
+ // merge top level properties if they're compatible
113
464
  const result = {
114
- ...defaults,
115
- ...targetConfiguration,
465
+ ...(isCompatible ? baseTargetProperties : {}),
466
+ ...target,
116
467
  };
117
- // Target is "compatible", e.g. executor is defined only once or is the same
118
- // in both places. This means that it is likely safe to merge options
119
- if (!targetDefaults.executor ||
120
- !targetConfiguration.executor ||
121
- targetDefaults.executor === targetConfiguration.executor) {
122
- result.options = { ...defaultOptions, ...targetConfiguration?.options };
123
- result.configurations = mergeConfigurations(defaultConfigurations, targetConfiguration.configurations);
468
+ // record top level properties in source map
469
+ if (projectConfigSourceMap) {
470
+ projectConfigSourceMap[targetIdentifier] = sourceInformation;
471
+ // record root level target properties to source map
472
+ for (const targetProperty in target) {
473
+ const targetPropertyId = `${targetIdentifier}.${targetProperty}`;
474
+ projectConfigSourceMap[targetPropertyId] = sourceInformation;
475
+ }
476
+ }
477
+ // merge options if there are any
478
+ // if the targets aren't compatible, we simply discard the old options during the merge
479
+ if (target.options || defaultOptions) {
480
+ result.options = mergeOptions(target.options, isCompatible ? defaultOptions : undefined, projectConfigSourceMap, sourceInformation, targetIdentifier);
481
+ }
482
+ // merge configurations if there are any
483
+ // if the targets aren't compatible, we simply discard the old configurations during the merge
484
+ if (target.configurations || defaultConfigurations) {
485
+ result.configurations = mergeConfigurations(target.configurations, isCompatible ? defaultConfigurations : undefined, projectConfigSourceMap, sourceInformation, targetIdentifier);
486
+ }
487
+ if (target.metadata) {
488
+ result.metadata = mergeMetadata(projectConfigSourceMap, sourceInformation, `${targetIdentifier}.metadata`, target.metadata, baseTarget?.metadata);
124
489
  }
125
490
  return result;
126
491
  }
127
492
  exports.mergeTargetConfigurations = mergeTargetConfigurations;
128
- function mergeConfigurations(defaultConfigurations, projectDefinedConfigurations) {
129
- const result = {};
493
+ /**
494
+ * Checks if targets options are compatible - used when merging configurations
495
+ * to avoid merging options for @nx/js:tsc into something like @nx/webpack:webpack.
496
+ *
497
+ * If the executors are both specified and don't match, the options aren't considered
498
+ * "compatible" and shouldn't be merged.
499
+ */
500
+ function isCompatibleTarget(a, b) {
501
+ const oneHasNoExecutor = !a.executor || !b.executor;
502
+ const bothHaveSameExecutor = a.executor === b.executor;
503
+ if (oneHasNoExecutor)
504
+ return true;
505
+ if (!bothHaveSameExecutor)
506
+ return false;
507
+ const isRunCommands = a.executor === 'nx:run-commands';
508
+ if (isRunCommands) {
509
+ const aCommand = a.options?.command ?? a.options?.commands.join(' && ');
510
+ const bCommand = b.options?.command ?? b.options?.commands.join(' && ');
511
+ const oneHasNoCommand = !aCommand || !bCommand;
512
+ const hasSameCommand = aCommand === bCommand;
513
+ return oneHasNoCommand || hasSameCommand;
514
+ }
515
+ const isRunScript = a.executor === 'nx:run-script';
516
+ if (isRunScript) {
517
+ const aScript = a.options?.script;
518
+ const bScript = b.options?.script;
519
+ const oneHasNoScript = !aScript || !bScript;
520
+ const hasSameScript = aScript === bScript;
521
+ return oneHasNoScript || hasSameScript;
522
+ }
523
+ return true;
524
+ }
525
+ exports.isCompatibleTarget = isCompatibleTarget;
526
+ function mergeConfigurations(newConfigurations, baseConfigurations, projectConfigSourceMap, sourceInformation, targetIdentifier) {
527
+ const mergedConfigurations = {};
130
528
  const configurations = new Set([
131
- ...Object.keys(defaultConfigurations ?? {}),
132
- ...Object.keys(projectDefinedConfigurations ?? {}),
529
+ ...Object.keys(baseConfigurations ?? {}),
530
+ ...Object.keys(newConfigurations ?? {}),
133
531
  ]);
134
532
  for (const configuration of configurations) {
135
- result[configuration] = {
136
- ...(defaultConfigurations?.[configuration] ?? {}),
137
- ...(projectDefinedConfigurations?.[configuration] ?? {}),
533
+ mergedConfigurations[configuration] = {
534
+ ...(baseConfigurations?.[configuration] ?? {}),
535
+ ...(newConfigurations?.[configuration] ?? {}),
138
536
  };
139
537
  }
140
- return result;
538
+ // record new configurations & configuration properties in source map
539
+ if (projectConfigSourceMap) {
540
+ for (const newConfiguration in newConfigurations) {
541
+ projectConfigSourceMap[`${targetIdentifier}.configurations.${newConfiguration}`] = sourceInformation;
542
+ for (const configurationProperty in newConfigurations[newConfiguration]) {
543
+ projectConfigSourceMap[`${targetIdentifier}.configurations.${newConfiguration}.${configurationProperty}`] = sourceInformation;
544
+ }
545
+ }
546
+ }
547
+ return mergedConfigurations;
548
+ }
549
+ function mergeOptions(newOptions, baseOptions, projectConfigSourceMap, sourceInformation, targetIdentifier) {
550
+ const mergedOptions = {
551
+ ...(baseOptions ?? {}),
552
+ ...(newOptions ?? {}),
553
+ };
554
+ // record new options & option properties in source map
555
+ if (projectConfigSourceMap) {
556
+ for (const newOption in newOptions) {
557
+ projectConfigSourceMap[`${targetIdentifier}.options.${newOption}`] =
558
+ sourceInformation;
559
+ }
560
+ }
561
+ return mergedOptions;
141
562
  }
142
563
  function resolveNxTokensInOptions(object, project, key) {
143
564
  const result = Array.isArray(object) ? [...object] : { ...object };
@@ -176,3 +597,29 @@ function readTargetDefaultsForTarget(targetName, targetDefaults, executor) {
176
597
  }
177
598
  }
178
599
  exports.readTargetDefaultsForTarget = readTargetDefaultsForTarget;
600
+ function createRootMap(projectRootMap) {
601
+ const map = {};
602
+ for (const [projectRoot, { name: projectName }] of projectRootMap) {
603
+ map[projectRoot] = projectName;
604
+ }
605
+ return map;
606
+ }
607
+ function resolveCommandSyntacticSugar(target, key) {
608
+ const { command, ...config } = target ?? {};
609
+ if (!command) {
610
+ return target;
611
+ }
612
+ if (config.executor) {
613
+ throw new Error(`${logger_1.NX_PREFIX} Project at ${key} should not have executor and command both configured.`);
614
+ }
615
+ else {
616
+ return {
617
+ ...config,
618
+ executor: 'nx:run-commands',
619
+ options: {
620
+ ...config.options,
621
+ command: command,
622
+ },
623
+ };
624
+ }
625
+ }