@supatype/cli 0.9.0 → 0.9.2

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 (619) hide show
  1. package/CHANGELOG.md +640 -68
  2. package/bin/node-version.js +28 -0
  3. package/bin/supatype.js +8 -4
  4. package/dist/app/port-holder.d.ts +33 -0
  5. package/dist/app/port-holder.d.ts.map +1 -0
  6. package/dist/app/port-holder.js +66 -0
  7. package/dist/app/port-holder.js.map +1 -0
  8. package/dist/app/proxy-dev-app.d.ts +32 -4
  9. package/dist/app/proxy-dev-app.d.ts.map +1 -1
  10. package/dist/app/proxy-dev-app.js +111 -77
  11. package/dist/app/proxy-dev-app.js.map +1 -1
  12. package/dist/app/vite-dev-args.d.ts +20 -0
  13. package/dist/app/vite-dev-args.d.ts.map +1 -0
  14. package/dist/app/vite-dev-args.js +65 -0
  15. package/dist/app/vite-dev-args.js.map +1 -0
  16. package/dist/app-config.d.ts +2 -0
  17. package/dist/app-config.d.ts.map +1 -1
  18. package/dist/app-config.js +27 -8
  19. package/dist/app-config.js.map +1 -1
  20. package/dist/augmentation-generator.d.ts +2 -0
  21. package/dist/augmentation-generator.d.ts.map +1 -1
  22. package/dist/augmentation-generator.js +7 -3
  23. package/dist/augmentation-generator.js.map +1 -1
  24. package/dist/auth-providers.d.ts +5 -4
  25. package/dist/auth-providers.d.ts.map +1 -1
  26. package/dist/auth-providers.js +3 -12
  27. package/dist/auth-providers.js.map +1 -1
  28. package/dist/binary-download-lock.d.ts.map +1 -1
  29. package/dist/binary-download-lock.js +2 -10
  30. package/dist/binary-download-lock.js.map +1 -1
  31. package/dist/build-spawn.d.ts +35 -0
  32. package/dist/build-spawn.d.ts.map +1 -0
  33. package/dist/build-spawn.js +75 -0
  34. package/dist/build-spawn.js.map +1 -0
  35. package/dist/cache-provider.d.ts +17 -2
  36. package/dist/cache-provider.d.ts.map +1 -1
  37. package/dist/cache-provider.js +28 -3
  38. package/dist/cache-provider.js.map +1 -1
  39. package/dist/cli-version-embedded.js +1 -1
  40. package/dist/cli.d.ts +7 -0
  41. package/dist/cli.d.ts.map +1 -1
  42. package/dist/cli.js +14 -1
  43. package/dist/cli.js.map +1 -1
  44. package/dist/cloud-credentials.d.ts.map +1 -1
  45. package/dist/cloud-credentials.js +3 -1
  46. package/dist/cloud-credentials.js.map +1 -1
  47. package/dist/commands/admin.d.ts.map +1 -1
  48. package/dist/commands/admin.js +11 -15
  49. package/dist/commands/admin.js.map +1 -1
  50. package/dist/commands/adopt.js +1 -1
  51. package/dist/commands/adopt.js.map +1 -1
  52. package/dist/commands/app.d.ts.map +1 -1
  53. package/dist/commands/app.js +22 -2
  54. package/dist/commands/app.js.map +1 -1
  55. package/dist/commands/build.d.ts +29 -0
  56. package/dist/commands/build.d.ts.map +1 -0
  57. package/dist/commands/build.js +69 -0
  58. package/dist/commands/build.js.map +1 -0
  59. package/dist/commands/cache.d.ts.map +1 -1
  60. package/dist/commands/cache.js +5 -0
  61. package/dist/commands/cache.js.map +1 -1
  62. package/dist/commands/db.d.ts.map +1 -1
  63. package/dist/commands/db.js +46 -23
  64. package/dist/commands/db.js.map +1 -1
  65. package/dist/commands/deploy.d.ts +14 -0
  66. package/dist/commands/deploy.d.ts.map +1 -1
  67. package/dist/commands/deploy.js +67 -52
  68. package/dist/commands/deploy.js.map +1 -1
  69. package/dist/commands/dev.d.ts +21 -4
  70. package/dist/commands/dev.d.ts.map +1 -1
  71. package/dist/commands/dev.js +244 -86
  72. package/dist/commands/dev.js.map +1 -1
  73. package/dist/commands/diff.d.ts +3 -0
  74. package/dist/commands/diff.d.ts.map +1 -1
  75. package/dist/commands/diff.js +28 -34
  76. package/dist/commands/diff.js.map +1 -1
  77. package/dist/commands/doctor.js +2 -2
  78. package/dist/commands/doctor.js.map +1 -1
  79. package/dist/commands/functions.d.ts.map +1 -1
  80. package/dist/commands/functions.js +21 -16
  81. package/dist/commands/functions.js.map +1 -1
  82. package/dist/commands/generate.d.ts.map +1 -1
  83. package/dist/commands/generate.js +3 -0
  84. package/dist/commands/generate.js.map +1 -1
  85. package/dist/commands/init.d.ts +15 -10
  86. package/dist/commands/init.d.ts.map +1 -1
  87. package/dist/commands/init.js +312 -163
  88. package/dist/commands/init.js.map +1 -1
  89. package/dist/commands/internal.d.ts.map +1 -1
  90. package/dist/commands/internal.js +27 -7
  91. package/dist/commands/internal.js.map +1 -1
  92. package/dist/commands/introspect.d.ts.map +1 -1
  93. package/dist/commands/introspect.js +3 -0
  94. package/dist/commands/introspect.js.map +1 -1
  95. package/dist/commands/keys-print.d.ts +20 -0
  96. package/dist/commands/keys-print.d.ts.map +1 -0
  97. package/dist/commands/keys-print.js +47 -0
  98. package/dist/commands/keys-print.js.map +1 -0
  99. package/dist/commands/keys.d.ts.map +1 -1
  100. package/dist/commands/keys.js +16 -12
  101. package/dist/commands/keys.js.map +1 -1
  102. package/dist/commands/link-helpers.d.ts.map +1 -1
  103. package/dist/commands/link-helpers.js +28 -6
  104. package/dist/commands/link-helpers.js.map +1 -1
  105. package/dist/commands/migrate.d.ts +5 -2
  106. package/dist/commands/migrate.d.ts.map +1 -1
  107. package/dist/commands/migrate.js +34 -36
  108. package/dist/commands/migrate.js.map +1 -1
  109. package/dist/commands/pull.d.ts.map +1 -1
  110. package/dist/commands/pull.js +6 -5
  111. package/dist/commands/pull.js.map +1 -1
  112. package/dist/commands/push.d.ts.map +1 -1
  113. package/dist/commands/push.js +30 -19
  114. package/dist/commands/push.js.map +1 -1
  115. package/dist/commands/rename.js +1 -1
  116. package/dist/commands/rename.js.map +1 -1
  117. package/dist/commands/seed.d.ts +2 -11
  118. package/dist/commands/seed.d.ts.map +1 -1
  119. package/dist/commands/seed.js +11 -38
  120. package/dist/commands/seed.js.map +1 -1
  121. package/dist/commands/self-host.d.ts +3 -3
  122. package/dist/commands/self-host.d.ts.map +1 -1
  123. package/dist/commands/self-host.js +133 -272
  124. package/dist/commands/self-host.js.map +1 -1
  125. package/dist/commands/sso.d.ts +26 -0
  126. package/dist/commands/sso.d.ts.map +1 -0
  127. package/dist/commands/sso.js +362 -0
  128. package/dist/commands/sso.js.map +1 -0
  129. package/dist/commands/status.d.ts.map +1 -1
  130. package/dist/commands/status.js +25 -8
  131. package/dist/commands/status.js.map +1 -1
  132. package/dist/commands/update.d.ts.map +1 -1
  133. package/dist/commands/update.js +156 -63
  134. package/dist/commands/update.js.map +1 -1
  135. package/dist/component-launch.d.ts.map +1 -1
  136. package/dist/component-launch.js +2 -1
  137. package/dist/component-launch.js.map +1 -1
  138. package/dist/compose-db-roles.d.ts +4 -4
  139. package/dist/compose-db-roles.d.ts.map +1 -1
  140. package/dist/compose-db-roles.js +14 -10
  141. package/dist/compose-db-roles.js.map +1 -1
  142. package/dist/compose-engine-run.d.ts +9 -2
  143. package/dist/compose-engine-run.d.ts.map +1 -1
  144. package/dist/compose-engine-run.js +30 -13
  145. package/dist/compose-engine-run.js.map +1 -1
  146. package/dist/compose-rename.d.ts.map +1 -1
  147. package/dist/compose-rename.js +5 -0
  148. package/dist/compose-rename.js.map +1 -1
  149. package/dist/compose-render-mode.d.ts +8 -3
  150. package/dist/compose-render-mode.d.ts.map +1 -1
  151. package/dist/compose-render-mode.js +13 -5
  152. package/dist/compose-render-mode.js.map +1 -1
  153. package/dist/compose-services.d.ts +18 -0
  154. package/dist/compose-services.d.ts.map +1 -1
  155. package/dist/compose-services.js +49 -23
  156. package/dist/compose-services.js.map +1 -1
  157. package/dist/config-mailer-env.d.ts +31 -0
  158. package/dist/config-mailer-env.d.ts.map +1 -0
  159. package/dist/config-mailer-env.js +45 -0
  160. package/dist/config-mailer-env.js.map +1 -0
  161. package/dist/config-version-pin.d.ts +42 -0
  162. package/dist/config-version-pin.d.ts.map +1 -0
  163. package/dist/config-version-pin.js +64 -0
  164. package/dist/config-version-pin.js.map +1 -0
  165. package/dist/config.d.ts +4 -0
  166. package/dist/config.d.ts.map +1 -1
  167. package/dist/config.js +6 -2
  168. package/dist/config.js.map +1 -1
  169. package/dist/db-rows.d.ts +3 -2
  170. package/dist/db-rows.d.ts.map +1 -1
  171. package/dist/db-rows.js +19 -4
  172. package/dist/db-rows.js.map +1 -1
  173. package/dist/dev-compose.d.ts +69 -9
  174. package/dist/dev-compose.d.ts.map +1 -1
  175. package/dist/dev-compose.js +272 -187
  176. package/dist/dev-compose.js.map +1 -1
  177. package/dist/dev-initial-push.d.ts.map +1 -1
  178. package/dist/dev-initial-push.js +6 -0
  179. package/dist/dev-initial-push.js.map +1 -1
  180. package/dist/dev-ports.d.ts +13 -6
  181. package/dist/dev-ports.d.ts.map +1 -1
  182. package/dist/dev-ports.js +124 -68
  183. package/dist/dev-ports.js.map +1 -1
  184. package/dist/dev-ready-panel.d.ts +26 -3
  185. package/dist/dev-ready-panel.d.ts.map +1 -1
  186. package/dist/dev-ready-panel.js +37 -5
  187. package/dist/dev-ready-panel.js.map +1 -1
  188. package/dist/dev-schema-watch.d.ts +8 -2
  189. package/dist/dev-schema-watch.d.ts.map +1 -1
  190. package/dist/dev-schema-watch.js +24 -13
  191. package/dist/dev-schema-watch.js.map +1 -1
  192. package/dist/dev-self-start.d.ts +16 -0
  193. package/dist/dev-self-start.d.ts.map +1 -0
  194. package/dist/dev-self-start.js +31 -0
  195. package/dist/dev-self-start.js.map +1 -0
  196. package/dist/dev-session-lock.d.ts +66 -2
  197. package/dist/dev-session-lock.d.ts.map +1 -1
  198. package/dist/dev-session-lock.js +104 -5
  199. package/dist/dev-session-lock.js.map +1 -1
  200. package/dist/dev-session.d.ts +19 -3
  201. package/dist/dev-session.d.ts.map +1 -1
  202. package/dist/dev-session.js +31 -8
  203. package/dist/dev-session.js.map +1 -1
  204. package/dist/dev-shutdown.d.ts +11 -2
  205. package/dist/dev-shutdown.d.ts.map +1 -1
  206. package/dist/dev-shutdown.js +27 -10
  207. package/dist/dev-shutdown.js.map +1 -1
  208. package/dist/diff-access.d.ts +10 -0
  209. package/dist/diff-access.d.ts.map +1 -0
  210. package/dist/diff-access.js +69 -0
  211. package/dist/diff-access.js.map +1 -0
  212. package/dist/diff-output.d.ts.map +1 -1
  213. package/dist/diff-output.js +2 -1
  214. package/dist/diff-output.js.map +1 -1
  215. package/dist/docker-exec.d.ts.map +1 -1
  216. package/dist/docker-exec.js +4 -4
  217. package/dist/docker-exec.js.map +1 -1
  218. package/dist/docker-runtime.d.ts +34 -4
  219. package/dist/docker-runtime.d.ts.map +1 -1
  220. package/dist/docker-runtime.js +155 -46
  221. package/dist/docker-runtime.js.map +1 -1
  222. package/dist/engine-answers.d.ts +2 -1
  223. package/dist/engine-answers.d.ts.map +1 -1
  224. package/dist/engine-answers.js +11 -0
  225. package/dist/engine-answers.js.map +1 -1
  226. package/dist/engine-client.d.ts +20 -0
  227. package/dist/engine-client.d.ts.map +1 -1
  228. package/dist/engine-client.js +9 -8
  229. package/dist/engine-client.js.map +1 -1
  230. package/dist/engine-columns.d.ts +26 -0
  231. package/dist/engine-columns.d.ts.map +1 -0
  232. package/dist/engine-columns.js +67 -0
  233. package/dist/engine-columns.js.map +1 -0
  234. package/dist/engine-floor.d.ts +3 -2
  235. package/dist/engine-floor.d.ts.map +1 -1
  236. package/dist/engine-floor.js +2 -2
  237. package/dist/engine-floor.js.map +1 -1
  238. package/dist/engine-push-output.d.ts +8 -1
  239. package/dist/engine-push-output.d.ts.map +1 -1
  240. package/dist/engine-push-output.js +8 -1
  241. package/dist/engine-push-output.js.map +1 -1
  242. package/dist/env-file.d.ts +23 -3
  243. package/dist/env-file.d.ts.map +1 -1
  244. package/dist/env-file.js +74 -40
  245. package/dist/env-file.js.map +1 -1
  246. package/dist/env-lines.d.ts +3 -2
  247. package/dist/env-lines.d.ts.map +1 -1
  248. package/dist/env-lines.js +5 -2
  249. package/dist/env-lines.js.map +1 -1
  250. package/dist/env-value.d.ts +15 -0
  251. package/dist/env-value.d.ts.map +1 -0
  252. package/dist/env-value.js +34 -0
  253. package/dist/env-value.js.map +1 -0
  254. package/dist/error-message.d.ts +20 -0
  255. package/dist/error-message.d.ts.map +1 -1
  256. package/dist/error-message.js +42 -0
  257. package/dist/error-message.js.map +1 -1
  258. package/dist/frontend-env.d.ts +13 -4
  259. package/dist/frontend-env.d.ts.map +1 -1
  260. package/dist/frontend-env.js +25 -5
  261. package/dist/frontend-env.js.map +1 -1
  262. package/dist/frontend-values-linked.d.ts +22 -0
  263. package/dist/frontend-values-linked.d.ts.map +1 -0
  264. package/dist/frontend-values-linked.js +143 -0
  265. package/dist/frontend-values-linked.js.map +1 -0
  266. package/dist/frontend-values.d.ts +90 -0
  267. package/dist/frontend-values.d.ts.map +1 -0
  268. package/dist/frontend-values.js +208 -0
  269. package/dist/frontend-values.js.map +1 -0
  270. package/dist/functions-deno-types.d.ts.map +1 -1
  271. package/dist/functions-deno-types.js +5 -5
  272. package/dist/functions-deno-types.js.map +1 -1
  273. package/dist/functions-env-local.d.ts +13 -0
  274. package/dist/functions-env-local.d.ts.map +1 -0
  275. package/dist/functions-env-local.js +20 -0
  276. package/dist/functions-env-local.js.map +1 -0
  277. package/dist/functions-worker-files.d.ts.map +1 -1
  278. package/dist/functions-worker-files.js +2 -13
  279. package/dist/functions-worker-files.js.map +1 -1
  280. package/dist/generated/release-images.d.ts +6 -6
  281. package/dist/generated/release-images.js +3 -3
  282. package/dist/generated/release-images.js.map +1 -1
  283. package/dist/generated/typescript-libs.d.ts +4 -0
  284. package/dist/generated/typescript-libs.d.ts.map +1 -0
  285. package/dist/generated/typescript-libs.js +64 -0
  286. package/dist/generated/typescript-libs.js.map +1 -0
  287. package/dist/gitignore.d.ts +29 -2
  288. package/dist/gitignore.d.ts.map +1 -1
  289. package/dist/gitignore.js +86 -21
  290. package/dist/gitignore.js.map +1 -1
  291. package/dist/hooks-generator.d.ts.map +1 -1
  292. package/dist/hooks-generator.js +4 -2
  293. package/dist/hooks-generator.js.map +1 -1
  294. package/dist/host-database.d.ts +16 -12
  295. package/dist/host-database.d.ts.map +1 -1
  296. package/dist/host-database.js +28 -17
  297. package/dist/host-database.js.map +1 -1
  298. package/dist/init-answers.d.ts +18 -0
  299. package/dist/init-answers.d.ts.map +1 -0
  300. package/dist/init-answers.js +46 -0
  301. package/dist/init-answers.js.map +1 -0
  302. package/dist/init-dependency-versions.d.ts +2 -3
  303. package/dist/init-dependency-versions.d.ts.map +1 -1
  304. package/dist/init-dependency-versions.js +12 -9
  305. package/dist/init-dependency-versions.js.map +1 -1
  306. package/dist/init-example.d.ts.map +1 -1
  307. package/dist/init-example.js +13 -1
  308. package/dist/init-example.js.map +1 -1
  309. package/dist/init-expo-runtime-env.d.ts +25 -0
  310. package/dist/init-expo-runtime-env.d.ts.map +1 -0
  311. package/dist/init-expo-runtime-env.js +112 -0
  312. package/dist/init-expo-runtime-env.js.map +1 -0
  313. package/dist/init-next-runtime-env.d.ts +43 -0
  314. package/dist/init-next-runtime-env.d.ts.map +1 -0
  315. package/dist/init-next-runtime-env.js +261 -0
  316. package/dist/init-next-runtime-env.js.map +1 -0
  317. package/dist/init-package-json.d.ts +11 -3
  318. package/dist/init-package-json.d.ts.map +1 -1
  319. package/dist/init-package-json.js +20 -13
  320. package/dist/init-package-json.js.map +1 -1
  321. package/dist/init-port-registry.d.ts +19 -0
  322. package/dist/init-port-registry.d.ts.map +1 -0
  323. package/dist/init-port-registry.js +57 -0
  324. package/dist/init-port-registry.js.map +1 -0
  325. package/dist/init-project-detect.d.ts +20 -0
  326. package/dist/init-project-detect.d.ts.map +1 -1
  327. package/dist/init-project-detect.js +41 -8
  328. package/dist/init-project-detect.js.map +1 -1
  329. package/dist/init-vite-node.d.ts +21 -0
  330. package/dist/init-vite-node.d.ts.map +1 -0
  331. package/dist/init-vite-node.js +75 -0
  332. package/dist/init-vite-node.js.map +1 -0
  333. package/dist/jsx-first-child.d.ts +18 -0
  334. package/dist/jsx-first-child.d.ts.map +1 -0
  335. package/dist/jsx-first-child.js +53 -0
  336. package/dist/jsx-first-child.js.map +1 -0
  337. package/dist/jwt.d.ts +5 -0
  338. package/dist/jwt.d.ts.map +1 -1
  339. package/dist/jwt.js +16 -0
  340. package/dist/jwt.js.map +1 -1
  341. package/dist/keyspace-password-file.d.ts +46 -0
  342. package/dist/keyspace-password-file.d.ts.map +1 -0
  343. package/dist/keyspace-password-file.js +128 -0
  344. package/dist/keyspace-password-file.js.map +1 -0
  345. package/dist/kong-config.d.ts +1 -0
  346. package/dist/kong-config.d.ts.map +1 -1
  347. package/dist/kong-config.js +64 -20
  348. package/dist/kong-config.js.map +1 -1
  349. package/dist/local-gateway.d.ts +11 -3
  350. package/dist/local-gateway.d.ts.map +1 -1
  351. package/dist/local-gateway.js +16 -7
  352. package/dist/local-gateway.js.map +1 -1
  353. package/dist/local-secrets.d.ts +32 -0
  354. package/dist/local-secrets.d.ts.map +1 -1
  355. package/dist/local-secrets.js +49 -0
  356. package/dist/local-secrets.js.map +1 -1
  357. package/dist/local-stack-guard.d.ts +37 -0
  358. package/dist/local-stack-guard.d.ts.map +1 -0
  359. package/dist/local-stack-guard.js +85 -0
  360. package/dist/local-stack-guard.js.map +1 -0
  361. package/dist/local-stack.d.ts.map +1 -1
  362. package/dist/local-stack.js +7 -6
  363. package/dist/local-stack.js.map +1 -1
  364. package/dist/local-storage.d.ts +3 -5
  365. package/dist/local-storage.d.ts.map +1 -1
  366. package/dist/local-storage.js +10 -10
  367. package/dist/local-storage.js.map +1 -1
  368. package/dist/mailer-autoconfirm.d.ts +29 -24
  369. package/dist/mailer-autoconfirm.d.ts.map +1 -1
  370. package/dist/mailer-autoconfirm.js +47 -43
  371. package/dist/mailer-autoconfirm.js.map +1 -1
  372. package/dist/mailer-env.d.ts +4 -0
  373. package/dist/mailer-env.d.ts.map +1 -1
  374. package/dist/mailer-env.js +12 -1
  375. package/dist/mailer-env.js.map +1 -1
  376. package/dist/model-hooks.d.ts +4 -4
  377. package/dist/model-hooks.d.ts.map +1 -1
  378. package/dist/model-hooks.js +13 -7
  379. package/dist/model-hooks.js.map +1 -1
  380. package/dist/native-dev-env.d.ts +25 -2
  381. package/dist/native-dev-env.d.ts.map +1 -1
  382. package/dist/native-dev-env.js +39 -4
  383. package/dist/native-dev-env.js.map +1 -1
  384. package/dist/native-keyspace.d.ts +21 -6
  385. package/dist/native-keyspace.d.ts.map +1 -1
  386. package/dist/native-keyspace.js +48 -14
  387. package/dist/native-keyspace.js.map +1 -1
  388. package/dist/native-leftover-postgres.d.ts +23 -0
  389. package/dist/native-leftover-postgres.d.ts.map +1 -0
  390. package/dist/native-leftover-postgres.js +55 -0
  391. package/dist/native-leftover-postgres.js.map +1 -0
  392. package/dist/native-leftover-services.d.ts +17 -0
  393. package/dist/native-leftover-services.d.ts.map +1 -0
  394. package/dist/native-leftover-services.js +93 -0
  395. package/dist/native-leftover-services.js.map +1 -0
  396. package/dist/native-pg-auth.d.ts.map +1 -1
  397. package/dist/native-pg-auth.js +2 -1
  398. package/dist/native-pg-auth.js.map +1 -1
  399. package/dist/native-port-lock.d.ts +37 -0
  400. package/dist/native-port-lock.d.ts.map +1 -0
  401. package/dist/native-port-lock.js +78 -0
  402. package/dist/native-port-lock.js.map +1 -0
  403. package/dist/native-realtime.d.ts +6 -3
  404. package/dist/native-realtime.d.ts.map +1 -1
  405. package/dist/native-realtime.js +65 -24
  406. package/dist/native-realtime.js.map +1 -1
  407. package/dist/native-roles-sql.d.ts.map +1 -1
  408. package/dist/native-roles-sql.js +2 -1
  409. package/dist/native-roles-sql.js.map +1 -1
  410. package/dist/native-storage-import.d.ts.map +1 -1
  411. package/dist/native-storage-import.js +6 -5
  412. package/dist/native-storage-import.js.map +1 -1
  413. package/dist/native-storage.d.ts +42 -7
  414. package/dist/native-storage.d.ts.map +1 -1
  415. package/dist/native-storage.js +196 -50
  416. package/dist/native-storage.js.map +1 -1
  417. package/dist/node-executable.d.ts +6 -0
  418. package/dist/node-executable.d.ts.map +1 -0
  419. package/dist/node-executable.js +43 -0
  420. package/dist/node-executable.js.map +1 -0
  421. package/dist/parent-watch.d.ts +8 -3
  422. package/dist/parent-watch.d.ts.map +1 -1
  423. package/dist/parent-watch.js +12 -11
  424. package/dist/parent-watch.js.map +1 -1
  425. package/dist/postgres-ctl.d.ts +33 -5
  426. package/dist/postgres-ctl.d.ts.map +1 -1
  427. package/dist/postgres-ctl.js +60 -16
  428. package/dist/postgres-ctl.js.map +1 -1
  429. package/dist/postgres-image.d.ts +16 -0
  430. package/dist/postgres-image.d.ts.map +1 -1
  431. package/dist/postgres-image.js +34 -11
  432. package/dist/postgres-image.js.map +1 -1
  433. package/dist/process-info.d.ts +14 -0
  434. package/dist/process-info.d.ts.map +1 -0
  435. package/dist/process-info.js +41 -0
  436. package/dist/process-info.js.map +1 -0
  437. package/dist/process-manager.d.ts +110 -9
  438. package/dist/process-manager.d.ts.map +1 -1
  439. package/dist/process-manager.js +242 -104
  440. package/dist/process-manager.js.map +1 -1
  441. package/dist/process-tree.d.ts +48 -0
  442. package/dist/process-tree.d.ts.map +1 -0
  443. package/dist/process-tree.js +141 -0
  444. package/dist/process-tree.js.map +1 -0
  445. package/dist/project-config.d.ts +60 -4
  446. package/dist/project-config.d.ts.map +1 -1
  447. package/dist/project-config.js +23 -1
  448. package/dist/project-config.js.map +1 -1
  449. package/dist/push-audit.d.ts +4 -1
  450. package/dist/push-audit.d.ts.map +1 -1
  451. package/dist/push-audit.js +33 -4
  452. package/dist/push-audit.js.map +1 -1
  453. package/dist/recorded-field-masking-tier.d.ts +2 -2
  454. package/dist/recorded-field-masking-tier.d.ts.map +1 -1
  455. package/dist/recorded-field-masking-tier.js +6 -6
  456. package/dist/recorded-field-masking-tier.js.map +1 -1
  457. package/dist/rename-journal.d.ts +1 -1
  458. package/dist/rename-journal.d.ts.map +1 -1
  459. package/dist/required-host-components.d.ts.map +1 -1
  460. package/dist/required-host-components.js +3 -5
  461. package/dist/required-host-components.js.map +1 -1
  462. package/dist/resolve-api-url.d.ts +2 -0
  463. package/dist/resolve-api-url.d.ts.map +1 -1
  464. package/dist/resolve-api-url.js +5 -1
  465. package/dist/resolve-api-url.js.map +1 -1
  466. package/dist/resolve-target.d.ts +16 -1
  467. package/dist/resolve-target.d.ts.map +1 -1
  468. package/dist/resolve-target.js +20 -11
  469. package/dist/resolve-target.js.map +1 -1
  470. package/dist/route-manifest.d.ts +24 -0
  471. package/dist/route-manifest.d.ts.map +1 -1
  472. package/dist/route-manifest.js +60 -2
  473. package/dist/route-manifest.js.map +1 -1
  474. package/dist/run-captured.d.ts +33 -0
  475. package/dist/run-captured.d.ts.map +1 -0
  476. package/dist/run-captured.js +36 -0
  477. package/dist/run-captured.js.map +1 -0
  478. package/dist/run-until-stopped.d.ts +3 -0
  479. package/dist/run-until-stopped.d.ts.map +1 -1
  480. package/dist/run-until-stopped.js +25 -11
  481. package/dist/run-until-stopped.js.map +1 -1
  482. package/dist/runtime-routes.d.ts +5 -0
  483. package/dist/runtime-routes.d.ts.map +1 -1
  484. package/dist/runtime-routes.js +5 -1
  485. package/dist/runtime-routes.js.map +1 -1
  486. package/dist/saml-config.d.ts +53 -0
  487. package/dist/saml-config.d.ts.map +1 -0
  488. package/dist/saml-config.js +177 -0
  489. package/dist/saml-config.js.map +1 -0
  490. package/dist/saml-key-rotation.d.ts +5 -0
  491. package/dist/saml-key-rotation.d.ts.map +1 -0
  492. package/dist/saml-key-rotation.js +26 -0
  493. package/dist/saml-key-rotation.js.map +1 -0
  494. package/dist/saml-sp-certificate.d.ts +15 -0
  495. package/dist/saml-sp-certificate.d.ts.map +1 -0
  496. package/dist/saml-sp-certificate.js +34 -0
  497. package/dist/saml-sp-certificate.js.map +1 -0
  498. package/dist/schema-reset.d.ts +41 -0
  499. package/dist/schema-reset.d.ts.map +1 -0
  500. package/dist/schema-reset.js +98 -0
  501. package/dist/schema-reset.js.map +1 -0
  502. package/dist/secret-sql.d.ts +13 -0
  503. package/dist/secret-sql.d.ts.map +1 -0
  504. package/dist/secret-sql.js +13 -0
  505. package/dist/secret-sql.js.map +1 -0
  506. package/dist/seed-child.d.ts +25 -0
  507. package/dist/seed-child.d.ts.map +1 -0
  508. package/dist/seed-child.js +61 -0
  509. package/dist/seed-child.js.map +1 -0
  510. package/dist/seed-ir.d.ts +8 -1
  511. package/dist/seed-ir.d.ts.map +1 -1
  512. package/dist/seed-ir.js +92 -6
  513. package/dist/seed-ir.js.map +1 -1
  514. package/dist/seed-runner.d.ts +3 -5
  515. package/dist/seed-runner.d.ts.map +1 -1
  516. package/dist/seed-runner.js +20 -42
  517. package/dist/seed-runner.js.map +1 -1
  518. package/dist/seed.d.ts +15 -2
  519. package/dist/seed.d.ts.map +1 -1
  520. package/dist/self-host-compose.d.ts +24 -2
  521. package/dist/self-host-compose.d.ts.map +1 -1
  522. package/dist/self-host-compose.js +261 -63
  523. package/dist/self-host-compose.js.map +1 -1
  524. package/dist/serial-runs.d.ts +7 -0
  525. package/dist/serial-runs.d.ts.map +1 -0
  526. package/dist/serial-runs.js +29 -0
  527. package/dist/serial-runs.js.map +1 -0
  528. package/dist/sso-admin.d.ts +114 -0
  529. package/dist/sso-admin.d.ts.map +1 -0
  530. package/dist/sso-admin.js +256 -0
  531. package/dist/sso-admin.js.map +1 -0
  532. package/dist/stack-engine.d.ts +28 -0
  533. package/dist/stack-engine.d.ts.map +1 -0
  534. package/dist/stack-engine.js +59 -0
  535. package/dist/stack-engine.js.map +1 -0
  536. package/dist/stack-exit-watch.d.ts +52 -0
  537. package/dist/stack-exit-watch.d.ts.map +1 -0
  538. package/dist/stack-exit-watch.js +98 -0
  539. package/dist/stack-exit-watch.js.map +1 -0
  540. package/dist/stack-folder.d.ts +28 -0
  541. package/dist/stack-folder.d.ts.map +1 -0
  542. package/dist/stack-folder.js +123 -0
  543. package/dist/stack-folder.js.map +1 -0
  544. package/dist/stack-setting-warnings.d.ts +9 -0
  545. package/dist/stack-setting-warnings.d.ts.map +1 -0
  546. package/dist/stack-setting-warnings.js +19 -0
  547. package/dist/stack-setting-warnings.js.map +1 -0
  548. package/dist/storage-provision.d.ts +12 -2
  549. package/dist/storage-provision.d.ts.map +1 -1
  550. package/dist/storage-provision.js +36 -11
  551. package/dist/storage-provision.js.map +1 -1
  552. package/dist/studio-dev-server.d.ts.map +1 -1
  553. package/dist/studio-dev-server.js +2 -1
  554. package/dist/studio-dev-server.js.map +1 -1
  555. package/dist/target-client.d.ts +12 -2
  556. package/dist/target-client.d.ts.map +1 -1
  557. package/dist/target-client.js +14 -1
  558. package/dist/target-client.js.map +1 -1
  559. package/dist/tsx-runner.d.ts +5 -0
  560. package/dist/tsx-runner.d.ts.map +1 -1
  561. package/dist/tsx-runner.js +16 -16
  562. package/dist/tsx-runner.js.map +1 -1
  563. package/dist/type-extractor.d.ts.map +1 -1
  564. package/dist/type-extractor.js +27 -3
  565. package/dist/type-extractor.js.map +1 -1
  566. package/dist/type-generation.d.ts +1 -1
  567. package/dist/type-generation.d.ts.map +1 -1
  568. package/dist/type-generation.js +2 -4
  569. package/dist/type-generation.js.map +1 -1
  570. package/dist/type-resolver.d.ts.map +1 -1
  571. package/dist/type-resolver.js +31 -12
  572. package/dist/type-resolver.js.map +1 -1
  573. package/dist/ui/clack-api.d.ts.map +1 -1
  574. package/dist/ui/clack-api.js +45 -23
  575. package/dist/ui/clack-api.js.map +1 -1
  576. package/dist/ui/components/LineInput.d.ts +26 -0
  577. package/dist/ui/components/LineInput.d.ts.map +1 -0
  578. package/dist/ui/components/LineInput.js +60 -0
  579. package/dist/ui/components/LineInput.js.map +1 -0
  580. package/dist/ui/dev/DevReadyPanelView.js +1 -1
  581. package/dist/ui/dev/DevReadyPanelView.js.map +1 -1
  582. package/dist/ui/flows/FlowApp.d.ts +3 -1
  583. package/dist/ui/flows/FlowApp.d.ts.map +1 -1
  584. package/dist/ui/flows/FlowApp.js +14 -5
  585. package/dist/ui/flows/FlowApp.js.map +1 -1
  586. package/dist/ui/flows/prompt-fields.d.ts +3 -1
  587. package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
  588. package/dist/ui/flows/prompt-fields.js +10 -5
  589. package/dist/ui/flows/prompt-fields.js.map +1 -1
  590. package/dist/ui/flows/types.d.ts +5 -1
  591. package/dist/ui/flows/types.d.ts.map +1 -1
  592. package/dist/ui/runtime/command-chrome.d.ts.map +1 -1
  593. package/dist/ui/runtime/command-chrome.js +2 -0
  594. package/dist/ui/runtime/command-chrome.js.map +1 -1
  595. package/dist/ui/runtime/flow-transcript.d.ts +17 -0
  596. package/dist/ui/runtime/flow-transcript.d.ts.map +1 -0
  597. package/dist/ui/runtime/flow-transcript.js +38 -0
  598. package/dist/ui/runtime/flow-transcript.js.map +1 -0
  599. package/dist/ui/runtime/run-clack-flow.d.ts +7 -0
  600. package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -1
  601. package/dist/ui/runtime/run-clack-flow.js +131 -17
  602. package/dist/ui/runtime/run-clack-flow.js.map +1 -1
  603. package/dist/valkey-sidecar.d.ts +24 -11
  604. package/dist/valkey-sidecar.d.ts.map +1 -1
  605. package/dist/valkey-sidecar.js +45 -25
  606. package/dist/valkey-sidecar.js.map +1 -1
  607. package/dist/windows-processes.d.ts +7 -0
  608. package/dist/windows-processes.d.ts.map +1 -0
  609. package/dist/windows-processes.js +31 -0
  610. package/dist/windows-processes.js.map +1 -0
  611. package/dist/write-if-changed.d.ts +12 -0
  612. package/dist/write-if-changed.d.ts.map +1 -0
  613. package/dist/write-if-changed.js +32 -0
  614. package/dist/write-if-changed.js.map +1 -0
  615. package/package.json +7 -6
  616. package/dist/systemd.d.ts +0 -26
  617. package/dist/systemd.d.ts.map +0 -1
  618. package/dist/systemd.js +0 -117
  619. package/dist/systemd.js.map +0 -1
