release-please 13.0.0-candidate.3 → 13.0.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +33 -131
  3. package/build/src/bin/release-please.d.ts +0 -1
  4. package/build/src/bin/release-please.js +24 -6
  5. package/build/src/changelog-notes/default.d.ts +1 -3
  6. package/build/src/changelog-notes/default.js +2 -3
  7. package/build/src/changelog-notes/github.d.ts +8 -0
  8. package/build/src/changelog-notes/github.js +26 -0
  9. package/build/src/changelog-notes.d.ts +3 -0
  10. package/build/src/changelog-notes.js +24 -0
  11. package/build/src/commit.d.ts +1 -1
  12. package/build/src/commit.js +14 -1
  13. package/build/src/factory.d.ts +13 -0
  14. package/build/src/factory.js +26 -1
  15. package/build/src/github.d.ts +48 -7
  16. package/build/src/github.js +73 -19
  17. package/build/src/index.d.ts +5 -0
  18. package/build/src/index.js +27 -0
  19. package/build/src/manifest.d.ts +7 -3
  20. package/build/src/manifest.js +93 -24
  21. package/build/src/plugins/cargo-workspace.js +2 -2
  22. package/build/src/plugins/merge.js +4 -1
  23. package/build/src/plugins/node-workspace.js +2 -2
  24. package/build/src/pull-request.d.ts +8 -8
  25. package/build/src/release-pull-request.d.ts +6 -6
  26. package/build/src/strategies/base.d.ts +108 -0
  27. package/build/src/strategies/base.js +253 -0
  28. package/build/src/strategies/dart.d.ts +2 -2
  29. package/build/src/strategies/dart.js +2 -2
  30. package/build/src/strategies/elixir.d.ts +2 -2
  31. package/build/src/strategies/elixir.js +2 -2
  32. package/build/src/strategies/go-yoshi.d.ts +3 -3
  33. package/build/src/strategies/go-yoshi.js +10 -2
  34. package/build/src/strategies/go.d.ts +2 -2
  35. package/build/src/strategies/go.js +2 -2
  36. package/build/src/strategies/helm.d.ts +2 -2
  37. package/build/src/strategies/helm.js +2 -2
  38. package/build/src/strategies/java-yoshi.d.ts +5 -4
  39. package/build/src/strategies/java-yoshi.js +58 -2
  40. package/build/src/strategies/krm-blueprint.d.ts +2 -2
  41. package/build/src/strategies/krm-blueprint.js +3 -3
  42. package/build/src/strategies/node.d.ts +2 -2
  43. package/build/src/strategies/node.js +2 -2
  44. package/build/src/strategies/ocaml.d.ts +2 -2
  45. package/build/src/strategies/ocaml.js +2 -2
  46. package/build/src/strategies/php-yoshi.d.ts +3 -3
  47. package/build/src/strategies/php-yoshi.js +3 -2
  48. package/build/src/strategies/php.d.ts +3 -3
  49. package/build/src/strategies/php.js +2 -2
  50. package/build/src/strategies/python.d.ts +2 -2
  51. package/build/src/strategies/python.js +2 -2
  52. package/build/src/strategies/ruby-yoshi.d.ts +3 -3
  53. package/build/src/strategies/ruby-yoshi.js +7 -2
  54. package/build/src/strategies/ruby.d.ts +3 -3
  55. package/build/src/strategies/ruby.js +2 -2
  56. package/build/src/strategies/rust.d.ts +2 -2
  57. package/build/src/strategies/rust.js +2 -2
  58. package/build/src/strategies/simple.d.ts +2 -2
  59. package/build/src/strategies/simple.js +2 -2
  60. package/build/src/strategies/terraform-module.d.ts +2 -2
  61. package/build/src/strategies/terraform-module.js +2 -2
  62. package/build/src/strategy.d.ts +8 -70
  63. package/build/src/strategy.js +0 -226
  64. package/build/src/updaters/go/version-go.d.ts +4 -0
  65. package/build/src/updaters/go/version-go.js +24 -0
  66. package/build/src/updaters/rust/cargo-toml.js +5 -1
  67. package/build/src/util/branch-name.js +65 -7
  68. package/build/src/util/commit-split.js +3 -0
  69. package/build/src/util/pull-request-title.js +1 -0
  70. package/build/src/version.d.ts +28 -5
  71. package/build/src/version.js +26 -0
  72. package/build/src/versioning-strategies/always-bump-patch.d.ts +4 -0
  73. package/build/src/versioning-strategies/always-bump-patch.js +4 -0
  74. package/build/src/versioning-strategies/default.d.ts +31 -0
  75. package/build/src/versioning-strategies/default.js +31 -0
  76. package/build/src/versioning-strategies/dependency-manifest.d.ts +8 -0
  77. package/build/src/versioning-strategies/dependency-manifest.js +8 -0
  78. package/build/src/versioning-strategies/java-add-snapshot.d.ts +4 -0
  79. package/build/src/versioning-strategies/java-add-snapshot.js +6 -5
  80. package/build/src/versioning-strategies/java-snapshot.d.ts +4 -0
  81. package/build/src/versioning-strategies/java-snapshot.js +4 -1
  82. package/build/src/versioning-strategies/service-pack.d.ts +5 -0
  83. package/build/src/versioning-strategies/service-pack.js +10 -3
  84. package/build/src/versioning-strategy.d.ts +67 -5
  85. package/build/src/versioning-strategy.js +37 -10
  86. package/package.json +4 -4
  87. package/build/src/release-notes.d.ts +0 -29
  88. package/build/src/release-notes.js +0 -71
