release-please 13.4.1 → 13.4.5

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.5](https://github.com/googleapis/release-please/compare/v13.4.4...v13.4.5) (2022-02-01)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * read packageName from config ([#1270](https://github.com/googleapis/release-please/issues/1270)) ([e953e1a](https://github.com/googleapis/release-please/commit/e953e1a387f6124fbacb7952b5451ca43bd498fa))
13
+
14
+ ### [13.4.4](https://github.com/googleapis/release-please/compare/v13.4.3...v13.4.4) (2022-01-26)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * delegate empty commit handling to strategies ([#1254](https://github.com/googleapis/release-please/issues/1254)) ([757f2a9](https://github.com/googleapis/release-please/commit/757f2a9304aec164632ee081b09d22595c5f1e67))
20
+ * extra file should include strategy path ([#1187](https://github.com/googleapis/release-please/issues/1187)) ([c8fffb0](https://github.com/googleapis/release-please/commit/c8fffb0bca7be83487e9d2e3257277e8650cdfaf))
21
+
22
+ ### [13.4.3](https://github.com/googleapis/release-please/compare/v13.4.2...v13.4.3) (2022-01-24)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * multi-component manifest release notes for single component release ([#1247](https://github.com/googleapis/release-please/issues/1247)) ([16aee09](https://github.com/googleapis/release-please/commit/16aee099c79d75853e565f83017745eef13b57fa))
28
+ * release notes should parse initial version heading ([#1248](https://github.com/googleapis/release-please/issues/1248)) ([71dc495](https://github.com/googleapis/release-please/commit/71dc4954e2393f74c4442c021fcf6c8ee530b4ae))
29
+
30
+ ### [13.4.2](https://github.com/googleapis/release-please/compare/v13.4.1...v13.4.2) (2022-01-21)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * Manifest.fromFile no longer ignores manifestFile arg ([#1243](https://github.com/googleapis/release-please/issues/1243)) ([04a44ab](https://github.com/googleapis/release-please/commit/04a44ab08e8ce3911ad814744cebb79aab2ef8aa))
36
+
7
37
  ### [13.4.1](https://github.com/googleapis/release-please/compare/v13.4.0...v13.4.1) (2022-01-20)
8
38
 
9
39
 
@@ -93,7 +93,11 @@ class Manifest {
93
93
  parseConfig(github, configFile, targetBranch),
94
94
  parseReleasedVersions(github, manifestFile, targetBranch),
95
95
  ]);
96
- return new Manifest(github, targetBranch, repositoryConfig, releasedVersions, { ...manifestOptions, ...manifestOptionOverrides });
96
+ return new Manifest(github, targetBranch, repositoryConfig, releasedVersions, {
97
+ manifestPath: manifestFile,
98
+ ...manifestOptions,
99
+ ...manifestOptionOverrides,
100
+ });
97
101
  }
98
102
  /**
99
103
  * Create a Manifest from explicit config in code. This assumes that the
@@ -261,10 +265,6 @@ class Manifest {
261
265
  logger_1.logger.debug(`type: ${config.releaseType}`);
262
266
  logger_1.logger.debug(`targetBranch: ${this.targetBranch}`);
263
267
  const pathCommits = commitsAfterSha(path === exports.ROOT_PROJECT_PATH ? commits : commitsPerPath[path], releaseShasByPath[path]);
264
- if (!pathCommits || pathCommits.length === 0) {
265
- logger_1.logger.info(`No commits for path: ${path}, skipping`);
266
- continue;
267
- }
268
268
  logger_1.logger.debug(`commits: ${pathCommits.length}`);
269
269
  const latestReleasePullRequest = releasePullRequestsBySha[releaseShasByPath[path]];
270
270
  if (!latestReleasePullRequest) {
@@ -20,6 +20,7 @@ const pull_request_title_1 = require("../util/pull-request-title");
20
20
  const pull_request_body_1 = require("../util/pull-request-body");
21
21
  const branch_name_1 = require("../util/branch-name");
22
22
  const composite_1 = require("../updaters/composite");
23
+ const logger_1 = require("../util/logger");
23
24
  /**
24
25
  * This plugin merges multiple pull requests into a single
25
26
  * release pull request.
@@ -36,6 +37,7 @@ class Merge extends plugin_1.ManifestPlugin {
36
37
  if (candidates.length < 1) {
37
38
  return candidates;
38
39
  }
40
+ logger_1.logger.info(`Merging ${candidates.length} pull requests`);
39
41
  const releaseData = [];
40
42
  const labels = new Set();
41
43
  let rawUpdates = [];
@@ -54,7 +56,7 @@ class Merge extends plugin_1.ManifestPlugin {
54
56
  const updates = composite_1.mergeUpdates(rawUpdates);
55
57
  const pullRequest = {
56
58
  title: pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(rootRelease === null || rootRelease === void 0 ? void 0 : rootRelease.pullRequest.title.component, this.targetBranch, rootRelease === null || rootRelease === void 0 ? void 0 : rootRelease.pullRequest.title.version, this.pullRequestTitlePattern),
57
- body: new pull_request_body_1.PullRequestBody(releaseData),
59
+ body: new pull_request_body_1.PullRequestBody(releaseData, { useComponents: true }),
58
60
  updates,
59
61
  labels: Array.from(labels),
60
62
  headRefName: branch_name_1.BranchName.ofTargetBranch(this.targetBranch).toString(),
@@ -110,5 +110,11 @@ export declare abstract class BaseStrategy implements Strategy {
110
110
  * Override this to handle the initial version of a new library.
111
111
  */
112
112
  protected initialReleaseVersion(): Version;
113
+ /**
114
+ * Adds a given file path to the strategy path.
115
+ * @param {string} file Desired file path.
116
+ * @returns {string} The file relative to the strategy.
117
+ * @throws {Error} If the file path contains relative pathing characters, i.e. ../, ~/
118
+ */
113
119
  protected addPath(file: string): string;
114
120
  }
@@ -65,7 +65,8 @@ 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()));
69
70
  }
