Skip to content

Commit a5c5b28

Browse files
authored
Merge pull request #7361 from Shopify/cx-revert-hosted-app
Revert hosted app project changes
2 parents bf56d92 + cb7982b commit a5c5b28

23 files changed

Lines changed: 30 additions & 833 deletions

File tree

packages/app/src/cli/models/app/app.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,18 +432,12 @@ export class App<
432432
}
433433

434434
creationDefaultOptions(): CreateAppOptions {
435-
const applicationUrl = this.configuration.application_url
436-
const redirectUrls = this.configuration.auth?.redirect_urls
437-
const staticRoot = this.configuration.admin?.static_root
438435
return {
439436
isLaunchable: this.appIsLaunchable(),
440437
scopesArray: getAppScopesArray(this.configuration),
441438
name: this.name,
442439
isEmbedded: this.appIsEmbedded,
443440
directory: this.directory,
444-
applicationUrl,
445-
redirectUrls,
446-
staticRoot,
447441
}
448442
}
449443

packages/app/src/cli/models/app/loader.test.ts

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3504,80 +3504,6 @@ value = true
35043504
})
35053505
})
35063506
})
3507-
3508-
test('extracts application_url from template config', async () => {
3509-
await inTemporaryDirectory(async (tmpDir) => {
3510-
const config = `
3511-
client_id = ""
3512-
name = "my-app"
3513-
application_url = "https://extensions.shopifycdn.com"
3514-
embedded = true
3515-
3516-
[access_scopes]
3517-
scopes = "write_products"
3518-
3519-
[auth]
3520-
redirect_urls = ["https://shopify.dev/apps/default-app-home/api/auth"]
3521-
`
3522-
await writeFile(joinPath(tmpDir, 'shopify.app.toml'), config)
3523-
await writeFile(joinPath(tmpDir, 'package.json'), '{}')
3524-
3525-
const result = await loadConfigForAppCreation(tmpDir, 'my-app')
3526-
3527-
expect(result).toEqual({
3528-
isLaunchable: false,
3529-
scopesArray: ['write_products'],
3530-
name: 'my-app',
3531-
directory: normalizePath(tmpDir),
3532-
isEmbedded: false,
3533-
applicationUrl: 'https://extensions.shopifycdn.com',
3534-
redirectUrls: ['https://shopify.dev/apps/default-app-home/api/auth'],
3535-
staticRoot: undefined,
3536-
})
3537-
})
3538-
})
3539-
3540-
test('extracts admin.static_root from template config', async () => {
3541-
await inTemporaryDirectory(async (tmpDir) => {
3542-
const config = `
3543-
client_id = ""
3544-
name = "my-app"
3545-
application_url = "https://extensions.shopifycdn.com"
3546-
embedded = true
3547-
3548-
[admin]
3549-
static_root = "./dist"
3550-
3551-
[access_scopes]
3552-
scopes = "write_products"
3553-
`
3554-
await writeFile(joinPath(tmpDir, 'shopify.app.toml'), config)
3555-
await writeFile(joinPath(tmpDir, 'package.json'), '{}')
3556-
3557-
const result = await loadConfigForAppCreation(tmpDir, 'my-app')
3558-
3559-
expect(result.staticRoot).toBe('./dist')
3560-
})
3561-
})
3562-
3563-
test('defaults applicationUrl and redirectUrls to undefined when not in template config', async () => {
3564-
await inTemporaryDirectory(async (tmpDir) => {
3565-
const config = `
3566-
client_id = ""
3567-
name = "my-app"
3568-
3569-
[access_scopes]
3570-
scopes = "write_products"
3571-
`
3572-
await writeFile(joinPath(tmpDir, 'shopify.app.toml'), config)
3573-
await writeFile(joinPath(tmpDir, 'package.json'), '{}')
3574-
3575-
const result = await loadConfigForAppCreation(tmpDir, 'my-app')
3576-
3577-
expect(result.applicationUrl).toBeUndefined()
3578-
expect(result.redirectUrls).toBeUndefined()
3579-
})
3580-
})
35813507
})
35823508

