-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpostinstall.js
More file actions
63 lines (52 loc) · 1.78 KB
/
postinstall.js
File metadata and controls
63 lines (52 loc) · 1.78 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
#!/usr/bin/env node
/**
* Post-install script for @stealthsend/stealth-mcp-server.
*
* Downloads a pre-built stealth-mcp-server binary from GitHub Releases
* for the current platform/arch, falling back to a build-from-source
* message if no binary is available.
*/
const { execSync } = require("child_process");
const fs = require("fs");
const os = require("os");
const path = require("path");
const VERSION = require("./package.json").version;
const REPO = "Stealth-R-D-LLC/stealthsend-agent-tools";
const BIN_DIR = path.join(__dirname, "bin");
const PLATFORM_MAP = {
darwin: "darwin",
linux: "linux",
win32: "windows",
};
const ARCH_MAP = {
x64: "amd64",
arm64: "arm64",
};
function main() {
const platform = PLATFORM_MAP[os.platform()];
const arch = ARCH_MAP[os.arch()];
if (!platform || !arch) {
console.log(
`stealth-mcp-server: No pre-built binary for ${os.platform()}/${os.arch()}.`
);
console.log("Build from source: cd stealth-mcp-server && go build .");
return;
}
const ext = platform === "windows" ? ".exe" : "";
const asset = `stealth-mcp-server-${platform}-${arch}${ext}`;
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${asset}`;
const dest = path.join(BIN_DIR, `stealth-mcp-server${ext}`);
fs.mkdirSync(BIN_DIR, { recursive: true });
try {
console.log(`Downloading stealth-mcp-server v${VERSION} for ${platform}/${arch}...`);
execSync(`curl -fsSL "${url}" -o "${dest}"`, { stdio: "inherit" });
if (platform !== "windows") {
fs.chmodSync(dest, 0o755);
}
console.log("stealth-mcp-server installed successfully.");
} catch (err) {
console.log(`Could not download pre-built binary from ${url}`);
console.log("Build from source: cd stealth-mcp-server && go build .");
}
}
main();