Files
shields/services/conda/conda-version.service.js
Caleb Cartwright b7dcf58bd6 convert some service classes to static props, run [codefactor codeship conda continuousphp] (#5515)
* refactor(codefactor): convert to static props

* refactor(codeship): convert to static props

* refactor(conda): convert to static props

* refactor(continuousphp): convert to static props

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-09-12 17:17:19 +00:00

51 lines
1.3 KiB
JavaScript

'use strict'
const { addv: versionText } = require('../text-formatters')
const { version: versionColor } = require('../color-formatters')
const BaseCondaService = require('./conda-base')
module.exports = class CondaVersion extends BaseCondaService {
static category = 'version'
static route = { base: 'conda', pattern: ':variant(v|vn)/:channel/:pkg' }
static examples = [
{
title: 'Conda',
namedParams: { channel: 'conda-forge', package: 'python' },
pattern: 'v/:channel/:package',
staticPreview: this.render({
variant: 'v',
channel: 'conda-forge',
version: '3.7.1',
}),
},
{
title: 'Conda (channel only)',
namedParams: { channel: 'conda-forge', package: 'python' },
pattern: 'vn/:channel/:package',
staticPreview: this.render({
variant: 'vn',
channel: 'conda-forge',
version: '3.7.1',
}),
},
]
static render({ variant, channel, version }) {
return {
label: variant === 'vn' ? channel : `conda|${channel}`,
message: versionText(version),
color: versionColor(version),
}
}
async handle({ variant, channel, pkg }) {
const json = await this.fetch({ channel, pkg })
return this.constructor.render({
variant,
channel,
version: json.latest_version,
})
}
}