rman 2.45.0 → 2.46.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.
@@ -18,6 +18,9 @@ export declare class NodeDependencyUpdater implements DependencyUpdater {
18
18
  protected readonly kindAliases: Readonly<Record<string, string>>;
19
19
  /** The ranges that move: `^` or `~`, then a plain version. The prefix is kept on the rewrite. */
20
20
  protected readonly movablePattern: RegExp;
21
+ /** Files beside a `package.json` whose `dependencies` block names ranges another tool checks
22
+ * against that package's own declarations - a name listed there is held where it is. */
23
+ protected readonly pinFiles: readonly string[];
21
24
  /** The plan each `'update'` entry was made from, for `applyPlan`. */
22
25
  protected readonly planned: WeakMap<DependencyUpdater.Entry, NodeDependencyUpdater.Decision>;
23
26
  /** The first pnpm whose `install` takes `--dry-run`; an older one is not asked. */
@@ -102,6 +105,12 @@ export declare class NodeDependencyUpdater implements DependencyUpdater {
102
105
  /** One decision per dependency name `pkg` declares, whether or not it may move - one that may not
103
106
  * still states rules the others have to keep. */
104
107
  protected collect(pkg: Package, settings: DependencyUpdater.Settings, options: DependencyUpdater.Options, inRepo: ReadonlySet<string>): NodeDependencyUpdater.Decision[];
108
+ /**
109
+ * The dependency names a file in `pinFiles` beside `pkg`'s `package.json` names in its
110
+ * `dependencies`, each with the reason to show - those stay as declared. Empty when there is no
111
+ * such file, or it cannot be read.
112
+ */
113
+ protected pinnedElsewhere(pkg: Package): Map<string, string>;
105
114
  /** Every name's releases, from the lowest version any declaration of it can mean - once per name,
106
115
  * however many packages declare it, `concurrency` at a time. */
107
116
  protected fetchAll(ctx: DependencyUpdater.Context, decisions: readonly NodeDependencyUpdater.Decision[], withTime: boolean): Promise<Map<string, NpmReleases | undefined>>;
@@ -214,6 +223,10 @@ export declare namespace NodeDependencyUpdater {
214
223
  movable: string[];
215
224
  /** The fields holding a valid range rman does not rewrite - a pinned version, `>=a <b`. */
216
225
  fixed: string[];
226
+ /** Why the name stays as declared whatever the registry offers - `deps.reject`, or a file
227
+ * beside the manifest that names its range (`pinnedElsewhere`). Listed as `'skipped'` with
228
+ * this as the reason, and still a rule for the others at its declared version. */
229
+ heldBy?: string;
217
230
  /** Not planned, but listed when a release falls outside a `fixed` range - see `outgrown`. */
218
231
  listed?: boolean;
219
232
  /** That release, and the range it falls outside. */
@@ -62,6 +62,15 @@ export class NodeDependencyUpdater {
62
62
  };
63
63
  /** The ranges that move: `^` or `~`, then a plain version. The prefix is kept on the rewrite. */
64
64
  movablePattern = /^([\^~])(\d+(?:\.\d+){0,2}(?:-[0-9A-Za-z.-]+)?)$/;
65
+ /** Files beside a `package.json` whose `dependencies` block names ranges another tool checks
66
+ * against that package's own declarations - a name listed there is held where it is. */
67
+ /* **SyncBridge's `syncbridge-manifest.json`**, reported by `abisena/syncbridge-iomt`: it names the
68
+ * host modules a package needs (`"@syncbridge/builtins": "^2.2.1"`, the minimum the sites' engines
69
+ * must run), and `spm add` writes a devDependency alias carrying exactly that range for the types
70
+ * (`"npm:@sbext/syncbridge__builtins@^2.2.1"`). `spm build` refuses the package when the two
71
+ * differ, so `deps -u` raising the alias to `^2.3.1` broke the build every run - and raising the
72
+ * manifest instead would demand newer engines on every site. The range is the manifest's to set. */
73
+ pinFiles = ['syncbridge-manifest.json'];
65
74
  /** The plan each `'update'` entry was made from, for `applyPlan`. */
66
75
  planned = new WeakMap();
67
76
  /** The first pnpm whose `install` takes `--dry-run`; an older one is not asked. */
@@ -533,17 +542,44 @@ export class NodeDependencyUpdater {
533
542
  d.fixed.push(field);
534
543
  }
535
544
  }
545
+ const pinned = this.pinnedElsewhere(pkg);
536
546
  for (const d of byName.values()) {
537
547
  const picked = !options.names?.length || micromatch.isMatch(d.name, options.names);
538
- const rejected = settings.reject.length > 0 && micromatch.isMatch(d.name, settings.reject);
539
- d.wanted = d.movable.length > 0 && picked && !rejected;
540
- d.listed = !d.wanted && d.fixed.length > 0 && picked && !rejected;
548
+ const rejected = settings.reject.find(glob => micromatch.isMatch(d.name, glob));
549
+ d.heldBy = rejected !== undefined ? `deps.reject names it ("${rejected}")` : pinned.get(d.name);
550
+ d.wanted = d.movable.length > 0 && picked;
551
+ d.listed = !d.wanted && d.fixed.length > 0 && picked;
541
552
  if (d.wanted) {
542
553
  d.floor = d.movable.map(f => semver.minVersion(d.fields.get(f)).version).sort(semver.rcompare)[0];
543
554
  }
544
555
  }
545
556
  return [...byName.values()];
546
557
  }
558
+ /**
559
+ * The dependency names a file in `pinFiles` beside `pkg`'s `package.json` names in its
560
+ * `dependencies`, each with the reason to show - those stay as declared. Empty when there is no
561
+ * such file, or it cannot be read.
562
+ */
563
+ pinnedElsewhere(pkg) {
564
+ const result = new Map();
565
+ for (const file of this.pinFiles) {
566
+ let deps;
567
+ try {
568
+ deps = JSON.parse(fs.readFileSync(path.join(pkg.dirname, file), 'utf-8'))?.dependencies;
569
+ }
570
+ catch {
571
+ continue;
572
+ }
573
+ if (!deps || typeof deps !== 'object')
574
+ continue;
575
+ for (const [name, range] of Object.entries(deps)) {
576
+ if (!result.has(name)) {
577
+ result.set(name, `held by ${file}` + (typeof range === 'string' ? ` (${range})` : ''));
578
+ }
579
+ }
580
+ }
581
+ return result;
582
+ }
547
583
  /** Every name's releases, from the lowest version any declaration of it can mean - once per name,
548
584
  * however many packages declare it, `concurrency` at a time. */
549
585
  async fetchAll(ctx, decisions, withTime) {
@@ -581,6 +617,12 @@ export class NodeDependencyUpdater {
581
617
  d.unmovable = this.outgrown(d, info.releases);
582
618
  if (!d.wanted)
583
619
  return;
620
+ /** A held name was never going to move, so a registry with nothing to say about it is no
621
+ * error - the row is dropped instead. */
622
+ if (!info && d.heldBy) {
623
+ d.wanted = false;
624
+ return;
625
+ }
584
626
  if (!info) {
585
627
  d.error = 'the registry gave no answer';
586
628
  return;
@@ -589,6 +631,10 @@ export class NodeDependencyUpdater {
589
631
  .filter(r => this.offerable(d, r))
590
632
  .sort((a, b) => semver.rcompare(a.version, b.version));
591
633
  d.available = newer[0]?.version;
634
+ if (d.heldBy) {
635
+ d.skipReason = d.heldBy;
636
+ return;
637
+ }
592
638
  d.allowed = newer.filter(r => !this.settingRefusal(d, r, info.time)).map(r => r.version);
593
639
  if (d.available && d.available !== d.allowed[0]) {
594
640
  d.skipReason = this.settingRefusal(d, newer[0], info.time);
@@ -896,7 +942,7 @@ export class NodeDependencyUpdater {
896
942
  status: 'skipped',
897
943
  latest: version,
898
944
  available: version,
899
- reason: 'not a ^ or ~ range - rman moves only those',
945
+ reason: d.heldBy ?? 'not a ^ or ~ range - rman moves only those',
900
946
  };
901
947
  }
902
948
  /** A range rman does not move whose newest release it still takes: nothing to write, and listed
@@ -41,9 +41,11 @@ export declare class NodeManifestProvider implements ManifestProvider {
41
41
  * the range with its floor raised to it - see `ManifestProvider.referencesTo`.
42
42
  *
43
43
  * A bare `"workspace:*"`/`"^"`/`"~"` is `dynamic`: it already follows the sibling, so there is
44
- * nothing to keep or raise. An explicit `"workspace:<range>"` is judged by the range after it.
44
+ * nothing to keep or raise. Given `current`, it is judged as what publishing wrote for it -
45
+ * `^current`, `~current`, or `current` itself for `*`. An explicit `"workspace:<range>"` is judged
46
+ * by the range after it.
45
47
  */
46
- referencesTo(manifest: Manifest, dependency: string, version: string): ManifestProvider.Reference[];
48
+ referencesTo(manifest: Manifest, dependency: string, version: string, current?: string): ManifestProvider.Reference[];
47
49
  setReference(manifest: Manifest, field: string, dependency: string, range: string): void;
48
50
  /**
49
51
  * What the npm registry says this package's current version is - used *only* by
@@ -4,7 +4,7 @@ import semver from 'semver';
4
4
  import { Manifest } from '../../../core/interfaces/manifest.js';
5
5
  import { stampVersionConstant } from '../../../utils/version-stamp.js';
6
6
  import { npmViewVersion } from '../../publish-targets/npm/npm-view.js';
7
- import { parseWorkspaceRange } from './utils/workspace-range.js';
7
+ import { parseWorkspaceRange, resolveWorkspaceRange } from './utils/workspace-range.js';
8
8
  export class NodeManifestProvider {
9
9
  name = 'node';
10
10
  fileName = 'package.json';
@@ -117,9 +117,16 @@ export class NodeManifestProvider {
117
117
  * the range with its floor raised to it - see `ManifestProvider.referencesTo`.
118
118
  *
119
119
  * A bare `"workspace:*"`/`"^"`/`"~"` is `dynamic`: it already follows the sibling, so there is
120
- * nothing to keep or raise. An explicit `"workspace:<range>"` is judged by the range after it.
120
+ * nothing to keep or raise. Given `current`, it is judged as what publishing wrote for it -
121
+ * `^current`, `~current`, or `current` itself for `*`. An explicit `"workspace:<range>"` is judged
122
+ * by the range after it.
121
123
  */
122
- referencesTo(manifest, dependency, version) {
124
+ /* **Judged, because a dynamic reference left unjudged released every dependent.** Measured on
125
+ * `syncbridge-io/syncbridge-extensions` (rman 2.46.0, `dependentRanges: keep`): builtins
126
+ * 2.3.1 -> 2.4.0 released all seven extensions declaring it as `"workspace:^"`, though each one's
127
+ * published `^2.3.1` already takes 2.4.0 - with no range to check, `keep` said nothing and the
128
+ * ripple released them. `*` publishes an exact version, so it still refuses every new one. */
129
+ referencesTo(manifest, dependency, version, current) {
123
130
  const refs = [];
124
131
  for (const field of DEPENDENCY_KEYS) {
125
132
  const declared = manifest.raw[field]?.[dependency];
@@ -127,7 +134,9 @@ export class NodeManifestProvider {
127
134
  continue;
128
135
  const workspace = parseWorkspaceRange(declared);
129
136
  if (workspace && workspace.selector !== 'explicit') {
130
- refs.push({ field, range: declared, dynamic: true, accepts: true });
137
+ const publishedAs = current ? resolveWorkspaceRange(workspace, current) : undefined;
138
+ const accepts = !publishedAs || semver.satisfies(version, publishedAs);
139
+ refs.push({ field, range: declared, dynamic: true, accepts, ...(publishedAs ? { publishedAs } : {}) });
131
140
  continue;
132
141
  }
133
142
  const range = workspace ? workspace.range : declared;
package/constants.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.45.0';
1
+ export const version = '2.46.1';
@@ -172,6 +172,9 @@ export interface ManifestProvider {
172
172
  * it, each judged against `version` - whether the range written there accepts it, and the range
173
173
  * with its lower bound raised to it.
174
174
  *
175
+ * `current` is the version `dependency` has now. Given, a reference that follows the dependency by
176
+ * itself is judged too, as the range it was published with (`publishedAs`).
177
+ *
175
178
  * What `.rmanrc "version.dependentRanges": keep` asks instead of `updateDependencyVersions`: a
176
179
  * hand-written range is left alone while it accepts the new version, moved to accept it when it
177
180
  * does not, and has its floor raised when the package holding it is released for reasons of its
@@ -179,7 +182,7 @@ export interface ManifestProvider {
179
182
  *
180
183
  * Omit it and a package has no ranges to keep, so `keep` behaves like `rewrite` for it.
181
184
  */
182
- referencesTo?(manifest: Manifest, dependency: string, version: string): ManifestProvider.Reference[];
185
+ referencesTo?(manifest: Manifest, dependency: string, version: string, current?: string): ManifestProvider.Reference[];
183
186
  /**
184
187
  * Writes `range` as this manifest's reference to `dependency` in `field` - one of the fields
185
188
  * `referencesTo` reported. Mutates `manifest.raw`, like `updateDependencyVersions`.
@@ -193,9 +196,13 @@ export declare namespace ManifestProvider {
193
196
  field: string;
194
197
  /** The range as written. */
195
198
  range: string;
196
- /** It follows the dependency by itself (npm's bare `"workspace:^"`) - always accepts, never
197
- * rewritten, and keeps `rewrite`'s handling under `keep` too. */
199
+ /** It follows the dependency by itself (npm's bare `"workspace:^"`) - never rewritten or
200
+ * raised. `accepts` is `true` unless `publishedAs` says otherwise. */
198
201
  dynamic?: boolean;
202
+ /** For a `dynamic` reference, when `referencesTo` was given the dependency's `current` version:
203
+ * the range a registry consumer sees - `"workspace:^"` against 2.3.1 is `^2.3.1` - and
204
+ * `accepts` is judged against it. */
205
+ publishedAs?: string;
199
206
  /** Whether the range accepts the version asked about. */
200
207
  accepts: boolean;
201
208
  /** The range with its lower bound raised to the version asked about, when that moves it.
@@ -271,7 +278,7 @@ export declare namespace Manifest {
271
278
  function updateDependencyVersions(pkg: Package, bumped: ReadonlyMap<Package, string>): void;
272
279
  /** `pkg`'s references to `dependency`, judged against `version` - see
273
280
  * `ManifestProvider.referencesTo`. Empty where the provider has no opinion. */
274
- function referencesTo(pkg: Package, dependency: string, version: string): ManifestProvider.Reference[];
281
+ function referencesTo(pkg: Package, dependency: string, version: string, current?: string): ManifestProvider.Reference[];
275
282
  /** Writes one of `pkg`'s references - see `ManifestProvider.setReference`. */
276
283
  function setReference(pkg: Package, field: string, dependency: string, range: string): void;
277
284
  /**
@@ -97,8 +97,8 @@ export var Manifest;
97
97
  Manifest.updateDependencyVersions = updateDependencyVersions;
98
98
  /** `pkg`'s references to `dependency`, judged against `version` - see
99
99
  * `ManifestProvider.referencesTo`. Empty where the provider has no opinion. */
100
- function referencesTo(pkg, dependency, version) {
101
- return platformOf(pkg)?.manifestProvider.referencesTo?.(pkg.manifest, dependency, version) ?? [];
100
+ function referencesTo(pkg, dependency, version, current) {
101
+ return platformOf(pkg)?.manifestProvider.referencesTo?.(pkg.manifest, dependency, version, current) ?? [];
102
102
  }
103
103
  Manifest.referencesTo = referencesTo;
104
104
  /** Writes one of `pkg`'s references - see `ManifestProvider.setReference`. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rman",
3
3
  "description": "Repository manager",
4
- "version": "2.45.0",
4
+ "version": "2.46.1",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
@@ -409,7 +409,9 @@ export class VersionPlanService {
409
409
  rangeVerdict(dependent, dependency, version) {
410
410
  if (dependent.config?.version?.dependentRanges !== 'keep')
411
411
  return undefined;
412
- const refs = Manifest.referencesTo(dependent, dependency.name, version).filter(r => !r.dynamic);
412
+ /** A dynamic reference counts once it is judged as what was published for it (`publishedAs`) -
413
+ * `"workspace:^"` against the dependency's current version. */
414
+ const refs = Manifest.referencesTo(dependent, dependency.name, version, dependency.version).filter(r => !r.dynamic || r.publishedAs);
413
415
  if (!refs.length)
414
416
  return undefined;
415
417
  if (dependency.versionScheme.isPrerelease(version))
@@ -442,9 +444,19 @@ export class VersionPlanService {
442
444
  for (const dep of pkg.dependencies) {
443
445
  const depEntry = entries.get(dep.name);
444
446
  const version = depEntry?.status === 'bump' ? depEntry.to : dep.version;
445
- const refs = Manifest.referencesTo(pkg, dep.name, version).filter(r => !r.dynamic);
446
- if (!refs.length || dep.versionScheme.isPrerelease(version))
447
+ const all = Manifest.referencesTo(pkg, dep.name, version, dep.version);
448
+ const refs = all.filter(r => !r.dynamic);
449
+ if (dep.versionScheme.isPrerelease(version))
447
450
  continue;
451
+ /** A dynamic reference is never moved or refused - publishing writes it afresh - but one
452
+ * whose published range still takes the new version is why the package stays out. */
453
+ if (!refs.length) {
454
+ const published = all.filter(r => r.publishedAs);
455
+ if (depEntry?.status === 'bump' && published.length && published.every(r => r.accepts)) {
456
+ kept.push(`${dep.name} "${published[0].range}" (published as "${published[0].publishedAs}")`);
457
+ }
458
+ continue;
459
+ }
448
460
  for (const ref of refs) {
449
461
  if (!ref.accepts) {
450
462
  /** Only a version this run gives: a range already refusing the version on disk is not