To enable this, add an env variable BIT_CLI_SERVER=true.
This is how it works:
At bootstrap, bit checks whether the env variable above exists and if so it doesn't invoke "yargs" to parse the arguments in the command line.
Instead, it checks whether there is bit-server running in the background and if so it sends an http request with the cli arguments. Bit server in the background gets the request, parse the arguments, invoke the command and returns the response.
One of the challenges was to show the loader and print messages in between the request and the response. This was eventually done by server-sent events that was sent from the bit-server to the terminal every time the loader got called.
Another challenge was chalk, it recognizes that bit-server spawned from the IDE as a child-process and disables all colors. For the IDE it's good, the messages shown in the IDE interface should be without chalk characters. For the terminal we do want the colors. To workaround this, when a command is executed from the terminal, it sends "isTerminal" to the bit-server, which change the global chalk.enabled to true and change it back to false once the command completed/failed.
To enable this, add an env variable
BIT_CLI_SERVER=true
. This is how it works: At bootstrap, bit checks whether the env variable above exists and if so it doesn't invoke "yargs" to parse the arguments in the command line. Instead, it checks whether there is bit-server running in the background and if so it sends an http request with the cli arguments. Bit server in the background gets the request, parse the arguments, invoke the command and returns the response.One of the challenges was to show the loader and print messages in between the request and the response. This was eventually done by server-sent events that was sent from the bit-server to the terminal every time the loader got called.
Another challenge was
chalk
, it recognizes that bit-server spawned from the IDE as a child-process and disables all colors. For the IDE it's good, the messages shown in the IDE interface should be without chalk characters. For the terminal we do want the colors. To workaround this, when a command is executed from the terminal, it sends "isTerminal" to the bit-server, which change the globalchalk.enabled
totrue
and change it back tofalse
once the command completed/failed.