mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
chore(deadcode): remove unused infra wrappers
This commit is contained in:
@@ -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" },
|
||||
|
||||
@@ -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[];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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")) {
|
||||
|
||||
Reference in New Issue
Block a user