Files
wecom_it_smart_desk/scripts/deploy-v1.2.ps1
T
Simon 7864ab404b feat(scripts): 收纳运维/部署/修复/调试脚本到 scripts/ 目录
**目录结构**:
- scripts/                 顶层运维/工具脚本(20 个)
- scripts/deploy/          一键部署脚本(deploy_*.py / upload_*.py / redeploy.py 等 8 个)
- scripts/fix/             一次性修复脚本(fix_*.py / fix_*.cypher / fix_*.sql 等 9 个)
- scripts/debug/           调试脚本集合(check_*.py/sql、test_*.py、debug_*.py 等 42 个)

**ops-tools/jms_ops.py**:jumpserver-ops skill 默认路径修复
- 从 'jumpserver-automation-shareable' 改为 'jumpserver-ops'
- 同步更新注释(优先 JP_SKILL_DIR 环境变量)

**典型脚本用途**:
- scripts/deploy-v1.2.ps1 / -staging.ps1:一键部署 v1.2 到生产 / staging
- scripts/init_quick_rules.sql:quick_rules 表初始数据
- scripts/gen_admin_token.py:生成 admin JWT token(调试用)
- scripts/build-and-verify.sh:v1.1 实施验证脚本
- scripts/verify_*.sh / .py:API/quick_rules 验证
- scripts/fix/*.py:环境修复(compose、env_key、itsm_bridge 等)

合计 81 文件 + 3317 行 / - 1 行
2026-08-03 18:48:02 +08:00

133 lines
6.4 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================================
# REQ-会话-001 v1.2 一键部署脚本
# 用途:从本地代码 commit 到 H5 生产环境上线全流程
# 用法:在 Windows TerminalPowerShell)执行 `.\deploy-v1.2.ps1`
# 前提:v2_ops.py status 显示 cache 有效,否则先跑 `login`
# ============================================================================
#Requires -Version 5.1
# 配置区(按需修改) ===========================================================
$WORK_DIR = "D:\资料\03-项目开发\wecom_it_smart_desk"
$ASCII_COPY = "D:\dev\wecom"
$FRONTEND_BUILD_DIR = "$ASCII_COPY\src\frontend-h5"
$PACKAGE_DIR = "$ASCII_COPY\packages"
$PYTHON_BIN = "C:\Users\simon\.workbuddy\binaries\python\versions\3.13.12\python.exe"
$V2_OPS = "C:\Users\simon\.workbuddy\skills\jumpserver-V2\scripts\v2_ops.py"
$DEPLOY_REMOTE_DIR = "/opt/wecom-it-desk/frontend-h5"
$TMP_ZIP_NAME = "h5-dist-v1.2.zip"
$H5_URL = "https://itsupport.servyou.com.cn/h5/"
# ============================================================================
# Step 1:本地代码 commit
# ============================================================================
Write-Host "`n[Step 1/6] 本地代码 commit..." -ForegroundColor Cyan
Set-Location $WORK_DIR
$gitStatus = git status --short
if ([string]::IsNullOrWhiteSpace($gitStatus)) {
Write-Host " ℹ️ 无新改动(可能已 commit),跳过 commit 步骤" -ForegroundColor Yellow
} else {
Write-Host " 待提交文件:" -ForegroundColor Gray
Write-Host $gitStatus
git add -A
git commit -M "[REQ-会话-001] 员工结束会话 v1.2:6 态按钮 + 4 种引导语 + 顶部按钮 AI 场景互斥 + 重新打开按钮
- InputBar.vue: 6 态扩展(移除 hidden / 恢复 end / 新增 reopen
- ChatPanel.vue: 顶部按钮 v-show + 文案修订
- conversation.ts (store): showHeaderExitBtn + canReopen + reopenCurrentConversation
- conversation.ts (api): ConversationInfo + resolved_at
- inputBarGuideText.ts: 新增 helper(避免 P1 Bug 回归)
- 测试: 23 store + 15 helper = 38 用例全 PASS
QA 第 1 轮发现 P1 BugInputBar.vue:337 误用 'active' 而非 'ai_handling'),
抽离 helper 修复并加 2 个回归保护用例。AC1-AC11 全部 PASS(含修复后)。"
if ($LASTEXITCODE -ne 0) {
Write-Host " ❌ commit 失败,请检查 git 状态" -ForegroundColor Red
exit 1
}
Write-Host " ✅ commit 成功" -ForegroundColor Green
}
# ============================================================================
# Step 2:代码同步到 ASCII 副本 + 前端 build + 打包
# ============================================================================
Write-Host "`n[Step 2/6] 同步代码到 ASCII 副本 + 前端 build..." -ForegroundColor Cyan
if (-not (Test-Path $ASCII_COPY)) {
Write-Host " ❌ ASCII 副本路径不存在: $ASCII_COPY" -ForegroundColor Red
exit 1
}
# 同步 src/frontend-h5/src(排除 node_modules 和 dist
robocopy "$WORK_DIR\src\frontend-h5\src" "$FRONTEND_BUILD_DIR\src" /MIR /XD node_modules dist /NFL /NDL /NJH /NJS | Out-Null
robocopy "$WORK_DIR\src\frontend-h5\package.json" "$FRONTEND_BUILD_DIR\package.json" /NFL /NDL /NJH /NJS | Out-Null
# build
Set-Location $FRONTEND_BUILD_DIR
npm run build 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Host " ❌ npm run build 失败" -ForegroundColor Red
exit 1
}
Write-Host " ✅ 前端 build 成功" -ForegroundColor Green
# 打包
if (-not (Test-Path $PACKAGE_DIR)) {
New-Item -ItemType Directory -Path $PACKAGE_DIR -Force | Out-Null
}
Compress-Archive -Path "$FRONTEND_BUILD_DIR\dist" -DestinationPath "$PACKAGE_DIR\$TMP_ZIP_NAME" -Force
Write-Host " ✅ 打包完成: $PACKAGE_DIR\$TMP_ZIP_NAME" -ForegroundColor Green
# ============================================================================
# Step 3:上传到 SFTP 虚拟路径 /tmp
# ============================================================================
Write-Host "`n[Step 3/6] 上传到 SFTP 虚拟路径..." -ForegroundColor Cyan
& $PYTHON_BIN $V2_OPS upload "$PACKAGE_DIR\$TMP_ZIP_NAME" $TMP_ZIP_NAME
if ($LASTEXITCODE -ne 0) {
Write-Host " ❌ 上传失败" -ForegroundColor Red
exit 1
}
Write-Host " ✅ 上传成功" -ForegroundColor Green
# ============================================================================
# Step 4:服务器侧部署
# ============================================================================
Write-Host "`n[Step 4/6] 服务器侧部署..." -ForegroundColor Cyan
$deployCmdsPath = "$ASCII_COPY\deploy_cmds_v1.2.txt"
if (-not (Test-Path $deployCmdsPath)) {
Write-Host " ❌ 服务器命令文件不存在: $deployCmdsPath" -ForegroundColor Red
Write-Host " 请先创建 deploy_cmds_v1.2.txt(参考部署清单 Step 4" -ForegroundColor Yellow
exit 1
}
& $PYTHON_BIN $V2_OPS batch $deployCmdsPath
if ($LASTEXITCODE -ne 0) {
Write-Host " ❌ 服务器部署失败,可执行回滚" -ForegroundColor Red
exit 1
}
Write-Host " ✅ 服务器部署成功" -ForegroundColor Green
# ============================================================================
# Step 5:验证 HTTP 200
# ============================================================================
Write-Host "`n[Step 5/6] 验证 H5 URL..." -ForegroundColor Cyan
& $PYTHON_BIN $V2_OPS exec "curl -I $H5_URL"
if ($LASTEXITCODE -ne 0) {
Write-Host " ⚠️ HTTP 验证失败,请人工检查" -ForegroundColor Yellow
}
# 检查前端 dist 文件
& $PYTHON_BIN $V2_OPS exec "ls $DEPLOY_REMOTE_DIR/dist/assets/ | head -20"
# ============================================================================
# Step 6:完成
# ============================================================================
Write-Host "`n[Step 6/6] 部署完成" -ForegroundColor Cyan
Write-Host " 📋 请按以下清单验证业务:" -ForegroundColor Gray
Write-Host " 1. H5 打开 → AI 对话 <3 轮 → 引导语'请继续描述您的问题或需求'显示 ✅" -ForegroundColor Gray
Write-Host " 2. AI 对话 ≥3 轮 → 按钮'🎧 人工坐席' + 顶部红色退出按钮可见 ✅" -ForegroundColor Gray
Write-Host " 3. 坐席服务中(mock)→ 操作按钮'📴 结束咨询' + 顶部按钮隐藏 ✅" -ForegroundColor Gray
Write-Host " 📞 如发现问题立即回滚:" -ForegroundColor Yellow
Write-Host " & $PYTHON_BIN $V2_OPS exec `"rm -rf $DEPLOY_REMOTE_DIR/dist && mv $DEPLOY_REMOTE_DIR/dist.v1.1.bak $DEPLOY_REMOTE_DIR/dist`" -ForegroundColor Yellow