rman 2.33.0 → 2.34.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.
|
@@ -5,9 +5,10 @@ import { type NpmRelease, type NpmReleases } from '../../publish-targets/npm/npm
|
|
|
5
5
|
* npm's answer to `rman deps`: which of a `package.json`'s dependencies have a newer version on the
|
|
6
6
|
* registry, and which of those can be taken without breaking a rule another dependency states.
|
|
7
7
|
*
|
|
8
|
-
* Only a caret or tilde range on a plain version moves (`^1.2.3`, `~1.2.3`), keeping its prefix
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Only a caret or tilde range on a plain version moves (`^1.2.3`, `~1.2.3`), keeping its prefix -
|
|
9
|
+
* an npm alias of one too (`npm:@scope/real@^1.2.3`), asked about under the package it names. An
|
|
10
|
+
* exact version, a compound range (`>=1 <2`, `a || b`), a dist-tag, a URL and an in-repo package
|
|
11
|
+
* are left as they are - but every one of them still counts as a rule the others must keep.
|
|
11
12
|
*/
|
|
12
13
|
export declare class NodeDependencyUpdater implements DependencyUpdater {
|
|
13
14
|
/** `.rmanrc "deps.types"`'s short spellings, as `npm-check-updates` named them. The field names
|
|
@@ -90,10 +91,22 @@ export declare class NodeDependencyUpdater implements DependencyUpdater {
|
|
|
90
91
|
/** The newest release `d`'s declarations already allow - what an install picks if `d` does not
|
|
91
92
|
* move. */
|
|
92
93
|
protected resolvedDeclared(d: NodeDependencyUpdater.Decision): string | undefined;
|
|
93
|
-
/** What `d` declares in `field` once it has moved. */
|
|
94
94
|
/** Whether `line` names `token` (`name@version`) whole - not `1.2.3` inside `1.2.30`. */
|
|
95
95
|
protected mentions(line: string, token: string): boolean;
|
|
96
|
+
/** What `d` declares in `field` once it has moved - the range alone, an alias's `npm:<name>@`
|
|
97
|
+
* left off, which is what every rule compares. */
|
|
96
98
|
protected rangeFor(d: NodeDependencyUpdater.Decision, field: string): string;
|
|
99
|
+
/** The name `d`'s versions are asked under - the package an alias names, else its own. */
|
|
100
|
+
protected sourceOf(d: NodeDependencyUpdater.Decision): string;
|
|
101
|
+
/** What `field` holds once `d` has moved, as the manifest spells it - an alias keeps its
|
|
102
|
+
* `npm:<name>@`. */
|
|
103
|
+
protected writtenFor(d: NodeDependencyUpdater.Decision, field: string): string;
|
|
104
|
+
/** `npm:<name>@<range>`, npm's alias form, as the package it names and the range - or `undefined`
|
|
105
|
+
* for anything else. */
|
|
106
|
+
protected aliasOf(value: string): {
|
|
107
|
+
source: string;
|
|
108
|
+
range: string;
|
|
109
|
+
} | undefined;
|
|
97
110
|
/** The in-repo packages `pkg` declares a dependency on. */
|
|
98
111
|
protected siblingsOf(pkg: Package, repoPackages: ReadonlyMap<string, Package>): Package[];
|
|
99
112
|
protected toEntry(d: NodeDependencyUpdater.Decision): DependencyUpdater.Entry;
|
|
@@ -116,8 +129,14 @@ export declare namespace NodeDependencyUpdater {
|
|
|
116
129
|
pkg: Package;
|
|
117
130
|
name: string;
|
|
118
131
|
settings: DependencyUpdater.Settings;
|
|
119
|
-
/** Every field declaring the name, and its range there
|
|
132
|
+
/** Every field declaring the name, and its range there - an alias's range, its `npm:<name>@`
|
|
133
|
+
* kept in `aliases`. */
|
|
120
134
|
fields: Map<string, string>;
|
|
135
|
+
/** The fields declaring the name as an npm alias, and the `npm:<name>@` they write in front. */
|
|
136
|
+
aliases: Map<string, string>;
|
|
137
|
+
/** The package an alias names, whose versions every field of this name is held to - an alias
|
|
138
|
+
* is what installs, so a plain peer range beside it is satisfied by that package. */
|
|
139
|
+
source?: string;
|
|
121
140
|
/** The fields whose range is rewritten. */
|
|
122
141
|
movable: string[];
|
|
123
142
|
/** The fields holding a valid range rman does not rewrite - a pinned version, `>=a <b`. */
|
|
@@ -14,10 +14,17 @@ import { parseWorkspaceRange } from './utils/workspace-range.js';
|
|
|
14
14
|
* npm's answer to `rman deps`: which of a `package.json`'s dependencies have a newer version on the
|
|
15
15
|
* registry, and which of those can be taken without breaking a rule another dependency states.
|
|
16
16
|
*
|
|
17
|
-
* Only a caret or tilde range on a plain version moves (`^1.2.3`, `~1.2.3`), keeping its prefix
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* Only a caret or tilde range on a plain version moves (`^1.2.3`, `~1.2.3`), keeping its prefix -
|
|
18
|
+
* an npm alias of one too (`npm:@scope/real@^1.2.3`), asked about under the package it names. An
|
|
19
|
+
* exact version, a compound range (`>=1 <2`, `a || b`), a dist-tag, a URL and an in-repo package
|
|
20
|
+
* are left as they are - but every one of them still counts as a rule the others must keep.
|
|
20
21
|
*/
|
|
22
|
+
/* **Aliases were skipped outright, and silently**: `npm:...` is no semver range, so the field was
|
|
23
|
+
* neither moved nor listed. Measured on `abisena/syncbridge-iomt`, whose host modules are a peer
|
|
24
|
+
* `"@syncbridge/hl7": "^2.0.0"` beside a dev `"npm:@sbext/syncbridge__hl7@^2.0.0"` from a mirror:
|
|
25
|
+
* the alias never appeared, and the peer was asked of npmjs.org under its own name, which stops at
|
|
26
|
+
* 1.2.1 - so a 2.1.0 on the mirror would have read "up to date". The alias is what installs, so the
|
|
27
|
+
* whole name is held to the package it names, and the peer moves with it. */
|
|
21
28
|
/* **The default is the policy every `.ncurc.yml` in this organization wrote by hand.** Twenty
|
|
22
29
|
* repositories carried the same `rejectVersion: "/(\|\|)|(&&)|>|<|^[0-9]/"` - no `||`, no `&&`, no
|
|
23
30
|
* comparator, no bare version - which leaves exactly a `^` or `~` range. Built in, it is a line
|
|
@@ -62,7 +69,7 @@ export class NodeDependencyUpdater {
|
|
|
62
69
|
const withTime = decisions.some(d => d.settings.minAge > 0);
|
|
63
70
|
const registry = await this.fetchAll(ctx, decisions, withTime);
|
|
64
71
|
for (const d of decisions)
|
|
65
|
-
this.prepare(d, registry.get(d
|
|
72
|
+
this.prepare(d, registry.get(this.sourceOf(d)));
|
|
66
73
|
this.resolve(decisions, ctx);
|
|
67
74
|
return decisions
|
|
68
75
|
.filter(d => d.wanted || d.unmovable)
|
|
@@ -87,8 +94,8 @@ export class NodeDependencyUpdater {
|
|
|
87
94
|
if (!originals.has(d.pkg))
|
|
88
95
|
originals.set(d.pkg, fs.readFileSync(this.manifestFile(d.pkg), 'utf-8'));
|
|
89
96
|
for (const field of d.movable) {
|
|
90
|
-
|
|
91
|
-
|
|
97
|
+
d.pkg.manifest.raw[field][d.name] =
|
|
98
|
+
(d.aliases.get(field) ?? '') + this.movablePattern.exec(d.fields.get(field))[1] + version;
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
101
|
for (const pkg of originals.keys())
|
|
@@ -142,21 +149,39 @@ export class NodeDependencyUpdater {
|
|
|
142
149
|
* tree around it. The `Could not resolve dependency:` line is npm's own verdict - measured on the
|
|
143
150
|
* `@hookform/resolvers` case it reads `peerOptional effect@"^4.0.0" from @hookform/resolvers@6.0.0`
|
|
144
151
|
* - so a move it names is the one to hold, and the others it merely passes through stay. That line
|
|
145
|
-
* sat past the 20 lines `verify` used to keep, which is why it now keeps them all.
|
|
152
|
+
* sat past the 20 lines `verify` used to keep, which is why it now keeps them all.
|
|
153
|
+
*
|
|
154
|
+
* **The range form is the other name npm uses**, and missing it misattributed the hold: measured on
|
|
155
|
+
* `abisena/syncbridge-iomt`, the verdict read `dev @syncbridge/syncbuild@"^2.2.0" from the root
|
|
156
|
+
* project`, matched nothing, and every move the output mentioned anywhere was held under that one
|
|
157
|
+
* line - `@syncbridge/testing` included, with syncbuild's reason. */
|
|
146
158
|
blame(refusal, plan) {
|
|
147
159
|
const moves = plan.flatMap(entry => {
|
|
148
160
|
const d = this.planned.get(entry);
|
|
149
|
-
|
|
161
|
+
if (entry.status !== 'update' || !d)
|
|
162
|
+
return [];
|
|
163
|
+
/** npm names a move two ways: at the version it resolved (`from x@2.2.0`) and as the range a
|
|
164
|
+
* manifest declares (`dev x@"^2.2.0" from the root project`). */
|
|
165
|
+
const tokens = [
|
|
166
|
+
`${d.name}@${d.candidates[d.index]}`,
|
|
167
|
+
...d.movable.map(f => `${d.name}@"${this.writtenFor(d, f)}"`),
|
|
168
|
+
];
|
|
169
|
+
return [{ entry, tokens }];
|
|
150
170
|
});
|
|
171
|
+
const names = (line, m) => m.tokens.some(t => this.mentions(line, t));
|
|
151
172
|
const lines = refusal.split('\n').map(line => line.trim());
|
|
152
173
|
const at = lines.indexOf('Could not resolve dependency:');
|
|
153
174
|
const verdict = at >= 0 ? lines.slice(at + 1).find(Boolean) : undefined;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
175
|
+
/** What it conflicts with, when npm says - the half of the verdict that explains it. */
|
|
176
|
+
const conflict = lines.find(l => l.startsWith('Conflicting peer dependency:'));
|
|
177
|
+
const named = verdict ? moves.filter(m => names(verdict, m)) : [];
|
|
178
|
+
if (named.length) {
|
|
179
|
+
const reason = `npm cannot install it: ${verdict}${conflict ? ` - ${conflict}` : ''}`;
|
|
180
|
+
return named.map(m => ({ entry: m.entry, reason }));
|
|
181
|
+
}
|
|
157
182
|
return moves.flatMap(m => {
|
|
158
|
-
const line = lines.find(l =>
|
|
159
|
-
return line ? [{ entry: m.entry, reason: `npm cannot install it: ${
|
|
183
|
+
const line = lines.find(l => names(l, m));
|
|
184
|
+
return line ? [{ entry: m.entry, reason: `npm cannot install it: ${line}` }] : [];
|
|
160
185
|
});
|
|
161
186
|
}
|
|
162
187
|
/** One decision per dependency name `pkg` declares, whether or not it may move - one that may not
|
|
@@ -168,8 +193,8 @@ export class NodeDependencyUpdater {
|
|
|
168
193
|
const declared = pkg.manifest.raw[field];
|
|
169
194
|
if (!declared || typeof declared !== 'object')
|
|
170
195
|
continue;
|
|
171
|
-
for (const [name,
|
|
172
|
-
if (typeof
|
|
196
|
+
for (const [name, value] of Object.entries(declared)) {
|
|
197
|
+
if (typeof value !== 'string' || inRepo.has(name) || parseWorkspaceRange(value))
|
|
173
198
|
continue;
|
|
174
199
|
let d = byName.get(name);
|
|
175
200
|
if (!d) {
|
|
@@ -178,6 +203,7 @@ export class NodeDependencyUpdater {
|
|
|
178
203
|
name,
|
|
179
204
|
settings,
|
|
180
205
|
fields: new Map(),
|
|
206
|
+
aliases: new Map(),
|
|
181
207
|
movable: [],
|
|
182
208
|
fixed: [],
|
|
183
209
|
wanted: false,
|
|
@@ -187,6 +213,17 @@ export class NodeDependencyUpdater {
|
|
|
187
213
|
};
|
|
188
214
|
byName.set(name, d);
|
|
189
215
|
}
|
|
216
|
+
/** An alias is the range of the package it names: its versions are that package's, so the
|
|
217
|
+
* rules compare the range and the rewrite keeps the `npm:<name>@` in front. */
|
|
218
|
+
/** Two fields aliasing one name to different packages have no one version list to share -
|
|
219
|
+
* the second is left as written, which no rule moves. */
|
|
220
|
+
const parsed = this.aliasOf(value);
|
|
221
|
+
const alias = parsed && (!d.source || d.source === parsed.source) ? parsed : undefined;
|
|
222
|
+
if (alias) {
|
|
223
|
+
d.source = alias.source;
|
|
224
|
+
d.aliases.set(field, `npm:${alias.source}@`);
|
|
225
|
+
}
|
|
226
|
+
const range = alias ? alias.range : value;
|
|
190
227
|
d.fields.set(field, range);
|
|
191
228
|
if (kinds && !kinds.includes(field))
|
|
192
229
|
continue;
|
|
@@ -212,13 +249,14 @@ export class NodeDependencyUpdater {
|
|
|
212
249
|
async fetchAll(ctx, decisions, withTime) {
|
|
213
250
|
const floors = new Map();
|
|
214
251
|
for (const d of decisions) {
|
|
252
|
+
const source = this.sourceOf(d);
|
|
215
253
|
for (const range of d.fields.values()) {
|
|
216
254
|
const min = semver.validRange(range) ? semver.minVersion(range)?.version : undefined;
|
|
217
255
|
if (!min)
|
|
218
256
|
continue;
|
|
219
|
-
const known = floors.get(
|
|
257
|
+
const known = floors.get(source);
|
|
220
258
|
if (!known || semver.lt(min, known))
|
|
221
|
-
floors.set(
|
|
259
|
+
floors.set(source, min);
|
|
222
260
|
}
|
|
223
261
|
}
|
|
224
262
|
const names = [...floors.keys()];
|
|
@@ -480,18 +518,34 @@ export class NodeDependencyUpdater {
|
|
|
480
518
|
.filter(v => ranges.every(r => semver.satisfies(v, r)))
|
|
481
519
|
.sort(semver.rcompare)[0];
|
|
482
520
|
}
|
|
483
|
-
/** What `d` declares in `field` once it has moved. */
|
|
484
521
|
/** Whether `line` names `token` (`name@version`) whole - not `1.2.3` inside `1.2.30`. */
|
|
485
522
|
mentions(line, token) {
|
|
486
523
|
const escaped = token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
487
524
|
return new RegExp(`(^|[\\s"'(])${escaped}(?![\\w.+-])`).test(line);
|
|
488
525
|
}
|
|
526
|
+
/** What `d` declares in `field` once it has moved - the range alone, an alias's `npm:<name>@`
|
|
527
|
+
* left off, which is what every rule compares. */
|
|
489
528
|
rangeFor(d, field) {
|
|
490
529
|
const declared = d.fields.get(field) ?? '';
|
|
491
530
|
if (d.index < 0 || !d.movable.includes(field))
|
|
492
531
|
return declared;
|
|
493
532
|
return this.movablePattern.exec(declared)[1] + d.candidates[d.index];
|
|
494
533
|
}
|
|
534
|
+
/** The name `d`'s versions are asked under - the package an alias names, else its own. */
|
|
535
|
+
sourceOf(d) {
|
|
536
|
+
return d.source ?? d.name;
|
|
537
|
+
}
|
|
538
|
+
/** What `field` holds once `d` has moved, as the manifest spells it - an alias keeps its
|
|
539
|
+
* `npm:<name>@`. */
|
|
540
|
+
writtenFor(d, field) {
|
|
541
|
+
return (d.aliases.get(field) ?? '') + this.rangeFor(d, field);
|
|
542
|
+
}
|
|
543
|
+
/** `npm:<name>@<range>`, npm's alias form, as the package it names and the range - or `undefined`
|
|
544
|
+
* for anything else. */
|
|
545
|
+
aliasOf(value) {
|
|
546
|
+
const match = /^npm:((?:@[^/@\s]+\/)?[^@\s]+)@(.+)$/.exec(value);
|
|
547
|
+
return match ? { source: match[1], range: match[2] } : undefined;
|
|
548
|
+
}
|
|
495
549
|
/** The in-repo packages `pkg` declares a dependency on. */
|
|
496
550
|
siblingsOf(pkg, repoPackages) {
|
|
497
551
|
const result = new Set();
|
|
@@ -522,7 +576,7 @@ export class NodeDependencyUpdater {
|
|
|
522
576
|
package: d.pkg,
|
|
523
577
|
name: d.name,
|
|
524
578
|
types: [...d.fields.keys()],
|
|
525
|
-
current: d.fields.get(d.movable[0]),
|
|
579
|
+
current: (d.aliases.get(d.movable[0]) ?? '') + d.fields.get(d.movable[0]),
|
|
526
580
|
status: 'up-to-date',
|
|
527
581
|
latest: d.allowed[0],
|
|
528
582
|
available: d.available,
|
|
@@ -539,7 +593,7 @@ export class NodeDependencyUpdater {
|
|
|
539
593
|
const result = {
|
|
540
594
|
...entry,
|
|
541
595
|
status: 'update',
|
|
542
|
-
target: this.
|
|
596
|
+
target: this.writtenFor(d, d.movable[0]),
|
|
543
597
|
bump: this.sizeOf(d.floor, version),
|
|
544
598
|
/** What stopped it short of `available`, if anything did - another rule first, since that is
|
|
545
599
|
* the nearer reason. */
|
package/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.34.0';
|