release-please 13.4.3 → 13.4.7

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,36 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ### [13.4.7](https://github.com/googleapis/release-please/compare/v13.4.6...v13.4.7) (2022-02-02)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * php-yoshi strategy should handle custom changelog secctions ([#1277](https://github.com/googleapis/release-please/issues/1277)) ([bd74a5b](https://github.com/googleapis/release-please/commit/bd74a5b7b622a6cec0d64cbf9b9e01102dc835b2))
13
+
14
+ ### [13.4.6](https://github.com/googleapis/release-please/compare/v13.4.5...v13.4.6) (2022-02-01)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * cargo workspace cargo lock handling ([#1260](https://github.com/googleapis/release-please/issues/1260)) ([55e9d38](https://github.com/googleapis/release-please/commit/55e9d3822d4d36d3123231f22dccacf35910929e))
20
+ * krm blueprints should update yaml files ([#1269](https://github.com/googleapis/release-please/issues/1269)) ([d6ef98a](https://github.com/googleapis/release-please/commit/d6ef98a7031b599e38a505af2ffc51e85b3c6da6)), closes [#1268](https://github.com/googleapis/release-please/issues/1268)
21
+
22
+ ### [13.4.5](https://github.com/googleapis/release-please/compare/v13.4.4...v13.4.5) (2022-02-01)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * read packageName from config ([#1270](https://github.com/googleapis/release-please/issues/1270)) ([e953e1a](https://github.com/googleapis/release-please/commit/e953e1a387f6124fbacb7952b5451ca43bd498fa))
28
+
29
+ ### [13.4.4](https://github.com/googleapis/release-please/compare/v13.4.3...v13.4.4) (2022-01-26)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * delegate empty commit handling to strategies ([#1254](https://github.com/googleapis/release-please/issues/1254)) ([757f2a9](https://github.com/googleapis/release-please/commit/757f2a9304aec164632ee081b09d22595c5f1e67))
35
+ * extra file should include strategy path ([#1187](https://github.com/googleapis/release-please/issues/1187)) ([c8fffb0](https://github.com/googleapis/release-please/commit/c8fffb0bca7be83487e9d2e3257277e8650cdfaf))
36
+
7
37
  ### [13.4.3](https://github.com/googleapis/release-please/compare/v13.4.2...v13.4.3) (2022-01-24)
8
38
 
9
39
 
@@ -265,10 +265,6 @@ class Manifest {
265
265
  logger_1.logger.debug(`type: ${config.releaseType}`);
266
266
  logger_1.logger.debug(`targetBranch: ${this.targetBranch}`);
267
267
  const pathCommits = commitsAfterSha(path === exports.ROOT_PROJECT_PATH ? commits : commitsPerPath[path], releaseShasByPath[path]);
268
- if (!pathCommits || pathCommits.length === 0) {
269
- logger_1.logger.info(`No commits for path: ${path}, skipping`);
270
- continue;
271
- }
272
268
  logger_1.logger.debug(`commits: ${pathCommits.length}`);
273
269
  const latestReleasePullRequest = releasePullRequestsBySha[releaseShasByPath[path]];
274
270
  if (!latestReleasePullRequest) {
@@ -316,7 +312,6 @@ class Manifest {
316
312
  targetBranch: this.targetBranch,
317
313
  repositoryConfig: this.repositoryConfig,
318
314
  }));
319
- logger_1.logger.info(`separate pull requests: ${this.separatePullRequests}`);
320
315
  // Combine pull requests into 1 unless configured for separate
321
316
  // pull requests
322
317
  if (!this.separatePullRequests) {
@@ -45,6 +45,7 @@ export declare class CargoWorkspace extends WorkspacePlugin<CrateInfo> {
45
45
  protected bumpVersion(pkg: CrateInfo): Version;
46
46
  protected updateCandidate(existingCandidate: CandidateReleasePullRequest, pkg: CrateInfo, updatedVersions: VersionsMap): CandidateReleasePullRequest;
47
47
  protected newCandidate(pkg: CrateInfo, updatedVersions: VersionsMap): CandidateReleasePullRequest;
48
+ protected postProcessCandidates(candidates: CandidateReleasePullRequest[], updatedVersions: VersionsMap): CandidateReleasePullRequest[];
48
49
  protected buildGraph(allPackages: CrateInfo[]): Promise<DependencyGraph<CrateInfo>>;
49
50
  protected inScope(candidate: CandidateReleasePullRequest): boolean;
50
51
  protected packageNameFromPackage(pkg: CrateInfo): string;
@@ -113,10 +113,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
113
113
  update.updater.changelogEntry = appendDependenciesSectionToChangelog(update.updater.changelogEntry, dependencyNotes);
114
114
  }
115
115
  else if (update.path === addPath(existingCandidate.path, 'Cargo.lock')) {
116
- update.updater = new cargo_lock_1.CargoLock({
117
- version,
118
- versionsMap: updatedVersions,
119
- });
116
+ update.updater = new cargo_lock_1.CargoLock(updatedVersions);
120
117
  }
121
118
  return update;
122
119
  });
@@ -186,6 +183,18 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
186
183
  },
187
184
  };
188
185
  }
