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

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 (216) hide show
  1. package/README.md +1 -1
  2. package/dist/{HostingerProvider-mJ7YruxH.cjs → HostingerProvider-Dlmbfass.cjs} +3 -3
  3. package/dist/{HostingerProvider-mJ7YruxH.cjs.map → HostingerProvider-Dlmbfass.cjs.map} +1 -1
  4. package/dist/{HostingerProvider-DBBwpDjn.mjs → HostingerProvider-x9gQTAGZ.mjs} +2 -2
  5. package/dist/{HostingerProvider-DBBwpDjn.mjs.map → HostingerProvider-x9gQTAGZ.mjs.map} +1 -1
  6. package/dist/{LegacyStateStore-CP7SZwTP.cjs → LegacyStateStore-BGoo__sO.cjs} +2 -2
  7. package/dist/{LegacyStateStore-CP7SZwTP.cjs.map → LegacyStateStore-BGoo__sO.cjs.map} +1 -1
  8. package/dist/{LegacyStateStore-Q3GmKOdw.mjs → LegacyStateStore-BUu1nQ5u.mjs} +2 -2
  9. package/dist/{LegacyStateStore-Q3GmKOdw.mjs.map → LegacyStateStore-BUu1nQ5u.mjs.map} +1 -1
  10. package/dist/{LocalStateStore-sS8mvLeq.cjs → LocalStateStore-93urXyQe.cjs} +2 -2
  11. package/dist/{LocalStateStore-sS8mvLeq.cjs.map → LocalStateStore-93urXyQe.cjs.map} +1 -1
  12. package/dist/{LocalStateStore-BGIXcrvX.mjs → LocalStateStore-BRhMQRuy.mjs} +2 -2
  13. package/dist/{LocalStateStore-BGIXcrvX.mjs.map → LocalStateStore-BRhMQRuy.mjs.map} +1 -1
  14. package/dist/{OpenApiTsGenerator-CjHWFRDd.cjs → OpenApiTsGenerator-BWuDRHe9.cjs} +2 -2
  15. package/dist/{OpenApiTsGenerator-CjHWFRDd.cjs.map → OpenApiTsGenerator-BWuDRHe9.cjs.map} +1 -1
  16. package/dist/{OpenApiTsGenerator-CnAwhGxi.mjs → OpenApiTsGenerator-C6v-IeHt.mjs} +2 -2
  17. package/dist/{OpenApiTsGenerator-CnAwhGxi.mjs.map → OpenApiTsGenerator-C6v-IeHt.mjs.map} +1 -1
  18. package/dist/{S3StateStore-6jqITH2F.cjs → S3StateStore-F4dxw6kS.cjs} +2 -2
  19. package/dist/{S3StateStore-6jqITH2F.cjs.map → S3StateStore-F4dxw6kS.cjs.map} +1 -1
  20. package/dist/{S3StateStore-D7l_lWJ3.mjs → S3StateStore-pw1GhWwt.mjs} +2 -2
  21. package/dist/{S3StateStore-D7l_lWJ3.mjs.map → S3StateStore-pw1GhWwt.mjs.map} +1 -1
  22. package/dist/{SSMStateStore-B__F7IJa.cjs → SSMStateStore-Bt9acuAF.cjs} +2 -2
  23. package/dist/{SSMStateStore-B__F7IJa.cjs.map → SSMStateStore-Bt9acuAF.cjs.map} +1 -1
  24. package/dist/{SSMStateStore-CAQDVpoc.mjs → SSMStateStore-Dmj7zzFO.mjs} +2 -2
  25. package/dist/{SSMStateStore-CAQDVpoc.mjs.map → SSMStateStore-Dmj7zzFO.mjs.map} +1 -1
  26. package/dist/{bundler-DLfOn0ls.cjs → bundler-D6MlIfBT.cjs} +3 -3
  27. package/dist/{bundler-DLfOn0ls.cjs.map → bundler-D6MlIfBT.cjs.map} +1 -1
  28. package/dist/{bundler-DyWI41Iy.mjs → bundler-D_14JLZF.mjs} +3 -3
  29. package/dist/{bundler-DyWI41Iy.mjs.map → bundler-D_14JLZF.mjs.map} +1 -1
  30. package/dist/{cli-D-ZM-X2s.cjs → cli-BfH1deAT.cjs} +8 -7
  31. package/dist/{cli-D-ZM-X2s.cjs.map → cli-BfH1deAT.cjs.map} +1 -1
  32. package/dist/{cli-PkVF28LM.mjs → cli-P56vvrDQ.mjs} +5 -4
  33. package/dist/{cli-PkVF28LM.mjs.map → cli-P56vvrDQ.mjs.map} +1 -1
  34. package/dist/compose-391oEKj1.cjs +1982 -0
  35. package/dist/compose-391oEKj1.cjs.map +1 -0
  36. package/dist/compose-DprE3ASm.mjs +1862 -0
  37. package/dist/compose-DprE3ASm.mjs.map +1 -0
  38. package/dist/{config-C2BUosLm.d.mts → config-BonvTW8p.d.mts} +3 -3
  39. package/dist/{config-C2BUosLm.d.mts.map → config-BonvTW8p.d.mts.map} +1 -1
  40. package/dist/{config-CemHVcIr.d.cts → config-V_X_BMpm.d.cts} +3 -3
  41. package/dist/{config-CemHVcIr.d.cts.map → config-V_X_BMpm.d.cts.map} +1 -1
  42. package/dist/config.cjs +416 -17
  43. package/dist/config.cjs.map +1 -0
  44. package/dist/config.d.cts +3 -3
  45. package/dist/config.d.mts +3 -3
  46. package/dist/config.mjs +401 -2
  47. package/dist/config.mjs.map +1 -0
  48. package/dist/credentials-Bzbg23n8.cjs +298 -0
  49. package/dist/credentials-Bzbg23n8.cjs.map +1 -0
  50. package/dist/credentials-Dq1MnWQf.mjs +233 -0
  51. package/dist/credentials-Dq1MnWQf.mjs.map +1 -0
  52. package/dist/{define-CHBIEc5j.mjs → define-DR8xGYfL.mjs} +6 -3
  53. package/dist/define-DR8xGYfL.mjs.map +1 -0
  54. package/dist/{define-Cv_QvDrg.cjs → define-DzRz8FgH.cjs} +6 -3
  55. package/dist/define-DzRz8FgH.cjs.map +1 -0
  56. package/dist/deploy/public.cjs +39 -33
  57. package/dist/deploy/public.cjs.map +1 -1
  58. package/dist/deploy/public.d.cts +44 -5
  59. package/dist/deploy/public.d.cts.map +1 -1
  60. package/dist/deploy/public.d.mts +44 -5
  61. package/dist/deploy/public.d.mts.map +1 -1
  62. package/dist/deploy/public.mjs +15 -12
  63. package/dist/deploy/public.mjs.map +1 -1
  64. package/dist/{deploy-CGW-QY9D.mjs → deploy-9MBG_QLd.mjs} +11 -9
  65. package/dist/deploy-9MBG_QLd.mjs.map +1 -0
  66. package/dist/{deploy-BiMrP9i7.cjs → deploy-B80idPUZ.cjs} +17 -15
  67. package/dist/deploy-B80idPUZ.cjs.map +1 -0
  68. package/dist/{deploy-CG8bfFij.mjs → deploy-CZ5nlpsu.mjs} +16 -119
  69. package/dist/deploy-CZ5nlpsu.mjs.map +1 -0
  70. package/dist/{deploy-ABBI0lf1.cjs → deploy-Cy8igpQF.cjs} +48 -151
  71. package/dist/deploy-Cy8igpQF.cjs.map +1 -0
  72. package/dist/derive-B4vDpzgP.mjs +150 -0
  73. package/dist/derive-B4vDpzgP.mjs.map +1 -0
  74. package/dist/derive-DAbo49sm.cjs +161 -0
  75. package/dist/derive-DAbo49sm.cjs.map +1 -0
  76. package/dist/{discover-C_6COHEv.cjs → discover-DHdECueV.cjs} +6 -157
  77. package/dist/discover-DHdECueV.cjs.map +1 -0
  78. package/dist/{discover-BaT6bpnA.mjs → discover-LMrqsWSU.mjs} +8 -117
  79. package/dist/discover-LMrqsWSU.mjs.map +1 -0
  80. package/dist/{dokploy-CwdmlyQL.mjs → dokploy-BdtBePjp.mjs} +3 -3
  81. package/dist/{dokploy-CwdmlyQL.mjs.map → dokploy-BdtBePjp.mjs.map} +1 -1
  82. package/dist/{dokploy-QJxMhxdf.cjs → dokploy-iFY8MY-L.cjs} +3 -3
  83. package/dist/{dokploy-QJxMhxdf.cjs.map → dokploy-iFY8MY-L.cjs.map} +1 -1
  84. package/dist/{encryption-DXw3jj0c.cjs → encryption-B1wJwgae.cjs} +6 -6
  85. package/dist/{encryption-DXw3jj0c.cjs.map → encryption-B1wJwgae.cjs.map} +1 -1
  86. package/dist/{encryption-CbQG_ayW.mjs → encryption-DF_hgIpl.mjs} +5 -5
  87. package/dist/{encryption-CbQG_ayW.mjs.map → encryption-DF_hgIpl.mjs.map} +1 -1
  88. package/dist/{github-ciwbIwVa.mjs → github-B0YYE98x.mjs} +4 -4
  89. package/dist/{github-ciwbIwVa.mjs.map → github-B0YYE98x.mjs.map} +1 -1
  90. package/dist/{github-BH_mETav.cjs → github-CYcmTdFs.cjs} +4 -4
  91. package/dist/{github-BH_mETav.cjs.map → github-CYcmTdFs.cjs.map} +1 -1
  92. package/dist/{index-DrKzpHl-.d.mts → index-DPUAGJaK.d.cts} +16 -3
  93. package/dist/index-DPUAGJaK.d.cts.map +1 -0
  94. package/dist/{index-BtXDZQuF.d.cts → index-DwKD_8lt.d.mts} +16 -3
  95. package/dist/index-DwKD_8lt.d.mts.map +1 -0
  96. package/dist/index.cjs +280 -1849
  97. package/dist/index.cjs.map +1 -1
  98. package/dist/index.mjs +221 -1774
  99. package/dist/index.mjs.map +1 -1
  100. package/dist/local-BdH4XN0E.cjs +409 -0
  101. package/dist/local-BdH4XN0E.cjs.map +1 -0
  102. package/dist/local-CWR4Y_kW.mjs +350 -0
  103. package/dist/local-CWR4Y_kW.mjs.map +1 -0
  104. package/dist/{migrate-ImBKTBcW.mjs → migrate-B2qL5wj4.mjs} +8 -7
  105. package/dist/{migrate-ImBKTBcW.mjs.map → migrate-B2qL5wj4.mjs.map} +1 -1
  106. package/dist/{migrate-6oa9y_f2.cjs → migrate-q4pPAXtO.cjs} +21 -20
  107. package/dist/{migrate-6oa9y_f2.cjs.map → migrate-q4pPAXtO.cjs.map} +1 -1
  108. package/dist/openapi.cjs +2 -2
  109. package/dist/openapi.d.cts +1 -1
  110. package/dist/openapi.d.mts +1 -1
  111. package/dist/openapi.mjs +2 -2
  112. package/dist/provider-C9_-45d5.cjs +56 -0
  113. package/dist/provider-C9_-45d5.cjs.map +1 -0
  114. package/dist/provider-q4lsYzYG.mjs +45 -0
  115. package/dist/provider-q4lsYzYG.mjs.map +1 -0
  116. package/dist/{ready-Bpdnn2ON.mjs → ready-bQfu9GES.mjs} +3 -3
  117. package/dist/{ready-Bpdnn2ON.mjs.map → ready-bQfu9GES.mjs.map} +1 -1
  118. package/dist/{ready-BiG0rt4h.cjs → ready-brEhh68f.cjs} +3 -3
  119. package/dist/{ready-BiG0rt4h.cjs.map → ready-brEhh68f.cjs.map} +1 -1
  120. package/dist/reconcile/public.cjs +1 -1
  121. package/dist/reconcile/public.d.cts +1 -1
  122. package/dist/reconcile/public.d.mts +1 -1
  123. package/dist/reconcile/public.mjs +1 -1
  124. package/dist/resolve-DLkIXTct.mjs +262 -0
  125. package/dist/resolve-DLkIXTct.mjs.map +1 -0
  126. package/dist/resolve-N_i4XNd-.cjs +315 -0
  127. package/dist/resolve-N_i4XNd-.cjs.map +1 -0
  128. package/dist/{runtime-Dn_n-29S.d.cts → runtime-BnD7Nn96.d.cts} +2 -2
  129. package/dist/{runtime-CXPlkZzs.d.mts.map → runtime-BnD7Nn96.d.cts.map} +1 -1
  130. package/dist/{runtime-CXPlkZzs.d.mts → runtime-j-tmFL65.d.mts} +2 -2
  131. package/dist/{runtime-Dn_n-29S.d.cts.map → runtime-j-tmFL65.d.mts.map} +1 -1
  132. package/dist/sandbox/discover-worker.cjs +1 -1
  133. package/dist/sandbox/discover-worker.mjs +1 -1
  134. package/dist/sandbox-CL--ZDui.cjs +164 -0
  135. package/dist/sandbox-CL--ZDui.cjs.map +1 -0
  136. package/dist/sandbox-Dm247NGx.mjs +117 -0
  137. package/dist/sandbox-Dm247NGx.mjs.map +1 -0
  138. package/dist/sniffer-BSwaL-dX.cjs +2236 -0
  139. package/dist/sniffer-BSwaL-dX.cjs.map +1 -0
  140. package/dist/sniffer-BZ-OJO4Y.mjs +2068 -0
  141. package/dist/sniffer-BZ-OJO4Y.mjs.map +1 -0
  142. package/dist/sst-B2HbrDR3.mjs +430 -0
  143. package/dist/sst-B2HbrDR3.mjs.map +1 -0
  144. package/dist/sst-DcfsVH6x.cjs +453 -0
  145. package/dist/sst-DcfsVH6x.cjs.map +1 -0
  146. package/dist/{sniffer-aO_-s5vq.mjs → state-B8YwmUZU.mjs} +1204 -3236
  147. package/dist/state-B8YwmUZU.mjs.map +1 -0
  148. package/dist/{sniffer-D_SYc_pO.cjs → state-DF26e_lo.cjs} +1251 -3494
  149. package/dist/state-DF26e_lo.cjs.map +1 -0
  150. package/dist/{store-KvNQwYaB.cjs → store-CJF1Tqkq.cjs} +4 -4
  151. package/dist/{store-KvNQwYaB.cjs.map → store-CJF1Tqkq.cjs.map} +1 -1
  152. package/dist/{store-BS8A7NcA.mjs → store-CLiHnqOY.mjs} +2 -2
  153. package/dist/{store-BS8A7NcA.mjs.map → store-CLiHnqOY.mjs.map} +1 -1
  154. package/dist/target/public.cjs +6 -6
  155. package/dist/target/public.d.cts +3 -3
  156. package/dist/target/public.d.mts +3 -3
  157. package/dist/target/public.mjs +3 -3
  158. package/dist/terminal-Bs5E1oxm.cjs +88 -0
  159. package/dist/terminal-Bs5E1oxm.cjs.map +1 -0
  160. package/dist/terminal-CfbiYUbZ.mjs +84 -0
  161. package/dist/terminal-CfbiYUbZ.mjs.map +1 -0
  162. package/dist/{types-DIA7Li-J.d.cts → types-BCzMWBb6.d.mts} +84 -17
  163. package/dist/types-BCzMWBb6.d.mts.map +1 -0
  164. package/dist/{types-CfLKGfC_.d.mts → types-ByMWkXKP.d.cts} +85 -16
  165. package/dist/types-ByMWkXKP.d.cts.map +1 -0
  166. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  167. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  168. package/dist/utils-D_fxUqvU.mjs +156 -0
  169. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  170. package/dist/vitest.cjs +1 -1
  171. package/dist/vitest.mjs +1 -1
  172. package/dist/workspace/index.cjs +3 -1
  173. package/dist/workspace/index.d.cts +3 -3
  174. package/dist/workspace/index.d.mts +3 -3
  175. package/dist/workspace/index.mjs +2 -2
  176. package/dist/{workspace-Kl4NG9IH.cjs → workspace-BewAHZIo.cjs} +41 -6
  177. package/dist/workspace-BewAHZIo.cjs.map +1 -0
  178. package/dist/{workspace-Dh7rr7l4.mjs → workspace-C06_pW4g.mjs} +30 -7
  179. package/dist/workspace-C06_pW4g.mjs.map +1 -0
  180. package/package.json +13 -13
  181. package/dist/config-BEJYKd4s.cjs +0 -648
  182. package/dist/config-BEJYKd4s.cjs.map +0 -1
  183. package/dist/config-LKKCVCnC.mjs +0 -547
  184. package/dist/config-LKKCVCnC.mjs.map +0 -1
  185. package/dist/define-CHBIEc5j.mjs.map +0 -1
  186. package/dist/define-Cv_QvDrg.cjs.map +0 -1
  187. package/dist/deploy-ABBI0lf1.cjs.map +0 -1
  188. package/dist/deploy-BiMrP9i7.cjs.map +0 -1
  189. package/dist/deploy-CG8bfFij.mjs.map +0 -1
  190. package/dist/deploy-CGW-QY9D.mjs.map +0 -1
  191. package/dist/discover-BaT6bpnA.mjs.map +0 -1
  192. package/dist/discover-C_6COHEv.cjs.map +0 -1
  193. package/dist/home-DOzBaWaL.cjs +0 -33
  194. package/dist/home-DOzBaWaL.cjs.map +0 -1
  195. package/dist/home-GI7pJl1M.mjs +0 -22
  196. package/dist/home-GI7pJl1M.mjs.map +0 -1
  197. package/dist/index-BtXDZQuF.d.cts.map +0 -1
  198. package/dist/index-DrKzpHl-.d.mts.map +0 -1
  199. package/dist/resolve-B1T0hUaR.mjs +0 -170
  200. package/dist/resolve-B1T0hUaR.mjs.map +0 -1
  201. package/dist/resolve-xytBTtG4.cjs +0 -217
  202. package/dist/resolve-xytBTtG4.cjs.map +0 -1
  203. package/dist/runtime-CMwtq0AL.cjs +0 -163
  204. package/dist/runtime-CMwtq0AL.cjs.map +0 -1
  205. package/dist/runtime-DbakJS8u.mjs +0 -134
  206. package/dist/runtime-DbakJS8u.mjs.map +0 -1
  207. package/dist/sniffer-D_SYc_pO.cjs.map +0 -1
  208. package/dist/sniffer-aO_-s5vq.mjs.map +0 -1
  209. package/dist/terminal-D0f1u0LG.cjs +0 -576
  210. package/dist/terminal-D0f1u0LG.cjs.map +0 -1
  211. package/dist/terminal-gMxAo9Dj.mjs +0 -517
  212. package/dist/terminal-gMxAo9Dj.mjs.map +0 -1
  213. package/dist/types-CfLKGfC_.d.mts.map +0 -1
  214. package/dist/types-DIA7Li-J.d.cts.map +0 -1
  215. package/dist/workspace-Dh7rr7l4.mjs.map +0 -1
  216. package/dist/workspace-Kl4NG9IH.cjs.map +0 -1
