@stacksjs/cli 0.75.258 → 0.75.259

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 CHANGED
@@ -9,6 +9,37 @@ The simple way to build beautiful CLIs.
9
9
  - 🚦 Elegant terminal spinners
10
10
  - ⛑️ Helper methods to run commands
11
11
 
12
+ ## Capturing bounded command output
13
+
14
+ Use the narrow `@stacksjs/cli/process` entry for a finite command whose text
15
+ output needs explicit limits. Arguments are passed directly to the executable.
16
+ Both output streams are drained concurrently, and nonzero exit codes are returned
17
+ with their bounded diagnostics.
18
+
19
+ ```ts
20
+ import { runBoundedProcess } from '@stacksjs/cli/process'
21
+
22
+ const result = await runBoundedProcess(['git', 'rev-parse', 'HEAD'], {
23
+ cwd: '/trusted/source',
24
+ timeoutMs: 10000,
25
+ stdoutBytes: 65536,
26
+ stderrBytes: 65536,
27
+ label: 'Source revision',
28
+ })
29
+
30
+ if (result.exitCode !== 0)
31
+ throw new Error('Source inspection failed', { cause: result })
32
+ ```
33
+
34
+ All three limits are required positive integers. Timeouts are at most 120,000 ms;
35
+ each stream is capped at 2,000,000 bytes before UTF-8 decoding. Stdin is ignored.
36
+ Output overflow, read errors and deadlines reject after owned cleanup. Original
37
+ failure values and cleanup errors are retained without coercing them to strings.
38
+ On POSIX the command gets its own process group, which is terminated on completion
39
+ or failure, including descendants holding inherited pipes. On Windows cleanup
40
+ covers the direct process and readers. Use this API for finite inspection or build
41
+ probes whose descendants should end with the command.
42
+
12
43
  ## 🤖 Usage
13
44
 
