perf: lazy-load status route startup helpers

This commit is contained in:
Ayaan Zaidi
2026-03-16 22:07:59 +05:30
parent 97a7dcf48e
commit 7e2658908d
2 changed files with 10 additions and 8 deletions

View File

@@ -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);