Prettier had never been run in --check mode here before, so this had drifted across most files (markdown tables, long option() chains, line wrapping). Purely formatting, no logic changes - needed so a CI format:check gate can actually pass. Adds .prettierignore for pnpm-lock.yaml specifically: prettier's YAML formatter rewrites every quoted key (single -> double quotes) producing an ~8700-line diff of pure noise on a file pnpm itself owns the formatting of. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import fs from "node:fs";
|
|
import { ConfigError, loadConfig } from "../../lib/config/load";
|
|
import { isPortFree } from "../lib/network";
|
|
import { resolveConfigPath } from "../lib/paths";
|
|
|
|
export interface DoctorOptions {
|
|
config?: string;
|
|
}
|
|
|
|
export async function doctorCommand(opts: DoctorOptions): Promise<void> {
|
|
const rows: [string, string][] = [];
|
|
|
|
rows.push(["Node.js", process.version]);
|
|
|
|
const configPath = resolveConfigPath(opts.config);
|
|
const exists = fs.existsSync(configPath);
|
|
rows.push([
|
|
"Config path",
|
|
`${configPath} ${exists ? "(exists)" : "(not found)"}`,
|
|
]);
|
|
|
|
if (exists) {
|
|
try {
|
|
const { config } = loadConfig(configPath);
|
|
const portFree = await isPortFree(config.server.host, config.server.port);
|
|
rows.push([
|
|
"Port available",
|
|
portFree
|
|
? "yes"
|
|
: `no (${config.server.host}:${config.server.port} in use)`,
|
|
]);
|
|
rows.push(["Scripts configured", String(config.scripts.length)]);
|
|
rows.push(["Auth enabled", String(config.auth.enabled)]);
|
|
} catch (error) {
|
|
if (error instanceof ConfigError) {
|
|
rows.push(["Config", error.message]);
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
|
|
const labelWidth = Math.max(...rows.map(([label]) => label.length));
|
|
for (const [label, value] of rows) {
|
|
console.log(`${label.padEnd(labelWidth)} ${value}`);
|
|
}
|
|
}
|