env-verifier-cli
v1.1.2
Published
๐ก๏ธ A command-line tool to validate .env files against a defined schema to ensure correct environment variable configurations.
Maintainers
Readme
๐ก๏ธ env-verifier-cli
A lightweight and powerful CLI tool to validate your .env files against a defined schema.
Very easy to configure with minimal setup.
๐ Features
Validate .env files for:
- โ Missing or invalid required keys
- โ ๏ธ Unused keys not defined in your schema
- ๐งช Type checking:
string,number,boolean,array,JSON (object),Object, Date - ๐งฉ Support for optional keys, allowing flexible configurations
- ๐ Works with multiple
.envfiles (e.g.,.env.production,.env.staging,.env.test) and supports type-specific validation for each - ๐ ๏ธ Customizable schema for defining required and optional keys with specific types (string, number, boolean, array, JSON)
- ๐ Multi-environment support with easy-to-understand validation for complex configurations
๐ฆ Installation
Global:
npm install -g env-verifier-cliLocal (as dev dependency):
npm install --save-dev env-verifier-cli๐จโ๐ป Usage
env-verifier --env .env --schema env.schema.jsonOr
env-verifier --env .env.staging --schema env.schema.jsonOr for different folder paths
env-verifier --env %USERPROFILE%\Downloads\.env --schema %USERPROFILE%\Downloads\env.schema.json --exit true
env-verifier --env $HOME/Downloads/.env --schema $HOME/Downloads/env.schema.json --exit 1
env-verifier --env ~/Downloads/.env --schema ~/Downloads/env.schema.json --exit falseOptions:
--env Path to the .env file to validate (default: .env)
--schema Path to the schema JSON file (default: env.schema.json)
--exit Set true, 'true' or 1 if you want to throw on invalids or warnings (default: true)๐ Example (for more details see env.schema.json)
.env file:
API_KEY=abc123
DEBUG_MODE=true
PORT=3000env.schema.json file:
{
"REQUIRED_KEYS": {
"API_KEY": "string",
"DEBUG_MODE": "boolean"
},
"OPTIONAL_KEYS": {
"PORT": "number"
}
}๐งฉ Supported Types
- string โ
my-api-key,https://example.com,debug - number โ
3000,42,3.14 - boolean โ
true,false - array โ
["https://myapp.com", "https://admin.myapp.com"],["feature1", "feature2", "feature3"] - JSON (object) โ
{"theme": "dark", "notifications": true},{"maxRetries": 3, "timeout": 5000} - date โ
2025-01-01,2023-05-01T15:30:00Z
๐ FAQ
Don't worry, the .env files provided in this repository contain dummy data only.
