release-please 16.2.0 → 16.3.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/build/src/factories/versioning-strategy-factory.d.ts +1 -0
- package/build/src/factory.js +1 -0
- package/build/src/github.js +33 -8
- package/build/src/plugins/node-workspace.d.ts +9 -7
- package/build/src/plugins/node-workspace.js +75 -103
- package/build/src/plugins/workspace.js +1 -1
- package/build/src/updaters/node/package-json.d.ts +8 -0
- package/build/src/updaters/node/package-json.js +60 -1
- package/package.json +2 -3
- package/CHANGELOG.md +0 -2800
- package/build/src/updaters/changelog.js.map +0 -1
|
@@ -6,6 +6,7 @@ export interface VersioningStrategyFactoryOptions {
|
|
|
6
6
|
bumpMinorPreMajor?: boolean;
|
|
7
7
|
bumpPatchForMinorPreMajor?: boolean;
|
|
8
8
|
prereleaseType?: string;
|
|
9
|
+
prerelease?: boolean;
|
|
9
10
|
github: GitHub;
|
|
10
11
|
}
|
|
11
12
|
export type VersioningStrategyBuilder = (options: VersioningStrategyFactoryOptions) => VersioningStrategy;
|
package/build/src/factory.js
CHANGED
|
@@ -110,6 +110,7 @@ async function buildStrategy(options) {
|
|
|
110
110
|
bumpMinorPreMajor: options.bumpMinorPreMajor,
|
|
111
111
|
bumpPatchForMinorPreMajor: options.bumpPatchForMinorPreMajor,
|
|
112
112
|
prereleaseType: options.prereleaseType,
|
|
113
|
+
prerelease: options.prerelease,
|
|
113
114
|
});
|
|
114
115
|
const changelogNotes = (0, changelog_notes_factory_1.buildChangelogNotes)({
|
|
115
116
|
type: options.changelogType || 'default',
|
package/build/src/github.js
CHANGED
|
@@ -508,7 +508,8 @@ class GitHub {
|
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
510
|
async mergeCommitsGraphQL(targetBranch, cursor, options = {}) {
|
|
511
|
-
var _a, _b, _c, _d;
|
|
511
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
512
|
+
var _h;
|
|
512
513
|
this.logger.debug(`Fetching merge commits on branch ${targetBranch} with cursor: ${cursor}`);
|
|
513
514
|
const query = `query pullRequestsSince($owner: String!, $repo: String!, $num: Int!, $maxFilesChanged: Int, $targetBranch: String!, $cursor: String) {
|
|
514
515
|
repository(owner: $owner, name: $repo) {
|
|
@@ -579,17 +580,38 @@ class GitHub {
|
|
|
579
580
|
}
|
|
580
581
|
const history = response.repository.ref.target.history;
|
|
581
582
|
const commits = (history.nodes || []);
|
|
583
|
+
// Count the number of pull requests associated with each merge commit. This is
|
|
584
|
+
// used in the next step to make sure we only find pull requests with a
|
|
585
|
+
// merge commit that contain 1 merged commit.
|
|
586
|
+
const mergeCommitCount = {};
|
|
587
|
+
for (const commit of commits) {
|
|
588
|
+
for (const pr of commit.associatedPullRequests.nodes) {
|
|
589
|
+
if ((_b = pr.mergeCommit) === null || _b === void 0 ? void 0 : _b.oid) {
|
|
590
|
+
(_c = mergeCommitCount[_h = pr.mergeCommit.oid]) !== null && _c !== void 0 ? _c : (mergeCommitCount[_h] = 0);
|
|
591
|
+
mergeCommitCount[pr.mergeCommit.oid]++;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
582
595
|
const commitData = [];
|
|
583
596
|
for (const graphCommit of commits) {
|
|
584
597
|
const commit = {
|
|
585
598
|
sha: graphCommit.sha,
|
|
586
599
|
message: graphCommit.message,
|
|
587
600
|
};
|
|
588
|
-
const
|
|
589
|
-
return
|
|
601
|
+
const mergePullRequest = graphCommit.associatedPullRequests.nodes.find(pr => {
|
|
602
|
+
return (
|
|
603
|
+
// Only match the pull request with a merge commit if there is a
|
|
604
|
+
// single merged commit in the PR. This means merge commits and squash
|
|
605
|
+
// merges will be matched, but rebase merged PRs will only be matched
|
|
606
|
+
// if they contain a single commit. This is so PRs that are rebased
|
|
607
|
+
// and merged will have ßSfiles backfilled from each commit instead of
|
|
608
|
+
// the whole PR.
|
|
609
|
+
pr.mergeCommit &&
|
|
610
|
+
pr.mergeCommit.oid === graphCommit.sha &&
|
|
611
|
+
mergeCommitCount[pr.mergeCommit.oid] === 1);
|
|
590
612
|
});
|
|
613
|
+
const pullRequest = mergePullRequest || graphCommit.associatedPullRequests.nodes[0];
|
|
591
614
|
if (pullRequest) {
|
|
592
|
-
const files = (((_b = pullRequest.files) === null || _b === void 0 ? void 0 : _b.nodes) || []).map(node => node.path);
|
|
593
615
|
commit.pullRequest = {
|
|
594
616
|
sha: commit.sha,
|
|
595
617
|
number: pullRequest.number,
|
|
@@ -598,16 +620,19 @@ class GitHub {
|
|
|
598
620
|
title: pullRequest.title,
|
|
599
621
|
body: pullRequest.body,
|
|
600
622
|
labels: pullRequest.labels.nodes.map(node => node.name),
|
|
601
|
-
files,
|
|
623
|
+
files: (((_d = pullRequest.files) === null || _d === void 0 ? void 0 : _d.nodes) || []).map(node => node.path),
|
|
602
624
|
};
|
|
603
|
-
|
|
604
|
-
|
|
625
|
+
}
|
|
626
|
+
if (mergePullRequest) {
|
|
627
|
+
if (((_f = (_e = mergePullRequest.files) === null || _e === void 0 ? void 0 : _e.pageInfo) === null || _f === void 0 ? void 0 : _f.hasNextPage) &&
|
|
628
|
+
options.backfillFiles) {
|
|
629
|
+
this.logger.info(`PR #${mergePullRequest.number} has many files, backfilling`);
|
|
605
630
|
commit.files = await this.getCommitFiles(graphCommit.sha);
|
|
606
631
|
}
|
|
607
632
|
else {
|
|
608
633
|
// We cannot directly fetch files on commits via graphql, only provide file
|
|
609
634
|
// information for commits with associated pull requests
|
|
610
|
-
commit.files = files;
|
|
635
|
+
commit.files = (((_g = mergePullRequest.files) === null || _g === void 0 ? void 0 : _g.nodes) || []).map(node => node.path);
|
|
611
636
|
}
|
|
612
637
|
}
|
|
613
638
|
else if (options.backfillFiles) {
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { Package as LernaPackage, RawManifest as PackageJson } from '@lerna-lite/core';
|
|
2
1
|
import { GitHub } from '../github';
|
|
3
2
|
import { CandidateReleasePullRequest, RepositoryConfig } from '../manifest';
|
|
4
3
|
import { Version, VersionsMap } from '../version';
|
|
5
4
|
import { WorkspacePlugin, DependencyGraph, WorkspacePluginOptions } from './workspace';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
interface Package {
|
|
6
|
+
path: string;
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
dependencies: Record<string, string>;
|
|
10
|
+
devDependencies: Record<string, string>;
|
|
11
|
+
peerDependencies: Record<string, string>;
|
|
12
|
+
optionalDependencies: Record<string, string>;
|
|
13
|
+
jsonContent: string;
|
|
10
14
|
}
|
|
11
15
|
interface NodeWorkspaceOptions extends WorkspacePluginOptions {
|
|
12
16
|
alwaysLinkLocal?: boolean;
|
|
@@ -20,7 +24,6 @@ interface NodeWorkspaceOptions extends WorkspacePluginOptions {
|
|
|
20
24
|
*/
|
|
21
25
|
export declare class NodeWorkspace extends WorkspacePlugin<Package> {
|
|
22
26
|
private alwaysLinkLocal;
|
|
23
|
-
private packageGraph?;
|
|
24
27
|
constructor(github: GitHub, targetBranch: string, repositoryConfig: RepositoryConfig, options?: NodeWorkspaceOptions);
|
|
25
28
|
protected buildAllPackages(candidates: CandidateReleasePullRequest[]): Promise<{
|
|
26
29
|
allPackages: Package[];
|
|
@@ -34,7 +37,6 @@ export declare class NodeWorkspace extends WorkspacePlugin<Package> {
|
|
|
34
37
|
protected inScope(candidate: CandidateReleasePullRequest): boolean;
|
|
35
38
|
protected packageNameFromPackage(pkg: Package): string;
|
|
36
39
|
protected pathFromPackage(pkg: Package): string;
|
|
37
|
-
private detectRangePrefix;
|
|
38
40
|
private combineDeps;
|
|
39
41
|
}
|
|
40
42
|
export {};
|
|
@@ -14,26 +14,15 @@
|
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.NodeWorkspace = void 0;
|
|
17
|
-
const core_1 = require("@lerna-lite/core");
|
|
18
|
-
const core_2 = require("@lerna-lite/core");
|
|
19
17
|
const version_1 = require("../version");
|
|
20
|
-
const raw_content_1 = require("../updaters/raw-content");
|
|
21
18
|
const pull_request_title_1 = require("../util/pull-request-title");
|
|
22
19
|
const pull_request_body_1 = require("../util/pull-request-body");
|
|
23
20
|
const branch_name_1 = require("../util/branch-name");
|
|
24
|
-
const json_stringify_1 = require("../util/json-stringify");
|
|
25
21
|
const changelog_1 = require("../updaters/changelog");
|
|
26
22
|
const workspace_1 = require("./workspace");
|
|
27
23
|
const versioning_strategy_1 = require("../versioning-strategy");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
super(pkg !== null && pkg !== void 0 ? pkg : JSON.parse(rawContent), location);
|
|
31
|
-
this.rawContent = rawContent;
|
|
32
|
-
}
|
|
33
|
-
clone() {
|
|
34
|
-
return new Package(this.rawContent, this.location, this.toJSON());
|
|
35
|
-
}
|
|
36
|
-
}
|
|
24
|
+
const composite_1 = require("../updaters/composite");
|
|
25
|
+
const package_json_1 = require("../updaters/node/package-json");
|
|
37
26
|
/**
|
|
38
27
|
* The plugin analyzed a cargo workspace and will bump dependencies
|
|
39
28
|
* of managed packages if those dependencies are being updated.
|
|
@@ -47,6 +36,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
47
36
|
this.alwaysLinkLocal = options.alwaysLinkLocal === false ? false : true;
|
|
48
37
|
}
|
|
49
38
|
async buildAllPackages(candidates) {
|
|
39
|
+
var _a;
|
|
50
40
|
const candidatesByPath = new Map();
|
|
51
41
|
for (const candidate of candidates) {
|
|
52
42
|
candidatesByPath.set(candidate.path, candidate);
|
|
@@ -63,27 +53,41 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
63
53
|
this.logger.debug(`Found candidate pull request for path: ${candidate.path}`);
|
|
64
54
|
const packagePath = (0, workspace_1.addPath)(candidate.path, 'package.json');
|
|
65
55
|
const packageUpdate = candidate.pullRequest.updates.find(update => update.path === packagePath);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
const contents = (_a = packageUpdate === null || packageUpdate === void 0 ? void 0 : packageUpdate.cachedFileContents) !== null && _a !== void 0 ? _a : (await this.github.getFileContentsOnBranch(packagePath, this.targetBranch));
|
|
57
|
+
const packageJson = JSON.parse(contents.parsedContent);
|
|
58
|
+
const pkg = {
|
|
59
|
+
name: packageJson.name,
|
|
60
|
+
path,
|
|
61
|
+
version: packageJson.version,
|
|
62
|
+
dependencies: packageJson.dependencies || {},
|
|
63
|
+
devDependencies: packageJson.devDependencies || {},
|
|
64
|
+
peerDependencies: packageJson.peerDependencies || {},
|
|
65
|
+
optionalDependencies: packageJson.optionalDependencies || {},
|
|
66
|
+
jsonContent: contents.parsedContent,
|
|
67
|
+
};
|
|
68
|
+
packagesByPath.set(candidate.path, pkg);
|
|
69
|
+
candidatesByPackage[pkg.name] = candidate;
|
|
70
|
+
// }
|
|
77
71
|
}
|
|
78
72
|
else {
|
|
79
73
|
const packagePath = (0, workspace_1.addPath)(path, 'package.json');
|
|
80
74
|
this.logger.debug(`No candidate pull request for path: ${path} - inspect package from ${packagePath}`);
|
|
81
75
|
const contents = await this.github.getFileContentsOnBranch(packagePath, this.targetBranch);
|
|
82
|
-
|
|
76
|
+
const packageJson = JSON.parse(contents.parsedContent);
|
|
77
|
+
const pkg = {
|
|
78
|
+
name: packageJson.name,
|
|
79
|
+
path,
|
|
80
|
+
version: packageJson.version,
|
|
81
|
+
dependencies: packageJson.dependencies || {},
|
|
82
|
+
devDependencies: packageJson.devDependencies || {},
|
|
83
|
+
peerDependencies: packageJson.peerDependencies || {},
|
|
84
|
+
optionalDependencies: packageJson.optionalDependencies || {},
|
|
85
|
+
jsonContent: contents.parsedContent,
|
|
86
|
+
};
|
|
87
|
+
packagesByPath.set(path, pkg);
|
|
83
88
|
}
|
|
84
89
|
}
|
|
85
90
|
const allPackages = Array.from(packagesByPath.values());
|
|
86
|
-
this.packageGraph = new core_1.PackageGraph(allPackages, 'allDependencies', this.alwaysLinkLocal);
|
|
87
91
|
return {
|
|
88
92
|
allPackages,
|
|
89
93
|
candidatesByPackage,
|
|
@@ -94,35 +98,24 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
94
98
|
return new versioning_strategy_1.PatchVersionUpdate().bump(version);
|
|
95
99
|
}
|
|
96
100
|
updateCandidate(existingCandidate, pkg, updatedVersions) {
|
|
97
|
-
var _a, _b;
|
|
98
|
-
const graphPackage = (_a = this.packageGraph) === null || _a === void 0 ? void 0 : _a.get(pkg.name);
|
|
99
|
-
if (!graphPackage) {
|
|
100
|
-
throw new Error(`Could not find graph package for ${pkg.name}`);
|
|
101
|
-
}
|
|
102
|
-
const updatedPackage = pkg.clone();
|
|
103
101
|
// Update version of the package
|
|
104
|
-
const newVersion = updatedVersions.get(
|
|
105
|
-
if (newVersion) {
|
|
106
|
-
|
|
107
|
-
updatedPackage.version = newVersion.toString();
|
|
108
|
-
}
|
|
109
|
-
// Update dependency versions
|
|
110
|
-
for (const [depName, resolved] of graphPackage.localDependencies) {
|
|
111
|
-
const depVersion = updatedVersions.get(depName);
|
|
112
|
-
if (depVersion && resolved.type !== 'directory') {
|
|
113
|
-
const currentVersion = (_b = this.combineDeps(pkg)) === null || _b === void 0 ? void 0 : _b[depName];
|
|
114
|
-
const prefix = currentVersion
|
|
115
|
-
? this.detectRangePrefix(currentVersion)
|
|
116
|
-
: '';
|
|
117
|
-
updatedPackage.updateLocalDependency(resolved, depVersion.toString(), prefix);
|
|
118
|
-
this.logger.info(`${pkg.name}.${depName} updated to ${prefix}${depVersion.toString()}`);
|
|
119
|
-
}
|
|
102
|
+
const newVersion = updatedVersions.get(pkg.name);
|
|
103
|
+
if (!newVersion) {
|
|
104
|
+
throw new Error(`Didn't find updated version for ${pkg.name}`);
|
|
120
105
|
}
|
|
121
|
-
const
|
|
106
|
+
const updatedPackage = {
|
|
107
|
+
...pkg,
|
|
108
|
+
version: newVersion.toString(),
|
|
109
|
+
};
|
|
110
|
+
const updater = new package_json_1.PackageJson({
|
|
111
|
+
version: newVersion,
|
|
112
|
+
versionsMap: updatedVersions,
|
|
113
|
+
});
|
|
114
|
+
const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage, updatedVersions, this.logger);
|
|
122
115
|
existingCandidate.pullRequest.updates =
|
|
123
116
|
existingCandidate.pullRequest.updates.map(update => {
|
|
124
117
|
if (update.path === (0, workspace_1.addPath)(existingCandidate.path, 'package.json')) {
|
|
125
|
-
update.updater = new
|
|
118
|
+
update.updater = new composite_1.CompositeUpdater(update.updater, updater);
|
|
126
119
|
}
|
|
127
120
|
else if (update.updater instanceof changelog_1.Changelog) {
|
|
128
121
|
if (dependencyNotes) {
|
|
@@ -149,63 +142,50 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
149
142
|
return existingCandidate;
|
|
150
143
|
}
|
|
151
144
|
newCandidate(pkg, updatedVersions) {
|
|
152
|
-
var _a, _b;
|
|
153
|
-
const graphPackage = (_a = this.packageGraph) === null || _a === void 0 ? void 0 : _a.get(pkg.name);
|
|
154
|
-
if (!graphPackage) {
|
|
155
|
-
throw new Error(`Could not find graph package for ${pkg.name}`);
|
|
156
|
-
}
|
|
157
|
-
const updatedPackage = pkg.clone();
|
|
158
145
|
// Update version of the package
|
|
159
|
-
const newVersion = updatedVersions.get(
|
|
160
|
-
if (newVersion) {
|
|
161
|
-
|
|
162
|
-
updatedPackage.version = newVersion.toString();
|
|
146
|
+
const newVersion = updatedVersions.get(pkg.name);
|
|
147
|
+
if (!newVersion) {
|
|
148
|
+
throw new Error(`Didn't find updated version for ${pkg.name}`);
|
|
163
149
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
? this.detectRangePrefix(currentVersion)
|
|
170
|
-
: '';
|
|
171
|
-
updatedPackage.updateLocalDependency(resolved, depVersion.toString(), prefix);
|
|
172
|
-
this.logger.info(`${pkg.name}.${depName} updated to ${prefix}${depVersion.toString()}`);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage, updatedVersions);
|
|
176
|
-
const packageJson = updatedPackage.toJSON();
|
|
177
|
-
const version = version_1.Version.parse(packageJson.version);
|
|
150
|
+
const updatedPackage = {
|
|
151
|
+
...pkg,
|
|
152
|
+
version: newVersion.toString(),
|
|
153
|
+
};
|
|
154
|
+
const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage, updatedVersions, this.logger);
|
|
178
155
|
const pullRequest = {
|
|
179
156
|
title: pull_request_title_1.PullRequestTitle.ofTargetBranch(this.targetBranch),
|
|
180
157
|
body: new pull_request_body_1.PullRequestBody([
|
|
181
158
|
{
|
|
182
159
|
component: updatedPackage.name,
|
|
183
|
-
version,
|
|
160
|
+
version: newVersion,
|
|
184
161
|
notes: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes, this.logger),
|
|
185
162
|
},
|
|
186
163
|
]),
|
|
187
164
|
updates: [
|
|
188
165
|
{
|
|
189
|
-
path: (0, workspace_1.addPath)(updatedPackage.
|
|
166
|
+
path: (0, workspace_1.addPath)(updatedPackage.path, 'package.json'),
|
|
190
167
|
createIfMissing: false,
|
|
191
|
-
updater: new
|
|
168
|
+
updater: new package_json_1.PackageJson({
|
|
169
|
+
version: newVersion,
|
|
170
|
+
versionsMap: updatedVersions,
|
|
171
|
+
}),
|
|
192
172
|
},
|
|
193
173
|
{
|
|
194
|
-
path: (0, workspace_1.addPath)(updatedPackage.
|
|
174
|
+
path: (0, workspace_1.addPath)(updatedPackage.path, 'CHANGELOG.md'),
|
|
195
175
|
createIfMissing: false,
|
|
196
176
|
updater: new changelog_1.Changelog({
|
|
197
|
-
version,
|
|
177
|
+
version: newVersion,
|
|
198
178
|
changelogEntry: (0, workspace_1.appendDependenciesSectionToChangelog)('', dependencyNotes, this.logger),
|
|
199
179
|
}),
|
|
200
180
|
},
|
|
201
181
|
],
|
|
202
182
|
labels: [],
|
|
203
183
|
headRefName: branch_name_1.BranchName.ofTargetBranch(this.targetBranch).toString(),
|
|
204
|
-
version,
|
|
184
|
+
version: newVersion,
|
|
205
185
|
draft: false,
|
|
206
186
|
};
|
|
207
187
|
return {
|
|
208
|
-
path: updatedPackage.
|
|
188
|
+
path: updatedPackage.path,
|
|
209
189
|
pullRequest,
|
|
210
190
|
config: {
|
|
211
191
|
releaseType: 'node',
|
|
@@ -236,10 +216,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
236
216
|
return pkg.name;
|
|
237
217
|
}
|
|
238
218
|
pathFromPackage(pkg) {
|
|
239
|
-
return pkg.
|
|
240
|
-
}
|
|
241
|
-
detectRangePrefix(version) {
|
|
242
|
-
return (Object.values(SUPPORTED_RANGE_PREFIXES).find(supportedRangePrefix => version.startsWith(supportedRangePrefix)) || '');
|
|
219
|
+
return pkg.path;
|
|
243
220
|
}
|
|
244
221
|
combineDeps(packageJson) {
|
|
245
222
|
var _a, _b, _c;
|
|
@@ -251,17 +228,8 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
251
228
|
}
|
|
252
229
|
}
|
|
253
230
|
exports.NodeWorkspace = NodeWorkspace;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
SUPPORTED_RANGE_PREFIXES["CARET"] = "^";
|
|
257
|
-
SUPPORTED_RANGE_PREFIXES["TILDE"] = "~";
|
|
258
|
-
SUPPORTED_RANGE_PREFIXES["GREATER_THAN"] = ">";
|
|
259
|
-
SUPPORTED_RANGE_PREFIXES["LESS_THAN"] = "<";
|
|
260
|
-
SUPPORTED_RANGE_PREFIXES["EQUAL_OR_GREATER_THAN"] = ">=";
|
|
261
|
-
SUPPORTED_RANGE_PREFIXES["EQUAL_OR_LESS_THAN"] = "<=";
|
|
262
|
-
})(SUPPORTED_RANGE_PREFIXES || (SUPPORTED_RANGE_PREFIXES = {}));
|
|
263
|
-
function getChangelogDepsNotes(original, updated, updateVersions) {
|
|
264
|
-
var _a, _b;
|
|
231
|
+
function getChangelogDepsNotes(original, updated, updateVersions, logger) {
|
|
232
|
+
var _a;
|
|
265
233
|
let depUpdateNotes = '';
|
|
266
234
|
const depTypes = [
|
|
267
235
|
'dependencies',
|
|
@@ -277,15 +245,19 @@ function getChangelogDepsNotes(original, updated, updateVersions) {
|
|
|
277
245
|
continue;
|
|
278
246
|
}
|
|
279
247
|
for (const [depName, currentDepVer] of Object.entries(pkgDepTypes)) {
|
|
248
|
+
const newVersion = updateVersions.get(depName);
|
|
249
|
+
if (!newVersion) {
|
|
250
|
+
logger.debug(`${depName} was not bumped, ignoring`);
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
280
253
|
const origDepVer = (_a = original[depType]) === null || _a === void 0 ? void 0 : _a[depName];
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
254
|
+
const newVersionString = (0, package_json_1.newVersionWithRange)(origDepVer, newVersion);
|
|
255
|
+
if (currentDepVer.startsWith('workspace:')) {
|
|
256
|
+
depUpdates.push(`\n * ${depName} bumped to ${newVersionString}`);
|
|
284
257
|
}
|
|
285
|
-
else if (
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
.get(depName)) === null || _b === void 0 ? void 0 : _b.toString()}`);
|
|
258
|
+
else if (newVersionString !== origDepVer) {
|
|
259
|
+
depUpdates.push(`\n * ${depName} bumped from ${origDepVer} to ${newVersionString}`);
|
|
260
|
+
//handle case when "workspace:" version is used
|
|
289
261
|
}
|
|
290
262
|
}
|
|
291
263
|
if (depUpdates.length > 0) {
|
|
@@ -73,7 +73,7 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin {
|
|
|
73
73
|
const existingCandidate = this.findCandidateForPackage(pkg, candidatesByPackage);
|
|
74
74
|
if (existingCandidate) {
|
|
75
75
|
// if already has an pull request, update the changelog and update
|
|
76
|
-
this.logger.info(`Updating
|
|
76
|
+
this.logger.info(`Updating existing candidate pull request for ${this.packageNameFromPackage(pkg)}, path: ${existingCandidate.path}`);
|
|
77
77
|
if (newCandidatePaths.has(existingCandidate.path)) {
|
|
78
78
|
this.logger.info(`Already updated candidate for path: ${existingCandidate.path}`);
|
|
79
79
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Logger } from '../../util/logger';
|
|
2
2
|
import { DefaultUpdater } from '../default';
|
|
3
|
+
import { Version } from '../../version';
|
|
3
4
|
/**
|
|
4
5
|
* This updates a Node.js package.json file's main version.
|
|
5
6
|
*/
|
|
@@ -11,3 +12,10 @@ export declare class PackageJson extends DefaultUpdater {
|
|
|
11
12
|
*/
|
|
12
13
|
updateContent(content: string, logger?: Logger): string;
|
|
13
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Helper to coerce a new version value into a version range that preserves the
|
|
17
|
+
* version range prefix of the original version.
|
|
18
|
+
* @param {string} oldVersion Old semver with range
|
|
19
|
+
* @param {Version} newVersion The new version to update with
|
|
20
|
+
*/
|
|
21
|
+
export declare function newVersionWithRange(oldVersion: string, newVersion: Version): string;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.PackageJson = void 0;
|
|
16
|
+
exports.newVersionWithRange = exports.PackageJson = void 0;
|
|
17
17
|
const json_stringify_1 = require("../../util/json-stringify");
|
|
18
18
|
const logger_1 = require("../../util/logger");
|
|
19
19
|
const default_1 = require("../default");
|
|
@@ -30,8 +30,67 @@ class PackageJson extends default_1.DefaultUpdater {
|
|
|
30
30
|
const parsed = JSON.parse(content);
|
|
31
31
|
logger.info(`updating from ${parsed.version} to ${this.version}`);
|
|
32
32
|
parsed.version = this.version.toString();
|
|
33
|
+
// If additional dependency versions specified, then update dependency versions
|
|
34
|
+
// while preserving any valid version range prefixes.
|
|
35
|
+
if (this.versionsMap) {
|
|
36
|
+
if (parsed.dependencies) {
|
|
37
|
+
updateDependencies(parsed.dependencies, this.versionsMap);
|
|
38
|
+
}
|
|
39
|
+
if (parsed.devDependencies) {
|
|
40
|
+
updateDependencies(parsed.devDependencies, this.versionsMap);
|
|
41
|
+
}
|
|
42
|
+
if (parsed.peerDependencies) {
|
|
43
|
+
updateDependencies(parsed.peerDependencies, this.versionsMap);
|
|
44
|
+
}
|
|
45
|
+
if (parsed.optionalDependencies) {
|
|
46
|
+
updateDependencies(parsed.optionalDependencies, this.versionsMap);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
33
49
|
return (0, json_stringify_1.jsonStringify)(parsed, content);
|
|
34
50
|
}
|
|
35
51
|
}
|
|
36
52
|
exports.PackageJson = PackageJson;
|
|
53
|
+
var SUPPORTED_RANGE_PREFIXES;
|
|
54
|
+
(function (SUPPORTED_RANGE_PREFIXES) {
|
|
55
|
+
SUPPORTED_RANGE_PREFIXES["CARET"] = "^";
|
|
56
|
+
SUPPORTED_RANGE_PREFIXES["TILDE"] = "~";
|
|
57
|
+
SUPPORTED_RANGE_PREFIXES["GREATER_THAN"] = ">";
|
|
58
|
+
SUPPORTED_RANGE_PREFIXES["LESS_THAN"] = "<";
|
|
59
|
+
SUPPORTED_RANGE_PREFIXES["EQUAL_OR_GREATER_THAN"] = ">=";
|
|
60
|
+
SUPPORTED_RANGE_PREFIXES["EQUAL_OR_LESS_THAN"] = "<=";
|
|
61
|
+
})(SUPPORTED_RANGE_PREFIXES || (SUPPORTED_RANGE_PREFIXES = {}));
|
|
62
|
+
function detectRangePrefix(version) {
|
|
63
|
+
return (Object.values(SUPPORTED_RANGE_PREFIXES).find(supportedRangePrefix => version.startsWith(supportedRangePrefix)) || '');
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Helper to coerce a new version value into a version range that preserves the
|
|
67
|
+
* version range prefix of the original version.
|
|
68
|
+
* @param {string} oldVersion Old semver with range
|
|
69
|
+
* @param {Version} newVersion The new version to update with
|
|
70
|
+
*/
|
|
71
|
+
function newVersionWithRange(oldVersion, newVersion) {
|
|
72
|
+
const prefix = detectRangePrefix(oldVersion);
|
|
73
|
+
if (prefix) {
|
|
74
|
+
return `${prefix}${newVersion}`;
|
|
75
|
+
}
|
|
76
|
+
return newVersion.toString();
|
|
77
|
+
}
|
|
78
|
+
exports.newVersionWithRange = newVersionWithRange;
|
|
79
|
+
/**
|
|
80
|
+
* Helper function to update dependency versions for all new versions specified
|
|
81
|
+
* in the updated versions map. Note that this mutates the existing input.
|
|
82
|
+
* @param {Record<string, string>} dependencies Entries in package.json dependencies
|
|
83
|
+
* where the key is the dependency name and the value is the dependency range
|
|
84
|
+
* @param {VersionsMap} updatedVersions Map of new versions (without dependency range prefixes)
|
|
85
|
+
*/
|
|
86
|
+
function updateDependencies(dependencies, updatedVersions) {
|
|
87
|
+
for (const depName of Object.keys(dependencies)) {
|
|
88
|
+
const newVersion = updatedVersions.get(depName);
|
|
89
|
+
if (newVersion) {
|
|
90
|
+
const oldVersion = dependencies[depName];
|
|
91
|
+
const newVersionString = newVersionWithRange(oldVersion, newVersion);
|
|
92
|
+
dependencies[depName] = newVersionString;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
37
96
|
//# sourceMappingURL=package-json.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "release-please",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.3.1",
|
|
4
4
|
"description": "generate release PRs based on the conventionalcommits.org spec",
|
|
5
5
|
"main": "./build/src/index.js",
|
|
6
6
|
"bin": "./build/src/bin/release-please.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@types/jsonpath": "^0.2.0",
|
|
48
48
|
"@types/mocha": "^9.0.0",
|
|
49
49
|
"@types/node": "^18.0.0",
|
|
50
|
-
"@types/npmlog": "^
|
|
50
|
+
"@types/npmlog": "^7.0.0",
|
|
51
51
|
"@types/pino": "^7.0.0",
|
|
52
52
|
"@types/semver": "^7.0.0",
|
|
53
53
|
"@types/sinon": "^10.0.0",
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"@conventional-commits/parser": "^0.4.1",
|
|
70
70
|
"@google-automations/git-file-utils": "^1.2.5",
|
|
71
71
|
"@iarna/toml": "^3.0.0",
|
|
72
|
-
"@lerna-lite/core": "1.17.0",
|
|
73
72
|
"@octokit/graphql": "^5.0.0",
|
|
74
73
|
"@octokit/request": "^6.0.0",
|
|
75
74
|
"@octokit/request-error": "^3.0.0",
|