Repository navigation
Expand file tree
/
Copy pathserver-platform.js
More file actions
109 lines (95 loc) · 2.67 KB
/
Copy pathserver-platform.js
File metadata and controls
109 lines (95 loc) · 2.67 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
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
'use strict';
// Single source of truth for the VS Code target <-> Cvolo Language Server RID
// mapping. Runtime discovery (extension-runtime.js), the staging script
// (scripts/stage-server.js), the packaging workflow and validation all read the
// mapping from here so the five platforms can never drift apart.
//
// A VS Code target is exactly `<process.platform>-<process.arch>` for every
// supported desktop platform, which is why one table can drive both the runtime
// platform/arch lookup and the `vsce package --target` value.
const TARGETS = Object.freeze([
Object.freeze({
target: 'win32-x64',
rid: 'win-x64',
platform: 'win32',
arch: 'x64',
executable: 'cvolo-language-server.exe',
archiveExtension: 'zip'
}),
Object.freeze({
target: 'linux-x64',
rid: 'linux-x64',
platform: 'linux',
arch: 'x64',
executable: 'cvolo-language-server',
archiveExtension: 'tar.gz'
}),
Object.freeze({
target: 'linux-arm64',
rid: 'linux-arm64',
platform: 'linux',
arch: 'arm64',
executable: 'cvolo-language-server',
archiveExtension: 'tar.gz'
}),
Object.freeze({
target: 'darwin-x64',
rid: 'osx-x64',
platform: 'darwin',
arch: 'x64',
executable: 'cvolo-language-server',
archiveExtension: 'tar.gz'
}),
Object.freeze({
target: 'darwin-arm64',
rid: 'osx-arm64',
platform: 'darwin',
arch: 'arm64',
executable: 'cvolo-language-server',
archiveExtension: 'tar.gz'
})
]);
const ALL_RIDS = Object.freeze(TARGETS.map(entry => entry.rid));
const ALL_TARGETS = Object.freeze(TARGETS.map(entry => entry.target));
function entryForPlatform(platform, arch) {
return TARGETS.find(entry => entry.platform === platform && entry.arch === arch) ?? null;
}
function entryForRid(rid) {
return TARGETS.find(entry => entry.rid === rid) ?? null;
}
function entryForTarget(target) {
return TARGETS.find(entry => entry.target === target) ?? null;
}
function ridFor(platform, arch) {
return entryForPlatform(platform, arch)?.rid ?? null;
}
function targetFor(platform, arch) {
return entryForPlatform(platform, arch)?.target ?? null;
}
function ridForTarget(target) {
return entryForTarget(target)?.rid ?? null;
}
function targetForRid(rid) {
return entryForRid(rid)?.target ?? null;
}
function executableForRid(rid) {
return entryForRid(rid)?.executable ?? null;
}
function archiveExtensionForRid(rid) {
return entryForRid(rid)?.archiveExtension ?? null;
}
function isKnownRid(rid) {
return entryForRid(rid) !== null;
}
module.exports = {
TARGETS,
ALL_RIDS,
ALL_TARGETS,
ridFor,
targetFor,
ridForTarget,
targetForRid,
executableForRid,
archiveExtensionForRid,
isKnownRid
};