convert some service classes to static props, run [clojars cocoapods] (#5513)

* refactor(clojars): convert to static props

* refactor(cocoapods): 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:03:52 -05:00
committed by GitHub
parent 005b3ba4ac
commit 65295ddcdf
6 changed files with 67 additions and 140 deletions

View File

@@ -5,29 +5,17 @@ const { downloadCount: downloadsColor } = require('../color-formatters')
const { BaseClojarsService } = require('./clojars-base')
module.exports = class ClojarsDownloads extends BaseClojarsService {
static get category() {
return 'downloads'
}
static category = 'downloads'
static route = { base: 'clojars/dt', pattern: ':clojar+' }
static get route() {
return {
base: 'clojars/dt',
pattern: ':clojar+',
}
}
static examples = [
{
namedParams: { clojar: 'prismic' },
staticPreview: this.render({ downloads: 117 }),
},
]
static get examples() {
return [
{
namedParams: { clojar: 'prismic' },
staticPreview: this.render({ downloads: 117 }),
},
]
}
static get defaultBadgeData() {
return { label: 'downloads' }
}
static defaultBadgeData = { label: 'downloads' }
static render({ downloads }) {
return {

View File

@@ -10,37 +10,24 @@ const queryParamSchema = Joi.object({
}).required()
class ClojarsVersionService extends BaseClojarsService {
static get category() {
return 'version'
}
static category = 'version'
static route = { base: 'clojars/v', pattern: ':clojar+', queryParamSchema }
static get route() {
return {
base: 'clojars/v',
pattern: ':clojar+',
queryParamSchema,
}
}
static examples = [
{
title: 'Clojars Version',
namedParams: { clojar: 'prismic' },
staticPreview: this.render({ clojar: 'clojar', version: '1.2' }),
},
{
title: 'Clojars Version (including pre-releases)',
namedParams: { clojar: 'prismic' },
queryParams: { include_prereleases: null },
staticPreview: this.render({ clojar: 'clojar', version: '1.2' }),
},
]
static get examples() {
return [
{
title: 'Clojars Version',
namedParams: { clojar: 'prismic' },
staticPreview: this.render({ clojar: 'clojar', version: '1.2' }),
},
{
title: 'Clojars Version (including pre-releases)',
namedParams: { clojar: 'prismic' },
queryParams: { include_prereleases: null },
staticPreview: this.render({ clojar: 'clojar', version: '1.2' }),
},
]
}
static get defaultBadgeData() {
return { label: 'clojars' }
}
static defaultBadgeData = { label: 'clojars' }
static render({ clojar, version }) {
return {

View File

@@ -13,30 +13,18 @@ const schema = Joi.object({
}).required()
module.exports = class CocoapodsDocs extends BaseJsonService {
static get category() {
return 'analysis'
}
static category = 'analysis'
static route = { base: 'cocoapods/metrics/doc-percent', pattern: ':spec' }
static get route() {
return {
base: 'cocoapods/metrics/doc-percent',
pattern: ':spec',
}
}
static examples = [
{
title: 'Cocoapods doc percentage',
namedParams: { spec: 'AFNetworking' },
staticPreview: this.render({ percentage: 94 }),
},
]
static get examples() {
return [
{
title: 'Cocoapods doc percentage',
namedParams: { spec: 'AFNetworking' },
staticPreview: this.render({ percentage: 94 }),
},
]
}
static get defaultBadgeData() {
return { label: 'docs' }
}
static defaultBadgeData = { label: 'docs' }
static render({ percentage }) {
return {

View File

@@ -3,30 +3,18 @@
const BaseCocoaPodsService = require('./cocoapods-base')
module.exports = class CocoapodsLicense extends BaseCocoaPodsService {
static get category() {
return 'license'
}
static category = 'license'
static route = { base: 'cocoapods/l', pattern: ':spec' }
static get route() {
return {
base: 'cocoapods/l',
pattern: ':spec',
}
}
static examples = [
{
title: 'Cocoapods',
namedParams: { spec: 'AFNetworking' },
staticPreview: this.render({ license: 'MIT' }),
},
]
static get examples() {
return [
{
title: 'Cocoapods',
namedParams: { spec: 'AFNetworking' },
staticPreview: this.render({ license: 'MIT' }),
},
]
}
static get defaultBadgeData() {
return { label: 'license' }
}
static defaultBadgeData = { label: 'license' }
static render({ license }) {
if (license) {

View File

@@ -3,32 +3,20 @@
const BaseCocoaPodsService = require('./cocoapods-base')
module.exports = class CocoapodsPlatform extends BaseCocoaPodsService {
static get category() {
return 'platform-support'
}
static category = 'platform-support'
static route = { base: 'cocoapods/p', pattern: ':spec' }
static get route() {
return {
base: 'cocoapods/p',
pattern: ':spec',
}
}
static examples = [
{
title: 'Cocoapods platforms',
namedParams: { spec: 'AFNetworking' },
staticPreview: this.render({
platforms: ['ios', 'osx', 'watchos', 'tvos'],
}),
},
]
static get examples() {
return [
{
title: 'Cocoapods platforms',
namedParams: { spec: 'AFNetworking' },
staticPreview: this.render({
platforms: ['ios', 'osx', 'watchos', 'tvos'],
}),
},
]
}
static get defaultBadgeData() {
return { label: 'platform' }
}
static defaultBadgeData = { label: 'platform' }
static render({ platforms }) {
return {

View File

@@ -4,30 +4,18 @@ const { renderVersionBadge } = require('../version')
const BaseCocoaPodsService = require('./cocoapods-base')
module.exports = class CocoapodsVersion extends BaseCocoaPodsService {
static get category() {
return 'version'
}
static category = 'version'
static route = { base: 'cocoapods/v', pattern: ':spec' }
static get route() {
return {
base: 'cocoapods/v',
pattern: ':spec',
}
}
static examples = [
{
title: 'Cocoapods',
namedParams: { spec: 'AFNetworking' },
staticPreview: renderVersionBadge({ version: 'v3.2.1' }),
},
]
static get examples() {
return [
{
title: 'Cocoapods',
namedParams: { spec: 'AFNetworking' },
staticPreview: renderVersionBadge({ version: 'v3.2.1' }),
},
]
}
static get defaultBadgeData() {
return { label: 'pod' }
}
static defaultBadgeData = { label: 'pod' }
async handle({ spec }) {
const { version } = await this.fetch({ spec })