35833509
describe('loadOpaqueApp', () => {

packages/app/src/cli/models/app/loader.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,6 @@ export async function loadConfigForAppCreation(directory: string, name: string):
206206
const isLaunchable = webs.some((web) => isWebType(web, WebType.Frontend) || isWebType(web, WebType.Backend))
207207

208208
const scopesArray = getAppScopesArray(rawConfig as CurrentAppConfiguration)
209-
const appConfig = rawConfig as CurrentAppConfiguration
210-
const applicationUrl = appConfig.application_url
211-
const redirectUrls = appConfig.auth?.redirect_urls
212-
const staticRoot = appConfig.admin?.static_root
213209

214210
return {
215211
isLaunchable,
@@ -218,9 +214,6 @@ export async function loadConfigForAppCreation(directory: string, name: string):
218214
directory: project.directory,
219215
// By default, and ONLY for `app init`, we consider the app as embedded if it is launchable.
220216
isEmbedded: isLaunchable,
221-
applicationUrl,
222-
redirectUrls,
223-
staticRoot,
224217
}
225218
}
226219

packages/app/src/cli/models/extensions/extension-instance.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,6 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi
543543
} else {
544544
return nonRandomUUID(JSON.stringify(this.configuration))
545545
}
546-
default:
547-
return this.specification.identifier
548546
}
549547
}
550548

packages/app/src/cli/models/extensions/load-specifications.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import webPixelSpec from './specifications/web_pixel_extension.js'
2828
import editorExtensionCollectionSpecification from './specifications/editor_extension_collection.js'
2929
import channelSpecificationSpec from './specifications/channel.js'
3030
import orderAttributionConfigSpec from './specifications/order_attribution_config.js'
31-
import adminSpecificationSpec from './specifications/admin.js'
3231
import adminLinkSpec from './specifications/admin_link.js'
3332

