@fumadocs/cli 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +64 -51
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -238,7 +238,7 @@ async function init(plugin, config = {}) {
|
|
|
238
238
|
if (value) {
|
|
239
239
|
await plugin.transform(ctx);
|
|
240
240
|
note(
|
|
241
|
-
`You can format the output with Prettier or other code
|
|
241
|
+
`You can format the output with Prettier or other code formatting tools
|
|
242
242
|
prettier . --write`,
|
|
243
243
|
picocolors.bold(picocolors.green("Changes Applied"))
|
|
244
244
|
);
|
|
@@ -256,6 +256,9 @@ prettier . --write`,
|
|
|
256
256
|
if (text.type === "code") {
|
|
257
257
|
note(text.code, text.title);
|
|
258
258
|
}
|
|
259
|
+
if (text.type === "title") {
|
|
260
|
+
log.step(text.text);
|
|
261
|
+
}
|
|
259
262
|
}
|
|
260
263
|
}
|
|
261
264
|
|
|
@@ -421,7 +424,7 @@ function localResolver(dir) {
|
|
|
421
424
|
import picocolors3 from "picocolors";
|
|
422
425
|
|
|
423
426
|
// src/generated.js
|
|
424
|
-
var generated = { "app/docs-og/[...slug]/route": "import { generateOGImage } from 'fumadocs-ui/og';\nimport { metadataImage } from '@/lib/metadata';\n\nexport const GET = metadataImage.createAPI((page) => {\n return generateOGImage({\n title: page.data.title,\n description: page.data.description,\n site: 'My App',\n });\n});\n\nexport function generateStaticParams() {\n return metadataImage.generateParams();\n}\n", "lib/i18n": "import type { I18nConfig } from 'fumadocs-core/i18n';\n\nexport const i18n: I18nConfig = {\n defaultLanguage: 'en',\n languages: ['en', 'cn'],\n};\n", "middleware": "import { createI18nMiddleware } from 'fumadocs-core/i18n';\nimport { i18n } from '@/lib/i18n';\n\nexport default createI18nMiddleware(i18n);\n\nexport const config = {\n // Matcher ignoring `/_next/` and `/api/`\n matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],\n};\n", "scripts/generate-docs": "import * as OpenAPI from 'fumadocs-openapi';\nimport { rimrafSync } from 'rimraf';\n\nconst out = './content/docs/(api)';\n\n// clean generated files\nrimrafSync(out, {\n filter(v) {\n return !v.endsWith('index.mdx') && !v.endsWith('meta.json');\n },\n});\n\nvoid OpenAPI.generateFiles({\n // input files\n input: ['./openapi.json'],\n output: out,\n groupBy: 'tag',\n});\n"
|
|
427
|
+
var generated = { "lib/metadata": "import { createMetadataImage } from 'fumadocs-core/server';\nimport { source } from '@/lib/source';\n\nexport const metadataImage = createMetadataImage({\n imageRoute: '/docs-og',\n source,\n});\n", "app/docs-og/[...slug]/route": "import { generateOGImage } from 'fumadocs-ui/og';\nimport { metadataImage } from '@/lib/metadata';\n\nexport const GET = metadataImage.createAPI((page) => {\n return generateOGImage({\n title: page.data.title,\n description: page.data.description,\n site: 'My App',\n });\n});\n\nexport function generateStaticParams() {\n return metadataImage.generateParams();\n}\n", "lib/i18n": "import type { I18nConfig } from 'fumadocs-core/i18n';\n\nexport const i18n: I18nConfig = {\n defaultLanguage: 'en',\n languages: ['en', 'cn'],\n};\n", "middleware": "import { createI18nMiddleware } from 'fumadocs-core/i18n';\nimport { i18n } from '@/lib/i18n';\n\nexport default createI18nMiddleware(i18n);\n\nexport const config = {\n // Matcher ignoring `/_next/` and `/api/`\n matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],\n};\n", "scripts/generate-docs": "import * as OpenAPI from 'fumadocs-openapi';\nimport { rimrafSync } from 'rimraf';\n\nconst out = './content/docs/(api)';\n\n// clean generated files\nrimrafSync(out, {\n filter(v) {\n return !v.endsWith('index.mdx') && !v.endsWith('meta.json');\n },\n});\n\nvoid OpenAPI.generateFiles({\n // input files\n input: ['./openapi.json'],\n output: out,\n groupBy: 'tag',\n});\n" };
|
|
425
428
|
|
|
426
429
|
// src/plugins/og-image.ts
|
|
427
430
|
function isI18nEnabled(ctx) {
|
|
@@ -473,7 +476,6 @@ export function generateMetadata({ params }: { params: { slug?: string[] } }) {
|
|
|
473
476
|
|
|
474
477
|
// src/plugins/i18n.ts
|
|
475
478
|
import path7 from "node:path";
|
|
476
|
-
import picocolors4 from "picocolors";
|
|
477
479
|
import { log as log3 } from "@clack/prompts";
|
|
478
480
|
|
|
479
481
|
// src/utils/i18n/transform-layout-config.ts
|
|
@@ -508,6 +510,10 @@ import fs5 from "node:fs/promises";
|
|
|
508
510
|
import path5 from "node:path";
|
|
509
511
|
var transformExtensions = [".js", ".ts", ".tsx", ".jsx"];
|
|
510
512
|
async function moveFiles(from, to, filter, project, src2, originalDir = from) {
|
|
513
|
+
function isIncluded(file) {
|
|
514
|
+
if (!transformExtensions.includes(path5.extname(file))) return false;
|
|
515
|
+
return filter(path5.resolve(file));
|
|
516
|
+
}
|
|
511
517
|
const stats = await fs5.lstat(from).catch(() => void 0);
|
|
512
518
|
if (!stats) return;
|
|
513
519
|
if (stats.isDirectory()) {
|
|
@@ -515,8 +521,8 @@ async function moveFiles(from, to, filter, project, src2, originalDir = from) {
|
|
|
515
521
|
await Promise.all(
|
|
516
522
|
items.map(async (item) => {
|
|
517
523
|
await moveFiles(
|
|
518
|
-
path5.
|
|
519
|
-
path5.
|
|
524
|
+
path5.join(from, item),
|
|
525
|
+
path5.join(to, item),
|
|
520
526
|
filter,
|
|
521
527
|
project,
|
|
522
528
|
src2,
|
|
@@ -527,31 +533,31 @@ async function moveFiles(from, to, filter, project, src2, originalDir = from) {
|
|
|
527
533
|
await fs5.rmdir(from).catch(() => {
|
|
528
534
|
});
|
|
529
535
|
}
|
|
530
|
-
if (!stats.isFile()) return;
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
alias: {
|
|
542
|
-
type: "append",
|
|
543
|
-
dir: src2 ? "src" : ""
|
|
544
|
-
},
|
|
545
|
-
relativeTo: path5.dirname(from)
|
|
536
|
+
if (!stats.isFile() || !await isIncluded(from)) return;
|
|
537
|
+
const content = await fs5.readFile(from);
|
|
538
|
+
const sourceFile = project.createSourceFile(from, content.toString(), {
|
|
539
|
+
overwrite: true
|
|
540
|
+
});
|
|
541
|
+
await transformReferences(
|
|
542
|
+
sourceFile,
|
|
543
|
+
{
|
|
544
|
+
alias: {
|
|
545
|
+
type: "append",
|
|
546
|
+
dir: src2 ? "src" : ""
|
|
546
547
|
},
|
|
547
|
-
(
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
548
|
+
relativeTo: path5.dirname(from)
|
|
549
|
+
},
|
|
550
|
+
async (resolved) => {
|
|
551
|
+
if (resolved.type !== "file") return;
|
|
552
|
+
if (
|
|
553
|
+
// ignore if the file is also moved
|
|
554
|
+
isRelative(originalDir, from) && await isIncluded(resolved.path)
|
|
555
|
+
)
|
|
556
|
+
return;
|
|
557
|
+
return toReferencePath(to, resolved.path);
|
|
558
|
+
}
|
|
559
|
+
);
|
|
560
|
+
await sourceFile.save();
|
|
555
561
|
await fs5.mkdir(path5.dirname(to), { recursive: true });
|
|
556
562
|
await fs5.rename(from, to);
|
|
557
563
|
}
|
|
@@ -641,6 +647,7 @@ function runTransform(sourceFile) {
|
|
|
641
647
|
}
|
|
642
648
|
|
|
643
649
|
// src/plugins/i18n.ts
|
|
650
|
+
import picocolors4 from "picocolors";
|
|
644
651
|
var i18nPlugin = {
|
|
645
652
|
files: ({ src: src2 }) => ({
|
|
646
653
|
"lib/i18n.ts": generated["lib/i18n"],
|
|
@@ -649,8 +656,19 @@ var i18nPlugin = {
|
|
|
649
656
|
dependencies: [],
|
|
650
657
|
instructions: () => [
|
|
651
658
|
{
|
|
652
|
-
type: "
|
|
653
|
-
text:
|
|
659
|
+
type: "title",
|
|
660
|
+
text: `1. Update the params of ${picocolors4.bold("page.tsx")} and ${picocolors4.bold("layout.tsx")}, and make them async if necessary.`
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
type: "code",
|
|
664
|
+
title: "layout.tsx",
|
|
665
|
+
code: `
|
|
666
|
+
export default async function Layout({
|
|
667
|
+
params,
|
|
668
|
+
}: {
|
|
669
|
+
${picocolors4.underline(picocolors4.bold("params: Promise<{ lang: string }>"))}
|
|
670
|
+
})
|
|
671
|
+
`.trim()
|
|
654
672
|
},
|
|
655
673
|
{
|
|
656
674
|
type: "code",
|
|
@@ -664,19 +682,12 @@ export default async function Page({
|
|
|
664
682
|
`.trim()
|
|
665
683
|
},
|
|
666
684
|
{
|
|
667
|
-
type: "
|
|
668
|
-
text: "Update
|
|
685
|
+
type: "title",
|
|
686
|
+
text: "2. Update references to your `source` object"
|
|
669
687
|
},
|
|
670
688
|
{
|
|
671
|
-
type: "
|
|
672
|
-
|
|
673
|
-
code: `const page = source.getPage(params.slug, params.lang);
|
|
674
|
-
const pages = source.getPage(params.lang);`
|
|
675
|
-
},
|
|
676
|
-
{
|
|
677
|
-
type: "code",
|
|
678
|
-
title: "layout.tsx",
|
|
679
|
-
code: `const tree = source.pageTree[params.lang];`
|
|
689
|
+
type: "text",
|
|
690
|
+
text: "You can follow the instructions in https://fumadocs.vercel.app/docs/ui/internationalization#source section."
|
|
680
691
|
}
|
|
681
692
|
],
|
|
682
693
|
async transform(ctx) {
|
|
@@ -700,7 +711,9 @@ const pages = source.getPage(params.lang);`
|
|
|
700
711
|
resolveAppPath("./app", ctx.src),
|
|
701
712
|
resolveAppPath("./app/[lang]", ctx.src),
|
|
702
713
|
(v) => {
|
|
703
|
-
|
|
714
|
+
const parsed = path7.parse(v);
|
|
715
|
+
if (parsed.ext === ".css") return false;
|
|
716
|
+
return parsed.name !== "layout.config" && !isRelative("./app/api", v);
|
|
704
717
|
},
|
|
705
718
|
project,
|
|
706
719
|
ctx.src
|
|
@@ -895,7 +908,7 @@ async function runTree(args) {
|
|
|
895
908
|
// package.json
|
|
896
909
|
var package_default = {
|
|
897
910
|
name: "@fumadocs/cli",
|
|
898
|
-
version: "0.0.
|
|
911
|
+
version: "0.0.8",
|
|
899
912
|
description: "The CLI tool for Fumadocs",
|
|
900
913
|
keywords: [
|
|
901
914
|
"NextJs",
|
|
@@ -929,19 +942,19 @@ var package_default = {
|
|
|
929
942
|
"types:check": "tsc --noEmit"
|
|
930
943
|
},
|
|
931
944
|
dependencies: {
|
|
932
|
-
"@clack/prompts": "^0.
|
|
933
|
-
commander: "^
|
|
945
|
+
"@clack/prompts": "^0.10.0",
|
|
946
|
+
commander: "^13.1.0",
|
|
934
947
|
execa: "^9.5.2",
|
|
935
|
-
"package-manager-detector": "^0.2.
|
|
948
|
+
"package-manager-detector": "^0.2.9",
|
|
936
949
|
picocolors: "^1.1.1",
|
|
937
|
-
"ts-morph": "^
|
|
950
|
+
"ts-morph": "^25.0.1"
|
|
938
951
|
},
|
|
939
952
|
devDependencies: {
|
|
940
953
|
"@types/cross-spawn": "^6.0.6",
|
|
941
|
-
"@types/node": "22.
|
|
942
|
-
"@types/react": "^19.0.
|
|
954
|
+
"@types/node": "22.13.1",
|
|
955
|
+
"@types/react": "^19.0.8",
|
|
943
956
|
"eslint-config-custom": "workspace:*",
|
|
944
|
-
"fast-glob": "^3.3.
|
|
957
|
+
"fast-glob": "^3.3.3",
|
|
945
958
|
tsconfig: "workspace:*",
|
|
946
959
|
tsx: "^4.19.2"
|
|
947
960
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fumadocs/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "The CLI tool for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
"dist/*"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@clack/prompts": "^0.
|
|
30
|
-
"commander": "^
|
|
29
|
+
"@clack/prompts": "^0.10.0",
|
|
30
|
+
"commander": "^13.1.0",
|
|
31
31
|
"execa": "^9.5.2",
|
|
32
|
-
"package-manager-detector": "^0.2.
|
|
32
|
+
"package-manager-detector": "^0.2.9",
|
|
33
33
|
"picocolors": "^1.1.1",
|
|
34
|
-
"ts-morph": "^
|
|
34
|
+
"ts-morph": "^25.0.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/cross-spawn": "^6.0.6",
|
|
38
|
-
"@types/node": "22.
|
|
39
|
-
"@types/react": "^19.0.
|
|
40
|
-
"fast-glob": "^3.3.
|
|
38
|
+
"@types/node": "22.13.1",
|
|
39
|
+
"@types/react": "^19.0.8",
|
|
40
|
+
"fast-glob": "^3.3.3",
|
|
41
41
|
"tsx": "^4.19.2",
|
|
42
42
|
"eslint-config-custom": "0.0.0",
|
|
43
43
|
"tsconfig": "0.0.0"
|