Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify users if there's a pre-release version available. #11569

Merged
merged 7 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as path from 'path';
import * as vscode from 'vscode';
import { Range } from 'vscode-languageclient';
import * as nls from 'vscode-nls';
import { TargetPopulation } from 'vscode-tas-client';
import { logAndReturn } from '../Utility/Async/returns';
import * as util from '../common';
import { PlatformInformation } from '../platform';
Expand Down Expand Up @@ -1162,3 +1163,36 @@ export function UpdateInsidersAccess(): void {
void vscode.commands.executeCommand("workbench.extensions.installExtension", "ms-vscode.cpptools", { installPreReleaseVersion: true }).then(undefined, logAndReturn.undefined);
}
}

export async function preReleaseCheck(): Promise<void> {
const displayedPreReleasePrompt: PersistentState<boolean> = new PersistentState<boolean>("CPP.displayedPreReleasePrompt", false);

// First we need to make sure the user isn't already on a pre-release version and hasn't dismissed this prompt before.
if (!displayedPreReleasePrompt.Value && util.getCppToolsTargetPopulation() === TargetPopulation.Public) {
// Get the info on the latest version from the marketplace to check if there is a pre-release version available.
const response = await fetch('https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery', {
Colengms marked this conversation as resolved.
Show resolved Hide resolved
method: 'POST',
headers: {
Accept : 'application/json; api-version=3.0-preview',
'Content-Type' : 'application/json'
},
body: '{"filters": [{"criteria": [{"filterType": 7, "value": "ms-vscode.cpptools"}]}], "flags": 529}'
});

const data = await response.json();
const preReleaseAvailable = data.results[0].extensions[0].versions[0].properties.some((e: object) => Object.values(e).includes("Microsoft.VisualStudio.Code.PreRelease"));

// If the user isn't on the pre-release version, but one is available, prompt them to install it.
if (preReleaseAvailable) {
displayedPreReleasePrompt.Value = true;
const message: string = localize("prerelease.message", "A pre-release version of the C/C++ extension is available. Would you like to switch to it?");
const yes: string = localize("yes.button", "Yes");
const no: string = localize("no.button", "No");
void vscode.window.showInformationMessage(message, yes, no).then((selection) => {
if (selection === yes) {
void vscode.commands.executeCommand("workbench.extensions.installExtension", "ms-vscode.cpptools", { installPreReleaseVersion: true }).then(undefined, logAndReturn.undefined);
}
});
}
}
}
1 change: 1 addition & 0 deletions Extension/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<CppToo
util.checkDistro(info);
await checkVsixCompatibility();
LanguageServer.UpdateInsidersAccess();
await LanguageServer.preReleaseCheck();

const settings: CppSettings = new CppSettings((vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) ? vscode.workspace.workspaceFolders[0]?.uri : undefined);
let isOldMacOs: boolean = false;
Expand Down