//#region src/supply-chain/package-manager.d.ts /** * Package-manager wrapper used by the npm + git installers. The * framework prefers `pnpm` (the project default) and falls back to * `npm` / `yarn` when `pnpm` is not on `PATH`. Every spawned process * passes the appropriate `--ignore-scripts` flag when the resolved * trust policy demands it. * * @packageDocumentation */ /** * Discriminator for the resolved package manager. * * @stable */ type PackageManagerKind = 'pnpm' | 'npm' | 'yarn'; /** * Strategy hook: replace the default `child_process.spawn` runner. * Tests use this to assert the correct CLI is invoked without * actually shelling out. * * @experimental */ type PackageManagerRunner = (args: { readonly command: string; readonly args: ReadonlyArray; readonly cwd?: string; readonly env?: NodeJS.ProcessEnv; readonly signal?: AbortSignal; }) => Promise; /** Result returned by the runner. */ interface PackageManagerResult { readonly exitCode: number; readonly stdout: string; readonly stderr: string; } /** * Override the runner. Returns the previous runner so tests can * restore the default at the end of a fixture. * * @experimental */ declare function _setPackageManagerRunnerForTesting(runner: PackageManagerRunner | null): PackageManagerRunner | null; /** * Override the detected package manager. Returns the previous value. * * @experimental */ declare function _setPackageManagerForTesting(detector: (() => PackageManagerKind) | null): (() => PackageManagerKind) | null; /** * Detect the available package manager. Prefers `pnpm` (project * default) and falls back to `npm` and `yarn`. * * @stable */ declare function detectPackageManager(env?: NodeJS.ProcessEnv): PackageManagerKind; /** * Build the CLI invocation for an install request. Encapsulates the * subtle differences between the supported package managers. * * @stable */ declare function buildInstallInvocation(args: { readonly manager: PackageManagerKind; readonly packageSpec: string; readonly ignoreScripts: boolean; readonly cwd?: string; }): { command: string; args: ReadonlyArray; }; /** * Run a package-manager invocation. Returns the buffered stdout + * stderr; a non-zero exit code is reported to the caller via the * `exitCode` field rather than thrown. * * @stable */ declare function runPackageManager(args: { readonly command: string; readonly args: ReadonlyArray; readonly cwd?: string; readonly env?: NodeJS.ProcessEnv; readonly signal?: AbortSignal; }): Promise; //#endregion export { PackageManagerKind, PackageManagerResult, PackageManagerRunner, _setPackageManagerForTesting, _setPackageManagerRunnerForTesting, buildInstallInvocation, detectPackageManager, runPackageManager }; //# sourceMappingURL=package-manager.d.ts.map