kindergarten_java/api-generator.bat

50 lines
1.1 KiB
Batchfile
Raw Permalink Normal View History

@echo off
REM 后端接口变更后自动更新前端 API 规范
REM 使用方式:修改接口后运行 api-generator.bat
echo === 自动更新前端 API 规格 ===
REM 检查前端目录是否存在
if not exist "reading-platform-frontend" (
echo ❌ 错误:前端目录不存在
exit /b 1
)
REM 进入前端目录
cd reading-platform-frontend
REM 检查 npm 是否安装
node --version > NUL 2>&1
if %errorlevel% neq 0 (
echo ❌ 错误:未找到 Node.js请安装 Node.js 18+
exit /b 1
)
REM 检查 package.json 中是否有 api:update 脚本
findstr "api:update" package.json > NUL
if %errorlevel% neq 0 (
echo ❌ 错误package.json 中未找到 api:update 脚本
exit /b 1
)
echo 📦 正在安装依赖...
call npm install
echo 🔄 正在拉取最新 API 规范并生成代码...
call npm run api:update
echo ✅ 完成!
REM 显示修改的文件
echo.
echo 📝 修改的文件:
git status --short
REM 提示用户检查并提交
echo.
echo 💡 请检查生成的文件,然后提交:
echo git add api-spec.yml src/api/generated/
echo git commit -m "chore(api): 同步最新接口规范"
echo git push