Skip to content

Commit 16b9df4

Browse files
Fix auth status CI failures
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 7d464bd commit 16b9df4

5 files changed

Lines changed: 40 additions & 7 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This is an autogenerated file. Don't edit this file manually.
2+
/**
3+
* The following flags are available for the `auth status` command:
4+
* @publicDocs
5+
*/
6+
export interface authstatus {
7+
/**
8+
* Output the result as JSON. Automatically disables color output.
9+
* @environment SHOPIFY_FLAG_JSON
10+
*/
11+
'-j, --json'?: ''
12+
}

docs-shopify.dev/generated/generated_docs_data_v2.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,6 +2607,26 @@
26072607
"value": "export interface authlogout {\n\n}"
26082608
}
26092609
},
2610+
"authstatus": {
2611+
"docs-shopify.dev/commands/interfaces/auth-status.interface.ts": {
2612+
"filePath": "docs-shopify.dev/commands/interfaces/auth-status.interface.ts",
2613+
"name": "authstatus",
2614+
"description": "The following flags are available for the `auth status` command:",
2615+
"isPublicDocs": true,
2616+
"members": [
2617+
{
2618+
"filePath": "docs-shopify.dev/commands/interfaces/auth-status.interface.ts",
2619+
"syntaxKind": "PropertySignature",
2620+
"name": "-j, --json",
2621+
"value": "''",
2622+
"description": "Output the result as JSON. Automatically disables color output.",
2623+
"isOptional": true,
2624+
"environmentValue": "SHOPIFY_FLAG_JSON"
2625+
}
2626+
],
2627+
"value": "export interface authstatus {\n /**\n * Output the result as JSON. Automatically disables color output.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n}"
2628+
}
2629+
},
26102630
"commands": {
26112631
"docs-shopify.dev/commands/interfaces/commands.interface.ts": {
26122632
"filePath": "docs-shopify.dev/commands/interfaces/commands.interface.ts",

packages/cli-kit/src/public/node/session.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ function authStatusGuidance(status: AuthStatusName): AuthStatus['agentGuidance']
125125
}
126126
}
127127

128+
function validationResultToAuthStatus(validationResult: Awaited<ReturnType<typeof validateSession>>): AuthStatusName {
129+
if (validationResult === 'ok') return 'authenticated'
130+
if (validationResult === 'needs_refresh') return 'needs_refresh'
131+
return 'invalid'
132+
}
133+
128134
/**
129135
* Returns the current Shopify CLI authentication status without starting a login flow.
130136
*
@@ -157,7 +163,7 @@ export async function getAuthStatus(): Promise<AuthStatus> {
157163
}
158164

159165
const validationResult = await validateSession(allDefaultScopes(), {}, session)
160-
const status = validationResult === 'ok' ? 'authenticated' : validationResult === 'needs_refresh' ? 'needs_refresh' : 'invalid'
166+
const status = validationResultToAuthStatus(validationResult)
161167

162168
return {
163169
status,

packages/cli/src/cli/commands/auth/status.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import Status from './status.js'
22
import {authStatusService} from '../../services/commands/auth-status.js'
33

4-
import {beforeEach, describe, expect, test, vi} from 'vitest'
4+
import {describe, expect, test, vi} from 'vitest'
55

66
vi.mock('../../services/commands/auth-status.js')
77

88
describe('auth status command', () => {
9-
beforeEach(() => {
10-
vi.clearAllMocks()
11-
})
12-
139
test('checks auth status as text by default', async () => {
1410
// When
1511
await Status.run([])

packages/cli/src/cli/services/commands/auth-status.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ vi.mock('@shopify/cli-kit/node/session')
99
describe('authStatusService', () => {
1010
beforeEach(() => {
1111
mockAndCaptureOutput().clear()
12-
vi.clearAllMocks()
1312
process.exitCode = undefined
1413
})
1514

0 commit comments

Comments
 (0)