70
71
  async getDefaultPackageName() {
71
72
  return '';
@@ -117,10 +118,17 @@ class BaseStrategy {
117
118
  * open a pull request.
118
119
  */
119
120
  async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
121
+ var _a;
120
122
  const conventionalCommits = await this.postProcessCommits(commit_1.parseConventionalCommits(commits));
121
123
  logger_1.logger.info(`Considering: ${conventionalCommits.length} commits`);
124
+ if (conventionalCommits.length === 0) {
125
+ logger_1.logger.info(`No commits for path: ${this.path}, skipping`);
126
+ return undefined;
127
+ }
122
128
  const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease);
123
129
  const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits);
130
+ this.packageName = (_a = this.packageName) !== null && _a !== void 0 ? _a : (await this.getDefaultPackageName());
131
+ logger_1.logger.debug('packageName', this.packageName);
124
132
  const component = await this.getComponent();
125
133
  logger_1.logger.debug('component:', component);
126
134
  const newVersionTag = new tag_name_1.TagName(newVersion, this.includeComponentInTag ? component : undefined, this.tagSeparator);
@@ -154,13 +162,11 @@ class BaseStrategy {
154
162
  }
155
163
  extraFileUpdates(version) {
156
164
  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
- });
165
+ return this.extraFiles.map(path => ({
166
+ path: this.addPath(path),
167
+ createIfMissing: false,
168
+ updater: genericUpdater,
169
+ }));
164
170
  }
