workers-sdk
workers-sdk copied to clipboard
🚀 Feature Request: Have something like tail's `format` flag for all wrangler commands
Describe the solution
Related: https://github.com/cloudflare/pages-action/issues/29
It would be great if the CLI supported a global --json flag for producing JSON output for all commands. That would make leveraging the CLI in CI much more painless. The entire aformentioned github action could then be replaced by npx wrangler publish --json | jq ... to grab the relevant output for instance.
Could you give an example of the type of output you'd like to see from npx wrangler publish --json?
For instance, when you run npx wrangler pages deployment list, you get Environment │ Branch │ Source│Deployment │ Status │ Build
For npx wrangler pages publish --json I'd expect the same values (and maybe others too, like number of deployed files, number of functions, function paths, etc. [?!]) in JSON format.
Ah ok, so essentially something like wrangler tail --format json but for publishing? Hmm...
Yes. For all commands so thart the outout can easily be piped into e.g. 'jq' or used in other tools more easily without trying to parse it from human readable output
This would also help with the github action - https://github.com/cloudflare/wrangler-action/issues/77 Currently one has to find the deploy url in the logs of the action.
Contributing to this worthwhile goal: #6570
I stumbled upon parsing code that tediously processes wrangler's terminal output , I agree that it would be wonderful to have the option for JSON output everywhere. Please see: https://github.com/Dhravya/cloudflare-saas-stack/blob/main/scripts/setup.ts#L29 - it would unlock a lot of automatio, bot locally and in the deployment process.
Oh no. I just landed here, because I need to do the same thing–automatically deploy a site and use the deployment URL in another step. I really need to parse the fancy table output..?
Thanks for raising this feature request, and apologies for the delay! Instead of parsing Wrangler's output, we'd recommend using the WRANGLER_OUTPUT_FILE_DIRECTORY environment variable, which when provided to Wrangler when deploying will make Wrangler write an ND-JSON description of the deployment to that directory, including details like deployment & preview URLs. This feature is not currently documented, but was added in: https://github.com/cloudflare/workers-sdk/pull/6383