优化
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[switch]$DryRun,
|
||||
[switch]$SkipAdmin,
|
||||
[switch]$SkipClient
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path
|
||||
|
||||
function Invoke-FrontendStep {
|
||||
param([string]$Name, [string]$Directory, [string]$Task)
|
||||
$display = "pnpm --dir `"$Directory`" $Task"
|
||||
Write-Host " [$Name] $display"
|
||||
if ($DryRun) { return }
|
||||
& pnpm --dir $Directory $Task
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
}
|
||||
|
||||
if ($SkipAdmin -and $SkipClient) { Write-Error 'At least one of Admin or Client must be selected.'; exit 2 }
|
||||
if (-not (Get-Command pnpm -ErrorAction SilentlyContinue)) { Write-Error 'pnpm was not found on PATH.'; exit 2 }
|
||||
|
||||
$targets = @()
|
||||
if (-not $SkipAdmin) { $targets += @{ Name = 'Admin'; Directory = Join-Path $repoRoot 'apps/admin-web' } }
|
||||
if (-not $SkipClient) { $targets += @{ Name = 'Client'; Directory = Join-Path $repoRoot 'apps/client-web' } }
|
||||
|
||||
Write-Host 'Frontend full regression (local only)'
|
||||
Write-Host "Repository: $repoRoot"
|
||||
Write-Host "Mode: $(if ($DryRun) { 'DryRun' } else { 'Execute' })"
|
||||
Write-Host 'Gateway/database/deployment: not used'
|
||||
|
||||
foreach ($target in $targets) {
|
||||
$packageJson = Join-Path $target.Directory 'package.json'
|
||||
if (-not (Test-Path -LiteralPath $packageJson)) { Write-Error "$($target.Name) package.json not found: $packageJson"; exit 2 }
|
||||
Write-Host "[$($target.Name)]"
|
||||
Invoke-FrontendStep 'test' $target.Directory 'test'
|
||||
Invoke-FrontendStep 'typecheck' $target.Directory 'typecheck'
|
||||
}
|
||||
|
||||
Write-Host 'Frontend regression completed.'
|
||||
Reference in New Issue
Block a user