/** * Dependency Lock File Check * * Verifies that lock files are in sync with package.json to prevent cache poisoning. * Supports npm, pnpm, yarn, and bun package managers with auto-detection. */ /** * Supported package managers */ export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun'; /** * Skip reasons for dependency check */ export type SkipReason = 'env-var' | 'no-lock-file'; /** * Result of dependency lock file check */ export interface DependencyCheckResult { /** Whether the check passed (lock file in sync) */ passed: boolean; /** Whether the check was skipped */ skipped: boolean; /** Reason for skipping the check */ skipReason?: SkipReason; /** Error message if check failed */ error?: string; /** Package manager used for check */ packageManager?: PackageManager; /** Command executed for verification */ command?: string; /** Duration of check in milliseconds */ duration: number; } /** * Detect package manager from git root directory * * Detection strategy: * 1. Check config override first (if provided) * 2. Read package.json for packageManager field * 3. Check for lock files in priority order (bun → yarn → pnpm → npm) * * @param gitRoot - Git repository root path * @param configPackageManager - Optional package manager from config * @returns Detected package manager or null if none found * * @example * const pm = detectPackageManager('/path/to/repo'); * console.log(pm); // 'pnpm' or 'npm' or null * * @example * // With config override * const pm = detectPackageManager('/path/to/repo', 'yarn'); * console.log(pm); // 'yarn' */ export declare function detectPackageManager(gitRoot: string, configPackageManager?: PackageManager): PackageManager | null; /** * Build install command for package manager * * If custom command provided, parses into array format. * Otherwise, returns appropriate frozen lockfile command: * - npm: npm ci * - pnpm: pnpm install --frozen-lockfile * - yarn: yarn install --immutable * - bun: bun install --frozen-lockfile * * @param packageManager - Package manager to build command for * @param customCommand - Optional custom command string * @returns Command array [command, ...args] * * @example * const cmd = buildInstallCommand('npm'); * console.log(cmd); // ['npm', 'ci'] * * @example * const cmd = buildInstallCommand('npm', 'npm ci --legacy-peer-deps'); * console.log(cmd); // ['npm', 'ci', '--legacy-peer-deps'] */ export declare function buildInstallCommand(packageManager: PackageManager, customCommand?: string): string[]; /** * Run dependency lock file verification * * Checks that lock file is in sync with package.json by running * the package manager's install command with frozen lockfile flag. * * Skip conditions: * - VV_SKIP_DEPENDENCY_CHECK env var is set * * @param gitRoot - Git repository root path * @param config - Configuration object * @param config.packageManager - Optional package manager override * @param config.command - Optional custom verification command * @param verbose - Enable verbose output * @returns Dependency check result * * @example * const result = await runDependencyCheck('/path/to/repo', {}, false); * if (!result.passed) { * console.error(result.error); * } * * @example * // With custom command * const result = await runDependencyCheck('/path/to/repo', { * packageManager: 'npm', * command: 'npm ci --legacy-peer-deps' * }, true); */ export declare function runDependencyCheck(gitRoot: string, config: { packageManager?: PackageManager; command?: string; }, verbose: boolean): Promise; //# sourceMappingURL=dependency-lock-check.d.ts.map