rman 2.42.0 → 2.43.0
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/builtins/platforms/node/node-dependency-updater.d.ts +8 -0
- package/builtins/platforms/node/node-dependency-updater.js +61 -3
- package/commands/deps.command.js +30 -3
- package/constants.js +1 -1
- package/core/interfaces/dependency-updater.d.ts +15 -1
- package/core/interfaces/dependency-updater.js +15 -0
- package/package.json +1 -1
- package/services/github-release.service.js +3 -11
- package/services/version-plan.service.d.ts +5 -0
- package/services/version-plan.service.js +16 -1
- package/services/version.service.js +22 -13
- package/utils/release-version.d.ts +6 -0
- package/utils/release-version.js +14 -0
|
@@ -30,6 +30,12 @@ export declare class NodeDependencyUpdater implements DependencyUpdater {
|
|
|
30
30
|
/** The first pnpm with a non-zero default `minimumReleaseAge`; an older one has none. */
|
|
31
31
|
protected readonly pnpmReleaseAgeSince: string;
|
|
32
32
|
getPlan(ctx: DependencyUpdater.Context, packages: readonly Package[]): Promise<DependencyUpdater.Entry[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Brings the installed copies of `names` up to what their declared ranges already take, with the
|
|
35
|
+
* repository's own package manager at its root - `pnpm update -r <names> --no-save` or
|
|
36
|
+
* `npm update <names> --no-save`. No manifest changes; the lockfile and `node_modules` do.
|
|
37
|
+
*/
|
|
38
|
+
refresh(ctx: DependencyUpdater.Context, names: readonly string[]): Promise<string[]>;
|
|
33
39
|
applyPlan(ctx: DependencyUpdater.Context, plan: readonly DependencyUpdater.Entry[]): Promise<DependencyUpdater.Applied>;
|
|
34
40
|
/**
|
|
35
41
|
* The repository's own package manager, asked whether the manifests install, writing nothing:
|
|
@@ -80,6 +86,8 @@ export declare class NodeDependencyUpdater implements DependencyUpdater {
|
|
|
80
86
|
/** Runs `pnpm <args>` at the repository root, never throwing - the one place this class spawns
|
|
81
87
|
* pnpm, so a spec answers for it instead of whichever pnpm is on the machine. */
|
|
82
88
|
protected pnpm(ctx: DependencyUpdater.Context, args: string): Promise<ExecResult>;
|
|
89
|
+
/** `npm <args>` at the repository root, never throwing - `refresh`'s spawn, and the spec's seam. */
|
|
90
|
+
protected npm(ctx: DependencyUpdater.Context, args: string): Promise<ExecResult>;
|
|
83
91
|
/**
|
|
84
92
|
* The moves a pnpm peer issue is about: the peer at the version pnpm found, when this run moved it
|
|
85
93
|
* there, else the packages wanting it that this run moved.
|
|
@@ -89,8 +89,8 @@ export class NodeDependencyUpdater {
|
|
|
89
89
|
this.prepare(d, registry.get(this.sourceOf(d)));
|
|
90
90
|
this.resolve(decisions, ctx);
|
|
91
91
|
return decisions
|
|
92
|
-
.filter(d => d.wanted || d.
|
|
93
|
-
.
|
|
92
|
+
.filter(d => d.wanted || d.listed)
|
|
93
|
+
.flatMap(d => {
|
|
94
94
|
/** Set on the entry itself, never a copy: `planned` is keyed by that object. */
|
|
95
95
|
const entry = this.toEntry(d);
|
|
96
96
|
entry.installed = this.installedVersion(d.pkg, d.name);
|
|
@@ -98,9 +98,49 @@ export class NodeDependencyUpdater {
|
|
|
98
98
|
if (entry.installed && semver.validRange(entry.current)) {
|
|
99
99
|
entry.installedInRange = semver.satisfies(entry.installed, entry.current, { includePrerelease: true });
|
|
100
100
|
}
|
|
101
|
-
return entry;
|
|
101
|
+
return d.wanted || d.unmovable || DependencyUpdater.lagsBehind(entry) ? [entry] : [];
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Brings the installed copies of `names` up to what their declared ranges already take, with the
|
|
106
|
+
* repository's own package manager at its root - `pnpm update -r <names> --no-save` or
|
|
107
|
+
* `npm update <names> --no-save`. No manifest changes; the lockfile and `node_modules` do.
|
|
108
|
+
*/
|
|
109
|
+
/* **`--no-save`, or the package manager rewrites the ranges itself.** Measured on pnpm 12.10.1:
|
|
110
|
+
* `pnpm update -r ms debug` turned `^2.0.0` into `^2.1.3` and `^4.3.0` into `^4.4.3`, and
|
|
111
|
+
* re-sorted the dependency block while at it; a `>=2.0.0 <3` it left alone. With `--no-save` both
|
|
112
|
+
* stayed as written, the lockfile moved to 2.1.3 / 4.4.3 with the specifiers unchanged, and a
|
|
113
|
+
* `--frozen-lockfile` install afterwards passed. npm 11.12.1 the same: `npm update ms debug
|
|
114
|
+
* --no-save` at a workspace root moved `package-lock.json` and the hoisted copies, left every
|
|
115
|
+
* manifest alone, and `npm ci` afterwards passed. `-r` is harmless in a single-package pnpm
|
|
116
|
+
* repository (measured), so it is passed always.
|
|
117
|
+
*
|
|
118
|
+
* **Why `deps -u` does this at all**, when it otherwise writes manifests and leaves installing to
|
|
119
|
+
* the user: a range rman does not rewrite - `>=2.3.0 <3`, a pin, `||` - has nothing for `-u` to
|
|
120
|
+
* write, so an upgrade it takes already was invisible and unreachable. Reported from
|
|
121
|
+
* `syncbridge-io/syncbridge-extensions`: `hl7v2` and `hl7v2-net` declared `>=2.3.0 <3`, 2.3.2 was
|
|
122
|
+
* out, 2.3.0 was installed, and `rman deps` listed neither. */
|
|
123
|
+
async refresh(ctx, names) {
|
|
124
|
+
if (!names.length)
|
|
125
|
+
return [];
|
|
126
|
+
const manager = this.installer(ctx);
|
|
127
|
+
const list = names.join(' ');
|
|
128
|
+
let result;
|
|
129
|
+
if (manager === 'pnpm')
|
|
130
|
+
result = await this.pnpm(ctx, `update -r ${list} --no-save`);
|
|
131
|
+
else if (manager === 'npm')
|
|
132
|
+
result = await this.npm(ctx, `update ${list} --no-save --no-audit --no-fund`);
|
|
133
|
+
else {
|
|
134
|
+
console.error(colors.yellow(`Not refreshed: "${manager}" is not asked to update - run its own update.`));
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
if (result.code) {
|
|
138
|
+
const output = (result.stdout ?? '').trim();
|
|
139
|
+
throw new Error(`${manager} update exited ${result.code}${output ? `:\n${output}` : ''}`);
|
|
140
|
+
}
|
|
141
|
+
const lockfile = path.join(ctx.repository.dirname, manager === 'pnpm' ? 'pnpm-lock.yaml' : 'package-lock.json');
|
|
142
|
+
return fs.existsSync(lockfile) ? [lockfile] : [];
|
|
143
|
+
}
|
|
104
144
|
async applyPlan(ctx, plan) {
|
|
105
145
|
const originals = new Map();
|
|
106
146
|
this.written = new Set();
|
|
@@ -360,6 +400,10 @@ export class NodeDependencyUpdater {
|
|
|
360
400
|
pnpm(ctx, args) {
|
|
361
401
|
return exec(`pnpm ${args}`, { cwd: ctx.repository.dirname, app: ctx.app, throwOnError: false });
|
|
362
402
|
}
|
|
403
|
+
/** `npm <args>` at the repository root, never throwing - `refresh`'s spawn, and the spec's seam. */
|
|
404
|
+
npm(ctx, args) {
|
|
405
|
+
return exec(`npm ${args}`, { cwd: ctx.repository.dirname, app: ctx.app, throwOnError: false });
|
|
406
|
+
}
|
|
363
407
|
/**
|
|
364
408
|
* The moves a pnpm peer issue is about: the peer at the version pnpm found, when this run moved it
|
|
365
409
|
* there, else the packages wanting it that this run moved.
|
|
@@ -855,6 +899,20 @@ export class NodeDependencyUpdater {
|
|
|
855
899
|
reason: 'not a ^ or ~ range - rman moves only those',
|
|
856
900
|
};
|
|
857
901
|
}
|
|
902
|
+
/** A range rman does not move whose newest release it still takes: nothing to write, and listed
|
|
903
|
+
* only when what is installed lags behind it (`getPlan`'s last filter). */
|
|
904
|
+
if (!d.wanted) {
|
|
905
|
+
const field = d.fixed[0];
|
|
906
|
+
const range = d.fields.get(field);
|
|
907
|
+
return {
|
|
908
|
+
package: d.pkg,
|
|
909
|
+
name: d.name,
|
|
910
|
+
types: [...d.fixed],
|
|
911
|
+
current: (d.aliases.get(field) ?? '') + range,
|
|
912
|
+
status: 'up-to-date',
|
|
913
|
+
latest: this.resolvedVersion(d, range),
|
|
914
|
+
};
|
|
915
|
+
}
|
|
858
916
|
const entry = {
|
|
859
917
|
package: d.pkg,
|
|
860
918
|
name: d.name,
|
package/commands/deps.command.js
CHANGED
|
@@ -16,7 +16,7 @@ const config = {
|
|
|
16
16
|
upgrade: {
|
|
17
17
|
target: 'cli',
|
|
18
18
|
alias: 'u',
|
|
19
|
-
describe: 'Write the new ranges to the manifests,
|
|
19
|
+
describe: 'Write the new ranges to the manifests, check that they still install, then install what a range already takes and the lockfile lags behind',
|
|
20
20
|
type: 'boolean',
|
|
21
21
|
},
|
|
22
22
|
/** Its `choices` and its default are the version schemes' own sizes, so they are filled in where
|
|
@@ -122,9 +122,12 @@ const depsCommand = registerCommand(app => {
|
|
|
122
122
|
console.log(JSON.stringify(jsonPlan(all), undefined, 2));
|
|
123
123
|
const errors = all.filter(e => e.status === 'error');
|
|
124
124
|
const updates = all.filter(e => e.status === 'update');
|
|
125
|
+
/** Behind what a range rman leaves as it is already takes - `-u` installs those, writing no range. */
|
|
126
|
+
const lagging = all.filter(e => e.status !== 'update' && e.status !== 'error' && DependencyUpdater.lagsBehind(e));
|
|
125
127
|
if (!args.upgrade) {
|
|
126
|
-
if (updates.length && !args.json)
|
|
128
|
+
if ((updates.length || lagging.length) && !args.json) {
|
|
127
129
|
console.log(colors.gray('\nRun "rman deps -u" to upgrade.'));
|
|
130
|
+
}
|
|
128
131
|
if (errors.length)
|
|
129
132
|
throw logged(`${errors.length} dependency lookup(s) failed - see above.`);
|
|
130
133
|
return;
|
|
@@ -167,6 +170,19 @@ const depsCommand = registerCommand(app => {
|
|
|
167
170
|
}
|
|
168
171
|
}
|
|
169
172
|
const files = [...applied.values()].flatMap(a => a.files);
|
|
173
|
+
/* After the manifests, so an install that runs anyway takes the new ranges too; and only once
|
|
174
|
+
* they are verified, so a refused upgrade never reaches the lockfile. */
|
|
175
|
+
for (const [updater, plan] of plans) {
|
|
176
|
+
const names = [...new Set(lagging.filter(e => plan.includes(e)).map(e => e.name))];
|
|
177
|
+
if (!names.length || !updater.refresh)
|
|
178
|
+
continue;
|
|
179
|
+
try {
|
|
180
|
+
files.push(...(await updater.refresh(ctx, names)));
|
|
181
|
+
}
|
|
182
|
+
catch (e) {
|
|
183
|
+
throw logged(`Could not install the in-range upgrades (${names.join(', ')}):\n${e?.message ?? e}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
170
186
|
if (args.json)
|
|
171
187
|
console.log(JSON.stringify(jsonPlan(all), undefined, 2));
|
|
172
188
|
else {
|
|
@@ -277,7 +293,7 @@ function printPlan(entries, root) {
|
|
|
277
293
|
for (const e of rows) {
|
|
278
294
|
const paint = e.status === 'update' ? sizeColor(e.bump, sizes) : changeColor(e.status);
|
|
279
295
|
const values = cells(e);
|
|
280
|
-
const note =
|
|
296
|
+
const note = noteOf(e);
|
|
281
297
|
if (note)
|
|
282
298
|
values[last] = values[last].padEnd(widths[last]);
|
|
283
299
|
const text = line(values, (v, column) => {
|
|
@@ -319,6 +335,17 @@ function wrapNote(note, width) {
|
|
|
319
335
|
lines.push(current);
|
|
320
336
|
return lines;
|
|
321
337
|
}
|
|
338
|
+
/** What the `Note` column says: the entry's own reason, and what an install would change. */
|
|
339
|
+
function noteOf(e) {
|
|
340
|
+
if (e.status === 'update')
|
|
341
|
+
return e.reason;
|
|
342
|
+
const install = DependencyUpdater.lagsBehind(e)
|
|
343
|
+
? `"${e.current}" takes ${e.resolved} - "deps -u" installs it`
|
|
344
|
+
: reinstall(e)
|
|
345
|
+
? `"${e.current}" takes ${e.resolved} - install again`
|
|
346
|
+
: undefined;
|
|
347
|
+
return e.reason && install ? `${e.reason}; ${install}` : (e.reason ?? install);
|
|
348
|
+
}
|
|
322
349
|
/** What the `Change` column says: the size of the move, or why there is none. */
|
|
323
350
|
function changeOf(e) {
|
|
324
351
|
if (e.status === 'up-to-date')
|
package/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.43.0';
|
|
@@ -26,6 +26,14 @@ export interface DependencyUpdater {
|
|
|
26
26
|
* answer, or none at all, puts every write back.
|
|
27
27
|
*/
|
|
28
28
|
blame?(refusal: string, plan: readonly DependencyUpdater.Entry[]): DependencyUpdater.Blame[];
|
|
29
|
+
/**
|
|
30
|
+
* Under `--upgrade`, once the manifests are written and verified: brings the installed copies of
|
|
31
|
+
* `names` up to what their declared ranges already take, without changing a manifest, and returns
|
|
32
|
+
* the files it wrote (a lockfile). Throws when the package manager fails.
|
|
33
|
+
*
|
|
34
|
+
* Omit it when the ecosystem cannot do that; those entries are then listed and left as they are.
|
|
35
|
+
*/
|
|
36
|
+
refresh?(ctx: DependencyUpdater.Context, names: readonly string[]): Promise<string[]>;
|
|
29
37
|
}
|
|
30
38
|
export declare namespace DependencyUpdater {
|
|
31
39
|
/** What one call is handed. */
|
|
@@ -71,7 +79,8 @@ export declare namespace DependencyUpdater {
|
|
|
71
79
|
* `reason` names that rule - or, under `--upgrade`, the ecosystem's resolver refused it.
|
|
72
80
|
* - `'skipped'`: a newer version exists, and the package's own settings leave it out - a major
|
|
73
81
|
* under `target: minor`, or one younger than `minAge`. `reason` says which.
|
|
74
|
-
* - `'up-to-date'`: nothing newer exists
|
|
82
|
+
* - `'up-to-date'`: no range to write - nothing newer exists, or the declared range already takes
|
|
83
|
+
* it. Still worth a row when `lagsBehind` says what is installed is older than `resolved`.
|
|
75
84
|
* - `'error'`: the registry gave no answer.
|
|
76
85
|
*/
|
|
77
86
|
interface Entry {
|
|
@@ -130,4 +139,9 @@ export declare namespace DependencyUpdater {
|
|
|
130
139
|
/** The settings `pkg` is planned with: `options` from the command line over its `.rmanrc "deps"`,
|
|
131
140
|
* and the defaults under both. */
|
|
132
141
|
function settingsFor(pkg: Package, options: Options): Settings;
|
|
142
|
+
/**
|
|
143
|
+
* Whether what is installed for `entry` is older than what its declared range already takes - an
|
|
144
|
+
* install would move it with no manifest change, which is what `refresh` does under `--upgrade`.
|
|
145
|
+
*/
|
|
146
|
+
function lagsBehind(entry: Entry): boolean;
|
|
133
147
|
}
|
|
@@ -60,6 +60,21 @@ export var DependencyUpdater;
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
DependencyUpdater.settingsFor = settingsFor;
|
|
63
|
+
/**
|
|
64
|
+
* Whether what is installed for `entry` is older than what its declared range already takes - an
|
|
65
|
+
* install would move it with no manifest change, which is what `refresh` does under `--upgrade`.
|
|
66
|
+
*/
|
|
67
|
+
function lagsBehind(entry) {
|
|
68
|
+
if (!entry.installed || !entry.resolved)
|
|
69
|
+
return false;
|
|
70
|
+
try {
|
|
71
|
+
return entry.package.versionScheme.compare(entry.installed, entry.resolved) < 0;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
DependencyUpdater.lagsBehind = lagsBehind;
|
|
63
78
|
})(DependencyUpdater || (DependencyUpdater = {}));
|
|
64
79
|
function toList(value) {
|
|
65
80
|
if (value === undefined)
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { Package } from '../core/classes/package.js';
|
|
|
5
5
|
import { Repository } from '../core/classes/repository.js';
|
|
6
6
|
import { Service } from '../core/classes/service.js';
|
|
7
7
|
import { dirtyReason, GitHelper } from '../utils/git.js';
|
|
8
|
-
import {
|
|
8
|
+
import { isCalendarVersion, releaseTagPattern, repositoryReleaseTag } from '../utils/release-version.js';
|
|
9
9
|
import { ChangeHashService } from './change-hash.service.js';
|
|
10
10
|
/**
|
|
11
11
|
* A service class - see `ListService` for the shape and `Service` for the three measured
|
|
@@ -48,7 +48,7 @@ export class GithubReleaseService extends Service {
|
|
|
48
48
|
},
|
|
49
49
|
];
|
|
50
50
|
}
|
|
51
|
-
const tag =
|
|
51
|
+
const tag = repositoryReleaseTag(root, root.version);
|
|
52
52
|
const dirtyFiles = await git.listDirtyFiles();
|
|
53
53
|
if (dirtyFiles.length) {
|
|
54
54
|
return [
|
|
@@ -130,15 +130,7 @@ export class GithubReleaseService extends Service {
|
|
|
130
130
|
}
|
|
131
131
|
const GITHUB_API = 'https://api.github.com';
|
|
132
132
|
const GITHUB_UPLOADS = 'https://uploads.github.com';
|
|
133
|
-
/** The
|
|
134
|
-
* so the release needs a name of its own (`release-*`); a plain one means every package shares it,
|
|
135
|
-
* and that shared version's tag already *is* the release. */
|
|
136
|
-
function releaseTagFor(root) {
|
|
137
|
-
return isCalendarVersion(root.version)
|
|
138
|
-
? expandReleaseTag(root, root.version)
|
|
139
|
-
: ChangeHashService.expandTag(root, root.version);
|
|
140
|
-
}
|
|
141
|
-
/** The glob matching the tags `releaseTagFor` produces - for stepping back to the previous one. */
|
|
133
|
+
/** The glob matching the tags `repositoryReleaseTag` produces - for stepping back to the previous one. */
|
|
142
134
|
function releaseTagGlob(root) {
|
|
143
135
|
const pattern = isCalendarVersion(root.version) ? releaseTagPattern(root) : ChangeHashService.tagPattern(root);
|
|
144
136
|
return pattern.replace('{name}', root.name);
|
|
@@ -77,6 +77,11 @@ export declare abstract class VersionPlanService {
|
|
|
77
77
|
* commits count toward the published packages that carry it (`bundledPackages`).
|
|
78
78
|
*/
|
|
79
79
|
protected notVersionedReason(pkg: Package): string | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* How many version lines the repository has - the distinct groups of every package it versions,
|
|
82
|
+
* whatever this run was filtered to. `buildRootEntry`'s `groupCount`.
|
|
83
|
+
*/
|
|
84
|
+
protected versionLines(repository: Repository): number;
|
|
80
85
|
/**
|
|
81
86
|
* The commit a package's changes are measured **since** - its last release boundary, or
|
|
82
87
|
* `undefined` for a package that has never been released (the caller then reads the whole
|
|
@@ -208,7 +208,7 @@ export class VersionPlanService {
|
|
|
208
208
|
const result = packages.map(pkg => entries.get(pkg.name));
|
|
209
209
|
if (repository.monorepo) {
|
|
210
210
|
result.push(this.buildRootEntry(repository, result, {
|
|
211
|
-
groupCount:
|
|
211
|
+
groupCount: this.versionLines(repository),
|
|
212
212
|
lastReleaseVersion: await findLastReleaseVersion(git, repository.rootPackage),
|
|
213
213
|
now: options.now ?? (() => new Date()),
|
|
214
214
|
}));
|
|
@@ -243,6 +243,21 @@ export class VersionPlanService {
|
|
|
243
243
|
notVersionedReason(pkg) {
|
|
244
244
|
return unversionedReason(pkg);
|
|
245
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* How many version lines the repository has - the distinct groups of every package it versions,
|
|
248
|
+
* whatever this run was filtered to. `buildRootEntry`'s `groupCount`.
|
|
249
|
+
*/
|
|
250
|
+
/* **Structural, not the groups this run built.** It was `groups.size`, and `groups` holds only the
|
|
251
|
+
* packages this run looks at: `rman version patch --scope pkg-a` on a repository with two version
|
|
252
|
+
* lines built one group, so the root took the semver path and reported `1.0.1` - a shared number
|
|
253
|
+
* claiming a release `pkg-b` never had. That went unseen while `version` created no root tag on
|
|
254
|
+
* semver; once it creates the one `github-release` looks for (`repositoryReleaseTag`), it tagged
|
|
255
|
+
* `v1.0.1`. A package the planner never versions (`notVersionedReason` - a `publish.skip` demo
|
|
256
|
+
* app) is left out: it moves no number, so it is no version line of the release's. */
|
|
257
|
+
versionLines(repository) {
|
|
258
|
+
const versioned = repository.getPackages().filter(pkg => !this.notVersionedReason(pkg));
|
|
259
|
+
return new Set(versioned.map(pkg => this.resolveGroupKey(pkg))).size;
|
|
260
|
+
}
|
|
246
261
|
/**
|
|
247
262
|
* Every version of `pkg` its registry already has - `[]` when it has none, or when the package is
|
|
248
263
|
* not published to a registry at all. A computed version never lands on or below the highest of
|
|
@@ -5,7 +5,7 @@ import { ConfigInterpolator } from '../core/config/config-interpolator.js';
|
|
|
5
5
|
import { Manifest } from '../core/interfaces/manifest.js';
|
|
6
6
|
import { GitHelper } from '../utils/git.js';
|
|
7
7
|
import { ROOT_SELECTOR } from '../utils/package-filter.js';
|
|
8
|
-
import {
|
|
8
|
+
import { isCalendarVersion, repositoryReleaseTag } from '../utils/release-version.js';
|
|
9
9
|
import { groupKeyOf, versionLineCount } from '../utils/version-group.js';
|
|
10
10
|
import { stampVersionLabel } from '../utils/version-stamp.js';
|
|
11
11
|
import { ChangeHashService } from './change-hash.service.js';
|
|
@@ -267,19 +267,28 @@ export class VersionService extends Service {
|
|
|
267
267
|
tagged.push({ name: tag, created: !exists });
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
/**
|
|
271
|
-
*
|
|
272
|
-
* (same version, same commit), and
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
270
|
+
/** The repository release tag `github-release` looks for (`repositoryReleaseTag`), on top of the
|
|
271
|
+
* per-group ones. On a calendar version it is always a name of its own. On a semver one it is
|
|
272
|
+
* usually the group's own tag already (same version, same commit), and then nothing is added -
|
|
273
|
+
* a second name would only be noise in every existing repo's tag space; it is created only when
|
|
274
|
+
* the members' tags are named otherwise (`{name}@*`). Created last, so it lands on HEAD rather
|
|
275
|
+
* than behind whichever group happened to be committed last. */
|
|
276
|
+
if (rootEntry?.status === 'bump') {
|
|
277
|
+
const releaseTag = repositoryReleaseTag(repository.rootPackage, rootEntry.to);
|
|
278
|
+
const exists = await git.tagExists(releaseTag);
|
|
279
|
+
if (isCalendarVersion(rootEntry.to)) {
|
|
280
|
+
if (exists) {
|
|
281
|
+
throw new Error(`Release tag "${releaseTag}" already exists - a second release within the same minute. ` +
|
|
282
|
+
'Wait a moment and run again.');
|
|
283
|
+
}
|
|
284
|
+
await git.createTag(releaseTag);
|
|
285
|
+
tagged.push({ name: releaseTag, created: true, release: true });
|
|
286
|
+
}
|
|
287
|
+
else if (!tagged.some(t => t.name === releaseTag)) {
|
|
288
|
+
if (!exists)
|
|
289
|
+
await git.createTag(releaseTag);
|
|
290
|
+
tagged.push({ name: releaseTag, created: !exists, release: true });
|
|
280
291
|
}
|
|
281
|
-
await git.createTag(releaseTag);
|
|
282
|
-
tagged.push({ name: releaseTag, created: true, release: true });
|
|
283
292
|
}
|
|
284
293
|
const pushed = !!options.push && bumped.length > 0;
|
|
285
294
|
if (pushed) {
|
|
@@ -43,6 +43,12 @@ export declare function usesCalendarVersion(options: {
|
|
|
43
43
|
/** The tag naming a given repository release - `releaseTagPattern` run forward, the way
|
|
44
44
|
* `expandTag` runs `changelog.tagPattern` forward for a package. */
|
|
45
45
|
export declare function expandReleaseTag(root: Package, version: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* The tag naming the repository's release at `version` (the root's): its release tag on a calendar
|
|
48
|
+
* version, the root's own `changelog.tagPattern` tag (`v*` unless configured) otherwise. `version`
|
|
49
|
+
* creates it and `github-release` looks it up, so both name it through this one function.
|
|
50
|
+
*/
|
|
51
|
+
export declare function repositoryReleaseTag(root: Package, version: string): string;
|
|
46
52
|
/** The version of the repository's most recent release, from its release tags (highest by version
|
|
47
53
|
* sort) - `undefined` for a repo that has never cut one, or whose tags aren't available (a shallow
|
|
48
54
|
* clone). The authoritative half of `usesCalendarVersion`'s stickiness check: tags record what was
|
package/utils/release-version.js
CHANGED
|
@@ -54,6 +54,20 @@ export function usesCalendarVersion(options) {
|
|
|
54
54
|
export function expandReleaseTag(root, version) {
|
|
55
55
|
return ChangeHashService.applyTagPattern(releaseTagPattern(root), root.name, version);
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* The tag naming the repository's release at `version` (the root's): its release tag on a calendar
|
|
59
|
+
* version, the root's own `changelog.tagPattern` tag (`v*` unless configured) otherwise. `version`
|
|
60
|
+
* creates it and `github-release` looks it up, so both name it through this one function.
|
|
61
|
+
*/
|
|
62
|
+
/* **One function, because two copies drifted.** `github-release` expected `v<version>` for a semver
|
|
63
|
+
* root while `version` created a root tag only on the calendar path, trusting the group's own tag to
|
|
64
|
+
* be the same name. It is not whenever the members' tags are `{name}@*` - declared, or derived by
|
|
65
|
+
* `versionLineCount` counting a package the planner leaves out (a `publish.skip` app). Reported from
|
|
66
|
+
* panates/peacox-ui: one named group plus a private demo app, `version` tagged
|
|
67
|
+
* `@panates-prv/peacox-ui@2.0.0-beta.0` and `github-release` refused for want of `v2.0.0-beta.0`. */
|
|
68
|
+
export function repositoryReleaseTag(root, version) {
|
|
69
|
+
return isCalendarVersion(version) ? expandReleaseTag(root, version) : ChangeHashService.expandTag(root, version);
|
|
70
|
+
}
|
|
57
71
|
/** The version of the repository's most recent release, from its release tags (highest by version
|
|
58
72
|
* sort) - `undefined` for a repo that has never cut one, or whose tags aren't available (a shallow
|
|
59
73
|
* clone). The authoritative half of `usesCalendarVersion`'s stickiness check: tags record what was
|