* 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>
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
import { BaseOreService, documentation, keywords } from './ore-base.js'
|
|
|
|
export default class OreSpongeVersions extends BaseOreService {
|
|
static category = 'platform-support'
|
|
|
|
static route = {
|
|
base: 'ore/sponge-versions',
|
|
pattern: ':pluginId',
|
|
}
|
|
|
|
static examples = [
|
|
{
|
|
title: 'Compatible versions (plugins on Ore)',
|
|
namedParams: {
|
|
pluginId: 'nucleus',
|
|
},
|
|
staticPreview: this.render({ versions: ['7.3', '6.0'] }),
|
|
documentation,
|
|
keywords,
|
|
},
|
|
]
|
|
|
|
static defaultBadgeData = {
|
|
label: 'sponge',
|
|
}
|
|
|
|
static render({ versions }) {
|
|
if (versions.length === 0) {
|
|
return { message: 'none', color: 'inactive' }
|
|
}
|
|
return { message: versions.join(' | '), color: 'blue' }
|
|
}
|
|
|
|
transform({ data }) {
|
|
const { promoted_versions: promotedVersions } = data
|
|
return {
|
|
versions: promotedVersions
|
|
.reduce((acc, { tags }) => acc.concat(tags), [])
|
|
.filter(({ name }) => name.toLowerCase() === 'sponge')
|
|
.map(({ display_data: displayData }) => displayData)
|
|
// display_data is not mandatory in the schema, filter null values
|
|
.filter(x => !!x),
|
|
}
|
|
}
|
|
|
|
async handle({ pluginId }) {
|
|
const data = await this.fetch({ pluginId })
|
|
const { versions } = this.transform({ data })
|
|
return this.constructor.render({ versions })
|
|
}
|
|
}
|