Files
u-claw/uclaw-scripts/运行.bat
dongsheng123132 c556f36d92 fix: 5 critical bugs from Codex review
1. Windows: change "node npm.cmd" to "call npm.cmd" (npm.cmd is a
   batch wrapper, not a JS file — can't run with node.exe)
2. Build: use pnpm instead of npm (upstream build script calls pnpm
   subcommands that fail without it); add set -eo pipefail
3. Build: fail explicitly when dist/ not generated instead of || true
4. Run scripts: separate first-time onboard from normal startup
   (was running onboard every time, blocking normal launch)
5. Windows .bat: fix findstr patterns for .env dedup with /r flag
2026-03-09 11:02:14 +08:00

65 lines
1.8 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
chcp 65001 >nul 2>&1
title U-Claw 虾盘 - OpenClaw 一键启动
echo.
echo ╔══════════════════════════════════════╗
echo ║ U-Claw 虾盘 v1.0 ║
echo ║ OpenClaw 一键启动 (Windows) ║
echo ╚══════════════════════════════════════╝
echo.
set "UCLAW_DIR=%~dp0"
set "OPENCLAW_DIR=%UCLAW_DIR%openclaw"
set "NODE_DIR=%UCLAW_DIR%runtime\node-win-x64"
set "NODE_BIN=%NODE_DIR%\node.exe"
set "NPM_BIN=%NODE_DIR%\npm.cmd"
if not exist "%NODE_BIN%" (
echo [错误] 找不到 Node.js 运行环境
echo 请确保 runtime\node-win-x64 目录完整
echo.
pause
exit /b 1
)
for /f "tokens=*" %%v in ('"%NODE_BIN%" --version') do set NODE_VER=%%v
echo Node.js 版本: %NODE_VER%
echo.
set "PATH=%NODE_DIR%;%NODE_DIR%\node_modules\.bin;%PATH%"
if not exist "%OPENCLAW_DIR%\node_modules" (
echo 首次运行,正在安装依赖...
echo (使用淘宝镜像,请稍等)
echo.
cd /d "%OPENCLAW_DIR%"
call "%NPM_BIN%" install --registry=https://registry.npmmirror.com
echo.
echo 依赖安装完成!
echo.
)
if not exist "%OPENCLAW_DIR%\dist" (
echo 首次运行,正在构建...
cd /d "%OPENCLAW_DIR%"
call "%NPM_BIN%" run build 2>nul
echo.
)
echo 正在启动 OpenClaw...
echo.
cd /d "%OPENCLAW_DIR%"
REM 首次运行走 onboard之后直接启动
if not exist "%USERPROFILE%\.openclaw\openclaw.json" (
echo 首次配置...
"%NODE_BIN%" openclaw.mjs onboard --install-daemon
)
echo.
echo 启动 OpenClaw 服务...
"%NODE_BIN%" openclaw.mjs 2>nul || call "%NPM_BIN%" start
echo.
echo OpenClaw 已退出
pause