@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
|
@@ -0,0 +1,137 @@
|
|
|
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.LinkedVersions = void 0;
|
|
17
|
+
const plugin_1 = require("../plugin");
|
|
18
|
+
const commit_1 = require("../commit");
|
|
19
|
+
const factory_1 = require("../factory");
|
|
20
|
+
const merge_1 = require("./merge");
|
|
21
|
+
const branch_name_1 = require("../util/branch-name");
|
|
22
|
+
/**
|
|
23
|
+
* This plugin reconfigures strategies by linking multiple components
|
|
24
|
+
* together.
|
|
25
|
+
*
|
|
26
|
+
* Release notes are broken up using `<summary>`/`<details>` blocks.
|
|
27
|
+
*/
|
|
28
|
+
class LinkedVersions extends plugin_1.ManifestPlugin {
|
|
29
|
+
constructor(github, targetBranch, repositoryConfig, groupName, components, options = {}) {
|
|
30
|
+
var _a;
|
|
31
|
+
super(github, targetBranch, repositoryConfig, options.logger);
|
|
32
|
+
this.groupName = groupName;
|
|
33
|
+
this.components = new Set(components);
|
|
34
|
+
this.merge = (_a = options.merge) !== null && _a !== void 0 ? _a : true;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Pre-configure strategies.
|
|
38
|
+
* @param {Record<string, Strategy>} strategiesByPath Strategies indexed by path
|
|
39
|
+
* @returns {Record<string, Strategy>} Updated strategies indexed by path
|
|
40
|
+
*/
|
|
41
|
+
async preconfigure(strategiesByPath, commitsByPath, releasesByPath) {
|
|
42
|
+
// Find all strategies in the group
|
|
43
|
+
const groupStrategies = {};
|
|
44
|
+
for (const path in strategiesByPath) {
|
|
45
|
+
const strategy = strategiesByPath[path];
|
|
46
|
+
const component = await strategy.getComponent();
|
|
47
|
+
if (!component) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (this.components.has(component)) {
|
|
51
|
+
groupStrategies[path] = strategy;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
this.logger.info(`Found ${Object.keys(groupStrategies).length} group components for ${this.groupName}`);
|
|
55
|
+
const groupVersions = {};
|
|
56
|
+
const missingReleasePaths = new Set();
|
|
57
|
+
for (const path in groupStrategies) {
|
|
58
|
+
const strategy = groupStrategies[path];
|
|
59
|
+
const latestRelease = releasesByPath[path];
|
|
60
|
+
const releasePullRequest = await strategy.buildReleasePullRequest((0, commit_1.parseConventionalCommits)(commitsByPath[path], this.logger), latestRelease);
|
|
61
|
+
if (releasePullRequest === null || releasePullRequest === void 0 ? void 0 : releasePullRequest.version) {
|
|
62
|
+
groupVersions[path] = releasePullRequest.version;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
missingReleasePaths.add(path);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const versions = Object.values(groupVersions);
|
|
69
|
+
if (versions.length === 0) {
|
|
70
|
+
return strategiesByPath;
|
|
71
|
+
}
|
|
72
|
+
const primaryVersion = versions.reduce((collector, version) => collector.compare(version) > 0 ? collector : version, versions[0]);
|
|
73
|
+
const newStrategies = {};
|
|
74
|
+
for (const path in strategiesByPath) {
|
|
75
|
+
if (path in groupStrategies) {
|
|
76
|
+
const component = await strategiesByPath[path].getComponent();
|
|
77
|
+
this.logger.info(`Replacing strategy for path ${path} with forced version: ${primaryVersion}`);
|
|
78
|
+
newStrategies[path] = await (0, factory_1.buildStrategy)({
|
|
79
|
+
...this.repositoryConfig[path],
|
|
80
|
+
github: this.github,
|
|
81
|
+
path,
|
|
82
|
+
targetBranch: this.targetBranch,
|
|
83
|
+
releaseAs: primaryVersion.toString(),
|
|
84
|
+
});
|
|
85
|
+
if (missingReleasePaths.has(path)) {
|
|
86
|
+
this.logger.debug(`Appending fake commit for path: ${path}`);
|
|
87
|
+
commitsByPath[path].push({
|
|
88
|
+
sha: '',
|
|
89
|
+
message: `chore(${component}): Synchronize ${this.groupName} versions\n\nRelease-As: ${primaryVersion.toString()}`,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
newStrategies[path] = strategiesByPath[path];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return newStrategies;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Post-process candidate pull requests.
|
|
101
|
+
* @param {CandidateReleasePullRequest[]} pullRequests Candidate pull requests
|
|
102
|
+
* @returns {CandidateReleasePullRequest[]} Updated pull requests
|
|
103
|
+
*/
|
|
104
|
+
async run(candidates) {
|
|
105
|
+
if (!this.merge) {
|
|
106
|
+
return candidates;
|
|
107
|
+
}
|
|
108
|
+
const [inScopeCandidates, outOfScopeCandidates] = candidates.reduce((collection, candidate) => {
|
|
109
|
+
if (!candidate.pullRequest.version) {
|
|
110
|
+
this.logger.warn('pull request missing version', candidate);
|
|
111
|
+
collection[1].push(candidate);
|
|
112
|
+
return collection;
|
|
113
|
+
}
|
|
114
|
+
if (this.components.has(candidate.config.component || '')) {
|
|
115
|
+
collection[0].push(candidate);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
collection[1].push(candidate);
|
|
119
|
+
}
|
|
120
|
+
return collection;
|
|
121
|
+
}, [[], []]);
|
|
122
|
+
this.logger.info(`found ${inScopeCandidates.length} linked-versions candidates`);
|
|
123
|
+
// delegate to the merge plugin and add merged pull request
|
|
124
|
+
if (inScopeCandidates.length > 0) {
|
|
125
|
+
const merge = new merge_1.Merge(this.github, this.targetBranch, this.repositoryConfig, {
|
|
126
|
+
pullRequestTitlePattern: 'chore${scope}: release ' + this.groupName + ' libraries',
|
|
127
|
+
forceMerge: true,
|
|
128
|
+
headBranchName: branch_name_1.BranchName.ofGroupTargetBranch(this.groupName, this.targetBranch).toString(),
|
|
129
|
+
});
|
|
130
|
+
const merged = await merge.run(inScopeCandidates);
|
|
131
|
+
outOfScopeCandidates.push(...merged);
|
|
132
|
+
}
|
|
133
|
+
return outOfScopeCandidates;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.LinkedVersions = LinkedVersions;
|
|
137
|
+
//# sourceMappingURL=linked-versions.js.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { WorkspacePlugin, AllPackages, DependencyGraph, WorkspacePluginOptions } from './workspace';
|
|
2
|
+
import { Version, VersionsMap } from '../version';
|
|
3
|
+
import { CandidateReleasePullRequest, RepositoryConfig } from '../manifest';
|
|
4
|
+
import { Scm } from '../scm';
|
|
5
|
+
interface Gav {
|
|
6
|
+
groupId: string;
|
|
7
|
+
artifactId: string;
|
|
8
|
+
version: string;
|
|
9
|
+
}
|
|
10
|
+
interface MavenArtifact extends Gav {
|
|
11
|
+
path: string;
|
|
12
|
+
name: string;
|
|
13
|
+
dependencies: Gav[];
|
|
14
|
+
testDependencies: Gav[];
|
|
15
|
+
managedDependencies: Gav[];
|
|
16
|
+
pomContent: string;
|
|
17
|
+
}
|
|
18
|
+
interface MavenWorkspacePluginOptions extends WorkspacePluginOptions {
|
|
19
|
+
considerAllArtifacts?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare class MavenWorkspace extends WorkspacePlugin<MavenArtifact> {
|
|
22
|
+
readonly considerAllArtifacts: boolean;
|
|
23
|
+
constructor(github: Scm, targetBranch: string, repositoryConfig: RepositoryConfig, options?: MavenWorkspacePluginOptions);
|
|
24
|
+
private fetchPom;
|
|
25
|
+
protected buildAllPackages(candidates: CandidateReleasePullRequest[]): Promise<AllPackages<MavenArtifact>>;
|
|
26
|
+
/**
|
|
27
|
+
* Our maven components can have multiple artifacts if using
|
|
28
|
+
* `considerAllArtifacts`. Find the candidate release for the component
|
|
29
|
+
* that contains that maven artifact.
|
|
30
|
+
* @param {MavenArtifact} pkg The artifact to search for
|
|
31
|
+
* @param {Record<string, CandidateReleasePullRequest} candidatesByPackage
|
|
32
|
+
* The candidate pull requests indexed by the package name.
|
|
33
|
+
* @returns {CandidateReleasePullRequest | undefined} The associated
|
|
34
|
+
* candidate release or undefined if there is no existing release yet
|
|
35
|
+
*/
|
|
36
|
+
protected findCandidateForPackage(pkg: MavenArtifact, candidatesByPackage: Record<string, CandidateReleasePullRequest>): CandidateReleasePullRequest | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Helper to determine which packages we will use to base our search
|
|
39
|
+
* for touched packages upon. These are usually the packages that
|
|
40
|
+
* have candidate pull requests open.
|
|
41
|
+
*
|
|
42
|
+
* If you configure `updateAllPackages`, we fill force update all
|
|
43
|
+
* packages as if they had a release.
|
|
44
|
+
* @param {DependencyGraph<T>} graph All the packages in the repository
|
|
45
|
+
* @param {Record<string, CandidateReleasePullRequest} candidatesByPackage
|
|
46
|
+
* The candidate pull requests indexed by the package name.
|
|
47
|
+
* @returns {string[]} Package names to
|
|
48
|
+
*/
|
|
49
|
+
protected packageNamesToUpdate(graph: DependencyGraph<MavenArtifact>, candidatesByPackage: Record<string, CandidateReleasePullRequest>): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Helper to build up all the versions we are modifying in this
|
|
52
|
+
* repository.
|
|
53
|
+
* @param {DependencyGraph<T>} graph All the packages in the repository
|
|
54
|
+
* @param {T[]} orderedPackages A list of packages that are currently
|
|
55
|
+
* updated by the existing candidate pull requests
|
|
56
|
+
* @param {Record<string, CandidateReleasePullRequest} candidatesByPackage
|
|
57
|
+
* The candidate pull requests indexed by the package name.
|
|
58
|
+
* @returns A map of all updated versions (package name => Version) and a
|
|
59
|
+
* map of all updated versions (component path => Version).
|
|
60
|
+
*/
|
|
61
|
+
protected buildUpdatedVersions(_graph: DependencyGraph<MavenArtifact>, orderedPackages: MavenArtifact[], candidatesByPackage: Record<string, CandidateReleasePullRequest>): Promise<{
|
|
62
|
+
updatedVersions: VersionsMap;
|
|
63
|
+
updatedPathVersions: VersionsMap;
|
|
64
|
+
}>;
|
|
65
|
+
protected buildGraph(allPackages: MavenArtifact[]): Promise<DependencyGraph<MavenArtifact>>;
|
|
66
|
+
/**
|
|
67
|
+
* Given a release version, determine if we should bump the manifest
|
|
68
|
+
* version as well. For maven artifacts, SNAPSHOT versions are not
|
|
69
|
+
* considered releases.
|
|
70
|
+
* @param {Version} version The release version
|
|
71
|
+
*/
|
|
72
|
+
protected isReleaseVersion(version: Version): boolean;
|
|
73
|
+
protected bumpVersion(artifact: MavenArtifact): Version;
|
|
74
|
+
protected updateCandidate(existingCandidate: CandidateReleasePullRequest, artifact: MavenArtifact, updatedVersions: VersionsMap): CandidateReleasePullRequest;
|
|
75
|
+
protected newCandidate(artifact: MavenArtifact, updatedVersions: VersionsMap): Promise<CandidateReleasePullRequest>;
|
|
76
|
+
protected inScope(candidate: CandidateReleasePullRequest): boolean;
|
|
77
|
+
protected packageNameFromPackage(artifact: MavenArtifact): string;
|
|
78
|
+
protected pathFromPackage(artifact: MavenArtifact): string;
|
|
79
|
+
protected postProcessCandidates(candidates: CandidateReleasePullRequest[], _updatedVersions: VersionsMap): CandidateReleasePullRequest[];
|
|
80
|
+
}
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,431 @@
|
|
|
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.MavenWorkspace = void 0;
|
|
17
|
+
const workspace_1 = require("./workspace");
|
|
18
|
+
const version_1 = require("../version");
|
|
19
|
+
const dom = require("@xmldom/xmldom");
|
|
20
|
+
const xpath = require("xpath");
|
|
21
|
+
const path_1 = require("path");
|
|
22
|
+
const pom_xml_1 = require("../updaters/java/pom-xml");
|
|
23
|
+
const changelog_1 = require("../updaters/changelog");
|
|
24
|
+
const pull_request_title_1 = require("../util/pull-request-title");
|
|
25
|
+
const pull_request_body_1 = require("../util/pull-request-body");
|
|
26
|
+
const branch_name_1 = require("../util/branch-name");
|
|
27
|
+
const logger_1 = require("../util/logger");
|
|
28
|
+
const java_snapshot_1 = require("../versioning-strategies/java-snapshot");
|
|
29
|
+
const always_bump_patch_1 = require("../versioning-strategies/always-bump-patch");
|
|
30
|
+
const composite_1 = require("../updaters/composite");
|
|
31
|
+
const JAVA_RELEASE_TYPES = new Set([
|
|
32
|
+
'java',
|
|
33
|
+
'java-bom',
|
|
34
|
+
'java-yoshi',
|
|
35
|
+
'java-yoshi-mono-repo',
|
|
36
|
+
'maven',
|
|
37
|
+
]);
|
|
38
|
+
const XPATH_PROJECT_GROUP = '/*[local-name()="project"]/*[local-name()="groupId"]';
|
|
39
|
+
const XPATH_PROJECT_ARTIFACT = '/*[local-name()="project"]/*[local-name()="artifactId"]';
|
|
40
|
+
const XPATH_PROJECT_VERSION = '/*[local-name()="project"]/*[local-name()="version"]';
|
|
41
|
+
const XPATH_PROJECT_DEPENDENCIES = '/*[local-name()="project"]/*[local-name()="dependencies"]/*[local-name()="dependency"]';
|
|
42
|
+
const XPATH_PROJECT_DEPENDENCY_MANAGEMENT_DEPENDENCIES = '/*[local-name()="project"]/*[local-name()="dependencyManagement"]/*[local-name()="dependencies"]/*[local-name()="dependency"]';
|
|
43
|
+
class MavenWorkspace extends workspace_1.WorkspacePlugin {
|
|
44
|
+
constructor(github, targetBranch, repositoryConfig, options = {}) {
|
|
45
|
+
var _a;
|
|
46
|
+
super(github, targetBranch, repositoryConfig, options);
|
|
47
|
+
this.considerAllArtifacts = (_a = options.considerAllArtifacts) !== null && _a !== void 0 ? _a : true;
|
|
48
|
+
}
|
|
49
|
+
async fetchPom(path) {
|
|
50
|
+
const content = await this.github.getFileContentsOnBranch(path, this.targetBranch);
|
|
51
|
+
return parseMavenArtifact(content.parsedContent, path, this.logger);
|
|
52
|
+
}
|
|
53
|
+
async buildAllPackages(candidates) {
|
|
54
|
+
const allPackages = [];
|
|
55
|
+
const candidatesByPackage = {};
|
|
56
|
+
// find all pom.xml files and build a dependency graph
|
|
57
|
+
const pomFiles = await this.github.findFilesByFilenameAndRef('pom.xml', this.targetBranch);
|
|
58
|
+
for (const pomFile of pomFiles) {
|
|
59
|
+
const path = (0, path_1.dirname)(pomFile);
|
|
60
|
+
const config = this.repositoryConfig[path];
|
|
61
|
+
if (!config) {
|
|
62
|
+
if (!this.considerAllArtifacts) {
|
|
63
|
+
this.logger.info(`path '${path}' not configured, ignoring '${pomFile}'`);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
this.logger.info(`path '${path}' not configured, but 'considerAllArtifacts' option enabled`);
|
|
67
|
+
}
|
|
68
|
+
const mavenArtifact = await this.fetchPom(pomFile);
|
|
69
|
+
if (!mavenArtifact) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
allPackages.push(mavenArtifact);
|
|
73
|
+
const candidate = candidates.find(candidate => candidate.path === path);
|
|
74
|
+
if (candidate) {
|
|
75
|
+
candidatesByPackage[this.packageNameFromPackage(mavenArtifact)] =
|
|
76
|
+
candidate;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.logger.warn(`found ${pomFile} in path ${path}, but did not find an associated candidate PR`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
allPackages,
|
|
84
|
+
candidatesByPackage,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Our maven components can have multiple artifacts if using
|
|
89
|
+
* `considerAllArtifacts`. Find the candidate release for the component
|
|
90
|
+
* that contains that maven artifact.
|
|
91
|
+
* @param {MavenArtifact} pkg The artifact to search for
|
|
92
|
+
* @param {Record<string, CandidateReleasePullRequest} candidatesByPackage
|
|
93
|
+
* The candidate pull requests indexed by the package name.
|
|
94
|
+
* @returns {CandidateReleasePullRequest | undefined} The associated
|
|
95
|
+
* candidate release or undefined if there is no existing release yet
|
|
96
|
+
*/
|
|
97
|
+
findCandidateForPackage(pkg, candidatesByPackage) {
|
|
98
|
+
this.logger.debug(`Looking for existing candidate for ${pkg.name}`);
|
|
99
|
+
const packageName = this.packageNameFromPackage(pkg);
|
|
100
|
+
const existingCandidate = candidatesByPackage[packageName];
|
|
101
|
+
if (existingCandidate) {
|
|
102
|
+
return existingCandidate;
|
|
103
|
+
}
|
|
104
|
+
// fall back to finding the nearest candidate for that artifact
|
|
105
|
+
return Object.values(candidatesByPackage).find(candidate => pkg.path.startsWith(`${candidate.path}/`));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Helper to determine which packages we will use to base our search
|
|
109
|
+
* for touched packages upon. These are usually the packages that
|
|
110
|
+
* have candidate pull requests open.
|
|
111
|
+
*
|
|
112
|
+
* If you configure `updateAllPackages`, we fill force update all
|
|
113
|
+
* packages as if they had a release.
|
|
114
|
+
* @param {DependencyGraph<T>} graph All the packages in the repository
|
|
115
|
+
* @param {Record<string, CandidateReleasePullRequest} candidatesByPackage
|
|
116
|
+
* The candidate pull requests indexed by the package name.
|
|
117
|
+
* @returns {string[]} Package names to
|
|
118
|
+
*/
|
|
119
|
+
packageNamesToUpdate(graph, candidatesByPackage) {
|
|
120
|
+
if (this.considerAllArtifacts) {
|
|
121
|
+
const candidatePaths = Object.values(candidatesByPackage).map(candidate => candidate.path);
|
|
122
|
+
// Find artifacts that are in an existing candidate release
|
|
123
|
+
return Array.from(graph.values())
|
|
124
|
+
.filter(({ value }) => candidatePaths.find(path => value.path === path || value.path.startsWith(`${path}/`)))
|
|
125
|
+
.map(({ value }) => this.packageNameFromPackage(value));
|
|
126
|
+
}
|
|
127
|
+
return super.packageNamesToUpdate(graph, candidatesByPackage);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Helper to build up all the versions we are modifying in this
|
|
131
|
+
* repository.
|
|
132
|
+
* @param {DependencyGraph<T>} graph All the packages in the repository
|
|
133
|
+
* @param {T[]} orderedPackages A list of packages that are currently
|
|
134
|
+
* updated by the existing candidate pull requests
|
|
135
|
+
* @param {Record<string, CandidateReleasePullRequest} candidatesByPackage
|
|
136
|
+
* The candidate pull requests indexed by the package name.
|
|
137
|
+
* @returns A map of all updated versions (package name => Version) and a
|
|
138
|
+
* map of all updated versions (component path => Version).
|
|
139
|
+
*/
|
|
140
|
+
async buildUpdatedVersions(_graph, orderedPackages, candidatesByPackage) {
|
|
141
|
+
const updatedVersions = new Map();
|
|
142
|
+
const updatedPathVersions = new Map();
|
|
143
|
+
// Look for updated pom.xml files
|
|
144
|
+
for (const [_, candidate] of Object.entries(candidatesByPackage)) {
|
|
145
|
+
const pomUpdates = candidate.pullRequest.updates.filter(update => update.path.endsWith('pom.xml'));
|
|
146
|
+
for (const pomUpdate of pomUpdates) {
|
|
147
|
+
if (!pomUpdate.cachedFileContents) {
|
|
148
|
+
pomUpdate.cachedFileContents =
|
|
149
|
+
await this.github.getFileContentsOnBranch(pomUpdate.path, this.targetBranch);
|
|
150
|
+
}
|
|
151
|
+
if (pomUpdate.cachedFileContents) {
|
|
152
|
+
// pre-run the version updater on this artifact and extract the
|
|
153
|
+
// new version
|
|
154
|
+
const updatedArtifact = parseMavenArtifact(pomUpdate.updater.updateContent(pomUpdate.cachedFileContents.parsedContent), pomUpdate.path, this.logger);
|
|
155
|
+
if (updatedArtifact) {
|
|
156
|
+
this.logger.debug(`updating ${updatedArtifact.name} to ${updatedArtifact.version}`);
|
|
157
|
+
updatedVersions.set(updatedArtifact.name, version_1.Version.parse(updatedArtifact.version));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.logger.warn(`${pomUpdate.path} does not have cached contents`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (candidate.pullRequest.version &&
|
|
165
|
+
this.isReleaseVersion(candidate.pullRequest.version)) {
|
|
166
|
+
updatedPathVersions.set(candidate.path, candidate.pullRequest.version);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
for (const pkg of orderedPackages) {
|
|
170
|
+
const packageName = this.packageNameFromPackage(pkg);
|
|
171
|
+
this.logger.debug(`Looking for next version for: ${packageName}`);
|
|
172
|
+
const existingCandidate = candidatesByPackage[packageName];
|
|
173
|
+
if (existingCandidate) {
|
|
174
|
+
const version = existingCandidate.pullRequest.version;
|
|
175
|
+
this.logger.debug(`version: ${version} from release-please`);
|
|
176
|
+
updatedVersions.set(packageName, version);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
const version = this.bumpVersion(pkg);
|
|
180
|
+
if (updatedVersions.get(packageName)) {
|
|
181
|
+
this.logger.debug('version already set');
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
this.logger.debug(`version: ${version} forced bump`);
|
|
185
|
+
updatedVersions.set(packageName, version);
|
|
186
|
+
if (this.isReleaseVersion(version)) {
|
|
187
|
+
updatedPathVersions.set(this.pathFromPackage(pkg), version);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
updatedVersions,
|
|
194
|
+
updatedPathVersions,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
async buildGraph(allPackages) {
|
|
198
|
+
this.logger.trace('building graph', allPackages);
|
|
199
|
+
const artifactsByName = allPackages.reduce((collection, mavenArtifact) => {
|
|
200
|
+
collection[mavenArtifact.name] = mavenArtifact;
|
|
201
|
+
return collection;
|
|
202
|
+
}, {});
|
|
203
|
+
this.logger.trace('artifacts by name', artifactsByName);
|
|
204
|
+
const graph = new Map();
|
|
205
|
+
for (const mavenArtifact of allPackages) {
|
|
206
|
+
const allDeps = [
|
|
207
|
+
...mavenArtifact.dependencies,
|
|
208
|
+
...mavenArtifact.testDependencies,
|
|
209
|
+
...mavenArtifact.managedDependencies,
|
|
210
|
+
];
|
|
211
|
+
const workspaceDeps = allDeps.filter(dep => artifactsByName[packageNameFromGav(dep)]);
|
|
212
|
+
graph.set(mavenArtifact.name, {
|
|
213
|
+
deps: workspaceDeps.map(dep => packageNameFromGav(dep)),
|
|
214
|
+
value: mavenArtifact,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return graph;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Given a release version, determine if we should bump the manifest
|
|
221
|
+
* version as well. For maven artifacts, SNAPSHOT versions are not
|
|
222
|
+
* considered releases.
|
|
223
|
+
* @param {Version} version The release version
|
|
224
|
+
*/
|
|
225
|
+
isReleaseVersion(version) {
|
|
226
|
+
var _a;
|
|
227
|
+
return !((_a = version.preRelease) === null || _a === void 0 ? void 0 : _a.includes('SNAPSHOT'));
|
|
228
|
+
}
|
|
229
|
+
bumpVersion(artifact) {
|
|
230
|
+
const strategy = new java_snapshot_1.JavaSnapshot(new always_bump_patch_1.AlwaysBumpPatch());
|
|
231
|
+
return strategy.bump(version_1.Version.parse(artifact.version), [FAKE_COMMIT]);
|
|
232
|
+
}
|
|
233
|
+
updateCandidate(existingCandidate, artifact, updatedVersions) {
|
|
234
|
+
const version = updatedVersions.get(artifact.name);
|
|
235
|
+
if (!version) {
|
|
236
|
+
throw new Error(`Didn't find updated version for ${artifact.name}`);
|
|
237
|
+
}
|
|
238
|
+
const updater = new pom_xml_1.PomXml(version, updatedVersions);
|
|
239
|
+
const dependencyNotes = getChangelogDepsNotes(artifact, updater, updatedVersions, this.logger);
|
|
240
|
+
existingCandidate.pullRequest.updates =
|
|
241
|
+
existingCandidate.pullRequest.updates.map(update => {
|
|
242
|
+
if (update.path === (0, workspace_1.addPath)(existingCandidate.path, 'pom.xml')) {
|
|
243
|
+
update.updater = new composite_1.CompositeUpdater(update.updater, updater);
|
|
244
|
+
}
|
|
245
|
+
else if (update.updater instanceof changelog_1.Changelog) {
|
|
246
|
+
if (dependencyNotes) {
|
|
247
|
+
update.updater.changelogEntry =
|
|
248
|
+
(0, workspace_1.appendDependenciesSectionToChangelog)(update.updater.changelogEntry, dependencyNotes, this.logger);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return update;
|
|
252
|
+
});
|
|
253
|
+
// append dependency notes
|
|
254
|
+
if (dependencyNotes) {
|
|
255
|
+
if (existingCandidate.pullRequest.body.releaseData.length > 0) {
|
|
256
|
+
existingCandidate.pullRequest.body.releaseData[0].notes =
|
|
257
|
+
(0, workspace_1.appendDependenciesSectionToChangelog)(existingCandidate.pullRequest.body.releaseData[0].notes, dependencyNotes, this.logger);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
existingCandidate.pullRequest.body.releaseData.push({
|
|
261
|
+
component: artifact.name,
|
|
262
|
+
version: existingCandidate.pullRequest.version,
|
|
263
|
+
notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes, this.logger),
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return existingCandidate;
|
|
268
|
+
}
|
|
269
|
+
async newCandidate(artifact, updatedVersions) {
|
|
270
|
+
const version = updatedVersions.get(artifact.name);
|
|
271
|
+
if (!version) {
|
|
272
|
+
throw new Error(`Didn't find updated version for ${artifact.name}`);
|
|
273
|
+
}
|
|
274
|
+
const updater = new pom_xml_1.PomXml(version, updatedVersions);
|
|
275
|
+
const dependencyNotes = getChangelogDepsNotes(artifact, updater, updatedVersions, this.logger);
|
|
276
|
+
const pullRequest = {
|
|
277
|
+
title: pull_request_title_1.PullRequestTitle.ofTargetBranch(this.targetBranch),
|
|
278
|
+
body: new pull_request_body_1.PullRequestBody([
|
|
279
|
+
{
|
|
280
|
+
component: artifact.name,
|
|
281
|
+
version,
|
|
282
|
+
notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes, this.logger),
|
|
283
|
+
},
|
|
284
|
+
]),
|
|
285
|
+
updates: [
|
|
286
|
+
{
|
|
287
|
+
path: (0, workspace_1.addPath)(artifact.path, 'pom.xml'),
|
|
288
|
+
createIfMissing: false,
|
|
289
|
+
updater,
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
path: (0, workspace_1.addPath)(artifact.path, 'CHANGELOG.md'),
|
|
293
|
+
createIfMissing: false,
|
|
294
|
+
updater: new changelog_1.Changelog({
|
|
295
|
+
version,
|
|
296
|
+
changelogEntry: dependencyNotes,
|
|
297
|
+
}),
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
labels: [],
|
|
301
|
+
headRefName: branch_name_1.BranchName.ofTargetBranch(this.targetBranch).toString(),
|
|
302
|
+
version,
|
|
303
|
+
draft: false,
|
|
304
|
+
};
|
|
305
|
+
return {
|
|
306
|
+
path: artifact.path,
|
|
307
|
+
pullRequest,
|
|
308
|
+
config: {
|
|
309
|
+
releaseType: 'maven',
|
|
310
|
+
},
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
inScope(candidate) {
|
|
314
|
+
return JAVA_RELEASE_TYPES.has(candidate.config.releaseType);
|
|
315
|
+
}
|
|
316
|
+
packageNameFromPackage(artifact) {
|
|
317
|
+
return artifact.name;
|
|
318
|
+
}
|
|
319
|
+
pathFromPackage(artifact) {
|
|
320
|
+
return artifact.path;
|
|
321
|
+
}
|
|
322
|
+
postProcessCandidates(candidates, _updatedVersions) {
|
|
323
|
+
// NOP for maven workspaces
|
|
324
|
+
return candidates;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
exports.MavenWorkspace = MavenWorkspace;
|
|
328
|
+
function packageNameFromGav(gav) {
|
|
329
|
+
return `${gav.groupId}:${gav.artifactId}`;
|
|
330
|
+
}
|
|
331
|
+
function getChangelogDepsNotes(artifact, updater, updatedVersions, logger = logger_1.logger) {
|
|
332
|
+
const document = new dom.DOMParser().parseFromString(artifact.pomContent);
|
|
333
|
+
const dependencyUpdates = updater.dependencyUpdates(document, updatedVersions);
|
|
334
|
+
const depUpdateNotes = [];
|
|
335
|
+
for (const dependencyUpdate of dependencyUpdates) {
|
|
336
|
+
depUpdateNotes.push(`\n * ${dependencyUpdate.name} bumped to ${dependencyUpdate.version}`);
|
|
337
|
+
logger.info(`bumped ${dependencyUpdate.name} to ${dependencyUpdate.version}`);
|
|
338
|
+
}
|
|
339
|
+
if (depUpdateNotes.length > 0) {
|
|
340
|
+
return `* The following workspace dependencies were updated${depUpdateNotes.join()}`;
|
|
341
|
+
}
|
|
342
|
+
return '';
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Helper to parse a pom.xml file and extract important fields
|
|
346
|
+
* @param {string} pomContent The XML contents as a string
|
|
347
|
+
* @param {string} path The path to the file in the repository including the filename.
|
|
348
|
+
* @param {Logger} logger Context logger
|
|
349
|
+
* @returns {MavenArtifact | undefined} Returns undefined if we are missing key
|
|
350
|
+
* attributes. We log a warning in these cases.
|
|
351
|
+
*/
|
|
352
|
+
function parseMavenArtifact(pomContent, path, logger) {
|
|
353
|
+
const document = new dom.DOMParser().parseFromString(pomContent);
|
|
354
|
+
const groupNodes = xpath.select(XPATH_PROJECT_GROUP, document);
|
|
355
|
+
if (groupNodes.length === 0) {
|
|
356
|
+
logger.warn(`Missing project.groupId in ${path}`);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const artifactNodes = xpath.select(XPATH_PROJECT_ARTIFACT, document);
|
|
360
|
+
if (artifactNodes.length === 0) {
|
|
361
|
+
logger.warn(`Missing project.artifactId in ${path}`);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const versionNodes = xpath.select(XPATH_PROJECT_VERSION, document);
|
|
365
|
+
if (versionNodes.length === 0) {
|
|
366
|
+
logger.warn(`Missing project.version in ${path}`);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const dependencies = [];
|
|
370
|
+
const testDependencies = [];
|
|
371
|
+
for (const dependencyNode of xpath.select(XPATH_PROJECT_DEPENDENCIES, document)) {
|
|
372
|
+
const parsedNode = (0, pom_xml_1.parseDependencyNode)(dependencyNode);
|
|
373
|
+
if (!parsedNode.version) {
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
if (parsedNode.scope === 'test') {
|
|
377
|
+
testDependencies.push({
|
|
378
|
+
groupId: parsedNode.groupId,
|
|
379
|
+
artifactId: parsedNode.artifactId,
|
|
380
|
+
version: parsedNode.version,
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
dependencies.push({
|
|
385
|
+
groupId: parsedNode.groupId,
|
|
386
|
+
artifactId: parsedNode.artifactId,
|
|
387
|
+
version: parsedNode.version,
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const managedDependencies = [];
|
|
392
|
+
for (const dependencyNode of xpath.select(XPATH_PROJECT_DEPENDENCY_MANAGEMENT_DEPENDENCIES, document)) {
|
|
393
|
+
const parsedNode = (0, pom_xml_1.parseDependencyNode)(dependencyNode);
|
|
394
|
+
if (!parsedNode.version) {
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
managedDependencies.push({
|
|
398
|
+
groupId: parsedNode.groupId,
|
|
399
|
+
artifactId: parsedNode.artifactId,
|
|
400
|
+
version: parsedNode.version,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
const groupId = groupNodes[0].firstChild.textContent;
|
|
404
|
+
const artifactId = artifactNodes[0].firstChild.textContent;
|
|
405
|
+
return {
|
|
406
|
+
path: (0, path_1.dirname)(path),
|
|
407
|
+
groupId,
|
|
408
|
+
artifactId,
|
|
409
|
+
name: `${groupId}:${artifactId}`,
|
|
410
|
+
version: versionNodes[0].firstChild.textContent,
|
|
411
|
+
dependencies,
|
|
412
|
+
testDependencies,
|
|
413
|
+
managedDependencies,
|
|
414
|
+
pomContent,
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
// We use a fake commit to leverage the Java versioning strategy
|
|
418
|
+
// (it should be a patch version bump and potentially remove the
|
|
419
|
+
// -SNAPSHOT portion of the version)
|
|
420
|
+
const FAKE_COMMIT = {
|
|
421
|
+
message: 'fix: fake fix',
|
|
422
|
+
type: 'fix',
|
|
423
|
+
scope: null,
|
|
424
|
+
notes: [],
|
|
425
|
+
references: [],
|
|
426
|
+
bareMessage: 'fake fix',
|
|
427
|
+
breaking: false,
|
|
428
|
+
sha: 'abc123',
|
|
429
|
+
files: [],
|
|
430
|
+
};
|
|
431
|
+
//# sourceMappingURL=maven-workspace.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ManifestPlugin } from '../plugin';
|
|
2
|
+
import { CandidateReleasePullRequest, RepositoryConfig } from '../manifest';
|
|
3
|
+
import { Scm } from '../scm';
|
|
4
|
+
export interface MergeOptions {
|
|
5
|
+
pullRequestTitlePattern?: string;
|
|
6
|
+
pullRequestHeader?: string;
|
|
7
|
+
pullRequestFooter?: string;
|
|
8
|
+
componentNoSpace?: boolean;
|
|
9
|
+
headBranchName?: string;
|
|
10
|
+
forceMerge?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* This plugin merges multiple pull requests into a single
|
|
14
|
+
* release pull request.
|
|
15
|
+
*
|
|
16
|
+
* Release notes are broken up using `<summary>`/`<details>` blocks.
|
|
17
|
+
*/
|
|
18
|
+
export declare class Merge extends ManifestPlugin {
|
|
19
|
+
private pullRequestTitlePattern?;
|
|
20
|
+
private pullRequestHeader?;
|
|
21
|
+
private pullRequestFooter?;
|
|
22
|
+
private componentNoSpace?;
|
|
23
|
+
private headBranchName?;
|
|
24
|
+
private forceMerge;
|
|
25
|
+
constructor(github: Scm, targetBranch: string, repositoryConfig: RepositoryConfig, options?: MergeOptions);
|
|
26
|
+
run(candidates: CandidateReleasePullRequest[]): Promise<CandidateReleasePullRequest[]>;
|
|
27
|
+
}
|