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: 6 additions & 0 deletions .changeset/ninety-doodles-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/cli-kit': minor
'@shopify/app': minor
---

Update extension-only template to include app home by default
35 changes: 6 additions & 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, visibleTemplates} from './init.js'
import init, {InitOptions, visibleTemplates} 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 All @@ -17,7 +15,7 @@ describe('init', () => {

test('it renders the label for the template options', async () => {
const answers = {
template: 'https://github.com/Shopify/shopify-app-template-none',
template: 'https://github.com/Shopify/shopify-app-template-extension-only',
}
const options: InitOptions = {}

Expand Down Expand Up @@ -49,30 +47,6 @@ describe('init', () => {
})
})

describe('buildNoneTemplate', () => {
test('returns extension-only template URL when HOSTED_APPS is enabled', () => {
// Given
vi.mocked(isHostedAppsMode).mockReturnValue(true)

// When
const got = buildNoneTemplate()

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

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

// When
const got = buildNoneTemplate()

// Then
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 All @@ -90,7 +64,10 @@ describe('init', () => {
expect(renderSelectPrompt).toHaveBeenCalledWith({
choices: [
{label: 'Build a React Router app (recommended)', value: 'reactRouter'},
{label: 'Build an extension-only app', value: 'none'},
{
label: 'Build an extension-only app',
value: 'none',
},
],
message: 'Get started building your app:',
defaultValue: 'reactRouter',
Expand Down
19 changes: 6 additions & 13 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,16 +28,6 @@ interface Template {
}
}

export function buildNoneTemplate(): Template {
return {
url: isHostedAppsMode()
? 'https://github.com/Shopify/shopify-app-template-extension-only'
: 'https://github.com/Shopify/shopify-app-template-none',
label: '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 @@ -68,7 +57,11 @@ export const templates = {
},
},
} as Template,
none: buildNoneTemplate(),
none: {
url: 'https://github.com/Shopify/shopify-app-template-extension-only',
label: 'Build an extension-only app',
visible: true,
} as Template,
node: {
url: 'https://github.com/Shopify/shopify-app-template-node',
visible: false,
Expand All @@ -77,7 +70,7 @@ export const templates = {
url: 'https://github.com/Shopify/shopify-app-template-ruby',
visible: false,
} as Template,
}
} as const
type PredefinedTemplate = keyof typeof templates

const allTemplates = Object.keys(templates) as Readonly<PredefinedTemplate[]>
Expand Down
1 change: 0 additions & 1 deletion packages/cli-kit/src/private/node/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const environmentVariables = {
skipNetworkLevelRetry: 'SHOPIFY_CLI_SKIP_NETWORK_LEVEL_RETRY',
maxRequestTimeForNetworkCalls: 'SHOPIFY_CLI_MAX_REQUEST_TIME_FOR_NETWORK_CALLS',
disableImportScanning: 'SHOPIFY_CLI_DISABLE_IMPORT_SCANNING',
hostedApps: 'HOSTED_APPS',
}

export const defaultThemeKitAccessDomain = 'theme-kit-access.shopifyapps.com'
Expand Down
25 changes: 0 additions & 25 deletions packages/cli-kit/src/public/node/context/local.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
ciPlatform,
hasGit,
isDevelopment,
isHostedAppsMode,
isShopify,
isTerminalInteractive,
isUnitTest,
Expand Down Expand Up @@ -97,30 +96,6 @@ describe('isDevelopment', () => {
})
})

describe('isHostedAppsMode', () => {
test('returns true when HOSTED_APPS is truthy', () => {
// Given
const env = {HOSTED_APPS: '1'}

// When
const got = isHostedAppsMode(env)

// Then
expect(got).toBe(true)
})

test('returns false when HOSTED_APPS is not set', () => {
// Given
const env = {}

// When
const got = isHostedAppsMode(env)

// Then
expect(got).toBe(false)
})
})

describe('isShopify', () => {
test('returns false when the SHOPIFY_RUN_AS_USER env. variable is truthy', async () => {
// Given
Expand Down
10 changes: 0 additions & 10 deletions packages/cli-kit/src/public/node/context/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ export function isVerbose(env = process.env): boolean {
return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose')
}

/**
* Returns true if the hosted apps mode is enabled.
*
* @param env - The environment variables from the environment of the current process.
* @returns True if HOSTED_APPS is truthy.
*/
export function isHostedAppsMode(env = process.env): boolean {
return isTruthy(env[environmentVariables.hostedApps])
}

/**
* Returns true if the environment in which the CLI is running is either
* a local environment (where dev is present).
Expand Down
Loading