laserlemon / figaro

Simple Rails app configuration
MIT License
3.77k stars 288 forks source link

Any npm packages that could use the same secrets? #284

Open vfonic opened 4 years ago

vfonic commented 4 years ago

I have a rails + webpacker project and I need to share some ENV vars between rails and webpacker (webpack/node).

It works great if I use 'dotenv-rails', but I prefer 'figaro' and its "use one file, never commit it and it's YAML" philosophy.

I also like ease of use of pushing ENV vars to heroku.

Is there some npm package that I can use, like 'dotenv', that will be able to read the secrets from config/application.yml? Should we build one? Maybe we could just fork 'dotenv' and have it parse YAML instead of reading in the "plain text" key=value pairs from multiple dotfiles.

What do you think?

laserlemon commented 4 years ago

@vfonic Figaro 2.0 (in development) adds a figaro exec command, which uses Ruby to load your Figaro configuration into ENV and then execute some other command of your choosing.

I'm not very familiar with Node.js development but figaro exec your/node/command might be interesting for that use case.

vfonic commented 4 years ago

That might work!

I'm curious how it would work after deployment. 🤔 It might be a bit inconvenient to have to add figaro exec before every command. Plus, heroku is precompiling assets automatically, so, in order for this to work there, we'd have to override "assets:precompile" task to get ENV vars into webpacker/webpack. I'm not sure actually...

I'm eager to be the beta tester if that helps! :)

laserlemon commented 4 years ago

I'm also very open to the creation of a JS Figaro sidecar (by somebody else! 😜), although I might suggest avoiding replicating Figaro v1 at this point, in favor of v2.

Hanaffi commented 5 months ago

@laserlemon Is there a better way to handle this please? (ie loading application.yml/figaro envs in webpack)

Also can you share more details on how to do it with figaro exec please?