Files
shields/services/ore/ore-sponge-versions.service.js
dependabot-preview[bot] ee83590942 Build(deps-dev): bump @typescript-eslint/eslint-plugin from 2.34.0 to 4.19.0, run [GitHub GitlabCoverage F-Droid Wordpress VisualStudioAppCenter Ore Packagist] (#6319)
* Build(deps-dev): bump @typescript-eslint/eslint-plugin

Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 2.34.0 to 4.19.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.19.0/packages/eslint-plugin)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* chore: update eslint camelcase rule

* chore: eslint camelcase updates for wordpress

* chore: fix eslint camelcase for misc other services

* chore: fix eslint camelcase issue in github and gitlab

* chore: run prettier

* chore: account for JSX globals

* deps: bump typescript-eslint-parser to v4

* chore: frontend lint changes

* chore: update eslint config to only run @typescript-eslint/explicit-module-boundary-types on ts files

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Caleb Cartwright <caleb.cartwright@outlook.com>
2021-03-28 08:26:01 -05:00

54 lines
1.3 KiB
JavaScript

'use strict'
const { BaseOreService, documentation, keywords } = require('./ore-base')
module.exports = 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 } = data
return {
versions: promoted_versions
.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 })
}
}