@fumadocs/cli 0.1.0 → 0.1.1
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/build/index.js +35 -39
- package/dist/index.js +31 -7
- package/package.json +3 -3
package/dist/build/index.js
CHANGED
|
@@ -254,7 +254,6 @@ async function buildComponent(component, builder) {
|
|
|
254
254
|
const subComponents = /* @__PURE__ */ new Set();
|
|
255
255
|
const devDependencies = /* @__PURE__ */ new Map();
|
|
256
256
|
const dependencies = /* @__PURE__ */ new Map();
|
|
257
|
-
const files = [];
|
|
258
257
|
async function build2(file) {
|
|
259
258
|
let inputPath;
|
|
260
259
|
let outputPath;
|
|
@@ -272,57 +271,54 @@ async function buildComponent(component, builder) {
|
|
|
272
271
|
inputPath = path3.join(builder.registryDir, file.in);
|
|
273
272
|
outputPath = file.out;
|
|
274
273
|
}
|
|
275
|
-
if (processedFiles.has(inputPath)) return;
|
|
274
|
+
if (processedFiles.has(inputPath)) return [];
|
|
276
275
|
processedFiles.add(inputPath);
|
|
277
276
|
const queue = [];
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
(reference)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
277
|
+
const result = await buildFile(
|
|
278
|
+
inputPath,
|
|
279
|
+
outputPath,
|
|
280
|
+
builder,
|
|
281
|
+
component,
|
|
282
|
+
(reference) => {
|
|
283
|
+
if (reference.type === "file") {
|
|
284
|
+
queue.push(path3.relative(builder.registryDir, reference.file));
|
|
285
|
+
return builder.resolveOutputPath(reference.file);
|
|
286
|
+
}
|
|
287
|
+
if (reference.type === "sub-component") {
|
|
288
|
+
const resolved = reference.resolved;
|
|
289
|
+
subComponents.add(resolved.component.name);
|
|
290
|
+
if (resolved.type === "remote") {
|
|
291
|
+
return reference.targetFile;
|
|
288
292
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
293
|
+
for (const childFile of resolved.component.files) {
|
|
294
|
+
if (typeof childFile === "string" && childFile === reference.targetFile) {
|
|
295
|
+
return builder.resolveOutputPath(
|
|
296
|
+
childFile,
|
|
297
|
+
reference.resolved.registryName
|
|
298
|
+
);
|
|
294
299
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return builder.resolveOutputPath(
|
|
298
|
-
childFile,
|
|
299
|
-
reference.resolved.registryName
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
if (typeof childFile === "object" && childFile.in === reference.targetFile) {
|
|
303
|
-
return childFile.out;
|
|
304
|
-
}
|
|
300
|
+
if (typeof childFile === "object" && childFile.in === reference.targetFile) {
|
|
301
|
+
return childFile.out;
|
|
305
302
|
}
|
|
306
|
-
throw new Error(
|
|
307
|
-
`Failed to find sub component ${resolved.component.name}'s ${reference.targetFile} referenced by ${inputPath}`
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
if (reference.type === "dependency") {
|
|
311
|
-
if (reference.isDev)
|
|
312
|
-
devDependencies.set(reference.name, reference.version);
|
|
313
|
-
else dependencies.set(reference.name, reference.version);
|
|
314
303
|
}
|
|
304
|
+
throw new Error(
|
|
305
|
+
`Failed to find sub component ${resolved.component.name}'s ${reference.targetFile} referenced by ${inputPath}`
|
|
306
|
+
);
|
|
315
307
|
}
|
|
316
|
-
|
|
308
|
+
if (reference.type === "dependency") {
|
|
309
|
+
if (reference.isDev)
|
|
310
|
+
devDependencies.set(reference.name, reference.version);
|
|
311
|
+
else dependencies.set(reference.name, reference.version);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
317
314
|
);
|
|
318
|
-
await Promise.all(queue.map(build2));
|
|
315
|
+
return [result, ...(await Promise.all(queue.map(build2))).flat()];
|
|
319
316
|
}
|
|
320
|
-
await Promise.all(component.files.map(build2));
|
|
321
317
|
return [
|
|
322
318
|
component,
|
|
323
319
|
{
|
|
324
320
|
name: component.name,
|
|
325
|
-
files,
|
|
321
|
+
files: (await Promise.all(component.files.map(build2))).flat(),
|
|
326
322
|
subComponents: Array.from(subComponents),
|
|
327
323
|
dependencies: Object.fromEntries(dependencies),
|
|
328
324
|
devDependencies: Object.fromEntries(devDependencies)
|
package/dist/index.js
CHANGED
|
@@ -424,7 +424,7 @@ function localResolver(dir) {
|
|
|
424
424
|
import picocolors3 from "picocolors";
|
|
425
425
|
|
|
426
426
|
// src/generated.js
|
|
427
|
-
var generated = { "
|
|
427
|
+
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/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", "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" };
|
|
428
428
|
|
|
429
429
|
// src/plugins/og-image.ts
|
|
430
430
|
function isI18nEnabled(ctx) {
|
|
@@ -908,7 +908,7 @@ async function runTree(args) {
|
|
|
908
908
|
// package.json
|
|
909
909
|
var package_default = {
|
|
910
910
|
name: "@fumadocs/cli",
|
|
911
|
-
version: "0.1.
|
|
911
|
+
version: "0.1.1",
|
|
912
912
|
description: "The CLI tool for Fumadocs",
|
|
913
913
|
keywords: [
|
|
914
914
|
"NextJs",
|
|
@@ -951,8 +951,8 @@ var package_default = {
|
|
|
951
951
|
},
|
|
952
952
|
devDependencies: {
|
|
953
953
|
"@types/cross-spawn": "^6.0.6",
|
|
954
|
-
"@types/node": "22.
|
|
955
|
-
"@types/react": "^19.0
|
|
954
|
+
"@types/node": "22.14.0",
|
|
955
|
+
"@types/react": "^19.1.0",
|
|
956
956
|
"eslint-config-custom": "workspace:*",
|
|
957
957
|
"fast-glob": "^3.3.3",
|
|
958
958
|
tsconfig: "workspace:*",
|
|
@@ -977,6 +977,11 @@ async function customise(resolver, config) {
|
|
|
977
977
|
label: "Docs Layout",
|
|
978
978
|
value: "docs",
|
|
979
979
|
hint: "main UI of your docs"
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
label: "Home Layout",
|
|
983
|
+
value: "home",
|
|
984
|
+
hint: "the navbar for your other pages"
|
|
980
985
|
}
|
|
981
986
|
]
|
|
982
987
|
}),
|
|
@@ -1018,11 +1023,16 @@ async function customise(resolver, config) {
|
|
|
1018
1023
|
}
|
|
1019
1024
|
}
|
|
1020
1025
|
);
|
|
1021
|
-
if (result.target === "docs"
|
|
1022
|
-
|
|
1026
|
+
if (result.target === "docs") {
|
|
1027
|
+
let pageAdded = false;
|
|
1023
1028
|
if (result.mode === "minimal") {
|
|
1024
1029
|
await add("layouts/docs-min", resolver, config);
|
|
1030
|
+
pageAdded = true;
|
|
1025
1031
|
} else {
|
|
1032
|
+
if (result.page) {
|
|
1033
|
+
await add("layouts/page", resolver, config);
|
|
1034
|
+
pageAdded = true;
|
|
1035
|
+
}
|
|
1026
1036
|
await add(
|
|
1027
1037
|
result.mode === "full-default" ? "layouts/docs" : "layouts/notebook",
|
|
1028
1038
|
resolver,
|
|
@@ -1038,12 +1048,26 @@ async function customise(resolver, config) {
|
|
|
1038
1048
|
picocolors5.greenBright(
|
|
1039
1049
|
"`fumadocs-ui/layouts/docs` -> `@/components/layouts/docs`"
|
|
1040
1050
|
),
|
|
1041
|
-
|
|
1051
|
+
pageAdded ? picocolors5.greenBright(
|
|
1042
1052
|
"`fumadocs-ui/page` -> `@/components/layouts/page`"
|
|
1043
1053
|
) : ""
|
|
1044
1054
|
].join("\n")
|
|
1045
1055
|
);
|
|
1046
1056
|
}
|
|
1057
|
+
if (result.target === "home") {
|
|
1058
|
+
await add("layouts/home", resolver, config);
|
|
1059
|
+
log5.info(
|
|
1060
|
+
[
|
|
1061
|
+
picocolors5.bold("What is Next?"),
|
|
1062
|
+
"You can check the installed components in `components/layouts`.",
|
|
1063
|
+
picocolors5.dim("---"),
|
|
1064
|
+
"Open your `layout.tsx` files, replace the imports of components:",
|
|
1065
|
+
picocolors5.greenBright(
|
|
1066
|
+
"`fumadocs-ui/layouts/home` -> `@/components/layouts/home`"
|
|
1067
|
+
)
|
|
1068
|
+
].join("\n")
|
|
1069
|
+
);
|
|
1070
|
+
}
|
|
1047
1071
|
}
|
|
1048
1072
|
|
|
1049
1073
|
// src/index.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fumadocs/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "The CLI tool for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/cross-spawn": "^6.0.6",
|
|
38
|
-
"@types/node": "22.
|
|
39
|
-
"@types/react": "^19.0
|
|
38
|
+
"@types/node": "22.14.0",
|
|
39
|
+
"@types/react": "^19.1.0",
|
|
40
40
|
"fast-glob": "^3.3.3",
|
|
41
41
|
"tsx": "^4.19.3",
|
|
42
42
|
"eslint-config-custom": "0.0.0",
|