UNPKG

2.69 kBTypeScriptView Raw
1import { PackageLock } from './package-lock-parser';
2import { YarnLock } from './yarn-lock-parser';
3import { Yarn2Lock } from './yarn2-lock-parser';
4export interface Dep {
5 name: string;
6 version: string;
7 dev?: boolean;
8}
9interface WorkspacesAlternateConfig {
10 packages?: string[];
11}
12export declare type ManifestDependencies = {
13 [dep: string]: string;
14};
15export declare type PeerDependenciesMeta = {
16 [dep: string]: {
17 optional: boolean;
18 };
19};
20export interface ManifestFile {
21 name: string;
22 private?: string;
23 engines?: {
24 node?: string;
25 };
26 workspaces?: string[] | WorkspacesAlternateConfig;
27 dependencies?: ManifestDependencies;
28 devDependencies?: ManifestDependencies;
29 optionalDependencies?: ManifestDependencies;
30 peerDependencies?: ManifestDependencies;
31 peerDependenciesMeta?: PeerDependenciesMeta;
32 resolutions?: ManifestDependencies;
33 version?: string;
34}
35export interface DepTreeDep {
36 name?: string;
37 version?: string;
38 dependencies?: {
39 [depName: string]: DepTreeDep;
40 };
41 labels?: {
42 [key: string]: string | undefined;
43 scope?: 'dev' | 'prod';
44 pruned?: 'cyclic' | 'true';
45 missingLockFileEntry?: 'true';
46 };
47}
48export interface PkgTree extends DepTreeDep {
49 type?: string;
50 packageFormatVersion?: string;
51 dependencies: {
52 [depName: string]: DepTreeDep;
53 };
54 meta?: {
55 nodeVersion?: string;
56 lockfileVersion?: number;
57 packageManager?: string;
58 };
59 hasDevDependencies?: boolean;
60 cyclic?: boolean;
61 size?: number;
62}
63export declare enum Scope {
64 prod = "prod",
65 dev = "dev"
66}
67export declare enum LockfileType {
68 npm = "npm",
69 npm7 = "npm7",
70 yarn = "yarn",
71 yarn2 = "yarn2",
72 pnpm = "pnpm"
73}
74export interface LockfileParser {
75 parseLockFile: (lockFileContents: string) => Lockfile;
76 getDependencyTree: (manifestFile: ManifestFile, lockfile: Lockfile, includeDev?: boolean, strictOutOfSync?: boolean) => Promise<PkgTree>;
77}
78export declare type Lockfile = PackageLock | YarnLock | Yarn2Lock;
79export declare function parseManifestFile(manifestFileContents: string): ManifestFile;
80export declare function getTopLevelDeps({ targetFile, includeDev, includePeerDeps, applyYarn2Resolutions, }: {
81 targetFile: ManifestFile;
82 includeDev: boolean;
83 includePeerDeps?: boolean;
84 applyYarn2Resolutions?: boolean;
85}): Dep[];
86export declare function createDepTreeDepFromDep(dep: Dep): DepTreeDep;
87export declare function getYarnWorkspaces(targetFile: string): string[] | false;
88export declare function getPnpmWorkspaces(workspacesYamlFile: string): string[];
89export {};