-
Notifications
You must be signed in to change notification settings - Fork 928
fix: allow specifying an auth token for third-party registries #2721
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
base: main
Are you sure you want to change the base?
Conversation
Do NPM not publish a library that the CLI could be using for registry communication? E.g. one that'd automatically obey .npmrc, etc. settings rather than the CLI doing a raw |
That's a good callout: I think I was looking at a very old version of the tool that I had installed locally, and it was using some attributes that were only available via the registry and not npm info. I'll see if I can update my MR to use Or maybe I was looking at a different code branch that we only hit if a specific |
1e71a58
to
4d038c5
Compare
I updated my PR. Turns out there are two places where we currently fetch npm registry data (my initial change only updated one). The second one deals with the https://github.com/react-native-community/cli/blob/main/packages/cli/src/tools/npm.ts#L134 This second registry query does need to pull directly from the registry without an npm command, since it assumes it can view scripts information for all published version. This information is available by hitting the registry directly, but not available via So we could update the first registry query (which only cares about tags and versions) to use |
Wouldn't it be enough to provide the auth token in your root
|
We do have that set up locally, which is enough for running
So there is no good way to extract that value and automatically add it to the headers |
It looks like NPM publish this package which might be worth investigating as a replacement for the raw fetch? https://github.com/npm/npm-registry-fetch
|
I experimented with this package a bit. It takes configuration values that are similar to what you would find in a |
So close to being helpful... Does https://www.npmjs.com/package/@npmcli/config let you load the config via normal lookup methods & then pass it to npm-registry-fetch? |
Summary
Currently if we are using a third-party registry, we are unable to initialize a react-native project under either of the following conditions:
https://registry.example.com/foo
instead ofhttps://registry.example.com
)Related: #2718
Test Plan
I am on an enterprise network with a third-party registry that requires authentication. After making the changes in this PR locally, I was able to initialize a react-native repository locally with the following commands:
yarn install
npm run build
chmod 755 packages/cli/build/bin.js
../../packages/cli/build/bin.js init --auth-token ... MyAwesomeProject
Checklist
react-native
checkout (instructions).