rman 2.25.2 → 2.27.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.
|
@@ -90,6 +90,15 @@ export declare class NodeDependencyUpdater implements DependencyUpdater {
|
|
|
90
90
|
/** The in-repo packages `pkg` declares a dependency on. */
|
|
91
91
|
protected siblingsOf(pkg: Package, repoPackages: ReadonlyMap<string, Package>): Package[];
|
|
92
92
|
protected toEntry(d: NodeDependencyUpdater.Decision): DependencyUpdater.Entry;
|
|
93
|
+
/**
|
|
94
|
+
* The version of `name` that `pkg` resolves today: the first `node_modules/<name>/package.json`
|
|
95
|
+
* walking up from its directory, which is Node's own lookup - so a hoisted copy at a monorepo's
|
|
96
|
+
* root counts, and a nested one under the package wins over it.
|
|
97
|
+
*/
|
|
98
|
+
protected installedVersion(pkg: Package, name: string): string | undefined;
|
|
99
|
+
/** The newest release `range` takes, as npm's install would pick it: no prerelease unless the
|
|
100
|
+
* range asks for one, nothing above the `latest` tag, a deprecated one only when nothing else is. */
|
|
101
|
+
protected resolvedVersion(d: NodeDependencyUpdater.Decision, range: string): string | undefined;
|
|
93
102
|
protected manifestFile(pkg: Package): string;
|
|
94
103
|
/** `fn` over `items`, at most `limit` at a time. */
|
|
95
104
|
protected mapConcurrent<T>(items: readonly T[], limit: number, fn: (item: T) => Promise<void>): Promise<void>;
|
|
@@ -64,7 +64,18 @@ export class NodeDependencyUpdater {
|
|
|
64
64
|
for (const d of decisions)
|
|
65
65
|
this.prepare(d, registry.get(d.name));
|
|
66
66
|
this.resolve(decisions, ctx);
|
|
67
|
-
return decisions
|
|
67
|
+
return decisions
|
|
68
|
+
.filter(d => d.wanted || d.unmovable)
|
|
69
|
+
.map(d => {
|
|
70
|
+
/** Set on the entry itself, never a copy: `planned` is keyed by that object. */
|
|
71
|
+
const entry = this.toEntry(d);
|
|
72
|
+
entry.installed = this.installedVersion(d.pkg, d.name);
|
|
73
|
+
entry.resolved = this.resolvedVersion(d, entry.current);
|
|
74
|
+
if (entry.installed && semver.validRange(entry.current)) {
|
|
75
|
+
entry.installedInRange = semver.satisfies(entry.installed, entry.current, { includePrerelease: true });
|
|
76
|
+
}
|
|
77
|
+
return entry;
|
|
78
|
+
});
|
|
68
79
|
}
|
|
69
80
|
async applyPlan(ctx, plan) {
|
|
70
81
|
const originals = new Map();
|
|
@@ -506,6 +517,41 @@ export class NodeDependencyUpdater {
|
|
|
506
517
|
this.planned.set(result, d);
|
|
507
518
|
return result;
|
|
508
519
|
}
|
|
520
|
+
/**
|
|
521
|
+
* The version of `name` that `pkg` resolves today: the first `node_modules/<name>/package.json`
|
|
522
|
+
* walking up from its directory, which is Node's own lookup - so a hoisted copy at a monorepo's
|
|
523
|
+
* root counts, and a nested one under the package wins over it.
|
|
524
|
+
*/
|
|
525
|
+
installedVersion(pkg, name) {
|
|
526
|
+
let dir = pkg.dirname;
|
|
527
|
+
for (;;) {
|
|
528
|
+
const file = path.join(dir, 'node_modules', name, 'package.json');
|
|
529
|
+
if (fs.existsSync(file)) {
|
|
530
|
+
try {
|
|
531
|
+
const version = JSON.parse(fs.readFileSync(file, 'utf-8'))?.version;
|
|
532
|
+
return typeof version === 'string' ? version : undefined;
|
|
533
|
+
}
|
|
534
|
+
catch {
|
|
535
|
+
return undefined;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
const parent = path.dirname(dir);
|
|
539
|
+
if (parent === dir)
|
|
540
|
+
return undefined;
|
|
541
|
+
dir = parent;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
/** The newest release `range` takes, as npm's install would pick it: no prerelease unless the
|
|
545
|
+
* range asks for one, nothing above the `latest` tag, a deprecated one only when nothing else is. */
|
|
546
|
+
resolvedVersion(d, range) {
|
|
547
|
+
if (!d.releases || !semver.validRange(range))
|
|
548
|
+
return undefined;
|
|
549
|
+
const taken = [...d.releases.values()]
|
|
550
|
+
.filter(r => semver.satisfies(r.version, range))
|
|
551
|
+
.filter(r => !d.latestTag || !semver.valid(d.latestTag) || semver.lte(r.version, d.latestTag))
|
|
552
|
+
.sort((a, b) => semver.rcompare(a.version, b.version));
|
|
553
|
+
return (taken.find(r => !r.deprecated) ?? taken[0])?.version;
|
|
554
|
+
}
|
|
509
555
|
manifestFile(pkg) {
|
|
510
556
|
return path.join(pkg.dirname, 'package.json');
|
|
511
557
|
}
|
package/commands/deps.command.js
CHANGED
|
@@ -182,6 +182,9 @@ function jsonPlan(entries) {
|
|
|
182
182
|
types: e.types,
|
|
183
183
|
status: e.status,
|
|
184
184
|
current: e.current,
|
|
185
|
+
installed: e.installed,
|
|
186
|
+
installedInRange: e.installedInRange,
|
|
187
|
+
resolved: e.resolved,
|
|
185
188
|
target: e.target,
|
|
186
189
|
latest: e.latest,
|
|
187
190
|
available: e.available,
|
|
@@ -200,30 +203,40 @@ function jsonPlan(entries) {
|
|
|
200
203
|
* own settings leave the newer version out) or `error`. Moves first, smallest first, then the rest. */
|
|
201
204
|
function printPlan(entries, root) {
|
|
202
205
|
const updated = entries.filter(e => e.status === 'update');
|
|
203
|
-
const shown = entries.filter(e => e.status !== 'up-to-date');
|
|
206
|
+
const shown = entries.filter(e => e.status !== 'up-to-date' || reinstall(e));
|
|
204
207
|
/** Said first when nothing moves, so a run whose only rows are majors left behind does not read
|
|
205
208
|
* as a list of things to do. */
|
|
206
209
|
if (!updated.length) {
|
|
207
|
-
|
|
208
|
-
(shown.
|
|
210
|
+
const why = [
|
|
211
|
+
...(shown.some(e => e.status !== 'up-to-date')
|
|
212
|
+
? ['newer versions their settings leave out, or another rule holds back']
|
|
213
|
+
: []),
|
|
214
|
+
...(shown.some(reinstall) ? ['installed versions that differ from what the range takes'] : []),
|
|
215
|
+
];
|
|
216
|
+
console.log(colors.green('All dependencies are up to date') + (why.length ? colors.gray(` - ${why.join('; ')}:`) : '.'));
|
|
209
217
|
if (!shown.length)
|
|
210
218
|
return;
|
|
211
219
|
}
|
|
212
|
-
|
|
220
|
+
/** The upgrade last before the note, so the row reads from what is there to what it would become. */
|
|
221
|
+
const header = ['Dependency', 'Current', 'Installed', 'Latest', 'Change', 'Upgrade'];
|
|
213
222
|
const cells = (e) => [
|
|
214
223
|
e.name,
|
|
215
224
|
e.current,
|
|
216
|
-
e.
|
|
217
|
-
e.status === 'error' ? '-' : (e.available ?? e.latest ?? ''),
|
|
225
|
+
e.installed ?? '-',
|
|
226
|
+
e.status === 'error' ? '-' : (e.available ?? e.latest ?? e.resolved ?? ''),
|
|
218
227
|
changeOf(e),
|
|
228
|
+
e.status === 'update' ? (e.target ?? '') : '-',
|
|
219
229
|
];
|
|
230
|
+
const last = header.length - 1;
|
|
220
231
|
const widths = header.map((h, i) => Math.max(h.length, ...shown.map(e => cells(e)[i].length)));
|
|
221
232
|
/** Padded to the column, except a last value nothing follows - trailing spaces inside a colour
|
|
222
233
|
* code are past the reach of `trimEnd`. */
|
|
223
234
|
const line = (values, paint = text => text) => ' ' + values.map((v, i) => paint(i === values.length - 1 ? v : v.padEnd(widths[i]), i)).join(' ');
|
|
224
235
|
for (const pkg of [...new Set(shown.map(e => e.package))]) {
|
|
225
236
|
const sizes = pkg.versionScheme.bumpNames;
|
|
226
|
-
const rank = (e) => e.status === 'update'
|
|
237
|
+
const rank = (e) => e.status === 'update'
|
|
238
|
+
? sizes.indexOf(e.bump)
|
|
239
|
+
: sizes.length + ['held', 'skipped', 'error', 'up-to-date'].indexOf(e.status);
|
|
227
240
|
const rows = shown.filter(e => e.package === pkg).sort((x, y) => rank(x) - rank(y));
|
|
228
241
|
const where = path.relative(root, pkg.dirname);
|
|
229
242
|
console.log(colors.cyan(pkg.name) + (where ? colors.gray(` (${where})`) : ''));
|
|
@@ -231,16 +244,23 @@ function printPlan(entries, root) {
|
|
|
231
244
|
for (const e of rows) {
|
|
232
245
|
const paint = e.status === 'update' ? sizeColor(e.bump, sizes) : changeColor(e.status);
|
|
233
246
|
const values = cells(e);
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
247
|
+
const note = e.reason ?? (reinstall(e) ? `"${e.current}" takes ${e.resolved} - install again` : undefined);
|
|
248
|
+
if (note)
|
|
249
|
+
values[last] = values[last].padEnd(widths[last]);
|
|
250
|
+
const text = line(values, (v, column) => {
|
|
251
|
+
if (column === 2 && e.installedInRange === false)
|
|
252
|
+
return colors.red(v);
|
|
253
|
+
if (column === 3 && values[3] !== '-')
|
|
254
|
+
return reachesLatest(e) ? colors.green(v) : colors.yellow(v);
|
|
255
|
+
return column === 4 || column === 5 ? paint(v) : v;
|
|
256
|
+
});
|
|
257
|
+
if (!note) {
|
|
238
258
|
console.log(text);
|
|
239
259
|
continue;
|
|
240
260
|
}
|
|
241
261
|
const indent = 2 + widths.reduce((sum, w) => sum + w + 2, 0);
|
|
242
|
-
const
|
|
243
|
-
console.log(`${text} ${
|
|
262
|
+
const wrapped = wrapNote(note, process.stdout.isTTY ? process.stdout.columns - indent : 0);
|
|
263
|
+
console.log(`${text} ${wrapped.map(l => colors.gray(l)).join('\n' + ' '.repeat(indent))}`);
|
|
244
264
|
}
|
|
245
265
|
}
|
|
246
266
|
}
|
|
@@ -268,8 +288,36 @@ function wrapNote(note, width) {
|
|
|
268
288
|
}
|
|
269
289
|
/** What the `Change` column says: the size of the move, or why there is none. */
|
|
270
290
|
function changeOf(e) {
|
|
291
|
+
if (e.status === 'up-to-date')
|
|
292
|
+
return reinstall(e) ? 'install' : e.status;
|
|
271
293
|
return e.status === 'update' ? (e.bump ?? 'other') : e.status;
|
|
272
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* A range already at the newest version, with something else installed - a `node_modules` behind
|
|
297
|
+
* its manifest. Listed although nothing moves: hidden, it read as up to date while the code ran
|
|
298
|
+
* against the older version.
|
|
299
|
+
*/
|
|
300
|
+
function reinstall(e) {
|
|
301
|
+
return e.status === 'up-to-date' && installedDiffers(e);
|
|
302
|
+
}
|
|
303
|
+
/** What is installed is not what the declared range takes. */
|
|
304
|
+
function installedDiffers(e) {
|
|
305
|
+
return !!e.installed && !!e.resolved && e.installed !== e.resolved;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Whether this row ends on the newest version - an upgrade that goes all the way, or a range that
|
|
309
|
+
* already takes it. What the Latest column's colour says at a glance: green when it is reached,
|
|
310
|
+
* yellow when the row stops short of it (skipped, held, or an upgrade cut short), so a reader need
|
|
311
|
+
* not go to the note to tell the two apart.
|
|
312
|
+
*/
|
|
313
|
+
/* **Installed is red only outside the declared range**, never merely behind the newest: a lockfile
|
|
314
|
+
* pinning an older version inside the range is the ordinary state of every row that moves, and
|
|
315
|
+
* colouring it would light up the whole column - the user's first version, yellow everywhere. */
|
|
316
|
+
function reachesLatest(e) {
|
|
317
|
+
if (e.status === 'update')
|
|
318
|
+
return !e.reason;
|
|
319
|
+
return e.status === 'up-to-date';
|
|
320
|
+
}
|
|
273
321
|
/** `held` and `skipped` in yellow, an error in red - a row with no move to colour by size. */
|
|
274
322
|
function changeColor(status) {
|
|
275
323
|
return status === 'error' ? colors.red : colors.yellow;
|
package/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.27.0';
|
|
@@ -76,6 +76,15 @@ export declare namespace DependencyUpdater {
|
|
|
76
76
|
types: string[];
|
|
77
77
|
/** The range as the manifest declares it. */
|
|
78
78
|
current: string;
|
|
79
|
+
/** The version installed now, as the package would resolve it - unset when it is not
|
|
80
|
+
* installed, or the ecosystem cannot say. */
|
|
81
|
+
installed?: string;
|
|
82
|
+
/** Whether `installed` is one the declared range accepts - `false` means the installed copy
|
|
83
|
+
* is not what the manifest says, and an install is due. Unset when nothing is installed. */
|
|
84
|
+
installedInRange?: boolean;
|
|
85
|
+
/** The newest version the declared range takes - what an install would put there. An
|
|
86
|
+
* `'up-to-date'` entry whose `installed` differs from it is still listed. */
|
|
87
|
+
resolved?: string;
|
|
79
88
|
status: 'update' | 'held' | 'skipped' | 'up-to-date' | 'error';
|
|
80
89
|
/** The range it is rewritten to, on an `'update'`. */
|
|
81
90
|
target?: string;
|