@stacksjs/bunpress 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/bin/cli.js +1 -1
- package/dist/chunk-2dt48d7r.js +2 -0
- package/dist/chunk-3w4kkysy.js +9006 -0
- package/dist/chunk-4j30b1q3.js +658 -0
- package/dist/{chunk-szme5v1e.js → chunk-e9211y1k.js} +1 -1
- package/dist/chunk-h6ac3d60.js +3 -0
- package/dist/chunk-mwr0x3ag.js +496 -0
- package/dist/src/index.js +1 -1
- package/dist/templates/blocks/alerts/caution.stx +1 -1
- package/dist/templates/blocks/alerts/important.stx +1 -1
- package/dist/templates/blocks/alerts/note.stx +1 -1
- package/dist/templates/blocks/alerts/tip.stx +1 -1
- package/dist/templates/blocks/alerts/warning.stx +1 -1
- package/dist/templates/blocks/containers/danger.stx +1 -1
- package/dist/templates/blocks/containers/details.stx +1 -1
- package/dist/templates/blocks/containers/info.stx +1 -1
- package/dist/templates/blocks/containers/raw.stx +1 -1
- package/dist/templates/blocks/containers/tip.stx +1 -1
- package/dist/templates/blocks/containers/warning.stx +1 -1
- package/dist/templates/features.stx +4 -17
- package/dist/templates/hero.stx +62 -7
- package/dist/templates/layout-doc.stx +23 -21
- package/dist/templates/layout-home.stx +0 -2
- package/dist/templates/layout-page.stx +10 -10
- package/dist/templates/page-toc.stx +6 -1
- package/dist/templates/sidebar-section.stx +68 -12
- package/dist/templates/sidebar.stx +23 -1
- package/dist/themes/vitepress/index.d.ts +638 -0
- package/dist/themes/vitepress/index.ts +640 -0
- package/package.json +3 -3
- package/dist/chunk-1ymh7yt2.js +0 -9656
- package/dist/chunk-8qj79f0y.js +0 -2
- package/dist/chunk-z0redasq.js +0 -530
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as $,b as I,c as f,d as h,f as x}from"./chunk-
|
|
2
|
+
import{a as $,b as I,c as f,d as h,f as x}from"./chunk-mwr0x3ag.js";import{h as _}from"./chunk-3w4kkysy.js";import"./chunk-h6ac3d60.js";import{join as D}from"path";var Y="@stacksjs/ts-cloud";function E(j,A){let k=A||j?.provider;if(!k||k==="route53")return null;if(k==="porkbun"){let m=j?.apiKey||process.env.PORKBUN_API_KEY,w=j?.secretKey||process.env.PORKBUN_SECRET_KEY;if(!m||!w)throw Error("Porkbun API credentials not found. Set PORKBUN_API_KEY and PORKBUN_SECRET_KEY environment variables, or configure them in bunpress.config.ts under cloud.dnsProvider");return{provider:"porkbun",apiKey:m,secretKey:w}}if(k==="godaddy"){let m=j?.apiKey||process.env.GODADDY_API_KEY,w=j?.secretKey||process.env.GODADDY_API_SECRET,J=j?.environment||process.env.GODADDY_ENVIRONMENT;if(!m||!w)throw Error("GoDaddy API credentials not found. Set GODADDY_API_KEY and GODADDY_API_SECRET environment variables, or configure them in bunpress.config.ts under cloud.dnsProvider");return{provider:"godaddy",apiKey:m,apiSecret:w,environment:J}}throw Error(`Unknown DNS provider: ${k}. Supported: porkbun, godaddy, route53`)}async function v(j={}){let A=await _,k=A.cloud||{},m=j.verbose??A.verbose??!1,w=j.region||k.region||"us-east-1",J=j.domain||k.domain,M=j.subdomain||k.subdomain,N=j.baseDomain||k.baseDomain,O=j.bucket||k.bucket,P=j.stackName||k.stackName,U=j.hostedZoneId||k.hostedZoneId,Q=j.certificateArn||k.certificateArn,V=k.cacheControl||"max-age=31536000, public",B;if(J)B=J;else if(M&&N)B=`${M}.${N}`;let K=B?.replace(/\./g,"-")||"bunpress-site",G=null;try{G=E(k.dnsProvider,j.dnsProvider)}catch(H){return I(H.message),!1}let L=G!==null;if(j.dryRun){if(f("Dry run mode - no changes will be made"),console.log(`
|
|
3
3
|
Configuration:`),console.log(` Region: ${w}`),console.log(` Site Name: ${K}`),console.log(` Bucket: ${O||"auto-generated"}`),console.log(` Domain: ${B||"not specified"}`),console.log(` Stack Name: ${P||`${K}-static-site`}`),console.log(` DNS Provider: ${G?.provider||"route53 (AWS)"}`),!L)console.log(` Hosted Zone ID: ${U||"auto-detected"}`);return console.log(` Certificate ARN: ${Q||"auto-created"}`),!0}if(!process.env.AWS_ACCESS_KEY_ID||!process.env.AWS_SECRET_ACCESS_KEY)return I("AWS credentials not found. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables."),!1;let z=new h("Building documentation...");try{if(!m)z.start();if(!await x({verbose:m})){if(!m)z.fail("Build failed");return!1}if(!m)z.succeed("Documentation built successfully");let C=A.outDir||"./dist",X=D(C,".bunpress");if(!m)z.text="Deploying infrastructure with CloudFormation...",z.start();else if(console.log(`
|
|
4
4
|
Deploying with CloudFormation...`),L)console.log(`Using external DNS provider: ${G.provider}`);let q;if(L&&B){let R={siteName:K,region:w,domain:B,bucket:O,stackName:P,certificateArn:Q,cacheControl:V,defaultRootObject:"index.html",errorDocument:"404.html",sourceDir:X,dnsProvider:G,tags:{Project:"BunPress",Environment:k.environment||"production"},onProgress:Z(z,m)},{deployStaticSiteWithExternalDnsFull:T}=await import(Y);q=await T(R)}else{let R={siteName:K,region:w,bucket:O,domain:B,subdomain:M,baseDomain:N,stackName:P,hostedZoneId:U,certificateArn:Q,cacheControl:V,defaultRootObject:"index.html",errorDocument:"404.html",sourceDir:X,tags:{Project:"BunPress",Environment:k.environment||"production"},onProgress:Z(z,m)},{deployStaticSiteFull:T}=await import(Y);q=await T(R)}if(!q.success){if(!m)z.fail("Deployment failed");return I(q.message),!1}if(console.log(`
|
|
5
5
|
`+"=".repeat(50)),$("Deployment complete!"),console.log("=".repeat(50)),console.log(`
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{K as z6,h as L}from"./chunk-3w4kkysy.js";import{L as v}from"./chunk-h6ac3d60.js";var{Glob:L6}=globalThis.Bun;import{copyFile as A4,mkdir as I6,readdir as J4}from"fs/promises";import{join as y}from"path";import E from"process";import{CLI as M4}from"@stacksjs/clapp";var e="0.1.5";import*as K6 from"fs";import*as Q6 from"path";async function Z6(K,$){let Q=$.robots;if(Q?.enabled===!1)return;let Z=Q?.filename||"robots.txt",Y=D6($),N=Q6.join(K,Z);if(await K6.promises.writeFile(N,Y,"utf-8"),$.verbose)console.log(`\u2705 Robots.txt generated: ${N}`)}function D6(K){let $=K.robots,Q=[];if($?.rules&&$.rules.length>0)for(let Z of $.rules)Q.push(...k6(Z)),Q.push("");else Q.push("User-agent: *"),Q.push("Allow: /"),Q.push("");if($?.host)Q.push(`Host: ${$.host}`),Q.push("");if($?.sitemaps&&$.sitemaps.length>0){for(let Z of $.sitemaps)Q.push(`Sitemap: ${Z}`);Q.push("")}else if(K.sitemap?.enabled!==!1&&K.sitemap?.baseUrl){let Z=K.sitemap.filename||"sitemap.xml",Y=`${K.sitemap.baseUrl.replace(/\/$/,"")}/${Z}`;Q.push(`Sitemap: ${Y}`),Q.push("")}if($?.customContent)Q.push($.customContent),Q.push("");return`${Q.join(`
|
|
3
|
+
`).trim()}
|
|
4
|
+
`}function k6(K){let $=[];if($.push(`User-agent: ${K.userAgent}`),K.allow&&K.allow.length>0)for(let Q of K.allow)$.push(`Allow: ${Q}`);if(K.disallow&&K.disallow.length>0)for(let Q of K.disallow)$.push(`Disallow: ${Q}`);if(K.crawlDelay!==void 0)$.push(`Crawl-delay: ${K.crawlDelay}`);return $}var{YAML:C6}=globalThis.Bun;import*as p from"fs";import*as m from"path";async function $6(K,$,Q,Z){if(!Z?.enabled)return;let Y=Q.sitemap?.baseUrl;if(!Y){if(Q.verbose)console.warn("\u26A0\uFE0F RSS feed generation skipped: baseUrl not configured");return}let N=Z.title||Q.title||Q.markdown?.title||"Documentation Feed",H=Z.description||Q.description||Q.markdown?.meta?.description||"Documentation updates",X=Z.author||"Documentation Team",W=Z.email||"",q=Z.language||"en-us",V=Z.filename||"feed.xml",j=Z.maxItems||20,G=Z.fullContent||!1,_=await P6(K,Y,G);_.sort((A,J)=>J.pubDate.getTime()-A.pubDate.getTime());let M=_.slice(0,j),O=d6({title:N,description:H,link:Y,language:q,author:X,email:W,items:M}),x=m.join($,V);if(await p.promises.writeFile(x,O,"utf-8"),Q.verbose)console.log(`\u2705 RSS feed generated: ${x} (${M.length} items)`)}async function P6(K,$,Q){let Z=[],Y=await h6(K);for(let N of Y){let H=await p.promises.readFile(N,"utf-8"),{frontmatter:X,markdown:W}=m6(H);if(!X.date||!X.title)continue;let V=m.relative(K,N).replace(/\.md$/,"").replace(/index$/,"").replace(/\\/g,"/");if(!V.startsWith("/"))V=`/${V}`;if(V.endsWith("/")&&V!=="/")V=V.slice(0,-1);let j=`${$.replace(/\/$/,"")}${V}`,G=X.description||g6(W),_=new Date(X.date),M=X.author;Z.push({title:X.title,link:j,description:G,pubDate:_,author:M,content:Q?W:void 0})}return Z}async function h6(K){let $=[];async function Q(Z){let Y=await p.promises.readdir(Z,{withFileTypes:!0});for(let N of Y){let H=m.join(Z,N.name);if(N.isDirectory()){if(!N.name.startsWith(".")&&N.name!=="node_modules")await Q(H)}else if(N.isFile()&&N.name.endsWith(".md"))$.push(H)}}return await Q(K),$}function m6(K){let $=/^---\n([\s\S]*?)\n---\n?/,Q=K.match($);if(!Q)return{frontmatter:{},markdown:K};let Z=Q[1],Y=K.slice(Q[0].length);try{return{frontmatter:C6.parse(Z),markdown:Y}}catch{return{frontmatter:{},markdown:K}}}function g6(K,$=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(),Z=Q.split(`
|
|
5
|
+
|
|
6
|
+
`)[0]||Q;if(Z.length>$)return`${Z.slice(0,$)}...`;return Z}function d6(K){let $=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"/>`,Z," </channel>","</rss>"].join(`
|
|
16
|
+
`)}import*as C from"fs";import*as D from"path";async function N6(K,$,Q){let Z=Q.sitemap;if(Z?.enabled===!1)return;if(!Z?.baseUrl){if(Q.verbose)console.warn("\u26A0\uFE0F Sitemap generation skipped: baseUrl not configured");return}let Y=Z.baseUrl.replace(/\/$/,""),N=Z.filename||"sitemap.xml",H=Z.defaultPriority??0.5,X=Z.defaultChangefreq||"monthly",W=Z.maxUrlsPerFile||50000,q=Z.useSitemapIndex||!1,V=await p6(K,Y,H,X,Z.exclude||[],Z.priorityMap||{},Z.changefreqMap||{}),j=Z.transform?V.map((G)=>Z.transform(G)).filter(Boolean):V;if(Q.verbose)console.log(`\uD83D\uDCC4 Generated ${j.length} sitemap entries`);if(q&&j.length>W)await f6(j,$,Y,N,W);else{let G=Y6(j),_=D.join($,N);if(await C.promises.writeFile(_,G,"utf-8"),Q.verbose)console.log(`\u2705 Sitemap generated: ${_}`)}}async function p6(K,$,Q,Z,Y,N,H){let X=[],W=await u6(K);for(let q of W){let j=D.relative(K,q).replace(/\.md$/,"").replace(/index$/,"").replace(/\\/g,"/");if(!j.startsWith("/"))j=`/${j}`;if(j.endsWith("/")&&j!=="/")j=j.slice(0,-1);if(c6(j,Y))continue;let _=(await C.promises.stat(q)).mtime.toISOString(),M=Q;for(let[x,A]of Object.entries(N))if(a(j,x)){M=A;break}let O=Z;for(let[x,A]of Object.entries(H))if(a(j,x)){O=A;break}X.push({url:j,lastmod:_,changefreq:O,priority:M})}return X}async function u6(K){let $=[];async function Q(Z){let Y=await C.promises.readdir(Z,{withFileTypes:!0});for(let N of Y){let H=D.join(Z,N.name);if(N.isDirectory()){if(!N.name.startsWith(".")&&N.name!=="node_modules")await Q(H)}else if(N.isFile()&&N.name.endsWith(".md"))$.push(H)}}return await Q(K),$}function c6(K,$){for(let Q of $)if(a(K,Q))return!0;return!1}function a(K,$){let Q=$.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*").replace(/\?/g,".");return new RegExp(`^${Q}$`).test(K)}function Y6(K){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
17
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
18
|
+
${K.map((Q)=>{let Z=Q.url,Y=Q.lastmod?`
|
|
19
|
+
<lastmod>${H6(Q.lastmod)}</lastmod>`:"",N=Q.changefreq?`
|
|
20
|
+
<changefreq>${Q.changefreq}</changefreq>`:"",H=Q.priority!==void 0?`
|
|
21
|
+
<priority>${Q.priority.toFixed(1)}</priority>`:"";return` <url>
|
|
22
|
+
<loc>${Z}</loc>${Y}${N}${H}
|
|
23
|
+
</url>`}).join(`
|
|
24
|
+
`)}
|
|
25
|
+
</urlset>`}async function f6(K,$,Q,Z,Y){let N=l6(K,Y),H=[];for(let V=0;V<N.length;V++){let j=`sitemap-${V+1}.xml`,G=Y6(N[V]),_=D.join($,j);await C.promises.writeFile(_,G,"utf-8"),H.push(j)}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 j=`${Q}/${V}`,G=new Date().toISOString();return` <sitemap>
|
|
28
|
+
<loc>${j}</loc>
|
|
29
|
+
<lastmod>${H6(G)}</lastmod>
|
|
30
|
+
</sitemap>`}).join(`
|
|
31
|
+
`)}
|
|
32
|
+
</sitemapindex>`,q=D.join($,Z);await C.promises.writeFile(q,W,"utf-8")}function H6(K){return(typeof K==="string"?new Date(K):K).toISOString().split("T")[0]}function l6(K,$){let Q=[];for(let Z=0;Z<K.length;Z+=$)Q.push(K.slice(Z,Z+$));return Q}import{existsSync as a6}from"fs";import{rm as n6}from"fs/promises";import{join as s6}from"path";var S={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,$){return`${S[$]}${K}${S.reset}`}function T(K){console.log(`${S.green}\u2713${S.reset} ${K}`)}function B(K){console.error(`${S.red}\u2717${S.reset} ${K}`)}function u(K){console.warn(`${S.yellow}\u26A0${S.reset} ${K}`)}function U(K){console.log(`${S.blue}\u2139${S.reset} ${K}`)}function b(K){if(K===0)return"0 B";let $=1024,Q=["B","KB","MB","GB"],Z=Math.floor(Math.log(K)/Math.log($));return`${Number.parseFloat((K/$**Z).toFixed(2))} ${Q[Z]}`}function n(K){if(K<1000)return`${K}ms`;if(K<60000)return`${(K/1000).toFixed(2)}s`;return`${(K/60000).toFixed(2)}m`}var X6=!!(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(X6){console.log(` ${this.text}`);return}process.stdout.write("\x1B[?25l"),this.interval=setInterval(()=>{let K=this.frames[this.index];process.stdout.write(`\r${S.cyan}${K}${S.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(!X6)process.stdout.write("\r\x1B[K"),process.stdout.write("\x1B[?25h")}update(K){this.text=K}}async function c(K,$=!1){let Q=$?"Y/n":"y/N";process.stdout.write(`${S.cyan}?${S.reset} ${K} ${S.dim}(${Q})${S.reset}: `);let Z=Bun.file("/dev/stdin").stream().getReader(),Y=new TextDecoder,{value:N}=await Z.read(),H=Y.decode(N).trim().toLowerCase();if(!H)return $;return H==="y"||H==="yes"}function g(K){if(K.length===0)return;let $=Object.keys(K[0]),Q={};for(let Y of $)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(Z,"bold")),console.log("\u2500".repeat(Z.length));for(let Y of K){let N=$.map((H)=>String(Y[H]).padEnd(Q[H])).join(" ");console.log(N)}}async function f(K){try{return Bun.file(K).size}catch{return 0}}async function i6(K){try{let{Glob:$}=awaitPromise.resolve(globalThis.Bun),Q=new $("**/*"),Z=0;for await(let Y of Q.scan(K)){let N=`${K}/${Y}`,H=await f(N);Z+=H}return Z}catch{return 0}}async function _6(K={}){let $=await L,Q=K.outdir||$.outDir||"./dist",Z=s6(Q,".bunpress"),Y=K.force||!1,N=K.verbose||!1;try{if(!a6(Z))return U(`Directory "${Z}" does not exist, nothing to clean`),!0;let X=await i6(Z);if(N)U(`Found "${Z}" (${b(X)})`);if(!Y){if(!await c(`Delete "${Z}" directory? (${b(X)})`,!1))return U("Clean cancelled"),!1}let W=process.env.VITEST==="true"||!1,q=null;if(!W&&!N)q=new k("Cleaning build artifacts..."),q.start();if(await n6(Z,{recursive:!0,force:!0}),q)q.succeed(`Cleaned ${b(X)} from "${Z}"`);else if(N||W)T(`Cleaned ${b(X)} from "${Z}"`);return!0}catch(H){return B(`Failed to clean directory: ${H}`),!1}}import{existsSync as s}from"fs";import{join as i}from"path";async function W6(K={}){try{let $=["bunpress.config.ts","bunpress.config.js"],Q=null;for(let Y of $){let N=i(process.cwd(),Y);if(s(N)){Q=N;break}}if(!Q)return B("No configuration file found"),U('Run "bunpress config init" to create one'),!1;T(`Configuration file: ${Q}`),console.log();let Z=await Bun.file(Q).text();return console.log(z("Configuration:","bold")),console.log(Z),!0}catch($){return B(`Failed to show configuration: ${$}`),!1}}async function V6(K={}){let $=K.verbose||!1;try{let Q=["bunpress.config.ts","bunpress.config.js"],Z=null;for(let X of Q){let W=i(process.cwd(),X);if(s(W)){Z=W;break}}if(!Z)return B("No configuration file found"),!1;if($)U(`Validating ${Z}...`);let N=(await import(Z)).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 j6(K={}){let $=i(process.cwd(),"bunpress.config.ts");if(s($))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($,Q),T(`Created ${$}`),!0}catch(Z){return B(`Failed to create configuration: ${Z}`),!1}}import{existsSync as P}from"fs";import{join as h}from"path";async function q6(K={}){let $=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 Z=["bunpress.config.ts","bunpress.config.js"],Y=!1;for(let _ of Z)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),M=new _("**/*.md"),O=0;for await(let x of M.scan(N))O++;Q.push({name:"Documentation",status:O>0?"pass":"warn",message:`${O} 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(),M=_.scripts?.dev,O=_.scripts?.build;Q.push({name:"Package Scripts",status:M&&O?"pass":"warn",message:`dev: ${M?"\u2713":"\u2717"}, build: ${O?"\u2713":"\u2717"}`});let x=_.dependencies?.["@stacksjs/bunpress"]||_.devDependencies?.["@stacksjs/bunpress"];Q.push({name:"BunPress Package",status:x?"pass":"warn",message:x||"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 q=h(process.cwd(),"tsconfig.json");if(P(q))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 M=_.status==="pass"?"\u2713":_.status==="fail"?"\u2717":"\u26A0",O=_.status==="pass"?"green":_.status==="fail"?"red":"yellow";console.log(` ${z(M,O)} ${_.name}: ${z(_.message,"dim")}`)}console.log();let V=Q.filter((_)=>_.status==="pass").length,j=Q.filter((_)=>_.status==="fail").length,G=Q.filter((_)=>_.status==="warn").length;if(j>0){if(B(`${j} checks failed, ${G} warnings`),console.log(),U("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 u(`${V} checks passed, ${G} warnings`),!0;else return T(`All ${V} checks passed!`),!0}import{mkdir as r}from"fs/promises";var r6=`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
|
+
`,o6=`---
|
|
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
|
+
`,t6=`# 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
|
+
`,e6=`node_modules/
|
|
200
|
+
dist/
|
|
201
|
+
.DS_Store
|
|
202
|
+
*.log
|
|
203
|
+
.env
|
|
204
|
+
.env.*
|
|
205
|
+
!.env.example
|
|
206
|
+
`,K4=`# 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 B6(K={}){try{if(await Bun.file("./docs").exists()&&!K.force){if(!await c("Documentation directory already exists. Continue?",!1))return U("Initialization cancelled"),!1}let Q=new k("Initializing BunPress project...");Q.start(),await r("./docs",{recursive:!0}),await r("./docs/guide",{recursive:!0}),await r("./docs/public",{recursive:!0}),await Bun.write("./bunpress.config.ts",r6),await Bun.write("./docs/index.md",o6),await Bun.write("./docs/guide/index.md",t6);let Z=await Bun.file("./.gitignore").exists();if(!Z)await Bun.write("./.gitignore",e6);let Y=await Bun.file("./README.md").exists();if(!Y)await Bun.write("./README.md",K4);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/"),!Z)console.log(" \u2022 .gitignore");if(!Y)console.log(" \u2022 README.md");return console.log(),U("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($){return B(`Failed to initialize project: ${$}`),!1}}import{mkdir as Q4}from"fs/promises";import{dirname as Z4,join as $4}from"path";var G6={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 A6(K,$={}){try{let Q=K.endsWith(".md")?K:`${K}.md`,Z=$4(process.cwd(),"docs",Q);if(await Bun.file(Z).exists())return B(`File already exists: ${Q}`),!1;let N=$.title;if(!N)N=(Q.split("/").pop()?.replace(".md","")||"").split("-").map((j)=>j.charAt(0).toUpperCase()+j.slice(1)).join(" ");let H=$.template||"default",X=G6[H];if(!X)return B(`Unknown template: ${H}`),B(`Available templates: ${Object.keys(G6).join(", ")}`),!1;let W=X(N),q=Z4(Z);return await Q4(q,{recursive:!0}),await Bun.write(Z,W),T(`Created ${Q}`),console.log(),console.log(` Title: ${N}`),console.log(` Template: ${H}`),console.log(` Path: ${Z}`),!0}catch(Q){return B(`Failed to create file: ${Q}`),!1}}import{join as J6}from"path";async function M6(K={}){let $=K.port||3000,Q=await L,Z=K.outdir||Q.outDir||"./dist",Y=J6(Z,".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)}U(`Starting preview server from ${Y}`);try{let X=Bun.serve({port:$,fetch:async(W)=>{let V=new URL(W.url).pathname;if(V.startsWith("/"))V=V.slice(1);if(V===""||V==="/")V="index.html";let j=J6(Y,V),G=Bun.file(j);if(await G.exists())return new Response(G,{headers:{"Content-Type":N4(V)}});let M=`${j}.html`,O=Bun.file(M);if(await O.exists())return new Response(O,{headers:{"Content-Type":"text/html"}});return new Response("404 - Not Found",{status:404})}});T(`Preview server running at http://localhost:${$}`),console.log(`Press Ctrl+C to stop
|
|
312
|
+
`),await new Promise(()=>{})}catch(X){if(X.message?.includes("EADDRINUSE")||X.code==="EADDRINUSE")B(`Port ${$} is already in use.`),B("Try running with a different port: bunpress preview --port <port>"),B(`Or stop any processes using port ${$}`);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 N4(K){let $=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"}[$||""]||"text/plain"}import*as F from"fs";import*as w from"path";var{YAML:R6}=globalThis.Bun;async function U6(K={}){let $=await L,Q=K.dir||$.docsDir||"./docs",Z=K.fix||!1;if(U("\uD83D\uDD0D Running SEO checks..."),console.log(""),!F.existsSync(Q))B(`Documentation directory not found: ${Q}`),process.exit(1);let Y={totalPages:0,errors:[],warnings:[],passed:0},N=await H4(Q);Y.totalPages=N.length;for(let H of N)await Y4(H,Q,Y,Z);if(q4(Y),Y.errors.length>0)process.exit(1)}async function Y4(K,$,Q,Z){let Y=await F.promises.readFile(K,"utf-8"),{frontmatter:N,markdown:H}=X4(Y),X=w.relative($,K),W=!1,q=!1,V={...N};if(!N.title){let _=_4(H);if(!_)Q.errors.push({type:"error",category:"Title",file:X,message:"Missing title in frontmatter"}),W=!0;else if(Z)V.title=_,q=!0,U(`\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 _=W4(H);if(Z)V.description=_,q=!0,U(`\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 j=V4(H,$,K);for(let _ of j)Q.errors.push({type:"error",category:"Links",file:X,message:`Broken internal link: ${_}`}),W=!0;let G=j4(H);for(let _ of G)Q.warnings.push({type:"warning",category:"Images",file:X,message:`Image missing alt text: ${_}`}),W=!0;if(q){let _=`---
|
|
313
|
+
${R6.stringify(V)}---
|
|
314
|
+
${H}`;await F.promises.writeFile(K,_,"utf-8")}if(!W)Q.passed++}async function H4(K){let $=[];async function Q(Z){let Y=await F.promises.readdir(Z,{withFileTypes:!0});for(let N of Y){let H=w.join(Z,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"))$.push(H)}}return await Q(K),$}function X4(K){let $=/^---\n([\s\S]*?)\n---\n?/,Q=K.match($);if(!Q)return{frontmatter:{},markdown:K};let Z=Q[1],Y=K.slice(Q[0].length);try{return{frontmatter:R6.parse(Z),markdown:Y}}catch{return{frontmatter:{},markdown:K}}}function _4(K){let $=K.match(/^#\s+(.+)$/m);return $?$[1].trim():null}function W4(K,$=155){let Q=K.replace(/^#{1,6}\s+.+$/gm,"").replace(/```[\s\S]*?```/g,"").replace(/`[^`]+`/g,"").replace(/!\[.*?\]\(.*?\)/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_~]/g,"").trim(),Z=Q.split(`
|
|
315
|
+
|
|
316
|
+
`)[0]||Q;if(Z.length>$)return`${Z.slice(0,$)}...`;return Z||"Documentation page"}function V4(K,$,Q){let Z=[],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=w.dirname(Q),W=w.resolve(X,H),q=W.endsWith(".md")?W:`${W}.md`;if(!F.existsSync(q)&&!F.existsSync(W))Z.push(H)}return Z}function j4(K){let $=[],Q=/!\[([^\]]*)\]\(([^)]+)\)/g,Z;while((Z=Q.exec(K))!==null){let Y=Z[1],N=Z[2];if(!Y||Y.trim()==="")$.push(N)}return $}function q4(K){if(console.log(""),U("\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 $=K.errors.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));g($),console.log("")}if(K.warnings.length>0){u(`\u26A0 ${K.warnings.length} warnings found:`),console.log("");let $=K.warnings.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));g($),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 B4}from"path";async function G4(K){let $=await Bun.file(K).text(),Q=$.split(`
|
|
317
|
+
`),Z=0,Y=!1,N=[];for(let q of Q){if(q.trim().startsWith("```")){Y=!Y;continue}if(!Y)N.push(q)}Z=N.join(" ").split(/\s+/).filter((q)=>q.length>0).length;let X=Q.filter((q)=>q.match(/^#{1,6}\s+/)).length,W=($.match(/```/g)||[]).length/2;return{path:K,size:await f(K),lines:Q.length,words:Z,headings:X,codeBlocks:Math.floor(W)}}async function O6(K={}){let $=await L,Q=K.dir||$.docsDir||"./docs",Z=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 J=B4(Q,A),l=await G4(J);H.push(l)}if(H.length===0)return B("No markdown files found"),!1;let X=H.reduce((A,J)=>A+J.size,0),W=H.reduce((A,J)=>A+J.lines,0),q=H.reduce((A,J)=>A+J.words,0),V=H.reduce((A,J)=>A+J.headings,0),j=H.reduce((A,J)=>A+J.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: ${q.toLocaleString()}`),console.log(`Headings: ${V}`),console.log(`Code blocks: ${j}`),console.log(),Z){console.log(z("Per-file Statistics","bold")),console.log("\u2500".repeat(50));let A=H.map((J)=>({File:J.path.replace(`${Q}/`,""),Size:b(J.size),Lines:J.lines,Words:J.words,Headings:J.headings,"Code Blocks":J.codeBlocks}));g(A),console.log()}let G=X/H.length,_=W/H.length,M=q/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(M)}`),console.log();let O=[...H].sort((A,J)=>J.size-A.size).slice(0,5);if(O.length>0){console.log(z("Top 5 Largest Files","bold")),console.log("\u2500".repeat(50));for(let A of O){let J=A.path.replace(`${Q}/`,"");console.log(` ${J.padEnd(40)} ${b(A.size)}`)}console.log()}let x=Math.ceil(q/200);return U(`Estimated reading time: ${x} minutes`),!0}catch(Y){return B(`Failed to generate statistics: ${Y}`),!1}}var I=new M4("bunpress"),R={outdir:L.outDir||"./dist",docsdir:L.docsDir||"./docs",port:3000,open:!0,watch:!0,verbose:L.verbose};async function x6(K){let $=new L6("**/*.md"),Q=[];for await(let Z of $.scan(K))Q.push(y(K,Z));return Q}async function R4(K,$,Q=!1){let Z=`${$}/public`;try{await J4(Z);let Y=new L6("**/*");for await(let N of Y.scan(Z)){let H=y(Z,N),X=y(K,N);await I6(y(K,N.split("/").slice(0,-1).join("/")),{recursive:!0}),await A4(H,X)}}catch{if(Q)console.log("No public directory found, skipping static assets copy")}}async function U4(K,$,Q){try{let Z=await L;if(Z.sitemap?.enabled!==!1&&Z.sitemap?.baseUrl)await N6(K,$,Z);if(Z.robots?.enabled!==!1)await Z6($,Z);if(Z.rss?.enabled)await $6(K,$,Z,Z.rss)}catch(Z){if(Q)console.error("Error generating SEO files:",Z)}}async function T6(K={}){let $=await L,Q=K.outdir||$.outDir||R.outdir,Z=y(Q,".bunpress"),Y=K.dir||$.docsDir||R.docsdir,N=K.verbose??R.verbose,H=K.minify??!1,X=K.sourcemap??!1,W=performance.now(),q=new k("Building documentation...");if(!N)q.start();await I6(Z,{recursive:!0});let V=await x6(Y);if(V.length===0){if(!N)q.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((j)=>console.log(`- ${j}`));try{let{markdownToHtml:j,wrapInLayout:G}=await import("./chunk-2dt48d7r.js"),{mkdir:_,writeFile:M}=await import("fs/promises");if(N)console.log("Transforming markdown to HTML...");for(let A of V){let J=await Bun.file(A).text(),{html:l,frontmatter:S6}=await j(J,Y),E6=A.replace(/^\.\//,""),b6=Y.replace(/^\.\//,""),o=E6.replace(b6,"").replace(/^\//,"").replace(/\.md$/,""),v6=`/${o}`,F6=S6.layout||"doc",w6=await G(l,$,v6,F6),d=y(Z,o+".html"),t=d.substring(0,d.lastIndexOf("/"));if(t)await _(t,{recursive:!0});if(await M(d,w6),N)console.log(`Generated: ${d}`)}if(N)console.log(`Processed ${V.length} markdown files.`);await R4(Z,Y,N),await T4(Z),await O4(Z,$),await U4(Y,Z,N||!1);let x=performance.now()-W;if(!N)q.succeed(`Built ${V.length} pages to HTML in ${n(x)}`);else T(`Build completed in ${n(x)}`),console.log(`
|
|
320
|
+
Generated ${V.length} HTML files in ${Z}`);return!0}catch(j){if(!N)q.fail("Build failed");return console.error("Error during build:",j),!1}}async function O4(K,$){let{wrapInLayout:Q}=await import("./chunk-2dt48d7r.js"),Z=`
|
|
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
|
+
`,$,"/404","doc");await Bun.write(y(K,"404.html"),Y)}async function T4(K){let $=y(K,"index.html");try{if(!await Bun.file($).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 T6(K))E.exit(1);if(K.watch){let{watch:Q}=await import("fs"),Z=await L,Y=K.dir||Z.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 T6(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 $=await L,Q=K.port||R.port,Z=K.dir||$.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:Z,watch:Y,verbose:N});await z6({port:Q,root:Z,watch:Y,config:$})});async function z4(K={}){let $=await L,Q=K.dir||$.docsDir||R.docsdir,Z=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: ${Z}`),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 q=W.replace(`${Q}/`,""),V=await Bun.file(W).text();if(N)console.log(`Processing: ${q}`);if(X+=`## File: ${q}
|
|
485
|
+
|
|
486
|
+
`,Y)X+=V,X+=`
|
|
487
|
+
|
|
488
|
+
`;else{let j=V.split(`
|
|
489
|
+
`),G=!1,_="";for(let M of j){if(M.trim()==="---")if(!G){G=!0;continue}else{if(G=!1,_)X+="**Frontmatter:**\n```yaml\n",X+=_,X+="```\n\n",_="";continue}if(G){_+=`${M}
|
|
490
|
+
`;continue}if(M.match(/^#{1,6}\s+/))X+=`${M}
|
|
491
|
+
`}X+=`
|
|
492
|
+
`}X+=`---
|
|
493
|
+
|
|
494
|
+
`}return await Bun.write(Z,X),console.log(`
|
|
495
|
+
LLM markdown generated successfully: ${Z}`),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 z4(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 B6(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 M6(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 _6(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 q6(K))E.exit(1)});I.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{if(!await W6(K))E.exit(1)});I.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:R.verbose}).action(async(K)=>{if(!await V6(K))E.exit(1)});I.command("config:init","Initialize configuration file").action(async(K)=>{if(!await j6(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,$)=>{if(!await A6(K,$))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 O6(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 U6(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:$}=await import("./chunk-e9211y1k.js");if(!await $(K))E.exit(1)});I.help();I.version(e);I.parse();
|
|
496
|
+
export{T as a,B as b,U as c,k as d,x6 as e,T6 as f};
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{A as
|
|
2
|
+
import{A as L,B as M,C as N,D as O,E as P,F as Q,G as R,H as S,I as T,J as V,K as W,g as t,h as b,i as e,j as h,k as j,l as k,m as q,n as u,o as v,p as w,q as z,r as B,s as D,t as E,u as F,v as G,w as H,x as I,y as J,z as K}from"../chunk-3w4kkysy.js";import"../chunk-h6ac3d60.js";export{S as wrapInLayout,V as startServer,W as serveCLI,h as resetHighlighter,O as processInlineTocSyntax,w as prewarmHighlighter,j as normalizeLanguage,T as markdownToHtml,k as isLanguageSupported,u as highlightCodeSync,q as highlightCode,v as getSyntaxHighlightingStyles,z as getHighlighterInstance,e as getConfig,E as generateUniqueSlug,Q as generateTocStyles,R as generateTocScripts,N as generateTocPositions,I as generateTocHtml,M as generateTocData,D as generateSlug,K as generateSidebarTocHtml,J as generateInlineTocHtml,L as generateFloatingTocHtml,H as filterHeadings,F as extractHeadings,P as enhanceHeadingsWithAnchors,B as defaultTocConfig,t as defaultConfig,b as config,G as buildTocHierarchy};
|