From 6ebc6bf4c496ce8c229ae3f37e959a071c3bad95 Mon Sep 17 00:00:00 2001 From: Ben Sabic Date: Fri, 20 Feb 2026 13:38:31 +1100 Subject: [PATCH] fix: rename --json to --json-data on members update command The --json option on members update shadowed the global --json output flag, preventing users from getting JSON output on this command. Renamed to --json-data to resolve the conflict. --- src/commands/members.ts | 6 ++--- src/lib/types.ts | 2 +- tests/commands/members.test.ts | 45 ++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/commands/members.ts b/src/commands/members.ts index 83c5da5..22d0921 100644 --- a/src/commands/members.ts +++ b/src/commands/members.ts @@ -377,7 +377,7 @@ membersCommand [] ) .option("--meta-data ", "Metadata field (repeatable)", collect, []) - .option("--json ", "JSON data (as JSON string)") + .option("--json-data ", "JSON data (as JSON string)") .option("--login-redirect ", "Login redirect URL") .action(async (id: string, options: MembersUpdateOptions) => { const spinner = yoctoSpinner({ text: "Updating member..." }).start(); @@ -399,8 +399,8 @@ membersCommand if (options.metaData?.length) { input.metaData = parseKeyValuePairs(options.metaData); } - if (options.json) { - input.json = parseJsonString(options.json); + if (options.jsonData) { + input.json = parseJsonString(options.jsonData); } if (options.loginRedirect) { input.loginRedirect = options.loginRedirect; diff --git a/src/lib/types.ts b/src/lib/types.ts index d443a3b..622c379 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -152,7 +152,7 @@ export interface MembersCreateOptions { export interface MembersUpdateOptions { customFields?: string[]; email?: string; - json?: string; + jsonData?: string; loginRedirect?: string; metaData?: string[]; } diff --git a/tests/commands/members.test.ts b/tests/commands/members.test.ts index 610130e..07dba5b 100644 --- a/tests/commands/members.test.ts +++ b/tests/commands/members.test.ts @@ -160,6 +160,51 @@ describe("members", () => { ); }); + it("update sends custom fields and meta data", async () => { + graphqlRequest.mockResolvedValueOnce({ updateMember: mockMember }); + + await runCommand(membersCommand, [ + "update", + "mem_1", + "--meta-data", + "source=cli", + ]); + + const call = graphqlRequest.mock.calls[0][0]; + expect(call.variables.input.memberId).toBe("mem_1"); + expect(call.variables.input.metaData).toEqual({ source: "cli" }); + }); + + it("update sends --json-data as parsed JSON", async () => { + graphqlRequest.mockResolvedValueOnce({ updateMember: mockMember }); + + await runCommand(membersCommand, [ + "update", + "mem_1", + "--json-data", + '{"key":"value"}', + ]); + + const call = graphqlRequest.mock.calls[0][0]; + expect(call.variables.input.memberId).toBe("mem_1"); + expect(call.variables.input.json).toEqual({ key: "value" }); + }); + + it("update accepts --json-data alongside global --json without conflict", async () => { + graphqlRequest.mockResolvedValueOnce({ updateMember: mockMember }); + + await runCommand(membersCommand, [ + "update", + "mem_1", + "--json-data", + '{"key":"value"}', + "--json", + ]); + + const call = graphqlRequest.mock.calls[0][0]; + expect(call.variables.input.json).toEqual({ key: "value" }); + }); + it("handles errors gracefully", async () => { graphqlRequest.mockRejectedValueOnce(new Error("Unauthorized"));