@@ -4,18 +4,18 @@
4
4
  import { setTimeout as sleep } from "node:timers/promises";
5
5
  import { projectOutputPaths, writeAstDerivedOutputs, writeSeedBuilder } from "./type-generation.js";
6
6
  import { errorMessage } from "./error-message.js";
7
- import { warn } from "./ui/messages.js";
7
+ import { printRoleAccess } from "./diff-access.js";
8
+ import { postApplyFailed } from "./post-apply.js";
8
9
  import { FRONTEND_URL_KEYS, frontendEnv, writeFrontendEnv } from "./frontend-env.js";
9
10
  import { withPublishing } from "./model-versioning.js";
10
11
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
11
- import { homedir } from "node:os";
12
12
  import { dirname, join } from "node:path";
13
13
  import { askDocker, askDockerSync, DOCKER_EXEC_TIMEOUT_MS, DOCKER_QUERY_TIMEOUT_MS } from "./docker-exec.js";
14
- import { startProxyDevApp, resolveProxyDevScript } from "./app/proxy-dev-app.js";
14
+ import { appPanelLinks, startProxyDevApp } from "./app/proxy-dev-app.js";
15
15
  import { loadSchemaAst, projectNameInFile } from "./config.js";
16
16
  import { withComposeSchemaPushLock } from "./schema-push-lock.js";
