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

@@ -84,8 +84,7 @@ export type GmailRunOptions = {
tailscaleTarget?: string;
};
const DEFAULT_GMAIL_TOPIC_IAM_MEMBER =
"serviceAccount:gmail-api-push@system.gserviceaccount.com";
const DEFAULT_GMAIL_TOPIC_IAM_MEMBER = "serviceAccount:gmail-api-push@system.gserviceaccount.com";
export async function runGmailSetup(opts: GmailSetupOptions) {
await ensureDependency("gcloud", ["--cask", "gcloud-cli"]);
@@ -103,20 +102,15 @@ export async function runGmailSetup(opts: GmailSetupOptions) {
const baseConfig = configSnapshot.config;
const hooksPath = normalizeHooksPath(baseConfig.hooks?.path);
const hookToken =
opts.hookToken ?? baseConfig.hooks?.token ?? generateHookToken();
const pushToken =
opts.pushToken ?? baseConfig.hooks?.gmail?.pushToken ?? generateHookToken();
const hookToken = opts.hookToken ?? baseConfig.hooks?.token ?? generateHookToken();
const pushToken = opts.pushToken ?? baseConfig.hooks?.gmail?.pushToken ?? generateHookToken();
const topicInput =
opts.topic ?? baseConfig.hooks?.gmail?.topic ?? DEFAULT_GMAIL_TOPIC;
const topicInput = opts.topic ?? baseConfig.hooks?.gmail?.topic ?? DEFAULT_GMAIL_TOPIC;
const parsedTopic = parseTopicPath(topicInput);
const topicName = parsedTopic?.topicName ?? topicInput;
const projectId =
opts.project ??
parsedTopic?.projectId ??
(await resolveProjectIdFromGogCredentials());
opts.project ?? parsedTopic?.projectId ?? (await resolveProjectIdFromGogCredentials());
// Gmail watch requires the Pub/Sub topic to live in the OAuth client project.
if (!projectId) {
throw new Error(
@@ -139,28 +133,23 @@ export async function runGmailSetup(opts: GmailSetupOptions) {
const configuredTailscaleTarget =
opts.tailscaleTarget ?? baseConfig.hooks?.gmail?.tailscale?.target;
const normalizedServePath =
typeof configuredServePath === "string" &&
configuredServePath.trim().length > 0
typeof configuredServePath === "string" && configuredServePath.trim().length > 0
? normalizeServePath(configuredServePath)
: DEFAULT_GMAIL_SERVE_PATH;
const normalizedTailscaleTarget =
typeof configuredTailscaleTarget === "string" &&
configuredTailscaleTarget.trim().length > 0
typeof configuredTailscaleTarget === "string" && configuredTailscaleTarget.trim().length > 0
? configuredTailscaleTarget.trim()
: undefined;
const includeBody = opts.includeBody ?? true;
const maxBytes = opts.maxBytes ?? DEFAULT_GMAIL_MAX_BYTES;
const renewEveryMinutes =
opts.renewEveryMinutes ?? DEFAULT_GMAIL_RENEW_MINUTES;
const renewEveryMinutes = opts.renewEveryMinutes ?? DEFAULT_GMAIL_RENEW_MINUTES;
const tailscaleMode = opts.tailscale ?? "funnel";
// Tailscale strips the path before proxying; keep a public path while gog
// listens on "/" whenever Tailscale is enabled.
const servePath = normalizeServePath(
tailscaleMode !== "off" && !normalizedTailscaleTarget
? "/"
: normalizedServePath,
tailscaleMode !== "off" && !normalizedTailscaleTarget ? "/" : normalizedServePath,
);
const tailscalePath = normalizeServePath(
opts.tailscalePath ??
@@ -256,9 +245,7 @@ export async function runGmailSetup(opts: GmailSetupOptions) {
const validated = validateConfigObject(nextConfig);
if (!validated.ok) {
throw new Error(
`Config validation failed: ${validated.issues[0]?.message ?? "invalid"}`,
);
throw new Error(`Config validation failed: ${validated.issues[0]?.message ?? "invalid"}`);
}
await writeConfigFile(validated.config);