@fumadocs/cli 1.7.5 → 1.7.6
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-BoUGzPvv.js → ai-CvrtLYh1.js} +8 -6
- package/dist/ai-CvrtLYh1.js.map +1 -0
- package/dist/all-bAINnjNQ.js +26 -0
- package/dist/{all-DgAfTffR.js.map → all-bAINnjNQ.js.map} +1 -1
- package/dist/codemod/index.d.ts +1 -1
- package/dist/codemod/index.js +1 -2
- package/dist/{codemod-auol-p4R.js → codemod-Wc9nRqrw.js} +60 -39
- package/dist/codemod-Wc9nRqrw.js.map +1 -0
- package/dist/{config-Bw0kmF01.js → config-BpiQyqBs.js} +13 -8
- package/dist/config-BpiQyqBs.js.map +1 -0
- package/dist/{config-Bfg4yG8S.d.ts → config-Z-4b_Y_C.d.ts} +1 -3
- package/dist/config-Z-4b_Y_C.d.ts.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -2
- package/dist/{docs-qRGwd9Yp.js → docs---dy-BSm.js} +286 -32
- package/dist/docs---dy-BSm.js.map +1 -0
- package/dist/{epub-DbOh5Q2D.js → epub-BKvZ4ppz.js} +12 -13
- package/dist/epub-BKvZ4ppz.js.map +1 -0
- package/dist/features/ai.d.ts +2 -3
- package/dist/features/ai.d.ts.map +1 -1
- package/dist/features/ai.js +1 -2
- package/dist/features/all.d.ts +1 -3
- package/dist/features/all.d.ts.map +1 -1
- package/dist/features/all.js +1 -2
- package/dist/features/docs/index.d.ts +2 -4
- package/dist/features/docs/index.d.ts.map +1 -1
- package/dist/features/docs/index.js +1 -2
- package/dist/features/epub.d.ts +1 -3
- package/dist/features/epub.d.ts.map +1 -1
- package/dist/features/epub.js +1 -2
- package/dist/features/feedback.d.ts +1 -3
- package/dist/features/feedback.d.ts.map +1 -1
- package/dist/features/feedback.js +1 -2
- package/dist/features/index.d.ts +1 -1
- package/dist/features/index.js +1 -2
- package/dist/features/lint.d.ts +1 -3
- package/dist/features/lint.d.ts.map +1 -1
- package/dist/features/lint.js +1 -2
- package/dist/features/llms.d.ts +6 -7
- package/dist/features/llms.d.ts.map +1 -1
- package/dist/features/llms.js +1 -2
- package/dist/features/mcp.d.ts +5 -7
- package/dist/features/mcp.d.ts.map +1 -1
- package/dist/features/mcp.js +1 -2
- package/dist/features/og.d.ts +2 -3
- package/dist/features/og.d.ts.map +1 -1
- package/dist/features/og.js +1 -2
- package/dist/features/search.d.ts +10 -10
- package/dist/features/search.d.ts.map +1 -1
- package/dist/features/search.js +1 -2
- package/dist/features/utils.d.ts +2 -2
- package/dist/features/utils.js +1 -2
- package/dist/features/webmcp.d.ts +2 -3
- package/dist/features/webmcp.d.ts.map +1 -1
- package/dist/features/webmcp.js +1 -2
- package/dist/{features-Do6x9Tsz.js → features-C_FG2WD0.js} +5 -6
- package/dist/{features-Do6x9Tsz.js.map → features-C_FG2WD0.js.map} +1 -1
- package/dist/{feedback-DpXYMKtX.js → feedback-7u1-eklc.js} +6 -7
- package/dist/feedback-7u1-eklc.js.map +1 -0
- package/dist/{fs-D6J9dOEx.js → fs-Dqr1VJSD.js} +2 -3
- package/dist/{fs-D6J9dOEx.js.map → fs-Dqr1VJSD.js.map} +1 -1
- package/dist/{index-Cs7hw2un.d.ts → index-CAIqrY1S.d.ts} +3 -5
- package/dist/index-CAIqrY1S.d.ts.map +1 -0
- package/dist/{index-DI66DoV8.d.ts → index-DCJbgkgf.d.ts} +4 -8
- package/dist/index-DCJbgkgf.d.ts.map +1 -0
- package/dist/{index-Ck0EPdgu.d.ts → index-w9FHKPPs.d.ts} +6 -16
- package/dist/index-w9FHKPPs.d.ts.map +1 -0
- package/dist/index.js +22 -31
- package/dist/index.js.map +1 -1
- package/dist/{installer-C4662Woc.js → installer-CEOV0fBv.js} +3 -5
- package/dist/{installer-C4662Woc.js.map → installer-CEOV0fBv.js.map} +1 -1
- package/dist/{lint-zkXUULgO.js → lint-AC2ClOfa.js} +3 -4
- package/dist/{lint-zkXUULgO.js.map → lint-AC2ClOfa.js.map} +1 -1
- package/dist/{llms-DQzAst6R.js → llms-Cge1uefC.js} +11 -12
- package/dist/llms-Cge1uefC.js.map +1 -0
- package/dist/{mcp-BpFZ_fdV.js → mcp-BVpVFl6G.js} +7 -9
- package/dist/mcp-BVpVFl6G.js.map +1 -0
- package/dist/{og-CY4RS9Un.js → og-DuPd9kNq.js} +10 -11
- package/dist/og-DuPd9kNq.js.map +1 -0
- package/dist/project/index.d.ts +2 -2
- package/dist/project/index.js +1 -2
- package/dist/{project-DwRVTm4p.js → project-D655VGTX.js} +19 -10
- package/dist/project-D655VGTX.js.map +1 -0
- package/dist/registry/installer.d.ts +1 -3
- package/dist/registry/installer.d.ts.map +1 -1
- package/dist/registry/installer.js +1 -2
- package/dist/{search-BCHEW0-K.js → search-B44II4bM.js} +39 -30
- package/dist/search-B44II4bM.js.map +1 -0
- package/dist/{utils-DbMe7h6c.js → utils-Btt-BJ53.js} +6 -12
- package/dist/utils-Btt-BJ53.js.map +1 -0
- package/dist/{utils-CxJ7kw39.d.ts → utils-DlGz_4va.d.ts} +6 -12
- package/dist/utils-DlGz_4va.d.ts.map +1 -0
- package/dist/{webmcp-I9L7xzmw.js → webmcp-lY3_RsR3.js} +6 -8
- package/dist/webmcp-lY3_RsR3.js.map +1 -0
- package/package.json +7 -7
- package/dist/ai-BoUGzPvv.js.map +0 -1
- package/dist/all-DgAfTffR.js +0 -27
- package/dist/codemod-auol-p4R.js.map +0 -1
- package/dist/config-Bfg4yG8S.d.ts.map +0 -1
- package/dist/config-Bw0kmF01.js.map +0 -1
- package/dist/docs-qRGwd9Yp.js.map +0 -1
- package/dist/epub-DbOh5Q2D.js.map +0 -1
- package/dist/feedback-DpXYMKtX.js.map +0 -1
- package/dist/index-Ck0EPdgu.d.ts.map +0 -1
- package/dist/index-Cs7hw2un.d.ts.map +0 -1
- package/dist/index-DI66DoV8.d.ts.map +0 -1
- package/dist/llms-DQzAst6R.js.map +0 -1
- package/dist/mcp-BpFZ_fdV.js.map +0 -1
- package/dist/og-CY4RS9Un.js.map +0 -1
- package/dist/project-DwRVTm4p.js.map +0 -1
- package/dist/search-BCHEW0-K.js.map +0 -1
- package/dist/utils-CxJ7kw39.d.ts.map +0 -1
- package/dist/utils-DbMe7h6c.js.map +0 -1
- package/dist/webmcp-I9L7xzmw.js.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { i as addReactRouterPrerenderArray, n as enableProcessedMarkdown } from "./codemod-
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
1
|
+
import { i as addReactRouterPrerenderArray, n as enableProcessedMarkdown } from "./codemod-Wc9nRqrw.js";
|
|
2
|
+
import { i as formatRoute, o as routeModule, t as docs } from "./docs---dy-BSm.js";
|
|
3
|
+
import { a as registerReactRouterRoutes, l as sourceRef, o as requiresMarkdown } from "./utils-Btt-BJ53.js";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
5
|
+
// src/features/epub.ts
|
|
6
|
+
/** Astro inlines `import.meta.env` at build time, `getSecret()` reads secrets at runtime */
|
|
7
|
+
const api = ({ dynamic, ref }, astro) => `import { ${ref} } from '@/lib/source';
|
|
8
|
+
import { createEpubExportAPI } from 'fumadocs-epub';${astro ? "\nimport { getSecret } from 'astro:env/server';" : ""}
|
|
8
9
|
|
|
9
10
|
const api = createEpubExportAPI({
|
|
10
11
|
${ref === "source" ? "source" : `source: ${ref}`},${dynamic ? "\n getMarkdown: (page) => page.data.content," : ""}
|
|
@@ -12,11 +13,11 @@ const api = createEpubExportAPI({
|
|
|
12
13
|
author: 'Your Team',
|
|
13
14
|
description: 'Exported documentation',
|
|
14
15
|
// guards the route, requests must send \`Authorization: Bearer <secret>\`
|
|
15
|
-
secret: process.env.EXPORT_SECRET,
|
|
16
|
+
secret: ${astro ? "getSecret('EXPORT_SECRET')" : "process.env.EXPORT_SECRET"},
|
|
16
17
|
});
|
|
17
18
|
`;
|
|
18
19
|
const templates = (framework, route, src) => routeModule(framework, route, {
|
|
19
|
-
imports: api(src),
|
|
20
|
+
imports: api(src, framework === "astro"),
|
|
20
21
|
body: "api.GET(request)",
|
|
21
22
|
request: true,
|
|
22
23
|
revalidate: true
|
|
@@ -28,11 +29,10 @@ const epub = {
|
|
|
28
29
|
requires: [docs],
|
|
29
30
|
supports: (project) => project.static ? "the export route needs a server at runtime" : requiresMarkdown(project),
|
|
30
31
|
async apply(ctx) {
|
|
31
|
-
const { baseDir, source } = ctx.project;
|
|
32
|
-
const framework = reactFramework(ctx.project);
|
|
32
|
+
const { baseDir, source, framework } = ctx.project;
|
|
33
33
|
ctx.addDependencies({ "fumadocs-epub": null });
|
|
34
34
|
if (source.collections) await ctx.source(source.collections, (file) => {
|
|
35
|
-
if (!enableProcessedMarkdown(file)) throw new Error(`cannot
|
|
35
|
+
if (!enableProcessedMarkdown(file)) throw new Error(`cannot enable \`includeProcessedMarkdown\` in ${source.collections}`);
|
|
36
36
|
});
|
|
37
37
|
const route = formatRoute({ segments: ["export/epub"] }, framework, null);
|
|
38
38
|
await ctx.write(path.join(baseDir, route.file), templates(framework, route, sourceRef(ctx.project.source.dynamic)));
|
|
@@ -46,7 +46,6 @@ const epub = {
|
|
|
46
46
|
ctx.note("Set EXPORT_SECRET in `.env.local`, then export with `fumadocs export epub` after a production build.");
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
//#endregion
|
|
50
49
|
export { epub as t };
|
|
51
50
|
|
|
52
|
-
//# sourceMappingURL=epub-
|
|
51
|
+
//# sourceMappingURL=epub-BKvZ4ppz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epub-BKvZ4ppz.js","names":[],"sources":["../src/features/epub.ts"],"sourcesContent":["import path from 'node:path';\nimport type { Feature } from '@/features';\nimport type { Framework } from '@/project';\nimport { type FormattedRoute, formatRoute, routeModule } from '@/project/route';\nimport { addReactRouterPrerenderArray, enableProcessedMarkdown } from '@/codemod';\nimport { docs } from './docs';\nimport { registerReactRouterRoutes, requiresMarkdown, type SourceRef, sourceRef } from './utils';\n\n/** Astro inlines `import.meta.env` at build time, `getSecret()` reads secrets at runtime */\nconst api = ({ dynamic, ref }: SourceRef, astro: boolean) => `import { ${ref} } from '@/lib/source';\nimport { createEpubExportAPI } from 'fumadocs-epub';${astro ? \"\\nimport { getSecret } from 'astro:env/server';\" : ''}\n\nconst api = createEpubExportAPI({\n ${ref === 'source' ? 'source' : `source: ${ref}`},${dynamic ? '\\n getMarkdown: (page) => page.data.content,' : ''}\n title: 'Documentation',\n author: 'Your Team',\n description: 'Exported documentation',\n // guards the route, requests must send \\`Authorization: Bearer <secret>\\`\n secret: ${astro ? \"getSecret('EXPORT_SECRET')\" : 'process.env.EXPORT_SECRET'},\n});\n`;\n\nconst templates = (framework: Framework, route: FormattedRoute, src: SourceRef) =>\n routeModule(framework, route, {\n imports: api(src, framework === 'astro'),\n body: 'api.GET(request)',\n request: true,\n revalidate: true,\n });\n\nexport const epub: Feature = {\n id: 'epub',\n title: 'EPUB Export',\n description: 'a route to export docs as an EPUB file, protected by EXPORT_SECRET',\n requires: [docs],\n supports: (project) =>\n project.static ? 'the export route needs a server at runtime' : requiresMarkdown(project),\n async apply(ctx) {\n const { baseDir, source, framework } = ctx.project;\n ctx.addDependencies({ 'fumadocs-epub': null });\n\n if (source.collections) {\n await ctx.source(source.collections, (file) => {\n if (!enableProcessedMarkdown(file))\n throw new Error(`cannot enable \\`includeProcessedMarkdown\\` in ${source.collections}`);\n });\n }\n\n const route = formatRoute({ segments: ['export/epub'] }, framework, null);\n await ctx.write(\n path.join(baseDir, route.file),\n templates(framework, route, sourceRef(ctx.project.source.dynamic)),\n );\n if (framework === 'react-router') {\n await registerReactRouterRoutes(ctx, [route]);\n // the route needs a secret at runtime\n await ctx.source('react-router.config.ts', (file) => {\n addReactRouterPrerenderArray(file, 'excluded', [`/${route.path}`]);\n });\n }\n\n ctx.env('EXPORT_SECRET', '');\n ctx.note(\n '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sGACF;CACF;AACF"}
|
package/dist/features/ai.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { r as Feature } from "../index-
|
|
2
|
-
//#region src/features/ai.d.ts
|
|
1
|
+
import { r as Feature } from "../index-CAIqrY1S.js";
|
|
3
2
|
declare const providers: {
|
|
4
3
|
openrouter: {
|
|
5
4
|
label: string;
|
|
@@ -21,5 +20,5 @@ export type AIProvider = keyof typeof providers;
|
|
|
21
20
|
export declare const ai: Feature<{
|
|
22
21
|
provider: AIProvider;
|
|
23
22
|
}>;
|
|
24
|
-
|
|
23
|
+
export {};
|
|
25
24
|
//# sourceMappingURL=ai.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.d.ts","names":[],"sources":["../../src/features/ai.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ai.d.ts","names":[],"sources":["../../src/features/ai.ts"],"mappings":";cAMM;EACJ;IAAc;IAAiB;IAA+B;;EAC9D;IACE;IACA;IACA;;EAEF;IAAU;IAAoB;IAA0B;;;YAG9C,0BAA0B;qBAEzB,IAAI;EAAU,UAAU"}
|
package/dist/features/ai.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { ai };
|
|
1
|
+
export { t as ai } from "../ai-CvrtLYh1.js";
|
package/dist/features/all.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all.d.ts","names":[],"sources":["../../src/features/all.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"all.d.ts","names":[],"sources":["../../src/features/all.ts"],"mappings":";qBAYa,UAAU"}
|
package/dist/features/all.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { features };
|
|
1
|
+
export { t as features } from "../all-bAINnjNQ.js";
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { a as Project } from "../../index-
|
|
2
|
-
import { r as Feature } from "../../index-
|
|
3
|
-
//#region src/features/docs/index.d.ts
|
|
1
|
+
import { a as Project } from "../../index-DCJbgkgf.js";
|
|
2
|
+
import { r as Feature } from "../../index-CAIqrY1S.js";
|
|
4
3
|
export declare const docs: Feature<{
|
|
5
4
|
i18n: boolean;
|
|
6
5
|
}>;
|
|
7
6
|
/** the Next.js proxy (middleware) file of the project, relative to cwd */
|
|
8
7
|
export declare function findNextProxy({ cwd, baseDir }: Project): Promise<string | undefined>;
|
|
9
|
-
//#endregion
|
|
10
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/features/docs/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/features/docs/index.ts"],"mappings":";;qBA4Ba,MAAM;EAAU;;;wBAgHP,gBAAgB,KAAK,WAAW,UAAO"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { docs, findNextProxy };
|
|
1
|
+
export { t as docs, n as findNextProxy } from "../../docs---dy-BSm.js";
|
package/dist/features/epub.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epub.d.ts","names":[],"sources":["../../src/features/epub.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"epub.d.ts","names":[],"sources":["../../src/features/epub.ts"],"mappings":";qBA8Ba,MAAM"}
|
package/dist/features/epub.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { epub };
|
|
1
|
+
export { t as epub } from "../epub-BKvZ4ppz.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feedback.d.ts","names":[],"sources":["../../src/features/feedback.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"feedback.d.ts","names":[],"sources":["../../src/features/feedback.ts"],"mappings":";qBAMa,UAAU"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { feedback };
|
|
1
|
+
export { t as feedback } from "../feedback-7u1-eklc.js";
|
package/dist/features/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as FeatureIO, c as RunOptions, i as FeatureContext, l as SelectOption, n as ConfirmOption, o as FeatureOption, r as Feature, s as PackageJson, t as AnyFeature, u as runFeature } from "../index-
|
|
1
|
+
import { a as FeatureIO, c as RunOptions, i as FeatureContext, l as SelectOption, n as ConfirmOption, o as FeatureOption, r as Feature, s as PackageJson, t as AnyFeature, u as runFeature } from "../index-CAIqrY1S.js";
|
|
2
2
|
export { AnyFeature, ConfirmOption, Feature, FeatureContext, FeatureIO, FeatureOption, PackageJson, RunOptions, SelectOption, runFeature };
|
package/dist/features/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { runFeature };
|
|
1
|
+
export { t as runFeature } from "../features-C_FG2WD0.js";
|
package/dist/features/lint.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { r as Feature } from "../index-
|
|
2
|
-
//#region src/features/lint.d.ts
|
|
1
|
+
import { r as Feature } from "../index-CAIqrY1S.js";
|
|
3
2
|
export declare const lint: Feature<{
|
|
4
3
|
linter: 'eslint' | 'biome' | 'oxlint';
|
|
5
4
|
}>;
|
|
6
|
-
//#endregion
|
|
7
5
|
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","names":[],"sources":["../../src/features/lint.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"lint.d.ts","names":[],"sources":["../../src/features/lint.ts"],"mappings":";qBAwEa,MAAM;EAAU"}
|
package/dist/features/lint.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { lint };
|
|
1
|
+
export { t as lint } from "../lint-AC2ClOfa.js";
|
package/dist/features/llms.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as FeatureContext, r as Feature } from "../index-
|
|
3
|
-
import {
|
|
4
|
-
//#region src/features/llms.d.ts
|
|
1
|
+
import { r as I18nInfo, t as Framework } from "../index-DCJbgkgf.js";
|
|
2
|
+
import { i as FeatureContext, r as Feature } from "../index-CAIqrY1S.js";
|
|
3
|
+
import { d as FormattedRoute, t as SourceRef } from "../utils-DlGz_4va.js";
|
|
5
4
|
/** runtime content sources expose raw Markdown as `page.data.content`, Fumadocs MDX processes it */
|
|
6
5
|
export declare const docsLlms: ({ dynamic, ref }: SourceRef) => string;
|
|
7
6
|
/** the Markdown URL of a page, `/llms.mdx/docs/<slugs>/content.md` */
|
|
@@ -13,8 +12,8 @@ interface Routes {
|
|
|
13
12
|
full: FormattedRoute;
|
|
14
13
|
markdown: FormattedRoute;
|
|
15
14
|
}
|
|
16
|
-
export declare function templates(framework:
|
|
17
|
-
export declare function llmsRoutes(framework:
|
|
15
|
+
export declare function templates(framework: Framework, routes: Routes, i18n: I18nInfo | null, src: SourceRef): [route: FormattedRoute, content: string][];
|
|
16
|
+
export declare function llmsRoutes(framework: Framework, i18n: I18nInfo | null, docsRoute: string, contentRoute: string): Routes;
|
|
18
17
|
export declare const llms: Feature;
|
|
19
18
|
/** `/docs/*.md` serves the Markdown of a page, like TanStack Start's `.md` route */
|
|
20
19
|
export declare const markdownRewrite: (docsRoute: string, markdown: FormattedRoute, i18n: boolean) => {
|
|
@@ -23,5 +22,5 @@ export declare const markdownRewrite: (docsRoute: string, markdown: FormattedRou
|
|
|
23
22
|
};
|
|
24
23
|
/** routes under `[lang]` need the i18n middleware to resolve the locale */
|
|
25
24
|
export declare function extendNextProxy(ctx: FeatureContext, route: FormattedRoute): Promise<void>;
|
|
26
|
-
|
|
25
|
+
export {};
|
|
27
26
|
//# sourceMappingURL=llms.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llms.d.ts","names":[],"sources":["../../src/features/llms.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"llms.d.ts","names":[],"sources":["../../src/features/llms.ts"],"mappings":";;;;qBA8Ba,aAAQ,SAAA,OAAsB;;qBAQ9B,cAAW;;qBAUX,sBAAmB;UAgCtB;EACR,OAAO;EACP,MAAM;EACN,UAAU;;wBAsFI,UACd,WAAW,WACX,QAAQ,QACR,MAAM,iBACN,KAAK,aACH,OAAO,gBAAgB;wBAgBX,WACd,WAAW,WACX,MAAM,iBACN,mBACA,uBACC;qBAmBU,MAAM;;qBAgEN,kBAAe,mBAAqB,UAAY,gBAAc;EACzE;EACA;;;wBA2BoB,gBAAgB,KAAK,gBAAgB,OAAO,iBAAc"}
|
package/dist/features/llms.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { docsLlms, extendNextProxy, llms, llmsRoutes, markdownRewrite, markdownUrl, tanstackMarkdownUrl, templates };
|
|
1
|
+
export { t as docsLlms, n as extendNextProxy, r as llms, i as llmsRoutes, a as markdownRewrite, o as markdownUrl, s as tanstackMarkdownUrl, c as templates } from "../llms-Cge1uefC.js";
|
package/dist/features/mcp.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as Feature } from "../index-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const mcpRoute: (framework: ReactFramework) => FormattedRoute;
|
|
1
|
+
import { t as Framework } from "../index-DCJbgkgf.js";
|
|
2
|
+
import { r as Feature } from "../index-CAIqrY1S.js";
|
|
3
|
+
import { d as FormattedRoute, t as SourceRef } from "../utils-DlGz_4va.js";
|
|
4
|
+
export declare const templates: (framework: Framework, route: FormattedRoute, src: SourceRef) => string;
|
|
5
|
+
export declare const mcpRoute: (framework: Framework) => FormattedRoute;
|
|
7
6
|
export declare const mcp: Feature;
|
|
8
|
-
//#endregion
|
|
9
7
|
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","names":[],"sources":["../../src/features/mcp.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","names":[],"sources":["../../src/features/mcp.ts"],"mappings":";;;qBA4Ba,YAAS,WAAe,WAAS,OAAS,gBAAc,KAAO;qBAQ/D,WAAQ,WAAe,cAAS;qBAGhC,KAAK"}
|
package/dist/features/mcp.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { mcp, mcpRoute, templates };
|
|
1
|
+
export { t as mcp, n as mcpRoute, r as templates } from "../mcp-BVpVFl6G.js";
|
package/dist/features/og.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { r as Feature } from "../index-
|
|
2
|
-
//#region src/features/og.d.ts
|
|
1
|
+
import { r as Feature } from "../index-CAIqrY1S.js";
|
|
3
2
|
type Engine = 'takumi' | 'next-og';
|
|
4
3
|
export declare const og: Feature<{
|
|
5
4
|
engine: Engine;
|
|
6
5
|
}>;
|
|
7
|
-
|
|
6
|
+
export {};
|
|
8
7
|
//# sourceMappingURL=og.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"og.d.ts","names":[],"sources":["../../src/features/og.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"og.d.ts","names":[],"sources":["../../src/features/og.ts"],"mappings":";KAoBK;qBAiHQ,IAAI;EAAU,QAAQ"}
|
package/dist/features/og.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { og };
|
|
1
|
+
export { t as og } from "../og-DuPd9kNq.js";
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { o as
|
|
2
|
-
import { r as Feature } from "../index-
|
|
3
|
-
import {
|
|
4
|
-
//#region src/features/search.d.ts
|
|
1
|
+
import { o as SourceInfo, t as Framework } from "../index-DCJbgkgf.js";
|
|
2
|
+
import { r as Feature } from "../index-CAIqrY1S.js";
|
|
3
|
+
import { d as FormattedRoute, t as SourceRef } from "../utils-DlGz_4va.js";
|
|
5
4
|
/** how client code reads public env variables */
|
|
6
5
|
interface Env {
|
|
7
6
|
prefix: string;
|
|
8
7
|
read: string;
|
|
9
8
|
}
|
|
10
|
-
/** `scripts/sync-content.ts`, syncing the search indexes pre-rendered to `output
|
|
9
|
+
/** `scripts/sync-content.ts`, syncing the search indexes pre-rendered to `output`, the first match of a glob pattern (Next.js) */
|
|
11
10
|
export declare const syncScript: (output: string, imports: string, body: string) => string;
|
|
12
11
|
declare const providers: {
|
|
13
12
|
'orama-cloud': {
|
|
@@ -105,24 +104,25 @@ declare const providers: {
|
|
|
105
104
|
'react-router': string;
|
|
106
105
|
'tanstack-start': string;
|
|
107
106
|
waku: string;
|
|
107
|
+
astro: string;
|
|
108
108
|
};
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
111
|
export type SearchProvider = keyof typeof providers;
|
|
112
112
|
/** pre-rendered on build to export the search indexes */
|
|
113
|
-
export declare const staticJson: (framework:
|
|
114
|
-
export declare const staticRoute: (framework:
|
|
113
|
+
export declare const staticJson: (framework: Framework) => FormattedRoute;
|
|
114
|
+
export declare const staticRoute: (framework: Framework, head: string, documents: string) => string;
|
|
115
115
|
/** where `static.json` is pre-rendered on build, `config` is the Vite config of TanStack Start */
|
|
116
|
-
export declare function staticOutput(framework:
|
|
116
|
+
export declare function staticOutput(framework: Framework, config?: string, isStatic?: boolean): string;
|
|
117
117
|
/** runs the sync script after build */
|
|
118
118
|
export declare const syncCommand = "node --env-file-if-exists=.env.local scripts/sync-content.ts";
|
|
119
119
|
/** the files written by a provider, relative to the project, `output` is where `static.json` is pre-rendered */
|
|
120
|
-
export declare function templates(name: SearchProvider, framework:
|
|
120
|
+
export declare function templates(name: SearchProvider, framework: Framework, { baseDir, source }: {
|
|
121
121
|
baseDir: string;
|
|
122
122
|
source: Pick<SourceInfo, 'dynamic' | 'async'>;
|
|
123
123
|
}, output: string): [file: string, content: string][];
|
|
124
124
|
export declare const search: Feature<{
|
|
125
125
|
provider: SearchProvider;
|
|
126
126
|
}>;
|
|
127
|
-
|
|
127
|
+
export {};
|
|
128
128
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","names":["_$__project_route0.FormattedRoute"],"sources":["../../src/features/search.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.d.ts","names":["_$__project_route0.FormattedRoute"],"sources":["../../src/features/search.ts"],"mappings":";;;;UAwBU;EACR;EACA;;;qBAwEW,aAAU,gBACP,iBACC;cA2CX;;;;;MAIc;;;;;;;;;;;MATiB;;;;;;;MAwDjB;;;;;;;;;;;MAxDiB;;;;;;;MAqGjB;;;;;;;;;;;MArGiB;;;;;;;MAqJjB;MAAiB;;;;;;;;;;;MArJA;;;;;;;MAqMjB;;;;;;;;;;;MArMiB;;;;;;;;;;;YAmRzB,8BAA8B;;qBAG7B,aAAU,WAAe,cAAAA;qBAGzB,cAAW,WAAe,WAAS,cAAc;;wBAS9C,aAAa,WAAW,WAAW,iBAAa;;qBAmBnD;;wBAGG,UACd,MAAM,gBACN,WAAW,aACT,SAAS;EAAY;EAAiB,QAAQ,KAAK;GACrD,kBACE,cAAc;qBAkBL,QAAQ;EAAU,UAAU"}
|
package/dist/features/search.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { search, staticJson, staticOutput, staticRoute, syncCommand, syncScript, templates };
|
|
1
|
+
export { t as search, n as staticJson, r as staticOutput, i as staticRoute, a as syncCommand, o as syncScript, s as templates } from "../search-B44II4bM.js";
|
package/dist/features/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as posix, c as
|
|
2
|
-
export { SourceRef, addExport, addPageUrl, findSource, posix,
|
|
1
|
+
import { a as posix, c as scripts, i as findSource, l as sharedRoute, n as addExport, o as registerReactRouterRoutes, r as addPageUrl, s as requiresMarkdown, t as SourceRef, u as sourceRef } from "../utils-DlGz_4va.js";
|
|
2
|
+
export { SourceRef, addExport, addPageUrl, findSource, posix, registerReactRouterRoutes, requiresMarkdown, scripts, sharedRoute, sourceRef };
|
package/dist/features/utils.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { addExport, addPageUrl, findSource, posix, reactFramework, reactOnly, registerReactRouterRoutes, requiresMarkdown, scripts, sharedRoute, sourceRef };
|
|
1
|
+
export { t as addExport, n as addPageUrl, r as findSource, i as posix, a as registerReactRouterRoutes, o as requiresMarkdown, s as scripts, c as sharedRoute, l as sourceRef } from "../utils-Btt-BJ53.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { r as Feature } from "../index-
|
|
2
|
-
//#region src/features/webmcp.d.ts
|
|
1
|
+
import { r as Feature } from "../index-CAIqrY1S.js";
|
|
3
2
|
interface Input {
|
|
4
3
|
static: boolean;
|
|
5
4
|
i18n: boolean;
|
|
@@ -8,5 +7,5 @@ interface Input {
|
|
|
8
7
|
}
|
|
9
8
|
export declare const component: ({ static: isStatic, i18n, tanstack }: Input) => string;
|
|
10
9
|
export declare const webmcp: Feature;
|
|
11
|
-
|
|
10
|
+
export {};
|
|
12
11
|
//# sourceMappingURL=webmcp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webmcp.d.ts","names":[],"sources":["../../src/features/webmcp.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"webmcp.d.ts","names":[],"sources":["../../src/features/webmcp.ts"],"mappings":";UAMU;EACR;EACA;;EAEA;;qBAGW,cAAS,QAAA,UAAA,MAAA,YAA0C;qBAuGnD,QAAQ"}
|
package/dist/features/webmcp.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { component, webmcp };
|
|
1
|
+
export { t as component, n as webmcp } from "../webmcp-lY3_RsR3.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { g as createSourceFile } from "./codemod-
|
|
2
|
-
import { t as exists } from "./fs-
|
|
3
|
-
import { t as FumadocsComponentInstaller } from "./installer-
|
|
1
|
+
import { g as createSourceFile } from "./codemod-Wc9nRqrw.js";
|
|
2
|
+
import { t as exists } from "./fs-Dqr1VJSD.js";
|
|
3
|
+
import { t as FumadocsComponentInstaller } from "./installer-CEOV0fBv.js";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { x } from "tinyexec";
|
|
7
|
-
|
|
7
|
+
// src/features/index.ts
|
|
8
8
|
async function runFeature(feature, options, { project, connector, io, versions }) {
|
|
9
9
|
for (const dep of feature.requires ?? []) if (dep.detect && !await dep.detect(project)) throw new Error(`"${feature.id}" requires "${dep.id}", run \`fumadocs feature ${dep.id}\` first.`);
|
|
10
10
|
const supported = feature.supports?.(project) ?? true;
|
|
@@ -120,7 +120,6 @@ async function installDependencies(project, deps, devDeps, io, versions = {}) {
|
|
|
120
120
|
await fs.writeFile(file, `${JSON.stringify(json, null, 2)}\n`);
|
|
121
121
|
io.log("updated package.json");
|
|
122
122
|
}
|
|
123
|
-
//#endregion
|
|
124
123
|
export { runFeature as t };
|
|
125
124
|
|
|
126
|
-
//# sourceMappingURL=features-
|
|
125
|
+
//# sourceMappingURL=features-C_FG2WD0.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features-Do6x9Tsz.js","names":[],"sources":["../src/features/index.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { x } from 'tinyexec';\nimport type { RegistryConnector } from 'fuma-cli/registry/connector';\nimport type { Project } from '@/project';\nimport { createSourceFile, type SourceFile } from '@/codemod';\nimport { FumadocsComponentInstaller } from '@/registry/installer';\nimport { exists } from '@/utils/fs';\n\nexport interface SelectOption<T> {\n message: string;\n choices: { value: T; label: string; hint?: string }[];\n}\n\nexport interface ConfirmOption {\n message: string;\n initialValue?: boolean;\n}\n\nexport type FeatureOption<T> = [T] extends [boolean] ? ConfirmOption : SelectOption<T>;\n\nexport interface Feature<Options extends object = Record<never, never>> {\n id: string;\n title: string;\n description: string;\n options?: { [K in keyof Options]: FeatureOption<Options[K]> };\n /** features that must be applied first */\n requires?: AnyFeature[];\n /** whether the feature is already applied to the project */\n detect?: (project: Project) => Promise<boolean>;\n /** @returns `true` if supported, otherwise the reason */\n supports?: (project: Project) => true | string;\n apply(ctx: FeatureContext, options: Options): Promise<void>;\n}\n\nexport type AnyFeature = Omit<Feature<Record<string, unknown>>, 'options'> & {\n options?: Record<string, SelectOption<unknown> | ConfirmOption>;\n};\n\nexport interface PackageJson {\n scripts?: Record<string, string>;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n}\n\nexport interface FeatureContext {\n project: Project;\n /** write a file (relative to project root), asks before overwriting */\n write: (file: string, content: string) => Promise<void>;\n /** edit a file with codemods, `false` if the file doesn't exist */\n source: (file: string, edit: (file: SourceFile) => void) => Promise<boolean>;\n /** append lines to a text file, skip lines already present */\n append: (file: string, lines: string[]) => Promise<void>;\n remove: (file: string) => Promise<void>;\n packageJson: (edit: (data: PackageJson) => void) => Promise<void>;\n /** install a registry component */\n install: (name: string, subRegistry?: string) => Promise<void>;\n /** `null` to install the latest version */\n addDependencies: (deps: Record<string, string | null>, dev?: boolean) => void;\n env: (key: string, value: string) => void;\n /** instructions to show after the feature is applied */\n note: (text: string) => void;\n log: (message: string) => void;\n}\n\nexport interface FeatureIO {\n log: (message: string) => void;\n confirmOverwrite: (file: string) => Promise<boolean>;\n /** run package manager to install dependencies, otherwise only write them into `package.json` */\n installDependencies: boolean;\n}\n\nexport interface RunOptions {\n project: Project;\n connector: RegistryConnector;\n io: FeatureIO;\n /** preferred versions of dependencies, when a feature doesn't specify one */\n versions?: Record<string, string>;\n}\n\nexport async function runFeature<O extends object>(\n feature: Omit<Feature<O>, 'options'>,\n options: O,\n { project, connector, io, versions }: RunOptions,\n): Promise<{ notes: string[] }> {\n for (const dep of feature.requires ?? []) {\n if (dep.detect && !(await dep.detect(project)))\n throw new Error(\n `\"${feature.id}\" requires \"${dep.id}\", run \\`fumadocs feature ${dep.id}\\` first.`,\n );\n }\n const supported = feature.supports?.(project) ?? true;\n if (supported !== true) throw new Error(`\"${feature.id}\" is unavailable: ${supported}`);\n\n const { cwd } = project;\n const deps: Record<string, string | null> = {};\n const devDeps: Record<string, string | null> = {};\n const env: string[] = [];\n const notes: string[] = [];\n const installer = new FumadocsComponentInstaller(connector, project.config, cwd, {\n confirmFileOverride: (file) => io.confirmOverwrite(path.relative(cwd, file.output)),\n onFileWritten: (file) => io.log(`installed ${path.relative(cwd, file.output)}`),\n });\n\n const ctx: FeatureContext = {\n project,\n log: io.log,\n note: (text) => notes.push(text),\n env: (key, value) => env.push(`${key}=${value}`),\n addDependencies(input, dev) {\n Object.assign(dev ? devDeps : deps, input);\n },\n async write(file, content) {\n const target = path.join(cwd, file);\n const current = await fs.readFile(target, 'utf-8').catch(() => null);\n if (current !== null) {\n if (current.trim() === content.trim()) return;\n if (!(await io.confirmOverwrite(file))) return;\n }\n await fs.mkdir(path.dirname(target), { recursive: true });\n await fs.writeFile(target, content);\n io.log(`${current === null ? 'created' : 'updated'} ${file}`);\n },\n async source(file, edit) {\n const target = path.join(cwd, file);\n if (!(await exists(target))) return false;\n const source = await createSourceFile(target);\n edit(source);\n if (source.s.hasChanged()) {\n await source.save();\n io.log(`updated ${file}`);\n }\n return true;\n },\n async append(file, lines) {\n const target = path.join(cwd, file);\n const current = await fs.readFile(target, 'utf-8').catch(() => '');\n const missing = lines.filter((line) => !current.includes(line));\n if (missing.length === 0) return;\n const separator = current.length === 0 || current.endsWith('\\n') ? '' : '\\n';\n await fs.mkdir(path.dirname(target), { recursive: true });\n await fs.writeFile(target, `${current}${separator}${missing.join('\\n')}\\n`);\n io.log(`updated ${file}`);\n },\n async remove(file) {\n await fs.rm(path.join(cwd, file), { force: true });\n io.log(`removed ${file}`);\n },\n async packageJson(edit) {\n const target = path.join(cwd, 'package.json');\n const data = JSON.parse(await fs.readFile(target, 'utf-8'));\n edit(data);\n await fs.writeFile(target, `${JSON.stringify(data, null, 2)}\\n`);\n io.log('updated package.json');\n },\n async install(name, subRegistry) {\n const result = await installer.install(name, subRegistry);\n const manager = await result.deps();\n Object.assign(deps, manager.required);\n Object.assign(devDeps, manager.requiredDev);\n },\n };\n\n await feature.apply(ctx, options);\n\n if (env.length > 0) await ctx.append('.env.local', env);\n await installDependencies(project, deps, devDeps, io, versions);\n return { notes };\n}\n\nasync function installDependencies(\n project: Project,\n deps: Record<string, string | null>,\n devDeps: Record<string, string | null>,\n io: FeatureIO,\n versions: Record<string, string> = {},\n) {\n const { dependencies = {}, devDependencies = {} } = project.packageJson;\n const filter = (input: Record<string, string | null>) =>\n Object.entries(input).filter(([name]) => !(name in dependencies) && !(name in devDependencies));\n const missing = filter(deps);\n const missingDev = filter(devDeps);\n if (missing.length === 0 && missingDev.length === 0) return;\n\n if (io.installDependencies) {\n const pm = project.packageManager;\n const run = async (flags: string[], entries: [string, string | null][]) => {\n if (entries.length === 0) return;\n const args = [\n 'add',\n ...flags,\n ...entries.map(([name, version]) => (version ? `${name}@${version}` : name)),\n ];\n io.log(`${pm} ${args.join(' ')}`);\n await x(pm, args, {\n nodeOptions: { cwd: project.cwd, stdio: 'inherit' },\n throwOnError: true,\n });\n };\n await run([], missing);\n await run(['-D'], missingDev);\n return;\n }\n\n const file = path.join(project.cwd, 'package.json');\n const json = JSON.parse(await fs.readFile(file, 'utf-8'));\n const write = (field: string, entries: [string, string | null][]) => {\n if (entries.length === 0) return;\n const target = (json[field] ??= {});\n for (const [name, version] of entries) target[name] = version ?? versions[name] ?? 'latest';\n };\n write('dependencies', missing);\n write('devDependencies', missingDev);\n await fs.writeFile(file, `${JSON.stringify(json, null, 2)}\\n`);\n io.log('updated package.json');\n}\n"],"mappings":";;;;;;;AAgFA,eAAsB,WACpB,SACA,SACA,EAAE,SAAS,WAAW,IAAI,YACI;CAC9B,KAAK,MAAM,OAAO,QAAQ,YAAY,CAAC,GACrC,IAAI,IAAI,UAAU,CAAE,MAAM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QAAQ,KAAK,cAAc;CAClD,MAAM,OAAO,KAAK,MAAM,MAAM,GAAG,SAAS,MAAM,OAAO,CAAC;CACxD,MAAM,SAAS,OAAe,YAAuC;EACnE,IAAI,QAAQ,WAAW,GAAG;EAC1B,MAAM,SAAU,KAAK,WAAW,CAAC;EACjC,KAAK,MAAM,CAAC,MAAM,YAAY,SAAS,OAAO,QAAQ,WAAW,SAAS,SAAS;CACrF;CACA,MAAM,gBAAgB,OAAO;CAC7B,MAAM,mBAAmB,UAAU;CACnC,MAAM,GAAG,UAAU,MAAM,GAAG,KAAK,UAAU,MAAM,MAAM,CAAC,EAAE,GAAG;CAC7D,GAAG,IAAI,sBAAsB;AAC/B"}
|
|
1
|
+
{"version":3,"file":"features-C_FG2WD0.js","names":[],"sources":["../src/features/index.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { x } from 'tinyexec';\nimport type { RegistryConnector } from 'fuma-cli/registry/connector';\nimport type { Project } from '@/project';\nimport { createSourceFile, type SourceFile } from '@/codemod';\nimport { FumadocsComponentInstaller } from '@/registry/installer';\nimport { exists } from '@/utils/fs';\n\nexport interface SelectOption<T> {\n message: string;\n choices: { value: T; label: string; hint?: string }[];\n}\n\nexport interface ConfirmOption {\n message: string;\n initialValue?: boolean;\n}\n\nexport type FeatureOption<T> = [T] extends [boolean] ? ConfirmOption : SelectOption<T>;\n\nexport interface Feature<Options extends object = Record<never, never>> {\n id: string;\n title: string;\n description: string;\n options?: { [K in keyof Options]: FeatureOption<Options[K]> };\n /** features that must be applied first */\n requires?: AnyFeature[];\n /** whether the feature is already applied to the project */\n detect?: (project: Project) => Promise<boolean>;\n /** @returns `true` if supported, otherwise the reason */\n supports?: (project: Project) => true | string;\n apply(ctx: FeatureContext, options: Options): Promise<void>;\n}\n\nexport type AnyFeature = Omit<Feature<Record<string, unknown>>, 'options'> & {\n options?: Record<string, SelectOption<unknown> | ConfirmOption>;\n};\n\nexport interface PackageJson {\n scripts?: Record<string, string>;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n}\n\nexport interface FeatureContext {\n project: Project;\n /** write a file (relative to project root), asks before overwriting */\n write: (file: string, content: string) => Promise<void>;\n /** edit a file with codemods, `false` if the file doesn't exist */\n source: (file: string, edit: (file: SourceFile) => void) => Promise<boolean>;\n /** append lines to a text file, skip lines already present */\n append: (file: string, lines: string[]) => Promise<void>;\n remove: (file: string) => Promise<void>;\n packageJson: (edit: (data: PackageJson) => void) => Promise<void>;\n /** install a registry component */\n install: (name: string, subRegistry?: string) => Promise<void>;\n /** `null` to install the latest version */\n addDependencies: (deps: Record<string, string | null>, dev?: boolean) => void;\n env: (key: string, value: string) => void;\n /** instructions to show after the feature is applied */\n note: (text: string) => void;\n log: (message: string) => void;\n}\n\nexport interface FeatureIO {\n log: (message: string) => void;\n confirmOverwrite: (file: string) => Promise<boolean>;\n /** run package manager to install dependencies, otherwise only write them into `package.json` */\n installDependencies: boolean;\n}\n\nexport interface RunOptions {\n project: Project;\n connector: RegistryConnector;\n io: FeatureIO;\n /** preferred versions of dependencies, when a feature doesn't specify one */\n versions?: Record<string, string>;\n}\n\nexport async function runFeature<O extends object>(\n feature: Omit<Feature<O>, 'options'>,\n options: O,\n { project, connector, io, versions }: RunOptions,\n): Promise<{ notes: string[] }> {\n for (const dep of feature.requires ?? []) {\n if (dep.detect && !(await dep.detect(project)))\n throw new Error(\n `\"${feature.id}\" requires \"${dep.id}\", run \\`fumadocs feature ${dep.id}\\` first.`,\n );\n }\n const supported = feature.supports?.(project) ?? true;\n if (supported !== true) throw new Error(`\"${feature.id}\" is unavailable: ${supported}`);\n\n const { cwd } = project;\n const deps: Record<string, string | null> = {};\n const devDeps: Record<string, string | null> = {};\n const env: string[] = [];\n const notes: string[] = [];\n const installer = new FumadocsComponentInstaller(connector, project.config, cwd, {\n confirmFileOverride: (file) => io.confirmOverwrite(path.relative(cwd, file.output)),\n onFileWritten: (file) => io.log(`installed ${path.relative(cwd, file.output)}`),\n });\n\n const ctx: FeatureContext = {\n project,\n log: io.log,\n note: (text) => notes.push(text),\n env: (key, value) => env.push(`${key}=${value}`),\n addDependencies(input, dev) {\n Object.assign(dev ? devDeps : deps, input);\n },\n async write(file, content) {\n const target = path.join(cwd, file);\n const current = await fs.readFile(target, 'utf-8').catch(() => null);\n if (current !== null) {\n if (current.trim() === content.trim()) return;\n if (!(await io.confirmOverwrite(file))) return;\n }\n await fs.mkdir(path.dirname(target), { recursive: true });\n await fs.writeFile(target, content);\n io.log(`${current === null ? 'created' : 'updated'} ${file}`);\n },\n async source(file, edit) {\n const target = path.join(cwd, file);\n if (!(await exists(target))) return false;\n const source = await createSourceFile(target);\n edit(source);\n if (source.s.hasChanged()) {\n await source.save();\n io.log(`updated ${file}`);\n }\n return true;\n },\n async append(file, lines) {\n const target = path.join(cwd, file);\n const current = await fs.readFile(target, 'utf-8').catch(() => '');\n const missing = lines.filter((line) => !current.includes(line));\n if (missing.length === 0) return;\n const separator = current.length === 0 || current.endsWith('\\n') ? '' : '\\n';\n await fs.mkdir(path.dirname(target), { recursive: true });\n await fs.writeFile(target, `${current}${separator}${missing.join('\\n')}\\n`);\n io.log(`updated ${file}`);\n },\n async remove(file) {\n await fs.rm(path.join(cwd, file), { force: true });\n io.log(`removed ${file}`);\n },\n async packageJson(edit) {\n const target = path.join(cwd, 'package.json');\n const data = JSON.parse(await fs.readFile(target, 'utf-8'));\n edit(data);\n await fs.writeFile(target, `${JSON.stringify(data, null, 2)}\\n`);\n io.log('updated package.json');\n },\n async install(name, subRegistry) {\n const result = await installer.install(name, subRegistry);\n const manager = await result.deps();\n Object.assign(deps, manager.required);\n Object.assign(devDeps, manager.requiredDev);\n },\n };\n\n await feature.apply(ctx, options);\n\n if (env.length > 0) await ctx.append('.env.local', env);\n await installDependencies(project, deps, devDeps, io, versions);\n return { notes };\n}\n\nasync function installDependencies(\n project: Project,\n deps: Record<string, string | null>,\n devDeps: Record<string, string | null>,\n io: FeatureIO,\n versions: Record<string, string> = {},\n) {\n const { dependencies = {}, devDependencies = {} } = project.packageJson;\n const filter = (input: Record<string, string | null>) =>\n Object.entries(input).filter(([name]) => !(name in dependencies) && !(name in devDependencies));\n const missing = filter(deps);\n const missingDev = filter(devDeps);\n if (missing.length === 0 && missingDev.length === 0) return;\n\n if (io.installDependencies) {\n const pm = project.packageManager;\n const run = async (flags: string[], entries: [string, string | null][]) => {\n if (entries.length === 0) return;\n const args = [\n 'add',\n ...flags,\n ...entries.map(([name, version]) => (version ? `${name}@${version}` : name)),\n ];\n io.log(`${pm} ${args.join(' ')}`);\n await x(pm, args, {\n nodeOptions: { cwd: project.cwd, stdio: 'inherit' },\n throwOnError: true,\n });\n };\n await run([], missing);\n await run(['-D'], missingDev);\n return;\n }\n\n const file = path.join(project.cwd, 'package.json');\n const json = JSON.parse(await fs.readFile(file, 'utf-8'));\n const write = (field: string, entries: [string, string | null][]) => {\n if (entries.length === 0) return;\n const target = (json[field] ??= {});\n for (const [name, version] of entries) target[name] = version ?? versions[name] ?? 'latest';\n };\n write('dependencies', missing);\n write('devDependencies', missingDev);\n await fs.writeFile(file, `${JSON.stringify(json, null, 2)}\\n`);\n io.log('updated package.json');\n}\n"],"mappings":";;;;;;;AAgFA,eAAsB,WACpB,SACA,SACA,EAAE,SAAS,WAAW,IAAI,YACI;CAC9B,KAAK,MAAM,OAAO,QAAQ,YAAY,CAAC,GACrC,IAAI,IAAI,UAAU,CAAE,MAAM,IAAI,OAAO,OAAO,GAC1C,MAAM,IAAI,MACR,IAAI,QAAQ,GAAG,cAAc,IAAI,GAAG,4BAA4B,IAAI,GAAG,UACzE;CAEJ,MAAM,YAAY,QAAQ,WAAW,OAAO,KAAK;CACjD,IAAI,cAAc,MAAM,MAAM,IAAI,MAAM,IAAI,QAAQ,GAAG,oBAAoB,WAAW;CAEtF,MAAM,EAAE,QAAQ;CAChB,MAAM,OAAsC,CAAC;CAC7C,MAAM,UAAyC,CAAC;CAChD,MAAM,MAAgB,CAAC;CACvB,MAAM,QAAkB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AAG,KAAK,UAAU,MAAM,MAAM,CAAC,EAAE,GAAG;CAC7D,GAAG,IAAI,sBAAsB;AAC/B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { b as findJsxElement, h as appendJsxChildren, p as addImport } from "./codemod-
|
|
2
|
-
import { t as docs } from "./docs-
|
|
3
|
-
import { r as findSource } from "./utils-
|
|
1
|
+
import { b as findJsxElement, h as appendJsxChildren, p as addImport } from "./codemod-Wc9nRqrw.js";
|
|
2
|
+
import { t as docs } from "./docs---dy-BSm.js";
|
|
3
|
+
import { r as findSource } from "./utils-Btt-BJ53.js";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
|
|
5
|
+
// src/features/feedback.ts
|
|
6
6
|
const feedback = {
|
|
7
7
|
id: "feedback",
|
|
8
8
|
title: "Feedback",
|
|
@@ -12,7 +12,7 @@ const feedback = {
|
|
|
12
12
|
const { cwd, baseDir, info, framework, static: isStatic } = ctx.project;
|
|
13
13
|
await ctx.install("feedback");
|
|
14
14
|
const serverAction = framework === "next" || framework === "waku";
|
|
15
|
-
const page = await findSource(cwd, path.join(baseDir, info.routesDir), "<DocsPage");
|
|
15
|
+
const page = await findSource(cwd, framework === "astro" ? baseDir : path.join(baseDir, info.routesDir), "<DocsPage");
|
|
16
16
|
if (!(page !== void 0 && !(serverAction && isStatic) && await ctx.source(page, (file) => {
|
|
17
17
|
if (file.code.includes("<Feedback")) return;
|
|
18
18
|
const element = findJsxElement(file, "DocsPage");
|
|
@@ -31,7 +31,6 @@ const feedback = {
|
|
|
31
31
|
ctx.note("Handle the feedback in `onSendAction`, e.g. report it to GitHub Discussions: https://fumadocs.dev/docs/integrations/feedback.");
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
//#endregion
|
|
35
34
|
export { feedback as t };
|
|
36
35
|
|
|
37
|
-
//# sourceMappingURL=feedback-
|
|
36
|
+
//# sourceMappingURL=feedback-7u1-eklc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback-7u1-eklc.js","names":[],"sources":["../src/features/feedback.ts"],"sourcesContent":["import path from 'node:path';\nimport type { Feature } from '@/features';\nimport { addImport, appendJsxChildren, findJsxElement } from '@/codemod';\nimport { docs } from './docs';\nimport { findSource } from './utils';\n\nexport const feedback: Feature = {\n id: 'feedback',\n title: 'Feedback',\n description: 'let readers rate docs pages, with a component to send feedback',\n requires: [docs],\n async apply(ctx) {\n const { cwd, baseDir, info, framework, static: isStatic } = ctx.project;\n await ctx.install('feedback');\n\n // server actions are only available on RSC frameworks, static export has none\n const serverAction = framework === 'next' || framework === 'waku';\n // Astro renders docs pages in a React island, from its components\n const page = await findSource(\n cwd,\n framework === 'astro' ? baseDir : path.join(baseDir, info.routesDir),\n '<DocsPage',\n );\n const edited =\n page !== undefined &&\n !(serverAction && isStatic) &&\n (await ctx.source(page, (file) => {\n if (file.code.includes('<Feedback')) return;\n const element = findJsxElement(file, 'DocsPage');\n if (!element) return;\n\n appendJsxChildren(\n file,\n element,\n `<Feedback\n onSendAction={async (feedback) => {${serverAction ? \"\\n 'use server';\\n\" : ''}\n console.log(feedback);\n return {};\n }}\n/>`,\n );\n addImport(file, { from: '@/components/feedback/client', named: ['Feedback'] });\n }));\n\n if (!edited) {\n ctx.note(\n serverAction && isStatic\n ? 'Static export has no server actions, render `<Feedback />` from `@/components/feedback/client` in a client component and send the feedback to your API in `onSendAction`.'\n : 'Add `<Feedback />` from `@/components/feedback/client` to the bottom of your docs page.',\n );\n }\n ctx.note(\n 'Handle the feedback in `onSendAction`, e.g. report it to GitHub Discussions: https://fumadocs.dev/docs/integrations/feedback.',\n );\n },\n};\n"],"mappings":";;;;;AAMA,MAAa,WAAoB;CAC/B,IAAI;CACJ,OAAO;CACP,aAAa;CACb,UAAU,CAAC,IAAI;CACf,MAAM,MAAM,KAAK;EACf,MAAM,EAAE,KAAK,SAAS,MAAM,WAAW,QAAQ,aAAa,IAAI;EAChE,MAAM,IAAI,QAAQ,UAAU;EAG5B,MAAM,eAAe,cAAc,UAAU,cAAc;EAE3D,MAAM,OAAO,MAAM,WACjB,KACA,cAAc,UAAU,UAAU,KAAK,KAAK,SAAS,KAAK,SAAS,GACnE,WACF;EAsBA,IAAI,EApBF,SAAS,KAAA,KACT,EAAE,gBAAgB,aACjB,MAAM,IAAI,OAAO,OAAO,SAAS;GAChC,IAAI,KAAK,KAAK,SAAS,WAAW,GAAG;GACrC,MAAM,UAAU,eAAe,MAAM,UAAU;GAC/C,IAAI,CAAC,SAAS;GAEd,kBACE,MACA,SACA;uCAC6B,eAAe,0BAA0B,GAAG;;;;GAK3E;GACA,UAAU,MAAM;IAAE,MAAM;IAAgC,OAAO,CAAC,UAAU;GAAE,CAAC;EAC/E,CAAC,IAGD,IAAI,KACF,gBAAgB,WACZ,8KACA,yFACN;EAEF,IAAI,KACF,+HACF;CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
|
-
|
|
2
|
+
// src/utils/fs.ts
|
|
3
3
|
async function exists(pathLike) {
|
|
4
4
|
try {
|
|
5
5
|
await fs.access(pathLike);
|
|
@@ -8,7 +8,6 @@ async function exists(pathLike) {
|
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
//#endregion
|
|
12
11
|
export { exists as t };
|
|
13
12
|
|
|
14
|
-
//# sourceMappingURL=fs-
|
|
13
|
+
//# sourceMappingURL=fs-Dqr1VJSD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-
|
|
1
|
+
{"version":3,"file":"fs-Dqr1VJSD.js","names":[],"sources":["../src/utils/fs.ts"],"sourcesContent":["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"],"mappings":";;AAEA,eAAsB,OAAO,UAAoC;CAC/D,IAAI;EACF,MAAM,GAAG,OAAO,QAAQ;EACxB,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { p as SourceFile } from "./index-
|
|
2
|
-
import { a as Project } from "./index-
|
|
1
|
+
import { p as SourceFile } from "./index-w9FHKPPs.js";
|
|
2
|
+
import { a as Project } from "./index-DCJbgkgf.js";
|
|
3
3
|
import { RegistryConnector } from "fuma-cli/registry/connector";
|
|
4
|
-
//#region src/features/index.d.ts
|
|
5
4
|
interface SelectOption<T> {
|
|
6
5
|
message: string;
|
|
7
6
|
choices: {
|
|
@@ -71,6 +70,5 @@ interface RunOptions {
|
|
|
71
70
|
declare function runFeature<O extends object>(feature: Omit<Feature<O>, 'options'>, options: O, { project, connector, io, versions }: RunOptions): Promise<{
|
|
72
71
|
notes: string[];
|
|
73
72
|
}>;
|
|
74
|
-
//#endregion
|
|
75
73
|
export { FeatureIO as a, RunOptions as c, FeatureContext as i, SelectOption as l, ConfirmOption as n, FeatureOption as o, Feature as r, PackageJson as s, AnyFeature as t, runFeature as u };
|
|
76
|
-
//# sourceMappingURL=index-
|
|
74
|
+
//# sourceMappingURL=index-CAIqrY1S.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CAIqrY1S.d.ts","names":[],"sources":["../src/features/index.ts"],"mappings":";;;UASiB,aAAa;EAC5B;EACA;IAAW,OAAO;IAAG;IAAe;;;UAGrB;EACf;EACA;;KAGU,cAAc,MAAM,uBAAuB,gBAAgB,aAAa;UAEnE,QAAQ,yBAAyB;EAChD;EACA;EACA;EACA,aAAa,WAAW,UAAU,cAAc,QAAQ;;EAExD,WAAW;;EAEX,UAAU,SAAS,YAAY;;EAE/B,YAAY,SAAS;EACrB,MAAM,KAAK,gBAAgB,SAAS,UAAU;;KAGpC,aAAa,KAAK,QAAQ;EACpC,UAAU,eAAe,wBAAwB;;UAGlC;EACf,UAAU;EACV,eAAe;EACf,kBAAkB;;UAGH;EACf,SAAS;;EAET,QAAQ,cAAc,oBAAoB;;EAE1C,SAAS,cAAc,OAAO,MAAM,wBAAwB;;EAE5D,SAAS,cAAc,oBAAoB;EAC3C,SAAS,iBAAiB;EAC1B,cAAc,OAAO,MAAM,yBAAyB;;EAEpD,UAAU,cAAc,yBAAyB;;EAEjD,kBAAkB,MAAM,+BAA+B;EACvD,MAAM,aAAa;;EAEnB,OAAO;EACP,MAAM;;UAGS;EACf,MAAM;EACN,mBAAmB,iBAAiB;;EAEpC;;UAGe;EACf,SAAS;EACT,WAAW;EACX,IAAI;;EAEJ,WAAW;;iBAGS,WAAW,kBAC/B,SAAS,KAAK,QAAQ,gBACtB,SAAS,KACP,SAAS,WAAW,IAAI,YAAY,aACrC;EAAU"}
|