release-please 13.0.2 → 13.2.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,39 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ### [13.2.1](https://github.com/googleapis/release-please/compare/v13.2.0...v13.2.1) (2022-01-12)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **php-yoshi:** fix parsing of pull request body ([#1213](https://github.com/googleapis/release-please/issues/1213)) ([00702ca](https://github.com/googleapis/release-please/commit/00702ca575e5d134505280b436e1348eccb2de01))
13
+
14
+ ## [13.2.0](https://github.com/googleapis/release-please/compare/v13.1.1...v13.2.0) (2022-01-11)
15
+
16
+
17
+ ### Features
18
+
19
+ * allow prerelease releases on Github ([#1181](https://github.com/googleapis/release-please/issues/1181)) ([267dbfc](https://github.com/googleapis/release-please/commit/267dbfc58a50cde7ffa378b357df62066a1218c9))
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * java snapshots should update all files with :current annotations ([#1204](https://github.com/googleapis/release-please/issues/1204)) ([6f3ae8b](https://github.com/googleapis/release-please/commit/6f3ae8b58afb6673dab2f49daa3d17fbbbef352c))
25
+
26
+ ### [13.1.1](https://www.github.com/googleapis/release-please/compare/v13.1.0...v13.1.1) (2022-01-03)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * **rust:** Rust strategy should update root Cargo files in a workspace ([#1182](https://www.github.com/googleapis/release-please/issues/1182)) ([26a040c](https://www.github.com/googleapis/release-please/commit/26a040cf06a7a2cf97b9ebc3d204bb36f0b2c13b)), closes [#1170](https://www.github.com/googleapis/release-please/issues/1170) [#1096](https://www.github.com/googleapis/release-please/issues/1096)
32
+
33
+ ## [13.1.0](https://www.github.com/googleapis/release-please/compare/v13.0.2...v13.1.0) (2021-12-29)
34
+
35
+
36
+ ### Features
37
+
38
+ * introduce generic updater ([#1157](https://www.github.com/googleapis/release-please/issues/1157)) ([c97598c](https://www.github.com/googleapis/release-please/commit/c97598c137b5018c76f5d62137e277b991f4bfa3)), closes [#435](https://www.github.com/googleapis/release-please/issues/435) [#305](https://www.github.com/googleapis/release-please/issues/305) [#1139](https://www.github.com/googleapis/release-please/issues/1139) [#1174](https://www.github.com/googleapis/release-please/issues/1174)
39
+
7
40
  ### [13.0.2](https://www.github.com/googleapis/release-please/compare/v13.0.1...v13.0.2) (2021-12-29)
8
41
 
9
42
 
package/README.md CHANGED
@@ -91,6 +91,24 @@ chore: release 2.0.0
91
91
  Release-As: 2.0.0
92
92
  ```
93
93
 
94
+ ## How can I fix release notes?
95
+
96
+ If you have merged a pull request and you would like to amend the commit message
97
+ used to generate the release notes for that commit, you can edit the body of
98
+ the merged pull requests and add a section like:
99
+
100
+ ```
101
+ BEGIN_COMMIT_OVERRIDE
102
+ feat: add ability to override merged commit message
103
+
104
+ fix: another message
105
+ chore: a third message
106
+ END_COMMIT_OVERRIDE
107
+ ```
108
+
109
+ The next time release please runs, it will use that override section as the
110
+ commit message instead of the merged commit message.
111
+
94
112
  ## Strategy (Language) types supported
95
113
 
96
114
  Release Please automates releases for the following flavors of repositories:
@@ -39,6 +39,7 @@ interface ManifestConfigArgs {
39
39
  }
40
40
  interface ReleaseArgs {
41
41
  draft?: boolean;
42
+ prerelease?: boolean;
42
43
  releaseLabel?: string;
43
44
  label?: string;
44
45
  }
@@ -76,6 +76,12 @@ function releaseOptions(yargs) {
76
76
  'tag creation upon "un-drafting" the release.',
77
77
  type: 'boolean',
78
78
  default: false,
79
+ })
80
+ .option('prerelease', {
81
+ describe: 'mark release that have prerelease versions ' +
82
+ 'as as a prerelease on Github',
83
+ type: 'boolean',
84
+ default: false,
79
85
  })
80
86
  .option('label', {
81
87
  default: 'autorelease: pending',
@@ -316,6 +322,7 @@ const createReleaseCommand = {
316
322
  component: argv.component,
317
323
  packageName: argv.packageName,
318
324
  draft: argv.draft,
325
+ prerelease: argv.prerelease,
319
326
  includeComponentInTag: argv.monorepoTags,
320
327
  }, extractManifestOptions(argv), argv.path);
321
328
  }
@@ -419,6 +426,7 @@ const bootstrapCommand = {
419
426
  component: argv.component,
420
427
  packageName: argv.packageName,
421
428
  draft: argv.draft,
429
+ prerelease: argv.prerelease,
422
430
  draftPullRequest: argv.draftPullRequest,
423
431
  bumpMinorPreMajor: argv.bumpMinorPreMajor,
424
432
  bumpPatchForMinorPreMajor: argv.bumpPatchForMinorPreMajor,
@@ -68,6 +68,7 @@ const allReleaseTypes = [
68
68
  const releasers = {
69
69
  go: options => new go_1.Go(options),
70
70
  'go-yoshi': options => new go_yoshi_1.GoYoshi(options),
71
+ 'java-yoshi': options => new java_yoshi_1.JavaYoshi(options),
71
72
  'krm-blueprint': options => new krm_blueprint_1.KRMBlueprint(options),
72
73
  node: options => new node_1.Node(options),
73
74
  ocaml: options => new ocaml_1.OCaml(options),
@@ -122,6 +123,7 @@ async function buildStrategy(options) {
122
123
  includeComponentInTag: options.includeComponentInTag,
123
124
  changelogNotes,
124
125
  pullRequestTitlePattern: options.pullRequestTitlePattern,
126
+ extraFiles: options.extraFiles,
125
127
  };
126
128
  switch (options.releaseType) {
127
129
  case 'ruby': {
@@ -136,23 +138,15 @@ async function buildStrategy(options) {
136
138
  versionFile: options.versionFile,
137
139
  });
138
140
  }
139
- case 'java-yoshi': {
140
- return new java_yoshi_1.JavaYoshi({
141
- ...strategyOptions,
142
- extraFiles: options.extraFiles,
143
- });
144
- }
145
141
  case 'java-backport': {
146
142
  return new java_yoshi_1.JavaYoshi({
147
143
  ...strategyOptions,
148
- extraFiles: options.extraFiles,
149
144
  versioningStrategy: new always_bump_patch_1.AlwaysBumpPatch(),
150
145
  });
151
146
  }
152
147
  case 'java-bom': {
153
148
  return new java_yoshi_1.JavaYoshi({
154
149
  ...strategyOptions,
155
- extraFiles: options.extraFiles,
156
150
  versioningStrategy: new dependency_manifest_1.DependencyManifest({
157
151
  bumpMinorPreMajor: options.bumpMinorPreMajor,
158
152
  bumpPatchForMinorPreMajor: options.bumpPatchForMinorPreMajor,
@@ -162,7 +156,6 @@ async function buildStrategy(options) {
162
156
  case 'java-lts': {
163
157
  return new java_yoshi_1.JavaYoshi({
164
158
  ...strategyOptions,
165
- extraFiles: options.extraFiles,
166
159
  versioningStrategy: new service_pack_1.ServicePackVersioningStrategy(),
167
160
  });
168
161
  }
@@ -46,6 +46,10 @@ interface ReleaseIteratorOptions {
46
46
  interface TagIteratorOptions {
47
47
  maxResults?: number;
48
48
  }
49
+ export interface ReleaseOptions {
50
+ draft?: boolean;
51
+ prerelease?: boolean;
52
+ }
49
53
  export interface GitHubRelease {
50
54
  name?: string;
51
55
  tagName: string;
@@ -306,13 +310,11 @@ export declare class GitHub {
306
310
  * Create a GitHub release
307
311
  *
308
312
  * @param {Release} release Release parameters
309
- * @param {boolean} draft Whether or not to create the release as a draft
313
+ * @param {ReleaseOptions} options Release option parameters
310
314
  * @throws {DuplicateReleaseError} if the release tag already exists
311
315
  * @throws {GitHubAPIError} on other API errors
312
316
  */
313
- createRelease: (release: Release, options?: {
314
- draft?: boolean | undefined;
315
- } | undefined) => Promise<GitHubRelease>;
317
+ createRelease: (release: Release, options?: ReleaseOptions | undefined) => Promise<GitHubRelease>;
316
318
  /**
317
319
  * Makes a comment on a issue/pull request.
318
320
  *
@@ -293,7 +293,7 @@ class GitHub {
293
293
  * Create a GitHub release
294
294
  *
295
295
  * @param {Release} release Release parameters
296
- * @param {boolean} draft Whether or not to create the release as a draft
296
+ * @param {ReleaseOptions} options Release option parameters
297
297
  * @throws {DuplicateReleaseError} if the release tag already exists
298
298
  * @throws {GitHubAPIError} on other API errors
299
299
  */
@@ -306,6 +306,7 @@ class GitHub {
306
306
  body: release.notes,
307
307
  sha: release.sha,
308
308
  draft: !!options.draft,
309
+ prerelease: !!options.prerelease,
309
310
  });
310
311
  return {
311
312
  name: resp.data.name || undefined,
@@ -651,39 +652,39 @@ class GitHub {
651
652
  logger_1.logger.debug(`Fetching ${states} pull requests on branch ${targetBranch} with cursor ${cursor}`);
652
653
  const response = await this.graphqlRequest({
653
654
  query: `query mergedPullRequests($owner: String!, $repo: String!, $num: Int!, $maxFilesChanged: Int, $targetBranch: String!, $states: [PullRequestState!], $cursor: String) {
654
- repository(owner: $owner, name: $repo) {
655
- pullRequests(first: $num, after: $cursor, baseRefName: $targetBranch, states: $states, orderBy: {field: CREATED_AT, direction: DESC}) {
656
- nodes {
657
- number
658
- title
659
- baseRefName
660
- headRefName
661
- labels(first: 10) {
662
- nodes {
663
- name
664
- }
655
+ repository(owner: $owner, name: $repo) {
656
+ pullRequests(first: $num, after: $cursor, baseRefName: $targetBranch, states: $states, orderBy: {field: CREATED_AT, direction: DESC}) {
657
+ nodes {
658
+ number
659
+ title
660
+ baseRefName
661
+ headRefName
662
+ labels(first: 10) {
663
+ nodes {
664
+ name
665
665
  }
666
- body
667
- mergeCommit {
668
- oid
666
+ }
667
+ body
668
+ mergeCommit {
669
+ oid
670
+ }
671
+ files(first: $maxFilesChanged) {
672
+ nodes {
673
+ path
669
674
  }
670
- files(first: $maxFilesChanged) {
671
- nodes {
672
- path
673
- }
674
- pageInfo {
675
- endCursor
676
- hasNextPage
677
- }
675
+ pageInfo {
676
+ endCursor
677
+ hasNextPage
678
678
  }
679
679
  }
680
- pageInfo {
681
- endCursor
682
- hasNextPage
683
- }
680
+ }
681
+ pageInfo {
682
+ endCursor
683
+ hasNextPage
684
684
  }
685
685
  }
686
- }`,
686
+ }
687
+ }`,
687
688
  cursor,
688
689
  owner: this.repository.owner,
689
690
  repo: this.repository.repo,
@@ -16,6 +16,7 @@ export interface ReleaserConfig {
16
16
  releaseAs?: string;
17
17
  skipGithubRelease?: boolean;
18
18
  draft?: boolean;
19
+ prerelease?: boolean;
19
20
  draftPullRequest?: boolean;
20
21
  component?: string;
21
22
  packageName?: string;
@@ -34,8 +35,9 @@ export interface CandidateReleasePullRequest {
34
35
  }
35
36
  export interface CandidateRelease extends Release {
36
37
  pullRequest: PullRequest;
37
- draft?: boolean;
38
38
  path: string;
39
+ draft?: boolean;
40
+ prerelease?: boolean;
39
41
  }
40
42
  interface ReleaserConfigJson {
41
43
  'release-type'?: ReleaseType;
@@ -45,6 +47,7 @@ interface ReleaserConfigJson {
45
47
  'release-as'?: string;
46
48
  'skip-github-release'?: boolean;
47
49
  draft?: boolean;
50
+ prerelease?: boolean;
48
51
  'draft-pull-request'?: boolean;
49
52
  label?: string;
50
53
  'release-label'?: string;
@@ -66,6 +69,7 @@ export interface ManifestOptions {
66
69
  labels?: string[];
67
70
  releaseLabels?: string[];
68
71
  draft?: boolean;
72
+ prerelease?: boolean;
69
73
  draftPullRequest?: boolean;
70
74
  }
71
75
  interface ReleaserPackageConfig extends ReleaserConfigJson {
@@ -116,6 +120,7 @@ export declare class Manifest {
116
120
  private bootstrapSha?;
117
121
  private lastReleaseSha?;
118
122
  private draft?;
123
+ private prerelease?;
119
124
  private draftPullRequest?;
120
125
  /**
121
126
  * Create a Manifest from explicit config in code. This assumes that the
@@ -439,6 +439,9 @@ class Manifest {
439
439
  path,
440
440
  pullRequest,
441
441
  draft: (_a = config.draft) !== null && _a !== void 0 ? _a : this.draft,
442
+ prerelease: config.prerelease &&
443
+ (!!release.tag.version.preRelease ||
444
+ release.tag.version.major === 0),
442
445
  });
443
446
  }
444
447
  }
@@ -488,6 +491,7 @@ class Manifest {
488
491
  async createRelease(release) {
489
492
  const githubRelease = await this.github.createRelease(release, {
490
493
  draft: release.draft,
494
+ prerelease: release.prerelease,
491
495
  });
492
496
  // comment on pull request
493
497
  const comment = `:robot: Release is at ${githubRelease.url} :sunflower:`;
@@ -553,6 +557,7 @@ function extractReleaserConfig(config) {
553
557
  releaseAs: config['release-as'],
554
558
  skipGithubRelease: config['skip-github-release'],
555
559
  draft: config.draft,
560
+ prerelease: config.prerelease,
556
561
  draftPullRequest: config['draft-pull-request'],
557
562
  component: config['component'],
558
563
  packageName: config['package-name'],
@@ -696,7 +701,7 @@ async function latestReleaseVersion(github, targetBranch, prefix, pullRequestTit
696
701
  return candidateTagVersion.sort((a, b) => b.compare(a))[0];
697
702
  }
698
703
  function mergeReleaserConfig(defaultConfig, pathConfig) {
699
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
704
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
700
705
  return {
701
706
  releaseType: (_b = (_a = pathConfig.releaseType) !== null && _a !== void 0 ? _a : defaultConfig.releaseType) !== null && _b !== void 0 ? _b : 'node',
702
707
  bumpMinorPreMajor: (_c = pathConfig.bumpMinorPreMajor) !== null && _c !== void 0 ? _c : defaultConfig.bumpMinorPreMajor,
@@ -706,10 +711,11 @@ function mergeReleaserConfig(defaultConfig, pathConfig) {
706
711
  releaseAs: (_g = pathConfig.releaseAs) !== null && _g !== void 0 ? _g : defaultConfig.releaseAs,
707
712
  skipGithubRelease: (_h = pathConfig.skipGithubRelease) !== null && _h !== void 0 ? _h : defaultConfig.skipGithubRelease,
708
713
  draft: (_j = pathConfig.draft) !== null && _j !== void 0 ? _j : defaultConfig.draft,
709
- component: (_k = pathConfig.component) !== null && _k !== void 0 ? _k : defaultConfig.component,
710
- packageName: (_l = pathConfig.packageName) !== null && _l !== void 0 ? _l : defaultConfig.packageName,
711
- versionFile: (_m = pathConfig.versionFile) !== null && _m !== void 0 ? _m : defaultConfig.versionFile,
712
- extraFiles: (_o = pathConfig.extraFiles) !== null && _o !== void 0 ? _o : defaultConfig.extraFiles,
714
+ prerelease: (_k = pathConfig.prerelease) !== null && _k !== void 0 ? _k : defaultConfig.prerelease,
715
+ component: (_l = pathConfig.component) !== null && _l !== void 0 ? _l : defaultConfig.component,
716
+ packageName: (_m = pathConfig.packageName) !== null && _m !== void 0 ? _m : defaultConfig.packageName,
717
+ versionFile: (_o = pathConfig.versionFile) !== null && _o !== void 0 ? _o : defaultConfig.versionFile,
718
+ extraFiles: (_p = pathConfig.extraFiles) !== null && _p !== void 0 ? _p : defaultConfig.extraFiles,
713
719
  };
714
720
  }
715
721
  /**
@@ -26,6 +26,7 @@ const pull_request_title_1 = require("../util/pull-request-title");
26
26
  const pull_request_body_1 = require("../util/pull-request-body");
27
27
  const branch_name_1 = require("../util/branch-name");
28
28
  const versioning_strategy_1 = require("../versioning-strategy");
29
+ const cargo_lock_1 = require("../updaters/rust/cargo-lock");
29
30
  /**
30
31
  * The plugin analyzed a cargo workspace and will bump dependencies
31
32
  * of managed packages if those dependencies are being updated.
@@ -50,7 +51,9 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
50
51
  }
51
52
  const allCrates = [];
52
53
  const candidatesByPackage = {};
53
- for (const path of cargoManifest.workspace.members) {
54
+ const members = cargoManifest.workspace.members;
55
+ members.push(manifest_1.ROOT_PROJECT_PATH);
56
+ for (const path of members) {
54
57
  const manifestPath = addPath(path, 'Cargo.toml');
55
58
  logger_1.logger.info(`looking for candidate with path: ${path}`);
56
59
  const candidate = candidates.find(c => c.path === path);
@@ -60,7 +63,8 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
60
63
  const manifest = common_1.parseCargoManifest(manifestContent.parsedContent);
61
64
  const packageName = (_c = manifest.package) === null || _c === void 0 ? void 0 : _c.name;
62
65
  if (!packageName) {
63
- throw new Error(`package manifest at ${manifestPath} is missing [package.name]`);
66
+ logger_1.logger.warn(`package manifest at ${manifestPath} is missing [package.name]`);
67
+ continue;
64
68
  }
65
69
  if (candidate) {
66
70
  candidatesByPackage[packageName] = candidate;
@@ -105,9 +109,15 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
105
109
  if (update.path === addPath(existingCandidate.path, 'Cargo.toml')) {
106
110
  update.updater = new raw_content_1.RawContent(updatedContent);
107
111
  }
108
- else if (update.updater instanceof changelog_1.Changelog) {
112
+ else if (update.updater instanceof changelog_1.Changelog && dependencyNotes) {
109
113
  update.updater.changelogEntry = appendDependenciesSectionToChangelog(update.updater.changelogEntry, dependencyNotes);
110
114
  }
115
+ else if (update.path === addPath(existingCandidate.path, 'Cargo.lock')) {
116
+ update.updater = new cargo_lock_1.CargoLock({
117
+ version,
118
+ versionsMap: updatedVersions,
119
+ });
120
+ }
111
121
  return update;
112
122
  });
113
123
  // append dependency notes
@@ -195,8 +205,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
195
205
  return graph;
196
206
  }
197
207
  inScope(candidate) {
198
- return (candidate.config.releaseType === 'rust' &&
199
- candidate.path !== manifest_1.ROOT_PROJECT_PATH);
208
+ return candidate.config.releaseType === 'rust';
200
209
  }
201
210
  packageNameFromPackage(pkg) {
202
211
  return pkg.name;
@@ -31,36 +31,18 @@ class Merge extends plugin_1.ManifestPlugin {
31
31
  if (candidates.length < 1) {
32
32
  return candidates;
33
33
  }
34
- const updatesByPath = {};
35
34
  const releaseData = [];
36
35
  const labels = new Set();
36
+ let rawUpdates = [];
37
37
  for (const candidate of candidates) {
38
38
  const pullRequest = candidate.pullRequest;
39
- for (const update of pullRequest.updates) {
40
- if (updatesByPath[update.path]) {
41
- updatesByPath[update.path].push(update);
42
- }
43
- else {
44
- updatesByPath[update.path] = [update];
45
- }
46
- }
39
+ rawUpdates = rawUpdates.concat(...pullRequest.updates);
47
40
  for (const label of pullRequest.labels) {
48
41
  labels.add(label);
49
42
  }
50
43
  releaseData.push(...pullRequest.body.releaseData);
51
44
  }
52
- const updates = [];
53
- for (const path in updatesByPath) {
54
- const update = updatesByPath[path];
55
- const updaters = update.map(u => u.updater);
56
- updates.push({
57
- path,
58
- createIfMissing: update[0].createIfMissing,
59
- updater: updaters.length === 1
60
- ? updaters[0]
61
- : new composite_1.CompositeUpdater(...updaters),
62
- });
63
- }
45
+ const updates = composite_1.mergeUpdates(rawUpdates);
64
46
  const pullRequest = {
65
47
  title: pull_request_title_1.PullRequestTitle.ofTargetBranch(this.targetBranch, manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN),
66
48
  body: new pull_request_body_1.PullRequestBody(releaseData),
@@ -9,6 +9,7 @@ import { Version, VersionsMap } from '../version';
9
9
  import { TagName } from '../util/tag-name';
10
10
  import { Release } from '../release';
11
11
  import { ReleasePullRequest } from '../release-pull-request';
12
+ import { PullRequestBody } from '../util/pull-request-body';
12
13
  import { PullRequest } from '../pull-request';
13
14
  export interface BuildUpdatesOptions {
14
15
  changelogEntry: string;
@@ -36,6 +37,7 @@ export interface BaseStrategyOptions {
36
37
  changelogNotes?: ChangelogNotes;
37
38
  includeComponentInTag?: boolean;
38
39
  pullRequestTitlePattern?: string;
40
+ extraFiles?: string[];
39
41
  }
40
42
  /**
41
43
  * A strategy is responsible for determining which files are
@@ -55,6 +57,7 @@ export declare abstract class BaseStrategy implements Strategy {
55
57
  private releaseAs?;
56
58
  private includeComponentInTag;
57
59
  private pullRequestTitlePattern?;
60
+ readonly extraFiles: string[];
58
61
  readonly changelogNotes: ChangelogNotes;
59
62
  protected changelogSections?: ChangelogSection[];
60
63
  constructor(options: BaseStrategyOptions);
@@ -90,10 +93,12 @@ export declare abstract class BaseStrategy implements Strategy {
90
93
  * open a pull request.
91
94
  */
92
95
  buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
96
+ private extraFileUpdates;
93
97
  protected changelogEmpty(changelogEntry: string): boolean;
94
98
  protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
95
99
  protected buildNewVersion(conventionalCommits: ConventionalCommit[], latestRelease?: Release): Promise<Version>;
96
100
  protected buildVersionsMap(_conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
101
+ protected parsePullRequestBody(pullRequestBody: string): Promise<PullRequestBody | undefined>;
97
102
  /**
98
103
  * Given a merged pull request, build the candidate release.
99
104
  * @param {PullRequest} mergedPullRequest The merged release pull request.
@@ -24,6 +24,8 @@ const logger_1 = require("../util/logger");
24
24
  const pull_request_title_1 = require("../util/pull-request-title");
25
25
  const branch_name_1 = require("../util/branch-name");
26
26
  const pull_request_body_1 = require("../util/pull-request-body");
27
+ const composite_1 = require("../updaters/composite");
28
+ const generic_1 = require("../updaters/generic");
27
29
  const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md';
28
30
  /**
29
31
  * A strategy is responsible for determining which files are
@@ -50,6 +52,7 @@ class BaseStrategy {
50
52
  options.changelogNotes || new default_2.DefaultChangelogNotes(options);
51
53
  this.includeComponentInTag = (_a = options.includeComponentInTag) !== null && _a !== void 0 ? _a : true;
52
54
  this.pullRequestTitlePattern = options.pullRequestTitlePattern;
55
+ this.extraFiles = options.extraFiles || [];
53
56
  }
54
57
  /**
55
58
  * Return the component for this strategy. This may be a computed field.
@@ -127,6 +130,7 @@ class BaseStrategy {
127
130
  versionsMap,
128
131
  latestVersion: latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag.version,
129
132
  });
133
+ const updatesWithExtras = composite_1.mergeUpdates(updates.concat(...this.extraFileUpdates(newVersion)));
130
134
  const pullRequestBody = new pull_request_body_1.PullRequestBody([
131
135
  {
132
136
  component,
@@ -137,13 +141,23 @@ class BaseStrategy {
137
141
  return {
138
142
  title: pullRequestTitle,
139
143
  body: pullRequestBody,
140
- updates,
144
+ updates: updatesWithExtras,
141
145
  labels,
142
146
  headRefName: branchName.toString(),
143
147
  version: newVersion,
144
148
  draft: draft !== null && draft !== void 0 ? draft : false,
145
149
  };
146
150
  }
151
+ extraFileUpdates(version) {
152
+ const genericUpdater = new generic_1.Generic({ version });
153
+ return this.extraFiles.map(path => {
154
+ return {
155
+ path,
156
+ createIfMissing: false,
157
+ updater: genericUpdater,
158
+ };
159
+ });
160
+ }
147
161
  changelogEmpty(changelogEntry) {
148
162
  return changelogEntry.split('\n').length <= 1;
149
163
  }
@@ -174,6 +188,9 @@ class BaseStrategy {
174
188
  async buildVersionsMap(_conventionalCommits) {
175
189
  return new Map();
176
190
  }
191
+ async parsePullRequestBody(pullRequestBody) {
192
+ return pull_request_body_1.PullRequestBody.parse(pullRequestBody);
193
+ }
177
194
  /**
178
195
  * Given a merged pull request, build the candidate release.
179
196
  * @param {PullRequest} mergedPullRequest The merged release pull request.
@@ -199,7 +216,7 @@ class BaseStrategy {
199
216
  logger_1.logger.error(`Bad branch name: ${mergedPullRequest.headBranchName}`);
200
217
  return;
201
218
  }
202
- const pullRequestBody = pull_request_body_1.PullRequestBody.parse(mergedPullRequest.body);
219
+ const pullRequestBody = await this.parsePullRequestBody(mergedPullRequest.body);
203
220
  if (!pullRequestBody) {
204
221
  logger_1.logger.error('Could not parse pull request body as a release PR');
205
222
  return;
@@ -5,20 +5,19 @@ import { GitHubFileContents } from '../github';
5
5
  import { Commit, ConventionalCommit } from '../commit';
6
6
  import { Release } from '../release';
7
7
  import { ReleasePullRequest } from '../release-pull-request';
8
- interface JavaStrategyOptions extends BaseStrategyOptions {
9
- extraFiles?: string[];
8
+ interface JavaBuildUpdatesOption extends BuildUpdatesOptions {
9
+ isSnapshot?: boolean;
10
10
  }
11
11
  export declare class JavaYoshi extends BaseStrategy {
12
- readonly extraFiles: string[];
13
12
  private versionsContent?;
14
13
  private snapshotVersioning;
15
- constructor(options: JavaStrategyOptions);
14
+ constructor(options: BaseStrategyOptions);
16
15
  buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
17
16
  private buildSnapshotPullRequest;
18
17
  private needsSnapshot;
19
18
  protected buildVersionsMap(): Promise<VersionsMap>;
20
19
  protected getVersionsContent(): Promise<GitHubFileContents>;
21
- protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
20
+ protected buildUpdates(options: JavaBuildUpdatesOption): Promise<Update[]>;
22
21
  protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
23
22
  protected initialReleaseVersion(): Version;
24
23
  }
@@ -49,7 +49,6 @@ class JavaYoshi extends base_1.BaseStrategy {
49
49
  const parentVersioningStrategy = options.versioningStrategy || new default_1.DefaultVersioningStrategy();
50
50
  options.versioningStrategy = new java_snapshot_1.JavaSnapshot(parentVersioningStrategy);
51
51
  super(options);
52
- this.extraFiles = options.extraFiles || [];
53
52
  this.snapshotVersioning = new java_add_snapshot_1.JavaAddSnapshot(parentVersioningStrategy);
54
53
  }
55
54
  async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
@@ -79,26 +78,24 @@ class JavaYoshi extends base_1.BaseStrategy {
79
78
  const branchName = component
80
79
  ? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch)
81
80
  : branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
81
+ const notes = '### Updating meta-information for bleeding-edge SNAPSHOT release.';
82
82
  const pullRequestBody = new pull_request_body_1.PullRequestBody([
83
83
  {
84
84
  component,
85
85
  version: newVersion,
86
- notes: '### Updating meta-information for bleeding-edge SNAPSHOT release.',
86
+ notes,
87
87
  },
88
88
  ]);
89
+ const updates = await this.buildUpdates({
90
+ newVersion,
91
+ versionsMap,
92
+ changelogEntry: notes,
93
+ isSnapshot: true,
94
+ });
89
95
  return {
90
96
  title: pullRequestTitle,
91
97
  body: pullRequestBody,
92
- updates: [
93
- {
94
- path: this.addPath('versions.txt'),
95
- createIfMissing: false,
96
- updater: new versions_manifest_1.VersionsManifest({
97
- version: newVersion,
98
- versionsMap,
99
- }),
100
- },
101
- ],
98
+ updates,
102
99
  labels: [],
103
100
  headRefName: branchName.toString(),
104
101
  version: newVersion,
@@ -150,6 +147,7 @@ class JavaYoshi extends base_1.BaseStrategy {
150
147
  updater: new java_update_1.JavaUpdate({
151
148
  version,
152
149
  versionsMap,
150
+ isSnapshot: options.isSnapshot,
153
151
  }),
154
152
  });
155
153
  });
@@ -161,6 +159,7 @@ class JavaYoshi extends base_1.BaseStrategy {
161
159
  updater: new java_update_1.JavaUpdate({
162
160
  version,
163
161
  versionsMap,
162
+ isSnapshot: options.isSnapshot,
164
163
  }),
165
164
  });
166
165
  });
@@ -172,6 +171,7 @@ class JavaYoshi extends base_1.BaseStrategy {
172
171
  updater: new java_update_1.JavaUpdate({
173
172
  version,
174
173
  versionsMap,
174
+ isSnapshot: options.isSnapshot,
175
175
  }),
176
176
  });
177
177
  });
@@ -182,17 +182,20 @@ class JavaYoshi extends base_1.BaseStrategy {
182
182
  updater: new java_update_1.JavaUpdate({
183
183
  version,
184
184
  versionsMap,
185
+ isSnapshot: options.isSnapshot,
185
186
  }),
186
187
  });
187
188
  });
188
- updates.push({
189
- path: this.addPath(this.changelogPath),
190
- createIfMissing: true,
191
- updater: new changelog_1.Changelog({
192
- version,
193
- changelogEntry: options.changelogEntry,
194
- }),
195
- });
189
+ if (!options.isSnapshot) {
190
+ updates.push({
191
+ path: this.addPath(this.changelogPath),
192
+ createIfMissing: true,
193
+ updater: new changelog_1.Changelog({
194
+ version,
195
+ changelogEntry: options.changelogEntry,
196
+ }),
197
+ });
198
+ }
196
199
  return updates;
197
200
  }
198
201
  async updateVersionsMap(versionsMap, conventionalCommits) {
@@ -3,8 +3,10 @@ import { Update } from '../update';
3
3
  import { Commit } from '../commit';
4
4
  import { Release } from '../release';
5
5
  import { ReleasePullRequest } from '../release-pull-request';
6
+ import { PullRequestBody } from '../util/pull-request-body';
6
7
  export declare class PHPYoshi extends BaseStrategy {
7
8
  constructor(options: BaseStrategyOptions);
8
9
  buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest>;
10
+ protected parsePullRequestBody(pullRequestBody: string): Promise<PullRequestBody | undefined>;
9
11
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
10
12
  }
@@ -146,6 +146,23 @@ class PHPYoshi extends base_1.BaseStrategy {
146
146
  draft: draft !== null && draft !== void 0 ? draft : false,
147
147
  };
148
148
  }
149
+ async parsePullRequestBody(pullRequestBody) {
150
+ const body = pull_request_body_1.PullRequestBody.parse(pullRequestBody);
151
+ if (!body) {
152
+ return undefined;
153
+ }
154
+ const component = await this.getComponent();
155
+ const notes = body.releaseData
156
+ .map(release => {
157
+ var _a;
158
+ return `<details><summary>${release.component}: ${(_a = release.version) === null || _a === void 0 ? void 0 : _a.toString()}</summary>\n\n${release.notes}\n</details>`;
159
+ })
160
+ .join('\n\n');
161
+ return new pull_request_body_1.PullRequestBody([{ component, notes }], {
162
+ footer: body.footer,
163
+ header: body.header,
164
+ });
165
+ }
149
166
  async buildUpdates(options) {
150
167
  const updates = [];
151
168
  const version = options.newVersion;
@@ -12,9 +12,6 @@ export declare class Rust extends BaseStrategy {
12
12
  * @returns the package's manifest, ie. `crates/foobar/Cargo.toml`
13
13
  */
14
14
  protected getPackageManifest(): Promise<CargoManifest | null>;
15
- /**
16
- * @returns the workspace's manifest, ie. `Cargo.toml` (top-level)
17
- */
18
- protected getWorkspaceManifest(): Promise<CargoManifest | null>;
15
+ private getContent;
19
16
  protected getManifest(path: string): Promise<CargoManifest | null>;
20
17
  }
@@ -25,6 +25,7 @@ const base_1 = require("./base");
25
25
  const version_1 = require("../version");
26
26
  class Rust extends base_1.BaseStrategy {
27
27
  async buildUpdates(options) {
28
+ var _a, _b, _c;
28
29
  const updates = [];
29
30
  const version = options.newVersion;
30
31
  updates.push({
@@ -35,30 +36,62 @@ class Rust extends base_1.BaseStrategy {
35
36
  changelogEntry: options.changelogEntry,
36
37
  }),
37
38
  });
38
- const workspaceManifest = await this.getWorkspaceManifest();
39
- const manifestPaths = [];
40
- let lockPath;
41
- if (workspaceManifest &&
42
- workspaceManifest.workspace &&
43
- workspaceManifest.workspace.members) {
39
+ const workspaceManifest = await this.getPackageManifest();
40
+ const versionsMap = new Map();
41
+ if ((_a = workspaceManifest === null || workspaceManifest === void 0 ? void 0 : workspaceManifest.workspace) === null || _a === void 0 ? void 0 : _a.members) {
44
42
  const members = workspaceManifest.workspace.members;
43
+ if ((_b = workspaceManifest.package) === null || _b === void 0 ? void 0 : _b.name) {
44
+ versionsMap.set(workspaceManifest.package.name, version);
45
+ }
46
+ else {
47
+ logger_1.logger.warn('No workspace manifest package name found');
48
+ }
45
49
  logger_1.logger.info(`found workspace with ${members.length} members, upgrading all`);
50
+ // Collect submodule names to update
51
+ const manifestsByPath = new Map();
46
52
  for (const member of members) {
47
- manifestPaths.push(`${member}/Cargo.toml`);
53
+ const manifestPath = `${member}/Cargo.toml`;
54
+ const manifestContent = await this.getContent(manifestPath);
55
+ if (!manifestContent) {
56
+ logger_1.logger.warn(`member ${member} declared but did not find Cargo.toml`);
57
+ continue;
58
+ }
59
+ const manifest = common_1.parseCargoManifest(manifestContent.parsedContent);
60
+ manifestsByPath.set(manifestPath, manifestContent);
61
+ if (!((_c = manifest.package) === null || _c === void 0 ? void 0 : _c.name)) {
62
+ logger_1.logger.warn(`member ${member} has no package name`);
63
+ continue;
64
+ }
65
+ versionsMap.set(manifest.package.name, version);
48
66
  }
49
- lockPath = 'Cargo.lock';
67
+ logger_1.logger.info(`updating ${manifestsByPath.size} submodules`);
68
+ logger_1.logger.debug('versions map:', versionsMap);
69
+ for (const [manifestPath, manifestContent] of manifestsByPath) {
70
+ updates.push({
71
+ path: this.addPath(manifestPath),
72
+ createIfMissing: false,
73
+ cachedFileContents: manifestContent,
74
+ updater: new cargo_toml_1.CargoToml({
75
+ version,
76
+ versionsMap,
77
+ }),
78
+ });
79
+ }
80
+ // Update root Cargo.toml
81
+ updates.push({
82
+ path: this.addPath('Cargo.toml'),
83
+ createIfMissing: false,
84
+ updater: new cargo_toml_1.CargoToml({
85
+ version,
86
+ versionsMap,
87
+ }),
88
+ });
50
89
  }
51
90
  else {
52
91
  const manifestPath = this.addPath('Cargo.toml');
53
92
  logger_1.logger.info(`single crate found, updating ${manifestPath}`);
54
- manifestPaths.push(manifestPath);
55
- lockPath = this.addPath('Cargo.lock');
56
- }
57
- const versionsMap = new Map();
58
- versionsMap.set(this.component || '', version);
59
- for (const path of manifestPaths) {
60
93
  updates.push({
61
- path,
94
+ path: manifestPath,
62
95
  createIfMissing: false,
63
96
  updater: new cargo_toml_1.CargoToml({
64
97
  version,
@@ -67,7 +100,7 @@ class Rust extends base_1.BaseStrategy {
67
100
  });
68
101
  }
69
102
  updates.push({
70
- path: lockPath,
103
+ path: this.addPath('Cargo.lock'),
71
104
  createIfMissing: false,
72
105
  updater: new cargo_lock_1.CargoLock({
73
106
  version,
@@ -92,28 +125,21 @@ class Rust extends base_1.BaseStrategy {
92
125
  */
93
126
  async getPackageManifest() {
94
127
  if (this.packageManifest === undefined) {
95
- this.packageManifest = await this.getManifest(this.addPath('Cargo.toml'));
128
+ this.packageManifest = await this.getManifest('Cargo.toml');
96
129
  }
97
130
  return this.packageManifest;
98
131
  }
99
- /**
100
- * @returns the workspace's manifest, ie. `Cargo.toml` (top-level)
101
- */
102
- async getWorkspaceManifest() {
103
- if (this.workspaceManifest === undefined) {
104
- this.workspaceManifest = await this.getManifest('Cargo.toml');
105
- }
106
- return this.workspaceManifest;
107
- }
108
- async getManifest(path) {
109
- let content;
132
+ async getContent(path) {
110
133
  try {
111
- content = await this.github.getFileContentsOnBranch(path, this.targetBranch);
134
+ return await this.github.getFileContentsOnBranch(this.addPath(path), this.targetBranch);
112
135
  }
113
136
  catch (e) {
114
137
  return null;
115
138
  }
116
- return common_1.parseCargoManifest(content.parsedContent);
139
+ }
140
+ async getManifest(path) {
141
+ const content = await this.getContent(path);
142
+ return content ? common_1.parseCargoManifest(content.parsedContent) : null;
117
143
  }
118
144
  }
119
145
  exports.Rust = Rust;
@@ -1,10 +1,10 @@
1
- import { Updater } from '../update';
1
+ import { Updater, Update } from '../update';
2
2
  /**
3
3
  * The CompositeUpdater chains 0...n updaters and updates
4
4
  * the content in order.
5
5
  */
6
6
  export declare class CompositeUpdater implements Updater {
7
- updaters: Updater[];
7
+ readonly updaters: Updater[];
8
8
  /**
9
9
  * Instantiate a new CompositeUpdater
10
10
  * @param {Updater[]} updaters The updaters to chain together
@@ -17,3 +17,4 @@ export declare class CompositeUpdater implements Updater {
17
17
  */
18
18
  updateContent(content: string | undefined): string;
19
19
  }
20
+ export declare function mergeUpdates(updates: Update[]): Update[];
@@ -13,7 +13,7 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.CompositeUpdater = void 0;
16
+ exports.mergeUpdates = exports.CompositeUpdater = void 0;
17
17
  /**
18
18
  * The CompositeUpdater chains 0...n updaters and updates
19
19
  * the content in order.
@@ -39,4 +39,27 @@ class CompositeUpdater {
39
39
  }
40
40
  }
41
41
  exports.CompositeUpdater = CompositeUpdater;
42
+ function mergeUpdates(updates) {
43
+ const updatesByPath = {};
44
+ for (const update of updates) {
45
+ if (updatesByPath[update.path]) {
46
+ updatesByPath[update.path].push(update);
47
+ }
48
+ else {
49
+ updatesByPath[update.path] = [update];
50
+ }
51
+ }
52
+ const newUpdates = [];
53
+ for (const path in updatesByPath) {
54
+ const update = updatesByPath[path];
55
+ const updaters = update.map(u => u.updater);
56
+ newUpdates.push({
57
+ path,
58
+ createIfMissing: update[0].createIfMissing,
59
+ updater: updaters.length === 1 ? updaters[0] : new CompositeUpdater(...updaters),
60
+ });
61
+ }
62
+ return newUpdates;
63
+ }
64
+ exports.mergeUpdates = mergeUpdates;
42
65
  //# sourceMappingURL=composite.js.map
@@ -0,0 +1,32 @@
1
+ import { DefaultUpdater } from './default';
2
+ /**
3
+ * The Generic updater looks for well known patterns and replaces
4
+ * content. The well known patterns are:
5
+ *
6
+ * 1. `x-release-please-version` if this string is found on the line,
7
+ * then replace a semver-looking string on that line with the next
8
+ * version
9
+ * 2. `x-release-please-major` if this string is found on the line,
10
+ * then replace an integer looking value with the the next version's
11
+ * major
12
+ * 3. `x-release-please-minor` if this string is found on the line,
13
+ * then replace an integer looking value with the the next version's
14
+ * minor
15
+ * 4. `x-release-please-patch` if this string is found on the line,
16
+ * then replace an integer looking value with the the next version's
17
+ * patch
18
+ *
19
+ * You can also use a block-based replacement. Content between the
20
+ * opening `x-release-please-start-version` and `x-release-please-end` will
21
+ * be considered for version replacement. You can also open these blocks
22
+ * with `x-release-please-start-<major|minor|patch>` to replace single
23
+ * numbers
24
+ */
25
+ export declare class Generic extends DefaultUpdater {
26
+ /**
27
+ * Given initial file contents, return updated contents.
28
+ * @param {string} content The initial content
29
+ * @returns {string} The updated content
30
+ */
31
+ updateContent(content: string | undefined): string;
32
+ }
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ // Copyright 2021 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.Generic = void 0;
17
+ const default_1 = require("./default");
18
+ const logger_1 = require("../util/logger");
19
+ const VERSION_REGEX = /(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-(?<preRelease>[\w.]+))?(\+(?<build>[-\w.]+))?/;
20
+ const SINGLE_VERSION_REGEX = /\b\d+\b/;
21
+ const INLINE_UPDATE_REGEX = /x-release-please-(?<scope>major|minor|patch|version)/;
22
+ const BLOCK_START_REGEX = /x-release-please-start-(?<scope>major|minor|patch|version)/;
23
+ const BLOCK_END_REGEX = /x-release-please-end/;
24
+ /**
25
+ * The Generic updater looks for well known patterns and replaces
26
+ * content. The well known patterns are:
27
+ *
28
+ * 1. `x-release-please-version` if this string is found on the line,
29
+ * then replace a semver-looking string on that line with the next
30
+ * version
31
+ * 2. `x-release-please-major` if this string is found on the line,
32
+ * then replace an integer looking value with the the next version's
33
+ * major
34
+ * 3. `x-release-please-minor` if this string is found on the line,
35
+ * then replace an integer looking value with the the next version's
36
+ * minor
37
+ * 4. `x-release-please-patch` if this string is found on the line,
38
+ * then replace an integer looking value with the the next version's
39
+ * patch
40
+ *
41
+ * You can also use a block-based replacement. Content between the
42
+ * opening `x-release-please-start-version` and `x-release-please-end` will
43
+ * be considered for version replacement. You can also open these blocks
44
+ * with `x-release-please-start-<major|minor|patch>` to replace single
45
+ * numbers
46
+ */
47
+ class Generic extends default_1.DefaultUpdater {
48
+ /**
49
+ * Given initial file contents, return updated contents.
50
+ * @param {string} content The initial content
51
+ * @returns {string} The updated content
52
+ */
53
+ updateContent(content) {
54
+ if (!content) {
55
+ return '';
56
+ }
57
+ const newLines = [];
58
+ let blockScope;
59
+ function replaceVersion(line, scope, version) {
60
+ switch (scope) {
61
+ case 'major':
62
+ newLines.push(line.replace(SINGLE_VERSION_REGEX, `${version.major}`));
63
+ return;
64
+ case 'minor':
65
+ newLines.push(line.replace(SINGLE_VERSION_REGEX, `${version.minor}`));
66
+ return;
67
+ case 'patch':
68
+ newLines.push(line.replace(SINGLE_VERSION_REGEX, `${version.patch}`));
69
+ return;
70
+ case 'version':
71
+ newLines.push(line.replace(VERSION_REGEX, version.toString()));
72
+ return;
73
+ default:
74
+ logger_1.logger.warn(`unknown block scope: ${scope}`);
75
+ newLines.push(line);
76
+ }
77
+ }
78
+ content.split(/\r?\n/).forEach(line => {
79
+ var _a, _b;
80
+ let match = line.match(INLINE_UPDATE_REGEX);
81
+ if (match) {
82
+ // replace inline versions
83
+ replaceVersion(line, (((_a = match.groups) === null || _a === void 0 ? void 0 : _a.scope) || 'version'), this.version);
84
+ }
85
+ else if (blockScope) {
86
+ // in a block, so try to replace versions
87
+ replaceVersion(line, blockScope, this.version);
88
+ if (line.match(BLOCK_END_REGEX)) {
89
+ blockScope = undefined;
90
+ }
91
+ }
92
+ else {
93
+ // look for block start line
94
+ match = line.match(BLOCK_START_REGEX);
95
+ if (match) {
96
+ if ((_b = match.groups) === null || _b === void 0 ? void 0 : _b.scope) {
97
+ blockScope = match.groups.scope;
98
+ }
99
+ else {
100
+ blockScope = 'version';
101
+ }
102
+ }
103
+ newLines.push(line);
104
+ }
105
+ });
106
+ return newLines.join('\n');
107
+ }
108
+ }
109
+ exports.Generic = Generic;
110
+ //# sourceMappingURL=generic.js.map
@@ -1,10 +1,15 @@
1
- import { DefaultUpdater } from '../default';
1
+ import { DefaultUpdater, UpdateOptions } from '../default';
2
+ interface JavaUpdateOptions extends UpdateOptions {
3
+ isSnapshot?: boolean;
4
+ }
2
5
  /**
3
6
  * Updates a file annotated with region markers. These region markers are
4
7
  * either denoted inline with `{x-version-update:<component-name>:current|released}`
5
8
  * or with a `{x-version-update-start:<component-name>}` and `{x-version-update-end}`.
6
9
  */
7
10
  export declare class JavaUpdate extends DefaultUpdater {
11
+ isSnapshot: boolean;
12
+ constructor(options: JavaUpdateOptions);
8
13
  /**
9
14
  * Given initial file contents, return updated contents.
10
15
  * @param {string} content The initial content
@@ -12,3 +17,4 @@ export declare class JavaUpdate extends DefaultUpdater {
12
17
  */
13
18
  updateContent(content: string): string;
14
19
  }
20
+ export {};
@@ -26,6 +26,10 @@ const VERSION_REGEX = /\d+\.\d+\.\d+(-\w+(\.\d+)?)?(-SNAPSHOT)?/;
26
26
  * or with a `{x-version-update-start:<component-name>}` and `{x-version-update-end}`.
27
27
  */
28
28
  class JavaUpdate extends default_1.DefaultUpdater {
29
+ constructor(options) {
30
+ super(options);
31
+ this.isSnapshot = !!options.isSnapshot;
32
+ }
29
33
  /**
30
34
  * Given initial file contents, return updated contents.
31
35
  * @param {string} content The initial content
@@ -40,7 +44,7 @@ class JavaUpdate extends default_1.DefaultUpdater {
40
44
  let blockPackageName = null;
41
45
  content.split(/\r?\n/).forEach(line => {
42
46
  let match = line.match(INLINE_UPDATE_REGEX);
43
- if (match) {
47
+ if (match && (!this.isSnapshot || match[2] === 'current')) {
44
48
  const newVersion = this.versionsMap.get(match[1]);
45
49
  if (newVersion) {
46
50
  newLines.push(line.replace(VERSION_REGEX, newVersion.toString()));
@@ -63,7 +67,7 @@ class JavaUpdate extends default_1.DefaultUpdater {
63
67
  }
64
68
  else {
65
69
  match = line.match(BLOCK_START_REGEX);
66
- if (match) {
70
+ if (match && (!this.isSnapshot || match[2] === 'current')) {
67
71
  blockPackageName = match[1];
68
72
  }
69
73
  newLines.push(line);
@@ -28,7 +28,6 @@ class CargoToml extends default_1.DefaultUpdater {
28
28
  * @returns {string} The updated content
29
29
  */
30
30
  updateContent(content) {
31
- var _a;
32
31
  let payload = content;
33
32
  if (!this.versionsMap) {
34
33
  throw new Error('updateContent called with no versions');
@@ -39,12 +38,8 @@ class CargoToml extends default_1.DefaultUpdater {
39
38
  logger_1.logger.error(msg);
40
39
  throw new Error(msg);
41
40
  }
41
+ payload = toml_edit_1.replaceTomlValue(payload, ['package', 'version'], this.version.toString());
42
42
  for (const [pkgName, pkgVersion] of this.versionsMap) {
43
- if (parsed.package.name === pkgName) {
44
- logger_1.logger.info(`updating own version from ${(_a = parsed.package) === null || _a === void 0 ? void 0 : _a.version} to ${pkgVersion}`);
45
- payload = toml_edit_1.replaceTomlValue(payload, ['package', 'version'], pkgVersion.toString());
46
- continue; // to next [pkgName, pkgVersion] pair
47
- }
48
43
  for (const depKind of common_1.DEP_KINDS) {
49
44
  const deps = parsed[depKind];
50
45
  if (!deps) {
@@ -87,7 +87,7 @@ function splitBody(body) {
87
87
  content,
88
88
  };
89
89
  }
90
- const SUMMARY_PATTERN = /^(?<component>.*): (?<version>\d+\.\d+\.\d+.*)$/;
90
+ const SUMMARY_PATTERN = /^(?<component>.*[^:]):? (?<version>\d+\.\d+\.\d+.*)$/;
91
91
  function extractMultipleReleases(notes) {
92
92
  const data = [];
93
93
  const root = node_html_parser_1.parse(notes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "13.0.2",
3
+ "version": "13.2.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",
@@ -41,7 +41,7 @@
41
41
  "@types/chai": "^4.1.7",
42
42
  "@types/iarna__toml": "^2.0.1",
43
43
  "@types/js-yaml": "^4.0.0",
44
- "@types/mocha": "^8.0.0",
44
+ "@types/mocha": "^9.0.0",
45
45
  "@types/node": "^16.0.0",
46
46
  "@types/pino": "^7.0.0",
47
47
  "@types/semver": "^7.0.0",
@@ -50,8 +50,8 @@
50
50
  "c8": "^7.0.0",
51
51
  "chai": "^4.2.0",
52
52
  "cross-env": "^7.0.0",
53
- "gts": "^2.0.0",
54
- "mocha": "^8.0.0",
53
+ "gts": "^3.0.0",
54
+ "mocha": "^9.0.0",
55
55
  "nock": "^13.0.0",
56
56
  "sinon": "12.0.1",
57
57
  "snap-shot-it": "^7.0.0"