Files

21 lines
1.0 KiB
PowerShell
Raw Permalink Normal View History

2026-10-20 08:34:12 +08:00
[CmdletBinding()]
param([string]$NodePath)
$ErrorActionPreference = 'Stop'
$projectRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
$frontendRoot = Join-Path $projectRoot 'frontend'
if (-not $NodePath) {
$nodeCommand = Get-Command node.exe -ErrorAction SilentlyContinue
if ($nodeCommand) { $NodePath = $nodeCommand.Source }
}
if (-not $NodePath -or -not (Test-Path -LiteralPath $NodePath)) { throw '请安装 Node.js 20.19 或更新版本,或使用 -NodePath 指定 node.exe。' }
$vite = Join-Path $frontendRoot 'node_modules/vite/bin/vite.js'
if (-not (Test-Path -LiteralPath $vite)) { throw '缺少页面构建依赖。请先在 frontend 目录运行 pnpm install 或 npm install。' }
Push-Location $frontendRoot
try {
& $NodePath '--test' 'tests/data.test.mjs'
if ($LASTEXITCODE -ne 0) { throw '页面数据规则测试失败。' }
& $NodePath $vite 'build'
if ($LASTEXITCODE -ne 0) { throw '页面构建失败。' }
} finally { Pop-Location }
Write-Output '系统融合软件页面已构建到原生 JAR 静态资源目录。'