release-please 13.8.1 → 13.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +9 -6
- package/build/src/bin/release-please.d.ts +1 -0
- package/build/src/bin/release-please.js +9 -1
- package/build/src/factory.d.ts +1 -1
- package/build/src/factory.js +22 -1
- package/build/src/github.js +21 -4
- package/build/src/manifest.d.ts +16 -2
- package/build/src/manifest.js +44 -26
- package/build/src/strategies/base.d.ts +3 -3
- package/build/src/strategies/base.js +12 -5
- package/build/src/strategies/java-yoshi.d.ts +4 -14
- package/build/src/strategies/java-yoshi.js +3 -83
- package/build/src/strategies/java.d.ts +28 -0
- package/build/src/strategies/java.js +160 -0
- package/build/src/strategies/maven.d.ts +9 -0
- package/build/src/strategies/maven.js +56 -0
- package/build/src/strategies/rust.js +9 -3
- package/build/src/strategy.d.ts +7 -0
- package/build/src/updaters/base-xml.d.ts +19 -0
- package/build/src/updaters/base-xml.js +39 -0
- package/build/src/updaters/generic-xml.d.ts +5 -10
- package/build/src/updaters/generic-xml.js +11 -20
- package/build/src/updaters/generic.d.ts +16 -4
- package/build/src/updaters/generic.js +13 -6
- 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/pom-xml.d.ts +14 -0
- package/build/src/updaters/java/pom-xml.js +52 -0
- package/package.json +1 -1
|
@@ -16,92 +16,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.JavaYoshi = void 0;
|
|
17
17
|
const versions_manifest_1 = require("../updaters/java/versions-manifest");
|
|
18
18
|
const version_1 = require("../version");
|
|
19
|
-
const java_update_1 = require("../updaters/java/java-update");
|
|
20
|
-
const base_1 = require("./base");
|
|
21
19
|
const changelog_1 = require("../updaters/changelog");
|
|
22
|
-
const java_snapshot_1 = require("../versioning-strategies/java-snapshot");
|
|
23
20
|
const errors_1 = require("../errors");
|
|
24
21
|
const logger_1 = require("../util/logger");
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const default_1 = require("../versioning-strategies/default");
|
|
29
|
-
const java_add_snapshot_1 = require("../versioning-strategies/java-add-snapshot");
|
|
30
|
-
const CHANGELOG_SECTIONS = [
|
|
31
|
-
{ type: 'feat', section: 'Features' },
|
|
32
|
-
{ type: 'fix', section: 'Bug Fixes' },
|
|
33
|
-
{ type: 'perf', section: 'Performance Improvements' },
|
|
34
|
-
{ type: 'deps', section: 'Dependencies' },
|
|
35
|
-
{ type: 'revert', section: 'Reverts' },
|
|
36
|
-
{ type: 'docs', section: 'Documentation' },
|
|
37
|
-
{ type: 'style', section: 'Styles', hidden: true },
|
|
38
|
-
{ type: 'chore', section: 'Miscellaneous Chores', hidden: true },
|
|
39
|
-
{ type: 'refactor', section: 'Code Refactoring', hidden: true },
|
|
40
|
-
{ type: 'test', section: 'Tests', hidden: true },
|
|
41
|
-
{ type: 'build', section: 'Build System', hidden: true },
|
|
42
|
-
{ type: 'ci', section: 'Continuous Integration', hidden: true },
|
|
43
|
-
];
|
|
44
|
-
class JavaYoshi extends base_1.BaseStrategy {
|
|
45
|
-
constructor(options) {
|
|
46
|
-
var _a;
|
|
47
|
-
options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS;
|
|
48
|
-
// wrap the configured versioning strategy with snapshotting
|
|
49
|
-
const parentVersioningStrategy = options.versioningStrategy || new default_1.DefaultVersioningStrategy();
|
|
50
|
-
options.versioningStrategy = new java_snapshot_1.JavaSnapshot(parentVersioningStrategy);
|
|
51
|
-
super(options);
|
|
52
|
-
this.snapshotVersioning = new java_add_snapshot_1.JavaAddSnapshot(parentVersioningStrategy);
|
|
53
|
-
}
|
|
54
|
-
async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
|
|
55
|
-
if (await this.needsSnapshot()) {
|
|
56
|
-
logger_1.logger.info('Repository needs a snapshot bump.');
|
|
57
|
-
return await this.buildSnapshotPullRequest(latestRelease);
|
|
58
|
-
}
|
|
59
|
-
logger_1.logger.info('No Java snapshot needed');
|
|
60
|
-
return await super.buildReleasePullRequest(commits, latestRelease, draft, labels);
|
|
61
|
-
}
|
|
62
|
-
async buildSnapshotPullRequest(latestRelease) {
|
|
63
|
-
const component = await this.getComponent();
|
|
64
|
-
const newVersion = latestRelease
|
|
65
|
-
? await this.snapshotVersioning.bump(latestRelease.tag.version, [])
|
|
66
|
-
: this.initialReleaseVersion();
|
|
67
|
-
const versionsMap = await this.buildVersionsMap();
|
|
68
|
-
for (const versionKey of versionsMap.keys()) {
|
|
69
|
-
const version = versionsMap.get(versionKey);
|
|
70
|
-
if (!version) {
|
|
71
|
-
logger_1.logger.warn(`didn't find version for ${versionKey}`);
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
const newVersion = await this.snapshotVersioning.bump(version, []);
|
|
75
|
-
versionsMap.set(versionKey, newVersion);
|
|
76
|
-
}
|
|
77
|
-
const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion);
|
|
78
|
-
const branchName = component
|
|
79
|
-
? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch)
|
|
80
|
-
: branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
|
|
81
|
-
const notes = '### Updating meta-information for bleeding-edge SNAPSHOT release.';
|
|
82
|
-
const pullRequestBody = new pull_request_body_1.PullRequestBody([
|
|
83
|
-
{
|
|
84
|
-
component,
|
|
85
|
-
version: newVersion,
|
|
86
|
-
notes,
|
|
87
|
-
},
|
|
88
|
-
]);
|
|
89
|
-
const updates = await this.buildUpdates({
|
|
90
|
-
newVersion,
|
|
91
|
-
versionsMap,
|
|
92
|
-
changelogEntry: notes,
|
|
93
|
-
isSnapshot: true,
|
|
94
|
-
});
|
|
95
|
-
return {
|
|
96
|
-
title: pullRequestTitle,
|
|
97
|
-
body: pullRequestBody,
|
|
98
|
-
updates,
|
|
99
|
-
labels: [],
|
|
100
|
-
headRefName: branchName.toString(),
|
|
101
|
-
version: newVersion,
|
|
102
|
-
draft: false,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
22
|
+
const java_1 = require("./java");
|
|
23
|
+
const java_update_1 = require("../updaters/java/java-update");
|
|
24
|
+
class JavaYoshi extends java_1.Java {
|
|
105
25
|
/**
|
|
106
26
|
* Override this method to post process commits
|
|
107
27
|
* @param {ConventionalCommit[]} commits parsed commits
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Update } from '../update';
|
|
2
|
+
import { Version } from '../version';
|
|
3
|
+
import { BaseStrategy, BaseStrategyOptions, BuildUpdatesOptions } from './base';
|
|
4
|
+
import { Commit } from '../commit';
|
|
5
|
+
import { Release } from '../release';
|
|
6
|
+
import { ReleasePullRequest } from '../release-pull-request';
|
|
7
|
+
import { VersioningStrategy } from '../versioning-strategy';
|
|
8
|
+
export interface JavaStrategyOptions extends BaseStrategyOptions {
|
|
9
|
+
snapshotLabels?: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface JavaBuildUpdatesOption extends BuildUpdatesOptions {
|
|
12
|
+
isSnapshot?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A strategy that generates SNAPSHOT version after each release, which is standard especially in Maven projects.
|
|
16
|
+
*
|
|
17
|
+
* This is universal strategy that does not update any files on its own. Use maven strategy for Maven projects.
|
|
18
|
+
*/
|
|
19
|
+
export declare class Java extends BaseStrategy {
|
|
20
|
+
protected readonly snapshotVersioning: VersioningStrategy;
|
|
21
|
+
protected readonly snapshotLabels: string[];
|
|
22
|
+
constructor(options: JavaStrategyOptions);
|
|
23
|
+
buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
|
|
24
|
+
protected buildSnapshotPullRequest(latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest>;
|
|
25
|
+
isPublishedVersion(version: Version): boolean;
|
|
26
|
+
protected needsSnapshot(commits: Commit[], latestRelease?: Release): Promise<boolean>;
|
|
27
|
+
protected buildUpdates(options: JavaBuildUpdatesOption): Promise<Update[]>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
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.Java = void 0;
|
|
17
|
+
const base_1 = require("./base");
|
|
18
|
+
const changelog_1 = require("../updaters/changelog");
|
|
19
|
+
const java_snapshot_1 = require("../versioning-strategies/java-snapshot");
|
|
20
|
+
const logger_1 = require("../util/logger");
|
|
21
|
+
const pull_request_title_1 = require("../util/pull-request-title");
|
|
22
|
+
const branch_name_1 = require("../util/branch-name");
|
|
23
|
+
const pull_request_body_1 = require("../util/pull-request-body");
|
|
24
|
+
const default_1 = require("../versioning-strategies/default");
|
|
25
|
+
const java_add_snapshot_1 = require("../versioning-strategies/java-add-snapshot");
|
|
26
|
+
const manifest_1 = require("../manifest");
|
|
27
|
+
const java_released_1 = require("../updaters/java/java-released");
|
|
28
|
+
const composite_1 = require("../updaters/composite");
|
|
29
|
+
const CHANGELOG_SECTIONS = [
|
|
30
|
+
{ type: 'feat', section: 'Features' },
|
|
31
|
+
{ type: 'fix', section: 'Bug Fixes' },
|
|
32
|
+
{ type: 'perf', section: 'Performance Improvements' },
|
|
33
|
+
{ type: 'deps', section: 'Dependencies' },
|
|
34
|
+
{ type: 'revert', section: 'Reverts' },
|
|
35
|
+
{ type: 'docs', section: 'Documentation' },
|
|
36
|
+
{ type: 'style', section: 'Styles', hidden: true },
|
|
37
|
+
{ type: 'chore', section: 'Miscellaneous Chores', hidden: true },
|
|
38
|
+
{ type: 'refactor', section: 'Code Refactoring', hidden: true },
|
|
39
|
+
{ type: 'test', section: 'Tests', hidden: true },
|
|
40
|
+
{ type: 'build', section: 'Build System', hidden: true },
|
|
41
|
+
{ type: 'ci', section: 'Continuous Integration', hidden: true },
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* A strategy that generates SNAPSHOT version after each release, which is standard especially in Maven projects.
|
|
45
|
+
*
|
|
46
|
+
* This is universal strategy that does not update any files on its own. Use maven strategy for Maven projects.
|
|
47
|
+
*/
|
|
48
|
+
class Java extends base_1.BaseStrategy {
|
|
49
|
+
constructor(options) {
|
|
50
|
+
var _a;
|
|
51
|
+
options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS;
|
|
52
|
+
// wrap the configured versioning strategy with snapshotting
|
|
53
|
+
const parentVersioningStrategy = options.versioningStrategy || new default_1.DefaultVersioningStrategy();
|
|
54
|
+
options.versioningStrategy = new java_snapshot_1.JavaSnapshot(parentVersioningStrategy);
|
|
55
|
+
super(options);
|
|
56
|
+
this.snapshotVersioning = new java_add_snapshot_1.JavaAddSnapshot(parentVersioningStrategy);
|
|
57
|
+
this.snapshotLabels = options.snapshotLabels || manifest_1.DEFAULT_SNAPSHOT_LABELS;
|
|
58
|
+
}
|
|
59
|
+
async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
|
|
60
|
+
if (await this.needsSnapshot(commits, latestRelease)) {
|
|
61
|
+
logger_1.logger.info('Repository needs a snapshot bump.');
|
|
62
|
+
return await this.buildSnapshotPullRequest(latestRelease, draft, this.snapshotLabels);
|
|
63
|
+
}
|
|
64
|
+
logger_1.logger.info('No Java snapshot needed');
|
|
65
|
+
return await super.buildReleasePullRequest(commits, latestRelease, draft, labels);
|
|
66
|
+
}
|
|
67
|
+
async buildSnapshotPullRequest(latestRelease, draft, labels = []) {
|
|
68
|
+
const component = await this.getComponent();
|
|
69
|
+
const newVersion = latestRelease
|
|
70
|
+
? await this.snapshotVersioning.bump(latestRelease.tag.version, [])
|
|
71
|
+
: this.initialReleaseVersion();
|
|
72
|
+
const versionsMap = await this.buildVersionsMap([]);
|
|
73
|
+
const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion);
|
|
74
|
+
const branchName = component
|
|
75
|
+
? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch)
|
|
76
|
+
: branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
|
|
77
|
+
const notes = '### Updating meta-information for bleeding-edge SNAPSHOT release.';
|
|
78
|
+
const pullRequestBody = new pull_request_body_1.PullRequestBody([
|
|
79
|
+
{
|
|
80
|
+
component,
|
|
81
|
+
version: newVersion,
|
|
82
|
+
notes,
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
const updates = await this.buildUpdates({
|
|
86
|
+
newVersion,
|
|
87
|
+
versionsMap,
|
|
88
|
+
changelogEntry: notes,
|
|
89
|
+
isSnapshot: true,
|
|
90
|
+
});
|
|
91
|
+
const updatesWithExtras = composite_1.mergeUpdates(updates.concat(...this.extraFileUpdates(newVersion, versionsMap)));
|
|
92
|
+
return {
|
|
93
|
+
title: pullRequestTitle,
|
|
94
|
+
body: pullRequestBody,
|
|
95
|
+
updates: updatesWithExtras,
|
|
96
|
+
labels: labels,
|
|
97
|
+
headRefName: branchName.toString(),
|
|
98
|
+
version: newVersion,
|
|
99
|
+
draft: draft !== null && draft !== void 0 ? draft : false,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
isPublishedVersion(version) {
|
|
103
|
+
return !version.preRelease || version.preRelease.indexOf('SNAPSHOT') < 0;
|
|
104
|
+
}
|
|
105
|
+
async needsSnapshot(commits, latestRelease) {
|
|
106
|
+
var _a;
|
|
107
|
+
const component = await this.getComponent();
|
|
108
|
+
logger_1.logger.debug('component:', component);
|
|
109
|
+
const version = (_a = latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag) === null || _a === void 0 ? void 0 : _a.version;
|
|
110
|
+
if (!version) {
|
|
111
|
+
// Don't bump snapshots for the first release ever
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
// Found snapshot as a release, this is unexpected, but use it
|
|
115
|
+
if (!this.isPublishedVersion(version)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
// Search commits for snapshot bump
|
|
119
|
+
const pullRequests = commits
|
|
120
|
+
.map(commit => {
|
|
121
|
+
var _a;
|
|
122
|
+
return pull_request_title_1.PullRequestTitle.parse(((_a = commit.pullRequest) === null || _a === void 0 ? void 0 : _a.title) || commit.message, this.pullRequestTitlePattern);
|
|
123
|
+
})
|
|
124
|
+
.filter(pullRequest => pullRequest);
|
|
125
|
+
const snapshotCommits = pullRequests
|
|
126
|
+
.filter(pullRequest => ((pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.component) || '') === component)
|
|
127
|
+
.map(pullRequest => pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.getVersion())
|
|
128
|
+
.filter(version => version && !this.isPublishedVersion(version));
|
|
129
|
+
return snapshotCommits.length === 0;
|
|
130
|
+
}
|
|
131
|
+
async buildUpdates(options) {
|
|
132
|
+
const version = options.newVersion;
|
|
133
|
+
const versionsMap = options.versionsMap;
|
|
134
|
+
const updates = [];
|
|
135
|
+
if (!options.isSnapshot) {
|
|
136
|
+
// Append java-specific updater for extraFiles
|
|
137
|
+
this.extraFiles.forEach(extraFile => {
|
|
138
|
+
if (typeof extraFile === 'string') {
|
|
139
|
+
updates.push({
|
|
140
|
+
path: this.addPath(extraFile),
|
|
141
|
+
createIfMissing: false,
|
|
142
|
+
updater: new java_released_1.JavaReleased({ version, versionsMap }),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
// Update changelog
|
|
147
|
+
updates.push({
|
|
148
|
+
path: this.addPath(this.changelogPath),
|
|
149
|
+
createIfMissing: true,
|
|
150
|
+
updater: new changelog_1.Changelog({
|
|
151
|
+
version,
|
|
152
|
+
changelogEntry: options.changelogEntry,
|
|
153
|
+
}),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return updates;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.Java = Java;
|
|
160
|
+
//# sourceMappingURL=java.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Java, JavaBuildUpdatesOption } from './java';
|
|
2
|
+
import { Update } from '../update';
|
|
3
|
+
/**
|
|
4
|
+
* Strategy for Maven projects. It generates SNAPSHOT version after each release, and updates all found
|
|
5
|
+
* pom.xml files automatically.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Maven extends Java {
|
|
8
|
+
protected buildUpdates(options: JavaBuildUpdatesOption): Promise<Update[]>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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.Maven = void 0;
|
|
17
|
+
const java_1 = require("./java");
|
|
18
|
+
const java_released_1 = require("../updaters/java/java-released");
|
|
19
|
+
const generic_1 = require("../updaters/generic");
|
|
20
|
+
const pom_xml_1 = require("../updaters/java/pom-xml");
|
|
21
|
+
/**
|
|
22
|
+
* Strategy for Maven projects. It generates SNAPSHOT version after each release, and updates all found
|
|
23
|
+
* pom.xml files automatically.
|
|
24
|
+
*/
|
|
25
|
+
class Maven extends java_1.Java {
|
|
26
|
+
async buildUpdates(options) {
|
|
27
|
+
const version = options.newVersion;
|
|
28
|
+
const versionsMap = options.versionsMap;
|
|
29
|
+
// Use generic Java updates
|
|
30
|
+
const updates = await super.buildUpdates(options);
|
|
31
|
+
// Update pom.xml files
|
|
32
|
+
const pomFiles = await this.github.findFilesByFilenameAndRef('pom.xml', this.targetBranch, this.path);
|
|
33
|
+
pomFiles.forEach(path => {
|
|
34
|
+
updates.push({
|
|
35
|
+
path: this.addPath(path),
|
|
36
|
+
createIfMissing: false,
|
|
37
|
+
updater: new pom_xml_1.PomXml(version),
|
|
38
|
+
});
|
|
39
|
+
if (!options.isSnapshot) {
|
|
40
|
+
updates.push({
|
|
41
|
+
path: this.addPath(path),
|
|
42
|
+
createIfMissing: false,
|
|
43
|
+
updater: new java_released_1.JavaReleased({ version, versionsMap }),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
updates.push({
|
|
47
|
+
path: this.addPath(path),
|
|
48
|
+
createIfMissing: false,
|
|
49
|
+
updater: new generic_1.Generic({ version, versionsMap }),
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return updates;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.Maven = Maven;
|
|
56
|
+
//# sourceMappingURL=maven.js.map
|
|
@@ -88,10 +88,16 @@ class Rust extends base_1.BaseStrategy {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
logger_1.logger.info('single crate found, updating Cargo.toml');
|
|
92
|
+
const packageName = await this.getDefaultPackageName();
|
|
93
|
+
if (packageName) {
|
|
94
|
+
versionsMap.set(packageName, version);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
logger_1.logger.warn('No crate package name found');
|
|
98
|
+
}
|
|
93
99
|
updates.push({
|
|
94
|
-
path:
|
|
100
|
+
path: this.addPath('Cargo.toml'),
|
|
95
101
|
createIfMissing: false,
|
|
96
102
|
updater: new cargo_toml_1.CargoToml({
|
|
97
103
|
version,
|
package/build/src/strategy.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { PullRequest } from './pull-request';
|
|
|
4
4
|
import { Commit } from './commit';
|
|
5
5
|
import { VersioningStrategy } from './versioning-strategy';
|
|
6
6
|
import { ChangelogNotes } from './changelog-notes';
|
|
7
|
+
import { Version } from './version';
|
|
7
8
|
/**
|
|
8
9
|
* A strategy is responsible for determining which files are
|
|
9
10
|
* necessary to update in a release pull request.
|
|
@@ -35,4 +36,10 @@ export interface Strategy {
|
|
|
35
36
|
* @returns {string}
|
|
36
37
|
*/
|
|
37
38
|
getComponent(): Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Validate whether version is a valid release.
|
|
41
|
+
* @param version Released version.
|
|
42
|
+
* @returns true of release is valid, false if it should be skipped.
|
|
43
|
+
*/
|
|
44
|
+
isPublishedVersion?(version: Version): boolean;
|
|
38
45
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Updater } from '../update';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for all updaters working with XML files.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class BaseXml implements Updater {
|
|
6
|
+
/**
|
|
7
|
+
* Given initial file contents, return updated contents.
|
|
8
|
+
* @param {string} content The initial content
|
|
9
|
+
* @returns {string} The updated content
|
|
10
|
+
*/
|
|
11
|
+
updateContent(content: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Updates the document in-place if needed.
|
|
14
|
+
* @param document Document to be modified.
|
|
15
|
+
* @return true if document has been changed and therefore file needs to be changed, false otherwise.
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
18
|
+
protected abstract updateDocument(document: Document): boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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.BaseXml = void 0;
|
|
17
|
+
const dom = require("xmldom");
|
|
18
|
+
/**
|
|
19
|
+
* Base class for all updaters working with XML files.
|
|
20
|
+
*/
|
|
21
|
+
class BaseXml {
|
|
22
|
+
/**
|
|
23
|
+
* Given initial file contents, return updated contents.
|
|
24
|
+
* @param {string} content The initial content
|
|
25
|
+
* @returns {string} The updated content
|
|
26
|
+
*/
|
|
27
|
+
updateContent(content) {
|
|
28
|
+
const document = new dom.DOMParser().parseFromString(content);
|
|
29
|
+
const updated = this.updateDocument(document);
|
|
30
|
+
if (updated) {
|
|
31
|
+
return new dom.XMLSerializer().serializeToString(document);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return content;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.BaseXml = BaseXml;
|
|
39
|
+
//# sourceMappingURL=base-xml.js.map
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { Updater } from '../update';
|
|
2
1
|
import { Version } from '../version';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
private
|
|
2
|
+
import { BaseXml } from './base-xml';
|
|
3
|
+
export declare class GenericXml extends BaseXml {
|
|
4
|
+
private readonly xpath;
|
|
5
|
+
private readonly version;
|
|
6
6
|
constructor(xpath: string, version: Version);
|
|
7
|
-
|
|
8
|
-
* Given initial file contents, return updated contents.
|
|
9
|
-
* @param {string} content The initial content
|
|
10
|
-
* @returns {string} The updated content
|
|
11
|
-
*/
|
|
12
|
-
updateContent(content: string): string;
|
|
7
|
+
protected updateDocument(document: Document): boolean;
|
|
13
8
|
}
|
|
@@ -14,33 +14,24 @@
|
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.GenericXml = void 0;
|
|
17
|
+
const base_xml_1 = require("./base-xml");
|
|
17
18
|
const xpath = require("xpath");
|
|
18
|
-
|
|
19
|
-
class GenericXml {
|
|
19
|
+
class GenericXml extends base_xml_1.BaseXml {
|
|
20
20
|
constructor(xpath, version) {
|
|
21
|
+
super();
|
|
21
22
|
this.xpath = xpath;
|
|
22
23
|
this.version = version;
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* @param {string} content The initial content
|
|
27
|
-
* @returns {string} The updated content
|
|
28
|
-
*/
|
|
29
|
-
updateContent(content) {
|
|
30
|
-
const document = new dom.DOMParser().parseFromString(content);
|
|
31
|
-
const iterator = xpath.evaluate(this.xpath, document, null, 0, null);
|
|
32
|
-
let node;
|
|
25
|
+
updateDocument(document) {
|
|
26
|
+
const version = this.version.toString();
|
|
33
27
|
let updated = false;
|
|
34
|
-
|
|
35
|
-
node.textContent
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return new dom.XMLSerializer().serializeToString(document);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
return content;
|
|
28
|
+
for (const node of xpath.select(this.xpath, document)) {
|
|
29
|
+
if (node.textContent !== version) {
|
|
30
|
+
node.textContent = version;
|
|
31
|
+
updated = true;
|
|
32
|
+
}
|
|
43
33
|
}
|
|
34
|
+
return updated;
|
|
44
35
|
}
|
|
45
36
|
}
|
|
46
37
|
exports.GenericXml = GenericXml;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { DefaultUpdater } from './default';
|
|
1
|
+
import { DefaultUpdater, UpdateOptions } from './default';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the Generic updater.
|
|
4
|
+
*/
|
|
5
|
+
export interface GenericUpdateOptions extends UpdateOptions {
|
|
6
|
+
inlineUpdateRegex?: RegExp;
|
|
7
|
+
blockStartRegex?: RegExp;
|
|
8
|
+
blockEndRegex?: RegExp;
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* The Generic updater looks for well known patterns and replaces
|
|
4
12
|
* content. The well known patterns are:
|
|
@@ -7,13 +15,13 @@ import { DefaultUpdater } from './default';
|
|
|
7
15
|
* then replace a semver-looking string on that line with the next
|
|
8
16
|
* version
|
|
9
17
|
* 2. `x-release-please-major` if this string is found on the line,
|
|
10
|
-
* then replace an integer looking value with the
|
|
18
|
+
* then replace an integer looking value with the next version's
|
|
11
19
|
* major
|
|
12
20
|
* 3. `x-release-please-minor` if this string is found on the line,
|
|
13
|
-
* then replace an integer looking value with the
|
|
21
|
+
* then replace an integer looking value with the next version's
|
|
14
22
|
* minor
|
|
15
23
|
* 4. `x-release-please-patch` if this string is found on the line,
|
|
16
|
-
* then replace an integer looking value with the
|
|
24
|
+
* then replace an integer looking value with the next version's
|
|
17
25
|
* patch
|
|
18
26
|
*
|
|
19
27
|
* You can also use a block-based replacement. Content between the
|
|
@@ -23,6 +31,10 @@ import { DefaultUpdater } from './default';
|
|
|
23
31
|
* numbers
|
|
24
32
|
*/
|
|
25
33
|
export declare class Generic extends DefaultUpdater {
|
|
34
|
+
private readonly inlineUpdateRegex;
|
|
35
|
+
private readonly blockStartRegex;
|
|
36
|
+
private readonly blockEndRegex;
|
|
37
|
+
constructor(options: GenericUpdateOptions);
|
|
26
38
|
/**
|
|
27
39
|
* Given initial file contents, return updated contents.
|
|
28
40
|
* @param {string} content The initial content
|
|
@@ -29,13 +29,13 @@ const BLOCK_END_REGEX = /x-release-please-end/;
|
|
|
29
29
|
* then replace a semver-looking string on that line with the next
|
|
30
30
|
* version
|
|
31
31
|
* 2. `x-release-please-major` if this string is found on the line,
|
|
32
|
-
* then replace an integer looking value with the
|
|
32
|
+
* then replace an integer looking value with the next version's
|
|
33
33
|
* major
|
|
34
34
|
* 3. `x-release-please-minor` if this string is found on the line,
|
|
35
|
-
* then replace an integer looking value with the
|
|
35
|
+
* then replace an integer looking value with the next version's
|
|
36
36
|
* minor
|
|
37
37
|
* 4. `x-release-please-patch` if this string is found on the line,
|
|
38
|
-
* then replace an integer looking value with the
|
|
38
|
+
* then replace an integer looking value with the next version's
|
|
39
39
|
* patch
|
|
40
40
|
*
|
|
41
41
|
* You can also use a block-based replacement. Content between the
|
|
@@ -45,6 +45,13 @@ const BLOCK_END_REGEX = /x-release-please-end/;
|
|
|
45
45
|
* numbers
|
|
46
46
|
*/
|
|
47
47
|
class Generic extends default_1.DefaultUpdater {
|
|
48
|
+
constructor(options) {
|
|
49
|
+
var _a, _b, _c;
|
|
50
|
+
super(options);
|
|
51
|
+
this.inlineUpdateRegex = (_a = options.inlineUpdateRegex) !== null && _a !== void 0 ? _a : INLINE_UPDATE_REGEX;
|
|
52
|
+
this.blockStartRegex = (_b = options.blockStartRegex) !== null && _b !== void 0 ? _b : BLOCK_START_REGEX;
|
|
53
|
+
this.blockEndRegex = (_c = options.blockEndRegex) !== null && _c !== void 0 ? _c : BLOCK_END_REGEX;
|
|
54
|
+
}
|
|
48
55
|
/**
|
|
49
56
|
* Given initial file contents, return updated contents.
|
|
50
57
|
* @param {string} content The initial content
|
|
@@ -77,7 +84,7 @@ class Generic extends default_1.DefaultUpdater {
|
|
|
77
84
|
}
|
|
78
85
|
content.split(/\r?\n/).forEach(line => {
|
|
79
86
|
var _a, _b;
|
|
80
|
-
let match = line.match(
|
|
87
|
+
let match = line.match(this.inlineUpdateRegex);
|
|
81
88
|
if (match) {
|
|
82
89
|
// replace inline versions
|
|
83
90
|
replaceVersion(line, (((_a = match.groups) === null || _a === void 0 ? void 0 : _a.scope) || 'version'), this.version);
|
|
@@ -85,13 +92,13 @@ class Generic extends default_1.DefaultUpdater {
|
|
|
85
92
|
else if (blockScope) {
|
|
86
93
|
// in a block, so try to replace versions
|
|
87
94
|
replaceVersion(line, blockScope, this.version);
|
|
88
|
-
if (line.match(
|
|
95
|
+
if (line.match(this.blockEndRegex)) {
|
|
89
96
|
blockScope = undefined;
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
99
|
else {
|
|
93
100
|
// look for block start line
|
|
94
|
-
match = line.match(
|
|
101
|
+
match = line.match(this.blockStartRegex);
|
|
95
102
|
if (match) {
|
|
96
103
|
if ((_b = match.groups) === null || _b === void 0 ? void 0 : _b.scope) {
|
|
97
104
|
blockScope = match.groups.scope;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Generic, GenericUpdateOptions } from '../generic';
|
|
2
|
+
/**
|
|
3
|
+
* The JavaReleased updater is used only when updating to stable (not SNAPSHOT)
|
|
4
|
+
* versions. It looks for well known patterns and replaces content.
|
|
5
|
+
* The well known patterns are:
|
|
6
|
+
*
|
|
7
|
+
* 1. `x-release-please-released-version` if this string is found on the line,
|
|
8
|
+
* then replace a semver-looking string on that line with the next
|
|
9
|
+
* version
|
|
10
|
+
* 2. `x-release-please-released-major` if this string is found on the line,
|
|
11
|
+
* then replace an integer looking value with the next version's
|
|
12
|
+
* major
|
|
13
|
+
* 3. `x-release-please-released-minor` if this string is found on the line,
|
|
14
|
+
* then replace an integer looking value with the next version's
|
|
15
|
+
* minor
|
|
16
|
+
* 4. `x-release-please-released-patch` if this string is found on the line,
|
|
17
|
+
* then replace an integer looking value with the next version's
|
|
18
|
+
* patch
|
|
19
|
+
*
|
|
20
|
+
* You can also use a block-based replacement. Content between the
|
|
21
|
+
* opening `x-release-please-released-start-version` and `x-release-please-released-end` will
|
|
22
|
+
* be considered for version replacement. You can also open these blocks
|
|
23
|
+
* with `x-release-please-released-start-<major|minor|patch>` to replace single
|
|
24
|
+
* numbers
|
|
25
|
+
*/
|
|
26
|
+
export declare class JavaReleased extends Generic {
|
|
27
|
+
constructor(options: GenericUpdateOptions);
|
|
28
|
+
}
|