feat: read registry and credentials from .npmrc using @npmcli/config#1252
feat: read registry and credentials from .npmrc using @npmcli/config#1252Copilot wants to merge 5 commits into
Conversation
…provided Agent-Logs-Url: https://github.com/microsoft/beachball/sessions/b5da8d10-9062-454f-96b2-9db368a9b782 Co-authored-by: ecraig12345 <5864305+ecraig12345@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/beachball/sessions/b5da8d10-9062-454f-96b2-9db368a9b782 Co-authored-by: ecraig12345 <5864305+ecraig12345@users.noreply.github.com>
|
@copilot When reading the npmrc, add environment variable substitution support similar to |
…ry values Agent-Logs-Url: https://github.com/microsoft/beachball/sessions/2ba37dcc-6171-497b-9265-5fc8971ec21e Co-authored-by: ecraig12345 <5864305+ecraig12345@users.noreply.github.com>
Added |
|
@copilot Update the PR (and description) to use |
…try optional and lazily resolved Agent-Logs-Url: https://github.com/microsoft/beachball/sessions/450b1525-6875-45f9-bae5-78f870a3694b Co-authored-by: ecraig12345 <5864305+ecraig12345@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/beachball/sessions/450b1525-6875-45f9-bae5-78f870a3694b Co-authored-by: ecraig12345 <5864305+ecraig12345@users.noreply.github.com>
Done in 88b6d92. Key changes:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Summary
When no
registryis specified via CLI (--registry/-r) or config file (beachball.config.js), beachball now lazily resolves theregistryand credentials from.npmrcfiles using@npmcli/configbefore npm operations, falling back to the defaulthttps://registry.npmjs.org/.This resolution is lazy — it only happens when the registry and token are actually needed (e.g., during
publish,canary,sync, orinit), not during initial options parsing. Results are cached percwdfor efficiency.Lookup order
--registryflag (highest priority)registrysetting.npmrcfiles resolved via@npmcli/config(project-level, user-level, global, environment variables)https://registry.npmjs.org/Auth credentials (e.g.,
_authToken) are also read from.npmrcvia@npmcli/config'sgetCredentialsByURI()when available. Explicit--token/NPM_TOKENvalues take precedence over.npmrccredentials.Changes
@npmcli/config— Used to read npm config from all standard sources with full environment variable substitution and credential support.src/packageManager/npmConfig.ts—getNpmConfig(cwd)loads npm config lazily and caches results.resolveNpmConfig(options)resolves registry and auth token on the options object, returning a type-narrowed result withregistry: string.src/types/BeachballOptions.ts—registryis now optional inRepoOptions.src/options/getDefaultOptions.ts— Removedregistrydefault (resolved lazily instead).src/options/getOptions.ts— Removed.npmrcfallback frommergeRepoOptions(resolution is now lazy).publish.ts,canary.ts,sync.ts,init.ts) — AddedresolveNpmConfig()calls before npm operations.src/publish/publishToRegistry.ts— Parameter type narrowed to requireregistry: string.src/packageManager/npmAuthEnvPassthrough.ts— Updated parameter type to use inline{ registry: string; path: string }.src/packageManager/npmrc.ts— Replaced bynpmConfig.ts.docs/overview/configuration.md— Updated docs for theregistryoption.getNpmConfigandresolveNpmConfig(including env var substitution and credential reading). Updated existing tests and snapshots for the optionalregistrytype change.