chore: migrate to oxlint and oxfmt

Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-14 14:31:43 +00:00
parent 912ebffc63
commit c379191f80
1480 changed files with 28608 additions and 43547 deletions

View File

@@ -1,12 +1,6 @@
import { existsSync } from "node:fs";
import { promptYesNo } from "../cli/prompt.js";
import {
danger,
info,
logVerbose,
shouldLogVerbose,
warn,
} from "../globals.js";
import { danger, info, logVerbose, shouldLogVerbose, warn } from "../globals.js";
import { runExec } from "../process/exec.js";
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
import { colorize, isRich, theme } from "../terminal/theme.js";
@@ -39,9 +33,7 @@ export async function findTailscaleBinary(): Promise<string | null> {
// Use Promise.race with runExec to implement timeout
await Promise.race([
runExec(path, ["--version"], { timeoutMs: 3000 }),
new Promise<never>((_, reject) =>
setTimeout(() => reject(new Error("timeout")), 3000),
),
new Promise<never>((_, reject) => setTimeout(() => reject(new Error("timeout")), 3000)),
]);
return true;
} catch {
@@ -95,9 +87,7 @@ export async function findTailscaleBinary(): Promise<string | null> {
const candidates = stdout
.trim()
.split("\n")
.filter((line) =>
line.includes("/Tailscale.app/Contents/MacOS/Tailscale"),
);
.filter((line) => line.includes("/Tailscale.app/Contents/MacOS/Tailscale"));
for (const candidate of candidates) {
if (await checkBinary(candidate)) {
return candidate;
@@ -110,10 +100,7 @@ export async function findTailscaleBinary(): Promise<string | null> {
return null;
}
export async function getTailnetHostname(
exec: typeof runExec = runExec,
detectedBinary?: string,
) {
export async function getTailnetHostname(exec: typeof runExec = runExec, detectedBinary?: string) {
// Derive tailnet hostname (or IP fallback) from tailscale status JSON.
const candidates = detectedBinary
? [detectedBinary]
@@ -132,10 +119,7 @@ export async function getTailnetHostname(
typeof parsed.Self === "object" && parsed.Self !== null
? (parsed.Self as Record<string, unknown>)
: undefined;
const dns =
typeof self?.DNSName === "string"
? (self.DNSName as string)
: undefined;
const dns = typeof self?.DNSName === "string" ? (self.DNSName as string) : undefined;
const ips = Array.isArray(self?.TailscaleIPs)
? ((parsed.Self as { TailscaleIPs?: string[] }).TailscaleIPs ?? [])
: [];
@@ -230,16 +214,10 @@ export async function ensureFunnel(
// Ensure Funnel is enabled and publish the webhook port.
try {
const tailscaleBin = await getTailscaleBinary();
const statusOut = (
await exec(tailscaleBin, ["funnel", "status", "--json"])
).stdout.trim();
const parsed = statusOut
? (JSON.parse(statusOut) as Record<string, unknown>)
: {};
const statusOut = (await exec(tailscaleBin, ["funnel", "status", "--json"])).stdout.trim();
const parsed = statusOut ? (JSON.parse(statusOut) as Record<string, unknown>) : {};
if (!parsed || Object.keys(parsed).length === 0) {
runtime.error(
danger("Tailscale Funnel is not enabled on this tailnet/device."),
);
runtime.error(danger("Tailscale Funnel is not enabled on this tailnet/device."));
runtime.error(
info(
"Enable in admin console: https://login.tailscale.com/admin (see https://tailscale.com/kb/1223/funnel)",
@@ -250,10 +228,7 @@ export async function ensureFunnel(
"macOS user-space tailscaled docs: https://github.com/tailscale/tailscale/wiki/Tailscaled-on-macOS",
),
);
const proceed = await prompt(
"Attempt local setup with user-space tailscaled?",
true,
);
const proceed = await prompt("Attempt local setup with user-space tailscaled?", true);
if (!proceed) runtime.exit(1);
await ensureBinary("brew", exec, runtime);
await ensureGoInstalled(exec, prompt, runtime);
@@ -261,14 +236,10 @@ export async function ensureFunnel(
}
logVerbose(`Enabling funnel on port ${port}`);
const { stdout } = await exec(
tailscaleBin,
["funnel", "--yes", "--bg", `${port}`],
{
maxBuffer: 200_000,
timeoutMs: 15_000,
},
);
const { stdout } = await exec(tailscaleBin, ["funnel", "--yes", "--bg", `${port}`], {
maxBuffer: 200_000,
timeoutMs: 15_000,
});
if (stdout.trim()) console.log(stdout.trim());
} catch (err) {
const errOutput = err as { stdout?: unknown; stderr?: unknown };
@@ -287,19 +258,14 @@ export async function ensureFunnel(
);
}
}
if (
stderr.includes("client version") ||
stdout.includes("client version")
) {
if (stderr.includes("client version") || stdout.includes("client version")) {
console.error(
warn(
"Tailscale client/server version mismatch detected; try updating tailscale/tailscaled.",
),
);
}
runtime.error(
"Failed to enable Tailscale Funnel. Is it allowed on your tailnet?",
);
runtime.error("Failed to enable Tailscale Funnel. Is it allowed on your tailnet?");
runtime.error(
info(
"Tip: Funnel is optional for CLAWDBOT. You can keep running the web gateway without it: `pnpm clawdbot gateway`",
@@ -319,10 +285,7 @@ export async function ensureFunnel(
}
}
export async function enableTailscaleServe(
port: number,
exec: typeof runExec = runExec,
) {
export async function enableTailscaleServe(port: number, exec: typeof runExec = runExec) {
const tailscaleBin = await getTailscaleBinary();
await exec(tailscaleBin, ["serve", "--bg", "--yes", `${port}`], {
maxBuffer: 200_000,
@@ -338,10 +301,7 @@ export async function disableTailscaleServe(exec: typeof runExec = runExec) {
});
}
export async function enableTailscaleFunnel(
port: number,
exec: typeof runExec = runExec,
) {
export async function enableTailscaleFunnel(port: number, exec: typeof runExec = runExec) {
const tailscaleBin = await getTailscaleBinary();
await exec(tailscaleBin, ["funnel", "--bg", "--yes", `${port}`], {
maxBuffer: 200_000,