mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-24 20:09:02 +00:00
Refactor: pnpm v11 & remove bun
This commit is contained in:
@@ -1 +0,0 @@
|
||||
preload = ["./scripts/preload.ts"]
|
||||
@@ -20,6 +20,8 @@ import {
|
||||
InlineTOC,
|
||||
} from '@/components/preview/lazy';
|
||||
import BannerImage from '@/public/banner.png';
|
||||
import { GraphView } from '@/components/preview/lazy';
|
||||
import { buildGraph } from '@/lib/build-graph';
|
||||
|
||||
export function heading(): ReactNode {
|
||||
return (
|
||||
@@ -246,3 +248,7 @@ export function githubInfo() {
|
||||
</Wrapper>
|
||||
);
|
||||
}
|
||||
|
||||
export async function graphView() {
|
||||
return <GraphView graph={await buildGraph()} />;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as radixUi from '../../../../packages/radix-ui/registry';
|
||||
import * as baseUi from '../../../../packages/base-ui/registry';
|
||||
import * as sanity from '../../../../packages/sanity/registry';
|
||||
import * as radixUi from '../../../../packages/radix-ui/registry/index.ts';
|
||||
import * as baseUi from '../../../../packages/base-ui/registry/index.ts';
|
||||
import * as sanity from '../../../../packages/sanity/registry/index.ts';
|
||||
import * as path from 'node:path';
|
||||
import type { CompileOptions, Registry } from 'fuma-cli/compiler';
|
||||
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
---
|
||||
title: Graph View
|
||||
description: A graph of all pages.
|
||||
preview: graphView
|
||||
---
|
||||
|
||||
import { GraphView } from '@/components/preview/lazy';
|
||||
import { buildGraph } from '@/lib/build-graph';
|
||||
|
||||
<GraphView graph={await buildGraph()} />
|
||||
|
||||
## Installation
|
||||
|
||||
You can install this from CLI:
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "pnpm build:pre && next build && pnpm build:post",
|
||||
"build:pre": "bun ./scripts/pre-build.ts",
|
||||
"build:post": "bun ./scripts/post-build.ts",
|
||||
"build:pre": "node ./scripts/pre-build.ts",
|
||||
"build:post": "node ./scripts/post-build.ts",
|
||||
"types:check": "fumadocs-mdx && next typegen && tsc --noEmit",
|
||||
"clean": "rimraf .next",
|
||||
"dev": "next dev",
|
||||
"lint": "fumadocs-mdx && bun ./scripts/lint.ts",
|
||||
"lint": "fumadocs-mdx && node ./scripts/lint.entry.ts",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -97,7 +97,8 @@
|
||||
"ts-morph": "^28.0.0",
|
||||
"tsconfig": "workspace:*",
|
||||
"typescript": "^6.0.3",
|
||||
"unified": "^11.0.5"
|
||||
"unified": "^11.0.5",
|
||||
"unrun": "^0.3.0"
|
||||
},
|
||||
"browserslist": [
|
||||
"extends browserslist-config-baseline/2024"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { compileOptions, registry } from '@/components/registry/index.js';
|
||||
import { compileOptions, registry } from '../components/registry/index.ts';
|
||||
import { compile, writeRegistry } from 'fuma-cli/compiler';
|
||||
|
||||
export async function buildRegistry() {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { postInstall } from 'fumadocs-mdx/next';
|
||||
import mdx from 'fumadocs-mdx/rolldown';
|
||||
import { unrun } from 'unrun';
|
||||
|
||||
process.env.LINT = '1';
|
||||
await postInstall();
|
||||
await unrun({
|
||||
path: './scripts/lint.ts',
|
||||
inputOptions: {
|
||||
plugins: [mdx(await import('../source.config.ts'))],
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import env from '@next/env';
|
||||
import { updateSearchIndexes } from './update-orama-index';
|
||||
import { updateSearchIndexes } from './update-orama-index.ts';
|
||||
|
||||
env.loadEnvConfig(process.cwd());
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { buildRegistry } from '@/scripts/build-registry';
|
||||
import { buildRegistry } from './build-registry.ts';
|
||||
|
||||
async function main() {
|
||||
await Promise.all([buildRegistry()]);
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { createMdxPlugin } from 'fumadocs-mdx/bun';
|
||||
import { postInstall } from 'fumadocs-mdx/next';
|
||||
|
||||
process.env.LINT = '1';
|
||||
const configPath = 'source.config.ts';
|
||||
await postInstall({ configPath });
|
||||
Bun.plugin(createMdxPlugin({ configPath }));
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type OramaDocument, sync } from 'fumadocs-core/search/orama-cloud';
|
||||
import * as fs from 'node:fs/promises';
|
||||
import { DataSourceId, isAdmin, orama } from '@/lib/orama/client';
|
||||
import { DataSourceId, isAdmin, orama } from '../lib/orama/client.ts';
|
||||
|
||||
export async function updateSearchIndexes(): Promise<void> {
|
||||
if (!isAdmin) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import jsonSchema from 'fumadocs-mdx/plugins/json-schema';
|
||||
import lastModified from 'fumadocs-mdx/plugins/last-modified';
|
||||
import type { ShikiTransformer } from 'shiki';
|
||||
import type { RemarkAutoTypeTableOptions } from 'fumadocs-typescript';
|
||||
import { defaultShikiOptions } from './lib/shiki';
|
||||
import { defaultShikiOptions } from './lib/shiki.ts';
|
||||
import { metaSchema, pageSchema } from 'fumadocs-core/source/schema';
|
||||
import { visit } from 'unist-util-visit';
|
||||
import type { Transformer } from 'unified';
|
||||
@@ -93,6 +93,7 @@ export const docs = defineDocs({
|
||||
},
|
||||
},
|
||||
},
|
||||
remarkImageOptions: isLint ? false : undefined,
|
||||
remarkNpmOptions: {
|
||||
persist: {
|
||||
id: 'package-manager',
|
||||
@@ -144,6 +145,7 @@ export const blog = defineCollections({
|
||||
remarkCodeTabOptions: {
|
||||
parseMdx: true,
|
||||
},
|
||||
remarkImageOptions: isLint ? false : undefined,
|
||||
remarkNpmOptions: {
|
||||
persist: {
|
||||
id: 'package-manager',
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
"paths": {
|
||||
"@/*": ["./*"],
|
||||
"collections/*": ["./.source/*"]
|
||||
}
|
||||
},
|
||||
"allowImportingTsExtensions": true
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "content/**/*.mdx", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules", "eslint.config.mjs", "components/registry/build-graph.ts"]
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# Unkey API Docs
|
||||
|
||||
This is an example API documentation based on Unkey's [API documentation](https://github.com/unkeyed/unkey), using Fumadocs OpenAPI.
|
||||
@@ -42,7 +42,9 @@ export async function generateStaticParams() {
|
||||
return source.generateParams();
|
||||
}
|
||||
|
||||
export async function generateMetadata(props: { params: Promise<{ slug?: string[] }> }) {
|
||||
export async function generateMetadata(props: {
|
||||
params: Promise<{ slug?: string[] }>;
|
||||
}): Promise<Metadata> {
|
||||
const params = await props.params;
|
||||
const page = source.getPage(params.slug);
|
||||
if (!page) notFound();
|
||||
@@ -58,5 +60,5 @@ export async function generateMetadata(props: { params: Promise<{ slug?: string[
|
||||
card: 'summary_large_image',
|
||||
images: image,
|
||||
},
|
||||
} satisfies Metadata;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@ import { createMDX } from 'fumadocs-mdx/next';
|
||||
|
||||
const withMDX = createMDX();
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const config = {
|
||||
export default withMDX({
|
||||
reactStrictMode: true,
|
||||
};
|
||||
|
||||
export default withMDX(config);
|
||||
});
|
||||
@@ -4,7 +4,6 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "next build",
|
||||
"build:docs": "bun ./scripts/generate-docs.ts",
|
||||
"dev": "next dev",
|
||||
"start": "next start",
|
||||
"types:check": "fumadocs-mdx && tsc --noEmit"
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import * as OpenAPI from 'fumadocs-openapi';
|
||||
import { rimraf } from 'rimraf';
|
||||
import { openapi } from '@/lib/openapi';
|
||||
|
||||
const out = './content/docs/(api)';
|
||||
|
||||
async function generate() {
|
||||
// clean generated files
|
||||
await rimraf(out, {
|
||||
filter(v) {
|
||||
return !v.endsWith('meta.json');
|
||||
},
|
||||
});
|
||||
|
||||
await OpenAPI.generateFiles({
|
||||
input: openapi,
|
||||
output: out,
|
||||
});
|
||||
}
|
||||
|
||||
void generate();
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
|
||||
import { i18n } from '@/lib/i18n';
|
||||
import { i18n } from '#/lib/i18n.ts';
|
||||
|
||||
export function baseOptions(locale = i18n.defaultLanguage): BaseLayoutProps {
|
||||
return {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { loader } from 'fumadocs-core/source';
|
||||
import { docs } from 'collections/server';
|
||||
import { i18n } from '@/lib/i18n';
|
||||
import { docs } from '#/collections/server.ts';
|
||||
import { i18n } from '#/lib/i18n.ts';
|
||||
|
||||
export const source = loader({
|
||||
source: docs.toFumadocsSource(),
|
||||
|
||||
@@ -11,7 +11,7 @@ import { RootProvider } from 'fumadocs-ui/provider/react-router';
|
||||
import type { Route } from './+types/root';
|
||||
import './app.css';
|
||||
import type { Translations } from 'fumadocs-ui/i18n';
|
||||
import { i18n } from '@/lib/i18n';
|
||||
import { i18n } from '#/lib/i18n.ts';
|
||||
import NotFound from './routes/not-found';
|
||||
|
||||
export const links: Route.LinksFunction = () => [
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { Route } from './+types/docs';
|
||||
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
|
||||
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/layouts/docs/page';
|
||||
import { source } from '@/lib/source';
|
||||
import browserCollections from 'collections/browser';
|
||||
import { baseOptions } from '@/lib/layout.shared';
|
||||
import { source } from '#/lib/source.ts';
|
||||
import browserCollections from '#/collections/browser.ts';
|
||||
import { baseOptions } from '#/lib/layout.shared.tsx';
|
||||
import { useFumadocsLoader } from 'fumadocs-core/source/client';
|
||||
import { useMDXComponents } from '@/components/mdx';
|
||||
import { useMDXComponents } from '#/components/mdx.tsx';
|
||||
|
||||
export async function loader({ params }: Route.LoaderArgs) {
|
||||
const slugs = params['*'].split('/').filter((v) => v.length > 0);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { Route } from './+types/home';
|
||||
import { HomeLayout } from 'fumadocs-ui/layouts/home';
|
||||
import { Link } from 'react-router';
|
||||
import { baseOptions } from '@/lib/layout.shared';
|
||||
import { baseOptions } from '#/lib/layout.shared.tsx';
|
||||
|
||||
export function meta({}: Route.MetaArgs) {
|
||||
export function meta(_meta: Route.MetaArgs) {
|
||||
return [
|
||||
{ title: 'New React Router App' },
|
||||
{ name: 'description', content: 'Welcome to React Router!' },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Route } from './+types/not-found';
|
||||
import { HomeLayout } from 'fumadocs-ui/layouts/home';
|
||||
import { Link } from 'react-router';
|
||||
import { baseOptions } from '@/lib/layout.shared';
|
||||
import { baseOptions } from '#/lib/layout.shared.tsx';
|
||||
|
||||
export function meta({}: Route.MetaArgs) {
|
||||
return [{ title: 'Not Found' }];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Route } from './+types/search';
|
||||
import { createFromSource } from 'fumadocs-core/search/server';
|
||||
import { source } from '@/lib/source';
|
||||
import { source } from '#/lib/source.ts';
|
||||
import { createTokenizer } from '@orama/tokenizers/mandarin';
|
||||
|
||||
const server = createFromSource(source, {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
preload = ["./scripts/preload.ts"]
|
||||
@@ -2,8 +2,12 @@
|
||||
"name": "example-react-router-i18n",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"imports": {
|
||||
"#/collections/*": "./.source/*",
|
||||
"#/*": "./app/*"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bun scripts/generate-info.ts && react-router build",
|
||||
"build": "node scripts/generate-info.ts && react-router build",
|
||||
"dev": "react-router dev",
|
||||
"start": "react-router-serve ./build/server/index.js",
|
||||
"types:check": "react-router typegen && fumadocs-mdx && tsc --noEmit"
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
import { source } from '@/lib/source';
|
||||
import { register } from 'fumadocs-mdx/node';
|
||||
import { postInstall } from 'fumadocs-mdx/vite';
|
||||
import { writeFile } from 'node:fs/promises';
|
||||
|
||||
register();
|
||||
|
||||
await postInstall({
|
||||
index: {
|
||||
target: 'default',
|
||||
},
|
||||
});
|
||||
|
||||
export interface Info {
|
||||
prerender: string[];
|
||||
}
|
||||
|
||||
const { source } = await import('../app/lib/source.ts');
|
||||
const info: Info = {
|
||||
prerender: source.getPages().map((page) => page.url),
|
||||
};
|
||||
|
||||
await Bun.write('.react-router/_info', JSON.stringify(info));
|
||||
await writeFile('.react-router/_info', JSON.stringify(info));
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { createMdxPlugin } from 'fumadocs-mdx/bun';
|
||||
import { postInstall } from 'fumadocs-mdx/vite';
|
||||
|
||||
Bun.plugin(createMdxPlugin());
|
||||
|
||||
await postInstall({
|
||||
index: {
|
||||
target: 'default',
|
||||
},
|
||||
});
|
||||
@@ -7,11 +7,9 @@
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "react-jsx",
|
||||
"resolvePackageJsonImports": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"rootDirs": [".", "./.react-router/types"],
|
||||
"paths": {
|
||||
"@/*": ["./app/*"],
|
||||
"collections/*": ["./.source/*"]
|
||||
},
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
|
||||
+1
-2
@@ -18,7 +18,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@changesets/cli": "^2.31.0",
|
||||
"bun": "1.3.13",
|
||||
"concurrently": "^9.2.1",
|
||||
"oxfmt": "^0.48.0",
|
||||
"oxlint": "^1.63.0",
|
||||
@@ -30,5 +29,5 @@
|
||||
"engines": {
|
||||
"node": ">= 24.14.0"
|
||||
},
|
||||
"packageManager": "pnpm@10.18.3"
|
||||
"packageManager": "pnpm@11.1.0"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import * as path from 'node:path';
|
||||
import type { Registry } from 'fuma-cli/compiler';
|
||||
import { commonComponents, findSlotComponents } from '../../shared/registry';
|
||||
import { commonComponents, findSlotComponents } from '../../shared/registry.ts';
|
||||
|
||||
const dir = path.join(path.dirname(fileURLToPath(import.meta.url)), '../src');
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
},
|
||||
"types": ["@types/mdx"]
|
||||
"types": ["@types/mdx"],
|
||||
"allowImportingTsExtensions": true
|
||||
},
|
||||
"exclude": ["node_modules", "dist", "eslint.config.mjs"]
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
"lint": "oxlint .",
|
||||
"postpublish": "echo \"Updating template repo\" && bash ./scripts/update-git-repo.sh",
|
||||
"types:check": "tsc --noEmit",
|
||||
"sync": "bun ./scripts/sync.ts"
|
||||
"sync": "node ./scripts/sync.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.3.0",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { copy } from '@/utils';
|
||||
import { copy } from '../src/utils.ts';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import fs from 'node:fs/promises';
|
||||
@@ -77,6 +77,8 @@ async function main() {
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
console.log('updated create-fumadocs-app');
|
||||
}
|
||||
|
||||
void main();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"allowImportingTsExtensions": true,
|
||||
"moduleResolution": "bundler",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import * as path from 'node:path';
|
||||
import { commonComponents, findSlotComponents } from '../../shared/registry';
|
||||
import { commonComponents, findSlotComponents } from '../../shared/registry.ts';
|
||||
import type { Registry } from 'fuma-cli/compiler';
|
||||
|
||||
const dir = path.join(path.dirname(fileURLToPath(import.meta.url)), '../src');
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
},
|
||||
"allowImportingTsExtensions": true,
|
||||
"types": ["@types/mdx"]
|
||||
},
|
||||
"exclude": ["node_modules", "dist", "eslint.config.mjs"]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "shared",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"fuma-cli": "^0.1.1",
|
||||
"tinyglobby": "^0.2.16"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"declarationMap": false,
|
||||
"incremental": true,
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "preserve",
|
||||
"jsx": "react-jsx",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"module": "esnext",
|
||||
"noEmit": true,
|
||||
|
||||
Generated
+259
-427
File diff suppressed because it is too large
Load Diff
+8
-2
@@ -2,5 +2,11 @@ packages:
|
||||
- packages/*
|
||||
- apps/*
|
||||
- examples/*
|
||||
onlyBuiltDependencies:
|
||||
- bun
|
||||
allowBuilds:
|
||||
'@parcel/watcher': false
|
||||
core-js: false
|
||||
esbuild: false
|
||||
msw: false
|
||||
protobufjs: false
|
||||
sharp: false
|
||||
vue-demi: false
|
||||
|
||||
Reference in New Issue
Block a user