Rewrite auto-update

Everything now happens in main.ts, in the bootstrap family of
functions. The current flow is:

* check everything only on extension installation.
* if the user is on nightly channel, try to download the nightly
  extension and reload.
* when we install nightly extension, we persist its release id, so
  that we can check if the current release is different.
* if server binary was not downloaded by the current version of the
  extension, redownload it (we persist the version of ext that
  downloaded the server).
This commit is contained in:
Aleksey Kladov 2020-03-17 12:44:31 +01:00
parent f0a1b64d7e
commit fb6e655de8
13 changed files with 270 additions and 696 deletions

View file

@ -4,21 +4,20 @@ import * as lc from 'vscode-languageclient';
import { Config } from './config';
import { createClient } from './client';
import { isRustEditor, RustEditor } from './util';
import { PersistentState } from './persistent_state';
export class Ctx {
private constructor(
readonly config: Config,
readonly state: PersistentState,
private readonly extCtx: vscode.ExtensionContext,
readonly client: lc.LanguageClient
readonly client: lc.LanguageClient,
readonly serverPath: string,
) {
}
static async create(config: Config, state: PersistentState, extCtx: vscode.ExtensionContext, serverPath: string): Promise<Ctx> {
static async create(config: Config, extCtx: vscode.ExtensionContext, serverPath: string): Promise<Ctx> {
const client = await createClient(config, serverPath);
const res = new Ctx(config, state, extCtx, client);
const res = new Ctx(config, extCtx, client, serverPath);
res.pushCleanup(client.start());
await client.onReady();
return res;