convert some service classes to static props, run [cookbook coveralls cpan] (#5516)

* refactor(cookbook): convert to static props

* refactor(coveralls): convert to static props

* refactor(coverity): convert to static props

* refactor(cpan): convert to static props

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
Caleb Cartwright
2020-09-12 12:39:01 -05:00
committed by GitHub
parent b7dcf58bd6
commit bb6d2b5c78
6 changed files with 85 additions and 142 deletions

View File

@@ -7,30 +7,18 @@ const { BaseJsonService } = require('..')
const schema = Joi.object({ version: Joi.string().required() }).required()
module.exports = class Cookbook extends BaseJsonService {
static get category() {
return 'version'
}
static category = 'version'
static route = { base: 'cookbook/v', pattern: ':cookbook' }
static get route() {
return {
base: 'cookbook/v',
pattern: ':cookbook',
}
}
static examples = [
{
title: 'Chef cookbook',
namedParams: { cookbook: 'chef-sugar' },
staticPreview: renderVersionBadge({ version: '5.0.0' }),
},
]
static get examples() {
return [
{
title: 'Chef cookbook',
namedParams: { cookbook: 'chef-sugar' },
staticPreview: renderVersionBadge({ version: '5.0.0' }),
},
]
}
static get defaultBadgeData() {
return { label: 'cookbook' }
}
static defaultBadgeData = { label: 'cookbook' }
async fetch({ cookbook }) {
const url = `https://supermarket.getchef.com/api/v1/cookbooks/${cookbook}/versions/latest`

View File

@@ -9,59 +9,50 @@ const schema = Joi.object({
}).required()
module.exports = class Coveralls extends BaseJsonService {
static get category() {
return 'coverage'
static category = 'coverage'
static route = {
base: 'coveralls',
pattern: ':vcsType(github|bitbucket)?/:user/:repo/:branch*',
}
static get route() {
return {
base: 'coveralls',
pattern: ':vcsType(github|bitbucket)?/:user/:repo/:branch*',
}
}
static examples = [
{
title: 'Coveralls github',
pattern: ':vcsType/:user/:repo',
namedParams: { vcsType: 'github', user: 'jekyll', repo: 'jekyll' },
staticPreview: this.render({ coverage: 86 }),
},
{
title: 'Coveralls github branch',
pattern: ':vcsType/:user/:repo/:branch',
namedParams: {
vcsType: 'github',
user: 'lemurheavy',
repo: 'coveralls-ruby',
branch: 'master',
},
staticPreview: this.render({ coverage: 91.81 }),
},
{
title: 'Coveralls bitbucket',
pattern: ':vcsType/:user/:repo',
namedParams: { vcsType: 'bitbucket', user: 'pyKLIP', repo: 'pyklip' },
staticPreview: this.render({ coverage: 86 }),
},
{
title: 'Coveralls bitbucket branch',
pattern: ':vcsType/:user/:repo/:branch',
namedParams: {
vcsType: 'bitbucket',
user: 'pyKLIP',
repo: 'pyklip',
branch: 'master',
},
staticPreview: this.render({ coverage: 96 }),
},
]
static get examples() {
return [
{
title: 'Coveralls github',
pattern: ':vcsType/:user/:repo',
namedParams: { vcsType: 'github', user: 'jekyll', repo: 'jekyll' },
staticPreview: this.render({ coverage: 86 }),
},
{
title: 'Coveralls github branch',
pattern: ':vcsType/:user/:repo/:branch',
namedParams: {
vcsType: 'github',
user: 'lemurheavy',
repo: 'coveralls-ruby',
branch: 'master',
},
staticPreview: this.render({ coverage: 91.81 }),
},
{
title: 'Coveralls bitbucket',
pattern: ':vcsType/:user/:repo',
namedParams: { vcsType: 'bitbucket', user: 'pyKLIP', repo: 'pyklip' },
staticPreview: this.render({ coverage: 86 }),
},
{
title: 'Coveralls bitbucket branch',
pattern: ':vcsType/:user/:repo/:branch',
namedParams: {
vcsType: 'bitbucket',
user: 'pyKLIP',
repo: 'pyklip',
branch: 'master',
},
staticPreview: this.render({ coverage: 96 }),
},
]
}
static get defaultBadgeData() {
return { label: 'coverage' }
}
static defaultBadgeData = { label: 'coverage' }
static render({ coverage }) {
return {

View File

@@ -9,36 +9,22 @@ const schema = Joi.object({
}).required()
module.exports = class CoverityScan extends BaseJsonService {
static get category() {
return 'analysis'
}
static category = 'analysis'
static route = { base: 'coverity/scan', pattern: ':projectId' }
static get route() {
return {
base: 'coverity/scan',
pattern: ':projectId',
}
}
static get examples() {
return [
{
title: 'Coverity Scan',
namedParams: {
projectId: '3997',
},
staticPreview: this.render({
message: 'passed',
}),
static examples = [
{
title: 'Coverity Scan',
namedParams: {
projectId: '3997',
},
]
}
staticPreview: this.render({
message: 'passed',
}),
},
]
static get defaultBadgeData() {
return {
label: 'coverity',
}
}
static defaultBadgeData = { label: 'coverity' }
static render({ message }) {
let color

View File

@@ -3,27 +3,17 @@
const BaseCpanService = require('./cpan')
module.exports = class CpanLicense extends BaseCpanService {
static get category() {
return 'license'
}
static category = 'license'
static route = { base: 'cpan/l', pattern: ':packageName' }
static get route() {
return {
base: 'cpan/l',
pattern: ':packageName',
}
}
static get examples() {
return [
{
title: 'CPAN',
namedParams: { packageName: 'Config-Augeas' },
staticPreview: this.render({ license: 'lgpl_2_1' }),
keywords: ['perl'],
},
]
}
static examples = [
{
title: 'CPAN',
namedParams: { packageName: 'Config-Augeas' },
staticPreview: this.render({ license: 'lgpl_2_1' }),
keywords: ['perl'],
},
]
static render({ license }) {
return {

View File

@@ -4,27 +4,17 @@ const { renderVersionBadge } = require('../version')
const BaseCpanService = require('./cpan')
module.exports = class CpanVersion extends BaseCpanService {
static get category() {
return 'version'
}
static category = 'version'
static route = { base: 'cpan/v', pattern: ':packageName' }
static get route() {
return {
base: 'cpan/v',
pattern: ':packageName',
}
}
static get examples() {
return [
{
title: 'CPAN',
namedParams: { packageName: 'Config-Augeas' },
staticPreview: renderVersionBadge({ version: '1.000' }),
keywords: ['perl'],
},
]
}
static examples = [
{
title: 'CPAN',
namedParams: { packageName: 'Config-Augeas' },
staticPreview: renderVersionBadge({ version: '1.000' }),
keywords: ['perl'],
},
]
async handle({ packageName }) {
const { version } = await this.fetch({ packageName })

View File

@@ -9,9 +9,7 @@ const schema = Joi.object({
}).required()
module.exports = class BaseCpanService extends BaseJsonService {
static get defaultBadgeData() {
return { label: 'cpan' }
}
static defaultBadgeData = { label: 'cpan' }
async fetch({ packageName }) {
const url = `https://fastapi.metacpan.org/v1/release/${packageName}`