Skip to content

[wrangler] Add --json flag to pages project list command#12465

Merged
petebacondarwin merged 4 commits intomainfrom
fix/4140-pages-project-list-json
Feb 9, 2026
Merged

[wrangler] Add --json flag to pages project list command#12465
petebacondarwin merged 4 commits intomainfrom
fix/4140-pages-project-list-json

Conversation

@petebacondarwin
Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin commented Feb 7, 2026

Fixes #4140.

This adds a --json flag to the wrangler pages project list command that outputs the project list as clean JSON instead of a formatted table. This enables easier programmatic processing and scripting workflows.

Example usage:

wrangler pages project list --json

Changes:

  • Added json argument to pagesProjectListCommand with type boolean and default false
  • Added printBanner: (args) => !args.json behavior to suppress the banner when JSON output is requested
  • Updated handler to conditionally output JSON (with JSON.stringify(data, null, 2)) or table
  • Added two new tests for JSON output validation and banner suppression

This follows the same pattern used by other wrangler commands like wrangler pages deployment list --json, wrangler d1 list --json, and wrangler queues list --json.


A picture of a cute animal (not mandatory, but encouraged)

🐕


Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 7, 2026

🦋 Changeset detected

Latest commit: 39f355f

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Feb 7, 2026

Claude finished @petebacondarwin's task —— View job


Changeset Review

Reviewed .changeset/pages-project-list-json-flag.md against project guidelines.

Todo:

  • Read changeset guidelines
  • Review .changeset/pages-project-list-json-flag.md
  • Validate against criteria
  • Check for cute animals

All changesets look good

The changeset properly:

  • Uses minor version type (new CLI flag = new feature ✓)
  • Provides clear description of the change and its purpose
  • Includes a helpful usage example showing the JSON output format
  • Contains no problematic markdown headers (h1/h2/h3)
  • Does not involve analytics changes
  • Is not an experimental feature

The description clearly explains what the feature does and why it's useful, with a practical example showing the expected output format.


Cuteness Report: This is Claude. He's a spinning loading indicator and doesn't even know he's working overtime. Very dedicated. 14/10 would spin again. 🔄

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 7, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12465

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12465

miniflare

npm i https://pkg.pr.new/miniflare@12465

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12465

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12465

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12465

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12465

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12465

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12465

wrangler

npm i https://pkg.pr.new/wrangler@12465

commit: 39f355f

@petebacondarwin petebacondarwin marked this pull request as ready for review February 7, 2026 15:53
@petebacondarwin petebacondarwin requested review from a team as code owners February 7, 2026 15:53
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Closes #4140

This adds a --json flag to the 'wrangler pages project list' command that
outputs the project list as clean JSON instead of a formatted table.
This enables easier programmatic processing and scripting workflows.

Changes:
- Added json argument to pagesProjectListCommand
- Added printBanner behavior to suppress banner when --json is used
- Updated handler to conditionally output JSON or table
- Added tests for JSON output and banner suppression
@petebacondarwin petebacondarwin force-pushed the fix/4140-pages-project-list-json branch from 7bae777 to 90d3ff6 Compare February 8, 2026 14:11
vicb
vicb previously requested changes Feb 8, 2026
Copy link
Copy Markdown
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comments