17
17
  import { recordDatabaseTier, sameApiSurface } from "./recorded-field-masking-tier.js";
18
- import { connectionString, pgSchema, projectRootFromConfig, resolveRuntimeProvider, schemaPathFromProject, selfHostTlsEnabled, usesExternalDatabase, } from "./project-config.js";
18
+ import { connectionString, nativeStateRoot, pgSchema, projectRootFromConfig, resolveRuntimeProvider, schemaPathFromProject, selfHostTlsEnabled, usesExternalDatabase, } from "./project-config.js";
19
19
  import { rowCacheChangeNote } from "./model-cache.js";
20
20
  import { writeAppliedAstArtifacts } from "./applied-ast-artifacts.js";
21
21
  import { anonKeyEnvUpdates } from "./commands/keys.js";
@@ -25,8 +25,9 @@ import { astRelatesToAuthUsers } from "./byo-preflight.js";
25
25
  import { ensureDevDbPort, ensureKongPort } from "./dev-ports.js";
26
26
  import { applyForThisRun, splitShellPortUpdates } from "./shell-ports.js";
27
27
  import { handleComposeProjectRename } from "./compose-rename.js";
28
- import { devSessionLockFor, recoverStaleDevSession, writeDevSessionLock } from "./dev-session-lock.js";
29
- import { endDevSession, showDevStep, startDevSession } from "./dev-session.js";
28
+ import { devSessionLockFor, enterLocalStack, recoverStaleDevSession, writeDevSessionLock } from "./dev-session-lock.js";
29
+ import { recordStackFolder, refuseOtherFoldersStack } from "./stack-folder.js";
30
+ import { endDevSession, showDevStep, startDevSession, withSavePushOutput } from "./dev-session.js";
30
31
  import { ensureDevApiConfig } from "./ensure-dev-api-config.js";
