release-please 14.1.2 → 14.2.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +7 -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 +3 -0
  5. package/build/src/github.js +29 -27
  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
@@ -19,13 +19,13 @@ const version_1 = require("../version");
19
19
  const versioning_strategy_1 = require("../versioning-strategy");
20
20
  const dom = require("@xmldom/xmldom");
21
21
  const xpath = require("xpath");
22
- const logger_1 = require("../util/logger");
23
22
  const path_1 = require("path");
24
23
  const pom_xml_1 = require("../updaters/java/pom-xml");
25
24
  const changelog_1 = require("../updaters/changelog");
26
25
  const pull_request_title_1 = require("../util/pull-request-title");
27
26
  const pull_request_body_1 = require("../util/pull-request-body");
28
27
  const branch_name_1 = require("../util/branch-name");
28
+ const logger_1 = require("../util/logger");
29
29
  const JAVA_RELEASE_TYPES = new Set(['java', 'java-bom', 'java-yoshi', 'maven']);
30
30
  const XPATH_PROJECT_GROUP = '/*[local-name()="project"]/*[local-name()="groupId"]';
31
31
  const XPATH_PROJECT_ARTIFACT = '/*[local-name()="project"]/*[local-name()="artifactId"]';
@@ -37,17 +37,17 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin {
37
37
  const document = new dom.DOMParser().parseFromString(content.parsedContent);
38
38
  const groupNodes = xpath.select(XPATH_PROJECT_GROUP, document);
39
39
  if (groupNodes.length === 0) {
40
- logger_1.logger.warn(`Missing project.groupId in ${path}`);
40
+ this.logger.warn(`Missing project.groupId in ${path}`);
41
41
  return;
42
42
  }
43
43
  const artifactNodes = xpath.select(XPATH_PROJECT_ARTIFACT, document);
44
44
  if (artifactNodes.length === 0) {
45
- logger_1.logger.warn(`Missing project.artifactId in ${path}`);
45
+ this.logger.warn(`Missing project.artifactId in ${path}`);
46
46
  return;
47
47
  }
48
48
  const versionNodes = xpath.select(XPATH_PROJECT_VERSION, document);
49
49
  if (versionNodes.length === 0) {
50
- logger_1.logger.warn(`Missing project.version in ${path}`);
50
+ this.logger.warn(`Missing project.version in ${path}`);
51
51
  return;
52
52
  }
53
53
  const dependencies = [];
@@ -94,7 +94,7 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin {
94
94
  const path = (0, path_1.dirname)(pomFile);
95
95
  const config = this.repositoryConfig[path];
96
96
  if (!config) {
97
- logger_1.logger.info(`path '${path}' not configured, ignoring '${pomFile}'`);
97
+ this.logger.info(`path '${path}' not configured, ignoring '${pomFile}'`);
98
98
  continue;
99
99
  }
100
100
  const mavenArtifact = await this.fetchPom(pomFile);
@@ -108,7 +108,7 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin {
108
108
  candidate;
109
109
  }
110
110
  else {
111
- logger_1.logger.warn(`found ${pomFile} in path ${path}, but did not find an associated candidate PR`);
111
+ this.logger.warn(`found ${pomFile} in path ${path}, but did not find an associated candidate PR`);
112
112
  }
113
113
  }
114
114
  return {
@@ -145,7 +145,7 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin {
145
145
  throw new Error(`Didn't find updated version for ${artifact.name}`);
146
146
  }
147
147
  const updater = new pom_xml_1.PomXml(version, updatedVersions);
148
- const dependencyNotes = getChangelogDepsNotes(artifact, updater, updatedVersions);
148
+ const dependencyNotes = getChangelogDepsNotes(artifact, updater, updatedVersions, this.logger);
149
149
  existingCandidate.pullRequest.updates =
150
150
  existingCandidate.pullRequest.updates.map(update => {
151
151
  if (update.path === (0, workspace_1.addPath)(existingCandidate.path, 'pom.xml')) {
@@ -154,7 +154,7 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin {
154
154
  else if (update.updater instanceof changelog_1.Changelog) {
155
155
  if (dependencyNotes) {
156
156
  update.updater.changelogEntry =
157
- (0, workspace_1.appendDependenciesSectionToChangelog)(update.updater.changelogEntry, dependencyNotes);
157
+ (0, workspace_1.appendDependenciesSectionToChangelog)(update.updater.changelogEntry, dependencyNotes, this.logger);
158
158
  }
159
159
  }
160
160
  return update;
@@ -163,13 +163,13 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin {
163
163
  if (dependencyNotes) {
164
164
  if (existingCandidate.pullRequest.body.releaseData.length > 0) {
165
165
  existingCandidate.pullRequest.body.releaseData[0].notes =
166
- (0, workspace_1.appendDependenciesSectionToChangelog)(existingCandidate.pullRequest.body.releaseData[0].notes, dependencyNotes);
166
+ (0, workspace_1.appendDependenciesSectionToChangelog)(existingCandidate.pullRequest.body.releaseData[0].notes, dependencyNotes, this.logger);
167
167
  }
168
168
  else {
169
169
  existingCandidate.pullRequest.body.releaseData.push({
170
170
  component: artifact.name,
171
171
  version: existingCandidate.pullRequest.version,
172
- notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes),
172
+ notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes, this.logger),
173
173
  });
174
174
  }
175
175
  }
@@ -181,14 +181,14 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin {
181
181
  throw new Error(`Didn't find updated version for ${artifact.name}`);
182
182
  }
183
183
  const updater = new pom_xml_1.PomXml(version, updatedVersions);
184
- const dependencyNotes = getChangelogDepsNotes(artifact, updater, updatedVersions);
184
+ const dependencyNotes = getChangelogDepsNotes(artifact, updater, updatedVersions, this.logger);
185
185
  const pullRequest = {
186
186
  title: pull_request_title_1.PullRequestTitle.ofTargetBranch(this.targetBranch),
187
187
  body: new pull_request_body_1.PullRequestBody([
188
188
  {
189
189
  component: artifact.name,
190
190
  version,
191
- notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes),
191
+ notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes, this.logger),
192
192
  },
193
193
  ]),
194
194
  updates: [
@@ -237,13 +237,13 @@ exports.MavenWorkspace = MavenWorkspace;
237
237
  function packageNameFromGav(gav) {
238
238
  return `${gav.groupId}:${gav.artifactId}`;
239
239
  }
240
- function getChangelogDepsNotes(artifact, updater, updatedVersions) {
240
+ function getChangelogDepsNotes(artifact, updater, updatedVersions, logger = logger_1.logger) {
241
241
  const document = new dom.DOMParser().parseFromString(artifact.pomContent);
242
242
  const dependencyUpdates = updater.dependencyUpdates(document, updatedVersions);
243
243
  const depUpdateNotes = [];
244
244
  for (const dependencyUpdate of dependencyUpdates) {
245
245
  depUpdateNotes.push(`\n * ${dependencyUpdate.name} bumped to ${dependencyUpdate.version}`);
246
- logger_1.logger.info(`bumped ${dependencyUpdate.name} to ${dependencyUpdate.version}`);
246
+ logger.info(`bumped ${dependencyUpdate.name} to ${dependencyUpdate.version}`);
247
247
  }
248
248
  if (depUpdateNotes.length > 0) {
249
249
  return `* The following workspace dependencies were updated${depUpdateNotes.join()}`;
@@ -20,7 +20,6 @@ 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");
24
23
  /**
25
24
  * This plugin merges multiple pull requests into a single
26
25
  * release pull request.
@@ -38,7 +37,7 @@ class Merge extends plugin_1.ManifestPlugin {
38
37
  if (candidates.length < 1) {
39
38
  return candidates;
40
39
  }
41
- logger_1.logger.info(`Merging ${candidates.length} pull requests`);
40
+ this.logger.info(`Merging ${candidates.length} pull requests`);
42
41
  const [inScopeCandidates, outOfScopeCandidates] = candidates.reduce((collection, candidate) => {
43
42
  if (candidate.config.separatePullRequests) {
44
43
  collection[1].push(candidate);
@@ -16,7 +16,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.NodeWorkspace = void 0;
17
17
  const package_graph_1 = require("@lerna/package-graph");
18
18
  const package_1 = require("@lerna/package");
19
- const logger_1 = require("../util/logger");
20
19
  const manifest_1 = require("../manifest");
21
20
  const version_1 = require("../version");
22
21
  const raw_content_1 = require("../updaters/raw-content");
@@ -62,7 +61,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
62
61
  }
63
62
  const candidate = candidatesByPath.get(path);
64
63
  if (candidate) {
65
- logger_1.logger.debug(`Found candidate pull request for path: ${candidate.path}`);
64
+ this.logger.debug(`Found candidate pull request for path: ${candidate.path}`);
66
65
  const packagePath = (0, workspace_1.addPath)(candidate.path, 'package.json');
67
66
  const packageUpdate = candidate.pullRequest.updates.find(update => update.path === packagePath);
68
67
  if (packageUpdate === null || packageUpdate === void 0 ? void 0 : packageUpdate.cachedFileContents) {
@@ -79,7 +78,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
79
78
  }
80
79
  else {
81
80
  const packagePath = (0, workspace_1.addPath)(path, 'package.json');
82
- logger_1.logger.debug(`No candidate pull request for path: ${path} - inspect package from ${packagePath}`);
81
+ this.logger.debug(`No candidate pull request for path: ${path} - inspect package from ${packagePath}`);
83
82
  const contents = await this.github.getFileContentsOnBranch(packagePath, this.targetBranch);
84
83
  packagesByPath.set(path, new Package(contents.parsedContent, path));
85
84
  }
@@ -105,7 +104,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
105
104
  // Update version of the package
106
105
  const newVersion = updatedVersions.get(updatedPackage.name);
107
106
  if (newVersion) {
108
- logger_1.logger.info(`Updating ${updatedPackage.name} to ${newVersion}`);
107
+ this.logger.info(`Updating ${updatedPackage.name} to ${newVersion}`);
109
108
  updatedPackage.version = newVersion.toString();
110
109
  }
111
110
  // Update dependency versions
@@ -113,7 +112,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
113
112
  const depVersion = updatedVersions.get(depName);
114
113
  if (depVersion && resolved.type !== 'directory') {
115
114
  updatedPackage.updateLocalDependency(resolved, depVersion.toString(), '^');
116
- logger_1.logger.info(`${pkg.name}.${depName} updated to ^${depVersion.toString()}`);
115
+ this.logger.info(`${pkg.name}.${depName} updated to ^${depVersion.toString()}`);
117
116
  }
118
117
  }
119
118
  const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage);
@@ -125,7 +124,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
125
124
  else if (update.updater instanceof changelog_1.Changelog) {
126
125
  if (dependencyNotes) {
127
126
  update.updater.changelogEntry =
128
- (0, workspace_1.appendDependenciesSectionToChangelog)(update.updater.changelogEntry, dependencyNotes);
127
+ (0, workspace_1.appendDependenciesSectionToChangelog)(update.updater.changelogEntry, dependencyNotes, this.logger);
129
128
  }
130
129
  }
131
130
  return update;
@@ -134,13 +133,13 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
134
133
  if (dependencyNotes) {
135
134
  if (existingCandidate.pullRequest.body.releaseData.length > 0) {
136
135
  existingCandidate.pullRequest.body.releaseData[0].notes =
137
- (0, workspace_1.appendDependenciesSectionToChangelog)(existingCandidate.pullRequest.body.releaseData[0].notes, dependencyNotes);
136
+ (0, workspace_1.appendDependenciesSectionToChangelog)(existingCandidate.pullRequest.body.releaseData[0].notes, dependencyNotes, this.logger);
138
137
  }
139
138
  else {
140
139
  existingCandidate.pullRequest.body.releaseData.push({
141
140
  component: updatedPackage.name,
142
141
  version: existingCandidate.pullRequest.version,
143
- notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes),
142
+ notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes, this.logger),
144
143
  });
145
144
  }
146
145
  }
@@ -156,14 +155,14 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
156
155
  // Update version of the package
157
156
  const newVersion = updatedVersions.get(updatedPackage.name);
158
157
  if (newVersion) {
159
- logger_1.logger.info(`Updating ${updatedPackage.name} to ${newVersion}`);
158
+ this.logger.info(`Updating ${updatedPackage.name} to ${newVersion}`);
160
159
  updatedPackage.version = newVersion.toString();
161
160
  }
162
161
  for (const [depName, resolved] of graphPackage.localDependencies) {
163
162
  const depVersion = updatedVersions.get(depName);
164
163
  if (depVersion && resolved.type !== 'directory') {
165
164
  updatedPackage.updateLocalDependency(resolved, depVersion.toString(), '^');
166
- logger_1.logger.info(`${pkg.name}.${depName} updated to ^${depVersion.toString()}`);
165
+ this.logger.info(`${pkg.name}.${depName} updated to ^${depVersion.toString()}`);
167
166
  }
168
167
  }
169
168
  const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage);
@@ -175,7 +174,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
175
174
  {
176
175
  component: updatedPackage.name,
177
176
  version,
178
- notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes),
177
+ notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes, this.logger),
179
178
  },
180
179
  ]),
181
180
  updates: [
@@ -189,7 +188,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
189
188
  createIfMissing: false,
190
189
  updater: new changelog_1.Changelog({
191
190
  version,
192
- changelogEntry: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes),
191
+ changelogEntry: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes, this.logger),
193
192
  }),
194
193
  },
195
194
  ],
@@ -1,5 +1,6 @@
1
1
  import { ManifestPlugin } from '../plugin';
2
2
  import { CandidateReleasePullRequest, RepositoryConfig } from '../manifest';
3
+ import { Logger } from '../util/logger';
3
4
  import { VersionsMap, Version } from '../version';
4
5
  import { GitHub } from '../github';
5
6
  export declare type DependencyGraph<T> = Map<string, DependencyNode<T>>;
@@ -11,6 +12,7 @@ export interface WorkspacePluginOptions {
11
12
  manifestPath?: string;
12
13
  updateAllPackages?: boolean;
13
14
  merge?: boolean;
15
+ logger?: Logger;
14
16
  }
15
17
  export interface AllPackages<T> {
16
18
  allPackages: T[];
@@ -122,5 +124,5 @@ export declare abstract class WorkspacePlugin<T> extends ManifestPlugin {
122
124
  protected buildGraphOrder(graph: DependencyGraph<T>, packageNamesToUpdate: string[]): T[];
123
125
  private visitPostOrder;
124
126
  }
125
- export declare function appendDependenciesSectionToChangelog(changelog: string, notes: string): string;
127
+ export declare function appendDependenciesSectionToChangelog(changelog: string, notes: string, logger?: Logger): string;
126
128
  export declare function addPath(path: string, file: string): string;
@@ -33,16 +33,16 @@ const release_please_manifest_1 = require("../updaters/release-please-manifest")
33
33
  class WorkspacePlugin extends plugin_1.ManifestPlugin {
34
34
  constructor(github, targetBranch, repositoryConfig, options = {}) {
35
35
  var _a, _b, _c;
36
- super(github, targetBranch, repositoryConfig);
36
+ super(github, targetBranch, repositoryConfig, options.logger);
37
37
  this.manifestPath = (_a = options.manifestPath) !== null && _a !== void 0 ? _a : manifest_1.DEFAULT_RELEASE_PLEASE_MANIFEST;
38
38
  this.updateAllPackages = (_b = options.updateAllPackages) !== null && _b !== void 0 ? _b : false;
39
39
  this.merge = (_c = options.merge) !== null && _c !== void 0 ? _c : true;
40
40
  }
41
41
  async run(candidates) {
42
- logger_1.logger.info('Running workspace plugin');
42
+ this.logger.info('Running workspace plugin');
43
43
  const [inScopeCandidates, outOfScopeCandidates] = candidates.reduce((collection, candidate) => {
44
44
  if (!candidate.pullRequest.version) {
45
- logger_1.logger.warn('pull request missing version', candidate);
45
+ this.logger.warn('pull request missing version', candidate);
46
46
  return collection;
47
47
  }
48
48
  if (this.inScope(candidate)) {
@@ -53,33 +53,33 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
53
53
  }
54
54
  return collection;
55
55
  }, [[], []]);
56
- logger_1.logger.info(`Found ${inScopeCandidates.length} in-scope releases`);
56
+ this.logger.info(`Found ${inScopeCandidates.length} in-scope releases`);
57
57
  if (inScopeCandidates.length === 0) {
58
58
  return outOfScopeCandidates;
59
59
  }
60
- logger_1.logger.info('Building list of all packages');
60
+ this.logger.info('Building list of all packages');
61
61
  const { allPackages, candidatesByPackage } = await this.buildAllPackages(inScopeCandidates);
62
- logger_1.logger.info(`Building dependency graph for ${allPackages.length} packages`);
62
+ this.logger.info(`Building dependency graph for ${allPackages.length} packages`);
63
63
  const graph = await this.buildGraph(allPackages);
64
64
  const packageNamesToUpdate = this.updateAllPackages
65
65
  ? allPackages.map(this.packageNameFromPackage)
66
66
  : Object.keys(candidatesByPackage);
67
67
  const orderedPackages = this.buildGraphOrder(graph, packageNamesToUpdate);
68
- logger_1.logger.info(`Updating ${orderedPackages.length} packages`);
68
+ this.logger.info(`Updating ${orderedPackages.length} packages`);
69
69
  const updatedVersions = new Map();
70
70
  const updatedPathVersions = new Map();
71
71
  for (const pkg of orderedPackages) {
72
72
  const packageName = this.packageNameFromPackage(pkg);
73
- logger_1.logger.debug(`package: ${packageName}`);
73
+ this.logger.debug(`package: ${packageName}`);
74
74
  const existingCandidate = candidatesByPackage[packageName];
75
75
  if (existingCandidate) {
76
76
  const version = existingCandidate.pullRequest.version;
77
- logger_1.logger.debug(`version: ${version} from release-please`);
77
+ this.logger.debug(`version: ${version} from release-please`);
78
78
  updatedVersions.set(packageName, version);
79
79
  }
80
80
  else {
81
81
  const version = this.bumpVersion(pkg);
82
- logger_1.logger.debug(`version: ${version} forced bump`);
82
+ this.logger.debug(`version: ${version} forced bump`);
83
83
  updatedVersions.set(packageName, version);
84
84
  updatedPathVersions.set(this.pathFromPackage(pkg), version);
85
85
  }
@@ -90,19 +90,19 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
90
90
  const existingCandidate = candidatesByPackage[packageName];
91
91
  if (existingCandidate) {
92
92
  // if already has an pull request, update the changelog and update
93
- logger_1.logger.info(`Updating exising candidate pull request for ${this.packageNameFromPackage(pkg)}`);
93
+ this.logger.info(`Updating exising candidate pull request for ${this.packageNameFromPackage(pkg)}`);
94
94
  const newCandidate = this.updateCandidate(existingCandidate, pkg, updatedVersions);
95
95
  newCandidates.push(newCandidate);
96
96
  }
97
97
  else {
98
98
  // otherwise, build a new pull request with changelog and entry update
99
- logger_1.logger.info(`Creating new candidate pull request for ${this.packageNameFromPackage(pkg)}`);
99
+ this.logger.info(`Creating new candidate pull request for ${this.packageNameFromPackage(pkg)}`);
100
100
  const newCandidate = this.newCandidate(pkg, updatedVersions);
101
101
  newCandidates.push(newCandidate);
102
102
  }
103
103
  }
104
104
  if (this.merge) {
105
- logger_1.logger.info(`Merging ${newCandidates.length} in-scope candidates`);
105
+ this.logger.info(`Merging ${newCandidates.length} in-scope candidates`);
106
106
  const mergePlugin = new merge_1.Merge(this.github, this.targetBranch, this.repositoryConfig);
107
107
  newCandidates = await mergePlugin.run(newCandidates);
108
108
  }
@@ -115,7 +115,7 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
115
115
  versionsMap: updatedPathVersions,
116
116
  }),
117
117
  });
118
- logger_1.logger.info(`Post-processing ${newCandidates.length} in-scope candidates`);
118
+ this.logger.info(`Post-processing ${newCandidates.length} in-scope candidates`);
119
119
  newCandidates = this.postProcessCandidates(newCandidates, updatedVersions);
120
120
  return [...outOfScopeCandidates, ...newCandidates];
121
121
  }
@@ -149,7 +149,7 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
149
149
  * being updated.
150
150
  */
151
151
  buildGraphOrder(graph, packageNamesToUpdate) {
152
- logger_1.logger.info(`building graph order, existing package names: ${packageNamesToUpdate}`);
152
+ this.logger.info(`building graph order, existing package names: ${packageNamesToUpdate}`);
153
153
  // invert the graph so it's dependency name => packages that depend on it
154
154
  const dependentGraph = this.invertGraph(graph);
155
155
  const visited = new Set();
@@ -168,31 +168,31 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
168
168
  }
169
169
  const node = graph.get(name);
170
170
  if (!node) {
171
- logger_1.logger.warn(`Didn't find node: ${name} in graph`);
171
+ this.logger.warn(`Didn't find node: ${name} in graph`);
172
172
  return;
173
173
  }
174
174
  const nextPath = [...path, name];
175
175
  for (const depName of node.deps) {
176
176
  const dep = graph.get(depName);
177
177
  if (!dep) {
178
- logger_1.logger.warn(`dependency not found in graph: ${depName}`);
178
+ this.logger.warn(`dependency not found in graph: ${depName}`);
179
179
  return;
180
180
  }
181
181
  this.visitPostOrder(graph, depName, visited, nextPath);
182
182
  }
183
183
  if (!visited.has(node.value)) {
184
- logger_1.logger.debug(`marking ${name} as visited and adding ${this.packageNameFromPackage(node.value)} to order`);
184
+ this.logger.debug(`marking ${name} as visited and adding ${this.packageNameFromPackage(node.value)} to order`);
185
185
  visited.add(node.value);
186
186
  }
187
187
  }
188
188
  }
189
189
  exports.WorkspacePlugin = WorkspacePlugin;
190
190
  const DEPENDENCY_HEADER = new RegExp('### Dependencies');
191
- function appendDependenciesSectionToChangelog(changelog, notes) {
191
+ function appendDependenciesSectionToChangelog(changelog, notes, logger = logger_1.logger) {
192
192
  if (!changelog) {
193
193
  return `### Dependencies\n\n${notes}`;
194
194
  }
195
- logger_1.logger.info('appending dependency notes to changelog');
195
+ logger.info('appending dependency notes to changelog');
196
196
  const newLines = [];
197
197
  let seenDependenciesSection = false;
198
198
  let seenDependencySectionSpacer = false;
@@ -10,6 +10,7 @@ import { Version, VersionsMap } from '../version';
10
10
  import { TagName } from '../util/tag-name';
11
11
  import { Release } from '../release';
12
12
  import { ReleasePullRequest } from '../release-pull-request';
13
+ import { Logger } from '../util/logger';
13
14
  import { PullRequestBody } from '../util/pull-request-body';
14
15
  import { PullRequest } from '../pull-request';
15
16
  export interface BuildUpdatesOptions {
@@ -45,6 +46,7 @@ export interface BaseStrategyOptions {
45
46
  versionFile?: string;
46
47
  snapshotLabels?: string[];
47
48
  skipSnapshot?: boolean;
49
+ logger?: Logger;
48
50
  }
49
51
  /**
50
52
  * A strategy is responsible for determining which files are
@@ -53,6 +55,7 @@ export interface BaseStrategyOptions {
53
55
  export declare abstract class BaseStrategy implements Strategy {
54
56
  readonly path: string;
55
57
  protected github: GitHub;
58
+ protected logger: Logger;
56
59
  protected component?: string;
57
60
  private packageName?;
58
61
  readonly versioningStrategy: VersioningStrategy;
@@ -37,14 +37,16 @@ const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md';
37
37
  */
38
38
  class BaseStrategy {
39
39
  constructor(options) {
40
- var _a, _b;
40
+ var _a, _b, _c;
41
+ this.logger = (_a = options.logger) !== null && _a !== void 0 ? _a : logger_1.logger;
41
42
  this.path = options.path || manifest_1.ROOT_PROJECT_PATH;
42
43
  this.github = options.github;
43
44
  this.packageName = options.packageName;
44
45
  this.component =
45
46
  options.component || this.normalizeComponent(this.packageName);
46
47
  this.versioningStrategy =
47
- options.versioningStrategy || new default_1.DefaultVersioningStrategy({});
48
+ options.versioningStrategy ||
49
+ new default_1.DefaultVersioningStrategy({ logger: this.logger });
48
50
  this.targetBranch = options.targetBranch;
49
51
  this.repository = options.github.repository;
50
52
  this.changelogPath = options.changelogPath || DEFAULT_CHANGELOG_PATH;
@@ -55,8 +57,8 @@ class BaseStrategy {
55
57
  this.releaseAs = options.releaseAs;
56
58
  this.changelogNotes =
57
59
  options.changelogNotes || new default_2.DefaultChangelogNotes(options);
58
- this.includeComponentInTag = (_a = options.includeComponentInTag) !== null && _a !== void 0 ? _a : true;
59
- this.includeVInTag = (_b = options.includeVInTag) !== null && _b !== void 0 ? _b : true;
60
+ this.includeComponentInTag = (_b = options.includeComponentInTag) !== null && _b !== void 0 ? _b : true;
61
+ this.includeVInTag = (_c = options.includeVInTag) !== null && _c !== void 0 ? _c : true;
60
62
  this.pullRequestTitlePattern = options.pullRequestTitlePattern;
61
63
  this.pullRequestHeader = options.pullRequestHeader;
62
64
  this.extraFiles = options.extraFiles || [];
@@ -135,18 +137,18 @@ class BaseStrategy {
135
137
  * open a pull request.
136
138
  */
137
139
  async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
138
- const conventionalCommits = await this.postProcessCommits((0, commit_1.parseConventionalCommits)(commits));
139
- logger_1.logger.info(`Considering: ${conventionalCommits.length} commits`);
140
+ const conventionalCommits = await this.postProcessCommits((0, commit_1.parseConventionalCommits)(commits, this.logger));
141
+ this.logger.info(`Considering: ${conventionalCommits.length} commits`);
140
142
  if (conventionalCommits.length === 0) {
141
- logger_1.logger.info(`No commits for path: ${this.path}, skipping`);
143
+ this.logger.info(`No commits for path: ${this.path}, skipping`);
142
144
  return undefined;
143
145
  }
144
146
  const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease);
145
147
  const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits, newVersion);
146
148
  const component = await this.getComponent();
147
- logger_1.logger.debug('component:', component);
149
+ this.logger.debug('component:', component);
148
150
  const newVersionTag = new tag_name_1.TagName(newVersion, this.includeComponentInTag ? component : undefined, this.tagSeparator, this.includeVInTag);
149
- logger_1.logger.debug('pull request title pattern:', this.pullRequestTitlePattern);
151
+ this.logger.debug('pull request title pattern:', this.pullRequestTitlePattern);
150
152
  const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion, this.pullRequestTitlePattern);
151
153
  const branchComponent = await this.getBranchComponent();
152
154
  const branchName = branchComponent
@@ -154,7 +156,7 @@ class BaseStrategy {
154
156
  : branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
155
157
  const releaseNotesBody = await this.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits);
156
158
  if (this.changelogEmpty(releaseNotesBody)) {
157
- logger_1.logger.info(`No user facing commits found since ${latestRelease ? latestRelease.sha : 'beginning of time'} - skipping`);
159
+ this.logger.info(`No user facing commits found since ${latestRelease ? latestRelease.sha : 'beginning of time'} - skipping`);
158
160
  return undefined;
159
161
  }
160
162
  const updates = await this.buildUpdates({
@@ -225,7 +227,7 @@ class BaseStrategy {
225
227
  }
226
228
  async buildNewVersion(conventionalCommits, latestRelease) {
227
229
  if (this.releaseAs) {
228
- logger_1.logger.warn(`Setting version for ${this.path} from release-as configuration`);
230
+ this.logger.warn(`Setting version for ${this.path} from release-as configuration`);
229
231
  return version_1.Version.parse(this.releaseAs);
230
232
  }
231
233
  const releaseAsCommit = conventionalCommits.find(conventionalCommit => conventionalCommit.notes.find(note => note.title === 'RELEASE AS'));
@@ -244,7 +246,7 @@ class BaseStrategy {
244
246
  return new Map();
245
247
  }
246
248
  async parsePullRequestBody(pullRequestBody) {
247
- return pull_request_body_1.PullRequestBody.parse(pullRequestBody);
249
+ return pull_request_body_1.PullRequestBody.parse(pullRequestBody, this.logger);
248
250
  }
249
251
  /**
250
252
  * Given a merged pull request, build the candidate release.
@@ -253,27 +255,27 @@ class BaseStrategy {
253
255
  */
254
256
  async buildRelease(mergedPullRequest) {
255
257
  if (this.skipGitHubRelease) {
256
- logger_1.logger.info('Release skipped from strategy config');
258
+ this.logger.info('Release skipped from strategy config');
257
259
  return;
258
260
  }
259
261
  if (!mergedPullRequest.sha) {
260
- logger_1.logger.error('Pull request should have been merged');
262
+ this.logger.error('Pull request should have been merged');
261
263
  return;
262
264
  }
263
- const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, this.pullRequestTitlePattern) ||
264
- pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN);
265
+ const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, this.pullRequestTitlePattern, this.logger) ||
266
+ pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN, this.logger);
265
267
  if (!pullRequestTitle) {
266
- logger_1.logger.error(`Bad pull request title: '${mergedPullRequest.title}'`);
268
+ this.logger.error(`Bad pull request title: '${mergedPullRequest.title}'`);
267
269
  return;
268
270
  }
269
- const branchName = branch_name_1.BranchName.parse(mergedPullRequest.headBranchName);
271
+ const branchName = branch_name_1.BranchName.parse(mergedPullRequest.headBranchName, this.logger);
270
272
  if (!branchName) {
271
- logger_1.logger.error(`Bad branch name: ${mergedPullRequest.headBranchName}`);
273
+ this.logger.error(`Bad branch name: ${mergedPullRequest.headBranchName}`);
272
274
  return;
273
275
  }
274
276
  const pullRequestBody = await this.parsePullRequestBody(mergedPullRequest.body);
275
277
  if (!pullRequestBody) {
276
- logger_1.logger.error('Could not parse pull request body as a release PR');
278
+ this.logger.error('Could not parse pull request body as a release PR');
277
279
  return;
278
280
  }
279
281
  const component = await this.getComponent();
@@ -284,7 +286,7 @@ class BaseStrategy {
284
286
  // standalone release PR, ensure the components match
285
287
  if (this.normalizeComponent(branchName.component) !==
286
288
  this.normalizeComponent(branchComponent)) {
287
- logger_1.logger.warn(`PR component: ${branchName.component} does not match configured component: ${branchComponent}`);
289
+ this.logger.warn(`PR component: ${branchName.component} does not match configured component: ${branchComponent}`);
288
290
  return;
289
291
  }
290
292
  releaseData = pullRequestBody.releaseData[0];
@@ -298,17 +300,17 @@ class BaseStrategy {
298
300
  this.normalizeComponent(component));
299
301
  });
300
302
  if (!releaseData && pullRequestBody.releaseData.length > 0) {
301
- logger_1.logger.info(`Pull request contains releases, but not for component: ${component}`);
303
+ this.logger.info(`Pull request contains releases, but not for component: ${component}`);
302
304
  return;
303
305
  }
304
306
  }
305
307
  const notes = releaseData === null || releaseData === void 0 ? void 0 : releaseData.notes;
306
308
  if (notes === undefined) {
307
- logger_1.logger.warn('Failed to find release notes');
309
+ this.logger.warn('Failed to find release notes');
308
310
  }
309
311
  const version = pullRequestTitle.getVersion() || (releaseData === null || releaseData === void 0 ? void 0 : releaseData.version);
310
312
  if (!version) {
311
- logger_1.logger.error('Pull request should have included version');
313
+ this.logger.error('Pull request should have included version');
312
314
  return;
313
315
  }
314
316
  const tag = new tag_name_1.TagName(version, this.includeComponentInTag ? component : undefined, this.tagSeparator, this.includeVInTag);
@@ -17,7 +17,6 @@ exports.DotnetYoshi = void 0;
17
17
  const base_1 = require("./base");
18
18
  const changelog_1 = require("../updaters/changelog");
19
19
  const apis_1 = require("../updaters/dotnet/apis");
20
- const logger_1 = require("../util/logger");
21
20
  const errors_1 = require("../errors");
22
21
  const CHANGELOG_SECTIONS = [
23
22
  { type: 'feat', section: 'New features' },
@@ -77,7 +76,7 @@ class DotnetYoshi extends base_1.BaseStrategy {
77
76
  const component = await this.getComponent();
78
77
  const api = await this.getApi();
79
78
  if (api === null || api === void 0 ? void 0 : api.noVersionHistory) {
80
- logger_1.logger.info(`Skipping changelog for ${component} via noVersionHistory configuration`);
79
+ this.logger.info(`Skipping changelog for ${component} via noVersionHistory configuration`);
81
80
  }
82
81
  else {
83
82
  updates.push({
@@ -91,7 +90,7 @@ class DotnetYoshi extends base_1.BaseStrategy {
91
90
  });
92
91
  }
93
92
  if (!component) {
94
- logger_1.logger.warn('Dotnet strategy expects to use components, could not update all files');
93
+ this.logger.warn('Dotnet strategy expects to use components, could not update all files');
95
94
  return updates;
96
95
  }
97
96
  updates.push({