fix: osv-startup.ps1 — resolve syntax error line 105, pre-compute all status strings [Phase 4]

This commit is contained in:
chrischristiansen-glitch 2026-05-22 02:47:30 +02:00
parent b993055bbd
commit 105e44fea4

View File

@ -10,62 +10,81 @@ $W = 52
Set-Location $REPO Set-Location $REPO
Clear-Host Clear-Host
$gcOK = $adcOK = $opaxOK = $gitOK = $false # ---- SJEKKER (stille) ----------------------------------------
$gitOut = git pull 2>&1; $gitOK = ($LASTEXITCODE -eq 0) $gcOK = $false; $adcOK = $false; $opaxOK = $false; $gitOK = $false
try { $gcAcc = gcloud auth list --filter=status:ACTIVE --format="value(account)" 2>$null $gcAcc = ""
if ($gcAcc) { $gcOK = $true
$gitOut = git pull 2>&1
$gitOK = ($LASTEXITCODE -eq 0)
try {
$gcAcc = gcloud auth list --filter=status:ACTIVE --format="value(account)" 2>$null
if ($gcAcc) {
$gcOK = $true
gcloud config set project propane-will-491900-m5 2>$null | Out-Null gcloud config set project propane-will-491900-m5 2>$null | Out-Null
gcloud config set compute/region us-central1 2>$null|Out-Null } } catch {} gcloud config set compute/region us-central1 2>$null | Out-Null
try { if (gcloud auth application-default print-access-token 2>$null) { $adcOK = $true } } catch {} }
try { if ((Invoke-RestMethod -Uri $PING -TimeoutSec 5).status -eq 'ok') { $opaxOK = $true } } catch {} } catch {}
try {
$t = gcloud auth application-default print-access-token 2>$null
if ($t) { $adcOK = $true }
} catch {}
try {
$r = Invoke-RestMethod -Uri $PING -TimeoutSec 5
if ($r.status -eq 'ok') { $opaxOK = $true }
} catch {}
$allOK = $gitOK -and $opaxOK -and $gcOK $allOK = $gitOK -and $opaxOK -and $gcOK
$IC = if ($allOK) { 'Green' } else { 'Gray' }
# Gradient top-border: Magenta -> DarkGreen -> Green # ---- STATUS-STRENGER (pre-computed) -------------------------
$G1 = 'Magenta'; $G2 = 'DarkGreen'; $G3 = 'Green' if ($gitOut -match 'Already') { $gitTxt = "✅ Git : up to date" }
else { $gitTxt = "✅ Git : oppdatert" }
if (-not $gitOK) { $gitTxt = "❌ Git : FEIL" }
if ($gcOK) { $gcTxt = "✅ GCP : " + ($gcAcc -replace '@vauco.no','') }
else { $gcTxt = "⚠ GCP : ikke logget inn" }
if ($adcOK) { $adcTxt = "✅ ADC : OK" }
else { $adcTxt = "⚠ ADC : gcloud auth application-default login" }
if ($opaxOK) { $opaxTxt = "✅ OPAX : opax.vauco.no" }
else { $opaxTxt = "❌ OPAX : nede - sjekk Cloud Run" }
# ---- HJELPEFUNKSJONER ---------------------------------------
function GlowBox($lines) { function GlowBox($lines) {
# Top border — gradient left=purple, mid=darkgreen, right=green
$seg = [math]::Floor($W / 3) $seg = [math]::Floor($W / 3)
Write-Host " " -NoNewline Write-Host " " -NoNewline
Write-Host ("" * $seg) -NoNewline -ForegroundColor $G1 Write-Host ("" * $seg) -NoNewline -ForegroundColor Magenta
Write-Host ("" * $seg) -NoNewline -ForegroundColor $G2 Write-Host ("" * $seg) -NoNewline -ForegroundColor DarkGreen
Write-Host ("" * ($W - $seg*2)) -ForegroundColor $G3 Write-Host ("" * ($W - $seg * 2)) -ForegroundColor Green
foreach ($line in $lines) { foreach ($line in $lines) {
$pad = $W - 4 - $line.Length $pad = $W - 4 - $line.Length
if ($pad -lt 0) { $line = $line.Substring(0, $W - 5) + ""; $pad = 0 } if ($pad -lt 0) { $line = $line.Substring(0, $W - 5) + ""; $pad = 0 }
Write-Host " " -NoNewline Write-Host " " -NoNewline
Write-Host "" -NoNewline -ForegroundColor $G1 Write-Host "" -NoNewline -ForegroundColor Magenta
Write-Host (" " + $line + (" " * $pad) + " ") -NoNewline -ForegroundColor Green Write-Host (" " + $line + (" " * $pad) + " ") -NoNewline -ForegroundColor Green
Write-Host "" -ForegroundColor $G3 Write-Host "" -ForegroundColor Green
}
Write-Host " " -NoNewline
Write-Host ("" * ($W - $seg * 2)) -NoNewline -ForegroundColor Green
Write-Host ("" * $seg) -NoNewline -ForegroundColor DarkGreen
Write-Host ("" * $seg) -ForegroundColor Magenta
} }
# Bottom border — gradient right=purple, mid=darkgreen, left=green function ThinBox($lines, $borderColor) {
Write-Host " " -NoNewline Write-Host " " -NoNewline; Write-Host ("" * $W) -ForegroundColor $borderColor
Write-Host ("" * ($W - $seg*2)) -NoNewline -ForegroundColor $G3
Write-Host ("" * $seg) -NoNewline -ForegroundColor $G2
Write-Host ("" * $seg) -ForegroundColor $G1
}
function ThinBox($lines, $titleColor) {
Write-Host " " -NoNewline
Write-Host ("" * $W) -ForegroundColor $titleColor
foreach ($line in $lines) { foreach ($line in $lines) {
$pad = $W - 4 - $line.Length $col = if ($line -match "^✅") { 'Green' } elseif ($line -match "^❌") { 'Red' } elseif ($line -match "^⚠") { 'Yellow' } else { 'Gray' }
if ($pad -lt 0) { $line = $line.Substring(0, $W - 5) + ""; $pad = 0 }
$ok = $line -match "^✅"
$col = if ($ok) { 'Green' } else { 'Gray' }
Write-Host " " -NoNewline Write-Host " " -NoNewline
Write-Host "" -NoNewline -ForegroundColor $titleColor Write-Host "" -NoNewline -ForegroundColor $borderColor
Write-Host (" " + $line + (" " * ($pad+1))) -ForegroundColor $col Write-Host (" " + $line) -ForegroundColor $col
} }
Write-Host " " -NoNewline Write-Host " " -NoNewline; Write-Host ("" * $W) -ForegroundColor $borderColor
Write-Host ("" * $W) -ForegroundColor $titleColor
} }
# ══ TOPP GLOW-BOKS ══════════════════════════════════════════ # ---- TOPP GLOW-BOKS -----------------------------------------
Write-Host "" Write-Host ""
GlowBox @( GlowBox @(
"", "",
@ -76,9 +95,9 @@ GlowBox @(
) )
Write-Host "" Write-Host ""
# ══ NESTE OPPGAVE ═══════════════════════════════════════════ # ---- NESTE OPPGAVE ------------------------------------------
Write-Host " ■ NESTE OPPGAVE" -ForegroundColor Magenta Write-Host " ■ NESTE OPPGAVE" -ForegroundColor Magenta
$nesteLines = @() $nesteLines = @("Sjekk docs/VAUCO_OS_ROADMAP.md")
if (Test-Path $LOG) { if (Test-Path $LOG) {
$m = [regex]::Match((Get-Content $LOG -Raw -Encoding UTF8), '(?s)## NESTE OPPGAVE\r?\n(.*?)(?=\r?\n## |$)') $m = [regex]::Match((Get-Content $LOG -Raw -Encoding UTF8), '(?s)## NESTE OPPGAVE\r?\n(.*?)(?=\r?\n## |$)')
if ($m.Success) { if ($m.Success) {
@ -88,29 +107,22 @@ if (Test-Path $LOG) {
ForEach-Object { $_.Trim() } ForEach-Object { $_.Trim() }
} }
} }
if (-not $nesteLines) { $nesteLines = @("Sjekk docs/VAUCO_OS_ROADMAP.md") }
ThinBox $nesteLines Magenta ThinBox $nesteLines Magenta
Write-Host "" Write-Host ""
# ══ DOCS ════════════════════════════════════════════════════ # ---- SISTE DOCS ---------------------------------------------
Write-Host " ■ SISTE DOCS" -ForegroundColor Magenta Write-Host " ■ SISTE DOCS" -ForegroundColor Magenta
$docLines = git -C $REPO log -3 --pretty=format:"%h %cd %s" --date=short -- docs 2>&1 | $docLines = git -C $REPO log -3 --pretty=format:"%h %cd %s" --date=short -- docs 2>&1 |
ForEach-Object { ($_ -replace '[^\x00-\x7F\u00e6\u00f8\u00e5\u00c6\u00d8\u00c5\u2014\u2013]+', '').Trim() } ForEach-Object { ($_ -replace '[^\x00-\x7F\u00e6\u00f8\u00e5\u00c6\u00d8\u00c5\u2014\u2013]+', '').Trim() }
ThinBox $docLines DarkGreen ThinBox $docLines DarkGreen
Write-Host "" Write-Host ""
# ══ STATUS ══════════════════════════════════════════════════ # ---- STATUS -------------------------------------------------
Write-Host " ■ STATUS" -ForegroundColor Magenta Write-Host " ■ STATUS" -ForegroundColor Magenta
$statusLines = @( ThinBox @($gitTxt, $gcTxt, $adcTxt, $opaxTxt) Magenta
("✅ Git : " + (if ($gitOut -match 'Already') {'up to date'} else {'oppdatert'})),
((if ($gcOK) {'✅'} else {'⚠ '}) + " GCP : " + ($gcAcc -replace '@vauco.no','')),
((if ($adcOK) {'✅'} else {'⚠ '}) + " ADC : " + (if ($adcOK) {'OK'} else {'gcloud auth application-default login'})),
((if ($opaxOK) {'✅'} else {'❌'}) + " OPAX : opax.vauco.no")
)
ThinBox $statusLines Magenta
Write-Host "" Write-Host ""
# ══ BUNN GLOW-BOKS ══════════════════════════════════════════ # ---- BUNN GLOW-BOKS -----------------------------------------
if ($allOK) { if ($allOK) {
GlowBox @("", " ▶▶ ALL SYSTEMS GREEN ◀◀", "") GlowBox @("", " ▶▶ ALL SYSTEMS GREEN ◀◀", "")
} else { } else {
@ -122,7 +134,7 @@ if ($allOK) {
} }
Write-Host "" Write-Host ""
# ══ CUSTOM PROMPT ═══════════════════════════════════════════ # ---- CUSTOM PROMPT ------------------------------------------
function prompt { function prompt {
Write-Host " G:\Shared-drives\" -NoNewline -ForegroundColor Magenta Write-Host " G:\Shared-drives\" -NoNewline -ForegroundColor Magenta
Write-Host "OS" -NoNewline -ForegroundColor White Write-Host "OS" -NoNewline -ForegroundColor White