@stacksjs/cli 0.73.1 → 0.73.3

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/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- import Oe from"process";async function ve(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??Oe.cwd(),stdout:t.silent?"ignore":"inherit",stderr:t.silent?"ignore":"inherit",stdin:"ignore",env:Oe.env}).exited;if(i!==0)throw Error(`Failed to install ${e} (exit code ${i})`)}async function Et(e,t){return ve(e,t??{silent:!0})}async function Tt(e,t){return ve(`@stacksjs/${e}`,t??{silent:!0})}import{CLI as Wt,cli as Je,onUnknownSubcommand as Yt}from"@stacksjs/clapp";function Nt(e,t){if(typeof e==="object")t=e,e=t.name;return Je(e||"buddy")}import{existsSync as q,readdirSync as Qe}from"fs";import{join as Se}from"path";var Xe=/(?:\.test|\.spec|\.bench|\.d)\.ts$/;function Ze(e){return e.endsWith(".ts")&&!Xe.test(e)&&!e.startsWith("_")}function et(e){if(!q(e))return[];let t=[],n=(r,o)=>{for(let i of Qe(r,{withFileTypes:!0})){if(i.name.startsWith(".")||i.name==="node_modules")continue;if(i.isDirectory()){n(Se(r,i.name),`${o}${i.name}/`);continue}if(Ze(i.name))t.push(`${o}${i.name.slice(0,-3)}`)}};return n(e,""),t.sort()}async function Re(e){if(!e||!q(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 tt(e){let{commandsDir:t}=e,n=e.registry??(await Re(e.registryPath)).registry,r=et(t),o=new Map;for(let s of r)o.set(s,{file:s,path:Se(t,`${s}.ts`),aliases:[],enabled:!0,source:"auto"});let i=[];for(let[s,a]of Object.entries(n??{})){let u=typeof a==="string"?{file:a}:a,m=o.get(u.file);if(!m)continue;if(m.signature=s,m.aliases=u.aliases??[],m.enabled=u.enabled!==!1,m.source="registry",!i.includes(m))i.push(m)}for(let s of r){let a=o.get(s);if(a&&!i.includes(a))i.push(a)}return i}function nt(e,t,n){let r=t.trim().split(/\s+/)[0],i=e?.commands?.find((s)=>s.name===r);if(!i||typeof i.alias!=="function")return!1;for(let s of n)i.alias(s);return!0}async function _t(e,t){let n=t.onError??(()=>{}),r=t.onDebug??(()=>{});if(!q(t.commandsDir))return r(`No ${t.commandsDir} directory, skipping application commands.`),[];let o=t.registry?{registry:t.registry}:await Re(t.registryPath);if(o.error)n(`Could not read the command registry at ${t.registryPath}`,o.error);let i=await tt({...t,registry:o.registry}),s=[];for(let a of i){if(!a.enabled){r(`Skipping disabled command ${a.file}.`);continue}try{let u=await import(a.path);if(u.enabled===!1){r(`Skipping ${a.file}: the module exports \`enabled = false\`.`);continue}if(typeof u.default!=="function"){n(`Expected a default export function in ${a.file}.ts, but got: ${typeof u.default}`);continue}let m=e.commands?.length??0;u.default(e);let B=[...a.aliases,...u.aliases??[]];if(B.length)rt(e,a.signature,m,B,r);s.push(a)}catch(u){n(`Failed to load command ${a.file}`,u)}}return s}function rt(e,t,n,r,o){if(t&&nt(e,t,r))return;let a=(e.commands?.slice(n)??[])[0];if(!a||typeof a.alias!=="function"){o(`Could not alias '${t??"command"}': no matching command was registered.`);return}for(let u of r)a.alias(u)}function Ht(e){if(typeof e==="function")return e;return(t)=>ot(t,e)}function ot(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 Kt(e){return e}import M from"process";import{err as I,handleError as _,ok as it}from"@stacksjs/error-handling";import{ExitCode as G}from"@stacksjs/types";async function H(e,t){let n=Array.isArray(e)?e:e.match(/(?:[^\s"]|"[^"]*")+/g);if(!n)return I(_(`Failed to parse command: ${n}`,t));let r=t?.cwd??M.cwd(),o=t?.timeoutMs,i=Bun.spawn(n,{stdin:t?.stdin??"inherit",stdout:t?.silent||t?.quiet?"ignore":t?.stdin?t.stdin:t?.stdout||"inherit",stderr:t?.silent||t?.quiet?"ignore":t?.stderr||"inherit",cwd:r,env:{...M.env,...t?.env},onExit(m,B,N,D){Ge("spawn",m,B,N,D)}});if(t?.stdin==="pipe"&&t.input){if(i.stdin)i.stdin.write(t.input),i.stdin.end()}let s,a=await Promise.race([i.exited,new Promise((m)=>{if(!o)return;s=setTimeout(()=>{try{i.kill()}catch{}m(G.FatalError)},o)})]);if(s)clearTimeout(s);if(o&&a===G.FatalError&&i.exitCode===null)return I(_(`Command timed out after ${o}ms: ${d(n.join(" "))} in ${d(r)}`,t));if(a===G.Success)return it(i);let u=i.signalCode;if(u==="SIGTERM"||u==="SIGINT"||u==="SIGKILL"||i.exitCode===null&&a!==G.Success)return I(Error(`Command terminated by ${u??"signal"}: ${n.join(" ")}`));return I(_(`Failed to execute command: ${d(n.join(" "))} in ${d(r)}`,t))}async function Ie(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??M.cwd(),env:{...M.env,...t?.env},onExit(i,s,a,u){Ge("spawnSync",i,s,a,u)}}),o=r.stdout?.toString()??"";if(t?.throwOnError&&r.exitCode!==0){let s=((r.stderr?.toString()??"").trim()||o.trim()||"(no output)").split(`
2
+ import Le from"process";async function ve(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??Le.cwd(),stdout:t.silent?"ignore":"inherit",stderr:t.silent?"ignore":"inherit",stdin:"ignore",env:Le.env}).exited;if(i!==0)throw Error(`Failed to install ${e} (exit code ${i})`)}async function Et(e,t){return ve(e,t??{silent:!0})}async function Tt(e,t){return ve(`@stacksjs/${e}`,t??{silent:!0})}import{CLI as Wt,cli as Je,onUnknownSubcommand as Yt}from"@stacksjs/clapp";function Nt(e,t){if(typeof e==="object")t=e,e=t.name;return Je(e||"buddy")}import{existsSync as q,readdirSync as Qe}from"fs";import{join as Se}from"path";var Xe=/(?:\.test|\.spec|\.bench|\.d)\.ts$/;function Ze(e){return e.endsWith(".ts")&&!Xe.test(e)&&!e.startsWith("_")}function et(e){if(!q(e))return[];let t=[],n=(r,o)=>{for(let i of Qe(r,{withFileTypes:!0})){if(i.name.startsWith(".")||i.name==="node_modules")continue;if(i.isDirectory()){n(Se(r,i.name),`${o}${i.name}/`);continue}if(Ze(i.name))t.push(`${o}${i.name.slice(0,-3)}`)}};return n(e,""),t.sort()}async function Re(e){if(!e||!q(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 tt(e){let{commandsDir:t}=e,n=e.registry??(await Re(e.registryPath)).registry,r=et(t),o=new Map;for(let s of r)o.set(s,{file:s,path:Se(t,`${s}.ts`),aliases:[],enabled:!0,source:"auto"});let i=[];for(let[s,a]of Object.entries(n??{})){let u=typeof a==="string"?{file:a}:a,m=o.get(u.file);if(!m)continue;if(m.signature=s,m.aliases=u.aliases??[],m.enabled=u.enabled!==!1,m.source="registry",!i.includes(m))i.push(m)}for(let s of r){let a=o.get(s);if(a&&!i.includes(a))i.push(a)}return i}function nt(e,t,n){let r=t.trim().split(/\s+/)[0],i=e?.commands?.find((s)=>s.name===r);if(!i||typeof i.alias!=="function")return!1;for(let s of n)i.alias(s);return!0}async function _t(e,t){let n=t.onError??(()=>{}),r=t.onDebug??(()=>{});if(!q(t.commandsDir))return r(`No ${t.commandsDir} directory, skipping application commands.`),[];let o=t.registry?{registry:t.registry}:await Re(t.registryPath);if(o.error)n(`Could not read the command registry at ${t.registryPath}`,o.error);let i=await tt({...t,registry:o.registry}),s=[];for(let a of i){if(!a.enabled){r(`Skipping disabled command ${a.file}.`);continue}try{let u=await import(a.path);if(u.enabled===!1){r(`Skipping ${a.file}: the module exports \`enabled = false\`.`);continue}if(typeof u.default!=="function"){n(`Expected a default export function in ${a.file}.ts, but got: ${typeof u.default}`);continue}let m=e.commands?.length??0;u.default(e);let B=[...a.aliases,...u.aliases??[]];if(B.length)rt(e,a.signature,m,B,r);s.push(a)}catch(u){n(`Failed to load command ${a.file}`,u)}}return s}function rt(e,t,n,r,o){if(t&&nt(e,t,r))return;let a=(e.commands?.slice(n)??[])[0];if(!a||typeof a.alias!=="function"){o(`Could not alias '${t??"command"}': no matching command was registered.`);return}for(let u of r)a.alias(u)}function Ht(e){if(typeof e==="function")return e;return(t)=>ot(t,e)}function ot(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 Kt(e){return e}import M from"process";import{err as I,handleError as _,ok as it}from"@stacksjs/error-handling";import{ExitCode as G}from"@stacksjs/types";async function H(e,t){let n=Array.isArray(e)?e:e.match(/(?:[^\s"]|"[^"]*")+/g);if(!n)return I(_(`Failed to parse command: ${n}`,t));let r=t?.cwd??M.cwd(),o=t?.timeoutMs,i=Bun.spawn(n,{stdin:t?.stdin??"inherit",stdout:t?.silent||t?.quiet?"ignore":t?.stdin?t.stdin:t?.stdout||"inherit",stderr:t?.silent||t?.quiet?"ignore":t?.stderr||"inherit",cwd:r,env:{...M.env,...t?.env},onExit(m,B,N,D){Ge("spawn",m,B,N,D)}});if(t?.stdin==="pipe"&&t.input){if(i.stdin)i.stdin.write(t.input),i.stdin.end()}let s,a=await Promise.race([i.exited,new Promise((m)=>{if(!o)return;s=setTimeout(()=>{try{i.kill()}catch{}m(G.FatalError)},o)})]);if(s)clearTimeout(s);if(o&&a===G.FatalError&&i.exitCode===null)return I(_(`Command timed out after ${o}ms: ${d(n.join(" "))} in ${d(r)}`,t));if(a===G.Success)return it(i);let u=i.signalCode;if(u==="SIGTERM"||u==="SIGINT"||u==="SIGKILL"||i.exitCode===null&&a!==G.Success)return I(Error(`Command terminated by ${u??"signal"}: ${n.join(" ")}`));return I(_(`Failed to execute command: ${d(n.join(" "))} in ${d(r)}`,t))}async function Ie(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??M.cwd(),env:{...M.env,...t?.env},onExit(i,s,a,u){Ge("spawnSync",i,s,a,u)}}),o=r.stdout?.toString()??"";if(t?.throwOnError&&r.exitCode!==0){let s=((r.stderr?.toString()??"").trim()||o.trim()||"(no output)").split(`
3
3
  `).slice(0,5).join(`
4
4
  `);throw Error(`Command failed with exit code ${r.exitCode}: ${n.join(" ")}
5
- ${s}`)}return o}function Ge(e,t,n,r,o){if(p.debug(`exitHandler: ${e}, exitCode: ${n}, signalCode: ${r}`),o)p.debug("Process error:",o.message)}import{handleError as ft}from"@stacksjs/error-handling";import{log as p}from"@stacksjs/logging";import{ExitCode as Be}from"@stacksjs/types";import{collect as st}from"@stacksjs/collections";var c=!process.env.NO_COLOR&&(process.env.FORCE_COLOR?process.env.FORCE_COLOR!=="0":!!process.stdout?.isTTY),g={reset:c?"\x1B[0m":"",black:c?"\x1B[30m":"",red:c?"\x1B[31m":"",green:c?"\x1B[32m":"",yellow:c?"\x1B[33m":"",blue:c?"\x1B[34m":"",magenta:c?"\x1B[35m":"",cyan:c?"\x1B[36m":"",white:c?"\x1B[37m":"",gray:c?"\x1B[90m":"",lightRed:c?"\x1B[91m":"",lightGreen:c?"\x1B[92m":"",lightYellow:c?"\x1B[93m":"",lightBlue:c?"\x1B[94m":"",lightMagenta:c?"\x1B[95m":"",lightCyan:c?"\x1B[96m":"",lightGray:c?"\x1B[37m":"",bgBlack:c?"\x1B[40m":"",bgRed:c?"\x1B[41m":"",bgGreen:c?"\x1B[42m":"",bgYellow:c?"\x1B[43m":"",bgBlue:c?"\x1B[44m":"",bgMagenta:c?"\x1B[45m":"",bgCyan:c?"\x1B[46m":"",bgWhite:c?"\x1B[47m":"",bgGray:c?"\x1B[100m":"",bgLightRed:c?"\x1B[101m":"",bgLightGreen:c?"\x1B[102m":"",bgLightYellow:c?"\x1B[103m":"",bgLightBlue:c?"\x1B[104m":"",bgLightMagenta:c?"\x1B[105m":"",bgLightCyan:c?"\x1B[106m":"",bgLightGray:c?"\x1B[47m":"",bold:c?"\x1B[1m":"",dim:c?"\x1B[2m":"",italic:c?"\x1B[3m":"",underline:c?"\x1B[4m":"",inverse:c?"\x1B[7m":"",hidden:c?"\x1B[8m":"",strikethrough:c?"\x1B[9m":""},T="\x1B[",at="\x1B]8;;",lt="\x1B]8;;\x07",Me=(e)=>String(e);function b(e,t,n){return Math.min(Math.max(Math.floor(e),t),n)}function l(e,t=g.reset){return(n)=>{if(!c)return String(n);return`${e}${String(n)}${t}`}}function ct(e){return e.replace(/\x1B\]8;;[^\x07]*(?:\x07|\x1B\\)/g,"").replace(/\x1B\]8;;(?:\x07|\x1B\\)/g,"")}function K(e){return ct(e).replace(/\x1B\[[0-?]*[ -/]*[@-~]/g,"")}var je=K;function Ee(e){return Array.from(K(e)).length}var U=l(g.black),V=l(g.red),x=l(g.green),J=l(g.yellow),Q=l(g.blue),X=l(g.magenta),w=l(g.cyan),Z=l(g.white),y=l(g.gray),ee=l(g.lightRed),te=l(g.lightGreen),ne=l(g.lightYellow),re=l(g.lightBlue),oe=l(g.lightMagenta),ie=l(g.lightCyan),j=l(g.lightGray),se=l(g.bgBlack),ae=l(g.bgRed),le=l(g.bgGreen),ce=l(g.bgYellow),ge=l(g.bgBlue),ue=l(g.bgMagenta),L=l(g.bgCyan),me=l(g.bgWhite),de=l(g.bgGray),pe=l(g.bgLightRed),fe=l(g.bgLightGreen),he=l(g.bgLightYellow),be=l(g.bgLightBlue),ye=l(g.bgLightMagenta),Ce=l(g.bgLightCyan),E=l(g.bgLightGray),h=l(g.bold),C=l(g.dim),d=l(g.italic),xe=l(g.underline),we=l(g.inverse),ke=l(g.hidden),Fe=l(g.strikethrough),$e=l(g.reset,"");function Te(e){return l(`${T}38;5;${b(e,0,255)}m`)}function Pe(e){return l(`${T}48;5;${b(e,0,255)}m`)}function Ae(e,t,n){return l(`${T}38;2;${b(e,0,255)};${b(t,0,255)};${b(n,0,255)}m`)}function We(e,t,n){return l(`${T}48;2;${b(e,0,255)};${b(t,0,255)};${b(n,0,255)}m`)}function Ye(e,t){let n=(o,i)=>{let s=String(o);if(!c)return s;return`${at}${i}\x07${s}${lt}`};if(typeof t==="string")return n(e,t);let r=String(e);return(o)=>n(o,r)}var gt={black:U,red:V,green:x,yellow:J,blue:Q,magenta:X,cyan:w,white:Z,gray:y,lightRed:ee,lightGreen:te,lightYellow:ne,lightBlue:re,lightMagenta:oe,lightCyan:ie,lightGray:j,bgBlack:se,bgRed:ae,bgGreen:le,bgYellow:ce,bgBlue:ge,bgMagenta:ue,bgCyan:L,bgWhite:me,bgGray:de,bgLightRed:pe,bgLightGreen:fe,bgLightYellow:he,bgLightBlue:be,bgLightMagenta:ye,bgLightCyan:Ce,bgLightGray:E,bold:h,dim:C,italic:d,underline:xe,inverse:we,hidden:ke,strikethrough:Fe,reset:$e};function Ne(e){return gt[e]??Me}function tn(e,t){if(typeof t==="function")return t(e);return Ne(t)(e)}function ut(){return c}var nn={black:U,red:V,green:x,yellow:J,blue:Q,magenta:X,cyan:w,white:Z,gray:y,lightRed:ee,lightGreen:te,lightYellow:ne,lightBlue:re,lightMagenta:oe,lightCyan:ie,lightGray:j,bgBlack:se,bgRed:ae,bgGreen:le,bgYellow:ce,bgBlue:ge,bgMagenta:ue,bgCyan:L,bgWhite:me,bgGray:de,bgLightRed:pe,bgLightGreen:fe,bgLightYellow:he,bgLightBlue:be,bgLightMagenta:ye,bgLightCyan:Ce,bgLightGray:E,bold:h,dim:C,italic:d,underline:xe,inverse:we,hidden:ke,strikethrough:Fe,reset:$e,ansi256:Te,ansi256Bg:Pe,trueColor:Ae,trueColorBg:We,link:Ye,stripColors:je},rn={black:U,red:V,green:x,yellow:J,blue:Q,magenta:X,cyan:w,white:Z,gray:y,lightRed:ee,lightGreen:te,lightYellow:ne,lightBlue:re,lightMagenta:oe,lightCyan:ie,lightGray:j,bgBlack:se,bgRed:ae,bgGreen:le,bgYellow:ce,bgBlue:ge,bgMagenta:ue,bgCyan:L,bgWhite:me,bgGray:de,bgLightRed:pe,bgLightGreen:fe,bgLightYellow:he,bgLightBlue:be,bgLightMagenta:ye,bgLightCyan:Ce,bgLightGray:E,bold:h,dim:C,italic:d,underline:xe,inverse:we,hidden:ke,strikethrough:Fe,reset:$e,ansi256:Te,ansi256Bg:Pe,trueColor:Ae,trueColorBg:We,link:Ye,stripColors:je,grey:y,lightGrey:j,bgLightGrey:E,supportsColor:ut};function mt(e,t,n,r){let o=Ee(e);if(o>=t)return e;let i=r[0]||" ",s=t-o;if(n==="right")return`${i.repeat(s)}${e}`;if(n==="center"){let a=Math.floor(s/2),u=s-a;return`${i.repeat(a)}${e}${i.repeat(u)}`}return`${e}${i.repeat(s)}`}function P(e){return Math.max(0,...e.map(Ee))}function A(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??P(r),s=o?.align??n,a=o?.padChar??" ";return r.map((u)=>mt(u,Math.max(0,i),s,a)).join(`
5
+ ${s}`)}return o}function Ge(e,t,n,r,o){if(p.debug(`exitHandler: ${e}, exitCode: ${n}, signalCode: ${r}`),o)p.debug("Process error:",o.message)}import{handleError as ft}from"@stacksjs/error-handling";import{log as p}from"@stacksjs/logging";import{ExitCode as Be}from"@stacksjs/types";import{collect as st}from"@stacksjs/collections";var c=!process.env.NO_COLOR&&(process.env.FORCE_COLOR?process.env.FORCE_COLOR!=="0":!!process.stdout?.isTTY),g={reset:c?"\x1B[0m":"",black:c?"\x1B[30m":"",red:c?"\x1B[31m":"",green:c?"\x1B[32m":"",yellow:c?"\x1B[33m":"",blue:c?"\x1B[34m":"",magenta:c?"\x1B[35m":"",cyan:c?"\x1B[36m":"",white:c?"\x1B[37m":"",gray:c?"\x1B[90m":"",lightRed:c?"\x1B[91m":"",lightGreen:c?"\x1B[92m":"",lightYellow:c?"\x1B[93m":"",lightBlue:c?"\x1B[94m":"",lightMagenta:c?"\x1B[95m":"",lightCyan:c?"\x1B[96m":"",lightGray:c?"\x1B[37m":"",bgBlack:c?"\x1B[40m":"",bgRed:c?"\x1B[41m":"",bgGreen:c?"\x1B[42m":"",bgYellow:c?"\x1B[43m":"",bgBlue:c?"\x1B[44m":"",bgMagenta:c?"\x1B[45m":"",bgCyan:c?"\x1B[46m":"",bgWhite:c?"\x1B[47m":"",bgGray:c?"\x1B[100m":"",bgLightRed:c?"\x1B[101m":"",bgLightGreen:c?"\x1B[102m":"",bgLightYellow:c?"\x1B[103m":"",bgLightBlue:c?"\x1B[104m":"",bgLightMagenta:c?"\x1B[105m":"",bgLightCyan:c?"\x1B[106m":"",bgLightGray:c?"\x1B[47m":"",bold:c?"\x1B[1m":"",dim:c?"\x1B[2m":"",italic:c?"\x1B[3m":"",underline:c?"\x1B[4m":"",inverse:c?"\x1B[7m":"",hidden:c?"\x1B[8m":"",strikethrough:c?"\x1B[9m":""},T="\x1B[",at="\x1B]8;;",lt="\x1B]8;;\x07",Me=(e)=>String(e);function b(e,t,n){return Math.min(Math.max(Math.floor(e),t),n)}function l(e,t=g.reset){return(n)=>{if(!c)return String(n);return`${e}${String(n)}${t}`}}function ct(e){return e.replace(/\x1B\]8;;[^\x07]*(?:\x07|\x1B\\)/g,"").replace(/\x1B\]8;;(?:\x07|\x1B\\)/g,"")}function K(e){return ct(e).replace(/\x1B\[[0-?]*[ -/]*[@-~]/g,"")}var je=K;function Ee(e){return Array.from(K(e)).length}var U=l(g.black),V=l(g.red),x=l(g.green),J=l(g.yellow),Q=l(g.blue),X=l(g.magenta),w=l(g.cyan),Z=l(g.white),y=l(g.gray),ee=l(g.lightRed),te=l(g.lightGreen),ne=l(g.lightYellow),re=l(g.lightBlue),oe=l(g.lightMagenta),ie=l(g.lightCyan),j=l(g.lightGray),se=l(g.bgBlack),ae=l(g.bgRed),le=l(g.bgGreen),ce=l(g.bgYellow),ge=l(g.bgBlue),ue=l(g.bgMagenta),O=l(g.bgCyan),me=l(g.bgWhite),de=l(g.bgGray),pe=l(g.bgLightRed),fe=l(g.bgLightGreen),he=l(g.bgLightYellow),be=l(g.bgLightBlue),ye=l(g.bgLightMagenta),Ce=l(g.bgLightCyan),E=l(g.bgLightGray),h=l(g.bold),C=l(g.dim),d=l(g.italic),xe=l(g.underline),we=l(g.inverse),ke=l(g.hidden),Fe=l(g.strikethrough),$e=l(g.reset,"");function Te(e){return l(`${T}38;5;${b(e,0,255)}m`)}function Pe(e){return l(`${T}48;5;${b(e,0,255)}m`)}function Ae(e,t,n){return l(`${T}38;2;${b(e,0,255)};${b(t,0,255)};${b(n,0,255)}m`)}function We(e,t,n){return l(`${T}48;2;${b(e,0,255)};${b(t,0,255)};${b(n,0,255)}m`)}function Ye(e,t){let n=(o,i)=>{let s=String(o);if(!c)return s;return`${at}${i}\x07${s}${lt}`};if(typeof t==="string")return n(e,t);let r=String(e);return(o)=>n(o,r)}var gt={black:U,red:V,green:x,yellow:J,blue:Q,magenta:X,cyan:w,white:Z,gray:y,lightRed:ee,lightGreen:te,lightYellow:ne,lightBlue:re,lightMagenta:oe,lightCyan:ie,lightGray:j,bgBlack:se,bgRed:ae,bgGreen:le,bgYellow:ce,bgBlue:ge,bgMagenta:ue,bgCyan:O,bgWhite:me,bgGray:de,bgLightRed:pe,bgLightGreen:fe,bgLightYellow:he,bgLightBlue:be,bgLightMagenta:ye,bgLightCyan:Ce,bgLightGray:E,bold:h,dim:C,italic:d,underline:xe,inverse:we,hidden:ke,strikethrough:Fe,reset:$e};function Ne(e){return gt[e]??Me}function tn(e,t){if(typeof t==="function")return t(e);return Ne(t)(e)}function ut(){return c}var nn={black:U,red:V,green:x,yellow:J,blue:Q,magenta:X,cyan:w,white:Z,gray:y,lightRed:ee,lightGreen:te,lightYellow:ne,lightBlue:re,lightMagenta:oe,lightCyan:ie,lightGray:j,bgBlack:se,bgRed:ae,bgGreen:le,bgYellow:ce,bgBlue:ge,bgMagenta:ue,bgCyan:O,bgWhite:me,bgGray:de,bgLightRed:pe,bgLightGreen:fe,bgLightYellow:he,bgLightBlue:be,bgLightMagenta:ye,bgLightCyan:Ce,bgLightGray:E,bold:h,dim:C,italic:d,underline:xe,inverse:we,hidden:ke,strikethrough:Fe,reset:$e,ansi256:Te,ansi256Bg:Pe,trueColor:Ae,trueColorBg:We,link:Ye,stripColors:je},rn={black:U,red:V,green:x,yellow:J,blue:Q,magenta:X,cyan:w,white:Z,gray:y,lightRed:ee,lightGreen:te,lightYellow:ne,lightBlue:re,lightMagenta:oe,lightCyan:ie,lightGray:j,bgBlack:se,bgRed:ae,bgGreen:le,bgYellow:ce,bgBlue:ge,bgMagenta:ue,bgCyan:O,bgWhite:me,bgGray:de,bgLightRed:pe,bgLightGreen:fe,bgLightYellow:he,bgLightBlue:be,bgLightMagenta:ye,bgLightCyan:Ce,bgLightGray:E,bold:h,dim:C,italic:d,underline:xe,inverse:we,hidden:ke,strikethrough:Fe,reset:$e,ansi256:Te,ansi256Bg:Pe,trueColor:Ae,trueColorBg:We,link:Ye,stripColors:je,grey:y,lightGrey:j,bgLightGrey:E,supportsColor:ut};function mt(e,t,n,r){let o=Ee(e);if(o>=t)return e;let i=r[0]||" ",s=t-o;if(n==="right")return`${i.repeat(s)}${e}`;if(n==="center"){let a=Math.floor(s/2),u=s-a;return`${i.repeat(a)}${e}${i.repeat(u)}`}return`${e}${i.repeat(s)}`}function P(e){return Math.max(0,...e.map(Ee))}function A(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??P(r),s=o?.align??n,a=o?.padChar??" ";return r.map((u)=>mt(u,Math.max(0,i),s,a)).join(`
6
6
  `)}function on(e,t){return A(e,t,"left")}function sn(e,t){let n=String(e).split(/\r?\n/);return A(e,t??process.stdout?.columns??P(n),"right")}function an(e,t){let n=String(e).split(/\r?\n/);return A(e,t??process.stdout?.columns??P(n),"center")}var dt={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 ln(e,t={}){let n=String(e).split(/\r?\n/),r=dt[t.borderStyle??"single"],o=Math.max(0,t.padding??1),i=Math.max(0,t.margin??0),s=t.align??"left",a=P(n),u=a+o*2,m=typeof t.borderColor==="function"?t.borderColor:t.borderColor?Ne(t.borderColor):Me,N=m((()=>{if(!t.title)return`${r.topLeft}${r.horizontal.repeat(u)}${r.topRight}`;let R=` ${K(String(t.title))} `.slice(0,u),z=r.horizontal.repeat(Math.max(0,u-R.length));return`${r.topLeft}${R}${z}${r.topRight}`})()),D=m(`${r.bottomLeft}${r.horizontal.repeat(u)}${r.bottomRight}`),Ue=n.map((S)=>{let R=A(S,{align:s,width:a}),z=`${" ".repeat(o)}${R}${" ".repeat(o)}`;return`${m(r.vertical)}${z}${m(r.vertical)}`}),Ve=" ".repeat(i);return[N,...Ue,D].map((S)=>`${Ve}${S}`).join(`
7
- `)}var cn=st(["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 De="0.73.1";async function bn(e,t){return new Promise((n)=>{if(t?.quiet===!1)console.log(),console.log(w(h("Stacks CLI"))+C(` v${De}`)),console.log();if(p.info(`Running ${L(d(h(` ${e} `)))}`),t?.showPerformance===!1||t?.quiet)return n(0);return n(performance.now())})}function yn(e,t,n){let r={type:"success",useSeconds:!0,...t};return r.message=t?.message||e,new Promise((o)=>{if(n)return ft(n),o(Be.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(Be.Success);if(n)p.error(`[${i.toFixed(2)}${r.useSeconds?"s":"ms"}] Failed`);else if(r.type==="info")p.info(`${C(y(`[${i.toFixed(2)}${r.useSeconds?"s":"ms"}]`))} ${r.message??"Complete"}`);else p.success(`${C(y(h(`[${i.toFixed(2)}${r.useSeconds?"s":"ms"}]`)))} ${h(x(r.message??"Complete"))}`)}else if(r?.type==="info")p.info(e);else if(r?.type==="success"&&r?.quiet!==!0)p.success(e);p.flush().catch(()=>{}).then(()=>o(Be.Success))})}import W from"process";function ze(e){if(!e)return!1;return e.startsWith("--")}function ht(e){return e.startsWith("-")&&!ze(e)}function Le(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 bt(e,t,n,r){let[o,i]=e.slice(2).split("=");if(i!==void 0)r[o]=Le(i);else if(n+1<t.length&&!t[n+1]?.startsWith("-"))r[o]=t[n+1],n++;else r[o]=!0;return n}function yt(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 s=0;s<o.length;s++)r[o[s]]=Le(i);else for(let s=0;s<o.length;s++)if(n+1<t.length&&s===o.length-1&&!t[n+1]?.startsWith("-"))r[o[s]]=Le(t[n+1]),n++;else r[o[s]]=!0;return n}function Ct(e){if(e===void 0)e=W.argv.slice(2);let t=[],n={};for(let r=0;r<e.length;r++){let o=e[r];if(!o)continue;if(ze(o))r=bt(o,e,r,n);else if(ht(o))r=yt(o,e,r,n);else t.push(o)}return{args:t,options:n}}function kn(e){if(e===void 0)e=W.argv.slice(2);return Ct(e).args}function Fn(e){e=e||{};let t={dryRun:!1,quiet:!1,verbose:!1},n=W.argv.slice(2);for(let r=0;r<n.length;r++){let o=n[r];if(o?.startsWith("--")){let s=o.substring(2).replace(/-([a-z])/gi,(a)=>a[1]?a[1].toUpperCase():"");if(r+1<n.length&&!n?.[r+1]?.startsWith("--"))if(n?.[r+1]==="true"||n?.[r+1]==="false")e[s]=n[r+1]==="true",r++;else e[s]=n[r+1],r++;else e[s]=!0}}if(Object.keys(e).length===0)return{};return{...t,...e}}function xt(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 Object.entries(e).filter(([t,n])=>t!=="--"&&t!=="_"&&n!==!1&&n!==void 0&&n!==null).map(([t,n])=>{if(n===!0)return`--${t}`;return`--${t} ${n}`}).join(" ");return xt(W.argv.slice(2))}import f from"process";import{createInterface as wt}from"readline";var On=f.stdin.destroy;f.stdin.destroy=function(e){if(e)this.emit("error",e);return this};f.on("SIGINT",()=>{console.log(`
8
- `),f.exit(130)});var k=null;function kt(){if(!k){let e=f.stdin.isTTY&&f.stdout.isTTY;if(k=wt({input:f.stdin,output:f.stdout,terminal:e}),e&&typeof f.stdin.setRawMode==="function")k.on("SIGINT",()=>{f.emit("SIGINT")});k.once("close",()=>{k=null})}return k}var Y=Symbol("stdin-eof");function qe(e){return new Promise((t)=>{let n=kt(),r=!1,o=(s)=>{if(r)return;r=!0,n.off("close",i),t(s)},i=()=>o(Y);n.once("close",i);try{n.question(e,o)}catch{o(Y)}})}async function O(e){let t=await qe(e);return t===Y?"":t}function _e(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 vn(e){let t=typeof e==="string"?{message:e}:e,n=t.initial??!1,r=n?" (Y/n) ":" (y/N) ",o=await qe(`${t.message}${r}`);if(o===Y)return null;return _e(o,n)}async function Ft(e){let t=typeof e==="string"?{message:e}:e,n=t.initial??!1,r=n?" (Y/n) ":" (y/N) ",o=await O(`${t.message}${r}`);return _e(o,n)}async function $t(e){let t=typeof e==="string"?{message:e}:e,n=t.placeholder||t.initial||"",r=n?` (${n}) `:" ";return(await O(`${t.message}${r}`)).trim()||t.initial||""}async function Bt(e){console.log(e.message),e.choices.forEach((o,i)=>{let s=i===(e.initial??0)?">":" ";console.log(`${s} ${i+1}. ${o.label}`)});let t=await O("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 Lt(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 O("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 Ot(e){return(await O(`${(typeof e==="string"?{message:e}:e).message} `)).trim()}var Sn={text:$t,confirm:Ft,select:Bt,multiselect:Lt,password:Ot};import{handleError as vt}from"@stacksjs/error-handling";async function St(e,t){let n={...t,stdin:t?.stdin??"inherit",verbose:t?.verbose??!1};return await H(e,n)}async function Mn(e,t){let n={...t,stdio:[t?.stdin??"inherit","pipe","pipe"],verbose:t?.verbose??!1};return await H(e,n)}async function jn(e,t){let n={...t,stdio:[t?.stdin??"inherit","pipe","pipe"],verbose:t?.verbose??!1};return await Ie(e,n)}async function En(e,t){let n=[];for(let r of e){let o=await St(r,t);if(o.isErr)throw vt("Error during runCommands",o.error),o.error;n.push(o)}return n}import Rt from"process";var It=["SIGINT","SIGTERM","SIGHUP"],F=new Map,He=!1;function Gt(){if(He)return;He=!0;for(let e of It)Rt.on(e,async()=>{for(let[t,n]of F)try{await n()}catch(r){console.error(`[signals] cleanup '${t}' threw:`,r)}})}function An(e,t){return Gt(),F.set(e,t),()=>{if(F.get(e)===t)F.delete(e)}}function Wn(e){F.delete(e)}function Yn(){return[...F.keys()]}var Ke=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],v=process.stdout.isTTY&&!process.env.CI;function Mt(e){let t=e||"",n=0,r=null,o=!1,i=()=>{if(v)process.stdout.write("\r\x1B[K")},s=()=>{if(!v)return;i();let a=Ke[n];process.stdout.write(`${a} ${t}`),n=(n+1)%Ke.length};return{start(a){if(a)t=a;if(o)return;if(o=!0,v)s(),r=setInterval(s,80);else if(t)console.log(` ${t}`)},stop(a){if(o=!1,r)clearInterval(r),r=null;if(i(),a)console.log(a)},update(a){if(t=a,!v&&o)console.log(` ${a}`)},succeed(a){let u=a||t;if(o=!1,r)clearInterval(r),r=null;i(),console.log(`\u2713 ${u}`)},fail(a){let u=a||t;if(o=!1,r)clearInterval(r),r=null;i(),console.error(`\u2717 ${u}`)},get text(){return t},set text(a){if(t=a,v&&o)s()},get isSpinning(){return o}}}async function Dn(e,t,n){let r=Mt(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}}export{Wt as CLI,A as align,Te as ansi256,Pe as ansi256Bg,nt as applyAliases,se as bgBlack,ge as bgBlue,L as bgCyan,de as bgGray,le as bgGreen,be as bgLightBlue,Ce as bgLightCyan,E as bgLightGray,fe as bgLightGreen,ye as bgLightMagenta,pe as bgLightRed,he as bgLightYellow,ue as bgMagenta,ae as bgRed,me as bgWhite,ce as bgYellow,U as black,Q as blue,h as bold,ln as box,xt as buddyOptions,an as centerAlign,Nt as cli,tn as colorize,nn as colors,Ft as confirm,vn as confirmOrNull,w as cyan,Ht as defineCommand,Kt as defineCommands,C as dim,et as discoverCommandFiles,H as exec,Ie as execSync,Ne as getColor,y as gray,x as green,ke as hidden,Et as installPackage,Tt as installStack,bn as intro,we as inverse,d as italic,rn as kolorist,on as leftAlign,re as lightBlue,ie as lightCyan,j as lightGray,te as lightGreen,oe as lightMagenta,ee as lightRed,ne as lightYellow,Ye as link,Yn as listSignalHandlers,Re as loadCommandRegistry,_t as loadCommands,p as log,X as magenta,Lt as multiselect,Wn as offSignal,An as onSignal,Yt as onUnknownSubcommand,yn as outro,kn as parseArgs,Ct as parseArgv,Fn as parseOptions,Ot as password,Sn as prompts,cn as quotes,V as red,$e as reset,tt as resolveCommands,sn as rightAlign,St as runCommand,jn as runCommandSync,En as runCommands,Mn as runProcess,Bt as select,Mt as spinner,Fe as strikethrough,K as stripAnsi,je as stripColors,$t as text,Ae as trueColor,We as trueColorBg,xe as underline,Z as white,Dn as withSpinner,J as yellow};
7
+ `)}var cn=st(["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 De="0.73.3";async function bn(e,t){return new Promise((n)=>{if(t?.quiet===!1)console.log(),console.log(w(h("Stacks CLI"))+C(` v${De}`)),console.log();if(p.info(`Running ${O(d(h(` ${e} `)))}`),t?.showPerformance===!1||t?.quiet)return n(0);return n(performance.now())})}function yn(e,t,n){let r={type:"success",useSeconds:!0,...t};return r.message=t?.message||e,new Promise((o)=>{if(n)return ft(n),o(Be.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(Be.Success);if(n)p.error(`[${i.toFixed(2)}${r.useSeconds?"s":"ms"}] Failed`);else if(r.type==="info")p.info(`${C(y(`[${i.toFixed(2)}${r.useSeconds?"s":"ms"}]`))} ${r.message??"Complete"}`);else p.success(`${C(y(h(`[${i.toFixed(2)}${r.useSeconds?"s":"ms"}]`)))} ${h(x(r.message??"Complete"))}`)}else if(r?.type==="info")p.info(e);else if(r?.type==="success"&&r?.quiet!==!0)p.success(e);p.flush().catch(()=>{}).then(()=>o(Be.Success))})}import W from"process";function ze(e){if(!e)return!1;return e.startsWith("--")}function ht(e){return e.startsWith("-")&&!ze(e)}function Oe(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 bt(e,t,n,r){let[o,i]=e.slice(2).split("=");if(i!==void 0)r[o]=Oe(i);else if(n+1<t.length&&!t[n+1]?.startsWith("-"))r[o]=t[n+1],n++;else r[o]=!0;return n}function yt(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 s=0;s<o.length;s++)r[o[s]]=Oe(i);else for(let s=0;s<o.length;s++)if(n+1<t.length&&s===o.length-1&&!t[n+1]?.startsWith("-"))r[o[s]]=Oe(t[n+1]),n++;else r[o[s]]=!0;return n}function Ct(e){if(e===void 0)e=W.argv.slice(2);let t=[],n={};for(let r=0;r<e.length;r++){let o=e[r];if(!o)continue;if(ze(o))r=bt(o,e,r,n);else if(ht(o))r=yt(o,e,r,n);else t.push(o)}return{args:t,options:n}}function kn(e){if(e===void 0)e=W.argv.slice(2);return Ct(e).args}function Fn(e){e=e||{};let t={dryRun:!1,quiet:!1,verbose:!1},n=W.argv.slice(2);for(let r=0;r<n.length;r++){let o=n[r];if(o?.startsWith("--")){let s=o.substring(2).replace(/-([a-z])/gi,(a)=>a[1]?a[1].toUpperCase():"");if(r+1<n.length&&!n?.[r+1]?.startsWith("--"))if(n?.[r+1]==="true"||n?.[r+1]==="false")e[s]=n[r+1]==="true",r++;else e[s]=n[r+1],r++;else e[s]=!0}}if(Object.keys(e).length===0)return{};return{...t,...e}}function xt(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 Object.entries(e).filter(([t,n])=>t!=="--"&&t!=="_"&&n!==!1&&n!==void 0&&n!==null).map(([t,n])=>{if(n===!0)return`--${t}`;return`--${t} ${n}`}).join(" ");return xt(W.argv.slice(2))}import f from"process";import{createInterface as wt}from"readline";var Ln=f.stdin.destroy;f.stdin.destroy=function(e){if(e)this.emit("error",e);return this};f.on("SIGINT",()=>{console.log(`
8
+ `),f.exit(130)});var k=null;function kt(){if(!k){let e=f.stdin.isTTY&&f.stdout.isTTY;if(k=wt({input:f.stdin,output:f.stdout,terminal:e}),e&&typeof f.stdin.setRawMode==="function")k.on("SIGINT",()=>{f.emit("SIGINT")});k.once("close",()=>{k=null})}return k}var Y=Symbol("stdin-eof");function qe(e){return new Promise((t)=>{let n=kt(),r=!1,o=(s)=>{if(r)return;r=!0,n.off("close",i),t(s)},i=()=>o(Y);n.once("close",i);try{n.question(e,o)}catch{o(Y)}})}async function L(e){let t=await qe(e);return t===Y?"":t}function _e(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 vn(e){let t=typeof e==="string"?{message:e}:e,n=t.initial??!1,r=n?" (Y/n) ":" (y/N) ",o=await qe(`${t.message}${r}`);if(o===Y)return null;return _e(o,n)}async function Ft(e){let t=typeof e==="string"?{message:e}:e,n=t.initial??!1,r=n?" (Y/n) ":" (y/N) ",o=await L(`${t.message}${r}`);return _e(o,n)}async function $t(e){let t=typeof e==="string"?{message:e}:e,n=t.placeholder||t.initial||"",r=n?` (${n}) `:" ";return(await L(`${t.message}${r}`)).trim()||t.initial||""}async function Bt(e){console.log(e.message),e.choices.forEach((o,i)=>{let s=i===(e.initial??0)?">":" ";console.log(`${s} ${i+1}. ${o.label}`)});let t=await L("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 Ot(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 L("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 Lt(e){return(await L(`${(typeof e==="string"?{message:e}:e).message} `)).trim()}var Sn={text:$t,confirm:Ft,select:Bt,multiselect:Ot,password:Lt};import{handleError as vt}from"@stacksjs/error-handling";async function St(e,t){let n={...t,stdin:t?.stdin??"inherit",verbose:t?.verbose??!1};return await H(e,n)}async function Mn(e,t){let n={...t,stdio:[t?.stdin??"inherit","pipe","pipe"],verbose:t?.verbose??!1};return await H(e,n)}async function jn(e,t){let n={...t,stdio:[t?.stdin??"inherit","pipe","pipe"],verbose:t?.verbose??!1};return await Ie(e,n)}async function En(e,t){let n=[];for(let r of e){let o=await St(r,t);if(o.isErr)throw vt("Error during runCommands",o.error),o.error;n.push(o)}return n}import Rt from"process";var It=["SIGINT","SIGTERM","SIGHUP"],F=new Map,He=!1;function Gt(){if(He)return;He=!0;for(let e of It)Rt.on(e,async()=>{for(let[t,n]of F)try{await n()}catch(r){console.error(`[signals] cleanup '${t}' threw:`,r)}})}function An(e,t){return Gt(),F.set(e,t),()=>{if(F.get(e)===t)F.delete(e)}}function Wn(e){F.delete(e)}function Yn(){return[...F.keys()]}var Ke=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],v=process.stdout.isTTY&&!process.env.CI;function Mt(e){let t=e||"",n=0,r=null,o=!1,i=()=>{if(v)process.stdout.write("\r\x1B[K")},s=()=>{if(!v)return;i();let a=Ke[n];process.stdout.write(`${a} ${t}`),n=(n+1)%Ke.length};return{start(a){if(a)t=a;if(o)return;if(o=!0,v)s(),r=setInterval(s,80);else if(t)console.log(` ${t}`)},stop(a){if(o=!1,r)clearInterval(r),r=null;if(i(),a)console.log(a)},update(a){if(t=a,!v&&o)console.log(` ${a}`)},succeed(a){let u=a||t;if(o=!1,r)clearInterval(r),r=null;i(),console.log(`\u2713 ${u}`)},fail(a){let u=a||t;if(o=!1,r)clearInterval(r),r=null;i(),console.error(`\u2717 ${u}`)},get text(){return t},set text(a){if(t=a,v&&o)s()},get isSpinning(){return o}}}async function Dn(e,t,n){let r=Mt(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}}export{Wt as CLI,A as align,Te as ansi256,Pe as ansi256Bg,nt as applyAliases,se as bgBlack,ge as bgBlue,O as bgCyan,de as bgGray,le as bgGreen,be as bgLightBlue,Ce as bgLightCyan,E as bgLightGray,fe as bgLightGreen,ye as bgLightMagenta,pe as bgLightRed,he as bgLightYellow,ue as bgMagenta,ae as bgRed,me as bgWhite,ce as bgYellow,U as black,Q as blue,h as bold,ln as box,xt as buddyOptions,an as centerAlign,Nt as cli,tn as colorize,nn as colors,Ft as confirm,vn as confirmOrNull,w as cyan,Ht as defineCommand,Kt as defineCommands,C as dim,et as discoverCommandFiles,H as exec,Ie as execSync,Ne as getColor,y as gray,x as green,ke as hidden,Et as installPackage,Tt as installStack,bn as intro,we as inverse,d as italic,rn as kolorist,on as leftAlign,re as lightBlue,ie as lightCyan,j as lightGray,te as lightGreen,oe as lightMagenta,ee as lightRed,ne as lightYellow,Ye as link,Yn as listSignalHandlers,Re as loadCommandRegistry,_t as loadCommands,p as log,X as magenta,Ot as multiselect,Wn as offSignal,An as onSignal,Yt as onUnknownSubcommand,yn as outro,kn as parseArgs,Ct as parseArgv,Fn as parseOptions,Lt as password,Sn as prompts,cn as quotes,V as red,$e as reset,tt as resolveCommands,sn as rightAlign,St as runCommand,jn as runCommandSync,En as runCommands,Mn as runProcess,Bt as select,Mt as spinner,Fe as strikethrough,K as stripAnsi,je as stripColors,$t as text,Ae as trueColor,We as trueColorBg,xe as underline,Z as white,Dn as withSpinner,J as yellow};
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { CollectionOperations } from '@stacksjs/collections';
1
2
  export declare function stripAnsi(text: string): string;
2
3
  export declare function ansi256(code: number): ColorFn;
3
4
  export declare function ansi256Bg(code: number): ColorFn;
@@ -58,17 +59,27 @@ export declare const reset: ColorFn;
58
59
  export declare const colors: ColorsApi;
59
60
  export declare const kolorist: KoloristApi;
60
61
  /*
61
- * Inferred, not `any`.
62
+ * Stated, not inferred, and certainly not `any`.
62
63
  *
63
- * This was annotated `: any`, which threw away the `Collection<string>` that
64
- * `collect()` already returns. Nothing downstream could see a quote was a
64
+ * This was annotated `: any`, which threw away the `CollectionOperations<string>`
65
+ * that `collect()` already returns. Nothing downstream could see a quote was a
65
66
  * string: `quotes.random(1).first()` typed as `any` and got interpolated into
66
67
  * output unchecked, and `app/Commands/Inspire.ts` wrote
67
68
  * `.forEach((quote: string, index: number) => …)` to get names back - which is
68
69
  * an assertion over an untyped value, not a check, and would have been
69
70
  * accepted just the same if `random()` returned objects.
71
+ *
72
+ * Dropping the annotation fixed that inside this repo and broke it outside.
73
+ * `bun-plugin-dtsx` could not follow the inferred type across the
74
+ * `@stacksjs/collections` re-export and emitted `export declare const quotes:
75
+ * unknown`, so a scaffolded app - which resolves this package from its
76
+ * PUBLISHED dist, not from source - failed its own `buddy typecheck` on the
77
+ * `inspire` command the scaffold ships. In this repo the same code typechecks,
78
+ * because here the import resolves to the source above. That is why the type
79
+ * is written out: it is the one form that survives the package boundary
80
+ * (stacksjs/stacks#2389).
70
81
  */
71
- export declare const quotes: unknown;
82
+ export declare const quotes: CollectionOperations<string>;
72
83
  declare interface AlignOptions {
73
84
  width?: number
74
85
  align?: Alignment
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/cli",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.73.1",
5
+ "version": "0.73.3",
6
6
  "description": "TypeScript framework for CLI artisans. Build beautiful console apps with ease.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -72,14 +72,14 @@
72
72
  "@stacksjs/clapp": "^0.2.12"
73
73
  },
74
74
  "devDependencies": {
75
- "@stacksjs/collections": "0.73.1",
76
- "@stacksjs/config": "0.73.1",
75
+ "@stacksjs/collections": "0.73.3",
76
+ "@stacksjs/config": "0.73.3",
77
77
  "better-dx": "^0.2.24",
78
- "@stacksjs/error-handling": "0.73.1",
79
- "@stacksjs/logging": "0.73.1",
80
- "@stacksjs/path": "0.73.1",
81
- "@stacksjs/types": "0.73.1",
82
- "@stacksjs/utils": "0.73.1",
83
- "@stacksjs/validation": "0.73.1"
78
+ "@stacksjs/error-handling": "0.73.3",
79
+ "@stacksjs/logging": "0.73.3",
80
+ "@stacksjs/path": "0.73.3",
81
+ "@stacksjs/types": "0.73.3",
82
+ "@stacksjs/utils": "0.73.3",
83
+ "@stacksjs/validation": "0.73.3"
84
84
  }
85
85
  }