Skip to content

Commit f34e131

Browse files
committed
feat: ✨ introduce json output for cf pages deployment list, as it enables other tools like jq to parse the data
1 parent b391e00 commit f34e131

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

packages/wrangler/src/pages/deployments.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,19 @@ export function ListOptions(yargs: CommonYargsArgv) {
2828
choices: ["production", "preview"],
2929
description: "Environment type to list deployments for",
3030
},
31+
json: {
32+
type: "boolean",
33+
description: "Return output as clean JSON",
34+
default: false,
35+
},
3136
});
3237
}
3338

34-
export async function ListHandler({ projectName, environment }: ListArgs) {
39+
export async function ListHandler({
40+
projectName,
41+
environment,
42+
json,
43+
}: ListArgs) {
3544
const config = getConfigCache<PagesConfigCache>(PAGES_CONFIG_CACHE_FILENAME);
3645
const accountId = await requireAuth(config);
3746

@@ -72,6 +81,7 @@ export async function ListHandler({ projectName, environment }: ListArgs) {
7281

7382
const data = deployments.map((deployment) => {
7483
return {
84+
Id: deployment.id,
7585
Environment: titleCase(deployment.environment),
7686
Branch: deployment.deployment_trigger.metadata.branch,
7787
Source: shortSha(deployment.deployment_trigger.metadata.commit_hash),
@@ -86,6 +96,10 @@ export async function ListHandler({ projectName, environment }: ListArgs) {
8696
account_id: accountId,
8797
});
8898

89-
logger.table(data);
99+
if (json) {
100+
logger.log(JSON.stringify(data, null, 2));
101+
} else {
102+
logger.table(data);
103+
}
90104
metrics.sendMetricsEvent("list pages deployments");
91105
}

0 commit comments

Comments
 (0)