envsight
v1.0.0
Published
CLI tool for environment variables
Readme
🛡 envsight
A lightweight environment variable validator CLI for Node.js projects.
Prevent runtime crashes caused by missing environment variables by validating your configuration before running your application or deploying.
Features
- Validate required environment variables
- Detect missing environment variables
- Support optional environment variables
- Generate
.env.exampleautomatically - Safe overwrite using
--force - CLI support
- JSON output mode
- Config file support
- GitHub Actions support
Installation
Install globally:
npm install -g envsightInstall Locally:
npm install envsightUse directly with npx:
npx envsightSetup
Create a configuration file in your project root:
envsight.config.jsExample:
export default {
required: [
"DATABASE_URL",
"JWT_SECRET"
],
optional: [
"PORT",
"REDIS_URL"
]
}Your project Structure:
my-project/
├── src/
├── .env
├── envsight.config.js
├── package.json
└── node_modules/Example .env:
DATABASE_URL=my_database_url
JWT_SECRET=my_secret
PORT=5000Usage
- Check Environment Variables
Run:
envsight checkExample Output:
🛡 envsight
Checking environment...
✔ DATABASE_URL
✔ JWT_SECRET
✔ Environment validation passed- Generate .env.example
Generate a template file from your .env:
envsight initExample:
Before:
DATABASE_URL=my_database
JWT_SECRET=my_secretAfter:
DATABASE_URL=
JWT_SECRET=- Force Regenerate
If .env.example already exists:
envsight initwill not overwrite it.
To OverWrite :
envsight init --forceOutput:
✔ .env.example regenerated- JSON Output
Useful for CI/CD pipelines
envsight check --jsonExample :
{
"success": true,
"missing": [],
"present": [
"DATABASE_URL",
"JWT_SECRET"
]
}Github Actions
Create:
.github/workflows/env-check.yml
Add :
name: Environment Check
on:
push:
pull_request:
jobs:
check-env:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm install
- name: Validate environment
run: npx envsight checkNow every push and pull request validates your environment automatically.
Commands
| Command | Description |
| ----------------------- | ------------------------------ |
| envsight check | Validate environment variables |
| envsight check --json | Output JSON result |
| envsight init | Generate .env.example |
| envsight init --force | Regenerate .env.example |
Development
Clone Repository :
git clone https://github.com/Aayush-0821/envsight.gitInstall Dependencies:
npm installBuild:
npm run buildRun Tests:
npm testLicense
MIT License
