-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdoctor.ps1
More file actions
146 lines (118 loc) · 4.1 KB
/
doctor.ps1
File metadata and controls
146 lines (118 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<#
CyberAi Doctor Script (Read‑Only Diagnostics)
Hard‑coded for:
D:\tools\repos\SolanaRemix\CyberAi
#>
$RepoRoot = "D:\tools\repos\SolanaRemix\CyberAi"
$SiteDir = "$RepoRoot\site"
function Info($m){ Write-Host "[INFO] $m" -ForegroundColor Gray }
function Pass($m){ Write-Host "[PASS] $m" -ForegroundColor Green }
function Warn($m){ Write-Host "[WARN] $m" -ForegroundColor Yellow }
function Fail($m){ Write-Host "[FAIL] $m" -ForegroundColor Red }
$Global:FAILURES = 0
function MarkFail($msg){ Fail $msg; $Global:FAILURES++ }
Write-Host "`n=== CyberAi Doctor ===" -ForegroundColor Cyan
# -----------------------------
# 1. Repo layout
# -----------------------------
Info "Checking repo layout"
if (Test-Path $RepoRoot) {
Pass "Repo root exists"
} else {
MarkFail "Repo root missing: $RepoRoot"
}
if (Test-Path $SiteDir) {
Pass "Site directory exists"
} else {
MarkFail "Site directory missing: $SiteDir"
}
# -----------------------------
# 2. Tooling
# -----------------------------
Info "Checking Node and pnpm"
$node = Get-Command node -ErrorAction SilentlyContinue
$pnpm = Get-Command pnpm -ErrorAction SilentlyContinue
if ($node) { Pass "Node found: $($node.Source)" } else { MarkFail "Node not found" }
if ($pnpm) { Pass "pnpm found: $($pnpm.Source)" } else { MarkFail "pnpm not found" }
if ($node -and ($node.Source -match "Portable|scoop|nvm")) {
Warn "Portable Node detected — native binaries may break"
}
$pnpmVersion = (& pnpm -v)
Info "pnpm version: $pnpmVersion"
if ($pnpmVersion -like "10.*") {
Warn "pnpm v10 detected — strict security model may block native builds"
}
# -----------------------------
# 3. pnpm metadata
# -----------------------------
Info "Checking pnpm metadata"
$Paths = @{
"Virtual Store" = "$RepoRoot\node_modules\.pnpm"
"Ignored Metadata" = "$RepoRoot\node_modules\.ignored"
"pnpm Workspace Meta" = "$RepoRoot\.pnpm"
"pnpm Store" = "$RepoRoot\.pnpm-store"
"Lockfile" = "$RepoRoot\pnpm-lock.yaml"
}
foreach ($label in $Paths.Keys) {
$path = $Paths[$label]
if (Test-Path $path) {
Warn "$label present: $path"
} else {
Pass "$label clean"
}
}
# -----------------------------
# 4. Dangling symlinks
# -----------------------------
function Get-Dangling($path) {
if (-not (Test-Path $path)) { return @() }
Get-ChildItem -Recurse -Force $path |
Where-Object { $_.Attributes -match "ReparsePoint" } |
Where-Object { -not (Test-Path $_.Target) }
}
Info "Scanning for dangling symlinks"
$dangRoot = Get-Dangling "$RepoRoot\node_modules"
$dangSite = Get-Dangling "$SiteDir\node_modules"
if ($dangRoot.Count -gt 0) { MarkFail "Dangling symlinks in root: $($dangRoot.Count)" } else { Pass "No dangling symlinks in root" }
if ($dangSite.Count -gt 0) { MarkFail "Dangling symlinks in site: $($dangSite.Count)" } else { Pass "No dangling symlinks in site" }
# -----------------------------
# 5. Native binaries
# -----------------------------
function CheckBin($bin, $dir) {
Info "Checking $bin"
try {
$out = pnpm exec --dir $dir $bin --version 2>$null
if ($LASTEXITCODE -eq 0) {
Pass "$bin OK ($out)"
} else {
MarkFail "$bin missing or broken"
}
} catch {
MarkFail "$bin missing or broken"
}
}
Info "Validating toolchain"
CheckBin "esbuild" $RepoRoot
CheckBin "sharp" $RepoRoot
CheckBin "vite" $SiteDir
CheckBin "astro" $SiteDir
# -----------------------------
# 6. Lockfile
# -----------------------------
Info "Checking lockfile"
if (Test-Path "$RepoRoot\pnpm-lock.yaml") {
Pass "Lockfile exists"
} else {
Warn "Lockfile missing — install may not be deterministic"
}
# -----------------------------
# 7. Final report
# -----------------------------
Write-Host "`n=== CyberAi Doctor Report ===" -ForegroundColor Cyan
if ($Global:FAILURES -eq 0) {
Write-Host "All systems healthy. No failures detected." -ForegroundColor Green
} else {
Write-Host "$Global:FAILURES subsystem(s) reported failures." -ForegroundColor Red
Write-Host "Run bootstrap.ps1 to repair the workspace." -ForegroundColor Yellow
}
Write-Host ""