convert some service classes to static props, run [date david debian debug dependabot] (#5539)

* refactor(date): convert to static props

* refactor(david): convert to static props

* refactor(debian): convert to static props

* refactor(debug): convert to static props

* refactor(dependabot): 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-14 16:54:22 -05:00
committed by GitHub
parent 1d649fa702
commit 0b31461af6
5 changed files with 61 additions and 113 deletions

View File

@@ -10,33 +10,21 @@ const documentation = `
`
module.exports = class Date extends BaseService {
static get category() {
return 'other'
}
static category = 'other'
static route = { base: 'date', pattern: ':timestamp([0-9]+)' }
static get route() {
return {
base: 'date',
pattern: ':timestamp([0-9]+)',
}
}
static examples = [
{
title: 'Relative date',
pattern: ':timestamp',
namedParams: { timestamp: '1540814400' },
staticPreview: this.render({ relativeDateString: '2 days ago' }),
keywords: ['time', 'countdown', 'countup', 'moment'],
documentation,
},
]
static get examples() {
return [
{
title: 'Relative date',
pattern: ':timestamp',
namedParams: { timestamp: '1540814400' },
staticPreview: this.render({ relativeDateString: '2 days ago' }),
keywords: ['time', 'countdown', 'countup', 'moment'],
documentation,
},
]
}
static get defaultBadgeData() {
return { label: 'date' }
}
static defaultBadgeData = { label: 'date' }
static render({ relativeDateString }) {
return {

View File

@@ -41,37 +41,28 @@ const statusMap = {
}
module.exports = class David extends BaseJsonService {
static get category() {
return 'dependencies'
static category = 'dependencies'
static route = {
base: 'david',
pattern: ':kind(dev|optional|peer)?/:user/:repo',
queryParamSchema,
}
static get route() {
return {
base: 'david',
pattern: ':kind(dev|optional|peer)?/:user/:repo',
queryParamSchema,
}
}
static examples = [
{
title: 'David',
namedParams: { user: 'expressjs', repo: 'express' },
staticPreview: this.render({ status: 'uptodate' }),
},
{
title: 'David (path)',
namedParams: { user: 'babel', repo: 'babel' },
queryParams: { path: 'packages/babel-core' },
staticPreview: this.render({ status: 'uptodate' }),
},
]
static get examples() {
return [
{
title: 'David',
namedParams: { user: 'expressjs', repo: 'express' },
staticPreview: this.render({ status: 'uptodate' }),
},
{
title: 'David (path)',
namedParams: { user: 'babel', repo: 'babel' },
queryParams: { path: 'packages/babel-core' },
staticPreview: this.render({ status: 'uptodate' }),
},
]
}
static get defaultBadgeData() {
return { label: 'dependencies' }
}
static defaultBadgeData = { label: 'dependencies' }
static render({ status, kind }) {
return {

View File

@@ -19,30 +19,21 @@ const schema = Joi.array()
const defaultDistribution = 'stable'
module.exports = class Debian extends BaseJsonService {
static get category() {
return 'version'
static category = 'version'
static route = {
base: 'debian/v',
pattern: ':packageName/:distribution?',
}
static get route() {
return {
base: 'debian/v',
pattern: ':packageName/:distribution?',
}
}
static examples = [
{
title: 'Debian package',
namedParams: { packageName: 'apt', distribution: 'unstable' },
staticPreview: renderVersionBadge({ version: '1.8.0' }),
},
]
static get examples() {
return [
{
title: 'Debian package',
namedParams: { packageName: 'apt', distribution: 'unstable' },
staticPreview: renderVersionBadge({ version: '1.8.0' }),
},
]
}
static get defaultBadgeData() {
return { label: 'debian' }
}
static defaultBadgeData = { label: 'debian' }
async handle({ packageName, distribution = defaultDistribution }) {
const data = await this._requestJson({

View File

@@ -6,23 +6,10 @@ const serverStartTime = new Date(new Date().toGMTString())
let bitFlip = false
module.exports = class Debug extends NonMemoryCachingBaseService {
static get category() {
return 'debug'
}
static category = 'debug'
static route = { base: 'debug', pattern: ':variant(time|starttime|flip)' }
static get route() {
return {
base: 'debug',
pattern: ':variant(time|starttime|flip)',
}
}
static get defaultBadgeData() {
return {
label: 'debug',
color: 'blue',
}
}
static defaultBadgeData = { label: 'debug', color: 'blue' }
async handle({ variant }) {
switch (variant) {

View File

@@ -10,33 +10,24 @@ const schema = Joi.object({
})
module.exports = class DependabotSemverCompatibility extends BaseJsonService {
static get category() {
return 'analysis'
static category = 'analysis'
static route = {
base: 'dependabot/semver',
pattern: ':packageManager/:dependencyName',
}
static get route() {
return {
base: 'dependabot/semver',
pattern: ':packageManager/:dependencyName',
}
}
static get examples() {
return [
{
title: 'Dependabot SemVer Compatibility',
namedParams: { packageManager: 'bundler', dependencyName: 'puma' },
staticPreview: {
color: 'green',
message: '98%',
},
static examples = [
{
title: 'Dependabot SemVer Compatibility',
namedParams: { packageManager: 'bundler', dependencyName: 'puma' },
staticPreview: {
color: 'green',
message: '98%',
},
]
}
},
]
static get defaultBadgeData() {
return { label: 'semver stability' }
}
static defaultBadgeData = { label: 'semver stability' }
_getQuery({ packageManager, dependencyName }) {
return {