/** * npm Execution Wrapper * Issue #1194: registry query + global install (D-15 / S3-007) * * Registry queries go through `npm view` rather than a direct fetch to the * registry API so that the user's `.npmrc` (registry / proxy / scope / auth) is * honoured and the *same* registry is used as the subsequent `npm install -g`. * A hard-coded registry URL would break mirror/proxy setups (making the post * install version check fail permanently) and would add a new fixed external * endpoint of the kind [SEC-001] guards against. * * MF-SEC-1: all commands use spawnSync with array args (never a shell string), * following the safe pattern of `preflight.ts:23-66`. * * @module npm-runner */ /** Timeout for `npm view` (longer than preflight's 5s: this is a network round trip) */ export declare const NPM_VIEW_TIMEOUT_MS = 10000; /** Timeout for `npm root -g` (a local path lookup, so preflight's 5s is plenty) */ export declare const NPM_ROOT_TIMEOUT_MS = 5000; /** * Result of a registry version query */ export interface NpmViewResult { /** Whether the query succeeded */ success: boolean; /** Resolved version (only when success) */ version?: string; /** Human readable failure reason (only when !success) */ error?: string; } /** * Result of a global install */ export interface NpmInstallResult { /** Whether the install succeeded */ success: boolean; /** Whether the failure was a permission error (EACCES) */ permissionDenied: boolean; /** Human readable failure reason (only when !success) */ error?: string; } /** * Query the npm registry for the latest published version of a package. * * @param packageName - Package name (e.g. `commandmate`) * @returns The resolved version, or a classified failure */ export declare function viewLatestVersion(packageName: string): NpmViewResult; /** * Install the latest published version of a package globally. * * npm output is captured and echoed so the user sees what happened. spawnSync * cannot both stream and capture, and the output is needed to classify EACCES. * * @param packageName - Package name (e.g. `commandmate`) * @returns Success, or a classified failure (EACCES flagged separately) */ export declare function installGlobalLatest(packageName: string): NpmInstallResult; /** * A package present in the npm global root (`npm root -g`) */ export interface GlobalInstallation { /** Absolute path of the installed package directory */ path: string; /** Version read from its package.json; undefined when that cannot be read */ version?: string; } /** * Locate a globally installed (`npm install -g`) package. * * Issue #1633: an npx self-update refreshes only the npx cache, so a global install left on the * machine keeps shadowing `commandmate` on PATH at whatever version it was — a divergence that * went unnoticed for months and surfaced as #1632. Callers only *warn* about what this reports, * so every failure mode (npm missing, `npm root -g` failing on permissions, an unreadable * package.json) degrades to "nothing to report" instead of propagating. * * @param packageName - Package name (e.g. `commandmate`) * @returns The installation, or null when npm could not be asked or the package is not there */ export declare function findGlobalInstallation(packageName: string): GlobalInstallation | null; //# sourceMappingURL=npm-runner.d.ts.map