fix: osv-startup.ps1 — resolve syntax error line 105, pre-compute all status strings [Phase 4]
This commit is contained in:
parent
b993055bbd
commit
105e44fea4
|
|
@ -10,77 +10,96 @@ $W = 52
|
|||
Set-Location $REPO
|
||||
Clear-Host
|
||||
|
||||
$gcOK = $adcOK = $opaxOK = $gitOK = $false
|
||||
$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 compute/region us-central1 2>$null|Out-Null } } catch {}
|
||||
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 {}
|
||||
# ---- SJEKKER (stille) ----------------------------------------
|
||||
$gcOK = $false; $adcOK = $false; $opaxOK = $false; $gitOK = $false
|
||||
$gcAcc = ""
|
||||
|
||||
$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 compute/region us-central1 2>$null | Out-Null
|
||||
}
|
||||
} 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
|
||||
$IC = if ($allOK) { 'Green' } else { 'Gray' }
|
||||
|
||||
# Gradient top-border: Magenta -> DarkGreen -> Green
|
||||
$G1 = 'Magenta'; $G2 = 'DarkGreen'; $G3 = 'Green'
|
||||
# ---- STATUS-STRENGER (pre-computed) -------------------------
|
||||
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) {
|
||||
# Top border — gradient left=purple, mid=darkgreen, right=green
|
||||
$seg = [math]::Floor($W / 3)
|
||||
Write-Host " " -NoNewline
|
||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor $G1
|
||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor $G2
|
||||
Write-Host ("█" * ($W - $seg*2)) -ForegroundColor $G3
|
||||
|
||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor Magenta
|
||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor DarkGreen
|
||||
Write-Host ("█" * ($W - $seg * 2)) -ForegroundColor Green
|
||||
foreach ($line in $lines) {
|
||||
$pad = $W - 4 - $line.Length
|
||||
if ($pad -lt 0) { $line = $line.Substring(0, $W - 5) + "…"; $pad = 0 }
|
||||
Write-Host " " -NoNewline
|
||||
Write-Host "█" -NoNewline -ForegroundColor $G1
|
||||
Write-Host "█" -NoNewline -ForegroundColor Magenta
|
||||
Write-Host (" " + $line + (" " * $pad) + " ") -NoNewline -ForegroundColor Green
|
||||
Write-Host "█" -ForegroundColor $G3
|
||||
Write-Host "█" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Bottom border — gradient right=purple, mid=darkgreen, left=green
|
||||
Write-Host " " -NoNewline
|
||||
Write-Host ("█" * ($W - $seg*2)) -NoNewline -ForegroundColor $G3
|
||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor $G2
|
||||
Write-Host ("█" * $seg) -ForegroundColor $G1
|
||||
Write-Host ("█" * ($W - $seg * 2)) -NoNewline -ForegroundColor Green
|
||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor DarkGreen
|
||||
Write-Host ("█" * $seg) -ForegroundColor Magenta
|
||||
}
|
||||
|
||||
function ThinBox($lines, $titleColor) {
|
||||
Write-Host " " -NoNewline
|
||||
Write-Host ("─" * $W) -ForegroundColor $titleColor
|
||||
function ThinBox($lines, $borderColor) {
|
||||
Write-Host " " -NoNewline; Write-Host ("─" * $W) -ForegroundColor $borderColor
|
||||
foreach ($line in $lines) {
|
||||
$pad = $W - 4 - $line.Length
|
||||
if ($pad -lt 0) { $line = $line.Substring(0, $W - 5) + "…"; $pad = 0 }
|
||||
$ok = $line -match "^✅"
|
||||
$col = if ($ok) { 'Green' } else { 'Gray' }
|
||||
$col = if ($line -match "^✅") { 'Green' } elseif ($line -match "^❌") { 'Red' } elseif ($line -match "^⚠") { 'Yellow' } else { 'Gray' }
|
||||
Write-Host " " -NoNewline
|
||||
Write-Host "│" -NoNewline -ForegroundColor $titleColor
|
||||
Write-Host (" " + $line + (" " * ($pad+1))) -ForegroundColor $col
|
||||
Write-Host "│" -NoNewline -ForegroundColor $borderColor
|
||||
Write-Host (" " + $line) -ForegroundColor $col
|
||||
}
|
||||
Write-Host " " -NoNewline
|
||||
Write-Host ("─" * $W) -ForegroundColor $titleColor
|
||||
Write-Host " " -NoNewline; Write-Host ("─" * $W) -ForegroundColor $borderColor
|
||||
}
|
||||
|
||||
# ══ TOPP GLOW-BOKS ══════════════════════════════════════════
|
||||
# ---- TOPP GLOW-BOKS -----------------------------------------
|
||||
Write-Host ""
|
||||
GlowBox @(
|
||||
"",
|
||||
" O S V A U C O · O P A X",
|
||||
" us-central1 · gemini-2.5-pro",
|
||||
" $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')",
|
||||
" O S V A U C O · O P A X",
|
||||
" us-central1 · gemini-2.5-pro",
|
||||
" $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')",
|
||||
""
|
||||
)
|
||||
Write-Host ""
|
||||
|
||||
# ══ NESTE OPPGAVE ═══════════════════════════════════════════
|
||||
# ---- NESTE OPPGAVE ------------------------------------------
|
||||
Write-Host " ■ NESTE OPPGAVE" -ForegroundColor Magenta
|
||||
$nesteLines = @()
|
||||
$nesteLines = @("Sjekk docs/VAUCO_OS_ROADMAP.md")
|
||||
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) {
|
||||
$nesteLines = $m.Groups[1].Value.Trim() -split "`n" |
|
||||
Where-Object { $_.Trim() -and $_.Trim() -ne '---' } |
|
||||
|
|
@ -88,31 +107,24 @@ if (Test-Path $LOG) {
|
|||
ForEach-Object { $_.Trim() }
|
||||
}
|
||||
}
|
||||
if (-not $nesteLines) { $nesteLines = @("Sjekk docs/VAUCO_OS_ROADMAP.md") }
|
||||
ThinBox $nesteLines Magenta
|
||||
Write-Host ""
|
||||
|
||||
# ══ DOCS ════════════════════════════════════════════════════
|
||||
# ---- SISTE DOCS ---------------------------------------------
|
||||
Write-Host " ■ SISTE DOCS" -ForegroundColor Magenta
|
||||
$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
|
||||
Write-Host ""
|
||||
|
||||
# ══ STATUS ══════════════════════════════════════════════════
|
||||
# ---- STATUS -------------------------------------------------
|
||||
Write-Host " ■ STATUS" -ForegroundColor Magenta
|
||||
$statusLines = @(
|
||||
("✅ 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
|
||||
ThinBox @($gitTxt, $gcTxt, $adcTxt, $opaxTxt) Magenta
|
||||
Write-Host ""
|
||||
|
||||
# ══ BUNN GLOW-BOKS ══════════════════════════════════════════
|
||||
# ---- BUNN GLOW-BOKS -----------------------------------------
|
||||
if ($allOK) {
|
||||
GlowBox @("", " ▶▶ ALL SYSTEMS GREEN ◀◀", "")
|
||||
GlowBox @("", " ▶▶ ALL SYSTEMS GREEN ◀◀", "")
|
||||
} else {
|
||||
Write-Host " " -NoNewline
|
||||
Write-Host ("█" * $W) -ForegroundColor Yellow
|
||||
|
|
@ -122,7 +134,7 @@ if ($allOK) {
|
|||
}
|
||||
Write-Host ""
|
||||
|
||||
# ══ CUSTOM PROMPT ═══════════════════════════════════════════
|
||||
# ---- CUSTOM PROMPT ------------------------------------------
|
||||
function prompt {
|
||||
Write-Host " G:\Shared-drives\" -NoNewline -ForegroundColor Magenta
|
||||
Write-Host "OS" -NoNewline -ForegroundColor White
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user