rman 2.0.0-beta.5 → 2.0.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.
@@ -156,7 +156,13 @@ export var PublishService;
156
156
  const packages = filterPackages(repository.getPackages({ toposort: true }), options);
157
157
  const dirtyFiles = await git.listDirtyFiles({ absolute: true });
158
158
  const isDirty = (pkg) => dirtyFiles.some(f => !path.relative(pkg.dirname, f).startsWith('..'));
159
- const viewPackage = deps.npmViewPackage ?? ((name, cwd) => npmViewPackage(name, cwd, options));
159
+ /** Per package, not per run: `resolveRegistry` reads the package's own `publishConfig.registry`
160
+ * when `--registry` was not given, so the question is asked where the answer lives. The test
161
+ * seam keeps its `(name, cwd)` shape - a stub answers from a map and has no registry to
162
+ * respect. */
163
+ const viewPackage = (pkg) => deps.npmViewPackage
164
+ ? deps.npmViewPackage(pkg.name, pkg.dirname)
165
+ : npmViewPackage(pkg.name, pkg.dirname, { ...options, registry: resolveRegistry(pkg, options.registry) });
160
166
  const entries = new Map();
161
167
  const toCheck = [];
162
168
  for (const pkg of packages) {
@@ -200,7 +206,7 @@ export var PublishService;
200
206
  }
201
207
  }
202
208
  await Promise.all(toCheck.map(async (pkg) => {
203
- const view = await viewPackage(pkg.name, pkg.dirname);
209
+ const view = await viewPackage(pkg);
204
210
  const registryVersion = view?.latest;
205
211
  /** **This version**, not `latest` - the two part company the moment a prerelease is
206
212
  * published under its own dist-tag, and `latest` then never moves however many betas go
@@ -304,6 +310,40 @@ function resolvePublishDir(pkg, contentsOverride) {
304
310
  const rel = (typeof native === 'string' && native) || configured || contentsOverride;
305
311
  return rel ? path.resolve(pkg.dirname, rel) : pkg.dirname;
306
312
  }
313
+ /**
314
+ * Which registry a package's own version is asked about, and published to.
315
+ *
316
+ * npm's own precedence, measured rather than assumed: `--registry` on the command line wins over
317
+ * `package.json`'s `publishConfig.registry`, and with neither given npm resolves it itself from
318
+ * `.npmrc` - including a scoped `@owner:registry=`, which is how a GitHub Packages repository is
319
+ * normally set up.
320
+ *
321
+ * @returns the registry to pass, or `undefined` to let npm decide.
322
+ */
323
+ /* **The check has to ask the registry the publish will use, and it did not.** `npm publish` honours
324
+ * `publishConfig.registry` - it survives into the generated manifest, since `derivePublishManifest`
325
+ * deletes only `publishConfig.directory` - but **`npm view` ignores it**: measured, a package whose
326
+ * `publishConfig.registry` pointed at a dead local address was still answered from
327
+ * registry.npmjs.org.
328
+ *
329
+ * So question B was asked of the wrong registry for exactly one of the three ways a registry can be
330
+ * stated, and `npmViewPackage` swallows a failed lookup as `undefined`, which reads as "never
331
+ * published". Two consequences, and the second is the one to fear:
332
+ *
333
+ * - the plan proposes a publish on **every** run, so the first succeeds and the second is rejected
334
+ * by the registry for republishing a version - a release job that fails for no reason of its own;
335
+ * - if some *other* package holds that name on npmjs.org, rman reads a stranger's version list, and
336
+ * can report `up-to-date` for a publish that never happened.
337
+ *
338
+ * A scoped name in an `.npmrc` was always fine - measured, `npm view @foo/bar` with
339
+ * `@foo:registry=http://127.0.0.1:1/` tries that address - which is why this went unnoticed.
340
+ *
341
+ * Returning `undefined` rather than a default is the half that keeps it working: passing an explicit
342
+ * `--registry` would override whatever `.npmrc` says and break the case that already worked. */
343
+ function resolveRegistry(pkg, override) {
344
+ const native = pkg.manifest.raw.publishConfig?.registry;
345
+ return override || (typeof native === 'string' && native ? native : undefined);
346
+ }
307
347
  /**
308
348
  * The retired `publish.directory` spelling, if a config still carries it.
309
349
  *
@@ -59,7 +59,8 @@ export class NpmPublishTarget {
59
59
  },
60
60
  registry: {
61
61
  target: 'cli',
62
- describe: 'Registry to check against and publish to (default: whatever .npmrc already configures)',
62
+ describe: 'Registry to check against and publish to, for every package in this run. Overrides each ' +
63
+ 'package\'s own "publishConfig.registry"; with neither, npm resolves .npmrc itself',
63
64
  type: 'string',
64
65
  },
65
66
  userconfig: {
package/constants.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.0.0-beta.5';
1
+ export const version = '2.0.0';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rman",
3
3
  "description": "Repository manager",
4
- "version": "2.0.0-beta.5",
4
+ "version": "2.0.0",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {