-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathauto-installer.ts
53 lines (44 loc) · 1.44 KB
/
auto-installer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import * as fs from "fs";
import { Progress, Uri } from "vscode";
import Configuration from "./configuration";
import Github from "./github";
import InstallationManifest from "./installation-manifest";
import Logger from "./logger";
import Notifications from "./notifications";
import Paths from "./paths";
import Release from "./release";
import Zip from "./zip";
namespace AutoInstaller {
export function isInstalledReleaseLatest(
installationDirectoryUri: Uri,
latestRelease: Release.T,
): boolean {
const installationManifest = InstallationManifest.fetch(
installationDirectoryUri,
);
if (installationManifest === undefined) {
return false;
}
return InstallationManifest.isInstalledVersionGreaterThan(
installationManifest,
latestRelease.version,
);
}
export async function install(
progress: Progress<{ message: string }>,
latestRelease: Release.T,
releaseUri: Uri,
) {
progress.report({ message: "Downloading Lexical release" });
const zipBuffer = await Github.downloadZip(latestRelease);
progress.report({ message: "Installing..." });
const zipUri = Paths.getZipUri();
Logger.info(`Writing zip archive to ${zipUri.fsPath}`);
fs.writeFileSync(zipUri.fsPath, zipBuffer, "binary");
await Zip.extract(zipUri, releaseUri, latestRelease.version);
if (Configuration.getAutoInstallUpdateNotification()) {
Notifications.notifyAutoInstallSuccess(latestRelease.version);
}
}
}
export default AutoInstaller;