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
6 changes: 0 additions & 6 deletions packages/app/src/cli/models/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,18 +432,12 @@ export class App<
}

creationDefaultOptions(): CreateAppOptions {
const applicationUrl = this.configuration.application_url
const redirectUrls = this.configuration.auth?.redirect_urls
const staticRoot = this.configuration.admin?.static_root
return {
isLaunchable: this.appIsLaunchable(),
scopesArray: getAppScopesArray(this.configuration),
name: this.name,
isEmbedded: this.appIsEmbedded,
directory: this.directory,
applicationUrl,
redirectUrls,
staticRoot,
}
}

Expand Down
74 changes: 0 additions & 74 deletions packages/app/src/cli/models/app/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3504,80 +3504,6 @@ value = true
})
})
})

test('extracts application_url from template config', async () => {
await inTemporaryDirectory(async (tmpDir) => {
const config = `
client_id = ""
name = "my-app"
application_url = "https://extensions.shopifycdn.com"
embedded = true

[access_scopes]
scopes = "write_products"

[auth]
redirect_urls = ["https://shopify.dev/apps/default-app-home/api/auth"]
`
await writeFile(joinPath(tmpDir, 'shopify.app.toml'), config)
await writeFile(joinPath(tmpDir, 'package.json'), '{}')

const result = await loadConfigForAppCreation(tmpDir, 'my-app')

expect(result).toEqual({
isLaunchable: false,
scopesArray: ['write_products'],
name: 'my-app',
directory: normalizePath(tmpDir),
isEmbedded: false,
applicationUrl: 'https://extensions.shopifycdn.com',
redirectUrls: ['https://shopify.dev/apps/default-app-home/api/auth'],
staticRoot: undefined,
})
})
})

test('extracts admin.static_root from template config', async () => {
await inTemporaryDirectory(async (tmpDir) => {
const config = `
client_id = ""
name = "my-app"
application_url = "https://extensions.shopifycdn.com"
embedded = true

[admin]
static_root = "./dist"

[access_scopes]
scopes = "write_products"
`
await writeFile(joinPath(tmpDir, 'shopify.app.toml'), config)
await writeFile(joinPath(tmpDir, 'package.json'), '{}')

const result = await loadConfigForAppCreation(tmpDir, 'my-app')

expect(result.staticRoot).toBe('./dist')
})
})

test('defaults applicationUrl and redirectUrls to undefined when not in template config', async () => {
await inTemporaryDirectory(async (tmpDir) => {
const config = `
client_id = ""
name = "my-app"

[access_scopes]
scopes = "write_products"
`
await writeFile(joinPath(tmpDir, 'shopify.app.toml'), config)
await writeFile(joinPath(tmpDir, 'package.json'), '{}')

const result = await loadConfigForAppCreation(tmpDir, 'my-app')

expect(result.applicationUrl).toBeUndefined()
expect(result.redirectUrls).toBeUndefined()
})
})
})

