CLI tool to track which version is deployed in each environment. Works with local JSON files or MongoDB.
npm install --save-dev env-version-trackerAfter installation, use the evt command (short for Env Version Tracker).
Using npx (without installation):
npx evt <command>
# Example:
npx evt config remote --env-file-dev .env.dev
npx evt push patch devUsing a JSON file:
evt config local --storage-path ./versions.jsonUsing MongoDB:
You can configure a different .env file for each environment, or use the same file for all environments.
Option 1: Same .env file for all environments
- Create a
.envfile in your project with the following variables:
# .env file
DATABASE_URL=mongodb://localhost:27017
DATABASE_NAME=version-tracker
COLLECTION_NAME=versions- Configure the tool to use the
.envfile for all environments:
evt config remote --storage-env-file .envOption 2: Different .env file per environment (recommended)
- Create separate
.envfiles for each environment:
# .env.dev
DATABASE_URL=mongodb://dev-server:27017
DATABASE_NAME=version-tracker-dev
COLLECTION_NAME=versions
# .env.staging
DATABASE_URL=mongodb://staging-server:27017
DATABASE_NAME=version-tracker-staging
COLLECTION_NAME=versions
# .env.production
DATABASE_URL=mongodb://prod-server:27017
DATABASE_NAME=version-tracker-prod
COLLECTION_NAME=versions- Configure each environment separately:
evt config remote \
--env-file-dev .env.dev \
--env-file-staging .env.staging \
--env-file-preprod .env.preprod \
--env-file-production .env.productionOr configure them one by one:
evt config remote --env-file-dev .env.dev
evt config remote --env-file-staging .env.staging
evt config remote --env-file-production .env.productionSupported environment variable names (generic, provider-agnostic):
- URL:
DATABASE_URL(recommended),DATABASE_URI,DB_URL, orDB_URI - Database:
DATABASE_NAME(recommended),DATABASE,DB_NAME, orDB - Collection:
COLLECTION_NAME(recommended),COLLECTION,TABLE_NAME, orTABLE
Legacy MongoDB-specific names (still supported for backward compatibility):
MONGODB_URL,MONGO_URL,MONGODB_URI,MONGO_URIMONGODB_DATABASE,MONGO_DATABASE,MONGODB_DB,MONGO_DBMONGODB_COLLECTION,MONGO_COLLECTION,MONGODB_COL,MONGO_COL
Note:
- The
.envfile path can be absolute or relative to your project root. - Security: Make sure to add
.envto your.gitignorefile to avoid committing sensitive credentials.
If you want the tool to ask for version info automatically after each git push:
evt setup-hookThis creates a deploy alias that you can use instead of git push. After a successful push, you'll be prompted for version tag and environment.
To override git push directly (may cause conflicts):
evt setup-push-aliasManual:
evt push patch dev
evt push minor staging
evt push major productionWith alias installed:
Use git deploy instead of git push. After a successful push, you'll be prompted for version tag and environment.
git deploy origin main
# After successful push, prompts appear automatically:
# ? What version tag? (Use arrow keys)
# ? Which environment?
# ? Track the author? (y/N)config <storage> [options] - Set up where to store versions
storage:localorremote- For local storage:
--storage-path <path>: Path to JSON file
- For remote storage:
--storage-env-file <path>: Use same .env file for all environments--env-file-dev <path>: .env file for dev environment--env-file-staging <path>: .env file for staging environment--env-file-preprod <path>: .env file for preprod environment--env-file-production <path>: .env file for production environment
push <version-tag> <environment> [options] - Record a deployment
version-tag:major,minor,patch, or exact version like1.2.3environment:dev,staging,preprod,production--track-author: Include git author email (flag, no value needed)
Important notes:
- For remote storage, the tool automatically loads the
.envfile configured for the specified environment. If no.envfile is configured, you'll get an error with instructions to configure it. - To use
--track-author, you must have git configured with your email:git config --global user.email "your.email@example.com" - The tool validates configuration and version format before pushing to git, so you can use
git pushseparately if needed.
setup-hook - Enable auto-tracking by creating a deploy git alias
Creates a git deploy command that wraps git push and triggers version tracking after successful pushes. This is the recommended approach to avoid conflicts with the standard git push command.
setup-push-alias - Override git push directly with version tracking
git push command and may cause conflicts. Use setup-hook instead for a safer approach.
remove-hook - Remove git aliases (deploy and push if configured)
- Calculates the next version based on the last version for that environment
- Gets commit info from git (hash, message, author if enabled)
- Handles merge commits by extracting the original commit
- Saves everything to your configured storage
After running setup-hook, a git alias deploy is configured in your local git config.
Your project will have:
your-project/
├── .env-version-tracker/
│ ├── config.json # Your config (stores .env file paths per environment)
│ └── git-push-wrapper.sh # Git push wrapper script
├── .env.dev # Dev environment credentials (add to .gitignore!)
├── .env.staging # Staging environment credentials (add to .gitignore!)
├── .env.production # Production environment credentials (add to .gitignore!)
└── versions.json # Version history (if local storage)
Config is stored in .env-version-tracker/config.json per project. For remote storage, only the paths to your .env files are stored (one per environment), not the actual credentials.
Debug logs: If something goes wrong, check /tmp/evt-debug.log for detailed logs.
Basic usage:
evt push patch dev
# Version 1.0.1 pushed to devWith author tracking:
evt push minor staging --track-author trueWith alias (automatic):
git deploy origin main
# After successful push, prompts appear automatically:
# 🚀 Post-push handler triggered!
# Tracking version...
# ? What version tag? (Use arrow keys)
# ? Which environment?
# ? Track the author? (y/N)
# ✅ Version tracking completed!Versions are stored with:
- Version number (auto-incremented)
- Environment name
- Git commit hash and message
- Author (optional)
- Timestamp
Local JSON example:
[
{
"version": "1.0.1",
"environment": "dev",
"commitHash": "abc123",
"commitMessage": "feat: new feature",
"author": "user@example.com",
"createdAt": "2024-01-15T10:30:00.000Z"
}
]MongoDB uses the same structure.
Alias not working?
- Check if the alias exists:
git config --local --get alias.deploy - Verify the script exists:
ls -la .env-version-tracker/git-push-wrapper.sh - Check debug logs:
cat /tmp/evt-debug.log
Want to remove the alias?
evt remove-hook
# Or manually:
git config --local --unset alias.deploy
git config --local --unset alias.push- On config, ask for env file instead of asking directly the remote storage path
- Use husky or another git hook instead of deploy alias
- Add another storage provider
- Node.js >= 20.0.0 (tested with v20 and v22)
- Git repo (for commit info)
- Git configured with user email if using
--track-author:git config --global user.email "your.email@example.com"
ISC