@eminemah/checkmyenv
v1.0.1
Published
CLI to scan code for process.env vars, compare with .env, and sync with .env.example
Maintainers
Readme
checkmyenv
Scan your project for process.env.* usages, compare them with your .env, and keep .env in sync with .env.example.
Features
- Scan project files for environment variables (
process.env.*). - Compare with
.envto find missing and unused variables. - Interactive prompts to fill in missing values.
- Generate a new
.envif it doesn’t exist. - Sync
.envwith.env.example. - Install globally and use as a CLI.
Installation
npm install -g checkmyenvRequires Node.js >= 18.
Usage
# Using npx (recommended)
npx @eminemah/checkmyenv DB_URL API_KEY PORT SECRET_KEY
# Or, if globally installed correctly
checkmyenv DB_URL API_KEY PORT SECRET_KEY
# Show report of missing/unused variables
checkmyenv check
# Create/update .env by prompting for missing values
checkmyenv generate
# Merge .env with .env.example (prompts for any missing values)
checkmyenv syncOptions:
-e, --env-file <path>: Path to.envfile (default.env)-x, --example-file <path>: Path to.env.example(default.env.example, sync only)-p, --patterns <globs...>: File globs to scan (default**/*.{js,jsx,ts,tsx,mjs,cjs,vue,svelte})-i, --ignore <globs...>: Ignore globs (default**/node_modules/** **/dist/** **/build/** **/.git/**)
Examples
# Scan a monorepo workspace
checkmyenv check -p "packages/**/*.{ts,tsx}" -i "**/node_modules/**" "**/dist/**"
# Generate .env in a custom path
checkmyenv generate -e ./config/.env
# Sync with a custom example file
checkmyenv sync -e .env -x .env.exampleHow it works
- Uses glob patterns to find files.
- Regex-detects
process.env.VAR_NAMEoccurrences. - Parses
.envusingdotenvand compares the keys to what’s used in code.
License
MIT
