@geekmidas/cli 10.0.0-alpha.65 → 10.0.0-alpha.66

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 (208) hide show
  1. package/README.md +14 -0
  2. package/dist/{HostingerProvider-Dlmbfass.cjs → HostingerProvider-BznqRC2S.cjs} +3 -3
  3. package/dist/HostingerProvider-BznqRC2S.cjs.map +1 -0
  4. package/dist/{HostingerProvider-x9gQTAGZ.mjs → HostingerProvider-CY_VpVud.mjs} +3 -3
  5. package/dist/HostingerProvider-CY_VpVud.mjs.map +1 -0
  6. package/dist/{LegacyStateStore-BGoo__sO.cjs → LegacyStateStore-BFcTT2QL.cjs} +2 -2
  7. package/dist/{LegacyStateStore-BGoo__sO.cjs.map → LegacyStateStore-BFcTT2QL.cjs.map} +1 -1
  8. package/dist/{LegacyStateStore-BUu1nQ5u.mjs → LegacyStateStore-CFheFo62.mjs} +2 -2
  9. package/dist/{LegacyStateStore-BUu1nQ5u.mjs.map → LegacyStateStore-CFheFo62.mjs.map} +1 -1
  10. package/dist/{LocalStateStore-93urXyQe.cjs → LocalStateStore-BVUexSvu.cjs} +2 -2
  11. package/dist/{LocalStateStore-93urXyQe.cjs.map → LocalStateStore-BVUexSvu.cjs.map} +1 -1
  12. package/dist/{LocalStateStore-BRhMQRuy.mjs → LocalStateStore-Bm3x9oOg.mjs} +2 -2
  13. package/dist/{LocalStateStore-BRhMQRuy.mjs.map → LocalStateStore-Bm3x9oOg.mjs.map} +1 -1
  14. package/dist/{OpenApiTsGenerator-BWuDRHe9.cjs → OpenApiTsGenerator-B2zrdyP4.cjs} +2 -2
  15. package/dist/{OpenApiTsGenerator-BWuDRHe9.cjs.map → OpenApiTsGenerator-B2zrdyP4.cjs.map} +1 -1
  16. package/dist/{OpenApiTsGenerator-C6v-IeHt.mjs → OpenApiTsGenerator-BmUAcR7d.mjs} +2 -2
  17. package/dist/{OpenApiTsGenerator-C6v-IeHt.mjs.map → OpenApiTsGenerator-BmUAcR7d.mjs.map} +1 -1
  18. package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-Bllus2NR.cjs} +2 -2
  19. package/dist/Route53Provider-Bllus2NR.cjs.map +1 -0
  20. package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-QXxjkZO1.mjs} +2 -2
  21. package/dist/Route53Provider-QXxjkZO1.mjs.map +1 -0
  22. package/dist/{S3StateStore-pw1GhWwt.mjs → S3StateStore-BFHuctWM.mjs} +2 -2
  23. package/dist/{S3StateStore-pw1GhWwt.mjs.map → S3StateStore-BFHuctWM.mjs.map} +1 -1
  24. package/dist/{S3StateStore-F4dxw6kS.cjs → S3StateStore-CoXBhILd.cjs} +2 -2
  25. package/dist/{S3StateStore-F4dxw6kS.cjs.map → S3StateStore-CoXBhILd.cjs.map} +1 -1
  26. package/dist/{SSMStateStore-Bt9acuAF.cjs → SSMStateStore-BqCA9TP2.cjs} +2 -2
  27. package/dist/{SSMStateStore-Bt9acuAF.cjs.map → SSMStateStore-BqCA9TP2.cjs.map} +1 -1
  28. package/dist/{SSMStateStore-Dmj7zzFO.mjs → SSMStateStore-C1kvHScY.mjs} +2 -2
  29. package/dist/{SSMStateStore-Dmj7zzFO.mjs.map → SSMStateStore-C1kvHScY.mjs.map} +1 -1
  30. package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
  31. package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
  32. package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
  33. package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
  34. package/dist/{bundler-D_14JLZF.mjs → bundler-Dvaiud0h.mjs} +4 -4
  35. package/dist/{bundler-D_14JLZF.mjs.map → bundler-Dvaiud0h.mjs.map} +1 -1
  36. package/dist/{bundler-D6MlIfBT.cjs → bundler-orRqUJNZ.cjs} +4 -4
  37. package/dist/{bundler-D6MlIfBT.cjs.map → bundler-orRqUJNZ.cjs.map} +1 -1
  38. package/dist/{cli-P56vvrDQ.mjs → cli-CfHm0AO7.mjs} +5 -4
  39. package/dist/cli-CfHm0AO7.mjs.map +1 -0
  40. package/dist/{cli-BfH1deAT.cjs → cli-D1JkkOwg.cjs} +5 -4
  41. package/dist/cli-D1JkkOwg.cjs.map +1 -0
  42. package/dist/{compose-DprE3ASm.mjs → compose-CNQL8BnO.mjs} +18 -482
  43. package/dist/compose-CNQL8BnO.mjs.map +1 -0
  44. package/dist/{compose-391oEKj1.cjs → compose-jrLy7KGO.cjs} +16 -571
  45. package/dist/compose-jrLy7KGO.cjs.map +1 -0
  46. package/dist/{config-V_X_BMpm.d.cts → config-4XFxX1al.d.cts} +3 -3
  47. package/dist/{config-BonvTW8p.d.mts.map → config-4XFxX1al.d.cts.map} +1 -1
  48. package/dist/{config-BonvTW8p.d.mts → config-UtKzhpFb.d.mts} +3 -3
  49. package/dist/{config-V_X_BMpm.d.cts.map → config-UtKzhpFb.d.mts.map} +1 -1
  50. package/dist/config.cjs +3 -3
  51. package/dist/config.d.cts +3 -3
  52. package/dist/config.d.mts +3 -3
  53. package/dist/config.mjs +3 -3
  54. package/dist/databases-C2p5LGAp.cjs +419 -0
  55. package/dist/databases-C2p5LGAp.cjs.map +1 -0
  56. package/dist/databases-hUHTuwhx.mjs +346 -0
  57. package/dist/databases-hUHTuwhx.mjs.map +1 -0
  58. package/dist/deploy/public.cjs +26 -17
  59. package/dist/deploy/public.d.cts +136 -19
  60. package/dist/deploy/public.d.cts.map +1 -1
  61. package/dist/deploy/public.d.mts +136 -19
  62. package/dist/deploy/public.d.mts.map +1 -1
  63. package/dist/deploy/public.mjs +8 -8
  64. package/dist/deploy-B7aJi_Ah.cjs +511 -0
  65. package/dist/deploy-B7aJi_Ah.cjs.map +1 -0
  66. package/dist/deploy-DWn7YfIc.mjs +488 -0
  67. package/dist/deploy-DWn7YfIc.mjs.map +1 -0
  68. package/dist/{discover-LMrqsWSU.mjs → discover-BFoJWKGD.mjs} +4 -2
  69. package/dist/discover-BFoJWKGD.mjs.map +1 -0
  70. package/dist/{discover-DHdECueV.cjs → discover-OEfZ9OkA.cjs} +4 -2
  71. package/dist/discover-OEfZ9OkA.cjs.map +1 -0
  72. package/dist/dokploy-B4LcYG1E.cjs +38 -0
  73. package/dist/dokploy-B4LcYG1E.cjs.map +1 -0
  74. package/dist/dokploy-DalwLML5.mjs +38 -0
  75. package/dist/dokploy-DalwLML5.mjs.map +1 -0
  76. package/dist/{encryption-B1wJwgae.cjs → encryption-3KlGS1sl.cjs} +5 -7
  77. package/dist/{encryption-B1wJwgae.cjs.map → encryption-3KlGS1sl.cjs.map} +1 -1
  78. package/dist/{encryption-DF_hgIpl.mjs → encryption-CPfENwWO.mjs} +3 -5
  79. package/dist/{encryption-DF_hgIpl.mjs.map → encryption-CPfENwWO.mjs.map} +1 -1
  80. package/dist/{deploy-CZ5nlpsu.mjs → engine-CunvOG3s.mjs} +2100 -1733
  81. package/dist/engine-CunvOG3s.mjs.map +1 -0
  82. package/dist/{deploy-Cy8igpQF.cjs → engine-DR6KurWX.cjs} +2136 -1727
  83. package/dist/engine-DR6KurWX.cjs.map +1 -0
  84. package/dist/{github-CYcmTdFs.cjs → github-BJ5gh9bw.cjs} +7 -7
  85. package/dist/{github-CYcmTdFs.cjs.map → github-BJ5gh9bw.cjs.map} +1 -1
  86. package/dist/{github-B0YYE98x.mjs → github-MXA9v7Ge.mjs} +3 -3
  87. package/dist/{github-B0YYE98x.mjs.map → github-MXA9v7Ge.mjs.map} +1 -1
  88. package/dist/{index-DwKD_8lt.d.mts → index-CyApaHVe.d.cts} +2 -2
  89. package/dist/{index-DPUAGJaK.d.cts.map → index-CyApaHVe.d.cts.map} +1 -1
  90. package/dist/{index-DPUAGJaK.d.cts → index-DD1FfUHh.d.mts} +2 -2
  91. package/dist/{index-DwKD_8lt.d.mts.map → index-DD1FfUHh.d.mts.map} +1 -1
  92. package/dist/index.cjs +276 -68
  93. package/dist/index.cjs.map +1 -1
  94. package/dist/index.mjs +254 -50
  95. package/dist/index.mjs.map +1 -1
  96. package/dist/{migrate-B2qL5wj4.mjs → migrate-BJBcm4sG.mjs} +6 -6
  97. package/dist/{migrate-B2qL5wj4.mjs.map → migrate-BJBcm4sG.mjs.map} +1 -1
  98. package/dist/{migrate-q4pPAXtO.cjs → migrate-CF4J4GQS.cjs} +16 -16
  99. package/dist/{migrate-q4pPAXtO.cjs.map → migrate-CF4J4GQS.cjs.map} +1 -1
  100. package/dist/openapi.cjs +1 -1
  101. package/dist/openapi.d.cts +1 -1
  102. package/dist/openapi.d.mts +1 -1
  103. package/dist/openapi.mjs +1 -1
  104. package/dist/provider-B3Sv_a74.cjs +173 -0
  105. package/dist/provider-B3Sv_a74.cjs.map +1 -0
  106. package/dist/provider-D7rQzzzf.mjs +138 -0
  107. package/dist/provider-D7rQzzzf.mjs.map +1 -0
  108. package/dist/{ready-bQfu9GES.mjs → ready-2s3-CndS.mjs} +3 -3
  109. package/dist/{ready-bQfu9GES.mjs.map → ready-2s3-CndS.mjs.map} +1 -1
  110. package/dist/{ready-brEhh68f.cjs → ready-B6uHr4sm.cjs} +3 -3
  111. package/dist/{ready-brEhh68f.cjs.map → ready-B6uHr4sm.cjs.map} +1 -1
  112. package/dist/reconcile/public.cjs +1 -1
  113. package/dist/reconcile/public.d.cts +1 -1
  114. package/dist/reconcile/public.d.mts +1 -1
  115. package/dist/reconcile/public.mjs +1 -1
  116. package/dist/{resolve-N_i4XNd-.cjs → resolve-CVmch0wI.cjs} +3 -3
  117. package/dist/{resolve-N_i4XNd-.cjs.map → resolve-CVmch0wI.cjs.map} +1 -1
  118. package/dist/{resolve-DLkIXTct.mjs → resolve-Db0tNlrW.mjs} +3 -3
  119. package/dist/{resolve-DLkIXTct.mjs.map → resolve-Db0tNlrW.mjs.map} +1 -1
  120. package/dist/rollback-DvAo4OKS.mjs +133 -0
  121. package/dist/rollback-DvAo4OKS.mjs.map +1 -0
  122. package/dist/rollback-DxJK84hy.cjs +162 -0
  123. package/dist/rollback-DxJK84hy.cjs.map +1 -0
  124. package/dist/{runtime-BnD7Nn96.d.cts → runtime-BRqFOvPM.d.cts} +2 -2
  125. package/dist/{runtime-BnD7Nn96.d.cts.map → runtime-BRqFOvPM.d.cts.map} +1 -1
  126. package/dist/{runtime-j-tmFL65.d.mts → runtime-CEk5n4VH.d.mts} +2 -2
  127. package/dist/{runtime-j-tmFL65.d.mts.map → runtime-CEk5n4VH.d.mts.map} +1 -1
  128. package/dist/sandbox/discover-worker.cjs +1 -1
  129. package/dist/sandbox/discover-worker.mjs +1 -1
  130. package/dist/sandbox/migrate-worker.cjs +61 -0
  131. package/dist/sandbox/migrate-worker.cjs.map +1 -0
  132. package/dist/sandbox/migrate-worker.d.cts +1 -0
  133. package/dist/sandbox/migrate-worker.d.mts +1 -0
  134. package/dist/sandbox/migrate-worker.mjs +62 -0
  135. package/dist/sandbox/migrate-worker.mjs.map +1 -0
  136. package/dist/{schemas-D2LCF689.mjs → schemas-Cfhtpdo0.mjs} +10 -2
  137. package/dist/{schemas-Ckm_aBnF.cjs.map → schemas-Cfhtpdo0.mjs.map} +1 -1
  138. package/dist/{schemas-Ckm_aBnF.cjs → schemas-RUlKHu27.cjs} +15 -1
  139. package/dist/{schemas-D2LCF689.mjs.map → schemas-RUlKHu27.cjs.map} +1 -1
  140. package/dist/{sniffer-BSwaL-dX.cjs → sniffer-5xmrkh2a.cjs} +112 -606
  141. package/dist/sniffer-5xmrkh2a.cjs.map +1 -0
  142. package/dist/{sniffer-BZ-OJO4Y.mjs → sniffer-BAQhLEsI.mjs} +95 -546
  143. package/dist/sniffer-BAQhLEsI.mjs.map +1 -0
  144. package/dist/{state-DF26e_lo.cjs → state-Y6ATakMX.cjs} +744 -20
  145. package/dist/state-Y6ATakMX.cjs.map +1 -0
  146. package/dist/{state-B8YwmUZU.mjs → state-uuYqnRVO.mjs} +605 -19
  147. package/dist/state-uuYqnRVO.mjs.map +1 -0
  148. package/dist/target/public.cjs +1 -1
  149. package/dist/target/public.d.cts +2 -2
  150. package/dist/target/public.d.mts +2 -2
  151. package/dist/target/public.mjs +1 -1
  152. package/dist/{terminal-Bs5E1oxm.cjs → terminal-CHy_MdjG.cjs} +11 -15
  153. package/dist/{terminal-Bs5E1oxm.cjs.map → terminal-CHy_MdjG.cjs.map} +1 -1
  154. package/dist/{terminal-CfbiYUbZ.mjs → terminal-DUhcZ1ND.mjs} +4 -4
  155. package/dist/{terminal-CfbiYUbZ.mjs.map → terminal-DUhcZ1ND.mjs.map} +1 -1
  156. package/dist/{types-ByMWkXKP.d.cts → types-CSw2w69a.d.mts} +68 -10
  157. package/dist/types-CSw2w69a.d.mts.map +1 -0
  158. package/dist/{types-BCzMWBb6.d.mts → types-D5WIxRDP.d.cts} +69 -9
  159. package/dist/types-D5WIxRDP.d.cts.map +1 -0
  160. package/dist/vitest.cjs +1 -1
  161. package/dist/vitest.mjs +1 -1
  162. package/dist/workspace/index.cjs +1 -1
  163. package/dist/workspace/index.d.cts +2 -2
  164. package/dist/workspace/index.d.mts +2 -2
  165. package/dist/workspace/index.mjs +1 -1
  166. package/dist/{workspace-C06_pW4g.mjs → workspace-Be6uBhlF.mjs} +10 -3
  167. package/dist/workspace-Be6uBhlF.mjs.map +1 -0
  168. package/dist/{workspace-BewAHZIo.cjs → workspace-ON-bqiJz.cjs} +10 -3
  169. package/dist/workspace-ON-bqiJz.cjs.map +1 -0
  170. package/package.json +13 -13
  171. package/dist/HostingerProvider-Dlmbfass.cjs.map +0 -1
  172. package/dist/HostingerProvider-x9gQTAGZ.mjs.map +0 -1
  173. package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
  174. package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
  175. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
  176. package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
  177. package/dist/cli-BfH1deAT.cjs.map +0 -1
  178. package/dist/cli-P56vvrDQ.mjs.map +0 -1
  179. package/dist/compose-391oEKj1.cjs.map +0 -1
  180. package/dist/compose-DprE3ASm.mjs.map +0 -1
  181. package/dist/deploy-9MBG_QLd.mjs +0 -137
  182. package/dist/deploy-9MBG_QLd.mjs.map +0 -1
  183. package/dist/deploy-B80idPUZ.cjs +0 -142
  184. package/dist/deploy-B80idPUZ.cjs.map +0 -1
  185. package/dist/deploy-CZ5nlpsu.mjs.map +0 -1
  186. package/dist/deploy-Cy8igpQF.cjs.map +0 -1
  187. package/dist/discover-DHdECueV.cjs.map +0 -1
  188. package/dist/discover-LMrqsWSU.mjs.map +0 -1
  189. package/dist/dokploy-BdtBePjp.mjs +0 -32
  190. package/dist/dokploy-BdtBePjp.mjs.map +0 -1
  191. package/dist/dokploy-iFY8MY-L.cjs +0 -32
  192. package/dist/dokploy-iFY8MY-L.cjs.map +0 -1
  193. package/dist/sniffer-BSwaL-dX.cjs.map +0 -1
  194. package/dist/sniffer-BZ-OJO4Y.mjs.map +0 -1
  195. package/dist/state-B8YwmUZU.mjs.map +0 -1
  196. package/dist/state-DF26e_lo.cjs.map +0 -1
  197. package/dist/storage-BzaUxmqe.mjs +0 -124
  198. package/dist/storage-BzaUxmqe.mjs.map +0 -1
  199. package/dist/storage-CSGoC3bK.cjs +0 -152
  200. package/dist/storage-CSGoC3bK.cjs.map +0 -1
  201. package/dist/store-CJF1Tqkq.cjs +0 -510
  202. package/dist/store-CJF1Tqkq.cjs.map +0 -1
  203. package/dist/store-CLiHnqOY.mjs +0 -415
  204. package/dist/store-CLiHnqOY.mjs.map +0 -1
  205. package/dist/types-BCzMWBb6.d.mts.map +0 -1
  206. package/dist/types-ByMWkXKP.d.cts.map +0 -1
  207. package/dist/workspace-BewAHZIo.cjs.map +0 -1
  208. package/dist/workspace-C06_pW4g.mjs.map +0 -1
