fix [pypi] status badge when package has no 'Development Status' classifier (#10107)

This commit is contained in:
chris48s
2024-05-06 19:58:12 +01:00
committed by GitHub
parent f562fe7c03
commit 2857d9bf5c
2 changed files with 10 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ export default class PypiStatus extends PypiBase {
stable: 'brightgreen',
mature: 'brightgreen',
inactive: 'red',
unknown: 'lightgrey',
}[status]
return {
@@ -48,7 +49,7 @@ export default class PypiStatus extends PypiBase {
// - Development Status :: 6 - Mature
// - Development Status :: 7 - Inactive
// https://pypi.org/pypi?%3Aaction=list_classifiers
const status = parseClassifiers(
let status = parseClassifiers(
packageData,
/^Development Status :: (\d - \S+)$/,
)
@@ -57,6 +58,10 @@ export default class PypiStatus extends PypiBase {
.map(classifier => classifier.replace(/production\/stable/i, 'stable'))
.pop()
if (!status) {
status = 'Unknown'
}
return this.constructor.render({ status })
}
}

View File

@@ -13,6 +13,10 @@ t.create('status (valid, beta)')
.get('/django/2.0rc1.json')
.expectBadge({ label: 'status', message: 'beta' })
t.create('status (status not specified)')
.get('/arcgis2geojson/3.0.2.json')
.expectBadge({ label: 'status', message: 'unknown' })
t.create('status (invalid)')
.get('/not-a-package.json')
.expectBadge({ label: 'status', message: 'package or version not found' })