Skip to content

Commit

Permalink
feat: add version notification message
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsonk committed Apr 5, 2021
1 parent 2d573fe commit 694ebd7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
12 changes: 9 additions & 3 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
"vscode": "^1.53.0"
},
"dependencies": {
"semver": "7.3.5",
"vscode-languageclient": "^7.0.0"
},
"devDependencies": {
"@types/semver": "7.3.4",
"@types/vscode": "1.53.0",
"vscode-test": "^1.5.0"
}
Expand Down
19 changes: 18 additions & 1 deletion client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { DenoDebugConfigurationProvider } from "./debug_config_provider";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import * as semver from "semver";
import * as vscode from "vscode";
import {
Executable,
Expand All @@ -20,6 +21,8 @@ import {
ServerOptions,
} from "vscode-languageclient/node";

const SERVER_SEMVER = ">=1.9.0";

interface TsLanguageFeaturesApiV0 {
configurePlugin(
pluginId: string,
Expand Down Expand Up @@ -181,7 +184,14 @@ export async function activate(
getSettings(),
);

showWelcomePage(context);
if (
semver.valid(serverVersion) &&
!semver.satisfies(serverVersion, SERVER_SEMVER)
) {
notifyServerSemver(serverVersion);
} else {
showWelcomePage(context);
}
}

export function deactivate(): Thenable<void> | undefined {
Expand All @@ -193,6 +203,13 @@ export function deactivate(): Thenable<void> | undefined {
});
}

function notifyServerSemver(serverVersion: string) {
return vscode.window.showWarningMessage(
`The version of Deno language server ("${serverVersion}") does not meet the requirements of the extension ("${SERVER_SEMVER}"). Please update Deno and restart.`,
"OK",
);
}

function showWelcomePage(context: vscode.ExtensionContext) {
const welcomeShown = context.globalState.get<boolean>("deno.welcomeShown") ??
false;
Expand Down
5 changes: 4 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 694ebd7

Please sign in to comment.