Get tools service install location from extensions (#16796)

* Get STS install location from extensions

* Update error
This commit is contained in:
Charles Gagnon
2021-08-17 13:48:22 -07:00
committed by GitHub
parent f2499fb01b
commit 6b1cc85c9a
7 changed files with 26 additions and 38 deletions

View File

@@ -104,7 +104,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IExten
}
});
return createMssqlApi(appContext);
return createMssqlApi(appContext, server);
}
const logFiles = ['resourceprovider.log', 'sqltools.log', 'credentialstore.log'];

View File

@@ -24,6 +24,10 @@ export const enum extension {
* The APIs provided by Mssql extension
*/
export interface IExtension {
/**
* Path to the root of the SQL Tools Service folder
*/
readonly sqlToolsServicePath: string;
/**
* Gets the object explorer API that supports querying over the connections supported by this extension
*

View File

@@ -8,9 +8,13 @@ import { IExtension, ICmsService, IDacFxService, ISchemaCompareService, MssqlObj
import * as constants from './constants';
import { MssqlObjectExplorerNodeProvider } from './objectExplorerNodeProvider/objectExplorerNodeProvider';
import * as azdata from 'azdata';
import { SqlToolsServer } from './sqlToolsServer';
export function createMssqlApi(context: AppContext): IExtension {
export function createMssqlApi(context: AppContext, sqlToolsServer: SqlToolsServer): IExtension {
return {
get sqlToolsServicePath() {
return sqlToolsServer.installDirectory;
},
get cmsService() {
return context.getService<ICmsService>(constants.CmsService);
},

View File

@@ -35,13 +35,15 @@ export class SqlToolsServer {
private client: SqlOpsDataClient;
private config: IConfig;
private disposables = new Array<{ dispose: () => void }>();
public installDirectory: string | undefined = undefined;
public async start(context: AppContext): Promise<SqlOpsDataClient> {
try {
const installationStart = Date.now();
const path = await this.download(context);
const serverPath = await this.download(context);
this.installDirectory = path.dirname(serverPath);
const installationComplete = Date.now();
let serverOptions = generateServerOptions(context.extensionContext.logPath, path);
let serverOptions = generateServerOptions(context.extensionContext.logPath, serverPath);
let clientOptions = getClientOptions(context);
this.client = new SqlOpsDataClient(Constants.serviceName, serverOptions, clientOptions);
const processStart = Date.now();