release-please 13.0.0 → 13.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,34 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ### [13.1.1](https://www.github.com/googleapis/release-please/compare/v13.1.0...v13.1.1) (2022-01-03)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **rust:** Rust strategy should update root Cargo files in a workspace ([#1182](https://www.github.com/googleapis/release-please/issues/1182)) ([26a040c](https://www.github.com/googleapis/release-please/commit/26a040cf06a7a2cf97b9ebc3d204bb36f0b2c13b)), closes [#1170](https://www.github.com/googleapis/release-please/issues/1170) [#1096](https://www.github.com/googleapis/release-please/issues/1096)
13
+
14
+ ## [13.1.0](https://www.github.com/googleapis/release-please/compare/v13.0.2...v13.1.0) (2021-12-29)
15
+
16
+
17
+ ### Features
18
+
19
+ * introduce generic updater ([#1157](https://www.github.com/googleapis/release-please/issues/1157)) ([c97598c](https://www.github.com/googleapis/release-please/commit/c97598c137b5018c76f5d62137e277b991f4bfa3)), closes [#435](https://www.github.com/googleapis/release-please/issues/435) [#305](https://www.github.com/googleapis/release-please/issues/305) [#1139](https://www.github.com/googleapis/release-please/issues/1139) [#1174](https://www.github.com/googleapis/release-please/issues/1174)
20
+
21
+ ### [13.0.2](https://www.github.com/googleapis/release-please/compare/v13.0.1...v13.0.2) (2021-12-29)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * set the title when creating a release ([#1177](https://www.github.com/googleapis/release-please/issues/1177)) ([d05001f](https://www.github.com/googleapis/release-please/commit/d05001faedcdf11869cd9db06e3a8a8071af4470))
27
+
28
+ ### [13.0.1](https://www.github.com/googleapis/release-please/compare/v13.0.0...v13.0.1) (2021-12-23)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * export public interface types from index.ts ([#1169](https://www.github.com/googleapis/release-please/issues/1169)) ([cef6407](https://www.github.com/googleapis/release-please/commit/cef6407b05b8bbbc17d0c0b9d4704dc1de80ccf0))
34
+
7
35
  ## [13.0.0](https://www.github.com/googleapis/release-please/compare/v12.6.0...v13.0.0) (2021-12-22)
8
36
 
9
37
 
package/README.md CHANGED
@@ -91,6 +91,24 @@ chore: release 2.0.0
91
91
  Release-As: 2.0.0
92
92
  ```
93
93
 
94
+ ## How can I fix release notes?
95
+
96
+ If you have merged a pull request and you would like to amend the commit message
97
+ used to generate the release notes for that commit, you can edit the body of
98
+ the merged pull requests and add a section like:
99
+
100
+ ```
101
+ BEGIN_COMMIT_OVERRIDE
102
+ feat: add ability to override merged commit message
103
+
104
+ fix: another message
105
+ chore: a third message
106
+ END_COMMIT_OVERRIDE
107
+ ```
108
+
109
+ The next time release please runs, it will use that override section as the
110
+ commit message instead of the merged commit message.
111
+
94
112
  ## Strategy (Language) types supported
95
113
 
96
114
  Release Please automates releases for the following flavors of repositories:
@@ -68,6 +68,7 @@ const allReleaseTypes = [
68
68
  const releasers = {
69
69
  go: options => new go_1.Go(options),
70
70
  'go-yoshi': options => new go_yoshi_1.GoYoshi(options),
71
+ 'java-yoshi': options => new java_yoshi_1.JavaYoshi(options),
71
72
  'krm-blueprint': options => new krm_blueprint_1.KRMBlueprint(options),
72
73
  node: options => new node_1.Node(options),
73
74
  ocaml: options => new ocaml_1.OCaml(options),
@@ -122,6 +123,7 @@ async function buildStrategy(options) {
122
123
  includeComponentInTag: options.includeComponentInTag,
123
124
  changelogNotes,
124
125
  pullRequestTitlePattern: options.pullRequestTitlePattern,
126
+ extraFiles: options.extraFiles,
125
127
  };
126
128
  switch (options.releaseType) {
127
129
  case 'ruby': {
@@ -136,23 +138,15 @@ async function buildStrategy(options) {
136
138
  versionFile: options.versionFile,
137
139
  });
138
140
  }
139
- case 'java-yoshi': {
140
- return new java_yoshi_1.JavaYoshi({
141
- ...strategyOptions,
142
- extraFiles: options.extraFiles,
143
- });
144
- }
145
141
  case 'java-backport': {
146
142
  return new java_yoshi_1.JavaYoshi({
147
143
  ...strategyOptions,
148
- extraFiles: options.extraFiles,
149
144
  versioningStrategy: new always_bump_patch_1.AlwaysBumpPatch(),
150
145
  });
151
146
  }
152
147
  case 'java-bom': {
153
148
  return new java_yoshi_1.JavaYoshi({
154
149
  ...strategyOptions,
155
- extraFiles: options.extraFiles,
156
150
  versioningStrategy: new dependency_manifest_1.DependencyManifest({
157
151
  bumpMinorPreMajor: options.bumpMinorPreMajor,
158
152
  bumpPatchForMinorPreMajor: options.bumpPatchForMinorPreMajor,
@@ -162,7 +156,6 @@ async function buildStrategy(options) {
162
156
  case 'java-lts': {
163
157
  return new java_yoshi_1.JavaYoshi({
164
158
  ...strategyOptions,
165
- extraFiles: options.extraFiles,
166
159
  versioningStrategy: new service_pack_1.ServicePackVersioningStrategy(),
167
160
  });
168
161
  }
@@ -299,6 +299,7 @@ class GitHub {
299
299
  */
300
300
  this.createRelease = wrapAsync(async (release, options = {}) => {
301
301
  const resp = await this.octokit.repos.createRelease({
302
+ name: release.name,
302
303
  owner: this.repository.owner,
303
304
  repo: this.repository.repo,
304
305
  tag_name: release.tag.toString(),
@@ -0,0 +1,5 @@
1
+ export * as Errors from './errors';
2
+ export { Manifest, ReleaserConfig, ManifestOptions } from './manifest';
3
+ export { ReleaseType, getReleaserTypes, VersioningStrategyType, getVersioningStrategyTypes, ChangelogNotesType, getChangelogTypes, } from './factory';
4
+ export { Logger, setLogger } from './util/logger';
5
+ export { GitHub } from './github';
@@ -0,0 +1,27 @@
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.Errors = require("./errors");
17
+ var manifest_1 = require("./manifest");
18
+ Object.defineProperty(exports, "Manifest", { enumerable: true, get: function () { return manifest_1.Manifest; } });
19
+ var factory_1 = require("./factory");
20
+ Object.defineProperty(exports, "getReleaserTypes", { enumerable: true, get: function () { return factory_1.getReleaserTypes; } });
21
+ Object.defineProperty(exports, "getVersioningStrategyTypes", { enumerable: true, get: function () { return factory_1.getVersioningStrategyTypes; } });
22
+ Object.defineProperty(exports, "getChangelogTypes", { enumerable: true, get: function () { return factory_1.getChangelogTypes; } });
23
+ var logger_1 = require("./util/logger");
24
+ Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return logger_1.setLogger; } });
25
+ var github_1 = require("./github");
26
+ Object.defineProperty(exports, "GitHub", { enumerable: true, get: function () { return github_1.GitHub; } });
27
+ //# sourceMappingURL=index.js.map
@@ -182,6 +182,7 @@ class Manifest {
182
182
  logger_1.logger.debug(`Found release for path ${path}, ${release.tagName}`);
183
183
  releaseShasByPath[path] = release.sha;
184
184
  releasesByPath[path] = {
185
+ name: release.name,
185
186
  tag: tagName,
186
187
  sha: release.sha,
187
188
  notes: release.notes || '',
@@ -26,6 +26,7 @@ const pull_request_title_1 = require("../util/pull-request-title");
26
26
  const pull_request_body_1 = require("../util/pull-request-body");
27
27
  const branch_name_1 = require("../util/branch-name");
28
28
  const versioning_strategy_1 = require("../versioning-strategy");
29
+ const cargo_lock_1 = require("../updaters/rust/cargo-lock");
29
30
  /**
30
31
  * The plugin analyzed a cargo workspace and will bump dependencies
31
32
  * of managed packages if those dependencies are being updated.
@@ -50,7 +51,9 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
50
51
  }
51
52
  const allCrates = [];
52
53
  const candidatesByPackage = {};
53
- for (const path of cargoManifest.workspace.members) {
54
+ const members = cargoManifest.workspace.members;
55
+ members.push(manifest_1.ROOT_PROJECT_PATH);
56
+ for (const path of members) {
54
57
  const manifestPath = addPath(path, 'Cargo.toml');
55
58
  logger_1.logger.info(`looking for candidate with path: ${path}`);
56
59
  const candidate = candidates.find(c => c.path === path);
@@ -60,7 +63,8 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
60
63
  const manifest = common_1.parseCargoManifest(manifestContent.parsedContent);
61
64
  const packageName = (_c = manifest.package) === null || _c === void 0 ? void 0 : _c.name;
62
65
  if (!packageName) {
63
- throw new Error(`package manifest at ${manifestPath} is missing [package.name]`);
66
+ logger_1.logger.warn(`package manifest at ${manifestPath} is missing [package.name]`);
67
+ continue;
64
68
  }
65
69
  if (candidate) {
66
70
  candidatesByPackage[packageName] = candidate;
@@ -105,9 +109,15 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
105
109
  if (update.path === addPath(existingCandidate.path, 'Cargo.toml')) {
106
110
  update.updater = new raw_content_1.RawContent(updatedContent);
107
111
  }
108
- else if (update.updater instanceof changelog_1.Changelog) {
112
+ else if (update.updater instanceof changelog_1.Changelog && dependencyNotes) {
109
113
  update.updater.changelogEntry = appendDependenciesSectionToChangelog(update.updater.changelogEntry, dependencyNotes);
110
114
  }
115
+ else if (update.path === addPath(existingCandidate.path, 'Cargo.lock')) {
116
+ update.updater = new cargo_lock_1.CargoLock({
117
+ version,
118
+ versionsMap: updatedVersions,
119
+ });
120
+ }
111
121
  return update;
112
122
  });
113
123
  // append dependency notes
@@ -195,8 +205,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
195
205
  return graph;
196
206
  }
197
207
  inScope(candidate) {
198
- return (candidate.config.releaseType === 'rust' &&
199
- candidate.path !== manifest_1.ROOT_PROJECT_PATH);
208
+ return candidate.config.releaseType === 'rust';
200
209
  }
201
210
  packageNameFromPackage(pkg) {
202
211
  return pkg.name;
@@ -31,36 +31,18 @@ class Merge extends plugin_1.ManifestPlugin {
31
31
  if (candidates.length < 1) {
32
32
  return candidates;
33
33
  }
34
- const updatesByPath = {};
35
34
  const releaseData = [];
36
35
  const labels = new Set();
36
+ let rawUpdates = [];
37
37
  for (const candidate of candidates) {
38
38
  const pullRequest = candidate.pullRequest;
39
- for (const update of pullRequest.updates) {
40
- if (updatesByPath[update.path]) {
41
- updatesByPath[update.path].push(update);
42
- }
43
- else {
44
- updatesByPath[update.path] = [update];
45
- }
46
- }
39
+ rawUpdates = rawUpdates.concat(...pullRequest.updates);
47
40
  for (const label of pullRequest.labels) {
48
41
  labels.add(label);
49
42
  }
50
43
  releaseData.push(...pullRequest.body.releaseData);
51
44
  }
52
- const updates = [];
53
- for (const path in updatesByPath) {
54
- const update = updatesByPath[path];
55
- const updaters = update.map(u => u.updater);
56
- updates.push({
57
- path,
58
- createIfMissing: update[0].createIfMissing,
59
- updater: updaters.length === 1
60
- ? updaters[0]
61
- : new composite_1.CompositeUpdater(...updaters),
62
- });
63
- }
45
+ const updates = composite_1.mergeUpdates(rawUpdates);
64
46
  const pullRequest = {
65
47
  title: pull_request_title_1.PullRequestTitle.ofTargetBranch(this.targetBranch, manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN),
66
48
  body: new pull_request_body_1.PullRequestBody(releaseData),
@@ -1,5 +1,6 @@
1
1
  import { TagName } from './util/tag-name';
2
2
  export interface Release {
3
+ readonly name?: string;
3
4
  readonly tag: TagName;
4
5
  readonly sha: string;
5
6
  readonly notes: string;
@@ -36,6 +36,7 @@ export interface BaseStrategyOptions {
36
36
  changelogNotes?: ChangelogNotes;
37
37
  includeComponentInTag?: boolean;
38
38
  pullRequestTitlePattern?: string;
39
+ extraFiles?: string[];
39
40
  }
40
41
  /**
41
42
  * A strategy is responsible for determining which files are
@@ -55,6 +56,7 @@ export declare abstract class BaseStrategy implements Strategy {
55
56
  private releaseAs?;
56
57
  private includeComponentInTag;
57
58
  private pullRequestTitlePattern?;
59
+ readonly extraFiles: string[];
58
60
  readonly changelogNotes: ChangelogNotes;
59
61
  protected changelogSections?: ChangelogSection[];
60
62
  constructor(options: BaseStrategyOptions);
@@ -90,6 +92,7 @@ export declare abstract class BaseStrategy implements Strategy {
90
92
  * open a pull request.
91
93
  */
92
94
  buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
95
+ private extraFileUpdates;
93
96
  protected changelogEmpty(changelogEntry: string): boolean;
94
97
  protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
95
98
  protected buildNewVersion(conventionalCommits: ConventionalCommit[], latestRelease?: Release): Promise<Version>;
@@ -24,6 +24,8 @@ const logger_1 = require("../util/logger");
24
24
  const pull_request_title_1 = require("../util/pull-request-title");
25
25
  const branch_name_1 = require("../util/branch-name");
26
26
  const pull_request_body_1 = require("../util/pull-request-body");
27
+ const composite_1 = require("../updaters/composite");
28
+ const generic_1 = require("../updaters/generic");
27
29
  const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md';
28
30
  /**
29
31
  * A strategy is responsible for determining which files are
@@ -50,6 +52,7 @@ class BaseStrategy {
50
52
  options.changelogNotes || new default_2.DefaultChangelogNotes(options);
51
53
  this.includeComponentInTag = (_a = options.includeComponentInTag) !== null && _a !== void 0 ? _a : true;
52
54
  this.pullRequestTitlePattern = options.pullRequestTitlePattern;
55
+ this.extraFiles = options.extraFiles || [];
53
56
  }
54
57
  /**
55
58
  * Return the component for this strategy. This may be a computed field.
@@ -127,6 +130,7 @@ class BaseStrategy {
127
130
  versionsMap,
128
131
  latestVersion: latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag.version,
129
132
  });
133
+ const updatesWithExtras = composite_1.mergeUpdates(updates.concat(...this.extraFileUpdates(newVersion)));
130
134
  const pullRequestBody = new pull_request_body_1.PullRequestBody([
131
135
  {
132
136
  component,
@@ -137,13 +141,23 @@ class BaseStrategy {
137
141
  return {
138
142
  title: pullRequestTitle,
139
143
  body: pullRequestBody,
140
- updates,
144
+ updates: updatesWithExtras,
141
145
  labels,
142
146
  headRefName: branchName.toString(),
143
147
  version: newVersion,
144
148
  draft: draft !== null && draft !== void 0 ? draft : false,
145
149
  };
146
150
  }
151
+ extraFileUpdates(version) {
152
+ const genericUpdater = new generic_1.Generic({ version });
153
+ return this.extraFiles.map(path => {
154
+ return {
155
+ path,
156
+ createIfMissing: false,
157
+ updater: genericUpdater,
158
+ };
159
+ });
160
+ }
147
161
  changelogEmpty(changelogEntry) {
148
162
  return changelogEntry.split('\n').length <= 1;
149
163
  }
@@ -223,7 +237,11 @@ class BaseStrategy {
223
237
  return;
224
238
  }
225
239
  const tag = new tag_name_1.TagName(version, this.includeComponentInTag ? component : undefined, this.tagSeparator);
240
+ const releaseName = component && this.includeComponentInTag
241
+ ? `${component}: v${version.toString()}`
242
+ : `v${version.toString()}`;
226
243
  return {
244
+ name: releaseName,
227
245
  tag,
228
246
  notes: notes || '',
229
247
  sha: mergedPullRequest.sha,
@@ -5,14 +5,10 @@ import { GitHubFileContents } from '../github';
5
5
  import { Commit, ConventionalCommit } from '../commit';
6
6
  import { Release } from '../release';
7
7
  import { ReleasePullRequest } from '../release-pull-request';
8
- interface JavaStrategyOptions extends BaseStrategyOptions {
9
- extraFiles?: string[];
10
- }
11
8
  export declare class JavaYoshi extends BaseStrategy {
12
- readonly extraFiles: string[];
13
9
  private versionsContent?;
14
10
  private snapshotVersioning;
15
- constructor(options: JavaStrategyOptions);
11
+ constructor(options: BaseStrategyOptions);
16
12
  buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
17
13
  private buildSnapshotPullRequest;
18
14
  private needsSnapshot;
@@ -22,4 +18,3 @@ export declare class JavaYoshi extends BaseStrategy {
22
18
  protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
23
19
  protected initialReleaseVersion(): Version;
24
20
  }
25
- export {};
@@ -49,7 +49,6 @@ class JavaYoshi extends base_1.BaseStrategy {
49
49
  const parentVersioningStrategy = options.versioningStrategy || new default_1.DefaultVersioningStrategy();
50
50
  options.versioningStrategy = new java_snapshot_1.JavaSnapshot(parentVersioningStrategy);
51
51
  super(options);
52
- this.extraFiles = options.extraFiles || [];
53
52
  this.snapshotVersioning = new java_add_snapshot_1.JavaAddSnapshot(parentVersioningStrategy);
54
53
  }
55
54
  async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
@@ -12,9 +12,6 @@ export declare class Rust extends BaseStrategy {
12
12
  * @returns the package's manifest, ie. `crates/foobar/Cargo.toml`
13
13
  */
14
14
  protected getPackageManifest(): Promise<CargoManifest | null>;
15
- /**
16
- * @returns the workspace's manifest, ie. `Cargo.toml` (top-level)
17
- */
18
- protected getWorkspaceManifest(): Promise<CargoManifest | null>;
15
+ private getContent;
19
16
  protected getManifest(path: string): Promise<CargoManifest | null>;
20
17
  }
@@ -25,6 +25,7 @@ const base_1 = require("./base");
25
25
  const version_1 = require("../version");
26
26
  class Rust extends base_1.BaseStrategy {
27
27
  async buildUpdates(options) {
28
+ var _a, _b, _c;
28
29
  const updates = [];
29
30
  const version = options.newVersion;
30
31
  updates.push({
@@ -35,30 +36,62 @@ class Rust extends base_1.BaseStrategy {
35
36
  changelogEntry: options.changelogEntry,
36
37
  }),
37
38
  });
38
- const workspaceManifest = await this.getWorkspaceManifest();
39
- const manifestPaths = [];
40
- let lockPath;
41
- if (workspaceManifest &&
42
- workspaceManifest.workspace &&
43
- workspaceManifest.workspace.members) {
39
+ const workspaceManifest = await this.getPackageManifest();
40
+ const versionsMap = new Map();
41
+ if ((_a = workspaceManifest === null || workspaceManifest === void 0 ? void 0 : workspaceManifest.workspace) === null || _a === void 0 ? void 0 : _a.members) {
44
42
  const members = workspaceManifest.workspace.members;
43
+ if ((_b = workspaceManifest.package) === null || _b === void 0 ? void 0 : _b.name) {
44
+ versionsMap.set(workspaceManifest.package.name, version);
45
+ }
46
+ else {
47
+ logger_1.logger.warn('No workspace manifest package name found');
48
+ }
45
49
  logger_1.logger.info(`found workspace with ${members.length} members, upgrading all`);
50
+ // Collect submodule names to update
51
+ const manifestsByPath = new Map();
46
52
  for (const member of members) {
47
- manifestPaths.push(`${member}/Cargo.toml`);
53
+ const manifestPath = `${member}/Cargo.toml`;
54
+ const manifestContent = await this.getContent(manifestPath);
55
+ if (!manifestContent) {
56
+ logger_1.logger.warn(`member ${member} declared but did not find Cargo.toml`);
57
+ continue;
58
+ }
59
+ const manifest = common_1.parseCargoManifest(manifestContent.parsedContent);
60
+ manifestsByPath.set(manifestPath, manifestContent);
61
+ if (!((_c = manifest.package) === null || _c === void 0 ? void 0 : _c.name)) {
62
+ logger_1.logger.warn(`member ${member} has no package name`);
63
+ continue;
64
+ }
65
+ versionsMap.set(manifest.package.name, version);
48
66
  }
49
- lockPath = 'Cargo.lock';
67
+ logger_1.logger.info(`updating ${manifestsByPath.size} submodules`);
68
+ logger_1.logger.debug('versions map:', versionsMap);
69
+ for (const [manifestPath, manifestContent] of manifestsByPath) {
70
+ updates.push({
71
+ path: this.addPath(manifestPath),
72
+ createIfMissing: false,
73
+ cachedFileContents: manifestContent,
74
+ updater: new cargo_toml_1.CargoToml({
75
+ version,
76
+ versionsMap,
77
+ }),
78
+ });
79
+ }
80
+ // Update root Cargo.toml
81
+ updates.push({
82
+ path: this.addPath('Cargo.toml'),
83
+ createIfMissing: false,
84
+ updater: new cargo_toml_1.CargoToml({
85
+ version,
86
+ versionsMap,
87
+ }),
88
+ });
50
89
  }
51
90
  else {
52
91
  const manifestPath = this.addPath('Cargo.toml');
53
92
  logger_1.logger.info(`single crate found, updating ${manifestPath}`);
54
- manifestPaths.push(manifestPath);
55
- lockPath = this.addPath('Cargo.lock');
56
- }
57
- const versionsMap = new Map();
58
- versionsMap.set(this.component || '', version);
59
- for (const path of manifestPaths) {
60
93
  updates.push({
61
- path,
94
+ path: manifestPath,
62
95
  createIfMissing: false,
63
96
  updater: new cargo_toml_1.CargoToml({
64
97
  version,
@@ -67,7 +100,7 @@ class Rust extends base_1.BaseStrategy {
67
100
  });
68
101
  }
69
102
  updates.push({
70
- path: lockPath,
103
+ path: this.addPath('Cargo.lock'),
71
104
  createIfMissing: false,
72
105
  updater: new cargo_lock_1.CargoLock({
73
106
  version,
@@ -92,28 +125,21 @@ class Rust extends base_1.BaseStrategy {
92
125
  */
93
126
  async getPackageManifest() {
94
127
  if (this.packageManifest === undefined) {
95
- this.packageManifest = await this.getManifest(this.addPath('Cargo.toml'));
128
+ this.packageManifest = await this.getManifest('Cargo.toml');
96
129
  }
97
130
  return this.packageManifest;
98
131
  }
99
- /**
100
- * @returns the workspace's manifest, ie. `Cargo.toml` (top-level)
101
- */
102
- async getWorkspaceManifest() {
103
- if (this.workspaceManifest === undefined) {
104
- this.workspaceManifest = await this.getManifest('Cargo.toml');
105
- }
106
- return this.workspaceManifest;
107
- }
108
- async getManifest(path) {
109
- let content;
132
+ async getContent(path) {
110
133
  try {
111
- content = await this.github.getFileContentsOnBranch(path, this.targetBranch);
134
+ return await this.github.getFileContentsOnBranch(this.addPath(path), this.targetBranch);
112
135
  }
113
136
  catch (e) {
114
137
  return null;
115
138
  }
116
- return common_1.parseCargoManifest(content.parsedContent);
139
+ }
140
+ async getManifest(path) {
141
+ const content = await this.getContent(path);
142
+ return content ? common_1.parseCargoManifest(content.parsedContent) : null;
117
143
  }
118
144
  }
119
145
  exports.Rust = Rust;
@@ -1,10 +1,10 @@
1
- import { Updater } from '../update';
1
+ import { Updater, Update } from '../update';
2
2
  /**
3
3
  * The CompositeUpdater chains 0...n updaters and updates
4
4
  * the content in order.
5
5
  */
6
6
  export declare class CompositeUpdater implements Updater {
7
- updaters: Updater[];
7
+ readonly updaters: Updater[];
8
8
  /**
9
9
  * Instantiate a new CompositeUpdater
10
10
  * @param {Updater[]} updaters The updaters to chain together
@@ -17,3 +17,4 @@ export declare class CompositeUpdater implements Updater {
17
17
  */
18
18
  updateContent(content: string | undefined): string;
19
19
  }
20
+ export declare function mergeUpdates(updates: Update[]): Update[];
@@ -13,7 +13,7 @@
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.CompositeUpdater = void 0;
16
+ exports.mergeUpdates = exports.CompositeUpdater = void 0;
17
17
  /**
18
18
  * The CompositeUpdater chains 0...n updaters and updates
19
19
  * the content in order.
@@ -39,4 +39,27 @@ class CompositeUpdater {
39
39
  }
40
40
  }
41
41
  exports.CompositeUpdater = CompositeUpdater;
42
+ function mergeUpdates(updates) {
43
+ const updatesByPath = {};
44
+ for (const update of updates) {
45
+ if (updatesByPath[update.path]) {
46
+ updatesByPath[update.path].push(update);
47
+ }
48
+ else {
49
+ updatesByPath[update.path] = [update];
50
+ }
51
+ }
52
+ const newUpdates = [];
53
+ for (const path in updatesByPath) {
54
+ const update = updatesByPath[path];
55
+ const updaters = update.map(u => u.updater);
56
+ newUpdates.push({
57
+ path,
58
+ createIfMissing: update[0].createIfMissing,
59
+ updater: updaters.length === 1 ? updaters[0] : new CompositeUpdater(...updaters),
60
+ });
61
+ }
62
+ return newUpdates;
63
+ }
64
+ exports.mergeUpdates = mergeUpdates;
42
65
  //# sourceMappingURL=composite.js.map
@@ -0,0 +1,32 @@
1
+ import { DefaultUpdater } from './default';
2
+ /**
3
+ * The Generic updater looks for well known patterns and replaces
4
+ * content. The well known patterns are:
5
+ *
6
+ * 1. `x-release-please-version` if this string is found on the line,
7
+ * then replace a semver-looking string on that line with the next
8
+ * version
9
+ * 2. `x-release-please-major` if this string is found on the line,
10
+ * then replace an integer looking value with the the next version's
11
+ * major
12
+ * 3. `x-release-please-minor` if this string is found on the line,
13
+ * then replace an integer looking value with the the next version's
14
+ * minor
15
+ * 4. `x-release-please-patch` if this string is found on the line,
16
+ * then replace an integer looking value with the the next version's
17
+ * patch
18
+ *
19
+ * You can also use a block-based replacement. Content between the
20
+ * opening `x-release-please-start-version` and `x-release-please-end` will
21
+ * be considered for version replacement. You can also open these blocks
22
+ * with `x-release-please-start-<major|minor|patch>` to replace single
23
+ * numbers
24
+ */
25
+ export declare class Generic extends DefaultUpdater {
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: string | undefined): string;
32
+ }
@@ -0,0 +1,110 @@
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.Generic = void 0;
17
+ const default_1 = require("./default");
18
+ const logger_1 = require("../util/logger");
19
+ const VERSION_REGEX = /(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-(?<preRelease>[\w.]+))?(\+(?<build>[-\w.]+))?/;
20
+ const SINGLE_VERSION_REGEX = /\b\d+\b/;
21
+ const INLINE_UPDATE_REGEX = /x-release-please-(?<scope>major|minor|patch|version)/;
22
+ const BLOCK_START_REGEX = /x-release-please-start-(?<scope>major|minor|patch|version)/;
23
+ const BLOCK_END_REGEX = /x-release-please-end/;
24
+ /**
25
+ * The Generic updater looks for well known patterns and replaces
26
+ * content. The well known patterns are:
27
+ *
28
+ * 1. `x-release-please-version` if this string is found on the line,
29
+ * then replace a semver-looking string on that line with the next
30
+ * version
31
+ * 2. `x-release-please-major` if this string is found on the line,
32
+ * then replace an integer looking value with the the next version's
33
+ * major
34
+ * 3. `x-release-please-minor` if this string is found on the line,
35
+ * then replace an integer looking value with the the next version's
36
+ * minor
37
+ * 4. `x-release-please-patch` if this string is found on the line,
38
+ * then replace an integer looking value with the the next version's
39
+ * patch
40
+ *
41
+ * You can also use a block-based replacement. Content between the
42
+ * opening `x-release-please-start-version` and `x-release-please-end` will
43
+ * be considered for version replacement. You can also open these blocks
44
+ * with `x-release-please-start-<major|minor|patch>` to replace single
45
+ * numbers
46
+ */
47
+ class Generic extends default_1.DefaultUpdater {
48
+ /**
49
+ * Given initial file contents, return updated contents.
50
+ * @param {string} content The initial content
51
+ * @returns {string} The updated content
52
+ */
53
+ updateContent(content) {
54
+ if (!content) {
55
+ return '';
56
+ }
57
+ const newLines = [];
58
+ let blockScope;
59
+ function replaceVersion(line, scope, version) {
60
+ switch (scope) {
61
+ case 'major':
62
+ newLines.push(line.replace(SINGLE_VERSION_REGEX, `${version.major}`));
63
+ return;
64
+ case 'minor':
65
+ newLines.push(line.replace(SINGLE_VERSION_REGEX, `${version.minor}`));
66
+ return;
67
+ case 'patch':
68
+ newLines.push(line.replace(SINGLE_VERSION_REGEX, `${version.patch}`));
69
+ return;
70
+ case 'version':
71
+ newLines.push(line.replace(VERSION_REGEX, version.toString()));
72
+ return;
73
+ default:
74
+ logger_1.logger.warn(`unknown block scope: ${scope}`);
75
+ newLines.push(line);
76
+ }
77
+ }
78
+ content.split(/\r?\n/).forEach(line => {
79
+ var _a, _b;
80
+ let match = line.match(INLINE_UPDATE_REGEX);
81
+ if (match) {
82
+ // replace inline versions
83
+ replaceVersion(line, (((_a = match.groups) === null || _a === void 0 ? void 0 : _a.scope) || 'version'), this.version);
84
+ }
85
+ else if (blockScope) {
86
+ // in a block, so try to replace versions
87
+ replaceVersion(line, blockScope, this.version);
88
+ if (line.match(BLOCK_END_REGEX)) {
89
+ blockScope = undefined;
90
+ }
91
+ }
92
+ else {
93
+ // look for block start line
94
+ match = line.match(BLOCK_START_REGEX);
95
+ if (match) {
96
+ if ((_b = match.groups) === null || _b === void 0 ? void 0 : _b.scope) {
97
+ blockScope = match.groups.scope;
98
+ }
99
+ else {
100
+ blockScope = 'version';
101
+ }
102
+ }
103
+ newLines.push(line);
104
+ }
105
+ });
106
+ return newLines.join('\n');
107
+ }
108
+ }
109
+ exports.Generic = Generic;
110
+ //# sourceMappingURL=generic.js.map
@@ -28,7 +28,6 @@ class CargoToml extends default_1.DefaultUpdater {
28
28
  * @returns {string} The updated content
29
29
  */
30
30
  updateContent(content) {
31
- var _a;
32
31
  let payload = content;
33
32
  if (!this.versionsMap) {
34
33
  throw new Error('updateContent called with no versions');
@@ -39,12 +38,8 @@ class CargoToml extends default_1.DefaultUpdater {
39
38
  logger_1.logger.error(msg);
40
39
  throw new Error(msg);
41
40
  }
41
+ payload = toml_edit_1.replaceTomlValue(payload, ['package', 'version'], this.version.toString());
42
42
  for (const [pkgName, pkgVersion] of this.versionsMap) {
43
- if (parsed.package.name === pkgName) {
44
- logger_1.logger.info(`updating own version from ${(_a = parsed.package) === null || _a === void 0 ? void 0 : _a.version} to ${pkgVersion}`);
45
- payload = toml_edit_1.replaceTomlValue(payload, ['package', 'version'], pkgVersion.toString());
46
- continue; // to next [pkgName, pkgVersion] pair
47
- }
48
43
  for (const depKind of common_1.DEP_KINDS) {
49
44
  const deps = parsed[depKind];
50
45
  if (!deps) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "13.0.0",
3
+ "version": "13.1.1",
4
4
  "description": "generate release PRs based on the conventionalcommits.org spec",
5
5
  "main": "./build/src/index.js",
6
6
  "bin": "./build/src/bin/release-please.js",