docmk 1.0.0 → 1.0.2
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/README.md +122 -0
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/builder/vite-dev.ts +14 -8
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# DocGen
|
|
2
|
+
|
|
3
|
+
一个简单的文档生成工具,将 Markdown 文档转换为静态网站。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 📁 **自动扫描** - 递归扫描目录结构
|
|
8
|
+
- 📝 **Markdown 支持** - 完整的 Markdown 渲染和 frontmatter
|
|
9
|
+
- 🔍 **内置搜索** - 全文搜索功能
|
|
10
|
+
- 🎨 **代码高亮** - 基于 Shiki 的语法高亮
|
|
11
|
+
- ⚡ **热更新** - 文件监听和自动刷新
|
|
12
|
+
- 📱 **响应式** - 支持移动端和桌面端
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g docgen
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
或本地安装:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install
|
|
24
|
+
npm run build
|
|
25
|
+
npm link
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 使用方法
|
|
29
|
+
|
|
30
|
+
### 开发模式
|
|
31
|
+
|
|
32
|
+
启动开发服务器,支持热更新:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
docgen ./docs
|
|
36
|
+
# 或指定端口
|
|
37
|
+
docgen ./docs --port 3001
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 构建静态站点
|
|
41
|
+
|
|
42
|
+
生成可部署的静态文件:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
docgen build ./docs --output ./dist
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 预览构建结果
|
|
49
|
+
|
|
50
|
+
预览已构建的站点:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
docgen preview --output ./dist
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 目录结构
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
docs/
|
|
60
|
+
├── getting-started/
|
|
61
|
+
│ ├── README.md # 目录首页
|
|
62
|
+
│ ├── installation.md
|
|
63
|
+
│ └── quick-start.md
|
|
64
|
+
├── guides/
|
|
65
|
+
│ ├── README.md
|
|
66
|
+
│ └── advanced.md
|
|
67
|
+
└── api/
|
|
68
|
+
└── README.md
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 文档格式
|
|
72
|
+
|
|
73
|
+
每个 Markdown 文件支持 frontmatter:
|
|
74
|
+
|
|
75
|
+
```markdown
|
|
76
|
+
---
|
|
77
|
+
title: 页面标题
|
|
78
|
+
description: 页面描述
|
|
79
|
+
tags: ["tag1", "tag2"]
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
# 页面内容
|
|
83
|
+
|
|
84
|
+
这里是 Markdown 内容...
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 路由规则
|
|
88
|
+
|
|
89
|
+
- `README.md` → 目录路径(如 `/getting-started`)
|
|
90
|
+
- `SKILL.md` → 目录路径
|
|
91
|
+
- 其他 `.md` 文件 → 保留文件名(如 `/guides/advanced`)
|
|
92
|
+
|
|
93
|
+
## 开发
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# 安装依赖
|
|
97
|
+
npm install
|
|
98
|
+
|
|
99
|
+
# 构建 CLI
|
|
100
|
+
npm run build
|
|
101
|
+
|
|
102
|
+
# 类型检查
|
|
103
|
+
npm run typecheck
|
|
104
|
+
|
|
105
|
+
# 代码检查
|
|
106
|
+
npm run lint
|
|
107
|
+
|
|
108
|
+
# 本地测试
|
|
109
|
+
npx tsx src/cli/index.ts dev --dir ./my-docs
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 技术栈
|
|
113
|
+
|
|
114
|
+
- **后端**: Node.js, TypeScript, Commander.js
|
|
115
|
+
- **前端**: Vue 3, Vite, Vue Router
|
|
116
|
+
- **解析**: gray-matter, markdown-it, Shiki
|
|
117
|
+
- **监听**: chokidar
|
|
118
|
+
- **构建**: tsup
|
|
119
|
+
|
|
120
|
+
## 许可证
|
|
121
|
+
|
|
122
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -312,6 +312,8 @@ async function createViteDevServer(options) {
|
|
|
312
312
|
port: options.port,
|
|
313
313
|
host: "localhost"
|
|
314
314
|
},
|
|
315
|
+
publicDir: false,
|
|
316
|
+
// Disable public dir in dev mode
|
|
315
317
|
plugins: [
|
|
316
318
|
vue(),
|
|
317
319
|
// Custom plugin to inject config and handle API routes
|
|
@@ -326,13 +328,17 @@ async function createViteDevServer(options) {
|
|
|
326
328
|
next();
|
|
327
329
|
}
|
|
328
330
|
});
|
|
329
|
-
|
|
330
|
-
|
|
331
|
+
return () => {
|
|
332
|
+
server2.middlewares.use((req, res, next) => {
|
|
333
|
+
if (req.url?.startsWith("/api/") || req.url?.startsWith("/@") || req.url?.includes(".html")) {
|
|
334
|
+
return next();
|
|
335
|
+
}
|
|
336
|
+
if (req.url && !req.url.includes(".")) {
|
|
337
|
+
req.url = "/index.html";
|
|
338
|
+
}
|
|
331
339
|
next();
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
});
|
|
340
|
+
});
|
|
341
|
+
};
|
|
336
342
|
},
|
|
337
343
|
transformIndexHtml: {
|
|
338
344
|
order: "pre",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/scanner/index.ts","../src/parser/index.ts","../src/cli/index.ts","../src/cli/commands/dev.ts","../src/builder/vite-dev.ts","../src/cli/commands/build.ts","../src/builder/index.ts","../src/cli/commands/preview.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\nimport { SkillDirectory, SkillFile } from '../types/index.js'\n\nexport async function scanSkillsDirectory(sourceDir: string): Promise<SkillDirectory[]> {\n try {\n await fs.access(sourceDir)\n } catch {\n throw new Error(`Source directory not found: ${sourceDir}`)\n }\n\n const entries = await fs.readdir(sourceDir, { withFileTypes: true })\n const directories: SkillDirectory[] = []\n\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const dirPath = path.join(sourceDir, entry.name)\n const skillDirectory = await scanDirectory(dirPath, entry.name)\n directories.push(skillDirectory)\n }\n }\n\n return directories\n}\n\nasync function scanDirectory(dirPath: string, name: string): Promise<SkillDirectory> {\n const entries = await fs.readdir(dirPath, { withFileTypes: true })\n const children: (SkillDirectory | SkillFile)[] = []\n let skillFile: SkillFile | undefined\n\n for (const entry of entries) {\n const entryPath = path.join(dirPath, entry.name)\n\n if (entry.isDirectory()) {\n const subDir = await scanDirectory(entryPath, entry.name)\n children.push(subDir)\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n const file = await parseMarkdownFile(entryPath, entry.name)\n \n if (entry.name === 'SKILL.md') {\n skillFile = file\n } else {\n children.push(file)\n }\n }\n }\n\n return {\n path: dirPath,\n name,\n children,\n skillFile\n }\n}\n\nasync function parseMarkdownFile(filePath: string, fileName: string): Promise<SkillFile> {\n const content = await fs.readFile(filePath, 'utf-8')\n const stats = await fs.stat(filePath)\n\n // Basic frontmatter extraction\n const frontmatterMatch = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n/)\n const frontmatter: Record<string, any> = {}\n let markdownContent = content\n\n if (frontmatterMatch) {\n // Remove frontmatter from content\n markdownContent = content.slice(frontmatterMatch[0].length)\n \n // Parse frontmatter key-value pairs\n const fmLines = frontmatterMatch[1].split(/\\r?\\n/)\n for (const line of fmLines) {\n const colonIndex = line.indexOf(':')\n if (colonIndex > 0) {\n const key = line.slice(0, colonIndex).trim()\n const value = line.slice(colonIndex + 1).trim().replace(/^[\"']|[\"']$/g, '')\n if (key && value) {\n frontmatter[key] = value\n }\n }\n }\n }\n\n return {\n path: filePath,\n name: fileName,\n title: frontmatter.title || fileName.replace('.md', ''),\n description: frontmatter.description,\n content: markdownContent,\n frontmatter,\n lastModified: stats.mtime.getTime()\n }\n}\n\nexport async function watchSkillsDirectory(\n sourceDir: string, \n callback: (directories: SkillDirectory[]) => void\n) {\n const chokidar = await import('chokidar')\n \n const watcher = chokidar.watch(sourceDir, {\n ignored: /node_modules/,\n persistent: true,\n ignoreInitial: true\n })\n\n let debounceTimer: NodeJS.Timeout\n\n const handleChange = () => {\n clearTimeout(debounceTimer)\n debounceTimer = setTimeout(async () => {\n try {\n const directories = await scanSkillsDirectory(sourceDir)\n callback(directories)\n } catch (error) {\n console.error('Error rescanning source directory:', error)\n }\n }, 300)\n }\n\n watcher.on('add', handleChange)\n watcher.on('change', handleChange)\n watcher.on('unlink', handleChange)\n watcher.on('addDir', handleChange)\n watcher.on('unlinkDir', handleChange)\n\n return watcher\n}","import matter from 'gray-matter'\nimport MarkdownIt from 'markdown-it'\nimport { createHighlighter, Highlighter } from 'shiki'\nimport { SkillDirectory, SkillFile, SiteConfig, DocGenConfig, Navigation } from '../types/index.js'\n\nlet highlighter: Highlighter | null = null\n\nasync function getHighlighter() {\n if (!highlighter) {\n highlighter = await createHighlighter({\n themes: ['github-dark', 'github-light'],\n langs: ['javascript', 'typescript', 'bash', 'shell', 'json', 'html', 'css', 'vue', 'jsx', 'tsx', 'python', 'markdown', 'yaml', 'sql', 'go', 'rust', 'java', 'c', 'cpp']\n })\n }\n return highlighter\n}\n\nconst md = new MarkdownIt({\n html: true,\n linkify: true,\n typographer: true,\n highlight: function (str: string, lang: string) {\n // Synchronous fallback - actual highlighting done in enhanceFileContent\n return `<pre class=\"shiki-pending\" data-lang=\"${lang || 'text'}\"><code>${md.utils.escapeHtml(str)}</code></pre>`\n }\n})\n\nexport async function parseSkillsToConfig(\n directories: SkillDirectory[],\n siteConfig: SiteConfig\n): Promise<DocGenConfig> {\n const files: SkillFile[] = []\n const navigation = await generateNavigation(directories)\n\n // Collect all files for search indexing\n collectAllFiles(directories, files)\n\n // Enhance files with parsed content\n for (const file of files) {\n await enhanceFileContent(file)\n }\n\n return {\n siteConfig,\n navigation,\n files,\n directories\n }\n}\n\nfunction collectAllFiles(items: (SkillDirectory | SkillFile)[], files: SkillFile[]) {\n for (const item of items) {\n if ('content' in item) {\n // It's a SkillFile\n files.push(item)\n } else {\n // It's a SkillDirectory\n if (item.skillFile) {\n files.push(item.skillFile)\n }\n collectAllFiles(item.children, files)\n }\n }\n}\n\nasync function enhanceFileContent(file: SkillFile) {\n try {\n let content = file.content\n\n // Update title and description from frontmatter if available\n file.title = file.frontmatter.title || file.title\n file.description = file.frontmatter.description || file.description\n\n // Remove duplicate h1 if it matches frontmatter title\n if (file.frontmatter.title) {\n // Match first h1 heading in content (may have leading whitespace/newlines)\n const h1Match = content.match(/^\\s*#\\s+(.+)$/m)\n if (h1Match) {\n const h1Text = h1Match[1].trim()\n // If h1 matches title, remove it to avoid duplication\n if (h1Text === file.frontmatter.title) {\n content = content.replace(/^\\s*#\\s+.+\\n*/, '')\n }\n }\n }\n\n // Render markdown to HTML\n let html = md.render(content)\n \n // Apply syntax highlighting with shiki\n html = await highlightCodeBlocks(html)\n file.frontmatter.html = html\n\n // Extract headings for TOC\n const headings = extractHeadings(content)\n file.frontmatter.headings = headings\n\n } catch (error) {\n console.warn(`Failed to enhance content for ${file.path}:`, error)\n try {\n file.frontmatter.html = md.render(file.content)\n } catch (e) {\n console.error(`Failed to render markdown for ${file.path}:`, e)\n }\n }\n}\n\nasync function highlightCodeBlocks(html: string): Promise<string> {\n const hl = await getHighlighter()\n \n // Find all pending shiki code blocks and highlight them\n const codeBlockRegex = /<pre class=\"shiki-pending\" data-lang=\"([^\"]*)\"[^>]*><code>([^]*?)<\\/code><\\/pre>/g\n \n const matches = [...html.matchAll(codeBlockRegex)]\n \n for (const match of matches) {\n const [fullMatch, lang, escapedCode] = match\n // Unescape HTML entities\n const code = escapedCode\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/&/g, '&')\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n \n try {\n const validLang = hl.getLoadedLanguages().includes(lang) ? lang : 'text'\n const highlighted = hl.codeToHtml(code, {\n lang: validLang,\n theme: 'github-dark'\n })\n html = html.replace(fullMatch, highlighted)\n } catch (e) {\n // Keep original if highlighting fails\n console.warn(`Failed to highlight ${lang}:`, e)\n }\n }\n \n return html\n}\n\nfunction extractHeadings(content: string) {\n const headings: Array<{ level: number; text: string; anchor: string }> = []\n const lines = content.split('\\n')\n\n for (const line of lines) {\n const match = line.match(/^(#{1,6})\\\\s+(.+)$/)\n if (match) {\n const level = match[1].length\n const text = match[2].trim()\n const anchor = text.toLowerCase()\n .replace(/[^\\\\w\\\\s-]/g, '')\n .replace(/\\\\s+/g, '-')\n .trim()\n\n headings.push({ level, text, anchor })\n }\n }\n\n return headings\n}\n\nasync function generateNavigation(directories: SkillDirectory[]): Promise<Navigation[]> {\n const navigation: Navigation[] = []\n\n for (const dir of directories) {\n const navItem: Navigation = {\n text: dir.skillFile?.title || formatDirName(dir.name),\n link: dir.skillFile ? getFileRoute(dir.skillFile) : undefined\n }\n\n if (dir.children.length > 0) {\n navItem.children = []\n \n for (const child of dir.children) {\n if ('content' in child) {\n // It's a file\n navItem.children.push({\n text: child.title || formatFileName(child.name),\n link: getFileRoute(child)\n })\n } else {\n // It's a subdirectory\n const subNav = await generateNavigation([child])\n navItem.children.push(...subNav)\n }\n }\n }\n\n navigation.push(navItem)\n }\n\n return navigation\n}\n\nfunction getFileRoute(file: SkillFile): string {\n // Import the utility function from client utils\n // For now, use inline implementation\n const filePath = file.path\n \n // Try common patterns\n const patterns = ['my-docs', 'docs', 'documentation', '.claude/skills']\n let relativePath = ''\n \n for (const pattern of patterns) {\n const index = filePath.indexOf(pattern)\n if (index !== -1) {\n relativePath = filePath.slice(index + pattern.length)\n break\n }\n }\n \n if (!relativePath) {\n // Fallback: use last 2 segments\n const segments = filePath.split('/').filter(Boolean)\n if (segments.length >= 2) {\n relativePath = '/' + segments.slice(-2).join('/')\n } else {\n return '/'\n }\n }\n \n const segments = relativePath.split('/').filter(Boolean)\n \n if (segments.length === 0) return '/'\n \n // Remove file extension\n const lastSegment = segments[segments.length - 1]\n if (lastSegment.endsWith('.md')) {\n segments[segments.length - 1] = lastSegment.slice(0, -3)\n }\n \n // SKILL.md and README.md should map to parent directory route\n const finalSegment = segments[segments.length - 1]\n if (finalSegment === 'SKILL' || finalSegment === 'README') {\n segments.pop()\n }\n \n return '/' + segments.join('/')\n}\n\nfunction formatDirName(name: string): string {\n return name.split('-').map(word => \n word.charAt(0).toUpperCase() + word.slice(1)\n ).join(' ')\n}\n\nfunction formatFileName(name: string): string {\n const baseName = name.replace('.md', '')\n return formatDirName(baseName)\n}\n\nexport { md as markdownRenderer }","#!/usr/bin/env node\n\nimport { Command } from 'commander'\nimport { devCommand } from './commands/dev.js'\nimport { buildCommand } from './commands/build.js'\nimport { previewCommand } from './commands/preview.js'\n\nconst program = new Command()\n\nprogram\n .name('docmk')\n .description('CLI tool for generating documentation from any directory')\n .version('1.0.0')\n .argument('[directory]', 'Source directory path (starts dev server)', './docs')\n .option('-p, --port <port>', 'Port to run dev server on', '3000')\n .action((directory, options) => {\n // Default action: start dev server\n devCommand({ dir: directory, port: options.port })\n })\n\nprogram\n .command('dev')\n .description('Start development server')\n .option('-p, --port <port>', 'Port to run dev server on', '3000')\n .option('-d, --dir <directory>', 'Source directory path', './docs')\n .action(devCommand)\n\nprogram\n .command('build')\n .description('Build static documentation site')\n .option('-d, --dir <directory>', 'Source directory path', './docs')\n .option('-o, --output <directory>', 'Output directory', 'dist')\n .action(buildCommand)\n\nprogram\n .command('preview')\n .description('Preview built documentation site')\n .option('-p, --port <port>', 'Port to run preview server on', '4173')\n .option('-o, --output <directory>', 'Built site directory', 'dist')\n .action(previewCommand)\n\nprogram.parse()","import path from 'path'\nimport { createViteDevServer } from '../../builder/vite-dev.js'\nimport { scanSkillsDirectory } from '../../scanner/index.js'\nimport { parseSkillsToConfig } from '../../parser/index.js'\n\ninterface DevOptions {\n port: string\n dir: string\n}\n\nexport async function devCommand(options: DevOptions) {\n console.log('🚀 Starting DocGen development server...')\n \n const sourceDir = path.resolve(process.cwd(), options.dir)\n const port = parseInt(options.port, 10)\n \n try {\n // Check if source directory exists\n console.log(`📁 Scanning source directory: ${sourceDir}`)\n const directories = await scanSkillsDirectory(sourceDir)\n \n console.log(`✅ Found ${directories.length} directories`)\n \n // Parse to config\n const config = await parseSkillsToConfig(directories, {\n title: 'Documentation',\n description: 'Documentation generated from source directory',\n baseUrl: '/',\n skillsDir: sourceDir,\n outputDir: 'dist'\n })\n \n // Start Vite dev server\n const server = await createViteDevServer({\n port,\n skillsDir: sourceDir,\n config\n })\n \n console.log(`🎉 Dev server running at http://localhost:${port}`)\n \n // Handle graceful shutdown\n process.on('SIGINT', async () => {\n console.log('\\\\n👋 Shutting down dev server...')\n await server.close()\n process.exit(0)\n })\n \n } catch (error) {\n console.error('❌ Failed to start dev server:', error)\n process.exit(1)\n }\n}","import { createServer, ViteDevServer } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport path from 'path'\nimport { DocGenConfig } from '../types/index.js'\nimport { scanSkillsDirectory, watchSkillsDirectory } from '../scanner/index.js'\nimport { parseSkillsToConfig } from '../parser/index.js'\n\ninterface DevServerOptions {\n port: number\n skillsDir: string\n config: DocGenConfig\n}\n\nexport async function createViteDevServer(options: DevServerOptions): Promise<ViteDevServer> {\n let currentConfig = options.config\n\n const server = await createServer({\n root: path.resolve(process.cwd(), 'src/client'),\n server: {\n port: options.port,\n host: 'localhost'\n },\n plugins: [\n vue(),\n // Custom plugin to inject config and handle API routes\n {\n name: 'docgen-dev',\n configureServer(server) {\n // API endpoint for configuration\n server.middlewares.use('/api/config', (req, res, next) => {\n if (req.method === 'GET') {\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(currentConfig))\n } else {\n next()\n }\n })\n\n // Inject config into HTML\n server.middlewares.use((req, res, next) => {\n if (req.url === '/' || req.url === '/index.html') {\n // Let Vite handle the HTML transformation\n next()\n } else {\n next()\n }\n })\n },\n transformIndexHtml: {\n order: 'pre',\n handler(html) {\n // Inject lightweight config placeholder\n // Full config will be loaded via API to avoid HTML parsing issues\n const configScript = `\n <script>\n // Config will be loaded from /api/config\n globalThis.__DOCGEN_CONFIG__ = null;\n </script>\n `\n return html.replace('<head>', `<head>${configScript}`)\n }\n }\n }\n ],\n resolve: {\n alias: {\n '@': path.resolve(process.cwd(), 'src/client')\n }\n },\n define: {\n __DOCGEN_CONFIG__: JSON.stringify(currentConfig)\n }\n })\n\n // Watch skills directory for changes\n const watcher = await watchSkillsDirectory(options.skillsDir, async (directories) => {\n console.log('📝 Skills directory changed, updating configuration...')\n \n try {\n currentConfig = await parseSkillsToConfig(directories, currentConfig.siteConfig)\n \n // Notify all connected clients to reload\n server.ws.send({\n type: 'full-reload'\n })\n \n console.log('✅ Configuration updated')\n } catch (error) {\n console.error('❌ Failed to update configuration:', error)\n \n // Send error to clients\n server.ws.send({\n type: 'error',\n err: {\n message: `Failed to update configuration: ${error.message}`,\n stack: error.stack\n }\n })\n }\n })\n\n // Start the server\n await server.listen()\n\n // Extend server with cleanup method\n const originalClose = server.close.bind(server)\n server.close = async () => {\n await watcher?.close()\n return originalClose()\n }\n\n return server\n}\n\nexport async function createProductionBuild() {\n // This will be implemented in the builder\n}","import path from 'path'\nimport { buildSite } from '../../builder/index.js'\nimport { scanSkillsDirectory } from '../../scanner/index.js'\nimport { parseSkillsToConfig } from '../../parser/index.js'\n\ninterface BuildOptions {\n dir: string\n output: string\n}\n\nexport async function buildCommand(options: BuildOptions) {\n console.log('🏗️ Building DocGen documentation site...')\n \n const sourceDir = path.resolve(process.cwd(), options.dir)\n const outputDir = path.resolve(process.cwd(), options.output)\n \n try {\n // Scan source directory\n console.log(`📁 Scanning source directory: ${sourceDir}`)\n const directories = await scanSkillsDirectory(sourceDir)\n \n console.log(`✅ Found ${directories.length} directories`)\n \n // Parse to config\n const config = await parseSkillsToConfig(directories, {\n title: 'Documentation',\n description: 'Documentation generated from source directory',\n baseUrl: '/',\n skillsDir: sourceDir,\n outputDir\n })\n \n // Build site\n console.log(`📦 Building to: ${outputDir}`)\n await buildSite({\n input: sourceDir,\n output: outputDir,\n mode: 'production'\n }, config)\n \n console.log('✅ Build completed successfully!')\n console.log(`📂 Built files are in: ${outputDir}`)\n \n } catch (error) {\n console.error('❌ Build failed:', error)\n process.exit(1)\n }\n}","import { build } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport path from 'path'\nimport fs from 'fs/promises'\nimport { DocGenConfig, BuildOptions } from '../types/index.js'\n\nexport async function buildSite(options: BuildOptions, config: DocGenConfig) {\n console.log('🏗️ Building documentation site...')\n \n // Ensure output directory exists\n await fs.mkdir(options.output, { recursive: true })\n \n // Write config to a temporary file for the build process\n const configPath = path.join(process.cwd(), 'temp-config.json')\n await fs.writeFile(configPath, JSON.stringify(config, null, 2))\n \n try {\n // Build the client application\n await build({\n root: path.resolve(process.cwd(), 'src/client'),\n base: config.siteConfig.baseUrl,\n build: {\n outDir: options.output,\n emptyOutDir: true,\n rollupOptions: {\n input: {\n main: path.resolve(process.cwd(), 'src/client/index.html')\n }\n }\n },\n plugins: [\n vue(),\n // Plugin to inject config during build\n {\n name: 'docgen-build',\n transformIndexHtml: {\n order: 'pre',\n handler(html) {\n // Encode config as base64 with proper UTF-8 handling\n const configJson = JSON.stringify(config)\n // Use encodeURIComponent to handle UTF-8 properly before base64\n const utf8Encoded = unescape(encodeURIComponent(configJson))\n const configBase64 = Buffer.from(utf8Encoded, 'binary').toString('base64')\n // Decode: atob -> decodeURIComponent(escape()) to restore UTF-8\n const configScript = `<script>globalThis.__DOCGEN_CONFIG__=JSON.parse(decodeURIComponent(escape(atob(\"${configBase64}\"))));</script>`\n return html.replace('</head>', `${configScript}\\n</head>`)\n }\n }\n }\n ],\n resolve: {\n alias: {\n '@': path.resolve(process.cwd(), 'src/client')\n }\n },\n define: {\n __DOCGEN_CONFIG__: JSON.stringify(config)\n }\n })\n \n // Generate additional static files\n await generateSitemap(options.output, config)\n await generateRobotsTxt(options.output, config)\n await copyAssets(options.output)\n \n console.log('✅ Build completed successfully!')\n \n } finally {\n // Clean up temporary config file\n try {\n await fs.unlink(configPath)\n } catch {\n // Ignore if file doesn't exist\n }\n }\n}\n\nasync function generateSitemap(outputDir: string, config: DocGenConfig) {\n console.log('📄 Generating sitemap...')\n \n const baseUrl = config.siteConfig.baseUrl.replace(/\\/$/, '')\n const urls: string[] = []\n \n // Add home page\n urls.push(`${baseUrl}/`)\n \n // Add all skill pages\n for (const file of config.files) {\n const route = getFileRoute(file.path, config.siteConfig.skillsDir)\n if (route !== '/') {\n urls.push(`${baseUrl}${route}`)\n }\n }\n \n const sitemap = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n${urls.map(url => ` <url>\n <loc>${url}</loc>\n <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.8</priority>\n </url>`).join('\\\\n')}\n</urlset>`\n \n await fs.writeFile(path.join(outputDir, 'sitemap.xml'), sitemap)\n}\n\nasync function generateRobotsTxt(outputDir: string, config: DocGenConfig) {\n console.log('🤖 Generating robots.txt...')\n \n const baseUrl = config.siteConfig.baseUrl.replace(/\\/$/, '')\n const robotsTxt = `User-agent: *\nAllow: /\n\nSitemap: ${baseUrl}/sitemap.xml`\n \n await fs.writeFile(path.join(outputDir, 'robots.txt'), robotsTxt)\n}\n\nasync function copyAssets(outputDir: string) {\n console.log('📁 Copying static assets...')\n \n // Create a simple favicon if it doesn't exist\n const faviconPath = path.join(outputDir, 'favicon.ico')\n \n try {\n await fs.access(faviconPath)\n } catch {\n // Create a simple SVG favicon\n const faviconSvg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\">\n <rect width=\"32\" height=\"32\" rx=\"4\" fill=\"#3182ce\"/>\n <text x=\"16\" y=\"22\" text-anchor=\"middle\" fill=\"white\" font-family=\"system-ui\" font-size=\"18\" font-weight=\"bold\">D</text>\n</svg>`\n \n await fs.writeFile(path.join(outputDir, 'favicon.svg'), faviconSvg)\n }\n}\n\nfunction getFileRoute(filePath: string, baseDir: string): string {\n // Normalize paths for comparison\n const normalizedFilePath = path.normalize(filePath)\n const normalizedBaseDir = path.normalize(baseDir)\n \n // Check if file is within base directory\n if (!normalizedFilePath.startsWith(normalizedBaseDir)) {\n return '/'\n }\n \n // Get relative path from base directory\n const relativePath = normalizedFilePath.slice(normalizedBaseDir.length)\n const segments = relativePath.split(path.sep).filter(Boolean)\n \n if (segments.length === 0) return '/'\n \n const lastSegment = segments[segments.length - 1]\n if (lastSegment.endsWith('.md')) {\n segments[segments.length - 1] = lastSegment.slice(0, -3)\n }\n \n // SKILL.md and README.md should map to parent directory route\n const finalSegment = segments[segments.length - 1]\n if (finalSegment === 'SKILL' || finalSegment === 'README') {\n segments.pop()\n }\n\n return '/' + segments.join('/')\n}\n\nexport async function buildForProduction(sourceDir: string, outputDir: string): Promise<DocGenConfig> {\n const { scanSkillsDirectory } = await import('../scanner/index.js')\n const { parseSkillsToConfig } = await import('../parser/index.js')\n \n const directories = await scanSkillsDirectory(sourceDir)\n const config = await parseSkillsToConfig(directories, {\n title: 'Documentation',\n description: 'Documentation generated from source directory',\n baseUrl: '/',\n skillsDir: sourceDir,\n outputDir\n })\n \n await buildSite({\n input: sourceDir,\n output: outputDir,\n mode: 'production'\n }, config)\n \n return config\n}","import path from 'path'\nimport fs from 'fs/promises'\nimport sirv from 'sirv'\nimport { createServer } from 'http'\n\ninterface PreviewOptions {\n port: string\n output: string\n}\n\nexport async function previewCommand(options: PreviewOptions) {\n console.log('👀 Starting DocGen preview server...')\n \n const outputDir = path.resolve(process.cwd(), options.output)\n const port = parseInt(options.port, 10)\n \n try {\n // Check if build directory exists\n try {\n await fs.access(outputDir)\n } catch {\n console.error(`❌ Build directory not found: ${outputDir}`)\n console.log('💡 Run \"docgen build\" first to generate the static site')\n process.exit(1)\n }\n \n // Create static file server\n const serve = sirv(outputDir, {\n single: true, // SPA mode\n dev: false,\n setHeaders: (res, pathname) => {\n if (pathname.endsWith('.html') || pathname === '/') {\n res.setHeader('Content-Type', 'text/html; charset=utf-8')\n }\n }\n })\n \n const server = createServer(serve)\n \n server.listen(port, () => {\n console.log(`🎉 Preview server running at http://localhost:${port}`)\n console.log(`📂 Serving files from: ${outputDir}`)\n })\n \n // Handle graceful shutdown\n process.on('SIGINT', () => {\n console.log('\\\\n👋 Shutting down preview server...')\n server.close(() => {\n process.exit(0)\n })\n })\n \n } catch (error) {\n console.error('❌ Failed to start preview server:', error)\n process.exit(1)\n }\n}"],"mappings":";;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAGjB,eAAsB,oBAAoB,WAA8C;AACtF,MAAI;AACF,UAAM,GAAG,OAAO,SAAS;AAAA,EAC3B,QAAQ;AACN,UAAM,IAAI,MAAM,+BAA+B,SAAS,EAAE;AAAA,EAC5D;AAEA,QAAM,UAAU,MAAM,GAAG,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC;AACnE,QAAM,cAAgC,CAAC;AAEvC,aAAW,SAAS,SAAS;AAC3B,QAAI,MAAM,YAAY,GAAG;AACvB,YAAM,UAAU,KAAK,KAAK,WAAW,MAAM,IAAI;AAC/C,YAAM,iBAAiB,MAAM,cAAc,SAAS,MAAM,IAAI;AAC9D,kBAAY,KAAK,cAAc;AAAA,IACjC;AAAA,EACF;AAEA,SAAO;AACT;AAEA,eAAe,cAAc,SAAiB,MAAuC;AACnF,QAAM,UAAU,MAAM,GAAG,QAAQ,SAAS,EAAE,eAAe,KAAK,CAAC;AACjE,QAAM,WAA2C,CAAC;AAClD,MAAI;AAEJ,aAAW,SAAS,SAAS;AAC3B,UAAM,YAAY,KAAK,KAAK,SA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O,EACf,SAAS,eAAe,6CAA6C,QAAQ,EAC7E,OAAO,qBAAqB,6BAA6B,MAAM,EAC/D,OAAO,CAAC,WAAW,YAAY;AAE9B,aAAW,EAAE,KAAK,WAAW,MAAM,QAAQ,KAAK,CAAC;AACnD,CAAC;AAEH,QACG,QAAQ,KAAK,EACb,YAAY,0BAA0B,EACtC,OAAO,qBAAqB,6BAA6B,MAAM,EAC/D,OAAO,yBAAyB,yBAAyB,QAAQ,EACjE,OAAO,UAAU;AAEpB,QACG,QAAQ,OAAO,EACf,YAAY,iCAAiC,EAC7C,OAAO,yBAAyB,yBAAyB,QAAQ,EACjE,OAAO,4BAA4B,oBAAoB,MAAM,EAC7D,OAAO,YAAY;AAEtB,QACG,QAAQ,SAAS,EACjB,YAAY,kCAAkC,EAC9C,OAAO,qBAAqB,iCAAiC,MAAM,EACnE,OAAO,4BAA4B,wBAAwB,MAAM,EACjE,OAAO,cAAc;AAExB,QAAQ,MAAM;","names":["segments","path","path","server","path","path","vue","path","fs","getFileRoute","path","path","fs","createServer"]}
|
|
1
|
+
{"version":3,"sources":["../src/scanner/index.ts","../src/parser/index.ts","../src/cli/index.ts","../src/cli/commands/dev.ts","../src/builder/vite-dev.ts","../src/cli/commands/build.ts","../src/builder/index.ts","../src/cli/commands/preview.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\nimport { SkillDirectory, SkillFile } from '../types/index.js'\n\nexport async function scanSkillsDirectory(sourceDir: string): Promise<SkillDirectory[]> {\n try {\n await fs.access(sourceDir)\n } catch {\n throw new Error(`Source directory not found: ${sourceDir}`)\n }\n\n const entries = await fs.readdir(sourceDir, { withFileTypes: true })\n const directories: SkillDirectory[] = []\n\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const dirPath = path.join(sourceDir, entry.name)\n const skillDirectory = await scanDirectory(dirPath, entry.name)\n directories.push(skillDirectory)\n }\n }\n\n return directories\n}\n\nasync function scanDirectory(dirPath: string, name: string): Promise<SkillDirectory> {\n const entries = await fs.readdir(dirPath, { withFileTypes: true })\n const children: (SkillDirectory | SkillFile)[] = []\n let skillFile: SkillFile | undefined\n\n for (const entry of entries) {\n const entryPath = path.join(dirPath, entry.name)\n\n if (entry.isDirectory()) {\n const subDir = await scanDirectory(entryPath, entry.name)\n children.push(subDir)\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n const file = await parseMarkdownFile(entryPath, entry.name)\n \n if (entry.name === 'SKILL.md') {\n skillFile = file\n } else {\n children.push(file)\n }\n }\n }\n\n return {\n path: dirPath,\n name,\n children,\n skillFile\n }\n}\n\nasync function parseMarkdownFile(filePath: string, fileName: string): Promise<SkillFile> {\n const content = await fs.readFile(filePath, 'utf-8')\n const stats = await fs.stat(filePath)\n\n // Basic frontmatter extraction\n const frontmatterMatch = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n/)\n const frontmatter: Record<string, any> = {}\n let markdownContent = content\n\n if (frontmatterMatch) {\n // Remove frontmatter from content\n markdownContent = content.slice(frontmatterMatch[0].length)\n \n // Parse frontmatter key-value pairs\n const fmLines = frontmatterMatch[1].split(/\\r?\\n/)\n for (const line of fmLines) {\n const colonIndex = line.indexOf(':')\n if (colonIndex > 0) {\n const key = line.slice(0, colonIndex).trim()\n const value = line.slice(colonIndex + 1).trim().replace(/^[\"']|[\"']$/g, '')\n if (key && value) {\n frontmatter[key] = value\n }\n }\n }\n }\n\n return {\n path: filePath,\n name: fileName,\n title: frontmatter.title || fileName.replace('.md', ''),\n description: frontmatter.description,\n content: markdownContent,\n frontmatter,\n lastModified: stats.mtime.getTime()\n }\n}\n\nexport async function watchSkillsDirectory(\n sourceDir: string, \n callback: (directories: SkillDirectory[]) => void\n) {\n const chokidar = await import('chokidar')\n \n const watcher = chokidar.watch(sourceDir, {\n ignored: /node_modules/,\n persistent: true,\n ignoreInitial: true\n })\n\n let debounceTimer: NodeJS.Timeout\n\n const handleChange = () => {\n clearTimeout(debounceTimer)\n debounceTimer = setTimeout(async () => {\n try {\n const directories = await scanSkillsDirectory(sourceDir)\n callback(directories)\n } catch (error) {\n console.error('Error rescanning source directory:', error)\n }\n }, 300)\n }\n\n watcher.on('add', handleChange)\n watcher.on('change', handleChange)\n watcher.on('unlink', handleChange)\n watcher.on('addDir', handleChange)\n watcher.on('unlinkDir', handleChange)\n\n return watcher\n}","import matter from 'gray-matter'\nimport MarkdownIt from 'markdown-it'\nimport { createHighlighter, Highlighter } from 'shiki'\nimport { SkillDirectory, SkillFile, SiteConfig, DocGenConfig, Navigation } from '../types/index.js'\n\nlet highlighter: Highlighter | null = null\n\nasync function getHighlighter() {\n if (!highlighter) {\n highlighter = await createHighlighter({\n themes: ['github-dark', 'github-light'],\n langs: ['javascript', 'typescript', 'bash', 'shell', 'json', 'html', 'css', 'vue', 'jsx', 'tsx', 'python', 'markdown', 'yaml', 'sql', 'go', 'rust', 'java', 'c', 'cpp']\n })\n }\n return highlighter\n}\n\nconst md = new MarkdownIt({\n html: true,\n linkify: true,\n typographer: true,\n highlight: function (str: string, lang: string) {\n // Synchronous fallback - actual highlighting done in enhanceFileContent\n return `<pre class=\"shiki-pending\" data-lang=\"${lang || 'text'}\"><code>${md.utils.escapeHtml(str)}</code></pre>`\n }\n})\n\nexport async function parseSkillsToConfig(\n directories: SkillDirectory[],\n siteConfig: SiteConfig\n): Promise<DocGenConfig> {\n const files: SkillFile[] = []\n const navigation = await generateNavigation(directories)\n\n // Collect all files for search indexing\n collectAllFiles(directories, files)\n\n // Enhance files with parsed content\n for (const file of files) {\n await enhanceFileContent(file)\n }\n\n return {\n siteConfig,\n navigation,\n files,\n directories\n }\n}\n\nfunction collectAllFiles(items: (SkillDirectory | SkillFile)[], files: SkillFile[]) {\n for (const item of items) {\n if ('content' in item) {\n // It's a SkillFile\n files.push(item)\n } else {\n // It's a SkillDirectory\n if (item.skillFile) {\n files.push(item.skillFile)\n }\n collectAllFiles(item.children, files)\n }\n }\n}\n\nasync function enhanceFileContent(file: SkillFile) {\n try {\n let content = file.content\n\n // Update title and description from frontmatter if available\n file.title = file.frontmatter.title || file.title\n file.description = file.frontmatter.description || file.description\n\n // Remove duplicate h1 if it matches frontmatter title\n if (file.frontmatter.title) {\n // Match first h1 heading in content (may have leading whitespace/newlines)\n const h1Match = content.match(/^\\s*#\\s+(.+)$/m)\n if (h1Match) {\n const h1Text = h1Match[1].trim()\n // If h1 matches title, remove it to avoid duplication\n if (h1Text === file.frontmatter.title) {\n content = content.replace(/^\\s*#\\s+.+\\n*/, '')\n }\n }\n }\n\n // Render markdown to HTML\n let html = md.render(content)\n \n // Apply syntax highlighting with shiki\n html = await highlightCodeBlocks(html)\n file.frontmatter.html = html\n\n // Extract headings for TOC\n const headings = extractHeadings(content)\n file.frontmatter.headings = headings\n\n } catch (error) {\n console.warn(`Failed to enhance content for ${file.path}:`, error)\n try {\n file.frontmatter.html = md.render(file.content)\n } catch (e) {\n console.error(`Failed to render markdown for ${file.path}:`, e)\n }\n }\n}\n\nasync function highlightCodeBlocks(html: string): Promise<string> {\n const hl = await getHighlighter()\n \n // Find all pending shiki code blocks and highlight them\n const codeBlockRegex = /<pre class=\"shiki-pending\" data-lang=\"([^\"]*)\"[^>]*><code>([^]*?)<\\/code><\\/pre>/g\n \n const matches = [...html.matchAll(codeBlockRegex)]\n \n for (const match of matches) {\n const [fullMatch, lang, escapedCode] = match\n // Unescape HTML entities\n const code = escapedCode\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/&/g, '&')\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n \n try {\n const validLang = hl.getLoadedLanguages().includes(lang) ? lang : 'text'\n const highlighted = hl.codeToHtml(code, {\n lang: validLang,\n theme: 'github-dark'\n })\n html = html.replace(fullMatch, highlighted)\n } catch (e) {\n // Keep original if highlighting fails\n console.warn(`Failed to highlight ${lang}:`, e)\n }\n }\n \n return html\n}\n\nfunction extractHeadings(content: string) {\n const headings: Array<{ level: number; text: string; anchor: string }> = []\n const lines = content.split('\\n')\n\n for (const line of lines) {\n const match = line.match(/^(#{1,6})\\\\s+(.+)$/)\n if (match) {\n const level = match[1].length\n const text = match[2].trim()\n const anchor = text.toLowerCase()\n .replace(/[^\\\\w\\\\s-]/g, '')\n .replace(/\\\\s+/g, '-')\n .trim()\n\n headings.push({ level, text, anchor })\n }\n }\n\n return headings\n}\n\nasync function generateNavigation(directories: SkillDirectory[]): Promise<Navigation[]> {\n const navigation: Navigation[] = []\n\n for (const dir of directories) {\n const navItem: Navigation = {\n text: dir.skillFile?.title || formatDirName(dir.name),\n link: dir.skillFile ? getFileRoute(dir.skillFile) : undefined\n }\n\n if (dir.children.length > 0) {\n navItem.children = []\n \n for (const child of dir.children) {\n if ('content' in child) {\n // It's a file\n navItem.children.push({\n text: child.title || formatFileName(child.name),\n link: getFileRoute(child)\n })\n } else {\n // It's a subdirectory\n const subNav = await generateNavigation([child])\n navItem.children.push(...subNav)\n }\n }\n }\n\n navigation.push(navItem)\n }\n\n return navigation\n}\n\nfunction getFileRoute(file: SkillFile): string {\n // Import the utility function from client utils\n // For now, use inline implementation\n const filePath = file.path\n \n // Try common patterns\n const patterns = ['my-docs', 'docs', 'documentation', '.claude/skills']\n let relativePath = ''\n \n for (const pattern of patterns) {\n const index = filePath.indexOf(pattern)\n if (index !== -1) {\n relativePath = filePath.slice(index + pattern.length)\n break\n }\n }\n \n if (!relativePath) {\n // Fallback: use last 2 segments\n const segments = filePath.split('/').filter(Boolean)\n if (segments.length >= 2) {\n relativePath = '/' + segments.slice(-2).join('/')\n } else {\n return '/'\n }\n }\n \n const segments = relativePath.split('/').filter(Boolean)\n \n if (segments.length === 0) return '/'\n \n // Remove file extension\n const lastSegment = segments[segments.length - 1]\n if (lastSegment.endsWith('.md')) {\n segments[segments.length - 1] = lastSegment.slice(0, -3)\n }\n \n // SKILL.md and README.md should map to parent directory route\n const finalSegment = segments[segments.length - 1]\n if (finalSegment === 'SKILL' || finalSegment === 'README') {\n segments.pop()\n }\n \n return '/' + segments.join('/')\n}\n\nfunction formatDirName(name: string): string {\n return name.split('-').map(word => \n word.charAt(0).toUpperCase() + word.slice(1)\n ).join(' ')\n}\n\nfunction formatFileName(name: string): string {\n const baseName = name.replace('.md', '')\n return formatDirName(baseName)\n}\n\nexport { md as markdownRenderer }","#!/usr/bin/env node\n\nimport { Command } from 'commander'\nimport { devCommand } from './commands/dev.js'\nimport { buildCommand } from './commands/build.js'\nimport { previewCommand } from './commands/preview.js'\n\nconst program = new Command()\n\nprogram\n .name('docmk')\n .description('CLI tool for generating documentation from any directory')\n .version('1.0.0')\n .argument('[directory]', 'Source directory path (starts dev server)', './docs')\n .option('-p, --port <port>', 'Port to run dev server on', '3000')\n .action((directory, options) => {\n // Default action: start dev server\n devCommand({ dir: directory, port: options.port })\n })\n\nprogram\n .command('dev')\n .description('Start development server')\n .option('-p, --port <port>', 'Port to run dev server on', '3000')\n .option('-d, --dir <directory>', 'Source directory path', './docs')\n .action(devCommand)\n\nprogram\n .command('build')\n .description('Build static documentation site')\n .option('-d, --dir <directory>', 'Source directory path', './docs')\n .option('-o, --output <directory>', 'Output directory', 'dist')\n .action(buildCommand)\n\nprogram\n .command('preview')\n .description('Preview built documentation site')\n .option('-p, --port <port>', 'Port to run preview server on', '4173')\n .option('-o, --output <directory>', 'Built site directory', 'dist')\n .action(previewCommand)\n\nprogram.parse()","import path from 'path'\nimport { createViteDevServer } from '../../builder/vite-dev.js'\nimport { scanSkillsDirectory } from '../../scanner/index.js'\nimport { parseSkillsToConfig } from '../../parser/index.js'\n\ninterface DevOptions {\n port: string\n dir: string\n}\n\nexport async function devCommand(options: DevOptions) {\n console.log('🚀 Starting DocGen development server...')\n \n const sourceDir = path.resolve(process.cwd(), options.dir)\n const port = parseInt(options.port, 10)\n \n try {\n // Check if source directory exists\n console.log(`📁 Scanning source directory: ${sourceDir}`)\n const directories = await scanSkillsDirectory(sourceDir)\n \n console.log(`✅ Found ${directories.length} directories`)\n \n // Parse to config\n const config = await parseSkillsToConfig(directories, {\n title: 'Documentation',\n description: 'Documentation generated from source directory',\n baseUrl: '/',\n skillsDir: sourceDir,\n outputDir: 'dist'\n })\n \n // Start Vite dev server\n const server = await createViteDevServer({\n port,\n skillsDir: sourceDir,\n config\n })\n \n console.log(`🎉 Dev server running at http://localhost:${port}`)\n \n // Handle graceful shutdown\n process.on('SIGINT', async () => {\n console.log('\\\\n👋 Shutting down dev server...')\n await server.close()\n process.exit(0)\n })\n \n } catch (error) {\n console.error('❌ Failed to start dev server:', error)\n process.exit(1)\n }\n}","import { createServer, ViteDevServer } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport path from 'path'\nimport { DocGenConfig } from '../types/index.js'\nimport { scanSkillsDirectory, watchSkillsDirectory } from '../scanner/index.js'\nimport { parseSkillsToConfig } from '../parser/index.js'\n\ninterface DevServerOptions {\n port: number\n skillsDir: string\n config: DocGenConfig\n}\n\nexport async function createViteDevServer(options: DevServerOptions): Promise<ViteDevServer> {\n let currentConfig = options.config\n\n const server = await createServer({\n root: path.resolve(process.cwd(), 'src/client'),\n server: {\n port: options.port,\n host: 'localhost'\n },\n publicDir: false, // Disable public dir in dev mode\n plugins: [\n vue(),\n // Custom plugin to inject config and handle API routes\n {\n name: 'docgen-dev',\n configureServer(server) {\n // API endpoint for configuration\n server.middlewares.use('/api/config', (req, res, next) => {\n if (req.method === 'GET') {\n res.setHeader('Content-Type', 'application/json')\n res.end(JSON.stringify(currentConfig))\n } else {\n next()\n }\n })\n\n // SPA fallback - return index.html for all non-API routes\n return () => {\n server.middlewares.use((req, res, next) => {\n // Skip API routes and vite's own routes\n if (req.url?.startsWith('/api/') || req.url?.startsWith('/@') || req.url?.includes('.html')) {\n return next()\n }\n // For all other routes, serve index.html for SPA routing\n if (req.url && !req.url.includes('.')) {\n req.url = '/index.html'\n }\n next()\n })\n }\n },\n transformIndexHtml: {\n order: 'pre',\n handler(html) {\n // Inject lightweight config placeholder\n // Full config will be loaded via API to avoid HTML parsing issues\n const configScript = `\n <script>\n // Config will be loaded from /api/config\n globalThis.__DOCGEN_CONFIG__ = null;\n </script>\n `\n return html.replace('<head>', `<head>${configScript}`)\n }\n }\n }\n ],\n resolve: {\n alias: {\n '@': path.resolve(process.cwd(), 'src/client')\n }\n },\n define: {\n __DOCGEN_CONFIG__: JSON.stringify(currentConfig)\n }\n })\n\n // Watch skills directory for changes\n const watcher = await watchSkillsDirectory(options.skillsDir, async (directories) => {\n console.log('📝 Skills directory changed, updating configuration...')\n \n try {\n currentConfig = await parseSkillsToConfig(directories, currentConfig.siteConfig)\n \n // Notify all connected clients to reload\n server.ws.send({\n type: 'full-reload'\n })\n \n console.log('✅ Configuration updated')\n } catch (error) {\n console.error('❌ Failed to update configuration:', error)\n \n // Send error to clients\n server.ws.send({\n type: 'error',\n err: {\n message: `Failed to update configuration: ${error.message}`,\n stack: error.stack\n }\n })\n }\n })\n\n // Start the server\n await server.listen()\n\n // Extend server with cleanup method\n const originalClose = server.close.bind(server)\n server.close = async () => {\n await watcher?.close()\n return originalClose()\n }\n\n return server\n}\n\nexport async function createProductionBuild() {\n // This will be implemented in the builder\n}","import path from 'path'\nimport { buildSite } from '../../builder/index.js'\nimport { scanSkillsDirectory } from '../../scanner/index.js'\nimport { parseSkillsToConfig } from '../../parser/index.js'\n\ninterface BuildOptions {\n dir: string\n output: string\n}\n\nexport async function buildCommand(options: BuildOptions) {\n console.log('🏗️ Building DocGen documentation site...')\n \n const sourceDir = path.resolve(process.cwd(), options.dir)\n const outputDir = path.resolve(process.cwd(), options.output)\n \n try {\n // Scan source directory\n console.log(`📁 Scanning source directory: ${sourceDir}`)\n const directories = await scanSkillsDirectory(sourceDir)\n \n console.log(`✅ Found ${directories.length} directories`)\n \n // Parse to config\n const config = await parseSkillsToConfig(directories, {\n title: 'Documentation',\n description: 'Documentation generated from source directory',\n baseUrl: '/',\n skillsDir: sourceDir,\n outputDir\n })\n \n // Build site\n console.log(`📦 Building to: ${outputDir}`)\n await buildSite({\n input: sourceDir,\n output: outputDir,\n mode: 'production'\n }, config)\n \n console.log('✅ Build completed successfully!')\n console.log(`📂 Built files are in: ${outputDir}`)\n \n } catch (error) {\n console.error('❌ Build failed:', error)\n process.exit(1)\n }\n}","import { build } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport path from 'path'\nimport fs from 'fs/promises'\nimport { DocGenConfig, BuildOptions } from '../types/index.js'\n\nexport async function buildSite(options: BuildOptions, config: DocGenConfig) {\n console.log('🏗️ Building documentation site...')\n \n // Ensure output directory exists\n await fs.mkdir(options.output, { recursive: true })\n \n // Write config to a temporary file for the build process\n const configPath = path.join(process.cwd(), 'temp-config.json')\n await fs.writeFile(configPath, JSON.stringify(config, null, 2))\n \n try {\n // Build the client application\n await build({\n root: path.resolve(process.cwd(), 'src/client'),\n base: config.siteConfig.baseUrl,\n build: {\n outDir: options.output,\n emptyOutDir: true,\n rollupOptions: {\n input: {\n main: path.resolve(process.cwd(), 'src/client/index.html')\n }\n }\n },\n plugins: [\n vue(),\n // Plugin to inject config during build\n {\n name: 'docgen-build',\n transformIndexHtml: {\n order: 'pre',\n handler(html) {\n // Encode config as base64 with proper UTF-8 handling\n const configJson = JSON.stringify(config)\n // Use encodeURIComponent to handle UTF-8 properly before base64\n const utf8Encoded = unescape(encodeURIComponent(configJson))\n const configBase64 = Buffer.from(utf8Encoded, 'binary').toString('base64')\n // Decode: atob -> decodeURIComponent(escape()) to restore UTF-8\n const configScript = `<script>globalThis.__DOCGEN_CONFIG__=JSON.parse(decodeURIComponent(escape(atob(\"${configBase64}\"))));</script>`\n return html.replace('</head>', `${configScript}\\n</head>`)\n }\n }\n }\n ],\n resolve: {\n alias: {\n '@': path.resolve(process.cwd(), 'src/client')\n }\n },\n define: {\n __DOCGEN_CONFIG__: JSON.stringify(config)\n }\n })\n \n // Generate additional static files\n await generateSitemap(options.output, config)\n await generateRobotsTxt(options.output, config)\n await copyAssets(options.output)\n \n console.log('✅ Build completed successfully!')\n \n } finally {\n // Clean up temporary config file\n try {\n await fs.unlink(configPath)\n } catch {\n // Ignore if file doesn't exist\n }\n }\n}\n\nasync function generateSitemap(outputDir: string, config: DocGenConfig) {\n console.log('📄 Generating sitemap...')\n \n const baseUrl = config.siteConfig.baseUrl.replace(/\\/$/, '')\n const urls: string[] = []\n \n // Add home page\n urls.push(`${baseUrl}/`)\n \n // Add all skill pages\n for (const file of config.files) {\n const route = getFileRoute(file.path, config.siteConfig.skillsDir)\n if (route !== '/') {\n urls.push(`${baseUrl}${route}`)\n }\n }\n \n const sitemap = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n${urls.map(url => ` <url>\n <loc>${url}</loc>\n <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.8</priority>\n </url>`).join('\\\\n')}\n</urlset>`\n \n await fs.writeFile(path.join(outputDir, 'sitemap.xml'), sitemap)\n}\n\nasync function generateRobotsTxt(outputDir: string, config: DocGenConfig) {\n console.log('🤖 Generating robots.txt...')\n \n const baseUrl = config.siteConfig.baseUrl.replace(/\\/$/, '')\n const robotsTxt = `User-agent: *\nAllow: /\n\nSitemap: ${baseUrl}/sitemap.xml`\n \n await fs.writeFile(path.join(outputDir, 'robots.txt'), robotsTxt)\n}\n\nasync function copyAssets(outputDir: string) {\n console.log('📁 Copying static assets...')\n \n // Create a simple favicon if it doesn't exist\n const faviconPath = path.join(outputDir, 'favicon.ico')\n \n try {\n await fs.access(faviconPath)\n } catch {\n // Create a simple SVG favicon\n const faviconSvg = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\">\n <rect width=\"32\" height=\"32\" rx=\"4\" fill=\"#3182ce\"/>\n <text x=\"16\" y=\"22\" text-anchor=\"middle\" fill=\"white\" font-family=\"system-ui\" font-size=\"18\" font-weight=\"bold\">D</text>\n</svg>`\n \n await fs.writeFile(path.join(outputDir, 'favicon.svg'), faviconSvg)\n }\n}\n\nfunction getFileRoute(filePath: string, baseDir: string): string {\n // Normalize paths for comparison\n const normalizedFilePath = path.normalize(filePath)\n const normalizedBaseDir = path.normalize(baseDir)\n \n // Check if file is within base directory\n if (!normalizedFilePath.startsWith(normalizedBaseDir)) {\n return '/'\n }\n \n // Get relative path from base directory\n const relativePath = normalizedFilePath.slice(normalizedBaseDir.length)\n const segments = relativePath.split(path.sep).filter(Boolean)\n \n if (segments.length === 0) return '/'\n \n const lastSegment = segments[segments.length - 1]\n if (lastSegment.endsWith('.md')) {\n segments[segments.length - 1] = lastSegment.slice(0, -3)\n }\n \n // SKILL.md and README.md should map to parent directory route\n const finalSegment = segments[segments.length - 1]\n if (finalSegment === 'SKILL' || finalSegment === 'README') {\n segments.pop()\n }\n\n return '/' + segments.join('/')\n}\n\nexport async function buildForProduction(sourceDir: string, outputDir: string): Promise<DocGenConfig> {\n const { scanSkillsDirectory } = await import('../scanner/index.js')\n const { parseSkillsToConfig } = await import('../parser/index.js')\n \n const directories = await scanSkillsDirectory(sourceDir)\n const config = await parseSkillsToConfig(directories, {\n title: 'Documentation',\n description: 'Documentation generated from source directory',\n baseUrl: '/',\n skillsDir: sourceDir,\n outputDir\n })\n \n await buildSite({\n input: sourceDir,\n output: outputDir,\n mode: 'production'\n }, config)\n \n return config\n}","import path from 'path'\nimport fs from 'fs/promises'\nimport sirv from 'sirv'\nimport { createServer } from 'http'\n\ninterface PreviewOptions {\n port: string\n output: string\n}\n\nexport async function previewCommand(options: PreviewOptions) {\n console.log('👀 Starting DocGen preview server...')\n \n const outputDir = path.resolve(process.cwd(), options.output)\n const port = parseInt(options.port, 10)\n \n try {\n // Check if build directory exists\n try {\n await fs.access(outputDir)\n } catch {\n console.error(`❌ Build directory not found: ${outputDir}`)\n console.log('💡 Run \"docgen build\" first to generate the static site')\n process.exit(1)\n }\n \n // Create static file server\n const serve = sirv(outputDir, {\n single: true, // SPA mode\n dev: false,\n setHeaders: (res, pathname) => {\n if (pathname.endsWith('.html') || pathname === '/') {\n res.setHeader('Content-Type', 'text/html; charset=utf-8')\n }\n }\n })\n \n const server = createServer(serve)\n \n server.listen(port, () => {\n console.log(`🎉 Preview server running at http://localhost:${port}`)\n console.log(`📂 Serving files from: ${outputDir}`)\n })\n \n // Handle graceful shutdown\n process.on('SIGINT', () => {\n console.log('\\\\n👋 Shutting down preview server...')\n server.close(() => {\n process.exit(0)\n })\n })\n \n } catch (error) {\n console.error('❌ Failed to start preview server:', error)\n process.exit(1)\n }\n}"],"mappings":";;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAGjB,eAAsB,oBAAoB,WAA8C;AACtF,MAAI;AACF,UAAM,GAAG,OAAO,SAAS;AAAA,EAC3B,QAAQ;AACN,UAAM,IAAI,MAAM,+BAA+B,SAAS,EAAE;AAAA,EAC5D;AAEA,QAAM,UAAU,MAAM,GAAG,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC;AACnE,QAAM,cAAgC,CAAC;AAEvC,aAAW,SAAS,SAAS;AAC3B,QAAI,MAAM,YAAY,GAAG;AACvB,YAAM,UAAU,KAAK,KAAK,WAAW,MAAM,IAAI;AAC/C,YAAM,iBAAiB,MAAM,cAAc,SAAS,MAAM,IAAI;AAC9D,kBAAY,KAAK,cAAc;AAAA,IACjC;AAAA,EACF;AAEA,SAAO;AACT;AAEA,eAAe,cAAc,SAAiB,MAAuC;AACnF,QAAM,UAAU,MAAM,GAAG,QAAQ,SAAS,EAAE,eAAe,KAAK,CAAC;AACjE,QAAM,WAA2C,CAAC;AAClD,MAAI;AAEJ,aAAW,SAAS,SAAS;AAC3B,UAAM,YAAY,KAAK,KAAK,SAAS,MAAM,IAAI;AAE/C,QAAI,MAAM,YAAY,GAAG;AACvB,YAAM,SAAS,MAAM,cAAc,WAAW,MAAM,IAAI;AACxD,eAAS,KAAK,MAAM;AAAA,IACtB,WAAW,MAAM,OAAO,KAAK,MAAM,KAAK,SAAS,KAAK,GAAG;AACvD,YAAM,OAAO,MAAM,kBAAkB,WAAW,MAAM,IAAI;AAE1D,UAAI,MAAM,SAAS,YAAY;A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O,CAAC,WAAW,YAAY;AAE9B,aAAW,EAAE,KAAK,WAAW,MAAM,QAAQ,KAAK,CAAC;AACnD,CAAC;AAEH,QACG,QAAQ,KAAK,EACb,YAAY,0BAA0B,EACtC,OAAO,qBAAqB,6BAA6B,MAAM,EAC/D,OAAO,yBAAyB,yBAAyB,QAAQ,EACjE,OAAO,UAAU;AAEpB,QACG,QAAQ,OAAO,EACf,YAAY,iCAAiC,EAC7C,OAAO,yBAAyB,yBAAyB,QAAQ,EACjE,OAAO,4BAA4B,oBAAoB,MAAM,EAC7D,OAAO,YAAY;AAEtB,QACG,QAAQ,SAAS,EACjB,YAAY,kCAAkC,EAC9C,OAAO,qBAAqB,iCAAiC,MAAM,EACnE,OAAO,4BAA4B,wBAAwB,MAAM,EACjE,OAAO,cAAc;AAExB,QAAQ,MAAM;","names":["segments","path","path","server","path","path","vue","path","fs","getFileRoute","path","path","fs","createServer"]}
|
package/package.json
CHANGED
package/src/builder/vite-dev.ts
CHANGED
|
@@ -20,6 +20,7 @@ export async function createViteDevServer(options: DevServerOptions): Promise<Vi
|
|
|
20
20
|
port: options.port,
|
|
21
21
|
host: 'localhost'
|
|
22
22
|
},
|
|
23
|
+
publicDir: false, // Disable public dir in dev mode
|
|
23
24
|
plugins: [
|
|
24
25
|
vue(),
|
|
25
26
|
// Custom plugin to inject config and handle API routes
|
|
@@ -36,15 +37,20 @@ export async function createViteDevServer(options: DevServerOptions): Promise<Vi
|
|
|
36
37
|
}
|
|
37
38
|
})
|
|
38
39
|
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//
|
|
40
|
+
// SPA fallback - return index.html for all non-API routes
|
|
41
|
+
return () => {
|
|
42
|
+
server.middlewares.use((req, res, next) => {
|
|
43
|
+
// Skip API routes and vite's own routes
|
|
44
|
+
if (req.url?.startsWith('/api/') || req.url?.startsWith('/@') || req.url?.includes('.html')) {
|
|
45
|
+
return next()
|
|
46
|
+
}
|
|
47
|
+
// For all other routes, serve index.html for SPA routing
|
|
48
|
+
if (req.url && !req.url.includes('.')) {
|
|
49
|
+
req.url = '/index.html'
|
|
50
|
+
}
|
|
43
51
|
next()
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
})
|
|
52
|
+
})
|
|
53
|
+
}
|
|
48
54
|
},
|
|
49
55
|
transformIndexHtml: {
|
|
50
56
|
order: 'pre',
|