feat: migrate /hackage badges, and fixes #585 (#600)

* feat: migrate /pypi badges

* feat: migrate /hackage badges

* chore: add comments for cabalfile compability
pull/601/head
Amio Jin 2023-06-10 11:11:10 +08:00 zatwierdzone przez GitHub
rodzic 34a019ab34
commit d7adf406b8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 17 dodań i 10 usunięć

Wyświetl plik

@ -20,7 +20,6 @@ export const liveBadgeList = [
'packagist',
'rubygems',
'apm',
'hackage',
'vs-marketplace',
'melpa',
'maven',

Wyświetl plik

@ -2,6 +2,7 @@ import staticBadge from '../pages/api/static'
import github from '../pages/api/github'
import npm from '../pages/api/npm'
import chromeWebStore from '../pages/api/chrome-web-store'
import hackage from '../pages/api/hackage'
import pypi from '../pages/api/pypi'
import runkit from '../pages/api/runkit'
import winget from '../pages/api/winget'
@ -12,6 +13,7 @@ export default {
github: github.meta,
npm: npm.meta,
chromeWebStore: chromeWebStore.meta,
hackage: hackage.meta,
pypi: pypi.meta,
runkit: runkit.meta,
winget: winget.meta,

Wyświetl plik

@ -45,6 +45,7 @@ const nextConfig = {
'/github',
'/npm',
'/chrome-web-store',
'/hackage',
'/pypi',
'/runkit',
'/winget',

Wyświetl plik

@ -1,6 +1,6 @@
import got from '../libs/got'
import { version as v, versionColor } from '../libs/utils'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
import got from '../../libs/got'
import { version as v, versionColor } from '../../libs/utils'
import { createBadgenHandler, PathArgs } from '../../libs/create-badgen-handler-next'
export default createBadgenHandler({
title: 'Hackage',
@ -32,14 +32,23 @@ async function handler ({ topic, pkg }: PathArgs) {
status: license,
color: 'blue'
}
default:
return {
subject: 'hackage',
status: 'unknown topic',
color: 'grey'
}
}
}
// Naive implementation (only parse meta blocks)
const parseCabalFile = raw => {
return raw.match(/[\w-]+:.+\S+$/gm).reduce((accu, line) => {
// this regex needs to support both v1 and v2 for cabalfile
const cabalMeta = raw.match(/[\w-]+:.+\S+$/gm).reduce((accu, line) => {
const [key, value] = line.split(':')
accu[key] = value.trim()
accu[key.toLowerCase()] = value.trim()
return accu
}, {})
return cabalMeta
}

Wyświetl plik

@ -110,10 +110,6 @@
"source": "/gitter/:match*",
"destination": "https://v2022.badgen.net/gitter/:match*"
},
{
"source": "/hackage/:match*",
"destination": "https://v2022.badgen.net/hackage/:match*"
},
{
"source": "/haxelib/:match*",
"destination": "https://v2022.badgen.net/haxelib/:match*"