import { spawnSync } from 'node:child_process'; import { FiledistExtractEntry, PackageConfig } from './types'; /** * Parse a package spec like "my-pkg@^1.2.3" or "@scope/pkg@2.x" into name and version. * The version separator is the LAST "@" so that scoped packages ("@scope/name") are handled. */ export declare function parsePackageSpec(spec: string): PackageConfig; /** * Compute the SHA-256 hash of a file. */ export declare function hashFile(filePath: string): Promise; /** * Compute the SHA-256 hash of an in-memory buffer or string. * Used to hash content that has been transformed in memory before comparison. */ export declare function hashBuffer(content: Buffer | string): string; /** * Shorten a hex hash to 12 chars taken from position 19 (index 18). * Used to reduce verbosity of stored checksums in .filedist marker files * while still providing integrity protection. */ export declare function shortenChecksum(hash: string): string; /** * Synchronous file hash (SHA-256). */ export declare function hashFileSync(filePath: string): string; /** * Detect whether a file is binary by scanning it for null bytes. * Reads up to the first 8 KB only. */ export declare function isBinaryFile(filePath: string): boolean; /** * Return the installed package path if already present and satisfies the requested version. */ export declare function getInstalledIfSatisfies(name: string, version: string | undefined, workDir: string): string | null; /** * Install and/or upgrade a package using the detected package manager. * Returns the installed package path under node_modules. * If no package.json exists in the working directory, one is initialised automatically. */ export declare function installOrUpgradePackage(name: string, version: string | undefined, upgrade: boolean, cwd?: string, verbose?: boolean): Promise; /** * Return the installed package path under cwd/node_modules, or null if not installed. */ export declare function getInstalledPackagePath(name: string, cwd?: string): string | null; /** * Ensure a directory exists, creating it recursively if needed. */ export declare function ensureDir(dir: string): void; /** * Format a path for logs relative to the current working directory used by the action. */ export declare function formatDisplayPath(targetPath: string, cwd?: string): string; /** * Filter entries by requested presets. * When no presets are requested, all entries pass through. */ export declare function filterEntriesByPresets(entries: FiledistExtractEntry[], presets: string[] | undefined): FiledistExtractEntry[]; /** * Initialise a minimal package.json and ensure node_modules is listed in .gitignore * for the given working directory. */ export declare function initTempPackageJson(workDir: string, verbose?: boolean): void; export declare function cleanupTempPackageJson(cwd: string, verbose?: boolean): void; export declare function spawnWithLog(command: string, args: string[], workDir: string, verbose: boolean | undefined, failOnError: boolean): ReturnType; //# sourceMappingURL=utils.d.ts.map