create-envexample v1.2.3
🔨 Create env.example
A simple npm package to create a .env.example file from a .env file.
🎯 Introduction
When working with environment variables, it's common to have a .env
file that contains sensitive information such as API keys or database credentials. However, when sharing your project with others or committing it to a version control system, you may want to exclude this sensitive information. That's where .env.example
comes in!
🚀 Installation
# Install globally
npm install -g create-envexample
# Or use with npx
npx create-envexample
📝 Usage
To create a .env.example
file from your .env
file, simply run:
npx create-envexample
⚙️ How it works
The package performs these steps:
- Reads your
.env
file - Filters out comment lines (starting with #)
- Replaces sensitive values with empty placeholders
- Creates a new
.env.example
file
💡 Example
Your .env file:
DB_HOST=localhost
DB_USER=myuser
DB_PASSWORD=mypassword
API_KEY=1234567890
Generated .env.example:
DB_HOST=
DB_USER=
DB_PASSWORD=
API_KEY=
🎯 Options
The following command-line options are available:
Option | Alias | Description | Default |
---|---|---|---|
--output | -o | Specify output file path | .env.example |
--sort | - | Sort variables and comments alphabetically | false |
--no-comments | - | Remove all comments from output | false |
--delimiter | - | Specify custom delimiter | = |
--verbose | - | Enable verbose mode for debugging | false |
--help | -h | Show help information | - |
📚 Examples
Basic usage:
npx create-envexample
Custom output path:
npx create-envexample -o ./config/.env.template
Sort variables:
npx create-envexample --sort
Remove comments:
npx create-envexample --no-comments
Use custom delimiter:
npx create-envexample --delimiter :
Combined options:
npx create-envexample -o custom.env --sort --no-comments
🔍 Ignoring Variables
You can create a .envignore
file to specify which environment variables should be excluded from the .env.example
file:
# .envignore
GENERATED_KEY
TEMP_TOKEN
🌟 Features
- Preserves comments from original .env file
- Supports custom output path
- Optional sorting of variables
- Configurable delimiter
- Ability to ignore specific variables
- Timestamp generation in output file
🤝 Contributing
Contributions are welcome! Feel free to:
- Fork the repository
- Create your feature branch
- Submit a pull request
License
create-envexample is licensed under the ISC license