@storm-software/workspace-tools 1.270.2 → 1.271.1

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 (287) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +1 -1
  3. package/dist/chunk-4QYM3VS4.mjs +282 -0
  4. package/dist/{chunk-ZP76EMBE.js → chunk-FYXWAGK3.js} +97 -27
  5. package/dist/chunk-MJMN2T4N.mjs +166 -0
  6. package/dist/chunk-RZVF4LHT.js +282 -0
  7. package/dist/executors.js +6 -6
  8. package/dist/executors.mjs +6 -6
  9. package/dist/index.d.mts +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +6 -6
  12. package/dist/index.mjs +8 -8
  13. package/dist/src/executors/npm-publish/executor.js +3 -3
  14. package/dist/src/executors/npm-publish/executor.mjs +2 -2
  15. package/dist/src/generators/preset/files/LICENSE +201 -0
  16. package/dist/src/utils/index.d.mts +1 -1
  17. package/dist/src/utils/index.d.ts +1 -1
  18. package/dist/src/utils/index.js +2 -2
  19. package/dist/src/utils/index.mjs +3 -3
  20. package/dist/src/utils/pnpm-deps-update.d.mts +3 -3
  21. package/dist/src/utils/pnpm-deps-update.d.ts +3 -3
  22. package/dist/src/utils/pnpm-deps-update.js +2 -2
  23. package/dist/src/utils/pnpm-deps-update.mjs +3 -3
  24. package/docs/api/base/base-executor.schema.md +16 -0
  25. package/docs/api/base/base-generator.schema.md +15 -0
  26. package/docs/api/base/cargo-base-executor.schema.md +90 -0
  27. package/docs/api/base/typescript-build-executor.schema.md +126 -0
  28. package/docs/api/base/typescript-library-generator.schema.md +129 -0
  29. package/docs/api/executors/cargo-build/schema.md +89 -0
  30. package/docs/api/executors/cargo-check/schema.md +90 -0
  31. package/docs/api/executors/cargo-clippy/schema.md +99 -0
  32. package/docs/api/executors/cargo-doc/schema.md +130 -0
  33. package/docs/api/executors/cargo-format/schema.md +90 -0
  34. package/docs/api/executors/cargo-publish/schema.md +117 -0
  35. package/docs/api/executors/clean-package/schema.md +65 -0
  36. package/docs/api/executors/esbuild/schema.md +126 -0
  37. package/docs/api/executors/npm-publish/schema.md +64 -0
  38. package/docs/api/executors/size-limit/schema.md +25 -0
  39. package/docs/api/executors/typia/schema.md +46 -0
  40. package/docs/api/executors/unbuild/schema.md +222 -0
  41. package/docs/api/generators/browser-library/files/README.md +58 -0
  42. package/docs/api/generators/browser-library/schema.md +129 -0
  43. package/docs/api/generators/config-schema/schema.md +25 -0
  44. package/docs/api/generators/init/schema.md +15 -0
  45. package/docs/api/generators/neutral-library/files/README.md +58 -0
  46. package/docs/api/generators/neutral-library/schema.md +129 -0
  47. package/docs/api/generators/node-library/files/README.md +63 -0
  48. package/docs/api/generators/node-library/schema.md +129 -0
  49. package/docs/api/generators/preset/schema.md +110 -0
  50. package/docs/api/generators/release-version/schema.md +160 -0
  51. package/package.json +13 -35
  52. package/dist/chunk-CMH2A42G.js +0 -467
  53. package/dist/chunk-HMJTTE4A.mjs +0 -96
  54. package/dist/chunk-I54IKCIV.mjs +0 -467
  55. package/docs/executors/rollup.md +0 -88
  56. package/executors.ts +0 -23
  57. package/generators.ts +0 -14
  58. package/index.ts +0 -5
  59. package/project.json +0 -58
  60. package/src/base/base-executor.ts +0 -200
  61. package/src/base/base-executor.untyped.ts +0 -18
  62. package/src/base/base-generator.ts +0 -130
  63. package/src/base/base-generator.untyped.ts +0 -16
  64. package/src/base/cargo-base-executor.untyped.ts +0 -73
  65. package/src/base/index.ts +0 -8
  66. package/src/base/typescript-build-executor.untyped.ts +0 -153
  67. package/src/base/typescript-library-generator.ts +0 -415
  68. package/src/base/typescript-library-generator.untyped.ts +0 -106
  69. package/src/executors/cargo-build/executor.spec.ts +0 -18
  70. package/src/executors/cargo-build/executor.ts +0 -28
  71. package/src/executors/cargo-build/untyped.ts +0 -18
  72. package/src/executors/cargo-check/executor.spec.ts +0 -18
  73. package/src/executors/cargo-check/executor.ts +0 -27
  74. package/src/executors/cargo-check/untyped.ts +0 -11
  75. package/src/executors/cargo-clippy/executor.spec.ts +0 -18
  76. package/src/executors/cargo-clippy/executor.ts +0 -28
  77. package/src/executors/cargo-clippy/untyped.ts +0 -18
  78. package/src/executors/cargo-doc/executor.spec.ts +0 -18
  79. package/src/executors/cargo-doc/executor.ts +0 -39
  80. package/src/executors/cargo-doc/untyped.ts +0 -44
  81. package/src/executors/cargo-format/executor.spec.ts +0 -18
  82. package/src/executors/cargo-format/executor.ts +0 -28
  83. package/src/executors/cargo-format/untyped.ts +0 -11
  84. package/src/executors/cargo-publish/executor.spec.ts +0 -11
  85. package/src/executors/cargo-publish/executor.ts +0 -139
  86. package/src/executors/cargo-publish/untyped.ts +0 -33
  87. package/src/executors/clean-package/constants.ts +0 -99
  88. package/src/executors/clean-package/executor.spec.ts +0 -18
  89. package/src/executors/clean-package/executor.ts +0 -214
  90. package/src/executors/clean-package/types.ts +0 -6
  91. package/src/executors/clean-package/untyped.ts +0 -60
  92. package/src/executors/clean-package/utils.ts +0 -85
  93. package/src/executors/esbuild/executor.spec.ts +0 -11
  94. package/src/executors/esbuild/executor.ts +0 -67
  95. package/src/executors/esbuild/untyped.ts +0 -20
  96. package/src/executors/npm-publish/executor.spec.ts +0 -11
  97. package/src/executors/npm-publish/executor.ts +0 -680
  98. package/src/executors/npm-publish/untyped.ts +0 -56
  99. package/src/executors/size-limit/executor.spec.ts +0 -18
  100. package/src/executors/size-limit/executor.ts +0 -88
  101. package/src/executors/size-limit/untyped.ts +0 -22
  102. package/src/executors/typia/executor.ts +0 -54
  103. package/src/executors/typia/untyped.ts +0 -48
  104. package/src/executors/unbuild/executor.spec.ts +0 -11
  105. package/src/executors/unbuild/executor.ts +0 -136
  106. package/src/executors/unbuild/untyped.ts +0 -152
  107. package/src/generators/browser-library/generator.spec.ts +0 -20
  108. package/src/generators/browser-library/generator.ts +0 -109
  109. package/src/generators/browser-library/untyped.ts +0 -29
  110. package/src/generators/config-schema/generator.spec.ts +0 -20
  111. package/src/generators/config-schema/generator.ts +0 -90
  112. package/src/generators/config-schema/untyped.ts +0 -19
  113. package/src/generators/init/init.ts +0 -32
  114. package/src/generators/init/untyped.ts +0 -16
  115. package/src/generators/neutral-library/generator.spec.ts +0 -20
  116. package/src/generators/neutral-library/generator.ts +0 -81
  117. package/src/generators/neutral-library/untyped.ts +0 -29
  118. package/src/generators/node-library/generator.spec.ts +0 -20
  119. package/src/generators/node-library/generator.ts +0 -84
  120. package/src/generators/node-library/untyped.ts +0 -29
  121. package/src/generators/preset/files/.all-contributorsrc.template +0 -48
  122. package/src/generators/preset/files/.editorconfig +0 -454
  123. package/src/generators/preset/files/.env.template +0 -38
  124. package/src/generators/preset/files/.gitattributes +0 -52
  125. package/src/generators/preset/files/.github/.nvmrc +0 -1
  126. package/src/generators/preset/files/.github/CODEOWNERS +0 -3
  127. package/src/generators/preset/files/.github/CODE_OF_CONDUCT.md +0 -125
  128. package/src/generators/preset/files/.github/CONTRIBUTING.md.template +0 -15
  129. package/src/generators/preset/files/.github/FUNDING.yml +0 -3
  130. package/src/generators/preset/files/.github/ISSUE_TEMPLATE/bug-report.yml.template +0 -102
  131. package/src/generators/preset/files/.github/ISSUE_TEMPLATE/documentation.yml.template +0 -56
  132. package/src/generators/preset/files/.github/ISSUE_TEMPLATE/feature-request.yml.template +0 -60
  133. package/src/generators/preset/files/.github/PULL_REQUEST_TEMPLATE.md.template +0 -39
  134. package/src/generators/preset/files/.github/SECURITY.md +0 -9
  135. package/src/generators/preset/files/.github/codecov.yml +0 -29
  136. package/src/generators/preset/files/.github/dependabot.yml +0 -64
  137. package/src/generators/preset/files/.github/labels.yml +0 -84
  138. package/src/generators/preset/files/.github/renovate.json +0 -4
  139. package/src/generators/preset/files/.github/renovate.json.template +0 -63
  140. package/src/generators/preset/files/.github/stale.yml +0 -55
  141. package/src/generators/preset/files/.github/workflows/build-release.yml.template +0 -25
  142. package/src/generators/preset/files/.github/workflows/code-review.yml +0 -18
  143. package/src/generators/preset/files/.github/workflows/codeql.yml +0 -84
  144. package/src/generators/preset/files/.github/workflows/dependabot-update.yml +0 -32
  145. package/src/generators/preset/files/.github/workflows/git-guardian.yml +0 -23
  146. package/src/generators/preset/files/.github/workflows/greetings.yml +0 -31
  147. package/src/generators/preset/files/.github/workflows/labels.yml +0 -31
  148. package/src/generators/preset/files/.github/workflows/lock.yml +0 -26
  149. package/src/generators/preset/files/.log4brains.yml.template +0 -5
  150. package/src/generators/preset/files/.markdownlint.json +0 -155
  151. package/src/generators/preset/files/.verdaccio/config.yml.template +0 -40
  152. package/src/generators/preset/files/.vscode/README.md +0 -32
  153. package/src/generators/preset/files/.vscode/cspell.json +0 -3
  154. package/src/generators/preset/files/.vscode/extensions.json +0 -14
  155. package/src/generators/preset/files/.vscode/launch.json +0 -37
  156. package/src/generators/preset/files/.vscode/settings.json +0 -401
  157. package/src/generators/preset/files/.vscode/tasks.json +0 -4
  158. package/src/generators/preset/files/.whitesource +0 -14
  159. package/src/generators/preset/files/assets/diagrams/.gitkeep +0 -0
  160. package/src/generators/preset/files/assets/icons/dark/.gitkeep +0 -0
  161. package/src/generators/preset/files/assets/icons/light/.gitkeep +0 -0
  162. package/src/generators/preset/files/assets/logos/.gitkeep +0 -0
  163. package/src/generators/preset/files/docs/api-reference/.gitkeep +0 -0
  164. package/src/generators/preset/generator.spec.ts +0 -20
  165. package/src/generators/preset/generator.ts +0 -315
  166. package/src/generators/preset/untyped.ts +0 -88
  167. package/src/generators/release-version/generator.spec.ts +0 -20
  168. package/src/generators/release-version/generator.ts +0 -920
  169. package/src/generators/release-version/untyped.ts +0 -156
  170. package/src/plugins/rust/cargo-toml.ts +0 -434
  171. package/src/plugins/rust/index.ts +0 -1
  172. package/src/plugins/typescript/index.ts +0 -1
  173. package/src/plugins/typescript/project-config.ts +0 -564
  174. package/src/plugins/typescript/tsup.ts +0 -198
  175. package/src/types.ts +0 -130
  176. package/src/utils/apply-workspace-tokens.ts +0 -73
  177. package/src/utils/cargo.ts +0 -219
  178. package/src/utils/create-cli-options.ts +0 -23
  179. package/src/utils/get-project-configurations.ts +0 -27
  180. package/src/utils/index.ts +0 -12
  181. package/src/utils/lock-file.ts +0 -159
  182. package/src/utils/package-helpers.ts +0 -54
  183. package/src/utils/plugin-helpers.ts +0 -112
  184. package/src/utils/pnpm-deps-update.ts +0 -111
  185. package/src/utils/project-tags.ts +0 -162
  186. package/src/utils/toml.ts +0 -204
  187. package/src/utils/typia-transform.ts +0 -8
  188. package/src/utils/versions.ts +0 -19
  189. package/tsconfig.json +0 -30
  190. package/tsup.config.ts +0 -36
  191. /package/{src/generators/preset/files/LICENSE → LICENSE} +0 -0
  192. /package/{src → dist/src}/base/base-executor.schema.d.ts +0 -0
  193. /package/{src → dist/src}/base/base-executor.schema.json +0 -0
  194. /package/{src → dist/src}/base/base-executor.schema.md +0 -0
  195. /package/{src → dist/src}/base/base-generator.schema.d.ts +0 -0
  196. /package/{src → dist/src}/base/base-generator.schema.json +0 -0
  197. /package/{src → dist/src}/base/base-generator.schema.md +0 -0
  198. /package/{src → dist/src}/base/cargo-base-executor.schema.d.ts +0 -0
  199. /package/{src → dist/src}/base/cargo-base-executor.schema.json +0 -0
  200. /package/{src → dist/src}/base/cargo-base-executor.schema.md +0 -0
  201. /package/{src → dist/src}/base/typescript-build-executor.schema.d.ts +0 -0
  202. /package/{src → dist/src}/base/typescript-build-executor.schema.json +0 -0
  203. /package/{src → dist/src}/base/typescript-build-executor.schema.md +0 -0
  204. /package/{src → dist/src}/base/typescript-library-generator.schema.d.ts +0 -0
  205. /package/{src → dist/src}/base/typescript-library-generator.schema.json +0 -0
  206. /package/{src → dist/src}/base/typescript-library-generator.schema.md +0 -0
  207. /package/{src → dist/src}/executors/cargo-build/schema.d.ts +0 -0
  208. /package/{src → dist/src}/executors/cargo-build/schema.json +0 -0
  209. /package/{src → dist/src}/executors/cargo-build/schema.md +0 -0
  210. /package/{src → dist/src}/executors/cargo-check/schema.d.ts +0 -0
  211. /package/{src → dist/src}/executors/cargo-check/schema.json +0 -0
  212. /package/{src → dist/src}/executors/cargo-check/schema.md +0 -0
  213. /package/{src → dist/src}/executors/cargo-clippy/schema.d.ts +0 -0
  214. /package/{src → dist/src}/executors/cargo-clippy/schema.json +0 -0
  215. /package/{src → dist/src}/executors/cargo-clippy/schema.md +0 -0
  216. /package/{src → dist/src}/executors/cargo-doc/schema.d.ts +0 -0
  217. /package/{src → dist/src}/executors/cargo-doc/schema.json +0 -0
  218. /package/{src → dist/src}/executors/cargo-doc/schema.md +0 -0
  219. /package/{src → dist/src}/executors/cargo-format/schema.d.ts +0 -0
  220. /package/{src → dist/src}/executors/cargo-format/schema.json +0 -0
  221. /package/{src → dist/src}/executors/cargo-format/schema.md +0 -0
  222. /package/{src → dist/src}/executors/cargo-publish/schema.d.ts +0 -0
  223. /package/{src → dist/src}/executors/cargo-publish/schema.json +0 -0
  224. /package/{src → dist/src}/executors/cargo-publish/schema.md +0 -0
  225. /package/{src → dist/src}/executors/clean-package/schema.d.ts +0 -0
  226. /package/{src → dist/src}/executors/clean-package/schema.json +0 -0
  227. /package/{src → dist/src}/executors/clean-package/schema.md +0 -0
  228. /package/{src → dist/src}/executors/esbuild/schema.d.ts +0 -0
  229. /package/{src → dist/src}/executors/esbuild/schema.json +0 -0
  230. /package/{src → dist/src}/executors/esbuild/schema.md +0 -0
  231. /package/{src → dist/src}/executors/npm-publish/schema.d.ts +0 -0
  232. /package/{src → dist/src}/executors/npm-publish/schema.json +0 -0
  233. /package/{src → dist/src}/executors/npm-publish/schema.md +0 -0
  234. /package/{src → dist/src}/executors/size-limit/schema.d.ts +0 -0
  235. /package/{src → dist/src}/executors/size-limit/schema.json +0 -0
  236. /package/{src → dist/src}/executors/size-limit/schema.md +0 -0
  237. /package/{src → dist/src}/executors/typia/schema.d.ts +0 -0
  238. /package/{src → dist/src}/executors/typia/schema.json +0 -0
  239. /package/{src → dist/src}/executors/typia/schema.md +0 -0
  240. /package/{src → dist/src}/executors/unbuild/schema.d.ts +0 -0
  241. /package/{src → dist/src}/executors/unbuild/schema.json +0 -0
  242. /package/{src → dist/src}/executors/unbuild/schema.md +0 -0
  243. /package/{src → dist/src}/generators/browser-library/files/README.md +0 -0
  244. /package/{src → dist/src}/generators/browser-library/files/jest.config.ts +0 -0
  245. /package/{src → dist/src}/generators/browser-library/files/src/index.ts.template +0 -0
  246. /package/{src → dist/src}/generators/browser-library/files/tsconfig.spec.json +0 -0
  247. /package/{src → dist/src}/generators/browser-library/schema.d.ts +0 -0
  248. /package/{src → dist/src}/generators/browser-library/schema.json +0 -0
  249. /package/{src → dist/src}/generators/browser-library/schema.md +0 -0
  250. /package/{src → dist/src}/generators/config-schema/schema.d.ts +0 -0
  251. /package/{src → dist/src}/generators/config-schema/schema.json +0 -0
  252. /package/{src → dist/src}/generators/config-schema/schema.md +0 -0
  253. /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
  254. /package/{src → dist/src}/generators/init/schema.json +0 -0
  255. /package/{src → dist/src}/generators/init/schema.md +0 -0
  256. /package/{src → dist/src}/generators/neutral-library/files/README.md +0 -0
  257. /package/{src → dist/src}/generators/neutral-library/files/jest.config.ts +0 -0
  258. /package/{src → dist/src}/generators/neutral-library/files/src/index.ts.template +0 -0
  259. /package/{src → dist/src}/generators/neutral-library/files/tsconfig.spec.json +0 -0
  260. /package/{src → dist/src}/generators/neutral-library/schema.d.ts +0 -0
  261. /package/{src → dist/src}/generators/neutral-library/schema.json +0 -0
  262. /package/{src → dist/src}/generators/neutral-library/schema.md +0 -0
  263. /package/{src → dist/src}/generators/node-library/files/README.md +0 -0
  264. /package/{src → dist/src}/generators/node-library/files/jest.config.ts +0 -0
  265. /package/{src → dist/src}/generators/node-library/files/src/index.ts.template +0 -0
  266. /package/{src → dist/src}/generators/node-library/files/tsconfig.spec.json +0 -0
  267. /package/{src → dist/src}/generators/node-library/schema.d.ts +0 -0
  268. /package/{src → dist/src}/generators/node-library/schema.json +0 -0
  269. /package/{src → dist/src}/generators/node-library/schema.md +0 -0
  270. /package/{src → dist/src}/generators/preset/files/README.md.template +0 -0
  271. /package/{src → dist/src}/generators/preset/files/docs/readme-templates/README.footer.md.template +0 -0
  272. /package/{src → dist/src}/generators/preset/files/docs/readme-templates/README.header.md.template +0 -0
  273. /package/{src → dist/src}/generators/preset/files/eslint.config.js.template +0 -0
  274. /package/{src → dist/src}/generators/preset/files/knip.json +0 -0
  275. /package/{src → dist/src}/generators/preset/files/lefthook.json +0 -0
  276. /package/{src → dist/src}/generators/preset/files/nx.json +0 -0
  277. /package/{src → dist/src}/generators/preset/files/pnpm-workspace.yaml +0 -0
  278. /package/{src → dist/src}/generators/preset/files/socket.yaml +0 -0
  279. /package/{src → dist/src}/generators/preset/files/storm.json.template +0 -0
  280. /package/{src → dist/src}/generators/preset/files/tsconfig.base.json.template +0 -0
  281. /package/{src → dist/src}/generators/preset/schema.d.ts +0 -0
  282. /package/{src → dist/src}/generators/preset/schema.json +0 -0
  283. /package/{src → dist/src}/generators/preset/schema.md +0 -0
  284. /package/{src → dist/src}/generators/release-version/schema.d.ts +0 -0
  285. /package/{src → dist/src}/generators/release-version/schema.json +0 -0
  286. /package/{src → dist/src}/generators/release-version/schema.md +0 -0
  287. /package/{src → dist/src}/plugins/typescript/untyped-schema.ts +0 -0
