|
| 1 | +# envcheck |
| 2 | + |
| 3 | +[](https://github.com/ayushdad609-code/envcheck/actions) |
| 4 | +[](LICENSE) |
| 5 | +[](https://github.com/ayushdad609-code/envcheck/releases) |
| 6 | + |
| 7 | +> Validates .env files against a typed schema so missing or misconfigured variables fail loudly before your app boots. |
| 8 | +
|
| 9 | +<!-- DEMO GIF OR SCREENSHOT — MANDATORY. See section 1.5 for how to generate --> |
| 10 | + |
| 11 | + |
| 12 | +## Why I built this |
| 13 | +I was constantly debugging production crashes caused by a missing `STRIPE_API_KEY` or a malformed `DATABASE_URL` in the `.env` file. Existing tools were either too heavy, tightly coupled to a framework, or didn't validate the types (just the presence) of the variables. `envcheck` fixes this by making environment validation a single step in your build or boot process. |
| 14 | + |
| 15 | +## Install |
| 16 | + |
| 17 | +```bash |
| 18 | +# npm (global) |
| 19 | +npm install -g envcheck-cli |
| 20 | + |
| 21 | +# npx (run without installing) |
| 22 | +npx envcheck-cli |
| 23 | + |
| 24 | +# curl (Linux/macOS) |
| 25 | +curl -fsSL https://raw.githubusercontent.com/ayushdad609-code/envcheck/main/install.sh | sh |
| 26 | +``` |
| 27 | + |
| 28 | +> Windows: see [docs/windows.md](docs/windows.md) |
| 29 | +
|
| 30 | +## Quick start |
| 31 | + |
| 32 | +Create a `schema.json` (or let the tool generate one from your `.env.example`): |
| 33 | + |
| 34 | +```bash |
| 35 | +envcheck init |
| 36 | +``` |
| 37 | + |
| 38 | +Validate your `.env` against the schema: |
| 39 | + |
| 40 | +```bash |
| 41 | +envcheck validate |
| 42 | +# Output: |
| 43 | +# ❌ Error: DATABASE_URL must be a valid URI. |
| 44 | +# ❌ Error: PORT must be a number. |
| 45 | +``` |
| 46 | + |
| 47 | +## Usage |
| 48 | + |
| 49 | +### Common commands |
| 50 | + |
| 51 | +| Command | What it does | |
| 52 | +|---------|-------------| |
| 53 | +| `envcheck validate` | Validates `.env` against `schema.json` | |
| 54 | +| `envcheck init` | Generates a base schema from your `.env.example` | |
| 55 | + |
| 56 | +### Pre-commit hook or CI pipeline |
| 57 | +```bash |
| 58 | +# Fails the build if .env doesn't match the required schema |
| 59 | +envcheck validate --ci |
| 60 | +``` |
| 61 | + |
| 62 | +## Why not Zod/Joi directly? |
| 63 | + |
| 64 | +| | envcheck | Zod/Joi (Custom Script) | dotenv-safe | |
| 65 | +|---|---|---|---| |
| 66 | +| Language-agnostic | ✅ | ❌ | ❌ | |
| 67 | +| Zero config CLI | ✅ | ❌ | ❌ | |
| 68 | +| Single binary/command | ✅ | ❌ | ✅ | |
| 69 | +| Type validation | ✅ | ✅ | ❌ | |
| 70 | + |
| 71 | +## Limitations |
| 72 | +- Does not automatically inject variables into your app (it only validates). |
| 73 | +- Windows support is experimental. |
| 74 | + |
| 75 | +## Contributing |
| 76 | +PRs welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for setup. |
| 77 | +Good first issues labeled [`good-first-issue`](https://github.com/ayushdad609-code/envcheck/issues?q=is%3Aissue+is%3Aopen+label%3A%22good-first-issue%22). |
| 78 | + |
| 79 | +## License |
| 80 | +MIT © Ayush Das |
| 81 | + |
| 82 | +--- |
| 83 | +*If this saved you time, a ⭐ helps others find it.* |
0 commit comments