@flisk-sh/flisk 1.3.200 → 1.3.201

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.
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  import chalk from "chalk";
4
4
  import { Command } from "commander";
5
+ import { probeHostPort } from "../utils/doctor-runtime.js";
5
6
  import { showDetail, showStep } from "../utils/formatting.js";
6
7
  import { getHostPortPlan } from "../utils/host-port-config.js";
7
8
  import { findProjectRoot } from "../utils/paths.js";
@@ -89,9 +90,21 @@ export async function openFirstFrontend(projectRootOverride) {
89
90
  });
90
91
  if (!first) {
91
92
  spinner.fail("No frontend answered yet.");
92
- console.log(chalk.yellow("The stack is not serving the frontend yet."));
93
- console.log(chalk.gray(" - Start the stack in another terminal: flisk up"));
94
- console.log(chalk.gray(" - Then run this again: flisk open"));
93
+ const plan = await getHostPortPlan(projectRoot, { inspectDocker: false });
94
+ const ingress = plan?.ingressHttp;
95
+ const reachable = ingress ? (await probeHostPort(ingress)) === "in-use" : false;
96
+ if (ingress && !reachable) {
97
+ // The stack is up but this machine cannot reach the published port: Docker is not
98
+ // publishing it to the host. Saying that is more useful than "not serving yet".
99
+ console.log(chalk.yellow(`The stack is running, but this machine cannot reach port ${ingress}.`));
100
+ console.log(chalk.gray(" Docker is not publishing the port to the host."));
101
+ console.log(chalk.gray(" Restart Docker Desktop, then run `flisk open` again."));
102
+ }
103
+ else {
104
+ console.log(chalk.yellow("The stack is not serving the frontend yet."));
105
+ console.log(chalk.gray(" - Start the stack in another terminal: flisk up"));
106
+ console.log(chalk.gray(" - Then run this again: flisk open"));
107
+ }
95
108
  for (const target of targets) {
96
109
  console.log(chalk.gray(` - ${target.name}: ${target.url}`));
97
110
  }
@@ -30,7 +30,9 @@ export async function readStackProgress(port, tiltBin = "tilt") {
30
30
  failed += 1;
31
31
  broken.push({
32
32
  name,
33
- message: (item.status?.buildHistory?.[0]?.error ?? "the resource failed").replace(/\s+/g, " ").slice(0, 160),
33
+ message: (item.status?.buildHistory?.[0]?.error ?? "the resource failed")
34
+ .replace(/\s+/g, " ")
35
+ .slice(0, 160),
34
36
  });
35
37
  continue;
36
38
  }
@@ -39,15 +39,22 @@ export function checkExpectedResources(jsonText, expected) {
39
39
  disabled: expected.filter((name) => byName.get(name)?.status?.disableStatus?.state === "Disabled"),
40
40
  };
41
41
  }
42
+ /** Resources that report on the stack without gating it. */
43
+ export function isAdvisoryResource(name) {
44
+ return name.endsWith("-typecheck");
45
+ }
42
46
  /**
43
47
  * One look at `tilt get uiresources -o json`. `settled` means polling can stop: everything is ready, or the rest has
44
48
  * finished with a failure (an errored resource, or an expected service Tilt has disabled).
45
49
  */
