OSVauco/scripts/osv-startup.ps1

101 lines
4.5 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# OSVauco · OPAX — VS Code Windows Startup
# settings.json: "args": ["-NoExit","-File","G:\\Shared drives\\OS-VAUCO-DRIVE\\OSVauco\\scripts\\osv-startup.ps1"]
$REPO = "G:\Shared drives\OS-VAUCO-DRIVE\OSVauco"
$PING = "https://opax.vauco.no/ping"
$LOG = "$REPO\docs\OSVAUCO_OPAX_SESSION_LOG.md"
$W = 52
$LINE = " " + ("" * $W)
$THIN = " " + ("" * $W)
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
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 {}
$allOK = $gitOK -and $opaxOK -and $gcOK
$BC = if ($allOK) { 'Green' } else { 'Yellow' }
$IC = if ($allOK) { 'Green' } else { 'Gray' }
$P = 'Magenta'
function Box($text, $color) {
$pad = $W - 4 - $text.Length
if ($pad -lt 0) { $text = $text.Substring(0, $W-5) + ""; $pad = 0 }
Write-Host ("" + $text + (" " * $pad) + "") -ForegroundColor $color
}
function Glow($label, $val, $ok) {
$sym = if ($ok) { "" } else { "" }
$col = if ($ok) { 'Green' } else { 'Yellow' }
$line = "$sym $label : $val"
Box $line $col
}
# ── TOPP ────────────────────────────────────────────────────
Write-Host ""
Write-Host $LINE -ForegroundColor $BC
Box " O S V A U C O · O P A X" $BC
Box " VS Code · us-central1 · gemini-2.5-pro" $IC
Box " $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" $IC
Write-Host $LINE -ForegroundColor $BC
Write-Host ""
# ── NESTE OPPGAVE ───────────────────────────────────────────
Write-Host " ■ NESTE OPPGAVE" -ForegroundColor $P
Write-Host $THIN -ForegroundColor $P
if (Test-Path $LOG) {
$m = [regex]::Match((Get-Content $LOG -Raw -Encoding UTF8),'(?s)## NESTE OPPGAVE\r?\n(.*?)(?=\r?\n## |$)')
if ($m.Success) {
$m.Groups[1].Value.Trim() -split "`n" | Select-Object -First 3 | ForEach-Object {
$t = $_.Trim(); if ($t -and $t -ne '---') { Box $t $BC }
}
} else { Box "Sjekk docs/VAUCO_OS_ROADMAP.md" Yellow }
} else { Box "Session log ikke funnet" Yellow }
Write-Host $THIN -ForegroundColor $P
Write-Host ""
# ── DOCS ────────────────────────────────────────────────────
Write-Host " ■ SISTE DOCS" -ForegroundColor $P
Write-Host $THIN -ForegroundColor $P
git -C $REPO log -3 --pretty=format:"%h %cd %s" --date=short -- docs 2>&1 | ForEach-Object {
$s = $_ -replace '[^\x00-\x7FæøåÆØÅ—“”]+',''
Box $s DarkGreen
}
Write-Host $THIN -ForegroundColor $P
Write-Host ""
# ── STATUS ──────────────────────────────────────────────────
Write-Host " ■ STATUS" -ForegroundColor $P
Write-Host $THIN -ForegroundColor $P
Glow "Git " (if ($gitOut -match 'Already') {'up to date'} else {'oppdatert'}) $gitOK
Glow "GCP " ($gcAcc -replace '@vauco.no','') $gcOK
Glow "ADC " (if ($adcOK) {'OK'} else {'kjør: gcloud auth application-default login'}) $adcOK
Glow "OPAX" "opax.vauco.no" $opaxOK
Write-Host $THIN -ForegroundColor $P
Write-Host ""
# ── BUNN ────────────────────────────────────────────────────
Write-Host $LINE -ForegroundColor $BC
if ($allOK) {
Box " ▶▶ ALL SYSTEMS GREEN ◀◀" 'Green'
} else {
Box " ⚠ PARTIAL — sjekk status over" 'Yellow'
}
Write-Host $LINE -ForegroundColor $BC
Write-Host ""
# ── CUSTOM PROMPT ───────────────────────────────────────────
function prompt {
Write-Host " G:\Shared-drives\" -NoNewline -ForegroundColor Magenta
Write-Host "OS" -NoNewline -ForegroundColor White
Write-Host "Vauco" -NoNewline -ForegroundColor Green
Write-Host " " -NoNewline -ForegroundColor Green
return " "
}