Skip to content

Commit

Permalink
Revert "Initial start on migration to official Node SDK"
Browse files Browse the repository at this point in the history
This reverts commit 71e9f67.
  • Loading branch information
jlandersen committed Oct 15, 2016
1 parent 71e9f67 commit cbc2810
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 138 deletions.
198 changes: 98 additions & 100 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,100 +1,98 @@
{
"name": "vstsbuildstatus",
"displayName": "Visual Studio Team Services Build Status",
"description": "Monitor Visual Studio Team Services builds in the status bar",
"version": "0.5.0",
"publisher": "jeppeandersen",
"license": "MIT",
"keywords": [
"Visual Studio Team Services",
"Build Status",
"CI"
],
"icon": "assets/icon.png",
"bugs": {
"url": "https://github.com/jlandersen/vscode-vsts-build-status/issues"
},
"homepage": "https://github.com/jlandersen/vscode-vsts-build-status/blob/master/README.md",
"repository": {
"type": "git",
"url": "https://github.com/jlandersen/vscode-vsts-build-status.git"
},
"galleryBanner": {
"color": "#5c2d91",
"theme": "dark"
},
"engines": {
"vscode": "^1.5.0"
},
"categories": [
"Other"
],
"activationEvents": [
"*"
],
"main": "./out/src/extension",
"scripts": {
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install"
},
"dependencies": {
"@types/q": "0.0.32",
"node-rest-client": "^2.0.0",
"openurl": "^1.1.1",
"vso-node-api": "^5.0.5"
},
"devDependencies": {
"typescript": "^2.0.3",
"vscode": "^1.0.0",
"mocha": "^2.3.3",
"@types/node": "^6.0.40",
"@types/mocha": "^2.2.32"
},
"contributes": {
"configuration": {
"type": "object",
"title": "VSTS Build Status Configuration",
"properties": {
"vsts.account": {
"type": "string",
"default": "",
"description": "Specifies your Visual Studio Team Services account name ([account].visualstudio.com)."
},
"vsts.username": {
"type": "string",
"default": "",
"description": "Specifies a username to use for accessing VSTS Build information on the account. Not needed if you use a personal acceess token."
},
"vsts.password": {
"type": "string",
"default": "",
"description": "Specifies the password or Personal Access Token to use for accessing VSTS Build information on the account."
},
"vsts.project": {
"type": "string",
"default": "",
"description": "Specifies the VSTS project to look for builds in."
}
}
},
"commands": [
{
"command": "extension.openVstsBuildDefinitionSelection",
"title": " VSTS Build Status: Select Build Definition to Monitor"
},
{
"command": "extension.openVstsQueueBuildSelection",
"title": " VSTS Build Status: Queue Build"
},
{
"command": "extension.openVstsBuildLogSelection",
"title": " VSTS Build Status: View Build Log"
},
{
"command": "extension.openVstsBuildWebSelection",
"title": "VSTS Build Status: Open Build in Browser"
}
]
}
}
{
"name": "vstsbuildstatus",
"displayName": "Visual Studio Team Services Build Status",
"description": "Monitor Visual Studio Team Services builds in the status bar",
"version": "0.5.0",
"publisher": "jeppeandersen",
"license": "MIT",
"keywords": [
"Visual Studio Team Services",
"Build Status",
"CI"
],
"icon": "assets/icon.png",
"bugs": {
"url": "https://github.com/jlandersen/vscode-vsts-build-status/issues"
},
"homepage": "https://github.com/jlandersen/vscode-vsts-build-status/blob/master/README.md",
"repository": {
"type": "git",
"url": "https://github.com/jlandersen/vscode-vsts-build-status.git"
},
"galleryBanner": {
"color": "#5c2d91",
"theme": "dark"
},
"engines": {
"vscode": "^1.5.0"
},
"categories": [
"Other"
],
"activationEvents": [
"*"
],
"main": "./out/src/extension",
"scripts": {
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install"
},
"dependencies": {
"node-rest-client": "^2.0.0",
"openurl": "^1.1.1"
},
"devDependencies": {
"typescript": "^2.0.3",
"vscode": "^1.0.0",
"mocha": "^2.3.3",
"@types/node": "^6.0.40",
"@types/mocha": "^2.2.32"
},
"contributes": {
"configuration": {
"type": "object",
"title": "VSTS Build Status Configuration",
"properties": {
"vsts.account": {
"type": "string",
"default": "",
"description": "Specifies your Visual Studio Team Services account name ([account].visualstudio.com)."
},
"vsts.username": {
"type": "string",
"default": "",
"description": "Specifies a username to use for accessing VSTS Build information on the account. Not needed if you use a personal acceess token."
},
"vsts.password": {
"type": "string",
"default": "",
"description": "Specifies the password or Personal Access Token to use for accessing VSTS Build information on the account."
},
"vsts.project": {
"type": "string",
"default": "",
"description": "Specifies the VSTS project to look for builds in."
}
}
},
"commands": [
{
"command": "extension.openVstsBuildDefinitionSelection",
"title": " VSTS Build Status: Select Build Definition to Monitor"
},
{
"command": "extension.openVstsQueueBuildSelection",
"title": " VSTS Build Status: Queue Build"
},
{
"command": "extension.openVstsBuildLogSelection",
"title": " VSTS Build Status: View Build Log"
},
{
"command": "extension.openVstsBuildWebSelection",
"title": "VSTS Build Status: Open Build in Browser"
}
]
}
}
31 changes: 5 additions & 26 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

