UNPKG

env-sync-cli-tool

Version:

CLI tool to auto-generate and sync .env.example from .env

140 lines (84 loc) • 1.94 kB
# env-sync-cli-tool > ⚔ **Automatically generate and sync your `.env.example` from your `.env` files in Node.js projects, with watch mode support.** --- ## šŸš€ Features āœ… Generates `.env.example` from `.env` by stripping values (keeping keys and comments) āœ… Automatically syncs on `.env` changes with `--watch` flag āœ… Prevents missing environment variables in teams and CI āœ… Simple CLI for local and CI workflows --- ## šŸ“¦ Installation ### Using npm: ```bash npm install env-sync-cli-tool ``` Or globally: ```bash npm install -g env-sync-cli-tool ``` ### āš™ļø Usage Ensure your .env file exists in your project root. Generate .env.example once Using npx: ```bash npx envsync ``` Using globally: ```bash envsync ``` This will generate or update .env.example in your project. #### Watch mode Automatically regenerate .env.example whenever .env changes: ```bash npx envsync --watch ``` or ```bash envsync --watch ``` Press Ctrl + C to stop the watcher when done. Add to your project scripts To automate, add to your package.json: ```bash "scripts": { "sync-env": "envsync", "sync-env:watch": "envsync --watch" } ``` Now you can run: ```bash npm run sync-env ``` or ```bash npm run sync-env:watch ``` for continuous syncing during development. #### šŸ‘„ Recommended Workflow āœ… Commit your .env.example to your repository (never your .env). āœ… Team members can copy it when setting up locally: ```bash cp .env.example .env ``` āœ… Run npx envsync after updating .env to keep .env.example current. ## šŸ“ø Example Given .env: ```bash # Database configuration DB_HOST=localhost DB_USER=root DB_PASS=password123 ``` Generated .env.example: ```bash # Database configuration DB_HOST= DB_USER= DB_PASS= ``` ## šŸ¤ Contributing PRs and issues are welcome to improve the tool or add new features. ## ✨ Author Built with ā¤ļø by [`Codehouze`](https://codehouze.dev) ###