@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
@@ -5,8 +5,12 @@ import { p, runClackFlow } from "../ui/clack.js";
5
5
  import { withProgressView } from "../ui/progress.js";
6
6
  import { installCommand, installDependencies, plainStepView, runTimedStep, spinnerStepView, } from "../init-setup-steps.js";
7
7
  import { ensureNotCancelled } from "../ui/prompts.js";
8
+ import { adminEmailProblem, answerProblem, askText, smtpHostProblem, smtpPortProblem } from "../init-answers.js";
9
+ import { assertEnvValues } from "../env-value.js";
10
+ import { ensureFunctionsEnvLocal, FUNCTIONS_ENV_LOCAL } from "../functions-env-local.js";
8
11
  import { generateAndWriteKeys } from "./keys.js";
9
- import { BUNDLED_DB_USER, CONTROL_PLANE_SECRET_ENV, generateControlPlaneSecret, givenJwtSecret, newJwtSecret, } from "../local-secrets.js";
12
+ import { BUNDLED_DB_USER, CONTROL_PLANE_SECRET_ENV, generateControlPlaneSecret, generateObjectStoreCredentials, givenJwtSecret, KEYSPACE_PASSWORD_ENV, KEYSPACE_USERNAME, newJwtSecret, OBJECT_STORE_ACCESS_KEY_ENV, OBJECT_STORE_SECRET_KEY_ENV, } from "../local-secrets.js";
13
+ import { KEYSPACE_PASSWORD_FILE_ENV, shellNamesKeyspacePasswordFile } from "../keyspace-password-file.js";
10
14
  import { file, error, info, plain, warn } from "../ui/messages.js";
11
15
  import { nextSteps } from "../ui/next-steps.js";
12
16
  import { probeDockerDaemonAsync, reportDockerUnavailable } from "../docker-runtime.js";
@@ -14,18 +18,25 @@ import { loadConfig } from "../config.js";
14
18
  import { ensureComponentBinaries, reportComponentBinaryFailures, } from "../ensure-component-binaries.js";
15
19
  import { ensureFunctionsDenoTypes, sharedFunctionsReadmeSource, } from "../functions-deno-types.js";
16
20
  import { functionTemplateSource } from "../functions-template.js";
17
- import { mergeSupatypePackageJson, PREPARE_COMMAND, scaffoldPackageJson, supatypeDevScript, } from "../init-package-json.js";
21
+ import { mergeSupatypePackageJson, mergeSupatypeScripts, PREPARE_COMMAND, scaffoldPackageJson, } from "../init-package-json.js";
22
+ import { runsSupatypeDev } from "../dev-self-start.js";
23
+ import { DEFAULT_PROXY_DEV_SCRIPT } from "../app/proxy-dev-app.js";
18
24
  import { downloadRelease, initFromExample } from "../init-example.js";
19
25
  import { errorMessage } from "../error-message.js";
20
26
  import { isJsonObject, parseJsonObject } from "@supatype/shared";
21
27
  import { cliPackageVersion } from "../cli-package-version.js";
22
28
  import { initDependencyVersionsFallback, resolveInitDependencyVersions, } from "../init-dependency-versions.js";
23
- import { detectProjectSetup } from "../init-project-detect.js";
24
- import { SUPATYPE_GITIGNORE_PATHS } from "../gitignore.js";
29
+ import { detectProjectSetup, readPackageJson, VITE_CONFIG_NAMES, withFreeVitePort, } from "../init-project-detect.js";
30
+ import { missingSupatypeIgnores, negationOverrideNotice, SUPATYPE_GITIGNORE_PATHS, withSupatypeIgnores, } from "../gitignore.js";
25
31
  import { DEV_FRONTEND_ENV_FILE, writeFrontendEnv } from "../frontend-env.js";
26
32
  import { DEFAULT_CLIENT_PATH, DEFAULT_TYPES_PATH } from "../type-generation.js";
27
33
  import { COMPOSE_DEV_KONG_PORT, defaultAppStaticDir, NATIVE_DB_PORT, NATIVE_SERVER_PORT, nativeDatabaseUrl, VITE_BUILD_DIR, } from "../project-config.js";
28
34
  import { cliDatabaseUrlLines } from "../database-url-owner.js";
35
+ import { scaffoldNextRuntimeEnv } from "../init-next-runtime-env.js";
36
+ import { scaffoldExpoRuntimeEnv } from "../init-expo-runtime-env.js";
37
+ import { refuseAddingViteOnOldNode, refuseViteOnOldNode } from "../init-vite-node.js";
38
+ import { recordInitKongPort } from "../init-port-registry.js";
39
+ import { MAILER_AUTOCONFIRM_NOTE } from "../mailer-autoconfirm.js";
29
40
  const STORAGE_PROVIDER_OPTIONS = [
30
41
  { value: "local", label: "Local", hint: "storage you host yourself (SeaweedFS)" },
31
42
  { value: "s3", label: "S3", hint: "external bucket (AWS S3 or compatible)" },
@@ -136,6 +147,7 @@ async function createProject(args) {
136
147
  if (name)
137
148
  mkdirSync(dir, { recursive: true });
138
149
  scaffold(dir, result, await args.deps);
150
+ recordScaffoldedKongPort(dir, result);
139
151
  const outcome = await withStepView((view) => runSetupSteps(dir, result.packageManager, wants, view));
140
152
  exitOnFailedSetup(outcome, wants, result.packageManager);
141
153
  await warnDockerUnavailableForProvider(result.provider, args.daemon);
@@ -145,7 +157,6 @@ async function createProject(args) {
145
157
  installed: wants.install && outcome.installOk,
146
158
  keysGenerated: outcome.keysGenerated,
147
159
  binariesReady: outcome.binariesReady,
148
- devScript: projectDevScript(dir),
149
160
  });
150
161
  }
151
162
  /** `--no-admin`, or `--admin-email` with `--admin-password`, over the answers. */
@@ -155,16 +166,28 @@ function applyAdminFlags(result, opts) {
155
166
  delete result.adminPassword;
156
167
  }
157
168
  else if (opts.adminEmail && opts.adminPassword) {
158
- result.adminEmail = opts.adminEmail;
169
+ refuseAdminFlags(opts.adminEmail, opts.adminPassword);
170
+ result.adminEmail = opts.adminEmail.trim();
159
171
  result.adminPassword = opts.adminPassword;
160
172
  }
161
173
  }
174
+ /** Exits before anything is written when the admin flags hold what the prompts would refuse. */
175
+ function refuseAdminFlags(email, password) {
176
+ const emailProblem = adminEmailProblem(email);
177
+ const passwordProblem = answerProblem(password);
178
+ if (emailProblem !== undefined)
179
+ error(`--admin-email: ${emailProblem}`);
180
+ if (passwordProblem !== undefined)
181
+ error(`--admin-password: ${passwordProblem}`);
182
+ if (emailProblem !== undefined || passwordProblem !== undefined)
183
+ process.exit(1);
184
+ }
162
185
  /** Interactive init: one Ink session for wizard + scaffold + install + finish. */
