/
index.ts
86 lines (75 loc) · 1.84 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { DependencyManifest } from '@pnpm/types'
/**
* tarball hosted remotely
*/
export interface TarballResolution {
type?: undefined
tarball: string
integrity?: string
// needed in some cases to get the auth token
// sometimes the tarball URL is under a different path
// and the auth token is specified for the registry only
registry?: string
}
/**
* directory on a file system
*/
export interface DirectoryResolution {
type: 'directory'
directory: string
}
export interface GitResolution {
commit: string
repo: string
type: 'git'
}
export type Resolution =
TarballResolution |
DirectoryResolution |
GitResolution |
({ type: string } & object)
export interface ResolveResult {
id: string
latest?: string
publishedAt?: string
manifest?: DependencyManifest
normalizedPref?: string // is null for npm-hosted dependencies
resolution: Resolution
resolvedVia: 'npm-registry' | 'git-repository' | 'local-filesystem' | 'url' | string
}
export interface WorkspacePackages {
[name: string]: {
[version: string]: {
dir: string
manifest: DependencyManifest
}
}
}
export interface VersionSelectors {
[selector: string]: 'version' | 'range' | 'tag'
}
export interface PreferredVersions {
[packageName: string]: VersionSelectors
}
export interface ResolveOptions {
alwaysTryWorkspacePackages?: boolean
defaultTag?: string
pickLowestVersion?: boolean
publishedBy?: Date
projectDir: string
lockfileDir: string
preferredVersions: PreferredVersions
preferWorkspacePackages?: boolean
registry: string
workspacePackages?: WorkspacePackages
}
export type WantedDependency = {
injected?: boolean
} & ({
alias?: string
pref: string
} | {
alias: string
pref?: string
})
export type ResolveFunction = (wantedDependency: WantedDependency, opts: ResolveOptions) => Promise<ResolveResult>