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
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CONVENTIONAL_COMMITS_CONFIG = void 0;
4
+ exports.DEFAULT_CONVENTIONAL_COMMITS_CONFIG = {
5
+ types: {
6
+ feat: {
7
+ semverBump: 'minor',
8
+ changelog: {
9
+ title: '🚀 Features',
10
+ hidden: false,
11
+ },
12
+ },
13
+ fix: {
14
+ semverBump: 'patch',
15
+ changelog: {
16
+ title: '🩹 Fixes',
17
+ hidden: false,
18
+ },
19
+ },
20
+ perf: {
21
+ semverBump: 'none',
22
+ changelog: {
23
+ title: '🔥 Performance',
24
+ hidden: false,
25
+ },
26
+ },
27
+ refactor: {
28
+ semverBump: 'none',
29
+ changelog: {
30
+ title: '💅 Refactors',
31
+ hidden: true,
32
+ },
33
+ },
34
+ docs: {
35
+ semverBump: 'none',
36
+ changelog: {
37
+ title: '📖 Documentation',
38
+ hidden: true,
39
+ },
40
+ },
41
+ build: {
42
+ semverBump: 'none',
43
+ changelog: {
44
+ title: '📦 Build',
45
+ hidden: true,
46
+ },
47
+ },
48
+ types: {
49
+ semverBump: 'none',
50
+ changelog: {
51
+ title: '🌊 Types',
52
+ hidden: true,
53
+ },
54
+ },
55
+ chore: {
56
+ semverBump: 'none',
57
+ changelog: {
58
+ title: '🏡 Chore',
59
+ hidden: true,
60
+ },
61
+ },
62
+ examples: {
63
+ semverBump: 'none',
64
+ changelog: {
65
+ title: '🏀 Examples',
66
+ hidden: true,
67
+ },
68
+ },
69
+ test: {
70
+ semverBump: 'none',
71
+ changelog: {
72
+ title: '✅ Tests',
73
+ hidden: true,
74
+ },
75
+ },
76
+ style: {
77
+ semverBump: 'none',
78
+ changelog: {
79
+ title: '🎨 Styles',
80
+ hidden: true,
81
+ },
82
+ },
83
+ ci: {
84
+ semverBump: 'none',
85
+ changelog: {
86
+ title: '🤖 CI',
87
+ hidden: true,
88
+ },
89
+ },
90
+ revert: {
91
+ semverBump: 'none',
92
+ changelog: {
93
+ title: '⏪ Revert',
94
+ hidden: true,
95
+ },
96
+ },
97
+ },
98
+ };
@@ -1,6 +1,6 @@
1
1
  import { ProjectGraph } from '../../../config/project-graph';
2
2
  import { NxReleaseConfig } from './config';
3
- type ReleaseGroupWithName = NxReleaseConfig['groups'][string] & {
3
+ export type ReleaseGroupWithName = NxReleaseConfig['groups'][string] & {
4
4
  name: string;
5
5
  };
6
6
  export declare function filterReleaseGroups(projectGraph: ProjectGraph, nxReleaseConfig: NxReleaseConfig, projectsFilter?: string[], groupsFilter?: string[]): {
@@ -11,4 +11,3 @@ export declare function filterReleaseGroups(projectGraph: ProjectGraph, nxReleas
11
11
  releaseGroups: ReleaseGroupWithName[];
12
12
  releaseGroupToFilteredProjects: Map<ReleaseGroupWithName, Set<string>>;
13
13
  };
14
- export {};
@@ -37,6 +37,12 @@ function filterReleaseGroups(projectGraph, nxReleaseConfig, projectsFilter, grou
37
37
  releaseGroupToFilteredProjects,
38
38
  };
39
39
  }
40
+ // Remove any non-matching projects from filteredProjectToReleaseGroup
41
+ for (const project of filteredProjectToReleaseGroup.keys()) {
42
+ if (!matchingProjectsForFilter.includes(project)) {
43
+ filteredProjectToReleaseGroup.delete(project);
44
+ }
45
+ }
40
46
  // Filter out any non-matching projects from the release group to filtered projects map
41
47
  for (const releaseGroup of releaseGroups) {
42
48
  releaseGroup.projects
@@ -60,11 +66,42 @@ function filterReleaseGroups(projectGraph, nxReleaseConfig, projectsFilter, grou
60
66
  };
61
67
  }
62
68
  }
