#!/usr/bin/env bash
source "$(cd "$(dirname "$0")/.." && pwd)/scripts/_config.sh"
HAR="$REPO_ROOT/flexui-engine/output/flexui_engine.har"
if [ ! -f "$HAR" ]; then
err "HAR not found: $HAR"
err "请先执行 build.sh build-engine --release"
exit 1
fi
log "Opening interactive terminal for ohpm publish..."
echo ""
echo " HAR: $HAR"
echo ""
echo " 新窗口中会提示输入私钥密码,输入后完成发布。"
echo ""
case "$(uname -s)" in
MINGW*|MSYS*|CYGWIN*)
HAR_WIN="$(echo "$HAR" | sed 's|\\|/|g; s|^\([A-Za-z]\):|/\1|')"
if echo "$HAR_WIN" | grep -q '^/[a-zA-Z]/'; then
HAR_WIN="$(echo "$HAR_WIN" | sed 's|^/\([a-zA-Z]\)/|\1:/|')"
fi
powershell -Command "Start-Process powershell -ArgumentList '-NoExit', '-Command', 'ohpm publish $HAR_WIN'"
;;
Darwin)
osascript -e "tell app \"Terminal\" to do script \"ohpm publish '$HAR'; echo ''; echo 'Press Ctrl+C to close...'; read\""
;;
Linux)
if command -v gnome-terminal &>/dev/null; then
gnome-terminal -- bash -c "ohpm publish '$HAR'; read -p 'Press Enter to close...'"
elif command -v xterm &>/dev/null; then
xterm -e "ohpm publish '$HAR'; read -p 'Press Enter to close...'"
else
warn "未找到终端模拟器,直接执行 ohpm publish..."
ohpm publish "$HAR"
fi
;;
*)
warn "未知平台,直接执行 ohpm publish..."
ohpm publish "$HAR"
;;
esac