chore: deps

This commit is contained in:
iCrawl
2024-03-11 17:50:39 +01:00
parent 5f2095b76c
commit 0d4c26ba4c
32 changed files with 2218 additions and 2304 deletions

View File

@@ -22,8 +22,7 @@ export default withBundleAnalyzer({
},
webpack(config, { isServer }) {
if (!isServer) {
// Don't include any locale strings in the client JS bundle.
config.plugins.push(localesPlugin.webpack({ locales: [] }));
config.plugins.push(localesPlugin.webpack({ locales: ['en-US'] }));
}
return config;

View File

@@ -53,33 +53,33 @@
"@vercel/edge-config": "^1.1.0",
"@vercel/og": "^0.6.2",
"@vercel/postgres": "^0.7.2",
"cmdk": "^0.2.1",
"cmdk": "^1.0.0",
"geist": "^1.2.2",
"jotai": "^2.7.0",
"lucide-react": "^0.344.0",
"meilisearch": "^0.37.0",
"next": "14.1.2-canary.2",
"lucide-react": "^0.356.0",
"meilisearch": "^0.38.0",
"next": "14.2.0-canary.13",
"next-mdx-remote": "^4.4.1",
"next-themes": "^0.2.1",
"overlayscrollbars": "^2.5.0",
"overlayscrollbars": "^2.6.0",
"overlayscrollbars-react": "^0.5.4",
"react": "^18.2.0",
"react-aria-components": "^1.1.1",
"react-dom": "^18.2.0",
"sharp": "^0.33.2",
"usehooks-ts": "^2.15.1",
"usehooks-ts": "^3.0.1",
"vaul": "^0.9.0"
},
"devDependencies": {
"@next/bundle-analyzer": "14.1.2-canary.2",
"@next/bundle-analyzer": "14.2.0-canary.13",
"@react-aria/optimize-locales-plugin": "^1.0.2",
"@shikijs/rehype": "1.1.7",
"@tailwindcss/typography": "^0.5.10",
"@testing-library/react": "^14.2.1",
"@testing-library/user-event": "^14.5.2",
"@types/node": "18.18.8",
"@types/react": "^18.2.61",
"@types/react-dom": "^18.2.19",
"@types/react": "^18.2.64",
"@types/react-dom": "^18.2.21",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^1.3.1",
"autoprefixer": "^10.4.18",
@@ -88,17 +88,17 @@
"eslint": "^8.57.0",
"eslint-config-neon": "^0.1.59",
"eslint-formatter-pretty": "^6.0.1",
"happy-dom": "^13.6.2",
"happy-dom": "^13.7.3",
"postcss": "^8.4.35",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.11",
"prettier-plugin-tailwindcss": "^0.5.12",
"remark-gfm": "^3.0.1",
"remark-rehype": "^11.1.0",
"shiki": "1.1.7",
"tailwindcss": "^3.4.1",
"turbo": "^1.12.4",
"typescript": "^5.3.3",
"vercel": "^33.5.3",
"turbo": "^1.12.5",
"typescript": "^5.4.2",
"vercel": "^33.5.5",
"vitest": "^1.3.1"
},
"engines": {

View File

@@ -0,0 +1,16 @@
import Link from 'next/link';
export default function NotFound() {
return (
<div className="mx-auto flex min-h-[calc(100vh_-_100px)] max-w-lg flex-col place-content-center place-items-center gap-8 px-8 py-16 lg:px-6 lg:py-0">
<h1 className="text-[9rem] font-black leading-none md:text-[12rem]">404</h1>
<h2 className="text-[2rem] md:text-[3rem]">Not found.</h2>
<Link
className="inline-flex rounded-md border border-transparent bg-blurple px-6 py-2 font-medium text-white"
href="/docs"
>
Take me back
</Link>
</div>
);
}

View File

@@ -8,9 +8,13 @@ async function fetchLatestVersion(packageName: string): Promise<string> {
return 'main';
}
const { rows } = await sql`select version from documentation where name = ${packageName} order by version desc`;
try {
const { rows } = await sql`select version from documentation where name = ${packageName} order by version desc`;
return rows.map((row) => row.version).at(1) ?? 'main';
return rows.map((row) => row.version).at(1) ?? 'main';
} catch {
return '';
}
}
export default async function middleware(request: NextRequest) {

View File

@@ -10,21 +10,34 @@ export async function fetchDependencies({
readonly version: string;
}) {
if (ENV.IS_LOCAL_DEV) {
const fileContent = await readFile(
join(process.cwd(), `../../packages/${packageName}/docs/${packageName}/split/${version}.dependencies.api.json`),
'utf8',
);
try {
const fileContent = await readFile(
join(process.cwd(), `../../packages/${packageName}/docs/${packageName}/split/${version}.dependencies.api.json`),
'utf8',
);
return JSON.parse(fileContent);
const parsedDependencies = JSON.parse(fileContent);
return Object.entries<string>(parsedDependencies)
.filter(([key]) => key.startsWith('@discordjs/') && !key.includes('api-extractor'))
.map(([key, value]) => `${key.replace('@discordjs/', '').replaceAll('.', '-')}-${value.replaceAll('.', '-')}`);
} catch {
return [];
}
}
const isMainVersion = version === 'main';
const fileContent = await fetch(
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.dependencies.api.json`,
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
);
const parsedDependencies = await fileContent.json();
return Object.entries<string>(parsedDependencies)
.filter(([key]) => key.startsWith('@discordjs/') && !key.includes('api-extractor'))
.map(([key, value]) => `${key.replace('@discordjs/', '').replaceAll('.', '-')}-${value.replaceAll('.', '-')}`);
try {
const isMainVersion = version === 'main';
const fileContent = await fetch(
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.dependencies.api.json`,
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
);
const parsedDependencies = await fileContent.json();
return Object.entries<string>(parsedDependencies)
.filter(([key]) => key.startsWith('@discordjs/') && !key.includes('api-extractor'))
.map(([key, value]) => `${key.replace('@discordjs/', '').replaceAll('.', '-')}-${value.replaceAll('.', '-')}`);
} catch {
return [];
}
}

View File

@@ -6,7 +6,11 @@ export async function fetchLatestVersion(packageName: string): Promise<string> {
return 'main';
}
const { rows } = await sql`select version from documentation where name = ${packageName} order by version desc`;
try {
const { rows } = await sql`select version from documentation where name = ${packageName} order by version desc`;
return rows.map((row) => row.version).at(1) ?? 'main';
return rows.map((row) => row.version).at(1) ?? 'main';
} catch {
return '';
}
}

