Skip to content

Commit 23ceb49

Browse files
committed
fix(doctor): link each toolchain fix to its install guide
The fixes for a missing uv, Node, pnpm or JDK named the tool and nothing more ("install pnpm"). Each now links its section of docs/guides/toolchains.md, and a missing uv under the python check gets the same fix as the uv check.
1 parent 539aefb commit 23ceb49

2 files changed

Lines changed: 38 additions & 6 deletions

File tree

‎cli/src/coding_study/application/doctor.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
PYTHON_VERSION = "3.13"
5454
MINIMUM_NODE_MAJOR = 24
5555
JAVA_MAJOR = 21
56+
TOOLCHAINS_GUIDE = "https://github.com/bkuberek/coding-study/blob/main/docs/guides/toolchains.md"
57+
INSTALL_UV = f"install uv: {TOOLCHAINS_GUIDE}#python-and-uv"
58+
INSTALL_PNPM = f"install pnpm: {TOOLCHAINS_GUIDE}#nodejs-and-pnpm"
5659

5760
_DOTTED_VERSION = re.compile(r"(?P<version>\d+(?:\.\d+)+)")
5861
_JAVA_VERSION = re.compile(r'version "(?P<version>\d+(?:\.\d+)*)')
@@ -244,9 +247,9 @@ def run_doctor(environment: DoctorEnvironment, notify: ProgressNotice) -> Doctor
244247
tools = environment.tools
245248
results = [
246249
_python(tools),
247-
_present_tool(tools, "uv", "install uv: https://docs.astral.sh/uv/"),
250+
_present_tool(tools, "uv", INSTALL_UV),
248251
_node(tools),
249-
_present_tool(tools, "pnpm", "install pnpm"),
252+
_present_tool(tools, "pnpm", INSTALL_PNPM),
250253
_java(tools),
251254
_gradle(tools),
252255
_config(environment.config),
@@ -284,7 +287,10 @@ def _python(tools: ToolProbe) -> CheckResult:
284287
found = tools.run(("uv", "python", "find", PYTHON_VERSION))
285288
if found is None:
286289
return CheckResult(
287-
"python", CheckStatus.FAIL, f"uv not found (uv provides Python {PYTHON_VERSION})"
290+
"python",
291+
CheckStatus.FAIL,
292+
f"uv not found (uv provides Python {PYTHON_VERSION})",
293+
fix=INSTALL_UV,
288294
)
289295
interpreters = found.output.strip().splitlines()
290296
if found.exit_code != 0 or not interpreters:
@@ -309,7 +315,7 @@ def _present_version(name: str, version: str | _Unavailable, fix: str | None) ->
309315

310316
def _node(tools: ToolProbe) -> CheckResult:
311317
version = _version_of(tools, ("node", "--version"))
312-
fix = f"install Node {MINIMUM_NODE_MAJOR} or newer"
318+
fix = f"install Node {MINIMUM_NODE_MAJOR} or newer: {TOOLCHAINS_GUIDE}#nodejs-and-pnpm"
313319
if isinstance(version, _Unavailable):
314320
return CheckResult("node", CheckStatus.FAIL, version.reason, fix=fix)
315321
if _major(version) < MINIMUM_NODE_MAJOR:
@@ -320,7 +326,7 @@ def _node(tools: ToolProbe) -> CheckResult:
320326

321327
def _java(tools: ToolProbe) -> CheckResult:
322328
version = _version_of(tools, ("java", "-version"), _JAVA_VERSION)
323-
fix = f"install JDK {JAVA_MAJOR}"
329+
fix = f"install JDK {JAVA_MAJOR}: {TOOLCHAINS_GUIDE}#jdk-{JAVA_MAJOR}"
324330
if isinstance(version, _Unavailable):
325331
return CheckResult("java", CheckStatus.FAIL, version.reason, fix=fix)
326332
if _major(version) != JAVA_MAJOR:

‎cli/tests/application/test_doctor.py‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"typescript/node_modules",
5959
}
6060
RUNNING_VERSION = "0.1.0"
61+
TOOLCHAINS_GUIDE = "https://github.com/bkuberek/coding-study/blob/main/docs/guides/toolchains.md"
6162

6263

6364
@dataclass
@@ -251,7 +252,32 @@ def test_java_must_be_21(output, expected):
251252

252253
def test_missing_tool_fails_with_fix():
253254
result = check(doctor(tools_with(("pnpm", "--version"), None)), "pnpm")
254-
assert (result.status, result.detail, result.fix) == (FAIL, "not found on PATH", "install pnpm")
255+
assert (result.status, result.detail, result.fix) == (
256+
FAIL,
257+
"not found on PATH",
258+
f"install pnpm: {TOOLCHAINS_GUIDE}#nodejs-and-pnpm",
259+
)
260+
261+
262+
@pytest.mark.parametrize(
263+
("command", "name", "fix"),
264+
[
265+
(("uv", "--version"), "uv", f"install uv: {TOOLCHAINS_GUIDE}#python-and-uv"),
266+
(
267+
("uv", "python", "find", "3.13"),
268+
"python",
269+
f"install uv: {TOOLCHAINS_GUIDE}#python-and-uv",
270+
),
271+
(
272+
("node", "--version"),
273+
"node",
274+
f"install Node 24 or newer: {TOOLCHAINS_GUIDE}#nodejs-and-pnpm",
275+
),
276+
(("java", "-version"), "java", f"install JDK 21: {TOOLCHAINS_GUIDE}#jdk-21"),
277+
],
278+
)
279+
def test_missing_toolchain_fix_links_its_install_guide(command, name, fix):
280+
assert check(doctor(tools_with(command, None)), name).fix == fix
255281

256282

257283
def test_failing_version_command_fails():

0 commit comments

Comments
 (0)