Conversation
Adds a new `publish-registry` config option that allows setting a separate registry URL for `npm publish` and `npm unpublish`, while leaving the `registry` config in effect for all other operations like install and view. This enables workflows like using a local caching proxy (e.g. VSR, Verdaccio) for reads while publishing directly to the public npm registry, without needing per-package publishConfig or shell aliases. When set in .npmrc: registry=http://localhost:1337/npm publish-registry=https://registry.npmjs.org/ All installs/views go through the local proxy, while publishes go directly to npmjs.org. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
I think this may be something per-command config can help with. We need to solve the problem of setting them in |
publish-registry config optionpublish-registry config option
|
Absolutely per-command config would be ideal here. What's the status of that? |
Addresses CodeQL "Incomplete URL substring sanitization" warning. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
It shipped with the trust command. It's still in its initial iteration and needs a second dev to iterate on it probably but it's there. |
|
So should i update this PR to use per-command config? |
|
I don't think we're there yet. We need a way to do this from the npmrc file. The idea would be that you could specify something like: [config-just-for-command-publish]
registry=//myregistry.tld(I made the group name intentionally obtuse so nobody thinks this is already architected). With that we wouldn't need a wholly new config item. As you can tell this is NOT fleshed out, and idk if we're close enough to an implementation for a full PR yet. |
Summary
Adds a new
publish-registryconfig option that allows setting a separate registry URL fornpm publishandnpm unpublish, while leavingregistryin effect for all other operations (install, view, etc.).This enables using a local caching proxy (VSR, Verdaccio, etc.) for reads while publishing directly to the public npm registry:
Motivation
There is no clean way today to split read vs write registries in npm:
publishConfig.registryinpackage.jsonis per-package, not global.npmrcapply to both reads and writes--registryflag must be passed manually every timeThis has been a long-standing pain point across many issues: #1937, #559, #4034, #7043, and npm/feedback#131.
Changes
workspaces/config/lib/definitions/definitions.js: Newpublish-registryconfig definition (type:null | URL, default:null)lib/commands/publish.js: Whenpublish-registryis set, overridesopts.registrybefore registry selection. Added tostatic paramsfor help/docs.lib/commands/unpublish.js: Same treatment for symmetry (addresses [BUG]npm publishuses different registry thennpm unpublish#559 where publish and unpublish use different registries)Behavior
nulldefault means zero behavior change for existing userspublishConfig.registryinpackage.jsonstill takes precedence (applied later viaflatten)pickRegistry(existing behavior)--registryflag still takes precedence (existing behavior)