ashald / EnvFile

EnvFile 3.x is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or multiple files.
MIT License
548 stars 129 forks source link

Add support for shadowenv #89

Open lavoiesl opened 5 years ago

lavoiesl commented 5 years ago

Shadowenv does project-local environment variable shadowing.

It can set variables when you enter a project on the terminal, and restore them when you leave. It is flexible and supports appending, prepending, and set-if-not-set operations.

There are already plugins for vim and [emacs] (https://github.com/shopify/shadowenv.el).

Our team (behind shadowenv) are planning on adding support to the JetBrains family, but it might be simpler to piggyback on this module, which already manages environments.

ashald commented 5 years ago

Hi there! I really like the idea behind Shadowenv and delighted you're considering integration via JetBrains IDEs viaEnvFile!

IDK if you explored EnvFile architecture, but just in case here is my take on how this could be done.

EnvFile on its own exposes an extension point which at the end is backed by EnvVarsProvider interface. All the existing "providers" (.env, json/yaml etc) are implemented by conforming to that interface and I would imagine that Shadowenv would require its own counterpart.

Now, with all of that being said, I can see 2 options: we can add such an implementation to EnvFile on its own or Shadowenv can be a standalone plugin that would conform to the aforementioned api and declare a dependency on EnvFile plugin. I never tried the latter but to the best of my understanding, this way when someone would install Shadowenv plugin they would automatically get EnvFile installed as a dependency. If you'd chose this approach you could have full control over the codebase and the release cycle for the Shadowenv integration. I'm fine either way.

Last but not least, EnvVarsProvider interface is pretty limited at the moment. It's mostly focused around validation and injecting the env vars. If you'd need to add some visual controls to configure integration or display some extra information in the UI I'd be open to adjusting the interface to accommodate that.

The only thing that is not immediately clear to me is what would be the best way to evaluate Shadowenv configurations - whether by re-implementing it on JVM (or reusing some existing list interpreter) or by executing a sub-process - would be curious to learn your thoughts on this.