diff --git a/services/github/github-forks.service.js b/services/github/github-forks.service.js index 97a9bcae49b58a8ddc0f88d85b7a910acbf2afa2..23e8ec33a0ad1f8263ce0048b6fca1c338c3002a 100644 --- a/services/github/github-forks.service.js +++ b/services/github/github-forks.service.js @@ -16,49 +16,33 @@ const schema = Joi.object({ }).required() module.exports = class GithubForks extends GithubAuthV4Service { - static get category() { - return 'social' - } - - static get route() { - return { - base: 'github/forks', - pattern: ':user/:repo', - } - } - - static get examples() { - return [ - { - title: 'GitHub forks', - namedParams: { - user: 'badges', - repo: 'shields', - }, - // TODO: This is currently a literal, as `staticPreview` doesn't - // support `link`. - staticPreview: { - label: 'Fork', - message: '150', - style: 'social', - }, - // staticPreview: { - // ...this.render({ user: 'badges', repo: 'shields', forkCount: 150 }), - // label: 'fork', - // style: 'social', - // }, - queryParams: { label: 'Fork' }, - documentation, + static category = 'social' + static route = { base: 'github/forks', pattern: ':user/:repo' } + static examples = [ + { + title: 'GitHub forks', + namedParams: { + user: 'badges', + repo: 'shields', }, - ] - } + // TODO: This is currently a literal, as `staticPreview` doesn't + // support `link`. + staticPreview: { + label: 'Fork', + message: '150', + style: 'social', + }, + // staticPreview: { + // ...this.render({ user: 'badges', repo: 'shields', forkCount: 150 }), + // label: 'fork', + // style: 'social', + // }, + queryParams: { label: 'Fork' }, + documentation, + }, + ] - static get defaultBadgeData() { - return { - label: 'forks', - namedLogo: 'github', - } - } + static defaultBadgeData = { label: 'forks', namedLogo: 'github' } static render({ user, repo, forkCount }) { return { diff --git a/services/github/github-go-mod.service.js b/services/github/github-go-mod.service.js index f958299cb6768d9e6b294b6f6b3f0c5fdeb020bf..b5c82a37b2f14bd2e5d102b6c7be3679cf60faae 100644 --- a/services/github/github-go-mod.service.js +++ b/services/github/github-go-mod.service.js @@ -16,64 +16,55 @@ const goVersionRegExp = new RegExp('^go (.+)$', 'm') const keywords = ['golang'] module.exports = class GithubGoModGoVersion extends ConditionalGithubAuthV3Service { - static get category() { - return 'version' + static category = 'version' + static route = { + base: 'github/go-mod/go-version', + pattern: ':user/:repo/:branch*', + queryParamSchema, } - static get route() { - return { - base: 'github/go-mod/go-version', - pattern: ':user/:repo/:branch*', - queryParamSchema, - } - } - - static get examples() { - return [ - { - title: 'GitHub go.mod Go version', - pattern: ':user/:repo', - namedParams: { user: 'gohugoio', repo: 'hugo' }, - staticPreview: this.render({ version: '1.12' }), - documentation, - keywords, - }, - { - title: 'GitHub go.mod Go version (branch)', - pattern: ':user/:repo/:branch', - namedParams: { - user: 'gohugoio', - repo: 'hugo', - branch: 'master', - }, - staticPreview: this.render({ version: '1.12', branch: 'master' }), - documentation, - keywords, + static examples = [ + { + title: 'GitHub go.mod Go version', + pattern: ':user/:repo', + namedParams: { user: 'gohugoio', repo: 'hugo' }, + staticPreview: this.render({ version: '1.12' }), + documentation, + keywords, + }, + { + title: 'GitHub go.mod Go version (branch)', + pattern: ':user/:repo/:branch', + namedParams: { + user: 'gohugoio', + repo: 'hugo', + branch: 'master', }, - { - title: 'GitHub go.mod Go version (subfolder of monorepo)', - pattern: ':user/:repo', - namedParams: { user: 'golang', repo: 'go' }, - queryParams: { filename: 'src/go.mod' }, - staticPreview: this.render({ version: '1.14' }), - documentation, - keywords, - }, - { - title: 'GitHub go.mod Go version (branch & subfolder of monorepo)', - pattern: ':user/:repo/:branch', - namedParams: { user: 'golang', repo: 'go', branch: 'master' }, - queryParams: { filename: 'src/go.mod' }, - staticPreview: this.render({ version: '1.14' }), - documentation, - keywords, - }, - ] - } + staticPreview: this.render({ version: '1.12', branch: 'master' }), + documentation, + keywords, + }, + { + title: 'GitHub go.mod Go version (subfolder of monorepo)', + pattern: ':user/:repo', + namedParams: { user: 'golang', repo: 'go' }, + queryParams: { filename: 'src/go.mod' }, + staticPreview: this.render({ version: '1.14' }), + documentation, + keywords, + }, + { + title: 'GitHub go.mod Go version (branch & subfolder of monorepo)', + pattern: ':user/:repo/:branch', + namedParams: { user: 'golang', repo: 'go', branch: 'master' }, + queryParams: { filename: 'src/go.mod' }, + staticPreview: this.render({ version: '1.14' }), + documentation, + keywords, + }, + ] - static get defaultBadgeData() { - return { label: 'Go' } - } + static defaultBadgeData = { label: 'Go' } static render({ version, branch }) { return renderVersionBadge({ diff --git a/services/github/github-issue-detail.service.js b/services/github/github-issue-detail.service.js index 7e344a49fe48f9fba798f4892a930d88f912327c..4c5a6c05fbf85d8a5ff6c7857e6410093f189fdf 100644 --- a/services/github/github-issue-detail.service.js +++ b/services/github/github-issue-detail.service.js @@ -153,54 +153,45 @@ const propertyMap = { } module.exports = class GithubIssueDetail extends GithubAuthV3Service { - static get category() { - return 'issue-tracking' + static category = 'issue-tracking' + static route = { + base: 'github', + pattern: + ':issueKind(issues|pulls)/detail/:property(state|title|author|label|comments|age|last-update)/:user/:repo/:number([0-9]+)', } - static get route() { - return { - base: 'github', - pattern: - ':issueKind(issues|pulls)/detail/:property(state|title|author|label|comments|age|last-update)/:user/:repo/:number([0-9]+)', - } - } - - static get examples() { - return [ - { - title: 'GitHub issue/pull request detail', - namedParams: { - issueKind: 'issues', - property: 'state', - user: 'badges', - repo: 'shields', - number: '979', - }, - staticPreview: this.render({ - property: 'state', - value: { state: 'closed' }, - isPR: false, - number: '979', - }), - keywords: [ - 'state', - 'title', - 'author', - 'label', - 'comments', - 'age', - 'last update', - ], - documentation, + static examples = [ + { + title: 'GitHub issue/pull request detail', + namedParams: { + issueKind: 'issues', + property: 'state', + user: 'badges', + repo: 'shields', + number: '979', }, - ] - } - - static get defaultBadgeData() { - return { - label: 'issue/pull request', - color: 'informational', - } + staticPreview: this.render({ + property: 'state', + value: { state: 'closed' }, + isPR: false, + number: '979', + }), + keywords: [ + 'state', + 'title', + 'author', + 'label', + 'comments', + 'age', + 'last update', + ], + documentation, + }, + ] + + static defaultBadgeData = { + label: 'issue/pull request', + color: 'informational', } static render({ property, value, isPR, number }) { diff --git a/services/github/github-issues.service.js b/services/github/github-issues.service.js index 52e580dfa1bd9a30752c8647941b3d6b3306b576..5c949f4135a0d3e56d8b3910b225bc8b80ceaaa6 100644 --- a/services/github/github-issues.service.js +++ b/services/github/github-issues.service.js @@ -38,207 +38,195 @@ const isClosedVariant = { } module.exports = class GithubIssues extends GithubAuthV4Service { - static get category() { - return 'issue-tracking' + static category = 'issue-tracking' + static route = { + base: 'github', + pattern: + ':variant(issues|issues-closed|issues-pr|issues-pr-closed):raw(-raw)?/:user/:repo/:label*', } - static get route() { - return { - base: 'github', - pattern: - ':variant(issues|issues-closed|issues-pr|issues-pr-closed):raw(-raw)?/:user/:repo/:label*', - } - } - - static get examples() { - return [ - { - title: 'GitHub issues', - pattern: 'issues/:user/:repo', - namedParams: { - user: 'badges', - repo: 'shields', - }, - staticPreview: { - label: 'issues', - message: '167 open', - color: 'yellow', - }, - documentation, + static examples = [ + { + title: 'GitHub issues', + pattern: 'issues/:user/:repo', + namedParams: { + user: 'badges', + repo: 'shields', }, - { - title: 'GitHub issues', - pattern: 'issues-raw/:user/:repo', - namedParams: { - user: 'badges', - repo: 'shields', - }, - staticPreview: { - label: 'open issues', - message: '167', - color: 'yellow', - }, - documentation, + staticPreview: { + label: 'issues', + message: '167 open', + color: 'yellow', }, - { - title: 'GitHub issues by-label', - pattern: 'issues/:user/:repo/:label', - namedParams: { - user: 'badges', - repo: 'shields', - label: 'service-badge', - }, - staticPreview: { - label: 'service-badge issues', - message: '110 open', - color: 'yellow', - }, - documentation, + documentation, + }, + { + title: 'GitHub issues', + pattern: 'issues-raw/:user/:repo', + namedParams: { + user: 'badges', + repo: 'shields', }, - { - title: 'GitHub issues by-label', - pattern: 'issues-raw/:user/:repo/:label', - namedParams: { - user: 'badges', - repo: 'shields', - label: 'service-badge', - }, - staticPreview: { - label: 'open service-badge issues', - message: '110', - color: 'yellow', - }, - documentation, + staticPreview: { + label: 'open issues', + message: '167', + color: 'yellow', }, - { - title: 'GitHub closed issues', - pattern: 'issues-closed/:user/:repo', - namedParams: { - user: 'badges', - repo: 'shields', - }, - staticPreview: { - label: 'issues', - message: '899 closed', - color: 'yellow', - }, - documentation, + documentation, + }, + { + title: 'GitHub issues by-label', + pattern: 'issues/:user/:repo/:label', + namedParams: { + user: 'badges', + repo: 'shields', + label: 'service-badge', }, - { - title: 'GitHub closed issues', - pattern: 'issues-closed-raw/:user/:repo', - namedParams: { - user: 'badges', - repo: 'shields', - }, - staticPreview: { - label: 'closed issues', - message: '899', - color: 'yellow', - }, - documentation, + staticPreview: { + label: 'service-badge issues', + message: '110 open', + color: 'yellow', }, - { - title: 'GitHub pull requests', - pattern: 'issues-pr/:user/:repo', - namedParams: { - user: 'cdnjs', - repo: 'cdnjs', - }, - staticPreview: { - label: 'pull requests', - message: '136 open', - color: 'yellow', - }, - keywords: ['pullrequest', 'pr'], - documentation, + documentation, + }, + { + title: 'GitHub issues by-label', + pattern: 'issues-raw/:user/:repo/:label', + namedParams: { + user: 'badges', + repo: 'shields', + label: 'service-badge', }, - { - title: 'GitHub pull requests', - pattern: 'issues-pr-raw/:user/:repo', - namedParams: { - user: 'cdnjs', - repo: 'cdnjs', - }, - staticPreview: { - label: 'open pull requests', - message: '136', - color: 'yellow', - }, - keywords: ['pullrequest', 'pr'], - documentation, + staticPreview: { + label: 'open service-badge issues', + message: '110', + color: 'yellow', }, - { - title: 'GitHub closed pull requests', - pattern: 'issues-pr-closed/:user/:repo', - namedParams: { - user: 'cdnjs', - repo: 'cdnjs', - }, - staticPreview: { - label: 'pull requests', - message: '7k closed', - color: 'yellow', - }, - keywords: ['pullrequest', 'pr'], - documentation, + documentation, + }, + { + title: 'GitHub closed issues', + pattern: 'issues-closed/:user/:repo', + namedParams: { + user: 'badges', + repo: 'shields', }, - { - title: 'GitHub closed pull requests', - pattern: 'issues-pr-closed-raw/:user/:repo', - namedParams: { - user: 'cdnjs', - repo: 'cdnjs', - }, - staticPreview: { - label: 'closed pull requests', - message: '7k', - color: 'yellow', - }, - keywords: ['pullrequest', 'pr'], - documentation, + staticPreview: { + label: 'issues', + message: '899 closed', + color: 'yellow', }, - { - title: 'GitHub pull requests by-label', - pattern: 'issues-pr/:user/:repo/:label', - namedParams: { - user: 'badges', - repo: 'shields', - label: 'service-badge', - }, - staticPreview: { - label: 'service-badge pull requests', - message: '8 open', - color: 'yellow', - }, - keywords: ['pullrequests', 'pr'], - documentation, + documentation, + }, + { + title: 'GitHub closed issues', + pattern: 'issues-closed-raw/:user/:repo', + namedParams: { + user: 'badges', + repo: 'shields', }, - { - title: 'GitHub pull requests by-label', - pattern: 'issues-pr-raw/:user/:repo/:label', - namedParams: { - user: 'badges', - repo: 'shields', - label: 'service-badge', - }, - staticPreview: { - label: 'open service-badge pull requests', - message: '8', - color: 'yellow', - }, - keywords: ['pullrequests', 'pr'], - documentation, + staticPreview: { + label: 'closed issues', + message: '899', + color: 'yellow', }, - ] - } + documentation, + }, + { + title: 'GitHub pull requests', + pattern: 'issues-pr/:user/:repo', + namedParams: { + user: 'cdnjs', + repo: 'cdnjs', + }, + staticPreview: { + label: 'pull requests', + message: '136 open', + color: 'yellow', + }, + keywords: ['pullrequest', 'pr'], + documentation, + }, + { + title: 'GitHub pull requests', + pattern: 'issues-pr-raw/:user/:repo', + namedParams: { + user: 'cdnjs', + repo: 'cdnjs', + }, + staticPreview: { + label: 'open pull requests', + message: '136', + color: 'yellow', + }, + keywords: ['pullrequest', 'pr'], + documentation, + }, + { + title: 'GitHub closed pull requests', + pattern: 'issues-pr-closed/:user/:repo', + namedParams: { + user: 'cdnjs', + repo: 'cdnjs', + }, + staticPreview: { + label: 'pull requests', + message: '7k closed', + color: 'yellow', + }, + keywords: ['pullrequest', 'pr'], + documentation, + }, + { + title: 'GitHub closed pull requests', + pattern: 'issues-pr-closed-raw/:user/:repo', + namedParams: { + user: 'cdnjs', + repo: 'cdnjs', + }, + staticPreview: { + label: 'closed pull requests', + message: '7k', + color: 'yellow', + }, + keywords: ['pullrequest', 'pr'], + documentation, + }, + { + title: 'GitHub pull requests by-label', + pattern: 'issues-pr/:user/:repo/:label', + namedParams: { + user: 'badges', + repo: 'shields', + label: 'service-badge', + }, + staticPreview: { + label: 'service-badge pull requests', + message: '8 open', + color: 'yellow', + }, + keywords: ['pullrequests', 'pr'], + documentation, + }, + { + title: 'GitHub pull requests by-label', + pattern: 'issues-pr-raw/:user/:repo/:label', + namedParams: { + user: 'badges', + repo: 'shields', + label: 'service-badge', + }, + staticPreview: { + label: 'open service-badge pull requests', + message: '8', + color: 'yellow', + }, + keywords: ['pullrequests', 'pr'], + documentation, + }, + ] - static get defaultBadgeData() { - return { - label: 'issues', - color: 'informational', - } - } + static defaultBadgeData = { label: 'issues', color: 'informational' } static render({ isPR, isClosed, issueCount, raw, label }) { const state = isClosed ? 'closed' : 'open' diff --git a/services/github/github-labels.service.js b/services/github/github-labels.service.js index 056c2ffda4b3e977ff05e1e798d1b534351b188a..91f75bb192bcde7720fddb318bc4f5a2dd273c28 100644 --- a/services/github/github-labels.service.js +++ b/services/github/github-labels.service.js @@ -9,37 +9,22 @@ const schema = Joi.object({ }).required() module.exports = class GithubLabels extends GithubAuthV3Service { - static get category() { - return 'issue-tracking' - } - - static get route() { - return { - base: 'github/labels', - pattern: ':user/:repo/:name', - } - } - - static get examples() { - return [ - { - title: 'GitHub labels', - namedParams: { - user: 'atom', - repo: 'atom', - name: 'help-wanted', - }, - staticPreview: this.render({ name: 'help-wanted', color: '#159818' }), - documentation, + static category = 'issue-tracking' + static route = { base: 'github/labels', pattern: ':user/:repo/:name' } + static examples = [ + { + title: 'GitHub labels', + namedParams: { + user: 'atom', + repo: 'atom', + name: 'help-wanted', }, - ] - } + staticPreview: this.render({ name: 'help-wanted', color: '#159818' }), + documentation, + }, + ] - static get defaultBadgeData() { - return { - label: ' ', - } - } + static defaultBadgeData = { label: ' ' } static render({ name, color }) { return { diff --git a/services/github/github-language-count.service.js b/services/github/github-language-count.service.js index c7f84dfbca58cf7eb8ec107d0fead071af4fb557..311a097271e0924111c1b507bd1ec5d5a65fd454 100644 --- a/services/github/github-language-count.service.js +++ b/services/github/github-language-count.service.js @@ -4,36 +4,21 @@ const { BaseGithubLanguage } = require('./github-languages-base') const { documentation } = require('./github-helpers') module.exports = class GithubLanguageCount extends BaseGithubLanguage { - static get category() { - return 'analysis' - } - - static get route() { - return { - base: 'github/languages/count', - pattern: ':user/:repo', - } - } - - static get examples() { - return [ - { - title: 'GitHub language count', - namedParams: { - user: 'badges', - repo: 'shields', - }, - staticPreview: this.render({ count: 5 }), - documentation, + static category = 'analysis' + static route = { base: 'github/languages/count', pattern: ':user/:repo' } + static examples = [ + { + title: 'GitHub language count', + namedParams: { + user: 'badges', + repo: 'shields', }, - ] - } + staticPreview: this.render({ count: 5 }), + documentation, + }, + ] - static get defaultBadgeData() { - return { - label: 'languages', - } - } + static defaultBadgeData = { label: 'languages' } static render({ count }) { return { diff --git a/services/github/github-last-commit.service.js b/services/github/github-last-commit.service.js index 499b928a904af2b2ea3987a637a36c0b9b583394..1dead7e8925254503797e83b1ce28ce19e8aeba2 100644 --- a/services/github/github-last-commit.service.js +++ b/services/github/github-last-commit.service.js @@ -23,48 +23,33 @@ const schema = Joi.array() .required() module.exports = class GithubLastCommit extends GithubAuthV3Service { - static get category() { - return 'activity' - } - - static get route() { - return { - base: 'github/last-commit', - pattern: ':user/:repo/:branch*', - } - } - - static get examples() { - return [ - { - title: 'GitHub last commit', - pattern: ':user/:repo', - namedParams: { - user: 'google', - repo: 'skia', - }, - staticPreview: this.render({ commitDate: '2013-07-31T20:01:41Z' }), - ...commonExampleAttrs, + static category = 'activity' + static route = { base: 'github/last-commit', pattern: ':user/:repo/:branch*' } + static examples = [ + { + title: 'GitHub last commit', + pattern: ':user/:repo', + namedParams: { + user: 'google', + repo: 'skia', }, - { - title: 'GitHub last commit (branch)', - pattern: ':user/:repo/:branch', - namedParams: { - user: 'google', - repo: 'skia', - branch: 'infra/config', - }, - staticPreview: this.render({ commitDate: '2013-07-31T20:01:41Z' }), - ...commonExampleAttrs, + staticPreview: this.render({ commitDate: '2013-07-31T20:01:41Z' }), + ...commonExampleAttrs, + }, + { + title: 'GitHub last commit (branch)', + pattern: ':user/:repo/:branch', + namedParams: { + user: 'google', + repo: 'skia', + branch: 'infra/config', }, - ] - } + staticPreview: this.render({ commitDate: '2013-07-31T20:01:41Z' }), + ...commonExampleAttrs, + }, + ] - static get defaultBadgeData() { - return { - label: 'last commit', - } - } + static defaultBadgeData = { label: 'last commit' } static render({ commitDate }) { return {