release-please 15.2.0 → 15.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ## [15.3.1](https://github.com/googleapis/release-please/compare/v15.3.0...v15.3.1) (2023-01-26)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * Filter changelog.json commits based on changelog sections ([#1827](https://github.com/googleapis/release-please/issues/1827)) ([844aacd](https://github.com/googleapis/release-please/commit/844aacd76434ae288ee3ac9b2061dd9406e99bd8))
13
+
14
+ ## [15.3.0](https://github.com/googleapis/release-please/compare/v15.2.0...v15.3.0) (2023-01-25)
15
+
16
+
17
+ ### Features
18
+
19
+ * Add Salesforce strategy ([#1815](https://github.com/googleapis/release-please/issues/1815)) ([25b518f](https://github.com/googleapis/release-please/commit/25b518f4f34afcd749968d021f4eed99222a328a))
20
+ * Add support for yarn workspace versions ([#1819](https://github.com/googleapis/release-please/issues/1819)) ([8b0cc7d](https://github.com/googleapis/release-please/commit/8b0cc7d7d203609c95e9e7cfbef4f0faedd3f46d))
21
+ * **java-monorepo:** Switch to using .repo-metadata.json ([#1820](https://github.com/googleapis/release-please/issues/1820)) ([6cc85db](https://github.com/googleapis/release-please/commit/6cc85dbb95ade1c38c354a567a02b8a41d729a72))
22
+ * **node:** Add support for changelog.json in Node ([#1823](https://github.com/googleapis/release-please/issues/1823)) ([d3e3bd3](https://github.com/googleapis/release-please/commit/d3e3bd3b102195befb051457f9a837ff47388157))
23
+
7
24
  ## [15.2.0](https://github.com/googleapis/release-please/compare/v15.1.2...v15.2.0) (2023-01-23)
8
25
 
9
26
 
package/README.md CHANGED
@@ -150,6 +150,7 @@ Release Please automates releases for the following flavors of repositories:
150
150
  | `python` | [A Python repository, with a setup.py, setup.cfg, CHANGELOG.md](https://github.com/googleapis/python-storage) and optionally a pyproject.toml and a <project>/\_\_init\_\_.py |
151
151
  | `ruby` | A repository with a version.rb and a CHANGELOG.md |
152
152
  | `rust` | A Rust repository, with a Cargo.toml (either as a crate or workspace) and a CHANGELOG.md |
153
+ | `salesforce` | A repository with a sfdx-project.json and a CHANGELOG.md |
153
154
  | `simple` | [A repository with a version.txt and a CHANGELOG.md](https://github.com/googleapis/gapic-generator) |
154
155
  | `terraform-module` | [A terraform module, with a version in the README.md, and a CHANGELOG.md](https://github.com/terraform-google-modules/terraform-google-project-factory) |
155
156
 
@@ -40,6 +40,7 @@ const python_1 = require("./strategies/python");
40
40
  const ruby_1 = require("./strategies/ruby");
41
41
  const ruby_yoshi_1 = require("./strategies/ruby-yoshi");
42
42
  const rust_1 = require("./strategies/rust");
43
+ const salesforce_1 = require("./strategies/salesforce");
43
44
  const simple_1 = require("./strategies/simple");
44
45
  const terraform_module_1 = require("./strategies/terraform-module");
45
46
  const helm_1 = require("./strategies/helm");
@@ -92,6 +93,7 @@ const releasers = {
92
93
  ruby: options => new ruby_1.Ruby(options),
93
94
  'ruby-yoshi': options => new ruby_yoshi_1.RubyYoshi(options),
94
95
  rust: options => new rust_1.Rust(options),
96
+ salesforce: options => new salesforce_1.Salesforce(options),
95
97
  simple: options => new simple_1.Simple(options),
96
98
  'terraform-module': options => new terraform_module_1.TerraformModule(options),
97
99
  helm: options => new helm_1.Helm(options),
@@ -118,7 +118,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
118
118
  this.logger.info(`${pkg.name}.${depName} updated to ${prefix}${depVersion.toString()}`);
119
119
  }
120
120
  }
121
- const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage);
121
+ const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage, updatedVersions);
122
122
  existingCandidate.pullRequest.updates =
123
123
  existingCandidate.pullRequest.updates.map(update => {
124
124
  if (update.path === (0, workspace_1.addPath)(existingCandidate.path, 'package.json')) {
@@ -172,7 +172,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
172
172
  this.logger.info(`${pkg.name}.${depName} updated to ${prefix}${depVersion.toString()}`);
173
173
  }
174
174
  }
175
- const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage);
175
+ const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage, updatedVersions);
176
176
  const packageJson = updatedPackage.toJSON();
177
177
  const version = version_1.Version.parse(packageJson.version);
178
178
  const pullRequest = {
@@ -260,8 +260,8 @@ var SUPPORTED_RANGE_PREFIXES;
260
260
  SUPPORTED_RANGE_PREFIXES["EQUAL_OR_GREATER_THAN"] = ">=";
261
261
  SUPPORTED_RANGE_PREFIXES["EQUAL_OR_LESS_THAN"] = "<=";
262
262
  })(SUPPORTED_RANGE_PREFIXES || (SUPPORTED_RANGE_PREFIXES = {}));
263
- function getChangelogDepsNotes(original, updated) {
264
- var _a;
263
+ function getChangelogDepsNotes(original, updated, updateVersions) {
264
+ var _a, _b;
265
265
  let depUpdateNotes = '';
266
266
  const depTypes = [
267
267
  'dependencies',
@@ -280,6 +280,12 @@ function getChangelogDepsNotes(original, updated) {
280
280
  const origDepVer = (_a = original[depType]) === null || _a === void 0 ? void 0 : _a[depName];
281
281
  if (currentDepVer !== origDepVer) {
282
282
  depUpdates.push(`\n * ${depName} bumped from ${origDepVer} to ${currentDepVer}`);
283
+ //handle case when "workspace:" version is used
284
+ }
285
+ else if (currentDepVer.startsWith('workspace:') &&
286
+ updateVersions.get(depName) !== undefined) {
287
+ depUpdates.push(`\n * ${depName} bumped to ${(_b = updateVersions
288
+ .get(depName)) === null || _b === void 0 ? void 0 : _b.toString()}`);
283
289
  }
284
290
  }
285
291
  if (depUpdates.length > 0) {
@@ -15,7 +15,8 @@ export declare class JavaYoshiMonoRepo extends Java {
15
15
  protected buildVersionsMap(): Promise<VersionsMap>;
16
16
  protected getVersionsContent(): Promise<GitHubFileContents>;
17
17
  protected buildUpdates(options: JavaBuildUpdatesOption): Promise<Update[]>;
18
- private getArtifactMap;
18
+ private hasChangelogJson;
19
+ private getRepoMetadata;
19
20
  protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
20
21
  protected initialReleaseVersion(): Version;
21
22
  }
@@ -23,7 +23,7 @@ const composite_1 = require("../updaters/composite");
23
23
  const errors_1 = require("../errors");
24
24
  const java_1 = require("./java");
25
25
  const java_update_1 = require("../updaters/java/java-update");
26
- const BREAKING_CHANGE_NOTE = 'BREAKING CHANGE';
26
+ const filter_commits_1 = require("../util/filter-commits");
27
27
  class JavaYoshiMonoRepo extends java_1.Java {
28
28
  /**
29
29
  * Override this method to post process commits
@@ -144,25 +144,24 @@ class JavaYoshiMonoRepo extends java_1.Java {
144
144
  changelogEntry: options.changelogEntry,
145
145
  }),
146
146
  });
147
- // The artifact map maps from directory paths in repo to artifact names on
148
- // Maven, e.g, java-secretmanager to com.google.cloud/google-cloud-secretmanager.
149
- const artifactMap = await this.getArtifactMap('artifact-map.json');
150
- if (artifactMap && options.commits) {
147
+ // Bail early if the repository has no root changelog.json.
148
+ // This file is used to opt into machine readable commits.
149
+ const hasChangelogJson = await this.hasChangelogJson();
150
+ if (hasChangelogJson && options.commits) {
151
151
  const changelogUpdates = [];
152
152
  const cs = new commit_split_1.CommitSplit({
153
153
  includeEmpty: false,
154
154
  });
155
- const splitCommits = cs.split(options.commits.filter(commit => {
156
- const isBreaking = commit.notes.find(note => {
157
- return note.title === BREAKING_CHANGE_NOTE;
158
- });
159
- return commit.type !== 'chore' || isBreaking;
160
- }));
155
+ const splitCommits = cs.split((0, filter_commits_1.filterCommits)(options.commits, this.changelogSections));
161
156
  for (const path of Object.keys(splitCommits)) {
162
- if (artifactMap[path]) {
163
- this.logger.info(`Found artifact ${artifactMap[path]} for ${path}`);
157
+ const repoMetadata = await this.getRepoMetadata(path);
158
+ const artifactName = repoMetadata
159
+ ? repoMetadata['distribution_name']
160
+ : null;
161
+ if (repoMetadata && artifactName) {
162
+ this.logger.info(`Found artifact ${artifactName} for ${path}`);
164
163
  changelogUpdates.push(new changelog_json_1.ChangelogJson({
165
- artifactName: artifactMap[path],
164
+ artifactName,
166
165
  version,
167
166
  // We filter out "chore:" commits, to reduce noise in the upstream
168
167
  // release notes. We will only show a product release note entry
@@ -181,13 +180,28 @@ class JavaYoshiMonoRepo extends java_1.Java {
181
180
  }
182
181
  return updates;
183
182
  }
184
- async getArtifactMap(path) {
183
+ async hasChangelogJson() {
185
184
  try {
186
- const content = await this.github.getFileContentsOnBranch(path, this.targetBranch);
187
- return JSON.parse(content.parsedContent);
185
+ const content = await this.github.getFileContentsOnBranch('changelog.json', this.targetBranch);
186
+ return !!content;
188
187
  }
189
188
  catch (e) {
190
- return null;
189
+ if (e instanceof errors_1.FileNotFoundError)
190
+ return false;
191
+ else
192
+ throw e;
193
+ }
194
+ }
195
+ async getRepoMetadata(path) {
196
+ try {
197
+ const content = await this.github.getFileContentsOnBranch(this.addPath(`${path}/.repo-metadata.json`), this.targetBranch);
198
+ return content ? JSON.parse(content.parsedContent) : null;
199
+ }
200
+ catch (e) {
201
+ if (e instanceof errors_1.FileNotFoundError)
202
+ return null;
203
+ else
204
+ throw e;
191
205
  }
192
206
  }
193
207
  async updateVersionsMap(versionsMap, conventionalCommits) {
@@ -15,11 +15,13 @@
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.Node = void 0;
17
17
  const base_1 = require("./base");
18
+ const changelog_json_1 = require("../updaters/changelog-json");
18
19
  const package_lock_json_1 = require("../updaters/node/package-lock-json");
19
20
  const samples_package_json_1 = require("../updaters/node/samples-package-json");
20
21
  const changelog_1 = require("../updaters/changelog");
21
22
  const package_json_1 = require("../updaters/node/package-json");
22
23
  const errors_1 = require("../errors");
24
+ const filter_commits_1 = require("../util/filter-commits");
23
25
  class Node extends base_1.BaseStrategy {
24
26
  async buildUpdates(options) {
25
27
  var _a;
@@ -60,6 +62,20 @@ class Node extends base_1.BaseStrategy {
60
62
  version,
61
63
  }),
62
64
  });
65
+ // If a machine readable changelog.json exists update it:
66
+ if (options.commits && packageName) {
67
+ const commits = (0, filter_commits_1.filterCommits)(options.commits, this.changelogSections);
68
+ updates.push({
69
+ path: 'changelog.json',
70
+ createIfMissing: false,
71
+ updater: new changelog_json_1.ChangelogJson({
72
+ artifactName: packageName,
73
+ version,
74
+ commits,
75
+ language: 'JAVASCRIPT',
76
+ }),
77
+ });
78
+ }
63
79
  return updates;
64
80
  }
65
81
  async getDefaultPackageName() {
@@ -0,0 +1,9 @@
1
+ import { BaseStrategy, BuildUpdatesOptions } from './base';
2
+ import { Update } from '../update';
3
+ import { GitHubFileContents } from '@google-automations/git-file-utils';
4
+ export declare class Salesforce extends BaseStrategy {
5
+ private sfdxProjectJsonContents?;
6
+ protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
7
+ getDefaultPackageName(): Promise<string | undefined>;
8
+ protected getSfdxProjectJsonContents(): Promise<GitHubFileContents>;
9
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ // Copyright 2023 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Salesforce = void 0;
17
+ const base_1 = require("./base");
18
+ const changelog_1 = require("../updaters/changelog");
19
+ const errors_1 = require("../errors");
20
+ const sfdx_project_json_1 = require("../updaters/salesforce/sfdx-project-json");
21
+ const sfdxProjectJsonFileName = 'sfdx-project.json';
22
+ class Salesforce extends base_1.BaseStrategy {
23
+ async buildUpdates(options) {
24
+ const updates = [];
25
+ const version = options.newVersion;
26
+ updates.push({
27
+ path: this.addPath(this.changelogPath),
28
+ createIfMissing: true,
29
+ updater: new changelog_1.Changelog({
30
+ version,
31
+ changelogEntry: options.changelogEntry,
32
+ }),
33
+ });
34
+ updates.push({
35
+ path: this.addPath(sfdxProjectJsonFileName),
36
+ createIfMissing: false,
37
+ cachedFileContents: this.sfdxProjectJsonContents,
38
+ updater: new sfdx_project_json_1.SfdxProjectJson({
39
+ version,
40
+ }),
41
+ });
42
+ return updates;
43
+ }
44
+ async getDefaultPackageName() {
45
+ const pkgJsonContents = await this.getSfdxProjectJsonContents();
46
+ const pkg = JSON.parse(pkgJsonContents.parsedContent);
47
+ return pkg.name;
48
+ }
49
+ async getSfdxProjectJsonContents() {
50
+ if (!this.sfdxProjectJsonContents) {
51
+ try {
52
+ this.sfdxProjectJsonContents =
53
+ await this.github.getFileContentsOnBranch(this.addPath(sfdxProjectJsonFileName), this.targetBranch);
54
+ }
55
+ catch (e) {
56
+ if (e instanceof errors_1.FileNotFoundError) {
57
+ throw new errors_1.MissingRequiredFileError(this.addPath(sfdxProjectJsonFileName), 'salesforce', `${this.repository.owner}/${this.repository.repo}`);
58
+ }
59
+ throw e;
60
+ }
61
+ }
62
+ return this.sfdxProjectJsonContents;
63
+ }
64
+ }
65
+ exports.Salesforce = Salesforce;
66
+ //# sourceMappingURL=salesforce.js.map
@@ -0,0 +1,21 @@
1
+ import { Logger } from '../../util/logger';
2
+ import { DefaultUpdater } from '../default';
3
+ export type PackageDirectory = {
4
+ versionNumber: string;
5
+ default: boolean;
6
+ };
7
+ export type SfdxProjectFile = {
8
+ packageDirectories: PackageDirectory[];
9
+ name: string;
10
+ };
11
+ /**
12
+ * This updates a Salesfore sfdx-project.json file's main version.
13
+ */
14
+ export declare class SfdxProjectJson extends DefaultUpdater {
15
+ /**
16
+ * Given initial file contents, return updated contents.
17
+ * @param {string} content The initial content
18
+ * @returns {string} The updated content
19
+ */
20
+ updateContent(content: string, logger?: Logger): string;
21
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ // Copyright 2023 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.SfdxProjectJson = void 0;
17
+ const json_stringify_1 = require("../../util/json-stringify");
18
+ const logger_1 = require("../../util/logger");
19
+ const default_1 = require("../default");
20
+ /**
21
+ * This updates a Salesfore sfdx-project.json file's main version.
22
+ */
23
+ class SfdxProjectJson extends default_1.DefaultUpdater {
24
+ /**
25
+ * Given initial file contents, return updated contents.
26
+ * @param {string} content The initial content
27
+ * @returns {string} The updated content
28
+ */
29
+ updateContent(content, logger = logger_1.logger) {
30
+ const parsed = JSON.parse(content);
31
+ for (const packDir of parsed.packageDirectories) {
32
+ if (packDir.default) {
33
+ logger.info(`updating from ${packDir.versionNumber} to ${this.version}`);
34
+ packDir.versionNumber = `${this.version.toString()}.NEXT`;
35
+ }
36
+ }
37
+ return (0, json_stringify_1.jsonStringify)(parsed, content);
38
+ }
39
+ }
40
+ exports.SfdxProjectJson = SfdxProjectJson;
41
+ //# sourceMappingURL=sfdx-project-json.js.map
@@ -0,0 +1,12 @@
1
+ import { ChangelogSection } from '../changelog-notes';
2
+ import { ConventionalCommit } from '../commit';
3
+ /**
4
+ * Given a set of conventional commits and the configured
5
+ * changelog sections provided by the user, return the set
6
+ * of commits that should be displayed:
7
+ *
8
+ * @param commits
9
+ * @param changelogSections
10
+ * @returns ConventionalCommit[]
11
+ */
12
+ export declare function filterCommits(commits: ConventionalCommit[], changelogSections?: ChangelogSection[]): ConventionalCommit[];
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ // Copyright 2023 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.filterCommits = void 0;
17
+ const BREAKING_CHANGE_NOTE = 'BREAKING CHANGE';
18
+ const DEFAULT_CHANGELOG_SECTIONS = [
19
+ { type: 'feat', section: 'Features' },
20
+ { type: 'fix', section: 'Bug Fixes' },
21
+ { type: 'perf', section: 'Performance Improvements' },
22
+ { type: 'revert', section: 'Reverts' },
23
+ { type: 'chore', section: 'Miscellaneous Chores', hidden: true },
24
+ { type: 'docs', section: 'Documentation', hidden: true },
25
+ { type: 'style', section: 'Styles', hidden: true },
26
+ { type: 'refactor', section: 'Code Refactoring', hidden: true },
27
+ { type: 'test', section: 'Tests', hidden: true },
28
+ { type: 'build', section: 'Build System', hidden: true },
29
+ { type: 'ci', section: 'Continuous Integration', hidden: true },
30
+ ];
31
+ /**
32
+ * Given a set of conventional commits and the configured
33
+ * changelog sections provided by the user, return the set
34
+ * of commits that should be displayed:
35
+ *
36
+ * @param commits
37
+ * @param changelogSections
38
+ * @returns ConventionalCommit[]
39
+ */
40
+ function filterCommits(commits, changelogSections) {
41
+ changelogSections = changelogSections !== null && changelogSections !== void 0 ? changelogSections : DEFAULT_CHANGELOG_SECTIONS;
42
+ const hiddenSections = [];
43
+ const visibleSections = [];
44
+ for (const section of changelogSections) {
45
+ if (!section.hidden)
46
+ visibleSections.push(section.type);
47
+ else
48
+ hiddenSections.push(section.type);
49
+ }
50
+ return commits.filter(commit => {
51
+ const isBreaking = commit.notes.find(note => {
52
+ return note.title === BREAKING_CHANGE_NOTE;
53
+ });
54
+ return (visibleSections.includes(commit.type) ||
55
+ (isBreaking && hiddenSections.includes(commit.type)));
56
+ });
57
+ }
58
+ exports.filterCommits = filterCommits;
59
+ //# sourceMappingURL=filter-commits.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "15.2.0",
3
+ "version": "15.3.1",
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",
@@ -44,10 +44,10 @@
44
44
  "@types/iarna__toml": "^2.0.1",
45
45
  "@types/js-yaml": "^4.0.0",
46
46
  "@types/jsonpath": "^0.2.0",
47
- "@types/lerna__collect-updates": "^5.0.0",
48
- "@types/lerna__package": "^5.0.0",
49
- "@types/lerna__package-graph": "^5.0.0",
50
- "@types/lerna__run-topologically": "^5.0.0",
47
+ "@types/lerna__collect-updates": "^5.1.0",
48
+ "@types/lerna__package": "^5.1.0",
49
+ "@types/lerna__package-graph": "^5.1.0",
50
+ "@types/lerna__run-topologically": "^5.1.0",
51
51
  "@types/mocha": "^9.0.0",
52
52
  "@types/node": "^18.0.0",
53
53
  "@types/pino": "^7.0.0",
@@ -70,10 +70,10 @@
70
70
  "@conventional-commits/parser": "^0.4.1",
71
71
  "@google-automations/git-file-utils": "^1.2.5",
72
72
  "@iarna/toml": "^2.2.5",
73
- "@lerna/collect-updates": "^4.0.0",
74
- "@lerna/package": "^4.0.0",
75
- "@lerna/package-graph": "^4.0.0",
76
- "@lerna/run-topologically": "^4.0.0",
73
+ "@lerna/collect-updates": "^6.4.1",
74
+ "@lerna/package": "^6.4.1",
75
+ "@lerna/package-graph": "^6.4.1",
76
+ "@lerna/run-topologically": "^6.4.1",
77
77
  "@octokit/graphql": "^5.0.0",
78
78
  "@octokit/request": "^6.0.0",
79
79
  "@octokit/request-error": "^3.0.0",