@flisk-sh/flisk 1.3.201 → 1.3.204

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.
Files changed (30) hide show
  1. package/cli/dist/cli.js +9 -0
  2. package/cli/dist/commands/doctor.js +22 -0
  3. package/cli/dist/commands/open.js +9 -1
  4. package/cli/dist/utils/cold-preflight.js +14 -0
  5. package/cli/dist/utils/colima.js +144 -0
  6. package/cli/dist/utils/doctor-fix.js +78 -1
  7. package/cli/dist/utils/stack-progress.js +5 -4
  8. package/cli/dist-bundle/{chunk-M6S25PIS.js → chunk-BS6G2SLM.js} +1 -1
  9. package/cli/dist-bundle/{chunk-LYOSHFYU.js → chunk-CBFVK3TF.js} +1 -1
  10. package/cli/dist-bundle/{chunk-5ZSZ4WCI.js → chunk-EPBYRJE3.js} +1 -1
  11. package/cli/dist-bundle/chunk-GD5676UE.js +52 -0
  12. package/cli/dist-bundle/chunk-MKJNQTIN.js +2 -0
  13. package/cli/dist-bundle/{chunk-S5EXKK7H.js → chunk-QSPFSZCS.js} +2 -2
  14. package/cli/dist-bundle/{chunk-NC6KOYDN.js → chunk-RFHMXJTK.js} +1 -1
  15. package/cli/dist-bundle/{chunk-KXKBWLTE.js → chunk-WMF4AFAE.js} +1 -1
  16. package/cli/dist-bundle/{chunk-R67UHACQ.js → chunk-Z6UD7UZH.js} +1 -1
  17. package/cli/dist-bundle/chunk-ZVGY7COV.js +4 -0
  18. package/cli/dist-bundle/cli.js +80 -80
  19. package/cli/dist-bundle/cold-preflight-FXOZ5SR5.js +2 -0
  20. package/cli/dist-bundle/colima-4ID4BGHC.js +2 -0
  21. package/cli/dist-bundle/{open-SMKISRHH.js → open-UQ6DF3XN.js} +1 -1
  22. package/cli/dist-bundle/{project-WEC2GSR7.js → project-GTYHCCFG.js} +1 -1
  23. package/cli/dist-bundle/stack-progress-6GO2TCRH.js +2 -0
  24. package/cli/dist-bundle/{tilt-port-owner-67UVQJTX.js → tilt-port-owner-KLNX2ZI2.js} +1 -1
  25. package/cli/package.json +1 -1
  26. package/package.json +1 -1
  27. package/cli/dist-bundle/chunk-GCFNSFW7.js +0 -52
  28. package/cli/dist-bundle/chunk-GNNN2WCF.js +0 -4
  29. package/cli/dist-bundle/cold-preflight-6Z4RBFKV.js +0 -2
  30. package/cli/dist-bundle/stack-progress-UVREHNNB.js +0 -2
@@ -0,0 +1,2 @@
1
+ import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
+ import{A as d,B as e,C as f,D as g,E as h,F as i,G as j,x as a,y as b,z as c}from"./chunk-GD5676UE.js";import"./chunk-BS6G2SLM.js";import"./chunk-MKJNQTIN.js";import"./chunk-Z6UD7UZH.js";import"./chunk-EPBYRJE3.js";import"./chunk-WMF4AFAE.js";import"./chunk-42IVF3YT.js";import"./chunk-CBFVK3TF.js";import"./chunk-CF46CD6R.js";import"./chunk-6EA4DGCY.js";export{c as MACHINE_CHECK_IDS,a as RUNTIME_CHECK_IDS,b as SCAFFOLD_CHECK_IDS,h as assertMachineReadyOrExit,i as detectRuntimePrerequisites,g as formatColdPreflight,j as formatRuntimeNextSteps,d as nodeTooOld,e as requireVerifiedDockerVersions,f as runColdPreflight};
@@ -0,0 +1,2 @@
1
+ import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
+ import{a,b,c,d}from"./chunk-MKJNQTIN.js";import"./chunk-6EA4DGCY.js";export{b as checkColima,a as isColimaDocker,d as nativeLimaPath,c as planColimaRepair};
@@ -1,2 +1,2 @@
1
1
  import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{e as a,f as b,g as c,h as d,i as e,j as f}from"./chunk-GNNN2WCF.js";import"./chunk-DTIHDMED.js";import"./chunk-R67UHACQ.js";import"./chunk-5ZSZ4WCI.js";import"./chunk-LYOSHFYU.js";import"./chunk-CF46CD6R.js";import"./chunk-6EA4DGCY.js";export{d as findReadyFrontend,b as isFrontendReady,a as listFrontendTargets,f as openCommand,e as openFirstFrontend,c as pickReadyFrontend};
2
+ import{e as a,f as b,g as c,h as d,i as e,j as f}from"./chunk-ZVGY7COV.js";import"./chunk-DTIHDMED.js";import"./chunk-Z6UD7UZH.js";import"./chunk-EPBYRJE3.js";import"./chunk-CBFVK3TF.js";import"./chunk-CF46CD6R.js";import"./chunk-6EA4DGCY.js";export{d as findReadyFrontend,b as isFrontendReady,a as listFrontendTargets,f as openCommand,e as openFirstFrontend,c as pickReadyFrontend};
@@ -1,2 +1,2 @@
1
1
  import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{h as a,i as b,j as c,k as d}from"./chunk-S5EXKK7H.js";import"./chunk-KXKBWLTE.js";import"./chunk-42IVF3YT.js";import"./chunk-LYOSHFYU.js";import"./chunk-CF46CD6R.js";import"./chunk-6EA4DGCY.js";export{c as cloneProjectTemplate,a as enableDiscoveredStacks,d as projectCommand,b as templateTargetDir};
2
+ import{h as a,i as b,j as c,k as d}from"./chunk-QSPFSZCS.js";import"./chunk-WMF4AFAE.js";import"./chunk-42IVF3YT.js";import"./chunk-CBFVK3TF.js";import"./chunk-CF46CD6R.js";import"./chunk-6EA4DGCY.js";export{c as cloneProjectTemplate,a as enableDiscoveredStacks,d as projectCommand,b as templateTargetDir};
@@ -0,0 +1,2 @@
1
+ import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
+ import"./chunk-6EA4DGCY.js";import{execFile as m}from"node:child_process";var h=e=>new Promise(a=>{m("tilt",["get","uiresources","-o","json","--port",String(e)],{timeout:15e3,maxBuffer:16*1024*1024},(n,i)=>a(n?null:i))});async function $(e,a=h){let n=await a(e);if(!n)return;let i=[];try{i=JSON.parse(n).items??[]}catch{return}let t=[],d=[],l=0,c=0,f=0,p=0;for(let o of i){let r=o.metadata?.name??"unknown",u=o.status?.updateStatus??"",s=o.status?.runtimeStatus??"";if(u==="error"||s==="error"){p+=1,d.push({name:r,message:(o.status?.buildHistory?.[0]?.error??"the resource failed").replace(/\s+/g," ").slice(0,160)});continue}if(u==="ok"&&(s==="ok"||s==="not_applicable"||s==="")){l+=1;continue}if(u==="pending"||u===""){f+=1,t.push({name:r,state:s||"pending"});continue}c+=1,t.push({name:r,state:u})}return{ready:l,building:c,pending:f,failed:p,total:i.length,working:t,broken:d}}function b(e){let a=Math.floor(e.elapsed/60),n=Math.round(e.elapsed%60),i=a>0?`${a}m ${n}s`:`${n}s`,t=[`${e.ready}/${e.total} resources ready`,i];return e.building>0&&t.push(`${e.building} building`),e.pending>0&&t.push(`${e.pending} queued`),e.failed>0&&t.push(`${e.failed} failed`),t.join(" \xB7 ")}export{b as formatProgress,$ as readStackProgress};
@@ -1,2 +1,2 @@
1
1
  import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{a,b,c}from"./chunk-NC6KOYDN.js";import"./chunk-M6S25PIS.js";import"./chunk-5ZSZ4WCI.js";import"./chunk-LYOSHFYU.js";import"./chunk-CF46CD6R.js";import"./chunk-6EA4DGCY.js";export{c as classifyTiltPorts,a as findTiltPortOwner,b as isForeignTilt};
2
+ import{a,b,c}from"./chunk-RFHMXJTK.js";import"./chunk-BS6G2SLM.js";import"./chunk-EPBYRJE3.js";import"./chunk-CBFVK3TF.js";import"./chunk-CF46CD6R.js";import"./chunk-6EA4DGCY.js";export{c as classifyTiltPorts,a as findTiltPortOwner,b as isForeignTilt};
package/cli/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tdk-cli-internal",
3
3
  "private": true,
4
- "version": "1.3.201",
4
+ "version": "1.3.204",
5
5
  "description": "Flisk CLI — start services on your machine.",
