import { spawn } from 'node:child_process'; import fs from 'node:fs'; import { extractArchive } from './file.js'; import { fetchJRE, serverSupportsJREProvisioning } from './java.js'; import { locateExecutableFromPath } from './process.js'; import { download as defaultDownload, fetch as defaultFetch } from './request.js'; import { downloadScannerCli, runScannerCli } from './scanner-cli.js'; import { fetchScannerEngine, runScannerEngine } from './scanner-engine.js'; export type ExecAsyncFn = (command: string) => Promise<{ stdout: string; stderr: string; }>; export type SpawnFn = typeof spawn; export type RunScannerCliFn = typeof runScannerCli; export type RunScannerEngineFn = typeof runScannerEngine; /** * Centralized dependency container for all injectable dependencies. * This allows for easy mocking in tests while keeping function signatures clean. */ export interface Dependencies { fs: { existsSync: typeof fs.existsSync; statSync: typeof fs.statSync; readFileSync: typeof fs.readFileSync; readFile: typeof fs.readFile; mkdirSync: typeof fs.mkdirSync; createReadStream: typeof fs.createReadStream; createWriteStream: typeof fs.createWriteStream; remove: (path: string) => Promise; writeFile: (path: string, data: string) => Promise; exists: (path: string) => Promise; ensureDir: (path: string) => Promise; }; process: { platform: NodeJS.Platform; arch: NodeJS.Architecture; env: NodeJS.ProcessEnv; cwd: () => string; }; http: { fetch: typeof defaultFetch; download: typeof defaultDownload; }; spawn: SpawnFn; execAsync: ExecAsyncFn; scan: { serverSupportsJREProvisioning: typeof serverSupportsJREProvisioning; fetchJRE: typeof fetchJRE; downloadScannerCli: typeof downloadScannerCli; runScannerCli: typeof runScannerCli; fetchScannerEngine: typeof fetchScannerEngine; runScannerEngine: typeof runScannerEngine; locateExecutableFromPath: typeof locateExecutableFromPath; }; file: { extractArchive: typeof extractArchive; }; } /** * Get the current dependency container. * Internal functions use this to access dependencies. */ export declare function getDeps(): Dependencies; /** * Set/override dependencies. Used for testing. * Merges the provided partial dependencies with the defaults. * * @param newDeps - Partial dependencies to override */ export declare function setDeps(newDeps: Partial): void; /** * Reset dependencies to defaults. Should be called in afterEach() in tests. */ export declare function resetDeps(): void;