sonarqube-scanner
Version:
SonarQube/SonarCloud Scanner for the JavaScript world
69 lines (68 loc) • 2.53 kB
TypeScript
import { exec, spawn } from 'node:child_process';
import fs from 'node:fs';
import { extractArchive } from './file';
import { fetchJRE, serverSupportsJREProvisioning } from './java';
import { locateExecutableFromPath } from './process';
import { download as defaultDownload, fetch as defaultFetch } from './request';
import { downloadScannerCli, runScannerCli } from './scanner-cli';
import { fetchScannerEngine, runScannerEngine } from './scanner-engine';
declare const execAsync: typeof exec.__promisify__;
/**
* 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;
readFileSync: typeof fs.readFileSync;
readFile: typeof fs.readFile;
mkdirSync: typeof fs.mkdirSync;
createReadStream: typeof fs.createReadStream;
createWriteStream: typeof fs.createWriteStream;
remove: (path: string) => Promise<void>;
writeFile: (path: string, data: string) => Promise<void>;
exists: (path: string) => Promise<boolean>;
ensureDir: (path: string) => Promise<void>;
};
process: {
platform: NodeJS.Platform;
arch: NodeJS.Architecture;
env: NodeJS.ProcessEnv;
cwd: () => string;
};
http: {
fetch: typeof defaultFetch;
download: typeof defaultDownload;
};
spawn: typeof spawn;
execAsync: typeof execAsync;
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<Dependencies>): void;
/**
* Reset dependencies to defaults. Should be called in afterEach() in tests.
*/
export declare function resetDeps(): void;
export {};