Keep the GitHub Packages token out of the committed .npmrc - #63
Closed
duguankui wants to merge 1 commit into
Closed
Conversation
angular/.npmrc referenced ${PACKAGES_READ_TOKEN}, which broke local
development outright: any ${...} placeholder in a committed .npmrc makes
every yarn invocation in that directory fail with "Failed to replace env in
config" the moment the variable is unset - including yarn start, yarn build
and yarn test, none of which touch that registry. Reported from a plain
./start.ps1.
The file now carries only the two scope mappings. Both workflows write the
credential to ~/.npmrc in an "Authenticate to GitHub Packages" step, and the
file documents the one-line equivalent for developers. That also drops the
job-level env from both workflows, and with it the whole "must be job-level
because setup-node's cache probe reads .npmrc first" complication - with no
placeholder to expand, that probe has nothing to fail on.
Note the token needs the read:packages scope; a plain repo-scoped one (which
is what tends to be sitting in $GITHUB_TOKEN) is not enough, and would have
failed at download time instead.
Also drops //npm.pkg.github.com/:always-auth=true. With both scopes mapped
yarn already attaches the token to the tarball download without it, and npm
11 warns on every invocation that the per-registry form is unknown config.
Verified by cold-cache `yarn install --frozen-lockfile` with and without it,
and by re-running the reported ./start.ps1 path with no token variable set.
Member
Author
|
Superseded by #64. That PR removes the need for a GitHub Packages credential altogether — flex-fields 10.0.0-rc.16 is now on public npmjs, so |
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.
The bug
angular/.npmrcreferenced${PACKAGES_READ_TOKEN}. Any${...}placeholder in a committed.npmrcmakes every yarn invocation in that directory fail hard when the variable is unset:That includes
yarn start,yarn buildandyarn test— none of which touch the private registry. Reported from a plain./start.ps1.The fix
angular/.npmrckeeps only the two scope mappings and no credential.~/.npmrcin a new Authenticate to GitHub Packages step. That also removes the job-levelenv:from both, and with it the "must be job-level because setup-node'scache: yarnprobe reads.npmrcbefore any step" complication — with no placeholder to expand, the probe has nothing to fail on.read:packages; a plainrepo-scoped one (which is typically what's sitting in$GITHUB_TOKEN) is not enough and would have failed at download time instead.//npm.pkg.github.com/:always-auth=true. With both scopes mapped, yarn attaches the token to the tarball download without it, and npm 11 warns on every invocation that the per-registry form is unknown config.Test plan
./start.ps1path with no token variable set — clean, and the npmalways-authwarning is gone tooyarn install --frozen-lockfile(YARN_CACHE_FOLDERpointed at an empty dir, credential in a user-level.npmrc) — succeeds, all four packages at10.0.0-rc.16always-auth, to establish it isn't load-bearing