/
index.ts
152 lines (137 loc) · 3.59 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import {
DirectoryResolution,
PreferredVersions,
Resolution,
WantedDependency,
WorkspacePackages,
} from '@pnpm/resolver-base'
import type {
ImportPackageFunction,
PackageFileInfo,
PackageFilesResponse,
} from '@pnpm/cafs-types'
import {
DependencyManifest,
PackageManifest,
} from '@pnpm/types'
export { PackageFileInfo, PackageFilesResponse, ImportPackageFunction }
export * from '@pnpm/resolver-base'
export type BundledManifest = Pick<
DependencyManifest,
| 'bin'
| 'bundledDependencies'
| 'bundleDependencies'
| 'dependencies'
| 'directories'
| 'engines'
| 'name'
| 'optionalDependencies'
| 'os'
| 'peerDependencies'
| 'peerDependenciesMeta'
| 'scripts'
| 'version'
>
export interface UploadPkgToStoreOpts {
filesIndexFile: string
sideEffectsCacheKey: string
}
export type UploadPkgToStore = (builtPkgLocation: string, opts: UploadPkgToStoreOpts) => Promise<void>
export interface StoreController {
requestPackage: RequestPackageFunction
fetchPackage: FetchPackageToStoreFunction
importPackage: ImportPackageFunction
close: () => Promise<void>
prune: () => Promise<void>
upload: UploadPkgToStore
}
export type FetchPackageToStoreFunction = (
opts: FetchPackageToStoreOptions
) => {
bundledManifest?: BundledManifestFunction
filesIndexFile: string
files: () => Promise<PackageFilesResponse>
finishing: () => Promise<void>
}
export interface PkgNameVersion {
name?: string
version?: string
}
export interface FetchPackageToStoreOptions {
fetchRawManifest?: boolean
force: boolean
lockfileDir: string
pkg: PkgNameVersion & {
id: string
resolution: Resolution
}
/**
* Expected package is the package name and version that are found in the lockfile.
*/
expectedPkg?: PkgNameVersion
}
export type RequestPackageFunction = (
wantedDependency: WantedDependency & { optional?: boolean },
options: RequestPackageOptions
) => Promise<PackageResponse>
export interface RequestPackageOptions {
alwaysTryWorkspacePackages?: boolean
currentPkg?: {
id?: string
resolution?: Resolution
}
/**
* Expected package is the package name and version that are found in the lockfile.
*/
expectedPkg?: PkgNameVersion
defaultTag?: string
pickLowestVersion?: boolean
publishedBy?: Date
downloadPriority: number
projectDir: string
lockfileDir: string
preferredVersions: PreferredVersions
preferWorkspacePackages?: boolean
registry: string
sideEffectsCache?: boolean
skipFetch?: boolean
update?: boolean
workspacePackages?: WorkspacePackages
forceResolve?: boolean
}
export type BundledManifestFunction = () => Promise<BundledManifest | undefined>
export interface PackageResponse {
bundledManifest?: BundledManifestFunction
files?: () => Promise<PackageFilesResponse>
filesIndexFile?: string
finishing?: () => Promise<void> // a package request is finished once its integrity is generated and saved
body: {
isLocal: boolean
isInstallable?: boolean
resolution: Resolution
manifest?: PackageManifest
id: string
normalizedPref?: string
updated: boolean
publishedAt?: string
resolvedVia?: string
// This is useful for recommending updates.
// If latest does not equal the version of the
// resolved package, it is out-of-date.
latest?: string
} & (
{
isLocal: true
resolution: DirectoryResolution
} | {
isLocal: false
}
)
}
export type FilesMap = Record<string, string>
export interface ImportOptions {
filesMap: FilesMap
force: boolean
fromStore: boolean
}
export type ImportIndexedPackage = (to: string, opts: ImportOptions) => Promise<string | undefined>