@stacksjs/bunpress 0.1.8 → 0.1.10

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