cli icon indicating copy to clipboard operation
cli copied to clipboard

Replace the command env:import with env:push

Open ivorpad opened this issue 3 years ago • 1 comments

Which problem is this feature request solving?

I think env:import is terribly confusing and very prone to errors, and I understand this might be too much to ask, however I think this command reads as import the environment variables to a .env local file, but after it's run the variables are overwritten in the Netlify UI without any warning.

Describe the solution you'd like

Instead of netlify env:import .env:

  • netlify env:get and netlify env:list to get the environment files
  • netlify env:push .env to 'push' the environment variables to netlify

ivorpad avatar Jun 02 '22 16:06 ivorpad

+1. When I read netlify env:import I think I'm importing the env variables from the Netlify UI to my local machine.

If possible, can we also have a command called netlify env:pull .env which pulls the environment variables from the Netlify UI to your local machine?

watadarkstar avatar Jun 02 '22 18:06 watadarkstar

@ivorpad env:import goes against my expectations as well, and I like that introducing a new word, env:push avoids the confusion that would result from changing it to env:export. 😵

I think it makes sense to add env:push and make it the default, documented command for uploading env vars, but still keep env:import as a legacy alias for backward compatibility.

On a separate note, your point about overriding variables in the UI without warning is now solved with the introduction of a new --replaceExisting flag. When run without the flag, env:import now merges with UI variables instead of replacing them.

@watadarkstar for the "pull"-style functionality you're asking for, we have a proposal in https://github.com/netlify/cli/issues/3262 to add a --plain flag to env:list that formats the env var list so that it can be piped into a local .env file in the proper format. I could potentially see adding an env:pull [path] alias that essentially runs env:list --plain > [path].

verythorough avatar Dec 01 '22 03:12 verythorough

@watadarkstar You should be able to use the newly added --plain flag like netlify env:list --plain > [path of file to write] to pull the environment variables & write them to a file on local machine now.

Update the Netlify CLI package to v12.5.0 or greater to use the --plain flag.

tinfoil-knight avatar Dec 22 '22 12:12 tinfoil-knight

Thank you, @tinfoil-knight !

verythorough avatar Dec 22 '22 18:12 verythorough