Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/cli/src/lib/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ describe('auth', () => {
expect(result).toStrictEqual(EXPECTED_LOGIN_RESULT);
});

it('throws an error when account has no active shops', async () => {
vi.mocked(getUserAccount).mockResolvedValue({
email: EMAIL,
activeShops: [],
});

await expect(login(ROOT)).rejects.toThrow(AbortError);
expect(renderSelectPrompt).not.toHaveBeenCalled();
});

it('prompts for shop is not found in arguments and local config', async () => {
const result = await login(ROOT);

Expand Down
7 changes: 7 additions & 0 deletions packages/cli/src/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export async function login(root?: string, shop?: string | true) {
shop &&
userAccount.activeShops.find(({fqdn}) => shop === fqdn);

if (!preselected && userAccount.activeShops.length === 0) {
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The !preselected && part of this condition is redundant because preselected can only be truthy when activeShops.length > 0. Simplifying to just if (userAccount.activeShops.length === 0) would make the intent clearer.

Suggested change
if (!preselected && userAccount.activeShops.length === 0) {
if (userAccount.activeShops.length === 0) {

Copilot uses AI. Check for mistakes.
throw new AbortError(
'No shops found for your Shopify account.',
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userAccount.activeShops is filtered to only status === 'ACTIVE' in getUserAccount, so the error headline could be misleading if the account has shops but none are active. Consider wording this as “No active shops found for your Shopify account.” (or similar) to match the actual condition being checked.

Suggested change
'No shops found for your Shopify account.',
'No active shops found for your Shopify account.',

Copilot uses AI. Check for mistakes.
"If you're just getting started, create a free dev store in your Shopify Dev Dashboard, then run the command again.",
);
}

const selected =
preselected ||
(await renderSelectPrompt({
Expand Down
Loading