abd-env-guard
v2.0.0
Published
Advanced CLI tool to protect .env files with Git history tracking, strict mode, JSON output, auto-backup, and support for multiple ignore files
Maintainers
Readme
🛡️ abd-env-guard v2.0
An advanced CLI tool to protect .env files and sensitive data with Git history tracking, strict mode for CI/CD, JSON output, auto-backup, and support for multiple ignore file types.
🚨 NEW in v2.0: Git history scanning, strict mode, JSON output, auto-backup, custom patterns, and much more!
📦 Installation
npm install -g abd-env-guardOr use with npx (no install):
npx abd-env-guard🚀 Usage
abd-env-guard [options]🔧 Available Options
| Flag | Description |
|------------------|--------------------------------------------------------------------------|
| --fix | Automatically adds missing ignore patterns |
| --interactive | Prompts user before creating or editing ignore file |
| --verbose | Shows detailed logging output |
| --file <name> | Use a custom ignore file (e.g. .dockerignore, .npmignore) |
| --recursive | Recursively scans folders (e.g. for monorepos) |
| --strict | NEW! Exit with code 1 if issues found (perfect for CI/CD) |
| --json | NEW! Output results in JSON format for automation |
| --ci | NEW! Alias for --strict --json |
| --ignore | NEW! Add custom ignore patterns via command line |
| --help | Displays help information |
🆕 New in v2.0 - Advanced Features
🚨 Feature 1: Git History Scanning
Detects if .env files were ever committed to Git history (even if now in .gitignore):
abd-env-guard
# Output: 🚨 These files were found in Git history:
# - .env (first added: 12/25/2023, commit: a1b2c3d4)
# └─ "Initial project setup"⚙️ Feature 2: Strict Mode for CI/CD
Fail builds if sensitive files are detected:
abd-env-guard --strict
# Exit code 1 if issues found, 0 if all good📦 Feature 3: Postinstall Hook
Add to package.json to protect new team members:
{
"scripts": {
"postinstall": "abd-env-guard --strict"
}
}🎨 Feature 4: Color-coded Output
Beautiful, readable terminal output with colors (optional dependency).
🤖 Feature 5: CI-friendly JSON Output
Perfect for DevOps pipelines:
abd-env-guard --json
# {
# "status": "failed",
# "missing": [".env"],
# "gitIssues": {
# "tracked": [],
# "inHistory": [".env"]
# }
# }🔧 Feature 6: Custom Ignore Patterns
Add patterns via command line:
abd-env-guard --ignore ".env.secret" "config/*.key" "private/**"💾 Feature 7: Auto-backup
Automatically creates .gitignore.bak before modifications.
🔍 Feature 8: Git History Details
Shows when and how sensitive files were first committed:
abd-env-guard --verbose
# Shows commit hash, date, and message for each file🌐 Feature 9: Glob Pattern Support
Powerful pattern matching for complex file structures.
📁 Feature 10: Multiple Ignore File Support
Works with various ignore files:
abd-env-guard --file .dockerignore # Docker builds
abd-env-guard --file .npmignore # NPM publishing
abd-env-guard --file .eslintignore # ESLint
abd-env-guard --file .prettierignore # Prettier💡 Examples
✅ Check .gitignore in the current folder:
abd-env-guard🛠️ Auto-fix missing ignore entries:
abd-env-guard --fix👨💻 Interactive prompt for action:
abd-env-guard --interactive📁 Use a custom ignore file:
abd-env-guard --file .dockerignore🧭 Scan all folders recursively (monorepo mode):
abd-env-guard --recursive🔐 What It Checks
By default, the tool checks for these common patterns:
.env.env.local.env.*.local
⚙️ Optional Configuration
You can create a .abd-env-guardrc JSON config file to define custom ignore patterns:
{
"ignore": [".env", "config/secrets.env", "private/**"]
}This allows you to customize the files to detect and suggest ignoring.
🔍 Git Awareness
- Warns if sensitive files are already tracked by Git
- Skips git check if run outside a Git repository
👨💻 Author
Abdullah Firdowsi
GitHub
📄 License
MIT
