npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

env-version-tracker

v1.1.1

Published

A CLI tool to track deployments version across multiple environments

Readme

env-version-tracker

CLI tool to track which version is deployed in each environment. Works with local JSON files or MongoDB.

Install

npm install --save-dev env-version-tracker

After 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 dev

Setup

1. Configure where to store versions

Using a JSON file:

evt config local --storage-path ./versions.json

Using 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

  1. Create a .env file in your project with the following variables:
# .env file
DATABASE_URL=mongodb://localhost:27017
DATABASE_NAME=version-tracker
COLLECTION_NAME=versions
  1. Configure the tool to use the .env file for all environments:
evt config remote --storage-env-file .env

Option 2: Different .env file per environment (recommended)

  1. Create separate .env files 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
  1. 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.production

Or 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.production

Supported environment variable names (generic, provider-agnostic):

  • URL: DATABASE_URL (recommended), DATABASE_URI, DB_URL, or DB_URI
  • Database: DATABASE_NAME (recommended), DATABASE, DB_NAME, or DB
  • Collection: COLLECTION_NAME (recommended), COLLECTION, TABLE_NAME, or TABLE

Legacy MongoDB-specific names (still supported for backward compatibility):

  • MONGODB_URL, MONGO_URL, MONGODB_URI, MONGO_URI
  • MONGODB_DATABASE, MONGO_DATABASE, MONGODB_DB, MONGO_DB
  • MONGODB_COLLECTION, MONGO_COLLECTION, MONGODB_COL, MONGO_COL

Note:

  • The .env file path can be absolute or relative to your project root.
  • Security: Make sure to add .env to your .gitignore file to avoid committing sensitive credentials.

2. Optional: Auto-track after git push

If you want the tool to ask for version info automatically after each git push:

evt setup-hook

This 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-alias

3. Track a deployment

Manual:

evt push patch dev
evt push minor staging
evt push major production

With 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)

Commands

config <storage> [options] - Set up where to store versions

  • storage: local or remote
  • 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 like 1.2.3
  • environment: dev, staging, preprod, production
  • --track-author: Include git author email (flag, no value needed)

Important notes:

  • For remote storage, the tool automatically loads the .env file configured for the specified environment. If no .env file 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 "[email protected]"
  • The tool validates configuration and version format before pushing to git, so you can use git push separately 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

⚠️ Warning: This overrides the standard 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)

How it works

  • 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

What gets created

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.

Examples

Basic usage:

evt push patch dev
# Version 1.0.1 pushed to dev

With author tracking:

evt push minor staging --track-author true

With 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!

Data format

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": "[email protected]",
    "createdAt": "2024-01-15T10:30:00.000Z"
  }
]

MongoDB uses the same structure.

Troubleshooting

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

TODO

  • [x] 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

Requirements

  • 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 "[email protected]"

License

ISC