{"_id":"@atyahassis/env-doctor","_rev":"3-42aee8851b5521f693fcf69d05ebee8b","name":"@atyahassis/env-doctor","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"@atyahassis/env-doctor","version":"1.0.0","keywords":["env","dotenv","environment","variables","validate","cli","developer-tools","devops","configuration","schema","lint"],"author":{"name":"Atyah Labs"},"license":"MIT","_id":"@atyahassis/env-doctor@1.0.0","maintainers":[{"name":"atyahassis","email":"8yahassistant@gmail.com"}],"homepage":"https://github.com/AtyahsLab/env-doctor#readme","bugs":{"url":"https://github.com/AtyahsLab/env-doctor/issues"},"bin":{"env-doctor":"bin/cli.js"},"dist":{"shasum":"283d2b3e18e6f8d29b2760c802b7e803a3857049","tarball":"https://registry.npmjs.org/@atyahassis/env-doctor/-/env-doctor-1.0.0.tgz","fileCount":12,"integrity":"sha512-si65ODsYkRD6dGMmaPjfULsVshxDACZN+9ygUDY60VIWrUgS5Xm4rkdYkpMWcryFSRXrIYM7xm1uqOPLOaciHQ==","signatures":[{"sig":"MEQCIAyyYaVF8KuEVw4TcPV7kwbieiAO5OlX0pTDaRHACF+WAiBvj+QE4kk9e5SqM5WfUF1VvK5jJGAgLwtK7NBF8eUTXw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29581},"main":"src/index.js","engines":{"node":">=18.0.0"},"gitHead":"0424409bc2c043f3b35c4176f23da885175611d9","scripts":{"test":"node --test test/**/*.test.js","test:verbose":"node --test --test-reporter=spec test/**/*.test.js"},"_npmUser":{"name":"atyahassis","email":"8yahassistant@gmail.com"},"repository":{"url":"git+https://github.com/AtyahsLab/env-doctor.git","type":"git"},"_npmVersion":"11.9.0","description":"Diagnose, validate, and manage your .env files. Find missing vars, type mismatches, and sync across environments.","directories":{},"_nodeVersion":"25.6.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/env-doctor_1.0.0_1771407880036_0.10323910278612725","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@atyahassis/env-doctor","version":"1.1.0","keywords":["env","dotenv","environment","variables","validate","cli","developer-tools","devops","configuration","schema","lint"],"author":{"name":"Atyah Labs"},"license":"MIT","_id":"@atyahassis/env-doctor@1.1.0","maintainers":[{"name":"atyahassis","email":"8yahassistant@gmail.com"}],"homepage":"https://github.com/AtyahsLab/env-doctor#readme","bugs":{"url":"https://github.com/AtyahsLab/env-doctor/issues"},"bin":{"env-doctor":"bin/cli.js"},"dist":{"shasum":"15080432642269e8ef118c28b2c4ed90c1e31ecb","tarball":"https://registry.npmjs.org/@atyahassis/env-doctor/-/env-doctor-1.1.0.tgz","fileCount":14,"integrity":"sha512-w5Suq4VgUr5MxNlIHNkNAZZ5WfWJJIVe61wbH9W6Xq36R72fNk09og8dhKWv/8GH4625e6kRTqL/KGKHcTYuNw==","signatures":[{"sig":"MEYCIQDCeVzDN/8aNLUZY+16ai8H5vEjAkPRXH4A6ecXU90pcgIhAOClwt6BqKMRoYpSc2Ps7PBuhk2MzpAKcW+STY8fXyJI","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":40569},"main":"src/index.js","engines":{"node":">=18.0.0"},"gitHead":"171ceb0a7c3697aee171ca7169ebf4857c68a39a","scripts":{"test":"node --test test/**/*.test.js","test:verbose":"node --test --test-reporter=spec test/**/*.test.js"},"_npmUser":{"name":"atyahassis","email":"8yahassistant@gmail.com"},"repository":{"url":"git+https://github.com/AtyahsLab/env-doctor.git","type":"git"},"_npmVersion":"11.9.0","description":"Diagnose, validate, and manage your .env files. Find missing vars, type mismatches, and sync across environments.","directories":{},"_nodeVersion":"25.6.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/env-doctor_1.1.0_1771430722650_0.0869382519467532","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@atyahassis/env-doctor","version":"1.2.0","description":"Diagnose, validate, and manage your .env files. Find missing vars, type mismatches, and sync across environments.","main":"src/index.js","bin":{"env-doctor":"bin/cli.js"},"scripts":{"test":"node --test test/**/*.test.js","test:verbose":"node --test --test-reporter=spec test/**/*.test.js"},"keywords":["env","dotenv","environment","variables","validate","cli","developer-tools","devops","configuration","schema","lint"],"author":{"name":"Atyah Labs"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/AtyahsLab/env-doctor.git"},"homepage":"https://github.com/AtyahsLab/env-doctor#readme","bugs":{"url":"https://github.com/AtyahsLab/env-doctor/issues"},"engines":{"node":">=18.0.0"},"gitHead":"4b8712df4dbb9ab940ad9f34c745e5bd48985377","_id":"@atyahassis/env-doctor@1.2.0","_nodeVersion":"25.6.1","_npmVersion":"11.9.0","dist":{"integrity":"sha512-JN+vn3kOp0WlYGkm0th/9Irjmme6TNt/ng6tcGQmxNj6wgtiOps/sc9y8QUuBbiusFfCjbyL3t6PkvbDk9p0QQ==","shasum":"f47880a35abefd783983d1a691f52425f1e6d87c","tarball":"https://registry.npmjs.org/@atyahassis/env-doctor/-/env-doctor-1.2.0.tgz","fileCount":19,"unpackedSize":66262,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICKJcVpdDyu+whD5wMJAPso03EhLDIOD+EVmXQaGRYS9AiBXDBDwJqYN+JEwPDIh3082P/5cSX8+TzQ2csaCO50PNw=="}]},"_npmUser":{"name":"atyahassis","email":"8yahassistant@gmail.com"},"directories":{},"maintainers":[{"name":"atyahassis","email":"8yahassistant@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/env-doctor_1.2.0_1771431443192_0.5231301687121326"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-18T09:44:39.939Z","modified":"2026-02-18T16:17:23.470Z","1.0.0":"2026-02-18T09:44:40.189Z","1.1.0":"2026-02-18T16:05:22.811Z","1.2.0":"2026-02-18T16:17:23.366Z"},"bugs":{"url":"https://github.com/AtyahsLab/env-doctor/issues"},"author":{"name":"Atyah Labs"},"license":"MIT","homepage":"https://github.com/AtyahsLab/env-doctor#readme","keywords":["env","dotenv","environment","variables","validate","cli","developer-tools","devops","configuration","schema","lint"],"repository":{"type":"git","url":"git+https://github.com/AtyahsLab/env-doctor.git"},"description":"Diagnose, validate, and manage your .env files. Find missing vars, type mismatches, and sync across environments.","maintainers":[{"name":"atyahassis","email":"8yahassistant@gmail.com"}],"readme":"# env-doctor 🩺\n\n[![npm version](https://img.shields.io/npm/v/@atyahassis/env-doctor)](https://www.npmjs.com/package/@atyahassis/env-doctor)\n[![license](https://img.shields.io/npm/l/@atyahassis/env-doctor)](./LICENSE)\n[![node](https://img.shields.io/node/v/@atyahassis/env-doctor)](https://nodejs.org)\n[![tests](https://img.shields.io/badge/tests-66%20passing-brightgreen)](#)\n\nDiagnose, validate, and manage your `.env` files. Find missing vars, catch type mismatches, and keep environments in sync.\n\n> **Zero dependencies.** Pure Node.js. Works with any framework.\n\n```\n$ env-doctor check\n\nChecking .env against .env.schema\n\n  ✗ DATABASE_URL: Required variable is missing or empty\n  ✗ PORT: Expected a number, got: \"abc\"\n\nResult: 2 error(s)\n```\n\n## Install\n\n```bash\nnpm install -g env-doctor\n```\n\nOr use without installing:\n\n```bash\nnpx env-doctor check\n```\n\n## Commands\n\n### `env-doctor check [dir]`\n\nValidate your `.env` against a `.env.schema` (preferred) or `.env.example`.\n\n```bash\nenv-doctor check              # current directory\nenv-doctor check ./backend    # specific directory\nenv-doctor check --strict     # treat warnings as errors\n```\n\nIf a `.env.schema` exists, env-doctor validates types, patterns, enums, and required fields. Otherwise, it falls back to checking key presence against `.env.example`.\n\n### `env-doctor diff <file1> <file2>`\n\nCompare two env files side by side. Great for spotting drift between environments.\n\n```bash\nenv-doctor diff .env .env.staging\nenv-doctor diff .env.local .env.production --values  # show actual values\n```\n\n```\nComparing .env ↔ .env.staging\n\n  - LOCAL_ONLY  (only in .env)\n  + REDIS_URL   (only in .env.staging)\n  ~ API_URL     (different values)\n\n3 difference(s): 1 added, 1 removed, 1 changed\n```\n\n### `env-doctor mask [dir]`\n\nPrint your `.env` with sensitive values masked. Safe for sharing in logs, PRs, or Slack.\n\n```bash\nenv-doctor mask                  # masks sensitive keys (password, token, key, etc.)\nenv-doctor mask --mask-all       # mask everything\nenv-doctor mask --output=.env.masked  # write to file\n```\n\n```\nDATABASE_URL=postgres://localhost:5432/mydb\nAPI_KEY=sk-*********\nJWT_SECRET=myS*********\nAPP_NAME=my-cool-app\nPORT=3000\n```\n\n### `env-doctor init [dir]`\n\nGenerate a `.env.example` from an existing `.env`. Sensitive values are automatically stripped.\n\n```bash\nenv-doctor init                  # generates .env.example\nenv-doctor init --strip-values   # strip ALL values\nenv-doctor init --dry-run        # preview without writing\nenv-doctor init --force          # overwrite existing\n```\n\n### `env-doctor sync [dir]`\n\nSync your `.env` with a `.env.schema` or `.env.example`. Adds missing variables, preserves existing values, and warns about orphaned vars.\n\n```bash\nenv-doctor sync                      # interactive — prompts for missing values\nenv-doctor sync --non-interactive    # use defaults or leave empty\nenv-doctor sync --dry-run            # preview what would change\nenv-doctor sync -f .env.local        # sync a different env file\nenv-doctor sync -s custom.schema     # use a custom schema file\n```\n\n```\nSyncing .env with .env.schema\n\n  ⚠ Orphaned variables (not in .env.schema):\n    ! OLD_UNUSED_VAR\n\n  Variables to add:\n    + PORT=3000 (default)\n    + API_KEY= (empty)\n\n  ✓ Written .env (2 variable(s) added)\n```\n\n**How it works:**\n1. Reads `.env.schema` (or `.env.example` as fallback)\n2. Reads your existing `.env` (if it exists)\n3. For missing variables: uses schema defaults, example values, or prompts you\n4. Warns about variables in `.env` that aren't in the schema\n5. Writes the updated `.env`, preserving all existing content\n\n## Schema Format (`.env.schema`)\n\nDefine validation rules for your env vars. Simple DSL — one variable per line:\n\n```ini\n# Database\nDATABASE_URL=required,url\nDB_POOL_SIZE=number,default:5\n\n# App\nNODE_ENV=required,enum:development|staging|production\nAPP_NAME=required,string,min:1,max:50\nDEBUG=boolean,default:false\n\n# Secrets\nAPI_KEY=required,string,secret,min:16\nJWT_SECRET=required,secret,min:32,pattern:^[A-Za-z0-9+/=_-]+$\n```\n\n### Supported Rules\n\n| Token | Description |\n|-------|-------------|\n| `required` | Must be present and non-empty |\n| `optional` | May be absent (default) |\n| `string` | Any string (default type) |\n| `number` | Must be numeric |\n| `boolean` | Must be `true`, `false`, `0`, `1`, `yes`, or `no` |\n| `url` | Must start with `http://` or `https://` |\n| `email` | Must be a valid email format |\n| `ip` | Must be an IPv4 address |\n| `secret` | Marks as sensitive (used by `mask` command) |\n| `default:<value>` | Default value (documentation) |\n| `min:<n>` | Minimum length |\n| `max:<n>` | Maximum length |\n| `pattern:<regex>` | Must match regex pattern |\n| `enum:<a\\|b\\|c>` | Must be one of the listed values |\n\nThe schema also supports JSON format:\n\n```json\n{\n  \"DATABASE_URL\": \"required,url\",\n  \"PORT\": { \"required\": true, \"type\": \"number\", \"default\": \"3000\" }\n}\n```\n\n## Options\n\n| Flag | Description |\n|------|-------------|\n| `--strict` | Exit with error on warnings too |\n| `--env=<file>` | Custom env file name (default: `.env`) |\n| `--example=<file>` | Custom example file name |\n| `--values` | Show values in diff output |\n| `--mask-all` | Mask all values, not just sensitive ones |\n| `--strip-values` | Strip all values in init |\n| `--output=<file>` | Write output to file |\n| `--force` | Overwrite existing files |\n| `--dry-run` | Preview without writing |\n| `--no-heuristics` | Skip heuristic checks |\n| `--non-interactive` | Skip prompts in sync (use defaults or leave empty) |\n| `-f, --file=<file>` | Target env file for sync (default: `.env`) |\n| `-s, --schema=<file>` | Schema file for sync (default: `.env.schema`) |\n\n### `env-doctor fix [dir]`\n\nAuto-fix your `.env` based on `.env.schema`. Adds missing variables, removes orphans, and sorts to match schema order.\n\n```bash\nenv-doctor fix                      # add missing vars with defaults\nenv-doctor fix --dry-run            # preview changes without writing\nenv-doctor fix --remove-orphans     # comment out vars not in schema\nenv-doctor fix --sort               # reorder to match schema order\nenv-doctor fix --sort --remove-orphans --dry-run  # full preview\n```\n\n```\nenv-doctor fix\n\n  Added 2 missing variable(s):\n    + PORT (default: 3000)\n    + API_KEY (empty)\n\n  Commented out 1 orphaned variable(s):\n    - OLD_UNUSED_VAR\n\n  ↕ Reordered variables to match schema order\n\n  ✓ Written .env\n```\n\n## GitHub Action\n\nUse env-doctor directly in your CI pipeline. It validates `.env` files on every push and PR, and posts a summary comment on PRs.\n\n```yaml\n# .github/workflows/env-check.yml\nname: Validate env files\n\non:\n  push:\n    branches: [main]\n  pull_request:\n\njobs:\n  env-doctor:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - uses: AtyahsLab/env-doctor@v1\n        with:\n          schema: '.env.schema'        # path to schema (default: .env.schema)\n          env-files: '.env,.env.test'   # comma-separated list (default: .env)\n          fail-on-warn: 'false'         # fail on warnings too (default: false)\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n```\n\nThe action will:\n- ✅ Validate all specified `.env` files against your schema\n- ❌ Fail the workflow if errors are found\n- 💬 Post a summary table as a PR comment (updated on each push)\n- 📊 Write results to the GitHub Actions job summary\n\n## CI Integration\n\n```yaml\n# Simple usage with npx\n- run: npx env-doctor check --strict\n```\n\nExit codes: `0` = all good, `1` = errors found.\n\n## Why env-doctor?\n\n- 🔍 **Find missing vars** before your app crashes at runtime\n- 📐 **Schema validation** — types, patterns, enums, ranges\n- 🔒 **Mask secrets** for safe sharing in logs and PRs\n- 🔄 **Diff environments** — spot drift between local, staging, production\n- 📦 **Zero dependencies** — nothing to audit, nothing to break\n- ⚡ **Fast** — 50 tests run in <1s\n\n## Contributing\n\nIssues and PRs welcome at [github.com/AtyahsLab/env-doctor](https://github.com/AtyahsLab/env-doctor).\n\n## License\n\nMIT © Atyah Labs\n","readmeFilename":"README.md"}