A fully-functioning CLI with tunnel capabilities requires product-specific
configuration that is not included in the OSS. This change has the CLI's build
script automatically look for a peer `vscode-distro` folder and, in a debug
build, set its build variables based on that.
It also works to set correct variables if vscode-distro is not found, based on
the OSS product.json (though this is not sufficient to run a fully fledged
tunnel.)
Fixes https://github.com/microsoft/vscode-cli/issues/563
If a new tunnel `--name` was provided but the existing tunnel was deleted,
the CLI would error out with a lookup failed message. Instead it now
recreates it like it normally would.
Adds support for running the tunnel as a service on macOS via launchservices.
It also hooks up observability (`code tunnel service log`) on macOS and Linux.
On macOS--and later Windows, hence the manual implementation of `tail`--it
saves output to a log file and watches it. On Linux, it simply delegates to
journalctl.
The "tailing" is implemented via simple polling of the file size. I didn't want
to pull in a giant set of dependencies for inotify/kqueue/etc just for this use
case; performance when polling a single log file is not a huge concern.
systemd, like most 'modern' linux components, has a nice dbus API. This uses
that API to register the tunnel as a service of the calling user.
The dbus dependency is temporarily duplicated, until secret-service 3 is
released, where they update to the latest version (should be a week or two).
For https://github.com/microsoft/vscode-cli/issues/367. Next up, macOS,
then it's done :)
This is the CLI side of enabling compression of servermsg's sent
over the socket. It is feature-detected by the CLI sending
protocolVersion=2. If present, the consumer can request compression by
passing `compress:true` when setting up the server.
In this mode, servermsg's are an inflate/deflate stream. Not a ton of
code here, but was lots of fun tweaking to get it right :)
Fixes https://github.com/microsoft/vscode/issues/163688
Implements an automatic local download fallback, similar to SSH
(cc @roblourens). If the initial download results in an error, either
in making the request or a 5xx, it'll try to fall back to making the
request locally and streaming it over the tunnel.
This abstracts the request client behing a "SimpleHttp" trait which
either uses to the native reqwest or uses the 'delegated' mode over the
socket.
Previously the control server could only handle a single request at a
time. To enable local download mode, this needs to change as the client
will be sending data to the CLI as it downloads the vscode server zip.
This does that. There's a little mess since things that async handlers
need to use are cloned out of the previously unified "context" (we
could try and clone the whole context each time, but this is more work
than needed.) We still keep the fast things as "blocking" since that
avoids the need for clones and separate tasks.
The standalone CLI should detect and fall back to using and
system-installed VS Code instance, rather than trying to download zips
and manage its own VS Code instances.
There are three approaches used for discovery:
- On Windows, we can easily and quickly read the register to find
installed versions based on their app ID.
- On macOS, we initially look in `/Applications` and fall back to the
slow `system_profiler` command to list app .app's if that fails.
- On Linux, we just look in the PATH. I believe all Linux installers
(snap, dep, rpm) automatically add VS Code to the user's PATH.
Failing this, the user can also manually specify their installation dir,
using the command `code version use stable --install-dir /path/to/vscode`.
Fixes#164159
- Start separating a "standalone" CLI. This is a little awkward with clap-
derive, but I got it working. Detection of whether the CLI _is_
standalone is still todo.
- Remove the old ad-hoc update code for code-server, and use the update
service instead.
- Fix some of the "permission denied" errors people got while updating
before. We need to rename the old running binary, not just overwrite it.