-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: respect scoped registries from publishConfig #844
base: master
Are you sure you want to change the base?
fix: respect scoped registries from publishConfig #844
Conversation
This stops a niche issue when using Gitlab registries, where setting the `.npmrc` to pull packages from the instance-wide registry while also setting the `package.json:publishConfig` to push to the project-local registry for a given `@scope` would pass the incorrect `--registry` flag to `npm publish` as well as associate the `NPM_TOKEN` with the wrong URL in the generated userconfig file. This DOES NOT resolve semantic-release#219. So `--registry` is still technically ignored for scoped packages. See [npm/cli#7043](npm/cli#7043) for more details on that. I made sure not to affect the priority of other resolutions to avoid any breaking changes. An additional test has been added for this specific case.
Could you please provide a public reproduction of the problem? What you describe is the default npm behavior, which we do or best to align with already by mostly deferring to npm to handle. I've used such configuration myself without complication, so I'm skeptical of this being a problem |
Thanks for your time, @travi! I don't have a way to reproduce publicly right now, as this is happening in a private self-hosted instance of Gitlab. But I can go into a little more detail. To define NPM's behavior, assuming a package called Scopeless// package.json
{
"publishConfig": {
"registry": "https://pkg.fake.io"
}
} # .npmrc
registry=https://rc.fake.io # Command
npm publish $(pwd) --registry "https://cli.fake.io"
# Attempts to publish to
# https://cli.fake.io Scoped in the
|
Another way to confirm this change is needed is just to reset the changes to [test:unit ] get-registry › Get the registry configured in "publishConfig" for scoped package
[test:unit ]
[test:unit ] test/get-registry.test.js:47
[test:unit ]
[test:unit ] 46:
[test:unit ] 47: t.is(
[test:unit ] 48: getRegistry(
[test:unit ]
[test:unit ] Difference (- actual, + expected):
[test:unit ]
[test:unit ] - 'https://custom6.registry.com'
[test:unit ] + 'https://custom5.registry.com'
[test:unit ]
[test:unit ] › file://test/get-registry.test.js:47:5 It's unable to see the scoped registry under |
This stops a niche issue when using Gitlab registries, where setting the
.npmrc
to pull packages from the instance-wide registry while also setting thepackage.json:publishConfig
to push to the project-local registry for a given@scope
wouldpass the incorrectassociate the--registry
flag tonpm publish
as well asNPM_TOKEN
with the wrong URL in the generated userconfig file.This DOES NOT resolve #219. So
--registry
is still technically ignored for scoped packages. Seenpm/cli#7043 for more details on that.
I made sure not to affect the priority of other resolutions to avoid any breaking changes. An additional test has been added for this specific case.
EDIT: Fixed description to make it clear I did not fix #219.