mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
Require root-owned, non-group/other-writable pmg for --system install; allow remove without that validation. Doctor checks npm resolution for PATH precedence, uses ImpliesInterception instead of message matching, and documents version-manager shadowing. Pass profile bin dir from the shim manager and note that system config ignores per-user files. Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.0 KiB
Go
55 lines
1.0 KiB
Go
package doctor
|
|
|
|
type CheckStatus int
|
|
|
|
const (
|
|
StatusPass CheckStatus = iota
|
|
StatusWarn
|
|
StatusFail
|
|
)
|
|
|
|
type CheckResult struct {
|
|
Name string
|
|
Category string
|
|
Status CheckStatus
|
|
Message string
|
|
ImpliesInterception bool
|
|
}
|
|
|
|
type Check struct {
|
|
Name string
|
|
Category string
|
|
Run func() CheckResult
|
|
}
|
|
|
|
func RunChecks(checks []Check) []CheckResult {
|
|
results := make([]CheckResult, 0, len(checks))
|
|
for _, c := range checks {
|
|
result := c.Run()
|
|
result.Name = c.Name
|
|
result.Category = c.Category
|
|
results = append(results, result)
|
|
}
|
|
return results
|
|
}
|
|
|
|
func HasFailures(results []CheckResult) bool {
|
|
for _, r := range results {
|
|
if r.Status == StatusFail {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func CategorySummary(results []CheckResult) map[string]CheckStatus {
|
|
summary := make(map[string]CheckStatus)
|
|
for _, r := range results {
|
|
current, exists := summary[r.Category]
|
|
if !exists || r.Status > current {
|
|
summary[r.Category] = r.Status
|
|
}
|
|
}
|
|
return summary
|
|
}
|