2026-01-30 00:22:47 +00:00
|
|
|
package doctor
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"os"
|
|
|
|
|
"os/exec"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"strings"
|
|
|
|
|
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
"github.com/host-uk/core/pkg/i18n"
|
2026-01-30 00:22:47 +00:00
|
|
|
"github.com/host-uk/core/pkg/repos"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// checkGitHubSSH checks if SSH keys exist for GitHub access
|
|
|
|
|
func checkGitHubSSH() bool {
|
|
|
|
|
// Just check if SSH keys exist - don't try to authenticate
|
|
|
|
|
// (key might be locked/passphrase protected)
|
|
|
|
|
home, err := os.UserHomeDir()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sshDir := filepath.Join(home, ".ssh")
|
|
|
|
|
keyPatterns := []string{"id_rsa", "id_ed25519", "id_ecdsa", "id_dsa"}
|
|
|
|
|
|
|
|
|
|
for _, key := range keyPatterns {
|
|
|
|
|
keyPath := filepath.Join(sshDir, key)
|
|
|
|
|
if _, err := os.Stat(keyPath); err == nil {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// checkGitHubCLI checks if the GitHub CLI is authenticated
|
|
|
|
|
func checkGitHubCLI() bool {
|
|
|
|
|
cmd := exec.Command("gh", "auth", "status")
|
|
|
|
|
output, _ := cmd.CombinedOutput()
|
|
|
|
|
// Check for any successful login (even if there's also a failing token)
|
|
|
|
|
return strings.Contains(string(output), "Logged in to")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// checkWorkspace checks for repos.yaml and counts cloned repos
|
|
|
|
|
func checkWorkspace() {
|
|
|
|
|
registryPath, err := repos.FindRegistry()
|
|
|
|
|
if err == nil {
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Printf(" %s %s\n", successStyle.Render("✓"), i18n.T("cmd.doctor.repos_yaml_found", map[string]interface{}{"Path": registryPath}))
|
2026-01-30 00:22:47 +00:00
|
|
|
|
|
|
|
|
reg, err := repos.LoadRegistry(registryPath)
|
|
|
|
|
if err == nil {
|
|
|
|
|
basePath := reg.BasePath
|
|
|
|
|
if basePath == "" {
|
|
|
|
|
basePath = "./packages"
|
|
|
|
|
}
|
|
|
|
|
if !filepath.IsAbs(basePath) {
|
|
|
|
|
basePath = filepath.Join(filepath.Dir(registryPath), basePath)
|
|
|
|
|
}
|
|
|
|
|
if strings.HasPrefix(basePath, "~/") {
|
|
|
|
|
home, _ := os.UserHomeDir()
|
|
|
|
|
basePath = filepath.Join(home, basePath[2:])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Count existing repos
|
|
|
|
|
allRepos := reg.List()
|
|
|
|
|
var cloned int
|
|
|
|
|
for _, repo := range allRepos {
|
|
|
|
|
repoPath := filepath.Join(basePath, repo.Name)
|
|
|
|
|
if _, err := os.Stat(filepath.Join(repoPath, ".git")); err == nil {
|
|
|
|
|
cloned++
|
|
|
|
|
}
|
|
|
|
|
}
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Printf(" %s %s\n", successStyle.Render("✓"), i18n.T("cmd.doctor.repos_cloned", map[string]interface{}{"Cloned": cloned, "Total": len(allRepos)}))
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Printf(" %s %s\n", dimStyle.Render("○"), i18n.T("cmd.doctor.no_repos_yaml"))
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
}
|