@fumadocs/cli 1.3.1 → 1.3.3

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.
Files changed (47) hide show
  1. package/dist/build/index.d.ts +4 -6
  2. package/dist/build/index.d.ts.map +1 -1
  3. package/dist/build/index.js +12 -19
  4. package/dist/build/index.js.map +1 -1
  5. package/dist/{client-YTcWP1iz.js → client-C2A4Jf2w.js} +1 -1
  6. package/dist/{client-YTcWP1iz.js.map → client-C2A4Jf2w.js.map} +1 -1
  7. package/dist/{config-Dyass4D9.d.ts → config-Bx-m6awG.d.ts} +9 -5
  8. package/dist/config-Bx-m6awG.d.ts.map +1 -0
  9. package/dist/config.d.ts +2 -2
  10. package/dist/config.js +74 -1
  11. package/dist/config.js.map +1 -0
  12. package/dist/{fs-CigSthjp.js → fs-C3j4H046.js} +1 -1
  13. package/dist/{fs-CigSthjp.js.map → fs-C3j4H046.js.map} +1 -1
  14. package/dist/{ast-BRNdmLn5.js → import-CSbSteB3.js} +56 -2
  15. package/dist/import-CSbSteB3.js.map +1 -0
  16. package/dist/index.js +273 -59
  17. package/dist/index.js.map +1 -1
  18. package/dist/installer-BWoLnsXE.js +673 -0
  19. package/dist/installer-BWoLnsXE.js.map +1 -0
  20. package/dist/registry/client.d.ts +27 -9
  21. package/dist/registry/client.d.ts.map +1 -1
  22. package/dist/registry/client.js +1 -1
  23. package/dist/registry/installer/index.d.ts +17 -27
  24. package/dist/registry/installer/index.d.ts.map +1 -1
  25. package/dist/registry/installer/index.js +1 -3
  26. package/dist/registry/macros/route-handler.d.ts +21 -0
  27. package/dist/registry/macros/route-handler.d.ts.map +1 -0
  28. package/dist/registry/macros/route-handler.js +11 -0
  29. package/dist/registry/macros/route-handler.js.map +1 -0
  30. package/dist/registry/schema.d.ts +2 -2
  31. package/dist/registry/schema.js +15 -11
  32. package/dist/registry/schema.js.map +1 -1
  33. package/dist/{schema-80shuzWO.d.ts → schema-BAaUX4uu.d.ts} +26 -10
  34. package/dist/schema-BAaUX4uu.d.ts.map +1 -0
  35. package/dist/schema.json +1 -0
  36. package/dist/types-79PW0lgM.d.ts +6 -0
  37. package/dist/types-79PW0lgM.d.ts.map +1 -0
  38. package/package.json +6 -6
  39. package/dist/ast-BRNdmLn5.js.map +0 -1
  40. package/dist/config-BYrMmXOw.js +0 -55
  41. package/dist/config-BYrMmXOw.js.map +0 -1
  42. package/dist/config-Dyass4D9.d.ts.map +0 -1
  43. package/dist/installer-B3-my9zN.js +0 -248
  44. package/dist/installer-B3-my9zN.js.map +0 -1
  45. package/dist/schema/default.json +0 -1
  46. package/dist/schema/src.json +0 -1
  47. package/dist/schema-80shuzWO.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { t as exists } from "./fs-CigSthjp.js";
3
- import { i as initConfig, n as createOrLoadConfig } from "./config-BYrMmXOw.js";
4
- import { n as transformSpecifiers } from "./ast-BRNdmLn5.js";
5
- import { n as LocalRegistryClient, t as HttpRegistryClient } from "./client-YTcWP1iz.js";
6
- import { t as ComponentInstaller } from "./installer-B3-my9zN.js";
2
+ import { createOrLoadConfig, initConfig } from "./config.js";
3
+ import { n as LocalRegistryClient, t as HttpRegistryClient } from "./client-C2A4Jf2w.js";
4
+ import { t as ComponentInstaller } from "./installer-BWoLnsXE.js";
5
+ import { t as exists } from "./fs-C3j4H046.js";
7
6
  import fs from "node:fs/promises";
8
7
  import path from "node:path";
9
8
  import { Command } from "commander";
10
9
  import picocolors from "picocolors";
11
10
  import { x } from "tinyexec";
12
11
  import { autocompleteMultiselect, box, cancel, confirm, group, intro, isCancel, log, outro, select, spinner } from "@clack/prompts";
12
+ import { detect } from "package-manager-detector";
13
13
  import { exec } from "node:child_process";
14
14
  import { promisify } from "node:util";
15
15
  //#region src/commands/file-tree.ts
@@ -63,7 +63,7 @@ async function runTree(args) {
63
63
  }
64
64
  //#endregion
65
65
  //#region package.json
66
- var version = "1.3.1";
66
+ var version = "1.3.3";
67
67
  //#endregion
68
68
  //#region src/commands/shared.ts
69
69
  const UIRegistries = {
@@ -108,12 +108,9 @@ function pluginPreserveLayouts() {
108
108
  $subComponents: comp.$subComponents.filter((child) => !layoutNameSet.has(child.name))
109
109
  };
110
110
  },
111
- beforeTransform({ parsed, s, stack }) {
112
- if (layoutNameSet.has(stack[0].name)) return;
113
- transformSpecifiers(parsed.program, s, (specifier) => {
114
- if (!(specifier in layoutComps)) return specifier;
115
- return `fumadocs-ui/${layoutComps[specifier]}`;
116
- });
111
+ transformImport(specifier, { stack }) {
112
+ if (layoutNameSet.has(stack[0].name) || !(specifier in layoutComps)) return specifier;
113
+ return `fumadocs-ui/${layoutComps[specifier]}`;
117
114
  }
118
115
  };
119
116
  }
