Skip to content

feat: add kiqr doctor preflight command#12

Merged
kjellberg merged 1 commit into
kiqr:mainfrom
kjellbergzoey:feat/doctor-command
Jun 7, 2026
Merged

feat: add kiqr doctor preflight command#12
kjellberg merged 1 commit into
kiqr:mainfrom
kjellbergzoey:feat/doctor-command

Conversation

@kjellbergzoey

Copy link
Copy Markdown
Contributor

Summary

Adds a kiqr doctor command that runs cheap, read-only environment preflight checks and reports each as pass/fail with an actionable message. Useful before kiqr up to catch the usual culprits.

Checks:

  • Docker installed (isDockerInstalled)
  • Docker running (isDockerRunning) — skipped cleanly when the CLI isn't present
  • Traefik port 5477 available (isPortAvailable)
  • LiveReload port 35729 available (isPortAvailable)
  • Platform — detects WSL via /proc/version (informational)

Design

  • All check logic is in a pure, testable src/lib/doctor.ts that returns {name, ok, detail}[].
  • src/commands/doctor.tsx is a thin Ink renderer that exits non-zero if any check fails.
  • The port constants reference the values already used by src/lib/traefik.ts and src/lib/livereload.ts, and this gives the previously-unused isPortAvailable helper a real caller.

Tests

tests/lib/doctor.test.ts (10 cases) mocks the docker/ports modules and node:fs (for WSL detection), following the existing tests/lib/docker.test.ts / tests/lib/ports.test.ts style. Covers healthy env, missing Docker CLI (and that the daemon is then not probed), daemon down, both port checks, port-in-use, and WSL detection.

Also lists kiqr doctor in the kiqr help screen and the README command table.

npm run typecheck, npm test (80 passing), and npm run build all green.

Note: this command only performs static/read-only checks (no docker compose run), so it is fully verifiable without a Docker daemon.

🤖 Generated with Claude Code

Add a `kiqr doctor` command that runs cheap, read-only environment checks
and reports pass/fail with actionable messages:

- Docker installed (isDockerInstalled)
- Docker running (isDockerRunning) — skipped when the CLI is absent
- Traefik port 5477 available (isPortAvailable)
- LiveReload port 35729 available (isPortAvailable)
- Platform (WSL detection via /proc/version)

The check logic lives in a pure, testable src/lib/doctor.ts returning a
list of {name, ok, detail} results; src/commands/doctor.tsx is a thin Ink
renderer that exits non-zero when any check fails. This also gives the
previously-unused isPortAvailable helper in src/lib/ports.ts a real caller.

Adds tests/lib/doctor.test.ts (10 cases) mocking node:child_process via the
docker/ports modules and node:fs for WSL detection, mirroring the existing
docker/ports test style. Lists the command in `kiqr` help and the README.

typecheck, test (80 passing), and build all green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kjellberg
kjellberg merged commit 2a9cc92 into kiqr:main Jun 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants