Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { DEFAULT_ENV_FILE } from '../config/constants.js';
* handleMissingFiles result
*/
interface ExitDecision extends ExitResult {
/** Indicates if the process should exit */
shouldExit: boolean;
}

Expand Down
9 changes: 9 additions & 0 deletions src/commands/prompts/promptEnsureFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,29 @@ import { DEFAULT_ENV_FILE } from '../../config/constants.js';
* Result of ensureFilesOrPrompt function
*/
interface EnsureFilesResult {
/** Indicates if a file was created */
didCreate: boolean;
/** Indicates if the process should exit */
shouldExit: boolean;
/** Exit code to use if the process should exit */
exitCode: number;
}

/**
* Arguments for ensureFilesOrPrompt function
*/
interface EnsureFilesArgs {
/** Current working directory */
cwd: string;
/** Path to the primary .env file */
primaryEnv: string;
/** Path to the primary .env.example file */
primaryExample: string;
/** Indicates if the user has already been warned about a missing .env file */
alreadyWarnedMissingEnv: boolean;
/** Indicates if the --yes flag is set */
isYesMode: boolean;
/** Indicates if the --ci flag is set */
isCiMode: boolean;
}
/**
Expand Down
38 changes: 33 additions & 5 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ export type DetectedFramework = SupportedFramework | 'unknown';
* From rules defined for each supported framework (SvelteKit, Next.js)
*/
export interface FrameworkWarning {
/** The environment variable causing the warning */
variable: string;
/** The reason for the warning */
reason: string;
/** The file where the warning was detected */
file: string;
/** The line number where the warning was detected */
line: number;
/** The framework in which the warning was detected */
framework: SupportedFramework;
}

Expand All @@ -32,7 +37,9 @@ export type Duplicate = { key: string; count: number };
* Type representing the result of duplicate detection
*/
export interface DuplicateResult {
/** Number of duplicate keys in the .env file */
dupsEnv: Duplicate[];
/** Number of duplicate keys in the .env.example file */
dupsEx: Duplicate[];
}

Expand Down Expand Up @@ -129,14 +136,22 @@ export interface Options {
* Represents a single usage of an environment variable in the codebase.
*/
export interface EnvUsage {
/** The environment variable being used */
variable: string;
/** The file where the usage was detected */
file: string;
/** The line number where the usage was detected */
line: number;
/** The column number where the usage was detected */
column: number;
/** The pattern used to access the environment variable */
pattern: 'process.env' | 'import.meta.env' | 'sveltekit';
imports?: string[]; // For sveltekit: list of imported env modules
context: string; // The actual line content
isLogged?: boolean; // Whether this usage is logged to console
/** List of imported env modules (for sveltekit) */
imports?: string[];
/** The actual line content where the usage was detected */
context: string;
/** Whether this usage is logged to console */
isLogged?: boolean;
}

/**
Expand All @@ -148,9 +163,13 @@ export type VariableUsages = Record<string, EnvUsage[]>;
* Warning about secrets found in example files
*/
export interface ExampleSecretWarning {
/** The environment variable key */
key: string;
/** The environment variable value */
value: string;
/** The reason for the warning */
reason: string;
/** The severity of the warning */
severity: 'high' | 'medium' | 'low';
}

Expand Down Expand Up @@ -280,7 +299,9 @@ export interface ComparisonOptions {
* Resolved comparison file with absolute path and display name.
*/
export interface ComparisonFile {
/** Absolute path to the comparison file */
path: string;
/** Display name of the comparison file */
name: string;
}

Expand Down Expand Up @@ -309,10 +330,8 @@ export interface Discovery {
export interface FilePair {
/** The name of the environment file (e.g. ".env", ".env.production") */
envName: string;

/** Absolute path to the environment file */
envPath: string;

/** Absolute path to the example file this env file is compared against */
examplePath: string;
}
Expand All @@ -334,6 +353,7 @@ export type Filtered = {
* Result of the exit code determination after scanning or comparing.
*/
export interface ExitResult {
/** Whether the process should exit with an error */
exitWithError: boolean;
}

Expand Down Expand Up @@ -361,7 +381,9 @@ export interface FixContext extends FixResult {
* Warning about environment variable keys that are not uppercase.
*/
export interface UppercaseWarning {
/** The environment variable key */
key: string;
/** Suggested uppercase version of the key */
suggestion: string;
}

Expand All @@ -375,8 +397,11 @@ export interface UppercaseWarning {
* This will generate a warning that API_KEY expires on 2025-12-31.
*/
export interface ExpireWarning {
/** The environment variable key */
key: string;
/** The expiration date of the environment variable */
date: string;
/** The number of days left until the environment variable expires */
daysLeft: number;
}

Expand All @@ -385,7 +410,10 @@ export interface ExpireWarning {
* fx: If you have both SECRET_KEY and SECRETKEY (inconsistent naming)
*/
export interface InconsistentNamingWarning {
/** The first environment variable key */
key1: string;
/** The second environment variable key */
key2: string;
/** Suggested consistent naming for the keys */
suggestion: string;
}
4 changes: 4 additions & 0 deletions src/core/compare/parseAndFilterEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import type { ComparisonOptions } from '../../config/types.js';
* Result of parsing and filtering environment files
*/
interface ParsedAndFilteredEnv {
/** Parsed and filtered current environment variables */
current: Record<string, string>;
/** Parsed and filtered example environment variables */
example: Record<string, string>;
/** Keys of the parsed and filtered current environment variables */
currentKeys: string[];
/** Keys of the parsed and filtered example environment variables */
exampleKeys: string[];
}

Expand Down
5 changes: 5 additions & 0 deletions src/core/compare/updateTotals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import type { CompareJsonEntry, Filtered } from '../../config/types.js';
* Totals of issues found during comparison --compare operation
*/
export interface Totals {
/** Number of missing keys */
missing: number;
/** Number of extra keys */
extra: number;
/** Number of empty keys */
empty: number;
/** Number of duplicate keys */
duplicate: number;
/** Number of gitignore issues */
gitignore: number;
}

Expand Down
Loading