import { OutfitterError } from "@outfitter/contracts"; import { Result } from "@outfitter/contracts"; /** A package dependency found across workspace manifests. */ interface WorkspacePackageEntry { /** Full package name (e.g. "@outfitter/cli") */ readonly name: string; /** Cleaned semver version (without range prefix) */ readonly version: string; } /** Version conflict: same package at different versions in different manifests. */ interface VersionConflict { /** Full package name */ readonly name: string; /** All distinct versions found, with their manifest paths */ readonly versions: ReadonlyArray<{ readonly version: string; readonly manifests: readonly string[]; }>; } /** Result of scanning a workspace for @outfitter/* packages. */ interface WorkspaceScanResult { /** Version conflicts found across manifests */ readonly conflicts: readonly VersionConflict[]; /** All manifest paths scanned */ readonly manifestPaths: readonly string[]; /** Maps package name to the manifest paths that contain it */ readonly manifestsByPackage: ReadonlyMap; /** Deduplicated @outfitter/* packages (uses lowest version for conflicts) */ readonly packages: readonly WorkspacePackageEntry[]; /** Workspace root directory (null if not a workspace) */ readonly workspaceRoot: string | null; } /** * Walk up from `cwd` looking for a workspace root. * * Workspace root is identified by: * - `package.json` with a `workspaces` field (npm/yarn/bun) * - `pnpm-workspace.yaml` file * * Returns `null` (as Ok) if no workspace root found — this is not an error, * it means the project is a standalone package. */ declare function detectWorkspaceRoot(cwd: string): Result; /** * Collect all package.json files from a workspace root directory. * * Reads workspace patterns from the root package.json, resolves globs, * and returns sorted absolute paths to all matching package.json files. * Always includes the root package.json itself. */ declare function collectWorkspaceManifests(rootDir: string): Result; /** * Scan all workspace manifests, collect @outfitter/* deps, * deduplicate, and detect version conflicts. * * For deduplication: when the same package appears at the same version * in multiple manifests, it appears once in the result. * When versions differ, the lowest version is used and a conflict is reported. */ declare function getInstalledPackagesFromWorkspace(rootDir: string): Result; /** * Apply version updates to all manifests in a workspace that contain * the specified @outfitter/* packages. * * Preserves the existing version range prefix (^, ~, >=, etc.) in each manifest. * Does NOT run `bun install` — the caller is responsible for that. */ declare function applyUpdatesToWorkspace(manifestPaths: readonly string[], manifestsByPackage: ReadonlyMap, updates: readonly { name: string; latestVersion: string; }[]): Promise>; /** * Run `bun install` at the given directory. */ declare function runInstall(cwd: string): Promise>; export { WorkspacePackageEntry, VersionConflict, WorkspaceScanResult, detectWorkspaceRoot, collectWorkspaceManifests, getInstalledPackagesFromWorkspace, applyUpdatesToWorkspace, runInstall };