Skip to content
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

inject $NPM_TOKEN into .npmrc for the user #216

Closed
aleclarson opened this issue Jan 19, 2019 · 9 comments · Fixed by #223
Closed

inject $NPM_TOKEN into .npmrc for the user #216

aleclarson opened this issue Jan 19, 2019 · 9 comments · Fixed by #223
Labels
enhancement New feature or request

Comments

@aleclarson
Copy link
Contributor

Why is .npmrc searched for a Github token?

https://github.com/intuit/auto-release/blob/a4206047e02b006fb747d027595a66ef29dddb35/src/utils/github-token.ts#L25-L39

@aleclarson aleclarson added the bug Something isn't working label Jan 19, 2019
@aleclarson
Copy link
Contributor Author

aleclarson commented Jan 19, 2019

Also, why isn't process.env.NPM_TOKEN checked for, like GH_TOKEN is?

Could auto-release inject $NPM_TOKEN into .npmrc for the user? (potentially useful in CI builds)

@hipstersmoothie
Copy link
Collaborator

This is a GitHub enterprise thing. @adierkens can tell you more as I haven't encountered it.

Could auto-release inject $NPM_TOKEN into .npmrc for the user? (potentially useful in CI builds)

I like this. it should be do-able

@hipstersmoothie hipstersmoothie added enhancement New feature or request and removed bug Something isn't working labels Jan 19, 2019
@hipstersmoothie hipstersmoothie changed the title Github token question inject $NPM_TOKEN into .npmrc for the user? Jan 19, 2019
@hipstersmoothie hipstersmoothie changed the title inject $NPM_TOKEN into .npmrc for the user? inject $NPM_TOKEN into .npmrc for the user Jan 19, 2019
@hipstersmoothie
Copy link
Collaborator

This feature should probably only be enable on the CI. If it were to run locally you might accidentally commit the token.

@hipstersmoothie
Copy link
Collaborator

Would this package get accomplish the desired behavior you're looking for?

https://www.npmjs.com/package/@hutson/set-npm-auth-token-for-ci

@aleclarson
Copy link
Contributor Author

Sure, but a look at the source code reveals a very basic implementation, so it would be better to include it in auto-release than to force the user to install another dependency.

@hipstersmoothie
Copy link
Collaborator

It seems like it does what it does quite well though:

  • handles rc files at multiple locations on any OS (using local-or-home-npmrc)
  • checks if the token is already set
  • handles the registry being set in the package.json
  • correctly handles npmrc scope configuration (using registry-url)

This is a bunch of functionality that if we wanted to cover all the use cases, we would have to code all of the above as well (or at least use the same packages).

In a few other cases we do the same thing as well. We defer to parse-author to parse the git author correctly and parse-github-url for the github URL. So it wouldn't be a stretch to use a package to do this.

I also like depending on packages like these so there is less code duplication in the world. Any by using this package and finding problems with it we can solve problems for future devs too!

My main issue with the package is how they also ship the CLI with the API. For that I have opened an issue here

@aleclarson
Copy link
Contributor Author

In the meantime, we should fork the package (and maybe even open a PR). 😁

@hipstersmoothie
Copy link
Collaborator

Yeah I plan on making a PR! Just want to know what the author would like. But the best path for that package is probably to do both: make a monorepo and use a smaller CLI library

@hipstersmoothie
Copy link
Collaborator

The maintainer already implemented this! https://gitlab.com/hyper-expanse/open-source/set-npm-auth-token-for-ci/issues/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants