@stacksjs/bunpress 0.2.8 → 0.2.9

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,32 +0,0 @@
1
- // @bun
2
- var{YAML:E}=globalThis.Bun;import*as I from"fs";import*as A from"path";async function R(H,J,j){let K=J.sitemap?.baseUrl||"",N=j?.title||J.title||J.markdown?.title||"Documentation Feed",O=j?.description||J.description||J.markdown?.meta?.description||"Documentation updates",Q=j?.author||"Documentation Team",Z=j?.email||"",_=j?.language||"en-us",$=j?.maxItems||20,V=j?.fullContent||!1,W=await F(H,K,V);W.sort((G,Y)=>Y.pubDate.getTime()-G.pubDate.getTime());let B=W.slice(0,$);return x({title:N,description:O,link:K,language:_,author:Q,email:Z,items:B})}async function u(H,J,j,K){if(!K?.enabled)return;if(!j.sitemap?.baseUrl){if(j.verbose)console.warn("\u26A0\uFE0F RSS feed generation skipped: baseUrl not configured");return}let N=await R(H,j,K),O=K.filename||"feed.xml",Q=A.join(J,O);if(await I.promises.writeFile(Q,N,"utf-8"),j.verbose){let Z=(N.match(/<item>/g)||[]).length;console.log(`\u2705 RSS feed generated: ${Q} (${Z} items)`)}}async function F(H,J,j){let K=[],N=await w(H);for(let O of N){let Q=await I.promises.readFile(O,"utf-8"),{frontmatter:Z,markdown:_}=k(Q);if(!Z.date||!Z.title)continue;let V=A.relative(H,O).replace(/\.md$/,"").replace(/index$/,"").replace(/\\/g,"/");if(!V.startsWith("/"))V=`/${V}`;if(V.endsWith("/")&&V!=="/")V=V.slice(0,-1);let W=`${J.replace(/\/$/,"")}${V}`,B=Z.description||U(_),G=new Date(Z.date),Y=Z.author;K.push({title:Z.title,link:W,description:B,pubDate:G,author:Y,content:j?_:void 0})}return K}async function w(H){let J=[];async function j(K){let N=await I.promises.readdir(K,{withFileTypes:!0});for(let O of N){let Q=A.join(K,O.name);if(O.isDirectory()){if(!O.name.startsWith(".")&&O.name!=="node_modules")await j(Q)}else if(O.isFile()&&O.name.endsWith(".md"))J.push(Q)}}return await j(H),J}function k(H){let J=/^---\n([\s\S]*?)\n---\n?/,j=H.match(J);if(!j)return{frontmatter:{},markdown:H};let K=j[1],N=H.slice(j[0].length);try{return{frontmatter:E.parse(K),markdown:N}}catch{return{frontmatter:{},markdown:H}}}function U(H,J=200){let j=H.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(),K=j.split(`
3
-
4
- `)[0]||j;if(K.length>J)return`${K.slice(0,J)}...`;return K}function x(H){let J=new Date,j=H.items.length>0?H.items[0].pubDate:J,K=H.items.map((N)=>{let O=N.content?`
5
- <content:encoded><![CDATA[${N.content}]]></content:encoded>`:"",Q=N.author?`
6
- <dc:creator><![CDATA[${N.author}]]></dc:creator>`:"";return` <item>
7
- <title><![CDATA[${N.title}]]></title>
8
- <link>${N.link}</link>
9
- <guid>${N.link}</guid>
10
- <description><![CDATA[${N.description}]]></description>
11
- <pubDate>${N.pubDate.toUTCString()}</pubDate>${Q}${O}
12
- </item>`}).join(`
13
- `);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[${H.title}]]></title>`,` <description><![CDATA[${H.description}]]></description>`,` <link>${H.link}</link>`,` <language>${H.language}</language>`,` <lastBuildDate>${j.toUTCString()}</lastBuildDate>`,` <atom:link href="${H.link}/feed.xml" rel="self" type="application/rss+xml"/>`,K," </channel>","</rss>"].join(`
14
- `)}import*as M from"fs";import*as S from"path";async function g(H,J){let j=J.robots;if(j?.enabled===!1)return;let K=j?.filename||"robots.txt",N=P(J),O=S.join(H,K);if(await M.promises.writeFile(O,N,"utf-8"),J.verbose)console.log(`\u2705 Robots.txt generated: ${O}`)}function P(H){let J=H.robots,j=[];if(J?.rules&&J.rules.length>0)for(let K of J.rules)j.push(...b(K)),j.push("");else j.push("User-agent: *"),j.push("Allow: /"),j.push("");if(J?.host)j.push(`Host: ${J.host}`),j.push("");if(J?.sitemaps&&J.sitemaps.length>0){for(let K of J.sitemaps)j.push(`Sitemap: ${K}`);j.push("")}else if(H.sitemap?.enabled!==!1&&H.sitemap?.baseUrl){let K=H.sitemap.filename||"sitemap.xml",N=`${H.sitemap.baseUrl.replace(/\/$/,"")}/${K}`;j.push(`Sitemap: ${N}`),j.push("")}if(J?.customContent)j.push(J.customContent),j.push("");return`${j.join(`
15
- `).trim()}
16
- `}function b(H){let J=[];if(J.push(`User-agent: ${H.userAgent}`),H.allow&&H.allow.length>0)for(let j of H.allow)J.push(`Allow: ${j}`);if(H.disallow&&H.disallow.length>0)for(let j of H.disallow)J.push(`Disallow: ${j}`);if(H.crawlDelay!==void 0)J.push(`Crawl-delay: ${H.crawlDelay}`);return J}import*as T from"fs";import*as z from"path";async function v(H,J,j){let K=J.sitemap,N=await D(H,j,K?.defaultPriority??0.5,K?.defaultChangefreq||"monthly",K?.exclude||[],K?.priorityMap||{},K?.changefreqMap||{});return K?.transform?N.map((O)=>K.transform(O)).filter(Boolean):N}async function l(H,J){let j=(J.sitemap?.baseUrl||"").replace(/\/$/,""),K=await v(H,J,j);return q(K,j)}async function a(H,J,j){let K=j.sitemap;if(K?.enabled===!1)return;if(!K?.baseUrl){if(j.verbose)console.warn("\u26A0\uFE0F Sitemap generation skipped: baseUrl not configured");return}let N=K.baseUrl.replace(/\/$/,""),O=K.filename||"sitemap.xml",Q=K.maxUrlsPerFile||50000,Z=K.useSitemapIndex||!1,_=await v(H,j,N);if(j.verbose)console.log(`\uD83D\uDCC4 Generated ${_.length} sitemap entries`);if(Z&&_.length>Q)await C(_,J,N,O,Q);else{let $=q(_,N),V=z.join(J,O);if(await T.promises.writeFile(V,$,"utf-8"),j.verbose)console.log(`\u2705 Sitemap generated: ${V}`)}}async function D(H,J,j,K,N,O,Q){let Z=[],_=await y(H);for(let $ of _){let W=z.relative(H,$).replace(/\.md$/,"").replace(/index$/,"").replace(/\\/g,"/");if(!W.startsWith("/"))W=`/${W}`;if(W.endsWith("/")&&W!=="/")W=W.slice(0,-1);if(h(W,N))continue;let B=j;for(let[Y,X]of Object.entries(O))if(L(W,Y)){B=X;break}let G=K;for(let[Y,X]of Object.entries(Q))if(L(W,Y)){G=X;break}Z.push({url:W,changefreq:G,priority:B})}return Z.sort(($,V)=>$.url.localeCompare(V.url))}async function y(H){let J=[];async function j(K){let N=await T.promises.readdir(K,{withFileTypes:!0});for(let O of N){let Q=z.join(K,O.name);if(O.isDirectory()){if(!O.name.startsWith(".")&&O.name!=="node_modules")await j(Q)}else if(O.isFile()&&O.name.endsWith(".md"))J.push(Q)}}return await j(H),J}function h(H,J){for(let j of J)if(L(H,j))return!0;return!1}function L(H,J){let j=J.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*").replace(/\?/g,".");return new RegExp(`^${j}$`).test(H)}function q(H,J=""){let j=J.replace(/\/$/,"");return`<?xml version="1.0" encoding="UTF-8"?>
17
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
18
- ${H.map((N)=>{let O=/^https?:\/\//.test(N.url)?N.url:`${j}${N.url}`,Q=N.lastmod?`
19
- <lastmod>${p(N.lastmod)}</lastmod>`:"",Z=N.changefreq?`
20
- <changefreq>${N.changefreq}</changefreq>`:"",_=N.priority!==void 0?`
21
- <priority>${N.priority.toFixed(1)}</priority>`:"";return` <url>
22
- <loc>${O}</loc>${Q}${Z}${_}
23
- </url>`}).join(`
24
- `)}
25
- </urlset>`}async function C(H,J,j,K,N){let O=d(H,N),Q=[];for(let V=0;V<O.length;V++){let W=`sitemap-${V+1}.xml`,B=q(O[V],j),G=z.join(J,W);await T.promises.writeFile(G,B,"utf-8"),Q.push(W)}let _=`<?xml version="1.0" encoding="UTF-8"?>
26
- <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
27
- ${Q.map((V)=>{return` <sitemap>
28
- <loc>${`${j}/${V}`}</loc>
29
- </sitemap>`}).join(`
30
- `)}
31
- </sitemapindex>`,$=z.join(J,K);await T.promises.writeFile($,_,"utf-8")}function p(H){return(typeof H==="string"?new Date(H):H).toISOString().split("T")[0]}function d(H,J){let j=[];for(let K=0;K<H.length;K+=J)j.push(H.slice(K,K+J));return j}
32
- export{R as w,u as x,g as y,l as z,a as A};
@@ -1,393 +0,0 @@
1
- // @bun
2
- import{A as v4,x as w4,y as C4}from"./chunk-5cxb3t2e.js";import{$ as P4,C as b4,D as z,F as o,I as I4,J as L4,K as x4,Z as k4}from"./chunk-he00q0q4.js";import{aa as F}from"./chunk-3f29kjd8.js";var{Glob:h4}=globalThis.Bun;import{copyFile as I6,mkdir as m4,readdir as L6,rename as x6,rm as t}from"fs/promises";import{existsSync as E6}from"fs";import{join as D,resolve as S6}from"path";import S from"process";import{CLI as F6}from"@stacksjs/clapp";var f="0.2.8";var{Glob:n4}=globalThis.Bun;import{dirname as i4,relative as s4,resolve as d,sep as X4}from"path";import{mkdir as r4}from"fs/promises";function Y4(K){return X4==="/"?K:K.split(X4).join("/")}function o4(K){let Z=new Bun.CryptoHasher("sha256");return Z.update(K),Z.digest("hex")}async function q4(K,Z,Q){let $=d(K),N=Q?Y4(s4($,d(Q))):void 0,X=[],q=new n4("**/*");for await(let j of q.scan({cwd:$,onlyFiles:!0})){let _=Y4(j);if(_===N)continue;X.push(_)}X.sort((j,_)=>j.localeCompare(_));let Y=[],W=new Bun.CryptoHasher("sha256");for(let j of X){let _=new Uint8Array(await Bun.file(d($,j)).arrayBuffer()),R=o4(_);Y.push({path:j,bytes:_.byteLength,sha256:R}),W.update(`${j}\x00${_.byteLength}\x00${R}
3
- `)}return{schema_version:1,generator:"bunpress",generator_version:Z,outputs:Y,tree_sha256:W.digest("hex")}}async function H4(K,Z,Q){let $=await q4(K,Q,Z);return await r4(i4(d(Z)),{recursive:!0}),await Bun.write(Z,`${JSON.stringify($,null,2)}
4
- `),$}function N4(K){return new Map(K.outputs.map((Z)=>[Z.path,Z]))}async function _4(K,Z,Q){let $=await Bun.file(Z).json();if($.schema_version!==1||$.generator!=="bunpress"||!Array.isArray($.outputs))throw Error(`Unsupported or malformed BunPress build manifest: ${Z}`);let N=await q4(K,Q,Z);if(JSON.stringify(N)===JSON.stringify($))return N;let X=N4($),q=N4(N),Y=N.outputs.filter((R)=>!X.has(R.path)).map((R)=>R.path),W=$.outputs.filter((R)=>!q.has(R.path)).map((R)=>R.path),j=N.outputs.filter((R)=>{let G=X.get(R.path);return G&&(G.bytes!==R.bytes||G.sha256!==R.sha256)}).map((R)=>{let G=X.get(R.path);return`${R.path} [bytes ${G.bytes} -> ${R.bytes}; sha256 ${G.sha256} -> ${R.sha256}]`}),_=[$.generator_version!==N.generator_version?`generator ${$.generator_version} -> ${N.generator_version}`:"",Y.length?`added: ${Y.join(", ")}`:"",W.length?`removed: ${W.join(", ")}`:"",j.length?`changed: ${j.join(", ")}`:""].filter(Boolean);throw Error(`BunPress output does not match ${Z}: ${_.join("; ")||"tree hash changed"}`)}import{existsSync as t4}from"fs";import{rm as e4}from"fs/promises";import{join as K6}from"path";var L={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 O(K,Z){return`${L[Z]}${K}${L.reset}`}function T(K){console.log(`${L.green}\u2713${L.reset} ${K}`)}function U(K){console.error(`${L.red}\u2717${L.reset} ${K}`)}function p(K){console.warn(`${L.yellow}\u26A0${L.reset} ${K}`)}function M(K){console.log(`${L.blue}\u2139${L.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 a(K){if(K<1000)return`${K}ms`;if(K<60000)return`${(K/1000).toFixed(2)}s`;return`${(K/60000).toFixed(2)}m`}var W4=!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.BUILDKITE||process.env.CIRCLECI||process.env.GITLAB_CI);class v{frames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];index=0;interval=null;text;constructor(K){this.text=K}start(){if(W4){console.log(` ${this.text}`);return}process.stdout.write("\x1B[?25l"),this.interval=setInterval(()=>{let K=this.frames[this.index];process.stdout.write(`\r${L.cyan}${K}${L.reset} ${this.text}`),this.index=(this.index+1)%this.frames.length},80)}succeed(K){this.stop(),T(K||this.text)}fail(K){this.stop(),U(K||this.text)}stop(){if(this.interval)clearInterval(this.interval),this.interval=null;if(!W4)process.stdout.write("\r\x1B[K"),process.stdout.write("\x1B[?25h")}update(K){this.text=K}}async function c(K,Z=!1){let Q=Z?"Y/n":"y/N";process.stdout.write(`${L.cyan}?${L.reset} ${K} ${L.dim}(${Q})${L.reset}: `);let $=Bun.file("/dev/stdin").stream().getReader(),N=new TextDecoder,{value:X}=await $.read(),q=N.decode(X).trim().toLowerCase();if(!q)return Z;return q==="y"||q==="yes"}function m(K){if(K.length===0)return;let Z=Object.keys(K[0]),Q={};for(let N of Z)Q[N]=Math.max(N.length,...K.map((X)=>String(X[N]).length));let $=Z.map((N)=>N.padEnd(Q[N])).join(" ");console.log(O($,"bold")),console.log("\u2500".repeat($.length));for(let N of K){let X=Z.map((q)=>String(N[q]).padEnd(Q[q])).join(" ");console.log(X)}}async function l(K){try{return Bun.file(K).size}catch{return 0}}async function Q6(K){try{let{Glob:Z}=awaitPromise.resolve(globalThis.Bun),Q=new Z("**/*"),$=0;for await(let N of Q.scan(K)){let X=`${K}/${N}`,q=await l(X);$+=q}return $}catch{return 0}}async function R4(K={}){let Z=await z,Q=K.outdir||Z.outDir||"./dist",$=K6(Q,".bunpress"),N=K.force||!1,X=K.verbose||!1;try{if(!t4($))return M(`Directory "${$}" does not exist, nothing to clean`),!0;let Y=await Q6($);if(X)M(`Found "${$}" (${b(Y)})`);if(!N){if(!await c(`Delete "${$}" directory? (${b(Y)})`,!1))return M("Clean cancelled"),!1}let W=process.env.VITEST==="true"||!1,j=null;if(!W&&!X)j=new v("Cleaning build artifacts..."),j.start();if(await e4($,{recursive:!0,force:!0}),j)j.succeed(`Cleaned ${b(Y)} from "${$}"`);else if(X||W)T(`Cleaned ${b(Y)} from "${$}"`);return!0}catch(q){return U(`Failed to clean directory: ${q}`),!1}}import{existsSync as n}from"fs";import{join as i}from"path";async function j4(K={}){try{let Z=["bunpress.config.ts","bunpress.config.js"],Q=null;for(let N of Z){let X=i(process.cwd(),N);if(n(X)){Q=X;break}}if(!Q)return U("No configuration file found"),M('Run "bunpress config init" to create one'),!1;T(`Configuration file: ${Q}`),console.log();let $=await Bun.file(Q).text();return console.log(O("Configuration:","bold")),console.log($),!0}catch(Z){return U(`Failed to show configuration: ${Z}`),!1}}async function G4(K={}){let Z=K.verbose||!1;try{let Q=["bunpress.config.ts","bunpress.config.js"],$=null;for(let Y of Q){let W=i(process.cwd(),Y);if(n(W)){$=W;break}}if(!$)return U("No configuration file found"),!1;if(Z)M(`Validating ${$}...`);let X=(await import($)).default;if(!X)return U("Configuration file does not export a default object"),!1;let q=[];if(X.markdown){if(X.markdown.toc&&typeof X.markdown.toc!=="object"&&typeof X.markdown.toc!=="boolean")q.push("markdown.toc should be an object or boolean");if(X.markdown.features){if(typeof X.markdown.features!=="object")q.push("markdown.features should be an object")}}if(X.nav){if(!Array.isArray(X.nav))q.push("nav should be an array");else for(let[Y,W]of X.nav.entries())if(!W.text||!W.link)q.push(`nav[${Y}] is missing required fields (text, link)`)}if(X.sitemap){if(!X.sitemap.hostname)q.push("sitemap.hostname is required for SEO")}if(q.length>0){U("Configuration validation failed:");for(let Y of q)console.log(` \u2022 ${Y}`);return!1}return T("Configuration is valid \u2713"),!0}catch(Q){return U(`Failed to validate configuration: ${Q}`),!1}}async function U4(K={}){let Z=i(process.cwd(),"bunpress.config.ts");if(n(Z))return U("Configuration file already exists"),!1;let Q=`import type { BunPressConfig } from '@stacksjs/bunpress'
5
-
6
- export default {
7
- verbose: false,
8
-
9
- markdown: {
10
- toc: {
11
- enabled: true,
12
- position: 'sidebar',
13
- minDepth: 2,
14
- maxDepth: 3,
15
- },
16
- features: {
17
- inlineFormatting: true,
18
- containers: true,
19
- githubAlerts: true,
20
- codeBlocks: {
21
- lineNumbers: true,
22
- lineHighlighting: true,
23
- focus: true,
24
- diff: true,
25
- errorWarning: true,
26
- },
27
- codeGroups: true,
28
- codeImports: true,
29
- inlineToc: true,
30
- customAnchors: true,
31
- emoji: true,
32
- badges: true,
33
- includes: true,
34
- externalLinks: {
35
- enabled: true,
36
- openInNewTab: true,
37
- addIcon: true,
38
- },
39
- imageLazyLoading: true,
40
- tables: {
41
- responsive: true,
42
- striped: true,
43
- hover: true,
44
- },
45
- },
46
- },
47
-
48
- nav: [
49
- { text: 'Home', link: '/' },
50
- { text: 'Guide', link: '/guide/' },
51
- ],
52
-
53
- sitemap: {
54
- hostname: 'https://example.com',
55
- },
56
- } satisfies BunPressConfig
57
- `;try{return await Bun.write(Z,Q),T(`Created ${Z}`),!0}catch($){return U(`Failed to create configuration: ${$}`),!1}}import{existsSync as k}from"fs";import{join as P}from"path";function V4(){let Z=["bunpress","docs"].flatMap(($)=>[`${$}.config`,`.${$}.config`,$,`.${$}`]),Q=[".ts",".js",".mjs",".cjs",".json"];return Z.flatMap(($)=>Q.map((N)=>`${$}${N}`))}async function A4(K={}){let Z=K.verbose||!1,Q=[];console.log(O(`
58
- Running diagnostics...
59
- `,"bold")),Q.push({name:"Bun Runtime",status:"pass",message:`v${Bun.version}`});let $=V4().find((H)=>k(P(process.cwd(),H)));if($)Q.push({name:"Configuration",status:"pass",message:$});else Q.push({name:"Configuration",status:"pass",message:"using defaults (no config file)",detail:`Looked for: ${V4().join(", ")}`});let N=K.dir||z.docsDir||"./docs",X=P(process.cwd(),N);if(k(X)){let{Glob:H}=awaitPromise.resolve(globalThis.Bun),x=new H("**/*.md"),E=0;for await(let A of x.scan(X))E++;Q.push({name:"Documentation",status:E>0?"pass":"warn",message:`${E} markdown files in ${N}`,fix:E>0?void 0:`Add a .md file under ${N}, or run "bunpress new index"`})}else Q.push({name:"Documentation",status:"fail",message:`${N} not found`,fix:'Run "bunpress init" to create the docs directory',detail:`Resolved from ${K.dir?"--dir":z.docsDir?"config docsDir":"the default"}`});let q=P(process.cwd(),"package.json");if(k(q)){let H=await Bun.file(q).json(),x=H.scripts?.dev,E=H.scripts?.build;Q.push({name:"Package Scripts",status:x&&E?"pass":"warn",message:`dev: ${x?"\u2713":"\u2717"}, build: ${E?"\u2713":"\u2717"}`,fix:x&&E?void 0:'Add "dev": "bunpress dev" and "build": "bunpress build" to package.json scripts'});let A=H.dependencies?.["@stacksjs/bunpress"]||H.devDependencies?.["@stacksjs/bunpress"];if(H.name==="@stacksjs/bunpress"||k(P(process.cwd(),"packages","bunpress","package.json")))Q.push({name:"BunPress Package",status:"pass",message:"this is the BunPress source repository"});else Q.push({name:"BunPress Package",status:A?"pass":"warn",message:A||"not declared in package.json",fix:A?void 0:'Run "bun add -d @stacksjs/bunpress"'})}else Q.push({name:"Package.json",status:"warn",message:"Not found",fix:'Run "bun init" to create one'});let Y=P(process.cwd(),"node_modules");if(k(Y))Q.push({name:"Dependencies",status:"pass",message:"node_modules found"});else Q.push({name:"Dependencies",status:"warn",message:"node_modules not found",fix:'Run "bun install"'});let W=P(process.cwd(),".git");if(k(W))Q.push({name:"Git Repository",status:"pass",message:"Initialized"});else Q.push({name:"Git Repository",status:"warn",message:"Not initialized",fix:'Run "git init" \u2014 without it, "last updated" falls back to file timestamps'});let j=P(process.cwd(),"tsconfig.json");if(k(j))Q.push({name:"TypeScript",status:"pass",message:"tsconfig.json found"});else Q.push({name:"TypeScript",status:"warn",message:"tsconfig.json not found",fix:"Only needed for a TypeScript config file \u2014 safe to ignore otherwise"});for(let H of Q){let x=H.status==="pass"?"\u2713":H.status==="fail"?"\u2717":"\u26A0",E=H.status==="pass"?"green":H.status==="fail"?"red":"yellow";if(console.log(` ${O(x,E)} ${H.name}: ${O(H.message,"dim")}`),Z&&H.detail)console.log(` ${O(H.detail,"dim")}`)}console.log();let _=Q.filter((H)=>H.status==="pass").length,R=Q.filter((H)=>H.status==="fail").length,G=Q.filter((H)=>H.status==="warn").length,B=Q.filter((H)=>H.status!=="pass"&&H.fix);if(B.length>0){M("Recommended actions:");for(let H of B)console.log(` \u2022 ${H.fix}`);console.log()}if(R>0)return U(`${R} checks failed, ${G} warnings`),!1;if(G>0)return p(`${_} checks passed, ${G} warnings`),!0;return T(`All ${_} checks passed!`),!0}import{mkdir as s}from"fs/promises";var Z6=`import type { BunPressConfig } from '@stacksjs/bunpress'
60
-
61
- export default {
62
- verbose: false,
63
-
64
- markdown: {
65
- toc: {
66
- enabled: true,
67
- position: 'sidebar',
68
- minDepth: 2,
69
- maxDepth: 3,
70
- },
71
- features: {
72
- inlineFormatting: true,
73
- containers: true,
74
- githubAlerts: true,
75
- codeBlocks: {
76
- lineNumbers: true,
77
- lineHighlighting: true,
78
- focus: true,
79
- diff: true,
80
- errorWarning: true,
81
- },
82
- codeGroups: true,
83
- codeImports: true,
84
- inlineToc: true,
85
- customAnchors: true,
86
- emoji: true,
87
- badges: true,
88
- includes: true,
89
- externalLinks: {
90
- enabled: true,
91
- openInNewTab: true,
92
- addIcon: true,
93
- },
94
- imageLazyLoading: true,
95
- tables: {
96
- responsive: true,
97
- striped: true,
98
- hover: true,
99
- },
100
- },
101
- },
102
-
103
- nav: [
104
- { text: 'Home', link: '/' },
105
- { text: 'Guide', link: '/guide/' },
106
- { text: 'GitHub', link: 'https://github.com/stacksjs/bunpress' },
107
- ],
108
-
109
- sitemap: {
110
- hostname: 'https://example.com',
111
- },
112
- } satisfies BunPressConfig
113
- `,$6=`---
114
- layout: home
115
- title: Welcome to My Documentation
116
-
117
- hero:
118
- name: My Project
119
- text: Modern documentation made easy
120
- tagline: Fast, flexible, and beautiful documentation powered by BunPress
121
- actions:
122
- - theme: brand
123
- text: Get Started
124
- link: /guide/
125
- - theme: alt
126
- text: View on GitHub
127
- link: https://github.com/yourusername/your-repo
128
-
129
- features:
130
- - icon: \u26A1
131
- title: Lightning Fast
132
- details: Powered by Bun runtime for incredible build and dev server performance
133
- - icon: \uD83C\uDFA8
134
- title: Beautiful by Default
135
- details: Clean, modern design with dark mode support out of the box
136
- - icon: \uD83D\uDCDD
137
- title: Markdown Enhanced
138
- details: Extended markdown features including containers, code groups, and more
139
- ---
140
-
141
- # Welcome
142
-
143
- This is your new BunPress documentation site. Start editing files in the \`docs/\` directory to customize your content.
144
- `,X6=`# Getting Started
145
-
146
- Welcome to the getting started guide!
147
-
148
- ## Installation
149
-
150
- \`\`\`bash
151
- bun install @stacksjs/bunpress
152
- \`\`\`
153
-
154
- ## Quick Start
155
-
156
- Create your first documentation page:
157
-
158
- \`\`\`bash
159
- bunpress new my-page
160
- \`\`\`
161
-
162
- ## Next Steps
163
-
164
- ::: tip
165
- Check out the [markdown extensions](/guide/markdown) to learn about all the powerful features available.
166
- :::
167
-
168
- - Learn about [configuration](/guide/configuration)
169
- - Explore [advanced features](/guide/advanced)
170
- - Read the [API reference](/api/)
171
- `,Y6=`node_modules/
172
- dist/
173
- .DS_Store
174
- *.log
175
- .env
176
- .env.*
177
- !.env.example
178
- `,N6=`# My BunPress Documentation
179
-
180
- Documentation powered by [BunPress](https://github.com/stacksjs/bunpress).
181
-
182
- ## Development
183
-
184
- Start the dev server:
185
-
186
- \`\`\`bash
187
- bun run dev
188
- \`\`\`
189
-
190
- ## Build
191
-
192
- Build the documentation:
193
-
194
- \`\`\`bash
195
- bun run build
196
- \`\`\`
197
-
198
- ## Preview
199
-
200
- Preview the built site:
201
-
202
- \`\`\`bash
203
- bun run preview
204
- \`\`\`
205
- `;async function J4(K={}){try{if(await Bun.file("./docs").exists()&&!K.force){if(!await c("Documentation directory already exists. Continue?",!1))return M("Initialization cancelled"),!1}let Q=new v("Initializing BunPress project...");Q.start(),await s("./docs",{recursive:!0}),await s("./docs/guide",{recursive:!0}),await s("./docs/public",{recursive:!0}),await Bun.write("./bunpress.config.ts",Z6),await Bun.write("./docs/index.md",$6),await Bun.write("./docs/guide/index.md",X6);let $=await Bun.file("./.gitignore").exists();if(!$)await Bun.write("./.gitignore",Y6);let N=await Bun.file("./README.md").exists();if(!N)await Bun.write("./README.md",N6);let X="./package.json";if(await Bun.file(X).exists()){let Y=await Bun.file(X).json();Y.scripts=Y.scripts||{},Y.scripts.dev=Y.scripts.dev||"bunpress dev",Y.scripts.build=Y.scripts.build||"bunpress build",Y.scripts.preview=Y.scripts.preview||"bunpress preview",await Bun.write(X,JSON.stringify(Y,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(!N)console.log(" \u2022 README.md");return console.log(),M("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 U(`Failed to initialize project: ${Z}`),!1}}import{mkdir as q6}from"fs/promises";import{dirname as H6,join as _6}from"path";var M4={default:(K)=>`---
206
- title: ${K}
207
- description:
208
- ---
209
-
210
- # ${K}
211
-
212
- Your content goes here...
213
- `,guide:(K)=>`---
214
- title: ${K}
215
- description: ${K} guide
216
- ---
217
-
218
- # ${K}
219
-
220
- ## Introduction
221
-
222
- Brief introduction to the topic.
223
-
224
- ## Getting Started
225
-
226
- Step-by-step instructions.
227
-
228
- ## Examples
229
-
230
- \`\`\`typescript
231
- // Example code
232
- \`\`\`
233
-
234
- ## Next Steps
235
-
236
- - [ ] Task 1
237
- - [ ] Task 2
238
- `,api:(K)=>`---
239
- title: ${K}
240
- description: API reference for ${K}
241
- ---
242
-
243
- # ${K}
244
-
245
- ## Overview
246
-
247
- Brief overview of the API.
248
-
249
- ## Methods
250
-
251
- ### \`methodName()\`
252
-
253
- Description of the method.
254
-
255
- **Parameters:**
256
-
257
- - \`param1\` (\`type\`) - Description
258
-
259
- **Returns:**
260
-
261
- - \`ReturnType\` - Description
262
-
263
- **Example:**
264
-
265
- \`\`\`typescript
266
- // Example usage
267
- \`\`\`
268
- `,blog:(K)=>`---
269
- title: ${K}
270
- description:
271
- date: ${new Date().toISOString().split("T")[0]}
272
- author:
273
- tags: []
274
- ---
275
-
276
- # ${K}
277
-
278
- Post content goes here...
279
-
280
- ## Section 1
281
-
282
- Content...
283
- `};async function B4(K,Z={}){try{let Q=K.endsWith(".md")?K:`${K}.md`,$=_6(process.cwd(),"docs",Q);if(await Bun.file($).exists())return U(`File already exists: ${Q}`),!1;let X=Z.title;if(!X)X=(Q.split("/").pop()?.replace(".md","")||"").split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(" ");let q=Z.template||"default",Y=M4[q];if(!Y)return U(`Unknown template: ${q}`),U(`Available templates: ${Object.keys(M4).join(", ")}`),!1;let W=Y(X),j=H6($);return await q6(j,{recursive:!0}),await Bun.write($,W),T(`Created ${Q}`),console.log(),console.log(` Title: ${X}`),console.log(` Template: ${q}`),console.log(` Path: ${$}`),!0}catch(Q){return U(`Failed to create file: ${Q}`),!1}}import{join as T4}from"path";async function z4(K={}){let Z=K.port||3000,Q=await z,$=K.outdir||Q.outDir||"./dist",N=T4($,".bunpress"),X=K.verbose||!1;try{let{stat:q}=await import("fs/promises");try{if(!(await q(N)).isDirectory())U(`"${N}" is not a directory.`),U('Run "bunpress build" first to generate the documentation.'),process.exit(1)}catch{U(`Build directory "${N}" not found.`),U('Run "bunpress build" first to generate the documentation.'),process.exit(1)}M(`Starting preview server from ${N}`);try{let Y=Bun.serve({port:Z,fetch:async(W)=>{let _=new URL(W.url).pathname;if(_.startsWith("/"))_=_.slice(1);if(_===""||_==="/")_="index.html";let R=T4(N,_),G=Bun.file(R);if(await G.exists())return new Response(G,{headers:{"Content-Type":W6(_)}});let H=`${R}.html`,x=Bun.file(H);if(await x.exists())return new Response(x,{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
284
- `),await new Promise(()=>{})}catch(Y){if(Y.message?.includes("EADDRINUSE")||Y.code==="EADDRINUSE")U(`Port ${Z} is already in use.`),U("Try running with a different port: bunpress preview --port <port>"),U(`Or stop any processes using port ${Z}`);else U(`Failed to start server: ${Y.message||Y}`);process.exit(1)}}catch(q){U(`Failed to start preview server: ${q}`),process.exit(1)}}function W6(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:E4}=globalThis.Bun;async function S4(K={}){let Z=await z,Q=K.dir||Z.docsDir||"./docs",$=K.fix||!1;if(M("\uD83D\uDD0D Running SEO checks..."),console.log(""),!w.existsSync(Q))U(`Documentation directory not found: ${Q}`),process.exit(1);let N={totalPages:0,errors:[],warnings:[],passed:0},X=await U6(Q);N.totalPages=X.length;for(let q of X)await R6(q,Q,N,$);if(j6(Z,Q,N),T6(N),N.errors.length>0)process.exit(1)}async function R6(K,Z,Q,$){let N=await w.promises.readFile(K,"utf-8"),{frontmatter:X,markdown:q}=V6(N),Y=y.relative(Z,K),W=!1,j=$&&Object.keys(X).length>0,_={...X},R=X.layout==="home"?X.hero?.text||X.hero?.name:void 0;if(!X.title&&R);else if(!X.title){let H=A6(q);if(!H)Q.errors.push({type:"error",category:"Title",file:Y,message:"Missing title in frontmatter"}),W=!0;else if($)_.title=H,j=!0,M(`\u2713 Added title to ${Y}: "${H}"`);else Q.warnings.push({type:"warning",category:"Title",file:Y,message:`No title in frontmatter (could extract: "${H}")`}),W=!0}else{let H=X.title.length;if(H>60)Q.warnings.push({type:"warning",category:"Title",file:Y,message:`Title too long (${H} chars, recommended <60)`}),W=!0;else if(H<10)Q.warnings.push({type:"warning",category:"Title",file:Y,message:`Title too short (${H} chars, recommended >10)`}),W=!0}if(!X.description){let H=J6(q);if($)_.description=H,j=!0,M(`\u2713 Added description to ${Y}`);else Q.warnings.push({type:"warning",category:"Description",file:Y,message:"Missing description in frontmatter"}),W=!0}else{let H=X.description.length;if(H>160)Q.warnings.push({type:"warning",category:"Description",file:Y,message:`Description too long (${H} chars, recommended <160)`}),W=!0;else if(H<50)Q.warnings.push({type:"warning",category:"Description",file:Y,message:`Description too short (${H} chars, recommended >50)`}),W=!0}let G=M6(q,Z,K);for(let H of G)Q.errors.push({type:"error",category:"Links",file:Y,message:`Broken internal link: ${H}`}),W=!0;let B=B6(q);for(let H of B)Q.warnings.push({type:"warning",category:"Images",file:Y,message:`Image missing alt text: ${H}`}),W=!0;if(j){let H=G6(_,q);await w.promises.writeFile(K,H,"utf-8")}if(!W)Q.passed++}function j6(K,Z,Q){let $=new Set,N=(Y,W)=>{if(typeof Y!=="string"||!Y.startsWith("/"))return;let j=`${W}:${Y}`;if($.has(j))return;$.add(j);let[_,R]=Y.split("#"),G=F4(y.resolve(Z,`.${_}`));if(!G){Q.errors.push({type:"error",category:"Links",file:W,message:`Broken link: ${Y}`});return}if(R&&!r(G).has(R))Q.errors.push({type:"error",category:"Links",file:W,message:`Broken anchor: ${Y}`})},X=(Y,W)=>{if(!Array.isArray(Y))return;for(let j of Y){if(!j||typeof j!=="object")continue;let _=j;N(_.link,W),X(_.items,W)}};X(K.nav,"config nav"),X(K.themeConfig?.nav,"themeConfig nav");let q=[[K.markdown?.sidebar,"config sidebar"],[K.themeConfig?.sidebar,"themeConfig sidebar"]];for(let[Y,W]of q)if(Array.isArray(Y))X(Y,W);else if(Y&&typeof Y==="object")for(let[j,_]of Object.entries(Y))X(_,`${W} ${j}`)}function G6(K,Z){return`---
285
- ${E4.stringify(K,null,2)}
286
- ---
287
- ${Z}`}async function U6(K){let Z=[];async function Q($){let N=await w.promises.readdir($,{withFileTypes:!0});for(let X of N){let q=y.join($,X.name);if(X.isDirectory()){if(!X.name.startsWith(".")&&X.name!=="node_modules"&&X.name!=="public")await Q(q)}else if(X.isFile()&&X.name.endsWith(".md"))Z.push(q)}}return await Q(K),Z}function V6(K){let Z=/^---\n([\s\S]*?)\n---\n?/,Q=K.match(Z);if(!Q)return{frontmatter:{},markdown:K};let $=Q[1],N=K.slice(Q[0].length);try{return{frontmatter:E4.parse($),markdown:N}}catch{return{frontmatter:{},markdown:K}}}function A6(K){let Z=K.match(/^#\s+(.+)$/m);return Z?Z[1].trim():null}function J6(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(`
288
-
289
- `)[0]||Q;if($.length>Z)return`${$.slice(0,Z)}...`;return $||"Documentation page"}function M6(K,Z,Q){let $=[],N=/\[([^\]]+)\]\(([^)]+)\)/g,X=o(K).replace(/`+[^`\n]*`+/g,"").replace(/<!--[\s\S]*?-->/g,""),q;while((q=N.exec(X))!==null){let Y=q[2].trim();if(/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(Y))continue;let W=Y.includes("#")?Y.slice(Y.indexOf("#")+1):"";if(Y.startsWith("#")){if(W&&!r(Q).has(W))$.push(Y);continue}let j=Y.split("#",1)[0].split("?",1)[0];if(!j)continue;let _;try{_=decodeURIComponent(j.replace(/^<|>$/g,""))}catch{$.push(Y);continue}let R=_.startsWith("/")?y.resolve(Z,`.${_}`):y.resolve(y.dirname(Q),_),G=F4(R);if(!G){$.push(Y);continue}if(W&&!r(G).has(W))$.push(Y)}return $}function F4(K){let Z=K.endsWith(".md")?[K]:[K,`${K}.md`,y.join(K,"index.md")];for(let Q of Z)try{if(w.statSync(Q).isFile())return Q}catch{}return null}var O4=new Map;function r(K){let Z=O4.get(K);if(Z)return Z;let Q=new Set;try{let $=o(w.readFileSync(K,"utf8"));for(let N of $.split(`
290
- `)){let X=N.match(/^#{1,6}\s+(.*)$/);if(!X)continue;let q=X[1].trim(),Y=q.match(/\{#([\w-]+)\}\s*$/),W=Y?Y[1]:L4(I4(q));if(!W)continue;x4(W,Q)}}catch{}return O4.set(K,Q),Q}function B6(K){let Z=[],Q=/!\[([^\]]*)\]\(([^)]+)\)/g,$;while(($=Q.exec(K))!==null){let N=$[1],X=$[2];if(!N||N.trim()==="")Z.push(X)}return Z}function T6(K){if(console.log(""),M("\uD83D\uDCCA SEO Report"),console.log(""),console.log(`Total pages checked: ${O(K.totalPages.toString(),"blue")}`),console.log(`Passed: ${O(K.passed.toString(),"green")}`),console.log(`Errors: ${O(K.errors.length.toString(),K.errors.length>0?"red":"green")}`),console.log(`Warnings: ${O(K.warnings.length.toString(),K.warnings.length>0?"yellow":"green")}`),console.log(""),K.errors.length>0){U(`\u2717 ${K.errors.length} errors found:`),console.log("");let Z=K.errors.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));m(Z),console.log("")}if(K.warnings.length>0){p(`\u26A0 ${K.warnings.length} warnings found:`),console.log("");let Z=K.warnings.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));m(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 z6}from"path";async function O6(K){let Z=await Bun.file(K).text(),Q=Z.split(`
291
- `),$=0,N=!1,X=[];for(let j of Q){if(j.trim().startsWith("```")){N=!N;continue}if(!N)X.push(j)}$=X.join(" ").split(/\s+/).filter((j)=>j.length>0).length;let Y=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:Y,codeBlocks:Math.floor(W)}}async function y4(K={}){let Z=await z,Q=K.dir||Z.docsDir||"./docs",$=K.verbose||!1;try{console.log(O(`
292
- Analyzing documentation...
293
- `,"bold"));let{Glob:N}=awaitPromise.resolve(globalThis.Bun),X=new N("**/*.md"),q=[];for await(let A of X.scan(Q)){let V=z6(Q,A),g=await O6(V);q.push(g)}if(q.length===0)return U("No markdown files found"),!1;let Y=q.reduce((A,V)=>A+V.size,0),W=q.reduce((A,V)=>A+V.lines,0),j=q.reduce((A,V)=>A+V.words,0),_=q.reduce((A,V)=>A+V.headings,0),R=q.reduce((A,V)=>A+V.codeBlocks,0);if(console.log(O("Summary","bold")),console.log("\u2500".repeat(50)),console.log(`Files: ${q.length}`),console.log(`Total size: ${b(Y)}`),console.log(`Total lines: ${W.toLocaleString()}`),console.log(`Total words: ${j.toLocaleString()}`),console.log(`Headings: ${_}`),console.log(`Code blocks: ${R}`),console.log(),$){console.log(O("Per-file Statistics","bold")),console.log("\u2500".repeat(50));let A=q.map((V)=>({File:V.path.replace(`${Q}/`,""),Size:b(V.size),Lines:V.lines,Words:V.words,Headings:V.headings,"Code Blocks":V.codeBlocks}));m(A),console.log()}let G=Y/q.length,B=W/q.length,H=j/q.length;console.log(O("Averages per File","bold")),console.log("\u2500".repeat(50)),console.log(`Size: ${b(G)}`),console.log(`Lines: ${Math.round(B)}`),console.log(`Words: ${Math.round(H)}`),console.log();let x=[...q].sort((A,V)=>V.size-A.size).slice(0,5);if(x.length>0){console.log(O("Top 5 Largest Files","bold")),console.log("\u2500".repeat(50));for(let A of x){let V=A.path.replace(`${Q}/`,"");console.log(` ${V.padEnd(40)} ${b(A.size)}`)}console.log()}let E=Math.ceil(j/200);return M(`Estimated reading time: ${E} minutes`),!0}catch(N){return U(`Failed to generate statistics: ${N}`),!1}}var I=new F6("bunpress"),J={outdir:z.outDir||"./dist",docsdir:z.docsDir||"./docs",port:3000,open:!0,watch:!0,verbose:z.verbose};async function g4(K){let Z=new h4("**/*.md"),Q=[];for await(let $ of Z.scan(K))Q.push(D(K,$));return Q}async function y6(K,Z,Q=!1){let $=`${Z}/public`;try{await L6($);let N=new h4("**/*");for await(let X of N.scan($)){let q=D($,X),Y=D(K,X);await m4(D(K,X.split("/").slice(0,-1).join("/")),{recursive:!0}),await I6(q,Y)}}catch{if(Q)console.log("No public directory found, skipping static assets copy")}}function D6(K,Z,Q){let $=Z.replace(/^\.\//,""),N=(_)=>_.replace(/^\.\//,"").replace($,"").replace(/^\//,"").replace(/\.md$/,"");if(!Q.enabled)return K.map((_)=>({sourceFile:_,relativePath:N(_),locale:Q.defaultLocale}));let X=Q.locales,q=new Set(X),Y=new Map;for(let _ of X)Y.set(_,new Map);let W=new Set;for(let _ of K){let R=N(_),G=R.split("/");if(G.length>1&&q.has(G[0])&&G[0]!==Q.defaultLocale){let H=G.slice(1).join("/");Y.get(G[0]).set(H,_),W.add(H);continue}let B=R.match(/^(.*)\.([A-Za-z-]+)$/);if(B&&q.has(B[2])){Y.get(B[2]).set(B[1],_),W.add(B[1]);continue}Y.get(Q.defaultLocale).set(R,_),W.add(R)}let j=[];for(let _ of X)for(let R of W){let G=Y.get(_).get(R)??Y.get(Q.defaultLocale).get(R);if(!G)continue;j.push({sourceFile:G,relativePath:R,locale:_})}return j}async function b6(K,Z,Q,$){if((Q.search??Q.markdown?.search)?.enabled===!1)return;try{let N=await P4(K,Q);if(await Bun.write(D(Z,k4.replace(/^\//,"")),JSON.stringify(N)),$)console.log(`Indexed ${N.length} sections for search.`)}catch(N){if($)console.error("Error generating search index:",N)}}async function w6(K,Z,Q){try{let $=await z;if($.sitemap?.enabled!==!1&&$.sitemap?.baseUrl)await v4(K,Z,$);if($.robots?.enabled!==!1)await C4(Z,$);if($.rss?.enabled)await w4(K,Z,$,$.rss)}catch($){if(Q)console.error("Error generating SEO files:",$)}}async function C6(K={}){let Z=await z;if(!K.config)return Z;let Q=S6(S.cwd(),K.config);if(!E6(Q))throw Error(`Config file not found: ${Q}`);let $=await import(Q),N=$.default??$;return b4({...Z,...N})}async function D4(K={}){if(K.manifest&&K.checkManifest)throw Error("--manifest and --check-manifest are mutually exclusive");let Z=await C6(K),Q=K.outdir||Z.outDir||J.outdir,$=D(Q,".bunpress"),N=`${$}.tmp-${S.pid}`,X=K.dir||Z.docsDir||J.docsdir,q=K.verbose??J.verbose,Y=K.minify??!1,W=K.sourcemap??!1,j=performance.now(),_=new v("Building documentation...");if(!q)_.start();await t(N,{recursive:!0,force:!0}),await m4(N,{recursive:!0});let R=await g4(X);if(R.length===0){if(!q)_.fail("No markdown files found in docs directory");else console.log("No markdown files found in docs directory");return!1}if(q)console.log(`Found ${R.length} markdown files:`),R.forEach((G)=>console.log(`- ${G}`));try{let{markdownToHtml:G,wrapInLayout:B}=await import("./chunk-6we3d5xh.js"),{loadI18nTranslations:H,resolveI18nConfig:x}=await import("./chunk-m6pshd6t.js"),{mkdir:E,writeFile:A}=await import("fs/promises"),V=await H(x(Z),Z);if(q)console.log("Transforming markdown to HTML...");let g=D6(R,X,V);for(let C of g){let u4=await Bun.file(C.sourceFile).text(),{html:f4,frontmatter:Q4}=await G(u4,X),h=C.relativePath,d4=`/${h}`,p4=Q4.layout||"doc",c4=await B(f4,Z,d4,p4,Q4,{i18n:V,locale:C.locale,sourceFile:C.sourceFile,docsDir:X}),l4=h==="index"||h.endsWith("/index"),Z4=C.locale&&C.locale!==V.defaultLocale&&V.enabled?D(N,C.locale):N,u=l4?D(Z4,`${h}.html`):D(Z4,h,"index.html"),$4=u.substring(0,u.lastIndexOf("/"));if($4)await E($4,{recursive:!0});if(await A(u,c4),q)console.log(`Generated: ${u}`)}if(q)console.log(`Processed ${R.length} markdown files into ${g.length} pages.`);if(await y6(N,X,q),await k6(N),await v6(N,Z),K.searchIndex!==!1)await b6(X,N,Z,q||!1);if(await w6(X,N,q||!1),K.checkManifest)await _4(N,K.checkManifest,f);if(await t($,{recursive:!0,force:!0}),await x6(N,$),K.manifest)await H4($,K.manifest,f);let K4=performance.now()-j;if(!q)_.succeed(`Built ${R.length} pages to HTML in ${a(K4)}`);else T(`Build completed in ${a(K4)}`),console.log(`
294
- Generated ${R.length} HTML files in ${$}`);return!0}catch(G){if(await t(N,{recursive:!0,force:!0}),!q)_.fail("Build failed");return console.error("Error during build:",G),!1}}async function v6(K,Z){let{getConfiguredBasePath:Q,wrapInLayout:$}=await import("./chunk-6we3d5xh.js"),X=`
295
- <style>
296
- .NotFound {
297
- padding: 64px 24px 96px;
298
- text-align: center;
299
- }
300
-
301
- @media (min-width: 768px) {
302
- .NotFound {
303
- padding: 96px 32px 168px;
304
- }
305
- }
306
-
307
- .NotFound .code {
308
- line-height: 64px;
309
- font-size: 64px;
310
- font-weight: 600;
311
- }
312
-
313
- .NotFound .title {
314
- padding-top: 12px;
315
- letter-spacing: 2px;
316
- line-height: 20px;
317
- font-size: 20px;
318
- font-weight: 700;
319
- }
320
-
321
- .NotFound .divider {
322
- margin: 24px auto 18px;
323
- width: 64px;
324
- height: 1px;
325
- background-color: var(--vp-c-divider);
326
- }
327
-
328
- .NotFound .quote {
329
- margin: 0 auto;
330
- max-width: 256px;
331
- font-size: 14px;
332
- font-weight: 500;
333
- color: var(--vp-c-text-2);
334
- }
335
-
336
- .NotFound .action {
337
- padding-top: 20px;
338
- }
339
-
340
- .NotFound .link {
341
- display: inline-block;
342
- border: 1px solid var(--vp-c-brand-1);
343
- border-radius: 16px;
344
- padding: 3px 16px;
345
- font-size: 14px;
346
- font-weight: 500;
347
- color: var(--vp-c-brand-1);
348
- transition: border-color 0.25s, color 0.25s;
349
- text-decoration: none;
350
- }
351
-
352
- .NotFound .link:hover {
353
- border-color: var(--vp-c-brand-2);
354
- color: var(--vp-c-brand-2);
355
- }
356
- </style>
357
-
358
- <div class="NotFound">
359
- <p class="code">404</p>
360
- <h1 class="title">PAGE NOT FOUND</h1>
361
- <div class="divider"></div>
362
- <blockquote class="quote">
363
- But if you don't change your direction, and if you keep looking, you may end up where you are heading.
364
- </blockquote>
365
- <div class="action">
366
- <a class="link" href="${`${Q(Z)}/`}" aria-label="go to home">
367
- Take me home
368
- </a>
369
- </div>
370
- </div>
371
- `,q=await $(X,Z,"/404","doc");await Bun.write(D(K,"404.html"),q)}async function k6(K){let Z=D(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("--manifest <path>","Write a deterministic rendered-tree manifest").option("--check-manifest <path>","Fail unless the rendered tree matches a checked manifest").option("--search-index","Write the client search index (on by default; --no-search-index skips it)",{default:!0}).option("--watch","Watch for changes and rebuild",{default:!1}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await D4(K))S.exit(1);if(K.watch){let{watch:Q}=await import("fs"),$=await z,N=K.dir||$.docsDir||"./docs";console.log(`
372
- Watching for changes...`),Q(N,{recursive:!0},async(X,q)=>{if(q&&q.endsWith(".md"))console.log(`
373
- Detected change in ${q}, rebuilding...`),await D4(K)}),await new Promise(()=>{})}});I.command("dev","Build and serve documentation using BunPress server").option("--port <port>","Port to listen on",{default:J.port}).option("--dir <dir>","Documentation directory").option("--watch","Watch for changes",{default:J.watch}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{let Z=await z,Q=K.port||J.port,$=K.dir||Z.docsDir||J.docsdir,N=K.watch??J.watch,X=K.verbose??J.verbose;if(X)console.log("Starting BunPress dev server with options:",{port:Q,root:$,watch:N,verbose:X});let{serveCLI:q}=await import("./chunk-6we3d5xh.js");await q({port:Q,root:$,watch:N,config:Z})});async function P6(K={}){let Z=await z,Q=K.dir||Z.docsDir||J.docsdir,$=K.output||"./docs.md",N=K.full??!1,X=K.verbose??J.verbose;if(X)console.log(`Generating LLM markdown from ${Q}`),console.log(`Output file: ${$}`),console.log(`Full content: ${N}`);let q=await g4(Q);if(q.length===0)return console.log("No markdown files found in docs directory"),!1;if(X)console.log(`Found ${q.length} markdown files`);q.sort();let Y=`# Documentation
374
-
375
- `;Y+=`Generated: ${new Date().toISOString()}
376
-
377
- `,Y+=`Total files: ${q.length}
378
-
379
- `,Y+=`---
380
-
381
- `;for(let W of q){let j=W.replace(`${Q}/`,""),_=await Bun.file(W).text();if(X)console.log(`Processing: ${j}`);if(Y+=`## File: ${j}
382
-
383
- `,N)Y+=_,Y+=`
384
-
385
- `;else{let R=_.split(`
386
- `),G=!1,B="";for(let H of R){if(H.trim()==="---")if(!G){G=!0;continue}else{if(G=!1,B)Y+="**Frontmatter:**\n```yaml\n",Y+=B,Y+="```\n\n",B="";continue}if(G){B+=`${H}
387
- `;continue}if(H.match(/^#{1,6}\s+/))Y+=`${H}
388
- `}Y+=`
389
- `}Y+=`---
390
-
391
- `}return await Bun.write($,Y),console.log(`
392
- LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(Y.length/1024).toFixed(2)} KB`),!0}I.command("llm","Generate LLM-friendly markdown file from documentation").option("--dir <dir>","Documentation directory (defaults to config docsDir)").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:J.verbose}).action(async(K)=>{if(!await P6(K))S.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 J4(K))S.exit(1)});I.command("preview","Preview the built documentation site").option("--port <port>","Port to listen on",{default:J.port}).option("--outdir <outdir>","Output directory (looks for .bunpress folder inside)").option("--open","Open in browser",{default:!1}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{await z4(K)});I.command("clean","Clean build artifacts").option("--outdir <outdir>","Output directory to clean",{default:J.outdir}).option("--force","Skip confirmation prompt",{default:!1}).option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await R4(K))S.exit(1)});I.command("doctor","Run diagnostic checks on the project").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await A4(K))S.exit(1)});I.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await j4(K))S.exit(1)});I.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await G4(K))S.exit(1)});I.command("config:init","Initialize configuration file").action(async(K)=>{if(!await U4(K))S.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:J.verbose}).action(async(K,Z)=>{if(!await B4(K,Z))S.exit(1)});I.command("stats","Show documentation statistics").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:J.verbose}).action(async(K)=>{if(!await y4(K))S.exit(1)});I.command("seo:check","Check SEO for all documentation pages").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--fix","Automatically fix issues (add missing titles/descriptions)",{default:!1}).action(async(K)=>{await S4(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:J.verbose}).action(async(K)=>{let{deployCommand:Z}=await import("./chunk-cw47386k.js");if(!await Z(K))S.exit(1)});I.help();I.version(f);var e=Bun.argv[1]||"",h6=e.endsWith("/bunpress")||e.endsWith("/cli.ts")||e.endsWith("/cli.js");if(h6)I.parse();
393
- export{T as p,U as q,M as r,v as s,g4 as t,C6 as u,D4 as v};