@supatype/cli 0.1.0-alpha.10

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 (416) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/.turbo/turbo-test.log +221 -0
  3. package/.turbo/turbo-typecheck.log +4 -0
  4. package/assets/supatype-logo-wordmark.ascii.txt +6 -0
  5. package/bin/dev-entry.ts +2 -0
  6. package/bin/supatype.js +5 -0
  7. package/dist/app/framework.d.ts +44 -0
  8. package/dist/app/framework.d.ts.map +1 -0
  9. package/dist/app/framework.js +200 -0
  10. package/dist/app/framework.js.map +1 -0
  11. package/dist/app/proxy-dev-app.d.ts +13 -0
  12. package/dist/app/proxy-dev-app.d.ts.map +1 -0
  13. package/dist/app/proxy-dev-app.js +54 -0
  14. package/dist/app/proxy-dev-app.js.map +1 -0
  15. package/dist/app-config.d.ts +7 -0
  16. package/dist/app-config.d.ts.map +1 -0
  17. package/dist/app-config.js +113 -0
  18. package/dist/app-config.js.map +1 -0
  19. package/dist/assets/supatype-logo-wordmark.ascii.txt +6 -0
  20. package/dist/augmentation-generator.d.ts +2 -0
  21. package/dist/augmentation-generator.d.ts.map +1 -0
  22. package/dist/augmentation-generator.js +111 -0
  23. package/dist/augmentation-generator.js.map +1 -0
  24. package/dist/binary-cache.d.ts +98 -0
  25. package/dist/binary-cache.d.ts.map +1 -0
  26. package/dist/binary-cache.js +687 -0
  27. package/dist/binary-cache.js.map +1 -0
  28. package/dist/cli.d.ts +2 -0
  29. package/dist/cli.d.ts.map +1 -0
  30. package/dist/cli.js +61 -0
  31. package/dist/cli.js.map +1 -0
  32. package/dist/commands/admin.d.ts +4 -0
  33. package/dist/commands/admin.d.ts.map +1 -0
  34. package/dist/commands/admin.js +271 -0
  35. package/dist/commands/admin.js.map +1 -0
  36. package/dist/commands/app.d.ts +3 -0
  37. package/dist/commands/app.d.ts.map +1 -0
  38. package/dist/commands/app.js +82 -0
  39. package/dist/commands/app.js.map +1 -0
  40. package/dist/commands/cache.d.ts +6 -0
  41. package/dist/commands/cache.d.ts.map +1 -0
  42. package/dist/commands/cache.js +105 -0
  43. package/dist/commands/cache.js.map +1 -0
  44. package/dist/commands/cloud.d.ts +23 -0
  45. package/dist/commands/cloud.d.ts.map +1 -0
  46. package/dist/commands/cloud.js +254 -0
  47. package/dist/commands/cloud.js.map +1 -0
  48. package/dist/commands/db.d.ts +8 -0
  49. package/dist/commands/db.d.ts.map +1 -0
  50. package/dist/commands/db.js +116 -0
  51. package/dist/commands/db.js.map +1 -0
  52. package/dist/commands/deploy-types.d.ts +14 -0
  53. package/dist/commands/deploy-types.d.ts.map +1 -0
  54. package/dist/commands/deploy-types.js +38 -0
  55. package/dist/commands/deploy-types.js.map +1 -0
  56. package/dist/commands/deploy.d.ts +15 -0
  57. package/dist/commands/deploy.d.ts.map +1 -0
  58. package/dist/commands/deploy.js +322 -0
  59. package/dist/commands/deploy.js.map +1 -0
  60. package/dist/commands/dev.d.ts +14 -0
  61. package/dist/commands/dev.d.ts.map +1 -0
  62. package/dist/commands/dev.js +806 -0
  63. package/dist/commands/dev.js.map +1 -0
  64. package/dist/commands/diff.d.ts +3 -0
  65. package/dist/commands/diff.d.ts.map +1 -0
  66. package/dist/commands/diff.js +54 -0
  67. package/dist/commands/diff.js.map +1 -0
  68. package/dist/commands/engine.d.ts +7 -0
  69. package/dist/commands/engine.d.ts.map +1 -0
  70. package/dist/commands/engine.js +27 -0
  71. package/dist/commands/engine.js.map +1 -0
  72. package/dist/commands/functions.d.ts +3 -0
  73. package/dist/commands/functions.d.ts.map +1 -0
  74. package/dist/commands/functions.js +749 -0
  75. package/dist/commands/functions.js.map +1 -0
  76. package/dist/commands/generate.d.ts +3 -0
  77. package/dist/commands/generate.d.ts.map +1 -0
  78. package/dist/commands/generate.js +38 -0
  79. package/dist/commands/generate.js.map +1 -0
  80. package/dist/commands/init.d.ts +7 -0
  81. package/dist/commands/init.d.ts.map +1 -0
  82. package/dist/commands/init.js +228 -0
  83. package/dist/commands/init.js.map +1 -0
  84. package/dist/commands/keys.d.ts +4 -0
  85. package/dist/commands/keys.d.ts.map +1 -0
  86. package/dist/commands/keys.js +57 -0
  87. package/dist/commands/keys.js.map +1 -0
  88. package/dist/commands/logs.d.ts +6 -0
  89. package/dist/commands/logs.d.ts.map +1 -0
  90. package/dist/commands/logs.js +52 -0
  91. package/dist/commands/logs.js.map +1 -0
  92. package/dist/commands/migrate-from-v1.d.ts +5 -0
  93. package/dist/commands/migrate-from-v1.d.ts.map +1 -0
  94. package/dist/commands/migrate-from-v1.js +125 -0
  95. package/dist/commands/migrate-from-v1.js.map +1 -0
  96. package/dist/commands/migrate.d.ts +3 -0
  97. package/dist/commands/migrate.d.ts.map +1 -0
  98. package/dist/commands/migrate.js +75 -0
  99. package/dist/commands/migrate.js.map +1 -0
  100. package/dist/commands/pg.d.ts +8 -0
  101. package/dist/commands/pg.d.ts.map +1 -0
  102. package/dist/commands/pg.js +102 -0
  103. package/dist/commands/pg.js.map +1 -0
  104. package/dist/commands/plugins.d.ts +3 -0
  105. package/dist/commands/plugins.d.ts.map +1 -0
  106. package/dist/commands/plugins.js +431 -0
  107. package/dist/commands/plugins.js.map +1 -0
  108. package/dist/commands/pull.d.ts +3 -0
  109. package/dist/commands/pull.d.ts.map +1 -0
  110. package/dist/commands/pull.js +12 -0
  111. package/dist/commands/pull.js.map +1 -0
  112. package/dist/commands/push.d.ts +3 -0
  113. package/dist/commands/push.d.ts.map +1 -0
  114. package/dist/commands/push.js +179 -0
  115. package/dist/commands/push.js.map +1 -0
  116. package/dist/commands/seed.d.ts +5 -0
  117. package/dist/commands/seed.d.ts.map +1 -0
  118. package/dist/commands/seed.js +55 -0
  119. package/dist/commands/seed.js.map +1 -0
  120. package/dist/commands/self-host.d.ts +9 -0
  121. package/dist/commands/self-host.d.ts.map +1 -0
  122. package/dist/commands/self-host.js +310 -0
  123. package/dist/commands/self-host.js.map +1 -0
  124. package/dist/commands/self-update.d.ts +9 -0
  125. package/dist/commands/self-update.d.ts.map +1 -0
  126. package/dist/commands/self-update.js +33 -0
  127. package/dist/commands/self-update.js.map +1 -0
  128. package/dist/commands/status.d.ts +6 -0
  129. package/dist/commands/status.d.ts.map +1 -0
  130. package/dist/commands/status.js +70 -0
  131. package/dist/commands/status.js.map +1 -0
  132. package/dist/commands/types.d.ts +3 -0
  133. package/dist/commands/types.d.ts.map +1 -0
  134. package/dist/commands/types.js +62 -0
  135. package/dist/commands/types.js.map +1 -0
  136. package/dist/commands/update.d.ts +7 -0
  137. package/dist/commands/update.d.ts.map +1 -0
  138. package/dist/commands/update.js +118 -0
  139. package/dist/commands/update.js.map +1 -0
  140. package/dist/components.d.ts +5 -0
  141. package/dist/components.d.ts.map +1 -0
  142. package/dist/components.js +3 -0
  143. package/dist/components.js.map +1 -0
  144. package/dist/config.d.ts +65 -0
  145. package/dist/config.d.ts.map +1 -0
  146. package/dist/config.js +134 -0
  147. package/dist/config.js.map +1 -0
  148. package/dist/dev-compose.d.ts +19 -0
  149. package/dist/dev-compose.d.ts.map +1 -0
  150. package/dist/dev-compose.js +468 -0
  151. package/dist/dev-compose.js.map +1 -0
  152. package/dist/dev-log-bus.d.ts +30 -0
  153. package/dist/dev-log-bus.d.ts.map +1 -0
  154. package/dist/dev-log-bus.js +87 -0
  155. package/dist/dev-log-bus.js.map +1 -0
  156. package/dist/dev-log-filter.d.ts +10 -0
  157. package/dist/dev-log-filter.d.ts.map +1 -0
  158. package/dist/dev-log-filter.js +36 -0
  159. package/dist/dev-log-filter.js.map +1 -0
  160. package/dist/dev-logo.d.ts +12 -0
  161. package/dist/dev-logo.d.ts.map +1 -0
  162. package/dist/dev-logo.js +57 -0
  163. package/dist/dev-logo.js.map +1 -0
  164. package/dist/dev-session.d.ts +26 -0
  165. package/dist/dev-session.d.ts.map +1 -0
  166. package/dist/dev-session.js +106 -0
  167. package/dist/dev-session.js.map +1 -0
  168. package/dist/dev-shutdown.d.ts +9 -0
  169. package/dist/dev-shutdown.d.ts.map +1 -0
  170. package/dist/dev-shutdown.js +50 -0
  171. package/dist/dev-shutdown.js.map +1 -0
  172. package/dist/dev-task-colors.d.ts +14 -0
  173. package/dist/dev-task-colors.d.ts.map +1 -0
  174. package/dist/dev-task-colors.js +44 -0
  175. package/dist/dev-task-colors.js.map +1 -0
  176. package/dist/dev-tui.d.ts +24 -0
  177. package/dist/dev-tui.d.ts.map +1 -0
  178. package/dist/dev-tui.js +188 -0
  179. package/dist/dev-tui.js.map +1 -0
  180. package/dist/diff-output.d.ts +4 -0
  181. package/dist/diff-output.d.ts.map +1 -0
  182. package/dist/diff-output.js +12 -0
  183. package/dist/diff-output.js.map +1 -0
  184. package/dist/docker-postgres.d.ts +57 -0
  185. package/dist/docker-postgres.d.ts.map +1 -0
  186. package/dist/docker-postgres.js +208 -0
  187. package/dist/docker-postgres.js.map +1 -0
  188. package/dist/engine-client.d.ts +69 -0
  189. package/dist/engine-client.d.ts.map +1 -0
  190. package/dist/engine-client.js +157 -0
  191. package/dist/engine-client.js.map +1 -0
  192. package/dist/engine-push-output.d.ts +16 -0
  193. package/dist/engine-push-output.d.ts.map +1 -0
  194. package/dist/engine-push-output.js +61 -0
  195. package/dist/engine-push-output.js.map +1 -0
  196. package/dist/ensure-binary.d.ts +7 -0
  197. package/dist/ensure-binary.d.ts.map +1 -0
  198. package/dist/ensure-binary.js +17 -0
  199. package/dist/ensure-binary.js.map +1 -0
  200. package/dist/functions-router-gen.d.ts +14 -0
  201. package/dist/functions-router-gen.d.ts.map +1 -0
  202. package/dist/functions-router-gen.js +199 -0
  203. package/dist/functions-router-gen.js.map +1 -0
  204. package/dist/index.d.ts +11 -0
  205. package/dist/index.d.ts.map +1 -0
  206. package/dist/index.js +9 -0
  207. package/dist/index.js.map +1 -0
  208. package/dist/jwt.d.ts +3 -0
  209. package/dist/jwt.d.ts.map +1 -0
  210. package/dist/jwt.js +13 -0
  211. package/dist/jwt.js.map +1 -0
  212. package/dist/kong-config.d.ts +25 -0
  213. package/dist/kong-config.d.ts.map +1 -0
  214. package/dist/kong-config.js +71 -0
  215. package/dist/kong-config.js.map +1 -0
  216. package/dist/local-gateway.d.ts +7 -0
  217. package/dist/local-gateway.d.ts.map +1 -0
  218. package/dist/local-gateway.js +9 -0
  219. package/dist/local-gateway.js.map +1 -0
  220. package/dist/local-storage.d.ts +8 -0
  221. package/dist/local-storage.d.ts.map +1 -0
  222. package/dist/local-storage.js +14 -0
  223. package/dist/local-storage.js.map +1 -0
  224. package/dist/pgbouncer-userlist.d.ts +5 -0
  225. package/dist/pgbouncer-userlist.d.ts.map +1 -0
  226. package/dist/pgbouncer-userlist.js +14 -0
  227. package/dist/pgbouncer-userlist.js.map +1 -0
  228. package/dist/postgres-ctl.d.ts +44 -0
  229. package/dist/postgres-ctl.d.ts.map +1 -0
  230. package/dist/postgres-ctl.js +137 -0
  231. package/dist/postgres-ctl.js.map +1 -0
  232. package/dist/process-manager.d.ts +49 -0
  233. package/dist/process-manager.d.ts.map +1 -0
  234. package/dist/process-manager.js +177 -0
  235. package/dist/process-manager.js.map +1 -0
  236. package/dist/project-config.d.ts +238 -0
  237. package/dist/project-config.d.ts.map +1 -0
  238. package/dist/project-config.js +159 -0
  239. package/dist/project-config.js.map +1 -0
  240. package/dist/pull-utils.d.ts +31 -0
  241. package/dist/pull-utils.d.ts.map +1 -0
  242. package/dist/pull-utils.js +77 -0
  243. package/dist/pull-utils.js.map +1 -0
  244. package/dist/release-pins.d.ts +7 -0
  245. package/dist/release-pins.d.ts.map +1 -0
  246. package/dist/release-pins.js +27 -0
  247. package/dist/release-pins.js.map +1 -0
  248. package/dist/release-public-key.d.ts +8 -0
  249. package/dist/release-public-key.d.ts.map +1 -0
  250. package/dist/release-public-key.js +13 -0
  251. package/dist/release-public-key.js.map +1 -0
  252. package/dist/restore-system-relation-targets.d.ts +3 -0
  253. package/dist/restore-system-relation-targets.d.ts.map +1 -0
  254. package/dist/restore-system-relation-targets.js +45 -0
  255. package/dist/restore-system-relation-targets.js.map +1 -0
  256. package/dist/runtime-routes.d.ts +34 -0
  257. package/dist/runtime-routes.d.ts.map +1 -0
  258. package/dist/runtime-routes.js +252 -0
  259. package/dist/runtime-routes.js.map +1 -0
  260. package/dist/schema-ast-v2.d.ts +127 -0
  261. package/dist/schema-ast-v2.d.ts.map +1 -0
  262. package/dist/schema-ast-v2.js +226 -0
  263. package/dist/schema-ast-v2.js.map +1 -0
  264. package/dist/scripts/postinstall.d.ts +11 -0
  265. package/dist/scripts/postinstall.d.ts.map +1 -0
  266. package/dist/scripts/postinstall.js +47 -0
  267. package/dist/scripts/postinstall.js.map +1 -0
  268. package/dist/seed.d.ts +8 -0
  269. package/dist/seed.d.ts.map +1 -0
  270. package/dist/seed.js +32 -0
  271. package/dist/seed.js.map +1 -0
  272. package/dist/self-host-compose.d.ts +43 -0
  273. package/dist/self-host-compose.d.ts.map +1 -0
  274. package/dist/self-host-compose.js +400 -0
  275. package/dist/self-host-compose.js.map +1 -0
  276. package/dist/storage-provision.d.ts +24 -0
  277. package/dist/storage-provision.d.ts.map +1 -0
  278. package/dist/storage-provision.js +44 -0
  279. package/dist/storage-provision.js.map +1 -0
  280. package/dist/studio-admin-roles.d.ts +7 -0
  281. package/dist/studio-admin-roles.d.ts.map +1 -0
  282. package/dist/studio-admin-roles.js +14 -0
  283. package/dist/studio-admin-roles.js.map +1 -0
  284. package/dist/studio-dev-server.d.ts +22 -0
  285. package/dist/studio-dev-server.d.ts.map +1 -0
  286. package/dist/studio-dev-server.js +28 -0
  287. package/dist/studio-dev-server.js.map +1 -0
  288. package/dist/supatype-eval-1781522769253.d.mts +2 -0
  289. package/dist/supatype-eval-1781522769253.d.mts.map +1 -0
  290. package/dist/supatype-eval-1781522769253.mjs +3 -0
  291. package/dist/supatype-eval-1781522769253.mjs.map +1 -0
  292. package/dist/systemd.d.ts +26 -0
  293. package/dist/systemd.d.ts.map +1 -0
  294. package/dist/systemd.js +102 -0
  295. package/dist/systemd.js.map +1 -0
  296. package/dist/tsx-runner.d.ts +18 -0
  297. package/dist/tsx-runner.d.ts.map +1 -0
  298. package/dist/tsx-runner.js +69 -0
  299. package/dist/tsx-runner.js.map +1 -0
  300. package/dist/type-extractor.d.ts +4 -0
  301. package/dist/type-extractor.d.ts.map +1 -0
  302. package/dist/type-extractor.js +1213 -0
  303. package/dist/type-extractor.js.map +1 -0
  304. package/dist/type-resolver.d.ts +33 -0
  305. package/dist/type-resolver.d.ts.map +1 -0
  306. package/dist/type-resolver.js +338 -0
  307. package/dist/type-resolver.js.map +1 -0
  308. package/package.json +41 -0
  309. package/releases/deno/VERSION +1 -0
  310. package/scripts/mirror-deno-release.sh +76 -0
  311. package/src/TYPE-RESOLUTION.md +294 -0
  312. package/src/app/framework.ts +249 -0
  313. package/src/app/proxy-dev-app.ts +68 -0
  314. package/src/app-config.ts +128 -0
  315. package/src/augmentation-generator.ts +126 -0
  316. package/src/binary-cache.ts +845 -0
  317. package/src/cli.ts +63 -0
  318. package/src/commands/admin.ts +372 -0
  319. package/src/commands/app.ts +97 -0
  320. package/src/commands/cache.ts +117 -0
  321. package/src/commands/cloud.ts +325 -0
  322. package/src/commands/db.ts +136 -0
  323. package/src/commands/deploy-types.ts +49 -0
  324. package/src/commands/deploy.ts +400 -0
  325. package/src/commands/dev.ts +1009 -0
  326. package/src/commands/diff.ts +63 -0
  327. package/src/commands/engine.ts +30 -0
  328. package/src/commands/functions.ts +901 -0
  329. package/src/commands/generate.ts +44 -0
  330. package/src/commands/init.ts +253 -0
  331. package/src/commands/keys.ts +66 -0
  332. package/src/commands/logs.ts +58 -0
  333. package/src/commands/migrate-from-v1.ts +131 -0
  334. package/src/commands/migrate.ts +87 -0
  335. package/src/commands/pg.ts +133 -0
  336. package/src/commands/plugins.ts +508 -0
  337. package/src/commands/pull.ts +17 -0
  338. package/src/commands/push.ts +226 -0
  339. package/src/commands/seed.ts +68 -0
  340. package/src/commands/self-host.ts +364 -0
  341. package/src/commands/self-update.ts +45 -0
  342. package/src/commands/status.ts +84 -0
  343. package/src/commands/types.ts +76 -0
  344. package/src/commands/update.ts +136 -0
  345. package/src/components.ts +6 -0
  346. package/src/config.ts +223 -0
  347. package/src/dev-compose.ts +583 -0
  348. package/src/dev-log-bus.ts +101 -0
  349. package/src/dev-log-filter.ts +32 -0
  350. package/src/dev-logo.ts +62 -0
  351. package/src/dev-session.ts +130 -0
  352. package/src/dev-shutdown.ts +54 -0
  353. package/src/dev-task-colors.ts +47 -0
  354. package/src/dev-tui.ts +232 -0
  355. package/src/diff-output.ts +12 -0
  356. package/src/docker-postgres.ts +295 -0
  357. package/src/engine-client.ts +236 -0
  358. package/src/engine-push-output.ts +71 -0
  359. package/src/ensure-binary.ts +28 -0
  360. package/src/functions-router-gen.ts +224 -0
  361. package/src/index.ts +11 -0
  362. package/src/jwt.ts +14 -0
  363. package/src/kong-config.ts +93 -0
  364. package/src/local-gateway.ts +9 -0
  365. package/src/local-storage.ts +14 -0
  366. package/src/pgbouncer-userlist.ts +15 -0
  367. package/src/postgres-ctl.ts +171 -0
  368. package/src/process-manager.ts +220 -0
  369. package/src/project-config.ts +388 -0
  370. package/src/pull-utils.ts +81 -0
  371. package/src/release-pins.ts +31 -0
  372. package/src/release-public-key.ts +12 -0
  373. package/src/restore-system-relation-targets.ts +45 -0
  374. package/src/runtime-routes.ts +291 -0
  375. package/src/schema-ast-v2.ts +324 -0
  376. package/src/scripts/postinstall.ts +51 -0
  377. package/src/seed.ts +43 -0
  378. package/src/self-host-compose.ts +452 -0
  379. package/src/storage-provision.ts +58 -0
  380. package/src/studio-admin-roles.ts +16 -0
  381. package/src/studio-dev-server.ts +53 -0
  382. package/src/supatype-eval-1781522769253.mts +1 -0
  383. package/src/systemd.ts +137 -0
  384. package/src/tsx-runner.ts +89 -0
  385. package/src/type-extractor.ts +1479 -0
  386. package/src/type-resolver.ts +457 -0
  387. package/tests/app-command.test.ts +54 -0
  388. package/tests/augmentation-generator.test.ts +59 -0
  389. package/tests/binary-cache-cloud-overrides.test.ts +123 -0
  390. package/tests/cached-artifact-format.test.ts +84 -0
  391. package/tests/cli-help.test.ts +133 -0
  392. package/tests/config.test.ts +252 -0
  393. package/tests/dev-ui.test.ts +139 -0
  394. package/tests/docker-postgres.test.ts +39 -0
  395. package/tests/engine-distribution.test.ts +418 -0
  396. package/tests/engine-push-output.test.ts +67 -0
  397. package/tests/ensure-binary.test.ts +59 -0
  398. package/tests/init.test.ts +127 -0
  399. package/tests/keys.test.ts +160 -0
  400. package/tests/migrate-from-v1.test.ts +29 -0
  401. package/tests/normalize-admin-config.test.ts +48 -0
  402. package/tests/pg-spawn-env.test.ts +18 -0
  403. package/tests/postgres-archive-tag.test.ts +9 -0
  404. package/tests/proxy-dev-app.test.ts +33 -0
  405. package/tests/pull-utils.test.ts +150 -0
  406. package/tests/release-pins.test.ts +28 -0
  407. package/tests/runtime-contract.test.ts +370 -0
  408. package/tests/seed-discover.test.ts +31 -0
  409. package/tests/studio-admin-roles.test.ts +27 -0
  410. package/tests/tsconfig.json +9 -0
  411. package/tests/tsx-runner.test.ts +66 -0
  412. package/tests/type-extractor.test.ts +985 -0
  413. package/tests/type-resolver.test.ts +59 -0
  414. package/tsconfig.json +10 -0
  415. package/tsconfig.tsbuildinfo +1 -0
  416. package/vitest.config.ts +12 -0
