@release-please-oss/release-please 0.0.0-stage → 17.11.3
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/LICENSE +202 -0
- package/README.md +279 -2
- package/build/src/bin/release-please.d.ts +22 -0
- package/build/src/bin/release-please.js +727 -0
- package/build/src/bootstrapper.d.ts +18 -0
- package/build/src/bootstrapper.js +64 -0
- package/build/src/changelog-notes/default.d.ts +15 -0
- package/build/src/changelog-notes/default.js +96 -0
- package/build/src/changelog-notes/github.d.ts +8 -0
- package/build/src/changelog-notes/github.js +29 -0
- package/build/src/changelog-notes.d.ts +22 -0
- package/build/src/changelog-notes.js +40 -0
- package/build/src/commit.d.ts +33 -0
- package/build/src/commit.js +422 -0
- package/build/src/errors/index.d.ts +36 -0
- package/build/src/errors/index.js +77 -0
- package/build/src/factories/changelog-notes-factory.d.ts +16 -0
- package/build/src/factories/changelog-notes-factory.js +44 -0
- package/build/src/factories/plugin-factory.d.ts +23 -0
- package/build/src/factories/plugin-factory.js +94 -0
- package/build/src/factories/versioning-strategy-factory.d.ts +16 -0
- package/build/src/factories/versioning-strategy-factory.js +52 -0
- package/build/src/factory.d.ts +18 -0
- package/build/src/factory.js +161 -0
- package/build/src/github-api.d.ts +260 -0
- package/build/src/github-api.js +714 -0
- package/build/src/github.d.ts +306 -0
- package/build/src/github.js +769 -0
- package/build/src/index.d.ts +17 -0
- package/build/src/index.js +41 -0
- package/build/src/local-github.d.ts +270 -0
- package/build/src/local-github.js +756 -0
- package/build/src/manifest.d.ts +370 -0
- package/build/src/manifest.js +1142 -0
- package/build/src/plugin.d.ts +37 -0
- package/build/src/plugin.js +57 -0
- package/build/src/plugins/cargo-workspace.d.ts +58 -0
- package/build/src/plugins/cargo-workspace.js +339 -0
- package/build/src/plugins/group-priority.d.ts +29 -0
- package/build/src/plugins/group-priority.js +82 -0
- package/build/src/plugins/linked-versions.d.ts +36 -0
- package/build/src/plugins/linked-versions.js +137 -0
- package/build/src/plugins/maven-workspace.d.ts +81 -0
- package/build/src/plugins/maven-workspace.js +431 -0
- package/build/src/plugins/merge.d.ts +27 -0
- package/build/src/plugins/merge.js +99 -0
- package/build/src/plugins/node-workspace.d.ts +50 -0
- package/build/src/plugins/node-workspace.js +352 -0
- package/build/src/plugins/sentence-case.d.ts +19 -0
- package/build/src/plugins/sentence-case.js +80 -0
- package/build/src/plugins/workspace.d.ts +173 -0
- package/build/src/plugins/workspace.js +308 -0
- package/build/src/pull-request.d.ts +11 -0
- package/build/src/pull-request.js +16 -0
- package/build/src/release-pull-request.d.ts +14 -0
- package/build/src/release-pull-request.js +16 -0
- package/build/src/release.d.ts +7 -0
- package/build/src/release.js +16 -0
- package/build/src/repository.d.ts +5 -0
- package/build/src/repository.js +16 -0
- package/build/src/scm.d.ts +80 -0
- package/build/src/scm.js +16 -0
- package/build/src/strategies/base.d.ts +162 -0
- package/build/src/strategies/base.js +494 -0
- package/build/src/strategies/bazel.d.ts +7 -0
- package/build/src/strategies/bazel.js +49 -0
- package/build/src/strategies/dart.d.ts +8 -0
- package/build/src/strategies/dart.js +73 -0
- package/build/src/strategies/dotnet-yoshi.d.ts +13 -0
- package/build/src/strategies/dotnet-yoshi.js +109 -0
- package/build/src/strategies/elixir.d.ts +5 -0
- package/build/src/strategies/elixir.js +46 -0
- package/build/src/strategies/expo.d.ts +15 -0
- package/build/src/strategies/expo.js +51 -0
- package/build/src/strategies/go-librarian.d.ts +11 -0
- package/build/src/strategies/go-librarian.js +84 -0
- package/build/src/strategies/go-yoshi.d.ts +14 -0
- package/build/src/strategies/go-yoshi.js +168 -0
- package/build/src/strategies/go.d.ts +7 -0
- package/build/src/strategies/go.js +53 -0
- package/build/src/strategies/helm.d.ts +8 -0
- package/build/src/strategies/helm.js +73 -0
- package/build/src/strategies/java-yoshi-mono-repo.d.ts +22 -0
- package/build/src/strategies/java-yoshi-mono-repo.js +308 -0
- package/build/src/strategies/java-yoshi.d.ts +20 -0
- package/build/src/strategies/java-yoshi.js +210 -0
- package/build/src/strategies/java.d.ts +28 -0
- package/build/src/strategies/java.js +176 -0
- package/build/src/strategies/krm-blueprint.d.ts +7 -0
- package/build/src/strategies/krm-blueprint.js +65 -0
- package/build/src/strategies/maven.d.ts +9 -0
- package/build/src/strategies/maven.js +56 -0
- package/build/src/strategies/node-librarian.d.ts +10 -0
- package/build/src/strategies/node-librarian.js +121 -0
- package/build/src/strategies/node.d.ts +10 -0
- package/build/src/strategies/node.js +111 -0
- package/build/src/strategies/ocaml.d.ts +5 -0
- package/build/src/strategies/ocaml.js +86 -0
- package/build/src/strategies/php-librarian.d.ts +6 -0
- package/build/src/strategies/php-librarian.js +35 -0
- package/build/src/strategies/php-yoshi.d.ts +13 -0
- package/build/src/strategies/php-yoshi.js +255 -0
- package/build/src/strategies/php.d.ts +6 -0
- package/build/src/strategies/php.js +76 -0
- package/build/src/strategies/python-librarian.d.ts +6 -0
- package/build/src/strategies/python-librarian.js +35 -0
- package/build/src/strategies/python.d.ts +11 -0
- package/build/src/strategies/python.js +175 -0
- package/build/src/strategies/r.d.ts +8 -0
- package/build/src/strategies/r.js +67 -0
- package/build/src/strategies/ruby-librarian.d.ts +6 -0
- package/build/src/strategies/ruby-librarian.js +35 -0
- package/build/src/strategies/ruby-yoshi.d.ts +13 -0
- package/build/src/strategies/ruby-yoshi.js +97 -0
- package/build/src/strategies/ruby.d.ts +9 -0
- package/build/src/strategies/ruby.js +71 -0
- package/build/src/strategies/rust.d.ts +17 -0
- package/build/src/strategies/rust.js +149 -0
- package/build/src/strategies/sfdx.d.ts +9 -0
- package/build/src/strategies/sfdx.js +67 -0
- package/build/src/strategies/simple.d.ts +7 -0
- package/build/src/strategies/simple.js +51 -0
- package/build/src/strategies/terraform-module.d.ts +7 -0
- package/build/src/strategies/terraform-module.js +90 -0
- package/build/src/strategy.d.ts +68 -0
- package/build/src/strategy.js +16 -0
- package/build/src/update.d.ts +24 -0
- package/build/src/update.js +16 -0
- package/build/src/updaters/base-xml.d.ts +19 -0
- package/build/src/updaters/base-xml.js +43 -0
- package/build/src/updaters/bazel/module-bazel.d.ts +7 -0
- package/build/src/updaters/bazel/module-bazel.js +33 -0
- package/build/src/updaters/changelog-json.d.ts +29 -0
- package/build/src/updaters/changelog-json.js +100 -0
- package/build/src/updaters/changelog.d.ts +13 -0
- package/build/src/updaters/changelog.js +55 -0
- package/build/src/updaters/composite.d.ts +20 -0
- package/build/src/updaters/composite.js +65 -0
- package/build/src/updaters/dart/pubspec-yaml.d.ts +13 -0
- package/build/src/updaters/dart/pubspec-yaml.js +50 -0
- package/build/src/updaters/default.d.ts +21 -0
- package/build/src/updaters/default.js +36 -0
- package/build/src/updaters/dotnet/apis.d.ts +18 -0
- package/build/src/updaters/dotnet/apis.js +45 -0
- package/build/src/updaters/dotnet/csproj.d.ts +12 -0
- package/build/src/updaters/dotnet/csproj.js +33 -0
- package/build/src/updaters/elixir/elixir-mix-exs.d.ts +13 -0
- package/build/src/updaters/elixir/elixir-mix-exs.js +42 -0
- package/build/src/updaters/expo/app-json.d.ts +31 -0
- package/build/src/updaters/expo/app-json.js +67 -0
- package/build/src/updaters/generic-json.d.ts +14 -0
- package/build/src/updaters/generic-json.js +54 -0
- package/build/src/updaters/generic-toml.d.ts +21 -0
- package/build/src/updaters/generic-toml.js +66 -0
- package/build/src/updaters/generic-xml.d.ts +8 -0
- package/build/src/updaters/generic-xml.js +38 -0
- package/build/src/updaters/generic-yaml.d.ts +23 -0
- package/build/src/updaters/generic-yaml.js +85 -0
- package/build/src/updaters/generic.d.ts +54 -0
- package/build/src/updaters/generic.js +187 -0
- package/build/src/updaters/go/version-go.d.ts +4 -0
- package/build/src/updaters/go/version-go.js +24 -0
- package/build/src/updaters/helm/chart-yaml.d.ts +13 -0
- package/build/src/updaters/helm/chart-yaml.js +41 -0
- package/build/src/updaters/java/java-released.d.ts +28 -0
- package/build/src/updaters/java/java-released.js +59 -0
- package/build/src/updaters/java/java-update.d.ts +21 -0
- package/build/src/updaters/java/java-update.js +80 -0
- package/build/src/updaters/java/pom-xml.d.ts +29 -0
- package/build/src/updaters/java/pom-xml.js +135 -0
- package/build/src/updaters/java/versions-manifest.d.ts +19 -0
- package/build/src/updaters/java/versions-manifest.js +71 -0
- package/build/src/updaters/krm/krm-blueprint-version.d.ts +13 -0
- package/build/src/updaters/krm/krm-blueprint-version.js +46 -0
- package/build/src/updaters/librarian-yaml.d.ts +45 -0
- package/build/src/updaters/librarian-yaml.js +149 -0
- package/build/src/updaters/node/package-json.d.ts +46 -0
- package/build/src/updaters/node/package-json.js +106 -0
- package/build/src/updaters/node/package-lock-json.d.ts +14 -0
- package/build/src/updaters/node/package-lock-json.js +83 -0
- package/build/src/updaters/node/samples-package-json.d.ts +24 -0
- package/build/src/updaters/node/samples-package-json.js +49 -0
- package/build/src/updaters/ocaml/dune-project.d.ts +13 -0
- package/build/src/updaters/ocaml/dune-project.js +37 -0
- package/build/src/updaters/ocaml/esy-json.d.ts +13 -0
- package/build/src/updaters/ocaml/esy-json.js +37 -0
- package/build/src/updaters/ocaml/opam.d.ts +13 -0
- package/build/src/updaters/ocaml/opam.js +37 -0
- package/build/src/updaters/php/php-client-version.d.ts +12 -0
- package/build/src/updaters/php/php-client-version.js +32 -0
- package/build/src/updaters/php/root-composer-update-packages.d.ts +13 -0
- package/build/src/updaters/php/root-composer-update-packages.js +60 -0
- package/build/src/updaters/python/pyproject-toml.d.ts +29 -0
- package/build/src/updaters/python/pyproject-toml.js +53 -0
- package/build/src/updaters/python/python-file-with-version.d.ts +12 -0
- package/build/src/updaters/python/python-file-with-version.js +32 -0
- package/build/src/updaters/python/setup-cfg.d.ts +12 -0
- package/build/src/updaters/python/setup-cfg.js +32 -0
- package/build/src/updaters/python/setup-py.d.ts +12 -0
- package/build/src/updaters/python/setup-py.js +32 -0
- package/build/src/updaters/r/description.d.ts +12 -0
- package/build/src/updaters/r/description.js +32 -0
- package/build/src/updaters/r/news.d.ts +12 -0
- package/build/src/updaters/r/news.js +49 -0
- package/build/src/updaters/raw-content.d.ts +19 -0
- package/build/src/updaters/raw-content.js +39 -0
- package/build/src/updaters/release-please-config.d.ts +8 -0
- package/build/src/updaters/release-please-config.js +80 -0
- package/build/src/updaters/release-please-manifest.d.ts +4 -0
- package/build/src/updaters/release-please-manifest.js +34 -0
- package/build/src/updaters/ruby/common.d.ts +17 -0
- package/build/src/updaters/ruby/common.js +46 -0
- package/build/src/updaters/ruby/gemfile-lock.d.ts +24 -0
- package/build/src/updaters/ruby/gemfile-lock.js +53 -0
- package/build/src/updaters/ruby/version-rb.d.ts +12 -0
- package/build/src/updaters/ruby/version-rb.js +34 -0
- package/build/src/updaters/rust/cargo-lock.d.ts +16 -0
- package/build/src/updaters/rust/cargo-lock.js +64 -0
- package/build/src/updaters/rust/cargo-toml.d.ts +13 -0
- package/build/src/updaters/rust/cargo-toml.js +89 -0
- package/build/src/updaters/rust/common.d.ts +54 -0
- package/build/src/updaters/rust/common.js +35 -0
- package/build/src/updaters/sfdx/sfdx-project-json.d.ts +21 -0
- package/build/src/updaters/sfdx/sfdx-project-json.js +41 -0
- package/build/src/updaters/terraform/metadata-version.d.ts +13 -0
- package/build/src/updaters/terraform/metadata-version.js +37 -0
- package/build/src/updaters/terraform/module-version.d.ts +13 -0
- package/build/src/updaters/terraform/module-version.js +37 -0
- package/build/src/updaters/terraform/readme.d.ts +12 -0
- package/build/src/updaters/terraform/readme.js +32 -0
- package/build/src/util/branch-name.d.ts +20 -0
- package/build/src/util/branch-name.js +225 -0
- package/build/src/util/code-suggester/default-options-handler.d.ts +10 -0
- package/build/src/util/code-suggester/default-options-handler.js +45 -0
- package/build/src/util/code-suggester/errors.d.ts +4 -0
- package/build/src/util/code-suggester/errors.js +24 -0
- package/build/src/util/code-suggester/github/branch.d.ts +45 -0
- package/build/src/util/code-suggester/github/branch.js +118 -0
- package/build/src/util/code-suggester/github/commit-and-push.d.ts +51 -0
- package/build/src/util/code-suggester/github/commit-and-push.js +141 -0
- package/build/src/util/code-suggester/github/create-commit.d.ts +20 -0
- package/build/src/util/code-suggester/github/create-commit.js +60 -0
- package/build/src/util/code-suggester/github/fork.d.ts +15 -0
- package/build/src/util/code-suggester/github/fork.js +48 -0
- package/build/src/util/code-suggester/github/labels.d.ts +14 -0
- package/build/src/util/code-suggester/github/labels.js +42 -0
- package/build/src/util/code-suggester/github/open-pull-request.d.ts +16 -0
- package/build/src/util/code-suggester/github/open-pull-request.js +56 -0
- package/build/src/util/code-suggester/index.d.ts +28 -0
- package/build/src/util/code-suggester/index.js +110 -0
- package/build/src/util/code-suggester/logger.d.ts +4 -0
- package/build/src/util/code-suggester/logger.js +37 -0
- package/build/src/util/code-suggester/types.d.ts +109 -0
- package/build/src/util/code-suggester/types.js +30 -0
- package/build/src/util/coerce-option.d.ts +1 -0
- package/build/src/util/coerce-option.js +40 -0
- package/build/src/util/commit-exclude.d.ts +10 -0
- package/build/src/util/commit-exclude.js +49 -0
- package/build/src/util/commit-split.d.ts +26 -0
- package/build/src/util/commit-split.js +100 -0
- package/build/src/util/commit-utils.d.ts +1 -0
- package/build/src/util/commit-utils.js +34 -0
- package/build/src/util/filter-commits.d.ts +12 -0
- package/build/src/util/filter-commits.js +59 -0
- package/build/src/util/indent-commit.d.ts +2 -0
- package/build/src/util/indent-commit.js +39 -0
- package/build/src/util/json-stringify.d.ts +1 -0
- package/build/src/util/json-stringify.js +22 -0
- package/build/src/util/logger.d.ts +24 -0
- package/build/src/util/logger.js +54 -0
- package/build/src/util/pull-request-body.d.ts +25 -0
- package/build/src/util/pull-request-body.js +147 -0
- package/build/src/util/pull-request-overflow-handler.d.ts +54 -0
- package/build/src/util/pull-request-overflow-handler.js +78 -0
- package/build/src/util/pull-request-title.d.ts +22 -0
- package/build/src/util/pull-request-title.js +146 -0
- package/build/src/util/signoff-commit-message.d.ts +1 -0
- package/build/src/util/signoff-commit-message.js +35 -0
- package/build/src/util/tag-name.d.ts +10 -0
- package/build/src/util/tag-name.js +42 -0
- package/build/src/util/toml-edit.d.ts +16 -0
- package/build/src/util/toml-edit.js +126 -0
- package/build/src/version.d.ts +35 -0
- package/build/src/version.js +74 -0
- package/build/src/versioning-strategies/always-bump-major.d.ts +10 -0
- package/build/src/versioning-strategies/always-bump-major.js +28 -0
- package/build/src/versioning-strategies/always-bump-minor.d.ts +10 -0
- package/build/src/versioning-strategies/always-bump-minor.js +28 -0
- package/build/src/versioning-strategies/always-bump-patch.d.ts +11 -0
- package/build/src/versioning-strategies/always-bump-patch.js +29 -0
- package/build/src/versioning-strategies/default.d.ts +48 -0
- package/build/src/versioning-strategies/default.js +102 -0
- package/build/src/versioning-strategies/dependency-manifest.d.ts +15 -0
- package/build/src/versioning-strategies/dependency-manifest.js +103 -0
- package/build/src/versioning-strategies/java-add-snapshot.d.ts +13 -0
- package/build/src/versioning-strategies/java-add-snapshot.js +54 -0
- package/build/src/versioning-strategies/java-snapshot.d.ts +13 -0
- package/build/src/versioning-strategies/java-snapshot.js +70 -0
- package/build/src/versioning-strategies/prerelease.d.ts +20 -0
- package/build/src/versioning-strategies/prerelease.js +163 -0
- package/build/src/versioning-strategies/service-pack.d.ts +12 -0
- package/build/src/versioning-strategies/service-pack.js +47 -0
- package/build/src/versioning-strategy.d.ts +90 -0
- package/build/src/versioning-strategy.js +82 -0
- package/package.json +114 -4
- package/schemas/config.json +513 -0
- package/schemas/manifest.json +9 -0
- package/templates/commit.hbs +2 -0
- package/templates/header.hbs +9 -0
- package/templates/template.hbs +19 -0
package/build/src/scm.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2026 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
|
+
//# sourceMappingURL=scm.js.map
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Strategy, BuildReleaseOptions, BumpReleaseOptions } from '../strategy';
|
|
2
|
+
import { Scm } from '../scm';
|
|
3
|
+
import { VersioningStrategy } from '../versioning-strategy';
|
|
4
|
+
import { Repository } from '../repository';
|
|
5
|
+
import { ChangelogNotes, ChangelogSection } from '../changelog-notes';
|
|
6
|
+
import { ExtraFile } from '../manifest';
|
|
7
|
+
import { Update } from '../update';
|
|
8
|
+
import { ConventionalCommit, Commit } from '../commit';
|
|
9
|
+
import { Version, VersionsMap } from '../version';
|
|
10
|
+
import { TagName } from '../util/tag-name';
|
|
11
|
+
import { Release } from '../release';
|
|
12
|
+
import { ReleasePullRequest } from '../release-pull-request';
|
|
13
|
+
import { Logger } from '../util/logger';
|
|
14
|
+
import { PullRequestBody } from '../util/pull-request-body';
|
|
15
|
+
import { PullRequest } from '../pull-request';
|
|
16
|
+
export interface BuildUpdatesOptions {
|
|
17
|
+
changelogEntry: string;
|
|
18
|
+
skipChangelog?: boolean;
|
|
19
|
+
commits?: ConventionalCommit[];
|
|
20
|
+
newVersion: Version;
|
|
21
|
+
versionsMap: VersionsMap;
|
|
22
|
+
latestVersion?: Version;
|
|
23
|
+
}
|
|
24
|
+
export interface BaseStrategyOptions {
|
|
25
|
+
path?: string;
|
|
26
|
+
bumpMinorPreMajor?: boolean;
|
|
27
|
+
bumpPatchForMinorPreMajor?: boolean;
|
|
28
|
+
github: Scm;
|
|
29
|
+
component?: string;
|
|
30
|
+
packageName?: string;
|
|
31
|
+
versioningStrategy?: VersioningStrategy;
|
|
32
|
+
targetBranch: string;
|
|
33
|
+
changelogPath?: string;
|
|
34
|
+
changelogHost?: string;
|
|
35
|
+
changelogSections?: ChangelogSection[];
|
|
36
|
+
commitPartial?: string;
|
|
37
|
+
headerPartial?: string;
|
|
38
|
+
mainTemplate?: string;
|
|
39
|
+
tagSeparator?: string;
|
|
40
|
+
skipGitHubRelease?: boolean;
|
|
41
|
+
skipChangelog?: boolean;
|
|
42
|
+
releaseAs?: string;
|
|
43
|
+
changelogNotes?: ChangelogNotes;
|
|
44
|
+
includeComponentInTag?: boolean;
|
|
45
|
+
includeVInTag?: boolean;
|
|
46
|
+
includeVInReleaseName?: boolean;
|
|
47
|
+
pullRequestTitlePattern?: string;
|
|
48
|
+
pullRequestHeader?: string;
|
|
49
|
+
pullRequestFooter?: string;
|
|
50
|
+
componentNoSpace?: boolean;
|
|
51
|
+
extraFiles?: ExtraFile[];
|
|
52
|
+
versionFile?: string;
|
|
53
|
+
snapshotLabels?: string[];
|
|
54
|
+
skipSnapshot?: boolean;
|
|
55
|
+
logger?: Logger;
|
|
56
|
+
initialVersion?: string;
|
|
57
|
+
extraLabels?: string[];
|
|
58
|
+
dateFormat?: string;
|
|
59
|
+
includeCommitAuthors?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A strategy is responsible for determining which files are
|
|
63
|
+
* necessary to update in a release pull request.
|
|
64
|
+
*/
|
|
65
|
+
export declare abstract class BaseStrategy implements Strategy {
|
|
66
|
+
readonly path: string;
|
|
67
|
+
protected github: Scm;
|
|
68
|
+
protected logger: Logger;
|
|
69
|
+
protected component?: string;
|
|
70
|
+
private packageName?;
|
|
71
|
+
readonly versioningStrategy: VersioningStrategy;
|
|
72
|
+
protected targetBranch: string;
|
|
73
|
+
protected repository: Repository;
|
|
74
|
+
protected changelogPath: string;
|
|
75
|
+
protected changelogHost?: string;
|
|
76
|
+
protected tagSeparator?: string;
|
|
77
|
+
private skipGitHubRelease;
|
|
78
|
+
protected skipChangelog: boolean;
|
|
79
|
+
private releaseAs?;
|
|
80
|
+
protected includeComponentInTag: boolean;
|
|
81
|
+
protected includeVInTag: boolean;
|
|
82
|
+
protected includeVInReleaseName: boolean;
|
|
83
|
+
protected initialVersion?: string;
|
|
84
|
+
readonly pullRequestTitlePattern?: string;
|
|
85
|
+
readonly pullRequestHeader?: string;
|
|
86
|
+
readonly pullRequestFooter?: string;
|
|
87
|
+
readonly componentNoSpace?: boolean;
|
|
88
|
+
readonly extraFiles: ExtraFile[];
|
|
89
|
+
readonly extraLabels: string[];
|
|
90
|
+
protected dateFormat: string;
|
|
91
|
+
protected includeCommitAuthors?: boolean;
|
|
92
|
+
readonly changelogNotes: ChangelogNotes;
|
|
93
|
+
protected changelogSections?: ChangelogSection[];
|
|
94
|
+
constructor(options: BaseStrategyOptions);
|
|
95
|
+
/**
|
|
96
|
+
* Specify the files necessary to update in a release pull request.
|
|
97
|
+
* @param {BuildUpdatesOptions} options
|
|
98
|
+
*/
|
|
99
|
+
protected abstract buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Return the component for this strategy. This may be a computed field.
|
|
102
|
+
* @returns {string}
|
|
103
|
+
*/
|
|
104
|
+
getComponent(): Promise<string | undefined>;
|
|
105
|
+
getDefaultComponent(): Promise<string | undefined>;
|
|
106
|
+
getBranchComponent(): Promise<string | undefined>;
|
|
107
|
+
getPackageName(): Promise<string | undefined>;
|
|
108
|
+
getDefaultPackageName(): Promise<string | undefined>;
|
|
109
|
+
protected normalizeComponent(component: string | undefined): string;
|
|
110
|
+
/**
|
|
111
|
+
* Override this method to post process commits
|
|
112
|
+
* @param {ConventionalCommit[]} commits parsed commits
|
|
113
|
+
* @returns {ConventionalCommit[]} modified commits
|
|
114
|
+
*/
|
|
115
|
+
protected postProcessCommits(commits: ConventionalCommit[]): Promise<ConventionalCommit[]>;
|
|
116
|
+
protected buildReleaseNotes(conventionalCommits: ConventionalCommit[], newVersion: Version, newVersionTag: TagName, latestRelease?: Release, commits?: Commit[]): Promise<string>;
|
|
117
|
+
protected buildPullRequestBody(component: string | undefined, newVersion: Version, releaseNotesBody: string, _conventionalCommits: ConventionalCommit[], _latestRelease?: Release, pullRequestHeader?: string, pullRequestFooter?: string): Promise<PullRequestBody>;
|
|
118
|
+
/**
|
|
119
|
+
* Builds a candidate release pull request
|
|
120
|
+
* @param {Commit[]} commits Raw commits to consider for this release.
|
|
121
|
+
* @param {Release} latestRelease Optional. The last release for this
|
|
122
|
+
* component if available.
|
|
123
|
+
* @param {boolean} draft Optional. Whether or not to create the pull
|
|
124
|
+
* request as a draft. Defaults to `false`.
|
|
125
|
+
* @returns {ReleasePullRequest | undefined} The release pull request to
|
|
126
|
+
* open for this path/component. Returns undefined if we should not
|
|
127
|
+
* open a pull request.
|
|
128
|
+
*/
|
|
129
|
+
buildReleasePullRequest(commits: ConventionalCommit[], latestRelease?: Release, draft?: boolean, labels?: string[], bumpOnlyOptions?: BumpReleaseOptions): Promise<ReleasePullRequest | undefined>;
|
|
130
|
+
private extraFilePaths;
|
|
131
|
+
protected extraFileUpdates(version: Version, versionsMap: VersionsMap, dateFormat: string): Promise<Update[]>;
|
|
132
|
+
protected changelogEmpty(changelogEntry: string): boolean;
|
|
133
|
+
protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[], _newVersion: Version): Promise<VersionsMap>;
|
|
134
|
+
protected buildNewVersion(conventionalCommits: ConventionalCommit[], latestRelease?: Release): Promise<Version>;
|
|
135
|
+
protected buildVersionsMap(_conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
|
|
136
|
+
protected parsePullRequestBody(pullRequestBody: string): Promise<PullRequestBody | undefined>;
|
|
137
|
+
/**
|
|
138
|
+
* Given a merged pull request, build the candidate release.
|
|
139
|
+
* @param {PullRequest} mergedPullRequest The merged release pull request.
|
|
140
|
+
* @returns {Release} The candidate release.
|
|
141
|
+
* @deprecated Use buildReleases() instead.
|
|
142
|
+
*/
|
|
143
|
+
buildRelease(mergedPullRequest: PullRequest, options?: BuildReleaseOptions): Promise<Release | undefined>;
|
|
144
|
+
/**
|
|
145
|
+
* Given a merged pull request, build the candidate releases.
|
|
146
|
+
* @param {PullRequest} mergedPullRequest The merged release pull request.
|
|
147
|
+
* @returns {Release} The candidate release.
|
|
148
|
+
*/
|
|
149
|
+
buildReleases(mergedPullRequest: PullRequest, options?: BuildReleaseOptions): Promise<Release[]>;
|
|
150
|
+
isPublishedVersion(_version: Version): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Override this to handle the initial version of a new library.
|
|
153
|
+
*/
|
|
154
|
+
protected initialReleaseVersion(): Version;
|
|
155
|
+
/**
|
|
156
|
+
* Adds a given file path to the strategy path.
|
|
157
|
+
* @param {string} file Desired file path.
|
|
158
|
+
* @returns {string} The file relative to the strategy.
|
|
159
|
+
* @throws {Error} If the file path contains relative pathing characters, i.e. ../, ~/
|
|
160
|
+
*/
|
|
161
|
+
protected addPath(file: string): string;
|
|
162
|
+
}
|
|
@@ -0,0 +1,494 @@
|
|
|
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.BaseStrategy = void 0;
|
|
17
|
+
const manifest_1 = require("../manifest");
|
|
18
|
+
const default_1 = require("../versioning-strategies/default");
|
|
19
|
+
const default_2 = require("../changelog-notes/default");
|
|
20
|
+
const version_1 = require("../version");
|
|
21
|
+
const tag_name_1 = require("../util/tag-name");
|
|
22
|
+
const logger_1 = require("../util/logger");
|
|
23
|
+
const pull_request_title_1 = require("../util/pull-request-title");
|
|
24
|
+
const branch_name_1 = require("../util/branch-name");
|
|
25
|
+
const pull_request_body_1 = require("../util/pull-request-body");
|
|
26
|
+
const composite_1 = require("../updaters/composite");
|
|
27
|
+
const generic_1 = require("../updaters/generic");
|
|
28
|
+
const generic_json_1 = require("../updaters/generic-json");
|
|
29
|
+
const generic_xml_1 = require("../updaters/generic-xml");
|
|
30
|
+
const pom_xml_1 = require("../updaters/java/pom-xml");
|
|
31
|
+
const generic_yaml_1 = require("../updaters/generic-yaml");
|
|
32
|
+
const generic_toml_1 = require("../updaters/generic-toml");
|
|
33
|
+
const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md';
|
|
34
|
+
/**
|
|
35
|
+
* A strategy is responsible for determining which files are
|
|
36
|
+
* necessary to update in a release pull request.
|
|
37
|
+
*/
|
|
38
|
+
class BaseStrategy {
|
|
39
|
+
constructor(options) {
|
|
40
|
+
var _a, _b, _c, _d;
|
|
41
|
+
this.logger = (_a = options.logger) !== null && _a !== void 0 ? _a : logger_1.logger;
|
|
42
|
+
this.path = options.path || manifest_1.ROOT_PROJECT_PATH;
|
|
43
|
+
this.github = options.github;
|
|
44
|
+
this.packageName = options.packageName;
|
|
45
|
+
this.component =
|
|
46
|
+
options.component || this.normalizeComponent(this.packageName);
|
|
47
|
+
this.versioningStrategy =
|
|
48
|
+
options.versioningStrategy ||
|
|
49
|
+
new default_1.DefaultVersioningStrategy({ logger: this.logger });
|
|
50
|
+
this.targetBranch = options.targetBranch;
|
|
51
|
+
this.repository = options.github.repository;
|
|
52
|
+
this.changelogPath = options.changelogPath || DEFAULT_CHANGELOG_PATH;
|
|
53
|
+
this.changelogHost = options.changelogHost;
|
|
54
|
+
this.changelogSections = options.changelogSections;
|
|
55
|
+
this.tagSeparator = options.tagSeparator;
|
|
56
|
+
this.skipGitHubRelease = options.skipGitHubRelease || false;
|
|
57
|
+
this.skipChangelog = options.skipChangelog || false;
|
|
58
|
+
this.releaseAs = options.releaseAs;
|
|
59
|
+
this.changelogNotes =
|
|
60
|
+
options.changelogNotes || new default_2.DefaultChangelogNotes(options);
|
|
61
|
+
this.includeComponentInTag = (_b = options.includeComponentInTag) !== null && _b !== void 0 ? _b : true;
|
|
62
|
+
this.includeVInTag = (_c = options.includeVInTag) !== null && _c !== void 0 ? _c : true;
|
|
63
|
+
this.includeVInReleaseName = (_d = options.includeVInReleaseName) !== null && _d !== void 0 ? _d : true;
|
|
64
|
+
this.pullRequestTitlePattern = options.pullRequestTitlePattern;
|
|
65
|
+
this.pullRequestHeader = options.pullRequestHeader;
|
|
66
|
+
this.pullRequestFooter = options.pullRequestFooter;
|
|
67
|
+
this.componentNoSpace = options.componentNoSpace;
|
|
68
|
+
this.extraFiles = options.extraFiles || [];
|
|
69
|
+
this.initialVersion = options.initialVersion;
|
|
70
|
+
this.extraLabels = options.extraLabels || [];
|
|
71
|
+
this.dateFormat = options.dateFormat || generic_1.DEFAULT_DATE_FORMAT;
|
|
72
|
+
this.includeCommitAuthors = options.includeCommitAuthors;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Return the component for this strategy. This may be a computed field.
|
|
76
|
+
* @returns {string}
|
|
77
|
+
*/
|
|
78
|
+
async getComponent() {
|
|
79
|
+
if (!this.includeComponentInTag) {
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
return this.component || (await this.getDefaultComponent());
|
|
83
|
+
}
|
|
84
|
+
async getDefaultComponent() {
|
|
85
|
+
var _a;
|
|
86
|
+
return this.normalizeComponent((_a = this.packageName) !== null && _a !== void 0 ? _a : (await this.getDefaultPackageName()));
|
|
87
|
+
}
|
|
88
|
+
async getBranchComponent() {
|
|
89
|
+
return this.component || (await this.getDefaultComponent());
|
|
90
|
+
}
|
|
91
|
+
async getPackageName() {
|
|
92
|
+
var _a;
|
|
93
|
+
return (_a = this.packageName) !== null && _a !== void 0 ? _a : (await this.getDefaultPackageName());
|
|
94
|
+
}
|
|
95
|
+
async getDefaultPackageName() {
|
|
96
|
+
var _a;
|
|
97
|
+
return (_a = this.packageName) !== null && _a !== void 0 ? _a : '';
|
|
98
|
+
}
|
|
99
|
+
normalizeComponent(component) {
|
|
100
|
+
if (!component) {
|
|
101
|
+
return '';
|
|
102
|
+
}
|
|
103
|
+
return component;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Override this method to post process commits
|
|
107
|
+
* @param {ConventionalCommit[]} commits parsed commits
|
|
108
|
+
* @returns {ConventionalCommit[]} modified commits
|
|
109
|
+
*/
|
|
110
|
+
async postProcessCommits(commits) {
|
|
111
|
+
return commits;
|
|
112
|
+
}
|
|
113
|
+
async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits) {
|
|
114
|
+
var _a;
|
|
115
|
+
return await this.changelogNotes.buildNotes(conventionalCommits, {
|
|
116
|
+
host: this.changelogHost,
|
|
117
|
+
owner: this.repository.owner,
|
|
118
|
+
repository: this.repository.repo,
|
|
119
|
+
version: newVersion.toString(),
|
|
120
|
+
previousTag: (_a = latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
121
|
+
currentTag: newVersionTag.toString(),
|
|
122
|
+
targetBranch: this.targetBranch,
|
|
123
|
+
changelogSections: this.changelogSections,
|
|
124
|
+
commits: commits,
|
|
125
|
+
includeCommitAuthors: this.includeCommitAuthors,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async buildPullRequestBody(component, newVersion, releaseNotesBody, _conventionalCommits, _latestRelease, pullRequestHeader, pullRequestFooter) {
|
|
129
|
+
return new pull_request_body_1.PullRequestBody([
|
|
130
|
+
{
|
|
131
|
+
component,
|
|
132
|
+
version: newVersion,
|
|
133
|
+
notes: releaseNotesBody,
|
|
134
|
+
},
|
|
135
|
+
], {
|
|
136
|
+
header: pullRequestHeader,
|
|
137
|
+
footer: pullRequestFooter,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Builds a candidate release pull request
|
|
142
|
+
* @param {Commit[]} commits Raw commits to consider for this release.
|
|
143
|
+
* @param {Release} latestRelease Optional. The last release for this
|
|
144
|
+
* component if available.
|
|
145
|
+
* @param {boolean} draft Optional. Whether or not to create the pull
|
|
146
|
+
* request as a draft. Defaults to `false`.
|
|
147
|
+
* @returns {ReleasePullRequest | undefined} The release pull request to
|
|
148
|
+
* open for this path/component. Returns undefined if we should not
|
|
149
|
+
* open a pull request.
|
|
150
|
+
*/
|
|
151
|
+
async buildReleasePullRequest(commits, latestRelease, draft, labels = [], bumpOnlyOptions) {
|
|
152
|
+
var _a;
|
|
153
|
+
const conventionalCommits = await this.postProcessCommits(commits);
|
|
154
|
+
this.logger.info(`Considering: ${conventionalCommits.length} commits`);
|
|
155
|
+
if (!bumpOnlyOptions && conventionalCommits.length === 0) {
|
|
156
|
+
this.logger.info(`No commits for path: ${this.path}, skipping`);
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
const newVersion = (_a = bumpOnlyOptions === null || bumpOnlyOptions === void 0 ? void 0 : bumpOnlyOptions.newVersion) !== null && _a !== void 0 ? _a : (await this.buildNewVersion(conventionalCommits, latestRelease));
|
|
160
|
+
const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits, newVersion);
|
|
161
|
+
const component = await this.getComponent();
|
|
162
|
+
this.logger.debug('component:', component);
|
|
163
|
+
const newVersionTag = new tag_name_1.TagName(newVersion, this.includeComponentInTag ? component : undefined, this.tagSeparator, this.includeVInTag);
|
|
164
|
+
this.logger.debug('pull request title pattern:', this.pullRequestTitlePattern);
|
|
165
|
+
this.logger.debug('componentNoSpace:', this.componentNoSpace);
|
|
166
|
+
const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion, this.pullRequestTitlePattern, this.componentNoSpace);
|
|
167
|
+
const branchComponent = await this.getBranchComponent();
|
|
168
|
+
const branchName = branchComponent
|
|
169
|
+
? branch_name_1.BranchName.ofComponentTargetBranch(branchComponent, this.targetBranch)
|
|
170
|
+
: branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
|
|
171
|
+
const releaseNotesBody = await this.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits);
|
|
172
|
+
if (!bumpOnlyOptions && this.changelogEmpty(releaseNotesBody)) {
|
|
173
|
+
this.logger.info(`No user facing commits found since ${latestRelease ? latestRelease.sha : 'beginning of time'} - skipping`);
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
const updates = await this.buildUpdates({
|
|
177
|
+
changelogEntry: releaseNotesBody,
|
|
178
|
+
skipChangelog: this.skipChangelog,
|
|
179
|
+
newVersion,
|
|
180
|
+
versionsMap,
|
|
181
|
+
latestVersion: latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag.version,
|
|
182
|
+
commits: conventionalCommits,
|
|
183
|
+
});
|
|
184
|
+
const updatesWithExtras = (0, composite_1.mergeUpdates)(updates.concat(...(await this.extraFileUpdates(newVersion, versionsMap, this.dateFormat))));
|
|
185
|
+
const pullRequestBody = await this.buildPullRequestBody(component, newVersion, releaseNotesBody, conventionalCommits, latestRelease, this.pullRequestHeader, this.pullRequestFooter);
|
|
186
|
+
return {
|
|
187
|
+
title: pullRequestTitle,
|
|
188
|
+
body: pullRequestBody,
|
|
189
|
+
updates: updatesWithExtras,
|
|
190
|
+
labels: [...labels, ...this.extraLabels],
|
|
191
|
+
headRefName: branchName.toString(),
|
|
192
|
+
version: newVersion,
|
|
193
|
+
draft: draft !== null && draft !== void 0 ? draft : false,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
// Helper to convert extra files with globs to the file paths to add
|
|
197
|
+
async extraFilePaths(extraFile) {
|
|
198
|
+
if (typeof extraFile !== 'object') {
|
|
199
|
+
return [extraFile];
|
|
200
|
+
}
|
|
201
|
+
if (!extraFile.glob) {
|
|
202
|
+
return [extraFile.path];
|
|
203
|
+
}
|
|
204
|
+
if (extraFile.path.startsWith('/')) {
|
|
205
|
+
// glob is relative to root, strip the leading `/` for glob matching
|
|
206
|
+
// and re-add the leading `/` to make the file relative to the root
|
|
207
|
+
return (await this.github.findFilesByGlobAndRef(extraFile.path.slice(1), this.targetBranch)).map(file => `/${file}`);
|
|
208
|
+
}
|
|
209
|
+
else if (this.path === manifest_1.ROOT_PROJECT_PATH) {
|
|
210
|
+
// root component, ignore path prefix
|
|
211
|
+
return this.github.findFilesByGlobAndRef(extraFile.path, this.targetBranch);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
// glob is relative to current path
|
|
215
|
+
return this.github.findFilesByGlobAndRef(extraFile.path, this.targetBranch, this.path);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
async extraFileUpdates(version, versionsMap, dateFormat) {
|
|
219
|
+
const extraFileUpdates = [];
|
|
220
|
+
for (const extraFile of this.extraFiles) {
|
|
221
|
+
if (typeof extraFile === 'object') {
|
|
222
|
+
const paths = await this.extraFilePaths(extraFile);
|
|
223
|
+
for (const path of paths) {
|
|
224
|
+
switch (extraFile.type) {
|
|
225
|
+
case 'generic':
|
|
226
|
+
extraFileUpdates.push({
|
|
227
|
+
path: this.addPath(path),
|
|
228
|
+
createIfMissing: false,
|
|
229
|
+
updater: new generic_1.Generic({
|
|
230
|
+
version,
|
|
231
|
+
versionsMap,
|
|
232
|
+
dateFormat: dateFormat,
|
|
233
|
+
}),
|
|
234
|
+
});
|
|
235
|
+
break;
|
|
236
|
+
case 'json':
|
|
237
|
+
extraFileUpdates.push({
|
|
238
|
+
path: this.addPath(path),
|
|
239
|
+
createIfMissing: false,
|
|
240
|
+
updater: new generic_json_1.GenericJson(extraFile.jsonpath, version),
|
|
241
|
+
});
|
|
242
|
+
break;
|
|
243
|
+
case 'yaml':
|
|
244
|
+
extraFileUpdates.push({
|
|
245
|
+
path: this.addPath(path),
|
|
246
|
+
createIfMissing: false,
|
|
247
|
+
updater: new generic_yaml_1.GenericYaml(extraFile.jsonpath, version),
|
|
248
|
+
});
|
|
249
|
+
break;
|
|
250
|
+
case 'toml':
|
|
251
|
+
extraFileUpdates.push({
|
|
252
|
+
path: this.addPath(path),
|
|
253
|
+
createIfMissing: false,
|
|
254
|
+
updater: new generic_toml_1.GenericToml(extraFile.jsonpath, version),
|
|
255
|
+
});
|
|
256
|
+
break;
|
|
257
|
+
case 'xml':
|
|
258
|
+
extraFileUpdates.push({
|
|
259
|
+
path: this.addPath(path),
|
|
260
|
+
createIfMissing: false,
|
|
261
|
+
updater: new generic_xml_1.GenericXml(extraFile.xpath, version),
|
|
262
|
+
});
|
|
263
|
+
break;
|
|
264
|
+
case 'pom':
|
|
265
|
+
extraFileUpdates.push({
|
|
266
|
+
path: this.addPath(path),
|
|
267
|
+
createIfMissing: false,
|
|
268
|
+
updater: new pom_xml_1.PomXml(version),
|
|
269
|
+
});
|
|
270
|
+
break;
|
|
271
|
+
default:
|
|
272
|
+
throw new Error(`unsupported extraFile type: ${extraFile.type}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
else if (extraFile.endsWith('.json')) {
|
|
277
|
+
extraFileUpdates.push({
|
|
278
|
+
path: this.addPath(extraFile),
|
|
279
|
+
createIfMissing: false,
|
|
280
|
+
updater: new composite_1.CompositeUpdater(new generic_json_1.GenericJson('$.version', version), new generic_1.Generic({ version, versionsMap, dateFormat: dateFormat })),
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
else if (extraFile.endsWith('.yaml') || extraFile.endsWith('.yml')) {
|
|
284
|
+
extraFileUpdates.push({
|
|
285
|
+
path: this.addPath(extraFile),
|
|
286
|
+
createIfMissing: false,
|
|
287
|
+
updater: new composite_1.CompositeUpdater(new generic_yaml_1.GenericYaml('$.version', version), new generic_1.Generic({ version, versionsMap, dateFormat: dateFormat })),
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
else if (extraFile.endsWith('.toml')) {
|
|
291
|
+
extraFileUpdates.push({
|
|
292
|
+
path: this.addPath(extraFile),
|
|
293
|
+
createIfMissing: false,
|
|
294
|
+
updater: new composite_1.CompositeUpdater(new generic_toml_1.GenericToml('$.version', version), new generic_1.Generic({ version, versionsMap, dateFormat: dateFormat })),
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
else if (extraFile.endsWith('.xml')) {
|
|
298
|
+
extraFileUpdates.push({
|
|
299
|
+
path: this.addPath(extraFile),
|
|
300
|
+
createIfMissing: false,
|
|
301
|
+
updater: new composite_1.CompositeUpdater(
|
|
302
|
+
// Updates "version" element that is a child of the root element.
|
|
303
|
+
new generic_xml_1.GenericXml('/*/version', version), new generic_1.Generic({ version, versionsMap, dateFormat: dateFormat })),
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
extraFileUpdates.push({
|
|
308
|
+
path: this.addPath(extraFile),
|
|
309
|
+
createIfMissing: false,
|
|
310
|
+
updater: new generic_1.Generic({ version, versionsMap, dateFormat: dateFormat }),
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return extraFileUpdates;
|
|
315
|
+
}
|
|
316
|
+
changelogEmpty(changelogEntry) {
|
|
317
|
+
return changelogEntry.split('\n').length <= 1;
|
|
318
|
+
}
|
|
319
|
+
async updateVersionsMap(versionsMap, conventionalCommits, _newVersion) {
|
|
320
|
+
for (const [component, version] of versionsMap.entries()) {
|
|
321
|
+
versionsMap.set(component, await this.versioningStrategy.bump(version, conventionalCommits));
|
|
322
|
+
}
|
|
323
|
+
return versionsMap;
|
|
324
|
+
}
|
|
325
|
+
async buildNewVersion(conventionalCommits, latestRelease) {
|
|
326
|
+
if (this.releaseAs) {
|
|
327
|
+
this.logger.warn(`Setting version for ${this.path} from release-as configuration`);
|
|
328
|
+
return version_1.Version.parse(this.releaseAs);
|
|
329
|
+
}
|
|
330
|
+
const releaseAsCommit = conventionalCommits.find(conventionalCommit => conventionalCommit.notes.find(note => note.title === 'RELEASE AS'));
|
|
331
|
+
if (releaseAsCommit) {
|
|
332
|
+
const note = releaseAsCommit.notes.find(note => note.title === 'RELEASE AS');
|
|
333
|
+
if (note) {
|
|
334
|
+
return version_1.Version.parse(note.text);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (latestRelease) {
|
|
338
|
+
return await this.versioningStrategy.bump(latestRelease.tag.version, conventionalCommits);
|
|
339
|
+
}
|
|
340
|
+
return this.initialReleaseVersion();
|
|
341
|
+
}
|
|
342
|
+
async buildVersionsMap(_conventionalCommits) {
|
|
343
|
+
return new Map();
|
|
344
|
+
}
|
|
345
|
+
async parsePullRequestBody(pullRequestBody) {
|
|
346
|
+
return pull_request_body_1.PullRequestBody.parse(pullRequestBody, this.logger);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Given a merged pull request, build the candidate release.
|
|
350
|
+
* @param {PullRequest} mergedPullRequest The merged release pull request.
|
|
351
|
+
* @returns {Release} The candidate release.
|
|
352
|
+
* @deprecated Use buildReleases() instead.
|
|
353
|
+
*/
|
|
354
|
+
async buildRelease(mergedPullRequest, options) {
|
|
355
|
+
var _a;
|
|
356
|
+
if (this.skipGitHubRelease) {
|
|
357
|
+
this.logger.info('Release skipped from strategy config');
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (!mergedPullRequest.sha) {
|
|
361
|
+
this.logger.error('Pull request should have been merged');
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const mergedTitlePattern = (_a = options === null || options === void 0 ? void 0 : options.groupPullRequestTitlePattern) !== null && _a !== void 0 ? _a : manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN;
|
|
365
|
+
const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, this.pullRequestTitlePattern, this.componentNoSpace, this.logger) ||
|
|
366
|
+
pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, mergedTitlePattern, this.componentNoSpace, this.logger);
|
|
367
|
+
if (!pullRequestTitle) {
|
|
368
|
+
this.logger.error(`Bad pull request title: '${mergedPullRequest.title}'`);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const branchName = branch_name_1.BranchName.parse(mergedPullRequest.headBranchName, this.logger);
|
|
372
|
+
if (!branchName) {
|
|
373
|
+
this.logger.error(`Bad branch name: ${mergedPullRequest.headBranchName}`);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
const branchComponent = await this.getBranchComponent();
|
|
377
|
+
if (branchName.isComponent()) {
|
|
378
|
+
if (this.normalizeComponent(branchName.component) !==
|
|
379
|
+
this.normalizeComponent(branchComponent)) {
|
|
380
|
+
this.logger.info(`PR branch component: ${branchName.component} does not match configured branch component: ${branchComponent}`);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
const pullRequestBody = await this.parsePullRequestBody(mergedPullRequest.body);
|
|
385
|
+
if (!pullRequestBody) {
|
|
386
|
+
this.logger.error('Could not parse pull request body as a release PR');
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const component = await this.getComponent();
|
|
390
|
+
let releaseData;
|
|
391
|
+
if (pullRequestBody.releaseData.length === 1 &&
|
|
392
|
+
!pullRequestBody.releaseData[0].component) {
|
|
393
|
+
const branchComponent = await this.getBranchComponent();
|
|
394
|
+
// standalone release PR, ensure the components match
|
|
395
|
+
if (this.normalizeComponent(branchName.component) !==
|
|
396
|
+
this.normalizeComponent(branchComponent)) {
|
|
397
|
+
this.logger.warn(`PR component: ${branchName.component} does not match configured component: ${branchComponent}`);
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
releaseData = pullRequestBody.releaseData[0];
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
// manifest release with multiple components - find the release notes
|
|
404
|
+
// for the component to see if it was included in this release (parsed
|
|
405
|
+
// from the release pull request body)
|
|
406
|
+
releaseData = pullRequestBody.releaseData.find(datum => {
|
|
407
|
+
return (this.normalizeComponent(datum.component) ===
|
|
408
|
+
this.normalizeComponent(component));
|
|
409
|
+
});
|
|
410
|
+
if (!releaseData && pullRequestBody.releaseData.length > 0) {
|
|
411
|
+
this.logger.info(`Pull request contains releases, but not for component: ${component}`);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
const notes = releaseData === null || releaseData === void 0 ? void 0 : releaseData.notes;
|
|
416
|
+
if (notes === undefined) {
|
|
417
|
+
this.logger.warn('Failed to find release notes');
|
|
418
|
+
}
|
|
419
|
+
let version = pullRequestTitle.getVersion();
|
|
420
|
+
if (!version ||
|
|
421
|
+
(pullRequestBody.releaseData.length > 1 && (releaseData === null || releaseData === void 0 ? void 0 : releaseData.version))) {
|
|
422
|
+
// prioritize pull-request body version for multi-component releases
|
|
423
|
+
version = releaseData === null || releaseData === void 0 ? void 0 : releaseData.version;
|
|
424
|
+
}
|
|
425
|
+
if (!version) {
|
|
426
|
+
this.logger.error('Pull request should have included version');
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (!this.isPublishedVersion(version)) {
|
|
430
|
+
this.logger.warn(`Skipping non-published version: ${version.toString()}`);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
const tag = new tag_name_1.TagName(version, this.includeComponentInTag ? component : undefined, this.tagSeparator, this.includeVInTag);
|
|
434
|
+
const versionPrefix = this.includeVInReleaseName ? 'v' : '';
|
|
435
|
+
const releaseName = component && this.includeComponentInTag
|
|
436
|
+
? `${component}: ${versionPrefix}${version.toString()}`
|
|
437
|
+
: `${versionPrefix}${version.toString()}`;
|
|
438
|
+
return {
|
|
439
|
+
name: releaseName,
|
|
440
|
+
tag,
|
|
441
|
+
notes: notes || '',
|
|
442
|
+
sha: mergedPullRequest.sha,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Given a merged pull request, build the candidate releases.
|
|
447
|
+
* @param {PullRequest} mergedPullRequest The merged release pull request.
|
|
448
|
+
* @returns {Release} The candidate release.
|
|
449
|
+
*/
|
|
450
|
+
async buildReleases(mergedPullRequest, options) {
|
|
451
|
+
const release = await this.buildRelease(mergedPullRequest, options);
|
|
452
|
+
if (release) {
|
|
453
|
+
return [release];
|
|
454
|
+
}
|
|
455
|
+
return [];
|
|
456
|
+
}
|
|
457
|
+
isPublishedVersion(_version) {
|
|
458
|
+
return true;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Override this to handle the initial version of a new library.
|
|
462
|
+
*/
|
|
463
|
+
initialReleaseVersion() {
|
|
464
|
+
if (this.initialVersion) {
|
|
465
|
+
return version_1.Version.parse(this.initialVersion);
|
|
466
|
+
}
|
|
467
|
+
return version_1.Version.parse('1.0.0');
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Adds a given file path to the strategy path.
|
|
471
|
+
* @param {string} file Desired file path.
|
|
472
|
+
* @returns {string} The file relative to the strategy.
|
|
473
|
+
* @throws {Error} If the file path contains relative pathing characters, i.e. ../, ~/
|
|
474
|
+
*/
|
|
475
|
+
addPath(file) {
|
|
476
|
+
// There is no strategy path to join, the strategy is at the root, or the
|
|
477
|
+
// file is at the root (denoted by a leading slash or tilde)
|
|
478
|
+
if (!this.path || this.path === manifest_1.ROOT_PROJECT_PATH || file.startsWith('/')) {
|
|
479
|
+
file = file.replace(/^\/+/, '');
|
|
480
|
+
}
|
|
481
|
+
// Otherwise, the file is relative to the strategy path
|
|
482
|
+
else {
|
|
483
|
+
file = `${this.path.replace(/\/+$/, '')}/${file}`;
|
|
484
|
+
}
|
|
485
|
+
// Ensure the file path does not escape the workspace
|
|
486
|
+
if (/((^|\/)\.{1,2}|^~|^\/*)+\//.test(file)) {
|
|
487
|
+
throw new Error(`illegal pathing characters in path: ${file}`);
|
|
488
|
+
}
|
|
489
|
+
// Strip any trailing slashes and return
|
|
490
|
+
return file.replace(/\/+$/, '');
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
exports.BaseStrategy = BaseStrategy;
|
|
494
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Update } from '../update';
|
|
2
|
+
import { BaseStrategy, BaseStrategyOptions, BuildUpdatesOptions } from './base';
|
|
3
|
+
export declare class Bazel extends BaseStrategy {
|
|
4
|
+
readonly versionFile: string;
|
|
5
|
+
constructor(options: BaseStrategyOptions);
|
|
6
|
+
protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
7
|
+
}
|