@@ -189,7 +186,8 @@ async function install(target, installer) {
189
186
  if (deps.hasRequired()) {
190
187
  log.message();
191
188
  box([...deps.dependencies, ...deps.devDependencies].join("\n"), "New Dependencies");
192
- const value = await confirm({ message: `Do you want to install with ${deps.packageManager}?` });
189
+ const pm = (await detect())?.name ?? "npm";
190
+ const value = await confirm({ message: `Do you want to install with ${pm}?` });
193
191
  if (isCancel(value)) {
194
192
  outro("Installation terminated");
195
193
  process.exit(0);
@@ -197,9 +195,9 @@ async function install(target, installer) {
197
195
  if (value) {
198
196
  const spin = spinner({ errorMessage: "Failed to install dependencies" });
199
197
  spin.start("Installing dependencies");
200
- await deps.installRequired();
198
+ await deps.installRequired(pm);
201
199
  spin.stop("Dependencies installed");
202
- }
200
+ } else await deps.writeRequired();
203
201
  }
204
202
  await installer.onEnd();
205
203
  outro(picocolors.bold(picocolors.greenBright("Successful")));
@@ -211,59 +209,119 @@ async function customise(client) {
211
209
  const config = client.config;
212
210
  const installer = new ComponentInstaller(client, { plugins: [pluginPreserveLayouts()] });
213
211
  const registry = UIRegistries[config.uiLibrary];
212
+ const info = await client.createLinkedRegistryClient(registry).fetchRegistryInfo();
214
213
  const target = (await group({
215
214
  layout: () => select({
216
215
  message: "What do you want to customise?",
217
- options: [{
218
- label: "Docs Layout",
219
- value: "docs",
220
- hint: "main UI of your docs"
221
- }, {
222
- label: "Home Layout",
223
- value: "home",
224
- hint: "the navbar for your other pages"
225
- }]
216
+ options: [
217
+ {
218
+ label: "Docs Layout",
219
+ value: {
220
+ id: "docs",
221
+ target: [`${registry}/layouts/docs`],
222
+ print() {
223
+ printLayout(["fumadocs-ui/layouts/docs", "@/layouts/docs"], ["fumadocs-ui/layouts/docs/page", "@/layouts/docs/page"]);
224
+ }
225
+ },
226
+ hint: "the default docs layout"
227
+ },
228
+ {
229
+ label: "Notebook Layout",
230
+ value: {
231
+ id: "notebook",
232
+ target: [`${registry}/layouts/notebook`],
233
+ print() {
234
+ printLayout(["fumadocs-ui/layouts/notebook", "@/layouts/notebook"], ["fumadocs-ui/layouts/notebook/page", "@/layouts/notebook/page"]);
235
+ }
236
+ },
237
+ hint: "a more compact version of docs layout"
238
+ },
239
+ {
240
+ label: "Flux Layout",
241
+ value: {
242
+ id: "flux",
243
+ target: [`${registry}/layouts/flux`],
244
+ print() {
245
+ printLayout(["fumadocs-ui/layouts/flux", "@/layouts/flux"], ["fumadocs-ui/layouts/flux/page", "@/layouts/flux/page"]);
246
+ }
247
+ },
248
+ hint: "the experimental variant of docs layout"
249
+ },
250
+ {
251
+ label: "Home Layout",
252
+ value: {
253
+ id: "home",
254
+ target: [`${registry}/layouts/home`],
255
+ print() {
256
+ printLayout(["fumadocs-ui/layouts/home", `@/layouts/home`]);
257
+ }
258
+ },
259
+ hint: "the layout for other non-docs pages"
260
+ }
261
+ ]
226
262
  }),
227
263
  target: (v) => {
228
- if (v.results.layout !== "docs") return Promise.resolve({
229
- target: [`${registry}/layouts/home`],
230
- replace: [["fumadocs-ui/layouts/home", `@/components/layout/home`]]
231
- });
264
+ const selected = v.results.layout;
265
+ if (selected.id === "home") return Promise.resolve(selected);
232
266
  return select({
233
- message: "Which variant do you want to start from?",
267
+ message: "Which part do you want to customise?",
234
268
  options: [
235
269
  {
236
- label: "Start from minimal styles",
237
- hint: "for those who want to build their own variant from ground up.",
238
- value: {
239
- target: ["layouts/docs-min"],
240
- replace: [["fumadocs-ui/layouts/docs", "@/components/layout/docs"], ["fumadocs-ui/layouts/docs/page", "@/components/layout/docs/page"]]
241
- }
242
- },
243
- {
244
- label: "Start from default layout",
245
- value: {
246
- target: [`${registry}/layouts/docs`],
247
- replace: [["fumadocs-ui/layouts/docs", "@/components/layout/docs"], ["fumadocs-ui/layouts/docs/page", "@/components/layout/docs/page"]]
248
- },
249
- hint: "useful for adjusting small details."
270
+ label: "All",
271
+ hint: "install the entire layout",
272
+ value: selected
250
273
  },
251
274
  {
252
- label: "Start from Notebook layout",
275
+ label: "Replace & rewrite from minimal styles",
276
+ hint: "for those who want to build their own UI from ground up",
253
277
  value: {
254
- target: [`${registry}/layouts/notebook`],
255
- replace: [["fumadocs-ui/layouts/notebook", "@/components/layout/notebook"], ["fumadocs-ui/layouts/notebook/page", "@/components/layout/notebook/page"]]
256
- },
257
- hint: "useful for adjusting small details."
278
+ id: "docs-min",
279
+ target: ["layouts/docs-min"],
280
+ print() {
281
+ printLayout(["fumadocs-ui/layouts/docs", "@/layouts/docs"], ["fumadocs-ui/layouts/docs/page", "@/layouts/docs/page"]);
282
+ }
283
+ }
258
284
  },
259
- {
260
- label: "Start from Flux layout",
261
- value: {
262
- target: [`${registry}/layouts/flux`],
263
- replace: [["fumadocs-ui/layouts/flux", "@/components/layout/flux"], ["fumadocs-ui/layouts/flux/page", "@/components/layout/flux/page"]]
264
- },
265
- hint: "useful for adjusting small details."
266
- }
285
+ ...info.unlistedIndexes.flatMap((index) => {
286
+ const prefix = `slots/${selected.id}`;
287
+ if (!index.name.startsWith(prefix)) return [];
288
+ let name = index.name.slice(prefix.length + 1);
289
+ if (name.startsWith("page/")) {
290
+ name = name.slice(5);
291
+ return {
292
+ label: `Page: ${name}`,
293
+ hint: "only replace a part of layout's page, useful for adjusting details",
294
+ value: {
295
+ id: index.name,
296
+ target: [`${registry}/${index.name}`],
297
+ print() {
298
+ printSlot({
299
+ at: `@/layouts/${selected.id}/page/slots/${name}`,
300
+ layoutId: selected.id,
301
+ name,
302
+ isPage: true
303
+ });
304
+ }
305
+ }
306
+ };
307
+ }
308
+ return {
309
+ label: `Layout: ${name}`,
310
+ hint: "only replace a part of layout, useful for adjusting details",
311
+ value: {
312
+ id: index.name,
313
+ target: [`${registry}/${index.name}`],
314
+ print() {
315
+ printSlot({
316
+ at: `@/layouts/${selected.id}/slots/${name}`,
317
+ layoutId: selected.id,
318
+ name,
319
+ isPage: false
320
+ });
321
+ }
322
+ }
323
+ };
324
+ })
267
325
  ]
268
326
  });
269
327
  }
@@ -272,18 +330,174 @@ async function customise(client) {
272
330
  process.exit(0);
273
331
  } })).target;
274
332
  await install(target.target, installer);
275
- printNext(...target.replace);
333
+ target.print?.();
276
334
  outro(picocolors.bold("Have fun!"));
277
335
  }
278
- function printNext(...maps) {
336
+ function printLayout(...maps) {
279
337
  intro(picocolors.bold("What is Next?"));
280
338
  log.info([
281
- "You can check the installed components in `components`.",
339
+ "You can check the installed layouts in `layouts` folder.",
282
340
  picocolors.dim("---"),
283
341
  "Open your `layout.tsx` files, replace the imports of components:",
284
342
  ...maps.map(([from, to]) => picocolors.greenBright(`"${from}" -> "${to}"`))
285
343
  ].join("\n"));
286
344
  }
345
+ function printSlot({ at, layoutId, name, isPage }) {
346
+ intro(picocolors.bold("What is Next?"));
347
+ log.info(`You can check the installed layout slot in "${at}".`);
348
+ const code = getSlotCode({
349
+ at,
350
+ layoutId,
351
+ name,
352
+ isPage
353
+ });
354
+ if (code) if (isPage) log.info(`${picocolors.bold("At your <DocsPage /> component, update your \"slots\" prop:")}\n\n${code}`);
355
+ else log.info(`${picocolors.bold("At your <DocsLayout /> component, update your \"slots\" prop:")}\n\n${code}`);
356
+ }
357
+ function getSlotCode({ at, layoutId, name, isPage }) {
358
+ if (isPage) switch (name) {
359
+ case "toc":
360
+ if (layoutId === "flux") return `import { TOCProvider, TOC } from '${at}';
361
+
362
+ return (
363
+ <DocsPage
364
+ slots={{
365
+ toc: {
366
+ provider: TOCProvider,
367
+ main: TOC,
368
+ },
369
+ }}
370
+ >
371
+ ...
372
+ </DocsPage>
373
+ );`;
374
+ return `import { TOCProvider, TOC, TOCPopover } from '${at}';
375
+
376
+ return (
377
+ <DocsPage
378
+ slots={{
379
+ toc: {
380
+ provider: TOCProvider,
381
+ main: TOC,
382
+ popover: TOCPopover,
383
+ },
384
+ }}
385
+ >
386
+ ...
387
+ </DocsPage>
388
+ );`;
389
+ case "container": return `import { Container } from '${at}';
390
+
391
+ return (
392
+ <DocsPage
393
+ slots={{
394
+ container: Container,
395
+ }}
396
+ >
397
+ ...
398
+ </DocsPage>
399
+ );`;
400
+ case "footer": return `import { Footer } from '${at}';
401
+
402
+ return (
403
+ <DocsPage
404
+ slots={{
405
+ footer: Footer,
406
+ }}
407
+ >
408
+ ...
409
+ </DocsPage>
410
+ );`;
411
+ case "breadcrumb": return `import { Breadcrumb } from '${at}';
412
+
413
+ return (
414
+ <DocsPage
415
+ slots={{
416
+ breadcrumb: Breadcrumb,
417
+ }}
418
+ >
419
+ ...
420
+ </DocsPage>
421
+ );`;
422
+ default: return;
423
+ }
424
+ switch (name) {
425
+ case "sidebar":
426
+ if (layoutId === "notebook") return `import {
427
+ SidebarProvider,
428
+ Sidebar,
429
+ SidebarTrigger,
430
+ SidebarCollapseTrigger,
431
+ useSidebar,
432
+ } from '${at}';
433
+
434
+ return (
435
+ <DocsLayout
436
+ slots={{
437
+ sidebar: {
438
+ provider: SidebarProvider,
439
+ root: Sidebar,
440
+ trigger: SidebarTrigger,
441
+ collapseTrigger: SidebarCollapseTrigger,
442
+ useSidebar: useSidebar,
443
+ },
444
+ }}
445
+ >
446
+ ...
447
+ </DocsLayout>
448
+ );`;
449
+ return `import { SidebarProvider, Sidebar, SidebarTrigger, useSidebar } from '${at}';
450
+
451
+ return (
452
+ <DocsLayout
453
+ slots={{
454
+ sidebar: {
455
+ provider: SidebarProvider,
456
+ root: Sidebar,
457
+ trigger: SidebarTrigger,
458
+ useSidebar: useSidebar,
459
+ },
460
+ }}
461
+ >
462
+ ...
463
+ </DocsLayout>
464
+ );`;
465
+ case "container": return `import { Container } from '${at}';
466
+
467
+ return (
468
+ <DocsLayout
469
+ slots={{
470
+ container: Container,
471
+ }}
472
+ >
473
+ ...
474
+ </DocsLayout>
475
+ );`;
476
+ case "header": return `import { Header } from '${at}';
477
+
478
+ return (
479
+ <DocsLayout
480
+ slots={{
481
+ header: Header,
482
+ }}
483
+ >
484
+ ...
485
+ </DocsLayout>
486
+ );`;
487
+ case "tab-dropdown": return `import { TabDropdown } from '${at}';
488
+
489
+ return (
490
+ <DocsLayout
491
+ slots={{
492
+ tabDropdown: TabDropdown,
493
+ }}
494
+ >
495
+ ...
496
+ </DocsLayout>
497
+ );`;
498
+ default: return;
499
+ }
500
+ }
287
501
  //#endregion
288
502
  //#region src/commands/export-epub.ts
289
503
  const execAsync = promisify(exec);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["packageJson.version"],"sources":["../src/commands/file-tree.ts","../src/utils/file-tree/run-tree.ts","../package.json","../src/commands/shared.ts","../src/registry/plugins/preserve.ts","../src/commands/add.ts","../src/commands/customise.ts","../src/commands/export-epub.ts","../src/index.ts"],"sourcesContent":["export type JsonTreeNode =\n | {\n type: 'file';\n name: string;\n }\n | {\n type: 'directory';\n name: string;\n contents: JsonTreeNode[];\n }\n | {\n type: 'report';\n }\n | {\n type: 'link';\n name: string;\n };\n\nconst scanned = ['file', 'directory', 'link'];\n\nexport function treeToMdx(input: JsonTreeNode[], noRoot = false): string {\n function toNode(item: JsonTreeNode): string {\n if (item.type === 'file' || item.type === 'link') {\n return `<File name=${JSON.stringify(item.name)} />`;\n }\n\n if (item.type === 'directory') {\n if (item.contents.length === 1 && 'name' in item.contents[0]) {\n const child = item.contents[0];\n\n return toNode({\n ...child,\n name: `${item.name}/${child.name}`,\n });\n }\n\n return `<Folder name=${JSON.stringify(item.name)}>\n${item.contents.map(toNode).filter(Boolean).join('\\n')}\n</Folder>`;\n }\n\n return '';\n }\n\n let children = input.filter((v) => scanned.includes(v.type));\n\n if (noRoot && children.length === 1 && input[0].type === 'directory') {\n children = input[0].contents;\n }\n\n return `<Files>\n${children.map(toNode).filter(Boolean).join('\\n')}\n</Files>`;\n}\n\nexport function treeToJavaScript(\n input: JsonTreeNode[],\n noRoot?: boolean,\n importName = 'fumadocs-ui/components/files',\n): string {\n return `import { File, Files, Folder } from ${JSON.stringify(importName)}\n\nexport default (${treeToMdx(input, noRoot)})`;\n}\n","import { x } from 'tinyexec';\nimport type { JsonTreeNode } from '@/commands/file-tree';\n\nexport async function runTree(args: string): Promise<JsonTreeNode[]> {\n const out = await x('tree', [args, '--gitignore', '--prune', '-J']);\n\n try {\n return JSON.parse(out.stdout) as JsonTreeNode[];\n } catch (e) {\n throw new Error('failed to run `tree` command', {\n cause: e,\n });\n }\n}\n","","export const UIRegistries = {\n 'base-ui': 'fumadocs/base-ui',\n 'radix-ui': 'fumadocs/radix-ui',\n};\n","import { transformSpecifiers } from '@/utils/ast';\nimport type { ComponentInstallerPlugin } from '../installer';\n\n/**\n * keep references to `fumadocs-ui/layouts/*` components as original, unless the user is installing them directly.\n */\nexport function pluginPreserveLayouts(): ComponentInstallerPlugin {\n const layoutNames = [\n 'layouts/home',\n 'layouts/flux',\n 'layouts/notebook',\n 'layouts/docs',\n 'layouts/shared',\n ];\n // original specifier -> new specifier\n const layoutComps: Record<string, string> = {\n '@/<dir>/home/index.tsx': 'layouts/home',\n '@/<dir>/shared/index.tsx': 'layouts/shared',\n '@/<dir>/shared/client.tsx': 'layouts/shared',\n '@/<dir>/notebook/index.tsx': 'layouts/notebook',\n '@/<dir>/notebook/client.tsx': 'layouts/notebook',\n '@/<dir>/notebook/page/index.tsx': 'layouts/notebook/page',\n '@/<dir>/notebook/page/client.tsx': 'layouts/notebook/page',\n '@/<dir>/docs/index.tsx': 'layouts/docs',\n '@/<dir>/docs/client.tsx': 'layouts/docs',\n '@/<dir>/docs/page/index.tsx': 'layouts/docs/page',\n '@/<dir>/docs/page/client.tsx': 'layouts/docs/page',\n '@/<dir>/flux/index.tsx': 'layouts/flux',\n '@/<dir>/flux/page/index.tsx': 'layouts/flux/page',\n '@/<dir>/flux/page/client.tsx': 'layouts/flux/page',\n };\n const layoutNameSet = new Set(layoutNames);\n\n return {\n beforeInstall(comp, { stack }) {\n const isDirectInstall = layoutNameSet.has(stack[0].name);\n if (isDirectInstall) return;\n\n return {\n ...comp,\n $subComponents: comp.$subComponents.filter((child) => !layoutNameSet.has(child.name)),\n };\n },\n beforeTransform({ parsed, s, stack }) {\n const isDirectInstall = layoutNameSet.has(stack[0].name);\n if (isDirectInstall) return;\n\n transformSpecifiers(parsed.program, s, (specifier) => {\n // skip if unrelated to layout component\n if (!(specifier in layoutComps)) return specifier;\n\n return `fumadocs-ui/${layoutComps[specifier]}`;\n });\n },\n };\n}\n","import {\n isCancel,\n autocompleteMultiselect,\n outro,\n spinner,\n confirm,\n box,\n log,\n} from '@clack/prompts';\nimport picocolors from 'picocolors';\nimport { ComponentInstaller } from '@/registry/installer';\nimport type { RegistryClient } from '@/registry/client';\nimport { UIRegistries } from '@/commands/shared';\nimport { pluginPreserveLayouts } from '@/registry/plugins/preserve';\n\nexport async function add(input: string[], client: RegistryClient) {\n const config = client.config;\n let target: string[];\n const installer = new ComponentInstaller(client, {\n plugins: [pluginPreserveLayouts()],\n });\n const registry = UIRegistries[config.uiLibrary];\n\n if (input.length === 0) {\n const spin = spinner();\n spin.start('fetching registry');\n const info = await client.fetchRegistryInfo();\n const options: {\n label: string;\n value: string;\n hint?: string;\n }[] = [];\n\n for (const item of info.indexes) {\n options.push({\n label: item.title ?? item.name,\n value: item.name,\n hint: item.description,\n });\n }\n const { indexes } = await client.createLinkedRegistryClient(registry).fetchRegistryInfo();\n\n for (const item of indexes) {\n options.push({\n label: item.title ?? item.name,\n value: `${registry}/${item.name}`,\n hint: item.description,\n });\n }\n\n spin.stop(picocolors.bold(picocolors.greenBright('registry fetched')));\n const value = await autocompleteMultiselect({\n message: 'Select components to install',\n options,\n });\n\n if (isCancel(value)) {\n outro('Ended');\n return;\n }\n\n target = value;\n } else {\n target = await Promise.all(\n input.map(async (item) => ((await client.hasComponent(item)) ? item : `${registry}/${item}`)),\n );\n }\n\n await install(target, installer);\n}\n\nexport async function install(target: string[], installer: ComponentInstaller) {\n for (const name of target) {\n const spin = spinner();\n spin.start(picocolors.bold(picocolors.cyanBright(`Installing ${name}`)));\n\n try {\n await installer.install(name, {\n onWarn(message) {\n spin.message(message);\n },\n async confirmFileOverride(options) {\n spin.clear();\n const value = await confirm({\n message: `Do you want to override ${options.path}?`,\n initialValue: false,\n });\n if (isCancel(value)) {\n outro('Installation terminated');\n process.exit(0);\n }\n spin.start(picocolors.bold(picocolors.cyanBright(`Installing ${name}`)));\n return value;\n },\n onFileDownloaded(options) {\n spin.message(options.path);\n },\n });\n spin.stop(picocolors.bold(picocolors.greenBright(`${name} installed`)));\n } catch (e) {\n spin.error(e instanceof Error ? e.message : String(e));\n process.exit(-1);\n }\n }\n\n const deps = await installer.deps();\n if (deps.hasRequired()) {\n log.message();\n box([...deps.dependencies, ...deps.devDependencies].join('\\n'), 'New Dependencies');\n const value = await confirm({\n message: `Do you want to install with ${deps.packageManager}?`,\n });\n\n if (isCancel(value)) {\n outro('Installation terminated');\n process.exit(0);\n }\n\n if (value) {\n const spin = spinner({\n errorMessage: 'Failed to install dependencies',\n });\n spin.start('Installing dependencies');\n await deps.installRequired();\n spin.stop('Dependencies installed');\n }\n }\n\n await installer.onEnd();\n outro(picocolors.bold(picocolors.greenBright('Successful')));\n}\n","import { cancel, group, intro, log, outro, select } from '@clack/prompts';\nimport picocolors from 'picocolors';\nimport { install } from '@/commands/add';\nimport type { RegistryClient } from '@/registry/client';\nimport { ComponentInstaller } from '@/registry/installer';\nimport { UIRegistries } from '@/commands/shared';\nimport { pluginPreserveLayouts } from '@/registry/plugins/preserve';\n\ninterface TargetInfo {\n target: string[];\n replace: [string, string][];\n}\n\nexport async function customise(client: RegistryClient) {\n intro(picocolors.bgBlack(picocolors.whiteBright('Customise Fumadocs UI')));\n const config = client.config;\n const installer = new ComponentInstaller(client, {\n plugins: [pluginPreserveLayouts()],\n });\n const registry = UIRegistries[config.uiLibrary];\n\n const result = await group(\n {\n layout: () =>\n select({\n message: 'What do you want to customise?',\n options: [\n {\n label: 'Docs Layout',\n value: 'docs',\n hint: 'main UI of your docs',\n },\n {\n label: 'Home Layout',\n value: 'home',\n hint: 'the navbar for your other pages',\n },\n ],\n }),\n target: (v): Promise<TargetInfo | symbol> => {\n if (v.results.layout !== 'docs')\n return Promise.resolve({\n target: [`${registry}/layouts/home`],\n replace: [['fumadocs-ui/layouts/home', `@/components/layout/home`]],\n });\n\n return select<TargetInfo>({\n message: 'Which variant do you want to start from?',\n options: [\n {\n label: 'Start from minimal styles',\n hint: 'for those who want to build their own variant from ground up.',\n value: {\n target: ['layouts/docs-min'],\n replace: [\n ['fumadocs-ui/layouts/docs', '@/components/layout/docs'],\n ['fumadocs-ui/layouts/docs/page', '@/components/layout/docs/page'],\n ],\n },\n },\n {\n label: 'Start from default layout',\n value: {\n target: [`${registry}/layouts/docs`],\n replace: [\n ['fumadocs-ui/layouts/docs', '@/components/layout/docs'],\n ['fumadocs-ui/layouts/docs/page', '@/components/layout/docs/page'],\n ],\n },\n hint: 'useful for adjusting small details.',\n },\n {\n label: 'Start from Notebook layout',\n value: {\n target: [`${registry}/layouts/notebook`],\n replace: [\n ['fumadocs-ui/layouts/notebook', '@/components/layout/notebook'],\n ['fumadocs-ui/layouts/notebook/page', '@/components/layout/notebook/page'],\n ],\n },\n hint: 'useful for adjusting small details.',\n },\n {\n label: 'Start from Flux layout',\n value: {\n target: [`${registry}/layouts/flux`],\n replace: [\n ['fumadocs-ui/layouts/flux', '@/components/layout/flux'],\n ['fumadocs-ui/layouts/flux/page', '@/components/layout/flux/page'],\n ],\n },\n hint: 'useful for adjusting small details.',\n },\n ],\n });\n },\n },\n {\n onCancel: () => {\n cancel('Installation Stopped.');\n process.exit(0);\n },\n },\n );\n\n const target = result.target as TargetInfo;\n await install(target.target, installer);\n printNext(...target.replace);\n\n outro(picocolors.bold('Have fun!'));\n}\n\nfunction printNext(...maps: [from: string, to: string][]) {\n intro(picocolors.bold('What is Next?'));\n\n log.info(\n [\n 'You can check the installed components in `components`.',\n picocolors.dim('---'),\n 'Open your `layout.tsx` files, replace the imports of components:',\n ...maps.map(([from, to]) => picocolors.greenBright(`\"${from}\" -> \"${to}\"`)),\n ].join('\\n'),\n );\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { exists } from '@/utils/fs';\nimport picocolors from 'picocolors';\nimport { spinner } from '@clack/prompts';\nimport { exec } from 'node:child_process';\nimport { promisify } from 'node:util';\n\nconst execAsync = promisify(exec);\n\ninterface PackageJson {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n}\n\nasync function readPackageJson(cwd: string): Promise<PackageJson | null> {\n try {\n const raw = await fs.readFile(path.join(cwd, 'package.json'), 'utf-8');\n return JSON.parse(raw) as PackageJson;\n } catch {\n return null;\n }\n}\n\n/** Path of pre-rendered EPUB, choose one according to your React framework. Next.js fetches from the running server instead. */\nconst EPUB_BUILD_PATHS: Record<string, string> = {\n next: '', // Fetched from /export/epub at runtime; route handlers don't produce static files\n 'tanstack-start': '.output/public/export/epub',\n 'tanstack-start-spa': 'dist/client/export/epub',\n 'react-router': 'build/client/export/epub',\n 'react-router-spa': 'build/client/export/epub',\n waku: 'dist/public/export/epub',\n};\n\nconst API_ROUTE_TEMPLATE = `import { source } from '@/lib/source';\nimport { exportEpub } from 'fumadocs-epub';\n\nexport const revalidate = false;\n\nexport async function GET(request: Request): Promise<Response> {\n // Require EXPORT_SECRET to prevent unauthenticated abuse. Pass via Authorization: Bearer <secret>\n const secret = process.env.EXPORT_SECRET;\n if (!secret) {\n return new Response('EXPORT_SECRET is not configured. Set it in your environment to protect this endpoint.', { status: 503 });\n }\n const authHeader = request.headers.get('authorization');\n const token = authHeader?.replace(/^Bearer\\\\s+/i, '') ?? '';\n if (token !== secret) {\n return new Response('Unauthorized', { status: authHeader ? 403 : 401 });\n }\n const buffer = await exportEpub({\n source,\n title: 'Documentation',\n author: 'Your Team',\n description: 'Exported documentation',\n cover: '/cover.png',\n });\n return new Response(new Uint8Array(buffer), {\n headers: {\n 'Content-Type': 'application/epub+zip',\n 'Content-Disposition': 'attachment; filename=\"docs.epub\"',\n },\n });\n}\n`;\n\nasync function findAppDir(cwd: string): Promise<string | null> {\n const appPaths = ['app', 'src/app'];\n for (const appPath of appPaths) {\n const fullPath = path.join(cwd, appPath);\n if (await exists(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\nasync function scaffoldEpubRoute(cwd: string): Promise<boolean> {\n const appDir = await findAppDir(cwd);\n if (!appDir) {\n console.error(picocolors.red('Could not find app directory (app/ or src/app/)'));\n return false;\n }\n\n const routePath = path.join(appDir, 'export', 'epub', 'route.ts');\n if (await exists(routePath)) {\n console.log(picocolors.yellow('EPUB route already exists at'), routePath);\n return true;\n }\n\n await fs.mkdir(path.dirname(routePath), { recursive: true });\n await fs.writeFile(routePath, API_ROUTE_TEMPLATE);\n console.log(picocolors.green('Created EPUB route at'), routePath);\n return true;\n}\n\nexport async function exportEpub(options: {\n output?: string;\n framework: string;\n scaffoldOnly?: boolean;\n}) {\n const cwd = process.cwd();\n const outputPath = path.resolve(cwd, options.output ?? 'docs.epub');\n const framework = options.framework;\n\n const spin = spinner();\n\n const buildPath = EPUB_BUILD_PATHS[framework];\n if (!(framework in EPUB_BUILD_PATHS)) {\n const valid = Object.keys(EPUB_BUILD_PATHS).join(', ');\n console.error(picocolors.red(`Invalid --framework \"${framework}\". Must be one of: ${valid}`));\n process.exit(1);\n }\n\n // Check for Next.js when scaffolding (only Next.js scaffold is implemented)\n const pkg = await readPackageJson(cwd);\n const hasNextConfig =\n (await exists(path.join(cwd, 'next.config.js'))) ||\n (await exists(path.join(cwd, 'next.config.ts'))) ||\n (await exists(path.join(cwd, 'next.config.mjs')));\n const nextDeps = pkg\n ? { ...pkg.dependencies, ...pkg.devDependencies, ...pkg.peerDependencies }\n : {};\n const hasNextInPkg = !!nextDeps?.next;\n const hasAppOrPages =\n (await exists(path.join(cwd, 'app'))) ||\n (await exists(path.join(cwd, 'pages'))) ||\n (await exists(path.join(cwd, 'src', 'app'))) ||\n (await exists(path.join(cwd, 'src', 'pages')));\n const hasNext = hasNextConfig || (hasNextInPkg && hasAppOrPages);\n\n if (!hasNext && framework === 'next') {\n console.error(\n picocolors.red(\n 'Next.js project not found. Run this command from a Fumadocs Next.js project root.',\n ),\n );\n process.exit(1);\n }\n\n // Scaffold EPUB route (Next.js only for now)\n if (framework === 'next') {\n spin.start('Scaffolding EPUB route');\n const scaffolded = await scaffoldEpubRoute(cwd);\n spin.stop(scaffolded ? 'EPUB route ready' : 'Scaffolding failed');\n\n if (!scaffolded) {\n process.exit(1);\n }\n }\n\n if (options.scaffoldOnly) {\n console.log(picocolors.cyan('\\nTo export:'));\n console.log(' 1. Add fumadocs-epub to your dependencies: pnpm add fumadocs-epub');\n console.log(' 2. Ensure includeProcessedMarkdown: true in your docs collection config');\n if (framework === 'next') {\n console.log(\n ' 3. Set EXPORT_SECRET in your environment to protect the /export/epub endpoint',\n );\n console.log(' 4. Run production build: pnpm build');\n console.log(' 5. Start the server (e.g. pnpm start) and keep it running');\n console.log(' 6. Run: fumadocs export epub --framework next');\n } else {\n console.log(` 3. Add a prerender route that outputs EPUB to ${buildPath}`);\n console.log(' 4. Run production build: pnpm build');\n console.log(` 5. Run: fumadocs export epub --framework ${framework}`);\n }\n return;\n }\n\n // Check for fumadocs-epub dependency\n if (!pkg) {\n console.error(\n picocolors.red('Cannot read or parse package.json. Ensure it exists and is valid JSON.'),\n );\n process.exit(1);\n }\n const deps = { ...pkg.dependencies, ...pkg.devDependencies };\n if (!deps['fumadocs-epub']) {\n console.log(picocolors.yellow('\\nInstalling fumadocs-epub...'));\n const packageManager = process.env.npm_execpath?.includes('pnpm')\n ? 'pnpm'\n : process.env.npm_execpath?.includes('bun')\n ? 'bun'\n : 'npm';\n const installCmd = `${packageManager} add fumadocs-epub`;\n try {\n await execAsync(installCmd, { cwd });\n } catch (err: unknown) {\n const stderr =\n err && typeof err === 'object' && 'stderr' in err\n ? String((err as { stderr?: string }).stderr)\n : '';\n console.error(picocolors.red(`Failed to install fumadocs-epub. Command: ${installCmd}`));\n if (stderr) console.error(stderr);\n process.exit(1);\n }\n }\n\n if (framework === 'next') {\n const secret = process.env.EXPORT_SECRET;\n if (!secret) {\n console.error(\n picocolors.red('EXPORT_SECRET is required for Next.js export. Set it in your environment.'),\n );\n process.exit(1);\n }\n const port = process.env.PORT || '3000';\n const url = `http://localhost:${port}/export/epub`;\n spin.start('Fetching EPUB from server');\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 30_000);\n try {\n const res = await fetch(url, {\n headers: { Authorization: `Bearer ${secret}` },\n signal: controller.signal,\n });\n if (!res.ok) {\n if (res.status === 401 || res.status === 403) {\n console.error(\n picocolors.red('Auth failed. Check that EXPORT_SECRET matches the value in your app.'),\n );\n } else {\n console.error(\n picocolors.red(\n `Server returned ${res.status}. Ensure the app is running (e.g. pnpm start) on port ${port}.`,\n ),\n );\n }\n process.exit(1);\n }\n const buffer = Buffer.from(await res.arrayBuffer());\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, buffer);\n spin.stop(picocolors.green(`EPUB saved to ${outputPath}`));\n } catch (err: unknown) {\n if (err instanceof Error && err.name === 'AbortError') {\n console.error(picocolors.red('Request timed out after 30 seconds.'));\n } else {\n const msg = err instanceof Error ? err.message : String(err);\n console.error(picocolors.red(`Could not fetch EPUB: ${msg}`));\n }\n console.error(\n picocolors.yellow(`Ensure the server is running (e.g. pnpm start) on port ${port}.`),\n );\n process.exit(1);\n } finally {\n clearTimeout(timeoutId);\n }\n return;\n }\n\n const fullBuildPath = path.join(cwd, buildPath);\n if (!(await exists(fullBuildPath))) {\n console.error(\n picocolors.red(\n `EPUB not found at ${buildPath}. Run production build first (e.g. pnpm build).`,\n ),\n );\n process.exit(1);\n }\n\n spin.start('Copying EPUB');\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.copyFile(fullBuildPath, outputPath);\n spin.stop(picocolors.green(`EPUB saved to ${outputPath}`));\n}\n","#!/usr/bin/env node\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { Command } from 'commander';\nimport picocolors from 'picocolors';\nimport { createOrLoadConfig, initConfig, type LoadedConfig } from '@/config';\nimport { type JsonTreeNode, treeToJavaScript, treeToMdx } from '@/commands/file-tree';\nimport { runTree } from '@/utils/file-tree/run-tree';\nimport packageJson from '../package.json';\nimport { customise } from '@/commands/customise';\nimport { add } from '@/commands/add';\nimport { exportEpub } from '@/commands/export-epub';\nimport { HttpRegistryClient, LocalRegistryClient } from '@/registry/client';\n\nconst program = new Command().option('--config <string>');\n\nprogram\n .name('fumadocs')\n .description('CLI to setup Fumadocs, init a config')\n .version(packageJson.version)\n .action(async () => {\n if (await initConfig()) {\n console.log(picocolors.green('Initialized a `./cli.json` config file.'));\n } else {\n console.log(picocolors.redBright('A config file already exists.'));\n }\n });\n\nprogram\n .command('customise')\n .alias('customize')\n .description('simple way to customise layouts with Fumadocs UI')\n .option('--dir <string>', 'the root url or directory to resolve registry')\n .action(async (options: { config?: string; dir?: string }) => {\n await customise(createClientFromDir(options.dir, await createOrLoadConfig(options.config)));\n });\n\nconst dirShortcuts: Record<string, string> = {\n ':preview': 'https://preview.fumadocs.dev/registry',\n ':dev': 'http://localhost:3000/registry',\n};\n\nprogram\n .command('add')\n .description('add a new component to your docs')\n .argument('[components...]', 'components to download')\n .option('--dir <string>', 'the root url or directory to resolve registry')\n .action(async (input: string[], options: { config?: string; dir?: string }) => {\n const client = createClientFromDir(options.dir, await createOrLoadConfig(options.config));\n await add(input, client);\n });\n\nconst exportCmd = program.command('export').description('export documentation to various formats');\n\nexportCmd\n .command('epub')\n .description('export documentation to EPUB format (run after production build)')\n .requiredOption('--framework <name>', 'React framework: next, tanstack-start, react-router, waku')\n .option('--output <path>', 'output file path', 'docs.epub')\n .option('--scaffold-only', 'only scaffold the EPUB route, do not copy')\n .action(async (options: { output?: string; framework: string; scaffoldOnly?: boolean }) => {\n await exportEpub({\n output: options.output,\n framework: options.framework,\n scaffoldOnly: options.scaffoldOnly,\n });\n });\n\nprogram\n .command('tree')\n .argument('[json_or_args]', 'JSON output of `tree` command or arguments for the `tree` command')\n .argument('[output]', 'output path of file')\n .option('--js', 'output as JavaScript file')\n .option('--no-root', 'remove the root node')\n .option('--import-name <name>', 'where to import components (JS only)')\n .action(\n async (\n str: string | undefined,\n output: string | undefined,\n { js, root, importName }: { js: boolean; root: boolean; importName?: string },\n ) => {\n const jsExtensions = ['.js', '.tsx', '.jsx'];\n const noRoot = !root;\n let nodes: JsonTreeNode[];\n\n try {\n nodes = JSON.parse(str ?? '') as JsonTreeNode[];\n } catch {\n nodes = await runTree(str ?? './');\n }\n\n const out =\n js || (output && jsExtensions.includes(path.extname(output)))\n ? treeToJavaScript(nodes, noRoot, importName)\n : treeToMdx(nodes, noRoot);\n\n if (output) {\n await fs.mkdir(path.dirname(output), { recursive: true });\n await fs.writeFile(output, out);\n } else {\n console.log(out);\n }\n },\n );\n\nfunction createClientFromDir(dir = 'https://fumadocs.dev/registry', config: LoadedConfig) {\n if (dir in dirShortcuts) dir = dirShortcuts[dir];\n\n return dir.startsWith('http://') || dir.startsWith('https://')\n ? new HttpRegistryClient(dir, config)\n : new LocalRegistryClient(dir, config);\n}\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAM,UAAU;CAAC;CAAQ;CAAa;CAAO;AAE7C,SAAgB,UAAU,OAAuB,SAAS,OAAe;CACvE,SAAS,OAAO,MAA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M,GAAG,UAAU,QAAQ,IAAI;OAE/B,SAAQ,IAAI,IAAI;EAGrB;AAEH,SAAS,oBAAoB,MAAM,iCAAiC,QAAsB;AACxF,KAAI,OAAO,aAAc,OAAM,aAAa;AAE5C,QAAO,IAAI,WAAW,UAAU,IAAI,IAAI,WAAW,WAAW,GAC1D,IAAI,mBAAmB,KAAK,OAAO,GACnC,IAAI,oBAAoB,KAAK,OAAO;;AAG1C,QAAQ,OAAO"}
1
+ {"version":3,"file":"index.js","names":["packageJson.version"],"sources":["../src/commands/file-tree.ts","../src/utils/file-tree/run-tree.ts","../package.json","../src/commands/shared.ts","../src/registry/plugins/preserve.ts","../src/commands/add.ts","../src/commands/customise.ts","../src/commands/export-epub.ts","../src/index.ts"],"sourcesContent":["export type JsonTreeNode =\n | {\n type: 'file';\n name: string;\n }\n | {\n type: 'directory';\n name: string;\n contents: JsonTreeNode[];\n }\n | {\n type: 'report';\n }\n | {\n type: 'link';\n name: string;\n };\n\nconst scanned = ['file', 'directory', 'link'];\n\nexport function treeToMdx(input: JsonTreeNode[], noRoot = false): string {\n function toNode(item: JsonTreeNode): string {\n if (item.type === 'file' || item.type === 'link') {\n return `<File name=${JSON.stringify(item.name)} />`;\n }\n\n if (item.type === 'directory') {\n if (item.contents.length === 1 && 'name' in item.contents[0]) {\n const child = item.contents[0];\n\n return toNode({\n ...child,\n name: `${item.name}/${child.name}`,\n });\n }\n\n return `<Folder name=${JSON.stringify(item.name)}>\n${item.contents.map(toNode).filter(Boolean).join('\\n')}\n</Folder>`;\n }\n\n return '';\n }\n\n let children = input.filter((v) => scanned.includes(v.type));\n\n if (noRoot && children.length === 1 && input[0].type === 'directory') {\n children = input[0].contents;\n }\n\n return `<Files>\n${children.map(toNode).filter(Boolean).join('\\n')}\n</Files>`;\n}\n\nexport function treeToJavaScript(\n input: JsonTreeNode[],\n noRoot?: boolean,\n importName = 'fumadocs-ui/components/files',\n): string {\n return `import { File, Files, Folder } from ${JSON.stringify(importName)}\n\nexport default (${treeToMdx(input, noRoot)})`;\n}\n","import { x } from 'tinyexec';\nimport type { JsonTreeNode } from '@/commands/file-tree';\n\nexport async function runTree(args: string): Promise<JsonTreeNode[]> {\n const out = await x('tree', [args, '--gitignore', '--prune', '-J']);\n\n try {\n return JSON.parse(out.stdout) as JsonTreeNode[];\n } catch (e) {\n throw new Error('failed to run `tree` command', {\n cause: e,\n });\n }\n}\n","","export const UIRegistries = {\n 'base-ui': 'fumadocs/base-ui',\n 'radix-ui': 'fumadocs/radix-ui',\n};\n","import type { ComponentInstallerPlugin } from '../installer';\n\n/**\n * keep references to `fumadocs-ui/layouts/*` components as original, unless the user is installing them directly.\n */\nexport function pluginPreserveLayouts(): ComponentInstallerPlugin {\n const layoutNames = [\n 'layouts/home',\n 'layouts/flux',\n 'layouts/notebook',\n 'layouts/docs',\n 'layouts/shared',\n ];\n // original specifier -> new specifier\n const layoutComps: Record<string, string> = {\n '@/<dir>/home/index.tsx': 'layouts/home',\n '@/<dir>/shared/index.tsx': 'layouts/shared',\n '@/<dir>/shared/client.tsx': 'layouts/shared',\n '@/<dir>/notebook/index.tsx': 'layouts/notebook',\n '@/<dir>/notebook/client.tsx': 'layouts/notebook',\n '@/<dir>/notebook/page/index.tsx': 'layouts/notebook/page',\n '@/<dir>/notebook/page/client.tsx': 'layouts/notebook/page',\n '@/<dir>/docs/index.tsx': 'layouts/docs',\n '@/<dir>/docs/client.tsx': 'layouts/docs',\n '@/<dir>/docs/page/index.tsx': 'layouts/docs/page',\n '@/<dir>/docs/page/client.tsx': 'layouts/docs/page',\n '@/<dir>/flux/index.tsx': 'layouts/flux',\n '@/<dir>/flux/page/index.tsx': 'layouts/flux/page',\n '@/<dir>/flux/page/client.tsx': 'layouts/flux/page',\n };\n const layoutNameSet = new Set(layoutNames);\n\n return {\n beforeInstall(comp, { stack }) {\n const isDirectInstall = layoutNameSet.has(stack[0].name);\n if (isDirectInstall) return;\n\n return {\n ...comp,\n $subComponents: comp.$subComponents.filter((child) => !layoutNameSet.has(child.name)),\n };\n },\n transformImport(specifier, { stack }) {\n const isDirectInstall = layoutNameSet.has(stack[0].name);\n // skip if direct install or unrelated to layout component\n if (isDirectInstall || !(specifier in layoutComps)) return specifier;\n\n return `fumadocs-ui/${layoutComps[specifier]}`;\n },\n };\n}\n","import {\n isCancel,\n autocompleteMultiselect,\n outro,\n spinner,\n confirm,\n box,\n log,\n} from '@clack/prompts';\nimport picocolors from 'picocolors';\nimport { ComponentInstaller } from '@/registry/installer';\nimport type { RegistryClient } from '@/registry/client';\nimport { UIRegistries } from '@/commands/shared';\nimport { pluginPreserveLayouts } from '@/registry/plugins/preserve';\nimport { detect } from 'package-manager-detector';\n\nexport async function add(input: string[], client: RegistryClient) {\n const config = client.config;\n let target: string[];\n const installer = new ComponentInstaller(client, {\n plugins: [pluginPreserveLayouts()],\n });\n const registry = UIRegistries[config.uiLibrary];\n\n if (input.length === 0) {\n const spin = spinner();\n spin.start('fetching registry');\n const info = await client.fetchRegistryInfo();\n const options: {\n label: string;\n value: string;\n hint?: string;\n }[] = [];\n\n for (const item of info.indexes) {\n options.push({\n label: item.title ?? item.name,\n value: item.name,\n hint: item.description,\n });\n }\n const { indexes } = await client.createLinkedRegistryClient(registry).fetchRegistryInfo();\n\n for (const item of indexes) {\n options.push({\n label: item.title ?? item.name,\n value: `${registry}/${item.name}`,\n hint: item.description,\n });\n }\n\n spin.stop(picocolors.bold(picocolors.greenBright('registry fetched')));\n const value = await autocompleteMultiselect({\n message: 'Select components to install',\n options,\n });\n\n if (isCancel(value)) {\n outro('Ended');\n return;\n }\n\n target = value;\n } else {\n target = await Promise.all(\n input.map(async (item) => ((await client.hasComponent(item)) ? item : `${registry}/${item}`)),\n );\n }\n\n await install(target, installer);\n}\n\nexport async function install(target: string[], installer: ComponentInstaller) {\n for (const name of target) {\n const spin = spinner();\n spin.start(picocolors.bold(picocolors.cyanBright(`Installing ${name}`)));\n\n try {\n await installer.install(name, {\n onWarn(message) {\n spin.message(message);\n },\n async confirmFileOverride(options) {\n spin.clear();\n const value = await confirm({\n message: `Do you want to override ${options.path}?`,\n initialValue: false,\n });\n if (isCancel(value)) {\n outro('Installation terminated');\n process.exit(0);\n }\n spin.start(picocolors.bold(picocolors.cyanBright(`Installing ${name}`)));\n return value;\n },\n onFileDownloaded(options) {\n spin.message(options.path);\n },\n });\n spin.stop(picocolors.bold(picocolors.greenBright(`${name} installed`)));\n } catch (e) {\n spin.error(e instanceof Error ? e.message : String(e));\n process.exit(-1);\n }\n }\n\n const deps = await installer.deps();\n if (deps.hasRequired()) {\n log.message();\n box([...deps.dependencies, ...deps.devDependencies].join('\\n'), 'New Dependencies');\n const pm = (await detect())?.name ?? 'npm';\n const value = await confirm({\n message: `Do you want to install with ${pm}?`,\n });\n\n if (isCancel(value)) {\n outro('Installation terminated');\n process.exit(0);\n }\n\n if (value) {\n const spin = spinner({\n errorMessage: 'Failed to install dependencies',\n });\n spin.start('Installing dependencies');\n await deps.installRequired(pm);\n spin.stop('Dependencies installed');\n } else {\n await deps.writeRequired();\n }\n }\n\n await installer.onEnd();\n outro(picocolors.bold(picocolors.greenBright('Successful')));\n}\n","import { cancel, group, intro, log, outro, select } from '@clack/prompts';\nimport picocolors from 'picocolors';\nimport { install } from '@/commands/add';\nimport type { RegistryClient } from '@/registry/client';\nimport { ComponentInstaller } from '@/registry/installer';\nimport { UIRegistries } from '@/commands/shared';\nimport { pluginPreserveLayouts } from '@/registry/plugins/preserve';\n\ninterface TargetInfo {\n target: string[];\n id: string;\n print?: () => void;\n}\n\ninterface SlotPrintInfo {\n at: string;\n layoutId: string;\n name: string;\n isPage: boolean;\n}\n\nexport async function customise(client: RegistryClient) {\n intro(picocolors.bgBlack(picocolors.whiteBright('Customise Fumadocs UI')));\n const config = client.config;\n const installer = new ComponentInstaller(client, {\n plugins: [pluginPreserveLayouts()],\n });\n const registry = UIRegistries[config.uiLibrary];\n const info = await client.createLinkedRegistryClient(registry).fetchRegistryInfo();\n\n const result = await group(\n {\n layout: (): Promise<TargetInfo | symbol> =>\n select({\n message: 'What do you want to customise?',\n options: [\n {\n label: 'Docs Layout',\n value: {\n id: 'docs',\n target: [`${registry}/layouts/docs`],\n print() {\n printLayout(\n ['fumadocs-ui/layouts/docs', '@/layouts/docs'],\n ['fumadocs-ui/layouts/docs/page', '@/layouts/docs/page'],\n );\n },\n },\n hint: 'the default docs layout',\n },\n {\n label: 'Notebook Layout',\n value: {\n id: 'notebook',\n target: [`${registry}/layouts/notebook`],\n print() {\n printLayout(\n ['fumadocs-ui/layouts/notebook', '@/layouts/notebook'],\n ['fumadocs-ui/layouts/notebook/page', '@/layouts/notebook/page'],\n );\n },\n },\n hint: 'a more compact version of docs layout',\n },\n {\n label: 'Flux Layout',\n value: {\n id: 'flux',\n target: [`${registry}/layouts/flux`],\n print() {\n printLayout(\n ['fumadocs-ui/layouts/flux', '@/layouts/flux'],\n ['fumadocs-ui/layouts/flux/page', '@/layouts/flux/page'],\n );\n },\n },\n hint: 'the experimental variant of docs layout',\n },\n {\n label: 'Home Layout',\n value: {\n id: 'home',\n target: [`${registry}/layouts/home`],\n print() {\n printLayout(['fumadocs-ui/layouts/home', `@/layouts/home`]);\n },\n },\n hint: 'the layout for other non-docs pages',\n },\n ],\n }),\n target: (v): Promise<TargetInfo | symbol> => {\n const selected = v.results.layout!;\n if (selected.id === 'home') return Promise.resolve(selected);\n\n return select<TargetInfo>({\n message: 'Which part do you want to customise?',\n options: [\n {\n label: 'All',\n hint: 'install the entire layout',\n value: selected,\n },\n {\n label: 'Replace & rewrite from minimal styles',\n hint: 'for those who want to build their own UI from ground up',\n value: {\n id: 'docs-min',\n target: ['layouts/docs-min'],\n print() {\n printLayout(\n ['fumadocs-ui/layouts/docs', '@/layouts/docs'],\n ['fumadocs-ui/layouts/docs/page', '@/layouts/docs/page'],\n );\n },\n },\n },\n ...info.unlistedIndexes.flatMap((index) => {\n const prefix = `slots/${selected.id}`;\n if (!index.name.startsWith(prefix)) return [];\n let name = index.name.slice(prefix.length + 1);\n\n if (name.startsWith('page/')) {\n name = name.slice('page/'.length);\n\n return {\n label: `Page: ${name}`,\n hint: \"only replace a part of layout's page, useful for adjusting details\",\n value: {\n id: index.name,\n target: [`${registry}/${index.name}`],\n print() {\n printSlot({\n at: `@/layouts/${selected.id}/page/slots/${name}`,\n layoutId: selected.id,\n name,\n isPage: true,\n });\n },\n } as TargetInfo,\n };\n }\n\n return {\n label: `Layout: ${name}`,\n hint: 'only replace a part of layout, useful for adjusting details',\n value: {\n id: index.name,\n target: [`${registry}/${index.name}`],\n print() {\n printSlot({\n at: `@/layouts/${selected.id}/slots/${name}`,\n layoutId: selected.id,\n name,\n isPage: false,\n });\n },\n } as TargetInfo,\n };\n }),\n ],\n });\n },\n },\n {\n onCancel: () => {\n cancel('Installation Stopped.');\n process.exit(0);\n },\n },\n );\n\n const target = result.target as TargetInfo;\n await install(target.target, installer);\n target.print?.();\n\n outro(picocolors.bold('Have fun!'));\n}\n\nfunction printLayout(...maps: [from: string, to: string][]) {\n intro(picocolors.bold('What is Next?'));\n\n log.info(\n [\n 'You can check the installed layouts in `layouts` folder.',\n picocolors.dim('---'),\n 'Open your `layout.tsx` files, replace the imports of components:',\n ...maps.map(([from, to]) => picocolors.greenBright(`\"${from}\" -> \"${to}\"`)),\n ].join('\\n'),\n );\n}\n\nfunction printSlot({ at, layoutId, name, isPage }: SlotPrintInfo) {\n intro(picocolors.bold('What is Next?'));\n\n log.info(`You can check the installed layout slot in \"${at}\".`);\n\n const code = getSlotCode({ at, layoutId, name, isPage });\n\n if (code) {\n if (isPage) {\n log.info(\n `${picocolors.bold('At your <DocsPage /> component, update your \"slots\" prop:')}\\n\\n${code}`,\n );\n } else {\n log.info(\n `${picocolors.bold('At your <DocsLayout /> component, update your \"slots\" prop:')}\\n\\n${code}`,\n );\n }\n }\n}\n\nfunction getSlotCode({ at, layoutId, name, isPage }: SlotPrintInfo): string | undefined {\n if (isPage) {\n switch (name) {\n case 'toc':\n if (layoutId === 'flux') {\n return `import { TOCProvider, TOC } from '${at}';\n\nreturn (\n <DocsPage\n slots={{\n toc: {\n provider: TOCProvider,\n main: TOC,\n },\n }}\n >\n ...\n </DocsPage>\n);`;\n }\n\n return `import { TOCProvider, TOC, TOCPopover } from '${at}';\n\nreturn (\n <DocsPage\n slots={{\n toc: {\n provider: TOCProvider,\n main: TOC,\n popover: TOCPopover,\n },\n }}\n >\n ...\n </DocsPage>\n);`;\n case 'container': {\n return `import { Container } from '${at}';\n\nreturn (\n <DocsPage\n slots={{\n container: Container,\n }}\n >\n ...\n </DocsPage>\n);`;\n }\n case 'footer': {\n return `import { Footer } from '${at}';\n\nreturn (\n <DocsPage\n slots={{\n footer: Footer,\n }}\n >\n ...\n </DocsPage>\n);`;\n }\n case 'breadcrumb': {\n return `import { Breadcrumb } from '${at}';\n\nreturn (\n <DocsPage\n slots={{\n breadcrumb: Breadcrumb,\n }}\n >\n ...\n </DocsPage>\n);`;\n }\n default:\n return;\n }\n }\n\n switch (name) {\n case 'sidebar': {\n if (layoutId === 'notebook') {\n return `import {\n SidebarProvider,\n Sidebar,\n SidebarTrigger,\n SidebarCollapseTrigger,\n useSidebar,\n} from '${at}';\n\nreturn (\n <DocsLayout\n slots={{\n sidebar: {\n provider: SidebarProvider,\n root: Sidebar,\n trigger: SidebarTrigger,\n collapseTrigger: SidebarCollapseTrigger,\n useSidebar: useSidebar,\n },\n }}\n >\n ...\n </DocsLayout>\n);`;\n }\n\n return `import { SidebarProvider, Sidebar, SidebarTrigger, useSidebar } from '${at}';\n\nreturn (\n <DocsLayout\n slots={{\n sidebar: {\n provider: SidebarProvider,\n root: Sidebar,\n trigger: SidebarTrigger,\n useSidebar: useSidebar,\n },\n }}\n >\n ...\n </DocsLayout>\n);`;\n }\n case 'container': {\n return `import { Container } from '${at}';\n\nreturn (\n <DocsLayout\n slots={{\n container: Container,\n }}\n >\n ...\n </DocsLayout>\n);`;\n }\n case 'header': {\n return `import { Header } from '${at}';\n\nreturn (\n <DocsLayout\n slots={{\n header: Header,\n }}\n >\n ...\n </DocsLayout>\n);`;\n }\n case 'tab-dropdown': {\n return `import { TabDropdown } from '${at}';\n\nreturn (\n <DocsLayout\n slots={{\n tabDropdown: TabDropdown,\n }}\n >\n ...\n </DocsLayout>\n);`;\n }\n default:\n return;\n }\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { exists } from '@/utils/fs';\nimport picocolors from 'picocolors';\nimport { spinner } from '@clack/prompts';\nimport { exec } from 'node:child_process';\nimport { promisify } from 'node:util';\n\nconst execAsync = promisify(exec);\n\ninterface PackageJson {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n}\n\nasync function readPackageJson(cwd: string): Promise<PackageJson | null> {\n try {\n const raw = await fs.readFile(path.join(cwd, 'package.json'), 'utf-8');\n return JSON.parse(raw) as PackageJson;\n } catch {\n return null;\n }\n}\n\n/** Path of pre-rendered EPUB, choose one according to your React framework. Next.js fetches from the running server instead. */\nconst EPUB_BUILD_PATHS: Record<string, string> = {\n next: '', // Fetched from /export/epub at runtime; route handlers don't produce static files\n 'tanstack-start': '.output/public/export/epub',\n 'tanstack-start-spa': 'dist/client/export/epub',\n 'react-router': 'build/client/export/epub',\n 'react-router-spa': 'build/client/export/epub',\n waku: 'dist/public/export/epub',\n};\n\nconst API_ROUTE_TEMPLATE = `import { source } from '@/lib/source';\nimport { exportEpub } from 'fumadocs-epub';\n\nexport const revalidate = false;\n\nexport async function GET(request: Request): Promise<Response> {\n // Require EXPORT_SECRET to prevent unauthenticated abuse. Pass via Authorization: Bearer <secret>\n const secret = process.env.EXPORT_SECRET;\n if (!secret) {\n return new Response('EXPORT_SECRET is not configured. Set it in your environment to protect this endpoint.', { status: 503 });\n }\n const authHeader = request.headers.get('authorization');\n const token = authHeader?.replace(/^Bearer\\\\s+/i, '') ?? '';\n if (token !== secret) {\n return new Response('Unauthorized', { status: authHeader ? 403 : 401 });\n }\n const buffer = await exportEpub({\n source,\n title: 'Documentation',\n author: 'Your Team',\n description: 'Exported documentation',\n cover: '/cover.png',\n });\n return new Response(new Uint8Array(buffer), {\n headers: {\n 'Content-Type': 'application/epub+zip',\n 'Content-Disposition': 'attachment; filename=\"docs.epub\"',\n },\n });\n}\n`;\n\nasync function findAppDir(cwd: string): Promise<string | null> {\n const appPaths = ['app', 'src/app'];\n for (const appPath of appPaths) {\n const fullPath = path.join(cwd, appPath);\n if (await exists(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\nasync function scaffoldEpubRoute(cwd: string): Promise<boolean> {\n const appDir = await findAppDir(cwd);\n if (!appDir) {\n console.error(picocolors.red('Could not find app directory (app/ or src/app/)'));\n return false;\n }\n\n const routePath = path.join(appDir, 'export', 'epub', 'route.ts');\n if (await exists(routePath)) {\n console.log(picocolors.yellow('EPUB route already exists at'), routePath);\n return true;\n }\n\n await fs.mkdir(path.dirname(routePath), { recursive: true });\n await fs.writeFile(routePath, API_ROUTE_TEMPLATE);\n console.log(picocolors.green('Created EPUB route at'), routePath);\n return true;\n}\n\nexport async function exportEpub(options: {\n output?: string;\n framework: string;\n scaffoldOnly?: boolean;\n}) {\n const cwd = process.cwd();\n const outputPath = path.resolve(cwd, options.output ?? 'docs.epub');\n const framework = options.framework;\n\n const spin = spinner();\n\n const buildPath = EPUB_BUILD_PATHS[framework];\n if (!(framework in EPUB_BUILD_PATHS)) {\n const valid = Object.keys(EPUB_BUILD_PATHS).join(', ');\n console.error(picocolors.red(`Invalid --framework \"${framework}\". Must be one of: ${valid}`));\n process.exit(1);\n }\n\n // Check for Next.js when scaffolding (only Next.js scaffold is implemented)\n const pkg = await readPackageJson(cwd);\n const hasNextConfig =\n (await exists(path.join(cwd, 'next.config.js'))) ||\n (await exists(path.join(cwd, 'next.config.ts'))) ||\n (await exists(path.join(cwd, 'next.config.mjs')));\n const nextDeps = pkg\n ? { ...pkg.dependencies, ...pkg.devDependencies, ...pkg.peerDependencies }\n : {};\n const hasNextInPkg = !!nextDeps?.next;\n const hasAppOrPages =\n (await exists(path.join(cwd, 'app'))) ||\n (await exists(path.join(cwd, 'pages'))) ||\n (await exists(path.join(cwd, 'src', 'app'))) ||\n (await exists(path.join(cwd, 'src', 'pages')));\n const hasNext = hasNextConfig || (hasNextInPkg && hasAppOrPages);\n\n if (!hasNext && framework === 'next') {\n console.error(\n picocolors.red(\n 'Next.js project not found. Run this command from a Fumadocs Next.js project root.',\n ),\n );\n process.exit(1);\n }\n\n // Scaffold EPUB route (Next.js only for now)\n if (framework === 'next') {\n spin.start('Scaffolding EPUB route');\n const scaffolded = await scaffoldEpubRoute(cwd);\n spin.stop(scaffolded ? 'EPUB route ready' : 'Scaffolding failed');\n\n if (!scaffolded) {\n process.exit(1);\n }\n }\n\n if (options.scaffoldOnly) {\n console.log(picocolors.cyan('\\nTo export:'));\n console.log(' 1. Add fumadocs-epub to your dependencies: pnpm add fumadocs-epub');\n console.log(' 2. Ensure includeProcessedMarkdown: true in your docs collection config');\n if (framework === 'next') {\n console.log(\n ' 3. Set EXPORT_SECRET in your environment to protect the /export/epub endpoint',\n );\n console.log(' 4. Run production build: pnpm build');\n console.log(' 5. Start the server (e.g. pnpm start) and keep it running');\n console.log(' 6. Run: fumadocs export epub --framework next');\n } else {\n console.log(` 3. Add a prerender route that outputs EPUB to ${buildPath}`);\n console.log(' 4. Run production build: pnpm build');\n console.log(` 5. Run: fumadocs export epub --framework ${framework}`);\n }\n return;\n }\n\n // Check for fumadocs-epub dependency\n if (!pkg) {\n console.error(\n picocolors.red('Cannot read or parse package.json. Ensure it exists and is valid JSON.'),\n );\n process.exit(1);\n }\n const deps = { ...pkg.dependencies, ...pkg.devDependencies };\n if (!deps['fumadocs-epub']) {\n console.log(picocolors.yellow('\\nInstalling fumadocs-epub...'));\n const packageManager = process.env.npm_execpath?.includes('pnpm')\n ? 'pnpm'\n : process.env.npm_execpath?.includes('bun')\n ? 'bun'\n : 'npm';\n const installCmd = `${packageManager} add fumadocs-epub`;\n try {\n await execAsync(installCmd, { cwd });\n } catch (err: unknown) {\n const stderr =\n err && typeof err === 'object' && 'stderr' in err\n ? String((err as { stderr?: string }).stderr)\n : '';\n console.error(picocolors.red(`Failed to install fumadocs-epub. Command: ${installCmd}`));\n if (stderr) console.error(stderr);\n process.exit(1);\n }\n }\n\n if (framework === 'next') {\n const secret = process.env.EXPORT_SECRET;\n if (!secret) {\n console.error(\n picocolors.red('EXPORT_SECRET is required for Next.js export. Set it in your environment.'),\n );\n process.exit(1);\n }\n const port = process.env.PORT || '3000';\n const url = `http://localhost:${port}/export/epub`;\n spin.start('Fetching EPUB from server');\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 30_000);\n try {\n const res = await fetch(url, {\n headers: { Authorization: `Bearer ${secret}` },\n signal: controller.signal,\n });\n if (!res.ok) {\n if (res.status === 401 || res.status === 403) {\n console.error(\n picocolors.red('Auth failed. Check that EXPORT_SECRET matches the value in your app.'),\n );\n } else {\n console.error(\n picocolors.red(\n `Server returned ${res.status}. Ensure the app is running (e.g. pnpm start) on port ${port}.`,\n ),\n );\n }\n process.exit(1);\n }\n const buffer = Buffer.from(await res.arrayBuffer());\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.writeFile(outputPath, buffer);\n spin.stop(picocolors.green(`EPUB saved to ${outputPath}`));\n } catch (err: unknown) {\n if (err instanceof Error && err.name === 'AbortError') {\n console.error(picocolors.red('Request timed out after 30 seconds.'));\n } else {\n const msg = err instanceof Error ? err.message : String(err);\n console.error(picocolors.red(`Could not fetch EPUB: ${msg}`));\n }\n console.error(\n picocolors.yellow(`Ensure the server is running (e.g. pnpm start) on port ${port}.`),\n );\n process.exit(1);\n } finally {\n clearTimeout(timeoutId);\n }\n return;\n }\n\n const fullBuildPath = path.join(cwd, buildPath);\n if (!(await exists(fullBuildPath))) {\n console.error(\n picocolors.red(\n `EPUB not found at ${buildPath}. Run production build first (e.g. pnpm build).`,\n ),\n );\n process.exit(1);\n }\n\n spin.start('Copying EPUB');\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.copyFile(fullBuildPath, outputPath);\n spin.stop(picocolors.green(`EPUB saved to ${outputPath}`));\n}\n","#!/usr/bin/env node\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { Command } from 'commander';\nimport picocolors from 'picocolors';\nimport { createOrLoadConfig, initConfig, type LoadedConfig } from '@/config';\nimport { type JsonTreeNode, treeToJavaScript, treeToMdx } from '@/commands/file-tree';\nimport { runTree } from '@/utils/file-tree/run-tree';\nimport packageJson from '../package.json';\nimport { customise } from '@/commands/customise';\nimport { add } from '@/commands/add';\nimport { exportEpub } from '@/commands/export-epub';\nimport { HttpRegistryClient, LocalRegistryClient } from '@/registry/client';\n\nconst program = new Command().option('--config <string>');\n\nprogram\n .name('fumadocs')\n .description('CLI to setup Fumadocs, init a config')\n .version(packageJson.version)\n .action(async () => {\n if (await initConfig()) {\n console.log(picocolors.green('Initialized a `./cli.json` config file.'));\n } else {\n console.log(picocolors.redBright('A config file already exists.'));\n }\n });\n\nprogram\n .command('customise')\n .alias('customize')\n .description('simple way to customise layouts with Fumadocs UI')\n .option('--dir <string>', 'the root url or directory to resolve registry')\n .action(async (options: { config?: string; dir?: string }) => {\n await customise(createClientFromDir(options.dir, await createOrLoadConfig(options.config)));\n });\n\nconst dirShortcuts: Record<string, string> = {\n ':preview': 'https://preview.fumadocs.dev/registry',\n ':dev': 'http://localhost:3000/registry',\n};\n\nprogram\n .command('add')\n .description('add a new component to your docs')\n .argument('[components...]', 'components to download')\n .option('--dir <string>', 'the root url or directory to resolve registry')\n .action(async (input: string[], options: { config?: string; dir?: string }) => {\n const client = createClientFromDir(options.dir, await createOrLoadConfig(options.config));\n await add(input, client);\n });\n\nconst exportCmd = program.command('export').description('export documentation to various formats');\n\nexportCmd\n .command('epub')\n .description('export documentation to EPUB format (run after production build)')\n .requiredOption('--framework <name>', 'React framework: next, tanstack-start, react-router, waku')\n .option('--output <path>', 'output file path', 'docs.epub')\n .option('--scaffold-only', 'only scaffold the EPUB route, do not copy')\n .action(async (options: { output?: string; framework: string; scaffoldOnly?: boolean }) => {\n await exportEpub({\n output: options.output,\n framework: options.framework,\n scaffoldOnly: options.scaffoldOnly,\n });\n });\n\nprogram\n .command('tree')\n .argument('[json_or_args]', 'JSON output of `tree` command or arguments for the `tree` command')\n .argument('[output]', 'output path of file')\n .option('--js', 'output as JavaScript file')\n .option('--no-root', 'remove the root node')\n .option('--import-name <name>', 'where to import components (JS only)')\n .action(\n async (\n str: string | undefined,\n output: string | undefined,\n { js, root, importName }: { js: boolean; root: boolean; importName?: string },\n ) => {\n const jsExtensions = ['.js', '.tsx', '.jsx'];\n const noRoot = !root;\n let nodes: JsonTreeNode[];\n\n try {\n nodes = JSON.parse(str ?? '') as JsonTreeNode[];\n } catch {\n nodes = await runTree(str ?? './');\n }\n\n const out =\n js || (output && jsExtensions.includes(path.extname(output)))\n ? treeToJavaScript(nodes, noRoot, importName)\n : treeToMdx(nodes, noRoot);\n\n if (output) {\n await fs.mkdir(path.dirname(output), { recursive: true });\n await fs.writeFile(output, out);\n } else {\n console.log(out);\n }\n },\n );\n\nfunction createClientFromDir(dir = 'https://fumadocs.dev/registry', config: LoadedConfig) {\n if (dir in dirShortcuts) dir = dirShortcuts[dir];\n\n return dir.startsWith('http://') || dir.startsWith('https://')\n ? new HttpRegistryClient(dir, config)\n : new LocalRegistryClient(dir, config);\n}\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAM,UAAU;CAAC;CAAQ;CAAa;CAAO;AAE7C,SAAgB,UAAU,OAAuB,SAAS,OAAe;CACvE,SAAS,OAAO,MAA4B;AAC1C,MAAI,KAAK,SAAS,UAAU,KAAK,SAAS,OACxC,QAAO,cAAc,KAAK,UAAU,KAAK,KAAK,CAAC;AAGjD,MAAI,KAAK,SAAS,aAAa;AAC7B,OAAI,KAAK,SAAS,WAAW,KAAK,UAAU,KAAK,SAAS,IAAI;IAC5D,MAAM,QAAQ,KAAK,SAAS;AAE5B,WAAO,OAAO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