fix: refine earth hud structure and bun startup flow
- refactor the /earth HUD into class-first CSS layers with dedicated base, hud, and toolbar responsibilities - clean up Earth markup and runtime DOM hooks so shared panel, toolbar, tooltip, and status classes stay consistent after dynamic updates - keep HUD scaling configurable through extracted constants and remove leftover legacy panel/toolbar styling paths - make planet.sh self-bootstrap Bun and uv by prepending local runtime bins to PATH and auto-installing missing tools in fresh environments - document Bun as the frontend package manager of record and sync repository version metadata to 0.24.1
This commit is contained in:
90
planet.sh
90
planet.sh
@@ -60,6 +60,24 @@ FRONTEND_RUNTIME_BIN="${FRONTEND_RUNTIME_BIN:-}"
|
||||
FRONTEND_RUNTIME_SOURCE="${FRONTEND_RUNTIME_SOURCE:-}"
|
||||
FRONTEND_PID_FILE="/tmp/planet_frontend.pid"
|
||||
|
||||
prepend_path_once() {
|
||||
local path_entry="$1"
|
||||
[ -n "$path_entry" ] || return 0
|
||||
[ -d "$path_entry" ] || return 0
|
||||
|
||||
case ":$PATH:" in
|
||||
*":$path_entry:"*) ;;
|
||||
*) export PATH="$path_entry:$PATH" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
ensure_local_runtime_bins_on_path() {
|
||||
prepend_path_once "$HOME/.local/bin"
|
||||
prepend_path_once "$HOME/.bun/bin"
|
||||
}
|
||||
|
||||
ensure_local_runtime_bins_on_path
|
||||
|
||||
# Shell / Docker helpers
|
||||
compose_up() {
|
||||
if docker compose version >/dev/null 2>&1; then
|
||||
@@ -320,12 +338,62 @@ run_with_retry() {
|
||||
return 1
|
||||
}
|
||||
|
||||
install_uv_if_needed() {
|
||||
if command -v uv >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
set_wait_detail "未找到 uv,准备自动安装"
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
|
||||
if ! run_with_retry \
|
||||
"$DEPENDENCY_INSTALL_MAX_RETRIES" \
|
||||
"$DEPENDENCY_INSTALL_RETRY_INTERVAL" \
|
||||
"uv 安装失败,已重试 ${DEPENDENCY_INSTALL_MAX_RETRIES} 次" \
|
||||
"安装 uv" \
|
||||
sh -c 'curl -LsSf https://astral.sh/uv/install.sh | sh'; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ensure_local_runtime_bins_on_path
|
||||
|
||||
if ! command -v uv >/dev/null 2>&1; then
|
||||
log_error "uv 安装完成后仍未找到命令,请检查 ~/.local/bin"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_bun_if_needed() {
|
||||
if command -v bun >/dev/null 2>&1 || [ -x "$HOME/.bun/bin/bun" ]; then
|
||||
ensure_local_runtime_bins_on_path
|
||||
return 0
|
||||
fi
|
||||
|
||||
set_wait_detail "未找到 bun,准备自动安装"
|
||||
mkdir -p "$HOME/.bun"
|
||||
|
||||
if ! run_with_retry \
|
||||
"$DEPENDENCY_INSTALL_MAX_RETRIES" \
|
||||
"$DEPENDENCY_INSTALL_RETRY_INTERVAL" \
|
||||
"bun 安装失败,已重试 ${DEPENDENCY_INSTALL_MAX_RETRIES} 次" \
|
||||
"安装 bun" \
|
||||
sh -c 'curl -fsSL https://bun.sh/install | bash'; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ensure_local_runtime_bins_on_path
|
||||
|
||||
if [ ! -x "$HOME/.bun/bin/bun" ] && ! command -v bun >/dev/null 2>&1; then
|
||||
log_error "bun 安装完成后仍未找到命令,请检查 ~/.bun/bin"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_uv_backend_deps() {
|
||||
set_wait_detail "检查后端 uv 环境"
|
||||
|
||||
if ! command -v uv >/dev/null 2>&1; then
|
||||
log_error "未找到 uv,请先安装 uv 并加入 PATH"
|
||||
exit 1
|
||||
install_uv_if_needed
|
||||
fi
|
||||
|
||||
cd "$SCRIPT_DIR"
|
||||
@@ -357,6 +425,15 @@ resolve_frontend_runtime() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
ensure_local_runtime_bins_on_path
|
||||
|
||||
if [ -x "$HOME/.bun/bin/bun" ]; then
|
||||
FRONTEND_RUNTIME_BIN="$HOME/.bun/bin/bun"
|
||||
FRONTEND_RUNTIME_SOURCE="local-install"
|
||||
WAIT_SPINNER_DETAIL="已找到 ~/.bun/bin/bun"
|
||||
return 0
|
||||
fi
|
||||
|
||||
set_wait_detail "读取 zsh 配置中的 bun"
|
||||
if resolve_bun_from_shell_configs "zsh" "$HOME/.zshrc" "$HOME/.zprofile"; then
|
||||
WAIT_SPINNER_DETAIL="已找到 zsh 配置中的 bun"
|
||||
@@ -413,9 +490,12 @@ ensure_frontend_deps() {
|
||||
|
||||
set_wait_detail "解析前端运行时"
|
||||
if ! resolve_frontend_runtime; then
|
||||
close_wait_session_context "$owns_wait_session"
|
||||
log_error "未找到 bun,已按 zsh > powershell 顺序检查启动配置"
|
||||
exit 1
|
||||
install_bun_if_needed
|
||||
if ! resolve_frontend_runtime; then
|
||||
close_wait_session_context "$owns_wait_session"
|
||||
log_error "未找到 bun,自动安装后仍无法解析运行时"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
cd "$SCRIPT_DIR/frontend"
|
||||
|
||||
Reference in New Issue
Block a user