You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.7 KiB

param(
[string]$NodePath = "C:\Users\ruixininfo\AppData\Local\nodejs\npm.cmd"
)
$ErrorActionPreference = "Stop"
$root = Resolve-Path (Join-Path $PSScriptRoot "..")
$backend = Join-Path $root "backend"
$pcAdmin = Join-Path $root "pc-admin"
$release = Join-Path $root "release"
$serverPackage = Join-Path $release "server"
$pcStatic = Join-Path $serverPackage "public\pc-admin"
$serverPackageFull = [System.IO.Path]::GetFullPath($serverPackage)
$releaseFull = [System.IO.Path]::GetFullPath($release)
if (-not $serverPackageFull.StartsWith($releaseFull, [System.StringComparison]::OrdinalIgnoreCase)) {
throw "Refusing to clean package path outside release directory: $serverPackageFull"
}
if (Test-Path $serverPackage) {
Remove-Item -LiteralPath $serverPackage -Recurse -Force
}
New-Item -ItemType Directory -Force -Path $pcStatic | Out-Null
Push-Location $pcAdmin
try {
& $NodePath run build
} finally {
Pop-Location
}
Copy-Item -Path (Join-Path $backend "src") -Destination (Join-Path $serverPackage "src") -Recurse
Copy-Item -Path (Join-Path $backend "sql") -Destination (Join-Path $serverPackage "sql") -Recurse
Copy-Item -Path (Join-Path $backend "package.json") -Destination $serverPackage
Copy-Item -Path (Join-Path $backend "package-lock.json") -Destination $serverPackage
Copy-Item -Path (Join-Path $backend ".env.example") -Destination $serverPackage
Copy-Item -Path (Join-Path $pcAdmin "dist\*") -Destination $pcStatic -Recurse
$uploads = Join-Path $serverPackage "uploads"
New-Item -ItemType Directory -Force -Path $uploads | Out-Null
Write-Host "Server package ready:" $serverPackage
Write-Host "Upload this directory, then run npm ci --omit=dev and npm start on the server."