$ErrorActionPreference = 'Stop'
if (-not (Get-Command ruby -ErrorAction SilentlyContinue)) { throw 'ruby tidak ditemukan.' }
$file = & ruby .\app.rb --dashboard
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$target = ($file | Select-Object -Last 1).Trim()
if ($target -and (Test-Path $target)) {
  Start-Process $target
  Write-Output "Dashboard dibuka: $target"
} else {
  throw 'File dashboard tidak berhasil dibuat.'
}
