Skip to content

Auto-upgrade: skip project-local installs in postrun hook#7534

Open
alfonso-noriega wants to merge 3 commits into
mainfrom
autoupgrade-skip-local-projects
Open

Auto-upgrade: skip project-local installs in postrun hook#7534
alfonso-noriega wants to merge 3 commits into
mainfrom
autoupgrade-skip-local-projects

Conversation

@alfonso-noriega
Copy link
Copy Markdown
Contributor

What

When the autoupgrade postrun hook fires, it now passes {autoupgrade: true} to runCLIUpgrade. With that flag set, project-local installs are skipped — only global installs get upgraded silently in the background.

Explicit shopify upgrade invocations are unchanged: they still upgrade the project's package.json / lockfile.

Why

Mutating a user's package.json and 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 run shopify upgrade explicitly.

Changes

  • runCLIUpgrade accepts a new optional RunCLIUpgradeOptions arg with an autoupgrade?: boolean field.
  • When autoupgrade && !isGlobal, we skip with a debug log and return early.
  • postrun.ts passes {autoupgrade: true}; shopify upgrade calls runCLIUpgrade() with no args (default false).
  • Added a unit test covering the new skip path.
  • Changeset (patch on @shopify/cli-kit).

Testing

pnpm vitest run src/public/node/upgrade.test.ts        # 29/29 ✓
pnpm vitest run src/public/node/hooks/postrun.test.ts  # 9/9 ✓
pnpm type-check                                         # ✓

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.
@alfonso-noriega alfonso-noriega requested review from a team as code owners May 12, 2026 16:22
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label May 12, 2026
@github-actions github-actions Bot added no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. and removed Area: @shopify/cli @shopify/cli package issues labels May 12, 2026
@github-actions
Copy link
Copy Markdown
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/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 .

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

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant