util-dotenv
v1.0.4
Published
Utility cli to manage .env files.
Readme
util-dotenv
util-dotenv 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 util-dotenv globally via npm:
npm install -g util-dotenvOr use it directly via npx without global install:
npx util-dotenv <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.
util-dotenv 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.
util-dotenv 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:
util-dotenv gen-env-exampleCommit
.env.exampleto your repository to share environment variable keys without secrets.When setting up a new environment, run:
util-dotenv 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]