Skip to content

Commit 4c06766

Browse files
authored
fix(wrangler): skip banner when using --json flag in wrangler pages deployment commands (#10822)
* fix(wrangler): wrangler pages deployment list --json should skip the banner * refactor(wrangler): align printBanner setup on wrangler deployment commands
1 parent df793f2 commit 4c06766

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

.changeset/bumpy-schools-sniff.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
fix: skip banner when using `--json` flag in `wrangler pages deployment` commands

packages/wrangler/src/__tests__/pages/deployment-list.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { runWrangler } from "./../helpers/run-wrangler";
88
import type { Deployment } from "./../../pages/types";
99

1010
describe("pages deployment list", () => {
11+
vi.unmock("../../wrangler-banner");
1112
runInTempDir();
1213
mockAccountId();
1314
mockApiToken();
@@ -47,7 +48,10 @@ describe("pages deployment list", () => {
4748

4849
expect(requests.count).toBe(1);
4950
expect(std.out).toMatchInlineSnapshot(`
50-
"┌─┬─┬─┬─┬─┬─┬─┐
51+
"
52+
⛅️ wrangler x.x.x
53+
──────────────────
54+
┌─┬─┬─┬─┬─┬─┬─┐
5155
│ Id │ Environment │ Branch │ Source │ Deployment │ Status │ Build │
5256
├─┼─┼─┼─┼─┼─┼─┤
5357
│ 87bbc8fe-16be-45cd-81e0-63d722e82cdf │ Preview │ main │ c764936 │ https://87bbc8fe.images.pages.dev │ 3 years ago │ https://dash.cloudflare.com/some-account-id/pages/view/images/87bbc8fe-16be-45cd-81e0-63d722e82cdf │

packages/wrangler/src/pages/deployments.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const pagesDeploymentListCommand = createCommand({
2121
},
2222
behaviour: {
2323
provideConfig: false,
24+
printBanner: (args) => !args.json,
2425
},
2526
args: {
2627
"project-name": {

packages/wrangler/src/versions/deployments/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const deploymentsListCommand = createCommand({
3131
},
3232
},
3333
behaviour: {
34-
printBanner: false,
34+
printBanner: (args) => !args.json,
3535
},
3636
handler: async function versionsDeploymentsListHandler(args, { config }) {
3737
metrics.sendMetricsEvent(

packages/wrangler/src/versions/deployments/status.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { UserError } from "../../errors";
66
import * as metrics from "../../metrics";
77
import { requireAuth } from "../../user";
88
import formatLabelledValues from "../../utils/render-labelled-values";
9-
import { printWranglerBanner } from "../../wrangler-banner";
109
import { fetchLatestDeployment, fetchVersions } from "../api";
1110
import { getDeploymentSource } from "./list";
1211
import type { VersionCache } from "../types";
@@ -32,13 +31,9 @@ export const deploymentsStatusCommand = createCommand({
3231
},
3332
},
3433
behaviour: {
35-
printBanner: false,
34+
printBanner: (args) => !args.json,
3635
},
3736
handler: async function versionsDeploymentsStatusHandler(args, { config }) {
38-
if (!args.json) {
39-
await printWranglerBanner();
40-
}
41-
4237
metrics.sendMetricsEvent(
4338
"view latest versioned deployment",
4439
{},

0 commit comments

Comments
 (0)