Skip to content

Simple script that generate .env files by parsing .template-env files and replacing placeholder with values read from /config/envs/<env>.json

License

Notifications You must be signed in to change notification settings

FrazCake/generate-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

generate-env

Simple script that generate .env files by parsing .template-env files and replacing placeholder with values read from /config/envs/<env>.json.

The reason behind this tool is to write all the configuration in a central place and spread the values across all the env files where needed.

Example

.template-env

SERVICE_X_API_KEY={{x.apiKey}}
SERVICE_X_NAME={{x.name}}

SERVICE_Y_API_KEY={{y.apiKey}}
SERVICE_Y_NAME={{y.name}}

/config/envs/dev.json

{
  "x": {
    "apiKey": "aSuperSecretApiKeyHere",
    "name": "amazingServiceX"
  },
  "y": {
    "apiKey": "anotherSuperSecretApiKeyHere",
    "name": "amazingServiceY"
  }
}

than just exec:

yarn generate-env dev

Now for each .template-env file in your codebase, a new .env file will be created/updated with the variable read from the central configuration.

You can easily push your secrets stored in configuration by encrypting them with some tools like Mozilla sops or other similar tools.

About

Simple script that generate .env files by parsing .template-env files and replacing placeholder with values read from /config/envs/<env>.json

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published