infra-kit 0.7.12 → 0.8.0

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.
@@ -1,4 +1,4 @@
1
- import{a as Ue,b as L,c as M,d as Fe,e as H,k as Me,l as He,m as Be,p as je}from"./chunk-T2WBH6YO.js";import{$ as Ce,K as T,L as Ae,R as ne,U as C,V as U,W as Re,X as Ee,Y as F,Z as Te,_ as $,aa as $e,ba as Le,ca as Ne,da as Ie,ea as Oe,fa as _e}from"./chunk-5FYZAIFC.js";import{c as te,k as re,o as ke,r as xe}from"./chunk-6OFUVD7F.js";import"./chunk-MFAFQVTW.js";import"./chunk-HHWP3YXW.js";import{d as Pe,f as ee,p as De}from"./chunk-75URROMU.js";import{a as N,b as We}from"./chunk-VDBJ73LS.js";import{Command as Fn}from"commander";import P from"node:process";import{pathToFileURL as Mn}from"node:url";import*as Ve from"node:path";import qt from"node:process";var Jt=r=>({pane:{surfaces:[{type:"terminal",command:r}]}}),ie=(r,e)=>{if(r.length===1)return Jt(r[0]);let t=Math.ceil(r.length/2),n=r.slice(0,t),i=r.slice(t);return{direction:e%2===0?"horizontal":"vertical",split:Math.round(t/r.length*100)/100,children:[ie(n,e+1),ie(i,e+1)]}},Ge=r=>{if(r.length===0)throw new Error("buildCmuxLayout: at least one command is required");return ie(r,0)};var zt=(r,e)=>r.map(({app:t,targets:n})=>`pnpm exec infra-kit dev ${n&&n.length>0?`--target=${n.join(",")}`:`--app=${t}`}${e?" --watch":""}`),Yt=r=>{let e=new Map;for(let t of Object.keys(r?.apps??{})){let n=t.split("/")[0];n===void 0||n==="*"||e.set(n,[...e.get(n)??[],t])}return e},Xt=(r,e)=>{let t=U(r);return e?t.filter(n=>e.includes(n.name)):t},Qt=(r,e)=>{T.info(`\u{1F9E9} Opened cmux dev workspace ${e} with ${r.length} pane(s):`);for(let t of r)T.info(` \u2022 ${t.name} (infra-kit dev --app=${t.name})`)},Zt=r=>{H({onSignal:async e=>{T.info(`
1
+ import{a as Ue,b as L,c as M,d as Fe,e as H,k as Me,l as He,m as Be,p as je}from"./chunk-AOWMCNYY.js";import{$ as Re,P as T,Q as Ae,W as ne,Z as C,_ as U,aa as Ee,ba as F,ca as Te,da as $,ea as Ce,fa as $e,ga as Le,ha as Ne,ia as Ie,ja as Oe,ka as _e}from"./chunk-GCX3HDDL.js";import{c as te,k as re,o as ke,r as xe}from"./chunk-6OFUVD7F.js";import"./chunk-MFAFQVTW.js";import"./chunk-HHWP3YXW.js";import{d as Pe,f as ee,p as De}from"./chunk-75URROMU.js";import{a as N,b as We}from"./chunk-VDBJ73LS.js";import{Command as Fn}from"commander";import P from"node:process";import{pathToFileURL as Mn}from"node:url";import*as Ve from"node:path";import qt from"node:process";var Jt=r=>({pane:{surfaces:[{type:"terminal",command:r}]}}),ie=(r,e)=>{if(r.length===1)return Jt(r[0]);let t=Math.ceil(r.length/2),n=r.slice(0,t),i=r.slice(t);return{direction:e%2===0?"horizontal":"vertical",split:Math.round(t/r.length*100)/100,children:[ie(n,e+1),ie(i,e+1)]}},Ge=r=>{if(r.length===0)throw new Error("buildCmuxLayout: at least one command is required");return ie(r,0)};var zt=(r,e)=>r.map(({app:t,targets:n})=>`pnpm exec infra-kit dev ${n&&n.length>0?`--target=${n.join(",")}`:`--app=${t}`}${e?" --watch":""}`),Yt=r=>{let e=new Map;for(let t of Object.keys(r?.apps??{})){let n=t.split("/")[0];n===void 0||n==="*"||e.set(n,[...e.get(n)??[],t])}return e},Xt=(r,e)=>{let t=U(r);return e?t.filter(n=>e.includes(n.name)):t},Qt=(r,e)=>{T.info(`\u{1F9E9} Opened cmux dev workspace ${e} with ${r.length} pane(s):`);for(let t of r)T.info(` \u2022 ${t.name} (infra-kit dev --app=${t.name})`)},Zt=r=>{H({onSignal:async e=>{T.info(`
2
2
  Received ${e}, closing cmux dev workspace ${r}...`),await Be(r)}})},Ke=async r=>{let e=C(qt.cwd()),t=Xt(e,F(r.include));if(t.length===0){T.warn("No API apps found to run");return}let n=Yt(r.presetDef),i=zt(t.map(u=>({app:u.name,targets:n.get(u.name)})),r.watch??!1),s=Ge(i),o=`${Ve.basename(e)} dev`,a=await He({cwd:e,title:o,layout:s});Qt(t,a),Zt(a);let l=setInterval(()=>{l.refresh()},2**30);await new Promise(()=>{})};import se from"node:process";var oe=r=>{try{se.stderr.write(r)}catch{}},I=(r,e,t=!0)=>{let n=e instanceof Error?`${e.message}
3
3
  ${e.stack??"(no stack)"}`:String(e);return`
4
4
  \u26A0\uFE0F ${r}: ${n}
@@ -34,5 +34,5 @@ Reinstalling restarts it (still the only step that needs root):
34
34
  `);let l=n(()=>{e(),t(we)},i);a.shutdown().finally(()=>{l(),t(we)}).catch(()=>{})}},Vn=["SIGINT","SIGTERM"],Kn=({forceReap:r=L,exit:e=i=>{P.exit(i)},register:t=(i,s)=>{P.on(i,s)},unregister:n=(i,s)=>{P.off(i,s)}}={})=>{let i=new Map;for(let s of Vn){let o=()=>{Vt(r,e,Fe(s))};i.set(s,o),t(s,o)}return{remove:()=>{for(let[s,o]of i)n(s,o)}}},be=async r=>{let e=jn(r);if(e.cmux){if(await Me()){await Ke(e);return}P.stdout.write(`cmux not available; falling back to single-terminal dev
35
35
  `)}let t=null,n=Wn(),i=Gn({getRunner:()=>t,setTimer:n}),s=ot({onDeath:(l,u)=>{i(`stdio unwritable: ${l} ${u.code}`)}}),o=Kn();try{t=await Bt({...e,onExitRequest:l=>{P.exit(l)}})}finally{o.remove()}let a=t;Je({onFault:(l,u)=>{a.reportFault(I(l,u))},isTerminalDead:s.isDead,fileFault:(l,u)=>{a.fileFault(I(l,u,!1))},onFatal:i}),H({onSignal:async l=>{le(`
36
36
  Received ${l}, shutting down dev-server...
37
- `),await a.shutdown()},describeStall:()=>a.shutdownStage,fileReport:l=>{a.fileFault(l)},setTimer:n})},Jn=(r,e,t)=>!r.preset&&!r.app&&!r.self&&!r.cmux&&!r.watch&&!r.verbose&&!r.routes&&e&&!t,qn=(r,e)=>({watch:r.watch,cmux:r.cmux,include:r.include??null,preset:r.preset,presetDef:r.presetDef,self:!1,verbose:!1,routes:!1,uiHealth:e.uiHealth??!0}),Is=async(r,e,t)=>{if(Jn(r,e,t)){let{runDevWizard:n}=await import("./dev-wizard-run-DRBMPH2O.js"),i=Promise.all([import("./persistent-ink-dev-ui-P65EJCC6.js"),import("./safe-stderr-ECYA6DRR.js")]).catch(()=>{}),s;try{s=await n()}catch(o){if(je(o))return;throw o}if(s==null)return;await i,await be({...qn(s,r),tty:e,json:t});return}await be({...Wt(r),tty:e,json:t})},zn=async r=>{let e=new Fn;e.name("infra-kit-dev-server").description("Run local dev servers for the apps in a named devServersPresets preset (or all apps)").argument("[preset]","Named preset from devServersPresets (omit to run every app)").option("-w, --watch","Rebuild and restart on file save").option("--app <names>","Further narrow to these app folder names (comma-separated)").option("--cmux","Run each app in its own cmux pane (one workspace, N panes; falls back to single terminal if cmux is unavailable)").option("--self","Run only the app of the current directory (infer from cwd; use inside apps/<app>/\u2026)").option("-V, --verbose","Print full boot narration (default: quiet; full detail always in the session log)").option("--routes","Print each app\u2019s registered METHOD /path routes at startup (default: off)"),e.parse(r),await be(Wt({...e.opts(),preset:e.args[0]}))};import.meta.url===Mn(P.argv[1]??"").href&&zn(P.argv).catch(r=>{console.error(r instanceof Error?r.message:String(r)),P.exit(1)});export{Gn as createFatalHandler,Wn as createSharedDeadlineTimer,Kn as installBootSignalGuard,be as runDevServer,Is as runDevServerCli,Jn as shouldRunWizard,Wt as toDevServerOptions};
37
+ `),await a.shutdown()},describeStall:()=>a.shutdownStage,fileReport:l=>{a.fileFault(l)},setTimer:n})},Jn=(r,e,t)=>!r.preset&&!r.app&&!r.self&&!r.cmux&&!r.watch&&!r.verbose&&!r.routes&&e&&!t,qn=(r,e)=>({watch:r.watch,cmux:r.cmux,include:r.include??null,preset:r.preset,presetDef:r.presetDef,self:!1,verbose:!1,routes:!1,uiHealth:e.uiHealth??!0}),Is=async(r,e,t)=>{if(Jn(r,e,t)){let{runDevWizard:n}=await import("./dev-wizard-run-RPZOX53B.js"),i=Promise.all([import("./persistent-ink-dev-ui-P65EJCC6.js"),import("./safe-stderr-ECYA6DRR.js")]).catch(()=>{}),s;try{s=await n()}catch(o){if(je(o))return;throw o}if(s==null)return;await i,await be({...qn(s,r),tty:e,json:t});return}await be({...Wt(r),tty:e,json:t})},zn=async r=>{let e=new Fn;e.name("infra-kit-dev-server").description("Run local dev servers for the apps in a named devServersPresets preset (or all apps)").argument("[preset]","Named preset from devServersPresets (omit to run every app)").option("-w, --watch","Rebuild and restart on file save").option("--app <names>","Further narrow to these app folder names (comma-separated)").option("--cmux","Run each app in its own cmux pane (one workspace, N panes; falls back to single terminal if cmux is unavailable)").option("--self","Run only the app of the current directory (infer from cwd; use inside apps/<app>/\u2026)").option("-V, --verbose","Print full boot narration (default: quiet; full detail always in the session log)").option("--routes","Print each app\u2019s registered METHOD /path routes at startup (default: off)"),e.parse(r),await be(Wt({...e.opts(),preset:e.args[0]}))};import.meta.url===Mn(P.argv[1]??"").href&&zn(P.argv).catch(r=>{console.error(r instanceof Error?r.message:String(r)),P.exit(1)});export{Gn as createFatalHandler,Wn as createSharedDeadlineTimer,Kn as installBootSignalGuard,be as runDevServer,Is as runDevServerCli,Jn as shouldRunWizard,Wt as toDevServerOptions};
38
38
  //# sourceMappingURL=dev-server.js.map