163
186
  async function runInteractiveInit(args) {
164
187
  const { name, dir, defaultName, modeTarget, opts } = args;
165
188
  await runClackFlow(async () => {
166
189
  p.intro("Create a new Supatype project");
167
- const detected = detectProjectSetup(dir);
190
+ const detected = await withFreeVitePort(detectProjectSetup(dir));
168
191
  if (detected.hasExistingFiles && detected.summaryLines.length > 0) {
169
192
  p.note(["Existing project detected:", ...detected.summaryLines.map((line) => ` • ${line}`)].join("\n"));
170
193
  }
@@ -201,23 +224,7 @@ export async function collectWizardAnswers(context) {
201
224
  { value: "later", label: "Decide later", hint: "local development only for now" },
202
225
  ],
203
226
  }));
204
- let domain;
205
- let tlsEmail;
206
- if (productionTarget === "self-host") {
207
- domain = ensureNotCancelled(await p.text({
208
- message: "Production domain for ACME TLS (optional, can set later)",
209
- placeholder: "api.example.com",
210
- defaultValue: "",
211
- })).trim();
212
- if (domain) {
213
- tlsEmail =
214
- ensureNotCancelled(await p.text({
215
- message: "Email for Let's Encrypt (HTTPS) certificates",
216
- placeholder: "you@example.com",
217
- defaultValue: "",
218
- })).trim() || undefined;
219
- }
220
- }
227
+ const tls = productionTarget === "self-host" ? await promptSelfHostTls() : {};
221
228
  const provider = ensureNotCancelled(await p.select({
222
229
  message: "How should Postgres and the server run for local development?",
223
230
  initialValue: "docker",
@@ -243,6 +250,8 @@ export async function collectWizardAnswers(context) {
243
250
  { value: "ses", label: "Amazon SES" },
244
251
  ],
245
252
  }));
