fix: 改用 shell wrapper 代替 bun compile(bun 1.x compile 有 bug)

install.sh 生成 shell wrapper 脚本 exec bun run cli.ts,
而非 bun build --compile(生成空文件)。
auth-cli.ts 修复 HOME 环境变量缺失时 homedir() 返回空的问题。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ywkj 2026-03-20 18:30:56 +08:00
parent f079b68559
commit ff8e74e0aa
4 changed files with 11 additions and 8 deletions

1
.gitignore vendored
View File

@ -1,2 +1 @@
node_modules/
auth-rt

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Compile auth-rt CLI binary and install to ~/.openclaw/bin/
# Install auth-rt CLI wrapper to ~/.openclaw/bin/
#
# Usage:
# ./install.sh
@ -9,10 +9,14 @@ set -euo pipefail
cd "$(dirname "$0")"
BIN_DIR="${1:-$HOME/.openclaw/bin}"
SELF_DIR="$(pwd)"
mkdir -p "$BIN_DIR"
echo "Compiling auth-rt..."
bun build --compile src/cli.ts --outfile "$BIN_DIR/auth-rt"
cat > "$BIN_DIR/auth-rt" <<WRAPPER
#!/usr/bin/env bash
exec bun run "$SELF_DIR/src/cli.ts" "\$@"
WRAPPER
chmod +x "$BIN_DIR/auth-rt"
echo "Installed: $BIN_DIR/auth-rt"
echo "Installed: $BIN_DIR/auth-rt$SELF_DIR/src/cli.ts"
echo "Ensure $BIN_DIR is in your PATH."

View File

@ -13,8 +13,7 @@
},
"scripts": {
"build": "tsc",
"compile": "bun build --compile src/cli.ts --outfile auth-rt",
"clean": "rm -rf dist auth-rt"
"clean": "rm -rf dist"
},
"keywords": [
"auth",

View File

@ -18,8 +18,9 @@ import { spawnSync } from 'child_process';
import * as path from 'path';
import * as os from 'os';
const home = process.env.HOME || os.homedir();
const AUTH_RT_BIN = process.env.AUTH_RT_BIN
|| path.join(os.homedir(), '.openclaw', 'bin', 'auth-rt');
|| path.join(home, '.openclaw', 'bin', 'auth-rt');
export interface ApiResponse {
status: number;