release-please 14.1.2 → 14.2.2

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 (80) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/build/src/commit.d.ts +2 -1
  3. package/build/src/commit.js +2 -2
  4. package/build/src/github.d.ts +4 -0
  5. package/build/src/github.js +32 -29
  6. package/build/src/manifest.d.ts +3 -0
  7. package/build/src/manifest.js +66 -65
  8. package/build/src/plugin.d.ts +3 -1
  9. package/build/src/plugin.js +3 -1
  10. package/build/src/plugins/cargo-workspace.js +9 -10
  11. package/build/src/plugins/linked-versions.d.ts +2 -0
  12. package/build/src/plugins/linked-versions.js +5 -6
  13. package/build/src/plugins/maven-workspace.js +14 -14
  14. package/build/src/plugins/merge.js +1 -2
  15. package/build/src/plugins/node-workspace.js +11 -12
  16. package/build/src/plugins/workspace.d.ts +3 -1
  17. package/build/src/plugins/workspace.js +20 -20
  18. package/build/src/strategies/base.d.ts +3 -0
  19. package/build/src/strategies/base.js +26 -24
  20. package/build/src/strategies/dotnet-yoshi.js +2 -3
  21. package/build/src/strategies/go-yoshi.js +7 -8
  22. package/build/src/strategies/java-yoshi.js +1 -2
  23. package/build/src/strategies/java.js +9 -8
  24. package/build/src/strategies/php-yoshi.js +4 -5
  25. package/build/src/strategies/python.js +2 -3
  26. package/build/src/strategies/rust.js +8 -9
  27. package/build/src/update.d.ts +2 -1
  28. package/build/src/updaters/dart/pubspec-yaml.d.ts +2 -1
  29. package/build/src/updaters/dart/pubspec-yaml.js +4 -4
  30. package/build/src/updaters/dotnet/apis.d.ts +2 -1
  31. package/build/src/updaters/dotnet/apis.js +2 -2
  32. package/build/src/updaters/elixir/elixir-mix-exs.d.ts +2 -1
  33. package/build/src/updaters/elixir/elixir-mix-exs.js +2 -2
  34. package/build/src/updaters/generic-json.d.ts +2 -1
  35. package/build/src/updaters/generic-json.js +2 -2
  36. package/build/src/updaters/generic-yaml.d.ts +2 -1
  37. package/build/src/updaters/generic-yaml.js +3 -3
  38. package/build/src/updaters/generic.d.ts +2 -1
  39. package/build/src/updaters/generic.js +2 -2
  40. package/build/src/updaters/helm/chart-yaml.d.ts +2 -1
  41. package/build/src/updaters/helm/chart-yaml.js +2 -2
  42. package/build/src/updaters/java/java-update.d.ts +2 -1
  43. package/build/src/updaters/java/java-update.js +2 -2
  44. package/build/src/updaters/java/versions-manifest.d.ts +2 -1
  45. package/build/src/updaters/java/versions-manifest.js +2 -2
  46. package/build/src/updaters/krm/krm-blueprint-version.d.ts +2 -1
  47. package/build/src/updaters/krm/krm-blueprint-version.js +2 -2
  48. package/build/src/updaters/node/package-json.d.ts +2 -1
  49. package/build/src/updaters/node/package-json.js +2 -2
  50. package/build/src/updaters/node/package-lock-json.d.ts +2 -1
  51. package/build/src/updaters/node/package-lock-json.js +2 -2
  52. package/build/src/updaters/node/samples-package-json.d.ts +2 -1
  53. package/build/src/updaters/node/samples-package-json.js +2 -2
  54. package/build/src/updaters/ocaml/dune-project.d.ts +2 -1
  55. package/build/src/updaters/ocaml/dune-project.js +2 -2
  56. package/build/src/updaters/ocaml/esy-json.d.ts +2 -1
  57. package/build/src/updaters/ocaml/esy-json.js +2 -2
  58. package/build/src/updaters/ocaml/opam.d.ts +2 -1
  59. package/build/src/updaters/ocaml/opam.js +2 -2
  60. package/build/src/updaters/php/php-manifest.d.ts +2 -1
  61. package/build/src/updaters/php/php-manifest.js +3 -3
  62. package/build/src/updaters/php/root-composer-update-packages.d.ts +2 -1
  63. package/build/src/updaters/php/root-composer-update-packages.js +3 -3
  64. package/build/src/updaters/python/pyproject-toml.d.ts +2 -1
  65. package/build/src/updaters/python/pyproject-toml.js +2 -2
  66. package/build/src/updaters/rust/cargo-lock.d.ts +2 -1
  67. package/build/src/updaters/rust/cargo-lock.js +3 -3
  68. package/build/src/updaters/rust/cargo-toml.d.ts +2 -1
  69. package/build/src/updaters/rust/cargo-toml.js +7 -7
  70. package/build/src/updaters/terraform/module-version.d.ts +2 -1
  71. package/build/src/updaters/terraform/module-version.js +2 -2
  72. package/build/src/util/branch-name.d.ts +2 -1
  73. package/build/src/util/branch-name.js +2 -2
  74. package/build/src/util/pull-request-body.d.ts +2 -1
  75. package/build/src/util/pull-request-body.js +9 -9
  76. package/build/src/util/pull-request-title.d.ts +3 -2
  77. package/build/src/util/pull-request-title.js +8 -7
  78. package/build/src/versioning-strategies/default.d.ts +3 -0
  79. package/build/src/versioning-strategies/default.js +3 -1
  80. package/package.json +1 -1
