I started this issue because I was looking at the changesets action code and came upon these lines where the environment variable is directly written to the file:
|
`\n//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}\n` |
|
`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}\n` |
What you could do instead is just what github says it does and copy the following to the .npmrc file:
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
I see now in the README that you reference the fact that node sets up an npmrc file with the environment variable => and of course, the code checks for the authToken line, so obviously the code/you/someone is aware of the NPM behavior.
But I also note that the name of the environment variable you suggest using is NPM_TOKEN and not NODE_AUTH_TOKEN. Maybe that reflects an earlier/custom behavior of the setup-node action, although in terms of references, all I could find for auth was this PR), and so node's automatic behavior in theory should not be working.
Presumably, this would actually cause auth errors for anyone using the action, but it seems that setup-node only writes the npmrc file if a registry-url config setting is added, and so as long as you don't add that, changesets would detect that no npmrc file was written, and write its own, with the NPM_TOKEN embedded in cleartext.
So I can setup a PR to change the README to suggest using NODE_AUTH_TOKEN like in the github docs, and also change the written npmrc string to use an environment variable instead of actually reading the variable and writing its value.
Let me know what I've misunderstood, I'm sure something!