-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplatform.ts
More file actions
95 lines (87 loc) · 2.99 KB
/
Copy pathplatform.ts
File metadata and controls
95 lines (87 loc) · 2.99 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
export type PlatformKey =
| "darwin-arm64"
| "darwin-x64"
| "linux-arm64"
| "linux-x64"
| "win32-x64"
| "win32-arm64";
export interface PlatformInfo {
platformKey: PlatformKey;
targetTriple: string;
binaryName: "phpantom_lsp" | "phpantom_lsp.exe";
assetCandidates: string[];
}
interface PlatformMapping {
platformKey: PlatformKey;
targetTriple: string;
archiveExtension: "tar.gz" | "zip";
binaryName: "phpantom_lsp" | "phpantom_lsp.exe";
}
const mappings: Record<string, PlatformMapping> = {
"darwin-arm64": {
platformKey: "darwin-arm64",
targetTriple: "aarch64-apple-darwin",
archiveExtension: "tar.gz",
binaryName: "phpantom_lsp"
},
"darwin-x64": {
platformKey: "darwin-x64",
targetTriple: "x86_64-apple-darwin",
archiveExtension: "tar.gz",
binaryName: "phpantom_lsp"
},
"linux-arm64": {
platformKey: "linux-arm64",
targetTriple: "aarch64-unknown-linux-gnu",
archiveExtension: "tar.gz",
binaryName: "phpantom_lsp"
},
"linux-x64": {
platformKey: "linux-x64",
targetTriple: "x86_64-unknown-linux-gnu",
archiveExtension: "tar.gz",
binaryName: "phpantom_lsp"
},
"win32-x64": {
platformKey: "win32-x64",
targetTriple: "x86_64-pc-windows-msvc",
archiveExtension: "zip",
binaryName: "phpantom_lsp.exe"
},
"win32-arm64": {
platformKey: "win32-arm64",
targetTriple: "aarch64-pc-windows-msvc",
archiveExtension: "zip",
binaryName: "phpantom_lsp.exe"
}
};
export function getPlatformInfo(): PlatformInfo {
const lookupKey = `${process.platform}-${process.arch}`;
const mapping = mappings[lookupKey];
if (!mapping) {
throw new Error(
`Unsupported platform ${lookupKey}. PHPantom publishes binaries for darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-x64, and win32-arm64. You can build phpantom_lsp from source and set phpantom.serverPath manually.`
);
}
return {
platformKey: mapping.platformKey,
targetTriple: mapping.targetTriple,
binaryName: mapping.binaryName,
assetCandidates: buildAssetCandidates(mapping)
};
}
function buildAssetCandidates(mapping: PlatformMapping): string[] {
const secondaryArchive = mapping.archiveExtension === "zip" ? "tar.gz" : "zip";
return [
`phpantom_lsp-${mapping.targetTriple}.${mapping.archiveExtension}`,
`phpantom_lsp-${mapping.targetTriple}.${secondaryArchive}`,
`phpantom_lsp-${mapping.platformKey}.${mapping.archiveExtension}`,
`phpantom_lsp-${mapping.platformKey}.${secondaryArchive}`,
`phpantom_lsp-${mapping.targetTriple}.tgz`,
`phpantom_lsp-${mapping.platformKey}.tgz`,
`phpantom_lsp-${mapping.targetTriple}.gz`,
`phpantom_lsp-${mapping.platformKey}.gz`,
`phpantom_lsp-${mapping.targetTriple}`,
`phpantom_lsp-${mapping.platformKey}`
];
}