46 lines
1.3 KiB
PowerShell
46 lines
1.3 KiB
PowerShell
param(
|
|
[string]$ScriptPath = "scripts/open-offline-real-client-window.ps1"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
|
|
$target = if ([System.IO.Path]::IsPathRooted($ScriptPath)) {
|
|
$ScriptPath
|
|
}
|
|
else {
|
|
Join-Path $repo $ScriptPath
|
|
}
|
|
|
|
if (-not (Test-Path -LiteralPath $target)) {
|
|
throw "script not found: $target"
|
|
}
|
|
|
|
$text = Get-Content -LiteralPath $target -Raw
|
|
|
|
$requiredPatterns = @(
|
|
@{ Name = "WatchSeconds parameter"; Pattern = '\[int\]\$WatchSeconds' },
|
|
@{ Name = "PollIntervalMs parameter"; Pattern = '\[int\]\$PollIntervalMs' },
|
|
@{ Name = "watch loop output"; Pattern = 'watch_iteration_count' },
|
|
@{ Name = "relaunch counter output"; Pattern = 'relaunch_count' },
|
|
@{ Name = "move repair counter output"; Pattern = 'repair_count' },
|
|
@{ Name = "closed window recovery"; Pattern = 'Relaunch-OfflineClient' },
|
|
@{ Name = "moved window recovery"; Pattern = 'Repair-ClientWindowPlacement' }
|
|
)
|
|
|
|
$missing = @()
|
|
foreach ($item in $requiredPatterns) {
|
|
if ($text -notmatch $item.Pattern) {
|
|
$missing += $item.Name
|
|
}
|
|
}
|
|
|
|
if ($missing.Count -gt 0) {
|
|
throw "watchdog contract missing: $($missing -join ', ')"
|
|
}
|
|
|
|
[pscustomobject]@{
|
|
ok = $true
|
|
script = $target
|
|
checked = $requiredPatterns.Count
|
|
} | ConvertTo-Json -Compress
|