@@ -0,0 +1,84 @@
1
+ import { afterEach, describe, expect, it } from "vitest"
2
+ import { mkdtempSync, writeFileSync, rmSync } from "node:fs"
3
+ import { join } from "node:path"
4
+ import { tmpdir } from "node:os"
5
+ import {
6
+ validateArtifactFormat,
7
+ type Component,
8
+ type PlatformId,
9
+ } from "../src/binary-cache.js"
10
+
11
+ function writeMagic(name: string, bytes: number[]): string {
12
+ const dir = mkdtempSync(join(tmpdir(), "supatype-artifact-"))
13
+ const path = join(dir, name)
14
+ writeFileSync(path, Buffer.from(bytes))
15
+ return path
16
+ }
17
+
18
+ function expectValid(component: Component, path: string, platform: PlatformId): void {
19
+ expect(() => validateArtifactFormat(component, path, platform)).not.toThrow()
20
+ }
21
+
22
+ function expectInvalid(component: Component, path: string, platform: PlatformId): void {
23
+ expect(() => validateArtifactFormat(component, path, platform)).toThrow()
24
+ }
25
+
26
+ describe("validateArtifactFormat", () => {
27
+ const paths: string[] = []
28
+
29
+ afterEach(() => {
30
+ for (const p of paths) {
31
+ try {
32
+ rmSync(join(p, ".."), { recursive: true, force: true })
33
+ } catch {
34
+ /* ignore */
35
+ }
36
+ }
37
+ paths.length = 0
38
+ })
39
+
40
+ it("accepts ELF for engine/server/deno on linux", () => {
41
+ const linux: PlatformId = { os: "linux", arch: "amd64" }
42
+ for (const component of ["engine", "server", "deno"] as const) {
43
+ const p = writeMagic(component, [0x7f, 0x45, 0x4c, 0x46, 0, 0, 0, 0])
44
+ paths.push(p)
45
+ expectValid(component, p, linux)
46
+ }
47
+ })
48
+
49
+ it("accepts Mach-O for engine on darwin", () => {
50
+ const p = writeMagic("engine", [0xcf, 0xfa, 0xed, 0xfe, 0, 0, 0, 0])
51
+ paths.push(p)
52
+ expectValid("engine", p, { os: "darwin", arch: "arm64" })
53
+ })
54
+
55
+ it("accepts PE for deno on windows", () => {
56
+ const p = writeMagic("deno.exe", [0x4d, 0x5a, 0x90, 0x00, 0, 0, 0, 0])
57
+ paths.push(p)
58
+ expectValid("deno", p, { os: "windows", arch: "amd64" })
59
+ })
60
+
61
+ it("rejects Go c-archive for server on linux", () => {
62
+ const p = writeMagic("server", [0x21, 0x3c, 0x61, 0x72, 0, 0, 0, 0])
63
+ paths.push(p)
64
+ expectInvalid("server", p, { os: "linux", arch: "amd64" })
65
+ })
66
+
67
+ it("accepts gzip for postgres on linux", () => {
68
+ const p = writeMagic("pg.tar.gz", [0x1f, 0x8b, 0x08, 0x00, 0, 0, 0, 0])
69
+ paths.push(p)
70
+ expectValid("postgres", p, { os: "linux", arch: "amd64" })
71
+ })
72
+
73
+ it("accepts zip for postgres on windows", () => {
74
+ const p = writeMagic("pg.zip", [0x50, 0x4b, 0x03, 0x04, 0, 0, 0, 0])
75
+ paths.push(p)
76
+ expectValid("postgres", p, { os: "windows", arch: "amd64" })
77
+ })
78
+
79
+ it("rejects gzip postgres artifact on windows", () => {
80
+ const p = writeMagic("pg.tar.gz", [0x1f, 0x8b, 0x08, 0x00, 0, 0, 0, 0])
81
+ paths.push(p)
82
+ expectInvalid("postgres", p, { os: "windows", arch: "amd64" })
83
+ })
84
+ })
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Subprocess tests — spawn the compiled CLI binary and verify commands are
3
+ * registered. Requires `pnpm build` to have run first (turbo handles this).
4
+ */
5
+ import { describe, it, expect } from "vitest"
6
+ import { spawnSync } from "node:child_process"
7
+ import { resolve, dirname } from "node:path"
8
+ import { fileURLToPath } from "node:url"
9
+
10
+ const __dirname = dirname(fileURLToPath(import.meta.url))
11
+ const CLI_BIN = resolve(__dirname, "../bin/supatype.js")
12
+ const DIST_CLI = resolve(__dirname, "../dist/cli.js")
13
+
14
+ function runCli(args: string[]): { stdout: string; stderr: string; exitCode: number } {
15
+ const result = spawnSync(process.execPath, [CLI_BIN, ...args], {
16
+ encoding: "utf8",
17
+ timeout: 10_000,
18
+ })
19
+ return {
20
+ stdout: String(result.stdout ?? ""),
21
+ stderr: String(result.stderr ?? ""),
22
+ exitCode: result.status ?? 1,
23
+ }
24
+ }
25
+
26
+ describe("CLI binary (requires built dist/)", () => {
27
+ it("--help lists all top-level commands", () => {
28
+ const { stdout, exitCode } = runCli(["--help"])
29
+ expect(exitCode).toBe(0)
30
+ const commands = [
31
+ "init",
32
+ "dev",
33
+ "push",
34
+ "diff",
35
+ "pull",
36
+ "generate",
37
+ "migrate",
38
+ "rollback",
39
+ "reset",
40
+ "seed",
41
+ "keys",
42
+ "app",
43
+ "self-host",
44
+ "self-update",
45
+ ]
46
+ for (const cmd of commands) {
47
+ expect(stdout, `Expected '${cmd}' in --help output`).toContain(cmd)
48
+ }
49
+ })
50
+
51
+ it("--version prints a semver string", () => {
52
+ const { stdout, exitCode } = runCli(["--version"])
53
+ expect(exitCode).toBe(0)
54
+ expect(stdout.trim()).toMatch(/^\d+\.\d+\.\d+/)
55
+ })
56
+
57
+ it("self-update --help describes the command", () => {
58
+ const { stdout, exitCode } = runCli(["self-update", "--help"])
59
+ expect(exitCode).toBe(0)
60
+ expect(stdout.toLowerCase()).toMatch(/npm|update/)
61
+ })
62
+
63
+ it("init --help describes the init command", () => {
64
+ const { stdout, exitCode } = runCli(["init", "--help"])
65
+ expect(exitCode).toBe(0)
66
+ expect(stdout).toContain("Scaffold")
67
+ })
68
+
69
+ it("push --help describes the push command and --yes flag", () => {
70
+ const { stdout, exitCode } = runCli(["push", "--help"])
71
+ expect(exitCode).toBe(0)
72
+ expect(stdout).toContain("--yes")
73
+ expect(stdout).toContain("--connection")
74
+ })
75
+
76
+ it("diff --help describes the diff command", () => {
77
+ const { stdout, exitCode } = runCli(["diff", "--help"])
78
+ expect(exitCode).toBe(0)
79
+ expect(stdout).toContain("dry run")
80
+ })
81
+
82
+ it("pull --help describes deprecated pull command", () => {
83
+ const { stdout, exitCode } = runCli(["pull", "--help"])
84
+ expect(exitCode).toBe(0)
85
+ expect(stdout).toContain("deprecated")
86
+ })
87
+
88
+ it("reset --help shows --yes flag", () => {
89
+ const { stdout, exitCode } = runCli(["reset", "--help"])
90
+ expect(exitCode).toBe(0)
91
+ expect(stdout).toContain("--yes")
92
+ })
93
+
94
+ it("app --help describes the app command with add/remove subcommands", () => {
95
+ const { stdout, exitCode } = runCli(["app", "--help"])
96
+ expect(exitCode).toBe(0)
97
+ expect(stdout).toContain("add")
98
+ expect(stdout).toContain("remove")
99
+ })
100
+
101
+ it("app add --help shows --static and --port options", () => {
102
+ const { stdout, exitCode } = runCli(["app", "add", "--help"])
103
+ expect(exitCode).toBe(0)
104
+ expect(stdout).toContain("--static")
105
+ expect(stdout).toContain("--port")
106
+ })
107
+
108
+ it("self-host --help shows compose only (legacy commands hidden)", () => {
109
+ const { stdout, exitCode } = runCli(["self-host", "--help"])
110
+ expect(exitCode).toBe(0)
111
+ const commandsSection = stdout.split("Commands:")[1] ?? ""
112
+ expect(commandsSection).toContain("compose")
113
+ expect(commandsSection).not.toContain("install-service")
114
+ expect(commandsSection).not.toContain("native")
115
+ expect(commandsSection).not.toContain("backup")
116
+ expect(stdout).not.toContain("--output-dir")
117
+ })
118
+
119
+ it("self-host compose --help shows compose subcommands", () => {
120
+ const { stdout, exitCode } = runCli(["self-host", "compose", "--help"])
121
+ expect(exitCode).toBe(0)
122
+ expect(stdout).toContain("render")
123
+ expect(stdout).toContain("up")
124
+ expect(stdout).toContain("down")
125
+ expect(stdout).toContain("status")
126
+ expect(stdout).toContain("logs")
127
+ })
128
+
129
+ it("unknown command exits non-zero", () => {
130
+ const { exitCode } = runCli(["doesnotexist"])
131
+ expect(exitCode).not.toBe(0)
132
+ })
133
+ })
@@ -0,0 +1,252 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from "vitest"
2
+ import { mkdirSync, rmSync, writeFileSync } from "node:fs"
3
+ import { join } from "node:path"
4
+ import { tmpdir } from "node:os"
5
+ import { defineConfig, loadConfig } from "../src/config.js"
6
+ import { mergeProjectConfig, resolveRuntimeProvider, type SupatypeProjectConfig } from "../src/project-config.js"
7
+ import { DENO_RELEASE_PIN } from "../src/release-pins.js"
8
+
9
+ let counter = 0
10
+ let tmpDir: string
11
+
12
+ const minimalProject = (name: string): SupatypeProjectConfig => ({
13
+ project: { name },
14
+ database: { provider: "docker" },
15
+ server: { mode: "dev" },
16
+ app: { mode: "none" },
17
+ versions: {
18
+ engine: "0.4.2",
19
+ server: "0.1.0",
20
+ postgres: "17.2",
21
+ deno: DENO_RELEASE_PIN,
22
+ },
23
+ })
24
+
25
+ beforeEach(() => {
26
+ tmpDir = join(tmpdir(), `dt-config-test-${Date.now()}-${++counter}`)
27
+ mkdirSync(tmpDir, { recursive: true })
28
+ })
29
+
30
+ afterEach(() => {
31
+ rmSync(tmpDir, { recursive: true, force: true })
32
+ })
33
+
34
+ describe("defineConfig()", () => {
35
+ it("returns its argument unchanged (identity helper for type inference)", () => {
36
+ const cfg = defineConfig({
37
+ ...minimalProject("test"),
38
+ connection: "postgresql://localhost/test",
39
+ schema: { path: "./schema/index.ts" },
40
+ })
41
+ expect(defineConfig(cfg)).toBe(cfg)
42
+ })
43
+
44
+ it("preserves optional output field", () => {
45
+ const cfg = defineConfig({
46
+ ...minimalProject("test"),
47
+ schema: { path: "./schema/index.ts" },
48
+ output: { types: "./src/types.d.ts", client: "./src/client.ts" },
49
+ })
50
+ expect(cfg.output?.types).toBe("./src/types.d.ts")
51
+ expect(cfg.output?.client).toBe("./src/client.ts")
52
+ })
53
+ })
54
+
55
+ describe("loadConfig()", () => {
56
+ it("throws when no config file exists in the directory", () => {
57
+ expect(() => loadConfig(tmpDir)).toThrow(/No supatype.config.ts/)
58
+ })
59
+
60
+ it("loads a valid supatype.config.ts (plain export default, no package imports)", () => {
61
+ const body = {
62
+ ...minimalProject("mydb"),
63
+ connection: "postgresql://localhost/mydb",
64
+ schema: { path: "./schema/index.ts" },
65
+ }
66
+ writeFileSync(
67
+ join(tmpDir, "supatype.config.ts"),
68
+ `export default ${JSON.stringify(body)}
69
+ `,
70
+ )
71
+ const cfg = loadConfig(tmpDir)
72
+ expect(cfg.connection).toBe("postgresql://localhost/mydb")
73
+ expect(cfg.schema?.path).toBe("./schema/index.ts")
74
+ })
75
+
76
+ it("normalizes shorthand schema string to { path, pg_schema }", () => {
77
+ writeFileSync(
78
+ join(tmpDir, "supatype.config.ts"),
79
+ `export default ${JSON.stringify({
80
+ ...minimalProject("x"),
81
+ schema: "./schema/index.ts",
82
+ })}
83
+ `,
84
+ )
85
+ const cfg = loadConfig(tmpDir)
86
+ expect(cfg.schema?.path).toBe("./schema/index.ts")
87
+ expect(cfg.schema?.pg_schema).toBe("public")
88
+ })
89
+
90
+ it("loads a supatype.config.js (plain ESM)", () => {
91
+ writeFileSync(
92
+ join(tmpDir, "supatype.config.js"),
93
+ `export default ${JSON.stringify({
94
+ ...minimalProject("jsdb"),
95
+ connection: "postgresql://localhost/jsdb",
96
+ schema: { path: "./schema/index.ts" },
97
+ })}
98
+ `,
99
+ )
100
+ const cfg = loadConfig(tmpDir)
101
+ expect(cfg.connection).toBe("postgresql://localhost/jsdb")
102
+ })
103
+
104
+ it("loads config without a versions section (latest by default)", () => {
105
+ writeFileSync(
106
+ join(tmpDir, "supatype.config.ts"),
107
+ `export default {
108
+ project: { name: "t" },
109
+ database: { provider: "docker" },
110
+ server: { mode: "dev" },
111
+ app: { mode: "none" },
112
+ schema: { path: "./schema/index.ts" },
113
+ }`,
114
+ )
115
+ const cfg = loadConfig(tmpDir)
116
+ expect(cfg.versions).toBeUndefined()
117
+ })
118
+
119
+ it("prefers supatype.config.ts over supatype.config.js when both exist", () => {
120
+ writeFileSync(
121
+ join(tmpDir, "supatype.config.ts"),
122
+ `export default ${JSON.stringify({
123
+ ...minimalProject("from-ts"),
124
+ connection: "postgresql://localhost/from-ts",
125
+ schema: { path: "./schema/index.ts" },
126
+ })}`,
127
+ )
128
+ writeFileSync(
129
+ join(tmpDir, "supatype.config.js"),
130
+ `export default ${JSON.stringify({
131
+ ...minimalProject("from-js"),
132
+ connection: "postgresql://localhost/from-js",
133
+ schema: { path: "./schema/index.ts" },
134
+ })}`,
135
+ )
136
+ const cfg = loadConfig(tmpDir)
137
+ expect(cfg.connection).toContain("from-ts")
138
+ })
139
+
140
+ it("supports optional output field in config", () => {
141
+ writeFileSync(
142
+ join(tmpDir, "supatype.config.ts"),
143
+ `export default ${JSON.stringify({
144
+ ...minimalProject("t"),
145
+ schema: { path: "./schema/index.ts" },
146
+ output: { types: "./src/types.d.ts" },
147
+ })}`,
148
+ )
149
+ const cfg = loadConfig(tmpDir)
150
+ expect(cfg.output?.types).toBe("./src/types.d.ts")
151
+ })
152
+
153
+ it("merges supatype.local.config.ts over base", () => {
154
+ writeFileSync(
155
+ join(tmpDir, "supatype.config.ts"),
156
+ `export default ${JSON.stringify({
157
+ ...minimalProject("base"),
158
+ schema: { path: "./a.ts" },
159
+ versions: {
160
+ engine: "0.4.0",
161
+ server: "0.1.0",
162
+ postgres: "17",
163
+ deno: "2.2.0",
164
+ },
165
+ })}`,
166
+ )
167
+ writeFileSync(
168
+ join(tmpDir, "supatype.local.config.ts"),
169
+ `export default ${JSON.stringify({
170
+ versions: {
171
+ engine: "0.4.2",
172
+ server: "0.1.0",
173
+ postgres: "17",
174
+ deno: "2.2.0",
175
+ },
176
+ })}`,
177
+ )
178
+ const cfg = loadConfig(tmpDir)
179
+ expect(cfg.versions.engine).toBe("0.4.2")
180
+ expect(cfg.schema?.path).toBe("./a.ts")
181
+ })
182
+ })
183
+
184
+ describe("resolveRuntimeProvider()", () => {
185
+ it("prefers top-level provider over database.provider", () => {
186
+ const cfg = defineConfig({
187
+ ...minimalProject("p"),
188
+ provider: "docker",
189
+ database: { provider: "native" },
190
+ })
191
+ expect(resolveRuntimeProvider(cfg)).toBe("docker")
192
+ })
193
+
194
+ it("falls back to database.provider then native", () => {
195
+ expect(resolveRuntimeProvider(defineConfig({ ...minimalProject("p"), database: { provider: "docker" } }))).toBe(
196
+ "docker",
197
+ )
198
+ expect(resolveRuntimeProvider(defineConfig({ ...minimalProject("p"), database: { provider: "native" } }))).toBe(
199
+ "native",
200
+ )
201
+ })
202
+ })
203
+
204
+ describe("mergeProjectConfig()", () => {
205
+ it("deep-merges email.smtp between base and local", () => {
206
+ const base = defineConfig({
207
+ ...minimalProject("p"),
208
+ email: { provider: "smtp", smtp: { host: "h1", port: 587, user: "u0" } },
209
+ })
210
+ const merged = mergeProjectConfig(base, { email: { smtp: { host: "h2", pass: "x" } } })
211
+ expect(merged.email?.provider).toBe("smtp")
212
+ expect(merged.email?.smtp?.host).toBe("h2")
213
+ expect(merged.email?.smtp?.port).toBe(587)
214
+ expect(merged.email?.smtp?.user).toBe("u0")
215
+ expect(merged.email?.smtp?.pass).toBe("x")
216
+ })
217
+
218
+ it("merges send_email_hook fields from local", () => {
219
+ const base = defineConfig({
220
+ ...minimalProject("p"),
221
+ email: { provider: "console", send_email_hook: true, send_email_hook_uri: "http://old/hook" },
222
+ })
223
+ const merged = mergeProjectConfig(base, {
224
+ email: { send_email_hook_secrets: "v1,whsec_customsecret0000000000000000" },
225
+ })
226
+ expect(merged.email?.send_email_hook).toBe(true)
227
+ expect(merged.email?.send_email_hook_uri).toBe("http://old/hook")
228
+ expect(merged.email?.send_email_hook_secrets).toBe("v1,whsec_customsecret0000000000000000")
229
+ })
230
+
231
+ it("overrides app.vite_dev_url from local", () => {
232
+ const base = defineConfig({
233
+ ...minimalProject("p"),
234
+ app: { mode: "static", static_dir: "./dist", vite_dev_url: "http://127.0.0.1:1111" },
235
+ })
236
+ const merged = mergeProjectConfig(base, { app: { vite_dev_url: "http://127.0.0.1:5173" } })
237
+ expect(merged.app?.vite_dev_url).toBe("http://127.0.0.1:5173")
238
+ })
239
+
240
+ it("merges app.start for proxy dev script override", () => {
241
+ const base = defineConfig({
242
+ ...minimalProject("p"),
243
+ app: { mode: "static", static_dir: "./dist" },
244
+ })
245
+ const merged = mergeProjectConfig(base, {
246
+ app: { mode: "proxy", upstream: "http://127.0.0.1:4321", start: "dev:site" },
247
+ })
248
+ expect(merged.app.mode).toBe("proxy")
249
+ expect(merged.app.start).toBe("dev:site")
250
+ expect(merged.app.static_dir).toBe("./dist")
251
+ })
252
+ })
@@ -0,0 +1,139 @@
1
+ import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"
2
+ import { DevLogBus } from "../src/dev-log-bus.js"
3
+ import { filterDevSubprocessLine, formatConsoleArgs, stripAnsi } from "../src/dev-log-filter.js"
4
+ import { appendDevTaskLog, beginDevSession, endDevSession, resolveDevUiMode } from "../src/dev-session.js"
5
+ import {
6
+ layoutLogoBlock,
7
+ logoRowCount,
8
+ pickLogoLines,
9
+ SUPATYPE_ASCII_LOGO_WORDMARK,
10
+ } from "../src/dev-logo.js"
11
+ import { normalizeStackLogLine, taskColor } from "../src/dev-task-colors.js"
12
+
13
+ describe("filterDevSubprocessLine()", () => {
14
+ it("filters npm script banners and vite network URLs for app", () => {
15
+ expect(filterDevSubprocessLine("app", "> vite")).toBe(false)
16
+ expect(filterDevSubprocessLine("app", " ➜ Network: http://10.0.0.1:5173/")).toBe(false)
17
+ expect(filterDevSubprocessLine("app", " ➜ Local: http://localhost:5173/")).toBe(true)
18
+ })
19
+
20
+ it("does not filter stack logs", () => {
21
+ expect(filterDevSubprocessLine("stack", "> vite")).toBe(true)
22
+ })
23
+ })
24
+
25
+ describe("stripAnsi()", () => {
26
+ it("removes colour codes", () => {
27
+ expect(stripAnsi("\x1b[33mhello\x1b[0m")).toBe("hello")
28
+ })
29
+ })
30
+
31
+ describe("formatConsoleArgs()", () => {
32
+ it("joins mixed arguments", () => {
33
+ expect(formatConsoleArgs(["a", 1])).toBe("a 1")
34
+ })
35
+ })
36
+
37
+ describe("DevLogBus", () => {
38
+ it("marks non-focused tasks unread", () => {
39
+ const bus = new DevLogBus()
40
+ bus.registerTask("app", "app")
41
+ bus.setFocusedTaskId("stack")
42
+ bus.append("app", "ready")
43
+ expect(bus.getTask("app")?.unread).toBe(true)
44
+ bus.setFocusedTaskId("app")
45
+ expect(bus.getTask("app")?.unread).toBe(false)
46
+ })
47
+
48
+ it("splits multiline append into separate rows", () => {
49
+ const bus = new DevLogBus()
50
+ bus.append("stack", "line one\nline two")
51
+ expect(bus.getTask("stack")?.lines).toEqual(["line one", "line two"])
52
+ })
53
+
54
+ it("strips [supatype] prefix on stack task", () => {
55
+ const bus = new DevLogBus()
56
+ bus.append("stack", "[supatype] hello")
57
+ expect(bus.getTask("stack")?.lines).toEqual(["hello"])
58
+ })
59
+ })
60
+
61
+ describe("resolveDevUiMode()", () => {
62
+ it("honours --stream", () => {
63
+ expect(resolveDevUiMode(true)).toBe("stream")
64
+ })
65
+ })
66
+
67
+ describe("appendDevTaskLog()", () => {
68
+ afterEach(() => {
69
+ endDevSession()
70
+ })
71
+
72
+ it("routes proxy bootstrap lines to the app task in TUI mode", () => {
73
+ const session = beginDevSession("tui")
74
+ appendDevTaskLog("app", "app", "Proxy mode: running npm run vite (/tmp/app)")
75
+ expect(session.bus.getTask("app")?.lines).toEqual(["Proxy mode: running npm run vite (/tmp/app)"])
76
+ expect(session.bus.getTask("stack")?.lines ?? []).toEqual([])
77
+ })
78
+ })
79
+
80
+ describe("dev-logo", () => {
81
+ it("preserves authored line spacing including trailing spaces", () => {
82
+ const out = layoutLogoBlock([" aa", " bbbb ", ""])
83
+ expect(out[0]).toBe(" aa")
84
+ expect(out[1]).toBe(" bbbb ")
85
+ })
86
+
87
+ it("loads the figlet slant wordmark", () => {
88
+ expect(pickLogoLines()).toEqual([...SUPATYPE_ASCII_LOGO_WORDMARK])
89
+ expect(logoRowCount()).toBe(6)
90
+ expect(SUPATYPE_ASCII_LOGO_WORDMARK[1]).toContain("_______")
91
+ })
92
+ })
93
+
94
+ describe("dev-task-colors", () => {
95
+ it("assigns purple to stack and green to app", () => {
96
+ expect(taskColor("stack")).toBe("\x1b[35m")
97
+ expect(taskColor("app")).toBe("\x1b[32m")
98
+ })
99
+
100
+ it("strips stack log prefix", () => {
101
+ expect(normalizeStackLogLine("[supatype] Waiting for Postgres")).toBe("Waiting for Postgres")
102
+ })
103
+ })
104
+
105
+ describe("dev-shutdown", () => {
106
+ const exitSpy = vi.spyOn(process, "exit").mockImplementation((() => undefined) as typeof process.exit)
107
+
108
+ beforeEach(() => {
109
+ exitSpy.mockClear()
110
+ })
111
+
112
+ afterEach(() => {
113
+ vi.resetModules()
114
+ })
115
+
116
+ it("exits 0 after registered work completes", async () => {
117
+ vi.resetModules()
118
+ const { registerDevShutdown, requestDevShutdown } = await import("../src/dev-shutdown.js")
119
+ let ran = false
120
+ registerDevShutdown(async () => {
121
+ ran = true
122
+ })
123
+ requestDevShutdown()
124
+ await vi.waitFor(() => expect(exitSpy).toHaveBeenCalledWith(0))
125
+ expect(ran).toBe(true)
126
+ })
127
+
128
+ it("force-exits 130 on second interrupt", async () => {
129
+ vi.resetModules()
130
+ const { registerDevShutdown, requestDevShutdown } = await import("../src/dev-shutdown.js")
131
+ registerDevShutdown(async () => {
132
+ await new Promise(() => undefined)
133
+ })
134
+ requestDevShutdown()
135
+ await vi.waitFor(() => expect(exitSpy).toHaveBeenCalledTimes(0))
136
+ requestDevShutdown()
137
+ expect(exitSpy).toHaveBeenCalledWith(130)
138
+ })
139
+ })
@@ -0,0 +1,39 @@
1
+ import { describe, expect, it } from "vitest"
2
+ import {
3
+ containerName,
4
+ dockerPgLoopbackDbUrl,
5
+ dockerPgPostInitServing,
6
+ } from "../src/docker-postgres.js"
7
+
8
+ describe("docker-postgres", () => {
9
+ it("derives container name from project name", () => {
10
+ expect(containerName("supatype-integration")).toBe("supatype-supatype-integration")
11
+ })
12
+
13
+ it("detects post-init serving after first-boot init", () => {
14
+ const logs = [
15
+ "PostgreSQL init process complete; ready for start up.",
16
+ "database system is ready to accept connections",
17
+ ].join("\n")
18
+ expect(dockerPgPostInitServing(logs)).toBe(true)
19
+ })
20
+
21
+ it("detects post-init serving on reused volume (no init banner this run)", () => {
22
+ const logs = "database system is ready to accept connections\n"
23
+ expect(dockerPgPostInitServing(logs)).toBe(true)
24
+ })
25
+
26
+ it("builds loopback DB URL for in-container migrate", () => {
27
+ expect(dockerPgLoopbackDbUrl("my-project")).toBe(
28
+ "postgres://supatype_admin:postgres@127.0.0.1:5432/my-project?sslmode=disable",
29
+ )
30
+ })
31
+
32
+ it("rejects ready line before init complete on first boot", () => {
33
+ const logs = [
34
+ "database system is ready to accept connections",
35
+ "PostgreSQL init process complete; ready for start up.",
36
+ ].join("\n")
37
+ expect(dockerPgPostInitServing(logs)).toBe(false)
38
+ })
39
+ })