release-please 12.3.0 → 13.0.0-candidate.0

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 (244) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +5 -0
  3. package/build/src/bin/release-please.d.ts +51 -11
  4. package/build/src/bin/release-please.js +409 -150
  5. package/build/src/bootstrapper.d.ts +12 -0
  6. package/build/src/bootstrapper.js +60 -0
  7. package/build/src/commit.d.ts +26 -0
  8. package/build/src/{util/to-conventional-changelog-format.js → commit.js} +97 -2
  9. package/build/src/errors/index.d.ts +0 -5
  10. package/build/src/errors/index.js +1 -10
  11. package/build/src/factory.d.ts +25 -37
  12. package/build/src/factory.js +159 -150
  13. package/build/src/github.d.ts +151 -883
  14. package/build/src/github.js +584 -1013
  15. package/build/src/manifest.d.ts +177 -48
  16. package/build/src/manifest.js +583 -487
  17. package/build/src/plugin.d.ts +20 -0
  18. package/build/src/{plugins/plugin.js → plugin.js} +10 -9
  19. package/build/src/plugins/cargo-workspace.d.ts +48 -18
  20. package/build/src/plugins/cargo-workspace.js +247 -328
  21. package/build/src/plugins/merge.d.ts +11 -0
  22. package/build/src/plugins/merge.js +83 -0
  23. package/build/src/plugins/node-workspace.d.ts +35 -17
  24. package/build/src/plugins/node-workspace.js +234 -271
  25. package/build/src/plugins/workspace.d.ts +102 -0
  26. package/build/src/plugins/workspace.js +170 -0
  27. package/build/src/pull-request.d.ts +10 -0
  28. package/build/src/{updaters/java/readme.js → pull-request.js} +2 -7
  29. package/build/src/release-notes.d.ts +29 -0
  30. package/build/src/release-notes.js +71 -0
  31. package/build/src/release-pull-request.d.ts +13 -0
  32. package/build/src/{updaters/java/pom-xml.js → release-pull-request.js} +2 -7
  33. package/build/src/release.d.ts +6 -0
  34. package/build/src/release.js +16 -0
  35. package/build/src/repository.d.ts +5 -0
  36. package/build/src/repository.js +16 -0
  37. package/build/src/strategies/dart.d.ts +8 -0
  38. package/build/src/strategies/dart.js +63 -0
  39. package/build/src/strategies/elixir.d.ts +5 -0
  40. package/build/src/{releasers → strategies}/elixir.js +18 -14
  41. package/build/src/strategies/go-yoshi.d.ts +13 -0
  42. package/build/src/strategies/go-yoshi.js +106 -0
  43. package/build/src/strategies/go.d.ts +5 -0
  44. package/build/src/{releasers → strategies}/go.js +11 -12
  45. package/build/src/strategies/helm.d.ts +8 -0
  46. package/build/src/strategies/helm.js +63 -0
  47. package/build/src/strategies/java-yoshi.d.ts +24 -0
  48. package/build/src/strategies/java-yoshi.js +203 -0
  49. package/build/src/strategies/krm-blueprint.d.ts +7 -0
  50. package/build/src/{releasers → strategies}/krm-blueprint.js +26 -22
  51. package/build/src/strategies/node.d.ts +9 -0
  52. package/build/src/strategies/node.js +82 -0
  53. package/build/src/strategies/ocaml.d.ts +5 -0
  54. package/build/src/{releasers → strategies}/ocaml.js +34 -28
  55. package/build/src/strategies/php-yoshi.d.ts +9 -0
  56. package/build/src/strategies/php-yoshi.js +214 -0
  57. package/build/src/strategies/php.d.ts +6 -0
  58. package/build/src/{releasers → strategies}/php.js +24 -23
  59. package/build/src/strategies/python.d.ts +8 -0
  60. package/build/src/strategies/python.js +117 -0
  61. package/build/src/strategies/ruby-yoshi.d.ts +17 -0
  62. package/build/src/strategies/ruby-yoshi.js +116 -0
  63. package/build/src/strategies/ruby.d.ts +13 -0
  64. package/build/src/{releasers → strategies}/ruby.js +26 -27
  65. package/build/src/strategies/rust.d.ts +20 -0
  66. package/build/src/strategies/rust.js +120 -0
  67. package/build/src/strategies/simple.d.ts +5 -0
  68. package/build/src/{releasers → strategies}/simple.js +18 -14
  69. package/build/src/strategies/terraform-module.d.ts +7 -0
  70. package/build/src/{releasers → strategies}/terraform-module.js +29 -23
  71. package/build/src/strategy.d.ts +99 -0
  72. package/build/src/strategy.js +237 -0
  73. package/build/src/update.d.ts +23 -0
  74. package/build/src/{updaters/update.js → update.js} +1 -1
  75. package/build/src/updaters/changelog.d.ts +7 -10
  76. package/build/src/updaters/changelog.js +3 -9
  77. package/build/src/updaters/changelog.js.map +1 -1
  78. package/build/src/updaters/composite.d.ts +19 -0
  79. package/build/src/updaters/composite.js +42 -0
  80. package/build/src/updaters/dart/pubspec-yaml.d.ts +12 -0
  81. package/build/src/updaters/dart/pubspec-yaml.js +45 -0
  82. package/build/src/updaters/default.d.ts +21 -0
  83. package/build/src/updaters/{version-txt.js → default.js} +16 -10
  84. package/build/src/updaters/dotnet/csproj.d.ts +12 -0
  85. package/build/src/updaters/{java/google-utils.js → dotnet/csproj.js} +16 -13
  86. package/build/src/updaters/elixir/elixir-mix-exs.d.ts +12 -0
  87. package/build/src/updaters/{elixir-mix-exs.js → elixir/elixir-mix-exs.js} +12 -10
  88. package/build/src/updaters/helm/chart-yaml.d.ts +10 -11
  89. package/build/src/updaters/helm/chart-yaml.js +12 -10
  90. package/build/src/updaters/java/java-update.d.ts +14 -0
  91. package/build/src/updaters/java/{java_update.js → java-update.js} +22 -22
  92. package/build/src/updaters/java/versions-manifest.d.ts +12 -2
  93. package/build/src/updaters/java/versions-manifest.js +20 -4
  94. package/build/src/updaters/krm/krm-blueprint-version.d.ts +10 -11
  95. package/build/src/updaters/krm/krm-blueprint-version.js +13 -12
  96. package/build/src/updaters/node/package-json.d.ts +12 -0
  97. package/build/src/updaters/{package-json.js → node/package-json.js} +14 -16
  98. package/build/src/updaters/node/package-lock-json.d.ts +8 -0
  99. package/build/src/updaters/node/package-lock-json.js +36 -0
  100. package/build/src/updaters/node/samples-package-json.d.ts +23 -0
  101. package/build/src/updaters/{samples-package-json.js → node/samples-package-json.js} +19 -8
  102. package/build/src/updaters/ocaml/dune-project.d.ts +10 -11
  103. package/build/src/updaters/ocaml/dune-project.js +11 -9
  104. package/build/src/updaters/ocaml/esy-json.d.ts +10 -11
  105. package/build/src/updaters/ocaml/esy-json.js +12 -10
  106. package/build/src/updaters/ocaml/opam.d.ts +10 -11
  107. package/build/src/updaters/ocaml/opam.js +11 -9
  108. package/build/src/updaters/php/php-client-version.d.ts +12 -0
  109. package/build/src/updaters/{php-client-version.js → php/php-client-version.js} +10 -9
  110. package/build/src/updaters/php/php-manifest.d.ts +13 -0
  111. package/build/src/updaters/{php-manifest.js → php/php-manifest.js} +17 -15
  112. package/build/src/updaters/php/root-composer-update-packages.d.ts +12 -0
  113. package/build/src/updaters/{root-composer-update-packages.js → php/root-composer-update-packages.js} +17 -16
  114. package/build/src/updaters/python/pyproject-toml.d.ts +10 -11
  115. package/build/src/updaters/python/pyproject-toml.js +13 -11
  116. package/build/src/updaters/python/python-file-with-version.d.ts +7 -11
  117. package/build/src/updaters/python/python-file-with-version.js +7 -8
  118. package/build/src/updaters/python/setup-cfg.d.ts +10 -11
  119. package/build/src/updaters/python/setup-cfg.js +10 -8
  120. package/build/src/updaters/python/setup-py.d.ts +10 -11
  121. package/build/src/updaters/python/setup-py.js +10 -8
  122. package/build/src/updaters/raw-content.d.ts +19 -0
  123. package/build/src/{plugins/index.js → updaters/raw-content.js} +23 -12
  124. package/build/src/updaters/release-please-config.d.ts +8 -0
  125. package/build/src/updaters/release-please-config.js +41 -0
  126. package/build/src/updaters/release-please-manifest.d.ts +2 -11
  127. package/build/src/updaters/release-please-manifest.js +11 -14
  128. package/build/src/updaters/ruby/version-rb.d.ts +12 -0
  129. package/build/src/updaters/{version-rb.js → ruby/version-rb.js} +10 -8
  130. package/build/src/updaters/rust/cargo-lock.d.ts +7 -11
  131. package/build/src/updaters/rust/cargo-lock.js +14 -16
  132. package/build/src/updaters/rust/cargo-toml.d.ts +7 -11
  133. package/build/src/updaters/rust/cargo-toml.js +19 -21
  134. package/build/src/updaters/terraform/module-version.d.ts +10 -11
  135. package/build/src/updaters/terraform/module-version.js +11 -9
  136. package/build/src/updaters/terraform/readme.d.ts +10 -11
  137. package/build/src/updaters/terraform/readme.js +11 -10
  138. package/build/src/updaters/terraform/readme.js.map +1 -1
  139. package/build/src/util/branch-name.d.ts +5 -4
  140. package/build/src/util/branch-name.js +13 -10
  141. package/build/src/{commit-split.d.ts → util/commit-split.d.ts} +2 -4
  142. package/build/src/{commit-split.js → util/commit-split.js} +4 -2
  143. package/build/src/util/indent-commit.d.ts +1 -1
  144. package/build/src/util/logger.d.ts +5 -2
  145. package/build/src/util/logger.js +9 -4
  146. package/build/src/util/pull-request-body.d.ts +20 -0
  147. package/build/src/util/pull-request-body.js +129 -0
  148. package/build/src/util/pull-request-title.d.ts +8 -6
  149. package/build/src/util/pull-request-title.js +20 -6
  150. package/build/src/util/tag-name.d.ts +9 -0
  151. package/build/src/util/tag-name.js +41 -0
  152. package/build/src/{updaters → util}/toml-edit.d.ts +0 -0
  153. package/build/src/{updaters → util}/toml-edit.js +0 -0
  154. package/build/src/version.d.ts +11 -0
  155. package/build/src/version.js +45 -0
  156. package/build/src/versioning-strategies/always-bump-patch.d.ts +7 -0
  157. package/build/src/{updaters/package-lock-json.js → versioning-strategies/always-bump-patch.js} +8 -11
  158. package/build/src/versioning-strategies/default.d.ts +15 -0
  159. package/build/src/versioning-strategies/default.js +67 -0
  160. package/build/src/versioning-strategies/dependency-manifest.d.ts +7 -0
  161. package/build/src/versioning-strategies/dependency-manifest.js +90 -0
  162. package/build/src/versioning-strategies/java-add-snapshot.d.ts +9 -0
  163. package/build/src/versioning-strategies/java-add-snapshot.js +53 -0
  164. package/build/src/versioning-strategies/java-snapshot.d.ts +9 -0
  165. package/build/src/versioning-strategies/java-snapshot.js +67 -0
  166. package/build/src/versioning-strategies/service-pack.d.ts +7 -0
  167. package/build/src/versioning-strategies/service-pack.js +40 -0
  168. package/build/src/versioning-strategy.d.ts +28 -0
  169. package/build/src/versioning-strategy.js +55 -0
  170. package/package.json +9 -8
  171. package/build/src/constants.d.ts +0 -6
  172. package/build/src/constants.js +0 -23
  173. package/build/src/conventional-commits.d.ts +0 -53
  174. package/build/src/conventional-commits.js +0 -167
  175. package/build/src/github-release.d.ts +0 -34
  176. package/build/src/github-release.js +0 -92
  177. package/build/src/graphql-to-commits.d.ts +0 -60
  178. package/build/src/graphql-to-commits.js +0 -112
  179. package/build/src/index.d.ts +0 -94
  180. package/build/src/index.js +0 -32
  181. package/build/src/plugins/index.d.ts +0 -5
  182. package/build/src/plugins/plugin.d.ts +0 -21
  183. package/build/src/release-pr.d.ts +0 -101
  184. package/build/src/release-pr.js +0 -461
  185. package/build/src/releasers/elixir.d.ts +0 -5
  186. package/build/src/releasers/go-yoshi.d.ts +0 -10
  187. package/build/src/releasers/go-yoshi.js +0 -162
  188. package/build/src/releasers/go.d.ts +0 -6
  189. package/build/src/releasers/helm.d.ts +0 -9
  190. package/build/src/releasers/helm.js +0 -66
  191. package/build/src/releasers/index.d.ts +0 -7
  192. package/build/src/releasers/index.js +0 -72
  193. package/build/src/releasers/java/bump_type.d.ts +0 -4
  194. package/build/src/releasers/java/bump_type.js +0 -38
  195. package/build/src/releasers/java/stability.d.ts +0 -5
  196. package/build/src/releasers/java/stability.js +0 -37
  197. package/build/src/releasers/java/version.d.ts +0 -13
  198. package/build/src/releasers/java/version.js +0 -112
  199. package/build/src/releasers/java-bom.d.ts +0 -16
  200. package/build/src/releasers/java-bom.js +0 -83
  201. package/build/src/releasers/java-lts.d.ts +0 -9
  202. package/build/src/releasers/java-lts.js +0 -47
  203. package/build/src/releasers/java-yoshi.d.ts +0 -28
  204. package/build/src/releasers/java-yoshi.js +0 -304
  205. package/build/src/releasers/krm-blueprint.d.ts +0 -6
  206. package/build/src/releasers/node.d.ts +0 -10
  207. package/build/src/releasers/node.js +0 -84
  208. package/build/src/releasers/ocaml.d.ts +0 -5
  209. package/build/src/releasers/php-yoshi.d.ts +0 -5
  210. package/build/src/releasers/php-yoshi.js +0 -191
  211. package/build/src/releasers/php.d.ts +0 -7
  212. package/build/src/releasers/python.d.ts +0 -11
  213. package/build/src/releasers/python.js +0 -127
  214. package/build/src/releasers/ruby-yoshi.d.ts +0 -5
  215. package/build/src/releasers/ruby-yoshi.js +0 -142
  216. package/build/src/releasers/ruby.d.ts +0 -11
  217. package/build/src/releasers/rust.d.ts +0 -30
  218. package/build/src/releasers/rust.js +0 -163
  219. package/build/src/releasers/simple.d.ts +0 -5
  220. package/build/src/releasers/terraform-module.d.ts +0 -6
  221. package/build/src/updaters/elixir-mix-exs.d.ts +0 -13
  222. package/build/src/updaters/java/google-utils.d.ts +0 -13
  223. package/build/src/updaters/java/java_update.d.ts +0 -13
  224. package/build/src/updaters/java/pom-xml.d.ts +0 -3
  225. package/build/src/updaters/java/readme.d.ts +0 -3
  226. package/build/src/updaters/java/readme.js.map +0 -1
  227. package/build/src/updaters/package-json.d.ts +0 -16
  228. package/build/src/updaters/package-lock-json.d.ts +0 -7
  229. package/build/src/updaters/php-client-version.d.ts +0 -13
  230. package/build/src/updaters/php-manifest.d.ts +0 -13
  231. package/build/src/updaters/root-composer-update-package.d.ts +0 -13
  232. package/build/src/updaters/root-composer-update-package.js +0 -45
  233. package/build/src/updaters/root-composer-update-packages.d.ts +0 -13
  234. package/build/src/updaters/samples-package-json.d.ts +0 -13
  235. package/build/src/updaters/update.d.ts +0 -20
  236. package/build/src/updaters/version-rb.d.ts +0 -13
  237. package/build/src/updaters/version-txt.d.ts +0 -12
  238. package/build/src/updaters/version.d.ts +0 -13
  239. package/build/src/updaters/version.js +0 -31
  240. package/build/src/util/checkpoint.d.ts +0 -6
  241. package/build/src/util/checkpoint.js +0 -33
  242. package/build/src/util/release-notes.d.ts +0 -7
  243. package/build/src/util/release-notes.js +0 -34
  244. package/build/src/util/to-conventional-changelog-format.d.ts +0 -2
