mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-26 17:23:15 -05:00
allow registering options source providers to resource-deployment (#12712)
* first draft * compile fixes * uncomment code * waitForAzdataToolDisovery added to azdata api * missed change in last commit * remove switchReturn * contributeOptionsSource renamed * remove switchReturn reference * create optionSourceService * azdataTool usage more reliable * package.json fixes and cleanup * cleanup * revert 4831a6e6b8b08684488b2c9e18092fa252e3057f * pr feedback * pr feedback * pr feedback * cleanup * cleanup * fix eulaAccepted check * fix whitespade in doc comments.
This commit is contained in:
@@ -10,7 +10,7 @@ import { isString } from 'util';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { NotebookPathInfo } from '../interfaces';
|
||||
import { getDateTimeString, getErrorMessage } from '../utils';
|
||||
import { getDateTimeString, getErrorMessage } from '../common/utils';
|
||||
import { IPlatformService } from './platformService';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as rd from 'resource-deployment';
|
||||
import * as loc from '../localizedConstants';
|
||||
|
||||
class OptionsSourcesService {
|
||||
private _optionsSourceStore = new Map<string, rd.IOptionsSourceProvider>();
|
||||
registerOptionsSourceProvider(provider: rd.IOptionsSourceProvider): void {
|
||||
if (this._optionsSourceStore.has(provider.optionsSourceId)) {
|
||||
throw new Error(loc.optionsSourceAlreadyDefined(provider.optionsSourceId));
|
||||
}
|
||||
this._optionsSourceStore.set(provider.optionsSourceId, provider);
|
||||
}
|
||||
|
||||
getOptionsSource(optionsSourceProviderId: string): rd.IOptionsSourceProvider {
|
||||
const optionsSource = this._optionsSourceStore.get(optionsSourceProviderId);
|
||||
if (optionsSource === undefined) {
|
||||
throw new Error(loc.noOptionsSourceDefined(optionsSourceProviderId));
|
||||
}
|
||||
return optionsSource;
|
||||
}
|
||||
}
|
||||
|
||||
export const optionsSourcesService = new OptionsSourcesService();
|
||||
@@ -10,7 +10,7 @@ import * as sudo from 'sudo-prompt';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { OsDistribution, OsRelease } from '../interfaces';
|
||||
import { getErrorMessage } from '../utils';
|
||||
import { getErrorMessage } from '../common/utils';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
const extensionOutputChannel = localize('resourceDeployment.outputChannel', "Deployments");
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as azdataExt from 'azdata-ext';
|
||||
import { EOL } from 'os';
|
||||
import * as path from 'path';
|
||||
import { SemVer } from 'semver';
|
||||
@@ -9,10 +10,9 @@ import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { AzdataInstallLocationKey, DeploymentConfigurationKey } from '../../constants';
|
||||
import { Command, OsDistribution, ToolStatus, ToolType } from '../../interfaces';
|
||||
import { apiService } from '../apiService';
|
||||
import * as loc from '../../localizedConstants';
|
||||
import { IPlatformService } from '../platformService';
|
||||
import { dependencyType, ToolBase } from './toolBase';
|
||||
import * as loc from '../../localizedConstants';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
export const AzdataToolName = 'azdata';
|
||||
@@ -21,6 +21,7 @@ const macInstallationRoot = '/usr/local/bin';
|
||||
const debianInstallationRoot = '/usr/local/bin';
|
||||
|
||||
export class AzdataTool extends ToolBase {
|
||||
private azdataApi!: azdataExt.IExtension;
|
||||
constructor(platformService: IPlatformService) {
|
||||
super(platformService);
|
||||
}
|
||||
@@ -46,7 +47,7 @@ export class AzdataTool extends ToolBase {
|
||||
}
|
||||
|
||||
public isEulaAccepted(): boolean {
|
||||
if (apiService.azdataApi.isEulaAccepted()) {
|
||||
if (this.azdataApi.isEulaAccepted()) {
|
||||
return true;
|
||||
} else {
|
||||
this.setStatusDescription(loc.azdataEulaNotAccepted);
|
||||
@@ -55,7 +56,7 @@ export class AzdataTool extends ToolBase {
|
||||
}
|
||||
|
||||
public async promptForEula(): Promise<boolean> {
|
||||
const eulaAccepted = await apiService.azdataApi.promptForEula();
|
||||
const eulaAccepted = await this.azdataApi.promptForEula();
|
||||
if (!eulaAccepted) {
|
||||
this.setStatusDescription(loc.azdataEulaDeclined);
|
||||
}
|
||||
@@ -80,15 +81,16 @@ export class AzdataTool extends ToolBase {
|
||||
* updates the version and status for the tool.
|
||||
*/
|
||||
protected async updateVersionAndStatus(): Promise<void> {
|
||||
this.azdataApi = await vscode.extensions.getExtension(azdataExt.extension.name)?.activate();
|
||||
this.setStatusDescription('');
|
||||
await this.addInstallationSearchPathsToSystemPath();
|
||||
|
||||
const commandOutput = await apiService.azdataApi.azdata.version();
|
||||
this.version = apiService.azdataApi.azdata.getSemVersion();
|
||||
const commandOutput = await this.azdataApi.azdata.version();
|
||||
this.version = await this.azdataApi.azdata.getSemVersion();
|
||||
if (this.version) {
|
||||
if (this.autoInstallSupported) {
|
||||
// set the installationPath
|
||||
this.setInstallationPathOrAdditionalInformation(apiService.azdataApi.azdata.getPath());
|
||||
this.setInstallationPathOrAdditionalInformation(await this.azdataApi.azdata.getPath());
|
||||
}
|
||||
this.setStatus(ToolStatus.Installed);
|
||||
}
|
||||
@@ -99,8 +101,8 @@ export class AzdataTool extends ToolBase {
|
||||
}
|
||||
}
|
||||
|
||||
protected getVersionFromOutput(output: string): SemVer | undefined {
|
||||
return apiService.azdataApi.azdata.getSemVersion();
|
||||
protected getVersionFromOutput(output: string): SemVer | Promise<SemVer> | undefined {
|
||||
return this.azdataApi.azdata.getSemVersion();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { EOL } from 'os';
|
||||
import * as path from 'path';
|
||||
import { SemVer, compare as SemVerCompare } from 'semver';
|
||||
import { compare as SemVerCompare, SemVer } from 'semver';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { getErrorMessage } from '../../common/utils';
|
||||
import { Command, ITool, OsDistribution, ToolStatus, ToolType } from '../../interfaces';
|
||||
import { getErrorMessage } from '../../utils';
|
||||
import { IPlatformService } from '../platformService';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
@@ -52,7 +52,7 @@ export abstract class ToolBase implements ITool {
|
||||
protected abstract readonly allInstallationCommands: Map<OsDistribution, Command[]>;
|
||||
protected readonly dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>();
|
||||
|
||||
protected abstract getVersionFromOutput(output: string): SemVer | undefined;
|
||||
protected abstract getVersionFromOutput(output: string): SemVer | Promise<SemVer> | undefined;
|
||||
protected readonly _onDidUpdateData = new vscode.EventEmitter<ITool>();
|
||||
protected readonly uninstallCommand?: string;
|
||||
|
||||
@@ -274,7 +274,7 @@ export abstract class ToolBase implements ITool {
|
||||
ignoreError: true
|
||||
},
|
||||
);
|
||||
this.version = this.getVersionFromOutput(commandOutput);
|
||||
this.version = await this.getVersionFromOutput(commandOutput);
|
||||
if (this.version) {
|
||||
if (this.autoInstallSupported) {
|
||||
// discover and set the installationPath
|
||||
|
||||
Reference in New Issue
Block a user