getlarge / nx-heroku

Nx plugin to quickly deploy and promote your Nx apps on Heroku
MIT License
3 stars 0 forks source link

Question about API keys #23

Open chuckurbis opened 6 months ago

chuckurbis commented 6 months ago

Is there a way to have the library load email and API key from a specific location? Right now I'm having to type in those credentials from the command line, which is inconvenient. Ideally it could read from a .env file.

Also, i noticed it is deleting my ~/.netrc file after I fail in an attempt to deploy. Is this the intended behavior? It is forcing me to re-login to heroku for other apps I use the heroku CLI with.

Thanks for any guidance!

getlarge commented 6 months ago

Currently, both values are resolved from the options passed to the executors/generator options as you can see in the schema. They default to the environment variables:

Yes, deleting the ~/.netrc file was intended and worked fine in the use cases I encountered, where I wanted to avoid inadvertently using the same credentials used for deployment during development. I understand it can be troublesome in your use case. This behavior could be configurable via the options to avoid deleting the ~/.netrc. To extend that logic, we could resolve the email and API key from an existing ~/.netrc file and ignore the email and apiKey options from the executor. Could that work?

chuckurbis commented 6 months ago

I haven't had a chance to dive into your code. But I was wondering if we could specify a location for a file with the credentials? Or even just specify where to look for the file.

getlarge commented 6 months ago

I consider this idea, but it should be a more specific requirement. You meant location to a .env file containing HEROKU_API_KEY and HEROKU_EMAIL? It could work, but updating the .netrc file will still be required.

chuckurbis commented 6 months ago

Got it. That's probably okay then. I didn't realize it needed to pull from the .netrc file. I think it would be best to at least have the option to use the existing netrc file.

getlarge commented 5 months ago

Okay, so we could have a useNetrcFile (boolean) option, and when set to true we would ignore the email and apiKey options. We would probably need to parse the .netrc to load