rman 2.42.1 → 2.43.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/README.md +2 -2
- 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 +3 -3
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ Or run it without installing, via `npx`:
|
|
|
36
36
|
npx rman list
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
`rman` requires **Node.js >=
|
|
39
|
+
`rman` requires **Node.js >= 22**.
|
|
40
40
|
|
|
41
41
|
## Quick start
|
|
42
42
|
|
|
@@ -514,7 +514,7 @@ Full reference, with detailed examples for every service (`VersionService`, `Pub
|
|
|
514
514
|
|
|
515
515
|
## Node compatibility
|
|
516
516
|
|
|
517
|
-
- Node.js >=
|
|
517
|
+
- Node.js >= 22
|
|
518
518
|
|
|
519
519
|
## License
|
|
520
520
|
|
|
@@ -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.1';
|
|
@@ -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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rman",
|
|
3
3
|
"description": "Repository manager",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.43.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"easy-table": "^1.2.0",
|
|
13
13
|
"envinfo": "^7.21.0",
|
|
14
14
|
"fast-glob": "^3.3.3",
|
|
15
|
-
"fast-tokenizer": "^1.10.
|
|
15
|
+
"fast-tokenizer": "^1.10.2",
|
|
16
16
|
"ini": "^7.0.0",
|
|
17
17
|
"js-yaml": "^5.5.0",
|
|
18
18
|
"micromatch": "^4.0.8",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"rman": "cli.js"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
42
|
+
"node": ">=22"
|
|
43
43
|
},
|
|
44
44
|
"contributors": [
|
|
45
45
|
"Eray Hanoglu <e.hanoglu@panates.com>",
|