mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Get tools service install location from extensions (#16796)
* Get STS install location from extensions * Update error
This commit is contained in:
@@ -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'];
|
const logFiles = ['resourceprovider.log', 'sqltools.log', 'credentialstore.log'];
|
||||||
|
|||||||
4
extensions/mssql/src/mssql.d.ts
vendored
4
extensions/mssql/src/mssql.d.ts
vendored
@@ -24,6 +24,10 @@ export const enum extension {
|
|||||||
* The APIs provided by Mssql extension
|
* The APIs provided by Mssql extension
|
||||||
*/
|
*/
|
||||||
export interface IExtension {
|
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
|
* Gets the object explorer API that supports querying over the connections supported by this extension
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,9 +8,13 @@ import { IExtension, ICmsService, IDacFxService, ISchemaCompareService, MssqlObj
|
|||||||
import * as constants from './constants';
|
import * as constants from './constants';
|
||||||
import { MssqlObjectExplorerNodeProvider } from './objectExplorerNodeProvider/objectExplorerNodeProvider';
|
import { MssqlObjectExplorerNodeProvider } from './objectExplorerNodeProvider/objectExplorerNodeProvider';
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
|
import { SqlToolsServer } from './sqlToolsServer';
|
||||||
|
|
||||||
export function createMssqlApi(context: AppContext): IExtension {
|
export function createMssqlApi(context: AppContext, sqlToolsServer: SqlToolsServer): IExtension {
|
||||||
return {
|
return {
|
||||||
|
get sqlToolsServicePath() {
|
||||||
|
return sqlToolsServer.installDirectory;
|
||||||
|
},
|
||||||
get cmsService() {
|
get cmsService() {
|
||||||
return context.getService<ICmsService>(constants.CmsService);
|
return context.getService<ICmsService>(constants.CmsService);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -35,13 +35,15 @@ export class SqlToolsServer {
|
|||||||
private client: SqlOpsDataClient;
|
private client: SqlOpsDataClient;
|
||||||
private config: IConfig;
|
private config: IConfig;
|
||||||
private disposables = new Array<{ dispose: () => void }>();
|
private disposables = new Array<{ dispose: () => void }>();
|
||||||
|
public installDirectory: string | undefined = undefined;
|
||||||
|
|
||||||
public async start(context: AppContext): Promise<SqlOpsDataClient> {
|
public async start(context: AppContext): Promise<SqlOpsDataClient> {
|
||||||
try {
|
try {
|
||||||
const installationStart = Date.now();
|
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();
|
const installationComplete = Date.now();
|
||||||
let serverOptions = generateServerOptions(context.extensionContext.logPath, path);
|
let serverOptions = generateServerOptions(context.extensionContext.logPath, serverPath);
|
||||||
let clientOptions = getClientOptions(context);
|
let clientOptions = getClientOptions(context);
|
||||||
this.client = new SqlOpsDataClient(Constants.serviceName, serverOptions, clientOptions);
|
this.client = new SqlOpsDataClient(Constants.serviceName, serverOptions, clientOptions);
|
||||||
const processStart = Date.now();
|
const processStart = Date.now();
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ export function invalidInput(input: string) { return localize('invalidInput', "I
|
|||||||
export function invalidProjectPropertyValue(propertyName: string) { return localize('invalidPropertyValue', "Invalid value specified for the property '{0}' in .sqlproj file", propertyName); }
|
export function invalidProjectPropertyValue(propertyName: string) { return localize('invalidPropertyValue', "Invalid value specified for the property '{0}' in .sqlproj file", propertyName); }
|
||||||
export function unableToCreatePublishConnection(input: string) { return localize('unableToCreatePublishConnection', "Unable to construct connection: {0}", input); }
|
export function unableToCreatePublishConnection(input: string) { return localize('unableToCreatePublishConnection', "Unable to construct connection: {0}", input); }
|
||||||
export function circularProjectReference(project1: string, project2: string) { return localize('cicularProjectReference', "Circular reference from project {0} to project {1}", project1, project2); }
|
export function circularProjectReference(project1: string, project2: string) { return localize('cicularProjectReference', "Circular reference from project {0} to project {1}", project1, project2); }
|
||||||
export function sqlToolsServiceNotFound(sqlToolsServiceDir: string) { return localize('mssqlNotFound', "Could not get SQL Tools Service install location at {0}", sqlToolsServiceDir); }
|
export function errorFindingBuildFilesLocation(err: any) { return localize('errorFindingBuildFilesLocation', "Error finding build files location: {0}", utils.getErrorMessage(err)); }
|
||||||
export function projBuildFailed(errorMessage: string) { return localize('projBuildFailed', "Build failed. Check output pane for more details. {0}", errorMessage); }
|
export function projBuildFailed(errorMessage: string) { return localize('projBuildFailed', "Build failed. Check output pane for more details. {0}", errorMessage); }
|
||||||
export function unexpectedProjectContext(uri: string) { return localize('unexpectedProjectContext', "Unable to establish project context. Command invoked from unexpected location: {0}", uri); }
|
export function unexpectedProjectContext(uri: string) { return localize('unexpectedProjectContext', "Unable to establish project context. Command invoked from unexpected location: {0}", uri); }
|
||||||
export function unableToPerformAction(action: string, uri: string) { return localize('unableToPerformAction', "Unable to locate '{0}' target: '{1}'", action, uri); }
|
export function unableToPerformAction(action: string, uri: string) { return localize('unableToPerformAction', "Unable to locate '{0}' target: '{1}'", action, uri); }
|
||||||
|
|||||||
@@ -5,10 +5,9 @@
|
|||||||
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as os from 'os';
|
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import * as utils from '../common/utils';
|
import * as utils from '../common/utils';
|
||||||
import { sqlToolsServiceNotFound } from '../common/constants';
|
import { errorFindingBuildFilesLocation } from '../common/constants';
|
||||||
import * as mssql from '../../../mssql/src/mssql';
|
import * as mssql from '../../../mssql/src/mssql';
|
||||||
import * as vscodeMssql from 'vscode-mssql';
|
import * as vscodeMssql from 'vscode-mssql';
|
||||||
import * as sqldbproj from 'sqldbproj';
|
import * as sqldbproj from 'sqldbproj';
|
||||||
@@ -66,41 +65,15 @@ export class BuildHelper {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
private async getBuildDirPathFromMssqlTools(): Promise<string> {
|
private async getBuildDirPathFromMssqlTools(): Promise<string> {
|
||||||
let mssqlConfigDir = '';
|
try {
|
||||||
if (utils.getAzdataApi()) {
|
|
||||||
mssqlConfigDir = vscode.extensions.getExtension(mssql.extension.name)?.extensionPath ?? '';
|
|
||||||
} else {
|
|
||||||
// VS Code MSSQL extension has its tools service config in a slightly different spot
|
|
||||||
mssqlConfigDir = path.join(vscode.extensions.getExtension(vscodeMssql.extension.name)?.extensionPath ?? '', 'out', 'src');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await utils.exists(path.join(mssqlConfigDir, 'config.json'))) {
|
|
||||||
const rawConfig = await fs.readFile(path.join(mssqlConfigDir, 'config.json'));
|
|
||||||
const config = JSON.parse(rawConfig.toString());
|
|
||||||
let installDir = '';
|
|
||||||
if (utils.getAzdataApi()) {
|
if (utils.getAzdataApi()) {
|
||||||
installDir = config.installDirectory?.replace('{#version#}', config.version).replace('{#platform#}', this.getPlatform());
|
return (vscode.extensions.getExtension(mssql.extension.name)?.exports as mssql.IExtension).sqlToolsServicePath;
|
||||||
} else {
|
} else {
|
||||||
// VS Code MSSQL extension has a slightly different format for its config.json
|
return (vscode.extensions.getExtension(vscodeMssql.extension.name)?.exports as vscodeMssql.IExtension).sqlToolsServicePath;
|
||||||
installDir = config.service?.installDir?.replace('{#version#}', config.service.version).replace('{#platform#}', this.getPlatform());
|
|
||||||
if (installDir) {
|
|
||||||
// The path to the install location is relative to one directory above where the config is so account for that here
|
|
||||||
installDir = path.join('..', installDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (installDir) {
|
|
||||||
return path.join(mssqlConfigDir, installDir);
|
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(errorFindingBuildFilesLocation(err));
|
||||||
}
|
}
|
||||||
throw new Error(sqlToolsServiceNotFound(mssqlConfigDir));
|
|
||||||
}
|
|
||||||
|
|
||||||
private getPlatform(): string {
|
|
||||||
return os.platform() === 'win32' ? 'Windows' :
|
|
||||||
os.platform() === 'darwin' ? 'OSX' :
|
|
||||||
os.platform() === 'linux' ? 'Linux' :
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public get extensionBuildDirPath(): string {
|
public get extensionBuildDirPath(): string {
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ declare module 'vscode-mssql' {
|
|||||||
*/
|
*/
|
||||||
export interface IExtension {
|
export interface IExtension {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the root of the SQL Tools Service folder
|
||||||
|
*/
|
||||||
|
readonly sqlToolsServicePath: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for accessing DacFx functionality
|
* Service for accessing DacFx functionality
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user