betool-cli 0.4.0
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/bin/betool +17 -0
- package/bin/betool.cmd +3 -0
- package/bin/betool.exe +0 -0
- package/install.js +114 -0
- package/package.json +27 -0
package/bin/betool
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# betool CLI wrapper — delegates to the downloaded binary
|
|
3
|
+
basedir=$(dirname "$(readlink -f "$0" 2>/dev/null || echo "$0")")
|
|
4
|
+
|
|
5
|
+
if [ -f "$basedir/betool.exe" ]; then
|
|
6
|
+
exec "$basedir/betool.exe" "$@"
|
|
7
|
+
elif [ -f "$basedir/../bin/betool" ] && [ "$(uname)" != "Linux" ] && [ "$(uname)" != "Darwin" ]; then
|
|
8
|
+
exec "$basedir/../bin/betool" "$@"
|
|
9
|
+
else
|
|
10
|
+
# Find the binary next to this script
|
|
11
|
+
binary="$basedir/betool"
|
|
12
|
+
if [ ! -f "$binary" ]; then
|
|
13
|
+
echo "betool: binaire introuvable. Relancez 'npm install -g betool-cli'" >&2
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
exec "$binary" "$@"
|
|
17
|
+
fi
|
package/bin/betool.cmd
ADDED
package/bin/betool.exe
ADDED
|
Binary file
|
package/install.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* postinstall script — downloads the correct betool binary for the current platform.
|
|
4
|
+
*
|
|
5
|
+
* Binary naming convention on GitHub releases:
|
|
6
|
+
* betool-windows-amd64.exe
|
|
7
|
+
* betool-linux-amd64
|
|
8
|
+
* betool-darwin-amd64
|
|
9
|
+
* betool-darwin-arm64
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const https = require("https");
|
|
13
|
+
const http = require("http");
|
|
14
|
+
const fs = require("fs");
|
|
15
|
+
const path = require("path");
|
|
16
|
+
const { execSync } = require("child_process");
|
|
17
|
+
|
|
18
|
+
const pkg = require("./package.json");
|
|
19
|
+
const VERSION = pkg.version;
|
|
20
|
+
const REPO = "yossigabay/betool-releases";
|
|
21
|
+
const BASE_URL = `https://github.com/${REPO}/releases/download/v${VERSION}`;
|
|
22
|
+
|
|
23
|
+
const PLATFORM_MAP = {
|
|
24
|
+
win32: "windows",
|
|
25
|
+
linux: "linux",
|
|
26
|
+
darwin: "darwin",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const ARCH_MAP = {
|
|
30
|
+
x64: "amd64",
|
|
31
|
+
arm64: "arm64",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function getBinaryName() {
|
|
35
|
+
const platform = PLATFORM_MAP[process.platform];
|
|
36
|
+
const arch = ARCH_MAP[process.arch];
|
|
37
|
+
|
|
38
|
+
if (!platform) {
|
|
39
|
+
console.error(`Plateforme non supportee : ${process.platform}`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
if (!arch) {
|
|
43
|
+
console.error(`Architecture non supportee : ${process.arch}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
48
|
+
return `betool-${platform}-${arch}${ext}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getLocalBinPath() {
|
|
52
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
53
|
+
return path.join(__dirname, "bin", `betool${ext}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function download(url, dest) {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
const get = url.startsWith("https") ? https.get : http.get;
|
|
59
|
+
|
|
60
|
+
get(url, (res) => {
|
|
61
|
+
// Follow redirects (GitHub releases redirect to S3)
|
|
62
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
63
|
+
return download(res.headers.location, dest).then(resolve).catch(reject);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (res.statusCode !== 200) {
|
|
67
|
+
reject(new Error(`HTTP ${res.statusCode} pour ${url}`));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const file = fs.createWriteStream(dest);
|
|
72
|
+
res.pipe(file);
|
|
73
|
+
file.on("finish", () => {
|
|
74
|
+
file.close();
|
|
75
|
+
resolve();
|
|
76
|
+
});
|
|
77
|
+
file.on("error", reject);
|
|
78
|
+
}).on("error", reject);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function main() {
|
|
83
|
+
const binaryName = getBinaryName();
|
|
84
|
+
const url = `${BASE_URL}/${binaryName}`;
|
|
85
|
+
const dest = getLocalBinPath();
|
|
86
|
+
|
|
87
|
+
// Create bin/ if needed
|
|
88
|
+
const binDir = path.dirname(dest);
|
|
89
|
+
if (!fs.existsSync(binDir)) {
|
|
90
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
console.log(`betool v${VERSION} — telechargement pour ${process.platform}/${process.arch}...`);
|
|
94
|
+
console.log(` ${url}`);
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
await download(url, dest);
|
|
98
|
+
|
|
99
|
+
// Make executable on Unix
|
|
100
|
+
if (process.platform !== "win32") {
|
|
101
|
+
fs.chmodSync(dest, 0o755);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
console.log(` OK — installe dans ${dest}`);
|
|
105
|
+
} catch (err) {
|
|
106
|
+
console.error(`Erreur de telechargement : ${err.message}`);
|
|
107
|
+
console.error(`\nInstallation manuelle :`);
|
|
108
|
+
console.error(` 1. Telecharger ${url}`);
|
|
109
|
+
console.error(` 2. Placer dans ${dest}`);
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "betool-cli",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "betool — Assistant IA conversationnel en CLI",
|
|
5
|
+
"homepage": "https://github.com/yossigabay/betool-code",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/yossigabay/betool-releases.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "UNLICENSED",
|
|
11
|
+
"bin": {
|
|
12
|
+
"betool": "bin/betool"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "node install.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin/",
|
|
19
|
+
"install.js"
|
|
20
|
+
],
|
|
21
|
+
"os": ["win32", "linux", "darwin"],
|
|
22
|
+
"cpu": ["x64", "arm64"],
|
|
23
|
+
"keywords": ["betool", "ai", "cli", "assistant", "code"],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=16"
|
|
26
|
+
}
|
|
27
|
+
}
|