186
+ postProcessCandidates(candidates, updatedVersions) {
187
+ const rootCandidate = candidates.find(c => c.path === manifest_1.ROOT_PROJECT_PATH);
188
+ if (!rootCandidate) {
189
+ throw Error('Unable to find root candidate pull request');
190
+ }
191
+ rootCandidate.pullRequest.updates.push({
192
+ path: 'Cargo.lock',
193
+ createIfMissing: false,
194
+ updater: new cargo_lock_1.CargoLock(updatedVersions),
195
+ });
196
+ return candidates;
197
+ }
189
198
  async buildGraph(allPackages) {
190
199
  var _a, _b, _c;
191
200
  const workspaceCrateNames = new Set(allPackages.map(crateInfo => crateInfo.name));
@@ -29,6 +29,7 @@ export declare class NodeWorkspace extends WorkspacePlugin<Package> {
29
29
  protected bumpVersion(pkg: Package): Version;
30
30
  protected updateCandidate(existingCandidate: CandidateReleasePullRequest, pkg: Package, updatedVersions: VersionsMap): CandidateReleasePullRequest;
31
31
  protected newCandidate(pkg: Package, updatedVersions: VersionsMap): CandidateReleasePullRequest;
32
+ protected postProcessCandidates(candidates: CandidateReleasePullRequest[], _updatedVersions: VersionsMap): CandidateReleasePullRequest[];
32
33
  protected buildGraph(allPackages: Package[]): Promise<DependencyGraph<Package>>;
33
34
  protected inScope(candidate: CandidateReleasePullRequest): boolean;
34
35
  protected packageNameFromPackage(pkg: Package): string;
@@ -190,6 +190,10 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
190
190
  },
191
191
  };
192
192
  }
