release-please 16.12.1 → 16.13.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.
package/README.md CHANGED
@@ -191,7 +191,7 @@ Release Please automates releases for the following flavors of repositories:
191
191
  | `krm-blueprint` | [A kpt package, with 1 or more KRM files and a CHANGELOG.md](https://github.com/GoogleCloudPlatform/blueprints/tree/main/catalog/project) |
192
192
  | `maven` | [Strategy for Maven projects, generates SNAPSHOT version after each release and updates `pom.xml` automatically](docs/java.md) |
193
193
  | `node` | [A Node.js repository, with a package.json and CHANGELOG.md](https://github.com/yargs/yargs) |
194
- | `expo` | An Expo based React Native repository, with a package.json, app.json and CHANGELOG.md |
194
+ | `expo` | [An Expo based React Native repository, with a package.json, app.json and CHANGELOG.md](https://github.com/dmi3y/expo-release-please-example) |
195
195
  | `ocaml` | [An OCaml repository, containing 1 or more opam or esy files and a CHANGELOG.md](https://github.com/grain-lang/binaryen.ml) |
196
196
  | `php` | A repository with a composer.json and a CHANGELOG.md |
197
197
  | `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 |
@@ -278,6 +278,11 @@ function taggingOptions(yargs) {
278
278
  .option('pull-request-footer', {
279
279
  describe: 'Footer for release PR',
280
280
  type: 'string',
281
+ })
282
+ .option('component-no-space', {
283
+ describe: 'release-please automatically adds ` ` (space) in front of parsed ${component}. Should this be disabled?',
284
+ type: 'boolean',
285
+ default: false,
281
286
  });
282
287
  }
283
288
  const createReleasePullRequestCommand = {
@@ -305,6 +310,7 @@ const createReleasePullRequestCommand = {
305
310
  pullRequestTitlePattern: argv.pullRequestTitlePattern,
306
311
  pullRequestHeader: argv.pullRequestHeader,
307
312
  pullRequestFooter: argv.pullRequestFooter,
313
+ componentNoSpace: argv.componentNoSpace,
308
314
  changelogSections: argv.changelogSections,
309
315
  releaseAs: argv.releaseAs,
310
316
  versioning: argv.versioningStrategy,
@@ -331,6 +331,7 @@ function parseConventionalCommits(commits, logger = logger_1.logger) {
331
331
  }
332
332
  catch (_err) {
333
333
  logger.debug(`commit could not be parsed: ${commit.sha} ${commit.message.split('\n')[0]}`);
334
+ logger.debug(`error message: ${_err}`);
334
335
  }
335
336
  }
336
337
  }
@@ -14,4 +14,4 @@ export { Logger, setLogger } from './util/logger';
14
14
  export { GitHub } from './github';
15
15
  export declare const configSchema: any;
16
16
  export declare const manifestSchema: any;
17
- export declare const VERSION = "16.12.1";
17
+ export declare const VERSION = "16.13.0";
@@ -36,6 +36,6 @@ Object.defineProperty(exports, "GitHub", { enumerable: true, get: function () {
36
36
  exports.configSchema = require('../../schemas/config.json');
37
37
  exports.manifestSchema = require('../../schemas/manifest.json');
38
38
  // x-release-please-start-version
39
- exports.VERSION = '16.12.1';
39
+ exports.VERSION = '16.13.0';
40
40
  // x-release-please-end
41
41
  //# sourceMappingURL=index.js.map
@@ -63,6 +63,7 @@ export interface ReleaserConfig {
63
63
  pullRequestTitlePattern?: string;
64
64
  pullRequestHeader?: string;
65
65
  pullRequestFooter?: string;
66
+ componentNoSpace?: boolean;
66
67
  tagSeparator?: string;
67
68
  separatePullRequests?: boolean;
68
69
  labels?: string[];
@@ -112,6 +113,7 @@ interface ReleaserConfigJson {
112
113
  'pull-request-title-pattern'?: string;
113
114
  'pull-request-header'?: string;
114
115
  'pull-request-footer'?: string;
116
+ 'component-no-space'?: boolean;
115
117
  'separate-pull-requests'?: boolean;
116
118
  'tag-separator'?: string;
117
119
  'extra-files'?: ExtraFile[];
@@ -392,6 +392,10 @@ class Manifest {
392
392
  !('pullRequestFooter' in mergeOptions)) {
393
393
  mergeOptions.pullRequestFooter = config.pullRequestFooter;
394
394
  }
395
+ if ('componentNoSpace' in config &&
396
+ !('componentNoSpace' in mergeOptions)) {
397
+ mergeOptions.componentNoSpace = config.componentNoSpace;
398
+ }
395
399
  }
396
400
  this.plugins.push(new merge_1.Merge(this.github, this.targetBranch, this.repositoryConfig, mergeOptions));
397
401
  }
@@ -818,6 +822,7 @@ function extractReleaserConfig(config) {
818
822
  pullRequestTitlePattern: config['pull-request-title-pattern'],
819
823
  pullRequestHeader: config['pull-request-header'],
820
824
  pullRequestFooter: config['pull-request-footer'],
825
+ componentNoSpace: config['component-no-space'],
821
826
  tagSeparator: config['tag-separator'],
822
827
  separatePullRequests: config['separate-pull-requests'],
823
828
  labels: (_a = config['label']) === null || _a === void 0 ? void 0 : _a.split(','),
@@ -946,7 +951,6 @@ function isPublishedVersion(strategy, version) {
946
951
  * @param {string} targetBranch Name of the scanned branch.
947
952
  * @param releaseFilter Validator function for release version. Used to filter-out SNAPSHOT releases for Java strategy.
948
953
  * @param {string} prefix Limit the release to a specific component.
949
- * @param pullRequestTitlePattern Configured PR title pattern.
950
954
  */
951
955
  async function latestReleaseVersion(github, targetBranch, releaseFilter, config, prefix, logger = logger_1.logger) {
952
956
  const branchPrefix = prefix
@@ -983,7 +987,7 @@ async function latestReleaseVersion(github, targetBranch, releaseFilter, config,
983
987
  logger.trace(`skipping commit: ${commitWithPullRequest.sha} branch component ${branchName.getComponent()} doesn't match expected prefix: ${branchPrefix}`);
984
988
  continue;
985
989
  }
986
- const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, config.pullRequestTitlePattern, logger);
990
+ const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, config.pullRequestTitlePattern, config.componentNoSpace, logger);
987
991
  if (!pullRequestTitle) {
988
992
  logger.trace(`skipping commit: ${commitWithPullRequest.sha} couldn't parse pull request title: ${mergedPullRequest.title}`);
989
993
  continue;
@@ -1039,7 +1043,7 @@ async function latestReleaseVersion(github, targetBranch, releaseFilter, config,
1039
1043
  return candidateTagVersion.sort((a, b) => b.compare(a))[0];
1040
1044
  }
1041
1045
  function mergeReleaserConfig(defaultConfig, pathConfig) {
1042
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
1046
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
1043
1047
  return {
1044
1048
  releaseType: (_b = (_a = pathConfig.releaseType) !== null && _a !== void 0 ? _a : defaultConfig.releaseType) !== null && _b !== void 0 ? _b : 'node',
1045
1049
  bumpMinorPreMajor: (_c = pathConfig.bumpMinorPreMajor) !== null && _c !== void 0 ? _c : defaultConfig.bumpMinorPreMajor,
@@ -1065,11 +1069,12 @@ function mergeReleaserConfig(defaultConfig, pathConfig) {
1065
1069
  pullRequestTitlePattern: (_y = pathConfig.pullRequestTitlePattern) !== null && _y !== void 0 ? _y : defaultConfig.pullRequestTitlePattern,
1066
1070
  pullRequestHeader: (_z = pathConfig.pullRequestHeader) !== null && _z !== void 0 ? _z : defaultConfig.pullRequestHeader,
1067
1071
  pullRequestFooter: (_0 = pathConfig.pullRequestFooter) !== null && _0 !== void 0 ? _0 : defaultConfig.pullRequestFooter,
1068
- separatePullRequests: (_1 = pathConfig.separatePullRequests) !== null && _1 !== void 0 ? _1 : defaultConfig.separatePullRequests,
1069
- skipSnapshot: (_2 = pathConfig.skipSnapshot) !== null && _2 !== void 0 ? _2 : defaultConfig.skipSnapshot,
1070
- initialVersion: (_3 = pathConfig.initialVersion) !== null && _3 !== void 0 ? _3 : defaultConfig.initialVersion,
1071
- extraLabels: (_4 = pathConfig.extraLabels) !== null && _4 !== void 0 ? _4 : defaultConfig.extraLabels,
1072
- excludePaths: (_5 = pathConfig.excludePaths) !== null && _5 !== void 0 ? _5 : defaultConfig.excludePaths,
1072
+ componentNoSpace: (_1 = pathConfig.componentNoSpace) !== null && _1 !== void 0 ? _1 : defaultConfig.componentNoSpace,
1073
+ separatePullRequests: (_2 = pathConfig.separatePullRequests) !== null && _2 !== void 0 ? _2 : defaultConfig.separatePullRequests,
1074
+ skipSnapshot: (_3 = pathConfig.skipSnapshot) !== null && _3 !== void 0 ? _3 : defaultConfig.skipSnapshot,
1075
+ initialVersion: (_4 = pathConfig.initialVersion) !== null && _4 !== void 0 ? _4 : defaultConfig.initialVersion,
1076
+ extraLabels: (_5 = pathConfig.extraLabels) !== null && _5 !== void 0 ? _5 : defaultConfig.extraLabels,
1077
+ excludePaths: (_6 = pathConfig.excludePaths) !== null && _6 !== void 0 ? _6 : defaultConfig.excludePaths,
1073
1078
  };
1074
1079
  }
1075
1080
  /**
@@ -2,6 +2,9 @@ import { CandidateReleasePullRequest } from '../manifest';
2
2
  import { WorkspacePlugin, DependencyGraph } from './workspace';
3
3
  import { CargoManifest } from '../updaters/rust/common';
4
4
  import { VersionsMap, Version } from '../version';
5
+ import { Strategy } from '../strategy';
6
+ import { Commit } from '../commit';
7
+ import { Release } from '../release';
5
8
  interface CrateInfo {
6
9
  /**
7
10
  * e.g. `crates/crate-a`
@@ -36,6 +39,8 @@ interface CrateInfo {
36
39
  * into a single rust package.
37
40
  */
38
41
  export declare class CargoWorkspace extends WorkspacePlugin<CrateInfo> {
42
+ private strategiesByPath;
43
+ private releasesByPath;
39
44
  protected buildAllPackages(candidates: CandidateReleasePullRequest[]): Promise<{
40
45
  allPackages: CrateInfo[];
41
46
  candidatesByPackage: Record<string, CandidateReleasePullRequest>;
@@ -48,5 +53,6 @@ export declare class CargoWorkspace extends WorkspacePlugin<CrateInfo> {
48
53
  protected inScope(candidate: CandidateReleasePullRequest): boolean;
49
54
  protected packageNameFromPackage(pkg: CrateInfo): string;
50
55
  protected pathFromPackage(pkg: CrateInfo): string;
56
+ preconfigure(strategiesByPath: Record<string, Strategy>, _commitsByPath: Record<string, Commit[]>, _releasesByPath: Record<string, Release>): Promise<Record<string, Strategy>>;
51
57
  }
52
58
  export {};
@@ -35,6 +35,11 @@ const errors_1 = require("../errors");
35
35
  * into a single rust package.
36
36
  */
37
37
  class CargoWorkspace extends workspace_1.WorkspacePlugin {
38
+ constructor() {
39
+ super(...arguments);
40
+ this.strategiesByPath = {};
41
+ this.releasesByPath = {};
42
+ }
38
43
  async buildAllPackages(candidates) {
39
44
  var _a, _b, _c, _d;
40
45
  const cargoManifestContent = await this.github.getFileContentsOnBranch('Cargo.toml', this.targetBranch);
@@ -143,6 +148,26 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
143
148
  const originalManifest = (0, common_1.parseCargoManifest)(pkg.manifestContent);
144
149
  const updatedManifest = (0, common_1.parseCargoManifest)(updatedContent);
145
150
  const dependencyNotes = getChangelogDepsNotes(originalManifest, updatedManifest);
151
+ const updatedPackage = {
152
+ ...pkg,
153
+ version: version.toString(),
154
+ };
155
+ const strategy = this.strategiesByPath[updatedPackage.path];
156
+ const latestRelease = this.releasesByPath[updatedPackage.path];
157
+ const basePullRequest = strategy
158
+ ? await strategy.buildReleasePullRequest([], latestRelease, false, [], {
159
+ newVersion: version,
160
+ })
161
+ : undefined;
162
+ if (basePullRequest) {
163
+ return this.updateCandidate({
164
+ path: pkg.path,
165
+ pullRequest: basePullRequest,
166
+ config: {
167
+ releaseType: 'rust',
168
+ },
169
+ }, pkg, updatedVersions);
170
+ }
146
171
  const pullRequest = {
147
172
  title: pull_request_title_1.PullRequestTitle.ofTargetBranch(this.targetBranch),
148
173
  body: new pull_request_body_1.PullRequestBody([
@@ -236,6 +261,12 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
236
261
  pathFromPackage(pkg) {
237
262
  return pkg.path;
238
263
  }
264
+ async preconfigure(strategiesByPath, _commitsByPath, _releasesByPath) {
265
+ // Using preconfigure to siphon releases and strategies.
266
+ this.strategiesByPath = strategiesByPath;
267
+ this.releasesByPath = _releasesByPath;
268
+ return strategiesByPath;
269
+ }
239
270
  }
240
271
  exports.CargoWorkspace = CargoWorkspace;
241
272
  function getChangelogDepsNotes(originalManifest, updatedManifest) {
@@ -5,6 +5,7 @@ export interface MergeOptions {
5
5
  pullRequestTitlePattern?: string;
6
6
  pullRequestHeader?: string;
7
7
  pullRequestFooter?: string;
8
+ componentNoSpace?: boolean;
8
9
  headBranchName?: string;
9
10
  forceMerge?: boolean;
10
11
  }
@@ -18,6 +19,7 @@ export declare class Merge extends ManifestPlugin {
18
19
  private pullRequestTitlePattern?;
19
20
  private pullRequestHeader?;
20
21
  private pullRequestFooter?;
22
+ private componentNoSpace?;
21
23
  private headBranchName?;
22
24
  private forceMerge;
23
25
  constructor(github: GitHub, targetBranch: string, repositoryConfig: RepositoryConfig, options?: MergeOptions);
@@ -34,6 +34,7 @@ class Merge extends plugin_1.ManifestPlugin {
34
34
  (_a = options.pullRequestTitlePattern) !== null && _a !== void 0 ? _a : manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN;
35
35
  this.pullRequestHeader = options.pullRequestHeader;
36
36
  this.pullRequestFooter = options.pullRequestFooter;
37
+ this.componentNoSpace = options.componentNoSpace;
37
38
  this.headBranchName = options.headBranchName;
38
39
  this.forceMerge = (_b = options.forceMerge) !== null && _b !== void 0 ? _b : false;
39
40
  }
@@ -69,7 +70,7 @@ class Merge extends plugin_1.ManifestPlugin {
69
70
  }
70
71
  const updates = (0, composite_1.mergeUpdates)(rawUpdates);
71
72
  const pullRequest = {
72
- title: pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(rootRelease === null || rootRelease === void 0 ? void 0 : rootRelease.pullRequest.title.component, this.targetBranch, rootRelease === null || rootRelease === void 0 ? void 0 : rootRelease.pullRequest.title.version, this.pullRequestTitlePattern),
73
+ title: pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(rootRelease === null || rootRelease === void 0 ? void 0 : rootRelease.pullRequest.title.component, this.targetBranch, rootRelease === null || rootRelease === void 0 ? void 0 : rootRelease.pullRequest.title.version, this.pullRequestTitlePattern, this.componentNoSpace),
73
74
  body: new pull_request_body_1.PullRequestBody(releaseData, {
74
75
  useComponents: true,
75
76
  header: this.pullRequestHeader,
@@ -21,9 +21,9 @@ const pull_request_body_1 = require("../util/pull-request-body");
21
21
  const branch_name_1 = require("../util/branch-name");
22
22
  const changelog_1 = require("../updaters/changelog");
23
23
  const workspace_1 = require("./workspace");
24
- const versioning_strategy_1 = require("../versioning-strategy");
25
24
  const composite_1 = require("../updaters/composite");
26
25
  const package_json_1 = require("../updaters/node/package-json");
26
+ const versioning_strategy_1 = require("../versioning-strategy");
27
27
  /**
28
28
  * The plugin analyzed a cargo workspace and will bump dependencies
29
29
  * of managed packages if those dependencies are being updated.
@@ -99,6 +99,9 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
99
99
  }
100
100
  bumpVersion(pkg) {
101
101
  const version = version_1.Version.parse(pkg.version);
102
+ const strategy = this.strategiesByPath[pkg.path];
103
+ if (strategy)
104
+ return strategy.versioningStrategy.bump(version, []);
102
105
  return new versioning_strategy_1.PatchVersionUpdate().bump(version);
103
106
  }
104
107
  updateCandidate(existingCandidate, pkg, updatedVersions) {
@@ -44,6 +44,7 @@ export interface BaseStrategyOptions {
44
44
  pullRequestTitlePattern?: string;
45
45
  pullRequestHeader?: string;
46
46
  pullRequestFooter?: string;
47
+ componentNoSpace?: boolean;
47
48
  extraFiles?: ExtraFile[];
48
49
  versionFile?: string;
49
50
  snapshotLabels?: string[];
@@ -76,6 +77,7 @@ export declare abstract class BaseStrategy implements Strategy {
76
77
  readonly pullRequestTitlePattern?: string;
77
78
  readonly pullRequestHeader?: string;
78
79
  readonly pullRequestFooter?: string;
80
+ readonly componentNoSpace?: boolean;
79
81
  readonly extraFiles: ExtraFile[];
80
82
  readonly extraLabels: string[];
81
83
  readonly changelogNotes: ChangelogNotes;
@@ -62,6 +62,7 @@ class BaseStrategy {
62
62
  this.pullRequestTitlePattern = options.pullRequestTitlePattern;
63
63
  this.pullRequestHeader = options.pullRequestHeader;
64
64
  this.pullRequestFooter = options.pullRequestFooter;
65
+ this.componentNoSpace = options.componentNoSpace;
65
66
  this.extraFiles = options.extraFiles || [];
66
67
  this.initialVersion = options.initialVersion;
67
68
  this.extraLabels = options.extraLabels || [];
@@ -156,7 +157,8 @@ class BaseStrategy {
156
157
  this.logger.debug('component:', component);
157
158
  const newVersionTag = new tag_name_1.TagName(newVersion, this.includeComponentInTag ? component : undefined, this.tagSeparator, this.includeVInTag);
158
159
  this.logger.debug('pull request title pattern:', this.pullRequestTitlePattern);
159
- const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion, this.pullRequestTitlePattern);
160
+ this.logger.debug('componentNoSpace:', this.componentNoSpace);
161
+ const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion, this.pullRequestTitlePattern, this.componentNoSpace);
160
162
  const branchComponent = await this.getBranchComponent();
161
163
  const branchName = branchComponent
162
164
  ? branch_name_1.BranchName.ofComponentTargetBranch(branchComponent, this.targetBranch)
@@ -350,8 +352,8 @@ class BaseStrategy {
350
352
  return;
351
353
  }
352
354
  const mergedTitlePattern = (_a = options === null || options === void 0 ? void 0 : options.groupPullRequestTitlePattern) !== null && _a !== void 0 ? _a : manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN;
353
- const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, this.pullRequestTitlePattern, this.logger) ||
354
- pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, mergedTitlePattern, this.logger);
355
+ const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, this.pullRequestTitlePattern, this.componentNoSpace, this.logger) ||
356
+ pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, mergedTitlePattern, this.componentNoSpace, this.logger);
355
357
  if (!pullRequestTitle) {
356
358
  this.logger.error(`Bad pull request title: '${mergedPullRequest.title}'`);
357
359
  return;
@@ -130,7 +130,7 @@ class Java extends base_1.BaseStrategy {
130
130
  const pullRequests = commits
131
131
  .map(commit => {
132
132
  var _a;
133
- return pull_request_title_1.PullRequestTitle.parse(((_a = commit.pullRequest) === null || _a === void 0 ? void 0 : _a.title) || commit.message, this.pullRequestTitlePattern, this.logger);
133
+ return pull_request_title_1.PullRequestTitle.parse(((_a = commit.pullRequest) === null || _a === void 0 ? void 0 : _a.title) || commit.message, this.pullRequestTitlePattern, this.componentNoSpace, this.logger);
134
134
  })
135
135
  .filter(pullRequest => pullRequest);
136
136
  const snapshotCommits = pullRequests
@@ -65,6 +65,7 @@ function releaserConfigToJsonConfig(config) {
65
65
  'pull-request-title-pattern': config.pullRequestTitlePattern,
66
66
  'pull-request-header': config.pullRequestHeader,
67
67
  'pull-request-footer': config.pullRequestFooter,
68
+ 'component-no-space': config.componentNoSpace,
68
69
  'separate-pull-requests': config.separatePullRequests,
69
70
  'tag-separator': config.tagSeparator,
70
71
  'extra-files': config.extraFiles,
@@ -1,19 +1,20 @@
1
1
  import { Logger } from './logger';
2
2
  import { Version } from '../version';
3
- export declare function generateMatchPattern(pullRequestTitlePattern?: string, logger?: Logger): RegExp;
3
+ export declare function generateMatchPattern(pullRequestTitlePattern?: string, componentNoSpace?: boolean, logger?: Logger): RegExp;
4
4
  export declare class PullRequestTitle {
5
5
  component?: string;
6
6
  targetBranch?: string;
7
7
  version?: Version;
8
8
  pullRequestTitlePattern: string;
9
9
  matchPattern: RegExp;
10
+ componentNoSpace?: boolean;
10
11
  private constructor();
11
- static parse(title: string, pullRequestTitlePattern?: string, logger?: Logger): PullRequestTitle | undefined;
12
- static ofComponentVersion(component: string, version: Version, pullRequestTitlePattern?: string): PullRequestTitle;
13
- static ofVersion(version: Version, pullRequestTitlePattern?: string): PullRequestTitle;
14
- static ofTargetBranchVersion(targetBranch: string, version: Version, pullRequestTitlePattern?: string): PullRequestTitle;
15
- static ofComponentTargetBranchVersion(component?: string, targetBranch?: string, version?: Version, pullRequestTitlePattern?: string): PullRequestTitle;
16
- static ofTargetBranch(targetBranch: string, pullRequestTitlePattern?: string): PullRequestTitle;
12
+ static parse(title: string, pullRequestTitlePattern?: string, componentNoSpace?: boolean, logger?: Logger): PullRequestTitle | undefined;
13
+ static ofComponentVersion(component: string, version: Version, pullRequestTitlePattern?: string, componentNoSpace?: boolean): PullRequestTitle;
14
+ static ofVersion(version: Version, pullRequestTitlePattern?: string, componentNoSpace?: boolean): PullRequestTitle;
15
+ static ofTargetBranchVersion(targetBranch: string, version: Version, pullRequestTitlePattern?: string, componentNoSpace?: boolean): PullRequestTitle;
16
+ static ofComponentTargetBranchVersion(component?: string, targetBranch?: string, version?: Version, pullRequestTitlePattern?: string, componentNoSpace?: boolean): PullRequestTitle;
17
+ static ofTargetBranch(targetBranch: string, pullRequestTitlePattern?: string, componentNoSpace?: boolean): PullRequestTitle;
17
18
  getTargetBranch(): string | undefined;
18
19
  getComponent(): string | undefined;
19
20
  getVersion(): Version | undefined;
@@ -20,7 +20,8 @@ const version_1 = require("../version");
20
20
  // at the script level are undefined, they are only defined inside function
21
21
  // or instance methods/properties.
22
22
  const DEFAULT_PR_TITLE_PATTERN = 'chore${scope}: release${component} ${version}';
23
- function generateMatchPattern(pullRequestTitlePattern, logger = logger_1.logger) {
23
+ const COMPONENT_NO_SPACE = false;
24
+ function generateMatchPattern(pullRequestTitlePattern, componentNoSpace, logger = logger_1.logger) {
24
25
  if (pullRequestTitlePattern &&
25
26
  pullRequestTitlePattern.search(/\$\{scope\}/) === -1)
26
27
  logger.warn("pullRequestTitlePattern miss the part of '${scope}'");
@@ -36,7 +37,9 @@ function generateMatchPattern(pullRequestTitlePattern, logger = logger_1.logger)
36
37
  .replace('(', '\\(')
37
38
  .replace(')', '\\)')
38
39
  .replace('${scope}', '(\\((?<branch>[\\w-./]+)\\))?')
39
- .replace('${component}', ' ?(?<component>@?[\\w-./]*)?')
40
+ .replace('${component}', componentNoSpace === true
41
+ ? '?(?<component>@?[\\w-./]*)?'
42
+ : ' ?(?<component>@?[\\w-./]*)?')
40
43
  .replace('${version}', 'v?(?<version>[0-9].*)')
41
44
  .replace('${branch}', '(?<branch>[\\w-./]+)?')}$`);
42
45
  }
@@ -48,10 +51,11 @@ class PullRequestTitle {
48
51
  this.targetBranch = opts.targetBranch;
49
52
  this.pullRequestTitlePattern =
50
53
  opts.pullRequestTitlePattern || DEFAULT_PR_TITLE_PATTERN;
51
- this.matchPattern = generateMatchPattern(this.pullRequestTitlePattern, opts.logger);
54
+ this.componentNoSpace = opts.componentNoSpace || COMPONENT_NO_SPACE;
55
+ this.matchPattern = generateMatchPattern(this.pullRequestTitlePattern, this.componentNoSpace, opts.logger);
52
56
  }
53
- static parse(title, pullRequestTitlePattern, logger = logger_1.logger) {
54
- const matchPattern = generateMatchPattern(pullRequestTitlePattern, logger);
57
+ static parse(title, pullRequestTitlePattern, componentNoSpace, logger = logger_1.logger) {
58
+ const matchPattern = generateMatchPattern(pullRequestTitlePattern, componentNoSpace, logger);
55
59
  const match = title.match(matchPattern);
56
60
  if (match === null || match === void 0 ? void 0 : match.groups) {
57
61
  return new PullRequestTitle({
@@ -61,36 +65,49 @@ class PullRequestTitle {
61
65
  component: match.groups['component'],
62
66
  targetBranch: match.groups['branch'],
63
67
  pullRequestTitlePattern,
68
+ componentNoSpace,
64
69
  logger,
65
70
  });
66
71
  }
67
72
  return undefined;
68
73
  }
69
- static ofComponentVersion(component, version, pullRequestTitlePattern) {
70
- return new PullRequestTitle({ version, component, pullRequestTitlePattern });
74
+ static ofComponentVersion(component, version, pullRequestTitlePattern, componentNoSpace) {
75
+ return new PullRequestTitle({
76
+ version,
77
+ component,
78
+ pullRequestTitlePattern,
79
+ componentNoSpace,
80
+ });
71
81
  }
72
- static ofVersion(version, pullRequestTitlePattern) {
73
- return new PullRequestTitle({ version, pullRequestTitlePattern });
82
+ static ofVersion(version, pullRequestTitlePattern, componentNoSpace) {
83
+ return new PullRequestTitle({
84
+ version,
85
+ pullRequestTitlePattern,
86
+ componentNoSpace,
87
+ });
74
88
  }
75
- static ofTargetBranchVersion(targetBranch, version, pullRequestTitlePattern) {
89
+ static ofTargetBranchVersion(targetBranch, version, pullRequestTitlePattern, componentNoSpace) {
76
90
  return new PullRequestTitle({
77
91
  version,
78
92
  targetBranch,
79
93
  pullRequestTitlePattern,
94
+ componentNoSpace,
80
95
  });
81
96
  }
82
- static ofComponentTargetBranchVersion(component, targetBranch, version, pullRequestTitlePattern) {
97
+ static ofComponentTargetBranchVersion(component, targetBranch, version, pullRequestTitlePattern, componentNoSpace) {
83
98
  return new PullRequestTitle({
84
99
  version,
85
100
  component,
86
101
  targetBranch,
87
102
  pullRequestTitlePattern,
103
+ componentNoSpace,
88
104
  });
89
105
  }
90
- static ofTargetBranch(targetBranch, pullRequestTitlePattern) {
106
+ static ofTargetBranch(targetBranch, pullRequestTitlePattern, componentNoSpace) {
91
107
  return new PullRequestTitle({
92
108
  targetBranch,
93
109
  pullRequestTitlePattern,
110
+ componentNoSpace,
94
111
  });
95
112
  }
96
113
  getTargetBranch() {
@@ -105,8 +122,18 @@ class PullRequestTitle {
105
122
  toString() {
106
123
  var _a;
107
124
  const scope = this.targetBranch ? `(${this.targetBranch})` : '';
108
- const component = this.component ? ` ${this.component}` : '';
125
+ const component = this.componentNoSpace === true
126
+ ? this.component
127
+ ? `${this.component}`
128
+ : ''
129
+ : this.component
130
+ ? ` ${this.component}`
131
+ : '';
109
132
  const version = (_a = this.version) !== null && _a !== void 0 ? _a : '';
133
+ if (this.componentNoSpace === true && !component) {
134
+ console.log('`component` is empty. Removing component from title pattern..');
135
+ this.pullRequestTitlePattern = this.pullRequestTitlePattern.replace('${component} ', '');
136
+ }
110
137
  return this.pullRequestTitlePattern
111
138
  .replace('${scope}', scope)
112
139
  .replace('${component}', component)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "16.12.1",
3
+ "version": "16.13.0",
4
4
  "description": "generate release PRs based on the conventionalcommits.org spec",
5
5
  "main": "./build/src/index.js",
6
6
  "bin": "./build/src/bin/release-please.js",
@@ -62,7 +62,7 @@
62
62
  "gts": "^3.1.0",
63
63
  "mocha": "^9.2.2",
64
64
  "nock": "^13.0.0",
65
- "sinon": "18.0.0",
65
+ "sinon": "18.0.1",
66
66
  "snap-shot-it": "^7.0.0"
67
67
  },
68
68
  "dependencies": {
@@ -81,7 +81,7 @@
81
81
  "conventional-changelog-writer": "^6.0.0",
82
82
  "conventional-commits-filter": "^3.0.0",
83
83
  "detect-indent": "^6.1.0",
84
- "diff": "^5.0.0",
84
+ "diff": "^7.0.0",
85
85
  "figures": "^3.0.0",
86
86
  "http-proxy-agent": "^7.0.0",
87
87
  "https-proxy-agent": "^7.0.0",
@@ -233,6 +233,10 @@
233
233
  "initial-version": {
234
234
  "description": "Releases the initial library with a specified version",
235
235
  "type": "string"
236
+ },
237
+ "component-no-space": {
238
+ "description": "release-please automatically adds ` ` (space) in front of parsed ${component}. This option indicates whether that behaviour should be disabled. Defaults to `false`",
239
+ "type": "boolean"
236
240
  }
237
241
  }
238
242
  }
@@ -423,6 +427,10 @@
423
427
  "release-label": {
424
428
  "description": "Comma-separated list of labels to add to a pull request that has been released/tagged",
425
429
  "type": "string"
430
+ },
431
+ "component-no-space": {
432
+ "description": "release-please automatically adds ` ` (space) in front of parsed ${component}. This option indicates whether that behaviour should be disabled. Defaults to `false`",
433
+ "type": "boolean"
426
434
  }
427
435
  },
428
436
  "required": ["packages"]
@@ -467,6 +475,7 @@
467
475
  "version-file": true,
468
476
  "snapshot-label": true,
469
477
  "initial-version": true,
470
- "exclude-paths": true
478
+ "exclude-paths": true,
479
+ "component-no-space": false
471
480
  }
472
481
  }