Skip to main content

Compare dotenv files and report configuration drift.

Project description

env-drift-report

Compare dotenv files and report configuration drift before missing keys reach a deploy, onboarding guide, or CI job.

Problem

.env.example files often drift away from real local or template configuration. A teammate adds STRIPE_WEBHOOK_SECRET to one file, leaves another template untouched, and the gap only appears after a failed setup. This CLI checks required keys, empty values, duplicate entries, malformed lines, and unexpected extras with output that works for humans or CI logs.

Install

pip install env-drift-report

For local development:

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

CLI Usage

Compare .env against .env.example:

env-drift-report .env

Compare several files against a reference:

env-drift-report --reference .env.example .env .env.production.example

Emit JSON for scripts:

env-drift-report --reference .env.example --format json .env

Write an HTML report for CI artifacts or onboarding handoff:

env-drift-report --reference .env.example --format html --output env-report.html .env .env.local.example

Ignore target-only keys when local files are expected to contain private values:

env-drift-report --ignore-extra .env

Ignore commented KEY=value examples:

env-drift-report --ignore-commented .env

The command exits with:

  • 0 when every target file passes
  • 1 when drift is found
  • 2 when a file cannot be read

Report Formats

text is optimized for terminal use, json is stable for scripts, and html creates a self-contained report that can be uploaded as a build artifact or shared during setup reviews.

Python Usage

from env_drift_report import compare_env_files

report = compare_env_files(".env.example", ".env")

if not report.ok:
    print(report.missing)

Example Output

FAIL .env
Reference: .env.example
Missing:
  - REDIS_URL
Empty:
  - API_KEY (line 1)
Extra:
  - DEBUG_SQL
Duplicates:
  - .env:PORT (lines 2, 3)

Supported Dotenv Syntax

The parser intentionally supports the common subset used by templates:

  • KEY=value
  • export KEY=value
  • commented examples like # KEY=value
  • quoted values
  • inline comments after unquoted values

It does not evaluate shell expansion or source other files.

Development

Run tests:

PYTHONPATH=src python3 -m unittest discover -s tests

Build the package:

python3 -m build --no-isolation

Contributing

Issues and pull requests are welcome. Keep changes focused, include tests for behavior changes, and update the README when command behavior changes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

env_drift_report-0.2.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

env_drift_report-0.2.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file env_drift_report-0.2.0.tar.gz.

File metadata

  • Download URL: env_drift_report-0.2.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for env_drift_report-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bfe5152c01c199d66fa99bbe30886fcc4ddfc5d0b3a3c2ba925d36f9f359731d
MD5 f93440fd2c1ee4d6e9055e6a2836999e
BLAKE2b-256 b4bbdf34f58eb107852b9334d7f6a6e8a50eafa55870ae3d7f844e71ff3fbf3a

See more details on using hashes here.

File details

Details for the file env_drift_report-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for env_drift_report-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9dc368ca28d8df764e5e8177e393ac52a0f64e56b0b2b40bde03c1bdd6e0498f
MD5 83d7b9ce06b9ab2440ee8701028c4e95
BLAKE2b-256 c6967bc1b7056fe3c9e10d4b8f3a8e4cdc762787de376a83f0df2755b6990a0b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page