@release-please-oss/release-please 0.0.0 → 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 +280 -0
  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 +113 -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,422 @@
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.parseConventionalCommits = void 0;
17
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
18
+ const visit = require('unist-util-visit');
19
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
20
+ const visitWithAncestors = require('unist-util-visit-parents');
21
+ const NUMBER_REGEX = /^[0-9]+$/;
22
+ const logger_1 = require("./util/logger");
23
+ const parser = require("@conventional-commits/parser");
24
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
25
+ const conventionalCommitsFilter = require('conventional-commits-filter');
26
+ function getBlankConventionalCommit() {
27
+ return {
28
+ body: '',
29
+ subject: '',
30
+ type: '',
31
+ scope: null,
32
+ notes: [],
33
+ references: [],
34
+ mentions: [],
35
+ merge: null,
36
+ revert: null,
37
+ header: '',
38
+ footer: null,
39
+ };
40
+ }
41
+ // Converts conventional commit AST into conventional-changelog's
42
+ // output format, see: https://www.npmjs.com/package/conventional-commits-parser
43
+ function toConventionalChangelogFormat(ast) {
44
+ const commits = [];
45
+ const headerCommit = getBlankConventionalCommit();
46
+ // Separate the body and summary nodes, this simplifies the subsequent
47
+ // tree walking logic:
48
+ let body;
49
+ let summary;
50
+ visit(ast, ['body', 'summary'], (node) => {
51
+ switch (node.type) {
52
+ case 'body':
53
+ body = node;
54
+ break;
55
+ case 'summary':
56
+ summary = node;
57
+ break;
58
+ }
59
+ });
60
+ // <type>, "(", <scope>, ")", ["!"], ":", <whitespace>*, <text>
61
+ visit(summary, (node) => {
62
+ switch (node.type) {
63
+ case 'type':
64
+ headerCommit.type = node.value;
65
+ headerCommit.header += node.value;
66
+ break;
67
+ case 'scope':
68
+ headerCommit.scope = node.value;
69
+ headerCommit.header += `(${node.value})`;
70
+ break;
71
+ case 'breaking-change':
72
+ headerCommit.header += '!';
73
+ break;
74
+ case 'text':
75
+ headerCommit.subject = node.value;
76
+ headerCommit.header += `: ${node.value}`;
77
+ break;
78
+ default:
79
+ break;
80
+ }
81
+ });
82
+ // [<any body-text except pre-footer>]
83
+ if (body) {
84
+ visit(body, ['text', 'newline'], (node) => {
85
+ headerCommit.body += node.value;
86
+ });
87
+ }
88
+ // Extract BREAKING CHANGE notes, regardless of whether they fall in
89
+ // summary, body, or footer:
90
+ const breaking = {
91
+ title: 'BREAKING CHANGE',
92
+ text: '', // "text" will be populated if a BREAKING CHANGE token is parsed.
93
+ };
94
+ visitWithAncestors(ast, ['breaking-change'], (node, ancestors) => {
95
+ let hitBreakingMarker = false;
96
+ let parent = ancestors.pop();
97
+ if (!parent) {
98
+ return;
99
+ }
100
+ switch (parent.type) {
101
+ case 'summary':
102
+ breaking.text = headerCommit.subject;
103
+ break;
104
+ case 'body':
105
+ breaking.text = '';
106
+ // We treat text from the BREAKING CHANGE marker forward as
107
+ // the breaking change notes:
108
+ visit(parent, ['breaking-change', 'text', 'newline'], (node) => {
109
+ if (node.type === 'breaking-change') {
110
+ hitBreakingMarker = true;
111
+ return;
112
+ }
113
+ if (!hitBreakingMarker)
114
+ return;
115
+ breaking.text += node.value;
116
+ });
117
+ break;
118
+ case 'token':
119
+ // If the '!' breaking change marker is used, the breaking change
120
+ // will be identified when the footer is parsed as a commit:
121
+ if (!node.value.includes('BREAKING'))
122
+ return;
123
+ parent = ancestors.pop();
124
+ visit(parent, ['text', 'newline'], (node) => {
125
+ breaking.text = node.value;
126
+ });
127
+ break;
128
+ }
129
+ });
130
+ // Add additional breaking change detection from commit body
131
+ if (body) {
132
+ const bodyString = String(body);
133
+ const breakingChangeMatch = bodyString.match(/BREAKING-CHANGE:\s*(.*)/);
134
+ if (breakingChangeMatch && breakingChangeMatch[1]) {
135
+ if (breaking.text) {
136
+ breaking.text += '\n';
137
+ }
138
+ breaking.text += breakingChangeMatch[1].trim();
139
+ }
140
+ }
141
+ if (breaking.text !== '')
142
+ headerCommit.notes.push(breaking);
143
+ // Populates references array from footers:
144
+ // references: [{
145
+ // action: 'Closes',
146
+ // owner: null,
147
+ // repository: null,
148
+ // issue: '1', raw: '#1',
149
+ // prefix: '#'
150
+ // }]
151
+ visit(ast, ['footer'], (node) => {
152
+ const reference = {
153
+ prefix: '#',
154
+ action: '',
155
+ issue: '',
156
+ };
157
+ let hasRefSepartor = false;
158
+ visit(node, ['type', 'separator', 'text'], (node) => {
159
+ switch (node.type) {
160
+ case 'type':
161
+ // refs, closes, etc:
162
+ // TODO(@bcoe): conventional-changelog does not currently use
163
+ // "reference.action" in its templates:
164
+ reference.action = node.value;
165
+ break;
166
+ case 'separator':
167
+ // Footer of the form "Refs #99":
168
+ if (node.value.includes('#'))
169
+ hasRefSepartor = true;
170
+ break;
171
+ case 'text':
172
+ // Footer of the form "Refs: #99"
173
+ if (node.value.charAt(0) === '#') {
174
+ hasRefSepartor = true;
175
+ reference.issue = node.value.substring(1);
176
+ // TODO(@bcoe): what about references like "Refs: #99, #102"?
177
+ }
178
+ else {
179
+ reference.issue = node.value;
180
+ }
181
+ break;
182
+ }
183
+ });
184
+ // TODO(@bcoe): how should references like "Refs: v8:8940" work.
185
+ if (hasRefSepartor && reference.issue.match(NUMBER_REGEX)) {
186
+ headerCommit.references.push(reference);
187
+ }
188
+ });
189
+ /*
190
+ * Split footers that resemble commits into additional commits, e.g.,
191
+ * chore: multiple commits
192
+ * chore(recaptchaenterprise): migrate recaptchaenterprise to the Java microgenerator
193
+ * Committer: @miraleung
194
+ * PiperOrigin-RevId: 345559154
195
+ * ...
196
+ */
197
+ visitWithAncestors(ast, ['type'], (node, ancestors) => {
198
+ let parent = ancestors.pop();
199
+ if (!parent) {
200
+ return;
201
+ }
202
+ if (parent.type === 'token') {
203
+ parent = ancestors.pop();
204
+ let footerText = '';
205
+ const semanticFooter = node.value.toLowerCase() === 'release-as';
206
+ visit(parent, ['type', 'scope', 'breaking-change', 'separator', 'text', 'newline'], (node) => {
207
+ switch (node.type) {
208
+ case 'scope':
209
+ footerText += `(${node.value})`;
210
+ break;
211
+ case 'separator':
212
+ // Footers of the form Fixes #99, should not be parsed.
213
+ if (node.value.includes('#'))
214
+ return;
215
+ footerText += `${node.value} `;
216
+ break;
217
+ default:
218
+ footerText += node.value;
219
+ break;
220
+ }
221
+ });
222
+ // Any footers that carry semantic meaning, e.g., Release-As, should
223
+ // be added to the footer field, for the benefits of post-processing:
224
+ if (semanticFooter) {
225
+ let releaseAs = '';
226
+ visit(parent, ['text'], (node) => {
227
+ releaseAs = node.value;
228
+ });
229
+ // record Release-As footer as a note
230
+ headerCommit.notes.push({
231
+ title: 'RELEASE AS',
232
+ text: releaseAs,
233
+ });
234
+ if (!headerCommit.footer)
235
+ headerCommit.footer = '';
236
+ headerCommit.footer += `\n${footerText.toLowerCase()}`.trimStart();
237
+ }
238
+ try {
239
+ for (const commit of toConventionalChangelogFormat(parser.parser(footerText))) {
240
+ commits.push(commit);
241
+ }
242
+ }
243
+ catch (err) {
244
+ // Footer does not appear to be an additional commit.
245
+ }
246
+ }
247
+ });
248
+ commits.push(headerCommit);
249
+ return commits;
250
+ }
251
+ // TODO(@bcoe): now that we walk the actual AST of conventional commits
252
+ // we should be able to move post processing into
253
+ // to-conventional-changelog.ts.
254
+ function postProcessCommits(commit) {
255
+ var _a;
256
+ commit.notes.forEach(note => {
257
+ let text = '';
258
+ let i = 0;
259
+ let extendedContext = false;
260
+ for (const chunk of note.text.split(/\r?\n/)) {
261
+ if (i > 0 && hasExtendedContext(chunk) && !extendedContext) {
262
+ text = `${text.trim()}\n`;
263
+ extendedContext = true;
264
+ }
265
+ if (chunk === '')
266
+ break;
267
+ else if (extendedContext) {
268
+ text += ` ${chunk}\n`;
269
+ }
270
+ else {
271
+ text += `${chunk} `;
272
+ }
273
+ i++;
274
+ }
275
+ note.text = text.trim();
276
+ });
277
+ const breakingChangeMatch = (_a = commit.body) === null || _a === void 0 ? void 0 : _a.match(/BREAKING-CHANGE:\s*(.*)/);
278
+ if (breakingChangeMatch && breakingChangeMatch[1]) {
279
+ const existingNote = commit.notes.find(note => note.title === 'BREAKING CHANGE');
280
+ if (existingNote) {
281
+ existingNote.text += `\n${breakingChangeMatch[1].trim()}`;
282
+ }
283
+ else {
284
+ commit.notes.push({
285
+ title: 'BREAKING CHANGE',
286
+ text: breakingChangeMatch[1].trim(),
287
+ });
288
+ }
289
+ }
290
+ return commit;
291
+ }
292
+ // If someone wishes to include additional contextual information for a
293
+ // BREAKING CHANGE using markdown, they can do so by starting the line after the initial
294
+ // breaking change description with either:
295
+ //
296
+ // 1. a fourth-level header.
297
+ // 2. a bulleted list (using either '*' or '-').
298
+ //
299
+ // BREAKING CHANGE: there were breaking changes
300
+ // #### Deleted Endpoints
301
+ // - endpoint 1
302
+ // - endpoint 2
303
+ function hasExtendedContext(line) {
304
+ if (line.match(/^#### |^[*-] /))
305
+ return true;
306
+ return false;
307
+ }
308
+ function parseCommits(message) {
309
+ let ast;
310
+ try {
311
+ ast = parser.parser(message);
312
+ }
313
+ catch (err) {
314
+ const sanitizedMessage = sanitizeBodyScopes(message);
315
+ if (sanitizedMessage === message) {
316
+ throw err;
317
+ }
318
+ ast = parser.parser(sanitizedMessage);
319
+ }
320
+ return conventionalCommitsFilter(toConventionalChangelogFormat(ast)).map(postProcessCommits);
321
+ }
322
+ const UNTERMINATED_SCOPE_LINE_REGEX = /^[^\s:!()]+\([^()\r\n]*(?:\(|\r?$)/;
323
+ /**
324
+ * `@conventional-commits/parser` attempts to parse the start of every body line
325
+ * as a Conventional Commit footer (`<type>(<scope>): <value>`). If a body line
326
+ * starts at column 0 with `token(` and encounters another `(` or end-of-line
327
+ * before a closing `)` (such as nested parentheses `Foo.Bar(baz(abc))` or a
328
+ * function call wrapped across lines), the parser's `scope()` rule throws an
329
+ * uncaught `Error: unexpected token ... valid tokens [)]`.
330
+ *
331
+ * Since a valid Conventional Commit `<scope>` can never contain `(` or span
332
+ * lines, prefixing a single space to matching body lines prevents `scope()`
333
+ * from throwing while preserving all valid footers (`BREAKING CHANGE`,
334
+ * `Release-As`, issue references, and footer commits).
335
+ */
336
+ function sanitizeBodyScopes(message) {
337
+ const lines = message.split('\n');
338
+ for (let i = 1; i < lines.length; i++) {
339
+ if (UNTERMINATED_SCOPE_LINE_REGEX.test(lines[i])) {
340
+ lines[i] = ` ${lines[i]}`;
341
+ }
342
+ }
343
+ return lines.join('\n');
344
+ }
345
+ /**
346
+ * Splits a commit message into multiple messages based on conventional commit format and nested commit blocks.
347
+ * This function is capable of:
348
+ * 1. Separating conventional commits (feat, fix, docs, etc.) within the main message.
349
+ * 2. Extracting nested commits enclosed in BEGIN_NESTED_COMMIT/END_NESTED_COMMIT blocks.
350
+ * 3. Preserving the original message structure outside of nested commit blocks.
351
+ * 4. Handling multiple nested commits and conventional commits in a single message.
352
+ *
353
+ * @param message The input commit message string
354
+ * @returns An array of individual commit messages
355
+ */
356
+ function splitMessages(message) {
357
+ const parts = message.split('BEGIN_NESTED_COMMIT');
358
+ const messages = [parts.shift()];
359
+ for (const part of parts) {
360
+ const [newMessage, ...rest] = part.split('END_NESTED_COMMIT');
361
+ messages.push(newMessage);
362
+ messages[0] = messages[0] + rest.join('END_NESTED_COMMIT');
363
+ }
364
+ const conventionalCommits = messages[0]
365
+ .split(/\r?\n\r?\n(?=(?:feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.*?\))?: )/)
366
+ .filter(Boolean);
367
+ return [...conventionalCommits, ...messages.slice(1)];
368
+ }
369
+ /**
370
+ * Given a list of raw commits, parse and expand into conventional commits.
371
+ *
372
+ * @param commits {Commit[]} The input commits
373
+ *
374
+ * @returns {ConventionalCommit[]} Parsed and expanded commits. There may be
375
+ * more commits returned as a single raw commit may contain multiple release
376
+ * messages.
377
+ */
378
+ function parseConventionalCommits(commits, logger = logger_1.logger) {
379
+ const conventionalCommits = [];
380
+ for (const commit of commits) {
381
+ for (const commitMessage of splitMessages(preprocessCommitMessage(commit))) {
382
+ try {
383
+ for (const parsedCommit of parseCommits(commitMessage)) {
384
+ const breaking = parsedCommit.notes.filter(note => note.title === 'BREAKING CHANGE')
385
+ .length > 0;
386
+ conventionalCommits.push({
387
+ sha: commit.sha,
388
+ message: parsedCommit.header,
389
+ files: commit.files,
390
+ pullRequest: commit.pullRequest,
391
+ type: parsedCommit.type,
392
+ scope: parsedCommit.scope,
393
+ bareMessage: parsedCommit.subject,
394
+ notes: parsedCommit.notes,
395
+ references: parsedCommit.references,
396
+ breaking,
397
+ author: commit.author,
398
+ });
399
+ }
400
+ }
401
+ catch (_err) {
402
+ logger.debug(`commit could not be parsed: ${commit.sha} ${commit.message.split('\n')[0]}`);
403
+ logger.debug(`error message: ${_err}`);
404
+ }
405
+ }
406
+ }
407
+ return conventionalCommits;
408
+ }
409
+ exports.parseConventionalCommits = parseConventionalCommits;
410
+ function preprocessCommitMessage(commit) {
411
+ // look for 'BEGIN_COMMIT_OVERRIDE' section of pull request body
412
+ if (commit.pullRequest) {
413
+ const overrideMessage = (commit.pullRequest.body.split('BEGIN_COMMIT_OVERRIDE')[1] || '')
414
+ .split('END_COMMIT_OVERRIDE')[0]
415
+ .trim();
416
+ if (overrideMessage) {
417
+ return overrideMessage;
418
+ }
419
+ }
420
+ return commit.message;
421
+ }
422
+ //# sourceMappingURL=commit.js.map
@@ -0,0 +1,36 @@
1
+ import { RequestError } from '@octokit/request-error';
2
+ import { RequestError as RequestErrorBody } from '@octokit/types';
3
+ interface SingleError {
4
+ resource: string;
5
+ code: string;
6
+ field: string;
7
+ }
8
+ export declare class ConfigurationError extends Error {
9
+ releaserName: string;
10
+ repository: string;
11
+ constructor(message: string, releaserName: string, repository: string);
12
+ }
13
+ export declare class MissingRequiredFileError extends ConfigurationError {
14
+ file: string;
15
+ constructor(file: string, releaserName: string, repository: string);
16
+ }
17
+ export declare class GitHubAPIError extends Error {
18
+ body: RequestErrorBody | undefined;
19
+ status: number;
20
+ cause?: Error;
21
+ constructor(requestError: RequestError, message?: string);
22
+ static parseErrorBody(requestError: RequestError): RequestErrorBody | undefined;
23
+ static parseErrors(requestError: RequestError): SingleError[];
24
+ }
25
+ export declare class AuthError extends GitHubAPIError {
26
+ constructor(requestError: RequestError);
27
+ }
28
+ export declare class DuplicateReleaseError extends GitHubAPIError {
29
+ tag: string;
30
+ constructor(requestError: RequestError, tag: string);
31
+ }
32
+ export declare class FileNotFoundError extends Error {
33
+ path: string;
34
+ constructor(path: string);
35
+ }
36
+ export {};
@@ -0,0 +1,77 @@
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.FileNotFoundError = exports.DuplicateReleaseError = exports.AuthError = exports.GitHubAPIError = exports.MissingRequiredFileError = exports.ConfigurationError = void 0;
17
+ class ConfigurationError extends Error {
18
+ constructor(message, releaserName, repository) {
19
+ super(`${releaserName} (${repository}): ${message}`);
20
+ this.releaserName = releaserName;
21
+ this.repository = repository;
22
+ this.name = ConfigurationError.name;
23
+ }
24
+ }
25
+ exports.ConfigurationError = ConfigurationError;
26
+ class MissingRequiredFileError extends ConfigurationError {
27
+ constructor(file, releaserName, repository) {
28
+ super(`Missing required file: ${file}`, releaserName, repository);
29
+ this.file = file;
30
+ this.name = MissingRequiredFileError.name;
31
+ }
32
+ }
33
+ exports.MissingRequiredFileError = MissingRequiredFileError;
34
+ class GitHubAPIError extends Error {
35
+ constructor(requestError, message) {
36
+ super(message !== null && message !== void 0 ? message : requestError.message);
37
+ this.status = requestError.status;
38
+ this.body = GitHubAPIError.parseErrorBody(requestError);
39
+ this.name = GitHubAPIError.name;
40
+ this.cause = requestError;
41
+ this.stack = requestError.stack;
42
+ }
43
+ static parseErrorBody(requestError) {
44
+ const body = requestError.response;
45
+ return (body === null || body === void 0 ? void 0 : body.data) || undefined;
46
+ }
47
+ static parseErrors(requestError) {
48
+ var _a;
49
+ return ((_a = GitHubAPIError.parseErrorBody(requestError)) === null || _a === void 0 ? void 0 : _a.errors) || [];
50
+ }
51
+ }
52
+ exports.GitHubAPIError = GitHubAPIError;
53
+ class AuthError extends GitHubAPIError {
54
+ constructor(requestError) {
55
+ super(requestError, 'unauthorized');
56
+ this.status = 401;
57
+ this.name = AuthError.name;
58
+ }
59
+ }
60
+ exports.AuthError = AuthError;
61
+ class DuplicateReleaseError extends GitHubAPIError {
62
+ constructor(requestError, tag) {
63
+ super(requestError);
64
+ this.tag = tag;
65
+ this.name = DuplicateReleaseError.name;
66
+ }
67
+ }
68
+ exports.DuplicateReleaseError = DuplicateReleaseError;
69
+ class FileNotFoundError extends Error {
70
+ constructor(path) {
71
+ super(`Failed to find file: ${path}`);
72
+ this.path = path;
73
+ this.name = FileNotFoundError.name;
74
+ }
75
+ }
76
+ exports.FileNotFoundError = FileNotFoundError;
77
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,16 @@
1
+ import { Scm } from '../scm';
2
+ import { ChangelogNotes, ChangelogSection } from '../changelog-notes';
3
+ export type ChangelogNotesType = string;
4
+ export interface ChangelogNotesFactoryOptions {
5
+ type: ChangelogNotesType;
6
+ github: Scm;
7
+ changelogSections?: ChangelogSection[];
8
+ commitPartial?: string;
9
+ headerPartial?: string;
10
+ mainTemplate?: string;
11
+ }
12
+ export type ChangelogNotesBuilder = (options: ChangelogNotesFactoryOptions) => ChangelogNotes;
13
+ export declare function buildChangelogNotes(options: ChangelogNotesFactoryOptions): ChangelogNotes;
14
+ export declare function registerChangelogNotes(name: string, changelogNotesBuilder: ChangelogNotesBuilder): void;
15
+ export declare function unregisterChangelogNotes(name: string): void;
16
+ export declare function getChangelogTypes(): readonly ChangelogNotesType[];
@@ -0,0 +1,44 @@
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.getChangelogTypes = exports.unregisterChangelogNotes = exports.registerChangelogNotes = exports.buildChangelogNotes = void 0;
17
+ const github_1 = require("../changelog-notes/github");
18
+ const default_1 = require("../changelog-notes/default");
19
+ const errors_1 = require("../errors");
20
+ const changelogNotesFactories = {
21
+ github: options => new github_1.GitHubChangelogNotes(options.github),
22
+ default: options => new default_1.DefaultChangelogNotes(options),
23
+ };
24
+ function buildChangelogNotes(options) {
25
+ const builder = changelogNotesFactories[options.type];
26
+ if (builder) {
27
+ return builder(options);
28
+ }
29
+ throw new errors_1.ConfigurationError(`Unknown changelog type: ${options.type}`, 'core', `${options.github.repository.owner}/${options.github.repository.repo}`);
30
+ }
31
+ exports.buildChangelogNotes = buildChangelogNotes;
32
+ function registerChangelogNotes(name, changelogNotesBuilder) {
33
+ changelogNotesFactories[name] = changelogNotesBuilder;
34
+ }
35
+ exports.registerChangelogNotes = registerChangelogNotes;
36
+ function unregisterChangelogNotes(name) {
37
+ delete changelogNotesFactories[name];
38
+ }
39
+ exports.unregisterChangelogNotes = unregisterChangelogNotes;
40
+ function getChangelogTypes() {
41
+ return Object.keys(changelogNotesFactories).sort();
42
+ }
43
+ exports.getChangelogTypes = getChangelogTypes;
44
+ //# sourceMappingURL=changelog-notes-factory.js.map
@@ -0,0 +1,23 @@
1
+ import { PluginType, RepositoryConfig } from '../manifest';
2
+ import { Scm } from '../scm';
3
+ import { ManifestPlugin } from '../plugin';
4
+ import { VersioningStrategyType } from './versioning-strategy-factory';
5
+ import { Logger } from '../util/logger';
6
+ export interface PluginFactoryOptions {
7
+ type: PluginType;
8
+ github: Scm;
9
+ targetBranch: string;
10
+ repositoryConfig: RepositoryConfig;
11
+ manifestPath: string;
12
+ separatePullRequests?: boolean;
13
+ alwaysLinkLocal?: boolean;
14
+ updatePeerDependencies?: boolean;
15
+ updateAllPackages?: boolean;
16
+ considerAllArtifacts?: boolean;
17
+ logger?: Logger;
18
+ }
19
+ export type PluginBuilder = (options: PluginFactoryOptions) => ManifestPlugin;
20
+ export declare function buildPlugin(options: PluginFactoryOptions): ManifestPlugin;
21
+ export declare function registerPlugin(name: string, pluginBuilder: PluginBuilder): void;
22
+ export declare function unregisterPlugin(name: string): void;
23
+ export declare function getPluginTypes(): readonly VersioningStrategyType[];