31
32
  import { cacheSeedingNotes } from "./api-config-cache.js";
32
33
  import { restartComposeFunctionsWorker, watchFunctionSources } from "./dev-functions-watch.js";
@@ -41,6 +42,7 @@ import { auditFlags, auditWhenSupported } from "./push-audit.js";
41
42
  import { consentRefusal, reportDevPushFailure } from "./push-refusal.js";
42
43
  import { COMPOSE_PINNED_IMAGE_ENV_KEYS, composeDockerImageEnv, composeProjectName, exitComposeFailed, noteUnpinnedImages, publishesDbToHost, runDockerCompose, runDockerComposeQuietly, settleComposeRuns, schemaEngineImageForPush, writeSelfHostCompose, composeFieldMaskingTier, selfHostComposePaths, } from "./self-host-compose.js";
43
44
  import { composeServiceIsRunning } from "./compose-kong.js";
45
+ import { requireStackDatabase } from "./local-stack-guard.js";
44
46
  import { hasEngineOverride } from "./binary-cache.js";
45
47
  import { STUDIO_DEV_PORT, startStudioViteDevServer } from "./studio-dev-server.js";
46
48
  import { ensureLocalServerDockerImage, usesLocalServerImage, LOCAL_SERVER_DOCKER_IMAGE, } from "./compose-local-server-image.js";
@@ -48,14 +50,14 @@ import { ensureEngine, enginePush, engineRequest } from "./engine-client.js";
48
50
  import { isAdoptOutcome, isAnyAnswer, isDiffResult, isEnginePushResult, isGenerateAnswer, } from "./engine-answers.js";
49
51
  import { writeSchemaSourcePushArtifacts } from "./schema-sources.js";
50
52
  import { readEnvFile, readEnvValue, upsertEnvFile } from "./env-file.js";
51
- import { warnProjectAuthProviderSecrets } from "./auth-providers.js";
53
+ import { warnMissingStackSettings } from "./stack-setting-warnings.js";
52
54
  import { devDatabaseIdentity, devDatabaseUrl, seedMissingDatabaseIdentity, seedMissingLocalSecrets, } from "./local-secrets.js";
53
55
  import { writeLocalEnvironment } from "./link.js";
54
56
  import { registerDevShutdown, waitForDevShutdown } from "./dev-shutdown.js";
55
57
  import { filterComposeNoise, parseEngineJsonOutput, parseEnginePushOutput, reportAppliedPush, } from "./engine-push-output.js";
56
58
  import { withAdminRoles } from "./studio-admin-roles.js";
57
59
  import { restoreSystemRelationTargets } from "./restore-system-relation-targets.js";
58
- import { provisionBucketsFromAst, unprovisionedBuckets } from "./storage-provision.js";
60
+ import { provisionBucketsFromAst, unprovisionedBuckets, warnBucketsLeft } from "./storage-provision.js";
59
61
  import { ensureFirstAdminUserForProject } from "./commands/admin.js";
60
62
  import { demoDataHint, publishDevReady } from "./dev-ready-panel.js";
61
63
  import { pushInitialSchema, settleInitialPush } from "./dev-initial-push.js";
