@fumadocs/cli 1.5.0 → 1.6.0
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/ai-BVuNjYXU.js +100 -0
- package/dist/ai-BVuNjYXU.js.map +1 -0
- package/dist/all-aUHxtoXL.js +27 -0
- package/dist/all-aUHxtoXL.js.map +1 -0
- package/dist/codemod/index.d.ts +2 -0
- package/dist/codemod/index.js +2 -0
- package/dist/codemod-auol-p4R.js +404 -0
- package/dist/codemod-auol-p4R.js.map +1 -0
- package/dist/config-CT2jj39D.d.ts +52 -0
- package/dist/config-CT2jj39D.d.ts.map +1 -0
- package/dist/config-D6uv73fs.js +94 -0
- package/dist/config-D6uv73fs.js.map +1 -0
- package/dist/config.d.ts +2 -52
- package/dist/config.js +1 -72
- package/dist/docs-DeIEl_Kt.js +738 -0
- package/dist/docs-DeIEl_Kt.js.map +1 -0
- package/dist/epub-CnQFJh09.js +52 -0
- package/dist/epub-CnQFJh09.js.map +1 -0
- package/dist/features/ai.d.ts +25 -0
- package/dist/features/ai.d.ts.map +1 -0
- package/dist/features/ai.js +2 -0
- package/dist/features/all.d.ts +5 -0
- package/dist/features/all.d.ts.map +1 -0
- package/dist/features/all.js +2 -0
- package/dist/features/docs/index.d.ts +10 -0
- package/dist/features/docs/index.d.ts.map +1 -0
- package/dist/features/docs/index.js +2 -0
- package/dist/features/epub.d.ts +5 -0
- package/dist/features/epub.d.ts.map +1 -0
- package/dist/features/epub.js +2 -0
- package/dist/features/feedback.d.ts +5 -0
- package/dist/features/feedback.d.ts.map +1 -0
- package/dist/features/feedback.js +2 -0
- package/dist/features/index.d.ts +2 -0
- package/dist/features/index.js +2 -0
- package/dist/features/lint.d.ts +7 -0
- package/dist/features/lint.d.ts.map +1 -0
- package/dist/features/lint.js +2 -0
- package/dist/features/llms.d.ts +27 -0
- package/dist/features/llms.d.ts.map +1 -0
- package/dist/features/llms.js +2 -0
- package/dist/features/mcp.d.ts +9 -0
- package/dist/features/mcp.d.ts.map +1 -0
- package/dist/features/mcp.js +2 -0
- package/dist/features/og.d.ts +8 -0
- package/dist/features/og.d.ts.map +1 -0
- package/dist/features/og.js +2 -0
- package/dist/features/search.d.ts +84 -0
- package/dist/features/search.d.ts.map +1 -0
- package/dist/features/search.js +2 -0
- package/dist/features/utils.d.ts +2 -0
- package/dist/features/utils.js +2 -0
- package/dist/features/webmcp.d.ts +12 -0
- package/dist/features/webmcp.d.ts.map +1 -0
- package/dist/features/webmcp.js +2 -0
- package/dist/features-C1kf2s8j.js +132 -0
- package/dist/features-C1kf2s8j.js.map +1 -0
- package/dist/feedback-COmWtc5C.js +37 -0
- package/dist/feedback-COmWtc5C.js.map +1 -0
- package/dist/fs-D6J9dOEx.js +14 -0
- package/dist/fs-D6J9dOEx.js.map +1 -0
- package/dist/index-BCVGQxn9.d.ts +64 -0
- package/dist/index-BCVGQxn9.d.ts.map +1 -0
- package/dist/index-CR9T40ox.d.ts +76 -0
- package/dist/index-CR9T40ox.d.ts.map +1 -0
- package/dist/index-Ck0EPdgu.d.ts +126 -0
- package/dist/index-Ck0EPdgu.d.ts.map +1 -0
- package/dist/index.js +121 -112
- package/dist/index.js.map +1 -1
- package/dist/{installer-Ci3Hf9it.js → installer-D0Obb2Md.js} +16 -6
- package/dist/installer-D0Obb2Md.js.map +1 -0
- package/dist/lint-zkXUULgO.js +137 -0
- package/dist/lint-zkXUULgO.js.map +1 -0
- package/dist/llms-CONd8Vnn.js +228 -0
- package/dist/llms-CONd8Vnn.js.map +1 -0
- package/dist/mcp-BT8BLZZ-.js +67 -0
- package/dist/mcp-BT8BLZZ-.js.map +1 -0
- package/dist/og-DRDOyQ_t.js +142 -0
- package/dist/og-DRDOyQ_t.js.map +1 -0
- package/dist/project/index.d.ts +2 -0
- package/dist/project/index.js +2 -0
- package/dist/project-DwRVTm4p.js +110 -0
- package/dist/project-DwRVTm4p.js.map +1 -0
- package/dist/registry/installer.d.ts +4 -5
- package/dist/registry/installer.d.ts.map +1 -1
- package/dist/registry/installer.js +1 -1
- package/dist/schema.json +1 -1
- package/dist/search-iphnSVVY.js +381 -0
- package/dist/search-iphnSVVY.js.map +1 -0
- package/dist/utils-B1Xy4l_a.d.ts +43 -0
- package/dist/utils-B1Xy4l_a.d.ts.map +1 -0
- package/dist/utils-DbMe7h6c.js +98 -0
- package/dist/utils-DbMe7h6c.js.map +1 -0
- package/dist/webmcp-C2PM_9md.js +135 -0
- package/dist/webmcp-C2PM_9md.js.map +1 -0
- package/package.json +27 -7
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/installer-Ci3Hf9it.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { t as FumadocsComponentInstaller } from "./installer-
|
|
2
|
+
import { i as initConfig, n as createOrLoadConfig } from "./config-D6uv73fs.js";
|
|
3
|
+
import { n as isCancel$1, t as FumadocsComponentInstaller } from "./installer-D0Obb2Md.js";
|
|
4
|
+
import { t as exists } from "./fs-D6J9dOEx.js";
|
|
5
|
+
import { i as loadProject } from "./project-DwRVTm4p.js";
|
|
6
|
+
import { t as runFeature } from "./features-C1kf2s8j.js";
|
|
7
|
+
import { t as features } from "./all-aUHxtoXL.js";
|
|
4
8
|
import fs from "node:fs/promises";
|
|
5
9
|
import path from "node:path";
|
|
6
|
-
import {
|
|
10
|
+
import { cac } from "cac";
|
|
7
11
|
import picocolors from "picocolors";
|
|
8
12
|
import { x } from "tinyexec";
|
|
9
|
-
import { autocompleteMultiselect, cancel, group, intro,
|
|
13
|
+
import { autocompleteMultiselect, cancel, confirm, group, intro, log, note, outro, select, spinner } from "@clack/prompts";
|
|
10
14
|
import { exec } from "node:child_process";
|
|
11
15
|
import { promisify } from "node:util";
|
|
12
16
|
import { HttpRegistryConnector, LocalRegistryConnector } from "fuma-cli/registry/connector";
|
|
@@ -61,7 +65,7 @@ async function runTree(args) {
|
|
|
61
65
|
}
|
|
62
66
|
//#endregion
|
|
63
67
|
//#region package.json
|
|
64
|
-
var version = "1.
|
|
68
|
+
var version = "1.6.0";
|
|
65
69
|
//#endregion
|
|
66
70
|
//#region src/commands/shared.ts
|
|
67
71
|
const UIRegistries = {
|
|
@@ -474,7 +478,7 @@ async function add(input, connector, config) {
|
|
|
474
478
|
message: "Select components to install",
|
|
475
479
|
options: groups.flat().sort((a, b) => a.label.localeCompare(b.label))
|
|
476
480
|
});
|
|
477
|
-
if (isCancel(value)) {
|
|
481
|
+
if (isCancel$1(value)) {
|
|
478
482
|
outro("Ended");
|
|
479
483
|
return;
|
|
480
484
|
}
|
|
@@ -487,16 +491,6 @@ async function add(input, connector, config) {
|
|
|
487
491
|
outro(picocolors.bold(picocolors.greenBright("Successful")));
|
|
488
492
|
}
|
|
489
493
|
//#endregion
|
|
490
|
-
//#region src/utils/fs.ts
|
|
491
|
-
async function exists(pathLike) {
|
|
492
|
-
try {
|
|
493
|
-
await fs.access(pathLike);
|
|
494
|
-
return true;
|
|
495
|
-
} catch {
|
|
496
|
-
return false;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
//#endregion
|
|
500
494
|
//#region src/commands/export-epub.ts
|
|
501
495
|
const execAsync = promisify(exec);
|
|
502
496
|
async function readPackageJson(cwd) {
|
|
@@ -517,60 +511,6 @@ const EPUB_BUILD_PATHS = {
|
|
|
517
511
|
"react-router-spa": "build/client/export/epub",
|
|
518
512
|
waku: "dist/public/export/epub"
|
|
519
513
|
};
|
|
520
|
-
const API_ROUTE_TEMPLATE = `import { source } from '@/lib/source';
|
|
521
|
-
import { exportEpub } from 'fumadocs-epub';
|
|
522
|
-
|
|
523
|
-
export const revalidate = false;
|
|
524
|
-
|
|
525
|
-
export async function GET(request: Request): Promise<Response> {
|
|
526
|
-
// Require EXPORT_SECRET to prevent unauthenticated abuse. Pass via Authorization: Bearer <secret>
|
|
527
|
-
const secret = process.env.EXPORT_SECRET;
|
|
528
|
-
if (!secret) {
|
|
529
|
-
return new Response('EXPORT_SECRET is not configured. Set it in your environment to protect this endpoint.', { status: 503 });
|
|
530
|
-
}
|
|
531
|
-
const authHeader = request.headers.get('authorization');
|
|
532
|
-
const token = authHeader?.replace(/^Bearer\\s+/i, '') ?? '';
|
|
533
|
-
if (token !== secret) {
|
|
534
|
-
return new Response('Unauthorized', { status: authHeader ? 403 : 401 });
|
|
535
|
-
}
|
|
536
|
-
const buffer = await exportEpub({
|
|
537
|
-
source,
|
|
538
|
-
title: 'Documentation',
|
|
539
|
-
author: 'Your Team',
|
|
540
|
-
description: 'Exported documentation',
|
|
541
|
-
cover: '/cover.png',
|
|
542
|
-
});
|
|
543
|
-
return new Response(new Uint8Array(buffer), {
|
|
544
|
-
headers: {
|
|
545
|
-
'Content-Type': 'application/epub+zip',
|
|
546
|
-
'Content-Disposition': 'attachment; filename="docs.epub"',
|
|
547
|
-
},
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
`;
|
|
551
|
-
async function findAppDir(cwd) {
|
|
552
|
-
for (const appPath of ["app", "src/app"]) {
|
|
553
|
-
const fullPath = path.join(cwd, appPath);
|
|
554
|
-
if (await exists(fullPath)) return fullPath;
|
|
555
|
-
}
|
|
556
|
-
return null;
|
|
557
|
-
}
|
|
558
|
-
async function scaffoldEpubRoute(cwd) {
|
|
559
|
-
const appDir = await findAppDir(cwd);
|
|
560
|
-
if (!appDir) {
|
|
561
|
-
console.error(picocolors.red("Could not find app directory (app/ or src/app/)"));
|
|
562
|
-
return false;
|
|
563
|
-
}
|
|
564
|
-
const routePath = path.join(appDir, "export", "epub", "route.ts");
|
|
565
|
-
if (await exists(routePath)) {
|
|
566
|
-
console.log(picocolors.yellow("EPUB route already exists at"), routePath);
|
|
567
|
-
return true;
|
|
568
|
-
}
|
|
569
|
-
await fs.mkdir(path.dirname(routePath), { recursive: true });
|
|
570
|
-
await fs.writeFile(routePath, API_ROUTE_TEMPLATE);
|
|
571
|
-
console.log(picocolors.green("Created EPUB route at"), routePath);
|
|
572
|
-
return true;
|
|
573
|
-
}
|
|
574
514
|
async function exportEpub(options) {
|
|
575
515
|
const cwd = process.cwd();
|
|
576
516
|
const outputPath = path.resolve(cwd, options.output ?? "docs.epub");
|
|
@@ -583,39 +523,6 @@ async function exportEpub(options) {
|
|
|
583
523
|
process.exit(1);
|
|
584
524
|
}
|
|
585
525
|
const pkg = await readPackageJson(cwd);
|
|
586
|
-
const hasNextConfig = await exists(path.join(cwd, "next.config.js")) || await exists(path.join(cwd, "next.config.ts")) || await exists(path.join(cwd, "next.config.mjs"));
|
|
587
|
-
const hasNextInPkg = !!(pkg ? {
|
|
588
|
-
...pkg.dependencies,
|
|
589
|
-
...pkg.devDependencies,
|
|
590
|
-
...pkg.peerDependencies
|
|
591
|
-
} : {}).next;
|
|
592
|
-
const hasAppOrPages = await exists(path.join(cwd, "app")) || await exists(path.join(cwd, "pages")) || await exists(path.join(cwd, "src", "app")) || await exists(path.join(cwd, "src", "pages"));
|
|
593
|
-
if (!(hasNextConfig || hasNextInPkg && hasAppOrPages) && framework === "next") {
|
|
594
|
-
console.error(picocolors.red("Next.js project not found. Run this command from a Fumadocs Next.js project root."));
|
|
595
|
-
process.exit(1);
|
|
596
|
-
}
|
|
597
|
-
if (framework === "next") {
|
|
598
|
-
spin.start("Scaffolding EPUB route");
|
|
599
|
-
const scaffolded = await scaffoldEpubRoute(cwd);
|
|
600
|
-
spin.stop(scaffolded ? "EPUB route ready" : "Scaffolding failed");
|
|
601
|
-
if (!scaffolded) process.exit(1);
|
|
602
|
-
}
|
|
603
|
-
if (options.scaffoldOnly) {
|
|
604
|
-
console.log(picocolors.cyan("\nTo export:"));
|
|
605
|
-
console.log(" 1. Add fumadocs-epub to your dependencies: pnpm add fumadocs-epub");
|
|
606
|
-
console.log(" 2. Ensure includeProcessedMarkdown: true in your docs collection config");
|
|
607
|
-
if (framework === "next") {
|
|
608
|
-
console.log(" 3. Set EXPORT_SECRET in your environment to protect the /export/epub endpoint");
|
|
609
|
-
console.log(" 4. Run production build: pnpm build");
|
|
610
|
-
console.log(" 5. Start the server (e.g. pnpm start) and keep it running");
|
|
611
|
-
console.log(" 6. Run: fumadocs export epub --framework next");
|
|
612
|
-
} else {
|
|
613
|
-
console.log(` 3. Add a prerender route that outputs EPUB to ${buildPath}`);
|
|
614
|
-
console.log(" 4. Run production build: pnpm build");
|
|
615
|
-
console.log(` 5. Run: fumadocs export epub --framework ${framework}`);
|
|
616
|
-
}
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
526
|
if (!pkg) {
|
|
620
527
|
console.error(picocolors.red("Cannot read or parse package.json. Ensure it exists and is valid JSON."));
|
|
621
528
|
process.exit(1);
|
|
@@ -653,6 +560,7 @@ async function exportEpub(options) {
|
|
|
653
560
|
});
|
|
654
561
|
if (!res.ok) {
|
|
655
562
|
if (res.status === 401 || res.status === 403) console.error(picocolors.red("Auth failed. Check that EXPORT_SECRET matches the value in your app."));
|
|
563
|
+
else if (res.status === 404) console.error(picocolors.red("Export route not found, run `fumadocs feature epub` to create it."));
|
|
656
564
|
else console.error(picocolors.red(`Server returned ${res.status}. Ensure the app is running (e.g. pnpm start) on port ${port}.`));
|
|
657
565
|
process.exit(1);
|
|
658
566
|
}
|
|
@@ -684,31 +592,124 @@ async function exportEpub(options) {
|
|
|
684
592
|
spin.stop(picocolors.green(`EPUB saved to ${outputPath}`));
|
|
685
593
|
}
|
|
686
594
|
//#endregion
|
|
595
|
+
//#region src/commands/feature.ts
|
|
596
|
+
function registerFeatureCommands(cli, createConnector) {
|
|
597
|
+
const ids = features.map((feature) => feature.id).join(", ");
|
|
598
|
+
register(cli.command("feature <id>", `configure a feature on your project (${ids})`), features).action(async (id, options) => {
|
|
599
|
+
const feature = features.find((item) => item.id === id);
|
|
600
|
+
if (!feature) throw new Error(`unknown feature: ${id}, available: ${ids}`);
|
|
601
|
+
await run(feature, options, createConnector(options.dir));
|
|
602
|
+
});
|
|
603
|
+
register(cli.command("init", "set up Fumadocs on an existing app, same as `feature docs`"), [features[0]]).action(async (options) => {
|
|
604
|
+
await run(features[0], options, createConnector(options.dir));
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
function register(command, list) {
|
|
608
|
+
command.option("--dir <string>", "the root url or directory to resolve registry").option("-y, --yes", "skip prompts, overwrite existing files").option("--no-install", "write dependencies to package.json without installing");
|
|
609
|
+
for (const feature of list) for (const [key, option] of Object.entries(feature.options ?? {})) if ("choices" in option) command.option(`--${key} <value>`, `${option.message} (${option.choices.map((choice) => choice.value).join(", ")})`);
|
|
610
|
+
else command.option(`--${key}`, option.message);
|
|
611
|
+
return command;
|
|
612
|
+
}
|
|
613
|
+
async function run(feature, options, connector) {
|
|
614
|
+
intro(picocolors.bgBlack(picocolors.whiteBright(feature.title)));
|
|
615
|
+
const config = await createOrLoadConfig(options.config);
|
|
616
|
+
const project = await loadProject(config);
|
|
617
|
+
log.info(`${project.framework}${project.static ? " (static)" : ""}, ${project.packageManager}`);
|
|
618
|
+
const values = {};
|
|
619
|
+
for (const [key, option] of Object.entries(feature.options ?? {})) {
|
|
620
|
+
const given = options[key];
|
|
621
|
+
if ("choices" in option) {
|
|
622
|
+
if (given !== void 0) {
|
|
623
|
+
if (!option.choices.some((choice) => choice.value === given)) throw new Error(`invalid value for --${key}: ${given}`);
|
|
624
|
+
values[key] = given;
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
const value = await select({
|
|
628
|
+
message: option.message,
|
|
629
|
+
options: option.choices
|
|
630
|
+
});
|
|
631
|
+
if (isCancel$1(value)) {
|
|
632
|
+
cancel("Stopped.");
|
|
633
|
+
process.exit(0);
|
|
634
|
+
}
|
|
635
|
+
values[key] = value;
|
|
636
|
+
} else if (given !== void 0) values[key] = given === true;
|
|
637
|
+
else if (options.yes) values[key] = option.initialValue ?? false;
|
|
638
|
+
else {
|
|
639
|
+
const value = await confirm({
|
|
640
|
+
message: option.message,
|
|
641
|
+
initialValue: option.initialValue
|
|
642
|
+
});
|
|
643
|
+
if (isCancel$1(value)) {
|
|
644
|
+
cancel("Stopped.");
|
|
645
|
+
process.exit(0);
|
|
646
|
+
}
|
|
647
|
+
values[key] = value;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
const spin = spinner();
|
|
651
|
+
const io = {
|
|
652
|
+
installDependencies: options.install !== false,
|
|
653
|
+
log: (message) => spin.message(message),
|
|
654
|
+
async confirmOverwrite(file) {
|
|
655
|
+
if (options.yes) return true;
|
|
656
|
+
spin.clear();
|
|
657
|
+
const value = await confirm({
|
|
658
|
+
message: `Overwrite ${file}?`,
|
|
659
|
+
initialValue: false
|
|
660
|
+
});
|
|
661
|
+
if (isCancel$1(value)) {
|
|
662
|
+
cancel("Stopped.");
|
|
663
|
+
process.exit(0);
|
|
664
|
+
}
|
|
665
|
+
spin.start();
|
|
666
|
+
return value;
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
spin.start(`Applying ${feature.title}`);
|
|
670
|
+
try {
|
|
671
|
+
const { notes } = await runFeature(feature, values, {
|
|
672
|
+
project,
|
|
673
|
+
connector,
|
|
674
|
+
io
|
|
675
|
+
});
|
|
676
|
+
spin.stop(`${feature.title} applied`);
|
|
677
|
+
if (notes.length > 0) note(notes.join("\n\n"), "What is Next?");
|
|
678
|
+
} catch (e) {
|
|
679
|
+
spin.error(e instanceof Error ? e.message : String(e));
|
|
680
|
+
process.exit(1);
|
|
681
|
+
}
|
|
682
|
+
outro(picocolors.bold(picocolors.greenBright("Done")));
|
|
683
|
+
}
|
|
684
|
+
//#endregion
|
|
687
685
|
//#region src/index.ts
|
|
688
|
-
const
|
|
689
|
-
|
|
686
|
+
const cli = cac("fumadocs");
|
|
687
|
+
cli.option("--config <string>", "path to the config file");
|
|
688
|
+
cli.command("", "init a `cli.json` config file").action(async () => {
|
|
690
689
|
if (await initConfig()) console.log(picocolors.green("Initialized a `./cli.json` config file."));
|
|
691
690
|
else console.log(picocolors.redBright("A config file already exists."));
|
|
692
691
|
});
|
|
693
|
-
|
|
692
|
+
cli.command("customise", "simple way to customize layouts with Fumadocs UI").alias("customize").option("--dir <string>", "the root url or directory to resolve registry").action(async (options) => {
|
|
694
693
|
await customise(await createOrLoadConfig(options.config), createClientFromDir(options.dir));
|
|
695
694
|
});
|
|
696
695
|
const dirShortcuts = {
|
|
697
696
|
":preview": "https://preview.fumadocs.dev/registry",
|
|
698
697
|
":dev": "http://localhost:3000/registry"
|
|
699
698
|
};
|
|
700
|
-
|
|
699
|
+
cli.command("add [...components]", "add a new component to your docs").option("--dir <string>", "the root url or directory to resolve registry").action(async (input, options) => {
|
|
701
700
|
const config = await createOrLoadConfig(options.config);
|
|
702
701
|
await add(input, createClientFromDir(options.dir), config);
|
|
703
702
|
});
|
|
704
|
-
|
|
703
|
+
registerFeatureCommands(cli, createClientFromDir);
|
|
704
|
+
cli.command("export <format>", "export documentation to various formats (run after production build)").option("--framework <name>", "framework: next, astro, tanstack-start, react-router, waku").option("--output <path>", "output file path", { default: "docs.epub" }).action(async (format, options) => {
|
|
705
|
+
if (format !== "epub") throw new Error(`unsupported format: ${format}, only \`epub\` is supported.`);
|
|
706
|
+
if (!options.framework) throw new Error("option `--framework <name>` is required.");
|
|
705
707
|
await exportEpub({
|
|
706
|
-
output: options.output,
|
|
707
708
|
framework: options.framework,
|
|
708
|
-
|
|
709
|
+
output: options.output
|
|
709
710
|
});
|
|
710
711
|
});
|
|
711
|
-
|
|
712
|
+
cli.command("tree [json_or_args] [output]", "generate a file tree for the Files component, from a directory or JSON output of `tree`").option("--js", "output as JavaScript file").option("--no-root", "remove the root node").option("--import-name <name>", "where to import components (JS only)").action(async (str, output, { js, root, importName }) => {
|
|
712
713
|
const jsExtensions = [
|
|
713
714
|
".js",
|
|
714
715
|
".tsx",
|
|
@@ -731,7 +732,15 @@ function createClientFromDir(dir = "https://fumadocs.dev/registry") {
|
|
|
731
732
|
if (dir in dirShortcuts) dir = dirShortcuts[dir];
|
|
732
733
|
return dir.startsWith("http://") || dir.startsWith("https://") ? new HttpRegistryConnector(dir) : new LocalRegistryConnector(dir);
|
|
733
734
|
}
|
|
734
|
-
|
|
735
|
+
cli.help();
|
|
736
|
+
cli.version(version);
|
|
737
|
+
try {
|
|
738
|
+
cli.parse(process.argv, { run: false });
|
|
739
|
+
await cli.runMatchedCommand();
|
|
740
|
+
} catch (e) {
|
|
741
|
+
console.error(picocolors.redBright(e instanceof Error ? e.message : String(e)));
|
|
742
|
+
process.exit(1);
|
|
743
|
+
}
|
|
735
744
|
//#endregion
|
|
736
745
|
export {};
|
|
737
746
|
|
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/commands/customise.ts","../src/commands/add.ts","../src/utils/fs.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 { cancel, group, intro, log, outro, select } from '@clack/prompts';\nimport picocolors from 'picocolors';\nimport type { Target } from '@/commands/add';\nimport { UIRegistries } from '@/commands/shared';\nimport { LoadedConfig } from '@/config';\nimport { RegistryConnector } from 'fuma-cli/registry/connector';\nimport { FumadocsComponentInstaller } from '@/registry/installer';\n\ninterface TargetInfo {\n targets: Target[];\n id: string;\n print?: () => void;\n}\n\ninterface SlotPrintInfo {\n at: string;\n layoutId: string;\n name: string;\n isPage: boolean;\n uiLibrary: LoadedConfig['uiLibrary'];\n}\n\nexport async function customise(config: LoadedConfig, connector: RegistryConnector) {\n intro(picocolors.bgBlack(picocolors.whiteBright('Customize Fumadocs UI')));\n\n const installer = new FumadocsComponentInstaller(connector, config);\n const subRegistry = UIRegistries[config.uiLibrary];\n const info = await connector.fetchRegistryInfo(subRegistry);\n\n const result = await group(\n {\n layout: (): Promise<TargetInfo | symbol> =>\n select({\n message: 'What do you want to customize?',\n options: [\n {\n label: 'Docs Layout',\n value: {\n id: 'docs',\n targets: [{ subRegistry, name: '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 targets: [{ subRegistry, name: '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 targets: [{ subRegistry, name: '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: 'Glass Layout',\n value: {\n id: 'glass',\n targets: [{ subRegistry, name: 'layouts/glass' }],\n print() {\n printLayout(\n ['fumadocs-ui/layouts/glass', '@/layouts/glass'],\n ['fumadocs-ui/layouts/glass/page', '@/layouts/glass/page'],\n );\n },\n },\n hint: 'a docs layout with floating, translucent panels',\n },\n {\n label: 'Home Layout',\n value: {\n id: 'home',\n targets: [{ subRegistry, name: '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 customize?',\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 targets: [{ name: '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 targets: [{ subRegistry, name: index.name }],\n print() {\n printSlot({\n at: `@/layouts/${selected.id}/page/slots/${name}`,\n layoutId: selected.id,\n name,\n isPage: true,\n uiLibrary: config.uiLibrary,\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 targets: [{ subRegistry, name: index.name }],\n print() {\n printSlot({\n at: `@/layouts/${selected.id}/slots/${name}`,\n layoutId: selected.id,\n name,\n isPage: false,\n uiLibrary: config.uiLibrary,\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 targetInfo = result.target as TargetInfo;\n for (const target of targetInfo.targets) {\n await installer.installInteractive(target.name, target.subRegistry);\n }\n\n targetInfo.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, uiLibrary }: 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, uiLibrary });\n\n if (code) {\n const layoutComponent = layoutId === 'glass' ? '<GlassLayout />' : '<DocsLayout />';\n\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 ${layoutComponent} component, update your \"slots\" prop:`)}\\n\\n${code}`,\n );\n }\n }\n}\n\nfunction getSlotCode({ at, layoutId, name, isPage, uiLibrary }: SlotPrintInfo): string | undefined {\n if (layoutId === 'glass') {\n // Glass layout wires its page slots directly, only layout-level slots are swappable.\n if (isPage) return;\n\n switch (name) {\n case 'header':\n return `import { Header } from '${at}';\n\nreturn (\n <GlassLayout\n slots={{\n header: Header,\n }}\n >\n ...\n </GlassLayout>\n);`;\n case 'sidebar': {\n // `sidebar` slot file holds the whole sidebar system (desktop, mobile drawer, provider).\n // Base UI additionally exposes a `drawerHandle` for its swipeable drawer.\n const imports = ['Sidebar', 'SidebarDrawer', 'SidebarProvider', 'useSidebar'];\n if (uiLibrary === 'base-ui') imports.push('drawerHandle');\n\n return `import { ${imports.join(', ')} } from '${at}';\n\nreturn (\n <GlassLayout\n slots={{\n sidebar: {\n main: Sidebar,\n provider: SidebarProvider,\n use: useSidebar,\n drawer: SidebarDrawer,${uiLibrary === 'base-ui' ? '\\n drawerHandle,' : ''}\n },\n }}\n >\n ...\n </GlassLayout>\n);`;\n }\n default:\n return;\n }\n }\n\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 { isCancel, autocompleteMultiselect, outro, spinner } from '@clack/prompts';\nimport picocolors from 'picocolors';\nimport { UIRegistries } from '@/commands/shared';\nimport { RegistryConnector } from 'fuma-cli/registry/connector';\nimport { LoadedConfig } from '@/config';\nimport { FumadocsComponentInstaller } from '@/registry/installer';\n\ninterface AddOption {\n label: string;\n value: Target;\n hint?: string;\n}\n\nexport interface Target {\n name: string;\n subRegistry?: string;\n}\n\nexport async function add(input: string[], connector: RegistryConnector, config: LoadedConfig) {\n let targets: Target[];\n const installer = new FumadocsComponentInstaller(connector, config);\n const subRegistry = UIRegistries[config.uiLibrary];\n\n if (input.length === 0) {\n const spin = spinner();\n spin.start('fetching registry');\n\n async function scan(subRegistry?: string, prefix?: string): Promise<AddOption[]> {\n const info = await connector.fetchRegistryInfo(subRegistry);\n\n return info.indexes.map((item) => ({\n label: `${prefix ? `${picocolors.bold(prefix)} - ` : ''}${item.title ?? item.name}`,\n value: { name: item.name, subRegistry },\n hint: item.description,\n }));\n }\n\n const groups = await Promise.all([\n scan(undefined, 'common'),\n scan('fumadocs/sanity', 'sanity'),\n scan('fumadocs/openapi', 'openapi'),\n scan('fumadocs/api-docs', 'api-docs'),\n scan(subRegistry, 'ui'),\n ]);\n\n spin.stop(picocolors.bold(picocolors.greenBright('registry fetched')));\n const value = await autocompleteMultiselect({\n message: 'Select components to install',\n options: groups.flat().sort((a, b) => a.label.localeCompare(b.label)),\n });\n\n if (isCancel(value)) {\n outro('Ended');\n return;\n }\n\n targets = value;\n } else {\n targets = await Promise.all(\n input.map(async (item) =>\n (await connector.hasComponent(item)) ? { name: item } : { subRegistry, name: item },\n ),\n );\n }\n\n for (const target of targets) {\n await installer.installInteractive(target.name, target.subRegistry);\n }\n\n outro(picocolors.bold(picocolors.greenBright('Successful')));\n}\n","import fs from 'node:fs/promises';\n\nexport async function exists(pathLike: string): Promise<boolean> {\n try {\n await fs.access(pathLike);\n return true;\n } catch {\n return false;\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 astro: 'dist/export/epub',\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 } 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 { HttpRegistryConnector, LocalRegistryConnector } from 'fuma-cli/registry/connector';\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 customize 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 const config = await createOrLoadConfig(options.config);\n await customise(config, createClientFromDir(options.dir));\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 config = await createOrLoadConfig(options.config);\n const client = createClientFromDir(options.dir);\n await add(input, client, config);\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(\n '--framework <name>',\n 'framework: next, astro, tanstack-start, react-router, waku',\n )\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') {\n if (dir in dirShortcuts) dir = dirShortcuts[dir];\n\n return dir.startsWith('http://') || dir.startsWith('https://')\n ? new HttpRegistryConnector(dir)\n : new LocalRegistryConnector(dir);\n}\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,UAAU;CAAC;CAAQ;CAAa;AAAM;AAE5C,SAAgB,UAAU,OAAuB,SAAS,OAAe;CACvE,SAAS,OAAO,MAA4B;EAC1C,IAAI,KAAK,SAAS,UAAU,KAAK,SAAS,QACxC,OAAO,cAAc,KAAK,UAAU,KAAK,IAAI,EAAE;EAGjD,IAAI,KAAK,SAAS,aAAa;GAC7B,IAAI,KAAK,SAAS,WAAW,KAAK,UAAU,KAAK,SAAS,IAAI;IAC5D,MAAM,QAAQ,KAAK,SAAS;IAE5B,OAAO,OAAO;KACZ,GAAG;KACH,MAAM,GAAG,KAAK,KAAK,GAAG,MAAM;IAC9B,CAAC;GACH;GAEA,OAAO,gBAAgB,KAAK,UAAU,KAAK,IAAI,EAAE;EACrD,KAAK,SAAS,IAAI,MAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE;;EAEnD;EAEA,OAAO;CACT;CAEA,IAAI,WAAW,MAAM,QAAQ,MAAM,QAAQ,SAAS,EAAE,IAAI,CAAC;CAE3D,IAAI,UAAU,SAAS,WAAW,KAAK,MAAM,EAAE,CAAC,SAAS,aACvD,WAAW,MAAM,EAAE,CAAC;CAGtB,OAAO;EACP,SAAS,IAAI,MAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,E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S,kBAAkB,mEAAmE,CAAC,CAC/F,SAAS,YAAY,qBAAqB,CAAC,CAC3C,OAAO,QAAQ,2BAA2B,CAAC,CAC3C,OAAO,aAAa,sBAAsB,CAAC,CAC3C,OAAO,wBAAwB,sCAAsC,CAAC,CACtE,OACC,OACE,KACA,QACA,EAAE,IAAI,MAAM,iBACT;CACH,MAAM,eAAe;EAAC;EAAO;EAAQ;CAAM;CAC3C,MAAM,SAAS,CAAC;CAChB,IAAI;CAEJ,IAAI;EACF,QAAQ,KAAK,MAAM,OAAO,EAAE;CAC9B,QAAQ;EACN,QAAQ,MAAM,QAAQ,OAAO,IAAI;CACnC;CAEA,MAAM,MACJ,MAAO,UAAU,aAAa,SAAS,KAAK,QAAQ,MAAM,CAAC,IACvD,iBAAiB,OAAO,QAAQ,UAAU,IAC1C,UAAU,OAAO,MAAM;CAE7B,IAAI,QAAQ;EACV,MAAM,GAAG,MAAM,KAAK,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;EACxD,MAAM,GAAG,UAAU,QAAQ,GAAG;CAChC,OACE,QAAQ,IAAI,GAAG;AAEnB,CACF;AAEF,SAAS,oBAAoB,MAAM,iCAAiC;CAClE,IAAI,OAAO,cAAc,MAAM,aAAa;CAE5C,OAAO,IAAI,WAAW,SAAS,KAAK,IAAI,WAAW,UAAU,IACzD,IAAI,sBAAsB,GAAG,IAC7B,IAAI,uBAAuB,GAAG;AACpC;AAEA,QAAQ,MAAM"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["isCancel","isCancel","packageJson.version"],"sources":["../src/commands/file-tree.ts","../src/utils/file-tree/run-tree.ts","../package.json","../src/commands/shared.ts","../src/commands/customise.ts","../src/commands/add.ts","../src/commands/export-epub.ts","../src/commands/feature.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 { cancel, group, intro, log, outro, select } from '@clack/prompts';\nimport picocolors from 'picocolors';\nimport type { Target } from '@/commands/add';\nimport { UIRegistries } from '@/commands/shared';\nimport { LoadedConfig } from '@/config';\nimport { RegistryConnector } from 'fuma-cli/registry/connector';\nimport { FumadocsComponentInstaller } from '@/registry/installer';\n\ninterface TargetInfo {\n targets: Target[];\n id: string;\n print?: () => void;\n}\n\ninterface SlotPrintInfo {\n at: string;\n layoutId: string;\n name: string;\n isPage: boolean;\n uiLibrary: LoadedConfig['uiLibrary'];\n}\n\nexport async function customise(config: LoadedConfig, connector: RegistryConnector) {\n intro(picocolors.bgBlack(picocolors.whiteBright('Customize Fumadocs UI')));\n\n const installer = new FumadocsComponentInstaller(connector, config);\n const subRegistry = UIRegistries[config.uiLibrary];\n const info = await connector.fetchRegistryInfo(subRegistry);\n\n const result = await group(\n {\n layout: (): Promise<TargetInfo | symbol> =>\n select({\n message: 'What do you want to customize?',\n options: [\n {\n label: 'Docs Layout',\n value: {\n id: 'docs',\n targets: [{ subRegistry, name: '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 targets: [{ subRegistry, name: '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 targets: [{ subRegistry, name: '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: 'Glass Layout',\n value: {\n id: 'glass',\n targets: [{ subRegistry, name: 'layouts/glass' }],\n print() {\n printLayout(\n ['fumadocs-ui/layouts/glass', '@/layouts/glass'],\n ['fumadocs-ui/layouts/glass/page', '@/layouts/glass/page'],\n );\n },\n },\n hint: 'a docs layout with floating, translucent panels',\n },\n {\n label: 'Home Layout',\n value: {\n id: 'home',\n targets: [{ subRegistry, name: '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 customize?',\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 targets: [{ name: '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 targets: [{ subRegistry, name: index.name }],\n print() {\n printSlot({\n at: `@/layouts/${selected.id}/page/slots/${name}`,\n layoutId: selected.id,\n name,\n isPage: true,\n uiLibrary: config.uiLibrary,\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 targets: [{ subRegistry, name: index.name }],\n print() {\n printSlot({\n at: `@/layouts/${selected.id}/slots/${name}`,\n layoutId: selected.id,\n name,\n isPage: false,\n uiLibrary: config.uiLibrary,\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 targetInfo = result.target as TargetInfo;\n for (const target of targetInfo.targets) {\n await installer.installInteractive(target.name, target.subRegistry);\n }\n\n targetInfo.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, uiLibrary }: 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, uiLibrary });\n\n if (code) {\n const layoutComponent = layoutId === 'glass' ? '<GlassLayout />' : '<DocsLayout />';\n\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 ${layoutComponent} component, update your \"slots\" prop:`)}\\n\\n${code}`,\n );\n }\n }\n}\n\nfunction getSlotCode({ at, layoutId, name, isPage, uiLibrary }: SlotPrintInfo): string | undefined {\n if (layoutId === 'glass') {\n // Glass layout wires its page slots directly, only layout-level slots are swappable.\n if (isPage) return;\n\n switch (name) {\n case 'header':\n return `import { Header } from '${at}';\n\nreturn (\n <GlassLayout\n slots={{\n header: Header,\n }}\n >\n ...\n </GlassLayout>\n);`;\n case 'sidebar': {\n // `sidebar` slot file holds the whole sidebar system (desktop, mobile drawer, provider).\n // Base UI additionally exposes a `drawerHandle` for its swipeable drawer.\n const imports = ['Sidebar', 'SidebarDrawer', 'SidebarProvider', 'useSidebar'];\n if (uiLibrary === 'base-ui') imports.push('drawerHandle');\n\n return `import { ${imports.join(', ')} } from '${at}';\n\nreturn (\n <GlassLayout\n slots={{\n sidebar: {\n main: Sidebar,\n provider: SidebarProvider,\n use: useSidebar,\n drawer: SidebarDrawer,${uiLibrary === 'base-ui' ? '\\n drawerHandle,' : ''}\n },\n }}\n >\n ...\n </GlassLayout>\n);`;\n }\n default:\n return;\n }\n }\n\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 { autocompleteMultiselect, outro, spinner } from '@clack/prompts';\nimport { isCancel } from '@/utils/prompt';\nimport picocolors from 'picocolors';\nimport { UIRegistries } from '@/commands/shared';\nimport { RegistryConnector } from 'fuma-cli/registry/connector';\nimport { LoadedConfig } from '@/config';\nimport { FumadocsComponentInstaller } from '@/registry/installer';\n\ninterface AddOption {\n label: string;\n value: Target;\n hint?: string;\n}\n\nexport interface Target {\n name: string;\n subRegistry?: string;\n}\n\nexport async function add(input: string[], connector: RegistryConnector, config: LoadedConfig) {\n let targets: Target[];\n const installer = new FumadocsComponentInstaller(connector, config);\n const subRegistry = UIRegistries[config.uiLibrary];\n\n if (input.length === 0) {\n const spin = spinner();\n spin.start('fetching registry');\n\n async function scan(subRegistry?: string, prefix?: string): Promise<AddOption[]> {\n const info = await connector.fetchRegistryInfo(subRegistry);\n\n return info.indexes.map((item) => ({\n label: `${prefix ? `${picocolors.bold(prefix)} - ` : ''}${item.title ?? item.name}`,\n value: { name: item.name, subRegistry },\n hint: item.description,\n }));\n }\n\n const groups = await Promise.all([\n scan(undefined, 'common'),\n scan('fumadocs/sanity', 'sanity'),\n scan('fumadocs/openapi', 'openapi'),\n scan('fumadocs/api-docs', 'api-docs'),\n scan(subRegistry, 'ui'),\n ]);\n\n spin.stop(picocolors.bold(picocolors.greenBright('registry fetched')));\n const value = await autocompleteMultiselect({\n message: 'Select components to install',\n options: groups.flat().sort((a, b) => a.label.localeCompare(b.label)),\n });\n\n if (isCancel(value)) {\n outro('Ended');\n return;\n }\n\n targets = value;\n } else {\n targets = await Promise.all(\n input.map(async (item) =>\n (await connector.hasComponent(item)) ? { name: item } : { subRegistry, name: item },\n ),\n );\n }\n\n for (const target of targets) {\n await installer.installInteractive(target.name, target.subRegistry);\n }\n\n outro(picocolors.bold(picocolors.greenBright('Successful')));\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 astro: 'dist/export/epub',\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\nexport async function exportEpub(options: { output?: string; framework: string }) {\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 const pkg = await readPackageJson(cwd);\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 if (res.status === 404) {\n console.error(\n picocolors.red('Export route not found, run `fumadocs feature epub` to create it.'),\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","import type { CAC, Command } from 'cac';\nimport { cancel, confirm, intro, log, note, outro, select, spinner } from '@clack/prompts';\nimport { isCancel } from '@/utils/prompt';\nimport picocolors from 'picocolors';\nimport type { RegistryConnector } from 'fuma-cli/registry/connector';\nimport { createOrLoadConfig } from '@/config';\nimport { loadProject } from '@/project';\nimport { type AnyFeature, type FeatureIO, runFeature } from '@/features';\nimport { features } from '@/features/all';\n\ninterface CommandOptions extends Record<string, string | boolean | undefined> {\n config?: string;\n dir?: string;\n yes?: boolean;\n install?: boolean;\n}\n\nexport function registerFeatureCommands(\n cli: CAC,\n createConnector: (dir?: string) => RegistryConnector,\n) {\n const ids = features.map((feature) => feature.id).join(', ');\n\n register(\n cli.command('feature <id>', `configure a feature on your project (${ids})`),\n features,\n ).action(async (id: string, options: CommandOptions) => {\n const feature = features.find((item) => item.id === id);\n if (!feature) throw new Error(`unknown feature: ${id}, available: ${ids}`);\n\n await run(feature, options, createConnector(options.dir));\n });\n\n register(cli.command('init', 'set up Fumadocs on an existing app, same as `feature docs`'), [\n features[0],\n ]).action(async (options: CommandOptions) => {\n await run(features[0], options, createConnector(options.dir));\n });\n}\n\nfunction register(command: Command, list: AnyFeature[]) {\n command\n .option('--dir <string>', 'the root url or directory to resolve registry')\n .option('-y, --yes', 'skip prompts, overwrite existing files')\n .option('--no-install', 'write dependencies to package.json without installing');\n\n for (const feature of list) {\n for (const [key, option] of Object.entries(feature.options ?? {})) {\n if ('choices' in option) {\n command.option(\n `--${key} <value>`,\n `${option.message} (${option.choices.map((choice) => choice.value).join(', ')})`,\n );\n } else {\n command.option(`--${key}`, option.message);\n }\n }\n }\n\n return command;\n}\n\nasync function run(feature: AnyFeature, options: CommandOptions, connector: RegistryConnector) {\n intro(picocolors.bgBlack(picocolors.whiteBright(feature.title)));\n const config = await createOrLoadConfig(options.config);\n const project = await loadProject(config);\n log.info(`${project.framework}${project.static ? ' (static)' : ''}, ${project.packageManager}`);\n\n const values: Record<string, unknown> = {};\n for (const [key, option] of Object.entries(feature.options ?? {})) {\n const given = options[key];\n if ('choices' in option) {\n if (given !== undefined) {\n if (!option.choices.some((choice) => choice.value === given))\n throw new Error(`invalid value for --${key}: ${given}`);\n values[key] = given;\n continue;\n }\n\n const value = await select({ message: option.message, options: option.choices });\n if (isCancel(value)) {\n cancel('Stopped.');\n process.exit(0);\n }\n values[key] = value;\n } else if (given !== undefined) {\n values[key] = given === true;\n } else if (options.yes) {\n values[key] = option.initialValue ?? false;\n } else {\n const value = await confirm({ message: option.message, initialValue: option.initialValue });\n if (isCancel(value)) {\n cancel('Stopped.');\n process.exit(0);\n }\n values[key] = value;\n }\n }\n\n const spin = spinner();\n const io: FeatureIO = {\n installDependencies: options.install !== false,\n log: (message) => spin.message(message),\n async confirmOverwrite(file) {\n if (options.yes) return true;\n spin.clear();\n const value = await confirm({ message: `Overwrite ${file}?`, initialValue: false });\n if (isCancel(value)) {\n cancel('Stopped.');\n process.exit(0);\n }\n spin.start();\n return value;\n },\n };\n\n spin.start(`Applying ${feature.title}`);\n try {\n const { notes } = await runFeature(feature, values, { project, connector, io });\n spin.stop(`${feature.title} applied`);\n if (notes.length > 0) note(notes.join('\\n\\n'), 'What is Next?');\n } catch (e) {\n spin.error(e instanceof Error ? e.message : String(e));\n process.exit(1);\n }\n outro(picocolors.bold(picocolors.greenBright('Done')));\n}\n","#!/usr/bin/env node\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { cac } from 'cac';\nimport picocolors from 'picocolors';\nimport { createOrLoadConfig, initConfig } 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 { registerFeatureCommands } from '@/commands/feature';\nimport { HttpRegistryConnector, LocalRegistryConnector } from 'fuma-cli/registry/connector';\n\nconst cli = cac('fumadocs');\ncli.option('--config <string>', 'path to the config file');\n\ncli.command('', 'init a `cli.json` config file').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\ncli\n .command('customise', 'simple way to customize layouts with Fumadocs UI')\n .alias('customize')\n .option('--dir <string>', 'the root url or directory to resolve registry')\n .action(async (options: { config?: string; dir?: string }) => {\n const config = await createOrLoadConfig(options.config);\n await customise(config, createClientFromDir(options.dir));\n });\n\nconst dirShortcuts: Record<string, string> = {\n ':preview': 'https://preview.fumadocs.dev/registry',\n ':dev': 'http://localhost:3000/registry',\n};\n\ncli\n .command('add [...components]', 'add a new component to your docs')\n .option('--dir <string>', 'the root url or directory to resolve registry')\n .action(async (input: string[], options: { config?: string; dir?: string }) => {\n const config = await createOrLoadConfig(options.config);\n const client = createClientFromDir(options.dir);\n await add(input, client, config);\n });\n\nregisterFeatureCommands(cli, createClientFromDir);\n\ncli\n .command(\n 'export <format>',\n 'export documentation to various formats (run after production build)',\n )\n .option('--framework <name>', 'framework: next, astro, tanstack-start, react-router, waku')\n .option('--output <path>', 'output file path', { default: 'docs.epub' })\n .action(async (format: string, options: { framework?: string; output: string }) => {\n if (format !== 'epub')\n throw new Error(`unsupported format: ${format}, only \\`epub\\` is supported.`);\n if (!options.framework) throw new Error('option `--framework <name>` is required.');\n\n await exportEpub({ framework: options.framework, output: options.output });\n });\n\ncli\n .command(\n 'tree [json_or_args] [output]',\n 'generate a file tree for the Files component, from a directory or JSON output of `tree`',\n )\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') {\n if (dir in dirShortcuts) dir = dirShortcuts[dir];\n\n return dir.startsWith('http://') || dir.startsWith('https://')\n ? new HttpRegistryConnector(dir)\n : new LocalRegistryConnector(dir);\n}\n\ncli.help();\ncli.version(packageJson.version);\n\ntry {\n cli.parse(process.argv, { run: false });\n await cli.runMatchedCommand();\n} catch (e) {\n console.error(picocolors.redBright(e instanceof Error ? e.message : String(e)));\n process.exit(1);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAM,UAAU;CAAC;CAAQ;CAAa;AAAM;AAE5C,SAAgB,UAAU,OAAuB,SAAS,OAAe;CACvE,SAAS,OAAO,MAA4B;EAC1C,IAAI,KAAK,SAAS,UAAU,KAAK,SAAS,QACxC,OAAO,cAAc,KAAK,UAAU,KAAK,IAAI,EAAE;EAGjD,IAAI,KAAK,SAAS,aAAa;GAC7B,IAAI,KAAK,SAAS,WAAW,KAAK,UAAU,KAAK,SAAS,IAAI;IAC5D,MAAM,QAAQ,KAAK,SAAS;IAE5B,OAAO,OAAO;KACZ,GAA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reserveLayouts() {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
|
+
//#region src/utils/prompt.ts
|
|
53
|
+
/**
|
|
54
|
+
* `@clack/core` narrows to its own `unique symbol`, which can't exclude the wider `symbol` that
|
|
55
|
+
* `@clack/prompts` returns, so a prompt result never narrows without this.
|
|
56
|
+
*/
|
|
57
|
+
function isCancel$1(value) {
|
|
58
|
+
return isCancel(value);
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
52
61
|
//#region src/registry/installer.ts
|
|
53
62
|
var FumadocsComponentInstaller = class extends ComponentInstaller {
|
|
54
|
-
constructor(connector, config, cwd) {
|
|
63
|
+
constructor(connector, config, cwd, io) {
|
|
55
64
|
super(connector, {
|
|
56
65
|
cwd,
|
|
57
66
|
framework: config.framework === "astro" ? "none" : config.framework,
|
|
@@ -75,7 +84,7 @@ var FumadocsComponentInstaller = class extends ComponentInstaller {
|
|
|
75
84
|
message: `Do you want to override ${options.path}?`,
|
|
76
85
|
initialValue: false
|
|
77
86
|
});
|
|
78
|
-
if (isCancel(value)) {
|
|
87
|
+
if (isCancel$1(value)) {
|
|
79
88
|
outro("Installation terminated");
|
|
80
89
|
process.exit(0);
|
|
81
90
|
}
|
|
@@ -84,7 +93,8 @@ var FumadocsComponentInstaller = class extends ComponentInstaller {
|
|
|
84
93
|
},
|
|
85
94
|
onFileDownloaded: (options) => {
|
|
86
95
|
this.interactive?.spin.message(options.path);
|
|
87
|
-
}
|
|
96
|
+
},
|
|
97
|
+
...io
|
|
88
98
|
},
|
|
89
99
|
plugins: [pluginPreserveLayouts()]
|
|
90
100
|
});
|
|
@@ -106,7 +116,7 @@ var FumadocsComponentInstaller = class extends ComponentInstaller {
|
|
|
106
116
|
box([...deps.dependencies, ...deps.devDependencies].join("\n"), "New Dependencies");
|
|
107
117
|
const pm = (await detectPackageManager())?.name ?? "npm";
|
|
108
118
|
const value = await confirm({ message: `Do you want to install with ${pm}?` });
|
|
109
|
-
if (isCancel(value)) {
|
|
119
|
+
if (isCancel$1(value)) {
|
|
110
120
|
outro("Installation terminated");
|
|
111
121
|
process.exit(0);
|
|
112
122
|
}
|
|
@@ -126,6 +136,6 @@ var FumadocsComponentInstaller = class extends ComponentInstaller {
|
|
|
126
136
|
}
|
|
127
137
|
};
|
|
128
138
|
//#endregion
|
|
129
|
-
export { FumadocsComponentInstaller as t };
|
|
139
|
+
export { isCancel$1 as n, FumadocsComponentInstaller as t };
|
|
130
140
|
|
|
131
|
-
//# sourceMappingURL=installer-
|
|
141
|
+
//# sourceMappingURL=installer-D0Obb2Md.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer-D0Obb2Md.js","names":["isCancel","isCancelSymbol","isCancel"],"sources":["../src/registry/plugins/preserve.ts","../src/utils/prompt.ts","../src/registry/installer.ts"],"sourcesContent":["import type { InstallerPlugin } from 'fuma-cli/registry/installer';\n\n/**\n * keep references to `fumadocs-ui/layouts/*` components as original, unless the user is installing them directly.\n */\nexport function pluginPreserveLayouts(): InstallerPlugin {\n const layoutNames = [\n 'layouts/home',\n 'layouts/flux',\n 'layouts/glass',\n 'layouts/notebook',\n 'layouts/docs',\n 'layouts/shared',\n ];\n // original specifier -> new specifier\n const layoutComps: Record<string, string> = {\n 'local:<dir>/home/index.tsx': 'layouts/home',\n 'local:<dir>/shared/index.tsx': 'layouts/shared',\n 'local:<dir>/shared/client.tsx': 'layouts/shared',\n 'local:<dir>/notebook/index.tsx': 'layouts/notebook',\n 'local:<dir>/notebook/client.tsx': 'layouts/notebook',\n 'local:<dir>/notebook/page/index.tsx': 'layouts/notebook/page',\n 'local:<dir>/notebook/page/client.tsx': 'layouts/notebook/page',\n 'local:<dir>/docs/index.tsx': 'layouts/docs',\n 'local:<dir>/docs/client.tsx': 'layouts/docs',\n 'local:<dir>/docs/page/index.tsx': 'layouts/docs/page',\n 'local:<dir>/docs/page/client.tsx': 'layouts/docs/page',\n 'local:<dir>/flux/index.tsx': 'layouts/flux',\n 'local:<dir>/flux/page/index.tsx': 'layouts/flux/page',\n 'local:<dir>/flux/page/client.tsx': 'layouts/flux/page',\n 'local:<dir>/glass/index.tsx': 'layouts/glass',\n 'local:<dir>/glass/page/index.tsx': 'layouts/glass/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 { isCancel as isCancelSymbol } from '@clack/prompts';\n\n/**\n * `@clack/core` narrows to its own `unique symbol`, which can't exclude the wider `symbol` that\n * `@clack/prompts` returns, so a prompt result never narrows without this.\n */\nexport function isCancel<T>(value: T | symbol): value is symbol {\n return isCancelSymbol(value);\n}\n","import { ComponentInstaller, type IOInterface } from 'fuma-cli/registry/installer';\nimport { pluginPreserveLayouts } from './plugins/preserve';\nimport { RegistryConnector } from 'fuma-cli/registry/connector';\nimport type { LoadedConfig } from '@/config';\nimport { box, confirm, log, outro, spinner, SpinnerResult } from '@clack/prompts';\nimport { isCancel } from '@/utils/prompt';\nimport picocolors from 'picocolors';\nimport { detectPackageManager } from 'fuma-cli/detect';\n\nexport class FumadocsComponentInstaller extends ComponentInstaller {\n private interactive: {\n name: string;\n spin: SpinnerResult;\n } | null = null;\n\n constructor(\n connector: RegistryConnector,\n config: LoadedConfig,\n cwd?: string,\n io?: Partial<IOInterface>,\n ) {\n super(connector, {\n cwd,\n framework: config.framework === 'astro' ? 'none' : config.framework,\n outDir: {\n base: config.baseDir,\n components: config.aliases.componentsDir,\n css: config.aliases.cssDir,\n layout: config.aliases.layoutDir,\n lib: config.aliases.libDir,\n ui: config.aliases.uiDir,\n },\n io: {\n onWarn: (message) => {\n this.interactive?.spin.message(message);\n },\n confirmFileOverride: async (options) => {\n if (!this.interactive) return true;\n const { name, spin } = this.interactive;\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 this.interactive?.spin.message(options.path);\n },\n ...io,\n },\n plugins: [pluginPreserveLayouts()],\n });\n }\n\n async installInteractive(name: string, subRegistry?: string): Promise<void> {\n if (this.interactive) {\n throw new Error(`cannot install while installing another component`);\n }\n\n const spin = spinner();\n spin.start(picocolors.bold(picocolors.cyanBright(`Installing ${name}`)));\n\n try {\n this.interactive = { name, spin };\n const deps = await super.install(name, subRegistry).then((res) => res.deps());\n spin.stop(picocolors.bold(picocolors.greenBright(`${name} installed`)));\n\n if (deps.hasRequired()) {\n log.message();\n box([...deps.dependencies, ...deps.devDependencies].join('\\n'), 'New Dependencies');\n const pm = (await detectPackageManager())?.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 } catch (e) {\n spin.error(e instanceof Error ? e.message : String(e));\n process.exit(-1);\n } finally {\n this.interactive = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAKA,SAAgB,wBAAyC;CACvD,MAAM,cAAc;EAClB;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,MAAM,cAAsC;EAC1C,8BAA8B;EAC9B,gCAAgC;EAChC,iCAAiC;EACjC,kCAAkC;EAClC,mCAAmC;EACnC,uCAAuC;EACvC,wCAAw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