feat: Added doctor command to test if all requirements are install.#20
feat: Added doctor command to test if all requirements are install.#20
Conversation
src/doctor.ts
Outdated
| case 'linux': { | ||
| // Try to detect the Linux distribution | ||
| try { | ||
| const fs = require('fs'); |
There was a problem hiding this comment.
I think require('fs') in an ESM output file will throw ReferenceError: require is not defined at runtime on Node.js 20-21 (only 22.12+ made require available in ESM). Since the tool supports Node >= 20, should this be import { existsSync } from 'fs' at the top of the file instead? I could be wrong on this.
| if (fs.existsSync('/etc/debian_version')) { | ||
| // Debian/Ubuntu | ||
| return { | ||
| command: 'sudo', |
There was a problem hiding this comment.
--fix runs sudo apt/dnf install with -y and no user confirmation beyond the flag itself. Should this prompt before escalating to root?
src/__tests__/doctor.test.ts
Outdated
| } as any); | ||
|
|
||
| const { runDoctor } = await import('../doctor.js'); | ||
| await expect(runDoctor(false)).resolves.not.toThrow(); |
There was a problem hiding this comment.
Every test just asserts resolves.not.toThrow() - none verify the actual behavior (logged messages, execa call args, return values). These will pass even if the implementation is completely wrong. The test names say "should detect when X" but nothing is actually detected or asserted.
There was a problem hiding this comment.
Something like:
it('should detect when Node.js version is too old', async () => {
const logSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
Object.defineProperty(process, 'version', {
value: 'v18.0.0',
writable: true,
});
const { runDoctor } = await import('../doctor.js');
await runDoctor(false);
expect(logSpy).toHaveBeenCalledWith(
expect.stringContaining('Node.js version v18.0.0 is not supported')
);
});
src/__tests__/doctor.test.ts
Outdated
| import { jest } from '@jest/globals'; | ||
| import { execa } from 'execa'; | ||
|
|
||
| // Mock execa |
There was a problem hiding this comment.
nit: unnecessary comment. There are a few of these - where the comment doesn't add value - just repeats what the line below easily reads on its own.
|
🎉 This PR is included in version 1.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
In order to use the Patternfly cli it is required that a user has node version 20 or greater, corepack enabled, and github cli installed for their OS. In order to make this easier for new users the doctor command was added to help the user set up these prerequisites.
Developed with Claude and Opus