@shopify/cli-kit 3.94.3 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/private/node/api/headers.js +2 -2
- package/dist/private/node/api/headers.js.map +1 -1
- package/dist/private/node/conf-store.d.ts +3 -2
- package/dist/private/node/conf-store.js +3 -2
- package/dist/private/node/conf-store.js.map +1 -1
- package/dist/private/node/constants.d.ts +1 -1
- package/dist/private/node/constants.js +1 -1
- package/dist/private/node/constants.js.map +1 -1
- package/dist/private/node/ui/components/Alert.test.js +29 -0
- package/dist/private/node/ui/components/Alert.test.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.d.ts +8 -1
- package/dist/private/node/ui/components/AutocompletePrompt.js +3 -2
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +16 -0
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.js +6 -1
- package/dist/private/node/ui/components/FatalError.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.test.js +28 -0
- package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
- package/dist/private/node/ui/components/Link.js +8 -4
- package/dist/private/node/ui/components/Link.js.map +1 -1
- package/dist/private/node/ui/components/Link.test.js +45 -0
- package/dist/private/node/ui/components/Link.test.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.js +61 -2
- package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.test.js +109 -2
- package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
- package/dist/public/common/string.js +22 -25
- package/dist/public/common/string.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/base-command.js +23 -14
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/cli-launcher.d.ts +2 -0
- package/dist/public/node/cli-launcher.js +7 -3
- package/dist/public/node/cli-launcher.js.map +1 -1
- package/dist/public/node/cli.d.ts +5 -1
- package/dist/public/node/cli.js +3 -3
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/context/local.d.ts +1 -8
- package/dist/public/node/context/local.js +34 -15
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/custom-oclif-loader.d.ts +31 -0
- package/dist/public/node/custom-oclif-loader.js +45 -0
- package/dist/public/node/custom-oclif-loader.js.map +1 -0
- package/dist/public/node/error.d.ts +1 -1
- package/dist/public/node/error.js +1 -1
- package/dist/public/node/error.js.map +1 -1
- package/dist/public/node/fs.js +12 -16
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/git.js +9 -3
- package/dist/public/node/git.js.map +1 -1
- package/dist/public/node/hooks/postrun.d.ts +15 -0
- package/dist/public/node/hooks/postrun.js +75 -14
- package/dist/public/node/hooks/postrun.js.map +1 -1
- package/dist/public/node/hooks/prerun.d.ts +1 -1
- package/dist/public/node/hooks/prerun.js +17 -10
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/public/node/import-extractor.js +4 -3
- package/dist/public/node/import-extractor.js.map +1 -1
- package/dist/public/node/is-global.d.ts +1 -1
- package/dist/public/node/is-global.js +27 -11
- package/dist/public/node/is-global.js.map +1 -1
- package/dist/public/node/monorail.d.ts +2 -1
- package/dist/public/node/monorail.js +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/node-package-manager.d.ts +2 -2
- package/dist/public/node/node-package-manager.js +10 -10
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/notifications-system.d.ts +6 -6
- package/dist/public/node/output.js +2 -0
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/path.js +0 -2
- package/dist/public/node/path.js.map +1 -1
- package/dist/public/node/session.d.ts +6 -0
- package/dist/public/node/session.js +8 -0
- package/dist/public/node/session.js.map +1 -1
- package/dist/public/node/system.js +19 -42
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/tree-kill.js +17 -5
- package/dist/public/node/tree-kill.js.map +1 -1
- package/dist/public/node/ui.js +6 -0
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/upgrade.d.ts +27 -8
- package/dist/public/node/upgrade.js +50 -21
- package/dist/public/node/upgrade.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -7,21 +7,46 @@ export { getAutoUpgradeEnabled, setAutoUpgradeEnabled };
|
|
|
7
7
|
* @returns A string with the command to run, or undefined if the package manager cannot be determined.
|
|
8
8
|
*/
|
|
9
9
|
export declare function cliInstallCommand(): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Options for {@link runCLIUpgrade}.
|
|
12
|
+
*/
|
|
13
|
+
export interface RunCLIUpgradeOptions {
|
|
14
|
+
/**
|
|
15
|
+
* `true` when the upgrade is being triggered by the automatic postrun hook.
|
|
16
|
+
* In that case we skip project-local upgrades — those should only happen when the
|
|
17
|
+
* user explicitly runs `shopify upgrade` so we don't surprise them by mutating
|
|
18
|
+
* their `package.json` / lockfile in the background.
|
|
19
|
+
*/
|
|
20
|
+
autoupgrade?: boolean;
|
|
21
|
+
}
|
|
10
22
|
/**
|
|
11
23
|
* Runs the CLI upgrade using the appropriate package manager.
|
|
12
24
|
* Determines the install command and executes it.
|
|
13
25
|
*
|
|
26
|
+
* @param options - See {@link RunCLIUpgradeOptions}.
|
|
14
27
|
* @throws AbortError if the package manager or command cannot be determined.
|
|
15
28
|
*/
|
|
16
|
-
export declare function runCLIUpgrade(): Promise<void>;
|
|
29
|
+
export declare function runCLIUpgrade(options?: RunCLIUpgradeOptions): Promise<void>;
|
|
17
30
|
/**
|
|
18
31
|
* Returns the version to auto-upgrade to, or undefined if auto-upgrade should be skipped.
|
|
19
|
-
* Auto-upgrade is
|
|
32
|
+
* Auto-upgrade is enabled by default and can be disabled via `setAutoUpgradeEnabled(false)`.
|
|
20
33
|
* Also skips for CI, pre-release versions, or when no newer version is available.
|
|
21
34
|
*
|
|
22
35
|
* @returns The version string to upgrade to, or undefined if no upgrade should happen.
|
|
23
36
|
*/
|
|
24
37
|
export declare function versionToAutoUpgrade(): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Checks the freshly fetched notifications feed for a kill-switch notification that
|
|
40
|
+
* disables auto-upgrade. A blocking notification is one with `surface: "autoupgrade"`,
|
|
41
|
+
* `type: "error"`, and matching version/date ranges for the current CLI.
|
|
42
|
+
*
|
|
43
|
+
* Fails open: any error fetching or parsing the feed results in `false`, so a broken
|
|
44
|
+
* notifications endpoint never prevents users from auto-upgrading. Intentionally silent
|
|
45
|
+
* (no logs) — this is invoked on the auto-upgrade hot path.
|
|
46
|
+
*
|
|
47
|
+
* @returns `true` when an active blocking notification is found, `false` otherwise.
|
|
48
|
+
*/
|
|
49
|
+
export declare function hasBlockingAutoUpgradeNotification(): Promise<boolean>;
|
|
25
50
|
/**
|
|
26
51
|
* Shows a daily upgrade-available warning for users who have not enabled auto-upgrade.
|
|
27
52
|
* Skipped in CI and for pre-release versions. When auto-upgrade is enabled this is a no-op
|
|
@@ -38,9 +63,3 @@ export declare function warnIfUpgradeAvailable(): Promise<void>;
|
|
|
38
63
|
* @returns The message to remind the user to update the CLI.
|
|
39
64
|
*/
|
|
40
65
|
export declare function getOutputUpdateCLIReminder(version: string, isMajor?: boolean): string;
|
|
41
|
-
/**
|
|
42
|
-
* Prompts the user to enable or disable automatic upgrades, then persists their choice.
|
|
43
|
-
*
|
|
44
|
-
* @returns Whether the user chose to enable auto-upgrade.
|
|
45
|
-
*/
|
|
46
|
-
export declare function promptAutoUpgrade(): Promise<boolean>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { fetchNotifications, filterNotifications } from './notifications-system.js';
|
|
1
2
|
import { isDevelopment } from './context/local.js';
|
|
2
3
|
import { currentProcessIsGlobal, inferPackageManagerForGlobalCLI, getProjectDir } from './is-global.js';
|
|
3
4
|
import { checkForCachedNewVersion, findUpAndReadPackageJson, checkForNewVersion, usesWorkspaces, addNPMDependencies, getPackageManager, } from './node-package-manager.js';
|
|
4
5
|
import { outputContent, outputDebug, outputInfo, outputToken, outputWarn } from './output.js';
|
|
6
|
+
import { renderSuccess } from './ui.js';
|
|
5
7
|
import { cwd, moduleDirectory, sniffForPath } from './path.js';
|
|
6
8
|
import { exec, isCI } from './system.js';
|
|
7
|
-
import { renderConfirmationPrompt } from './ui.js';
|
|
8
9
|
import { isPreReleaseVersion } from './version.js';
|
|
9
10
|
import { getAutoUpgradeEnabled, setAutoUpgradeEnabled, runAtMinimumInterval } from '../../private/node/conf-store.js';
|
|
10
11
|
import { CLI_KIT_VERSION } from '../common/version.js';
|
|
@@ -34,9 +35,10 @@ export function cliInstallCommand() {
|
|
|
34
35
|
* Runs the CLI upgrade using the appropriate package manager.
|
|
35
36
|
* Determines the install command and executes it.
|
|
36
37
|
*
|
|
38
|
+
* @param options - See {@link RunCLIUpgradeOptions}.
|
|
37
39
|
* @throws AbortError if the package manager or command cannot be determined.
|
|
38
40
|
*/
|
|
39
|
-
export async function runCLIUpgrade() {
|
|
41
|
+
export async function runCLIUpgrade(options = {}) {
|
|
40
42
|
// Path where the current project is (app/hydrogen)
|
|
41
43
|
const path = sniffForPath() ?? cwd();
|
|
42
44
|
const projectDir = getProjectDir(path);
|
|
@@ -47,6 +49,13 @@ export async function runCLIUpgrade() {
|
|
|
47
49
|
outputInfo('Skipping upgrade in development mode.');
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
52
|
+
// When triggered by the automatic postrun hook, skip project-local upgrades.
|
|
53
|
+
// Bumping `package.json` / lockfile silently in the background would surprise users
|
|
54
|
+
// and produce noisy diffs; explicit `shopify upgrade` invocations still upgrade the
|
|
55
|
+
// local project.
|
|
56
|
+
if (options.autoupgrade && !isGlobal) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
50
59
|
// Generate the install command for the global CLI and execute it
|
|
51
60
|
if (isGlobal) {
|
|
52
61
|
const installCommand = cliInstallCommand();
|
|
@@ -57,8 +66,19 @@ export async function runCLIUpgrade() {
|
|
|
57
66
|
if (!command) {
|
|
58
67
|
throw new Error('Could not determine the command to run');
|
|
59
68
|
}
|
|
60
|
-
|
|
69
|
+
// Cache lookup — already populated by versionToAutoUpgrade() upstream, so this
|
|
70
|
+
// is just a synchronous cache read, no extra network call.
|
|
71
|
+
const newerVersion = checkForCachedNewVersion('@shopify/cli', CLI_KIT_VERSION);
|
|
72
|
+
const headline = newerVersion
|
|
73
|
+
? `✨ New version of Shopify CLI available! (${CLI_KIT_VERSION} → ${newerVersion})`
|
|
74
|
+
: '✨ New version of Shopify CLI available!';
|
|
75
|
+
outputInfo(outputContent `${headline}
|
|
76
|
+
Now upgrading by running: ${outputToken.genericShellCommand(installCommand)}...`);
|
|
61
77
|
await exec(command, args, { stdio: 'inherit' });
|
|
78
|
+
renderSuccess({
|
|
79
|
+
headline: 'Shopify CLI upgraded.',
|
|
80
|
+
body: newerVersion ? `You're now on version ${newerVersion}.` : "You're now on the latest version.",
|
|
81
|
+
});
|
|
62
82
|
}
|
|
63
83
|
else if (projectDir) {
|
|
64
84
|
await upgradeLocalShopify(projectDir, CLI_KIT_VERSION);
|
|
@@ -69,7 +89,7 @@ export async function runCLIUpgrade() {
|
|
|
69
89
|
}
|
|
70
90
|
/**
|
|
71
91
|
* Returns the version to auto-upgrade to, or undefined if auto-upgrade should be skipped.
|
|
72
|
-
* Auto-upgrade is
|
|
92
|
+
* Auto-upgrade is enabled by default and can be disabled via `setAutoUpgradeEnabled(false)`.
|
|
73
93
|
* Also skips for CI, pre-release versions, or when no newer version is available.
|
|
74
94
|
*
|
|
75
95
|
* @returns The version string to upgrade to, or undefined if no upgrade should happen.
|
|
@@ -99,6 +119,32 @@ export function versionToAutoUpgrade() {
|
|
|
99
119
|
}
|
|
100
120
|
return newerVersion;
|
|
101
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Checks the freshly fetched notifications feed for a kill-switch notification that
|
|
124
|
+
* disables auto-upgrade. A blocking notification is one with `surface: "autoupgrade"`,
|
|
125
|
+
* `type: "error"`, and matching version/date ranges for the current CLI.
|
|
126
|
+
*
|
|
127
|
+
* Fails open: any error fetching or parsing the feed results in `false`, so a broken
|
|
128
|
+
* notifications endpoint never prevents users from auto-upgrading. Intentionally silent
|
|
129
|
+
* (no logs) — this is invoked on the auto-upgrade hot path.
|
|
130
|
+
*
|
|
131
|
+
* @returns `true` when an active blocking notification is found, `false` otherwise.
|
|
132
|
+
*/
|
|
133
|
+
export async function hasBlockingAutoUpgradeNotification() {
|
|
134
|
+
try {
|
|
135
|
+
const { notifications } = await fetchNotifications();
|
|
136
|
+
// Reuse the standard notifications filtering for version/date/surface. The empty
|
|
137
|
+
// commandId disables the command filter; ['autoupgrade'] scopes to our surface.
|
|
138
|
+
// The frequency filter is a no-op here because we never render, so nothing gets
|
|
139
|
+
// written to the lastShown cache for these notifications.
|
|
140
|
+
const matching = filterNotifications(notifications, '', ['autoupgrade']);
|
|
141
|
+
return matching.some((notification) => notification.type === 'error');
|
|
142
|
+
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
102
148
|
/**
|
|
103
149
|
* Shows a daily upgrade-available warning for users who have not enabled auto-upgrade.
|
|
104
150
|
* Skipped in CI and for pre-release versions. When auto-upgrade is enabled this is a no-op
|
|
@@ -136,23 +182,6 @@ export function getOutputUpdateCLIReminder(version, isMajor = false) {
|
|
|
136
182
|
}
|
|
137
183
|
return base;
|
|
138
184
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Prompts the user to enable or disable automatic upgrades, then persists their choice.
|
|
141
|
-
*
|
|
142
|
-
* @returns Whether the user chose to enable auto-upgrade.
|
|
143
|
-
*/
|
|
144
|
-
export async function promptAutoUpgrade() {
|
|
145
|
-
const current = getAutoUpgradeEnabled();
|
|
146
|
-
if (current !== undefined)
|
|
147
|
-
return current;
|
|
148
|
-
const enabled = await renderConfirmationPrompt({
|
|
149
|
-
message: 'Enable automatic updates for Shopify CLI?',
|
|
150
|
-
confirmationMessage: 'Yes, automatically update',
|
|
151
|
-
cancellationMessage: "No, I'll update manually",
|
|
152
|
-
});
|
|
153
|
-
setAutoUpgradeEnabled(enabled);
|
|
154
|
-
return enabled;
|
|
155
|
-
}
|
|
156
185
|
async function upgradeLocalShopify(projectDir, currentVersion) {
|
|
157
186
|
const packageJson = (await findUpAndReadPackageJson(projectDir)).content;
|
|
158
187
|
const packageJsonDependencies = packageJson.dependencies ?? {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../../src/public/node/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,sBAAsB,EAAE,+BAA+B,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAA;AACrG,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EAExB,kBAAkB,EAElB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAC,MAAM,aAAa,CAAA;AAC3F,OAAO,EAAC,GAAG,EAAE,eAAe,EAAE,YAAY,EAAC,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAChD,OAAO,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAA;AAChD,OAAO,EAAC,qBAAqB,EAAE,qBAAqB,EAAE,oBAAoB,EAAC,MAAM,kCAAkC,CAAA;AACnH,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AAEpD,OAAO,EAAC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eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QACpF,oBAAoB,GAAG,oBAAoB,IAAK,WAAW,CAAC,OAA+B,CAAA;IAC7F,CAAC;IACD,OAAO,oBAAoB,CAAA;AAC7B,CAAC;AAED,SAAS,wBAAwB,CAAC,cAAsB;IACtD,UAAU,CAAC,aAAa,CAAA,iCAAiC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAA;AACrH,CAAC;AAED,SAAS,oBAAoB,CAAC,cAAsB,EAAE,aAAqB;IACzE,UAAU,CACR,aAAa,CAAA,sBAAsB,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CACnH,CAAA;AACH,CAAC","sourcesContent":["import {isDevelopment} from './context/local.js'\nimport {currentProcessIsGlobal, inferPackageManagerForGlobalCLI, getProjectDir} from './is-global.js'\nimport {\n checkForCachedNewVersion,\n findUpAndReadPackageJson,\n PackageJson,\n checkForNewVersion,\n DependencyType,\n usesWorkspaces,\n addNPMDependencies,\n getPackageManager,\n} from './node-package-manager.js'\nimport {outputContent, outputDebug, outputInfo, outputToken, outputWarn} from './output.js'\nimport {cwd, moduleDirectory, sniffForPath} from './path.js'\nimport {exec, isCI} from './system.js'\nimport {renderConfirmationPrompt} from './ui.js'\nimport {isPreReleaseVersion} from './version.js'\nimport {getAutoUpgradeEnabled, setAutoUpgradeEnabled, runAtMinimumInterval} from '../../private/node/conf-store.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\n\nexport {getAutoUpgradeEnabled, setAutoUpgradeEnabled}\n\n/**\n * Utility function for generating an install command for the user to run\n * to install an updated version of Shopify CLI.\n *\n * @returns A string with the command to run, or undefined if the package manager cannot be determined.\n */\nexport function cliInstallCommand(): string | undefined {\n const packageManager = inferPackageManagerForGlobalCLI()\n if (!packageManager || packageManager === 'unknown') return undefined\n\n if (packageManager === 'homebrew') {\n return 'brew upgrade shopify-cli'\n } else if (packageManager === 'yarn') {\n return `${packageManager} global add @shopify/cli@latest`\n } else {\n const verb = packageManager === 'pnpm' ? 'add' : 'install'\n return `${packageManager} ${verb} -g @shopify/cli@latest`\n }\n}\n\n/**\n * Runs the CLI upgrade using the appropriate package manager.\n * Determines the install command and executes it.\n *\n * @throws AbortError if the package manager or command cannot be determined.\n */\nexport async function runCLIUpgrade(): Promise<void> {\n // Path where the current project is (app/hydrogen)\n const path = sniffForPath() ?? cwd()\n const projectDir = getProjectDir(path)\n\n // Check if we are running in a global context if not, return\n const isGlobal = currentProcessIsGlobal()\n\n // Don't auto-upgrade for development mode\n if (isDevelopment()) {\n outputInfo('Skipping upgrade in development mode.')\n return\n }\n\n // Generate the install command for the global CLI and execute it\n if (isGlobal) {\n const installCommand = cliInstallCommand()\n if (!installCommand) {\n throw new Error('Could not determine the package manager')\n }\n const [command, ...args] = installCommand.split(' ')\n if (!command) {\n throw new Error('Could not determine the command to run')\n }\n outputInfo(outputContent`Upgrading Shopify CLI by running: ${outputToken.genericShellCommand(installCommand)}...`)\n await exec(command, args, {stdio: 'inherit'})\n } else if (projectDir) {\n await upgradeLocalShopify(projectDir, CLI_KIT_VERSION)\n } else {\n throw new Error('Could not determine the local project directory')\n }\n}\n\n/**\n * Returns the version to auto-upgrade to, or undefined if auto-upgrade should be skipped.\n * Auto-upgrade is disabled by default and must be enabled via `shopify upgrade`.\n * Also skips for CI, pre-release versions, or when no newer version is available.\n *\n * @returns The version string to upgrade to, or undefined if no upgrade should happen.\n */\nexport function versionToAutoUpgrade(): string | undefined {\n const currentVersion = CLI_KIT_VERSION\n const newerVersion = checkForCachedNewVersion('@shopify/cli', currentVersion)\n if (!newerVersion) {\n outputDebug('Auto-upgrade: No newer version available.')\n return undefined\n }\n if (process.env.SHOPIFY_CLI_FORCE_AUTO_UPGRADE === '1') {\n outputDebug('Auto-upgrade: Forcing auto-upgrade because of SHOPIFY_CLI_FORCE_AUTO_UPGRADE.')\n return newerVersion\n }\n if (!getAutoUpgradeEnabled()) {\n outputDebug('Auto-upgrade: Skipping because auto-upgrade is not enabled.')\n return undefined\n }\n if (isCI()) {\n outputDebug('Auto-upgrade: Skipping auto-upgrade in CI.')\n return undefined\n }\n if (isPreReleaseVersion(currentVersion)) {\n outputDebug('Auto-upgrade: Skipping auto-upgrade for pre-release version.')\n return undefined\n }\n return newerVersion\n}\n\n/**\n * Shows a daily upgrade-available warning for users who have not enabled auto-upgrade.\n * Skipped in CI and for pre-release versions. When auto-upgrade is enabled this is a no-op\n * because the postrun hook will handle the upgrade directly.\n */\nexport async function warnIfUpgradeAvailable(): Promise<void> {\n if (isCI() || isPreReleaseVersion(CLI_KIT_VERSION) || getAutoUpgradeEnabled()) return\n\n const newerVersion = checkForCachedNewVersion('@shopify/cli', CLI_KIT_VERSION)\n if (!newerVersion) return\n\n await runAtMinimumInterval('warn-on-available-upgrade', {days: 1}, async () => {\n outputWarn(getOutputUpdateCLIReminder(newerVersion))\n })\n}\n\n/**\n * Generates a message to remind the user to update the CLI.\n * For major version bumps, appends a link to the GitHub release notes so users\n * can review breaking changes before deciding to upgrade.\n *\n * @param version - The version to update to.\n * @param isMajor - Whether the version bump is a major version change.\n * @returns The message to remind the user to update the CLI.\n */\nexport function getOutputUpdateCLIReminder(version: string, isMajor = false): string {\n const installCommand = cliInstallCommand()\n const base = installCommand\n ? outputContent`💡 Version ${version} available! Run ${outputToken.genericShellCommand(installCommand)}`.value\n : outputContent`💡 Version ${version} available!`.value\n\n if (isMajor) {\n const releaseUrl = `https://github.com/Shopify/cli/releases/tag/${version}`\n const majorNotice =\n outputContent`⚠️ This is a major version — review breaking changes before upgrading:\\n ${outputToken.link(releaseUrl, releaseUrl)}`\n .value\n return `${base}\\n\\n${majorNotice}`\n }\n\n return base\n}\n\n/**\n * Prompts the user to enable or disable automatic upgrades, then persists their choice.\n *\n * @returns Whether the user chose to enable auto-upgrade.\n */\nexport async function promptAutoUpgrade(): Promise<boolean> {\n const current = getAutoUpgradeEnabled()\n if (current !== undefined) return current\n\n const enabled = await renderConfirmationPrompt({\n message: 'Enable automatic updates for Shopify CLI?',\n confirmationMessage: 'Yes, automatically update',\n cancellationMessage: \"No, I'll update manually\",\n })\n setAutoUpgradeEnabled(enabled)\n return enabled\n}\n\nasync function upgradeLocalShopify(projectDir: string, currentVersion: string) {\n const packageJson = (await findUpAndReadPackageJson(projectDir)).content\n const packageJsonDependencies = packageJson.dependencies ?? {}\n const packageJsonDevDependencies = packageJson.devDependencies ?? {}\n const allDependencies = {...packageJsonDependencies, ...packageJsonDevDependencies}\n\n let resolvedCLIVersion = allDependencies[await cliDependency()]\n if (!resolvedCLIVersion) {\n outputDebug('Auto-upgrade: CLI dependency not found in project dependencies, skipping local upgrade.')\n return\n }\n\n if (resolvedCLIVersion.slice(0, 1).match(/[\\^~]/)) resolvedCLIVersion = currentVersion\n const newestCLIVersion = await checkForNewVersion(await cliDependency(), resolvedCLIVersion)\n\n if (newestCLIVersion) {\n outputUpgradeMessage(resolvedCLIVersion, newestCLIVersion)\n } else {\n outputWontInstallMessage(resolvedCLIVersion)\n }\n\n await installJsonDependencies('prod', packageJsonDependencies, projectDir)\n await installJsonDependencies('dev', packageJsonDevDependencies, projectDir)\n}\n\nasync function installJsonDependencies(\n depsEnv: DependencyType,\n deps: {[key: string]: string},\n directory: string,\n): Promise<void> {\n const packagesToUpdate = [await cliDependency(), ...(await oclifPlugins())]\n .filter((pkg: string): boolean => {\n const pkgRequirement: string | undefined = deps[pkg]\n return Boolean(pkgRequirement)\n })\n .map((pkg) => {\n return {name: pkg, version: 'latest'}\n })\n\n const appUsesWorkspaces = await usesWorkspaces(directory)\n\n if (packagesToUpdate.length > 0) {\n await addNPMDependencies(packagesToUpdate, {\n packageManager: await getPackageManager(directory),\n type: depsEnv,\n directory,\n stdout: process.stdout,\n stderr: process.stderr,\n addToRootDirectory: appUsesWorkspaces,\n })\n }\n}\n\nasync function cliDependency(): Promise<string> {\n return (await packageJsonContents()).name\n}\n\nasync function oclifPlugins(): Promise<string[]> {\n return (await packageJsonContents())?.oclif?.plugins ?? []\n}\n\ntype PackageJsonWithName = Omit<PackageJson, 'name'> & {name: string}\nlet _packageJsonContents: PackageJsonWithName | undefined\n\nasync function packageJsonContents(): Promise<PackageJsonWithName> {\n if (!_packageJsonContents) {\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(import.meta.url))\n _packageJsonContents = _packageJsonContents ?? (packageJson.content as PackageJsonWithName)\n }\n return _packageJsonContents\n}\n\nfunction outputWontInstallMessage(currentVersion: string): void {\n outputInfo(outputContent`You're on the latest version, ${outputToken.yellow(currentVersion)}, no need to upgrade!`)\n}\n\nfunction outputUpgradeMessage(currentVersion: string, newestVersion: string): void {\n outputInfo(\n outputContent`Upgrading CLI from ${outputToken.yellow(currentVersion)} to ${outputToken.yellow(newestVersion)}...`,\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../../src/public/node/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAE,mBAAmB,EAAC,MAAM,2BAA2B,CAAA;AACjF,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,sBAAsB,EAAE,+BAA+B,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAA;AACrG,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EAExB,kBAAkB,EAElB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAC,MAAM,aAAa,CAAA;AAC3F,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAA;AACrC,OAAO,EAAC,GAAG,EAAE,eAAe,EAAE,YAAY,EAAC,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO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AA,sBAAsB,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CACnH,CAAA;AACH,CAAC","sourcesContent":["import {fetchNotifications, filterNotifications} from './notifications-system.js'\nimport {isDevelopment} from './context/local.js'\nimport {currentProcessIsGlobal, inferPackageManagerForGlobalCLI, getProjectDir} from './is-global.js'\nimport {\n checkForCachedNewVersion,\n findUpAndReadPackageJson,\n PackageJson,\n checkForNewVersion,\n DependencyType,\n usesWorkspaces,\n addNPMDependencies,\n getPackageManager,\n} from './node-package-manager.js'\nimport {outputContent, outputDebug, outputInfo, outputToken, outputWarn} from './output.js'\nimport {renderSuccess} from './ui.js'\nimport {cwd, moduleDirectory, sniffForPath} from './path.js'\nimport {exec, isCI} from './system.js'\nimport {isPreReleaseVersion} from './version.js'\nimport {getAutoUpgradeEnabled, setAutoUpgradeEnabled, runAtMinimumInterval} from '../../private/node/conf-store.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\n\nexport {getAutoUpgradeEnabled, setAutoUpgradeEnabled}\n\n/**\n * Utility function for generating an install command for the user to run\n * to install an updated version of Shopify CLI.\n *\n * @returns A string with the command to run, or undefined if the package manager cannot be determined.\n */\nexport function cliInstallCommand(): string | undefined {\n const packageManager = inferPackageManagerForGlobalCLI()\n if (!packageManager || packageManager === 'unknown') return undefined\n\n if (packageManager === 'homebrew') {\n return 'brew upgrade shopify-cli'\n } else if (packageManager === 'yarn') {\n return `${packageManager} global add @shopify/cli@latest`\n } else {\n const verb = packageManager === 'pnpm' ? 'add' : 'install'\n return `${packageManager} ${verb} -g @shopify/cli@latest`\n }\n}\n\n/**\n * Options for {@link runCLIUpgrade}.\n */\nexport interface RunCLIUpgradeOptions {\n /**\n * `true` when the upgrade is being triggered by the automatic postrun hook.\n * In that case we skip project-local upgrades — those should only happen when the\n * user explicitly runs `shopify upgrade` so we don't surprise them by mutating\n * their `package.json` / lockfile in the background.\n */\n autoupgrade?: boolean\n}\n\n/**\n * Runs the CLI upgrade using the appropriate package manager.\n * Determines the install command and executes it.\n *\n * @param options - See {@link RunCLIUpgradeOptions}.\n * @throws AbortError if the package manager or command cannot be determined.\n */\nexport async function runCLIUpgrade(options: RunCLIUpgradeOptions = {}): Promise<void> {\n // Path where the current project is (app/hydrogen)\n const path = sniffForPath() ?? cwd()\n const projectDir = getProjectDir(path)\n\n // Check if we are running in a global context if not, return\n const isGlobal = currentProcessIsGlobal()\n\n // Don't auto-upgrade for development mode\n if (isDevelopment()) {\n outputInfo('Skipping upgrade in development mode.')\n return\n }\n\n // When triggered by the automatic postrun hook, skip project-local upgrades.\n // Bumping `package.json` / lockfile silently in the background would surprise users\n // and produce noisy diffs; explicit `shopify upgrade` invocations still upgrade the\n // local project.\n if (options.autoupgrade && !isGlobal) {\n return\n }\n\n // Generate the install command for the global CLI and execute it\n if (isGlobal) {\n const installCommand = cliInstallCommand()\n if (!installCommand) {\n throw new Error('Could not determine the package manager')\n }\n const [command, ...args] = installCommand.split(' ')\n if (!command) {\n throw new Error('Could not determine the command to run')\n }\n // Cache lookup — already populated by versionToAutoUpgrade() upstream, so this\n // is just a synchronous cache read, no extra network call.\n const newerVersion = checkForCachedNewVersion('@shopify/cli', CLI_KIT_VERSION)\n const headline = newerVersion\n ? `✨ New version of Shopify CLI available! (${CLI_KIT_VERSION} → ${newerVersion})`\n : '✨ New version of Shopify CLI available!'\n outputInfo(\n outputContent`${headline}\n Now upgrading by running: ${outputToken.genericShellCommand(installCommand)}...`,\n )\n await exec(command, args, {stdio: 'inherit'})\n renderSuccess({\n headline: 'Shopify CLI upgraded.',\n body: newerVersion ? `You're now on version ${newerVersion}.` : \"You're now on the latest version.\",\n })\n } else if (projectDir) {\n await upgradeLocalShopify(projectDir, CLI_KIT_VERSION)\n } else {\n throw new Error('Could not determine the local project directory')\n }\n}\n\n/**\n * Returns the version to auto-upgrade to, or undefined if auto-upgrade should be skipped.\n * Auto-upgrade is enabled by default and can be disabled via `setAutoUpgradeEnabled(false)`.\n * Also skips for CI, pre-release versions, or when no newer version is available.\n *\n * @returns The version string to upgrade to, or undefined if no upgrade should happen.\n */\nexport function versionToAutoUpgrade(): string | undefined {\n const currentVersion = CLI_KIT_VERSION\n const newerVersion = checkForCachedNewVersion('@shopify/cli', currentVersion)\n if (!newerVersion) {\n outputDebug('Auto-upgrade: No newer version available.')\n return undefined\n }\n if (process.env.SHOPIFY_CLI_FORCE_AUTO_UPGRADE === '1') {\n outputDebug('Auto-upgrade: Forcing auto-upgrade because of SHOPIFY_CLI_FORCE_AUTO_UPGRADE.')\n return newerVersion\n }\n if (!getAutoUpgradeEnabled()) {\n outputDebug('Auto-upgrade: Skipping because auto-upgrade is not enabled.')\n return undefined\n }\n if (isCI()) {\n outputDebug('Auto-upgrade: Skipping auto-upgrade in CI.')\n return undefined\n }\n if (isPreReleaseVersion(currentVersion)) {\n outputDebug('Auto-upgrade: Skipping auto-upgrade for pre-release version.')\n return undefined\n }\n return newerVersion\n}\n\n/**\n * Checks the freshly fetched notifications feed for a kill-switch notification that\n * disables auto-upgrade. A blocking notification is one with `surface: \"autoupgrade\"`,\n * `type: \"error\"`, and matching version/date ranges for the current CLI.\n *\n * Fails open: any error fetching or parsing the feed results in `false`, so a broken\n * notifications endpoint never prevents users from auto-upgrading. Intentionally silent\n * (no logs) — this is invoked on the auto-upgrade hot path.\n *\n * @returns `true` when an active blocking notification is found, `false` otherwise.\n */\nexport async function hasBlockingAutoUpgradeNotification(): Promise<boolean> {\n try {\n const {notifications} = await fetchNotifications()\n // Reuse the standard notifications filtering for version/date/surface. The empty\n // commandId disables the command filter; ['autoupgrade'] scopes to our surface.\n // The frequency filter is a no-op here because we never render, so nothing gets\n // written to the lastShown cache for these notifications.\n const matching = filterNotifications(notifications, '', ['autoupgrade'])\n return matching.some((notification) => notification.type === 'error')\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Shows a daily upgrade-available warning for users who have not enabled auto-upgrade.\n * Skipped in CI and for pre-release versions. When auto-upgrade is enabled this is a no-op\n * because the postrun hook will handle the upgrade directly.\n */\nexport async function warnIfUpgradeAvailable(): Promise<void> {\n if (isCI() || isPreReleaseVersion(CLI_KIT_VERSION) || getAutoUpgradeEnabled()) return\n\n const newerVersion = checkForCachedNewVersion('@shopify/cli', CLI_KIT_VERSION)\n if (!newerVersion) return\n\n await runAtMinimumInterval('warn-on-available-upgrade', {days: 1}, async () => {\n outputWarn(getOutputUpdateCLIReminder(newerVersion))\n })\n}\n\n/**\n * Generates a message to remind the user to update the CLI.\n * For major version bumps, appends a link to the GitHub release notes so users\n * can review breaking changes before deciding to upgrade.\n *\n * @param version - The version to update to.\n * @param isMajor - Whether the version bump is a major version change.\n * @returns The message to remind the user to update the CLI.\n */\nexport function getOutputUpdateCLIReminder(version: string, isMajor = false): string {\n const installCommand = cliInstallCommand()\n const base = installCommand\n ? outputContent`💡 Version ${version} available! Run ${outputToken.genericShellCommand(installCommand)}`.value\n : outputContent`💡 Version ${version} available!`.value\n\n if (isMajor) {\n const releaseUrl = `https://github.com/Shopify/cli/releases/tag/${version}`\n const majorNotice =\n outputContent`⚠️ This is a major version — review breaking changes before upgrading:\\n ${outputToken.link(releaseUrl, releaseUrl)}`\n .value\n return `${base}\\n\\n${majorNotice}`\n }\n\n return base\n}\n\nasync function upgradeLocalShopify(projectDir: string, currentVersion: string) {\n const packageJson = (await findUpAndReadPackageJson(projectDir)).content\n const packageJsonDependencies = packageJson.dependencies ?? {}\n const packageJsonDevDependencies = packageJson.devDependencies ?? {}\n const allDependencies = {...packageJsonDependencies, ...packageJsonDevDependencies}\n\n let resolvedCLIVersion = allDependencies[await cliDependency()]\n if (!resolvedCLIVersion) {\n outputDebug('Auto-upgrade: CLI dependency not found in project dependencies, skipping local upgrade.')\n return\n }\n\n if (resolvedCLIVersion.slice(0, 1).match(/[\\^~]/)) resolvedCLIVersion = currentVersion\n const newestCLIVersion = await checkForNewVersion(await cliDependency(), resolvedCLIVersion)\n\n if (newestCLIVersion) {\n outputUpgradeMessage(resolvedCLIVersion, newestCLIVersion)\n } else {\n outputWontInstallMessage(resolvedCLIVersion)\n }\n\n await installJsonDependencies('prod', packageJsonDependencies, projectDir)\n await installJsonDependencies('dev', packageJsonDevDependencies, projectDir)\n}\n\nasync function installJsonDependencies(\n depsEnv: DependencyType,\n deps: {[key: string]: string},\n directory: string,\n): Promise<void> {\n const packagesToUpdate = [await cliDependency(), ...(await oclifPlugins())]\n .filter((pkg: string): boolean => {\n const pkgRequirement: string | undefined = deps[pkg]\n return Boolean(pkgRequirement)\n })\n .map((pkg) => {\n return {name: pkg, version: 'latest'}\n })\n\n const appUsesWorkspaces = await usesWorkspaces(directory)\n\n if (packagesToUpdate.length > 0) {\n await addNPMDependencies(packagesToUpdate, {\n packageManager: await getPackageManager(directory),\n type: depsEnv,\n directory,\n stdout: process.stdout,\n stderr: process.stderr,\n addToRootDirectory: appUsesWorkspaces,\n })\n }\n}\n\nasync function cliDependency(): Promise<string> {\n return (await packageJsonContents()).name\n}\n\nasync function oclifPlugins(): Promise<string[]> {\n return (await packageJsonContents())?.oclif?.plugins ?? []\n}\n\ntype PackageJsonWithName = Omit<PackageJson, 'name'> & {name: string}\nlet _packageJsonContents: PackageJsonWithName | undefined\n\nasync function packageJsonContents(): Promise<PackageJsonWithName> {\n if (!_packageJsonContents) {\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(import.meta.url))\n _packageJsonContents = _packageJsonContents ?? (packageJson.content as PackageJsonWithName)\n }\n return _packageJsonContents\n}\n\nfunction outputWontInstallMessage(currentVersion: string): void {\n outputInfo(outputContent`You're on the latest version, ${outputToken.yellow(currentVersion)}, no need to upgrade!`)\n}\n\nfunction outputUpgradeMessage(currentVersion: string, newestVersion: string): void {\n outputInfo(\n outputContent`Upgrading CLI from ${outputToken.yellow(currentVersion)} to ${outputToken.yellow(newestVersion)}...`,\n )\n}\n"]}
|