fix: 添加setup.sh环境安装脚本, 修复start.sh依赖检查

- 新增 setup.sh: 一键安装 Node.js/Python依赖/构建前端/创建.env
- start.sh: 增加 Python 依赖检查, npx 不可用时给出明确提示
- 解决新机器上 npx not found 和 backend.main import 失败问题
This commit is contained in:
cnbugs
2026-07-25 10:40:41 +08:00
parent d5d7e45ded
commit 98b19f542e
2 changed files with 71 additions and 5 deletions
+14 -5
View File
@@ -1,7 +1,6 @@
#!/bin/bash
# K8S 智能诊断平台 - 一键启动脚本
set -e
cd "$(dirname "$0")"
PORT=${PORT:-8900}
@@ -24,13 +23,23 @@ if [ -f "$HOME/.kube/config" ]; then
echo "✅ kubeconfig: ~/.kube/config"
else
echo "⚠️ 未找到 ~/.kube/config,诊断将返回空结果"
echo " 请将 kubeconfig 放到 ~/.kube/config"
fi
# 检查 Python 依赖
if ! python3 -c "import fastapi, uvicorn" 2>/dev/null; then
echo "❌ 缺少 Python 依赖,请先运行: ./setup.sh"
exit 1
fi
# 检查前端构建
if [ ! -d "frontend/dist" ]; then
echo "📦 构建前端..."
cd frontend && npx vite build && cd ..
if [ ! -f "frontend/dist/index.html" ]; then
if command -v npx &>/dev/null; then
echo "📦 构建前端..."
cd frontend && npx vite build && cd ..
else
echo "❌ 前端未构建且 npx 不可用,请先运行: ./setup.sh"
exit 1
fi
fi
echo ""