doccupine 0.0.49 → 0.0.51
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/LICENSE +2 -2
- package/README.md +88 -22
- package/dist/index.d.ts +2 -1
- package/dist/index.js +173 -404
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +48 -0
- package/dist/templates/components/Docs.d.ts +1 -1
- package/dist/templates/components/Docs.js +1 -0
- package/dist/templates/components/layout/Button.d.ts +1 -1
- package/dist/templates/components/layout/Button.js +6 -20
- package/dist/templates/components/layout/Icon.d.ts +1 -1
- package/dist/templates/components/layout/Icon.js +4 -2
- package/dist/templates/components/layout/Steps.d.ts +1 -0
- package/dist/templates/components/layout/Steps.js +114 -0
- package/dist/templates/eslint.config.d.ts +1 -1
- package/dist/templates/eslint.config.js +1 -1
- package/dist/templates/mdx/deployment.mdx.d.ts +1 -1
- package/dist/templates/mdx/deployment.mdx.js +16 -21
- package/dist/templates/package.js +2 -2
- package/package.json +8 -5
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import chalk from "chalk";
|
|
|
9
9
|
import prompts from "prompts";
|
|
10
10
|
import { envExampleTemplate } from "./templates/env.example.js";
|
|
11
11
|
import { gitignoreTemplate } from "./templates/gitignore.js";
|
|
12
|
-
import {
|
|
12
|
+
import { eslintConfigTemplate } from "./templates/eslint.config.js";
|
|
13
13
|
import { nextConfigTemplate } from "./templates/next.config.js";
|
|
14
14
|
import { packageJsonTemplate } from "./templates/package.js";
|
|
15
15
|
import { proxyTemplate } from "./templates/proxy.js";
|
|
@@ -46,7 +46,7 @@ import { iconTemplate } from "./templates/components/layout/Icon.js";
|
|
|
46
46
|
import { pictogramsTemplate } from "./templates/components/layout/Pictograms.js";
|
|
47
47
|
import { sharedStyledTemplate } from "./templates/components/layout/SharedStyles.js";
|
|
48
48
|
import { staticLinksTemplate } from "./templates/components/layout/StaticLinks.js";
|
|
49
|
-
import { stepsTemplate } from "./templates/components/layout/
|
|
49
|
+
import { stepsTemplate } from "./templates/components/layout/Steps.js";
|
|
50
50
|
import { tabsTemplate } from "./templates/components/layout/Tabs.js";
|
|
51
51
|
import { themeToggleTemplate } from "./templates/components/layout/ThemeToggle.js";
|
|
52
52
|
import { typographyTemplate } from "./templates/components/layout/Typography.js";
|
|
@@ -86,6 +86,34 @@ import { stepsMdxTemplate } from "./templates/mdx/steps.mdx.js";
|
|
|
86
86
|
import { tabsMdxTemplate } from "./templates/mdx/tabs.mdx.js";
|
|
87
87
|
import { themeMdxTemplate } from "./templates/mdx/theme.mdx.js";
|
|
88
88
|
import { updateMdxTemplate } from "./templates/mdx/update.mdx.js";
|
|
89
|
+
async function findAvailablePort(startPort) {
|
|
90
|
+
const net = await import("net");
|
|
91
|
+
return new Promise((resolve) => {
|
|
92
|
+
const server = net.createServer();
|
|
93
|
+
server.listen(startPort, () => {
|
|
94
|
+
server.close(() => resolve(startPort));
|
|
95
|
+
});
|
|
96
|
+
server.on("error", () => {
|
|
97
|
+
resolve(findAvailablePort(startPort + 1));
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export function generateSlug(filePath) {
|
|
102
|
+
if (filePath === "index.mdx" || filePath === "./index.mdx") {
|
|
103
|
+
return "";
|
|
104
|
+
}
|
|
105
|
+
return filePath
|
|
106
|
+
.replace(/\.mdx$/, "")
|
|
107
|
+
.replace(/\\/g, "/")
|
|
108
|
+
.replace(/[^a-zA-Z0-9\/\-_]/g, "-")
|
|
109
|
+
.toLowerCase();
|
|
110
|
+
}
|
|
111
|
+
export function escapeTemplateContent(content) {
|
|
112
|
+
return content
|
|
113
|
+
.replace(/\\/g, "\\\\")
|
|
114
|
+
.replace(/`/g, "\\`")
|
|
115
|
+
.replace(/\$\{/g, "\\${");
|
|
116
|
+
}
|
|
89
117
|
const __filename = fileURLToPath(import.meta.url);
|
|
90
118
|
const __dirname = path.dirname(__filename);
|
|
91
119
|
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
|
|
@@ -134,6 +162,10 @@ class ConfigManager {
|
|
|
134
162
|
},
|
|
135
163
|
];
|
|
136
164
|
const { watchDir, outputDir } = (await prompts(questions));
|
|
165
|
+
if (!watchDir || !outputDir) {
|
|
166
|
+
console.log(chalk.yellow("\n⚠️ Setup cancelled."));
|
|
167
|
+
process.exit(0);
|
|
168
|
+
}
|
|
137
169
|
return {
|
|
138
170
|
watchDir: path.resolve(process.cwd(), watchDir),
|
|
139
171
|
outputDir: path.resolve(process.cwd(), outputDir),
|
|
@@ -194,98 +226,98 @@ class MDXToNextJSGenerator {
|
|
|
194
226
|
}
|
|
195
227
|
async createNextJSStructure() {
|
|
196
228
|
const structure = {
|
|
197
|
-
".env.example":
|
|
198
|
-
".gitignore":
|
|
199
|
-
"config.json":
|
|
200
|
-
"eslint.config.mjs":
|
|
201
|
-
"links.json":
|
|
202
|
-
"navigation.json":
|
|
203
|
-
"next.config.ts":
|
|
204
|
-
"package.json":
|
|
205
|
-
"proxy.ts":
|
|
206
|
-
"theme.json":
|
|
207
|
-
"tsconfig.json":
|
|
208
|
-
"app/layout.tsx":
|
|
209
|
-
"app/not-found.tsx":
|
|
210
|
-
"app/theme.ts":
|
|
211
|
-
"app/api/mcp/route.ts":
|
|
212
|
-
"app/api/rag/route.ts":
|
|
213
|
-
"app/api/theme/route.ts":
|
|
214
|
-
"services/mcp/index.ts":
|
|
215
|
-
"services/mcp/server.ts":
|
|
216
|
-
"services/mcp/tools.ts":
|
|
217
|
-
"services/mcp/types.ts":
|
|
218
|
-
"services/llm/config.ts":
|
|
219
|
-
"services/llm/factory.ts":
|
|
220
|
-
"services/llm/index.ts":
|
|
221
|
-
"services/llm/types.ts":
|
|
222
|
-
"types/styled.d.ts":
|
|
223
|
-
"utils/orderNavItems.ts":
|
|
224
|
-
"components/Chat.tsx":
|
|
225
|
-
"components/ClickOutside.ts":
|
|
226
|
-
"components/Docs.tsx":
|
|
227
|
-
"components/DocsSideBar.tsx":
|
|
228
|
-
"components/MDXComponents.tsx":
|
|
229
|
-
"components/SideBar.tsx":
|
|
230
|
-
"components/layout/Accordion.tsx":
|
|
231
|
-
"components/layout/ActionBar.tsx":
|
|
232
|
-
"components/layout/Button.tsx":
|
|
233
|
-
"components/layout/Callout.tsx":
|
|
234
|
-
"components/layout/Card.tsx":
|
|
235
|
-
"components/layout/CherryThemeProvider.tsx":
|
|
236
|
-
"components/layout/ClientThemeProvider.tsx":
|
|
237
|
-
"components/layout/Code.tsx":
|
|
238
|
-
"components/layout/Columns.tsx":
|
|
239
|
-
"components/layout/DemoTheme.tsx":
|
|
240
|
-
"components/layout/DocsComponents.tsx":
|
|
241
|
-
"components/layout/DocsNavigation.tsx":
|
|
242
|
-
"components/layout/Field.tsx":
|
|
243
|
-
"components/layout/Footer.tsx":
|
|
244
|
-
"components/layout/GlobalStyles.ts":
|
|
245
|
-
"components/layout/Header.tsx":
|
|
246
|
-
"components/layout/Icon.tsx":
|
|
247
|
-
"components/layout/Pictograms.tsx":
|
|
248
|
-
"components/layout/SharedStyled.ts":
|
|
249
|
-
"components/layout/StaticLinks.tsx":
|
|
250
|
-
"components/layout/Steps.tsx":
|
|
251
|
-
"components/layout/Tabs.tsx":
|
|
252
|
-
"components/layout/ThemeToggle.tsx":
|
|
253
|
-
"components/layout/Typography.ts":
|
|
254
|
-
"components/layout/Update.tsx":
|
|
229
|
+
".env.example": envExampleTemplate,
|
|
230
|
+
".gitignore": gitignoreTemplate,
|
|
231
|
+
"config.json": `{}`,
|
|
232
|
+
"eslint.config.mjs": eslintConfigTemplate,
|
|
233
|
+
"links.json": `[]`,
|
|
234
|
+
"navigation.json": `[]`,
|
|
235
|
+
"next.config.ts": nextConfigTemplate,
|
|
236
|
+
"package.json": packageJsonTemplate,
|
|
237
|
+
"proxy.ts": proxyTemplate,
|
|
238
|
+
"theme.json": `{}`,
|
|
239
|
+
"tsconfig.json": tsconfigTemplate,
|
|
240
|
+
"app/layout.tsx": this.generateRootLayout(),
|
|
241
|
+
"app/not-found.tsx": notFoundTemplate,
|
|
242
|
+
"app/theme.ts": themeTemplate,
|
|
243
|
+
"app/api/mcp/route.ts": mcpRoutesTemplate,
|
|
244
|
+
"app/api/rag/route.ts": ragRoutesTemplate,
|
|
245
|
+
"app/api/theme/route.ts": routesTemplate,
|
|
246
|
+
"services/mcp/index.ts": mcpIndexTemplate,
|
|
247
|
+
"services/mcp/server.ts": mcpServerTemplate,
|
|
248
|
+
"services/mcp/tools.ts": mcpToolsTemplate,
|
|
249
|
+
"services/mcp/types.ts": mcpTypesTemplate,
|
|
250
|
+
"services/llm/config.ts": llmConfigTemplate,
|
|
251
|
+
"services/llm/factory.ts": llmFactoryTemplate,
|
|
252
|
+
"services/llm/index.ts": llmIndexTemplate,
|
|
253
|
+
"services/llm/types.ts": llmTypesTemplate,
|
|
254
|
+
"types/styled.d.ts": styledDTemplate,
|
|
255
|
+
"utils/orderNavItems.ts": orderNavItemsTemplate,
|
|
256
|
+
"components/Chat.tsx": chatTemplate,
|
|
257
|
+
"components/ClickOutside.ts": clickOutsideTemplate,
|
|
258
|
+
"components/Docs.tsx": docsTemplate,
|
|
259
|
+
"components/DocsSideBar.tsx": docsSideBarTemplate,
|
|
260
|
+
"components/MDXComponents.tsx": mdxComponentsTemplate,
|
|
261
|
+
"components/SideBar.tsx": sideBarTemplate,
|
|
262
|
+
"components/layout/Accordion.tsx": accordionTemplate,
|
|
263
|
+
"components/layout/ActionBar.tsx": actionBarTemplate,
|
|
264
|
+
"components/layout/Button.tsx": buttonTemplate,
|
|
265
|
+
"components/layout/Callout.tsx": calloutTemplate,
|
|
266
|
+
"components/layout/Card.tsx": cardTemplate,
|
|
267
|
+
"components/layout/CherryThemeProvider.tsx": cherryThemeProviderTemplate,
|
|
268
|
+
"components/layout/ClientThemeProvider.tsx": clientThemeProviderTemplate,
|
|
269
|
+
"components/layout/Code.tsx": codeTemplate,
|
|
270
|
+
"components/layout/Columns.tsx": columnsTemplate,
|
|
271
|
+
"components/layout/DemoTheme.tsx": demoThemeTemplate,
|
|
272
|
+
"components/layout/DocsComponents.tsx": docsComponentsTemplate,
|
|
273
|
+
"components/layout/DocsNavigation.tsx": docsNavigationTemplate,
|
|
274
|
+
"components/layout/Field.tsx": fieldTemplate,
|
|
275
|
+
"components/layout/Footer.tsx": footerTemplate,
|
|
276
|
+
"components/layout/GlobalStyles.ts": globalStylesTemplate,
|
|
277
|
+
"components/layout/Header.tsx": headerTemplate,
|
|
278
|
+
"components/layout/Icon.tsx": iconTemplate,
|
|
279
|
+
"components/layout/Pictograms.tsx": pictogramsTemplate,
|
|
280
|
+
"components/layout/SharedStyled.ts": sharedStyledTemplate,
|
|
281
|
+
"components/layout/StaticLinks.tsx": staticLinksTemplate,
|
|
282
|
+
"components/layout/Steps.tsx": stepsTemplate,
|
|
283
|
+
"components/layout/Tabs.tsx": tabsTemplate,
|
|
284
|
+
"components/layout/ThemeToggle.tsx": themeToggleTemplate,
|
|
285
|
+
"components/layout/Typography.ts": typographyTemplate,
|
|
286
|
+
"components/layout/Update.tsx": updateTemplate,
|
|
255
287
|
};
|
|
256
288
|
for (const [filePath, content] of Object.entries(structure)) {
|
|
257
289
|
const fullPath = path.join(this.outputDir, filePath);
|
|
258
290
|
await fs.ensureDir(path.dirname(fullPath));
|
|
259
|
-
await fs.writeFile(fullPath, String(content), "utf8");
|
|
291
|
+
await fs.writeFile(fullPath, String(await content), "utf8");
|
|
260
292
|
}
|
|
261
293
|
}
|
|
262
294
|
async createStartingDocs() {
|
|
263
295
|
const structure = {
|
|
264
|
-
"accordion.mdx":
|
|
265
|
-
"ai-assistant.mdx":
|
|
266
|
-
"buttons.mdx":
|
|
267
|
-
"callouts.mdx":
|
|
268
|
-
"cards.mdx":
|
|
269
|
-
"code.mdx":
|
|
270
|
-
"columns.mdx":
|
|
271
|
-
"commands.mdx":
|
|
272
|
-
"deployment.mdx":
|
|
273
|
-
"fields.mdx":
|
|
274
|
-
"fonts.mdx":
|
|
275
|
-
"globals.mdx":
|
|
276
|
-
"headers-and-text.mdx":
|
|
277
|
-
"icons.mdx":
|
|
278
|
-
"image-and-embeds.mdx":
|
|
279
|
-
"index.mdx":
|
|
280
|
-
"links.mdx":
|
|
281
|
-
"lists-and-tables.mdx":
|
|
282
|
-
"media-and-assets.mdx":
|
|
283
|
-
"model-context-protocol.mdx":
|
|
284
|
-
"navigation.mdx":
|
|
285
|
-
"steps.mdx":
|
|
286
|
-
"tabs.mdx":
|
|
287
|
-
"theme.mdx":
|
|
288
|
-
"update.mdx":
|
|
296
|
+
"accordion.mdx": accordionMdxTemplate,
|
|
297
|
+
"ai-assistant.mdx": aiAssistantMdxTemplate,
|
|
298
|
+
"buttons.mdx": buttonsMdxTemplate,
|
|
299
|
+
"callouts.mdx": calloutsMdxTemplate,
|
|
300
|
+
"cards.mdx": cardsMdxTemplate,
|
|
301
|
+
"code.mdx": codeMdxTemplate,
|
|
302
|
+
"columns.mdx": columnsMdxTemplate,
|
|
303
|
+
"commands.mdx": commandsMdxTemplate,
|
|
304
|
+
"deployment.mdx": deploymentMdxTemplate,
|
|
305
|
+
"fields.mdx": fieldsMdxTemplate,
|
|
306
|
+
"fonts.mdx": fontsMdxTemplate,
|
|
307
|
+
"globals.mdx": globalsMdxTemplate,
|
|
308
|
+
"headers-and-text.mdx": headersAndTextMdxTemplate,
|
|
309
|
+
"icons.mdx": iconsMdxTemplate,
|
|
310
|
+
"image-and-embeds.mdx": imageAndEmbedsMdxTemplate,
|
|
311
|
+
"index.mdx": indexMdxTemplate,
|
|
312
|
+
"links.mdx": linksMdxTemplate,
|
|
313
|
+
"lists-and-tables.mdx": listAndTablesMdxTemplate,
|
|
314
|
+
"media-and-assets.mdx": mediaAndAssetsMdxTemplate,
|
|
315
|
+
"model-context-protocol.mdx": mcpMdxTemplate,
|
|
316
|
+
"navigation.mdx": navigationMdxTemplate,
|
|
317
|
+
"steps.mdx": stepsMdxTemplate,
|
|
318
|
+
"tabs.mdx": tabsMdxTemplate,
|
|
319
|
+
"theme.mdx": themeMdxTemplate,
|
|
320
|
+
"update.mdx": updateMdxTemplate,
|
|
289
321
|
};
|
|
290
322
|
const indexMdxExists = await fs.pathExists(path.join(this.watchDir, "index.mdx"));
|
|
291
323
|
if (!indexMdxExists) {
|
|
@@ -372,7 +404,6 @@ class MDXToNextJSGenerator {
|
|
|
372
404
|
try {
|
|
373
405
|
await fs.copy(sourcePath, destPath);
|
|
374
406
|
console.log(chalk.green(`📋 Updated ${this.fontConfigFile} in Next.js app`));
|
|
375
|
-
// Update the layout template with new font config
|
|
376
407
|
await this.updateRootLayout();
|
|
377
408
|
console.log(chalk.green(`✅ Layout updated with new font configuration`));
|
|
378
409
|
}
|
|
@@ -387,7 +418,6 @@ class MDXToNextJSGenerator {
|
|
|
387
418
|
if (await fs.pathExists(destPath)) {
|
|
388
419
|
await fs.remove(destPath);
|
|
389
420
|
console.log(chalk.yellow(`🗑️ Removed ${this.fontConfigFile} from Next.js app`));
|
|
390
|
-
// Update the layout template without font config
|
|
391
421
|
await this.updateRootLayout();
|
|
392
422
|
console.log(chalk.green(`✅ Layout updated without font configuration`));
|
|
393
423
|
}
|
|
@@ -535,6 +565,25 @@ class MDXToNextJSGenerator {
|
|
|
535
565
|
});
|
|
536
566
|
}
|
|
537
567
|
}
|
|
568
|
+
async parseMDXFile(file) {
|
|
569
|
+
const fullPath = path.join(this.watchDir, file);
|
|
570
|
+
const content = await fs.readFile(fullPath, "utf8");
|
|
571
|
+
const { data: frontmatter } = matter(content);
|
|
572
|
+
return {
|
|
573
|
+
slug: this.generateSlug(file),
|
|
574
|
+
title: frontmatter.title || "Untitled",
|
|
575
|
+
description: frontmatter.description || "",
|
|
576
|
+
date: frontmatter.date || null,
|
|
577
|
+
category: frontmatter.category || "",
|
|
578
|
+
path: file,
|
|
579
|
+
categoryOrder: frontmatter.categoryOrder || 0,
|
|
580
|
+
order: frontmatter.order || 0,
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
async buildAllPagesMeta() {
|
|
584
|
+
const files = await this.getAllMDXFiles();
|
|
585
|
+
return Promise.all(files.map((file) => this.parseMDXFile(file)));
|
|
586
|
+
}
|
|
538
587
|
async handleFileChange(action, filePath) {
|
|
539
588
|
console.log(chalk.cyan(`📝 File ${action}: ${filePath}`));
|
|
540
589
|
const fullPath = path.join(this.watchDir, filePath);
|
|
@@ -543,8 +592,6 @@ class MDXToNextJSGenerator {
|
|
|
543
592
|
const { data: frontmatter, content: mdxContent } = matter(content);
|
|
544
593
|
if (filePath === "index.mdx" || filePath === "./index.mdx") {
|
|
545
594
|
console.log(chalk.blue("🏠 Updating homepage with index.mdx content"));
|
|
546
|
-
await this.updatePagesIndex();
|
|
547
|
-
await this.updateRootLayout();
|
|
548
595
|
}
|
|
549
596
|
else {
|
|
550
597
|
const mdxFile = {
|
|
@@ -554,9 +601,9 @@ class MDXToNextJSGenerator {
|
|
|
554
601
|
slug: this.generateSlug(filePath),
|
|
555
602
|
};
|
|
556
603
|
await this.generatePageFromMDX(mdxFile);
|
|
557
|
-
await this.updatePagesIndex();
|
|
558
|
-
await this.updateRootLayout();
|
|
559
604
|
}
|
|
605
|
+
await this.updatePagesIndex();
|
|
606
|
+
await this.updateRootLayout();
|
|
560
607
|
console.log(chalk.green(`✅ Generated page for: ${filePath}`));
|
|
561
608
|
}
|
|
562
609
|
catch (error) {
|
|
@@ -568,16 +615,14 @@ class MDXToNextJSGenerator {
|
|
|
568
615
|
try {
|
|
569
616
|
if (filePath === "index.mdx" || filePath === "./index.mdx") {
|
|
570
617
|
console.log(chalk.blue("🏠 Updating homepage - index.mdx deleted"));
|
|
571
|
-
await this.updatePagesIndex();
|
|
572
|
-
await this.updateRootLayout();
|
|
573
618
|
}
|
|
574
619
|
else {
|
|
575
620
|
const slug = this.generateSlug(filePath);
|
|
576
621
|
const pagePath = path.join(this.outputDir, "app", slug);
|
|
577
622
|
await fs.remove(pagePath);
|
|
578
|
-
await this.updatePagesIndex();
|
|
579
|
-
await this.updateRootLayout();
|
|
580
623
|
}
|
|
624
|
+
await this.updatePagesIndex();
|
|
625
|
+
await this.updateRootLayout();
|
|
581
626
|
console.log(chalk.green(`✅ Removed page for: ${filePath}`));
|
|
582
627
|
}
|
|
583
628
|
catch (error) {
|
|
@@ -609,90 +654,14 @@ class MDXToNextJSGenerator {
|
|
|
609
654
|
return files;
|
|
610
655
|
}
|
|
611
656
|
generateSlug(filePath) {
|
|
612
|
-
|
|
613
|
-
return "";
|
|
614
|
-
}
|
|
615
|
-
return filePath
|
|
616
|
-
.replace(/\.mdx$/, "")
|
|
617
|
-
.replace(/\\/g, "/")
|
|
618
|
-
.replace(/[^a-zA-Z0-9\/\-_]/g, "-")
|
|
619
|
-
.toLowerCase();
|
|
620
|
-
}
|
|
621
|
-
generateEnvExample() {
|
|
622
|
-
return envExampleTemplate;
|
|
623
|
-
}
|
|
624
|
-
generateGitIgnore() {
|
|
625
|
-
return gitignoreTemplate;
|
|
626
|
-
}
|
|
627
|
-
generateConfig() {
|
|
628
|
-
return `{}`;
|
|
629
|
-
}
|
|
630
|
-
generateESLintConfig() {
|
|
631
|
-
return eslintConfigTeamplate;
|
|
632
|
-
}
|
|
633
|
-
generateLinksConfig() {
|
|
634
|
-
return `[]`;
|
|
635
|
-
}
|
|
636
|
-
generateNavigationConfig() {
|
|
637
|
-
return `[]`;
|
|
638
|
-
}
|
|
639
|
-
generateNextConfig() {
|
|
640
|
-
return nextConfigTemplate;
|
|
641
|
-
}
|
|
642
|
-
generatePackageJson() {
|
|
643
|
-
return packageJsonTemplate;
|
|
644
|
-
}
|
|
645
|
-
generateProxy() {
|
|
646
|
-
return proxyTemplate;
|
|
647
|
-
}
|
|
648
|
-
generateThemeConfig() {
|
|
649
|
-
return `{}`;
|
|
650
|
-
}
|
|
651
|
-
generateTSConfig() {
|
|
652
|
-
return tsconfigTemplate;
|
|
657
|
+
return generateSlug(filePath);
|
|
653
658
|
}
|
|
654
659
|
async generateRootLayout() {
|
|
655
|
-
const
|
|
656
|
-
const pages = [];
|
|
657
|
-
for (const file of files) {
|
|
658
|
-
const fullPath = path.join(this.watchDir, file);
|
|
659
|
-
const content = await fs.readFile(fullPath, "utf8");
|
|
660
|
-
const { data: frontmatter } = matter(content);
|
|
661
|
-
pages.push({
|
|
662
|
-
slug: this.generateSlug(file),
|
|
663
|
-
title: frontmatter.title || "Untitled",
|
|
664
|
-
description: frontmatter.description || "",
|
|
665
|
-
date: frontmatter.date || null,
|
|
666
|
-
category: frontmatter.category || "",
|
|
667
|
-
path: file,
|
|
668
|
-
categoryOrder: frontmatter.categoryOrder || 0,
|
|
669
|
-
order: frontmatter.order || 0,
|
|
670
|
-
});
|
|
671
|
-
}
|
|
660
|
+
const pages = await this.buildAllPagesMeta();
|
|
672
661
|
const fontConfig = await this.loadFontConfig();
|
|
673
662
|
return layoutTemplate(pages, fontConfig);
|
|
674
663
|
}
|
|
675
|
-
generateNotFoundPage() {
|
|
676
|
-
return notFoundTemplate;
|
|
677
|
-
}
|
|
678
664
|
async generatePageFromMDX(mdxFile) {
|
|
679
|
-
const files = await this.getAllMDXFiles();
|
|
680
|
-
const pages = [];
|
|
681
|
-
for (const file of files) {
|
|
682
|
-
const fullPath = path.join(this.watchDir, file);
|
|
683
|
-
const content = await fs.readFile(fullPath, "utf8");
|
|
684
|
-
const { data: frontmatter } = matter(content);
|
|
685
|
-
pages.push({
|
|
686
|
-
slug: this.generateSlug(file),
|
|
687
|
-
title: frontmatter.title || "Untitled",
|
|
688
|
-
description: frontmatter.description || "",
|
|
689
|
-
date: frontmatter.date || null,
|
|
690
|
-
category: frontmatter.category || "",
|
|
691
|
-
path: file,
|
|
692
|
-
categoryOrder: frontmatter.categoryOrder || 0,
|
|
693
|
-
order: frontmatter.order || 0,
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
665
|
const pageContent = `import { Metadata } from "next";
|
|
697
666
|
import { Docs } from "@/components/Docs";
|
|
698
667
|
import configData from "@/config.json";
|
|
@@ -706,7 +675,7 @@ interface Config {
|
|
|
706
675
|
|
|
707
676
|
const config = configData as Config;
|
|
708
677
|
|
|
709
|
-
const content = \`${mdxFile.content
|
|
678
|
+
const content = \`${escapeTemplateContent(mdxFile.content)}\`;
|
|
710
679
|
|
|
711
680
|
export const metadata: Metadata = {
|
|
712
681
|
title: \`${mdxFile.frontmatter.title || "Generated with Doccupine"} \${config.name ? "- " + config.name : "- Doccupine"}\`,
|
|
@@ -731,21 +700,18 @@ export default function Page() {
|
|
|
731
700
|
const files = await this.getAllMDXFiles();
|
|
732
701
|
let indexMDX = null;
|
|
733
702
|
for (const file of files) {
|
|
734
|
-
const fullPath = path.join(this.watchDir, file);
|
|
735
|
-
const content = await fs.readFile(fullPath, "utf8");
|
|
736
|
-
const { data: frontmatter, content: mdxContent } = matter(content);
|
|
737
703
|
if (file === "index.mdx" || file === "./index.mdx") {
|
|
704
|
+
const fullPath = path.join(this.watchDir, file);
|
|
705
|
+
const content = await fs.readFile(fullPath, "utf8");
|
|
706
|
+
const { data: frontmatter, content: mdxContent } = matter(content);
|
|
738
707
|
indexMDX = {
|
|
739
708
|
content: mdxContent,
|
|
740
|
-
frontmatter,
|
|
741
709
|
title: frontmatter.title || "Welcome",
|
|
742
|
-
category: frontmatter.category || "",
|
|
743
710
|
description: frontmatter.description || "",
|
|
744
|
-
categoryOrder: frontmatter.categoryOrder || 0,
|
|
745
|
-
order: frontmatter.order || 0,
|
|
746
711
|
icon: frontmatter.icon,
|
|
747
712
|
image: frontmatter.image,
|
|
748
713
|
};
|
|
714
|
+
break;
|
|
749
715
|
}
|
|
750
716
|
}
|
|
751
717
|
const indexContent = `import { Metadata } from "next";
|
|
@@ -761,7 +727,7 @@ interface Config {
|
|
|
761
727
|
|
|
762
728
|
const config = configData as Config;
|
|
763
729
|
|
|
764
|
-
${indexMDX ? `const content = \`${indexMDX.content
|
|
730
|
+
${indexMDX ? `const content = \`${escapeTemplateContent(indexMDX.content)}\`;` : `const content = null;`}
|
|
765
731
|
|
|
766
732
|
${indexMDX
|
|
767
733
|
? `export const metadata: Metadata = {
|
|
@@ -795,216 +761,6 @@ export default function Home() {
|
|
|
795
761
|
const layoutContent = await this.generateRootLayout();
|
|
796
762
|
await fs.writeFile(path.join(this.outputDir, "app", "layout.tsx"), layoutContent, "utf8");
|
|
797
763
|
}
|
|
798
|
-
generateTheme() {
|
|
799
|
-
return themeTemplate;
|
|
800
|
-
}
|
|
801
|
-
generateMCPRoutes() {
|
|
802
|
-
return mcpRoutesTemplate;
|
|
803
|
-
}
|
|
804
|
-
generateRagRoutes() {
|
|
805
|
-
return ragRoutesTemplate;
|
|
806
|
-
}
|
|
807
|
-
generateRoutes() {
|
|
808
|
-
return routesTemplate;
|
|
809
|
-
}
|
|
810
|
-
generateMCPIndex() {
|
|
811
|
-
return mcpIndexTemplate;
|
|
812
|
-
}
|
|
813
|
-
generateMCPServer() {
|
|
814
|
-
return mcpServerTemplate;
|
|
815
|
-
}
|
|
816
|
-
generateMCPTools() {
|
|
817
|
-
return mcpToolsTemplate;
|
|
818
|
-
}
|
|
819
|
-
generateMCPTypes() {
|
|
820
|
-
return mcpTypesTemplate;
|
|
821
|
-
}
|
|
822
|
-
generateLLMConfig() {
|
|
823
|
-
return llmConfigTemplate;
|
|
824
|
-
}
|
|
825
|
-
generateLLMFactory() {
|
|
826
|
-
return llmFactoryTemplate;
|
|
827
|
-
}
|
|
828
|
-
generateLLMIndex() {
|
|
829
|
-
return llmIndexTemplate;
|
|
830
|
-
}
|
|
831
|
-
generateLLMTypes() {
|
|
832
|
-
return llmTypesTemplate;
|
|
833
|
-
}
|
|
834
|
-
generateStyledDTypes() {
|
|
835
|
-
return styledDTemplate;
|
|
836
|
-
}
|
|
837
|
-
generateOrderNavItems() {
|
|
838
|
-
return orderNavItemsTemplate;
|
|
839
|
-
}
|
|
840
|
-
generateChat() {
|
|
841
|
-
return chatTemplate;
|
|
842
|
-
}
|
|
843
|
-
generateClickOutside() {
|
|
844
|
-
return clickOutsideTemplate;
|
|
845
|
-
}
|
|
846
|
-
generateDocs() {
|
|
847
|
-
return docsTemplate;
|
|
848
|
-
}
|
|
849
|
-
generateDocsSideBar() {
|
|
850
|
-
return docsSideBarTemplate;
|
|
851
|
-
}
|
|
852
|
-
generateMDXComponents() {
|
|
853
|
-
return mdxComponentsTemplate;
|
|
854
|
-
}
|
|
855
|
-
generateSideBar() {
|
|
856
|
-
return sideBarTemplate;
|
|
857
|
-
}
|
|
858
|
-
generateAccordion() {
|
|
859
|
-
return accordionTemplate;
|
|
860
|
-
}
|
|
861
|
-
generateActionBar() {
|
|
862
|
-
return actionBarTemplate;
|
|
863
|
-
}
|
|
864
|
-
generateButton() {
|
|
865
|
-
return buttonTemplate;
|
|
866
|
-
}
|
|
867
|
-
generateCallout() {
|
|
868
|
-
return calloutTemplate;
|
|
869
|
-
}
|
|
870
|
-
generateCard() {
|
|
871
|
-
return cardTemplate;
|
|
872
|
-
}
|
|
873
|
-
generateCherryThemeProvider() {
|
|
874
|
-
return cherryThemeProviderTemplate;
|
|
875
|
-
}
|
|
876
|
-
generateClientThemeProvider() {
|
|
877
|
-
return clientThemeProviderTemplate;
|
|
878
|
-
}
|
|
879
|
-
generateCode() {
|
|
880
|
-
return codeTemplate;
|
|
881
|
-
}
|
|
882
|
-
generateColumns() {
|
|
883
|
-
return columnsTemplate;
|
|
884
|
-
}
|
|
885
|
-
generateDemoTheme() {
|
|
886
|
-
return demoThemeTemplate;
|
|
887
|
-
}
|
|
888
|
-
generateDocsComponents() {
|
|
889
|
-
return docsComponentsTemplate;
|
|
890
|
-
}
|
|
891
|
-
generateDocsNavigation() {
|
|
892
|
-
return docsNavigationTemplate;
|
|
893
|
-
}
|
|
894
|
-
generateField() {
|
|
895
|
-
return fieldTemplate;
|
|
896
|
-
}
|
|
897
|
-
generateFooter() {
|
|
898
|
-
return footerTemplate;
|
|
899
|
-
}
|
|
900
|
-
generateGlobalStyles() {
|
|
901
|
-
return globalStylesTemplate;
|
|
902
|
-
}
|
|
903
|
-
generateHeader() {
|
|
904
|
-
return headerTemplate;
|
|
905
|
-
}
|
|
906
|
-
generateIcon() {
|
|
907
|
-
return iconTemplate;
|
|
908
|
-
}
|
|
909
|
-
generatePictograms() {
|
|
910
|
-
return pictogramsTemplate;
|
|
911
|
-
}
|
|
912
|
-
generateSharedStyled() {
|
|
913
|
-
return sharedStyledTemplate;
|
|
914
|
-
}
|
|
915
|
-
generateStaticLinks() {
|
|
916
|
-
return staticLinksTemplate;
|
|
917
|
-
}
|
|
918
|
-
generateSteps() {
|
|
919
|
-
return stepsTemplate;
|
|
920
|
-
}
|
|
921
|
-
generateTabs() {
|
|
922
|
-
return tabsTemplate;
|
|
923
|
-
}
|
|
924
|
-
generateThemeToggle() {
|
|
925
|
-
return themeToggleTemplate;
|
|
926
|
-
}
|
|
927
|
-
generateTypography() {
|
|
928
|
-
return typographyTemplate;
|
|
929
|
-
}
|
|
930
|
-
generateUpdate() {
|
|
931
|
-
return updateTemplate;
|
|
932
|
-
}
|
|
933
|
-
generateAccordionMdx() {
|
|
934
|
-
return accordionMdxTemplate;
|
|
935
|
-
}
|
|
936
|
-
generateAiAssistantMdx() {
|
|
937
|
-
return aiAssistantMdxTemplate;
|
|
938
|
-
}
|
|
939
|
-
generateButtonsMdx() {
|
|
940
|
-
return buttonsMdxTemplate;
|
|
941
|
-
}
|
|
942
|
-
generateCalloutsMdx() {
|
|
943
|
-
return calloutsMdxTemplate;
|
|
944
|
-
}
|
|
945
|
-
generateCardsMdx() {
|
|
946
|
-
return cardsMdxTemplate;
|
|
947
|
-
}
|
|
948
|
-
generateCodeMdx() {
|
|
949
|
-
return codeMdxTemplate;
|
|
950
|
-
}
|
|
951
|
-
generateColumnsMdx() {
|
|
952
|
-
return columnsMdxTemplate;
|
|
953
|
-
}
|
|
954
|
-
generateCommandsMdx() {
|
|
955
|
-
return commandsMdxTemplate;
|
|
956
|
-
}
|
|
957
|
-
generateDeploymentMdx() {
|
|
958
|
-
return deploymentMdxTemplate;
|
|
959
|
-
}
|
|
960
|
-
generateFieldsMdx() {
|
|
961
|
-
return fieldsMdxTemplate;
|
|
962
|
-
}
|
|
963
|
-
generateFontsMdx() {
|
|
964
|
-
return fontsMdxTemplate;
|
|
965
|
-
}
|
|
966
|
-
generateGlobalsMdx() {
|
|
967
|
-
return globalsMdxTemplate;
|
|
968
|
-
}
|
|
969
|
-
generateHeadersAndTextMdx() {
|
|
970
|
-
return headersAndTextMdxTemplate;
|
|
971
|
-
}
|
|
972
|
-
generateIconsMdx() {
|
|
973
|
-
return iconsMdxTemplate;
|
|
974
|
-
}
|
|
975
|
-
generateImagesAndEmbedsMdx() {
|
|
976
|
-
return imageAndEmbedsMdxTemplate;
|
|
977
|
-
}
|
|
978
|
-
generateIndexMdx() {
|
|
979
|
-
return indexMdxTemplate;
|
|
980
|
-
}
|
|
981
|
-
generateLinksMdx() {
|
|
982
|
-
return linksMdxTemplate;
|
|
983
|
-
}
|
|
984
|
-
generateListsAndTablesMdx() {
|
|
985
|
-
return listAndTablesMdxTemplate;
|
|
986
|
-
}
|
|
987
|
-
generateMediaAndAssetsMdx() {
|
|
988
|
-
return mediaAndAssetsMdxTemplate;
|
|
989
|
-
}
|
|
990
|
-
generateMCPMdx() {
|
|
991
|
-
return mcpMdxTemplate;
|
|
992
|
-
}
|
|
993
|
-
generateNavigationMdx() {
|
|
994
|
-
return navigationMdxTemplate;
|
|
995
|
-
}
|
|
996
|
-
generateStepsMdx() {
|
|
997
|
-
return stepsMdxTemplate;
|
|
998
|
-
}
|
|
999
|
-
generateTabsMdx() {
|
|
1000
|
-
return tabsMdxTemplate;
|
|
1001
|
-
}
|
|
1002
|
-
generateThemeMdx() {
|
|
1003
|
-
return themeMdxTemplate;
|
|
1004
|
-
}
|
|
1005
|
-
generateUpdateMdx() {
|
|
1006
|
-
return updateMdxTemplate;
|
|
1007
|
-
}
|
|
1008
764
|
async stop() {
|
|
1009
765
|
if (this.watcher) {
|
|
1010
766
|
await this.watcher.close();
|
|
@@ -1066,20 +822,28 @@ program
|
|
|
1066
822
|
resolve(void 0);
|
|
1067
823
|
}
|
|
1068
824
|
else {
|
|
1069
|
-
reject(new Error(
|
|
825
|
+
reject(new Error(`${packageManager} install failed with code ${code}`));
|
|
1070
826
|
}
|
|
1071
827
|
});
|
|
1072
828
|
install.on("error", reject);
|
|
1073
829
|
});
|
|
1074
|
-
|
|
1075
|
-
|
|
830
|
+
const port = await findAvailablePort(parseInt(config.port, 10));
|
|
831
|
+
if (port !== parseInt(config.port, 10)) {
|
|
832
|
+
console.log(chalk.yellow(`⚠️ Port ${config.port} is in use, using port ${port} instead`));
|
|
833
|
+
}
|
|
834
|
+
console.log(chalk.blue(`🚀 Starting Next.js dev server on port ${port}...`));
|
|
835
|
+
const portStr = String(port);
|
|
836
|
+
const devArgs = packageManager === "npm"
|
|
837
|
+
? ["run", "dev", "--", "--port", portStr]
|
|
838
|
+
: ["run", "dev", "--port", portStr];
|
|
839
|
+
devServer = spawn(packageManager, devArgs, {
|
|
1076
840
|
cwd: config.outputDir,
|
|
1077
841
|
stdio: ["ignore", "pipe", "pipe"],
|
|
1078
842
|
});
|
|
1079
|
-
devServer.stdout
|
|
843
|
+
devServer.stdout?.on("data", (data) => {
|
|
1080
844
|
const output = data.toString();
|
|
1081
845
|
if (output.includes("Ready") || output.includes("started")) {
|
|
1082
|
-
console.log(chalk.green(`🌐 Next.js ready at http://localhost:${
|
|
846
|
+
console.log(chalk.green(`🌐 Next.js ready at http://localhost:${port}`));
|
|
1083
847
|
}
|
|
1084
848
|
if (output.includes("compiled") ||
|
|
1085
849
|
output.includes("error") ||
|
|
@@ -1087,14 +851,20 @@ program
|
|
|
1087
851
|
process.stdout.write(chalk.gray("[Next.js] ") + output);
|
|
1088
852
|
}
|
|
1089
853
|
});
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
854
|
+
devServer.stderr?.on("data", (data) => {
|
|
855
|
+
const output = data.toString();
|
|
856
|
+
if (options.verbose || output.includes("Error") || output.includes("error")) {
|
|
857
|
+
process.stderr.write(chalk.red("[Next.js] ") + output);
|
|
858
|
+
}
|
|
859
|
+
});
|
|
1095
860
|
devServer.on("error", (error) => {
|
|
1096
861
|
console.error(chalk.red("❌ Error starting dev server:"), error);
|
|
1097
862
|
});
|
|
863
|
+
devServer.on("close", (code) => {
|
|
864
|
+
if (code && code !== 0) {
|
|
865
|
+
console.error(chalk.red(`❌ Next.js dev server exited with code ${code}`));
|
|
866
|
+
}
|
|
867
|
+
});
|
|
1098
868
|
await generator.startWatching();
|
|
1099
869
|
process.on("SIGINT", async () => {
|
|
1100
870
|
console.log(chalk.yellow("\n🛑 Shutting down..."));
|
|
@@ -1106,7 +876,6 @@ program
|
|
|
1106
876
|
});
|
|
1107
877
|
console.log(chalk.green("🎉 Generator is running! Press Ctrl+C to stop."));
|
|
1108
878
|
console.log(chalk.cyan(`📝 Edit your MDX files in: ${config.watchDir}`));
|
|
1109
|
-
console.log(chalk.cyan(`🌐 View changes at: http://localhost:${config.port}`));
|
|
1110
879
|
});
|
|
1111
880
|
program
|
|
1112
881
|
.command("build")
|