Skip to content

Commit 98e0b13

Browse files
authored
Merge pull request #6664 from Shopify/theme-profile-messaging-for-themekit
return an error when using Theme Access password with theme profile
2 parents 48a844b + f688a2b commit 98e0b13

File tree

3 files changed

+11
-31
lines changed

3 files changed

+11
-31
lines changed

.changeset/short-items-see.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/theme': patch
3+
---
4+
5+
Return error when running `theme profile` using a Theme Access password

packages/theme/src/cli/services/profile.test.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,6 @@ describe('profile', () => {
8282
expect(htmlContent).toContain('speedscope')
8383
})
8484

85-
test('uses provided passwords for authentication', async () => {
86-
// When
87-
await profile(mockAdminSession, themeId, urlPath, true, 'themeAccessPassword', 'storePassword')
88-
89-
// Then
90-
expect(ensureAuthenticatedStorefront).toHaveBeenCalledWith([], 'themeAccessPassword', {
91-
forceRefresh: false,
92-
noPrompt: true,
93-
})
94-
})
95-
9685
test('throws error when fetch fails', async () => {
9786
// Given
9887
vi.mocked(render).mockRejectedValue(new Error('Network error'))
@@ -120,22 +109,15 @@ describe('profile', () => {
120109
await expect(result).rejects.toThrow('Bad response: 404: {"error":"Some error message"}')
121110
})
122111

123-
test('throws error when an Admin API token is used', async () => {
112+
test('throws error when a password is used', async () => {
124113
// When
125114
const result = profile(mockAdminSession, themeId, urlPath, true, 'shpat_hello', undefined)
126115

127116
// Then
128117
await expect(result).rejects.toThrow(
129118
new AbortError(
130-
'Unable to use Admin API tokens with the profile command',
131-
`To use this command with the --password flag you must:
132-
133-
1. Install the Theme Access app on your shop
134-
2. Generate a new password
135-
136-
Alternatively, you can authenticate normally by not passing the --password flag.
137-
138-
Learn more: https://shopify.dev/docs/storefronts/themes/tools/theme-access`,
119+
'Unable to use Admin API or Theme Access tokens with the profile command',
120+
'You must authenticate manually by not passing the --password flag.',
139121
),
140122
)
141123
})

packages/theme/src/cli/services/profile.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,10 @@ export async function profile(
2222
? await ensureValidPassword(storefrontPassword, adminSession.storeFqdn)
2323
: undefined
2424

25-
if (themeAccessPassword?.startsWith('shpat_')) {
25+
if (themeAccessPassword) {
2626
throw new AbortError(
27-
'Unable to use Admin API tokens with the profile command',
28-
`To use this command with the --password flag you must:
29-
30-
1. Install the Theme Access app on your shop
31-
2. Generate a new password
32-
33-
Alternatively, you can authenticate normally by not passing the --password flag.
34-
35-
Learn more: https://shopify.dev/docs/storefronts/themes/tools/theme-access`,
27+
'Unable to use Admin API or Theme Access tokens with the profile command',
28+
'You must authenticate manually by not passing the --password flag.',
3629
)
3730
}
3831

0 commit comments

Comments
 (0)