14
45
  ```bash
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './commands';
4
4
  export * from './exec';
5
5
  export * from './helpers';
6
6
  export * from './parse';
7
+ export * from './process';
7
8
  export * from './output';
8
9
  export * from './prompts';
9
10
  export * from './run';
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- import Me from"process";async function Ie(e,t={silent:!0}){let r=t.packageManager??"bun",n=[r==="npm"?"install":"add"];if(t.dev)n.push("-D");if(t.preferOffline&&r!=="bun")n.push("--prefer-offline");if(t.additionalArgs)n.push(...t.additionalArgs);n.push(e);let i=await Bun.spawn([r,...n],{cwd:t.cwd??Me.cwd(),stdout:t.silent?"ignore":"inherit",stderr:t.silent?"ignore":"inherit",stdin:"ignore",env:Me.env}).exited;if(i!==0)throw Error(`Failed to install ${e} (exit code ${i})`)}async function Kt(e,t){return Ie(e,t??{silent:!0})}async function Ht(e,t){return Ie(`@stacksjs/${e}`,t??{silent:!0})}import{CLI as Jt,cli as rt,onUnknownSubcommand as Qt}from"@stacksjs/clapp";function Xt(e,t){if(typeof e==="object")t=e,e=t.name;return rt(e||"buddy")}import{existsSync as V,readdirSync as ot}from"fs";import{join as Te}from"path";var it=/(?:\.test|\.spec|\.bench|\.d)\.ts$/;function st(e){return e.endsWith(".ts")&&!it.test(e)&&!e.startsWith("_")}function at(e){if(!V(e))return[];let t=[],r=(n,o)=>{for(let i of ot(n,{withFileTypes:!0})){if(i.name.startsWith(".")||i.name==="node_modules")continue;if(i.isDirectory()){r(Te(n,i.name),`${o}${i.name}/`);continue}if(st(i.name))t.push(`${o}${i.name.slice(0,-3)}`)}};return r(e,""),t.sort()}async function Ee(e){if(!e||!V(e))return{};try{let r=(await import(e)).default;if(!r||typeof r!=="object")return{error:Error(`${e} must default-export a command registry object.`)};return{registry:r}}catch(t){return{error:t}}}async function lt(e){let{commandsDir:t}=e,r=e.registry??(await Ee(e.registryPath)).registry,n=at(t),o=new Map;for(let l of n)o.set(l,{file:l,path:Te(t,`${l}.ts`),aliases:[],enabled:!0,source:"auto"});let i=[];for(let[l,a]of Object.entries(r??{})){let s=typeof a==="string"?{file:a}:a,g=o.get(s.file);if(!g)continue;if(g.signature=l,g.aliases=s.aliases??[],g.enabled=s.enabled!==!1,g.source="registry",!i.includes(g))i.push(g)}for(let l of n){let a=o.get(l);if(a&&!i.includes(a))i.push(a)}return i}function ct(e,t,r){let n=t.trim().split(/\s+/)[0],i=e?.commands?.find((l)=>l.name===n);if(!i||typeof i.alias!=="function")return!1;for(let l of r)i.alias(l);return!0}async function nn(e,t){let r=t.onError??(()=>{}),n=t.onDebug??(()=>{});if(!V(t.commandsDir))return n(`No ${t.commandsDir} directory, skipping application commands.`),[];let o=t.registry?{registry:t.registry}:await Ee(t.registryPath);if(o.error)r(`Could not read the command registry at ${t.registryPath}`,o.error);let i=await lt({...t,registry:o.registry}),l=[];for(let a of i){if(!a.enabled){n(`Skipping disabled command ${a.file}.`);continue}try{let s=await import(a.path);if(s.enabled===!1){n(`Skipping ${a.file}: the module exports \`enabled = false\`.`);continue}if(typeof s.default!=="function"){r(`Expected a default export function in ${a.file}.ts, but got: ${typeof s.default}`);continue}let g=e.commands?.length??0;s.default(e);let m=[...a.aliases,...s.aliases??[]];if(m.length)gt(e,a.signature,g,m,n);l.push(a)}catch(s){r(`Failed to load command ${a.file}`,s)}}return l}function gt(e,t,r,n,o){if(t&&ct(e,t,n))return;let a=(e.commands?.slice(r)??[])[0];if(!a||typeof a.alias!=="function"){o(`Could not alias '${t??"command"}': no matching command was registered.`);return}for(let s of n)a.alias(s)}function rn(e){if(typeof e==="function")return e;return(t)=>ut(t,e)}function ut(e,t){let r=e.command(t.name,t.description??"",{allowUnknownOptions:t.allowUnknownOptions});if(t.usage)r.usage(t.usage);for(let[n,o]of Object.entries(t.options??{})){let i=typeof o==="string"?{description:o}:o;r.option(n,i.description??"",{...i.default===void 0?{}:{default:i.default},...i.type?{type:i.type}:{}})}for(let n of t.aliases??[])r.alias(n);for(let n of t.examples??[])r.example(n);return r.action((...n)=>{let o=n[n.length-1];return t.handle(o,...n.slice(0,-1))}),r}function on(e){return e}import W from"process";import{err as j,handleError as J,ok as dt}from"@stacksjs/error-handling";import{ExitCode as G}from"@stacksjs/types";async function Q(e,t){let r=Array.isArray(e)?e:e.match(/(?:[^\s"]|"[^"]*")+/g);if(!r)return j(J(`Failed to parse command: ${r}`,t));let n=t?.cwd??W.cwd(),o=t?.timeoutMs,[i,l,a]=Array.isArray(t?.stdio)?t.stdio:[],s=t?.silent||t?.quiet,g=Bun.spawn(r,{stdin:t?.stdin??i??"inherit",stdout:s?"ignore":t?.stdout??l??"inherit",stderr:s?"ignore":t?.stderr??a??"inherit",cwd:n,env:{...W.env,...t?.env},onExit(x,T,w,S){Pe("spawn",x,T,w,S)}});if(t?.stdin==="pipe"&&t.input){if(g.stdin)g.stdin.write(t.input),g.stdin.end()}let m,b=await Promise.race([g.exited,new Promise((x)=>{if(!o)return;m=setTimeout(()=>{try{g.kill()}catch{}x(G.FatalError)},o)})]);if(m)clearTimeout(m);if(o&&b===G.FatalError&&g.exitCode===null)return j(J(`Command timed out after ${o}ms: ${h(r.join(" "))} in ${h(n)}`,t));if(b===G.Success)return dt(g);let y=g.signalCode;if(y==="SIGTERM"||y==="SIGINT"||y==="SIGKILL"||g.exitCode===null&&b!==G.Success)return j(Error(`Command terminated by ${y??"signal"}: ${r.join(" ")}`));return j(J(`Failed to execute command: ${h(r.join(" "))} in ${h(n)}`,t))}async function Ae(e,t){let r=Array.isArray(e)?e:e.match(/(?:[^\s"]|"[^"]*")+/g);if(!r)throw p.error(`Failed to parse command: ${r}`,t),Error(`Failed to parse command: ${r}`);let n=Bun.spawnSync(r,{...t,stdin:t?.stdin??"inherit",stdout:t?.stdout??"pipe",stderr:t?.stderr??"inherit",cwd:t?.cwd??W.cwd(),env:{...W.env,...t?.env},onExit(i,l,a,s){Pe("spawnSync",i,l,a,s)}}),o=n.stdout?.toString()??"";if(t?.throwOnError&&n.exitCode!==0){let l=((n.stderr?.toString()??"").trim()||o.trim()||"(no output)").split(`
2
+ import We from"process";async function Ye(e,t={silent:!0}){let n=t.packageManager??"bun",r=[n==="npm"?"install":"add"];if(t.dev)r.push("-D");if(t.preferOffline&&n!=="bun")r.push("--prefer-offline");if(t.additionalArgs)r.push(...t.additionalArgs);r.push(e);let i=await Bun.spawn([n,...r],{cwd:t.cwd??We.cwd(),stdout:t.silent?"ignore":"inherit",stderr:t.silent?"ignore":"inherit",stdin:"ignore",env:We.env}).exited;if(i!==0)throw Error(`Failed to install ${e} (exit code ${i})`)}async function er(e,t){return Ye(e,t??{silent:!0})}async function tr(e,t){return Ye(`@stacksjs/${e}`,t??{silent:!0})}import{CLI as or,cli as gt,onUnknownSubcommand as ir}from"@stacksjs/clapp";function sr(e,t){if(typeof e==="object")t=e,e=t.name;return gt(e||"buddy")}import{existsSync as re,readdirSync as dt}from"fs";import{join as Ne}from"path";var mt=/(?:\.test|\.spec|\.bench|\.d)\.ts$/;function ft(e){return e.endsWith(".ts")&&!mt.test(e)&&!e.startsWith("_")}function pt(e){if(!re(e))return[];let t=[],n=(r,o)=>{for(let i of dt(r,{withFileTypes:!0})){if(i.name.startsWith(".")||i.name==="node_modules")continue;if(i.isDirectory()){n(Ne(r,i.name),`${o}${i.name}/`);continue}if(ft(i.name))t.push(`${o}${i.name.slice(0,-3)}`)}};return n(e,""),t.sort()}async function De(e){if(!e||!re(e))return{};try{let n=(await import(e)).default;if(!n||typeof n!=="object")return{error:Error(`${e} must default-export a command registry object.`)};return{registry:n}}catch(t){return{error:t}}}async function ht(e){let{commandsDir:t}=e,n=e.registry??(await De(e.registryPath)).registry,r=pt(t),o=new Map;for(let l of r)o.set(l,{file:l,path:Ne(t,`${l}.ts`),aliases:[],enabled:!0,source:"auto"});let i=[];for(let[l,s]of Object.entries(n??{})){let a=typeof s==="string"?{file:s}:s,c=o.get(a.file);if(!c)continue;if(c.signature=l,c.aliases=a.aliases??[],c.enabled=a.enabled!==!1,c.source="registry",!i.includes(c))i.push(c)}for(let l of r){let s=o.get(l);if(s&&!i.includes(s))i.push(s)}return i}function bt(e,t,n){let r=t.trim().split(/\s+/)[0],i=e?.commands?.find((l)=>l.name===r);if(!i||typeof i.alias!=="function")return!1;for(let l of n)i.alias(l);return!0}async function ur(e,t){let n=t.onError??(()=>{}),r=t.onDebug??(()=>{});if(!re(t.commandsDir))return r(`No ${t.commandsDir} directory, skipping application commands.`),[];let o=t.registry?{registry:t.registry}:await De(t.registryPath);if(o.error)n(`Could not read the command registry at ${t.registryPath}`,o.error);let i=await ht({...t,registry:o.registry}),l=[];for(let s of i){if(!s.enabled){r(`Skipping disabled command ${s.file}.`);continue}try{let a=await import(s.path);if(a.enabled===!1){r(`Skipping ${s.file}: the module exports \`enabled = false\`.`);continue}if(typeof a.default!=="function"){n(`Expected a default export function in ${s.file}.ts, but got: ${typeof a.default}`);continue}let c=e.commands?.length??0;a.default(e);let m=[...s.aliases,...a.aliases??[]];if(m.length)yt(e,s.signature,c,m,r);l.push(s)}catch(a){n(`Failed to load command ${s.file}`,a)}}return l}function yt(e,t,n,r,o){if(t&&bt(e,t,r))return;let s=(e.commands?.slice(n)??[])[0];if(!s||typeof s.alias!=="function"){o(`Could not alias '${t??"command"}': no matching command was registered.`);return}for(let a of r)s.alias(a)}function gr(e){if(typeof e==="function")return e;return(t)=>Ct(t,e)}function Ct(e,t){let n=e.command(t.name,t.description??"",{allowUnknownOptions:t.allowUnknownOptions});if(t.usage)n.usage(t.usage);for(let[r,o]of Object.entries(t.options??{})){let i=typeof o==="string"?{description:o}:o;n.option(r,i.description??"",{...i.default===void 0?{}:{default:i.default},...i.type?{type:i.type}:{}})}for(let r of t.aliases??[])n.alias(r);for(let r of t.examples??[])n.example(r);return n.action((...r)=>{let o=r[r.length-1];return t.handle(o,...r.slice(0,-1))}),n}function dr(e){return e}import q from"process";import{err as z,handleError as ne,ok as xt}from"@stacksjs/error-handling";import{ExitCode as _}from"@stacksjs/types";async function oe(e,t){let n=Array.isArray(e)?e:e.match(/(?:[^\s"]|"[^"]*")+/g);if(!n)return z(ne(`Failed to parse command: ${n}`,t));let r=t?.cwd??q.cwd(),o=t?.timeoutMs,[i,l,s]=Array.isArray(t?.stdio)?t.stdio:[],a=t?.silent||t?.quiet,c=Bun.spawn(n,{stdin:t?.stdin??i??"inherit",stdout:a?"ignore":t?.stdout??l??"inherit",stderr:a?"ignore":t?.stderr??s??"inherit",cwd:r,env:{...q.env,...t?.env},onExit(h,v,w,k){_e("spawn",h,v,w,k)}});if(t?.stdin==="pipe"&&t.input){if(c.stdin)c.stdin.write(t.input),c.stdin.end()}let m,y=await Promise.race([c.exited,new Promise((h)=>{if(!o)return;m=setTimeout(()=>{try{c.kill()}catch{}h(_.FatalError)},o)})]);if(m)clearTimeout(m);if(o&&y===_.FatalError&&c.exitCode===null)return z(ne(`Command timed out after ${o}ms: ${x(n.join(" "))} in ${x(r)}`,t));if(y===_.Success)return xt(c);let C=c.signalCode;if(C==="SIGTERM"||C==="SIGINT"||C==="SIGKILL"||c.exitCode===null&&y!==_.Success)return z(Error(`Command terminated by ${C??"signal"}: ${n.join(" ")}`));return z(ne(`Failed to execute command: ${x(n.join(" "))} in ${x(r)}`,t))}async function ze(e,t){let n=Array.isArray(e)?e:e.match(/(?:[^\s"]|"[^"]*")+/g);if(!n)throw p.error(`Failed to parse command: ${n}`,t),Error(`Failed to parse command: ${n}`);let r=Bun.spawnSync(n,{...t,stdin:t?.stdin??"inherit",stdout:t?.stdout??"pipe",stderr:t?.stderr??"inherit",cwd:t?.cwd??q.cwd(),env:{...q.env,...t?.env},onExit(i,l,s,a){_e("spawnSync",i,l,s,a)}}),o=r.stdout?.toString()??"";if(t?.throwOnError&&r.exitCode!==0){let l=((r.stderr?.toString()??"").trim()||o.trim()||"(no output)").split(`
3
3
  `).slice(0,5).join(`
4
- `);throw Error(`Command failed with exit code ${n.exitCode}: ${r.join(" ")}
5
- ${l}`)}return o}function Pe(e,t,r,n,o){if(p.debug(`exitHandler: ${e}, exitCode: ${r}, signalCode: ${n}`),o)p.debug("Process error:",o.message)}import{handleError as kt}from"@stacksjs/error-handling";import{log as p}from"@stacksjs/logging";import{ExitCode as Le}from"@stacksjs/types";import{collect as mt}from"@stacksjs/collections";var u=!process.env.NO_COLOR&&(process.env.FORCE_COLOR?process.env.FORCE_COLOR!=="0":!!process.stdout?.isTTY),d={reset:u?"\x1B[0m":"",black:u?"\x1B[30m":"",red:u?"\x1B[31m":"",green:u?"\x1B[32m":"",yellow:u?"\x1B[33m":"",blue:u?"\x1B[34m":"",magenta:u?"\x1B[35m":"",cyan:u?"\x1B[36m":"",white:u?"\x1B[37m":"",gray:u?"\x1B[90m":"",lightRed:u?"\x1B[91m":"",lightGreen:u?"\x1B[92m":"",lightYellow:u?"\x1B[93m":"",lightBlue:u?"\x1B[94m":"",lightMagenta:u?"\x1B[95m":"",lightCyan:u?"\x1B[96m":"",lightGray:u?"\x1B[37m":"",bgBlack:u?"\x1B[40m":"",bgRed:u?"\x1B[41m":"",bgGreen:u?"\x1B[42m":"",bgYellow:u?"\x1B[43m":"",bgBlue:u?"\x1B[44m":"",bgMagenta:u?"\x1B[45m":"",bgCyan:u?"\x1B[46m":"",bgWhite:u?"\x1B[47m":"",bgGray:u?"\x1B[100m":"",bgLightRed:u?"\x1B[101m":"",bgLightGreen:u?"\x1B[102m":"",bgLightYellow:u?"\x1B[103m":"",bgLightBlue:u?"\x1B[104m":"",bgLightMagenta:u?"\x1B[105m":"",bgLightCyan:u?"\x1B[106m":"",bgLightGray:u?"\x1B[47m":"",bold:u?"\x1B[1m":"",dim:u?"\x1B[2m":"",italic:u?"\x1B[3m":"",underline:u?"\x1B[4m":"",inverse:u?"\x1B[7m":"",hidden:u?"\x1B[8m":"",strikethrough:u?"\x1B[9m":""},D="\x1B[",pt="\x1B]8;;",ft="\x1B]8;;\x07",je=(e)=>String(e);function k(e,t,r){return Math.min(Math.max(Math.floor(e),t),r)}function c(e,t=d.reset){return(r)=>{if(!u)return String(r);return`${e}${String(r)}${t}`}}function ht(e){return e.replace(/\x1B\]8;;[^\x07]*(?:\x07|\x1B\\)/g,"").replace(/\x1B\]8;;(?:\x07|\x1B\\)/g,"")}function O(e){return ht(e).replace(/\x1B\[[0-?]*[ -/]*[@-~]/g,"")}var Ge=O;function We(e){return Array.from(O(e)).length}var X=c(d.black),Z=c(d.red),L=c(d.green),ee=c(d.yellow),te=c(d.blue),ne=c(d.magenta),R=c(d.cyan),re=c(d.white),F=c(d.gray),oe=c(d.lightRed),ie=c(d.lightGreen),se=c(d.lightYellow),ae=c(d.lightBlue),le=c(d.lightMagenta),ce=c(d.lightCyan),Y=c(d.lightGray),ge=c(d.bgBlack),ue=c(d.bgRed),de=c(d.bgGreen),me=c(d.bgYellow),pe=c(d.bgBlue),fe=c(d.bgMagenta),E=c(d.bgCyan),he=c(d.bgWhite),be=c(d.bgGray),ye=c(d.bgLightRed),Ce=c(d.bgLightGreen),xe=c(d.bgLightYellow),we=c(d.bgLightBlue),ke=c(d.bgLightMagenta),$e=c(d.bgLightCyan),N=c(d.bgLightGray),C=c(d.bold),v=c(d.dim),h=c(d.italic),Fe=c(d.underline),ve=c(d.inverse),Oe=c(d.hidden),Be=c(d.strikethrough),Se=c(d.reset,"");function Ye(e){return c(`${D}38;5;${k(e,0,255)}m`)}function Ne(e){return c(`${D}48;5;${k(e,0,255)}m`)}function De(e,t,r){return c(`${D}38;2;${k(e,0,255)};${k(t,0,255)};${k(r,0,255)}m`)}function ze(e,t,r){return c(`${D}48;2;${k(e,0,255)};${k(t,0,255)};${k(r,0,255)}m`)}function _e(e,t){let r=(o,i)=>{let l=String(o);if(!u)return l;return`${pt}${i}\x07${l}${ft}`};if(typeof t==="string")return r(e,t);let n=String(e);return(o)=>r(o,n)}var bt={black:X,red:Z,green:L,yellow:ee,blue:te,magenta:ne,cyan:R,white:re,gray:F,lightRed:oe,lightGreen:ie,lightYellow:se,lightBlue:ae,lightMagenta:le,lightCyan:ce,lightGray:Y,bgBlack:ge,bgRed:ue,bgGreen:de,bgYellow:me,bgBlue:pe,bgMagenta:fe,bgCyan:E,bgWhite:he,bgGray:be,bgLightRed:ye,bgLightGreen:Ce,bgLightYellow:xe,bgLightBlue:we,bgLightMagenta:ke,bgLightCyan:$e,bgLightGray:N,bold:C,dim:v,italic:h,underline:Fe,inverse:ve,hidden:Oe,strikethrough:Be,reset:Se};function qe(e){return bt[e]??je}function mn(e,t){if(typeof t==="function")return t(e);return qe(t)(e)}function yt(){return u}var pn={black:X,red:Z,green:L,yellow:ee,blue:te,magenta:ne,cyan:R,white:re,gray:F,lightRed:oe,lightGreen:ie,lightYellow:se,lightBlue:ae,lightMagenta:le,lightCyan:ce,lightGray:Y,bgBlack:ge,bgRed:ue,bgGreen:de,bgYellow:me,bgBlue:pe,bgMagenta:fe,bgCyan:E,bgWhite:he,bgGray:be,bgLightRed:ye,bgLightGreen:Ce,bgLightYellow:xe,bgLightBlue:we,bgLightMagenta:ke,bgLightCyan:$e,bgLightGray:N,bold:C,dim:v,italic:h,underline:Fe,inverse:ve,hidden:Oe,strikethrough:Be,reset:Se,ansi256:Ye,ansi256Bg:Ne,trueColor:De,trueColorBg:ze,link:_e,stripColors:Ge},fn={black:X,red:Z,green:L,yellow:ee,blue:te,magenta:ne,cyan:R,white:re,gray:F,lightRed:oe,lightGreen:ie,lightYellow:se,lightBlue:ae,lightMagenta:le,lightCyan:ce,lightGray:Y,bgBlack:ge,bgRed:ue,bgGreen:de,bgYellow:me,bgBlue:pe,bgMagenta:fe,bgCyan:E,bgWhite:he,bgGray:be,bgLightRed:ye,bgLightGreen:Ce,bgLightYellow:xe,bgLightBlue:we,bgLightMagenta:ke,bgLightCyan:$e,bgLightGray:N,bold:C,dim:v,italic:h,underline:Fe,inverse:ve,hidden:Oe,strikethrough:Be,reset:Se,ansi256:Ye,ansi256Bg:Ne,trueColor:De,trueColorBg:ze,link:_e,stripColors:Ge,grey:F,lightGrey:Y,bgLightGrey:N,supportsColor:yt};function Ct(e,t,r,n){let o=We(e);if(o>=t)return e;let i=n[0]||" ",l=t-o;if(r==="right")return`${i.repeat(l)}${e}`;if(r==="center"){let a=Math.floor(l/2),s=l-a;return`${i.repeat(a)}${e}${i.repeat(s)}`}return`${e}${i.repeat(l)}`}function z(e){return Math.max(0,...e.map(We))}function _(e,t,r="left"){let n=String(e).split(/\r?\n/),o=typeof t==="object"?t:void 0,i=typeof t==="number"?t:o?.width??z(n),l=o?.align??r,a=o?.padChar??" ";return n.map((s)=>Ct(s,Math.max(0,i),l,a)).join(`
6
- `)}function hn(e,t){return _(e,t,"left")}function bn(e,t){let r=String(e).split(/\r?\n/);return _(e,t??process.stdout?.columns??z(r),"right")}function yn(e,t){let r=String(e).split(/\r?\n/);return _(e,t??process.stdout?.columns??z(r),"center")}var xt={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551"},round:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502"}};function Ke(e,t={}){let r=String(e).split(/\r?\n/),n=xt[t.borderStyle??"single"],o=Math.max(0,t.padding??1),i=Math.max(0,t.margin??0),l=t.align??"left",a=z(r),s=a+o*2,g=typeof t.borderColor==="function"?t.borderColor:t.borderColor?qe(t.borderColor):je,b=g((()=>{if(!t.title)return`${n.topLeft}${n.horizontal.repeat(s)}${n.topRight}`;let S=` ${O(String(t.title))} `.slice(0,s),U=n.horizontal.repeat(Math.max(0,s-S.length));return`${n.topLeft}${S}${U}${n.topRight}`})()),y=g(`${n.bottomLeft}${n.horizontal.repeat(s)}${n.bottomRight}`),x=r.map((w)=>{let S=_(w,{align:l,width:a}),U=`${" ".repeat(o)}${S}${" ".repeat(o)}`;return`${g(n.vertical)}${U}${g(n.vertical)}`}),T=" ".repeat(i);return[b,...x,y].map((w)=>`${T}${w}`).join(`
7
- `)}var Cn=mt(["The best way to get started is to quit talking and begin doing.","The pessimist sees difficulty in every opportunity. The optimist sees opportunity in every difficulty.","Don\u2019t let yesterday take up too much of today.","You learn more from failure than from success. Don\u2019t let it stop you. Failure builds character.","It\u2019s not whether you get knocked down, it\u2019s whether you get up.","If you are working on something that you really care about, you don\u2019t have to be pushed. The vision pulls you.","People who are crazy enough to think they can change the world, are the ones who do.","Failure will never overtake me if my determination to succeed is strong enough.","Entrepreneurs are great at dealing with uncertainty and also very good at minimizing risk. That\u2019s the classic entrepreneur.","We may encounter many defeats but we must not be defeated.","Knowing is not enough; we must apply. Wishing is not enough; we must do.","Imagine your life is perfect in every respect; what would it look like?","We generate fears while we sit. We overcome them by action.","Whether you think you can or think you can\u2019t, you\u2019re right.","Security is mostly a superstition. Life is either a daring adventure or nothing."]);var He="0.75.258";async function Bn(e,t){return new Promise((r)=>{if(t?.quiet===!1)console.log(),console.log(R(C("Stacks CLI"))+v(` v${He}`)),console.log();if(p.info(`Running ${E(h(C(` ${e} `)))}`),t?.showPerformance===!1||t?.quiet)return r(0);return r(performance.now())})}function Sn(e,t,r){let n={type:"success",useSeconds:!0,...t};return n.message=t?.message||e,new Promise((o)=>{if(r)return kt(r),o(Le.FatalError);if(n?.startTime){let i=performance.now()-n.startTime;if(n.useSeconds)i=i/1000,i=Math.round(i*100)/100;if(n.quiet===!0)return o(Le.Success);if(r)p.error(`[${i.toFixed(2)}${n.useSeconds?"s":"ms"}] Failed`);else if(n.type==="error")p.error(`[${i.toFixed(2)}${n.useSeconds?"s":"ms"}] ${n.message??"Failed"}`);else if(n.type==="warning")p.warn(`[${i.toFixed(2)}${n.useSeconds?"s":"ms"}] ${n.message??"Complete"}`);else if(n.type==="info")p.info(`${v(F(`[${i.toFixed(2)}${n.useSeconds?"s":"ms"}]`))} ${n.message??"Complete"}`);else p.success(`${v(F(C(`[${i.toFixed(2)}${n.useSeconds?"s":"ms"}]`)))} ${C(L(n.message??"Complete"))}`)}else if(n?.type==="info")p.info(e);else if(n?.type==="error")p.error(e);else if(n?.type==="warning")p.warn(e);else if(n?.type==="success"&&n?.quiet!==!0)p.success(e);p.flush().catch(()=>{}).then(()=>o(Le.Success))})}import q from"process";function Ue(e){if(!e)return!1;return e.startsWith("--")}function $t(e){return e.startsWith("-")&&!Ue(e)}function Re(e){if(e==="true")return!0;if(e==="false")return!1;let t=Number.parseFloat(e);if(!Number.isNaN(t))return t;return e.replace(/"/g,"")}function Ft(e,t,r,n){let[o,i]=e.slice(2).split("=");if(i!==void 0)n[o]=Re(i);else if(r+1<t.length&&!t[r+1]?.startsWith("-"))n[o]=t[r+1],r++;else n[o]=!0;return r}function vt(e,t,r,n){let[o,i]=e.slice(1).split("=");if(o===void 0)return r;if(i!==void 0&&o!==void 0)for(let l=0;l<o.length;l++)n[o[l]]=Re(i);else for(let l=0;l<o.length;l++)if(r+1<t.length&&l===o.length-1&&!t[r+1]?.startsWith("-"))n[o[l]]=Re(t[r+1]),r++;else n[o[l]]=!0;return r}function Ot(e){if(e===void 0)e=q.argv.slice(2);let t=[],r={};for(let n=0;n<e.length;n++){let o=e[n];if(!o)continue;if(Ue(o))n=Ft(o,e,n,r);else if($t(o))n=vt(o,e,n,r);else t.push(o)}return{args:t,options:r}}function In(e){if(e===void 0)e=q.argv.slice(2);return Ot(e).args}function Tn(e){e=e||{};let t={dryRun:!1,quiet:!1,verbose:!1},r=q.argv.slice(2);for(let n=0;n<r.length;n++){let o=r[n];if(o?.startsWith("--")){let l=o.substring(2).replace(/-([a-z])/gi,(a)=>a[1]?a[1].toUpperCase():"");if(n+1<r.length&&!r?.[n+1]?.startsWith("--"))if(r?.[n+1]==="true"||r?.[n+1]==="false")e[l]=r[n+1]==="true",n++;else e[l]=r[n+1],n++;else e[l]=!0}}if(Object.keys(e).length===0)return{};return{...t,...e}}function Bt(e){let t=[];for(let[r,n]of Object.entries(e)){if(r==="--"||r==="_"||n===!1||n===void 0||n===null)continue;if(typeof n==="object"&&!Array.isArray(n))continue;if(typeof n==="function"||typeof n==="symbol")continue;if(n===!0)t.push(`--${r}`);else t.push(`--${r}`,String(n))}return t}function St(e){if(Array.isArray(e)){if(e=Array.from(new Set(e)),Array.isArray(e)&&e[0]&&!e[0].startsWith("-"))e.shift();return e.join(" ")}if(typeof e==="object"&&e!==null)return Bt(e).join(" ");return St(q.argv.slice(2))}import{writeSync as Lt}from"fs";import{format as K}from"util";function jn(...e){Je(1,K(...e))}function Gn(...e){Je(2,K(...e))}async function Wn(...e){await Ve(process.stdout,K(...e))}async function Yn(...e){await Ve(process.stderr,K(...e))}function Ve(e,t){return new Promise((r,n)=>{let o=(i)=>{e.off("error",o),n(i)};e.once("error",o);try{e.write(`${t}
8
- `,"utf8",(i)=>{if(i)setImmediate(()=>e.off("error",o)),n(i);else e.off("error",o),r()})}catch(i){e.off("error",o),n(i)}})}function Je(e,t){let r=Buffer.from(`${t}
9
- `),n=0;while(n<r.length)n+=Lt(e,r,n,r.length-n)}import f from"process";import{createInterface as Rt}from"readline";var _n=f.stdin.destroy;f.stdin.destroy=function(e){if(e)this.emit("error",e);return this};f.on("SIGINT",()=>{console.log(`
10
- `),f.exit(130)});var M=null;function Mt(){if(!M){let e=f.stdin.isTTY&&f.stdout.isTTY;if(M=Rt({input:f.stdin,output:f.stdout,terminal:e}),e&&typeof f.stdin.setRawMode==="function")M.on("SIGINT",()=>{f.emit("SIGINT")});M.once("close",()=>{M=null})}return M}var H=Symbol("stdin-eof");function Qe(e){return new Promise((t)=>{let r=Mt(),n=!1,o=(l)=>{if(n)return;n=!0,r.off("close",i),t(l)},i=()=>o(H);r.once("close",i);try{r.question(e,o)}catch{o(H)}})}function Xe(){if(f.argv.includes("--no-interaction"))return!1;if(f.env.CI)return!1;return Boolean(f.stdin.isTTY&&f.stdout.isTTY)}async function A(e){if(!Xe())return"";let t=await Qe(e);return t===H?"":t}function Ze(e,t){let r=e.toLowerCase().trim();if(!r)return t;if(r==="y"||r==="yes")return!0;if(r==="n"||r==="no")return!1;return t}async function qn(e){let t=typeof e==="string"?{message:e}:e,r=t.initial??!1,n=r?" (Y/n) ":" (y/N) ";if(!Xe())return null;let o=await Qe(`${t.message}${n}`);if(o===H)return null;return Ze(o,r)}async function It(e){let t=typeof e==="string"?{message:e}:e,r=t.initial??!1,n=r?" (Y/n) ":" (y/N) ",o=await A(`${t.message}${n}`);return Ze(o,r)}async function Tt(e){let t=typeof e==="string"?{message:e}:e,r=t.placeholder||t.initial||"",n=r?` (${r}) `:" ";return(await A(`${t.message}${n}`)).trim()||t.initial||""}async function Et(e){console.log(e.message),e.choices.forEach((o,i)=>{let l=i===(e.initial??0)?">":" ";console.log(`${l} ${i+1}. ${o.label}`)});let t=await A("Select (number): "),r=Number.parseInt(t.trim(),10)-1,n=e.choices[r]??e.choices[e.initial??0];if(!n)throw Error("select prompt: no choices available");return n.value}async function At(e){console.log(e.message),console.log("(Enter numbers separated by commas)"),e.choices.forEach((o,i)=>{console.log(` ${i+1}. ${o.label}`)});let r=(await A("Select (e.g., 1,3,4): ")).split(",").map((o)=>Number.parseInt(o.trim(),10)-1),n=[];for(let o of r){let i=e.choices[o];if(i)n.push(i.value)}return n}async function Pt(e){return(await A(`${(typeof e==="string"?{message:e}:e).message} `)).trim()}var Kn={text:Tt,confirm:It,select:Et,multiselect:At,password:Pt};import{handleError as jt}from"@stacksjs/error-handling";async function Gt(e,t){let r={...t,stdin:t?.stdin??"inherit",verbose:t?.verbose??!1};return await Q(e,r)}async function Jn(e,t){let r={...t,stdio:[t?.stdin??"inherit","pipe","pipe"],verbose:t?.verbose??!1};return await Q(e,r)}async function Qn(e,t){let r={...t,stdio:[t?.stdin??"inherit","pipe","pipe"],verbose:t?.verbose??!1};return await Ae(e,r)}async function Xn(e,t){let r=[];for(let n of e){let o=await Gt(n,t);if(o.isErr)throw jt("Error during runCommands",o.error),o.error;r.push(o)}return r}import Wt from"process";var Yt=["SIGINT","SIGTERM","SIGHUP"],I=new Map,et=!1;function Nt(){if(et)return;et=!0;for(let e of Yt)Wt.on(e,async()=>{for(let[t,r]of I)try{await r()}catch(n){console.error(`[signals] cleanup '${t}' threw:`,n)}})}function tr(e,t){return Nt(),I.set(e,t),()=>{if(I.get(e)===t)I.delete(e)}}function nr(e){I.delete(e)}function rr(){return[...I.keys()]}var tt=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],P=process.stdout.isTTY&&!process.env.CI;function Dt(e){let t=e||"",r=0,n=null,o=!1,i=()=>{if(P)process.stdout.write("\r\x1B[K")},l=()=>{if(!P)return;i();let a=tt[r];process.stdout.write(`${a} ${t}`),r=(r+1)%tt.length};return{start(a){if(a)t=a;if(o)return;if(o=!0,P)l(),n=setInterval(l,80);else if(t)console.log(` ${t}`)},stop(a){if(o=!1,n)clearInterval(n),n=null;if(i(),a)console.log(a)},update(a){if(t=a,!P&&o)console.log(` ${a}`)},succeed(a){let s=a||t;if(o=!1,n)clearInterval(n),n=null;i(),console.log(`\u2713 ${s}`)},fail(a){let s=a||t;if(o=!1,n)clearInterval(n),n=null;i(),console.error(`\u2717 ${s}`)},get text(){return t},set text(a){if(t=a,P&&o)l()},get isSpinning(){return o}}}async function ir(e,t,r){let n=Dt(e);n.start();try{let o=await t();return n.succeed(r?.successMessage||e),o}catch(o){throw n.fail(r?.failMessage||`Failed: ${e}`),o}}import B from"process";var nt="\r\x1B[2K";function zt(){return{columns:B.stdout.columns??80,rows:B.stdout.rows??24}}function _t(){return Boolean(B.stdout.isTTY)&&!B.env.CI}function cr(e,t){console.log(Ke(e,t===void 0?{}:{title:t}))}function gr(e,t={}){let n=(t.columns??[...new Set(e.flatMap((s)=>Object.keys(s)))]).map((s)=>typeof s==="string"?{key:s}:s);if(n.length===0)return"";let o=(s,g)=>{let m=s[g.key];return m===void 0||m===null?"":String(m)},i=n.map((s)=>{let g=t.header===!1?"":s.header??s.key;return Math.max(O(g).length,...e.map((m)=>O(o(m,s)).length))}),l=(s,g,m)=>{let b=Math.max(0,g-O(s).length);return m==="right"?" ".repeat(b)+s:s+" ".repeat(b)},a=[];if(t.header!==!1)a.push(n.map((s,g)=>l(s.header??s.key,i[g],s.align)).join(" ").trimEnd()),a.push(n.map((s,g)=>"-".repeat(i[g])).join(" "));for(let s of e)a.push(n.map((g,m)=>l(o(s,g),i[m],g.align)).join(" ").trimEnd());return a.join(`
11
- `)}function ur(e){if(!Number.isFinite(e.total)||e.total<=0)throw TypeError(`progress() needs a positive total; got ${e.total}`);let t=e.format??"|{bar}| {percentage}% | {value}/{total}",r=e.width??Math.max(10,Math.floor(zt().columns/3)),n=_t(),o=0,i=-1,l=(s)=>{let g=Math.min(1,o/e.total),m=Math.round(g*r),b={bar:"\u2588".repeat(m)+"\u2591".repeat(r-m),percentage:Math.round(g*100),value:o,total:e.total,...s},y=t.replace(/\{(\w+)\}/g,(T,w)=>String(b[w]??T));if(n){B.stdout.write(`${nt}${y}`);return}let x=Math.floor(g*10);if(x>i)i=x,console.log(y)},a={update(s,g={}){o=Math.max(0,Math.min(e.total,s)),l(g)},increment(s=1){a.update(o+s)},stop(s){if(n)B.stdout.write(nt);if(s)console.log(s);else if(n)B.stdout.write(`
12
- `)},get value(){return o},get total(){return e.total}};return a}async function dr(e){let t=[];for(let r of e){let n=Date.now(),o=r.skip?.();if(o){console.log(`- ${r.title}${typeof o==="string"?` (${o})`:""}`),t.push({title:r.title,status:"skipped",durationMs:0});continue}try{await r.task(),console.log(`\u2713 ${r.title}`),t.push({title:r.title,status:"done",durationMs:Date.now()-n})}catch(i){throw console.log(`\u2717 ${r.title}`),t.push({title:r.title,status:"failed",error:i instanceof Error?i:Error(String(i)),durationMs:Date.now()-n}),i}}return t}export{Jt as CLI,_ as align,Ye as ansi256,Ne as ansi256Bg,ct as applyAliases,ge as bgBlack,pe as bgBlue,E as bgCyan,be as bgGray,de as bgGreen,we as bgLightBlue,$e as bgLightCyan,N as bgLightGray,Ce as bgLightGreen,ke as bgLightMagenta,ye as bgLightRed,xe as bgLightYellow,fe as bgMagenta,ue as bgRed,he as bgWhite,me as bgYellow,X as black,te as blue,C as bold,Ke as box,Bt as buddyOptionArgs,St as buddyOptions,yn as centerAlign,Xt as cli,mn as colorize,pn as colors,It as confirm,qn as confirmOrNull,R as cyan,rn as defineCommand,on as defineCommands,v as dim,at as discoverCommandFiles,Q as exec,Ae as execSync,qe as getColor,zt as getTerminalSize,F as gray,L as green,Oe as hidden,Kt as installPackage,Ht as installStack,Bn as intro,ve as inverse,_t as isInteractive,h as italic,fn as kolorist,hn as leftAlign,ae as lightBlue,ce as lightCyan,Y as lightGray,ie as lightGreen,le as lightMagenta,oe as lightRed,se as lightYellow,_e as link,rr as listSignalHandlers,Ee as loadCommandRegistry,nn as loadCommands,p as log,ne as magenta,At as multiselect,cr as note,nr as offSignal,tr as onSignal,Qt as onUnknownSubcommand,Sn as outro,In as parseArgs,Ot as parseArgv,Tn as parseOptions,Pt as password,jn as print,Wn as printAsync,Gn as printError,Yn as printErrorAsync,ur as progress,Kn as prompts,Xe as promptsAreInteractive,Cn as quotes,Z as red,Se as reset,lt as resolveCommands,bn as rightAlign,Gt as runCommand,Qn as runCommandSync,Xn as runCommands,Jn as runProcess,Et as select,Dt as spinner,Be as strikethrough,O as stripAnsi,Ge as stripColors,gr as table,dr as tasks,Tt as text,De as trueColor,ze as trueColorBg,Fe as underline,re as white,ir as withSpinner,ee as yellow};
4
+ `);throw Error(`Command failed with exit code ${r.exitCode}: ${n.join(" ")}
5
+ ${l}`)}return o}function _e(e,t,n,r,o){if(p.debug(`exitHandler: ${e}, exitCode: ${n}, signalCode: ${r}`),o)p.debug("Process error:",o.message)}import{handleError as Rt}from"@stacksjs/error-handling";import{log as p}from"@stacksjs/logging";import{ExitCode as Ae}from"@stacksjs/types";import{collect as wt}from"@stacksjs/collections";var g=!process.env.NO_COLOR&&(process.env.FORCE_COLOR?process.env.FORCE_COLOR!=="0":!!process.stdout?.isTTY),d={reset:g?"\x1B[0m":"",black:g?"\x1B[30m":"",red:g?"\x1B[31m":"",green:g?"\x1B[32m":"",yellow:g?"\x1B[33m":"",blue:g?"\x1B[34m":"",magenta:g?"\x1B[35m":"",cyan:g?"\x1B[36m":"",white:g?"\x1B[37m":"",gray:g?"\x1B[90m":"",lightRed:g?"\x1B[91m":"",lightGreen:g?"\x1B[92m":"",lightYellow:g?"\x1B[93m":"",lightBlue:g?"\x1B[94m":"",lightMagenta:g?"\x1B[95m":"",lightCyan:g?"\x1B[96m":"",lightGray:g?"\x1B[37m":"",bgBlack:g?"\x1B[40m":"",bgRed:g?"\x1B[41m":"",bgGreen:g?"\x1B[42m":"",bgYellow:g?"\x1B[43m":"",bgBlue:g?"\x1B[44m":"",bgMagenta:g?"\x1B[45m":"",bgCyan:g?"\x1B[46m":"",bgWhite:g?"\x1B[47m":"",bgGray:g?"\x1B[100m":"",bgLightRed:g?"\x1B[101m":"",bgLightGreen:g?"\x1B[102m":"",bgLightYellow:g?"\x1B[103m":"",bgLightBlue:g?"\x1B[104m":"",bgLightMagenta:g?"\x1B[105m":"",bgLightCyan:g?"\x1B[106m":"",bgLightGray:g?"\x1B[47m":"",bold:g?"\x1B[1m":"",dim:g?"\x1B[2m":"",italic:g?"\x1B[3m":"",underline:g?"\x1B[4m":"",inverse:g?"\x1B[7m":"",hidden:g?"\x1B[8m":"",strikethrough:g?"\x1B[9m":""},U="\x1B[",kt="\x1B]8;;",$t="\x1B]8;;\x07",qe=(e)=>String(e);function B(e,t,n){return Math.min(Math.max(Math.floor(e),t),n)}function u(e,t=d.reset){return(n)=>{if(!g)return String(n);return`${e}${String(n)}${t}`}}function Ft(e){return e.replace(/\x1B\]8;;[^\x07]*(?:\x07|\x1B\\)/g,"").replace(/\x1B\]8;;(?:\x07|\x1B\\)/g,"")}function I(e){return Ft(e).replace(/\x1B\[[0-?]*[ -/]*[@-~]/g,"")}var Ke=I;function He(e){return Array.from(I(e)).length}var ie=u(d.black),se=u(d.red),T=u(d.green),ae=u(d.yellow),le=u(d.blue),ce=u(d.magenta),P=u(d.cyan),ue=u(d.white),S=u(d.gray),ge=u(d.lightRed),de=u(d.lightGreen),me=u(d.lightYellow),fe=u(d.lightBlue),pe=u(d.lightMagenta),he=u(d.lightCyan),K=u(d.lightGray),be=u(d.bgBlack),ye=u(d.bgRed),Ce=u(d.bgGreen),xe=u(d.bgYellow),we=u(d.bgBlue),ke=u(d.bgMagenta),j=u(d.bgCyan),$e=u(d.bgWhite),Fe=u(d.bgGray),ve=u(d.bgLightRed),Be=u(d.bgLightGreen),Se=u(d.bgLightYellow),Oe=u(d.bgLightBlue),Le=u(d.bgLightMagenta),Re=u(d.bgLightCyan),H=u(d.bgLightGray),F=u(d.bold),O=u(d.dim),x=u(d.italic),Ie=u(d.underline),Me=u(d.inverse),Ee=u(d.hidden),Te=u(d.strikethrough),Pe=u(d.reset,"");function Ue(e){return u(`${U}38;5;${B(e,0,255)}m`)}function Ve(e){return u(`${U}48;5;${B(e,0,255)}m`)}function Je(e,t,n){return u(`${U}38;2;${B(e,0,255)};${B(t,0,255)};${B(n,0,255)}m`)}function Qe(e,t,n){return u(`${U}48;2;${B(e,0,255)};${B(t,0,255)};${B(n,0,255)}m`)}function Xe(e,t){let n=(o,i)=>{let l=String(o);if(!g)return l;return`${kt}${i}\x07${l}${$t}`};if(typeof t==="string")return n(e,t);let r=String(e);return(o)=>n(o,r)}var vt={black:ie,red:se,green:T,yellow:ae,blue:le,magenta:ce,cyan:P,white:ue,gray:S,lightRed:ge,lightGreen:de,lightYellow:me,lightBlue:fe,lightMagenta:pe,lightCyan:he,lightGray:K,bgBlack:be,bgRed:ye,bgGreen:Ce,bgYellow:xe,bgBlue:we,bgMagenta:ke,bgCyan:j,bgWhite:$e,bgGray:Fe,bgLightRed:ve,bgLightGreen:Be,bgLightYellow:Se,bgLightBlue:Oe,bgLightMagenta:Le,bgLightCyan:Re,bgLightGray:H,bold:F,dim:O,italic:x,underline:Ie,inverse:Me,hidden:Ee,strikethrough:Te,reset:Pe};function Ze(e){return vt[e]??qe}function xr(e,t){if(typeof t==="function")return t(e);return Ze(t)(e)}function Bt(){return g}var wr={black:ie,red:se,green:T,yellow:ae,blue:le,magenta:ce,cyan:P,white:ue,gray:S,lightRed:ge,lightGreen:de,lightYellow:me,lightBlue:fe,lightMagenta:pe,lightCyan:he,lightGray:K,bgBlack:be,bgRed:ye,bgGreen:Ce,bgYellow:xe,bgBlue:we,bgMagenta:ke,bgCyan:j,bgWhite:$e,bgGray:Fe,bgLightRed:ve,bgLightGreen:Be,bgLightYellow:Se,bgLightBlue:Oe,bgLightMagenta:Le,bgLightCyan:Re,bgLightGray:H,bold:F,dim:O,italic:x,underline:Ie,inverse:Me,hidden:Ee,strikethrough:Te,reset:Pe,ansi256:Ue,ansi256Bg:Ve,trueColor:Je,trueColorBg:Qe,link:Xe,stripColors:Ke},kr={black:ie,red:se,green:T,yellow:ae,blue:le,magenta:ce,cyan:P,white:ue,gray:S,lightRed:ge,lightGreen:de,lightYellow:me,lightBlue:fe,lightMagenta:pe,lightCyan:he,lightGray:K,bgBlack:be,bgRed:ye,bgGreen:Ce,bgYellow:xe,bgBlue:we,bgMagenta:ke,bgCyan:j,bgWhite:$e,bgGray:Fe,bgLightRed:ve,bgLightGreen:Be,bgLightYellow:Se,bgLightBlue:Oe,bgLightMagenta:Le,bgLightCyan:Re,bgLightGray:H,bold:F,dim:O,italic:x,underline:Ie,inverse:Me,hidden:Ee,strikethrough:Te,reset:Pe,ansi256:Ue,ansi256Bg:Ve,trueColor:Je,trueColorBg:Qe,link:Xe,stripColors:Ke,grey:S,lightGrey:K,bgLightGrey:H,supportsColor:Bt};function St(e,t,n,r){let o=He(e);if(o>=t)return e;let i=r[0]||" ",l=t-o;if(n==="right")return`${i.repeat(l)}${e}`;if(n==="center"){let s=Math.floor(l/2),a=l-s;return`${i.repeat(s)}${e}${i.repeat(a)}`}return`${e}${i.repeat(l)}`}function V(e){return Math.max(0,...e.map(He))}function J(e,t,n="left"){let r=String(e).split(/\r?\n/),o=typeof t==="object"?t:void 0,i=typeof t==="number"?t:o?.width??V(r),l=o?.align??n,s=o?.padChar??" ";return r.map((a)=>St(a,Math.max(0,i),l,s)).join(`
6
+ `)}function $r(e,t){return J(e,t,"left")}function Fr(e,t){let n=String(e).split(/\r?\n/);return J(e,t??process.stdout?.columns??V(n),"right")}function vr(e,t){let n=String(e).split(/\r?\n/);return J(e,t??process.stdout?.columns??V(n),"center")}var Ot={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551"},round:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502"}};function et(e,t={}){let n=String(e).split(/\r?\n/),r=Ot[t.borderStyle??"single"],o=Math.max(0,t.padding??1),i=Math.max(0,t.margin??0),l=t.align??"left",s=V(n),a=s+o*2,c=typeof t.borderColor==="function"?t.borderColor:t.borderColor?Ze(t.borderColor):qe,y=c((()=>{if(!t.title)return`${r.topLeft}${r.horizontal.repeat(a)}${r.topRight}`;let k=` ${I(String(t.title))} `.slice(0,a),E=r.horizontal.repeat(Math.max(0,a-k.length));return`${r.topLeft}${k}${E}${r.topRight}`})()),C=c(`${r.bottomLeft}${r.horizontal.repeat(a)}${r.bottomRight}`),h=n.map((w)=>{let k=J(w,{align:l,width:s}),E=`${" ".repeat(o)}${k}${" ".repeat(o)}`;return`${c(r.vertical)}${E}${c(r.vertical)}`}),v=" ".repeat(i);return[y,...h,C].map((w)=>`${v}${w}`).join(`
7
+ `)}var Br=wt(["The best way to get started is to quit talking and begin doing.","The pessimist sees difficulty in every opportunity. The optimist sees opportunity in every difficulty.","Don\u2019t let yesterday take up too much of today.","You learn more from failure than from success. Don\u2019t let it stop you. Failure builds character.","It\u2019s not whether you get knocked down, it\u2019s whether you get up.","If you are working on something that you really care about, you don\u2019t have to be pushed. The vision pulls you.","People who are crazy enough to think they can change the world, are the ones who do.","Failure will never overtake me if my determination to succeed is strong enough.","Entrepreneurs are great at dealing with uncertainty and also very good at minimizing risk. That\u2019s the classic entrepreneur.","We may encounter many defeats but we must not be defeated.","Knowing is not enough; we must apply. Wishing is not enough; we must do.","Imagine your life is perfect in every respect; what would it look like?","We generate fears while we sit. We overcome them by action.","Whether you think you can or think you can\u2019t, you\u2019re right.","Security is mostly a superstition. Life is either a daring adventure or nothing."]);var tt="0.75.259";async function Tr(e,t){return new Promise((n)=>{if(t?.quiet===!1)console.log(),console.log(P(F("Stacks CLI"))+O(` v${tt}`)),console.log();if(p.info(`Running ${j(x(F(` ${e} `)))}`),t?.showPerformance===!1||t?.quiet)return n(0);return n(performance.now())})}function Pr(e,t,n){let r={type:"success",useSeconds:!0,...t};return r.message=t?.message||e,new Promise((o)=>{if(n)return Rt(n),o(Ae.FatalError);if(r?.startTime){let i=performance.now()-r.startTime;if(r.useSeconds)i=i/1000,i=Math.round(i*100)/100;if(r.quiet===!0)return o(Ae.Success);if(n)p.error(`[${i.toFixed(2)}${r.useSeconds?"s":"ms"}] Failed`);else if(r.type==="error")p.error(`[${i.toFixed(2)}${r.useSeconds?"s":"ms"}] ${r.message??"Failed"}`);else if(r.type==="warning")p.warn(`[${i.toFixed(2)}${r.useSeconds?"s":"ms"}] ${r.message??"Complete"}`);else if(r.type==="info")p.info(`${O(S(`[${i.toFixed(2)}${r.useSeconds?"s":"ms"}]`))} ${r.message??"Complete"}`);else p.success(`${O(S(F(`[${i.toFixed(2)}${r.useSeconds?"s":"ms"}]`)))} ${F(T(r.message??"Complete"))}`)}else if(r?.type==="info")p.info(e);else if(r?.type==="error")p.error(e);else if(r?.type==="warning")p.warn(e);else if(r?.type==="success"&&r?.quiet!==!0)p.success(e);p.flush().catch(()=>{}).then(()=>o(Ae.Success))})}import Q from"process";function rt(e){if(!e)return!1;return e.startsWith("--")}function It(e){return e.startsWith("-")&&!rt(e)}function Ge(e){if(e==="true")return!0;if(e==="false")return!1;let t=Number.parseFloat(e);if(!Number.isNaN(t))return t;return e.replace(/"/g,"")}function Mt(e,t,n,r){let[o,i]=e.slice(2).split("=");if(i!==void 0)r[o]=Ge(i);else if(n+1<t.length&&!t[n+1]?.startsWith("-"))r[o]=t[n+1],n++;else r[o]=!0;return n}function Et(e,t,n,r){let[o,i]=e.slice(1).split("=");if(o===void 0)return n;if(i!==void 0&&o!==void 0)for(let l=0;l<o.length;l++)r[o[l]]=Ge(i);else for(let l=0;l<o.length;l++)if(n+1<t.length&&l===o.length-1&&!t[n+1]?.startsWith("-"))r[o[l]]=Ge(t[n+1]),n++;else r[o[l]]=!0;return n}function Tt(e){if(e===void 0)e=Q.argv.slice(2);let t=[],n={};for(let r=0;r<e.length;r++){let o=e[r];if(!o)continue;if(rt(o))r=Mt(o,e,r,n);else if(It(o))r=Et(o,e,r,n);else t.push(o)}return{args:t,options:n}}function Wr(e){if(e===void 0)e=Q.argv.slice(2);return Tt(e).args}function Yr(e){e=e||{};let t={dryRun:!1,quiet:!1,verbose:!1},n=Q.argv.slice(2);for(let r=0;r<n.length;r++){let o=n[r];if(o?.startsWith("--")){let l=o.substring(2).replace(/-([a-z])/gi,(s)=>s[1]?s[1].toUpperCase():"");if(r+1<n.length&&!n?.[r+1]?.startsWith("--"))if(n?.[r+1]==="true"||n?.[r+1]==="false")e[l]=n[r+1]==="true",r++;else e[l]=n[r+1],r++;else e[l]=!0}}if(Object.keys(e).length===0)return{};return{...t,...e}}function Pt(e){let t=[];for(let[n,r]of Object.entries(e)){if(n==="--"||n==="_"||r===!1||r===void 0||r===null)continue;if(typeof r==="object"&&!Array.isArray(r))continue;if(typeof r==="function"||typeof r==="symbol")continue;if(r===!0)t.push(`--${n}`);else t.push(`--${n}`,String(r))}return t}function At(e){if(Array.isArray(e)){if(e=Array.from(new Set(e)),Array.isArray(e)&&e[0]&&!e[0].startsWith("-"))e.shift();return e.join(" ")}if(typeof e==="object"&&e!==null)return Pt(e).join(" ");return At(Q.argv.slice(2))}async function Dr(e,t){if(!Number.isSafeInteger(t.timeoutMs)||t.timeoutMs<1||t.timeoutMs>120000)throw Error("Invalid bounded process timeout");for(let f of[t.stdoutBytes,t.stderrBytes])if(!Number.isSafeInteger(f)||f<1||f>2000000)throw Error("Invalid bounded process output limit");let n=process.platform!=="win32",r=Bun.spawn(e,{cwd:t.cwd,env:t.env??process.env,stdin:"ignore",stdout:"pipe",stderr:"pipe",detached:n}),o=[r.stdout.getReader(),r.stderr.getReader()],i=[],l,s=!1,a=!1,c="failed",m=[];function y(f){if(f?.code!=="ESRCH")m.push(f)}function C(){if(n)try{process.kill(-r.pid,"SIGKILL")}catch(f){y(f)}if(r.exitCode===null)try{r.kill("SIGKILL")}catch(f){y(f)}}function h(f,L="failed"){if(!s)l=f,s=!0,c=L;if(a)return;a=!0,C();for(let R of o)i.push(R.cancel().catch((N)=>{m.push(N)}))}async function v(f,L,R){let N=[],ee=0;try{while(!0){let{done:D,value:te}=await f.read();if(D)return Buffer.concat(N,ee).toString("utf8");if(te.byteLength>L-ee){let je=Error(`${t.label} ${R} exceeds byte limit`);throw h(je,`${R} exceeds byte limit`),je}ee+=te.byteLength,N.push(te)}}catch(D){throw h(D,`${R} read failed`),D}}let w=setTimeout(()=>h(Error(`${t.label} timed out`),"timed out"),t.timeoutMs),k=v(o[0],t.stdoutBytes,"stdout"),E=v(o[1],t.stderrBytes,"stderr");try{let[f,L,R]=await Promise.all([r.exited,k,E]);if(s)throw l;return{exitCode:f,stdout:L,stderr:R}}catch(f){throw h(f),f}finally{if(clearTimeout(w),C(),r.exitCode===null)h(Error(`${t.label} interrupted`));await Promise.allSettled([r.exited,k,E,...i]);for(let f of o)try{f.releaseLock()}catch(L){m.push(L)}if(m.length)throw AggregateError(s?[l,...m]:m,`${t.label} ${s?`${c}; `:""}process cleanup failed`)}}import{writeSync as Gt}from"fs";import{format as X}from"util";function Kr(...e){ot(1,X(...e))}function Hr(...e){ot(2,X(...e))}async function Ur(...e){await nt(process.stdout,X(...e))}async function Vr(...e){await nt(process.stderr,X(...e))}function nt(e,t){return new Promise((n,r)=>{let o=(i)=>{e.off("error",o),r(i)};e.once("error",o);try{e.write(`${t}
8
+ `,"utf8",(i)=>{if(i)setImmediate(()=>e.off("error",o)),r(i);else e.off("error",o),n()})}catch(i){e.off("error",o),r(i)}})}function ot(e,t){let n=Buffer.from(`${t}
9
+ `),r=0;while(r<n.length)r+=Gt(e,n,r,n.length-r)}import b from"process";import{createInterface as jt}from"readline";var Zr=b.stdin.destroy;b.stdin.destroy=function(e){if(e)this.emit("error",e);return this};b.on("SIGINT",()=>{console.log(`
10
+ `),b.exit(130)});var A=null;function Wt(){if(!A){let e=b.stdin.isTTY&&b.stdout.isTTY;if(A=jt({input:b.stdin,output:b.stdout,terminal:e}),e&&typeof b.stdin.setRawMode==="function")A.on("SIGINT",()=>{b.emit("SIGINT")});A.once("close",()=>{A=null})}return A}var Z=Symbol("stdin-eof");function it(e){return new Promise((t)=>{let n=Wt(),r=!1,o=(l)=>{if(r)return;r=!0,n.off("close",i),t(l)},i=()=>o(Z);n.once("close",i);try{n.question(e,o)}catch{o(Z)}})}function st(){if(b.argv.includes("--no-interaction"))return!1;if(b.env.CI)return!1;return Boolean(b.stdin.isTTY&&b.stdout.isTTY)}async function W(e){if(!st())return"";let t=await it(e);return t===Z?"":t}function at(e,t){let n=e.toLowerCase().trim();if(!n)return t;if(n==="y"||n==="yes")return!0;if(n==="n"||n==="no")return!1;return t}async function en(e){let t=typeof e==="string"?{message:e}:e,n=t.initial??!1,r=n?" (Y/n) ":" (y/N) ";if(!st())return null;let o=await it(`${t.message}${r}`);if(o===Z)return null;return at(o,n)}async function Yt(e){let t=typeof e==="string"?{message:e}:e,n=t.initial??!1,r=n?" (Y/n) ":" (y/N) ",o=await W(`${t.message}${r}`);return at(o,n)}async function Nt(e){let t=typeof e==="string"?{message:e}:e,n=t.placeholder||t.initial||"",r=n?` (${n}) `:" ";return(await W(`${t.message}${r}`)).trim()||t.initial||""}async function Dt(e){console.log(e.message),e.choices.forEach((o,i)=>{let l=i===(e.initial??0)?">":" ";console.log(`${l} ${i+1}. ${o.label}`)});let t=await W("Select (number): "),n=Number.parseInt(t.trim(),10)-1,r=e.choices[n]??e.choices[e.initial??0];if(!r)throw Error("select prompt: no choices available");return r.value}async function zt(e){console.log(e.message),console.log("(Enter numbers separated by commas)"),e.choices.forEach((o,i)=>{console.log(` ${i+1}. ${o.label}`)});let n=(await W("Select (e.g., 1,3,4): ")).split(",").map((o)=>Number.parseInt(o.trim(),10)-1),r=[];for(let o of n){let i=e.choices[o];if(i)r.push(i.value)}return r}async function _t(e){return(await W(`${(typeof e==="string"?{message:e}:e).message} `)).trim()}var tn={text:Nt,confirm:Yt,select:Dt,multiselect:zt,password:_t};import{handleError as qt}from"@stacksjs/error-handling";async function Kt(e,t){let n={...t,stdin:t?.stdin??"inherit",verbose:t?.verbose??!1};return await oe(e,n)}async function sn(e,t){let n={...t,stdio:[t?.stdin??"inherit","pipe","pipe"],verbose:t?.verbose??!1};return await oe(e,n)}async function an(e,t){let n={...t,stdio:[t?.stdin??"inherit","pipe","pipe"],verbose:t?.verbose??!1};return await ze(e,n)}async function ln(e,t){let n=[];for(let r of e){let o=await Kt(r,t);if(o.isErr)throw qt("Error during runCommands",o.error),o.error;n.push(o)}return n}import Ht from"process";var Ut=["SIGINT","SIGTERM","SIGHUP"],G=new Map,lt=!1;function Vt(){if(lt)return;lt=!0;for(let e of Ut)Ht.on(e,async()=>{for(let[t,n]of G)try{await n()}catch(r){console.error(`[signals] cleanup '${t}' threw:`,r)}})}function gn(e,t){return Vt(),G.set(e,t),()=>{if(G.get(e)===t)G.delete(e)}}function dn(e){G.delete(e)}function mn(){return[...G.keys()]}var ct=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Y=process.stdout.isTTY&&!process.env.CI;function Jt(e){let t=e||"",n=0,r=null,o=!1,i=()=>{if(Y)process.stdout.write("\r\x1B[K")},l=()=>{if(!Y)return;i();let s=ct[n];process.stdout.write(`${s} ${t}`),n=(n+1)%ct.length};return{start(s){if(s)t=s;if(o)return;if(o=!0,Y)l(),r=setInterval(l,80);else if(t)console.log(` ${t}`)},stop(s){if(o=!1,r)clearInterval(r),r=null;if(i(),s)console.log(s)},update(s){if(t=s,!Y&&o)console.log(` ${s}`)},succeed(s){let a=s||t;if(o=!1,r)clearInterval(r),r=null;i(),console.log(`\u2713 ${a}`)},fail(s){let a=s||t;if(o=!1,r)clearInterval(r),r=null;i(),console.error(`\u2717 ${a}`)},get text(){return t},set text(s){if(t=s,Y&&o)l()},get isSpinning(){return o}}}async function pn(e,t,n){let r=Jt(e);r.start();try{let o=await t();return r.succeed(n?.successMessage||e),o}catch(o){throw r.fail(n?.failMessage||`Failed: ${e}`),o}}import M from"process";var ut="\r\x1B[2K";function Qt(){return{columns:M.stdout.columns??80,rows:M.stdout.rows??24}}function Xt(){return Boolean(M.stdout.isTTY)&&!M.env.CI}function Cn(e,t){console.log(et(e,t===void 0?{}:{title:t}))}function xn(e,t={}){let r=(t.columns??[...new Set(e.flatMap((a)=>Object.keys(a)))]).map((a)=>typeof a==="string"?{key:a}:a);if(r.length===0)return"";let o=(a,c)=>{let m=a[c.key];return m===void 0||m===null?"":String(m)},i=r.map((a)=>{let c=t.header===!1?"":a.header??a.key;return Math.max(I(c).length,...e.map((m)=>I(o(m,a)).length))}),l=(a,c,m)=>{let y=Math.max(0,c-I(a).length);return m==="right"?" ".repeat(y)+a:a+" ".repeat(y)},s=[];if(t.header!==!1)s.push(r.map((a,c)=>l(a.header??a.key,i[c],a.align)).join(" ").trimEnd()),s.push(r.map((a,c)=>"-".repeat(i[c])).join(" "));for(let a of e)s.push(r.map((c,m)=>l(o(a,c),i[m],c.align)).join(" ").trimEnd());return s.join(`
11
+ `)}function wn(e){if(!Number.isFinite(e.total)||e.total<=0)throw TypeError(`progress() needs a positive total; got ${e.total}`);let t=e.format??"|{bar}| {percentage}% | {value}/{total}",n=e.width??Math.max(10,Math.floor(Qt().columns/3)),r=Xt(),o=0,i=-1,l=(a)=>{let c=Math.min(1,o/e.total),m=Math.round(c*n),y={bar:"\u2588".repeat(m)+"\u2591".repeat(n-m),percentage:Math.round(c*100),value:o,total:e.total,...a},C=t.replace(/\{(\w+)\}/g,(v,w)=>String(y[w]??v));if(r){M.stdout.write(`${ut}${C}`);return}let h=Math.floor(c*10);if(h>i)i=h,console.log(C)},s={update(a,c={}){o=Math.max(0,Math.min(e.total,a)),l(c)},increment(a=1){s.update(o+a)},stop(a){if(r)M.stdout.write(ut);if(a)console.log(a);else if(r)M.stdout.write(`
12
+ `)},get value(){return o},get total(){return e.total}};return s}async function kn(e){let t=[];for(let n of e){let r=Date.now(),o=n.skip?.();if(o){console.log(`- ${n.title}${typeof o==="string"?` (${o})`:""}`),t.push({title:n.title,status:"skipped",durationMs:0});continue}try{await n.task(),console.log(`\u2713 ${n.title}`),t.push({title:n.title,status:"done",durationMs:Date.now()-r})}catch(i){throw console.log(`\u2717 ${n.title}`),t.push({title:n.title,status:"failed",error:i instanceof Error?i:Error(String(i)),durationMs:Date.now()-r}),i}}return t}export{or as CLI,J as align,Ue as ansi256,Ve as ansi256Bg,bt as applyAliases,be as bgBlack,we as bgBlue,j as bgCyan,Fe as bgGray,Ce as bgGreen,Oe as bgLightBlue,Re as bgLightCyan,H as bgLightGray,Be as bgLightGreen,Le as bgLightMagenta,ve as bgLightRed,Se as bgLightYellow,ke as bgMagenta,ye as bgRed,$e as bgWhite,xe as bgYellow,ie as black,le as blue,F as bold,et as box,Pt as buddyOptionArgs,At as buddyOptions,vr as centerAlign,sr as cli,xr as colorize,wr as colors,Yt as confirm,en as confirmOrNull,P as cyan,gr as defineCommand,dr as defineCommands,O as dim,pt as discoverCommandFiles,oe as exec,ze as execSync,Ze as getColor,Qt as getTerminalSize,S as gray,T as green,Ee as hidden,er as installPackage,tr as installStack,Tr as intro,Me as inverse,Xt as isInteractive,x as italic,kr as kolorist,$r as leftAlign,fe as lightBlue,he as lightCyan,K as lightGray,de as lightGreen,pe as lightMagenta,ge as lightRed,me as lightYellow,Xe as link,mn as listSignalHandlers,De as loadCommandRegistry,ur as loadCommands,p as log,ce as magenta,zt as multiselect,Cn as note,dn as offSignal,gn as onSignal,ir as onUnknownSubcommand,Pr as outro,Wr as parseArgs,Tt as parseArgv,Yr as parseOptions,_t as password,Kr as print,Ur as printAsync,Hr as printError,Vr as printErrorAsync,wn as progress,tn as prompts,st as promptsAreInteractive,Br as quotes,se as red,Pe as reset,ht as resolveCommands,Fr as rightAlign,Dr as runBoundedProcess,Kt as runCommand,an as runCommandSync,ln as runCommands,sn as runProcess,Dt as select,Jt as spinner,Te as strikethrough,I as stripAnsi,Ke as stripColors,xn as table,kn as tasks,Nt as text,Je as trueColor,Qe as trueColorBg,Ie as underline,ue as white,pn as withSpinner,ae as yellow};
@@ -0,0 +1,15 @@
1
+ /** Owns a finite command, its output readers and, on POSIX, its process group. */
2
+ export declare function runBoundedProcess(command: string[], options: BoundedProcessOptions): Promise<BoundedProcessResult>;
3
+ export declare interface BoundedProcessOptions {
4
+ cwd?: string
5
+ env?: Record<string, string | undefined>
6
+ timeoutMs: number
7
+ stdoutBytes: number
8
+ stderrBytes: number
9
+ label: string
10
+ }
11
+ export declare interface BoundedProcessResult {
12
+ exitCode: number
13
+ stdout: string
14
+ stderr: string
15
+ }
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ async function S(P,t){if(!Number.isSafeInteger(t.timeoutMs)||t.timeoutMs<1||t.timeoutMs>120000)throw Error("Invalid bounded process timeout");for(let e of[t.stdoutBytes,t.stderrBytes])if(!Number.isSafeInteger(e)||e<1||e>2000000)throw Error("Invalid bounded process output limit");let w=process.platform!=="win32",r=Bun.spawn(P,{cwd:t.cwd,env:t.env??process.env,stdin:"ignore",stdout:"pipe",stderr:"pipe",detached:w}),d=[r.stdout.getReader(),r.stderr.getReader()],h=[],l,i=!1,g=!1,p="failed",o=[];function y(e){if(e?.code!=="ESRCH")o.push(e)}function b(){if(w)try{process.kill(-r.pid,"SIGKILL")}catch(e){y(e)}if(r.exitCode===null)try{r.kill("SIGKILL")}catch(e){y(e)}}function u(e,n="failed"){if(!i)l=e,i=!0,p=n;if(g)return;g=!0,b();for(let s of d)h.push(s.cancel().catch((a)=>{o.push(a)}))}async function B(e,n,s){let a=[],f=0;try{while(!0){let{done:c,value:m}=await e.read();if(c)return Buffer.concat(a,f).toString("utf8");if(m.byteLength>n-f){let E=Error(`${t.label} ${s} exceeds byte limit`);throw u(E,`${s} exceeds byte limit`),E}f+=m.byteLength,a.push(m)}}catch(c){throw u(c,`${s} read failed`),c}}let R=setTimeout(()=>u(Error(`${t.label} timed out`),"timed out"),t.timeoutMs),x=B(d[0],t.stdoutBytes,"stdout"),k=B(d[1],t.stderrBytes,"stderr");try{let[e,n,s]=await Promise.all([r.exited,x,k]);if(i)throw l;return{exitCode:e,stdout:n,stderr:s}}catch(e){throw u(e),e}finally{if(clearTimeout(R),b(),r.exitCode===null)u(Error(`${t.label} interrupted`));await Promise.allSettled([r.exited,x,k,...h]);for(let e of d)try{e.releaseLock()}catch(n){o.push(n)}if(o.length)throw AggregateError(i?[l,...o]:o,`${t.label} ${i?`${p}; `:""}process cleanup failed`)}}export{S as runBoundedProcess};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/cli",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.258",
5
+ "version": "0.75.259",
6
6
  "description": "TypeScript framework for CLI artisans. Build beautiful console apps with ease.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -70,16 +70,16 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@stacksjs/clapp": "^0.2.12",
73
- "@stacksjs/collections": "0.75.258",
74
- "@stacksjs/error-handling": "0.75.258",
75
- "@stacksjs/logging": "0.75.258",
76
- "@stacksjs/types": "0.75.258"
73
+ "@stacksjs/collections": "0.75.259",
74
+ "@stacksjs/error-handling": "0.75.259",
75
+ "@stacksjs/logging": "0.75.259",
76
+ "@stacksjs/types": "0.75.259"
77
77
  },
78
78
  "devDependencies": {
79
- "@stacksjs/config": "0.75.258",
80
- "@stacksjs/path": "0.75.258",
81
- "@stacksjs/utils": "0.75.258",
82
- "@stacksjs/validation": "0.75.258",
79
+ "@stacksjs/config": "0.75.259",
80
+ "@stacksjs/path": "0.75.259",
81
+ "@stacksjs/utils": "0.75.259",
82
+ "@stacksjs/validation": "0.75.259",
83
83
  "better-dx": "^0.2.24"
84
84
  }
85
85
  }