UNPKG

snyk-nodejs-lockfile-parser

Version:
32 lines (31 loc) 1.67 kB
export declare enum NodeLockfileVersion { NpmLockV1 = "NPM_LOCK_V1", NpmLockV2 = "NPM_LOCK_V2", NpmLockV3 = "NPM_LOCK_V3", YarnLockV1 = "YARN_LOCK_V1", YarnLockV2 = "YARN_LOCK_V2", PnpmLockV5 = "PNPM_LOCK_V5", PnpmLockV6 = "PNPM_LOCK_V6", PnpmLockV9 = "PNPM_LOCK_V9" } export declare const getLockfileVersionFromFile: (targetFile: string) => NodeLockfileVersion; export declare function getPnpmLockfileVersion(lockFileContents: string): NodeLockfileVersion.PnpmLockV5 | NodeLockfileVersion.PnpmLockV6 | NodeLockfileVersion.PnpmLockV9; export declare function getYarnLockfileVersion(lockFileContents: string): NodeLockfileVersion.YarnLockV1 | NodeLockfileVersion.YarnLockV2; export declare function getNpmLockfileVersion(lockFileContents: string): NodeLockfileVersion.NpmLockV1 | NodeLockfileVersion.NpmLockV2 | NodeLockfileVersion.NpmLockV3; /** * Parse JSON from a manifest or lockfile. On failure throws an * InvalidUserInputError that preserves the underlying parser message * (including the position of the syntax error) and appends a best-effort hint * about the likely cause. * * `fileLabel` is the file kind shown in the error, e.g. 'package.json' or * 'package-lock.json'. */ export declare function parseJsonFile<T = any>(content: string, fileLabel: string): T; /** * Best-effort, allocation-light hint describing the most likely reason a JSON * parse failed. Inspects only the leading characters of the content, never * throws, and returns '' when nothing recognisable is found - so it is always * safe to append to a parse-error message. */ export declare function describeLikelyJsonCause(content: string): string;