1
0
mirror of https://github.com/badges/shields.git synced 2025-11-09 12:40:59 +03:00
Files
shields/services/pypi/pypi-wheel.service.js

51 lines
1.0 KiB
JavaScript

'use strict'
const PypiBase = require('./pypi-base')
const { getPackageFormats } = require('./pypi-helpers')
module.exports = class PypiWheel extends PypiBase {
static get category() {
return 'platform-support'
}
static get route() {
return this.buildRoute('pypi/wheel')
}
static get defaultBadgeData() {
return { label: 'wheel' }
}
static get examples() {
return [
{
title: 'PyPI - Wheel',
pattern: ':packageName',
namedParams: { packageName: 'Django' },
staticPreview: this.render({ hasWheel: true }),
keywords: ['python'],
},
]
}
static render({ hasWheel }) {
if (hasWheel) {
return {
message: 'yes',
color: 'brightgreen',
}
} else {
return {
message: 'no',
color: 'red',
}
}
}
async handle({ egg }) {
const packageData = await this.fetch({ egg })
const { hasWheel } = getPackageFormats(packageData)
return this.constructor.render({ hasWheel })
}
}