-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathfeatureSet.ts
More file actions
57 lines (53 loc) · 1.62 KB
/
featureSet.ts
File metadata and controls
57 lines (53 loc) · 1.62 KB
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
import type * as semver from "semver";
export interface FeatureSet {
vscodessh: boolean;
proxyLogDirectory: boolean;
wildcardSSH: boolean;
buildReason: boolean;
cliUpdate: boolean;
keyringAuth: boolean;
keyringTokenRead: boolean;
supportBundle: boolean;
}
/**
* True when the CLI version is at least `minVersion`, or is a dev build.
* Returns false for null (unknown) versions.
*/
function versionAtLeast(
version: semver.SemVer | null,
minVersion: string,
): boolean {
if (!version) {
return false;
}
return version.compare(minVersion) >= 0 || version.prerelease[0] === "devel";
}
/**
* Builds and returns a FeatureSet object for a given coder version.
*/
export function featureSetForVersion(
version: semver.SemVer | null,
): FeatureSet {
return {
vscodessh: !(
version?.major === 0 &&
version?.minor <= 14 &&
version?.patch < 1 &&
version?.prerelease.length === 0
),
// --log-dir flag for proxy logs; vscodessh fails if unsupported
proxyLogDirectory: versionAtLeast(version, "2.4.0"),
// Wildcard SSH host matching
wildcardSSH: versionAtLeast(version, "2.19.0"),
// --reason flag for `coder start`
buildReason: versionAtLeast(version, "2.25.0"),
// `coder update` with stop transition (stops before updating)
cliUpdate: versionAtLeast(version, "2.24.0"),
// Keyring-backed token storage via `coder login`
keyringAuth: versionAtLeast(version, "2.29.0"),
// `coder login token` for reading tokens from the keyring
keyringTokenRead: versionAtLeast(version, "2.31.0"),
// `coder support bundle` (officially released/unhidden in 2.10.0)
supportBundle: versionAtLeast(version, "2.10.0"),
};
}