@@ -1,21 +1,18 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
2
  import { c as runOutput, s as run, t as LocalSandbox } from "./local-CWR4Y_kW.mjs";
3
- import { r as discover } from "./discover-LMrqsWSU.mjs";
3
+ import { r as discover } from "./discover-BFoJWKGD.mjs";
4
4
  import { i as activeSandbox } from "./sandbox-Dm247NGx.mjs";
5
5
  import { t as appKey } from "./derive-B4vDpzgP.mjs";
6
6
  import { t as defineTarget } from "./define-DR8xGYfL.mjs";
7
- import { t as initStageSecrets } from "./storage-BzaUxmqe.mjs";
8
- import { f as imageRef } from "./store-CLiHnqOY.mjs";
9
- import { $ as portKeys, B as networkEnv, C as isMainFrontendApp, D as constructGlobs, F as postgresStatements, G as hostFor, H as localRolePassword, L as composeFor, N as applyPostgres, R as pgClient, S as validateImageRef, U as planFor, V as envFor, X as DEFAULT_IMAGES, b as generateDockerignore, et as primaryPortKey, f as DeployJournal, g as appPackageName, p as withGeneratedSecrets, s as setDeployedImage, t as createEmptyState, v as siteDockerfile, w as resolveHost, x as generateSlimDockerfile, y as detectPackageManager, z as appEnvKeys } from "./state-B8YwmUZU.mjs";
7
+ import { B as appEnvKeys, C as validateImageRef, Et as initStageSecrets, G as planFor, H as networkEnv, I as postgresStatements, O as constructGlobs, P as applyPostgres, Q as DEFAULT_IMAGES, R as composeFor, S as generateSlimDockerfile, T as resolveHost, U as envFor, W as localRolePassword, _ as appPackageName, a as recordRelease, b as detectPackageManager, m as withGeneratedSecrets, nt as primaryPortKey, p as DeployJournal, q as hostFor, t as createEmptyState, tt as portKeys, w as isMainFrontendApp, x as generateDockerignore, xt as imageRef, y as siteDockerfile, z as pgClient } from "./state-uuYqnRVO.mjs";
10
8
  import { n as DEFAULT_CACHE, r as DEFAULT_EVENTS } from "./fakes-C9RiT6XG.mjs";
