feat: osv-startup.ps1 — individual doc boxes, pulse animation on top/bottom, glow per line [Phase 4]
This commit is contained in:
parent
105e44fea4
commit
f879e75221
|
|
@ -4,89 +4,138 @@
|
||||||
$REPO = "G:\Shared drives\OS-VAUCO-DRIVE\OSVauco"
|
$REPO = "G:\Shared drives\OS-VAUCO-DRIVE\OSVauco"
|
||||||
$PING = "https://opax.vauco.no/ping"
|
$PING = "https://opax.vauco.no/ping"
|
||||||
$LOG = "$REPO\docs\OSVAUCO_OPAX_SESSION_LOG.md"
|
$LOG = "$REPO\docs\OSVAUCO_OPAX_SESSION_LOG.md"
|
||||||
$W = 52
|
$W = 54
|
||||||
|
|
||||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
Set-Location $REPO
|
Set-Location $REPO
|
||||||
Clear-Host
|
Clear-Host
|
||||||
|
|
||||||
# ---- SJEKKER (stille) ----------------------------------------
|
# ---- SJEKKER (stille) ----------------------------------------
|
||||||
$gcOK = $false; $adcOK = $false; $opaxOK = $false; $gitOK = $false
|
$gcOK = $false; $adcOK = $false; $opaxOK = $false; $gitOK = $false; $gcAcc = ""
|
||||||
$gcAcc = ""
|
$gitOut = git pull 2>&1; $gitOK = ($LASTEXITCODE -eq 0)
|
||||||
|
try { $gcAcc = gcloud auth list --filter=status:ACTIVE --format="value(account)" 2>$null
|
||||||
$gitOut = git pull 2>&1
|
if ($gcAcc) { $gcOK = $true
|
||||||
$gitOK = ($LASTEXITCODE -eq 0)
|
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 {
|
try { if (gcloud auth application-default print-access-token 2>$null) { $adcOK = $true } } catch {}
|
||||||
$gcAcc = gcloud auth list --filter=status:ACTIVE --format="value(account)" 2>$null
|
try { if ((Invoke-RestMethod -Uri $PING -TimeoutSec 5).status -eq 'ok') { $opaxOK = $true } } catch {}
|
||||||
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
|
$allOK = $gitOK -and $opaxOK -and $gcOK
|
||||||
|
|
||||||
# ---- STATUS-STRENGER (pre-computed) -------------------------
|
# ---- STATUS STRENGER -----------------------------------------
|
||||||
if ($gitOut -match 'Already') { $gitTxt = "✅ Git : up to date" }
|
if ($gitOK) { $gitTxt = "✅ Git : " + $(if ($gitOut -match 'Already') {'up to date'} else {'oppdatert'}) }
|
||||||
else { $gitTxt = "✅ Git : oppdatert" }
|
else { $gitTxt = "❌ Git : FEIL" }
|
||||||
if (-not $gitOK) { $gitTxt = "❌ Git : FEIL" }
|
$gcTxt = $(if ($gcOK) { "✅ GCP : " + ($gcAcc -replace '@vauco.no','') } else { "⚠ GCP : ikke logget inn" })
|
||||||
|
$adcTxt = $(if ($adcOK) { "✅ ADC : OK" } else { "⚠ ADC : gcloud auth application-default login" })
|
||||||
|
$opaxTxt = $(if ($opaxOK) { "✅ OPAX : opax.vauco.no" } else { "❌ OPAX : nede - sjekk Cloud Run" })
|
||||||
|
|
||||||
if ($gcOK) { $gcTxt = "✅ GCP : " + ($gcAcc -replace '@vauco.no','') }
|
# ---- HJELPEFUNKSJONER ----------------------------------------
|
||||||
else { $gcTxt = "⚠ GCP : ikke logget inn" }
|
function Pad($text, $width) {
|
||||||
|
if ($text.Length -gt $width) { return $text.Substring(0, $width - 1) + "…" }
|
||||||
|
return $text + (" " * ($width - $text.Length))
|
||||||
|
}
|
||||||
|
|
||||||
if ($adcOK) { $adcTxt = "✅ ADC : OK" }
|
function GlowLine($cols) {
|
||||||
else { $adcTxt = "⚠ ADC : gcloud auth application-default login" }
|
# $cols = array of [text, color] pairs filling $W chars
|
||||||
|
foreach ($c in $cols) { Write-Host $c[0] -NoNewline -ForegroundColor $c[1] }
|
||||||
|
Write-Host ""
|
||||||
|
}
|
||||||
|
|
||||||
if ($opaxOK) { $opaxTxt = "✅ OPAX : opax.vauco.no" }
|
|
||||||
else { $opaxTxt = "❌ OPAX : nede - sjekk Cloud Run" }
|
|
||||||
|
|
||||||
# ---- HJELPEFUNKSJONER ---------------------------------------
|
|
||||||
function GlowBox($lines) {
|
function GlowBox($lines) {
|
||||||
$seg = [math]::Floor($W / 3)
|
$seg = [math]::Floor($W / 3)
|
||||||
|
$r = $W - $seg * 2
|
||||||
|
# Top
|
||||||
Write-Host " " -NoNewline
|
Write-Host " " -NoNewline
|
||||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor Magenta
|
Write-Host ("█" * $seg) -NoNewline -ForegroundColor Magenta
|
||||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor DarkGreen
|
Write-Host ("█" * $seg) -NoNewline -ForegroundColor DarkGreen
|
||||||
Write-Host ("█" * ($W - $seg * 2)) -ForegroundColor Green
|
Write-Host ("█" * $r) -ForegroundColor Green
|
||||||
|
# Lines
|
||||||
foreach ($line in $lines) {
|
foreach ($line in $lines) {
|
||||||
$pad = $W - 4 - $line.Length
|
$inner = Pad $line ($W - 4)
|
||||||
if ($pad -lt 0) { $line = $line.Substring(0, $W - 5) + "…"; $pad = 0 }
|
|
||||||
Write-Host " " -NoNewline
|
Write-Host " " -NoNewline
|
||||||
Write-Host "█" -NoNewline -ForegroundColor Magenta
|
Write-Host "█" -NoNewline -ForegroundColor Magenta
|
||||||
Write-Host (" " + $line + (" " * $pad) + " ") -NoNewline -ForegroundColor Green
|
Write-Host (" $inner ") -NoNewline -ForegroundColor Green
|
||||||
Write-Host "█" -ForegroundColor Green
|
Write-Host "█" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
# Bottom (reversed)
|
||||||
Write-Host " " -NoNewline
|
Write-Host " " -NoNewline
|
||||||
Write-Host ("█" * ($W - $seg * 2)) -NoNewline -ForegroundColor Green
|
Write-Host ("█" * $r) -NoNewline -ForegroundColor Green
|
||||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor DarkGreen
|
Write-Host ("█" * $seg) -NoNewline -ForegroundColor DarkGreen
|
||||||
Write-Host ("█" * $seg) -ForegroundColor Magenta
|
Write-Host ("█" * $seg) -ForegroundColor Magenta
|
||||||
}
|
}
|
||||||
|
|
||||||
function ThinBox($lines, $borderColor) {
|
function PulseBox($lines) {
|
||||||
Write-Host " " -NoNewline; Write-Host ("─" * $W) -ForegroundColor $borderColor
|
# Animate border: cycle Magenta->DarkGreen->Green->DarkGreen->Magenta (3 frames)
|
||||||
foreach ($line in $lines) {
|
$frames = @(
|
||||||
$col = if ($line -match "^✅") { 'Green' } elseif ($line -match "^❌") { 'Red' } elseif ($line -match "^⚠") { 'Yellow' } else { 'Gray' }
|
@('Magenta','DarkGreen','Green'),
|
||||||
|
@('DarkGreen','Green','Magenta'),
|
||||||
|
@('Green','Magenta','DarkGreen')
|
||||||
|
)
|
||||||
|
$seg = [math]::Floor($W / 3); $r = $W - $seg * 2
|
||||||
|
foreach ($f in $frames) {
|
||||||
|
# Move cursor up to overwrite (skip on first frame)
|
||||||
|
$top = " " + ($f[0] * 0) # just use colors
|
||||||
|
[System.Console]::SetCursorPosition(0, [System.Console]::CursorTop)
|
||||||
Write-Host " " -NoNewline
|
Write-Host " " -NoNewline
|
||||||
Write-Host "│" -NoNewline -ForegroundColor $borderColor
|
Write-Host ("█" * $seg) -NoNewline -ForegroundColor $f[0]
|
||||||
Write-Host (" " + $line) -ForegroundColor $col
|
Write-Host ("█" * $seg) -NoNewline -ForegroundColor $f[1]
|
||||||
|
Write-Host ("█" * $r) -ForegroundColor $f[2]
|
||||||
|
foreach ($line in $lines) {
|
||||||
|
$inner = Pad $line ($W - 4)
|
||||||
|
Write-Host " " -NoNewline
|
||||||
|
Write-Host "█" -NoNewline -ForegroundColor $f[0]
|
||||||
|
Write-Host (" $inner ") -NoNewline -ForegroundColor Green
|
||||||
|
Write-Host "█" -ForegroundColor $f[2]
|
||||||
|
}
|
||||||
|
Write-Host " " -NoNewline
|
||||||
|
Write-Host ("█" * $r) -NoNewline -ForegroundColor $f[2]
|
||||||
|
Write-Host ("█" * $seg) -NoNewline -ForegroundColor $f[1]
|
||||||
|
Write-Host ("█" * $seg) -ForegroundColor $f[0]
|
||||||
|
Start-Sleep -Milliseconds 180
|
||||||
|
# Move cursor back up
|
||||||
|
$moveUp = $lines.Count + 2
|
||||||
|
for ($i = 0; $i -lt $moveUp; $i++) {
|
||||||
|
Write-Host "`e[1A" -NoNewline
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Write-Host " " -NoNewline; Write-Host ("─" * $W) -ForegroundColor $borderColor
|
# Final static draw
|
||||||
|
GlowBox $lines
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---- TOPP GLOW-BOKS -----------------------------------------
|
function DocBox($line) {
|
||||||
|
# Each doc commit gets its own mini glow box
|
||||||
|
$hash = ""
|
||||||
|
$date = ""
|
||||||
|
$msg = $line
|
||||||
|
if ($line -match '^([0-9a-f]{7}) (\d{4}-\d{2}-\d{2}) (.+)$') {
|
||||||
|
$hash = $matches[1]; $date = $matches[2]; $msg = $matches[3]
|
||||||
|
}
|
||||||
|
$msgPad = Pad $msg ($W - 6)
|
||||||
|
Write-Host " " -NoNewline
|
||||||
|
Write-Host "┌─" -NoNewline -ForegroundColor DarkGreen
|
||||||
|
Write-Host $hash -NoNewline -ForegroundColor Green
|
||||||
|
Write-Host " $date" -ForegroundColor DarkGreen
|
||||||
|
Write-Host " " -NoNewline
|
||||||
|
Write-Host "│ " -NoNewline -ForegroundColor DarkGreen
|
||||||
|
Write-Host $msgPad -ForegroundColor Green
|
||||||
|
Write-Host " " -NoNewline
|
||||||
|
Write-Host "└" -NoNewline -ForegroundColor DarkGreen
|
||||||
|
Write-Host ("─" * ($W - 2)) -ForegroundColor DarkGreen
|
||||||
|
}
|
||||||
|
|
||||||
|
function StatusLine($text) {
|
||||||
|
$col = if ($text -match "^✅") { 'Green' } elseif ($text -match "^❌") { 'Red' } else { 'Yellow' }
|
||||||
|
$glyph = if ($text -match "^✅") { "▓" } else { "░" }
|
||||||
|
Write-Host " " -NoNewline
|
||||||
|
Write-Host $glyph -NoNewline -ForegroundColor $col
|
||||||
|
Write-Host (" $text") -ForegroundColor $col
|
||||||
|
}
|
||||||
|
|
||||||
|
# ==============================================================
|
||||||
|
# TOPP PULSE-BOKS
|
||||||
|
# ==============================================================
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
GlowBox @(
|
PulseBox @(
|
||||||
"",
|
"",
|
||||||
" O S V A U C O · O P A X",
|
" O S V A U C O · O P A X",
|
||||||
" us-central1 · gemini-2.5-pro",
|
" us-central1 · gemini-2.5-pro",
|
||||||
|
|
@ -95,7 +144,9 @@ GlowBox @(
|
||||||
)
|
)
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# ---- NESTE OPPGAVE ------------------------------------------
|
# ==============================================================
|
||||||
|
# NESTE OPPGAVE
|
||||||
|
# ==============================================================
|
||||||
Write-Host " ■ NESTE OPPGAVE" -ForegroundColor Magenta
|
Write-Host " ■ NESTE OPPGAVE" -ForegroundColor Magenta
|
||||||
$nesteLines = @("Sjekk docs/VAUCO_OS_ROADMAP.md")
|
$nesteLines = @("Sjekk docs/VAUCO_OS_ROADMAP.md")
|
||||||
if (Test-Path $LOG) {
|
if (Test-Path $LOG) {
|
||||||
|
|
@ -103,28 +154,50 @@ if (Test-Path $LOG) {
|
||||||
if ($m.Success) {
|
if ($m.Success) {
|
||||||
$nesteLines = $m.Groups[1].Value.Trim() -split "`n" |
|
$nesteLines = $m.Groups[1].Value.Trim() -split "`n" |
|
||||||
Where-Object { $_.Trim() -and $_.Trim() -ne '---' } |
|
Where-Object { $_.Trim() -and $_.Trim() -ne '---' } |
|
||||||
Select-Object -First 2 |
|
Select-Object -First 3 |
|
||||||
ForEach-Object { $_.Trim() }
|
ForEach-Object { $_.Trim() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ThinBox $nesteLines Magenta
|
# Egen boks per linje
|
||||||
|
foreach ($nl in $nesteLines) {
|
||||||
|
Write-Host " " -NoNewline
|
||||||
|
Write-Host "┌" -NoNewline -ForegroundColor Magenta
|
||||||
|
Write-Host ("─" * ($W - 2)) -ForegroundColor Magenta
|
||||||
|
$inner = Pad $nl ($W - 4)
|
||||||
|
Write-Host " " -NoNewline
|
||||||
|
Write-Host "│ " -NoNewline -ForegroundColor Magenta
|
||||||
|
Write-Host $inner -ForegroundColor Green
|
||||||
|
Write-Host " " -NoNewline
|
||||||
|
Write-Host "└" -NoNewline -ForegroundColor Magenta
|
||||||
|
Write-Host ("─" * ($W - 2)) -ForegroundColor Magenta
|
||||||
|
}
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# ---- SISTE DOCS ---------------------------------------------
|
# ==============================================================
|
||||||
|
# SISTE DOCS — egen boks per commit
|
||||||
|
# ==============================================================
|
||||||
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
|
Where-Object { $_ }
|
||||||
|
foreach ($dl in $docLines) { DocBox $dl }
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# ---- STATUS -------------------------------------------------
|
# ==============================================================
|
||||||
|
# STATUS — glow per linje
|
||||||
|
# ==============================================================
|
||||||
Write-Host " ■ STATUS" -ForegroundColor Magenta
|
Write-Host " ■ STATUS" -ForegroundColor Magenta
|
||||||
ThinBox @($gitTxt, $gcTxt, $adcTxt, $opaxTxt) Magenta
|
StatusLine $gitTxt
|
||||||
|
StatusLine $gcTxt
|
||||||
|
StatusLine $adcTxt
|
||||||
|
StatusLine $opaxTxt
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# ---- BUNN GLOW-BOKS -----------------------------------------
|
# ==============================================================
|
||||||
|
# BUNN PULSE-BOKS
|
||||||
|
# ==============================================================
|
||||||
if ($allOK) {
|
if ($allOK) {
|
||||||
GlowBox @("", " ▶▶ ALL SYSTEMS GREEN ◀◀", "")
|
PulseBox @("", " ▶▶ ALL SYSTEMS GREEN ◀◀", "")
|
||||||
} else {
|
} else {
|
||||||
Write-Host " " -NoNewline
|
Write-Host " " -NoNewline
|
||||||
Write-Host ("█" * $W) -ForegroundColor Yellow
|
Write-Host ("█" * $W) -ForegroundColor Yellow
|
||||||
|
|
@ -134,7 +207,9 @@ 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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user