@flisk-sh/flisk 0.0.0-stage → 1.3.189

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (440) hide show
  1. package/CHANGELOG.md +492 -0
  2. package/LICENSE +21 -0
  3. package/README.md +479 -2
  4. package/Tiltfile +151 -0
  5. package/cli/bin/flisk.js +42 -0
  6. package/cli/dist/agent-runtimes/custom.js +335 -0
  7. package/cli/dist/agent-runtimes/registry.js +34 -0
  8. package/cli/dist/backend-frameworks/elysia.js +38 -0
  9. package/cli/dist/backend-frameworks/express.js +49 -0
  10. package/cli/dist/backend-frameworks/fastify.js +43 -0
  11. package/cli/dist/backend-frameworks/h3.js +37 -0
  12. package/cli/dist/backend-frameworks/koa.js +47 -0
  13. package/cli/dist/backend-frameworks/mcp.js +86 -0
  14. package/cli/dist/backend-frameworks/nestjs.js +55 -0
  15. package/cli/dist/backend-frameworks/registry.js +134 -0
  16. package/cli/dist/backend-frameworks/types.js +1 -0
  17. package/cli/dist/backend-languages/bun.js +76 -0
  18. package/cli/dist/backend-languages/go.js +125 -0
  19. package/cli/dist/backend-languages/node.js +122 -0
  20. package/cli/dist/backend-languages/python.js +94 -0
  21. package/cli/dist/backend-languages/registry.js +37 -0
  22. package/cli/dist/backend-languages/rust.js +82 -0
  23. package/cli/dist/backend-languages/types.js +1 -0
  24. package/cli/dist/cli.js +29 -0
  25. package/cli/dist/commands/__tests__/project-e2e-helpers.js +49 -0
  26. package/cli/dist/commands/__tests__/ui-loading-screen.test.js +16 -0
  27. package/cli/dist/commands/agent.js +182 -0
  28. package/cli/dist/commands/completion-candidates.js +116 -0
  29. package/cli/dist/commands/completion.js +843 -0
  30. package/cli/dist/commands/config.js +362 -0
  31. package/cli/dist/commands/doctor.js +1504 -0
  32. package/cli/dist/commands/down.js +114 -0
  33. package/cli/dist/commands/eject.js +108 -0
  34. package/cli/dist/commands/help.js +152 -0
  35. package/cli/dist/commands/import.js +164 -0
  36. package/cli/dist/commands/logs.js +119 -0
  37. package/cli/dist/commands/maintainers.js +102 -0
  38. package/cli/dist/commands/mcp.js +28 -0
  39. package/cli/dist/commands/networks.js +306 -0
  40. package/cli/dist/commands/project.js +447 -0
  41. package/cli/dist/commands/projects.js +103 -0
  42. package/cli/dist/commands/registry.js +53 -0
  43. package/cli/dist/commands/resource.js +992 -0
  44. package/cli/dist/commands/resources.js +127 -0
  45. package/cli/dist/commands/restart.js +89 -0
  46. package/cli/dist/commands/runtime.js +75 -0
  47. package/cli/dist/commands/stack.js +171 -0
  48. package/cli/dist/commands/stacks.js +71 -0
  49. package/cli/dist/commands/status.js +211 -0
  50. package/cli/dist/commands/ui.js +725 -0
  51. package/cli/dist/commands/up.js +609 -0
  52. package/cli/dist/commands/upgrade.js +840 -0
  53. package/cli/dist/commands/version.js +10 -0
  54. package/cli/dist/components/Accessible.js +11 -0
  55. package/cli/dist/components/BaseTooltip.js +30 -0
  56. package/cli/dist/components/DetailPanel.js +33 -0
  57. package/cli/dist/components/FileTree.js +51 -0
  58. package/cli/dist/components/ResourceSelectInput.js +42 -0
  59. package/cli/dist/components/ResourceTable.js +35 -0
  60. package/cli/dist/components/ServiceIssues.js +13 -0
  61. package/cli/dist/components/TUIHeader.js +27 -0
  62. package/cli/dist/components/TabBar.js +27 -0
  63. package/cli/dist/components/Tooltip.js +13 -0
  64. package/cli/dist/components/index.js +11 -0
  65. package/cli/dist/components/ui-theme.js +120 -0
  66. package/cli/dist/config/platform-standards.js +182 -0
  67. package/cli/dist/frontend-frameworks/lit.js +64 -0
  68. package/cli/dist/frontend-frameworks/preact.js +62 -0
  69. package/cli/dist/frontend-frameworks/qwik.js +61 -0
  70. package/cli/dist/frontend-frameworks/react.js +69 -0
  71. package/cli/dist/frontend-frameworks/registry.js +83 -0
  72. package/cli/dist/frontend-frameworks/solid.js +62 -0
  73. package/cli/dist/frontend-frameworks/svelte.js +67 -0
  74. package/cli/dist/frontend-frameworks/tanstack-router.js +101 -0
  75. package/cli/dist/frontend-frameworks/types.js +1 -0
  76. package/cli/dist/frontend-frameworks/vanilla.js +59 -0
  77. package/cli/dist/frontend-frameworks/vue.js +72 -0
  78. package/cli/dist/generator/__tests__/golden-helpers.js +43 -0
  79. package/cli/dist/generator/extension-fetch.js +291 -0
  80. package/cli/dist/generator/resource-templates.js +133 -0
  81. package/cli/dist/generator/template-engine.js +801 -0
  82. package/cli/dist/index.js +10 -0
  83. package/cli/dist/mcp/server.js +101 -0
  84. package/cli/dist/mcp/tools.js +351 -0
  85. package/cli/dist/program.js +37 -0
  86. package/cli/dist/types/index.js +38 -0
  87. package/cli/dist/utils/agent-host.js +36 -0
  88. package/cli/dist/utils/atomic-write.js +36 -0
  89. package/cli/dist/utils/bun-floor.js +9 -0
  90. package/cli/dist/utils/bun-requirement.js +10 -0
  91. package/cli/dist/utils/cache.js +63 -0
  92. package/cli/dist/utils/cold-preflight.js +257 -0
  93. package/cli/dist/utils/command-helpers.js +57 -0
  94. package/cli/dist/utils/constants.js +160 -0
  95. package/cli/dist/utils/discovery-context.js +71 -0
  96. package/cli/dist/utils/discovery-paths.js +93 -0
  97. package/cli/dist/utils/docker.js +34 -0
  98. package/cli/dist/utils/doctor-crashloop.js +161 -0
  99. package/cli/dist/utils/doctor-fix.js +391 -0
  100. package/cli/dist/utils/doctor-host.js +66 -0
  101. package/cli/dist/utils/doctor-report.js +78 -0
  102. package/cli/dist/utils/doctor-runtime.js +880 -0
  103. package/cli/dist/utils/doctor-starlark.js +132 -0
  104. package/cli/dist/utils/doctor-wiring.js +698 -0
  105. package/cli/dist/utils/down-cleanup.js +125 -0
  106. package/cli/dist/utils/env-validator.js +266 -0
  107. package/cli/dist/utils/errors.js +175 -0
  108. package/cli/dist/utils/exec-async.js +31 -0
  109. package/cli/dist/utils/file-helpers.js +104 -0
  110. package/cli/dist/utils/formatting.js +165 -0
  111. package/cli/dist/utils/generated-paths.js +51 -0
  112. package/cli/dist/utils/help-command.js +11 -0
  113. package/cli/dist/utils/host-port-config.js +140 -0
  114. package/cli/dist/utils/host-port-plan.js +100 -0
  115. package/cli/dist/utils/json-output.js +29 -0
  116. package/cli/dist/utils/machine-output.js +33 -0
  117. package/cli/dist/utils/paths.js +43 -0
  118. package/cli/dist/utils/platform.js +58 -0
  119. package/cli/dist/utils/port-assignment.js +75 -0
  120. package/cli/dist/utils/port-conflict-fix.js +25 -0
  121. package/cli/dist/utils/port-fallback-notice.js +17 -0
  122. package/cli/dist/utils/port-listener-probe.js +20 -0
  123. package/cli/dist/utils/project-config-defaults.js +17 -0
  124. package/cli/dist/utils/project-features.js +91 -0
  125. package/cli/dist/utils/project-templates.js +32 -0
  126. package/cli/dist/utils/prompt.js +97 -0
  127. package/cli/dist/utils/resource-features.js +184 -0
  128. package/cli/dist/utils/resource-kind.js +9 -0
  129. package/cli/dist/utils/schema-version-gate.js +45 -0
  130. package/cli/dist/utils/search-status.js +12 -0
  131. package/cli/dist/utils/secret-redaction.js +73 -0
  132. package/cli/dist/utils/service-config-checks.js +189 -0
  133. package/cli/dist/utils/service-manifest.js +254 -0
  134. package/cli/dist/utils/service-runtime-state.js +66 -0
  135. package/cli/dist/utils/service-urls.js +112 -0
  136. package/cli/dist/utils/services.js +360 -0
  137. package/cli/dist/utils/shared-infra.js +45 -0
  138. package/cli/dist/utils/shared-platform-postgres.js +232 -0
  139. package/cli/dist/utils/single-flight.js +21 -0
  140. package/cli/dist/utils/smoke.js +401 -0
  141. package/cli/dist/utils/spinner.js +40 -0
  142. package/cli/dist/utils/stack-features.js +15 -0
  143. package/cli/dist/utils/stack-status.js +14 -0
  144. package/cli/dist/utils/startup-report.js +78 -0
  145. package/cli/dist/utils/status-message.js +21 -0
  146. package/cli/dist/utils/status-ports.js +33 -0
  147. package/cli/dist/utils/suggestions.js +63 -0
  148. package/cli/dist/utils/tar.js +46 -0
  149. package/cli/dist/utils/tdk-version.js +51 -0
  150. package/cli/dist/utils/terminal-layout.js +19 -0
  151. package/cli/dist/utils/tilt-events.js +194 -0
  152. package/cli/dist/utils/tilt-logs.js +61 -0
  153. package/cli/dist/utils/tilt-port-owner.js +63 -0
  154. package/cli/dist/utils/tilt-process.js +54 -0
  155. package/cli/dist/utils/tilt-resource-state.js +32 -0
  156. package/cli/dist/utils/tilt-startup.js +49 -0
  157. package/cli/dist/utils/tilt-unreachable-message.js +9 -0
  158. package/cli/dist/utils/tilt.js +104 -0
  159. package/cli/dist/utils/ui-keymap.js +129 -0
  160. package/cli/dist/utils/ui-service-state.js +34 -0
  161. package/cli/dist/utils/up-only.js +28 -0
  162. package/cli/dist/utils/up-readiness.js +118 -0
  163. package/cli/dist/utils/url-actions.js +103 -0
  164. package/cli/dist/utils/validation.js +62 -0
  165. package/cli/dist/utils/which.js +56 -0
  166. package/cli/dist/utils/windows-doctor.js +176 -0
  167. package/cli/dist-bundle/chunk-6EA4DGCY.js +2 -0
  168. package/cli/dist-bundle/chunk-BZ4H7MM4.js +3 -0
  169. package/cli/dist-bundle/chunk-QWYXYAX6.js +510 -0
  170. package/cli/dist-bundle/cli.js +2017 -0
  171. package/cli/dist-bundle/cold-preflight-MM46GFQA.js +2 -0
  172. package/cli/dist-bundle/devtools-ZUHXW33W.js +5 -0
  173. package/cli/dist-bundle/extension-fetch-J4FFH7TJ.js +2 -0
  174. package/cli/package.json +83 -0
  175. package/cli/shared-platform-engineering/docker-templates/bun-hoisted-symlink-fix.sh +25 -0
  176. package/cli/shared-platform-engineering/docker-templates/infisical-entrypoint.sh +466 -0
  177. package/cli/shared-platform-engineering/docker-templates/install-deps.sh +154 -0
  178. package/cli/shared-platform-engineering/docker-templates/prisma-bun-client-link-fix.sh +14 -0
  179. package/cli/shared-platform-engineering/docker-templates/prisma-normalize-client.sh +58 -0
  180. package/cli/templates/.tiltignore.hbs +72 -0
  181. package/cli/templates/TILT_RESOURCE_DEFAULTS.star.hbs +220 -0
  182. package/cli/templates/TILT_TECH_STACK.star.hbs +149 -0
  183. package/cli/templates/Tiltfile.hbs +381 -0
  184. package/cli/templates/spec.master.hbs +192 -0
  185. package/discovery/AGENTS.md +362 -0
  186. package/discovery/TILT_DISCOVERY.star +429 -0
  187. package/discovery/Tiltfile +58 -0
  188. package/discovery/config.star +265 -0
  189. package/discovery/constants.star +167 -0
  190. package/discovery/deterministic.star +213 -0
  191. package/discovery/discovery_daemon.star +193 -0
  192. package/discovery/discovery_orchestrator.star +492 -0
  193. package/discovery/filtering.star +7 -0
  194. package/discovery/identity-management-backend/service.yaml +26 -0
  195. package/discovery/identity-management-frontend/service.yaml +29 -0
  196. package/discovery/identity-sdk/service.yaml +9 -0
  197. package/discovery/incremental_discovery.star +215 -0
  198. package/discovery/indexing.star +9 -0
  199. package/discovery/json_manifest_scanner.star +57 -0
  200. package/discovery/libraries.star +48 -0
  201. package/discovery/loading.star +25 -0
  202. package/discovery/manifest/constants.star +106 -0
  203. package/discovery/manifest/loading.star +418 -0
  204. package/discovery/manifest/normalize.star +289 -0
  205. package/discovery/manifest/validation.star +110 -0
  206. package/discovery/normalization.star +13 -0
  207. package/discovery/registry.star +562 -0
  208. package/discovery/resource_snapshot.py +384 -0
  209. package/discovery/resource_snapshot.star +145 -0
  210. package/discovery/schemas.star +3 -0
  211. package/discovery/services/platform/cdc/debezium/nats-connector/service.yaml +9 -0
  212. package/discovery/services/platform/cdc/nats-http-bridge/service.yaml +9 -0
  213. package/discovery/services/platform/orchestrator/orchestrator-glue-backend/service.yaml +26 -0
  214. package/discovery/services/platform/synthetic-monitor/service.yaml +9 -0
  215. package/discovery/test_resource_snapshot.py +253 -0
  216. package/discovery/validation.star +80 -0
  217. package/discovery/versioning.star +3 -0
  218. package/engine/AGENTS.md +706 -0
  219. package/engine/README.md +31 -0
  220. package/engine/REFACTORING_MANIFEST_SYSTEM.md +974 -0
  221. package/engine/Tiltfile +86 -0
  222. package/engine/assets/docker/golden-layers.Dockerfile +204 -0
  223. package/engine/assets/docker/wake-gateway/Dockerfile +28 -0
  224. package/engine/assets/docker/wake-gateway/decide.test.ts +177 -0
  225. package/engine/assets/docker/wake-gateway/decide.ts +135 -0
  226. package/engine/assets/docker/wake-gateway/server.ts +363 -0
  227. package/engine/assets/scripts/cleanup-completed-migrator-images.sh +39 -0
  228. package/engine/assets/scripts/cleanup-tilt-images.sh +122 -0
  229. package/engine/assets/scripts/mac-m1-resource-monitor.sh +123 -0
  230. package/engine/config.star +5 -0
  231. package/engine/entrypoint.star +101 -0
  232. package/engine/lifecycle/orchestrator.star +263 -0
  233. package/engine/paths.star +719 -0
  234. package/engine/schemas/project-schema.json +147 -0
  235. package/engine/schemas/service-schema.json +537 -0
  236. package/engine/scripts/README.md +89 -0
  237. package/engine/scripts/build-and-publish-lib.sh +207 -0
  238. package/engine/scripts/check-lib-publish.sh +87 -0
  239. package/engine/scripts/debug-container.sh +265 -0
  240. package/engine/scripts/generate-manifest.sh +200 -0
  241. package/engine/spec.master +702 -0
  242. package/engine/spec.master.example +341 -0
  243. package/engine/topologies/README.md +33 -0
  244. package/engine/topologies/platform/docker/AGENTS.md +59 -0
  245. package/engine/topologies/platform/docker/auth/auth.star +207 -0
  246. package/engine/topologies/platform/docker/build/frontend_build_plan.star +65 -0
  247. package/engine/topologies/platform/docker/build/golden_image.star +37 -0
  248. package/engine/topologies/platform/docker/build/golden_image_build.star +144 -0
  249. package/engine/topologies/platform/docker/build/golden_image_constants.star +100 -0
  250. package/engine/topologies/platform/docker/build/golden_image_dockerfile.star +263 -0
  251. package/engine/topologies/platform/docker/compose/compose.star +637 -0
  252. package/engine/topologies/platform/docker/compose/compose_helpers.star +54 -0
  253. package/engine/topologies/platform/docker/compose/traefik_standalone.star +171 -0
  254. package/engine/topologies/platform/docker/config/bunignore.star +144 -0
  255. package/engine/topologies/platform/docker/config/dockerignore.star +152 -0
  256. package/engine/topologies/platform/docker/config/healthcheck.star +58 -0
  257. package/engine/topologies/platform/docker/constants.star +211 -0
  258. package/engine/topologies/platform/docker/dockerfile/dockerfile.star +56 -0
  259. package/engine/topologies/platform/docker/dockerfile/language_dockerfile.star +264 -0
  260. package/engine/topologies/platform/docker/generators/golden_docker_generator_v2.star +76 -0
  261. package/engine/topologies/platform/docker/index.star +40 -0
  262. package/engine/topologies/platform/docker/layers/bun_helpers.star +25 -0
  263. package/engine/topologies/platform/docker/layers/infisical/index.star +42 -0
  264. package/engine/topologies/platform/docker/layers/infisical/infisical_docker.star +264 -0
  265. package/engine/topologies/platform/docker/layers/l1_base_layers.star +89 -0
  266. package/engine/topologies/platform/docker/layers/l2_dependency_layers.star +147 -0
  267. package/engine/topologies/platform/docker/layers/l3_builder_layers.star +229 -0
  268. package/engine/topologies/platform/docker/layers/l4_runtime_layers.star +282 -0
  269. package/engine/topologies/platform/docker/layers/prisma/constants.star +138 -0
  270. package/engine/topologies/platform/docker/layers/prisma/db_readiness.star +98 -0
  271. package/engine/topologies/platform/docker/layers/prisma/filesystem_setup.star +131 -0
  272. package/engine/topologies/platform/docker/layers/prisma/migrate_script.star +100 -0
  273. package/engine/topologies/platform/docker/layers/prisma/prisma_build.star +128 -0
  274. package/engine/topologies/platform/docker/layers/prisma/prisma_runtime.star +205 -0
  275. package/engine/topologies/platform/docker/layers/prisma/secret_resolution.star +121 -0
  276. package/engine/topologies/platform/docker/networking/api_path_constants.star +206 -0
  277. package/engine/topologies/platform/docker/networking/sablier_container_cycle.star +31 -0
  278. package/engine/topologies/platform/docker/networking/traefik.star +266 -0
  279. package/engine/topologies/platform/docker/networking/traefik_constants.star +148 -0
  280. package/engine/topologies/platform/docker/networking/traefik_helpers.star +162 -0
  281. package/engine/topologies/platform/docker/networking/traefik_static_routes.star +165 -0
  282. package/engine/topologies/platform/docker/secrets/env_secrets.star +74 -0
  283. package/engine/topologies/platform/docker/secrets/infisical.star +109 -0
  284. package/engine/topologies/platform/net/AGENTS.md +64 -0
  285. package/engine/topologies/platform/net/proxy.star +6 -0
  286. package/engine/topologies/platform/registries/local.star +6 -0
  287. package/engine/topologies/platform/registries/verdaccio_loader.star +20 -0
  288. package/engine/topologies/platform/security/AGENTS.md +49 -0
  289. package/engine/topologies/platform/security/secrets.star +241 -0
  290. package/engine/topologies/platform/state/AGENTS.md +64 -0
  291. package/engine/topologies/platform/state/relational.star +6 -0
  292. package/engine/topologies/tilt/common/AGENTS.md +59 -0
  293. package/engine/topologies/tilt/common/utils.star +409 -0
  294. package/engine/topologies/tilt/common/utils_debug.star +71 -0
  295. package/engine/topologies/tilt/common/utils_deterministic.star +170 -0
  296. package/engine/topologies/tilt/common/utils_docker_networks.star +54 -0
  297. package/engine/topologies/tilt/common/utils_env.star +92 -0
  298. package/engine/topologies/tilt/common/utils_output.star +99 -0
  299. package/engine/topologies/tilt/config/AGENTS.md +68 -0
  300. package/engine/topologies/tilt/config/defaults.star +5 -0
  301. package/engine/topologies/tilt/config/feature_flags.star +12 -0
  302. package/engine/topologies/tilt/config/global.star +57 -0
  303. package/engine/topologies/tilt/config/profiles.star +398 -0
  304. package/engine/topologies/tilt/generators/agents_md.star +64 -0
  305. package/engine/topologies/tilt/generators/api_gateway.star +147 -0
  306. package/engine/topologies/tilt/generators/index.star +126 -0
  307. package/engine/topologies/tilt/generators/infisical/README.md +424 -0
  308. package/engine/topologies/tilt/generators/infisical/examples.star +314 -0
  309. package/engine/topologies/tilt/generators/infisical/index.star +59 -0
  310. package/engine/topologies/tilt/generators/infisical/machine_identity.star +422 -0
  311. package/engine/topologies/tilt/generators/infisical/organization.star +536 -0
  312. package/engine/topologies/tilt/generators/infisical/path_manager.star +478 -0
  313. package/engine/topologies/tilt/generators/infisical/secrets_generator.star +422 -0
  314. package/engine/topologies/tilt/generators/nginx_conf.star +145 -0
  315. package/engine/topologies/tilt/generators/npmrc.star +132 -0
  316. package/engine/topologies/tilt/generators/tsconfig.star +25 -0
  317. package/engine/topologies/tilt/generators/typescript/backend_library_tsconfig.star +73 -0
  318. package/engine/topologies/tilt/generators/typescript/backend_tsconfig.star +137 -0
  319. package/engine/topologies/tilt/generators/typescript/common.star +9 -0
  320. package/engine/topologies/tilt/generators/typescript/frontend_library_tsconfig.star +78 -0
  321. package/engine/topologies/tilt/generators/typescript/frontend_tsconfig.star +140 -0
  322. package/engine/topologies/tilt/generators/typescript/include.star +25 -0
  323. package/engine/topologies/tilt/generators/typescript/playwright_config.star +42 -0
  324. package/engine/topologies/tilt/generators/typescript/prisma_config.star +51 -0
  325. package/engine/topologies/tilt/generators/validators.star +868 -0
  326. package/engine/topologies/tilt/generators/vite/backend.star +80 -0
  327. package/engine/topologies/tilt/generators/vite/frameworks/lit.star +92 -0
  328. package/engine/topologies/tilt/generators/vite/frameworks/preact.star +94 -0
  329. package/engine/topologies/tilt/generators/vite/frameworks/qwik.star +94 -0
  330. package/engine/topologies/tilt/generators/vite/frameworks/react.star +128 -0
  331. package/engine/topologies/tilt/generators/vite/frameworks/solid.star +94 -0
  332. package/engine/topologies/tilt/generators/vite/frameworks/svelte.star +94 -0
  333. package/engine/topologies/tilt/generators/vite/frameworks/vanilla.star +92 -0
  334. package/engine/topologies/tilt/generators/vite/frameworks/vue.star +94 -0
  335. package/engine/topologies/tilt/generators/vite/frontend.star +153 -0
  336. package/engine/topologies/tilt/generators/vite/generators.star +45 -0
  337. package/engine/topologies/tilt/generators/vite/helpers.star +256 -0
  338. package/engine/topologies/tilt/generators/vite/library.star +67 -0
  339. package/engine/topologies/tilt/generators/vite/sdk.star +75 -0
  340. package/engine/topologies/tilt/generators/vite/templates.star +460 -0
  341. package/engine/topologies/tilt/generators/vite_config.star +24 -0
  342. package/engine/topologies/tilt/manifest/AGENTS.md +61 -0
  343. package/engine/topologies/tilt/manifest/README.md +679 -0
  344. package/engine/topologies/tilt/manifest/__init__.star +220 -0
  345. package/engine/topologies/tilt/manifest/constants.star +262 -0
  346. package/engine/topologies/tilt/manifest/errors.star +268 -0
  347. package/engine/topologies/tilt/manifest/integration.star +348 -0
  348. package/engine/topologies/tilt/manifest/json_to_yaml.py +61 -0
  349. package/engine/topologies/tilt/manifest/loader.star +239 -0
  350. package/engine/topologies/tilt/manifest/mapper.star +229 -0
  351. package/engine/topologies/tilt/manifest/parser.star +490 -0
  352. package/engine/topologies/tilt/manifest/schema.star +502 -0
  353. package/engine/topologies/tilt/manifest/tests/test_integration.star +278 -0
  354. package/engine/topologies/tilt/manifest/tests/test_loader_parser.star +475 -0
  355. package/engine/topologies/tilt/manifest/tests/test_manifest.star +319 -0
  356. package/engine/topologies/tilt/manifest/tests/test_validator.star +472 -0
  357. package/engine/topologies/tilt/manifest/validator.star +744 -0
  358. package/engine/topologies/tilt/manifest/yaml_to_json.py +20 -0
  359. package/engine/topologies/tilt/resources/AGENTS.md +71 -0
  360. package/engine/topologies/tilt/resources/build_concurrency.star +56 -0
  361. package/engine/topologies/tilt/resources/conditions.star +5 -0
  362. package/engine/topologies/tilt/resources/databases.star +246 -0
  363. package/engine/topologies/tilt/resources/declaration.star +5 -0
  364. package/engine/topologies/tilt/resources/deps.star +5 -0
  365. package/engine/topologies/tilt/resources/infra-loader.star +504 -0
  366. package/engine/topologies/tilt/resources/libs.star +32 -0
  367. package/engine/topologies/tilt/resources/libs_discovery.star +104 -0
  368. package/engine/topologies/tilt/resources/libs_paths.star +81 -0
  369. package/engine/topologies/tilt/resources/libs_resource_definition.star +153 -0
  370. package/engine/topologies/tilt/resources/libs_setup.star +166 -0
  371. package/engine/topologies/tilt/resources/libs_tsconfig.star +39 -0
  372. package/engine/topologies/tilt/resources/orchestrator/apply.star +79 -0
  373. package/engine/topologies/tilt/resources/orchestrator/apply_compose_resource_registration.star +864 -0
  374. package/engine/topologies/tilt/resources/orchestrator/apply_manifest_orchestration.star +90 -0
  375. package/engine/topologies/tilt/resources/orchestrator/apply_migrator_orchestration.star +150 -0
  376. package/engine/topologies/tilt/resources/orchestrator/apply_resource_validation.star +38 -0
  377. package/engine/topologies/tilt/resources/orchestrator/apply_runtime_flags.star +46 -0
  378. package/engine/topologies/tilt/resources/orchestrator/builders/typescript.star +193 -0
  379. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/AGENTS.md +75 -0
  380. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/index.star +23 -0
  381. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/resolver.star +136 -0
  382. package/engine/topologies/tilt/resources/orchestrator/generators/env.star +219 -0
  383. package/engine/topologies/tilt/resources/orchestrator/generators/frontend.star +172 -0
  384. package/engine/topologies/tilt/resources/orchestrator/generators/manifest_resource.star +577 -0
  385. package/engine/topologies/tilt/resources/orchestrator/helpers.star +35 -0
  386. package/engine/topologies/tilt/resources/orchestrator.star +56 -0
  387. package/engine/topologies/tilt/resources/ordering.star +5 -0
  388. package/engine/topologies/tilt/resources/shared-platform-postgres.star +30 -0
  389. package/engine/topologies/tilt/resources/triggers.star +5 -0
  390. package/engine/topologies/tilt/resources/watchers.star +304 -0
  391. package/engine/where-things-live.star +719 -0
  392. package/examples/tdk-example/LICENSE +21 -0
  393. package/examples/tdk-example/README.md +23 -0
  394. package/examples/tdk-example/TILT_SERVICE_DEFAULTS.star +42 -0
  395. package/examples/tdk-example/TILT_TECH_STACK.star +67 -0
  396. package/examples/tdk-example/Tiltfile +25 -0
  397. package/examples/tdk-example/services/platform/messaging/docker-compose.yml +26 -0
  398. package/examples/tdk-example/services/shop/orders-api/package.json +20 -0
  399. package/examples/tdk-example/services/shop/orders-api/service.json +14 -0
  400. package/examples/tdk-example/services/shop/orders-api/src/index.ts +81 -0
  401. package/examples/tdk-example/services/shop/orders-app/index.html +12 -0
  402. package/examples/tdk-example/services/shop/orders-app/package.json +23 -0
  403. package/examples/tdk-example/services/shop/orders-app/public/.gitkeep +0 -0
  404. package/examples/tdk-example/services/shop/orders-app/service.json +9 -0
  405. package/examples/tdk-example/services/shop/orders-app/src/main.tsx +9 -0
  406. package/examples/tdk-example/services/shop/orders-app/src/orders.tsx +67 -0
  407. package/examples/tdk-example/services/shop/orders-app/src/style.css +15 -0
  408. package/examples/tdk-example/services/shop/orders-worker/package.json +18 -0
  409. package/examples/tdk-example/services/shop/orders-worker/service.json +13 -0
  410. package/examples/tdk-example/services/shop/orders-worker/src/index.ts +33 -0
  411. package/ext/Tiltfile +66 -0
  412. package/ext/ide-components/README.md +221 -0
  413. package/ext/ide-components/code_viewer/server.py +208 -0
  414. package/ext/ide-components/config_inspector/server.py +1052 -0
  415. package/ext/ide-components/file_browser/server.py +287 -0
  416. package/ext/ide-components/shared/config_service.py +471 -0
  417. package/ext/ide-components/shared/file_utils.py +300 -0
  418. package/ext/ide-components/shared/http_utils.py +234 -0
  419. package/ext/ide-components/shared/static/styles.css +1334 -0
  420. package/ext/ide-components/shared/syntax_highlighter.py +142 -0
  421. package/ext/ide-components/shared/template_engine.py +125 -0
  422. package/ext/ide-components/shared/templates/base.html +121 -0
  423. package/ext/ide-components/shared/test_config_service.py +328 -0
  424. package/ext/ide-components/shared/tilt_integration.py +160 -0
  425. package/ext/ui-enhancements/cron-status-server.sh +51 -0
  426. package/ext/ui-enhancements/cron-status-tracker.sh +148 -0
  427. package/ext/ui-enhancements/extension.yaml +36 -0
  428. package/ext/ui-enhancements/tiltfile.py +101 -0
  429. package/ext/ui-enhancements/ui/cron-jobs-tab.css +396 -0
  430. package/ext/ui-enhancements/ui/help-panel.css +279 -0
  431. package/ext/ui-enhancements/ui/icons.css +125 -0
  432. package/ext/ui-enhancements/ui/tooltips.css +114 -0
  433. package/package.json +94 -4
  434. package/shared-platform-engineering/docker-templates/bun-hoisted-symlink-fix.sh +25 -0
  435. package/shared-platform-engineering/docker-templates/infisical-entrypoint.sh +466 -0
  436. package/shared-platform-engineering/docker-templates/install-deps.sh +154 -0
  437. package/shared-platform-engineering/docker-templates/prisma-bun-client-link-fix.sh +14 -0
  438. package/shared-platform-engineering/docker-templates/prisma-normalize-client.sh +58 -0
  439. package/specs/specs/TILT_SERVICE_DEFAULTS.star +207 -0
  440. package/specs/specs/TILT_TECH_STACK.star +161 -0
