Skip to content

Auto-upgrade#6848

Draft
gonzaloriestra wants to merge 1 commit intomainfrom
auto-upgrade
Draft

Auto-upgrade#6848
gonzaloriestra wants to merge 1 commit intomainfrom
auto-upgrade

Conversation

@gonzaloriestra
Copy link
Contributor

@gonzaloriestra gonzaloriestra commented Feb 11, 2026

HackDays project: https://vault.shopify.io/hackdays/153/projects/22255

WHY are these changes introduced?

We want our devs to always use the latest CLI version and avoid fragmentation

WHAT is this pull request doing?

Checks once per day if there is a new CLI version available and automatically upgrades unless:

  • CI
  • Snapshot or nightly version
  • SHOPIFY_CLI_NO_AUTO_UPGRADE=1
  • Major version change
  • Development environment

TODO:

  • Clean old upgrade functions
  • Show loading bar while installs (and print more output?)

How to test your changes?

TBD

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@gonzaloriestra gonzaloriestra changed the title HackDays tests Auto-upgrade Feb 11, 2026
@Shopify Shopify deleted a comment from github-actions bot Feb 11, 2026
@Shopify Shopify deleted a comment from github-actions bot Feb 11, 2026
@Shopify Shopify deleted a comment from github-actions bot Feb 11, 2026
@Shopify Shopify deleted a comment from github-actions bot Feb 11, 2026
@Shopify Shopify deleted a comment from alfonso-noriega Feb 11, 2026
@Shopify Shopify deleted a comment from alfonso-noriega Feb 11, 2026
@Shopify Shopify deleted a comment from github-actions bot Feb 11, 2026
@gonzaloriestra gonzaloriestra force-pushed the auto-upgrade branch 2 times, most recently from a51cd38 to 085b95c Compare February 12, 2026 08:44
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.79% 14626/18564
🟡 Branches 73.13% 7269/9940
🟡 Functions 78.96% 3712/4701
🟡 Lines 79.14% 13823/17466

Test suite run success

3789 tests passing in 1456 suites.

Report generated by 🧪jest coverage report action from a2e57d5

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@gonzaloriestra
Copy link
Contributor Author

/snapit

@Shopify Shopify deleted a comment from github-actions bot Feb 13, 2026
@Shopify Shopify deleted a comment from github-actions bot Feb 13, 2026
@Shopify Shopify deleted a comment from github-actions bot Feb 13, 2026
@github-actions
Copy link
Contributor

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260213121951

Caution

After installing, validate the version by running just shopify in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