import {workspace, WorkspaceConfiguration, Memento, Disposable} from "vscode"
import {BuildDefinition} from "./vstsbuildrestclient"
import * as vsts from "vso-node-api/WebApi";
import {IRequestHandler} from "vso-node-api/interfaces/common/VsoBaseInterfaces"
import {BuildDefinitionReference} from 'vso-node-api/interfaces/BuildInterfaces';

export interface Settings {
account: string;
username: string;
password: string;
project: string;
activeBuildDefinition: BuildDefinitionReference;
activeBuildDefinition: BuildDefinition;
onDidChangeSettings(handler: () => void): void;
getConnection(): vsts.WebApi;

dispose(): void;
isValid(): boolean;
Expand All @@ -25,7 +21,7 @@ export class WorkspaceVstsSettings implements Settings {
password: string;
project: string;

private _activeBuildDefinition: BuildDefinitionReference;
private _activeBuildDefinition: BuildDefinition;
private activeBuildDefinitionStateKey: string = "vsts.active.definition";
private state: Memento;
private workspaceSettingsChangedDisposable: Disposable;
Expand All @@ -34,7 +30,7 @@ export class WorkspaceVstsSettings implements Settings {
constructor(state: Memento) {
this.state = state;

var definition = state.get<BuildDefinitionReference>(this.activeBuildDefinitionStateKey);
var definition = state.get<BuildDefinition>(this.activeBuildDefinitionStateKey);
if (definition) {
this.activeBuildDefinition = definition;
}
Expand All @@ -50,11 +46,11 @@ export class WorkspaceVstsSettings implements Settings {
this.reload();
}

get activeBuildDefinition(): BuildDefinitionReference {
get activeBuildDefinition(): BuildDefinition {
return this._activeBuildDefinition;
}

set activeBuildDefinition(definition: BuildDefinitionReference) {
set activeBuildDefinition(definition: BuildDefinition) {
this._activeBuildDefinition = definition;
this.state.update(this.activeBuildDefinitionStateKey, definition);
}
Expand All @@ -63,23 +59,6 @@ export class WorkspaceVstsSettings implements Settings {
this.onDidChangeSettingsHandler = handler;
}

public getConnection(): vsts.WebApi {
if (!this.isValid()) {
return null;
}

let collectionUrl = `https://${this.account}.visualstudio.com/DefaultCollection/`;
let authHandler: IRequestHandler;

if (this.username) {
authHandler = vsts.getBasicHandler(this.username, this.password);
} else {
authHandler = vsts.getPersonalAccessTokenHandler(this.password);
}

return new vsts.WebApi(collectionUrl, authHandler);
}

public isValid(): boolean {
return this.isAccountProvided() && this.isCredentialsProvided() && this.isProjectSpecified();
}
Expand Down
20 changes: 8 additions & 12 deletions src/vstsbuildstatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import { Build, BuildDefinition, VstsBuildRestClient, VstsBuildRestClientFactory
import { VstsBuildLogStreamHandler } from "./vstsbuildlog";
import fs = require("fs");
import openurl = require("openurl");
import * as vsts from "vso-node-api/WebApi";
import * as bi from 'vso-node-api/interfaces/BuildInterfaces';

interface BuildDefinitionQuickPickItem {
id: number;
label: string;
description: string;
definition: bi.BuildDefinitionReference;
definition: BuildDefinition;
}

interface BuildQuickPickItem {
Expand All @@ -27,8 +25,8 @@ interface BuildQuickPickItem {
export class VstsBuildStatus {
private updateIntervalInSeconds = 15;
private statusBar: VstsBuildStatusBar;
private activeDefinition: bi.BuildDefinitionReference;

private activeDefinition: BuildDefinition;
private settings: Settings;
private intervalTimer: NodeJS.Timer;
private restClient: VstsBuildRestClient;
Expand All @@ -41,7 +39,7 @@ export class VstsBuildStatus {
this.restClient = restClientFactory.createClient(settings);
this.activeDefinition = settings.activeBuildDefinition;
this.logStreamHandler = new VstsBuildLogStreamHandler(this.restClient);

this.settings.onDidChangeSettings(() => {
this.beginBuildStatusUpdates();
});
Expand Down Expand Up @@ -153,18 +151,16 @@ export class VstsBuildStatus {
});
}

private getBuildDefinitionByQuickPick(placeHolder: string): Thenable<bi.BuildDefinitionReference> {
private getBuildDefinitionByQuickPick(placeHolder: string): Thenable<BuildDefinition> {
if (!this.settings.isValid()) {
this.showSettingsMissingMessage();

return Promise.resolve(null);
}

let build = this.settings.getConnection().getBuildApi();

return new Promise((resolve, reject) => {
build.getDefinitions(this.settings.project).then(response => {
let buildDefinitions = response.map(definition => {
this.restClient.getDefinitions().then(response => {
let buildDefinitions: BuildDefinitionQuickPickItem[] = response.value.map(function (definition) {
return {
label: definition.name,
description: `Revision ${definition.revision}`,
Expand All @@ -173,7 +169,7 @@ export class VstsBuildStatus {
}
});

let options = {
let options = {
placeHolder: placeHolder
};

Expand Down

0 comments on commit cbc2810

Please sign in to comment.