@@ -1,6 +1,6 @@
1
- import { Strategy, BuildUpdatesOptions } from '../strategy';
1
+ import { BaseStrategy, BuildUpdatesOptions } from './base';
2
2
  import { Update } from '../update';
3
- export declare class Node extends Strategy {
3
+ export declare class Node extends BaseStrategy {
4
4
  private pkgJsonContents?;
5
5
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
6
6
  getDefaultPackageName(): Promise<string | undefined>;
@@ -14,12 +14,12 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.Node = void 0;
17
- const strategy_1 = require("../strategy");
17
+ const base_1 = require("./base");
18
18
  const package_lock_json_1 = require("../updaters/node/package-lock-json");
19
19
  const samples_package_json_1 = require("../updaters/node/samples-package-json");
20
20
  const changelog_1 = require("../updaters/changelog");
21
21
  const package_json_1 = require("../updaters/node/package-json");
22
- class Node extends strategy_1.Strategy {
22
+ class Node extends base_1.BaseStrategy {
23
23
  async buildUpdates(options) {
24
24
  const updates = [];
25
25
  const version = options.newVersion;
@@ -1,5 +1,5 @@
1
- import { Strategy, BuildUpdatesOptions } from '../strategy';
1
+ import { BaseStrategy, BuildUpdatesOptions } from './base';
2
2
  import { Update } from '../update';
3
- export declare class OCaml extends Strategy {
3
+ export declare class OCaml extends BaseStrategy {
4
4
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
5
5
  }
@@ -20,9 +20,9 @@ const changelog_1 = require("../updaters/changelog");
20
20
  const opam_1 = require("../updaters/ocaml/opam");
21
21
  const esy_json_1 = require("../updaters/ocaml/esy-json");
22
22
  const dune_project_1 = require("../updaters/ocaml/dune-project");
23
- const strategy_1 = require("../strategy");
23
+ const base_1 = require("./base");
24
24
  const notEsyLock = (path) => !path.startsWith('esy.lock');
25
- class OCaml extends strategy_1.Strategy {
25
+ class OCaml extends base_1.BaseStrategy {
26
26
  async buildUpdates(options) {
27
27
  const updates = [];
28
28
  const version = options.newVersion;
@@ -1,10 +1,10 @@
1
- import { Strategy, BuildUpdatesOptions, StrategyOptions } from '../strategy';
1
+ import { BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions } from './base';
2
2
  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
- export declare class PHPYoshi extends Strategy {
7
- constructor(options: StrategyOptions);
6
+ export declare class PHPYoshi extends BaseStrategy {
7
+ constructor(options: BaseStrategyOptions);
8
8
  buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest>;
9
9
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
10
10
  }
@@ -14,7 +14,7 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.PHPYoshi = void 0;
17
- const strategy_1 = require("../strategy");
17
+ const base_1 = require("./base");
18
18
  const changelog_1 = require("../updaters/changelog");
19
19
  const root_composer_update_packages_1 = require("../updaters/php/root-composer-update-packages");
20
20
  const php_manifest_1 = require("../updaters/php/php-manifest");
@@ -41,7 +41,7 @@ const CHANGELOG_SECTIONS = [
41
41
  { type: 'build', section: 'Build System', hidden: true },
42
42
  { type: 'ci', section: 'Continuous Integration', hidden: true },
43
43
  ];
44
- class PHPYoshi extends strategy_1.Strategy {
44
+ class PHPYoshi extends base_1.BaseStrategy {
45
45
  constructor(options) {
46
46
  super({
47
47
  ...options,
@@ -79,6 +79,7 @@ class PHPYoshi extends strategy_1.Strategy {
79
79
  version: newVersion.toString(),
80
80
  previousTag: (_a = latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag) === null || _a === void 0 ? void 0 : _a.toString(),
81
81
  currentTag: newVersionTag.toString(),
82
+ targetBranch: this.targetBranch,
82
83
  });
83
84
  releaseNotesBody = updatePHPChangelogEntry(`${composer.name} ${newVersion.toString()}`, releaseNotesBody, partialReleaseNotes);
84
85
  }
@@ -1,6 +1,6 @@
1
- import { Strategy, BuildUpdatesOptions, StrategyOptions } from '../strategy';
1
+ import { BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions } from './base';
2
2
  import { Update } from '../update';
3
- export declare class PHP extends Strategy {
4
- constructor(options: StrategyOptions);
3
+ export declare class PHP extends BaseStrategy {
4
+ constructor(options: BaseStrategyOptions);
5
5
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
6
6
  }
@@ -18,7 +18,7 @@ exports.PHP = void 0;
18
18
  const changelog_1 = require("../updaters/changelog");
19
19
  // PHP Specific.
20
20
  const root_composer_update_packages_1 = require("../updaters/php/root-composer-update-packages");
21
- const strategy_1 = require("../strategy");
21
+ const base_1 = require("./base");
22
22
  const CHANGELOG_SECTIONS = [
23
23
  { type: 'feat', section: 'Features' },
24
24
  { type: 'fix', section: 'Bug Fixes' },
@@ -32,7 +32,7 @@ const CHANGELOG_SECTIONS = [
32
32
  { type: 'build', section: 'Build System', hidden: true },
33
33
  { type: 'ci', section: 'Continuous Integration', hidden: true },
34
34
  ];
35
- class PHP extends strategy_1.Strategy {
35
+ class PHP extends base_1.BaseStrategy {
36
36
  constructor(options) {
37
37
  var _a;
38
38
  options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS;
@@ -1,7 +1,7 @@
1
- import { Strategy, BuildUpdatesOptions } from '../strategy';
1
+ import { BaseStrategy, BuildUpdatesOptions } from './base';
2
2
  import { Update } from '../update';
3
3
  import { Version } from '../version';
4
- export declare class Python extends Strategy {
4
+ export declare class Python extends BaseStrategy {
5
5
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
6
6
  private getPyProject;
7
7
  protected initialReleaseVersion(): Version;
@@ -14,7 +14,7 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.Python = void 0;
17
- const strategy_1 = require("../strategy");
17
+ const base_1 = require("./base");
18
18
  const changelog_1 = require("../updaters/changelog");
19
19
  const version_1 = require("../version");
20
20
  const setup_cfg_1 = require("../updaters/python/setup-cfg");
@@ -22,7 +22,7 @@ const setup_py_1 = require("../updaters/python/setup-py");
22
22
  const pyproject_toml_1 = require("../updaters/python/pyproject-toml");
23
23
  const logger_1 = require("../util/logger");
24
24
  const python_file_with_version_1 = require("../updaters/python/python-file-with-version");
25
- class Python extends strategy_1.Strategy {
25
+ class Python extends base_1.BaseStrategy {
26
26
  async buildUpdates(options) {
27
27
  var _a;
28
28
  const updates = [];
@@ -1,13 +1,13 @@
1
- import { StrategyOptions, Strategy, BuildUpdatesOptions } from '../strategy';
1
+ import { BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions } from './base';
2
2
  import { ConventionalCommit } from '../commit';
3
3
  import { Update } from '../update';
4
4
  import { Release } from '../release';
5
5
  import { Version } from '../version';
6
6
  import { TagName } from '../util/tag-name';
7
- interface RubyYoshiStrategyOptions extends StrategyOptions {
7
+ interface RubyYoshiStrategyOptions extends BaseStrategyOptions {
8
8
  versionFile?: string;
9
9
  }
10
- export declare class RubyYoshi extends Strategy {
10
+ export declare class RubyYoshi extends BaseStrategy {
11
11
  readonly versionFile: string;
12
12
  constructor(options: RubyYoshiStrategyOptions);
13
13
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
@@ -19,10 +19,11 @@ const indent_commit_1 = require("../util/indent-commit");
19
19
  const changelog_1 = require("../updaters/changelog");
20
20
  // RubyYoshi
21
21
  const version_rb_1 = require("../updaters/ruby/version-rb");
22
- const strategy_1 = require("../strategy");
22
+ const base_1 = require("./base");
23
23
  const fs_1 = require("fs");
24
24
  const path_1 = require("path");
25
25
  const manifest_1 = require("../manifest");
26
+ const logger_1 = require("../util/logger");
26
27
  const CHANGELOG_SECTIONS = [
27
28
  { type: 'feat', section: 'Features' },
28
29
  { type: 'fix', section: 'Bug Fixes' },
@@ -36,7 +37,7 @@ const CHANGELOG_SECTIONS = [
36
37
  { type: 'build', section: 'Build System', hidden: true },
37
38
  { type: 'ci', section: 'Continuous Integration', hidden: true },
38
39
  ];
39
- class RubyYoshi extends strategy_1.Strategy {
40
+ class RubyYoshi extends base_1.BaseStrategy {
40
41
  constructor(options) {
41
42
  var _a;
42
43
  super({
@@ -97,6 +98,10 @@ class RubyYoshi extends strategy_1.Strategy {
97
98
  .slice(1)
98
99
  .join('\n')}</code></pre>\n`;
99
100
  }
101
+ if (commit.files === undefined) {
102
+ logger_1.logger.error('No files for commit - this is likely a bug.');
103
+ continue;
104
+ }
100
105
  commit.files.forEach(file => {
101
106
  if (this.path === manifest_1.ROOT_PROJECT_PATH || file.startsWith(this.path)) {
102
107
  updatedFiles[file] = true;
@@ -1,10 +1,10 @@
1
- import { StrategyOptions, Strategy, BuildUpdatesOptions } from '../strategy';
1
+ import { BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions } from './base';
2
2
  import { ConventionalCommit } from '../commit';
3
3
  import { Update } from '../update';
4
- interface RubyStrategyOptions extends StrategyOptions {
4
+ interface RubyStrategyOptions extends BaseStrategyOptions {
5
5
  versionFile?: string;
6
6
  }
7
- export declare class Ruby extends Strategy {
7
+ export declare class Ruby extends BaseStrategy {
8
8
  readonly versionFile: string;
9
9
  constructor(options: RubyStrategyOptions);
10
10
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
@@ -19,8 +19,8 @@ const indent_commit_1 = require("../util/indent-commit");
19
19
  const changelog_1 = require("../updaters/changelog");
20
20
  // Ruby
21
21
  const version_rb_1 = require("../updaters/ruby/version-rb");
22
- const strategy_1 = require("../strategy");
23
- class Ruby extends strategy_1.Strategy {
22
+ const base_1 = require("./base");
23
+ class Ruby extends base_1.BaseStrategy {
24
24
  constructor(options) {
25
25
  var _a;
26
26
  super(options);
@@ -1,8 +1,8 @@
1
1
  import { CargoManifest } from '../updaters/rust/common';
2
- import { Strategy, BuildUpdatesOptions } from '../strategy';
2
+ import { BaseStrategy, BuildUpdatesOptions } from './base';
3
3
  import { Version } from '../version';
4
4
  import { Update } from '../update';
5
- export declare class Rust extends Strategy {
5
+ export declare class Rust extends BaseStrategy {
6
6
  private packageManifest?;
7
7
  private workspaceManifest?;
8
8
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
@@ -21,9 +21,9 @@ const cargo_toml_1 = require("../updaters/rust/cargo-toml");
21
21
  const cargo_lock_1 = require("../updaters/rust/cargo-lock");
22
22
  const common_1 = require("../updaters/rust/common");
23
23
  const logger_1 = require("../util/logger");
24
- const strategy_1 = require("../strategy");
24
+ const base_1 = require("./base");
25
25
  const version_1 = require("../version");
26
- class Rust extends strategy_1.Strategy {
26
+ class Rust extends base_1.BaseStrategy {
27
27
  async buildUpdates(options) {
28
28
  const updates = [];
29
29
  const version = options.newVersion;
@@ -1,5 +1,5 @@
1
- import { Strategy, BuildUpdatesOptions } from '../strategy';
1
+ import { BaseStrategy, BuildUpdatesOptions } from './base';
2
2
  import { Update } from '../update';
3
- export declare class Simple extends Strategy {
3
+ export declare class Simple extends BaseStrategy {
4
4
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
5
5
  }
@@ -17,9 +17,9 @@ exports.Simple = void 0;
17
17
  // Generic
18
18
  const changelog_1 = require("../updaters/changelog");
19
19
  // version.txt support
20
- const strategy_1 = require("../strategy");
20
+ const base_1 = require("./base");
21
21
  const default_1 = require("../updaters/default");
22
- class Simple extends strategy_1.Strategy {
22
+ class Simple extends base_1.BaseStrategy {
23
23
  async buildUpdates(options) {
24
24
  const updates = [];
25
25
  const version = options.newVersion;
@@ -1,7 +1,7 @@
1
- import { Strategy, BuildUpdatesOptions } from '../strategy';
1
+ import { BaseStrategy, BuildUpdatesOptions } from './base';
2
2
  import { Update } from '../update';
3
3
  import { Version } from '../version';
4
- export declare class TerraformModule extends Strategy {
4
+ export declare class TerraformModule extends BaseStrategy {
5
5
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
6
6
  protected initialReleaseVersion(): Version;
7
7
  }
@@ -19,9 +19,9 @@ const changelog_1 = require("../updaters/changelog");
19
19
  // Terraform specific.
20
20
  const readme_1 = require("../updaters/terraform/readme");
21
21
  const module_version_1 = require("../updaters/terraform/module-version");
22
- const strategy_1 = require("../strategy");
22
+ const base_1 = require("./base");
23
23
  const version_1 = require("../version");
24
- class TerraformModule extends strategy_1.Strategy {
24
+ class TerraformModule extends base_1.BaseStrategy {
25
25
  async buildUpdates(options) {
26
26
  const updates = [];
27
27
  const version = options.newVersion;
@@ -1,76 +1,17 @@
1
1
  import { ReleasePullRequest } from './release-pull-request';
2
2
  import { Release } from './release';
3
- import { GitHub } from './github';
4
- import { Version, VersionsMap } from './version';
5
- import { Commit, ConventionalCommit } from './commit';
6
- import { VersioningStrategy } from './versioning-strategy';
7
- import { ChangelogNotes, ChangelogSection } from './changelog-notes';
8
- import { Update } from './update';
9
- import { Repository } from './repository';
10
3
  import { PullRequest } from './pull-request';
11
- import { TagName } from './util/tag-name';
12
- export interface BuildUpdatesOptions {
13
- changelogEntry: string;
14
- newVersion: Version;
15
- versionsMap: VersionsMap;
16
- latestVersion?: Version;
17
- }
18
- export interface StrategyOptions {
19
- path?: string;
20
- bumpMinorPreMajor?: boolean;
21
- bumpPatchForMinorPreMajor?: boolean;
22
- github: GitHub;
23
- component?: string;
24
- packageName?: string;
25
- versioningStrategy?: VersioningStrategy;
26
- targetBranch: string;
27
- changelogPath?: string;
28
- changelogSections?: ChangelogSection[];
29
- commitPartial?: string;
30
- headerPartial?: string;
31
- mainTemplate?: string;
32
- tagSeparator?: string;
33
- skipGitHubRelease?: boolean;
34
- releaseAs?: string;
35
- changelogNotes?: ChangelogNotes;
36
- includeComponentInTag?: boolean;
37
- }
4
+ import { Commit } from './commit';
5
+ import { VersioningStrategy } from './versioning-strategy';
6
+ import { ChangelogNotes } from './changelog-notes';
38
7
  /**
39
8
  * A strategy is responsible for determining which files are
40
9
  * necessary to update in a release pull request.
41
10
  */
42
- export declare abstract class Strategy {
11
+ export interface Strategy {
12
+ readonly changelogNotes: ChangelogNotes;
43
13
  readonly path: string;
44
- protected github: GitHub;
45
- readonly component?: string;
46
- protected packageName?: string;
47
14
  readonly versioningStrategy: VersioningStrategy;
48
- protected targetBranch: string;
49
- protected repository: Repository;
50
- readonly changelogPath: string;
51
- protected tagSeparator?: string;
52
- private skipGitHubRelease;
53
- private releaseAs?;
54
- private includeComponentInTag;
55
- protected changelogNotes: ChangelogNotes;
56
- protected changelogSections?: ChangelogSection[];
57
- constructor(options: StrategyOptions);
58
- /**
59
- * Specify the files necessary to update in a release pull request.
60
- * @param {BuildUpdatesOptions} options
61
- */
62
- protected abstract buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
63
- getComponent(): Promise<string | undefined>;
64
- getDefaultComponent(): Promise<string | undefined>;
65
- getDefaultPackageName(): Promise<string | undefined>;
66
- protected normalizeComponent(component: string | undefined): string;
67
- /**
68
- * Override this method to post process commits
69
- * @param {ConventionalCommit[]} commits parsed commits
70
- * @returns {ConventionalCommit[]} modified commits
71
- */
72
- protected postProcessCommits(commits: ConventionalCommit[]): ConventionalCommit[];
73
- protected buildReleaseNotes(conventionalCommits: ConventionalCommit[], newVersion: Version, newVersionTag: TagName, latestRelease?: Release): Promise<string>;
74
15
  /**
75
16
  * Builds a candidate release pull request
76
17
  * @param {Commit[]} commits Raw commits to consider for this release.
@@ -83,9 +24,6 @@ export declare abstract class Strategy {
83
24
  * open a pull request.
84
25
  */
85
26
  buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
86
- protected changelogEmpty(changelogEntry: string): boolean;
87
- protected buildNewVersion(conventionalCommits: ConventionalCommit[], latestRelease?: Release): Promise<Version>;
88
- protected buildVersionsMap(_conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
89
27
  /**
90
28
  * Given a merged pull request, build the candidate release.
91
29
  * @param {PullRequest} mergedPullRequest The merged release pull request.
@@ -93,8 +31,8 @@ export declare abstract class Strategy {
93
31
  */
94
32
  buildRelease(mergedPullRequest: PullRequest): Promise<Release | undefined>;
95
33
  /**
96
- * Override this to handle the initial version of a new library.
34
+ * Return the component for this strategy. This may be a computed field.
35
+ * @returns {string}
97
36
  */
98
- protected initialReleaseVersion(): Version;
99
- protected addPath(file: string): string;
37
+ getComponent(): Promise<string | undefined>;
100
38
  }
@@ -13,230 +13,4 @@
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.Strategy = void 0;
17
- const version_1 = require("./version");
18
- const commit_1 = require("./commit");
19
- const default_1 = require("./versioning-strategies/default");
20
- const pull_request_title_1 = require("./util/pull-request-title");
21
- const branch_name_1 = require("./util/branch-name");
22
- const tag_name_1 = require("./util/tag-name");
23
- const logger_1 = require("./util/logger");
24
- const manifest_1 = require("./manifest");
25
- const pull_request_body_1 = require("./util/pull-request-body");
26
- const default_2 = require("./changelog-notes/default");
27
- const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md';
28
- /**
29
- * A strategy is responsible for determining which files are
30
- * necessary to update in a release pull request.
31
- */
32
- class Strategy {
33
- constructor(options) {
34
- var _a;
35
- this.path = options.path || manifest_1.ROOT_PROJECT_PATH;
36
- this.github = options.github;
37
- this.packageName = options.packageName;
38
- this.component =
39
- options.component || this.normalizeComponent(this.packageName);
40
- this.versioningStrategy =
41
- options.versioningStrategy || new default_1.DefaultVersioningStrategy({});
42
- this.targetBranch = options.targetBranch;
43
- this.repository = options.github.repository;
44
- this.changelogPath = options.changelogPath || DEFAULT_CHANGELOG_PATH;
45
- this.changelogSections = options.changelogSections;
46
- this.tagSeparator = options.tagSeparator;
47
- this.skipGitHubRelease = options.skipGitHubRelease || false;
48
- this.releaseAs = options.releaseAs;
49
- this.changelogNotes =
50
- options.changelogNotes || new default_2.DefaultChangelogNotes(options);
51
- this.includeComponentInTag = (_a = options.includeComponentInTag) !== null && _a !== void 0 ? _a : true;
52
- }
53
- async getComponent() {
54
- if (!this.includeComponentInTag) {
55
- return '';
56
- }
57
- return this.component || (await this.getDefaultComponent());
58
- }
59
- async getDefaultComponent() {
60
- return this.normalizeComponent(await this.getDefaultPackageName());
61
- }
62
- async getDefaultPackageName() {
63
- return '';
64
- }
65
- normalizeComponent(component) {
66
- if (!component) {
67
- return '';
68
- }
69
- return component;
70
- }
71
- /**
72
- * Override this method to post process commits
73
- * @param {ConventionalCommit[]} commits parsed commits
74
- * @returns {ConventionalCommit[]} modified commits
75
- */
76
- postProcessCommits(commits) {
77
- return commits;
78
- }
79
- async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease) {
80
- var _a;
81
- return await this.changelogNotes.buildNotes(conventionalCommits, {
82
- owner: this.repository.owner,
83
- repository: this.repository.repo,
84
- version: newVersion.toString(),
85
- previousTag: (_a = latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag) === null || _a === void 0 ? void 0 : _a.toString(),
86
- currentTag: newVersionTag.toString(),
87
- });
88
- }
89
- /**
90
- * Builds a candidate release pull request
91
- * @param {Commit[]} commits Raw commits to consider for this release.
92
- * @param {Release} latestRelease Optional. The last release for this
93
- * component if available.
94
- * @param {boolean} draft Optional. Whether or not to create the pull
95
- * request as a draft. Defaults to `false`.
96
- * @returns {ReleasePullRequest | undefined} The release pull request to
97
- * open for this path/component. Returns undefined if we should not
98
- * open a pull request.
99
- */
100
- async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
101
- const conventionalCommits = this.postProcessCommits(commit_1.parseConventionalCommits(commits));
102
- const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease);
103
- const versionsMap = await this.buildVersionsMap(conventionalCommits);
104
- for (const versionKey of versionsMap.keys()) {
105
- const version = versionsMap.get(versionKey);
106
- if (!version) {
107
- logger_1.logger.warn(`didn't find version for ${versionKey}`);
108
- continue;
109
- }
110
- const newVersion = await this.versioningStrategy.bump(version, conventionalCommits);
111
- versionsMap.set(versionKey, newVersion);
112
- }
113
- const component = await this.getComponent();
114
- logger_1.logger.debug('component:', component);
115
- const newVersionTag = new tag_name_1.TagName(newVersion, this.includeComponentInTag ? component : undefined, this.tagSeparator);
116
- const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion);
117
- const branchName = component
118
- ? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch)
119
- : branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
120
- const releaseNotesBody = await this.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease);
121
- if (this.changelogEmpty(releaseNotesBody)) {
122
- logger_1.logger.info(`No user facing commits found since ${latestRelease ? latestRelease.sha : 'beginning of time'} - skipping`);
123
- return undefined;
124
- }
125
- const updates = await this.buildUpdates({
126
- changelogEntry: releaseNotesBody,
127
- newVersion,
128
- versionsMap,
129
- latestVersion: latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag.version,
130
- });
131
- const pullRequestBody = new pull_request_body_1.PullRequestBody([
132
- {
133
- component,
134
- version: newVersion,
135
- notes: releaseNotesBody,
136
- },
137
- ]);
138
- return {
139
- title: pullRequestTitle,
140
- body: pullRequestBody,
141
- updates,
142
- labels,
143
- headRefName: branchName.toString(),
144
- version: newVersion,
145
- draft: draft !== null && draft !== void 0 ? draft : false,
146
- };
147
- }
148
- changelogEmpty(changelogEntry) {
149
- return changelogEntry.split('\n').length <= 1;
150
- }
151
- async buildNewVersion(conventionalCommits, latestRelease) {
152
- if (this.releaseAs) {
153
- logger_1.logger.warn(`Setting version for ${this.path} from release-as configuration`);
154
- return version_1.Version.parse(this.releaseAs);
155
- }
156
- else if (latestRelease) {
157
- return await this.versioningStrategy.bump(latestRelease.tag.version, conventionalCommits);
158
- }
159
- else {
160
- return this.initialReleaseVersion();
161
- }
162
- }
163
- async buildVersionsMap(_conventionalCommits) {
164
- return new Map();
165
- }
166
- /**
167
- * Given a merged pull request, build the candidate release.
168
- * @param {PullRequest} mergedPullRequest The merged release pull request.
169
- * @returns {Release} The candidate release.
170
- */
171
- async buildRelease(mergedPullRequest) {
172
- if (this.skipGitHubRelease) {
173
- logger_1.logger.info('Release skipped from strategy config');
174
- return;
175
- }
176
- if (!mergedPullRequest.sha) {
177
- logger_1.logger.error('Pull request should have been merged');
178
- return;
179
- }
180
- const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title) ||
181
- pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN);
182
- if (!pullRequestTitle) {
183
- logger_1.logger.error(`Bad pull request title: '${mergedPullRequest.title}'`);
184
- return;
185
- }
186
- const branchName = branch_name_1.BranchName.parse(mergedPullRequest.headBranchName);
187
- if (!branchName) {
188
- logger_1.logger.error(`Bad branch name: ${mergedPullRequest.headBranchName}`);
189
- return;
190
- }
191
- const pullRequestBody = pull_request_body_1.PullRequestBody.parse(mergedPullRequest.body);
192
- if (!pullRequestBody) {
193
- logger_1.logger.error('Could not parse pull request body as a release PR');
194
- return;
195
- }
196
- const component = await this.getComponent();
197
- logger_1.logger.info('component:', component);
198
- const releaseData = pullRequestBody.releaseData.length === 1 &&
199
- !pullRequestBody.releaseData[0].component
200
- ? pullRequestBody.releaseData[0]
201
- : pullRequestBody.releaseData.find(releaseData => {
202
- return (this.normalizeComponent(releaseData.component) ===
203
- this.normalizeComponent(component));
204
- });
205
- const notes = releaseData === null || releaseData === void 0 ? void 0 : releaseData.notes;
206
- if (notes === undefined) {
207
- logger_1.logger.warn('Failed to find release notes');
208
- }
209
- const version = pullRequestTitle.getVersion() || (releaseData === null || releaseData === void 0 ? void 0 : releaseData.version);
210
- if (!version) {
211
- logger_1.logger.error('Pull request should have included version');
212
- return;
213
- }
214
- const tag = new tag_name_1.TagName(version, this.includeComponentInTag ? component : undefined, this.tagSeparator);
215
- return {
216
- tag,
217
- notes: notes || '',
218
- sha: mergedPullRequest.sha,
219
- };
220
- }
221
- /**
222
- * Override this to handle the initial version of a new library.
223
- */
224
- initialReleaseVersion() {
225
- return version_1.Version.parse('1.0.0');
226
- }
227
- addPath(file) {
228
- if (this.path === manifest_1.ROOT_PROJECT_PATH) {
229
- return file;
230
- }
231
- file = file.replace(/^[/\\]/, '');
232
- if (this.path === undefined) {
233
- return file;
234
- }
235
- else {
236
- const path = this.path.replace(/[/\\]$/, '');
237
- return `${path}/${file}`;
238
- }
239
- }
240
- }
241
- exports.Strategy = Strategy;
242
16
  //# sourceMappingURL=strategy.js.map
@@ -0,0 +1,4 @@
1
+ import { DefaultUpdater } from '../default';
2
+ export declare class VersionGo extends DefaultUpdater {
3
+ updateContent(content: string): string;
4
+ }