refactor(github): convert some clasess to static fields (#5556)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
@@ -11,35 +11,26 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class GithubAllContributorsService extends ConditionalGithubAuthV3Service {
|
||||
static get category() {
|
||||
return 'activity'
|
||||
static category = 'activity'
|
||||
static route = {
|
||||
base: 'github/all-contributors',
|
||||
pattern: ':user/:repo/:branch*',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'github/all-contributors',
|
||||
pattern: ':user/:repo/:branch*',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Github All Contributors',
|
||||
namedParams: {
|
||||
repo: 'all-contributors',
|
||||
user: 'all-contributors',
|
||||
branch: 'master',
|
||||
},
|
||||
staticPreview: this.render({ contributorCount: 66 }),
|
||||
documentation,
|
||||
static examples = [
|
||||
{
|
||||
title: 'Github All Contributors',
|
||||
namedParams: {
|
||||
repo: 'all-contributors',
|
||||
user: 'all-contributors',
|
||||
branch: 'master',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ contributorCount: 66 }),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'all contributors' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'all contributors' }
|
||||
|
||||
static render({ contributorCount }) {
|
||||
return renderContributorBadge({ contributorCount })
|
||||
|
||||
@@ -5,36 +5,25 @@ const { BaseGithubLanguage } = require('./github-languages-base')
|
||||
const { documentation } = require('./github-helpers')
|
||||
|
||||
module.exports = class GithubCodeSize extends BaseGithubLanguage {
|
||||
static get category() {
|
||||
return 'size'
|
||||
static category = 'size'
|
||||
static route = {
|
||||
base: 'github/languages/code-size',
|
||||
pattern: ':user/:repo',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'github/languages/code-size',
|
||||
pattern: ':user/:repo',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'GitHub code size in bytes',
|
||||
namedParams: {
|
||||
user: 'badges',
|
||||
repo: 'shields',
|
||||
},
|
||||
staticPreview: this.render({ size: 1625000 }),
|
||||
documentation,
|
||||
static examples = [
|
||||
{
|
||||
title: 'GitHub code size in bytes',
|
||||
namedParams: {
|
||||
user: 'badges',
|
||||
repo: 'shields',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ size: 1625000 }),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'code size',
|
||||
}
|
||||
}
|
||||
static defaultBadgeData = { label: 'code size' }
|
||||
|
||||
static render({ size }) {
|
||||
return {
|
||||
|
||||
@@ -15,37 +15,25 @@ const schema = Joi.array()
|
||||
.required()
|
||||
|
||||
module.exports = class GithubCommitActivity extends GithubAuthV3Service {
|
||||
static get category() {
|
||||
return 'activity'
|
||||
static category = 'activity'
|
||||
static route = {
|
||||
base: 'github/commit-activity',
|
||||
pattern: ':interval(y|m|4w|w)/:user/:repo',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'github/commit-activity',
|
||||
pattern: ':interval(y|m|4w|w)/:user/:repo',
|
||||
}
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'GitHub commit activity',
|
||||
// Override the pattern to omit the deprecated interval "4w".
|
||||
pattern: ':interval(y|m|w)/:user/:repo',
|
||||
namedParams: { interval: 'm', user: 'eslint', repo: 'eslint' },
|
||||
staticPreview: this.render({ interval: 'm', commitCount: 457 }),
|
||||
keywords: ['commits'],
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'GitHub commit activity',
|
||||
// Override the pattern to omit the deprecated interval "4w".
|
||||
pattern: ':interval(y|m|w)/:user/:repo',
|
||||
namedParams: { interval: 'm', user: 'eslint', repo: 'eslint' },
|
||||
staticPreview: this.render({ interval: 'm', commitCount: 457 }),
|
||||
keywords: ['commits'],
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'commit activity',
|
||||
color: 'blue',
|
||||
}
|
||||
}
|
||||
static defaultBadgeData = { label: 'commit activity', color: 'blue' }
|
||||
|
||||
static render({ interval, commitCount }) {
|
||||
const intervalLabel = {
|
||||
|
||||
@@ -11,42 +11,31 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class GithubCommitStatus extends GithubAuthV3Service {
|
||||
static get category() {
|
||||
return 'issue-tracking'
|
||||
static category = 'issue-tracking'
|
||||
static route = {
|
||||
base: 'github/commit-status',
|
||||
pattern: ':user/:repo/:branch/:commit',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'github/commit-status',
|
||||
pattern: ':user/:repo/:branch/:commit',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'GitHub commit merge status',
|
||||
namedParams: {
|
||||
user: 'badges',
|
||||
repo: 'shields',
|
||||
branch: 'master',
|
||||
commit: '5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
isInBranch: true,
|
||||
branch: 'master',
|
||||
}),
|
||||
keywords: ['branch'],
|
||||
documentation,
|
||||
static examples = [
|
||||
{
|
||||
title: 'GitHub commit merge status',
|
||||
namedParams: {
|
||||
user: 'badges',
|
||||
repo: 'shields',
|
||||
branch: 'master',
|
||||
commit: '5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({
|
||||
isInBranch: true,
|
||||
branch: 'master',
|
||||
}),
|
||||
keywords: ['branch'],
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'commit status',
|
||||
}
|
||||
}
|
||||
static defaultBadgeData = { label: 'commit status' }
|
||||
|
||||
static render({ isInBranch, branch }) {
|
||||
if (isInBranch) {
|
||||
|
||||
Reference in New Issue
Block a user