mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-11 21:06:04 +00:00
Doctor: add lint --all (#96471)
* fix(doctor): keep audit scrub lint opt-in * fix(doctor): keep audit lint defaults internal * feat(doctor): add lint profiles
This commit is contained in:
@@ -112,6 +112,7 @@ describe("registerMaintenanceCommands doctor action", () => {
|
||||
"--json",
|
||||
"--severity-min",
|
||||
"error",
|
||||
"--all",
|
||||
"--skip",
|
||||
"a",
|
||||
"--only",
|
||||
@@ -123,6 +124,7 @@ describe("registerMaintenanceCommands doctor action", () => {
|
||||
expect(runDoctorLintCli).toHaveBeenCalledWith(runtime, {
|
||||
json: true,
|
||||
severityMin: "error",
|
||||
includeAllChecks: true,
|
||||
skipIds: ["a"],
|
||||
onlyIds: ["b"],
|
||||
allowExec: true,
|
||||
@@ -141,6 +143,17 @@ describe("registerMaintenanceCommands doctor action", () => {
|
||||
expect(runtime.exit).toHaveBeenCalledWith(2);
|
||||
});
|
||||
|
||||
it("rejects --all outside doctor lint mode", async () => {
|
||||
await runMaintenanceCli(["doctor", "--all"]);
|
||||
|
||||
expect(doctorCommand).not.toHaveBeenCalled();
|
||||
expect(runDoctorLintCli).not.toHaveBeenCalled();
|
||||
expect(runtime.error).toHaveBeenCalledWith(
|
||||
"doctor lint options require --lint. Use `openclaw doctor --lint ...`.",
|
||||
);
|
||||
expect(runtime.exit).toHaveBeenCalledWith(2);
|
||||
});
|
||||
|
||||
it("exits with code 2 when doctor lint mode fails before findings are emitted", async () => {
|
||||
runDoctorLintCli.mockRejectedValue(new Error("lint failed"));
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ export function registerMaintenanceCommands(program: Command) {
|
||||
"--severity-min <level>",
|
||||
"With --lint: drop findings below this severity (info|warning|error)",
|
||||
)
|
||||
.option("--all", "With --lint: run all registered checks, including opt-in checks", false)
|
||||
.option(
|
||||
"--skip <id>",
|
||||
"With --lint: skip a specific check id (repeatable)",
|
||||
@@ -60,6 +61,7 @@ export function registerMaintenanceCommands(program: Command) {
|
||||
const exitCode = await runDoctorLintCli(defaultRuntime, {
|
||||
json: Boolean(opts.json),
|
||||
severityMin: typeof opts.severityMin === "string" ? opts.severityMin : undefined,
|
||||
includeAllChecks: Boolean(opts.all),
|
||||
skipIds: Array.isArray(opts.skip) ? opts.skip : [],
|
||||
onlyIds: Array.isArray(opts.only) ? opts.only : [],
|
||||
allowExec: Boolean(opts.allowExec),
|
||||
@@ -180,12 +182,14 @@ function hasLintOnlyDoctorOptions(opts: {
|
||||
readonly json?: boolean;
|
||||
readonly postUpgrade?: boolean;
|
||||
readonly severityMin?: unknown;
|
||||
readonly all?: boolean;
|
||||
readonly skip?: unknown;
|
||||
readonly only?: unknown;
|
||||
}): boolean {
|
||||
return (
|
||||
(opts.json === true && opts.postUpgrade !== true) ||
|
||||
typeof opts.severityMin === "string" ||
|
||||
opts.all === true ||
|
||||
(Array.isArray(opts.skip) && opts.skip.length > 0) ||
|
||||
(Array.isArray(opts.only) && opts.only.length > 0)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user