From e9b3a0a92174a3e8e75d87daeb8aa6f6fe7b06e3 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Tue, 8 Sep 2020 17:03:12 -0500 Subject: [PATCH] convert some service classes to static props, run [bitbucket bitrise bountysource] (#5502) * refactor(bitbucket): convert to static props * refactor(bitrise): convert to static props * refactor(bountysource): convert to static props Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com> --- .../bitbucket/bitbucket-issues.service.js | 41 ++++--------- .../bitbucket/bitbucket-pipelines.service.js | 39 +++++------- .../bitbucket-pull-request.service.js | 60 ++++++++----------- services/bitrise/bitrise.service.js | 39 +++++------- services/bountysource/bountysource.service.js | 32 ++++------ 5 files changed, 76 insertions(+), 135 deletions(-) diff --git a/services/bitbucket/bitbucket-issues.service.js b/services/bitbucket/bitbucket-issues.service.js index 2950033205..1e742087b7 100644 --- a/services/bitbucket/bitbucket-issues.service.js +++ b/services/bitbucket/bitbucket-issues.service.js @@ -14,37 +14,22 @@ function issueClassGenerator(raw) { const badgeSuffix = raw ? '' : ' open' return class BitbucketIssues extends BaseJsonService { - static get name() { - return `BitbucketIssues${raw ? 'Raw' : ''}` - } + static name = `BitbucketIssues${raw ? 'Raw' : ''}` + static category = 'issue-tracking' + static route = { base: `bitbucket/${routePrefix}`, pattern: ':user/:repo' } - static get category() { - return 'issue-tracking' - } - - static get route() { - return { - base: `bitbucket/${routePrefix}`, - pattern: ':user/:repo', - } - } - - static get examples() { - return [ - { - title: 'Bitbucket open issues', - namedParams: { - user: 'atlassian', - repo: 'python-bitbucket', - }, - staticPreview: this.render({ issues: 33 }), + static examples = [ + { + title: 'Bitbucket open issues', + namedParams: { + user: 'atlassian', + repo: 'python-bitbucket', }, - ] - } + staticPreview: this.render({ issues: 33 }), + }, + ] - static get defaultBadgeData() { - return { label: 'issues' } - } + static defaultBadgeData = { label: 'issues' } static render({ issues }) { return { diff --git a/services/bitbucket/bitbucket-pipelines.service.js b/services/bitbucket/bitbucket-pipelines.service.js index b2b60e3181..9e38753fca 100644 --- a/services/bitbucket/bitbucket-pipelines.service.js +++ b/services/bitbucket/bitbucket-pipelines.service.js @@ -26,34 +26,25 @@ const bitbucketPipelinesSchema = Joi.object({ }).required() class BitbucketPipelines extends BaseJsonService { - static get category() { - return 'build' + static category = 'build' + static route = { + base: 'bitbucket/pipelines', + pattern: ':user/:repo/:branch+', } - static get route() { - return { - base: 'bitbucket/pipelines', - pattern: ':user/:repo/:branch+', - } - } - - static get examples() { - return [ - { - title: 'Bitbucket Pipelines', - namedParams: { - user: 'atlassian', - repo: 'adf-builder-javascript', - branch: 'task/SECO-2168', - }, - staticPreview: this.render({ status: 'SUCCESSFUL' }), + static examples = [ + { + title: 'Bitbucket Pipelines', + namedParams: { + user: 'atlassian', + repo: 'adf-builder-javascript', + branch: 'task/SECO-2168', }, - ] - } + staticPreview: this.render({ status: 'SUCCESSFUL' }), + }, + ] - static get defaultBadgeData() { - return { label: 'build' } - } + static defaultBadgeData = { label: 'build' } static render({ status }) { return renderBuildStatusBadge({ status: status.toLowerCase() }) diff --git a/services/bitbucket/bitbucket-pull-request.service.js b/services/bitbucket/bitbucket-pull-request.service.js index 9f932aeb6e..47b9726f2d 100644 --- a/services/bitbucket/bitbucket-pull-request.service.js +++ b/services/bitbucket/bitbucket-pull-request.service.js @@ -25,47 +25,35 @@ function pullRequestClassGenerator(raw) { const badgeSuffix = raw ? '' : ' open' return class BitbucketPullRequest extends BaseJsonService { - static get name() { - return `BitbucketPullRequest${raw ? 'Raw' : ''}` + static name = `BitbucketPullRequest${raw ? 'Raw' : ''}` + static category = 'issue-tracking' + static route = { + base: `bitbucket/${routePrefix}`, + pattern: `:user/:repo`, + queryParamSchema, } - static get category() { - return 'issue-tracking' - } - - static get route() { - return { - base: `bitbucket/${routePrefix}`, - pattern: `:user/:repo`, - queryParamSchema, - } - } - - static get examples() { - return [ - { - title: 'Bitbucket open pull requests', - namedParams: { - user: 'atlassian', - repo: 'python-bitbucket', - }, - staticPreview: this.render({ prs: 22 }), + static examples = [ + { + title: 'Bitbucket open pull requests', + namedParams: { + user: 'atlassian', + repo: 'python-bitbucket', }, - { - title: 'Bitbucket Server open pull requests', - namedParams: { - user: 'foo', - repo: 'bar', - }, - queryParams: { server: 'https://bitbucket.mydomain.net' }, - staticPreview: this.render({ prs: 42 }), + staticPreview: this.render({ prs: 22 }), + }, + { + title: 'Bitbucket Server open pull requests', + namedParams: { + user: 'foo', + repo: 'bar', }, - ] - } + queryParams: { server: 'https://bitbucket.mydomain.net' }, + staticPreview: this.render({ prs: 42 }), + }, + ] - static get defaultBadgeData() { - return { label: 'pull requests' } - } + static defaultBadgeData = { label: 'pull requests' } static render({ prs }) { return { diff --git a/services/bitrise/bitrise.service.js b/services/bitrise/bitrise.service.js index 95b635a4f1..79d81e06ec 100644 --- a/services/bitrise/bitrise.service.js +++ b/services/bitrise/bitrise.service.js @@ -13,34 +13,23 @@ const queryParamSchema = Joi.object({ }).required() module.exports = class Bitrise extends BaseJsonService { - static get category() { - return 'build' + static category = 'build' + static route = { + base: 'bitrise', + pattern: ':appId/:branch?', + queryParamSchema, } - static get route() { - return { - base: 'bitrise', - pattern: ':appId/:branch?', - queryParamSchema, - } - } + static examples = [ + { + title: 'Bitrise', + namedParams: { appId: 'cde737473028420d', branch: 'master' }, + queryParams: { token: 'GCIdEzacE4GW32jLVrZb7A' }, + staticPreview: this.render({ status: 'success' }), + }, + ] - static get examples() { - return [ - { - title: 'Bitrise', - namedParams: { appId: 'cde737473028420d', branch: 'master' }, - queryParams: { token: 'GCIdEzacE4GW32jLVrZb7A' }, - staticPreview: this.render({ status: 'success' }), - }, - ] - } - - static get defaultBadgeData() { - return { - label: 'bitrise', - } - } + static defaultBadgeData = { label: 'bitrise' } static render({ status }) { const color = { diff --git a/services/bountysource/bountysource.service.js b/services/bountysource/bountysource.service.js index 75920176ff..96b793630e 100644 --- a/services/bountysource/bountysource.service.js +++ b/services/bountysource/bountysource.service.js @@ -8,30 +8,18 @@ const { BaseJsonService } = require('..') const schema = Joi.object({ activity_total: nonNegativeInteger }) module.exports = class Bountysource extends BaseJsonService { - static get category() { - return 'funding' - } + static category = 'funding' + static route = { base: 'bountysource/team', pattern: ':team/activity' } - static get route() { - return { - base: 'bountysource/team', - pattern: ':team/activity', - } - } + static examples = [ + { + title: 'Bountysource', + namedParams: { team: 'mozilla-core' }, + staticPreview: this.render({ total: 53000 }), + }, + ] - static get examples() { - return [ - { - title: 'Bountysource', - namedParams: { team: 'mozilla-core' }, - staticPreview: this.render({ total: 53000 }), - }, - ] - } - - static get defaultBadgeData() { - return { label: 'bounties' } - } + static defaultBadgeData = { label: 'bounties' } static render({ total }) { return {