baro-ai 0.10.0 → 0.10.2
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/baro +8 -2
- package/bin/baro.cmd +8 -2
- package/package.json +1 -1
- package/scripts/postinstall.js +11 -6
package/bin/baro
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env sh
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
3
|
+
NATIVE="$SCRIPT_DIR/baro-native"
|
|
4
|
+
if [ -x "$NATIVE" ]; then
|
|
5
|
+
exec "$NATIVE" "$@"
|
|
6
|
+
else
|
|
7
|
+
echo "baro: binary not installed. Run: npm rebuild baro-ai" >&2
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
package/bin/baro.cmd
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
@echo off
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
set "SCRIPT_DIR=%~dp0"
|
|
3
|
+
set "NATIVE=%SCRIPT_DIR%baro-native.exe"
|
|
4
|
+
if exist "%NATIVE%" (
|
|
5
|
+
"%NATIVE%" %*
|
|
6
|
+
) else (
|
|
7
|
+
echo baro: binary not installed. Run: npm rebuild baro-ai 1>&2
|
|
8
|
+
exit /b 1
|
|
9
|
+
)
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* Postinstall script - downloads the baro binary for the current platform.
|
|
4
|
-
* Binary is fetched from GitHub Releases
|
|
4
|
+
* Binary is fetched from GitHub Releases and saved as baro-native (not baro)
|
|
5
|
+
* so the package directory only contains small npm-managed files, avoiding
|
|
6
|
+
* ENOTEMPTY errors on upgrade.
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
9
|
import * as fs from "fs"
|
|
@@ -12,7 +14,7 @@ import * as https from "https"
|
|
|
12
14
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
13
15
|
const PACKAGE_ROOT = path.resolve(__dirname, "..")
|
|
14
16
|
const BIN_DIR = path.join(PACKAGE_ROOT, "bin")
|
|
15
|
-
const
|
|
17
|
+
const NATIVE_NAME = process.platform === "win32" ? "baro-native.exe" : "baro-native"
|
|
16
18
|
const REPO = "Lotus015/baro"
|
|
17
19
|
|
|
18
20
|
function getPlatformKey() {
|
|
@@ -64,23 +66,26 @@ async function download(url, dest) {
|
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
async function main() {
|
|
67
|
-
const
|
|
69
|
+
const nativePath = path.join(BIN_DIR, NATIVE_NAME)
|
|
68
70
|
const platformKey = getPlatformKey()
|
|
69
71
|
const version = getVersion()
|
|
70
72
|
|
|
71
73
|
const artifactName = process.platform === "win32"
|
|
72
74
|
? `baro-${platformKey}.exe`
|
|
73
|
-
:
|
|
75
|
+
: `baro-${platformKey}`
|
|
74
76
|
const url = `https://github.com/${REPO}/releases/download/v${version}/${artifactName}`
|
|
75
77
|
|
|
76
78
|
console.log(`Downloading baro for ${platformKey}...`)
|
|
77
79
|
|
|
78
80
|
fs.mkdirSync(BIN_DIR, { recursive: true })
|
|
79
81
|
|
|
82
|
+
// Clean up old binary (from previous versions or failed installs)
|
|
83
|
+
try { fs.unlinkSync(nativePath) } catch {}
|
|
84
|
+
|
|
80
85
|
try {
|
|
81
|
-
await download(url,
|
|
86
|
+
await download(url, nativePath)
|
|
82
87
|
if (process.platform !== "win32") {
|
|
83
|
-
fs.chmodSync(
|
|
88
|
+
fs.chmodSync(nativePath, 0o755)
|
|
84
89
|
}
|
|
85
90
|
console.log(`baro installed successfully`)
|
|
86
91
|
} catch (err) {
|