mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Prompt for arcdata install upon extension activation (fix) (#20167)
* Made prompt when no arcdata upon startup * Changed to NoAzureCLIArcExtError Co-authored-by: Candice Ye <canye@microsoft.com>
This commit is contained in:
@@ -5,9 +5,7 @@
|
|||||||
|
|
||||||
import * as azExt from 'az-ext';
|
import * as azExt from 'az-ext';
|
||||||
import { IAzTool } from './az';
|
import { IAzTool } from './az';
|
||||||
import Logger from './common/logger';
|
|
||||||
import { NoAzureCLIError } from './common/utils';
|
import { NoAzureCLIError } from './common/utils';
|
||||||
import * as loc from './localizedConstants';
|
|
||||||
import { AzToolService } from './services/azToolService';
|
import { AzToolService } from './services/azToolService';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,7 +19,6 @@ export function validateAz(az: IAzTool | undefined) {
|
|||||||
|
|
||||||
export function throwIfNoAz(localAz: IAzTool | undefined): asserts localAz {
|
export function throwIfNoAz(localAz: IAzTool | undefined): asserts localAz {
|
||||||
if (!localAz) {
|
if (!localAz) {
|
||||||
Logger.log(loc.noAzureCLI);
|
|
||||||
throw new NoAzureCLIError();
|
throw new NoAzureCLIError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import * as vscode from 'vscode';
|
|||||||
import { executeCommand, executeSudoCommand, ExitCodeError, ProcessOutput } from './common/childProcess';
|
import { executeCommand, executeSudoCommand, ExitCodeError, ProcessOutput } from './common/childProcess';
|
||||||
import { HttpClient } from './common/httpClient';
|
import { HttpClient } from './common/httpClient';
|
||||||
import Logger from './common/logger';
|
import Logger from './common/logger';
|
||||||
import { AzureCLIArcExtError, NoAzureCLIError, searchForCmd } from './common/utils';
|
import { NoAzureCLIArcExtError, NoAzureCLIError, searchForCmd } from './common/utils';
|
||||||
import { azArcdataInstallKey, azConfigSection, azFound, debugConfigKey, latestAzArcExtensionVersion, azCliInstallKey, azArcFound, azHostname, azUri } from './constants';
|
import { azArcdataInstallKey, azConfigSection, azFound, debugConfigKey, latestAzArcExtensionVersion, azCliInstallKey, azArcFound, azHostname, azUri } from './constants';
|
||||||
import * as loc from './localizedConstants';
|
import * as loc from './localizedConstants';
|
||||||
|
|
||||||
@@ -447,7 +447,7 @@ export async function checkAndInstallAz(userRequested: boolean = false): Promise
|
|||||||
try {
|
try {
|
||||||
return await findAzAndArc(); // find currently installed Az
|
return await findAzAndArc(); // find currently installed Az
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err === AzureCLIArcExtError) {
|
if (err instanceof NoAzureCLIArcExtError) {
|
||||||
// Az found but arcdata extension not found. Prompt user to install it, then check again.
|
// Az found but arcdata extension not found. Prompt user to install it, then check again.
|
||||||
if (await promptToInstallArcdata(userRequested)) {
|
if (await promptToInstallArcdata(userRequested)) {
|
||||||
return await findAzAndArc();
|
return await findAzAndArc();
|
||||||
@@ -478,7 +478,7 @@ export async function findAzAndArc(): Promise<IAzTool> {
|
|||||||
Logger.log(loc.foundExistingAz(await azTool.getPath(), (await azTool.getSemVersionAz()).raw, (await azTool.getSemVersionArc()).raw));
|
Logger.log(loc.foundExistingAz(await azTool.getPath(), (await azTool.getSemVersionAz()).raw, (await azTool.getSemVersionArc()).raw));
|
||||||
return azTool;
|
return azTool;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err === AzureCLIArcExtError) {
|
if (err === NoAzureCLIArcExtError) {
|
||||||
Logger.log(loc.couldNotFindAzArc(err));
|
Logger.log(loc.couldNotFindAzArc(err));
|
||||||
Logger.log(loc.noAzArc);
|
Logger.log(loc.noAzArc);
|
||||||
await vscode.commands.executeCommand('setContext', azArcFound, false); // save a context key that az was not found so that command for installing az is available in commandPalette and that for updating it is no longer available.
|
await vscode.commands.executeCommand('setContext', azArcFound, false); // save a context key that az was not found so that command for installing az is available in commandPalette and that for updating it is no longer available.
|
||||||
@@ -506,7 +506,7 @@ async function findSpecificAzAndArc(): Promise<IAzTool> {
|
|||||||
// if no az has been found. If found, check if az arcdata extension exists.
|
// if no az has been found. If found, check if az arcdata extension exists.
|
||||||
const arcVersion = parseArcExtensionVersion(versionOutput.stdout);
|
const arcVersion = parseArcExtensionVersion(versionOutput.stdout);
|
||||||
if (arcVersion === undefined) {
|
if (arcVersion === undefined) {
|
||||||
throw AzureCLIArcExtError;
|
throw new NoAzureCLIArcExtError;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quietly attempt to update the arcdata extension to the latest. If it is already the latest, then it will not update.
|
// Quietly attempt to update the arcdata extension to the latest. If it is already the latest, then it will not update.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class NoAzureCLIError extends Error implements azExt.ErrorWithLink {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AzureCLIArcExtError extends Error implements azExt.ErrorWithLink {
|
export class NoAzureCLIArcExtError extends Error implements azExt.ErrorWithLink {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(loc.arcdataExtensionNotInstalled);
|
super(loc.arcdataExtensionNotInstalled);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user