fix(cli): reject partial numeric options

This commit is contained in:
Peter Steinberger
2026-05-27 14:31:25 -04:00
parent ac176d496b
commit 0f5ea87244
8 changed files with 146 additions and 36 deletions

View File

@@ -102,6 +102,12 @@ describe("registerOnboardCommand", () => {
await runCli(["onboard", "--gateway-port", "nope"]);
expect(setupWizardOptions(1).gatewayPort).toBeUndefined();
await runCli(["onboard", "--gateway-port", "18789x"]);
expect(setupWizardOptions(2).gatewayPort).toBeUndefined();
await runCli(["onboard", "--gateway-port", "99999"]);
expect(setupWizardOptions(3).gatewayPort).toBeUndefined();
});
it("forwards --reset-scope to setup wizard options", async () => {

View File

@@ -15,6 +15,7 @@ import { resolveManifestProviderOnboardAuthFlags } from "../../plugins/provider-
import { formatDocsLink } from "../../terminal/links.js";
import { theme } from "../../terminal/theme.js";
import { runCommandWithRuntime } from "../cli-utils.js";
import { parsePort } from "../shared/parse-port.js";
function resolveInstallDaemonFlag(
command: unknown,
@@ -191,8 +192,7 @@ export function registerOnboardCommand(program: Command): void {
const installDaemon = resolveInstallDaemonFlag(commandRuntime, {
installDaemon: Boolean(opts.installDaemon),
});
const gatewayPort =
typeof opts.gatewayPort === "string" ? Number.parseInt(opts.gatewayPort, 10) : undefined;
const gatewayPort = parsePort(opts.gatewayPort);
const providerAuthOptionValues = pickOnboardProviderAuthOptionValues(
opts as Record<string, unknown>,
);
@@ -224,10 +224,7 @@ export function registerOnboardCommand(program: Command): void {
: opts.customImageInput === true
? true
: undefined,
gatewayPort:
typeof gatewayPort === "number" && Number.isFinite(gatewayPort)
? gatewayPort
: undefined,
gatewayPort: gatewayPort ?? undefined,
gatewayBind: opts.gatewayBind as GatewayBind | undefined,
gatewayAuth: opts.gatewayAuth as GatewayAuthChoice | undefined,
gatewayToken: opts.gatewayToken as string | undefined,