env-genius
v1.0.2
Published
Scan project for env usage and create a .env file with detected variables and sensible defaults.
Maintainers
Readme
🌡️ env-genius
env-genius is a beginner-friendly CLI tool that scans your project for environment variables and automatically generates a .env file. Even if your project has no .env, it will detect variables like PORT, MONGO_URI, or any process.env.KEY usage in your code to help you get started quickly.
🚀 Why Use env-genius?
Environment variables are crucial for:
- Database URLs
- API keys
- Secret tokens
- Port numbers
Beginners often forget to create a .env file or make formatting mistakes. env-genius automatically:
- Detects environment variables in your code
- Provides default values if available
- Creates a
.envfile for you - Gives friendly warnings about formatting issues
🔧 Installation
Local (for your project)
npm install env-geniusGlobal (CLI accessible anywhere)
npm install -g env-genius🧪 Usage
1. Scan your project and create .env
npx env-genius
# or if installed globally
env-genius- If
.envalready exists, it will warn you. - Use
--forceto overwrite an existing.env.
2. Dry run (show detected variables without writing)
env-genius --dry📂 Example
Suppose your project has no .env, and your code contains:
const PORT = process.env.PORT || 3000;
const DB = process.env.DB_URL ?? "mongodb://localhost/test";
const SECRET = process.env.JWT_SECRET;Running env-genius will generate:
PORT=3000
DB_URL=mongodb://localhost/test
JWT_SECRET=
# TODO: provide value for JWT_SECRET🛠 How It Works
- Scans project files:
.js,.ts,.jsx,.tsx,.mjs,.cjs - Detects
process.env.KEYusage - Detects fallback/default values if present (
||or numeric defaults) - Generates
.envwith placeholders for missing values - Provides friendly warnings about key formatting
📄 License
MIT License — free for personal and commercial use.
