convert some service classes to static props, run [ciibestpractices circleci cirrus] (#5511)
* refactor(ciibestpractices): convert to static props * refactor(circleci): convert to static props * refactor(cirrus): convert to static props * chore: prettify Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
@@ -31,56 +31,45 @@ const summaryColorScale = colorScale(
|
||||
)
|
||||
|
||||
module.exports = class CIIBestPracticesService extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'analysis'
|
||||
static category = 'analysis'
|
||||
static route = {
|
||||
base: 'cii',
|
||||
pattern: ':metric(level|percentage|summary)/:projectId',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'cii',
|
||||
pattern: ':metric(level|percentage|summary)/:projectId',
|
||||
}
|
||||
}
|
||||
static exampless = [
|
||||
{
|
||||
title: 'CII Best Practices Level',
|
||||
pattern: 'level/:projectId',
|
||||
namedParams: {
|
||||
projectId: '1',
|
||||
},
|
||||
staticPreview: this.renderLevelBadge({ level: 'gold' }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'CII Best Practices Tiered Percentage',
|
||||
pattern: 'percentage/:projectId',
|
||||
namedParams: {
|
||||
projectId: '29',
|
||||
},
|
||||
staticPreview: this.renderTieredPercentageBadge({ percentage: 107 }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'CII Best Practices Summary',
|
||||
pattern: 'summary/:projectId',
|
||||
namedParams: {
|
||||
projectId: '33',
|
||||
},
|
||||
staticPreview: this.renderSummaryBadge({ percentage: 94 }),
|
||||
keywords,
|
||||
documentation:
|
||||
'This badge uses the same message and color scale as the native CII one, but with all the configuration and goodness that Shields provides!',
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'CII Best Practices Level',
|
||||
pattern: 'level/:projectId',
|
||||
namedParams: {
|
||||
projectId: '1',
|
||||
},
|
||||
staticPreview: this.renderLevelBadge({ level: 'gold' }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'CII Best Practices Tiered Percentage',
|
||||
pattern: 'percentage/:projectId',
|
||||
namedParams: {
|
||||
projectId: '29',
|
||||
},
|
||||
staticPreview: this.renderTieredPercentageBadge({ percentage: 107 }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'CII Best Practices Summary',
|
||||
pattern: 'summary/:projectId',
|
||||
namedParams: {
|
||||
projectId: '33',
|
||||
},
|
||||
staticPreview: this.renderSummaryBadge({ percentage: 94 }),
|
||||
keywords,
|
||||
documentation:
|
||||
'This badge uses the same message and color scale as the native CII one, but with all the configuration and goodness that Shields provides!',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'cii',
|
||||
}
|
||||
}
|
||||
static defaultBadgeData = { label: 'cii' }
|
||||
|
||||
static renderLevelBadge({ level }) {
|
||||
let message = level
|
||||
|
||||
@@ -20,40 +20,31 @@ const documentation = `
|
||||
const vcsTypeMap = { gh: 'gh', github: 'gh', bb: 'bb', bitbucket: 'bb' }
|
||||
|
||||
class CircleCi extends BaseSvgScrapingService {
|
||||
static get category() {
|
||||
return 'build'
|
||||
static category = 'build'
|
||||
static route = {
|
||||
base: 'circleci/build',
|
||||
pattern: ':vcsType(github|gh|bitbucket|bb)/:user/:repo/:branch*',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'circleci/build',
|
||||
pattern: ':vcsType(github|gh|bitbucket|bb)/:user/:repo/:branch*',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'CircleCI',
|
||||
namedParams: {
|
||||
vcsType: 'github',
|
||||
user: 'RedSparr0w',
|
||||
repo: 'node-csgo-parser',
|
||||
branch: 'master',
|
||||
},
|
||||
queryParams: {
|
||||
token: 'abc123def456',
|
||||
},
|
||||
staticPreview: this.render({ status: 'success' }),
|
||||
documentation,
|
||||
static examples = [
|
||||
{
|
||||
title: 'CircleCI',
|
||||
namedParams: {
|
||||
vcsType: 'github',
|
||||
user: 'RedSparr0w',
|
||||
repo: 'node-csgo-parser',
|
||||
branch: 'master',
|
||||
},
|
||||
]
|
||||
}
|
||||
queryParams: {
|
||||
token: 'abc123def456',
|
||||
},
|
||||
staticPreview: this.render({ status: 'success' }),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'build' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'build' }
|
||||
|
||||
static render({ status }) {
|
||||
return renderBuildStatusBadge({ status: status.replace('_', ' ') })
|
||||
|
||||
@@ -16,57 +16,48 @@ const queryParamSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class Cirrus extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'build'
|
||||
static category = 'build'
|
||||
static route = {
|
||||
base: 'cirrus',
|
||||
pattern: 'github/:user/:repo/:branch*',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'cirrus',
|
||||
pattern: 'github/:user/:repo/:branch*',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Cirrus CI - Base Branch Build Status',
|
||||
namedParams: { user: 'flutter', repo: 'flutter' },
|
||||
pattern: 'github/:user/:repo',
|
||||
queryParams: { task: 'analyze', script: 'test' },
|
||||
staticPreview: this.render({ status: 'passing' }),
|
||||
},
|
||||
{
|
||||
title: 'Cirrus CI - Specific Branch Build Status',
|
||||
pattern: 'github/:user/:repo/:branch',
|
||||
namedParams: { user: 'flutter', repo: 'flutter', branch: 'master' },
|
||||
queryParams: { task: 'analyze', script: 'test' },
|
||||
staticPreview: this.render({ status: 'passing' }),
|
||||
},
|
||||
{
|
||||
title: 'Cirrus CI - Specific Task Build Status',
|
||||
pattern: 'github/:user/:repo',
|
||||
queryParams: { task: 'analyze' },
|
||||
namedParams: { user: 'flutter', repo: 'flutter' },
|
||||
staticPreview: this.render({ subject: 'analyze', status: 'passing' }),
|
||||
},
|
||||
{
|
||||
title: 'Cirrus CI - Task and Script Build Status',
|
||||
pattern: 'github/:user/:repo',
|
||||
queryParams: { task: 'analyze', script: 'test' },
|
||||
namedParams: {
|
||||
user: 'flutter',
|
||||
repo: 'flutter',
|
||||
},
|
||||
staticPreview: this.render({ subject: 'test', status: 'passing' }),
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Cirrus CI - Base Branch Build Status',
|
||||
namedParams: { user: 'flutter', repo: 'flutter' },
|
||||
pattern: 'github/:user/:repo',
|
||||
queryParams: { task: 'analyze', script: 'test' },
|
||||
staticPreview: this.render({ status: 'passing' }),
|
||||
},
|
||||
{
|
||||
title: 'Cirrus CI - Specific Branch Build Status',
|
||||
pattern: 'github/:user/:repo/:branch',
|
||||
namedParams: { user: 'flutter', repo: 'flutter', branch: 'master' },
|
||||
queryParams: { task: 'analyze', script: 'test' },
|
||||
staticPreview: this.render({ status: 'passing' }),
|
||||
},
|
||||
{
|
||||
title: 'Cirrus CI - Specific Task Build Status',
|
||||
pattern: 'github/:user/:repo',
|
||||
queryParams: { task: 'analyze' },
|
||||
namedParams: { user: 'flutter', repo: 'flutter' },
|
||||
staticPreview: this.render({ subject: 'analyze', status: 'passing' }),
|
||||
},
|
||||
{
|
||||
title: 'Cirrus CI - Task and Script Build Status',
|
||||
pattern: 'github/:user/:repo',
|
||||
queryParams: { task: 'analyze', script: 'test' },
|
||||
namedParams: {
|
||||
user: 'flutter',
|
||||
repo: 'flutter',
|
||||
},
|
||||
staticPreview: this.render({ subject: 'test', status: 'passing' }),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'build' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'build' }
|
||||
|
||||
static render({ subject, status }) {
|
||||
return renderBuildStatusBadge({ label: subject, status })
|
||||
|
||||
Reference in New Issue
Block a user