@sharmapukar217/dotenv-utils
v1.0.0
Published
env utils to manage .env files
Readme
dotenv-utils
dotenv-utils is a simple and interactive CLI utility to help you manage your .env files.
It enables you to generate .env.example files by extracting keys from existing .env files, and also to create .env files interactively by filling in missing values based on .env.example.
Features
- Generate
.env.examplefiles by copying keys from your.envand stripping out the values to avoid leaking secrets. - Create or update your
.envfile interactively by prompting for each variable defined in.env.example. - Skip variables during configuration by pressing
Ctrl+C. - Clear informative messages and error handling for better developer experience.
Installation
You can install dotenv-utils globally via npm:
npm install -g dotenv-utilsOr use it directly via npx without global install:
npx dotenv-utils <command> [options]Commands
gen-env-example
Generate a .env.example file by copying all keys from your .env file, replacing all values with empty strings.
dotenv-utils gen-env-example -i .env -o .env.exampleOptions
-i, --input <file>: Path to the source.envfile (default:.env)-o, --output <file>: Path where the generated.env.examplefile will be saved (default:.env.example)
configure-env
Create or update your .env file interactively by reading keys from a .env.example file and prompting you to enter their values.
dotenv-utils configure-env -i .env.example -o .envOptions
-i, --input <file>: Path to the.env.examplefile to read keys from (default:.env.example)-o, --output <file>: Path where the resulting.envfile will be saved (default:.env)
You will be prompted to enter a value for each environment variable defined in .env.example. If you want to skip a variable, press Ctrl+C to abort the process.
Usage Example
- Generate an example file from your existing
.env:
dotenv-utils gen-env-exampleCommit
.env.exampleto your repository to share environment variable keys without secrets.When setting up a new environment, run:
dotenv-utils configure-envand fill in the requested values interactively.
Development
Build
Install dependencies, then run:
npm run buildRun locally
Run your CLI directly from the built files:
node dist/index.js <command> [options]