Refactor service classes [snyk sonar sourceforge sourcegraph spack] (#5632)

* Refactor service classes snyk-sonar-sourceforge-sourcegraph-spack

* Amend end-line issue on pull-request #5632

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
Christian Haag
2020-10-03 18:14:47 +02:00
committed by GitHub
parent 5d3c26efe1
commit fba860fbe9
14 changed files with 400 additions and 510 deletions

View File

@@ -3,42 +3,38 @@
const SynkVulnerabilityBase = require('./snyk-vulnerability-base') const SynkVulnerabilityBase = require('./snyk-vulnerability-base')
module.exports = class SnykVulnerabilityGitHub extends SynkVulnerabilityBase { module.exports = class SnykVulnerabilityGitHub extends SynkVulnerabilityBase {
static get route() { static route = {
return { base: 'snyk/vulnerabilities/github',
base: 'snyk/vulnerabilities/github', pattern: ':user/:repo/:manifestFilePath*',
pattern: ':user/:repo/:manifestFilePath*',
}
} }
static get examples() { static examples = [
return [ {
{ title: 'Snyk Vulnerabilities for GitHub Repo',
title: 'Snyk Vulnerabilities for GitHub Repo', pattern: ':user/:repo',
pattern: ':user/:repo', namedParams: {
namedParams: { user: 'badges',
user: 'badges', repo: 'shields',
repo: 'shields',
},
staticPreview: this.render({ vulnerabilities: '0' }),
}, },
{ staticPreview: this.render({ vulnerabilities: '0' }),
title: 'Snyk Vulnerabilities for GitHub Repo (Specific Manifest)', },
pattern: ':user/:repo/:manifestFilePath', {
namedParams: { title: 'Snyk Vulnerabilities for GitHub Repo (Specific Manifest)',
user: 'badges', pattern: ':user/:repo/:manifestFilePath',
repo: 'shields', namedParams: {
manifestFilePath: 'badge-maker/package.json', user: 'badges',
}, repo: 'shields',
staticPreview: this.render({ vulnerabilities: '0' }), manifestFilePath: 'badge-maker/package.json',
documentation: `
<p>
Provide the path to your target manifest file relative to the base of your repository.
Snyk does not support using a specific branch for this, so do not include "blob" nor a branch name.
</p>
`,
}, },
] staticPreview: this.render({ vulnerabilities: '0' }),
} documentation: `
<p>
Provide the path to your target manifest file relative to the base of your repository.
Snyk does not support using a specific branch for this, so do not include "blob" nor a branch name.
</p>
`,
},
]
async handle({ user, repo, manifestFilePath }) { async handle({ user, repo, manifestFilePath }) {
const url = `https://snyk.io/test/github/${user}/${repo}/badge.svg` const url = `https://snyk.io/test/github/${user}/${repo}/badge.svg`

View File

@@ -4,41 +4,37 @@ const { NotFound } = require('..')
const SynkVulnerabilityBase = require('./snyk-vulnerability-base') const SynkVulnerabilityBase = require('./snyk-vulnerability-base')
module.exports = class SnykVulnerabilityNpm extends SynkVulnerabilityBase { module.exports = class SnykVulnerabilityNpm extends SynkVulnerabilityBase {
static get route() { static route = {
return { base: 'snyk/vulnerabilities/npm',
base: 'snyk/vulnerabilities/npm', pattern: ':packageName(.+?)',
pattern: ':packageName(.+?)',
}
} }
static get examples() { static examples = [
return [ {
{ title: 'Snyk Vulnerabilities for npm package',
title: 'Snyk Vulnerabilities for npm package', pattern: ':packageName',
pattern: ':packageName', namedParams: {
namedParams: { packageName: 'mocha',
packageName: 'mocha',
},
staticPreview: this.render({ vulnerabilities: '0' }),
}, },
{ staticPreview: this.render({ vulnerabilities: '0' }),
title: 'Snyk Vulnerabilities for npm package version', },
pattern: ':packageName', {
namedParams: { title: 'Snyk Vulnerabilities for npm package version',
packageName: 'mocha@4.0.0', pattern: ':packageName',
}, namedParams: {
staticPreview: this.render({ vulnerabilities: '1' }), packageName: 'mocha@4.0.0',
}, },
{ staticPreview: this.render({ vulnerabilities: '1' }),
title: 'Snyk Vulnerabilities for npm scoped package', },
pattern: ':packageName', {
namedParams: { title: 'Snyk Vulnerabilities for npm scoped package',
packageName: '@babel/core', pattern: ':packageName',
}, namedParams: {
staticPreview: this.render({ vulnerabilities: '0' }), packageName: '@babel/core',
}, },
] staticPreview: this.render({ vulnerabilities: '0' }),
} },
]
async handle({ packageName }) { async handle({ packageName }) {
const url = `https://snyk.io/test/npm/${packageName}/badge.svg` const url = `https://snyk.io/test/npm/${packageName}/badge.svg`

View File

@@ -5,39 +5,31 @@ const SonarBase = require('./sonar-base')
const { documentation, keywords, queryParamSchema } = require('./sonar-helpers') const { documentation, keywords, queryParamSchema } = require('./sonar-helpers')
module.exports = class SonarCoverage extends SonarBase { module.exports = class SonarCoverage extends SonarBase {
static get category() { static category = 'coverage'
return 'coverage'
static route = {
base: 'sonar/coverage',
pattern: ':component',
queryParamSchema,
} }
static get route() { static examples = [
return { {
base: 'sonar/coverage', title: 'Sonar Coverage',
pattern: ':component', namedParams: {
queryParamSchema, component: 'org.ow2.petals:petals-se-ase',
}
}
static get examples() {
return [
{
title: 'Sonar Coverage',
namedParams: {
component: 'org.ow2.petals:petals-se-ase',
},
queryParams: {
server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
},
staticPreview: this.render({ coverage: 63 }),
keywords,
documentation,
}, },
] queryParams: {
} server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
},
staticPreview: this.render({ coverage: 63 }),
keywords,
documentation,
},
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'coverage' }
return { label: 'coverage' }
}
static render({ coverage }) { static render({ coverage }) {
return { return {

View File

@@ -12,39 +12,31 @@ const {
const metric = 'public_documented_api_density' const metric = 'public_documented_api_density'
module.exports = class SonarDocumentedApiDensity extends SonarBase { module.exports = class SonarDocumentedApiDensity extends SonarBase {
static get category() { static category = 'analysis'
return 'analysis'
static route = {
base: `sonar/${metric}`,
pattern: ':component',
queryParamSchema,
} }
static get route() { static examples = [
return { {
base: `sonar/${metric}`, title: 'Sonar Documented API Density',
pattern: ':component', namedParams: {
queryParamSchema, component: 'org.ow2.petals:petals-se-ase',
}
}
static get examples() {
return [
{
title: 'Sonar Documented API Density',
namedParams: {
component: 'org.ow2.petals:petals-se-ase',
},
queryParams: {
server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
},
staticPreview: this.render({ density: 82 }),
keywords,
documentation,
}, },
] queryParams: {
} server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
},
staticPreview: this.render({ density: 82 }),
keywords,
documentation,
},
]
static get defaultBadgeData() { static defaultBadgeData = { label: getLabel({ metric }) }
return { label: getLabel({ metric }) }
}
static render({ density }) { static render({ density }) {
return { return {

View File

@@ -13,45 +13,37 @@ const colorMap = {
} }
module.exports = class SonarFortifyRating extends SonarBase { module.exports = class SonarFortifyRating extends SonarBase {
static get category() { static category = 'analysis'
return 'analysis'
static route = {
base: 'sonar/fortify-security-rating',
pattern: ':component',
queryParamSchema,
} }
static get route() { static examples = [
return { {
base: 'sonar/fortify-security-rating', title: 'Sonar Fortify Security Rating',
pattern: ':component', namedParams: {
queryParamSchema, component: 'org.ow2.petals:petals-se-ase',
}
}
static get examples() {
return [
{
title: 'Sonar Fortify Security Rating',
namedParams: {
component: 'org.ow2.petals:petals-se-ase',
},
queryParams: {
server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
},
staticPreview: this.render({ rating: 4 }),
keywords,
documentation: `
<p>
Note that the Fortify Security Rating badge will only work on Sonar instances that have the <a href='https://marketplace.microfocus.com/fortify/content/fortify-sonarqube-plugin'>Fortify SonarQube Plugin</a> installed.
The badge is not available for projects analyzed on SonarCloud.io
</p>
${documentation}
`,
}, },
] queryParams: {
} server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
},
staticPreview: this.render({ rating: 4 }),
keywords,
documentation: `
<p>
Note that the Fortify Security Rating badge will only work on Sonar instances that have the <a href='https://marketplace.microfocus.com/fortify/content/fortify-sonarqube-plugin'>Fortify SonarQube Plugin</a> installed.
The badge is not available for projects analyzed on SonarCloud.io
</p>
${documentation}
`,
},
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'fortify-security-rating' }
return { label: 'fortify-security-rating' }
}
static render({ rating }) { static render({ rating }) {
return { return {

View File

@@ -107,21 +107,15 @@ const metricNames = [
const metricNameRouteParam = metricNames.join('|') const metricNameRouteParam = metricNames.join('|')
module.exports = class SonarGeneric extends SonarBase { module.exports = class SonarGeneric extends SonarBase {
static get category() { static category = 'analysis'
return 'analysis'
static route = {
base: 'sonar',
pattern: `:metricName(${metricNameRouteParam})/:component`,
queryParamSchema,
} }
static get route() { static defaultBadgeData = { label: 'sonar' }
return {
base: 'sonar',
pattern: `:metricName(${metricNameRouteParam})/:component`,
queryParamSchema,
}
}
static get defaultBadgeData() {
return { label: 'sonar' }
}
static render({ metricName, metricValue }) { static render({ metricName, metricValue }) {
return { return {

View File

@@ -4,40 +4,32 @@ const SonarBase = require('./sonar-base')
const { documentation, keywords, queryParamSchema } = require('./sonar-helpers') const { documentation, keywords, queryParamSchema } = require('./sonar-helpers')
module.exports = class SonarQualityGate extends SonarBase { module.exports = class SonarQualityGate extends SonarBase {
static get category() { static category = 'analysis'
return 'analysis'
static route = {
base: 'sonar',
pattern: ':metric(quality_gate|alert_status)/:component',
queryParamSchema,
} }
static get route() { static examples = [
return { {
base: 'sonar', title: 'Sonar Quality Gate',
pattern: ':metric(quality_gate|alert_status)/:component', namedParams: {
queryParamSchema, component: 'swellaby:azdo-shellcheck',
} metric: 'quality_gate',
}
static get examples() {
return [
{
title: 'Sonar Quality Gate',
namedParams: {
component: 'swellaby:azdo-shellcheck',
metric: 'quality_gate',
},
queryParams: {
server: 'https://sonarcloud.io',
sonarVersion: '4.2',
},
staticPreview: this.render({ qualityState: 'OK' }),
keywords,
documentation,
}, },
] queryParams: {
} server: 'https://sonarcloud.io',
sonarVersion: '4.2',
},
staticPreview: this.render({ qualityState: 'OK' }),
keywords,
documentation,
},
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'quality gate' }
return { label: 'quality gate' }
}
static render({ qualityState }) { static render({ qualityState }) {
if (qualityState === 'OK') { if (qualityState === 'OK') {

View File

@@ -10,43 +10,35 @@ const {
} = require('./sonar-helpers') } = require('./sonar-helpers')
module.exports = class SonarTechDebt extends SonarBase { module.exports = class SonarTechDebt extends SonarBase {
static get category() { static category = 'analysis'
return 'analysis'
static route = {
base: 'sonar',
pattern: ':metric(tech_debt|sqale_debt_ratio)/:component',
queryParamSchema,
} }
static get route() { static examples = [
return { {
base: 'sonar', title: 'Sonar Tech Debt',
pattern: ':metric(tech_debt|sqale_debt_ratio)/:component', namedParams: {
queryParamSchema, component: 'org.ow2.petals:petals-se-ase',
} metric: 'tech_debt',
}
static get examples() {
return [
{
title: 'Sonar Tech Debt',
namedParams: {
component: 'org.ow2.petals:petals-se-ase',
metric: 'tech_debt',
},
queryParams: {
server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
},
staticPreview: this.render({
debt: 1,
metric: 'tech_debt',
}),
keywords,
documentation,
}, },
] queryParams: {
} server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
},
staticPreview: this.render({
debt: 1,
metric: 'tech_debt',
}),
keywords,
documentation,
},
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'tech debt' }
return { label: 'tech debt' }
}
static render({ debt, metric }) { static render({ debt, metric }) {
return { return {

View File

@@ -15,53 +15,45 @@ const {
} = require('./sonar-helpers') } = require('./sonar-helpers')
class SonarTestsSummary extends SonarBase { class SonarTestsSummary extends SonarBase {
static get category() { static category = 'build'
return 'build'
static route = {
base: 'sonar/tests',
pattern: ':component',
queryParamSchema: queryParamSchema.concat(testResultQueryParamSchema),
} }
static get route() { static examples = [
return { {
base: 'sonar/tests', title: 'Sonar Tests',
pattern: ':component', namedParams: {
queryParamSchema: queryParamSchema.concat(testResultQueryParamSchema), component: 'org.ow2.petals:petals-se-ase',
}
}
static get examples() {
return [
{
title: 'Sonar Tests',
namedParams: {
component: 'org.ow2.petals:petals-se-ase',
},
queryParams: {
server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
compact_message: null,
passed_label: 'passed',
failed_label: 'failed',
skipped_label: 'skipped',
},
staticPreview: this.render({
passed: 5,
failed: 1,
skipped: 0,
total: 6,
isCompact: false,
}),
keywords,
documentation: `
${documentation}
${testResultsDocumentation}
`,
}, },
] queryParams: {
} server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
compact_message: null,
passed_label: 'passed',
failed_label: 'failed',
skipped_label: 'skipped',
},
staticPreview: this.render({
passed: 5,
failed: 1,
skipped: 0,
total: 6,
isCompact: false,
}),
keywords,
documentation: `
${documentation}
${testResultsDocumentation}
`,
},
]
static get defaultBadgeData() { static defaultBadgeData = {
return { label: 'tests',
label: 'tests',
}
} }
static render({ static render({
@@ -139,81 +131,73 @@ class SonarTestsSummary extends SonarBase {
} }
class SonarTests extends SonarBase { class SonarTests extends SonarBase {
static get category() { static category = 'build'
return 'build'
static route = {
base: 'sonar',
pattern:
':metric(total_tests|skipped_tests|test_failures|test_errors|test_execution_time|test_success_density)/:component',
queryParamSchema,
} }
static get route() { static examples = [
return { {
base: 'sonar', title: 'Sonar Test Count',
pattern: pattern:
':metric(total_tests|skipped_tests|test_failures|test_errors|test_execution_time|test_success_density)/:component', ':metric(total_tests|skipped_tests|test_failures|test_errors)/:component',
queryParamSchema, namedParams: {
} component: 'org.ow2.petals:petals-log',
} metric: 'total_tests',
},
queryParams: {
server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
},
staticPreview: this.render({
metric: 'total_tests',
value: 131,
}),
keywords,
documentation,
},
{
title: 'Sonar Test Execution Time',
pattern: 'test_execution_time/:component',
namedParams: {
component: 'swellaby:azure-pipelines-templates',
},
queryParams: {
server: 'https://sonarcloud.io',
sonarVersion: '4.2',
},
staticPreview: this.render({
metric: 'test_execution_time',
value: 2,
}),
keywords,
documentation,
},
{
title: 'Sonar Test Success Rate',
pattern: 'test_success_density/:component',
namedParams: {
component: 'swellaby:azure-pipelines-templates',
},
queryParams: {
server: 'https://sonarcloud.io',
sonarVersion: '4.2',
},
staticPreview: this.render({
metric: 'test_success_density',
value: 100,
}),
keywords,
documentation,
},
]
static get examples() { static defaultBadgeData = {
return [ label: 'tests',
{
title: 'Sonar Test Count',
pattern:
':metric(total_tests|skipped_tests|test_failures|test_errors)/:component',
namedParams: {
component: 'org.ow2.petals:petals-log',
metric: 'total_tests',
},
queryParams: {
server: 'http://sonar.petalslink.com',
sonarVersion: '4.2',
},
staticPreview: this.render({
metric: 'total_tests',
value: 131,
}),
keywords,
documentation,
},
{
title: 'Sonar Test Execution Time',
pattern: 'test_execution_time/:component',
namedParams: {
component: 'swellaby:azure-pipelines-templates',
},
queryParams: {
server: 'https://sonarcloud.io',
sonarVersion: '4.2',
},
staticPreview: this.render({
metric: 'test_execution_time',
value: 2,
}),
keywords,
documentation,
},
{
title: 'Sonar Test Success Rate',
pattern: 'test_success_density/:component',
namedParams: {
component: 'swellaby:azure-pipelines-templates',
},
queryParams: {
server: 'https://sonarcloud.io',
sonarVersion: '4.2',
},
staticPreview: this.render({
metric: 'test_success_density',
value: 100,
}),
keywords,
documentation,
},
]
}
static get defaultBadgeData() {
return {
label: 'tests',
}
} }
static render({ value, metric }) { static render({ value, metric }) {

View File

@@ -24,67 +24,59 @@ const violationCategoryColorMap = {
} }
module.exports = class SonarViolations extends SonarBase { module.exports = class SonarViolations extends SonarBase {
static get category() { static category = 'analysis'
return 'analysis'
static route = {
base: 'sonar',
pattern:
':metric(violations|blocker_violations|critical_violations|major_violations|minor_violations|info_violations)/:component',
queryParamSchema: queryParamWithFormatSchema,
} }
static get route() { static examples = [
return { {
base: 'sonar', title: 'Sonar Violations (short format)',
pattern: namedParams: {
':metric(violations|blocker_violations|critical_violations|major_violations|minor_violations|info_violations)/:component', component: 'swellaby:azdo-shellcheck',
queryParamSchema: queryParamWithFormatSchema, metric: 'violations',
}
}
static get examples() {
return [
{
title: 'Sonar Violations (short format)',
namedParams: {
component: 'swellaby:azdo-shellcheck',
metric: 'violations',
},
queryParams: {
server: 'https://sonarcloud.io',
format: 'short',
sonarVersion: '4.2',
},
staticPreview: this.render({
violations: 0,
metricName: 'violations',
format: 'short',
}),
keywords,
documentation,
}, },
{ queryParams: {
title: 'Sonar Violations (long format)', server: 'https://sonarcloud.io',
namedParams: { format: 'short',
component: 'org.ow2.petals:petals-se-ase', sonarVersion: '4.2',
metric: 'violations',
},
queryParams: {
server: 'http://sonar.petalslink.com',
format: 'long',
},
staticPreview: this.render({
violations: {
info_violations: 2,
minor_violations: 1,
},
metricName: 'violations',
format: 'long',
}),
keywords,
documentation,
}, },
] staticPreview: this.render({
} violations: 0,
metricName: 'violations',
format: 'short',
}),
keywords,
documentation,
},
{
title: 'Sonar Violations (long format)',
namedParams: {
component: 'org.ow2.petals:petals-se-ase',
metric: 'violations',
},
queryParams: {
server: 'http://sonar.petalslink.com',
format: 'long',
},
staticPreview: this.render({
violations: {
info_violations: 2,
minor_violations: 1,
},
metricName: 'violations',
format: 'long',
}),
keywords,
documentation,
},
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'violations' }
return { label: 'violations' }
}
static renderLongViolationsBadge(violations) { static renderLongViolationsBadge(violations) {
if (violations.violations === 0) { if (violations.violations === 0) {

View File

@@ -10,35 +10,27 @@ const schema = Joi.object({
}).required() }).required()
module.exports = class SourceforgeOpenTickets extends BaseJsonService { module.exports = class SourceforgeOpenTickets extends BaseJsonService {
static get category() { static category = 'other'
return 'other'
static route = {
base: 'sourceforge/open-tickets',
pattern: ':project/:type(bugs|feature-requests)',
} }
static get route() { static examples = [
return { {
base: 'sourceforge/open-tickets', title: 'Sourceforge Open Tickets',
pattern: ':project/:type(bugs|feature-requests)', namedParams: {
} type: 'bugs',
} project: 'sevenzip',
static get examples() {
return [
{
title: 'Sourceforge Open Tickets',
namedParams: {
type: 'bugs',
project: 'sevenzip',
},
staticPreview: this.render({ count: 1338 }),
}, },
] staticPreview: this.render({ count: 1338 }),
} },
]
static get defaultBadgeData() { static defaultBadgeData = {
return { label: 'open tickets',
label: 'open tickets', color: 'blue',
color: 'blue',
}
} }
static render({ count }) { static render({ count }) {

View File

@@ -32,50 +32,42 @@ const intervalMap = {
} }
module.exports = class Sourceforge extends BaseJsonService { module.exports = class Sourceforge extends BaseJsonService {
static get category() { static category = 'downloads'
return 'downloads'
static route = {
base: 'sourceforge',
pattern: ':interval(dt|dm|dw|dd)/:project/:folder*',
} }
static get route() { static examples = [
return { {
base: 'sourceforge', title: 'SourceForge',
pattern: ':interval(dt|dm|dw|dd)/:project/:folder*', pattern: ':interval(dt|dm|dw|dd)/:project',
} namedParams: {
} interval: 'dm',
project: 'sevenzip',
static get examples() {
return [
{
title: 'SourceForge',
pattern: ':interval(dt|dm|dw|dd)/:project',
namedParams: {
interval: 'dm',
project: 'sevenzip',
},
staticPreview: this.render({
downloads: 215990,
interval: 'dm',
}),
}, },
{ staticPreview: this.render({
title: 'SourceForge', downloads: 215990,
pattern: ':interval(dt|dm|dw|dd)/:project/:folder', interval: 'dm',
namedParams: { }),
interval: 'dm', },
project: 'arianne', {
folder: 'stendhal', title: 'SourceForge',
}, pattern: ':interval(dt|dm|dw|dd)/:project/:folder',
staticPreview: this.render({ namedParams: {
downloads: 550, interval: 'dm',
interval: 'dm', project: 'arianne',
}), folder: 'stendhal',
}, },
] staticPreview: this.render({
} downloads: 550,
interval: 'dm',
}),
},
]
static get defaultBadgeData() { static defaultBadgeData = { label: 'sourceforge' }
return { label: 'sourceforge' }
}
static render({ downloads, interval }) { static render({ downloads, interval }) {
return { return {

View File

@@ -9,33 +9,25 @@ const schema = Joi.object({
}).required() }).required()
module.exports = class Sourcegraph extends BaseJsonService { module.exports = class Sourcegraph extends BaseJsonService {
static get category() { static category = 'other'
return 'other'
static route = {
base: 'sourcegraph/rrc',
pattern: ':repo(.*?)',
} }
static get route() { static examples = [
return { {
base: 'sourcegraph/rrc', title: 'Sourcegraph for Repo Reference Count',
pattern: ':repo(.*?)', pattern: ':repo',
} namedParams: {
} repo: 'github.com/gorilla/mux',
static get examples() {
return [
{
title: 'Sourcegraph for Repo Reference Count',
pattern: ':repo',
namedParams: {
repo: 'github.com/gorilla/mux',
},
staticPreview: this.render({ projectsCount: '9.9k projects' }),
}, },
] staticPreview: this.render({ projectsCount: '9.9k projects' }),
} },
]
static get defaultBadgeData() { static defaultBadgeData = { color: 'brightgreen', label: 'used by' }
return { color: 'brightgreen', label: 'used by' }
}
static render({ projectsCount }) { static render({ projectsCount }) {
return { return {

View File

@@ -8,31 +8,23 @@ const schema = Joi.object({
}).required() }).required()
module.exports = class SpackVersion extends BaseJsonService { module.exports = class SpackVersion extends BaseJsonService {
static get category() { static category = 'version'
return 'version'
static route = {
base: 'spack/v',
pattern: ':packageName',
} }
static get route() { static examples = [
return { {
base: 'spack/v', title: 'Spack',
pattern: ':packageName', namedParams: { packageName: 'adios2' },
} staticPreview: this.render({ version: '2.3.1' }),
} keywords: ['hpc'],
},
]
static get examples() { static defaultBadgeData = { label: 'spack' }
return [
{
title: 'Spack',
namedParams: { packageName: 'adios2' },
staticPreview: this.render({ version: '2.3.1' }),
keywords: ['hpc'],
},
]
}
static get defaultBadgeData() {
return { label: 'spack' }
}
static render({ version }) { static render({ version }) {
return renderVersionBadge({ version }) return renderVersionBadge({ version })