Update whoIsActive extension to use azdata (#7287)

* Update whoIsActive extension to use azdata

* Change path

* Update package-lock
This commit is contained in:
Charles Gagnon
2019-09-19 11:38:18 -07:00
committed by GitHub
parent a584aca969
commit 6a136854b0
9 changed files with 820 additions and 478 deletions

View File

@@ -67,6 +67,7 @@ const indentationFilter = [
// except multiple specific files // except multiple specific files
'!**/package.json', '!**/package.json',
'!**/package-lock.json', // {{SQL CARBON EDIT}}
'!**/yarn.lock', '!**/yarn.lock',
'!**/yarn-error.log', '!**/yarn-error.log',

View File

@@ -6,4 +6,4 @@ node_modules
.DS_Store .DS_Store
.idea .idea
test-reports/** test-reports/**
typings/sqlops.proposed.d.ts typings/azdata.d.ts

View File

@@ -9,7 +9,7 @@
// - open Azure Data Studio // - open Azure Data Studio
// - run the command "Install 'azuredatastudio' command in PATH" // - run the command "Install 'azuredatastudio' command in PATH"
{ {
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
@@ -21,33 +21,33 @@
"--extensionDevelopmentPath=${workspaceFolder}" "--extensionDevelopmentPath=${workspaceFolder}"
] ]
}, },
{ {
"type": "node", "type": "node",
"request": "attach", "request": "attach",
"name": "Attach to Ops Studio", "name": "Attach to Azure Data Studio",
"protocol": "inspector", "protocol": "inspector",
"port": 5870, "port": 5870,
"restart": true, "restart": true,
"sourceMaps": true, "sourceMaps": true,
"outFiles": [ "outFiles": [
"${workspaceRoot}/out/**/*.js" "${workspaceRoot}/out/**/*.js"
], ],
"preLaunchTask": "", "preLaunchTask": "",
"timeout": 25000 "timeout": 25000
}, },
{ {
"name": "Debug in enlistment", "name": "Debug in enlistment",
"type": "sqlopsExtensionHost", "type": "azuredatastudioExtensionHost",
"request": "launch", "request": "launch",
"windows": { "windows": {
"runtimeExecutable": "${workspaceFolder}/../../scripts/sql.bat" "runtimeExecutable": "${workspaceFolder}/../../scripts/sql.bat"
}, },
"osx": { "osx": {
"runtimeExecutable": "${workspaceFolder}/../../scripts/sql.sh" "runtimeExecutable": "${workspaceFolder}/../../scripts/sql.sh"
}, },
"linux": { "linux": {
"runtimeExecutable": "${workspaceFolder}/../../scripts/sql.sh" "runtimeExecutable": "${workspaceFolder}/../../scripts/sql.sh"
}, },
"args": [ "args": [
"--extensionDevelopmentPath=${workspaceFolder}" "--extensionDevelopmentPath=${workspaceFolder}"
], ],

File diff suppressed because it is too large Load Diff

View File

@@ -2,12 +2,12 @@
"name": "whoisactive", "name": "whoisactive",
"displayName": "whoisactive", "displayName": "whoisactive",
"description": "sp_whoisactive for Azure Data Studio", "description": "sp_whoisactive for Azure Data Studio",
"version": "0.1.1", "version": "0.1.2",
"publisher": "Microsoft", "publisher": "Microsoft",
"preview": true, "preview": true,
"engines": { "engines": {
"vscode": "^1.26.0", "vscode": "^1.26.0",
"azdata": "*" "azdata": "^1.11.0"
}, },
"icon": "images/sqlserver.png", "icon": "images/sqlserver.png",
"license": "SEE LICENSE IN LICENSE.txt", "license": "SEE LICENSE IN LICENSE.txt",
@@ -241,17 +241,17 @@
"compile": "gulp compile", "compile": "gulp compile",
"watch": "gulp watch", "watch": "gulp watch",
"typings": "gulp copytypings", "typings": "gulp copytypings",
"postinstall": "node ./node_modules/vscode/bin/install && node ./node_modules/sqlops/bin/install && gulp copytypings" "postinstall": "node ./node_modules/vscode/bin/install && node ./node_modules/azdata/bin/install && gulp copytypings"
}, },
"dependencies": { "dependencies": {
"fs-extra": "^5.0.0", "fs-extra": "^5.0.0",
"handlebars": "^4.0.11", "handlebars": "^4.0.11",
"openurl": "^1.1.1", "openurl": "^1.1.1"
"sqlops": "github:anthonydresser/sqlops-extension-sqlops"
}, },
"devDependencies": { "devDependencies": {
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",
"@types/node": "^7.0.43", "@types/node": "^7.0.43",
"azdata": "github:microsoft/azdata-extension-azdata",
"child-process-promise": "^2.2.1", "child-process-promise": "^2.2.1",
"del": "^3.0.0", "del": "^3.0.0",
"gulp": "^4.0.0", "gulp": "^4.0.0",

View File

@@ -1,4 +1,3 @@
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
@@ -9,18 +8,18 @@
import * as vscode from 'vscode'; import * as vscode from 'vscode';
export default abstract class ControllerBase implements vscode.Disposable { export default abstract class ControllerBase implements vscode.Disposable {
protected _context: vscode.ExtensionContext; protected _context: vscode.ExtensionContext;
public constructor(context: vscode.ExtensionContext) { public constructor(context: vscode.ExtensionContext) {
this._context = context; this._context = context;
} }
abstract activate(): Promise<boolean>; abstract activate(): Promise<boolean>;
abstract deactivate(): void; abstract deactivate(): void;
public dispose(): void { public dispose(): void {
this.deactivate(); this.deactivate();
} }
} }

View File

@@ -5,7 +5,7 @@
'use strict'; 'use strict';
import * as sqlops from 'sqlops'; import * as azdata from 'azdata';
import * as Utils from '../utils'; import * as Utils from '../utils';
import ControllerBase from './controllerBase'; import ControllerBase from './controllerBase';
import * as fs from 'fs'; import * as fs from 'fs';
@@ -19,35 +19,35 @@ import * as openurl from 'openurl';
*/ */
export default class MainController extends ControllerBase { export default class MainController extends ControllerBase {
public apiWrapper; public apiWrapper;
// PUBLIC METHODS ////////////////////////////////////////////////////// // PUBLIC METHODS //////////////////////////////////////////////////////
/** /**
* Deactivates the extension * Deactivates the extension
*/ */
public deactivate(): void { public deactivate(): void {
Utils.logDebug('Main controller deactivated'); Utils.logDebug('Main controller deactivated');
} }
public activate(): Promise<boolean> { public activate(): Promise<boolean> {
sqlops.tasks.registerTask('sp_whoisactive.install', e => this.openurl('http://whoisactive.com/downloads/')); azdata.tasks.registerTask('sp_whoisactive.install', e => this.openurl('http://whoisactive.com/downloads/'));
sqlops.tasks.registerTask('sp_whoisactive.documentation', e => this.openurl('http://whoisactive.com/docs/')); azdata.tasks.registerTask('sp_whoisactive.documentation', e => this.openurl('http://whoisactive.com/docs/'));
sqlops.tasks.registerTask('sp_whoisactive.findBlockLeaders', e => this.onExecute(e, 'findBlockLeaders.sql')); azdata.tasks.registerTask('sp_whoisactive.findBlockLeaders', e => this.onExecute(e, 'findBlockLeaders.sql'));
sqlops.tasks.registerTask('sp_whoisactive.getPlans', e => this.onExecute(e, 'getPlans.sql')); azdata.tasks.registerTask('sp_whoisactive.getPlans', e => this.onExecute(e, 'getPlans.sql'));
return Promise.resolve(true); return Promise.resolve(true);
} }
private openurl(link: string): void { private openurl(link: string): void {
openurl.open(link); openurl.open(link);
} }
private onExecute(connection: sqlops.IConnectionProfile, fileName: string): void { private onExecute(connection: azdata.IConnectionProfile, fileName: string): void {
let sqlContent = fs.readFileSync(path.join(__dirname, '..', 'sql', fileName)).toString(); let sqlContent = fs.readFileSync(path.join(__dirname, '..', 'sql', fileName)).toString();
vscode.workspace.openTextDocument({language: 'sql', content: sqlContent}).then(doc => { vscode.workspace.openTextDocument({language: 'sql', content: sqlContent}).then(doc => {
vscode.window.showTextDocument(doc, vscode.ViewColumn.Active, false).then(() => { vscode.window.showTextDocument(doc, vscode.ViewColumn.Active, false).then(() => {
let filePath = doc.uri.toString(); let filePath = doc.uri.toString();
sqlops.queryeditor.connect(filePath, connection.id).then(() => sqlops.queryeditor.runQuery(filePath)); azdata.queryeditor.connect(filePath, connection.id).then(() => azdata.queryeditor.runQuery(filePath));
}); });
}); });
} }
} }

View File

@@ -12,6 +12,7 @@ let tslint = require('gulp-tslint');
let ts = require('gulp-typescript'); let ts = require('gulp-typescript');
let cproc = require('child_process'); let cproc = require('child_process');
let os = require('os'); let os = require('os');
let path = require('path');
let config = require('./config'); let config = require('./config');
let tsProject = ts.createProject('tsconfig.json'); let tsProject = ts.createProject('tsconfig.json');
@@ -19,66 +20,66 @@ let tsProject = ts.createProject('tsconfig.json');
// GULP TASKS ////////////////////////////////////////////////////////////// // GULP TASKS //////////////////////////////////////////////////////////////
gulp.task('clean', function(done) { gulp.task('clean', function(done) {
return del('out', done); return del('out', done);
}); });
gulp.task('lint', () => { gulp.task('lint', () => {
return gulp.src([ return gulp.src([
config.paths.project.root + '/src/**/*.ts', config.paths.project.root + '/src/**/*.ts',
config.paths.project.root + '/test/**/*.ts' config.paths.project.root + '/test/**/*.ts'
]) ])
.pipe((tslint({ .pipe((tslint({
formatter: "verbose" formatter: "verbose"
}))) })))
.pipe(tslint.report()); .pipe(tslint.report());
}); });
gulp.task('compile:src', function(done) { gulp.task('compile:src', function(done) {
gulp.src([ gulp.src([
config.paths.project.root + '/src/**/*.sql', config.paths.project.root + '/src/**/*.sql',
config.paths.project.root + '/src/**/*.svg', config.paths.project.root + '/src/**/*.svg',
config.paths.project.root + '/src/**/*.html' config.paths.project.root + '/src/**/*.html'
]).pipe(gulp.dest('out/src/')); ]).pipe(gulp.dest('out/src/'));
let srcFiles = [ let srcFiles = [
config.paths.project.root + '/src/**/*.ts', config.paths.project.root + '/src/**/*.ts',
config.paths.project.root + '/src/**/*.js', config.paths.project.root + '/src/**/*.js',
config.paths.project.root + '/typings/**/*.ts' config.paths.project.root + '/typings/**/*.ts'
]; ];
return gulp.src(srcFiles) return gulp.src(srcFiles)
.pipe(srcmap.init()) .pipe(srcmap.init())
.pipe(tsProject()) .pipe(tsProject())
.on('error', function() { .on('error', function() {
if(process.env.BUILDMACHINE) { if(process.env.BUILDMACHINE) {
done('Failed to compile extension source, see above.'); done('Failed to compile extension source, see above.');
process.exit(1); process.exit(1);
} }
}) })
// TODO: Reinstate localization code // TODO: Reinstate localization code
// .pipe(nls.rewriteLocalizeCalls()) // .pipe(nls.rewriteLocalizeCalls())
// .pipe(nls.createAdditionalLanguageFiles(nls.coreLanguages, config.paths.project.root + '/localization/i18n', undefined, false)) // .pipe(nls.createAdditionalLanguageFiles(nls.coreLanguages, config.paths.project.root + '/localization/i18n', undefined, false))
.pipe(srcmap.write('.', { sourceRoot: function(file) { return file.cwd + '/src'; }})) .pipe(srcmap.write('.', { sourceRoot: function(file) { return file.cwd + '/src'; }}))
.pipe(gulp.dest('out/src/')); .pipe(gulp.dest('out/src/'));
}); });
gulp.task('compile:test', function(done) { gulp.task('compile:test', function(done) {
let srcFiles = [ let srcFiles = [
config.paths.project.root + '/test/**/*.ts', config.paths.project.root + '/test/**/*.ts',
config.paths.project.root + '/typings/**/*.ts' config.paths.project.root + '/typings/**/*.ts'
]; ];
return gulp.src(srcFiles) return gulp.src(srcFiles)
.pipe(srcmap.init()) .pipe(srcmap.init())
.pipe(tsProject()) .pipe(tsProject())
.on('error', function() { .on('error', function() {
if(process.env.BUILDMACHINE) { if(process.env.BUILDMACHINE) {
done('Failed to compile test source, see above.'); done('Failed to compile test source, see above.');
process.exit(1); process.exit(1);
} }
}) })
.pipe(srcmap.write('.', {sourceRoot: function(file) { return file.cwd + '/test'; }})) .pipe(srcmap.write('.', {sourceRoot: function(file) { return file.cwd + '/test'; }}))
.pipe(gulp.dest('out/test/')); .pipe(gulp.dest('out/test/'));
}); });
// COMPOSED GULP TASKS ///////////////////////////////////////////////////// // COMPOSED GULP TASKS /////////////////////////////////////////////////////
@@ -87,37 +88,37 @@ gulp.task("compile", gulp.series("compile:src", "compile:test"));
gulp.task("build", gulp.series("clean", "lint", "compile")); gulp.task("build", gulp.series("clean", "lint", "compile"));
gulp.task("watch", function() { gulp.task("watch", function() {
gulp.watch([config.paths.project.root + '/src/**/*', gulp.watch([config.paths.project.root + '/src/**/*',
config.paths.project.root + '/test/**/*.ts'], config.paths.project.root + '/test/**/*.ts'],
gulp.series('build')) gulp.series('build'));
}); });
gulp.task('test', (done) => { gulp.task('test', (done) => {
let workspace = process.env['WORKSPACE']; let workspace = process.env['WORKSPACE'];
if (!workspace) { if (!workspace) {
workspace = process.cwd(); workspace = process.cwd();
} }
process.env.JUNIT_REPORT_PATH = workspace + '/test-reports/ext_xunit.xml'; process.env.JUNIT_REPORT_PATH = workspace + '/test-reports/ext_xunit.xml';
let azuredatastudioPath = 'azuredatastudio'; let azuredatastudioPath = 'azuredatastudio';
if (process.env['SQLOPS_DEV']) { if (process.env['VSCODE_DEV']) {
let suffix = os.platform === 'win32' ? 'bat' : 'sh'; let suffix = os.platform === 'win32' ? 'bat' : 'sh';
azuredatastudioPath = `${process.env['SQLOPS_DEV']}/scripts/sql-cli.${suffix}`; azuredatastudioPath = `${process.env['VSCODE_DEV']}/scripts/sql-cli.${suffix}`;
} }
console.log(`Using SQLOPS Path of ${azuredatastudioPath}`); console.log(`Using ADS Path of ${azuredatastudioPath}`);
cproc.exec(`${azuredatastudioPath} --extensionDevelopmentPath="${workspace}" --extensionTestsPath="${workspace}/out/test" --verbose`, (error, stdout, stderr) => { cproc.exec(`${azuredatastudioPath} --extensionDevelopmentPath="${workspace}" --extensionTestsPath="${workspace}/out/test" --verbose`, (error, stdout, stderr) => {
if (error) { if (error) {
console.error(`exec error: ${error}`); console.error(`exec error: ${error}`);
process.exit(1); process.exit(1);
} }
console.log(`stdout: ${stdout}`); console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`); console.log(`stderr: ${stderr}`);
done(); done();
}); });
}); });
gulp.task('copytypings', function() { gulp.task('copytypings', function() {
return gulp.src(config.paths.project.root + '/../../src/sql/sqlops.proposed.d.ts') return gulp.src(config.paths.project.root + '/../../src/sql/azdata.d.ts')
.pipe(gulp.dest('typings/')); .pipe(gulp.dest('typings/'));
}); });

View File

@@ -1,123 +1,123 @@
{ {
"rules": { "rules": {
"align": [ "align": [
true, true,
"parameters", "parameters",
"statements" "statements"
], ],
"ban": false, "ban": false,
"class-name": true, "class-name": true,
"comment-format": [ "comment-format": [
true, true,
"check-space" "check-space"
], ],
"curly": true, "curly": true,
"eofline": true, "eofline": true,
"forin": true, "forin": true,
"indent": [ "indent": [
true, true,
"spaces" "tabs"
], ],
"interface-name": true, "interface-name": true,
"jsdoc-format": true, "jsdoc-format": true,
"label-position": true, "label-position": true,
"label-undefined": true, "label-undefined": true,
"max-line-length": [ "max-line-length": [
true, true,
160 160
], ],
"member-access": false, "member-access": false,
"member-ordering": false, "member-ordering": false,
"no-any": false, "no-any": false,
"no-arg": true, "no-arg": true,
"no-bitwise": true, "no-bitwise": true,
"no-conditional-assignment": true, "no-conditional-assignment": true,
"no-consecutive-blank-lines": false, "no-consecutive-blank-lines": false,
"no-console": [ "no-console": [
true, true,
"debug", "debug",
"info", "info",
"time", "time",
"timeEnd", "timeEnd",
"trace" "trace"
], ],
"no-construct": true, "no-construct": true,
"no-constructor-vars": false, "no-constructor-vars": false,
"no-debugger": true, "no-debugger": true,
"no-duplicate-key": true, "no-duplicate-key": true,
"no-duplicate-variable": true, "no-duplicate-variable": true,
"no-empty": true, "no-empty": true,
"no-eval": true, "no-eval": true,
"no-inferrable-types": false, "no-inferrable-types": false,
"no-internal-module": true, "no-internal-module": true,
"no-null-keyword": true, "no-null-keyword": true,
"no-require-imports": false, "no-require-imports": false,
"no-shadowed-variable": true, "no-shadowed-variable": true,
"no-string-literal": false, "no-string-literal": false,
"no-switch-case-fall-through": false, "no-switch-case-fall-through": false,
"no-trailing-whitespace": true, "no-trailing-whitespace": true,
"no-unreachable": true, "no-unreachable": true,
"no-unused-expression": false, "no-unused-expression": false,
"no-unused-variable": true, "no-unused-variable": true,
"no-use-before-declare": true, "no-use-before-declare": true,
"no-var-keyword": true, "no-var-keyword": true,
"no-var-requires": false, "no-var-requires": false,
"object-literal-sort-keys": false, "object-literal-sort-keys": false,
"one-line": [ "one-line": [
true, true,
"check-open-brace", "check-open-brace",
"check-catch", "check-catch",
"check-else", "check-else",
"check-finally", "check-finally",
"check-whitespace" "check-whitespace"
], ],
"quotemark": [ "quotemark": [
true, true,
"single", "single",
"avoid-escape" "avoid-escape"
], ],
"radix": true, "radix": true,
"semicolon": true, "semicolon": true,
"switch-default": true, "switch-default": true,
"trailing-comma": [ "trailing-comma": [
true, true,
{ {
"multiline": "never", "multiline": "never",
"singleline": "never" "singleline": "never"
} }
], ],
"triple-equals": [ "triple-equals": [
true, true,
"allow-null-check" "allow-null-check"
], ],
"typedef": [ "typedef": [
true, true,
"call-signature", "call-signature",
"property-declaration" "property-declaration"
], ],
"typedef-whitespace": [ "typedef-whitespace": [
true, true,
{ {
"call-signature": "nospace", "call-signature": "nospace",
"index-signature": "nospace", "index-signature": "nospace",
"parameter": "nospace", "parameter": "nospace",
"property-declaration": "nospace", "property-declaration": "nospace",
"variable-declaration": "nospace" "variable-declaration": "nospace"
} }
], ],
"use-strict": false, "use-strict": false,
"variable-name": [ "variable-name": [
true, true,
"allow-leading-underscore", "allow-leading-underscore",
"ban-keywords" "ban-keywords"
], ],
"whitespace": [ "whitespace": [
true, true,
"check-branch", "check-branch",
"check-decl", "check-decl",
"check-operator", "check-operator",
"check-separator", "check-separator",
"check-type" "check-type"
] ]
} }
} }