{"_id":"@barissozudogru/envdrift","_rev":"3-e5fdc13557d883921e12ef240f8863a5","name":"@barissozudogru/envdrift","dist-tags":{"latest":"0.5.1"},"versions":{"0.4.0":{"name":"@barissozudogru/envdrift","version":"0.4.0","keywords":["env","dotenv","drift","validation","cli"],"author":{"name":"Baris Sozudogru"},"license":"MIT","_id":"@barissozudogru/envdrift@0.4.0","maintainers":[{"name":"barissozudogru","email":"barissozudogru@gmail.com"}],"homepage":"https://github.com/barissozudogru/envdrift#readme","bugs":{"url":"https://github.com/barissozudogru/envdrift/issues"},"bin":{"envdrift":"dist/cli.js"},"dist":{"shasum":"e485b60ea515fc28298debc18fdb27090a5be299","tarball":"https://registry.npmjs.org/@barissozudogru/envdrift/-/envdrift-0.4.0.tgz","fileCount":11,"integrity":"sha512-2rQp11ctcwac5DUk7ERQf4lxFKBCmhuRRzyOUnqJu4hHizlVl/Cj6eHzXCyJLzmN8e1JUQs82CIJdOLUw/cxmQ==","signatures":[{"sig":"MEQCICpakF3WOxus4DNPC2G4grOLkzPFh1oy23L5X81hkegoAiAwKA4bWVloY5qYZm+aacjHvhuy5eFNh90yZ+GGG4AAmw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30245},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"d966bc6d986499b76599cf17b1c6c7d8c014df5a","scripts":{"test":"npm run build && node --test test/*.test.js","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"barissozudogru","email":"barissozudogru@gmail.com"},"repository":{"url":"git+https://github.com/barissozudogru/envdrift.git","type":"git"},"_npmVersion":"11.6.2","description":"Detect environment variable drift across .env files","directories":{},"_nodeVersion":"25.2.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3","@types/node":"^25.5.0"},"_npmOperationalInternal":{"tmp":"tmp/envdrift_0.4.0_1787176148796_0.9932092720118353","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@barissozudogru/envdrift","version":"0.5.0","keywords":["env","dotenv","environment-variables","configuration-drift","secret-redaction","validation","ci","cli"],"author":{"name":"Baris Sozudogru"},"license":"MIT","_id":"@barissozudogru/envdrift@0.5.0","maintainers":[{"name":"barissozudogru","email":"barissozudogru@gmail.com"}],"homepage":"https://petri-labs.org/tools/envdrift/","bugs":{"url":"https://github.com/barissozudogru/envdrift/issues"},"bin":{"envdrift":"dist/cli.js"},"dist":{"shasum":"363aec74568e57d7de05f1543621347ac7ded2d7","tarball":"https://registry.npmjs.org/@barissozudogru/envdrift/-/envdrift-0.5.0.tgz","fileCount":11,"integrity":"sha512-VXYACyt/sOj0rj0oba+zPxkqZvXNB+uoXZBn85ce4HgNphp0KZiefgmgPcN73wxoKh1D6n583BiPewxncclRNw==","signatures":[{"sig":"MEUCIQDjnHSY3RxTa9HpJQ994Bn+6UqkGtI6kfHgf0GBVJ6/vwIgfJIHYlETRu9v2rJdkn4Io6Ts/04dKTpz27mcSfwF5No=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":31635},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"f3b4b588caa0ed74d541747155f2e2f62ff5410f","scripts":{"test":"npm run build && node --test test/*.test.js","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"barissozudogru","email":"barissozudogru@gmail.com"},"repository":{"url":"git+https://github.com/barissozudogru/envdrift.git","type":"git"},"_npmVersion":"11.6.2","description":"Detect environment variable drift across .env files","directories":{},"_nodeVersion":"25.2.1","publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3","@types/node":"^25.5.0"},"_npmOperationalInternal":{"tmp":"tmp/envdrift_0.5.0_1787699101970_0.6540157982145469","host":"s3://npm-registry-packages-npm-production"}},"0.5.1":{"name":"@barissozudogru/envdrift","version":"0.5.1","description":"Detect environment variable drift across .env files","bin":{"envdrift":"dist/cli.js"},"main":"dist/index.js","types":"dist/index.d.ts","type":"module","scripts":{"build":"tsc","prepublishOnly":"npm run build","test":"npm run build && node --test test/*.test.js"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"repository":{"type":"git","url":"git+https://github.com/barissozudogru/envdrift.git"},"homepage":"https://petri-labs.org/tools/envdrift/","bugs":{"url":"https://github.com/barissozudogru/envdrift/issues"},"keywords":["env","dotenv","environment-variables","configuration-drift","secret-redaction","validation","ci","cli"],"author":{"name":"Baris Sozudogru"},"license":"MIT","engines":{"node":">=18.0.0"},"devDependencies":{"@types/node":"^25.5.0","typescript":"^5.9.3"},"gitHead":"4d98cd6cd9a61a54f90946c2c7829992df9540af","_id":"@barissozudogru/envdrift@0.5.1","_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-hWek+ha1yhXKT1etl1S2IoMglUjGf480cCz4/8Kb8A4SO7wOud5H/+PnVI5loPSgWPInILTkaV3ayXycKi2emg==","shasum":"d7d469d53e4d7cec74e751ecb9d054cdeeec716a","tarball":"https://registry.npmjs.org/@barissozudogru/envdrift/-/envdrift-0.5.1.tgz","fileCount":11,"unpackedSize":31717,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD1ZdQ+dKxFxBwiTJUEp6hv1XRgLwQAETfkSSNGrYW0RQIhAPr/RaAS0QtEevl4gbBZiYdZ2J+wHatWxriYcNSbYeLI"}]},"_npmUser":{"name":"barissozudogru","email":"barissozudogru@gmail.com"},"directories":{},"maintainers":[{"name":"barissozudogru","email":"barissozudogru@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/envdrift_0.5.1_1787745743486_0.7817869945943103"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-19T21:49:08.617Z","modified":"2026-08-26T12:02:23.803Z","0.4.0":"2026-08-19T21:49:08.933Z","0.5.0":"2026-08-25T23:05:02.135Z","0.5.1":"2026-08-26T12:02:23.627Z"},"bugs":{"url":"https://github.com/barissozudogru/envdrift/issues"},"author":{"name":"Baris Sozudogru"},"license":"MIT","homepage":"https://petri-labs.org/tools/envdrift/","keywords":["env","dotenv","environment-variables","configuration-drift","secret-redaction","validation","ci","cli"],"repository":{"type":"git","url":"git+https://github.com/barissozudogru/envdrift.git"},"description":"Detect environment variable drift across .env files","maintainers":[{"name":"barissozudogru","email":"barissozudogru@gmail.com"}],"readme":"<p align=\"center\">\n  <img src=\"./assets/social-preview.svg\" alt=\"envdrift\" width=\"900\" />\n</p>\n\n<p align=\"center\">\n  <a href=\"https://www.npmjs.com/package/@barissozudogru/envdrift\"><img alt=\"npm version\" src=\"https://img.shields.io/npm/v/@barissozudogru/envdrift?style=flat-square&color=6AB9D5\"></a>\n  <a href=\"https://www.npmjs.com/package/@barissozudogru/envdrift\"><img alt=\"npm downloads\" src=\"https://img.shields.io/npm/dm/@barissozudogru/envdrift?style=flat-square&color=6AB9D5\"></a>\n  <a href=\"https://github.com/barissozudogru/envdrift/actions/workflows/ci.yml\"><img alt=\"CI\" src=\"https://github.com/barissozudogru/envdrift/actions/workflows/ci.yml/badge.svg\"></a>\n  <a href=\"./LICENSE\"><img alt=\"MIT license\" src=\"https://img.shields.io/badge/License-MIT-6AB9D5?style=flat-square\"></a>\n</p>\n\n# envdrift\n\nDetect environment variable drift across your .env files before it causes production bugs.\n\nenvdrift compares two or more `.env` files and surfaces keys that are missing in some environments, values whose inferred types differ across files, and values that look like placeholders or contain protocol mismatches. It is designed to be used as a local check, a pre-commit hook, or a CI step that fails the build when drift is detected.\n\n[Tool page](https://petri-labs.org/tools/envdrift/) · [npm](https://www.npmjs.com/package/@barissozudogru/envdrift) · [Source](https://github.com/barissozudogru/envdrift)\n\n---\n\n## Installation\n\nInstall globally:\n\n```bash\nnpm install -g @barissozudogru/envdrift\n```\n\nOr run without installing:\n\n```bash\nnpx @barissozudogru/envdrift .env .env.staging .env.production\n```\n\n---\n\n## Usage\n\n### Auto-detect\n\nRun in any project directory and envdrift will pick up all `.env*` files automatically:\n\n```bash\ncd /your/project\nenvdrift\n```\n\n### Explicit files\n\n```bash\nenvdrift .env .env.staging .env.production\n```\n\n### JSON output for CI pipelines\n\n```bash\nenvdrift --json .env .env.production\n```\n\n### Ignore specific keys\n\n```bash\nenvdrift --ignore SECRET_KEY,INTERNAL_TOKEN .env .env.production\nenvdrift --ignore SECRET_KEY --ignore INTERNAL_TOKEN .env .env.production\n```\n\n---\n\n## Options\n\n| Flag | Short | Description |\n|---|---|---|\n| `--help` | `-h` | Show help message |\n| `--version` | `-v` | Show version number |\n| `--json` | | Output results as JSON |\n| `--ignore <keys>` | `-i` | Comma-separated keys to exclude from comparison. Can be repeated. |\n| `--show-values` | | Print raw values instead of their shape. Not for CI, see Value redaction below. |\n\n---\n\n## Example Output\n\n```\nenvdrift - environment drift report\n──────────────────────────────────────────────────\n\nComparing files:\n  • .env.development\n  • .env.production\n\nMISSING KEYS  (2)\n──────────────────────────────────────────────────\n  x STRIPE_WEBHOOK_SECRET\n    present in:   .env.production\n    missing from: .env.development\n\n  x REDIS_URL\n    present in:   .env.development, .env.production\n    missing from: .env.staging\n\nTYPE MISMATCHES  (1)\n──────────────────────────────────────────────────\n  ! MAX_CONNECTIONS\n    .env.development: number\n    .env.production: string\n\nVALUE ANOMALIES  (2)\n──────────────────────────────────────────────────\n  ~ DATABASE_URL  Placeholder value detected in .env.development\n    .env.development: 22 chars, ascii, #b310\n    .env.production: 44 chars, url, #7c02\n\n  ~ API_ENDPOINT  Protocol mismatch across files (http: vs https:)\n    .env.development: 31 chars, url, #4ae1\n    .env.production: 23 chars, url, #90d5\n\nSummary: 2 missing  1 type mismatch  2 anomalies\n```\n\nIf this saves you time, consider [starring the repository](https://github.com/barissozudogru/envdrift). It helps other developers find it.\n\n---\n\n## Value redaction\n\nenvdrift reads `.env` files, which routinely hold live credentials. It never prints a value.\nEach value is described instead: length, character class, and a short stable fingerprint.\n\n```\nAPI_FOOTBALL_KEY\n  .env: 32 chars, hex, #fa98\n  .env.example: 9 chars, token, #442c\n```\n\nThe fingerprint is what keeps the report useful. Identical values fingerprint identically, so\nyou can still tell at a glance whether two environments hold the same value, without the value\nappearing anywhere.\n\nThis matters most in CI. Values registered as CI secrets are masked in build logs, but values\nread from a file on disk are not, so anything printed lands in the log in cleartext.\n\n`--show-values` prints raw values for local debugging. Do not use it in CI.\n\n---\n\n## CI Integration\n\n### GitHub Actions\n\n```yaml\nname: Check env drift\n\non: [pull_request]\n\njobs:\n  env-drift:\n    runs-on: ubuntu-latest\n    permissions:\n      contents: read\n    steps:\n      - uses: actions/checkout@v4\n      - uses: barissozudogru/envdrift@v0.5.1\n        with:\n          files: .env.example .env.ci\n```\n\nThe action writes the redacted report to the workflow summary and preserves the CLI exit code. It never enables `--show-values`.\n\n### Pre-commit hook\n\nAdd to `.git/hooks/pre-commit`:\n\n```bash\n#!/bin/sh\nnpx @barissozudogru/envdrift .env.example .env\nif [ $? -ne 0 ]; then\n  echo \"Env drift detected. Fix before committing.\"\n  exit 1\nfi\n```\n\n---\n\n## Exit Codes\n\n| Code | Meaning |\n|---|---|\n| `0` | No drift detected, all files are in sync |\n| `1` | Drift detected or an error occurred |\n\n---\n\n## Programmatic API\n\n```typescript\nimport { compareEnvFiles, parseEnvFile, inferType } from \"@barissozudogru/envdrift\";\n\nconst result = compareEnvFiles([\".env\", \".env.production\"]);\n\nif (!result.clean) {\n  console.log(\"Missing keys:\", result.missingKeys);\n  console.log(\"Type mismatches:\", result.typeMismatches);\n  console.log(\"Value anomalies:\", result.valueAnomalies);\n}\n```\n\n### `parseEnvFile(path: string): EnvMap`\n\nParses a `.env` file into a key-value map. Handles comments, blank lines, quoted values, inline comments, `export` prefixes, and multiline double-quoted values.\n\n### `inferType(value: string): ValueType`\n\nInfers the semantic type of a value. Returns one of: `\"boolean\"`, `\"number\"`, `\"url\"`, `\"path\"`, `\"string\"`.\n\n### `compareEnvFiles(files: string[], ignoreKeys?: string[]): DriftResult`\n\nCompares all provided files and returns a structured result:\n\n```typescript\ninterface DriftResult {\n  files: string[];\n  missingKeys: MissingKey[];\n  typeMismatches: TypeMismatch[];\n  valueAnomalies: ValueAnomaly[];\n  clean: boolean;\n}\n```\n\n---\n\n## License\n\n[MIT](./LICENSE)\n","readmeFilename":"README.md"}