env-check-ts

1.0.3 • Public • Published

env-check-ts

A TypeScript CLI tool to validate .env files and auto-generate .env.example using a Zod schema.


Why env-check-ts?

Managing environment variables is risky without validation.
This tool helps you:

  • Validate all required environment variables before your app runs
  • Check variable types and allowed values using Zod
  • Auto-generate a clean .env.example for your team
  • Prevent runtime bugs due to misconfigured or missing envs

Installation

Install globally:

npm install -g env-check-ts

or use directly without installing:

npx env-check-ts validate

Features

  • CLI commands: validate, generate

  • Type-safe validation via Zod

  • Auto-generates .env.example from schema

  • Zero-config, works out-of-the-box

  • Easily extendable for teams and CI/CD

Usage

1)Define Schema Create src/schema.ts:

import { z } from "zod";

export const envSchema = z.object({
  NODE_ENV: z.enum(["development", "production", "test"]),
  PORT: z.string(),
  DATABASE_URL: z.string().url(),
});

2)Validate .env

env-check-ts validate

Example output:

❌ Environment validation failed:
• NODE_ENV: Invalid enum value. Expected 'development' | 'production' | 'test', received 'dev'
• DATABASE_URL: Required

3)Generate .env.example

env-check-ts generate

Example output:

env

 NODE_ENV=development
 PORT=
 DATABASE_URL=

Contributing

The project welcomes all constructive contributions. Contributions take many forms, from code for bug fixes and enhancements, to additions and fixes to documentation, additional tests, and many more!

git clone https://github.com/your-username/env-check-ts
cd env-check-ts
npm install
npm run dev

License

MIT

Package Sidebar

Install

npm i env-check-ts

Weekly Downloads

7

Version

1.0.3

License

ISC

Unpacked Size

6.79 kB

Total Files

3

Last publish

Collaborators

  • divyansh-kumar