mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 04:01:48 +00:00
refactor(cli): privatize internal exports (#106848)
This commit is contained in:
committed by
GitHub
parent
710d1eb443
commit
e69df7ef22
@@ -949,22 +949,15 @@ export const KNIP_UNUSED_EXPORT_BASELINE = [
|
||||
"src/cli/command-path-policy.ts: resolveCliCatalogCommandPath",
|
||||
"src/cli/command-secret-gateway.ts: testing",
|
||||
"src/cli/cron-cli/register.cron-simple.ts: loadCronJobForShow",
|
||||
"src/cli/daemon-cli/launchd-recovery.ts: LAUNCH_AGENT_RECOVERY_MESSAGE",
|
||||
"src/cli/daemon-cli/response.ts: buildDaemonHintItems",
|
||||
"src/cli/gateway-cli/qa-parent-watchdog.ts: QA_PARENT_PID_ENV",
|
||||
"src/cli/gateway-cli/qa-parent-watchdog.ts: QA_STAGED_RUNTIME_ROOT_ENV",
|
||||
"src/cli/gateway-cli/qa-parent-watchdog.ts: QA_TEMP_ROOT_ENV",
|
||||
"src/cli/gateway-cli/run.ts: testing",
|
||||
"src/cli/nodes-camera.ts: writeUrlToFile",
|
||||
"src/cli/plugins-install-command.ts: loadConfigForInstall",
|
||||
"src/cli/plugins-list-format.ts: formatPluginLine",
|
||||
"src/cli/plugins-uninstall-command.ts: PluginUninstallOptions",
|
||||
"src/cli/ports.ts: listPortListeners",
|
||||
"src/cli/ports.ts: parseLsofOutput",
|
||||
"src/cli/ports.ts: PortProcess",
|
||||
"src/cli/ports.ts: probePortFree",
|
||||
"src/cli/startup-metadata.ts: testing",
|
||||
"src/cli/tagline.ts: DEFAULT_TAGLINE",
|
||||
"src/cli/update-cli/progress.ts: inferUpdateFailureHints",
|
||||
"src/cli/update-cli/update-command-plugins.ts: buildInvalidConfigPostCoreUpdateResult",
|
||||
"src/cli/update-cli/update-command-plugins.ts: collectMissingPluginInstallPayloads",
|
||||
|
||||
@@ -4,9 +4,11 @@ import { spawnSync } from "node:child_process";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { forceFreePort, type PortProcess } from "../src/cli/ports.js";
|
||||
import { forceFreePort } from "../src/cli/ports.js";
|
||||
import { resolveGatewayPort } from "../src/config/config.js";
|
||||
|
||||
type PortProcess = ReturnType<typeof forceFreePort>[number];
|
||||
|
||||
function usage(): string {
|
||||
return [
|
||||
"Usage: node --import tsx scripts/test-force.ts",
|
||||
|
||||
@@ -20,12 +20,10 @@ vi.mock("../../daemon/launchd.js", () => ({
|
||||
}));
|
||||
|
||||
let recoverInstalledLaunchAgent: typeof import("./launchd-recovery.js").recoverInstalledLaunchAgent;
|
||||
let LAUNCH_AGENT_RECOVERY_MESSAGE: typeof import("./launchd-recovery.js").LAUNCH_AGENT_RECOVERY_MESSAGE;
|
||||
|
||||
describe("recoverInstalledLaunchAgent", () => {
|
||||
beforeAll(async () => {
|
||||
({ recoverInstalledLaunchAgent, LAUNCH_AGENT_RECOVERY_MESSAGE } =
|
||||
await import("./launchd-recovery.js"));
|
||||
({ recoverInstalledLaunchAgent } = await import("./launchd-recovery.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -57,7 +55,7 @@ describe("recoverInstalledLaunchAgent", () => {
|
||||
await expect(recoverInstalledLaunchAgent({ result: "restarted" })).resolves.toEqual({
|
||||
result: "restarted",
|
||||
loaded: true,
|
||||
message: LAUNCH_AGENT_RECOVERY_MESSAGE,
|
||||
message: "Gateway LaunchAgent was installed but not loaded; re-bootstrapped launchd service.",
|
||||
});
|
||||
expect(launchAgentPlistExists).toHaveBeenCalledWith(process.env);
|
||||
expect(repairLaunchAgentBootstrap).toHaveBeenCalledWith({ env: process.env });
|
||||
|
||||
@@ -53,6 +53,3 @@ export async function recoverInstalledLaunchAgent(params: {
|
||||
message: LAUNCH_AGENT_RECOVERY_MESSAGE,
|
||||
};
|
||||
}
|
||||
|
||||
/** User-facing recovery message for successful LaunchAgent bootstrap repair. */
|
||||
export { LAUNCH_AGENT_RECOVERY_MESSAGE };
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// Gateway QA parent watchdog tests cover parent-process watchdog shutdown behavior.
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
installQaParentWatchdog,
|
||||
QA_PARENT_PID_ENV,
|
||||
QA_STAGED_RUNTIME_ROOT_ENV,
|
||||
QA_TEMP_ROOT_ENV,
|
||||
} from "./qa-parent-watchdog.js";
|
||||
import { installQaParentWatchdog } from "./qa-parent-watchdog.js";
|
||||
|
||||
const QA_PARENT_PID_ENV = "OPENCLAW_QA_PARENT_PID";
|
||||
const QA_TEMP_ROOT_ENV = "OPENCLAW_QA_TEMP_ROOT";
|
||||
const QA_STAGED_RUNTIME_ROOT_ENV = "OPENCLAW_QA_STAGED_RUNTIME_ROOT";
|
||||
|
||||
describe("installQaParentWatchdog", () => {
|
||||
it("does not install without a QA parent pid", () => {
|
||||
|
||||
@@ -4,9 +4,9 @@ import path from "node:path";
|
||||
import { uniqueStrings } from "@openclaw/normalization-core/string-normalization";
|
||||
import { createSubsystemLogger } from "../../logging/subsystem.js";
|
||||
|
||||
export const QA_PARENT_PID_ENV = "OPENCLAW_QA_PARENT_PID";
|
||||
export const QA_TEMP_ROOT_ENV = "OPENCLAW_QA_TEMP_ROOT";
|
||||
export const QA_STAGED_RUNTIME_ROOT_ENV = "OPENCLAW_QA_STAGED_RUNTIME_ROOT";
|
||||
const QA_PARENT_PID_ENV = "OPENCLAW_QA_PARENT_PID";
|
||||
const QA_TEMP_ROOT_ENV = "OPENCLAW_QA_TEMP_ROOT";
|
||||
const QA_STAGED_RUNTIME_ROOT_ENV = "OPENCLAW_QA_STAGED_RUNTIME_ROOT";
|
||||
|
||||
const DEFAULT_QA_PARENT_WATCHDOG_INTERVAL_MS = 1000;
|
||||
const QA_TEMP_ROOT_PREFIX = "openclaw-qa-suite-";
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
||||
import { shortenHomePath } from "../utils.js";
|
||||
|
||||
export type PluginUninstallOptions = {
|
||||
type PluginUninstallOptions = {
|
||||
keepFiles?: boolean;
|
||||
/** @deprecated Use keepFiles. */
|
||||
keepConfig?: boolean;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { getWindowsSystem32ExePath } from "../infra/windows-install-roots.js";
|
||||
import { resolvePositiveTimerTimeoutMs, resolveTimerTimeoutMs } from "../shared/number-coercion.js";
|
||||
import { sleep } from "../utils.js";
|
||||
|
||||
export type PortProcess = { pid: number; command?: string };
|
||||
type PortProcess = { pid: number; command?: string };
|
||||
|
||||
type ForceFreePortResult = {
|
||||
killed: PortProcess[];
|
||||
|
||||
@@ -21,10 +21,11 @@ import {
|
||||
forceFreePort,
|
||||
forceFreePortAndWait,
|
||||
listPortListeners,
|
||||
type PortProcess,
|
||||
parseLsofOutput,
|
||||
} from "./ports.js";
|
||||
|
||||
type PortProcess = ReturnType<typeof forceFreePort>[number];
|
||||
|
||||
describe("gateway --force helpers", () => {
|
||||
let originalKill: typeof process.kill;
|
||||
let originalPlatform: NodeJS.Platform;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Tagline tests cover CLI tagline selection and display formatting.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { DEFAULT_TAGLINE, pickTagline } from "./tagline.js";
|
||||
import { pickTagline } from "./tagline.js";
|
||||
|
||||
const EXPECTED_DEFAULT_TAGLINE = "All your chats, one OpenClaw.";
|
||||
|
||||
describe("pickTagline", () => {
|
||||
it("returns empty string when mode is off", () => {
|
||||
@@ -8,7 +10,7 @@ describe("pickTagline", () => {
|
||||
});
|
||||
|
||||
it("returns default tagline when mode is default", () => {
|
||||
expect(pickTagline({ mode: "default" })).toBe(DEFAULT_TAGLINE);
|
||||
expect(pickTagline({ mode: "default" })).toBe(EXPECTED_DEFAULT_TAGLINE);
|
||||
});
|
||||
|
||||
it("keeps OPENCLAW_TAGLINE_INDEX behavior in random mode", () => {
|
||||
@@ -19,7 +21,7 @@ describe("pickTagline", () => {
|
||||
expect(value).toBe(
|
||||
"Your terminal just grew claws\u2014type something and let the bot pinch the busywork.",
|
||||
);
|
||||
expect(value).not.toBe(DEFAULT_TAGLINE);
|
||||
expect(value).not.toBe(EXPECTED_DEFAULT_TAGLINE);
|
||||
});
|
||||
|
||||
it("ignores partial OPENCLAW_TAGLINE_INDEX values", () => {
|
||||
|
||||
@@ -330,5 +330,3 @@ export function pickTagline(options: TaglineOptions = {}): string {
|
||||
const index = Math.floor(rand() * pool.length) % pool.length;
|
||||
return expectDefined(pool[index], "pool entry at index");
|
||||
}
|
||||
|
||||
export { DEFAULT_TAGLINE };
|
||||
|
||||
Reference in New Issue
Block a user