@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,45 @@
1
+ /**
2
+ * supatype self-update — Phase 10.6C8.
3
+ *
4
+ * npm-installed CLI: instruct to use `npm update -g`.
5
+ * Standalone / future curl|sh installs: CDN-published CLI binary replacement is not wired yet.
6
+ */
7
+
8
+ import type { Command } from "commander"
9
+ import { sep } from "node:path"
10
+
11
+ function looksLikeNpmOrWorkspaceCLI(): boolean {
12
+ const main = process.argv[1] ?? ""
13
+ return (
14
+ main.includes("node_modules") ||
15
+ main.includes(`${sep}dist${sep}cli`) ||
16
+ main.includes(`${sep}bin${sep}supatype.js`) ||
17
+ Boolean(process.env["npm_execpath"]) ||
18
+ Boolean(process.env["npm_lifecycle_event"])
19
+ )
20
+ }
21
+
22
+ export function registerSelfUpdate(program: Command): void {
23
+ program
24
+ .command("self-update")
25
+ .description(
26
+ "Update the supatype CLI (npm: use npm update; standalone binary swap from CDN is not available yet)",
27
+ )
28
+ .action(() => {
29
+ if (looksLikeNpmOrWorkspaceCLI()) {
30
+ console.log(
31
+ "This CLI was installed via npm (or runs from the package workspace).\n" +
32
+ "Update with:\n\n npm update -g @supatype/cli\n\n" +
33
+ "To bump engine/server/postgres/deno pinned in supatype.config.ts, use:\n\n supatype update\n",
34
+ )
35
+ return
36
+ }
37
+
38
+ console.error(
39
+ "Standalone CLI self-update (replace binary from CDN) is not published yet.\n\n" +
40
+ "Install or upgrade via npm:\n npm install -g @supatype/cli\n\n" +
41
+ "Component binaries (engine, server, postgres, deno):\n supatype update\n",
42
+ )
43
+ process.exit(1)
44
+ })
45
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * supatype status — show current state of local dev services.
3
+ */
4
+ import type { Command } from "commander"
5
+ import { spawnSync } from "node:child_process"
6
+ import { LOCAL_KONG_HOST_PORT, localKongBaseUrl } from "../local-gateway.js"
7
+
8
+ interface ServiceStatus {
9
+ name: string
10
+ container: string
11
+ status: "running" | "stopped" | "error"
12
+ port?: number
13
+ uptime?: string
14
+ }
15
+
16
+ export function registerStatus(program: Command): void {
17
+ program
18
+ .command("status")
19
+ .description("Show current state of local dev services")
20
+ .action(() => {
21
+ const services: ServiceStatus[] = [
22
+ { name: "Postgres", container: "supatype-postgres", port: 5432 },
23
+ { name: "PostgREST", container: "supatype-postgrest", port: 3000 },
24
+ { name: "GoTrue", container: "supatype-gotrue", port: 9999 },
25
+ { name: "Kong", container: "supatype-kong", port: LOCAL_KONG_HOST_PORT },
26
+ { name: "MinIO", container: "supatype-minio", port: 9000 },
27
+ { name: "Realtime", container: "supatype-realtime", port: 4000 },
28
+ { name: "Studio", container: "supatype-studio", port: 3100 },
29
+ ].map((svc) => {
30
+ const status = getContainerStatus(svc.container)
31
+ const uptime = getContainerUptime(svc.container)
32
+ return { ...svc, status, ...(uptime !== undefined && { uptime }) }
33
+ })
34
+
35
+ console.log("Supatype Local Development Stack\n")
36
+
37
+ const maxName = Math.max(...services.map((s) => s.name.length))
38
+ for (const svc of services) {
39
+ const icon = svc.status === "running" ? "●" : svc.status === "stopped" ? "○" : "✕"
40
+ const status = svc.status.padEnd(8)
41
+ const port = svc.port ? `:${svc.port}` : ""
42
+ const uptime = svc.uptime ? ` (${svc.uptime})` : ""
43
+ console.log(` ${icon} ${svc.name.padEnd(maxName)} ${status} ${port}${uptime}`)
44
+ }
45
+
46
+ const running = services.filter((s) => s.status === "running")
47
+ console.log(`\n${running.length}/${services.length} services running`)
48
+
49
+ if (running.length > 0) {
50
+ console.log(`\nAPI URL: ${localKongBaseUrl()}`)
51
+ console.log(`Studio: http://localhost:3100`)
52
+ console.log(`Database: postgresql://supatype_admin:postgres@localhost:5432/postgres`)
53
+ }
54
+ })
55
+ }
56
+
57
+ function getContainerStatus(name: string): "running" | "stopped" | "error" {
58
+ const result = spawnSync("docker", ["inspect", "--format", "{{.State.Status}}", name], {
59
+ timeout: 5000,
60
+ })
61
+ const status = result.stdout?.toString().trim()
62
+ if (status === "running") return "running"
63
+ if (result.status !== 0) return "stopped"
64
+ return "error"
65
+ }
66
+
67
+ function getContainerUptime(name: string): string | undefined {
68
+ const result = spawnSync("docker", ["inspect", "--format", "{{.State.StartedAt}}", name], {
69
+ timeout: 5000,
70
+ })
71
+ if (result.status !== 0) return undefined
72
+ const startedAt = result.stdout?.toString().trim()
73
+ if (!startedAt) return undefined
74
+
75
+ const started = new Date(startedAt)
76
+ const now = new Date()
77
+ const diffMs = now.getTime() - started.getTime()
78
+ if (diffMs < 0) return undefined
79
+
80
+ const hours = Math.floor(diffMs / (1000 * 60 * 60))
81
+ const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60))
82
+ if (hours > 0) return `${hours}h ${minutes}m`
83
+ return `${minutes}m`
84
+ }
@@ -0,0 +1,76 @@
1
+ import type { Command } from "commander"
2
+ import { existsSync, readFileSync } from "node:fs"
3
+ import { resolve, relative } from "node:path"
4
+ import ts from "typescript"
5
+ import { loadConfig } from "../config.js"
6
+
7
+ export function registerTypes(program: Command): void {
8
+ const types = program.command("types").description("Type generation and validation utilities")
9
+
10
+ types
11
+ .command("check")
12
+ .description("Validate generated client augmentation wiring")
13
+ .action(() => {
14
+ const cwd = process.cwd()
15
+ const config = loadConfig(cwd)
16
+ const augmentationPath = resolve(cwd, config.output?.client ?? "supatype/generated/index.d.ts")
17
+
18
+ const errors: string[] = []
19
+
20
+ if (!existsSync(augmentationPath)) {
21
+ errors.push(
22
+ `Missing generated augmentation file: ${relative(cwd, augmentationPath)}.\nRun: supatype generate`,
23
+ )
24
+ }
25
+
26
+ const tsconfigPath = resolve(cwd, "tsconfig.json")
27
+ if (!existsSync(tsconfigPath)) {
28
+ errors.push("Missing tsconfig.json in project root.")
29
+ } else {
30
+ const tsconfigRaw = readFileSync(tsconfigPath, "utf8")
31
+ const parsed = ts.parseConfigFileTextToJson(tsconfigPath, tsconfigRaw)
32
+ const cfg = (parsed.config ?? {}) as { include?: unknown; files?: unknown }
33
+ const include = Array.isArray(cfg.include) ? cfg.include.map(String) : []
34
+ const files = Array.isArray(cfg.files) ? cfg.files.map(String) : []
35
+ const relAug = toPosix(relative(cwd, augmentationPath))
36
+ const coveredByFiles = files.includes(relAug)
37
+ const coveredByInclude = include.some((entry) => {
38
+ if (entry.includes("**")) return relAug.startsWith(entry.split("**")[0] ?? "")
39
+ if (entry.endsWith("*.ts") || entry.endsWith("*.d.ts")) {
40
+ return relAug.startsWith(entry.replace(/\*\.d?ts$/, ""))
41
+ }
42
+ return relAug === entry || relAug.startsWith(entry.replace(/\/$/, "") + "/")
43
+ })
44
+ if (!coveredByFiles && !coveredByInclude) {
45
+ errors.push(
46
+ `tsconfig.json does not include ${relAug}. Add it to "include" or "files" so module augmentation is visible to TypeScript.`,
47
+ )
48
+ }
49
+ }
50
+
51
+ const packageJsonPath = resolve(cwd, "package.json")
52
+ if (existsSync(packageJsonPath)) {
53
+ const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8")) as {
54
+ dependencies?: Record<string, string>
55
+ devDependencies?: Record<string, string>
56
+ }
57
+ const hasClient =
58
+ (pkg.dependencies && "@supatype/client" in pkg.dependencies) ||
59
+ (pkg.devDependencies && "@supatype/client" in pkg.devDependencies)
60
+ if (!hasClient) {
61
+ errors.push('package.json is missing "@supatype/client" dependency.')
62
+ }
63
+ }
64
+
65
+ if (errors.length > 0) {
66
+ for (const err of errors) console.error(`- ${err}`)
67
+ process.exit(1)
68
+ }
69
+
70
+ console.log("types check passed")
71
+ })
72
+ }
73
+
74
+ function toPosix(path: string): string {
75
+ return path.replace(/\\/g, "/")
76
+ }
@@ -0,0 +1,136 @@
1
+ /**
2
+ * supatype update — bump component versions in supatype.config.ts
3
+ * and download the new binaries.
4
+ */
5
+
6
+ import type { Command } from "commander"
7
+ import { existsSync, readFileSync, writeFileSync } from "node:fs"
8
+ import { basename, resolve } from "node:path"
9
+ import { loadConfig } from "../config.js"
10
+ import { resolveRuntimeProvider } from "../project-config.js"
11
+ import { runDockerCompose, writeSelfHostCompose } from "../self-host-compose.js"
12
+ import { syncComposeImagePins } from "../dev-compose.js"
13
+ import { download, currentPlatform, fetchAllLatestVersions, pinnedVersion, type Component } from "../binary-cache.js"
14
+
15
+ const CONFIG_CANDIDATES = ["supatype.config.ts", "supatype.config.js", "supatype.config.mjs"]
16
+
17
+ function resolveConfigFile(cwd: string): string | null {
18
+ for (const name of CONFIG_CANDIDATES) {
19
+ const p = resolve(cwd, name)
20
+ if (existsSync(p)) return p
21
+ }
22
+ return null
23
+ }
24
+
25
+ export function registerUpdate(program: Command): void {
26
+ program
27
+ .command("update")
28
+ .description(
29
+ "Download the latest component binaries and update versions in supatype.config.ts",
30
+ )
31
+ .option("--check", "Print available updates without downloading", false)
32
+ .action(async (opts: { check: boolean }) => {
33
+ const cwd = process.cwd()
34
+ const config = loadConfig(cwd)
35
+ const provider = resolveRuntimeProvider(config)
36
+
37
+ if (provider === "docker") {
38
+ if (opts.check) {
39
+ console.log("Docker provider: run without --check to pull compose images (supatype self-host compose pull).")
40
+ return
41
+ }
42
+ const paths = writeSelfHostCompose(cwd, config, { devLocal: true })
43
+ syncComposeImagePins(cwd, config)
44
+ console.log("Pulling self-host compose images...")
45
+ const status = runDockerCompose(paths.composePath, ["pull"], cwd)
46
+ if (status !== 0) process.exit(status)
47
+ console.log("Compose images updated.")
48
+ return
49
+ }
50
+
51
+ const platform = currentPlatform()
52
+
53
+ const components: Component[] = ["engine", "server", "postgres", "deno"]
54
+ const updates: Array<{ component: Component; from: string; to: string }> = []
55
+
56
+ console.log("Fetching latest component versions from CDN...")
57
+ const latestVersions = await fetchAllLatestVersions()
58
+
59
+ for (const component of components) {
60
+ const latest = latestVersions[component]
61
+ const current = pinnedVersion(component, config)
62
+ if (!current) {
63
+ if (opts.check) {
64
+ console.log(` ${component} (latest) → ${latest} on CDN`)
65
+ } else {
66
+ console.log(`\nDownloading latest ${component} v${latest}...`)
67
+ try {
68
+ await download(component, latest, platform)
69
+ console.log(` ${component} v${latest} downloaded.`)
70
+ } catch (err) {
71
+ console.error(` Failed: ${(err as Error).message}`)
72
+ }
73
+ }
74
+ continue
75
+ }
76
+ if (current === "local") continue
77
+ if (current !== latest) {
78
+ updates.push({ component, from: current, to: latest })
79
+ }
80
+ }
81
+
82
+ if (updates.length === 0) {
83
+ console.log(opts.check ? "All pinned components match CDN latest." : "All components are up to date.")
84
+ return
85
+ }
86
+
87
+ console.log("Available updates:")
88
+ for (const { component, from, to } of updates) {
89
+ console.log(` ${component} ${from} → ${to}`)
90
+ }
91
+
92
+ if (opts.check) return
93
+
94
+ // Download updated binaries.
95
+ for (const { component, to } of updates) {
96
+ console.log(`\nDownloading ${component} v${to}...`)
97
+ try {
98
+ await download(component, to, platform)
99
+ } catch (err) {
100
+ console.error(` Failed: ${(err as Error).message}`)
101
+ continue
102
+ }
103
+ console.log(` ${component} v${to} downloaded.`)
104
+ }
105
+
106
+ const configPath = resolveConfigFile(cwd)
107
+ if (configPath === null) {
108
+ console.error("No supatype.config.ts (or .js/.mjs) found to patch versions.")
109
+ process.exit(1)
110
+ }
111
+
112
+ let text = readFileSync(configPath, "utf8")
113
+ for (const { component, to } of updates) {
114
+ const key = component
115
+ if (text.includes(`${key}:`)) {
116
+ text = text.replace(
117
+ new RegExp(`(${key}\\s*:\\s*['"])[^'"]*(['"])`),
118
+ `$1${to}$2`,
119
+ )
120
+ } else if (text.includes("versions:")) {
121
+ text = text.replace(
122
+ /(versions:\s*\{[^}]*)(\})/,
123
+ `$1,\n ${key}: "${to}"$2`,
124
+ )
125
+ } else {
126
+ text = text.replace(
127
+ /(\n)(\s*)(email:|schema:|storage:)/,
128
+ `$1$2versions: {\n$2 ${key}: "${to}",\n$2},\n$2$3`,
129
+ )
130
+ }
131
+ }
132
+
133
+ writeFileSync(configPath, text, "utf8")
134
+ console.log(`\n${basename(configPath)} updated.`)
135
+ })
136
+ }
@@ -0,0 +1,6 @@
1
+ /** CDN-cached binaries resolved by the CLI (`engine`, `server`, `postgres`, `deno`). */
2
+ export const BINARY_COMPONENTS = ["engine", "server", "postgres", "deno"] as const
3
+
4
+ export type Component = (typeof BINARY_COMPONENTS)[number]
5
+
6
+ export type ComponentVersions = Record<Component, string>
package/src/config.ts ADDED
@@ -0,0 +1,223 @@
1
+ import { existsSync, readFileSync, writeFileSync, unlinkSync } from "node:fs"
2
+ import { resolve } from "node:path"
3
+ import { tmpdir } from "node:os"
4
+ import { join } from "node:path"
5
+ import { evalTsSnippet } from "./tsx-runner.js"
6
+ import {
7
+ mergeProjectConfig,
8
+ validateProjectConfig,
9
+ type SupatypeProjectConfig,
10
+ } from "./project-config.js"
11
+ import { extractSchemaAstFromTypes } from "./type-extractor.js"
12
+
13
+ export type { SupatypeProjectConfig } from "./project-config.js"
14
+
15
+ /** Canonical project configuration shape (alias for clarity at call sites). */
16
+ export type SupatypeConfig = SupatypeProjectConfig
17
+
18
+ export interface ServiceVersionPin {
19
+ /** Docker image tag to pin this service to (e.g. "v1.2.3"). When set, `self-host upgrade` skips this service. */
20
+ version: string
21
+ }
22
+
23
+ export interface SelfHostConfig {
24
+ /** Production domain (e.g. "api.example.com"). Used by Caddy for HTTPS. */
25
+ domain: string
26
+ /** App service to include in the production stack. */
27
+ app?: {
28
+ /** Path to the app's Dockerfile, relative to the project root. */
29
+ dockerfile: string
30
+ /** Port the app listens on. */
31
+ port: number
32
+ }
33
+ ssl?: {
34
+ /** SSL provider. "caddy" = automatic Let's Encrypt. "none" = bring your own. */
35
+ provider: "caddy" | "none"
36
+ /** Email for Let's Encrypt registration (required when provider = "caddy"). */
37
+ email?: string
38
+ }
39
+ /**
40
+ * Pin specific services to fixed Docker image versions.
41
+ * When a service is pinned, `self-host upgrade` will skip it.
42
+ * Omit a service or set to `undefined` to allow automatic upgrades.
43
+ */
44
+ services?: {
45
+ db?: ServiceVersionPin
46
+ gotrue?: ServiceVersionPin
47
+ postgrest?: ServiceVersionPin
48
+ kong?: ServiceVersionPin
49
+ caddy?: ServiceVersionPin
50
+ pgbouncer?: ServiceVersionPin
51
+ }
52
+ }
53
+
54
+ export type AppFramework = "nextjs" | "astro" | "vite" | "remix-spa" | "sveltekit" | "nuxt" | "static"
55
+
56
+ export interface AppConfig {
57
+ /** Framework name. Auto-detected from package.json if not specified. */
58
+ framework?: AppFramework
59
+ /** Path to the app directory (default: "./" or "./apps/web" for monorepos). */
60
+ directory?: string
61
+ /** Build command (inferred from framework if not specified). */
62
+ buildCommand?: string
63
+ /** Output directory (inferred from framework if not specified). */
64
+ outputDirectory?: string
65
+ /** Enable SPA fallback routing (default: true for Vite/CRA, false for SSG frameworks). */
66
+ spa?: boolean
67
+ /** Environment variables to inject during build. */
68
+ env?: Record<string, string>
69
+ /** Custom response headers for the static site. */
70
+ headers?: Record<string, string>
71
+ }
72
+
73
+ /** Identity helper — provides type inference for config files. */
74
+ export function defineConfig(config: SupatypeProjectConfig): SupatypeProjectConfig {
75
+ return config
76
+ }
77
+
78
+ const LEGACY_TOML = "supatype.config.toml"
79
+
80
+ const MAIN_CONFIG_CANDIDATES = [
81
+ "supatype.config.ts",
82
+ "supatype.config.js",
83
+ "supatype.config.mjs",
84
+ ]
85
+
86
+ const LOCAL_CONFIG_CANDIDATES = [
87
+ "supatype.local.config.ts",
88
+ "supatype.local.config.js",
89
+ "supatype.local.config.mjs",
90
+ ]
91
+
92
+ /**
93
+ * Normalize a config object parsed from JSON (e.g. shorthand `schema: "./x"`).
94
+ */
95
+ function normalizeProjectJson(raw: unknown): unknown {
96
+ if (typeof raw !== "object" || raw === null) return raw
97
+ const o = { ...(raw as Record<string, unknown>) }
98
+ const sch = o["schema"]
99
+ if (typeof sch === "string") {
100
+ o["schema"] = {
101
+ path: sch,
102
+ pg_schema: typeof o["pg_schema"] === "string" ? o["pg_schema"] : "public",
103
+ }
104
+ delete o["pg_schema"]
105
+ }
106
+ return o
107
+ }
108
+
109
+ /**
110
+ * Load project config from `supatype.config.ts` (or .js/.mjs), merged with
111
+ * optional `supatype.local.config.*` (gitignored overrides).
112
+ */
113
+ export function loadConfig(cwd: string = process.cwd()): SupatypeProjectConfig {
114
+ if (existsSync(resolve(cwd, LEGACY_TOML))) {
115
+ throw new Error(
116
+ `Found ${LEGACY_TOML}, which is no longer supported.\n` +
117
+ "Move settings into supatype.config.ts (export default { project, database, server, app, versions, … }).\n" +
118
+ "Run `supatype init` in a new folder for a fresh template.",
119
+ )
120
+ }
121
+
122
+ const baseRaw = loadFirstTsConfig(cwd, MAIN_CONFIG_CANDIDATES)
123
+ if (baseRaw === null) {
124
+ throw new Error(
125
+ "No supatype.config.ts (or .js/.mjs) found in the current directory.\n" +
126
+ "Run: supatype init",
127
+ )
128
+ }
129
+
130
+ const baseNorm = normalizeProjectJson(baseRaw)
131
+ const base = validateProjectConfig(baseNorm, "supatype.config.ts")
132
+
133
+ const localRaw = loadFirstTsConfig(cwd, LOCAL_CONFIG_CANDIDATES)
134
+ if (localRaw === null) return base
135
+
136
+ const localNorm = normalizeProjectJson(localRaw) as Partial<SupatypeProjectConfig>
137
+ return mergeProjectConfig(base, localNorm)
138
+ }
139
+
140
+ function loadFirstTsConfig(
141
+ cwd: string,
142
+ candidates: string[],
143
+ ): Record<string, unknown> | null {
144
+ for (const candidate of candidates) {
145
+ const configPath = resolve(cwd, candidate)
146
+ if (!existsSync(configPath)) continue
147
+
148
+ const urlPath = "file:///" + configPath.replace(/\\/g, "/")
149
+ const snippet = `
150
+ const mod = await import(${JSON.stringify(urlPath)})
151
+ const config = mod.default ?? mod
152
+ process.stdout.write(JSON.stringify(config))
153
+ `
154
+ const result = evalTsSnippet(snippet, { cwd })
155
+ if (result.exitCode === 0) {
156
+ return JSON.parse(result.stdout) as Record<string, unknown>
157
+ }
158
+
159
+ const failure = result.stderr || result.stdout
160
+ if (!failure.includes("ERR_PACKAGE_PATH_NOT_EXPORTED")) {
161
+ throw new Error(`Failed to load ${candidate}:\n${failure}`)
162
+ }
163
+
164
+ const fallback = loadTsConfigWithoutCliImport(configPath, cwd)
165
+ if (fallback !== null) return fallback
166
+ throw new Error(`Failed to load ${candidate}:\n${failure}`)
167
+ }
168
+ return null
169
+ }
170
+
171
+ function loadTsConfigWithoutCliImport(
172
+ configPath: string,
173
+ cwd: string,
174
+ ): Record<string, unknown> | null {
175
+ const original = readFileSync(configPath, "utf8")
176
+ const patched = original
177
+ .replace(/^import\s+type\s+\{[^}]*\}\s+from\s+["']@supatype\/cli["'];?\s*$/gm, "")
178
+ .replace(/^import\s+\{[^}]*defineConfig[^}]*\}\s+from\s+["']@supatype\/cli["'];?\s*$/gm, "")
179
+
180
+ // If the file didn't import from @supatype/cli, this fallback won't help.
181
+ if (patched === original) return null
182
+
183
+ const tmpPath = join(tmpdir(), `supatype-config-fallback-${Date.now()}.mts`)
184
+ const wrapper = `const defineConfig = (config) => config\n${patched}`
185
+ writeFileSync(tmpPath, wrapper, "utf8")
186
+ try {
187
+ const urlPath = "file:///" + tmpPath.replace(/\\/g, "/")
188
+ const snippet = `
189
+ const mod = await import(${JSON.stringify(urlPath)})
190
+ const config = mod.default ?? mod
191
+ process.stdout.write(JSON.stringify(config))
192
+ `
193
+ const result = evalTsSnippet(snippet, { cwd })
194
+ if (result.exitCode !== 0) return null
195
+ return JSON.parse(result.stdout) as Record<string, unknown>
196
+ } finally {
197
+ try {
198
+ unlinkSync(tmpPath)
199
+ } catch {
200
+ // ignore cleanup errors
201
+ }
202
+ }
203
+ }
204
+
205
+ /** Load schema AST by evaluating the user's schema entry point via tsx. */
206
+ export function loadSchemaAst(
207
+ schemaPath: string,
208
+ cwd: string = process.cwd(),
209
+ ): unknown {
210
+ const extracted = extractSchemaAstFromTypes(schemaPath, cwd)
211
+ if (extracted !== null) return extracted
212
+
213
+ const absPath = resolve(cwd, schemaPath)
214
+ if (!existsSync(absPath)) {
215
+ throw new Error(`Schema file not found: ${absPath}`)
216
+ }
217
+
218
+ throw new Error(
219
+ "Runtime model() schemas are no longer supported.\n" +
220
+ `Could not extract type-based models from: ${absPath}\n` +
221
+ "Migrate this file to @supatype/types Model<> definitions (or run `supatype migrate-from-v1`).",
222
+ )
223
+ }