mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
feat(doctor): add extras source/target health checks
Check each configured extra's source directory exists and count its files; warn when one or more target parent directories are unreachable. Runs in both global and project mode after the main doctor checks.
This commit is contained in:
@@ -92,6 +92,7 @@ func cmdDoctorGlobal() error {
|
||||
}
|
||||
|
||||
runDoctorChecks(cfg, result, false)
|
||||
checkExtras(cfg.Extras, result, false, cfg.Source, "")
|
||||
checkBackupStatus(false, backup.BackupDir())
|
||||
checkTrashStatus(trash.TrashDir())
|
||||
checkVersionDoctor(cfg)
|
||||
@@ -129,6 +130,7 @@ func cmdDoctorProject(root string) error {
|
||||
}
|
||||
|
||||
runDoctorChecks(cfg, result, true)
|
||||
checkExtras(rt.config.Extras, result, true, "", root)
|
||||
checkBackupStatus(true, "")
|
||||
checkTrashStatus(trash.ProjectTrashDir(root))
|
||||
checkVersionDoctor(cfg)
|
||||
@@ -732,6 +734,50 @@ func checkDuplicateSkills(cfg *config.Config, result *doctorResult, discovered [
|
||||
}
|
||||
}
|
||||
|
||||
// checkExtras verifies extras source directories exist and targets are reachable.
|
||||
func checkExtras(extras []config.ExtraConfig, result *doctorResult, isProject bool, source, projectRoot string) {
|
||||
if len(extras) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
ui.Header("Extras")
|
||||
|
||||
for _, extra := range extras {
|
||||
var sourceDir string
|
||||
if isProject {
|
||||
sourceDir = config.ExtrasSourceDirProject(projectRoot, extra.Name)
|
||||
} else {
|
||||
sourceDir = config.ExtrasSourceDir(source, extra.Name)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(sourceDir); os.IsNotExist(err) {
|
||||
result.addError()
|
||||
ui.Error("%s: source directory missing (%s)", extra.Name, sourceDir)
|
||||
continue
|
||||
}
|
||||
|
||||
files, _ := sync.DiscoverExtraFiles(sourceDir)
|
||||
ui.Success(" %s: source exists (%d files)", extra.Name, len(files))
|
||||
|
||||
reachable := 0
|
||||
for _, t := range extra.Targets {
|
||||
targetPath := t.Path
|
||||
if isProject && !filepath.IsAbs(targetPath) {
|
||||
targetPath = filepath.Join(projectRoot, targetPath)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Dir(targetPath)); err == nil {
|
||||
reachable++
|
||||
}
|
||||
}
|
||||
if reachable == len(extra.Targets) {
|
||||
ui.Success(" %s: all targets reachable (%d/%d)", extra.Name, reachable, len(extra.Targets))
|
||||
} else {
|
||||
result.addWarning()
|
||||
ui.Warning(" %s: some targets unreachable (%d/%d)", extra.Name, reachable, len(extra.Targets))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// checkBackupStatus shows last backup time
|
||||
func checkBackupStatus(isProject bool, backupDir string) {
|
||||
if isProject {
|
||||
|
||||
Reference in New Issue
Block a user