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,47 +1,144 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleNxReleaseConfigError = exports.createNxReleaseConfig = exports.CATCH_ALL_RELEASE_GROUP = void 0;
4
- const devkit_exports_1 = require("../../../devkit-exports");
3
+ exports.handleNxReleaseConfigError = exports.createNxReleaseConfig = exports.IMPLICIT_DEFAULT_RELEASE_GROUP = void 0;
4
+ /**
5
+ * `nx release` is a powerful feature which spans many possible use cases. The possible variations
6
+ * of configuration are therefore quite complex, particularly when you consider release groups.
7
+ *
8
+ * We want to provide the best possible DX for users so that they can harness the power of `nx release`
9
+ * most effectively, therefore we need to both provide sensible defaults for common scenarios (to avoid
10
+ * verbose nx.json files wherever possible), and proactively handle potential sources of config issues
11
+ * in more complex use-cases.
12
+ *
13
+ * This file is the source of truth for all `nx release` configuration reconciliation, including sensible
14
+ * defaults and user overrides, as well as handling common errors, up front to produce a single, consistent,
15
+ * and easy to consume config object for all the `nx release` command implementations.
16
+ */
17
+ const path_1 = require("path");
18
+ const fileutils_1 = require("../../../utils/fileutils");
5
19
  const find_matching_projects_1 = require("../../../utils/find-matching-projects");
6
- const project_graph_utils_1 = require("../../../utils/project-graph-utils");
20
+ const output_1 = require("../../../utils/output");
21
+ const workspace_root_1 = require("../../../utils/workspace-root");
7
22
  const resolve_nx_json_error_message_1 = require("../utils/resolve-nx-json-error-message");
8
- exports.CATCH_ALL_RELEASE_GROUP = '__default__';
23
+ const conventional_commits_1 = require("./conventional-commits");
24
+ exports.IMPLICIT_DEFAULT_RELEASE_GROUP = '__default__';
9
25
  // Apply default configuration to any optional user configuration and handle known errors
