1.0.8 • Published 10 months ago

@arshtiwari/envguard v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Quick Start

Install via NPM

npm install @arshtiwari/envguard

Add to Project Startup

require('envguard'); // Validates env vars on startup

Or Use CLI

npx envguard validate

Features

  • 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.example up-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

CategoryTechnologies
Backend/CoreTypeScript, Node.js
Schema ValidationZod, Custom Schema Generator
File Parsingdotenv, fs-extra
CLIyargs, commander
Frontend (UI)React.js, Vite , TailwindCSS
TestingJest
CI/CDGitHub Actions

Installation and setup

1. Install

npm install --save-dev envguard

2. Validate in CLI

npx envguard validate

3. Use Programmatically

const { runEnvguard } = require('envguard');
if (!runEnvguard()) {
process.exit(1);
}

4. Access frontend

cd ui
npm install
npm run dev

Visit 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.js

How It Works

  1. Parse your .env.example for variable names and defaults.
  2. Generate a validation schema automatically.
  3. Validate your actual environment (process.env) against the schema.
  4. 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!

For bug reports or feature requests, please open an issue on GitHub.


1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.0

10 months ago