release-please 16.5.0 → 16.6.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.
@@ -43,12 +43,14 @@ class GitHub {
43
43
  this.getCommitFiles = wrapAsync(async (sha) => {
44
44
  this.logger.debug(`Backfilling file list for commit: ${sha}`);
45
45
  const files = [];
46
- for await (const resp of this.octokit.paginate.iterator(this.octokit.repos.getCommit, {
46
+ for await (const resp of this.octokit.paginate.iterator('GET /repos/{owner}/{repo}/commits/{ref}', {
47
47
  owner: this.repository.owner,
48
48
  repo: this.repository.repo,
49
49
  ref: sha,
50
50
  })) {
51
- for (const f of resp.data.files || []) {
51
+ // Paginate plugin doesn't have types for listing files on a commit
52
+ const data = resp.data;
53
+ for (const f of data.files || []) {
52
54
  if (f.filename) {
53
55
  files.push(f.filename);
54
56
  }
@@ -711,7 +713,7 @@ class GitHub {
711
713
  MERGED: 'closed',
712
714
  };
713
715
  let results = 0;
714
- for await (const { data: pulls } of this.octokit.paginate.iterator(this.octokit.rest.pulls.list, {
716
+ for await (const { data: pulls } of this.octokit.paginate.iterator('GET /repos/{owner}/{repo}/pulls', {
715
717
  state: statusMap[status],
716
718
  owner: this.repository.owner,
717
719
  repo: this.repository.repo,
@@ -921,7 +923,7 @@ class GitHub {
921
923
  async *tagIterator(options = {}) {
922
924
  const maxResults = options.maxResults || Number.MAX_SAFE_INTEGER;
923
925
  let results = 0;
924
- for await (const response of this.octokit.paginate.iterator(this.octokit.rest.repos.listTags, {
926
+ for await (const response of this.octokit.paginate.iterator('GET /repos/{owner}/{repo}/tags', {
925
927
  owner: this.repository.owner,
926
928
  repo: this.repository.repo,
927
929
  })) {
@@ -14,4 +14,4 @@ export { Logger, setLogger } from './util/logger';
14
14
  export { GitHub } from './github';
15
15
  export declare const configSchema: any;
16
16
  export declare const manifestSchema: any;
17
- export declare const VERSION = "16.5.0";
17
+ export declare const VERSION = "16.5.1";
@@ -36,6 +36,6 @@ Object.defineProperty(exports, "GitHub", { enumerable: true, get: function () {
36
36
  exports.configSchema = require('../../schemas/config.json');
37
37
  exports.manifestSchema = require('../../schemas/manifest.json');
38
38
  // x-release-please-start-version
39
- exports.VERSION = '16.5.0';
39
+ exports.VERSION = '16.5.1';
40
40
  // x-release-please-end
41
41
  //# sourceMappingURL=index.js.map
@@ -42,7 +42,7 @@ export declare class CargoWorkspace extends WorkspacePlugin<CrateInfo> {
42
42
  }>;
43
43
  protected bumpVersion(pkg: CrateInfo): Version;
44
44
  protected updateCandidate(existingCandidate: CandidateReleasePullRequest, pkg: CrateInfo, updatedVersions: VersionsMap): CandidateReleasePullRequest;
45
- protected newCandidate(pkg: CrateInfo, updatedVersions: VersionsMap): CandidateReleasePullRequest;
45
+ protected newCandidate(pkg: CrateInfo, updatedVersions: VersionsMap): Promise<CandidateReleasePullRequest>;
46
46
  protected postProcessCandidates(candidates: CandidateReleasePullRequest[], updatedVersions: VersionsMap): CandidateReleasePullRequest[];
47
47
  protected buildGraph(allPackages: CrateInfo[]): Promise<DependencyGraph<CrateInfo>>;
48
48
  protected inScope(candidate: CandidateReleasePullRequest): boolean;
@@ -130,7 +130,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
130
130
  }
131
131
  return existingCandidate;
132
132
  }
133
- newCandidate(pkg, updatedVersions) {
133
+ async newCandidate(pkg, updatedVersions) {
134
134
  const version = updatedVersions.get(pkg.name);
135
135
  if (!version) {
136
136
  throw new Error(`Didn't find updated version for ${pkg.name}`);
@@ -72,7 +72,7 @@ export declare class MavenWorkspace extends WorkspacePlugin<MavenArtifact> {
72
72
  protected isReleaseVersion(version: Version): boolean;
73
73
  protected bumpVersion(artifact: MavenArtifact): Version;
74
74
  protected updateCandidate(existingCandidate: CandidateReleasePullRequest, artifact: MavenArtifact, updatedVersions: VersionsMap): CandidateReleasePullRequest;
75
- protected newCandidate(artifact: MavenArtifact, updatedVersions: VersionsMap): CandidateReleasePullRequest;
75
+ protected newCandidate(artifact: MavenArtifact, updatedVersions: VersionsMap): Promise<CandidateReleasePullRequest>;
76
76
  protected inScope(candidate: CandidateReleasePullRequest): boolean;
77
77
  protected packageNameFromPackage(artifact: MavenArtifact): string;
78
78
  protected pathFromPackage(artifact: MavenArtifact): string;
@@ -266,7 +266,7 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin {
266
266
  }
267
267
  return existingCandidate;
268
268
  }
269
- newCandidate(artifact, updatedVersions) {
269
+ async newCandidate(artifact, updatedVersions) {
270
270
  const version = updatedVersions.get(artifact.name);
271
271
  if (!version) {
272
272
  throw new Error(`Didn't find updated version for ${artifact.name}`);
@@ -2,6 +2,9 @@ import { GitHub } from '../github';
2
2
  import { CandidateReleasePullRequest, RepositoryConfig } from '../manifest';
3
3
  import { Version, VersionsMap } from '../version';
4
4
  import { WorkspacePlugin, DependencyGraph, WorkspacePluginOptions } from './workspace';
5
+ import { Strategy } from '../strategy';
6
+ import { Commit } from '../commit';
7
+ import { Release } from '../release';
5
8
  interface Package {
6
9
  path: string;
7
10
  name: string;
@@ -25,6 +28,8 @@ interface NodeWorkspaceOptions extends WorkspacePluginOptions {
25
28
  */
26
29
  export declare class NodeWorkspace extends WorkspacePlugin<Package> {
27
30
  private alwaysLinkLocal;
31
+ private strategiesByPath;
32
+ private releasesByPath;
28
33
  readonly updatePeerDependencies: boolean;
29
34
  constructor(github: GitHub, targetBranch: string, repositoryConfig: RepositoryConfig, options?: NodeWorkspaceOptions);
30
35
  protected buildAllPackages(candidates: CandidateReleasePullRequest[]): Promise<{
@@ -33,12 +38,13 @@ export declare class NodeWorkspace extends WorkspacePlugin<Package> {
33
38
  }>;
34
39
  protected bumpVersion(pkg: Package): Version;
35
40
  protected updateCandidate(existingCandidate: CandidateReleasePullRequest, pkg: Package, updatedVersions: VersionsMap): CandidateReleasePullRequest;
36
- protected newCandidate(pkg: Package, updatedVersions: VersionsMap): CandidateReleasePullRequest;
41
+ protected newCandidate(pkg: Package, updatedVersions: VersionsMap): Promise<CandidateReleasePullRequest>;
37
42
  protected postProcessCandidates(candidates: CandidateReleasePullRequest[], _updatedVersions: VersionsMap): CandidateReleasePullRequest[];
38
43
  protected buildGraph(allPackages: Package[]): Promise<DependencyGraph<Package>>;
39
44
  protected inScope(candidate: CandidateReleasePullRequest): boolean;
40
45
  protected packageNameFromPackage(pkg: Package): string;
41
46
  protected pathFromPackage(pkg: Package): string;
42
47
  private combineDeps;
48
+ preconfigure(strategiesByPath: Record<string, Strategy>, _commitsByPath: Record<string, Commit[]>, _releasesByPath: Record<string, Release>): Promise<Record<string, Strategy>>;
43
49
  }
44
50
  export {};
@@ -33,6 +33,8 @@ const package_json_1 = require("../updaters/node/package-json");
33
33
  class NodeWorkspace extends workspace_1.WorkspacePlugin {
34
34
  constructor(github, targetBranch, repositoryConfig, options = {}) {
35
35
  super(github, targetBranch, repositoryConfig, options);
36
+ this.strategiesByPath = {};
37
+ this.releasesByPath = {};
36
38
  this.alwaysLinkLocal = options.alwaysLinkLocal === false ? false : true;
37
39
  this.updatePeerDependencies = options.updatePeerDependencies === true;
38
40
  }
@@ -142,7 +144,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
142
144
  }
143
145
  return existingCandidate;
144
146
  }
145
- newCandidate(pkg, updatedVersions) {
147
+ async newCandidate(pkg, updatedVersions) {
146
148
  // Update version of the package
147
149
  const newVersion = updatedVersions.get(pkg.name);
148
150
  if (!newVersion) {
@@ -153,6 +155,22 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
153
155
  version: newVersion.toString(),
154
156
  };
155
157
  const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage, updatedVersions, this.logger);
158
+ const strategy = this.strategiesByPath[updatedPackage.path];
159
+ const latestRelease = this.releasesByPath[updatedPackage.path];
160
+ const basePullRequest = strategy
161
+ ? await strategy.buildReleasePullRequest([], latestRelease, false, [], {
162
+ newVersion,
163
+ })
164
+ : undefined;
165
+ if (basePullRequest) {
166
+ return this.updateCandidate({
167
+ path: pkg.path,
168
+ pullRequest: basePullRequest,
169
+ config: {
170
+ releaseType: 'node',
171
+ },
172
+ }, pkg, updatedVersions);
173
+ }
156
174
  const pullRequest = {
157
175
  title: pull_request_title_1.PullRequestTitle.ofTargetBranch(this.targetBranch),
158
176
  body: new pull_request_body_1.PullRequestBody([
@@ -230,6 +248,12 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
230
248
  : {}),
231
249
  };
232
250
  }
251
+ async preconfigure(strategiesByPath, _commitsByPath, _releasesByPath) {
252
+ // Using preconfigure to siphon releases and strategies.
253
+ this.strategiesByPath = strategiesByPath;
254
+ this.releasesByPath = _releasesByPath;
255
+ return strategiesByPath;
256
+ }
233
257
  }
234
258
  exports.NodeWorkspace = NodeWorkspace;
235
259
  function getChangelogDepsNotes(original, updated, updateVersions, logger) {
@@ -105,7 +105,7 @@ export declare abstract class WorkspacePlugin<T> extends ManifestPlugin {
105
105
  * update.
106
106
  * @returns {CandidateReleasePullRequest} A new pull request
107
107
  */
108
- protected abstract newCandidate(pkg: T, updatedVersions: VersionsMap): CandidateReleasePullRequest;
108
+ protected abstract newCandidate(pkg: T, updatedVersions: VersionsMap): Promise<CandidateReleasePullRequest>;
109
109
  /**
110
110
  * Collect all packages being managed in this workspace.
111
111
  * @param {CanididateReleasePullRequest[]} candidates Existing candidate pull
@@ -86,7 +86,7 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
86
86
  else {
87
87
  // otherwise, build a new pull request with changelog and entry update
88
88
  this.logger.info(`Creating new candidate pull request for ${this.packageNameFromPackage(pkg)}`);
89
- const newCandidate = this.newCandidate(pkg, updatedVersions);
89
+ const newCandidate = await this.newCandidate(pkg, updatedVersions);
90
90
  if (newCandidatePaths.has(newCandidate.path)) {
91
91
  this.logger.info(`Already created new candidate for path: ${newCandidate.path}`);
92
92
  }
@@ -1,4 +1,4 @@
1
- import { Strategy, BuildReleaseOptions } from '../strategy';
1
+ import { Strategy, BuildReleaseOptions, BumpReleaseOptions } from '../strategy';
2
2
  import { GitHub } from '../github';
3
3
  import { VersioningStrategy } from '../versioning-strategy';
4
4
  import { Repository } from '../repository';
@@ -115,7 +115,7 @@ export declare abstract class BaseStrategy implements Strategy {
115
115
  * open for this path/component. Returns undefined if we should not
116
116
  * open a pull request.
117
117
  */
118
- buildReleasePullRequest(commits: ConventionalCommit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
118
+ buildReleasePullRequest(commits: ConventionalCommit[], latestRelease?: Release, draft?: boolean, labels?: string[], bumpOnlyOptions?: BumpReleaseOptions): Promise<ReleasePullRequest | undefined>;
119
119
  private extraFilePaths;
120
120
  protected extraFileUpdates(version: Version, versionsMap: VersionsMap): Promise<Update[]>;
121
121
  protected changelogEmpty(changelogEntry: string): boolean;
@@ -142,14 +142,15 @@ class BaseStrategy {
142
142
  * open for this path/component. Returns undefined if we should not
143
143
  * open a pull request.
144
144
  */
145
- async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
145
+ async buildReleasePullRequest(commits, latestRelease, draft, labels = [], bumpOnlyOptions) {
146
+ var _a;
146
147
  const conventionalCommits = await this.postProcessCommits(commits);
147
148
  this.logger.info(`Considering: ${conventionalCommits.length} commits`);
148
- if (conventionalCommits.length === 0) {
149
+ if (!bumpOnlyOptions && conventionalCommits.length === 0) {
149
150
  this.logger.info(`No commits for path: ${this.path}, skipping`);
150
151
  return undefined;
151
152
  }
152
- const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease);
153
+ const newVersion = (_a = bumpOnlyOptions === null || bumpOnlyOptions === void 0 ? void 0 : bumpOnlyOptions.newVersion) !== null && _a !== void 0 ? _a : (await this.buildNewVersion(conventionalCommits, latestRelease));
153
154
  const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits, newVersion);
154
155
  const component = await this.getComponent();
155
156
  this.logger.debug('component:', component);
@@ -161,7 +162,7 @@ class BaseStrategy {
161
162
  ? branch_name_1.BranchName.ofComponentTargetBranch(branchComponent, this.targetBranch)
162
163
  : branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
163
164
  const releaseNotesBody = await this.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits);
164
- if (this.changelogEmpty(releaseNotesBody)) {
165
+ if (!bumpOnlyOptions && this.changelogEmpty(releaseNotesBody)) {
165
166
  this.logger.info(`No user facing commits found since ${latestRelease ? latestRelease.sha : 'beginning of time'} - skipping`);
166
167
  return undefined;
167
168
  }
@@ -5,6 +5,7 @@ import { ConventionalCommit } from '../commit';
5
5
  import { Release } from '../release';
6
6
  import { ReleasePullRequest } from '../release-pull-request';
7
7
  import { VersioningStrategy } from '../versioning-strategy';
8
+ import { BumpReleaseOptions } from '../strategy';
8
9
  export interface JavaBuildUpdatesOption extends BuildUpdatesOptions {
9
10
  isSnapshot?: boolean;
10
11
  }
@@ -18,7 +19,7 @@ export declare class Java extends BaseStrategy {
18
19
  protected readonly snapshotLabels: string[];
19
20
  readonly skipSnapshot: boolean;
20
21
  constructor(options: BaseStrategyOptions);
21
- buildReleasePullRequest(commits: ConventionalCommit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
22
+ buildReleasePullRequest(commits: ConventionalCommit[], latestRelease?: Release, draft?: boolean, labels?: string[], _bumpOnlyOptions?: BumpReleaseOptions): Promise<ReleasePullRequest | undefined>;
22
23
  protected buildSnapshotPullRequest(latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest>;
23
24
  isPublishedVersion(version: Version): boolean;
24
25
  protected needsSnapshot(commits: ConventionalCommit[], latestRelease?: Release): Promise<boolean>;
@@ -58,7 +58,7 @@ class Java extends base_1.BaseStrategy {
58
58
  this.snapshotLabels = options.snapshotLabels || manifest_1.DEFAULT_SNAPSHOT_LABELS;
59
59
  this.skipSnapshot = (_c = options.skipSnapshot) !== null && _c !== void 0 ? _c : false;
60
60
  }
61
- async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
61
+ async buildReleasePullRequest(commits, latestRelease, draft, labels = [], _bumpOnlyOptions) {
62
62
  if (await this.needsSnapshot(commits, latestRelease)) {
63
63
  this.logger.info('Repository needs a snapshot bump.');
64
64
  return await this.buildSnapshotPullRequest(latestRelease, draft, this.snapshotLabels);
@@ -4,9 +4,10 @@ import { Commit } from '../commit';
4
4
  import { Release } from '../release';
5
5
  import { ReleasePullRequest } from '../release-pull-request';
6
6
  import { PullRequestBody } from '../util/pull-request-body';
7
+ import { BumpReleaseOptions } from '../strategy';
7
8
  export declare class PHPYoshi extends BaseStrategy {
8
9
  constructor(options: BaseStrategyOptions);
9
- buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
10
+ buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[], bumpOnlyOptions?: BumpReleaseOptions): Promise<ReleasePullRequest | undefined>;
10
11
  protected parsePullRequestBody(pullRequestBody: string): Promise<PullRequestBody | undefined>;
11
12
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
12
13
  }
@@ -48,10 +48,10 @@ class PHPYoshi extends base_1.BaseStrategy {
48
48
  changelogSections: CHANGELOG_SECTIONS,
49
49
  });
50
50
  }
51
- async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
51
+ async buildReleasePullRequest(commits, latestRelease, draft, labels = [], bumpOnlyOptions) {
52
52
  var _a, _b, _c;
53
53
  const conventionalCommits = await this.postProcessCommits((0, commit_1.parseConventionalCommits)(commits, this.logger));
54
- if (conventionalCommits.length === 0) {
54
+ if (!bumpOnlyOptions && conventionalCommits.length === 0) {
55
55
  this.logger.info(`No commits for path: ${this.path}, skipping`);
56
56
  return undefined;
57
57
  }
@@ -8,6 +8,9 @@ import { Version } from './version';
8
8
  export interface BuildReleaseOptions {
9
9
  groupPullRequestTitlePattern?: string;
10
10
  }
11
+ export interface BumpReleaseOptions {
12
+ newVersion: Version;
13
+ }
11
14
  /**
12
15
  * A strategy is responsible for determining which files are
13
16
  * necessary to update in a release pull request.
@@ -23,11 +26,15 @@ export interface Strategy {
23
26
  * component if available.
24
27
  * @param {boolean} draft Optional. Whether or not to create the pull
25
28
  * request as a draft. Defaults to `false`.
29
+ * @param {BumpReleaseOptions} bumpOnlyOptions Optional. Options, that when
30
+ * present, indicate a release should be created even if there are no
31
+ * conventional commits. This is used when a release is required for
32
+ * a dependency update with a workspace plugin.
26
33
  * @returns {ReleasePullRequest | undefined} The release pull request to
27
34
  * open for this path/component. Returns undefined if we should not
28
35
  * open a pull request.
29
36
  */
30
- buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
37
+ buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[], bumpOnlyOptions?: BumpReleaseOptions): Promise<ReleasePullRequest | undefined>;
31
38
  /**
32
39
  * Given a merged pull request, build the candidate release.
33
40
  * @param {PullRequest} mergedPullRequest The merged release pull request.
@@ -54,10 +54,10 @@ var SUPPORTED_RANGE_PREFIXES;
54
54
  (function (SUPPORTED_RANGE_PREFIXES) {
55
55
  SUPPORTED_RANGE_PREFIXES["CARET"] = "^";
56
56
  SUPPORTED_RANGE_PREFIXES["TILDE"] = "~";
57
- SUPPORTED_RANGE_PREFIXES["GREATER_THAN"] = ">";
58
- SUPPORTED_RANGE_PREFIXES["LESS_THAN"] = "<";
59
57
  SUPPORTED_RANGE_PREFIXES["EQUAL_OR_GREATER_THAN"] = ">=";
60
58
  SUPPORTED_RANGE_PREFIXES["EQUAL_OR_LESS_THAN"] = "<=";
59
+ SUPPORTED_RANGE_PREFIXES["GREATER_THAN"] = ">";
60
+ SUPPORTED_RANGE_PREFIXES["LESS_THAN"] = "<";
61
61
  })(SUPPORTED_RANGE_PREFIXES || (SUPPORTED_RANGE_PREFIXES = {}));
62
62
  function detectRangePrefix(version) {
63
63
  return (Object.values(SUPPORTED_RANGE_PREFIXES).find(supportedRangePrefix => version.startsWith(supportedRangePrefix)) || '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "16.5.0",
3
+ "version": "16.6.0",
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",
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "@conventional-commits/parser": "^0.4.1",
70
- "@google-automations/git-file-utils": "^1.2.5",
70
+ "@google-automations/git-file-utils": "^2.0.0",
71
71
  "@iarna/toml": "^3.0.0",
72
72
  "@octokit/graphql": "^5.0.0",
73
73
  "@octokit/request": "^6.0.0",
@@ -94,7 +94,7 @@
94
94
  "typescript": "^4.6.4",
95
95
  "unist-util-visit": "^2.0.3",
96
96
  "unist-util-visit-parents": "^3.1.1",
97
- "xpath": "^0.0.32",
97
+ "xpath": "^0.0.34",
98
98
  "yaml": "^2.2.2",
99
99
  "yargs": "^17.0.0"
100
100
  },