import { type PackageManagerName } from './PackageManager.shared.ts'; export { PACKAGE_MANAGERS, type PackageManagerName, } from './PackageManager.shared.ts'; export type CommandVariant = 'install' | 'install-dev' | 'run' | 'exec' | 'create'; export interface DetectOptions { /** Working directory to detect from. Defaults to process.cwd() */ cwd?: string; /** Whether to traverse up directories looking for lockfiles. Defaults to true */ traverse?: boolean; /** Whether to fall back to checking global availability. Defaults to true */ fallbackToAvailable?: boolean; } export type DetectionSource = 'packageManager-field' | 'lockfile' | 'available' | 'default'; /** * Lockfiles used to infer the workspace package manager. * * Order matters: this is treated as a priority list when multiple lockfiles * exist. */ export declare const LOCKFILE_CANDIDATES: ReadonlyArray; /** * Parse the "packageManager" field from package.json. * * @example * parsePackageManagerField('pnpm@9.0.0') -> { name: 'pnpm', version: '9.0.0' } */ export declare function parsePackageManagerField(value: string): { name: PackageManagerName; version: string; } | null; export declare class PackageManager { /** The package manager name */ readonly name: PackageManagerName; /** How this package manager was detected (only set when detected) */ readonly source?: DetectionSource; /** The version constraint from package.json (only set when source is 'packageManager-field') */ readonly constraint?: string; /** * Create a PackageManager instance. * * @param nameOrOptions - Either a package manager name ('npm', 'pnpm', 'yarn', 'bun') * or detection options. If omitted, detects automatically. * * @example * // Detect automatically * const pm = new PackageManager() * * // Detect with options * const pm = new PackageManager({ cwd: './my-app' }) * * // Use specific package manager * const pm = new PackageManager('pnpm') */ constructor(nameOrOptions?: PackageManagerName | DetectOptions); /** * Get all package managers available on the system. */ static getAvailable(): PackageManager[]; /** * Get all package managers (available or not). */ static getAll(): PackageManager[]; /** * Clear the internal cache. */ static clearCache(): void; /** * Check if a value is a valid package manager name. */ static isValid(value: unknown): value is PackageManagerName; /** Check if this package manager is available on the system */ isAvailable(): boolean; /** Get the installed version of this package manager */ getVersion(): string | null; /** Build a command for a given variant */ command(variant: CommandVariant, subject: string): string; /** Build an install command */ install(packages: string | string[], options?: { dev?: boolean; }): string; /** Build a run command */ run(script: string, args?: string): string; /** Build an exec/dlx command */ exec(binary: string, args?: string): string; /** Build a create command */ create(template: string, args?: string): string; /** Get the base install command (e.g., "pnpm add") */ get installBase(): string; /** Get the dev flag (e.g., "--save-dev") */ get devFlag(): string; /** Get the run prefix (e.g., "pnpm") */ get runPrefix(): string; /** Get the exec prefix (e.g., "pnpm dlx") */ get execPrefix(): string; /** Get the create prefix (e.g., "pnpm create") */ get createPrefix(): string; }