nx 17.0.2 → 17.0.4

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