style: fix lint formatting

This commit is contained in:
Peter Steinberger
2026-01-09 07:52:28 +01:00
parent 37cbcc97d3
commit 185727c696
7 changed files with 92 additions and 73 deletions

View File

@@ -1,23 +1,70 @@
import { describe, expect, it, vi } from "vitest";
import type { runCommandWithTimeout } from "../process/exec.js";
import { WIDE_AREA_DISCOVERY_DOMAIN } from "./widearea-dns.js";
import { discoverGatewayBeacons } from "./bonjour-discovery.js";
import { WIDE_AREA_DISCOVERY_DOMAIN } from "./widearea-dns.js";
describe("bonjour-discovery", () => {
it("discovers beacons on darwin across local + wide-area domains", async () => {
const calls: Array<{ argv: string[]; timeoutMs: number }> = [];
const run = vi.fn(async (argv: string[], options: { timeoutMs: number }) => {
calls.push({ argv, timeoutMs: options.timeoutMs });
const domain = argv[3] ?? "";
const run = vi.fn(
async (argv: string[], options: { timeoutMs: number }) => {
calls.push({ argv, timeoutMs: options.timeoutMs });
const domain = argv[3] ?? "";
if (argv[0] === "dns-sd" && argv[1] === "-B") {
if (domain === "local.") {
return {
stdout: [
"Add 2 3 local. _clawdbot-bridge._tcp. Studio Bridge",
"Add 2 3 local. _clawdbot-bridge._tcp. Laptop Bridge",
"",
].join("\n"),
stderr: "",
code: 0,
signal: null,
killed: false,
};
}
if (domain === WIDE_AREA_DISCOVERY_DOMAIN) {
return {
stdout: [
`Add 2 3 ${WIDE_AREA_DISCOVERY_DOMAIN} _clawdbot-bridge._tcp. Tailnet Bridge`,
"",
].join("\n"),
stderr: "",
code: 0,
signal: null,
killed: false,
};
}
}
if (argv[0] === "dns-sd" && argv[1] === "-L") {
const instance = argv[2] ?? "";
const host =
instance === "Studio Bridge"
? "studio.local"
: instance === "Laptop Bridge"
? "laptop.local"
: "tailnet.local";
const tailnetDns =
instance === "Tailnet Bridge" ? "studio.tailnet.ts.net" : "";
const txtParts = [
"txtvers=1",
`displayName=${instance.replace(" Bridge", "")}`,
`lanHost=${host}`,
"gatewayPort=18789",
"bridgePort=18790",
"sshPort=22",
tailnetDns ? `tailnetDns=${tailnetDns}` : null,
].filter((v): v is string => Boolean(v));
if (argv[0] === "dns-sd" && argv[1] === "-B") {
if (domain === "local.") {
return {
stdout: [
"Add 2 3 local. _clawdbot-bridge._tcp. Studio Bridge",
"Add 2 3 local. _clawdbot-bridge._tcp. Laptop Bridge",
`${instance}._clawdbot-bridge._tcp. can be reached at ${host}:18790`,
txtParts.join(" "),
"",
].join("\n"),
stderr: "",
@@ -26,55 +73,10 @@ describe("bonjour-discovery", () => {
killed: false,
};
}
if (domain === WIDE_AREA_DISCOVERY_DOMAIN) {
return {
stdout: [
`Add 2 3 ${WIDE_AREA_DISCOVERY_DOMAIN} _clawdbot-bridge._tcp. Tailnet Bridge`,
"",
].join("\n"),
stderr: "",
code: 0,
signal: null,
killed: false,
};
}
}
if (argv[0] === "dns-sd" && argv[1] === "-L") {
const instance = argv[2] ?? "";
const host =
instance === "Studio Bridge"
? "studio.local"
: instance === "Laptop Bridge"
? "laptop.local"
: "tailnet.local";
const tailnetDns =
instance === "Tailnet Bridge" ? "studio.tailnet.ts.net" : "";
const txtParts = [
"txtvers=1",
`displayName=${instance.replace(" Bridge", "")}`,
`lanHost=${host}`,
"gatewayPort=18789",
"bridgePort=18790",
"sshPort=22",
tailnetDns ? `tailnetDns=${tailnetDns}` : null,
].filter((v): v is string => Boolean(v));
return {
stdout: [
`${instance}._clawdbot-bridge._tcp. can be reached at ${host}:18790`,
txtParts.join(" "),
"",
].join("\n"),
stderr: "",
code: 0,
signal: null,
killed: false,
};
}
throw new Error(`unexpected argv: ${argv.join(" ")}`);
});
throw new Error(`unexpected argv: ${argv.join(" ")}`);
},
);
const beacons = await discoverGatewayBeacons({
platform: "darwin",