@release-please-oss/release-please 0.0.0 → 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 +280 -0
- 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 +113 -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
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2022 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.FilePullRequestOverflowHandler = void 0;
|
|
17
|
+
const pull_request_body_1 = require("./pull-request-body");
|
|
18
|
+
const logger_1 = require("./logger");
|
|
19
|
+
const url_1 = require("url");
|
|
20
|
+
const MAX_ISSUE_BODY_SIZE = 65536;
|
|
21
|
+
const OVERFLOW_MESSAGE = 'This release is too large to preview in the pull request body. View the full release notes here:';
|
|
22
|
+
const OVERFLOW_MESSAGE_REGEX = new RegExp(`${OVERFLOW_MESSAGE} (?<url>.*)`);
|
|
23
|
+
const RELEASE_NOTES_FILENAME = 'release-notes.md';
|
|
24
|
+
const FILE_PATH_REGEX = new RegExp(`blob/(?<branchName>.*)/${RELEASE_NOTES_FILENAME}`);
|
|
25
|
+
/**
|
|
26
|
+
* This implementation of PullRequestOverflowHandler stores the full release
|
|
27
|
+
* notes on a new git branch. The branch name is derived from the head branch
|
|
28
|
+
* name of the release pull request.
|
|
29
|
+
*/
|
|
30
|
+
class FilePullRequestOverflowHandler {
|
|
31
|
+
constructor(github, logger = logger_1.logger) {
|
|
32
|
+
this.github = github;
|
|
33
|
+
this.logger = logger;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Optionally store the full release notes into `release-notes.md` file
|
|
37
|
+
* on a new branch if they do not fit into the body of a pull request.
|
|
38
|
+
*
|
|
39
|
+
* The new release notes will have a link to the GitHub UI for that file
|
|
40
|
+
* which should render the release notes nicely.
|
|
41
|
+
* @param {ReleasePullRequest} pullRequest The candidate release pull request
|
|
42
|
+
* @returns {string} The new pull request body which contains a link to
|
|
43
|
+
* the full content.
|
|
44
|
+
*/
|
|
45
|
+
async handleOverflow(pullRequest, maxSize = MAX_ISSUE_BODY_SIZE) {
|
|
46
|
+
const notes = pullRequest.body.toString();
|
|
47
|
+
if (notes.length > maxSize) {
|
|
48
|
+
const notesBranchName = `${pullRequest.headRefName}--release-notes`;
|
|
49
|
+
const url = await this.github.createFileOnNewBranch(RELEASE_NOTES_FILENAME, notes, notesBranchName, this.github.repository.defaultBranch);
|
|
50
|
+
return `${OVERFLOW_MESSAGE} ${url}`;
|
|
51
|
+
}
|
|
52
|
+
return notes;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Given a pull request, retrieve the full release notes from the stored
|
|
56
|
+
* file if the body was too big to store in the pull request body.
|
|
57
|
+
* @param {PullRequest} pullRequest The pull request from GitHub
|
|
58
|
+
* @return {PullRequestBody} The parsed pull request body
|
|
59
|
+
*/
|
|
60
|
+
async parseOverflow(pullRequest) {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
const match = pullRequest.body.match(OVERFLOW_MESSAGE_REGEX);
|
|
63
|
+
if ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.url) {
|
|
64
|
+
this.logger.info(`Pull request body overflows, parsing full body from: ${match.groups.url}`);
|
|
65
|
+
const url = new url_1.URL(match.groups.url);
|
|
66
|
+
const pathMatch = url.pathname.match(FILE_PATH_REGEX);
|
|
67
|
+
if ((_b = pathMatch === null || pathMatch === void 0 ? void 0 : pathMatch.groups) === null || _b === void 0 ? void 0 : _b.branchName) {
|
|
68
|
+
const fileContents = await this.github.getFileContentsOnBranch(RELEASE_NOTES_FILENAME, pathMatch.groups.branchName);
|
|
69
|
+
return pull_request_body_1.PullRequestBody.parse(fileContents.parsedContent);
|
|
70
|
+
}
|
|
71
|
+
this.logger.warn(`Could not parse branch from ${match.groups.url}`);
|
|
72
|
+
return pull_request_body_1.PullRequestBody.parse(pullRequest.body, this.logger);
|
|
73
|
+
}
|
|
74
|
+
return pull_request_body_1.PullRequestBody.parse(pullRequest.body, this.logger);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.FilePullRequestOverflowHandler = FilePullRequestOverflowHandler;
|
|
78
|
+
//# sourceMappingURL=pull-request-overflow-handler.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Logger } from './logger';
|
|
2
|
+
import { Version } from '../version';
|
|
3
|
+
export declare function generateMatchPattern(pullRequestTitlePattern?: string, componentNoSpace?: boolean, logger?: Logger): RegExp;
|
|
4
|
+
export declare class PullRequestTitle {
|
|
5
|
+
component?: string;
|
|
6
|
+
targetBranch?: string;
|
|
7
|
+
version?: Version;
|
|
8
|
+
pullRequestTitlePattern: string;
|
|
9
|
+
matchPattern: RegExp;
|
|
10
|
+
componentNoSpace?: boolean;
|
|
11
|
+
private constructor();
|
|
12
|
+
static parse(title: string, pullRequestTitlePattern?: string, componentNoSpace?: boolean, logger?: Logger): PullRequestTitle | undefined;
|
|
13
|
+
static ofComponentVersion(component: string, version: Version, pullRequestTitlePattern?: string, componentNoSpace?: boolean): PullRequestTitle;
|
|
14
|
+
static ofVersion(version: Version, pullRequestTitlePattern?: string, componentNoSpace?: boolean): PullRequestTitle;
|
|
15
|
+
static ofTargetBranchVersion(targetBranch: string, version: Version, pullRequestTitlePattern?: string, componentNoSpace?: boolean): PullRequestTitle;
|
|
16
|
+
static ofComponentTargetBranchVersion(component?: string, targetBranch?: string, version?: Version, pullRequestTitlePattern?: string, componentNoSpace?: boolean): PullRequestTitle;
|
|
17
|
+
static ofTargetBranch(targetBranch: string, pullRequestTitlePattern?: string, componentNoSpace?: boolean): PullRequestTitle;
|
|
18
|
+
getTargetBranch(): string | undefined;
|
|
19
|
+
getComponent(): string | undefined;
|
|
20
|
+
getVersion(): Version | undefined;
|
|
21
|
+
toString(): string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
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.PullRequestTitle = exports.generateMatchPattern = void 0;
|
|
17
|
+
const logger_1 = require("./logger");
|
|
18
|
+
const version_1 = require("../version");
|
|
19
|
+
// cannot import from '..' - transpiled code references to RELEASE_PLEASE
|
|
20
|
+
// at the script level are undefined, they are only defined inside function
|
|
21
|
+
// or instance methods/properties.
|
|
22
|
+
const DEFAULT_PR_TITLE_PATTERN = 'chore${scope}: release${component} ${version}';
|
|
23
|
+
const COMPONENT_NO_SPACE = false;
|
|
24
|
+
function generateMatchPattern(pullRequestTitlePattern, componentNoSpace, logger = logger_1.logger) {
|
|
25
|
+
if (pullRequestTitlePattern &&
|
|
26
|
+
pullRequestTitlePattern.search(/\$\{scope\}/) === -1)
|
|
27
|
+
logger.warn("pullRequestTitlePattern miss the part of '${scope}'");
|
|
28
|
+
if (pullRequestTitlePattern &&
|
|
29
|
+
pullRequestTitlePattern.search(/\$\{component\}/) === -1)
|
|
30
|
+
logger.warn("pullRequestTitlePattern miss the part of '${component}'");
|
|
31
|
+
if (pullRequestTitlePattern &&
|
|
32
|
+
pullRequestTitlePattern.search(/\$\{version\}/) === -1)
|
|
33
|
+
logger.warn("pullRequestTitlePattern miss the part of '${version}'");
|
|
34
|
+
return new RegExp(`^${(pullRequestTitlePattern || DEFAULT_PR_TITLE_PATTERN)
|
|
35
|
+
.replace(/\[/g, '\\[') // TODO: handle all regex escaping
|
|
36
|
+
.replace(/\]/g, '\\]')
|
|
37
|
+
.replace(/\(/g, '\\(')
|
|
38
|
+
.replace(/\)/g, '\\)')
|
|
39
|
+
.replace('${scope}', '(\\((?<branch>[\\w-./]+)\\))?')
|
|
40
|
+
.replace('${component}', componentNoSpace === true
|
|
41
|
+
? '?(?<component>@?[\\w-./]*)?'
|
|
42
|
+
: ' ?(?<component>@?[\\w-./]*)?')
|
|
43
|
+
.replace('${version}', 'v?(?<version>[0-9].*)')
|
|
44
|
+
.replace('${branch}', '(?<branch>[\\w-./]+)?')}$`);
|
|
45
|
+
}
|
|
46
|
+
exports.generateMatchPattern = generateMatchPattern;
|
|
47
|
+
class PullRequestTitle {
|
|
48
|
+
constructor(opts) {
|
|
49
|
+
this.version = opts.version;
|
|
50
|
+
this.component = opts.component;
|
|
51
|
+
this.targetBranch = opts.targetBranch;
|
|
52
|
+
this.pullRequestTitlePattern =
|
|
53
|
+
opts.pullRequestTitlePattern || DEFAULT_PR_TITLE_PATTERN;
|
|
54
|
+
this.componentNoSpace = opts.componentNoSpace || COMPONENT_NO_SPACE;
|
|
55
|
+
this.matchPattern = generateMatchPattern(this.pullRequestTitlePattern, this.componentNoSpace, opts.logger);
|
|
56
|
+
}
|
|
57
|
+
static parse(title, pullRequestTitlePattern, componentNoSpace, logger = logger_1.logger) {
|
|
58
|
+
const matchPattern = generateMatchPattern(pullRequestTitlePattern, componentNoSpace, logger);
|
|
59
|
+
const match = title.match(matchPattern);
|
|
60
|
+
if (match === null || match === void 0 ? void 0 : match.groups) {
|
|
61
|
+
return new PullRequestTitle({
|
|
62
|
+
version: match.groups['version']
|
|
63
|
+
? version_1.Version.parse(match.groups['version'])
|
|
64
|
+
: undefined,
|
|
65
|
+
component: match.groups['component'],
|
|
66
|
+
targetBranch: match.groups['branch'],
|
|
67
|
+
pullRequestTitlePattern,
|
|
68
|
+
componentNoSpace,
|
|
69
|
+
logger,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
static ofComponentVersion(component, version, pullRequestTitlePattern, componentNoSpace) {
|
|
75
|
+
return new PullRequestTitle({
|
|
76
|
+
version,
|
|
77
|
+
component,
|
|
78
|
+
pullRequestTitlePattern,
|
|
79
|
+
componentNoSpace,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
static ofVersion(version, pullRequestTitlePattern, componentNoSpace) {
|
|
83
|
+
return new PullRequestTitle({
|
|
84
|
+
version,
|
|
85
|
+
pullRequestTitlePattern,
|
|
86
|
+
componentNoSpace,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
static ofTargetBranchVersion(targetBranch, version, pullRequestTitlePattern, componentNoSpace) {
|
|
90
|
+
return new PullRequestTitle({
|
|
91
|
+
version,
|
|
92
|
+
targetBranch,
|
|
93
|
+
pullRequestTitlePattern,
|
|
94
|
+
componentNoSpace,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
static ofComponentTargetBranchVersion(component, targetBranch, version, pullRequestTitlePattern, componentNoSpace) {
|
|
98
|
+
return new PullRequestTitle({
|
|
99
|
+
version,
|
|
100
|
+
component,
|
|
101
|
+
targetBranch,
|
|
102
|
+
pullRequestTitlePattern,
|
|
103
|
+
componentNoSpace,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
static ofTargetBranch(targetBranch, pullRequestTitlePattern, componentNoSpace) {
|
|
107
|
+
return new PullRequestTitle({
|
|
108
|
+
targetBranch,
|
|
109
|
+
pullRequestTitlePattern,
|
|
110
|
+
componentNoSpace,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
getTargetBranch() {
|
|
114
|
+
return this.targetBranch;
|
|
115
|
+
}
|
|
116
|
+
getComponent() {
|
|
117
|
+
return this.component;
|
|
118
|
+
}
|
|
119
|
+
getVersion() {
|
|
120
|
+
return this.version;
|
|
121
|
+
}
|
|
122
|
+
toString() {
|
|
123
|
+
var _a;
|
|
124
|
+
const scope = this.targetBranch ? `(${this.targetBranch})` : '';
|
|
125
|
+
const component = this.componentNoSpace === true
|
|
126
|
+
? this.component
|
|
127
|
+
? `${this.component}`
|
|
128
|
+
: ''
|
|
129
|
+
: this.component
|
|
130
|
+
? ` ${this.component}`
|
|
131
|
+
: '';
|
|
132
|
+
const version = (_a = this.version) !== null && _a !== void 0 ? _a : '';
|
|
133
|
+
if (this.componentNoSpace === true && !component) {
|
|
134
|
+
console.log('`component` is empty. Removing component from title pattern..');
|
|
135
|
+
this.pullRequestTitlePattern = this.pullRequestTitlePattern.replace('${component} ', '');
|
|
136
|
+
}
|
|
137
|
+
return this.pullRequestTitlePattern
|
|
138
|
+
.replace('${scope}', scope)
|
|
139
|
+
.replace('${component}', component)
|
|
140
|
+
.replace('${version}', version.toString())
|
|
141
|
+
.replace('${branch}', this.targetBranch || '')
|
|
142
|
+
.trim();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.PullRequestTitle = PullRequestTitle;
|
|
146
|
+
//# sourceMappingURL=pull-request-title.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function signoffCommitMessage(commitMessage: string, signoffUser: string): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
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.signoffCommitMessage = void 0;
|
|
17
|
+
// cannot import from '..' - transpiled code references to RELEASE_PLEASE
|
|
18
|
+
// at the script level are undefined, they are only defined inside function
|
|
19
|
+
// or instance methods/properties.
|
|
20
|
+
function isValidSignoffUser(signoffUser) {
|
|
21
|
+
// Parse the name and email address from a string in the following format
|
|
22
|
+
// Display Name <email@address.com>
|
|
23
|
+
const pattern = /^([^<]+)\s*<([^>]+)>$/i;
|
|
24
|
+
// Check we have a match
|
|
25
|
+
const isMatch = new RegExp(pattern).test(signoffUser);
|
|
26
|
+
return isMatch;
|
|
27
|
+
}
|
|
28
|
+
function signoffCommitMessage(commitMessage, signoffUser) {
|
|
29
|
+
if (!isValidSignoffUser(signoffUser)) {
|
|
30
|
+
throw new Error(`The format of '${signoffUser}' is not a valid email address with display name`);
|
|
31
|
+
}
|
|
32
|
+
return commitMessage + `\n\nSigned-off-by: ${signoffUser}`;
|
|
33
|
+
}
|
|
34
|
+
exports.signoffCommitMessage = signoffCommitMessage;
|
|
35
|
+
//# sourceMappingURL=signoff-commit-message.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Version } from '../version';
|
|
2
|
+
export declare class TagName {
|
|
3
|
+
component?: string;
|
|
4
|
+
version: Version;
|
|
5
|
+
separator: string;
|
|
6
|
+
includeV: boolean;
|
|
7
|
+
constructor(version: Version, component?: string, separator?: string, includeV?: boolean);
|
|
8
|
+
static parse(tagName: string): TagName | undefined;
|
|
9
|
+
toString(): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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.TagName = void 0;
|
|
17
|
+
const version_1 = require("../version");
|
|
18
|
+
const TAG_PATTERN = /^((?<component>.*)(?<separator>[^a-zA-Z0-9]))?(?<v>v)?(?<version>\d+\.\d+\.\d+.*)$/;
|
|
19
|
+
const DEFAULT_SEPARATOR = '-';
|
|
20
|
+
class TagName {
|
|
21
|
+
constructor(version, component, separator = DEFAULT_SEPARATOR, includeV = true) {
|
|
22
|
+
this.version = version;
|
|
23
|
+
this.component = component;
|
|
24
|
+
this.separator = separator;
|
|
25
|
+
this.includeV = includeV;
|
|
26
|
+
}
|
|
27
|
+
static parse(tagName) {
|
|
28
|
+
const match = tagName.match(TAG_PATTERN);
|
|
29
|
+
if (match === null || match === void 0 ? void 0 : match.groups) {
|
|
30
|
+
return new TagName(version_1.Version.parse(match.groups.version), match.groups.component, match.groups.separator, !!match.groups.v);
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
toString() {
|
|
35
|
+
if (this.component) {
|
|
36
|
+
return `${this.component}${this.separator}${this.includeV ? 'v' : ''}${this.version.toString()}`;
|
|
37
|
+
}
|
|
38
|
+
return `${this.includeV ? 'v' : ''}${this.version.toString()}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.TagName = TagName;
|
|
42
|
+
//# sourceMappingURL=tag-name.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { JsonMap } from '@iarna/toml';
|
|
2
|
+
import * as TOMLParser from '@iarna/toml/lib/toml-parser';
|
|
3
|
+
/**
|
|
4
|
+
* Parses input as TOML with the given parser
|
|
5
|
+
* @param input A string
|
|
6
|
+
* @param parserType The TOML parser to use (might be custom)
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseWith(input: string, parserType?: typeof TOMLParser): JsonMap;
|
|
9
|
+
/**
|
|
10
|
+
* Given TOML input and a path to a value, attempt to replace
|
|
11
|
+
* that value without modifying the formatting.
|
|
12
|
+
* @param input A string that's valid TOML
|
|
13
|
+
* @param path Path to a value to replace. When replacing 'deps.tokio.version', pass ['deps', 'tokio', 'version']. The value must already exist.
|
|
14
|
+
* @param newValue The value to replace the value at `path` with. Is passed through `JSON.stringify()` when replacing: strings will end up being double-quoted strings, properly escaped. Numbers will be numbers.
|
|
15
|
+
*/
|
|
16
|
+
export declare function replaceTomlValue(input: string, path: (string | number)[], newValue: string): string;
|
|
@@ -0,0 +1,126 @@
|
|
|
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.replaceTomlValue = exports.parseWith = void 0;
|
|
17
|
+
const TOMLParser = require("@iarna/toml/lib/toml-parser");
|
|
18
|
+
const taggedValueMarker = Symbol('__TAGGED_VALUE');
|
|
19
|
+
/**
|
|
20
|
+
* A custom variant of `TOMLParser` that replaces all values with a tagged
|
|
21
|
+
* variant that includes their start and end positions, allowing them to be
|
|
22
|
+
* replaced.
|
|
23
|
+
*/
|
|
24
|
+
class TaggedTOMLParser extends TOMLParser {
|
|
25
|
+
parseValue() {
|
|
26
|
+
// Remember the start position of the value.
|
|
27
|
+
//
|
|
28
|
+
// Off-by-one correctness: by this point, `this.pos` points one character
|
|
29
|
+
// *after* the first character of the value, which is in `this.char`
|
|
30
|
+
this.state.__TAGGED_START = this.pos - 1;
|
|
31
|
+
return super.parseValue();
|
|
32
|
+
}
|
|
33
|
+
next(fn) {
|
|
34
|
+
const prevState = this.state;
|
|
35
|
+
super.next(fn); // `next` returns void
|
|
36
|
+
// Carry over the start position. If it wasn't set, (say, if we were parsing
|
|
37
|
+
// something other than a value), we're just assigning `undefined` here.
|
|
38
|
+
this.state.__TAGGED_START = prevState.__TAGGED_START;
|
|
39
|
+
}
|
|
40
|
+
return(value) {
|
|
41
|
+
const prevState = this.state;
|
|
42
|
+
super.return(value); // `return` returns void
|
|
43
|
+
if (prevState.__TAGGED_START && typeof this.state.returned !== 'object') {
|
|
44
|
+
// If the parser we just returned from remembered a start position,
|
|
45
|
+
// tag the returned value with "start" and "end".
|
|
46
|
+
// Note that we don't tag objects to avoid encountering multiple tagged
|
|
47
|
+
// values when replacing later on.
|
|
48
|
+
const taggedValue = {
|
|
49
|
+
[taggedValueMarker]: true,
|
|
50
|
+
start: prevState.__TAGGED_START,
|
|
51
|
+
end: this.pos,
|
|
52
|
+
value: this.state.returned,
|
|
53
|
+
};
|
|
54
|
+
this.state.returned = taggedValue;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Parses input as TOML with the given parser
|
|
60
|
+
* @param input A string
|
|
61
|
+
* @param parserType The TOML parser to use (might be custom)
|
|
62
|
+
*/
|
|
63
|
+
function parseWith(input, parserType = TaggedTOMLParser) {
|
|
64
|
+
const parser = new parserType();
|
|
65
|
+
parser.parse(input);
|
|
66
|
+
return parser.finish();
|
|
67
|
+
}
|
|
68
|
+
exports.parseWith = parseWith;
|
|
69
|
+
function isTaggedValue(x) {
|
|
70
|
+
if (!x) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (typeof x !== 'object') {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const ts = x;
|
|
77
|
+
return ts[taggedValueMarker] === true;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Given TOML input and a path to a value, attempt to replace
|
|
81
|
+
* that value without modifying the formatting.
|
|
82
|
+
* @param input A string that's valid TOML
|
|
83
|
+
* @param path Path to a value to replace. When replacing 'deps.tokio.version', pass ['deps', 'tokio', 'version']. The value must already exist.
|
|
84
|
+
* @param newValue The value to replace the value at `path` with. Is passed through `JSON.stringify()` when replacing: strings will end up being double-quoted strings, properly escaped. Numbers will be numbers.
|
|
85
|
+
*/
|
|
86
|
+
function replaceTomlValue(input, path, newValue) {
|
|
87
|
+
// our pointer into the object "tree", initially points to the root.
|
|
88
|
+
let current = parseWith(input, TaggedTOMLParser);
|
|
89
|
+
// navigate down the object tree, following the path, expecting only objects.
|
|
90
|
+
// Note that tagged strings (generated by `TaggedTOMLParser`) are also objects.
|
|
91
|
+
for (let i = 0; i < path.length; i++) {
|
|
92
|
+
const key = path[i];
|
|
93
|
+
// // We may encounter tagged values when descending through the object tree
|
|
94
|
+
// if (isTaggedValue(current)) {
|
|
95
|
+
// if (!current.value || typeof current.value !== 'object') {
|
|
96
|
+
// const msg = `partial path does not lead to table: ${path
|
|
97
|
+
// .slice(0, i)
|
|
98
|
+
// .join('.')}`;
|
|
99
|
+
// throw new Error(msg);
|
|
100
|
+
// }
|
|
101
|
+
// current = current.value as Record<string, unknown>;
|
|
102
|
+
// }
|
|
103
|
+
const next = current[key];
|
|
104
|
+
if (typeof next !== 'object') {
|
|
105
|
+
const msg = `path not found in object: ${path.slice(0, i + 1).join('.')}`;
|
|
106
|
+
throw new Error(msg);
|
|
107
|
+
}
|
|
108
|
+
current = next;
|
|
109
|
+
}
|
|
110
|
+
if (!isTaggedValue(current)) {
|
|
111
|
+
const msg = `value at path ${path.join('.')} is not tagged`;
|
|
112
|
+
throw new Error(msg);
|
|
113
|
+
}
|
|
114
|
+
const before = input.slice(0, current.start);
|
|
115
|
+
const after = input.slice(current.end);
|
|
116
|
+
const output = before + JSON.stringify(newValue) + after;
|
|
117
|
+
try {
|
|
118
|
+
parseWith(output, TOMLParser);
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
throw new Error(`After replacing value, result is not valid TOML: ${e}`);
|
|
122
|
+
}
|
|
123
|
+
return output;
|
|
124
|
+
}
|
|
125
|
+
exports.replaceTomlValue = replaceTomlValue;
|
|
126
|
+
//# sourceMappingURL=toml-edit.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This data class is used to represent a SemVer version.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Version {
|
|
5
|
+
readonly major: number;
|
|
6
|
+
readonly minor: number;
|
|
7
|
+
readonly patch: number;
|
|
8
|
+
readonly preRelease?: string;
|
|
9
|
+
readonly build?: string;
|
|
10
|
+
constructor(major: number, minor: number, patch: number, preRelease?: string, build?: string);
|
|
11
|
+
/**
|
|
12
|
+
* Parse a version string into a data class.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} versionString the input version string
|
|
15
|
+
* @returns {Version} the parsed version
|
|
16
|
+
* @throws {Error} if the version string cannot be parsed
|
|
17
|
+
*/
|
|
18
|
+
static parse(versionString: string): Version;
|
|
19
|
+
/**
|
|
20
|
+
* Comparator to other Versions to be used in sorting.
|
|
21
|
+
*
|
|
22
|
+
* @param {Version} other The other version to compare to
|
|
23
|
+
* @returns {number} -1 if this version is earlier, 0 if the versions
|
|
24
|
+
* are the same, or 1 otherwise.
|
|
25
|
+
*/
|
|
26
|
+
compare(other: Version): -1 | 0 | 1;
|
|
27
|
+
/**
|
|
28
|
+
* Returns a normalized string version of this version.
|
|
29
|
+
*
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
toString(): string;
|
|
33
|
+
get isPreMajor(): boolean;
|
|
34
|
+
}
|
|
35
|
+
export type VersionsMap = Map<string, Version>;
|
|
@@ -0,0 +1,74 @@
|
|
|
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.Version = void 0;
|
|
17
|
+
const semver = require("semver");
|
|
18
|
+
const VERSION_REGEX = /(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-(?<preRelease>[^+]+))?(\+(?<build>.*))?/;
|
|
19
|
+
/**
|
|
20
|
+
* This data class is used to represent a SemVer version.
|
|
21
|
+
*/
|
|
22
|
+
class Version {
|
|
23
|
+
constructor(major, minor, patch, preRelease, build) {
|
|
24
|
+
this.major = major;
|
|
25
|
+
this.minor = minor;
|
|
26
|
+
this.patch = patch;
|
|
27
|
+
this.preRelease = preRelease;
|
|
28
|
+
this.build = build;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parse a version string into a data class.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} versionString the input version string
|
|
34
|
+
* @returns {Version} the parsed version
|
|
35
|
+
* @throws {Error} if the version string cannot be parsed
|
|
36
|
+
*/
|
|
37
|
+
static parse(versionString) {
|
|
38
|
+
const match = versionString.match(VERSION_REGEX);
|
|
39
|
+
if (!(match === null || match === void 0 ? void 0 : match.groups)) {
|
|
40
|
+
throw Error(`unable to parse version string: ${versionString}`);
|
|
41
|
+
}
|
|
42
|
+
const major = Number(match.groups.major);
|
|
43
|
+
const minor = Number(match.groups.minor);
|
|
44
|
+
const patch = Number(match.groups.patch);
|
|
45
|
+
const preRelease = match.groups.preRelease;
|
|
46
|
+
const build = match.groups.build;
|
|
47
|
+
return new Version(major, minor, patch, preRelease, build);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Comparator to other Versions to be used in sorting.
|
|
51
|
+
*
|
|
52
|
+
* @param {Version} other The other version to compare to
|
|
53
|
+
* @returns {number} -1 if this version is earlier, 0 if the versions
|
|
54
|
+
* are the same, or 1 otherwise.
|
|
55
|
+
*/
|
|
56
|
+
compare(other) {
|
|
57
|
+
return semver.compare(this.toString(), other.toString());
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns a normalized string version of this version.
|
|
61
|
+
*
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
64
|
+
toString() {
|
|
65
|
+
const preReleasePart = this.preRelease ? `-${this.preRelease}` : '';
|
|
66
|
+
const buildPart = this.build ? `+${this.build}` : '';
|
|
67
|
+
return `${this.major}.${this.minor}.${this.patch}${preReleasePart}${buildPart}`;
|
|
68
|
+
}
|
|
69
|
+
get isPreMajor() {
|
|
70
|
+
return this.major < 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.Version = Version;
|
|
74
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Version } from '../version';
|
|
2
|
+
import { ConventionalCommit } from '../commit';
|
|
3
|
+
import { DefaultVersioningStrategy } from './default';
|
|
4
|
+
import { VersionUpdater } from '../versioning-strategy';
|
|
5
|
+
/**
|
|
6
|
+
* This VersioningStrategy always bumps the major version.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AlwaysBumpMajor extends DefaultVersioningStrategy {
|
|
9
|
+
determineReleaseType(_version: Version, _commits: ConventionalCommit[]): VersionUpdater;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2022 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.AlwaysBumpMajor = void 0;
|
|
17
|
+
const default_1 = require("./default");
|
|
18
|
+
const versioning_strategy_1 = require("../versioning-strategy");
|
|
19
|
+
/**
|
|
20
|
+
* This VersioningStrategy always bumps the major version.
|
|
21
|
+
*/
|
|
22
|
+
class AlwaysBumpMajor extends default_1.DefaultVersioningStrategy {
|
|
23
|
+
determineReleaseType(_version, _commits) {
|
|
24
|
+
return new versioning_strategy_1.MajorVersionUpdate();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.AlwaysBumpMajor = AlwaysBumpMajor;
|
|
28
|
+
//# sourceMappingURL=always-bump-major.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Version } from '../version';
|
|
2
|
+
import { ConventionalCommit } from '../commit';
|
|
3
|
+
import { DefaultVersioningStrategy } from './default';
|
|
4
|
+
import { VersionUpdater } from '../versioning-strategy';
|
|
5
|
+
/**
|
|
6
|
+
* This VersioningStrategy always bumps the minor version.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AlwaysBumpMinor extends DefaultVersioningStrategy {
|
|
9
|
+
determineReleaseType(_version: Version, _commits: ConventionalCommit[]): VersionUpdater;
|
|
10
|
+
}
|