165
171
  changelogEmpty(changelogEntry) {
166
172
  return changelogEntry.split('\n').length <= 1;
@@ -265,18 +271,28 @@ class BaseStrategy {
265
271
  initialReleaseVersion() {
266
272
  return version_1.Version.parse('1.0.0');
267
273
  }
274
+ /**
275
+ * Adds a given file path to the strategy path.
276
+ * @param {string} file Desired file path.
277
+ * @returns {string} The file relative to the strategy.
278
+ * @throws {Error} If the file path contains relative pathing characters, i.e. ../, ~/
279
+ */
268
280
  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;
281
+ // There is no strategy path to join, the strategy is at the root, or the
282
+ // file is at the root (denoted by a leading slash or tilde)
283
+ if (!this.path || this.path === manifest_1.ROOT_PROJECT_PATH || file.startsWith('/')) {
284
+ file = file.replace(/^\/+/, '');
275
285
  }
286
+ // Otherwise, the file is relative to the strategy path
276
287
  else {
277
- const path = this.path.replace(/[/\\]$/, '');
278
- return `${path}/${file}`;
288
+ file = `${this.path.replace(/\/+$/, '')}/${file}`;
289
+ }
290
+ // Ensure the file path does not escape the workspace
291
+ if (/((^|\/)\.{1,2}|^~|^\/*)+\//.test(file)) {
292
+ throw new Error(`illegal pathing characters in path: ${file}`);
279
293
  }
294
+ // Strip any trailing slashes and return
295
+ return file.replace(/\/+$/, '');
280
296
  }
281
297
  }
282
298
  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
  }
@@ -23,7 +23,7 @@ class Node extends base_1.BaseStrategy {
23
23
  async buildUpdates(options) {
24
24
  const updates = [];
25
25
  const version = options.newVersion;
26
- const packageName = this.component || '';
26
+ const packageName = this.packageName || '';
27
27
  const lockFiles = ['package-lock.json', 'npm-shrinkwrap.json'];
28
28
  lockFiles.forEach(lockFile => {
29
29
  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();
@@ -3,12 +3,14 @@ interface PullRequestBodyOptions {
3
3
  header?: string;
4
4
  footer?: string;
5
5
  extra?: string;
6
+ useComponents?: boolean;
6
7
  }
7
8
  export declare class PullRequestBody {
8
9
  header: string;
9
10
  footer: string;
10
11
  extra?: string;
11
12
  releaseData: ReleaseData[];
13
+ useComponents: boolean;
12
14
  constructor(releaseData: ReleaseData[], options?: PullRequestBodyOptions);
13
15
  static parse(body: string): PullRequestBody | undefined;
14
16
  notes(): string;
@@ -22,10 +22,12 @@ const DEFAULT_FOOTER = 'This PR was generated with [Release Please](https://gith
22
22
  const NOTES_DELIMITER = '---';
23
23
  class PullRequestBody {
24
24
  constructor(releaseData, options) {
25
+ var _a;
25
26
  this.header = (options === null || options === void 0 ? void 0 : options.header) || DEFAULT_HEADER;
26
27
  this.footer = (options === null || options === void 0 ? void 0 : options.footer) || DEFAULT_FOOTER;
27
28
  this.extra = options === null || options === void 0 ? void 0 : options.extra;
28
29
  this.releaseData = releaseData;
30
+ this.useComponents = (_a = options === null || options === void 0 ? void 0 : options.useComponents) !== null && _a !== void 0 ? _a : this.releaseData.length > 1;
29
31
  }
30
32
  static parse(body) {
31
33
  const parts = splitBody(body);
@@ -46,7 +48,7 @@ class PullRequestBody {
46
48
  });
47
49
  }
48
50
  notes() {
49
- if (this.releaseData.length > 1) {
51
+ if (this.useComponents) {
50
52
  return this.releaseData
51
53
  .map(release => {
52
54
  var _a;
@@ -110,7 +112,7 @@ function extractMultipleReleases(notes) {
110
112
  }
111
113
  return data;
112
114
  }
113
- const COMPARE_REGEX = /^#{2,} \[(?<version>\d+\.\d+\.\d+.*)\]/;
115
+ const COMPARE_REGEX = /^#{2,} \[?(?<version>\d+\.\d+\.\d+.*)\]?/;
114
116
  function extractSingleRelease(body) {
115
117
  var _a;
116
118
  body = body.trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "13.4.1",
3
+ "version": "13.4.5",
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.0",
57
57
  "snap-shot-it": "^7.0.0"
58
58
  },
59
59
  "dependencies": {