@stacksjs/bunpress 0.2.16 → 0.2.17
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{t as a,u as b,v as c}from"../chunk-
|
|
3
|
+
import{t as a,u as b,v as c}from"../chunk-r5g5120d.js";import"../chunk-s7tcgrb6.js";import"../chunk-kvkhq8vp.js";import"../chunk-4r44z49z.js";export{b as resolveConfig,a as findMarkdownFiles,c as buildDocs};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{p as $,q as I,r as f,s as h,v as x}from"./chunk-
|
|
2
|
+
import{p as $,q as I,r as f,s as h,v as x}from"./chunk-r5g5120d.js";import"./chunk-s7tcgrb6.js";import{D as _}from"./chunk-kvkhq8vp.js";import"./chunk-4r44z49z.js";import{join as D}from"path";var E="@stacksjs/ts-cloud";async function Y(){try{return await import(E)}catch(j){throw Error(`Deploying requires @stacksjs/ts-cloud, which is an optional dependency.
|
|
3
3
|
Install it with: bun add -d @stacksjs/ts-cloud
|
|
4
4
|
Original error: ${j instanceof Error?j.message:String(j)}`)}}function W(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 F(j={}){let A=await _,k=A.cloud||{},m=j.verbose??A.verbose??!1;if(k.driver&&k.driver!=="aws")return I(`Unsupported cloud driver: ${k.driver}. Only 'aws' is implemented.`),!1;let 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=W(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(`
|
|
5
5
|
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(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{A as k4,x as C4,y as v4}from"./chunk-s7tcgrb6.js";import{$ as h4,C as b4,D as O,F as e,I as L4,J as x4,K as E4,Z as P4}from"./chunk-kvkhq8vp.js";import{aa as F,ba as a}from"./chunk-4r44z49z.js";var{Glob:m4}=globalThis.Bun;import{copyFile as L6,mkdir as g4,readdir as x6,rename as E6,rm as K4}from"fs/promises";import{existsSync as S6}from"fs";import{join as D,resolve as F6}from"path";import E from"process";import{CLI as y6}from"@stacksjs/clapp";var p="0.2.
|
|
2
|
+
import{A as k4,x as C4,y as v4}from"./chunk-s7tcgrb6.js";import{$ as h4,C as b4,D as O,F as e,I as L4,J as x4,K as E4,Z as P4}from"./chunk-kvkhq8vp.js";import{aa as F,ba as a}from"./chunk-4r44z49z.js";var{Glob:m4}=globalThis.Bun;import{copyFile as L6,mkdir as g4,readdir as x6,rename as E6,rm as K4}from"fs/promises";import{existsSync as S6}from"fs";import{join as D,resolve as F6}from"path";import E from"process";import{CLI as y6}from"@stacksjs/clapp";var p="0.2.17";var{Glob:i4}=globalThis.Bun;import{dirname as s4,relative as r4,resolve as c,sep as N4}from"path";import{mkdir as o4}from"fs/promises";function q4(K){return N4==="/"?K:K.split(N4).join("/")}function t4(K){let Z=new Bun.CryptoHasher("sha256");return Z.update(K),Z.digest("hex")}async function _4(K,Z,Q){let $=c(K),Y=Q?q4(r4($,c(Q))):void 0,X=[],q=new i4("**/*");for await(let R of q.scan({cwd:$,onlyFiles:!0})){let _=q4(R);if(_===Y)continue;X.push(_)}X.sort((R,_)=>R.localeCompare(_));let N=[],W=new Bun.CryptoHasher("sha256");for(let R of X){let _=new Uint8Array(await Bun.file(c($,R)).arrayBuffer()),G=t4(_);N.push({path:R,bytes:_.byteLength,sha256:G}),W.update(`${R}\x00${_.byteLength}\x00${G}
|
|
3
3
|
`)}return{schema_version:1,generator:"bunpress",generator_version:Z,outputs:N,tree_sha256:W.digest("hex")}}async function W4(K,Z,Q){let $=await _4(K,Q,Z);return await o4(s4(c(Z)),{recursive:!0}),await Bun.write(Z,`${JSON.stringify($,null,2)}
|
|
4
4
|
`),$}function H4(K){return new Map(K.outputs.map((Z)=>[Z.path,Z]))}async function R4(K,Z,Q){let $=await Bun.file(Z).json();if($.schema_version!==1||$.generator!=="bunpress"||!Array.isArray($.outputs))throw Error(`Unsupported or malformed BunPress build manifest: ${Z}`);let Y=await _4(K,Q,Z);if(JSON.stringify(Y)===JSON.stringify($))return Y;let X=H4($),q=H4(Y),N=Y.outputs.filter((G)=>!X.has(G.path)).map((G)=>G.path),W=$.outputs.filter((G)=>!q.has(G.path)).map((G)=>G.path),R=Y.outputs.filter((G)=>{let V=X.get(G.path);return V&&(V.bytes!==G.bytes||V.sha256!==G.sha256)}).map((G)=>{let V=X.get(G.path);return`${G.path} [bytes ${V.bytes} -> ${G.bytes}; sha256 ${V.sha256} -> ${G.sha256}]`}),_=[$.generator_version!==Y.generator_version?`generator ${$.generator_version} -> ${Y.generator_version}`:"",N.length?`added: ${N.join(", ")}`:"",W.length?`removed: ${W.join(", ")}`:"",R.length?`changed: ${R.join(", ")}`:""].filter(Boolean);throw Error(`BunPress output does not match ${Z}: ${_.join("; ")||"tree hash changed"}`)}import{existsSync as e4}from"fs";import{rm as K6}from"fs/promises";import{join as Q6}from"path";var L={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m"};function z(K,Z){return`${L[Z]}${K}${L.reset}`}function T(K){console.log(`${L.green}\u2713${L.reset} ${K}`)}function j(K){console.error(`${L.red}\u2717${L.reset} ${K}`)}function h(K){console.warn(`${L.yellow}\u26A0${L.reset} ${K}`)}function B(K){console.log(`${L.blue}\u2139${L.reset} ${K}`)}function w(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 i(K){if(K<1000)return`${K}ms`;if(K<60000)return`${(K/1000).toFixed(2)}s`;return`${(K/60000).toFixed(2)}m`}var G4=!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.BUILDKITE||process.env.CIRCLECI||process.env.GITLAB_CI);class v{frames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];index=0;interval=null;text;constructor(K){this.text=K}start(){if(G4){console.log(` ${this.text}`);return}process.stdout.write("\x1B[?25l"),this.interval=setInterval(()=>{let K=this.frames[this.index];process.stdout.write(`\r${L.cyan}${K}${L.reset} ${this.text}`),this.index=(this.index+1)%this.frames.length},80)}succeed(K){this.stop(),T(K||this.text)}fail(K){this.stop(),j(K||this.text)}stop(){if(this.interval)clearInterval(this.interval),this.interval=null;if(!G4)process.stdout.write("\r\x1B[K"),process.stdout.write("\x1B[?25h")}update(K){this.text=K}}async function d(K,Z=!1){let Q=Z?"Y/n":"y/N";process.stdout.write(`${L.cyan}?${L.reset} ${K} ${L.dim}(${Q})${L.reset}: `);let $=Bun.file("/dev/stdin").stream().getReader(),Y=new TextDecoder,{value:X}=await $.read(),q=Y.decode(X).trim().toLowerCase();if(!q)return Z;return q==="y"||q==="yes"}function g(K){if(K.length===0)return;let Z=Object.keys(K[0]),Q={};for(let Y of Z)Q[Y]=Math.max(Y.length,...K.map((X)=>String(X[Y]).length));let $=Z.map((Y)=>Y.padEnd(Q[Y])).join(" ");console.log(z($,"bold")),console.log("\u2500".repeat($.length));for(let Y of K){let X=Z.map((q)=>String(Y[q]).padEnd(Q[q])).join(" ");console.log(X)}}async function l(K){try{return Bun.file(K).size}catch{return 0}}async function Z6(K){try{let{Glob:Z}=awaitPromise.resolve(globalThis.Bun),Q=new Z("**/*"),$=0;for await(let Y of Q.scan(K)){let X=`${K}/${Y}`,q=await l(X);$+=q}return $}catch{return 0}}async function V4(K={}){let Z=await O,Q=K.outdir||Z.outDir||"./dist",$=Q6(Q,".bunpress"),Y=K.force||!1,X=K.verbose||!1;try{if(!e4($))return B(`Directory "${$}" does not exist, nothing to clean`),!0;let N=await Z6($);if(X)B(`Found "${$}" (${w(N)})`);if(!Y){if(!await d(`Delete "${$}" directory? (${w(N)})`,!1))return B("Clean cancelled"),!1}let W=process.env.VITEST==="true"||!1,R=null;if(!W&&!X)R=new v("Cleaning build artifacts..."),R.start();if(await K6($,{recursive:!0,force:!0}),R)R.succeed(`Cleaned ${w(N)} from "${$}"`);else if(X||W)T(`Cleaned ${w(N)} from "${$}"`);return!0}catch(q){return j(`Failed to clean directory: ${q}`),!1}}import{existsSync as s}from"fs";import{join as r}from"path";async function j4(K={}){try{let Z=["bunpress.config.ts","bunpress.config.js"],Q=null;for(let Y of Z){let X=r(process.cwd(),Y);if(s(X)){Q=X;break}}if(!Q)return j("No configuration file found"),B('Run "bunpress config init" to create one'),!1;T(`Configuration file: ${Q}`),console.log();let $=await Bun.file(Q).text();return console.log(z("Configuration:","bold")),console.log($),!0}catch(Z){return j(`Failed to show configuration: ${Z}`),!1}}async function A4(K={}){let Z=K.verbose||!1;try{let Q=["bunpress.config.ts","bunpress.config.js"],$=null;for(let W of Q){let R=r(process.cwd(),W);if(s(R)){$=R;break}}if(!$)return j("No configuration file found"),!1;if(Z)B(`Validating ${$}...`);let X=(await import($)).default;if(!X)return j("Configuration file does not export a default object"),!1;let q=[],N=[];if(X.markdown){if(X.markdown.toc&&typeof X.markdown.toc!=="object"&&typeof X.markdown.toc!=="boolean")q.push("markdown.toc should be an object or boolean");if(X.markdown.features){if(typeof X.markdown.features!=="object")q.push("markdown.features should be an object")}}if(X.nav){if(!Array.isArray(X.nav))q.push("nav should be an array");else for(let[W,R]of X.nav.entries())if(!R.text||!R.link)q.push(`nav[${W}] is missing required fields (text, link)`)}if(!a(X))N.push("no `url` set: sitemap, RSS, canonical links and Open Graph tags are all skipped without an absolute base URL");if(q.length>0){j("Configuration validation failed:");for(let W of q)console.log(` \u2022 ${W}`);return!1}for(let W of N)h(W);return T("Configuration is valid \u2713"),!0}catch(Q){return j(`Failed to validate configuration: ${Q}`),!1}}async function J4(K={}){let Z=r(process.cwd(),"bunpress.config.ts");if(s(Z))return j("Configuration file already exists"),!1;let Q=`import type { BunPressConfig } from '@stacksjs/bunpress'
|
|
5
5
|
|
|
@@ -389,5 +389,5 @@ Detected change in ${q}, rebuilding...`),await w4(K)}),await new Promise(()=>{})
|
|
|
389
389
|
`}N+=`---
|
|
390
390
|
|
|
391
391
|
`}return await Bun.write($,N),console.log(`
|
|
392
|
-
LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(N.length/1024).toFixed(2)} KB`),!0}I.command("llm","Generate LLM-friendly markdown file from documentation").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--output <output>","Output file path",{default:"./docs.md"}).option("--full","Include full content (not just titles and headings)",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await h6(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 B4(K))E.exit(1)});I.command("preview","Preview the built documentation site").option("--port <port>","Port to listen on",{default:M.port}).option("--outdir <outdir>","Output directory (looks for .bunpress folder inside)").option("--open","Open in browser",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{await O4(K)});I.command("clean","Clean build artifacts").option("--outdir <outdir>","Output directory to clean",{default:M.outdir}).option("--force","Skip confirmation prompt",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await V4(K))E.exit(1)});I.command("doctor","Run diagnostic checks on the project").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await U4(K))E.exit(1)});I.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await j4(K))E.exit(1)});I.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await A4(K))E.exit(1)});I.command("config:init","Initialize configuration file").action(async(K)=>{if(!await J4(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:M.verbose}).action(async(K,Z)=>{if(!await z4(K,Z))E.exit(1)});I.command("stats","Show documentation statistics").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await D4(K))E.exit(1)});I.command("seo:check","Check SEO for all documentation pages").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--fix","Automatically fix issues (add missing titles/descriptions)",{default:!1}).action(async(K)=>{await F4(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:M.verbose}).action(async(K)=>{let{deployCommand:Z}=await import("./chunk-
|
|
392
|
+
LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(N.length/1024).toFixed(2)} KB`),!0}I.command("llm","Generate LLM-friendly markdown file from documentation").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--output <output>","Output file path",{default:"./docs.md"}).option("--full","Include full content (not just titles and headings)",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await h6(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 B4(K))E.exit(1)});I.command("preview","Preview the built documentation site").option("--port <port>","Port to listen on",{default:M.port}).option("--outdir <outdir>","Output directory (looks for .bunpress folder inside)").option("--open","Open in browser",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{await O4(K)});I.command("clean","Clean build artifacts").option("--outdir <outdir>","Output directory to clean",{default:M.outdir}).option("--force","Skip confirmation prompt",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await V4(K))E.exit(1)});I.command("doctor","Run diagnostic checks on the project").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await U4(K))E.exit(1)});I.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await j4(K))E.exit(1)});I.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await A4(K))E.exit(1)});I.command("config:init","Initialize configuration file").action(async(K)=>{if(!await J4(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:M.verbose}).action(async(K,Z)=>{if(!await z4(K,Z))E.exit(1)});I.command("stats","Show documentation statistics").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await D4(K))E.exit(1)});I.command("seo:check","Check SEO for all documentation pages").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--fix","Automatically fix issues (add missing titles/descriptions)",{default:!1}).action(async(K)=>{await F4(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:M.verbose}).action(async(K)=>{let{deployCommand:Z}=await import("./chunk-1d8gksnh.js");if(!await Z(K))E.exit(1)});I.help();I.version(p);var Q4=Bun.argv[1]||"",m6=Q4.endsWith("/bunpress")||Q4.endsWith("/cli.ts")||Q4.endsWith("/cli.js");if(m6)I.parse();
|
|
393
393
|
export{T as p,j as q,B as r,v as s,f4 as t,v6 as u,w4 as v};
|