-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.d.ts
145 lines (123 loc) · 2.82 KB
/
index.d.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
/**
* Which versions of which packages are required.
*/
interface WantedVersions {
/**
* Required version of Node.js.
*/
node?: string;
/**
* Required version of npm.
*/
npm?: string;
/**
* Required version of yarn.
*/
yarn?: string;
/**
* Required version of pnpm.
*/
pnpm?: string;
}
type OnGetVersion = (error: Error | null, info: VersionInfo) => void;
/**
* Gets the version of a package.
*
* @param packageName Name of the package.
* @param onComplete Handler for the package name.
*/
type GetVersion = (packageName: string, onComplete: OnGetVersion) => void;
/**
* Requested version range of a package.
*/
interface Wanted {
/**
* Resolved semver equivalent of the raw version.
*/
range: string;
/**
* Raw semver requirement for the version.
*/
raw: string;
}
/**
* Positive result of checking a program version.
*/
interface SatisfiedVersionInfo {
/**
* Whether the version was known to satisfy its requirements (true).
*/
isSatisfied: true;
/**
* Retrieved version.
*/
version: string;
/**
* Requested version range of the package, if any.
*/
wanted?: Wanted;
}
/**
* Negative result of checking a program version.
*/
interface UnsatisfiedVersionInfo {
/**
* Whether the version was known to satisfy its requirements (false).
*/
isSatisfied: false;
/**
* Whether the program version was unable to be found.
*/
notfound?: boolean;
/**
* Whether the program version string is non-compliant with semver.
*/
invalid?: boolean;
/**
* Retrieved version, if available.
*/
version?: string;
/**
* Requested version range of the package, if any.
*/
wanted?: Wanted;
}
/**
* Result of checking a program version.
*/
type VersionInfo = SatisfiedVersionInfo | UnsatisfiedVersionInfo;
/**
* Versions for each package, keyed by package name.
*/
interface VersionInfos {
[i: string]: VersionInfo;
}
/**
* Results from checking versions.
*/
interface Results {
/**
* Versions for each package, keyed by package name.
*/
versions: VersionInfos;
/**
* Whether all versions were satisfied.
*/
isSatisfied: boolean;
}
/**
* Handles results from checking versions.
*
* @param error Error from version checking, if any.
* @param results Results from checking versions.
*/
type OnComplete = (error: Error | null, results: Results) => void;
/**
* Checks package versions.
*
* @param [wanted] Which versions of programs are required.
* @param onComplete Handles results from checking versions.
*/
declare function check(onComplete: OnComplete): void;
declare function check(wanted: WantedVersions, onComplete: OnComplete): void;
export = check;