mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
azdata improvements (#11516)
* azdata improvements * Don't error on sudo command stderr either * Improve output channel logging for commands * Fix childprocess stuff * pr comments * Fix compile errors * more pr comments
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as uuid from 'uuid';
|
||||
import * as vscode from 'vscode';
|
||||
import { HttpClient } from './common/httpClient';
|
||||
import * as loc from './localizedConstants';
|
||||
@@ -32,9 +30,6 @@ export async function findAzdata(outputChannel: vscode.OutputChannel): Promise<I
|
||||
try {
|
||||
let azdata: IAzdata | undefined = undefined;
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
azdata = await findAzdataDarwin(outputChannel);
|
||||
break;
|
||||
case 'win32':
|
||||
azdata = await findAzdataWin32(outputChannel);
|
||||
break;
|
||||
@@ -55,6 +50,7 @@ export async function findAzdata(outputChannel: vscode.OutputChannel): Promise<I
|
||||
*/
|
||||
export async function downloadAndInstallAzdata(outputChannel: vscode.OutputChannel): Promise<void> {
|
||||
const statusDisposable = vscode.window.setStatusBarMessage(loc.installingAzdata);
|
||||
outputChannel.show();
|
||||
outputChannel.appendLine(loc.installingAzdata);
|
||||
try {
|
||||
switch (process.platform) {
|
||||
@@ -62,13 +58,13 @@ export async function downloadAndInstallAzdata(outputChannel: vscode.OutputChann
|
||||
await downloadAndInstallAzdataWin32(outputChannel);
|
||||
break;
|
||||
case 'darwin':
|
||||
await installAzdataDarwin();
|
||||
await installAzdataDarwin(outputChannel);
|
||||
break;
|
||||
case 'linux':
|
||||
await installAzdataLinux(outputChannel);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Platform ${process.platform} is unsupported`);
|
||||
throw new Error(loc.platformUnsupported(process.platform));
|
||||
}
|
||||
} finally {
|
||||
statusDisposable.dispose();
|
||||
@@ -80,17 +76,18 @@ export async function downloadAndInstallAzdata(outputChannel: vscode.OutputChann
|
||||
* @param outputChannel Channel used to display diagnostic information
|
||||
*/
|
||||
async function downloadAndInstallAzdataWin32(outputChannel: vscode.OutputChannel): Promise<void> {
|
||||
const downloadPath = path.join(os.tmpdir(), `azdata-msi-${uuid.v4()}.msi`);
|
||||
outputChannel.appendLine(loc.downloadingTo('azdata-cli.msi', downloadPath));
|
||||
await HttpClient.download(`${azdataHostname}/${azdataUri}`, downloadPath, outputChannel);
|
||||
await executeCommand('msiexec', ['/i', downloadPath], outputChannel);
|
||||
const downloadFolder = os.tmpdir();
|
||||
const downloadedFile = await HttpClient.download(`${azdataHostname}/${azdataUri}`, downloadFolder, outputChannel);
|
||||
await executeCommand('msiexec', ['/qn', '/i', downloadedFile], outputChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs commands to install azdata on MacOS
|
||||
*/
|
||||
async function installAzdataDarwin(): Promise<void> {
|
||||
throw new Error('Not yet implemented');
|
||||
async function installAzdataDarwin(outputChannel: vscode.OutputChannel): Promise<void> {
|
||||
await executeCommand('brew', ['tap', 'microsoft/azdata-cli-release'], outputChannel);
|
||||
await executeCommand('brew', ['update'], outputChannel);
|
||||
await executeCommand('brew', ['install', 'azdata-cli'], outputChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +101,7 @@ async function installAzdataLinux(outputChannel: vscode.OutputChannel): Promise<
|
||||
// Download and install the signing key
|
||||
await executeSudoCommand('curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null', outputChannel);
|
||||
// Add the azdata repository information
|
||||
const release = (await executeCommand('lsb_release', ['-rs'], outputChannel)).trim();
|
||||
const release = (await executeCommand('lsb_release', ['-rs'], outputChannel)).stdout.trim();
|
||||
await executeSudoCommand(`add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/${release}/mssql-server-2019.list)"`, outputChannel);
|
||||
// Update repository information and install azdata
|
||||
await executeSudoCommand('apt-get update', outputChannel);
|
||||
@@ -120,14 +117,6 @@ async function findAzdataWin32(outputChannel: vscode.OutputChannel): Promise<IAz
|
||||
return findSpecificAzdata(await promise, outputChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds azdata specifically on MacOS
|
||||
* @param outputChannel Channel used to display diagnostic information
|
||||
*/
|
||||
async function findAzdataDarwin(_outputChannel: vscode.OutputChannel): Promise<IAzdata> {
|
||||
throw new Error('Not yet implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the version using a known azdata path
|
||||
* @param path The path to the azdata executable
|
||||
@@ -137,7 +126,7 @@ async function findSpecificAzdata(path: string, outputChannel: vscode.OutputChan
|
||||
const versionOutput = await executeCommand(path, ['--version'], outputChannel);
|
||||
return {
|
||||
path: path,
|
||||
version: parseVersion(versionOutput)
|
||||
version: parseVersion(versionOutput.stdout)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user