@release-please-oss/release-please 0.0.0-stage → 17.11.3

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 (310) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +279 -2
  3. package/build/src/bin/release-please.d.ts +22 -0
  4. package/build/src/bin/release-please.js +727 -0
  5. package/build/src/bootstrapper.d.ts +18 -0
  6. package/build/src/bootstrapper.js +64 -0
  7. package/build/src/changelog-notes/default.d.ts +15 -0
  8. package/build/src/changelog-notes/default.js +96 -0
  9. package/build/src/changelog-notes/github.d.ts +8 -0
  10. package/build/src/changelog-notes/github.js +29 -0
  11. package/build/src/changelog-notes.d.ts +22 -0
  12. package/build/src/changelog-notes.js +40 -0
  13. package/build/src/commit.d.ts +33 -0
  14. package/build/src/commit.js +422 -0
  15. package/build/src/errors/index.d.ts +36 -0
  16. package/build/src/errors/index.js +77 -0
  17. package/build/src/factories/changelog-notes-factory.d.ts +16 -0
  18. package/build/src/factories/changelog-notes-factory.js +44 -0
  19. package/build/src/factories/plugin-factory.d.ts +23 -0
  20. package/build/src/factories/plugin-factory.js +94 -0
  21. package/build/src/factories/versioning-strategy-factory.d.ts +16 -0
  22. package/build/src/factories/versioning-strategy-factory.js +52 -0
  23. package/build/src/factory.d.ts +18 -0
  24. package/build/src/factory.js +161 -0
  25. package/build/src/github-api.d.ts +260 -0
  26. package/build/src/github-api.js +714 -0
  27. package/build/src/github.d.ts +306 -0
  28. package/build/src/github.js +769 -0
  29. package/build/src/index.d.ts +17 -0
  30. package/build/src/index.js +41 -0
  31. package/build/src/local-github.d.ts +270 -0
  32. package/build/src/local-github.js +756 -0
  33. package/build/src/manifest.d.ts +370 -0
  34. package/build/src/manifest.js +1142 -0
  35. package/build/src/plugin.d.ts +37 -0
  36. package/build/src/plugin.js +57 -0
  37. package/build/src/plugins/cargo-workspace.d.ts +58 -0
  38. package/build/src/plugins/cargo-workspace.js +339 -0
  39. package/build/src/plugins/group-priority.d.ts +29 -0
  40. package/build/src/plugins/group-priority.js +82 -0
  41. package/build/src/plugins/linked-versions.d.ts +36 -0
  42. package/build/src/plugins/linked-versions.js +137 -0
  43. package/build/src/plugins/maven-workspace.d.ts +81 -0
  44. package/build/src/plugins/maven-workspace.js +431 -0
  45. package/build/src/plugins/merge.d.ts +27 -0
  46. package/build/src/plugins/merge.js +99 -0
  47. package/build/src/plugins/node-workspace.d.ts +50 -0
  48. package/build/src/plugins/node-workspace.js +352 -0
  49. package/build/src/plugins/sentence-case.d.ts +19 -0
  50. package/build/src/plugins/sentence-case.js +80 -0
  51. package/build/src/plugins/workspace.d.ts +173 -0
  52. package/build/src/plugins/workspace.js +308 -0
  53. package/build/src/pull-request.d.ts +11 -0
  54. package/build/src/pull-request.js +16 -0
  55. package/build/src/release-pull-request.d.ts +14 -0
  56. package/build/src/release-pull-request.js +16 -0
  57. package/build/src/release.d.ts +7 -0
  58. package/build/src/release.js +16 -0
  59. package/build/src/repository.d.ts +5 -0
  60. package/build/src/repository.js +16 -0
  61. package/build/src/scm.d.ts +80 -0
  62. package/build/src/scm.js +16 -0
  63. package/build/src/strategies/base.d.ts +162 -0
  64. package/build/src/strategies/base.js +494 -0
  65. package/build/src/strategies/bazel.d.ts +7 -0
  66. package/build/src/strategies/bazel.js +49 -0
  67. package/build/src/strategies/dart.d.ts +8 -0
  68. package/build/src/strategies/dart.js +73 -0
  69. package/build/src/strategies/dotnet-yoshi.d.ts +13 -0
  70. package/build/src/strategies/dotnet-yoshi.js +109 -0
  71. package/build/src/strategies/elixir.d.ts +5 -0
  72. package/build/src/strategies/elixir.js +46 -0
  73. package/build/src/strategies/expo.d.ts +15 -0
  74. package/build/src/strategies/expo.js +51 -0
  75. package/build/src/strategies/go-librarian.d.ts +11 -0
  76. package/build/src/strategies/go-librarian.js +84 -0
  77. package/build/src/strategies/go-yoshi.d.ts +14 -0
  78. package/build/src/strategies/go-yoshi.js +168 -0
  79. package/build/src/strategies/go.d.ts +7 -0
  80. package/build/src/strategies/go.js +53 -0
  81. package/build/src/strategies/helm.d.ts +8 -0
  82. package/build/src/strategies/helm.js +73 -0
  83. package/build/src/strategies/java-yoshi-mono-repo.d.ts +22 -0
  84. package/build/src/strategies/java-yoshi-mono-repo.js +308 -0
  85. package/build/src/strategies/java-yoshi.d.ts +20 -0
  86. package/build/src/strategies/java-yoshi.js +210 -0
  87. package/build/src/strategies/java.d.ts +28 -0
  88. package/build/src/strategies/java.js +176 -0
  89. package/build/src/strategies/krm-blueprint.d.ts +7 -0
  90. package/build/src/strategies/krm-blueprint.js +65 -0
  91. package/build/src/strategies/maven.d.ts +9 -0
  92. package/build/src/strategies/maven.js +56 -0
  93. package/build/src/strategies/node-librarian.d.ts +10 -0
  94. package/build/src/strategies/node-librarian.js +121 -0
  95. package/build/src/strategies/node.d.ts +10 -0
  96. package/build/src/strategies/node.js +111 -0
  97. package/build/src/strategies/ocaml.d.ts +5 -0
  98. package/build/src/strategies/ocaml.js +86 -0
  99. package/build/src/strategies/php-librarian.d.ts +6 -0
  100. package/build/src/strategies/php-librarian.js +35 -0
  101. package/build/src/strategies/php-yoshi.d.ts +13 -0
  102. package/build/src/strategies/php-yoshi.js +255 -0
  103. package/build/src/strategies/php.d.ts +6 -0
  104. package/build/src/strategies/php.js +76 -0
  105. package/build/src/strategies/python-librarian.d.ts +6 -0
  106. package/build/src/strategies/python-librarian.js +35 -0
  107. package/build/src/strategies/python.d.ts +11 -0
  108. package/build/src/strategies/python.js +175 -0
  109. package/build/src/strategies/r.d.ts +8 -0
  110. package/build/src/strategies/r.js +67 -0
  111. package/build/src/strategies/ruby-librarian.d.ts +6 -0
  112. package/build/src/strategies/ruby-librarian.js +35 -0
  113. package/build/src/strategies/ruby-yoshi.d.ts +13 -0
  114. package/build/src/strategies/ruby-yoshi.js +97 -0
  115. package/build/src/strategies/ruby.d.ts +9 -0
  116. package/build/src/strategies/ruby.js +71 -0
  117. package/build/src/strategies/rust.d.ts +17 -0
  118. package/build/src/strategies/rust.js +149 -0
  119. package/build/src/strategies/sfdx.d.ts +9 -0
  120. package/build/src/strategies/sfdx.js +67 -0
  121. package/build/src/strategies/simple.d.ts +7 -0
  122. package/build/src/strategies/simple.js +51 -0
  123. package/build/src/strategies/terraform-module.d.ts +7 -0
  124. package/build/src/strategies/terraform-module.js +90 -0
  125. package/build/src/strategy.d.ts +68 -0
  126. package/build/src/strategy.js +16 -0
  127. package/build/src/update.d.ts +24 -0
  128. package/build/src/update.js +16 -0
  129. package/build/src/updaters/base-xml.d.ts +19 -0
  130. package/build/src/updaters/base-xml.js +43 -0
  131. package/build/src/updaters/bazel/module-bazel.d.ts +7 -0
  132. package/build/src/updaters/bazel/module-bazel.js +33 -0
  133. package/build/src/updaters/changelog-json.d.ts +29 -0
  134. package/build/src/updaters/changelog-json.js +100 -0
  135. package/build/src/updaters/changelog.d.ts +13 -0
  136. package/build/src/updaters/changelog.js +55 -0
  137. package/build/src/updaters/composite.d.ts +20 -0
  138. package/build/src/updaters/composite.js +65 -0
  139. package/build/src/updaters/dart/pubspec-yaml.d.ts +13 -0
  140. package/build/src/updaters/dart/pubspec-yaml.js +50 -0
  141. package/build/src/updaters/default.d.ts +21 -0
  142. package/build/src/updaters/default.js +36 -0
  143. package/build/src/updaters/dotnet/apis.d.ts +18 -0
  144. package/build/src/updaters/dotnet/apis.js +45 -0
  145. package/build/src/updaters/dotnet/csproj.d.ts +12 -0
  146. package/build/src/updaters/dotnet/csproj.js +33 -0
  147. package/build/src/updaters/elixir/elixir-mix-exs.d.ts +13 -0
  148. package/build/src/updaters/elixir/elixir-mix-exs.js +42 -0
  149. package/build/src/updaters/expo/app-json.d.ts +31 -0
  150. package/build/src/updaters/expo/app-json.js +67 -0
  151. package/build/src/updaters/generic-json.d.ts +14 -0
  152. package/build/src/updaters/generic-json.js +54 -0
  153. package/build/src/updaters/generic-toml.d.ts +21 -0
  154. package/build/src/updaters/generic-toml.js +66 -0
  155. package/build/src/updaters/generic-xml.d.ts +8 -0
  156. package/build/src/updaters/generic-xml.js +38 -0
  157. package/build/src/updaters/generic-yaml.d.ts +23 -0
  158. package/build/src/updaters/generic-yaml.js +85 -0
  159. package/build/src/updaters/generic.d.ts +54 -0
  160. package/build/src/updaters/generic.js +187 -0
  161. package/build/src/updaters/go/version-go.d.ts +4 -0
  162. package/build/src/updaters/go/version-go.js +24 -0
  163. package/build/src/updaters/helm/chart-yaml.d.ts +13 -0
  164. package/build/src/updaters/helm/chart-yaml.js +41 -0
  165. package/build/src/updaters/java/java-released.d.ts +28 -0
  166. package/build/src/updaters/java/java-released.js +59 -0
  167. package/build/src/updaters/java/java-update.d.ts +21 -0
  168. package/build/src/updaters/java/java-update.js +80 -0
  169. package/build/src/updaters/java/pom-xml.d.ts +29 -0
  170. package/build/src/updaters/java/pom-xml.js +135 -0
  171. package/build/src/updaters/java/versions-manifest.d.ts +19 -0
  172. package/build/src/updaters/java/versions-manifest.js +71 -0
  173. package/build/src/updaters/krm/krm-blueprint-version.d.ts +13 -0
  174. package/build/src/updaters/krm/krm-blueprint-version.js +46 -0
  175. package/build/src/updaters/librarian-yaml.d.ts +45 -0
  176. package/build/src/updaters/librarian-yaml.js +149 -0
  177. package/build/src/updaters/node/package-json.d.ts +46 -0
  178. package/build/src/updaters/node/package-json.js +106 -0
  179. package/build/src/updaters/node/package-lock-json.d.ts +14 -0
  180. package/build/src/updaters/node/package-lock-json.js +83 -0
  181. package/build/src/updaters/node/samples-package-json.d.ts +24 -0
  182. package/build/src/updaters/node/samples-package-json.js +49 -0
  183. package/build/src/updaters/ocaml/dune-project.d.ts +13 -0
  184. package/build/src/updaters/ocaml/dune-project.js +37 -0
  185. package/build/src/updaters/ocaml/esy-json.d.ts +13 -0
  186. package/build/src/updaters/ocaml/esy-json.js +37 -0
  187. package/build/src/updaters/ocaml/opam.d.ts +13 -0
  188. package/build/src/updaters/ocaml/opam.js +37 -0
  189. package/build/src/updaters/php/php-client-version.d.ts +12 -0
  190. package/build/src/updaters/php/php-client-version.js +32 -0
  191. package/build/src/updaters/php/root-composer-update-packages.d.ts +13 -0
  192. package/build/src/updaters/php/root-composer-update-packages.js +60 -0
  193. package/build/src/updaters/python/pyproject-toml.d.ts +29 -0
  194. package/build/src/updaters/python/pyproject-toml.js +53 -0
  195. package/build/src/updaters/python/python-file-with-version.d.ts +12 -0
  196. package/build/src/updaters/python/python-file-with-version.js +32 -0
  197. package/build/src/updaters/python/setup-cfg.d.ts +12 -0
  198. package/build/src/updaters/python/setup-cfg.js +32 -0
  199. package/build/src/updaters/python/setup-py.d.ts +12 -0
  200. package/build/src/updaters/python/setup-py.js +32 -0
  201. package/build/src/updaters/r/description.d.ts +12 -0
  202. package/build/src/updaters/r/description.js +32 -0
  203. package/build/src/updaters/r/news.d.ts +12 -0
  204. package/build/src/updaters/r/news.js +49 -0
  205. package/build/src/updaters/raw-content.d.ts +19 -0
  206. package/build/src/updaters/raw-content.js +39 -0
  207. package/build/src/updaters/release-please-config.d.ts +8 -0
  208. package/build/src/updaters/release-please-config.js +80 -0
  209. package/build/src/updaters/release-please-manifest.d.ts +4 -0
  210. package/build/src/updaters/release-please-manifest.js +34 -0
  211. package/build/src/updaters/ruby/common.d.ts +17 -0
  212. package/build/src/updaters/ruby/common.js +46 -0
  213. package/build/src/updaters/ruby/gemfile-lock.d.ts +24 -0
  214. package/build/src/updaters/ruby/gemfile-lock.js +53 -0
  215. package/build/src/updaters/ruby/version-rb.d.ts +12 -0
  216. package/build/src/updaters/ruby/version-rb.js +34 -0
  217. package/build/src/updaters/rust/cargo-lock.d.ts +16 -0
  218. package/build/src/updaters/rust/cargo-lock.js +64 -0
  219. package/build/src/updaters/rust/cargo-toml.d.ts +13 -0
  220. package/build/src/updaters/rust/cargo-toml.js +89 -0
  221. package/build/src/updaters/rust/common.d.ts +54 -0
  222. package/build/src/updaters/rust/common.js +35 -0
  223. package/build/src/updaters/sfdx/sfdx-project-json.d.ts +21 -0
  224. package/build/src/updaters/sfdx/sfdx-project-json.js +41 -0
  225. package/build/src/updaters/terraform/metadata-version.d.ts +13 -0
  226. package/build/src/updaters/terraform/metadata-version.js +37 -0
  227. package/build/src/updaters/terraform/module-version.d.ts +13 -0
  228. package/build/src/updaters/terraform/module-version.js +37 -0
  229. package/build/src/updaters/terraform/readme.d.ts +12 -0
  230. package/build/src/updaters/terraform/readme.js +32 -0
  231. package/build/src/util/branch-name.d.ts +20 -0
  232. package/build/src/util/branch-name.js +225 -0
  233. package/build/src/util/code-suggester/default-options-handler.d.ts +10 -0
  234. package/build/src/util/code-suggester/default-options-handler.js +45 -0
  235. package/build/src/util/code-suggester/errors.d.ts +4 -0
  236. package/build/src/util/code-suggester/errors.js +24 -0
  237. package/build/src/util/code-suggester/github/branch.d.ts +45 -0
  238. package/build/src/util/code-suggester/github/branch.js +118 -0
  239. package/build/src/util/code-suggester/github/commit-and-push.d.ts +51 -0
  240. package/build/src/util/code-suggester/github/commit-and-push.js +141 -0
  241. package/build/src/util/code-suggester/github/create-commit.d.ts +20 -0
  242. package/build/src/util/code-suggester/github/create-commit.js +60 -0
  243. package/build/src/util/code-suggester/github/fork.d.ts +15 -0
  244. package/build/src/util/code-suggester/github/fork.js +48 -0
  245. package/build/src/util/code-suggester/github/labels.d.ts +14 -0
  246. package/build/src/util/code-suggester/github/labels.js +42 -0
  247. package/build/src/util/code-suggester/github/open-pull-request.d.ts +16 -0
  248. package/build/src/util/code-suggester/github/open-pull-request.js +56 -0
  249. package/build/src/util/code-suggester/index.d.ts +28 -0
  250. package/build/src/util/code-suggester/index.js +110 -0
  251. package/build/src/util/code-suggester/logger.d.ts +4 -0
  252. package/build/src/util/code-suggester/logger.js +37 -0
  253. package/build/src/util/code-suggester/types.d.ts +109 -0
  254. package/build/src/util/code-suggester/types.js +30 -0
  255. package/build/src/util/coerce-option.d.ts +1 -0
  256. package/build/src/util/coerce-option.js +40 -0
  257. package/build/src/util/commit-exclude.d.ts +10 -0
  258. package/build/src/util/commit-exclude.js +49 -0
  259. package/build/src/util/commit-split.d.ts +26 -0
  260. package/build/src/util/commit-split.js +100 -0
  261. package/build/src/util/commit-utils.d.ts +1 -0
  262. package/build/src/util/commit-utils.js +34 -0
  263. package/build/src/util/filter-commits.d.ts +12 -0
  264. package/build/src/util/filter-commits.js +59 -0
  265. package/build/src/util/indent-commit.d.ts +2 -0
  266. package/build/src/util/indent-commit.js +39 -0
  267. package/build/src/util/json-stringify.d.ts +1 -0
  268. package/build/src/util/json-stringify.js +22 -0
  269. package/build/src/util/logger.d.ts +24 -0
  270. package/build/src/util/logger.js +54 -0
  271. package/build/src/util/pull-request-body.d.ts +25 -0
  272. package/build/src/util/pull-request-body.js +147 -0
  273. package/build/src/util/pull-request-overflow-handler.d.ts +54 -0
  274. package/build/src/util/pull-request-overflow-handler.js +78 -0
  275. package/build/src/util/pull-request-title.d.ts +22 -0
  276. package/build/src/util/pull-request-title.js +146 -0
  277. package/build/src/util/signoff-commit-message.d.ts +1 -0
  278. package/build/src/util/signoff-commit-message.js +35 -0
  279. package/build/src/util/tag-name.d.ts +10 -0
  280. package/build/src/util/tag-name.js +42 -0
  281. package/build/src/util/toml-edit.d.ts +16 -0
  282. package/build/src/util/toml-edit.js +126 -0
  283. package/build/src/version.d.ts +35 -0
  284. package/build/src/version.js +74 -0
  285. package/build/src/versioning-strategies/always-bump-major.d.ts +10 -0
  286. package/build/src/versioning-strategies/always-bump-major.js +28 -0
  287. package/build/src/versioning-strategies/always-bump-minor.d.ts +10 -0
  288. package/build/src/versioning-strategies/always-bump-minor.js +28 -0
  289. package/build/src/versioning-strategies/always-bump-patch.d.ts +11 -0
  290. package/build/src/versioning-strategies/always-bump-patch.js +29 -0
  291. package/build/src/versioning-strategies/default.d.ts +48 -0
  292. package/build/src/versioning-strategies/default.js +102 -0
  293. package/build/src/versioning-strategies/dependency-manifest.d.ts +15 -0
  294. package/build/src/versioning-strategies/dependency-manifest.js +103 -0
  295. package/build/src/versioning-strategies/java-add-snapshot.d.ts +13 -0
  296. package/build/src/versioning-strategies/java-add-snapshot.js +54 -0
  297. package/build/src/versioning-strategies/java-snapshot.d.ts +13 -0
  298. package/build/src/versioning-strategies/java-snapshot.js +70 -0
  299. package/build/src/versioning-strategies/prerelease.d.ts +20 -0
  300. package/build/src/versioning-strategies/prerelease.js +163 -0
  301. package/build/src/versioning-strategies/service-pack.d.ts +12 -0
  302. package/build/src/versioning-strategies/service-pack.js +47 -0
  303. package/build/src/versioning-strategy.d.ts +90 -0
  304. package/build/src/versioning-strategy.js +82 -0
  305. package/package.json +114 -4
  306. package/schemas/config.json +513 -0
  307. package/schemas/manifest.json +9 -0
  308. package/templates/commit.hbs +2 -0
  309. package/templates/header.hbs +9 -0
  310. package/templates/template.hbs +19 -0
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ // Copyright 2021 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.JavaYoshi = void 0;
17
+ const versions_manifest_1 = require("../updaters/java/versions-manifest");
18
+ const version_1 = require("../version");
19
+ const changelog_1 = require("../updaters/changelog");
20
+ const errors_1 = require("../errors");
21
+ const java_1 = require("./java");
22
+ const java_update_1 = require("../updaters/java/java-update");
23
+ class JavaYoshi extends java_1.Java {
24
+ /**
25
+ * Override this method to post process commits
26
+ * @param {ConventionalCommit[]} commits parsed commits
27
+ * @returns {ConventionalCommit[]} modified commits
28
+ */
29
+ async postProcessCommits(commits) {
30
+ if (commits.length === 0) {
31
+ // For Java commits, push a fake commit so we force a
32
+ // SNAPSHOT release
33
+ commits.push({
34
+ type: 'fake',
35
+ bareMessage: 'fake commit',
36
+ message: 'fake commit',
37
+ breaking: false,
38
+ scope: null,
39
+ notes: [],
40
+ files: [],
41
+ references: [],
42
+ sha: 'fake',
43
+ });
44
+ }
45
+ return commits;
46
+ }
47
+ async needsSnapshot() {
48
+ if (this.canSkipSnapshot()) {
49
+ return false;
50
+ }
51
+ return versions_manifest_1.VersionsManifest.needsSnapshot((await this.getVersionsContent()).parsedContent);
52
+ }
53
+ async buildVersionsMap() {
54
+ this.versionsContent = await this.getVersionsContent();
55
+ return versions_manifest_1.VersionsManifest.parseVersions(this.versionsContent.parsedContent);
56
+ }
57
+ async getVersionsContent() {
58
+ if (!this.versionsContent) {
59
+ try {
60
+ this.versionsContent = await this.github.getFileContentsOnBranch(this.addPath('versions.txt'), this.targetBranch);
61
+ }
62
+ catch (err) {
63
+ if (err instanceof errors_1.FileNotFoundError) {
64
+ throw new errors_1.MissingRequiredFileError(this.addPath('versions.txt'), JavaYoshi.name, `${this.repository.owner}/${this.repository.repo}`);
65
+ }
66
+ throw err;
67
+ }
68
+ }
69
+ return this.versionsContent;
70
+ }
71
+ async buildUpdates(options) {
72
+ const updates = [];
73
+ const version = options.newVersion;
74
+ const versionsMap = options.versionsMap;
75
+ updates.push({
76
+ path: this.addPath('versions.txt'),
77
+ createIfMissing: false,
78
+ cachedFileContents: this.versionsContent,
79
+ updater: new versions_manifest_1.VersionsManifest({
80
+ version,
81
+ versionsMap,
82
+ }),
83
+ });
84
+ const pomFilesSearch = this.github.findFilesByFilenameAndRef('pom.xml', this.targetBranch, this.path);
85
+ const buildFilesSearch = this.github.findFilesByFilenameAndRef('build.gradle', this.targetBranch, this.path);
86
+ const dependenciesSearch = this.github.findFilesByFilenameAndRef('dependencies.properties', this.targetBranch, this.path);
87
+ const pomFiles = await pomFilesSearch;
88
+ pomFiles.forEach(path => {
89
+ updates.push({
90
+ path: this.addPath(path),
91
+ createIfMissing: false,
92
+ updater: new java_update_1.JavaUpdate({
93
+ version,
94
+ versionsMap,
95
+ isSnapshot: options.isSnapshot,
96
+ }),
97
+ });
98
+ });
99
+ const buildFiles = await buildFilesSearch;
100
+ buildFiles.forEach(path => {
101
+ updates.push({
102
+ path: this.addPath(path),
103
+ createIfMissing: false,
104
+ updater: new java_update_1.JavaUpdate({
105
+ version,
106
+ versionsMap,
107
+ isSnapshot: options.isSnapshot,
108
+ }),
109
+ });
110
+ });
111
+ const dependenciesFiles = await dependenciesSearch;
112
+ dependenciesFiles.forEach(path => {
113
+ updates.push({
114
+ path: this.addPath(path),
115
+ createIfMissing: false,
116
+ updater: new java_update_1.JavaUpdate({
117
+ version,
118
+ versionsMap,
119
+ isSnapshot: options.isSnapshot,
120
+ }),
121
+ });
122
+ });
123
+ this.extraFiles.forEach(extraFile => {
124
+ if (typeof extraFile === 'object') {
125
+ return;
126
+ }
127
+ updates.push({
128
+ path: extraFile,
129
+ createIfMissing: false,
130
+ updater: new java_update_1.JavaUpdate({
131
+ version,
132
+ versionsMap,
133
+ isSnapshot: options.isSnapshot,
134
+ }),
135
+ });
136
+ });
137
+ if (!options.isSnapshot && !this.skipChangelog) {
138
+ updates.push({
139
+ path: this.addPath(this.changelogPath),
140
+ createIfMissing: true,
141
+ updater: new changelog_1.Changelog({
142
+ version,
143
+ changelogEntry: options.changelogEntry,
144
+ }),
145
+ });
146
+ }
147
+ return updates;
148
+ }
149
+ async updateVersionsMap(versionsMap, conventionalCommits) {
150
+ let isPromotion = false;
151
+ const modifiedCommits = [];
152
+ for (const commit of conventionalCommits) {
153
+ if (isPromotionCommit(commit)) {
154
+ isPromotion = true;
155
+ modifiedCommits.push({
156
+ ...commit,
157
+ notes: commit.notes.filter(note => !isPromotionNote(note)),
158
+ });
159
+ }
160
+ else {
161
+ modifiedCommits.push(commit);
162
+ }
163
+ }
164
+ for (const versionKey of versionsMap.keys()) {
165
+ const version = versionsMap.get(versionKey);
166
+ if (!version) {
167
+ this.logger.warn(`didn't find version for ${versionKey}`);
168
+ continue;
169
+ }
170
+ if (isPromotion && isStableArtifact(versionKey)) {
171
+ versionsMap.set(versionKey, version_1.Version.parse('1.0.0'));
172
+ }
173
+ else {
174
+ const newVersion = await this.versioningStrategy.bump(version, modifiedCommits);
175
+ versionsMap.set(versionKey, newVersion);
176
+ }
177
+ }
178
+ return versionsMap;
179
+ }
180
+ initialReleaseVersion() {
181
+ return version_1.Version.parse('0.1.0');
182
+ }
183
+ }
184
+ exports.JavaYoshi = JavaYoshi;
185
+ const VERSIONED_ARTIFACT_REGEX = /^.*-(v\d+[^-]*)$/;
186
+ const VERSION_REGEX = /^v\d+(.*)$/;
187
+ /**
188
+ * Returns true if the artifact should be considered stable
189
+ * @param artifact name of the artifact to check
190
+ */
191
+ function isStableArtifact(artifact) {
192
+ const match = artifact.match(VERSIONED_ARTIFACT_REGEX);
193
+ if (!match) {
194
+ // The artifact does not have a version qualifier at the end
195
+ return true;
196
+ }
197
+ const versionMatch = match[1].match(VERSION_REGEX);
198
+ if (versionMatch && versionMatch[1]) {
199
+ // The version is not stable (probably alpha/beta/rc)
200
+ return false;
201
+ }
202
+ return true;
203
+ }
204
+ function isPromotionCommit(commit) {
205
+ return commit.notes.some(isPromotionNote);
206
+ }
207
+ function isPromotionNote(note) {
208
+ return note.title === 'RELEASE AS' && note.text === '1.0.0';
209
+ }
210
+ //# sourceMappingURL=java-yoshi.js.map
@@ -0,0 +1,28 @@
1
+ import { Update } from '../update';
2
+ import { Version } from '../version';
3
+ import { BaseStrategy, BaseStrategyOptions, BuildUpdatesOptions } from './base';
4
+ import { ConventionalCommit } from '../commit';
5
+ import { Release } from '../release';
6
+ import { ReleasePullRequest } from '../release-pull-request';
7
+ import { VersioningStrategy } from '../versioning-strategy';
8
+ import { BumpReleaseOptions } from '../strategy';
9
+ export interface JavaBuildUpdatesOption extends BuildUpdatesOptions {
10
+ isSnapshot?: boolean;
11
+ }
12
+ /**
13
+ * A strategy that generates SNAPSHOT version after each release, which is standard especially in Maven projects.
14
+ *
15
+ * This is universal strategy that does not update any files on its own. Use maven strategy for Maven projects.
16
+ */
17
+ export declare class Java extends BaseStrategy {
18
+ protected readonly snapshotVersioning: VersioningStrategy;
19
+ protected readonly snapshotLabels: string[];
20
+ readonly skipSnapshot: boolean;
21
+ constructor(options: BaseStrategyOptions);
22
+ buildReleasePullRequest(commits: ConventionalCommit[], latestRelease?: Release, draft?: boolean, labels?: string[], _bumpOnlyOptions?: BumpReleaseOptions): Promise<ReleasePullRequest | undefined>;
23
+ protected buildSnapshotPullRequest(latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest>;
24
+ isPublishedVersion(version: Version): boolean;
25
+ protected canSkipSnapshot(): boolean;
26
+ protected needsSnapshot(commits: ConventionalCommit[], latestRelease?: Release): Promise<boolean>;
27
+ protected buildUpdates(options: JavaBuildUpdatesOption): Promise<Update[]>;
28
+ }
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ // Copyright 2022 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Java = void 0;
17
+ const base_1 = require("./base");
18
+ const changelog_1 = require("../updaters/changelog");
19
+ const java_snapshot_1 = require("../versioning-strategies/java-snapshot");
20
+ const pull_request_title_1 = require("../util/pull-request-title");
21
+ const branch_name_1 = require("../util/branch-name");
22
+ const pull_request_body_1 = require("../util/pull-request-body");
23
+ const default_1 = require("../versioning-strategies/default");
24
+ const java_add_snapshot_1 = require("../versioning-strategies/java-add-snapshot");
25
+ const manifest_1 = require("../manifest");
26
+ const java_released_1 = require("../updaters/java/java-released");
27
+ const composite_1 = require("../updaters/composite");
28
+ const logger_1 = require("../util/logger");
29
+ const CHANGELOG_SECTIONS = [
30
+ { type: 'feat', section: 'Features' },
31
+ { type: 'fix', section: 'Bug Fixes' },
32
+ { type: 'perf', section: 'Performance Improvements' },
33
+ { type: 'deps', section: 'Dependencies' },
34
+ { type: 'revert', section: 'Reverts' },
35
+ { type: 'docs', section: 'Documentation' },
36
+ { type: 'style', section: 'Styles', hidden: true },
37
+ { type: 'chore', section: 'Miscellaneous Chores', hidden: true },
38
+ { type: 'refactor', section: 'Code Refactoring', hidden: true },
39
+ { type: 'test', section: 'Tests', hidden: true },
40
+ { type: 'build', section: 'Build System', hidden: true },
41
+ { type: 'ci', section: 'Continuous Integration', hidden: true },
42
+ ];
43
+ /**
44
+ * A strategy that generates SNAPSHOT version after each release, which is standard especially in Maven projects.
45
+ *
46
+ * This is universal strategy that does not update any files on its own. Use maven strategy for Maven projects.
47
+ */
48
+ class Java extends base_1.BaseStrategy {
49
+ constructor(options) {
50
+ var _a, _b, _c;
51
+ options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS;
52
+ // wrap the configured versioning strategy with snapshotting
53
+ const parentVersioningStrategy = options.versioningStrategy ||
54
+ new default_1.DefaultVersioningStrategy({ logger: (_b = options.logger) !== null && _b !== void 0 ? _b : logger_1.logger });
55
+ options.versioningStrategy = new java_snapshot_1.JavaSnapshot(parentVersioningStrategy);
56
+ super(options);
57
+ this.snapshotVersioning = new java_add_snapshot_1.JavaAddSnapshot(parentVersioningStrategy);
58
+ this.snapshotLabels = options.snapshotLabels || manifest_1.DEFAULT_SNAPSHOT_LABELS;
59
+ this.skipSnapshot = (_c = options.skipSnapshot) !== null && _c !== void 0 ? _c : false;
60
+ }
61
+ async buildReleasePullRequest(commits, latestRelease, draft, labels = [], _bumpOnlyOptions) {
62
+ if (await this.needsSnapshot(commits, latestRelease)) {
63
+ this.logger.info('Repository needs a snapshot bump.');
64
+ return await this.buildSnapshotPullRequest(latestRelease, draft, this.snapshotLabels);
65
+ }
66
+ this.logger.info('No Java snapshot needed');
67
+ return await super.buildReleasePullRequest(commits, latestRelease, draft, labels);
68
+ }
69
+ async buildSnapshotPullRequest(latestRelease, draft, labels = []) {
70
+ const component = await this.getComponent();
71
+ const newVersion = latestRelease
72
+ ? await this.snapshotVersioning.bump(latestRelease.tag.version, [])
73
+ : this.initialReleaseVersion();
74
+ const versionsMap = await this.buildVersionsMap([]);
75
+ for (const [component, version] of versionsMap.entries()) {
76
+ versionsMap.set(component, await this.snapshotVersioning.bump(version, []));
77
+ }
78
+ const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion);
79
+ const branchName = component
80
+ ? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch)
81
+ : branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
82
+ const notes = '### Updating meta-information for bleeding-edge SNAPSHOT release.';
83
+ // TODO use pullrequest header here?
84
+ const pullRequestBody = new pull_request_body_1.PullRequestBody([
85
+ {
86
+ component,
87
+ version: newVersion,
88
+ notes,
89
+ },
90
+ ]);
91
+ const updates = await this.buildUpdates({
92
+ newVersion,
93
+ versionsMap,
94
+ skipChangelog: this.skipChangelog,
95
+ changelogEntry: notes,
96
+ isSnapshot: true,
97
+ commits: [],
98
+ });
99
+ const updatesWithExtras = (0, composite_1.mergeUpdates)(updates.concat(...(await this.extraFileUpdates(newVersion, versionsMap, this.dateFormat))));
100
+ return {
101
+ title: pullRequestTitle,
102
+ body: pullRequestBody,
103
+ updates: updatesWithExtras,
104
+ labels: [...labels, ...this.extraLabels],
105
+ headRefName: branchName.toString(),
106
+ version: newVersion,
107
+ draft: draft !== null && draft !== void 0 ? draft : false,
108
+ group: 'snapshot',
109
+ };
110
+ }
111
+ isPublishedVersion(version) {
112
+ return !version.preRelease || version.preRelease.indexOf('SNAPSHOT') < 0;
113
+ }
114
+ canSkipSnapshot() {
115
+ return this.skipSnapshot;
116
+ }
117
+ async needsSnapshot(commits, latestRelease) {
118
+ var _a;
119
+ if (this.canSkipSnapshot()) {
120
+ return false;
121
+ }
122
+ const component = await this.getComponent();
123
+ this.logger.debug('component:', component);
124
+ const version = (_a = latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag) === null || _a === void 0 ? void 0 : _a.version;
125
+ if (!version) {
126
+ // Don't bump snapshots for the first release ever
127
+ return false;
128
+ }
129
+ // Found snapshot as a release, this is unexpected, but use it
130
+ if (!this.isPublishedVersion(version)) {
131
+ return false;
132
+ }
133
+ // Search commits for snapshot bump
134
+ const pullRequests = commits
135
+ .map(commit => {
136
+ var _a;
137
+ return pull_request_title_1.PullRequestTitle.parse(((_a = commit.pullRequest) === null || _a === void 0 ? void 0 : _a.title) || commit.message, this.pullRequestTitlePattern, this.componentNoSpace, this.logger);
138
+ })
139
+ .filter(pullRequest => pullRequest);
140
+ const snapshotCommits = pullRequests
141
+ .filter(pullRequest => ((pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.component) || '') === component)
142
+ .map(pullRequest => pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.getVersion())
143
+ .filter(version => version && !this.isPublishedVersion(version));
144
+ return snapshotCommits.length === 0;
145
+ }
146
+ async buildUpdates(options) {
147
+ const version = options.newVersion;
148
+ const versionsMap = options.versionsMap;
149
+ const updates = [];
150
+ if (!options.isSnapshot) {
151
+ // Append java-specific updater for extraFiles
152
+ this.extraFiles.forEach(extraFile => {
153
+ if (typeof extraFile === 'string') {
154
+ updates.push({
155
+ path: this.addPath(extraFile),
156
+ createIfMissing: false,
157
+ updater: new java_released_1.JavaReleased({ version, versionsMap }),
158
+ });
159
+ }
160
+ });
161
+ // Update changelog
162
+ !this.skipChangelog &&
163
+ updates.push({
164
+ path: this.addPath(this.changelogPath),
165
+ createIfMissing: true,
166
+ updater: new changelog_1.Changelog({
167
+ version,
168
+ changelogEntry: options.changelogEntry,
169
+ }),
170
+ });
171
+ }
172
+ return updates;
173
+ }
174
+ }
175
+ exports.Java = Java;
176
+ //# sourceMappingURL=java.js.map
@@ -0,0 +1,7 @@
1
+ import { BaseStrategy, BuildUpdatesOptions } from './base';
2
+ import { Update } from '../update';
3
+ import { Version } from '../version';
4
+ export declare class KRMBlueprint extends BaseStrategy {
5
+ protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
6
+ protected initialReleaseVersion(): Version;
7
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ // Copyright 2021 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.KRMBlueprint = void 0;
17
+ // Generic
18
+ const changelog_1 = require("../updaters/changelog");
19
+ // KRM specific.
20
+ const krm_blueprint_version_1 = require("../updaters/krm/krm-blueprint-version");
21
+ const base_1 = require("./base");
22
+ const version_1 = require("../version");
23
+ const KRMBlueprintAttribAnnotation = 'cnrm.cloud.google.com/blueprint';
24
+ const hasKRMBlueprintAttrib = (content) => content.includes(KRMBlueprintAttribAnnotation);
25
+ class KRMBlueprint extends base_1.BaseStrategy {
26
+ async buildUpdates(options) {
27
+ const updates = [];
28
+ const version = options.newVersion;
29
+ !this.skipChangelog &&
30
+ updates.push({
31
+ path: this.addPath(this.changelogPath),
32
+ createIfMissing: true,
33
+ updater: new changelog_1.Changelog({
34
+ version,
35
+ changelogEntry: options.changelogEntry,
36
+ }),
37
+ });
38
+ const versionsMap = new Map();
39
+ if (options.latestVersion) {
40
+ versionsMap.set('previousVersion', options.latestVersion);
41
+ }
42
+ // Update version in all yaml files with attribution annotation
43
+ const yamlPaths = await this.github.findFilesByExtensionAndRef('yaml', this.targetBranch, this.path);
44
+ for (const yamlPath of yamlPaths) {
45
+ const contents = await this.github.getFileContents(this.addPath(yamlPath));
46
+ if (hasKRMBlueprintAttrib(contents.parsedContent)) {
47
+ updates.push({
48
+ path: this.addPath(yamlPath),
49
+ createIfMissing: false,
50
+ cachedFileContents: contents,
51
+ updater: new krm_blueprint_version_1.KRMBlueprintVersion({
52
+ version,
53
+ versionsMap,
54
+ }),
55
+ });
56
+ }
57
+ }
58
+ return updates;
59
+ }
60
+ initialReleaseVersion() {
61
+ return version_1.Version.parse('0.1.0');
62
+ }
63
+ }
64
+ exports.KRMBlueprint = KRMBlueprint;
65
+ //# sourceMappingURL=krm-blueprint.js.map
@@ -0,0 +1,9 @@
1
+ import { Java, JavaBuildUpdatesOption } from './java';
2
+ import { Update } from '../update';
3
+ /**
4
+ * Strategy for Maven projects. It generates SNAPSHOT version after each release, and updates all found
5
+ * pom.xml files automatically.
6
+ */
7
+ export declare class Maven extends Java {
8
+ protected buildUpdates(options: JavaBuildUpdatesOption): Promise<Update[]>;
9
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ // Copyright 2022 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Maven = void 0;
17
+ const java_1 = require("./java");
18
+ const java_released_1 = require("../updaters/java/java-released");
19
+ const generic_1 = require("../updaters/generic");
20
+ const pom_xml_1 = require("../updaters/java/pom-xml");
21
+ /**
22
+ * Strategy for Maven projects. It generates SNAPSHOT version after each release, and updates all found
23
+ * pom.xml files automatically.
24
+ */
25
+ class Maven extends java_1.Java {
26
+ async buildUpdates(options) {
27
+ const version = options.newVersion;
28
+ const versionsMap = options.versionsMap;
29
+ // Use generic Java updates
30
+ const updates = await super.buildUpdates(options);
31
+ // Update pom.xml files
32
+ const pomFiles = await this.github.findFilesByFilenameAndRef('pom.xml', this.targetBranch, this.path);
33
+ pomFiles.forEach(path => {
34
+ updates.push({
35
+ path: this.addPath(path),
36
+ createIfMissing: false,
37
+ updater: new pom_xml_1.PomXml(version),
38
+ });
39
+ if (!options.isSnapshot) {
40
+ updates.push({
41
+ path: this.addPath(path),
42
+ createIfMissing: false,
43
+ updater: new java_released_1.JavaReleased({ version, versionsMap }),
44
+ });
45
+ }
46
+ updates.push({
47
+ path: this.addPath(path),
48
+ createIfMissing: false,
49
+ updater: new generic_1.Generic({ version, versionsMap }),
50
+ });
51
+ });
52
+ return updates;
53
+ }
54
+ }
55
+ exports.Maven = Maven;
56
+ //# sourceMappingURL=maven.js.map
@@ -0,0 +1,10 @@
1
+ import { BaseStrategy, BuildUpdatesOptions } from './base';
2
+ import { Update } from '../update';
3
+ import { GitHubFileContents } from '@google-automations/git-file-utils';
4
+ export declare class NodeLibrarian extends BaseStrategy {
5
+ private pkgJsonContents?;
6
+ protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
7
+ getDefaultPackageName(): Promise<string | undefined>;
8
+ protected normalizeComponent(component: string | undefined): string;
9
+ protected getPkgJsonContents(): Promise<GitHubFileContents>;
10
+ }