Files
cmbone/init.ps1
T

50 lines
1.1 KiB
PowerShell

#!/usr/bin/env pwsh
$ErrorActionPreference = "Stop"
Set-Location -Path $PSScriptRoot
$InstallCmds = @(
"Push-Location frontend; npm install; Pop-Location"
)
$VerifyCmds = @(
"go test ./...",
"Push-Location frontend; npm run build; Pop-Location",
"New-Item -ItemType Directory -Force -Path bin | Out-Null; go build -o bin\cmbone.exe ."
)
$StartCmd = "wails3 dev"
function Invoke-ProjectCommand {
param([string]$Command)
Write-Host " $Command"
Invoke-Expression $Command
if ($LASTEXITCODE -ne 0) {
throw "Command failed with exit code ${LASTEXITCODE}: $Command"
}
}
Write-Host "==> 当前目录: $($PWD.Path)"
Write-Host "==> 同步依赖"
foreach ($cmd in $InstallCmds) {
Invoke-ProjectCommand $cmd
}
Write-Host "==> 运行基础验证"
foreach ($cmd in $VerifyCmds) {
Invoke-ProjectCommand $cmd
}
Write-Host "==> 启动命令"
Write-Host " $StartCmd"
if ($env:RUN_START_COMMAND -eq "1") {
Write-Host "==> 启动应用"
Invoke-ProjectCommand $StartCmd
} else {
Write-Host "如需直接启动应用,请设置 RUN_START_COMMAND=1。"
Write-Host "基础验证失败时,先修复基线,再继续功能开发。"
}