diff --git a/.changeset/ninety-doodles-scream.md b/.changeset/ninety-doodles-scream.md new file mode 100644 index 0000000000..ec3bd6005c --- /dev/null +++ b/.changeset/ninety-doodles-scream.md @@ -0,0 +1,6 @@ +--- +'@shopify/cli-kit': minor +'@shopify/app': minor +--- + +Update extension-only template to include app home by default diff --git a/packages/app/src/cli/prompts/init/init.test.ts b/packages/app/src/cli/prompts/init/init.test.ts index af3ee97d02..a4a0644475 100644 --- a/packages/app/src/cli/prompts/init/init.test.ts +++ b/packages/app/src/cli/prompts/init/init.test.ts @@ -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} @@ -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 = {} @@ -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', @@ -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', diff --git a/packages/app/src/cli/prompts/init/init.ts b/packages/app/src/cli/prompts/init/init.ts index 5b840ba005..dc9d1c51e3 100644 --- a/packages/app/src/cli/prompts/init/init.ts +++ b/packages/app/src/cli/prompts/init/init.ts @@ -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 { @@ -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 = { @@ -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, @@ -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 diff --git a/packages/cli-kit/src/private/node/constants.ts b/packages/cli-kit/src/private/node/constants.ts index 3b777bc319..a38e83f2d9 100644 --- a/packages/cli-kit/src/private/node/constants.ts +++ b/packages/cli-kit/src/private/node/constants.ts @@ -20,7 +20,6 @@ export const environmentVariables = { enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT', env: 'SHOPIFY_CLI_ENV', firstPartyDev: 'SHOPIFY_CLI_1P_DEV', - hostedApps: 'HOSTED_APPS', noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS', optOutInstrumentation: 'OPT_OUT_INSTRUMENTATION', appAutomationToken: 'SHOPIFY_APP_AUTOMATION_TOKEN', diff --git a/packages/cli-kit/src/public/node/context/local.test.ts b/packages/cli-kit/src/public/node/context/local.test.ts index db141564ce..abe71bb52b 100644 --- a/packages/cli-kit/src/public/node/context/local.test.ts +++ b/packages/cli-kit/src/public/node/context/local.test.ts @@ -2,7 +2,6 @@ import { ciPlatform, hasGit, isDevelopment, - isHostedAppsMode, isShopify, isTerminalInteractive, isUnitTest, @@ -84,30 +83,6 @@ describe('isUnitTest', () => { }) }) -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('isDevelopment', () => { test('returns true when SHOPIFY_CLI_ENV is debug', () => { // Given diff --git a/packages/cli-kit/src/public/node/context/local.ts b/packages/cli-kit/src/public/node/context/local.ts index c2ae8dce2e..ad816399db 100644 --- a/packages/cli-kit/src/public/node/context/local.ts +++ b/packages/cli-kit/src/public/node/context/local.ts @@ -101,16 +101,6 @@ export function isUnitTest(env = process.env): boolean { return isTruthy(env[environmentVariables.unitTest]) } -/** - * Returns true if the CLI is running in hosted apps mode. - * - * @param env - The environment variables from the environment of the current process. - * @returns True if the HOSTED_APPS environment variable is truthy. - */ -export function isHostedAppsMode(env = process.env): boolean { - return isTruthy(env[environmentVariables.hostedApps]) -} - /** * Returns true if reporting analytics is enabled. *