Skip to content

Commit 0ec1eae

Browse files
Include release notes link in major version upgrade notification
When isMajorVersionChange() is true, extend the notification to include a link to the GitHub release notes so users can review breaking changes before upgrading. Closes shop/issues-develop#22372
1 parent fdfccd5 commit 0ec1eae

4 files changed

Lines changed: 51 additions & 6 deletions

File tree

packages/cli-kit/src/public/node/hooks/postrun.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ describe('autoUpgradeIfNeeded', () => {
9090

9191
// Then
9292
expect(runCLIUpgrade).not.toHaveBeenCalled()
93+
expect(getOutputUpdateCLIReminder).toHaveBeenCalledWith('4.0.0', true)
9394
expect(outputMock.warn()).toMatch(installReminder)
9495
})
9596
})

packages/cli-kit/src/public/node/hooks/postrun.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export async function autoUpgradeIfNeeded(): Promise<void> {
6969

7070
async function performAutoUpgrade(newerVersion: string): Promise<void> {
7171
if (isMajorVersionChange(CLI_KIT_VERSION, newerVersion)) {
72-
return outputWarn(getOutputUpdateCLIReminder(newerVersion))
72+
return outputWarn(getOutputUpdateCLIReminder(newerVersion, true))
7373
}
7474

7575
try {

packages/cli-kit/src/public/node/upgrade.test.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {isDevelopment} from './context/local.js'
22
import {currentProcessIsGlobal, inferPackageManagerForGlobalCLI} from './is-global.js'
33
import {checkForCachedNewVersion, packageManagerFromUserAgent, PackageManager} from './node-package-manager.js'
44
import {exec, isCI} from './system.js'
5-
import {cliInstallCommand, runCLIUpgrade, versionToAutoUpgrade} from './upgrade.js'
5+
import {cliInstallCommand, getOutputUpdateCLIReminder, runCLIUpgrade, versionToAutoUpgrade} from './upgrade.js'
66
import {isPreReleaseVersion} from './version.js'
77
import {getAutoUpgradeEnabled} from '../../private/node/conf-store.js'
88
import {vi, describe, test, expect, beforeEach} from 'vitest'
@@ -96,6 +96,38 @@ describe('cliInstallCommand', () => {
9696
expect(got).toBeUndefined()
9797
})
9898
})
99+
describe('getOutputUpdateCLIReminder', () => {
100+
test('returns a basic upgrade message for a minor version bump', () => {
101+
vi.mocked(inferPackageManagerForGlobalCLI).mockReturnValue('homebrew')
102+
103+
const message = getOutputUpdateCLIReminder('3.91.0')
104+
105+
expect(message).toContain('3.91.0')
106+
expect(message).toContain('brew upgrade shopify-cli')
107+
expect(message).not.toContain('major version')
108+
})
109+
110+
test('appends the GitHub release URL for a major version bump', () => {
111+
vi.mocked(inferPackageManagerForGlobalCLI).mockReturnValue('homebrew')
112+
113+
const message = getOutputUpdateCLIReminder('4.0.0', true)
114+
115+
expect(message).toContain('4.0.0')
116+
expect(message).toContain('brew upgrade shopify-cli')
117+
expect(message).toContain('major version')
118+
expect(message).toContain('https://github.com/Shopify/cli/releases/tag/v4.0.0')
119+
})
120+
121+
test('does not append the release URL for a minor version bump even when isMajor is false', () => {
122+
vi.mocked(inferPackageManagerForGlobalCLI).mockReturnValue('npm')
123+
124+
const message = getOutputUpdateCLIReminder('3.91.0', false)
125+
126+
expect(message).not.toContain('major version')
127+
expect(message).not.toContain('releases/tag')
128+
})
129+
})
130+
99131
describe('runCLIUpgrade', () => {
100132
beforeEach(() => {
101133
// Mock isDevelopment to return false by default (not in CLI development mode)

packages/cli-kit/src/public/node/upgrade.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,28 @@ export async function warnIfUpgradeAvailable(): Promise<void> {
128128

129129
/**
130130
* Generates a message to remind the user to update the CLI.
131+
* For major version bumps, appends a link to the GitHub release notes so users
132+
* can review breaking changes before deciding to upgrade.
131133
*
132134
* @param version - The version to update to.
135+
* @param isMajor - Whether the version bump is a major version change.
133136
* @returns The message to remind the user to update the CLI.
134137
*/
135-
export function getOutputUpdateCLIReminder(version: string): string {
138+
export function getOutputUpdateCLIReminder(version: string, isMajor = false): string {
136139
const installCommand = cliInstallCommand()
137-
if (installCommand) {
138-
return outputContent`💡 Version ${version} available! Run ${outputToken.genericShellCommand(installCommand)}`.value
140+
const base = installCommand
141+
? outputContent`💡 Version ${version} available! Run ${outputToken.genericShellCommand(installCommand)}`.value
142+
: outputContent`💡 Version ${version} available!`.value
143+
144+
if (isMajor) {
145+
const releaseUrl = `https://github.com/Shopify/cli/releases/tag/v${version}`
146+
const majorNotice =
147+
outputContent`⚠️ This is a major version — review breaking changes before upgrading:\n ${outputToken.link(releaseUrl, releaseUrl)}`
148+
.value
149+
return `${base}\n\n${majorNotice}`
139150
}
140-
return outputContent`💡 Version ${version} available!`.value
151+
152+
return base
141153
}
142154

143155
/**

0 commit comments

Comments
 (0)