fix: build issues

pull/579/head
Amio 2022-12-31 16:23:34 +08:00
rodzic 44f79afb84
commit af21b43c93
23 zmienionych plików z 501 dodań i 583 usunięć

Wyświetl plik

@ -110,6 +110,6 @@ async function fetchDownloads (pkg: string, period: string) {
const end = 'last-day'
period = [start, end].join(':')
}
const [stats] = await client.get(`downloads/total/${period}/${pkg}`).json()
const [stats] = await client.get(`downloads/total/${period}/${pkg}`).json() as any
return stats.downloads
}

Wyświetl plik

@ -4,7 +4,7 @@ import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
const CTAN_API_URL = 'https://ctan.org/json/2.0/'
const client = got.extend({ prefixUrl: CTAN_API_URL, timeout: 3500 })
const client = got.extend({ prefixUrl: CTAN_API_URL, timeout: { request: 3500 } })
export default createBadgenHandler({
title: 'CTAN',

Wyświetl plik

@ -23,7 +23,7 @@ async function handler ({ topic, owner, name }: PathArgs) {
'elm-version': elmVersion,
license,
version: ver
} = await client.get(`packages/${owner}/${name}/latest/elm.json`).json()
} = await client.get(`packages/${owner}/${name}/latest/elm.json`).json<any>()
switch (topic) {
case 'v':

Wyświetl plik

@ -27,7 +27,7 @@ async function handler ({ instance, topic, 'video-uuid': videoUUID }: PathArgs)
switch (topic) {
case 'comments': {
const { total } = await client.get(`/videos/${videoUUID}/comment-threads`).json()
const { total } = await client.get(`/videos/${videoUUID}/comment-threads`).json<any>()
return {
subject: 'comments',
status: millify(total),
@ -35,7 +35,7 @@ async function handler ({ instance, topic, 'video-uuid': videoUUID }: PathArgs)
}
}
case 'views': {
const { views } = await client.get(`/videos/${videoUUID}`).json()
const { views } = await client.get(`/videos/${videoUUID}`).json<any>()
return {
subject: 'views',
status: millify(views),
@ -47,7 +47,7 @@ async function handler ({ instance, topic, 'video-uuid': videoUUID }: PathArgs)
async function votesHandler ({ instance, 'video-uuid': videoUUID, format }: PathArgs) {
const client = createClient(instance)
const { likes, dislikes } = await client.get(`/videos/${videoUUID}`).json()
const { likes, dislikes } = await client.get(`/videos/${videoUUID}`).json<any>()
switch (format) {
case 'likes': {
@ -76,7 +76,7 @@ async function followersHandler ({ instance, account, channel }: PathArgs) {
const client = createClient(instance)
if (channel) {
const { followersCount } = await client.get(`/video-channels/${channel}`).json()
const { followersCount } = await client.get(`/video-channels/${channel}`).json<any>()
return {
subject: 'followers',
status: millify(followersCount),
@ -84,7 +84,7 @@ async function followersHandler ({ instance, account, channel }: PathArgs) {
}
}
const { followersCount } = await client.get(`/accounts/${account}`).json()
const { followersCount } = await client.get(`/accounts/${account}`).json<any>()
return {
subject: 'followers',
status: millify(followersCount),

Wyświetl plik

@ -22,7 +22,7 @@ async function handler ({ owner, repo, branch, targetFile }: PathArgs) {
const searchParams = new URLSearchParams()
if (targetFile) searchParams.set('targetFile', targetFile)
const resp = await got(badgeUrl, { searchParams, timeout: 3500 })
const resp = await got(badgeUrl, { searchParams })
const params = isBadge(resp) && parseBadge(resp.body)
return params || {

Wyświetl plik

@ -12,7 +12,7 @@ export default ({ data }) => {
<ExampleItem key={path} desc={desc} url={path} />
))
}
<style jsx>{`
<style>{`
dl {
padding: 0 1em;
margin: 0 auto;
@ -63,9 +63,9 @@ export default ({ data }) => {
const ExampleItem = ({ desc, url }) => (
<dd>
<b>{desc}</b>
<i><img src={url} /></i>
<i><img alt={desc} src={url} /></i>
<span><a href={url}>{url}</a></span>
<style jsx>{`
<style>{`
dd {
font: 14px/20px sans-serif;
vertical-align: top;

Wyświetl plik

@ -1,17 +1,22 @@
import Link from 'next/link'
import Image from 'next/image'
const BadgenTitle = ({ host }) => {
import { Merriweather } from '@next/font/google'
const merriweather = Merriweather({ subsets: ['latin'], weight: ["300", "700"] })
export default function BadgenTitle ({ host }) {
return (
<div className='title-block'>
<div className='title'>
<div className={`title ${merriweather.className}`}>
<h1>
<img src='/static/badgen-logo.svg' />
<Image alt='badgen logo' src='/static/badgen-logo.svg' width='42' height='42' />
Badgen
<StyleSwitch host={host} />
</h1>
<p>Fast badge generating service</p>
<div>Fast badge generating service</div>
</div>
<style jsx>{`
<style>{`
.title-block {
width: 100%;
height: 260px;
@ -36,27 +41,27 @@ const BadgenTitle = ({ host }) => {
.title.show {
transition-delay: 100ms;
}
.title img {
height: 42px;
width: 42px;
vertical-align: top;
margin-top: -1px;
margin-right: 10px;
}
.title h1 {
margin: 1.5rem 0 0 0;
font: 46px/48px Merriweather, serif;
font: 46px/42px Merriweather, Georgia, serif;
font-weight: 700;
color: #333;
height: 52px;
width: 235px;
position: relative;
}
.title p {
font: 20px/32px Merriweather, serif;
.title h1 img {
height: 42px;
width: 42px;
vertical-align: top;
margin-top: -1px;
margin-right: 10px;
}
.title div {
font: 20px/32px Merriweather, Georgia, serif;
font-weight: 300;
letter-spacing: 0.3px;
color: #333;
margin-top: 10px;
}
`}
</style>
@ -70,13 +75,13 @@ const StyleSwitch = ({ host }) => {
return (
<span className='style-switch'>
{host.includes('https://flat.') ? [
<Link key='2' href='https://flat.badgen.net'><a>FLAT</a></Link>,
<Link key='1' href='https://badgen.net'><a>CLASSIC</a></Link>
<Link key='2' href='https://flat.badgen.net'>FLAT</Link>,
<Link key='1' href='https://badgen.net'>CLASSIC</Link>
] : [
<Link key='1' href='https://badgen.net'><a>CLASSIC</a></Link>,
<Link key='2' href='https://flat.badgen.net'><a>FLAT</a></Link>
<Link key='1' href='https://badgen.net'>CLASSIC</Link>,
<Link key='2' href='https://flat.badgen.net'>FLAT</Link>
]}
<style jsx>{`
<style>{`
.style-switch {
position: absolute;
box-sizing: border-box;
@ -108,5 +113,3 @@ const StyleSwitch = ({ host }) => {
</span>
)
}
export default BadgenTitle

Wyświetl plik

@ -41,7 +41,7 @@ export default class BuilderBar extends React.Component<BuilderBarProps> {
onBlur={this.props.onBlur}
value={badgeURL}
/>
<style jsx>{`
<style>{`
label {
height: 100px;
width: 100%;

Wyświetl plik

@ -36,7 +36,7 @@ export default function BuilderHelper ({ badgeURL, onSelect }: BuilderHelperProp
return (
<div className='helper'>
{hints}
<style jsx>{`
<style>{`
.helper {
height: 50vh;
width: 100%;
@ -59,7 +59,7 @@ const Hint = ({ info, onSelect }) => (
<tr onClick={onSelect}>
<th>{info[1]}</th>
<td>{info[0]}</td>
<style jsx>{`
<style>{`
tr {
font-size: 15px;
line-height: 36px;

Wyświetl plik

@ -21,7 +21,7 @@ export default function BuilderHints ({ focus, badgeURL }) {
<Hint left={290} width={110} height={1}>
<a href='/#options'>OPTIONS (icon, label, etc.)</a>
</Hint>
<style jsx>{`
<style>{`
.hints {
height: 0;
position: relative;
@ -54,7 +54,7 @@ const Hint = ({ left, width, height, children, align = 'left' }) => {
<div className='hint' style={wrapperPos}>
<div className='line' />
<div className='content'>{children}</div>
<style jsx>{`
<style>{`
.hint {
border-top: 2px solid #666;
position: absolute;

Wyświetl plik

@ -1,4 +1,4 @@
import debounceRender from 'react-debounce-render'
// import debounceRender from 'react-debounce-render'
import BadgenTitle from './badgen-title'
const BadgePreview = ({ host, badgeURL, focus }) => {
@ -11,7 +11,7 @@ const BadgePreview = ({ host, badgeURL, focus }) => {
<div className={'preview ' + (showPreview ? 'show' : 'none')}>
<PreviewBadge host={host} url={badgeURL} />
</div>
<style jsx>{`
<style>{`
.header-preview {
height: calc(50vh - 100px);
width: 100%;
@ -54,9 +54,13 @@ const BadgePreview = ({ host, badgeURL, focus }) => {
)
}
const PreviewBadge = debounceRender(({ host, url }) => {
/* const PreviewBadge = debounceRender(({ host, url }) => {
return <img style={{ height: '30px' }} src={genBadgeSrc(host, url)} />
}, 300)
}, 300) */
const PreviewBadge = ({ host, url }) => {
return <img alt={url} style={{ height: '30px' }} src={genBadgeSrc(host, url)} />
}
const genBadgeSrc = (host, url) => {
if (!url) {

Wyświetl plik

@ -1,23 +1,27 @@
import Link from 'next/link'
import Image from 'next/image'
export default function Footer () {
return (
<footer>
<div className='footer-content'>
<div>
<h3><img src='/static/badgen-logo-w.svg' />Badgen Service</h3>
<h3>
<img alt='badgen logo' src='/static/badgen-logo-w.svg' />
Badgen Service
</h3>
<div className='sitemap'>
<Link href='https://badgen.net'><a>Classic</a></Link>
<Link href='https://badgen.net'>Classic</Link>
<em>/</em>
<Link href='https://flat.badgen.net'><a>Flat</a></Link>
<Link href='https://flat.badgen.net'>Flat</Link>
<em>/</em>
<Link href='/builder'><a>Builder</a></Link>
<Link href='/builder'>Builder</Link>
<em>/</em>
<Link href='https://github.com/badgen/badgen.net'><a>GitHub</a></Link>
<Link href='https://github.com/badgen/badgen.net'>GitHub</Link>
<em>/</em>
<Link href='https://twitter.com/badgen_net'><a>Twitter</a></Link>
<Link href='https://twitter.com/badgen_net'>Twitter</Link>
<em>/</em>
<Link href='https://opencollective.com/badgen'><a>OpenCollective</a></Link>
<Link href='https://opencollective.com/badgen'>OpenCollective</Link>
<br />
</div>
</div>
@ -28,17 +32,20 @@ export default function Footer () {
Powered by <a href='https://vercel.com'>Vercel</a>.
</div>
<div className='links'>
<a href='https://twitter.com/badgen_net'>
<img src='https://simpleicons.now.sh/twitter/fff' />
<a title='badgen twitter link' href='https://twitter.com/badgen_net'>
<img alt='badgen twitter link' src='https://simpleicons.now.sh/twitter/fff' width='30' height='30' />
</a>
<a href='https://github.com/badgen/badgen.net'>
<img src='https://simpleicons.now.sh/github/fff' />
<img alt='badgen github link' src='https://simpleicons.now.sh/github/fff' width='30' height='30' />
</a>
</div>
</div>
</div>
<style jsx>{`
<style>{`
footer {
margin-top: 8rem;
background-color: #222;
padding: 2rem 2rem;
color: #777;
@ -46,12 +53,13 @@ export default function Footer () {
.footer-content {
margin: 0 auto;
}
h3 {
font: 24px/32px Merriweather, serif;
footer h3 {
font: 22px/32px Merriweather, Georgia, serif;
letter-spacing: 0.5px;
color: #DDD;
margin-bottom: 1em;
}
h3 img {
footer h3 img {
height: 21px;
opacity: 0.8;
margin-right: 8px;
@ -60,12 +68,12 @@ export default function Footer () {
}
.sitemap {
line-height: 26px;
padding-bottom: 2em;
}
.sitemap a {
color: #999;
text-transform: uppercase;
letter-spacing: 0.5px;
display: inline;
}
a:hover {
color: #EEE;
@ -84,13 +92,14 @@ export default function Footer () {
}
.bottom a {
color: #999;
display: inline;
}
.links {
text-align: right;
}
.links a {
margin-left: 1em;
opacity: 0.7;
display: inline;
}
.links a:hover {
opacity: 1;

Wyświetl plik

@ -12,7 +12,7 @@ export default function GalleryHeader ({ current }) {
<a className='static'>Static Badges</a>
</Link>
</div>
<style jsx>{`
<style>{`
header {
background-color: #F7F7F7;
text-align: center;

Wyświetl plik

@ -1,17 +1,15 @@
import icons from 'badgen-icons'
import Image from 'next/image'
import { Inter } from '@next/font/google'
const inter = Inter({ subsets: ['latin'] })
export default function HomeIntro ({ isFlat = false }) {
return (
<div>
<div className={`home-intro ${inter.className}`}>
<pre>{explainCode(isFlat)}</pre>
<h3 id='colors'>Builtin color names</h3>
{colorExamples()}
<h3 id='icons'>Builtin icons</h3>
{iconExamples()}
<h3 id='options'>Options</h3>
<h3>Options</h3>
<ul>
<li>
<code>color</code>
@ -61,13 +59,27 @@ export default function HomeIntro ({ isFlat = false }) {
turn an api endpoint into a svg live badge.
</li>
</ul>
<style jsx>{`
<style>{`
pre {
font-size: 15px;
font-family: Menlo, Courier New, monospace;
font-weight: 300;
background-color: #EEF2F8;
padding: 20px;
}
code {
margin-right: 6px;
}
.home-intro h3 {
font-family: Merriweather, serif;
margin: 2rem 0;
}
ul { padding-left: 2em; }
li { vertical-align: top; font: 14px/32px menlo, sans-serif; color: #777 }
li code { padding: 0.3em 0.5em; display: pre; color: #333; background: #EEF2F8 }
li a { display: inline }
a code { color: #06D }
`}
</style>
</div>
@ -77,8 +89,8 @@ const colorExamples = () => {
const colors = ['blue', 'cyan', 'green', 'yellow', 'orange', 'red', 'pink', 'purple', 'grey', 'black']
return colors.map(c => (
<a href={`/badge/color/${c}/${c}`} key={c}>
<img src={`/badge/color/${c}/${c}`} />
<style jsx>{`
<Image alt={c} src={`/badge/color/${c}/${c}`} width='30' height='20' />
<style>{`
a {
margin-right: 4px;
}
@ -93,8 +105,8 @@ const iconExamples = () => {
const url = `/badge/icon/${icon}?icon=${icon}&label`
return (
<a href={url} key={icon}>
<img src={url} />
<style jsx>{`
<Image alt={icon} src={url} width='30' height='20' />
<style>{`
a {
margin-right: 4px;
}
@ -105,7 +117,7 @@ const iconExamples = () => {
})
}
const explainCode = (isFlat) => {
const explainCode = (isFlat: Boolean) => {
const text = `
https://badgen.net/badge/:subject/:status/:color?icon=github
@ -114,12 +126,13 @@ https://badgen.net/badge/:subject/:status/:color?icon=github
TEXT TEXT RGB / COLOR_NAME ( optional )
"badge" - default (static) badge generator`
if (isFlat) {
return text
.replace('badgen.net', 'flat.badgen.net')
.replace(/\n/g, '\n ')
.trim()
} else {
return text.trim()
}
return text.trim()
}

Wyświetl plik

@ -1,39 +0,0 @@
const TopBar = () => {
return (
<div className="topbar">
<div className="navs">
<a href="https://badgen.net">CLASSIC STYLE</a>
<a href="https://flat.badgen.net">FLAT STYLE</a>
<a href="/builder">BADGE BUILDER</a>
</div>
<div className="news">
<a href="https://opencollective.com/badgen">
Consider donating to help us sustain our service
</a>
</div>
<style jsx>{`
.topbar {
height: 50px;
line-height: 50px;
padding: 0 0.5em;
display: grid;
grid-template-columns: 1fr 460px;
}
.navs {
letter-spacing: 0.04em;
}
.news {
text-align: right;
}
a {
display: inline-block;
font-size: 14px;
margin: 0 1em;
color: #777;
}
`}</style>
</div>
)
}
export default TopBar

Wyświetl plik

@ -1,6 +1,10 @@
import got from 'got'
export default got.extend({
timeout: 3200,
retry: 0
})
timeout: {
request: 3200,
},
retry: {
limit: 0,
}
})<any>

657
package-lock.json wygenerowano

Plik diff jest za duży Load Diff

Wyświetl plik

@ -8,7 +8,8 @@
"lint": "eslint --ext .js,.ts,.jsx .",
"build:api": "tsc -p server.tsconfig.json",
"build:web": "next build && next export -o dist",
"build": "npm run tools && npm run build:web && npm run build:api",
"build-0": "npm run tools && npm run build:web && npm run build:api",
"build": "next build",
"dev": "npm run build && npm run dev:api",
"dev:api": "nodemon --config nodemon.json index.ts",
"dev:web": "next",
@ -29,7 +30,7 @@
"byte-size": "^8.1.0",
"date-fns": "^2.21.1",
"eslint-config-next": "^13.1.1",
"got": "^10.7.0",
"got": "^12.5.3",
"haxe-rpc-client": "^1.0.0",
"humanize-duration": "^3.24.0",
"lodash.debounce": "^4.0.8",
@ -38,7 +39,6 @@
"millify": "^4.0.0",
"my-way": "^2.0.0",
"original-url": "^1.2.3",
"react-debounce-render": "^8.0.2",
"semver": "^7.3.5",
"serve-handler": "^6.1.3",
"serve-marked": "^4.0.0",
@ -74,11 +74,11 @@
"typescript": "^4.9.4"
},
"engines": {
"node": ">=16.x",
"npm": ">=8.x"
"node": ">=18.x",
"npm": ">=9.x"
},
"volta": {
"node": "16.15.0",
"npm": "8.5.5"
"node": "18.10.0",
"npm": "9.2.0"
}
}

Wyświetl plik

@ -7,7 +7,7 @@ export default function Document() {
<Head>
<link rel='icon' type='image/png' href='/static/favicon.png' />
<meta name='viewport' content='initial-scale=1.0, width=device-width' />
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Merriweather:700,300&display=optional' />
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Merriweather:700,300&display=swap' />
<Script
src="https://www.googletagmanager.com/gtag/js?id=UA-4646421-14"
strategy="afterInteractive"

Wyświetl plik

@ -1,22 +1,84 @@
import Head from 'next/head'
import Image from 'next/image'
import { Inter } from '@next/font/google'
import { Inter, Merriweather } from '@next/font/google'
import styles from '../styles/Home.module.css'
const inter = Inter({ subsets: ['latin'] })
const merriweather = Inter({ subsets: ['latin'] })
export default function Home() {
return (
<>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={styles.main}>
asdf
</main>
</>
)
// export default function Home() {
// return (
// <>
// <Head>
// <title>Create Next App</title>
// <meta name="description" content="Generated by create next app" />
// <meta name="viewport" content="width=device-width, initial-scale=1" />
// <link rel="icon" href="/favicon.ico" />
// </Head>
// <main className={styles.main}>
// asdf
// </main>
// </>
// )
// }
import { useState, useEffect } from 'react'
import BadgeExamples from '../components/badge-examples'
import BadgenTitle from '../components/badgen-title'
// import TopBar from '../components/top-bar'
import Intro from '../components/home-intro'
import Footer from '../components/footer'
import examples from '../static/.meta/badges.json'
export default function Index () {
const [tab, setTab] = useState('live')
const [host, setHost] = useState('')
const badges = examples[tab]
useEffect(() => {
const forceHost = new URL(window.location.href).searchParams.get('host')
setHost((forceHost || window.location.origin) + '/')
})
return <>
<BadgenTitle host={host} />
<div className='body-wrapper'>
<Intro />
</div>
<Footer />
<style>{`
.docs {
margin: 0 auto;
padding-bottom: 6em;
}
p {
text-align: center
}
.tab-row {
text-align: center;
}
.tab {
display: inline-block;
border: 1px solid #333;
margin-bottom: 2rem;
}
.tab a {
display: inline-block;
padding: 0 8px;
color: #333;
font: 14px/26px sans-serif;
text-transform: uppercase;
}
.tab a:hover {
cursor: pointer;
}
.live a.live,
.static a.static {
color: #EEE;
background-color: #333;
}
`}
</style>
</> // eslint-disable-line
}

Wyświetl plik

@ -5,72 +5,6 @@
'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro',
'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
--primary-glow: conic-gradient(
from 180deg at 50% 50%,
#16abff33 0deg,
#0885ff33 55deg,
#54d6ff33 120deg,
#0071ff33 160deg,
transparent 360deg
);
--secondary-glow: radial-gradient(
rgba(255, 255, 255, 1),
rgba(255, 255, 255, 0)
);
--tile-start-rgb: 239, 245, 249;
--tile-end-rgb: 228, 232, 233;
--tile-border: conic-gradient(
#00000080,
#00000040,
#00000030,
#00000020,
#00000010,
#00000010,
#00000080
);
--callout-rgb: 238, 240, 241;
--callout-border-rgb: 172, 175, 176;
--card-rgb: 180, 185, 188;
--card-border-rgb: 131, 134, 135;
}
@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
--primary-glow: radial-gradient(rgba(1, 65, 255, 0.4), rgba(1, 65, 255, 0));
--secondary-glow: linear-gradient(
to bottom right,
rgba(1, 65, 255, 0),
rgba(1, 65, 255, 0),
rgba(1, 65, 255, 0.3)
);
--tile-start-rgb: 2, 13, 46;
--tile-end-rgb: 2, 5, 19;
--tile-border: conic-gradient(
#ffffff80,
#ffffff40,
#ffffff30,
#ffffff20,
#ffffff10,
#ffffff10,
#ffffff80
);
--callout-rgb: 20, 20, 20;
--callout-border-rgb: 108, 108, 108;
--card-rgb: 100, 100, 100;
--card-border-rgb: 200, 200, 200;
}
}
* {
@ -87,12 +21,6 @@ body {
body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}
a {
@ -100,8 +28,7 @@ a {
text-decoration: none;
}
@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
}
.body-wrapper {
width: 980px;
margin: 0 auto;
}

Wyświetl plik

@ -34,7 +34,8 @@
"index.ts",
"components",
"pages",
"next-env.d.ts"
"next-env.d.ts",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"

Wyświetl plik

@ -1,13 +1,8 @@
{
"version": 2,
"regions": ["all"],
"builds": [
{ "src": "package.json", "use": "@vercel/static-build" },
{ "src": "api/*.ts", "use": "@vercel/node" }
],
"routes": [
{ "src": "/docs/(.*)", "status": 301, "headers": { "Location": "/$1" } },
{ "src": "/builder", "dest": "/builder.html" },
{ "src": "/(?<name>[^/]+).*", "dest": "/api/$name.ts" }
],
"env": {