From 1093908e8765a42d86845a0b0232675248ca2be2 Mon Sep 17 00:00:00 2001 From: panda <1415243231@qq.com> Date: Mon, 25 May 2026 23:20:54 +0800 Subject: [PATCH] add: rebuild.ps1 for quick local packaging --- deploy/rebuild.ps1 | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 deploy/rebuild.ps1 diff --git a/deploy/rebuild.ps1 b/deploy/rebuild.ps1 new file mode 100644 index 0000000..aaaf697 --- /dev/null +++ b/deploy/rebuild.ps1 @@ -0,0 +1,31 @@ +$ErrorActionPreference = 'Stop' +$ProjectRoot = 'D:\Idea Project\publish' +$tmpDir = "$env:TEMP\publish_deploy_$((Get-Date).ToString('yyyyMMdd_HHmmss'))" + +Write-Host '=== 打包 publish_deploy.zip ===' -ForegroundColor Cyan + +# 1. 准备目录 +New-Item -ItemType Directory -Path "$tmpDir\frontend" -Force | Out-Null + +# 2. 复制前端构建产物 +Copy-Item "$ProjectRoot\dist\index.html" "$tmpDir\frontend\" -Force +Copy-Item "$ProjectRoot\dist\assets" "$tmpDir\frontend\" -Recurse -Force +Copy-Item "$ProjectRoot\server.js" "$tmpDir\frontend\" -Force +Write-Host ' [OK] 前端文件就位' -ForegroundColor Green + +# 3. 复制后端 jar +Copy-Item "$ProjectRoot\deploy\baota\app.jar" "$tmpDir\" -Force +Write-Host ' [OK] 后端 jar 就位' -ForegroundColor Green + +# 4. 打包 +$outputZip = "$ProjectRoot\deploy\publish_deploy.zip" +Compress-Archive -Path "$tmpDir\*" -DestinationPath $outputZip -Force +$size = [math]::Round((Get-Item $outputZip).Length / 1MB, 1) +Write-Host " [OK] 打包完成: $size MB" -ForegroundColor Green + +# 5. 清理 +Remove-Item $tmpDir -Recurse -Force -ErrorAction SilentlyContinue + +Write-Host '' +Write-Host '=== 完成 ===' -ForegroundColor Green +Write-Host "文件位置: $outputZip"