refactor(cli): rely on Commander contracts (#106366)

This commit is contained in:
Peter Steinberger
2026-07-13 05:05:31 -07:00
committed by GitHub
parent a03df5fd58
commit 801ec63f92
13 changed files with 42 additions and 155 deletions

View File

@@ -12,29 +12,11 @@ import type {
} from "../../commands/onboard-types.js";
import { runCommandWithRuntime } from "../cli-utils.js";
import { parsePort } from "../shared/parse-port.js";
import { pickOnboardAuthOptionValues, registerOnboardAuthOptions } from "./register.onboard.js";
function resolveInstallDaemonFlag(
command: unknown,
opts: { installDaemon?: boolean },
): boolean | undefined {
if (!command || typeof command !== "object") {
return undefined;
}
const getOptionValueSource =
"getOptionValueSource" in command ? command.getOptionValueSource : undefined;
if (typeof getOptionValueSource !== "function") {
return undefined;
}
if (getOptionValueSource.call(command, "skipDaemon") === "cli") {
return false;
}
if (getOptionValueSource.call(command, "installDaemon") === "cli") {
return Boolean(opts.installDaemon);
}
return undefined;
}
import {
pickOnboardAuthOptionValues,
registerOnboardAuthOptions,
resolveInstallDaemonFlag,
} from "./register.onboard.js";
/** Register the `setup` command as an onboarding alias. */
export function registerSetupCommand(program: Command): void {
@@ -107,7 +89,7 @@ export function registerSetupCommand(program: Command): void {
.option("--remote-url <url>", "Remote Gateway WebSocket URL")
.option("--remote-token <token>", "Remote Gateway token (optional)")
.option("--json", "Output JSON summary", false)
.action(async (opts, commandRuntime) => {
.action(async (opts, commandRuntime: Command) => {
const { defaultRuntime } = await import("../../runtime.js");
await runCommandWithRuntime(defaultRuntime, async () => {
if (opts.baseline) {
@@ -115,9 +97,7 @@ export function registerSetupCommand(program: Command): void {
await setupCommand({ workspace: opts.workspace as string | undefined }, defaultRuntime);
return;
}
const installDaemon = resolveInstallDaemonFlag(commandRuntime, {
installDaemon: Boolean(opts.installDaemon),
});
const installDaemon = resolveInstallDaemonFlag(commandRuntime);
const gatewayPort = parsePort(opts.gatewayPort);
const { setupWizardCommand } = await import("../../commands/onboard.js");
await setupWizardCommand(