-
Notifications
You must be signed in to change notification settings - Fork 129
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
Auto-update CLI in the background when a new version is available #4789
base: main
Are you sure you want to change the base?
Conversation
Coverage report
Show files with reduced coverage 🔻
Test suite run success1931 tests passing in 874 suites. Report generated by 🧪jest coverage report action from dc80aa3 |
/snapit |
🫰✨ Thanks @amcaplan! Your snapshot has been published to npm. Test the snapshot by intalling your package globally: pnpm i -g @shopify/[email protected]
|
/snapit |
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@@ -30,6 +30,7 @@ export declare const environmentVariables: {
refreshToken: string;
otelURL: string;
themeKitAccessDomain: string;
+ disableAutoUpdate: string;
};
export declare const defaultThemeKitAccessDomain = "theme-kit-access.shopifyapps.com";
export declare const systemEnvironmentVariables: {
packages/cli-kit/dist/public/node/node-package-manager.d.ts@@ -140,6 +140,17 @@ export declare function checkForNewVersion(dependency: string, currentVersion: s
* @returns A more recent version or undefined if there's no more recent version.
*/
export declare function checkForCachedNewVersion(dependency: string, currentVersion: string): string | undefined;
+/**
+ * Given a current version and a new version, it returns true if it's safe to auto-upgrade the dependency.
+ * It's considered safe if the major version is the same.
+ * @param currentVersion - The current version.
+ * @param newVersion - The new version.
+ * @returns Boolean Whether it's safe to auto-upgrade the dependency.
+ * @example
+ * safeToAutoUpgrade('1.2.3', '1.3.0') // true
+ * safeToAutoUpgrade('1.2.3', '2.0.0') // false
+ */
+export declare function safeToAutoUpgrade(currentVersion: string, newVersion: string): boolean;
/**
* Utility function used to check whether a package version satisfies some requirements
* @param version - The version to check
packages/cli-kit/dist/public/node/system.d.ts@@ -12,6 +12,8 @@ export interface ExecOptions {
stdio?: 'inherit';
input?: string;
signal?: AbortSignal;
+ detached?: boolean;
+ unref?: boolean;
externalErrorHandler?: (error: unknown) => Promise<void>;
}
/**
packages/cli-kit/dist/public/node/upgrade.d.ts@@ -5,6 +5,13 @@
* @returns A string with the command to run.
*/
export declare function cliInstallCommand(): string;
+/**
+ * Utility function for generating an install command for the user to run
+ * to install an updated version of Shopify CLI. Returns as an array of strings.
+ *
+ * @returns A string array with the command to run.
+ */
+export declare function cliInstallCommandAsArray(): [string, ...string[]];
/**
* Generates a message to remind the user to update the CLI.
*
packages/cli-kit/dist/public/node/context/local.d.ts@@ -170,4 +170,12 @@ export declare function macAddress(): Promise<string>;
* @returns The domain to send OTEL metrics to.
*/
export declare function opentelemetryDomain(env?: NodeJS.ProcessEnv): string | undefined;
-export type CIMetadata = Metadata;
\ No newline at end of file
+export type CIMetadata = Metadata;
+/**
+ * Returns whether auto-updates are enabled.
+ * It can be overridden via the SHOPIFY_CLI_DISABLE_AUTO_UPDATES environment variable.
+ *
+ * @param env - The environment variables from the environment of the current process.
+ * @returns Whether auto-updates are enabled.
+ */
+export declare function autoUpdatesEnabled(env?: NodeJS.ProcessEnv): boolean;
\ No newline at end of file
packages/cli-kit/dist/public/node/hooks/prerun.d.ts@@ -13,4 +13,5 @@ export declare function parseCommandContent(cmdInfo: {
/**
* Warns the user if there is a new version of the CLI available
*/
-export declare function warnOnAvailableUpgrade(): Promise<void>;
\ No newline at end of file
+export declare function warnOnAvailableUpgrade(): Promise<void>;
+export declare function autoUpdateCli(currentVersion: string, newerVersion: string): Promise<void>;
\ No newline at end of file
|
🫰✨ Thanks @amcaplan! Your snapshot has been published to npm. Test the snapshot by intalling your package globally: pnpm i -g @shopify/[email protected]
|
WHY are these changes introduced?
Fixes #0000
WHAT is this pull request doing?
How to test your changes?
Post-release steps
Measuring impact
How do we know this change was effective? Please choose one:
Checklist