/** * @file Wrapper-script parsers: given a shim's source text, extract the * relative path to the real script it executes. * A binary like `npm` is rarely an executable. It is a generated wrapper — * `npm.cmd` / `npm.ps1` / an extensionless shell script — whose format is * fixed by the npm CLI build, by a manager's own installer, or by * `cmd-shim`. Each parser here pattern-matches one of those formats and * returns the captured relative path, or `''` when the source does not * match. Dispatch is by `binShimFormat`, so a new manager is a table row * rather than another branch here. * Every function is pure over its source string: no filesystem, no platform * check. That is what lets the Windows-only formats be unit-tested on any * host, and it keeps the branchy regex work out of the resolver that owns * the I/O. */ export declare const SHIM_SOURCE_MAX_LENGTH: number; /** * One shim to parse: its basename, its lowered extension, and its source text. */ export type ShimSource = { basename: string; extLowered: string; source: string; }; /** * The generic `cmd-shim` formats, used for every package binary that does not * ship a bespoke wrapper. * * Verbatim shim bodies: docs/references/repo/cmd-shim-formats.md. The parsers * match that exact generated text, so an upstream wording change yields an * empty path rather than a loud failure. */ export declare function cmdShimRelPath(config: ShimSource): string; export declare function extractShimLinePath(source: string, prefix: string, pathTerminator: string, tail: string): string; /** * The installer-emitted Unix shell formats, tried in order: a standalone * installer's `.tools/...` layout, the generic cmd-shim body, then the bare * `exec node "$basedir/..."` spelling a setup action emits. * * The setup-pnpm action emits a target of `pnpm/bin/pnpm.cjs` where the real * layout is one directory up, so that one spelling is repaired here. */ export declare function installerPosixShimRelPath(config: ShimSource): string; /** * The installer-emitted `.cmd` formats, tried in order: a setup action's * `node "%~dp0\..."`, the bundled-node variant that spells `node.exe` first, * then the generic cmd-shim body. */ export declare function installerWindowsCmdRelPath(source: string): string; /** * The extensionless installer-emitted shell formats, tried in order: a * standalone installer's `.tools/pnpm/` layout under either * `"$basedir/node"` or a bare `exec node`, then the generic cmd-shim body. */ export declare function installerWindowsShellRelPath(source: string): string; /** * The installer-emitted wrapper formats, which vary by install method — a * setup action, a global install, and a standalone installer each generate a * different body. */ export declare function installerWindowsShimRelPath(config: ShimSource): string; /** * The npm CLI's Unix shell format, which assigns the target to `NPM_CLI_JS`. */ export declare function npmPosixShimRelPath(config: ShimSource): string; /** * The npm CLI's wrapper formats. Each variant assigns the target to a shell * variable, so the parser reads the path from that assignment. * * Sources: npm/cli v11.4.2 `bin/npm{,.cmd,.ps1}` and `bin/npx{,.cmd,.ps1}`. */ export declare function npmWindowsShimRelPath(config: ShimSource): string; /** * The Unix wrapper's relative target, dispatched by shim format. A `cmd-shim` * binary on Unix is already the real script, so it answers `''`. */ export declare function posixShimRelPath(config: ShimSource): string; /** * The Windows wrapper's relative target, dispatched by shim format. */ export declare function windowsShimRelPath(config: ShimSource): string;