mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 17:22:55 -05:00
* Build breaks 1 * Build breaks * Build breaks * Build breaks * More build breaks * Build breaks (#2512) * Runtime breaks * Build breaks * Fix dialog location break * Update typescript * Fix ASAR break issue * Unit test breaks * Update distro * Fix breaks in ADO builds (#2513) * Bump to node 16 * Fix hygiene errors * Bump distro * Remove reference to node type * Delete vscode specific extension * Bump to node 16 in CI yaml * Skip integration tests in CI builds (while fixing) * yarn.lock update * Bump moment dependency in remote yarn * Fix drop-down chevron style * Bump to node 16 * Remove playwrite from ci.yaml * Skip building build scripts in hygine check
84 lines
3.1 KiB
TypeScript
84 lines
3.1 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { ExtensionContext } from 'vscode';
|
|
import { startClient, LanguageClientConstructor } from '../jsonClient';
|
|
import { ServerOptions, TransportKind, LanguageClientOptions, LanguageClient } from 'vscode-languageclient/node';
|
|
|
|
import * as fs from 'fs';
|
|
import { xhr, XHRResponse, getErrorStatusDescription } from 'request-light';
|
|
|
|
import TelemetryReporter from 'vscode-extension-telemetry';
|
|
import { RequestService } from '../requests';
|
|
|
|
let telemetry: TelemetryReporter | undefined;
|
|
|
|
// this method is called when vs code is activated
|
|
export function activate(context: ExtensionContext) {
|
|
|
|
const clientPackageJSON = getPackageInfo(context);
|
|
telemetry = new TelemetryReporter(clientPackageJSON.name, clientPackageJSON.version, clientPackageJSON.aiKey);
|
|
|
|
const serverMain = `./server/${clientPackageJSON.main.indexOf('/dist/') !== -1 ? 'dist' : 'out'}/node/jsonServerMain`;
|
|
const serverModule = context.asAbsolutePath(serverMain);
|
|
|
|
// The debug options for the server
|
|
const debugOptions = { execArgv: ['--nolazy', '--inspect=' + (6000 + Math.round(Math.random() * 999))] };
|
|
|
|
// If the extension is launch in debug mode the debug server options are use
|
|
// Otherwise the run options are used
|
|
const serverOptions: ServerOptions = {
|
|
run: { module: serverModule, transport: TransportKind.ipc },
|
|
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
|
|
};
|
|
|
|
const newLanguageClient: LanguageClientConstructor = (id: string, name: string, clientOptions: LanguageClientOptions) => {
|
|
return new LanguageClient(id, name, serverOptions, clientOptions);
|
|
};
|
|
|
|
startClient(context, newLanguageClient, { http: getHTTPRequestService(), telemetry });
|
|
}
|
|
|
|
export function deactivate(): Promise<any> {
|
|
return telemetry ? telemetry.dispose() : Promise.resolve(null);
|
|
}
|
|
|
|
interface IPackageInfo {
|
|
name: string;
|
|
version: string;
|
|
aiKey: string;
|
|
main: string;
|
|
}
|
|
|
|
function getPackageInfo(context: ExtensionContext): IPackageInfo {
|
|
const location = context.asAbsolutePath('./package.json');
|
|
try {
|
|
return JSON.parse(fs.readFileSync(location).toString());
|
|
} catch (e) {
|
|
console.log(`Problems reading ${location}: ${e}`);
|
|
return { name: '', version: '', aiKey: '', main: '' };
|
|
}
|
|
}
|
|
|
|
function getHTTPRequestService(): RequestService {
|
|
return {
|
|
getContent(uri: string, _encoding?: string): Promise<string> {
|
|
const headers = { 'Accept-Encoding': 'gzip, deflate' };
|
|
return xhr({ url: uri, followRedirects: 5, headers }).then(response => {
|
|
return response.responseText;
|
|
}, (error: XHRResponse) => {
|
|
let status = getErrorStatusDescription(error.status);
|
|
if (status && error.responseText) {
|
|
status = `${status}\n${error.responseText.substring(0, 200)}`;
|
|
}
|
|
if (!status) {
|
|
status = error.toString();
|
|
}
|
|
return Promise.reject(status);
|
|
});
|
|
}
|
|
};
|
|
}
|