mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-18 19:50:38 +09:00
34 lines
903 B
TypeScript
34 lines
903 B
TypeScript
|
|
import { readConfig, configExists, resolveConfigPath } from "../config/store.js";
|
||
|
|
import type { CheckResult } from "./index.js";
|
||
|
|
|
||
|
|
export function configCheck(configPath?: string): CheckResult {
|
||
|
|
const filePath = resolveConfigPath(configPath);
|
||
|
|
|
||
|
|
if (!configExists(configPath)) {
|
||
|
|
return {
|
||
|
|
name: "Config file",
|
||
|
|
status: "fail",
|
||
|
|
message: `Config file not found at ${filePath}`,
|
||
|
|
canRepair: false,
|
||
|
|
repairHint: "Run `paperclip onboard` to create one",
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
try {
|
||
|
|
readConfig(configPath);
|
||
|
|
return {
|
||
|
|
name: "Config file",
|
||
|
|
status: "pass",
|
||
|
|
message: `Valid config at ${filePath}`,
|
||
|
|
};
|
||
|
|
} catch (err) {
|
||
|
|
return {
|
||
|
|
name: "Config file",
|
||
|
|
status: "fail",
|
||
|
|
message: `Invalid config: ${err instanceof Error ? err.message : String(err)}`,
|
||
|
|
canRepair: false,
|
||
|
|
repairHint: "Run `paperclip onboard` to recreate",
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|