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
2 changes: 0 additions & 2 deletions packages/cli/src/core/diffEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
export type DiffResult = {
/** Keys present in the example file but missing from the current file */
missing: string[];

/** Keys present in the current file but not defined in the example file */
extra: string[];

/** Keys that exist in both files but have mismatched values */
valueMismatches: {
/** The environment variable key */
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/core/envLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
* This module provides utility functions for parsing and handling dotenv files.
*/
export interface EnvKeyValue {
/** The key of the environment variable. */
key: string;
/** The value of the environment variable. */
value: string;
}

/** BOM (Byte Order Mark) character used to indicate UTF-8 encoding. */
const BOM = '\uFEFF';

/** Strips a UTF-8 BOM from the start of the content, if present.
Expand Down
14 changes: 12 additions & 2 deletions packages/cli/src/core/suggestTypos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ import type { TypoSuggestion } from '../config/types.js';
import { MAX_TYPO_DISTANCE, MAX_TYPO_RATIO } from '../config/constants.js';
import { levenshtein } from './helpers/levenshtein.js';

/**
* A candidate key that qualifies as a likely typo of a reported key
*/
interface ClosestMatch {
/** The candidate key from the existing key pool */
key: string;
/** Levenshtein distance between the reported key and this candidate */
distance: number;
}

/**
* Cross-references reported keys against a pool of existing candidate keys and
* suggests the closest match when a key looks like a simple typo of another.
Expand Down Expand Up @@ -50,8 +60,8 @@ export function suggestTypos(
function findClosestKey(
key: string,
candidateKeys: string[],
): { key: string; distance: number } | null {
let best: { key: string; distance: number } | null = null;
): ClosestMatch | null {
let best: ClosestMatch | null = null;

for (const candidate of candidateKeys) {
if (candidate === key) continue;
Expand Down