mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Manual azdata installation/upgrade using Readme (#12023)
* code complete * string fixes * show logger * pr feedback
This commit is contained in:
@@ -12,7 +12,7 @@ import { HttpClient } from './common/httpClient';
|
|||||||
import Logger from './common/logger';
|
import Logger from './common/logger';
|
||||||
import { getErrorMessage, searchForCmd } from './common/utils';
|
import { getErrorMessage, searchForCmd } from './common/utils';
|
||||||
import * as loc from './localizedConstants';
|
import * as loc from './localizedConstants';
|
||||||
import { azdataConfigSection, debugConfigKey } from './constants';
|
import { azdataConfigSection, debugConfigKey, requiredVersion as requiredVersion, installationReadmeUrl } from './constants';
|
||||||
|
|
||||||
export const azdataHostname = 'https://aka.ms';
|
export const azdataHostname = 'https://aka.ms';
|
||||||
export const azdataUri = 'azdata-msi';
|
export const azdataUri = 'azdata-msi';
|
||||||
@@ -228,7 +228,7 @@ export async function upgradeAzdata(): Promise<void> {
|
|||||||
/**
|
/**
|
||||||
* Checks whether a newer version of azdata is available - and if it is prompts the user to download and
|
* Checks whether a newer version of azdata is available - and if it is prompts the user to download and
|
||||||
* install it.
|
* install it.
|
||||||
* @param currentAzdata The current version of azdata to check . This function is a no-o if currentAzdata is undefined.
|
* @param currentAzdata The current version of azdata to check . This function is a no-op if currentAzdata is undefined.
|
||||||
* returns true if an upgrade was performed and false otherwise.
|
* returns true if an upgrade was performed and false otherwise.
|
||||||
*/
|
*/
|
||||||
export async function checkAndUpgradeAzdata(currentAzdata: IAzdataTool | undefined): Promise<boolean> {
|
export async function checkAndUpgradeAzdata(currentAzdata: IAzdataTool | undefined): Promise<boolean> {
|
||||||
@@ -250,6 +250,30 @@ export async function checkAndUpgradeAzdata(currentAzdata: IAzdataTool | undefin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prompts user to install azdata using opened documentation if it is not installed.
|
||||||
|
* If it is installed it verifies that the installed version is correct else it prompts user
|
||||||
|
* to install the correct version using opened documentation
|
||||||
|
* @param currentAzdata The current version of azdata to check.
|
||||||
|
*/
|
||||||
|
export async function manuallyInstallOrUpgradeAzdata(currentAzdata: IAzdataTool | undefined): Promise<void> {
|
||||||
|
if (currentAzdata === undefined) {
|
||||||
|
vscode.window.showInformationMessage(loc.installManually(requiredVersion, installationReadmeUrl), 'Ok');
|
||||||
|
Logger.show();
|
||||||
|
Logger.log(loc.installManually(requiredVersion, installationReadmeUrl));
|
||||||
|
} else {
|
||||||
|
const requiredSemVersion = new SemVer(requiredVersion);
|
||||||
|
if (requiredSemVersion.compare(currentAzdata.cachedVersion) === 0) {
|
||||||
|
return; // if we have the required version then nothing more needs to be eon.
|
||||||
|
}
|
||||||
|
vscode.window.showInformationMessage(loc.installCorrectVersionManually(currentAzdata.cachedVersion.raw, requiredVersion, installationReadmeUrl), 'Ok');
|
||||||
|
Logger.show();
|
||||||
|
Logger.log(loc.installCorrectVersionManually(currentAzdata.cachedVersion.raw, requiredVersion, installationReadmeUrl));
|
||||||
|
}
|
||||||
|
// display the instructions document in a new editor window.
|
||||||
|
// const downloadedFile = await HttpClient.downloadFile(installationInstructionDoc, os.tmpdir());
|
||||||
|
// await vscode.window.showTextDocument(vscode.Uri.parse(downloadedFile));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads the Windows installer and runs it
|
* Downloads the Windows installer and runs it
|
||||||
|
|||||||
@@ -4,5 +4,6 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
export const azdataConfigSection = 'azdata';
|
export const azdataConfigSection = 'azdata';
|
||||||
|
|
||||||
export const debugConfigKey = 'logDebugInfo';
|
export const debugConfigKey = 'logDebugInfo';
|
||||||
|
export const requiredVersion = '20.1.1';
|
||||||
|
export const installationReadmeUrl = 'https://github.com/microsoft/Azure-data-services-on-Azure-Arc/blob/Aug-2020/scenarios-new/001-install-client-tools.md';
|
||||||
|
|||||||
@@ -4,23 +4,16 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import * as azdataExt from 'azdata-ext';
|
import * as azdataExt from 'azdata-ext';
|
||||||
import * as vscode from 'vscode';
|
import { findAzdata, IAzdataTool, manuallyInstallOrUpgradeAzdata } from './azdata';
|
||||||
import { checkAndUpgradeAzdata, findAzdata, IAzdataTool } from './azdata';
|
|
||||||
import * as loc from './localizedConstants';
|
import * as loc from './localizedConstants';
|
||||||
|
|
||||||
let localAzdata: IAzdataTool | undefined = undefined;
|
let localAzdata: IAzdataTool | undefined = undefined;
|
||||||
|
|
||||||
export async function activate(): Promise<azdataExt.IExtension> {
|
export async function activate(): Promise<azdataExt.IExtension> {
|
||||||
localAzdata = await checkForAzdata();
|
localAzdata = await checkForAzdata();
|
||||||
// Don't block on this since we want the extension to finish activating without needing user input
|
// Don't block on this since we want the extension to finish activating without user actions
|
||||||
// upgrade if available and user wants it.
|
manuallyInstallOrUpgradeAzdata(localAzdata)
|
||||||
checkAndUpgradeAzdata(localAzdata)
|
.catch(err => console.log(err));
|
||||||
.then(async upgradePerformed => {
|
|
||||||
if (upgradePerformed) { // If upgrade was performed then find and save the new azdata
|
|
||||||
localAzdata = await findAzdata();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(err => vscode.window.showWarningMessage(loc.upgradeError(err)));
|
|
||||||
return {
|
return {
|
||||||
azdata: {
|
azdata: {
|
||||||
arc: {
|
arc: {
|
||||||
|
|||||||
@@ -36,3 +36,5 @@ export const upgradeError = (err: any): string => localize('azdata.upgradeError'
|
|||||||
export const upgradeCheckSkipped = localize('azdata.updateCheckSkipped', "No check for new azdata version availability performed as azdata was not found to be installed");
|
export const upgradeCheckSkipped = localize('azdata.updateCheckSkipped', "No check for new azdata version availability performed as azdata was not found to be installed");
|
||||||
export const unexpectedExitCode = (code: number, err: string): string => localize('azdata.unexpectedExitCode', "Unexpected exit code from command : {1} ({0})", code, err);
|
export const unexpectedExitCode = (code: number, err: string): string => localize('azdata.unexpectedExitCode', "Unexpected exit code from command : {1} ({0})", code, err);
|
||||||
export const noAzdata = localize('azdata.NoAzdata', "No azdata available");
|
export const noAzdata = localize('azdata.NoAzdata', "No azdata available");
|
||||||
|
export const installManually = (expectedVersion: string, instructionsUrl: string) => localize('azdata.installManually', "azdata is not installed. Version: {0} needs to be installed or some features may not work. Please install it manually using these [instructions]({1}). Restart ADS when installation is done.", expectedVersion, instructionsUrl);
|
||||||
|
export const installCorrectVersionManually = (currentVersion: string, expectedVersion: string, instructionsUrl: string) => localize('azdata.installCorrectVersionManually', "azdata version: {0} is installed, version: {1} needs to be installed or some features may not work. Please uninstall the current version and then install the correct version manually using these [instructions]({2}). Restart ADS when installation is done.", currentVersion, expectedVersion, instructionsUrl);
|
||||||
|
|||||||
Reference in New Issue
Block a user