From 77e906260f01328eb05cfc10e6c6e72d2596d92c Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Wed, 29 Apr 2026 21:37:16 +0100 Subject: [PATCH 1/2] fix(wrangler): skip versions deploy prompts for args --- .changeset/slow-masks-film.md | 7 +++ .../versions/versions.deploy.test.ts | 50 +++++++++++++++++++ packages/wrangler/src/versions/deploy.ts | 29 +++++------ 3 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 .changeset/slow-masks-film.md diff --git a/.changeset/slow-masks-film.md b/.changeset/slow-masks-film.md new file mode 100644 index 00000000000..0336d3a7320 --- /dev/null +++ b/.changeset/slow-masks-film.md @@ -0,0 +1,7 @@ +--- +"wrangler": patch +--- + +Skip confirmation prompts in `wrangler versions deploy` when versions are provided as CLI arguments + +Passing version IDs or version specs to `wrangler versions deploy` now applies those values directly instead of opening interactive prompts to confirm the same versions and percentages. This makes the command easier to automate without requiring `--yes`. diff --git a/packages/wrangler/src/__tests__/versions/versions.deploy.test.ts b/packages/wrangler/src/__tests__/versions/versions.deploy.test.ts index a95d4fc43d3..d377a0f8ec5 100644 --- a/packages/wrangler/src/__tests__/versions/versions.deploy.test.ts +++ b/packages/wrangler/src/__tests__/versions/versions.deploy.test.ts @@ -278,6 +278,22 @@ describe("versions deploy", () => { `); }); + test("1 version @ (implicit) 100% without --yes", async ({ expect }) => { + const result = runWrangler( + "versions deploy 10000000-0000-0000-0000-000000000000" + ); + + await expect(result).resolves.toBeUndefined(); + + const output = normalizeOutput(cliStd.out); + expect(output).toContain( + "SUCCESS Deployed test-name version 00000000-0000-0000-0000-000000000000 at 100%" + ); + expect(output).not.toContain( + "Use SPACE to select/unselect version(s) and ENTER to submit." + ); + }); + test("1 version @ (explicit) 100%", async ({ expect }) => { const result = runWrangler( "versions deploy 10000000-0000-0000-0000-000000000000@100% --yes" @@ -537,6 +553,40 @@ describe("versions deploy", () => { `); }); + test("2 versions @ (explicit) 40% + (explicit) 60% without --yes", async ({ + expect, + }) => { + const result = runWrangler( + "versions deploy 10000000-0000-0000-0000-000000000000@40% 20000000-0000-0000-0000-000000000000@60%" + ); + + await expect(result).resolves.toBeUndefined(); + + const output = normalizeOutput(cliStd.out); + expect(output).toContain( + "SUCCESS Deployed test-name version 00000000-0000-0000-0000-000000000000 at 40% and version 00000000-0000-0000-0000-000000000000 at 60%" + ); + expect(output).not.toContain( + "Use SPACE to select/unselect version(s) and ENTER to submit." + ); + }); + + test("--version-id and --percentage without --yes", async ({ expect }) => { + const result = runWrangler( + "versions deploy --version-id 10000000-0000-0000-0000-000000000000 --percentage 100" + ); + + await expect(result).resolves.toBeUndefined(); + + const output = normalizeOutput(cliStd.out); + expect(output).toContain( + "SUCCESS Deployed test-name version 00000000-0000-0000-0000-000000000000 at 100%" + ); + expect(output).not.toContain( + "Use SPACE to select/unselect version(s) and ENTER to submit." + ); + }); + describe("max versions restrictions (temp)", () => { test("2+ versions fails", async ({ expect }) => { msw.use(mswGetVersion30000000); diff --git a/packages/wrangler/src/versions/deploy.ts b/packages/wrangler/src/versions/deploy.ts index 394201ff469..5ee4d3f1921 100644 --- a/packages/wrangler/src/versions/deploy.ts +++ b/packages/wrangler/src/versions/deploy.ts @@ -117,6 +117,7 @@ export const versionsDeployCommand = createCommand({ const versionCache: VersionCache = new Map(); const optionalVersionTraffic = parseVersionSpecs(args); + const acceptPromptDefaults = args.yes || optionalVersionTraffic.size > 0; cli.startSection( "Deploy Worker Versions", @@ -133,7 +134,7 @@ export const versionsDeployCommand = createCommand({ workerName, [...optionalVersionTraffic.keys()], versionCache, - args.yes + acceptPromptDefaults ); // validate we have at least 1 version @@ -155,7 +156,7 @@ export const versionsDeployCommand = createCommand({ const confirmedVersionTraffic = await promptPercentages( confirmedVersionsToDeploy, optionalVersionTraffic, - args.yes + acceptPromptDefaults ); // prompt for deployment message @@ -163,7 +164,7 @@ export const versionsDeployCommand = createCommand({ type: "text", label: "Deployment message", defaultValue: args.message, - acceptDefault: args.yes, + acceptDefault: acceptPromptDefaults, question: "Add a deployment message", helpText: "(optional)", }); @@ -351,7 +352,7 @@ function formatVersions( * @param accountId * @param workerName * @param defaultSelectedVersionIds - * @param yesFlag + * @param acceptDefault * @returns */ async function promptVersionsToDeploy( @@ -360,13 +361,13 @@ async function promptVersionsToDeploy( workerName: string, defaultSelectedVersionIds: VersionId[], versionCache: VersionCache, - yesFlag: boolean + acceptDefault: boolean ): Promise { // If the user has already specified all versions they want to deploy and - // has passed --yes (so there's no interactive prompt), skip fetching the + // the defaults will be accepted (so there's no interactive prompt), skip fetching the // full deployable-versions list and only fetch the specific versions needed. const skipDeployableVersionsFetch = - yesFlag && defaultSelectedVersionIds.length > 0; + acceptDefault && defaultSelectedVersionIds.length > 0; await spinnerWhile({ startMessage: "Fetching versions", @@ -414,7 +415,7 @@ ${ZERO_WIDTH_SPACE} Message: ${ label: "", helpText: "Use SPACE to select/unselect version(s) and ENTER to submit.", defaultValue: defaultSelectedVersionIds, - acceptDefault: yesFlag, + acceptDefault, validate(versionIds) { if (versionIds === undefined) { return `You must select at least 1 version to deploy.`; @@ -464,14 +465,14 @@ ${grayBar} ${gray( * * @param versionIds The Version IDs the user has selected to deploy * @param optionalVersionTraffic The percentages the user has specified as args (if any) - * @param yesFlag Whether the user specified the --yes flag + * @param acceptDefault Whether prompt defaults should be accepted automatically * @param confirmedVersionTraffic The percentages the user has already entered. Used for recursive calls. * @returns A Map of Version IDs to their respective percentages confirmed by the user, totaling 100% */ async function promptPercentages( versionIds: VersionId[], optionalVersionTraffic: Map, - yesFlag: boolean, + acceptDefault: boolean, confirmedVersionTraffic = new Map() ): Promise> { let n = 0; @@ -497,7 +498,7 @@ async function promptPercentages( label: `Traffic`, defaultValue, initialValue: confirmedVersionTraffic.get(versionId)?.toString(), // if the user already entered a value, override the default - acceptDefault: yesFlag, + acceptDefault, format: (val) => `${val}%`, validate: (val) => { const input = val !== "" ? val : defaultValue; @@ -538,9 +539,9 @@ async function promptPercentages( validateTrafficSubtotal(subtotal); } catch (err) { if (err instanceof UserError) { - // if the user has indicated they'll accept all defaults (yesFlag) + // if the user has indicated they'll accept all defaults // then rethrow to avoid an infinite loop of reprompting - if (yesFlag) { + if (acceptDefault) { throw err; } @@ -549,7 +550,7 @@ async function promptPercentages( return promptPercentages( versionIds, optionalVersionTraffic, - yesFlag, + acceptDefault, confirmedVersionTraffic ); } From 9ab7a95a25d37770c535b236269b94fe67ab9993 Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Tue, 5 May 2026 15:30:08 +0100 Subject: [PATCH 2/2] update version-specs description --- packages/wrangler/src/versions/deploy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wrangler/src/versions/deploy.ts b/packages/wrangler/src/versions/deploy.ts index 5ee4d3f1921..a0b4e3198e6 100644 --- a/packages/wrangler/src/versions/deploy.ts +++ b/packages/wrangler/src/versions/deploy.ts @@ -72,7 +72,7 @@ export const versionsDeployCommand = createCommand({ }, "version-specs": { describe: - "Shorthand notation to deploy Worker Version(s) [@..]", + "Shorthand notation to deploy Worker Version(s) [@..]. Omitted percentages share the remaining traffic.", type: "string", array: true, },