* 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>
51 lines
1.3 KiB
JavaScript
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,
|
|
})
|
|
}
|
|
}
|