-
Notifications
You must be signed in to change notification settings - Fork 225
Auto-upgrade #6848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Auto-upgrade #6848
Conversation
|
/snapit |
|
🫰✨ 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/[email protected]Caution After installing, validate the version by running just |
7056201 to
0287a52
Compare
a51cd38 to
085b95c
Compare
Coverage report
Test suite run success3788 tests passing in 1455 suites. Report generated by 🧪jest coverage report action from 312b035 |
085b95c to
a8bb7b0
Compare
Co-Authored-By: Alfonso Noriega <[email protected]>
a8bb7b0 to
312b035
Compare
Differences in type declarationsWe 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:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/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,7 @@ 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;
\ 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,22 @@
*
* @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>;
+/**
+ * Determines whether the CLI should auto-upgrade. Returns false for CI, when SHOPIFY_CLI_NO_AUTO_UPGRADE=1, or major version changes.
+ *
+ * @param currentVersion - The current CLI version.
+ * @param newerVersion - The newer available version.
+ * @returns True if auto-upgrade should proceed, false otherwise.
+ */
+export declare function shouldAutoUpgrade(currentVersion: string, newerVersion: string): boolean;
/**
* Generates a message to remind the user to update the CLI.
*
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
|

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:
SHOPIFY_CLI_NO_AUTO_UPGRADE=1How to test your changes?
TBD
Measuring impact
How do we know this change was effective? Please choose one:
Checklist