dotenv-diff 2.4.9 → 2.4.11
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 +22 -0
- package/dist/src/cli/run.js +3 -3
- 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 +28 -31
- package/dist/src/commands/compare.js.map +1 -1
- package/dist/src/commands/ensureFilesOrPrompt.d.ts.map +1 -1
- package/dist/src/commands/ensureFilesOrPrompt.js +9 -5
- package/dist/src/commands/ensureFilesOrPrompt.js.map +1 -1
- package/dist/src/commands/scanUsage.js +3 -3
- package/dist/src/commands/scanUsage.js.map +1 -1
- package/dist/src/config/constants.d.ts +7 -0
- package/dist/src/config/constants.d.ts.map +1 -1
- package/dist/src/config/constants.js +7 -0
- package/dist/src/config/constants.js.map +1 -1
- package/dist/src/config/types.d.ts +15 -6
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/config/types.js +1 -1
- package/dist/src/config/types.js.map +1 -1
- package/dist/src/core/duplicates.d.ts.map +1 -1
- package/dist/src/core/duplicates.js +0 -2
- package/dist/src/core/duplicates.js.map +1 -1
- package/dist/src/core/frameworks/sveltekitRules.d.ts.map +1 -1
- package/dist/src/core/frameworks/sveltekitRules.js +32 -14
- package/dist/src/core/frameworks/sveltekitRules.js.map +1 -1
- package/dist/src/core/parseAndFilterEnv.d.ts +20 -0
- package/dist/src/core/parseAndFilterEnv.d.ts.map +1 -0
- package/dist/src/core/parseAndFilterEnv.js +22 -0
- package/dist/src/core/parseAndFilterEnv.js.map +1 -0
- package/dist/src/core/patterns.d.ts +5 -0
- package/dist/src/core/patterns.d.ts.map +1 -1
- package/dist/src/core/patterns.js +14 -2
- package/dist/src/core/patterns.js.map +1 -1
- package/dist/src/core/scanFile.d.ts.map +1 -1
- package/dist/src/core/scanFile.js +3 -1
- package/dist/src/core/scanFile.js.map +1 -1
- package/dist/src/core/security/exampleSecretDetector.d.ts.map +1 -1
- package/dist/src/core/security/exampleSecretDetector.js +2 -13
- package/dist/src/core/security/exampleSecretDetector.js.map +1 -1
- package/dist/src/services/detectEnvExpirations.d.ts +14 -0
- package/dist/src/services/detectEnvExpirations.d.ts.map +1 -0
- package/dist/src/services/detectEnvExpirations.js +44 -0
- package/dist/src/services/detectEnvExpirations.js.map +1 -0
- package/dist/src/services/envPairing.d.ts +2 -6
- package/dist/src/services/envPairing.d.ts.map +1 -1
- package/dist/src/services/envPairing.js +6 -3
- package/dist/src/services/envPairing.js.map +1 -1
- package/dist/src/services/fileWalker.d.ts.map +1 -1
- package/dist/src/services/fileWalker.js +0 -5
- package/dist/src/services/fileWalker.js.map +1 -1
- package/dist/src/services/git.d.ts +5 -7
- package/dist/src/services/git.d.ts.map +1 -1
- package/dist/src/services/git.js +16 -17
- package/dist/src/services/git.js.map +1 -1
- package/dist/src/services/processComparisonFile.d.ts +43 -0
- package/dist/src/services/processComparisonFile.d.ts.map +1 -0
- package/dist/src/services/processComparisonFile.js +170 -0
- package/dist/src/services/processComparisonFile.js.map +1 -0
- package/dist/src/services/scanCodebase.d.ts.map +1 -1
- package/dist/src/services/scanCodebase.js +3 -2
- package/dist/src/services/scanCodebase.js.map +1 -1
- package/dist/src/ui/compare/compareJsonOutput.d.ts +23 -0
- package/dist/src/ui/compare/compareJsonOutput.d.ts.map +1 -0
- package/dist/src/ui/compare/compareJsonOutput.js +45 -0
- package/dist/src/ui/compare/compareJsonOutput.js.map +1 -0
- package/dist/src/ui/compare/printErrorNotFound.d.ts.map +1 -1
- package/dist/src/ui/compare/printErrorNotFound.js +3 -0
- package/dist/src/ui/compare/printErrorNotFound.js.map +1 -1
- package/dist/src/ui/compare/printHeader.d.ts +1 -1
- package/dist/src/ui/compare/printHeader.d.ts.map +1 -1
- package/dist/src/ui/compare/printHeader.js +1 -4
- package/dist/src/ui/compare/printHeader.js.map +1 -1
- package/dist/src/ui/scan/printStats.d.ts.map +1 -1
- package/dist/src/ui/scan/printStats.js +1 -1
- package/dist/src/ui/scan/printStats.js.map +1 -1
- package/dist/src/ui/scan/scanJsonOutput.d.ts +85 -0
- package/dist/src/ui/scan/scanJsonOutput.d.ts.map +1 -0
- package/dist/src/ui/scan/scanJsonOutput.js +97 -0
- package/dist/src/ui/scan/scanJsonOutput.js.map +1 -0
- package/dist/src/ui/shared/printGitignore.d.ts +4 -3
- package/dist/src/ui/shared/printGitignore.d.ts.map +1 -1
- package/dist/src/ui/shared/printGitignore.js +2 -1
- package/dist/src/ui/shared/printGitignore.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { parseEnvFile } from '../core/parseEnv.js';
|
|
3
|
+
import { filterIgnoredKeys } from '../core/filterIgnoredKeys.js';
|
|
4
|
+
import { compareWithEnvFiles } from '../core/compareScan.js';
|
|
5
|
+
import { findDuplicateKeys } from '../core/duplicates.js';
|
|
6
|
+
import { applyFixes } from '../core/fixEnv.js';
|
|
7
|
+
import { toUpperSnakeCase } from '../core/helpers/toUpperSnakeCase.js';
|
|
8
|
+
import { resolveFromCwd } from '../core/helpers/resolveFromCwd.js';
|
|
9
|
+
import { detectEnvExpirations } from './detectEnvExpirations.js';
|
|
10
|
+
import { detectInconsistentNaming } from '../core/detectInconsistentNaming.js';
|
|
11
|
+
/**
|
|
12
|
+
* Process comparison file: parse env, check duplicates, check missing keys, apply fixes
|
|
13
|
+
* @param scanResult - Current scan result
|
|
14
|
+
* @param compareFile - File to compare against
|
|
15
|
+
* @param opts - Scan options
|
|
16
|
+
* @returns Processed comparison result
|
|
17
|
+
*/
|
|
18
|
+
export function processComparisonFile(scanResult, compareFile, opts) {
|
|
19
|
+
let envVariables = {};
|
|
20
|
+
let comparedAgainst = '';
|
|
21
|
+
let duplicatesFound = false;
|
|
22
|
+
let dupsEnv = [];
|
|
23
|
+
let dupsEx = [];
|
|
24
|
+
let fixApplied = false;
|
|
25
|
+
let removedDuplicates = [];
|
|
26
|
+
let addedEnv = [];
|
|
27
|
+
let addedExample = [];
|
|
28
|
+
let gitignoreUpdated = false;
|
|
29
|
+
let exampleFull = undefined;
|
|
30
|
+
let uppercaseWarnings = [];
|
|
31
|
+
let expireWarnings = [];
|
|
32
|
+
let inconsistentNamingWarnings = [];
|
|
33
|
+
try {
|
|
34
|
+
// Load .env.example (if exists)
|
|
35
|
+
if (opts.examplePath) {
|
|
36
|
+
const examplePath = resolveFromCwd(opts.cwd, opts.examplePath);
|
|
37
|
+
if (fs.existsSync(examplePath)) {
|
|
38
|
+
exampleFull = parseEnvFile(examplePath);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Parse and filter env file
|
|
42
|
+
const envFull = parseEnvFile(compareFile.path);
|
|
43
|
+
const envKeys = filterIgnoredKeys(Object.keys(envFull), opts.ignore, opts.ignoreRegex);
|
|
44
|
+
envVariables = Object.fromEntries(envKeys.map((k) => [k, envFull[k]]));
|
|
45
|
+
scanResult = compareWithEnvFiles(scanResult, envVariables);
|
|
46
|
+
comparedAgainst = compareFile.name;
|
|
47
|
+
// Detect uppercase keys
|
|
48
|
+
if (opts.uppercaseKeys) {
|
|
49
|
+
for (const key of envKeys) {
|
|
50
|
+
if (!/^[A-Z0-9_]+$/.test(key)) {
|
|
51
|
+
uppercaseWarnings.push({ key, suggestion: toUpperSnakeCase(key) });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Find duplicates
|
|
56
|
+
if (!opts.allowDuplicates) {
|
|
57
|
+
const duplicateResults = checkDuplicates(compareFile, opts);
|
|
58
|
+
dupsEnv = duplicateResults.dupsEnv;
|
|
59
|
+
dupsEx = duplicateResults.dupsEx;
|
|
60
|
+
duplicatesFound = dupsEnv.length > 0 || dupsEx.length > 0;
|
|
61
|
+
}
|
|
62
|
+
if (opts.expireWarnings) {
|
|
63
|
+
expireWarnings = detectEnvExpirations(compareFile.path);
|
|
64
|
+
}
|
|
65
|
+
// Check for inconsistent naming across env + example keys
|
|
66
|
+
if (opts.inconsistentNamingWarnings) {
|
|
67
|
+
const envKeysList = Object.keys(envFull);
|
|
68
|
+
const exampleKeysList = exampleFull ? Object.keys(exampleFull) : [];
|
|
69
|
+
// Combine all keys for naming analysis
|
|
70
|
+
const allKeys = [...envKeysList, ...exampleKeysList];
|
|
71
|
+
inconsistentNamingWarnings = detectInconsistentNaming(allKeys);
|
|
72
|
+
}
|
|
73
|
+
// Apply fixes (both duplicates + missing keys + gitignore)
|
|
74
|
+
if (opts.fix &&
|
|
75
|
+
(duplicatesFound || scanResult.missing.length > 0 || true)) {
|
|
76
|
+
const { changed, result } = applyFixes({
|
|
77
|
+
envPath: compareFile.path,
|
|
78
|
+
examplePath: opts.examplePath
|
|
79
|
+
? resolveFromCwd(opts.cwd, opts.examplePath)
|
|
80
|
+
: '',
|
|
81
|
+
missingKeys: scanResult.missing,
|
|
82
|
+
duplicateKeys: dupsEnv.map((d) => d.key),
|
|
83
|
+
ensureGitignore: true,
|
|
84
|
+
});
|
|
85
|
+
if (changed) {
|
|
86
|
+
fixApplied = true;
|
|
87
|
+
removedDuplicates = result.removedDuplicates;
|
|
88
|
+
addedEnv = result.addedEnv;
|
|
89
|
+
addedExample = result.addedExample;
|
|
90
|
+
gitignoreUpdated = result.gitignoreUpdated;
|
|
91
|
+
scanResult.missing = [];
|
|
92
|
+
dupsEnv = [];
|
|
93
|
+
dupsEx = [];
|
|
94
|
+
duplicatesFound = false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Keep duplicates for output if not fixed
|
|
98
|
+
if (duplicatesFound && (!opts.fix || !fixApplied)) {
|
|
99
|
+
if (!scanResult.duplicates)
|
|
100
|
+
scanResult.duplicates = {};
|
|
101
|
+
if (dupsEnv.length > 0)
|
|
102
|
+
scanResult.duplicates.env = dupsEnv;
|
|
103
|
+
if (dupsEx.length > 0)
|
|
104
|
+
scanResult.duplicates.example = dupsEx;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const errorMessage = `Could not read ${compareFile.name}: ${compareFile.path} - ${error}`;
|
|
109
|
+
return {
|
|
110
|
+
scanResult,
|
|
111
|
+
envVariables,
|
|
112
|
+
comparedAgainst,
|
|
113
|
+
duplicatesFound,
|
|
114
|
+
dupsEnv,
|
|
115
|
+
dupsEx,
|
|
116
|
+
fixApplied,
|
|
117
|
+
removedDuplicates,
|
|
118
|
+
addedEnv,
|
|
119
|
+
addedExample,
|
|
120
|
+
gitignoreUpdated,
|
|
121
|
+
exampleFull,
|
|
122
|
+
uppercaseWarnings,
|
|
123
|
+
expireWarnings,
|
|
124
|
+
inconsistentNamingWarnings,
|
|
125
|
+
error: {
|
|
126
|
+
message: errorMessage,
|
|
127
|
+
shouldExit: opts.isCiMode ?? false,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
scanResult,
|
|
133
|
+
envVariables,
|
|
134
|
+
comparedAgainst,
|
|
135
|
+
duplicatesFound,
|
|
136
|
+
dupsEnv,
|
|
137
|
+
dupsEx,
|
|
138
|
+
fixApplied,
|
|
139
|
+
removedDuplicates,
|
|
140
|
+
addedEnv,
|
|
141
|
+
addedExample,
|
|
142
|
+
gitignoreUpdated,
|
|
143
|
+
exampleFull,
|
|
144
|
+
uppercaseWarnings,
|
|
145
|
+
expireWarnings,
|
|
146
|
+
inconsistentNamingWarnings,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Check for duplicate keys in env and example files
|
|
151
|
+
* @param compareFile - The file to compare against
|
|
152
|
+
* @param opts - Scan options
|
|
153
|
+
* @returns Object containing duplicate keys in env and example files
|
|
154
|
+
*/
|
|
155
|
+
function checkDuplicates(compareFile, opts) {
|
|
156
|
+
const isIgnored = (key) => !opts.ignore.includes(key) && !opts.ignoreRegex.some((rx) => rx.test(key));
|
|
157
|
+
// Duplicates in main env file
|
|
158
|
+
const dupsEnv = findDuplicateKeys(compareFile.path).filter(({ key }) => isIgnored(key));
|
|
159
|
+
// Duplicates in example file
|
|
160
|
+
let dupsEx = [];
|
|
161
|
+
if (opts.examplePath) {
|
|
162
|
+
const examplePath = resolveFromCwd(opts.cwd, opts.examplePath);
|
|
163
|
+
const exampleIsDifferentFile = fs.existsSync(examplePath) && examplePath !== compareFile.path;
|
|
164
|
+
if (exampleIsDifferentFile) {
|
|
165
|
+
dupsEx = findDuplicateKeys(examplePath).filter(({ key }) => isIgnored(key));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return { dupsEnv, dupsEx };
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=processComparisonFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processComparisonFile.js","sourceRoot":"","sources":["../../../src/services/processComparisonFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAgC/E;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,UAAsB,EACtB,WAA2C,EAC3C,IAAsB;IAEtB,IAAI,YAAY,GAAuC,EAAE,CAAC;IAC1D,IAAI,eAAe,GAAG,EAAE,CAAC;IACzB,IAAI,eAAe,G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E7B,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,MAAM,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAE/D,MAAM,sBAAsB,GAC1B,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,WAAW,KAAK,WAAW,CAAC,IAAI,CAAC;QAEjE,IAAI,sBAAsB,EAAE,CAAC;YAC3B,MAAM,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CACzD,SAAS,CAAC,GAAG,CAAC,CACf,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAA4B,CAAC;AACvD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanCodebase.d.ts","sourceRoot":"","sources":["../../../src/services/scanCodebase.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAY,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"scanCodebase.d.ts","sourceRoot":"","sources":["../../../src/services/scanCodebase.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAY,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAW5E;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAsEzE"}
|
|
@@ -5,6 +5,7 @@ import { DEFAULT_EXCLUDE_PATTERNS } from '../core/patterns.js';
|
|
|
5
5
|
import { scanFile } from '../core/scanFile.js';
|
|
6
6
|
import { findFiles } from './fileWalker.js';
|
|
7
7
|
import { printProgress } from '../ui/scan/printProgress.js';
|
|
8
|
+
import { normalizePath } from '../core/helpers/normalizePath.js';
|
|
8
9
|
/**
|
|
9
10
|
* Scans the codebase for environment variable usage based on the provided options.
|
|
10
11
|
* @param opts - Options for scanning the codebase.
|
|
@@ -14,7 +15,7 @@ export async function scanCodebase(opts) {
|
|
|
14
15
|
const files = await findFiles(opts.cwd, {
|
|
15
16
|
include: opts.include,
|
|
16
17
|
exclude: [...DEFAULT_EXCLUDE_PATTERNS, ...opts.exclude],
|
|
17
|
-
...(opts.files
|
|
18
|
+
...(opts.files && opts.files.length > 0 && { files: opts.files }),
|
|
18
19
|
});
|
|
19
20
|
const allUsages = [];
|
|
20
21
|
let filesScanned = 0;
|
|
@@ -28,7 +29,7 @@ export async function scanCodebase(opts) {
|
|
|
28
29
|
const fileUsages = scanFile(filePath, content, opts);
|
|
29
30
|
allUsages.push(...fileUsages);
|
|
30
31
|
// Store file content for later use (e.g., framework validation 'use client')
|
|
31
|
-
const relativePath = path.relative(opts.cwd, filePath);
|
|
32
|
+
const relativePath = normalizePath(path.relative(opts.cwd, filePath));
|
|
32
33
|
fileContentMap.set(relativePath, content);
|
|
33
34
|
// Detect secrets in the file content
|
|
34
35
|
const secrets = safeDetectSecrets(relativePath, content, opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanCodebase.js","sourceRoot":"","sources":["../../../src/services/scanCodebase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,qBAAqB,GAEtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"scanCodebase.js","sourceRoot":"","sources":["../../../src/services/scanCodebase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,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ry for the given comparison results.
|
|
4
|
+
* @param params - The parameters for building the entry.
|
|
5
|
+
* @returns A CompareJsonEntry object.
|
|
6
|
+
*/
|
|
7
|
+
export declare function compareJsonOutput({ envName, exampleName, dupsEnv, dupsEx, gitignoreIssue, ok, filtered, stats, }: {
|
|
8
|
+
envName: string;
|
|
9
|
+
exampleName: string;
|
|
10
|
+
dupsEnv: Duplicate[];
|
|
11
|
+
dupsEx: Duplicate[];
|
|
12
|
+
gitignoreIssue: {
|
|
13
|
+
reason: GitignoreIssue;
|
|
14
|
+
} | null;
|
|
15
|
+
ok?: boolean;
|
|
16
|
+
filtered?: Filtered;
|
|
17
|
+
stats?: {
|
|
18
|
+
envCount: number;
|
|
19
|
+
exampleCount: number;
|
|
20
|
+
sharedCount: number;
|
|
21
|
+
};
|
|
22
|
+
}): CompareJsonEntry;
|
|
23
|
+
//# sourceMappingURL=compareJsonOutput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareJsonOutput.d.ts","sourceRoot":"","sources":["../../../../src/ui/compare/compareJsonOutput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,cAAc,EACf,MAAM,uBAAuB,CAAC;AAE/B;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,WAAW,EACX,OAAO,EACP,MAAM,EACN,cAAc,EACd,EAAE,EACF,QAAQ,EACR,KAAK,GACN,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,cAAc,EAAE;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI,CAAC;IAClD,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,GAAG,gBAAgB,CA0CnB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds a CompareJsonEntry for the given comparison results.
|
|
3
|
+
* @param params - The parameters for building the entry.
|
|
4
|
+
* @returns A CompareJsonEntry object.
|
|
5
|
+
*/
|
|
6
|
+
export function compareJsonOutput({ envName, exampleName, dupsEnv, dupsEx, gitignoreIssue, ok, filtered, stats, }) {
|
|
7
|
+
const entry = {
|
|
8
|
+
env: envName,
|
|
9
|
+
example: exampleName,
|
|
10
|
+
};
|
|
11
|
+
// Add stats if provided
|
|
12
|
+
if (stats) {
|
|
13
|
+
entry.stats = stats;
|
|
14
|
+
}
|
|
15
|
+
// Add filtered data if provided
|
|
16
|
+
if (filtered) {
|
|
17
|
+
if (filtered.missing.length > 0) {
|
|
18
|
+
entry.missing = filtered.missing;
|
|
19
|
+
}
|
|
20
|
+
if (filtered.extra && filtered.extra.length > 0) {
|
|
21
|
+
entry.extra = filtered.extra;
|
|
22
|
+
}
|
|
23
|
+
if (filtered.empty && filtered.empty.length > 0) {
|
|
24
|
+
entry.empty = filtered.empty;
|
|
25
|
+
}
|
|
26
|
+
if (filtered.mismatches && filtered.mismatches.length > 0) {
|
|
27
|
+
entry.valueMismatches = filtered.mismatches;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (dupsEnv.length || dupsEx.length) {
|
|
31
|
+
entry.duplicates = {};
|
|
32
|
+
if (dupsEnv.length)
|
|
33
|
+
entry.duplicates.env = dupsEnv;
|
|
34
|
+
if (dupsEx.length)
|
|
35
|
+
entry.duplicates.example = dupsEx;
|
|
36
|
+
}
|
|
37
|
+
if (gitignoreIssue) {
|
|
38
|
+
entry.gitignoreIssue = gitignoreIssue;
|
|
39
|
+
}
|
|
40
|
+
if (ok) {
|
|
41
|
+
entry.ok = ok;
|
|
42
|
+
}
|
|
43
|
+
return entry;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=compareJsonOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareJsonOutput.js","sourceRoot":"","sources":["../../../../src/ui/compare/compareJsonOutput.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,OAAO,EACP,WAAW,EACX,OAAO,EACP,MAAM,EACN,cAAc,EACd,EAAE,EACF,QAAQ,EACR,KAAK,GAcN;IACC,MAAM,KAAK,GAAqB;QAC9B,GAAG,EAAE,OAAO;QACZ,OAAO,EAAE,WAAW;KACrB,CAAC;IAEF,wBAAwB;IACxB,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,gCAAgC;IAChC,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,KAAK,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QACnC,CAAC;QACD,IAAI,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChD,KAAK,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;QAC/B,CAAC;QACD,IAAI,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChD,KAAK,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;QAC/B,CAAC;QACD,IAAI,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1D,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC,UAAU,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACpC,KAAK,CAAC,UAAU,GAAG,EAAE,CAAC;QACtB,IAAI,OAAO,CAAC,MAAM;YAAE,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC;QACnD,IAAI,MAAM,CAAC,MAAM;YAAE,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC;IACvD,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;IACxC,CAAC;IAED,IAAI,EAAE,EAAE,CAAC;QACP,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printErrorNotFound.d.ts","sourceRoot":"","sources":["../../../../src/ui/compare/printErrorNotFound.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,IAAI,
|
|
1
|
+
{"version":3,"file":"printErrorNotFound.d.ts","sourceRoot":"","sources":["../../../../src/ui/compare/printErrorNotFound.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,IAAI,CAoBN"}
|
|
@@ -14,5 +14,8 @@ export function printErrorNotFound(envExists, exExists, envFlag, exampleFlag) {
|
|
|
14
14
|
if (!exExists) {
|
|
15
15
|
console.error(chalk.red(`❌ Error: --example file not found: ${path.basename(exampleFlag)}`));
|
|
16
16
|
}
|
|
17
|
+
if (!envExists || !exExists) {
|
|
18
|
+
console.error(chalk.red('Please ensure both files exist before running the comparison.'));
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
//# sourceMappingURL=printErrorNotFound.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printErrorNotFound.js","sourceRoot":"","sources":["../../../../src/ui/compare/printErrorNotFound.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAAkB,EAClB,QAAiB,EACjB,OAAe,EACf,WAAmB;IAEnB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAAC,kCAAkC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CACtE,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CACP,sCAAsC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CACnE,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"printErrorNotFound.js","sourceRoot":"","sources":["../../../../src/ui/compare/printErrorNotFound.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAAkB,EAClB,QAAiB,EACjB,OAAe,EACf,WAAmB;IAEnB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAAC,kCAAkC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CACtE,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CACP,sCAAsC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CACnE,CACF,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,SAAS,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC5B,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CACP,+DAA+D,CAChE,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* @param skipping Whether the comparison is being skipped.
|
|
7
7
|
* @returns void
|
|
8
8
|
*/
|
|
9
|
-
export declare function printHeader(envName: string, exampleName: string, json: boolean
|
|
9
|
+
export declare function printHeader(envName: string, exampleName: string, json: boolean): void;
|
|
10
10
|
//# sourceMappingURL=printHeader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printHeader.d.ts","sourceRoot":"","sources":["../../../../src/ui/compare/printHeader.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"printHeader.d.ts","sourceRoot":"","sources":["../../../../src/ui/compare/printHeader.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,OAAO,GACZ,IAAI,CAKN"}
|
|
@@ -7,14 +7,11 @@ import chalk from 'chalk';
|
|
|
7
7
|
* @param skipping Whether the comparison is being skipped.
|
|
8
8
|
* @returns void
|
|
9
9
|
*/
|
|
10
|
-
export function printHeader(envName, exampleName, json
|
|
10
|
+
export function printHeader(envName, exampleName, json) {
|
|
11
11
|
if (json)
|
|
12
12
|
return;
|
|
13
13
|
console.log();
|
|
14
14
|
console.log(chalk.blue(`🔍 Comparing ${envName} ↔ ${exampleName}...`));
|
|
15
|
-
if (skipping) {
|
|
16
|
-
console.log(chalk.yellow('⚠️ Skipping: missing matching example file.'));
|
|
17
|
-
}
|
|
18
15
|
console.log();
|
|
19
16
|
}
|
|
20
17
|
//# sourceMappingURL=printHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printHeader.js","sourceRoot":"","sources":["../../../../src/ui/compare/printHeader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,OAAe,EACf,WAAmB,EACnB,IAAa
|
|
1
|
+
{"version":3,"file":"printHeader.js","sourceRoot":"","sources":["../../../../src/ui/compare/printHeader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,OAAe,EACf,WAAmB,EACnB,IAAa;IAEb,IAAI,IAAI;QAAE,OAAO;IACjB,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,OAAO,MAAM,WAAW,KAAK,CAAC,CAAC,CAAC;IACvE,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printStats.d.ts","sourceRoot":"","sources":["../../../../src/ui/scan/printStats.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,OAAO,GACjB,IAAI,
|
|
1
|
+
{"version":3,"file":"printStats.d.ts","sourceRoot":"","sources":["../../../../src/ui/scan/printStats.ts"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,OAAO,GACjB,IAAI,CAgBN"}
|
|
@@ -11,7 +11,7 @@ export function printStats(stats, json, showStats) {
|
|
|
11
11
|
console.log();
|
|
12
12
|
console.log(chalk.magenta('📊 Scan Statistics:'));
|
|
13
13
|
console.log(chalk.magenta.dim(` Files scanned: ${stats.filesScanned}`));
|
|
14
|
-
console.log(chalk.magenta.dim(` Total
|
|
14
|
+
console.log(chalk.magenta.dim(` Total variable references: ${stats.totalUsages}`));
|
|
15
15
|
console.log(chalk.magenta.dim(` Unique variables: ${stats.uniqueVariables}`));
|
|
16
16
|
console.log(chalk.magenta.dim(` Warnings: ${stats.warningsCount}`));
|
|
17
17
|
console.log(chalk.magenta.dim(` Scan duration: ${stats.duration.toFixed(2)}s`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printStats.js","sourceRoot":"","sources":["../../../../src/ui/scan/printStats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,KAAgB,EAChB,IAAa,EACb,SAAkB;IAElB,IAAI,IAAI,IAAI,CAAC,SAAS;QAAE,OAAO;IAC/B,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IAC1E,OAAO,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"printStats.js","sourceRoot":"","sources":["../../../../src/ui/scan/printStats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,KAAgB,EAChB,IAAa,EACb,SAAkB;IAElB,IAAI,IAAI,IAAI,CAAC,SAAS;QAAE,OAAO;IAC/B,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IAC1E,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,iCAAiC,KAAK,CAAC,WAAW,EAAE,CAAC,CACxE,CAAC;IACF,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,CAAC,eAAe,EAAE,CAAC,CACnE,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CACrE,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ScanResult, Duplicate, SupportedFramework } from '../../config/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* JSON structure for scan results output
|
|
4
|
+
*/
|
|
5
|
+
interface ScanJsonOutput {
|
|
6
|
+
stats?: {
|
|
7
|
+
filesScanned: number;
|
|
8
|
+
totalUsages: number;
|
|
9
|
+
uniqueVariables: number;
|
|
10
|
+
warningsCount: number;
|
|
11
|
+
duration: number;
|
|
12
|
+
};
|
|
13
|
+
missing?: Array<{
|
|
14
|
+
variable: string;
|
|
15
|
+
usages: Array<{
|
|
16
|
+
file: string;
|
|
17
|
+
line: number;
|
|
18
|
+
pattern: string;
|
|
19
|
+
context: string;
|
|
20
|
+
}>;
|
|
21
|
+
}>;
|
|
22
|
+
unused?: string[];
|
|
23
|
+
allUsages?: Array<{
|
|
24
|
+
variable: string;
|
|
25
|
+
file: string;
|
|
26
|
+
line: number;
|
|
27
|
+
pattern: string;
|
|
28
|
+
context: string;
|
|
29
|
+
}>;
|
|
30
|
+
comparedAgainst?: string;
|
|
31
|
+
totalEnvVariables?: number;
|
|
32
|
+
secrets?: Array<{
|
|
33
|
+
file: string;
|
|
34
|
+
line: number;
|
|
35
|
+
message: string;
|
|
36
|
+
snippet: string;
|
|
37
|
+
}>;
|
|
38
|
+
duplicates?: {
|
|
39
|
+
env?: Duplicate[];
|
|
40
|
+
example?: Duplicate[];
|
|
41
|
+
};
|
|
42
|
+
logged?: Array<{
|
|
43
|
+
variable: string;
|
|
44
|
+
file: string;
|
|
45
|
+
line: number;
|
|
46
|
+
context: string;
|
|
47
|
+
}>;
|
|
48
|
+
expireWarnings?: Array<{
|
|
49
|
+
key: string;
|
|
50
|
+
date: string;
|
|
51
|
+
daysLeft: number;
|
|
52
|
+
}>;
|
|
53
|
+
uppercaseWarnings?: Array<{
|
|
54
|
+
key: string;
|
|
55
|
+
suggestion: string;
|
|
56
|
+
}>;
|
|
57
|
+
inconsistentNamingWarnings?: Array<{
|
|
58
|
+
key1: string;
|
|
59
|
+
key2: string;
|
|
60
|
+
suggestion: string;
|
|
61
|
+
}>;
|
|
62
|
+
frameworkWarnings?: Array<{
|
|
63
|
+
variable: string;
|
|
64
|
+
reason: string;
|
|
65
|
+
file: string;
|
|
66
|
+
line: number;
|
|
67
|
+
framework: SupportedFramework;
|
|
68
|
+
}>;
|
|
69
|
+
exampleWarnings?: Array<{
|
|
70
|
+
key: string;
|
|
71
|
+
value: string;
|
|
72
|
+
reason: string;
|
|
73
|
+
severity: string;
|
|
74
|
+
}>;
|
|
75
|
+
healthScore?: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Creates a JSON output for the scan results.
|
|
79
|
+
* @param scanResult - The result of the scan.
|
|
80
|
+
* @param comparedAgainst - The file being compared against.
|
|
81
|
+
* @returns The JSON output.
|
|
82
|
+
*/
|
|
83
|
+
export declare function scanJsonOutput(scanResult: ScanResult, comparedAgainst: string): ScanJsonOutput;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=scanJsonOutput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanJsonOutput.d.ts","sourceRoot":"","sources":["../../../../src/ui/scan/scanJsonOutput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAEV,SAAS,EACT,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAI/B;;GAEG;AACH,UAAU,cAAc;IACtB,KAAK,CAAC,EAAE;QACN,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,OAAO,CAAC,EAAE,KAAK,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,KAAK,CAAC;YACZ,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;YAChB,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC,CAAC;KACJ,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IA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AC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,kBAAkB,CAAC;KAC/B,CAAC,CAAC;IACH,eAAe,CAAC,EAAE,KAAK,CAAC;QACtB,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,MAAM,GACtB,cAAc,CAwGhB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { computeHealthScore } from '../../core/computeHealthScore.js';
|
|
2
|
+
import { normalizePath } from '../../core/helpers/normalizePath.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a JSON output for the scan results.
|
|
5
|
+
* @param scanResult - The result of the scan.
|
|
6
|
+
* @param comparedAgainst - The file being compared against.
|
|
7
|
+
* @returns The JSON output.
|
|
8
|
+
*/
|
|
9
|
+
export function scanJsonOutput(scanResult, comparedAgainst) {
|
|
10
|
+
const output = {};
|
|
11
|
+
// Add comparison info if we compared against a file
|
|
12
|
+
if (comparedAgainst) {
|
|
13
|
+
output.comparedAgainst = comparedAgainst;
|
|
14
|
+
}
|
|
15
|
+
output.stats = scanResult.stats;
|
|
16
|
+
if (scanResult.secrets?.length) {
|
|
17
|
+
output.secrets = scanResult.secrets.map((s) => ({
|
|
18
|
+
file: normalizePath(s.file),
|
|
19
|
+
line: s.line,
|
|
20
|
+
message: s.message,
|
|
21
|
+
snippet: s.snippet,
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
if (scanResult.missing?.length) {
|
|
25
|
+
const missingSet = new Set(scanResult.missing);
|
|
26
|
+
const usagesByVariable = new Map();
|
|
27
|
+
for (const usage of scanResult.used) {
|
|
28
|
+
if (missingSet.has(usage.variable)) {
|
|
29
|
+
const existing = usagesByVariable.get(usage.variable) ?? [];
|
|
30
|
+
existing.push(usage);
|
|
31
|
+
usagesByVariable.set(usage.variable, existing);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
output.missing = scanResult.missing.map((variable) => ({
|
|
35
|
+
variable,
|
|
36
|
+
usages: (usagesByVariable.get(variable) ?? []).map((u) => ({
|
|
37
|
+
file: normalizePath(u.file),
|
|
38
|
+
line: u.line,
|
|
39
|
+
pattern: u.pattern,
|
|
40
|
+
context: u.context,
|
|
41
|
+
})),
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
if (scanResult.unused?.length) {
|
|
45
|
+
output.unused = scanResult.unused;
|
|
46
|
+
}
|
|
47
|
+
if (scanResult.uppercaseWarnings?.length) {
|
|
48
|
+
output.uppercaseWarnings = scanResult.uppercaseWarnings.map((w) => ({
|
|
49
|
+
key: w.key,
|
|
50
|
+
suggestion: w.suggestion,
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
if (scanResult.inconsistentNamingWarnings?.length) {
|
|
54
|
+
output.inconsistentNamingWarnings =
|
|
55
|
+
scanResult.inconsistentNamingWarnings.map((w) => ({
|
|
56
|
+
key1: w.key1,
|
|
57
|
+
key2: w.key2,
|
|
58
|
+
suggestion: w.suggestion,
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
if (scanResult.frameworkWarnings?.length) {
|
|
62
|
+
output.frameworkWarnings = scanResult.frameworkWarnings.map((w) => ({
|
|
63
|
+
variable: w.variable,
|
|
64
|
+
reason: w.reason,
|
|
65
|
+
file: normalizePath(w.file),
|
|
66
|
+
line: w.line,
|
|
67
|
+
framework: w.framework,
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
const hasDuplicates = (scanResult.duplicates.env?.length ?? 0) > 0 ||
|
|
71
|
+
(scanResult.duplicates.example?.length ?? 0) > 0;
|
|
72
|
+
if (hasDuplicates) {
|
|
73
|
+
output.duplicates = scanResult.duplicates;
|
|
74
|
+
}
|
|
75
|
+
// Add logged variables if any
|
|
76
|
+
if (scanResult.logged?.length) {
|
|
77
|
+
output.logged = scanResult.logged.map((l) => ({
|
|
78
|
+
variable: l.variable,
|
|
79
|
+
file: normalizePath(l.file),
|
|
80
|
+
line: l.line,
|
|
81
|
+
context: l.context,
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
// Example warnings
|
|
85
|
+
if (scanResult.exampleWarnings?.length) {
|
|
86
|
+
output.exampleWarnings = scanResult.exampleWarnings.map((w) => ({
|
|
87
|
+
key: w.key,
|
|
88
|
+
value: w.value,
|
|
89
|
+
reason: w.reason,
|
|
90
|
+
severity: w.severity,
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
const healthScore = computeHealthScore(scanResult);
|
|
94
|
+
output.healthScore = healthScore;
|
|
95
|
+
return output;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=scanJsonOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanJsonOutput.js","sourceRoot":"","sources":["../../../../src/ui/scan/scanJsonOutput.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AA8EpE;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAsB,EACtB,eAAuB;IAEvB,MAAM,MAAM,GAAmB,EAAE,CAAC;IAElC,oDAAoD;IACpD,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAEhC,IAAI,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QAC/B,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE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(msg: string) => void;
|
|
5
|
-
}
|
|
6
|
+
}
|
|
6
7
|
/**
|
|
7
8
|
* Logs a warning about .env not being ignored by Git.
|
|
8
9
|
* @param options - Options for the gitignore warning.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printGitignore.d.ts","sourceRoot":"","sources":["../../../../src/ui/shared/printGitignore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"printGitignore.d.ts","sourceRoot":"","sources":["../../../../src/ui/shared/printGitignore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,UAAU,uBAAuB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAoB5E"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
+
import { GITIGNORE_ISSUES } from '../../config/constants.js';
|
|
2
3
|
/**
|
|
3
4
|
* Logs a warning about .env not being ignored by Git.
|
|
4
5
|
* @param options - Options for the gitignore warning.
|
|
@@ -6,7 +7,7 @@ import chalk from 'chalk';
|
|
|
6
7
|
*/
|
|
7
8
|
export function printGitignoreWarning(options) {
|
|
8
9
|
const { envFile, reason, log = console.log } = options;
|
|
9
|
-
if (reason ===
|
|
10
|
+
if (reason === GITIGNORE_ISSUES.NO_GITIGNORE) {
|
|
10
11
|
log(chalk.yellow(`⚠️ No .gitignore found – your ${envFile} may be committed.\n` +
|
|
11
12
|
` Add:\n` +
|
|
12
13
|
` ${envFile}\n`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printGitignore.js","sourceRoot":"","sources":["../../../../src/ui/shared/printGitignore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"printGitignore.js","sourceRoot":"","sources":["../../../../src/ui/shared/printGitignore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAQ7D;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAgC;IACpE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;IAEvD,IAAI,MAAM,KAAK,gBAAgB,CAAC,YAAY,EAAE,CAAC;QAC7C,GAAG,CACD,KAAK,CAAC,MAAM,CACV,kCAAkC,OAAO,sBAAsB;YAC7D,WAAW;YACX,QAAQ,OAAO,IAAI,CACtB,CACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,GAAG,CACD,KAAK,CAAC,MAAM,CACV,OAAO,OAAO,wCAAwC;YACpD,uBAAuB;YACvB,QAAQ,OAAO,IAAI,CACtB,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|