Repository navigation
Add typed JSON output to upgrade - #8618
Conversation
4ec0fa7 to
e3d9285
Compare
e3d9285 to
3b3c599
Compare
|
/snapit |
|
🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm. Built from Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261002100254Caution After installing, validate the version by running |
3b3c599 to
e0d720d
Compare
|
/snapit |
|
🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm. Built from Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261006134446Caution After installing, validate the version by running |
bd57ce1 to
a0f6402
Compare
isaacroldan
left a comment
There was a problem hiding this comment.
One issue with the package manager output in JSON mode.
🤖 Generated by the review-pr skill
e843438 to
3bceff2
Compare
3bceff2 to
99214b7
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 declarationspackages/cli-kit/dist/public/node/upgrade/output.d.tsimport { Writable } from 'node:stream';
/**
* Keeps package-manager output off the result channel in JSON mode.
*
* @returns Streams for package-manager diagnostics, or the original terminal streams.
*/
export declare function upgradeOutputStreams(): {
stdout: Writable;
stderr: Writable;
};
/**
* Runs a global upgrade with terminal input and format-appropriate diagnostics.
*
* @param command - The package-manager executable.
* @param args - The install arguments.
*/
export declare function execUpgradeCommand(command: string, args: string[]): Promise<void>;
packages/cli-kit/dist/public/node/upgrade/result.d.tsimport { type UpgradeResult } from './types.js';
/**
* Presents the upgrade result without changing progress or package-manager output.
*
* @param result - The completed upgrade outcome.
* @param format - The output format selected by the caller.
*/
export declare function presentUpgradeResult(result: UpgradeResult, format: 'json' | 'text'): void;
packages/cli-kit/dist/public/node/upgrade/types.d.tsimport { type InferJsonOutputSchema } from '../json-output-schema.js';
import { zod } from '../schema.js';
export declare const upgradeJsonOutputSchema: import("../json-output-schema.js").JsonOutputSchema<zod.ZodUnion<[zod.ZodObject<{
status: zod.ZodLiteral<"success">;
changed: zod.ZodBoolean;
scope: zod.ZodLiteral<"global">;
previousVersion: zod.ZodString;
version: zod.ZodString;
packageManager: zod.ZodEnum<["npm", "pnpm", "yarn", "bun", "homebrew"]>;
}, "strict", zod.ZodTypeAny, {
status: "success";
version: string;
scope: "global";
changed: boolean;
previousVersion: string;
packageManager: "yarn" | "npm" | "pnpm" | "bun" | "homebrew";
}, {
status: "success";
version: string;
scope: "global";
changed: boolean;
previousVersion: string;
packageManager: "yarn" | "npm" | "pnpm" | "bun" | "homebrew";
}>, zod.ZodObject<{
status: zod.ZodLiteral<"success">;
changed: zod.ZodNull;
scope: zod.ZodLiteral<"local">;
directory: zod.ZodEffects<zod.ZodEffects<zod.ZodString, string, string>, string, string>;
previousVersion: zod.ZodString;
availableVersion: zod.ZodNullable<zod.ZodString>;
packages: zod.ZodArray<zod.ZodString, "many">;
}, "strict", zod.ZodTypeAny, {
status: "success";
directory: string;
scope: "local";
changed: null;
previousVersion: string;
availableVersion: string | null;
packages: string[];
}, {
status: "success";
directory: string;
scope: "local";
changed: null;
previousVersion: string;
availableVersion: string | null;
packages: string[];
}>, zod.ZodObject<{
status: zod.ZodLiteral<"skipped">;
reason: zod.ZodEnum<["development", "local-autoupgrade", "dependency-not-found"]>;
scope: zod.ZodEnum<["global", "local"]>;
}, "strict", zod.ZodTypeAny, {
status: "skipped";
scope: "local" | "global";
reason: "development" | "local-autoupgrade" | "dependency-not-found";
}, {
status: "skipped";
scope: "local" | "global";
reason: "development" | "local-autoupgrade" | "dependency-not-found";
}>]>>;
export type UpgradeResult = InferJsonOutputSchema<typeof upgradeJsonOutputSchema>;
Existing type declarationspackages/cli-kit/dist/public/node/upgrade.d.ts@@ -1,4 +1,5 @@
import { getAutoUpgradeEnabled, setAutoUpgradeEnabled } from '../../private/node/conf-store.js';
+import type { UpgradeResult } from './upgrade/types.js';
export { getAutoUpgradeEnabled, setAutoUpgradeEnabled };
/**
* Utility function for generating an install command for the user to run
@@ -27,6 +28,13 @@ export interface RunCLIUpgradeOptions {
* @throws AbortError if the package manager or command cannot be determined.
*/
export declare function runCLIUpgrade(options?: RunCLIUpgradeOptions): Promise<void>;
+/**
+ * Upgrades the CLI and returns the outcome independently of final presentation.
+ *
+ * @param options - Whether the upgrade was triggered automatically.
+ * @returns The verified global version, local dependency update, or skip reason.
+ */
+export declare function upgradeCLI(options?: RunCLIUpgradeOptions): Promise<UpgradeResult>;
/**
* Returns the version to auto-upgrade to, or undefined if auto-upgrade should be skipped.
* Auto-upgrade is enabled by default and can be disabled via `setAutoUpgradeEnabled(false)`.
|
|
/snapit |
|
🫰✨ Thanks @isaacroldan! Your snapshot has been published to npm. Built from Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261009090327Caution After installing, validate the version by running |
WHY are these changes introduced?
Fixes https://github.com/shop/issues-develop/issues/23676.
shopify upgradeneeds a structured result for scripts and agents.WHAT is this pull request doing?
Add
--jsonwith a strict, discoverable result schema for global upgrades, local dependency installations, and skips. Use canonicalsuccess/skippedoutcomes and kebab-case skip reasons; send package-manager diagnostics through stderr events.Global results include the verified installed version and
changed. Local results include the absolute project directory, updated package names, and nullable available version. Theirchangedisnullbecause installed local versions and dependency changes are not verified. Preserve existing terminal output and automatic upgrade behavior.How to manually test your changes?
Checklist