@@ -1,576 +0,0 @@
1
- const require_sniffer = require("./sniffer-D_SYc_pO.cjs");
2
- const require_discover = require("./discover-C_6COHEv.cjs");
3
- const require_config = require("./config-BEJYKd4s.cjs");
4
- const require_define = require("./define-Cv_QvDrg.cjs");
5
- const require_workspace = require("./workspace-Kl4NG9IH.cjs");
6
- const require_store = require("./store-KvNQwYaB.cjs");
7
- const require_resolve = require("./resolve-xytBTtG4.cjs");
8
- //#region src/deploy/credentials.ts
9
- /**
10
- * How a deploy gets the credentials it acts with.
11
- *
12
- * `deploy()` never prompts and never reads a terminal: it asks a
13
- * `CredentialProvider` and, when the provider has nothing, stops with
14
- * `MissingCredential` naming what it needed and how to supply it. Whether to
15
- * ask a person, read a vault or fail is the caller's decision — `gkm deploy`
16
- * prompts at a terminal and stores what was typed; a CI job sets the
17
- * environment; a host passes its own provider.
18
- */
19
- /**
20
- * How to supply each kind the CLI knows, for the error that says it is
21
- * missing. A target's own kinds are its to explain.
22
- */
23
- const HOW_TO_PROVIDE = {
24
- dokploy: "Set DOKPLOY_API_TOKEN (and DOKPLOY_ENDPOINT, or deploy.dokploy.endpoint in gkm.config.ts), run `gkm login --provider dokploy`, or pass them through the deploy's CredentialProvider.",
25
- registry: "Add the registry in Dokploy (Settings → Docker Registry) and set deploy.dokploy.registryId, set DOCKER_REGISTRY_USERNAME and DOCKER_REGISTRY_PASSWORD, or run `gkm deploy` at a terminal to be asked for them."
26
- };
27
- /** A deploy needed a credential, and its provider had none. */
28
- var MissingCredential = class extends Error {
29
- kind;
30
- target;
31
- howToProvide;
32
- constructor(kind, target, howToProvide = HOW_TO_PROVIDE[kind] ?? "Pass it through the deploy's CredentialProvider.") {
33
- const what = kind === "dokploy" ? `No Dokploy credentials${target ? ` for ${target}` : ""}.` : kind === "registry" ? `Dokploy has no registry for ${target ?? "the configured registry"}, and there are no credentials to create one with.` : `No "${String(kind)}" credentials${target ? ` for ${target}` : ""}.`;
34
- super(`${what} ${howToProvide}`);
35
- this.kind = kind;
36
- this.target = target;
37
- this.howToProvide = howToProvide;
38
- this.name = "MissingCredential";
39
- }
40
- };
41
- /** Whatever was asked for, from the first provider that has it. */
42
- function chainCredentials(...providers) {
43
- return { async get(request, options) {
44
- for (const provider of providers) {
45
- const found = await provider.get(request, options);
46
- if (found) return found;
47
- }
48
- } };
49
- }
50
- /**
51
- * Credentials from the environment, then from what `gkm login` stored. What
52
- * `deploy()` uses when it is handed no provider.
53
- *
54
- * - Dokploy: `DOKPLOY_API_TOKEN` / `DOKPLOY_ENDPOINT`, each falling back to
55
- * the stored login, and the endpoint finally to `deploy.dokploy.endpoint`.
56
- * Each half is read on its own: a token is a secret and belongs in the
57
- * environment, an endpoint is configuration and belongs in the config.
58
- * - Registry: `DOCKER_REGISTRY_USERNAME` / `DOCKER_REGISTRY_PASSWORD`.
59
- */
60
- function storedCredentials(options = {}) {
61
- const env = options.env ?? process.env;
62
- return { async get(asked) {
63
- const request = asked;
64
- switch (request.kind) {
65
- case "dokploy": {
66
- const stored = (await require_sniffer.readCredentials(options.home ? { home: options.home } : void 0)).dokploy;
67
- const token = env.DOKPLOY_API_TOKEN ?? stored?.token;
68
- const endpoint = env.DOKPLOY_ENDPOINT ?? stored?.endpoint ?? request.endpoint;
69
- if (!token || !endpoint) return void 0;
70
- return {
71
- endpoint: endpoint.replace(/\/$/, ""),
72
- token
73
- };
74
- }
75
- case "registry": {
76
- const username = env.DOCKER_REGISTRY_USERNAME;
77
- const password = env.DOCKER_REGISTRY_PASSWORD;
78
- if (!username || !password) return void 0;
79
- return {
80
- username,
81
- password
82
- };
83
- }
84
- }
85
- } };
86
- }
87
- //#endregion
88
- //#region src/target/secrets.ts
89
- /**
90
- * A stage's secrets as a target sees them: read and written through the
91
- * stage's own store, and masked in everything the run prints once read.
92
- */
93
- /**
94
- * Shorter values are left alone: what a progress line legitimately prints —
95
- * a port, a stage, an app name — would otherwise come out as `***` wherever
96
- * a secret happened to share it.
97
- */
98
- const SHORTEST_MASKED = 6;
99
- /** The values a run must never print, and the rewrite that keeps it so. */
100
- var Redactor = class {
101
- values = /* @__PURE__ */ new Set();
102
- add(value) {
103
- if (value && value.length >= SHORTEST_MASKED) this.values.add(value);
104
- }
105
- /** `text` with every masked value replaced by `***`, longest first. */
106
- redact(text) {
107
- if (this.values.size === 0) return text;
108
- let out = text;
109
- const longestFirst = [...this.values].sort((a, b) => b.length - a.length);
110
- for (const value of longestFirst) out = out.replaceAll(value, "***");
111
- return out;
112
- }
113
- };
114
- /** Every value in `secrets` that is a secret rather than a label. */
115
- function secretValues(secrets) {
116
- return [
117
- secrets.seed,
118
- ...Object.values(secrets.custom ?? {}),
119
- ...Object.values(secrets.urls ?? {}),
120
- ...Object.values(secrets.services ?? {}).map((service) => service?.password)
121
- ].filter((value) => typeof value === "string");
122
- }
123
- /**
124
- * The stage's secrets through the store `secrets.store` names for it. Opening
125
- * one builds a client and makes no request, so a target that never reads them
126
- * costs nothing.
127
- */
128
- async function deploySecrets(workspace, stage, redactor, options = {}) {
129
- const store = await require_store.secretsStoreFor(workspace, stage, options);
130
- const mask = (secrets) => {
131
- for (const value of secretValues(secrets)) redactor.add(value);
132
- };
133
- return {
134
- store: store.name,
135
- async read() {
136
- const secrets = await store.read(stage);
137
- if (secrets) mask(secrets);
138
- return secrets;
139
- },
140
- async write(secrets) {
141
- mask(secrets);
142
- await store.write(stage, secrets);
143
- },
144
- mask: (value) => redactor.add(value)
145
- };
146
- }
147
- //#endregion
148
- //#region src/deploy/events.ts
149
- /** An error as an event carries it: its name and message, nothing else. */
150
- function eventError(error) {
151
- if (error instanceof Error) return {
152
- name: error.name,
153
- message: error.message
154
- };
155
- return {
156
- name: "Error",
157
- message: String(error)
158
- };
159
- }
160
- //#endregion
161
- //#region src/deploy/orchestrate.ts
162
- /**
163
- * The run around a target: what every deploy does whatever it deploys
164
- * through.
165
- *
166
- * It loads the workspace, resolves the target, works out the apps and the
167
- * identity, takes the stage's lock, and calls the target's phases in order,
168
- * reporting each as it starts, finishes or fails. Everything that is about
169
- * *where* the stage goes is the target's.
170
- */
171
- /** Apps were asked for by name that the workspace does not have. */
172
- var UnknownDeployApps = class extends Error {
173
- apps;
174
- available;
175
- constructor(apps, available) {
176
- super(`Unknown apps: ${apps.join(", ")}\nAvailable apps: ${available.join(", ")}`);
177
- this.apps = apps;
178
- this.available = available;
179
- this.name = "UnknownDeployApps";
180
- }
181
- };
182
- /** Every app asked for deploys through some other target. */
183
- var NoDeployableApps = class extends Error {
184
- stage;
185
- target;
186
- constructor(stage, target) {
187
- super(`No apps to deploy through "${target}": every selected app deploys somewhere else. Pick the target with --target, or set each app's deploy in gkm.config.ts.`);
188
- this.stage = stage;
189
- this.target = target;
190
- this.name = "NoDeployableApps";
191
- }
192
- };
193
- /** A failed rollback, after the failure that called for it. */
194
- var RollbackFailed = class extends Error {
195
- target;
196
- failure;
197
- constructor(target, failure, cause) {
198
- super(`Deploying through "${target}" failed, and so did rolling it back: ${cause instanceof Error ? cause.message : String(cause)}. The stage may be part-released; deploy again, or roll it back by hand. The first failure: ${failure instanceof Error ? failure.message : String(failure)}`, { cause });
199
- this.target = target;
200
- this.failure = failure;
201
- this.name = "RollbackFailed";
202
- }
203
- };
204
- /**
205
- * Generate image tag from stage and timestamp
206
- */
207
- function generateTag(stage) {
208
- return `${stage}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19)}`;
209
- }
210
- /** Why an app that deploys through another target is left out. */
211
- function elsewhere(target, stage) {
212
- const instead = require_define.builtinTarget(target)?.instead?.(stage);
213
- if (target === "sst" && instead) return `it deploys with SST — ${instead}`;
214
- return `it deploys through "${target}" — run \`gkm deploy --target ${target} --stage ${stage}\``;
215
- }
216
- /**
217
- * Deploy a workspace's stage through its target.
218
- *
219
- * The engine under `deploy()` and `gkm deploy`. It never prompts and never
220
- * exits: credentials come from `ctx.credentials`, progress goes to
221
- * `ctx.emit` and to `output`, and every failure is thrown.
222
- *
223
- * @internal
224
- */
225
- async function runDeploy(source, request, ctx) {
226
- const { stage } = request;
227
- const redactor = ctx.redactor ?? new Redactor();
228
- const emit = (event) => ctx.emit(event.type === "log" ? {
229
- ...event,
230
- message: redactor.redact(event.message)
231
- } : event);
232
- /** Run one phase between its events. */
233
- const phase = async (name, body) => {
234
- ctx.signal?.throwIfAborted();
235
- emit({
236
- type: "phase.started",
237
- phase: name
238
- });
239
- try {
240
- const value = await body();
241
- emit({
242
- type: "phase.finished",
243
- phase: name
244
- });
245
- return value;
246
- } catch (error) {
247
- emit({
248
- type: "phase.failed",
249
- phase: name,
250
- error: eventError(error)
251
- });
252
- throw error;
253
- }
254
- };
255
- ctx.signal?.throwIfAborted();
256
- emit({
257
- type: "phase.started",
258
- phase: "validate"
259
- });
260
- let prepared;
261
- try {
262
- prepared = await prepare(source, request, ctx, emit, redactor);
263
- } catch (error) {
264
- emit({
265
- type: "phase.failed",
266
- phase: "validate",
267
- error: eventError(error)
268
- });
269
- throw error;
270
- }
271
- const { resolved, phaseCtx, store } = prepared;
272
- const { target } = resolved;
273
- if (ctx.dryRun) {
274
- const run = await validate(target, phaseCtx, emit);
275
- await phase("plan", () => target.plan(phaseCtx, run));
276
- return target.result(phaseCtx, run);
277
- }
278
- let lock;
279
- try {
280
- lock = await store.lock(stage, { operation: "deploy" });
281
- } catch (error) {
282
- emit({
283
- type: "phase.failed",
284
- phase: "validate",
285
- error: eventError(error)
286
- });
287
- throw error;
288
- }
289
- try {
290
- const run = await validate(target, phaseCtx, emit);
291
- if (target.provision) await phase("provision", () => target.provision(phaseCtx, run));
292
- if (target.build) await phase("build", () => target.build(phaseCtx, run));
293
- let releasing = "release";
294
- try {
295
- await phase("release", () => target.release(phaseCtx, run));
296
- releasing = "verify";
297
- if (target.verify) await phase("verify", () => target.verify(phaseCtx, run));
298
- } catch (error) {
299
- if (ctx.signal?.aborted || !target.capabilities.rollback) throw error;
300
- if (!target.rollback) throw error;
301
- try {
302
- await phase("rollback", () => target.rollback(phaseCtx, run, {
303
- phase: releasing,
304
- error
305
- }));
306
- } catch (rollbackError) {
307
- throw new RollbackFailed(resolved.name, error, rollbackError);
308
- }
309
- throw error;
310
- }
311
- return await target.result(phaseCtx, run);
312
- } finally {
313
- await lock.release();
314
- }
315
- }
316
- /** `validate`, then the run's `deploy.started`, inside the validate phase. */
317
- async function validate(target, phaseCtx, emit) {
318
- try {
319
- const run = await target.validate(phaseCtx);
320
- const skipped = new Set(phaseCtx.skipped.map((s) => s.app));
321
- emit({
322
- type: "deploy.started",
323
- stage: phaseCtx.stage,
324
- target: phaseCtx.target,
325
- identity: phaseCtx.identity.key,
326
- tag: phaseCtx.tag,
327
- apps: phaseCtx.apps.filter((app) => !skipped.has(app)),
328
- dryRun: phaseCtx.dryRun
329
- });
330
- emit({
331
- type: "phase.finished",
332
- phase: "validate"
333
- });
334
- return run;
335
- } catch (error) {
336
- emit({
337
- type: "phase.failed",
338
- phase: "validate",
339
- error: eventError(error)
340
- });
341
- throw error;
342
- }
343
- }
344
- /** Everything the phases are handed, worked out before the first of them. */
345
- async function prepare(source, request, ctx, emit, redactor) {
346
- const { stage } = request;
347
- const configured = typeof source === "function" ? await source() : source;
348
- const targetName = request.target ?? configured.deploy?.default ?? "dokploy";
349
- const resolved = await require_resolve.resolveTarget(targetName, {
350
- workspace: configured,
351
- stage,
352
- ...ctx.targets ? { host: ctx.targets } : {}
353
- });
354
- const options = await require_resolve.parseTargetOptions(resolved);
355
- const manifest = await require_discover.discover({
356
- patterns: require_sniffer.constructGlobs(configured),
357
- cwd: configured.root
358
- });
359
- const units = require_config.derivedApps(manifest, configured);
360
- const workspace = Object.keys(units).length > 0 ? {
361
- ...configured,
362
- apps: units
363
- } : configured;
364
- const identity = require_store.deployIdentity(workspace, stage);
365
- const tag = request.tag ?? generateTag(stage);
366
- const buildOrder = require_workspace.getAppBuildOrder(workspace);
367
- let selected = buildOrder;
368
- if (request.apps && request.apps.length > 0) {
369
- const unknown = request.apps.filter((name) => !workspace.apps[name]);
370
- if (unknown.length > 0) throw new UnknownDeployApps(unknown, Object.keys(workspace.apps));
371
- selected = buildOrder.filter((name) => request.apps.includes(name));
372
- }
373
- const skipped = [];
374
- const skip = (app, reason) => {
375
- skipped.push({
376
- app,
377
- reason
378
- });
379
- emit({
380
- type: "app.skipped",
381
- app,
382
- reason
383
- });
384
- };
385
- const byDefault = configured.deploy?.default ?? "dokploy";
386
- const apps = selected.filter((name) => {
387
- const own = workspace.apps[name].resolvedDeployTarget;
388
- const deploysThrough = own === byDefault ? targetName : own;
389
- if (deploysThrough === targetName) return true;
390
- skip(name, elsewhere(deploysThrough, stage));
391
- return false;
392
- });
393
- if (apps.length === 0) throw new NoDeployableApps(stage, targetName);
394
- const store = await require_sniffer.createStateStore({
395
- config: workspace.state,
396
- workspaceRoot: workspace.root,
397
- workspaceName: workspace.name
398
- });
399
- const secrets = await deploySecrets(workspace, stage, redactor, { ...ctx.home ? { home: ctx.home } : {} });
400
- const line = (level) => (message) => emit({
401
- type: "log",
402
- level,
403
- message
404
- });
405
- const logger = {
406
- info: line("info"),
407
- warn: line("warn"),
408
- error: line("error")
409
- };
410
- return {
411
- resolved,
412
- phaseCtx: {
413
- target: targetName,
414
- cwd: workspace.root,
415
- stage,
416
- tag,
417
- apps,
418
- skipped,
419
- identity,
420
- workspace,
421
- manifest,
422
- options,
423
- dryRun: ctx.dryRun,
424
- credentials: ctx.credentials,
425
- state: store,
426
- secrets,
427
- logger,
428
- signal: ctx.signal ?? new AbortController().signal,
429
- childOutput: ctx.childOutput ?? "inherit",
430
- emit,
431
- skip,
432
- name: (resource) => require_store.applicationName(identity, resource)
433
- },
434
- store
435
- };
436
- }
437
- //#endregion
438
- //#region src/deploy/terminal.ts
439
- /**
440
- * The credentials `gkm deploy` can ask a person for. CLI layer only.
441
- *
442
- * `deploy()` asks its `CredentialProvider` and stops with `MissingCredential`
443
- * when the answer is nothing. At a terminal, `gkm deploy` would rather ask:
444
- * this provider reads the environment and the stored login first, and only
445
- * when both are empty prompts — and stores a Dokploy login it validated, so
446
- * the next deploy does not ask again. With no terminal it answers nothing, and
447
- * the deploy says what was missing instead of waiting on a prompt nobody sees.
448
- */
449
- const logger = require_discover.output;
450
- /** What answers a deploy prompt without a terminal. */
451
- const INSTEAD = "Please configure manually.";
452
- /** The Dokploy URL typed at the prompt is not a URL. */
453
- var DokployEndpointInvalid = class extends Error {
454
- endpoint;
455
- constructor(endpoint) {
456
- super("Invalid URL format");
457
- this.endpoint = endpoint;
458
- this.name = "DokployEndpointInvalid";
459
- }
460
- };
461
- /** Dokploy refused the token typed at the prompt; nothing was stored. */
462
- var DokployTokenRejected = class extends Error {
463
- endpoint;
464
- constructor(endpoint) {
465
- super("Invalid credentials. Please check your token.");
466
- this.endpoint = endpoint;
467
- this.name = "DokployTokenRejected";
468
- }
469
- };
470
- /** Asks the person at the terminal for what nothing else supplied. */
471
- function asking() {
472
- return { async get(asked) {
473
- if (!require_sniffer.canPrompt()) return void 0;
474
- const request = asked;
475
- if (request.kind === "dokploy") {
476
- logger.log("\n📋 Dokploy credentials not found. Let's set them up.");
477
- const endpoint = (await require_sniffer.prompt("Dokploy URL (e.g., https://dokploy.example.com): ", { instead: INSTEAD })).replace(/\/$/, "");
478
- try {
479
- new URL(endpoint);
480
- } catch {
481
- throw new DokployEndpointInvalid(endpoint);
482
- }
483
- logger.log(`\nGenerate a token at: ${endpoint}/settings/profile\n`);
484
- const token = await require_sniffer.prompt("API Token: ", {
485
- hidden: true,
486
- instead: INSTEAD
487
- });
488
- logger.log("\nValidating credentials...");
489
- if (!await require_sniffer.validateDokployToken(endpoint, token)) throw new DokployTokenRejected(endpoint);
490
- await require_sniffer.storeDokployCredentials(token, endpoint);
491
- logger.log("✓ Credentials saved");
492
- return {
493
- endpoint,
494
- token
495
- };
496
- }
497
- logger.log(` Dokploy has no registry for ${request.url}. Let's create one.`);
498
- return {
499
- username: await require_sniffer.prompt("Registry username: ", { instead: INSTEAD }),
500
- password: await require_sniffer.prompt("Registry password/token: ", {
501
- hidden: true,
502
- instead: INSTEAD
503
- })
504
- };
505
- } };
506
- }
507
- /**
508
- * The environment, then the stored login, then — at a terminal — the person
509
- * running the command.
510
- */
511
- function terminalCredentials(base = storedCredentials()) {
512
- return chainCredentials(base, asking());
513
- }
514
- //#endregion
515
- Object.defineProperty(exports, "MissingCredential", {
516
- enumerable: true,
517
- get: function() {
518
- return MissingCredential;
519
- }
520
- });
521
- Object.defineProperty(exports, "NoDeployableApps", {
522
- enumerable: true,
523
- get: function() {
524
- return NoDeployableApps;
525
- }
526
- });
527
- Object.defineProperty(exports, "Redactor", {
528
- enumerable: true,
529
- get: function() {
530
- return Redactor;
531
- }
532
- });
533
- Object.defineProperty(exports, "RollbackFailed", {
534
- enumerable: true,
535
- get: function() {
536
- return RollbackFailed;
537
- }
538
- });
539
- Object.defineProperty(exports, "UnknownDeployApps", {
540
- enumerable: true,
541
- get: function() {
542
- return UnknownDeployApps;
543
- }
544
- });
545
- Object.defineProperty(exports, "chainCredentials", {
546
- enumerable: true,
547
- get: function() {
548
- return chainCredentials;
549
- }
550
- });
551
- Object.defineProperty(exports, "eventError", {
552
- enumerable: true,
553
- get: function() {
554
- return eventError;
555
- }
556
- });
557
- Object.defineProperty(exports, "runDeploy", {
558
- enumerable: true,
559
- get: function() {
560
- return runDeploy;
561
- }
562
- });
563
- Object.defineProperty(exports, "storedCredentials", {
564
- enumerable: true,
565
- get: function() {
566
- return storedCredentials;
567
- }
568
- });
569
- Object.defineProperty(exports, "terminalCredentials", {
570
- enumerable: true,
571
- get: function() {
572
- return terminalCredentials;
573
- }
574
- });
575
-
576
- //# sourceMappingURL=terminal-D0f1u0LG.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"terminal-D0f1u0LG.cjs","names":["readCredentials","secretsStoreFor","builtinTarget","resolveTarget","parseTargetOptions","discover","constructGlobs","derivedApps","deployIdentity","getAppBuildOrder","createStateStore","applicationName","output","canPrompt","prompt","validateDokployToken","storeDokployCredentials"],"sources":["../src/deploy/credentials.ts","../src/target/secrets.ts","../src/deploy/events.ts","../src/deploy/orchestrate.ts","../src/deploy/terminal.ts"],"sourcesContent":["/**\n * How a deploy gets the credentials it acts with.\n *\n * `deploy()` never prompts and never reads a terminal: it asks a\n * `CredentialProvider` and, when the provider has nothing, stops with\n * `MissingCredential` naming what it needed and how to supply it. Whether to\n * ask a person, read a vault or fail is the caller's decision — `gkm deploy`\n * prompts at a terminal and stores what was typed; a CI job sets the\n * environment; a host passes its own provider.\n */\n\nimport { readCredentials } from '../auth/credentials';\n\n/**\n * What each kind of credential is asked for with, and what it is.\n *\n * A target that needs a kind the CLI does not know declares it by augmenting\n * this interface, and lists it in its `credentials`:\n *\n * ```ts\n * declare module '@geekmidas/cli/target' {\n * interface CredentialKinds {\n * fly: { request: { org: string }; value: { token: string } };\n * }\n * }\n * ```\n */\nexport interface CredentialKinds {\n\t/** The Dokploy API a stage deploys through. */\n\tdokploy: {\n\t\t/** `deploy.dokploy.endpoint`, when the config names one. */\n\t\trequest: { endpoint?: string };\n\t\tvalue: { endpoint: string; token: string };\n\t};\n\t/**\n\t * A container registry login, for Dokploy to pull with. Asked for only when\n\t * Dokploy has no registry for `deploy.dokploy.registry` and one has to be\n\t * created.\n\t */\n\tregistry: {\n\t\t/** `deploy.dokploy.registry`. */\n\t\trequest: { url: string };\n\t\tvalue: { username: string; password: string };\n\t};\n}\n\nexport type CredentialKind = keyof CredentialKinds;\n\n/** What a deploy asks a provider for. */\nexport type CredentialRequest<K extends CredentialKind = CredentialKind> = {\n\t[P in K]: { kind: P } & CredentialKinds[P]['request'];\n}[K];\n\n/** What a provider answers with. */\nexport type Credential<K extends CredentialKind> = CredentialKinds[K]['value'];\n\nexport interface CredentialProvider {\n\t/**\n\t * The credential `request` asks for, or `undefined` when this provider has\n\t * none — the deploy then raises {@link MissingCredential}.\n\t */\n\tget<K extends CredentialKind>(\n\t\trequest: CredentialRequest<K>,\n\t\toptions?: { signal?: AbortSignal },\n\t): Promise<Credential<K> | undefined>;\n}\n\n/**\n * How to supply each kind the CLI knows, for the error that says it is\n * missing. A target's own kinds are its to explain.\n */\nconst HOW_TO_PROVIDE: Partial<Record<CredentialKind, string>> = {\n\tdokploy:\n\t\t\"Set DOKPLOY_API_TOKEN (and DOKPLOY_ENDPOINT, or deploy.dokploy.endpoint in gkm.config.ts), run `gkm login --provider dokploy`, or pass them through the deploy's CredentialProvider.\",\n\tregistry:\n\t\t'Add the registry in Dokploy (Settings → Docker Registry) and set deploy.dokploy.registryId, set DOCKER_REGISTRY_USERNAME and DOCKER_REGISTRY_PASSWORD, or run `gkm deploy` at a terminal to be asked for them.',\n};\n\n/** A deploy needed a credential, and its provider had none. */\nexport class MissingCredential extends Error {\n\tconstructor(\n\t\treadonly kind: CredentialKind,\n\t\t/** What it was for: the Dokploy endpoint or the registry URL. */\n\t\treadonly target: string | undefined,\n\t\t/** How to supply it. */\n\t\treadonly howToProvide: string = HOW_TO_PROVIDE[kind] ??\n\t\t\t\"Pass it through the deploy's CredentialProvider.\",\n\t) {\n\t\tconst what =\n\t\t\tkind === 'dokploy'\n\t\t\t\t? `No Dokploy credentials${target ? ` for ${target}` : ''}.`\n\t\t\t\t: kind === 'registry'\n\t\t\t\t\t? `Dokploy has no registry for ${target ?? 'the configured registry'}, and there are no credentials to create one with.`\n\t\t\t\t\t: `No \"${String(kind)}\" credentials${target ? ` for ${target}` : ''}.`;\n\t\tsuper(`${what} ${howToProvide}`);\n\t\tthis.name = 'MissingCredential';\n\t}\n}\n\n/** Whatever was asked for, from the first provider that has it. */\nexport function chainCredentials(\n\t...providers: CredentialProvider[]\n): CredentialProvider {\n\treturn {\n\t\tasync get(request, options) {\n\t\t\tfor (const provider of providers) {\n\t\t\t\tconst found = await provider.get(request, options);\n\t\t\t\tif (found) return found;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n\nexport interface StoredCredentialsOptions {\n\t/** Where to read the variables from. Defaults to `process.env`. */\n\tenv?: NodeJS.ProcessEnv;\n\t/**\n\t * The CLI's home, whose `credentials.json` holds stored logins. Defaults\n\t * to `GKM_HOME`, else `~/.gkm`.\n\t */\n\thome?: string;\n}\n\n/**\n * Credentials from the environment, then from what `gkm login` stored. What\n * `deploy()` uses when it is handed no provider.\n *\n * - Dokploy: `DOKPLOY_API_TOKEN` / `DOKPLOY_ENDPOINT`, each falling back to\n * the stored login, and the endpoint finally to `deploy.dokploy.endpoint`.\n * Each half is read on its own: a token is a secret and belongs in the\n * environment, an endpoint is configuration and belongs in the config.\n * - Registry: `DOCKER_REGISTRY_USERNAME` / `DOCKER_REGISTRY_PASSWORD`.\n */\nexport function storedCredentials(\n\toptions: StoredCredentialsOptions = {},\n): CredentialProvider {\n\tconst env = options.env ?? process.env;\n\n\treturn {\n\t\tasync get(asked) {\n\t\t\t// The union, so a switch on `kind` narrows it: `K` itself never is.\n\t\t\tconst request = asked as CredentialRequest;\n\t\t\tswitch (request.kind) {\n\t\t\t\tcase 'dokploy': {\n\t\t\t\t\tconst stored = (\n\t\t\t\t\t\tawait readCredentials(\n\t\t\t\t\t\t\toptions.home ? { home: options.home } : undefined,\n\t\t\t\t\t\t)\n\t\t\t\t\t).dokploy;\n\t\t\t\t\tconst token = env.DOKPLOY_API_TOKEN ?? stored?.token;\n\t\t\t\t\tconst endpoint =\n\t\t\t\t\t\tenv.DOKPLOY_ENDPOINT ?? stored?.endpoint ?? request.endpoint;\n\t\t\t\t\tif (!token || !endpoint) return undefined;\n\t\t\t\t\treturn { endpoint: endpoint.replace(/\\/$/, ''), token } as never;\n\t\t\t\t}\n\t\t\t\tcase 'registry': {\n\t\t\t\t\tconst username = env.DOCKER_REGISTRY_USERNAME;\n\t\t\t\t\tconst password = env.DOCKER_REGISTRY_PASSWORD;\n\t\t\t\t\tif (!username || !password) return undefined;\n\t\t\t\t\treturn { username, password } as never;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// A kind a target declared: nothing stored here can answer it.\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n","/**\n * A stage's secrets as a target sees them: read and written through the\n * stage's own store, and masked in everything the run prints once read.\n */\n\nimport { secretsStoreFor } from '../secrets/store';\nimport type { StageSecrets } from '../secrets/types';\nimport type { NormalizedWorkspace } from '../workspace/types';\nimport type { DeploySecrets } from './types';\n\n/**\n * Shorter values are left alone: what a progress line legitimately prints —\n * a port, a stage, an app name — would otherwise come out as `***` wherever\n * a secret happened to share it.\n */\nconst SHORTEST_MASKED = 6;\n\n/** The values a run must never print, and the rewrite that keeps it so. */\nexport class Redactor {\n\tprivate readonly values = new Set<string>();\n\n\tadd(value: string | undefined): void {\n\t\tif (value && value.length >= SHORTEST_MASKED) this.values.add(value);\n\t}\n\n\t/** `text` with every masked value replaced by `***`, longest first. */\n\tredact(text: string): string {\n\t\tif (this.values.size === 0) return text;\n\t\tlet out = text;\n\t\tconst longestFirst = [...this.values].sort((a, b) => b.length - a.length);\n\t\tfor (const value of longestFirst) out = out.replaceAll(value, '***');\n\t\treturn out;\n\t}\n}\n\n/** Every value in `secrets` that is a secret rather than a label. */\nfunction secretValues(secrets: StageSecrets): string[] {\n\treturn [\n\t\tsecrets.seed,\n\t\t...Object.values(secrets.custom ?? {}),\n\t\t...Object.values(secrets.urls ?? {}),\n\t\t...Object.values(secrets.services ?? {}).map(\n\t\t\t(service) => service?.password,\n\t\t),\n\t].filter((value): value is string => typeof value === 'string');\n}\n\n/**\n * The stage's secrets through the store `secrets.store` names for it. Opening\n * one builds a client and makes no request, so a target that never reads them\n * costs nothing.\n */\nexport async function deploySecrets(\n\tworkspace: NormalizedWorkspace,\n\tstage: string,\n\tredactor: Redactor,\n\toptions: { home?: string } = {},\n): Promise<DeploySecrets> {\n\tconst store = await secretsStoreFor(workspace, stage, options);\n\tconst mask = (secrets: StageSecrets) => {\n\t\tfor (const value of secretValues(secrets)) redactor.add(value);\n\t};\n\n\treturn {\n\t\tstore: store.name,\n\t\tasync read() {\n\t\t\tconst secrets = await store.read(stage);\n\t\t\tif (secrets) mask(secrets);\n\t\t\treturn secrets;\n\t\t},\n\t\tasync write(secrets) {\n\t\t\tmask(secrets);\n\t\t\tawait store.write(stage, secrets);\n\t\t},\n\t\tmask: (value) => redactor.add(value),\n\t};\n}\n","/**\n * What a deploy reports while it runs.\n *\n * Plain JSON objects, discriminated by `type`: `gkm deploy --json` writes them\n * one per line, and a host can forward them to a UI or a log pipeline without\n * a serialiser of its own. Nothing in an event is a class instance, a function\n * or a secret — an error travels as its name and message, a credential never\n * travels at all.\n *\n * Every target reports through this one union, so a UI renders a Dokploy\n * deploy and a plugin's the same way.\n *\n * The union only grows: a new event is a new `type`, a new field is optional,\n * and nothing that exists changes meaning. A consumer ignores types it does\n * not know. That is why the events carry no version number — the CLI that\n * writes a stream and the program that reads it agree by that rule rather\n * than by negotiating one.\n */\n\nimport type { DeployResult } from './types';\n\n/**\n * The stretch of a deploy an event belongs to.\n *\n * - `validate`: the config, the target, the stage, the apps, the lock, the\n * stage's secrets and what each app reads from its environment\n * - `plan`: a dry run's lookups — what would be created and what reused\n * - `provision`: what the apps run on — for Dokploy the project, environment\n * and registry — and the declared constructs\n * - `build`: each app's artifact, built without changing anything live\n * - `release`: the artifacts put live. Dokploy builds and pushes each image\n * here, beside its application, because a site's build args are resolved\n * per app\n * - `verify`: what was released answers — for Dokploy, DNS records and its\n * domain validation\n * - `rollback`: the previous release restored, after `release` or `verify`\n * failed, on a target that can\n */\nexport type DeployPhase =\n\t| 'validate'\n\t| 'plan'\n\t| 'provision'\n\t| 'build'\n\t| 'release'\n\t| 'verify'\n\t| 'rollback';\n\n/** An error, as an event carries it. */\nexport interface DeployEventError {\n\t/** The error's class name — `MissingCredential`, `StateLocked`. */\n\tname: string;\n\tmessage: string;\n}\n\n/**\n * How a resource came to be used:\n * - `recorded`: the id the stage's state holds still resolves\n * - `resumed`: a run that died after creating it is picked up\n * - `found`: it existed and was looked up\n * - `created`: this run created it\n */\nexport type ResourceVia = 'recorded' | 'resumed' | 'found' | 'created';\n\n/** One resource a deploy touches, planned or applied. */\nexport interface ResourceChange {\n\t/** `<type>:<name>`, unique within the stage — `application:api`. */\n\tkey: string;\n\t/** `project`, `environment`, `registry`, `application`, `domain`, `image`, or a construct's kind. */\n\tresourceType: string;\n\t/**\n\t * For a plan: whether the run would create it, reuse what exists, or\n\t * ensure it (look it up, and create it if missing). For an applied change:\n\t * what was done.\n\t */\n\taction: 'create' | 'reuse' | 'ensure' | 'build';\n\t/** The target's id, once there is one. */\n\tid?: string;\n}\n\nexport type DeployEvent =\n\t| {\n\t\t\ttype: 'deploy.started';\n\t\t\tstage: string;\n\t\t\t/** The target the run deploys through, by the name it was given. */\n\t\t\ttarget: string;\n\t\t\t/** `<namespace>/<project>`. */\n\t\t\tidentity: string;\n\t\t\ttag: string;\n\t\t\t/** The apps this run deploys, in order. */\n\t\t\tapps: string[];\n\t\t\tdryRun: boolean;\n\t }\n\t| { type: 'phase.started'; phase: DeployPhase }\n\t| { type: 'phase.finished'; phase: DeployPhase }\n\t/** A phase threw; `deploy.failed` follows (after a rollback, if any). */\n\t| { type: 'phase.failed'; phase: DeployPhase; error: DeployEventError }\n\t/**\n\t * A progress line, exactly as `gkm deploy` prints it — leading newline and\n\t * indentation included, so a terminal renderer prints `message` as is.\n\t */\n\t| { type: 'log'; level: 'info' | 'warn' | 'error'; message: string }\n\t| { type: 'app.skipped'; app: string; reason: string }\n\t| ({ type: 'resource.planned' } & ResourceChange)\n\t| ({ type: 'resource.applied'; via: ResourceVia } & ResourceChange & {\n\t\t\t\tid: string;\n\t\t\t})\n\t| {\n\t\t\ttype: 'artifact.built';\n\t\t\tapp: string;\n\t\t\timageRef: string;\n\t\t\t/** The registry's digest, `sha256:…`, once pushed. */\n\t\t\tdigest?: string;\n\t }\n\t| {\n\t\t\ttype: 'app.deployed';\n\t\t\tapp: string;\n\t\t\tapplicationId: string;\n\t\t\timageRef: string;\n\t\t\turl: string;\n\t }\n\t| { type: 'app.failed'; app: string; error: DeployEventError }\n\t/** One check of whether a released app answers. */\n\t| {\n\t\t\ttype: 'health.checked';\n\t\t\tapp: string;\n\t\t\t/** What was asked: a URL, or the target's own status check. */\n\t\t\turl: string;\n\t\t\thealthy: boolean;\n\t\t\t/** The HTTP status, when the check was a request. */\n\t\t\tstatus?: number;\n\t\t\t/** 1 for the first check of the app in this run. */\n\t\t\tattempt: number;\n\t }\n\t| { type: 'deploy.finished'; result: DeployResult }\n\t| { type: 'deploy.failed'; error: DeployEventError };\n\n/** Every `type` a deploy event can have. */\nexport type DeployEventType = DeployEvent['type'];\n\n/** An error as an event carries it: its name and message, nothing else. */\nexport function eventError(error: unknown): DeployEventError {\n\tif (error instanceof Error) {\n\t\treturn { name: error.name, message: error.message };\n\t}\n\treturn { name: 'Error', message: String(error) };\n}\n","/**\n * The run around a target: what every deploy does whatever it deploys\n * through.\n *\n * It loads the workspace, resolves the target, works out the apps and the\n * identity, takes the stage's lock, and calls the target's phases in order,\n * reporting each as it starts, finishes or fails. Everything that is about\n * *where* the stage goes is the target's.\n */\n\nimport { discover } from '../reconcile/discover.js';\nimport { constructGlobs } from '../reconcile/workspace.js';\nimport { builtinTarget } from '../target/builtins';\nimport {\n\tparseTargetOptions,\n\ttype ResolvedTarget,\n\tresolveTarget,\n} from '../target/resolve';\nimport { deploySecrets, Redactor } from '../target/secrets';\nimport type {\n\tAnyDeployTarget,\n\tDeployPhaseContext,\n\tDeployTargetLogger,\n} from '../target/types';\nimport { derivedApps } from '../workspace/derive.js';\nimport { getAppBuildOrder } from '../workspace/index.js';\nimport type { NormalizedWorkspace } from '../workspace/types.js';\nimport type { CredentialProvider } from './credentials';\nimport { type DeployEvent, type DeployPhase, eventError } from './events';\nimport { applicationName, deployIdentity } from './identity.js';\nimport { createStateStore } from './StateStore.js';\nimport type { DeployResult } from './types';\n\n/** What a run deploys, once the workspace is loaded. */\nexport interface DeployRequest {\n\t/** Deployment stage (e.g., 'production', 'staging') */\n\tstage: string;\n\t/** Image tag (default: stage-timestamp) */\n\ttag?: string;\n\t/** Specific apps to deploy (default: all) */\n\tapps?: string[];\n\t/** The target to deploy through. Defaults to `deploy.default`. */\n\ttarget?: string;\n}\n\n/**\n * What a run is handed by whoever started it: where its events go, where it\n * gets credentials, and whether it may change anything. Nothing in a run\n * reads a terminal or exits the process — that is its caller's business.\n */\nexport interface DeployContext {\n\temit: (event: DeployEvent) => void;\n\tcredentials: CredentialProvider;\n\tsignal?: AbortSignal;\n\t/** Look everything up, create, build and push nothing. */\n\tdryRun: boolean;\n\t/** The CLI's home, for the stage's keys. Defaults to `GKM_HOME`. */\n\thome?: string;\n\t/** Where spawned processes' output goes. Defaults to the terminal. */\n\tchildOutput?: 'inherit' | 'stderr' | 'ignore';\n\t/** The host's own targets, which win over every other by the same name. */\n\ttargets?: Record<string, AnyDeployTarget>;\n\t/**\n\t * What the run masks in what it prints. `deploy()` passes the one its\n\t * progress lines go through; a run without one masks only its events.\n\t */\n\tredactor?: Redactor;\n}\n\n/** Apps were asked for by name that the workspace does not have. */\nexport class UnknownDeployApps extends Error {\n\tconstructor(\n\t\treadonly apps: readonly string[],\n\t\treadonly available: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Unknown apps: ${apps.join(', ')}\\n` +\n\t\t\t\t`Available apps: ${available.join(', ')}`,\n\t\t);\n\t\tthis.name = 'UnknownDeployApps';\n\t}\n}\n\n/** Every app asked for deploys through some other target. */\nexport class NoDeployableApps extends Error {\n\tconstructor(\n\t\treadonly stage: string,\n\t\treadonly target: string,\n\t) {\n\t\tsuper(\n\t\t\t`No apps to deploy through \"${target}\": every selected app deploys somewhere else. Pick the target with --target, or set each app's deploy in gkm.config.ts.`,\n\t\t);\n\t\tthis.name = 'NoDeployableApps';\n\t}\n}\n\n/** A failed rollback, after the failure that called for it. */\nexport class RollbackFailed extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\t/** What failed first, and was being rolled back. */\n\t\treadonly failure: unknown,\n\t\tcause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Deploying through \"${target}\" failed, and so did rolling it back: ${cause instanceof Error ? cause.message : String(cause)}. The stage may be part-released; deploy again, or roll it back by hand. The first failure: ${failure instanceof Error ? failure.message : String(failure)}`,\n\t\t\t{ cause },\n\t\t);\n\t\tthis.name = 'RollbackFailed';\n\t}\n}\n\n/**\n * Generate image tag from stage and timestamp\n */\nexport function generateTag(stage: string): string {\n\tconst timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);\n\treturn `${stage}-${timestamp}`;\n}\n\n/** Why an app that deploys through another target is left out. */\nfunction elsewhere(target: string, stage: string): string {\n\tconst instead = builtinTarget(target)?.instead?.(stage);\n\tif (target === 'sst' && instead) return `it deploys with SST — ${instead}`;\n\treturn `it deploys through \"${target}\" — run \\`gkm deploy --target ${target} --stage ${stage}\\``;\n}\n\n/**\n * Deploy a workspace's stage through its target.\n *\n * The engine under `deploy()` and `gkm deploy`. It never prompts and never\n * exits: credentials come from `ctx.credentials`, progress goes to\n * `ctx.emit` and to `output`, and every failure is thrown.\n *\n * @internal\n */\nexport async function runDeploy(\n\tsource: NormalizedWorkspace | (() => Promise<NormalizedWorkspace>),\n\trequest: DeployRequest,\n\tctx: DeployContext,\n): Promise<DeployResult> {\n\tconst { stage } = request;\n\tconst redactor = ctx.redactor ?? new Redactor();\n\tconst emit = (event: DeployEvent) =>\n\t\tctx.emit(\n\t\t\tevent.type === 'log'\n\t\t\t\t? { ...event, message: redactor.redact(event.message) }\n\t\t\t\t: event,\n\t\t);\n\n\t/** Run one phase between its events. */\n\tconst phase = async <T>(name: DeployPhase, body: () => Promise<T>) => {\n\t\tctx.signal?.throwIfAborted();\n\t\temit({ type: 'phase.started', phase: name });\n\t\ttry {\n\t\t\tconst value = await body();\n\t\t\temit({ type: 'phase.finished', phase: name });\n\t\t\treturn value;\n\t\t} catch (error) {\n\t\t\temit({ type: 'phase.failed', phase: name, error: eventError(error) });\n\t\t\tthrow error;\n\t\t}\n\t};\n\n\tctx.signal?.throwIfAborted();\n\temit({ type: 'phase.started', phase: 'validate' });\n\n\tlet prepared: Prepared;\n\ttry {\n\t\tprepared = await prepare(source, request, ctx, emit, redactor);\n\t} catch (error) {\n\t\temit({ type: 'phase.failed', phase: 'validate', error: eventError(error) });\n\t\tthrow error;\n\t}\n\tconst { resolved, phaseCtx, store } = prepared;\n\tconst { target } = resolved;\n\n\t// A dry run takes no lock: it writes nothing a lock would protect, and it\n\t// should not stop a real deploy that starts while it is looking.\n\tif (ctx.dryRun) {\n\t\tconst run = await validate(target, phaseCtx, emit);\n\t\tawait phase('plan', () => target.plan(phaseCtx, run));\n\t\treturn target.result(phaseCtx, run);\n\t}\n\n\t// One deploy of a stage at a time. Taken before the target generates,\n\t// provisions or records anything, and held until the run ends however it\n\t// ends. A second run of the stage — another CI job, a laptop — gets\n\t// `StateLocked` naming this one instead of racing it; a run killed with\n\t// the lock held is released with `gkm state:unlock`.\n\tlet lock: Awaited<ReturnType<typeof store.lock>>;\n\ttry {\n\t\tlock = await store.lock(stage, { operation: 'deploy' });\n\t} catch (error) {\n\t\temit({ type: 'phase.failed', phase: 'validate', error: eventError(error) });\n\t\tthrow error;\n\t}\n\n\ttry {\n\t\tconst run = await validate(target, phaseCtx, emit);\n\t\tif (target.provision) {\n\t\t\tawait phase('provision', () => target.provision!(phaseCtx, run));\n\t\t}\n\t\tif (target.build) {\n\t\t\tawait phase('build', () => target.build!(phaseCtx, run));\n\t\t}\n\n\t\tlet releasing: 'release' | 'verify' = 'release';\n\t\ttry {\n\t\t\tawait phase('release', () => target.release(phaseCtx, run));\n\t\t\treleasing = 'verify';\n\t\t\tif (target.verify) {\n\t\t\t\tawait phase('verify', () => target.verify!(phaseCtx, run));\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// The caller stopping the run is not a release to undo.\n\t\t\tif (ctx.signal?.aborted || !target.capabilities.rollback) throw error;\n\t\t\tif (!target.rollback) throw error;\n\t\t\ttry {\n\t\t\t\tawait phase('rollback', () =>\n\t\t\t\t\ttarget.rollback!(phaseCtx, run, { phase: releasing, error }),\n\t\t\t\t);\n\t\t\t} catch (rollbackError) {\n\t\t\t\tthrow new RollbackFailed(resolved.name, error, rollbackError);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn await target.result(phaseCtx, run);\n\t} finally {\n\t\tawait lock.release();\n\t}\n}\n\n/** `validate`, then the run's `deploy.started`, inside the validate phase. */\nasync function validate(\n\ttarget: AnyDeployTarget,\n\tphaseCtx: DeployPhaseContext<unknown>,\n\temit: (event: DeployEvent) => void,\n): Promise<unknown> {\n\ttry {\n\t\tconst run = await target.validate(phaseCtx);\n\t\tconst skipped = new Set(phaseCtx.skipped.map((s) => s.app));\n\t\temit({\n\t\t\ttype: 'deploy.started',\n\t\t\tstage: phaseCtx.stage,\n\t\t\ttarget: phaseCtx.target,\n\t\t\tidentity: phaseCtx.identity.key,\n\t\t\ttag: phaseCtx.tag,\n\t\t\tapps: phaseCtx.apps.filter((app) => !skipped.has(app)),\n\t\t\tdryRun: phaseCtx.dryRun,\n\t\t});\n\t\temit({ type: 'phase.finished', phase: 'validate' });\n\t\treturn run;\n\t} catch (error) {\n\t\temit({ type: 'phase.failed', phase: 'validate', error: eventError(error) });\n\t\tthrow error;\n\t}\n}\n\ninterface Prepared {\n\tresolved: ResolvedTarget;\n\tphaseCtx: DeployPhaseContext<unknown>;\n\tstore: Awaited<ReturnType<typeof createStateStore>>;\n}\n\n/** Everything the phases are handed, worked out before the first of them. */\nasync function prepare(\n\tsource: NormalizedWorkspace | (() => Promise<NormalizedWorkspace>),\n\trequest: DeployRequest,\n\tctx: DeployContext,\n\temit: (event: DeployEvent) => void,\n\tredactor: Redactor,\n): Promise<Prepared> {\n\tconst { stage } = request;\n\tconst configured = typeof source === 'function' ? await source() : source;\n\n\t// Before anything is discovered or derived: a target that cannot be found\n\t// — or a package that would not load — fails a deploy that has done\n\t// nothing yet.\n\tconst targetName = request.target ?? configured.deploy?.default ?? 'dokploy';\n\tconst resolved = await resolveTarget(targetName, {\n\t\tworkspace: configured,\n\t\tstage,\n\t\t...(ctx.targets ? { host: ctx.targets } : {}),\n\t});\n\tconst options = await parseTargetOptions(resolved);\n\n\t// What to deploy comes from the manifest.\n\t//\n\t// Discovered here rather than by the target, because the list of things\n\t// to deploy is the *declarations* — one `rest-api` is one server, one\n\t// `site` is one site — and the config only says how to run each. A project\n\t// that declares no surfaces keeps its configured apps, so adopting\n\t// constructs stays something you do a piece at a time.\n\tconst manifest = await discover({\n\t\tpatterns: constructGlobs(configured),\n\t\tcwd: configured.root,\n\t});\n\tconst units = derivedApps(manifest, configured);\n\tconst workspace: NormalizedWorkspace =\n\t\tObject.keys(units).length > 0 ? { ...configured, apps: units } : configured;\n\n\t// What every resource this deploy touches is named and claimed by —\n\t// resolved first, so a namespace that cannot be a name fails before\n\t// anything is built.\n\tconst identity = deployIdentity(workspace, stage);\n\tconst tag = request.tag ?? generateTag(stage);\n\n\t// The apps asked for, in dependency order.\n\tconst buildOrder = getAppBuildOrder(workspace);\n\tlet selected = buildOrder;\n\tif (request.apps && request.apps.length > 0) {\n\t\tconst unknown = request.apps.filter((name) => !workspace.apps[name]);\n\t\tif (unknown.length > 0) {\n\t\t\tthrow new UnknownDeployApps(unknown, Object.keys(workspace.apps));\n\t\t}\n\t\tselected = buildOrder.filter((name) => request.apps!.includes(name));\n\t}\n\n\tconst skipped: { app: string; reason: string }[] = [];\n\tconst skip = (app: string, reason: string) => {\n\t\tskipped.push({ app, reason });\n\t\temit({ type: 'app.skipped', app, reason });\n\t};\n\n\t// An app that names another target deploys there, in a run of its own.\n\t// One on the default follows the run, so `--target` moves the stage\n\t// without every app having to be told.\n\tconst byDefault = configured.deploy?.default ?? 'dokploy';\n\tconst apps = selected.filter((name) => {\n\t\tconst own = workspace.apps[name]!.resolvedDeployTarget;\n\t\tconst deploysThrough = own === byDefault ? targetName : own;\n\t\tif (deploysThrough === targetName) return true;\n\t\tskip(name, elsewhere(deploysThrough, stage));\n\t\treturn false;\n\t});\n\tif (apps.length === 0) throw new NoDeployableApps(stage, targetName);\n\n\tconst store = await createStateStore({\n\t\tconfig: workspace.state,\n\t\tworkspaceRoot: workspace.root,\n\t\tworkspaceName: workspace.name,\n\t});\n\tconst secrets = await deploySecrets(workspace, stage, redactor, {\n\t\t...(ctx.home ? { home: ctx.home } : {}),\n\t});\n\n\tconst line =\n\t\t(level: 'info' | 'warn' | 'error') =>\n\t\t(message: string): void =>\n\t\t\temit({ type: 'log', level, message });\n\tconst logger: DeployTargetLogger = {\n\t\tinfo: line('info'),\n\t\twarn: line('warn'),\n\t\terror: line('error'),\n\t};\n\n\tconst phaseCtx: DeployPhaseContext<unknown> = {\n\t\ttarget: targetName,\n\t\tcwd: workspace.root,\n\t\tstage,\n\t\ttag,\n\t\tapps,\n\t\tskipped,\n\t\tidentity,\n\t\tworkspace,\n\t\tmanifest,\n\t\toptions,\n\t\tdryRun: ctx.dryRun,\n\t\tcredentials: ctx.credentials,\n\t\tstate: store,\n\t\tsecrets,\n\t\tlogger,\n\t\tsignal: ctx.signal ?? new AbortController().signal,\n\t\tchildOutput: ctx.childOutput ?? 'inherit',\n\t\temit,\n\t\tskip,\n\t\tname: (resource) => applicationName(identity, resource),\n\t};\n\n\treturn { resolved, phaseCtx, store };\n}\n","/**\n * The credentials `gkm deploy` can ask a person for. CLI layer only.\n *\n * `deploy()` asks its `CredentialProvider` and stops with `MissingCredential`\n * when the answer is nothing. At a terminal, `gkm deploy` would rather ask:\n * this provider reads the environment and the stored login first, and only\n * when both are empty prompts — and stores a Dokploy login it validated, so\n * the next deploy does not ask again. With no terminal it answers nothing, and\n * the deploy says what was missing instead of waiting on a prompt nobody sees.\n */\n\nimport { validateDokployToken } from '../auth';\nimport { storeDokployCredentials } from '../auth/credentials';\nimport { output } from '../output';\nimport { canPrompt, prompt } from '../prompt';\nimport {\n\ttype CredentialProvider,\n\ttype CredentialRequest,\n\tchainCredentials,\n\tstoredCredentials,\n} from './credentials';\n\nconst logger = output;\n\n/** What answers a deploy prompt without a terminal. */\nconst INSTEAD = 'Please configure manually.';\n\n/** The Dokploy URL typed at the prompt is not a URL. */\nexport class DokployEndpointInvalid extends Error {\n\tconstructor(readonly endpoint: string) {\n\t\tsuper('Invalid URL format');\n\t\tthis.name = 'DokployEndpointInvalid';\n\t}\n}\n\n/** Dokploy refused the token typed at the prompt; nothing was stored. */\nexport class DokployTokenRejected extends Error {\n\tconstructor(readonly endpoint: string) {\n\t\tsuper('Invalid credentials. Please check your token.');\n\t\tthis.name = 'DokployTokenRejected';\n\t}\n}\n\n/** Asks the person at the terminal for what nothing else supplied. */\nfunction asking(): CredentialProvider {\n\treturn {\n\t\tasync get(asked) {\n\t\t\tif (!canPrompt()) return undefined;\n\t\t\t// The union, so checking `kind` narrows it: `K` itself never is.\n\t\t\tconst request = asked as CredentialRequest;\n\n\t\t\tif (request.kind === 'dokploy') {\n\t\t\t\tlogger.log(\"\\n📋 Dokploy credentials not found. Let's set them up.\");\n\t\t\t\tconst endpoint = (\n\t\t\t\t\tawait prompt('Dokploy URL (e.g., https://dokploy.example.com): ', {\n\t\t\t\t\t\tinstead: INSTEAD,\n\t\t\t\t\t})\n\t\t\t\t).replace(/\\/$/, '');\n\n\t\t\t\ttry {\n\t\t\t\t\tnew URL(endpoint);\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new DokployEndpointInvalid(endpoint);\n\t\t\t\t}\n\n\t\t\t\tlogger.log(`\\nGenerate a token at: ${endpoint}/settings/profile\\n`);\n\t\t\t\tconst token = await prompt('API Token: ', {\n\t\t\t\t\thidden: true,\n\t\t\t\t\tinstead: INSTEAD,\n\t\t\t\t});\n\n\t\t\t\tlogger.log('\\nValidating credentials...');\n\t\t\t\tif (!(await validateDokployToken(endpoint, token))) {\n\t\t\t\t\tthrow new DokployTokenRejected(endpoint);\n\t\t\t\t}\n\n\t\t\t\tawait storeDokployCredentials(token, endpoint);\n\t\t\t\tlogger.log('✓ Credentials saved');\n\t\t\t\treturn { endpoint, token } as never;\n\t\t\t}\n\n\t\t\tlogger.log(\n\t\t\t\t` Dokploy has no registry for ${request.url}. Let's create one.`,\n\t\t\t);\n\t\t\tconst username = await prompt('Registry username: ', {\n\t\t\t\tinstead: INSTEAD,\n\t\t\t});\n\t\t\tconst password = await prompt('Registry password/token: ', {\n\t\t\t\thidden: true,\n\t\t\t\tinstead: INSTEAD,\n\t\t\t});\n\t\t\treturn { username, password } as never;\n\t\t},\n\t};\n}\n\n/**\n * The environment, then the stored login, then — at a terminal — the person\n * running the command.\n */\nexport function terminalCredentials(\n\tbase: CredentialProvider = storedCredentials(),\n): CredentialProvider {\n\treturn chainCredentials(base, asking());\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAM,iBAA0D;CAC/D,SACC;CACD,UACC;AACF;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CAElC;CAEA;CAEA;CALV,YACC,MAEA,QAEA,eAAgC,eAAe,SAC9C,oDACA;EACD,MAAM,OACL,SAAS,YACN,yBAAyB,SAAS,QAAQ,WAAW,GAAG,KACxD,SAAS,aACR,+BAA+B,UAAU,0BAA0B,sDACnE,OAAO,OAAO,IAAI,EAAE,eAAe,SAAS,QAAQ,WAAW,GAAG;EACvE,MAAM,GAAG,KAAK,GAAG,cAAc;EAbtB,KAAA,OAAA;EAEA,KAAA,SAAA;EAEA,KAAA,eAAA;EAUT,KAAK,OAAO;CACb;AACD;;AAGA,SAAgB,iBACf,GAAG,WACkB;CACrB,OAAO,EACN,MAAM,IAAI,SAAS,SAAS;EAC3B,KAAK,MAAM,YAAY,WAAW;GACjC,MAAM,QAAQ,MAAM,SAAS,IAAI,SAAS,OAAO;GACjD,IAAI,OAAO,OAAO;EACnB;CAED,EACD;AACD;;;;;;;;;;;AAsBA,SAAgB,kBACf,UAAoC,CAAC,GAChB;CACrB,MAAM,MAAM,QAAQ,OAAO,QAAQ;CAEnC,OAAO,EACN,MAAM,IAAI,OAAO;EAEhB,MAAM,UAAU;EAChB,QAAQ,QAAQ,MAAhB;GACC,KAAK,WAAW;IACf,MAAM,UACL,MAAMA,gBAAAA,gBACL,QAAQ,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,KAAA,CACzC,EAAA,CACC;IACF,MAAM,QAAQ,IAAI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