61 lines
1.3 KiB
Bash
61 lines
1.3 KiB
Bash
|
|
#!/bin/bash
|
|||
|
|
|
|||
|
|
echo "构建TSP智能助手前端..."
|
|||
|
|
echo
|
|||
|
|
|
|||
|
|
# 检查Node.js环境
|
|||
|
|
echo "检查Node.js环境..."
|
|||
|
|
if ! command -v node &> /dev/null; then
|
|||
|
|
echo "错误: 未找到Node.js,请先安装Node.js"
|
|||
|
|
echo "安装命令:"
|
|||
|
|
echo " Ubuntu/Debian: sudo apt update && sudo apt install nodejs npm"
|
|||
|
|
echo " CentOS/RHEL: sudo yum install nodejs npm"
|
|||
|
|
echo " 或访问: https://nodejs.org/"
|
|||
|
|
exit 1
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
# 检查npm环境
|
|||
|
|
echo "检查npm环境..."
|
|||
|
|
if ! command -v npm &> /dev/null; then
|
|||
|
|
echo "错误: 未找到npm,请检查Node.js安装"
|
|||
|
|
exit 1
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
echo "Node.js版本: $(node --version)"
|
|||
|
|
echo "npm版本: $(npm --version)"
|
|||
|
|
echo
|
|||
|
|
|
|||
|
|
# 进入前端目录
|
|||
|
|
cd frontend
|
|||
|
|
|
|||
|
|
# 检查依赖包
|
|||
|
|
echo "检查依赖包..."
|
|||
|
|
if [ ! -d "node_modules" ]; then
|
|||
|
|
echo "安装依赖包..."
|
|||
|
|
npm install
|
|||
|
|
if [ $? -ne 0 ]; then
|
|||
|
|
echo "错误: 依赖包安装失败"
|
|||
|
|
exit 1
|
|||
|
|
fi
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
# 运行类型检查
|
|||
|
|
echo "运行类型检查..."
|
|||
|
|
npm run type-check
|
|||
|
|
if [ $? -ne 0 ]; then
|
|||
|
|
echo "警告: 类型检查失败,但继续构建..."
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
# 构建生产版本
|
|||
|
|
echo "构建生产版本..."
|
|||
|
|
npm run build
|
|||
|
|
if [ $? -ne 0 ]; then
|
|||
|
|
echo "错误: 构建失败"
|
|||
|
|
exit 1
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
echo
|
|||
|
|
echo "构建完成!"
|
|||
|
|
echo "构建文件已输出到: ../src/web/static/dist"
|
|||
|
|
echo
|