修复指尖管理师上线配置

This commit is contained in:
2026-06-22 20:39:51 +08:00
parent 9400e53fe9
commit a53b27ef20
7 changed files with 425 additions and 459 deletions
+77 -47
View File
@@ -12,12 +12,13 @@ $releaseDir = Join-Path $releaseRoot $timestamp
$backendDir = Join-Path $releaseDir "backend"
$frontendDir = Join-Path $releaseDir "frontend"
$miniProgramDir = Join-Path $releaseDir "miniprograms"
$sqlPath = Join-Path $repoRoot "scripts\sql\init\YumiNail.sql"
function Resolve-Maven {
param([string]$PreferredPath)
if ($PreferredPath -and (Test-Path $PreferredPath)) {
return $PreferredPath
if ($PreferredPath -and (Test-Path -LiteralPath $PreferredPath)) {
return (Resolve-Path -LiteralPath $PreferredPath).Path
}
$fromPath = Get-Command mvn.cmd -ErrorAction SilentlyContinue
@@ -25,22 +26,33 @@ function Resolve-Maven {
return $fromPath.Source
}
$fallback = "D:\开发\apache-maven-3.9.9\bin\mvn.cmd"
if (Test-Path $fallback) {
return $fallback
$fromPath = Get-Command mvn -ErrorAction SilentlyContinue
if ($fromPath) {
return $fromPath.Source
}
throw "Cannot find mvn.cmd. Pass -MavenPath with an absolute Maven path."
throw "找不到 Maven,请通过 -MavenPath 传入 Maven 可执行文件绝对路径。"
}
function Invoke-Step {
function Invoke-Native {
param(
[string]$Name,
[scriptblock]$Script
[string]$FilePath,
[string[]]$Arguments,
[string]$WorkingDirectory
)
Write-Host "==> $Name"
& $Script
Write-Host ">> $FilePath $($Arguments -join ' ')"
$previousLocation = Get-Location
try {
Set-Location -LiteralPath $WorkingDirectory
& $FilePath @Arguments
if ($LASTEXITCODE -ne 0) {
throw "命令执行失败,退出码 ${LASTEXITCODE}:$FilePath"
}
}
finally {
Set-Location $previousLocation
}
}
function Copy-Directory {
@@ -49,12 +61,32 @@ function Copy-Directory {
[string]$Destination
)
if (!(Test-Path $Source)) {
throw "Missing source directory: $Source"
if (-not (Test-Path -LiteralPath $Source)) {
throw "缺少待打包目录:$Source"
}
New-Item -ItemType Directory -Force -Path $Destination | Out-Null
Copy-Item -Path (Join-Path $Source "*") -Destination $Destination -Recurse -Force
Copy-Item -LiteralPath $Source -Destination $Destination -Recurse -Force
}
function Copy-RequiredFile {
param(
[string]$Source,
[string]$Destination
)
if (-not (Test-Path -LiteralPath $Source)) {
throw "缺少待打包文件:$Source"
}
Copy-Item -LiteralPath $Source -Destination $Destination -Force
}
function Write-Step {
param([string]$Message)
Write-Host ""
Write-Host "==> $Message"
}
$maven = Resolve-Maven $MavenPath
@@ -65,52 +97,50 @@ if ($SkipTests) {
$mavenArgs += "-DskipTests"
}
Invoke-Step "Build YumiNail-Core" {
Push-Location (Join-Path $repoRoot "YumiNail-Core")
try { & $maven @mavenArgs } finally { Pop-Location }
}
Write-Step "构建 FD-Core"
Invoke-Native $maven $mavenArgs (Join-Path $repoRoot "FD-Core")
Invoke-Step "Build YumiNail-Gateway" {
Push-Location (Join-Path $repoRoot "YumiNail-Gateway")
try { & $maven @mavenArgs } finally { Pop-Location }
}
Write-Step "构建 FD-Gateway"
Invoke-Native $maven $mavenArgs (Join-Path $repoRoot "FD-Gateway")
Invoke-Step "Build YumiNail-Frontend" {
Push-Location (Join-Path $repoRoot "YumiNail-Frontend")
try {
if (!(Test-Path "node_modules")) {
npm ci
}
npm run build
} finally {
Pop-Location
}
Write-Step "构建 FD-Frontend"
$frontendRoot = Join-Path $repoRoot "FD-Frontend"
if (-not (Test-Path -LiteralPath (Join-Path $frontendRoot "node_modules"))) {
Invoke-Native "npm" @("ci") $frontendRoot
}
Invoke-Native "npm" @("run", "build") $frontendRoot
Copy-Item (Join-Path $repoRoot "YumiNail-Core\target\YumiNail-Core.jar") (Join-Path $backendDir "YumiNail-Core.jar") -Force
Copy-Item (Join-Path $repoRoot "YumiNail-Gateway\target\YumiNail-Gateway.jar") (Join-Path $backendDir "YumiNail-Gateway.jar") -Force
Copy-Directory (Join-Path $repoRoot "YumiNail-Frontend\dist") (Join-Path $frontendDir "dist")
Copy-Directory (Join-Path $repoRoot "WeChatProgram") (Join-Path $miniProgramDir "WeChatProgram")
Copy-Directory (Join-Path $repoRoot "YumiNail-Admin-Program") (Join-Path $miniProgramDir "YumiNail-Admin-Program")
Copy-Item (Join-Path $repoRoot "YumiNail-Core\src\main\resources\files\YumiNail.sql") (Join-Path $releaseDir "YumiNail.sql") -Force
$coreJar = Join-Path $repoRoot "FD-Core\target\FingertipDesigner-Core.jar"
$gatewayJar = Join-Path $repoRoot "FD-Gateway\target\FingertipDesigner-Gateway.jar"
$frontendDist = Join-Path $frontendRoot "dist"
Copy-RequiredFile $coreJar (Join-Path $backendDir "FingertipDesigner-Core.jar")
Copy-RequiredFile $gatewayJar (Join-Path $backendDir "FingertipDesigner-Gateway.jar")
Copy-Directory $frontendDist (Join-Path $frontendDir "dist")
Copy-Directory (Join-Path $repoRoot "FD-WeChat-Fronted") (Join-Path $miniProgramDir "FD-WeChat-Fronted")
Copy-Directory (Join-Path $repoRoot "FM-Wechat-Fronted") (Join-Path $miniProgramDir "FM-Wechat-Fronted")
Copy-RequiredFile $sqlPath (Join-Path $releaseDir "YumiNail.sql")
$manifest = @(
"# YumiNail Release $timestamp",
"# FingertipDesigner Release $timestamp",
"",
"- backend/YumiNail-Core.jar",
"- backend/YumiNail-Gateway.jar",
"- backend/FingertipDesigner-Core.jar",
"- backend/FingertipDesigner-Gateway.jar",
"- frontend/dist",
"- miniprograms/WeChatProgram",
"- miniprograms/YumiNail-Admin-Program",
"- miniprograms/FD-WeChat-Fronted",
"- miniprograms/FM-Wechat-Fronted",
"- YumiNail.sql",
"",
"Nacos namespace: YumiNail-Dev",
"Database initialized by: YumiNail.sql"
"Nacos namespace: FingertipDesigner",
"Database initialized by: scripts/sql/init/YumiNail.sql",
"Database name: FingertipDesigner",
"Manager mini program API: https://yunail.art/api/admin"
)
$manifest | Set-Content -Encoding UTF8 (Join-Path $releaseDir "README.md")
$zipPath = "$releaseDir.zip"
Compress-Archive -Path (Join-Path $releaseDir "*") -DestinationPath $zipPath -Force
Write-Host "Release folder: $releaseDir"
Write-Host "Release archive: $zipPath"
Write-Host ""
Write-Host "发布目录:$releaseDir"
Write-Host "发布压缩包:$zipPath"