This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbinary.js
80 lines (69 loc) · 1.7 KB
/
binary.js
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
const { Binary } = require("binary-install");
const os = require("os");
const cTable = require("console.table");
const error = msg => {
console.error(msg);
process.exit(1);
};
const { version } = require("./package.json");
const name = "scs";
const supportedPlatforms = [
{
TYPE: "Windows_NT",
ARCHITECTURE: "x64",
RUST_TARGET: "x86_64-windows",
BINARY_NAME: "scs.exe"
},
{
TYPE: "Linux",
ARCHITECTURE: "x64",
RUST_TARGET: "x86_64-linux",
BINARY_NAME: "scs"
},
{
TYPE: "Darwin",
ARCHITECTURE: "x64",
RUST_TARGET: "x86_64-macos",
BINARY_NAME: "scs"
},
{
TYPE: "Darwin",
ARCHITECTURE: "arm64",
RUST_TARGET: "x86_64-macos",
BINARY_NAME: "scs"
}
];
const getPlatformMetadata = () => {
const type = os.type();
const architecture = os.arch();
for (let supportedPlatform of supportedPlatforms) {
if (
type === supportedPlatform.TYPE &&
architecture === supportedPlatform.ARCHITECTURE
) {
return supportedPlatform;
}
}
error(
`Platform with type "${type}" and architecture "${architecture}" is not supported by ${name}.\nYour system must be one of the following:\n\n${cTable.getTable(
supportedPlatforms
)}`
);
};
const getBinary = () => {
const platformMetadata = getPlatformMetadata();
const url = `https://github.com/onboardbase/secure-share/releases/download/v${version}/secure-share-v${ version }-${ platformMetadata.RUST_TARGET }.tar.gz`;
return new Binary(platformMetadata.BINARY_NAME, url, version);
};
const run = () => {
const binary = getBinary();
binary.run();
};
const install = () => {
const binary = getBinary();
binary.install();
};
module.exports = {
install,
run
};