* Build(deps-dev): bump eslint-plugin-import from 2.17.3 to 2.18.0 Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.17.3 to 2.18.0. - [Release notes](https://github.com/benmosher/eslint-plugin-import/releases) - [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md) - [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.17.3...v2.18.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Autofixes
47 lines
963 B
JavaScript
47 lines
963 B
JavaScript
'use strict'
|
|
|
|
const Joi = require('@hapi/joi')
|
|
const { renderVersionBadge } = require('../version')
|
|
const { BaseJsonService } = require('..')
|
|
|
|
const schema = Joi.string().required()
|
|
|
|
module.exports = class DubVersion extends BaseJsonService {
|
|
static get category() {
|
|
return 'version'
|
|
}
|
|
|
|
static get route() {
|
|
return {
|
|
base: 'dub/v',
|
|
pattern: ':packageName',
|
|
}
|
|
}
|
|
|
|
static get examples() {
|
|
return [
|
|
{
|
|
title: 'DUB',
|
|
namedParams: { packageName: 'vibe-d' },
|
|
staticPreview: renderVersionBadge({ version: 'v0.8.4' }),
|
|
},
|
|
]
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return { label: 'dub' }
|
|
}
|
|
|
|
async fetch({ packageName }) {
|
|
return this._requestJson({
|
|
schema,
|
|
url: `https://code.dlang.org/api/packages/${packageName}/latest`,
|
|
})
|
|
}
|
|
|
|
async handle({ packageName }) {
|
|
const version = await this.fetch({ packageName })
|
|
return renderVersionBadge({ version })
|
|
}
|
|
}
|