Open
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>
Member
|
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
Contributor
Author
|
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>
Member
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)