From 55959148ca5a60c577cebd5131b4bbf1897c25e7 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 22 Jun 2026 04:14:12 +0800 Subject: [PATCH] chore(deadcode): remove unused infra wrappers --- src/daemon/service-audit.test.ts | 17 ----------------- src/daemon/service-audit.ts | 5 ----- src/infra/gateway-process-argv.test.ts | 23 +---------------------- src/infra/gateway-process-argv.ts | 26 -------------------------- 4 files changed, 1 insertion(+), 70 deletions(-) diff --git a/src/daemon/service-audit.test.ts b/src/daemon/service-audit.test.ts index cbfbfb0f0aa4..1452b1d6c0b7 100644 --- a/src/daemon/service-audit.test.ts +++ b/src/daemon/service-audit.test.ts @@ -7,7 +7,6 @@ import { VERSION } from "../version.js"; import { auditGatewayServiceConfig, checkTokenDrift, - readGatewayServiceCommandPort, SERVICE_AUDIT_CODES, } from "./service-audit.js"; import { buildMinimalServicePath } from "./service-env.js"; @@ -344,22 +343,6 @@ describe("auditGatewayServiceConfig", () => { ).toBe(false); }); - it("reads gateway service ports from split and equals-form arguments", () => { - expect( - readGatewayServiceCommandPort(["/usr/bin/node", "entry.js", "gateway", "--port", "18888"]), - ).toBe(18888); - expect( - readGatewayServiceCommandPort(["/usr/bin/node", "entry.js", "gateway", "--port=18889"]), - ).toBe(18889); - expect(readGatewayServiceCommandPort(["/usr/bin/node", "entry.js", "gateway"])).toBe(undefined); - expect( - readGatewayServiceCommandPort(["/usr/bin/node", "entry.js", "gateway", "--port=0"]), - ).toBe(undefined); - expect( - readGatewayServiceCommandPort(["/usr/bin/node", "entry.js", "gateway", "--port=65536"]), - ).toBe(undefined); - }); - it("flags gateway service port drift from the expected config port", async () => { const audit = await auditGatewayServiceConfig({ env: { HOME: "/tmp" }, diff --git a/src/daemon/service-audit.ts b/src/daemon/service-audit.ts index 15ddf83b7074..a8a8c5f23207 100644 --- a/src/daemon/service-audit.ts +++ b/src/daemon/service-audit.ts @@ -290,11 +290,6 @@ function readGatewayServiceCommandPortState( return { kind: "missing" }; } -export function readGatewayServiceCommandPort(programArguments?: string[]): number | undefined { - const servicePort = readGatewayServiceCommandPortState(programArguments); - return servicePort.kind === "valid" ? servicePort.port : undefined; -} - function auditGatewayServicePort(params: { programArguments: string[] | undefined; issues: ServiceConfigIssue[]; diff --git a/src/infra/gateway-process-argv.test.ts b/src/infra/gateway-process-argv.test.ts index b082abfb5fc2..e910d39c719b 100644 --- a/src/infra/gateway-process-argv.test.ts +++ b/src/infra/gateway-process-argv.test.ts @@ -1,6 +1,6 @@ // Tests gateway process argv parsing for diagnostics. import { describe, expect, it } from "vitest"; -import { isGatewayArgv, parseProcCmdline, parseWindowsCmdline } from "./gateway-process-argv.js"; +import { isGatewayArgv, parseProcCmdline } from "./gateway-process-argv.js"; describe("parseProcCmdline", () => { it("splits null-delimited argv and trims empty entries", () => { @@ -18,27 +18,6 @@ describe("parseProcCmdline", () => { }); }); -describe("parseWindowsCmdline", () => { - it("splits unquoted tokens by whitespace", () => { - expect(parseWindowsCmdline("node.exe gateway run")).toEqual(["node.exe", "gateway", "run"]); - }); - - it("handles double-quoted paths with spaces", () => { - expect( - parseWindowsCmdline('"C:\\Program Files\\node.exe" "C:\\my app\\dist\\index.js" gateway run'), - ).toEqual(["C:\\Program Files\\node.exe", "C:\\my app\\dist\\index.js", "gateway", "run"]); - }); - - it("returns empty array for empty input", () => { - expect(parseWindowsCmdline("")).toStrictEqual([]); - expect(parseWindowsCmdline(" ")).toStrictEqual([]); - }); - - it("collapses consecutive spaces outside quotes", () => { - expect(parseWindowsCmdline("node.exe gateway run")).toEqual(["node.exe", "gateway", "run"]); - }); -}); - describe("isGatewayArgv", () => { it("requires a gateway token", () => { expect(isGatewayArgv(["node", "dist/index.js", "--port", "18789"])).toBe(false); diff --git a/src/infra/gateway-process-argv.ts b/src/infra/gateway-process-argv.ts index bd68c1550136..88bdfd12b5c5 100644 --- a/src/infra/gateway-process-argv.ts +++ b/src/infra/gateway-process-argv.ts @@ -10,32 +10,6 @@ export function parseProcCmdline(raw: string): string[] { return normalizeStringEntries(raw.split("\0")); } -/** - * Parse a Windows command line string into argv-style tokens, - * handling double-quoted paths (e.g. `"C:\Program Files\node.exe" gateway run`). - */ -export function parseWindowsCmdline(raw: string): string[] { - const args: string[] = []; - let current = ""; - let inQuote = false; - for (const char of raw) { - if (char === '"') { - inQuote = !inQuote; - } else if (char === " " && !inQuote) { - if (current) { - args.push(current); - current = ""; - } - } else { - current += char; - } - } - if (current) { - args.push(current); - } - return args; -} - export function isGatewayArgv(args: string[], opts?: { allowGatewayBinary?: boolean }): boolean { const normalized = args.map(normalizeProcArg); if (!normalized.includes("gateway")) {