From 930d67fdd6a9a975db7bf100288f25e4bd4d0d13 Mon Sep 17 00:00:00 2001 From: lashman Date: Mon, 21 Sep 2026 02:01:49 +0300 Subject: [PATCH] add a single verification gate for all four checks --- verify.ps1 | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 verify.ps1 diff --git a/verify.ps1 b/verify.ps1 new file mode 100644 index 0000000..25ad05f --- /dev/null +++ b/verify.ps1 @@ -0,0 +1,82 @@ +# ByteSize verification gate. +# +# Runs the four checks that have to be green before a change is done: +# the frontend type gate, then the Rust check, lint and test passes. +# +# Run it from the repo root: +# +# powershell -File verify.ps1 +# +# Exit code 0 means everything passed. Any failure stops the run and names the +# failing step, because a later step's output is noise once an earlier one broke. + +$root = $PSScriptRoot +$failures = @() +$passed = @() + +function Invoke-Step { + param( + [string]$Name, + [scriptblock]$Body + ) + + Write-Host "" + Write-Host "=== $Name ===" -ForegroundColor Cyan + + # npm and cargo both write progress banners to stderr. Under + # ErrorActionPreference=Stop that becomes a terminating NativeCommandError + # in PowerShell 5.1, so relax it for the duration of the call and judge the + # step on its exit code instead. + $previous = $ErrorActionPreference + $ErrorActionPreference = 'Continue' + try { + $output = & $Body 2>&1 | ForEach-Object { "$_" } + $code = $LASTEXITCODE + } + finally { + $ErrorActionPreference = $previous + } + + $output | ForEach-Object { Write-Host $_ } + + if ($code -ne 0) { + $script:failures += "$Name (exit $code)" + return $false + } + + Write-Host "ok: $Name" -ForegroundColor Green + $script:passed += $Name + return $true +} + +if (-not (Test-Path (Join-Path $root 'node_modules'))) { + Write-Host "node_modules is missing - the frontend gate cannot run." -ForegroundColor Yellow + Write-Host "Install it with the per-command override, because the user-level" + Write-Host "allow-scripts setting belongs to another project and npm 12 rejects it:" + Write-Host "" + Write-Host " `$env:npm_config_allow_scripts = ''; npm ci --no-audit --no-fund" + Write-Host "" + exit 1 +} + +Push-Location $root +try { + $null = Invoke-Step 'svelte-check (frontend types)' { npm run check } + if ($failures.Count -eq 0) { $null = Invoke-Step 'cargo check' { cargo check --manifest-path src-tauri/Cargo.toml } } + if ($failures.Count -eq 0) { $null = Invoke-Step 'cargo clippy' { cargo clippy --manifest-path src-tauri/Cargo.toml } } + if ($failures.Count -eq 0) { $null = Invoke-Step 'cargo test' { cargo test --manifest-path src-tauri/Cargo.toml } } +} +finally { + Pop-Location +} + +Write-Host "" +if ($failures.Count -gt 0) { + Write-Host "FAILED:" -ForegroundColor Red + $failures | ForEach-Object { Write-Host " - $_" -ForegroundColor Red } + exit 1 +} + +Write-Host "All $($passed.Count) checks passed:" -ForegroundColor Green +$passed | ForEach-Object { Write-Host " - $_" -ForegroundColor Green } +exit 0