11
- import { createRequire } from "node:module";
12
- import { dirname, extname, join } from "node:path";
9
+ import { u as migrateDatabases } from "./databases-hUHTuwhx.mjs";
10
+ import { dirname, join } from "node:path";
13
11
  import { existsSync } from "node:fs";
14
- import { appendFile, chmod, mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
15
- import { DATABASE_FOLDERS, MIGRATIONS_ROOT, canonicalId, migrationTargets, provideKey, provisionOrder, publicEnvFor } from "@geekmidas/manifest";
16
- import { fileURLToPath, pathToFileURL } from "node:url";
12
+ import { appendFile, chmod, mkdir, readFile, writeFile } from "node:fs/promises";
13
+ import { provideKey, provisionOrder, publicEnvFor } from "@geekmidas/manifest";
14
+ import { fileURLToPath } from "node:url";
17
15
  import { spawn } from "node:child_process";
18
- import pg from "pg";
19
16
  import { stringify } from "yaml";
20
17
  import { request } from "node:https";
21
18
  //#region src/compose/docker.ts
@@ -710,474 +707,6 @@ function envFile(env) {
710
707
  return `${Object.entries(env).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => `${key}=${value}`).join("\n")}\n`;
711
708
  }
712
709
  //#endregion
713
- //#region src/migrate/provider.ts
714
- /**
715
- * One construct's migrations and seeds, read from its folders.
716
- *
717
- * Two kinds of file, told apart by extension rather than by configuration: a
718
- * script exports `up` (and may export `down`) — or `seed(db, { stage })`, in
719
- * `seeds/` — and a
720
- * `.sql` file is run whole. The second is what makes a folder independent of
721
- * the client the app uses — Better Auth's schema is SQL whatever the
722
- * application queries with.
723
- */
724
- const SCRIPTS = /* @__PURE__ */ new Set([
725
- ".ts",
726
- ".mts",
727
- ".js",
728
- ".mjs"
729
- ]);
730
- /** Two files in one folder that would be one migration. */
731
- var DuplicateMigration = class extends Error {
732
- folder;
733
- migration;
734
- constructor(folder, migration) {
735
- super(`${folder} has two migrations named '${migration}' — a script and a .sql file with the same name. A migration is recorded by name, so only one of them could ever run; rename or remove the other.`);
736
- this.folder = folder;
737
- this.migration = migration;
738
- this.name = "DuplicateMigration";
739
- }
740
- };
741
- /** A script in a migrations folder that exports no `up`. */
742
- var MigrationHasNoUp = class extends Error {
743
- file;
744
- constructor(file) {
745
- super(`${file} is in a migrations folder but exports no \`up\` function. Export \`async function up(db: Kysely<unknown>)\`, or move the file out of the folder if it is not a migration.`);
746
- this.file = file;
747
- this.name = "MigrationHasNoUp";
748
- }
749
- };
750
- /** A script in a seeds folder that exports no `seed`. */
751
- var SeedHasNoSeed = class extends Error {
752
- file;
753
- constructor(file) {
754
- super(`${file} is in a seeds folder but exports no \`seed\` function. Export \`async function seed(db, { stage })\`, or move the file out of the folder if it is not a seed.`);
755
- this.file = file;
756
- this.name = "SeedHasNoSeed";
757
- }
758
- };
759
- /**
760
- * The migration files in a folder, by name, without reading them.
761
- *
762
- * Also what `gkm dev` compares against a construct's history to report what
763
- * is pending, which is why it is separate from loading them.
764
- */
765
- async function migrationFiles(folder) {
766
- const entries = await readdir(folder, { withFileTypes: true }).catch((error) => {
767
- if (error.code === "ENOENT") return [];
768
- throw error;
769
- });
770
- const files = /* @__PURE__ */ new Map();
771
- for (const entry of entries) {
772
- if (!entry.isFile() || !isMigration(entry.name)) continue;
773
- const name = entry.name.slice(0, -extname(entry.name).length);
774
- if (files.has(name)) throw new DuplicateMigration(folder, name);
775
- files.set(name, join(folder, entry.name));
776
- }
777
- return files;
778
- }
779
- /** A Kysely provider over one construct's folder. */
780
- function folderProvider(folder, raw) {
781
- return { async getMigrations() {
782
- const migrations = {};
783
- for (const [name, file] of await migrationFiles(folder)) migrations[name] = extname(file) === ".sql" ? await sqlMigration(file, raw) : await scriptMigration(file);
784
- return migrations;
785
- } };
786
- }
787
- /**
788
- * The seeds in a folder, loaded, in name order.
789
- *
790
- * Every one runs on every pass — there is no history to consult — so the order
791
- * is the only thing between two seeds where one reads what another writes.
792
- * Name them to sort that way.
793
- */
794
- async function loadSeeds(folder, raw) {
795
- const files = [...await migrationFiles(folder)].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
796
- const seeds = [];
797
- for (const [name, file] of files) seeds.push({
798
- name,
799
- run: extname(file) === ".sql" ? (await sqlMigration(file, raw)).up : await scriptSeed(file)
800
- });
801
- return seeds;
802
- }
803
- /**
804
- * A seed script, imported as it is on disk now.
805
- *
806
- * Keyed by its modification time: a seed is run again after it is edited, and
807
- * a process that has imported it once would otherwise run the old one.
808
- */
809
- async function scriptSeed(file) {
810
- const url = pathToFileURL(file);
811
- url.searchParams.set("mtime", String((await stat(file)).mtimeMs));
812
- const module = await import(url.href);
813
- if (typeof module.seed !== "function") throw new SeedHasNoSeed(file);
814
- return module.seed;
815
- }
816
- function isMigration(file) {
817
- if (file.endsWith(".d.ts")) return false;
818
- if (/\.(spec|test)\.[cm]?[jt]s$/.test(file)) return false;
819
- const extension = extname(file);
820
- return extension === ".sql" || SCRIPTS.has(extension);
821
- }
822
- async function scriptMigration(file) {
823
- const module = await import(pathToFileURL(file).href);
824
- if (typeof module.up !== "function") throw new MigrationHasNoUp(file);
825
- return {
826
- up: module.up,
827
- ...typeof module.down === "function" ? { down: module.down } : {}
828
- };
829
- }
830
- /**
831
- * A `.sql` file, run whole.
832
- *
833
- * One query rather than split on `;`: with no parameters, Postgres takes
834
- * several statements in one message, and splitting by hand breaks on the first
835
- * `;` inside a string or a function body. There is no `down` — a generated
836
- * schema is rolled back by a migration that says how, not by guessing.
837
- */
838
- async function sqlMigration(file, raw) {
839
- const statements = await readFile(file, "utf-8");
840
- return { up: async (db) => {
841
- await raw.raw(statements).execute(db);
842
- } };
843
- }
844
- //#endregion
845
- //#region src/migrate/databases.ts
846
- /**
847
- * Bring each construct's schema up to its migrations folder.
848
- *
849
- * Which constructs, in what order, from which folder, is `migrationTargets`'
850
- * answer and nobody else's. What is decided here is only how one target is
851
- * run: as its owner, in its own schema, with a history of its own.
852
- */
853
- /** A folder under `db/` that names no construct. */
854
- var UnknownMigrationFolder = class extends Error {
855
- folder;
856
- known;
857
- constructor(folder, known) {
858
- super(`${folder} names no database construct, so its migrations would never run. ${known.length > 0 ? `The folders that do: ${known.join(", ")}.` : "This project declares no database."} Rename the folder after the construct it belongs to.`);
859
- this.folder = folder;
860
- this.known = known;
861
- this.name = "UnknownMigrationFolder";
862
- }
863
- };
864
- /** A construct was asked for by a name that takes no migrations. */
865
- var NoSuchMigrationTarget = class extends Error {
866
- construct;
867
- known;
868
- constructor(construct, known) {
869
- super(`'${construct}' is not a database construct. ` + (known.length > 0 ? `The ones with migrations: ${known.join(", ")}.` : "This project declares no database."));
870
- this.construct = construct;
871
- this.known = known;
872
- this.name = "NoSuchMigrationTarget";
873
- }
874
- };
875
- /**
876
- * A migration left directly in a construct's folder, where nothing reads it.
877
- *
878
- * Migrations moved into `migrations/` so seeds could sit beside them. A file
879
- * still at the old level would otherwise never run, and nothing would say so.
880
- */
881
- var MigrationsOutsideFolder = class extends Error {
882
- folder;
883
- files;
884
- constructor(folder, files) {
885
- super(`${folder} has ${files.join(", ")} directly inside it, where nothing runs them. Migrations live in ${folder}/migrations/ and seeds in ${folder}/seeds/ — move ${files.length === 1 ? "it" : "them"} there.`);
886
- this.folder = folder;
887
- this.files = files;
888
- this.name = "MigrationsOutsideFolder";
889
- }
890
- };
891
- /** A folder inside a construct's folder that is neither `migrations` nor `seeds`. */
892
- var UnknownDatabaseFolder = class extends Error {
893
- folder;
894
- constructor(folder) {
895
- super(`${folder} is neither migrations/ nor seeds/, so nothing in it would ever run. A construct's folder holds those two; rename or remove it.`);
896
- this.folder = folder;
897
- this.name = "UnknownDatabaseFolder";
898
- }
899
- };
900
- /** A seed failed; its own writes are rolled back, the ones before it stay. */
901
- var SeedFailed = class extends Error {
902
- construct;
903
- seed;
904
- cause;
905
- constructor(construct, seed, cause) {
906
- super(`${construct}: seed '${seed}' failed — ${cause instanceof Error ? cause.message : String(cause)}. Its writes were rolled back; fix it and run it again.`);
907
- this.construct = construct;
908
- this.seed = seed;
909
- this.cause = cause;
910
- this.name = "SeedFailed";
911
- }
912
- };
913
- /** A construct with roles has no owner URL to migrate with. */
914
- var NoOwnerCredential = class extends Error {
915
- construct;
916
- key;
917
- constructor(construct, key) {
918
- super(`${construct} has no ${key} to migrate with. Migrations run as the owner role — the runtime one cannot create a table — and nothing resolved its URL. Is the stage reconciled?`);
919
- this.construct = construct;
920
- this.key = key;
921
- this.name = "NoOwnerCredential";
922
- }
923
- };
924
- /** A migration failed; the ones before it in the run stay applied. */
925
- var MigrationFailed = class extends Error {
926
- construct;
927
- migration;
928
- cause;
929
- constructor(construct, migration, cause) {
930
- super(`${construct}: migration ${migration ? `'${migration}' ` : ""}failed — ${cause instanceof Error ? cause.message : String(cause)}`);
931
- this.construct = construct;
932
- this.migration = migration;
933
- this.cause = cause;
934
- this.name = "MigrationFailed";
935
- }
936
- };
937
- /** The project's Kysely could not be found from where a database is declared. */
938
- var KyselyNotFound = class extends Error {
939
- from;
940
- constructor(from) {
941
- super(`Could not resolve 'kysely' from ${from}. Migrations run with the project's own Kysely — install it where the database is declared.`);
942
- this.from = from;
943
- this.name = "KyselyNotFound";
944
- }
945
- };
946
- /** Apply every pending migration, construct by construct, parents first. */
947
- async function migrateDatabases(options) {
948
- const runs = [];
949
- for (const target of await targetsFor(options)) {
950
- if ((await migrationFiles(join(options.root, target.migrations))).size === 0) {
951
- runs.push({
952
- target,
953
- applied: []
954
- });
955
- continue;
956
- }
957
- const applied = await withMigrator(options, target, async (migrator) => {
958
- const { error, results = [] } = await migrator.migrateToLatest();
959
- if (error) {
960
- const failed = results.find((result) => result.status === "Error");
961
- throw new MigrationFailed(target.id, failed?.migrationName, error);
962
- }
963
- return results.filter((result) => result.status === "Success").map((result) => result.migrationName);
964
- });
965
- runs.push({
966
- target,
967
- applied
968
- });
969
- }
970
- return runs;
971
- }
972
- /**
973
- * Run every construct's seeds, parents first — each one, every time, on every
974
- * stage, production included. Each is handed the stage, so a seed decides
975
- * what belongs where.
976
- *
977
- * Seeds are reference data kept up to date by being run again, so there is no
978
- * history: a seed is an upsert, and a changed one is applied by the next run.
979
- * Each runs in its own transaction, as the construct's owner, so a failure
980
- * leaves nothing half-written. Assumes the schema is migrated —
981
- * {@link migrateAndSeed} is what makes that true.
982
- */
983
- async function seedDatabases(options) {
984
- const runs = [];
985
- for (const target of await targetsFor(options)) {
986
- const folder = join(options.root, target.seeds);
987
- if ((await migrationFiles(folder)).size === 0) {
988
- runs.push({
989
- target,
990
- seeded: []
991
- });
992
- continue;
993
- }
994
- const seeded = await withOwner(options, target, async (db, kysely) => {
995
- const names = [];
996
- for (const seed of await loadSeeds(folder, kysely.sql)) {
997
- try {
998
- await db.transaction().execute((trx) => seed.run(trx, { stage: options.stage }));
999
- } catch (error) {
1000
- throw new SeedFailed(target.id, seed.name, error);
1001
- }
1002
- names.push(seed.name);
1003
- }
1004
- return names;
1005
- });
1006
- runs.push({
1007
- target,
1008
- seeded
1009
- });
1010
- }
1011
- return runs;
1012
- }
1013
- /**
1014
- * Migrate, then seed: a seed only ever runs against the schema it was written
1015
- * for.
1016
- *
1017
- * With `only`, the constructs it lives in are migrated too — a tenant's seed
1018
- * cannot run before the database that owns its schema exists — and only it is
1019
- * seeded.
1020
- */
1021
- async function migrateAndSeed(options) {
1022
- const migrations = [];
1023
- for (const target of await withParents(options)) migrations.push(...await migrateDatabases({
1024
- ...options,
1025
- only: target.id
1026
- }));
1027
- return {
1028
- migrations,
1029
- seeds: await seedDatabases(options)
1030
- };
1031
- }
1032
- /** The targets `only` names, after the ones it lives in; all without it. */
1033
- async function withParents(options) {
1034
- const chosen = await targetsFor(options);
1035
- if (!options.only) return chosen;
1036
- const all = migrationTargets(options.manifest);
1037
- const ids = /* @__PURE__ */ new Set();
1038
- for (const target of chosen) {
1039
- let current = target;
1040
- while (current) {
1041
- ids.add(current.id);
1042
- const parent = current.of;
1043
- current = parent ? all.find((t) => t.id === parent) : void 0;
1044
- }
1045
- }
1046
- return all.filter((target) => ids.has(target.id));
1047
- }
1048
- /**
1049
- * What each construct's folder has that its history does not — without
1050
- * applying any of it. What `gkm dev` reports.
1051
- */
1052
- async function pendingMigrations(options) {
1053
- const found = [];
1054
- for (const target of await targetsFor(options)) {
1055
- if ((await migrationFiles(join(options.root, target.migrations))).size === 0) continue;
1056
- const pending = await withMigrator(options, target, async (migrator) => (await migrator.getMigrations()).filter((migration) => migration.executedAt === void 0).map((migration) => migration.name));
1057
- if (pending.length > 0) found.push({
1058
- target,
1059
- pending
1060
- });
1061
- }
1062
- return found;
1063
- }
1064
- /**
1065
- * The targets this run covers, with every folder under `db/` accounted for.
1066
- *
1067
- * A folder that names no construct is an error rather than something to skip:
1068
- * a typo in its name is otherwise a migration that silently never runs.
1069
- */
1070
- async function targetsFor(options) {
1071
- const targets = migrationTargets(options.manifest);
1072
- const folders = targets.map((target) => target.folder);
1073
- for (const folder of await foldersIn(join(options.root, MIGRATIONS_ROOT))) {
1074
- const relative = `${MIGRATIONS_ROOT}/${folder}`;
1075
- if (!folders.includes(relative)) throw new UnknownMigrationFolder(relative, folders);
1076
- await checkLayout(options.root, relative);
1077
- }
1078
- if (!options.only) return targets;
1079
- const id = canonicalId(options.only);
1080
- const chosen = targets.filter((target) => target.id === id);
1081
- if (chosen.length === 0) throw new NoSuchMigrationTarget(options.only, targets.map((target) => target.id));
1082
- return chosen;
1083
- }
1084
- /**
1085
- * A construct's folder holds `migrations/` and `seeds/`, and nothing else —
1086
- * anything beside them is a file or folder nothing would ever run.
1087
- */
1088
- async function checkLayout(root, folder) {
1089
- const entries = await readdir(join(root, folder), { withFileTypes: true });
1090
- const loose = entries.filter((entry) => entry.isFile() && !entry.name.startsWith(".")).map((entry) => entry.name);
1091
- if (loose.length > 0) throw new MigrationsOutsideFolder(folder, loose);
1092
- for (const entry of entries) if (entry.isDirectory() && !DATABASE_FOLDERS.includes(entry.name)) throw new UnknownDatabaseFolder(`${folder}/${entry.name}`);
1093
- }
1094
- async function foldersIn(dir) {
1095
- return (await readdir(dir, { withFileTypes: true }).catch((error) => {
1096
- if (error.code === "ENOENT") return [];
1097
- throw error;
1098
- })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
1099
- }
1100
- /**
1101
- * A migrator for one target, connected as its owner.
1102
- *
1103
- * No `migrationTableSchema`: the owner role's `search_path` is pinned to the
1104
- * construct's schema, so the history lands there — `app.kysely_migration` for
1105
- * the database, `auth_database.kysely_migration` for its tenant — and two
1106
- * constructs in one Postgres never share one.
1107
- *
1108
- * Unordered migrations are allowed. Files are timestamped, so a branch merged
1109
- * after another's migration ran carries an older one; refusing it would make
1110
- * every such merge a manual repair.
1111
- */
1112
- async function withMigrator(options, target, run) {
1113
- return withOwner(options, target, (db, { Migrator, sql }) => run(new Migrator({
1114
- db,
1115
- provider: folderProvider(join(options.root, target.migrations), sql),
1116
- allowUnorderedMigrations: true
1117
- })));
1118
- }
1119
- /**
1120
- * One target's database, connected as its owner and closed afterwards — what
1121
- * migrations and seeds both run as.
1122
- */
1123
- async function withOwner(options, target, run) {
1124
- const kysely = await kyselyFrom(options.sources?.[target.id]?.file ?? (target.of ? options.sources?.[target.of]?.file : void 0) ?? join(options.root, "package.json"));
1125
- const db = new kysely.Kysely({ dialect: new kysely.PostgresDialect({ pool: new pg.Pool(poolConfig(ownerUrl(options, target))) }) });
1126
- try {
1127
- return await run(db, kysely);
1128
- } finally {
1129
- await db.destroy();
1130
- }
1131
- }
1132
- /**
1133
- * The owner's URL, with no fallback to the runtime one.
1134
- *
1135
- * The runtime role can create nothing, so falling back would only move the
1136
- * failure to the first `CREATE TABLE` and make it read like a permissions
1137
- * bug. The one exception is a database declared `roles: false`, where there is
1138
- * no owner — both URLs are the master credential by design.
1139
- */
1140
- function ownerUrl(options, target) {
1141
- const key = provideKey(target.id, "ownerUrl");
1142
- const owner = options.env[key];
1143
- if (owner) return owner;
1144
- const database = options.manifest[target.of ?? target.id];
1145
- if (database?.kind === "database" && database.roles === false) {
1146
- const url = options.env[provideKey(target.id, "url")];
1147
- if (url) return url;
1148
- }
1149
- throw new NoOwnerCredential(target.id, key);
1150
- }
1151
- /**
1152
- * Pool settings for a URL, with `?search_path=` as the startup option Postgres
1153
- * reads. Only a `roles: false` URL carries it — a role pins its own.
1154
- */
1155
- function poolConfig(url) {
1156
- const parsed = new URL(url);
1157
- const searchPath = parsed.searchParams.get("search_path");
1158
- if (!searchPath) return { connectionString: url };
1159
- parsed.searchParams.delete("search_path");
1160
- return {
1161
- connectionString: parsed.toString(),
1162
- options: `-c search_path=${searchPath}`
1163
- };
1164
- }
1165
- /** Kysely as the project resolves it from `from`. */
1166
- async function kyselyFrom(from) {
1167
- const require = createRequire(from);
1168
- try {
1169
- const [main, migration] = await Promise.all([import(pathToFileURL(require.resolve("kysely")).href), import(pathToFileURL(require.resolve("kysely/migration")).href)]);
1170
- return {
1171
- Kysely: main.Kysely,
1172
- PostgresDialect: main.PostgresDialect,
1173
- sql: main.sql,
1174
- Migrator: migration.Migrator
1175
- };
1176
- } catch {
1177
- throw new KyselyNotFound(from);
1178
- }
1179
- }
1180
- //#endregion
1181
710
  //#region src/target/compose/health.ts
1182
711
  /**
1183
712
  * Asking each app of a stack whether it answers — through Caddy, over HTTPS,
@@ -1417,7 +946,14 @@ async function validateCompose(ctx, deps, forced) {
1417
946
  });
1418
947
  if (mode === "pull" && !ctx.dryRun) await assertImagesExist(deps.docker, tag, stack.apps);
1419
948
  const dir = join(root, stackDir(stage));
1420
- const previous = (await ctx.state.read(stage))?.state.images ?? {};
949
+ const previous = Object.fromEntries(Object.entries((await ctx.state.read(stage))?.state.releases ?? {}).map(([name, releases]) => {
950
+ const { ref, tag, digest } = releases.current;
951
+ return [name, {
952
+ ref,
953
+ ...tag ? { tag } : {},
954
+ ...digest ? { digest } : {}
955
+ }];
956
+ }));
1421
957
  return {
1422
958
  mode,
1423
959
  stack,
@@ -1636,7 +1172,7 @@ async function recordImages(ctx, run) {
1636
1172
  ref: app.ref,
1637
1173
  tag: app.tag
1638
1174
  };
1639
- setDeployedImage(journal.state, app.name, image);
1175
+ recordRelease(journal.state, app.name, image);
1640
1176
  }
1641
1177
  journal.state.identity = ctx.identity.key;
1642
1178
  await journal.save();
@@ -1857,6 +1393,6 @@ function composeTarget(options = {}) {
1857
1393
  });
1858
1394
  }
1859
1395
  //#endregion
1860
- export { SeedHasNoSeed as _, MigrationsOutsideFolder as a, dockerCompose as b, SeedFailed as c, migrateAndSeed as d, migrateDatabases as f, MigrationHasNoUp as g, DuplicateMigration as h, MigrationFailed as i, UnknownDatabaseFolder as l, seedDatabases as m, compose_exports as n, NoOwnerCredential as o, pendingMigrations as p, KyselyNotFound as r, NoSuchMigrationTarget as s, composeTarget as t, UnknownMigrationFolder as u, composeProject as v, stackDir as y };
1396
+ export { dockerCompose as a, stackDir as i, compose_exports as n, composeProject as r, composeTarget as t };
1861
1397
 
1862
- //# sourceMappingURL=compose-DprE3ASm.mjs.map
1398
+ //# sourceMappingURL=compose-CNQL8BnO.mjs.map