@@ -12,12 +12,12 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class BaseCpanService extends BaseJsonService {
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'cpan' }
|
||||
}
|
||||
|
||||
async fetch({ packageName }) {
|
||||
const url = `https://fastapi.metacpan.org/v1/release/${packageName}`
|
||||
return this._requestJson({ schema, url })
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'cpan' }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,6 @@ module.exports = class NpmTypeDefinitions extends NpmBase {
|
||||
return 'platform-support'
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'types' }
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return this.buildRoute('npm/types', { withTag: false })
|
||||
}
|
||||
@@ -32,6 +28,21 @@ module.exports = class NpmTypeDefinitions extends NpmBase {
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'types' }
|
||||
}
|
||||
|
||||
static render({ supportedLanguages }) {
|
||||
if (supportedLanguages.length === 0) {
|
||||
return { message: 'none', color: 'lightgray' }
|
||||
} else {
|
||||
return {
|
||||
message: supportedLanguages.sort().join(' | '),
|
||||
color: 'blue',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static transform({ devDependencies, types, files }) {
|
||||
const supportedLanguages = []
|
||||
|
||||
@@ -53,17 +64,6 @@ module.exports = class NpmTypeDefinitions extends NpmBase {
|
||||
return { supportedLanguages }
|
||||
}
|
||||
|
||||
static render({ supportedLanguages }) {
|
||||
if (supportedLanguages.length === 0) {
|
||||
return { message: 'none', color: 'lightgray' }
|
||||
} else {
|
||||
return {
|
||||
message: supportedLanguages.sort().join(' | '),
|
||||
color: 'blue',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async handle(namedParams, queryParams) {
|
||||
const { scope, packageName, registryUrl } = this.constructor.unpackParams(
|
||||
namedParams,
|
||||
|
||||
@@ -21,10 +21,6 @@ module.exports = class NpmVersion extends NpmBase {
|
||||
return this.buildRoute('npm/v', { withTag: true })
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'npm' }
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -66,6 +62,10 @@ module.exports = class NpmVersion extends NpmBase {
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'npm' }
|
||||
}
|
||||
|
||||
static render({ tag, version }) {
|
||||
const { label: defaultLabel } = this.defaultBadgeData
|
||||
return renderVersionBadge({
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
const OpencollectiveBase = require('./opencollective-base')
|
||||
|
||||
module.exports = class OpencollectiveAll extends OpencollectiveBase {
|
||||
static get route() {
|
||||
return this.buildRoute('all')
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -20,10 +24,6 @@ module.exports = class OpencollectiveAll extends OpencollectiveBase {
|
||||
}
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return this.buildRoute('all')
|
||||
}
|
||||
|
||||
async handle({ collective }) {
|
||||
const { backersCount } = await this.fetchCollectiveInfo(collective)
|
||||
return this.constructor.render(backersCount)
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
const OpencollectiveBase = require('./opencollective-base')
|
||||
|
||||
module.exports = class OpencollectiveBackers extends OpencollectiveBase {
|
||||
static get route() {
|
||||
return this.buildRoute('backers')
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -20,10 +24,6 @@ module.exports = class OpencollectiveBackers extends OpencollectiveBase {
|
||||
}
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return this.buildRoute('backers')
|
||||
}
|
||||
|
||||
async handle({ collective }) {
|
||||
const { backersCount } = await this.fetchCollectiveBackersCount(
|
||||
collective,
|
||||
|
||||
@@ -6,6 +6,10 @@ const documentation = `<h3>How to get the tierId</h3>
|
||||
<p>According to <a target="_blank" href="https://developer.opencollective.com/#/api/collectives?id=get-members-per-tier">open collectives documentation</a>, you can find the tierId by looking at the URL after clicking on a Tier Card on the collective page. (e.g. tierId for https://opencollective.com/shields/order/2988 is 2988)</p>`
|
||||
|
||||
module.exports = class OpencollectiveByTier extends OpencollectiveBase {
|
||||
static get route() {
|
||||
return this.buildRoute('tier', true)
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -24,10 +28,6 @@ module.exports = class OpencollectiveByTier extends OpencollectiveBase {
|
||||
}
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return this.buildRoute('tier', true)
|
||||
}
|
||||
|
||||
async handle({ collective, tierId }) {
|
||||
const result = await this.fetchCollectiveBackersCount(collective, {
|
||||
tierId,
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
const OpencollectiveBase = require('./opencollective-base')
|
||||
|
||||
module.exports = class OpencollectiveSponsors extends OpencollectiveBase {
|
||||
static get route() {
|
||||
return this.buildRoute('sponsors')
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -20,10 +24,6 @@ module.exports = class OpencollectiveSponsors extends OpencollectiveBase {
|
||||
}
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return this.buildRoute('sponsors')
|
||||
}
|
||||
|
||||
async handle({ collective }) {
|
||||
const { backersCount } = await this.fetchCollectiveBackersCount(
|
||||
collective,
|
||||
|
||||
@@ -14,10 +14,6 @@ module.exports = class OssTracker extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'oss lifecycle' }
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -35,10 +31,8 @@ module.exports = class OssTracker extends BaseService {
|
||||
]
|
||||
}
|
||||
|
||||
async fetch({ user, repo, branch }) {
|
||||
return this._request({
|
||||
url: `https://raw.githubusercontent.com/${user}/${repo}/${branch}/OSSMETADATA`,
|
||||
})
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'oss lifecycle' }
|
||||
}
|
||||
|
||||
static render({ status }) {
|
||||
@@ -48,6 +42,12 @@ module.exports = class OssTracker extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
async fetch({ user, repo, branch }) {
|
||||
return this._request({
|
||||
url: `https://raw.githubusercontent.com/${user}/${repo}/${branch}/OSSMETADATA`,
|
||||
})
|
||||
}
|
||||
|
||||
async handle({ user, repo, branch }) {
|
||||
const { buffer } = await this.fetch({
|
||||
user,
|
||||
|
||||
@@ -86,27 +86,6 @@ function DownloadsForInterval(interval) {
|
||||
return name
|
||||
}
|
||||
|
||||
static render({ downloads }) {
|
||||
return {
|
||||
message: `${metric(downloads)}${messageSuffix}`,
|
||||
color: downloadCount(downloads),
|
||||
}
|
||||
}
|
||||
|
||||
async fetch({ packageName }) {
|
||||
const url = `https://packagecontrol.io/packages/${packageName}.json`
|
||||
return this._requestJson({ schema, url })
|
||||
}
|
||||
|
||||
async handle({ packageName }) {
|
||||
const data = await this.fetch({ packageName })
|
||||
return this.constructor.render({ downloads: transform(data) })
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'downloads' }
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'downloads'
|
||||
}
|
||||
@@ -125,6 +104,27 @@ function DownloadsForInterval(interval) {
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'downloads' }
|
||||
}
|
||||
|
||||
static render({ downloads }) {
|
||||
return {
|
||||
message: `${metric(downloads)}${messageSuffix}`,
|
||||
color: downloadCount(downloads),
|
||||
}
|
||||
}
|
||||
|
||||
async fetch({ packageName }) {
|
||||
const url = `https://packagecontrol.io/packages/${packageName}.json`
|
||||
return this._requestJson({ schema, url })
|
||||
}
|
||||
|
||||
async handle({ packageName }) {
|
||||
const data = await this.fetch({ packageName })
|
||||
return this.constructor.render({ downloads: transform(data) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,10 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class PackagistDownloads extends BasePackagistService {
|
||||
static get category() {
|
||||
return 'downloads'
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'packagist',
|
||||
@@ -38,33 +42,6 @@ module.exports = class PackagistDownloads extends BasePackagistService {
|
||||
}
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'downloads',
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ interval, user, repo }) {
|
||||
const {
|
||||
package: { downloads },
|
||||
} = await this.fetch({ user, repo, schema })
|
||||
|
||||
return this.constructor.render({
|
||||
downloads: downloads[periodMap[interval].field],
|
||||
interval,
|
||||
})
|
||||
}
|
||||
|
||||
static render({ downloads, interval }) {
|
||||
return {
|
||||
message: metric(downloads) + periodMap[interval].suffix,
|
||||
color: downloadCount(downloads),
|
||||
}
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'downloads'
|
||||
}
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -82,4 +59,28 @@ module.exports = class PackagistDownloads extends BasePackagistService {
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'downloads',
|
||||
}
|
||||
}
|
||||
|
||||
static render({ downloads, interval }) {
|
||||
return {
|
||||
message: metric(downloads) + periodMap[interval].suffix,
|
||||
color: downloadCount(downloads),
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ interval, user, repo }) {
|
||||
const {
|
||||
package: { downloads },
|
||||
} = await this.fetch({ user, repo, schema })
|
||||
|
||||
return this.constructor.render({
|
||||
downloads: downloads[periodMap[interval].field],
|
||||
interval,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class PackagistLicense extends BasePackagistService {
|
||||
static get category() {
|
||||
return 'license'
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'packagist/l',
|
||||
@@ -22,6 +26,17 @@ module.exports = class PackagistLicense extends BasePackagistService {
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Packagist',
|
||||
namedParams: { user: 'doctrine', repo: 'orm' },
|
||||
staticPreview: renderLicenseBadge({ license: 'MIT' }),
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'license',
|
||||
@@ -37,18 +52,4 @@ module.exports = class PackagistLicense extends BasePackagistService {
|
||||
const { license } = this.transform({ json })
|
||||
return renderLicenseBadge({ license })
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'license'
|
||||
}
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Packagist',
|
||||
namedParams: { user: 'doctrine', repo: 'orm' },
|
||||
staticPreview: renderLicenseBadge({ license: 'MIT' }),
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@ const { allVersionsSchema, BasePackagistService } = require('./packagist-base')
|
||||
const { NotFound } = require('..')
|
||||
|
||||
module.exports = class PackagistPhpVersion extends BasePackagistService {
|
||||
static get category() {
|
||||
return 'platform-support'
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'packagist/php-v',
|
||||
@@ -11,38 +15,6 @@ module.exports = class PackagistPhpVersion extends BasePackagistService {
|
||||
}
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'php',
|
||||
color: 'blue',
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ user, repo, version = 'dev-master' }) {
|
||||
const allData = await this.fetch({
|
||||
user,
|
||||
repo,
|
||||
schema: allVersionsSchema,
|
||||
})
|
||||
|
||||
if (!allData.package.versions.hasOwnProperty(version)) {
|
||||
throw new NotFound({ prettyMessage: 'invalid version' })
|
||||
}
|
||||
|
||||
return this.constructor.render({
|
||||
php: allData.package.versions[version].require.php,
|
||||
})
|
||||
}
|
||||
|
||||
static render({ php }) {
|
||||
return {
|
||||
message: php,
|
||||
}
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'platform-support'
|
||||
}
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -66,4 +38,33 @@ module.exports = class PackagistPhpVersion extends BasePackagistService {
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'php',
|
||||
color: 'blue',
|
||||
}
|
||||
}
|
||||
|
||||
static render({ php }) {
|
||||
return {
|
||||
message: php,
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ user, repo, version = 'dev-master' }) {
|
||||
const allData = await this.fetch({
|
||||
user,
|
||||
repo,
|
||||
schema: allVersionsSchema,
|
||||
})
|
||||
|
||||
if (!allData.package.versions.hasOwnProperty(version)) {
|
||||
throw new NotFound({ prettyMessage: 'invalid version' })
|
||||
}
|
||||
|
||||
return this.constructor.render({
|
||||
php: allData.package.versions[version].require.php,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class PackagistVersion extends BasePackagistService {
|
||||
static get category() {
|
||||
return 'version'
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'packagist',
|
||||
@@ -33,6 +37,31 @@ module.exports = class PackagistVersion extends BasePackagistService {
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Packagist Version',
|
||||
pattern: 'v/:user/:repo',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: '4.2.2' }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'Packagist Pre Release Version',
|
||||
pattern: 'vpre/:user/:repo',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: '4.3-dev' }),
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'packagist',
|
||||
@@ -81,32 +110,4 @@ module.exports = class PackagistVersion extends BasePackagistService {
|
||||
const { version } = this.transform({ type, json })
|
||||
return renderVersionBadge({ version })
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'version'
|
||||
}
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Packagist Version',
|
||||
pattern: 'v/:user/:repo',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: '4.2.2' }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'Packagist Pre Release Version',
|
||||
pattern: 'vpre/:user/:repo',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: '4.3-dev' }),
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,15 +30,6 @@ const schema = Joi.array()
|
||||
.required()
|
||||
|
||||
module.exports = class Shippable extends BaseJsonService {
|
||||
async fetch({ projectId }) {
|
||||
const url = `https://api.shippable.com/projects/${projectId}/branchRunStatus`
|
||||
return this._requestJson({ schema, url })
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'shippable' }
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'build'
|
||||
}
|
||||
@@ -70,10 +61,19 @@ module.exports = class Shippable extends BaseJsonService {
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'shippable' }
|
||||
}
|
||||
|
||||
static render({ code }) {
|
||||
return renderBuildStatusBadge({ label: 'build', status: statusCodes[code] })
|
||||
}
|
||||
|
||||
async fetch({ projectId }) {
|
||||
const url = `https://api.shippable.com/projects/${projectId}/branchRunStatus`
|
||||
return this._requestJson({ schema, url })
|
||||
}
|
||||
|
||||
async handle({ projectId, branch = 'master' }) {
|
||||
const data = await this.fetch({ projectId })
|
||||
const builds = data.filter(result => result.branchName === branch)
|
||||
|
||||
@@ -10,6 +10,16 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class SnykVulnerabilityBase extends BaseSvgScrapingService {
|
||||
static get category() {
|
||||
return 'analysis'
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'vulnerabilities',
|
||||
}
|
||||
}
|
||||
|
||||
static render({ vulnerabilities }) {
|
||||
let color = 'red'
|
||||
if (vulnerabilities === '0') {
|
||||
@@ -33,14 +43,4 @@ module.exports = class SnykVulnerabilityBase extends BaseSvgScrapingService {
|
||||
|
||||
return { vulnerabilities }
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'analysis'
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'vulnerabilities',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,17 +14,6 @@ module.exports = class SonarCoverage extends SonarBase {
|
||||
return 'coverage'
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'coverage' }
|
||||
}
|
||||
|
||||
static render({ coverage }) {
|
||||
return {
|
||||
message: `${coverage.toFixed(0)}%`,
|
||||
color: coveragePercentage(coverage),
|
||||
}
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'sonar',
|
||||
@@ -52,6 +41,17 @@ module.exports = class SonarCoverage extends SonarBase {
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'coverage' }
|
||||
}
|
||||
|
||||
static render({ coverage }) {
|
||||
return {
|
||||
message: `${coverage.toFixed(0)}%`,
|
||||
color: coveragePercentage(coverage),
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ protocol, host, component }, { sonarVersion }) {
|
||||
const json = await this.fetch({
|
||||
sonarVersion,
|
||||
|
||||
@@ -17,17 +17,6 @@ module.exports = class SonarDocumentedApiDensity extends SonarBase {
|
||||
return 'analysis'
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: getLabel({ metric }) }
|
||||
}
|
||||
|
||||
static render({ density }) {
|
||||
return {
|
||||
message: `${density}%`,
|
||||
color: positiveMetricColorScale(density),
|
||||
}
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'sonar',
|
||||
@@ -55,6 +44,17 @@ module.exports = class SonarDocumentedApiDensity extends SonarBase {
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: getLabel({ metric }) }
|
||||
}
|
||||
|
||||
static render({ density }) {
|
||||
return {
|
||||
message: `${density}%`,
|
||||
color: positiveMetricColorScale(density),
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ protocol, host, component }, { sonarVersion }) {
|
||||
const json = await this.fetch({
|
||||
sonarVersion,
|
||||
|
||||
@@ -22,17 +22,6 @@ module.exports = class SonarFortifyRating extends SonarBase {
|
||||
return 'analysis'
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'fortify-security-rating' }
|
||||
}
|
||||
|
||||
static render({ rating }) {
|
||||
return {
|
||||
message: `${rating}/5`,
|
||||
color: colorMap[rating],
|
||||
}
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'sonar',
|
||||
@@ -66,6 +55,17 @@ module.exports = class SonarFortifyRating extends SonarBase {
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'fortify-security-rating' }
|
||||
}
|
||||
|
||||
static render({ rating }) {
|
||||
return {
|
||||
message: `${rating}/5`,
|
||||
color: colorMap[rating],
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ protocol, host, component }, { sonarVersion }) {
|
||||
const json = await this.fetch({
|
||||
sonarVersion,
|
||||
|
||||
@@ -117,6 +117,14 @@ module.exports = class SonarGeneric extends SonarBase {
|
||||
return 'analysis'
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'sonar',
|
||||
pattern: `${patternBase}/:metricName(${metricNameRouteParam})`,
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'sonar' }
|
||||
}
|
||||
@@ -129,14 +137,6 @@ module.exports = class SonarGeneric extends SonarBase {
|
||||
}
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'sonar',
|
||||
pattern: `${patternBase}/:metricName(${metricNameRouteParam})`,
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ protocol, host, component, metricName }, { sonarVersion }) {
|
||||
const json = await this.fetch({
|
||||
sonarVersion,
|
||||
|
||||
@@ -13,23 +13,6 @@ module.exports = class SonarQualityGate extends SonarBase {
|
||||
return 'analysis'
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'quality gate' }
|
||||
}
|
||||
|
||||
static render({ qualityState }) {
|
||||
if (qualityState === 'OK') {
|
||||
return {
|
||||
message: 'passed',
|
||||
color: 'success',
|
||||
}
|
||||
}
|
||||
return {
|
||||
message: 'failed',
|
||||
color: 'critical',
|
||||
}
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'sonar',
|
||||
@@ -58,6 +41,23 @@ module.exports = class SonarQualityGate extends SonarBase {
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'quality gate' }
|
||||
}
|
||||
|
||||
static render({ qualityState }) {
|
||||
if (qualityState === 'OK') {
|
||||
return {
|
||||
message: 'passed',
|
||||
color: 'success',
|
||||
}
|
||||
}
|
||||
return {
|
||||
message: 'failed',
|
||||
color: 'critical',
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ protocol, host, component }, { sonarVersion }) {
|
||||
const json = await this.fetch({
|
||||
sonarVersion,
|
||||
|
||||
@@ -15,18 +15,6 @@ module.exports = class SonarTechDebt extends SonarBase {
|
||||
return 'analysis'
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'tech debt' }
|
||||
}
|
||||
|
||||
static render({ debt, metric }) {
|
||||
return {
|
||||
label: getLabel({ metric }),
|
||||
message: `${debt}%`,
|
||||
color: negativeMetricColorScale(debt),
|
||||
}
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'sonar',
|
||||
@@ -58,13 +46,25 @@ module.exports = class SonarTechDebt extends SonarBase {
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'tech debt' }
|
||||
}
|
||||
|
||||
static render({ debt, metric }) {
|
||||
return {
|
||||
label: getLabel({ metric }),
|
||||
message: `${debt}%`,
|
||||
color: negativeMetricColorScale(debt),
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ protocol, host, component, metric }, { sonarVersion }) {
|
||||
const json = await this.fetch({
|
||||
sonarVersion,
|
||||
protocol,
|
||||
host,
|
||||
component,
|
||||
//special condition for backwards compatibility
|
||||
// Special condition for backwards compatibility.
|
||||
metricName: 'sqale_debt_ratio',
|
||||
})
|
||||
const { metricValue: debt } = this.transform({ json, sonarVersion })
|
||||
|
||||
@@ -30,6 +30,61 @@ module.exports = class SonarViolations extends SonarBase {
|
||||
return 'analysis'
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'sonar',
|
||||
pattern: `${patternBase}/:metric(violations|blocker_violations|critical_violations|major_violations|minor_violations|info_violations)`,
|
||||
queryParamSchema: queryParamWithFormatSchema,
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Sonar Violations (short format)',
|
||||
namedParams: {
|
||||
protocol: 'https',
|
||||
host: 'sonarcloud.io',
|
||||
component: 'swellaby:azdo-shellcheck',
|
||||
metric: 'violations',
|
||||
},
|
||||
queryParams: {
|
||||
format: 'short',
|
||||
sonarVersion: '4.2',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
violations: 0,
|
||||
metricName: 'violations',
|
||||
format: 'short',
|
||||
}),
|
||||
keywords,
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'Sonar Violations (long format)',
|
||||
namedParams: {
|
||||
protocol: 'http',
|
||||
host: 'sonar.petalslink.com',
|
||||
component: 'org.ow2.petals:petals-se-ase',
|
||||
metric: 'violations',
|
||||
},
|
||||
queryParams: {
|
||||
format: 'long',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
violations: {
|
||||
info_violations: 2,
|
||||
minor_violations: 1,
|
||||
},
|
||||
metricName: 'violations',
|
||||
format: 'long',
|
||||
}),
|
||||
keywords,
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'violations' }
|
||||
}
|
||||
@@ -93,61 +148,6 @@ module.exports = class SonarViolations extends SonarBase {
|
||||
}
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'sonar',
|
||||
pattern: `${patternBase}/:metric(violations|blocker_violations|critical_violations|major_violations|minor_violations|info_violations)`,
|
||||
queryParamSchema: queryParamWithFormatSchema,
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Sonar Violations (short format)',
|
||||
namedParams: {
|
||||
protocol: 'https',
|
||||
host: 'sonarcloud.io',
|
||||
component: 'swellaby:azdo-shellcheck',
|
||||
metric: 'violations',
|
||||
},
|
||||
queryParams: {
|
||||
format: 'short',
|
||||
sonarVersion: '4.2',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
violations: 0,
|
||||
metricName: 'violations',
|
||||
format: 'short',
|
||||
}),
|
||||
keywords,
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'Sonar Violations (long format)',
|
||||
namedParams: {
|
||||
protocol: 'http',
|
||||
host: 'sonar.petalslink.com',
|
||||
component: 'org.ow2.petals:petals-se-ase',
|
||||
metric: 'violations',
|
||||
},
|
||||
queryParams: {
|
||||
format: 'long',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
violations: {
|
||||
info_violations: 2,
|
||||
minor_violations: 1,
|
||||
},
|
||||
metricName: 'violations',
|
||||
format: 'long',
|
||||
}),
|
||||
keywords,
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
transformViolations({ json, sonarVersion, metric, format }) {
|
||||
// We can use the standard transform function in all cases
|
||||
// except when the requested badge is the long format of violations
|
||||
|
||||
@@ -32,22 +32,10 @@ const intervalMap = {
|
||||
}
|
||||
|
||||
module.exports = class Sourceforge extends BaseJsonService {
|
||||
static render({ downloads, interval }) {
|
||||
return {
|
||||
label: 'downloads',
|
||||
message: `${metric(downloads)}${intervalMap[interval].suffix}`,
|
||||
color: downloadCount(downloads),
|
||||
}
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'downloads'
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'sourceforge' }
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'sourceforge',
|
||||
@@ -85,6 +73,18 @@ module.exports = class Sourceforge extends BaseJsonService {
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'sourceforge' }
|
||||
}
|
||||
|
||||
static render({ downloads, interval }) {
|
||||
return {
|
||||
label: 'downloads',
|
||||
message: `${metric(downloads)}${intervalMap[interval].suffix}`,
|
||||
color: downloadCount(downloads),
|
||||
}
|
||||
}
|
||||
|
||||
async fetch({ interval, project, folder }) {
|
||||
const url = `http://sourceforge.net/projects/${project}/files/${
|
||||
folder ? `${folder}/` : ''
|
||||
|
||||
@@ -11,11 +11,6 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class Sourcegraph extends BaseJsonService {
|
||||
static render({ projectsCount }) {
|
||||
return {
|
||||
message: projectsCount,
|
||||
}
|
||||
}
|
||||
static get category() {
|
||||
return 'other'
|
||||
}
|
||||
@@ -27,10 +22,6 @@ module.exports = class Sourcegraph extends BaseJsonService {
|
||||
}
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { color: 'brightgreen', label: 'used by' }
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -44,6 +35,16 @@ module.exports = class Sourcegraph extends BaseJsonService {
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { color: 'brightgreen', label: 'used by' }
|
||||
}
|
||||
|
||||
static render({ projectsCount }) {
|
||||
return {
|
||||
message: projectsCount,
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ repo }) {
|
||||
const url = `https://sourcegraph.com/.api/repos/${repo}/-/shield`
|
||||
const json = await this._requestJson({
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
const { BaseSpigetService, documentation, keywords } = require('./spiget-base')
|
||||
|
||||
module.exports = class SpigetDownloadSize extends BaseSpigetService {
|
||||
static get category() {
|
||||
return 'size'
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'spiget/download-size',
|
||||
@@ -10,27 +14,6 @@ module.exports = class SpigetDownloadSize extends BaseSpigetService {
|
||||
}
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'size',
|
||||
color: 'blue',
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ resourceId }) {
|
||||
const { file } = await this.fetch({ resourceId })
|
||||
return this.constructor.render({ size: file.size, unit: file.sizeUnit })
|
||||
}
|
||||
|
||||
static render({ size, unit }) {
|
||||
return {
|
||||
message: `${size} ${unit}`,
|
||||
}
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'size'
|
||||
}
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -44,4 +27,22 @@ module.exports = class SpigetDownloadSize extends BaseSpigetService {
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'size',
|
||||
color: 'blue',
|
||||
}
|
||||
}
|
||||
|
||||
static render({ size, unit }) {
|
||||
return {
|
||||
message: `${size} ${unit}`,
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ resourceId }) {
|
||||
const { file } = await this.fetch({ resourceId })
|
||||
return this.constructor.render({ size: file.size, unit: file.sizeUnit })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ const { downloadCount } = require('../color-formatters')
|
||||
const { BaseSpigetService, documentation, keywords } = require('./spiget-base')
|
||||
|
||||
module.exports = class SpigetDownloads extends BaseSpigetService {
|
||||
static get category() {
|
||||
return 'downloads'
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'spiget/downloads',
|
||||
@@ -12,28 +16,6 @@ module.exports = class SpigetDownloads extends BaseSpigetService {
|
||||
}
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'downloads',
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ resourceId }) {
|
||||
const { downloads } = await this.fetch({ resourceId })
|
||||
return this.constructor.render({ downloads })
|
||||
}
|
||||
|
||||
static render({ downloads }) {
|
||||
return {
|
||||
message: metric(downloads),
|
||||
color: downloadCount(downloads),
|
||||
}
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'downloads'
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -47,4 +29,22 @@ module.exports = class SpigetDownloads extends BaseSpigetService {
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'downloads',
|
||||
}
|
||||
}
|
||||
|
||||
static render({ downloads }) {
|
||||
return {
|
||||
message: metric(downloads),
|
||||
color: downloadCount(downloads),
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ resourceId }) {
|
||||
const { downloads } = await this.fetch({ resourceId })
|
||||
return this.constructor.render({ downloads })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ const versionSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class SpigetLatestVersion extends BaseSpigetService {
|
||||
static get category() {
|
||||
return 'version'
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'spiget/version',
|
||||
@@ -17,6 +21,20 @@ module.exports = class SpigetLatestVersion extends BaseSpigetService {
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Spiget Version',
|
||||
namedParams: {
|
||||
resourceId: '9089',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: 2.1 }),
|
||||
documentation,
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'spiget',
|
||||
@@ -32,22 +50,4 @@ module.exports = class SpigetLatestVersion extends BaseSpigetService {
|
||||
})
|
||||
return renderVersionBadge({ version: name })
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'version'
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Spiget Version',
|
||||
namedParams: {
|
||||
resourceId: '9089',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: 2.1 }),
|
||||
documentation,
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ const { floorCount } = require('../color-formatters')
|
||||
const { BaseSpigetService, documentation, keywords } = require('./spiget-base')
|
||||
|
||||
module.exports = class SpigetRatings extends BaseSpigetService {
|
||||
static get category() {
|
||||
return 'rating'
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'spiget',
|
||||
@@ -12,34 +16,6 @@ module.exports = class SpigetRatings extends BaseSpigetService {
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ format, resourceId }) {
|
||||
const { rating } = await this.fetch({ resourceId })
|
||||
return this.constructor.render({
|
||||
format,
|
||||
total: rating.count,
|
||||
average: rating.average,
|
||||
})
|
||||
}
|
||||
|
||||
static render({ format, total, average }) {
|
||||
const message =
|
||||
format === 'stars'
|
||||
? starRating(average)
|
||||
: `${average}/5 (${metric(total)})`
|
||||
return {
|
||||
message,
|
||||
color: floorCount(average, 2, 3, 4),
|
||||
}
|
||||
}
|
||||
|
||||
static get category() {
|
||||
return 'rating'
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'rating' }
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
@@ -67,4 +43,28 @@ module.exports = class SpigetRatings extends BaseSpigetService {
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'rating' }
|
||||
}
|
||||
|
||||
static render({ format, total, average }) {
|
||||
const message =
|
||||
format === 'stars'
|
||||
? starRating(average)
|
||||
: `${average}/5 (${metric(total)})`
|
||||
return {
|
||||
message,
|
||||
color: floorCount(average, 2, 3, 4),
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ format, resourceId }) {
|
||||
const { rating } = await this.fetch({ resourceId })
|
||||
return this.constructor.render({
|
||||
format,
|
||||
total: rating.count,
|
||||
average: rating.average,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,20 @@ module.exports = class SpigetTestedVersions extends BaseSpigetService {
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Spiget tested server versions',
|
||||
namedParams: {
|
||||
resourceId: '9089',
|
||||
},
|
||||
staticPreview: this.render({ versions: '1.7-1.13' }),
|
||||
documentation,
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'tested versions',
|
||||
@@ -21,10 +35,10 @@ module.exports = class SpigetTestedVersions extends BaseSpigetService {
|
||||
}
|
||||
}
|
||||
|
||||
async handle({ resourceId }) {
|
||||
const { testedVersions } = await this.fetch({ resourceId })
|
||||
const { versions } = this.transform({ testedVersions })
|
||||
return this.constructor.render({ versions })
|
||||
static render({ versions }) {
|
||||
return {
|
||||
message: versions,
|
||||
}
|
||||
}
|
||||
|
||||
transform({ testedVersions }) {
|
||||
@@ -39,23 +53,9 @@ module.exports = class SpigetTestedVersions extends BaseSpigetService {
|
||||
return { versions }
|
||||
}
|
||||
|
||||
static render({ versions }) {
|
||||
return {
|
||||
message: versions,
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Spiget tested server versions',
|
||||
namedParams: {
|
||||
resourceId: '9089',
|
||||
},
|
||||
staticPreview: this.render({ versions: '1.7-1.13' }),
|
||||
documentation,
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
async handle({ resourceId }) {
|
||||
const { testedVersions } = await this.fetch({ resourceId })
|
||||
const { versions } = this.transform({ testedVersions })
|
||||
return this.constructor.render({ versions })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user