46
50
  export function evaluateTiltReadiness(jsonText, deferred, expected) {
47
51
  const parsed = parseTiltResourceFailures(onlyEnabledResources(jsonText), deferred);
52
+ // A `<service>-typecheck` resource runs on the host and is advisory: it reports type errors
53
+ // in Tilt, it does not decide whether the stack is up. It must not fail the stack.
54
+ const blocking = parsed.failures.filter((failure) => !isAdvisoryResource(failure.name));
48
55
  let result = {
49
- ready: parsed.failures.length === 0 && parsed.pendingCount === 0 && parsed.okCount > 0,
50
- failures: parsed.failures.map((failure) => ({
56
+ ready: blocking.length === 0 && parsed.pendingCount === 0 && parsed.okCount > 0,
57
+ failures: blocking.map((failure) => ({
51
58
  name: failure.name,
52
59
  message: failure.error || `${failure.updateStatus}/${failure.runtimeStatus}`,
53
60
  })),
@@ -1,2 +1,2 @@
1
1
  import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{Ta as _,cb as A,d as u,k as S}from"./chunk-LMHKXU2Q.js";import{existsSync as w,readFileSync as h}from"node:fs";import{join as i}from"node:path";var O=["postgres",u],y=["pre_alpha","alpha","beta","out_of_scope"];function D(e){return O.includes(e)}function b(e){try{return JSON.parse(h(i(e,".tdk",S),"utf-8"))}catch{return}}function d(e){try{return w(e)?h(e,"utf-8"):void 0}catch{return}}function k(e,s){let n=r=>{let t=r;for(;t<e.length&&/\s/.test(e[t]);)t+=1;return t},a=0;for(;;){let r=e.indexOf(s,a);if(r===-1)return;let t=n(r+s.length);if(e[t]==="="&&(t=n(t+1),e[t]==="[")){let o=e.indexOf("]",t+1);return o===-1?void 0:[...e.slice(t+1,o).matchAll(/"([^"]+)"|'([^']+)'/g)].map(f=>f[1]??f[2]??"")}a=r+s.length}}function N(e){let s=i(e,".tdk",".tdk-out","Tiltfile"),n=d(s);if(n)return k(n,"ALWAYS_ENABLED_INFRA")}function M(e){let s=i(e,".tdk",".tdk-out","spec.master"),n=d(s);if(n!==void 0)return/"database-management"\s*:\s*True/.test(n)}function x(e){let s=i(e,".tdk",".tdk-out"),n=d(i(s,"Tiltfile")),a=d(i(s,"spec.master")),r=d(i(s,"tdk-cli-ext","discovery","config.star")),t=d(i(s,"tdk-cli-ext","engine","topologies","tilt","config","profiles.star"));if(!n||!a||!r||!t)return!1;let o=a.match(/PRE_ALPHA_RESOURCES\s*=\s*\{([^}]*)\}/)?.[1],f=k(r,"CORE_INFRA");return/FOCUS_MODE\s*,\s*FOCUS_ENABLED_ALL\s*,\s*FOCUS_ENABLED_RESOURCES\s*=\s*Config\.apply_focus\(cfg\)/.test(n)&&/if FOCUS_MODE and FOCUS_ENABLED_ALL\s*:/.test(n)&&/"[^"]+"\s*:\s*True|'[^']+'\s*:\s*True/.test(o??"")&&(f?.includes("postgres")??!1)&&/["']postgres["']\s*:\s*["']database-management["']/.test(r)&&/for infra in CORE_INFRA_EXPORT\s*:/.test(t)&&/needed\[INFRA_STACK_MAP_EXPORT\[infra\]\]\s*=\s*True/.test(t)}function C(e){let s=b(e);if(!s)return!1;let n=s.phases??{};for(let r of y){let t=n[r]?.enabledStacks;if(Array.isArray(t)&&t.includes(u))return!0}let a=s.always_enabled_infra??A;return Array.isArray(a)&&a.includes(u)}function L(e,s){let n=new Set;for(let t of O)n.add(t);for(let t of s)n.add(t.name),t.stack&&n.add(t.stack);let a=b(e);if(a){let t=a.phases??{};for(let f of y){let l=t[f]?.enabledStacks;if(Array.isArray(l))for(let c of l)n.add(c)}let o=a.always_enabled_infra??A;if(Array.isArray(o))for(let f of o)n.add(f)}let r=N(e);if(Array.isArray(r))for(let t of r)n.add(t);return n}function $(e,s=_(e)){let n=C(e),a=N(e),r=Array.isArray(a)&&a.includes(u),t=M(e)===!0,o=n||r||t,f=!n&&x(e),l=L(e,s),c=[],E=[];for(let p of s){let P=p.config?.dependsOn??[],g=!1;for(let m of P){if(D(m)){g=!0;continue}l.has(m)||E.push({resource:p.name,name:m})}g&&c.push(p.name)}let T=o||c.length>0,F=o?"feature":c.length>0?"dependsOn":"none";return{featureOn:o,featureOnFromProjectJson:n,featureOnFromTiltfile:r,featureOnFromSpecMaster:t,focusWouldEnableDatabaseManagement:f,dependsOnUsers:c,willStart:T,reason:F,unknownDependsOnNames:E}}export{O as a,$ as b};
2
+ import{Ta as _,cb as A,d as u,k as S}from"./chunk-LYOSHFYU.js";import{existsSync as w,readFileSync as h}from"node:fs";import{join as i}from"node:path";var O=["postgres",u],y=["pre_alpha","alpha","beta","out_of_scope"];function D(e){return O.includes(e)}function b(e){try{return JSON.parse(h(i(e,".tdk",S),"utf-8"))}catch{return}}function d(e){try{return w(e)?h(e,"utf-8"):void 0}catch{return}}function k(e,s){let n=r=>{let t=r;for(;t<e.length&&/\s/.test(e[t]);)t+=1;return t},a=0;for(;;){let r=e.indexOf(s,a);if(r===-1)return;let t=n(r+s.length);if(e[t]==="="&&(t=n(t+1),e[t]==="[")){let o=e.indexOf("]",t+1);return o===-1?void 0:[...e.slice(t+1,o).matchAll(/"([^"]+)"|'([^']+)'/g)].map(f=>f[1]??f[2]??"")}a=r+s.length}}function N(e){let s=i(e,".tdk",".tdk-out","Tiltfile"),n=d(s);if(n)return k(n,"ALWAYS_ENABLED_INFRA")}function M(e){let s=i(e,".tdk",".tdk-out","spec.master"),n=d(s);if(n!==void 0)return/"database-management"\s*:\s*True/.test(n)}function x(e){let s=i(e,".tdk",".tdk-out"),n=d(i(s,"Tiltfile")),a=d(i(s,"spec.master")),r=d(i(s,"tdk-cli-ext","discovery","config.star")),t=d(i(s,"tdk-cli-ext","engine","topologies","tilt","config","profiles.star"));if(!n||!a||!r||!t)return!1;let o=a.match(/PRE_ALPHA_RESOURCES\s*=\s*\{([^}]*)\}/)?.[1],f=k(r,"CORE_INFRA");return/FOCUS_MODE\s*,\s*FOCUS_ENABLED_ALL\s*,\s*FOCUS_ENABLED_RESOURCES\s*=\s*Config\.apply_focus\(cfg\)/.test(n)&&/if FOCUS_MODE and FOCUS_ENABLED_ALL\s*:/.test(n)&&/"[^"]+"\s*:\s*True|'[^']+'\s*:\s*True/.test(o??"")&&(f?.includes("postgres")??!1)&&/["']postgres["']\s*:\s*["']database-management["']/.test(r)&&/for infra in CORE_INFRA_EXPORT\s*:/.test(t)&&/needed\[INFRA_STACK_MAP_EXPORT\[infra\]\]\s*=\s*True/.test(t)}function C(e){let s=b(e);if(!s)return!1;let n=s.phases??{};for(let r of y){let t=n[r]?.enabledStacks;if(Array.isArray(t)&&t.includes(u))return!0}let a=s.always_enabled_infra??A;return Array.isArray(a)&&a.includes(u)}function L(e,s){let n=new Set;for(let t of O)n.add(t);for(let t of s)n.add(t.name),t.stack&&n.add(t.stack);let a=b(e);if(a){let t=a.phases??{};for(let f of y){let l=t[f]?.enabledStacks;if(Array.isArray(l))for(let c of l)n.add(c)}let o=a.always_enabled_infra??A;if(Array.isArray(o))for(let f of o)n.add(f)}let r=N(e);if(Array.isArray(r))for(let t of r)n.add(t);return n}function $(e,s=_(e)){let n=C(e),a=N(e),r=Array.isArray(a)&&a.includes(u),t=M(e)===!0,o=n||r||t,f=!n&&x(e),l=L(e,s),c=[],E=[];for(let p of s){let P=p.config?.dependsOn??[],g=!1;for(let m of P){if(D(m)){g=!0;continue}l.has(m)||E.push({resource:p.name,name:m})}g&&c.push(p.name)}let T=o||c.length>0,F=o?"feature":c.length>0?"dependsOn":"none";return{featureOn:o,featureOnFromProjectJson:n,featureOnFromTiltfile:r,featureOnFromSpecMaster:t,focusWouldEnableDatabaseManagement:f,dependsOnUsers:c,willStart:T,reason:F,unknownDependsOnNames:E}}export{O as a,$ as b};
@@ -0,0 +1,52 @@
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};
@@ -0,0 +1,4 @@
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,5 +1,5 @@
1
1
  import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{c as z,e as Q}from"./chunk-42IVF3YT.js";import{Fa as J,Ga as B,Qa as O,Ta as Y,cb as X,d as v,e as k,g as q,ga as L,h as x,i as P,j as F,k as W,l as A,p as d,q as N}from"./chunk-LMHKXU2Q.js";import{b as V}from"./chunk-CF46CD6R.js";import{a as $}from"./chunk-6EA4DGCY.js";import{appendFileSync as le,existsSync as C,mkdirSync as fe,readFileSync as de,writeFileSync as Z}from"node:fs";import{dirname as pe,resolve as w}from"node:path";function ft(t,e,n){for(let[r,s]of e.entries())console.log(V.blue(`${s.emoji} ${s.description}...`)),s.type==="json"?me(t,s.filename,s.content):he(t,s.filename,String(s.content)),n&&n(s,r,e.length)}function ue(t,e,n=2){let r=`${JSON.stringify(e,null,n)}
2
+ import{c as z,e as Q}from"./chunk-42IVF3YT.js";import{Fa as J,Ga as B,Qa as O,Ta as Y,cb as X,d as v,e as k,g as q,ga as L,h as x,i as P,j as F,k as W,l as A,p as d,q as N}from"./chunk-LYOSHFYU.js";import{b as V}from"./chunk-CF46CD6R.js";import{a as $}from"./chunk-6EA4DGCY.js";import{appendFileSync as le,existsSync as C,mkdirSync as fe,readFileSync as de,writeFileSync as Z}from"node:fs";import{dirname as pe,resolve as w}from"node:path";function ft(t,e,n){for(let[r,s]of e.entries())console.log(V.blue(`${s.emoji} ${s.description}...`)),s.type==="json"?me(t,s.filename,s.content):he(t,s.filename,String(s.content)),n&&n(s,r,e.length)}function ue(t,e,n=2){let r=`${JSON.stringify(e,null,n)}
3
3
  `;Z(t,r,"utf-8")}function me(t,e,n,r=2){let s=w(t,e);ue(s,n,r)}function U(t,e){Z(t,e,"utf-8")}function he(t,e,n){let r=w(t,e);U(r,n)}function dt(t){C(t)||fe(t,{recursive:!0})}var ge=[".env",".tdk/.tdk-out/",".tdk/.project-id",".tdk/smoke/","node_modules/"];function Se(t){let e=w(t,".gitignore"),n=C(e)?de(e,"utf-8"):"",r=new Set(n.split(`
4
4
  `).map(f=>f.trim().replace(/\/$/,""))),s=ge.filter(f=>!r.has(f.replace(/\/$/,"")));if(s.length===0)return[];let c=n&&!n.endsWith(`
5
5
  `)?`
@@ -1,5 +1,5 @@
1
1
  import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{b as f}from"./chunk-CF46CD6R.js";var ar="Container Runtime",_="bring-your-own";var De="database-management",cr=".tiltignore",Ie="service.json",Q="docker-compose.yml",ur=".autogenerated",Ct="TILT_TECH_STACK.star",Dt="TILT_RESOURCE_DEFAULTS.star",B="project.json",je="package.json",fr=[Ct,Dt,"spec.master"],pr=["backend","frontend","library","sdk","worker","migrator","mcp","agent",_],lr={backend:["dev","build","start"],worker:["dev","build","start"],migrator:["dev","build","start"],mcp:["dev","build","start"],agent:["dev","build","start"],frontend:["dev","build"],library:["dev","build"],sdk:["dev","build"],[_]:[]};var Z=["monitoring","elk","debezium","golden_image","verdaccio"],dr={frontend:{base:3e3,min:3e3,max:3999,range:"3000-3999"},backend:{base:4e3,min:4e3,max:4999,range:"4000-4999"},mcp:{base:4e3,min:4e3,max:5999,range:"4000-5999"},agent:{base:4e3,min:4e3,max:5999,range:"4000-5999"},[_]:{base:4e3,min:4e3,max:5999,range:"4000-5999"},worker:{base:6e3,min:6e3,max:6999,range:"6000-6999"},health:{base:5e3,min:5e3,max:5999,range:"5000-5999"},migrator:{base:7e3,min:7e3,max:7999,range:"7000-7999"}},mr={tiltUi:10350,traefik:8080},ee="https://flisk.sh/docs/quickstart/";var Ne=["node_modules",".git",".tilt",".tilt-engine","dist","build",".prisma",".turbo","coverage","tmp","temp","__tests__","test","tests",".github",".vscode","docs"],Pe=["Dockerfile",Q,"docker-compose.yaml","Tiltfile","vite.config.ts","tsconfig.json","tsconfig.build.json"],It={infra:"\u{1F3D7}\uFE0F",core:"\u{1F527}",api:"\u26A1",app:"\u{1F3A8}",orchestrator:"\u2699\uFE0F"};function hr(e){let t=e.toLowerCase();for(let[n,r]of Object.entries(It))if(t.includes(n))return r;return"\u{1F4E6}"}import{existsSync as Nt}from"node:fs";import{dirname as Pt,join as Ft,resolve as Ue}from"node:path";import{cwd as Ut}from"node:process";var Fe={name:"tdk-cli-internal",private:!0,version:"1.3.200",description:"Flisk CLI \u2014 start services on your machine.",keywords:["flisk","tilt","cli","local-dev","microservices"],homepage:"https://github.com/flisk-sh/flisk#readme",bugs:{url:"https://github.com/flisk-sh/flisk/issues"},repository:{type:"git",url:"git+https://github.com/flisk-sh/flisk.git",directory:"cli"},license:"MIT",author:"Flisk Team",type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",bin:{flisk:"bin/tdk.js"},files:["dist","dist-bundle","bin","templates","README.md","Tiltfile","engine","discovery","specs","ext","!ext/ide-components/code_executor","shared-platform-engineering/docker-templates"],scripts:{build:"tsc && node scripts/bundle.mjs","build:watch":"tsc --watch","check:dist":"npm run build && ../scripts/check-cli-dist.sh",lint:"biome check .","lint:fix":"biome check . --write",typecheck:"tsc --project tsconfig.typecheck.json",clean:"rm -rf dist",dev:"bun run build:watch",test:"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage --coverage.reportOnFailure --coverage.reporter=text --coverage.reporter=html --coverage.reporter=json-summary --coverage.reporter=json --coverage.reportsDirectory=coverage --reporter=default --reporter=json --outputFile.json=test-results/vitest.json",prepack:"../scripts/stage-npm-engine.sh && npm run build"},dependencies:{commander:"^15.0.0",handlebars:"^4.7.8"},devDependencies:{"@biomejs/biome":"^2.5.13","@types/node":"^22.0.0","@types/react":"^19.3.0","@vitest/coverage-v8":"^5.0.2",ajv:"^8.17.1",chalk:"^6.0.1",esbuild:"^0.28.2",ink:"^8.0.0",knip:"^6.38.0",react:"^19.3.0","react-devtools-core":"^8.0.0",typescript:"^7.0.2",vite:"^8.3.3",vitest:"^5.0.0"},engines:{node:">=22.12.0"}};function E(e=Ut()){let t=Ue(e),n=Ue("/");for(;t!==n;){if(Nt(Ft(t,".tdk",B)))return t;let r=Pt(t);if(r===t)break;t=r}return null}var V=null;function Mt(){if(V)return V;let e=Fe;if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid package.json: expected object");let t=e;return V={name:String(t.name??"@flisk-sh/flisk"),version:String(t.version??"0.0.0"),fullPackage:t},V}function wr(){return Mt().version}import{existsSync as Me}from"node:fs";import{delimiter as Le,extname as Be,join as Ve}from"node:path";import{delimiter as br,extname as Lt}from"node:path";function U(){return process.platform==="win32"}function Bt(e){return e==="linux"?"linux":e==="darwin"?"darwin":e==="win32"?"windows":null}function Vt(e){return e==="x64"?"amd64":e==="arm64"?"arm64":null}function Gt(e,t){let n=Bt(e),r=Vt(t);if(!n||!r||n==="windows"&&r!=="amd64")return null;let o=`tdk-${n}-${r}`;return n==="windows"?`${o}.exe`:o}function Ar(){return Gt(process.platform,process.arch)}function Rr(){return U()?"tdk.exe":"flisk"}function te(e,t=U()){return t?Lt(e)?[e]:[e,`${e}.exe`,`${e}.cmd`,`${e}.bat`]:[e]}function G(e){let t=process.env.PATH??process.env.Path??"",n=U(),r=te(e,n);if(n&&!Be(e))for(let o of(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";")){let s=o.toLowerCase();s&&!r.includes(`${e}${s}`)&&r.push(`${e}${s}`)}for(let o of t.split(Le))if(o)for(let s of r){let i=Ve(o,s);if(Me(i))return i}return null}function Ir(e){let t=process.env.PATH??process.env.Path??"",n=U(),r=te(e,n);if(n&&!Be(e))for(let i of(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";")){let a=i.toLowerCase();a&&!r.includes(`${e}${a}`)&&r.push(`${e}${a}`)}let o=[],s=new Set;for(let i of t.split(Le))if(i)for(let a of r){let c=Ve(i,a);if(!Me(c))continue;let p=n?c.toLowerCase():c;s.has(p)||(s.add(p),o.push(c))}return o}import{execFileSync as Wt,execSync as Kt}from"node:child_process";var Ge=1e4;function We(){let e=!1;if(process.platform==="win32")try{return Wt(G("docker")??"docker",["ps"],{stdio:"ignore",timeout:Ge,windowsHide:!0}),"running"}catch(t){return t.code==="ETIMEDOUT"?"unresponsive":"missing"}for(let t of["docker ps","colima status","podman ps"])try{return Kt(t,{stdio:"ignore",timeout:Ge}),"running"}catch(n){n.code==="ETIMEDOUT"&&(e=!0)}return e?"unresponsive":"missing"}function W(e,t){return e[t]??0}function Ht(e,t){let n=Array.from({length:t.length+1},(r,o)=>o);for(let r=1;r<=e.length;r++){let o=[r];for(let s=1;s<=t.length;s++){let i=e[r-1]===t[s-1]?0:1;o[s]=Math.min(W(o,s-1)+1,W(n,s)+1,W(n,s-1)+i)}n=o}return W(n,t.length)}function zt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length-1;n++)if(e[n]!==t[n]&&e[n]===t[n+1]&&e[n+1]===t[n]&&e.slice(0,n)===t.slice(0,n)&&e.slice(n+2)===t.slice(n+2))return!0;return!1}function Ke(e,t){if(e.length<2||t.length===0||t.includes(e))return;let n=e.toLowerCase(),r,o=Number.POSITIVE_INFINITY;for(let s of t){if(s.length===0)continue;let i=s.toLowerCase(),a=zt(n,i)?1:Ht(n,i),c=Math.max(1,Math.min(2,Math.floor(Math.max(n.length,i.length)/3)));a>c||(a<o||a===o&&(r===void 0||s<r))&&(r=s,o=a)}return r}import{spawn as Jt}from"node:child_process";import{join as qt}from"node:path";function Yt(e,t=[],n={}){return new Promise((r,o)=>{let s=[e,...t];n.verbose&&console.log(`Executing: tilt ${s.join(" ")}`);let i=Jt(G("tilt")??"tilt",s,{stdio:n.inheritStdio?"inherit":"pipe",shell:!1,windowsHide:process.platform==="win32",timeout:n.timeoutMs}),a="",c="";n.inheritStdio||(i.stdout?.on("data",p=>{a+=p.toString()}),i.stderr?.on("data",p=>{c+=p.toString()})),i.on("close",p=>{r({exitCode:p??1,stdout:a,stderr:c})}),i.on("error",p=>{o(new Error(`Failed to spawn tilt: ${p.message}`))})})}async function He(){try{return(await Yt("version",[],{inheritStdio:!1,timeoutMs:1e4})).exitCode===0}catch{return!1}}function Xt(){let e=E();if(!e)throw $.notInProject();return qt(e,".tdk",".tdk-out","Tiltfile")}function ze(e){let t=Xt();e.push("-f",t)}function Wr(e,t={}){let n=[];return ze(n),t.focusTargets&&t.focusTargets.length>0&&n.push("--",`--focus=${t.focusTargets.join(",")}`),n.push(...e),t.verbose&&!t.quiet&&n.push("--verbose"),t.watch&&n.push("--watch"),n}function Kr(e={}){let t=[];return ze(t),e.focusTargets&&e.focusTargets.length>0&&t.push("--",`--focus=${e.focusTargets.join(",")}`),t}function Je(e){return e instanceof Error?e.message:String(e)}function Zr(e,t){if(process.env.TDK_VERBOSE){let n=t!==void 0?`: ${Je(t)}`:"";console.warn(f.gray(`${e}${n}`))}}var S=class extends Error{suggestions;exitCode;constructor(t,n=[],r=1){super(t),this.name="TdkError",this.suggestions=n,this.exitCode=r}display(){oe(this.message,void 0,this.suggestions)}exit(){this.display(),process.exit(this.exitCode)}},re=class extends Error{code;constructor(t=1){super(`process.exit(${t})`),this.name="ProcessExitError",this.code=t}};function ne(e,t,n=!1){let r=new Set;for(let o of e){let s=Ke(o,t);s&&r.add(n?`Did you mean "${s}" for "${o}"?`:`Did you mean "${s}"?`)}return[...r]}var $={tiltNotInstalled:()=>new S("Tilt CLI is not installed",["Install Tilt: `brew install tilt` (macOS)","Or download from: https://docs.tilt.dev/install.html","Verify with: `tilt version`",`Setup guide: ${ee}`]),dockerNotAvailable:()=>new S("Docker (or a compatible container runtime) is not running",["Start Docker Desktop, then verify with: `docker ps`","Or start Colima: `colima start`","Or start the Docker service on Linux: `sudo systemctl start docker`",`Setup guide: ${ee}`]),dockerNotResponding:()=>new S("Docker is running but not responding (`docker ps` hung for 10s)",["Quit and reopen Docker Desktop, or run `colima restart`","Then verify with: `docker ps`"]),stackNotFound:(e,t=[])=>new S(`Stack "${e}" not found`,[...ne([e],t),"Run `flisk stacks` to see available stacks","Run `flisk stack` to assign resources to a stack"]),resourceNotFound:(e,t=[])=>new S(`Resource "${e}" not found`,[...ne([e],t),"Run `flisk resources` to list all resources","Check the resource name spelling"]),unknownServices:(e,t)=>{let n=ne(e,t,e.length>1);return new S(`Unknown service ${e.join(", ")}. Valid names: ${t.join(", ")}`,n,2)},directoryExists:e=>new S(`Directory already exists: ${e}`,["Use `--path` to specify a different location","Remove the existing directory if no longer needed"]),invalidPath:e=>new S(`Invalid path: ${e}`,["Path must be within the project directory",'Path cannot contain special characters like <>:"|?*']),notInProject:()=>new S("Could not find project root (no .tdk/project.json found)",["Run this from within a Flisk project","Run `flisk project --yes` to initialize a new project"])};function eo(){let e=E();return e||$.notInProject().exit()}function Qt(e){e instanceof S&&e.exit(),oe(Je(e)),process.exit(1)}async function Zt(e,t){try{return await e()}catch(n){if(n instanceof re)throw n;return t?.verbose&&n instanceof Error&&n.stack&&console.error(f.gray(n.stack)),Qt(n)}}async function to(e,t){let n=[],r=We();return r==="unresponsive"?n.push($.dockerNotResponding()):r==="missing"&&n.push($.dockerNotAvailable()),await He()||n.push($.tiltNotInstalled()),n.length>0&&(console.error(f.red(`
2
+ import{b as f}from"./chunk-CF46CD6R.js";var ar="Container Runtime",_="bring-your-own";var De="database-management",cr=".tiltignore",Ie="service.json",Q="docker-compose.yml",ur=".autogenerated",Ct="TILT_TECH_STACK.star",Dt="TILT_RESOURCE_DEFAULTS.star",B="project.json",je="package.json",fr=[Ct,Dt,"spec.master"],pr=["backend","frontend","library","sdk","worker","migrator","mcp","agent",_],lr={backend:["dev","build","start"],worker:["dev","build","start"],migrator:["dev","build","start"],mcp:["dev","build","start"],agent:["dev","build","start"],frontend:["dev","build"],library:["dev","build"],sdk:["dev","build"],[_]:[]};var Z=["monitoring","elk","debezium","golden_image","verdaccio"],dr={frontend:{base:3e3,min:3e3,max:3999,range:"3000-3999"},backend:{base:4e3,min:4e3,max:4999,range:"4000-4999"},mcp:{base:4e3,min:4e3,max:5999,range:"4000-5999"},agent:{base:4e3,min:4e3,max:5999,range:"4000-5999"},[_]:{base:4e3,min:4e3,max:5999,range:"4000-5999"},worker:{base:6e3,min:6e3,max:6999,range:"6000-6999"},health:{base:5e3,min:5e3,max:5999,range:"5000-5999"},migrator:{base:7e3,min:7e3,max:7999,range:"7000-7999"}},mr={tiltUi:10350,traefik:8080},ee="https://flisk.sh/docs/quickstart/";var Ne=["node_modules",".git",".tilt",".tilt-engine","dist","build",".prisma",".turbo","coverage","tmp","temp","__tests__","test","tests",".github",".vscode","docs"],Pe=["Dockerfile",Q,"docker-compose.yaml","Tiltfile","vite.config.ts","tsconfig.json","tsconfig.build.json"],It={infra:"\u{1F3D7}\uFE0F",core:"\u{1F527}",api:"\u26A1",app:"\u{1F3A8}",orchestrator:"\u2699\uFE0F"};function hr(e){let t=e.toLowerCase();for(let[n,r]of Object.entries(It))if(t.includes(n))return r;return"\u{1F4E6}"}import{existsSync as Nt}from"node:fs";import{dirname as Pt,join as Ft,resolve as Ue}from"node:path";import{cwd as Ut}from"node:process";var Fe={name:"tdk-cli-internal",private:!0,version:"1.3.201",description:"Flisk CLI \u2014 start services on your machine.",keywords:["flisk","tilt","cli","local-dev","microservices"],homepage:"https://github.com/flisk-sh/flisk#readme",bugs:{url:"https://github.com/flisk-sh/flisk/issues"},repository:{type:"git",url:"git+https://github.com/flisk-sh/flisk.git",directory:"cli"},license:"MIT",author:"Flisk Team",type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",bin:{flisk:"bin/tdk.js"},files:["dist","dist-bundle","bin","templates","README.md","Tiltfile","engine","discovery","specs","ext","!ext/ide-components/code_executor","shared-platform-engineering/docker-templates"],scripts:{build:"tsc && node scripts/bundle.mjs","build:watch":"tsc --watch","check:dist":"npm run build && ../scripts/check-cli-dist.sh",lint:"biome check .","lint:fix":"biome check . --write",typecheck:"tsc --project tsconfig.typecheck.json",clean:"rm -rf dist",dev:"bun run build:watch",test:"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage --coverage.reportOnFailure --coverage.reporter=text --coverage.reporter=html --coverage.reporter=json-summary --coverage.reporter=json --coverage.reportsDirectory=coverage --reporter=default --reporter=json --outputFile.json=test-results/vitest.json",prepack:"../scripts/stage-npm-engine.sh && npm run build"},dependencies:{commander:"^15.0.0",handlebars:"^4.7.8"},devDependencies:{"@biomejs/biome":"^2.5.13","@types/node":"^22.0.0","@types/react":"^19.3.0","@vitest/coverage-v8":"^5.0.2",ajv:"^8.17.1",chalk:"^6.0.1",esbuild:"^0.28.2",ink:"^8.0.0",knip:"^6.38.0",react:"^19.3.0","react-devtools-core":"^8.0.0",typescript:"^7.0.2",vite:"^8.3.3",vitest:"^5.0.0"},engines:{node:">=22.12.0"}};function E(e=Ut()){let t=Ue(e),n=Ue("/");for(;t!==n;){if(Nt(Ft(t,".tdk",B)))return t;let r=Pt(t);if(r===t)break;t=r}return null}var V=null;function Mt(){if(V)return V;let e=Fe;if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid package.json: expected object");let t=e;return V={name:String(t.name??"@flisk-sh/flisk"),version:String(t.version??"0.0.0"),fullPackage:t},V}function wr(){return Mt().version}import{existsSync as Me}from"node:fs";import{delimiter as Le,extname as Be,join as Ve}from"node:path";import{delimiter as br,extname as Lt}from"node:path";function U(){return process.platform==="win32"}function Bt(e){return e==="linux"?"linux":e==="darwin"?"darwin":e==="win32"?"windows":null}function Vt(e){return e==="x64"?"amd64":e==="arm64"?"arm64":null}function Gt(e,t){let n=Bt(e),r=Vt(t);if(!n||!r||n==="windows"&&r!=="amd64")return null;let o=`tdk-${n}-${r}`;return n==="windows"?`${o}.exe`:o}function Ar(){return Gt(process.platform,process.arch)}function Rr(){return U()?"tdk.exe":"flisk"}function te(e,t=U()){return t?Lt(e)?[e]:[e,`${e}.exe`,`${e}.cmd`,`${e}.bat`]:[e]}function G(e){let t=process.env.PATH??process.env.Path??"",n=U(),r=te(e,n);if(n&&!Be(e))for(let o of(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";")){let s=o.toLowerCase();s&&!r.includes(`${e}${s}`)&&r.push(`${e}${s}`)}for(let o of t.split(Le))if(o)for(let s of r){let i=Ve(o,s);if(Me(i))return i}return null}function Ir(e){let t=process.env.PATH??process.env.Path??"",n=U(),r=te(e,n);if(n&&!Be(e))for(let i of(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";")){let a=i.toLowerCase();a&&!r.includes(`${e}${a}`)&&r.push(`${e}${a}`)}let o=[],s=new Set;for(let i of t.split(Le))if(i)for(let a of r){let c=Ve(i,a);if(!Me(c))continue;let p=n?c.toLowerCase():c;s.has(p)||(s.add(p),o.push(c))}return o}import{execFileSync as Wt,execSync as Kt}from"node:child_process";var Ge=1e4;function We(){let e=!1;if(process.platform==="win32")try{return Wt(G("docker")??"docker",["ps"],{stdio:"ignore",timeout:Ge,windowsHide:!0}),"running"}catch(t){return t.code==="ETIMEDOUT"?"unresponsive":"missing"}for(let t of["docker ps","colima status","podman ps"])try{return Kt(t,{stdio:"ignore",timeout:Ge}),"running"}catch(n){n.code==="ETIMEDOUT"&&(e=!0)}return e?"unresponsive":"missing"}function W(e,t){return e[t]??0}function Ht(e,t){let n=Array.from({length:t.length+1},(r,o)=>o);for(let r=1;r<=e.length;r++){let o=[r];for(let s=1;s<=t.length;s++){let i=e[r-1]===t[s-1]?0:1;o[s]=Math.min(W(o,s-1)+1,W(n,s)+1,W(n,s-1)+i)}n=o}return W(n,t.length)}function zt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length-1;n++)if(e[n]!==t[n]&&e[n]===t[n+1]&&e[n+1]===t[n]&&e.slice(0,n)===t.slice(0,n)&&e.slice(n+2)===t.slice(n+2))return!0;return!1}function Ke(e,t){if(e.length<2||t.length===0||t.includes(e))return;let n=e.toLowerCase(),r,o=Number.POSITIVE_INFINITY;for(let s of t){if(s.length===0)continue;let i=s.toLowerCase(),a=zt(n,i)?1:Ht(n,i),c=Math.max(1,Math.min(2,Math.floor(Math.max(n.length,i.length)/3)));a>c||(a<o||a===o&&(r===void 0||s<r))&&(r=s,o=a)}return r}import{spawn as Jt}from"node:child_process";import{join as qt}from"node:path";function Yt(e,t=[],n={}){return new Promise((r,o)=>{let s=[e,...t];n.verbose&&console.log(`Executing: tilt ${s.join(" ")}`);let i=Jt(G("tilt")??"tilt",s,{stdio:n.inheritStdio?"inherit":"pipe",shell:!1,windowsHide:process.platform==="win32",timeout:n.timeoutMs}),a="",c="";n.inheritStdio||(i.stdout?.on("data",p=>{a+=p.toString()}),i.stderr?.on("data",p=>{c+=p.toString()})),i.on("close",p=>{r({exitCode:p??1,stdout:a,stderr:c})}),i.on("error",p=>{o(new Error(`Failed to spawn tilt: ${p.message}`))})})}async function He(){try{return(await Yt("version",[],{inheritStdio:!1,timeoutMs:1e4})).exitCode===0}catch{return!1}}function Xt(){let e=E();if(!e)throw $.notInProject();return qt(e,".tdk",".tdk-out","Tiltfile")}function ze(e){let t=Xt();e.push("-f",t)}function Wr(e,t={}){let n=[];return ze(n),t.focusTargets&&t.focusTargets.length>0&&n.push("--",`--focus=${t.focusTargets.join(",")}`),n.push(...e),t.verbose&&!t.quiet&&n.push("--verbose"),t.watch&&n.push("--watch"),n}function Kr(e={}){let t=[];return ze(t),e.focusTargets&&e.focusTargets.length>0&&t.push("--",`--focus=${e.focusTargets.join(",")}`),t}function Je(e){return e instanceof Error?e.message:String(e)}function Zr(e,t){if(process.env.TDK_VERBOSE){let n=t!==void 0?`: ${Je(t)}`:"";console.warn(f.gray(`${e}${n}`))}}var S=class extends Error{suggestions;exitCode;constructor(t,n=[],r=1){super(t),this.name="TdkError",this.suggestions=n,this.exitCode=r}display(){oe(this.message,void 0,this.suggestions)}exit(){this.display(),process.exit(this.exitCode)}},re=class extends Error{code;constructor(t=1){super(`process.exit(${t})`),this.name="ProcessExitError",this.code=t}};function ne(e,t,n=!1){let r=new Set;for(let o of e){let s=Ke(o,t);s&&r.add(n?`Did you mean "${s}" for "${o}"?`:`Did you mean "${s}"?`)}return[...r]}var $={tiltNotInstalled:()=>new S("Tilt CLI is not installed",["Install Tilt: `brew install tilt` (macOS)","Or download from: https://docs.tilt.dev/install.html","Verify with: `tilt version`",`Setup guide: ${ee}`]),dockerNotAvailable:()=>new S("Docker (or a compatible container runtime) is not running",["Start Docker Desktop, then verify with: `docker ps`","Or start Colima: `colima start`","Or start the Docker service on Linux: `sudo systemctl start docker`",`Setup guide: ${ee}`]),dockerNotResponding:()=>new S("Docker is running but not responding (`docker ps` hung for 10s)",["Quit and reopen Docker Desktop, or run `colima restart`","Then verify with: `docker ps`"]),stackNotFound:(e,t=[])=>new S(`Stack "${e}" not found`,[...ne([e],t),"Run `flisk stacks` to see available stacks","Run `flisk stack` to assign resources to a stack"]),resourceNotFound:(e,t=[])=>new S(`Resource "${e}" not found`,[...ne([e],t),"Run `flisk resources` to list all resources","Check the resource name spelling"]),unknownServices:(e,t)=>{let n=ne(e,t,e.length>1);return new S(`Unknown service ${e.join(", ")}. Valid names: ${t.join(", ")}`,n,2)},directoryExists:e=>new S(`Directory already exists: ${e}`,["Use `--path` to specify a different location","Remove the existing directory if no longer needed"]),invalidPath:e=>new S(`Invalid path: ${e}`,["Path must be within the project directory",'Path cannot contain special characters like <>:"|?*']),notInProject:()=>new S("Could not find project root (no .tdk/project.json found)",["Run this from within a Flisk project","Run `flisk project --yes` to initialize a new project"])};function eo(){let e=E();return e||$.notInProject().exit()}function Qt(e){e instanceof S&&e.exit(),oe(Je(e)),process.exit(1)}async function Zt(e,t){try{return await e()}catch(n){if(n instanceof re)throw n;return t?.verbose&&n instanceof Error&&n.stack&&console.error(f.gray(n.stack)),Qt(n)}}async function to(e,t){let n=[],r=We();return r==="unresponsive"?n.push($.dockerNotResponding()):r==="missing"&&n.push($.dockerNotAvailable()),await He()||n.push($.tiltNotInstalled()),n.length>0&&(console.error(f.red(`
3
3
  Flisk can't start - missing prerequisites:
4
4
  `)),n.forEach((o,s)=>{s>0&&console.error(""),o.display()}),console.error(f.gray("\nRun `flisk doctor` for a full environment check.")),process.exit(1)),Zt(e,t)}function no(e,t=1,n){oe(e,void 0,n),process.exit(t)}function oe(e,t,n){if(console.error(f.red(`\u274C ${e}`)),t&&console.error(f.gray(` ${t}`)),n&&n.length>0){console.error(f.yellow(`
5
5
  \u{1F4A1} Suggestions:`));for(let r of n)console.error(f.cyan(` \u2192 ${r}`))}}function ro(e,t){console.error(f.red(`
@@ -1,5 +1,5 @@
1
1
  import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{b as N}from"./chunk-GEXOZCEQ.js";import{G as O,O as m,Ta as f,c as $,d as C,fa as T,g as U,h as E,k as F,l as P,s as l,x as M}from"./chunk-LMHKXU2Q.js";import{execFileSync as de,execSync as ue}from"node:child_process";import{existsSync as R,readdirSync as V,readFileSync as y}from"node:fs";import{basename as le,dirname as me,join as u,relative as k}from"node:path";function Oe(t){return I(t,!1)}function Ne(t){return I(t,!0)}function I(t,e){return`import { Hono } from 'hono';
2
+ import{b as N}from"./chunk-5ZSZ4WCI.js";import{G as O,O as m,Ta as f,c as $,d as C,fa as T,g as U,h as E,k as F,l as P,s as l,x as M}from"./chunk-LYOSHFYU.js";import{execFileSync as de,execSync as ue}from"node:child_process";import{existsSync as R,readdirSync as V,readFileSync as y}from"node:fs";import{basename as le,dirname as me,join as u,relative as k}from"node:path";function Oe(t){return I(t,!1)}function Ne(t){return I(t,!0)}function I(t,e){return`import { Hono } from 'hono';
3
3
  ${e?`import { sql } from 'drizzle-orm';
4
4
  import { db } from './db.js';
5
5
  `:""}
@@ -1,2 +1,2 @@
1
1
  import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{r as c}from"./chunk-RMZQU74X.js";import{execFileSync as u}from"node:child_process";import{realpathSync as l}from"node:fs";import{resolve as p}from"node:path";var m=(o,t)=>u(o,t,{encoding:"utf-8",stdio:"pipe",timeout:5e3,windowsHide:!0});function a(o,t=process.platform,e=m){if(t==="win32")return null;try{let s=e("lsof",["-nP",`-iTCP:${o}`,"-sTCP:LISTEN","-t"]).split(/\r?\n/).map(r=>r.trim()).filter(Boolean);for(let r of s){let n=e("ps",["-p",r,"-o","command="]).trim(),[i]=c(`${r} ${n}`);if(i)return i}}catch{}return null}function f(o){try{return l(o)}catch{return p(o)}}function d(o,t){return o!==null&&f(o.root)!==f(t)}async function P(o,t,e,s=a){let r={running:[],foreign:[]};for(let n of o){if(!await e(n))continue;let i=s(n);i&&d(i,t)?r.foreign.push({port:n,root:i.root}):r.running.push(n)}return r}export{a,d as b,P as c};
2
+ import{r as c}from"./chunk-M6S25PIS.js";import{execFileSync as u}from"node:child_process";import{realpathSync as l}from"node:fs";import{resolve as p}from"node:path";var m=(o,t)=>u(o,t,{encoding:"utf-8",stdio:"pipe",timeout:5e3,windowsHide:!0});function a(o,t=process.platform,e=m){if(t==="win32")return null;try{let s=e("lsof",["-nP",`-iTCP:${o}`,"-sTCP:LISTEN","-t"]).split(/\r?\n/).map(r=>r.trim()).filter(Boolean);for(let r of s){let n=e("ps",["-p",r,"-o","command="]).trim(),[i]=c(`${r} ${n}`);if(i)return i}}catch{}return null}function f(o){try{return l(o)}catch{return p(o)}}function d(o,t){return o!==null&&f(o.root)!==f(t)}async function P(o,t,e,s=a){let r={running:[],foreign:[]};for(let n of o){if(!await e(n))continue;let i=s(n);i&&d(i,t)?r.foreign.push({port:n,root:i.root}):r.running.push(n)}return r}export{a,d as b,P as c};
@@ -0,0 +1,24 @@
1
+ import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
+ import{O as h,Ta as D,Ua as L,fa as _,h as I,k as w,l as A,q as j,qa as x,s as T,x as F}from"./chunk-LYOSHFYU.js";import{execFileSync as B}from"node:child_process";import{existsSync as de,mkdirSync as le,readFileSync as K,realpathSync as fe,writeFileSync as pe}from"node:fs";import{join as S,resolve as he,sep as me}from"node:path";import{createServer as ie}from"node:net";import{connect as oe}from"node:net";function U(e,t=500){return new Promise(r=>{let s=oe({port:e,host:"127.0.0.1"}),n=o=>{s.destroy(),r(o)};s.setTimeout(t,()=>n(!1)),s.once("connect",()=>n(!0)),s.once("error",()=>n(!1))})}var ae={ingressHttp:{start:8080,end:8180},ingressHttps:{start:8443,end:8543},postgres:{start:15432,end:15532}},v={ingressHttp:"TDK_HTTP_PORT",ingressHttps:"TDK_HTTPS_PORT",postgres:"TDK_POSTGRES_PORT"},H={ingressHttp:80,ingressHttps:443,postgres:5432},E={ingressHttp:H.ingressHttp,ingressHttps:H.ingressHttps};function ce(e,t){return e==="EACCES"&&t==="darwin"}async function O(e){return await U(e)?!1:new Promise(t=>{let r=ie();r.once("error",s=>{t(ce(s.code,process.platform))}),r.listen(e,"127.0.0.1",()=>r.close(()=>t(!0)))})}function ue(e,t){let r=Number(t);if(!Number.isInteger(r)||r<1||r>65535)throw new Error(`${e} must be an integer between 1 and 65535 (received ${JSON.stringify(t)})`);return r}async function R(e={}){let t=e.env??process.env,r=e.isAvailable??O,s={ingressHttp:!1,ingressHttps:!1,postgres:!1},n={ingressHttp:"",ingressHttps:"",postgres:""},o={explicit:s},a=new Set;for(let c of["ingressHttp","ingressHttps","postgres"]){let u=t[v[c]],i=u!==void 0&&u.trim()!=="",d=e.ranges?.[c]??ae[c],l=E[c],f=i?[ue(v[c],u)]:[...l===void 0?[]:[l],...Array.from({length:d.end-d.start+1},(g,k)=>d.start+k)],m;for(let g of f)if(!a.has(g)){if(await r(g)){m=g;break}if(i)throw new Error(`${v[c]}=${g} is already in use. Choose a free host port and retry.`)}if(m===void 0)throw new Error(`No available host port in ${d.start}-${d.end} for ${c}. Set ${v[c]} to a free port and retry.`);a.add(m),o[c]=m,s[c]=i,n[c]=i?"explicit override":m===l?"requested port is free":`selected from fallback range ${d.start}-${d.end}`}return{...o,requested:{...H},reason:n}}function Ve(e){return`Host ports: HTTP ${e.ingressHttp}, HTTPS ${e.ingressHttps}, Postgres ${e.postgres}`}var G=S(".tdk",".tdk-out","host-ports.json");function ge(e,t,r){return e.split(`
3
+ `).some(s=>{let[n="",o=""]=s.split("|"),a=n.toLowerCase(),c=t.toLowerCase();return(a.startsWith(`${c}_`)||a.startsWith(`${c}-`))&&o.includes(`:${r}->`)})}function V(e){let t=S(e,G);if(!de(t))return null;try{let r=JSON.parse(K(t,"utf-8"));if(!r||typeof r!="object")return null;let s=r;return!Number.isInteger(s.ingressHttp)||!Number.isInteger(s.ingressHttps)||!Number.isInteger(s.postgres)||!s.requested||!s.explicit||!s.reason?null:s}catch{return null}}function Ye(e,t){let r=S(e,G);le(S(e,".tdk",".tdk-out"),{recursive:!0}),pe(r,`${JSON.stringify(t,null,2)}
4
+ `,{encoding:"utf-8",mode:384})}function Qe(e){process.env.TDK_HTTP_PORT=String(e.ingressHttp),process.env.TDK_HTTPS_PORT=String(e.ingressHttps),process.env.TDK_POSTGRES_PORT=String(e.postgres)}var ke="com.docker.compose.project.working_dir";function Pe(e,t,r){let s=new Set([he(t)]);try{s.add(fe(t))}catch{}return e.split(`
5
+ `).some(n=>{let[,o="",a=""]=n.split("|");return!a||!o.includes(`:${r}->`)?!1:[...s].some(c=>a===c||a.startsWith(`${c}${me}`))})}function Xe(e,t,r=()=>B("docker",["ps","--format",`{{.Names}}|{{.Ports}}|{{.Label "${ke}"}}`],{encoding:"utf-8",timeout:5e3})){let s=V(e);if(!s||s.ingressHttp===t)return t;try{if(Pe(r(),e,s.ingressHttp))return s.ingressHttp}catch{}return t}async function et(e,t={}){let r=V(e),s=["TDK_HTTP_PORT","TDK_HTTPS_PORT","TDK_POSTGRES_PORT"].some(i=>process.env[i]);if(t.inspectDocker===!1&&r&&!s)return r;let n="";try{let i=JSON.parse(K(S(e,".tdk",w),"utf-8"));n=String(i?.project?.name??"tdk-project").replace(/-/g,"_").toLowerCase()}catch{n="tdk_project"}let o="";if(t.inspectDocker!==!1)try{o=B("docker",["ps","--format","{{.Names}}|{{.Ports}}"],{encoding:"utf-8",timeout:5e3})}catch{}let a=i=>ge(o,n,i),c=t.isPortFree??O,u=async i=>await c(i)||a(i);if(r&&!s){for(let i of[r.ingressHttp,r.ingressHttps,r.postgres])if(!await u(i))return R({isAvailable:u});for(let[i,d]of Object.entries(E)){let l=r[i];if(d!==void 0&&l!==d&&await u(d))return R({isAvailable:u})}return r}return R({isAvailable:u})}import{execFileSync as Q,execSync as $}from"node:child_process";import{existsSync as C,readdirSync as Te,readFileSync as N}from"node:fs";import{createServer as Se}from"node:net";import{join as P}from"node:path";function W(e,t){return e==="pending"||e==="in_progress"||e==="none"||t==="pending"||t==="none"}var J="container is running, but its health check is failing";function M(e){let t=e?.runtimeStatus??"";if(t!=="ok")return t;let r=e?.composeResourceInfo?.healthStatus;return r==="unhealthy"?"error":r==="starting"?"pending":t}var b=1e4,z=3e3,be="http://localhost:4873";function X(e){return`'${e.replace(/'/g,"'\\''")}'`}function y(e,t,r,s,n){return process.platform==="win32"?Q(F(t)??t,r,{...n,windowsHide:!0}):e(s,n)}var ye=[80,443];function $e(e){return e.replace(/-/g,"_")}function we(e,t){let r=new Set(t),s=[];for(let n of e.split(`
6
+ `)){let o=n.trim();if(!o)continue;let a=o.indexOf(" "),c=a>=0?o.slice(0,a):o,u=a>=0?o.slice(a+1):"",i=[];for(let d of r)u.split(/[\s,]+/).some(f=>f.startsWith(`${d}->`)||f.includes(`:${d}->`))&&i.push(d);i.length>0&&s.push({name:c,ports:u,publishedPorts:i})}return s}function ee(e,t){let r=e.toLowerCase(),s=t.toLowerCase();return r===`${s}_traefik`||r.startsWith(`${s}_traefik`)}function ve(e,t){return e.filter(r=>!ee(r.name,t))}function Re(e){try{let t=e??L();return new Set(t.filter(r=>r.config?.sablier?.enable&&r.config?.sablier?.deferStart).map(r=>r.name))}catch{return new Set}}function _e(e,t=new Set){let s=JSON.parse(e).items??[],n=[],o=0,a=0,c=0;for(let u of s){let i=u.metadata?.name??"unknown",d=u.status?.updateStatus??"",l=M(u.status),f=l==="error"&&u.status?.runtimeStatus==="ok",g=(u.status?.buildHistory?.[0]?.error??"").trim()||(f?J:"");if(d==="error"||l==="error"){n.push({name:i,updateStatus:d,runtimeStatus:l,error:g.replace(/\s+/g," ").slice(0,800)});continue}if(d==="ok"&&(l==="ok"||l==="not_applicable")){c+=1;continue}i!=="(Tiltfile)"&&W(d,l)&&(t.has(i)?a+=1:o+=1)}return{failures:n,pendingCount:o,deferredCount:a,okCount:c,total:s.length}}var xe=/failed to resolve source metadata for docker\.io\/library\/([A-Za-z0-9._-]+-l[1-4](?:-[a-z]+)*)(?::[^\s:]+)?:/i;function te(e){let t=e.replace(/\s+/g," ").trim(),r=t.match(/Bind for [^ ]+:(\d+) failed: port is already allocated/i);if(r)return`host port ${r[1]} is already allocated`;if(/port is already allocated/i.test(t))return"a required host port is already allocated";let s=[...t.matchAll(/ConnectionRefused downloading package manifest (@[A-Za-z0-9._/-]+)/gi)].map(c=>c[1]);if(s.length>0){let c=[...new Set(s)],u=c.slice(0,4).join(", "),i=c.length>4?` (+${c.length-4} more)`:"";return`private registry ConnectionRefused for ${u}${i} \u2014 Verdaccio (:4873) is down or unreachable from the build`}let n=t.match(xe);if(n)return`base image ${n[1]} was missing when this build started (the golden layers weren't built yet, or golden-layers-build failed) - Tilt does not retry a failed build by itself`;if(/install-deps\.sh/i.test(t)||/bun install(?: --production)?/i.test(t)||/npm (?:ci|install)/i.test(t))return"dependency install failed during ImageBuild \u2014 usually Verdaccio (:4873) unreachable or missing @scoped packages (ConnectionRefused downloading package manifest)";let o=t.match(/No such image:\s*([^\s]+)/i)?.[1]??t.match(/pull access denied for ([^,:\s]+)/i)?.[1]??void 0,a=t.match(/\bup\s+-d\s+--no-build\s+([A-Za-z0-9._-]+)/i)?.[1];if(o||a||/docker compose .*\bup\s+-d\s+--no-build\b/i.test(t)){let c=o??`${a??"service"}:dev`,u=a?` for ${a}`:"";return`compose run failed because image is missing (${c})${u} \u2014 wait for the ImageBuild resource to finish, then re-trigger the *-run-only resource`}return/bun run build/i.test(t)?"ImageBuild failed during `bun run build` (compile/typecheck) \u2014 open the resource logs in Tilt for the TypeScript/build error":(/ImageBuild:/i.test(t)||/^Command "/i.test(t),t.slice(0,220))}function q(e){return/ConnectionRefused downloading package manifest|Verdaccio|private registry|dependency install failed during ImageBuild|install-deps\.sh|bun install/i.test(e)}function He(e=T()??process.cwd()){let t=P(e,".tdk",w);if(!C(t))return!1;try{let r=JSON.parse(N(t,"utf-8"));return r.optional_infra?.verdaccio===!0||Object.values(r.phases??{}).some(s=>(s.enabledStacks??[]).includes("verdaccio"))}catch{return!1}}function re(e){for(let t of[P(e,".npmrc"),P(e,A)])if(C(t))try{let r=N(t,"utf-8");if(/:4873\b/.test(r)||/verdaccio/i.test(r))return!0}catch{}return!1}function Ee(e=T()??process.cwd()){return He(e)||re(e)}function mt(e=$,t=T()??process.cwd(),r=process.env.VERDACCIO_URL??process.env.NPM_REGISTRY_URL??be,s=!0){if(!s&&!re(t))return{name:"Private npm registry",didPass:!0,isSkipped:!0,message:"Verdaccio is enabled in the project config but needs a Premium license, so Flisk will not start it - skipped"};if(!Ee(t))return{name:"Private npm registry",didPass:!0,isSkipped:!0,message:"Private npm registry (Verdaccio) not enabled for this project - skipped"};let n=!1;try{let c=y(e,"docker",["ps","--format","{{.Names}}"],"docker ps --format '{{.Names}}'",{stdio:"pipe",encoding:"utf-8",timeout:b});n=/verdaccio/i.test(c)}catch{}let o=!1,a="";try{let c=process.platform==="win32"?Q("curl.exe",["-fsS","-o","NUL","-w","%{http_code}","--max-time","2",r],{stdio:"pipe",encoding:"utf-8",timeout:z+1e3,windowsHide:!0}).trim():e(`curl -fsS -o /dev/null -w '%{http_code}' --max-time 2 ${X(r)}`,{stdio:"pipe",encoding:"utf-8",timeout:z+1e3}).trim();o=/^[23]\d\d$/.test(c),a=`HTTP ${c}`}catch(c){a=c instanceof Error?c.message.slice(0,120):"request failed"}return o?{name:"Private npm registry",didPass:!0,message:`Private npm registry reachable at ${r}${n?" (verdaccio container running)":""}`}:n?{name:"Private npm registry",didPass:!1,message:`Verdaccio container is running but ${r} is not responding (${a}). ImageBuilds that install @scoped packages will fail with ConnectionRefused downloading package manifest.`,fix:"Check `docker logs` for the verdaccio container, confirm port 4873 is published, then re-run `flisk doctor`."}:{name:"Private npm registry",didPass:!1,message:`Private npm registry (Verdaccio) is not reachable at ${r}. Docker ImageBuilds will fail with ConnectionRefused downloading package manifests for @flisk-sh/* and project-scoped packages.`,fix:"Start the registry with `bun run verdaccio:start` (or `docker compose -f docker-compose.verdaccio.yml up -d`), publish packages with `bun run publish:all` / `scripts/build/publish-to-verdaccio.sh`, then `tilt trigger` failed resources or re-run `flisk up`."}}function gt(e=$,t=x(),r=ye){let s=$e(t),n="";try{n=y(e,"docker",["ps","--format","{{.Names}}\\t{{.Ports}}"],"docker ps --format '{{.Names}}\\t{{.Ports}}'",{stdio:"pipe",encoding:"utf-8",timeout:b})}catch{return{name:"Ingress Ports",didPass:!0,isSkipped:!0,message:"Docker not available - skipped ingress port check"}}let o=we(n,r),a=ve(o,s);if(a.length===0){let u=o.filter(i=>ee(i.name,s));return u.length>0?{name:"Ingress Ports",didPass:!0,message:`Ingress ports ${r.join("/")} held by this project's Traefik (${u.map(i=>i.name).join(", ")})`}:{name:"Ingress Ports",didPass:!0,message:`Ingress ports ${r.join("/")} are free for Traefik`}}return{name:"Ingress Ports",didPass:!1,message:`Traefik cannot bind ingress ports because another container already owns them:
7
+ ${a.map(u=>{let i=u.publishedPorts.join(", ");return`${u.name} (host ports ${i})`}).join(`
8
+ `)}`,fix:`Stop the foreign container(s), e.g. \`docker stop ${a[0]?.name}\`, or shut down the other Flisk/Tilt project using that Traefik. Then re-run \`flisk up\`.`}}function Z(e,t){return new Promise(r=>{let s=Se();s.once("error",n=>r(n.code==="EADDRINUSE"?"in-use":"unknown")),s.once("listening",()=>s.close(()=>r("free"))),s.listen(e,t)})}async function kt(e){for(let t=0;t<2;t++){let r=await Z(e,"0.0.0.0");if(r==="unknown")return r;if(r==="free"){let s=await Z(e,"127.0.0.1");if(s==="free"||s==="unknown")return s}t===0&&await new Promise(s=>setTimeout(s,50))}return"in-use"}function Oe(e){let{status:t}=e;return t===void 0?e.error??"no response":t===404?"HTTP 404: Traefik is answering but has no route for this URL (container not started yet, or not running)":t===502||t===503||t===504?`HTTP ${t}: Traefik found the route but the container isn't answering (still starting, or unhealthy)`:`HTTP ${t}`}function Pt(e){let t=e.filter(o=>o.status!==void 0),r=e.filter(o=>!o.ok);if(t.length===0)return{name:"Service Health",didPass:!0,isSkipped:!0,message:`No services responded - skipped ping of ${h(e.length,"service")} (stack may be down, or Traefik never bound :80)`,fix:"If `flisk up` is already running, check Traefik/port 80 in the Tilt UI. Otherwise start with: flisk up"};if(r.length===0)return{name:"Service Health",didPass:!0,message:`All ${h(e.length,"service")} responding on /health`};let s=r.map(o=>`${o.name} (${Oe(o)})
9
+ ${o.url}`).join(`
10
+ `),n=r.some(o=>o.status===404);return{name:"Service Health",didPass:!1,message:`${h(r.length,"service")} not healthy (${e.length-r.length}/${e.length} healthy):
11
+ ${s}`,fix:n?"If `flisk up` just started, images may still be building: re-run `flisk doctor` in a minute. Otherwise check `docker ps` and the resource in the Tilt UI, and compare `flisk networks` with the URL above.":"Check container state and routing: docker ps, then flisk networks to compare the advertised URLs against Traefik's routers"}}function Tt(e){if(e.length===0)return{name:"Service Smoke",didPass:!0,isSkipped:!0,message:"No read-only smoke checks declared"};let t=e.filter(s=>!s.ok);if(t.length===0)return{name:"Service Smoke",didPass:!0,message:`All ${h(e.length,"service")} pass their smoke checks`};let r=t.map(s=>s.failure??`${s.name}: failed`).join(`
12
+ `);return{name:"Service Smoke",didPass:!1,message:`${h(t.length,"service")} failing a smoke check (${e.length-t.length}/${e.length} passing):
13
+ ${r}`,fix:'Add the route the smoke step expects, or correct its "path" in the service.json "smoke" block. Then re-run flisk doctor.'}}function St(e){let t=e.filter(n=>n.status!==void 0);if(t.length===0)return{name:"Advertised Endpoints",didPass:!0,isSkipped:!0,message:"No services responded - skipped advertised endpoint check"};let r=t.filter(n=>n.status===404);if(r.length===0)return{name:"Advertised Endpoints",didPass:!0,message:`${h(t.length,"advertised endpoint")} reachable`};let s=r.map(n=>`${n.name} (404)
14
+ ${n.url}`).join(`
15
+ `);return{name:"Advertised Endpoints",didPass:!0,isWarning:!0,message:`${h(r.length,"advertised link")} ${r.length===1?"returns":"return"} 404 (the service may be healthy, but nothing answers at this exact path):
16
+ ${s}`,fix:'Nothing handles this exact path, so opening the link shows a 404 even when /health is fine. If this API has no root route, you can leave it. Otherwise add a GET route for it (for example one that returns the service name), or declare a read-only "smoke" step on a real route in service.json. The URL flisk networks and the Flisk App print stays the same until the CLI changes how it reports it.'}}function bt(e=$){let t="";try{t=y(e,"tilt",["get","uiresources","-o","json"],"tilt get uiresources -o json",{stdio:"pipe",encoding:"utf-8",timeout:b})}catch{return{name:"Tilt Resources",didPass:!0,isSkipped:!0,message:"Tilt is not running - skipped resource status check",fix:"Start them with: flisk up"}}let r;try{r=_e(t,Re())}catch{return{name:"Tilt Resources",didPass:!0,isSkipped:!0,message:"Could not parse Tilt resource status - skipped"}}if(r.total===0)return{name:"Tilt Resources",didPass:!0,isSkipped:!0,message:"No Tilt UIResources found"};if(r.failures.length===0){let p=r.deferredCount>0?`, ${r.deferredCount} deferred`:"";return{name:"Tilt Resources",didPass:!0,message:`Tilt resources healthy (${r.okCount} ok, ${r.pendingCount} pending${p})`}}let s=Ne(r.failures),o=s.slice(0,20),a=s.length-o.length,c=o.map(p=>({failure:p,why:Ae(p,e)})),u=c.map(({failure:p,why:ne})=>`${p.name}: ${ne}`).join(`
17
+ `),i=a>0?`
18
+ \u2026and ${h(a,"more failed resource")}`:"",d=r.pendingCount>0?`
19
+ ${h(r.pendingCount,"resource")} still pending/not started \u2014 often blocked by the failures above.`:"",l=r.deferredCount>0?`
20
+ ${h(r.deferredCount,"resource")} intentionally deferred (sablier.deferStart) \u2014 not started until first request, unrelated to the failures above.`:"",f=s.some(p=>/port is already allocated/i.test(p.error)),m=s.some(p=>q(p.error)||q(te(p.error))),g=c.some(({why:p})=>/Kafka broker unreachable|kafka:9092/i.test(p)),k="Open the Tilt UI URL printed by flisk up (default port "+j.tiltUi+" when TILT_PORT is unset), inspect the red resources, fix the listed errors, then `tilt trigger <resource>` or re-run `flisk up`.";return f?k="Free the conflicting host port (usually 80/443): `docker ps --filter publish=80` then `docker stop <other-traefik>`. Re-trigger Traefik in the Tilt UI or run `flisk up` again.":m?k="Start Verdaccio (`bun run verdaccio:start`), ensure packages are published (`bun run publish:all` or `bash scripts/build/publish-to-verdaccio.sh`), confirm `curl http://localhost:4873` works, then `tilt trigger` the failed resources.":g&&(k="Kafka is not running (optional infra). Start it, point the bridge at a real broker, or disable Kafka-dependent resources until Kafka is enabled."),{name:"Tilt Resources",didPass:!1,message:`Tilt reports ${h(r.failures.length,"failed resource")}:
21
+ ${u}${i}${d}${l}`,fix:k}}var Ce=/^(traefik|postgres|nats|infisical|verdaccio|proxy)([.-]|$)/i;function Y(e){return Ce.test(e)}function Ne(e){return[...e].sort((t,r)=>{let s=Y(t.name)?0:1,n=Y(r.name)?0:1;return s!==n?s-n:t.name.localeCompare(r.name)})}function Ie(e,t=$,r=x()){try{let s=y(t,"docker",["ps","-a","--format","{{.Names}}"],"docker ps -a --format '{{.Names}}'",{stdio:"pipe",encoding:"utf-8",timeout:b}).split(`
22
+ `).map(i=>i.trim()).filter(Boolean),n=`-autogenerated-${e}-1`,o=s.find(i=>i===e)??s.find(i=>i.startsWith(`${r}-`)&&i.endsWith(n))??s.find(i=>i.endsWith(n))??s.find(i=>i.includes(e));if(!o)return null;let a=y(t,"docker",["logs","--tail","120",o],`docker logs --tail 120 ${X(o)} 2>&1`,{stdio:"pipe",encoding:"utf-8",timeout:b});if(/getaddrinfo ENOTFOUND/i.test(a)&&/kafka:9092/i.test(a))return"runtime crash: Kafka broker unreachable (getaddrinfo ENOTFOUND kafka:9092)";if(/ECONNREFUSED/i.test(a)&&/kafka/i.test(a))return"runtime crash: Kafka connection refused";let c=a.match(/ConnectionRefused downloading package manifest (@[A-Za-z0-9._/-]+)/i);if(c?.[1])return`runtime/build log: private registry ConnectionRefused for ${c[1]}`;if(/ZodError/i.test(a)){let i=[...a.matchAll(/"path"\s*:\s*\[\s*"([^"]+)"\s*\]/g)].map(l=>l[1]),d=[...new Set(i)].slice(0,6);return d.length>0?`runtime crash: ZodError missing required config/env: ${d.join(", ")}`:"runtime crash: ZodError during config/env validation"}let u=a.match(/error:\s+Failed to [^:\n]+[^\n]{0,120}/i)?.[0]??a.match(/Failed to (?:start|initialize) [^\n]{0,120}/i)?.[0]??a.match(/^\s*error:\s+[^\n]{0,160}/im)?.[0];if(u)return`runtime crash: ${u.replace(/\s+/g," ").trim().slice(0,180)}`}catch{return null}return null}function Ae(e,t=$){return e.error?te(e.error):e.runtimeStatus==="error"?Ie(e.name,t)??"runtime error (container crashed or unhealthy \u2014 check Tilt/docker logs)":e.updateStatus||e.runtimeStatus||"unknown error"}var je=/\.(ts|tsx|mts|js|mjs|cjs)$/,Fe=new Set(["node_modules","dist",I,"tests","__tests__"]);function se(e){let t=[];for(let r of Te(e,{withFileTypes:!0}))r.isDirectory()?Fe.has(r.name)||t.push(...se(P(e,r.name))):je.test(r.name)&&!/\.(test|spec)\./.test(r.name)&&t.push(P(e,r.name));return t}function De(e){let t=e?.healthCheckPath||"/health";return{container:t,traefik:e?.traefik?.healthCheck||t}}function Le(e){let t=[];for(let r of e){if(!_(r.config?.appType))continue;let s=P(r.path,"src");if(!C(s))continue;let n=se(s);if(n.length===0)continue;let o=n.map(i=>N(i,"utf-8")),{container:a,traefik:c}=De(r.config),u=a===c?[{path:a,usedBy:"container and Traefik healthchecks"}]:[{path:a,usedBy:"container healthcheck"},{path:c,usedBy:"Traefik healthcheck"}];for(let{path:i,usedBy:d}of u){let l=["'",'"',"`"].map(f=>`${f}${i}${f}`);o.some(f=>l.some(m=>f.includes(m)))||t.push({name:r.name,healthPath:i,usedBy:d})}}return t}function yt(e=T()??process.cwd()){let t=[];try{t=D(e)}catch{return{name:"Health Routes",didPass:!0,isSkipped:!0,message:"Could not read services - skipped health route check"}}let r=t.filter(o=>_(o.config?.appType));if(r.length===0)return{name:"Health Routes",didPass:!0,isSkipped:!0,message:"No backend services to check"};let s=Le(r);return s.length===0?{name:"Health Routes",didPass:!0,message:`All ${h(r.length,"backend")} define their health route`}:{name:"Health Routes",didPass:!1,message:`Backends without a health route (the container never turns healthy, so Traefik returns 404):
23
+ ${s.map(o=>`${o.name}: no "${o.healthPath}" route in src/ (probed by the ${o.usedBy})`).join(`
24
+ `)}`,fix:`Add the route, e.g. for Hono: app.get("${s[0]?.healthPath}", (c) => c.json({ status: "ok" })). To use a different path, set "healthCheckPath" (container healthcheck) or "traefik.healthCheck" (Traefik) in its service.json.`}}export{R as a,Ve as b,V as c,Ye as d,Qe as e,Xe as f,et as g,W as h,M as i,$e as j,Re as k,_e as l,te as m,He as n,mt as o,gt as p,kt as q,Pt as r,Tt as s,St as t,bt as u,yt as v};
@@ -1,12 +1,12 @@
1
1
  import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{b as N,c as pe,d as H,i as D,j as q,n as J,o as I,q as C}from"./chunk-DS47LHYF.js";import{H as B,J as V,L as A,Na as ne,Ra as ae,Sa as se,Ua as ie,V as F,W as z,Wa as ce,Xa as le,Ya as de,aa as f,ba as v,ca as t,d as P,ja as re,k as U,ka as G,la as W,m as E,s as T}from"./chunk-LMHKXU2Q.js";import{b as p}from"./chunk-CF46CD6R.js";import{execFileSync as ve}from"node:child_process";import{cpSync as ye,existsSync as y,readdirSync as Se,readFileSync as Y,writeFileSync as je}from"node:fs";import{basename as _e,dirname as we,join as _,resolve as M}from"node:path";import{cwd as ue}from"node:process";import{fileURLToPath as xe}from"node:url";import{Command as Pe}from"commander";var he="-y, --yes",ke="Skip prompts and confirmations; use defaults";function fe(e,o=ke){return e.option(he,o,!1)}async function be(e,o=!0){let c=await I({message:e,initial:o});return c||F(),c}function Ne(e,o=1){e.valid||A(e.error??"Validation failed",o)}function De(e,o,c,a){return e.dryRun?(a?a():(console.log(`Dry run - ${o}`),console.log(`Would run: ${c}`)),!0):!1}async function Je(e,o){return await be(e,!0)?!0:(o&&o(),!1)}var L=new Map;function me(e){e!==void 0?L.delete(e):L.clear()}function Ue(e=!1){let o=T(),c=o??"";if(!e){let n=L.get(c);if(n)return n}let{resources:a,problems:l}=o?ae(o):{resources:ie(),problems:[]},d=de(a),r=le(a);se(l);let g=a.filter(n=>!n.stack),m=new Map;for(let n of a)if(n.stack){let w=m.get(n.stack)||[];w.push(n),m.set(n.stack,w)}let k={resources:a,problems:l,stacks:d,stackNames:r,unassignedResources:g,resourcesByStack:m};return L.set(c,k),k}var O={proxy:{name:"proxy",description:"Traefik reverse proxy and API gateway for routing all services",category:"core",phase:"pre_alpha",enabled_by_default:!0,dependsOn:[]},verdaccio:{name:"verdaccio",description:"Verdaccio npm registry for package management and local publishing (Premium - requires TDK_LICENSE_KEY)",category:"premium",phase:"pre_alpha",enabled_by_default:!1,dependsOn:[]},[P]:{name:P,description:"PostgreSQL database for data persistence and SQL operations",category:"core",phase:"pre_alpha",enabled_by_default:!0,dependsOn:[]},monitoring:{name:"monitoring",description:"SigNoz or SkyWalking observability platform for monitoring and tracing",category:"optional",phase:"pre_alpha",enabled_by_default:!1,dependsOn:[P]},elk:{name:"elk",description:"Elasticsearch, Logstash, Kibana stack for log aggregation and analysis",category:"optional",phase:"pre_alpha",enabled_by_default:!1,dependsOn:[]},debezium:{name:"debezium",description:"Change Data Capture for real-time data streaming from databases",category:"optional",phase:"pre_alpha",enabled_by_default:!1,dependsOn:[P]},"golden-image":{name:"golden-image",description:"Pre-built Docker image layer for faster builds and smaller deployments",category:"optional",phase:"pre_alpha",enabled_by_default:!0,dependsOn:[]}};var j={demo:{repo:"https://github.com/flisk-sh/tdk-restaurant-example.git",description:"The demo stack: restaurant ops with reservations, kitchen and floor control"},restaurant:{repo:"https://github.com/flisk-sh/tdk-restaurant-example.git",description:"Restaurant ops: reservations, kitchen, floor control (Hono + Vite + Bun)"},saas:{repo:"https://github.com/flisk-sh/tdk-saas-starter.git",description:"SaaS starter: account dashboard and a working checkout button (Hono + Vite + Bun)"},erp:{repo:"https://github.com/flisk-sh/tdk-erp-system.git",description:"Enterprise ERP: 100 microservices across 7 business domains"},"user-management":{repo:"https://github.com/flisk-sh/tdk-user-management.git",description:"User/auth management services"},ecommerce:{repo:"https://github.com/flisk-sh/tdk-ecommerce-example.git",description:"Vue 3 storefront and Hono catalog API (needs Flisk 1.3.75+ for --framework vue)"},example:{repo:"https://github.com/flisk-sh/tdk-example.git",bundledPath:"examples/tdk-example",description:"Hono + Postgres + NATS worker + Vite example with a routed write path"},"agent-stack":{repo:"https://github.com/flisk-sh/tdk-agent-stack.git",description:"AI agent stack: Bun agent + MCP tool server + Postgres + NATS"}};function Ge(e){let o=e[2];if(!(!o||o.startsWith("-")))return o in j?o:void 0}function K(e,o){try{return ce(e,o)}catch{return[]}}function Ee(e){return new Set([...e.phases.pre_alpha.enabledStacks,...e.phases.alpha.enabledStacks,...e.phases.beta.enabledStacks,...e.phases.out_of_scope.enabledStacks])}function Q(e,o){let c=Ee(e),a=o.filter(l=>!c.has(l));return a.length===0?(e.phases.pre_alpha.enabledStacks=Array.from(new Set(e.phases.pre_alpha.enabledStacks)),[]):(e.phases.pre_alpha.enabledStacks=Array.from(new Set([...e.phases.pre_alpha.enabledStacks,...a])),a)}function ut(e,o){let c=_(e,".tdk",U);if(!y(c))return[];let a=D(e),l=Q(a,K(e,o));return l.length>0&&N(c,a),l}function Ae(){return Object.values(O).filter(e=>e.enabled_by_default&&e.category==="core").map(e=>e.name)}function Ce(e,o){return o||(j[e]?.repo.split("/").pop()??e).replace(/\.git$/,"")}async function Oe(e,o,c){let a=j[e];if(!a){console.log(p.red(`
2
+ import{b as N,c as pe,d as H,i as D,j as q,n as J,o as I,q as C}from"./chunk-KXKBWLTE.js";import{H as B,J as V,L as A,Na as ne,Ra as ae,Sa as se,Ua as ie,V as F,W as z,Wa as ce,Xa as le,Ya as de,aa as f,ba as v,ca as t,d as P,ja as re,k as U,ka as G,la as W,m as E,s as T}from"./chunk-LYOSHFYU.js";import{b as p}from"./chunk-CF46CD6R.js";import{execFileSync as ve}from"node:child_process";import{cpSync as ye,existsSync as y,readdirSync as Se,readFileSync as Y,writeFileSync as je}from"node:fs";import{basename as _e,dirname as we,join as _,resolve as M}from"node:path";import{cwd as ue}from"node:process";import{fileURLToPath as xe}from"node:url";import{Command as Pe}from"commander";var he="-y, --yes",ke="Skip prompts and confirmations; use defaults";function fe(e,o=ke){return e.option(he,o,!1)}async function be(e,o=!0){let c=await I({message:e,initial:o});return c||F(),c}function Ne(e,o=1){e.valid||A(e.error??"Validation failed",o)}function De(e,o,c,a){return e.dryRun?(a?a():(console.log(`Dry run - ${o}`),console.log(`Would run: ${c}`)),!0):!1}async function Je(e,o){return await be(e,!0)?!0:(o&&o(),!1)}var L=new Map;function me(e){e!==void 0?L.delete(e):L.clear()}function Ue(e=!1){let o=T(),c=o??"";if(!e){let n=L.get(c);if(n)return n}let{resources:a,problems:l}=o?ae(o):{resources:ie(),problems:[]},d=de(a),r=le(a);se(l);let g=a.filter(n=>!n.stack),m=new Map;for(let n of a)if(n.stack){let w=m.get(n.stack)||[];w.push(n),m.set(n.stack,w)}let k={resources:a,problems:l,stacks:d,stackNames:r,unassignedResources:g,resourcesByStack:m};return L.set(c,k),k}var O={proxy:{name:"proxy",description:"Traefik reverse proxy and API gateway for routing all services",category:"core",phase:"pre_alpha",enabled_by_default:!0,dependsOn:[]},verdaccio:{name:"verdaccio",description:"Verdaccio npm registry for package management and local publishing (Premium - requires TDK_LICENSE_KEY)",category:"premium",phase:"pre_alpha",enabled_by_default:!1,dependsOn:[]},[P]:{name:P,description:"PostgreSQL database for data persistence and SQL operations",category:"core",phase:"pre_alpha",enabled_by_default:!0,dependsOn:[]},monitoring:{name:"monitoring",description:"SigNoz or SkyWalking observability platform for monitoring and tracing",category:"optional",phase:"pre_alpha",enabled_by_default:!1,dependsOn:[P]},elk:{name:"elk",description:"Elasticsearch, Logstash, Kibana stack for log aggregation and analysis",category:"optional",phase:"pre_alpha",enabled_by_default:!1,dependsOn:[]},debezium:{name:"debezium",description:"Change Data Capture for real-time data streaming from databases",category:"optional",phase:"pre_alpha",enabled_by_default:!1,dependsOn:[P]},"golden-image":{name:"golden-image",description:"Pre-built Docker image layer for faster builds and smaller deployments",category:"optional",phase:"pre_alpha",enabled_by_default:!0,dependsOn:[]}};var j={demo:{repo:"https://github.com/flisk-sh/tdk-restaurant-example.git",description:"The demo stack: restaurant ops with reservations, kitchen and floor control"},restaurant:{repo:"https://github.com/flisk-sh/tdk-restaurant-example.git",description:"Restaurant ops: reservations, kitchen, floor control (Hono + Vite + Bun)"},saas:{repo:"https://github.com/flisk-sh/tdk-saas-starter.git",description:"SaaS starter: account dashboard and a working checkout button (Hono + Vite + Bun)"},erp:{repo:"https://github.com/flisk-sh/tdk-erp-system.git",description:"Enterprise ERP: 100 microservices across 7 business domains"},"user-management":{repo:"https://github.com/flisk-sh/tdk-user-management.git",description:"User/auth management services"},ecommerce:{repo:"https://github.com/flisk-sh/tdk-ecommerce-example.git",description:"Vue 3 storefront and Hono catalog API (needs Flisk 1.3.75+ for --framework vue)"},example:{repo:"https://github.com/flisk-sh/tdk-example.git",bundledPath:"examples/tdk-example",description:"Hono + Postgres + NATS worker + Vite example with a routed write path"},"agent-stack":{repo:"https://github.com/flisk-sh/tdk-agent-stack.git",description:"AI agent stack: Bun agent + MCP tool server + Postgres + NATS"}};function Ge(e){let o=e[2];if(!(!o||o.startsWith("-")))return o in j?o:void 0}function K(e,o){try{return ce(e,o)}catch{return[]}}function Ee(e){return new Set([...e.phases.pre_alpha.enabledStacks,...e.phases.alpha.enabledStacks,...e.phases.beta.enabledStacks,...e.phases.out_of_scope.enabledStacks])}function Q(e,o){let c=Ee(e),a=o.filter(l=>!c.has(l));return a.length===0?(e.phases.pre_alpha.enabledStacks=Array.from(new Set(e.phases.pre_alpha.enabledStacks)),[]):(e.phases.pre_alpha.enabledStacks=Array.from(new Set([...e.phases.pre_alpha.enabledStacks,...a])),a)}function ut(e,o){let c=_(e,".tdk",U);if(!y(c))return[];let a=D(e),l=Q(a,K(e,o));return l.length>0&&N(c,a),l}function Ae(){return Object.values(O).filter(e=>e.enabled_by_default&&e.category==="core").map(e=>e.name)}function Ce(e,o){return o||(j[e]?.repo.split("/").pop()??e).replace(/\.git$/,"")}async function Oe(e,o,c){let a=j[e];if(!a){console.log(p.red(`
3
3
  \u274C Unknown template: "${e}"`)),console.log(p.yellow(`
4
4
  Available templates:`));for(let[r,g]of Object.entries(j))console.log(` ${p.cyan(r)} ${p.gray(`- ${g.description}`)}`);console.log(p.gray("\nOr run `flisk project` with no template for a blank project.")),process.exit(1)}let l=Ce(e,o);ne(l)||B.invalidPath(l).exit();let d=M(ue(),l);y(d)&&Se(d).length>0&&B.directoryExists(d).exit(),z(`Cloning template: ${e}`),t(`${a.description}
5
5
  `,0),t(`Source: ${a.bundledPath?"bundled Flisk example":a.repo}`,0),t(`Destination: ${d}
6
6
  `,0);try{if(a.bundledPath){let r=M(we(xe(new URL("../dist/commands/project.js",import.meta.url).href)),"../../../");ye(M(r,a.bundledPath),d,{recursive:!0});let g=_e(d).replace(/-/g,"_");for(let m of["services/platform/messaging/docker-compose.yml","services/shop/orders-api/service.json","services/shop/orders-api/src/index.ts","services/shop/orders-worker/service.json","services/shop/orders-worker/src/index.ts"]){let k=_(d,m),n=Y(k,"utf-8");je(k,n.replaceAll("tdk_example",g))}}else ve("git",["clone",a.repo,d],{stdio:"inherit"})}catch{A(a.bundledPath?"Bundled example copy failed. Reinstall the Flisk CLI package and try again.":"git clone failed. Check you have git installed and network access.")}me(),console.log(p.green(`
7
7
  \u2705 Cloned "${e}" into ${l}/`)),t(`
8
8
  Next steps:`,0),t(`1. cd ${l}`),t("2. flisk doctor # check Docker/Tilt are ready"),t("3. flisk up # start the stack"),t(`
9
- Runtime readiness:`,0);for(let r of c)t(r,0)}var R={version:"1.0",project:{name:"",version:"1.0.0"},phases:{pre_alpha:{name:"Pre-Alpha",description:"Core infrastructure and MVP services",enabledStacks:Ae()},alpha:{name:"Alpha",description:"Essential business services",enabledStacks:[]},beta:{name:"Beta",description:"Extended features",enabledStacks:[]},out_of_scope:{name:"Out of Scope",description:"Future releases",enabledStacks:[]}},optional_infra:{monitoring:!1,elk:!1,debezium:!1,golden_image:!0,verdaccio:!1},discovery:{paths:["services/*/*"]},overrides:{}},gt=fe(new Pe("project")).description("Initialize or validate project-level master configuration").argument("[template]",`Clone a starter example instead of a blank project (${Object.keys(j).join(", ")})`).option("--path <dir>","Directory to clone the template into (default: the template's repo name)").option("--check","Check if master configs exist and are in sync").option("--force","Overwrite existing configuration (dangerous)").option("--config-file <path>","Load project config from existing JSON file").action(async(e,o)=>{let{assertMachineReadyOrExit:c,detectRuntimePrerequisites:a,formatRuntimeNextSteps:l}=await import("./cold-preflight-LPH7WF3B.js");await c({scope:"scaffold"});let d=l(a());if(e){await V(async()=>Oe(e,o.path,d));return}await V(async()=>{let r=T();r||(r=ue(),v(`\u{1F680} Initializing new Flisk project...
9
+ Runtime readiness:`,0);for(let r of c)t(r,0)}var R={version:"1.0",project:{name:"",version:"1.0.0"},phases:{pre_alpha:{name:"Pre-Alpha",description:"Core infrastructure and MVP services",enabledStacks:Ae()},alpha:{name:"Alpha",description:"Essential business services",enabledStacks:[]},beta:{name:"Beta",description:"Extended features",enabledStacks:[]},out_of_scope:{name:"Out of Scope",description:"Future releases",enabledStacks:[]}},optional_infra:{monitoring:!1,elk:!1,debezium:!1,golden_image:!0,verdaccio:!1},discovery:{paths:["services/*/*"]},overrides:{}},gt=fe(new Pe("project")).description("Initialize or validate project-level master configuration").argument("[template]",`Clone a starter example instead of a blank project (${Object.keys(j).join(", ")})`).option("--path <dir>","Directory to clone the template into (default: the template's repo name)").option("--check","Check if master configs exist and are in sync").option("--force","Overwrite existing configuration (dangerous)").option("--config-file <path>","Load project config from existing JSON file").action(async(e,o)=>{let{assertMachineReadyOrExit:c,detectRuntimePrerequisites:a,formatRuntimeNextSteps:l}=await import("./cold-preflight-6Z4RBFKV.js");await c({scope:"scaffold"});let d=l(a());if(e){await V(async()=>Oe(e,o.path,d));return}await V(async()=>{let r=T();r||(r=ue(),v(`\u{1F680} Initializing new Flisk project...
10
10
  `),t(`Location: ${r}
11
11
  `,0));let g=_(r,".tdk"),m=_(g,U);if(o.check){let i=E.every(u=>y(_(r,".tdk",".tdk-out",u))),h=y(m);if(i&&h){let u=D(r);f("Project configuration is valid"),t(`Project: ${u.project.name}`,3),t(`Phases: ${Object.keys(u.phases).join(", ")}`,3),process.exit(0)}else{if(console.log(p.yellow("\u26A0\uFE0F Project configuration incomplete:")),h||t(".tdk/project.json (not found)",3),!i)for(let u of E.filter(S=>!y(_(r,".tdk/.tdk-out",S))))t(`.tdk/.tdk-out/${u} (not found)`,3);t("Run `flisk project` to create them."),process.exit(1)}}z("Project Configuration"),t(`Project root: ${r}
12
12
  `,0),y(g)||(pe(g),f("Created: .tdk/ directory"));let k=y(m);if(k&&!o.force){f(".tdk/project.json exists");let i=JSON.parse(Y(m,"utf-8")),h=D(r),u=K(r),S=Q(h,u);if((S.length>0||!i.phases)&&N(m,h),S.length>0&&t(`Auto-enabled discovered service stacks: ${S.join(", ")}`,0),v(`
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
3
- import{a as H2,b as G2,c as k2,d as L2,j as z2}from"./chunk-RWNIFXXG.js";import{a as Yf}from"./chunk-DTIHDMED.js";import{A as iS,B as lS,H as F2,I as J2,a as En,b as nS,c as xo,d as I2,e as y2,f as Q2,g as S2,h as v2,i as D2,j as R2,k as PI,l as $I,m as Ff,n as N2,o as WI,p as T2,q as w2,r as b2,s as Jf,t as ey,u as x2,v as aS,w as U2,x as O2,y as M2,z as _2}from"./chunk-H446NBVS.js";import{a as o2,b as a2,c as JI,d as i2,e as l2,g as gm}from"./chunk-EICMGZXL.js";import{a as Ju,b as wi,c as oA,d as jf,e as vr,f as Em,g as j2,h as Y2,k as K2}from"./chunk-IYZENTVI.js";import{a as KI,b as qI,e as f2,f as d2,g as g2,h as m2,i as Yu,j as VI,k as p2,l as E2,m as XI,n as pm,o as oS,p as ZI,q as h2}from"./chunk-DS47LHYF.js";import{a as s2,c as u2,d as c2}from"./chunk-42IVF3YT.js";import{c as q2}from"./chunk-WUO7C6WO.js";import{a as Qh,b as A2,c as mm,d as r2,e as YI,h as B2}from"./chunk-RMZQU74X.js";import{b as C2}from"./chunk-GEXOZCEQ.js";import{$ as um,$a as e2,A as ju,Aa as jR,B as RR,Ba as FR,C as NR,Ca as xl,D as TR,Da as yh,E as Qs,Ea as JR,F as ci,G as At,H as ln,Ha as YR,I as Aa,Ia as KR,J as Mn,Ja as LI,K as UI,Ka as cm,L as Ya,La as qR,M as _A,Ma as zI,N as OI,Na as VR,O as qn,Oa as XR,P as wR,Pa as ZR,Q as bR,Qa as PR,R as Bh,Ra as jI,S as sm,Sa as FI,T as xR,Ta as $R,U as Ih,Ua as fm,V as qQ,Va as WR,W as MI,X as _I,Y as HI,Ya as zf,Z as VQ,Za as tS,_ as UR,_a as dm,a as bI,aa as XQ,ab as t2,ba as Fu,bb as n2,c as nA,ca as Vn,da as OR,ea as MR,f as Lf,fa as HA,h as hh,ha as _R,i as yR,ia as ZQ,j as QR,k as KQ,ka as HR,l as lm,m as Am,ma as GR,n as Ch,na as kR,oa as PQ,p as xI,pa as $Q,q as Tl,r as SR,ra as GI,s as Dn,sa as WQ,t as wl,ta as kI,u as ys,v as vR,va as eS,w as rm,x as MA,xa as LR,y as DR,z as bl,za as zR}from"./chunk-LMHKXU2Q.js";import{a as IR,b as D}from"./chunk-CF46CD6R.js";import{a as YQ,b as Ko,c as qO,d as ut}from"./chunk-6EA4DGCY.js";var bT=Ko(Ey=>{"use strict";var SH=Symbol.for("react.transitional.element"),vH=Symbol.for("react.fragment");function wT(n,i,A){var u=null;if(A!==void 0&&(u=""+A),i.key!==void 0&&(u=""+i.key),"key"in i){A={};for(var d in i)d!=="key"&&(A[d]=i[d])}else A=i;return i=A.ref,{$$typeof:SH,type:n,key:u,ref:i!==void 0?i:null,props:A}}Ey.Fragment=vH;Ey.jsx=wT;Ey.jsxs=wT});var JT=Ko(xt=>{"use strict";var TS=Symbol.for("react.transitional.element"),DH=Symbol.for("react.portal"),RH=Symbol.for("react.fragment"),NH=Symbol.for("react.strict_mode"),TH=Symbol.for("react.profiler"),wH=Symbol.for("react.consumer"),bH=Symbol.for("react.context"),xH=Symbol.for("react.forward_ref"),UH=Symbol.for("react.suspense"),OH=Symbol.for("react.memo"),_T=Symbol.for("react.lazy"),MH=Symbol.for("react.activity"),_H=Symbol.for("react.view_transition"),xT=Symbol.iterator;function HH(n){return n===null||typeof n!="object"?null:(n=xT&&n[xT]||n["@@iterator"],typeof n=="function"?n:null)}var HT={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},GT=Object.assign,kT={};function Dm(n,i,A){this.props=n,this.context=i,this.refs=kT,this.updater=A||HT}Dm.prototype.isReactComponent={};Dm.prototype.setState=function(n,i){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,i,"setState")};Dm.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function LT(){}LT.prototype=Dm.prototype;function wS(n,i,A){this.props=n,this.context=i,this.refs=kT,this.updater=A||HT}var bS=wS.prototype=new LT;bS.constructor=wS;GT(bS,Dm.prototype);bS.isPureReactComponent=!0;var UT=Array.isArray;function NS(){}var Wn={H:null,A:null,T:null,S:null},zT=Object.prototype.hasOwnProperty;function xS(n,i,A){var u=A.ref;return{$$typeof:TS,type:n,key:i,ref:u!==void 0?u:null,props:A}}function GH(n,i){return xS(n.type,i,n.props)}function US(n){return typeof n=="object"&&n!==null&&n.$$typeof===TS}function kH(n){var i={"=":"=0",":":"=2"};return"$"+n.replace(/[=:]/g,function(A){return i[A]})}var OT=/\/+/g;function RS(n,i){return typeof n=="object"&&n!==null&&n.key!=null?kH(""+n.key):i.toString(36)}function LH(n){switch(n.status){case"fulfilled":return n.value;case"rejected":throw n.reason;default:switch(typeof n.status=="string"?n.then(NS,NS):(n.status="pending",n.then(function(i){n.status==="pending"&&(n.status="fulfilled",n.value=i)},function(i){n.status==="pending"&&(n.status="rejected",n.reason=i)})),n.status){case"fulfilled":return n.value;case"rejected":throw n.reason}}throw n}function vm(n,i,A,u,d){var p=typeof n;(p==="undefined"||p==="boolean")&&(n=null);var h=!1;if(n===null)h=!0;else switch(p){case"bigint":case"string":case"number":h=!0;break;case"object":switch(n.$$typeof){case TS:case DH:h=!0;break;case _T:return h=n._init,vm(h(n._payload),i,A,u,d)}}if(h)return d=d(n),h=u===""?"."+RS(n,0):u,UT(d)?(A="",h!=null&&(A=h.replace(OT,"$&/")+"/"),vm(d,i,A,"",function(Q){return Q})):d!=null&&(US(d)&&(d=GH(d,A+(d.key==null||n&&n.key===d.key?"":(""+d.key).replace(OT,"$&/")+"/")+h)),i.push(d)),1;h=0;var C=u===""?".":u+":";if(UT(n))for(var I=0;I<n.length;I++)u=n[I],p=C+RS(u,I),h+=vm(u,i,A,p,d);else if(I=HH(n),typeof I=="function")for(n=I.call(n),I=0;!(u=n.next()).done;)u=u.value,p=C+RS(u,I++),h+=vm(u,i,A,p,d);else if(p==="object"){if(typeof n.then=="function")return vm(LH(n),i,A,u,d);throw i=String(n),Error("Objects are not valid as a React child (found: "+(i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)+"). If you meant to render a collection of children, use an array instead.")}return h}function hy(n,i,A){if(n==null)return n;var u=[],d=0;return vm(n,u,"","",function(p){return i.call(A,p,d++)}),u}function zH(n){if(n._status===-1){var i=n._result,A=i();A.then(function(u){(n._status===0||n._status===-1)&&(n._status=1,n._result=u,A.status===void 0&&(A.status="fulfilled",A.value=u))},function(u){(n._status===0||n._status===-1)&&(n._status=2,n._result=u,A.status===void 0&&(A.status="rejected",A.reason=u))}),n._status===-1&&(n._status=0,n._result=A)}if(n._status===1)return n._result.default;throw n._result}var MT=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var i=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(i))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)};function jT(n){var i=Wn.T,A={};A.types=i!==null?i.types:null,Wn.T=A;try{var u=n(),d=Wn.S;d!==null&&d(A,u),typeof u=="object"&&u!==null&&typeof u.then=="function"&&u.then(NS,MT)}catch(p){MT(p)}finally{i!==null&&A.types!==null&&(i.types=A.types),Wn.T=i}}function FT(n){var i=Wn.T;if(i!==null){var A=i.types;A===null?i.types=[n]:A.indexOf(n)===-1&&A.push(n)}else jT(FT.bind(null,n))}var jH={map:hy,forEach:function(n,i,A){hy(n,function(){i.apply(this,arguments)},A)},count:function(n){var i=0;return hy(n,function(){i++}),i},toArray:function(n){return hy(n,function(i){return i})||[]},only:function(n){if(!US(n))throw Error("React.Children.only expected to receive a single React element child.");return n}};xt.Activity=MH;xt.Children=jH;xt.Component=Dm;xt.Fragment=RH;xt.Profiler=TH;xt.PureComponent=wS;xt.StrictMode=NH;xt.Suspense=UH;xt.ViewTransition=_H;xt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Wn;xt.__COMPILER_RUNTIME={__proto__:null,c:function(n){return Wn.H.useMemoCache(n)}};xt.addTransitionType=FT;xt.cache=function(n){return function(){return n.apply(null,arguments)}};xt.cacheSignal=function(){return null};xt.cloneElement=function(n,i,A){if(n==null)throw Error("The argument must be a React element, but you passed "+n+".");var u=GT({},n.props),d=n.key;if(i!=null)for(p in i.key!==void 0&&(d=""+i.key),i)!zT.call(i,p)||p==="key"||p==="__self"||p==="__source"||p==="ref"&&i.ref===void 0||(u[p]=i[p]);var p=arguments.length-2;if(p===1)u.children=A;else if(1<p){for(var h=Array(p),C=0;C<p;C++)h[C]=arguments[C+2];u.children=h}return xS(n.type,d,u)};xt.createContext=function(n){return n={$$typeof:bH,_currentValue:n,_currentValue2:n,_threadCount:0,Provider:null,Consumer:null},n.Provider=n,n.Consumer={$$typeof:wH,_context:n},n};xt.createElement=function(n,i,A){var u,d={},p=null;if(i!=null)for(u in i.key!==void 0&&(p=""+i.key),i)zT.call(i,u)&&u!=="key"&&u!=="__self"&&u!=="__source"&&(d[u]=i[u]);var h=arguments.length-2;if(h===1)d.children=A;else if(1<h){for(var C=Array(h),I=0;I<h;I++)C[I]=arguments[I+2];d.children=C}if(n&&n.defaultProps)for(u in h=n.defaultProps,h)d[u]===void 0&&(d[u]=h[u]);return xS(n,p,d)};xt.createRef=function(){return{current:null}};xt.forwardRef=function(n){return{$$typeof:xH,render:n}};xt.isValidElement=US;xt.lazy=function(n){return{$$typeof:_T,_payload:{_status:-1,_result:n},_init:zH}};xt.memo=function(n,i){return{$$typeof:OH,type:n,compare:i===void 0?null:i}};xt.startTransition=jT;xt.unstable_useCacheRefresh=function(){return Wn.H.useCacheRefresh()};xt.use=function(n){return Wn.H.use(n)};xt.useActionState=function(n,i,A){return Wn.H.useActionState(n,i,A)};xt.useCallback=function(n,i){return Wn.H.useCallback(n,i)};xt.useContext=function(n){return Wn.H.useContext(n)};xt.useDebugValue=function(){};xt.useDeferredValue=function(n,i){return Wn.H.useDeferredValue(n,i)};xt.useEffect=function(n,i){return Wn.H.useEffect(n,i)};xt.useEffectEvent=function(n){return Wn.H.useEffectEvent(n)};xt.useId=function(){return Wn.H.useId()};xt.useImperativeHandle=function(n,i,A){return Wn.H.useImperativeHandle(n,i,A)};xt.useInsertionEffect=function(n,i){return Wn.H.useInsertionEffect(n,i)};xt.useLayoutEffect=function(n,i){return Wn.H.useLayoutEffect(n,i)};xt.useMemo=function(n,i){return Wn.H.useMemo(n,i)};xt.useOptimistic=function(n,i){return Wn.H.useOptimistic(n,i)};xt.useReducer=function(n,i,A){return Wn.H.useReducer(n,i,A)};xt.useRef=function(n){return Wn.H.useRef(n)};xt.useState=function(n){return Wn.H.useState(n)};xt.useSyncExternalStore=function(n,i,A){return Wn.H.useSyncExternalStore(n,i,A)};xt.useTransition=function(){return Wn.H.useTransition()};xt.version="19.3.0"});var YT=Ko((Dt,Cy)=>{"use strict";process.env.NODE_ENV!=="production"&&(function(){function n(R,Y){Object.defineProperty(u.prototype,R,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",Y[0],Y[1])}})}function i(R){return R===null||typeof R!="object"?null:(R=Nt&&R[Nt]||R["@@iterator"],typeof R=="function"?R:null)}function A(R,Y){R=(R=R.constructor)&&(R.displayName||R.name)||"ReactClass";var Ee=R+"."+Y;rt[Ee]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",Y,R),rt[Ee]=!0)}function u(R,Y,Ee){this.props=R,this.context=Y,this.refs=gn,this.updater=Ee||St}function d(){}function p(R,Y,Ee){this.props=R,this.context=Y,this.refs=gn,this.updater=Ee||St}function h(){}function C(R){return""+R}function I(R){try{C(R);var Y=!1}catch{Y=!0}if(Y){Y=console;var Ee=Y.error,H=typeof Symbol=="function"&&Symbol.toStringTag&&R[Symbol.toStringTag]||R.constructor.name||"Object";return Ee.call(Y,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",H),C(R)}}function Q(R){if(R==null)return null;if(typeof R=="function")return R.$$typeof===kt?null:R.displayName||R.name||null;if(typeof R=="string")return R;switch(R){case at:return"Fragment";case Be:return"Profiler";case X:return"StrictMode";case Wt:return"Suspense";case Bt:return"SuspenseList";case et:return"Activity";case Ot:return"ViewTransition"}if(typeof R=="object")switch(typeof R.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),R.$$typeof){case ze:return"Portal";case $e:return R.displayName||"Context";case ot:return(R._context.displayName||"Context")+".Consumer";case rn:var Y=R.render;return R=R.displayName,R||(R=Y.displayName||Y.name||"",R=R!==""?"ForwardRef("+R+")":"ForwardRef"),R;case re:return Y=R.displayName||null,Y!==null?Y:Q(R.type)||"Memo";case It:Y=R._payload,R=R._init;try{return Q(R(Y))}catch{}}return null}function U(R){if(R===at)return"<>";if(typeof R=="object"&&R!==null&&R.$$typeof===It)return"<...>";try{var Y=Q(R);return Y?"<"+Y+">":"<...>"}catch{return"<...>"}}function O(){var R=qe.A;return R===null?null:R.getOwner()}function S(){return Error("react-stack-top-frame")}function b(R){if(Gn.call(R,"key")){var Y=Object.getOwnPropertyDescriptor(R,"key").get;if(Y&&Y.isReactWarning)return!1}return R.key!==void 0}function x(R,Y){function Ee(){uo||(uo=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",Y))}Ee.isReactWarning=!0,Object.defineProperty(R,"key",{get:Ee,configurable:!0})}function k(){var R=Q(this.type);return mt[R]||(mt[R]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),R=this.props.ref,R!==void 0?R:null}function J(R,Y,Ee,H,te,We){var Re=Ee.ref;return R={$$typeof:Oe,type:R,key:Y,props:Ee,_owner:H},(Re!==void 0?Re:null)!==null?Object.defineProperty(R,"ref",{enumerable:!1,get:k}):Object.defineProperty(R,"ref",{enumerable:!1,value:null}),R._store={},Object.defineProperty(R._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(R,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(R,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.defineProperty(R,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:We}),Object.freeze&&(Object.freeze(R.props),Object.freeze(R)),R}function j(R,Y){return Y=J(R.type,Y,R.props,R._owner,R._debugStack,R._debugTask),R._store&&(Y._store.validated=R._store.validated),Y}function ye(R){fe(R)?R._store&&(R._store.validated=1):typeof R=="object"&&R!==null&&R.$$typeof===It&&(R._payload.status==="fulfilled"?fe(R._payload.value)&&R._payload.value._store&&(R._payload.value._store.validated=1):R._store&&(R._store.validated=1))}function fe(R){return typeof R=="object"&&R!==null&&R.$$typeof===Oe}function He(R){var Y={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(Ee){return Y[Ee]})}function xe(R,Y){return typeof R=="object"&&R!==null&&R.key!=null?(I(R.key),He(""+R.key)):Y.toString(36)}function ke(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(h,h):(R.status="pending",R.then(function(Y){R.status==="pending"&&(R.status="fulfilled",R.value=Y)},function(Y){R.status==="pending"&&(R.status="rejected",R.reason=Y)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function Pe(R,Y,Ee,H,te){var We=typeof R;(We==="undefined"||We==="boolean")&&(R=null);var Re=!1;if(R===null)Re=!0;else switch(We){case"bigint":case"string":case"number":Re=!0;break;case"object":switch(R.$$typeof){case Oe:case ze:Re=!0;break;case It:return Re=R._init,Pe(Re(R._payload),Y,Ee,H,te)}}if(Re){Re=R,te=te(Re);var Ie=H===""?"."+xe(Re,0):H;return Gt(te)?(Ee="",Ie!=null&&(Ee=Ie.replace(qo,"$&/")+"/"),Pe(te,Y,Ee,"",function(kn){return kn})):te!=null&&(fe(te)&&(te.key!=null&&(Re&&Re.key===te.key||I(te.key)),Ee=j(te,Ee+(te.key==null||Re&&Re.key===te.key?"":(""+te.key).replace(qo,"$&/")+"/")+Ie),H!==""&&Re!=null&&fe(Re)&&Re.key==null&&Re._store&&!Re._store.validated&&(Ee._store.validated=2),te=Ee),Y.push(te)),1}if(Re=0,Ie=H===""?".":H+":",Gt(R))for(var je=0;je<R.length;je++)H=R[je],We=Ie+xe(H,je),Re+=Pe(H,Y,Ee,We,te);else if(je=i(R),typeof je=="function")for(je===R.entries&&(sa||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),sa=!0),R=je.call(R),je=0;!(H=R.next()).done;)H=H.value,We=Ie+xe(H,je++),Re+=Pe(H,Y,Ee,We,te);else if(We==="object"){if(typeof R.then=="function")return Pe(ke(R),Y,Ee,H,te);throw Y=String(R),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return Re}function we(R,Y,Ee){if(R==null)return R;var H=[],te=0;return Pe(R,H,"","",function(We){return Y.call(Ee,We,te++)}),H}function Ce(R){if(R._status===-1){var Y=null,Ee=null,H=R._ioInfo;H!=null&&(H.start=H.end=performance.now(),H.value=new Promise(function(Re,Ie){Y=Re,Ee=Ie})),H=R._result;var te=H();if(te.then(function(Re){if(R._status===0||R._status===-1){R._status=1,R._result=Re;var Ie=R._ioInfo;if(Ie!=null){Ie.end=performance.now();var je=Re?.default;Y(je),Ie.value.status="fulfilled",Ie.value.value=je}te.status===void 0&&(te.status="fulfilled",te.value=Re)}},function(Re){if(R._status===0||R._status===-1){R._status=2,R._result=Re;var Ie=R._ioInfo;Ie!=null&&(Ie.end=performance.now(),Ie.value.then(h,h),Ee(Re),Ie.value.status="rejected",Ie.value.reason=Re),te.status===void 0&&(te.status="rejected",te.reason=Re)}}),H=R._ioInfo,H!=null){var We=te.displayName;typeof We=="string"&&(H.name=We)}R._status===-1&&(R._status=0,R._result=te)}if(R._status===1)return H=R._result,H===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
3
+ import{a as H2,b as G2,c as k2,d as L2,j as z2}from"./chunk-GNNN2WCF.js";import{a as Yf}from"./chunk-DTIHDMED.js";import{C as F2,D as J2,a as En,b as nS,c as xo,d as I2,e as y2,f as Q2,g as S2,h as v2,i as D2,j as R2,k as T2,l as w2,m as b2,n as Jf,o as ey,p as x2,q as aS,r as U2,s as O2,t as M2,u as _2,v as iS,w as lS}from"./chunk-GCFNSFW7.js";import{a as o2,b as a2,c as JI,d as i2,e as l2,g as gm,h as PI,i as $I,k as Ff,l as N2,m as WI}from"./chunk-R67UHACQ.js";import{a as Ju,b as wi,c as oA,d as jf,e as vr,f as Em,g as j2,h as Y2,k as K2}from"./chunk-S5EXKK7H.js";import{a as KI,b as qI,e as f2,f as d2,g as g2,h as m2,i as Yu,j as VI,k as p2,l as E2,m as XI,n as pm,o as oS,p as ZI,q as h2}from"./chunk-KXKBWLTE.js";import{a as s2,c as u2,d as c2}from"./chunk-42IVF3YT.js";import{c as q2}from"./chunk-NC6KOYDN.js";import{a as Qh,b as A2,c as mm,d as r2,e as YI,h as B2}from"./chunk-M6S25PIS.js";import{b as C2}from"./chunk-5ZSZ4WCI.js";import{$ as um,$a as e2,A as ju,Aa as jR,B as RR,Ba as FR,C as NR,Ca as xl,D as TR,Da as yh,E as Qs,Ea as JR,F as ci,G as At,H as ln,Ha as YR,I as Aa,Ia as KR,J as Mn,Ja as LI,K as UI,Ka as cm,L as Ya,La as qR,M as _A,Ma as zI,N as OI,Na as VR,O as qn,Oa as XR,P as wR,Pa as ZR,Q as bR,Qa as PR,R as Bh,Ra as jI,S as sm,Sa as FI,T as xR,Ta as $R,U as Ih,Ua as fm,V as qQ,Va as WR,W as MI,X as _I,Y as HI,Ya as zf,Z as VQ,Za as tS,_ as UR,_a as dm,a as bI,aa as XQ,ab as t2,ba as Fu,bb as n2,c as nA,ca as Vn,da as OR,ea as MR,f as Lf,fa as HA,h as hh,ha as _R,i as yR,ia as ZQ,j as QR,k as KQ,ka as HR,l as lm,m as Am,ma as GR,n as Ch,na as kR,oa as PQ,p as xI,pa as $Q,q as Tl,r as SR,ra as GI,s as Dn,sa as WQ,t as wl,ta as kI,u as ys,v as vR,va as eS,w as rm,x as MA,xa as LR,y as DR,z as bl,za as zR}from"./chunk-LYOSHFYU.js";import{a as IR,b as D}from"./chunk-CF46CD6R.js";import{a as YQ,b as Ko,c as qO,d as ut}from"./chunk-6EA4DGCY.js";var bT=Ko(Ey=>{"use strict";var SH=Symbol.for("react.transitional.element"),vH=Symbol.for("react.fragment");function wT(n,i,A){var u=null;if(A!==void 0&&(u=""+A),i.key!==void 0&&(u=""+i.key),"key"in i){A={};for(var d in i)d!=="key"&&(A[d]=i[d])}else A=i;return i=A.ref,{$$typeof:SH,type:n,key:u,ref:i!==void 0?i:null,props:A}}Ey.Fragment=vH;Ey.jsx=wT;Ey.jsxs=wT});var JT=Ko(xt=>{"use strict";var TS=Symbol.for("react.transitional.element"),DH=Symbol.for("react.portal"),RH=Symbol.for("react.fragment"),NH=Symbol.for("react.strict_mode"),TH=Symbol.for("react.profiler"),wH=Symbol.for("react.consumer"),bH=Symbol.for("react.context"),xH=Symbol.for("react.forward_ref"),UH=Symbol.for("react.suspense"),OH=Symbol.for("react.memo"),_T=Symbol.for("react.lazy"),MH=Symbol.for("react.activity"),_H=Symbol.for("react.view_transition"),xT=Symbol.iterator;function HH(n){return n===null||typeof n!="object"?null:(n=xT&&n[xT]||n["@@iterator"],typeof n=="function"?n:null)}var HT={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},GT=Object.assign,kT={};function Dm(n,i,A){this.props=n,this.context=i,this.refs=kT,this.updater=A||HT}Dm.prototype.isReactComponent={};Dm.prototype.setState=function(n,i){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,i,"setState")};Dm.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function LT(){}LT.prototype=Dm.prototype;function wS(n,i,A){this.props=n,this.context=i,this.refs=kT,this.updater=A||HT}var bS=wS.prototype=new LT;bS.constructor=wS;GT(bS,Dm.prototype);bS.isPureReactComponent=!0;var UT=Array.isArray;function NS(){}var Wn={H:null,A:null,T:null,S:null},zT=Object.prototype.hasOwnProperty;function xS(n,i,A){var u=A.ref;return{$$typeof:TS,type:n,key:i,ref:u!==void 0?u:null,props:A}}function GH(n,i){return xS(n.type,i,n.props)}function US(n){return typeof n=="object"&&n!==null&&n.$$typeof===TS}function kH(n){var i={"=":"=0",":":"=2"};return"$"+n.replace(/[=:]/g,function(A){return i[A]})}var OT=/\/+/g;function RS(n,i){return typeof n=="object"&&n!==null&&n.key!=null?kH(""+n.key):i.toString(36)}function LH(n){switch(n.status){case"fulfilled":return n.value;case"rejected":throw n.reason;default:switch(typeof n.status=="string"?n.then(NS,NS):(n.status="pending",n.then(function(i){n.status==="pending"&&(n.status="fulfilled",n.value=i)},function(i){n.status==="pending"&&(n.status="rejected",n.reason=i)})),n.status){case"fulfilled":return n.value;case"rejected":throw n.reason}}throw n}function vm(n,i,A,u,d){var p=typeof n;(p==="undefined"||p==="boolean")&&(n=null);var h=!1;if(n===null)h=!0;else switch(p){case"bigint":case"string":case"number":h=!0;break;case"object":switch(n.$$typeof){case TS:case DH:h=!0;break;case _T:return h=n._init,vm(h(n._payload),i,A,u,d)}}if(h)return d=d(n),h=u===""?"."+RS(n,0):u,UT(d)?(A="",h!=null&&(A=h.replace(OT,"$&/")+"/"),vm(d,i,A,"",function(Q){return Q})):d!=null&&(US(d)&&(d=GH(d,A+(d.key==null||n&&n.key===d.key?"":(""+d.key).replace(OT,"$&/")+"/")+h)),i.push(d)),1;h=0;var C=u===""?".":u+":";if(UT(n))for(var I=0;I<n.length;I++)u=n[I],p=C+RS(u,I),h+=vm(u,i,A,p,d);else if(I=HH(n),typeof I=="function")for(n=I.call(n),I=0;!(u=n.next()).done;)u=u.value,p=C+RS(u,I++),h+=vm(u,i,A,p,d);else if(p==="object"){if(typeof n.then=="function")return vm(LH(n),i,A,u,d);throw i=String(n),Error("Objects are not valid as a React child (found: "+(i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)+"). If you meant to render a collection of children, use an array instead.")}return h}function hy(n,i,A){if(n==null)return n;var u=[],d=0;return vm(n,u,"","",function(p){return i.call(A,p,d++)}),u}function zH(n){if(n._status===-1){var i=n._result,A=i();A.then(function(u){(n._status===0||n._status===-1)&&(n._status=1,n._result=u,A.status===void 0&&(A.status="fulfilled",A.value=u))},function(u){(n._status===0||n._status===-1)&&(n._status=2,n._result=u,A.status===void 0&&(A.status="rejected",A.reason=u))}),n._status===-1&&(n._status=0,n._result=A)}if(n._status===1)return n._result.default;throw n._result}var MT=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var i=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(i))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)};function jT(n){var i=Wn.T,A={};A.types=i!==null?i.types:null,Wn.T=A;try{var u=n(),d=Wn.S;d!==null&&d(A,u),typeof u=="object"&&u!==null&&typeof u.then=="function"&&u.then(NS,MT)}catch(p){MT(p)}finally{i!==null&&A.types!==null&&(i.types=A.types),Wn.T=i}}function FT(n){var i=Wn.T;if(i!==null){var A=i.types;A===null?i.types=[n]:A.indexOf(n)===-1&&A.push(n)}else jT(FT.bind(null,n))}var jH={map:hy,forEach:function(n,i,A){hy(n,function(){i.apply(this,arguments)},A)},count:function(n){var i=0;return hy(n,function(){i++}),i},toArray:function(n){return hy(n,function(i){return i})||[]},only:function(n){if(!US(n))throw Error("React.Children.only expected to receive a single React element child.");return n}};xt.Activity=MH;xt.Children=jH;xt.Component=Dm;xt.Fragment=RH;xt.Profiler=TH;xt.PureComponent=wS;xt.StrictMode=NH;xt.Suspense=UH;xt.ViewTransition=_H;xt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Wn;xt.__COMPILER_RUNTIME={__proto__:null,c:function(n){return Wn.H.useMemoCache(n)}};xt.addTransitionType=FT;xt.cache=function(n){return function(){return n.apply(null,arguments)}};xt.cacheSignal=function(){return null};xt.cloneElement=function(n,i,A){if(n==null)throw Error("The argument must be a React element, but you passed "+n+".");var u=GT({},n.props),d=n.key;if(i!=null)for(p in i.key!==void 0&&(d=""+i.key),i)!zT.call(i,p)||p==="key"||p==="__self"||p==="__source"||p==="ref"&&i.ref===void 0||(u[p]=i[p]);var p=arguments.length-2;if(p===1)u.children=A;else if(1<p){for(var h=Array(p),C=0;C<p;C++)h[C]=arguments[C+2];u.children=h}return xS(n.type,d,u)};xt.createContext=function(n){return n={$$typeof:bH,_currentValue:n,_currentValue2:n,_threadCount:0,Provider:null,Consumer:null},n.Provider=n,n.Consumer={$$typeof:wH,_context:n},n};xt.createElement=function(n,i,A){var u,d={},p=null;if(i!=null)for(u in i.key!==void 0&&(p=""+i.key),i)zT.call(i,u)&&u!=="key"&&u!=="__self"&&u!=="__source"&&(d[u]=i[u]);var h=arguments.length-2;if(h===1)d.children=A;else if(1<h){for(var C=Array(h),I=0;I<h;I++)C[I]=arguments[I+2];d.children=C}if(n&&n.defaultProps)for(u in h=n.defaultProps,h)d[u]===void 0&&(d[u]=h[u]);return xS(n,p,d)};xt.createRef=function(){return{current:null}};xt.forwardRef=function(n){return{$$typeof:xH,render:n}};xt.isValidElement=US;xt.lazy=function(n){return{$$typeof:_T,_payload:{_status:-1,_result:n},_init:zH}};xt.memo=function(n,i){return{$$typeof:OH,type:n,compare:i===void 0?null:i}};xt.startTransition=jT;xt.unstable_useCacheRefresh=function(){return Wn.H.useCacheRefresh()};xt.use=function(n){return Wn.H.use(n)};xt.useActionState=function(n,i,A){return Wn.H.useActionState(n,i,A)};xt.useCallback=function(n,i){return Wn.H.useCallback(n,i)};xt.useContext=function(n){return Wn.H.useContext(n)};xt.useDebugValue=function(){};xt.useDeferredValue=function(n,i){return Wn.H.useDeferredValue(n,i)};xt.useEffect=function(n,i){return Wn.H.useEffect(n,i)};xt.useEffectEvent=function(n){return Wn.H.useEffectEvent(n)};xt.useId=function(){return Wn.H.useId()};xt.useImperativeHandle=function(n,i,A){return Wn.H.useImperativeHandle(n,i,A)};xt.useInsertionEffect=function(n,i){return Wn.H.useInsertionEffect(n,i)};xt.useLayoutEffect=function(n,i){return Wn.H.useLayoutEffect(n,i)};xt.useMemo=function(n,i){return Wn.H.useMemo(n,i)};xt.useOptimistic=function(n,i){return Wn.H.useOptimistic(n,i)};xt.useReducer=function(n,i,A){return Wn.H.useReducer(n,i,A)};xt.useRef=function(n){return Wn.H.useRef(n)};xt.useState=function(n){return Wn.H.useState(n)};xt.useSyncExternalStore=function(n,i,A){return Wn.H.useSyncExternalStore(n,i,A)};xt.useTransition=function(){return Wn.H.useTransition()};xt.version="19.3.0"});var YT=Ko((Dt,Cy)=>{"use strict";process.env.NODE_ENV!=="production"&&(function(){function n(R,Y){Object.defineProperty(u.prototype,R,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",Y[0],Y[1])}})}function i(R){return R===null||typeof R!="object"?null:(R=Nt&&R[Nt]||R["@@iterator"],typeof R=="function"?R:null)}function A(R,Y){R=(R=R.constructor)&&(R.displayName||R.name)||"ReactClass";var Ee=R+"."+Y;rt[Ee]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",Y,R),rt[Ee]=!0)}function u(R,Y,Ee){this.props=R,this.context=Y,this.refs=gn,this.updater=Ee||St}function d(){}function p(R,Y,Ee){this.props=R,this.context=Y,this.refs=gn,this.updater=Ee||St}function h(){}function C(R){return""+R}function I(R){try{C(R);var Y=!1}catch{Y=!0}if(Y){Y=console;var Ee=Y.error,H=typeof Symbol=="function"&&Symbol.toStringTag&&R[Symbol.toStringTag]||R.constructor.name||"Object";return Ee.call(Y,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",H),C(R)}}function Q(R){if(R==null)return null;if(typeof R=="function")return R.$$typeof===kt?null:R.displayName||R.name||null;if(typeof R=="string")return R;switch(R){case at:return"Fragment";case Be:return"Profiler";case X:return"StrictMode";case Wt:return"Suspense";case Bt:return"SuspenseList";case et:return"Activity";case Ot:return"ViewTransition"}if(typeof R=="object")switch(typeof R.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),R.$$typeof){case ze:return"Portal";case $e:return R.displayName||"Context";case ot:return(R._context.displayName||"Context")+".Consumer";case rn:var Y=R.render;return R=R.displayName,R||(R=Y.displayName||Y.name||"",R=R!==""?"ForwardRef("+R+")":"ForwardRef"),R;case re:return Y=R.displayName||null,Y!==null?Y:Q(R.type)||"Memo";case It:Y=R._payload,R=R._init;try{return Q(R(Y))}catch{}}return null}function U(R){if(R===at)return"<>";if(typeof R=="object"&&R!==null&&R.$$typeof===It)return"<...>";try{var Y=Q(R);return Y?"<"+Y+">":"<...>"}catch{return"<...>"}}function O(){var R=qe.A;return R===null?null:R.getOwner()}function S(){return Error("react-stack-top-frame")}function b(R){if(Gn.call(R,"key")){var Y=Object.getOwnPropertyDescriptor(R,"key").get;if(Y&&Y.isReactWarning)return!1}return R.key!==void 0}function x(R,Y){function Ee(){uo||(uo=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",Y))}Ee.isReactWarning=!0,Object.defineProperty(R,"key",{get:Ee,configurable:!0})}function k(){var R=Q(this.type);return mt[R]||(mt[R]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),R=this.props.ref,R!==void 0?R:null}function J(R,Y,Ee,H,te,We){var Re=Ee.ref;return R={$$typeof:Oe,type:R,key:Y,props:Ee,_owner:H},(Re!==void 0?Re:null)!==null?Object.defineProperty(R,"ref",{enumerable:!1,get:k}):Object.defineProperty(R,"ref",{enumerable:!1,value:null}),R._store={},Object.defineProperty(R._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(R,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(R,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.defineProperty(R,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:We}),Object.freeze&&(Object.freeze(R.props),Object.freeze(R)),R}function j(R,Y){return Y=J(R.type,Y,R.props,R._owner,R._debugStack,R._debugTask),R._store&&(Y._store.validated=R._store.validated),Y}function ye(R){fe(R)?R._store&&(R._store.validated=1):typeof R=="object"&&R!==null&&R.$$typeof===It&&(R._payload.status==="fulfilled"?fe(R._payload.value)&&R._payload.value._store&&(R._payload.value._store.validated=1):R._store&&(R._store.validated=1))}function fe(R){return typeof R=="object"&&R!==null&&R.$$typeof===Oe}function He(R){var Y={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(Ee){return Y[Ee]})}function xe(R,Y){return typeof R=="object"&&R!==null&&R.key!=null?(I(R.key),He(""+R.key)):Y.toString(36)}function ke(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(h,h):(R.status="pending",R.then(function(Y){R.status==="pending"&&(R.status="fulfilled",R.value=Y)},function(Y){R.status==="pending"&&(R.status="rejected",R.reason=Y)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function Pe(R,Y,Ee,H,te){var We=typeof R;(We==="undefined"||We==="boolean")&&(R=null);var Re=!1;if(R===null)Re=!0;else switch(We){case"bigint":case"string":case"number":Re=!0;break;case"object":switch(R.$$typeof){case Oe:case ze:Re=!0;break;case It:return Re=R._init,Pe(Re(R._payload),Y,Ee,H,te)}}if(Re){Re=R,te=te(Re);var Ie=H===""?"."+xe(Re,0):H;return Gt(te)?(Ee="",Ie!=null&&(Ee=Ie.replace(qo,"$&/")+"/"),Pe(te,Y,Ee,"",function(kn){return kn})):te!=null&&(fe(te)&&(te.key!=null&&(Re&&Re.key===te.key||I(te.key)),Ee=j(te,Ee+(te.key==null||Re&&Re.key===te.key?"":(""+te.key).replace(qo,"$&/")+"/")+Ie),H!==""&&Re!=null&&fe(Re)&&Re.key==null&&Re._store&&!Re._store.validated&&(Ee._store.validated=2),te=Ee),Y.push(te)),1}if(Re=0,Ie=H===""?".":H+":",Gt(R))for(var je=0;je<R.length;je++)H=R[je],We=Ie+xe(H,je),Re+=Pe(H,Y,Ee,We,te);else if(je=i(R),typeof je=="function")for(je===R.entries&&(sa||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),sa=!0),R=je.call(R),je=0;!(H=R.next()).done;)H=H.value,We=Ie+xe(H,je++),Re+=Pe(H,Y,Ee,We,te);else if(We==="object"){if(typeof R.then=="function")return Pe(ke(R),Y,Ee,H,te);throw Y=String(R),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return Re}function we(R,Y,Ee){if(R==null)return R;var H=[],te=0;return Pe(R,H,"","",function(We){return Y.call(Ee,We,te++)}),H}function Ce(R){if(R._status===-1){var Y=null,Ee=null,H=R._ioInfo;H!=null&&(H.start=H.end=performance.now(),H.value=new Promise(function(Re,Ie){Y=Re,Ee=Ie})),H=R._result;var te=H();if(te.then(function(Re){if(R._status===0||R._status===-1){R._status=1,R._result=Re;var Ie=R._ioInfo;if(Ie!=null){Ie.end=performance.now();var je=Re?.default;Y(je),Ie.value.status="fulfilled",Ie.value.value=je}te.status===void 0&&(te.status="fulfilled",te.value=Re)}},function(Re){if(R._status===0||R._status===-1){R._status=2,R._result=Re;var Ie=R._ioInfo;Ie!=null&&(Ie.end=performance.now(),Ie.value.then(h,h),Ee(Re),Ie.value.status="rejected",Ie.value.reason=Re),te.status===void 0&&(te.status="rejected",te.reason=Re)}}),H=R._ioInfo,H!=null){var We=te.displayName;typeof We=="string"&&(H.name=We)}R._status===-1&&(R._status=0,R._result=te)}if(R._status===1)return H=R._result,H===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
4
4
 
5
5
  Your code should look like:
6
6
  const MyComponent = lazy(() => import('./MyComponent'))
@@ -1830,7 +1830,7 @@ Fix: ${C}`),console.error(D.red(`\u2717 ${h}`)),console.error(D.gray(` Fix: ${C
1830
1830
  `)),_A(u.join(`
1831
1831
  `)),A(q5))}function Z5(n,i,A=wl(),u=process.exit){if(i.ignoreVersion){console.warn(D.yellow("Warning: --ignore-version set; minTdkVersion was not checked."));return}let d=M2(n,A);d.status==="none"||d.status==="ok"||(i.onFail?.(`${d.message}
1832
1832
  ${d.fix}`),_A(`${d.message}
1833
- ${d.fix}`),u(1))}var nO=Symbol("startup-failed");async function P5(n,i,A=process.exit){let u=await Promise.race([n,i.then(()=>nO)]);return u===nO&&A(1),u}function $5(n,i=3e4){return new Promise(A=>{let u=Date.now()+i,d=()=>{let p=j5({host:"127.0.0.1",port:n}),h=!1,C=I=>{h||(h=!0,p.destroy(),I||Date.now()>=u?A(I):setTimeout(d,250))};p.once("connect",()=>C(!0)),p.once("error",()=>C(!1))};d()})}function W5(n,i){if(i===void 0)return;if(!n)throw ln.notInProject();let A=YU(n,i);return qU(n),A}function eL(n){let i=n instanceof At?n.suggestions:[];return{failure:{code:n instanceof zA?n.code:"ENV_FILE_INVALID",message:Qs(n),...i.length>0?{suggestions:i}:{}},exitCode:n instanceof At?n.exitCode:2}}var oO=new F5("up").description("Start all services (optionally filtered by stack)").alias("deploy").argument("[stack-name]","Name of the stack to start (optional - runs all if omitted)").option("-v, --verbose","Enable verbose output",!1).option("-q, --quiet","Suppress non-essential output",!1).option("--dry-run","Show what would be started without starting",!1).option("-f, --force","Kill existing Tilt process before starting",!1).option("--ignore-drift","Start even if generated files differ from service.json",!1).option("--ignore-version","Start even if this flisk is older than minTdkVersion in .tdk/project.json",!1).option("--only <services...>","Start only these services plus what the Tiltfile enables for them (their dependsOn services and shared infrastructure). With a stack, names must belong to that stack; dependencies may cross stacks").option("--env-file <path>","Use this project env file for the run instead of .env (for example: --env-file .env.integration)").option("--json","Print one JSON object on stdout when the stack is ready or the command fails; implies --quiet",!1).action(async(n,i)=>{let A=i.json?uy("UP_FAILED","flisk up"):void 0;i.json&&(i.quiet=!0);let u=DS(process.env.TILT_PORT);u.ok||(A?.({ok:!1},[{code:"INVALID_TILT_PORT",message:u.message}]),Ya(u.message));let d=u.port,p=Dn();p&&Z5(p,{ignoreVersion:i.ignoreVersion,onFail:b=>A?.({ok:!1},[{code:"TDK_VERSION_TOO_OLD",message:b}])});let h=p,C;if(i.envFile===void 0&&delete process.env[S0],i.envFile!==void 0){try{C=W5(h,i.envFile)}catch(b){let{failure:x,exitCode:k}=eL(b);A?.({ok:!1},[x]),Ya(x.message,k,x.suggestions)}if(C&&h){KU(C),i.quiet||console.log(D.gray(`Using env file: ${C.relativePath} (the project .env is not read in this run)`));let b=VU(h,C);b&&console.warn(D.yellow(b))}}let I=i.dryRun?null:await Y5();I&&(A?.({ok:!1},[{code:"HOST_UNSUPPORTED",message:I}]),Ya(I));let Q=J5(process.platform,process.env.TDK_ALLOW_NATIVE_WINDOWS);Q&&Ya(Q);let U=Dn(),O;if(U){try{O=jI(U),FI(O.problems)}catch{}O&&ZU(U,{resources:O.resources,onInvalid:b=>A?.({ok:!1},[{code:"INVALID_SCHEMA_VERSION",message:b}])})}if(!i.dryRun){let{assertMachineReadyOrExit:b}=await import("./cold-preflight-LPH7WF3B.js");await b()}let S=async()=>{let b=i.dryRun?Aa():Dn(),x=b??process.cwd(),k=WR(b&&b===U?O:void 0),J,j=[];if((!i.only||n)&&(J=zf(k),j=J.map(re=>re.name)),i.only){if(n&&!dm(n,k)){let et=ln.stackNotFound(n,j);A?.({ok:!1},[nS(et).error]),et.exit()}let re=n?tS(n,k):k,It=$U(i.only,re);if(It.length>0){let et=re.map(Nt=>Nt.name),Ot=ln.unknownServices(It,et);A?.({ok:!1},[{code:"UNKNOWN_SERVICE",message:Ot.message,...Ot.suggestions.length>0?{suggestions:Ot.suggestions}:{}}]),Ot.exit()}}b&&X5(b,{ignoreDrift:i.ignoreDrift,resources:k,onDrift:re=>A?.({ok:!1},[{code:"DRIFT_DETECTED",message:re}])}),b&&O2(b,{resources:k,onInvalid:re=>A?.({ok:!1},[{code:"INVALID_SERVICE_CONFIG",message:re}])}),b&&!A&&!i.quiet&&U2(b,k);let ye=await gm(x,{inspectDocker:!i.dryRun});if(!i.dryRun){if(b&&!C){let et=HR(x);et.length>0&&!i.quiet&&console.log(D.gray(`Added ${et.join(", ")} to .env (generated; existing values unchanged)`))}b&&!z5(eO(x,".tdk",".tdk-out","Tiltfile"))&&(i.quiet||console.log(D.gray("No generated Tiltfile yet; generating .tdk/.tdk-out/ ...")),await VI(x,{quiet:i.quiet}));let re=E2(x);re.length>0&&i.verbose&&!i.quiet&&console.log(D.gray(`Refreshed runtime assets: ${re.join(", ")}`));let It=Y2(x,k);It.length>0&&!i.quiet&&console.log(D.gray(`Added ${It.join(", ")} to the pre_alpha phase in .tdk/project.json`))}let fe,He,xe=[];if(n){if(fe=tS(n,k),fe.length===0){let re=ln.stackNotFound(n,j);A?.({ok:!1},[nS(re).error]),re.exit()}xe=fe.map(re=>re.name),He=`stack "${n}"`}else{fe=k;let re=J??zf(k);He=`all stacks (${qn(re.length,"stack")}, ${qn(fe.length,"service")})`}let ke=[];if(i.only){let re=WU(i.only,k);fe=re.selected,ke=re.dependencies,xe=fe.map(It=>It.name),He=`${qn(i.only.length,"requested service")}${ke.length>0?` plus ${ke.join(", ")}`:""}`}i.verbose&&!i.quiet&&console.log(D.gray(`Found ${qn(fe.length,"service")} in ${He}`));let Pe=fe.map(re=>re.name);if(!i.quiet){console.log(D.blue(`${i.dryRun?"Would start":"Starting"} ${qn(Pe.length,"service")} from ${He}...`));for(let Nt of Pe)console.log(D.gray(` - ${Nt}`));let{appBase:re,apiBase:It}=GI(ye.ingressHttp),et=fe.filter(Nt=>Nt.config?.appType==="frontend"),Ot=fe.filter(Nt=>HA(Nt.config?.appType));if(et.length>0){console.log(D.blue(`
1833
+ ${d.fix}`),u(1))}var nO=Symbol("startup-failed");async function P5(n,i,A=process.exit){let u=await Promise.race([n,i.then(()=>nO)]);return u===nO&&A(1),u}function $5(n,i=3e4){return new Promise(A=>{let u=Date.now()+i,d=()=>{let p=j5({host:"127.0.0.1",port:n}),h=!1,C=I=>{h||(h=!0,p.destroy(),I||Date.now()>=u?A(I):setTimeout(d,250))};p.once("connect",()=>C(!0)),p.once("error",()=>C(!1))};d()})}function W5(n,i){if(i===void 0)return;if(!n)throw ln.notInProject();let A=YU(n,i);return qU(n),A}function eL(n){let i=n instanceof At?n.suggestions:[];return{failure:{code:n instanceof zA?n.code:"ENV_FILE_INVALID",message:Qs(n),...i.length>0?{suggestions:i}:{}},exitCode:n instanceof At?n.exitCode:2}}var oO=new F5("up").description("Start all services (optionally filtered by stack)").alias("deploy").argument("[stack-name]","Name of the stack to start (optional - runs all if omitted)").option("-v, --verbose","Enable verbose output",!1).option("-q, --quiet","Suppress non-essential output",!1).option("--dry-run","Show what would be started without starting",!1).option("-f, --force","Kill existing Tilt process before starting",!1).option("--ignore-drift","Start even if generated files differ from service.json",!1).option("--ignore-version","Start even if this flisk is older than minTdkVersion in .tdk/project.json",!1).option("--only <services...>","Start only these services plus what the Tiltfile enables for them (their dependsOn services and shared infrastructure). With a stack, names must belong to that stack; dependencies may cross stacks").option("--env-file <path>","Use this project env file for the run instead of .env (for example: --env-file .env.integration)").option("--json","Print one JSON object on stdout when the stack is ready or the command fails; implies --quiet",!1).action(async(n,i)=>{let A=i.json?uy("UP_FAILED","flisk up"):void 0;i.json&&(i.quiet=!0);let u=DS(process.env.TILT_PORT);u.ok||(A?.({ok:!1},[{code:"INVALID_TILT_PORT",message:u.message}]),Ya(u.message));let d=u.port,p=Dn();p&&Z5(p,{ignoreVersion:i.ignoreVersion,onFail:b=>A?.({ok:!1},[{code:"TDK_VERSION_TOO_OLD",message:b}])});let h=p,C;if(i.envFile===void 0&&delete process.env[S0],i.envFile!==void 0){try{C=W5(h,i.envFile)}catch(b){let{failure:x,exitCode:k}=eL(b);A?.({ok:!1},[x]),Ya(x.message,k,x.suggestions)}if(C&&h){KU(C),i.quiet||console.log(D.gray(`Using env file: ${C.relativePath} (the project .env is not read in this run)`));let b=VU(h,C);b&&console.warn(D.yellow(b))}}let I=i.dryRun?null:await Y5();I&&(A?.({ok:!1},[{code:"HOST_UNSUPPORTED",message:I}]),Ya(I));let Q=J5(process.platform,process.env.TDK_ALLOW_NATIVE_WINDOWS);Q&&Ya(Q);let U=Dn(),O;if(U){try{O=jI(U),FI(O.problems)}catch{}O&&ZU(U,{resources:O.resources,onInvalid:b=>A?.({ok:!1},[{code:"INVALID_SCHEMA_VERSION",message:b}])})}if(!i.dryRun){let{assertMachineReadyOrExit:b}=await import("./cold-preflight-6Z4RBFKV.js");await b()}let S=async()=>{let b=i.dryRun?Aa():Dn(),x=b??process.cwd(),k=WR(b&&b===U?O:void 0),J,j=[];if((!i.only||n)&&(J=zf(k),j=J.map(re=>re.name)),i.only){if(n&&!dm(n,k)){let et=ln.stackNotFound(n,j);A?.({ok:!1},[nS(et).error]),et.exit()}let re=n?tS(n,k):k,It=$U(i.only,re);if(It.length>0){let et=re.map(Nt=>Nt.name),Ot=ln.unknownServices(It,et);A?.({ok:!1},[{code:"UNKNOWN_SERVICE",message:Ot.message,...Ot.suggestions.length>0?{suggestions:Ot.suggestions}:{}}]),Ot.exit()}}b&&X5(b,{ignoreDrift:i.ignoreDrift,resources:k,onDrift:re=>A?.({ok:!1},[{code:"DRIFT_DETECTED",message:re}])}),b&&O2(b,{resources:k,onInvalid:re=>A?.({ok:!1},[{code:"INVALID_SERVICE_CONFIG",message:re}])}),b&&!A&&!i.quiet&&U2(b,k);let ye=await gm(x,{inspectDocker:!i.dryRun});if(!i.dryRun){if(b&&!C){let et=HR(x);et.length>0&&!i.quiet&&console.log(D.gray(`Added ${et.join(", ")} to .env (generated; existing values unchanged)`))}b&&!z5(eO(x,".tdk",".tdk-out","Tiltfile"))&&(i.quiet||console.log(D.gray("No generated Tiltfile yet; generating .tdk/.tdk-out/ ...")),await VI(x,{quiet:i.quiet}));let re=E2(x);re.length>0&&i.verbose&&!i.quiet&&console.log(D.gray(`Refreshed runtime assets: ${re.join(", ")}`));let It=Y2(x,k);It.length>0&&!i.quiet&&console.log(D.gray(`Added ${It.join(", ")} to the pre_alpha phase in .tdk/project.json`))}let fe,He,xe=[];if(n){if(fe=tS(n,k),fe.length===0){let re=ln.stackNotFound(n,j);A?.({ok:!1},[nS(re).error]),re.exit()}xe=fe.map(re=>re.name),He=`stack "${n}"`}else{fe=k;let re=J??zf(k);He=`all stacks (${qn(re.length,"stack")}, ${qn(fe.length,"service")})`}let ke=[];if(i.only){let re=WU(i.only,k);fe=re.selected,ke=re.dependencies,xe=fe.map(It=>It.name),He=`${qn(i.only.length,"requested service")}${ke.length>0?` plus ${ke.join(", ")}`:""}`}i.verbose&&!i.quiet&&console.log(D.gray(`Found ${qn(fe.length,"service")} in ${He}`));let Pe=fe.map(re=>re.name);if(!i.quiet){console.log(D.blue(`${i.dryRun?"Would start":"Starting"} ${qn(Pe.length,"service")} from ${He}...`));for(let Nt of Pe)console.log(D.gray(` - ${Nt}`));let{appBase:re,apiBase:It}=GI(ye.ingressHttp),et=fe.filter(Nt=>Nt.config?.appType==="frontend"),Ot=fe.filter(Nt=>HA(Nt.config?.appType));if(et.length>0){console.log(D.blue(`
1834
1834
  \u{1F30D} Frontend URLs:`));for(let Nt of et){let rt=Nt.config?.basePath??`/${Nt.name}`;console.log(D.gray(` - ${Nt.name}: ${re}${D.cyan(WQ(rt))}`))}}if(Ot.length>0){console.log(D.blue(`
1835
1835
  \u{1F527} Backend API URLs:`));for(let Nt of Ot){let rt=Nt.name.replace(/-api$/,""),St=Nt.config?.apiPath??`/api/${rt}`,dt=Nt.config?.sablier,gn=dt?.enable&&dt?.deferStart?D.dim(" (deferred \u2014 starts on first request)"):"";console.log(D.gray(` - ${Nt.name}: ${It}${D.cyan(WQ(St))}${gn}`))}}}let we=i.only??(n?[n]:void 0),Ce=NR(xe,{verbose:i.verbose,quiet:i.quiet,force:i.force,focusTargets:we}),Le=we?`tilt up ${Ce.join(" ")}`:"tilt up";if(!i.quiet){console.log(D.blue(a2(ye)));for(let re of XU(ye))console.log(D.yellow(re));console.log(D.gray("Override with TDK_HTTP_PORT, TDK_HTTPS_PORT, or TDK_POSTGRES_PORT."))}if(A&&i.dryRun){A({ok:!0,dryRun:!0,stack:n??null,services:Pe,...i.only?{requested:i.only,declaredDependencies:ke}:{},command:Le});return}if(vr(i,"not starting services",Le))return;l2(ye),i2(x,ye);let ct=Tl.tiltUi,Ve=d??ct,Rt=i.only?[...new Set([ct,Ve])]:[Ve],{running:ht,foreign:de}=await q2(Rt,x,async re=>await Jf(re)!==null);if(de.length>0&&d!==void 0){let re=de[0],It=`TILT_PORT=${re?.port} is used by another project's Tilt (${re?.root}). Choose a free port, or run flisk down in that project.`;A?.({ok:!1},[{code:"TILT_PORT_IN_USE",message:It}]),Ya(It)}if(!i.quiet)for(let re of de)console.log(D.yellow(`\u26A0\uFE0F Tilt on port ${re.port} belongs to another project (${re.root}); this project will use another port.`));let Ue=i.force&&de.length===0,_e=DT({runningPorts:ht,force:Ue,only:!!i.only});if(_e.action==="already-running"){if(C){let It=`A Tilt is already running on port ${_e.ports.join(", ")}. --env-file applies to a new run only: run \`flisk down\` first, or pass --force to replace the running stack.`;A?.({ok:!1},[{code:"ENV_FILE_ALREADY_RUNNING",message:It}]),Ya(It)}let re=`Environment is already running on port ${_e.ports.join(", ")}.`;A?.({ok:!0,alreadyRunning:!0,tiltUrl:`http://localhost:${_e.ports[0]}`}),i.quiet||console.log(D.green(re));return}if(_e.action==="only-blocked"){let re=`A Tilt is already running on port ${_e.ports.join(", ")}. --only cannot change a running stack's services: run \`flisk down\` first, or pass --force to replace it.`;A?.({ok:!1},[{code:"TILT_ALREADY_RUNNING",message:re}]),Ya(re)}if(i.only)for(let re of ht)v0(re);let Ne=await RT({configuredPort:d,force:Ue,basePort:ct,findAvailablePort:tT}),Oe=Ne.port;Ne.autoSwitched&&!i.quiet&&(console.log(D.yellow(`\u26A0\uFE0F Port ${ct} is already in use`)),console.log(D.blue(`\u{1F504} Auto-switching to port ${Oe}
1836
1836
  `))),process.env.TILT_PORT=Oe.toString(),await NT({force:Ue,quiet:i.quiet,port:Oe},{stop:v0,log:re=>console.log(D.yellow(re)),wait:re=>new Promise(It=>setTimeout(It,re))}),i.quiet||(console.log(D.gray(`
@@ -1868,7 +1868,7 @@ Manual upgrade using a published package:`)),console.log(D.cyan(" npm install
1868
1868
  `)):(console.log(),await oS({message:"Proceed with upgrade?",initial:!0})||(qQ(),process.exit(0))),console.log();let h=!1;switch(A.method){case"npm":h=await mO();break;case"bun":h=await pO();break;case"git":A.path&&(h=await EO(A.path));break;case"binary":A.path&&p&&(h=await dO(A.path,p));break}if(!h){if(console.error(D.red(`
1869
1869
  Upgrade failed`)),A.method==="git")console.log(D.cyan(` Check local changes with: git -C ${A.path} status --short`)),console.log(D.cyan(" Commit or stash them, then retry: flisk upgrade"));else if(A.method==="binary"&&p&&A.path){let I=bi(G1(A.path),"tdk-cli");ys()?console.log(D.cyan(" irm https://flisk.sh/install.ps1 | iex")):(console.log(D.cyan(` curl -fsSL -o ${A.path} ${p.downloadUrl}`)),console.log(D.cyan(` chmod +x ${A.path}`)),console.log(D.cyan(` rm -rf ${I} && mkdir -p ${I}`)),console.log(D.cyan(` curl -fsSL ${p.engineDownloadUrl} | tar -xzf - -C ${I} --strip-components=1`)))}process.exit(1)}console.log();let C=Yf("Verifying upgrade...");try{let I=Ia(MA(rm())??rm(),["version"],{encoding:"utf-8",windowsHide:ys()}).trim();C.succeed(`Verified: now running ${D.green(I)}`),console.log(),console.log(D.green.bold("\u2728 Upgrade complete!")),console.log(D.gray(` Version: ${i} \u2192 ${I}`)),console.log(),console.log(D.cyan.bold("\u{1F4CD} Installation Details:")),A.method==="git"&&A.path?(console.log(D.gray(` Location: ${A.path}`)),console.log(D.gray(" Method: git clone + bun link"))):console.log(D.gray(` Method: ${A.method}`)),console.log(D.gray(` Binary: ${A.path??MA(rm())??"unknown"}`)),console.log(),console.log(D.cyan.bold("\u{1F680} Quick Start:")),console.log(D.white(" flisk --help Show all commands")),console.log(D.white(" flisk networks View service URLs")),console.log(D.white(" flisk doctor Check environment")),I===i&&!n.force&&(console.log(),console.log(D.yellow("\u{1F4A1} Tip: Version appears unchanged. You may need to restart your terminal."))),console.log(),console.log(D.green("Happy coding! \u{1F389}"))}catch(I){C.warn("Could not verify new version"),console.error(D.red(`Verification error: ${Qs(I)}`)),console.log(),console.log(D.yellow("\u26A0\uFE0F Upgrade status unknown - verification failed")),console.log(),dL(I)&&A.method!=="git"&&A.path?(console.log(D.yellow("\u{1F4A1} The installed binary isn't executable. Fix it with:")),console.log(D.cyan(` chmod +x ${A.path}`)),console.log(D.white(" then run: flisk version"))):(console.log(D.yellow("\u{1F4A1} Verify manually:")),console.log(D.white(" 1. Restart your terminal")),console.log(D.white(" 2. Run: flisk version")),A.method==="git"&&A.path&&console.log(D.white(` 3. Compare with: git -C ${A.path} rev-parse HEAD`)))}})}var hO=hL();import{Command as CL}from"commander";var CO=new CL("version").description("Display version number").alias("v").action(()=>{console.log(wl())});function BO(){return[SS,CT,lT,oO,xN,WN,zN,ON,HN,z2,TT,yT,hT,QS,K2,mS,kU,CO,FN,_2,RN,hO,aT,AS,BT]}function IO(){let n=new BL;n.name("flisk").description("Flisk CLI \u2014 start services on your machine.").version(bI.version,"-v, --version","Display version number").option("--verbose","Enable verbose output",!1).option("--template <name>","Create a project from a starter template in one command (restaurant, saas, erp, ecommerce, example)").option("--project <dir>","Directory to create the project in (default: the template name)").configureOutput({outputError:(i,A)=>A(D.red(i)),writeOut:i=>process.stdout.write(i),writeErr:i=>process.stderr.write(i)}),n.helpCommand("help [command]","Show colorful help").on("--help",()=>{ty(),process.exit(0)}),n.addHelpText("before","");for(let i of BO())n.addCommand(i);return n}function yO(n,i){let[A,u]=n;return A!=="help"||!u||u.startsWith("-")||i.some(p=>p.name()===u||p.aliases().includes(u))?void 0:u}var L1=IO();if(process.argv.length===2){let n=await F2();console.log(J2(n)),await lS(),console.log(`
1870
1870
  Commands: flisk doctor | flisk project --yes | flisk --help`),console.log(`
1871
- One command from scratch (installs, clones, boots and opens the browser):`),console.log(" npx @flisk-sh/flisk demo"),console.log(" npx @flisk-sh/flisk restaurant --project=my-stack"),process.exit(n.ok?0:1)}var k1=RO(process.argv,"--template")??j2(process.argv),yL=RO(process.argv,"--project");if(k1){let{cloneProjectTemplate:n,templateTargetDir:i}=await import("./project-2TVWT57J.js"),{assertMachineReadyOrExit:A,detectRuntimePrerequisites:u,formatRuntimeNextSteps:d}=await import("./cold-preflight-LPH7WF3B.js");await A({scope:"scaffold"});let p=d(u()),{nextAvailableProjectDir:h}=await import("./one-command-YP6L6MMM.js"),C=i(k1,yL),I=h(C,S=>{let b=SO(vO(),S);return QO(b)&&IL(b).length>0}),Q=SO(vO(),I);I!==C&&console.log(D.gray(`The folder ${C} is taken, using ${I} instead.`)),await n(k1,I,p),lS()==="installed"&&console.log("\n\u2714 flisk is installed globally, so `flisk` works from any folder.");let O=process.argv[1];if(O&&QO(Q)){let{initializeProject:S,installServiceDependencies:b,runStackQuiet:x}=await import("./one-command-YP6L6MMM.js"),{openFirstFrontend:k}=await import("./open-PF6BGKCR.js"),{startSpinner:J}=await import("./spinner-YLB6FYQH.js"),{findReadyFrontend:j}=await import("./open-PF6BGKCR.js"),ye=await j(Q,0);if(ye){console.log(D.gray(`A stack for this project is already running (${ye.name}).`));let{openFirstFrontend:Ne}=await import("./open-PF6BGKCR.js");await Ne(Q),process.exit(0)}let fe=J("Setting up the project..."),He=await S(O,Q);He.ok||(fe.fail("The project setup failed."),console.log(D.yellow(He.error??"flisk project --yes did not finish.")),process.exit(1)),fe.succeed("The project is ready.");let xe=J("Installing the service dependencies..."),Pe=(await b(Q)).filter(Ne=>!Ne.ok);if(Pe.length>0){xe.fail("Some services could not install their dependencies.");for(let Ne of Pe)console.log(D.yellow(` - ${Ne.dir}: run "bun install" there`))}else xe.succeed("The service dependencies are installed.");let we=J("Starting the stack (the first build takes a few minutes)..."),Ce=Date.now(),{readStackProgress:Le,formatProgress:ct}=await import("./stack-progress-UVREHNNB.js"),{classifyTiltPorts:Ve}=await import("./tilt-port-owner-7O5FOW5C.js"),Rt=Array.from({length:10},(Ne,Oe)=>10350+Oe),ht=!0;(async()=>{for(;ht;){let{running:Ne}=await Ve(Rt,Q,async Oe=>await Le(Oe)!==void 0);for(let Oe of Ne){let ze=await Le(Oe);if(ze){we.text=ct({...ze,elapsed:(Date.now()-Ce)/1e3});break}}await new Promise(Oe=>setTimeout(Oe,2e3))}})();let de=await x(O,Q);ht=!1;let Ue=de.data?.tiltUrl??"http://localhost:10350";de.ok||(we.fail("The stack did not come up."),console.log(D.yellow(de.error??"The stack stopped before it was ready.")),console.log(D.gray("Run `flisk up` in that folder to see the full output.")),process.exit(1)),we.succeed("The stack is up."),console.log(D.gray(` Tilt UI (live build logs): ${Ue}`)),console.log(D.gray(` Container logs: docker compose logs -f (in ${Q})`)),await k(Q).catch(Ne=>(console.log(D.yellow(`Could not open a browser: ${Ne instanceof Error?Ne.message:String(Ne)}`)),null))||console.log(D.gray(`The stack is running. Open it yourself: cd ${Q} && flisk open`))}process.exit(0)}process.argv[2]==="--doctor"&&(process.argv[2]="doctor");process.argv.length===3&&["-h","--help","help"].includes(process.argv[2])&&(ty(),process.exit(0));var DO=yO(process.argv.slice(2),L1.commands);DO&&L1.error(`error: unknown command '${DO}'`,{exitCode:1,code:"commander.unknownCommand"});L1.parse();function RO(n,i){let A=`${i}=`;for(let u=0;u<n.length;u+=1){let d=n[u];if(d.startsWith(A))return d.slice(A.length);if(d===i)return n[u+1]}}
1871
+ One command from scratch (installs, clones, boots and opens the browser):`),console.log(" npx @flisk-sh/flisk demo"),console.log(" npx @flisk-sh/flisk restaurant --project=my-stack"),process.exit(n.ok?0:1)}var k1=RO(process.argv,"--template")??j2(process.argv),yL=RO(process.argv,"--project");if(k1){let{cloneProjectTemplate:n,templateTargetDir:i}=await import("./project-WEC2GSR7.js"),{assertMachineReadyOrExit:A,detectRuntimePrerequisites:u,formatRuntimeNextSteps:d}=await import("./cold-preflight-6Z4RBFKV.js");await A({scope:"scaffold"});let p=d(u()),{nextAvailableProjectDir:h}=await import("./one-command-YP6L6MMM.js"),C=i(k1,yL),I=h(C,S=>{let b=SO(vO(),S);return QO(b)&&IL(b).length>0}),Q=SO(vO(),I);I!==C&&console.log(D.gray(`The folder ${C} is taken, using ${I} instead.`)),await n(k1,I,p),lS()==="installed"&&console.log("\n\u2714 flisk is installed globally, so `flisk` works from any folder.");let O=process.argv[1];if(O&&QO(Q)){let{initializeProject:S,installServiceDependencies:b,runStackQuiet:x}=await import("./one-command-YP6L6MMM.js"),{openFirstFrontend:k}=await import("./open-SMKISRHH.js"),{startSpinner:J}=await import("./spinner-YLB6FYQH.js"),{findReadyFrontend:j}=await import("./open-SMKISRHH.js"),ye=await j(Q,0);if(ye){console.log(D.gray(`A stack for this project is already running (${ye.name}).`));let{openFirstFrontend:Ne}=await import("./open-SMKISRHH.js");await Ne(Q),process.exit(0)}let fe=J("Setting up the project..."),He=await S(O,Q);He.ok||(fe.fail("The project setup failed."),console.log(D.yellow(He.error??"flisk project --yes did not finish.")),process.exit(1)),fe.succeed("The project is ready.");let xe=J("Installing the service dependencies..."),Pe=(await b(Q)).filter(Ne=>!Ne.ok);if(Pe.length>0){xe.fail("Some services could not install their dependencies.");for(let Ne of Pe)console.log(D.yellow(` - ${Ne.dir}: run "bun install" there`))}else xe.succeed("The service dependencies are installed.");let we=J("Starting the stack (the first build takes a few minutes)..."),Ce=Date.now(),{readStackProgress:Le,formatProgress:ct}=await import("./stack-progress-UVREHNNB.js"),{classifyTiltPorts:Ve}=await import("./tilt-port-owner-67UVQJTX.js"),Rt=Array.from({length:10},(Ne,Oe)=>10350+Oe),ht=!0;(async()=>{for(;ht;){let{running:Ne}=await Ve(Rt,Q,async Oe=>await Le(Oe)!==void 0);for(let Oe of Ne){let ze=await Le(Oe);if(ze){we.text=ct({...ze,elapsed:(Date.now()-Ce)/1e3});break}}await new Promise(Oe=>setTimeout(Oe,2e3))}})();let de=await x(O,Q);ht=!1;let Ue=de.data?.tiltUrl??"http://localhost:10350";de.ok||(we.fail("The stack did not come up."),console.log(D.yellow(de.error??"The stack stopped before it was ready.")),console.log(D.gray("Run `flisk up` in that folder to see the full output.")),process.exit(1)),we.succeed("The stack is up."),console.log(D.gray(` Tilt UI (live build logs): ${Ue}`)),console.log(D.gray(` Container logs: docker compose logs -f (in ${Q})`)),await k(Q).catch(Ne=>(console.log(D.yellow(`Could not open a browser: ${Ne instanceof Error?Ne.message:String(Ne)}`)),null))||console.log(D.gray(`The stack is running. Open it yourself: cd ${Q} && flisk open`))}process.exit(0)}process.argv[2]==="--doctor"&&(process.argv[2]="doctor");process.argv.length===3&&["-h","--help","help"].includes(process.argv[2])&&(ty(),process.exit(0));var DO=yO(process.argv.slice(2),L1.commands);DO&&L1.error(`error: unknown command '${DO}'`,{exitCode:1,code:"commander.unknownCommand"});L1.parse();function RO(n,i){let A=`${i}=`;for(let u=0;u<n.length;u+=1){let d=n[u];if(d.startsWith(A))return d.slice(A.length);if(d===i)return n[u+1]}}
1872
1872
  /*! Bundled license information:
1873
1873
 
1874
1874
  react/cjs/react-jsx-runtime.production.js:
@@ -1,2 +1,2 @@
1
1
  import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{C as a,D as b,E as c,F as d,G as e,H as f,I as g,J as h,K as i,L as j}from"./chunk-H446NBVS.js";import"./chunk-EICMGZXL.js";import"./chunk-DS47LHYF.js";import"./chunk-42IVF3YT.js";import"./chunk-RMZQU74X.js";import"./chunk-GEXOZCEQ.js";import"./chunk-LMHKXU2Q.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};
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 +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-RWNIFXXG.js";import"./chunk-DTIHDMED.js";import"./chunk-EICMGZXL.js";import"./chunk-GEXOZCEQ.js";import"./chunk-LMHKXU2Q.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-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};
@@ -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-IYZENTVI.js";import"./chunk-DS47LHYF.js";import"./chunk-42IVF3YT.js";import"./chunk-LMHKXU2Q.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-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};
@@ -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-WUO7C6WO.js";import"./chunk-RMZQU74X.js";import"./chunk-GEXOZCEQ.js";import"./chunk-LMHKXU2Q.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-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};
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.200",
4
+ "version": "1.3.201",
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.200",
3
+ "version": "1.3.201",
4
4
  "description": "Flisk CLI — start services on your machine.",
5
5
  "homepage": "https://flisk.sh",
6
6
  "repository": {
@@ -1,5 +0,0 @@
1
- import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{k as _}from"./chunk-LMHKXU2Q.js";import{execFileSync as v}from"node:child_process";import{existsSync as N,mkdirSync as A,readFileSync as y,realpathSync as F,writeFileSync as K}from"node:fs";import{join as g,resolve as L,sep as C}from"node:path";import{createServer as k}from"node:net";import{connect as R}from"node:net";function O(t,s=500){return new Promise(e=>{let r=R({port:t,host:"127.0.0.1"}),i=c=>{r.destroy(),e(c)};r.setTimeout(s,()=>i(!1)),r.once("connect",()=>i(!0)),r.once("error",()=>i(!1))})}var $={ingressHttp:{start:8080,end:8180},ingressHttps:{start:8443,end:8543},postgres:{start:15432,end:15532}},P={ingressHttp:"TDK_HTTP_PORT",ingressHttps:"TDK_HTTPS_PORT",postgres:"TDK_POSTGRES_PORT"},T={ingressHttp:80,ingressHttps:443,postgres:5432},m={ingressHttp:T.ingressHttp,ingressHttps:T.ingressHttps};function b(t,s){return t==="EACCES"&&s==="darwin"}async function S(t){return await O(t)?!1:new Promise(s=>{let e=k();e.once("error",r=>{s(b(r.code,process.platform))}),e.listen(t,"127.0.0.1",()=>e.close(()=>s(!0)))})}function D(t,s){let e=Number(s);if(!Number.isInteger(e)||e<1||e>65535)throw new Error(`${t} must be an integer between 1 and 65535 (received ${JSON.stringify(s)})`);return e}async function H(t={}){let s=t.env??process.env,e=t.isAvailable??S,r={ingressHttp:!1,ingressHttps:!1,postgres:!1},i={ingressHttp:"",ingressHttps:"",postgres:""},c={explicit:r},a=new Set;for(let n of["ingressHttp","ingressHttps","postgres"]){let f=s[P[n]],o=f!==void 0&&f.trim()!=="",p=t.ranges?.[n]??$[n],u=m[n],x=o?[D(P[n],f)]:[...u===void 0?[]:[u],...Array.from({length:p.end-p.start+1},(d,E)=>p.start+E)],l;for(let d of x)if(!a.has(d)){if(await e(d)){l=d;break}if(o)throw new Error(`${P[n]}=${d} is already in use. Choose a free host port and retry.`)}if(l===void 0)throw new Error(`No available host port in ${p.start}-${p.end} for ${n}. Set ${P[n]} to a free port and retry.`);a.add(l),c[n]=l,r[n]=o,i[n]=o?"explicit override":l===u?"requested port is free":`selected from fallback range ${p.start}-${p.end}`}return{...c,requested:{...T},reason:i}}function U(t){return`Host ports: HTTP ${t.ingressHttp}, HTTPS ${t.ingressHttps}, Postgres ${t.postgres}`}var h=g(".tdk",".tdk-out","host-ports.json");function j(t,s,e){return t.split(`
3
- `).some(r=>{let[i="",c=""]=r.split("|"),a=i.toLowerCase(),n=s.toLowerCase();return(a.startsWith(`${n}_`)||a.startsWith(`${n}-`))&&c.includes(`:${e}->`)})}function w(t){let s=g(t,h);if(!N(s))return null;try{let e=JSON.parse(y(s,"utf-8"));if(!e||typeof e!="object")return null;let r=e;return!Number.isInteger(r.ingressHttp)||!Number.isInteger(r.ingressHttps)||!Number.isInteger(r.postgres)||!r.requested||!r.explicit||!r.reason?null:r}catch{return null}}function Z(t,s){let e=g(t,h);A(g(t,".tdk",".tdk-out"),{recursive:!0}),K(e,`${JSON.stringify(s,null,2)}
4
- `,{encoding:"utf-8",mode:384})}function tt(t){process.env.TDK_HTTP_PORT=String(t.ingressHttp),process.env.TDK_HTTPS_PORT=String(t.ingressHttps),process.env.TDK_POSTGRES_PORT=String(t.postgres)}var I="com.docker.compose.project.working_dir";function G(t,s,e){let r=new Set([L(s)]);try{r.add(F(s))}catch{}return t.split(`
5
- `).some(i=>{let[,c="",a=""]=i.split("|");return!a||!c.includes(`:${e}->`)?!1:[...r].some(n=>a===n||a.startsWith(`${n}${C}`))})}function et(t,s,e=()=>v("docker",["ps","--format",`{{.Names}}|{{.Ports}}|{{.Label "${I}"}}`],{encoding:"utf-8",timeout:5e3})){let r=w(t);if(!r||r.ingressHttp===s)return s;try{if(G(e(),t,r.ingressHttp))return r.ingressHttp}catch{}return s}async function rt(t,s={}){let e=w(t),r=["TDK_HTTP_PORT","TDK_HTTPS_PORT","TDK_POSTGRES_PORT"].some(o=>process.env[o]);if(s.inspectDocker===!1&&e&&!r)return e;let i="";try{let o=JSON.parse(y(g(t,".tdk",_),"utf-8"));i=String(o?.project?.name??"tdk-project").replace(/-/g,"_").toLowerCase()}catch{i="tdk_project"}let c="";if(s.inspectDocker!==!1)try{c=v("docker",["ps","--format","{{.Names}}|{{.Ports}}"],{encoding:"utf-8",timeout:5e3})}catch{}let a=o=>j(c,i,o),n=s.isPortFree??S,f=async o=>await n(o)||a(o);if(e&&!r){for(let o of[e.ingressHttp,e.ingressHttps,e.postgres])if(!await f(o))return H({isAvailable:f});for(let[o,p]of Object.entries(m)){let u=e[o];if(p!==void 0&&u!==p&&await f(p))return H({isAvailable:f})}return e}return H({isAvailable:f})}export{H as a,U as b,w as c,Z as d,tt as e,et as f,rt as g};
@@ -1,71 +0,0 @@
1
- import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{a as xt,f as wt,g as te}from"./chunk-EICMGZXL.js";import{i as vt,o as Tt}from"./chunk-DS47LHYF.js";import{c as bt}from"./chunk-42IVF3YT.js";import{f as R,g as $t,h as Dt,i as Et,j as se,k as Nt,l as Ct,m as Rt,n as _t,o as Ot,p as re,q as jt,s as At,t as It}from"./chunk-RMZQU74X.js";import{Aa as St,Ba as yt,Ca as Pe,G as ut,O as y,Ta as x,Ua as Pt,b as v,fa as V,h as O,ja as pt,k as j,l as F,m as ge,ma as ft,na as Se,o as ke,oa as Q,pa as mt,q as ct,qa as G,s as h,t as lt,ua as ye,va as ht,wa as ee,x as D,xa as gt,y as dt,ya as kt}from"./chunk-LMHKXU2Q.js";import{b as g}from"./chunk-CF46CD6R.js";import{execFileSync as Us}from"node:child_process";import{readFileSync as ao}from"node:fs";import{join as co}from"node:path";import{execFileSync as kn,execSync as $s}from"node:child_process";import{existsSync as T,readdirSync as Sn,readFileSync as B}from"node:fs";import{join as w,normalize as Ye,relative as Ze}from"node:path";import{Command as yn}from"commander";import{existsSync as qs}from"node:fs";var ne="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 ${ne}.`,Ft=`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 ${ne}.`;function zs(){return{env:process.env,versions:process.versions,platform:process.platform,fileExists:qs}}function Ht(e=zs()){let{env:t,versions:s,platform:r,fileExists:n}=e;return s.webcontainer?{kind:"webcontainer",canUp:!1}:t.CODESPACES==="true"?{kind:"codespaces",canUp:!0}:t.REMOTE_CONTAINERS||n("/.dockerenv")&&t.DEVCONTAINER?{kind:"devcontainer",canUp:!0}:r==="win32"?{kind:"native-windows",canUp:t.TDK_ALLOW_NATIVE_WINDOWS==="1"}:r==="linux"&&t.WSL_DISTRO_NAME?{kind:"wsl2",canUp:!0}:{kind:"local",canUp:!0}}function Mt(e){return e==="devcontainer"||e==="codespaces"}function oe(e){return e.some(t=>V(t.config?.appType)||t.config?.appType==="frontend"||t.config?.appType==="worker")}import{existsSync as Xs,readFileSync as Ys}from"node:fs";import{join as Zs,relative as Lt,resolve as Bt,sep as Qs}from"node:path";var er=2,Ut=["services/*/*"];function Wt(e){return e.split(Qs).filter(Boolean)}function tr(e,t){let s=0,r=0,n=-1,o=0;for(;r<t.length;)if(s<e.length&&e[s]!=="*"&&(e[s]==="?"||e[s]===t[r]))s++,r++;else if(s<e.length&&e[s]==="*")n=s++,o=r;else if(n!==-1)s=n+1,r=++o;else return!1;for(;s<e.length&&e[s]==="*";)s++;return s===e.length}function sr(e,t){return e.length===t.length&&e.every((s,r)=>tr(s,t[r]))}function we(e){let t=Zs(e,".tdk",j);if(!Xs(t))return Ut;try{let s=JSON.parse(Ys(t,"utf-8"))?.discovery?.paths;if(Array.isArray(s)&&s.every(r=>typeof r=="string"))return s}catch{}return Ut}function ie(e,t,s){let r=Wt(Lt(e,Bt(e,t)));return s.some(n=>{let o=Wt(Lt(e,Bt(e,n)));for(let i=0;i<=er;i++){let a=r.length-i;if(a>0&&sr(o,r.slice(0,a)))return!0}return!1})}function bo(e,t,s,r){let n=we(e);if(ie(e,t,n))return{path:t};let o=`services/${s}/${r}`;return ie(e,o,n)?{path:o,adjustedFrom:t}:{path:t}}import{execFile as yr}from"node:child_process";import{promisify as Pr}from"node:util";import{execFileSync as Xt,execSync as q}from"node:child_process";import{existsSync as be,readdirSync as rr,readFileSync as ve}from"node:fs";import{join as L}from"node:path";function Vt(e,t){return e==="pending"||e==="in_progress"||e==="none"||t==="pending"||t==="none"}var Gt="container is running, but its health check is failing";function Kt(e){let t=e?.runtimeStatus??"";if(t!=="ok")return t;let s=e?.composeResourceInfo?.healthStatus;return s==="unhealthy"?"error":s==="starting"?"pending":t}var K=1e4,Jt=3e3,nr="http://localhost:4873";function Yt(e){return`'${e.replace(/'/g,"'\\''")}'`}function J(e,t,s,r,n){return process.platform==="win32"?Xt(D(t)??t,s,{...n,windowsHide:!0}):e(r,n)}var or=[80,443];function Te(e){return e.replace(/-/g,"_")}function ir(e,t){let s=new Set(t),r=[];for(let n of e.split(`
3
- `)){let o=n.trim();if(!o)continue;let i=o.indexOf(" "),a=i>=0?o.slice(0,i):o,l=i>=0?o.slice(i+1):"",c=[];for(let d of s)l.split(/[\s,]+/).some(m=>m.startsWith(`${d}->`)||m.includes(`:${d}->`))&&c.push(d);c.length>0&&r.push({name:a,ports:l,publishedPorts:c})}return r}function Zt(e,t){let s=e.toLowerCase(),r=t.toLowerCase();return s===`${r}_traefik`||s.startsWith(`${r}_traefik`)}function ar(e,t){return e.filter(s=>!Zt(s.name,t))}function $e(e){try{let t=e??Pt();return new Set(t.filter(s=>s.config?.sablier?.enable&&s.config?.sablier?.deferStart).map(s=>s.name))}catch{return new Set}}function De(e,t=new Set){let r=JSON.parse(e).items??[],n=[],o=0,i=0,a=0;for(let l of r){let c=l.metadata?.name??"unknown",d=l.status?.updateStatus??"",u=Kt(l.status),m=u==="error"&&l.status?.runtimeStatus==="ok",S=(l.status?.buildHistory?.[0]?.error??"").trim()||(m?Gt:"");if(d==="error"||u==="error"){n.push({name:c,updateStatus:d,runtimeStatus:u,error:S.replace(/\s+/g," ").slice(0,800)});continue}if(d==="ok"&&(u==="ok"||u==="not_applicable")){a+=1;continue}c!=="(Tiltfile)"&&Vt(d,u)&&(t.has(c)?i+=1:o+=1)}return{failures:n,pendingCount:o,deferredCount:i,okCount:a,total:r.length}}var cr=/failed to resolve source metadata for docker\.io\/library\/([A-Za-z0-9._-]+-l[1-4](?:-[a-z]+)*)(?::[^\s:]+)?:/i;function Ee(e){let t=e.replace(/\s+/g," ").trim(),s=t.match(/Bind for [^ ]+:(\d+) failed: port is already allocated/i);if(s)return`host port ${s[1]} is already allocated`;if(/port is already allocated/i.test(t))return"a required host port is already allocated";let r=[...t.matchAll(/ConnectionRefused downloading package manifest (@[A-Za-z0-9._/-]+)/gi)].map(a=>a[1]);if(r.length>0){let a=[...new Set(r)],l=a.slice(0,4).join(", "),c=a.length>4?` (+${a.length-4} more)`:"";return`private registry ConnectionRefused for ${l}${c} \u2014 Verdaccio (:4873) is down or unreachable from the build`}let n=t.match(cr);if(n)return`base image ${n[1]} was missing when this build started (the golden layers weren't built yet, or golden-layers-build failed) - Tilt does not retry a failed build by itself`;if(/install-deps\.sh/i.test(t)||/bun install(?: --production)?/i.test(t)||/npm (?:ci|install)/i.test(t))return"dependency install failed during ImageBuild \u2014 usually Verdaccio (:4873) unreachable or missing @scoped packages (ConnectionRefused downloading package manifest)";let o=t.match(/No such image:\s*([^\s]+)/i)?.[1]??t.match(/pull access denied for ([^,:\s]+)/i)?.[1]??void 0,i=t.match(/\bup\s+-d\s+--no-build\s+([A-Za-z0-9._-]+)/i)?.[1];if(o||i||/docker compose .*\bup\s+-d\s+--no-build\b/i.test(t)){let a=o??`${i??"service"}:dev`,l=i?` for ${i}`:"";return`compose run failed because image is missing (${a})${l} \u2014 wait for the ImageBuild resource to finish, then re-trigger the *-run-only resource`}return/bun run build/i.test(t)?"ImageBuild failed during `bun run build` (compile/typecheck) \u2014 open the resource logs in Tilt for the TypeScript/build error":(/ImageBuild:/i.test(t)||/^Command "/i.test(t),t.slice(0,220))}function qt(e){return/ConnectionRefused downloading package manifest|Verdaccio|private registry|dependency install failed during ImageBuild|install-deps\.sh|bun install/i.test(e)}function Ne(e=h()??process.cwd()){let t=L(e,".tdk",j);if(!be(t))return!1;try{let s=JSON.parse(ve(t,"utf-8"));return s.optional_infra?.verdaccio===!0||Object.values(s.phases??{}).some(r=>(r.enabledStacks??[]).includes("verdaccio"))}catch{return!1}}function Qt(e){for(let t of[L(e,".npmrc"),L(e,F)])if(be(t))try{let s=ve(t,"utf-8");if(/:4873\b/.test(s)||/verdaccio/i.test(s))return!0}catch{}return!1}function lr(e=h()??process.cwd()){return Ne(e)||Qt(e)}function Ce(e=q,t=h()??process.cwd(),s=process.env.VERDACCIO_URL??process.env.NPM_REGISTRY_URL??nr,r=!0){if(!r&&!Qt(t))return{name:"Private npm registry",didPass:!0,isSkipped:!0,message:"Verdaccio is enabled in the project config but needs a Premium license, so Flisk will not start it - skipped"};if(!lr(t))return{name:"Private npm registry",didPass:!0,isSkipped:!0,message:"Private npm registry (Verdaccio) not enabled for this project - skipped"};let n=!1;try{let a=J(e,"docker",["ps","--format","{{.Names}}"],"docker ps --format '{{.Names}}'",{stdio:"pipe",encoding:"utf-8",timeout:K});n=/verdaccio/i.test(a)}catch{}let o=!1,i="";try{let a=process.platform==="win32"?Xt("curl.exe",["-fsS","-o","NUL","-w","%{http_code}","--max-time","2",s],{stdio:"pipe",encoding:"utf-8",timeout:Jt+1e3,windowsHide:!0}).trim():e(`curl -fsS -o /dev/null -w '%{http_code}' --max-time 2 ${Yt(s)}`,{stdio:"pipe",encoding:"utf-8",timeout:Jt+1e3}).trim();o=/^[23]\d\d$/.test(a),i=`HTTP ${a}`}catch(a){i=a instanceof Error?a.message.slice(0,120):"request failed"}return o?{name:"Private npm registry",didPass:!0,message:`Private npm registry reachable at ${s}${n?" (verdaccio container running)":""}`}:n?{name:"Private npm registry",didPass:!1,message:`Verdaccio container is running but ${s} is not responding (${i}). ImageBuilds that install @scoped packages will fail with ConnectionRefused downloading package manifest.`,fix:"Check `docker logs` for the verdaccio container, confirm port 4873 is published, then re-run `flisk doctor`."}:{name:"Private npm registry",didPass:!1,message:`Private npm registry (Verdaccio) is not reachable at ${s}. Docker ImageBuilds will fail with ConnectionRefused downloading package manifests for @flisk-sh/* and project-scoped packages.`,fix:"Start the registry with `bun run verdaccio:start` (or `docker compose -f docker-compose.verdaccio.yml up -d`), publish packages with `bun run publish:all` / `scripts/build/publish-to-verdaccio.sh`, then `tilt trigger` failed resources or re-run `flisk up`."}}function Re(e=q,t=G(),s=or){let r=Te(t),n="";try{n=J(e,"docker",["ps","--format","{{.Names}}\\t{{.Ports}}"],"docker ps --format '{{.Names}}\\t{{.Ports}}'",{stdio:"pipe",encoding:"utf-8",timeout:K})}catch{return{name:"Ingress Ports",didPass:!0,isSkipped:!0,message:"Docker not available - skipped ingress port check"}}let o=ir(n,s),i=ar(o,r);if(i.length===0){let l=o.filter(c=>Zt(c.name,r));return l.length>0?{name:"Ingress Ports",didPass:!0,message:`Ingress ports ${s.join("/")} held by this project's Traefik (${l.map(c=>c.name).join(", ")})`}:{name:"Ingress Ports",didPass:!0,message:`Ingress ports ${s.join("/")} are free for Traefik`}}return{name:"Ingress Ports",didPass:!1,message:`Traefik cannot bind ingress ports because another container already owns them:
4
- ${i.map(l=>{let c=l.publishedPorts.join(", ");return`${l.name} (host ports ${c})`}).join(`
5
- `)}`,fix:`Stop the foreign container(s), e.g. \`docker stop ${i[0]?.name}\`, or shut down the other Flisk/Tilt project using that Traefik. Then re-run \`flisk up\`.`}}function dr(e){let{status:t}=e;return t===void 0?e.error??"no response":t===404?"HTTP 404: Traefik is answering but has no route for this URL (container not started yet, or not running)":t===502||t===503||t===504?`HTTP ${t}: Traefik found the route but the container isn't answering (still starting, or unhealthy)`:`HTTP ${t}`}function _e(e){let t=e.filter(o=>o.status!==void 0),s=e.filter(o=>!o.ok);if(t.length===0)return{name:"Service Health",didPass:!0,isSkipped:!0,message:`No services responded - skipped ping of ${y(e.length,"service")} (stack may be down, or Traefik never bound :80)`,fix:"If `flisk up` is already running, check Traefik/port 80 in the Tilt UI. Otherwise start with: flisk up"};if(s.length===0)return{name:"Service Health",didPass:!0,message:`All ${y(e.length,"service")} responding on /health`};let r=s.map(o=>`${o.name} (${dr(o)})
6
- ${o.url}`).join(`
7
- `),n=s.some(o=>o.status===404);return{name:"Service Health",didPass:!1,message:`${y(s.length,"service")} not healthy (${e.length-s.length}/${e.length} healthy):
8
- ${r}`,fix:n?"If `flisk up` just started, images may still be building: re-run `flisk doctor` in a minute. Otherwise check `docker ps` and the resource in the Tilt UI, and compare `flisk networks` with the URL above.":"Check container state and routing: docker ps, then flisk networks to compare the advertised URLs against Traefik's routers"}}function Oe(e){if(e.length===0)return{name:"Service Smoke",didPass:!0,isSkipped:!0,message:"No read-only smoke checks declared"};let t=e.filter(r=>!r.ok);if(t.length===0)return{name:"Service Smoke",didPass:!0,message:`All ${y(e.length,"service")} pass their smoke checks`};let s=t.map(r=>r.failure??`${r.name}: failed`).join(`
9
- `);return{name:"Service Smoke",didPass:!1,message:`${y(t.length,"service")} failing a smoke check (${e.length-t.length}/${e.length} passing):
10
- ${s}`,fix:'Add the route the smoke step expects, or correct its "path" in the service.json "smoke" block. Then re-run flisk doctor.'}}function es(e){let t=e.filter(n=>n.status!==void 0);if(t.length===0)return{name:"Advertised Endpoints",didPass:!0,isSkipped:!0,message:"No services responded - skipped advertised endpoint check"};let s=t.filter(n=>n.status===404);if(s.length===0)return{name:"Advertised Endpoints",didPass:!0,message:`${y(t.length,"advertised endpoint")} reachable`};let r=s.map(n=>`${n.name} (404)
11
- ${n.url}`).join(`
12
- `);return{name:"Advertised Endpoints",didPass:!0,isWarning:!0,message:`${y(s.length,"advertised link")} ${s.length===1?"returns":"return"} 404 (the service may be healthy, but nothing answers at this exact path):
13
- ${r}`,fix:'Nothing handles this exact path, so opening the link shows a 404 even when /health is fine. If this API has no root route, you can leave it. Otherwise add a GET route for it (for example one that returns the service name), or declare a read-only "smoke" step on a real route in service.json. The URL flisk networks and the Flisk App print stays the same until the CLI changes how it reports it.'}}function je(e=q){let t="";try{t=J(e,"tilt",["get","uiresources","-o","json"],"tilt get uiresources -o json",{stdio:"pipe",encoding:"utf-8",timeout:K})}catch{return{name:"Tilt Resources",didPass:!0,isSkipped:!0,message:"Tilt is not running - skipped resource status check",fix:"Start them with: flisk up"}}let s;try{s=De(t,$e())}catch{return{name:"Tilt Resources",didPass:!0,isSkipped:!0,message:"Could not parse Tilt resource status - skipped"}}if(s.total===0)return{name:"Tilt Resources",didPass:!0,isSkipped:!0,message:"No Tilt UIResources found"};if(s.failures.length===0){let f=s.deferredCount>0?`, ${s.deferredCount} deferred`:"";return{name:"Tilt Resources",didPass:!0,message:`Tilt resources healthy (${s.okCount} ok, ${s.pendingCount} pending${f})`}}let r=pr(s.failures),o=r.slice(0,20),i=r.length-o.length,a=o.map(f=>({failure:f,why:mr(f,e)})),l=a.map(({failure:f,why:I})=>`${f.name}: ${I}`).join(`
14
- `),c=i>0?`
15
- \u2026and ${y(i,"more failed resource")}`:"",d=s.pendingCount>0?`
16
- ${y(s.pendingCount,"resource")} still pending/not started \u2014 often blocked by the failures above.`:"",u=s.deferredCount>0?`
17
- ${y(s.deferredCount,"resource")} intentionally deferred (sablier.deferStart) \u2014 not started until first request, unrelated to the failures above.`:"",m=r.some(f=>/port is already allocated/i.test(f.error)),P=r.some(f=>qt(f.error)||qt(Ee(f.error))),S=a.some(({why:f})=>/Kafka broker unreachable|kafka:9092/i.test(f)),k="Open the Tilt UI URL printed by flisk up (default port "+ct.tiltUi+" when TILT_PORT is unset), inspect the red resources, fix the listed errors, then `tilt trigger <resource>` or re-run `flisk up`.";return m?k="Free the conflicting host port (usually 80/443): `docker ps --filter publish=80` then `docker stop <other-traefik>`. Re-trigger Traefik in the Tilt UI or run `flisk up` again.":P?k="Start Verdaccio (`bun run verdaccio:start`), ensure packages are published (`bun run publish:all` or `bash scripts/build/publish-to-verdaccio.sh`), confirm `curl http://localhost:4873` works, then `tilt trigger` the failed resources.":S&&(k="Kafka is not running (optional infra). Start it, point the bridge at a real broker, or disable Kafka-dependent resources until Kafka is enabled."),{name:"Tilt Resources",didPass:!1,message:`Tilt reports ${y(s.failures.length,"failed resource")}:
18
- ${l}${c}${d}${u}`,fix:k}}var ur=/^(traefik|postgres|nats|infisical|verdaccio|proxy)([.-]|$)/i;function zt(e){return ur.test(e)}function pr(e){return[...e].sort((t,s)=>{let r=zt(t.name)?0:1,n=zt(s.name)?0:1;return r!==n?r-n:t.name.localeCompare(s.name)})}function fr(e,t=q,s=G()){try{let r=J(t,"docker",["ps","-a","--format","{{.Names}}"],"docker ps -a --format '{{.Names}}'",{stdio:"pipe",encoding:"utf-8",timeout:K}).split(`
19
- `).map(c=>c.trim()).filter(Boolean),n=`-autogenerated-${e}-1`,o=r.find(c=>c===e)??r.find(c=>c.startsWith(`${s}-`)&&c.endsWith(n))??r.find(c=>c.endsWith(n))??r.find(c=>c.includes(e));if(!o)return null;let i=J(t,"docker",["logs","--tail","120",o],`docker logs --tail 120 ${Yt(o)} 2>&1`,{stdio:"pipe",encoding:"utf-8",timeout:K});if(/getaddrinfo ENOTFOUND/i.test(i)&&/kafka:9092/i.test(i))return"runtime crash: Kafka broker unreachable (getaddrinfo ENOTFOUND kafka:9092)";if(/ECONNREFUSED/i.test(i)&&/kafka/i.test(i))return"runtime crash: Kafka connection refused";let a=i.match(/ConnectionRefused downloading package manifest (@[A-Za-z0-9._/-]+)/i);if(a?.[1])return`runtime/build log: private registry ConnectionRefused for ${a[1]}`;if(/ZodError/i.test(i)){let c=[...i.matchAll(/"path"\s*:\s*\[\s*"([^"]+)"\s*\]/g)].map(u=>u[1]),d=[...new Set(c)].slice(0,6);return d.length>0?`runtime crash: ZodError missing required config/env: ${d.join(", ")}`:"runtime crash: ZodError during config/env validation"}let l=i.match(/error:\s+Failed to [^:\n]+[^\n]{0,120}/i)?.[0]??i.match(/Failed to (?:start|initialize) [^\n]{0,120}/i)?.[0]??i.match(/^\s*error:\s+[^\n]{0,160}/im)?.[0];if(l)return`runtime crash: ${l.replace(/\s+/g," ").trim().slice(0,180)}`}catch{return null}return null}function mr(e,t=q){return e.error?Ee(e.error):e.runtimeStatus==="error"?fr(e.name,t)??"runtime error (container crashed or unhealthy \u2014 check Tilt/docker logs)":e.updateStatus||e.runtimeStatus||"unknown error"}var hr=/\.(ts|tsx|mts|js|mjs|cjs)$/,gr=new Set(["node_modules","dist",O,"tests","__tests__"]);function ts(e){let t=[];for(let s of rr(e,{withFileTypes:!0}))s.isDirectory()?gr.has(s.name)||t.push(...ts(L(e,s.name))):hr.test(s.name)&&!/\.(test|spec)\./.test(s.name)&&t.push(L(e,s.name));return t}function kr(e){let t=e?.healthCheckPath||"/health";return{container:t,traefik:e?.traefik?.healthCheck||t}}function Sr(e){let t=[];for(let s of e){if(!V(s.config?.appType))continue;let r=L(s.path,"src");if(!be(r))continue;let n=ts(r);if(n.length===0)continue;let o=n.map(c=>ve(c,"utf-8")),{container:i,traefik:a}=kr(s.config),l=i===a?[{path:i,usedBy:"container and Traefik healthchecks"}]:[{path:i,usedBy:"container healthcheck"},{path:a,usedBy:"Traefik healthcheck"}];for(let{path:c,usedBy:d}of l){let u=["'",'"',"`"].map(m=>`${m}${c}${m}`);o.some(m=>u.some(P=>m.includes(P)))||t.push({name:s.name,healthPath:c,usedBy:d})}}return t}function ss(e=h()??process.cwd()){let t=[];try{t=x(e)}catch{return{name:"Health Routes",didPass:!0,isSkipped:!0,message:"Could not read services - skipped health route check"}}let s=t.filter(o=>V(o.config?.appType));if(s.length===0)return{name:"Health Routes",didPass:!0,isSkipped:!0,message:"No backend services to check"};let r=Sr(s);return r.length===0?{name:"Health Routes",didPass:!0,message:`All ${y(s.length,"backend")} define their health route`}:{name:"Health Routes",didPass:!1,message:`Backends without a health route (the container never turns healthy, so Traefik returns 404):
20
- ${r.map(o=>`${o.name}: no "${o.healthPath}" route in src/ (probed by the ${o.usedBy})`).join(`
21
- `)}`,fix:`Add the route, e.g. for Hono: app.get("${r[0]?.healthPath}", (c) => c.json({ status: "ok" })). To use a different path, set "healthCheckPath" (container healthcheck) or "traefik.healthCheck" (Traefik) in its service.json.`}}var xr=Pr(yr),wr=1e4,br=5,rs=10*6e4,vr=3,Tr=200,$r=async e=>{let{stdout:t,stderr:s}=await xr("docker",e,{encoding:"utf-8",timeout:wr,windowsHide:!0});return`${t}${s}`};function Dr(e,t){let s=Te(t).toLowerCase(),r=e.replace(/-/g,"_").toLowerCase();return r===s||r.startsWith(`${s}_`)}function Er(e,t=Date.now()){if(e.status==="restarting")return!0;if(e.restartCount<br)return!1;if(e.status==="running"){let r=Date.parse(e.startedAt);return Number.isNaN(r)||t-r<rs}let s=Date.parse(e.finishedAt??"");return e.exitCode!==0&&!Number.isNaN(s)&&t-s<rs}function Nr(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 Cr(e){let t=[];for(let s of e.split(/\r?\n/)){let[r,n,o,i,a,l]=s.split(" ");!r||n===void 0||t.push({name:r.replace(/^\//,""),restartCount:Number(n)||0,status:o??"",startedAt:i??"",exitCode:Number(a)||0,finishedAt:l??""})}return t}async function ns(e,t=[],s=$r,r=Date.now()){let n="Crash-looping containers",o;try{o=(await s(["ps","-a","--format",'{{.ID}} {{.Label "com.docker.compose.project"}}'])).split(/\r?\n/).map(u=>u.split(" ")).filter(([u,m])=>u&&m&&Dr(m,e)).map(([u])=>u)}catch{return{name:n,didPass:!0,isSkipped:!0,message:"Docker not available - skipped crash-loop check"}}if(o.length===0)return{name:n,didPass:!0,isSkipped:!0,message:"No project containers to check"};let i;try{i=Cr(await s(["inspect","--format","{{.Name}} {{.RestartCount}} {{.State.Status}} {{.State.StartedAt}} {{.State.ExitCode}} {{.State.FinishedAt}}",...o]))}catch{return{name:n,didPass:!0,isSkipped:!0,message:"Containers changed while checking - skipped crash-loop check"}}let a=i.filter(d=>Er(d,r));if(a.length===0)return{name:n,didPass:!0,message:"No project container is crash-looping"};let l=[],c=new Set;for(let d of a){let u="";try{u=await s(["logs","--tail",String(vr),d.name])}catch{}let m=Q(u,t).split(/\r?\n/).map(S=>S.trim().slice(0,Tr)).filter(Boolean),P=Nr(u,d);P&&c.add(P),l.push([`${d.name}: ${d.status}, restarted ${d.restartCount} times`,...m.map(S=>` | ${S}`)].join(`
22
- `))}return{name:n,didPass:!1,message:`${a.length} container${a.length===1?" is":"s are"} crash-looping:
23
- ${l.join(`
24
- `)}`,fix:[...c,"Read the full log: docker logs <container>"].join("; ")}}import{execFile as Ur}from"node:child_process";import{realpathSync as ds,statfsSync as Wr}from"node:fs";import{homedir as Vr}from"node:os";import{join as Gr}from"node:path";import{promisify as Kr}from"node:util";import{statfsSync as Rr}from"node:fs";import{homedir as _r}from"node:os";var ae="Disk Space",Or=1024**3,jr=2,Ae=10,os=["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(`
25
- `);function is(e=Rr,t=_r()){let s;try{let n=e(t);s=Number(n.bavail)*Number(n.bsize)/Or}catch{return{name:ae,didPass:!0,isSkipped:!0,message:"Could not read free disk space"}}let r=`${s.toFixed(1)} GB free`;return s<jr?{name:ae,didPass:!1,message:`${r}: Docker cannot build or start containers`,fix:os}:s<Ae?{name:ae,didPass:!1,isWarning:!0,message:`${r}: image builds may fail`,fix:os}:{name:ae,didPass:!0,message:r}}var Ar="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 as(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:Ar}}import{execFileSync as Ir}from"node:child_process";var Ie=(e,t)=>Ir(e,t,{encoding:"utf-8",stdio:"pipe",windowsHide:!0}),cs=["traefik-public","traefik-private","backend","database","infisical-network","verdaccio-network","proxy"];function Fe(e){let t=e.replace(/-/g,"_");return cs.map(s=>`${t}_${s}`)}function ls(e){let t=new Set;for(let s of e)for(let r of["traefik-public","traefik-private"])s.endsWith(`_${r}`)&&t.add(s.slice(0,-(r.length+1)));return t}function He(e,t){for(let s of cs)if(e.endsWith(`_${s}`)){let r=e.slice(0,-(s.length+1));if(t.has(r))return r}return null}function Jo(e,t=Ie){let s=new Set(t("docker",["network","ls","--format","{{.Name}}"]).split(/\r?\n/).map(n=>n.trim()).filter(Boolean)),r={removed:[],kept:[]};for(let n of Fe(e))if(s.has(n))try{t("docker",["network","rm",n]),r.removed.push(n)}catch(o){let i=String(o.stderr??o).trim();r.kept.push({name:n,reason:i.split(/\r?\n/)[0]??""})}return r}function ce(e,t=process.platform,s=Ie){if(t==="win32")return[];let r;try{r=s("ps",["-axo","pid=,command="])}catch{return[]}let n=[];for(let o of r.split(/\r?\n/)){let i=/^\s*(\d+)\s+(.*)$/.exec(o);if(!i)continue;let a=i[2]??"",l=(a.split(/\s+/)[0]??"").split("/").at(-1),c=` -f ${e}`,d=a.indexOf(c),u=a[d+c.length];l==="tilt"&&/^\S+\s+up\s/.test(a)&&d>0&&(u===void 0||u===" ")&&n.push(Number(i[1]))}return n}function qo(e,t=process.platform,s=Ie){let r=ce(e,t,s);for(let n of r)try{s("kill",["-TERM",String(n)])}catch{}return r}async function zo(e,t=8e3,s=ce){let r=Date.now()+t;for(;s(e).length>0;){if(Date.now()>=r)return!1;await new Promise(n=>setTimeout(n,250))}return!0}import{execFile as Fr}from"node:child_process";function Me(e){return new Promise(t=>{Fr(D("tilt")??"tilt",["get","uiresources","-o","json","--port",String(e)],{timeout:15e3,maxBuffer:16*1024*1024},(s,r)=>t(s?null:r))})}function Hr(e){let s=(JSON.parse(e).items??[]).filter(r=>r.status?.disableStatus?.state!=="Disabled").map(r=>r.status?.updateStatus==="not_applicable"?{...r,status:{...r.status,updateStatus:"ok"}}:r);return JSON.stringify({items:s})}function Mr(e){return(JSON.parse(e).items??[]).filter(t=>t.status?.disableStatus?.state!=="Disabled").flatMap(t=>t.metadata?.name?[t.metadata.name]:[])}function Lr(e,t){let s=JSON.parse(e).items??[],r=new Map(s.map(n=>[n.metadata?.name,n]));return{missing:t.filter(n=>!r.has(n)),disabled:t.filter(n=>r.get(n)?.status?.disableStatus?.state==="Disabled")}}function Br(e,t,s){let r=De(Hr(e),t),n={ready:r.failures.length===0&&r.pendingCount===0&&r.okCount>0,failures:r.failures.map(o=>({name:o.name,message:o.error||`${o.updateStatus}/${o.runtimeStatus}`})),pending:r.pendingCount,timedOut:!1,enabled:Mr(e)};if(s&&s.length>0){let{missing:o,disabled:i}=Lr(e,s);if(o.length>0&&(n={...n,ready:!1,pending:n.pending+o.length}),i.length>0)return{settled:!0,result:{...n,ready:!1,failures:[...n.failures,...i.map(a=>({name:a,message:"disabled in Tilt"}))]}}}return{result:n,settled:n.ready||n.failures.length>0&&n.pending===0}}async function ei(e,t={}){let s=t.timeoutMs??Number(process.env.TDK_UP_READY_TIMEOUT_MS??9e5),r=t.intervalMs??2e3,n=t.fetchJson??Me,o=t.deferred??$e(),i=Date.now()+s,a={ready:!1,failures:[],pending:0,timedOut:!1,enabled:[]};for(;;){let l=await n(e);if(l)try{let c=Br(l,o,t.expected);if(a=c.result,c.settled||a.failures.length>0&&t.isStalled?.(l))return a}catch{}if(Date.now()>=i)return{...a,ready:!1,timedOut:!0};await new Promise(c=>setTimeout(c,r))}}var le=Kr(Ur),Jr=15e3,qr=/^tdk_doctor_probe_(\d+)$/,zr=async e=>{let{stdout:t}=await le("docker",e,{encoding:"utf-8",timeout:Jr,windowsHide:!0});return t};function Le(e){return String(e.stderr??e).trim().split(/\r?\n/)[0]??""}var Xr=120;function Yr(e){let t=/^\s*(?:(?:(\d+)-)?(\d+):)?(\d+):(\d+)\s*$/.exec(e);if(!t)return null;let[,s="0",r="0",n="0",o="0"]=t;return((Number(s)*24+Number(r))*60+Number(n))*60+Number(o)}async function Zr(e,t=Me,s=2,r=n=>new Promise(o=>setTimeout(o,n))){for(let n=0;n<s;n++){n>0&&await r(1e3);for(let o of e)if(await t(o)!==null)return!0}return!1}async function Qr(e){if(process.platform==="win32")return"unknown";try{let{stdout:t}=await le("ps",["-p",String(e),"-o","etime="],{encoding:"utf-8",timeout:5e3}),s=Yr(t);if(s===null||s<Xr)return"unknown";let{stdout:r}=await le("lsof",["-nP","-a","-p",String(e),"-iTCP","-sTCP:LISTEN","-Fn"],{encoding:"utf-8",timeout:5e3}),n=[...r.matchAll(/^n.*:(\d+)$/gm)].map(o=>Number(o[1]));return await Zr(n)?"healthy":"stale"}catch{return"unknown"}}function en(e=zr){return{async listNetworks(){let t=(await e(["network","ls","--format","{{.Name}}"])).split(/\r?\n/).map(r=>r.trim()).filter(Boolean);return(await Promise.all(t.map(async r=>{try{let n=await e(["network","inspect","--format","{{len .Containers}}",r]);return{name:r,containers:Number(n.trim())||0}}catch(n){if(/no such network|not found/i.test(String(n)))return null;throw n}}))).filter(r=>r!==null)},async removeNetwork(t){try{await e(["network","rm",t])}catch(s){throw new Error(Le(s))}},freeDiskGib(){try{let t=Wr(Vr());return Number(t.bavail)*Number(t.bsize)/1024**3}catch{return null}},async reclaimable(){let t=null;try{let r=await e(["system","df","--format","{{.Type}} {{.Reclaimable}}"]);for(let n of r.split(/\r?\n/)){let[o,i]=n.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(Le(s))}},async tiltStatus(t){return Qr(t)},stopProcess(t){process.kill(t,"SIGTERM")},isProcessAlive(t){try{return process.kill(t,0),!0}catch(s){return s.code==="EPERM"}}}}var us=en();async function ps(e,t=us,s={}){let r=[],n=[];for(let d of s.tiltPids??[])await t.tiltStatus(d)==="stale"?r.push({id:`stop-tilt:${d}`,check:"Tilt processes",scope:"project",command:`kill -TERM ${d}`,status:"planned",reason:"this project's Tilt is running but its UI does not answer"}):n.push(d);let o=n.length>0?`Tilt is running for this project (pid ${n.join(", ")}); run flisk down first`:void 0,i=await t.listNetworks(),a=t.freeDiskGib();if(a!==null&&a<Ae){let{buildCache:d,danglingImages:u}=await t.reclaimable(),m=`${a.toFixed(1)} GB free`;d&&!/^0(\.0+)?\s*B$/i.test(d)&&r.push({id:"prune:builder",check:"Disk Space",scope:"host",command:"docker builder prune -f",status:"planned",reason:`${m}; ${d} of build cache reclaimable`}),u>0&&r.push({id:"prune:images",check:"Disk Space",scope:"host",command:"docker image prune -f",status:"planned",reason:`${m}; ${u} untagged image${u===1?"":"s"}`})}let l=new Set(e?Fe(e):[]),c=ls(i.map(d=>d.name));for(let d of i){let u=qr.exec(d.name),m,P,S="unused network";if(u)m="probe",P="Orphaned probe networks";else if(l.has(d.name))m="project",P="Docker networks";else if(s.machine&&He(d.name,c))m="machine",P="Docker networks",S=`unused network of project "${He(d.name,c)}"`;else continue;let k={id:`remove-network:${d.name}`,check:P,scope:m,command:`docker network rm ${d.name}`,status:"planned",reason:S};d.containers>0?(k.status="skipped",k.reason=`${d.containers} container(s) still attached`):m==="project"&&o?(k.status="skipped",k.reason=o):u&&t.isProcessAlive(Number(u[1]))&&(k.status="skipped",k.reason=`probe of a running process (pid ${u[1]})`),r.push(k)}return r}async function fs(e,t,s=us){let r=[];for(let n of e){if(n.status!=="planned"||t.dryRun){r.push(n);continue}if(!t.confirm){r.push({...n,status:"skipped",reason:"confirmation required; run in a terminal or pass --yes"});continue}let o=!1;try{o=await t.confirm(n)}catch{}if(!o){r.push({...n,status:"skipped",reason:"not confirmed"});continue}try{if(n.id.startsWith("prune:")){await s.prune(n.id==="prune:builder"?"builder":"images"),r.push({...n,status:"applied",reason:"pruned"});continue}if(n.id.startsWith("stop-tilt:")){s.stopProcess(Number(n.id.slice(10))),r.push({...n,status:"applied",reason:"stopped"});continue}await s.removeNetwork(n.id.slice(15)),r.push({...n,status:"applied",reason:"removed"})}catch(i){r.push({...n,status:"failed",reason:Le(i)})}}return r}function ms(e){return e.some(t=>t.status==="failed")}async function tn(e){try{let{stdout:t}=await le(e,["--version"],{encoding:"utf-8",timeout:5e3,windowsHide:!0});return t.trim().split(/\r?\n/)[0]||null}catch{return null}}async function sn(e=dt("flisk"),t=tn){let s=new Set,r=[];for(let n of e){let o=n;try{o=ds(n)}catch{}s.has(o)||(s.add(o),r.push({path:n,version:await t(n)}))}return r}async function hs(e){let t=e??await sn();if(t.length<=1)return{name:"Flisk installs",didPass:!0,message:"One flisk install on PATH"};let s=t.map(n=>`${n.path} (${n.version??"version unknown"})`).join(", "),r=new Set(t.map(n=>n.version));return{name:"Flisk installs",didPass:!1,isWarning:!0,message:`${t.length} flisk installs on PATH${r.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 gs(e,t=ce){let s=new Set([e]);try{s.add(ds(e))}catch{}let r=new Set;for(let n of s)for(let o of t(Gr(n,".tdk",".tdk-out","Tiltfile")))r.add(o);return[...r]}var Be=1;function rn(e,t=[]){return{schemaVersion:Be,data:e,errors:t}}function nn(e){return e instanceof ut?{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 fi(e){let t=nn(e);console.log(JSON.stringify(rn(null,[t.error]))),console.error(t.error.message),process.exit(t.exitCode)}async function Ss(e,t){let s=[],r=[],n=o=>{o.status==="fulfilled"?s.push(o.value):r.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))))n(o);for(let o of t)for(let i of await Promise.allSettled([Promise.resolve().then(o)]))n(i);return{checks:s,errors:r}}function ks(e){let t=e.find(s=>s.name===v);return t?t.didPass:null}function A(e,t,s=[],r,n){return{schemaVersion:Be,data:{ready:s.length===0&&e.every(o=>o.didPass||o.isSkipped||o.isWarning),inProject:t,checks:e,...n?{host:{...n,containerRuntimeReachable:ks(e),canUp:n.canUp&&ks(e)!==!1}}:{},...r!==void 0?{ports:{http:{requested:r?.requested.ingressHttp??80,chosen:r?.ingressHttp??null,explicit:r?.explicit.ingressHttp??!!process.env.TDK_HTTP_PORT,reason:r?.reason.ingressHttp??"port planning failed"},https:{requested:r?.requested.ingressHttps??443,chosen:r?.ingressHttps??null,explicit:r?.explicit.ingressHttps??!!process.env.TDK_HTTPS_PORT,reason:r?.reason.ingressHttps??"port planning failed"},postgres:{requested:r?.requested.postgres??5432,chosen:r?.postgres??null,explicit:r?.explicit.postgres??!!process.env.TDK_POSTGRES_PORT,reason:r?.reason.postgres??"port planning failed"}}}:{}},errors:s}}function ys(e){return e.errors.length>0?2:e.data.ready?0:1}import{existsSync as We,readFileSync as Ps}from"node:fs";import{dirname as on,join as Ue,normalize as an}from"node:path";function cn(e){let t=new Set,s=/^load\s*\(([\s\S]*?)\)/gm;for(let r of e.matchAll(s)){let n=r[1]??"",o=/["']([^"']+)["']/g,i=Array.from(n.matchAll(o),a=>a[1]);for(let a of i.slice(1))a.startsWith("_")&&t.add(a)}return Array.from(t).sort()}function xs(e,t,s){return t==="ext://tdk-cli"?Ue(s,".tdk",".tdk-out","tdk-cli-ext","Tiltfile"):t.startsWith(".")||!t.includes("://")&&!t.startsWith("@")?an(Ue(on(e),t)):null}function ln(e,t,s){let r=[],n=/^load\s*\(([\s\S]*?)\)/gm;for(let o of t.matchAll(n)){let l=(o[1]??"").match(/["']([^"']+)["']/)?.[1];if(!l)continue;let c=xs(e,l,s);c&&(We(c)||r.push(`${e}: ${l} -> ${c}`))}return r}function dn(e,t,s){let r=[],n=/^load\s*\(([\s\S]*?)\)/gm;for(let o of t.matchAll(n)){let l=(o[1]??"").match(/["']([^"']+)["']/)?.[1];if(l){let c=xs(e,l,s);c&&r.push(c)}}return r}function un(e,t){let s=new Set,r=[e];for(;r.length>0;){let n=r.pop();if(!n||s.has(n)||!We(n))continue;s.add(n);let o=Ps(n,"utf-8");for(let i of dn(n,o,t))s.has(i)||r.push(i)}return Array.from(s).sort()}function ws(){let e=h()??process.cwd(),t=Ue(e,".tdk",".tdk-out","Tiltfile");if(!We(t))return{name:"Starlark Load Exports",didPass:!0,isSkipped:!0,message:"No generated Tiltfile to check"};let s=[],r=[],n=un(t,e);for(let i of n){let a=Ps(i,"utf-8"),l=cn(a);l.length>0&&s.push(`${i}: ${l.join(", ")}`);for(let c of ln(i,a,e))r.push(c)}if(s.length===0&&r.length===0)return{name:"Starlark Load Exports",didPass:!0,message:`${y(n.length,"reachable Starlark file")} ${n.length===1?"has":"have"} valid load exports and paths`};let o=[];return s.length>0&&o.push(`Private exported symbols:
26
- ${s.join(`
27
- `)}`),r.length>0&&o.push(`Missing relative load targets:
28
- ${r.join(`
29
- `)}`),{name:"Starlark Load Exports",didPass:!1,message:`Starlark load() issues will stop Tilt before services start:
30
- ${o.join(`
31
-
32
- `)}`,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 pn}from"node:path";function de(e,t){return pn(e,t.configPath)||t.configPath}function bs(e){let t=e.config?.dependsOn;return t===void 0?[]:Array.isArray(t)&&t.every(s=>typeof s=="string")?t:null}function fn(e){let t=new Set(e.map(a=>a.name)),s=new Map(e.map(a=>[a.name,(bs(a)??[]).filter(l=>t.has(l))])),r=new Map,n=new Map,o=[],i=a=>{n.set(a,"visiting"),o.push(a);for(let l of s.get(a)??[])if(n.get(l)==="visiting"){let c=o.slice(o.indexOf(l)),d=c.indexOf([...c].sort()[0]??l),u=[...c.slice(d),...c.slice(0,d)];r.set(u.join(">"),[...u,u[0]??l])}else n.has(l)||i(l);o.pop(),n.set(a,"done")};for(let a of[...s.keys()].sort())n.has(a)||i(a);return[...r.values()]}function Ve(e=h()??process.cwd(),t=x(e)){let s=t.flatMap(r=>bs(r)===null?[`${de(e,r)} dependsOn ${JSON.stringify(r.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:`${y(s.length,"invalid dependsOn","invalid dependsOn")}:
33
- ${s.join(`
34
- `)}`,fix:'Write "dependsOn" as an array of service names, for example ["postgres", "api"]'}}function Ge(e=h()??process.cwd(),t=x(e)){let s=new Map(t.map(o=>[o.name,o])),r=fn(t);if(r.length===0)return{name:"Circular dependencies",didPass:!0,message:"No service depends on itself through dependsOn"};let n=r.map(o=>{let i=s.get(o[0]??""),a=o[1]??"";return`${i?de(e,i):o[0]} dependsOn "${a}": circular dependency ${o.join(" -> ")}`});return{name:"Circular dependencies",didPass:!1,message:`${r.length} ${r.length===1?"circular dependency":"circular dependencies"}:
35
- ${n.join(`
36
- `)}`,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 Ke(e=h()??process.cwd(),t=x(e)){let s=t.flatMap(r=>{let n=r.config?.port;return n===void 0?[]:typeof n=="number"&&Number.isInteger(n)&&n>=1&&n<=65535?[]:[`${de(e,r)} port ${JSON.stringify(n)}: 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:`${y(s.length,"invalid port")}:
37
- ${s.join(`
38
- `)}`,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=x(e)){let r=[],n=[];for(let i of s){let a=i.config?.schemaVersion;if(a===Pe)continue;let l=de(e,i);a===void 0?r.push(`${l} schemaVersion: missing`):n.push(`${l} schemaVersion ${JSON.stringify(a)}: this flisk supports ${Pe}`)}if(r.length===0&&n.length===0)return{name:"schemaVersion",didPass:!0,message:"Every service.json has a supported schemaVersion"};let o=[...r.length>0?["Run `flisk config migrate` to add the missing schemaVersion"]:[],...n.length>0?["A version this flisk does not support cannot be migrated: upgrade flisk"]:[]];return{name:"schemaVersion",didPass:!1,isWarning:!t,message:`${y(r.length+n.length,"service.json file")} without a supported schemaVersion:
39
- ${[...r,...n].join(`
40
- `)}`,fix:o.join(". ")}}function Ci(e,t){let s=Je(e,!1,t);s.didPass||(console.warn(g.yellow(`\u26A0 ${s.message}`)),s.fix&&console.warn(g.gray(` ${s.fix}`)))}function Ri(e,t={},s=process.exit){let r=t.resources??x(e),n=[se(e,r),Ve(e,r),Ge(e,r),Ke(e,r)].filter(i=>!i.didPass);if(n.length===0)return;let o=n.map(i=>`${i.message}${i.fix?`
41
- Fix: ${i.fix}`:""}`).join(`
42
- `);t.onInvalid?.(o);for(let i of n)console.error(g.red(`\u2717 ${i.message}`)),i.fix&&console.error(g.gray(` Fix: ${i.fix}`));s(1)}import{readFileSync as mn}from"node:fs";import{join as hn}from"node:path";function vs(e){let t=e.trim().match(/(\d+)\.(\d+)(?:\.(\d+))?/);return t?[Number(t[1]),Number(t[2]),Number(t[3]??0)]:null}function gn(e){try{return JSON.parse(mn(hn(e,".tdk",j),"utf-8"))?.minTdkVersion}catch{return}}function Ts(e,t){let s=gn(e);if(s===void 0)return{status:"none"};let r=typeof s=="string"?vs(s):null;if(!r||!/^\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 n=vs(t),o=n!==null&&(()=>{for(let[a,l]of r.entries()){let c=n[a]??0;if(c!==l)return c>l}return!0})(),i=r.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,N={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"},Ds="WSL2 detected. Use Docker Desktop WSL integration. Guide: docs/wsl2.md",Es="Native Windows landscape boot is unsupported. Use WSL2 Ubuntu with Docker Desktop integration. Guide: docs/wsl2.md",qe=[0,25,0],H=[1,2,0];function ue(e,t){let s=et(e);return s?tt(s,t):!1}function Pn(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 r=e.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase();if(r!=="/mnt/c"&&!r.startsWith("/mnt/c/"))return{name:"WSL project location",didPass:!0,message:`${Ds} Project is on the WSL filesystem.`};let n=`${Ds} 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:n,fix:"Move the repository under your WSL home directory (for example, ~/projects) and retry flisk doctor."}}function xn(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 wn(e=process.env,t=!1){let s=(e.TDK_BIND_ADDRESS??"").trim();return xn(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 Rs(e){let t=e.filter(r=>!r.didPass&&!r.isSkipped&&!r.isWarning),s=e.filter(r=>r.didPass||r.isSkipped||r.isWarning);return t.sort((r,n)=>{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(r)-o(n)}),[...t,...s]}function bn(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 Qe={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"},Ns=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(Qe)]);function vn(e){return!!(e.requiresContainerRuntime||e.checkName&&Ns.has(e.checkName)||e.name&&Ns.has(e.name))}function E(e,t){let s=()=>t();return s.requiresContainerRuntime=!0,s.checkName=e,s}async function Tn(e,t={}){let s=[],r=!!t.containerRuntimeFailed;for(let n of e){if(r&&vn(n)){let i=n.checkName??(n.name&&Qe[n.name]?Qe[n.name]:n.name&&n.name!=="check"&&n.name!=="fn"?n.name:"Container check");s.push({name:i,didPass:!0,isSkipped:!0,message:`Docker not running - skipped ${i} check`});continue}let o=await n();if(s.push(o),o.name===v&&!o.didPass&&(r=!0),!t.all&&!o.didPass&&!o.isSkipped&&!o.isWarning)break}return s}function $n(e){let t=0,s=0,r=0,n=0;for(let o of e)o.isSkipped?r++:o.isWarning?n++:o.didPass?t++:s++;return n>0?`${t} passed, ${n} warned, ${s} failed, ${r} skipped`:`${t} passed, ${s} failed, ${r} skipped`}function rt(e){return $t(e)}function Dn(e,t,s,r,n){return async(o=R)=>{try{return await o(t,C),{name:e,didPass:!0,message:s}}catch(i){return rt(i)?{name:e,didPass:!1,message:`${e} did not respond within ${C/1e3}s`,fix:n}:{name:e,didPass:!1,message:r,fix:n}}}}async function ze(e){try{return await R(e,C),!0}catch{return!1}}async function nt(){if(process.platform==="win32")try{return await R("docker ps",C),{name:v,didPass:!0,message:"Docker Desktop Linux container engine is running"}}catch{return{name:v,didPass:!1,message:"Docker is not running",fix:N.dockerDaemonDown}}let e=!!D("docker");try{return await R("docker ps",C),{name:v,didPass:!0,message:"Docker daemon is running"}}catch(s){if(rt(s))return{name:v,didPass:!1,message:"Docker daemon is not responding",fix:N.dockerDaemonDown}}let t=as(await ze("pgrep -f com.docker.backend"));return t||(await ze("colima status")?{name:v,didPass:!0,message:"Colima (Docker runtime) is running"}:D("colima")?{name:v,didPass:!1,message:"Colima is installed but not running",fix:N.dockerDaemonDown}:await ze("podman ps")?{name:v,didPass:!0,message:"Podman is running"}:e?{name:v,didPass:!1,message:"Docker daemon is not running",fix:N.dockerDaemonDown}:{name:v,didPass:!1,message:"Docker is not running",fix:N.dockerMissing})}var z=Dn("Docker Compose","docker compose version","Docker Compose plugin available","Docker Compose plugin not found","Install Docker Compose: https://docs.docker.com/compose/install/");z.requiresContainerRuntime=!0;z.checkName="Docker Compose";var En=[25,0,0],Nn=[2,20,2];function et(e){let t=e.trim().match(/(\d+)\.(\d+)(?:\.(\d+))?/);return t?[Number(t[1]),Number(t[2]),Number(t[3]??0)]:null}function tt(e,t){for(let[s,r]of t.entries()){let n=e[s]??0;if(n!==r)return n>r}return!0}async function X(e=R){let t=async a=>String(await e(a,C)).trim(),s,r;try{[s,r]=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 n=et(s),o=et(r);if(!n||!o)return{name:"Docker Versions",didPass:!0,isSkipped:!0,message:`Unrecognized Docker version output (engine "${s}", compose "${r}") - skipped version check`};let i=[];return tt(n,En)||i.push(`Docker Engine ${s} (need 25.0+)`),tt(o,Nn)||i.push(`Docker Compose ${r} (need 2.20.2+)`),i.length===0?{name:"Docker Versions",didPass:!0,message:`Docker Engine ${s} and Compose ${r} support generated healthchecks`}:{name:"Docker Versions",didPass:!1,message:`Docker is too old for generated healthchecks (they use start_interval):
43
- ${i.join(`
44
- `)}`,fix:"Update Docker Desktop, or on Linux update docker-ce and the docker-compose-plugin package"}}X.requiresContainerRuntime=!0;X.checkName="Docker Versions";async function ot(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:N.tiltMissing}}return ue(t,qe)?{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${qe.join(".")} floor`,fix:`Install Tilt v${qe.join(".")} or newer: https://docs.tilt.dev/install.html`}}async function it(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"}}it.requiresContainerRuntime=!0;it.checkName="Docker OS";async function Cn(e=R){let t=h();if(!t)return{name:"Bun",didPass:!0,isSkipped:!0,message:"Not in a project - skipping Bun check"};if(!oe(x(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 ue(s,H)?{name:"Bun",didPass:!0,message:`Bun ${s} is available`}:{name:"Bun",didPass:!1,message:`Bun ${s||"version unknown"} is below the required ${H.join(".")} floor`,fix:`Install Bun ${H.join(".")} or newer: https://bun.sh/install`}}catch{return{name:"Bun",didPass:!1,message:"Bun is not available",fix:N.bunMissing}}}function Rn(){let e=h()??process.cwd(),t=pt(e);if(t.missing.length>0)return{name:"Environment Variables",didPass:!1,message:`Missing required env variables: ${t.missing.join(", ")}`,fix:T(w(e,".env"))?`Edit .env and set these values:
45
- ${t.missing.map(r=>`${r}=<value>`).join(`
46
- `)}`:"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(r=>!r.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 _n(){let e=h()??process.cwd(),t=w(e,".tdk",".tdk-out"),s=ge.filter(r=>!T(w(t,r)));return s.length===0?{name:"Master Configs",didPass:!0,message:`${ge.join(", ")} found`}:{name:"Master Configs",didPass:!1,message:`Master configs missing: ${s.join(", ")}`,fix:"Run: flisk project"}}function On(e=lt()){let t=h();if(!t)return{name:"Flisk version",didPass:!0,isSkipped:!0,message:"Not in a project - skipping Flisk version check"};let s=Ts(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 jn(){let e=h()??process.cwd(),t=we(e),s=x(e).filter(n=>!ie(e,n.path,t));if(s.length===0)return{name:"Resource Discovery",didPass:!0,message:`All resources are covered by discovery.paths ${JSON.stringify(t)}`};let r=s.map(n=>Ye(Ze(e,n.path))).join(", ");return{name:"Resource Discovery",didPass:!1,message:`${y(s.length,"resource")} outside discovery.paths ${JSON.stringify(t)}: ${r}. \`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 An=["install-deps.sh","bun-hoisted-symlink-fix.sh","prisma-bun-client-link-fix.sh","prisma-normalize-client.sh","infisical-entrypoint.sh"],In=/shared-platform-engineering\/docker-templates\/([\w.-]+)/g;function Fn(e){let t=new Set;for(let s of x(e)){let r=w(s.path,O);if(T(r)){for(let n of Sn(r))if(!(!n.startsWith("Dockerfile")||n.endsWith(".dockerignore")))for(let o of B(w(r,n),"utf-8").matchAll(In))t.add(o[1])}}return[...t]}function Hn(){let e=h()??process.cwd(),t=[];T(w(e,F))||t.push(`${F} (workspace root manifest)`);let s=w(e,"shared-platform-engineering","docker-templates"),r=[];try{r=Fn(e)}catch{}for(let n of new Set([...An,...r]))T(w(s,n))||t.push(`shared-platform-engineering/docker-templates/${n}`);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:
47
- ${t.join(`
48
- `)}`,fix:"Run `flisk project --yes` (or `flisk config regenerate`) with an updated Flisk. `flisk up` also refreshes these assets before starting Tilt."}}function Mn(){let e=h()??process.cwd(),t=x(e),s=[];for(let r of t){let n=w(r.path,F);if(!T(n))continue;let o=r.config?.appType??"backend",i=ke[o]??ke.backend,a;try{a=JSON.parse(B(n,"utf-8")).scripts??{}}catch{s.push(`${r.name} (package.json is invalid JSON)`);continue}let l=i.filter(c=>!a[c]);l.length>0&&s.push(`${r.name}: missing "${l.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:
49
- ${s.join(`
50
- `)}`,fix:`Add the missing scripts to each service's package.json, e.g.:
51
- "dev": "bun run src/index.ts",
52
- "build": "tsc",
53
- "start": "bun run dist/index.js"`}}function _s(e){if(e.startsWith("@"))return[e.split("/").slice(0,2).join("/")];let t=e.split("/")[0]??e;return[`@types/${t}`,t]}function Os(e,t,s=0){let r=e[t];if(typeof r!="string"||s>3)return!1;if(/(^|[\s;&|(])tsc(\s|$)/.test(r))return!0;for(let n of r.matchAll(/\b(?:bun|npm|pnpm|yarn)\s+run\s+([\w:.-]+)/g))if(Os(e,n[1],s+1))return!0;return!1}function Cs(e){let t=_s(e);return e.includes("/")||e.startsWith("@")?t[t.length-1]:t[0]}var Ln={"@types/bun":"^1.4.2","@types/node":"^20.0.0"};function Bn(e,t){return(t.includes("bun")||e.has("@types/bun"))&&!e.has("@types/node")}function Un(){let e=h()??process.cwd(),t=x(e),s=[],r=new Set;for(let o of t){let i=w(o.path,F),a=w(o.path,O,"tsconfig.docker.autogenerated.json");if(!T(i)||!T(a))continue;let d=st(a)?.compilerOptions?.types;if(!Array.isArray(d))continue;let u=st(i),m=u?.scripts??{};if(!Os(m,"build"))continue;let P=new Set([...Object.keys(u?.devDependencies??{}),...Object.keys(u?.dependencies??{})]),S=d.filter(k=>typeof k=="string").filter(k=>!_s(k).some(f=>P.has(f)));for(let k of S)r.add(Cs(k));if(S.length>0){let k=S.map(f=>`"${f}" (needs ${Cs(f)})`).join(", ");s.push(`${o.name}: "types" lists ${k}`)}Bn(P,d)&&(r.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 n=[...r].map(o=>{let i=Ln[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:
54
- ${s.join(`
55
- `)}`,fix:`Add to each service's package.json devDependencies: ${n.join(", ")}`}}function st(e){try{return JSON.parse(B(e,"utf-8"))}catch{return null}}function Wn(e){let s=st(e)?.compilerOptions;return s?.allowSyntheticDefaultImports===!0||s?.esModuleInterop===!0}function Vn(){let e=h()??process.cwd(),t=x(e).filter(r=>r.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 r of t){T(w(r.path,"public"))||s.push(`${r.name}: no public/ folder, but the Docker build copies it. Create it: mkdir -p ${Ye(Ze(e,w(r.path,"public")))} && touch ${Ye(Ze(e,w(r.path,"public",".gitkeep")))}`);let n=w(r.path,O,"Dockerfile.app.autogenerated"),o=w(r.path,O,"tsconfig.docker.autogenerated.json");if(T(n)){let i=B(n,"utf-8"),a=/\bEXPOSE\s+80\b/.test(i),l=r.config?.stack,c=l?w(e,"services",l,O,"docker-compose.app.autogenerated.yml"):"";if(a&&c&&T(c)){let d=B(c,"utf-8"),u=r.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),m=new RegExp(`traefik\\.http\\.services\\.${u}\\.loadbalancer\\.server\\.port=(\\d+)`),S=d.match(m)?.[1];S&&S!=="80"&&s.push(`${r.name}: nginx runtime exposes 80, but generated Traefik routes to ${S}`)}}if(T(o)&&!Wn(o)){let i=w(r.path,"src","main.tsx");if(T(i)){let a=B(i,"utf-8"),l=[/import\s+\w+\s+from\s+["']react["']/,/import\s+\w+\s+from\s+["']react-dom\/client["']/].filter(c=>c.test(a)).map(c=>c.source.includes("react-dom")?"react-dom/client":"react");l.length>0&&s.push(`${r.name}: Docker tsconfig does not allow synthetic default imports, but src/main.tsx default-imports ${l.join(" and ")}`)}}}return s.length===0?{name:"Frontend Docker Preflight",didPass:!0,message:`${y(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:
56
- ${s.join(`
57
- `)}`,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 Gn=90,Kn=80;function Jn(e){return e.split(`
58
- `).map(t=>t.trim()).filter(Boolean).map(t=>{let[s,r,n]=t.split(",");return{name:s??"unknown",memPct:Number.parseFloat((r??"").replace(/%/g,"")),cpuPct:Number.parseFloat((n??"").replace(/%/g,""))}}).filter(t=>Number.isFinite(t.memPct)&&Number.isFinite(t.cpuPct))}var qn=Object.assign(function(){let t;try{t=kn(D("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:rt(o)?"Docker not responding - skipped container resource check":"Docker not running - skipped container resource check"}}let s=Jn(t);if(s.length===0)return{name:"Container Resource Health",didPass:!0,isSkipped:!0,message:"No running containers to check"};let r=s.filter(o=>o.memPct>=Gn&&o.cpuPct>=Kn);if(r.length===0)return{name:"Container Resource Health",didPass:!0,message:`${y(s.length,"container")} within normal resource usage`};let n=r.map(o=>`${o.name} (mem ${o.memPct.toFixed(0)}%, cpu ${o.cpuPct.toFixed(0)}%)`).join(`
59
- `);return{name:"Container Resource Health",didPass:!1,message:`${y(r.length,"container")} pinned near its memory limit while burning CPU -- likely stuck in a boot-time retry/fetch loop, not a normal crash:
60
- ${n}`,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"}),zn=5e3;async function Xn(e,t){let s=h()??process.cwd(),r=ye(x(s),t);return r.length===0?{name:"Service Health",didPass:!0,isSkipped:!0,message:"No routable services to ping"}:_e(await ee(r,e))}async function Yn(e,t){let s=h()??process.cwd(),r=x(s),n=kt(gt(r,t),{timeoutSeconds:Math.ceil(e/1e3)});return n.length===0?Oe([]):(await ee(ye(r,t),e)).some(i=>i.status!==void 0)?Oe(await yt(n,St(s))):{name:"Service Smoke",didPass:!0,isSkipped:!0,message:"No services responded - skipped smoke checks"}}async function Zn(e,t){let s=h()??process.cwd(),r=x(s),n=ht(r,t);return n.length===0?{name:"Advertised Endpoints",didPass:!0,isSkipped:!0,message:"No routable services to check"}:es(await ee(n,e))}function Qn(e,t){if(e.length===0){console.log(`${g.green("\u2713")} Nothing to repair
61
- `);return}for(let s of e){let r=s.status==="planned"?`${g.cyan("would run")}`:s.status==="applied"?g.green("ran"):s.status==="failed"?g.red("failed"):g.gray("skipped"),n=s.status==="planned"?"":` (${s.reason})`;console.log(`${r}: ${s.command}${n}`)}t&&console.log(g.gray(`
62
- Dry run: nothing was changed.`)),console.log("")}function Xe(e){for(let t of Rs(e))!t.didPass&&!t.isSkipped&&!t.isWarning?(console.log(`${g.red("\u2717")} ${t.message}`),t.fix&&console.log(`${g.blue("\u2139")} Fix: ${t.fix}`)):t.isWarning?(console.log(`${g.yellow("\u26A0")} ${g.yellow(t.message)}`),t.fix&&console.log(`${g.blue("\u2139")} Fix: ${t.fix}`)):t.isSkipped?(console.log(`${g.gray("\u25CB")} ${g.gray(t.message)}`),t.fix&&console.log(`${g.blue("\u2139")} ${t.fix}`)):console.log(`${g.green("\u2713")} ${t.message}`)}function eo(e,t,s,r={},n){let o=n??[...e,...t];r.all?(console.log(g.bold("Machine")),Xe(e),console.log(`
63
- ${g.bold("Project")}`),s?t.length>0&&Xe(t):console.log(`${g.gray("\u25CB")} ${g.gray("Not in a Flisk project, so project checks were skipped")}`),console.log(""),console.log($n(o))):(Xe(o),console.log(""),o.every(a=>a.didPass||a.isSkipped||a.isWarning)&&!s&&(console.log(`${g.gray("\u25CB")} ${g.gray("Not in a Flisk project, so project checks were skipped")}`),console.log("")))}var to=new yn("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),to.opts().json&&console.log(JSON.stringify(A([],!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(zn)).action(async e=>{let t=Number(e.pingTimeout);if(!/^\d+$/.test(e.pingTimeout)||!Number.isSafeInteger(t)||t<=0){let p="--ping-timeout must be a positive integer number of milliseconds";e.json&&console.log(JSON.stringify(A([],!1,[{code:"USAGE",message:p}]))),console.error(p),process.exit(2);return}let s=!["project","machine"].includes(e.scope),r=e.scope!=="project"&&!e.fix;if(s||r||(e.dryRun||e.yes)&&!e.fix){let p=s?`--scope must be project or machine, got "${e.scope}"`:r?"--scope only applies with --fix":`${e.dryRun?"--dry-run":"--yes"} only applies with --fix`;e.json&&console.log(JSON.stringify(A([],!1,[{code:"USAGE",message:p}]))),console.error(p),process.exit(2);return}e.json||console.log("Flisk doctor checks your local Docker + Tilt development environment; it does not check cluster deployments.");let n=Ht();if(process.platform==="win32"){if(e.json){let p=null;try{p=await xt()}catch{}console.log(JSON.stringify(A([{name:"Native Windows support",didPass:!1,message:Es,fix:"Use WSL2 Ubuntu with Docker Desktop integration. Guide: docs/wsl2.md"}],!!h(),[],p,{...n,canUp:!1})))}console.error(Es),process.exit(1);return}if(n.kind==="webcontainer"){let p=A([{name:"Host",didPass:!1,message:xe,fix:`Use a machine with Docker. Guide: ${ne}`}],!!h(),[],void 0,n);e.json&&console.log(JSON.stringify(p)),console.error(xe),process.exit(1);return}e.json||(console.log(`
64
- ${g.bold("\u{1F50D} Flisk Doctor")}
65
- `),console.log(`Checking environment...
66
- `));let o=h(),i;if(e.fix){try{let p;if(o)try{p=vt(o).project.name}catch{}let b=o?gs(o):[],fe=await ps(p,void 0,{tiltPids:b,machine:e.scope==="machine"});i=await fs(fe,{dryRun:e.dryRun,confirm:e.yes||!e.json&&process.stdin.isTTY?async $=>e.yes||await Tt({message:`Run \`${$.command}\` (${$.check}, ${$.reason})?`}):void 0})}catch(p){i=[{id:"plan-fixes",check:"Docker networks",scope:"project",command:"docker network ls",status:"failed",reason:`could not list Docker networks: ${(p instanceof Error?p.message:String(p)).split(/\r?\n/)[0]}`}]}e.json||Qn(i,e.dryRun)}let a,l;try{a=await te(o??process.cwd())}catch(p){a=null,l=p instanceof Error?p.message:String(p)}let c=[()=>a?{name:"Host Ports",didPass:!0,message:`HTTP ${a.ingressHttp}, HTTPS ${a.ingressHttps}, Postgres ${a.postgres}`}:{name:"Host Ports",didPass:!1,message:l??"Could not select host ports",fix:"Set TDK_HTTP_PORT, TDK_HTTPS_PORT, or TDK_POSTGRES_PORT to available host ports."},()=>a?Re($s,void 0,[a.ingressHttp,a.ingressHttps]):{name:"Ingress Ports",didPass:!1,message:"Ingress port plan is unavailable"},nt,()=>is(),E("Docker OS",it),ot,E("Docker Compose",z),E("Docker Versions",X),Cn,()=>Pn(h()??process.cwd(),e.strict),()=>wn(process.env,e.strict),E("Docker Network Pool",()=>It()),()=>hs()],d=[()=>On(),_n,Hn,ws,Mn,()=>ss(),Un,Vn,jn,()=>Et(),()=>se(),()=>Ve(),()=>Ge(),()=>Ke(),()=>Je(void 0,e.strict),()=>Nt(),()=>Ct(),()=>_t(),()=>Rt(),()=>re(),()=>Dt(),()=>jt(),()=>Ot(),()=>At(),Rn,async()=>{let p=h()??process.cwd(),b=Ne(p)?await bt(p):!0;return Ce($s,p,void 0,b)},E("Container Resource Health",qn),E("Crash-looping containers",()=>{let p=h()??process.cwd(),b=[];try{b=Se(p)}catch{return{name:"Crash-looping containers",didPass:!0,isSkipped:!0,message:"Could not read .env - skipped crash-loop check"}}return ns(G(),b)}),E("Tilt Resources",je)];if(e.ping){let p=o?wt(o,a?.ingressHttp):a?.ingressHttp;d.push(E("Service Health",()=>Xn(t,p))),d.push(E("Service Smoke",()=>Yn(t,p))),d.push(E("Advertised Endpoints",()=>Zn(t,p)))}let u=!!o,m=[],P=[],S,k=[];if(e.json||!e.all){let p=await Ss(c,u?d:[]);S=p.checks,k=p.errors}else{let p=async($,Ks=!1)=>{let Js=$.map(Z=>{let me=async()=>{try{return await Z()}catch(he){return k.push({code:"INTERNAL",message:he instanceof Error?he.message:String(he)}),{name:Z.checkName??"Doctor check",didPass:!1,isSkipped:!1,message:"Check failed with an internal error"}}};return me.requiresContainerRuntime=Z.requiresContainerRuntime,me.checkName=Z.checkName,me});return Tn(Js,{all:!!e.all,containerRuntimeFailed:Ks})};m=await p(c);let b=m.some($=>!$.didPass&&!$.isSkipped&&!$.isWarning),fe=m.some($=>$.name===v&&!$.didPass);u&&(e.all||!b)&&(P=await p(d,fe)),S=[...m,...P]}if(Mt(n.kind))for(let p of S)p.name===v&&!p.didPass&&(p.fix=Ft);let f=A(Rs(S),u,k,a,n);i&&(f.data.actions=i),i&&ms(i)&&(f.data.ready=!1);let M=ys(f),W=f.data.ready;if(e.json){let p;try{p=Se(h()??process.cwd())}catch(b){if(!(b instanceof ft))throw b;console.log(JSON.stringify(A([],u,[...k,{code:"ENV_UNREADABLE",message:b.message}]))),console.error(b.message),process.exit(1)}console.log(JSON.stringify(mt(f,p)));for(let b of k)console.error(Q(b.message,p));M!==0&&process.exit(M);return}for(let p of k)console.error(`${g.red("\u2717")} Doctor check failed: ${p.message}`);eo(m,P,u,e,S);let at=bn(u,W);console.log(`${W?g.green(g.bold("\u2713")):g.red(g.bold("\u2717"))} ${at}`),M!==0&&process.exit(M)});function js(e){return ue(e,H)}var Y=`${H[0]}.${H[1]}+`;import{execFileSync as As}from"node:child_process";import{accessSync as Is,constants as Fs,readdirSync as so}from"node:fs";import{delimiter as ro,join as U}from"node:path";var _="flisk",Hs="@flisk-sh/flisk",no="https://github.com/flisk-sh/flisk",Ms="@tdk-landscape/tdk-cli-core";function Ls(e=_,t=process.env){let s=t.PATH??t.Path??"";for(let r of s.split(ro)){if(!r)continue;let n=[U(r,e),U(r,`${e}.cmd`),U(r,`${e}.exe`)];for(let o of n)try{return Is(o,Fs.X_OK),!0}catch{}}return!1}function oo(e=process.env){let t=e.HOME??e.USERPROFILE??"";if(!t)return"flisk-workspace";let s=U(t,"Documents");try{return Is(s,Fs.F_OK),U(s,"flisk")}catch{return U(t,"flisk")}}function io(e){try{return so(e).every(t=>t.startsWith("."))}catch{return!0}}function Bs(e=process.env,t=process.cwd()){if(!Ls(_,e))return`The \`${_}\` command is not on PATH (this run is not a global install). Install it with \`npm install -g ${Hs}\`, then run \`${_} project --yes\`. If npm reports EEXIST for \`flisk\`, the old package still owns that command: run \`npm uninstall -g ${Ms}\` first. The current release is published from ${no}.`;if(io(t))return`Next: ${_} project --yes`;let s=oo(e);return`Next: mkdir -p ${s} && cd ${s} && ${_} project --yes
67
- (${_} 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: ${_} project example)`}function wa(e=process.env){if(Ls(_,e))return"present";let t=e.npm_execpath?.includes("bun")?"bun":"npm",s=t==="bun"?"bun remove -g":"npm uninstall -g";try{As(s,[Ms],{stdio:"ignore",timeout:12e4})}catch{}try{return As(t,["install","-g",Hs],{stdio:"inherit",timeout:3e5}),"installed"}catch{return"failed"}}var lo=["docker","compose","tilt"],Vs=["node","bun","ports"],Gs=["node",...lo,"bun","ports"];function uo(e,t){return{id:e,ok:t.didPass||!!t.isSkipped,message:t.message,fix:t.fix}}function Ws(e){let[t=0,s=0]=String(e).split(".").map(r=>Number.parseInt(r,10));return!Number.isFinite(t)||!Number.isFinite(s)||t<22||t===22&&s<12}async function pe(e,t,s){try{return uo(e,await t())}catch{return{id:e,ok:!1,message:s}}}function po(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 fo(e){try{return x(e).some(t=>t.config?.featuresEnabled?.includes("prisma")??!1)}catch{return!1}}async function mo(e={}){let t=e.cwd??process.cwd(),s=e.scope??"runtime",r=h(t),n=!!r,o=[],i=process.versions.node;o.push({id:"node",ok:!Ws(i),message:i,fix:Ws(i)?`Install Node.js 22.12+ (current: ${i}). https://nodejs.org`:void 0}),s==="runtime"&&(o.push(await pe("docker",nt,"Docker daemon is not running")),o.push(await pe("compose",async()=>{let[f,I]=await Promise.all([z(),X()]);return f.didPass?po(I):f},"Docker Engine or Compose version check failed")),o.push(await pe("tilt",ot,"Tilt CLI not found")));let a=r?oe(x(r)):!0,l=!1,c=a?D("bun"):void 0;if(c)try{let f=Us(c,["--version"],{encoding:"utf-8",timeout:3e3}).trim();l=js(f)}catch{}o.push(a?{id:"bun",ok:l,message:l?`Bun ${Y} is available on PATH`:`Bun ${Y} not found on PATH`,fix:l?void 0:"curl -fsSL https://bun.sh/install | bash"}:{id:"bun",ok:!0,message:"Bun not needed: no generated JS services"});try{let f=await te(r??t,s==="scaffold"?{inspectDocker:!1}:{});o.push({id:"ports",ok:!0,message:`HTTP ${f.ingressHttp}, HTTPS ${f.ingressHttps}, Postgres ${f.postgres}`})}catch(f){o.push({id:"ports",ok:!1,message:f instanceof Error?f.message:String(f),fix:"Set TDK_HTTP_PORT, TDK_HTTPS_PORT, or TDK_POSTGRES_PORT to available host ports."})}if(r&&s==="runtime"){let f=await pe("nats",()=>re(r),"NATS broker check failed");if(f.ok||o.push(f),fo(r)){let I=!1;try{let M=JSON.parse(ao(co(r,".tdk",j),"utf-8")),W=String(M?.project?.name??"").replace(/-/g,"_");W&&(I=Us(D("docker")??"docker",["ps","--filter",`label=com.docker.compose.project=${W}`,"--filter","label=com.docker.compose.service=postgres","--filter","health=healthy","--format","{{.Names}}"],{encoding:"utf-8",timeout:3e3}).trim().length>0)}catch{}I||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 d=o.filter(f=>!f.ok).slice(0,8),u=s==="scaffold"?Vs:Gs,m=d.some(f=>u.includes(f.id)),P=d.some(f=>f.id==="bun"),S=d.length?m?s==="scaffold"?P?`Project setup blocked. Bun ${Y} must be installed on PATH.
68
- Fix the machine checks below.`:"Project setup blocked. Fix the machine checks below.":P?`Cold start blocked. Bun ${Y} must be installed on PATH.
69
- 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=d.length?"":n?"Environment ready for Flisk":`This machine is ready for Flisk.
70
- ${Bs()}`;return{ok:d.length===0,inProject:n,items:d,header:S,footer:k}}function ho(e,t={}){let s=[e.header];for(let r of e.items)s.push(`FAIL ${r.id.padEnd(7)} ${r.message}`),r.fix&&s.push(` ${r.fix}`);return e.footer&&(t.includeSuccessFooter??!0)&&s.push(e.footer),s.filter(Boolean).join(`
71
- `)}async function Fa(e={}){let t=e.scope??"runtime",s=await mo({scope:t}),r=t==="scaffold"?Vs:Gs;s.items.some(o=>r.includes(o.id))&&(console.error(ho(s)),process.exit(1))}function Ha(e=D){return{hasDockerCli:!!e("docker"),hasTiltCli:!!e("tilt")}}function Ma(e){let t=[];return e.hasDockerCli||t.push(`Docker is not installed. ${N.dockerMissing}`),e.hasTiltCli||t.push(`Tilt is not installed. ${N.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{rn as a,nn as b,fi as c,xe as d,Ft as e,Ht as f,Mt as g,we as h,ie as i,bo as j,Vt as k,Kt as l,$e as m,De as n,Ee as o,Jo as p,qo as q,zo as r,Me as s,Hr as t,Br as u,ei as v,Ci as w,Ri as x,Ts as y,to as z,Ms as A,wa as B,lo as C,Vs as D,Gs as E,Ws as F,po as G,mo as H,ho as I,Fa as J,Ha as K,Ma as L};
@@ -1,4 +0,0 @@
1
- import{createRequire as __tdkRequire}from'node:module';const require=__tdkRequire(import.meta.url);
2
- import{a as x}from"./chunk-DTIHDMED.js";import{g as w}from"./chunk-EICMGZXL.js";import{a as y}from"./chunk-GEXOZCEQ.js";import{Ra as h,ba as d,ca as u,d as l,k as f,ra as m,s as p,ta as g}from"./chunk-LMHKXU2Q.js";import{b as a}from"./chunk-CF46CD6R.js";import{Command as O}from"commander";import{readFileSync as $}from"node:fs";import{join as j}from"node:path";function A(n){let e=n.config;return e?Array.isArray(e.featuresEnabled)&&e.featuresEnabled.includes(l)?!0:(Array.isArray(e.dependsOn)?e.dependsOn:[]).some(t=>y.includes(t)):!1}function H(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(A).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 k(n){try{let e=JSON.parse($(j(n,".tdk",f),"utf-8"));return typeof e?.project?.name=="string"?e.project.name:null}catch{return null}}import{spawn as P}from"node:child_process";function N(n){try{let e=new URL(n);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}function S(n,e=process.platform,i=P){if(!N(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 B(n,e=process.platform,i=P){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}=h(n),i=await w(n,{inspectDocker:!1}),{appBase:t}=m(i?.ingressHttp,n);return e.filter(o=>o.config?.appType==="frontend").map(o=>({name:o.name,url:`${t}${g(o)}`}))}async function b(n,e=2e3){try{return(await fetch(n,{signal:AbortSignal.timeout(e)})).status<500}catch{return!1}}async function T(n,e=3e4,i){if(n.length===0)return;let t=Date.now(),o=t+e;for(;;){for(let s of n)if(await b(s.url))return s;let r=Date.now()-t;if(r>=e)return;i?.(r),await new Promise(s=>setTimeout(s,2e3))}}async function Q(n,e=0,i){let t=await E(n);return T(t,e,i)}async function F(n){let e=n??p();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=k(e);d(`Opening the first frontend of ${t??"this project"}`);for(let c of i)console.log(a.gray(` - ${c.name}: ${c.url}`));let o=x("Waiting for the frontend to answer..."),r=await T(i,12e4,c=>{o.text=`Waiting for the frontend to answer... ${Math.round(c/1e3)}s`});if(!r){o.fail("No frontend answered yet."),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 c of i)console.log(a.gray(` - ${c.name}: ${c.url}`));return null}o.succeed(`The frontend is up: ${r.name}`);let s=await S(r.url);return console.log(s?a.green(`
3
- Opened ${r.url}`):a.yellow(`
4
- Could not open a browser. Open ${r.url} yourself.`)),u("Run `flisk open` again to open the next frontend."),r.url}var X=new O("open").description("Open the first frontend of the project in your browser").action(async()=>{await F()});export{H as a,k as b,S as c,B as d,E as e,b as f,T as g,Q as h,F as i,X as j};