mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:30:43 +00:00
refactor: trim cli helper exports
This commit is contained in:
@@ -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":
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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]" : "";
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export function formatChannelDefaultAccountPath(channelKey: string): string {
|
||||
function formatChannelDefaultAccountPath(channelKey: string): string {
|
||||
return `channels.${channelKey}.defaultAccount`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user