diff --git a/api/opam.ts b/api/opam.ts index 1d7c279..cb1343e 100644 --- a/api/opam.ts +++ b/api/opam.ts @@ -1,16 +1,9 @@ -import cheerio from 'cheerio' import got from '../libs/got' import { millify, version, versionColor } from '../libs/utils' import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler' const OPAM_REPO_URL = 'https://opam.ocaml.org/packages/' -type PackageInfo = { - version: string, - license: string, - downloads: number -} - export default createBadgenHandler({ title: 'OCaml Package Manager', examples: { @@ -26,14 +19,10 @@ export default createBadgenHandler({ async function handler ({ topic, pkg }: PathArgs) { const html = await got(pkg, { prefixUrl: OPAM_REPO_URL }).text() - const { - downloads, - license, - version: ver - } = await getPackageInfo(html) switch (topic) { case 'v': { + const ver = html.match(/class="package-version">([^<]+)<\//i)?.[1] ?? '' return { subject: 'opam', status: version(ver), @@ -41,6 +30,7 @@ async function handler ({ topic, pkg }: PathArgs) { } } case 'license': { + const license = html.match(/