import { type PnpmLockfile } from "./pnpmLockfile.js"; /** * What `pnpm install --frozen-lockfile` puts in `node_modules`, computed from * the lockfile alone, as a table of symlinks. * * Ported from pnpm's own crates (valbuild/pnpm, pacquet 12.13.0): * `deps-path/src/dep_path_to_filename.rs` names each snapshot's directory in * the virtual store, and `deps-restorer/src/hoist.rs` decides which * transitive dependencies are also linked into the private hoist * (`node_modules/.pnpm/node_modules`). The defaults are pnpm 12's: hoist * `["*"]` privately, nothing publicly, virtual store names at most 120 bytes, * no global virtual store. `pnpmLayout.test.ts` compares the result with * what a real install left on disk. * * Every path is absolute, under `root` (default `/project`), with `/` * separators. */ export type PnpmLayout = { root: string; /** `/node_modules/.pnpm` */ virtualStore: string; /** Every symlink: its own path, to the absolute directory it points at. */ links: Map; /** Every installed snapshot, by the directory its package's files are in. */ packages: Map; /** Each importer's directory, by its id (`.` is the root project). */ importers: Map; /** Snapshots `pnpm install` would skip: optional, and not for this platform. */ skipped: Set; }; export type LayoutPackage = { /** The snapshot key: `name@version(peers)`. */ snapshot: string; name: string; version: string; /** `null` for a package the lockfile does not give an integrity for (a tarball URL, git). */ integrity: string | null; /** Whether it comes from a registry by name and version, so its types can be asked for. */ fromRegistry: boolean; }; /** What `pnpm install` checks optional packages' `os`, `cpu` and `libc` against. */ export type Platform = { os: string; cpu: string; libc: string | null; }; export type LayoutOptions = { root?: string; /** `null` installs every optional package, whatever it is built for. */ platform?: Platform | null; hoistPattern?: string[]; publicHoistPattern?: string[]; virtualStoreDirMaxLength?: number; /** * Each workspace project's `name`, by importer id, from its package.json. * The lockfile does not carry them, and pnpm links every named project * into the hoist as well (`hoist-workspace-packages`). */ workspaceNames?: Record; /** `hoistWorkspacePackages`, on unless the workspace turns it off. */ hoistWorkspacePackages?: boolean; }; /** * Linux on x64 with glibc: what a CI runner and the build are, and so the * install the typecheck is compared with. It only decides which optional, * platform-specific packages exist, which hardly ever carry types. */ export declare const DEFAULT_PLATFORM: Platform; /** * The directory name of a snapshot in the virtual store: pnpm's * `dep_path_to_filename`. `@scope/foo@1.0.0(bar@2.0.0)` is * `@scope+foo@1.0.0_bar@2.0.0`; a name longer than `maxLength` bytes, or with * upper case letters, is cut and given a hash of the whole. */ export declare function depPathToFilename(depPath: string, maxLength?: number): string; /** * pnpm's `WildcardMatcher` lists: `*` is any run of characters, `?` one, a * leading `!` excludes, and a later exclude cancels an earlier include. */ export declare function createMatcher(patterns: string[]): (input: string) => boolean; /** `a/b/../c` → `a/c`, for absolute `/`-separated paths. */ export declare function normalizePath(path: string): string; /** A setting in `pnpm-workspace.yaml` the layout cannot follow. */ export declare class UnsupportedLayoutError extends Error { } /** * The settings in `pnpm-workspace.yaml` that change the layout: `hoist`, * `hoistPattern`, `publicHoistPattern`, `shamefullyHoist` and * `virtualStoreDirMaxLength`. pnpm 11 and later read these from there and not * from `.npmrc`. `nodeLinker` other than `isolated` is a different layout * altogether, and refused. */ export declare function layoutOptionsOfWorkspace(workspace: Record): LayoutOptions; /** What `pnpm install` would put in `node_modules` for this lockfile. */ export declare function computePnpmLayout(lockfile: PnpmLockfile, options?: LayoutOptions): PnpmLayout;