feat: osv-startup.ps1 + .vscode/settings.json — auto-unblock, purple/green only palette, clean prompt [Phase 4]
This commit is contained in:
parent
94fde5799d
commit
66527d18b8
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
|
@ -7,8 +7,8 @@
|
||||||
"path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
|
"path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
|
||||||
"args": [
|
"args": [
|
||||||
"-NoExit",
|
"-NoExit",
|
||||||
"-File",
|
"-Command",
|
||||||
"G:\\Shared drives\\OS-VAUCO-DRIVE\\OSVauco\\scripts\\osv-startup.ps1"
|
"Unblock-File 'G:\\Shared drives\\OS-VAUCO-DRIVE\\OSVauco\\scripts\\osv-startup.ps1'; & 'G:\\Shared drives\\OS-VAUCO-DRIVE\\OSVauco\\scripts\\osv-startup.ps1'"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
# OSVauco · OPAX — VS Code Windows Startup
|
# 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"
|
$REPO = "G:\Shared drives\OS-VAUCO-DRIVE\OSVauco"
|
||||||
$PING = "https://opax.vauco.no/ping"
|
$PING = "https://opax.vauco.no/ping"
|
||||||
|
|
@ -11,7 +10,6 @@ Set-Location $REPO
|
||||||
Clear-Host
|
Clear-Host
|
||||||
|
|
||||||
# ---- GCLOUD PATH DETECTION -----------------------------------
|
# ---- GCLOUD PATH DETECTION -----------------------------------
|
||||||
# Finn gcloud uavhengig av om den er i PATH
|
|
||||||
$gcloudCmd = $null
|
$gcloudCmd = $null
|
||||||
$gcloudPaths = @(
|
$gcloudPaths = @(
|
||||||
"gcloud",
|
"gcloud",
|
||||||
|
|
@ -20,18 +18,14 @@ $gcloudPaths = @(
|
||||||
"$env:USERPROFILE\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\gcloud.cmd"
|
"$env:USERPROFILE\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\gcloud.cmd"
|
||||||
)
|
)
|
||||||
foreach ($p in $gcloudPaths) {
|
foreach ($p in $gcloudPaths) {
|
||||||
try {
|
try { $null = & $p version 2>$null; if ($LASTEXITCODE -eq 0 -or $?) { $gcloudCmd = $p; break } } catch {}
|
||||||
$null = & $p version 2>$null
|
|
||||||
if ($LASTEXITCODE -eq 0 -or $?) { $gcloudCmd = $p; break }
|
|
||||||
} catch {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---- SJEKKER (stille) ----------------------------------------
|
# ---- SJEKKER -------------------------------------------------
|
||||||
$gcOK = $false; $adcOK = $false; $opaxOK = $false; $gitOK = $false
|
$gcOK = $false; $adcOK = $false; $opaxOK = $false; $gitOK = $false
|
||||||
$gcAcc = ""; $gcNotInstalled = ($null -eq $gcloudCmd)
|
$gcAcc = ""; $gcNotInstalled = ($null -eq $gcloudCmd)
|
||||||
|
|
||||||
$gitOut = git pull 2>&1
|
$gitOut = git pull 2>&1; $gitOK = ($LASTEXITCODE -eq 0)
|
||||||
$gitOK = ($LASTEXITCODE -eq 0)
|
|
||||||
|
|
||||||
if (-not $gcNotInstalled) {
|
if (-not $gcNotInstalled) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -42,29 +36,27 @@ if (-not $gcNotInstalled) {
|
||||||
& $gcloudCmd config set compute/region us-central1 2>$null | Out-Null
|
& $gcloudCmd config set compute/region us-central1 2>$null | Out-Null
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
try {
|
try { $t = & $gcloudCmd auth application-default print-access-token 2>$null; if ($t) { $adcOK = $true } } catch {}
|
||||||
$t = & $gcloudCmd auth application-default print-access-token 2>$null
|
|
||||||
if ($t) { $adcOK = $true }
|
|
||||||
} catch {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try { if ((Invoke-RestMethod -Uri $PING -TimeoutSec 5).status -eq 'ok') { $opaxOK = $true } } catch {}
|
||||||
if ((Invoke-RestMethod -Uri $PING -TimeoutSec 5).status -eq 'ok') { $opaxOK = $true }
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
$allOK = $gitOK -and $opaxOK -and $gcOK
|
$allOK = $gitOK -and $opaxOK -and $gcOK
|
||||||
|
|
||||||
|
# ---- FARGER (kun lilla + grønn) ------------------------------
|
||||||
|
$PU = 'Magenta' # lilla
|
||||||
|
$GR = 'Green' # grønn
|
||||||
|
$DG = 'DarkGreen' # mørkgrønn (for kontrast)
|
||||||
|
|
||||||
# ---- STATUS STRENGER -----------------------------------------
|
# ---- STATUS STRENGER -----------------------------------------
|
||||||
$gitTxt = if ($gitOK) { if ($gitOut -match 'Already') { "✅ Git : up to date" } else { "✅ Git : oppdatert" } }
|
$gitTxt = if ($gitOK) { if ($gitOut -match 'Already') { "✅ Git : up to date" } else { "✅ Git : oppdatert" } } else { "❌ Git : FEIL" }
|
||||||
else { "❌ Git : FEIL" }
|
$gcTxt = if ($gcNotInstalled) { "ℹ GCP : ikke funnet — bruk Cloud Shell" }
|
||||||
$gcTxt = if ($gcNotInstalled) { "ℹ GCP : gcloud ikke funnet — bruk Cloud Shell" }
|
elseif ($gcOK) { "✅ GCP : " + ($gcAcc -replace '@vauco.no','') }
|
||||||
elseif ($gcOK) { "✅ GCP : " + ($gcAcc -replace '@vauco.no','') }
|
else { "⚠ GCP : gcloud auth login" }
|
||||||
else { "⚠ GCP : ikke logget inn — gcloud auth login" }
|
$adcTxt = if ($gcNotInstalled) { "ℹ ADC : ikke tilgjengelig" }
|
||||||
$adcTxt = if ($gcNotInstalled) { "ℹ ADC : ikke tilgjengelig i dette miljøet" }
|
elseif ($adcOK) { "✅ ADC : OK" }
|
||||||
elseif ($adcOK) { "✅ ADC : OK" }
|
else { "⚠ ADC : gcloud auth application-default login" }
|
||||||
else { "⚠ ADC : gcloud auth application-default login" }
|
$opaxTxt = if ($opaxOK) { "✅ OPAX : opax.vauco.no" } else { "❌ OPAX : nede — sjekk Cloud Run" }
|
||||||
$opaxTxt = if ($opaxOK) { "✅ OPAX : opax.vauco.no" }
|
|
||||||
else { "❌ OPAX : nede — sjekk Cloud Run" }
|
|
||||||
|
|
||||||
# ---- HJELPEFUNKSJONER ----------------------------------------
|
# ---- HJELPEFUNKSJONER ----------------------------------------
|
||||||
function Pad($text, $width) {
|
function Pad($text, $width) {
|
||||||
|
|
@ -74,21 +66,15 @@ function Pad($text, $width) {
|
||||||
|
|
||||||
function GlowBox($lines) {
|
function GlowBox($lines) {
|
||||||
$seg = [math]::Floor($W / 3); $r = $W - $seg * 2
|
$seg = [math]::Floor($W / 3); $r = $W - $seg * 2
|
||||||
Write-Host " " -NoNewline
|
Write-Host " " -NoNewline; Write-Host ("█" * $seg) -NoNewline -ForegroundColor $PU
|
||||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor Magenta
|
Write-Host ("█" * $seg) -NoNewline -ForegroundColor $DG; Write-Host ("█" * $r) -ForegroundColor $GR
|
||||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor DarkGreen
|
|
||||||
Write-Host ("█" * $r) -ForegroundColor Green
|
|
||||||
foreach ($line in $lines) {
|
foreach ($line in $lines) {
|
||||||
$inner = Pad $line ($W - 4)
|
$inner = Pad $line ($W - 4)
|
||||||
Write-Host " " -NoNewline
|
Write-Host " " -NoNewline; Write-Host "█" -NoNewline -ForegroundColor $PU
|
||||||
Write-Host "█" -NoNewline -ForegroundColor Magenta
|
Write-Host (" $inner ") -NoNewline -ForegroundColor $GR; Write-Host "█" -ForegroundColor $GR
|
||||||
Write-Host (" $inner ") -NoNewline -ForegroundColor Green
|
|
||||||
Write-Host "█" -ForegroundColor Green
|
|
||||||
}
|
}
|
||||||
Write-Host " " -NoNewline
|
Write-Host " " -NoNewline; Write-Host ("█" * $r) -NoNewline -ForegroundColor $GR
|
||||||
Write-Host ("█" * $r) -NoNewline -ForegroundColor Green
|
Write-Host ("█" * $seg) -NoNewline -ForegroundColor $DG; Write-Host ("█" * $seg) -ForegroundColor $PU
|
||||||
Write-Host ("█" * $seg) -NoNewline -ForegroundColor DarkGreen
|
|
||||||
Write-Host ("█" * $seg) -ForegroundColor Magenta
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function DocBox($line) {
|
function DocBox($line) {
|
||||||
|
|
@ -96,43 +82,33 @@ function DocBox($line) {
|
||||||
if ($line -match '^([0-9a-f]{7}) (\d{4}-\d{2}-\d{2}) (.+)$') {
|
if ($line -match '^([0-9a-f]{7}) (\d{4}-\d{2}-\d{2}) (.+)$') {
|
||||||
$hash = $matches[1]; $date = $matches[2]; $msg = $matches[3]
|
$hash = $matches[1]; $date = $matches[2]; $msg = $matches[3]
|
||||||
}
|
}
|
||||||
Write-Host " " -NoNewline
|
Write-Host " " -NoNewline; Write-Host "┌─ " -NoNewline -ForegroundColor $PU
|
||||||
Write-Host "┌─ " -NoNewline -ForegroundColor DarkGreen
|
Write-Host $hash -NoNewline -ForegroundColor $GR; Write-Host " $date" -ForegroundColor $DG
|
||||||
Write-Host $hash -NoNewline -ForegroundColor Green
|
Write-Host " " -NoNewline; Write-Host "│ " -NoNewline -ForegroundColor $PU
|
||||||
Write-Host " $date" -ForegroundColor DarkGreen
|
Write-Host (Pad $msg ($W - 4)) -ForegroundColor $GR
|
||||||
$msgPad = Pad $msg ($W - 4)
|
Write-Host " " -NoNewline; Write-Host "└" -NoNewline -ForegroundColor $PU
|
||||||
Write-Host " " -NoNewline
|
Write-Host ("─" * ($W - 2)) -ForegroundColor $PU
|
||||||
Write-Host "│ " -NoNewline -ForegroundColor DarkGreen
|
}
|
||||||
Write-Host $msgPad -ForegroundColor Green
|
|
||||||
Write-Host " " -NoNewline
|
function NesteBox($text) {
|
||||||
Write-Host "└" -NoNewline -ForegroundColor DarkGreen
|
Write-Host " " -NoNewline; Write-Host "┌" -NoNewline -ForegroundColor $PU; Write-Host ("─" * ($W - 2)) -ForegroundColor $PU
|
||||||
Write-Host ("─" * ($W - 2)) -ForegroundColor DarkGreen
|
Write-Host " " -NoNewline; Write-Host "│ " -NoNewline -ForegroundColor $PU
|
||||||
|
Write-Host (Pad $text ($W - 4)) -ForegroundColor $GR
|
||||||
|
Write-Host " " -NoNewline; Write-Host "└" -NoNewline -ForegroundColor $PU; Write-Host ("─" * ($W - 2)) -ForegroundColor $PU
|
||||||
}
|
}
|
||||||
|
|
||||||
function StatusLine($text) {
|
function StatusLine($text) {
|
||||||
$col = if ($text -match "^✅") { 'Green' } elseif ($text -match "^❌") { 'Red' } elseif ($text -match "^⚠") { 'Yellow' } else { 'Cyan' }
|
$col = if ($text -match "^✅") { $GR } elseif ($text -match "^❌") { 'Red' } else { $PU }
|
||||||
$glyph = if ($text -match "^✅") { "▓" } elseif ($text -match "^❌") { "░" } else { "▒" }
|
Write-Host " " -NoNewline; Write-Host "▒ " -NoNewline -ForegroundColor $col
|
||||||
Write-Host " $glyph " -NoNewline -ForegroundColor $col
|
|
||||||
Write-Host $text -ForegroundColor $col
|
Write-Host $text -ForegroundColor $col
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==============================================================
|
|
||||||
# TOPP BOKS
|
|
||||||
# ==============================================================
|
# ==============================================================
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
GlowBox @(
|
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 ""
|
Write-Host ""
|
||||||
|
|
||||||
# ==============================================================
|
Write-Host " ■ NESTE OPPGAVE" -ForegroundColor $PU
|
||||||
# NESTE OPPGAVE
|
|
||||||
# ==============================================================
|
|
||||||
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) {
|
||||||
$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## |$)')
|
||||||
|
|
@ -142,54 +118,28 @@ if (Test-Path $LOG) {
|
||||||
Select-Object -First 3 | ForEach-Object { $_.Trim() }
|
Select-Object -First 3 | ForEach-Object { $_.Trim() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($nl in $nesteLines) {
|
foreach ($nl in $nesteLines) { NesteBox $nl }
|
||||||
Write-Host " " -NoNewline
|
|
||||||
Write-Host "┌" -NoNewline -ForegroundColor Magenta
|
|
||||||
Write-Host ("─" * ($W - 2)) -ForegroundColor Magenta
|
|
||||||
Write-Host " " -NoNewline
|
|
||||||
Write-Host "│ " -NoNewline -ForegroundColor Magenta
|
|
||||||
Write-Host (Pad $nl ($W - 4)) -ForegroundColor Green
|
|
||||||
Write-Host " " -NoNewline
|
|
||||||
Write-Host "└" -NoNewline -ForegroundColor Magenta
|
|
||||||
Write-Host ("─" * ($W - 2)) -ForegroundColor Magenta
|
|
||||||
}
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# ==============================================================
|
Write-Host " ■ SISTE DOCS" -ForegroundColor $PU
|
||||||
# SISTE DOCS
|
|
||||||
# ==============================================================
|
|
||||||
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() } | Where-Object { $_ }
|
||||||
Where-Object { $_ }
|
|
||||||
foreach ($dl in $docLines) { DocBox $dl }
|
foreach ($dl in $docLines) { DocBox $dl }
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# ==============================================================
|
Write-Host " ■ STATUS" -ForegroundColor $PU
|
||||||
# STATUS
|
StatusLine $gitTxt; StatusLine $gcTxt; StatusLine $adcTxt; StatusLine $opaxTxt
|
||||||
# ==============================================================
|
|
||||||
Write-Host " ■ STATUS" -ForegroundColor Magenta
|
|
||||||
StatusLine $gitTxt
|
|
||||||
StatusLine $gcTxt
|
|
||||||
StatusLine $adcTxt
|
|
||||||
StatusLine $opaxTxt
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# ==============================================================
|
|
||||||
# BUNN BOKS
|
|
||||||
# ==============================================================
|
|
||||||
if ($allOK) {
|
if ($allOK) {
|
||||||
GlowBox @("", " ▶▶ ALL SYSTEMS GREEN ◀◀", "")
|
GlowBox @("", " ▶▶ ALL SYSTEMS GREEN ◀◀", "")
|
||||||
} else {
|
} else {
|
||||||
Write-Host " " -NoNewline; Write-Host ("█" * $W) -ForegroundColor Yellow
|
Write-Host " " -NoNewline; Write-Host ("█" * $W) -ForegroundColor $PU
|
||||||
Write-Host " █ ⚠ PARTIAL — sjekk status over" -ForegroundColor Yellow
|
Write-Host " █ ⚠ PARTIAL — sjekk status over" -ForegroundColor $PU
|
||||||
Write-Host " " -NoNewline; Write-Host ("█" * $W) -ForegroundColor Yellow
|
Write-Host " " -NoNewline; Write-Host ("█" * $W) -ForegroundColor $PU
|
||||||
}
|
}
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
# ==============================================================
|
|
||||||
# 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