@@ -1,920 +0,0 @@
1
- import {
2
- formatFiles,
3
- joinPathFragments,
4
- output,
5
- readJson,
6
- updateJson,
7
- writeJson,
8
- type ProjectGraph,
9
- type ProjectGraphDependency,
10
- type ProjectGraphProjectNode,
11
- type Tree
12
- } from "@nx/devkit";
13
- import { resolveLocalPackageDependencies as resolveLocalPackageJsonDependencies } from "@nx/js/src/generators/release-version/utils/resolve-local-package-dependencies";
14
- import { updateLockFile } from "@nx/js/src/release/utils/update-lock-file";
15
- import type { StormWorkspaceConfig } from "@storm-software/config";
16
- import {
17
- findWorkspaceRoot,
18
- getConfig,
19
- getStopwatch,
20
- writeDebug,
21
- writeError,
22
- writeFatal,
23
- writeInfo,
24
- writeSuccess,
25
- writeTrace
26
- } from "@storm-software/config-tools";
27
- import { DEFAULT_CONVENTIONAL_COMMITS_CONFIG } from "@storm-software/git-tools";
28
- import { exec, execSync } from "node:child_process";
29
- import { relative } from "node:path";
30
- import { IMPLICIT_DEFAULT_RELEASE_GROUP } from "nx/src/command-line/release/config/config";
31
- import {
32
- getFirstGitCommit,
33
- getLatestGitTagForPattern
34
- } from "nx/src/command-line/release/utils/git";
35
- import {
36
- resolveSemverSpecifierFromConventionalCommits,
37
- resolveSemverSpecifierFromPrompt
38
- } from "nx/src/command-line/release/utils/resolve-semver-specifier";
39
- import { isValidSemverSpecifier } from "nx/src/command-line/release/utils/semver";
40
- import {
41
- ReleaseVersionGeneratorResult,
42
- VersionData,
43
- deriveNewSemverVersion,
44
- validReleaseVersionPrefixes
45
- } from "nx/src/command-line/release/version-legacy";
46
- import { interpolate } from "nx/src/tasks-runner/utils";
47
- import { prerelease } from "semver";
48
- import {
49
- modifyCargoTable,
50
- parseCargoToml,
51
- parseCargoTomlWithTree,
52
- stringifyCargoToml
53
- } from "../../utils/toml";
54
- import type { ReleaseVersionGeneratorSchema } from "./schema.d";
55
-
56
- type ReleaseVersionPrefixes = "auto" | "" | "~" | "^" | "=";
57
-
58
- export async function releaseVersionGeneratorFn(
59
- tree: Tree,
60
- options: ReleaseVersionGeneratorSchema,
61
- config?: StormWorkspaceConfig
62
- ): Promise<ReleaseVersionGeneratorResult> {
63
- writeInfo(`⚡ Running the Storm Release Version generator...\n\n`, config);
64
-
65
- const stopwatch = getStopwatch("Storm Release Version generator");
66
-
67
- try {
68
- const workspaceRoot = findWorkspaceRoot();
69
- writeDebug(
70
- `Loading the Storm Config from environment variables and storm.config.js file...
71
- - workspaceRoot: ${workspaceRoot}`,
72
- config
73
- );
74
-
75
- config = await getConfig(workspaceRoot);
76
-
77
- writeTrace(
78
- `Generator schema options ⚙️ \n${Object.keys(options ?? {})
79
- .filter(
80
- key =>
81
- ![
82
- "projects",
83
- "releaseGroup",
84
- "projectGraph",
85
- "currentVersionResolverMetadata"
86
- ].includes(key)
87
- )
88
- .map(key => ` - ${key}=${JSON.stringify(options[key])}`)
89
- .join("\n")}`,
90
- config
91
- );
92
-
93
- const versionData: VersionData = {};
94
-
95
- // If the user provided a specifier, validate that it is valid semver or a relative semver keyword
96
- if (options.specifier) {
97
- if (!isValidSemverSpecifier(options.specifier)) {
98
- throw new Error(
99
- `The given version specifier "${options.specifier}" is not valid. You provide an exact version or a valid semver keyword such as "major", "minor", "patch", etc.`
100
- );
101
- }
102
- // The node semver library classes a leading `v` as valid, but we want to ensure it is not present in the final version
103
- options.specifier = options.specifier.replace(/^v/, "");
104
- }
105
-
106
- if (
107
- options.versionPrefix &&
108
- validReleaseVersionPrefixes.indexOf(
109
- options.versionPrefix as ReleaseVersionPrefixes
110
- ) === -1
111
- ) {
112
- throw new Error(
113
- `Invalid value for version.generatorOptions.versionPrefix: "${options.versionPrefix}"
114
-
115
- Valid values are: ${validReleaseVersionPrefixes.map(s => `"${s}"`).join(", ")}`
116
- );
117
- }
118
-
119
- // always use disk as a fallback in case this is the first release
120
- options.fallbackCurrentVersionResolver ??= "disk";
121
- options.currentVersionResolver ??= "git-tag";
122
-
123
- const projects = options.projects;
124
-
125
- const createResolvePackageRoot =
126
- (customPackageRoot?: string) =>
127
- (projectNode: ProjectGraphProjectNode): string => {
128
- if (
129
- projectNode?.data?.root === config?.workspaceRoot ||
130
- projectNode?.data?.root === "."
131
- ) {
132
- return config?.workspaceRoot ?? findWorkspaceRoot();
133
- }
134
-
135
- // Default to the project root if no custom packageRoot
136
- if (!customPackageRoot) {
137
- return projectNode.data.root;
138
- }
139
-
140
- return interpolate(customPackageRoot, {
141
- workspaceRoot: "",
142
- projectRoot: projectNode.data.root,
143
- projectName: projectNode.name
144
- });
145
- };
146
-
147
- const resolvePackageRoot = createResolvePackageRoot(options.packageRoot);
148
-
149
- // Resolve any custom package roots for each project upfront as they will need to be reused during dependency resolution
150
- const projectNameToPackageRootMap = new Map<string, string>();
151
- for (const project of projects) {
152
- projectNameToPackageRootMap.set(
153
- project.name,
154
- resolvePackageRoot(project as ProjectGraphProjectNode)
155
- );
156
- }
157
-
158
- let currentVersion: string | null = null;
159
- let currentVersionResolvedFromFallback = false;
160
-
161
- let latestMatchingGitTag: any = null;
162
- let specifier = options.specifier ? options.specifier : undefined;
163
-
164
- for (const project of projects) {
165
- const projectName = project.name;
166
- const packageRoot = projectNameToPackageRootMap.get(projectName);
167
-
168
- const packageJsonPath = joinPathFragments(
169
- packageRoot ?? "./",
170
- "package.json"
171
- );
172
- const cargoTomlPath = joinPathFragments(
173
- packageRoot ?? "./",
174
- "Cargo.toml"
175
- );
176
- if (!tree.exists(packageJsonPath) && !tree.exists(cargoTomlPath)) {
177
- throw new Error(
178
- `The project "${projectName}" does not have a package.json available at ${packageJsonPath} or a Cargo.toml file available at ${cargoTomlPath}.
179
-
180
- To fix this you will either need to add a package.json or Cargo.toml file at that location, or configure "release" within your nx.json to exclude "${projectName}" from the current release group, or amend the packageRoot configuration to point to where the package.json should be.`
181
- );
182
- }
183
-
184
- const workspaceRelativePackagePath = relative(
185
- config?.workspaceRoot ?? findWorkspaceRoot(),
186
- tree.exists(packageJsonPath) ? packageJsonPath : cargoTomlPath
187
- );
188
-
189
- const log = (msg: string) => {
190
- writeInfo(`${projectName}: ${msg}`, config);
191
- };
192
-
193
- writeInfo(`Running release version for project: ${project.name}`, config);
194
-
195
- let packageName!: string;
196
- let currentVersionFromDisk!: string;
197
-
198
- if (tree.exists(packageJsonPath)) {
199
- const projectPackageJson = readJson(tree, packageJsonPath);
200
- log(
201
- `🔍 Reading data for package "${projectPackageJson.name}" from ${workspaceRelativePackagePath}`
202
- );
203
-
204
- packageName = projectPackageJson.name;
205
- currentVersionFromDisk = projectPackageJson.version;
206
- } else if (tree.exists(cargoTomlPath)) {
207
- const cargoToml = parseCargoToml(
208
- tree.read(cargoTomlPath)?.toString("utf-8")
209
- );
210
- log(
211
- `🔍 Reading data for package "${cargoToml.package.name}" from ${workspaceRelativePackagePath}`
212
- );
213
-
214
- packageName = cargoToml.package.name;
215
- currentVersionFromDisk = cargoToml.package.version;
216
-
217
- if (options.currentVersionResolver === "registry") {
218
- options.currentVersionResolver = "disk";
219
- }
220
- } else {
221
- throw new Error(
222
- `The project "${projectName}" does not have a package.json available at ${workspaceRelativePackagePath} or a Cargo.toml file available at ${cargoTomlPath}.
223
-
224
- To fix this you will either need to add a package.json or Cargo.toml file at that location, or configure "release" within your nx.json to exclude "${projectName}" from the current release group, or amend the packageRoot configuration to point to where the package.json should be.`
225
- );
226
- }
227
-
228
- switch (options.currentVersionResolver) {
229
- case "registry": {
230
- const metadata = options.currentVersionResolverMetadata;
231
- const npmRegistry = metadata?.registry ?? (await getNpmRegistry());
232
- const githubRegistry =
233
- metadata?.registry ?? (await getGitHubRegistry());
234
- const tag = metadata?.tag ?? "latest";
235
-
236
- /**
237
- * If the currentVersionResolver is set to registry, and the projects are not independent, we only want to make the request once for the whole batch of projects.
238
- * For independent projects, we need to make a request for each project individually as they will most likely have different versions.
239
- */
240
- if (options.releaseGroup.projectsRelationship === "independent") {
241
- try {
242
- // Must be non-blocking async to allow spinner to render
243
- currentVersion = await new Promise<string>((resolve, reject) => {
244
- exec(
245
- `npm view ${packageName} version --registry=${npmRegistry} --tag=${tag}`,
246
- (error, stdout, stderr) => {
247
- if (error) {
248
- return reject(error);
249
- }
250
- if (stderr) {
251
- return reject(stderr);
252
- }
253
- return resolve(stdout.trim());
254
- }
255
- );
256
- });
257
-
258
- // spinner.stop();
259
-
260
- log(
261
- `📄 Resolved the current version as ${currentVersion} for tag "${tag}" from registry ${npmRegistry}`
262
- );
263
- } catch (_) {
264
- try {
265
- // Try getting the version from the GitHub registry
266
- currentVersion = await new Promise<string>(
267
- (resolve, reject) => {
268
- exec(
269
- `npm view ${packageName} version --registry=${githubRegistry} --tag=${tag}`,
270
- (error, stdout, stderr) => {
271
- if (error) {
272
- return reject(error);
273
- }
274
- if (stderr) {
275
- return reject(stderr);
276
- }
277
- return resolve(stdout.trim());
278
- }
279
- );
280
- }
281
- );
282
-
283
- // spinner.stop();
284
-
285
- log(
286
- `📄 Resolved the current version as ${currentVersion} for tag "${tag}" from registry ${githubRegistry}`
287
- );
288
- } catch (_) {
289
- if (options.fallbackCurrentVersionResolver === "disk") {
290
- log(
291
- `📄 Unable to resolve the current version from the registry ${npmRegistry}${githubRegistry ? ` or ${githubRegistry}` : ""}. Falling back to the version on disk of ${currentVersionFromDisk}`
292
- );
293
- currentVersion = currentVersionFromDisk;
294
- currentVersionResolvedFromFallback = true;
295
- } else {
296
- throw new Error(
297
- `Unable to resolve the current version from the registry ${npmRegistry}${githubRegistry ? ` or ${githubRegistry}` : ""}. Please ensure that the package exists in the registry in order to use the "registry" currentVersionResolver. Alternatively, you can use the --first-release option or set "release.version.generatorOptions.fallbackCurrentVersionResolver" to "disk" in order to fallback to the version on disk when the registry lookup fails.`
298
- );
299
- }
300
- }
301
- }
302
- } else {
303
- if (currentVersionResolvedFromFallback) {
304
- log(
305
- `📄 Using the current version ${currentVersion} already resolved from disk fallback.`
306
- );
307
- } else {
308
- log(
309
- `📄 Using the current version ${currentVersion} already resolved from the registry ${npmRegistry ?? githubRegistry}`
310
- );
311
- }
312
- }
313
-
314
- break;
315
- }
316
- case "disk":
317
- currentVersion = currentVersionFromDisk;
318
- log(
319
- `📄 Resolved the current version as ${currentVersion} from ${packageJsonPath}`
320
- );
321
- break;
322
- case "git-tag": {
323
- if (
324
- // We always need to independently resolve the current version from git tag per project if the projects are independent
325
- options.releaseGroup.projectsRelationship === "independent"
326
- ) {
327
- const releaseTagPattern = options.releaseGroup.releaseTagPattern;
328
- latestMatchingGitTag = await getLatestGitTagForPattern(
329
- releaseTagPattern,
330
- {
331
- projectName: project.name
332
- }
333
- );
334
- if (!latestMatchingGitTag) {
335
- if (currentVersionFromDisk) {
336
- log(
337
- `📄 Unable to resolve the current version from git tag using pattern "${releaseTagPattern}". Falling back to the version on disk of ${currentVersionFromDisk}`
338
- );
339
- currentVersion = currentVersionFromDisk;
340
- } else {
341
- log(
342
- `No git tags matching pattern "${releaseTagPattern}" for project "${project.name}" were found. This process also could not determine the version by checking the package files on disk, so we will attempt to use the default version value: "0.0.1".`
343
- );
344
- currentVersion = "0.0.1";
345
- }
346
-
347
- currentVersionResolvedFromFallback = true;
348
- } else {
349
- currentVersion = latestMatchingGitTag.extractedVersion;
350
- log(
351
- `📄 Resolved the current version as ${currentVersion} from git tag "${latestMatchingGitTag.tag}".`
352
- );
353
- }
354
- } else {
355
- if (currentVersionResolvedFromFallback) {
356
- log(
357
- `📄 Using the current version ${currentVersion} already resolved from disk fallback.`
358
- );
359
- } else {
360
- log(
361
- `📄 Using the current version ${currentVersion} already resolved from git tag "${latestMatchingGitTag.tag}".`
362
- );
363
- }
364
- }
365
- break;
366
- }
367
- default:
368
- throw new Error(
369
- `Invalid value for options.currentVersionResolver: ${options.currentVersionResolver}`
370
- );
371
- }
372
-
373
- if (options.specifier) {
374
- log(`📄 Using the provided version specifier "${options.specifier}".`);
375
- }
376
-
377
- /**
378
- * If we are versioning independently then we always need to determine the specifier for each project individually, except
379
- * for the case where the user has provided an explicit specifier on the command.
380
- *
381
- * Otherwise, if versioning the projects together we only need to perform this logic if the specifier is still unset from
382
- * previous iterations of the loop.
383
- *
384
- * NOTE: In the case that we have previously determined via conventional commits that no changes are necessary, the specifier
385
- * will be explicitly set to `null`, so that is why we only check for `undefined` explicitly here.
386
- */
387
- if (
388
- specifier === undefined ||
389
- (options.releaseGroup.projectsRelationship === "independent" &&
390
- !options.specifier)
391
- ) {
392
- const specifierSource = options.specifierSource;
393
- switch (specifierSource) {
394
- case "conventional-commits": {
395
- if (options.currentVersionResolver !== "git-tag") {
396
- throw new Error(
397
- `Invalid currentVersionResolver "${options.currentVersionResolver}" provided for release group "${options.releaseGroup.name}". Must be "git-tag" when "specifierSource" is "conventional-commits"`
398
- );
399
- }
400
-
401
- const affectedProjects =
402
- options.releaseGroup.projectsRelationship === "independent"
403
- ? [projectName]
404
- : projects.map(p => p.name);
405
-
406
- // latestMatchingGitTag will be undefined if the current version was resolved from the disk fallback.
407
- // In this case, we want to use the first commit as the ref to be consistent with the changelog command.
408
- let previousVersionRef = latestMatchingGitTag?.tag
409
- ? latestMatchingGitTag.tag
410
- : await getFirstGitCommit();
411
- if (!previousVersionRef) {
412
- log(
413
- `Unable to determine previous version ref for the projects ${affectedProjects.join(
414
- ", "
415
- )}. This is likely a bug in Storm's Release Versioning. We will attempt to use the default version value "0.0.1" and continue with the process.`
416
- );
417
-
418
- previousVersionRef = "0.0.1";
419
- }
420
-
421
- specifier =
422
- (await resolveSemverSpecifierFromConventionalCommits(
423
- previousVersionRef,
424
- options.projectGraph as ProjectGraph,
425
- affectedProjects,
426
- DEFAULT_CONVENTIONAL_COMMITS_CONFIG
427
- )) ?? undefined;
428
-
429
- if (!specifier) {
430
- log(
431
- "🚫 No changes were detected using git history and the conventional commits standard."
432
- );
433
- break;
434
- }
435
-
436
- // Always assume that if the current version is a prerelease, then the next version should be a prerelease.
437
- // Users must manually graduate from a prerelease to a release by providing an explicit specifier.
438
- if (currentVersion && prerelease(currentVersion)) {
439
- specifier = "prerelease";
440
- log(
441
- `📄 Resolved the specifier as "${specifier}" since the current version is a prerelease.`
442
- );
443
- } else {
444
- log(
445
- `📄 Resolved the specifier as "${specifier}" using git history and the conventional commits standard.`
446
- );
447
- }
448
- break;
449
- }
450
- case "prompt": {
451
- // Only add the release group name to the log if it is one set by the user, otherwise it is useless noise
452
- const maybeLogReleaseGroup = (log: string): string => {
453
- if (
454
- options.releaseGroup.name === IMPLICIT_DEFAULT_RELEASE_GROUP
455
- ) {
456
- return log;
457
- }
458
- return `${log} within release group "${options.releaseGroup.name}"`;
459
- };
460
- if (options.releaseGroup.projectsRelationship === "independent") {
461
- specifier = await resolveSemverSpecifierFromPrompt(
462
- `${maybeLogReleaseGroup(
463
- `What kind of change is this for project "${projectName}"`
464
- )}?`,
465
- `${maybeLogReleaseGroup(`What is the exact version for project "${projectName}"`)}?`
466
- );
467
- } else {
468
- specifier = await resolveSemverSpecifierFromPrompt(
469
- `${maybeLogReleaseGroup(
470
- `What kind of change is this for the ${projects.length} matched projects(s)`
471
- )}?`,
472
- `${maybeLogReleaseGroup(
473
- `What is the exact version for the ${projects.length} matched project(s)`
474
- )}?`
475
- );
476
- }
477
- break;
478
- }
479
- default:
480
- throw new Error(
481
- `Invalid specifierSource "${specifierSource}" provided. Must be one of "prompt" or "conventional-commits"`
482
- );
483
- }
484
- }
485
-
486
- // Resolve any local package dependencies for this project (before applying the new version or updating the versionData)
487
- const localPackageDependencies = resolveLocalPackageDependencies(
488
- tree,
489
- options.projectGraph as ProjectGraph,
490
- projects.filter(
491
- project =>
492
- project?.data?.root && project?.data?.root !== config?.workspaceRoot
493
- ) as ProjectGraphProjectNode[],
494
- projectNameToPackageRootMap,
495
- resolvePackageRoot,
496
- // includeAll when the release group is independent, as we may be filtering to a specific subset of projects, but we still want to update their dependents
497
- options.releaseGroup.projectsRelationship === "independent",
498
- tree.exists(packageJsonPath)
499
- );
500
-
501
- const dependentProjects = Object.values(localPackageDependencies)
502
- .flat()
503
- .filter(localPackageDependency => {
504
- return localPackageDependency.target === project.name;
505
- });
506
-
507
- if (!currentVersion) {
508
- throw new Error(
509
- `Unable to determine the current version for project "${projectName}"`
510
- );
511
- }
512
-
513
- versionData[projectName] = {
514
- currentVersion: currentVersion ? currentVersion : "0.0.1",
515
- dependentProjects,
516
- newVersion: null // will stay as null in the final result in the case that no changes are detected
517
- } as any;
518
-
519
- if (!specifier) {
520
- log(
521
- `🚫 Skipping versioning "${packageName}" as no changes were detected.`
522
- );
523
- continue;
524
- }
525
-
526
- const newVersion = deriveNewSemverVersion(
527
- currentVersion,
528
- specifier,
529
- options.preid
530
- );
531
- if (versionData[projectName]) {
532
- versionData[projectName]!.newVersion = newVersion;
533
- }
534
-
535
- if (tree.exists(packageJsonPath)) {
536
- const projectPackageJson = readJson(tree, packageJsonPath);
537
-
538
- writeJson(tree, packageJsonPath, {
539
- ...projectPackageJson,
540
- version: newVersion
541
- });
542
- } else if (tree.exists(cargoTomlPath)) {
543
- const cargoToml = parseCargoToml(
544
- tree.read(cargoTomlPath)?.toString("utf-8")
545
- );
546
-
547
- cargoToml.package ??= {};
548
- cargoToml.package.version = newVersion;
549
- tree.write(cargoTomlPath, stringifyCargoToml(cargoToml));
550
- }
551
-
552
- log(
553
- `✍️ New version ${newVersion} written to ${workspaceRelativePackagePath}`
554
- );
555
-
556
- if (dependentProjects.length > 0) {
557
- log(
558
- `✍️ Applying new version ${newVersion} to ${dependentProjects.length} ${
559
- dependentProjects.length > 1
560
- ? "packages which depend"
561
- : "package which depends"
562
- } on ${project.name}`
563
- );
564
- }
565
-
566
- for (const dependentProject of dependentProjects) {
567
- const dependentPackageRoot = projectNameToPackageRootMap.get(
568
- dependentProject.source
569
- );
570
- if (!dependentPackageRoot) {
571
- throw new Error(
572
- `The dependent project "${dependentProject.source}" does not have a packageRoot available.
573
-
574
- Projects with packageRoot configured: ${Array.from(projectNameToPackageRootMap.keys()).join(", ")}`
575
- );
576
- }
577
-
578
- const dependentPackageJsonPath = joinPathFragments(
579
- dependentPackageRoot,
580
- "package.json"
581
- );
582
- const dependentCargoTomlPath = joinPathFragments(
583
- dependentPackageRoot,
584
- "Cargo.toml"
585
- );
586
-
587
- if (tree.exists(dependentPackageJsonPath)) {
588
- updateJson(tree, dependentPackageJsonPath, json => {
589
- // Auto (i.e.infer existing) by default
590
- let versionPrefix = options.versionPrefix ?? "auto";
591
-
592
- // For auto, we infer the prefix based on the current version of the dependent
593
- if (versionPrefix === "auto") {
594
- versionPrefix = ""; // we don't want to end up printing auto
595
-
596
- const current =
597
- json[dependentProject.dependencyCollection][packageName];
598
- if (current) {
599
- const prefixMatch = current.match(/^[~^]/);
600
- if (prefixMatch) {
601
- versionPrefix = prefixMatch[0];
602
- } else {
603
- versionPrefix = "";
604
- }
605
- }
606
- }
607
- json[dependentProject.dependencyCollection][packageName] =
608
- `${versionPrefix}${newVersion}`;
609
- return json;
610
- });
611
- } else if (tree.exists(dependentCargoTomlPath)) {
612
- const dependentPkg = parseCargoTomlWithTree(
613
- tree,
614
- dependentPackageRoot,
615
- dependentProject.source
616
- );
617
-
618
- // Auto (i.e.infer existing) by default
619
- let versionPrefix = options.versionPrefix ?? "auto";
620
- let updatedDependencyData: string | Record<string, string> = "";
621
-
622
- for (const dependency of Object.entries(
623
- dependentPkg[dependentProject.dependencyCollection] ?? {}
624
- )) {
625
- const [dependencyName, dependencyData] = dependency as [
626
- string,
627
- string | Record<string, string>
628
- ];
629
-
630
- if (dependencyName !== dependentProject.target) {
631
- continue;
632
- }
633
-
634
- // For auto, we infer the prefix based on the current version of the dependent
635
- if (versionPrefix === "auto") {
636
- versionPrefix = ""; // we don't want to end up printing auto
637
-
638
- if (currentVersion) {
639
- const dependencyVersion =
640
- typeof dependencyData === "string"
641
- ? dependencyData
642
- : dependencyData.version;
643
- const prefixMatch = dependencyVersion?.match(/^[~^=]/);
644
- if (prefixMatch) {
645
- versionPrefix = prefixMatch[0] as
646
- | ""
647
- | "auto"
648
- | "~"
649
- | "^"
650
- | "=";
651
- } else {
652
- versionPrefix = "";
653
- }
654
-
655
- // In rust the default version prefix/behavior is ^, so a ^ may have been inferred by cargo metadata via no prefix or an explicit ^.
656
- if (versionPrefix === "^") {
657
- if (
658
- typeof dependencyData !== "string" &&
659
- !dependencyData.version?.startsWith("^")
660
- ) {
661
- versionPrefix = "";
662
- }
663
- }
664
- }
665
- }
666
- const newVersionWithPrefix = `${versionPrefix}${newVersion}`;
667
- updatedDependencyData =
668
- typeof dependencyData === "string"
669
- ? newVersionWithPrefix
670
- : {
671
- ...dependencyData,
672
- version: newVersionWithPrefix
673
- };
674
- break;
675
- }
676
-
677
- const cargoTomlToUpdate = joinPathFragments(
678
- dependentPackageRoot,
679
- "Cargo.toml"
680
- );
681
-
682
- modifyCargoTable(
683
- dependentPkg,
684
- dependentProject.dependencyCollection,
685
- dependentProject.target,
686
- updatedDependencyData
687
- );
688
-
689
- tree.write(cargoTomlToUpdate, stringifyCargoToml(dependentPkg));
690
- }
691
- }
692
- }
693
-
694
- /**
695
- * Ensure that formatting is applied so that version bump diffs are as minimal as possible
696
- * within the context of the user's workspace.
697
- */
698
- await formatFiles(tree);
699
-
700
- writeSuccess(
701
- `Completed running the Storm Release Version generator!\n`,
702
- config
703
- );
704
-
705
- // Return the version data so that it can be leveraged by the overall version command
706
- return {
707
- data: versionData,
708
- callback: async (tree, opts) => {
709
- output.logSingleLine("Updating Cargo.lock file");
710
-
711
- const cwd = tree.root;
712
- const updatedFiles: string[] = (await updateLockFile(cwd, opts)) ?? [];
713
-
714
- const updatedCargoPackages = [] as string[];
715
- for (const [projectName, projectVersionData] of Object.entries(
716
- versionData
717
- )) {
718
- const project = projects.find(proj => proj.name === projectName);
719
- if (
720
- projectVersionData.newVersion &&
721
- project?.name &&
722
- projectNameToPackageRootMap.get(project.name)
723
- ) {
724
- const projectRoot = projectNameToPackageRootMap.get(project.name);
725
- if (
726
- projectRoot &&
727
- tree.exists(joinPathFragments(projectRoot, "Cargo.toml"))
728
- ) {
729
- updatedCargoPackages.push(projectName);
730
- }
731
- }
732
- }
733
-
734
- if (updatedCargoPackages.length > 0) {
735
- execSync(`cargo update ${updatedCargoPackages.join(" ")}`, {
736
- maxBuffer: 1024 * 1024 * 1024,
737
- env: {
738
- ...process.env
739
- },
740
- cwd: tree.root
741
- });
742
-
743
- if (hasGitDiff("Cargo.lock")) {
744
- updatedFiles.push("Cargo.lock");
745
- }
746
- }
747
-
748
- return updatedFiles;
749
- }
750
- };
751
- } catch (error) {
752
- writeFatal(
753
- "A fatal error occurred while running the Storm Release Version generator - the process was forced to terminate",
754
- config
755
- );
756
- writeError(
757
- `An exception was thrown in the Storm Release Version generator's process \n - Details: ${error.message}\n - Stacktrace: ${error.stack}`,
758
- config
759
- );
760
-
761
- throw new Error(
762
- `An exception was thrown in the Storm Release Version generator's process \n - Details: ${error.message}`,
763
- { cause: error }
764
- );
765
- } finally {
766
- stopwatch();
767
- }
768
- }
769
-
770
- export default releaseVersionGeneratorFn;
771
-
772
- async function getNpmRegistry() {
773
- if (process.env.STORM_REGISTRY_NPM) {
774
- return process.env.STORM_REGISTRY_NPM;
775
- }
776
-
777
- const registry = await new Promise<string>((resolve, reject) => {
778
- exec("npm config get registry", (error, stdout, stderr) => {
779
- if (error) {
780
- return reject(error);
781
- }
782
- if (stderr) {
783
- return reject(stderr);
784
- }
785
- return resolve(stdout.trim());
786
- });
787
- });
788
-
789
- return registry ? registry : "https://registry.npmjs.org";
790
- }
791
-
792
- function getGitHubRegistry() {
793
- if (process.env.STORM_REGISTRY_GITHUB) {
794
- return process.env.STORM_REGISTRY_GITHUB;
795
- }
796
-
797
- return "https://npm.pkg.github.com";
798
- }
799
-
800
- function hasGitDiff(filePath: string) {
801
- try {
802
- const result = execSync(`git diff --name-only "${filePath}"`).toString();
803
- return result.trim() === filePath;
804
- } catch (_) {
805
- // Assuming any error means no diff or a problem executing git command
806
- return false;
807
- }
808
- }
809
-
810
- interface LocalPackageDependency extends ProjectGraphDependency {
811
- dependencyCollection: "dependencies" | "dev-dependencies";
812
- }
813
-
814
- function resolveLocalPackageDependencies(
815
- tree: Tree,
816
- projectGraph: ProjectGraph,
817
- filteredProjects: ProjectGraphProjectNode[],
818
- projectNameToPackageRootMap: Map<string, string>,
819
- resolvePackageRoot: (projectNode: ProjectGraphProjectNode) => string,
820
- includeAll = false,
821
- isNodeProject = true
822
- ): Record<string, LocalPackageDependency[]> {
823
- if (isNodeProject) {
824
- return resolveLocalPackageJsonDependencies(
825
- tree,
826
- projectGraph,
827
- filteredProjects,
828
- projectNameToPackageRootMap,
829
- resolvePackageRoot,
830
- includeAll
831
- ) as Record<string, LocalPackageDependency[]>;
832
- }
833
-
834
- return resolveLocalPackageCargoDependencies(
835
- tree,
836
- projectGraph,
837
- filteredProjects,
838
- projectNameToPackageRootMap,
839
- resolvePackageRoot,
840
- includeAll
841
- );
842
- }
843
-
844
- function resolveLocalPackageCargoDependencies(
845
- tree: Tree,
846
- projectGraph: ProjectGraph,
847
- filteredProjects: ProjectGraphProjectNode[],
848
- projectNameToPackageRootMap: Map<string, string>,
849
- resolvePackageRoot: (projectNode: ProjectGraphProjectNode) => string,
850
- includeAll = false
851
- ): Record<string, LocalPackageDependency[]> {
852
- const localPackageDependencies: Record<string, LocalPackageDependency[]> = {};
853
-
854
- const projects = includeAll
855
- ? Object.values(projectGraph.nodes)
856
- : filteredProjects;
857
-
858
- for (const projectNode of projects) {
859
- // Resolve the Cargo.toml path for the project, taking into account any custom packageRoot settings
860
- let packageRoot = projectNameToPackageRootMap.get(projectNode.name);
861
- // packageRoot wasn't added to the map yet, try to resolve it dynamically
862
- if (!packageRoot && includeAll) {
863
- packageRoot = resolvePackageRoot(projectNode);
864
- if (!packageRoot) {
865
- continue;
866
- }
867
- // Append it to the map for later use within the release version generator
868
- projectNameToPackageRootMap.set(projectNode.name, packageRoot);
869
- }
870
-
871
- const cargoTomlPath = joinPathFragments(packageRoot ?? "./", "Cargo.toml");
872
- if (!tree.exists(cargoTomlPath)) {
873
- continue;
874
- }
875
-
876
- const projectDeps = projectGraph.dependencies[projectNode.name];
877
- if (!projectDeps) {
878
- continue;
879
- }
880
- const localPackageDepsForProject: LocalPackageDependency[] = [];
881
- for (const dep of projectDeps) {
882
- const depProject = projectGraph.nodes[dep.target];
883
- if (!depProject) {
884
- continue;
885
- }
886
- const depProjectRoot = projectNameToPackageRootMap.get(dep.target);
887
- if (!depProjectRoot) {
888
- throw new Error(
889
- `The project "${dep.target}" does not have a packageRoot available.`
890
- );
891
- }
892
- const cargoToml = parseCargoTomlWithTree(
893
- tree,
894
- resolvePackageRoot(projectNode),
895
- projectNode.name
896
- );
897
- const dependencies = cargoToml.dependencies ?? {};
898
- const devDependencies = cargoToml["dev-dependencies"] ?? {};
899
- const dependencyCollection: "dependencies" | "dev-dependencies" | null =
900
- dependencies[depProject.name]
901
- ? "dependencies"
902
- : devDependencies[depProject.name]
903
- ? "dev-dependencies"
904
- : null;
905
- if (!dependencyCollection) {
906
- throw new Error(
907
- `The project "${projectNode.name}" does not have a local dependency on "${depProject.name}" in its Cargo.toml`
908
- );
909
- }
910
- localPackageDepsForProject.push({
911
- ...dep,
912
- dependencyCollection
913
- });
914
- }
915
-
916
- localPackageDependencies[projectNode.name] = localPackageDepsForProject;
917
- }
918
-
919
- return localPackageDependencies;
920
- }