193
+ postProcessCandidates(candidates, _updatedVersions) {
194
+ // NOP for node workspaces
195
+ return candidates;
196
+ }
193
197
  async buildGraph(allPackages) {
194
198
  var _a, _b, _c, _d;
195
199
  const graph = new Map();
@@ -83,6 +83,19 @@ export declare abstract class WorkspacePlugin<T> extends ManifestPlugin {
83
83
  * @returns {string} The package name.
84
84
  */
85
85
  protected abstract packageNameFromPackage(pkg: T): string;
86
+ /**
87
+ * Amend any or all in-scope candidates once all other processing has occured.
88
+ *
89
+ * This gives the workspace plugin once last chance to tweak the pull-requests
90
+ * once all the underlying information has been collated.
91
+ * @param {CandidateReleasePullRequest[]} candidates - The list of candidates
92
+ * once all other workspace processing has occured.
93
+ * @param {VersionMap} updatedVersions - Map containing any component versions
94
+ * that have changed.
95
+ * @returns {CandidateReleasePullRequest[]} potentially amended list of
96
+ * candidates.
97
+ */
98
+ protected abstract postProcessCandidates(candidates: CandidateReleasePullRequest[], updatedVersions: VersionsMap): CandidateReleasePullRequest[];
86
99
  /**
87
100
  * Helper to invert the graph from package => packages that it depends on
88
101
  * to package => packages that depend on it.
@@ -98,6 +98,8 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
98
98
  logger_1.logger.info(`Merging ${newCandidates.length} in-scope candidates`);
99
99
  const mergePlugin = new merge_1.Merge(this.github, this.targetBranch, this.repositoryConfig);
100
100
  newCandidates = await mergePlugin.run(newCandidates);
101
+ logger_1.logger.info(`Post-processing ${newCandidates.length} in-scope candidates`);
102
+ newCandidates = this.postProcessCandidates(newCandidates, updatedVersions);
101
103
  return [...outOfScopeCandidates, ...newCandidates];
102
104
  }
103
105
  /**
@@ -47,7 +47,7 @@ export declare abstract class BaseStrategy implements Strategy {
47
47
  readonly path: string;
48
48
  protected github: GitHub;
49
49
  protected component?: string;
50
- protected packageName?: string;
50
+ private packageName?;
51
51
  readonly versioningStrategy: VersioningStrategy;
52
52
  protected targetBranch: string;
53
53
  protected repository: Repository;
@@ -72,6 +72,7 @@ export declare abstract class BaseStrategy implements Strategy {
72
72
  */
73
73
  getComponent(): Promise<string | undefined>;
74
74
  getDefaultComponent(): Promise<string | undefined>;
75
+ getPackageName(): Promise<string | undefined>;
75
76
  getDefaultPackageName(): Promise<string | undefined>;
76
77
  protected normalizeComponent(component: string | undefined): string;
77
78
  /**
@@ -110,5 +111,11 @@ export declare abstract class BaseStrategy implements Strategy {
110
111
  * Override this to handle the initial version of a new library.
111
112
  */
112
113
  protected initialReleaseVersion(): Version;
114
+ /**
115
+ * Adds a given file path to the strategy path.
116
+ * @param {string} file Desired file path.
117
+ * @returns {string} The file relative to the strategy.
118
+ * @throws {Error} If the file path contains relative pathing characters, i.e. ../, ~/
119
+ */
113
120
  protected addPath(file: string): string;
114
121
  }
@@ -65,10 +65,16 @@ class BaseStrategy {
65
65
  return this.component || (await this.getDefaultComponent());
66
66
  }
67
67
  async getDefaultComponent() {
68
- return this.normalizeComponent(await this.getDefaultPackageName());
68
+ var _a;
69
+ return this.normalizeComponent((_a = this.packageName) !== null && _a !== void 0 ? _a : (await this.getDefaultPackageName()));
70
+ }
71
+ async getPackageName() {
72
+ var _a;
73
+ return (_a = this.packageName) !== null && _a !== void 0 ? _a : (await this.getDefaultPackageName());
69
74
  }
70
75
  async getDefaultPackageName() {
71
- return '';
76
+ var _a;
77
+ return (_a = this.packageName) !== null && _a !== void 0 ? _a : '';
72
78
  }
73
79
  normalizeComponent(component) {
74
80
  if (!component) {
@@ -119,6 +125,10 @@ class BaseStrategy {
119
125
  async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
120
126
  const conventionalCommits = await this.postProcessCommits(commit_1.parseConventionalCommits(commits));
121
127
  logger_1.logger.info(`Considering: ${conventionalCommits.length} commits`);
128
+ if (conventionalCommits.length === 0) {
129
+ logger_1.logger.info(`No commits for path: ${this.path}, skipping`);
130
+ return undefined;
131
+ }
122
132
  const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease);
123
133
  const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits);
124
134
  const component = await this.getComponent();
@@ -154,13 +164,11 @@ class BaseStrategy {
154
164
  }
155
165
  extraFileUpdates(version) {
156
166
  const genericUpdater = new generic_1.Generic({ version });
157
- return this.extraFiles.map(path => {
158
- return {
159
- path,
160
- createIfMissing: false,
161
- updater: genericUpdater,
162
- };
163
- });
167
+ return this.extraFiles.map(path => ({
168
+ path: this.addPath(path),
169
+ createIfMissing: false,
170
+ updater: genericUpdater,
171
+ }));
164
172
  }
165
173
  changelogEmpty(changelogEntry) {
166
174
  return changelogEntry.split('\n').length <= 1;
@@ -265,18 +273,28 @@ class BaseStrategy {
265
273
  initialReleaseVersion() {
266
274
  return version_1.Version.parse('1.0.0');
267
275
  }
276
+ /**
277
+ * Adds a given file path to the strategy path.
278
+ * @param {string} file Desired file path.
279
+ * @returns {string} The file relative to the strategy.
280
+ * @throws {Error} If the file path contains relative pathing characters, i.e. ../, ~/
281
+ */
268
282
  addPath(file) {
269
- if (this.path === manifest_1.ROOT_PROJECT_PATH) {
270
- return file;
271
- }
272
- file = file.replace(/^[/\\]/, '');
273
- if (this.path === undefined) {
274
- return file;
283
+ // There is no strategy path to join, the strategy is at the root, or the
284
+ // file is at the root (denoted by a leading slash or tilde)
285
+ if (!this.path || this.path === manifest_1.ROOT_PROJECT_PATH || file.startsWith('/')) {
286
+ file = file.replace(/^\/+/, '');
275
287
  }
288
+ // Otherwise, the file is relative to the strategy path
276
289
  else {
277
- const path = this.path.replace(/[/\\]$/, '');
278
- return `${path}/${file}`;
290
+ file = `${this.path.replace(/\/+$/, '')}/${file}`;
291
+ }
292
+ // Ensure the file path does not escape the workspace
293
+ if (/((^|\/)\.{1,2}|^~|^\/*)+\//.test(file)) {
294
+ throw new Error(`illegal pathing characters in path: ${file}`);
279
295
  }
296
+ // Strip any trailing slashes and return
297
+ return file.replace(/\/+$/, '');
280
298
  }
281
299
  }
282
300
  exports.BaseStrategy = BaseStrategy;
@@ -14,6 +14,12 @@ export declare class JavaYoshi extends BaseStrategy {
14
14
  constructor(options: BaseStrategyOptions);
15
15
  buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
16
16
  private buildSnapshotPullRequest;
17
+ /**
18
+ * Override this method to post process commits
19
+ * @param {ConventionalCommit[]} commits parsed commits
20
+ * @returns {ConventionalCommit[]} modified commits
21
+ */
22
+ protected postProcessCommits(commits: ConventionalCommit[]): Promise<ConventionalCommit[]>;
17
23
  private needsSnapshot;
18
24
  protected buildVersionsMap(): Promise<VersionsMap>;
19
25
  protected getVersionsContent(): Promise<GitHubFileContents>;
@@ -102,6 +102,29 @@ class JavaYoshi extends base_1.BaseStrategy {
102
102
  draft: false,
103
103
  };
104
104
  }
105
+ /**
106
+ * Override this method to post process commits
107
+ * @param {ConventionalCommit[]} commits parsed commits
108
+ * @returns {ConventionalCommit[]} modified commits
109
+ */
110
+ async postProcessCommits(commits) {
111
+ if (commits.length === 0) {
112
+ // For Java commits, push a fake commit so we force a
113
+ // SNAPSHOT release
114
+ commits.push({
115
+ type: 'fake',
116
+ bareMessage: 'fake commit',
117
+ message: 'fake commit',
118
+ breaking: false,
119
+ scope: null,
120
+ notes: [],
121
+ files: [],
122
+ references: [],
123
+ sha: 'fake',
124
+ });
125
+ }
126
+ return commits;
127
+ }
105
128
  async needsSnapshot() {
106
129
  return versions_manifest_1.VersionsManifest.needsSnapshot((await this.getVersionsContent()).parsedContent);
107
130
  }
@@ -21,9 +21,10 @@ const changelog_1 = require("../updaters/changelog");
21
21
  const package_json_1 = require("../updaters/node/package-json");
22
22
  class Node extends base_1.BaseStrategy {
23
23
  async buildUpdates(options) {
24
+ var _a;
24
25
  const updates = [];
25
26
  const version = options.newVersion;
26
- const packageName = this.component || '';
27
+ const packageName = (_a = (await this.getPackageName())) !== null && _a !== void 0 ? _a : '';
27
28
  const lockFiles = ['package-lock.json', 'npm-shrinkwrap.json'];
28
29
  lockFiles.forEach(lockFile => {
29
30
  updates.push({
@@ -6,7 +6,7 @@ import { ReleasePullRequest } from '../release-pull-request';
6
6
  import { PullRequestBody } from '../util/pull-request-body';
7
7
  export declare class PHPYoshi extends BaseStrategy {
8
8
  constructor(options: BaseStrategyOptions);
9
- buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest>;
9
+ buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
10
10
  protected parsePullRequestBody(pullRequestBody: string): Promise<PullRequestBody | undefined>;
11
11
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
12
12
  }
@@ -51,6 +51,10 @@ class PHPYoshi extends base_1.BaseStrategy {
51
51
  async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
52
52
  var _a, _b, _c;
53
53
  const conventionalCommits = await this.postProcessCommits(commit_1.parseConventionalCommits(commits));
54
+ if (conventionalCommits.length === 0) {
55
+ logger_1.logger.info(`No commits for path: ${this.path}, skipping`);
56
+ return undefined;
57
+ }
54
58
  const newVersion = latestRelease
55
59
  ? await this.versioningStrategy.bump(latestRelease.tag.version, conventionalCommits)
56
60
  : this.initialReleaseVersion();
@@ -80,6 +84,7 @@ class PHPYoshi extends base_1.BaseStrategy {
80
84
  previousTag: (_a = latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag) === null || _a === void 0 ? void 0 : _a.toString(),
81
85
  currentTag: newVersionTag.toString(),
82
86
  targetBranch: this.targetBranch,
87
+ changelogSections: this.changelogSections,
83
88
  });
84
89
  releaseNotesBody = updatePHPChangelogEntry(`${composer.name} ${newVersion.toString()}`, releaseNotesBody, partialReleaseNotes);
85
90
  }
@@ -102,10 +102,7 @@ class Rust extends base_1.BaseStrategy {
102
102
  updates.push({
103
103
  path: this.addPath('Cargo.lock'),
104
104
  createIfMissing: false,
105
- updater: new cargo_lock_1.CargoLock({
106
- version,
107
- versionsMap,
108
- }),
105
+ updater: new cargo_lock_1.CargoLock(versionsMap),
109
106
  });
110
107
  return updates;
111
108
  }
@@ -32,7 +32,7 @@ class KRMBlueprintVersion extends default_1.DefaultUpdater {
32
32
  let matchRegex = '(cnrm/.*/)(v[0-9]+.[0-9]+.[0-9]+)+(-w+)?';
33
33
  // if explicit previous version, match only that version
34
34
  if ((_a = this.versionsMap) === null || _a === void 0 ? void 0 : _a.has('previousVersion')) {
35
- matchRegex = `(cnrm/.*/)(${this.versionsMap.get('previousVersion')})+(-w+)?`;
35
+ matchRegex = `(cnrm/.*/)(v${this.versionsMap.get('previousVersion')})+(-w+)?`;
36
36
  }
37
37
  const oldVersion = content.match(new RegExp(matchRegex));
38
38
  if (oldVersion) {
@@ -1,8 +1,11 @@
1
- import { DefaultUpdater } from '../default';
1
+ import { Updater } from '../../update';
2
+ import { VersionsMap } from '../../version';
2
3
  /**
3
4
  * Updates `Cargo.lock` lockfiles, preserving formatting and comments.
4
5
  */
5
- export declare class CargoLock extends DefaultUpdater {
6
+ export declare class CargoLock implements Updater {
7
+ versionsMap: VersionsMap;
8
+ constructor(versionsMap: VersionsMap);
6
9
  /**
7
10
  * Given initial file contents, return updated contents.
8
11
  * @param {string} content The initial content
@@ -17,11 +17,13 @@ exports.CargoLock = void 0;
17
17
  const toml_edit_1 = require("../../util/toml-edit");
18
18
  const common_1 = require("./common");
19
19
  const logger_1 = require("../../util/logger");
20
- const default_1 = require("../default");
21
20
  /**
22
21
  * Updates `Cargo.lock` lockfiles, preserving formatting and comments.
23
22
  */
24
- class CargoLock extends default_1.DefaultUpdater {
23
+ class CargoLock {
24
+ constructor(versionsMap) {
25
+ this.versionsMap = versionsMap;
26
+ }
25
27
  /**
26
28
  * Given initial file contents, return updated contents.
27
29
  * @param {string} content The initial content
@@ -29,9 +31,6 @@ class CargoLock extends default_1.DefaultUpdater {
29
31
  */
30
32
  updateContent(content) {
31
33
  let payload = content;
32
- if (!this.versionsMap) {
33
- throw new Error('updateContent called with no versions');
34
- }
35
34
  const parsed = common_1.parseCargoLockfile(payload);
36
35
  if (!parsed.package) {
37
36
  logger_1.logger.error('is not a Cargo lockfile');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "13.4.3",
3
+ "version": "13.4.7",
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",
@@ -53,7 +53,7 @@
53
53
  "gts": "^3.0.0",
54
54
  "mocha": "^9.0.0",
55
55
  "nock": "^13.0.0",
56
- "sinon": "12.0.1",
56
+ "sinon": "13.0.1",
57
57
  "snap-shot-it": "^7.0.0"
58
58
  },
59
59
  "dependencies": {