6
6
  "keywords": [
7
7
  "flisk",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flisk-sh/flisk",
3
- "version": "1.3.201",
3
+ "version": "1.3.204",
4
4
  "description": "Flisk CLI — start services on your machine.",
5
5
  "homepage": "https://flisk.sh",
6
6
  "repository": {
@@ -1,52 +0,0 @@
1
- import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{a as ct,f as lt,g as z,j as vt,k as Dt,l as Tt,n as $t,o as he,p as ge,r as ke,s as Se,t as Nt,u as ye,v as Et}from"./chunk-R67UHACQ.js";import{i as ut,o as pt}from"./chunk-KXKBWLTE.js";import{c as dt}from"./chunk-42IVF3YT.js";import{f as R,g as ft,h as mt,i as ht,j as X,k as gt,l as kt,m as St,n as yt,o as xt,p as Y,q as Pt,s as wt,t as bt}from"./chunk-M6S25PIS.js";import{Aa as it,Ba as at,Ca as me,G as Ye,O as T,Ta as y,b,fa as Qe,h as I,ja as Ze,k as F,l as W,m as de,ma as et,na as pe,o as ue,oa as J,pa as tt,qa as st,s as h,t as ze,ua as fe,va as nt,wa as q,x as $,xa as rt,y as Xe,ya as ot}from"./chunk-LYOSHFYU.js";import{b as f}from"./chunk-CF46CD6R.js";import{execFileSync as ws}from"node:child_process";import{readFileSync as Tr}from"node:fs";import{join as $r}from"node:path";import{execFileSync as In,execSync as is}from"node:child_process";import{existsSync as v,readdirSync as Fn,readFileSync as M}from"node:fs";import{join as P,normalize as Me,relative as Le}from"node:path";import{Command as Mn}from"commander";import{existsSync as Ns}from"node:fs";var Q="docs/agent-hosts.md",xe=`WebContainers cannot run Flisk: there is no Docker daemon or Tilt. Run \`flisk up\` on a machine with Docker. See ${Q}.`,Ct=`Docker is not reachable from this Dev Container. Mount the host Docker socket (-v /var/run/docker.sock:/var/run/docker.sock) or add the docker-outside-of-docker feature to devcontainer.json, then retry. Docker-in-docker is not supported. See ${Q}.`;function Es(){return{env:process.env,versions:process.versions,platform:process.platform,fileExists:Ns}}function Rt(e=Es()){let{env:t,versions:s,platform:n,fileExists:r}=e;return s.webcontainer?{kind:"webcontainer",canUp:!1}:t.CODESPACES==="true"?{kind:"codespaces",canUp:!0}:t.REMOTE_CONTAINERS||r("/.dockerenv")&&t.DEVCONTAINER?{kind:"devcontainer",canUp:!0}:n==="win32"?{kind:"native-windows",canUp:t.TDK_ALLOW_NATIVE_WINDOWS==="1"}:n==="linux"&&t.WSL_DISTRO_NAME?{kind:"wsl2",canUp:!0}:{kind:"local",canUp:!0}}function Ot(e){return e==="devcontainer"||e==="codespaces"}function Z(e){return e.some(t=>Qe(t.config?.appType)||t.config?.appType==="frontend"||t.config?.appType==="worker")}import{existsSync as Cs,readFileSync as Rs}from"node:fs";import{join as Os,relative as _t,resolve as jt,sep as _s}from"node:path";var js=2,At=["services/*/*"];function It(e){return e.split(_s).filter(Boolean)}function As(e,t){let s=0,n=0,r=-1,o=0;for(;n<t.length;)if(s<e.length&&e[s]!=="*"&&(e[s]==="?"||e[s]===t[n]))s++,n++;else if(s<e.length&&e[s]==="*")r=s++,o=n;else if(r!==-1)s=r+1,n=++o;else return!1;for(;s<e.length&&e[s]==="*";)s++;return s===e.length}function Is(e,t){return e.length===t.length&&e.every((s,n)=>As(s,t[n]))}function Pe(e){let t=Os(e,".tdk",F);if(!Cs(t))return At;try{let s=JSON.parse(Rs(t,"utf-8"))?.discovery?.paths;if(Array.isArray(s)&&s.every(n=>typeof n=="string"))return s}catch{}return At}function ee(e,t,s){let n=It(_t(e,jt(e,t)));return s.some(r=>{let o=It(_t(e,jt(e,r)));for(let i=0;i<=js;i++){let a=n.length-i;if(a>0&&Is(o,n.slice(0,a)))return!0}return!1})}function Br(e,t,s,n){let r=Pe(e);if(ee(e,t,r))return{path:t};let o=`services/${s}/${n}`;return ee(e,o,r)?{path:o,adjustedFrom:t}:{path:t}}import{execFile as Fs}from"node:child_process";import{promisify as Ms}from"node:util";var Ls=Ms(Fs),Hs=1e4,Bs=5,Ft=10*6e4,Ws=3,Vs=200,Us=async e=>{let{stdout:t,stderr:s}=await Ls("docker",e,{encoding:"utf-8",timeout:Hs,windowsHide:!0});return`${t}${s}`};function Gs(e,t){let s=vt(t).toLowerCase(),n=e.replace(/-/g,"_").toLowerCase();return n===s||n.startsWith(`${s}_`)}function Ks(e,t=Date.now()){if(e.status==="restarting")return!0;if(e.restartCount<Bs)return!1;if(e.status==="running"){let n=Date.parse(e.startedAt);return Number.isNaN(n)||t-n<Ft}let s=Date.parse(e.finishedAt??"");return e.exitCode!==0&&!Number.isNaN(s)&&t-s<Ft}function Js(e,t){let s=/database "([^"]+)" does not exist/i.exec(e);return s?`database "${s[1]}" does not exist: re-run the project's database provisioning (flisk up) or create it`:/Cannot find module|MODULE_NOT_FOUND|module not found/i.test(e)?"a module is missing from the image: rebuild it (flisk up --force) after checking the resource's dependencies":/EADDRINUSE|address already in use/i.test(e)?"the port inside the container is already in use: check for two processes started by the same command":/ECONNREFUSED|connection refused|could not connect/i.test(e)?"a dependency is not reachable: check that the service it connects to is running and healthy":/\b(?:environment variable|env var)\b.*\b(?:missing|not set|required|undefined)\b/i.test(e)||/\b[A-Z][A-Z0-9_]{2,}\b (?:is )?(?:not set|required|missing)\b/.test(e)?"a required environment variable is missing: check the project's .env":t.exitCode===137?"killed (exit 137), usually out of memory: raise the container's memory limit":null}function qs(e){let t=[];for(let s of e.split(/\r?\n/)){let[n,r,o,i,a,c]=s.split(" ");!n||r===void 0||t.push({name:n.replace(/^\//,""),restartCount:Number(r)||0,status:o??"",startedAt:i??"",exitCode:Number(a)||0,finishedAt:c??""})}return t}async function Mt(e,t=[],s=Us,n=Date.now()){let r="Crash-looping containers",o;try{o=(await s(["ps","-a","--format",'{{.ID}} {{.Label "com.docker.compose.project"}}'])).split(/\r?\n/).map(p=>p.split(" ")).filter(([p,g])=>p&&g&&Gs(g,e)).map(([p])=>p)}catch{return{name:r,didPass:!0,isSkipped:!0,message:"Docker not available - skipped crash-loop check"}}if(o.length===0)return{name:r,didPass:!0,isSkipped:!0,message:"No project containers to check"};let i;try{i=qs(await s(["inspect","--format","{{.Name}} {{.RestartCount}} {{.State.Status}} {{.State.StartedAt}} {{.State.ExitCode}} {{.State.FinishedAt}}",...o]))}catch{return{name:r,didPass:!0,isSkipped:!0,message:"Containers changed while checking - skipped crash-loop check"}}let a=i.filter(l=>Ks(l,n));if(a.length===0)return{name:r,didPass:!0,message:"No project container is crash-looping"};let c=[],d=new Set;for(let l of a){let p="";try{p=await s(["logs","--tail",String(Ws),l.name])}catch{}let g=J(p,t).split(/\r?\n/).map(S=>S.trim().slice(0,Vs)).filter(Boolean),x=Js(p,l);x&&d.add(x),c.push([`${l.name}: ${l.status}, restarted ${l.restartCount} times`,...g.map(S=>` | ${S}`)].join(`
3
- `))}return{name:r,didPass:!1,message:`${a.length} container${a.length===1?" is":"s are"} crash-looping:
4
- ${c.join(`
5
- `)}`,fix:[...d,"Read the full log: docker logs <container>"].join("; ")}}import{execFile as cn}from"node:child_process";import{realpathSync as Ut,statfsSync as ln}from"node:fs";import{homedir as dn}from"node:os";import{join as un}from"node:path";import{promisify as pn}from"node:util";import{statfsSync as zs}from"node:fs";import{homedir as Xs}from"node:os";var te="Disk Space",Ys=1024**3,Qs=2,we=10,Lt=["Free disk space, then retry: flisk doctor"," docker system prune -af # unused images and build cache (needs Docker running)"," npm cache clean --force"," bun pm cache rm"," brew cleanup -s"].join(`
6
- `);function Ht(e=zs,t=Xs()){let s;try{let r=e(t);s=Number(r.bavail)*Number(r.bsize)/Ys}catch{return{name:te,didPass:!0,isSkipped:!0,message:"Could not read free disk space"}}let n=`${s.toFixed(1)} GB free`;return s<Qs?{name:te,didPass:!1,message:`${n}: Docker cannot build or start containers`,fix:Lt}:s<we?{name:te,didPass:!1,isWarning:!0,message:`${n}: image builds may fail`,fix:Lt}:{name:te,didPass:!0,message:n}}var Zs="Quit Docker Desktop completely (whale icon > Quit Docker Desktop), reopen it, and wait until it shows Running. If it keeps getting stuck, check free disk space. Then retry: flisk doctor";function Bt(e,t=process.platform){return t!=="darwin"||!e?null:{name:"Container Runtime",didPass:!1,message:"Docker Desktop is open, but its engine is not responding",fix:Zs}}import{execFileSync as en}from"node:child_process";var be=(e,t)=>en(e,t,{encoding:"utf-8",stdio:"pipe",windowsHide:!0}),Wt=["traefik-public","traefik-private","backend","database","infisical-network","verdaccio-network","proxy"];function ve(e){let t=e.replace(/-/g,"_");return Wt.map(s=>`${t}_${s}`)}function Vt(e){let t=new Set;for(let s of e)for(let n of["traefik-public","traefik-private"])s.endsWith(`_${n}`)&&t.add(s.slice(0,-(n.length+1)));return t}function De(e,t){for(let s of Wt)if(e.endsWith(`_${s}`)){let n=e.slice(0,-(s.length+1));if(t.has(n))return n}return null}function Qr(e,t=be){let s=new Set(t("docker",["network","ls","--format","{{.Name}}"]).split(/\r?\n/).map(r=>r.trim()).filter(Boolean)),n={removed:[],kept:[]};for(let r of ve(e))if(s.has(r))try{t("docker",["network","rm",r]),n.removed.push(r)}catch(o){let i=String(o.stderr??o).trim();n.kept.push({name:r,reason:i.split(/\r?\n/)[0]??""})}return n}function se(e,t=process.platform,s=be){if(t==="win32")return[];let n;try{n=s("ps",["-axo","pid=,command="])}catch{return[]}let r=[];for(let o of n.split(/\r?\n/)){let i=/^\s*(\d+)\s+(.*)$/.exec(o);if(!i)continue;let a=i[2]??"",c=(a.split(/\s+/)[0]??"").split("/").at(-1),d=` -f ${e}`,l=a.indexOf(d),p=a[l+d.length];c==="tilt"&&/^\S+\s+up\s/.test(a)&&l>0&&(p===void 0||p===" ")&&r.push(Number(i[1]))}return r}function Zr(e,t=process.platform,s=be){let n=se(e,t,s);for(let r of n)try{s("kill",["-TERM",String(r)])}catch{}return n}async function eo(e,t=8e3,s=se){let n=Date.now()+t;for(;s(e).length>0;){if(Date.now()>=n)return!1;await new Promise(r=>setTimeout(r,250))}return!0}import{execFile as tn}from"node:child_process";function Te(e){return new Promise(t=>{tn($("tilt")??"tilt",["get","uiresources","-o","json","--port",String(e)],{timeout:15e3,maxBuffer:16*1024*1024},(s,n)=>t(s?null:n))})}function sn(e){let s=(JSON.parse(e).items??[]).filter(n=>n.status?.disableStatus?.state!=="Disabled").map(n=>n.status?.updateStatus==="not_applicable"?{...n,status:{...n.status,updateStatus:"ok"}}:n);return JSON.stringify({items:s})}function nn(e){return(JSON.parse(e).items??[]).filter(t=>t.status?.disableStatus?.state!=="Disabled").flatMap(t=>t.metadata?.name?[t.metadata.name]:[])}function rn(e,t){let s=JSON.parse(e).items??[],n=new Map(s.map(r=>[r.metadata?.name,r]));return{missing:t.filter(r=>!n.has(r)),disabled:t.filter(r=>n.get(r)?.status?.disableStatus?.state==="Disabled")}}function on(e){return e.endsWith("-typecheck")}function an(e,t,s){let n=Tt(sn(e),t),r=n.failures.filter(i=>!on(i.name)),o={ready:r.length===0&&n.pendingCount===0&&n.okCount>0,failures:r.map(i=>({name:i.name,message:i.error||`${i.updateStatus}/${i.runtimeStatus}`})),pending:n.pendingCount,timedOut:!1,enabled:nn(e)};if(s&&s.length>0){let{missing:i,disabled:a}=rn(e,s);if(i.length>0&&(o={...o,ready:!1,pending:o.pending+i.length}),a.length>0)return{settled:!0,result:{...o,ready:!1,failures:[...o.failures,...a.map(c=>({name:c,message:"disabled in Tilt"}))]}}}return{result:o,settled:o.ready||o.failures.length>0&&o.pending===0}}async function oo(e,t={}){let s=t.timeoutMs??Number(process.env.TDK_UP_READY_TIMEOUT_MS??9e5),n=t.intervalMs??2e3,r=t.fetchJson??Te,o=t.deferred??Dt(),i=Date.now()+s,a={ready:!1,failures:[],pending:0,timedOut:!1,enabled:[]};for(;;){let c=await r(e);if(c)try{let d=an(c,o,t.expected);if(a=d.result,d.settled||a.failures.length>0&&t.isStalled?.(c))return a}catch{}if(Date.now()>=i)return{...a,ready:!1,timedOut:!0};await new Promise(d=>setTimeout(d,n))}}var ne=pn(cn),fn=15e3,mn=/^tdk_doctor_probe_(\d+)$/,hn=async e=>{let{stdout:t}=await ne("docker",e,{encoding:"utf-8",timeout:fn,windowsHide:!0});return t};function $e(e){return String(e.stderr??e).trim().split(/\r?\n/)[0]??""}var gn=120;function kn(e){let t=/^\s*(?:(?:(\d+)-)?(\d+):)?(\d+):(\d+)\s*$/.exec(e);if(!t)return null;let[,s="0",n="0",r="0",o="0"]=t;return((Number(s)*24+Number(n))*60+Number(r))*60+Number(o)}async function Sn(e,t=Te,s=2,n=r=>new Promise(o=>setTimeout(o,r))){for(let r=0;r<s;r++){r>0&&await n(1e3);for(let o of e)if(await t(o)!==null)return!0}return!1}async function yn(e){if(process.platform==="win32")return"unknown";try{let{stdout:t}=await ne("ps",["-p",String(e),"-o","etime="],{encoding:"utf-8",timeout:5e3}),s=kn(t);if(s===null||s<gn)return"unknown";let{stdout:n}=await ne("lsof",["-nP","-a","-p",String(e),"-iTCP","-sTCP:LISTEN","-Fn"],{encoding:"utf-8",timeout:5e3}),r=[...n.matchAll(/^n.*:(\d+)$/gm)].map(o=>Number(o[1]));return await Sn(r)?"healthy":"stale"}catch{return"unknown"}}function xn(e=hn){return{async listNetworks(){let t=(await e(["network","ls","--format","{{.Name}}"])).split(/\r?\n/).map(n=>n.trim()).filter(Boolean);return(await Promise.all(t.map(async n=>{try{let r=await e(["network","inspect","--format","{{len .Containers}}",n]);return{name:n,containers:Number(r.trim())||0}}catch(r){if(/no such network|not found/i.test(String(r)))return null;throw r}}))).filter(n=>n!==null)},async removeNetwork(t){try{await e(["network","rm",t])}catch(s){throw new Error($e(s))}},freeDiskGib(){try{let t=ln(dn());return Number(t.bavail)*Number(t.bsize)/1024**3}catch{return null}},async reclaimable(){let t=null;try{let n=await e(["system","df","--format","{{.Type}} {{.Reclaimable}}"]);for(let r of n.split(/\r?\n/)){let[o,i]=r.split(" ");o==="Build Cache"&&i&&(t=i.replace(/\s*\(.*\)/,"").trim())}}catch{}let s=0;try{s=(await e(["images","-q","-f","dangling=true"])).split(/\r?\n/).filter(Boolean).length}catch{}return{buildCache:t,danglingImages:s}},async prune(t){try{await e(t==="builder"?["builder","prune","-f"]:["image","prune","-f"])}catch(s){throw new Error($e(s))}},async tiltStatus(t){return yn(t)},stopProcess(t){process.kill(t,"SIGTERM")},isProcessAlive(t){try{return process.kill(t,0),!0}catch(s){return s.code==="EPERM"}}}}var Gt=xn();async function Kt(e,t=Gt,s={}){let n=[],r=[];for(let l of s.tiltPids??[])await t.tiltStatus(l)==="stale"?n.push({id:`stop-tilt:${l}`,check:"Tilt processes",scope:"project",command:`kill -TERM ${l}`,status:"planned",reason:"this project's Tilt is running but its UI does not answer"}):r.push(l);let o=r.length>0?`Tilt is running for this project (pid ${r.join(", ")}); run flisk down first`:void 0,i=await t.listNetworks(),a=t.freeDiskGib();if(a!==null&&a<we){let{buildCache:l,danglingImages:p}=await t.reclaimable(),g=`${a.toFixed(1)} GB free`;l&&!/^0(\.0+)?\s*B$/i.test(l)&&n.push({id:"prune:builder",check:"Disk Space",scope:"host",command:"docker builder prune -f",status:"planned",reason:`${g}; ${l} of build cache reclaimable`}),p>0&&n.push({id:"prune:images",check:"Disk Space",scope:"host",command:"docker image prune -f",status:"planned",reason:`${g}; ${p} untagged image${p===1?"":"s"}`})}let c=new Set(e?ve(e):[]),d=Vt(i.map(l=>l.name));for(let l of i){let p=mn.exec(l.name),g,x,S="unused network";if(p)g="probe",x="Orphaned probe networks";else if(c.has(l.name))g="project",x="Docker networks";else if(s.machine&&De(l.name,d))g="machine",x="Docker networks",S=`unused network of project "${De(l.name,d)}"`;else continue;let k={id:`remove-network:${l.name}`,check:x,scope:g,command:`docker network rm ${l.name}`,status:"planned",reason:S};l.containers>0?(k.status="skipped",k.reason=`${l.containers} container(s) still attached`):g==="project"&&o?(k.status="skipped",k.reason=o):p&&t.isProcessAlive(Number(p[1]))&&(k.status="skipped",k.reason=`probe of a running process (pid ${p[1]})`),n.push(k)}return n}async function Jt(e,t,s=Gt){let n=[];for(let r of e){if(r.status!=="planned"||t.dryRun){n.push(r);continue}if(!t.confirm){n.push({...r,status:"skipped",reason:"confirmation required; run in a terminal or pass --yes"});continue}let o=!1;try{o=await t.confirm(r)}catch{}if(!o){n.push({...r,status:"skipped",reason:"not confirmed"});continue}try{if(r.id.startsWith("prune:")){await s.prune(r.id==="prune:builder"?"builder":"images"),n.push({...r,status:"applied",reason:"pruned"});continue}if(r.id.startsWith("stop-tilt:")){s.stopProcess(Number(r.id.slice(10))),n.push({...r,status:"applied",reason:"stopped"});continue}await s.removeNetwork(r.id.slice(15)),n.push({...r,status:"applied",reason:"removed"})}catch(i){n.push({...r,status:"failed",reason:$e(i)})}}return n}function qt(e){return e.some(t=>t.status==="failed")}async function Pn(e){try{let{stdout:t}=await ne(e,["--version"],{encoding:"utf-8",timeout:5e3,windowsHide:!0});return t.trim().split(/\r?\n/)[0]||null}catch{return null}}async function wn(e=Xe("flisk"),t=Pn){let s=new Set,n=[];for(let r of e){let o=r;try{o=Ut(r)}catch{}s.has(o)||(s.add(o),n.push({path:r,version:await t(r)}))}return n}async function zt(e){let t=e??await wn();if(t.length<=1)return{name:"Flisk installs",didPass:!0,message:"One flisk install on PATH"};let s=t.map(r=>`${r.path} (${r.version??"version unknown"})`).join(", "),n=new Set(t.map(r=>r.version));return{name:"Flisk installs",didPass:!1,isWarning:!0,message:`${t.length} flisk installs on PATH${n.size>1?" with different versions":""}: ${s}`,fix:"Keep one: remove the others, or run flisk upgrade. The first on PATH is the one your shell runs; tools that launch /usr/local/bin/flisk directly may use another"}}function Xt(e,t=se){let s=new Set([e]);try{s.add(Ut(e))}catch{}let n=new Set;for(let r of s)for(let o of t(un(r,".tdk",".tdk-out","Tiltfile")))n.add(o);return[...n]}var Ne=1;function bn(e,t=[]){return{schemaVersion:Ne,data:e,errors:t}}function vn(e){return e instanceof Ye?{error:{code:"COMMAND_FAILED",message:e.message,...e.suggestions.length>0?{suggestions:e.suggestions}:{}},exitCode:e.exitCode}:{error:{code:"INTERNAL",message:e instanceof Error?e.message:String(e)},exitCode:2}}function yo(e){let t=vn(e);console.log(JSON.stringify(bn(null,[t.error]))),console.error(t.error.message),process.exit(t.exitCode)}async function Qt(e,t){let s=[],n=[],r=o=>{o.status==="fulfilled"?s.push(o.value):n.push({code:"INTERNAL",message:o.reason instanceof Error?o.reason.message:String(o.reason)})};for(let o of await Promise.allSettled(e.map(i=>Promise.resolve().then(i))))r(o);for(let o of t)for(let i of await Promise.allSettled([Promise.resolve().then(o)]))r(i);return{checks:s,errors:n}}function Yt(e){let t=e.find(s=>s.name===b);return t?t.didPass:null}function _(e,t,s=[],n,r){return{schemaVersion:Ne,data:{ready:s.length===0&&e.every(o=>o.didPass||o.isSkipped||o.isWarning),inProject:t,checks:e,...r?{host:{...r,containerRuntimeReachable:Yt(e),canUp:r.canUp&&Yt(e)!==!1}}:{},...n!==void 0?{ports:{http:{requested:n?.requested.ingressHttp??80,chosen:n?.ingressHttp??null,explicit:n?.explicit.ingressHttp??!!process.env.TDK_HTTP_PORT,reason:n?.reason.ingressHttp??"port planning failed"},https:{requested:n?.requested.ingressHttps??443,chosen:n?.ingressHttps??null,explicit:n?.explicit.ingressHttps??!!process.env.TDK_HTTPS_PORT,reason:n?.reason.ingressHttps??"port planning failed"},postgres:{requested:n?.requested.postgres??5432,chosen:n?.postgres??null,explicit:n?.explicit.postgres??!!process.env.TDK_POSTGRES_PORT,reason:n?.reason.postgres??"port planning failed"}}}:{}},errors:s}}function Zt(e){return e.errors.length>0?2:e.data.ready?0:1}import{existsSync as Ce,readFileSync as es}from"node:fs";import{dirname as Dn,join as Ee,normalize as Tn}from"node:path";function $n(e){let t=new Set,s=/^load\s*\(([\s\S]*?)\)/gm;for(let n of e.matchAll(s)){let r=n[1]??"",o=/["']([^"']+)["']/g,i=Array.from(r.matchAll(o),a=>a[1]);for(let a of i.slice(1))a.startsWith("_")&&t.add(a)}return Array.from(t).sort()}function ts(e,t,s){return t==="ext://tdk-cli"?Ee(s,".tdk",".tdk-out","tdk-cli-ext","Tiltfile"):t.startsWith(".")||!t.includes("://")&&!t.startsWith("@")?Tn(Ee(Dn(e),t)):null}function Nn(e,t,s){let n=[],r=/^load\s*\(([\s\S]*?)\)/gm;for(let o of t.matchAll(r)){let c=(o[1]??"").match(/["']([^"']+)["']/)?.[1];if(!c)continue;let d=ts(e,c,s);d&&(Ce(d)||n.push(`${e}: ${c} -> ${d}`))}return n}function En(e,t,s){let n=[],r=/^load\s*\(([\s\S]*?)\)/gm;for(let o of t.matchAll(r)){let c=(o[1]??"").match(/["']([^"']+)["']/)?.[1];if(c){let d=ts(e,c,s);d&&n.push(d)}}return n}function Cn(e,t){let s=new Set,n=[e];for(;n.length>0;){let r=n.pop();if(!r||s.has(r)||!Ce(r))continue;s.add(r);let o=es(r,"utf-8");for(let i of En(r,o,t))s.has(i)||n.push(i)}return Array.from(s).sort()}function ss(){let e=h()??process.cwd(),t=Ee(e,".tdk",".tdk-out","Tiltfile");if(!Ce(t))return{name:"Starlark Load Exports",didPass:!0,isSkipped:!0,message:"No generated Tiltfile to check"};let s=[],n=[],r=Cn(t,e);for(let i of r){let a=es(i,"utf-8"),c=$n(a);c.length>0&&s.push(`${i}: ${c.join(", ")}`);for(let d of Nn(i,a,e))n.push(d)}if(s.length===0&&n.length===0)return{name:"Starlark Load Exports",didPass:!0,message:`${T(r.length,"reachable Starlark file")} ${r.length===1?"has":"have"} valid load exports and paths`};let o=[];return s.length>0&&o.push(`Private exported symbols:
7
- ${s.join(`
8
- `)}`),n.length>0&&o.push(`Missing relative load targets:
9
- ${n.join(`
10
- `)}`),{name:"Starlark Load Exports",didPass:!1,message:`Starlark load() issues will stop Tilt before services start:
11
- ${o.join(`
12
-
13
- `)}`,fix:"Regenerate with a current Flisk (`flisk config regenerate`). If the issue remains, rename loaded symbols without leading underscores and update stale load paths."}}import{relative as Rn}from"node:path";function re(e,t){return Rn(e,t.configPath)||t.configPath}function ns(e){let t=e.config?.dependsOn;return t===void 0?[]:Array.isArray(t)&&t.every(s=>typeof s=="string")?t:null}function On(e){let t=new Set(e.map(a=>a.name)),s=new Map(e.map(a=>[a.name,(ns(a)??[]).filter(c=>t.has(c))])),n=new Map,r=new Map,o=[],i=a=>{r.set(a,"visiting"),o.push(a);for(let c of s.get(a)??[])if(r.get(c)==="visiting"){let d=o.slice(o.indexOf(c)),l=d.indexOf([...d].sort()[0]??c),p=[...d.slice(l),...d.slice(0,l)];n.set(p.join(">"),[...p,p[0]??c])}else r.has(c)||i(c);o.pop(),r.set(a,"done")};for(let a of[...s.keys()].sort())r.has(a)||i(a);return[...n.values()]}function Re(e=h()??process.cwd(),t=y(e)){let s=t.flatMap(n=>ns(n)===null?[`${re(e,n)} dependsOn ${JSON.stringify(n.config?.dependsOn)}: expected an array of service names`]:[]);return s.length===0?{name:"dependsOn",didPass:!0,message:"Every dependsOn is a list of service names"}:{name:"dependsOn",didPass:!1,message:`${T(s.length,"invalid dependsOn","invalid dependsOn")}:
14
- ${s.join(`
15
- `)}`,fix:'Write "dependsOn" as an array of service names, for example ["postgres", "api"]'}}function Oe(e=h()??process.cwd(),t=y(e)){let s=new Map(t.map(o=>[o.name,o])),n=On(t);if(n.length===0)return{name:"Circular dependencies",didPass:!0,message:"No service depends on itself through dependsOn"};let r=n.map(o=>{let i=s.get(o[0]??""),a=o[1]??"";return`${i?re(e,i):o[0]} dependsOn "${a}": circular dependency ${o.join(" -> ")}`});return{name:"Circular dependencies",didPass:!1,message:`${n.length} ${n.length===1?"circular dependency":"circular dependencies"}:
16
- ${r.join(`
17
- `)}`,fix:'Remove one "dependsOn" entry in each cycle so the services no longer wait on each other, or move what they share into a third service'}}function _e(e=h()??process.cwd(),t=y(e)){let s=t.flatMap(n=>{let r=n.config?.port;return r===void 0?[]:typeof r=="number"&&Number.isInteger(r)&&r>=1&&r<=65535?[]:[`${re(e,n)} port ${JSON.stringify(r)}: not an integer from 1 to 65535`]});return s.length===0?{name:"Service ports",didPass:!0,message:"Every declared port is valid"}:{name:"Service ports",didPass:!1,message:`${T(s.length,"invalid port")}:
18
- ${s.join(`
19
- `)}`,fix:'Set "port" to the port the service listens on, an integer from 1 to 65535'}}function je(e=h()??process.cwd(),t=!1,s=y(e)){let n=[],r=[];for(let i of s){let a=i.config?.schemaVersion;if(a===me)continue;let c=re(e,i);a===void 0?n.push(`${c} schemaVersion: missing`):r.push(`${c} schemaVersion ${JSON.stringify(a)}: this flisk supports ${me}`)}if(n.length===0&&r.length===0)return{name:"schemaVersion",didPass:!0,message:"Every service.json has a supported schemaVersion"};let o=[...n.length>0?["Run `flisk config migrate` to add the missing schemaVersion"]:[],...r.length>0?["A version this flisk does not support cannot be migrated: upgrade flisk"]:[]];return{name:"schemaVersion",didPass:!1,isWarning:!t,message:`${T(n.length+r.length,"service.json file")} without a supported schemaVersion:
20
- ${[...n,...r].join(`
21
- `)}`,fix:o.join(". ")}}function Io(e,t){let s=je(e,!1,t);s.didPass||(console.warn(f.yellow(`\u26A0 ${s.message}`)),s.fix&&console.warn(f.gray(` ${s.fix}`)))}function Fo(e,t={},s=process.exit){let n=t.resources??y(e),r=[X(e,n),Re(e,n),Oe(e,n),_e(e,n)].filter(i=>!i.didPass);if(r.length===0)return;let o=r.map(i=>`${i.message}${i.fix?`
22
- Fix: ${i.fix}`:""}`).join(`
23
- `);t.onInvalid?.(o);for(let i of r)console.error(f.red(`\u2717 ${i.message}`)),i.fix&&console.error(f.gray(` Fix: ${i.fix}`));s(1)}import{readFileSync as _n}from"node:fs";import{join as jn}from"node:path";function rs(e){let t=e.trim().match(/(\d+)\.(\d+)(?:\.(\d+))?/);return t?[Number(t[1]),Number(t[2]),Number(t[3]??0)]:null}function An(e){try{return JSON.parse(_n(jn(e,".tdk",F),"utf-8"))?.minTdkVersion}catch{return}}function os(e,t){let s=An(e);if(s===void 0)return{status:"none"};let n=typeof s=="string"?rs(s):null;if(!n||!/^\d+\.\d+\.\d+$/.test(String(s).trim()))return{status:"malformed",message:`.tdk/project.json minTdkVersion ${JSON.stringify(s)} is not a version like "1.3.80"`,fix:'Set minTdkVersion to a MAJOR.MINOR.PATCH string, for example "1.3.80".'};let r=rs(t),o=r!==null&&(()=>{for(let[a,c]of n.entries()){let d=r[a]??0;if(d!==c)return d>c}return!0})(),i=n.join(".");return o?{status:"ok",required:i}:{status:"too-old",required:i,message:`flisk ${t} is older than the ${i} this project requires (minTdkVersion)`,fix:"Run: flisk upgrade"}}var C=1e4,E={dockerMissing:"See https://docs.docker.com/get-docker/",dockerDaemonDown:"Start Docker Desktop, OrbStack, or Colima, then retry: flisk doctor",tiltMissing:"curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash",bunMissing:"curl -fsSL https://bun.sh/install | bash",port80:"Stop the process bound to port 80, or stop local nginx/caddy. Then: flisk doctor",port5432:"Stop local Postgres or change the host port. Then: flisk doctor",notProject:"flisk project --yes"},as="WSL2 detected. Use Docker Desktop WSL integration. Guide: docs/wsl2.md",cs="Native Windows landscape boot is unsupported. Use WSL2 Ubuntu with Docker Desktop integration. Guide: docs/wsl2.md",Ae=[0,25,0],j=[1,2,0];function oe(e,t){let s=Be(e);return s?We(s,t):!1}function Ln(e,t,s=process.platform==="linux"&&!!process.env.WSL_DISTRO_NAME){if(!s)return{name:"WSL project location",didPass:!0,isSkipped:!0,message:"Not running in WSL2 - skipped project filesystem check"};let n=e.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase();if(n!=="/mnt/c"&&!n.startsWith("/mnt/c/"))return{name:"WSL project location",didPass:!0,message:`${as} Project is on the WSL filesystem.`};let r=`${as} Project is under /mnt/c (${e}); hot reload may be broken. Move it into the WSL filesystem, such as ~/projects.`;return{name:"WSL project location",didPass:!t,isWarning:!t,message:r,fix:"Move the repository under your WSL home directory (for example, ~/projects) and retry flisk doctor."}}function Hn(e){let t=e.replace(/^\[(.*)\]$/,"$1");return t==="0.0.0.0"||/^[0:]*:0\.0\.0\.0$/.test(t)?!0:t.includes(":")&&/^[0:]+$/.test(t)}function Bn(e=process.env,t=!1){let s=(e.TDK_BIND_ADDRESS??"").trim();return Hn(s)?{name:"Dev Port Bind Address",didPass:!t,isWarning:!t,message:`TDK_BIND_ADDRESS is ${s}: Traefik and Postgres are reachable from other machines on the network.`,fix:"Unset TDK_BIND_ADDRESS to keep dev ports on 127.0.0.1. Keep it only when you test from another device on purpose."}:{name:"Dev Port Bind Address",didPass:!0,message:s?`Dev ports bind to ${s}`:"Dev ports bind to 127.0.0.1 (this machine only)"}}function us(e){let t=e.filter(n=>!n.didPass&&!n.isSkipped&&!n.isWarning),s=e.filter(n=>n.didPass||n.isSkipped||n.isWarning);return t.sort((n,r)=>{let o=i=>i.name==="Host Ports"&&/\b5432\b/.test(i.message)?0:i.name==="Host Ports"?1:i.name==="Ingress Ports"?2:3;return o(n)-o(r)}),[...t,...s]}function Wn(e,t){return t?e?"Doctor passed. Next: flisk up":"Doctor passed. Next: flisk project example":"Doctor failed. Fix the items above, then run: flisk doctor"}var He={checkDockerOperatingSystem:"Docker OS",checkDockerCompose:"Docker Compose",checkDockerVersions:"Docker Versions",checkDockerNetworkCapacity:"Docker Network Pool",checkContainerResourceHealth:"Container Resource Health",checkCrashLoopingContainers:"Crash-looping containers",checkTiltResourceHealth:"Tilt Resources",checkServiceHealth:"Service Health",checkServiceSmoke:"Service Smoke",checkAdvertisedEndpoints:"Advertised Endpoints"},ls=new Set(["Docker OS","Docker Compose","Docker Versions","Docker Network Pool","Container Resource Health","Crash-looping containers","Tilt Resources","Service Health","Service Smoke","Advertised Endpoints",...Object.keys(He)]);function Vn(e){return!!(e.requiresContainerRuntime||e.checkName&&ls.has(e.checkName)||e.name&&ls.has(e.name))}function N(e,t){let s=()=>t();return s.requiresContainerRuntime=!0,s.checkName=e,s}async function Un(e,t={}){let s=[],n=!!t.containerRuntimeFailed;for(let r of e){if(n&&Vn(r)){let i=r.checkName??(r.name&&He[r.name]?He[r.name]:r.name&&r.name!=="check"&&r.name!=="fn"?r.name:"Container check");s.push({name:i,didPass:!0,isSkipped:!0,message:`Docker not running - skipped ${i} check`});continue}let o=await r();if(s.push(o),o.name===b&&!o.didPass&&(n=!0),!t.all&&!o.didPass&&!o.isSkipped&&!o.isWarning)break}return s}function Gn(e){let t=0,s=0,n=0,r=0;for(let o of e)o.isSkipped?n++:o.isWarning?r++:o.didPass?t++:s++;return r>0?`${t} passed, ${r} warned, ${s} failed, ${n} skipped`:`${t} passed, ${s} failed, ${n} skipped`}function Ue(e){return ft(e)}function Kn(e,t,s,n,r){return async(o=R)=>{try{return await o(t,C),{name:e,didPass:!0,message:s}}catch(i){return Ue(i)?{name:e,didPass:!1,message:`${e} did not respond within ${C/1e3}s`,fix:r}:{name:e,didPass:!1,message:n,fix:r}}}}async function Ie(e){try{return await R(e,C),!0}catch{return!1}}async function Ge(){if(process.platform==="win32")try{return await R("docker ps",C),{name:b,didPass:!0,message:"Docker Desktop Linux container engine is running"}}catch{return{name:b,didPass:!1,message:"Docker is not running",fix:E.dockerDaemonDown}}let e=!!$("docker");try{return await R("docker ps",C),{name:b,didPass:!0,message:"Docker daemon is running"}}catch(s){if(Ue(s))return{name:b,didPass:!1,message:"Docker daemon is not responding",fix:E.dockerDaemonDown}}let t=Bt(await Ie("pgrep -f com.docker.backend"));return t||(await Ie("colima status")?{name:b,didPass:!0,message:"Colima (Docker runtime) is running"}:$("colima")?{name:b,didPass:!1,message:"Colima is installed but not running",fix:E.dockerDaemonDown}:await Ie("podman ps")?{name:b,didPass:!0,message:"Podman is running"}:e?{name:b,didPass:!1,message:"Docker daemon is not running",fix:E.dockerDaemonDown}:{name:b,didPass:!1,message:"Docker is not running",fix:E.dockerMissing})}var V=Kn("Docker Compose","docker compose version","Docker Compose plugin available","Docker Compose plugin not found","Install Docker Compose: https://docs.docker.com/compose/install/");V.requiresContainerRuntime=!0;V.checkName="Docker Compose";var Jn=[25,0,0],qn=[2,20,2];function Be(e){let t=e.trim().match(/(\d+)\.(\d+)(?:\.(\d+))?/);return t?[Number(t[1]),Number(t[2]),Number(t[3]??0)]:null}function We(e,t){for(let[s,n]of t.entries()){let r=e[s]??0;if(r!==n)return r>n}return!0}async function U(e=R){let t=async a=>String(await e(a,C)).trim(),s,n;try{[s,n]=await Promise.all([t("docker version --format '{{.Server.Version}}'"),t("docker compose version --short")])}catch{return{name:"Docker Versions",didPass:!0,isSkipped:!0,message:"Could not read Docker Engine/Compose versions - skipped version check"}}let r=Be(s),o=Be(n);if(!r||!o)return{name:"Docker Versions",didPass:!0,isSkipped:!0,message:`Unrecognized Docker version output (engine "${s}", compose "${n}") - skipped version check`};let i=[];return We(r,Jn)||i.push(`Docker Engine ${s} (need 25.0+)`),We(o,qn)||i.push(`Docker Compose ${n} (need 2.20.2+)`),i.length===0?{name:"Docker Versions",didPass:!0,message:`Docker Engine ${s} and Compose ${n} support generated healthchecks`}:{name:"Docker Versions",didPass:!1,message:`Docker is too old for generated healthchecks (they use start_interval):
24
- ${i.join(`
25
- `)}`,fix:"Update Docker Desktop, or on Linux update docker-ce and the docker-compose-plugin package"}}U.requiresContainerRuntime=!0;U.checkName="Docker Versions";async function Ke(e=R){let t;try{t=String(await e("tilt version",C)).trim()}catch{return{name:"Tilt CLI",didPass:!1,message:"Tilt CLI not found",fix:E.tiltMissing}}return oe(t,Ae)?{name:"Tilt CLI",didPass:!0,message:`Tilt ${t} is available`}:{name:"Tilt CLI",didPass:!1,message:`Tilt ${t||"version unknown"} is below the required v${Ae.join(".")} floor`,fix:`Install Tilt v${Ae.join(".")} or newer: https://docs.tilt.dev/install.html`}}async function Je(e=R){let t;try{t=String(await e("docker info --format '{{.OSType}}'",C)).trim().toLowerCase()}catch{return{name:"Docker OS",didPass:!0,isSkipped:!0,message:"Docker OS unavailable - daemon failure reported separately"}}return t!=="linux"?{name:"Docker OS",didPass:!1,message:`Docker is using the ${t||"unknown"} engine; Flisk requires Linux containers`,fix:"Switch Docker Desktop to Linux containers, enable WSL2 integration, then retry flisk doctor."}:{name:"Docker OS",didPass:!0,message:"Docker is using Linux containers"}}Je.requiresContainerRuntime=!0;Je.checkName="Docker OS";async function zn(e=R){let t=h();if(!t)return{name:"Bun",didPass:!0,isSkipped:!0,message:"Not in a project - skipping Bun check"};if(!Z(y(t)))return{name:"Bun",didPass:!0,isSkipped:!0,message:"No generated JS services - skipping Bun check"};try{let s=String(await e("bun --version",C)).trim();return oe(s,j)?{name:"Bun",didPass:!0,message:`Bun ${s} is available`}:{name:"Bun",didPass:!1,message:`Bun ${s||"version unknown"} is below the required ${j.join(".")} floor`,fix:`Install Bun ${j.join(".")} or newer: https://bun.sh/install`}}catch{return{name:"Bun",didPass:!1,message:"Bun is not available",fix:E.bunMissing}}}function Xn(){let e=h()??process.cwd(),t=Ze(e);if(t.missing.length>0)return{name:"Environment Variables",didPass:!1,message:`Missing required env variables: ${t.missing.join(", ")}`,fix:v(P(e,".env"))?`Edit .env and set these values:
26
- ${t.missing.map(n=>`${n}=<value>`).join(`
27
- `)}`:"No .env file yet. Run `flisk project` to create one with working defaults."};if(t.invalid.length>0)return{name:"Environment Variables",didPass:!1,message:`Invalid env variables: ${t.invalid.join(", ")}`,fix:"Edit .env and provide values for empty variables"};let s=t.warnings.filter(n=>!n.startsWith(".env file not found"));return{name:"Environment Variables",didPass:!0,message:s.length>0?`All required environment variables are set (warning: ${s.join("; ")})`:"All required environment variables are set"}}function Yn(){let e=h()??process.cwd(),t=P(e,".tdk",".tdk-out"),s=de.filter(n=>!v(P(t,n)));return s.length===0?{name:"Master Configs",didPass:!0,message:`${de.join(", ")} found`}:{name:"Master Configs",didPass:!1,message:`Master configs missing: ${s.join(", ")}`,fix:"Run: flisk project"}}function Qn(e=ze()){let t=h();if(!t)return{name:"Flisk version",didPass:!0,isSkipped:!0,message:"Not in a project - skipping Flisk version check"};let s=os(t,e);return s.status==="none"?{name:"Flisk version",didPass:!0,isSkipped:!0,message:`flisk ${e} (no minTdkVersion in .tdk/project.json)`}:s.status==="malformed"||s.status==="too-old"?{name:"Flisk version",didPass:!1,message:s.message,fix:s.fix}:{name:"Flisk version",didPass:!0,message:`flisk ${e} meets minTdkVersion ${s.required}`}}function Zn(){let e=h()??process.cwd(),t=Pe(e),s=y(e).filter(r=>!ee(e,r.path,t));if(s.length===0)return{name:"Resource Discovery",didPass:!0,message:`All resources are covered by discovery.paths ${JSON.stringify(t)}`};let n=s.map(r=>Me(Le(e,r.path))).join(", ");return{name:"Resource Discovery",didPass:!1,message:`${T(s.length,"resource")} outside discovery.paths ${JSON.stringify(t)}: ${n}. \`flisk up\` will not start them`,fix:"Move each under services/<stack>/<name>, or add a matching pattern to discovery.paths in .tdk/project.json and run: flisk config regenerate"}}var er=["install-deps.sh","bun-hoisted-symlink-fix.sh","prisma-bun-client-link-fix.sh","prisma-normalize-client.sh","infisical-entrypoint.sh"],tr=/shared-platform-engineering\/docker-templates\/([\w.-]+)/g;function sr(e){let t=new Set;for(let s of y(e)){let n=P(s.path,I);if(v(n)){for(let r of Fn(n))if(!(!r.startsWith("Dockerfile")||r.endsWith(".dockerignore")))for(let o of M(P(n,r),"utf-8").matchAll(tr))t.add(o[1])}}return[...t]}function nr(){let e=h()??process.cwd(),t=[];v(P(e,W))||t.push(`${W} (workspace root manifest)`);let s=P(e,"shared-platform-engineering","docker-templates"),n=[];try{n=sr(e)}catch{}for(let r of new Set([...er,...n]))v(P(s,r))||t.push(`shared-platform-engineering/docker-templates/${r}`);return t.length===0?{name:"Generated Runtime Assets",didPass:!0,message:"Generated Docker runtime assets are present"}:{name:"Generated Runtime Assets",didPass:!1,message:`Generated Dockerfiles reference missing project runtime assets:
28
- ${t.join(`
29
- `)}`,fix:"Run `flisk project --yes` (or `flisk config regenerate`) with an updated Flisk. `flisk up` also refreshes these assets before starting Tilt."}}function rr(){let e=h()??process.cwd(),t=y(e),s=[];for(let n of t){let r=P(n.path,W);if(!v(r))continue;let o=n.config?.appType??"backend",i=ue[o]??ue.backend,a;try{a=JSON.parse(M(r,"utf-8")).scripts??{}}catch{s.push(`${n.name} (package.json is invalid JSON)`);continue}let c=i.filter(d=>!a[d]);c.length>0&&s.push(`${n.name}: missing "${c.join('", "')}"`)}return s.length===0?{name:"Startup Scripts",didPass:!0,message:"All services have required package.json scripts"}:{name:"Startup Scripts",didPass:!1,message:`Services missing required package.json scripts:
30
- ${s.join(`
31
- `)}`,fix:`Add the missing scripts to each service's package.json, e.g.:
32
- "dev": "bun run src/index.ts",
33
- "build": "tsc",
34
- "start": "bun run dist/index.js"`}}function ps(e){if(e.startsWith("@"))return[e.split("/").slice(0,2).join("/")];let t=e.split("/")[0]??e;return[`@types/${t}`,t]}function fs(e,t,s=0){let n=e[t];if(typeof n!="string"||s>3)return!1;if(/(^|[\s;&|(])tsc(\s|$)/.test(n))return!0;for(let r of n.matchAll(/\b(?:bun|npm|pnpm|yarn)\s+run\s+([\w:.-]+)/g))if(fs(e,r[1],s+1))return!0;return!1}function ds(e){let t=ps(e);return e.includes("/")||e.startsWith("@")?t[t.length-1]:t[0]}var or={"@types/bun":"^1.4.2","@types/node":"^20.0.0"};function ir(e,t){return(t.includes("bun")||e.has("@types/bun"))&&!e.has("@types/node")}function ar(){let e=h()??process.cwd(),t=y(e),s=[],n=new Set;for(let o of t){let i=P(o.path,W),a=P(o.path,I,"tsconfig.docker.autogenerated.json");if(!v(i)||!v(a))continue;let l=Ve(a)?.compilerOptions?.types;if(!Array.isArray(l))continue;let p=Ve(i),g=p?.scripts??{};if(!fs(g,"build"))continue;let x=new Set([...Object.keys(p?.devDependencies??{}),...Object.keys(p?.dependencies??{})]),S=l.filter(k=>typeof k=="string").filter(k=>!ps(k).some(m=>x.has(m)));for(let k of S)n.add(ds(k));if(S.length>0){let k=S.map(m=>`"${m}" (needs ${ds(m)})`).join(", ");s.push(`${o.name}: "types" lists ${k}`)}ir(x,l)&&(n.add("@types/node"),s.push(`${o.name}: uses @types/bun, which references node types internally, but @types/node is not a direct dependency`))}if(s.length===0)return{name:"TypeScript Type Dependencies",didPass:!0,message:`Every service's Docker tsconfig "types" entry has its @types package installed`};let r=[...n].map(o=>{let i=or[o];return i?`"${o}": "${i}"`:`${o} (bun add -d ${o})`});return{name:"TypeScript Type Dependencies",didPass:!1,message:`\`bun run build\` will fail with TS2688 (Cannot find type definition file) because a @types package it needs is not a direct dependency:
35
- ${s.join(`
36
- `)}`,fix:`Add to each service's package.json devDependencies: ${r.join(", ")}`}}function Ve(e){try{return JSON.parse(M(e,"utf-8"))}catch{return null}}function cr(e){let s=Ve(e)?.compilerOptions;return s?.allowSyntheticDefaultImports===!0||s?.esModuleInterop===!0}function lr(){let e=h()??process.cwd(),t=y(e).filter(n=>n.config?.appType==="frontend");if(t.length===0)return{name:"Frontend Docker Preflight",didPass:!0,isSkipped:!0,message:"No frontend services to check"};let s=[];for(let n of t){v(P(n.path,"public"))||s.push(`${n.name}: no public/ folder, but the Docker build copies it. Create it: mkdir -p ${Me(Le(e,P(n.path,"public")))} && touch ${Me(Le(e,P(n.path,"public",".gitkeep")))}`);let r=P(n.path,I,"Dockerfile.app.autogenerated"),o=P(n.path,I,"tsconfig.docker.autogenerated.json");if(v(r)){let i=M(r,"utf-8"),a=/\bEXPOSE\s+80\b/.test(i),c=n.config?.stack,d=c?P(e,"services",c,I,"docker-compose.app.autogenerated.yml"):"";if(a&&d&&v(d)){let l=M(d,"utf-8"),p=n.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=new RegExp(`traefik\\.http\\.services\\.${p}\\.loadbalancer\\.server\\.port=(\\d+)`),S=l.match(g)?.[1];S&&S!=="80"&&s.push(`${n.name}: nginx runtime exposes 80, but generated Traefik routes to ${S}`)}}if(v(o)&&!cr(o)){let i=P(n.path,"src","main.tsx");if(v(i)){let a=M(i,"utf-8"),c=[/import\s+\w+\s+from\s+["']react["']/,/import\s+\w+\s+from\s+["']react-dom\/client["']/].filter(d=>d.test(a)).map(d=>d.source.includes("react-dom")?"react-dom/client":"react");c.length>0&&s.push(`${n.name}: Docker tsconfig does not allow synthetic default imports, but src/main.tsx default-imports ${c.join(" and ")}`)}}}return s.length===0?{name:"Frontend Docker Preflight",didPass:!0,message:`${T(t.length,"frontend")} ${t.length===1?"has":"have"} compatible Docker build/routing metadata`}:{name:"Frontend Docker Preflight",didPass:!1,message:`Frontend Docker metadata has issues that will make \`flisk up\` fail or route 404:
37
- ${s.join(`
38
- `)}`,fix:'Regenerate with a current Flisk (`flisk config regenerate`) and ensure frontend nginx runtimes route to port 80. For React entrypoints, prefer named imports: `import { StrictMode } from "react"` and `import { createRoot } from "react-dom/client"`.'}}var dr=90,ur=80;function pr(e){return e.split(`
39
- `).map(t=>t.trim()).filter(Boolean).map(t=>{let[s,n,r]=t.split(",");return{name:s??"unknown",memPct:Number.parseFloat((n??"").replace(/%/g,"")),cpuPct:Number.parseFloat((r??"").replace(/%/g,""))}}).filter(t=>Number.isFinite(t.memPct)&&Number.isFinite(t.cpuPct))}var fr=Object.assign(function(){let t;try{t=In($("docker")??"docker",["stats","--no-stream","--format","{{.Name}},{{.MemPerc}},{{.CPUPerc}}"],{stdio:"pipe",encoding:"utf-8",timeout:C,windowsHide:process.platform==="win32"})}catch(o){return{name:"Container Resource Health",didPass:!0,isSkipped:!0,message:Ue(o)?"Docker not responding - skipped container resource check":"Docker not running - skipped container resource check"}}let s=pr(t);if(s.length===0)return{name:"Container Resource Health",didPass:!0,isSkipped:!0,message:"No running containers to check"};let n=s.filter(o=>o.memPct>=dr&&o.cpuPct>=ur);if(n.length===0)return{name:"Container Resource Health",didPass:!0,message:`${T(s.length,"container")} within normal resource usage`};let r=n.map(o=>`${o.name} (mem ${o.memPct.toFixed(0)}%, cpu ${o.cpuPct.toFixed(0)}%)`).join(`
40
- `);return{name:"Container Resource Health",didPass:!1,message:`${T(n.length,"container")} pinned near its memory limit while burning CPU -- likely stuck in a boot-time retry/fetch loop, not a normal crash:
41
- ${r}`,fix:"Check the container's boot logs for a network fetch loop (e.g. `bunx <pkg>` re-downloading a CLI on every start instead of using one already installed): docker logs <container>. If a Prisma auto-migration is the cause, set AUTO_MIGRATE=false in the project's .env as a temporary unblock."}},{requiresContainerRuntime:!0,checkName:"Container Resource Health"}),mr=5e3;async function hr(e,t){let s=h()??process.cwd(),n=fe(y(s),t);return n.length===0?{name:"Service Health",didPass:!0,isSkipped:!0,message:"No routable services to ping"}:ke(await q(n,e))}async function gr(e,t){let s=h()??process.cwd(),n=y(s),r=ot(rt(n,t),{timeoutSeconds:Math.ceil(e/1e3)});return r.length===0?Se([]):(await q(fe(n,t),e)).some(i=>i.status!==void 0)?Se(await at(r,it(s))):{name:"Service Smoke",didPass:!0,isSkipped:!0,message:"No services responded - skipped smoke checks"}}async function kr(e,t){let s=h()??process.cwd(),n=y(s),r=nt(n,t);return r.length===0?{name:"Advertised Endpoints",didPass:!0,isSkipped:!0,message:"No routable services to check"}:Nt(await q(r,e))}function Sr(e,t){if(e.length===0){console.log(`${f.green("\u2713")} Nothing to repair
42
- `);return}for(let s of e){let n=s.status==="planned"?`${f.cyan("would run")}`:s.status==="applied"?f.green("ran"):s.status==="failed"?f.red("failed"):f.gray("skipped"),r=s.status==="planned"?"":` (${s.reason})`;console.log(`${n}: ${s.command}${r}`)}t&&console.log(f.gray(`
43
- Dry run: nothing was changed.`)),console.log("")}function Fe(e){for(let t of us(e))!t.didPass&&!t.isSkipped&&!t.isWarning?(console.log(`${f.red("\u2717")} ${t.message}`),t.fix&&console.log(`${f.blue("\u2139")} Fix: ${t.fix}`)):t.isWarning?(console.log(`${f.yellow("\u26A0")} ${f.yellow(t.message)}`),t.fix&&console.log(`${f.blue("\u2139")} Fix: ${t.fix}`)):t.isSkipped?(console.log(`${f.gray("\u25CB")} ${f.gray(t.message)}`),t.fix&&console.log(`${f.blue("\u2139")} ${t.fix}`)):console.log(`${f.green("\u2713")} ${t.message}`)}function yr(e,t,s,n={},r){let o=r??[...e,...t];n.all?(console.log(f.bold("Machine")),Fe(e),console.log(`
44
- ${f.bold("Project")}`),s?t.length>0&&Fe(t):console.log(`${f.gray("\u25CB")} ${f.gray("Not in a Flisk project, so project checks were skipped")}`),console.log(""),console.log(Gn(o))):(Fe(o),console.log(""),o.every(a=>a.didPass||a.isSkipped||a.isWarning)&&!s&&(console.log(`${f.gray("\u25CB")} ${f.gray("Not in a Flisk project, so project checks were skipped")}`),console.log("")))}var xr=new Mn("doctor").description("Check environment readiness for Flisk").option("--all","Run every check and show Machine and Project sections with a summary",!1).option("--json","Output a versioned JSON readiness report",!1).exitOverride(e=>{e.exitCode===0&&process.exit(0),xr.opts().json&&console.log(JSON.stringify(_([],!1,[{code:"USAGE",message:e.message}]))),process.exit(2)}).option("--no-ping","Skip pinging running services' /health endpoints").option("--strict","Fail warnings such as a WSL project under /mnt/c").option("--fix","Repair this project's unused Docker networks and leftover doctor probes",!1).option("--dry-run","With --fix: list the repairs without changing anything",!1).option("--scope <scope>","With --fix: project (default) or machine, which also removes unused networks of other Flisk projects","project").option("-y, --yes","With --fix: apply every repair without asking",!1).option("--ping-timeout <ms>","Per-service ping timeout in milliseconds",String(mr)).action(async e=>{let t=Number(e.pingTimeout);if(!/^\d+$/.test(e.pingTimeout)||!Number.isSafeInteger(t)||t<=0){let u="--ping-timeout must be a positive integer number of milliseconds";e.json&&console.log(JSON.stringify(_([],!1,[{code:"USAGE",message:u}]))),console.error(u),process.exit(2);return}let s=!["project","machine"].includes(e.scope),n=e.scope!=="project"&&!e.fix;if(s||n||(e.dryRun||e.yes)&&!e.fix){let u=s?`--scope must be project or machine, got "${e.scope}"`:n?"--scope only applies with --fix":`${e.dryRun?"--dry-run":"--yes"} only applies with --fix`;e.json&&console.log(JSON.stringify(_([],!1,[{code:"USAGE",message:u}]))),console.error(u),process.exit(2);return}e.json||console.log("Flisk doctor checks your local Docker + Tilt development environment; it does not check cluster deployments.");let r=Rt();if(process.platform==="win32"){if(e.json){let u=null;try{u=await ct()}catch{}console.log(JSON.stringify(_([{name:"Native Windows support",didPass:!1,message:cs,fix:"Use WSL2 Ubuntu with Docker Desktop integration. Guide: docs/wsl2.md"}],!!h(),[],u,{...r,canUp:!1})))}console.error(cs),process.exit(1);return}if(r.kind==="webcontainer"){let u=_([{name:"Host",didPass:!1,message:xe,fix:`Use a machine with Docker. Guide: ${Q}`}],!!h(),[],void 0,r);e.json&&console.log(JSON.stringify(u)),console.error(xe),process.exit(1);return}e.json||(console.log(`
45
- ${f.bold("\u{1F50D} Flisk Doctor")}
46
- `),console.log(`Checking environment...
47
- `));let o=h(),i;if(e.fix){try{let u;if(o)try{u=ut(o).project.name}catch{}let w=o?Xt(o):[],ae=await Kt(u,void 0,{tiltPids:w,machine:e.scope==="machine"});i=await Jt(ae,{dryRun:e.dryRun,confirm:e.yes||!e.json&&process.stdin.isTTY?async D=>e.yes||await pt({message:`Run \`${D.command}\` (${D.check}, ${D.reason})?`}):void 0})}catch(u){i=[{id:"plan-fixes",check:"Docker networks",scope:"project",command:"docker network ls",status:"failed",reason:`could not list Docker networks: ${(u instanceof Error?u.message:String(u)).split(/\r?\n/)[0]}`}]}e.json||Sr(i,e.dryRun)}let a,c;try{a=await z(o??process.cwd())}catch(u){a=null,c=u instanceof Error?u.message:String(u)}let d=[()=>a?{name:"Host Ports",didPass:!0,message:`HTTP ${a.ingressHttp}, HTTPS ${a.ingressHttps}, Postgres ${a.postgres}`}:{name:"Host Ports",didPass:!1,message:c??"Could not select host ports",fix:"Set TDK_HTTP_PORT, TDK_HTTPS_PORT, or TDK_POSTGRES_PORT to available host ports."},()=>a?ge(is,void 0,[a.ingressHttp,a.ingressHttps]):{name:"Ingress Ports",didPass:!1,message:"Ingress port plan is unavailable"},Ge,()=>Ht(),N("Docker OS",Je),Ke,N("Docker Compose",V),N("Docker Versions",U),zn,()=>Ln(h()??process.cwd(),e.strict),()=>Bn(process.env,e.strict),N("Docker Network Pool",()=>bt()),()=>zt()],l=[()=>Qn(),Yn,nr,ss,rr,()=>Et(),ar,lr,Zn,()=>ht(),()=>X(),()=>Re(),()=>Oe(),()=>_e(),()=>je(void 0,e.strict),()=>gt(),()=>kt(),()=>yt(),()=>St(),()=>Y(),()=>mt(),()=>Pt(),()=>xt(),()=>wt(),Xn,async()=>{let u=h()??process.cwd(),w=$t(u)?await dt(u):!0;return he(is,u,void 0,w)},N("Container Resource Health",fr),N("Crash-looping containers",()=>{let u=h()??process.cwd(),w=[];try{w=pe(u)}catch{return{name:"Crash-looping containers",didPass:!0,isSkipped:!0,message:"Could not read .env - skipped crash-loop check"}}return Mt(st(),w)}),N("Tilt Resources",ye)];if(e.ping){let u=o?lt(o,a?.ingressHttp):a?.ingressHttp;l.push(N("Service Health",()=>hr(t,u))),l.push(N("Service Smoke",()=>gr(t,u))),l.push(N("Advertised Endpoints",()=>kr(t,u)))}let p=!!o,g=[],x=[],S,k=[];if(e.json||!e.all){let u=await Qt(d,p?l:[]);S=u.checks,k=u.errors}else{let u=async(D,Ts=!1)=>{let $s=D.map(K=>{let ce=async()=>{try{return await K()}catch(le){return k.push({code:"INTERNAL",message:le instanceof Error?le.message:String(le)}),{name:K.checkName??"Doctor check",didPass:!1,isSkipped:!1,message:"Check failed with an internal error"}}};return ce.requiresContainerRuntime=K.requiresContainerRuntime,ce.checkName=K.checkName,ce});return Un($s,{all:!!e.all,containerRuntimeFailed:Ts})};g=await u(d);let w=g.some(D=>!D.didPass&&!D.isSkipped&&!D.isWarning),ae=g.some(D=>D.name===b&&!D.didPass);p&&(e.all||!w)&&(x=await u(l,ae)),S=[...g,...x]}if(Ot(r.kind))for(let u of S)u.name===b&&!u.didPass&&(u.fix=Ct);let m=_(us(S),p,k,a,r);i&&(m.data.actions=i),i&&qt(i)&&(m.data.ready=!1);let A=Zt(m),B=m.data.ready;if(e.json){let u;try{u=pe(h()??process.cwd())}catch(w){if(!(w instanceof et))throw w;console.log(JSON.stringify(_([],p,[...k,{code:"ENV_UNREADABLE",message:w.message}]))),console.error(w.message),process.exit(1)}console.log(JSON.stringify(tt(m,u)));for(let w of k)console.error(J(w.message,u));A!==0&&process.exit(A);return}for(let u of k)console.error(`${f.red("\u2717")} Doctor check failed: ${u.message}`);yr(g,x,p,e,S);let qe=Wn(p,B);console.log(`${B?f.green(f.bold("\u2713")):f.red(f.bold("\u2717"))} ${qe}`),A!==0&&process.exit(A)});function ms(e){return oe(e,j)}var G=`${j[0]}.${j[1]}+`;import{execFileSync as hs}from"node:child_process";import{accessSync as gs,constants as ks,readdirSync as Pr}from"node:fs";import{delimiter as wr,join as L}from"node:path";var O="flisk",Ss="@flisk-sh/flisk",br="https://github.com/flisk-sh/flisk",ys="@tdk-landscape/tdk-cli-core";function xs(e=O,t=process.env){let s=t.PATH??t.Path??"";for(let n of s.split(wr)){if(!n)continue;let r=[L(n,e),L(n,`${e}.cmd`),L(n,`${e}.exe`)];for(let o of r)try{return gs(o,ks.X_OK),!0}catch{}}return!1}function vr(e=process.env){let t=e.HOME??e.USERPROFILE??"";if(!t)return"flisk-workspace";let s=L(t,"Documents");try{return gs(s,ks.F_OK),L(s,"flisk")}catch{return L(t,"flisk")}}function Dr(e){try{return Pr(e).every(t=>t.startsWith("."))}catch{return!0}}function Ps(e=process.env,t=process.cwd()){if(!xs(O,e))return`The \`${O}\` command is not on PATH (this run is not a global install). Install it with \`npm install -g ${Ss}\`, then run \`${O} project --yes\`. If npm reports EEXIST for \`flisk\`, the old package still owns that command: run \`npm uninstall -g ${ys}\` first. The current release is published from ${br}.`;if(Dr(t))return`Next: ${O} project --yes`;let s=vr(e);return`Next: mkdir -p ${s} && cd ${s} && ${O} project --yes
48
- (${O} project writes .tdk/ and the master configs into the current folder, so it starts clean in a folder of its own. Or clone a starter: ${O} project example)`}function Ei(e=process.env){if(xs(O,e))return"present";let t=e.npm_execpath?.includes("bun")?"bun":"npm",s=t==="bun"?"bun remove -g":"npm uninstall -g";try{hs(s,[ys],{stdio:"ignore",timeout:12e4})}catch{}try{return hs(t,["install","-g",Ss],{stdio:"inherit",timeout:3e5}),"installed"}catch{return"failed"}}var Nr=["docker","compose","tilt"],vs=["node","bun","ports"],Ds=["node",...Nr,"bun","ports"];function Er(e,t){return{id:e,ok:t.didPass||!!t.isSkipped,message:t.message,fix:t.fix}}function bs(e){let[t=0,s=0]=String(e).split(".").map(n=>Number.parseInt(n,10));return!Number.isFinite(t)||!Number.isFinite(s)||t<22||t===22&&s<12}async function ie(e,t,s){try{return Er(e,await t())}catch{return{id:e,ok:!1,message:s}}}function Cr(e){return e.isSkipped?{...e,didPass:!1,isSkipped:!1,message:`Could not verify Docker Engine/Compose minimum versions: ${e.message}`,fix:e.fix??"Start Docker and ensure Docker Engine 25+ and Compose 2.20.2+ are installed."}:e}function Rr(e){try{return y(e).some(t=>t.config?.featuresEnabled?.includes("prisma")??!1)}catch{return!1}}async function Or(e={}){let t=e.cwd??process.cwd(),s=e.scope??"runtime",n=h(t),r=!!n,o=[],i=process.versions.node;o.push({id:"node",ok:!bs(i),message:i,fix:bs(i)?`Install Node.js 22.12+ (current: ${i}). https://nodejs.org`:void 0}),s==="runtime"&&(o.push(await ie("docker",Ge,"Docker daemon is not running")),o.push(await ie("compose",async()=>{let[m,H]=await Promise.all([V(),U()]);return m.didPass?Cr(H):m},"Docker Engine or Compose version check failed")),o.push(await ie("tilt",Ke,"Tilt CLI not found")));let a=n?Z(y(n)):!0,c=!1,d=a?$("bun"):void 0;if(d)try{let m=ws(d,["--version"],{encoding:"utf-8",timeout:3e3}).trim();c=ms(m)}catch{}o.push(a?{id:"bun",ok:c,message:c?`Bun ${G} is available on PATH`:`Bun ${G} not found on PATH`,fix:c?void 0:"curl -fsSL https://bun.sh/install | bash"}:{id:"bun",ok:!0,message:"Bun not needed: no generated JS services"});try{let m=await z(n??t,s==="scaffold"?{inspectDocker:!1}:{});o.push({id:"ports",ok:!0,message:`HTTP ${m.ingressHttp}, HTTPS ${m.ingressHttps}, Postgres ${m.postgres}`})}catch(m){o.push({id:"ports",ok:!1,message:m instanceof Error?m.message:String(m),fix:"Set TDK_HTTP_PORT, TDK_HTTPS_PORT, or TDK_POSTGRES_PORT to available host ports."})}if(n&&s==="runtime"){let m=await ie("nats",()=>Y(n),"NATS broker check failed");if(m.ok||o.push(m),Rr(n)){let H=!1;try{let A=JSON.parse(Tr($r(n,".tdk",F),"utf-8")),B=String(A?.project?.name??"").replace(/-/g,"_");B&&(H=ws($("docker")??"docker",["ps","--filter",`label=com.docker.compose.project=${B}`,"--filter","label=com.docker.compose.service=postgres","--filter","health=healthy","--format","{{.Names}}"],{encoding:"utf-8",timeout:3e3}).trim().length>0)}catch{}H||o.push({id:"prisma",ok:!1,message:"A Prisma resource is configured, but the project Postgres service is not healthy",fix:"Run `flisk up` to start the bundled Postgres, then check `flisk doctor`."})}}let l=o.filter(m=>!m.ok).slice(0,8),p=s==="scaffold"?vs:Ds,g=l.some(m=>p.includes(m.id)),x=l.some(m=>m.id==="bun"),S=l.length?g?s==="scaffold"?x?`Project setup blocked. Bun ${G} must be installed on PATH.
49
- Fix the machine checks below.`:"Project setup blocked. Fix the machine checks below.":x?`Cold start blocked. Bun ${G} must be installed on PATH.
50
- Prisma/NATS configuration is project-specific and generated after \`flisk project\`. Fix the machine checks below.`:"Cold start blocked. Bun/Prisma/NATS are not the first failure.\nThey are generated after `flisk project`. Fix the machine checks below.":"Machine is ready. Project wiring is not.":"",k=l.length?"":r?"Environment ready for Flisk":`This machine is ready for Flisk.
51
- ${Ps()}`;return{ok:l.length===0,inProject:r,items:l,header:S,footer:k}}function _r(e,t={}){let s=[e.header];for(let n of e.items)s.push(`FAIL ${n.id.padEnd(7)} ${n.message}`),n.fix&&s.push(` ${n.fix}`);return e.footer&&(t.includeSuccessFooter??!0)&&s.push(e.footer),s.filter(Boolean).join(`
52
- `)}async function Ui(e={}){let t=e.scope??"runtime",s=await Or({scope:t}),n=t==="scaffold"?vs:Ds;s.items.some(o=>n.includes(o.id))&&(console.error(_r(s)),process.exit(1))}function Gi(e=$){return{hasDockerCli:!!e("docker"),hasTiltCli:!!e("tilt")}}function Ki(e){let t=[];return e.hasDockerCli||t.push(`Docker is not installed. ${E.dockerMissing}`),e.hasTiltCli||t.push(`Tilt is not installed. ${E.tiltMissing}`),t.push("Docker and Tilt are only needed to start the stack: start them, then run `flisk doctor` (readiness) and `flisk up`."),t}export{bn as a,vn as b,yo as c,xe as d,Ct as e,Rt as f,Ot as g,Pe as h,ee as i,Br as j,Qr as k,Zr as l,eo as m,Te as n,sn as o,an as p,oo as q,Io as r,Fo as s,os as t,xr as u,ys as v,Ei as w,Nr as x,vs as y,Ds as z,bs as A,Cr as B,Or as C,_r as D,Ui as E,Gi as F,Ki as G};
@@ -1,4 +0,0 @@
1
- import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{a as S}from"./chunk-DTIHDMED.js";import{g as p,q as P}from"./chunk-R67UHACQ.js";import{a as x}from"./chunk-5ZSZ4WCI.js";import{Ra as k,ba as g,ca as h,d,k as u,ra as w,s as m,ta as y}from"./chunk-LYOSHFYU.js";import{b as a}from"./chunk-CF46CD6R.js";import{Command as F}from"commander";import{readFileSync as N}from"node:fs";import{join as O}from"node:path";function D(n){let e=n.config;return e?Array.isArray(e.featuresEnabled)&&e.featuresEnabled.includes(d)?!0:(Array.isArray(e.dependsOn)?e.dependsOn:[]).some(t=>x.includes(t)):!1}function J(n,e){let i=n.replace(/-/g,"_"),t=[];for(let o of[...e].sort((r,s)=>r.name.localeCompare(s.name))){let r=o.resources.filter(D).map(s=>s.name);r.length!==0&&t.push({name:`${i}_${o.name.replace(/-/g,"_")}`,stack:o.name,services:r.sort()})}return t.length===0?null:{name:"postgres",databases:t}}function b(n){try{let e=JSON.parse(N(O(n,".tdk",u),"utf-8"));return typeof e?.project?.name=="string"?e.project.name:null}catch{return null}}import{spawn as T}from"node:child_process";function R(n){try{let e=new URL(n);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}function $(n,e=process.platform,i=T){if(!R(n))return Promise.resolve(!1);let t,o;return e==="darwin"?(t="open",o=[n]):e==="win32"?(t="rundll32.exe",o=["url.dll,FileProtocolHandler",n]):(t="xdg-open",o=[n]),new Promise(r=>{try{let s=i(t,o,{stdio:"ignore",detached:!0,windowsHide:!0});s.once("error",()=>r(!1)),s.once("spawn",()=>{typeof s.unref=="function"&&s.unref(),r(!0)})}catch{r(!1)}})}function G(n,e=process.platform,i=T){return new Promise(t=>{let o,r;e==="darwin"?(o="pbcopy",r=[]):e==="win32"?(o="clip",r=[]):(o="xclip",r=["-selection","clipboard"]);try{let s=i(o,r,{stdio:["pipe","ignore","ignore"],windowsHide:!0});s.on("error",()=>{t(!1)}),s.on("close",c=>{t(c===0)}),s.stdin?(s.stdin.on("error",()=>{t(!1)}),s.stdin.write(n,"utf-8"),s.stdin.end()):t(!1)}catch{t(!1)}})}async function E(n){let{resources:e}=k(n),i=await p(n,{inspectDocker:!1}),{appBase:t}=w(i?.ingressHttp,n);return e.filter(o=>o.config?.appType==="frontend").map(o=>({name:o.name,url:`${t}${y(o)}`}))}async function H(n,e=2e3){try{return(await fetch(n,{signal:AbortSignal.timeout(e)})).status<500}catch{return!1}}async function j(n,e=3e4,i){if(n.length===0)return;let t=Date.now(),o=t+e;for(;;){for(let s of n)if(await H(s.url))return s;let r=Date.now()-t;if(r>=e)return;i?.(r),await new Promise(s=>setTimeout(s,2e3))}}async function te(n,e=0,i){let t=await E(n);return j(t,e,i)}async function _(n){let e=n??m();if(!e)return console.log(a.yellow("Not in a Flisk project, so there is no frontend to open.")),console.log(a.gray("Run `flisk project --yes` first, or `flisk open` inside a project.")),null;let i=await E(e);if(i.length===0)return console.log(a.yellow("This project has no frontend service to open.")),console.log(a.gray("Start the stack with `flisk up` and add a frontend with `flisk resource`.")),null;let t=b(e);g(`Opening the first frontend of ${t??"this project"}`);for(let c of i)console.log(a.gray(` - ${c.name}: ${c.url}`));let o=S("Waiting for the frontend to answer..."),r=await j(i,12e4,c=>{o.text=`Waiting for the frontend to answer... ${Math.round(c/1e3)}s`});if(!r){o.fail("No frontend answered yet.");let l=(await p(e,{inspectDocker:!1}))?.ingressHttp,A=l?await P(l)==="in-use":!1;l&&!A?(console.log(a.yellow(`The stack is running, but this machine cannot reach port ${l}.`)),console.log(a.gray(" Docker is not publishing the port to the host.")),console.log(a.gray(" Restart Docker Desktop, then run `flisk open` again."))):(console.log(a.yellow("The stack is not serving the frontend yet.")),console.log(a.gray(" - Start the stack in another terminal: flisk up")),console.log(a.gray(" - Then run this again: flisk open")));for(let f of i)console.log(a.gray(` - ${f.name}: ${f.url}`));return null}o.succeed(`The frontend is up: ${r.name}`);let s=await $(r.url);return console.log(s?a.green(`
3
- Opened ${r.url}`):a.yellow(`
4
- Could not open a browser. Open ${r.url} yourself.`)),h("Run `flisk open` again to open the next frontend."),r.url}var oe=new F("open").description("Open the first frontend of the project in your browser").action(async()=>{await _()});export{J as a,b,$ as c,G as d,E as e,H as f,j as g,te as h,_ as i,oe as j};
@@ -1,2 +0,0 @@
1
- import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{A as d,B as e,C as f,D as g,E as h,F as i,G as j,x as a,y as b,z as c}from"./chunk-GCFNSFW7.js";import"./chunk-R67UHACQ.js";import"./chunk-KXKBWLTE.js";import"./chunk-42IVF3YT.js";import"./chunk-M6S25PIS.js";import"./chunk-5ZSZ4WCI.js";import"./chunk-LYOSHFYU.js";import"./chunk-CF46CD6R.js";import"./chunk-6EA4DGCY.js";export{c as MACHINE_CHECK_IDS,a as RUNTIME_CHECK_IDS,b as SCAFFOLD_CHECK_IDS,h as assertMachineReadyOrExit,i as detectRuntimePrerequisites,g as formatColdPreflight,j as formatRuntimeNextSteps,d as nodeTooOld,e as requireVerifiedDockerVersions,f as runColdPreflight};
@@ -1,2 +0,0 @@
1
- import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import"./chunk-6EA4DGCY.js";import{execFile as m}from"node:child_process";async function g(e,r="tilt"){let a=await new Promise(n=>{m(r,["get","uiresources","-o","json","--port",String(e)],{timeout:15e3,maxBuffer:16777216},(u,i)=>n(u?null:i))});if(!a)return;let o=[];try{o=JSON.parse(a).items??[]}catch{return}let t=[],d=[],l=0,c=0,f=0,p=0;for(let n of o){let u=n.metadata?.name??"unknown",i=n.status?.updateStatus??"",s=n.status?.runtimeStatus??"";if(i==="error"||s==="error"){p+=1,d.push({name:u,message:(n.status?.buildHistory?.[0]?.error??"the resource failed").replace(/\s+/g," ").slice(0,160)});continue}if(i==="ok"&&(s==="ok"||s==="not_applicable"||s==="")){l+=1;continue}if(i==="pending"||i===""){f+=1,t.push({name:u,state:s||"pending"});continue}c+=1,t.push({name:u,state:i})}return{ready:l,building:c,pending:f,failed:p,total:o.length,working:t,broken:d}}function $(e){let r=Math.floor(e.elapsed/60),a=Math.round(e.elapsed%60),o=r>0?`${r}m ${a}s`:`${a}s`,t=[`${e.ready}/${e.total} resources ready`,o];return e.building>0&&t.push(`${e.building} building`),e.pending>0&&t.push(`${e.pending} queued`),e.failed>0&&t.push(`${e.failed} failed`),t.join(" \xB7 ")}export{$ as formatProgress,g as readStackProgress};