rman 2.27.0 → 2.27.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.
@@ -64,6 +64,13 @@ export declare class NodeManifestProvider implements ManifestProvider {
64
64
  stampVersion(file: string, content: string, version: string, options?: {
65
65
  constant?: string;
66
66
  }): string | undefined;
67
+ /**
68
+ * `range` moved to accept a `version` it does not: `^1.1.4` -> `^2.0.0`, `~1.1.4` -> `~2.0.0`, a
69
+ * pinned `1.1.4` -> `2.0.0`, and `>=1.1.0 <2` -> `>=2.0.0 <3` - a window spanning one major moves
70
+ * to the next. `undefined` for any other shape: `||`, a hyphen range, an upper bound that is not
71
+ * the next major.
72
+ */
73
+ protected moveRange(range: string, version: string): string | undefined;
67
74
  /**
68
75
  * `range` with its lower bound moved up to `version`, keeping its upper bound and its operator -
69
76
  * `undefined` when the floor is already at or above it, `null` for a shape with no single floor
@@ -111,16 +111,16 @@ export class NodeManifestProvider {
111
111
  continue;
112
112
  }
113
113
  const range = workspace ? workspace.range : declared;
114
+ const prefix = workspace ? 'workspace:' : '';
115
+ const accepts = semver.satisfies(version, range);
114
116
  const raised = this.raiseFloor(range, version);
117
+ const rewritten = accepts ? undefined : this.moveRange(range, version);
115
118
  refs.push({
116
119
  field,
117
120
  range: declared,
118
- accepts: semver.satisfies(version, range),
119
- ...(raised === null
120
- ? { unraisable: true }
121
- : raised
122
- ? { raised: workspace ? `workspace:${raised}` : raised }
123
- : {}),
121
+ accepts,
122
+ ...(raised === null ? { unraisable: true } : raised ? { raised: prefix + raised } : {}),
123
+ ...(rewritten ? { rewritten: prefix + rewritten } : {}),
124
124
  });
125
125
  }
126
126
  return refs;
@@ -154,6 +154,35 @@ export class NodeManifestProvider {
154
154
  stampVersion(file, content, version, options) {
155
155
  return stampVersionConstant(content, version, options?.constant);
156
156
  }
157
+ /**
158
+ * `range` moved to accept a `version` it does not: `^1.1.4` -> `^2.0.0`, `~1.1.4` -> `~2.0.0`, a
159
+ * pinned `1.1.4` -> `2.0.0`, and `>=1.1.0 <2` -> `>=2.0.0 <3` - a window spanning one major moves
160
+ * to the next. `undefined` for any other shape: `||`, a hyphen range, an upper bound that is not
161
+ * the next major.
162
+ */
163
+ /* **Moved rather than refused**, which is what `keep` first did - and measured wrong on
164
+ * `panates/syncbridge`: `@syncbridge/common` went 1.1.4 -> 2.0.0 and four packages of its own
165
+ * group, every one already planned for 2.0.0, were refused for `^1.1.4`. A range that no longer
166
+ * accepts its sibling has to change whatever the setting says; `keep` is about the ranges that
167
+ * still do. Only a shape this can move without guessing is moved - the rest still refuse. */
168
+ moveRange(range, version) {
169
+ const r = range.trim();
170
+ const v = semver.parse(version);
171
+ if (!v)
172
+ return undefined;
173
+ if (semver.valid(r))
174
+ return version;
175
+ const caret = /^([\^~])\s*v?\d[^\s|]*$/.exec(r);
176
+ if (caret)
177
+ return `${caret[1]}${version}`;
178
+ const bounded = /^>=\s*v?(\d\S*)\s+<\s*v?(\d+)(\.0(\.0)?)?$/.exec(r);
179
+ if (bounded) {
180
+ const floor = semver.coerce(bounded[1]);
181
+ if (floor && Number(bounded[2]) === floor.major + 1)
182
+ return `>=${version} <${v.major + 1}${bounded[3] ?? ''}`;
183
+ }
184
+ return undefined;
185
+ }
157
186
  /**
158
187
  * `range` with its lower bound moved up to `version`, keeping its upper bound and its operator -
159
188
  * `undefined` when the floor is already at or above it, `null` for a shape with no single floor
@@ -125,7 +125,7 @@ const config = {
125
125
  describe: "What happens to this package's range on an in-repo dependency that is getting a new " +
126
126
  'version: "rewrite" (the default) sets it to the new version and releases this package for ' +
127
127
  'it; "keep" leaves a range that still accepts the new version alone and does not release ' +
128
- "this package for it, refuses the run when the range does not, and raises the range's " +
128
+ "this package for it, moves the range to accept it when it does not (refusing the run only for a shape it cannot move), and raises the range's " +
129
129
  'lower bound when this package is released for changes of its own. A prerelease never ' +
130
130
  "fails a range and never raises one. Per-package cascaded - the range is the package's own.",
131
131
  type: 'string',
package/constants.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.27.0';
1
+ export const version = '2.27.1';
@@ -165,8 +165,9 @@ export interface ManifestProvider {
165
165
  * with its lower bound raised to it.
166
166
  *
167
167
  * What `.rmanrc "version.dependentRanges": keep` asks instead of `updateDependencyVersions`: a
168
- * hand-written range is left alone while it accepts the new version, refused when it does not,
169
- * and has its floor raised when the package holding it is released for reasons of its own.
168
+ * hand-written range is left alone while it accepts the new version, moved to accept it when it
169
+ * does not, and has its floor raised when the package holding it is released for reasons of its
170
+ * own.
170
171
  *
171
172
  * Omit it and a package has no ranges to keep, so `keep` behaves like `rewrite` for it.
172
173
  */
@@ -194,6 +195,9 @@ export declare namespace ManifestProvider {
194
195
  raised?: string;
195
196
  /** The range's shape has no single lower bound this provider knows how to move. */
196
197
  unraisable?: boolean;
198
+ /** For a range that does not accept the version: the same shape moved to accept it - `^1.1.4`
199
+ * to `^2.0.0`. Unset when the shape cannot be moved without guessing at what was meant. */
200
+ rewritten?: string;
197
201
  }
198
202
  }
