# 本地构建前端并提示提交 dist（开发机执行，服务器不构建）
$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
Set-Location (Join-Path $Root "frontend")

Write-Host "[INFO] 安装依赖并构建前端…"
npm ci
npm run build

if (-not (Test-Path "dist\index.html")) {
    Write-Error "构建失败：未生成 dist\index.html"
}

Write-Host ""
Write-Host "构建完成。请提交并推送："
Write-Host "  git add frontend/dist"
Write-Host '  git commit -m "build: update frontend dist"'
Write-Host "  git push"
Write-Host ""
Write-Host "服务器更新："
Write-Host "  bash /opt/secondary-school-grade-archive/deploy/update.sh"
