From 14105547e84c3eddf6d4a379c8aabd4b0b31cd98 Mon Sep 17 00:00:00 2001 From: wb-liuxuehuan Date: Tue, 23 Jun 2026 18:27:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(tokenplan):=20=E4=BC=98=E5=8C=96=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新 `assign-seats` 和 `seats` 命令中的参数处理逻辑,简化对 AccountIds 和 StatusList 的检查,确保在缺少必要参数时抛出相应错误。同时,增强对 `--query-assigned` 参数的验证,确保其值为 'true' 或 'false'。此更改提高了代码的可读性和健壮性。 --- .../cli/src/commands/tokenplan/assign-seats.ts | 13 ++++--------- packages/cli/src/commands/tokenplan/seats.ts | 14 ++++++++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/commands/tokenplan/assign-seats.ts b/packages/cli/src/commands/tokenplan/assign-seats.ts index 5dd1e76..9d04759 100644 --- a/packages/cli/src/commands/tokenplan/assign-seats.ts +++ b/packages/cli/src/commands/tokenplan/assign-seats.ts @@ -86,11 +86,8 @@ export default defineCommand({ throw new BailianError("Missing required argument --seat-type.", ExitCode.USAGE); } - const accountIds = flags.accountId; - const hasAccountIds = - (Array.isArray(accountIds) && accountIds.length > 0) || - (typeof accountIds === "string" && accountIds.length > 0); - if (!hasAccountIds) { + const accountIds = flags.accountId as string[] | undefined; + if (!accountIds || accountIds.length === 0) { throw new BailianError("Missing required argument --account-id.", ExitCode.USAGE); } @@ -161,11 +158,9 @@ function buildQueryParams( if (flags.namespaceId) params.NamespaceId = flags.namespaceId as string; if (flags.locale) params.Locale = flags.locale as string; - const accountIds = flags.accountId as string | string[] | undefined; - if (Array.isArray(accountIds) && accountIds.length > 0) { + const accountIds = flags.accountId as string[] | undefined; + if (accountIds && accountIds.length > 0) { params.AccountIds = accountIds; - } else if (typeof accountIds === "string" && accountIds.length > 0) { - params.AccountIds = [accountIds]; } return params; diff --git a/packages/cli/src/commands/tokenplan/seats.ts b/packages/cli/src/commands/tokenplan/seats.ts index 16ff409..879ee01 100644 --- a/packages/cli/src/commands/tokenplan/seats.ts +++ b/packages/cli/src/commands/tokenplan/seats.ts @@ -143,18 +143,20 @@ function buildQueryParams(flags: GlobalFlags): Record 0) { - params.StatusList = status as string[]; - } else if (typeof status === "string" && status.length > 0) { - params.StatusList = [status]; + const status = flags.status as string[] | undefined; + if (status && status.length > 0) { + params.StatusList = status; } if (flags.seatId) params.SeatId = flags.seatId as string; if (flags.seatType) params.SeatType = flags.seatType as string; if (typeof flags.queryAssigned === "string" && flags.queryAssigned.length > 0) { - params.QueryAssigned = flags.queryAssigned; + const val = flags.queryAssigned.toLowerCase(); + if (val !== "true" && val !== "false") { + throw new BailianError("--query-assigned must be 'true' or 'false'.", ExitCode.USAGE); + } + params.QueryAssigned = val; } return params;