返回 DeepSeek-TUI-2026
artifacts.js
根目录 / npm / deepseek-tui / scripts / artifacts.js
1 const path = require("path");
2 const os = require("os");
3
4 const CHECKSUM_MANIFEST = "deepseek-artifacts-sha256.txt";
5
6 const ASSET_MATRIX = {
7 linux: {
8 x64: ["deepseek-linux-x64", "deepseek-tui-linux-x64"],
9 arm64: ["deepseek-linux-arm64", "deepseek-tui-linux-arm64"],
10 },
11 darwin: {
12 x64: ["deepseek-macos-x64", "deepseek-tui-macos-x64"],
13 arm64: ["deepseek-macos-arm64", "deepseek-tui-macos-arm64"],
14 },
15 win32: {
16 x64: ["deepseek-windows-x64.exe", "deepseek-tui-windows-x64.exe"],
17 },
18 };
19
20 function detectBinaryNames() {
21 const platform = os.platform();
22 const arch = os.arch();
23 const defaults = ASSET_MATRIX[platform];
24 if (!defaults) {
25 const supported = Object.keys(ASSET_MATRIX).map(p => `'${p}'`).join(', ');
26 throw new Error(
27 `Unsupported platform: ${platform}. Supported platforms: ${supported}.\n\n` +
28 unsupportedBuildHint(),
29 );
30 }
31 const pair = defaults[arch];
32 if (!pair) {
33 const supported = Object.keys(defaults).map(a => `'${a}'`).join(', ');
34 throw new Error(
35 `Unsupported architecture: ${arch} on platform ${platform}. ` +
36 `Supported architectures: ${supported}.\n\n` +
37 unsupportedBuildHint(),
38 );
39 }
40 return {
41 platform,
42 arch,
43 deepseek: pair[0],
44 tui: pair[1],
45 };
46 }
47
48 function unsupportedBuildHint() {
49 return [
50 "No prebuilt binary is available for this platform/architecture combo.",
51 "You can still run DeepSeek TUI by building from source with Cargo:",
52 "",
53 " # Requires Rust 1.88+ (https://rustup.rs)",
54 " cargo install deepseek-tui-cli --locked # provides `deepseek`",
55 " cargo install deepseek-tui --locked # provides `deepseek-tui`",
56 "",
57 "Or build from a checkout:",
58 "",
59 " git clone https://github.com/Hmbown/DeepSeek-TUI.git",
60 " cd DeepSeek-TUI",
61 " cargo install --path crates/cli --locked",
62 " cargo install --path crates/tui --locked",
63 "",
64 "See https://github.com/Hmbown/DeepSeek-TUI/blob/main/docs/INSTALL.md",
65 "for cross-compilation, mirror, and Linux ARM64 specifics.",
66 ].join("\n");
67 }
68
69 function executableName(base, platform) {
70 return platform === "win32" ? `${base}.exe` : base;
71 }
72
73 function releaseBaseUrl(version, repo = "Hmbown/DeepSeek-TUI") {
74 const override =
75 process.env.DEEPSEEK_TUI_RELEASE_BASE_URL || process.env.DEEPSEEK_RELEASE_BASE_URL;
76 if (override) {
77 const trimmed = String(override).trim();
78 return trimmed.endsWith("/") ? trimmed : `${trimmed}/`;
79 }
80 return `https://github.com/${repo}/releases/download/v${version}/`;
81 }
82
83 function releaseAssetUrl(baseName, version, repo = "Hmbown/DeepSeek-TUI") {
84 return new URL(baseName, releaseBaseUrl(version, repo)).toString();
85 }
86
87 function checksumManifestUrl(version, repo = "Hmbown/DeepSeek-TUI") {
88 return releaseAssetUrl(CHECKSUM_MANIFEST, version, repo);
89 }
90
91 function releaseBinaryDirectory() {
92 return path.join(__dirname, "..", "bin", "downloads");
93 }
94
95 function allAssetNames() {
96 const names = [];
97 for (const platformAssets of Object.values(ASSET_MATRIX)) {
98 for (const pair of Object.values(platformAssets)) {
99 names.push(pair[0], pair[1]);
100 }
101 }
102 return Array.from(new Set(names));
103 }
104
105 function allReleaseAssetNames() {
106 return [...allAssetNames(), CHECKSUM_MANIFEST];
107 }
108
109 module.exports = {
110 allAssetNames,
111 allReleaseAssetNames,
112 CHECKSUM_MANIFEST,
113 checksumManifestUrl,
114 detectBinaryNames,
115 executableName,
116 releaseAssetUrl,
117 releaseBaseUrl,
118 releaseBinaryDirectory,
119 };
120
120 lines JAVASCRIPT