@@ -0,0 +1,237 @@
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.Strategy = void 0;
17
+ const version_1 = require("./version");
18
+ const commit_1 = require("./commit");
19
+ const default_1 = require("./versioning-strategies/default");
20
+ const pull_request_title_1 = require("./util/pull-request-title");
21
+ const release_notes_1 = require("./release-notes");
22
+ const branch_name_1 = require("./util/branch-name");
23
+ const tag_name_1 = require("./util/tag-name");
24
+ const logger_1 = require("./util/logger");
25
+ const manifest_1 = require("./manifest");
26
+ const pull_request_body_1 = require("./util/pull-request-body");
27
+ const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md';
28
+ /**
29
+ * A strategy is responsible for determining which files are
30
+ * necessary to update in a release pull request.
31
+ */
32
+ class Strategy {
33
+ constructor(options) {
34
+ this.path = options.path || manifest_1.ROOT_PROJECT_PATH;
35
+ this.github = options.github;
36
+ this.packageName = options.packageName;
37
+ this.component =
38
+ options.component || this.normalizeComponent(this.packageName);
39
+ this.versioningStrategy =
40
+ options.versioningStrategy || new default_1.DefaultVersioningStrategy({});
41
+ this.targetBranch = options.targetBranch;
42
+ this.repository = options.github.repository;
43
+ this.changelogPath = options.changelogPath || DEFAULT_CHANGELOG_PATH;
44
+ this.changelogSections = options.changelogSections;
45
+ this.commitPartial = options.commitPartial;
46
+ this.headerPartial = options.headerPartial;
47
+ this.mainTemplate = options.mainTemplate;
48
+ this.tagSeparator = options.tagSeparator;
49
+ this.skipGitHubRelease = options.skipGitHubRelease || false;
50
+ this.releaseAs = options.releaseAs;
51
+ }
52
+ async getComponent() {
53
+ return this.component || (await this.getDefaultComponent());
54
+ }
55
+ async getDefaultComponent() {
56
+ return this.normalizeComponent(await this.getDefaultPackageName());
57
+ }
58
+ async getDefaultPackageName() {
59
+ return '';
60
+ }
61
+ normalizeComponent(component) {
62
+ if (!component) {
63
+ return '';
64
+ }
65
+ return component;
66
+ }
67
+ /**
68
+ * Override this method to post process commits
69
+ * @param {ConventionalCommit[]} commits parsed commits
70
+ * @returns {ConventionalCommit[]} modified commits
71
+ */
72
+ postProcessCommits(commits) {
73
+ return commits;
74
+ }
75
+ async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease) {
76
+ var _a;
77
+ const releaseNotes = new release_notes_1.ReleaseNotes({
78
+ changelogSections: this.changelogSections,
79
+ commitPartial: this.commitPartial,
80
+ headerPartial: this.headerPartial,
81
+ mainTemplate: this.mainTemplate,
82
+ });
83
+ return await releaseNotes.buildNotes(conventionalCommits, {
84
+ owner: this.repository.owner,
85
+ repository: this.repository.repo,
86
+ version: newVersion.toString(),
87
+ previousTag: (_a = latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag) === null || _a === void 0 ? void 0 : _a.toString(),
88
+ currentTag: newVersionTag.toString(),
89
+ });
90
+ }
91
+ /**
92
+ * Builds a candidate release pull request
93
+ * @param {Commit[]} commits Raw commits to consider for this release.
94
+ * @param {Release} latestRelease Optional. The last release for this
95
+ * component if available.
96
+ * @param {boolean} draft Optional. Whether or not to create the pull
97
+ * request as a draft. Defaults to `false`.
98
+ * @returns {ReleasePullRequest | undefined} The release pull request to
99
+ * open for this path/component. Returns undefined if we should not
100
+ * open a pull request.
101
+ */
102
+ async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
103
+ const conventionalCommits = this.postProcessCommits(commit_1.parseConventionalCommits(commits));
104
+ const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease);
105
+ const versionsMap = await this.buildVersionsMap(conventionalCommits);
106
+ for (const versionKey of versionsMap.keys()) {
107
+ const version = versionsMap.get(versionKey);
108
+ if (!version) {
109
+ logger_1.logger.warn(`didn't find version for ${versionKey}`);
110
+ continue;
111
+ }
112
+ const newVersion = await this.versioningStrategy.bump(version, conventionalCommits);
113
+ versionsMap.set(versionKey, newVersion);
114
+ }
115
+ const component = await this.getComponent();
116
+ logger_1.logger.debug('component:', component);
117
+ const newVersionTag = new tag_name_1.TagName(newVersion, component);
118
+ const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion);
119
+ const branchName = component
120
+ ? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch)
121
+ : branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
122
+ const releaseNotesBody = await this.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease);
123
+ if (this.changelogEmpty(releaseNotesBody)) {
124
+ logger_1.logger.info(`No user facing commits found since ${latestRelease ? latestRelease.sha : 'beginning of time'} - skipping`);
125
+ return undefined;
126
+ }
127
+ const updates = await this.buildUpdates({
128
+ changelogEntry: releaseNotesBody,
129
+ newVersion,
130
+ versionsMap,
131
+ latestVersion: latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag.version,
132
+ });
133
+ const pullRequestBody = new pull_request_body_1.PullRequestBody([
134
+ {
135
+ component,
136
+ version: newVersion,
137
+ notes: releaseNotesBody,
138
+ },
139
+ ]);
140
+ return {
141
+ title: pullRequestTitle,
142
+ body: pullRequestBody,
143
+ updates,
144
+ labels,
145
+ headRefName: branchName.toString(),
146
+ version: newVersion,
147
+ draft: draft !== null && draft !== void 0 ? draft : false,
148
+ };
149
+ }
150
+ changelogEmpty(changelogEntry) {
151
+ return changelogEntry.split('\n').length <= 1;
152
+ }
153
+ async buildNewVersion(conventionalCommits, latestRelease) {
154
+ if (this.releaseAs) {
155
+ logger_1.logger.warn(`Setting version for ${this.path} from release-as configuration`);
156
+ return version_1.Version.parse(this.releaseAs);
157
+ }
158
+ else if (latestRelease) {
159
+ return await this.versioningStrategy.bump(latestRelease.tag.version, conventionalCommits);
160
+ }
161
+ else {
162
+ return this.initialReleaseVersion();
163
+ }
164
+ }
165
+ async buildVersionsMap(_conventionalCommits) {
166
+ return new Map();
167
+ }
168
+ /**
169
+ * Given a merged pull request, build the candidate release.
170
+ * @param {PullRequest} mergedPullRequest The merged release pull request.
171
+ * @returns {Release} The candidate release.
172
+ */
173
+ async buildRelease(mergedPullRequest) {
174
+ if (this.skipGitHubRelease) {
175
+ return undefined;
176
+ }
177
+ const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title) ||
178
+ pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN);
179
+ if (!pullRequestTitle) {
180
+ throw new Error(`Bad pull request title: '${mergedPullRequest.title}'`);
181
+ }
182
+ const branchName = branch_name_1.BranchName.parse(mergedPullRequest.headBranchName);
183
+ if (!branchName) {
184
+ throw new Error(`Bad branch name: ${mergedPullRequest.headBranchName}`);
185
+ }
186
+ if (!mergedPullRequest.sha) {
187
+ throw new Error('Pull request should have been merged');
188
+ }
189
+ const pullRequestBody = pull_request_body_1.PullRequestBody.parse(mergedPullRequest.body);
190
+ if (!pullRequestBody) {
191
+ throw new Error('could not parse pull request body as a release PR');
192
+ }
193
+ const component = await this.getComponent();
194
+ logger_1.logger.info('component:', component);
195
+ const releaseData = pullRequestBody.releaseData.length === 1 &&
196
+ !pullRequestBody.releaseData[0].component
197
+ ? pullRequestBody.releaseData[0]
198
+ : pullRequestBody.releaseData.find(releaseData => {
199
+ return (this.normalizeComponent(releaseData.component) ===
200
+ this.normalizeComponent(component));
201
+ });
202
+ const notes = releaseData === null || releaseData === void 0 ? void 0 : releaseData.notes;
203
+ if (notes === undefined) {
204
+ logger_1.logger.warn('Failed to find release notes');
205
+ }
206
+ const version = pullRequestTitle.getVersion() || (releaseData === null || releaseData === void 0 ? void 0 : releaseData.version);
207
+ if (!version) {
208
+ throw new Error('Pull request should have included version');
209
+ }
210
+ return {
211
+ tag: new tag_name_1.TagName(version, component, this.tagSeparator),
212
+ notes: notes || '',
213
+ sha: mergedPullRequest.sha,
214
+ };
215
+ }
216
+ /**
217
+ * Override this to handle the initial version of a new library.
218
+ */
219
+ initialReleaseVersion() {
220
+ return version_1.Version.parse('1.0.0');
221
+ }
222
+ addPath(file) {
223
+ if (this.path === manifest_1.ROOT_PROJECT_PATH) {
224
+ return file;
225
+ }
226
+ file = file.replace(/^[/\\]/, '');
227
+ if (this.path === undefined) {
228
+ return file;
229
+ }
230
+ else {
231
+ const path = this.path.replace(/[/\\]$/, '');
232
+ return `${path}/${file}`;
233
+ }
234
+ }
235
+ }
236
+ exports.Strategy = Strategy;
237
+ //# sourceMappingURL=strategy.js.map
@@ -0,0 +1,23 @@
1
+ import { GitHubFileContents } from './github';
2
+ /**
3
+ * An update is a collection of data that represents changes to
4
+ * a file in a repository.
5
+ */
6
+ export interface Update {
7
+ cachedFileContents?: GitHubFileContents;
8
+ createIfMissing: boolean;
9
+ path: string;
10
+ updater: Updater;
11
+ }
12
+ /**
13
+ * An updater is responsible for updating code for a file.
14
+ * Given initial file contents, return updated contents.
15
+ */
16
+ export interface Updater {
17
+ /**
18
+ * Given initial file contents, return updated contents.
19
+ * @param {string} content The initial content
20
+ * @returns {string} The updated content
21
+ */
22
+ updateContent(content: string | undefined): string;
23
+ }
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2019 Google LLC
2
+ // Copyright 2021 Google LLC
3
3
  //
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // you may not use this file except in compliance with the License.
@@ -1,14 +1,11 @@
1
- import { Update, UpdateOptions, VersionsMap } from './update';
2
- import { GitHubFileContents } from '../github';
3
- export declare class Changelog implements Update {
4
- path: string;
1
+ import { DefaultUpdater, UpdateOptions } from './default';
2
+ interface ChangelogOptions extends UpdateOptions {
5
3
  changelogEntry: string;
6
- version: string;
7
- versions?: VersionsMap;
8
- packageName: string;
9
- create: boolean;
10
- contents?: GitHubFileContents;
11
- constructor(options: UpdateOptions);
4
+ }
5
+ export declare class Changelog extends DefaultUpdater {
6
+ changelogEntry: string;
7
+ constructor(options: ChangelogOptions);
12
8
  updateContent(content: string | undefined): string;
13
9
  private header;
14
10
  }
11
+ export {};
@@ -14,26 +14,20 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.Changelog = void 0;
17
- const logger_1 = require("../util/logger");
18
- class Changelog {
17
+ const default_1 = require("./default");
18
+ class Changelog extends default_1.DefaultUpdater {
19
19
  constructor(options) {
20
- this.create = true;
21
- this.path = options.path;
20
+ super(options);
22
21
  this.changelogEntry = options.changelogEntry;
23
- this.version = options.version;
24
- this.packageName = options.packageName;
25
22
  }
26
23
  updateContent(content) {
27
24
  content = content || '';
28
25
  // Handle both H2 (features/BREAKING CHANGES) and H3 (fixes).
29
26
  const lastEntryIndex = content.search(/\n###? v?[0-9[]/s);
30
27
  if (lastEntryIndex === -1) {
31
- logger_1.logger.warn(`${this.path} not found`);
32
- logger_1.logger.info(`creating ${this.path}`);
33
28
  return `${this.header()}\n${this.changelogEntry}\n`;
34
29
  }
35
30
  else {
36
- logger_1.logger.info(`updating ${this.path}`);
37
31
  const before = content.slice(0, lastEntryIndex);
38
32
  const after = content.slice(lastEntryIndex);
39
33
  return `${before}\n${this.changelogEntry}\n${after}`.trim() + '\n';
@@ -1 +1 @@
1
- {"version":3,"file":"changelog.js","sourceRoot":"","sources":["../../../src/updaters/changelog.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AAIjC,2CAAsC;AAEtC,MAAa,SAAS;IASpB,YAAY,OAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACzC,CAAC;IAED,aAAa,CAAC,OAA2B;QACvC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,6DAA6D;QAC7D,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAC1D,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE;YACzB,eAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,YAAY,CAAC,CAAC;YACtC,eAAM,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACrC,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,cAAc,IAAI,CAAC;SACrD;aAAM;YACL,eAAM,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACrC,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAC5C,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC,cAAc,KAAK,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;SACpE;IACH,CAAC;IACO,MAAM;QACZ,OAAO;;CAEV,CAAC;IACA,CAAC;CACF;AArCD,8BAqCC"}
1
+ {"version":3,"file":"changelog.js","sourceRoot":"","sources":["../../../src/updaters/changelog.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AAEjC,uCAAwD;AAMxD,MAAa,SAAU,SAAQ,wBAAc;IAG3C,YAAY,OAAyB;QACnC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAC/C,CAAC;IAED,aAAa,CAAC,OAA2B;QACvC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,6DAA6D;QAC7D,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAC1D,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE;YACzB,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,cAAc,IAAI,CAAC;SACrD;aAAM;YACL,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAC5C,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC,cAAc,KAAK,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;SACpE;IACH,CAAC;IACO,MAAM;QACZ,OAAO;;CAEV,CAAC;IACA,CAAC;CACF;AAzBD,8BAyBC"}
@@ -0,0 +1,19 @@
1
+ import { Updater } from '../update';
2
+ /**
3
+ * The CompositeUpdater chains 0...n updaters and updates
4
+ * the content in order.
5
+ */
6
+ export declare class CompositeUpdater implements Updater {
7
+ updaters: Updater[];
8
+ /**
9
+ * Instantiate a new CompositeUpdater
10
+ * @param {Updater[]} updaters The updaters to chain together
11
+ */
12
+ constructor(...updaters: Updater[]);
13
+ /**
14
+ * Given initial file contents, return updated contents.
15
+ * @param {string} content The initial content
16
+ * @returns {string} The updated content
17
+ */
18
+ updateContent(content: string | undefined): string;
19
+ }
@@ -0,0 +1,42 @@
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.CompositeUpdater = void 0;
17
+ /**
18
+ * The CompositeUpdater chains 0...n updaters and updates
19
+ * the content in order.
20
+ */
21
+ class CompositeUpdater {
22
+ /**
23
+ * Instantiate a new CompositeUpdater
24
+ * @param {Updater[]} updaters The updaters to chain together
25
+ */
26
+ constructor(...updaters) {
27
+ this.updaters = updaters;
28
+ }
29
+ /**
30
+ * Given initial file contents, return updated contents.
31
+ * @param {string} content The initial content
32
+ * @returns {string} The updated content
33
+ */
34
+ updateContent(content) {
35
+ for (const updater of this.updaters) {
36
+ content = updater.updateContent(content);
37
+ }
38
+ return content || '';
39
+ }
40
+ }
41
+ exports.CompositeUpdater = CompositeUpdater;
42
+ //# sourceMappingURL=composite.js.map
@@ -0,0 +1,12 @@
1
+ import { DefaultUpdater } from '../default';
2
+ /**
3
+ * Updates a Dart pubspec.yaml file.
4
+ */
5
+ export declare class PubspecYaml extends DefaultUpdater {
6
+ /**
7
+ * Given initial file contents, return updated contents.
8
+ * @param {string} content The initial content
9
+ * @returns {string} The updated content
10
+ */
11
+ updateContent(content: string): string;
12
+ }
@@ -0,0 +1,45 @@
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.PubspecYaml = void 0;
17
+ const logger_1 = require("../../util/logger");
18
+ const default_1 = require("../default");
19
+ /**
20
+ * Updates a Dart pubspec.yaml file.
21
+ */
22
+ class PubspecYaml extends default_1.DefaultUpdater {
23
+ /**
24
+ * Given initial file contents, return updated contents.
25
+ * @param {string} content The initial content
26
+ * @returns {string} The updated content
27
+ */
28
+ updateContent(content) {
29
+ const oldVersion = content.match(/version: ([0-9.]+)\+?([0-9]*$)/);
30
+ let buildNumber = '';
31
+ if (oldVersion) {
32
+ buildNumber = `${oldVersion[2]}`;
33
+ if (buildNumber.length > 0) {
34
+ buildNumber = `+${buildNumber}`;
35
+ logger_1.logger.info(`updating from ${oldVersion[1]}${buildNumber} to ${this.version}${buildNumber}`);
36
+ }
37
+ else {
38
+ logger_1.logger.info(`updating from ${oldVersion[1]} to ${this.version}`);
39
+ }
40
+ }
41
+ return content.replace(/version: ([0-9.]+)\+?([0-9]*$)/, `version: ${this.version}${buildNumber}`);
42
+ }
43
+ }
44
+ exports.PubspecYaml = PubspecYaml;
45
+ //# sourceMappingURL=pubspec-yaml.js.map
@@ -0,0 +1,21 @@
1
+ import { Updater } from '../update';
2
+ import { Version, VersionsMap } from '../version';
3
+ export interface UpdateOptions {
4
+ version: Version;
5
+ versionsMap?: VersionsMap;
6
+ }
7
+ /**
8
+ * This updater writes a plain file with the version string as the
9
+ * only content.
10
+ */
11
+ export declare class DefaultUpdater implements Updater {
12
+ version: Version;
13
+ versionsMap?: VersionsMap;
14
+ constructor(options: UpdateOptions);
15
+ /**
16
+ * Given initial file contents, return updated contents.
17
+ * @param {string} content The initial content
18
+ * @returns {string} The updated content
19
+ */
20
+ updateContent(_content: string): string;
21
+ }
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2020 Google LLC
2
+ // Copyright 2021 Google LLC
3
3
  //
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // you may not use this file except in compliance with the License.
@@ -13,18 +13,24 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.VersionTxt = void 0;
17
- class VersionTxt {
16
+ exports.DefaultUpdater = void 0;
17
+ /**
18
+ * This updater writes a plain file with the version string as the
19
+ * only content.
20
+ */
21
+ class DefaultUpdater {
18
22
  constructor(options) {
19
- this.create = true;
20
- this.path = options.path;
21
- this.changelogEntry = options.changelogEntry;
22
23
  this.version = options.version;
23
- this.packageName = options.packageName;
24
+ this.versionsMap = options.versionsMap;
24
25
  }
25
- updateContent() {
26
+ /**
27
+ * Given initial file contents, return updated contents.
28
+ * @param {string} content The initial content
29
+ * @returns {string} The updated content
30
+ */
31
+ updateContent(_content) {
26
32
  return this.version + '\n';
27
33
  }
28
34
  }
29
- exports.VersionTxt = VersionTxt;
30
- //# sourceMappingURL=version-txt.js.map
35
+ exports.DefaultUpdater = DefaultUpdater;
36
+ //# sourceMappingURL=default.js.map
@@ -0,0 +1,12 @@
1
+ import { DefaultUpdater } from '../default';
2
+ /**
3
+ * Updates a .NET .csproj.
4
+ */
5
+ export declare class CsProj extends DefaultUpdater {
6
+ /**
7
+ * Given initial file contents, return updated contents.
8
+ * @param {string} content The initial content
9
+ * @returns {string} The updated content
10
+ */
11
+ updateContent(content: string): string;
12
+ }
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2019 Google LLC
2
+ // Copyright 2021 Google LLC
3
3
  //
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // you may not use this file except in compliance with the License.
@@ -13,18 +13,21 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.GoogleUtils = void 0;
17
- class GoogleUtils {
18
- constructor(options) {
19
- this.create = false;
20
- this.path = options.path;
21
- this.changelogEntry = options.changelogEntry;
22
- this.version = options.version;
23
- this.packageName = options.packageName;
24
- }
16
+ exports.CsProj = void 0;
17
+ const default_1 = require("../default");
18
+ const VERSION_ATTR_REGEX = /<Version>\d+\.\d+\.\d+(-[^+]+)?(\+.*)?<\/Version>/;
19
+ /**
20
+ * Updates a .NET .csproj.
21
+ */
22
+ class CsProj extends default_1.DefaultUpdater {
23
+ /**
24
+ * Given initial file contents, return updated contents.
25
+ * @param {string} content The initial content
26
+ * @returns {string} The updated content
27
+ */
25
28
  updateContent(content) {
26
- return content.replace(/"[0-9]\.[0-9]+\.[0-9](-\w+)?"/, `"${this.version}"`);
29
+ return content.replace(VERSION_ATTR_REGEX, `<Version>${this.version}</Version>`);
27
30
  }
28
31
  }
29
- exports.GoogleUtils = GoogleUtils;
30
- //# sourceMappingURL=google-utils.js.map
32
+ exports.CsProj = CsProj;
33
+ //# sourceMappingURL=csproj.js.map
@@ -0,0 +1,12 @@
1
+ import { DefaultUpdater } from '../default';
2
+ /**
3
+ * Updates an Elixir mix.exs file and looks for a version string.
4
+ */
5
+ export declare class ElixirMixExs extends DefaultUpdater {
6
+ /**
7
+ * Given initial file contents, return updated contents.
8
+ * @param {string} content The initial content
9
+ * @returns {string} The updated content
10
+ */
11
+ updateContent(content: string): string;
12
+ }
@@ -14,19 +14,21 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.ElixirMixExs = void 0;
17
- const logger_1 = require("../util/logger");
18
- class ElixirMixExs {
19
- constructor(options) {
20
- this.create = false;
21
- this.path = options.path;
22
- this.changelogEntry = options.changelogEntry;
23
- this.version = options.version;
24
- this.packageName = options.packageName;
25
- }
17
+ const logger_1 = require("../../util/logger");
18
+ const default_1 = require("../default");
19
+ /**
20
+ * Updates an Elixir mix.exs file and looks for a version string.
21
+ */
22
+ class ElixirMixExs extends default_1.DefaultUpdater {
23
+ /**
24
+ * Given initial file contents, return updated contents.
25
+ * @param {string} content The initial content
26
+ * @returns {string} The updated content
27
+ */
26
28
  updateContent(content) {
27
29
  const oldVersion = content.match(/version: "([A-Za-z0-9_\-+.~]+)",/);
28
30
  if (oldVersion) {
29
- logger_1.logger.info(`updating ${this.path} from ${oldVersion[1]} to ${this.version}`);
31
+ logger_1.logger.info(`updating from ${oldVersion[1]} to ${this.version}`);
30
32
  }
31
33
  return content.replace(/version: "[A-Za-z0-9_\-+.~]+",/, `version: "${this.version}",`);
32
34
  }
@@ -1,13 +1,12 @@
1
- import { Update, UpdateOptions, VersionsMap } from '../update';
2
- import { GitHubFileContents } from '../../github';
3
- export declare class ChartYaml implements Update {
4
- path: string;
5
- changelogEntry: string;
6
- version: string;
7
- versions?: VersionsMap;
8
- packageName: string;
9
- create: boolean;
10
- contents?: GitHubFileContents;
11
- constructor(options: UpdateOptions);
1
+ import { DefaultUpdater } from '../default';
2
+ /**
3
+ * Updates a Helm chart.yaml file.
4
+ */
5
+ export declare class ChartYaml extends DefaultUpdater {
6
+ /**
7
+ * Given initial file contents, return updated contents.
8
+ * @param {string} content The initial content
9
+ * @returns {string} The updated content
10
+ */
12
11
  updateContent(content: string): string;
13
12
  }