watchmen-cli 1.0.7 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install.js +15 -29
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -9,30 +9,30 @@ const { createHash } = require("crypto");
|
|
|
9
9
|
const { execSync } = require("child_process");
|
|
10
10
|
|
|
11
11
|
const VERSION = require("./package.json").version;
|
|
12
|
-
const
|
|
12
|
+
const DOWNLOAD_BASE = "https://releases.trywatchmen.cloud/download/community";
|
|
13
13
|
|
|
14
|
-
// Platform →
|
|
14
|
+
// Platform → download path mapping
|
|
15
15
|
const PLATFORMS = {
|
|
16
|
-
"darwin-arm64": "
|
|
17
|
-
"darwin-x64": "
|
|
18
|
-
"linux-x64": "
|
|
19
|
-
"win32-x64": "
|
|
16
|
+
"darwin-arm64": "macos-arm64",
|
|
17
|
+
"darwin-x64": "macos-arm64", // Rosetta 2 fallback
|
|
18
|
+
"linux-x64": "linux-x86_64",
|
|
19
|
+
"win32-x64": "windows-x86_64",
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
function getPlatformKey() {
|
|
23
23
|
return `${process.platform}-${process.arch}`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function
|
|
26
|
+
function getPlatformSlug() {
|
|
27
27
|
const key = getPlatformKey();
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
28
|
+
const slug = PLATFORMS[key];
|
|
29
|
+
if (!slug) {
|
|
30
30
|
console.error(
|
|
31
31
|
`Unsupported platform: ${key}\nSupported: ${Object.keys(PLATFORMS).join(", ")}`
|
|
32
32
|
);
|
|
33
33
|
process.exit(1);
|
|
34
34
|
}
|
|
35
|
-
return
|
|
35
|
+
return slug;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function download(url) {
|
|
@@ -57,7 +57,7 @@ function download(url) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
async function main() {
|
|
60
|
-
const
|
|
60
|
+
const platformSlug = getPlatformSlug();
|
|
61
61
|
const binDir = path.join(__dirname, "bin");
|
|
62
62
|
const binName = process.platform === "win32" ? "wm.exe" : "wm";
|
|
63
63
|
const binPath = path.join(binDir, binName);
|
|
@@ -73,28 +73,14 @@ async function main() {
|
|
|
73
73
|
} catch {}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
const
|
|
76
|
+
// Pre-signed URL API redirects to S3
|
|
77
|
+
const url = `${DOWNLOAD_BASE}/${platformSlug}`;
|
|
78
78
|
|
|
79
79
|
console.log(`Downloading wm v${VERSION} for ${getPlatformKey()}...`);
|
|
80
80
|
console.log(` ${url}`);
|
|
81
81
|
|
|
82
|
-
// Download binary
|
|
83
|
-
const
|
|
84
|
-
download(url),
|
|
85
|
-
download(shaUrl).catch(() => null), // SHA256 file may not exist yet
|
|
86
|
-
]);
|
|
87
|
-
|
|
88
|
-
// Verify checksum if available
|
|
89
|
-
if (shaData) {
|
|
90
|
-
const expectedSha = shaData.toString("utf8").trim().split(/\s+/)[0];
|
|
91
|
-
const actualSha = createHash("sha256").update(binary).digest("hex");
|
|
92
|
-
if (actualSha !== expectedSha) {
|
|
93
|
-
console.error(`SHA256 mismatch!\n expected: ${expectedSha}\n actual: ${actualSha}`);
|
|
94
|
-
process.exit(1);
|
|
95
|
-
}
|
|
96
|
-
console.log(` SHA256 verified: ${actualSha.slice(0, 12)}...`);
|
|
97
|
-
}
|
|
82
|
+
// Download binary (URL redirects to pre-signed S3 URL)
|
|
83
|
+
const binary = await download(url);
|
|
98
84
|
|
|
99
85
|
// Write binary
|
|
100
86
|
fs.mkdirSync(binDir, { recursive: true });
|