69
+ /**
70
+ * If the user is filtering to a subset of projects, we need to make sure that they are all within release groups
71
+ * with "independent" configured for their projectsRelationship. If not, the filtering is invalid, and they should instead
72
+ * be targeting the release groups directly using the --group flag, or they should update their configuration to
73
+ * make the projects they were trying to filter be independently releasable.
74
+ */
75
+ const releaseGroupsForFilteredProjects = Array.from(new Set(Array.from(filteredProjectToReleaseGroup.values())));
76
+ const releaseGroupsThatAreNotIndependent = releaseGroupsForFilteredProjects.filter((rg) => rg.projectsRelationship !== 'independent');
77
+ if (releaseGroupsThatAreNotIndependent.length) {
78
+ // Special handling for IMPLICIT_DEFAULT_RELEASE_GROUP
79
+ if (releaseGroupsThatAreNotIndependent.length === 1 &&
80
+ releaseGroupsThatAreNotIndependent[0].name ===
81
+ config_1.IMPLICIT_DEFAULT_RELEASE_GROUP) {
82
+ return {
83
+ error: {
84
+ title: `In order to release specific projects independently with --projects those projects must be configured appropriately. For example, by setting \`"projectsRelationship": "independent"\` in your nx.json config.`,
85
+ bodyLines: [],
86
+ },
87
+ releaseGroups: [],
88
+ releaseGroupToFilteredProjects,
89
+ };
90
+ }
91
+ return {
92
+ error: {
93
+ title: `Your --projects filter "${projectsFilter}" matched projects in the following release groups which do not have "independent" configured for their "projectsRelationship":`,
94
+ bodyLines: releaseGroupsThatAreNotIndependent.map((rg) => `- ${rg.name}`),
95
+ },
96
+ releaseGroups: [],
97
+ releaseGroupToFilteredProjects,
98
+ };
99
+ }
63
100
  output_1.output.note({
64
101
  title: `Your filter "${projectsFilter}" matched the following projects:`,
65
102
  bodyLines: matchingProjectsForFilter.map((p) => {
66
103
  const releaseGroupForProject = filteredProjectToReleaseGroup.get(p);
67
- if (releaseGroupForProject.name === config_1.CATCH_ALL_RELEASE_GROUP) {
104
+ if (releaseGroupForProject.name === config_1.IMPLICIT_DEFAULT_RELEASE_GROUP) {
68
105
  return `- ${p}`;
69
106
  }
70
107
  return `- ${p} (release group "${releaseGroupForProject.name}")`;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @public
3
+ */
4
+ export { releaseChangelog } from './changelog';
5
+ /**
6
+ * @public
7
+ */
8
+ export { releasePublish } from './publish';
9
+ /**
10
+ * @public
11
+ */
12
+ export { releaseVersion } from './version';
13
+ /**
14
+ * @public
15
+ */
16
+ export { release } from './release';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.release = exports.releaseVersion = exports.releasePublish = exports.releaseChangelog = void 0;
4
+ /**
5
+ * @public
6
+ */
7
+ var changelog_1 = require("./changelog");
8
+ Object.defineProperty(exports, "releaseChangelog", { enumerable: true, get: function () { return changelog_1.releaseChangelog; } });
9
+ /**
10
+ * @public
11
+ */
12
+ var publish_1 = require("./publish");
13
+ Object.defineProperty(exports, "releasePublish", { enumerable: true, get: function () { return publish_1.releasePublish; } });
14
+ /**
15
+ * @public
16
+ */
17
+ var version_1 = require("./version");
18
+ Object.defineProperty(exports, "releaseVersion", { enumerable: true, get: function () { return version_1.releaseVersion; } });
19
+ /**
20
+ * @public
21
+ */
22
+ var release_1 = require("./release");
23
+ Object.defineProperty(exports, "release", { enumerable: true, get: function () { return release_1.release; } });
@@ -1,4 +1,8 @@
1
1
  import { PublishOptions } from './command-object';
2
- export declare function publishHandler(args: PublishOptions & {
3
- __overrides_unparsed__: string[];
4
- }): Promise<void>;
2
+ export declare const releasePublishCLIHandler: (args: PublishOptions) => Promise<any>;
3
+ /**
4
+ * NOTE: This function is also exported for programmatic usage and forms part of the public API
5
+ * of Nx. We intentionally do not wrap the implementation with handleErrors because users need
6
+ * to have control over their own error handling when using the API.
7
+ */
8
+ export declare function releasePublish(args: PublishOptions, isCLI?: boolean): Promise<number>;
@@ -1,53 +1,79 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.publishHandler = void 0;
3
+ exports.releasePublish = exports.releasePublishCLIHandler = void 0;
4
4
  const nx_json_1 = require("../../config/nx-json");
5
- const devkit_exports_1 = require("../../devkit-exports");
5
+ const file_map_utils_1 = require("../../project-graph/file-map-utils");
6
6
  const project_graph_1 = require("../../project-graph/project-graph");
7
7
  const run_command_1 = require("../../tasks-runner/run-command");
8
8
  const command_line_utils_1 = require("../../utils/command-line-utils");
9
- const logger_1 = require("../../utils/logger");
9
+ const output_1 = require("../../utils/output");
10
+ const params_1 = require("../../utils/params");
11
+ const project_graph_utils_1 = require("../../utils/project-graph-utils");
10
12
  const graph_1 = require("../graph/graph");
11
13
  const config_1 = require("./config/config");
12
14
  const filter_release_groups_1 = require("./config/filter-release-groups");
13
- async function publishHandler(args) {
15
+ const releasePublishCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => releasePublish(args, true));
16
+ exports.releasePublishCLIHandler = releasePublishCLIHandler;
17
+ /**
18
+ * NOTE: This function is also exported for programmatic usage and forms part of the public API
19
+ * of Nx. We intentionally do not wrap the implementation with handleErrors because users need
20
+ * to have control over their own error handling when using the API.
21
+ */
22
+ async function releasePublish(args, isCLI = false) {
23
+ /**
24
+ * When used via the CLI, the args object will contain a __overrides_unparsed__ property that is
25
+ * important for invoking the relevant executor behind the scenes.
26
+ *
27
+ * We intentionally do not include that in the function signature, however, so as not to cause
28
+ * confusing errors for programmatic consumers of this function.
29
+ */
30
+ const _args = args;
14
31
  const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
15
32
  const nxJson = (0, nx_json_1.readNxJson)();
16
- if (args.verbose) {
33
+ if (_args.verbose) {
17
34
  process.env.NX_VERBOSE_LOGGING = 'true';
18
35
  }
19
36
  // Apply default configuration to any optional user configuration
20
- const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, nxJson.release, 'nx-release-publish');
37
+ const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph), nxJson.release);
21
38
  if (configError) {
22
39
  return await (0, config_1.handleNxReleaseConfigError)(configError);
23
40
  }
24
- const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
41
+ const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, _args.projects, _args.groups);
25
42
  if (filterError) {
26
- devkit_exports_1.output.error(filterError);
43
+ output_1.output.error(filterError);
27
44
  process.exit(1);
28
45
  }
46
+ /**
47
+ * If the user is filtering to a subset of projects or groups, we should not run the publish task
48
+ * for dependencies, because that could cause projects outset of the filtered set to be published.
49
+ */
50
+ const shouldExcludeTaskDependencies = _args.projects?.length > 0 || _args.groups?.length > 0;
51
+ let overallExitStatus = 0;
29
52
  if (args.projects?.length) {
30
53
  /**
31
54
  * Run publishing for all remaining release groups and filtered projects within them
32
55
  */
33
56
  for (const releaseGroup of releaseGroups) {
34
- await runPublishOnProjects(args, projectGraph, nxJson, Array.from(releaseGroupToFilteredProjects.get(releaseGroup)));
57
+ const status = await runPublishOnProjects(_args, projectGraph, nxJson, Array.from(releaseGroupToFilteredProjects.get(releaseGroup)), shouldExcludeTaskDependencies, isCLI);
58
+ if (status !== 0) {
59
+ overallExitStatus = status || 1;
60
+ }
35
61
  }
36
- return process.exit(0);
62
+ return overallExitStatus;
37
63
  }
38
64
  /**
39
65
  * Run publishing for all remaining release groups
40
66
  */
41
67
  for (const releaseGroup of releaseGroups) {
42
- await runPublishOnProjects(args, projectGraph, nxJson, releaseGroup.projects);
43
- }
44
- if (args.dryRun) {
45
- logger_1.logger.warn(`\nNOTE: The "dryRun" flag means no projects were actually published.`);
68
+ const status = await runPublishOnProjects(_args, projectGraph, nxJson, releaseGroup.projects, shouldExcludeTaskDependencies, isCLI);
69
+ if (status !== 0) {
70
+ overallExitStatus = status || 1;
71
+ }
46
72
  }
47
- process.exit(0);
73
+ return overallExitStatus;
48
74
  }
49
- exports.publishHandler = publishHandler;
50
- async function runPublishOnProjects(args, projectGraph, nxJson, projectNames) {
75
+ exports.releasePublish = releasePublish;
76
+ async function runPublishOnProjects(args, projectGraph, nxJson, projectNames, shouldExcludeTaskDependencies, isCLI) {
51
77
  const projectsToRun = projectNames.map((projectName) => projectGraph.nodes[projectName]);
52
78
  const overrides = (0, command_line_utils_1.createOverrides)(args.__overrides_unparsed__);
53
79
  if (args.registry) {
@@ -56,40 +82,66 @@ async function runPublishOnProjects(args, projectGraph, nxJson, projectNames) {
56
82
  if (args.tag) {
57
83
  overrides.tag = args.tag;
58
84
  }
85
+ if (args.otp) {
86
+ overrides.otp = args.otp;
87
+ }
59
88
  if (args.dryRun) {
60
89
  overrides.dryRun = args.dryRun;
90
+ /**
91
+ * Ensure the env var is set too, so that any and all publish executors triggered
92
+ * indirectly via dependsOn can also pick up on the fact that this is a dry run.
93
+ */
94
+ process.env.NX_DRY_RUN = 'true';
61
95
  }
62
96
  if (args.verbose) {
63
97
  process.env.NX_VERBOSE_LOGGING = 'true';
64
98
  }
65
- const targets = ['nx-release-publish'];
99
+ if (args.firstRelease) {
100
+ overrides.firstRelease = args.firstRelease;
101
+ }
102
+ const requiredTargetName = 'nx-release-publish';
66
103
  if (args.graph) {
67
104
  const file = (0, command_line_utils_1.readGraphFileFromGraphArg)(args);
68
- const projectNames = projectsToRun.map((t) => t.name);
69
- return await (0, graph_1.generateGraph)({
105
+ const projectNamesWithTarget = projectsToRun
106
+ .map((t) => t.name)
107
+ .filter((projectName) => (0, project_graph_utils_1.projectHasTarget)(projectGraph.nodes[projectName], requiredTargetName));
108
+ await (0, graph_1.generateGraph)({
70
109
  watch: false,
71
110
  all: false,
72
111
  open: true,
73
112
  view: 'tasks',
74
- targets,
75
- projects: projectNames,
113
+ targets: [requiredTargetName],
114
+ projects: projectNamesWithTarget,
76
115
  file,
77
- }, projectNames);
116
+ }, projectNamesWithTarget);
117
+ return 0;
78
118
  }
79
- else {
80
- /**
81
- * Run the relevant nx-release-publish executor on each of the selected projects.
82
- */
83
- const status = await (0, run_command_1.runCommand)(projectsToRun, projectGraph, { nxJson }, {
84
- targets,
85
- outputStyle: 'static',
86
- ...args,
87
- }, overrides, null, {}, { excludeTaskDependencies: false, loadDotEnvFiles: true });
88
- if (status !== 0) {
89
- // fix for https://github.com/nrwl/nx/issues/1666
90
- if (process.stdin['unref'])
91
- process.stdin.unref();
92
- process.exit(status);
119
+ const projectsWithTarget = projectsToRun.filter((project) => (0, project_graph_utils_1.projectHasTarget)(project, requiredTargetName));
120
+ if (projectsWithTarget.length === 0) {
121
+ throw new Error(`Based on your config, the following projects were matched for publishing but do not have the "${requiredTargetName}" target specified:\n${[
122
+ ...projectsToRun.map((p) => `- ${p.name}`),
123
+ '',
124
+ `This is usually caused by not having an appropriate plugin, such as "@nx/js" installed, which will add the appropriate "${requiredTargetName}" target for you automatically.`,
125
+ ].join('\n')}\n`);
126
+ }
127
+ /**
128
+ * Run the relevant nx-release-publish executor on each of the selected projects.
129
+ */
130
+ const status = await (0, run_command_1.runCommand)(projectsWithTarget, projectGraph, { nxJson }, {
131
+ targets: [requiredTargetName],
132
+ outputStyle: 'static',
133
+ ...args,
134
+ }, overrides, null, {}, {
135
+ excludeTaskDependencies: shouldExcludeTaskDependencies,
136
+ loadDotEnvFiles: true,
137
+ });
138
+ if (status !== 0) {
139
+ // In order to not add noise to the overall CLI output, do not throw an additional error
140
+ if (isCLI) {
141
+ return status;
93
142
  }
143
+ // Throw an additional error for programmatic API usage
144
+ throw new Error('One or more of the selected projects could not be published');
94
145
  }
146
+ return 0;
95
147
  }
@@ -0,0 +1,4 @@
1
+ import { ReleaseOptions, VersionOptions } from './command-object';
2
+ import { NxReleaseVersionResult } from './version';
3
+ export declare const releaseCLIHandler: (args: VersionOptions) => Promise<any>;
4
+ export declare function release(args: ReleaseOptions): Promise<NxReleaseVersionResult | number>;
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.release = exports.releaseCLIHandler = void 0;
4
+ const enquirer_1 = require("enquirer");
5
+ const nx_json_1 = require("../../config/nx-json");
6
+ const file_map_utils_1 = require("../../project-graph/file-map-utils");
7
+ const project_graph_1 = require("../../project-graph/project-graph");
8
+ const output_1 = require("../../utils/output");
9
+ const params_1 = require("../../utils/params");
10
+ const changelog_1 = require("./changelog");
11
+ const config_1 = require("./config/config");
12
+ const filter_release_groups_1 = require("./config/filter-release-groups");
13
+ const publish_1 = require("./publish");
14
+ const git_1 = require("./utils/git");
15
+ const github_1 = require("./utils/github");
16
+ const resolve_nx_json_error_message_1 = require("./utils/resolve-nx-json-error-message");
17
+ const shared_1 = require("./utils/shared");
18
+ const version_1 = require("./version");
19
+ const releaseCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => release(args));
20
+ exports.releaseCLIHandler = releaseCLIHandler;
21
+ async function release(args) {
22
+ const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
23
+ const nxJson = (0, nx_json_1.readNxJson)();
24
+ if (args.verbose) {
25
+ process.env.NX_VERBOSE_LOGGING = 'true';
26
+ }
27
+ const hasVersionGitConfig = Object.keys(nxJson.release?.version?.git ?? {}).length > 0;
28
+ const hasChangelogGitConfig = Object.keys(nxJson.release?.changelog?.git ?? {}).length > 0;
29
+ if (hasVersionGitConfig || hasChangelogGitConfig) {
30
+ const jsonConfigErrorPath = hasVersionGitConfig
31
+ ? ['release', 'version', 'git']
32
+ : ['release', 'changelog', 'git'];
33
+ const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)(jsonConfigErrorPath);
34
+ output_1.output.error({
35
+ title: `The "release" top level command cannot be used with granular git configuration. Instead, configure git options in the "release.git" property in nx.json, or use the version, changelog, and publish subcommands or programmatic API directly.`,
36
+ bodyLines: [nxJsonMessage],
37
+ });
38
+ process.exit(1);
39
+ }
40
+ // Apply default configuration to any optional user configuration
41
+ const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph), nxJson.release);
42
+ if (configError) {
43
+ return await (0, config_1.handleNxReleaseConfigError)(configError);
44
+ }
45
+ // These properties must never be undefined as this command should
46
+ // always explicitly override the git operations of the subcommands.
47
+ const shouldCommit = nxJson.release?.git?.commit ?? true;
48
+ const shouldStage = (shouldCommit || nxJson.release?.git?.stageChanges) ?? false;
49
+ const shouldTag = nxJson.release?.git?.tag ?? true;
50
+ const versionResult = await (0, version_1.releaseVersion)({
51
+ ...args,
52
+ stageChanges: shouldStage,
53
+ gitCommit: false,
54
+ gitTag: false,
55
+ });
56
+ const changelogResult = await (0, changelog_1.releaseChangelog)({
57
+ ...args,
58
+ versionData: versionResult.projectsVersionData,
59
+ version: versionResult.workspaceVersion,
60
+ stageChanges: shouldStage,
61
+ gitCommit: false,
62
+ gitTag: false,
63
+ createRelease: false,
64
+ });
65
+ const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
66
+ if (filterError) {
67
+ output_1.output.error(filterError);
68
+ process.exit(1);
69
+ }
70
+ if (shouldCommit) {
71
+ output_1.output.logSingleLine(`Committing changes with git`);
72
+ const commitMessage = nxReleaseConfig.git.commitMessage;
73
+ const commitMessageValues = (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionResult.projectsVersionData, commitMessage);
74
+ await (0, git_1.gitCommit)({
75
+ messages: commitMessageValues,
76
+ additionalArgs: nxReleaseConfig.git.commitArgs,
77
+ dryRun: args.dryRun,
78
+ verbose: args.verbose,
79
+ });
80
+ }
81
+ if (shouldTag) {
82
+ output_1.output.logSingleLine(`Tagging commit with git`);
83
+ // Resolve any git tags as early as possible so that we can hard error in case of any duplicates before reaching the actual git command
84
+ const gitTagValues = (0, shared_1.createGitTagValues)(releaseGroups, releaseGroupToFilteredProjects, versionResult.projectsVersionData);
85
+ (0, shared_1.handleDuplicateGitTags)(gitTagValues);
86
+ for (const tag of gitTagValues) {
87
+ await (0, git_1.gitTag)({
88
+ tag,
89
+ message: nxReleaseConfig.git.tagMessage,
90
+ additionalArgs: nxReleaseConfig.git.tagArgs,
91
+ dryRun: args.dryRun,
92
+ verbose: args.verbose,
93
+ });
94
+ }
95
+ }
96
+ const shouldCreateWorkspaceRelease = (0, changelog_1.shouldCreateGitHubRelease)(nxReleaseConfig.changelog.workspaceChangelog);
97
+ let hasPushedChanges = false;
98
+ let latestCommit;
99
+ if (shouldCreateWorkspaceRelease && changelogResult.workspaceChangelog) {
100
+ output_1.output.logSingleLine(`Pushing to git remote`);
101
+ // Before we can create/update the release we need to ensure the commit exists on the remote
102
+ await (0, git_1.gitPush)({
103
+ dryRun: args.dryRun,
104
+ verbose: args.verbose,
105
+ });
106
+ hasPushedChanges = true;
107
+ output_1.output.logSingleLine(`Creating GitHub Release`);
108
+ latestCommit = await (0, git_1.getCommitHash)('HEAD');
109
+ await (0, github_1.createOrUpdateGithubRelease)(changelogResult.workspaceChangelog.releaseVersion, changelogResult.workspaceChangelog.contents, latestCommit, { dryRun: args.dryRun });
110
+ }
111
+ for (const releaseGroup of releaseGroups) {
112
+ const shouldCreateProjectReleases = (0, changelog_1.shouldCreateGitHubRelease)(releaseGroup.changelog);
113
+ if (shouldCreateProjectReleases && changelogResult.projectChangelogs) {
114
+ const projects = args.projects?.length
115
+ ? // If the user has passed a list of projects, we need to use the filtered list of projects within the release group
116
+ Array.from(releaseGroupToFilteredProjects.get(releaseGroup))
117
+ : // Otherwise, we use the full list of projects within the release group
118
+ releaseGroup.projects;
119
+ const projectNodes = projects.map((name) => projectGraph.nodes[name]);
120
+ for (const project of projectNodes) {
121
+ const changelog = changelogResult.projectChangelogs[project.name];
122
+ if (!changelog) {
123
+ continue;
124
+ }
125
+ if (!hasPushedChanges) {
126
+ output_1.output.logSingleLine(`Pushing to git remote`);
127
+ // Before we can create/update the release we need to ensure the commit exists on the remote
128
+ await (0, git_1.gitPush)({
129
+ dryRun: args.dryRun,
130
+ verbose: args.verbose,
131
+ });
132
+ hasPushedChanges = true;
133
+ }
134
+ output_1.output.logSingleLine(`Creating GitHub Release`);
135
+ if (!latestCommit) {
136
+ latestCommit = await (0, git_1.getCommitHash)('HEAD');
137
+ }
138
+ await (0, github_1.createOrUpdateGithubRelease)(changelog.releaseVersion, changelog.contents, latestCommit, { dryRun: args.dryRun });
139
+ }
140
+ }
141
+ }
142
+ let hasNewVersion = false;
143
+ // null means that all projects are versioned together but there were no changes
144
+ if (versionResult.workspaceVersion !== null) {
145
+ hasNewVersion = Object.values(versionResult.projectsVersionData).some((version) => version.newVersion !== null);
146
+ }
147
+ let shouldPublish = !!args.yes && !args.skipPublish && hasNewVersion;
148
+ const shouldPromptPublishing = !args.yes && !args.skipPublish && !args.dryRun && hasNewVersion;
149
+ if (shouldPromptPublishing) {
150
+ shouldPublish = await promptForPublish();
151
+ }
152
+ if (shouldPublish) {
153
+ await (0, publish_1.releasePublish)(args);
154
+ }
155
+ else {
156
+ output_1.output.logSingleLine('Skipped publishing packages.');
157
+ }
158
+ return versionResult;
159
+ }
160
+ exports.release = release;
161
+ async function promptForPublish() {
162
+ try {
163
+ const reply = await (0, enquirer_1.prompt)([
164
+ {
165
+ name: 'confirmation',
166
+ message: 'Do you want to publish these versions?',
167
+ type: 'confirm',
168
+ },
169
+ ]);
170
+ return reply.confirmation;
171
+ }
172
+ catch (e) {
173
+ // Handle the case where the user exits the prompt with ctrl+c
174
+ return false;
175
+ }
176
+ }
@@ -0,0 +1,7 @@
1
+ import { ProjectGraph } from '../../../config/project-graph';
2
+ import { ReleaseGroupWithName } from '../config/filter-release-groups';
3
+ /**
4
+ * To be most efficient with our invocations of runVersionOnProjects, we want to batch projects by their generator and generator options
5
+ * within any given release group.
6
+ */
7
+ export declare function batchProjectsByGeneratorConfig(projectGraph: ProjectGraph, releaseGroup: ReleaseGroupWithName, projectNamesToBatch: string[]): Map<string, string[]>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.batchProjectsByGeneratorConfig = void 0;
4
+ const json_diff_1 = require("../../../utils/json-diff");
5
+ /**
6
+ * To be most efficient with our invocations of runVersionOnProjects, we want to batch projects by their generator and generator options
7
+ * within any given release group.
8
+ */
9
+ function batchProjectsByGeneratorConfig(projectGraph, releaseGroup, projectNamesToBatch) {
10
+ const configBatches = new Map();
11
+ for (const projectName of projectNamesToBatch) {
12
+ const project = projectGraph.nodes[projectName];
13
+ const generator = project.data.release?.version?.generator ||
14
+ releaseGroup.version.generator;
15
+ const generatorOptions = {
16
+ ...releaseGroup.version.generatorOptions,
17
+ ...project.data.release?.version?.generatorOptions,
18
+ };
19
+ let found = false;
20
+ for (const [key, projects] of configBatches) {
21
+ const [existingGenerator, existingOptions] = JSON.parse(key);
22
+ if (generator === existingGenerator &&
23
+ (0, json_diff_1.deepEquals)(generatorOptions, existingOptions)) {
24
+ projects.push(projectName);
25
+ found = true;
26
+ break;
27
+ }
28
+ }
29
+ if (!found) {
30
+ configBatches.set(JSON.stringify([generator, generatorOptions]), [
31
+ projectName,
32
+ ]);
33
+ }
34
+ }
35
+ return configBatches;
36
+ }
37
+ exports.batchProjectsByGeneratorConfig = batchProjectsByGeneratorConfig;
@@ -0,0 +1 @@
1
+ export declare function execCommand(cmd: string, args: string[], options?: any): Promise<string>;