Files
shields/services/node/node-base.js
chris48s 9cfd301b82 Complete the examples --> openApi migration; affects [node sonar travis wordpress visualstudio librariesio] (#9977)
* you missed one

* remove examples from deprecatedService()

I'm not going to replace this with openApi
We have zero examples of deprecated services that declare examples

* remove examples from redirector()

* update test

* remove compatibility code for converting examples to openApi

* remove all the code for handling examples

* remove a few bits of redundant code

* improve docs for openApi property

* last one, I promise
2024-02-24 18:14:44 +00:00

41 lines
1.1 KiB
JavaScript

import NPMBase from '../npm/npm-base.js'
export default class NodeVersionBase extends NPMBase {
static category = 'platform-support'
static async render({ tag, nodeVersionRange }) {
// Atypically, the `render()` function of this badge is `async` because it needs to pull
// data from the server.
const label = tag ? `${this.defaultBadgeData.label}@${tag}` : undefined
if (nodeVersionRange === undefined) {
return {
label,
message: 'not specified',
color: 'lightgray',
}
} else {
return {
label,
message: nodeVersionRange,
color: await this.colorResolver(nodeVersionRange),
}
}
}
async handle(namedParams, queryParams) {
const { scope, packageName, tag, registryUrl } =
this.constructor.unpackParams(namedParams, queryParams)
const { engines } = await this.fetchPackageData({
scope,
packageName,
registryUrl,
tag,
})
const { node: nodeVersionRange } = engines || {}
return this.constructor.render({ tag, nodeVersionRange })
}
}