@neerav34/env-doctor 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Neerav Jha
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,180 @@
1
+ # env-doctor
2
+
3
+ > The eslint of environment variables — catch missing env vars before they hit production.
4
+
5
+ [![npm version](https://badge.fury.io/js/env-doctor.svg)](https://www.npmjs.com/package/env-doctor)
6
+ [![CI](https://github.com/your-username/env-doctor/actions/workflows/ci.yml/badge.svg)](https://github.com/your-username/env-doctor/actions)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ ## The Problem
10
+
11
+ Developers lose hours debugging "works on my machine" failures caused by missing, misconfigured, or undocumented environment variables. `env-doctor` gives you a fast, zero-config CLI that scans your codebase, detects all env var references, and cross-checks them against your `.env` and `.env.example` files.
12
+
13
+ ## Features
14
+
15
+ - **Zero config** — works out of the box on Node.js, Python, Go, Rust, Ruby, PHP, and Shell projects
16
+ - **Multi-language detection** — `process.env`, `os.environ`, `os.Getenv`, `env::var`, `ENV[]`, and more
17
+ - **CI-ready** — meaningful exit codes (0 = clean, 1 = errors, 2 = warnings, 3 = fatal)
18
+ - **Three output formats** — pretty terminal output, JSON for tooling, Markdown for PR comments
19
+ - **Auto-fix** — `--fix` updates `.env.example` automatically
20
+ - **Health scoring** — `doctor` command gives a 0–100 score with trend tracking
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install -g env-doctor
26
+ # or use without installing
27
+ npx env-doctor check
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ```bash
33
+ # Check for discrepancies
34
+ env-doctor check
35
+
36
+ # Generate / update .env.example from your code
37
+ env-doctor init
38
+
39
+ # Full diagnostic with health score
40
+ env-doctor doctor
41
+ ```
42
+
43
+ ## Commands
44
+
45
+ ### `env-doctor check`
46
+
47
+ Scans your codebase and reports all environment variable discrepancies.
48
+
49
+ ```bash
50
+ env-doctor check [options]
51
+
52
+ Options:
53
+ --fix Auto-update .env.example to match code references
54
+ --strict Treat warnings as errors (exit 1)
55
+ --env-file <path> Path to .env file (default: .env)
56
+ --example-file <path> Path to .env.example file (default: .env.example)
57
+ --ignore <patterns...> Additional glob patterns to skip
58
+ --format <fmt> Output format: pretty | json | markdown (default: pretty)
59
+ --no-color Disable ANSI color output
60
+ --root <path> Project root directory (default: cwd)
61
+ ```
62
+
63
+ **Exit codes:**
64
+ | Code | Meaning |
65
+ |------|---------|
66
+ | `0` | All clear |
67
+ | `1` | ERROR-level issues found (or `--strict` with warnings) |
68
+ | `2` | Only WARN-level issues |
69
+ | `3` | Fatal error (crash, bad arguments) |
70
+
71
+ ### `env-doctor init`
72
+
73
+ Generates or updates `.env.example` from all env var references found in your code.
74
+
75
+ ```bash
76
+ env-doctor init [options]
77
+
78
+ Options:
79
+ --env-file <path> Source .env file (default: .env)
80
+ --example-file <path> Target file (default: .env.example)
81
+ --with-comments Add source file comments to each variable
82
+ --ignore <patterns...> Additional glob patterns to skip
83
+ --no-color Disable ANSI color output
84
+ --root <path> Project root directory
85
+ ```
86
+
87
+ ### `env-doctor doctor`
88
+
89
+ Full diagnostic with a health score (0–100) and trend analysis vs. previous scans.
90
+
91
+ ```bash
92
+ env-doctor doctor [options]
93
+ ```
94
+
95
+ Same flags as `check`. Stores scan history in `.env-doctor/cache.json`.
96
+
97
+ ## What It Detects
98
+
99
+ | Check | Severity | Description |
100
+ |-------|----------|-------------|
101
+ | Missing Required | **ERROR** | Var referenced in code but absent from both `.env` and `.env.example` |
102
+ | Missing Optional | WARN | Var referenced in code and in `.env.example` but not in `.env` |
103
+ | Unused Variable | WARN | Var defined in `.env` but never referenced in code |
104
+ | Example Drift | WARN | Var in `.env` but not in `.env.example` (or vice versa) |
105
+
106
+ ## Supported Languages
107
+
108
+ | Language | Detected Patterns |
109
+ |----------|------------------|
110
+ | JavaScript / TypeScript | `process.env.VAR`, `process.env['VAR']`, `import.meta.env.VAR` |
111
+ | Python | `os.environ['VAR']`, `os.environ.get('VAR')`, `os.getenv('VAR')` |
112
+ | Go | `os.Getenv("VAR")` |
113
+ | Rust | `env::var("VAR")` |
114
+ | Ruby | `ENV['VAR']` |
115
+ | PHP | `$_ENV['VAR']`, `getenv('VAR')` |
116
+ | Shell / Docker | `${VAR}` in `.sh`, `Dockerfile`, `docker-compose.yml` |
117
+
118
+ ## CI Integration
119
+
120
+ ### GitHub Actions
121
+
122
+ ```yaml
123
+ - name: Check environment variables
124
+ run: npx env-doctor check --strict --format markdown >> $GITHUB_STEP_SUMMARY
125
+ ```
126
+
127
+ ### GitLab CI
128
+
129
+ ```yaml
130
+ env-check:
131
+ script:
132
+ - npx env-doctor check --strict
133
+ ```
134
+
135
+ ## Output Examples
136
+
137
+ ### Pretty (default)
138
+
139
+ ```
140
+ ERRORS (1)
141
+
142
+ ✗ DATABASE_URL [Missing Required]
143
+ DATABASE_URL is referenced in 2 location(s) but not defined in .env or .env.example
144
+ └─ src/db.ts:14 const pool = new Pool({ connectionString: process.env.DATABASE_URL });
145
+ → Add DATABASE_URL to .env.example
146
+
147
+ WARNINGS (2)
148
+
149
+ ⚠ OLD_API_KEY [Unused Variable]
150
+ OLD_API_KEY is defined in .env but never referenced in source code
151
+ → Remove OLD_API_KEY from .env or check for typos in variable name
152
+
153
+ Scanned 142 files in 45ms
154
+ ```
155
+
156
+ ### JSON (`--format json`)
157
+
158
+ ```json
159
+ {
160
+ "success": false,
161
+ "summary": { "errors": 1, "warnings": 2, "scannedFiles": 142, "duration": 45 },
162
+ "issues": [...]
163
+ }
164
+ ```
165
+
166
+ ## Development
167
+
168
+ ```bash
169
+ git clone https://github.com/your-username/env-doctor.git
170
+ cd env-doctor
171
+ npm install
172
+ npm run dev -- check # run in dev mode
173
+ npm test # run tests
174
+ npm run build # build to dist/
175
+ npm run dogfood # run against itself
176
+ ```
177
+
178
+ ## License
179
+
180
+ MIT © [Your Name]
@@ -0,0 +1,2 @@
1
+
2
+ export { }