Co-Authored-By: Alfonso Noriega <alfonso.noriega.meneses@gmail.com>
@github-actions
Copy link
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/private/node/constants.d.ts
@@ -32,6 +32,7 @@ export declare const environmentVariables: {
     neverUsePartnersApi: string;
     skipNetworkLevelRetry: string;
     maxRequestTimeForNetworkCalls: string;
+    noAutoUpgrade: string;
 };
 export declare const defaultThemeKitAccessDomain = "theme-kit-access.shopifyapps.com";
 export declare const systemEnvironmentVariables: {
packages/cli-kit/dist/public/node/fs.d.ts
@@ -1,6 +1,6 @@
 import { RandomNameFamily } from '../common/string.js';
 import { OverloadParameters } from '../../private/common/ts/overloaded-parameters.js';
-import { findUp as internalFindUp } from 'find-up';
+import { findUp as internalFindUp, findUpSync as internalFindUpSync } from 'find-up';
 import { ReadStream, WriteStream } from 'fs';
 import type { Pattern, Options as GlobOptions } from 'fast-glob';
 /**
@@ -335,6 +335,14 @@ export declare function defaultEOL(): EOL;
  * @returns The first path found that matches or  if none could be found.
  */
 export declare function findPathUp(matcher: OverloadParameters<typeof internalFindUp>[0], options: OverloadParameters<typeof internalFindUp>[1]): ReturnType<typeof internalFindUp>;
+/**
+ * Find a file by walking parent directories.
+ *
+ * @param matcher - A pattern or an array of patterns to match a file name.
+ * @param options - Options for the search.
+ * @returns The first path found that matches or  if none could be found.
+ */
+export declare function findPathUpSync(matcher: OverloadParameters<typeof internalFindUp>[0], options: OverloadParameters<typeof internalFindUp>[1]): ReturnType<typeof internalFindUpSync>;
 export interface MatchGlobOptions {
     matchBase: boolean;
     noglobstar: boolean;
packages/cli-kit/dist/public/node/is-global.d.ts
@@ -26,6 +26,14 @@ export declare function installGlobalCLIPrompt(): Promise<InstallGlobalCLIPrompt
  * Infers the package manager used by the global CLI.
  *
  * @param argv - The arguments passed to the process.
+ * @param env - The environment variables of the process.
  * @returns The package manager used by the global CLI.
  */
-export declare function inferPackageManagerForGlobalCLI(argv?: string[]): PackageManager;
\ No newline at end of file
+export declare function inferPackageManagerForGlobalCLI(argv?: string[], env?: NodeJS.ProcessEnv): PackageManager;
+/**
+ * Returns the project directory for the given path.
+ *
+ * @param directory - The path to the directory to get the project directory for.
+ * @returns The project directory for the given path.
+ */
+export declare function getProjectDir(directory: string): string | undefined;
\ No newline at end of file
packages/cli-kit/dist/public/node/node-package-manager.d.ts
@@ -27,7 +27,7 @@ export type DependencyType = 'dev' | 'prod' | 'peer';
 /**
  * A union that represents the package managers available.
  */
-export declare const packageManager: readonly ["yarn", "npm", "pnpm", "bun", "unknown"];
+export declare const packageManager: readonly ["yarn", "npm", "pnpm", "bun", "homebrew", "unknown"];
 export type PackageManager = (typeof packageManager)[number];
 /**
  * Returns an abort error that's thrown when the package manager can't be determined.
packages/cli-kit/dist/public/node/upgrade.d.ts
@@ -4,7 +4,21 @@
  *
  * @returns A string with the command to run.
  */
-export declare function cliInstallCommand(): string;
+export declare function cliInstallCommand(): string | undefined;
+/**
+ * Runs the CLI upgrade using the appropriate package manager.
+ * Determines the install command and executes it.
+ *
+ * @throws AbortError if the package manager or command cannot be determined.
+ */
+export declare function runCLIUpgrade(): Promise<void>;
+/**
+ * Returns the version to auto-upgrade to, or undefined if auto-upgrade should be skipped.
+ * Checks for a cached newer version and skips for CI, pre-release versions, SHOPIFY_CLI_NO_AUTO_UPGRADE, or major version changes.
+ *
+ * @returns The version string to upgrade to, or undefined if no upgrade should happen.
+ */
+export declare function versionToAutoUpgrade(): string | undefined;
 /**
  * Generates a message to remind the user to update the CLI.
  *
packages/cli-kit/dist/public/node/version.d.ts
@@ -1,3 +1,17 @@
+/**
+ * Returns the current CLI version, read from the nearest package.json.
+ * The result is cached after the first call.
+ *
+ * This is a lazy function (rather than a top-level constant) because 
+ * depends on npm packages that may not yet be initialized during ESM module evaluation
+ * when circular imports are involved. Deferring the call to runtime avoids that issue.
+ *
+ * In unbundled (dev) mode this finds cli-kit's own package.json.
+ * In bundled (global install) mode this finds the CLI's package.json, which shares the same version.
+ *
+ * @returns The CLI version string.
+ */
+export declare function cliVersion(): string;
 /**
  * Returns the version of the local dependency of the CLI if it's installed in the provided directory.
  *
@@ -18,4 +32,12 @@ export declare function globalCLIVersion(): Promise<string | undefined>;
  * @param version - The version to check.
  * @returns True if the version is a pre-release version.
  */
-export declare function isPreReleaseVersion(version: string): boolean;
\ No newline at end of file
+export declare function isPreReleaseVersion(version: string): boolean;
+/**
+ * Checks if the version is a major version change.
+ *
+ * @param currentVersion - The current version.
+ * @param newerVersion - The newer version.
+ * @returns True if the version is a major version change.
+ */
+export declare function isMajorVersionChange(currentVersion: string, newerVersion: string): boolean;
\ No newline at end of file
packages/cli-kit/dist/public/node/context/local.d.ts
@@ -173,4 +173,11 @@ export declare function getThemeKitAccessDomain(env?: NodeJS.ProcessEnv): string
  * @returns The domain to send OTEL metrics to.
  */
 export declare function opentelemetryDomain(env?: NodeJS.ProcessEnv): string;
+/**
+ * Returns true if the CLIshould not automatically upgrade.
+ *
+ * @param env - The environment variables from the environment of the current process.
+ * @returns True if the CLI should not automatically upgrade.
+ */
+export declare function noAutoUpgrade(env?: NodeJS.ProcessEnv): boolean;
 export type CIMetadata = Metadata;
\ No newline at end of file
packages/cli-kit/dist/public/node/hooks/postrun.d.ts
@@ -5,4 +5,10 @@ import { Hook } from '@oclif/core';
  * @returns Whether post run hook has completed.
  */
 export declare function postRunHookHasCompleted(): boolean;
-export declare const hook: Hook.Postrun;
\ No newline at end of file
+export declare const hook: Hook.Postrun;
+/**
+ * Auto-upgrades the CLI after a command completes, if a newer version is available.
+ *
+ * @returns Resolves when the upgrade attempt (or fallback warning) is complete.
+ */
+export declare function autoUpgradeIfNeeded(): Promise<void>;
\ No newline at end of file
packages/cli-kit/dist/public/node/hooks/prerun.d.ts
@@ -11,6 +11,7 @@ export declare function parseCommandContent(cmdInfo: {
     pluginAlias?: string;
 }): CommandContent;
 /**
- * Warns the user if there is a new version of the CLI available
+ * Triggers a background check for a newer CLI version (non-blocking).
+ * The result is cached and consumed by the postrun hook for auto-upgrade.
  */
-export declare function warnOnAvailableUpgrade(): Promise<void>;
\ No newline at end of file
+export declare function checkForNewVersionInBackground(): void;
\ No newline at end of file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant