teambit / bit

A build system for development of composable software.
https://bit.dev
Other
17.87k stars 927 forks source link

feat, introduce "--stream" for --json commands to print loader as json strings #9276

Closed davidfirst closed 10 hours ago

davidfirst commented 11 hours ago

This can be used by any command by simply adding --stream to the options prop. It's useful for processes that run bit commands with --json and need to show some feedback to the user during the command run. Normally, --json disables the loader to keep the output a valid JSON. When adding this --stream, the loader is printed in JSON format with a new line. The consuming process knows to consume one line at a time. The final output includes end: true to indicate this is the last output of the command.

Output example:

{"loader":"loading 3 component(s)"}
{"loader":"linking components"}
{"loader":"loading 3 component(s)"}
{"loader":"deduping dependencies for installation"}
{"loader":"loading 3 component(s)"}
{"loader":"running pre install subscribers"}
{"loader":"running post install subscribers"}
{"loader":"loading 3 component(s)"}
{"loader":"compiling components"}
{"loader":"loading 3 component(s)"}
{"snappedIds":["7b0e2371-remote/compa@0.0.1","7b0e2371-remote/compb@0.0.1","7b0e2371-remote/compc@0.0.1"],"end":true}