-
-
Notifications
You must be signed in to change notification settings - Fork 931
/
index.ts
64 lines (55 loc) · 1.77 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
import type { IntegrityLike } from 'ssri'
import type { DependencyManifest } from '@pnpm/types'
export interface DeferredManifestPromise {
resolve: (manifest: DependencyManifest | undefined) => void
reject: (err: Error) => void
}
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' | 'clone-or-copy'
sideEffects?: Record<string, Record<string, PackageFileInfo>>
} & ({
local: true
filesIndex: Record<string, string>
} | {
local?: false
filesIndex: Record<string, PackageFileInfo>
})
export interface ImportPackageOpts {
requiresBuild?: boolean
sideEffectsCacheKey?: string
filesResponse: PackageFilesResponse
force: boolean
keepModulesDir?: boolean
}
export type ImportPackageFunction = (
to: string,
opts: ImportPackageOpts
) => Promise<{ isBuilt: boolean, importMethod: undefined | string }>
export type FileType = 'exec' | 'nonexec' | 'index'
export interface FilesIndex {
[filename: string]: {
mode: number
size: number
writeResult: Promise<FileWriteResult>
}
}
export interface FileWriteResult {
checkedAt: number
integrity: IntegrityLike
}
export interface Cafs {
cafsDir: string
addFilesFromDir: (dir: string, manifest?: DeferredManifestPromise) => Promise<FilesIndex>
addFilesFromTarball: (stream: NodeJS.ReadableStream, manifest?: DeferredManifestPromise) => Promise<FilesIndex>
getFilePathInCafs: (integrity: string | IntegrityLike, fileType: FileType) => string
getFilePathByModeInCafs: (integrity: string | IntegrityLike, mode: number) => string
importPackage: ImportPackageFunction
tempDir: () => Promise<string>
}