Skip to content

Commit a435e55

Browse files
committed
option to get release notes or download new FRK
1 parent 00fef4b commit a435e55

3 files changed

Lines changed: 76 additions & 13 deletions

File tree

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,18 @@
3131
"main": "./out/extension",
3232
"contributes": {
3333
"commands": [
34+
{
35+
"command": "extension.OEdiagnostics",
36+
"title": "First Responder Kit: Node Info"
37+
},
3438
{
3539
"command": "extension.sp_blitzversion",
3640
"title": "First Responder Kit: Check sp_blitz Version"
3741
},
42+
{
43+
"command": "extension.sp_blitzall",
44+
"title": "First Responder Kit: Import sp_blitz and all its friends"
45+
},
3846
{
3947
"command": "extension.sp_blitz",
4048
"title": "First Responder Kit: Import sp_blitz"
@@ -81,13 +89,13 @@
8189
"menus": {
8290
"objectExplorer/item/context": [
8391
{
84-
"command": "extension.sp_blitzversion",
85-
"when": "connectionProvider == MSSQL && nodeType && nodeType == Database",
92+
"command": "extension.OEdiagnostics",
93+
"when": "connectionProvider == MSSQL",
8694
"group": "FRK"
8795
},
8896
{
8997
"command": "extension.sp_blitzversion",
90-
"when": "connectionProvider == MSSQL && nodeType && nodeType == Connection",
98+
"when": "connectionProvider == MSSQL",
9199
"group": "FRK"
92100
},
93101
{

src/extension.ts

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,54 @@ export function activate(context: vscode.ExtensionContext) {
1111
const baseUrl = "https://raw.githubusercontent.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/master/";
1212

1313

14+
// checking spblitz versioning
15+
var oediag = async (context: sqlops.ObjectExplorerContext) => {
16+
vscode.window.showInformationMessage(context.isConnectionNode.toString());
17+
vscode.window.showInformationMessage(context.nodeInfo.label);
18+
vscode.window.showInformationMessage(context.nodeInfo.nodePath);
19+
};
20+
var disposable_oediag = vscode.commands.registerCommand('extension.OEdiagnostics', oediag);
21+
context.subscriptions.push(disposable_oediag);
22+
1423
// checking spblitz versioning
1524
var getblitzversion = async (context: sqlops.ObjectExplorerContext) => {
16-
new updatecheck().checkForUpdates(context);
25+
var amIUPD = new updatecheck();
26+
let updateReturn = await amIUPD.checkForUpdates(context);
27+
28+
// updateChoice.then(function(updateReturn) {
29+
// if (updateReturn) {
30+
vscode.window.showInformationMessage(updateReturn);
31+
if (updateReturn == 'update') {
32+
getblitzall();
33+
} else if (updateReturn != '') {
34+
let versionURL = 'https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/releases/tag/' + updateReturn;
35+
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(versionURL));
36+
} else {
37+
// do nothing
38+
vscode.window.showInformationMessage("nothing came back");
39+
}
40+
// }
41+
// });
1742
};
1843
var disposable_spblitzversion = vscode.commands.registerCommand('extension.sp_blitzversion', getblitzversion);
1944
context.subscriptions.push(disposable_spblitzversion);
2045

21-
//importing the full spblitz script
46+
47+
//importing all first responder kit scripts
48+
var getblitzall = async () => {
49+
let fileName = "Install-All-Scripts.sql";
50+
var options = {
51+
uri: baseUrl + fileName,
52+
};
53+
console.log('Bringing in the first responder kit from the mothership.');
54+
const scriptText = await request.get(options);
55+
//await placeScript.placescript(fileName, scriptText);
56+
new placeScript().placescript(fileName,scriptText);
57+
};
58+
var disposable_spblitzall = vscode.commands.registerCommand('extension.sp_blitzall', getblitzall);
59+
context.subscriptions.push(disposable_spblitzall);
60+
61+
//importing the original spblitz script
2262
var getblitz = async () => {
2363
let fileName = "sp_Blitz.sql";
2464
var options = {

src/updateCheck.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import * as sqlops from 'sqlops';
44
import * as vscode from 'vscode';
55
import * as request from 'request-promise-native';
66
import * as apiConfig from './apiconfig';
7+
import { STATUS_CODES } from 'http';
78
let apiconfig: apiConfig.apiconfig = require('../apiconfig.json');
89

910
export class updatecheck {
10-
public async checkForUpdates(context: sqlops.ObjectExplorerContext) {
11+
public async checkForUpdates(context: sqlops.ObjectExplorerContext): Promise<string> {
1112
let baseUrl = "https://api.github.com/repos/BrentOzarULTD/SQL-Server-First-Responder-Kit/releases/latest";
1213
// /repos/:owner/:repo/releases/latest
1314
let apitoken = 'token ' + apiconfig.token;
@@ -41,17 +42,31 @@ export class updatecheck {
4142
let recentVersion = scriptText.tag_name;
4243
//compare against db version
4344
if (recentVersion > currentVersion) {
44-
vscode.window.showInformationMessage("New Version of First Responder Kit available.", {modal:false}, "Get It", "Tell Me More");
45-
46-
//tell me more : https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/releases/tag/<tag>
47-
48-
//get it : download all command
49-
45+
// var whatClicked =
46+
var buttonName = await vscode.window.showInformationMessage("New Version of First Responder Kit available.", {modal:false}, "Get It", "Tell Me More");
47+
48+
// whatClicked.then(function(buttonName) {
49+
vscode.window.showInformationMessage(buttonName);
50+
if (buttonName){
51+
if (buttonName == "Get It") {
52+
return 'update';
53+
} else if (buttonName == "Tell Me More") {
54+
return recentVersion;
55+
}
56+
} else {
57+
return '';
58+
}
59+
// });
60+
5061
} else {
51-
vscode.window.showInformationMessage("You're up to date!", {modal:false}, "Close")
62+
vscode.window.showInformationMessage("You're up to date!", {modal:false}, "Close");
63+
return '';
5264
}
5365

5466
//confirm if user wants to update scripts
67+
} else {
68+
vscode.window.showErrorMessage("Please connect to SQL server to check First Responder Kit version.");
69+
return '';
5570
}
5671
} catch (e) {
5772
vscode.window.showErrorMessage(e);

0 commit comments

Comments
 (0)