refactor: trim cli helper exports

This commit is contained in:
Peter Steinberger
2026-05-02 07:36:52 +01:00
parent d8326f2f70
commit 960fabdaef
7 changed files with 9 additions and 44 deletions

View File

@@ -6,39 +6,8 @@ import {
import { resolveGatewayService } from "../../daemon/service.js";
import { defaultRuntime } from "../../runtime.js";
import { formatCliCommand } from "../command-format.js";
import { parsePort } from "../shared/parse-port.js";
export { parsePort };
export const toOptionString = (value: unknown): string | undefined => {
if (typeof value === "string") {
return value;
}
if (typeof value === "number" || typeof value === "bigint") {
return value.toString();
}
return undefined;
};
export function extractGatewayMiskeys(parsed: unknown): {
hasGatewayToken: boolean;
hasRemoteToken: boolean;
} {
if (!parsed || typeof parsed !== "object") {
return { hasGatewayToken: false, hasRemoteToken: false };
}
const gateway = (parsed as Record<string, unknown>).gateway;
if (!gateway || typeof gateway !== "object") {
return { hasGatewayToken: false, hasRemoteToken: false };
}
const hasGatewayToken = "token" in (gateway as Record<string, unknown>);
const remote = (gateway as Record<string, unknown>).remote;
const hasRemoteToken =
remote && typeof remote === "object" ? "token" in (remote as Record<string, unknown>) : false;
return { hasGatewayToken, hasRemoteToken };
}
export function renderGatewayServiceStopHints(env: NodeJS.ProcessEnv = process.env): string[] {
function renderGatewayServiceStopHints(env: NodeJS.ProcessEnv = process.env): string[] {
const profile = env.OPENCLAW_PROFILE;
switch (process.platform) {
case "darwin":

View File

@@ -65,7 +65,7 @@ export function normalizeTag(value?: string | null): string | null {
return normalizePackageTagInput(value, ["openclaw", DEFAULT_PACKAGE_NAME]);
}
export function normalizeVersionTag(tag: string): string | null {
function normalizeVersionTag(tag: string): string | null {
const trimmed = tag.trim();
if (!trimmed) {
return null;
@@ -100,7 +100,7 @@ export async function isGitCheckout(root: string): Promise<boolean> {
}
}
export async function isCorePackage(root: string): Promise<boolean> {
async function isCorePackage(root: string): Promise<boolean> {
const name = await readPackageName(root);
return Boolean(name && CORE_PACKAGE_NAMES.has(name));
}

View File

@@ -26,11 +26,7 @@ export function inferSshTargetFromRemoteUrl(rawUrl?: string | null): string | nu
return user ? `${user}@${host}` : host;
}
export function buildSshTarget(input: {
user?: string;
host?: string;
port?: number;
}): string | null {
function buildSshTarget(input: { user?: string; host?: string; port?: number }): string | null {
const host = normalizeOptionalString(input.host) ?? "";
if (!host) {
return null;

View File

@@ -338,7 +338,7 @@ function colorForGatewayProbeCapability(capability: GatewayProbeCapability) {
}
}
export function renderProbeCapabilityLine(probe: GatewayProbeResult, rich: boolean) {
function renderProbeCapabilityLine(probe: GatewayProbeResult, rich: boolean) {
const capability = getGatewayProbeCapability(probe);
return colorize(
rich,

View File

@@ -5,7 +5,7 @@ import type { RuntimeEnv } from "../../runtime.js";
import { theme } from "../../terminal/theme.js";
import type { MigrateApplyOptions } from "./types.js";
export function formatCount(value: number, label: string): string {
function formatCount(value: number, label: string): string {
return `${value} ${label}${value === 1 ? "" : "s"}`;
}
@@ -52,7 +52,7 @@ export function formatMigrationPlan(plan: MigrationPlan): string[] {
return lines;
}
export function formatMigrationItem(item: MigrationItem): string {
function formatMigrationItem(item: MigrationItem): string {
const target = item.target ? ` -> ${item.target}` : "";
const message = item.message ? ` (${item.message})` : item.reason ? ` (${item.reason})` : "";
const sensitive = item.sensitive ? " [sensitive]" : "";

View File

@@ -1,7 +1,7 @@
import path from "node:path";
import { resolveStateDir } from "../config/paths.js";
export function resolveDebugProxyRootDir(env: NodeJS.ProcessEnv = process.env): string {
function resolveDebugProxyRootDir(env: NodeJS.ProcessEnv = process.env): string {
return path.join(resolveStateDir(env), "debug-proxy");
}

View File

@@ -1,4 +1,4 @@
export function formatChannelDefaultAccountPath(channelKey: string): string {
function formatChannelDefaultAccountPath(channelKey: string): string {
return `channels.${channelKey}.defaultAccount`;
}