feat: add env:add command #4533
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Okay, so this is something that's been bugging me for a long time. I'm often in the middle of development, and I realize that I need to add an environment variable. And then I have to open 3 different files in my editor:
env.example, the.env, and thestart/env.tsto add my new variable.Then I find myself with lots of new tabs open in my IDE, which is a mess. And even without that, it's boring to do manually.
That's why I suggest the
env:addcommand, which works like this:executing this command will add the variable to the
.env.example,.envandstart/env.tsfiles. The variable name will be converted to SCREAMING_SNAKE_CASE.executing the command without any arguments/flags will display prompts for each of the required values.
Small doubt about the
env.example: the current implementation adds the value of the variable in the.env.examplewhich can be problematic if people aren't careful before committing: they'll push the values to the repo.So, if we want to change this, we'd have to add the possibility of having a specific value for the
.env.examplewhen using theaddmethod of@adonisjs/envEnvEditor: https://github.com/adonisjs/env/blob/develop/src/editor.ts#L61I think it makes sense. I'll do a PR if you guys confirm this