@@ -13,6 +13,7 @@ import {
1313import { outputContent , outputDebug , outputInfo , outputToken , outputWarn } from './output.js'
1414import { cwd , moduleDirectory , sniffForPath } from './path.js'
1515import { exec , isCI } from './system.js'
16+ import { renderConfirmationPrompt } from './ui.js'
1617import { isPreReleaseVersion } from './version.js'
1718import { getAutoUpgradeEnabled , setAutoUpgradeEnabled , runAtMinimumInterval } from '../../private/node/conf-store.js'
1819import { CLI_KIT_VERSION } from '../common/version.js'
@@ -80,7 +81,7 @@ export async function runCLIUpgrade(): Promise<void> {
8081
8182/**
8283 * Returns the version to auto-upgrade to, or undefined if auto-upgrade should be skipped.
83- * Auto-upgrade is enabled by default and can be disabled via `setAutoUpgradeEnabled(false) `.
84+ * Auto-upgrade is disabled by default and must be enabled via `shopify upgrade `.
8485 * Also skips for CI, pre-release versions, or when no newer version is available.
8586 *
8687 * @returns The version string to upgrade to, or undefined if no upgrade should happen.
@@ -153,6 +154,24 @@ export function getOutputUpdateCLIReminder(version: string, isMajor = false): st
153154 return base
154155}
155156
157+ /**
158+ * Prompts the user to enable or disable automatic upgrades, then persists their choice.
159+ *
160+ * @returns Whether the user chose to enable auto-upgrade.
161+ */
162+ export async function promptAutoUpgrade ( ) : Promise < boolean > {
163+ const current = getAutoUpgradeEnabled ( )
164+ if ( current !== undefined ) return current
165+
166+ const enabled = await renderConfirmationPrompt ( {
167+ message : 'Enable automatic updates for Shopify CLI?' ,
168+ confirmationMessage : 'Yes, automatically update' ,
169+ cancellationMessage : "No, I'll update manually" ,
170+ } )
171+ setAutoUpgradeEnabled ( enabled )
172+ return enabled
173+ }
174+
156175async function upgradeLocalShopify ( projectDir : string , currentVersion : string ) {
157176 const packageJson = ( await findUpAndReadPackageJson ( projectDir ) ) . content
158177 const packageJsonDependencies = packageJson . dependencies ?? { }
0 commit comments