Skip to content

Commit 1c8badc

Browse files
committed
Use a generic success status for auth logout
1 parent 49992ff commit 1c8badc

8 files changed

Lines changed: 22 additions & 22 deletions

File tree

‎packages/cli/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3759,13 +3759,13 @@ DESCRIPTION
37593759
{
37603760
"type": "object",
37613761
"properties": {
3762-
"loggedOut": {
3763-
"type": "boolean",
3764-
"const": true
3762+
"status": {
3763+
"type": "string",
3764+
"const": "success"
37653765
}
37663766
},
37673767
"required": [
3768-
"loggedOut"
3768+
"status"
37693769
],
37703770
"additionalProperties": false,
37713771
"title": "AuthLogoutResult",

‎packages/cli/oclif.manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5571,7 +5571,7 @@
55715571
],
55725572
"args": {
55735573
},
5574-
"description": "Logs you out of the Shopify account or Partner account and store.\n\nUse `--json-schema` to print the result, error, and event schemas.\n\nOutput from `--json` conforms to the `AuthLogoutResult` schema.\n\n```json\n{\n \"type\": \"object\",\n \"properties\": {\n \"loggedOut\": {\n \"type\": \"boolean\",\n \"const\": true\n }\n },\n \"required\": [\n \"loggedOut\"\n ],\n \"additionalProperties\": false,\n \"title\": \"AuthLogoutResult\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\"\n}\n```",
5574+
"description": "Logs you out of the Shopify account or Partner account and store.\n\nUse `--json-schema` to print the result, error, and event schemas.\n\nOutput from `--json` conforms to the `AuthLogoutResult` schema.\n\n```json\n{\n \"type\": \"object\",\n \"properties\": {\n \"status\": {\n \"type\": \"string\",\n \"const\": \"success\"\n }\n },\n \"required\": [\n \"status\"\n ],\n \"additionalProperties\": false,\n \"title\": \"AuthLogoutResult\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\"\n}\n```",
55755575
"descriptionWithMarkdown": "Logs you out of the Shopify account or Partner account and store.",
55765576
"enableJsonFlag": false,
55775577
"flags": {

‎packages/cli/src/cli/commands/auth/logout-json.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test.each(['--json', '-j'])('writes one completed result through the launcher wi
3030
})
3131

3232
expect(logout).toHaveBeenCalledExactlyOnceWith()
33-
expect(stdout()).toBe(`${JSON.stringify({loggedOut: true}, null, 2)}\n`)
33+
expect(stdout()).toBe(`${JSON.stringify({status: 'success'}, null, 2)}\n`)
3434
expect(stderr()).toBe('')
3535
})
3636
})
@@ -41,7 +41,7 @@ test('supports the JSON environment flag', async () => {
4141
await withCapturedStandardStreams(async ({stdout, stderr}) => {
4242
await Logout.run([], import.meta.url)
4343

44-
expect(JSON.parse(stdout())).toEqual({loggedOut: true})
44+
expect(JSON.parse(stdout())).toEqual({status: 'success'})
4545
expect(stderr()).toBe('')
4646
})
4747
})
@@ -51,7 +51,7 @@ test.each([false, true])('keeps no-input independent from JSON output: %s', asyn
5151
await Logout.run(['--no-input', ...(json ? ['--json'] : [])], import.meta.url)
5252

5353
if (json) {
54-
expect(JSON.parse(stdout())).toEqual({loggedOut: true})
54+
expect(JSON.parse(stdout())).toEqual({status: 'success'})
5555
expect(stderr()).toBe('')
5656
} else {
5757
expect(stdout()).toBe('')
@@ -75,8 +75,8 @@ test('discovers the schema without logging out', async () => {
7575

7676
expect(JSON.parse(stdout()).definitions.Result).toMatchObject({
7777
type: 'object',
78-
properties: {loggedOut: {type: 'boolean', const: true}},
79-
required: ['loggedOut'],
78+
properties: {status: {type: 'string', const: 'success'}},
79+
required: ['status'],
8080
additionalProperties: false,
8181
})
8282
expect(logout).not.toHaveBeenCalled()
@@ -92,7 +92,7 @@ test('writes diagnostics to stderr separately from the result', async () => {
9292
await withCapturedStandardStreams(async ({stdout, stderr}) => {
9393
await Logout.run(['--json'], import.meta.url)
9494

95-
expect(JSON.parse(stdout())).toEqual({loggedOut: true})
95+
expect(JSON.parse(stdout())).toEqual({status: 'success'})
9696
expect(JSON.parse(stderr())).toMatchObject({
9797
type: 'diagnostic',
9898
level: 'info',

‎packages/cli/src/cli/services/commands/auth/logout/index.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ afterEach(() => {
1212
test('returns a completed logout without presenting output', async () => {
1313
const output = mockAndCaptureOutput()
1414

15-
await expect(logoutService()).resolves.toEqual({loggedOut: true})
15+
await expect(logoutService()).resolves.toEqual({status: 'success'})
1616

1717
expect(logout).toHaveBeenCalledExactlyOnceWith()
1818
expect(output.output()).toBe('')
@@ -22,8 +22,8 @@ test('returns a completed logout without presenting output', async () => {
2222
test('returns the same result when logout has no remaining sessions', async () => {
2323
vi.mocked(logout).mockResolvedValue(undefined)
2424

25-
await expect(logoutService()).resolves.toEqual({loggedOut: true})
26-
await expect(logoutService()).resolves.toEqual({loggedOut: true})
25+
await expect(logoutService()).resolves.toEqual({status: 'success'})
26+
await expect(logoutService()).resolves.toEqual({status: 'success'})
2727

2828
expect(logout).toHaveBeenCalledTimes(2)
2929
})

‎packages/cli/src/cli/services/commands/auth/logout/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import type {AuthLogoutResult} from './types.js'
33

44
export async function logoutService(): Promise<AuthLogoutResult> {
55
await logout()
6-
return {loggedOut: true}
6+
return {status: 'success'}
77
}

‎packages/cli/src/cli/services/commands/auth/logout/result.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ afterEach(() => {
99
})
1010

1111
test('encodes a completed logout', () => {
12-
expect(authLogoutJsonOutputSchema.encode({loggedOut: true})).toBe(JSON.stringify({loggedOut: true}, null, 2))
12+
expect(authLogoutJsonOutputSchema.encode({status: 'success'})).toBe(JSON.stringify({status: 'success'}, null, 2))
1313
})
1414

15-
test.each([{}, {loggedOut: false}, {loggedOut: 'true'}, {loggedOut: null}, {loggedOut: true, accessToken: 'secret'}])(
15+
test.each([{}, {status: 'failed'}, {status: true}, {status: null}, {status: 'success', accessToken: 'secret'}])(
1616
'rejects an invalid result %j',
1717
(value) => {
1818
expect(() => authLogoutJsonOutputSchema.validate(value)).toThrow()
@@ -21,16 +21,16 @@ test.each([{}, {loggedOut: false}, {loggedOut: 'true'}, {loggedOut: null}, {logg
2121

2222
test('writes one JSON result without the success message', async () => {
2323
await withCapturedStandardStreams(({stdout, stderr}) => {
24-
presentLogoutResult({loggedOut: true}, 'json')
24+
presentLogoutResult({status: 'success'}, 'json')
2525

26-
expect(stdout()).toBe(`${JSON.stringify({loggedOut: true}, null, 2)}\n`)
26+
expect(stdout()).toBe(`${JSON.stringify({status: 'success'}, null, 2)}\n`)
2727
expect(stderr()).toBe('')
2828
})
2929
})
3030

3131
test('keeps the exact text and stderr channel', async () => {
3232
await withCapturedStandardStreams(({stdout, stderr}) => {
33-
presentLogoutResult({loggedOut: true}, 'text')
33+
presentLogoutResult({status: 'success'}, 'text')
3434

3535
expect(stdout()).toBe('')
3636
expect(unstyled(stderr())).toBe('✅ Success! Logged out from all the accounts.\n')

‎packages/cli/src/cli/services/commands/auth/logout/result.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {outputResult, outputSuccess} from '@shopify/cli-kit/node/output'
33

44
export function presentLogoutResult(result: AuthLogoutResult, format: 'json' | 'text'): void {
55
if (format === 'json') {
6-
outputResult(authLogoutJsonOutputSchema.encode({loggedOut: result.loggedOut}))
6+
outputResult(authLogoutJsonOutputSchema.encode({status: result.status}))
77
return
88
}
99

‎packages/cli/src/cli/services/commands/auth/logout/types.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {zod} from '@shopify/cli-kit/node/schema'
33

44
export const authLogoutJsonOutputSchema = defineJsonOutputSchema({
55
name: 'AuthLogoutResult',
6-
schema: zod.object({loggedOut: zod.literal(true)}).strict(),
6+
schema: zod.object({status: zod.literal('success')}).strict(),
77
})
88

99
export type AuthLogoutResult = InferJsonOutputSchema<typeof authLogoutJsonOutputSchema>

0 commit comments

Comments
 (0)