3433
const SORTED_CONFIGURATION_SPEC_IDENTIFIERS = [
@@ -64,7 +63,6 @@ function loadSpecifications() {
6463
appWebhooksSpec,
6564
appWebhookSubscriptionSpec,
6665
appEventsSpec,
67-
adminSpecificationSpec,
6866
]
6967
const moduleSpecs = [
7068
checkoutPostPurchaseSpec,

packages/app/src/cli/models/extensions/specifications/admin.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.

packages/app/src/cli/services/deploy/bundle.test.ts

Lines changed: 1 addition & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ import {
66
testThemeExtensions,
77
testUIExtension,
88
} from '../../models/app/app.test-data.js'
9-
import {AppInterface, AppManifest, WebType} from '../../models/app/app.js'
9+
import {AppInterface, AppManifest} from '../../models/app/app.js'
1010
import * as bundle from '../bundle.js'
1111
import * as functionBuild from '../function/build.js'
12-
import * as webService from '../web.js'
1312
import {describe, expect, test, vi} from 'vitest'
1413
import * as file from '@shopify/cli-kit/node/fs'
1514
import {joinPath} from '@shopify/cli-kit/node/path'
1615

1716
vi.mock('../function/build.js')
18-
vi.mock('../web.js')
1917

2018
describe('bundleAndBuildExtensions', () => {
2119
let app: AppInterface
@@ -262,153 +260,6 @@ describe('bundleAndBuildExtensions', () => {
262260
})
263261
})
264262

265-
test('runs web build command concurrently with extensions when build command is defined', async () => {
266-
await file.inTemporaryDirectory(async (tmpDir: string) => {
267-
// Given
268-
const bundlePath = joinPath(tmpDir, 'bundle.zip')
269-
const mockBuildWeb = vi.mocked(webService.default)
270-
271-
const functionExtension = await testFunctionExtension()
272-
const extensionBuildMock = vi.fn().mockImplementation(async (options, bundleDirectory) => {
273-
file.writeFileSync(joinPath(bundleDirectory, 'index.wasm'), '')
274-
})
275-
functionExtension.buildForBundle = extensionBuildMock
276-
277-
const app = testApp({
278-
allExtensions: [functionExtension],
279-
directory: tmpDir,
280-
webs: [
281-
{
282-
directory: '/tmp/web',
283-
configuration: {
284-
roles: [WebType.Backend],
285-
commands: {dev: 'npm run dev', build: 'npm run build'},
286-
},
287-
},
288-
],
289-
})
290-
291-
const identifiers = {
292-
app: 'app-id',
293-
extensions: {[functionExtension.localIdentifier]: functionExtension.localIdentifier},
294-
extensionIds: {},
295-
extensionsNonUuidManaged: {},
296-
}
297-
appManifest = await app.manifest(identifiers)
298-
299-
// When
300-
await bundleAndBuildExtensions({
301-
app,
302-
appManifest,
303-
identifiers,
304-
bundlePath,
305-
skipBuild: false,
306-
isDevDashboardApp: false,
307-
})
308-
309-
// Then
310-
expect(mockBuildWeb).toHaveBeenCalledWith('build', expect.objectContaining({web: app.webs[0]}))
311-
})
312-
})
313-
314-
test('skips web build for webs without a build command defined', async () => {
315-
await file.inTemporaryDirectory(async (tmpDir: string) => {
316-
// Given
317-
const bundlePath = joinPath(tmpDir, 'bundle.zip')
318-
const mockBuildWeb = vi.mocked(webService.default)
319-
320-
const functionExtension = await testFunctionExtension()
321-
const extensionBuildMock = vi.fn().mockImplementation(async (options, bundleDirectory) => {
322-
file.writeFileSync(joinPath(bundleDirectory, 'index.wasm'), '')
323-
})
324-
functionExtension.buildForBundle = extensionBuildMock
325-
326-
const app = testApp({
327-
allExtensions: [functionExtension],
328-
directory: tmpDir,
329-
webs: [
330-
{
331-
directory: '/tmp/web',
332-
configuration: {
333-
roles: [WebType.Backend],
334-
commands: {dev: 'npm run dev'},
335-
},
336-
},
337-
],
338-
})
339-
340-
const identifiers = {
341-
app: 'app-id',
342-
extensions: {[functionExtension.localIdentifier]: functionExtension.localIdentifier},
343-
extensionIds: {},
344-
extensionsNonUuidManaged: {},
345-
}
346-
appManifest = await app.manifest(identifiers)
347-
348-
// When
349-
await bundleAndBuildExtensions({
350-
app,
351-
appManifest,
352-
identifiers,
353-
bundlePath,
354-
skipBuild: false,
355-
isDevDashboardApp: false,
356-
})
357-
358-
// Then
359-
expect(mockBuildWeb).not.toHaveBeenCalled()
360-
})
361-
})
362-
363-
test('skips web build command when skipBuild is true', async () => {
364-
await file.inTemporaryDirectory(async (tmpDir: string) => {
365-
// Given
366-
const bundlePath = joinPath(tmpDir, 'bundle.zip')
367-
const mockBuildWeb = vi.mocked(webService.default)
368-
369-
const functionExtension = await testFunctionExtension()
370-
const extensionCopyMock = vi.fn().mockImplementation(async (options, bundleDirectory) => {
371-
file.writeFileSync(joinPath(bundleDirectory, 'index.wasm'), '')
372-
})
373-
functionExtension.copyIntoBundle = extensionCopyMock
374-
375-
const app = testApp({
376-
allExtensions: [functionExtension],
377-
directory: tmpDir,
378-
webs: [
379-
{
380-
directory: '/tmp/web',
381-
configuration: {
382-
roles: [WebType.Backend],
383-
commands: {dev: 'npm run dev', build: 'npm run build'},
384-
},
385-
},
386-
],
387-
})
388-
389-
const identifiers = {
390-
app: 'app-id',
391-
extensions: {[functionExtension.localIdentifier]: functionExtension.localIdentifier},
392-
extensionIds: {},
393-
extensionsNonUuidManaged: {},
394-
}
395-
appManifest = await app.manifest(identifiers)
396-
397-
// When
398-
await bundleAndBuildExtensions({
399-
app,
400-
appManifest,
401-
identifiers,
402-
bundlePath,
403-
skipBuild: true,
404-
isDevDashboardApp: false,
405-
})
406-
407-
// Then
408-
expect(mockBuildWeb).not.toHaveBeenCalled()
409-
})
410-
})
411-
412263
test('handles multiple extension types together', async () => {
413264
await file.inTemporaryDirectory(async (tmpDir: string) => {
414265
// Given

0 commit comments

Comments
 (0)