Skip to content

Commit edcd06f

Browse files
authored
Merge pull request #6430 from Shopify/09-25-fix_dev_stores_with_custom_domains
Fix dev stores with custom domains
2 parents 24e7bd0 + ccbd42a commit edcd06f

File tree

7 files changed

+27
-7
lines changed

7 files changed

+27
-7
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@shopify/theme",
1212
"@shopify/ui-extensions-dev-console-app",
1313
"@shopify/plugin-cloudflare",
14-
"@shopify/plugin-did-you-mean",
14+
"@shopify/plugin-did-you-mean"
1515
]],
1616
"access": "public",
1717
"baseBranch": "main",

.changeset/thick-walls-explode.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/app': patch
3+
---
4+
5+
Add support to `app dev` for dev stores with custom domains

packages/app/src/cli/api/graphql/business-platform-organizations/generated/list_app_dev_stores.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type ListAppDevStoresQuery = {
2020
storeType?: Types.Store | null
2121
primaryDomain?: string | null
2222
shortName?: string | null
23+
url?: string | null
2324
}
2425
}[]
2526
pageInfo: {hasNextPage: boolean}
@@ -108,6 +109,7 @@ export const ListAppDevStores = {
108109
{kind: 'Field', name: {kind: 'Name', value: 'storeType'}},
109110
{kind: 'Field', name: {kind: 'Name', value: 'primaryDomain'}},
110111
{kind: 'Field', name: {kind: 'Name', value: 'shortName'}},
112+
{kind: 'Field', name: {kind: 'Name', value: 'url'}},
111113
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
112114
],
113115
},

packages/app/src/cli/api/graphql/business-platform-organizations/queries/list_app_dev_stores.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ query ListAppDevStores($searchTerm: String) {
1111
storeType
1212
primaryDomain
1313
shortName
14+
url
1415
}
1516
}
1617
pageInfo {

packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ import {
160160
import {CLI_KIT_VERSION} from '@shopify/cli-kit/common/version'
161161
import {versionSatisfies} from '@shopify/cli-kit/node/node-package-manager'
162162
import {outputDebug} from '@shopify/cli-kit/node/output'
163-
import {developerDashboardFqdn} from '@shopify/cli-kit/node/context/fqdn'
163+
import {developerDashboardFqdn, normalizeStoreFqdn} from '@shopify/cli-kit/node/context/fqdn'
164164
import {TokenItem} from '@shopify/cli-kit/node/ui'
165165
import {functionsRequestDoc, FunctionsRequestOptions} from '@shopify/cli-kit/node/api/functions'
166166
import {fileExists, readFile} from '@shopify/cli-kit/node/fs'
@@ -1291,11 +1291,12 @@ function mapBusinessPlatformStoresToOrganizationStores(
12911291
provisionable: boolean,
12921292
): OrganizationStore[] {
12931293
return storesArray.map((store: ShopNode) => {
1294-
const {externalId, primaryDomain, name} = store
1294+
const {externalId, primaryDomain, name, url} = store
1295+
if (!url) throw new BugError('The selected store does not have a valid URL')
12951296
return {
12961297
shopId: externalId ? idFromEncodedGid(externalId) : undefined,
12971298
link: primaryDomain,
1298-
shopDomain: primaryDomain,
1299+
shopDomain: normalizeStoreFqdn(url),
12991300
shopName: name,
13001301
transferDisabled: true,
13011302
convertableToPartnerTest: true,

packages/cli-kit/src/public/node/context/fqdn.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,12 @@ describe('normalizeStore', () => {
209209
// Then
210210
expect(got).toEqual('example.myshopify.io')
211211
})
212+
213+
test('parses store name with admin', async () => {
214+
// When
215+
const got = await normalizeStoreFqdn('https://example.myshopify.com/admin/')
216+
217+
// Then
218+
expect(got).toEqual('example.myshopify.com')
219+
})
212220
})

packages/cli-kit/src/public/node/context/fqdn.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,12 @@ export async function identityFqdn(): Promise<string> {
128128
* @param store - Store name.
129129
* @returns Normalized store name.
130130
*/
131-
export async function normalizeStoreFqdn(store: string): Promise<string> {
132-
const storeFqdn = store.replace(/^https?:\/\//, '').replace(/\/$/, '')
133-
const addDomain = async (storeFqdn: string) => {
131+
export function normalizeStoreFqdn(store: string): string {
132+
const storeFqdn = store
133+
.replace(/^https?:\/\//, '')
134+
.replace(/\/$/, '')
135+
.replace(/\/admin$/, '')
136+
const addDomain = (storeFqdn: string) => {
134137
switch (serviceEnvironment()) {
135138
case 'local':
136139
return new DevServerCore().host(storeFqdn)

0 commit comments

Comments
 (0)