1.2.3 • Published 6 months ago

create-envexample v1.2.3

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

🔨 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:

  1. Reads your .env file
  2. Filters out comment lines (starting with #)
  3. Replaces sensitive values with empty placeholders
  4. 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:

OptionAliasDescriptionDefault
--output-oSpecify output file path.env.example
--sort-Sort variables and comments alphabeticallyfalse
--no-comments-Remove all comments from outputfalse
--delimiter-Specify custom delimiter=
--verbose-Enable verbose mode for debuggingfalse
--help-hShow 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

1.2.3

6 months ago

1.2.2

6 months ago

1.2.1

6 months ago

1.1.1

6 months ago

1.1.0

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago