From 6ee497c57fdf0fbb1aa3b81f8180cf8ad39c54a1 Mon Sep 17 00:00:00 2001 From: Chrilleweb Date: Sun, 15 Feb 2026 11:22:47 +0100 Subject: [PATCH] chore: scan stas interface --- src/config/types.ts | 70 ++++++++++++++++++++--------------- src/ui/scan/printStats.ts | 17 +-------- src/ui/scan/scanJsonOutput.ts | 9 +---- 3 files changed, 43 insertions(+), 53 deletions(-) diff --git a/src/config/types.ts b/src/config/types.ts index 840d86d..5841678 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -154,6 +154,22 @@ export interface ExampleSecretWarning { severity: 'high' | 'medium' | 'low'; } +/** + * Statistics for codebase scanning + */ +export interface ScanStats { + /** Total number of files scanned during the scan process */ + filesScanned: number; + /** Total number of environment variable references found across all scanned files */ + totalUsages: number; + /** Total number of unique environment variables referenced across all scanned files */ + uniqueVariables: number; + /** Total number of warnings found during the scan process */ + warningsCount: number; + /** Total duration of the scan process in seconds */ + duration: number; +} + /** * Options for scanning the codebase */ @@ -195,13 +211,7 @@ export interface ScanResult { used: EnvUsage[]; missing: string[]; unused: string[]; - stats: { - filesScanned: number; - totalUsages: number; - uniqueVariables: number; - warningsCount: number; - duration: number; - }; + stats: ScanStats; secrets: SecretFinding[]; duplicates: { env?: Duplicate[]; @@ -266,6 +276,29 @@ export interface ComparisonOptions { inconsistentNamingWarnings?: boolean; } +/** + * Resolved comparison file with absolute path and display name. + */ +export interface ComparisonFile { + path: string; + name: string; +} + +/** + * Represents the discovery of environment files in a project. + * Contains information about the current working directory, found environment files, + * and the primary environment and example files. + */ +export interface Discovery { + cwd: string; + envFiles: string[]; + primaryEnv: string; + primaryExample: string; + envFlag: string | null; + exampleFlag: string | null; + alreadyWarnedMissingEnv: boolean; +} + /** * Represents a resolved pair of environment files used for comparison. * @@ -336,26 +369,3 @@ export interface InconsistentNamingWarning { key2: string; suggestion: string; } - -/** - * Represents the discovery of environment files in a project. - * Contains information about the current working directory, found environment files, - * and the primary environment and example files. - */ -export interface Discovery { - cwd: string; - envFiles: string[]; - primaryEnv: string; - primaryExample: string; - envFlag: string | null; - exampleFlag: string | null; - alreadyWarnedMissingEnv: boolean; -} - -/** - * Resolved comparison file with absolute path and display name. - */ -export interface ComparisonFile { - path: string; - name: string; -} diff --git a/src/ui/scan/printStats.ts b/src/ui/scan/printStats.ts index c9ce5f6..be276bd 100644 --- a/src/ui/scan/printStats.ts +++ b/src/ui/scan/printStats.ts @@ -1,20 +1,5 @@ import chalk from 'chalk'; - -/** - * Statistics for codebase scanning - */ -interface ScanStats { - /** Total number of files scanned during the scan process */ - filesScanned: number; - /** Total number of environment variable references found across all scanned files */ - totalUsages: number; - /** Total number of unique environment variables referenced across all scanned files */ - uniqueVariables: number; - /** Total number of warnings found during the scan process */ - warningsCount: number; - /** Total duration of the scan process in seconds */ - duration: number; -} +import type { ScanStats } from '../../config/types.js'; /** * Print scan statistics for codebase scanning. diff --git a/src/ui/scan/scanJsonOutput.ts b/src/ui/scan/scanJsonOutput.ts index 6385fc7..79640bb 100644 --- a/src/ui/scan/scanJsonOutput.ts +++ b/src/ui/scan/scanJsonOutput.ts @@ -1,5 +1,6 @@ import type { ScanResult, + ScanStats, EnvUsage, Duplicate, ExpireWarning, @@ -15,13 +16,7 @@ import { normalizePath } from '../../core/helpers/normalizePath.js'; * JSON structure for scan results output */ interface ScanJsonOutput { - stats?: { - filesScanned: number; - totalUsages: number; - uniqueVariables: number; - warningsCount: number; - duration: number; - }; + stats?: ScanStats; missing?: Array<{ variable: string; usages: Array<{