253
+ // Without a host the server uses its noop mailer and drops every email (issue 76).
254
+ const smtp = email === "smtp" ? await promptSmtpServer() : undefined;
246
255
  const storageLocal = ensureNotCancelled(await p.select({
247
256
  message: "Local storage (for development)?",
248
257
  initialValue: "local",
@@ -259,11 +268,11 @@ export async function collectWizardAnswers(context) {
259
268
  provider,
260
269
  ...(kongPort !== undefined ? { kongPort } : {}),
261
270
  productionTarget,
262
- ...(domain !== undefined ? { domain } : {}),
263
- ...(tlsEmail !== undefined ? { tlsEmail } : {}),
271
+ ...tls,
264
272
  schemaPath,
265
273
  app,
266
274
  email,
275
+ ...(smtp !== undefined && { smtp }),
267
276
  storageLocal,
268
277
  storageProduction,
269
278
  helloFunction,
@@ -273,12 +282,28 @@ export async function collectWizardAnswers(context) {
273
282
  ...admin,
274
283
  };
275
284
  }
285
+ /** The submission port most SMTP servers take, offered as the answer. */
286
+ const SMTP_PORT = "587";
287
+ /** The SMTP server's host and port, both required to send anything. */
288
+ async function promptSmtpServer() {
289
+ const host = (await askText({ message: "SMTP host", placeholder: "smtp.example.com", validate: smtpHostProblem })).trim();
290
+ const port = await askText({ message: "SMTP port", defaultValue: SMTP_PORT, placeholder: SMTP_PORT, validate: smtpPortProblem });
291
+ return { host, port: Number(port.trim() || SMTP_PORT) };
292
+ }
293
+ /** A self-hosted project's domain for ACME TLS, and the email for its certificates when it has one. */
294
+ async function promptSelfHostTls() {
295
+ const domain = (await askText({ message: "Production domain for ACME TLS (optional, can set later)", placeholder: "api.example.com", defaultValue: "" })).trim();
296
+ if (!domain)
297
+ return { domain };
298
+ const tlsEmail = (await askText({ message: "Email for Let's Encrypt (HTTPS) certificates", placeholder: "you@example.com", defaultValue: "" })).trim();
299
+ return { domain, ...(tlsEmail !== "" && { tlsEmail }) };
300
+ }
276
301
  async function promptProjectName(defaultName) {
277
302
  return askWithDefault("Project name", defaultName);
278
303
  }
279
304
  /** A text answer, trimmed, or `defaultValue` when it was left empty. */
280
305
  async function askWithDefault(message, defaultValue) {
281
- return ensureNotCancelled(await p.text({ message, defaultValue })).trim() || defaultValue;
306
+ return (await askText({ message, defaultValue })).trim() || defaultValue;
282
307
  }
283
308
  async function promptProductionStorage() {
284
309
  return ensureNotCancelled(await p.select({
@@ -295,11 +320,7 @@ async function promptAdminUser() {
295
320
  if (!createAdmin)
296
321
  return {};
297
322
  p.note("First sign-in to Studio at /studio/, created automatically on supatype dev or push.");
298
- const adminEmail = ensureNotCancelled(await p.text({
299
- message: "Admin email",
300
- placeholder: "you@example.com",
301
- validate: (value) => (value.trim() ? undefined : "Email is required"),
302
- })).trim();
323
+ const adminEmail = (await askText({ message: "Admin email", placeholder: "you@example.com", validate: adminEmailProblem })).trim();
303
324
  return { adminEmail, adminPassword: await promptAdminPassword() };
304
325
  }
305
326
  /**
@@ -309,8 +330,9 @@ async function promptAdminUser() {
309
330
  async function promptAdminPassword() {
310
331
  while (true) {
311
332
  const password = ensureNotCancelled(await p.password({ message: "Admin password (min 8 characters)" })).trim();
312
- if (password.length < 8) {
313
- p.log.warn("Password must be at least 8 characters.");
333
+ const problem = answerProblem(password) ?? (password.length < 8 ? "Password must be at least 8 characters." : undefined);
334
+ if (problem !== undefined) {
335
+ p.log.warn(problem);
314
336
  continue;
315
337
  }
316
338
  const confirmed = ensureNotCancelled(await p.password({ message: "Confirm admin password" })).trim();
@@ -338,14 +360,44 @@ async function promptApp(detected, productionTarget) {
338
360
  const viteDevUrl = await promptViteDevUrl(detected, productionTarget);
339
361
  return { mode, staticDir: await promptStaticDir(detected, viteDevUrl !== undefined), ...(viteDevUrl ? { viteDevUrl } : {}) };
340
362
  }
341
- if (mode === "proxy") {
342
- const upstream = await askWithDefault("URL of your running dev server", detected.hasVite ? detected.viteDevUrl : "http://localhost:3000");
343
- const start = await askWithDefault("package.json script that starts your dev server", detected.hasVite ? "vite" : "dev");
344
- const viteDevUrl = await promptViteDevUrl(detected, productionTarget);
345
- return { mode, upstream, start, ...(viteDevUrl ? { viteDevUrl } : {}) };
346
- }
363
+ if (mode === "proxy")
364
+ return promptDevServer(detected, productionTarget);
347
365
  return { mode: "none" };
348
366
  }
367
+ /**
368
+ * The dev server "Local dev server" forwards to, with Vite asked first. The script was asked before
369
+ * Vite and offered `dev`, which in a new folder is init's own `supatype dev`, so dev ran itself as
370
+ * the app. A Vite app runs the `vite` script init adds, at Vite's URL. Any other app runs a script
371
+ * of the project's own: its `dev` or `start` is offered, but never one that runs `supatype dev`.
372
+ */
373
+ async function promptDevServer(detected, productionTarget) {
374
+ const viteDevUrl = await promptViteDevUrl(detected, productionTarget);
375
+ if (viteDevUrl !== undefined)
376
+ return { mode: "proxy", upstream: viteDevUrl, start: "vite", viteDevUrl };
377
+ const upstream = await askWithDefault("URL of your running dev server", "http://localhost:3000");
378
+ const scripts = mergeSupatypeScripts(detected.packageScripts, { app: { mode: "proxy" }, helloFunction: false });
379
+ const offered = ["dev", DEFAULT_PROXY_DEV_SCRIPT].find((name) => {
380
+ const body = scripts[name];
381
+ return body !== undefined && !runsSupatypeDev(body);
382
+ });
383
+ const chosen = (answer) => answer.trim() || offered;
384
+ const start = chosen(await askText({
385
+ message: "package.json script that starts your dev server",
386
+ ...(offered !== undefined && { defaultValue: offered, placeholder: offered }),
387
+ validate: (answer) => devServerScriptProblem(chosen(answer), scripts),
388
+ }));
389
+ return { mode: "proxy", upstream, ...(start !== undefined && { start }) };
390
+ }
391
+ /** Why `script` cannot start the app's dev server, or undefined when it can. */
392
+ function devServerScriptProblem(script, scripts) {
393
+ if (script === undefined)
394
+ return `Enter the package.json script that starts your dev server, like ${DEFAULT_PROXY_DEV_SCRIPT}.`;
395
+ const body = scripts[script];
396
+ if (body !== undefined && runsSupatypeDev(body)) {
397
+ return `"${script}" runs supatype dev, so dev would start itself. Enter the script that starts your frontend's dev server.`;
398
+ }
399
+ return undefined;
400
+ }
349
401
  /**
350
402
  * The directory a static site is served from, asked after Vite: it was asked before, so a new Vite
351
403
  * project was offered ./public. A Vite project is offered its build output, ./dist; a site with no
@@ -370,6 +422,10 @@ async function promptViteDevUrl(detected, productionTarget) {
370
422
  }));
371
423
  if (!useVite)
372
424
  return undefined;
425
+ // Refused here on an old Node, not after every other question (pm N2). An app that lists its
426
+ // own Vite keeps it, so its Node is its own business.
427
+ if (!detected.declaresVite)
428
+ refuseAddingViteOnOldNode();
373
429
  return askWithDefault("Vite dev server URL", detected.viteDevUrl);
374
430
  }
375
431
  // ─── Package manager ───────────────────────────────────────────────────────--
@@ -479,6 +535,9 @@ export function scaffold(dir, optsOrName, deps = initDependencyVersionsFallback(
479
535
  writeFileSync(full, content, "utf8");
480
536
  file("created", rel);
481
537
  };
538
+ // First, so a value .env cannot hold is refused before any file is written.
539
+ const env = envTemplate(opts);
540
+ refuseViteOnOldNode(dir, opts.app.viteDevUrl);
482
541
  const pkgPath = join(dir, "package.json");
483
542
  if (!existsSync(pkgPath)) {
484
543
  write("package.json", scaffoldPackageJson(opts, deps));
@@ -491,15 +550,29 @@ export function scaffold(dir, optsOrName, deps = initDependencyVersionsFallback(
491
550
  write("supatype.local.config.ts", localConfigTemplate(opts.app));
492
551
  }
493
552
  write(opts.schemaPath, schemaTemplate());
494
- write(".env", envTemplate(opts));
553
+ write(".env", env);
495
554
  scaffoldDevFrontendEnv(dir, opts);
496
555
  write("seed.ts", seedTemplate(opts.projectName));
497
556
  write("seeds/.gitkeep", "");
498
557
  scaffoldAppAssets(dir, opts, write);
558
+ // The Next.js counterpart of the static page's script tag: the client and @supatype/ssr ship
559
+ // together, so the route's package is added at the client's range.
560
+ scaffoldNextRuntimeEnv(dir, write, `^${deps.client}`);
561
+ // An Expo Router app has neither an index.html nor a root layout: its page is +html.tsx.
562
+ scaffoldExpoRuntimeEnv(dir, write);
499
563
  if (opts.helloFunction)
500
564
  scaffoldHelloFunction(dir, write);
501
565
  scaffoldGitignore(dir, write);
502
566
  }
567
+ /**
568
+ * Record the Kong port the project in `dir` was given, so the next init skips it before this project
569
+ * ever starts (FF26, init-port-registry.ts). Outside `scaffold`, which tests call by the hundred and
570
+ * which writes only inside `dir`; this writes under the home folder.
571
+ */
572
+ export function recordScaffoldedKongPort(dir, opts) {
573
+ if (opts.provider === "docker" && opts.kongPort !== undefined)
574
+ recordInitKongPort(resolve(dir), opts.kongPort);
575
+ }
503
576
  /**
504
577
  * Supatype's scripts and packages merged into the project's own package.json, saying so when its
505
578
  * `prepare` changed: a project's own (husky, say) gets `supatype-prepare` after it, and the one
@@ -549,13 +622,16 @@ function scaffoldGitignore(dir, write) {
549
622
  return;
550
623
  }
551
624
  const existing = readFileSync(gitignorePath, "utf8");
552
- const merged = mergeGitignoreTemplate(existing);
553
- if (merged === existing) {
625
+ const missing = missingSupatypeIgnores(existing);
626
+ if (missing.length === 0) {
554
627
  file("skipped", ".gitignore (already exists)");
555
628
  return;
556
629
  }
557
- writeFileSync(gitignorePath, merged, "utf8");
630
+ writeFileSync(gitignorePath, withSupatypeIgnores(existing, missing), "utf8");
558
631
  file("updated", ".gitignore (added Supatype's local files)");
632
+ const notice = negationOverrideNotice(existing, missing);
633
+ if (notice !== undefined)
634
+ warn(notice);
559
635
  }
560
636
  /**
561
637
  * The directory a static app is served from: the one typed at init, else the stack's own default
@@ -568,24 +644,36 @@ function staticDirOf(app) {
568
644
  function staticDirRelative(staticDir) {
569
645
  return staticDir.trim().replace(/^\.\//, "").replace(/\/+$/, "") || "public";
570
646
  }
647
+ /**
648
+ * Whether the committed config has Supatype serve the app's files: a static app, and a proxied one
649
+ * with a production target, whose committed config serves its build (appConfigLines). Only such a
650
+ * server answers `/supatype-env.js`; a proxied app is served by its own.
651
+ */
652
+ function servedStatically(opts) {
653
+ return opts.app.mode === "static" || (opts.app.mode === "proxy" && opts.productionTarget !== "later");
654
+ }
571
655
  function scaffoldAppAssets(dir, opts, write) {
656
+ const hasVite = Boolean(opts.app.viteDevUrl);
657
+ // The app's own page: a Vite app's is the root index.html, and the one in its build output is rebuilt from it.
658
+ const appPage = (rel) => (hasVite ? rel === "index.html" : rel.endsWith("index.html"));
572
659
  const writeUnlessExists = (rel, content) => {
573
660
  const full = join(dir, rel);
574
661
  if (existsSync(full)) {
575
662
  file("skipped", `${rel} (already exists)`);
663
+ if (servedStatically(opts) && appPage(rel))
664
+ adviseRuntimeEnvScript(full);
576
665
  return;
577
666
  }
578
667
  write(rel, content);
579
668
  };
580
- const holding = holdingPageTemplate(opts.projectName, initLocalApiUrl(opts));
581
- const hasVite = Boolean(opts.app.viteDevUrl);
669
+ const holding = holdingPageTemplate(opts.projectName, initLocalApiUrl(opts), servedStatically(opts));
582
670
  if (opts.app.mode === "static") {
583
671
  writeUnlessExists(`${staticDirRelative(staticDirOf(opts.app))}/index.html`, holding);
584
672
  if (hasVite)
585
673
  scaffoldVite(dir, opts, writeUnlessExists, holding);
586
674
  return;
587
675
  }
588
- if (opts.app.mode === "proxy" && opts.productionTarget !== "later") {
676
+ if (servedStatically(opts)) {
589
677
  writeUnlessExists("dist/index.html", holding);
590
678
  if (hasVite)
591
679
  scaffoldVite(dir, opts, writeUnlessExists, holding);
@@ -601,12 +689,19 @@ function scaffoldVite(dir, opts, write, holding) {
601
689
  if (!opts.app.viteDevUrl)
602
690
  return;
603
691
  write("index.html", holding);
604
- const viteConfigRel = ["vite.config.ts", "vite.config.js", "vite.config.mjs", "vite.config.cjs"].find((name) => existsSync(join(dir, name)));
692
+ const viteConfigRel = VITE_CONFIG_NAMES.find((name) => existsSync(join(dir, name)));
605
693
  if (viteConfigRel) {
606
694
  file("skipped", `${viteConfigRel} (already exists)`);
607
695
  return;
608
696
  }
609
- write("vite.config.ts", viteConfigTemplate(opts.app.viteDevUrl, viteBuildOutDir(opts)));
697
+ write(newViteConfigName(dir), viteConfigTemplate(opts.app.viteDevUrl, viteBuildOutDir(opts)));
698
+ }
699
+ /**
700
+ * `vite.config.ts` in an ESM package, else `vite.config.mts`, which Vite loads as ESM by its
701
+ * extension: init no longer makes an existing app's package ESM (FF24), and the config imports `vite`.
702
+ */
703
+ function newViteConfigName(dir) {
704
+ return readPackageJson(dir)?.raw["type"] === "module" ? "vite.config.ts" : "vite.config.mts";
610
705
  }
611
706
  /**
612
707
  * Where `vite build` writes, when it is not Vite's own `dist`: the static directory a static app is
@@ -624,9 +719,8 @@ function scaffoldHelloFunction(dir, write) {
624
719
  if (!existsSync(join(dir, "functions/_shared/README.md"))) {
625
720
  write("functions/_shared/README.md", sharedFunctionsReadmeSource());
626
721
  }
627
- if (!existsSync(join(dir, "functions/.env.local"))) {
628
- write("functions/.env.local", functionsEnvLocalTemplate());
629
- }
722
+ if (ensureFunctionsEnvLocal(join(dir, "functions")).created)
723
+ file("created", `functions/${FUNCTIONS_ENV_LOCAL}`);
630
724
  const denoTypes = ensureFunctionsDenoTypes(dir, join(dir, "functions"));
631
725
  if (denoTypes.wroteDenoDts)
632
726
  file("created", "functions/deno.d.ts");
@@ -726,18 +820,24 @@ function localConfigTemplate(app) {
726
820
  lines.push(`}`, ``, `export default localConfig`, ``);
727
821
  return lines.join("\n");
728
822
  }
823
+ /**
824
+ * The app block for a dev server. A missing `start` is left out, and dev then runs `start`: it was
825
+ * written as `dev`, which in a new project is init's own `supatype dev`.
826
+ */
827
+ function proxyAppLines(app) {
828
+ return [
829
+ ` app: {`,
830
+ ` mode: "proxy",`,
831
+ ` upstream: "${app.upstream ?? "http://localhost:3000"}",`,
832
+ ...(app.start ? [` start: "${app.start}",`] : []),
833
+ ...(app.viteDevUrl ? [` vite_dev_url: "${app.viteDevUrl}",`] : []),
834
+ ` },`,
835
+ ];
836
+ }
729
837
  /** App block for supatype.local.config.ts (proxy + Vite during local dev). */
730
838
  function localDevAppConfigLines(app) {
731
- if (app.mode === "proxy") {
732
- return [
733
- ` app: {`,
734
- ` mode: "proxy",`,
735
- ` upstream: "${app.upstream ?? "http://localhost:3000"}",`,
736
- ` start: "${app.start ?? "dev"}",`,
737
- ...(app.viteDevUrl ? [` vite_dev_url: "${app.viteDevUrl}",`] : []),
738
- ` },`,
739
- ];
740
- }
839
+ if (app.mode === "proxy")
840
+ return proxyAppLines(app);
741
841
  if (app.viteDevUrl) {
742
842
  return [
743
843
  ` app: {`,
@@ -757,7 +857,7 @@ function appConfigLines(app, productionTarget) {
757
857
  return [` app: {`, ` mode: "static",`, ` static_dir: "${staticDirOf(app)}",${built}`, ` },`];
758
858
  }
759
859
  if (app.mode === "proxy") {
760
- if (productionTarget !== "later") {
860
+ if (servedStatically({ app, productionTarget })) {
761
861
  return [
762
862
  ` app: {`,
763
863
  ` mode: "static",`,
@@ -765,16 +865,7 @@ function appConfigLines(app, productionTarget) {
765
865
  ` },`,
766
866
  ];
767
867
  }
768
- const out = [
769
- ` app: {`,
770
- ` mode: "proxy",`,
771
- ` upstream: "${app.upstream ?? "http://localhost:3000"}",`,
772
- ` start: "${app.start ?? "dev"}",`,
773
- ];
774
- if (app.viteDevUrl)
775
- out.push(` vite_dev_url: "${app.viteDevUrl}",`);
776
- out.push(` },`);
777
- return out;
868
+ return proxyAppLines(app);
778
869
  }
779
870
  return [
780
871
  ` app: {`,
@@ -814,7 +905,32 @@ function initLocalApiUrl(opts) {
814
905
  function initSiteUrl(opts) {
815
906
  return opts.app.mode === "none" ? "http://localhost:3000" : initLocalApiUrl(opts);
816
907
  }
817
- function holdingPageTemplate(projectName, apiUrl) {
908
+ /**
909
+ * The deployment's address and anon key, from the server that serves the page, for a build that
910
+ * carried none. A classic script in the head runs before any module script, wherever the app puts
911
+ * its own. Where no Supatype server answers it (Vite's dev server, opened directly, sends its
912
+ * index.html back) the script fails with one console error and the page runs on: only that script
913
+ * is lost, and the dev build has its values from `.env.development.local` anyway. `vite-ignore`
914
+ * tells Vite to leave the tag as it is: without it, every `vite build` warned that it could not
915
+ * bundle a script the project does not have. Vite drops the attribute from the page it builds, and
916
+ * a browser ignores it in a page nothing builds.
917
+ */
918
+ const RUNTIME_ENV_TAG = '<script src="/supatype-env.js" vite-ignore></script>';
919
+ const RUNTIME_ENV_SCRIPT = `
920
+ <!-- The deployment's API address and anon key, from the server that serves this page.
921
+ vite-ignore tells Vite to leave it out of the bundle, so the build does not warn. -->
922
+ ${RUNTIME_ENV_TAG}`;
923
+ /**
924
+ * The tag for an app's own page, which init keeps. It used to print only "skipped index.html", and
925
+ * a production build of the page then threw MissingClientValuesError (0.9.2 release test round 2,
926
+ * N-S15).
927
+ */
928
+ function adviseRuntimeEnvScript(page) {
929
+ if (readFileSync(page, "utf8").includes("/supatype-env.js"))
930
+ return;
931
+ plain(` add ${RUNTIME_ENV_TAG} to its <head>, so a build Supatype serves gets its API URL and anon key`);
932
+ }
933
+ function holdingPageTemplate(projectName, apiUrl, runtimeEnv) {
818
934
  const name = escapeHtml(projectName);
819
935
  return `<!doctype html>
820
936
  <html lang="en">
@@ -822,7 +938,7 @@ function holdingPageTemplate(projectName, apiUrl) {
822
938
  <meta charset="UTF-8" />
823
939
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
824
940
  <title>${name}: Supatype</title>
825
- <meta name="description" content="A Supatype project. Define your types, we generate your platform." />
941
+ <meta name="description" content="A Supatype project. Define your types, we generate your platform." />${runtimeEnv ? RUNTIME_ENV_SCRIPT : ""}
826
942
  <link rel="preconnect" href="https://fonts.googleapis.com" />
827
943
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
828
944
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
@@ -965,20 +1081,10 @@ ${build} server: {
965
1081
  `;
966
1082
  }
967
1083
  function storageConfigLines(storageLocal, storageProduction) {
968
- const lines = [];
969
- if (storageLocal === "s3") {
970
- lines.push(` storage: { provider: "s3" }, // dev, configure S3_* in .env`);
971
- }
972
- else {
973
- lines.push(` storage: { provider: "local", local_path: ".supatype/storage" },`);
974
- }
975
- if (storageProduction === "s3" && storageLocal !== "s3") {
976
- lines.push(` // Production storage: external S3 bucket, set production S3_* in .env`);
977
- }
978
- else if (storageProduction === "local" && storageLocal === "s3") {
979
- lines.push(` // Production storage: SeaweedFS on your server (included in self-host compose)`);
980
- }
981
- return lines;
1084
+ // provider is dev's, production the self-host stack's; S3_* in .env name the bucket for either.
1085
+ const dev = storageLocal === "s3" ? `provider: "s3"` : `provider: "local", local_path: ".supatype/storage"`;
1086
+ const production = storageLocal === "local" && storageProduction === "local" ? "" : `, production: "${storageProduction}"`;
1087
+ return [` storage: { ${dev}${production} },`];
982
1088
  }
983
1089
  function schemaTemplate() {
984
1090
  return `import type { Model, LoggedIn, Owner, Public, Role, SupatypeAuthUserId, UUID } from "@supatype/types"
@@ -1009,7 +1115,29 @@ export type SiteSettings = Model<{
1009
1115
  }>
1010
1116
  `;
1011
1117
  }
1118
+ /**
1119
+ * The values `.env` takes from what init was told, rather than generates, under the key each is
1120
+ * written as. The project name is the database's name and, for SMTP, the sender's.
1121
+ */
1122
+ function envAnswers(opts) {
1123
+ return {
1124
+ POSTGRES_DB: opts.projectName,
1125
+ ...(opts.adminEmail !== undefined && { SUPATYPE_ADMIN_EMAIL: opts.adminEmail }),
1126
+ ...(opts.adminPassword !== undefined && { SUPATYPE_ADMIN_PASSWORD: opts.adminPassword }),
1127
+ };
1128
+ }
1129
+ /**
1130
+ * The keyspace password's line in the new .env: a generated password, or, when the shell names a
1131
+ * file for it, a note saying so. A password beside the file stops the stack at start (R2-S16).
1132
+ */
1133
+ function keyspacePasswordLine() {
1134
+ if (!shellNamesKeyspacePasswordFile())
1135
+ return `${KEYSPACE_PASSWORD_ENV}=${randomBytes(24).toString("base64url")}`;
1136
+ return `# Read from the file ${KEYSPACE_PASSWORD_FILE_ENV} names in your shell, so none is written here.
1137
+ # Do not set ${KEYSPACE_PASSWORD_ENV} as well: dev and self-host refuse to start with both.`;
1138
+ }
1012
1139
  function envTemplate(opts) {
1140
+ assertEnvValues(envAnswers(opts), ".env");
1013
1141
  const sections = [];
1014
1142
  // Generated, not constant. These reach a server: the previous defaults meant a self-host
1015
1143
  // deployment ran with a password of `postgres` and a JWT secret published in this repo,
@@ -1047,6 +1175,11 @@ SERVICE_ROLE_KEY=`);
1047
1175
  sections.push(`# Shared by the API server and the control plane only. The control plane refuses any
1048
1176
  # request without it, so code running in the functions worker cannot call it directly.
1049
1177
  ${CONTROL_PLANE_SECRET_ENV}=${generateControlPlaneSecret()}`);
1178
+ // Dev wrote it on first start, appended with no comment (0.9.2 release test round 2, R2-S14).
1179
+ sections.push(`# The cache's password when the cache runs in Postgres (pg_keyspace): the keyspace user
1180
+ # \`${KEYSPACE_USERNAME}\`'s, which the API server logs in with, and the gateway when HTTPS is on.
1181
+ # It reads and writes every cached value.
1182
+ ${keyspacePasswordLine()}`);
1050
1183
  sections.push(`# Site URL (used for email redirects)
1051
1184
  SITE_URL=${initSiteUrl(opts)}`);
1052
1185
  if (opts.provider === "docker" && opts.kongPort !== undefined) {
@@ -1056,34 +1189,40 @@ SITE_URL=${initSiteUrl(opts)}`);
1056
1189
  SUPATYPE_KONG_PORT=${opts.kongPort}
1057
1190
  API_EXTERNAL_URL=${initLocalApiUrl(opts)}`);
1058
1191
  }
1059
- sections.push(emailEnvSection(opts.email, opts.projectName));
1192
+ sections.push(emailEnvSection(opts));
1193
+ // Where the CLI would leave it after taking out a SUPATYPE_MAILER_AUTOCONFIRM an earlier CLI wrote.
1194
+ // Written here, a new project never has that done to a line of the developer's own (FF7).
1195
+ sections.push(MAILER_AUTOCONFIRM_NOTE);
1060
1196
  sections.push(storageEnvSections(opts.storageLocal, opts.storageProduction));
1061
1197
  if (opts.adminEmail && opts.adminPassword) {
1062
1198
  sections.push(`# First Studio admin (/studio/), consumed on first supatype dev or push (password removed after use)
1063
1199
  SUPATYPE_ADMIN_EMAIL=${opts.adminEmail}
1064
1200
  SUPATYPE_ADMIN_PASSWORD=${opts.adminPassword}`);
1065
1201
  }
1066
- sections.push(SELF_HOST_PORTS_ENV_SECTION);
1202
+ sections.push(selfHostPortsEnvSection(opts.storageProduction));
1067
1203
  return sections.join("\n\n") + "\n";
1068
1204
  }
1069
1205
  /**
1070
1206
  * The host ports `supatype self-host compose` publishes, with their defaults. Commented out so the
1071
- * defaults apply; the first anyone heard of these used to be a clash on 5432.
1207
+ * defaults apply; the first anyone heard of these used to be a clash on 5432. A stack on the
1208
+ * project's own S3 bucket runs no SeaweedFS, so it is not named there (0.9.2 release test round 2, N-S26).
1072
1209
  */
1073
- const SELF_HOST_PORTS_ENV_SECTION = `# Self-host stack ports (supatype self-host compose). Kong, at SUPATYPE_KONG_PORT, is the way in.
1074
- # Postgres, the API server and SeaweedFS bind 127.0.0.1 only. To reach them from other machines,
1210
+ function selfHostPortsEnvSection(storageProduction) {
1211
+ const seaweedfs = storageProduction !== "s3";
1212
+ return `# Self-host stack ports (supatype self-host compose). Kong, at SUPATYPE_KONG_PORT, is the way in.
1213
+ # Postgres${seaweedfs ? ", the API server and SeaweedFS" : " and the API server"} bind 127.0.0.1 only. To reach them from other machines,
1075
1214
  # set SUPATYPE_PUBLISH_ADDRESS=0.0.0.0 (put a firewall in front of the server first).
1076
1215
  # Self-host commands reach Postgres at SUPATYPE_DB_PORT for their own run; DATABASE_URL above stays dev's.
1077
1216
  # SUPATYPE_PUBLISH_ADDRESS=127.0.0.1
1078
1217
  # SUPATYPE_DB_PORT=5432
1079
- # SUPATYPE_SERVER_PORT=9999
1080
- # SUPATYPE_SEAWEEDFS_PORT=8333`;
1218
+ # SUPATYPE_SERVER_PORT=9999${seaweedfs ? "\n# SUPATYPE_SEAWEEDFS_PORT=8333" : ""}`;
1219
+ }
1081
1220
  /**
1082
1221
  * The scaffolded `.env`'s email settings, under the names the auth server reads. They used to be
1083
1222
  * written unprefixed (RESEND_API_KEY, SES_FROM, SMTP_HOST), which nothing reads, so a developer who
1084
1223
  * filled them in still got no email.
1085
1224
  */
1086
- function emailEnvSection(email, projectName) {
1225
+ function emailEnvSection({ email, projectName, smtp }) {
1087
1226
  switch (email) {
1088
1227
  case "resend":
1089
1228
  return `# Email (Resend)
@@ -1097,15 +1236,14 @@ AWS_ACCESS_KEY_ID=
1097
1236
  AWS_SECRET_ACCESS_KEY=`;
1098
1237
  case "smtp":
1099
1238
  return `# Email (SMTP)
1100
- SUPATYPE_SMTP_HOST=
1101
- SUPATYPE_SMTP_PORT=587
1239
+ SUPATYPE_SMTP_HOST=${smtp?.host ?? ""}
1240
+ SUPATYPE_SMTP_PORT=${smtp?.port ?? 587}
1102
1241
  SUPATYPE_SMTP_USER=
1103
1242
  SUPATYPE_SMTP_PASS=
1104
1243
  SUPATYPE_SMTP_SENDER_NAME=${projectName}`;
1105
1244
  case "console":
1106
1245
  default:
1107
1246
  return `# SMTP: unused while email.provider is console, which logs each email instead of sending it.
1108
- # Email confirmation is auth.email.enableConfirmations in supatype.config.ts.
1109
1247
  # SUPATYPE_SMTP_HOST=
1110
1248
  # SUPATYPE_SMTP_PORT=587
1111
1249
  # SUPATYPE_SMTP_USER=
@@ -1116,13 +1254,7 @@ SUPATYPE_SMTP_SENDER_NAME=${projectName}`;
1116
1254
  function storageEnvSections(storageLocal, storageProduction) {
1117
1255
  if (storageLocal === storageProduction) {
1118
1256
  if (storageLocal === "s3") {
1119
- return `# Storage (local development and production, external bucket)
1120
- # Use separate buckets for dev and production in your provider.
1121
- S3_ENDPOINT=
1122
- S3_REGION=us-east-1
1123
- S3_BUCKET=
1124
- S3_ACCESS_KEY=
1125
- S3_SECRET_KEY=`;
1257
+ return s3EnvSection("local development and production", "Use a separate bucket for dev and production.");
1126
1258
  }
1127
1259
  return `${localStorageEnvSection("local")}
1128
1260
 
@@ -1131,29 +1263,50 @@ S3_SECRET_KEY=`;
1131
1263
  }
1132
1264
  return [localStorageEnvSection(storageLocal), productionStorageEnvSection(storageProduction)].join("\n\n");
1133
1265
  }
1134
- function localStorageEnvSection(storage) {
1135
- if (storage === "s3") {
1136
- return `# Storage (local development, external bucket)
1266
+ /**
1267
+ * The settings for a bucket of your own (storage.provider "s3"), described as the storage service
1268
+ * uses them: one S3 bucket, every Supatype bucket a key prefix in it, as Supabase Storage keeps them.
1269
+ */
1270
+ function s3EnvSection(use, note) {
1271
+ return `# Storage (${use}, your own S3 bucket)
1272
+ # Every Supatype bucket is a folder (key prefix) in S3_BUCKET, and the storage service serves every
1273
+ # file, public ones included, so the bucket itself stays private. The keys need only read, write,
1274
+ # list and delete on that one bucket.${note === undefined ? "" : ` ${note}`}
1275
+ # AWS: set S3_REGION and leave S3_ENDPOINT blank. Another S3-compatible store (Cloudflare R2,
1276
+ # SeaweedFS, and the like): set S3_ENDPOINT too. On AWS, leave both keys blank to use the AWS SDK's
1277
+ # own credentials (an instance or task role, AWS_PROFILE).
1278
+ # In the self-host stack the storage service runs in a container, where localhost is that container.
1279
+ # For a store on the same machine use http://host.docker.internal:<port> with Docker Desktop, or on
1280
+ # Linux the host's Docker bridge address (usually 172.17.0.1). Native supatype dev can use localhost.
1137
1281
  S3_ENDPOINT=
1138
1282
  S3_REGION=us-east-1
1139
1283
  S3_BUCKET=
1140
1284
  S3_ACCESS_KEY=
1141
1285
  S3_SECRET_KEY=`;
1142
- }
1286
+ }
1287
+ /** Whether init generates the object store's login: for the local SeaweedFS, not a bucket of your own. */
1288
+ function generatesObjectStoreLogin(storage) {
1289
+ return storage !== "s3";
1290
+ }
1291
+ /**
1292
+ * Dev's storage settings. Local SeaweedFS takes no S3_* names: the compose file hands the storage
1293
+ * service its address itself. The S3_ENDPOINT=http://localhost:8333 written here was read by
1294
+ * nothing, named the storage container itself from inside it, and stayed behind when a project
1295
+ * moved to its own bucket (0.9.2 release test round 2, N-S26).
1296
+ */
1297
+ function localStorageEnvSection(storage) {
1298
+ if (!generatesObjectStoreLogin(storage))
1299
+ return s3EnvSection("local development");
1300
+ const login = generateObjectStoreCredentials();
1143
1301
  return `# Storage (local development, SeaweedFS)
1144
- S3_ENDPOINT=http://localhost:8333
1145
- S3_ACCESS_KEY=supatype
1146
- S3_SECRET_KEY=supatype-secret`;
1302
+ # The object store's login, generated for this project. It opens every file in every bucket, so
1303
+ # keep it as private as the database password.
1304
+ ${OBJECT_STORE_ACCESS_KEY_ENV}=${login.accessKey}
1305
+ ${OBJECT_STORE_SECRET_KEY_ENV}=${login.secretKey}`;
1147
1306
  }
1148
1307
  function productionStorageEnvSection(storage) {
1149
- if (storage === "s3") {
1150
- return `# Storage (production, external bucket)
1151
- S3_ENDPOINT=
1152
- S3_REGION=us-east-1
1153
- S3_BUCKET=
1154
- S3_ACCESS_KEY=
1155
- S3_SECRET_KEY=`;
1156
- }
1308
+ if (storage === "s3")
1309
+ return s3EnvSection("production");
1157
1310
  return `# Storage (production, SeaweedFS on your server)
1158
1311
  # Included in the self-host compose stack, no extra configuration needed.`;
1159
1312
  }
@@ -1197,9 +1350,6 @@ export default async function seed(ctx: SeedContext) {
1197
1350
  }
1198
1351
  `;
1199
1352
  }
1200
- function functionsEnvLocalTemplate() {
1201
- return "# Local environment variables for edge functions\n# These are NOT committed to git\n# Set production env vars via: npx supatype functions env set KEY=value\n";
1202
- }
1203
1353
  function gitignoreTemplate() {
1204
1354
  // Supatype's own paths come from `SUPATYPE_GITIGNORE_PATHS` rather than being written out again
1205
1355
  // here. This template and that list were two copies of the same thing and had already diverged;
@@ -1207,27 +1357,8 @@ function gitignoreTemplate() {
1207
1357
  return `${SUPATYPE_GITIGNORE_PATHS.join("\n")}
1208
1358
  node_modules/
1209
1359
  dist/
1210
- # Generated by supatype push (legacy paths, prefer output.types in config)
1211
- src/types/supatype.d.ts
1212
- src/lib/supatype.ts
1213
1360
  `;
1214
1361
  }
1215
- /**
1216
- * An existing `.gitignore` with what init adds to a project: `.supatype/` (link.json holds secrets)
1217
- * and `.env.*.local`, where init writes the front end's development-only API address. Each is added
1218
- * only when the file does not already cover it.
1219
- */
1220
- export function mergeGitignoreTemplate(existingContent) {
1221
- const lines = existingContent.split(/\r?\n/).map((line) => line.trim());
1222
- const missing = [
1223
- ...(existingContent.includes(".supatype/") || lines.includes(".supatype") ? [] : [".supatype/"]),
1224
- ...(lines.includes(".env.*.local") || lines.includes("*.local") ? [] : [".env.*.local"]),
1225
- ];
1226
- if (missing.length === 0)
1227
- return existingContent;
1228
- const block = `\n# Supatype: local runtime (secrets in .supatype/link.json) and development-only env files\n${missing.join("\n")}\n`;
1229
- return existingContent.endsWith("\n") ? `${existingContent}${block}` : `${existingContent}\n${block}`;
1230
- }
1231
1362
  // ─── Next steps ────────────────────────────────────────────────────────────--
1232
1363
  /** Say so when a Docker project's Docker is not running: from `started` when init already asked. */
1233
1364
  async function warnDockerUnavailableForProvider(provider, started) {
@@ -1251,16 +1382,6 @@ function startInitQuestions(provider) {
1251
1382
  const kongPort = import("../dev-ports.js").then(({ chooseInitKongPort }) => chooseInitKongPort());
1252
1383
  return { kongPort, daemon: probeDockerDaemonAsync(), deps };
1253
1384
  }
1254
- /** The script in `dir`'s package.json that runs `supatype dev`, or `dev` when it cannot be read. */
1255
- function projectDevScript(dir) {
1256
- try {
1257
- const pkg = parseJsonObject(readFileSync(join(dir, "package.json"), "utf8"));
1258
- return pkg.ok ? supatypeDevScript(pkg.value["scripts"]) : "dev";
1259
- }
1260
- catch {
1261
- return "dev";
1262
- }
1263
- }
1264
1385
  /** True when nothing is left to set up, only to run. */
1265
1386
  function initSetupComplete(args) {
1266
1387
  return args.installed && args.keysGenerated && args.binariesReady;
@@ -1287,7 +1408,7 @@ function printNextSteps(args) {
1287
1408
  export function initStepBlocks(args) {
1288
1409
  const blocks = [
1289
1410
  { title: initSetupComplete(args) ? "Next steps:" : "Finish setup:", steps: initFirstSteps(args) },
1290
- { title: "Secrets: generated for this project, kept in .env:", steps: initSecretLines(), after: SECRETS_CLOSING },
1411
+ { title: "Secrets: generated for this project, kept in .env:", steps: initSecretLines(args.result.storageLocal), after: SECRETS_CLOSING },
1291
1412
  ];
1292
1413
  const deploy = deployBlock(args.result);
1293
1414
  return deploy === undefined ? blocks : [...blocks, deploy];
@@ -1321,9 +1442,11 @@ function commented(command, comments) {
1321
1442
  return comments.map((comment, index) => `${(index === 0 ? command : "").padEnd(column)}# ${comment}`);
1322
1443
  }
1323
1444
  /**
1324
- * The dev script, which applies the schema and generates the types, then watches both; then where
1445
+ * `supatype dev`, which applies the schema and generates the types, then watches both; then where
1325
1446
  * to open the project. `push` is for another database (`push --env <name>`), and listing it here
1326
- * sent people to it anyway.
1447
+ * sent people to it anyway. The command as the docs give it: init printed the package.json script
1448
+ * (`npm run supatype:dev` beside a framework's own dev), which no page of the docs names
1449
+ * (0.9.2 release test round 2, N-S15).
1327
1450
  */
1328
1451
  function initDevSteps(args) {
1329
1452
  const { result } = args;
@@ -1333,7 +1456,7 @@ function initDevSteps(args) {
1333
1456
  ];
1334
1457
  if (result.adminEmail)
1335
1458
  comments.push("first admin user is created on dev");
1336
- const steps = commented(runScriptCommand(result.packageManager, args.devScript ?? "dev"), comments);
1459
+ const steps = commented("supatype dev", comments);
1337
1460
  steps.push(`Open ${initLocalApiUrl(result)}`);
1338
1461
  if (result.helloFunction) {
1339
1462
  steps.push(...commented(runScriptCommand(result.packageManager, "functions"), ["run edge functions locally"]));
@@ -1350,19 +1473,35 @@ const INIT_SECRETS = [
1350
1473
  ["AUTHENTICATOR_PASSWORD", "PostgREST's own login; rotating the one above does not affect it"],
1351
1474
  ["SUPATYPE_SQL_EDITOR_PASSWORD", "Studio's SQL editor login, a role that is not a superuser"],
1352
1475
  ["JWT_SECRET", "signs ANON_KEY and SERVICE_ROLE_KEY; changing it invalidates every token"],
1476
+ [KEYSPACE_PASSWORD_ENV, "the cache's login, which reads and writes every cached value"],
1477
+ ];
1478
+ /** The object store's login, when init generates one ({@link generatesObjectStoreLogin}). */
1479
+ const OBJECT_STORE_SECRETS = [
1480
+ [OBJECT_STORE_ACCESS_KEY_ENV, "the object store's login, which opens every file in every bucket"],
1481
+ [OBJECT_STORE_SECRET_KEY_ENV, "its password"],
1353
1482
  ];
1354
1483
  const SECRETS_CLOSING = "Keep .env out of version control, and use different values in production.";
1355
- /** One line per secret, each description two spaces past the longest name. */
1356
- export function initSecretLines() {
1357
- const width = Math.max(...INIT_SECRETS.map(([name]) => name.length)) + 2;
1358
- return INIT_SECRETS.map(([name, description]) => `${name.padEnd(width)}${description}`);
1484
+ /**
1485
+ * One line per secret init wrote, each description two spaces past the longest name. With
1486
+ * development storage in an S3 bucket of your own, init generates no object-store login.
1487
+ */
1488
+ export function initSecretLines(storageLocal = "local") {
1489
+ const generated = shellNamesKeyspacePasswordFile() ? INIT_SECRETS.filter(([name]) => name !== KEYSPACE_PASSWORD_ENV) : INIT_SECRETS;
1490
+ const secrets = generatesObjectStoreLogin(storageLocal) ? [...generated, ...OBJECT_STORE_SECRETS] : generated;
1491
+ const width = Math.max(...secrets.map(([name]) => name.length)) + 2;
1492
+ return secrets.map(([name, description]) => `${name.padEnd(width)}${description}`);
1359
1493
  }
1494
+ /**
1495
+ * The app's production build, given the linked deployment's API URL and anon key. Without it a
1496
+ * production build read neither, and the deployed app rendered a blank page (issue 29).
1497
+ */
1498
+ const BUILD_STEP = "supatype build --env production # your app's production build, with the deployment's URL and anon key";
1360
1499
  /** Taking the project to production, for a target that has one. No frontend block: `supatype app add` covers that. */
1361
1500
  function deployBlock(result) {
1362
1501
  if (result.productionTarget === "cloud") {
1363
1502
  return {
1364
1503
  title: "When you're ready to deploy (Supatype Cloud):",
1365
- steps: ["supatype login", "supatype link --env production --project <ref>", "supatype push --env production"],
1504
+ steps: ["supatype login", "supatype link --env production --project <ref>", "supatype push --env production", BUILD_STEP],
1366
1505
  };
1367
1506
  }
1368
1507
  if (result.productionTarget === "self-host") {
@@ -1370,6 +1509,11 @@ function deployBlock(result) {
1370
1509
  }
1371
1510
  return undefined;
1372
1511
  }
1512
+ /**
1513
+ * The server's bucket, for production storage on S3: compose refuses to start without S3_BUCKET,
1514
+ * and init's steps never named it (0.9.2 release test round 2, N-S26).
1515
+ */
1516
+ const S3_BUCKET_STEP = "Set S3_BUCKET in the server's .env, with S3_REGION for AWS or S3_ENDPOINT for another store # production storage is your own S3 bucket";
1373
1517
  /**
1374
1518
  * Taking a self-host project to its own server. With a domain, DNS and the firewall come first;
1375
1519
  * without one, HTTPS is the last step and an optional one, since the person just said they had none.
@@ -1377,10 +1521,13 @@ function deployBlock(result) {
1377
1521
  export function selfHostDeploySteps(result) {
1378
1522
  const domain = result.domain?.trim();
1379
1523
  const link = "supatype link --env production ... # then: supatype push --env production";
1524
+ const bucket = result.storageProduction === "s3" ? [S3_BUCKET_STEP] : [];
1380
1525
  if (!domain) {
1381
1526
  return [
1527
+ ...bucket,
1382
1528
  "supatype self-host compose up -d # on your server: the Docker stack",
1383
1529
  link,
1530
+ BUILD_STEP,
1384
1531
  "Later, optionally: set server.domain and server.tls.email in supatype.config.ts for automatic HTTPS",
1385
1532
  ];
1386
1533
  }
@@ -1388,8 +1535,10 @@ export function selfHostDeploySteps(result) {
1388
1535
  `1. Point DNS: an A record for ${domain} -> your server's public IP`,
1389
1536
  "2. Open ports 80 and 443 on the server firewall",
1390
1537
  ...(result.tlsEmail ? [] : ["3. Set server.tls.email in supatype.config.ts (required for HTTPS)"]),
1538
+ ...bucket,
1391
1539
  "supatype self-host compose up -d # Kong provisions HTTPS automatically",
1392
1540
  link,
1541
+ BUILD_STEP,
1393
1542
  `Your Supatype platform goes live at https://${domain}`,
1394
1543
  "Your app, REST, Auth, Storage, Realtime, Functions, and Studio, all behind one HTTPS domain (certificates outlive restarts)",
1395
1544
  ];