Skip to content

Commit 6ca29a9

Browse files
committed
report friendly error when cli fails to find shops to display
1 parent 43cdd3a commit 6ca29a9

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

packages/cli/src/lib/auth.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ describe('auth', () => {
128128
expect(result).toStrictEqual(EXPECTED_LOGIN_RESULT);
129129
});
130130

131+
it('throws an error when account has no active shops', async () => {
132+
vi.mocked(getUserAccount).mockResolvedValue({
133+
email: EMAIL,
134+
activeShops: [],
135+
});
136+
137+
await expect(login(ROOT)).rejects.toThrow(AbortError);
138+
expect(renderSelectPrompt).not.toHaveBeenCalled();
139+
});
140+
131141
it('prompts for shop is not found in arguments and local config', async () => {
132142
const result = await login(ROOT);
133143

packages/cli/src/lib/auth.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ export async function login(root?: string, shop?: string | true) {
6767
shop &&
6868
userAccount.activeShops.find(({fqdn}) => shop === fqdn);
6969

70+
if (!preselected && userAccount.activeShops.length === 0) {
71+
throw new AbortError(
72+
'No shops found for your Shopify account.',
73+
"If you're just getting started, create a free dev store in your Shopify Dev Dashboard, then run the command again.",
74+
);
75+
}
76+
7077
const selected =
7178
preselected ||
7279
(await renderSelectPrompt({

0 commit comments

Comments
 (0)