/
index.ts
77 lines (67 loc) · 1.89 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
import { Resolution } from '@pnpm/resolver-base'
import { DependencyManifest } from '@pnpm/types'
import { IntegrityLike } from 'ssri'
export interface PackageFileInfo {
checkedAt?: number // Nullable for backward compatibility
integrity: string
mode: number
size: number
}
export type PackageFilesResponse = {
fromStore: boolean
packageImportMethod?: 'auto' | 'hardlink' | 'copy' | 'clone'
sideEffects?: Record<string, Record<string, PackageFileInfo>>
} & ({
local: true
filesIndex: Record<string, string>
} | {
local?: false
filesIndex: Record<string, PackageFileInfo>
})
export type ImportPackageFunction = (
to: string,
opts: {
targetEngine?: string
filesResponse: PackageFilesResponse
force: boolean
}
) => Promise<{ isBuilt: boolean, importMethod: undefined | string }>
export interface Cafs {
addFilesFromDir: (dir: string, manifest?: DeferredManifestPromise) => Promise<FilesIndex>
addFilesFromTarball: (stream: NodeJS.ReadableStream, manifest?: DeferredManifestPromise) => Promise<FilesIndex>
importPackage: ImportPackageFunction
tempDir: () => Promise<string>
}
export interface FetchOptions {
manifest?: DeferredManifestPromise
lockfileDir: string
onStart?: (totalSize: number | null, attempt: number) => void
onProgress?: (downloaded: number) => void
}
export interface DeferredManifestPromise {
resolve: (manifest: DependencyManifest | undefined) => void
reject: (err: Error) => void
}
export type FetchFunction = (
cafs: Cafs,
resolution: Resolution,
opts: FetchOptions
) => Promise<FetchResult>
export type FetchResult = {
local?: false
filesIndex: FilesIndex
} | {
local: true
filesIndex: Record<string, string>
}
export interface FileWriteResult {
checkedAt: number
integrity: IntegrityLike
}
export interface FilesIndex {
[filename: string]: {
mode: number
size: number
writeResult: Promise<FileWriteResult>
}
}