import { PackageManager } from './package-files/package-manager.js'; import { Package, Workspace } from './package-files/workspace.js'; import { File, VirtualFile } from './parser.js'; export interface PruneBundledLockfileOptions { workspace: Workspace; packageManager: PackageManager; /** * The bundle's final file set, keyed by archive path (posix, relative to * the workspace root) — the bundler's own registry. */ files: ReadonlyMap; /** * Archive paths of manifests the bundler rewrote from their on-disk * originals (`bundle.packages.prune`, patch filtering). Unlike a faux * manifest, a rewritten manifest carries the member's real content and * version fields, so it is safe to feed into resolution even for a * member whose version is unknown. */ rewrittenManifests?: ReadonlySet; timeoutMs?: number; env?: NodeJS.ProcessEnv; } export type PruneBundledLockfileResult = { status: 'pruned'; /** The lockfile's archive path. */ archivePath: string; /** The regenerated lockfile contents. */ content: string; /** * The workspace's lockfile as it was before pruning. Callers that compare * the two — the patch filtering does, to tell a declaration pnpm dropped * from one it never read — get the exact bytes this prune was computed * from rather than re-reading a file that may since have changed. */ originalContent: string; /** * Faux manifests synthesized for workspace members that bundled * manifests reference as links but that have no manifest in the bundle * (see {@link pruneBundledLockfile}). The caller must register these * into the bundle so that the bundle and the pruned lockfile stay * consistent. */ backfilledManifests: VirtualFile[]; } | { status: 'skipped'; reason: string; /** * True when the skip means "pruning was needed but is unavailable" — * the bundle is a partial workspace whose lockfile over-describes it, * yet this setup cannot be pruned. Callers should surface these; skips * where there is simply nothing to do stay quiet. */ notable?: boolean; /** * True when the skip itself proves the shipped lockfile matches the * bundle's manifests: the regeneration ran against them and produced * byte-identical content. Lets a caller that rewrote manifests keep * the rewrite instead of rolling it back. */ consistent?: boolean; } | { status: 'failed'; reason: string; }; /** * A workspace package's manifest path in the archive, posix-relative to * the workspace root — the keying the bundler's file map uses. Exported so * the bundler's manifest pruning derives identical keys; the * `rewrittenManifests` set is matched against these. */ export declare function manifestArchivePath(workspace: Workspace, pkg: Package): string; /** The workspace lockfile's archive path, when the workspace has one. */ export declare function lockfileArchivePath(workspace: Workspace): string | undefined; export type ShouldPruneResult = { prune: true; lockfileArchivePath: string; } | { prune: false; reason: string; notable?: boolean; }; /** * Decides whether the bundle's lockfile needs pruning at all. Pruning only * matters when the bundle differs from the full workspace — when every * workspace member's real manifest is in the bundle, the original lockfile * already describes the bundle exactly. */ export declare function shouldPruneLockfile(workspace: Workspace, files: ReadonlyMap, env?: NodeJS.ProcessEnv, rewrittenManifests?: ReadonlySet): ShouldPruneResult; /** * Selects the bundle entries that affect dependency resolution: manifests, * package manager configuration, patches and the lockfile itself. This * deliberately mirrors what the remote install will see, so the pruned * lockfile matches the remote install's inputs. */ export declare function selectMaterializationEntries(files: ReadonlyMap, lockfileArchivePath: string): Array<[string, File]>; /** * Scrubs credentials from package manager output before it is surfaced * anywhere. Every http(s) URL is collapsed to scheme and host by * `redactUrl`: registries carry tokens in userinfo, in the query string and * in path segments (Gemfury-style `https://host//npm/`), and the host * is all a stalled-request diagnosis needs. A scheme-less `//user:pw@host` * (pnpm prints registry keys in that form) loses its userinfo. Redaction is * by removal only; nothing is reconstructed from the credential-bearing * parts. */ export declare function redactDetail(detail: string): string; /** * Regenerates the bundle's lockfile so it matches the bundle's actual set of * manifests, by materializing the resolution-relevant bundle entries into a * temp directory and running the package manager's lockfile-only install. * * Returns `skipped` when pruning is unnecessary or unsupported, and `failed` * when the caller should fall back to the original lockfile. */ export declare function pruneBundledLockfile(options: PruneBundledLockfileOptions): Promise;