feat: add Coderrr Doctor diagnostic tool#127
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🚀 Thanks for opening a Pull Request! A maintainer will review this soon. Meanwhile: Your contribution helps make this project better! |
There was a problem hiding this comment.
Pull request overview
This PR introduces the “Coderrr Doctor” diagnostics feature to help users verify their local environment (Node, Python, .env, and backend connectivity), exposes it via a new CLI command, and adds initial documentation and tests.
Changes:
- Added
CoderrrDoctorcore module (src/doctor.js) providing environment checks for.env, Python, Node.js, and backend reachability. - Implemented a user-facing diagnostics CLI UI (
src/doctorUI.js) wired into the main CLI entrypoint (bin/coderrr.js) ascoderrr doctor. - Added a basic Jest test for Node version detection and a helper for generating a summarized diagnostics report, plus a brief usage doc page (
docs/doctor.md).
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/doctor.js |
Implements the core diagnostic checks (env file presence, Python version detection, Node version reporting, and backend connectivity using fetch). |
src/doctorUI.js |
Provides a chalk-based CLI UI that runs the doctor checks, prints per-check status, and advises the user when backend connectivity fails. |
src/utils/doctorHelpers.js |
Adds a small helper to generate a timestamped, high-level diagnostics report string from aggregated check results. |
bin/coderrr.js |
Registers the new doctor subcommand and wires it to runDiagnostics, passing through process.env.CODERRR_BACKEND for backend checks. |
test/doctor.test.js |
Introduces a Jest test that asserts checkNode returns a truthy status and a version string containing the Node v prefix. |
docs/doctor.md |
Documents the new coderrr doctor command with a short description and a usage example. |
| ## Usage | ||
| Run the following to check your setup: | ||
| ```bash | ||
| coderrr doctor No newline at end of file |
There was a problem hiding this comment.
The documentation code block is missing a closing triple backtick, which will cause the coderrr doctor snippet to render incorrectly in many Markdown viewers. Please add a terminating code fence on a new line after the coderrr doctor command so the example displays as a proper fenced code block.
| describe('Doctor Module', () => { | ||
| test('should detect node version', () => { | ||
| const node = doctor.checkNode(); | ||
| expect(node.status).toBe(true); | ||
| expect(node.version).toContain('v'); | ||
| }); | ||
| }); No newline at end of file |
There was a problem hiding this comment.
The Doctor Module tests only cover checkNode, but the new diagnostics feature also introduces checkEnv, checkPython, checkBackend, the CLI UI in doctorUI.js, and the report helper in utils/doctorHelpers.js, none of which have any tests despite other modules in this project (e.g., insights and CLI commands) having Jest coverage. To keep diagnostics reliable and prevent regressions, consider adding unit tests that exercise these additional checks (including failure paths, e.g., missing .env or unreachable backend) and at least one test around the doctor CLI command wiring.
| try { | ||
| const version = execSync('python --version').toString().trim(); | ||
| return { status: true, version }; | ||
| } catch { | ||
| return { status: false, version: 'Not found' }; | ||
| } |
There was a problem hiding this comment.
checkPython only attempts to run python --version, which will incorrectly report status: false on systems where only python3 is installed (common on many Linux distros) even though a suitable Python 3 runtime is available for the backend. To avoid false negatives in the diagnostics, consider falling back to python3 --version (and possibly py -3 --version on Windows) if the initial python invocation fails, and include which binary was detected in the version string or result payload.
| try { | |
| const version = execSync('python --version').toString().trim(); | |
| return { status: true, version }; | |
| } catch { | |
| return { status: false, version: 'Not found' }; | |
| } | |
| const candidates = ['python --version', 'python3 --version']; | |
| if (process.platform === 'win32') { | |
| candidates.push('py -3 --version'); | |
| } | |
| for (const cmd of candidates) { | |
| try { | |
| const output = execSync(cmd).toString().trim(); | |
| const binary = cmd.split(' ')[0]; | |
| return { status: true, version: `${binary}: ${output}` }; | |
| } catch (error) { | |
| // Try next candidate | |
| } | |
| } | |
| return { status: false, version: 'Not found' }; |
This pull request introduces a new diagnostic tool called "Coderrr Doctor" for checking and reporting on the local development environment. It adds both the core logic for environment checks and a user-friendly CLI output, along with basic documentation and initial test coverage.
The most important changes are:
Core Diagnostic Logic:
CoderrrDoctorclass insrc/doctor.jsto check for environment file presence, Python installation, Node.js version, and backend connectivity.User Interface and Reporting:
src/doctorUI.jsthat runs checks, displays colored status messages, and provides advice if backend connectivity fails.src/utils/doctorHelpers.jsto generate a formatted diagnostic report for potential export.Documentation:
docs/doctor.mdwith usage instructions for the newcoderrr doctorcommand.Testing:
test/doctor.test.jsto verify Node.js version detection in the doctor module.