@@ -63,7 +63,7 @@ class Manifest {
63
63
  * pull request. Defaults to `[autorelease: tagged]`
64
64
  */
65
65
  constructor(github, targetBranch, repositoryConfig, releasedVersions, manifestOptions) {
66
- var _a;
66
+ var _a, _b;
67
67
  this.repository = github.repository;
68
68
  this.github = github;
69
69
  this.targetBranch = targetBranch;
@@ -93,6 +93,7 @@ class Manifest {
93
93
  (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.releaseSearchDepth) || DEFAULT_RELEASE_SEARCH_DEPTH;
94
94
  this.commitSearchDepth =
95
95
  (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.commitSearchDepth) || DEFAULT_COMMIT_SEARCH_DEPTH;
96
+ this.logger = (_b = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.logger) !== null && _b !== void 0 ? _b : logger_1.logger;
96
97
  }
97
98
  /**
98
99
  * Create a Manifest from config files in the repository.
@@ -149,7 +150,7 @@ class Manifest {
149
150
  });
150
151
  const component = await strategy.getBranchComponent();
151
152
  const releasedVersions = {};
152
- const latestVersion = await latestReleaseVersion(github, targetBranch, version => isPublishedVersion(strategy, version), config, component);
153
+ const latestVersion = await latestReleaseVersion(github, targetBranch, version => isPublishedVersion(strategy, version), config, component, manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.logger);
153
154
  if (latestVersion) {
154
155
  releasedVersions[path] = latestVersion;
155
156
  }
@@ -168,39 +169,39 @@ class Manifest {
168
169
  */
169
170
  async buildPullRequests() {
170
171
  var _a;
171
- logger_1.logger.info('Building pull requests');
172
+ this.logger.info('Building pull requests');
172
173
  const pathsByComponent = await this.getPathsByComponent();
173
174
  const strategiesByPath = await this.getStrategiesByPath();
174
175
  // Collect all the SHAs of the latest release packages
175
- logger_1.logger.info('Collecting release commit SHAs');
176
+ this.logger.info('Collecting release commit SHAs');
176
177
  let releasesFound = 0;
177
178
  const expectedReleases = Object.keys(strategiesByPath).length;
178
179
  // SHAs by path
179
180
  const releaseShasByPath = {};
180
181
  // Releases by path
181
182
  const releasesByPath = {};
182
- logger_1.logger.debug(`release search depth: ${this.releaseSearchDepth}`);
183
+ this.logger.debug(`release search depth: ${this.releaseSearchDepth}`);
183
184
  for await (const release of this.github.releaseIterator({
184
185
  maxResults: this.releaseSearchDepth,
185
186
  })) {
186
187
  const tagName = tag_name_1.TagName.parse(release.tagName);
187
188
  if (!tagName) {
188
- logger_1.logger.warn(`Unable to parse release name: ${release.name}`);
189
+ this.logger.warn(`Unable to parse release name: ${release.name}`);
189
190
  continue;
190
191
  }
191
192
  const component = tagName.component || exports.DEFAULT_COMPONENT_NAME;
192
193
  const path = pathsByComponent[component];
193
194
  if (!path) {
194
- logger_1.logger.warn(`Found release tag with component '${component}', but not configured in manifest`);
195
+ this.logger.warn(`Found release tag with component '${component}', but not configured in manifest`);
195
196
  continue;
196
197
  }
197
198
  const expectedVersion = this.releasedVersions[path];
198
199
  if (!expectedVersion) {
199
- logger_1.logger.warn(`Unable to find expected version for path '${path}' in manifest`);
200
+ this.logger.warn(`Unable to find expected version for path '${path}' in manifest`);
200
201
  continue;
201
202
  }
202
203
  if (expectedVersion.toString() === tagName.version.toString()) {
203
- logger_1.logger.debug(`Found release for path ${path}, ${release.tagName}`);
204
+ this.logger.debug(`Found release for path ${path}, ${release.tagName}`);
204
205
  releaseShasByPath[path] = release.sha;
205
206
  releasesByPath[path] = {
206
207
  name: release.name,
@@ -216,10 +217,10 @@ class Manifest {
216
217
  }
217
218
  const needsBootstrap = releasesFound < expectedReleases;
218
219
  if (releasesFound < expectedReleases) {
219
- logger_1.logger.warn(`Expected ${expectedReleases} releases, only found ${releasesFound}`);
220
+ this.logger.warn(`Expected ${expectedReleases} releases, only found ${releasesFound}`);
220
221
  // Fall back to looking for missing releases using expected tags
221
222
  const missingPaths = Object.keys(strategiesByPath).filter(path => !releasesByPath[path]);
222
- logger_1.logger.warn(`Missing ${missingPaths.length} paths: ${missingPaths}`);
223
+ this.logger.warn(`Missing ${missingPaths.length} paths: ${missingPaths}`);
223
224
  const missingReleases = await this.backfillReleasesFromTags(missingPaths, strategiesByPath);
224
225
  for (const path in missingReleases) {
225
226
  releaseShasByPath[path] = missingReleases[path].sha;
@@ -228,23 +229,23 @@ class Manifest {
228
229
  }
229
230
  }
230
231
  if (releasesFound < expectedReleases) {
231
- logger_1.logger.warn(`Expected ${expectedReleases} releases, only found ${releasesFound}`);
232
+ this.logger.warn(`Expected ${expectedReleases} releases, only found ${releasesFound}`);
232
233
  }
233
234
  for (const path in releasesByPath) {
234
235
  const release = releasesByPath[path];
235
- logger_1.logger.debug(`release for path: ${path}, version: ${release.tag.version.toString()}, sha: ${release.sha}`);
236
+ this.logger.debug(`release for path: ${path}, version: ${release.tag.version.toString()}, sha: ${release.sha}`);
236
237
  }
237
238
  // iterate through commits and collect commits until we have
238
239
  // seen all release commits
239
- logger_1.logger.info('Collecting commits since all latest releases');
240
+ this.logger.info('Collecting commits since all latest releases');
240
241
  const commits = [];
241
- logger_1.logger.debug(`commit search depth: ${this.commitSearchDepth}`);
242
+ this.logger.debug(`commit search depth: ${this.commitSearchDepth}`);
242
243
  const commitGenerator = this.github.mergeCommitIterator(this.targetBranch, {
243
244
  maxResults: this.commitSearchDepth,
244
245
  backfillFiles: true,
245
246
  });
246
247
  const releaseShas = new Set(Object.values(releaseShasByPath));
247
- logger_1.logger.debug(releaseShas);
248
+ this.logger.debug(releaseShas);
248
249
  const expectedShas = releaseShas.size;
249
250
  // sha => release pull request
250
251
  const releasePullRequestsBySha = {};
@@ -255,16 +256,16 @@ class Manifest {
255
256
  releasePullRequestsBySha[commit.sha] = commit.pullRequest;
256
257
  }
257
258
  else {
258
- logger_1.logger.warn(`Release SHA ${commit.sha} did not have an associated pull request`);
259
+ this.logger.warn(`Release SHA ${commit.sha} did not have an associated pull request`);
259
260
  }
260
261
  releaseCommitsFound += 1;
261
262
  }
262
263
  if (this.lastReleaseSha && this.lastReleaseSha === commit.sha) {
263
- logger_1.logger.info(`Using configured lastReleaseSha ${this.lastReleaseSha} as last commit.`);
264
+ this.logger.info(`Using configured lastReleaseSha ${this.lastReleaseSha} as last commit.`);
264
265
  break;
265
266
  }
266
267
  else if (needsBootstrap && commit.sha === this.bootstrapSha) {
267
- logger_1.logger.info(`Needed bootstrapping, found configured bootstrapSha ${this.bootstrapSha}`);
268
+ this.logger.info(`Needed bootstrapping, found configured bootstrapSha ${this.bootstrapSha}`);
268
269
  break;
269
270
  }
270
271
  else if (!needsBootstrap && releaseCommitsFound >= expectedShas) {
@@ -279,10 +280,10 @@ class Manifest {
279
280
  });
280
281
  }
281
282
  if (releaseCommitsFound < expectedShas) {
282
- logger_1.logger.warn(`Expected ${expectedShas} commits, only found ${releaseCommitsFound}`);
283
+ this.logger.warn(`Expected ${expectedShas} commits, only found ${releaseCommitsFound}`);
283
284
  }
284
285
  // split commits by path
285
- logger_1.logger.info(`Splitting ${commits.length} commits by path`);
286
+ this.logger.info(`Splitting ${commits.length} commits by path`);
286
287
  const cs = new commit_split_1.CommitSplit({
287
288
  includeEmpty: true,
288
289
  packagePaths: Object.keys(this.repositoryConfig),
@@ -302,7 +303,7 @@ class Manifest {
302
303
  const version = this.releasedVersions[path];
303
304
  const strategy = strategiesByPath[path];
304
305
  const component = await strategy.getComponent();
305
- logger_1.logger.info(`No latest release found for path: ${path}, component: ${component}, but a previous version (${version.toString()}) was specified in the manifest.`);
306
+ this.logger.info(`No latest release found for path: ${path}, component: ${component}, but a previous version (${version.toString()}) was specified in the manifest.`);
306
307
  releasesByPath[path] = {
307
308
  tag: new tag_name_1.TagName(version, component),
308
309
  sha: '',
@@ -325,14 +326,14 @@ class Manifest {
325
326
  let newReleasePullRequests = [];
326
327
  for (const path in this.repositoryConfig) {
327
328
  const config = this.repositoryConfig[path];
328
- logger_1.logger.info(`Building candidate release pull request for path: ${path}`);
329
- logger_1.logger.debug(`type: ${config.releaseType}`);
330
- logger_1.logger.debug(`targetBranch: ${this.targetBranch}`);
329
+ this.logger.info(`Building candidate release pull request for path: ${path}`);
330
+ this.logger.debug(`type: ${config.releaseType}`);
331
+ this.logger.debug(`targetBranch: ${this.targetBranch}`);
331
332
  const pathCommits = commitsPerPath[path];
332
- logger_1.logger.debug(`commits: ${pathCommits.length}`);
333
+ this.logger.debug(`commits: ${pathCommits.length}`);
333
334
  const latestReleasePullRequest = releasePullRequestsBySha[releaseShasByPath[path]];
334
335
  if (!latestReleasePullRequest) {
335
- logger_1.logger.warn('No latest release pull request found.');
336
+ this.logger.warn('No latest release pull request found.');
336
337
  }
337
338
  const strategy = strategies[path];
338
339
  const latestRelease = releasesByPath[path];
@@ -365,7 +366,7 @@ class Manifest {
365
366
  plugins.push(new merge_1.Merge(this.github, this.targetBranch, this.repositoryConfig, this.groupPullRequestTitlePattern));
366
367
  }
367
368
  for (const plugin of plugins) {
368
- logger_1.logger.debug(`running plugin: ${plugin.constructor.name}`);
369
+ this.logger.debug(`running plugin: ${plugin.constructor.name}`);
369
370
  newReleasePullRequests = await plugin.run(newReleasePullRequests);
370
371
  }
371
372
  return newReleasePullRequests.map(pullRequestWithConfig => pullRequestWithConfig.pullRequest);
@@ -376,15 +377,15 @@ class Manifest {
376
377
  for (const path of missingPaths) {
377
378
  const expectedVersion = this.releasedVersions[path];
378
379
  if (!expectedVersion) {
379
- logger_1.logger.warn(`No version for path ${path}`);
380
+ this.logger.warn(`No version for path ${path}`);
380
381
  continue;
381
382
  }
382
383
  const component = await strategiesByPath[path].getComponent();
383
384
  const expectedTag = new tag_name_1.TagName(expectedVersion, component, this.repositoryConfig[path].tagSeparator, this.repositoryConfig[path].includeVInTag);
384
- logger_1.logger.debug(`looking for tagName: ${expectedTag.toString()}`);
385
+ this.logger.debug(`looking for tagName: ${expectedTag.toString()}`);
385
386
  const foundTag = allTags[expectedTag.toString()];
386
387
  if (foundTag) {
387
- logger_1.logger.debug(`found: ${foundTag.name} ${foundTag.sha}`);
388
+ this.logger.debug(`found: ${foundTag.name} ${foundTag.sha}`);
388
389
  releasesByPath[path] = {
389
390
  name: foundTag.name,
390
391
  tag: expectedTag,
@@ -416,7 +417,7 @@ class Manifest {
416
417
  // any new release PRs
417
418
  const mergedPullRequestsGenerator = this.findMergedReleasePullRequests();
418
419
  for await (const _ of mergedPullRequestsGenerator) {
419
- logger_1.logger.warn('There are untagged, merged release PRs outstanding - aborting');
420
+ this.logger.warn('There are untagged, merged release PRs outstanding - aborting');
420
421
  return [];
421
422
  }
422
423
  // collect open and snoozed release pull requests
@@ -442,32 +443,32 @@ class Manifest {
442
443
  }
443
444
  }
444
445
  async findOpenReleasePullRequests() {
445
- logger_1.logger.info('Looking for open release pull requests');
446
+ this.logger.info('Looking for open release pull requests');
446
447
  const openPullRequests = [];
447
448
  const generator = this.github.pullRequestIterator(this.targetBranch, 'OPEN', Number.MAX_SAFE_INTEGER, false);
448
449
  for await (const openPullRequest of generator) {
449
450
  if ((hasAllLabels(this.labels, openPullRequest.labels) ||
450
451
  hasAllLabels(this.snapshotLabels, openPullRequest.labels)) &&
451
- branch_name_1.BranchName.parse(openPullRequest.headBranchName) &&
452
- pull_request_body_1.PullRequestBody.parse(openPullRequest.body)) {
452
+ branch_name_1.BranchName.parse(openPullRequest.headBranchName, this.logger) &&
453
+ pull_request_body_1.PullRequestBody.parse(openPullRequest.body, this.logger)) {
453
454
  openPullRequests.push(openPullRequest);
454
455
  }
455
456
  }
456
- logger_1.logger.info(`found ${openPullRequests.length} open release pull requests.`);
457
+ this.logger.info(`found ${openPullRequests.length} open release pull requests.`);
457
458
  return openPullRequests;
458
459
  }
459
460
  async findSnoozedReleasePullRequests() {
460
- logger_1.logger.info('Looking for snoozed release pull requests');
461
+ this.logger.info('Looking for snoozed release pull requests');
461
462
  const snoozedPullRequests = [];
462
463
  const closedGenerator = this.github.pullRequestIterator(this.targetBranch, 'CLOSED', 200, false);
463
464
  for await (const closedPullRequest of closedGenerator) {
464
465
  if (hasAllLabels([exports.SNOOZE_LABEL], closedPullRequest.labels) &&
465
- branch_name_1.BranchName.parse(closedPullRequest.headBranchName) &&
466
- pull_request_body_1.PullRequestBody.parse(closedPullRequest.body)) {
466
+ branch_name_1.BranchName.parse(closedPullRequest.headBranchName, this.logger) &&
467
+ pull_request_body_1.PullRequestBody.parse(closedPullRequest.body, this.logger)) {
467
468
  snoozedPullRequests.push(closedPullRequest);
468
469
  }
469
470
  }
470
- logger_1.logger.info(`found ${snoozedPullRequests.length} snoozed release pull requests.`);
471
+ this.logger.info(`found ${snoozedPullRequests.length} snoozed release pull requests.`);
471
472
  return snoozedPullRequests;
472
473
  }
473
474
  async createOrUpdatePullRequest(pullRequest, openPullRequests, snoozedPullRequests) {
@@ -492,7 +493,7 @@ class Manifest {
492
493
  async maybeUpdateExistingPullRequest(existing, pullRequest) {
493
494
  // If unchanged, no need to push updates
494
495
  if (existing.body === pullRequest.body.toString()) {
495
- logger_1.logger.info(`PR https://github.com/${this.repository.owner}/${this.repository.repo}/pull/${existing.number} remained the same`);
496
+ this.logger.info(`PR https://github.com/${this.repository.owner}/${this.repository.repo}/pull/${existing.number} remained the same`);
496
497
  return undefined;
497
498
  }
498
499
  const updatedPullRequest = await this.github.updatePullRequest(existing.number, pullRequest, this.targetBranch, {
@@ -505,7 +506,7 @@ class Manifest {
505
506
  async maybeUpdateSnoozedPullRequest(snoozed, pullRequest) {
506
507
  // If unchanged, no need to push updates
507
508
  if (snoozed.body === pullRequest.body.toString()) {
508
- logger_1.logger.info(`PR https://github.com/${this.repository.owner}/${this.repository.repo}/pull/${snoozed.number} remained the same`);
509
+ this.logger.info(`PR https://github.com/${this.repository.owner}/${this.repository.repo}/pull/${snoozed.number} remained the same`);
509
510
  return undefined;
510
511
  }
511
512
  const updatedPullRequest = await this.github.updatePullRequest(snoozed.number, pullRequest, this.targetBranch, {
@@ -523,10 +524,10 @@ class Manifest {
523
524
  if (!hasAllLabels(this.labels, pullRequest.labels)) {
524
525
  continue;
525
526
  }
526
- logger_1.logger.debug(`Found pull request #${pullRequest.number}: '${pullRequest.title}'`);
527
- const pullRequestBody = pull_request_body_1.PullRequestBody.parse(pullRequest.body);
527
+ this.logger.debug(`Found pull request #${pullRequest.number}: '${pullRequest.title}'`);
528
+ const pullRequestBody = pull_request_body_1.PullRequestBody.parse(pullRequest.body, this.logger);
528
529
  if (!pullRequestBody) {
529
- logger_1.logger.debug('could not parse pull request body as a release PR');
530
+ this.logger.debug('could not parse pull request body as a release PR');
530
531
  continue;
531
532
  }
532
533
  yield pullRequest;
@@ -539,7 +540,7 @@ class Manifest {
539
540
  */
540
541
  async buildReleases() {
541
542
  var _a;
542
- logger_1.logger.info('Building releases');
543
+ this.logger.info('Building releases');
543
544
  const strategiesByPath = await this.getStrategiesByPath();
544
545
  // Find merged release pull requests
545
546
  const generator = await this.findMergedReleasePullRequests();
@@ -547,9 +548,9 @@ class Manifest {
547
548
  for await (const pullRequest of generator) {
548
549
  for (const path in this.repositoryConfig) {
549
550
  const config = this.repositoryConfig[path];
550
- logger_1.logger.info(`Building release for path: ${path}`);
551
- logger_1.logger.debug(`type: ${config.releaseType}`);
552
- logger_1.logger.debug(`targetBranch: ${this.targetBranch}`);
551
+ this.logger.info(`Building release for path: ${path}`);
552
+ this.logger.debug(`type: ${config.releaseType}`);
553
+ this.logger.debug(`targetBranch: ${this.targetBranch}`);
553
554
  const strategy = strategiesByPath[path];
554
555
  const release = await strategy.buildRelease(pullRequest);
555
556
  if (release) {
@@ -564,7 +565,7 @@ class Manifest {
564
565
  });
565
566
  }
566
567
  else {
567
- logger_1.logger.info(`No release necessary for path: ${path}`);
568
+ this.logger.info(`No release necessary for path: ${path}`);
568
569
  }
569
570
  }
570
571
  }
@@ -607,7 +608,7 @@ class Manifest {
607
608
  }
608
609
  }
609
610
  async createReleasesForPullRequest(releases, pullRequest) {
610
- logger_1.logger.info(`Creating ${releases.length} releases for pull #${pullRequest.number}`);
611
+ this.logger.info(`Creating ${releases.length} releases for pull #${pullRequest.number}`);
611
612
  const duplicateReleases = [];
612
613
  const githubReleases = [];
613
614
  for (const release of releases) {
@@ -616,7 +617,7 @@ class Manifest {
616
617
  }
617
618
  catch (err) {
618
619
  if (err instanceof errors_1.DuplicateReleaseError) {
619
- logger_1.logger.warn(`Duplicate release tag: ${release.tag.toString()}`);
620
+ this.logger.warn(`Duplicate release tag: ${release.tag.toString()}`);
620
621
  duplicateReleases.push(err);
621
622
  }
622
623
  else {
@@ -667,11 +668,11 @@ class Manifest {
667
668
  }
668
669
  async getStrategiesByPath() {
669
670
  if (!this._strategiesByPath) {
670
- logger_1.logger.info('Building strategies by path');
671
+ this.logger.info('Building strategies by path');
671
672
  this._strategiesByPath = {};
672
673
  for (const path in this.repositoryConfig) {
673
674
  const config = this.repositoryConfig[path];
674
- logger_1.logger.debug(`${path}: ${config.releaseType}`);
675
+ this.logger.debug(`${path}: ${config.releaseType}`);
675
676
  const strategy = await (0, factory_1.buildStrategy)({
676
677
  ...config,
677
678
  github: this.github,
@@ -691,7 +692,7 @@ class Manifest {
691
692
  const strategy = strategiesByPath[path];
692
693
  const component = (await strategy.getComponent()) || '';
693
694
  if (this._pathsByComponent[component]) {
694
- logger_1.logger.warn(`Multiple paths for ${component}: ${this._pathsByComponent[component]}, ${path}`);
695
+ this.logger.warn(`Multiple paths for ${component}: ${this._pathsByComponent[component]}, ${path}`);
695
696
  }
696
697
  this._pathsByComponent[component] = path;
697
698
  }
@@ -855,13 +856,13 @@ function isPublishedVersion(strategy, version) {
855
856
  * @param {string} prefix Limit the release to a specific component.
856
857
  * @param pullRequestTitlePattern Configured PR title pattern.
857
858
  */
858
- async function latestReleaseVersion(github, targetBranch, releaseFilter, config, prefix) {
859
+ async function latestReleaseVersion(github, targetBranch, releaseFilter, config, prefix, logger = logger_1.logger) {
859
860
  const branchPrefix = prefix
860
861
  ? prefix.endsWith('-')
861
862
  ? prefix.replace(/-$/, '')
862
863
  : prefix
863
864
  : undefined;
864
- logger_1.logger.info(`Looking for latest release on branch: ${targetBranch} with prefix: ${prefix}`);
865
+ logger.info(`Looking for latest release on branch: ${targetBranch} with prefix: ${prefix}`);
865
866
  // collect set of recent commit SHAs seen to verify that the release
866
867
  // is in the current branch
867
868
  const commitShas = new Set();
@@ -878,7 +879,7 @@ async function latestReleaseVersion(github, targetBranch, releaseFilter, config,
878
879
  if (!mergedPullRequest) {
879
880
  continue;
880
881
  }
881
- const branchName = branch_name_1.BranchName.parse(mergedPullRequest.headBranchName);
882
+ const branchName = branch_name_1.BranchName.parse(mergedPullRequest.headBranchName, logger);
882
883
  if (!branchName) {
883
884
  continue;
884
885
  }
@@ -887,13 +888,13 @@ async function latestReleaseVersion(github, targetBranch, releaseFilter, config,
887
888
  if (branchName.getComponent() !== branchPrefix) {
888
889
  continue;
889
890
  }
890
- const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, config.pullRequestTitlePattern);
891
+ const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, config.pullRequestTitlePattern, logger);
891
892
  if (!pullRequestTitle) {
892
893
  continue;
893
894
  }
894
895
  const version = pullRequestTitle.getVersion();
895
896
  if (version && releaseFilter(version)) {
896
- logger_1.logger.debug(`Found latest release pull request: ${mergedPullRequest.number} version: ${version}`);
897
+ logger.debug(`Found latest release pull request: ${mergedPullRequest.number} version: ${version}`);
897
898
  candidateReleaseVersions.push(version);
898
899
  break;
899
900
  }
@@ -907,15 +908,15 @@ async function latestReleaseVersion(github, targetBranch, releaseFilter, config,
907
908
  continue;
908
909
  }
909
910
  if (tagMatchesConfig(tagName, branchPrefix, config.includeComponentInTag)) {
910
- logger_1.logger.debug(`found release for ${prefix}`, tagName.version);
911
+ logger.debug(`found release for ${prefix}`, tagName.version);
911
912
  if (!commitShas.has(release.sha)) {
912
- logger_1.logger.debug(`SHA not found in recent commits to branch ${targetBranch}, skipping`);
913
+ logger.debug(`SHA not found in recent commits to branch ${targetBranch}, skipping`);
913
914
  continue;
914
915
  }
915
916
  candidateReleaseVersions.push(tagName.version);
916
917
  }
917
918
  }
918
- logger_1.logger.debug(`found ${candidateReleaseVersions.length} possible releases.`, candidateReleaseVersions);
919
+ logger.debug(`found ${candidateReleaseVersions.length} possible releases.`, candidateReleaseVersions);
919
920
  if (candidateReleaseVersions.length > 0) {
920
921
  // Find largest release number (sort descending then return first)
921
922
  return candidateReleaseVersions.sort((a, b) => b.compare(a))[0];
@@ -931,13 +932,13 @@ async function latestReleaseVersion(github, targetBranch, releaseFilter, config,
931
932
  }
932
933
  if (tagMatchesConfig(tagName, branchPrefix, config.includeComponentInTag)) {
933
934
  if (!commitShas.has(tag.sha)) {
934
- logger_1.logger.debug(`SHA not found in recent commits to branch ${targetBranch}, skipping`);
935
+ logger.debug(`SHA not found in recent commits to branch ${targetBranch}, skipping`);
935
936
  continue;
936
937
  }
937
938
  candidateTagVersion.push(tagName.version);
938
939
  }
939
940
  }
940
- logger_1.logger.debug(`found ${candidateTagVersion.length} possible tags.`, candidateTagVersion);
941
+ logger.debug(`found ${candidateTagVersion.length} possible tags.`, candidateTagVersion);
941
942
  // Find largest release number (sort descending then return first)
942
943
  return candidateTagVersion.sort((a, b) => b.compare(a))[0];
943
944
  }
@@ -3,6 +3,7 @@ import { CandidateReleasePullRequest, RepositoryConfig } from './manifest';
3
3
  import { Strategy } from './strategy';
4
4
  import { Commit } from './commit';
5
5
  import { Release } from './release';
6
+ import { Logger } from './util/logger';
6
7
  /**
7
8
  * A plugin runs after a repository manifest has built candidate
8
9
  * pull requests and can make updates that span across multiple
@@ -13,7 +14,8 @@ export declare abstract class ManifestPlugin {
13
14
  readonly github: GitHub;
14
15
  readonly targetBranch: string;
15
16
  readonly repositoryConfig: RepositoryConfig;
16
- constructor(github: GitHub, targetBranch: string, repositoryConfig: RepositoryConfig);
17
+ protected logger: Logger;
18
+ constructor(github: GitHub, targetBranch: string, repositoryConfig: RepositoryConfig, logger?: Logger);
17
19
  /**
18
20
  * Post-process candidate pull requests.
19
21
  * @param {CandidateReleasePullRequest[]} pullRequests Candidate pull requests
@@ -14,6 +14,7 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.ManifestPlugin = void 0;
17
+ const logger_1 = require("./util/logger");
17
18
  /**
18
19
  * A plugin runs after a repository manifest has built candidate
19
20
  * pull requests and can make updates that span across multiple
@@ -21,10 +22,11 @@ exports.ManifestPlugin = void 0;
21
22
  * or update existing files.
22
23
  */
23
24
  class ManifestPlugin {
24
- constructor(github, targetBranch, repositoryConfig) {
25
+ constructor(github, targetBranch, repositoryConfig, logger = logger_1.logger) {
25
26
  this.github = github;
26
27
  this.targetBranch = targetBranch;
27
28
  this.repositoryConfig = repositoryConfig;
29
+ this.logger = logger;
28
30
  }
29
31
  /**
30
32
  * Post-process candidate pull requests.
@@ -15,7 +15,6 @@
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.CargoWorkspace = void 0;
17
17
  const manifest_1 = require("../manifest");
18
- const logger_1 = require("../util/logger");
19
18
  const workspace_1 = require("./workspace");
20
19
  const common_1 = require("../updaters/rust/common");
21
20
  const version_1 = require("../version");
@@ -40,7 +39,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
40
39
  const cargoManifestContent = await this.github.getFileContentsOnBranch('Cargo.toml', this.targetBranch);
41
40
  const cargoManifest = (0, common_1.parseCargoManifest)(cargoManifestContent.parsedContent);
42
41
  if (!((_a = cargoManifest.workspace) === null || _a === void 0 ? void 0 : _a.members)) {
43
- logger_1.logger.warn("cargo-workspace plugin used, but top-level Cargo.toml isn't a cargo workspace");
42
+ this.logger.warn("cargo-workspace plugin used, but top-level Cargo.toml isn't a cargo workspace");
44
43
  return { allPackages: [], candidatesByPackage: {} };
45
44
  }
46
45
  const allCrates = [];
@@ -49,7 +48,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
49
48
  members.push(manifest_1.ROOT_PROJECT_PATH);
50
49
  for (const path of members) {
51
50
  const manifestPath = (0, workspace_1.addPath)(path, 'Cargo.toml');
52
- logger_1.logger.info(`looking for candidate with path: ${path}`);
51
+ this.logger.info(`looking for candidate with path: ${path}`);
53
52
  const candidate = candidates.find(c => c.path === path);
54
53
  // get original content of the crate
55
54
  const manifestContent = ((_b = candidate === null || candidate === void 0 ? void 0 : candidate.pullRequest.updates.find(update => update.path === manifestPath)) === null || _b === void 0 ? void 0 : _b.cachedFileContents) ||
@@ -57,7 +56,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
57
56
  const manifest = (0, common_1.parseCargoManifest)(manifestContent.parsedContent);
58
57
  const packageName = (_c = manifest.package) === null || _c === void 0 ? void 0 : _c.name;
59
58
  if (!packageName) {
60
- logger_1.logger.warn(`package manifest at ${manifestPath} is missing [package.name]`);
59
+ this.logger.warn(`package manifest at ${manifestPath} is missing [package.name]`);
61
60
  continue;
62
61
  }
63
62
  if (candidate) {
@@ -104,7 +103,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
104
103
  update.updater = new raw_content_1.RawContent(updatedContent);
105
104
  }
106
105
  else if (update.updater instanceof changelog_1.Changelog && dependencyNotes) {
107
- update.updater.changelogEntry = (0, workspace_1.appendDependenciesSectionToChangelog)(update.updater.changelogEntry, dependencyNotes);
106
+ update.updater.changelogEntry = (0, workspace_1.appendDependenciesSectionToChangelog)(update.updater.changelogEntry, dependencyNotes, this.logger);
108
107
  }
109
108
  else if (update.path === (0, workspace_1.addPath)(existingCandidate.path, 'Cargo.lock')) {
110
109
  update.updater = new cargo_lock_1.CargoLock(updatedVersions);
@@ -115,13 +114,13 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
115
114
  if (dependencyNotes) {
116
115
  if (existingCandidate.pullRequest.body.releaseData.length > 0) {
117
116
  existingCandidate.pullRequest.body.releaseData[0].notes =
118
- (0, workspace_1.appendDependenciesSectionToChangelog)(existingCandidate.pullRequest.body.releaseData[0].notes, dependencyNotes);
117
+ (0, workspace_1.appendDependenciesSectionToChangelog)(existingCandidate.pullRequest.body.releaseData[0].notes, dependencyNotes, this.logger);
119
118
  }
120
119
  else {
121
120
  existingCandidate.pullRequest.body.releaseData.push({
122
121
  component: pkg.name,
123
122
  version: existingCandidate.pullRequest.version,
124
- notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes),
123
+ notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes, this.logger),
125
124
  });
126
125
  }
127
126
  }
@@ -146,7 +145,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
146
145
  {
147
146
  component: pkg.name,
148
147
  version,
149
- notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes),
148
+ notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes, this.logger),
150
149
  },
151
150
  ]),
152
151
  updates: [
@@ -180,11 +179,11 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
180
179
  postProcessCandidates(candidates, updatedVersions) {
181
180
  let rootCandidate = candidates.find(c => c.path === manifest_1.ROOT_PROJECT_PATH);
182
181
  if (!rootCandidate) {
183
- logger_1.logger.warn('Unable to find root candidate pull request');
182
+ this.logger.warn('Unable to find root candidate pull request');
184
183
  rootCandidate = candidates.find(c => c.config.releaseType === 'rust');
185
184
  }
186
185
  if (!rootCandidate) {
187
- logger_1.logger.warn('Unable to find a rust candidate pull request');
186
+ this.logger.warn('Unable to find a rust candidate pull request');
188
187
  return candidates;
189
188
  }
190
189
  // Update the root Cargo.lock if it exists
@@ -1,11 +1,13 @@
1
1
  import { ManifestPlugin } from '../plugin';
2
2
  import { RepositoryConfig, CandidateReleasePullRequest } from '../manifest';
3
3
  import { GitHub } from '../github';
4
+ import { Logger } from '../util/logger';
4
5
  import { Strategy } from '../strategy';
5
6
  import { Commit } from '../commit';
6
7
  import { Release } from '../release';
7
8
  interface LinkedVersionsPluginOptions {
8
9
  merge?: boolean;
10
+ logger?: Logger;
9
11
  }
10
12
  /**
11
13
  * This plugin reconfigures strategies by linking multiple components
@@ -15,7 +15,6 @@
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.LinkedVersions = void 0;
17
17
  const plugin_1 = require("../plugin");
18
- const logger_1 = require("../util/logger");
19
18
  const factory_1 = require("../factory");
20
19
  const merge_1 = require("./merge");
21
20
  /**
@@ -27,7 +26,7 @@ const merge_1 = require("./merge");
27
26
  class LinkedVersions extends plugin_1.ManifestPlugin {
28
27
  constructor(github, targetBranch, repositoryConfig, groupName, components, options = {}) {
29
28
  var _a;
30
- super(github, targetBranch, repositoryConfig);
29
+ super(github, targetBranch, repositoryConfig, options.logger);
31
30
  this.groupName = groupName;
32
31
  this.components = new Set(components);
33
32
  this.merge = (_a = options.merge) !== null && _a !== void 0 ? _a : true;
@@ -50,7 +49,7 @@ class LinkedVersions extends plugin_1.ManifestPlugin {
50
49
  groupStrategies[path] = strategy;
51
50
  }
52
51
  }
53
- logger_1.logger.info(`Found ${Object.keys(groupStrategies).length} group components for ${this.groupName}`);
52
+ this.logger.info(`Found ${Object.keys(groupStrategies).length} group components for ${this.groupName}`);
54
53
  const groupVersions = {};
55
54
  const missingReleasePaths = new Set();
56
55
  for (const path in groupStrategies) {
@@ -73,7 +72,7 @@ class LinkedVersions extends plugin_1.ManifestPlugin {
73
72
  for (const path in strategiesByPath) {
74
73
  if (path in groupStrategies) {
75
74
  const component = await strategiesByPath[path].getComponent();
76
- logger_1.logger.info(`Replacing strategy for path ${path} with forced version: ${primaryVersion}`);
75
+ this.logger.info(`Replacing strategy for path ${path} with forced version: ${primaryVersion}`);
77
76
  newStrategies[path] = await (0, factory_1.buildStrategy)({
78
77
  ...this.repositoryConfig[path],
79
78
  github: this.github,
@@ -82,7 +81,7 @@ class LinkedVersions extends plugin_1.ManifestPlugin {
82
81
  releaseAs: primaryVersion.toString(),
83
82
  });
84
83
  if (missingReleasePaths.has(path)) {
85
- logger_1.logger.debug(`Appending fake commit for path: ${path}`);
84
+ this.logger.debug(`Appending fake commit for path: ${path}`);
86
85
  commitsByPath[path].push({
87
86
  sha: '',
88
87
  message: `chore(${component}): Synchronize ${this.groupName} versions\n\nRelease-As: ${primaryVersion.toString()}`,
@@ -106,7 +105,7 @@ class LinkedVersions extends plugin_1.ManifestPlugin {
106
105
  }
107
106
  const [inScopeCandidates, outOfScopeCandidates] = candidates.reduce((collection, candidate) => {
108
107
  if (!candidate.pullRequest.version) {
109
- logger_1.logger.warn('pull request missing version', candidate);
108
+ this.logger.warn('pull request missing version', candidate);
110
109
  return collection;
111
110
  }
112
111
  if (this.components.has(candidate.config.component || '')) {