@@ -0,0 +1,98 @@
1
+ # Copyright (c) 2026 Flisk Landscape contributors
2
+ # SPDX-License-Identifier: MIT
3
+ """
4
+ DB Readiness Shell Fragment
5
+
6
+ Generates the shell script block that:
7
+ 1. Parses DB_HOST / DB_PORT from DATABASE_URL when the separate vars are absent
8
+ 2. Loops with `nc` until PostgreSQL accepts connections (120 s timeout)
9
+
10
+ Returns a plain string that is embedded verbatim inside migrate.sh.
11
+ """
12
+
13
+ load('../../../../tilt/common/utils_debug.star', 'DEBUG_MODE')
14
+ load(
15
+ './constants.star',
16
+ 'DB_URL_HOSTPORT_NO_AUTH_SED',
17
+ 'DB_URL_HOSTPORT_WITH_AUTH_SED',
18
+ 'DEFAULT_DB_PORT',
19
+ 'DEFAULT_DB_WAIT_TIMEOUT_SECS',
20
+ )
21
+
22
+
23
+ def _host_port_parse_block():
24
+ """
25
+ Extract DB_HOST_VAL / DB_PORT_VAL from DATABASE_URL when the individual
26
+ DB_HOST / DB_PORT env vars are not available.
27
+
28
+ Handles both:
29
+ postgresql://user:pass@host:port/db (with auth)
30
+ postgresql://host:port/db (without auth)
31
+ """
32
+ return (
33
+ "# Extract host and port for the readiness probe\n"
34
+ + "DB_HOST_VAL=\"$DB_HOST\"\n"
35
+ + "DB_PORT_VAL=\"$DB_PORT\"\n"
36
+ + "if [ -z \"$DB_HOST_VAL\" ]; then\n"
37
+ + " HOSTPORT=$(printf '%s\\n' \"$DATABASE_URL\" | "
38
+ + DB_URL_HOSTPORT_WITH_AUTH_SED + " | head -n1)\n"
39
+ + " if [ -z \"$HOSTPORT\" ]; then\n"
40
+ + " HOSTPORT=$(printf '%s\\n' \"$DATABASE_URL\" | "
41
+ + DB_URL_HOSTPORT_NO_AUTH_SED + " | head -n1)\n"
42
+ + " fi\n"
43
+ + " if printf '%s\\n' \"$HOSTPORT\" | grep -q '^\\['; then\n"
44
+ + " DB_HOST_VAL=$(printf '%s\\n' \"$HOSTPORT\" | sed -n 's/^\\[\\([^]]*\\)\\]\\(:[0-9][0-9]*\\)\\?$/\\1/p' || true)\n"
45
+ + " DB_PORT_VAL=$(printf '%s\\n' \"$HOSTPORT\" | sed -n 's/^\\[[^]]*\\]:\\([0-9][0-9]*\\)$/\\1/p' || true)\n"
46
+ + " else\n"
47
+ + " DB_HOST_VAL=$(printf '%s\\n' \"$HOSTPORT\" | awk -F: '{print $1}' || true)\n"
48
+ + " DB_PORT_VAL=$(printf '%s\\n' \"$HOSTPORT\" | awk -F: 'NF>1{print $NF}' || true)\n"
49
+ + " fi\n"
50
+ + "fi\n"
51
+ + "DB_PORT_VAL=\"${DB_PORT_VAL:-" + DEFAULT_DB_PORT + "}\"\n"
52
+ + "if [ -z \"$DB_HOST_VAL\" ]; then\n"
53
+ + " echo \"\\u274c ERROR: Unable to parse DB host from DATABASE_URL\"\n"
54
+ + " exit 1\n"
55
+ + "fi\n"
56
+ )
57
+
58
+
59
+ def _wait_loop_block(log_wait, log_ready, timeout_secs = DEFAULT_DB_WAIT_TIMEOUT_SECS):
60
+ """
61
+ nc-based polling loop. Retries every second up to `timeout_secs`.
62
+ """
63
+ return (
64
+ log_wait
65
+ + "i=0\n"
66
+ + "while ! nc -z \"${DB_HOST_VAL}\" \"${DB_PORT_VAL}\"; do\n"
67
+ + " i=$((i+1))\n"
68
+ + " if [ $i -gt " + str(timeout_secs) + " ]; then\n"
69
+ + " echo \"\\u274c Timeout waiting for DB at ${DB_HOST_VAL}:${DB_PORT_VAL}\"\n"
70
+ + " exit 1\n"
71
+ + " fi\n"
72
+ + " sleep 1\n"
73
+ + "done\n"
74
+ + log_ready
75
+ )
76
+
77
+
78
+ def db_readiness_script(timeout_secs = DEFAULT_DB_WAIT_TIMEOUT_SECS):
79
+ """
80
+ Return the complete shell fragment that waits for PostgreSQL to accept
81
+ connections before proceeding to migration.
82
+
83
+ Args:
84
+ timeout_secs: Seconds to wait before aborting (default: 120)
85
+ """
86
+ if DEBUG_MODE:
87
+ log_wait = "echo \"\\u23f3 Waiting for PostgreSQL at ${DB_HOST_VAL}:${DB_PORT_VAL}...\"\n"
88
+ log_ready = "echo \"\\u2705 PostgreSQL is ready!\"\n"
89
+ else:
90
+ log_wait = ""
91
+ log_ready = ""
92
+
93
+ return (
94
+ _host_port_parse_block()
95
+ + _wait_loop_block(log_wait, log_ready, timeout_secs)
96
+ )
97
+
98
+ DEBUG = {}
@@ -0,0 +1,131 @@
1
+ # Copyright (c) 2026 Flisk Landscape contributors
2
+ # SPDX-License-Identifier: MIT
3
+ """
4
+ Filesystem Setup Dockerfile Fragment
5
+
6
+ Generates the RUN/COPY instructions that:
7
+ - Install Alpine utilities needed by migrate.sh at runtime (curl, jq, nc)
8
+ - Create required directories and fix ownership so Prisma can write generated files
9
+ - Ensure @prisma/engines is resolvable for the CLI (engines may land under
10
+ prisma/node_modules in Bun hoisting layouts)
11
+
12
+ All functions return Dockerfile instruction strings.
13
+ """
14
+
15
+ load(
16
+ '../bun_helpers.star',
17
+ 'bun_hoisted_packages_symlink_fix',
18
+ )
19
+ load(
20
+ './constants.star',
21
+ 'APP_BUN_STORE_DIR',
22
+ 'APP_GENERATED_CLIENT_DIR',
23
+ 'APP_NODE_MODULES_BIN_DIR',
24
+ 'APP_NODE_MODULES_DIR',
25
+ 'APP_PRISMA_DIR',
26
+ 'APP_PRISMA_PACKAGE_DIR',
27
+ 'APP_PRISMA_SCOPE_DIR',
28
+ 'APP_SRC_DIR',
29
+ 'BUN_USER',
30
+ 'PRISMA_BIN_ABS_PATH',
31
+ 'PRISMA_BIN_SYMLINK_TARGET',
32
+ 'PRISMA_CONFIG_ABS_PATH',
33
+ 'PRISMA_SCHEMA_PATH',
34
+ )
35
+
36
+
37
+ def apk_runtime_tools():
38
+ """
39
+ Install runtime utilities required by migrate.sh: bash, curl, jq, netcat-openbsd, postgresql-client.
40
+ """
41
+ return "RUN apk add --no-cache bash curl jq netcat-openbsd postgresql-client\n"
42
+
43
+
44
+ def prisma_dir_and_permissions():
45
+ """
46
+ Create directories that Prisma writes to at runtime and ensure the `bun` user owns
47
+ them. Handles both the standard `node_modules/.prisma/client` path and custom
48
+ output paths like `../src/generated` or `../generated-client`.
49
+ """
50
+ return (
51
+ "# Ensure Prisma can write generated files including custom output paths\n"
52
+ + "RUN mkdir -p " + APP_NODE_MODULES_DIR + " " + APP_SRC_DIR + " " + APP_GENERATED_CLIENT_DIR
53
+ + " && chown -R " + BUN_USER + ":" + BUN_USER
54
+ + " " + APP_PRISMA_DIR + " " + APP_NODE_MODULES_DIR + " " + APP_SRC_DIR + " " + APP_GENERATED_CLIENT_DIR
55
+ + " " + PRISMA_CONFIG_ABS_PATH + " || true\n"
56
+ )
57
+
58
+
59
+ def prisma_engines_symlink():
60
+ """
61
+ Rebuild @prisma links from Bun's isolated store after cross-stage COPY.
62
+ Service-level node_modules symlinks are relative and can break when copied to
63
+ `/app/node_modules`. We relink from `/app/node_modules/.bun`.
64
+
65
+ Handles two types of packages:
66
+ 1. Nested packages: @prisma/client, @prisma/adapter-pg (under node_modules/@prisma/)
67
+ 2. Top-level package: @prisma/engines (copied as real files, not symlinked)
68
+ """
69
+ return (
70
+ "# Re-link @prisma packages from Bun store so Prisma CLI can resolve engines\n"
71
+ # Written inline: the template this used to COPY is not shipped anywhere.
72
+ + "RUN cat > /usr/local/bin/prisma-runtime-relink.sh << 'EOF'\n"
73
+ + "#!/bin/sh\n"
74
+ + "set -e\n"
75
+ + "# Nested @prisma packages: replace the symlink into node_modules/.bun with a real copy.\n"
76
+ + "for name in client adapter-pg; do\n"
77
+ + " src=$(ls -d /app/node_modules/.bun/@prisma+${name}@*/node_modules/@prisma/${name} 2>/dev/null | head -n 1 || true)\n"
78
+ + " if [ -n \"$src\" ]; then\n"
79
+ + " rm -rf /app/node_modules/@prisma/${name}\n"
80
+ + " mkdir -p /app/node_modules/@prisma\n"
81
+ + " cp -R \"$src\" /app/node_modules/@prisma/${name}\n"
82
+ + " fi\n"
83
+ + "done\n"
84
+ + "# Top-level @prisma/engines: copy as real files, not a symlink.\n"
85
+ + "src=$(ls -d /app/node_modules/.bun/@prisma+engines@*/node_modules/@prisma/engines 2>/dev/null | head -n 1 || true)\n"
86
+ + "if [ -n \"$src\" ]; then\n"
87
+ + " rm -rf /app/node_modules/@prisma/engines\n"
88
+ + " mkdir -p /app/node_modules/@prisma\n"
89
+ + " cp -R \"$src\" /app/node_modules/@prisma/engines\n"
90
+ + "fi\n"
91
+ + "EOF\n"
92
+ + "RUN chmod +x /usr/local/bin/prisma-runtime-relink.sh && /usr/local/bin/prisma-runtime-relink.sh\n"
93
+ )
94
+
95
+
96
+ def prisma_config_inline():
97
+ """
98
+ Inline-generate /app/prisma.config.ts so Prisma v7 migration commands pick up
99
+ the datasource URL from the environment without requiring a build-time file copy.
100
+ """
101
+ return (
102
+ "# Prisma v7 migration commands require datasource.url in prisma.config.ts\n"
103
+ + "RUN cat > " + PRISMA_CONFIG_ABS_PATH + " << 'EOF'\n"
104
+ + "export default {\n"
105
+ + " schema: '" + PRISMA_SCHEMA_PATH + "',\n"
106
+ + " datasource: {\n"
107
+ + " url: process.env.DATABASE_URL,\n"
108
+ + " },\n"
109
+ + "};\n"
110
+ + "EOF\n"
111
+ )
112
+
113
+
114
+ def migrator_filesystem_setup():
115
+ """
116
+ Convenience wrapper – returns all filesystem setup instructions in order:
117
+ 1. Inline prisma.config.ts
118
+ 2. Permission fixes
119
+ 3. @prisma/engines symlink
120
+ 4. Alpine utilities
121
+ 5. General Bun hoisted packages symlink fix
122
+
123
+ The caller is responsible for wrapping these in `USER root` / `USER bun` guards.
124
+ """
125
+ return (
126
+ prisma_config_inline()
127
+ + prisma_dir_and_permissions()
128
+ + prisma_engines_symlink()
129
+ + apk_runtime_tools()
130
+ + bun_hoisted_packages_symlink_fix()
131
+ )
@@ -0,0 +1,100 @@
1
+ # Copyright (c) 2026 Flisk Landscape contributors
2
+ # SPDX-License-Identifier: MIT
3
+ """
4
+ Migrate Script Builder
5
+
6
+ Assembles the complete /app/migrate.sh entrypoint that runs inside the
7
+ l4_migrator_runtime container. Delegates each logical section to a
8
+ dedicated module so this file stays focused on overall script structure.
9
+
10
+ secret_resolution – resolves DATABASE_URL (Infisical or env vars)
11
+ db_readiness – waits for PostgreSQL to accept connections
12
+ """
13
+
14
+ load('../../../../tilt/common/utils_debug.star', 'DEBUG_MODE')
15
+ load('./secret_resolution.star', 'secret_resolution_script')
16
+ load('./db_readiness.star', 'db_readiness_script')
17
+ load(
18
+ './constants.star',
19
+ 'APP_DIR',
20
+ 'MIGRATE_SH_ABS_PATH',
21
+ 'PRISMA_BIN_ABS_PATH',
22
+ 'PRISMA_GENERATE_SUBCOMMAND',
23
+ 'PRISMA_MIGRATE_DEPLOY_SUBCOMMAND',
24
+ )
25
+
26
+
27
+ def _log(debug_msg, prod_msg = ""):
28
+ """Return debug_msg when DEBUG_MODE is on, prod_msg otherwise."""
29
+ return debug_msg if DEBUG_MODE else prod_msg
30
+
31
+
32
+ def _prisma_run_block():
33
+ """
34
+ Shell fragment that locates the local Prisma CLI binary and runs
35
+ `migrate deploy` followed by `generate`. Avoids `bunx prisma` to
36
+ prevent accidental network fetches of the latest Prisma version.
37
+ """
38
+ return (
39
+ "# Use locally installed Prisma CLI – avoids bunx fetching prisma@latest\n"
40
+ + "PRISMA_BIN=\"" + PRISMA_BIN_ABS_PATH + "\"\n"
41
+ + "if [ ! -x \"$PRISMA_BIN\" ]; then\n"
42
+ + " echo \"\\u274c ERROR: Prisma CLI not found at $PRISMA_BIN\"\n"
43
+ + " exit 1\n"
44
+ + "fi\n"
45
+ + "# Ensure DATABASE_URL is exported for Prisma CLI\n"
46
+ + "export DATABASE_URL\n"
47
+ + _log("echo \"\\U0001f504 Running Prisma migrations...\"\n")
48
+ + "cd " + APP_DIR + " && \"$PRISMA_BIN\" " + PRISMA_MIGRATE_DEPLOY_SUBCOMMAND + "\n"
49
+ + _log("echo \"\\U0001f527 Generating Prisma client...\"\n")
50
+ + "\"$PRISMA_BIN\" " + PRISMA_GENERATE_SUBCOMMAND + "\n"
51
+ )
52
+
53
+
54
+ def migrate_sh_content(resource_name):
55
+ """
56
+ Return the full text of migrate.sh for the given service.
57
+
58
+ Args:
59
+ resource_name: Used in RESOURCE_NAME env var and Infisical secret path
60
+ (e.g. 'user-service', 'order-service').
61
+ """
62
+ done_msg = (
63
+ _log("echo \"\\U0001f389 Database migration completed successfully!\"\n")
64
+ or "echo \"Database migration completed\"\n"
65
+ )
66
+
67
+ return (
68
+ "#!/bin/sh\n"
69
+ + "set -e\n"
70
+ + _log(
71
+ "echo \"\\U0001f5c4\\ufe0f Starting database migration for $RESOURCE_NAME...\"\n",
72
+ "echo \"Starting database migration...\"\n",
73
+ )
74
+ + "\n# --- 1. Resolve DATABASE_URL ---\n"
75
+ + secret_resolution_script()
76
+ + "\n# --- 2. Wait for PostgreSQL ---\n"
77
+ + db_readiness_script()
78
+ + "\n# --- 3. Run Prisma migrate + generate ---\n"
79
+ + _prisma_run_block()
80
+ + "\n"
81
+ + done_msg
82
+ )
83
+
84
+
85
+ def migrate_sh_dockerfile_block(resource_name):
86
+ """
87
+ Return the Dockerfile fragment that writes migrate.sh and makes it executable.
88
+
89
+ Args:
90
+ resource_name: Forwarded to migrate_sh_content().
91
+ """
92
+ return (
93
+ "# Provide the migrate entrypoint\n"
94
+ + "RUN cat > " + MIGRATE_SH_ABS_PATH + " << 'EOF'\n"
95
+ + migrate_sh_content(resource_name)
96
+ + "EOF\n"
97
+ + "RUN chmod +x " + MIGRATE_SH_ABS_PATH + "\n"
98
+ )
99
+
100
+ DEBUG = {}
@@ -0,0 +1,128 @@
1
+ # Copyright (c) 2026 Flisk contributors
2
+ # SPDX-License-Identifier: MIT
3
+ # === INLINED CONSTANTS for pure extension loading ===
4
+ OUTPUT = struct(AUTOGENERATED_FOLDER = ".autogenerated")
5
+ # === END INLINED CONSTANTS ===
6
+
7
+
8
+ """
9
+ Prisma Build Layers - L3 Prisma Client Generation and Migration Engine
10
+
11
+ Encapsulates all Prisma-related Dockerfile instructions for the build stage:
12
+ - Client generation (`bunx prisma generate`)
13
+ - Output normalization (generated-client ↔ node_modules/.prisma/client)
14
+ - Default module shim for Prisma v7 / @prisma/client compatibility
15
+ - Migration engine stage for Prisma migrate deploy
16
+ """
17
+
18
+ load('../l1_base_layers.star', 'BUN_BASE')
19
+ load('../l2_dependency_layers.star', 'normalize_res_path')
20
+ load('../../../../../../discovery/config.star', 'GLOBAL_CONFIG')
21
+ load('../../../../tilt/manifest/constants.star', 'AUTOGENERATED_CONFIG_PATHS')
22
+
23
+ load(
24
+ './constants.star',
25
+ 'APP_BUN_STORE_DIR',
26
+ 'DEFAULT_GOLDEN_L3_MIGRATOR_IMAGE',
27
+ 'NODE_MODULES_DIR',
28
+ 'PRISMA_CONFIG_WORKDIR_PATH',
29
+ 'PRISMA_DIR_NAME',
30
+ 'PRISMA_GENERATE_RUN',
31
+ 'PRISMA_PACKAGE_NODE_MODULES_REL_PATH',
32
+ 'PRISMA_SCHEMA_PATH',
33
+ 'app_resource_dir',
34
+ 'prisma_normalize_output_block',
35
+ )
36
+
37
+ _docker_cfg = GLOBAL_CONFIG['docker']
38
+ GOLDEN_L3_MIGRATOR_IMAGE = _docker_cfg.get('golden_l3_migrator_image', DEFAULT_GOLDEN_L3_MIGRATOR_IMAGE)
39
+
40
+
41
+ def prisma_copy_instructions(res_path, has_prisma_config = False):
42
+ """
43
+ Generate Dockerfile COPY instructions for Prisma schema and config.
44
+
45
+ Args:
46
+ res_path: Resource path (service directory)
47
+ has_prisma_config: Whether prisma.config.ts exists (Prisma v7)
48
+
49
+ Returns:
50
+ Dockerfile content string for copying Prisma files
51
+ """
52
+ # Normalize res_path for Docker COPY (must be relative to build context)
53
+ res_path_rel = normalize_res_path(res_path)
54
+
55
+ parts = "COPY " + res_path_rel + "/" + PRISMA_DIR_NAME + " ./" + PRISMA_DIR_NAME + "\n"
56
+ if has_prisma_config:
57
+ # Prisma v7 requires prisma.config.ts in CWD for correct client generation
58
+ parts += "COPY " + res_path_rel + "/" + AUTOGENERATED_CONFIG_PATHS['prisma'] + " " + PRISMA_CONFIG_WORKDIR_PATH + "\n"
59
+ return parts
60
+
61
+
62
+ def prisma_generate_instructions():
63
+ """
64
+ Generate Dockerfile RUN instruction for Prisma client generation.
65
+
66
+ Returns:
67
+ Dockerfile content string that runs `bunx prisma generate`
68
+ """
69
+ return PRISMA_GENERATE_RUN
70
+
71
+
72
+ def prisma_normalize_output():
73
+ """
74
+ Generate Dockerfile instructions to normalize Prisma output for both
75
+ import styles: ../generated-client and node_modules/.prisma/client.
76
+
77
+ Also creates a default.js shim required by @prisma/client v7 which
78
+ resolves `.prisma/client/default` at runtime.
79
+
80
+ Returns:
81
+ Dockerfile content string for Prisma output normalization
82
+ """
83
+ return prisma_normalize_output_block(include_generated_client_export = True)
84
+
85
+
86
+ def L3_generate_migration_engine(res_path, use_golden = True):
87
+ """
88
+ Generate the migration engine layer for Prisma database migrations.
89
+
90
+ Args:
91
+ res_path: Resource path (service directory)
92
+ use_golden: Whether to use golden L3-migrator image (default: True)
93
+
94
+ Returns:
95
+ Dockerfile content string for the l3_migration_build stage
96
+ """
97
+ # Normalize res_path for Docker COPY (must be relative to build context)
98
+ res_path_rel = normalize_res_path(res_path)
99
+
100
+ # Use golden L3-migrator image if enabled (Prisma pre-installed)
101
+ base_image = GOLDEN_L3_MIGRATOR_IMAGE if use_golden else BUN_BASE
102
+ app_res_path = app_resource_dir(res_path)
103
+
104
+ return (
105
+ "# ---- L3: migration_engine ----\n"
106
+ + "FROM " + base_image + " AS l3_migration_build\n"
107
+ + "WORKDIR " + app_res_path + "\n"
108
+ + "# Copy manifest files for dependency installation\n"
109
+ + "COPY " + res_path_rel + "/package.json ./package.json\n"
110
+ + "COPY " + res_path_rel + "/" + PRISMA_DIR_NAME + " ./" + PRISMA_DIR_NAME + "\n"
111
+ + "COPY " + res_path_rel + "/" + OUTPUT.AUTOGENERATED_FOLDER + "/.npmrc.docker.autogenerated .npmrc\n"
112
+ + "COPY " + res_path_rel + "/" + OUTPUT.AUTOGENERATED_FOLDER + "/bunfig.docker.autogenerated.toml ./bunfig.toml\n"
113
+ + "COPY bun.lock* ./\n"
114
+ + "# Install runtime deps only for migrator image (skip test/dev toolchain)\n"
115
+ + "# NOTE: keep bunfig.toml (it carries the project/@tdk-landscape registry\n"
116
+ + "# scopes pointing at Verdaccio) - deleting it forces scoped packages to fall\n"
117
+ + "# back to the public npm registry and fail with ConnectionRefused/404.\n"
118
+ + "RUN --mount=type=cache,target=/cache/bun,sharing=shared rm -f bun.lock bun.lockb && env -u CI BUN_CONFIG_FROZEN_LOCKFILE=false BUN_TMPDIR=/tmp BUN_INSTALL=/tmp/bun-install bun install --production --no-frozen-lockfile --concurrent-scripts --cache-dir=/cache/bun\n"
119
+ + "# Prisma CLI is often in devDependencies; install it explicitly without mutating manifest files\n"
120
+ + "RUN --mount=type=cache,target=/cache/bun,sharing=shared PRISMA_VERSION=$(sed -n 's/.*\"prisma\"[[:space:]]*:[[:space:]]*\"[~^]*\\([^\"]*\\)\".*/\\1/p' package.json | head -n 1) && [ -n \"$PRISMA_VERSION\" ] && BUN_TMPDIR=/tmp BUN_INSTALL=/tmp/bun-install bun add --no-save --exact prisma@\"$PRISMA_VERSION\" --cache-dir=/cache/bun\n"
121
+ + "# Generate Prisma client and normalize output location for runtime compatibility\n"
122
+ + PRISMA_GENERATE_RUN
123
+ + prisma_normalize_output_block(include_generated_client_export = False)
124
+ + "RUN mkdir -p " + PRISMA_PACKAGE_NODE_MODULES_REL_PATH + "\n"
125
+ + "RUN test -f " + PRISMA_SCHEMA_PATH + "\n"
126
+ )
127
+
128
+ GLOBAL_CONFIG = {}
@@ -0,0 +1,205 @@
1
+ # Copyright (c) 2026 Flisk Landscape contributors
2
+ # SPDX-License-Identifier: MIT
3
+ """
4
+ Prisma Runtime Layers - L4 Prisma Runtime Copy and Resolution
5
+
6
+ Public API (preserved for backward compatibility with l4_runtime_layers.star):
7
+ prisma_runtime_copy(res_path) – copy .prisma artifacts from build stage
8
+ prisma_cli_runtime_copy(res_path) – copy the pinned Prisma CLI into the runtime
9
+ prisma_bun_symlink_fix() – fix Bun linker resolution for .prisma/client
10
+ prisma_config_copy(res_path) – copy prisma.config.ts (Prisma v7)
11
+ L4_generate_migrator_runtime(...) – full migrator stage (delegates to sub-modules)
12
+
13
+ Internal heavy-lifting is split across:
14
+ filesystem_setup.star – apk, dirs, permissions, engines symlink
15
+ shared docker template – generic migrate.sh entrypoint script
16
+ """
17
+
18
+ load('../l1_base_layers.star', 'BUN_BASE')
19
+ load('../l2_dependency_layers.star', 'normalize_res_path')
20
+ load('../../../../../../discovery/config.star', 'GLOBAL_CONFIG')
21
+ load('../../../../tilt/manifest/constants.star', 'AUTOGENERATED_CONFIG_PATHS')
22
+ load('./filesystem_setup.star', 'migrator_filesystem_setup')
23
+ load('./migrate_script.star', 'migrate_sh_dockerfile_block')
24
+ load(
25
+ './constants.star',
26
+ 'APP_DIR',
27
+ 'BUN_USER',
28
+ 'L3_MIGRATION_BUILD_STAGE',
29
+ 'DEFAULT_GOLDEN_L4_MIGRATOR_IMAGE',
30
+ 'MIGRATE_SH_ABS_PATH',
31
+ 'PRISMA_CONFIG_WORKDIR_PATH',
32
+ 'PRISMA_DOT_DIR_REL_PATH',
33
+ 'PRISMA_DIR_NAME',
34
+ 'PRISMA_PACKAGE_REL_PATH',
35
+ 'PRISMA_BIN_REL_PATH',
36
+ 'NODE_MODULES_BIN_DIR',
37
+ 'PRISMA_BIN_SYMLINK_TARGET',
38
+ 'ROOT_USER',
39
+ 'app_resource_dir',
40
+ 'resource_node_modules_dir',
41
+ )
42
+
43
+ _docker_cfg = GLOBAL_CONFIG['docker']
44
+ GOLDEN_L4_MIGRATOR_IMAGE = _docker_cfg.get('golden_l4_migrator_image', DEFAULT_GOLDEN_L4_MIGRATOR_IMAGE)
45
+
46
+
47
+ # ---------------------------------------------------------------------------
48
+ # Small copy/fix helpers (used by l4_runtime_layers.star for backend runtime)
49
+ # ---------------------------------------------------------------------------
50
+
51
+ def prisma_runtime_copy(res_path):
52
+ """
53
+ Copy .prisma generated client and prisma schema from the build stage.
54
+
55
+ Args:
56
+ res_path: Service directory relative to /app (e.g. 'services/product/users/...')
57
+ """
58
+ base = app_resource_dir(res_path)
59
+ return (
60
+ "COPY --from=l3_backend_build " + base + "/" + PRISMA_DOT_DIR_REL_PATH + " ./" + PRISMA_DOT_DIR_REL_PATH + "\n"
61
+ + "COPY --from=l3_backend_build " + base + "/" + PRISMA_DIR_NAME + " ./" + PRISMA_DIR_NAME + "\n"
62
+ )
63
+
64
+
65
+ def prisma_cli_runtime_copy(res_path):
66
+ """
67
+ Copy the pinned Prisma CLI package into the backend runtime image.
68
+
69
+ The runtime node_modules come from l3_production_purger, which runs
70
+ `bun install --production` and then deletes every `.bin` directory, so the
71
+ Prisma CLI (a devDependency) is absent. The entrypoint's auto-migration
72
+ would then fall back to `bunx prisma`, which downloads prisma@latest from
73
+ npm on every container start – slow at best, and a boot hang that fails the
74
+ healthcheck (and so blocks Traefik routing) on a slow network.
75
+
76
+ l3_migration_build already installs the CLI at the exact version pinned in
77
+ package.json, so reuse that instead of fetching at runtime.
78
+
79
+ Args:
80
+ res_path: Service directory relative to /app (e.g. 'services/app/dashboard-api')
81
+ """
82
+ base = resource_node_modules_dir(res_path)
83
+ return (
84
+ "# Prisma CLI at the version pinned in package.json - the entrypoint runs\n"
85
+ + "# migrations with it instead of `bunx prisma`, which would fetch prisma@latest.\n"
86
+ + "COPY --from=" + L3_MIGRATION_BUILD_STAGE + " " + base + "/" + PRISMA_DIR_NAME
87
+ + " ./" + PRISMA_PACKAGE_REL_PATH + "\n"
88
+ # bunx resolves a command against node_modules/.bin BEFORE considering a
89
+ # registry fetch - without this symlink it can't tell the CLI is already
90
+ # installed and falls back to `bun add prisma@latest` over the network.
91
+ # Needs root: at this point in the golden image we're already running
92
+ # as the unprivileged bun user, which doesn't own node_modules/.bin.
93
+ + "USER " + ROOT_USER + "\n"
94
+ # Relative to WORKDIR (/app/<res_path> here, unlike the migrator stage
95
+ # where WORKDIR is plain /app) - PRISMA_BIN_ABS_PATH assumes the latter
96
+ # and would point outside this service's node_modules entirely.
97
+ + "RUN mkdir -p " + NODE_MODULES_BIN_DIR
98
+ + " && ln -sf " + PRISMA_BIN_SYMLINK_TARGET + " ./" + PRISMA_BIN_REL_PATH
99
+ + " && chown -h " + BUN_USER + ":" + BUN_USER + " ./" + PRISMA_BIN_REL_PATH + "\n"
100
+ + "USER " + BUN_USER + "\n"
101
+ )
102
+
103
+
104
+ def prisma_bun_symlink_fix():
105
+ """
106
+ Symlink .prisma/client into every Bun linker path so runtime imports resolve.
107
+
108
+ Bun hoists @prisma/client under node_modules/.bun/@prisma+client*/node_modules/
109
+ and looks for .prisma relative to that path. The loop below covers all versions
110
+ that may be present.
111
+ """
112
+ return (
113
+ "# Fix Bun module resolution: .prisma/client must be reachable from .bun/ linker paths\n"
114
+ + "USER " + ROOT_USER + "\n"
115
+ + "COPY shared-platform-engineering/docker-templates/prisma-bun-client-link-fix.sh /usr/local/bin/prisma-bun-client-link-fix.sh\n"
116
+ + "RUN chmod +x /usr/local/bin/prisma-bun-client-link-fix.sh && /usr/local/bin/prisma-bun-client-link-fix.sh\n"
117
+ + "USER " + BUN_USER + "\n"
118
+ )
119
+
120
+
121
+ def prisma_config_copy(res_path):
122
+ """
123
+ Copy the auto-generated prisma.config.ts into the WORKDIR (required by Prisma v7).
124
+
125
+ Args:
126
+ res_path: Service directory relative to workspace root
127
+ """
128
+ # Normalize res_path for Docker COPY (must be relative to build context)
129
+ res_path_rel = normalize_res_path(res_path)
130
+ return "COPY " + res_path_rel + "/" + AUTOGENERATED_CONFIG_PATHS['prisma'] + " " + PRISMA_CONFIG_WORKDIR_PATH + "\n"
131
+
132
+
133
+ # ---------------------------------------------------------------------------
134
+ # Migrator stage builder
135
+ # ---------------------------------------------------------------------------
136
+
137
+ def _migrator_artifact_copies(res_path):
138
+ """
139
+ Runtime setup for migrator:
140
+ 1. Copy schema from l3 migration build stage
141
+ 2. Copy resolved node_modules from l3 migration build stage
142
+
143
+ This avoids Bun lockfile/frozen-lockfile edge cases in the l4 runtime image
144
+ while still keeping migrator logic simple (no pruner stage).
145
+ """
146
+ app_res_path = app_resource_dir(res_path)
147
+ base = resource_node_modules_dir(res_path)
148
+ return (
149
+ "# Copy migration schema + resolved deps from l3 stage\n"
150
+ + "COPY --from=l3_migration_build " + app_res_path + "/" + PRISMA_DIR_NAME + " ./" + PRISMA_DIR_NAME + "\n"
151
+ + "COPY --from=l3_migration_build " + base + " ./node_modules\n"
152
+ )
153
+
154
+
155
+ def _migrate_script_copy_block(resource_name):
156
+ """
157
+ Write the migrate entrypoint inline. It used to be COPYed from
158
+ shared-platform-engineering/docker-templates, a file no package ships, so the
159
+ migrator image could not build.
160
+ """
161
+ return migrate_sh_dockerfile_block(resource_name)
162
+
163
+
164
+ def L4_generate_migrator_runtime(res_path, resource_name = 'migrator', use_golden = True):
165
+ """
166
+ Generate the complete l4_migrator_runtime Dockerfile stage.
167
+
168
+ The stage:
169
+ 1. Copies Prisma artifacts from l3_migration_build
170
+ 2. Writes prisma.config.ts, fixes permissions, symlinks engines (filesystem_setup)
171
+ 3. Installs Alpine utilities (curl, jq, nc) needed at runtime
172
+ 4. Copies and chmod's /app/migrate.sh from shared docker templates
173
+ 5. Sets ENTRYPOINT to migrate.sh
174
+
175
+ Args:
176
+ res_path: Service directory relative to /app
177
+ resource_name: Used in RESOURCE_NAME env and Infisical secret path
178
+ use_golden: Always True – golden image is always preferred
179
+ """
180
+ # Golden image is mandatory – it ships Prisma + Infisical pre-built.
181
+ base_image = GOLDEN_L4_MIGRATOR_IMAGE
182
+
183
+ return (
184
+ "# ---- L4: migrator_runtime ----\n"
185
+ + "FROM " + base_image + " AS l4_migrator_runtime\n"
186
+ + "WORKDIR " + APP_DIR + "\n"
187
+ + "# Build argument to skip Infisical setup (for local dev / fast builds)\n"
188
+ + "ARG SKIP_INFISICAL_SETUP=0\n"
189
+ + "ENV NODE_ENV=production RESOURCE_NAME=" + resource_name + "\n"
190
+ + _migrator_artifact_copies(res_path)
191
+ + "USER " + ROOT_USER + "\n"
192
+ + migrator_filesystem_setup()
193
+ + "USER " + ROOT_USER + "\n"
194
+ + _migrate_script_copy_block(resource_name)
195
+ # Migrators are one-shot jobs; they should not inherit long-running
196
+ # service healthchecks (e.g. HTTP probes on localhost:3000) from base layers.
197
+ + "HEALTHCHECK NONE\n"
198
+ + "USER " + BUN_USER + "\n"
199
+ + "ENTRYPOINT [\"" + MIGRATE_SH_ABS_PATH + "\"]\n"
200
+ + "\nFROM l4_migrator_runtime AS migrator\n"
201
+ + "FROM l4_migrator_runtime AS production\n"
202
+ + "FROM l4_migrator_runtime AS development\n"
203
+ )
204
+
205
+ GLOBAL_CONFIG = {}