import { ResolvedBuildConfig, BuildValidationResult } from "./types"; export interface ValidatorOptions { verbose: boolean; timeout?: number; strictBinaryResolution?: boolean; maxConcurrentBuilds?: number; } /** * Validates webpack/rspack builds by running them and checking for errors * For HMR builds, starts webpack-dev-server and shuts down after successful start */ export declare class BuildValidator { private options; constructor(options: ValidatorOptions); /** * Filters environment variables to only include whitelisted safe variables. * This prevents command injection and limits exposure of sensitive data. * Also validates environment variable values for suspicious patterns. */ private filterEnvironment; /** * Validates that a config file exists and returns the resolved path. * Throws an error if the config file is not found or attempts path traversal. * * @param configFile - The config file path from the build configuration * @param appRoot - The application root directory * @param buildName - The name of the build (for error messages) * @returns The resolved absolute path to the config file * @throws Error if the config file does not exist or is outside appRoot */ private static validateConfigPath; /** * Validates a single build configuration by running the appropriate bundler command. * For HMR builds, starts webpack-dev-server and validates successful compilation. * For static builds, runs a full build and validates the output. * * @param build - The resolved build configuration to validate * @param appRoot - The application root directory * @returns A promise that resolves to the build validation result */ validateBuild(build: ResolvedBuildConfig, appRoot: string): Promise; /** * Validates an HMR build by starting webpack-dev-server * Waits for successful compilation, then shuts down */ private validateHMRBuild; /** * Validates a static build by running webpack/rspack in production mode * Uses --json flag to get structured output */ private validateStaticBuild; /** * Finds the binary for webpack, rspack, or dev servers. * Prefers local node_modules/.bin installation for security. * Falls back to global installation and PATH resolution with a warning in verbose mode. * * SECURITY NOTE: The PATH fallback allows resolving binaries from the system PATH, * which could be a security risk in untrusted environments where an attacker could * manipulate the PATH environment variable. This fallback is included for flexibility * and backward compatibility with systems that use npx or have binaries installed in * non-standard locations. In production CI/CD environments, ensure binaries are * installed locally in node_modules to avoid PATH resolution. * * @param name - The binary name to find (e.g., "webpack", "webpack-dev-server") * @param appRoot - The application root directory * @returns The path to the binary, or the bare name for PATH resolution */ private findBinary; /** * Formats validation results for display in the terminal. * Shows a summary of all builds with success/failure status, * error messages, warnings, and optional output logs. * * @param results - Array of validation results from all builds * @returns Formatted string ready for console output */ formatResults(results: BuildValidationResult[]): string; } //# sourceMappingURL=buildValidator.d.ts.map