diff --git a/components/builder-helper.tsx b/components/builder-helper.tsx index e42c1086..d2603bac 100644 --- a/components/builder-helper.tsx +++ b/components/builder-helper.tsx @@ -1,9 +1,4 @@ import badgeList from '../public/.meta/badge-list.json' -import badgeListLegacy from '../public/.meta/badges.json' - -// const examples = [...badgeList.live, ...badgeList.static].reduce((accu, curr) => { -// return (accu as any).concat(Object.entries(curr.examples)) -// }, [] as [string, string][]) type BadgeExamples = { [pathname: string]: string @@ -11,23 +6,17 @@ type BadgeExamples = { type BadgeList = { [id: string]: { title: string; - examples: BadgeExamples; + examples?: BadgeExamples; } } - const examples = extractExampleList(badgeList) function extractExampleList (badgeList: BadgeList): BadgeExamples { - let examples = {} - - Object.entries(badgeList).forEach((x) => { - examples = { ...examples, ...x[1].examples } - }) + let examples: BadgeExamples = {} - // Also apply legacy examples - badgeListLegacy.live.forEach((x) => { - examples = { ...examples, ...x.examples } + Object.values(badgeList).forEach((meta) => { + examples = { ...examples, ...(meta.examples || {}) } }) return examples diff --git a/libs/badge-list.ts b/libs/badge-list.ts deleted file mode 100644 index 3caca9e4..00000000 --- a/libs/badge-list.ts +++ /dev/null @@ -1,74 +0,0 @@ -import path from 'path' -import staticBadges from '../pages/api/static' - -const rel = (...args) => path.resolve(__dirname, ...args) - -/** @deprecated use badge-list2.ts instead */ -// sort live badge manually -export const liveBadgeList = [ - // // source control - // 'github', - // 'gitlab', - // release registries - 'homebrew', - 'nuget', - 'packagist', - 'melpa', - 'maven', - 'cocoapods', - 'haxelib', - 'opam', - 'cpan', - 'cran', - 'ctan', - 'dub', - 'elm-package', - 'scoop', - 'f-droid', - 'shards', - 'wapm', - 'snapcraft', - // CI - 'appveyor', - 'codacy', - 'azure-pipelines', - // quality & metrics - 'snyk', - 'deepscan', - 'uptime-robot', - 'badgesize', - // social - 'devrant', - 'reddit', - // utilities - 'opencollective', - 'keybase', - 'mastodon', - 'tidelift', - 'jenkins', -] - -export async function loadBadgeMeta() { - const liveBadgeExamples = await Promise.all(liveBadgeList.map(async id => { - const mod = await import(rel('../pages/api', id)) - const { title, examples, handlers } = mod.default.meta - - return { - id, - title, - examples, - routes: Object.keys(handlers), - } - })) - - const statics = { - title: staticBadges.meta.title, - examples: staticBadges.meta.examples, - routes: Object.keys(staticBadges.meta.handlers) - } - - return { - live: liveBadgeExamples, - static: [statics] - } -} diff --git a/next.config.js b/next.config.js index f92b38f3..70f517d5 100644 --- a/next.config.js +++ b/next.config.js @@ -2,8 +2,6 @@ const { withSentryConfig } = require('@sentry/nextjs') -const badgeList = require('./public/.meta/badges.json') - const nextConfig = { reactStrictMode: true, optimizeFonts: false, diff --git a/package-lock.json b/package-lock.json index 3f6a39ba..21a57223 100644 --- a/package-lock.json +++ b/package-lock.json @@ -909,6 +909,9 @@ "cpu": [ "arm" ], + "libc": [ + "glibc" + ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -925,6 +928,9 @@ "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -941,6 +947,9 @@ "cpu": [ "ppc64" ], + "libc": [ + "glibc" + ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -957,6 +966,9 @@ "cpu": [ "riscv64" ], + "libc": [ + "glibc" + ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -973,6 +985,9 @@ "cpu": [ "s390x" ], + "libc": [ + "glibc" + ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -989,6 +1004,9 @@ "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1005,6 +1023,9 @@ "cpu": [ "arm64" ], + "libc": [ + "musl" + ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1021,6 +1042,9 @@ "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1037,6 +1061,9 @@ "cpu": [ "arm" ], + "libc": [ + "glibc" + ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1059,6 +1086,9 @@ "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1081,6 +1111,9 @@ "cpu": [ "ppc64" ], + "libc": [ + "glibc" + ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1103,6 +1136,9 @@ "cpu": [ "riscv64" ], + "libc": [ + "glibc" + ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1125,6 +1161,9 @@ "cpu": [ "s390x" ], + "libc": [ + "glibc" + ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1147,6 +1186,9 @@ "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1169,6 +1211,9 @@ "cpu": [ "arm64" ], + "libc": [ + "musl" + ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1191,6 +1236,9 @@ "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1398,6 +1446,9 @@ "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1414,6 +1465,9 @@ "cpu": [ "arm64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1430,6 +1484,9 @@ "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1446,6 +1503,9 @@ "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2081,6 +2141,9 @@ "arm64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2098,6 +2161,9 @@ "arm64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2115,6 +2181,9 @@ "ppc64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2132,6 +2201,9 @@ "riscv64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2149,6 +2221,9 @@ "riscv64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2166,6 +2241,9 @@ "s390x" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2183,6 +2261,9 @@ "x64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2200,6 +2281,9 @@ "x64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2463,6 +2547,9 @@ "cpu": [ "arm" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2476,6 +2563,9 @@ "cpu": [ "arm" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2489,6 +2579,9 @@ "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2502,6 +2595,9 @@ "cpu": [ "arm64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2515,6 +2611,9 @@ "cpu": [ "loong64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2528,6 +2627,9 @@ "cpu": [ "loong64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2541,6 +2643,9 @@ "cpu": [ "ppc64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2554,6 +2659,9 @@ "cpu": [ "ppc64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2567,6 +2675,9 @@ "cpu": [ "riscv64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2580,6 +2691,9 @@ "cpu": [ "riscv64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2593,6 +2707,9 @@ "cpu": [ "s390x" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2606,6 +2723,9 @@ "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2619,6 +2739,9 @@ "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ diff --git a/pages/help.tsx b/pages/help.tsx index a63fabd0..7246b20c 100644 --- a/pages/help.tsx +++ b/pages/help.tsx @@ -6,7 +6,6 @@ import { useState, useEffect } from 'react' import BadgenTitle from '../components/badgen-title' import HelpInfo from '../components/help-info' import Footer from '../components/footer' -import examples from '../public/.meta/badges.json' export default function Index () { const [host, setHost] = useState('') diff --git a/tools/gen-examples.ts b/tools/gen-examples.ts index 3a76d907..4fd31643 100644 --- a/tools/gen-examples.ts +++ b/tools/gen-examples.ts @@ -1,18 +1,10 @@ import path from 'path' import fse from 'fs-extra' -import { loadBadgeMeta } from '../libs/badge-list' import BadgeList2 from '../libs/badge-list2' const rel = (...args) => path.resolve(__dirname, ...args) ;(async function main () { - // old list - const badgeMeta = await loadBadgeMeta() - await fse.outputJson(rel('../public/.meta/badges.json'), badgeMeta, { - spaces: 2 - }) - - // new list await fse.outputJson(rel('../public/.meta/badge-list.json'), BadgeList2, { spaces: 2 })