describe('loadOpaqueApp', () => {
Expand Down
7 changes: 0 additions & 7 deletions packages/app/src/cli/models/app/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ export async function loadConfigForAppCreation(directory: string, name: string):
const isLaunchable = webs.some((web) => isWebType(web, WebType.Frontend) || isWebType(web, WebType.Backend))

const scopesArray = getAppScopesArray(rawConfig as CurrentAppConfiguration)
const appConfig = rawConfig as CurrentAppConfiguration
const applicationUrl = appConfig.application_url
const redirectUrls = appConfig.auth?.redirect_urls
const staticRoot = appConfig.admin?.static_root

return {
isLaunchable,
Expand All @@ -218,9 +214,6 @@ export async function loadConfigForAppCreation(directory: string, name: string):
directory: project.directory,
// By default, and ONLY for `app init`, we consider the app as embedded if it is launchable.
isEmbedded: isLaunchable,
applicationUrl,
redirectUrls,
staticRoot,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,6 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi
} else {
return nonRandomUUID(JSON.stringify(this.configuration))
}
default:
return this.specification.identifier
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import webPixelSpec from './specifications/web_pixel_extension.js'
import editorExtensionCollectionSpecification from './specifications/editor_extension_collection.js'
import channelSpecificationSpec from './specifications/channel.js'
import orderAttributionConfigSpec from './specifications/order_attribution_config.js'
import adminSpecificationSpec from './specifications/admin.js'
import adminLinkSpec from './specifications/admin_link.js'

const SORTED_CONFIGURATION_SPEC_IDENTIFIERS = [
Expand Down Expand Up @@ -64,7 +63,6 @@ function loadSpecifications() {
appWebhooksSpec,
appWebhookSubscriptionSpec,
appEventsSpec,
adminSpecificationSpec,
]
const moduleSpecs = [
checkoutPostPurchaseSpec,
Expand Down
68 changes: 0 additions & 68 deletions packages/app/src/cli/models/extensions/specifications/admin.ts

This file was deleted.

151 changes: 1 addition & 150 deletions packages/app/src/cli/services/deploy/bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ import {
testThemeExtensions,
testUIExtension,
} from '../../models/app/app.test-data.js'
import {AppInterface, AppManifest, WebType} from '../../models/app/app.js'
import {AppInterface, AppManifest} from '../../models/app/app.js'
import * as bundle from '../bundle.js'
import * as functionBuild from '../function/build.js'
import * as webService from '../web.js'
import {describe, expect, test, vi} from 'vitest'
import * as file from '@shopify/cli-kit/node/fs'
import {joinPath} from '@shopify/cli-kit/node/path'

vi.mock('../function/build.js')
vi.mock('../web.js')

describe('bundleAndBuildExtensions', () => {
let app: AppInterface
Expand Down Expand Up @@ -262,153 +260,6 @@ describe('bundleAndBuildExtensions', () => {
})
})

test('runs web build command concurrently with extensions when build command is defined', async () => {
await file.inTemporaryDirectory(async (tmpDir: string) => {
// Given
const bundlePath = joinPath(tmpDir, 'bundle.zip')
const mockBuildWeb = vi.mocked(webService.default)

const functionExtension = await testFunctionExtension()
const extensionBuildMock = vi.fn().mockImplementation(async (options, bundleDirectory) => {
file.writeFileSync(joinPath(bundleDirectory, 'index.wasm'), '')
})
functionExtension.buildForBundle = extensionBuildMock

const app = testApp({
allExtensions: [functionExtension],
directory: tmpDir,
webs: [
{
directory: '/tmp/web',
configuration: {
roles: [WebType.Backend],
commands: {dev: 'npm run dev', build: 'npm run build'},
},
},
],
})

const identifiers = {
app: 'app-id',
extensions: {[functionExtension.localIdentifier]: functionExtension.localIdentifier},
extensionIds: {},
extensionsNonUuidManaged: {},
}
appManifest = await app.manifest(identifiers)

// When
await bundleAndBuildExtensions({
app,
appManifest,
identifiers,
bundlePath,
skipBuild: false,
isDevDashboardApp: false,
})

// Then
expect(mockBuildWeb).toHaveBeenCalledWith('build', expect.objectContaining({web: app.webs[0]}))
})
})

test('skips web build for webs without a build command defined', async () => {
await file.inTemporaryDirectory(async (tmpDir: string) => {
// Given
const bundlePath = joinPath(tmpDir, 'bundle.zip')
const mockBuildWeb = vi.mocked(webService.default)

const functionExtension = await testFunctionExtension()
const extensionBuildMock = vi.fn().mockImplementation(async (options, bundleDirectory) => {
file.writeFileSync(joinPath(bundleDirectory, 'index.wasm'), '')
})
functionExtension.buildForBundle = extensionBuildMock

const app = testApp({
allExtensions: [functionExtension],
directory: tmpDir,
webs: [
{
directory: '/tmp/web',
configuration: {
roles: [WebType.Backend],
commands: {dev: 'npm run dev'},
},
},
],
})

const identifiers = {
app: 'app-id',
extensions: {[functionExtension.localIdentifier]: functionExtension.localIdentifier},
extensionIds: {},
extensionsNonUuidManaged: {},
}
appManifest = await app.manifest(identifiers)

// When
await bundleAndBuildExtensions({
app,
appManifest,
identifiers,
bundlePath,
skipBuild: false,
isDevDashboardApp: false,
})

// Then
expect(mockBuildWeb).not.toHaveBeenCalled()
})
})

test('skips web build command when skipBuild is true', async () => {
await file.inTemporaryDirectory(async (tmpDir: string) => {
// Given
const bundlePath = joinPath(tmpDir, 'bundle.zip')
const mockBuildWeb = vi.mocked(webService.default)

const functionExtension = await testFunctionExtension()
const extensionCopyMock = vi.fn().mockImplementation(async (options, bundleDirectory) => {
file.writeFileSync(joinPath(bundleDirectory, 'index.wasm'), '')
})
functionExtension.copyIntoBundle = extensionCopyMock

const app = testApp({
allExtensions: [functionExtension],
directory: tmpDir,
webs: [
{
directory: '/tmp/web',
configuration: {
roles: [WebType.Backend],
commands: {dev: 'npm run dev', build: 'npm run build'},
},
},
],
})

const identifiers = {
app: 'app-id',
extensions: {[functionExtension.localIdentifier]: functionExtension.localIdentifier},
extensionIds: {},
extensionsNonUuidManaged: {},
}
appManifest = await app.manifest(identifiers)

// When
await bundleAndBuildExtensions({
app,
appManifest,
identifiers,
bundlePath,
skipBuild: true,
isDevDashboardApp: false,
})

// Then
expect(mockBuildWeb).not.toHaveBeenCalled()
})
})

test('handles multiple extension types together', async () => {
await file.inTemporaryDirectory(async (tmpDir: string) => {
// Given
Expand Down
Loading
Loading