* chore(deps-dev): bump eslint from 7.32.0 to 8.2.0 Bumps [eslint](https://github.com/eslint/eslint) from 7.32.0 to 8.2.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.32.0...v8.2.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * deps: update ts-eslint plugins * chore: apply linter fixes Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Caleb Cartwright <caleb.cartwright@outlook.com> Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
import { renderVersionBadge } from '../version.js'
|
|
import { BaseOreService, documentation, keywords } from './ore-base.js'
|
|
|
|
export default class OreVersion extends BaseOreService {
|
|
static category = 'version'
|
|
|
|
static route = {
|
|
base: 'ore/v',
|
|
pattern: ':pluginId',
|
|
}
|
|
|
|
static examples = [
|
|
{
|
|
title: 'Ore Version',
|
|
namedParams: {
|
|
pluginId: 'nucleus',
|
|
},
|
|
staticPreview: renderVersionBadge({ version: '2.2.3' }),
|
|
documentation,
|
|
keywords,
|
|
},
|
|
]
|
|
|
|
static defaultBadgeData = {
|
|
label: 'version',
|
|
}
|
|
|
|
static render({ version }) {
|
|
if (!version) {
|
|
return { message: 'none', color: 'inactive' }
|
|
}
|
|
return renderVersionBadge({ version })
|
|
}
|
|
|
|
transform({ data }) {
|
|
const { promoted_versions: promotedVersions } = data
|
|
return {
|
|
version:
|
|
promotedVersions.length === 0 ? undefined : promotedVersions[0].version,
|
|
}
|
|
}
|
|
|
|
async handle({ pluginId }) {
|
|
const data = await this.fetch({ pluginId })
|
|
const { version } = this.transform({ data })
|
|
return this.constructor.render({ version })
|
|
}
|
|
}
|