@tdk-landscape/tdk-cli-core 1.3.170 → 1.3.171
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/dist/agent-runtimes/custom.js +151 -0
- package/cli/dist/agent-runtimes/registry.js +36 -0
- package/cli/dist/backend-frameworks/registry.js +16 -0
- package/cli/dist/commands/help.js +1 -0
- package/cli/dist/commands/resource.js +39 -7
- package/cli/dist/types/index.js +2 -0
- package/cli/dist/utils/constants.js +4 -0
- package/cli/dist/utils/doctor-wiring.js +1 -1
- package/cli/dist/utils/resource-kind.js +1 -1
- package/cli/dist/utils/service-manifest.js +1 -0
- package/cli/dist/utils/status-ports.js +3 -1
- package/cli/dist-bundle/{chunk-MZBDLTO2.js → chunk-KCHXMU3C.js} +3 -3
- package/cli/dist-bundle/cli.js +400 -263
- package/cli/dist-bundle/{cold-preflight-PZKLJJGV.js → cold-preflight-6C6O6NDI.js} +1 -1
- package/cli/package.json +1 -1
- package/engine/schemas/service-schema.json +25 -1
- package/engine/topologies/platform/docker/compose/compose.star +31 -3
- package/engine/topologies/platform/docker/layers/l4_runtime_layers.star +8 -0
- package/engine/topologies/tilt/manifest/loader.star +9 -0
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import{c as Ke,e as rr}from"./chunk-42IVF3YT.js";import{a as wt}from"./chunk-6EA
|
|
|
3
3
|
`:`
|
|
4
4
|
`)+n,s=r+1,r=e.indexOf(`
|
|
5
5
|
`,s)}while(r!==-1);return o+=e.slice(s),o}var ir=(e=0)=>t=>`\x1B[${t+e}m`,Et=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,vt=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,ci=e=>`\x1B[58;5;${e<90?e-30:e-90+8}m`,E={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:["4:2",24],underlineCurly:["4:3",24],underlineDotted:["4:4",24],underlineDashed:["4:5",24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},underlineColor:{underlineBlack:["58;5;0",59],underlineRed:["58;5;1",59],underlineGreen:["58;5;2",59],underlineYellow:["58;5;3",59],underlineBlue:["58;5;4",59],underlineMagenta:["58;5;5",59],underlineCyan:["58;5;6",59],underlineWhite:["58;5;7",59],underlineBlackBright:["58;5;8",59],underlineGray:["58;5;8",59],underlineGrey:["58;5;8",59],underlineRedBright:["58;5;9",59],underlineGreenBright:["58;5;10",59],underlineYellowBright:["58;5;11",59],underlineBlueBright:["58;5;12",59],underlineMagentaBright:["58;5;13",59],underlineCyanBright:["58;5;14",59],underlineWhiteBright:["58;5;15",59]}},ar=Object.keys(E.modifier),Pt=Object.keys(E.color),$t=Object.keys(E.bgColor),ui=Object.keys(E.underlineColor),cr=[...Pt,...$t];function li(){let e=new Map;for(let[t,n]of Object.entries(E)){for(let[r,s]of Object.entries(n))E[r]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[r]=E[r],e.set(Number.parseInt(s[0],10),s[1]);Object.defineProperty(E,t,{value:n,enumerable:!1})}return Object.defineProperty(E,"codes",{value:e,enumerable:!1}),E.color.close="\x1B[39m",E.bgColor.close="\x1B[49m",E.underlineColor.close="\x1B[59m",E.color.ansi=ir(),E.color.ansi256=Et(),E.color.ansi16m=vt(),E.bgColor.ansi=ir(10),E.bgColor.ansi256=Et(10),E.bgColor.ansi16m=vt(10),E.underlineColor.ansi=ci,E.underlineColor.ansi256=Et(20),E.underlineColor.ansi16m=vt(20),Object.defineProperties(E,{rgbToAnsi256:{value(t,n,r){return t===n&&n===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},enumerable:!1},hexToRgb:{value(t){let n=/[\da-f]{6}|[\da-f]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[r]=n;r.length===3&&(r=[...r].map(o=>o+o).join(""));let s=Number.parseInt(r,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:t=>E.rgbToAnsi256(...E.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,r,s;if(t>=232)n=((t-232)*10+8)/255,r=n,s=n;else{t-=16;let a=t%36;n=Math.floor(t/36)/5,r=Math.floor(a/6)/5,s=a%6/5}let o=Math.max(n,r,s)*2;if(o===0)return 30;let i=30+(Math.round(s)<<2|Math.round(r)<<1|Math.round(n));return o===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(t,n,r)=>E.ansi256ToAnsi(E.rgbToAnsi256(t,n,r)),enumerable:!1},hexToAnsi:{value:t=>E.ansi256ToAnsi(E.hexToAnsi256(t)),enumerable:!1}}),E}var di=li(),W=di;import _t from"node:process";import pi from"node:os";import ur from"node:tty";function K(e,t=globalThis.Deno?globalThis.Deno.args:_t.argv){let n=e.startsWith("-")?"":e.length===1?"-":"--",r=t.indexOf(n+e),s=t.indexOf("--");return r!==-1&&(s===-1||r<s)}var{env:v}=_t,Ge;K("no-color")||K("no-colors")||K("color=false")||K("color=never")?Ge=0:(K("color")||K("colors")||K("color=true")||K("color=always"))&&(Ge=1);function dr(){return/^\d+$/.test(v.FORCE_COLOR)}function fi(){if("FORCE_COLOR"in v){if(v.FORCE_COLOR==="false")return 0;if(v.FORCE_COLOR==="true"||v.FORCE_COLOR.length===0)return 1;if(dr())return Math.min(Number.parseInt(v.FORCE_COLOR,10),3)}}function mi(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function hi(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=fi();r!==void 0&&(Ge=r);let s=n?Ge:r;if(s===0)return 0;if(n){if(K("color=16m")||K("color=full")||K("color=truecolor"))return 3;if(K("color=256"))return 2}if(s!==void 0&&dr())return s;if("TF_BUILD"in v&&"AGENT_NAME"in v)return 1;if(e&&!t&&s===void 0)return 0;let o=s||0;if(v.TERM==="dumb")return o;if(_t.platform==="win32"){let i=pi.release().split(".");return Number(i[0])>=10&&Number(i[2])>=10586?Number(i[2])>=14931?3:2:1}if("CI"in v)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(i=>i in v)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(i=>i in v)||v.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in v)return/^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(v.TEAMCITY_VERSION)?1:0;if(v.COLORTERM==="truecolor"||v.TERM==="xterm-kitty"||v.TERM==="xterm-ghostty"||v.TERM==="wezterm")return 3;if("TERM_PROGRAM"in v){let i=Number.parseInt((v.TERM_PROGRAM_VERSION||"").split(".",1)[0],10);switch(v.TERM_PROGRAM){case"iTerm.app":return i>=3?3:2;case"Apple_Terminal":return 2}}return/-256(?:color)?$/i.test(v.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(v.TERM)||"COLORTERM"in v?1:o}function lr(e,t={}){let n=hi(e,{streamIsTTY:e&&e.isTTY,...t});return mi(n)}var gi={stdout:lr({isTTY:ur.isatty(1)}),stderr:lr({isTTY:ur.isatty(2)})},pr=gi;var{stdout:fr,stderr:mr}=pr,xe=Symbol("GENERATOR"),we=Symbol("STYLER"),We=Symbol("IS_EMPTY"),Ve=Symbol("LEVEL"),Ee=Object.create(null),hr=e=>{if(!Number.isSafeInteger(e)||e<0||e>3)throw new Error("The `level` should be an integer from 0 to 3")},ki={enumerable:!0,get(){return this[Ve]},set(e){hr(e),this[Ve]=e}},yi=(e,t={})=>{t.level!==void 0&&hr(t.level);let n=fr?fr.level:0;e[Ve]=t.level===void 0?n:t.level};var Si=e=>{let t=(...n)=>n.join(" ");return yi(t,e),Object.setPrototypeOf(t,ve.prototype),t};function ve(e){return Si(e)}Object.setPrototypeOf(ve.prototype,Function.prototype);for(let[e,t]of Object.entries(W))Ee[e]={get(){let n=At(this,gr(t.open,t.close,this[we]),this[We]);return Object.defineProperty(this,e,{value:n}),n}};Ee.visible={get(){let e=At(this,this[we],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var bi=(e,t)=>{let n=W[t];if(e==="rgb"){let s=(i,a,c)=>n.ansi(W.rgbToAnsi(i,a,c));return[s,s,(i,a,c)=>n.ansi256(W.rgbToAnsi256(i,a,c)),n.ansi16m]}if(e==="hex"){let s=i=>n.ansi(W.hexToAnsi(i));return[s,s,i=>n.ansi256(W.hexToAnsi256(i)),i=>n.ansi16m(...W.hexToRgb(i))]}let r=s=>n.ansi(W.ansi256ToAnsi(s));return[r,r,n.ansi256,n.ansi256]},Ti=["rgb","hex","ansi256"];for(let e of Ti){let t=e[0].toUpperCase()+e.slice(1);for(let[n,r]of[[e,"color"],["bg"+t,"bgColor"],["underline"+t,"underlineColor"]]){let{close:s}=W[r],o=bi(e,r);Ee[n]={get(){let i=function(a,c,u){let d=o[this.level](a,c,u);return At(this,gr(d,s,this[we]),this[We])};return Object.defineProperty(this,n,{value:i}),i}}}}var xi=Object.defineProperties(()=>{},{...Ee,level:{enumerable:!0,get(){return this[xe].level},set(e){this[xe].level=e}}}),gr=(e,t,n)=>{let r,s;return n===void 0?(r=e,s=t):(r=n.openAll+e,s=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:s,parent:n}},At=(e,t,n)=>{let r=(...s)=>s.length===1?Rt(r,""+s[0]):s.length===2?Rt(r,`${s[0]??""} ${s[1]??""}`):Rt(r,s.join(" "));return Object.setPrototypeOf(r,xi),r[xe]=e[xe]??e,r[we]=t,r[We]=n,r},Rt=(e,t)=>{if(e[xe][Ve]<=0||!t)return e[We]?"":t;let n=e[we];if(n===void 0)return t;let{openAll:r,closeAll:s}=n;if(t.includes("\x1B"))for(;n!==void 0;)t=sr(t,n.close,n.open),n=n.parent;let o=t.indexOf(`
|
|
6
|
-
`);return o!==-1&&(t=or(t,s,r,o)),r+t+s};Object.defineProperties(ve.prototype,{...Ee,level:ki});var wi=ve(),ep=ve({level:mr?mr.level:0});var m=wi;import{Command as sd}from"commander";import*as S from"node:fs";import*as k from"node:path";import{fileURLToPath as lc}from"node:url";import ie from"handlebars";var B="Container Runtime",J="bring-your-own";var C="database-management",q=".tiltignore",kr="service.json",se="docker-compose.yml",N=".autogenerated",Je="TILT_TECH_STACK.star",qe="TILT_RESOURCE_DEFAULTS.star",_="project.json",A="package.json",Dt=[Je,qe,"spec.master"],rp=["backend","frontend","library","sdk","worker","migrator","mcp",J],Ot={backend:["dev","build","start"],worker:["dev","build","start"],migrator:["dev","build","start"],mcp:["dev","build","start"],frontend:["dev","build"],library:["dev","build"],sdk:["dev","build"],[J]:[]};var Nt=["monitoring","elk","debezium","golden_image","verdaccio"],P={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"},[J]:{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"}},Pe={tiltUi:10350,traefik:8080},Ct="https://tdk-landscape.github.io/tdk-website/docs/quickstart/";var yr=["node_modules",".git",".tilt",".tilt-engine","dist","build",".prisma",".turbo","coverage","tmp","temp","__tests__","test","tests",".github",".vscode","docs"],Sr=["Dockerfile",se,"docker-compose.yaml","Tiltfile","vite.config.ts","tsconfig.json","tsconfig.build.json"],Ei={infra:"\u{1F3D7}\uFE0F",core:"\u{1F527}",api:"\u26A1",app:"\u{1F3A8}",orchestrator:"\u2699\uFE0F"};function sp(e){let t=e.toLowerCase();for(let[n,r]of Object.entries(Ei))if(t.includes(n))return r;return"\u{1F4E6}"}var vi="1.0.0",Pi={runtime:"bun",bundler:"vite",language:"typescript",framework:"hono",database:"postgresql",orm:"prisma",messaging:"nats",linting:"biome",testing:"vitest"},$i={frontend:{base:P.frontend.base,range:P.frontend.range,start:P.frontend.min,end:P.frontend.max},backend:{base:P.backend.base,range:P.backend.range,start:P.backend.min,end:P.backend.max},health:{base:P.health.base,range:P.health.range,start:P.health.min,end:P.health.max},worker:{base:P.worker.base,range:P.worker.range,start:P.worker.min,end:P.worker.max},migrator:{base:P.migrator.base,range:P.migrator.range,start:P.migrator.min,end:P.migrator.max},tiltUi:Pe.tiltUi,traefik:Pe.traefik},_i={path:"/health",live:"/health/live",ready:"/health/ready",timeout:30,interval:5},Ri={frontend:"-frontend",backend:"-backend",worker:"-worker",migrator:"-migrator",library:"-lib",sdk:"-sdk",validSeparators:["-","_"],maxLength:63,minLength:3},Ai={entrypoint:"web",network:"traefik-public",defaultHost:"localhost",appHost:"app.localhost",apiHost:"api.localhost",appSubdomainPrefix:"app",apiSubdomainPrefix:"api",defaultPort:8080,tlsEnabled:!1,entrypoints:["web"],middlewares:[],tls:{enabled:!1},healthcheckPath:"/health",healthcheckInterval:"10s",healthcheckTimeout:"5s",frontendPriorityBase:100},Di=["node_modules","dist","build",".git",".prisma",".turbo","coverage","tmp","temp","__tests__","test","tests"],Oi={frontend:{suffix:"-frontend",portRange:"3000-3999"},backend:{suffix:"-backend",portRange:"4000-4999"},library:{suffix:"-library",portRange:null},sdk:{suffix:"-sdk",portRange:"3000-9999"},migrator:{suffix:"-migrator",portRange:"7000-7999"},worker:{suffix:"-worker",portRange:"6000-6999"}},Ni={prisma:"Database ORM with migrations",nats:"Event streaming via NATS",redis:"Caching layer",infisical:"Secrets management",vitest:"Testing framework",traefik:"HTTP routing",websocket:"Real-time connections",graphql:"GraphQL support",grpc:"gRPC support",viteNode:"Vite Node runtime",maintenance:"Maintenance mode"},Ci={services:"services/product",sharedPlatform:"shared-platform-engineering",sharedProduct:"shared-product-engineering",sharedDdd:"shared-ddd-layers"},ji={scanIntervalSeconds:5,maxManifestsPerRoot:50,servicePatterns:["services/product/*","services/platform/*"]},Ii={dockerfile:"Dockerfile",context:"."},Fi={backend:{command:"bun",args:["run","dev"],env:{NODE_ENV:"development"}},frontend:{command:"bun",args:["run","dev"],env:{NODE_ENV:"development"}}},L={version:vi,tech:Pi,ports:$i,health:_i,naming:Ri,traefik:Ai,filewatchIgnores:Di,serviceTypes:Oi,features:Ni,paths:Ci,discovery:ji,docker:Ii,runtime:Fi};import{randomBytes as Li}from"node:crypto";import{closeSync as Mi,fchmodSync as Ui,fsyncSync as Bi,openSync as Hi,renameSync as Ki,rmSync as Gi,statSync as Vi,writeFileSync as Wi}from"node:fs";import{basename as Ji,dirname as qi,join as zi}from"node:path";function $e(e,t){let n=zi(qi(e),`.${Ji(e)}.${process.pid}.${Li(4).toString("hex")}.tmp`),r;try{r=Vi(e).mode&511}catch{r=void 0}try{let s=Hi(n,"wx");try{r!==void 0&&Ui(s,r),Wi(s,t,"utf-8"),Bi(s)}finally{Mi(s)}Ki(n,e)}catch(s){throw Gi(n,{force:!0}),s}}import{appendFileSync as Yi,existsSync as br,mkdirSync as Xi,readFileSync as Qi,writeFileSync as Tr}from"node:fs";import{resolve as jt}from"node:path";function hp(e,t,n){for(let[r,s]of t.entries())console.log(m.blue(`${s.emoji} ${s.description}...`)),s.type==="json"?ea(e,s.filename,s.content):ta(e,s.filename,String(s.content)),n&&n(s,r,t.length)}function Zi(e,t,n=2){let r=`${JSON.stringify(t,null,n)}
|
|
6
|
+
`);return o!==-1&&(t=or(t,s,r,o)),r+t+s};Object.defineProperties(ve.prototype,{...Ee,level:ki});var wi=ve(),ep=ve({level:mr?mr.level:0});var m=wi;import{Command as sd}from"commander";import*as S from"node:fs";import*as k from"node:path";import{fileURLToPath as lc}from"node:url";import ie from"handlebars";var B="Container Runtime",J="bring-your-own";var C="database-management",q=".tiltignore",kr="service.json",se="docker-compose.yml",N=".autogenerated",Je="TILT_TECH_STACK.star",qe="TILT_RESOURCE_DEFAULTS.star",_="project.json",A="package.json",Dt=[Je,qe,"spec.master"],rp=["backend","frontend","library","sdk","worker","migrator","mcp","agent",J],Ot={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"],[J]:[]};var Nt=["monitoring","elk","debezium","golden_image","verdaccio"],P={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"},[J]:{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"}},Pe={tiltUi:10350,traefik:8080},Ct="https://tdk-landscape.github.io/tdk-website/docs/quickstart/";var yr=["node_modules",".git",".tilt",".tilt-engine","dist","build",".prisma",".turbo","coverage","tmp","temp","__tests__","test","tests",".github",".vscode","docs"],Sr=["Dockerfile",se,"docker-compose.yaml","Tiltfile","vite.config.ts","tsconfig.json","tsconfig.build.json"],Ei={infra:"\u{1F3D7}\uFE0F",core:"\u{1F527}",api:"\u26A1",app:"\u{1F3A8}",orchestrator:"\u2699\uFE0F"};function sp(e){let t=e.toLowerCase();for(let[n,r]of Object.entries(Ei))if(t.includes(n))return r;return"\u{1F4E6}"}var vi="1.0.0",Pi={runtime:"bun",bundler:"vite",language:"typescript",framework:"hono",database:"postgresql",orm:"prisma",messaging:"nats",linting:"biome",testing:"vitest"},$i={frontend:{base:P.frontend.base,range:P.frontend.range,start:P.frontend.min,end:P.frontend.max},backend:{base:P.backend.base,range:P.backend.range,start:P.backend.min,end:P.backend.max},health:{base:P.health.base,range:P.health.range,start:P.health.min,end:P.health.max},worker:{base:P.worker.base,range:P.worker.range,start:P.worker.min,end:P.worker.max},migrator:{base:P.migrator.base,range:P.migrator.range,start:P.migrator.min,end:P.migrator.max},tiltUi:Pe.tiltUi,traefik:Pe.traefik},_i={path:"/health",live:"/health/live",ready:"/health/ready",timeout:30,interval:5},Ri={frontend:"-frontend",backend:"-backend",worker:"-worker",migrator:"-migrator",library:"-lib",sdk:"-sdk",validSeparators:["-","_"],maxLength:63,minLength:3},Ai={entrypoint:"web",network:"traefik-public",defaultHost:"localhost",appHost:"app.localhost",apiHost:"api.localhost",appSubdomainPrefix:"app",apiSubdomainPrefix:"api",defaultPort:8080,tlsEnabled:!1,entrypoints:["web"],middlewares:[],tls:{enabled:!1},healthcheckPath:"/health",healthcheckInterval:"10s",healthcheckTimeout:"5s",frontendPriorityBase:100},Di=["node_modules","dist","build",".git",".prisma",".turbo","coverage","tmp","temp","__tests__","test","tests"],Oi={frontend:{suffix:"-frontend",portRange:"3000-3999"},backend:{suffix:"-backend",portRange:"4000-4999"},library:{suffix:"-library",portRange:null},sdk:{suffix:"-sdk",portRange:"3000-9999"},migrator:{suffix:"-migrator",portRange:"7000-7999"},worker:{suffix:"-worker",portRange:"6000-6999"}},Ni={prisma:"Database ORM with migrations",nats:"Event streaming via NATS",redis:"Caching layer",infisical:"Secrets management",vitest:"Testing framework",traefik:"HTTP routing",websocket:"Real-time connections",graphql:"GraphQL support",grpc:"gRPC support",viteNode:"Vite Node runtime",maintenance:"Maintenance mode"},Ci={services:"services/product",sharedPlatform:"shared-platform-engineering",sharedProduct:"shared-product-engineering",sharedDdd:"shared-ddd-layers"},ji={scanIntervalSeconds:5,maxManifestsPerRoot:50,servicePatterns:["services/product/*","services/platform/*"]},Ii={dockerfile:"Dockerfile",context:"."},Fi={backend:{command:"bun",args:["run","dev"],env:{NODE_ENV:"development"}},frontend:{command:"bun",args:["run","dev"],env:{NODE_ENV:"development"}}},L={version:vi,tech:Pi,ports:$i,health:_i,naming:Ri,traefik:Ai,filewatchIgnores:Di,serviceTypes:Oi,features:Ni,paths:Ci,discovery:ji,docker:Ii,runtime:Fi};import{randomBytes as Li}from"node:crypto";import{closeSync as Mi,fchmodSync as Ui,fsyncSync as Bi,openSync as Hi,renameSync as Ki,rmSync as Gi,statSync as Vi,writeFileSync as Wi}from"node:fs";import{basename as Ji,dirname as qi,join as zi}from"node:path";function $e(e,t){let n=zi(qi(e),`.${Ji(e)}.${process.pid}.${Li(4).toString("hex")}.tmp`),r;try{r=Vi(e).mode&511}catch{r=void 0}try{let s=Hi(n,"wx");try{r!==void 0&&Ui(s,r),Wi(s,t,"utf-8"),Bi(s)}finally{Mi(s)}Ki(n,e)}catch(s){throw Gi(n,{force:!0}),s}}import{appendFileSync as Yi,existsSync as br,mkdirSync as Xi,readFileSync as Qi,writeFileSync as Tr}from"node:fs";import{resolve as jt}from"node:path";function hp(e,t,n){for(let[r,s]of t.entries())console.log(m.blue(`${s.emoji} ${s.description}...`)),s.type==="json"?ea(e,s.filename,s.content):ta(e,s.filename,String(s.content)),n&&n(s,r,t.length)}function Zi(e,t,n=2){let r=`${JSON.stringify(t,null,n)}
|
|
7
7
|
`;Tr(e,r,"utf-8")}function ea(e,t,n,r=2){let s=jt(e,t);Zi(s,n,r)}function It(e,t){Tr(e,t,"utf-8")}function ta(e,t,n){let r=jt(e,t);It(r,n)}function gp(e){br(e)||Xi(e,{recursive:!0})}var na=[".env",".tdk/.tdk-out/",".tdk/.project-id",".tdk/smoke/","node_modules/"];function kp(e){let t=jt(e,".gitignore"),n=br(t)?Qi(t,"utf-8"):"",r=new Set(n.split(`
|
|
8
8
|
`).map(a=>a.trim().replace(/\/$/,""))),s=na.filter(a=>!r.has(a.replace(/\/$/,"")));if(s.length===0)return[];let o=n&&!n.endsWith(`
|
|
9
9
|
`)?`
|
|
@@ -12,8 +12,8 @@ import{c as Ke,e as rr}from"./chunk-42IVF3YT.js";import{a as wt}from"./chunk-6EA
|
|
|
12
12
|
`:`# TDK (generated files and secrets)
|
|
13
13
|
`}${s.join(`
|
|
14
14
|
`)}
|
|
15
|
-
`),s}import{existsSync as ra,lstatSync as sa}from"node:fs";import{isAbsolute as xr,normalize as ze,relative as oa,sep as wr}from"node:path";var xp=[`${N}/**`,".tdk/.tdk-out/**","Tiltfile","TILT_*.star",q,`${A} (create only)`,"shared-platform-engineering/docker-templates/**","services/platform/database-management/docker-compose.yml","product_autogenerated_resource_manifests/**","product_autogenerated_services_list/**"];function ia(e){let t=ze(e).split(wr).join("/");return xr(e)||t===".."||t.startsWith("../")?!1:t.split("/").includes(N)||t.startsWith(".tdk/.tdk-out/")||t==="shared-platform-engineering/docker-templates"||t.startsWith("shared-platform-engineering/docker-templates/")||t.startsWith("product_autogenerated_resource_manifests/")||t.startsWith("product_autogenerated_services_list/")?!0:t==="Tiltfile"||/^TILT_[^/]+\.star$/.test(t)||t===q||t===A||t==="services/platform/database-management/docker-compose.yml"}function oe(e,t){let n=xr(t)?ze(t):ze(`${e}/${t}`),r=oa(e,n).split(wr).join("/");if(!ia(r))throw new Error(`Refusing to write outside TDK's generated-file allowlist: ${r}`);let s=e;for(let o of r.split("/"))if(s=ze(`${s}/${o}`),ra(s)&&sa(s).isSymbolicLink())throw new Error(`Refusing to write through a symbolic link in generated path: ${r}`);return n}var _e=[C,"proxy"];import{existsSync as Kr,readFileSync as Gr}from"node:fs";import{copyFileSync as Rr,mkdirSync as ka,rmSync as Ar,writeFileSync as Dr}from"node:fs";import{join as de}from"node:path";function j(e){return e==="backend"||e==="mcp"}import{readFileSync as fa}from"node:fs";import{join as ma}from"node:path";import{existsSync as ca}from"node:fs";import{dirname as ua,join as la,resolve as vr}from"node:path";import{cwd as da}from"node:process";var Er={name:"tdk-cli-internal",private:!0,version:"1.3.
|
|
16
|
-
`),s&&(Rr(i,de(o,"last-success.json")),r===void 0?Ar(de(o,"last-success-body.txt"),{force:!0}):Rr(a,de(o,"last-success-body.txt"))),i}catch{return}}function va(e){let t=Buffer.from(e,"utf8");if(t.length<=jr)return{body:e,truncated:!1,bytes:t.length};let n=t.subarray(0,jr).toString("utf8").replace(/\uFFFD$/,"");return{body:n,truncated:!0,bytes:Buffer.byteLength(n,"utf8")}}async function Pa(e,t={}){let n=t.fetch??((d,l)=>fetch(d,l)),r=t.now??Date.now,s=t.sleep??(d=>new Promise(l=>setTimeout(l,d))),o=(e.smoke.timeoutSeconds??Fr)*1e3,i=r()+o,a={},c=Bt(e.smoke);if(c.length>0)return{name:e.name,ok:!1,failure:`${e.name}: invalid smoke block: ${c.join("; ")}`};if(e.readyPath){let d=`${e.baseUrl}${e.readyPath}`;for(;;){try{let l=await n(d,{method:"GET",signal:AbortSignal.timeout(Nr)});if(await l.text(),!Ir.has(l.status)&&l.status<500)break}catch{}if(r()>=i)break;await s(Or)}}i=r()+o;let u=new Map;for(let[d,l]of e.smoke.steps.entries()){let p=l.name??`step ${d+1}`,h=(l.method??"GET").toUpperCase(),f=`${e.baseUrl}${Ur(l.path,a)}`,b=l.expect??200,w=l.body!==void 0,$,U="",g,R;for(;;){g=void 0,R=void 0,$=void 0;let G=!1;try{let F=await n(f,{method:h,headers:w?{"content-type":"application/json"}:void 0,body:w?JSON.stringify(Ut(l.body,a)):void 0,signal:AbortSignal.timeout(Nr)});$=F.status,U=await F.text()}catch(F){G=ba(F,h),g=F instanceof Error?F.message:String(F);let re=X(F)?F.code??(X(F.cause)?F.cause.code:void 0):void 0;R=typeof re=="string"?re:void 0}if(!(g!==void 0&&G||$!==void 0&&$!==b&&Ir.has($))||r()>=i)break;await s(Or)}let ne=`${e.name}: ${p}: ${h} ${f}`,ue;if(t.recordDir){let G=$===void 0?void 0:va(U),Te=g===void 0&&$===b&&(l.bodyContains===void 0||U.includes(l.bodyContains));ue=Ea(t.recordDir,wa(u,p),{service:e.name,step:p,method:h,url:f,expectedStatus:b,status:$??null,...g===void 0?{}:{error:R??g},truncated:G?.truncated??!1,bodyBytes:G?.bytes??0},G?.body,Te)}let be=G=>({name:e.name,ok:!1,failure:G,recordPath:ue});if(g!==void 0)return be(`${ne} never answered (${g})`);if($!==b)return be(`${ne} returned ${$}, expected ${b}${U?`: ${Qe(U)}`:""}`);if(l.bodyContains!==void 0&&!U.includes(l.bodyContains))return be(`${ne} returned ${$} but the body does not contain "${l.bodyContains}": ${Qe(U)}`);if(l.save){let G;try{G=JSON.parse(U)}catch{return be(`${ne} returned a body that is not JSON, cannot save: ${Qe(U)}`)}for(let[Te,F]of Object.entries(l.save)){let re=xa(G,F);if(re==null||typeof re=="object")return be(`${ne} response has no ${F} to save as {{${Te}}}: ${Qe(U)}`);a[Te]=String(re)}}}return{name:e.name,ok:!0}}function Vp(e){return`Smoke check failed: ${e.failure}${e.recordPath?` (record: ${e.recordPath})`:""}`}async function Hr(e,t={}){return Promise.all(e.map(n=>Pa(n,t)))}var Re=1,zp="https://tdk-landscape.github.io/schema.service.json",$a={dependencies:"deprecated, use dependsOn (still read for now)",envVars:"deprecated, use params (still read when params is absent)",jwtSecret:"ignored. A secret must not be committed: remove it and set JWT_SECRET in the project .env"},_a=new Set(["$schema","apiBasePath","apiPath","appName","appType","backendName","basePath","build","buildContext","databaseName","dependencies","dev","dependsOn","dockerfile","enabled","exposeViaProxy","featuresEnabled","framework","healthCheckPath","image","language","name","nats","params","playwright","port","replicas","restart","runtime","sablier","schemaVersion","secrets","smoke","stack","syncs","traefik","type"]),Ra=[{path:["healthCheckPath"],pattern:/^\/[a-z0-9/-]*$/,expected:"a path such as /health"},{path:["traefik","host"],pattern:/^[A-Za-z0-9.-]+$/,expected:"a hostname such as shop.backend.myproject.local"},{path:["traefik","pathPrefix"],pattern:/^\/[a-z0-9/-]*$/,expected:"a path such as /api/v1/shop-management"},{path:["traefik","healthCheck"],pattern:/^\/[a-z0-9/-]*$/,expected:"a path such as /health"},{path:["nats","queueGroup"],pattern:/^[A-Za-z0-9_.-]+$/,expected:"letters, digits, '_', '.' or '-'"},{path:["databaseName"],pattern:/^[A-Za-z0-9_-]+$/,expected:"letters, digits, '_' or '-'"},{path:["stack"],pattern:/^[A-Za-z0-9_-]+$/,expected:"letters, digits, '_' or '-'"},{path:["image"],pattern:/^[A-Za-z0-9._/:@-]+$/,expected:"an image reference such as ghcr.io/acme/app:1.0"}];function Ze(e,t){let n=[],r=new Set;for(let{path:s,pattern:o,expected:i}of Ra){let a=e;for(let u of s)a=a&&typeof a=="object"&&!Array.isArray(a)?a[u]:void 0;if(a==null||a==="")continue;let c=`${t}.${s.join(".")}`;(typeof a!="string"||!o.test(a))&&r.add(c),typeof a!="string"?n.push(`${c}: expected a string`):o.test(a)||n.push(`${c}: must be ${i} (no spaces, line breaks or YAML syntax)`)}for(let[s,o]of Aa(e,t))r.has(s)||n.push(`${s}: ${o}`);return n}function Ht(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127||n===133||n===8232||n===8233)return!0}return!1}function Aa(e,t){let n=[],r=Object.entries(e).filter(([s])=>s!=="smoke").map(([s,o])=>[o,`${t}.${s}`]);for(let s of Object.keys(e))Ht(s)&&n.push([t,"a key contains a line break"]);for(;r.length>0;){let[s,o]=r.pop();if(typeof s=="string")Ht(s)&&n.push([o,"must not contain line breaks or control characters"]);else if(Array.isArray(s))for(let[i,a]of s.entries())r.push([a,`${o}[${i}]`]);else if(s&&typeof s=="object")for(let[i,a]of Object.entries(s))Ht(i)?n.push([o,"a key contains a line break"]):r.push([a,`${o}.${i}`])}return n.sort(([s],[o])=>s.localeCompare(o))}var Da=["apiPath","basePath"];function Kt(e){if(!e||typeof e!="object"||Array.isArray(e))return[];let t=e;return Da.filter(n=>n in t&&typeof t[n]!="string")}function Gt(e,t){if(!e||typeof e!="object"||Array.isArray(e))return{errors:[`${t}: expected a JSON object`],warnings:[]};let n=e,r=[];for(let a of["appName","appType","stack","schemaVersion"])a in n||r.push(`${t}.${a}: required field is missing`);for(let a of["appName","appType","stack"])a in n&&typeof n[a]!="string"&&r.push(`${t}.${a}: expected a string`);"schemaVersion"in n&&n.schemaVersion!==Re&&r.push(`${t}.schemaVersion: unsupported version ${String(n.schemaVersion)} (supported: ${Re})`);for(let a of Kt(n))r.push(`${t}.${a}: expected a string`);let s=n.dev,o=s&&typeof s=="object"&&!Array.isArray(s)?s.liveReload:void 0;if(o!==void 0&&typeof o!="boolean"&&r.push(`${t}.dev.liveReload: expected true or false`),r.push(...Ze(n,t)),"smoke"in n)for(let a of Bt(n.smoke))r.push(`${t}.${a}`);let i=Object.keys(n).flatMap(a=>{let c=$a[a];return c?[`${t}.${a}: ${c}`]:_a.has(a)?[]:[`${t}.${a}: unknown field is preserved`]});return o===!0&&n.language!=="go"&&i.push(`${t}.dev.liveReload: only applies to Go services (language "go"); it is ignored here`),{errors:r,warnings:i,manifest:n}}function Vr(e,t){if(!Kr(e))return[];try{let n=JSON.parse(Gr(e,"utf-8"));return!n||typeof n!="object"||Array.isArray(n)?[]:Ze(n,t)}catch{return[]}}function Wr(e,t){if(!Kr(e))return{errors:[`${t}: file is missing`],warnings:[]};try{let n=JSON.parse(Gr(e,"utf-8"));return Gt(n,t)}catch(n){let r=n instanceof Error?n.message:String(n);return{errors:[`${t}: invalid JSON (${r})`],warnings:[]}}}import{existsSync as pe,readdirSync as us,readFileSync as ls,statSync as Xt}from"node:fs";import{dirname as ec,join as Z}from"node:path";var Ae=class{data;options;constructor(t){this.data=new Map,this.options=t}has(t){let n=this.data.get(t);return n?Date.now()-n.timestamp>this.options.ttlMs?(this.data.delete(t),!1):!0:!1}get(t){if(this.has(t))return this.data.get(t)?.value}set(t,n){this.data.set(t,{value:n,timestamp:Date.now()})}delete(t){this.data.delete(t)}clear(){this.data.clear()}keys(){let t=[];for(let n of this.data.keys())this.has(n)&&t.push(n);return t}size(){return this.keys().length}};function Jr(e){let t=0;return{isValid(){return Date.now()-t<e},markUpdated(){t=Date.now()},reset(){t=0}}}import{execFileSync as Ia,execSync as Fa}from"node:child_process";import{existsSync as qr}from"node:fs";import{delimiter as zr,extname as Yr,join as Xr}from"node:path";import{delimiter as Zp,extname as Oa}from"node:path";function De(){return process.platform==="win32"}function Na(e){return e==="linux"?"linux":e==="darwin"?"darwin":e==="win32"?"windows":null}function Ca(e){return e==="x64"?"amd64":e==="arm64"?"arm64":null}function ja(e,t){let n=Na(e),r=Ca(t);if(!n||!r||n==="windows"&&r!=="amd64")return null;let s=`tdk-${n}-${r}`;return n==="windows"?`${s}.exe`:s}function ef(){return ja(process.platform,process.arch)}function tf(){return De()?"tdk.exe":"tdk"}function Vt(e,t=De()){return t?Oa(e)?[e]:[e,`${e}.exe`,`${e}.cmd`,`${e}.bat`]:[e]}function O(e){let t=process.env.PATH??process.env.Path??"",n=De(),r=Vt(e,n);if(n&&!Yr(e))for(let s of(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";")){let o=s.toLowerCase();o&&!r.includes(`${e}${o}`)&&r.push(`${e}${o}`)}for(let s of t.split(zr))if(s)for(let o of r){let i=Xr(s,o);if(qr(i))return i}return null}function Qr(e){let t=process.env.PATH??process.env.Path??"",n=De(),r=Vt(e,n);if(n&&!Yr(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 s=[],o=new Set;for(let i of t.split(zr))if(i)for(let a of r){let c=Xr(i,a);if(!qr(c))continue;let u=n?c.toLowerCase():c;o.has(u)||(o.add(u),s.push(c))}return s}var Zr=1e4;function es(){let e=!1;if(process.platform==="win32")try{return Ia(O("docker")??"docker",["ps"],{stdio:"ignore",timeout:Zr,windowsHide:!0}),"running"}catch(t){return t.code==="ETIMEDOUT"?"unresponsive":"missing"}for(let t of["docker ps","colima status","podman ps"])try{return Fa(t,{stdio:"ignore",timeout:Zr}),"running"}catch(n){n.code==="ETIMEDOUT"&&(e=!0)}return e?"unresponsive":"missing"}function et(e,t){return e[t]??0}function La(e,t){let n=Array.from({length:t.length+1},(r,s)=>s);for(let r=1;r<=e.length;r++){let s=[r];for(let o=1;o<=t.length;o++){let i=e[r-1]===t[o-1]?0:1;s[o]=Math.min(et(s,o-1)+1,et(n,o)+1,et(n,o-1)+i)}n=s}return et(n,t.length)}function Ma(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 ts(e,t){if(e.length<2||t.length===0||t.includes(e))return;let n=e.toLowerCase(),r,s=Number.POSITIVE_INFINITY;for(let o of t){if(o.length===0)continue;let i=o.toLowerCase(),a=Ma(n,i)?1:La(n,i),c=Math.max(1,Math.min(2,Math.floor(Math.max(n.length,i.length)/3)));a>c||(a<s||a===s&&(r===void 0||o<r))&&(r=o,s=a)}return r}import{spawn as Ua}from"node:child_process";import{join as Ba}from"node:path";function Ha(e,t=[],n={}){return new Promise((r,s)=>{let o=[e,...t];n.verbose&&console.log(`Executing: tilt ${o.join(" ")}`);let i=Ua(O("tilt")??"tilt",o,{stdio:n.inheritStdio?"inherit":"pipe",shell:!1,windowsHide:process.platform==="win32",timeout:n.timeoutMs}),a="",c="";n.inheritStdio||(i.stdout?.on("data",u=>{a+=u.toString()}),i.stderr?.on("data",u=>{c+=u.toString()})),i.on("close",u=>{r({exitCode:u??1,stdout:a,stderr:c})}),i.on("error",u=>{s(new Error(`Failed to spawn tilt: ${u.message}`))})})}async function ns(){try{return(await Ha("version",[],{inheritStdio:!1,timeoutMs:1e4})).exitCode===0}catch{return!1}}function Ka(){let e=y();if(!e)throw Y.notInProject();return Ba(e,".tdk",".tdk-out","Tiltfile")}function rs(e){let t=Ka();e.push("-f",t)}function kf(e,t={}){let n=[];return rs(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 yf(e={}){let t=[];return rs(t),e.focusTargets&&e.focusTargets.length>0&&t.push("--",`--focus=${e.focusTargets.join(",")}`),t}function ss(e){return e instanceof Error?e.message:String(e)}function Pf(e,t){if(process.env.TDK_VERBOSE){let n=t!==void 0?`: ${ss(t)}`:"";console.warn(m.gray(`${e}${n}`))}}var I=class extends Error{suggestions;exitCode;constructor(t,n=[],r=1){super(t),this.name="TdkError",this.suggestions=n,this.exitCode=r}display(){Wa(this.message,void 0,this.suggestions)}exit(){this.display(),process.exit(this.exitCode)}};function Wt(e,t,n=!1){let r=new Set;for(let s of e){let o=ts(s,t);o&&r.add(n?`Did you mean "${o}" for "${s}"?`:`Did you mean "${o}"?`)}return[...r]}var Y={tiltNotInstalled:()=>new I("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: ${Ct}`]),dockerNotAvailable:()=>new I("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: ${Ct}`]),dockerNotResponding:()=>new I("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 I(`Stack "${e}" not found`,[...Wt([e],t),"Run `tdk stacks` to see available stacks","Run `tdk stack` to assign resources to a stack"]),resourceNotFound:(e,t=[])=>new I(`Resource "${e}" not found`,[...Wt([e],t),"Run `tdk resources` to list all resources","Check the resource name spelling"]),unknownServices:(e,t)=>{let n=Wt(e,t,e.length>1);return new I(`Unknown service ${e.join(", ")}. Valid names: ${t.join(", ")}`,n,2)},directoryExists:e=>new I(`Directory already exists: ${e}`,["Use `--path` to specify a different location","Remove the existing directory if no longer needed"]),invalidPath:e=>new I(`Invalid path: ${e}`,["Path must be within the project directory",'Path cannot contain special characters like <>:"|?*']),notInProject:()=>new I("Could not find project root (no .tdk/project.json found)",["Run this from within a TDK project","Run `tdk project --yes` to initialize a new project"])};function $f(){let e=y();return e||Y.notInProject().exit()}function Ga(e){e instanceof I&&e.exit(),console.error(m.red(`Error: ${ss(e)}`)),process.exit(1)}async function Va(e,t){try{return await e()}catch(n){return t?.verbose&&n instanceof Error&&n.stack&&console.error(m.gray(n.stack)),Ga(n)}}async function _f(e,t){let n=[],r=es();return r==="unresponsive"?n.push(Y.dockerNotResponding()):r==="missing"&&n.push(Y.dockerNotAvailable()),await ns()||n.push(Y.tiltNotInstalled()),n.length>0&&(console.error(m.red(`
|
|
15
|
+
`),s}import{existsSync as ra,lstatSync as sa}from"node:fs";import{isAbsolute as xr,normalize as ze,relative as oa,sep as wr}from"node:path";var xp=[`${N}/**`,".tdk/.tdk-out/**","Tiltfile","TILT_*.star",q,`${A} (create only)`,"shared-platform-engineering/docker-templates/**","services/platform/database-management/docker-compose.yml","product_autogenerated_resource_manifests/**","product_autogenerated_services_list/**"];function ia(e){let t=ze(e).split(wr).join("/");return xr(e)||t===".."||t.startsWith("../")?!1:t.split("/").includes(N)||t.startsWith(".tdk/.tdk-out/")||t==="shared-platform-engineering/docker-templates"||t.startsWith("shared-platform-engineering/docker-templates/")||t.startsWith("product_autogenerated_resource_manifests/")||t.startsWith("product_autogenerated_services_list/")?!0:t==="Tiltfile"||/^TILT_[^/]+\.star$/.test(t)||t===q||t===A||t==="services/platform/database-management/docker-compose.yml"}function oe(e,t){let n=xr(t)?ze(t):ze(`${e}/${t}`),r=oa(e,n).split(wr).join("/");if(!ia(r))throw new Error(`Refusing to write outside TDK's generated-file allowlist: ${r}`);let s=e;for(let o of r.split("/"))if(s=ze(`${s}/${o}`),ra(s)&&sa(s).isSymbolicLink())throw new Error(`Refusing to write through a symbolic link in generated path: ${r}`);return n}var _e=[C,"proxy"];import{existsSync as Kr,readFileSync as Gr}from"node:fs";import{copyFileSync as Rr,mkdirSync as ka,rmSync as Ar,writeFileSync as Dr}from"node:fs";import{join as de}from"node:path";function j(e){return e==="backend"||e==="mcp"||e==="agent"}import{readFileSync as fa}from"node:fs";import{join as ma}from"node:path";import{existsSync as ca}from"node:fs";import{dirname as ua,join as la,resolve as vr}from"node:path";import{cwd as da}from"node:process";var Er={name:"tdk-cli-internal",private:!0,version:"1.3.171",description:"TDK CLI \u2014 start services on your machine.",keywords:["tdk","tilt","cli","local-dev","microservices"],homepage:"https://github.com/tdk-landscape/tdk-cli-core#readme",bugs:{url:"https://github.com/tdk-landscape/tdk-cli-core/issues"},repository:{type:"git",url:"git+https://github.com/tdk-landscape/tdk-cli-core.git",directory:"cli"},license:"MIT",author:"TDK Team",type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",bin:{tdk:"bin/tdk.js","tdk-cli":"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",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",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",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.1",vitest:"^5.0.0"},engines:{node:">=22.12.0"}};function y(e=da()){let t=vr(e),n=vr("/");for(;t!==n;){if(ca(la(t,".tdk",_)))return t;let r=ua(t);if(r===t)break;t=r}return null}var Ye=null;function pa(){if(Ye)return Ye;let e=Er;if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid package.json: expected object");let t=e;return Ye={name:String(t.name??"@tdk-landscape/tdk-cli-core"),version:String(t.version??"0.0.0"),fullPackage:t},Ye}function Pr(){return pa().version}function le(){let e=y();if(e)try{let t=fa(ma(e,".tdk",_),"utf-8"),n=JSON.parse(t);if(n?.project?.name)return n.project.name}catch{}return"tdk-project"}function Ft(e){let t=le(),n=process.env.TDK_SERVICE_BASE_URL??`http://${t}.localhost${e?`:${e}`:""}`;try{let r=new URL(n.includes("://")?n:`http://${n}`),s=r.hostname,o=r.protocol==="https:"?"443":"80",i=r.port||(e?String(e):""),a=i===o?"":i;if(s==="localhost"||/^\d+\.\d+\.\d+\.\d+$/.test(s))return{appBase:`${r.protocol}//${s}${a?`:${a}`:""}`,apiBase:`${r.protocol}//${s}${a?`:${a}`:""}`};let c=s.replace(/^(app|api)\./,"");return{appBase:`${r.protocol}//app.${c}${a?`:${a}`:""}`,apiBase:`${r.protocol}//api.${c}${a?`:${a}`:""}`}}catch{return{appBase:`http://app.${t}.localhost`,apiBase:`http://api.${t}.localhost`}}}function ha(e){return`${e.replace(/\/+$/,"")}/health`}function Lt(e){if(j(e.config?.appType)){let t=e.name.replace(/-api$/,"");return e.config?.apiPath??`/api/${t}`}return e.config?.basePath??`/${e.name}`}function Mt(e,t){return _r(e,t,n=>ha(n))}function $r(e,t){return _r(e,t,n=>n)}function _r(e,t,n){let{appBase:r,apiBase:s}=Ft(t);return e.filter(o=>o.config?.appType==="frontend"||j(o.config?.appType)).map(o=>{let i=j(o.config.appType)?s:r;return{name:o.name,appType:o.config.appType,url:`${i}${n(Lt(o))}`}})}async function ga(e,t){try{let n=await fetch(e.url,{method:"GET",redirect:"manual",signal:AbortSignal.timeout(t)});return{...e,ok:n.ok,status:n.status}}catch(n){let r=n instanceof Error&&n.name==="TimeoutError"?`no response within ${t}ms`:n instanceof Error?n.message:String(n);return{...e,ok:!1,error:r}}}async function Xe(e,t){return Promise.all(e.map(n=>ga(n,t)))}var Fr=60,Or=1e3,Nr=1e4,Cr=200,jr=64*1024,Ir=new Set([404,502,503,504]),ya=new Set(["ECONNREFUSED","ENOTFOUND","EAI_AGAIN","EHOSTUNREACH","ENETUNREACH"]),Sa=new Set(["GET","HEAD","OPTIONS"]);function X(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ba(e,t){if(Sa.has(t))return!0;if(!X(e))return!1;let n=X(e.cause)?e.cause:void 0,r=e.code??n?.code;return typeof r=="string"&&ya.has(r)}function Bt(e){if(!X(e))return['smoke: must be an object with "via" and "steps"'];let t=[];return e.via!=="proxy"&&t.push('smoke.via: only "proxy" is supported (the check must go through the public URL)'),e.timeoutSeconds!==void 0&&!(typeof e.timeoutSeconds=="number"&&e.timeoutSeconds>0)&&t.push("smoke.timeoutSeconds: must be a number greater than 0"),!Array.isArray(e.steps)||e.steps.length===0?(t.push("smoke.steps: needs at least one step"),t):(e.steps.forEach((n,r)=>{let s=`smoke.steps[${r}]`;if(!X(n)){t.push(`${s}: must be an object`);return}let o=n.path;(typeof o!="string"||!o.startsWith("/")||o.startsWith("//"))&&t.push(`${s}.path: must start with "/" and is appended to the public URL; a full URL or relative path would skip the proxy`),n.expect!==void 0&&!(typeof n.expect=="number"&&Number.isInteger(n.expect)&&n.expect>=100&&n.expect<=599)&&t.push(`${s}.expect: must be an HTTP status between 100 and 599`),n.bodyContains!==void 0&&typeof n.bodyContains!="string"&&t.push(`${s}.bodyContains: must be a string`),n.save!==void 0&&(X(n.save)&&Object.values(n.save).every(a=>typeof a=="string"&&a.startsWith("$."))||t.push(`${s}.save: must map names to paths such as "$.id"`))}),t)}function Lr(e,t){let{appBase:n,apiBase:r}=Ft(t),s=[];for(let o of e){let i=o.config;if(!i?.smoke)continue;let a=i.appType,c=j(a)||a===J;if(!c&&a!=="frontend"||i.exposeViaProxy===!1)continue;let u=c?r:n,d=i.healthCheckPath||(c&&a!==J?"/health":void 0);s.push({name:o.name,baseUrl:`${u}${Lt(o).replace(/\/+$/,"")}`,...d?.startsWith("/")?{readyPath:d}:{},smoke:i.smoke})}return s}var Ta=10;function Mr(e,t={}){let n=t.timeoutSeconds??Ta;return e.flatMap(r=>{let s=r.smoke.steps.filter(i=>(i.method??"GET").toUpperCase()==="GET"&&i.body===void 0&&!i.path.includes("{{")).map(i=>({...i,bodyContains:void 0}));if(s.length===0)return[];let o=Math.min(r.smoke.timeoutSeconds??Fr,n);return[{name:r.name,baseUrl:r.baseUrl,smoke:{via:r.smoke.via,timeoutSeconds:o,steps:s}}]})}function xa(e,t){let n=t.replace(/^\$\.?/,"").match(/[^.[\]]+/g)??[],r=e;for(let s of n){if(r==null||s==="__proto__"||s==="constructor"||s==="prototype"||!Object.hasOwn(r,s))return;let o=Object.getOwnPropertyDescriptor(r,s);if(!o||!("value"in o))return;r=o.value}return r}function Ur(e,t){return e.replace(/\{\{(\w+)\}\}/g,(n,r)=>t[r]??n)}function Ut(e,t){return typeof e=="string"?Ur(e,t):Array.isArray(e)?e.map(n=>Ut(n,t)):X(e)?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,Ut(r,t)])):e}function Qe(e){let t=e.replace(/\s+/g," ").trim();return t.length>Cr?`${t.slice(0,Cr)}...`:t}function Br(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"step"}function wa(e,t){let n=Br(t),r=(e.get(n)??0)+1;return e.set(n,r),r===1?n:`${n}-${r}`}function Ea(e,t,n,r,s){try{let o=de(e,Br(n.service),t);ka(o,{recursive:!0});let i=de(o,"latest.json"),a=de(o,"body.txt");return r===void 0?Ar(a,{force:!0}):Dr(a,r),Dr(i,`${JSON.stringify({...n,bodyPath:r===void 0?null:"body.txt"},null,2)}
|
|
16
|
+
`),s&&(Rr(i,de(o,"last-success.json")),r===void 0?Ar(de(o,"last-success-body.txt"),{force:!0}):Rr(a,de(o,"last-success-body.txt"))),i}catch{return}}function va(e){let t=Buffer.from(e,"utf8");if(t.length<=jr)return{body:e,truncated:!1,bytes:t.length};let n=t.subarray(0,jr).toString("utf8").replace(/\uFFFD$/,"");return{body:n,truncated:!0,bytes:Buffer.byteLength(n,"utf8")}}async function Pa(e,t={}){let n=t.fetch??((d,l)=>fetch(d,l)),r=t.now??Date.now,s=t.sleep??(d=>new Promise(l=>setTimeout(l,d))),o=(e.smoke.timeoutSeconds??Fr)*1e3,i=r()+o,a={},c=Bt(e.smoke);if(c.length>0)return{name:e.name,ok:!1,failure:`${e.name}: invalid smoke block: ${c.join("; ")}`};if(e.readyPath){let d=`${e.baseUrl}${e.readyPath}`;for(;;){try{let l=await n(d,{method:"GET",signal:AbortSignal.timeout(Nr)});if(await l.text(),!Ir.has(l.status)&&l.status<500)break}catch{}if(r()>=i)break;await s(Or)}}i=r()+o;let u=new Map;for(let[d,l]of e.smoke.steps.entries()){let p=l.name??`step ${d+1}`,h=(l.method??"GET").toUpperCase(),f=`${e.baseUrl}${Ur(l.path,a)}`,b=l.expect??200,w=l.body!==void 0,$,U="",g,R;for(;;){g=void 0,R=void 0,$=void 0;let G=!1;try{let F=await n(f,{method:h,headers:w?{"content-type":"application/json"}:void 0,body:w?JSON.stringify(Ut(l.body,a)):void 0,signal:AbortSignal.timeout(Nr)});$=F.status,U=await F.text()}catch(F){G=ba(F,h),g=F instanceof Error?F.message:String(F);let re=X(F)?F.code??(X(F.cause)?F.cause.code:void 0):void 0;R=typeof re=="string"?re:void 0}if(!(g!==void 0&&G||$!==void 0&&$!==b&&Ir.has($))||r()>=i)break;await s(Or)}let ne=`${e.name}: ${p}: ${h} ${f}`,ue;if(t.recordDir){let G=$===void 0?void 0:va(U),Te=g===void 0&&$===b&&(l.bodyContains===void 0||U.includes(l.bodyContains));ue=Ea(t.recordDir,wa(u,p),{service:e.name,step:p,method:h,url:f,expectedStatus:b,status:$??null,...g===void 0?{}:{error:R??g},truncated:G?.truncated??!1,bodyBytes:G?.bytes??0},G?.body,Te)}let be=G=>({name:e.name,ok:!1,failure:G,recordPath:ue});if(g!==void 0)return be(`${ne} never answered (${g})`);if($!==b)return be(`${ne} returned ${$}, expected ${b}${U?`: ${Qe(U)}`:""}`);if(l.bodyContains!==void 0&&!U.includes(l.bodyContains))return be(`${ne} returned ${$} but the body does not contain "${l.bodyContains}": ${Qe(U)}`);if(l.save){let G;try{G=JSON.parse(U)}catch{return be(`${ne} returned a body that is not JSON, cannot save: ${Qe(U)}`)}for(let[Te,F]of Object.entries(l.save)){let re=xa(G,F);if(re==null||typeof re=="object")return be(`${ne} response has no ${F} to save as {{${Te}}}: ${Qe(U)}`);a[Te]=String(re)}}}return{name:e.name,ok:!0}}function Vp(e){return`Smoke check failed: ${e.failure}${e.recordPath?` (record: ${e.recordPath})`:""}`}async function Hr(e,t={}){return Promise.all(e.map(n=>Pa(n,t)))}var Re=1,zp="https://tdk-landscape.github.io/schema.service.json",$a={dependencies:"deprecated, use dependsOn (still read for now)",envVars:"deprecated, use params (still read when params is absent)",jwtSecret:"ignored. A secret must not be committed: remove it and set JWT_SECRET in the project .env"},_a=new Set(["$schema","agent","apiBasePath","apiPath","appName","appType","backendName","basePath","build","buildContext","databaseName","dependencies","dev","dependsOn","dockerfile","enabled","exposeViaProxy","featuresEnabled","framework","healthCheckPath","image","language","name","nats","params","playwright","port","replicas","restart","runtime","sablier","schemaVersion","secrets","smoke","stack","syncs","traefik","type"]),Ra=[{path:["healthCheckPath"],pattern:/^\/[a-z0-9/-]*$/,expected:"a path such as /health"},{path:["traefik","host"],pattern:/^[A-Za-z0-9.-]+$/,expected:"a hostname such as shop.backend.myproject.local"},{path:["traefik","pathPrefix"],pattern:/^\/[a-z0-9/-]*$/,expected:"a path such as /api/v1/shop-management"},{path:["traefik","healthCheck"],pattern:/^\/[a-z0-9/-]*$/,expected:"a path such as /health"},{path:["nats","queueGroup"],pattern:/^[A-Za-z0-9_.-]+$/,expected:"letters, digits, '_', '.' or '-'"},{path:["databaseName"],pattern:/^[A-Za-z0-9_-]+$/,expected:"letters, digits, '_' or '-'"},{path:["stack"],pattern:/^[A-Za-z0-9_-]+$/,expected:"letters, digits, '_' or '-'"},{path:["image"],pattern:/^[A-Za-z0-9._/:@-]+$/,expected:"an image reference such as ghcr.io/acme/app:1.0"}];function Ze(e,t){let n=[],r=new Set;for(let{path:s,pattern:o,expected:i}of Ra){let a=e;for(let u of s)a=a&&typeof a=="object"&&!Array.isArray(a)?a[u]:void 0;if(a==null||a==="")continue;let c=`${t}.${s.join(".")}`;(typeof a!="string"||!o.test(a))&&r.add(c),typeof a!="string"?n.push(`${c}: expected a string`):o.test(a)||n.push(`${c}: must be ${i} (no spaces, line breaks or YAML syntax)`)}for(let[s,o]of Aa(e,t))r.has(s)||n.push(`${s}: ${o}`);return n}function Ht(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127||n===133||n===8232||n===8233)return!0}return!1}function Aa(e,t){let n=[],r=Object.entries(e).filter(([s])=>s!=="smoke").map(([s,o])=>[o,`${t}.${s}`]);for(let s of Object.keys(e))Ht(s)&&n.push([t,"a key contains a line break"]);for(;r.length>0;){let[s,o]=r.pop();if(typeof s=="string")Ht(s)&&n.push([o,"must not contain line breaks or control characters"]);else if(Array.isArray(s))for(let[i,a]of s.entries())r.push([a,`${o}[${i}]`]);else if(s&&typeof s=="object")for(let[i,a]of Object.entries(s))Ht(i)?n.push([o,"a key contains a line break"]):r.push([a,`${o}.${i}`])}return n.sort(([s],[o])=>s.localeCompare(o))}var Da=["apiPath","basePath"];function Kt(e){if(!e||typeof e!="object"||Array.isArray(e))return[];let t=e;return Da.filter(n=>n in t&&typeof t[n]!="string")}function Gt(e,t){if(!e||typeof e!="object"||Array.isArray(e))return{errors:[`${t}: expected a JSON object`],warnings:[]};let n=e,r=[];for(let a of["appName","appType","stack","schemaVersion"])a in n||r.push(`${t}.${a}: required field is missing`);for(let a of["appName","appType","stack"])a in n&&typeof n[a]!="string"&&r.push(`${t}.${a}: expected a string`);"schemaVersion"in n&&n.schemaVersion!==Re&&r.push(`${t}.schemaVersion: unsupported version ${String(n.schemaVersion)} (supported: ${Re})`);for(let a of Kt(n))r.push(`${t}.${a}: expected a string`);let s=n.dev,o=s&&typeof s=="object"&&!Array.isArray(s)?s.liveReload:void 0;if(o!==void 0&&typeof o!="boolean"&&r.push(`${t}.dev.liveReload: expected true or false`),r.push(...Ze(n,t)),"smoke"in n)for(let a of Bt(n.smoke))r.push(`${t}.${a}`);let i=Object.keys(n).flatMap(a=>{let c=$a[a];return c?[`${t}.${a}: ${c}`]:_a.has(a)?[]:[`${t}.${a}: unknown field is preserved`]});return o===!0&&n.language!=="go"&&i.push(`${t}.dev.liveReload: only applies to Go services (language "go"); it is ignored here`),{errors:r,warnings:i,manifest:n}}function Vr(e,t){if(!Kr(e))return[];try{let n=JSON.parse(Gr(e,"utf-8"));return!n||typeof n!="object"||Array.isArray(n)?[]:Ze(n,t)}catch{return[]}}function Wr(e,t){if(!Kr(e))return{errors:[`${t}: file is missing`],warnings:[]};try{let n=JSON.parse(Gr(e,"utf-8"));return Gt(n,t)}catch(n){let r=n instanceof Error?n.message:String(n);return{errors:[`${t}: invalid JSON (${r})`],warnings:[]}}}import{existsSync as pe,readdirSync as us,readFileSync as ls,statSync as Xt}from"node:fs";import{dirname as ec,join as Z}from"node:path";var Ae=class{data;options;constructor(t){this.data=new Map,this.options=t}has(t){let n=this.data.get(t);return n?Date.now()-n.timestamp>this.options.ttlMs?(this.data.delete(t),!1):!0:!1}get(t){if(this.has(t))return this.data.get(t)?.value}set(t,n){this.data.set(t,{value:n,timestamp:Date.now()})}delete(t){this.data.delete(t)}clear(){this.data.clear()}keys(){let t=[];for(let n of this.data.keys())this.has(n)&&t.push(n);return t}size(){return this.keys().length}};function Jr(e){let t=0;return{isValid(){return Date.now()-t<e},markUpdated(){t=Date.now()},reset(){t=0}}}import{execFileSync as Ia,execSync as Fa}from"node:child_process";import{existsSync as qr}from"node:fs";import{delimiter as zr,extname as Yr,join as Xr}from"node:path";import{delimiter as Zp,extname as Oa}from"node:path";function De(){return process.platform==="win32"}function Na(e){return e==="linux"?"linux":e==="darwin"?"darwin":e==="win32"?"windows":null}function Ca(e){return e==="x64"?"amd64":e==="arm64"?"arm64":null}function ja(e,t){let n=Na(e),r=Ca(t);if(!n||!r||n==="windows"&&r!=="amd64")return null;let s=`tdk-${n}-${r}`;return n==="windows"?`${s}.exe`:s}function ef(){return ja(process.platform,process.arch)}function tf(){return De()?"tdk.exe":"tdk"}function Vt(e,t=De()){return t?Oa(e)?[e]:[e,`${e}.exe`,`${e}.cmd`,`${e}.bat`]:[e]}function O(e){let t=process.env.PATH??process.env.Path??"",n=De(),r=Vt(e,n);if(n&&!Yr(e))for(let s of(process.env.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";")){let o=s.toLowerCase();o&&!r.includes(`${e}${o}`)&&r.push(`${e}${o}`)}for(let s of t.split(zr))if(s)for(let o of r){let i=Xr(s,o);if(qr(i))return i}return null}function Qr(e){let t=process.env.PATH??process.env.Path??"",n=De(),r=Vt(e,n);if(n&&!Yr(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 s=[],o=new Set;for(let i of t.split(zr))if(i)for(let a of r){let c=Xr(i,a);if(!qr(c))continue;let u=n?c.toLowerCase():c;o.has(u)||(o.add(u),s.push(c))}return s}var Zr=1e4;function es(){let e=!1;if(process.platform==="win32")try{return Ia(O("docker")??"docker",["ps"],{stdio:"ignore",timeout:Zr,windowsHide:!0}),"running"}catch(t){return t.code==="ETIMEDOUT"?"unresponsive":"missing"}for(let t of["docker ps","colima status","podman ps"])try{return Fa(t,{stdio:"ignore",timeout:Zr}),"running"}catch(n){n.code==="ETIMEDOUT"&&(e=!0)}return e?"unresponsive":"missing"}function et(e,t){return e[t]??0}function La(e,t){let n=Array.from({length:t.length+1},(r,s)=>s);for(let r=1;r<=e.length;r++){let s=[r];for(let o=1;o<=t.length;o++){let i=e[r-1]===t[o-1]?0:1;s[o]=Math.min(et(s,o-1)+1,et(n,o)+1,et(n,o-1)+i)}n=s}return et(n,t.length)}function Ma(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 ts(e,t){if(e.length<2||t.length===0||t.includes(e))return;let n=e.toLowerCase(),r,s=Number.POSITIVE_INFINITY;for(let o of t){if(o.length===0)continue;let i=o.toLowerCase(),a=Ma(n,i)?1:La(n,i),c=Math.max(1,Math.min(2,Math.floor(Math.max(n.length,i.length)/3)));a>c||(a<s||a===s&&(r===void 0||o<r))&&(r=o,s=a)}return r}import{spawn as Ua}from"node:child_process";import{join as Ba}from"node:path";function Ha(e,t=[],n={}){return new Promise((r,s)=>{let o=[e,...t];n.verbose&&console.log(`Executing: tilt ${o.join(" ")}`);let i=Ua(O("tilt")??"tilt",o,{stdio:n.inheritStdio?"inherit":"pipe",shell:!1,windowsHide:process.platform==="win32",timeout:n.timeoutMs}),a="",c="";n.inheritStdio||(i.stdout?.on("data",u=>{a+=u.toString()}),i.stderr?.on("data",u=>{c+=u.toString()})),i.on("close",u=>{r({exitCode:u??1,stdout:a,stderr:c})}),i.on("error",u=>{s(new Error(`Failed to spawn tilt: ${u.message}`))})})}async function ns(){try{return(await Ha("version",[],{inheritStdio:!1,timeoutMs:1e4})).exitCode===0}catch{return!1}}function Ka(){let e=y();if(!e)throw Y.notInProject();return Ba(e,".tdk",".tdk-out","Tiltfile")}function rs(e){let t=Ka();e.push("-f",t)}function kf(e,t={}){let n=[];return rs(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 yf(e={}){let t=[];return rs(t),e.focusTargets&&e.focusTargets.length>0&&t.push("--",`--focus=${e.focusTargets.join(",")}`),t}function ss(e){return e instanceof Error?e.message:String(e)}function Pf(e,t){if(process.env.TDK_VERBOSE){let n=t!==void 0?`: ${ss(t)}`:"";console.warn(m.gray(`${e}${n}`))}}var I=class extends Error{suggestions;exitCode;constructor(t,n=[],r=1){super(t),this.name="TdkError",this.suggestions=n,this.exitCode=r}display(){Wa(this.message,void 0,this.suggestions)}exit(){this.display(),process.exit(this.exitCode)}};function Wt(e,t,n=!1){let r=new Set;for(let s of e){let o=ts(s,t);o&&r.add(n?`Did you mean "${o}" for "${s}"?`:`Did you mean "${o}"?`)}return[...r]}var Y={tiltNotInstalled:()=>new I("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: ${Ct}`]),dockerNotAvailable:()=>new I("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: ${Ct}`]),dockerNotResponding:()=>new I("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 I(`Stack "${e}" not found`,[...Wt([e],t),"Run `tdk stacks` to see available stacks","Run `tdk stack` to assign resources to a stack"]),resourceNotFound:(e,t=[])=>new I(`Resource "${e}" not found`,[...Wt([e],t),"Run `tdk resources` to list all resources","Check the resource name spelling"]),unknownServices:(e,t)=>{let n=Wt(e,t,e.length>1);return new I(`Unknown service ${e.join(", ")}. Valid names: ${t.join(", ")}`,n,2)},directoryExists:e=>new I(`Directory already exists: ${e}`,["Use `--path` to specify a different location","Remove the existing directory if no longer needed"]),invalidPath:e=>new I(`Invalid path: ${e}`,["Path must be within the project directory",'Path cannot contain special characters like <>:"|?*']),notInProject:()=>new I("Could not find project root (no .tdk/project.json found)",["Run this from within a TDK project","Run `tdk project --yes` to initialize a new project"])};function $f(){let e=y();return e||Y.notInProject().exit()}function Ga(e){e instanceof I&&e.exit(),console.error(m.red(`Error: ${ss(e)}`)),process.exit(1)}async function Va(e,t){try{return await e()}catch(n){return t?.verbose&&n instanceof Error&&n.stack&&console.error(m.gray(n.stack)),Ga(n)}}async function _f(e,t){let n=[],r=es();return r==="unresponsive"?n.push(Y.dockerNotResponding()):r==="missing"&&n.push(Y.dockerNotAvailable()),await ns()||n.push(Y.tiltNotInstalled()),n.length>0&&(console.error(m.red(`
|
|
17
17
|
TDK can't start - missing prerequisites:
|
|
18
18
|
`)),n.forEach((s,o)=>{o>0&&console.error(""),s.display()}),console.error(m.gray("\nRun `tdk doctor` for a full environment check.")),process.exit(1)),Va(e,t)}function Rf(e,t=1){console.error(m.red(`Error: ${e}`)),process.exit(t)}function Wa(e,t,n){if(console.error(m.red(`\u274C ${e}`)),t&&console.error(m.gray(` ${t}`)),n&&n.length>0){console.error(m.yellow(`
|
|
19
19
|
\u{1F4A1} Suggestions:`));for(let r of n)console.error(m.cyan(` \u2192 ${r}`))}}function Af(e,t){console.error(m.red(`
|