@stacksjs/bunpress 0.1.13 → 0.1.14

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.
@@ -1,496 +0,0 @@
1
- // @bun
2
- import{L}from"./chunk-pa3gwajr.js";import{N as v}from"./chunk-43fsk0jg.js";var{Glob:L6}=globalThis.Bun;import{copyFile as M4,mkdir as I6,readdir as R4}from"fs/promises";import{join as F}from"path";import E from"process";import{CLI as O4}from"@stacksjs/clapp";var K6="0.1.13";import*as Q6 from"fs";import*as Z6 from"path";async function $6(K,Z){let Q=Z.robots;if(Q?.enabled===!1)return;let $=Q?.filename||"robots.txt",Y=D6(Z),N=Z6.join(K,$);if(await Q6.promises.writeFile(N,Y,"utf-8"),Z.verbose)console.log(`\u2705 Robots.txt generated: ${N}`)}function D6(K){let Z=K.robots,Q=[];if(Z?.rules&&Z.rules.length>0)for(let $ of Z.rules)Q.push(...k6($)),Q.push("");else Q.push("User-agent: *"),Q.push("Allow: /"),Q.push("");if(Z?.host)Q.push(`Host: ${Z.host}`),Q.push("");if(Z?.sitemaps&&Z.sitemaps.length>0){for(let $ of Z.sitemaps)Q.push(`Sitemap: ${$}`);Q.push("")}else if(K.sitemap?.enabled!==!1&&K.sitemap?.baseUrl){let $=K.sitemap.filename||"sitemap.xml",Y=`${K.sitemap.baseUrl.replace(/\/$/,"")}/${$}`;Q.push(`Sitemap: ${Y}`),Q.push("")}if(Z?.customContent)Q.push(Z.customContent),Q.push("");return`${Q.join(`
3
- `).trim()}
4
- `}function k6(K){let Z=[];if(Z.push(`User-agent: ${K.userAgent}`),K.allow&&K.allow.length>0)for(let Q of K.allow)Z.push(`Allow: ${Q}`);if(K.disallow&&K.disallow.length>0)for(let Q of K.disallow)Z.push(`Disallow: ${Q}`);if(K.crawlDelay!==void 0)Z.push(`Crawl-delay: ${K.crawlDelay}`);return Z}var{YAML:C6}=globalThis.Bun;import*as u from"fs";import*as d from"path";async function P6(K,Z,Q){let $=Z.sitemap?.baseUrl||"",Y=Q?.title||Z.title||Z.markdown?.title||"Documentation Feed",N=Q?.description||Z.description||Z.markdown?.meta?.description||"Documentation updates",H=Q?.author||"Documentation Team",X=Q?.email||"",W=Q?.language||"en-us",j=Q?.maxItems||20,V=Q?.fullContent||!1,q=await h6(K,$,V);q.sort((_,J)=>J.pubDate.getTime()-_.pubDate.getTime());let G=q.slice(0,j);return p6({title:Y,description:N,link:$,language:W,author:H,email:X,items:G})}async function N6(K,Z,Q,$){if(!$?.enabled)return;if(!Q.sitemap?.baseUrl){if(Q.verbose)console.warn("\u26A0\uFE0F RSS feed generation skipped: baseUrl not configured");return}let Y=await P6(K,Q,$),N=$.filename||"feed.xml",H=d.join(Z,N);if(await u.promises.writeFile(H,Y,"utf-8"),Q.verbose){let X=(Y.match(/<item>/g)||[]).length;console.log(`\u2705 RSS feed generated: ${H} (${X} items)`)}}async function h6(K,Z,Q){let $=[],Y=await m6(K);for(let N of Y){let H=await u.promises.readFile(N,"utf-8"),{frontmatter:X,markdown:W}=d6(H);if(!X.date||!X.title)continue;let V=d.relative(K,N).replace(/\.md$/,"").replace(/index$/,"").replace(/\\/g,"/");if(!V.startsWith("/"))V=`/${V}`;if(V.endsWith("/")&&V!=="/")V=V.slice(0,-1);let q=`${Z.replace(/\/$/,"")}${V}`,G=X.description||g6(W),_=new Date(X.date),J=X.author;$.push({title:X.title,link:q,description:G,pubDate:_,author:J,content:Q?W:void 0})}return $}async function m6(K){let Z=[];async function Q($){let Y=await u.promises.readdir($,{withFileTypes:!0});for(let N of Y){let H=d.join($,N.name);if(N.isDirectory()){if(!N.name.startsWith(".")&&N.name!=="node_modules")await Q(H)}else if(N.isFile()&&N.name.endsWith(".md"))Z.push(H)}}return await Q(K),Z}function d6(K){let Z=/^---\n([\s\S]*?)\n---\n?/,Q=K.match(Z);if(!Q)return{frontmatter:{},markdown:K};let $=Q[1],Y=K.slice(Q[0].length);try{return{frontmatter:C6.parse($),markdown:Y}}catch{return{frontmatter:{},markdown:K}}}function g6(K,Z=200){let Q=K.replace(/^#{1,6}\s+(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])$/gm,"").replace(/```[\s\S]*?```/g,"").replace(/`[^`]+`/g,"").replace(/!\[.*?\]\(.*?\)/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_~]/g,"").trim(),$=Q.split(`
5
-
6
- `)[0]||Q;if($.length>Z)return`${$.slice(0,Z)}...`;return $}function p6(K){let Z=new Date,Q=K.items.length>0?K.items[0].pubDate:Z,$=K.items.map((Y)=>{let N=Y.content?`
7
- <content:encoded><![CDATA[${Y.content}]]></content:encoded>`:"",H=Y.author?`
8
- <dc:creator><![CDATA[${Y.author}]]></dc:creator>`:"";return` <item>
9
- <title><![CDATA[${Y.title}]]></title>
10
- <link>${Y.link}</link>
11
- <guid>${Y.link}</guid>
12
- <description><![CDATA[${Y.description}]]></description>
13
- <pubDate>${Y.pubDate.toUTCString()}</pubDate>${H}${N}
14
- </item>`}).join(`
15
- `);return['<?xml version="1.0" encoding="UTF-8"?>','<rss version="2.0"',' xmlns:content="http://purl.org/rss/1.0/modules/content/"',' xmlns:dc="http://purl.org/dc/elements/1.1/"',' xmlns:atom="http://www.w3.org/2005/Atom">'," <channel>",` <title><![CDATA[${K.title}]]></title>`,` <description><![CDATA[${K.description}]]></description>`,` <link>${K.link}</link>`,` <language>${K.language}</language>`,` <lastBuildDate>${Q.toUTCString()}</lastBuildDate>`,` <atom:link href="${K.link}/feed.xml" rel="self" type="application/rss+xml"/>`,$," </channel>","</rss>"].join(`
16
- `)}import*as C from"fs";import*as D from"path";async function u6(K,Z,Q){let $=Z.sitemap,Y=await c6(K,Q,$?.defaultPriority??0.5,$?.defaultChangefreq||"monthly",$?.exclude||[],$?.priorityMap||{},$?.changefreqMap||{});return $?.transform?Y.map((N)=>$.transform(N)).filter(Boolean):Y}async function Y6(K,Z,Q){let $=Q.sitemap;if($?.enabled===!1)return;if(!$?.baseUrl){if(Q.verbose)console.warn("\u26A0\uFE0F Sitemap generation skipped: baseUrl not configured");return}let Y=$.baseUrl.replace(/\/$/,""),N=$.filename||"sitemap.xml",H=$.maxUrlsPerFile||50000,X=$.useSitemapIndex||!1,W=await u6(K,Q,Y);if(Q.verbose)console.log(`\uD83D\uDCC4 Generated ${W.length} sitemap entries`);if(X&&W.length>H)await a6(W,Z,Y,N,H);else{let j=H6(W,Y),V=D.join(Z,N);if(await C.promises.writeFile(V,j,"utf-8"),Q.verbose)console.log(`\u2705 Sitemap generated: ${V}`)}}async function c6(K,Z,Q,$,Y,N,H){let X=[],W=await f6(K);for(let j of W){let q=D.relative(K,j).replace(/\.md$/,"").replace(/index$/,"").replace(/\\/g,"/");if(!q.startsWith("/"))q=`/${q}`;if(q.endsWith("/")&&q!=="/")q=q.slice(0,-1);if(l6(q,Y))continue;let _=(await C.promises.stat(j)).mtime.toISOString(),J=Q;for(let[S,A]of Object.entries(N))if(n(q,S)){J=A;break}let U=$;for(let[S,A]of Object.entries(H))if(n(q,S)){U=A;break}X.push({url:q,lastmod:_,changefreq:U,priority:J})}return X}async function f6(K){let Z=[];async function Q($){let Y=await C.promises.readdir($,{withFileTypes:!0});for(let N of Y){let H=D.join($,N.name);if(N.isDirectory()){if(!N.name.startsWith(".")&&N.name!=="node_modules")await Q(H)}else if(N.isFile()&&N.name.endsWith(".md"))Z.push(H)}}return await Q(K),Z}function l6(K,Z){for(let Q of Z)if(n(K,Q))return!0;return!1}function n(K,Z){let Q=Z.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*").replace(/\?/g,".");return new RegExp(`^${Q}$`).test(K)}function H6(K,Z=""){let Q=Z.replace(/\/$/,"");return`<?xml version="1.0" encoding="UTF-8"?>
17
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
18
- ${K.map((Y)=>{let N=/^https?:\/\//.test(Y.url)?Y.url:`${Q}${Y.url}`,H=Y.lastmod?`
19
- <lastmod>${X6(Y.lastmod)}</lastmod>`:"",X=Y.changefreq?`
20
- <changefreq>${Y.changefreq}</changefreq>`:"",W=Y.priority!==void 0?`
21
- <priority>${Y.priority.toFixed(1)}</priority>`:"";return` <url>
22
- <loc>${N}</loc>${H}${X}${W}
23
- </url>`}).join(`
24
- `)}
25
- </urlset>`}async function a6(K,Z,Q,$,Y){let N=n6(K,Y),H=[];for(let V=0;V<N.length;V++){let q=`sitemap-${V+1}.xml`,G=H6(N[V],Q),_=D.join(Z,q);await C.promises.writeFile(_,G,"utf-8"),H.push(q)}let W=`<?xml version="1.0" encoding="UTF-8"?>
26
- <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
27
- ${H.map((V)=>{let q=`${Q}/${V}`,G=new Date().toISOString();return` <sitemap>
28
- <loc>${q}</loc>
29
- <lastmod>${X6(G)}</lastmod>
30
- </sitemap>`}).join(`
31
- `)}
32
- </sitemapindex>`,j=D.join(Z,$);await C.promises.writeFile(j,W,"utf-8")}function X6(K){return(typeof K==="string"?new Date(K):K).toISOString().split("T")[0]}function n6(K,Z){let Q=[];for(let $=0;$<K.length;$+=Z)Q.push(K.slice($,$+Z));return Q}import{existsSync as s6}from"fs";import{rm as i6}from"fs/promises";import{join as r6}from"path";var x={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m"};function z(K,Z){return`${x[Z]}${K}${x.reset}`}function T(K){console.log(`${x.green}\u2713${x.reset} ${K}`)}function B(K){console.error(`${x.red}\u2717${x.reset} ${K}`)}function c(K){console.warn(`${x.yellow}\u26A0${x.reset} ${K}`)}function O(K){console.log(`${x.blue}\u2139${x.reset} ${K}`)}function b(K){if(K===0)return"0 B";let Z=1024,Q=["B","KB","MB","GB"],$=Math.floor(Math.log(K)/Math.log(Z));return`${Number.parseFloat((K/Z**$).toFixed(2))} ${Q[$]}`}function s(K){if(K<1000)return`${K}ms`;if(K<60000)return`${(K/1000).toFixed(2)}s`;return`${(K/60000).toFixed(2)}m`}var _6=!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.BUILDKITE||process.env.CIRCLECI||process.env.GITLAB_CI);class k{frames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];index=0;interval=null;text;constructor(K){this.text=K}start(){if(_6){console.log(` ${this.text}`);return}process.stdout.write("\x1B[?25l"),this.interval=setInterval(()=>{let K=this.frames[this.index];process.stdout.write(`\r${x.cyan}${K}${x.reset} ${this.text}`),this.index=(this.index+1)%this.frames.length},80)}succeed(K){this.stop(),T(K||this.text)}fail(K){this.stop(),B(K||this.text)}stop(){if(this.interval)clearInterval(this.interval),this.interval=null;if(!_6)process.stdout.write("\r\x1B[K"),process.stdout.write("\x1B[?25h")}update(K){this.text=K}}async function f(K,Z=!1){let Q=Z?"Y/n":"y/N";process.stdout.write(`${x.cyan}?${x.reset} ${K} ${x.dim}(${Q})${x.reset}: `);let $=Bun.file("/dev/stdin").stream().getReader(),Y=new TextDecoder,{value:N}=await $.read(),H=Y.decode(N).trim().toLowerCase();if(!H)return Z;return H==="y"||H==="yes"}function g(K){if(K.length===0)return;let Z=Object.keys(K[0]),Q={};for(let Y of Z)Q[Y]=Math.max(Y.length,...K.map((N)=>String(N[Y]).length));let $=Z.map((Y)=>Y.padEnd(Q[Y])).join(" ");console.log(z($,"bold")),console.log("\u2500".repeat($.length));for(let Y of K){let N=Z.map((H)=>String(Y[H]).padEnd(Q[H])).join(" ");console.log(N)}}async function l(K){try{return Bun.file(K).size}catch{return 0}}async function o6(K){try{let{Glob:Z}=awaitPromise.resolve(globalThis.Bun),Q=new Z("**/*"),$=0;for await(let Y of Q.scan(K)){let N=`${K}/${Y}`,H=await l(N);$+=H}return $}catch{return 0}}async function W6(K={}){let Z=await L,Q=K.outdir||Z.outDir||"./dist",$=r6(Q,".bunpress"),Y=K.force||!1,N=K.verbose||!1;try{if(!s6($))return O(`Directory "${$}" does not exist, nothing to clean`),!0;let X=await o6($);if(N)O(`Found "${$}" (${b(X)})`);if(!Y){if(!await f(`Delete "${$}" directory? (${b(X)})`,!1))return O("Clean cancelled"),!1}let W=process.env.VITEST==="true"||!1,j=null;if(!W&&!N)j=new k("Cleaning build artifacts..."),j.start();if(await i6($,{recursive:!0,force:!0}),j)j.succeed(`Cleaned ${b(X)} from "${$}"`);else if(N||W)T(`Cleaned ${b(X)} from "${$}"`);return!0}catch(H){return B(`Failed to clean directory: ${H}`),!1}}import{existsSync as i}from"fs";import{join as r}from"path";async function V6(K={}){try{let Z=["bunpress.config.ts","bunpress.config.js"],Q=null;for(let Y of Z){let N=r(process.cwd(),Y);if(i(N)){Q=N;break}}if(!Q)return B("No configuration file found"),O('Run "bunpress config init" to create one'),!1;T(`Configuration file: ${Q}`),console.log();let $=await Bun.file(Q).text();return console.log(z("Configuration:","bold")),console.log($),!0}catch(Z){return B(`Failed to show configuration: ${Z}`),!1}}async function j6(K={}){let Z=K.verbose||!1;try{let Q=["bunpress.config.ts","bunpress.config.js"],$=null;for(let X of Q){let W=r(process.cwd(),X);if(i(W)){$=W;break}}if(!$)return B("No configuration file found"),!1;if(Z)O(`Validating ${$}...`);let N=(await import($)).default;if(!N)return B("Configuration file does not export a default object"),!1;let H=[];if(N.markdown){if(N.markdown.toc&&typeof N.markdown.toc!=="object"&&typeof N.markdown.toc!=="boolean")H.push("markdown.toc should be an object or boolean");if(N.markdown.features){if(typeof N.markdown.features!=="object")H.push("markdown.features should be an object")}}if(N.nav){if(!Array.isArray(N.nav))H.push("nav should be an array");else for(let[X,W]of N.nav.entries())if(!W.text||!W.link)H.push(`nav[${X}] is missing required fields (text, link)`)}if(N.sitemap){if(!N.sitemap.hostname)H.push("sitemap.hostname is required for SEO")}if(H.length>0){B("Configuration validation failed:");for(let X of H)console.log(` \u2022 ${X}`);return!1}return T("Configuration is valid \u2713"),!0}catch(Q){return B(`Failed to validate configuration: ${Q}`),!1}}async function q6(K={}){let Z=r(process.cwd(),"bunpress.config.ts");if(i(Z))return B("Configuration file already exists"),!1;let Q=`import type { BunPressConfig } from '@stacksjs/bunpress'
33
-
34
- export default {
35
- verbose: false,
36
-
37
- markdown: {
38
- toc: {
39
- enabled: true,
40
- position: 'sidebar',
41
- minDepth: 2,
42
- maxDepth: 3,
43
- },
44
- features: {
45
- inlineFormatting: true,
46
- containers: true,
47
- githubAlerts: true,
48
- codeBlocks: {
49
- lineNumbers: true,
50
- lineHighlighting: true,
51
- focus: true,
52
- diff: true,
53
- errorWarning: true,
54
- },
55
- codeGroups: true,
56
- codeImports: true,
57
- inlineToc: true,
58
- customAnchors: true,
59
- emoji: true,
60
- badges: true,
61
- includes: true,
62
- externalLinks: {
63
- enabled: true,
64
- openInNewTab: true,
65
- addIcon: true,
66
- },
67
- imageLazyLoading: true,
68
- tables: {
69
- responsive: true,
70
- striped: true,
71
- hover: true,
72
- },
73
- },
74
- },
75
-
76
- nav: [
77
- { text: 'Home', link: '/' },
78
- { text: 'Guide', link: '/guide/' },
79
- ],
80
-
81
- sitemap: {
82
- hostname: 'https://example.com',
83
- },
84
- } satisfies BunPressConfig
85
- `;try{return await Bun.write(Z,Q),T(`Created ${Z}`),!0}catch($){return B(`Failed to create configuration: ${$}`),!1}}import{existsSync as P}from"fs";import{join as h}from"path";async function B6(K={}){let Z=K.verbose||!1,Q=[];console.log(z(`
86
- Running diagnostics...
87
- `,"bold"));try{let _=Bun.version;Q.push({name:"Bun Runtime",status:"pass",message:`v${_}`})}catch(_){Q.push({name:"Bun Runtime",status:"fail",message:"Not found"})}let $=["bunpress.config.ts","bunpress.config.js"],Y=!1;for(let _ of $)if(P(h(process.cwd(),_))){Y=!0,Q.push({name:"Configuration",status:"pass",message:_});break}if(!Y)Q.push({name:"Configuration",status:"warn",message:"No config file found (using defaults)"});let N=h(process.cwd(),"docs");if(P(N)){let{Glob:_}=awaitPromise.resolve(globalThis.Bun),J=new _("**/*.md"),U=0;for await(let S of J.scan(N))U++;Q.push({name:"Documentation",status:U>0?"pass":"warn",message:`${U} markdown files`})}else Q.push({name:"Documentation",status:"fail",message:"docs/ directory not found"});let H=h(process.cwd(),"package.json");if(P(H)){let _=await Bun.file(H).json(),J=_.scripts?.dev,U=_.scripts?.build;Q.push({name:"Package Scripts",status:J&&U?"pass":"warn",message:`dev: ${J?"\u2713":"\u2717"}, build: ${U?"\u2713":"\u2717"}`});let S=_.dependencies?.["@stacksjs/bunpress"]||_.devDependencies?.["@stacksjs/bunpress"];Q.push({name:"BunPress Package",status:S?"pass":"warn",message:S||"Not installed"})}else Q.push({name:"Package.json",status:"warn",message:"Not found"});let X=h(process.cwd(),"node_modules");if(P(X))Q.push({name:"Dependencies",status:"pass",message:"node_modules found"});else Q.push({name:"Dependencies",status:"warn",message:"node_modules not found (run: bun install)"});let W=h(process.cwd(),".git");if(P(W))Q.push({name:"Git Repository",status:"pass",message:"Initialized"});else Q.push({name:"Git Repository",status:"warn",message:"Not initialized"});let j=h(process.cwd(),"tsconfig.json");if(P(j))Q.push({name:"TypeScript",status:"pass",message:"tsconfig.json found"});else Q.push({name:"TypeScript",status:"warn",message:"tsconfig.json not found"});for(let _ of Q){let J=_.status==="pass"?"\u2713":_.status==="fail"?"\u2717":"\u26A0",U=_.status==="pass"?"green":_.status==="fail"?"red":"yellow";console.log(` ${z(J,U)} ${_.name}: ${z(_.message,"dim")}`)}console.log();let V=Q.filter((_)=>_.status==="pass").length,q=Q.filter((_)=>_.status==="fail").length,G=Q.filter((_)=>_.status==="warn").length;if(q>0){if(B(`${q} checks failed, ${G} warnings`),console.log(),O("Recommended actions:"),Q.find((_)=>_.name==="Documentation"&&_.status==="fail"))console.log(' \u2022 Run "bunpress init" to create docs directory');if(Q.find((_)=>_.name==="Dependencies"&&_.status==="warn"))console.log(' \u2022 Run "bun install" to install dependencies');if(Q.find((_)=>_.name==="BunPress Package"&&_.status==="warn"))console.log(' \u2022 Run "bun add @stacksjs/bunpress" to install BunPress');return!1}else if(G>0)return c(`${V} checks passed, ${G} warnings`),!0;else return T(`All ${V} checks passed!`),!0}import{mkdir as o}from"fs/promises";var t6=`import type { BunPressConfig } from '@stacksjs/bunpress'
88
-
89
- export default {
90
- verbose: false,
91
-
92
- markdown: {
93
- toc: {
94
- enabled: true,
95
- position: 'sidebar',
96
- minDepth: 2,
97
- maxDepth: 3,
98
- },
99
- features: {
100
- inlineFormatting: true,
101
- containers: true,
102
- githubAlerts: true,
103
- codeBlocks: {
104
- lineNumbers: true,
105
- lineHighlighting: true,
106
- focus: true,
107
- diff: true,
108
- errorWarning: true,
109
- },
110
- codeGroups: true,
111
- codeImports: true,
112
- inlineToc: true,
113
- customAnchors: true,
114
- emoji: true,
115
- badges: true,
116
- includes: true,
117
- externalLinks: {
118
- enabled: true,
119
- openInNewTab: true,
120
- addIcon: true,
121
- },
122
- imageLazyLoading: true,
123
- tables: {
124
- responsive: true,
125
- striped: true,
126
- hover: true,
127
- },
128
- },
129
- },
130
-
131
- nav: [
132
- { text: 'Home', link: '/' },
133
- { text: 'Guide', link: '/guide/' },
134
- { text: 'GitHub', link: 'https://github.com/stacksjs/bunpress' },
135
- ],
136
-
137
- sitemap: {
138
- hostname: 'https://example.com',
139
- },
140
- } satisfies BunPressConfig
141
- `,e6=`---
142
- layout: home
143
- title: Welcome to My Documentation
144
-
145
- hero:
146
- name: My Project
147
- text: Modern documentation made easy
148
- tagline: Fast, flexible, and beautiful documentation powered by BunPress
149
- actions:
150
- - theme: brand
151
- text: Get Started
152
- link: /guide/
153
- - theme: alt
154
- text: View on GitHub
155
- link: https://github.com/yourusername/your-repo
156
-
157
- features:
158
- - icon: \u26A1
159
- title: Lightning Fast
160
- details: Powered by Bun runtime for incredible build and dev server performance
161
- - icon: \uD83C\uDFA8
162
- title: Beautiful by Default
163
- details: Clean, modern design with dark mode support out of the box
164
- - icon: \uD83D\uDCDD
165
- title: Markdown Enhanced
166
- details: Extended markdown features including containers, code groups, and more
167
- ---
168
-
169
- # Welcome
170
-
171
- This is your new BunPress documentation site. Start editing files in the \`docs/\` directory to customize your content.
172
- `,K4=`# Getting Started
173
-
174
- Welcome to the getting started guide!
175
-
176
- ## Installation
177
-
178
- \`\`\`bash
179
- bun install @stacksjs/bunpress
180
- \`\`\`
181
-
182
- ## Quick Start
183
-
184
- Create your first documentation page:
185
-
186
- \`\`\`bash
187
- bunpress new my-page
188
- \`\`\`
189
-
190
- ## Next Steps
191
-
192
- ::: tip
193
- Check out the [markdown extensions](/guide/markdown) to learn about all the powerful features available.
194
- :::
195
-
196
- - Learn about [configuration](/guide/configuration)
197
- - Explore [advanced features](/guide/advanced)
198
- - Read the [API reference](/api/)
199
- `,Q4=`node_modules/
200
- dist/
201
- .DS_Store
202
- *.log
203
- .env
204
- .env.*
205
- !.env.example
206
- `,Z4=`# My BunPress Documentation
207
-
208
- Documentation powered by [BunPress](https://github.com/stacksjs/bunpress).
209
-
210
- ## Development
211
-
212
- Start the dev server:
213
-
214
- \`\`\`bash
215
- bun run dev
216
- \`\`\`
217
-
218
- ## Build
219
-
220
- Build the documentation:
221
-
222
- \`\`\`bash
223
- bun run build
224
- \`\`\`
225
-
226
- ## Preview
227
-
228
- Preview the built site:
229
-
230
- \`\`\`bash
231
- bun run preview
232
- \`\`\`
233
- `;async function G6(K={}){try{if(await Bun.file("./docs").exists()&&!K.force){if(!await f("Documentation directory already exists. Continue?",!1))return O("Initialization cancelled"),!1}let Q=new k("Initializing BunPress project...");Q.start(),await o("./docs",{recursive:!0}),await o("./docs/guide",{recursive:!0}),await o("./docs/public",{recursive:!0}),await Bun.write("./bunpress.config.ts",t6),await Bun.write("./docs/index.md",e6),await Bun.write("./docs/guide/index.md",K4);let $=await Bun.file("./.gitignore").exists();if(!$)await Bun.write("./.gitignore",Q4);let Y=await Bun.file("./README.md").exists();if(!Y)await Bun.write("./README.md",Z4);let N="./package.json";if(await Bun.file(N).exists()){let X=await Bun.file(N).json();X.scripts=X.scripts||{},X.scripts.dev=X.scripts.dev||"bunpress dev",X.scripts.build=X.scripts.build||"bunpress build",X.scripts.preview=X.scripts.preview||"bunpress preview",await Bun.write(N,JSON.stringify(X,null,2))}if(Q.succeed("BunPress project initialized successfully!"),console.log(),T("Created files:"),console.log(" \u2022 bunpress.config.ts"),console.log(" \u2022 docs/index.md"),console.log(" \u2022 docs/guide/index.md"),console.log(" \u2022 docs/public/"),!$)console.log(" \u2022 .gitignore");if(!Y)console.log(" \u2022 README.md");return console.log(),O("Next steps:"),console.log(" 1. Install BunPress: bun add @stacksjs/bunpress"),console.log(" 2. Start dev server: bun run dev"),console.log(" 3. Edit docs/index.md to customize your home page"),!0}catch(Z){return B(`Failed to initialize project: ${Z}`),!1}}import{mkdir as $4}from"fs/promises";import{dirname as N4,join as Y4}from"path";var A6={default:(K)=>`---
234
- title: ${K}
235
- description:
236
- ---
237
-
238
- # ${K}
239
-
240
- Your content goes here...
241
- `,guide:(K)=>`---
242
- title: ${K}
243
- description: ${K} guide
244
- ---
245
-
246
- # ${K}
247
-
248
- ## Introduction
249
-
250
- Brief introduction to the topic.
251
-
252
- ## Getting Started
253
-
254
- Step-by-step instructions.
255
-
256
- ## Examples
257
-
258
- \`\`\`typescript
259
- // Example code
260
- \`\`\`
261
-
262
- ## Next Steps
263
-
264
- - [ ] Task 1
265
- - [ ] Task 2
266
- `,api:(K)=>`---
267
- title: ${K}
268
- description: API reference for ${K}
269
- ---
270
-
271
- # ${K}
272
-
273
- ## Overview
274
-
275
- Brief overview of the API.
276
-
277
- ## Methods
278
-
279
- ### \`methodName()\`
280
-
281
- Description of the method.
282
-
283
- **Parameters:**
284
-
285
- - \`param1\` (\`type\`) - Description
286
-
287
- **Returns:**
288
-
289
- - \`ReturnType\` - Description
290
-
291
- **Example:**
292
-
293
- \`\`\`typescript
294
- // Example usage
295
- \`\`\`
296
- `,blog:(K)=>`---
297
- title: ${K}
298
- description:
299
- date: ${new Date().toISOString().split("T")[0]}
300
- author:
301
- tags: []
302
- ---
303
-
304
- # ${K}
305
-
306
- Post content goes here...
307
-
308
- ## Section 1
309
-
310
- Content...
311
- `};async function J6(K,Z={}){try{let Q=K.endsWith(".md")?K:`${K}.md`,$=Y4(process.cwd(),"docs",Q);if(await Bun.file($).exists())return B(`File already exists: ${Q}`),!1;let N=Z.title;if(!N)N=(Q.split("/").pop()?.replace(".md","")||"").split("-").map((q)=>q.charAt(0).toUpperCase()+q.slice(1)).join(" ");let H=Z.template||"default",X=A6[H];if(!X)return B(`Unknown template: ${H}`),B(`Available templates: ${Object.keys(A6).join(", ")}`),!1;let W=X(N),j=N4($);return await $4(j,{recursive:!0}),await Bun.write($,W),T(`Created ${Q}`),console.log(),console.log(` Title: ${N}`),console.log(` Template: ${H}`),console.log(` Path: ${$}`),!0}catch(Q){return B(`Failed to create file: ${Q}`),!1}}import{join as M6}from"path";async function R6(K={}){let Z=K.port||3000,Q=await L,$=K.outdir||Q.outDir||"./dist",Y=M6($,".bunpress"),N=K.verbose||!1;try{let{stat:H}=await import("fs/promises");try{if(!(await H(Y)).isDirectory())B(`"${Y}" is not a directory.`),B('Run "bunpress build" first to generate the documentation.'),process.exit(1)}catch{B(`Build directory "${Y}" not found.`),B('Run "bunpress build" first to generate the documentation.'),process.exit(1)}O(`Starting preview server from ${Y}`);try{let X=Bun.serve({port:Z,fetch:async(W)=>{let V=new URL(W.url).pathname;if(V.startsWith("/"))V=V.slice(1);if(V===""||V==="/")V="index.html";let q=M6(Y,V),G=Bun.file(q);if(await G.exists())return new Response(G,{headers:{"Content-Type":H4(V)}});let J=`${q}.html`,U=Bun.file(J);if(await U.exists())return new Response(U,{headers:{"Content-Type":"text/html"}});return new Response("404 - Not Found",{status:404})}});T(`Preview server running at http://localhost:${Z}`),console.log(`Press Ctrl+C to stop
312
- `),await new Promise(()=>{})}catch(X){if(X.message?.includes("EADDRINUSE")||X.code==="EADDRINUSE")B(`Port ${Z} is already in use.`),B("Try running with a different port: bunpress preview --port <port>"),B(`Or stop any processes using port ${Z}`);else B(`Failed to start server: ${X.message||X}`);process.exit(1)}}catch(H){B(`Failed to start preview server: ${H}`),process.exit(1)}}function H4(K){let Z=K.split(".").pop()?.toLowerCase();return{html:"text/html",css:"text/css",js:"application/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml",ico:"image/x-icon",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",eot:"application/vnd.ms-fontobject"}[Z||""]||"text/plain"}import*as w from"fs";import*as y from"path";var{YAML:O6}=globalThis.Bun;async function T6(K={}){let Z=await L,Q=K.dir||Z.docsDir||"./docs",$=K.fix||!1;if(O("\uD83D\uDD0D Running SEO checks..."),console.log(""),!w.existsSync(Q))B(`Documentation directory not found: ${Q}`),process.exit(1);let Y={totalPages:0,errors:[],warnings:[],passed:0},N=await _4(Q);Y.totalPages=N.length;for(let H of N)await X4(H,Q,Y,$);if(G4(Y),Y.errors.length>0)process.exit(1)}async function X4(K,Z,Q,$){let Y=await w.promises.readFile(K,"utf-8"),{frontmatter:N,markdown:H}=W4(Y),X=y.relative(Z,K),W=!1,j=!1,V={...N};if(!N.title){let _=V4(H);if(!_)Q.errors.push({type:"error",category:"Title",file:X,message:"Missing title in frontmatter"}),W=!0;else if($)V.title=_,j=!0,O(`\u2713 Added title to ${X}: "${_}"`);else Q.warnings.push({type:"warning",category:"Title",file:X,message:`No title in frontmatter (could extract: "${_}")`}),W=!0}else{let _=N.title.length;if(_>60)Q.warnings.push({type:"warning",category:"Title",file:X,message:`Title too long (${_} chars, recommended <60)`}),W=!0;else if(_<10)Q.warnings.push({type:"warning",category:"Title",file:X,message:`Title too short (${_} chars, recommended >10)`}),W=!0}if(!N.description){let _=j4(H);if($)V.description=_,j=!0,O(`\u2713 Added description to ${X}`);else Q.warnings.push({type:"warning",category:"Description",file:X,message:"Missing description in frontmatter"}),W=!0}else{let _=N.description.length;if(_>160)Q.warnings.push({type:"warning",category:"Description",file:X,message:`Description too long (${_} chars, recommended <160)`}),W=!0;else if(_<50)Q.warnings.push({type:"warning",category:"Description",file:X,message:`Description too short (${_} chars, recommended >50)`}),W=!0}let q=q4(H,Z,K);for(let _ of q)Q.errors.push({type:"error",category:"Links",file:X,message:`Broken internal link: ${_}`}),W=!0;let G=B4(H);for(let _ of G)Q.warnings.push({type:"warning",category:"Images",file:X,message:`Image missing alt text: ${_}`}),W=!0;if(j){let _=`---
313
- ${O6.stringify(V)}---
314
- ${H}`;await w.promises.writeFile(K,_,"utf-8")}if(!W)Q.passed++}async function _4(K){let Z=[];async function Q($){let Y=await w.promises.readdir($,{withFileTypes:!0});for(let N of Y){let H=y.join($,N.name);if(N.isDirectory()){if(!N.name.startsWith(".")&&N.name!=="node_modules"&&N.name!=="public")await Q(H)}else if(N.isFile()&&N.name.endsWith(".md"))Z.push(H)}}return await Q(K),Z}function W4(K){let Z=/^---\n([\s\S]*?)\n---\n?/,Q=K.match(Z);if(!Q)return{frontmatter:{},markdown:K};let $=Q[1],Y=K.slice(Q[0].length);try{return{frontmatter:O6.parse($),markdown:Y}}catch{return{frontmatter:{},markdown:K}}}function V4(K){let Z=K.match(/^#\s+(.+)$/m);return Z?Z[1].trim():null}function j4(K,Z=155){let Q=K.replace(/^#{1,6}\s+.+$/gm,"").replace(/```[\s\S]*?```/g,"").replace(/`[^`]+`/g,"").replace(/!\[.*?\]\(.*?\)/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_~]/g,"").trim(),$=Q.split(`
315
-
316
- `)[0]||Q;if($.length>Z)return`${$.slice(0,Z)}...`;return $||"Documentation page"}function q4(K,Z,Q){let $=[],Y=/\[([^\]]+)\]\(([^)]+)\)/g,N;while((N=Y.exec(K))!==null){let H=N[2];if(H.startsWith("http://")||H.startsWith("https://"))continue;if(H.startsWith("#"))continue;let X=y.dirname(Q),W=y.resolve(X,H),j=W.endsWith(".md")?W:`${W}.md`;if(!w.existsSync(j)&&!w.existsSync(W))$.push(H)}return $}function B4(K){let Z=[],Q=/!\[([^\]]*)\]\(([^)]+)\)/g,$;while(($=Q.exec(K))!==null){let Y=$[1],N=$[2];if(!Y||Y.trim()==="")Z.push(N)}return Z}function G4(K){if(console.log(""),O("\uD83D\uDCCA SEO Report"),console.log(""),console.log(`Total pages checked: ${z(K.totalPages.toString(),"blue")}`),console.log(`Passed: ${z(K.passed.toString(),"green")}`),console.log(`Errors: ${z(K.errors.length.toString(),K.errors.length>0?"red":"green")}`),console.log(`Warnings: ${z(K.warnings.length.toString(),K.warnings.length>0?"yellow":"green")}`),console.log(""),K.errors.length>0){B(`\u2717 ${K.errors.length} errors found:`),console.log("");let Z=K.errors.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));g(Z),console.log("")}if(K.warnings.length>0){c(`\u26A0 ${K.warnings.length} warnings found:`),console.log("");let Z=K.warnings.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));g(Z),console.log("")}if(K.errors.length===0&&K.warnings.length===0)T("\u2713 All SEO checks passed!");else if(K.errors.length===0)T("\u2713 No errors found (only warnings)")}import{join as A4}from"path";async function J4(K){let Z=await Bun.file(K).text(),Q=Z.split(`
317
- `),$=0,Y=!1,N=[];for(let j of Q){if(j.trim().startsWith("```")){Y=!Y;continue}if(!Y)N.push(j)}$=N.join(" ").split(/\s+/).filter((j)=>j.length>0).length;let X=Q.filter((j)=>j.match(/^#{1,6}\s+/)).length,W=(Z.match(/```/g)||[]).length/2;return{path:K,size:await l(K),lines:Q.length,words:$,headings:X,codeBlocks:Math.floor(W)}}async function U6(K={}){let Z=await L,Q=K.dir||Z.docsDir||"./docs",$=K.verbose||!1;try{console.log(z(`
318
- Analyzing documentation...
319
- `,"bold"));let{Glob:Y}=awaitPromise.resolve(globalThis.Bun),N=new Y("**/*.md"),H=[];for await(let A of N.scan(Q)){let M=A4(Q,A),a=await J4(M);H.push(a)}if(H.length===0)return B("No markdown files found"),!1;let X=H.reduce((A,M)=>A+M.size,0),W=H.reduce((A,M)=>A+M.lines,0),j=H.reduce((A,M)=>A+M.words,0),V=H.reduce((A,M)=>A+M.headings,0),q=H.reduce((A,M)=>A+M.codeBlocks,0);if(console.log(z("Summary","bold")),console.log("\u2500".repeat(50)),console.log(`Files: ${H.length}`),console.log(`Total size: ${b(X)}`),console.log(`Total lines: ${W.toLocaleString()}`),console.log(`Total words: ${j.toLocaleString()}`),console.log(`Headings: ${V}`),console.log(`Code blocks: ${q}`),console.log(),$){console.log(z("Per-file Statistics","bold")),console.log("\u2500".repeat(50));let A=H.map((M)=>({File:M.path.replace(`${Q}/`,""),Size:b(M.size),Lines:M.lines,Words:M.words,Headings:M.headings,"Code Blocks":M.codeBlocks}));g(A),console.log()}let G=X/H.length,_=W/H.length,J=j/H.length;console.log(z("Averages per File","bold")),console.log("\u2500".repeat(50)),console.log(`Size: ${b(G)}`),console.log(`Lines: ${Math.round(_)}`),console.log(`Words: ${Math.round(J)}`),console.log();let U=[...H].sort((A,M)=>M.size-A.size).slice(0,5);if(U.length>0){console.log(z("Top 5 Largest Files","bold")),console.log("\u2500".repeat(50));for(let A of U){let M=A.path.replace(`${Q}/`,"");console.log(` ${M.padEnd(40)} ${b(A.size)}`)}console.log()}let S=Math.ceil(j/200);return O(`Estimated reading time: ${S} minutes`),!0}catch(Y){return B(`Failed to generate statistics: ${Y}`),!1}}var I=new O4("bunpress"),R={outdir:L.outDir||"./dist",docsdir:L.docsDir||"./docs",port:3000,open:!0,watch:!0,verbose:L.verbose};async function x6(K){let Z=new L6("**/*.md"),Q=[];for await(let $ of Z.scan(K))Q.push(F(K,$));return Q}async function T4(K,Z,Q=!1){let $=`${Z}/public`;try{await R4($);let Y=new L6("**/*");for await(let N of Y.scan($)){let H=F($,N),X=F(K,N);await I6(F(K,N.split("/").slice(0,-1).join("/")),{recursive:!0}),await M4(H,X)}}catch{if(Q)console.log("No public directory found, skipping static assets copy")}}async function U4(K,Z,Q){try{let $=await L;if($.sitemap?.enabled!==!1&&$.sitemap?.baseUrl)await Y6(K,Z,$);if($.robots?.enabled!==!1)await $6(Z,$);if($.rss?.enabled)await N6(K,Z,$,$.rss)}catch($){if(Q)console.error("Error generating SEO files:",$)}}async function z6(K={}){let Z=await L,Q=K.outdir||Z.outDir||R.outdir,$=F(Q,".bunpress"),Y=K.dir||Z.docsDir||R.docsdir,N=K.verbose??R.verbose,H=K.minify??!1,X=K.sourcemap??!1,W=performance.now(),j=new k("Building documentation...");if(!N)j.start();await I6($,{recursive:!0});let V=await x6(Y);if(V.length===0){if(!N)j.fail("No markdown files found in docs directory");else console.log("No markdown files found in docs directory");return!1}if(N)console.log(`Found ${V.length} markdown files:`),V.forEach((q)=>console.log(`- ${q}`));try{let{markdownToHtml:q,wrapInLayout:G}=await import("./chunk-h07knheg.js"),{mkdir:_,writeFile:J}=await import("fs/promises");if(N)console.log("Transforming markdown to HTML...");for(let A of V){let M=await Bun.file(A).text(),{html:a,frontmatter:S6}=await q(M,Y),E6=A.replace(/^\.\//,""),b6=Y.replace(/^\.\//,""),m=E6.replace(b6,"").replace(/^\//,"").replace(/\.md$/,""),v6=`/${m}`,F6=S6.layout||"doc",w6=await G(a,Z,v6,F6),p=m==="index"||m.endsWith("/index")?F($,`${m}.html`):F($,m,"index.html"),e=p.substring(0,p.lastIndexOf("/"));if(e)await _(e,{recursive:!0});if(await J(p,w6),N)console.log(`Generated: ${p}`)}if(N)console.log(`Processed ${V.length} markdown files.`);await T4($,Y,N),await L4($),await z4($,Z),await U4(Y,$,N||!1);let S=performance.now()-W;if(!N)j.succeed(`Built ${V.length} pages to HTML in ${s(S)}`);else T(`Build completed in ${s(S)}`),console.log(`
320
- Generated ${V.length} HTML files in ${$}`);return!0}catch(q){if(!N)j.fail("Build failed");return console.error("Error during build:",q),!1}}async function z4(K,Z){let{wrapInLayout:Q}=await import("./chunk-h07knheg.js"),$=`
321
- <style>
322
- .NotFound {
323
- padding: 64px 24px 96px;
324
- text-align: center;
325
- }
326
-
327
- @media (min-width: 768px) {
328
- .NotFound {
329
- padding: 96px 32px 168px;
330
- }
331
- }
332
-
333
- .NotFound .code {
334
- line-height: 64px;
335
- font-size: 64px;
336
- font-weight: 600;
337
- }
338
-
339
- .NotFound .title {
340
- padding-top: 12px;
341
- letter-spacing: 2px;
342
- line-height: 20px;
343
- font-size: 20px;
344
- font-weight: 700;
345
- }
346
-
347
- .NotFound .divider {
348
- margin: 24px auto 18px;
349
- width: 64px;
350
- height: 1px;
351
- background-color: var(--vp-c-divider);
352
- }
353
-
354
- .NotFound .quote {
355
- margin: 0 auto;
356
- max-width: 256px;
357
- font-size: 14px;
358
- font-weight: 500;
359
- color: var(--vp-c-text-2);
360
- }
361
-
362
- .NotFound .action {
363
- padding-top: 20px;
364
- }
365
-
366
- .NotFound .link {
367
- display: inline-block;
368
- border: 1px solid var(--vp-c-brand-1);
369
- border-radius: 16px;
370
- padding: 3px 16px;
371
- font-size: 14px;
372
- font-weight: 500;
373
- color: var(--vp-c-brand-1);
374
- transition: border-color 0.25s, color 0.25s;
375
- text-decoration: none;
376
- }
377
-
378
- .NotFound .link:hover {
379
- border-color: var(--vp-c-brand-2);
380
- color: var(--vp-c-brand-2);
381
- }
382
- </style>
383
-
384
- <div class="NotFound">
385
- <p class="code">404</p>
386
- <h1 class="title">PAGE NOT FOUND</h1>
387
- <div class="divider"></div>
388
- <blockquote class="quote">
389
- But if you don't change your direction, and if you keep looking, you may end up where you are heading.
390
- </blockquote>
391
- <div class="action">
392
- <a class="link" href="/docs/" aria-label="go to home">
393
- Take me home
394
- </a>
395
- </div>
396
- </div>
397
- `,Y=await Q(`
398
- <style>
399
- .NotFound {
400
- padding: 64px 24px 96px;
401
- text-align: center;
402
- }
403
-
404
- @media (min-width: 768px) {
405
- .NotFound {
406
- padding: 96px 32px 168px;
407
- }
408
- }
409
-
410
- .NotFound .code {
411
- line-height: 64px;
412
- font-size: 64px;
413
- font-weight: 600;
414
- }
415
-
416
- .NotFound .title {
417
- padding-top: 12px;
418
- letter-spacing: 2px;
419
- line-height: 20px;
420
- font-size: 20px;
421
- font-weight: 700;
422
- }
423
-
424
- .NotFound .divider {
425
- margin: 24px auto 18px;
426
- width: 64px;
427
- height: 1px;
428
- background-color: var(--vp-c-divider);
429
- }
430
-
431
- .NotFound .quote {
432
- margin: 0 auto;
433
- max-width: 256px;
434
- font-size: 14px;
435
- font-weight: 500;
436
- color: var(--vp-c-text-2);
437
- }
438
-
439
- .NotFound .action {
440
- padding-top: 20px;
441
- }
442
-
443
- .NotFound .link {
444
- display: inline-block;
445
- border: 1px solid var(--vp-c-brand-1);
446
- border-radius: 16px;
447
- padding: 3px 16px;
448
- font-size: 14px;
449
- font-weight: 500;
450
- color: var(--vp-c-brand-1);
451
- transition: border-color 0.25s, color 0.25s;
452
- text-decoration: none;
453
- }
454
-
455
- .NotFound .link:hover {
456
- border-color: var(--vp-c-brand-2);
457
- color: var(--vp-c-brand-2);
458
- }
459
- </style>
460
-
461
- <div class="NotFound">
462
- <p class="code">404</p>
463
- <h1 class="title">PAGE NOT FOUND</h1>
464
- <div class="divider"></div>
465
- <blockquote class="quote">
466
- But if you don't change your direction, and if you keep looking, you may end up where you are heading.
467
- </blockquote>
468
- <div class="action">
469
- <a class="link" href="/docs/" aria-label="go to home">
470
- Take me home
471
- </a>
472
- </div>
473
- </div>
474
- `,Z,"/404","doc");await Bun.write(F(K,"404.html"),Y)}async function L4(K){let Z=F(K,"index.html");try{if(!await Bun.file(Z).exists())console.error("Warning: No index.html found at root")}catch(Q){console.error("Error checking root index.html:",Q)}}I.command("build","Build the documentation site").option("--outdir <outdir>","Output directory").option("--dir <dir>","Documentation directory").option("--config <config>","Path to config file").option("--minify","Minify output files",{default:!1}).option("--sourcemap","Generate source maps",{default:!1}).option("--watch","Watch for changes and rebuild",{default:!1}).option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{if(!await z6(K))E.exit(1);if(K.watch){let{watch:Q}=await import("fs"),$=await L,Y=K.dir||$.docsDir||"./docs";console.log(`
475
- Watching for changes...`),Q(Y,{recursive:!0},async(N,H)=>{if(H&&H.endsWith(".md"))console.log(`
476
- Detected change in ${H}, rebuilding...`),await z6(K)}),await new Promise(()=>{})}});I.command("dev","Build and serve documentation using BunPress server").option("--port <port>","Port to listen on",{default:R.port}).option("--dir <dir>","Documentation directory").option("--watch","Watch for changes",{default:R.watch}).option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{let Z=await L,Q=K.port||R.port,$=K.dir||Z.docsDir||R.docsdir,Y=K.watch??R.watch,N=K.verbose??R.verbose;if(N)console.log("Starting BunPress dev server with options:",{port:Q,root:$,watch:Y,verbose:N});let{serveCLI:H}=await import("./chunk-h07knheg.js");await H({port:Q,root:$,watch:Y,config:Z})});async function I4(K={}){let Z=await L,Q=K.dir||Z.docsDir||R.docsdir,$=K.output||"./docs.md",Y=K.full??!1,N=K.verbose??R.verbose;if(N)console.log(`Generating LLM markdown from ${Q}`),console.log(`Output file: ${$}`),console.log(`Full content: ${Y}`);let H=await x6(Q);if(H.length===0)return console.log("No markdown files found in docs directory"),!1;if(N)console.log(`Found ${H.length} markdown files`);H.sort();let X=`# Documentation
477
-
478
- `;X+=`Generated: ${new Date().toISOString()}
479
-
480
- `,X+=`Total files: ${H.length}
481
-
482
- `,X+=`---
483
-
484
- `;for(let W of H){let j=W.replace(`${Q}/`,""),V=await Bun.file(W).text();if(N)console.log(`Processing: ${j}`);if(X+=`## File: ${j}
485
-
486
- `,Y)X+=V,X+=`
487
-
488
- `;else{let q=V.split(`
489
- `),G=!1,_="";for(let J of q){if(J.trim()==="---")if(!G){G=!0;continue}else{if(G=!1,_)X+="**Frontmatter:**\n```yaml\n",X+=_,X+="```\n\n",_="";continue}if(G){_+=`${J}
490
- `;continue}if(J.match(/^#{1,6}\s+/))X+=`${J}
491
- `}X+=`
492
- `}X+=`---
493
-
494
- `}return await Bun.write($,X),console.log(`
495
- LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(X.length/1024).toFixed(2)} KB`),!0}I.command("llm","Generate LLM-friendly markdown file from documentation").option("--dir <dir>","Documentation directory",{default:"./docs"}).option("--output <output>","Output file path",{default:"./docs.md"}).option("--full","Include full content (not just titles and headings)",{default:!1}).option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{if(!await I4(K))E.exit(1)});I.command("init","Initialize a new BunPress project").option("--name <name>","Project name").option("--template <template>","Template to use").option("--force","Overwrite existing files",{default:!1}).action(async(K)=>{if(!await G6(K))E.exit(1)});I.command("preview","Preview the built documentation site").option("--port <port>","Port to listen on",{default:R.port}).option("--outdir <outdir>","Output directory (looks for .bunpress folder inside)").option("--open","Open in browser",{default:!1}).option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{await R6(K)});I.command("clean","Clean build artifacts").option("--outdir <outdir>","Output directory to clean",{default:R.outdir}).option("--force","Skip confirmation prompt",{default:!1}).option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{if(!await W6(K))E.exit(1)});I.command("doctor","Run diagnostic checks on the project").option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{if(!await B6(K))E.exit(1)});I.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{if(!await V6(K))E.exit(1)});I.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{if(!await j6(K))E.exit(1)});I.command("config:init","Initialize configuration file").action(async(K)=>{if(!await q6(K))E.exit(1)});I.command("new <path>","Create a new markdown file").option("--title <title>","Page title").option("--template <template>","Template to use (default, guide, api, blog)",{default:"default"}).option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K,Z)=>{if(!await J6(K,Z))E.exit(1)});I.command("stats","Show documentation statistics").option("--dir <dir>","Documentation directory",{default:"./docs"}).option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{if(!await U6(K))E.exit(1)});I.command("seo:check","Check SEO for all documentation pages").option("--dir <dir>","Documentation directory",{default:"./docs"}).option("--fix","Automatically fix issues (add missing titles/descriptions)",{default:!1}).action(async(K)=>{await T6(K)});I.command("deploy","Deploy documentation to AWS using CloudFormation (S3 + CloudFront + Route53)").option("--region <region>","AWS region for S3 bucket",{default:"us-east-1"}).option("--bucket <bucket>","S3 bucket name (auto-generated if not provided)").option("--domain <domain>","Custom domain (e.g., docs.example.com)").option("--subdomain <subdomain>","Subdomain (used with --base-domain)").option("--base-domain <baseDomain>","Base domain (e.g., example.com) - must have Route53 hosted zone").option("--stack-name <stackName>","CloudFormation stack name").option("--hosted-zone-id <hostedZoneId>","Route53 hosted zone ID (auto-detected from domain)").option("--certificate-arn <certificateArn>","ACM certificate ARN (auto-created if not provided)").option("--dry-run","Show configuration without deploying",{default:!1}).option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{let{deployCommand:Z}=await import("./chunk-sd994fph.js");if(!await Z(K))E.exit(1)});I.help();I.version(K6);var t=Bun.argv[1]||"",x4=t.endsWith("/bunpress")||t.endsWith("/cli.ts")||t.endsWith("/cli.js");if(x4)I.parse();
496
- export{T as E,B as F,O as G,k as H,x6 as I,z6 as J};