Skip to content
Draft
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.

30 changes: 1 addition & 29 deletions packages/app/src/cli/prompts/init/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import init, {buildNoneTemplate, InitOptions} from './init.js'
import init, {InitOptions} from './init.js'
import {describe, expect, vi, test, beforeEach} from 'vitest'
import {renderSelectPrompt} from '@shopify/cli-kit/node/ui'
import {installGlobalCLIPrompt} from '@shopify/cli-kit/node/is-global'
import {isHostedAppsMode} from '@shopify/cli-kit/node/context/local'

vi.mock('@shopify/cli-kit/node/ui')
vi.mock('@shopify/cli-kit/node/is-global')
vi.mock('@shopify/cli-kit/node/context/local')

const globalCLIResult = {install: true, alreadyInstalled: false}

Expand Down Expand Up @@ -39,32 +37,6 @@ describe('init', () => {
expect(got).toEqual({...options, ...answers, templateType: 'none', globalCLIResult})
})

describe('buildNoneTemplate', () => {
test('returns hosted app label and URL when HOSTED_APPS is enabled', () => {
// Given
vi.mocked(isHostedAppsMode).mockReturnValue(true)

// When
const got = buildNoneTemplate()

// Then
expect(got.label).toBe('Build an extension-only app (Shopify-hosted Preact app home and extensions, no back-end)')
expect(got.url).toBe('https://github.com/Shopify/shopify-app-template-extension-only')
})

test('returns default label and URL when HOSTED_APPS is not set', () => {
// Given
vi.mocked(isHostedAppsMode).mockReturnValue(false)

// When
const got = buildNoneTemplate()

// Then
expect(got.label).toBe('Build an extension-only app')
expect(got.url).toBe('https://github.com/Shopify/shopify-app-template-none')
})
})

test('it renders branches for templates that have them', async () => {
const answers = {
template: 'https://github.com/Shopify/shopify-app-template-react-router#javascript-cli',
Expand Down
20 changes: 5 additions & 15 deletions packages/app/src/cli/prompts/init/init.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {InstallGlobalCLIPromptResult, installGlobalCLIPrompt} from '@shopify/cli-kit/node/is-global'
import {isHostedAppsMode} from '@shopify/cli-kit/node/context/local'
import {renderSelectPrompt} from '@shopify/cli-kit/node/ui'

export interface InitOptions {
Expand Down Expand Up @@ -29,19 +28,6 @@ interface Template {
}
}

export function buildNoneTemplate(): Template {
const hostedAppsEnabled = isHostedAppsMode()
return {
url: hostedAppsEnabled
? 'https://github.com/Shopify/shopify-app-template-extension-only'
: 'https://github.com/Shopify/shopify-app-template-none',
label: hostedAppsEnabled
? 'Build an extension-only app (Shopify-hosted Preact app home and extensions, no back-end)'
: 'Build an extension-only app',
visible: true,
}
}

// Eventually this list should be taken from a remote location
// That way we don't have to update the CLI every time we add a template
export const templates = {
Expand Down Expand Up @@ -69,7 +55,11 @@ export const templates = {
},
},
} as Template,
none: buildNoneTemplate(),
none: {
url: 'https://github.com/Shopify/shopify-app-template-none',
label: 'Build an extension-only app',
visible: true,
} as Template,
node: {
url: 'https://github.com/Shopify/shopify-app-template-node',
visible: false,
Expand Down
Loading
Loading