View File

@@ -1,5 +1,6 @@
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { notFound } from 'next/navigation';
import { ENV } from './env';
export async function fetchNode({
@@ -14,17 +15,27 @@ export async function fetchNode({
const normalizeItem = item.split(encodeURIComponent(':')).join('.').toLowerCase();
if (ENV.IS_LOCAL_DEV) {
const fileContent = await readFile(
join(process.cwd(), `../../packages/${packageName}/docs/split/${version}.${normalizeItem}.api.json`),
'utf8',
);
return JSON.parse(fileContent);
try {
const fileContent = await readFile(
join(process.cwd(), `../../packages/${packageName}/docs/split/${version}.${normalizeItem}.api.json`),
'utf8',
);
return JSON.parse(fileContent);
} catch {
notFound();
}
}
const isMainVersion = version === 'main';
const fileContent = await fetch(
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.${normalizeItem}.api.json`,
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
);
return fileContent.json();
try {
const isMainVersion = version === 'main';
const fileContent = await fetch(
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.${normalizeItem}.api.json`,
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
);
return await fileContent.json();
} catch {
notFound();
}
}

View File

@@ -1,5 +1,6 @@
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { notFound } from 'next/navigation';
import { ENV } from './env';
export async function fetchSitemap({
@@ -10,17 +11,27 @@ export async function fetchSitemap({
readonly version: string;
}) {
if (ENV.IS_LOCAL_DEV) {
const fileContent = await readFile(
join(process.cwd(), `../../packages/${packageName}/docs/split/${version}.sitemap.api.json`),
'utf8',
);
return JSON.parse(fileContent);
try {
const fileContent = await readFile(
join(process.cwd(), `../../packages/${packageName}/docs/split/${version}.sitemap.api.json`),
'utf8',
);
return JSON.parse(fileContent);
} catch {
notFound();
}
}
const isMainVersion = version === 'main';
const fileContent = await fetch(
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.sitemap.api.json`,
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
);
return fileContent.json();
try {
const isMainVersion = version === 'main';
const fileContent = await fetch(
`${process.env.BLOB_STORAGE_URL}/rewrite/${packageName}/${version}.sitemap.api.json`,
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
);
return await fileContent.json();
} catch {
notFound();
}
}