forked from pkgxdev/pkgx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
65 lines (54 loc) · 1.74 KB
/
types.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
import SemVer, { Range as SemVerRange } from "semver"
import Path from "path"
import { host } from "./utils/index.ts"
export interface Package {
project: string
version: SemVer
}
export interface PackageRequirement {
project: string
constraint: SemVerRange
}
export type PackageSpecification = Package | PackageRequirement
export interface Installation {
path: Path
pkg: Package
}
export enum Verbosity {
quiet = -1,
normal = 0,
loud = 1,
debug = 2,
trace = 3
}
// when we support more variants of these that require specification
// we will tuple a version in with each eg. 'darwin' | ['windows', 10 | 11 | '*']
export const SupportedPlatforms = ["darwin" , "linux" , "windows" , "freebsd" , "netbsd" , "aix" , "solaris" , "illumos"] as const
export type SupportedPlatform = typeof SupportedPlatforms[number]
export const SupportedArchitectures = ["x86-64", "aarch64"] as const
export type SupportedArchitecture = typeof SupportedArchitectures[number]
/// remotely available package content (bottles or source tarball)
export type Stowage = {
type: 'src'
pkg: Package
extname: string
} | {
type: 'bottle'
pkg: Package
compression: 'xz' | 'gz'
host?: { platform: SupportedPlatform, arch: SupportedArchitecture }
}
/// once downloaded, `Stowage` becomes `Stowed`
export type Stowed = Stowage & { path: Path }
export function StowageNativeBottle(opts: { pkg: Package, compression: 'xz' | 'gz' }): Stowage {
return { ...opts, host: host(), type: 'bottle' }
}
// ExitError will cause the application to exit with the specified exit code if it bubbles
// up to the main error handler
export class ExitError extends Error {
code: number
constructor(code: number) {
super(`exiting with code: ${code}`)
this.code = code
}
}