convert [homebrew hsts itunes jenkins jetbrains] classes to static props (#5582)

* convert [homebrew,hsts,itunes,jenkins,jetbrains] classes to static props

* Run the prettier across the files

* Updated the correct values in logos.spec.js

* revert back the logos.spec.js changes

Co-authored-by: Jabbar Memon <jabbar@zoop.one>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
Jabbar Memon
2020-09-20 21:37:59 +05:30
committed by GitHub
parent 4c34b14b4a
commit b61fc8291c
11 changed files with 192 additions and 287 deletions

View File

@@ -9,30 +9,18 @@ const schema = Joi.object({
}).required() }).required()
module.exports = class HomebrewCask extends BaseJsonService { module.exports = class HomebrewCask extends BaseJsonService {
static get category() { static category = 'version'
return 'version' static route = { base: 'homebrew/cask/v', pattern: ':cask' }
}
static get route() { static examples = [
return { {
base: 'homebrew/cask/v', title: 'homebrew cask',
pattern: ':cask', namedParams: { cask: 'iterm2' },
} staticPreview: renderVersionBadge({ version: 'v3.2.5' }),
} },
]
static get examples() { static defaultBadgeData = { label: 'homebrew cask' }
return [
{
title: 'homebrew cask',
namedParams: { cask: 'iterm2' },
staticPreview: renderVersionBadge({ version: 'v3.2.5' }),
},
]
}
static get defaultBadgeData() {
return { label: 'homebrew cask' }
}
async fetch({ cask }) { async fetch({ cask }) {
return this._requestJson({ return this._requestJson({

View File

@@ -11,30 +11,19 @@ const schema = Joi.object({
}).required() }).required()
module.exports = class Homebrew extends BaseJsonService { module.exports = class Homebrew extends BaseJsonService {
static get category() { static category = 'version'
return 'version'
}
static get route() { static route = { base: 'homebrew/v', pattern: ':formula' }
return {
base: 'homebrew/v',
pattern: ':formula',
}
}
static get examples() { static examples = [
return [ {
{ title: 'homebrew',
title: 'homebrew', namedParams: { formula: 'cake' },
namedParams: { formula: 'cake' }, staticPreview: renderVersionBadge({ version: 'v0.32.0' }),
staticPreview: renderVersionBadge({ version: 'v0.32.0' }), },
}, ]
]
}
static get defaultBadgeData() { static defaultBadgeData = { label: 'homebrew' }
return { label: 'homebrew' }
}
async fetch({ formula }) { async fetch({ formula }) {
return this._requestJson({ return this._requestJson({

View File

@@ -22,28 +22,22 @@ const documentation = `
` `
module.exports = class HSTS extends BaseJsonService { module.exports = class HSTS extends BaseJsonService {
static get category() { static category = 'monitoring'
return 'monitoring'
static route = {
base: 'hsts/preload',
pattern: ':domain',
} }
static get route() { static examples = [
return { {
base: 'hsts/preload', title: 'Chromium HSTS preload',
pattern: ':domain', namedParams: { domain: 'github.com' },
} staticPreview: this.render({ status: 'preloaded' }),
} keywords: ['security'],
documentation,
static get examples() { },
return [ ]
{
title: 'Chromium HSTS preload',
namedParams: { domain: 'github.com' },
staticPreview: this.render({ status: 'preloaded' }),
keywords: ['security'],
documentation,
},
]
}
static render({ status }) { static render({ status }) {
let color = 'red' let color = 'red'

View File

@@ -13,30 +13,22 @@ const schema = Joi.object({
}).required() }).required()
module.exports = class Itunes extends BaseJsonService { module.exports = class Itunes extends BaseJsonService {
static get category() { static category = 'version'
return 'version'
static route = {
base: 'itunes/v',
pattern: ':bundleId',
} }
static get route() { static examples = [
return { {
base: 'itunes/v', title: 'iTunes App Store',
pattern: ':bundleId', namedParams: { bundleId: '803453959' },
} staticPreview: renderVersionBadge({ version: 'v3.3.3' }),
} },
]
static get examples() { static defaultBadgeData = { label: 'itunes app store' }
return [
{
title: 'iTunes App Store',
namedParams: { bundleId: '803453959' },
staticPreview: renderVersionBadge({ version: 'v3.3.3' }),
},
]
}
static get defaultBadgeData() {
return { label: 'itunes app store' }
}
async fetch({ bundleId }) { async fetch({ bundleId }) {
return this._requestJson({ return this._requestJson({

View File

@@ -34,36 +34,26 @@ const schema = Joi.object({
}).required() }).required()
module.exports = class JenkinsBuild extends JenkinsBase { module.exports = class JenkinsBuild extends JenkinsBase {
static get category() { static category = 'build'
return 'build'
static route = {
base: 'jenkins',
pattern: 'build',
queryParamSchema,
} }
static get route() { static examples = [
return { {
base: 'jenkins', title: 'Jenkins',
pattern: 'build', namedParams: {},
queryParamSchema, queryParams: {
} jobUrl: 'https://wso2.org/jenkins/view/All%20Builds/job/archetypes',
}
static get examples() {
return [
{
title: 'Jenkins',
namedParams: {},
queryParams: {
jobUrl: 'https://wso2.org/jenkins/view/All%20Builds/job/archetypes',
},
staticPreview: renderBuildStatusBadge({ status: 'passing' }),
}, },
] staticPreview: renderBuildStatusBadge({ status: 'passing' }),
} },
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'build' }
return {
label: 'build',
}
}
static render({ status }) { static render({ status }) {
if (status === 'unstable') { if (status === 'unstable') {

View File

@@ -41,48 +41,40 @@ module.exports = class JenkinsPluginInstalls extends BaseJsonService {
} }
} }
static get category() { static category = 'downloads'
return 'downloads'
static route = {
base: 'jenkins/plugin/i',
pattern: ':plugin/:version?',
} }
static get route() { static examples = [
return { {
base: 'jenkins/plugin/i', title: 'Jenkins Plugin installs',
pattern: ':plugin/:version?', pattern: ':plugin',
} namedParams: {
} plugin: 'view-job-filters',
static get examples() {
return [
{
title: 'Jenkins Plugin installs',
pattern: ':plugin',
namedParams: {
plugin: 'view-job-filters',
},
staticPreview: this.render({
label: this._getLabel(),
installs: 10247,
}),
}, },
{ staticPreview: this.render({
title: 'Jenkins Plugin installs (version)', label: this._getLabel(),
pattern: ':plugin/:version', installs: 10247,
namedParams: { }),
plugin: 'view-job-filters', },
version: '1.26', {
}, title: 'Jenkins Plugin installs (version)',
staticPreview: this.render({ pattern: ':plugin/:version',
label: this._getLabel('1.26'), namedParams: {
installs: 955, plugin: 'view-job-filters',
}), version: '1.26',
}, },
] staticPreview: this.render({
} label: this._getLabel('1.26'),
installs: 955,
}),
},
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'installs' }
return { label: 'installs' }
}
static render({ label, installs }) { static render({ label, installs }) {
return { return {

View File

@@ -6,36 +6,28 @@ const { renderVersionBadge } = require('../version')
const { BaseService, NotFound } = require('..') const { BaseService, NotFound } = require('..')
module.exports = class JenkinsPluginVersion extends BaseService { module.exports = class JenkinsPluginVersion extends BaseService {
static get category() { static category = 'version'
return 'version'
static route = {
base: 'jenkins/plugin/v',
pattern: ':plugin',
} }
static get route() { static examples = [
return { {
base: 'jenkins/plugin/v', title: 'Jenkins Plugins',
pattern: ':plugin', namedParams: {
} plugin: 'blueocean',
}
static get examples() {
return [
{
title: 'Jenkins Plugins',
namedParams: {
plugin: 'blueocean',
},
staticPreview: {
label: 'plugin',
message: 'v1.10.1',
color: 'blue',
},
}, },
] staticPreview: {
} label: 'plugin',
message: 'v1.10.1',
color: 'blue',
},
},
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'plugin' }
return { label: 'plugin' }
}
static render({ version }) { static render({ version }) {
return renderVersionBadge({ version }) return renderVersionBadge({ version })

View File

@@ -36,47 +36,37 @@ const schema = Joi.object({
}).required() }).required()
module.exports = class JenkinsTests extends JenkinsBase { module.exports = class JenkinsTests extends JenkinsBase {
static get category() { static category = 'build'
return 'build'
static route = {
base: 'jenkins',
pattern: 'tests',
queryParamSchema: queryParamSchema.concat(testResultQueryParamSchema),
} }
static get route() { static examples = [
return { {
base: 'jenkins', title: 'Jenkins tests',
pattern: 'tests', namedParams: {},
queryParamSchema: queryParamSchema.concat(testResultQueryParamSchema), queryParams: {
} compact_message: null,
} passed_label: 'passed',
failed_label: 'failed',
static get examples() { skipped_label: 'skipped',
return [ jobUrl: 'https://jenkins.sqlalchemy.org/job/alembic_coverage',
{
title: 'Jenkins tests',
namedParams: {},
queryParams: {
compact_message: null,
passed_label: 'passed',
failed_label: 'failed',
skipped_label: 'skipped',
jobUrl: 'https://jenkins.sqlalchemy.org/job/alembic_coverage',
},
staticPreview: this.render({
passed: 477,
failed: 2,
skipped: 0,
total: 479,
isCompact: false,
}),
documentation,
}, },
] staticPreview: this.render({
} passed: 477,
failed: 2,
skipped: 0,
total: 479,
isCompact: false,
}),
documentation,
},
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'tests' }
return {
label: 'tests',
}
}
static render({ static render({
passed, passed,

View File

@@ -23,28 +23,22 @@ const schema = Joi.object({
}).required() }).required()
module.exports = class JetbrainsDownloads extends JetbrainsBase { module.exports = class JetbrainsDownloads extends JetbrainsBase {
static get category() { static category = 'downloads'
return 'downloads'
static route = {
base: 'jetbrains/plugin/d',
pattern: ':pluginId',
} }
static get route() { static examples = [
return { {
base: 'jetbrains/plugin/d', title: 'JetBrains IntelliJ plugins',
pattern: ':pluginId', namedParams: {
} pluginId: '1347-scala',
}
static get examples() {
return [
{
title: 'JetBrains IntelliJ plugins',
namedParams: {
pluginId: '1347-scala',
},
staticPreview: this.render({ downloads: 10200000 }),
}, },
] staticPreview: this.render({ downloads: 10200000 }),
} },
]
static render({ downloads }) { static render({ downloads }) {
return { return {

View File

@@ -24,47 +24,39 @@ const schema = Joi.object({
}).required() }).required()
module.exports = class JetbrainsRating extends JetbrainsBase { module.exports = class JetbrainsRating extends JetbrainsBase {
static get category() { static category = 'rating'
return 'rating'
static route = {
base: 'jetbrains/plugin/r',
pattern: ':format(rating|stars)/:pluginId',
} }
static get route() { static examples = [
return { {
base: 'jetbrains/plugin/r', title: 'JetBrains IntelliJ Plugins',
pattern: ':format(rating|stars)/:pluginId', pattern: 'rating/:pluginId',
} namedParams: {
} pluginId: '11941-automatic-power-saver',
static get examples() {
return [
{
title: 'JetBrains IntelliJ Plugins',
pattern: 'rating/:pluginId',
namedParams: {
pluginId: '11941-automatic-power-saver',
},
staticPreview: this.render({
rating: '4.5',
format: 'rating',
}),
}, },
{ staticPreview: this.render({
title: 'JetBrains IntelliJ Plugins', rating: '4.5',
pattern: 'stars/:pluginId', format: 'rating',
namedParams: { }),
pluginId: '11941-automatic-power-saver', },
}, {
staticPreview: this.render({ title: 'JetBrains IntelliJ Plugins',
rating: '4.5', pattern: 'stars/:pluginId',
format: 'stars', namedParams: {
}), pluginId: '11941-automatic-power-saver',
}, },
] staticPreview: this.render({
} rating: '4.5',
format: 'stars',
}),
},
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'rating' }
return { label: 'rating' }
}
static render({ rating, format }) { static render({ rating, format }) {
const message = const message =

View File

@@ -21,32 +21,24 @@ const schema = Joi.object({
}).required() }).required()
module.exports = class JetbrainsVersion extends JetbrainsBase { module.exports = class JetbrainsVersion extends JetbrainsBase {
static get category() { static category = 'version'
return 'version'
static route = {
base: 'jetbrains/plugin/v',
pattern: ':pluginId',
} }
static get route() { static examples = [
return { {
base: 'jetbrains/plugin/v', title: 'JetBrains IntelliJ Plugins',
pattern: ':pluginId', namedParams: {
} pluginId: '9630-a8translate',
}
static get examples() {
return [
{
title: 'JetBrains IntelliJ Plugins',
namedParams: {
pluginId: '9630-a8translate',
},
staticPreview: this.render({ version: 'v1.7' }),
}, },
] staticPreview: this.render({ version: 'v1.7' }),
} },
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'jetbrains plugin' }
return { label: 'jetbrains plugin' }
}
static render({ version }) { static render({ version }) {
return renderVersionBadge({ version }) return renderVersionBadge({ version })