From 8663a38fc435a27454fd4530339c85e634e89f3c Mon Sep 17 00:00:00 2001 From: Elana Kopelevich Date: Fri, 3 Apr 2026 17:19:08 -0600 Subject: [PATCH] Remove HOSTED_APPS env var and make extension-only template the default The new shopify-app-template-extension-only template was previously gated behind the HOSTED_APPS env var (PR #7096). This removes the env var entirely and makes the hosted app template the default for the "none" (extension-only) option in `shopify app init`. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../app/src/cli/prompts/init/init.test.ts | 36 +++---------------- packages/app/src/cli/prompts/init/init.ts | 22 ++++-------- .../cli-kit/src/private/node/constants.ts | 1 - .../src/public/node/context/local.test.ts | 25 ------------- .../cli-kit/src/public/node/context/local.ts | 10 ------ 5 files changed, 10 insertions(+), 84 deletions(-) diff --git a/packages/app/src/cli/prompts/init/init.test.ts b/packages/app/src/cli/prompts/init/init.test.ts index bba278daa75..e9c4fbd636a 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} 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} @@ -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 = {} @@ -31,7 +29,7 @@ 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 (Shopify-hosted Preact app home and extensions, no back-end)', value: 'none'}, ], message: 'Get started building your app:', defaultValue: 'reactRouter', @@ -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', @@ -82,7 +54,7 @@ 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 (Shopify-hosted Preact app home and extensions, no back-end)', 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 aa375b92447..2044dbc875b 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,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 = { @@ -69,7 +55,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 (Shopify-hosted Preact app home and extensions, no back-end)', + visible: true, + } as Template, node: { url: 'https://github.com/Shopify/shopify-app-template-node', visible: false, @@ -78,7 +68,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 40417176c61..50e3d05b547 100644 --- a/packages/cli-kit/src/private/node/constants.ts +++ b/packages/cli-kit/src/private/node/constants.ts @@ -48,7 +48,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' 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 abd5c523a6a..10c4a37f07c 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, isUnitTest, analyticsDisabled, @@ -46,30 +45,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 diff --git a/packages/cli-kit/src/public/node/context/local.ts b/packages/cli-kit/src/public/node/context/local.ts index 116ff50257a..c8910841442 100644 --- a/packages/cli-kit/src/public/node/context/local.ts +++ b/packages/cli-kit/src/public/node/context/local.ts @@ -47,16 +47,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).