Skip to content

Commit

Permalink
[DotnetStatus] Service deprecation (#1630)
Browse files Browse the repository at this point in the history
  • Loading branch information
PyvesB authored Apr 2, 2018
1 parent 3aa2130 commit a168072
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 71 deletions.
4 changes: 0 additions & 4 deletions lib/all-badge-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -2171,10 +2171,6 @@ const allBadgeExamples = [
title: 'David',
previewUri: '/david/peer/webcomponents/generator-element.svg'
},
{
title: '.Net Status (GitHub)',
previewUri: '/dotnetstatus/gh/jaredcnance/dotnet-status/API.svg'
},
{
title: 'bitHound',
previewUri: '/bithound/dependencies/github/rexxars/sse-channel.svg'
Expand Down
1 change: 1 addition & 0 deletions lib/deprecated-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const deprecatedServices = {
'snap': new Date('2018-01-23'),
'snap-ci': new Date('2018-01-23'),
'cauditor': new Date('2018-02-15'),
'dotnetstatus': new Date('2018-04-01'),
};

module.exports = {
Expand Down
46 changes: 4 additions & 42 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2948,50 +2948,12 @@ cache(function(data, match, sendBadge, request) {
});
}));

// dotnet-status integration.
// dotnet-status integration - deprecated as of April 2018.
camp.route(/^\/dotnetstatus\/(.+)\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
var projectUri = match[1]; // gh/{USER}/{REPO}/{PROJECT}
var format = match[2];
var url = 'http://dotnet-status.com/api/status/' + projectUri + '/';
var badgeData = getBadgeData('dependencies', data);
var sendErrorBadge = function() {
badgeData.text[1] = 'inconclusive';
sendBadge(format, badgeData);
};

request(url, function (err, res, buffer) {
if (err != null || res.statusCode === 404) {
sendErrorBadge();
return;
}

if (res.statusCode === 202) {
badgeData.text[1] = 'processing';
sendBadge(format, badgeData);
return;
}

try {
var data = JSON.parse(buffer);
if(data.projectResults.length === 1 && data.projectResults[0] !== null) {
if (data.projectResults[0].outOfDate) {
badgeData.text[1] = 'out of date';
badgeData.colorscheme = 'red';
} else {
badgeData.text[1] = 'up to date';
badgeData.colorscheme = 'blue';
}
}
else {
badgeData.text[1] = 'project not found';
}
sendBadge(format, badgeData);
}
catch (e) {
sendErrorBadge();
}
});
const format = match[2];
const badgeData = getDeprecatedBadge('dotnet status', data);
sendBadge(format, badgeData);
}));

// Gemnasium integration
Expand Down
33 changes: 8 additions & 25 deletions services/dotnetstatus/dotnetstatus.tester.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
"use strict";
'use strict';

const Joi = require("joi");
const ServiceTester = require('../service-tester');

const t = new ServiceTester({
id: "dotnetstatus",
title: "dotnet-status"
});
const t = new ServiceTester({ id: 'dotnetstatus', title: 'dotnet-status' });
module.exports = t;

t
.create("get nuget package status")
.get("/gh/jaredcnance/dotnet-status/API.json")
.expectJSONTypes(
Joi.object().keys({
name: "dependencies",
value: Joi.equal("up to date", "out of date", "processing")
})
);

t
.create("get nuget package status")
.get("/gh/jaredcnance/dotnet-status/invalid-project.json")
.expectJSON({ name: "dependencies", value: "project not found" });

t
.create("get nuget package status error")
.get("/not-a-valid-uri.json")
.expectJSON({ name: "dependencies", value: "inconclusive" });
t.create('no longer available (previously get package status)')
.get('/gh/jaredcnance/dotnet-status/API.json')
.expectJSON({
name: 'dotnet status',
value: 'no longer available'
});

0 comments on commit a168072

Please sign in to comment.