style: biome fixes
This commit is contained in:
@@ -478,7 +478,11 @@ export function buildProgram() {
|
||||
"config|config+creds+sessions|full (default: interactive prompt)",
|
||||
)
|
||||
.option("--yes", "Skip confirmation prompts", false)
|
||||
.option("--non-interactive", "Disable prompts (requires --scope + --yes)", false)
|
||||
.option(
|
||||
"--non-interactive",
|
||||
"Disable prompts (requires --scope + --yes)",
|
||||
false,
|
||||
)
|
||||
.option("--dry-run", "Print actions without removing files", false)
|
||||
.action(async (opts) => {
|
||||
try {
|
||||
@@ -501,11 +505,7 @@ export function buildProgram() {
|
||||
.option("--state", "Remove state + config", false)
|
||||
.option("--workspace", "Remove workspace dirs", false)
|
||||
.option("--app", "Remove the macOS app", false)
|
||||
.option(
|
||||
"--all",
|
||||
"Remove service + state + workspace + app",
|
||||
false,
|
||||
)
|
||||
.option("--all", "Remove service + state + workspace + app", false)
|
||||
.option("--yes", "Skip confirmation prompts", false)
|
||||
.option("--non-interactive", "Disable prompts (requires --yes)", false)
|
||||
.option("--dry-run", "Print actions without removing files", false)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
import { resolveDefaultAgentWorkspaceDir } from "../agents/workspace.js";
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { resolveDefaultAgentWorkspaceDir } from "../agents/workspace.js";
|
||||
import { resolveHomeDir, resolveUserPath } from "../utils.js";
|
||||
|
||||
export type RemovalResult = {
|
||||
@@ -34,7 +33,10 @@ export function collectWorkspaceDirs(
|
||||
|
||||
export function isPathWithin(child: string, parent: string): boolean {
|
||||
const relative = path.relative(parent, child);
|
||||
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
||||
return (
|
||||
relative === "" ||
|
||||
(!relative.startsWith("..") && !path.isAbsolute(relative))
|
||||
);
|
||||
}
|
||||
|
||||
function isUnsafeRemovalTarget(target: string): boolean {
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
import { cancel, confirm, isCancel, select } from "@clack/prompts";
|
||||
|
||||
import {
|
||||
isNixMode,
|
||||
loadConfig,
|
||||
resolveConfigPath,
|
||||
resolveOAuthDir,
|
||||
resolveStateDir,
|
||||
isNixMode,
|
||||
} from "../config/config.js";
|
||||
import { resolveGatewayService } from "../daemon/service.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { stylePromptHint, stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js";
|
||||
import { collectWorkspaceDirs, isPathWithin, listAgentSessionDirs, removePath } from "./cleanup-utils.js";
|
||||
import {
|
||||
stylePromptHint,
|
||||
stylePromptMessage,
|
||||
stylePromptTitle,
|
||||
} from "../terminal/prompt-style.js";
|
||||
import {
|
||||
collectWorkspaceDirs,
|
||||
isPathWithin,
|
||||
listAgentSessionDirs,
|
||||
removePath,
|
||||
} from "./cleanup-utils.js";
|
||||
|
||||
export type ResetScope = "config" | "config+creds+sessions" | "full";
|
||||
|
||||
@@ -26,7 +35,9 @@ const selectStyled = <T>(params: Parameters<typeof select<T>>[0]) =>
|
||||
...params,
|
||||
message: stylePromptMessage(params.message),
|
||||
options: params.options.map((opt) =>
|
||||
opt.hint === undefined ? opt : { ...opt, hint: stylePromptHint(opt.hint) },
|
||||
opt.hint === undefined
|
||||
? opt
|
||||
: { ...opt, hint: stylePromptHint(opt.hint) },
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
import { cancel, confirm, isCancel, multiselect } from "@clack/prompts";
|
||||
import path from "node:path";
|
||||
import { cancel, confirm, isCancel, multiselect } from "@clack/prompts";
|
||||
|
||||
import { loadConfig, resolveConfigPath, resolveOAuthDir, resolveStateDir, isNixMode } from "../config/config.js";
|
||||
import {
|
||||
isNixMode,
|
||||
loadConfig,
|
||||
resolveConfigPath,
|
||||
resolveOAuthDir,
|
||||
resolveStateDir,
|
||||
} from "../config/config.js";
|
||||
import { resolveGatewayService } from "../daemon/service.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { stylePromptHint, stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js";
|
||||
import {
|
||||
stylePromptHint,
|
||||
stylePromptMessage,
|
||||
stylePromptTitle,
|
||||
} from "../terminal/prompt-style.js";
|
||||
import { resolveHomeDir } from "../utils.js";
|
||||
import { collectWorkspaceDirs, isPathWithin, removePath } from "./cleanup-utils.js";
|
||||
import {
|
||||
collectWorkspaceDirs,
|
||||
isPathWithin,
|
||||
removePath,
|
||||
} from "./cleanup-utils.js";
|
||||
|
||||
type UninstallScope = "service" | "state" | "workspace" | "app";
|
||||
|
||||
@@ -21,14 +35,14 @@ export type UninstallOptions = {
|
||||
dryRun?: boolean;
|
||||
};
|
||||
|
||||
const multiselectStyled = <T>(
|
||||
params: Parameters<typeof multiselect<T>>[0],
|
||||
) =>
|
||||
const multiselectStyled = <T>(params: Parameters<typeof multiselect<T>>[0]) =>
|
||||
multiselect({
|
||||
...params,
|
||||
message: stylePromptMessage(params.message),
|
||||
options: params.options.map((opt) =>
|
||||
opt.hint === undefined ? opt : { ...opt, hint: stylePromptHint(opt.hint) },
|
||||
opt.hint === undefined
|
||||
? opt
|
||||
: { ...opt, hint: stylePromptHint(opt.hint) },
|
||||
),
|
||||
});
|
||||
|
||||
@@ -101,7 +115,9 @@ export async function uninstallCommand(
|
||||
|
||||
if (!hadExplicit) {
|
||||
if (!interactive) {
|
||||
runtime.error("Non-interactive mode requires explicit scopes (use --all).");
|
||||
runtime.error(
|
||||
"Non-interactive mode requires explicit scopes (use --all).",
|
||||
);
|
||||
runtime.exit(1);
|
||||
return;
|
||||
}
|
||||
@@ -115,12 +131,18 @@ export async function uninstallCommand(
|
||||
},
|
||||
{ value: "state", label: "State + config", hint: "~/.clawdbot" },
|
||||
{ value: "workspace", label: "Workspace", hint: "agent files" },
|
||||
{ value: "app", label: "macOS app", hint: "/Applications/Clawdbot.app" },
|
||||
{
|
||||
value: "app",
|
||||
label: "macOS app",
|
||||
hint: "/Applications/Clawdbot.app",
|
||||
},
|
||||
],
|
||||
initialValues: ["service", "state", "workspace"],
|
||||
});
|
||||
if (isCancel(selection)) {
|
||||
cancel(stylePromptTitle("Uninstall cancelled.") ?? "Uninstall cancelled.");
|
||||
cancel(
|
||||
stylePromptTitle("Uninstall cancelled.") ?? "Uninstall cancelled.",
|
||||
);
|
||||
runtime.exit(0);
|
||||
return;
|
||||
}
|
||||
@@ -137,7 +159,9 @@ export async function uninstallCommand(
|
||||
message: stylePromptMessage("Proceed with uninstall?"),
|
||||
});
|
||||
if (isCancel(ok) || !ok) {
|
||||
cancel(stylePromptTitle("Uninstall cancelled.") ?? "Uninstall cancelled.");
|
||||
cancel(
|
||||
stylePromptTitle("Uninstall cancelled.") ?? "Uninstall cancelled.",
|
||||
);
|
||||
runtime.exit(0);
|
||||
return;
|
||||
}
|
||||
@@ -184,7 +208,10 @@ export async function uninstallCommand(
|
||||
|
||||
if (scopes.has("state") && !scopes.has("workspace")) {
|
||||
const home = resolveHomeDir();
|
||||
if (home && workspaceDirs.some((dir) => dir.startsWith(path.resolve(home)))) {
|
||||
if (
|
||||
home &&
|
||||
workspaceDirs.some((dir) => dir.startsWith(path.resolve(home)))
|
||||
) {
|
||||
runtime.log(
|
||||
"Tip: workspaces were preserved. Re-run with --workspace to remove them.",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user