199
203
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rman",
3
3
  "description": "Repository manager",
4
- "version": "2.27.0",
4
+ "version": "2.27.1",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
@@ -146,7 +146,7 @@ export declare abstract class VersionPlanService {
146
146
  * Whether `dependent` keeps its range on `dependency` (`.rmanrc "version.dependentRanges": keep`)
147
147
  * and that range still accepts `version` - so the new version reaches it without a release of
148
148
  * its own. `undefined` means "release it as `rewrite` would": the key says `rewrite`, the range
149
- * no longer accepts the version (refused later, by `checkKeptRanges`), or there is no range to
149
+ * no longer accepts the version (moved, or refused, by `checkKeptRanges`), or there is no range to
150
150
  * judge - a reference that follows the dependency by itself, or an edge `.rmanrc
151
151
  * "dependencies"` declared with no range at all.
152
152
  *
@@ -156,10 +156,12 @@ export declare abstract class VersionPlanService {
156
156
  protected rangeVerdict(dependent: Package, dependency: Package, version: string): 'accepts' | undefined;
157
157
  /**
158
158
  * The plan's last word on kept ranges: every package that keeps its ranges is checked against
159
- * the versions its in-repo dependencies are getting. A range that refuses one makes the package
160
- * an `'error'` naming the field, the range and the version, so `version` writes nothing and the
161
- * range can be widened by hand. One left out of the release because its range still accepts says
162
- * so in its reason, and one being released notes a range whose floor cannot be raised.
159
+ * the versions its in-repo dependencies are getting. A range that refuses one is moved to accept
160
+ * it where its shape allows (`^1.1.4` -> `^2.0.0`, noted in the reason) - the package is then
161
+ * released as under `rewrite` - and makes the package an `'error'` naming the field, the range
162
+ * and the version where it does not, so `version` writes nothing and the range is fixed by hand.
163
+ * One left out of the release because its range still accepts says so in its reason, and one
164
+ * being released notes a range whose floor cannot be raised.
163
165
  */
164
166
  protected checkKeptRanges(packages: Package[], entries: Map<string, VersionPlanService.Entry>): void;
165
167
  /**
@@ -370,7 +370,7 @@ export class VersionPlanService {
370
370
  * Whether `dependent` keeps its range on `dependency` (`.rmanrc "version.dependentRanges": keep`)
371
371
  * and that range still accepts `version` - so the new version reaches it without a release of
372
372
  * its own. `undefined` means "release it as `rewrite` would": the key says `rewrite`, the range
373
- * no longer accepts the version (refused later, by `checkKeptRanges`), or there is no range to
373
+ * no longer accepts the version (moved, or refused, by `checkKeptRanges`), or there is no range to
374
374
  * judge - a reference that follows the dependency by itself, or an edge `.rmanrc
375
375
  * "dependencies"` declared with no range at all.
376
376
  *
@@ -395,10 +395,12 @@ export class VersionPlanService {
395
395
  }
396
396
  /**
397
397
  * The plan's last word on kept ranges: every package that keeps its ranges is checked against
398
- * the versions its in-repo dependencies are getting. A range that refuses one makes the package
399
- * an `'error'` naming the field, the range and the version, so `version` writes nothing and the
400
- * range can be widened by hand. One left out of the release because its range still accepts says
401
- * so in its reason, and one being released notes a range whose floor cannot be raised.
398
+ * the versions its in-repo dependencies are getting. A range that refuses one is moved to accept
399
+ * it where its shape allows (`^1.1.4` -> `^2.0.0`, noted in the reason) - the package is then
400
+ * released as under `rewrite` - and makes the package an `'error'` naming the field, the range
401
+ * and the version where it does not, so `version` writes nothing and the range is fixed by hand.
402
+ * One left out of the release because its range still accepts says so in its reason, and one
403
+ * being released notes a range whose floor cannot be raised.
402
404
  */
403
405
  /* **Every kept package, released or not - a `publish.skip` one included.** A range that no longer
404
406
  * accepts its sibling breaks more than a publish: npm workspaces link a sibling only while the
@@ -411,6 +413,7 @@ export class VersionPlanService {
411
413
  if (!entry)
412
414
  continue;
413
415
  const refused = [];
416
+ const moved = [];
414
417
  const kept = [];
415
418
  const unraisable = [];
416
419
  for (const dep of pkg.dependencies) {
@@ -423,9 +426,12 @@ export class VersionPlanService {
423
426
  if (!ref.accepts) {
424
427
  /** Only a version this run gives: a range already refusing the version on disk is not
425
428
  * this run's doing, and npm reports it at install time. */
426
- if (depEntry?.status === 'bump') {
429
+ if (depEntry?.status !== 'bump')
430
+ continue;
431
+ if (ref.rewritten)
432
+ moved.push(`${dep.name} "${ref.range}" -> "${ref.rewritten}"`);
433
+ else
427
434
  refused.push(`${ref.field} "${dep.name}": "${ref.range}" does not accept ${version}`);
428
- }
429
435
  }
430
436
  else if (entry.status === 'bump' && ref.unraisable) {
431
437
  unraisable.push(`${dep.name} "${ref.range}"`);
@@ -434,16 +440,19 @@ export class VersionPlanService {
434
440
  if (depEntry?.status === 'bump' && refs.every(r => r.accepts))
435
441
  kept.push(`${dep.name} "${refs[0].range}"`);
436
442
  }
443
+ const note = (text) => (entry.reason = `${entry.reason ? `${entry.reason}; ` : ''}${text}`);
437
444
  if (refused.length) {
438
445
  entry.status = 'error';
439
446
  entry.reason = `range does not accept the new version - ${refused.join('; ')}`;
447
+ continue;
440
448
  }
441
- else if (entry.status === 'no-change' && kept.length) {
449
+ if (entry.status === 'no-change' && kept.length && !moved.length) {
442
450
  entry.reason = `range ${kept.join(', ')} still satisfied`;
443
451
  }
444
- else if (unraisable.length) {
445
- entry.reason = `${entry.reason ? `${entry.reason}; ` : ''}lower bound not raised: ${unraisable.join(', ')}`;
446
- }
452
+ if (moved.length)
453
+ note(`range moved: ${moved.join(', ')}`);
454
+ if (unraisable.length)
455
+ note(`lower bound not raised: ${unraisable.join(', ')}`);
447
456
  }
448
457
  }
449
458
  /**
@@ -106,9 +106,10 @@ export declare namespace VersionService {
106
106
  function normalizeScriptValue(value: unknown, at: string): RunStepValue[];
107
107
  /**
108
108
  * Raises the lower bound of each of `pkg`'s ranges on an in-repo dependency to the version that
109
- * dependency now has - `bumped`'s for one this run moves, its own otherwise. Upper bounds stay.
110
- * What `.rmanrc "version.dependentRanges": keep` does for a package released for changes of its
111
- * own, in place of `Manifest.updateDependencyVersions`.
109
+ * dependency now has - `bumped`'s for one this run moves, its own otherwise. Upper bounds stay;
110
+ * a range that does not accept the version is moved to its shape's next window instead
111
+ * (`^1.1.4` -> `^2.0.0`). What `.rmanrc "version.dependentRanges": keep` does for a package
112
+ * released for changes of its own, in place of `Manifest.updateDependencyVersions`.
112
113
  */
113
114
  function raiseKeptFloors(pkg: Package, bumped: ReadonlyMap<Package, string>): void;
114
115
  /**
@@ -114,6 +114,31 @@ export class VersionService extends Service {
114
114
  }
115
115
  await hook('after');
116
116
  }
117
+ /** A kept package left out of versioning (`publish.skip`) still has its ranges moved where one
118
+ * no longer accepts a sibling, or npm workspaces would install that sibling from the registry
119
+ * instead of linking it. It takes no version, so its manifest rides the root's sync commit. */
120
+ const movedOnly = [];
121
+ for (const entry of plan) {
122
+ const pkg = entry.package;
123
+ if (entry.status !== 'skip' || pkg.config?.version?.dependentRanges !== 'keep')
124
+ continue;
125
+ let changed = false;
126
+ for (const dep of pkg.dependencies) {
127
+ const version = bumpedVersions.get(dep);
128
+ if (!version || dep.versionScheme.isPrerelease(version))
129
+ continue;
130
+ for (const ref of Manifest.referencesTo(pkg, dep.name, version)) {
131
+ if (ref.accepts || !ref.rewritten)
132
+ continue;
133
+ Manifest.setReference(pkg, ref.field, dep.name, ref.rewritten);
134
+ changed = true;
135
+ }
136
+ }
137
+ if (changed) {
138
+ pkg.writeManifest();
139
+ movedOnly.push(path.relative(repository.dirname, pkg.manifestFileName));
140
+ }
141
+ }
117
142
  const rootEntry = repository.monorepo ? plan.find(e => e.package === repository.rootPackage) : undefined;
118
143
  if (rootEntry?.status === 'bump') {
119
144
  repository.rootPackage.manifest.version = rootEntry.to;
@@ -197,7 +222,7 @@ export class VersionService extends Service {
197
222
  /** The root's own `CHANGELOG.md` rides along here, for the same reason its manifest does:
198
223
  * it belongs to no group, so no group commit would carry it and it would be left behind as
199
224
  * an uncommitted edit that `publish` then reads as a dirty tree. */
200
- const files = [path.relative(repository.dirname, repository.rootPackage.manifestFileName)];
225
+ const files = [path.relative(repository.dirname, repository.rootPackage.manifestFileName), ...movedOnly];
201
226
  const rootChangelog = changelogFileByPackage.get(repository.rootPackage.name);
202
227
  /** **Unless a group commit below is already carrying it**, which is the ordinary case under
203
228
  * `changelog.groupBy: 'group'`: the root is a member of the default group, so its file *is*
@@ -313,9 +338,10 @@ export class VersionService extends Service {
313
338
  VersionService.normalizeScriptValue = normalizeScriptValue;
314
339
  /**
315
340
  * Raises the lower bound of each of `pkg`'s ranges on an in-repo dependency to the version that
316
- * dependency now has - `bumped`'s for one this run moves, its own otherwise. Upper bounds stay.
317
- * What `.rmanrc "version.dependentRanges": keep` does for a package released for changes of its
318
- * own, in place of `Manifest.updateDependencyVersions`.
341
+ * dependency now has - `bumped`'s for one this run moves, its own otherwise. Upper bounds stay;
342
+ * a range that does not accept the version is moved to its shape's next window instead
343
+ * (`^1.1.4` -> `^2.0.0`). What `.rmanrc "version.dependentRanges": keep` does for a package
344
+ * released for changes of its own, in place of `Manifest.updateDependencyVersions`.
319
345
  */
320
346
  /* **Only when the package itself is released**, because that is the only time it can have
321
347
  * started using something new: code relying on a newer dependency is a change in the dependent,
@@ -331,8 +357,9 @@ export class VersionService extends Service {
331
357
  if (dep.versionScheme.isPrerelease(version))
332
358
  continue;
333
359
  for (const ref of Manifest.referencesTo(pkg, dep.name, version)) {
334
- if (ref.raised && ref.accepts)
335
- Manifest.setReference(pkg, ref.field, dep.name, ref.raised);
360
+ const to = ref.accepts ? ref.raised : ref.rewritten;
361
+ if (to)
362
+ Manifest.setReference(pkg, ref.field, dep.name, to);
336
363
  }
337
364
  }
338
365
  }