cli icon indicating copy to clipboard operation
cli copied to clipboard

Asking for npm registry?

Open kbrandwijk opened this issue 8 years ago • 3 comments

The @semantic-release/npm package determines the npm registry automatically (in getRegistry). There's no user intervention possible, and no environment variable to set to influence that either.

That made me wonder what the reason is for asking for registry in the CLI. In the best case, the registry is the same as the default setting (that is found the same way as getRegistry). In the worst case, the user enters a different registry, generates a token for it, and the @semantic-release/npm will come up with a different registry, and publish fails.

Proposal is to remove the registry question, and just log the registry that is being used (e.g. the result of getRegistry). Alternatively, if there is any use case for actually asking for the registry, and it's different from what getRegistry comes up with, then it should be stored as publishConfig in the package.json. Otherwise it will never be used in @semantic-release/npm.

Update: actually, if getRegistry comes up with a non-default registry, I think it should always be written to publishConfig, otherwise it will never be used. I believe this to be a bug in the current implementation, unless I'm missing something obvious.

kbrandwijk avatar Jan 09 '18 15:01 kbrandwijk

I think it's done this way because users of private registry might have a .npmrc in the home folder in the CI, with the registry URL configuration. This way if they change the registry they have to change it only on the CI and not on each repo.

pvdlg avatar Jan 11 '18 16:01 pvdlg

Okay, so the question is there in case the user using a npm config in the CI that is different from their local one. That makes sense.

Maybe in case of a non-default registry, a question at the end 'Do you want to save your npm registry to your package.json?' wouldn't hurt. And if the user answers no, some warning that they need to make sure that the CI knows (that warning needs better wording).

kbrandwijk avatar Jan 11 '18 17:01 kbrandwijk

Maybe in case of a non-default registry, a question at the end 'Do you want to save your npm registry to your package.json?' wouldn't hurt. And if the user answers no, some warning that they need to make sure that the CI knows (that warning needs better wording).

Sounds like a good idea to me 👍

gr2m avatar Jan 13 '18 20:01 gr2m