{"_id":"@0xdaniiel/env-checker","name":"@0xdaniiel/env-checker","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@0xdaniiel/env-checker","version":"1.0.0","description":"CLI & API to validate .env files","main":"index.js","bin":{"env-checker":"dist/cli.js"},"scripts":{"build":"tsc","start":"ts-node src/cli.ts","test":"jest"},"keywords":["cli","dotenv","env","validation","typescript"],"author":{"name":"0xDaniiel"},"license":"Apache-2.0","type":"module","dependencies":{"chalk":"^5.5.0","commander":"^14.0.0","dotenv":"^17.2.1"},"devDependencies":{"@types/chalk":"^0.4.31","@types/commander":"^2.12.0","@types/jest":"^30.0.0","@types/node":"^24.2.1","jest":"^30.0.5","ts-jest":"^29.4.1","ts-node":"^10.9.2","typescript":"^5.9.2"},"_id":"@0xdaniiel/env-checker@1.0.0","gitHead":"b161c86de142d1a8f96da11e40553435be61679e","_nodeVersion":"24.4.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-hp+2t9DVAiNEUgxvNWcIG1v6wZHaDKOpxEwvr6NMsq/xrwn75tOnTTytoHPyIqJwuFmN8KZP4rbhDyyDpXqvTw==","shasum":"63464bb42bf4bafa357fae41d9a44204ee0e79c4","tarball":"https://registry.npmjs.org/@0xdaniiel/env-checker/-/env-checker-1.0.0.tgz","fileCount":55,"unpackedSize":94286,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDmGkpKU826mIOujXB6fFM+bb7fO2vFSmOVq/MEE48gTQIgaDjTdYmFtmm3h2A+MkSPWExr0N+98W1Gn7fS7JDUNo8="}]},"_npmUser":{"name":"0xdaniiel","email":"dannydotdev@gmail.com"},"directories":{},"maintainers":[{"name":"0xdaniiel","email":"dannydotdev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/env-checker_1.0.0_1754920336716_0.8641346208455611"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-11T13:52:16.622Z","1.0.0":"2025-08-11T13:52:16.912Z","modified":"2025-08-11T13:52:17.619Z"},"maintainers":[{"name":"0xdaniiel","email":"dannydotdev@gmail.com"}],"description":"CLI & API to validate .env files","keywords":["cli","dotenv","env","validation","typescript"],"author":{"name":"0xDaniiel"},"license":"Apache-2.0","readme":"# `@0xdaniiel/env-checker` 🛡\r\n\r\n![npm version](https://img.shields.io/npm/v/@0xdaniiel/env-checker)\r\n\r\n> A fast, CI-friendly CLI & API to validate `.env` files — checks for missing/extra variables, type/format errors, and sensitive values. Includes `.env.example` generator.\r\n\r\n---\r\n\r\n## 📌 Overview\r\n\r\n`@0xdaniiel/env-checker` helps you **catch configuration issues early** — before they break production.  \r\nIt compares your `.env` against `.env.example`, validates formats, detects secrets, and can auto-generate `.env.example` from your current config.\r\n\r\n---\r\n\r\n## ❗ Problem\r\n\r\nEnvironment variables often cause **bugs, confusion, and security leaks** when they are missing, outdated, misformatted, or leaked to version control.  \r\n📄 **Read more:** [docs/problem.md](docs/problem.md)\r\n\r\n---\r\n\r\n## 💡 Solution\r\n\r\nValidate, enforce, and sanitize your `.env` files — locally and in CI/CD — so bad configs never make it to production.  \r\n📄 **Read more:** [docs/solution.md](docs/solution.md)\r\n\r\n---\r\n\r\n## 🚀 Features\r\n\r\n- Detect **missing/extra variables** by comparing `.env` ↔ `.env.example`.\r\n- **Type & format validation** using comment-based rules.\r\n- **Sensitive value detection** (tokens, keys, passwords).\r\n- **CI/CD mode** to fail builds on invalid configs.\r\n- **Auto `.env.example` generator** (strips secrets).\r\n- Multi-file support (`.env.local`, `.env.production`, etc.).\r\n- Friendly **color-coded output**.\r\n- Works as both **CLI** and **JavaScript API**.\r\n\r\n---\r\n\r\n## 📦 Installation\r\n\r\n```\r\nnpm install -g @0xdaniiel/env-checker\r\n# or locally\r\nnpm install --save-dev@0xdaniiel/env-checker\r\n```\r\n\r\n## 🖥 Usage\r\n\r\n### CLI\r\n\r\n```\r\nnpx @0xdaniiel/env-checker [options]\r\n\r\n```\r\n\r\n```\r\n| Flag               | Description                                        |\r\n| ------------------ | -------------------------------------------------- |\r\n| `--ci`             | Run in CI mode (non-zero exit code on failure)     |\r\n| `--generate`       | Create `.env.example` from `.env` (strips secrets) |\r\n| `--path <file>`    | Specify `.env` file path                           |\r\n| `--example <file>` | Specify `.env.example` path                        |\r\n| `--json`           | Output results in JSON                             |\r\n| `--help`           | Show help menu                                     |\r\n\r\n```\r\n\r\n### Running the Compiled CLI\r\n\r\nAfter building the project (`npm run build`), you can run the compiled CLI directly with Node.js:\r\n\r\n```\r\nnode dist/cli.js --path \".env\" --example \".env.example\"\r\n```\r\n\r\n## API Usage\r\n\r\nYou can use `@0xdaniiel/env-checker` programmatically in your Node.js or TypeScript projects.\r\n\r\n### Importing\r\n\r\n```ts\r\nimport { checkEnv } from \"@0xdaniiel/env-checker\";\r\n\r\nfunction runCheck() {\r\n  const result = checkEnv({\r\n    envPaths: [\".env\", \".env.local\"], // Paths to your .env files\r\n    examplePath: \".env.example\", // Path to your .env.example file\r\n  });\r\n\r\n  console.log(\"Missing variables:\", result.missing);\r\n  console.log(\"Extra variables:\", result.extra);\r\n  console.log(\"Type errors:\", result.typeErrors);\r\n  console.log(\"Sensitive warnings:\", result.sensitiveWarnings);\r\n\r\n  if (\r\n    result.missing.length ||\r\n    result.extra.length ||\r\n    result.typeErrors.length ||\r\n    result.sensitiveWarnings.length\r\n  ) {\r\n    throw new Error(\"Environment variables validation failed\");\r\n  }\r\n}\r\n\r\ntry {\r\n  runCheck();\r\n} catch (err) {\r\n  console.error(err);\r\n  process.exit(1);\r\n}\r\n```\r\n\r\n### Options\r\n\r\n```\r\n| Option        | Description                               |\r\n| ------------- | ----------------------------------------- |\r\n| `envPaths`    | Array of paths to `.env` files to merge   |\r\n| `examplePath` | Path to `.env.example` file for reference |\r\n```\r\n\r\n### Return Value\r\n\r\nThe `checkEnv` function returns an object containing:\r\n\r\n- `missing`: Array of variable names missing in your env files but present in example.\r\n- `extra`: Array of variable names present in env files but missing from example.\r\n- `typeErrors`: Array of strings describing type or format validation errors.\r\n- `sensitiveWarnings`: Array of strings warning about sensitive values detected.\r\n\r\n### Notes\r\n\r\n- You can integrate this API into your build or deploy scripts to enforce environment consistency.\r\n- The API works synchronously and throws on file read or parse errors.\r\n- For CI pipelines, use the CLI with the `--ci` flag for automatic failure on issues.\r\n\r\n## 📜 License\r\n\r\nThis project is licensed under the Apache 2.0 License. See the [LICENSE](LICENSE) file for details.\r\n\r\n---\r\n\r\n## 🤝 Contributing\r\n\r\nWe welcome contributions!\r\n\r\n1. Fork the repository\r\n2. Create your feature branch (`git checkout -b feature-name`)\r\n3. Commit your changes (`git commit -m 'Add some feature'`)\r\n4. Push to the branch (`git push origin feature-name`)\r\n5. Open a Pull Request\r\n\r\nPlease open an issue to discuss major changes before submitting a pull request.\r\n","readmeFilename":"Readme.md","_rev":"1-081a2fbec0d3500f60de34ca0702fd98"}