@@ -65,15 +67,16 @@ import { adoptKeysNeed, assertSupported, engineCapabilities, identityColumnsNeed
65
67
  import { devPushConsentingToDrift } from "./drift-consent.js";
66
68
  import { capabilitiesCache, rememberCapabilitiesSync } from "@supatype/shared";
67
69
  import { waitForDatabaseAfterUp } from "./dev-db-ready.js";
68
- import { DERIVED_DSN_SOURCE, hostComposeDbUrl, requireRunningStack, resolveHostDatabaseUrl, stackHostDbUrl, } from "./host-database.js";
70
+ import { DERIVED_DSN_SOURCE, hostComposeDbUrl, NoStackRunning, requireRunningStack, resolveHostDatabaseUrl, stackHostDbUrl, } from "./host-database.js";
69
71
  import { studioUrlAt } from "./local-stack.js";
70
72
  import { grantAuthSchemaAccess, privatizeTableDefaults, reconcileAuthenticatorPassword, reconcileSqlEditorPassword, } from "./compose-db-roles.js";
71
- import { spawnComposeEngine } from "./compose-engine-run.js";
73
+ import { spawnComposeEngine, spawnComposeEngineSync } from "./compose-engine-run.js";
72
74
  import { waitForRestReady } from "./rest-ready.js";
73
- import { claimDevRenderMode, composeRenderMode, composeRenderOptions } from "./compose-render-mode.js";
74
- import { devMailerAutoconfirmUpdate, MAILER_AUTOCONFIRM_ENV } from "./mailer-autoconfirm.js";
75
- import { mailerProviderEnv } from "./mailer-env.js";
75
+ import { claimDevRenderMode, composeRenderMode, composeRenderOptions, runningStackMode } from "./compose-render-mode.js";
76
+ import { configMailerEnv } from "./config-mailer-env.js";
77
+ import { retireCliMailerAutoconfirm } from "./mailer-autoconfirm.js";
76
78
  import { fetchWithin } from "./fetch-within.js";
79
+ import { composeStackWatch, exitedServiceFailure } from "./stack-exit-watch.js";
77
80
  import { assertEngineVersionSupported, engineImageVersion } from "./engine-floor.js";
78
81
  /**
79
82
  * The image pins config asks for, once the engine's is known not to be older than this CLI needs.
@@ -116,10 +119,14 @@ function projectDatabaseUrl(cwd, config, inNetwork = false) {
116
119
  return inNetwork ? composeDbUrl(cwd) : stackHostDbUrl(cwd, config.project.name);
117
120
  }
118
121
  /**
119
- * When `provider: docker` and `overrides.engine` is set, ensure Postgres is published
120
- * on the host (SUPATYPE_DEV_DB_PORT) so the local engine binary can connect.
122
+ * When `provider: docker` and `overrides.engine` is set: the stack's Postgres, which the local
123
+ * engine binary reaches on the host port the compose file publishes. Every layout publishes `db`
124
+ * ({@link publishesDbToHost}), dev on SUPATYPE_DEV_DB_PORT and standalone on SUPATYPE_DB_PORT, so
125
+ * on a running stack it is already there. Nothing is started (issue 46): this ran `up -d db`, and
126
+ * on a dev stack moved the dev port first, under a database that was already up. A stack that is
127
+ * not running, or whose `db` container is not, is refused instead.
121
128
  */
122
- export async function ensureDockerDbPublishedForHostEngine(cwd, config, brand) {
129
+ export function ensureDockerDbPublishedForHostEngine(cwd, config, command) {
123
130
  if (resolveRuntimeProvider(config) !== "docker") {
124
131
  throw new Error("ensureDockerDbPublishedForHostEngine requires provider: docker");
125
132
  }
@@ -127,15 +134,9 @@ export async function ensureDockerDbPublishedForHostEngine(cwd, config, brand) {
127
134
  throw new Error("This project uses an external database, so there is no Docker Postgres to publish. " +
128
135
  "Point DATABASE_URL at it, or pass --connection.");
129
136
  }
130
- const project = composeProjectName(config.project.name);
131
- // A standalone stack already publishes its database (SUPATYPE_DB_PORT), and its .env is the
132
- // operator's: only a dev stack gets the dev port and the dev values (SH1). With no stack running
133
- // the URL the engine is handed cannot be derived, so refuse before starting anything (M1b).
134
- const mode = requireRunningStack(cwd, config.project.name);
135
- if (mode === "dev")
136
- await prepareDevComposeEnv(cwd, config, project, await resolveKongPort(cwd, project));
137
- const paths = writeSelfHostCompose(cwd, config, { devLocal: mode === "dev" });
138
- await startComposeDatabase(config, paths, cwd, project, brand);
137
+ // With no stack running the URL the engine is handed cannot be derived (M1b).
138
+ requireRunningStack(cwd, config.project.name);
139
+ requireStackDatabase(cwd, config, command);
139
140
  }
140
141
  /**
141
142
  * True when CLI should publish local Compose Postgres for the host-side engine
@@ -161,10 +162,10 @@ export async function resolveHostEngineDatabaseUrl(cwd, config, explicit) {
161
162
  // The URL comes from the one resolver every host-side command uses. It is resolved first so a
162
163
  // derived URL with no stack running refuses before anything starts (M1b), and a DATABASE_URL
163
164
  // someone set is used without one. Then, when it is this project's local docker Postgres, the
164
- // database is published so the URL reaches something.
165
+ // stack's database is checked to be running, which is what the URL reaches.
165
166
  const resolved = resolveHostDatabaseUrl(cwd, config, { connection: explicit, allowDerived: true });
166
167
  if (resolved.source === DERIVED_DSN_SOURCE && usesLocalDockerEngineDb(config, explicit)) {
167
- await ensureDockerDbPublishedForHostEngine(cwd, config);
168
+ ensureDockerDbPublishedForHostEngine(cwd, config);
168
169
  }
169
170
  return resolved.dsn;
170
171
  }
@@ -182,8 +183,8 @@ export async function projectComposeEngine(cwd, config) {
182
183
  return undefined;
183
184
  if (config.connection?.trim())
184
185
  return undefined;
186
+ const project = enterLocalStack(cwd, config.project.name);
185
187
  const paths = writeSelfHostCompose(cwd, config, composeRenderOptions(cwd, config.project.name));
186
- const project = composeProjectName(config.project.name);
187
188
  const engineImage = await schemaEngineImageForPush(config, cwd);
188
189
  return {
189
190
  target: { cwd, project, composePath: paths.composePath, engineImage },
@@ -219,9 +220,14 @@ async function startComposeDatabase(config, paths, cwd, project, brand, timeoutM
219
220
  }
220
221
  await waitComposeHealthy(paths, cwd, timeoutMs, project);
221
222
  }
223
+ /**
224
+ * Write dev's values into `.env`, and return those held for this run only (DR9): built from a port
225
+ * only the shell gave, and set in this process's environment instead. The dev session records them.
226
+ */
222
227
  export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort) {
223
228
  const apiUrl = `http://localhost:${kongPort}`;
224
229
  const imagePins = checkedImagePins(config);
230
+ const mailer = configMailerEnv(config);
225
231
  // `POSTGRES_PASSWORD` and `JWT_SECRET` are deliberately absent.
226
232
  //
227
233
  // They used to be pinned here to published constants on every `dev` run, against the same
@@ -247,12 +253,10 @@ export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPo
247
253
  SUPATYPE_KONG_PORT: String(kongPort),
248
254
  API_EXTERNAL_URL: apiUrl,
249
255
  SITE_URL: apiUrl,
250
- // From auth.email.enableConfirmations, unless the developer set their own in .env.
251
- ...devMailerAutoconfirmUpdate(cwd, config),
252
- // email.provider and its settings, which the compose file passes to the server. The compose
253
- // path used to carry none of them, so a project that asked for smtp, Resend or SES got the auth
254
- // service's noop client and no message at all.
255
- ...mailerProviderEnv(config.email),
256
+ // email.provider and its settings, which the compose file passes to the server. The compose path
257
+ // used to carry none of them, so a project that asked for smtp, Resend or SES got the noop
258
+ // mailer. Email confirmation is not written here: the compose file falls back to the config.
259
+ ...mailer.updates,
256
260
  ...imagePins,
257
261
  };
258
262
  // Never for an external database: this URL describes the `db` container, which that project does
@@ -284,16 +288,16 @@ export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPo
284
288
  applyForThisRun(runOnly);
285
289
  const { urlsKept, rest } = takeFrontendUrls(persist);
286
290
  upsertEnvFile(cwd, rest, {
287
- removeManaged: removeImageKeys,
288
- managed: [...managedImageKeys, MAILER_AUTOCONFIRM_ENV],
291
+ removeManaged: [...removeImageKeys, ...mailer.removeManaged],
292
+ managed: [...managedImageKeys, ...mailer.managed],
289
293
  remove: [...retiredKeys, ...staleLocalServerImage(dotEnv["SUPATYPE_SERVER_IMAGE"], wantsLocalServer, imagePins)],
290
294
  });
291
295
  // The front end's copies go where a development build reads them, not .env, which a production
292
296
  // build reads (frontend-env.ts). The URL only when it is the project's port, not the shell's.
293
297
  writeFrontendEnv(cwd, { anonKey, ...(urlsKept && { apiUrl }) }, { local: true });
294
- if (devDbPort !== undefined && !usesExternalDatabase(config)) {
295
- writeDevStackDatabaseUrl(cwd, devDbPort, runOnly.SUPATYPE_DEV_DB_PORT !== undefined);
296
- }
298
+ if (devDbPort === undefined || usesExternalDatabase(config))
299
+ return runOnly;
300
+ return { ...runOnly, ...writeDevStackDatabaseUrl(cwd, devDbPort, runOnly.SUPATYPE_DEV_DB_PORT !== undefined) };
297
301
  }
298
302
  /** `persist` less the front-end URL names, and whether they were among what is kept. */
299
303
  function takeFrontendUrls(persist) {
@@ -316,18 +320,22 @@ function staleLocalServerImage(current, wantsLocalServer, imagePins) {
316
320
  * Docker dev's DATABASE_URL: the stack's database at `devDbPort`, with the project's own user and
317
321
  * database, not hardcoded ones, which on a project not named "supatype" named a database that does
318
322
  * not exist. Written over a URL the CLI owns, for this run only when the port is the shell's; one
319
- * that is yours always wins (database-url-owner.ts).
323
+ * that is yours always wins (database-url-owner.ts). The URL when it was set for this run only.
320
324
  */
321
325
  function writeDevStackDatabaseUrl(cwd, devDbPort, runOnly) {
322
326
  const url = hostComposeDbUrl(cwd, devDbPort);
323
- if (runOnly)
324
- setCliDatabaseUrlForRun(databaseUrlState(cwd), url);
325
- else
327
+ if (!runOnly) {
326
328
  writeCliDatabaseUrl(cwd, url);
329
+ return {};
330
+ }
331
+ return setCliDatabaseUrlForRun(databaseUrlState(cwd), url) ? { DATABASE_URL: url } : {};
327
332
  }
328
- /** Keep compose + Studio on the same freshly signed dev JWTs; sync optional image pins from config. */
333
+ /**
334
+ * Keep compose + Studio on the same freshly signed dev JWTs; sync optional image pins from config.
335
+ * The values held for this run only, as {@link upsertDevComposeEnv} returns them.
336
+ */
329
337
  function ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort) {
330
- upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort);
338
+ return upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort);
331
339
  }
332
340
  /**
333
341
  * The dev `.env` a push to a dev stack keeps current: the dev database port and the dev values.
@@ -446,34 +454,49 @@ async function reportUnhealthyStack(composePath, cwd, project) {
446
454
  }
447
455
  console.error("");
448
456
  }
449
- async function waitKongReady(kongPort, maxSec, stack) {
457
+ /** One look at the gateway's two health routes: whether both answer OK, and what each said. */
458
+ async function gatewayHealth(base) {
459
+ try {
460
+ const [auth, realtime] = await Promise.all([
461
+ fetchWithin(`${base}/auth/v1/health`, 2000),
462
+ fetchWithin(`${base}/realtime/v1/health`, 2000),
463
+ ]);
464
+ return { ready: auth.ok && realtime.ok, auth: `HTTP ${auth.status}`, realtime: `HTTP ${realtime.status}` };
465
+ }
466
+ catch (err) {
467
+ return { ready: false, auth: errorMessage(err), realtime: errorMessage(err) };
468
+ }
469
+ }
470
+ /**
471
+ * Wait for the gateway at `kongPort`, watching `stack`'s essential services as it goes: one that
472
+ * has exited will not come back, so the wait stops there and prints its exit code and last log
473
+ * lines before the caller's cleanup removes them (issue 38). Either failure ends dev's dashboard
474
+ * first, so what it prints reaches the terminal rather than a screen that is about to close.
475
+ */
476
+ export async function waitKongReady(kongPort, maxSec, stack) {
450
477
  const base = loopbackBase(kongPort);
478
+ const watched = stack === undefined ? undefined : { watch: stack.watch ?? composeStackWatch(stack), cwd: stack.cwd };
451
479
  // Remembered so the failure can name the unhealthy upstream. Blaming "the
452
480
  // Kong gateway" sent more than one investigation after Kong when Kong was
453
481
  // fine and a service behind it was not.
454
- let lastAuth = "no response";
455
- let lastRealtime = "no response";
482
+ let last = { auth: "no response", realtime: "no response" };
456
483
  for (let i = 0; i < maxSec; i++) {
457
- try {
458
- const [auth, realtime] = await Promise.all([
459
- fetchWithin(`${base}/auth/v1/health`, 2000),
460
- fetchWithin(`${base}/realtime/v1/health`, 2000),
461
- ]);
462
- lastAuth = `HTTP ${auth.status}`;
463
- lastRealtime = `HTTP ${realtime.status}`;
464
- if (auth.ok && realtime.ok)
465
- return;
466
- }
467
- catch (err) {
468
- lastAuth = lastRealtime = errorMessage(err);
484
+ const [health, exited] = await Promise.all([gatewayHealth(base), watched?.watch.exited().catch(() => undefined)]);
485
+ if (health.ready)
486
+ return;
487
+ last = health;
488
+ if (exited !== undefined && watched !== undefined) {
489
+ endDevSession();
490
+ throw await exitedServiceFailure(exited, watched);
469
491
  }
470
492
  await sleep(1000);
471
493
  }
472
494
  if (stack !== undefined) {
495
+ endDevSession();
473
496
  await reportUnhealthyStack(stack.composePath, stack.cwd, stack.project);
474
497
  }
475
498
  throw new Error(`Gateway at ${base} did not become ready within ${maxSec}s ` +
476
- `(auth/v1/health: ${lastAuth}, realtime/v1/health: ${lastRealtime})`);
499
+ `(auth/v1/health: ${last.auth}, realtime/v1/health: ${last.realtime})`);
477
500
  }
478
501
  /** Kong may be up while server → storage is still starting (503 or upstream errors). */
