stackdiff
v0.1.0
Published
Dump environment variables and diff them between snapshots
Maintainers
Readme
⚡ stackdiff
Snapshot, dump, and diff your environment variables. Detect installed tool versions. Beautiful colored output with spinners.
Install
npm install -g stackdiffOr use with npx:
npx stackdiff dumpCommands
| Command | Description |
|---------|-------------|
| stackdiff dump | Dump all current environment variables (sorted, colored) |
| stackdiff save <name> | Save current env as a named snapshot |
| stackdiff diff <a> [b] | Diff snapshot a vs snapshot b (or current env if b omitted) |
| stackdiff list | List all saved snapshots with timestamps |
| stackdiff delete <name> | Delete a saved snapshot |
| stackdiff search <pattern> | Search env vars by key or value (regex supported) |
| stackdiff export [name] | Export env (or snapshot) as .env file format |
| stackdiff stats [name] | Show summary stats (var count, PATH entries, sizes) |
| stackdiff versions | Detect and display installed tool versions |
| stackdiff containers | Show Docker/Podman containers, images, volumes, networks |
| stackdiff help | Show help |
Usage Examples
Dump current environment
stackdiff dumpOutputs all variables sorted alphabetically with colored KEY=value formatting and a total count.
Save & compare snapshots
# Save env before making changes
stackdiff save before
# ... install something, change PATH, etc. ...
# See what changed
stackdiff diff beforeOutput shows added (green), removed (red), and changed (yellow) variables with before/after values.
Compare two snapshots
stackdiff save dev
stackdiff save prod
stackdiff diff dev prodView environment stats
stackdiff statsEnvironment stats (current):
Total variables: 68
Total value size: 4131 chars
PATH entries: 50
Longest key: NuGetPackageSourceCredentials_vsts
Longest value: Path (2291 chars)Search variables
stackdiff search PATHSearch for variables whose key or value matches a regex pattern (case-insensitive).
Export as .env file
# Export current env
stackdiff export > .env
# Export a snapshot
stackdiff export prod > prod.envOutputs variables in KEY="value" format with proper escaping, suitable for use with dotenv or Docker.
Delete a snapshot
stackdiff delete old-snapshotDetect tool versions
stackdiff versionsDetected tool versions:
node v22.17.0
npm 11.11.0
npx 11.11.0
pnpm 10.33.0
git git version 2.48.1.windows.1
python Python 3.13.0
java openjdk version "23.0.2" 2025-01-21
dotnet 10.0.203
docker Docker version 29.2.1, build a5c7197Detected tools: node, npm, npx, yarn, pnpm, git, python, java, dotnet, docker (skips any not installed).
Docker/Podman containers
stackdiff containersContainer runtime: docker
┌ Containers (2)
│ my-api image=node:22-alpine Up 3 hours
│ my-db image=postgres:16 Up 3 hours
┌ Images (5)
│ node:22-alpine 187MB
│ postgres:16 430MB
│ redis:7-alpine 40MB
│ ...
┌ Volumes (1)
│ pgdata local
┌ Networks (3)
│ bridge bridge
│ host host
│ my-app-net bridgeAutomatically detects whether Docker or Podman is available and displays all containers (running and stopped), images, volumes, and networks.
Programmatic API
const { dumpEnv, saveSnapshot, loadSnapshot, diffEnv, searchEnv, exportEnv, deleteSnapshot, getVersions, detectContainerRuntime, getContainerInfo } = require('stackdiff');
// Get all env vars as a formatted string
console.log(dumpEnv());
// Save/load snapshots
saveSnapshot('./snap.json');
const env = loadSnapshot('./snap.json');
// Diff two env objects
const result = diffEnv(envA, envB);
// result = { added: ['NEW_VAR'], removed: ['OLD_VAR'], changed: ['MODIFIED_VAR'] }
// Search env vars by pattern (regex, case-insensitive)
const matches = searchEnv('node', process.env);
// matches = [{ key: 'NODE_ENV', value: 'production' }, ...]
// Export as .env format string
const dotenv = exportEnv(process.env);
// Delete a snapshot
deleteSnapshot('./snap.json'); // returns true/false
// Get installed tool versions
const versions = getVersions();
// versions = [{ name: 'node', version: 'v22.17.0' }, ...]
// Docker/Podman info
const runtime = detectContainerRuntime(); // 'docker', 'podman', or null
const info = getContainerInfo();
// info = { runtime, containers: [...], images: [...], volumes: [...], networks: [...] }Snapshots
Snapshots are stored in .stackdiff/ in the current working directory as JSON files. Add .stackdiff/ to your .gitignore if you don't want to commit them.
.stackdiff/Requirements
- Node.js >= 16.0.0
License
MIT
