Files
paperclip/cli/src/checks/log-check.ts
Forgotten f1b558dcfb CLI: add secrets configuration, doctor check, and path resolver extraction
Add secrets section to onboard, configure, and doctor commands. Doctor
validates local encrypted provider key file and can auto-repair missing
keys. Extract shared path resolution into path-resolver module used by
database and log checks. Show secrets env vars in `paperclip env`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 15:43:59 -06:00

39 lines
1.1 KiB
TypeScript

import fs from "node:fs";
import type { PaperclipConfig } from "../config/schema.js";
import type { CheckResult } from "./index.js";
import { resolveRuntimeLikePath } from "./path-resolver.js";
export function logCheck(config: PaperclipConfig, configPath?: string): CheckResult {
const logDir = resolveRuntimeLikePath(config.logging.logDir, configPath);
const reportedDir = logDir;
if (!fs.existsSync(logDir)) {
return {
name: "Log directory",
status: "warn",
message: `Log directory does not exist: ${reportedDir}`,
canRepair: true,
repair: () => {
fs.mkdirSync(reportedDir, { recursive: true });
},
};
}
try {
fs.accessSync(reportedDir, fs.constants.W_OK);
return {
name: "Log directory",
status: "pass",
message: `Log directory is writable: ${reportedDir}`,
};
} catch {
return {
name: "Log directory",
status: "fail",
message: `Log directory is not writable: ${logDir}`,
canRepair: false,
repairHint: "Check file permissions on the log directory",
};
}
}