From f696e0d35db2f339a56c34f91b47a3882164918e Mon Sep 17 00:00:00 2001 From: jingrow Date: Mon, 3 Nov 2025 21:30:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0dev.sh=E9=87=8C=E9=9D=A2uv?= =?UTF-8?q?=E7=9A=84=E6=A3=80=E6=B5=8B=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/dev.sh b/dev.sh index ea3c03a..0bf8805 100755 --- a/dev.sh +++ b/dev.sh @@ -69,6 +69,18 @@ cleanup() { success "清理完成" } +# 确保 uv 可用:最先执行 +ensure_uv() { + if command -v uv &> /dev/null; then + return 0 + fi + warn "uv 未安装,将尝试自动安装" + install_uv || { + error "自动安装 uv 失败,请手动安装: curl -fsSL https://astral.sh/uv/install.sh | sh" + exit 1 + } +} + # 检查Redis check_redis() { if redis-cli ping &> /dev/null; then @@ -95,13 +107,8 @@ check_deps() { info "检查依赖..." check_cmd node || exit 1 - if ! command -v uv &> /dev/null; then - warn "uv 未安装" - install_uv || { - error "自动安装 uv 失败,请手动安装: curl -fsSL https://astral.sh/uv/install.sh | sh" - exit 1 - } - fi + # 这里假设 ensure_uv 已经在更早阶段被调用 + check_cmd uv || exit 1 # 检查前端依赖 if [ ! -d "apps/jingrow/frontend/node_modules" ]; then @@ -150,6 +157,7 @@ build_reload_dirs() { # 启动所有服务 start_all() { info "启动开发环境..." + ensure_uv cleanup check_redis check_deps @@ -175,6 +183,7 @@ start_all() { # 只启动前端 start_frontend() { info "启动前端..." + ensure_uv cleanup check_deps cd apps/jingrow/frontend && npm run dev @@ -183,6 +192,7 @@ start_frontend() { # 只启动后端 start_backend() { info "启动后端..." + ensure_uv cleanup check_redis check_deps