dotenv-diff 2.4.5 → 2.4.7
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 +16 -0
- package/README.md +34 -131
- package/dist/src/cli/run.d.ts.map +1 -1
- package/dist/src/cli/run.js +53 -41
- package/dist/src/cli/run.js.map +1 -1
- package/dist/src/commands/compare.d.ts +2 -2
- package/dist/src/commands/compare.d.ts.map +1 -1
- package/dist/src/commands/compare.js +64 -50
- package/dist/src/commands/compare.js.map +1 -1
- package/dist/src/commands/scanUsage.d.ts +3 -5
- package/dist/src/commands/scanUsage.d.ts.map +1 -1
- package/dist/src/commands/scanUsage.js +2 -4
- package/dist/src/commands/scanUsage.js.map +1 -1
- package/dist/src/config/constants.d.ts +42 -0
- package/dist/src/config/constants.d.ts.map +1 -0
- package/dist/src/config/constants.js +54 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/config/loadConfig.d.ts.map +1 -1
- package/dist/src/config/loadConfig.js +6 -2
- package/dist/src/config/loadConfig.js.map +1 -1
- package/dist/src/config/options.d.ts +21 -4
- package/dist/src/config/options.d.ts.map +1 -1
- package/dist/src/config/options.js +72 -55
- package/dist/src/config/options.js.map +1 -1
- package/dist/src/config/types.d.ts +172 -197
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/config/types.js +1 -10
- package/dist/src/config/types.js.map +1 -1
- package/dist/src/core/compareScan.d.ts +1 -0
- package/dist/src/core/compareScan.d.ts.map +1 -1
- package/dist/src/core/compareScan.js +1 -0
- package/dist/src/core/compareScan.js.map +1 -1
- package/dist/src/core/determineComparisonFile.d.ts +1 -1
- package/dist/src/core/determineComparisonFile.d.ts.map +1 -1
- package/dist/src/core/determineComparisonFile.js +2 -8
- package/dist/src/core/determineComparisonFile.js.map +1 -1
- package/dist/src/core/envPairing.d.ts +1 -2
- package/dist/src/core/envPairing.d.ts.map +1 -1
- package/dist/src/core/envPairing.js +5 -2
- package/dist/src/core/envPairing.js.map +1 -1
- package/dist/src/core/fixEnv.d.ts.map +1 -1
- package/dist/src/core/fixEnv.js +4 -2
- package/dist/src/core/fixEnv.js.map +1 -1
- package/dist/src/core/frameworkDetector.d.ts +4 -3
- package/dist/src/core/frameworkDetector.d.ts.map +1 -1
- package/dist/src/core/frameworkDetector.js.map +1 -1
- package/dist/src/core/frameworkValidator.d.ts +2 -10
- package/dist/src/core/frameworkValidator.d.ts.map +1 -1
- package/dist/src/core/frameworkValidator.js.map +1 -1
- package/dist/src/core/frameworks/nextJsRules.d.ts +2 -3
- package/dist/src/core/frameworks/nextJsRules.d.ts.map +1 -1
- package/dist/src/core/frameworks/nextJsRules.js +18 -20
- package/dist/src/core/frameworks/nextJsRules.js.map +1 -1
- package/dist/src/core/frameworks/sveltekitRules.d.ts +2 -3
- package/dist/src/core/frameworks/sveltekitRules.d.ts.map +1 -1
- package/dist/src/core/frameworks/sveltekitRules.js +41 -29
- package/dist/src/core/frameworks/sveltekitRules.js.map +1 -1
- package/dist/src/core/helpers/normalizePath.d.ts +6 -0
- package/dist/src/core/helpers/normalizePath.d.ts.map +1 -0
- package/dist/src/core/helpers/normalizePath.js +8 -0
- package/dist/src/core/helpers/normalizePath.js.map +1 -0
- package/dist/src/core/helpers/updateTotals.d.ts +1 -2
- package/dist/src/core/helpers/updateTotals.d.ts.map +1 -1
- package/dist/src/core/helpers/updateTotals.js.map +1 -1
- package/dist/src/core/patterns.d.ts +0 -15
- package/dist/src/core/patterns.d.ts.map +1 -1
- package/dist/src/core/patterns.js +0 -18
- package/dist/src/core/patterns.js.map +1 -1
- package/dist/src/core/processComparisonFile.d.ts +6 -14
- package/dist/src/core/processComparisonFile.d.ts.map +1 -1
- package/dist/src/core/processComparisonFile.js.map +1 -1
- package/dist/src/core/scanFile.d.ts +1 -1
- package/dist/src/core/scanFile.d.ts.map +1 -1
- package/dist/src/core/scanFile.js +7 -5
- package/dist/src/core/scanFile.js.map +1 -1
- package/dist/src/core/scanJsonOutput.d.ts +78 -4
- package/dist/src/core/scanJsonOutput.d.ts.map +1 -1
- package/dist/src/core/scanJsonOutput.js +39 -32
- package/dist/src/core/scanJsonOutput.js.map +1 -1
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/services/codeBaseScanner.d.ts.map +1 -1
- package/dist/src/services/codeBaseScanner.js +59 -22
- package/dist/src/services/codeBaseScanner.js.map +1 -1
- package/dist/src/services/duplicates.js +2 -2
- package/dist/src/services/duplicates.js.map +1 -1
- package/dist/src/services/ensureFilesOrPrompt.d.ts.map +1 -1
- package/dist/src/services/ensureFilesOrPrompt.js +5 -2
- package/dist/src/services/ensureFilesOrPrompt.js.map +1 -1
- package/dist/src/services/envDiscovery.d.ts +1 -14
- package/dist/src/services/envDiscovery.d.ts.map +1 -1
- package/dist/src/services/envDiscovery.js +22 -9
- package/dist/src/services/envDiscovery.js.map +1 -1
- package/dist/src/services/git.d.ts.map +1 -1
- package/dist/src/services/git.js +10 -9
- package/dist/src/services/git.js.map +1 -1
- package/dist/src/services/scanOutputToConsole.d.ts +2 -4
- package/dist/src/services/scanOutputToConsole.d.ts.map +1 -1
- package/dist/src/services/scanOutputToConsole.js +5 -4
- package/dist/src/services/scanOutputToConsole.js.map +1 -1
- package/dist/src/ui/compare/printIssues.d.ts +1 -1
- package/dist/src/ui/compare/printIssues.d.ts.map +1 -1
- package/dist/src/ui/compare/printIssues.js +0 -1
- package/dist/src/ui/compare/printIssues.js.map +1 -1
- package/dist/src/ui/compare/printStats.d.ts +1 -1
- package/dist/src/ui/compare/printStats.d.ts.map +1 -1
- package/dist/src/ui/compare/printStats.js +0 -1
- package/dist/src/ui/compare/printStats.js.map +1 -1
- package/dist/src/ui/scan/printConsolelogWarning.d.ts.map +1 -1
- package/dist/src/ui/scan/printConsolelogWarning.js +3 -1
- package/dist/src/ui/scan/printConsolelogWarning.js.map +1 -1
- package/dist/src/ui/scan/printFrameworkWarnings.d.ts +2 -2
- package/dist/src/ui/scan/printFrameworkWarnings.d.ts.map +1 -1
- package/dist/src/ui/scan/printFrameworkWarnings.js.map +1 -1
- package/dist/src/ui/scan/printMissing.d.ts.map +1 -1
- package/dist/src/ui/scan/printMissing.js +3 -1
- package/dist/src/ui/scan/printMissing.js.map +1 -1
- package/dist/src/ui/scan/printProgress.d.ts +15 -0
- package/dist/src/ui/scan/printProgress.d.ts.map +1 -0
- package/dist/src/ui/scan/printProgress.js +35 -0
- package/dist/src/ui/scan/printProgress.js.map +1 -0
- package/dist/src/ui/scan/printSecrets.d.ts +1 -1
- package/dist/src/ui/scan/printSecrets.d.ts.map +1 -1
- package/dist/src/ui/scan/printSecrets.js +3 -2
- package/dist/src/ui/scan/printSecrets.js.map +1 -1
- package/dist/src/ui/shared/printFixTips.d.ts +1 -1
- package/dist/src/ui/shared/printFixTips.d.ts.map +1 -1
- package/dist/src/ui/shared/printFixTips.js +0 -1
- package/dist/src/ui/shared/printFixTips.js.map +1 -1
- package/dist/src/ui/shared/printProgress.d.ts +24 -0
- package/dist/src/ui/shared/printProgress.d.ts.map +1 -0
- package/dist/src/ui/shared/printProgress.js +43 -0
- package/dist/src/ui/shared/printProgress.js.map +1 -0
- package/dist/src/ui/shared/setupGlobalConfig.d.ts +1 -1
- package/dist/src/ui/shared/setupGlobalConfig.d.ts.map +1 -1
- package/dist/src/ui/shared/setupGlobalConfig.js +0 -1
- package/dist/src/ui/shared/setupGlobalConfig.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
import { ALLOWED_CATEGORIES } from './constants.js';
|
|
1
2
|
import { type SecretFinding } from '../core/secretDetectors.js';
|
|
2
|
-
import { type frameworkWarning } from '../core/frameworkValidator.js';
|
|
3
3
|
import { type ExampleSecretWarning } from '../core/exampleSecretDetector.js';
|
|
4
|
+
export type SupportedFramework = 'sveltekit' | 'nextjs';
|
|
5
|
+
export type DetectedFramework = SupportedFramework | 'unknown';
|
|
6
|
+
/**
|
|
7
|
+
* Framework-specific warning about environment variable usage
|
|
8
|
+
* From rules defined for each supported framework (SvelteKit, Next.js)
|
|
9
|
+
*/
|
|
10
|
+
export interface FrameworkWarning {
|
|
11
|
+
variable: string;
|
|
12
|
+
reason: string;
|
|
13
|
+
file: string;
|
|
14
|
+
line: number;
|
|
15
|
+
framework: SupportedFramework;
|
|
16
|
+
}
|
|
4
17
|
export type Duplicate = {
|
|
5
18
|
key: string;
|
|
6
19
|
count: number;
|
|
@@ -9,43 +22,21 @@ export interface DuplicateResult {
|
|
|
9
22
|
dupsEnv: Duplicate[];
|
|
10
23
|
dupsEx: Duplicate[];
|
|
11
24
|
}
|
|
12
|
-
export declare const ALLOWED_CATEGORIES: readonly ["missing", "extra", "empty", "mismatch", "duplicate", "gitignore"];
|
|
13
25
|
export type Category = (typeof ALLOWED_CATEGORIES)[number];
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
ignore: string[];
|
|
27
|
-
ignoreRegex: RegExp[];
|
|
28
|
-
cwd: string;
|
|
29
|
-
only?: Category[];
|
|
30
|
-
compare: boolean;
|
|
31
|
-
scanUsage: boolean;
|
|
32
|
-
includeFiles: string[];
|
|
33
|
-
excludeFiles: string[];
|
|
34
|
-
showUnused: boolean;
|
|
35
|
-
showStats: boolean;
|
|
36
|
-
files?: string[];
|
|
37
|
-
noColor?: boolean;
|
|
38
|
-
secrets: boolean;
|
|
39
|
-
strict: boolean | undefined;
|
|
40
|
-
ignoreUrls?: string[];
|
|
41
|
-
uppercaseKeys: boolean;
|
|
42
|
-
expireWarnings: boolean;
|
|
43
|
-
inconsistentNamingWarnings: boolean;
|
|
44
|
-
};
|
|
45
|
-
/** Type representing the raw options for the comparison
|
|
46
|
-
* These are the options that are directly passed to the comparison function without any processing or validation.
|
|
26
|
+
/**
|
|
27
|
+
* Raw options as received directly from the CLI argument parser.
|
|
28
|
+
*
|
|
29
|
+
* These values are intentionally loose and reflect how flags are actually
|
|
30
|
+
* provided by the user:
|
|
31
|
+
* - Values may be missing
|
|
32
|
+
* - Lists may be strings or string arrays
|
|
33
|
+
* - No defaults are applied
|
|
34
|
+
* - No validation or normalization has happened yet
|
|
35
|
+
*
|
|
36
|
+
* This type should only be used at the CLI boundary and passed into the
|
|
37
|
+
* normalization step that produces {@link Options}.
|
|
47
38
|
*/
|
|
48
|
-
export
|
|
39
|
+
export interface RawOptions {
|
|
49
40
|
checkValues?: boolean;
|
|
50
41
|
ci?: boolean;
|
|
51
42
|
yes?: boolean;
|
|
@@ -72,37 +63,48 @@ export type RawOptions = {
|
|
|
72
63
|
uppercaseKeys?: boolean;
|
|
73
64
|
expireWarnings?: boolean;
|
|
74
65
|
inconsistentNamingWarnings?: boolean;
|
|
75
|
-
}
|
|
66
|
+
}
|
|
76
67
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
68
|
+
* Normalized and validated options used internally by the application.
|
|
69
|
+
*
|
|
70
|
+
* These options represent the final, safe configuration that the rest of the
|
|
71
|
+
* codebase can rely on. All values are:
|
|
72
|
+
* - Fully normalized (no string | string[] unions)
|
|
73
|
+
* - Resolved to absolute paths where applicable
|
|
74
|
+
* - Filled with defaults for omitted flags
|
|
75
|
+
* - Validated and ready for use
|
|
76
|
+
*
|
|
77
|
+
* This type should be used everywhere outside of CLI parsing and option
|
|
78
|
+
* normalization logic.
|
|
79
79
|
*/
|
|
80
|
-
export
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
80
|
+
export interface Options {
|
|
81
|
+
checkValues: boolean;
|
|
82
|
+
isCiMode: boolean;
|
|
83
|
+
isYesMode: boolean;
|
|
84
|
+
allowDuplicates: boolean;
|
|
85
|
+
fix: boolean;
|
|
86
|
+
json: boolean;
|
|
87
|
+
envFlag: string | undefined;
|
|
88
|
+
exampleFlag: string | undefined;
|
|
89
|
+
ignore: string[];
|
|
90
|
+
ignoreRegex: RegExp[];
|
|
91
|
+
cwd: string;
|
|
92
|
+
only: Category[];
|
|
93
|
+
compare: boolean;
|
|
94
|
+
scanUsage: boolean;
|
|
95
|
+
includeFiles: string[];
|
|
96
|
+
excludeFiles: string[];
|
|
97
|
+
showUnused: boolean;
|
|
98
|
+
showStats: boolean;
|
|
99
|
+
files: string[];
|
|
100
|
+
noColor: boolean;
|
|
101
|
+
secrets: boolean;
|
|
102
|
+
strict: boolean;
|
|
103
|
+
ignoreUrls: string[];
|
|
104
|
+
uppercaseKeys: boolean;
|
|
105
|
+
expireWarnings: boolean;
|
|
106
|
+
inconsistentNamingWarnings: boolean;
|
|
107
|
+
}
|
|
106
108
|
/**
|
|
107
109
|
* Represents a single usage of an environment variable in the codebase.
|
|
108
110
|
*/
|
|
@@ -111,20 +113,45 @@ export interface EnvUsage {
|
|
|
111
113
|
file: string;
|
|
112
114
|
line: number;
|
|
113
115
|
column: number;
|
|
114
|
-
pattern: 'process.env' | 'import.meta.env' | 'sveltekit'
|
|
116
|
+
pattern: 'process.env' | 'import.meta.env' | 'sveltekit';
|
|
115
117
|
context: string;
|
|
116
118
|
isLogged?: boolean;
|
|
117
119
|
}
|
|
120
|
+
export type VariableUsages = Record<string, EnvUsage[]>;
|
|
121
|
+
/**
|
|
122
|
+
* Options for scanning the codebase
|
|
123
|
+
*/
|
|
118
124
|
export interface ScanOptions {
|
|
119
125
|
cwd: string;
|
|
120
126
|
include: string[];
|
|
121
127
|
exclude: string[];
|
|
122
128
|
ignore: string[];
|
|
123
129
|
ignoreRegex: RegExp[];
|
|
124
|
-
files
|
|
125
|
-
secrets
|
|
126
|
-
ignoreUrls
|
|
130
|
+
files: string[];
|
|
131
|
+
secrets: boolean;
|
|
132
|
+
ignoreUrls: string[];
|
|
133
|
+
json: boolean;
|
|
127
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Extends the basic ScanOptions with additional parameters.
|
|
137
|
+
* All of these options are optional, as they may not be needed for every scan.
|
|
138
|
+
*/
|
|
139
|
+
export interface ScanUsageOptions extends ScanOptions {
|
|
140
|
+
envPath?: string | undefined;
|
|
141
|
+
examplePath?: string | undefined;
|
|
142
|
+
fix?: boolean;
|
|
143
|
+
showUnused?: boolean;
|
|
144
|
+
showStats?: boolean;
|
|
145
|
+
isCiMode?: boolean;
|
|
146
|
+
allowDuplicates?: boolean;
|
|
147
|
+
strict?: boolean;
|
|
148
|
+
uppercaseKeys?: boolean;
|
|
149
|
+
expireWarnings?: boolean;
|
|
150
|
+
inconsistentNamingWarnings?: boolean;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Result of scanning the codebase for environment variable usages.
|
|
154
|
+
*/
|
|
128
155
|
export interface ScanResult {
|
|
129
156
|
used: EnvUsage[];
|
|
130
157
|
missing: string[];
|
|
@@ -138,16 +165,10 @@ export interface ScanResult {
|
|
|
138
165
|
};
|
|
139
166
|
secrets: SecretFinding[];
|
|
140
167
|
duplicates: {
|
|
141
|
-
env?:
|
|
142
|
-
|
|
143
|
-
count: number;
|
|
144
|
-
}>;
|
|
145
|
-
example?: Array<{
|
|
146
|
-
key: string;
|
|
147
|
-
count: number;
|
|
148
|
-
}>;
|
|
168
|
+
env?: Duplicate[];
|
|
169
|
+
example?: Duplicate[];
|
|
149
170
|
};
|
|
150
|
-
frameworkWarnings?:
|
|
171
|
+
frameworkWarnings?: FrameworkWarning[];
|
|
151
172
|
exampleWarnings?: ExampleSecretWarning[];
|
|
152
173
|
logged: EnvUsage[];
|
|
153
174
|
uppercaseWarnings?: UppercaseWarning[];
|
|
@@ -155,103 +176,33 @@ export interface ScanResult {
|
|
|
155
176
|
inconsistentNamingWarnings?: InconsistentNamingWarning[];
|
|
156
177
|
fileContentMap?: Map<string, string>;
|
|
157
178
|
}
|
|
158
|
-
/**
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
files?: string[];
|
|
168
|
-
allowDuplicates?: boolean;
|
|
169
|
-
strict?: boolean;
|
|
170
|
-
uppercaseKeys?: boolean;
|
|
171
|
-
expireWarnings?: boolean;
|
|
172
|
-
inconsistentNamingWarnings?: boolean;
|
|
173
|
-
}
|
|
174
|
-
export interface ScanJsonEntry {
|
|
175
|
-
stats: {
|
|
176
|
-
filesScanned: number;
|
|
177
|
-
totalUsages: number;
|
|
178
|
-
uniqueVariables: number;
|
|
179
|
-
warningsCount: number;
|
|
180
|
-
duration: number;
|
|
179
|
+
/**
|
|
180
|
+
* Type representing a single entry in the comparison results
|
|
181
|
+
* This entry contains the environment variable and its example value.
|
|
182
|
+
*/
|
|
183
|
+
export type CompareJsonEntry = {
|
|
184
|
+
env: string;
|
|
185
|
+
example: string;
|
|
186
|
+
skipped?: {
|
|
187
|
+
reason: string;
|
|
181
188
|
};
|
|
182
|
-
missing: Array<{
|
|
183
|
-
variable: string;
|
|
184
|
-
usages: Array<{
|
|
185
|
-
file: string;
|
|
186
|
-
line: number;
|
|
187
|
-
pattern: string;
|
|
188
|
-
context: string;
|
|
189
|
-
}>;
|
|
190
|
-
}>;
|
|
191
|
-
unused: string[];
|
|
192
|
-
allUsages?: Array<{
|
|
193
|
-
variable: string;
|
|
194
|
-
file: string;
|
|
195
|
-
line: number;
|
|
196
|
-
pattern: string;
|
|
197
|
-
context: string;
|
|
198
|
-
}>;
|
|
199
|
-
comparedAgainst?: string;
|
|
200
|
-
totalEnvVariables?: number;
|
|
201
|
-
secrets?: Array<{
|
|
202
|
-
file: string;
|
|
203
|
-
line: number;
|
|
204
|
-
message: string;
|
|
205
|
-
snippet: string;
|
|
206
|
-
}>;
|
|
207
189
|
duplicates?: {
|
|
208
|
-
env?:
|
|
209
|
-
|
|
210
|
-
count: number;
|
|
211
|
-
}>;
|
|
212
|
-
example?: Array<{
|
|
213
|
-
key: string;
|
|
214
|
-
count: number;
|
|
215
|
-
}>;
|
|
190
|
+
env?: Duplicate[];
|
|
191
|
+
example?: Duplicate[];
|
|
216
192
|
};
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
context: string;
|
|
222
|
-
}>;
|
|
223
|
-
expireWarnings?: Array<{
|
|
224
|
-
key: string;
|
|
225
|
-
date: string;
|
|
226
|
-
daysLeft: number;
|
|
227
|
-
}>;
|
|
228
|
-
uppercaseWarnings?: Array<{
|
|
229
|
-
key: string;
|
|
230
|
-
suggestion: string;
|
|
231
|
-
}>;
|
|
232
|
-
inconsistentNamingWarnings?: Array<{
|
|
233
|
-
key1: string;
|
|
234
|
-
key2: string;
|
|
235
|
-
suggestion: string;
|
|
236
|
-
}>;
|
|
237
|
-
frameworkWarnings?: Array<{
|
|
238
|
-
variable: string;
|
|
239
|
-
reason: string;
|
|
240
|
-
file: string;
|
|
241
|
-
line: number;
|
|
242
|
-
framework: string;
|
|
243
|
-
}>;
|
|
244
|
-
exampleWarnings?: Array<{
|
|
193
|
+
missing?: string[];
|
|
194
|
+
extra?: string[];
|
|
195
|
+
empty?: string[];
|
|
196
|
+
valueMismatches?: Array<{
|
|
245
197
|
key: string;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
severity: string;
|
|
198
|
+
expected: string;
|
|
199
|
+
actual: string;
|
|
249
200
|
}>;
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
201
|
+
ok?: boolean;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Options for comparing environment files (--compare flag).
|
|
205
|
+
*/
|
|
255
206
|
export interface ComparisonOptions {
|
|
256
207
|
checkValues: boolean;
|
|
257
208
|
cwd: string;
|
|
@@ -268,30 +219,24 @@ export interface ComparisonOptions {
|
|
|
268
219
|
expireWarnings?: boolean;
|
|
269
220
|
inconsistentNamingWarnings?: boolean;
|
|
270
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Represents a resolved pair of environment files used for comparison.
|
|
224
|
+
*
|
|
225
|
+
* A FilePair describes one concrete comparison unit consisting of:
|
|
226
|
+
* - an environment file (e.g. `.env`, `.env.production`)
|
|
227
|
+
* - the example file it should be compared against
|
|
228
|
+
*/
|
|
271
229
|
export interface FilePair {
|
|
230
|
+
/** The name of the environment file (e.g. ".env", ".env.production") */
|
|
272
231
|
envName: string;
|
|
232
|
+
/** Absolute path to the environment file */
|
|
273
233
|
envPath: string;
|
|
234
|
+
/** Absolute path to the example file this env file is compared against */
|
|
274
235
|
examplePath: string;
|
|
275
236
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
export type PairContext = {
|
|
280
|
-
envName: string;
|
|
281
|
-
envPath: string;
|
|
282
|
-
exampleName: string;
|
|
283
|
-
examplePath: string;
|
|
284
|
-
exists: {
|
|
285
|
-
env: boolean;
|
|
286
|
-
example: boolean;
|
|
287
|
-
};
|
|
288
|
-
currentFull?: Record<string, string>;
|
|
289
|
-
exampleFull?: Record<string, string>;
|
|
290
|
-
currentKeys?: string[];
|
|
291
|
-
exampleKeys?: string[];
|
|
292
|
-
current?: Record<string, string>;
|
|
293
|
-
example?: Record<string, string>;
|
|
294
|
-
};
|
|
237
|
+
/**
|
|
238
|
+
* Result of filtering comparison results based on categories
|
|
239
|
+
*/
|
|
295
240
|
export type Filtered = {
|
|
296
241
|
missing: string[];
|
|
297
242
|
extra?: string[];
|
|
@@ -301,30 +246,60 @@ export type Filtered = {
|
|
|
301
246
|
expected: string;
|
|
302
247
|
actual: string;
|
|
303
248
|
}>;
|
|
304
|
-
duplicatesEnv:
|
|
305
|
-
|
|
306
|
-
count: number;
|
|
307
|
-
}>;
|
|
308
|
-
duplicatesEx: Array<{
|
|
309
|
-
key: string;
|
|
310
|
-
count: number;
|
|
311
|
-
}>;
|
|
249
|
+
duplicatesEnv: Duplicate[];
|
|
250
|
+
duplicatesEx: Duplicate[];
|
|
312
251
|
gitignoreIssue: {
|
|
313
252
|
reason: 'no-gitignore' | 'not-ignored';
|
|
314
253
|
} | null;
|
|
315
254
|
};
|
|
255
|
+
/**
|
|
256
|
+
* Result of the exit code determination after scanning or comparing.
|
|
257
|
+
*/
|
|
258
|
+
export interface ExitResult {
|
|
259
|
+
exitWithError: boolean;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Warning about environment variable keys that are not uppercase.
|
|
263
|
+
*/
|
|
316
264
|
export interface UppercaseWarning {
|
|
317
265
|
key: string;
|
|
318
266
|
suggestion: string;
|
|
319
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Warning about environment variable keys that have expiration dates.
|
|
270
|
+
* fx:
|
|
271
|
+
*
|
|
272
|
+
* # @expire 2025-12-31
|
|
273
|
+
* API_KEY=
|
|
274
|
+
*
|
|
275
|
+
* This will generate a warning that API_KEY expires on 2025-12-31.
|
|
276
|
+
*/
|
|
320
277
|
export interface ExpireWarning {
|
|
321
278
|
key: string;
|
|
322
279
|
date: string;
|
|
323
280
|
daysLeft: number;
|
|
324
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Warning about inconsistent naming of environment variable keys.
|
|
284
|
+
* fx: If you have both SECRET_KEY and SECRETKEY (inconsistent naming)
|
|
285
|
+
*/
|
|
325
286
|
export interface InconsistentNamingWarning {
|
|
326
287
|
key1: string;
|
|
327
288
|
key2: string;
|
|
328
289
|
suggestion: string;
|
|
329
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Represents the discovery of environment files in a project.
|
|
293
|
+
* Contains information about the current working directory, found environment files,
|
|
294
|
+
* and the primary environment and example files.
|
|
295
|
+
*/
|
|
296
|
+
export interface Discovery {
|
|
297
|
+
cwd: string;
|
|
298
|
+
envFiles: string[];
|
|
299
|
+
primaryEnv: string;
|
|
300
|
+
primaryExample: string;
|
|
301
|
+
envFlag: string | null;
|
|
302
|
+
exampleFlag: string | null;
|
|
303
|
+
alreadyWarnedMissingEnv: boolean;
|
|
304
|
+
}
|
|
330
305
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAGxD,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG,SAAS,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,kBAAkB,CAAC;CAC/B;AAGD,MAAM,MAAM,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAGvD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAGD,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW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ACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,uBAAuB,EAAE,OAAO,CAAC;CAClC"}
|
package/dist/src/config/types.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
+
import { ALLOWED_CATEGORIES } from './constants.js';
|
|
1
2
|
import {} from '../core/secretDetectors.js';
|
|
2
|
-
import {} from '../core/frameworkValidator.js';
|
|
3
3
|
import {} from '../core/exampleSecretDetector.js';
|
|
4
|
-
// Allowed categories for comparison
|
|
5
|
-
export const ALLOWED_CATEGORIES = [
|
|
6
|
-
'missing',
|
|
7
|
-
'extra',
|
|
8
|
-
'empty',
|
|
9
|
-
'mismatch',
|
|
10
|
-
'duplicate',
|
|
11
|
-
'gitignore',
|
|
12
|
-
];
|
|
13
4
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAsB,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAA6B,MAAM,kCAAkC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ScanResult } from '../config/types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Compares the scan result with the environment variables.
|
|
4
|
+
* This function identifies missing and unused environment variables.
|
|
4
5
|
* @param scanResult - The result of the scan.
|
|
5
6
|
* @param envVariables - The environment variables to compare against.
|
|
6
7
|
* @returns The comparison result.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareScan.d.ts","sourceRoot":"","sources":["../../../src/core/compareScan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"compareScan.d.ts","sourceRoot":"","sources":["../../../src/core/compareScan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAC/C,UAAU,CAYZ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compares the scan result with the environment variables.
|
|
3
|
+
* This function identifies missing and unused environment variables.
|
|
3
4
|
* @param scanResult - The result of the scan.
|
|
4
5
|
* @param envVariables - The environment variables to compare against.
|
|
5
6
|
* @returns The comparison result.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareScan.js","sourceRoot":"","sources":["../../../src/core/compareScan.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"compareScan.js","sourceRoot":"","sources":["../../../src/core/compareScan.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAAsB,EACtB,YAAgD;IAEhD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtE,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnD,MAAM,OAAO,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,MAAM,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjE,OAAO;QACL,GAAG,UAAU;QACb,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"determineComparisonFile.d.ts","sourceRoot":"","sources":["../../../src/core/determineComparisonFile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"determineComparisonFile.d.ts","sourceRoot":"","sources":["../../../src/core/determineComparisonFile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,gBAAgB,GACrB,cAAc,GAAG,SAAS,CA0B5B"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import {} from '../config/types.js';
|
|
4
3
|
import { resolveFromCwd } from './helpers/resolveFromCwd.js';
|
|
5
|
-
|
|
6
|
-
'.env',
|
|
7
|
-
'.env.example',
|
|
8
|
-
'.env.local',
|
|
9
|
-
'.env.production',
|
|
10
|
-
];
|
|
4
|
+
import { DEFAULT_ENV_CANDIDATES } from '../config/constants.js';
|
|
11
5
|
/**
|
|
12
6
|
* Determines which file to use for comparison based on provided options
|
|
13
7
|
* @param {ScanUsageOptions} opts - Scan configuration options
|
|
@@ -28,7 +22,7 @@ export function determineComparisonFile(opts) {
|
|
|
28
22
|
}
|
|
29
23
|
}
|
|
30
24
|
// Auto-discovery: look for common env files relative to cwd
|
|
31
|
-
for (const candidate of
|
|
25
|
+
for (const candidate of DEFAULT_ENV_CANDIDATES) {
|
|
32
26
|
const fullPath = path.resolve(opts.cwd, candidate);
|
|
33
27
|
if (fs.existsSync(fullPath)) {
|
|
34
28
|
return { path: fullPath, name: candidate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"determineComparisonFile.js","sourceRoot":"","sources":["../../../src/core/determineComparisonFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"determineComparisonFile.js","sourceRoot":"","sources":["../../../src/core/determineComparisonFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAOhE;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACrC,IAAsB;IAEtB,sDAAsD;IAEtD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACrD,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;YACrB,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;YACrB,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACxD,CAAC;IACH,CAAC;IAED,4DAA4D;IAC5D,KAAK,MAAM,SAAS,IAAI,sBAAsB,EAAE,CAAC;QAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACnD,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Discovery } from '../
|
|
2
|
-
import type { FilePair } from '../config/types.js';
|
|
1
|
+
import type { FilePair, Discovery } from '../config/types.js';
|
|
3
2
|
/**
|
|
4
3
|
* Pairs each environment file with its corresponding example file.
|
|
5
4
|
* @param d - The discovery object containing environment and example file information.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envPairing.d.ts","sourceRoot":"","sources":["../../../src/core/envPairing.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"envPairing.d.ts","sourceRoot":"","sources":["../../../src/core/envPairing.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG9D;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,CAgC7D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { DEFAULT_ENV_FILE, DEFAULT_EXAMPLE_FILE } from '../config/constants.js';
|
|
3
4
|
/**
|
|
4
5
|
* Pairs each environment file with its corresponding example file.
|
|
5
6
|
* @param d - The discovery object containing environment and example file information.
|
|
@@ -14,8 +15,10 @@ export function pairWithExample(d) {
|
|
|
14
15
|
if (envAbs === path.resolve(d.cwd, d.primaryExample))
|
|
15
16
|
continue;
|
|
16
17
|
}
|
|
17
|
-
const suffix = envName ===
|
|
18
|
-
const exampleName = suffix
|
|
18
|
+
const suffix = envName === DEFAULT_ENV_FILE ? '' : envName.replace(DEFAULT_ENV_FILE, '');
|
|
19
|
+
const exampleName = suffix
|
|
20
|
+
? `${DEFAULT_EXAMPLE_FILE}${suffix}`
|
|
21
|
+
: d.primaryExample;
|
|
19
22
|
const envPathCurrent = path.resolve(d.cwd, envName);
|
|
20
23
|
const examplePathCurrent = d.exampleFlag && !d.envFlag
|
|
21
24
|
? path.resolve(d.cwd, d.primaryExample)
|