mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-19 14:00:51 +00:00
perf: lazy-load status route startup helpers
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import { loadAndMaybeMigrateDoctorConfig } from "../../commands/doctor-config-flow.js";
|
||||
import { readConfigFileSnapshot } from "../../config/config.js";
|
||||
import { formatConfigIssueLines } from "../../config/issue-format.js";
|
||||
import type { RuntimeEnv } from "../../runtime.js";
|
||||
import { colorize, isRich, theme } from "../../terminal/theme.js";
|
||||
import { shortenHomePath } from "../../utils.js";
|
||||
import { shouldMigrateStateFromPath } from "../argv.js";
|
||||
import { formatCliCommand } from "../command-format.js";
|
||||
|
||||
const ALLOWED_INVALID_COMMANDS = new Set(["doctor", "logs", "health", "help", "status"]);
|
||||
const ALLOWED_INVALID_GATEWAY_SUBCOMMANDS = new Set([
|
||||
@@ -47,7 +42,7 @@ export async function ensureConfigReady(params: {
|
||||
if (!didRunDoctorConfigFlow && shouldMigrateStateFromPath(commandPath)) {
|
||||
didRunDoctorConfigFlow = true;
|
||||
const runDoctorConfigFlow = async () =>
|
||||
loadAndMaybeMigrateDoctorConfig({
|
||||
(await import("../../commands/doctor-config-flow.js")).loadAndMaybeMigrateDoctorConfig({
|
||||
options: { nonInteractive: true },
|
||||
confirm: async () => false,
|
||||
});
|
||||
@@ -80,6 +75,7 @@ export async function ensureConfigReady(params: {
|
||||
subcommandName &&
|
||||
ALLOWED_INVALID_GATEWAY_SUBCOMMANDS.has(subcommandName))
|
||||
: false;
|
||||
const { formatConfigIssueLines } = await import("../../config/issue-format.js");
|
||||
const issues =
|
||||
snapshot.exists && !snapshot.valid
|
||||
? formatConfigIssueLines(snapshot.issues, "-", { normalizeRoot: true })
|
||||
@@ -92,6 +88,12 @@ export async function ensureConfigReady(params: {
|
||||
return;
|
||||
}
|
||||
|
||||
const [{ colorize, isRich, theme }, { shortenHomePath }, { formatCliCommand }] =
|
||||
await Promise.all([
|
||||
import("../../terminal/theme.js"),
|
||||
import("../../utils.js"),
|
||||
import("../command-format.js"),
|
||||
]);
|
||||
const rich = isRich();
|
||||
const muted = (value: string) => colorize(rich, theme.muted, value);
|
||||
const error = (value: string) => colorize(rich, theme.error, value);
|
||||
|
||||
Reference in New Issue
Block a user