dotenv-diff 2.6.1 → 2.6.2
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/CHANGELOG.md +12 -0
- package/README.md +9 -9
- package/dist/src/cli/run.d.ts.map +1 -1
- package/dist/src/cli/run.js.map +1 -1
- package/dist/src/commands/compare.d.ts.map +1 -1
- package/dist/src/commands/compare.js +5 -1
- package/dist/src/commands/compare.js.map +1 -1
- package/dist/src/commands/prompts/promptEnsureFiles.d.ts +9 -0
- package/dist/src/commands/prompts/promptEnsureFiles.d.ts.map +1 -1
- package/dist/src/commands/prompts/promptEnsureFiles.js +1 -1
- package/dist/src/commands/prompts/promptEnsureFiles.js.map +1 -1
- package/dist/src/commands/prompts/promptNoEnvScenario.js +1 -1
- package/dist/src/commands/prompts/promptNoEnvScenario.js.map +1 -1
- package/dist/src/commands/prompts/prompts.d.ts.map +1 -0
- package/dist/src/commands/prompts/prompts.js.map +1 -0
- package/dist/src/commands/scanUsage.js +4 -4
- package/dist/src/commands/scanUsage.js.map +1 -1
- package/dist/src/config/types.d.ts +85 -28
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/core/compare/parseAndFilterEnv.d.ts +4 -0
- package/dist/src/core/compare/parseAndFilterEnv.d.ts.map +1 -1
- package/dist/src/core/compare/parseAndFilterEnv.js.map +1 -1
- package/dist/src/core/compare/updateTotals.d.ts +5 -0
- package/dist/src/core/compare/updateTotals.d.ts.map +1 -1
- package/dist/src/core/compare/updateTotals.js.map +1 -1
- package/dist/src/core/fixEnv.d.ts +1 -11
- package/dist/src/core/fixEnv.d.ts.map +1 -1
- package/dist/src/core/fixEnv.js.map +1 -1
- package/dist/src/services/printScanResult.d.ts +1 -15
- package/dist/src/services/printScanResult.d.ts.map +1 -1
- package/dist/src/services/printScanResult.js +23 -17
- package/dist/src/services/printScanResult.js.map +1 -1
- package/dist/src/services/processComparisonFile.d.ts +2 -5
- package/dist/src/services/processComparisonFile.d.ts.map +1 -1
- package/dist/src/services/processComparisonFile.js +13 -17
- package/dist/src/services/processComparisonFile.js.map +1 -1
- package/dist/src/ui/scan/printConsolelogWarning.d.ts +1 -2
- package/dist/src/ui/scan/printConsolelogWarning.d.ts.map +1 -1
- package/dist/src/ui/scan/printConsolelogWarning.js +1 -4
- package/dist/src/ui/scan/printConsolelogWarning.js.map +1 -1
- package/dist/src/ui/scan/printExampleWarnings.d.ts +1 -2
- package/dist/src/ui/scan/printExampleWarnings.d.ts.map +1 -1
- package/dist/src/ui/scan/printExampleWarnings.js +1 -6
- package/dist/src/ui/scan/printExampleWarnings.js.map +1 -1
- package/dist/src/ui/scan/printFrameworkWarnings.d.ts +1 -2
- package/dist/src/ui/scan/printFrameworkWarnings.d.ts.map +1 -1
- package/dist/src/ui/scan/printFrameworkWarnings.js +1 -6
- package/dist/src/ui/scan/printFrameworkWarnings.js.map +1 -1
- package/dist/src/ui/scan/printHealthScore.d.ts.map +1 -1
- package/dist/src/ui/scan/printHealthScore.js +8 -4
- package/dist/src/ui/scan/printHealthScore.js.map +1 -1
- package/dist/src/ui/scan/printInconsistentNamingWarning.d.ts +1 -2
- package/dist/src/ui/scan/printInconsistentNamingWarning.d.ts.map +1 -1
- package/dist/src/ui/scan/printInconsistentNamingWarning.js +2 -3
- package/dist/src/ui/scan/printInconsistentNamingWarning.js.map +1 -1
- package/dist/src/ui/scan/printMissing.d.ts +1 -3
- package/dist/src/ui/scan/printMissing.d.ts.map +1 -1
- package/dist/src/ui/scan/printMissing.js +1 -5
- package/dist/src/ui/scan/printMissing.js.map +1 -1
- package/dist/src/ui/scan/printSecrets.d.ts +1 -2
- package/dist/src/ui/scan/printSecrets.d.ts.map +1 -1
- package/dist/src/ui/scan/printSecrets.js +1 -4
- package/dist/src/ui/scan/printSecrets.js.map +1 -1
- package/dist/src/ui/scan/printStats.d.ts +2 -17
- package/dist/src/ui/scan/printStats.d.ts.map +1 -1
- package/dist/src/ui/scan/printStats.js +2 -2
- package/dist/src/ui/scan/printStats.js.map +1 -1
- package/dist/src/ui/scan/printUnused.d.ts +1 -2
- package/dist/src/ui/scan/printUnused.d.ts.map +1 -1
- package/dist/src/ui/scan/printUnused.js +1 -4
- package/dist/src/ui/scan/printUnused.js.map +1 -1
- package/dist/src/ui/scan/printUppercaseWarning.d.ts +1 -2
- package/dist/src/ui/scan/printUppercaseWarning.d.ts.map +1 -1
- package/dist/src/ui/scan/printUppercaseWarning.js +2 -3
- package/dist/src/ui/scan/printUppercaseWarning.js.map +1 -1
- package/dist/src/ui/scan/scanJsonOutput.d.ts +2 -8
- package/dist/src/ui/scan/scanJsonOutput.d.ts.map +1 -1
- package/dist/src/ui/scan/scanJsonOutput.js.map +1 -1
- package/dist/src/ui/shared/printAutoFix.d.ts +2 -13
- package/dist/src/ui/shared/printAutoFix.d.ts.map +1 -1
- package/dist/src/ui/shared/printAutoFix.js +3 -5
- package/dist/src/ui/shared/printAutoFix.js.map +1 -1
- package/docs/assets/demo1.gif +0 -0
- package/docs/assets/success1.png +0 -0
- package/docs/configuration_and_flags.md +726 -0
- package/docs/expiration_warnings.md +111 -0
- package/docs/frameworks/index.md +24 -0
- package/docs/frameworks/nextjs_warnings.md +56 -0
- package/docs/frameworks/sveltekit_warnings.md +130 -0
- package/docs/git_hooks_ci.md +51 -0
- package/docs/ignore_comments.md +82 -0
- package/docs/index.md +43 -0
- package/docs/monorepo_support.md +63 -0
- package/package.json +10 -9
- package/dist/src/ui/prompts.d.ts.map +0 -1
- package/dist/src/ui/prompts.js.map +0 -1
- /package/dist/src/{ui → commands/prompts}/prompts.d.ts +0 -0
- /package/dist/src/{ui → commands/prompts}/prompts.js +0 -0
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
dotenv-diff can be configured using CLI flags or a configuration file.
|
|
4
|
+
CLI flags always take precedence over configuration file values.
|
|
5
|
+
|
|
6
|
+
## Table of Contents
|
|
7
|
+
|
|
8
|
+
### General Flags
|
|
9
|
+
|
|
10
|
+
- [--init](#configuration-file)
|
|
11
|
+
- [--env](#--env-file)
|
|
12
|
+
- [--example](#--example-file)
|
|
13
|
+
- [--allow-duplicates](#--allow-duplicates)
|
|
14
|
+
- [--ignore](#--ignore-keys)
|
|
15
|
+
- [--ignore-regex](#--ignore-regex-patterns)
|
|
16
|
+
- [--fix](#--fix)
|
|
17
|
+
- [--json](#--json)
|
|
18
|
+
- [--color](#--color)
|
|
19
|
+
- [--no-color](#--no-color)
|
|
20
|
+
- [--ci](#--ci)
|
|
21
|
+
- [--yes](#-y---yes)
|
|
22
|
+
|
|
23
|
+
### File Scanning Flags
|
|
24
|
+
|
|
25
|
+
- [--files](#--files-patterns)
|
|
26
|
+
- [--include-files](#--include-files-patterns)
|
|
27
|
+
- [--exclude-files](#--exclude-files-patterns)
|
|
28
|
+
|
|
29
|
+
### Display Options
|
|
30
|
+
|
|
31
|
+
- [--show-unused](#--show-unused)
|
|
32
|
+
- [--no-show-unused](#--no-show-unused)
|
|
33
|
+
- [--show-stats](#--show-stats)
|
|
34
|
+
- [--no-show-stats](#--no-show-stats)
|
|
35
|
+
|
|
36
|
+
### Validation Flags
|
|
37
|
+
|
|
38
|
+
- [--strict](#--strict)
|
|
39
|
+
- [--secrets](#--secrets)
|
|
40
|
+
- [--no-secrets](#--no-secrets)
|
|
41
|
+
- [--ignore-urls](#--ignore-urls-list)
|
|
42
|
+
- [--uppercase-keys](#--uppercase-keys)
|
|
43
|
+
- [--no-uppercase-keys](#--no-uppercase-keys)
|
|
44
|
+
- [--expire-warnings](#--expire-warnings)
|
|
45
|
+
- [--no-expire-warnings](#--no-expire-warnings)
|
|
46
|
+
- [--inconsistent-naming-warnings](#--inconsistent-naming-warnings)
|
|
47
|
+
- [--no-inconsistent-naming-warnings](#--no-inconsistent-naming-warnings)
|
|
48
|
+
|
|
49
|
+
### Comparison Flags
|
|
50
|
+
|
|
51
|
+
- [--compare](#--compare)
|
|
52
|
+
- [--check-values](#--check-values)
|
|
53
|
+
- [--only](#--only-list)
|
|
54
|
+
|
|
55
|
+
## Configuration file
|
|
56
|
+
|
|
57
|
+
You can generate a default configuration file using the `--init` flag:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
dotenv-diff --init
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This creates a `dotenv-diff.config.json` file in the project root with an example configuration
|
|
64
|
+
|
|
65
|
+
> **Note:** You can use all CLI flags in the config file
|
|
66
|
+
|
|
67
|
+
## General Flags
|
|
68
|
+
|
|
69
|
+
### `--env <file>`
|
|
70
|
+
|
|
71
|
+
Path to a specific `.env` file (default: `.env`).
|
|
72
|
+
|
|
73
|
+
Example usage:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
dotenv-diff --env .env.production
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This is the `.env` file that will be compared against your codebase.
|
|
80
|
+
|
|
81
|
+
Commonly used together with the `--compare` flag:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
dotenv-diff --compare --env .env.production --example .env.example
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This compares the specified `.env.production` file against the `.env.example` file.
|
|
88
|
+
|
|
89
|
+
Usage in the configuration file:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"env": ".env.production"
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### `--example <file>`
|
|
98
|
+
|
|
99
|
+
Path to the example `.env` file.
|
|
100
|
+
|
|
101
|
+
Example usage:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
dotenv-diff --example .env.test
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
This can also be used as the `.env` file that will be compared against your codebase. (The `--example` flag will override the `--env` flag if both are provided.)
|
|
108
|
+
|
|
109
|
+
Again, this is also commonly used with the `--compare` flag:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
dotenv-diff --compare --env .env.production --example .env.test
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
This compares the specified `.env.production` file against the `.env.test` file.
|
|
116
|
+
|
|
117
|
+
Usage in the configuration file:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"example": ".env.test"
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
In short, `--env` defines the runtime environment file, while `--example` defines the reference file used for comparison.
|
|
126
|
+
|
|
127
|
+
### `--allow-duplicates`
|
|
128
|
+
|
|
129
|
+
Allows duplicate keys in `.env` files without throwing a warning (or error in strict mode).
|
|
130
|
+
|
|
131
|
+
Example usage:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
dotenv-diff --allow-duplicates
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
This is useful when you have legitimate reasons for duplicate keys in your environment files.
|
|
138
|
+
|
|
139
|
+
This flag can also be used together with the `--compare` flag:
|
|
140
|
+
|
|
141
|
+
Usage in the configuration file:
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"allowDuplicates": true
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### `--ignore <keys>`
|
|
150
|
+
|
|
151
|
+
Specify a comma-separated list of keys to ignore during the comparison other than the default ignored keys which is:
|
|
152
|
+
|
|
153
|
+
- `PWD`
|
|
154
|
+
- `NODE_ENV`
|
|
155
|
+
- `VITE_MODE`
|
|
156
|
+
- `MODE`
|
|
157
|
+
- `BASE_URL`
|
|
158
|
+
- `PROD`
|
|
159
|
+
- `DEV`
|
|
160
|
+
- `SSR`
|
|
161
|
+
|
|
162
|
+
This is useful when you have certain environment variables that are expected to differ between environments and you want to exclude them from the comparison.
|
|
163
|
+
|
|
164
|
+
Example usage:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
dotenv-diff --ignore SECRET_KEY,API_TOKEN
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
This flag can also be used together with the `--compare` flag:
|
|
171
|
+
|
|
172
|
+
Usage in the configuration file:
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"ignore": ["SECRET_KEY", "API_TOKEN"]
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### `--ignore-regex <patterns>`
|
|
181
|
+
|
|
182
|
+
Specify a comma-separated list of regex patterns to ignore keys matching those patterns during the comparison.
|
|
183
|
+
|
|
184
|
+
This is useful when you have patterns of environment variable names that are expected to differ between environments and you want to exclude them from the comparison.
|
|
185
|
+
|
|
186
|
+
Example usage:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
dotenv-diff --ignore-regex SECRET_,API_
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
This flag can also be used together with the `--compare` flag:
|
|
193
|
+
|
|
194
|
+
Usage in the configuration file:
|
|
195
|
+
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"ignoreRegex": ["SECRET_", "API_"]
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### `--fix`
|
|
203
|
+
|
|
204
|
+
Automatically fix issues found during the comparison by adding missing keys, remove duplicates and add .env to .gitignore if missing.
|
|
205
|
+
|
|
206
|
+
Example usage:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
dotenv-diff --fix
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
This flag can also be used together with the `--compare` flag:
|
|
213
|
+
|
|
214
|
+
Usage in the configuration file:
|
|
215
|
+
|
|
216
|
+
```json
|
|
217
|
+
{
|
|
218
|
+
"fix": true
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### `--json`
|
|
223
|
+
|
|
224
|
+
Outputs the results in JSON format.
|
|
225
|
+
|
|
226
|
+
Example usage:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
dotenv-diff --json
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
This flag can also be used together with the `--compare` flag:
|
|
233
|
+
|
|
234
|
+
Usage in the configuration file:
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"json": true
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### `--color`
|
|
243
|
+
|
|
244
|
+
Enables colored output in the terminal (enabled by default).
|
|
245
|
+
|
|
246
|
+
Example usage:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
dotenv-diff --color
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Usage in the configuration file:
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"color": true
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### `--no-color`
|
|
261
|
+
|
|
262
|
+
Disables colored output in the terminal.
|
|
263
|
+
|
|
264
|
+
Example usage:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
dotenv-diff --no-color
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Usage in the configuration file:
|
|
271
|
+
|
|
272
|
+
```json
|
|
273
|
+
{
|
|
274
|
+
"noColor": true
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### `--ci`
|
|
279
|
+
|
|
280
|
+
Run in CI mode: non-interactive and read-only.
|
|
281
|
+
Prevents all file creation and modification, including prompts for missing files.
|
|
282
|
+
Always exits with an error if issues are found. Recommended for CI/CD pipelines.
|
|
283
|
+
|
|
284
|
+
Example usage:
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
dotenv-diff --compare --ci
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Usage in the configuration file:
|
|
291
|
+
|
|
292
|
+
```json
|
|
293
|
+
{
|
|
294
|
+
"ci": true
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### `-y, --yes`
|
|
299
|
+
|
|
300
|
+
Run non-interactively and automatically accept all prompts with "yes".
|
|
301
|
+
Useful for automation when you want to auto-create missing files or apply fixes without manual confirmation.
|
|
302
|
+
Cannot be combined with `--ci` (use one or the other).
|
|
303
|
+
|
|
304
|
+
Example usage:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
dotenv-diff --compare --fix --yes
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Usage in the configuration file:
|
|
311
|
+
|
|
312
|
+
```json
|
|
313
|
+
{
|
|
314
|
+
"yes": true
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## File Scanning Flags
|
|
319
|
+
|
|
320
|
+
### `--files <patterns>`
|
|
321
|
+
|
|
322
|
+
Specify a comma-separated list of file patterns to scan for environment variable usage.
|
|
323
|
+
This **completely replaces** the default file patterns (use `--include-files` to extend instead).
|
|
324
|
+
Useful when you want full control over which files are scanned.
|
|
325
|
+
|
|
326
|
+
Example usage:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
dotenv-diff --files "src/**/*.ts,config/*.js"
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Usage in the configuration file:
|
|
333
|
+
|
|
334
|
+
```json
|
|
335
|
+
{
|
|
336
|
+
"files": ["src/**/*.ts", "config/*.js"]
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### `--include-files <patterns>`
|
|
341
|
+
|
|
342
|
+
Specify a comma-separated list of file patterns to **add** to the default scan patterns.
|
|
343
|
+
This extends the default patterns rather than replacing them (unlike `--files`).
|
|
344
|
+
Useful when you want to include additional file types while keeping the defaults.
|
|
345
|
+
|
|
346
|
+
Example usage:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
dotenv-diff --include-files "*.config.js,scripts/*.sh"
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Usage in the configuration file:
|
|
353
|
+
|
|
354
|
+
```json
|
|
355
|
+
{
|
|
356
|
+
"includeFiles": ["*.config.js", "scripts/*.sh"]
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### `--exclude-files <patterns>`
|
|
361
|
+
|
|
362
|
+
Specify a comma-separated list of file patterns to exclude from scanning.
|
|
363
|
+
These patterns are added to the default exclude patterns (like `node_modules`, `dist`, etc.).
|
|
364
|
+
Useful when you want to skip specific files or directories that shouldn't be scanned.
|
|
365
|
+
|
|
366
|
+
Example usage:
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
dotenv-diff --exclude-files "tests/**,*.spec.ts"
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Usage in the configuration file:
|
|
373
|
+
|
|
374
|
+
```json
|
|
375
|
+
{
|
|
376
|
+
"excludeFiles": ["tests/**", "*.spec.ts"]
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
## Display Options
|
|
381
|
+
|
|
382
|
+
### `--show-unused`
|
|
383
|
+
|
|
384
|
+
List variables that are defined in `.env` but not used in the codebase (enabled by default).
|
|
385
|
+
Helps identify environment variables that may be outdated or unnecessary.
|
|
386
|
+
|
|
387
|
+
Example usage:
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
dotenv-diff --show-unused
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Usage in the configuration file:
|
|
394
|
+
|
|
395
|
+
```json
|
|
396
|
+
{
|
|
397
|
+
"showUnused": true
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### `--no-show-unused`
|
|
402
|
+
|
|
403
|
+
Do not list variables that are defined in `.env` but not used in code.
|
|
404
|
+
Use this flag to hide the unused variables section from the output.
|
|
405
|
+
|
|
406
|
+
Example usage:
|
|
407
|
+
|
|
408
|
+
```bash
|
|
409
|
+
dotenv-diff --no-show-unused
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
Usage in the configuration file:
|
|
413
|
+
|
|
414
|
+
```json
|
|
415
|
+
{
|
|
416
|
+
"showUnused": false
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### `--show-stats`
|
|
421
|
+
|
|
422
|
+
Display statistics about the scan or comparison results (enabled by default).
|
|
423
|
+
Shows metrics like files scanned, total usages, unique variables, and warnings count.
|
|
424
|
+
|
|
425
|
+
Example usage:
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
dotenv-diff --show-stats
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Usage in the configuration file:
|
|
432
|
+
|
|
433
|
+
```json
|
|
434
|
+
{
|
|
435
|
+
"showStats": true
|
|
436
|
+
}
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### `--no-show-stats`
|
|
440
|
+
|
|
441
|
+
Do not display statistics in the output.
|
|
442
|
+
Use this flag to hide the statistics section for a cleaner output.
|
|
443
|
+
|
|
444
|
+
Example usage:
|
|
445
|
+
|
|
446
|
+
```bash
|
|
447
|
+
dotenv-diff --no-show-stats
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
Usage in the configuration file:
|
|
451
|
+
|
|
452
|
+
```json
|
|
453
|
+
{
|
|
454
|
+
"showStats": false
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
## Validation Flags
|
|
459
|
+
|
|
460
|
+
### `--strict`
|
|
461
|
+
|
|
462
|
+
Enable strict mode: treat all warnings as errors and exit with error code 1.
|
|
463
|
+
In strict mode, issues like unused variables, duplicates, secrets, and framework warnings will cause the process to fail.
|
|
464
|
+
Useful for enforcing strict environment variable hygiene in CI/CD pipelines.
|
|
465
|
+
|
|
466
|
+
Example usage:
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
dotenv-diff --strict
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
Usage in the configuration file:
|
|
473
|
+
|
|
474
|
+
```json
|
|
475
|
+
{
|
|
476
|
+
"strict": true
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
### `--secrets`
|
|
481
|
+
|
|
482
|
+
Enable secret detection during codebase scan (enabled by default).
|
|
483
|
+
Scans your code for hardcoded secrets like API keys, tokens, passwords, and other sensitive values.
|
|
484
|
+
Detects high and medium severity secrets that may pose security risks.
|
|
485
|
+
|
|
486
|
+
Example usage:
|
|
487
|
+
|
|
488
|
+
```bash
|
|
489
|
+
dotenv-diff --secrets
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
Usage in the configuration file:
|
|
493
|
+
|
|
494
|
+
```json
|
|
495
|
+
{
|
|
496
|
+
"secrets": true
|
|
497
|
+
}
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
### `--no-secrets`
|
|
501
|
+
|
|
502
|
+
Disable secret detection during scan.
|
|
503
|
+
Use this flag to skip the secret scanning phase and improve scan performance.
|
|
504
|
+
|
|
505
|
+
Example usage:
|
|
506
|
+
|
|
507
|
+
```bash
|
|
508
|
+
dotenv-diff --no-secrets
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
Usage in the configuration file:
|
|
512
|
+
|
|
513
|
+
```json
|
|
514
|
+
{
|
|
515
|
+
"secrets": false
|
|
516
|
+
}
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
### `--ignore-urls <list>`
|
|
520
|
+
|
|
521
|
+
Specify a comma-separated list of URLs to ignore during secret detection.
|
|
522
|
+
Useful for whitelisting known safe URLs that might otherwise be flagged as potential secrets.
|
|
523
|
+
Uses case-insensitive substring matching.
|
|
524
|
+
|
|
525
|
+
Example usage:
|
|
526
|
+
|
|
527
|
+
```bash
|
|
528
|
+
dotenv-diff --ignore-urls https://safesecret
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
Usage in the configuration file:
|
|
532
|
+
|
|
533
|
+
```json
|
|
534
|
+
{
|
|
535
|
+
"ignoreUrls": ["https://example.com", "localhost"]
|
|
536
|
+
}
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
### `--uppercase-keys`
|
|
540
|
+
|
|
541
|
+
Enable validation that environment variable keys follow UPPER*SNAKE_CASE naming convention (enabled by default).
|
|
542
|
+
Warns about keys that don't match the pattern `[A-Z0-9*]+` and suggests properly formatted alternatives.
|
|
543
|
+
Helps maintain consistent naming conventions across your environment files.
|
|
544
|
+
|
|
545
|
+
Example usage:
|
|
546
|
+
|
|
547
|
+
```bash
|
|
548
|
+
dotenv-diff --uppercase-keys
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
Usage in the configuration file:
|
|
552
|
+
|
|
553
|
+
```json
|
|
554
|
+
{
|
|
555
|
+
"uppercaseKeys": true
|
|
556
|
+
}
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
### `--no-uppercase-keys`
|
|
560
|
+
|
|
561
|
+
Disable uppercase key validation.
|
|
562
|
+
Use this flag if your project uses different naming conventions for environment variables.
|
|
563
|
+
|
|
564
|
+
Example usage:
|
|
565
|
+
|
|
566
|
+
```bash
|
|
567
|
+
dotenv-diff --no-uppercase-keys
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
Usage in the configuration file:
|
|
571
|
+
|
|
572
|
+
```json
|
|
573
|
+
{
|
|
574
|
+
"uppercaseKeys": false
|
|
575
|
+
}
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
### `--expire-warnings`
|
|
579
|
+
|
|
580
|
+
Enable detection of expiration dates for environment variables (enabled by default).
|
|
581
|
+
Detects `@expire` or `# @expire YYYY-MM-DD` comments in `.env` files and warns when variables are approaching or past their expiration date.
|
|
582
|
+
Useful for managing temporary API keys, tokens, or time-sensitive credentials.
|
|
583
|
+
|
|
584
|
+
Example usage:
|
|
585
|
+
|
|
586
|
+
```bash
|
|
587
|
+
dotenv-diff --expire-warnings
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
Usage in the configuration file:
|
|
591
|
+
|
|
592
|
+
```json
|
|
593
|
+
{
|
|
594
|
+
"expireWarnings": true
|
|
595
|
+
}
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### `--no-expire-warnings`
|
|
599
|
+
|
|
600
|
+
Disable expiration date warnings.
|
|
601
|
+
Use this flag to skip checking for `@expire` annotations in environment files.
|
|
602
|
+
|
|
603
|
+
Example usage:
|
|
604
|
+
|
|
605
|
+
```bash
|
|
606
|
+
dotenv-diff --no-expire-warnings
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
Usage in the configuration file:
|
|
610
|
+
|
|
611
|
+
```json
|
|
612
|
+
{
|
|
613
|
+
"expireWarnings": false
|
|
614
|
+
}
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
### `--inconsistent-naming-warnings`
|
|
618
|
+
|
|
619
|
+
Detects inconsistent naming patterns in environment variable keys (enabled by default). This helps identify keys that are semantically the same but use different formatting styles (e.g., `API_KEY` vs `APIKEY`, `DATABASE_URL` vs `DATABASEURL`). The tool compares keys and warns when they match after removing underscores, suggesting the snake_case version as the standard.
|
|
620
|
+
|
|
621
|
+
Use this to maintain consistent naming conventions across your environment variables and avoid confusion.
|
|
622
|
+
|
|
623
|
+
Example usage:
|
|
624
|
+
|
|
625
|
+
```bash
|
|
626
|
+
dotenv-diff --inconsistent-naming-warnings
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
Usage in the configuration file:
|
|
630
|
+
|
|
631
|
+
```json
|
|
632
|
+
{
|
|
633
|
+
"inconsistentNamingWarnings": true
|
|
634
|
+
}
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
### `--no-inconsistent-naming-warnings`
|
|
638
|
+
|
|
639
|
+
Disable inconsistent naming pattern warnings.
|
|
640
|
+
|
|
641
|
+
Example usage:
|
|
642
|
+
|
|
643
|
+
```bash
|
|
644
|
+
dotenv-diff --no-inconsistent-naming-warnings
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
Usage in the configuration file:
|
|
648
|
+
|
|
649
|
+
```json
|
|
650
|
+
{
|
|
651
|
+
"inconsistentNamingWarnings": false
|
|
652
|
+
}
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
# Comparison Flags
|
|
656
|
+
|
|
657
|
+
This is flags related to comparing two `.env` files.
|
|
658
|
+
And can only be used in combination with the `--compare` flag.
|
|
659
|
+
|
|
660
|
+
### `--compare`
|
|
661
|
+
|
|
662
|
+
Explicitly enables the comparison between the specified `.env` file and the example `.env` file.
|
|
663
|
+
|
|
664
|
+
Example usage:
|
|
665
|
+
|
|
666
|
+
```bash
|
|
667
|
+
dotenv-diff --compare
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
This flag is useful when you want to ensure that your runtime environment file matches the structure of your example file.
|
|
671
|
+
|
|
672
|
+
Usage in the configuration file:
|
|
673
|
+
|
|
674
|
+
```json
|
|
675
|
+
{
|
|
676
|
+
"compare": true
|
|
677
|
+
}
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
### `--check-values`
|
|
681
|
+
|
|
682
|
+
Compare not only the keys but also the values of the environment variables between the two files.
|
|
683
|
+
|
|
684
|
+
This flag can only be used in combination with the `--compare` flag.
|
|
685
|
+
|
|
686
|
+
Example usage:
|
|
687
|
+
|
|
688
|
+
```bash
|
|
689
|
+
dotenv-diff --compare --check-values
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
Usage in the configuration file:
|
|
693
|
+
|
|
694
|
+
```json
|
|
695
|
+
{
|
|
696
|
+
"checkValues": true
|
|
697
|
+
}
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
### `--only <list>`
|
|
701
|
+
|
|
702
|
+
Specify a comma-separated list of keys to exclusively check in the comparison.
|
|
703
|
+
|
|
704
|
+
Example usage:
|
|
705
|
+
|
|
706
|
+
```bash
|
|
707
|
+
dotenv-diff --compare --only missing,duplicate
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
This flag can only be used in combination with the `--compare` flag.
|
|
711
|
+
|
|
712
|
+
`--only` accepts the following values:
|
|
713
|
+
|
|
714
|
+
- `missing`: Check for missing keys in the runtime `.env` file compared to the example file.
|
|
715
|
+
- `extra`: Check for extra keys in the runtime `.env` file that are not present in the example file.
|
|
716
|
+
- `empty`: Check for keys that have empty values in the runtime `.env` file.
|
|
717
|
+
- `duplicate`: Check for duplicate keys in either of the `.env` files.
|
|
718
|
+
- `gitignore`: check if the `.env` file is listed in `.gitignore`.
|
|
719
|
+
|
|
720
|
+
Usage in the configuration file:
|
|
721
|
+
|
|
722
|
+
```json
|
|
723
|
+
{
|
|
724
|
+
"only": ["missing", "duplicate"]
|
|
725
|
+
}
|
|
726
|
+
```
|