Comment thread .changeset/pages-project-list-json-flag.md
Comment thread packages/wrangler/src/__tests__/pages/project-list.test.ts Outdated
Comment thread packages/wrangler/src/__tests__/pages/project-list.test.ts Outdated
args: {
json: {
type: "boolean",
description: "Return output as clean JSON",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "Return output as clean JSON",
description: "Return output as JSON",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This phrasing is used throughout the code base...

27 results - 24 files

packages/wrangler/CHANGELOG.md:
  6561  
  6562: ⟪ 286 characters skipped ⟫erimental-versions`, `wrangler deployments status --experimental-versions`, `wrangler versions list --experimental-versions` and `wrangler versions view --experimental-versions` which will format the output as clean JSON. The ` --experimental-versions` flag is still required for these commands.
  6563  

  8194          --timestamp  accepts a Unix (seconds from epoch) or RFC3339 timestamp (e.g. 2023-07-13T08:46:42.228Z) to retrieve a bookmark for  [string]
  8195:         --json       return output as clean JSON  [boolean] [default: false]
  8196  

  8200          --timestamp  accepts a Unix (seconds from epoch) or RFC3339 timestamp (e.g. 2023-07-13T08:46:42.228Z) to retrieve a bookmark for  [string]
  8201:         --json       return output as clean JSON  [boolean] [default: false]
  8202    ```

packages/wrangler/src/__tests__/vectorize/vectorize.test.ts:
  124  			OPTIONS
  125: 			      --json           Return output as clean JSON  [boolean] [default: false]
  126  			      --deprecated-v1  Fetch a deprecated V1 Vectorize index. This must be enabled if the index was created with V1 option.  [boolean] [default: false]"

  925  			      --cursor  Cursor for pagination to get the next page of results  [string]
  926: 			      --json    Return output as clean JSON  [boolean] [default: false]
  927  

packages/wrangler/src/ai/listCatalog.ts:
  17  			type: "boolean",
  18: 			description: "Return output as clean JSON",
  19  			default: false,

packages/wrangler/src/ai/listFinetune.ts:
  18  			type: "boolean",
  19: 			description: "Return output as clean JSON",
  20  			default: false,

packages/wrangler/src/d1/execute.ts:
  93  			type: "boolean",
  94: 			description: "Return output as clean JSON",
  95  			default: false,

packages/wrangler/src/d1/info.ts:
  30  			type: "boolean",
  31: 			description: "Return output as clean JSON",
  32  			default: false,

packages/wrangler/src/d1/insights.ts:
  109  			type: "boolean",
  110: 			description: "return output as clean JSON",
  111  			default: false,

packages/wrangler/src/d1/list.ts:
  20  			type: "boolean",
  21: 			description: "Return output as clean JSON",
  22  			default: false,

packages/wrangler/src/d1/timeTravel/info.ts:
  35  			type: "boolean",
  36: 			description: "Return output as clean JSON",
  37  			default: false,

packages/wrangler/src/d1/timeTravel/restore.ts:
  43  			type: "boolean",
  44: 			description: "Return output as clean JSON",
  45  			default: false,

packages/wrangler/src/pages/deployments.ts:
  40  			type: "boolean",
  41: 			description: "Return output as clean JSON",
  42  			default: false,

packages/wrangler/src/pages/projects.ts:
  31  			type: "boolean",
  32: 			description: "Return output as clean JSON",
  33  			default: false,

packages/wrangler/src/vectorize/create.ts:
  57  			default: false,
  58: 			description: "Return output as clean JSON",
  59  		},

packages/wrangler/src/vectorize/get.ts:
  23  			default: false,
  24: 			description: "Return output as clean JSON",
  25  		},

packages/wrangler/src/vectorize/info.ts:
  20  		json: {
  21: 			describe: "return output as clean JSON",
  22  			type: "boolean",

packages/wrangler/src/vectorize/insert.ts:
  45  		json: {
  46: 			describe: "return output as clean JSON",
  47  			type: "boolean",

packages/wrangler/src/vectorize/list.ts:
  18  			default: false,
  19: 			description: "Return output as clean JSON",
  20  		},

packages/wrangler/src/vectorize/listMetadataIndex.ts:
  21  		json: {
  22: 			describe: "return output as clean JSON",
  23  			type: "boolean",

packages/wrangler/src/vectorize/listVectors.ts:
  44  			default: false,
  45: 			description: "Return output as clean JSON",
  46  		},

packages/wrangler/src/vectorize/upsert.ts:
  42  		json: {
  43: 			describe: "return output as clean JSON",
  44  			type: "boolean",

packages/wrangler/src/versions/list.ts:
  27  		json: {
  28: 			describe: "Display output as clean JSON",
  29  			type: "boolean",

packages/wrangler/src/versions/view.ts:
  35  		json: {
  36: 			describe: "Display output as clean JSON",
  37  			type: "boolean",

packages/wrangler/src/versions/deployments/list.ts:
  27  		json: {
  28: 			describe: "Display output as clean JSON",
  29  			type: "boolean",

packages/wrangler/src/versions/deployments/status.ts:
  27  		json: {
  28: 			describe: "Display output as clean JSON",
  29  			type: "boolean",

If it was good enough to land previously, then this is definitely a nit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it was good enough to land previously, then this is definitely a nit.

We should clean existing code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this PR 😄

@github-project-automation github-project-automation Bot moved this from Approved to In Review in workers-sdk Feb 8, 2026
@petebacondarwin
Copy link
Copy Markdown
Contributor Author

Can I confirm that all these suggestions are nits, which makes me surprised that you block the PR on those.

@petebacondarwin petebacondarwin requested a review from vicb February 8, 2026 17:33
Comment thread packages/wrangler/src/__tests__/pages/project-list.test.ts Outdated
@vicb vicb dismissed their stale review February 9, 2026 17:57

updates

Copy link
Copy Markdown
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update 🚀

Looks like the CI is unhappy because github is down :(

@github-project-automation github-project-automation Bot moved this from In Review to Approved in workers-sdk Feb 9, 2026
@petebacondarwin petebacondarwin merged commit 961705c into main Feb 9, 2026
37 of 67 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Feb 9, 2026
@petebacondarwin petebacondarwin deleted the fix/4140-pages-project-list-json branch February 9, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🚀 Feature Request: make pages project list return json

4 participants