diff --git a/api-/david.ts b/api-/david.ts deleted file mode 100644 index 0f04cee..0000000 --- a/api-/david.ts +++ /dev/null @@ -1,65 +0,0 @@ -import got from '../libs/got' -import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler' - -export default createBadgenHandler({ - title: 'David DM', - examples: { - '/david/dep/zeit/pkg': 'dependencies', - '/david/dev/zeit/pkg': 'dev dependencies', - '/david/peer/epoberezkin/ajv-keywords': 'peer dependencies', - '/david/optional/epoberezkin/ajv-keywords': 'optional dependencies', - '/david/dep/babel/babel/packages/babel-cli': 'dependencies (sub path)', - }, - handlers: { - '/david/:topic/:owner/:repo/:path*': handler - } -}) - -const statusInfo = { - insecure: ['insecure', 'red'], - outofdate: ['out of date', 'orange'], - notsouptodate: ['up to date', 'yellow'], - uptodate: ['up to date', 'green'], - none: ['none', 'green'] -} - -async function handler ({ topic, owner, repo, path = '' }: PathArgs) { - const prefix = { - dep: '', - dev: 'dev-', - peer: 'peer-', - optional: 'optional-' - }[topic] - - const endpoint = `https://david-dm.org/${owner}/${repo}/${prefix}info.json` - const { status } = await got(endpoint, { - searchParams: { path } - }).json() - - switch (topic) { - case 'dep': - return { - subject: 'dependencies', - status: statusInfo[status][0], - color: statusInfo[status][1] - } - case 'dev': - return { - subject: 'devDependencies', - status: statusInfo[status][0], - color: statusInfo[status][1] - } - case 'peer': - return { - subject: 'peerDependencies', - status: statusInfo[status][0], - color: statusInfo[status][1] - } - case 'optional': - return { - subject: 'optionalDependencies', - status: statusInfo[status][0], - color: statusInfo[status][1] - } - } -} diff --git a/libs/badge-list.ts b/libs/badge-list.ts index b21522b..c573463 100644 --- a/libs/badge-list.ts +++ b/libs/badge-list.ts @@ -9,7 +9,6 @@ export const liveBadgeList = [ // 'github', 'gitlab', // release registries - 'david', 'packagephobia', 'crates', 'docker', diff --git a/next.config.js b/next.config.js index ac49521..13287dc 100644 --- a/next.config.js +++ b/next.config.js @@ -55,6 +55,7 @@ const nextConfig = { // discontinued '/apm', '/lgtm', + '/david', ] badgeApis.forEach(badge => { diff --git a/pages/api/david.ts b/pages/api/david.ts new file mode 100644 index 0000000..e9b753f --- /dev/null +++ b/pages/api/david.ts @@ -0,0 +1,30 @@ +import { createBadgenHandler, PathArgs } from '../../libs/create-badgen-handler-next' + +const help = ` +## Discontinued + +Please refer to [https://github.com/alanshaw/david](https://github.com/alanshaw/david) for more info. +` + +export default createBadgenHandler({ + title: 'David DM', + examples: { + '/david/dep/zeit/pkg': 'dependencies', + '/david/dev/zeit/pkg': 'dev dependencies', + '/david/peer/epoberezkin/ajv-keywords': 'peer dependencies', + '/david/optional/epoberezkin/ajv-keywords': 'optional dependencies', + '/david/dep/babel/babel/packages/babel-cli': 'dependencies (sub path)', + }, + handlers: { + '/david/:topic/:owner/:repo/:path*': handler + }, + help +}) + +async function handler ({ topic, owner, repo, path = '' }: PathArgs) { + return { + subject: 'david badge', + status: 'discontinued', + color: 'grey', + } +} diff --git a/vercel.json b/vercel.json index 74c259f..13ea6b0 100644 --- a/vercel.json +++ b/vercel.json @@ -58,10 +58,6 @@ "source": "/ctan/:match*", "destination": "https://v2022.badgen.net/ctan/:match*" }, - { - "source": "/david/:match*", - "destination": "https://v2022.badgen.net/david/:match*" - }, { "source": "/deepscan/:match*", "destination": "https://v2022.badgen.net/deepscan/:match*"