@crabest/envguard
Version:
š”ļø Validate .env files and manage multiple environments with auto-sync
165 lines (121 loc) ⢠5.38 kB
Markdown
# EnvGuard š”ļø
[](https://www.npmjs.com/package/@crabest/envguard)
[](https://opensource.org/licenses/MIT)
A powerful CLI tool that validates `.env` files against `.env.example` files and manages multiple environment configurations with ease.
## ⨠Features
ā
**Environment Validation**: Compare `.env` files against `.env.example` templates
š **Multi-Environment Management**: Manage multiple environments using `.envguard/` directory
š **Auto-Sync**: Automatically saves `.env` changes to the active environment
šÆ **Easy Switching**: Quickly switch between development, staging, production, etc.
š **Fast & Reliable**: Built with Go for speed and reliability
š **Detailed Reports**: Clear summaries showing missing, extra, and valid variables
## š¦ Installation
### Global Installation (Recommended)
```bash
npm install -g @crabest/envguard
```
### Local Installation
```bash
npm install @crabest/envguard
```
## š Quick Start
```bash
# 1. Create your first environment
envguard create -e development --from-current
# 2. Create additional environments
envguard create -e staging
envguard create -e production --from-current
# 3. List all environments
envguard list
# 4. Use environments - edit .env normally!
envguard use production
# Edit .env in your editor...
envguard use development # Previous changes auto-saved!
# 5. Check current environment status
envguard status
# 6. Validate current environment
envguard
# 7. Clean up unused environments
envguard delete -e old-staging
```
## š Available Commands
| Command | Description | Auto-Sync | Example |
|---------|-------------|-----------|---------|
| `envguard` | Validate .env against .env.example | ā
| `envguard` |
| `envguard use <env>` | Use environment + track | ā
| `envguard use production` |
| `envguard status` | Show active environment | ā
| `envguard status` |
| `envguard create -e <env>` | Create new environment | ā
| `envguard create -e staging` |
| `envguard list` | List all environments | ā
| `envguard list` |
| `envguard delete -e <env>` | Delete environment | ā | `envguard delete -e old-env` |
## šÆ Example Output
```
š EnvGuard - Environment File Validator
š Validation Results:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š Comparing: .env ā .env.example
ā
Variables found in both files (8):
ā DATABASE_URL
ā API_KEY
ā PORT
ā JWT_SECRET
ā ļø Missing variables in .env (2):
⢠EMAIL_SERVICE_KEY
⢠WEBHOOK_SECRET
š Summary:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š ā
8 variables OK ⢠ā ļø 2 missing
```
## š Platform Support
EnvGuard supports the following platforms:
- **macOS** (Intel & Apple Silicon)
- **Linux** (x64)
- **Windows** (x64)
## š How It Works
- **`.envguard/` Directory**: All environment files are stored in this hidden directory
- **Active Environment**: The root `.env` file is always your active environment
- **Auto-Sync**: Any changes to `.env` are automatically saved to the active environment
- **Environment Usage**: `envguard use` copies the selected environment to `.env`
- **Active Tracking**: `envguard use` tracks the current environment in `.envguard/.active`
- **Status Checking**: `envguard status` shows which environment is currently active
- **Validation**: Always validates the active `.env` against `.env.example`
- **Isolation**: Each environment is completely isolated and independent
## š ļø Development Workflow
```bash
# Set up your project environments
envguard create -e development --from-current
envguard create -e staging
envguard create -e production --from-current
# Work with different environments - edit .env normally!
envguard use development # Switch to development
# Edit .env in your favorite editor...
envguard status # Auto-saves changes, shows current environment
envguard # Auto-saves changes, validates environment
envguard use production # Auto-saves dev changes, switches to production
envguard status # Confirm you're in production
envguard # Validate before deployment
```
## š Troubleshooting
### Permission Issues (macOS/Linux)
```bash
# If you get permission errors, run:
chmod +x $(which envguard)
```
### Reinstallation
```bash
# If something goes wrong, try:
npm uninstall -g @crabest/envguard
npm install -g @crabest/envguard
```
### Platform Not Supported
If you get an "Unsupported platform" error, EnvGuard currently supports:
- macOS (darwin)
- Linux
- Windows (win32)
## š License
MIT License - see [LICENSE](LICENSE) file for details.
## š¤ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## š Links
- [Source Code](https://github.com/crabest/envguard)
- [Issues](https://github.com/crabest/envguard/issues)
- [npm Package](https://www.npmjs.com/package/@crabest/envguard)