release-please 13.15.1 → 13.16.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,27 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ### [13.16.2](https://github.com/googleapis/release-please/compare/v13.16.1...v13.16.2) (2022-05-12)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * throw ConfigurationError when required manifest config file is missing ([#1422](https://github.com/googleapis/release-please/issues/1422)) ([83e461e](https://github.com/googleapis/release-please/commit/83e461e8947d16fbd92d57a0d9c64d37ab0dfa42))
13
+
14
+ ### [13.16.1](https://github.com/googleapis/release-please/compare/v13.16.0...v13.16.1) (2022-05-10)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * release tagging can find branch components ([#1425](https://github.com/googleapis/release-please/issues/1425)) ([2947d1e](https://github.com/googleapis/release-please/commit/2947d1e9bc49cc25e7c5eef022ba4106d72e829f))
20
+
21
+ ## [13.16.0](https://github.com/googleapis/release-please/compare/v13.15.1...v13.16.0) (2022-05-06)
22
+
23
+
24
+ ### Features
25
+
26
+ * allow configuring separate-pull-requests per component ([#1412](https://github.com/googleapis/release-please/issues/1412)) ([d274421](https://github.com/googleapis/release-please/commit/d2744219fbbd6c58a10b177a824fb3715039162a))
27
+
7
28
  ### [13.15.1](https://github.com/googleapis/release-please/compare/v13.15.0...v13.15.1) (2022-05-05)
8
29
 
9
30
 
@@ -39,6 +39,7 @@ export interface ReleaserConfig {
39
39
  includeVInTag?: boolean;
40
40
  pullRequestTitlePattern?: string;
41
41
  tagSeparator?: string;
42
+ separatePullRequests?: boolean;
42
43
  changelogSections?: ChangelogSection[];
43
44
  changelogPath?: string;
44
45
  changelogType?: ChangelogNotesType;
@@ -75,6 +76,7 @@ interface ReleaserConfigJson {
75
76
  'changelog-type'?: ChangelogNotesType;
76
77
  'changelog-host'?: string;
77
78
  'pull-request-title-pattern'?: string;
79
+ 'separate-pull-requests'?: boolean;
78
80
  'tag-separator'?: string;
79
81
  'extra-files'?: string[];
80
82
  'version-file'?: string;
@@ -125,7 +127,6 @@ export interface ManifestConfig extends ReleaserConfigJson {
125
127
  'last-release-sha'?: string;
126
128
  'always-link-local'?: boolean;
127
129
  plugins?: PluginType[];
128
- 'separate-pull-requests'?: boolean;
129
130
  'group-pull-request-title-pattern'?: string;
130
131
  'release-search-depth'?: number;
131
132
  'commit-search-depth'?: number;
@@ -715,6 +715,7 @@ function extractReleaserConfig(config) {
715
715
  changelogType: config['changelog-type'],
716
716
  pullRequestTitlePattern: config['pull-request-title-pattern'],
717
717
  tagSeparator: config['tag-separator'],
718
+ separatePullRequests: config['separate-pull-requests'],
718
719
  };
719
720
  }
720
721
  /**
@@ -728,7 +729,7 @@ function extractReleaserConfig(config) {
728
729
  * @param {string} releaseAs Optional. Override release-as and use the given version
729
730
  */
730
731
  async function parseConfig(github, configFile, branch, onlyPath, releaseAs) {
731
- const config = await github.getFileJson(configFile, branch);
732
+ const config = await fetchManifestConfig(github, configFile, branch);
732
733
  const defaultConfig = extractReleaserConfig(config);
733
734
  const repositoryConfig = {};
734
735
  for (const path in config.packages) {
@@ -758,21 +759,61 @@ async function parseConfig(github, configFile, branch, onlyPath, releaseAs) {
758
759
  };
759
760
  return { config: repositoryConfig, options: manifestOptions };
760
761
  }
762
+ /**
763
+ * Helper to fetch manifest config
764
+ *
765
+ * @param {GitHub} github
766
+ * @param {string} configFile
767
+ * @param {string} branch
768
+ * @returns {ManifestConfig}
769
+ * @throws {ConfigurationError} if missing the manifest config file
770
+ */
771
+ async function fetchManifestConfig(github, configFile, branch) {
772
+ try {
773
+ return await github.getFileJson(configFile, branch);
774
+ }
775
+ catch (e) {
776
+ if (e instanceof errors_1.FileNotFoundError) {
777
+ throw new errors_1.ConfigurationError(`Missing required manifest config: ${configFile}`, 'base', `${github.repository.owner}/${github.repository.repo}`);
778
+ }
779
+ throw e;
780
+ }
781
+ }
761
782
  /**
762
783
  * Helper to parse the manifest versions file.
763
784
  *
764
785
  * @param {GitHub} github GitHub client
765
786
  * @param {string} manifestFile Path in the repository to the versions file
766
787
  * @param {string} branch Branch to fetch the versions file from
788
+ * @returns {Record<string, string>}
767
789
  */
768
790
  async function parseReleasedVersions(github, manifestFile, branch) {
769
- const manifestJson = await github.getFileJson(manifestFile, branch);
791
+ const manifestJson = await fetchReleasedVersions(github, manifestFile, branch);
770
792
  const releasedVersions = {};
771
793
  for (const path in manifestJson) {
772
794
  releasedVersions[path] = version_1.Version.parse(manifestJson[path]);
773
795
  }
774
796
  return releasedVersions;
775
797
  }
798
+ /**
799
+ * Helper to fetch manifest config
800
+ *
801
+ * @param {GitHub} github
802
+ * @param {string} manifestFile
803
+ * @param {string} branch
804
+ * @throws {ConfigurationError} if missing the manifest config file
805
+ */
806
+ async function fetchReleasedVersions(github, manifestFile, branch) {
807
+ try {
808
+ return await github.getFileJson(manifestFile, branch);
809
+ }
810
+ catch (e) {
811
+ if (e instanceof errors_1.FileNotFoundError) {
812
+ throw new errors_1.ConfigurationError(`Missing required manifest versions: ${manifestFile}`, 'base', `${github.repository.owner}/${github.repository.repo}`);
813
+ }
814
+ throw e;
815
+ }
816
+ }
776
817
  function isPublishedVersion(strategy, version) {
777
818
  return strategy.isPublishedVersion
778
819
  ? strategy.isPublishedVersion(version)
@@ -873,7 +914,7 @@ async function latestReleaseVersion(github, targetBranch, releaseFilter, prefix,
873
914
  return candidateTagVersion.sort((a, b) => b.compare(a))[0];
874
915
  }
875
916
  function mergeReleaserConfig(defaultConfig, pathConfig) {
876
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
917
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
877
918
  return {
878
919
  releaseType: (_b = (_a = pathConfig.releaseType) !== null && _a !== void 0 ? _a : defaultConfig.releaseType) !== null && _b !== void 0 ? _b : 'node',
879
920
  bumpMinorPreMajor: (_c = pathConfig.bumpMinorPreMajor) !== null && _c !== void 0 ? _c : defaultConfig.bumpMinorPreMajor,
@@ -893,6 +934,7 @@ function mergeReleaserConfig(defaultConfig, pathConfig) {
893
934
  includeVInTag: (_s = pathConfig.includeVInTag) !== null && _s !== void 0 ? _s : defaultConfig.includeVInTag,
894
935
  tagSeparator: (_t = pathConfig.tagSeparator) !== null && _t !== void 0 ? _t : defaultConfig.tagSeparator,
895
936
  pullRequestTitlePattern: (_u = pathConfig.pullRequestTitlePattern) !== null && _u !== void 0 ? _u : defaultConfig.pullRequestTitlePattern,
937
+ separatePullRequests: (_v = pathConfig.separatePullRequests) !== null && _v !== void 0 ? _v : defaultConfig.separatePullRequests,
896
938
  };
897
939
  }
898
940
  /**
@@ -38,11 +38,20 @@ class Merge extends plugin_1.ManifestPlugin {
38
38
  return candidates;
39
39
  }
40
40
  logger_1.logger.info(`Merging ${candidates.length} pull requests`);
41
+ const [inScopeCandidates, outOfScopeCandidates] = candidates.reduce((collection, candidate) => {
42
+ if (candidate.config.separatePullRequests) {
43
+ collection[1].push(candidate);
44
+ }
45
+ else {
46
+ collection[0].push(candidate);
47
+ }
48
+ return collection;
49
+ }, [[], []]);
41
50
  const releaseData = [];
42
51
  const labels = new Set();
43
52
  let rawUpdates = [];
44
53
  let rootRelease = null;
45
- for (const candidate of candidates) {
54
+ for (const candidate of inScopeCandidates) {
46
55
  const pullRequest = candidate.pullRequest;
47
56
  rawUpdates = rawUpdates.concat(...pullRequest.updates);
48
57
  for (const label of pullRequest.labels) {
@@ -72,6 +81,7 @@ class Merge extends plugin_1.ManifestPlugin {
72
81
  releaseType,
73
82
  },
74
83
  },
84
+ ...outOfScopeCandidates,
75
85
  ];
76
86
  }
77
87
  }
@@ -79,6 +79,7 @@ export declare abstract class BaseStrategy implements Strategy {
79
79
  */
80
80
  getComponent(): Promise<string | undefined>;
81
81
  getDefaultComponent(): Promise<string | undefined>;
82
+ protected getBranchComponent(): Promise<string | undefined>;
82
83
  getPackageName(): Promise<string | undefined>;
83
84
  getDefaultPackageName(): Promise<string | undefined>;
84
85
  protected normalizeComponent(component: string | undefined): string;
@@ -73,6 +73,9 @@ class BaseStrategy {
73
73
  var _a;
74
74
  return this.normalizeComponent((_a = this.packageName) !== null && _a !== void 0 ? _a : (await this.getDefaultPackageName()));
75
75
  }
76
+ async getBranchComponent() {
77
+ return this.component || (await this.getDefaultComponent());
78
+ }
76
79
  async getPackageName() {
77
80
  var _a;
78
81
  return (_a = this.packageName) !== null && _a !== void 0 ? _a : (await this.getDefaultPackageName());
@@ -143,8 +146,9 @@ class BaseStrategy {
143
146
  const newVersionTag = new tag_name_1.TagName(newVersion, this.includeComponentInTag ? component : undefined, this.tagSeparator, this.includeVInTag);
144
147
  logger_1.logger.debug('pull request title pattern:', this.pullRequestTitlePattern);
145
148
  const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion, this.pullRequestTitlePattern);
146
- const branchName = component
147
- ? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch)
149
+ const branchComponent = await this.getBranchComponent();
150
+ const branchName = branchComponent
151
+ ? branch_name_1.BranchName.ofComponentTargetBranch(branchComponent, this.targetBranch)
148
152
  : branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
149
153
  const releaseNotesBody = await this.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits);
150
154
  if (this.changelogEmpty(releaseNotesBody)) {
@@ -268,10 +272,11 @@ class BaseStrategy {
268
272
  let releaseData;
269
273
  if (pullRequestBody.releaseData.length === 1 &&
270
274
  !pullRequestBody.releaseData[0].component) {
275
+ const branchComponent = await this.getBranchComponent();
271
276
  // standalone release PR, ensure the components match
272
277
  if (this.normalizeComponent(branchName.component) !==
273
- this.normalizeComponent(component)) {
274
- logger_1.logger.warn(`PR component: ${branchName.component} does not match configured component: ${component}`);
278
+ this.normalizeComponent(branchComponent)) {
279
+ logger_1.logger.warn(`PR component: ${branchName.component} does not match configured component: ${branchComponent}`);
275
280
  return;
276
281
  }
277
282
  releaseData = pullRequestBody.releaseData[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "13.15.1",
3
+ "version": "13.16.2",
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",
@@ -60,7 +60,7 @@
60
60
  "gts": "^3.0.0",
61
61
  "mocha": "^9.0.0",
62
62
  "nock": "^13.0.0",
63
- "sinon": "13.0.2",
63
+ "sinon": "14.0.0",
64
64
  "snap-shot-it": "^7.0.0"
65
65
  },
66
66
  "dependencies": {