479
502
  async function waitStorageApiReady(kongPort, serviceRoleKey, maxSec) {
@@ -499,15 +522,16 @@ async function waitStorageApiReady(kongPort, serviceRoleKey, maxSec) {
499
522
  console.warn(`[supatype] Storage API at ${url} did not become ready within ${maxSec}s, bucket provisioning may fail.`);
500
523
  }
501
524
  /**
502
- * The schema's buckets on the dev stack. One the service did not take is said in one line, with what
503
- * it means: dev carries on, and only uploads to that bucket fail. They were dropped without a word
504
- * past each bucket's own warning.
525
+ * The schema's buckets on the stack: the line naming those the service did not take, or null when it
526
+ * took them all. Each caller decides what that means: dev and `compose up` carry on and warn
527
+ * ({@link warnBucketsLeft}), a push ends non-zero (0.9.1 release test FF2).
505
528
  */
506
529
  async function provisionDockerStorageBuckets(ast, kongPort, serviceRoleKey) {
507
- const left = unprovisionedBuckets(await provisionBucketsFromAst(ast, `${loopbackBase(kongPort)}/storage/v1`, serviceRoleKey));
508
- if (left !== null)
509
- console.warn(`[supatype] ⚠ ${left}; uploads to them fail until a later push takes them.`);
530
+ const storageApi = `${loopbackBase(kongPort)}/storage/v1`;
531
+ return unprovisionedBuckets(await provisionBucketsFromAst(ast, storageApi, serviceRoleKey, { storageLogs: STORAGE_LOGS }));
510
532
  }
533
+ /** The command that shows the storage container's log, named when it is not answering (N-FF11). */
534
+ const STORAGE_LOGS = "supatype self-host compose logs --service storage";
511
535
  let _lastPushedAst = null;
512
536
  let _lastFailedAst = null;
513
537
  /** The schema the last push read, whether it applied, was refused or failed. */
@@ -680,6 +704,8 @@ export async function runComposeSchemaPush(cwd, config, paths, schemaPath, compo
680
704
  // asked by `engineRequest`).
681
705
  if (!hasEngineOverride(config))
682
706
  await requireDockerFeatures(cwd, config, identityColumnsNeed(ast));
707
+ if (opts.access === "plan")
708
+ await printPlannedAccess(cwd, config);
683
709
  try {
684
710
  if (hasEngineOverride(config))
685
711
  await applyViaHostEngine(cwd, config, ast, opts);
@@ -693,9 +719,27 @@ export async function runComposeSchemaPush(cwd, config, paths, schemaPath, compo
693
719
  _lastPushedAst = astJson;
694
720
  _lastFailedAst = null;
695
721
  if (astRelatesToAuthUsers(ast))
696
- grantAuthSchemaAccess(paths, cwd, composeProject);
722
+ await grantAuthSchemaAccess(paths, cwd, composeProject);
697
723
  await refreshSchemaArtifacts(cwd, config, ast);
698
724
  }
725
+ /**
726
+ * Each API role's access as the push about to apply leaves it, from a diff of the AST just written.
727
+ * Only a preview: a diff that fails says so and the push goes on, to report what is wrong itself.
728
+ */
729
+ async function printPlannedAccess(cwd, config) {
730
+ try {
731
+ const diff = await dockerDiff(cwd, config);
732
+ if (diff !== undefined)
733
+ printRoleAccess(diff);
734
+ }
735
+ catch (err) {
736
+ console.log(`[supatype] Could not read each role's access before the push: ${errorMessage(err)}`);
737
+ }
738
+ }
739
+ /** What a push reports of each role's access once applied: only `changes` prints anything. */
740
+ function appliedAccess(opts) {
741
+ return opts.access === undefined || opts.access === "changes" ? "changes" : "quiet";
742
+ }
699
743
  /** The schema on disk as a push sends it, and that AST serialized for comparing pushes. */
700
744
  function readSchemaToPush(schemaPath, cwd, config) {
701
745
  const ast = withPublishing(loadSchemaAst(schemaPath, cwd), config);
@@ -738,7 +782,7 @@ async function applyViaHostEngine(cwd, config, ast, opts) {
738
782
  schema_sources_manifest: sources.payload.manifest,
739
783
  }),
740
784
  };
741
- reportAppliedPush(await enginePush(cwd, body, isEnginePushResult));
785
+ reportAppliedPush(await enginePush(cwd, body, isEnginePushResult), appliedAccess(opts));
742
786
  }
743
787
  /** Apply the AST on disk with the stack's schema-engine container. Throws when it is not applied. */
744
788
  async function applyViaComposeEngine(cwd, config, stack, opts) {
@@ -777,7 +821,7 @@ async function runComposeSchemaPushQueued(cwd, config, paths, schemaPath, compos
777
821
  _composePushQueued = false;
778
822
  await runDevSchemaPush(cwd, config, paths, schemaPath, composeProject, opts);
779
823
  } while (_composePushQueued);
780
- followRecordedTier(cwd, config, { recreate: true });
824
+ await followRecordedTier(cwd, config, { recreate: true });
781
825
  }
782
826
  finally {
783
827
  _composePushInFlight = false;
@@ -791,13 +835,13 @@ async function runComposeSchemaPushQueued(cwd, config, paths, schemaPath, compos
791
835
  * recreated so a running stack serves the new search path now; a caller about to run
792
836
  * `compose up -d` leaves that to it.
793
837
  */
794
- export function followRecordedTier(cwd, config, opts) {
838
+ export async function followRecordedTier(cwd, config, opts) {
795
839
  if (usesExternalDatabase(config))
796
840
  return;
797
- const project = composeProjectName(config.project.name);
841
+ const project = enterLocalStack(cwd, config.project.name);
798
842
  const paths = selfHostComposePaths(cwd);
799
843
  const served = composeFieldMaskingTier(cwd, config);
800
- const recorded = recordDatabaseTier(cwd, { project, composePath: paths.composePath });
844
+ const recorded = await recordDatabaseTier(cwd, { project, composePath: paths.composePath });
801
845
  if (recorded === undefined || sameApiSurface(config, served, recorded))
802
846
  return;
803
847
  writeSelfHostCompose(cwd, config, composeRenderOptions(cwd, config.project.name));
@@ -835,11 +879,11 @@ async function runDevSchemaPush(cwd, config, paths, schemaPath, composeProject,
835
879
  * may be renames. Reads the AST the push wrote, so it is the schema that was refused.
836
880
  */
837
881
  export async function dockerDiff(cwd, config) {
882
+ const project = enterLocalStack(cwd, config.project.name);
838
883
  if (hasEngineOverride(config)) {
839
884
  const ast = JSON.parse(readFileSync(join(cwd, ".supatype", "schema.ast.json"), "utf8"));
840
885
  return engineRequest("/diff", { ast, database_url: projectDatabaseUrl(cwd, config), schema: pgSchema(config) }, isDiffResult);
841
886
  }
842
- const project = composeProjectName(config.project.name);
843
887
  const result = await runComposeEngineDiff(selfHostComposePaths(cwd), cwd, project, config);
844
888
  return result.diff ?? undefined;
845
889
  }
@@ -858,7 +902,7 @@ async function runComposeEnginePush(paths, cwd, composeProject, config, sources,
858
902
  const pushResult = parseEnginePushOutput(output);
859
903
  if (exitStatus === 0) {
860
904
  if (pushResult) {
861
- reportAppliedPush(pushResult);
905
+ reportAppliedPush(pushResult, appliedAccess(opts));
862
906
  }
863
907
  else {
864
908
  console.log("[supatype] Schema applied.");
@@ -873,13 +917,14 @@ async function runComposeEnginePush(paths, cwd, composeProject, config, sources,
873
917
  export async function dockerEngineCapabilities(cwd, config) {
874
918
  if (hasEngineOverride(config))
875
919
  return engineCapabilities();
920
+ const project = enterLocalStack(cwd, config.project.name);
876
921
  const engineImage = await schemaEngineImageForPush(config, cwd);
877
922
  // An image Docker could not pull throws with the daemon's sentence, and is asked again next time.
878
923
  const probe = () => {
879
924
  const paths = writeSelfHostCompose(cwd, config, composeRenderOptions(cwd, config.project.name));
880
- const target = { cwd, project: composeProjectName(config.project.name), composePath: paths.composePath, engineImage };
925
+ const target = { cwd, project, composePath: paths.composePath, engineImage };
881
926
  return checkedCapabilities((args) => {
882
- const run = spawnComposeEngine(target, args, { runFlags: ["--no-deps"] });
927
+ const run = spawnComposeEngineSync(target, args, { runFlags: ["--no-deps"] });
883
928
  return { status: run.status, stdout: run.stdout, stderr: run.error ?? run.stderr };
884
929
  });
885
930
  };
@@ -959,7 +1004,7 @@ async function runComposeEngineCommand(paths, cwd, composeProject, config, comma
959
1004
  async function runComposeEngine(paths, cwd, composeProject, config, engineArgs) {
960
1005
  const engineImage = await schemaEngineImageForPush(config, cwd);
961
1006
  const target = { cwd, project: composeProject, composePath: paths.composePath, engineImage };
962
- const result = spawnComposeEngine(target, engineArgs, {
1007
+ const result = await spawnComposeEngine(target, engineArgs, {
963
1008
  secrets: { DATABASE_URL: projectDatabaseUrl(cwd, config, true) },
964
1009
  });
965
1010
  return {
@@ -998,13 +1043,13 @@ export function dockerAdoptionSteps(cwd, config) {
998
1043
  * which it is whenever a push has just been refused by it.
999
1044
  */
1000
1045
  export async function adoptSchemaDocker(cwd, config, yes, keys) {
1001
- const project = composeProjectName(config.project.name);
1046
+ const project = enterLocalStack(cwd, config.project.name);
1002
1047
  // Only these conflicts, or none for an empty list: never sent to an engine that would read
1003
1048
  // either as "every conflict".
1004
1049
  if (keys !== undefined)
1005
1050
  await requireDockerFeatures(cwd, config, [adoptKeysNeed(keys)]);
1006
1051
  if (hasEngineOverride(config)) {
1007
- await ensureDockerDbPublishedForHostEngine(cwd, config, { intro: "Adopt" });
1052
+ ensureDockerDbPublishedForHostEngine(cwd, config, "adopt");
1008
1053
  await ensureEngine();
1009
1054
  return engineRequest("/adopt", {
1010
1055
  ast: withPublishing(loadSchemaAst(schemaPathFromProject(config, cwd), cwd), config),
@@ -1029,60 +1074,30 @@ export async function adoptSchemaDocker(cwd, config, yes, keys) {
1029
1074
  * `overrides.engine` is set: then Postgres is published to the host and diff runs
1030
1075
  * through the local engine binary.
1031
1076
  *
1032
- * A dry run leaves the machine as it found it: a database the diff had to start is stopped again
1033
- * afterwards. It used to be left running.
1077
+ * Only against a stack that is running (issue 41): a stopped one is refused, not started. The diff
1078
+ * used to start Postgres itself, and stop it again afterwards.
1034
1079
  */
1035
1080
  export async function diffSchemaDocker(cwd, config) {
1036
1081
  if (resolveRuntimeProvider(config) !== "docker") {
1037
1082
  throw new Error("diffSchemaDocker requires provider: docker");
1038
1083
  }
1039
- const project = composeProjectName(config.project.name);
1040
- const brand = { intro: "Schema diff" };
1084
+ const project = enterLocalStack(cwd, config.project.name);
1041
1085
  if (hasEngineOverride(config)) {
1042
- return withComposeDatabaseStarted(cwd, config, project, () => ensureDockerDbPublishedForHostEngine(cwd, config, brand), () => diffWithHostEngine(cwd, config));
1086
+ ensureDockerDbPublishedForHostEngine(cwd, config, "diff");
1087
+ return diffWithHostEngine(cwd, config);
1043
1088
  }
1089
+ const running = runningStackMode(cwd, config.project.name);
1090
+ if (running === undefined && !usesExternalDatabase(config))
1091
+ throw new NoStackRunning("diff");
1044
1092
  // A diff of a standalone stack must not write dev values over the operator's .env (SH1). A dev
1045
- // stack's is brought up to date as push does: compose interpolates the whole file, so a project
1046
- // that has not yet run `dev` can lack values `up -d db` needs.
1047
- const mode = composeRenderMode(cwd, config.project.name);
1093
+ // stack's is brought up to date as push does: compose interpolates the whole file.
1094
+ const mode = running ?? "standalone";
1048
1095
  if (mode === "dev") {
1049
1096
  const { anonKey, serviceRoleKey } = devApiKeys(cwd);
1050
1097
  ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, await resolveKongPort(cwd, project), undefined);
1051
1098
  }
1052
1099
  const paths = writeSelfHostCompose(cwd, config, { devLocal: mode === "dev" });
1053
- return withComposeDatabaseStarted(cwd, config, project, () => startComposeDatabase(config, paths, cwd, project, brand), () => diffWithComposeEngine(cwd, config, paths, project));
1054
- }
1055
- /**
1056
- * `run` with the stack's database up, `start` bringing it up, then stopped again when it was not
1057
- * running before. One that a `supatype dev` session or a running stack is using is left as it was.
1058
- */
1059
- async function withComposeDatabaseStarted(cwd, config, project, start, run) {
1060
- const stack = { project, composePath: selfHostComposePaths(cwd).composePath };
1061
- // An external database is not the stack's to start or stop.
1062
- const wasStopped = !usesExternalDatabase(config) && !composeServiceIsRunning(cwd, stack, "db");
1063
- let started = false;
1064
- try {
1065
- await start();
1066
- started = true;
1067
- return await run();
1068
- }
1069
- finally {
1070
- // A start that failed after `up -d db` (its health wait, the host publish) has still brought
1071
- // the container up; one refused before it (no stack running) has started nothing to stop.
1072
- if (wasStopped && (started || composeServiceIsRunning(cwd, stack, "db")))
1073
- stopComposeDatabase(cwd, stack);
1074
- }
1075
- }
1076
- /** Stop the stack's database, saying so rather than failing the command whose result is already in hand. */
1077
- function stopComposeDatabase(cwd, stack) {
1078
- try {
1079
- const status = runDockerCompose(stack.composePath, ["stop", "db"], cwd, stack.project, { quiet: true });
1080
- if (status !== 0)
1081
- warn("Could not stop the Postgres container this command started. Stop it with `supatype self-host compose stop db`.");
1082
- }
1083
- catch (err) {
1084
- warn(`Could not stop the Postgres container this command started: ${errorMessage(err)}`);
1085
- }
1100
+ return diffWithComposeEngine(cwd, config, paths, project);
1086
1101
  }
1087
1102
  /** The diff from the host engine binary, against the database published to the host. */
1088
1103
  async function diffWithHostEngine(cwd, config) {
@@ -1125,40 +1140,65 @@ function unparsedDiffError(rawOutput) {
1125
1140
  * `supatype push` when `provider: docker`. Uses in-compose schema-engine unless
1126
1141
  * `overrides.engine` is set: then Postgres is published to the host and push runs
1127
1142
  * through the local engine binary (AST v2, contributor builds).
1143
+ *
1144
+ * Only to a stack that is running (issue 41): a stopped one is refused, not started. The push used
1145
+ * to start Postgres, apply, then start the rest of the stack, and exited 1 with the schema applied
1146
+ * when that start failed. An external database is applied to with no stack running, and then no
1147
+ * stack is started.
1128
1148
  */
1129
1149
  export async function pushSchemaDocker(cwd, config, opts = {}) {
1130
1150
  if (resolveRuntimeProvider(config) !== "docker") {
1131
1151
  throw new Error("pushSchemaDocker requires provider: docker");
1132
1152
  }
1133
- const project = composeProjectName(config.project.name);
1134
- // The stack's own mode, never dev by default: a push to a production stack used to render it as
1135
- // dev and recreate it that way, and write dev values over the operator's .env (SH1). A host
1136
- // engine is handed the database derived from the running stack, so with none running it refuses
1137
- // before anything starts (M1b).
1138
- const hostEngineDerivesDb = hasEngineOverride(config) && !usesExternalDatabase(config);
1139
- const mode = hostEngineDerivesDb
1140
- ? requireRunningStack(cwd, config.project.name)
1141
- : composeRenderMode(cwd, config.project.name);
1153
+ const project = enterLocalStack(cwd, config.project.name);
1154
+ const running = pushStackMode(cwd, config);
1155
+ const mode = running ?? "standalone";
1142
1156
  const kongPort = await resolveKongPort(cwd, project);
1143
1157
  if (mode === "dev")
1144
1158
  await prepareDevComposeEnv(cwd, config, project, kongPort);
1145
- const gatewayPort = composeGatewayHostPort(config, mode, kongPort);
1146
- const { anonKey, serviceRoleKey } = devApiKeys(cwd);
1147
1159
  const paths = writeSelfHostCompose(cwd, config, { devLocal: mode === "dev" });
1148
- const pushBrand = { intro: "Push schema" };
1149
- await startComposeDatabase(config, paths, cwd, project, pushBrand);
1160
+ const stack = { paths, project, gatewayPort: composeGatewayHostPort(config, mode, kongPort), brand: { intro: "Push schema" } };
1150
1161
  if (!usesExternalDatabase(config))
1151
- privatizeTableDefaults(paths, cwd, project);
1162
+ await privatizeTableDefaults(paths, cwd, project);
1152
1163
  const schemaPath = schemaPathFromProject(config, cwd);
1153
1164
  const ast = withPublishing(loadSchemaAst(schemaPath, cwd), config);
1154
1165
  await runComposeSchemaPush(cwd, config, paths, schemaPath, project, opts);
1155
1166
  // `up -d` below recreates PostgREST when the tier changed its environment.
1156
- followRecordedTier(cwd, config, { recreate: false });
1157
- await bringPushedStackUp(cwd, config, { paths, project, gatewayPort, brand: pushBrand }, ast, {
1158
- anonKey,
1159
- serviceRoleKey,
1160
- });
1161
- console.log("[supatype] Schema pushed.");
1167
+ await followRecordedTier(cwd, config, { recreate: false });
1168
+ if (running === undefined) {
1169
+ console.log("[supatype] Schema pushed. The local stack isn't running, so nothing else was started.");
1170
+ return false;
1171
+ }
1172
+ return bringUpAfterApply(() => bringPushedStackUp(cwd, config, stack, ast, devApiKeys(cwd)));
1173
+ }
1174
+ /**
1175
+ * The mode of the stack a push goes to, or undefined for an external database with no stack
1176
+ * running. A stopped stack with its own database is refused ({@link NoStackRunning}). The stack's
1177
+ * own mode, never dev by default: a push to a production stack used to render it as dev and
1178
+ * recreate it that way, and write dev values over the operator's .env (SH1).
1179
+ */
1180
+ function pushStackMode(cwd, config) {
1181
+ const running = runningStackMode(cwd, config.project.name);
1182
+ if (running === undefined && !usesExternalDatabase(config))
1183
+ throw new NoStackRunning("push");
1184
+ return running;
1185
+ }
1186
+ /**
1187
+ * What a push does on a running stack after it applied: `up -d` for what the schema changed, then
1188
+ * the buckets, the first admin and the REST wait. `bringUp` answers with the buckets the stack did
1189
+ * not take, or null. The schema is in by then and stays in (issue 41), but a step that failed ends
1190
+ * the push non-zero with no success line, as a push to a linked server does: it was warned about
1191
+ * and exited 0, so a pipeline passed with buckets missing (0.9.1 release test FF2, issue 301).
1192
+ * True when a step failed.
1193
+ */
1194
+ async function bringUpAfterApply(bringUp) {
1195
+ const failure = await bringUp().catch((err) => `a step after it failed: ${errorMessage(err)}`);
1196
+ if (failure === null) {
1197
+ console.log("[supatype] Schema pushed.");
1198
+ return false;
1199
+ }
1200
+ postApplyFailed(failure);
1201
+ return true;
1162
1202
  }
1163
1203
  /**
1164
1204
  * The host port the stack's gateway answers plain HTTP on. A standalone stack with TLS publishes
@@ -1168,25 +1208,46 @@ export async function pushSchemaDocker(cwd, config, opts = {}) {
1168
1208
  export function composeGatewayHostPort(config, mode, kongPort) {
1169
1209
  return selfHostTlsEnabled(config, mode === "dev") ? 80 : kongPort;
1170
1210
  }
1211
+ /** A stack `up` started that never answered through its gateway: not up, whatever `up` said (issue 57). */
1212
+ export class StackNotServing extends Error {
1213
+ name = "StackNotServing";
1214
+ }
1215
+ /**
1216
+ * What a started stack needs once it answers: the gateway and storage waited for, then the schema's
1217
+ * declared buckets and the first admin user. A push to a running stack runs it after its `up -d`,
1218
+ * and `self-host compose up` after its own, so no command depends on a push to start the stack and
1219
+ * create them (issue 41). Answers with the buckets the stack did not take, or null, for the caller
1220
+ * to warn about or fail on.
1221
+ */
1222
+ export async function provisionStartedStack(cwd, config, stack, ast, serviceRoleKey) {
1223
+ const { composePath, project, gatewayPort } = stack;
1224
+ try {
1225
+ await waitKongReady(gatewayPort, 120, { composePath, cwd, project });
1226
+ }
1227
+ catch (err) {
1228
+ throw new StackNotServing(errorMessage(err), { cause: err });
1229
+ }
1230
+ await waitStorageApiReady(gatewayPort, serviceRoleKey, 90);
1231
+ const left = await provisionDockerStorageBuckets(ast, gatewayPort, serviceRoleKey);
1232
+ await ensureFirstAdminUserForProject(cwd, config, { compose: { project, composePath } });
1233
+ return left;
1234
+ }
1171
1235
  /**
1172
1236
  * After a compose push: the rest of the stack up, then what the schema asks of it once it answers
1173
- * (buckets, the first admin), then REST, which is the last to catch up with the new schema.
1237
+ * (buckets, the first admin), then REST, which is the last to catch up with the new schema. Answers
1238
+ * with the buckets the stack did not take, or null.
1174
1239
  */
1175
1240
  async function bringPushedStackUp(cwd, config, stack, ast, keys) {
1176
1241
  const { paths, project, gatewayPort, brand } = stack;
1177
1242
  const upGateway = runDockerCompose(paths.composePath, ["up", "-d"], cwd, project, { quiet: true, brand });
1178
- if (upGateway !== 0) {
1179
- exitComposeFailed(upGateway, "Could not start the Compose gateway stack.", brand);
1180
- }
1181
- await waitKongReady(gatewayPort, 120, { composePath: paths.composePath, cwd, project });
1182
- await waitStorageApiReady(gatewayPort, keys.serviceRoleKey, 90);
1183
- await provisionDockerStorageBuckets(ast, gatewayPort, keys.serviceRoleKey);
1184
- await ensureFirstAdminUserForProject(cwd, config, {
1185
- compose: { project, composePath: paths.composePath },
1186
- });
1243
+ // Thrown, not exited: the schema is applied by now (bringUpAfterApply).
1244
+ if (upGateway !== 0)
1245
+ throw new Error(`docker compose up exited with status ${upGateway}`);
1246
+ const left = await provisionStartedStack(cwd, config, { composePath: paths.composePath, project, gatewayPort }, ast, keys.serviceRoleKey);
1187
1247
  // Last, so the admin user and the buckets are not held up by it. `supatype dev` never comes
1188
1248
  // through here: it pushes before PostgREST starts, so PostgREST finds the schemas on its first try.
1189
1249
  await waitForRestReady(loopbackBase(gatewayPort), keys.anonKey);
1250
+ return left;
1190
1251
  }
1191
1252
  /**
1192
1253
  * The first push of a `dev` session. A retry only ever brings Postgres back up: it never removes
@@ -1230,6 +1291,26 @@ async function devStackDbPort(cwd, config, project) {
1230
1291
  await offerToSaveShellDbPort(cwd);
1231
1292
  return port;
1232
1293
  }
1294
+ /** Stop the watchers and processes dev started, then bring the compose stack down. */
1295
+ export async function stopDevComposeStack(state, stack, cwd) {
1296
+ state.schemaWatcher?.close();
1297
+ state.schemaWatcher = null;
1298
+ state.functionsWatcher?.close();
1299
+ state.functionsWatcher = null;
1300
+ console.log("[supatype] Shutting down compose...");
1301
+ await state.studioProc?.stop();
1302
+ await state.appProc?.stop();
1303
+ await settleComposeRuns();
1304
+ // Docker was answering a moment ago, so the daemon probe is skipped: a slow `docker info` made it
1305
+ // report the daemon down and exit before `down` ran (issue 33).
1306
+ const downStatus = runDockerCompose(stack.composePath, ["down"], cwd, stack.project, { quiet: true, skipDaemonProbe: true });
1307
+ if (downStatus === 0) {
1308
+ console.log("[supatype] Compose stack stopped.");
1309
+ }
1310
+ else {
1311
+ console.warn(`[supatype] Compose down exited with status ${downStatus}.`);
1312
+ }
1313
+ }
1233
1314
  export async function runDevCompose(cwd, config, opts) {
1234
1315
  if (resolveRuntimeProvider(config) !== "docker") {
1235
1316
  throw new Error("runDevCompose requires provider: docker");
@@ -1240,6 +1321,9 @@ export async function runDevCompose(cwd, config, opts) {
1240
1321
  // Per-project compose name + port isolate this project from any other Supatype
1241
1322
  // stack on the machine (own containers, volumes, network, and gateway port).
1242
1323
  const project = composeProjectName(config.project.name);
1324
+ // Before anything is rendered or started: the stack of that name may be another folder's (RB-2).
1325
+ refuseOtherFoldersStack(cwd, project);
1326
+ recordStackFolder(cwd, project);
1243
1327
  const kongPort = await resolveKongPort(cwd, project);
1244
1328
  // No dev db port for an external database: `ensureDevDbPort` allocates a host port for the `db`
1245
1329
  // container *and persists a matching DATABASE_URL*, which overwrote the operator's own URL, the
@@ -1249,11 +1333,15 @@ export async function runDevCompose(cwd, config, opts) {
1249
1333
  // with a database on 54329 and a URL still saying 5432.
1250
1334
  // Only dev moves the port off something else that holds it.
1251
1335
  const devDbPort = await devStackDbPort(cwd, config, project);
1336
+ // Before .env is written and handed to compose: a SUPATYPE_MAILER_AUTOCONFIRM an earlier CLI wrote
1337
+ // there would otherwise win over the config as if the developer had set it (FF7).
1338
+ retireCliMailerAutoconfirm(cwd);
1252
1339
  const { anonKey, serviceRoleKey } = devApiKeys(cwd);
1253
1340
  const devBrand = { intro: "Local development" };
1254
1341
  const localServerImage = await ensureLocalServerDockerImage(cwd, config, devBrand);
1255
- ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort);
1256
- warnProjectAuthProviderSecrets(cwd, config);
1342
+ // Recorded in the session's lock, so a later command from another shell runs this stack as it runs.
1343
+ const runEnv = ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort);
1344
+ warnMissingStackSettings(cwd, config);
1257
1345
  console.log(`[supatype] provider docker, starting self-host Compose stack (project ${project}, gateway :${kongPort})...`);
1258
1346
  await showDevStep("Preparing the Docker stack");
1259
1347
  noteUnpinnedImages(cwd);
@@ -1267,25 +1355,12 @@ export async function runDevCompose(cwd, config, opts) {
1267
1355
  schemaWatcher: null,
1268
1356
  functionsWatcher: null,
1269
1357
  };
1270
- registerDevShutdown(async () => {
1271
- shutdownState.schemaWatcher?.close();
1272
- shutdownState.schemaWatcher = null;
1273
- shutdownState.functionsWatcher?.close();
1274
- shutdownState.functionsWatcher = null;
1275
- console.log("[supatype] Shutting down compose...");
1276
- await shutdownState.studioProc?.stop();
1277
- await shutdownState.appProc?.stop();
1278
- await settleComposeRuns();
1279
- const downStatus = runDockerCompose(paths.composePath, ["down"], cwd, project, { quiet: true });
1280
- if (downStatus === 0) {
1281
- console.log("[supatype] Compose stack stopped.");
1282
- }
1283
- else {
1284
- console.warn(`[supatype] Compose down exited with status ${downStatus}.`);
1285
- }
1286
- }, {
1358
+ // As the start begins, so the stack comes down however dev ends. Until the start is done a Ctrl+C
1359
+ // is a stopped start, as on native dev (FF11).
1360
+ registerDevShutdown(() => stopDevComposeStack(shutdownState, { project, composePath: paths.composePath }, cwd), {
1287
1361
  cwd,
1288
1362
  compose: { cwd, composePath: paths.composePath, composeProject: project },
1363
+ duringStart: true,
1289
1364
  });
1290
1365
  await recoverStaleDevSession(cwd);
1291
1366
  await handleComposeProjectRename(cwd, projectNameInFile(config), paths);
@@ -1310,9 +1385,9 @@ export async function runDevCompose(cwd, config, opts) {
1310
1385
  // With the stack's database up, so a hand-written URL naming it is not reported as silent.
1311
1386
  await warnIfHandWrittenUrlSilent(cwd);
1312
1387
  if (!usesExternalDatabase(config)) {
1313
- reconcileAuthenticatorPassword(paths, cwd, project);
1314
- reconcileSqlEditorPassword(paths, cwd, project);
1315
- privatizeTableDefaults(paths, cwd, project);
1388
+ await reconcileAuthenticatorPassword(paths, cwd, project);
1389
+ await reconcileSqlEditorPassword(paths, cwd, project);
1390
+ await privatizeTableDefaults(paths, cwd, project);
1316
1391
  }
1317
1392
  // A: apply schema before realtime (and the rest of the stack) starts decoding WAL.
1318
1393
  const schemaPath = schemaPathFromProject(config, cwd);
@@ -1321,7 +1396,7 @@ export async function runDevCompose(cwd, config, opts) {
1321
1396
  await showDevStep("Applying the schema");
1322
1397
  const schemaApplied = await applyInitialSchema(cwd, config, paths, schemaPath, project, devBrand, pushOptions);
1323
1398
  // Before the stack starts, so PostgREST comes up on the tier the push actually produced.
1324
- followRecordedTier(cwd, config, { recreate: false });
1399
+ await followRecordedTier(cwd, config, { recreate: false });
1325
1400
  console.log("[supatype] Bringing up Docker Compose services...");
1326
1401
  await showDevStep("Starting services (the first start downloads their images)");
1327
1402
  const upStatus = await runDockerComposeQuietly(paths.composePath, ["up", "-d"], cwd, project, devBrand);
@@ -1388,14 +1463,21 @@ export async function runDevCompose(cwd, config, opts) {
1388
1463
  kongPort,
1389
1464
  provider: "docker",
1390
1465
  });
1391
- writeDevSessionLock(cwd, devSessionLockFor(config, { composeProject: project, composePath: paths.composePath, kongPort }));
1466
+ writeDevSessionLock(cwd, devSessionLockFor(config, {
1467
+ provider: "docker",
1468
+ composeProject: project,
1469
+ composePath: paths.composePath,
1470
+ kongPort,
1471
+ ...(devDbPort !== undefined && { dbPort: devDbPort }),
1472
+ runEnv,
1473
+ }));
1392
1474
  // Only for a schema the database took, as a save does: a refused one may not even load, and its
1393
1475
  // buckets belong to fields that do not exist yet. The save that applies it provisions them.
1394
1476
  if (schemaApplied) {
1395
1477
  const ast = withPublishing(loadSchemaAst(schemaPath, cwd), config);
1396
- await provisionDockerStorageBuckets(ast, kongPort, serviceRoleKey);
1478
+ warnBucketsLeft(await provisionDockerStorageBuckets(ast, kongPort, serviceRoleKey));
1397
1479
  }
1398
- const pidDir = join(homedir(), ".supatype", "projects", config.project.name, "pid");
1480
+ const pidDir = join(nativeStateRoot(config), "pid");
1399
1481
  mkdirSync(pidDir, { recursive: true });
1400
1482
  startDevSession();
1401
1483
  let studioProc = null;
@@ -1423,15 +1505,14 @@ export async function runDevCompose(cwd, config, opts) {
1423
1505
  { label: "Storage", url: `http://localhost:${kongPort}/storage/v1/` },
1424
1506
  { label: "Realtime", url: `ws://localhost:${kongPort}/realtime/v1/` },
1425
1507
  ];
1426
- if (resolveProxyDevScript(config) !== null) {
1427
- links.push({ label: "App", url: `http://localhost:${kongPort}/` });
1428
- }
1508
+ links.push(...appPanelLinks(config, `http://localhost:${kongPort}`));
1429
1509
  links.push({ label: "Studio", url: studioUrlAt(`http://localhost:${kongPort}`) });
1430
1510
  const hints = [];
1431
1511
  const demoData = demoDataHint(cwd);
1432
1512
  if (demoData !== undefined)
1433
1513
  hints.push(demoData);
1434
1514
  publishDevReady({
1515
+ cwd,
1435
1516
  title: `Services running (Docker · ${project})`,
1436
1517
  links,
1437
1518
  anonKey,
@@ -1446,14 +1527,18 @@ export async function runDevCompose(cwd, config, opts) {
1446
1527
  shutdownState.schemaWatcher = watchDevSchema({
1447
1528
  dir: schemaDir,
1448
1529
  changedSinceLastPush: () => schemaChangedSinceLastPush(schemaPath, cwd, config),
1530
+ // The failure is reported inside the scope too, so its hints reach the dashboard.
1449
1531
  push: (why) => {
1450
- console.log(`\n[supatype] ${why}, pushing schema...`);
1451
- runComposeSchemaPushQueued(cwd, config, paths, schemaPath, project, pushOptions)
1452
- .then(async () => {
1453
- const updatedAst = loadSchemaAst(schemaPath, cwd);
1454
- await provisionDockerStorageBuckets(updatedAst, kongPort, serviceRoleKey);
1455
- })
1456
- .catch(reportDevPushFailure);
1532
+ void withSavePushOutput(async () => {
1533
+ console.log(`\n[supatype] ${why}, pushing schema...`);
1534
+ try {
1535
+ await runComposeSchemaPushQueued(cwd, config, paths, schemaPath, project, pushOptions);
1536
+ warnBucketsLeft(await provisionDockerStorageBuckets(loadSchemaAst(schemaPath, cwd), kongPort, serviceRoleKey));
1537
+ }
1538
+ catch (err) {
1539
+ reportDevPushFailure(err);
1540
+ }
1541
+ });
1457
1542
  },
1458
1543
  });
1459
1544
  // The worker imports its handlers once; without this an edited function kept its old code.