2026-01-30 00:22:47 +00:00
|
|
|
package doctor
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os/exec"
|
|
|
|
|
"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
|
|
|
|
2026-02-16 14:24:37 +00:00
|
|
|
"forge.lthn.ai/core/go/pkg/i18n"
|
2026-01-30 00:22:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// check represents a tool check configuration
|
|
|
|
|
type check struct {
|
|
|
|
|
name string
|
|
|
|
|
description string
|
|
|
|
|
command string
|
|
|
|
|
args []string
|
|
|
|
|
versionFlag string
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
// requiredChecks returns tools that must be installed
|
|
|
|
|
func requiredChecks() []check {
|
|
|
|
|
return []check{
|
|
|
|
|
{
|
|
|
|
|
name: i18n.T("cmd.doctor.check.git.name"),
|
|
|
|
|
description: i18n.T("cmd.doctor.check.git.description"),
|
|
|
|
|
command: "git",
|
|
|
|
|
args: []string{"--version"},
|
|
|
|
|
versionFlag: "--version",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: i18n.T("cmd.doctor.check.gh.name"),
|
|
|
|
|
description: i18n.T("cmd.doctor.check.gh.description"),
|
|
|
|
|
command: "gh",
|
|
|
|
|
args: []string{"--version"},
|
|
|
|
|
versionFlag: "--version",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: i18n.T("cmd.doctor.check.php.name"),
|
|
|
|
|
description: i18n.T("cmd.doctor.check.php.description"),
|
|
|
|
|
command: "php",
|
|
|
|
|
args: []string{"-v"},
|
|
|
|
|
versionFlag: "-v",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: i18n.T("cmd.doctor.check.composer.name"),
|
|
|
|
|
description: i18n.T("cmd.doctor.check.composer.description"),
|
|
|
|
|
command: "composer",
|
|
|
|
|
args: []string{"--version"},
|
|
|
|
|
versionFlag: "--version",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: i18n.T("cmd.doctor.check.node.name"),
|
|
|
|
|
description: i18n.T("cmd.doctor.check.node.description"),
|
|
|
|
|
command: "node",
|
|
|
|
|
args: []string{"--version"},
|
|
|
|
|
versionFlag: "--version",
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
// optionalChecks returns tools that are nice to have
|
|
|
|
|
func optionalChecks() []check {
|
|
|
|
|
return []check{
|
|
|
|
|
{
|
|
|
|
|
name: i18n.T("cmd.doctor.check.pnpm.name"),
|
|
|
|
|
description: i18n.T("cmd.doctor.check.pnpm.description"),
|
|
|
|
|
command: "pnpm",
|
|
|
|
|
args: []string{"--version"},
|
|
|
|
|
versionFlag: "--version",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: i18n.T("cmd.doctor.check.claude.name"),
|
|
|
|
|
description: i18n.T("cmd.doctor.check.claude.description"),
|
|
|
|
|
command: "claude",
|
|
|
|
|
args: []string{"--version"},
|
|
|
|
|
versionFlag: "--version",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: i18n.T("cmd.doctor.check.docker.name"),
|
|
|
|
|
description: i18n.T("cmd.doctor.check.docker.description"),
|
|
|
|
|
command: "docker",
|
|
|
|
|
args: []string{"--version"},
|
|
|
|
|
versionFlag: "--version",
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// runCheck executes a tool check and returns success status and version info
|
|
|
|
|
func runCheck(c check) (bool, string) {
|
|
|
|
|
cmd := exec.Command(c.command, c.args...)
|
|
|
|
|
output, err := cmd.CombinedOutput()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Extract first line as version
|
|
|
|
|
lines := strings.Split(strings.TrimSpace(string(output)), "\n")
|
|
|
|
|
if len(lines) > 0 {
|
|
|
|
|
return true, strings.TrimSpace(lines[0])
|
|
|
|
|
}
|
|
|
|
|
return true, ""
|
|
|
|
|
}
|