1.0.0 ⢠Published 10 months ago
@arshtiwari/envguard v1.0.0
Quick Start
Install via NPM
npm install @arshtiwari/envguardAdd to Project Startup
require('envguard'); // Validates env vars on startupOr Use CLI
npx envguard validateFeatures
- Zero-config: Works out-of-the-box with your existing
.env.example - Framework-agnostic: Use in any Node.js or frontend project
- Auto-documentation: Keeps
.env.exampleup-to-date - CLI & Programmatic API: Validate env vars in scripts, CI, or app startup
- React UI: Visualize, debug, and document env variables (dev only)
- Descriptive errors: Friendly messages for missing/misconfigured variables
š§° Tech Stack
| Category | Technologies |
|---|---|
| Backend/Core | TypeScript, Node.js |
| Schema Validation | Zod, Custom Schema Generator |
| File Parsing | dotenv, fs-extra |
| CLI | yargs, commander |
| Frontend (UI) | React.js, Vite , TailwindCSS |
| Testing | Jest |
| CI/CD | GitHub Actions |
Installation and setup
1. Install
npm install --save-dev envguard2. Validate in CLI
npx envguard validate3. Use Programmatically
const { runEnvguard } = require('envguard');
if (!runEnvguard()) {
process.exit(1);
}4. Access frontend
cd ui
npm install
npm run devVisit http://localhost:5173 to view the UI.
Folder Structure
envguard/
āāā .env.example # Example env file for validation
āāā .gitignore
āāā README.md # Project documentation
āāā package.json
āāā babel.config.js # Babel config for transpiling (if needed)
āāā jest.config.js # Jest config for tests
āāā tsconfig.json # TypeScript config (optional)
āāā LICENSE
āāā dist/ # Transpiled output for npm (ignored in VCS)
ā āāā ... # Compiled JS files
āāā src/ # Main source code
ā āāā index.js # Main entry point (exports runEnvguard)
ā āāā parser/
ā ā āāā envExampleParser.js
ā āāā schema/
ā ā āāā schemaGenerator.js
ā āāā validator/
ā ā āāā validator.js
ā āāā reporter/
ā ā āāā errorReporter.js
ā āāā cli/
ā ā āāā cli.js # CLI entry point
ā āāā utils/
ā ā āāā helpers.js
ā āāā types/
ā āāā index.d.ts # Type definitions
āāā server/ # Backend server for live UI (optional)
ā āāā server.js
āāā scripts/ # Utility scripts (e.g., generate .env.example)
ā āāā generateEnvExample.js
āāā tests/ # Jest test files
ā āāā parser.test.js
ā āāā schema.test.js
ā āāā validator.test.js
ā āāā cli.test.js
āāā ui/ # React UI dashboard (dev/optional)
ā āāā src/
ā ā āāā App.jsx
ā ā āāā main.jsx
ā ā āāā index.css
ā ā āāā components/
ā ā āāā EnvTable.jsx
ā āāā public/
ā ā āāā index.html
ā ā āāā env-vars.json # (for demo, replaced by API in prod)
ā āāā tailwind.config.js
ā āāā vite.config.js
āāā website/ # Landing page (for npm promotion)
ā āāā src/
ā ā āāā App.jsx
ā ā āāā main.jsx
ā ā āāā components/
ā ā āāā Hero.jsx
ā ā āāā Pricing.jsx
ā āāā public/
ā ā āāā index.html
ā āāā tailwind.config.js
ā āāā vite.config.jsHow It Works
- Parse your
.env.examplefor variable names and defaults. - Generate a validation schema automatically.
- Validate your actual environment (
process.env) against the schema. - Report errors in CLI, programmatically, or visually in the UI.
Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
License
MIT Ā© Arsh Tiwari
š¬ Contact
Have questions or need help? Feel free to reach out!
- Email: arshtiwari12345@gmail.com
- GitHub: @ArshTiwari2004
- Twitter/X: @ArshTiwari17
- LinkedIn: Arsh Tiwari
For bug reports or feature requests, please open an issue on GitHub.