Auto-upgrade: skip project-local installs in postrun hook#7534
Open
alfonso-noriega wants to merge 3 commits into
Open
Auto-upgrade: skip project-local installs in postrun hook#7534alfonso-noriega wants to merge 3 commits into
alfonso-noriega wants to merge 3 commits into
Conversation
When the postrun hook triggers auto-upgrade, it now passes `{autoupgrade: true}`
to `runCLIUpgrade`. With that flag set, project-local installs are skipped so
the silent background flow doesn't surprise users by mutating their app's
`package.json` / lockfile.
Explicit `shopify upgrade` invocations still upgrade local projects \u2014 this
only changes the implicit postrun-triggered path.
Contributor
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/public/node/upgrade.d.ts@@ -7,13 +7,26 @@ export { getAutoUpgradeEnabled, setAutoUpgradeEnabled };
* @returns A string with the command to run, or undefined if the package manager cannot be determined.
*/
export declare function cliInstallCommand(): string | undefined;
+/**
+ * Options for {@link runCLIUpgrade}.
+ */
+export interface RunCLIUpgradeOptions {
+ /**
+ * when the upgrade is being triggered by the automatic postrun hook.
+ * In that case we skip project-local upgrades — those should only happen when the
+ * user explicitly runs so we don't surprise them by mutating
+ * their / lockfile in the background.
+ */
+ autoupgrade?: boolean;
+}
/**
* Runs the CLI upgrade using the appropriate package manager.
* Determines the install command and executes it.
*
+ * @param options - See {@link RunCLIUpgradeOptions}.
* @throws AbortError if the package manager or command cannot be determined.
*/
-export declare function runCLIUpgrade(): Promise<void>;
+export declare function runCLIUpgrade(options?: RunCLIUpgradeOptions): Promise<void>;
/**
* Returns the version to auto-upgrade to, or undefined if auto-upgrade should be skipped.
* Auto-upgrade is disabled by default and must be enabled via .
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When the autoupgrade postrun hook fires, it now passes
{autoupgrade: true}torunCLIUpgrade. With that flag set, project-local installs are skipped — only global installs get upgraded silently in the background.Explicit
shopify upgradeinvocations are unchanged: they still upgrade the project'spackage.json/ lockfile.Why
Mutating a user's
package.jsonand lockfile in the background is surprising and produces noisy diffs in their app project. The postrun-triggered upgrade should be unobtrusive; users who want their project bumped can runshopify upgradeexplicitly.Changes
runCLIUpgradeaccepts a new optionalRunCLIUpgradeOptionsarg with anautoupgrade?: booleanfield.autoupgrade && !isGlobal, we skip with a debug log and return early.postrun.tspasses{autoupgrade: true};shopify upgradecallsrunCLIUpgrade()with no args (defaultfalse).@shopify/cli-kit).Testing