10
- async function createNxReleaseConfig(projectGraph, userConfig = {},
11
- // Optionally ensure that all configured projects have implemented a certain target
12
- requiredTargetName) {
26
+ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig = {}) {
27
+ if (userConfig.projects && userConfig.groups) {
28
+ return {
29
+ error: {
30
+ code: 'PROJECTS_AND_GROUPS_DEFINED',
31
+ data: {},
32
+ },
33
+ nxReleaseConfig: null,
34
+ };
35
+ }
36
+ if (hasInvalidGitConfig(userConfig)) {
37
+ return {
38
+ error: {
39
+ code: 'GLOBAL_GIT_CONFIG_MIXED_WITH_GRANULAR_GIT_CONFIG',
40
+ data: {},
41
+ },
42
+ nxReleaseConfig: null,
43
+ };
44
+ }
45
+ if (hasInvalidConventionalCommitsConfig(userConfig)) {
46
+ return {
47
+ error: {
48
+ code: 'CONVENTIONAL_COMMITS_SHORTHAND_MIXED_WITH_OVERLAPPING_GENERATOR_OPTIONS',
49
+ data: {},
50
+ },
51
+ nxReleaseConfig: null,
52
+ };
53
+ }
54
+ const gitDefaults = {
55
+ commit: false,
56
+ commitMessage: 'chore(release): publish {version}',
57
+ commitArgs: '',
58
+ tag: false,
59
+ tagMessage: '',
60
+ tagArgs: '',
61
+ stageChanges: false,
62
+ };
63
+ const versionGitDefaults = {
64
+ ...gitDefaults,
65
+ stageChanges: true,
66
+ };
67
+ const changelogGitDefaults = {
68
+ ...gitDefaults,
69
+ commit: true,
70
+ tag: true,
71
+ };
72
+ const defaultFixedReleaseTagPattern = 'v{version}';
73
+ const defaultIndependentReleaseTagPattern = '{projectName}@{version}';
74
+ const workspaceProjectsRelationship = userConfig.projectsRelationship || 'fixed';
75
+ const defaultGeneratorOptions = userConfig.version?.conventionalCommits
76
+ ? {
77
+ currentVersionResolver: 'git-tag',
78
+ specifierSource: 'conventional-commits',
79
+ }
80
+ : {};
81
+ const userGroups = Object.values(userConfig.groups ?? {});
82
+ const disableWorkspaceChangelog = userGroups.length > 1 ||
83
+ (userGroups.length === 1 &&
84
+ userGroups[0].projectsRelationship === 'independent') ||
85
+ (userConfig.projectsRelationship === 'independent' &&
86
+ !userGroups.some((g) => g.projectsRelationship === 'fixed'));
87
+ const defaultRendererPath = (0, path_1.join)(__dirname, '../../../../release/changelog-renderer');
13
88
  const WORKSPACE_DEFAULTS = {
89
+ // By default all projects in all groups are released together
90
+ projectsRelationship: workspaceProjectsRelationship,
91
+ git: gitDefaults,
14
92
  version: {
93
+ git: versionGitDefaults,
94
+ conventionalCommits: userConfig.version?.conventionalCommits || false,
15
95
  generator: '@nx/js:release-version',
16
- generatorOptions: {},
96
+ generatorOptions: defaultGeneratorOptions,
97
+ preVersionCommand: userConfig.version?.preVersionCommand || '',
17
98
  },
18
99
  changelog: {
19
- workspaceChangelog: {
20
- createRelease: false,
21
- entryWhenNoChanges: 'This was a version bump only, there were no code changes.',
22
- file: '{workspaceRoot}/CHANGELOG.md',
23
- renderer: 'nx/changelog-renderer',
24
- renderOptions: {
25
- includeAuthors: true,
100
+ git: changelogGitDefaults,
101
+ workspaceChangelog: disableWorkspaceChangelog
102
+ ? false
103
+ : {
104
+ createRelease: false,
105
+ entryWhenNoChanges: 'This was a version bump only, there were no code changes.',
106
+ file: '{workspaceRoot}/CHANGELOG.md',
107
+ renderer: defaultRendererPath,
108
+ renderOptions: {
109
+ authors: true,
110
+ commitReferences: true,
111
+ versionTitleDate: true,
112
+ },
26
113
  },
27
- },
28
114
  // For projectChangelogs if the user has set any changelog config at all, then use one set of defaults, otherwise default to false for the whole feature
29
115
  projectChangelogs: userConfig.changelog?.projectChangelogs
30
116
  ? {
31
117
  createRelease: false,
32
118
  file: '{projectRoot}/CHANGELOG.md',
33
119
  entryWhenNoChanges: 'This was a version bump only for {projectName} to align it with other projects, there were no code changes.',
34
- renderer: 'nx/changelog-renderer',
120
+ renderer: defaultRendererPath,
35
121
  renderOptions: {
36
- includeAuthors: true,
122
+ authors: true,
123
+ commitReferences: true,
124
+ versionTitleDate: true,
37
125
  },
38
126
  }
39
127
  : false,
128
+ automaticFromRef: false,
40
129
  },
41
- releaseTagPattern: 'v{version}',
130
+ releaseTagPattern: userConfig.releaseTagPattern ||
131
+ // The appropriate default releaseTagPattern is dependent upon the projectRelationships
132
+ (workspaceProjectsRelationship === 'independent'
133
+ ? defaultIndependentReleaseTagPattern
134
+ : defaultFixedReleaseTagPattern),
135
+ conventionalCommits: conventional_commits_1.DEFAULT_CONVENTIONAL_COMMITS_CONFIG,
42
136
  };
137
+ const groupProjectsRelationship = userConfig.projectsRelationship || WORKSPACE_DEFAULTS.projectsRelationship;
43
138
  const GROUP_DEFAULTS = {
139
+ projectsRelationship: groupProjectsRelationship,
44
140
  version: {
141
+ conventionalCommits: false,
45
142
  generator: '@nx/js:release-version',
46
143
  generatorOptions: {},
47
144
  },
@@ -49,36 +146,85 @@ requiredTargetName) {
49
146
  createRelease: false,
50
147
  entryWhenNoChanges: 'This was a version bump only for {projectName} to align it with other projects, there were no code changes.',
51
148
  file: '{projectRoot}/CHANGELOG.md',
52
- renderer: 'nx/changelog-renderer',
149
+ renderer: defaultRendererPath,
53
150
  renderOptions: {
54
- includeAuthors: true,
151
+ authors: true,
152
+ commitReferences: true,
153
+ versionTitleDate: true,
55
154
  },
56
155
  },
57
- releaseTagPattern: '{projectName}@v{version}',
156
+ releaseTagPattern:
157
+ // The appropriate group default releaseTagPattern is dependent upon the projectRelationships
158
+ groupProjectsRelationship === 'independent'
159
+ ? defaultIndependentReleaseTagPattern
160
+ : WORKSPACE_DEFAULTS.releaseTagPattern,
58
161
  };
59
162
  /**
60
163
  * We first process root level config and apply defaults, so that we know how to handle the group level
61
164
  * overrides, if applicable.
62
165
  */
63
- const rootVersionConfig = deepMergeDefaults([WORKSPACE_DEFAULTS.version], userConfig.version);
64
- const rootChangelogConfig = deepMergeDefaults([WORKSPACE_DEFAULTS.changelog], userConfig.changelog);
65
- const allProjects = (0, find_matching_projects_1.findMatchingProjects)(['*'], projectGraph.nodes);
166
+ const rootGitConfig = deepMergeDefaults([WORKSPACE_DEFAULTS.git], userConfig.git);
167
+ const rootVersionConfig = deepMergeDefaults([
168
+ WORKSPACE_DEFAULTS.version,
169
+ // Merge in the git defaults from the top level
170
+ { git: versionGitDefaults },
171
+ {
172
+ git: userConfig.git,
173
+ },
174
+ ], userConfig.version);
175
+ if (userConfig.changelog?.workspaceChangelog) {
176
+ userConfig.changelog.workspaceChangelog = normalizeTrueToEmptyObject(userConfig.changelog.workspaceChangelog);
177
+ }
178
+ if (userConfig.changelog?.projectChangelogs) {
179
+ userConfig.changelog.projectChangelogs = normalizeTrueToEmptyObject(userConfig.changelog.projectChangelogs);
180
+ }
181
+ const rootChangelogConfig = deepMergeDefaults([
182
+ WORKSPACE_DEFAULTS.changelog,
183
+ // Merge in the git defaults from the top level
184
+ { git: changelogGitDefaults },
185
+ {
186
+ git: userConfig.git,
187
+ },
188
+ ], normalizeTrueToEmptyObject(userConfig.changelog));
189
+ const rootConventionalCommitsConfig = deepMergeDefaults([WORKSPACE_DEFAULTS.conventionalCommits], fillUnspecifiedConventionalCommitsProperties(normalizeConventionalCommitsConfig(userConfig.conventionalCommits)));
190
+ // these options are not supported at the group level, only the root/command level
191
+ const rootVersionWithoutGlobalOptions = { ...rootVersionConfig };
192
+ delete rootVersionWithoutGlobalOptions.git;
193
+ delete rootVersionWithoutGlobalOptions.preVersionCommand;
194
+ // Apply conventionalCommits shorthand to the final group defaults if explicitly configured in the original user config
195
+ if (userConfig.version?.conventionalCommits === true) {
196
+ rootVersionWithoutGlobalOptions.generatorOptions = {
197
+ ...rootVersionWithoutGlobalOptions.generatorOptions,
198
+ currentVersionResolver: 'git-tag',
199
+ specifierSource: 'conventional-commits',
200
+ };
201
+ }
202
+ if (userConfig.version?.conventionalCommits === false) {
203
+ delete rootVersionWithoutGlobalOptions.generatorOptions
204
+ .currentVersionResolver;
205
+ delete rootVersionWithoutGlobalOptions.generatorOptions.specifierSource;
206
+ }
66
207
  const groups = userConfig.groups && Object.keys(userConfig.groups).length
67
208
  ? ensureProjectsConfigIsArray(userConfig.groups)
68
209
  : /**
69
- * No user specified release groups, so we treat all projects as being in one release group
70
- * together in which all projects are released in lock step.
210
+ * No user specified release groups, so we treat all projects (or any any user-defined subset via the top level "projects" property)
211
+ * as being in one release group together in which the projects are released in lock step.
71
212
  */
72
213
  {
73
- [exports.CATCH_ALL_RELEASE_GROUP]: {
74
- projects: allProjects,
214
+ [exports.IMPLICIT_DEFAULT_RELEASE_GROUP]: {
215
+ projectsRelationship: GROUP_DEFAULTS.projectsRelationship,
216
+ projects: userConfig.projects
217
+ ? // user-defined top level "projects" config takes priority if set
218
+ (0, find_matching_projects_1.findMatchingProjects)(ensureArray(userConfig.projects), projectGraph.nodes)
219
+ : await getDefaultProjects(projectGraph, projectFileMap),
75
220
  /**
76
221
  * For properties which are overriding config at the root, we use the root level config as the
77
222
  * default values to merge with so that the group that matches a specific project will always
78
223
  * be the valid source of truth for that type of config.
79
224
  */
80
- version: deepMergeDefaults([GROUP_DEFAULTS.version], rootVersionConfig),
81
- releaseTagPattern: GROUP_DEFAULTS.releaseTagPattern,
225
+ version: deepMergeDefaults([GROUP_DEFAULTS.version], rootVersionWithoutGlobalOptions),
226
+ // If the user has set something custom for releaseTagPattern at the top level, respect it for the implicit default group
227
+ releaseTagPattern: userConfig.releaseTagPattern || GROUP_DEFAULTS.releaseTagPattern,
82
228
  // Directly inherit the root level config for projectChangelogs, if set
83
229
  changelog: rootChangelogConfig.projectChangelogs || false,
84
230
  },
@@ -103,9 +249,9 @@ requiredTargetName) {
103
249
  nxReleaseConfig: null,
104
250
  };
105
251
  }
106
- // Ensure all matching projects have the relevant target available, if applicable
107
- if (requiredTargetName) {
108
- const error = ensureProjectsHaveTarget(matchingProjects, projectGraph, requiredTargetName);
252
+ // If provided, ensure release tag pattern is valid
253
+ if (releaseGroup.releaseTagPattern) {
254
+ const error = ensureReleaseGroupReleaseTagPatternIsValid(releaseGroup.releaseTagPattern, releaseGroupName);
109
255
  if (error) {
110
256
  return {
111
257
  error,
@@ -132,43 +278,170 @@ requiredTargetName) {
132
278
  if (rootChangelogConfig.projectChangelogs) {
133
279
  groupChangelogDefaults.push(rootChangelogConfig.projectChangelogs);
134
280
  }
281
+ const projectsRelationship = releaseGroup.projectsRelationship || GROUP_DEFAULTS.projectsRelationship;
282
+ if (releaseGroup.changelog) {
283
+ releaseGroup.changelog = normalizeTrueToEmptyObject(releaseGroup.changelog);
284
+ }
135
285
  const groupDefaults = {
286
+ projectsRelationship,
136
287
  projects: matchingProjects,
137
288
  version: deepMergeDefaults(
138
289
  // First apply any group level defaults, then apply actual root level config, then group level config
139
- [GROUP_DEFAULTS.version, rootVersionConfig], releaseGroup.version),
290
+ [GROUP_DEFAULTS.version, rootVersionWithoutGlobalOptions], releaseGroup.version),
140
291
  // If the user has set any changelog config at all, including at the root level, then use one set of defaults, otherwise default to false for the whole feature
141
292
  changelog: releaseGroup.changelog || rootChangelogConfig.projectChangelogs
142
293
  ? deepMergeDefaults(groupChangelogDefaults, releaseGroup.changelog || {})
143
294
  : false,
144
- releaseTagPattern: GROUP_DEFAULTS.releaseTagPattern,
295
+ releaseTagPattern: releaseGroup.releaseTagPattern ||
296
+ // The appropriate group default releaseTagPattern is dependent upon the projectRelationships
297
+ (projectsRelationship === 'independent'
298
+ ? defaultIndependentReleaseTagPattern
299
+ : userConfig.releaseTagPattern || defaultFixedReleaseTagPattern),
145
300
  };
146
- releaseGroups[releaseGroupName] = deepMergeDefaults([groupDefaults], {
301
+ const finalReleaseGroup = deepMergeDefaults([groupDefaults], {
147
302
  ...releaseGroup,
148
303
  // Ensure that the resolved project names take priority over the original user config (which could have contained unresolved globs etc)
149
304
  projects: matchingProjects,
150
305
  });
306
+ // Apply conventionalCommits shorthand to the final group if explicitly configured in the original group
307
+ if (releaseGroup.version?.conventionalCommits === true) {
308
+ finalReleaseGroup.version.generatorOptions = {
309
+ ...finalReleaseGroup.version.generatorOptions,
310
+ currentVersionResolver: 'git-tag',
311
+ specifierSource: 'conventional-commits',
312
+ };
313
+ }
314
+ if (releaseGroup.version?.conventionalCommits === false &&
315
+ releaseGroupName !== exports.IMPLICIT_DEFAULT_RELEASE_GROUP) {
316
+ delete finalReleaseGroup.version.generatorOptions.currentVersionResolver;
317
+ delete finalReleaseGroup.version.generatorOptions.specifierSource;
318
+ }
319
+ releaseGroups[releaseGroupName] = finalReleaseGroup;
151
320
  }
152
321
  return {
153
322
  error: null,
154
323
  nxReleaseConfig: {
324
+ projectsRelationship: WORKSPACE_DEFAULTS.projectsRelationship,
325
+ releaseTagPattern: WORKSPACE_DEFAULTS.releaseTagPattern,
326
+ git: rootGitConfig,
155
327
  version: rootVersionConfig,
156
328
  changelog: rootChangelogConfig,
157
329
  groups: releaseGroups,
158
- releaseTagPattern: userConfig.releaseTagPattern || WORKSPACE_DEFAULTS.releaseTagPattern,
330
+ conventionalCommits: rootConventionalCommitsConfig,
159
331
  },
160
332
  };
161
333
  }
162
334
  exports.createNxReleaseConfig = createNxReleaseConfig;
335
+ /**
336
+ * In some cases it is much cleaner and more intuitive for the user to be able to
337
+ * specify `true` in their config when they want to use the default config for a
338
+ * particular property, rather than having to specify an empty object.
339
+ */
340
+ function normalizeTrueToEmptyObject(value) {
341
+ return value === true ? {} : value;
342
+ }
343
+ function normalizeConventionalCommitsConfig(userConventionalCommitsConfig) {
344
+ if (!userConventionalCommitsConfig || !userConventionalCommitsConfig.types) {
345
+ return userConventionalCommitsConfig;
346
+ }
347
+ const types = {};
348
+ for (const [t, typeConfig] of Object.entries(userConventionalCommitsConfig.types)) {
349
+ if (typeConfig === false) {
350
+ types[t] = {
351
+ semverBump: 'none',
352
+ changelog: {
353
+ hidden: true,
354
+ },
355
+ };
356
+ continue;
357
+ }
358
+ if (typeConfig === true) {
359
+ types[t] = {};
360
+ continue;
361
+ }
362
+ if (typeConfig.changelog === false) {
363
+ types[t] = {
364
+ ...typeConfig,
365
+ changelog: {
366
+ hidden: true,
367
+ },
368
+ };
369
+ continue;
370
+ }
371
+ if (typeConfig.changelog === true) {
372
+ types[t] = {
373
+ ...typeConfig,
374
+ changelog: {},
375
+ };
376
+ continue;
377
+ }
378
+ types[t] = typeConfig;
379
+ }
380
+ return {
381
+ ...userConventionalCommitsConfig,
382
+ types,
383
+ };
384
+ }
385
+ /**
386
+ * New, custom types specified by users will not be given the appropriate
387
+ * defaults with `deepMergeDefaults`, so we need to fill in the gaps here.
388
+ */
389
+ function fillUnspecifiedConventionalCommitsProperties(config) {
390
+ if (!config || !config.types) {
391
+ return config;
392
+ }
393
+ const types = {};
394
+ for (const [t, typeConfig] of Object.entries(config.types)) {
395
+ const defaultTypeConfig = conventional_commits_1.DEFAULT_CONVENTIONAL_COMMITS_CONFIG.types[t];
396
+ const semverBump = typeConfig.semverBump ||
397
+ // preserve our default semver bump if it's not 'none'
398
+ // this prevents a 'feat' from becoming a 'patch' just
399
+ // because they modified the changelog config for 'feat'
400
+ (defaultTypeConfig?.semverBump !== 'none' &&
401
+ defaultTypeConfig?.semverBump) ||
402
+ 'patch';
403
+ // don't preserve our default behavior for hidden, ever.
404
+ // we should assume that if users are explicitly enabling a
405
+ // type, then they intend it to be visible in the changelog
406
+ const hidden = typeConfig.changelog?.hidden || false;
407
+ const title = typeConfig.changelog?.title ||
408
+ // our default title is better than just the unmodified type name
409
+ defaultTypeConfig?.changelog.title ||
410
+ t;
411
+ types[t] = {
412
+ semverBump,
413
+ changelog: {
414
+ hidden,
415
+ title,
416
+ },
417
+ };
418
+ }
419
+ return {
420
+ ...config,
421
+ types,
422
+ };
423
+ }
163
424
  async function handleNxReleaseConfigError(error) {
164
425
  switch (error.code) {
426
+ case 'PROJECTS_AND_GROUPS_DEFINED':
427
+ {
428
+ const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)([
429
+ 'release',
430
+ 'projects',
431
+ ]);
432
+ output_1.output.error({
433
+ title: `"projects" is not valid when explicitly defining release groups, and everything should be expressed within "groups" in that case. If you are using "groups" then you should remove the "projects" property`,
434
+ bodyLines: [nxJsonMessage],
435
+ });
436
+ }
437
+ break;
165
438
  case 'RELEASE_GROUP_MATCHES_NO_PROJECTS':
166
439
  {
167
440
  const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)([
168
441
  'release',
169
442
  'groups',
170
443
  ]);
171
- devkit_exports_1.output.error({
444
+ output_1.output.error({
172
445
  title: `Release group "${error.data.releaseGroupName}" matches no projects. Please ensure all release groups match at least one project:`,
173
446
  bodyLines: [nxJsonMessage],
174
447
  });
@@ -180,17 +453,46 @@ async function handleNxReleaseConfigError(error) {
180
453
  'release',
181
454
  'groups',
182
455
  ]);
183
- devkit_exports_1.output.error({
456
+ output_1.output.error({
184
457
  title: `Project "${error.data.project}" matches multiple release groups. Please ensure all projects are part of only one release group:`,
185
458
  bodyLines: [nxJsonMessage],
186
459
  });
187
460
  }
188
461
  break;
189
- case 'PROJECTS_MISSING_TARGET':
462
+ case 'RELEASE_GROUP_RELEASE_TAG_PATTERN_VERSION_PLACEHOLDER_MISSING_OR_EXCESSIVE':
463
+ {
464
+ const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)([
465
+ 'release',
466
+ 'groups',
467
+ error.data.releaseGroupName,
468
+ 'releaseTagPattern',
469
+ ]);
470
+ output_1.output.error({
471
+ title: `Release group "${error.data.releaseGroupName}" has an invalid releaseTagPattern. Please ensure the pattern contains exactly one instance of the "{version}" placeholder`,
472
+ bodyLines: [nxJsonMessage],
473
+ });
474
+ }
475
+ break;
476
+ case 'CONVENTIONAL_COMMITS_SHORTHAND_MIXED_WITH_OVERLAPPING_GENERATOR_OPTIONS':
477
+ {
478
+ const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)([
479
+ 'release',
480
+ ]);
481
+ output_1.output.error({
482
+ title: `You have configured both the shorthand "version.conventionalCommits" and one or more of the related "version.generatorOptions" that it sets for you. Please use one or the other:`,
483
+ bodyLines: [nxJsonMessage],
484
+ });
485
+ }
486
+ break;
487
+ case 'GLOBAL_GIT_CONFIG_MIXED_WITH_GRANULAR_GIT_CONFIG':
190
488
  {
191
- devkit_exports_1.output.error({
192
- title: `Based on your config, the following projects were matched for release but do not have a "${error.data.targetName}" target specified. Please ensure you have an appropriate plugin such as @nx/js installed, or have configured the target manually, or exclude the projects using release groups config in nx.json:`,
193
- bodyLines: Array.from(error.data.projects).map((name) => `- ${name}`),
489
+ const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)([
490
+ 'release',
491
+ 'git',
492
+ ]);
493
+ output_1.output.error({
494
+ title: `You have duplicate conflicting git configurations. If you are using the top level 'nx release' command, then remove the 'release.version.git' and 'release.changelog.git' properties in favor of 'release.git'. If you are using the subcommands or the programmatic API, then remove the 'release.git' property in favor of 'release.version.git' and 'release.changelog.git':`,
495
+ bodyLines: [nxJsonMessage],
194
496
  });
195
497
  }
196
498
  break;
@@ -200,30 +502,29 @@ async function handleNxReleaseConfigError(error) {
200
502
  process.exit(1);
201
503
  }
202
504
  exports.handleNxReleaseConfigError = handleNxReleaseConfigError;
505
+ function ensureReleaseGroupReleaseTagPatternIsValid(releaseTagPattern, releaseGroupName) {
506
+ // ensure that any provided releaseTagPattern contains exactly one instance of {version}
507
+ return releaseTagPattern.split('{version}').length === 2
508
+ ? null
509
+ : {
510
+ code: 'RELEASE_GROUP_RELEASE_TAG_PATTERN_VERSION_PLACEHOLDER_MISSING_OR_EXCESSIVE',
511
+ data: {
512
+ releaseGroupName,
513
+ },
514
+ };
515
+ }
203
516
  function ensureProjectsConfigIsArray(groups) {
204
517
  const result = {};
205
518
  for (const [groupName, groupConfig] of Object.entries(groups)) {
206
519
  result[groupName] = {
207
520
  ...groupConfig,
208
- projects: Array.isArray(groupConfig.projects)
209
- ? groupConfig.projects
210
- : [groupConfig.projects],
521
+ projects: ensureArray(groupConfig.projects),
211
522
  };
212
523
  }
213
524
  return result;
214
525
  }
215
- function ensureProjectsHaveTarget(projects, projectGraph, requiredTargetName) {
216
- const missingTargetProjects = projects.filter((project) => !(0, project_graph_utils_1.projectHasTarget)(projectGraph.nodes[project], requiredTargetName));
217
- if (missingTargetProjects.length) {
218
- return {
219
- code: 'PROJECTS_MISSING_TARGET',
220
- data: {
221
- targetName: requiredTargetName,
222
- projects: missingTargetProjects,
223
- },
224
- };
225
- }
226
- return null;
526
+ function ensureArray(value) {
527
+ return Array.isArray(value) ? value : [value];
227
528
  }
228
529
  function isObject(value) {
229
530
  return value && typeof value === 'object' && !Array.isArray(value);
@@ -271,3 +572,59 @@ function deepMergeDefaults(defaultConfigs, userConfig) {
271
572
  }
272
573
  return result;
273
574
  }
575
+ /**
576
+ * We want to prevent users from setting both the conventionalCommits shorthand and any of the related
577
+ * generatorOptions at the same time, since it is at best redundant, and at worst invalid.
578
+ */
579
+ function hasInvalidConventionalCommitsConfig(userConfig) {
580
+ // at the root
581
+ if (userConfig.version?.conventionalCommits === true &&
582
+ (userConfig.version?.generatorOptions?.currentVersionResolver ||
583
+ userConfig.version?.generatorOptions?.specifierSource)) {
584
+ return true;
585
+ }
586
+ // within any groups
587
+ if (userConfig.groups) {
588
+ for (const group of Object.values(userConfig.groups)) {
589
+ if (group.version?.conventionalCommits === true &&
590
+ (group.version?.generatorOptions?.currentVersionResolver ||
591
+ group.version?.generatorOptions?.specifierSource)) {
592
+ return true;
593
+ }
594
+ }
595
+ }
596
+ return false;
597
+ }
598
+ /**
599
+ * We want to prevent users from setting both the global and granular git configurations. Users should prefer the
600
+ * global configuration if using the top level nx release command and the granular configuration if using
601
+ * the subcommands or the programmatic API.
602
+ */
603
+ function hasInvalidGitConfig(userConfig) {
604
+ return (!!userConfig.git && !!(userConfig.version?.git || userConfig.changelog?.git));
605
+ }
606
+ async function getDefaultProjects(projectGraph, projectFileMap) {
607
+ // default to all library projects in the workspace with a package.json file
608
+ return (0, find_matching_projects_1.findMatchingProjects)(['*'], projectGraph.nodes).filter((project) => projectGraph.nodes[project].type === 'lib' &&
609
+ // Exclude all projects with "private": true in their package.json because this is
610
+ // a common indicator that a project is not intended for release.
611
+ // Users can override this behavior by explicitly defining the projects they want to release.
612
+ isProjectPublic(project, projectGraph, projectFileMap));
613
+ }
614
+ function isProjectPublic(project, projectGraph, projectFileMap) {
615
+ const projectNode = projectGraph.nodes[project];
616
+ const packageJsonPath = (0, path_1.join)(projectNode.data.root, 'package.json');
617
+ if (!projectFileMap[project]?.find((f) => f.file === packageJsonPath)) {
618
+ return false;
619
+ }
620
+ try {
621
+ const fullPackageJsonPath = (0, path_1.join)(workspace_root_1.workspaceRoot, packageJsonPath);
622
+ const packageJson = (0, fileutils_1.readJsonFile)(fullPackageJsonPath);
623
+ return !(packageJson.private === true);
624
+ }
625
+ catch (e) {
626
+ // do nothing and assume that the project is not public if there is a parsing issue
627
+ // this will result in it being excluded from the default projects list
628
+ return false;
629
+ }
630
+ }
@@ -0,0 +1,2 @@
1
+ import { NxReleaseConfig } from './config';
2
+ export declare const DEFAULT_CONVENTIONAL_COMMITS_CONFIG: NxReleaseConfig['conventionalCommits'];