The utility allows you to easily template your .env files by mapping it in .json.
{
"@extends": ".examples/prod/bar.json",
"siteName": "Foo",
"siteDomain": "example.com",
"siteUrl": "https://{siteDomain}/help",
"webmasterName": "webmaster",
"webmasterEmail": "{webmasterName}@{siteDomain}",
"debug": 0
}
vvv
# Autogenerated with env-preset
SITE_NAME=Foo
SITE_DOMAIN=example.com
SITE_URL=https://example.com/help
WEBMASTER_NAME=webmaster
WEBMASTER_EMAIL=webmaster@example.com
HELLO_FROM_BAR={"bar":"Hello World!"}
DEBUG=0
- The project requires Node v14 or higher. To install it, use npm:
npm install --save-dev env-preset
- After the installation create .epconfig.json and enter your preferences:
nano .epconfig.json
Available preferences:
{
"input": ".examples/prod/foo.json",
"envInput": ".env.example",
"output": ".env",
"depth": 3,
"objDepth": 3,
"logging": 0,
"errorLogging": 1
}
- Compile your ENVs:
npx env-preset
You're all set!
- You can set all preferences in .epconfig.json:
{
"input": ".configs/prod.json",
"output": ".env",
"errorLogging": 0
}
- The "@extends" directive mixes your ENV with the target one:
{
"@extends": ".examples/variables.json",
"color": "{green}",
"secondColor": "{blue}"
}
- You can use CLI to override the config:
env-preset --input .examples/prod.json --output .env
env-preset
by Kenny Romanov