@geekmidas/cli 10.0.0-alpha.62 → 10.0.0-alpha.64

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 (234) hide show
  1. package/README.md +2 -0
  2. package/dist/{HostingerProvider-DyD1Hin8.cjs → HostingerProvider-Bx2lHHvu.cjs} +3 -3
  3. package/dist/{HostingerProvider-DyD1Hin8.cjs.map → HostingerProvider-Bx2lHHvu.cjs.map} +1 -1
  4. package/dist/{HostingerProvider-B92qH4dC.mjs → HostingerProvider-Cd4aS5Kj.mjs} +2 -2
  5. package/dist/{HostingerProvider-B92qH4dC.mjs.map → HostingerProvider-Cd4aS5Kj.mjs.map} +1 -1
  6. package/dist/{LegacyStateStore-UHJEBLdn.cjs → LegacyStateStore-C2abV49N.cjs} +2 -2
  7. package/dist/{LegacyStateStore-UHJEBLdn.cjs.map → LegacyStateStore-C2abV49N.cjs.map} +1 -1
  8. package/dist/{LegacyStateStore-A8d2GdT7.mjs → LegacyStateStore-DIgkGaUP.mjs} +2 -2
  9. package/dist/{LegacyStateStore-A8d2GdT7.mjs.map → LegacyStateStore-DIgkGaUP.mjs.map} +1 -1
  10. package/dist/{LocalStateStore-B51rnfgn.mjs → LocalStateStore-Cy1ZBW7U.mjs} +2 -2
  11. package/dist/{LocalStateStore-B51rnfgn.mjs.map → LocalStateStore-Cy1ZBW7U.mjs.map} +1 -1
  12. package/dist/{LocalStateStore-COW3Ldwa.cjs → LocalStateStore-DiJqKyPy.cjs} +2 -2
  13. package/dist/{LocalStateStore-COW3Ldwa.cjs.map → LocalStateStore-DiJqKyPy.cjs.map} +1 -1
  14. package/dist/{OpenApiTsGenerator-BSrgw7B0.cjs → OpenApiTsGenerator-BWuDRHe9.cjs} +2 -2
  15. package/dist/{OpenApiTsGenerator-BSrgw7B0.cjs.map → OpenApiTsGenerator-BWuDRHe9.cjs.map} +1 -1
  16. package/dist/{OpenApiTsGenerator-q5B0z8Xg.mjs → OpenApiTsGenerator-C6v-IeHt.mjs} +2 -2
  17. package/dist/{OpenApiTsGenerator-q5B0z8Xg.mjs.map → OpenApiTsGenerator-C6v-IeHt.mjs.map} +1 -1
  18. package/dist/{S3StateStore-CJewPhgz.mjs → S3StateStore-D3x6ivBL.mjs} +2 -2
  19. package/dist/{S3StateStore-CJewPhgz.mjs.map → S3StateStore-D3x6ivBL.mjs.map} +1 -1
  20. package/dist/{S3StateStore-WUJGdRNL.cjs → S3StateStore-Ds0V1Lgm.cjs} +2 -2
  21. package/dist/{S3StateStore-WUJGdRNL.cjs.map → S3StateStore-Ds0V1Lgm.cjs.map} +1 -1
  22. package/dist/{SSMStateStore-Zejt42V8.cjs → SSMStateStore-CLipvx47.cjs} +2 -2
  23. package/dist/{SSMStateStore-Zejt42V8.cjs.map → SSMStateStore-CLipvx47.cjs.map} +1 -1
  24. package/dist/{SSMStateStore-iK5UKp9d.mjs → SSMStateStore-DfF174xQ.mjs} +2 -2
  25. package/dist/{SSMStateStore-iK5UKp9d.mjs.map → SSMStateStore-DfF174xQ.mjs.map} +1 -1
  26. package/dist/{bundler-CfH9frOS.cjs → bundler-C8uJf324.cjs} +4 -4
  27. package/dist/{bundler-CfH9frOS.cjs.map → bundler-C8uJf324.cjs.map} +1 -1
  28. package/dist/{bundler-DN5r4x5b.mjs → bundler-DYgm9xsd.mjs} +3 -3
  29. package/dist/{bundler-DN5r4x5b.mjs.map → bundler-DYgm9xsd.mjs.map} +1 -1
  30. package/dist/{cli-DYwxmfsW.mjs → cli-Bogz-zEj.mjs} +5 -4
  31. package/dist/{cli-DYwxmfsW.mjs.map → cli-Bogz-zEj.mjs.map} +1 -1
  32. package/dist/{cli-DOAUp80L.cjs → cli-D3jofJ6j.cjs} +7 -6
  33. package/dist/{cli-DOAUp80L.cjs.map → cli-D3jofJ6j.cjs.map} +1 -1
  34. package/dist/config-Be-4_I6H.d.cts +256 -0
  35. package/dist/config-Be-4_I6H.d.cts.map +1 -0
  36. package/dist/config-DqNRiQOp.d.mts +256 -0
  37. package/dist/config-DqNRiQOp.d.mts.map +1 -0
  38. package/dist/config.cjs +416 -13
  39. package/dist/config.cjs.map +1 -0
  40. package/dist/config.d.cts +4 -211
  41. package/dist/config.d.mts +4 -211
  42. package/dist/config.mjs +402 -3
  43. package/dist/config.mjs.map +1 -0
  44. package/dist/credentials-B70vmLcm.cjs +125 -0
  45. package/dist/credentials-B70vmLcm.cjs.map +1 -0
  46. package/dist/credentials-s0wMeZBU.mjs +108 -0
  47. package/dist/credentials-s0wMeZBU.mjs.map +1 -0
  48. package/dist/{define-CHBIEc5j.mjs → define-CYs0PEfZ.mjs} +2 -3
  49. package/dist/define-CYs0PEfZ.mjs.map +1 -0
  50. package/dist/{define-Cv_QvDrg.cjs → define-zUsP72ym.cjs} +2 -3
  51. package/dist/define-zUsP72ym.cjs.map +1 -0
  52. package/dist/deploy/public.cjs +166 -14
  53. package/dist/deploy/public.cjs.map +1 -0
  54. package/dist/deploy/public.d.cts +224 -3
  55. package/dist/deploy/public.d.cts.map +1 -1
  56. package/dist/deploy/public.d.mts +224 -3
  57. package/dist/deploy/public.d.mts.map +1 -1
  58. package/dist/deploy/public.mjs +141 -10
  59. package/dist/deploy/public.mjs.map +1 -0
  60. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  61. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  62. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  63. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  64. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  65. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  66. package/dist/{deploy-DSaCYvcO.cjs → deploy-55rJkdKz.cjs} +17 -14
  67. package/dist/{deploy-DSaCYvcO.cjs.map → deploy-55rJkdKz.cjs.map} +1 -1
  68. package/dist/{deploy-Cg9fae7a.mjs → deploy-Dc2LBJaK.mjs} +13 -10
  69. package/dist/deploy-Dc2LBJaK.mjs.map +1 -0
  70. package/dist/{deploy-B7jvUORo.mjs → deploy-ZRXIPp1c.mjs} +11 -8
  71. package/dist/{deploy-B7jvUORo.mjs.map → deploy-ZRXIPp1c.mjs.map} +1 -1
  72. package/dist/{deploy-D8Qr-Xto.cjs → deploy-yUcR2OlW.cjs} +15 -12
  73. package/dist/deploy-yUcR2OlW.cjs.map +1 -0
  74. package/dist/derive-B4vDpzgP.mjs +150 -0
  75. package/dist/derive-B4vDpzgP.mjs.map +1 -0
  76. package/dist/derive-DAbo49sm.cjs +161 -0
  77. package/dist/derive-DAbo49sm.cjs.map +1 -0
  78. package/dist/discover-B6yPpvRV.d.mts +99 -0
  79. package/dist/discover-B6yPpvRV.d.mts.map +1 -0
  80. package/dist/discover-B_IkPukx.d.cts +99 -0
  81. package/dist/discover-B_IkPukx.d.cts.map +1 -0
  82. package/dist/{discover-Bc-4eA_p.cjs → discover-DHdECueV.cjs} +280 -1
  83. package/dist/discover-DHdECueV.cjs.map +1 -0
  84. package/dist/{discover-FrYvzkeC.mjs → discover-LMrqsWSU.mjs} +246 -3
  85. package/dist/discover-LMrqsWSU.mjs.map +1 -0
  86. package/dist/{dokploy-CD9PY-3D.mjs → dokploy-CepdXuMl.mjs} +3 -3
  87. package/dist/{dokploy-CD9PY-3D.mjs.map → dokploy-CepdXuMl.mjs.map} +1 -1
  88. package/dist/{dokploy-Ey2foJLv.cjs → dokploy-D1d37rvM.cjs} +3 -3
  89. package/dist/{dokploy-Ey2foJLv.cjs.map → dokploy-D1d37rvM.cjs.map} +1 -1
  90. package/dist/{encryption-ChBk3hTj.cjs → encryption-C9X98u2F.cjs} +5 -5
  91. package/dist/{encryption-ChBk3hTj.cjs.map → encryption-C9X98u2F.cjs.map} +1 -1
  92. package/dist/{encryption-CVwvGbsL.mjs → encryption-CKHjMpCr.mjs} +5 -5
  93. package/dist/{encryption-CVwvGbsL.mjs.map → encryption-CKHjMpCr.mjs.map} +1 -1
  94. package/dist/fakes-C9RiT6XG.mjs.map +1 -1
  95. package/dist/fakes-zW-jNAbQ.cjs.map +1 -1
  96. package/dist/{github-BCB3_LBX.mjs → github-D-byNI7T.mjs} +4 -4
  97. package/dist/{github-BCB3_LBX.mjs.map → github-D-byNI7T.mjs.map} +1 -1
  98. package/dist/{github-OUgPDlqg.cjs → github-Dd3tMa1u.cjs} +4 -4
  99. package/dist/{github-OUgPDlqg.cjs.map → github-Dd3tMa1u.cjs.map} +1 -1
  100. package/dist/{index-BtXDZQuF.d.cts → index-CJ2qsSpp.d.mts} +2 -2
  101. package/dist/{index-BtXDZQuF.d.cts.map → index-CJ2qsSpp.d.mts.map} +1 -1
  102. package/dist/{index-DrKzpHl-.d.mts → index-CfE9Y885.d.cts} +2 -2
  103. package/dist/{index-DrKzpHl-.d.mts.map → index-CfE9Y885.d.cts.map} +1 -1
  104. package/dist/index.cjs +111 -239
  105. package/dist/index.cjs.map +1 -1
  106. package/dist/index.mjs +82 -210
  107. package/dist/index.mjs.map +1 -1
  108. package/dist/local-C7wnrcYK.cjs +586 -0
  109. package/dist/local-C7wnrcYK.cjs.map +1 -0
  110. package/dist/local-Cd8ZYQG3.mjs +473 -0
  111. package/dist/local-Cd8ZYQG3.mjs.map +1 -0
  112. package/dist/{migrate-BoHMqdCu.mjs → migrate-B4gngTLe.mjs} +6 -6
  113. package/dist/{migrate-BoHMqdCu.mjs.map → migrate-B4gngTLe.mjs.map} +1 -1
  114. package/dist/{migrate-dnaFMvOm.cjs → migrate-tx9-P9uz.cjs} +6 -6
  115. package/dist/{migrate-dnaFMvOm.cjs.map → migrate-tx9-P9uz.cjs.map} +1 -1
  116. package/dist/openapi.cjs +3 -3
  117. package/dist/openapi.d.cts +1 -1
  118. package/dist/openapi.d.mts +1 -1
  119. package/dist/openapi.mjs +3 -3
  120. package/dist/{ready-DQIy21W5.mjs → ready-bQfu9GES.mjs} +3 -3
  121. package/dist/{ready-DQIy21W5.mjs.map → ready-bQfu9GES.mjs.map} +1 -1
  122. package/dist/{ready-XlNx-Gbo.cjs → ready-brEhh68f.cjs} +3 -3
  123. package/dist/{ready-XlNx-Gbo.cjs.map → ready-brEhh68f.cjs.map} +1 -1
  124. package/dist/reconcile/public.cjs +1 -1
  125. package/dist/reconcile/public.d.cts +4 -77
  126. package/dist/reconcile/public.d.cts.map +1 -1
  127. package/dist/reconcile/public.d.mts +4 -77
  128. package/dist/reconcile/public.d.mts.map +1 -1
  129. package/dist/reconcile/public.mjs +1 -1
  130. package/dist/{resolve-wbv66HjD.cjs → resolve-BXsNQjMR.cjs} +9 -6
  131. package/dist/resolve-BXsNQjMR.cjs.map +1 -0
  132. package/dist/{resolve-CFCIkm7m.mjs → resolve-DZ2IJ0qY.mjs} +9 -6
  133. package/dist/resolve-DZ2IJ0qY.mjs.map +1 -0
  134. package/dist/{runtime-CMwtq0AL.cjs → runtime-BGNDrHzh.cjs} +2 -2
  135. package/dist/{runtime-CMwtq0AL.cjs.map → runtime-BGNDrHzh.cjs.map} +1 -1
  136. package/dist/{runtime-Dn_n-29S.d.cts → runtime-CJEYK4Gz.d.mts} +2 -2
  137. package/dist/{runtime-CXPlkZzs.d.mts.map → runtime-CJEYK4Gz.d.mts.map} +1 -1
  138. package/dist/{runtime-CXPlkZzs.d.mts → runtime-Cjq1jlVX.d.cts} +2 -2
  139. package/dist/{runtime-Dn_n-29S.d.cts.map → runtime-Cjq1jlVX.d.cts.map} +1 -1
  140. package/dist/{runtime-DbakJS8u.mjs → runtime-Cmn-FeYO.mjs} +2 -2
  141. package/dist/{runtime-DbakJS8u.mjs.map → runtime-Cmn-FeYO.mjs.map} +1 -1
  142. package/dist/sandbox/config-worker.cjs +43 -0
  143. package/dist/sandbox/config-worker.cjs.map +1 -0
  144. package/dist/sandbox/config-worker.d.cts +1 -0
  145. package/dist/sandbox/config-worker.d.mts +1 -0
  146. package/dist/sandbox/config-worker.mjs +44 -0
  147. package/dist/sandbox/config-worker.mjs.map +1 -0
  148. package/dist/sandbox/discover-worker.cjs +44 -0
  149. package/dist/sandbox/discover-worker.cjs.map +1 -0
  150. package/dist/sandbox/discover-worker.d.cts +1 -0
  151. package/dist/sandbox/discover-worker.d.mts +1 -0
  152. package/dist/sandbox/discover-worker.mjs +45 -0
  153. package/dist/sandbox/discover-worker.mjs.map +1 -0
  154. package/dist/sandbox-CL--ZDui.cjs +164 -0
  155. package/dist/sandbox-CL--ZDui.cjs.map +1 -0
  156. package/dist/sandbox-Dm247NGx.mjs +117 -0
  157. package/dist/sandbox-Dm247NGx.mjs.map +1 -0
  158. package/dist/sandbox-M8UnLhXE.d.cts +126 -0
  159. package/dist/sandbox-M8UnLhXE.d.cts.map +1 -0
  160. package/dist/sandbox-M8UnLhXE.d.mts +126 -0
  161. package/dist/sandbox-M8UnLhXE.d.mts.map +1 -0
  162. package/dist/{workspace-BFe57es7.mjs → schemas-Ckm_aBnF.cjs} +71 -982
  163. package/dist/schemas-Ckm_aBnF.cjs.map +1 -0
  164. package/dist/{workspace-B6zQO6RY.cjs → schemas-D2LCF689.mjs} +2 -1168
  165. package/dist/schemas-D2LCF689.mjs.map +1 -0
  166. package/dist/{sniffer-DHE2Nafd.mjs → sniffer-49KPbDgq.mjs} +131 -444
  167. package/dist/sniffer-49KPbDgq.mjs.map +1 -0
  168. package/dist/{sniffer-BsfPa-GA.cjs → sniffer-ByhbEW5A.cjs} +145 -512
  169. package/dist/sniffer-ByhbEW5A.cjs.map +1 -0
  170. package/dist/sst-BdALKEas.cjs +453 -0
  171. package/dist/sst-BdALKEas.cjs.map +1 -0
  172. package/dist/sst-Cper040I.mjs +430 -0
  173. package/dist/sst-Cper040I.mjs.map +1 -0
  174. package/dist/{store-BS8A7NcA.mjs → store-BaaonhkJ.mjs} +2 -2
  175. package/dist/{store-BS8A7NcA.mjs.map → store-BaaonhkJ.mjs.map} +1 -1
  176. package/dist/{store-KvNQwYaB.cjs → store-D_2ByRtW.cjs} +4 -4
  177. package/dist/{store-KvNQwYaB.cjs.map → store-D_2ByRtW.cjs.map} +1 -1
  178. package/dist/target/public.cjs +3 -3
  179. package/dist/target/public.d.cts +3 -3
  180. package/dist/target/public.d.mts +3 -3
  181. package/dist/target/public.mjs +3 -3
  182. package/dist/{terminal-6oL0vANs.cjs → terminal-Bdv--jhY.cjs} +16 -111
  183. package/dist/terminal-Bdv--jhY.cjs.map +1 -0
  184. package/dist/{terminal-ByZNjuig.mjs → terminal-D7Ntz6WE.mjs} +13 -90
  185. package/dist/terminal-D7Ntz6WE.mjs.map +1 -0
  186. package/dist/{types-DIA7Li-J.d.cts → types-B_bEQvb9.d.mts} +42 -7
  187. package/dist/types-B_bEQvb9.d.mts.map +1 -0
  188. package/dist/{types-CfLKGfC_.d.mts → types-DkrDOMxw.d.cts} +43 -6
  189. package/dist/types-DkrDOMxw.d.cts.map +1 -0
  190. package/dist/utils-D2Nk1Nv2.cjs +205 -0
  191. package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
  192. package/dist/utils-D_fxUqvU.mjs +156 -0
  193. package/dist/utils-D_fxUqvU.mjs.map +1 -0
  194. package/dist/vitest.cjs +2 -2
  195. package/dist/vitest.mjs +2 -2
  196. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  197. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  198. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  199. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  200. package/dist/workspace/index.cjs +1 -1
  201. package/dist/workspace/index.d.cts +2 -2
  202. package/dist/workspace/index.d.mts +2 -2
  203. package/dist/workspace/index.mjs +1 -1
  204. package/dist/workspace-BwgWJK7h.cjs +1196 -0
  205. package/dist/workspace-BwgWJK7h.cjs.map +1 -0
  206. package/dist/workspace-Bwit4q9O.mjs +1024 -0
  207. package/dist/workspace-Bwit4q9O.mjs.map +1 -0
  208. package/package.json +13 -13
  209. package/dist/config-BYh9S0cZ.cjs +0 -534
  210. package/dist/config-BYh9S0cZ.cjs.map +0 -1
  211. package/dist/config-Bf4-bROQ.mjs +0 -457
  212. package/dist/config-Bf4-bROQ.mjs.map +0 -1
  213. package/dist/config.d.cts.map +0 -1
  214. package/dist/config.d.mts.map +0 -1
  215. package/dist/define-CHBIEc5j.mjs.map +0 -1
  216. package/dist/define-Cv_QvDrg.cjs.map +0 -1
  217. package/dist/deploy-Cg9fae7a.mjs.map +0 -1
  218. package/dist/deploy-D8Qr-Xto.cjs.map +0 -1
  219. package/dist/discover-Bc-4eA_p.cjs.map +0 -1
  220. package/dist/discover-FrYvzkeC.mjs.map +0 -1
  221. package/dist/home-DOzBaWaL.cjs +0 -33
  222. package/dist/home-DOzBaWaL.cjs.map +0 -1
  223. package/dist/home-GI7pJl1M.mjs +0 -22
  224. package/dist/home-GI7pJl1M.mjs.map +0 -1
  225. package/dist/resolve-CFCIkm7m.mjs.map +0 -1
  226. package/dist/resolve-wbv66HjD.cjs.map +0 -1
  227. package/dist/sniffer-BsfPa-GA.cjs.map +0 -1
  228. package/dist/sniffer-DHE2Nafd.mjs.map +0 -1
  229. package/dist/terminal-6oL0vANs.cjs.map +0 -1
  230. package/dist/terminal-ByZNjuig.mjs.map +0 -1
  231. package/dist/types-CfLKGfC_.d.mts.map +0 -1
  232. package/dist/types-DIA7Li-J.d.cts.map +0 -1
  233. package/dist/workspace-B6zQO6RY.cjs.map +0 -1
  234. package/dist/workspace-BFe57es7.mjs.map +0 -1
@@ -0,0 +1,108 @@
1
+ import { m as readCredentials } from "./local-Cd8ZYQG3.mjs";
2
+ //#region src/deploy/credentials.ts
3
+ /**
4
+ * How a deploy gets the credentials it acts with.
5
+ *
6
+ * `deploy()` never prompts and never reads a terminal: it asks a
7
+ * `CredentialProvider` and, when the provider has nothing, stops with
8
+ * `MissingCredential` naming what it needed and how to supply it. Whether to
9
+ * ask a person, read a vault or fail is the caller's decision — `gkm deploy`
10
+ * prompts at a terminal and stores what was typed; a CI job sets the
11
+ * environment; a host passes its own provider.
12
+ */
13
+ /**
14
+ * How to supply each kind the CLI knows, for the error that says it is
15
+ * missing. A target's own kinds are its to explain.
16
+ */
17
+ const HOW_TO_PROVIDE = {
18
+ 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.",
19
+ 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.",
20
+ aws: "Set AWS_PROFILE to the stage account's profile, or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (and AWS_SESSION_TOKEN) — in CI, the keys aws-actions/configure-aws-credentials exports — or pass them through the deploy's CredentialProvider."
21
+ };
22
+ /** A deploy needed a credential, and its provider had none. */
23
+ var MissingCredential = class extends Error {
24
+ kind;
25
+ target;
26
+ howToProvide;
27
+ constructor(kind, target, howToProvide = HOW_TO_PROVIDE[kind] ?? "Pass it through the deploy's CredentialProvider.") {
28
+ 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.` : kind === "aws" ? `No AWS credentials${target ? ` for the "${target}" stage` : ""}.` : `No "${String(kind)}" credentials${target ? ` for ${target}` : ""}.`;
29
+ super(`${what} ${howToProvide}`);
30
+ this.kind = kind;
31
+ this.target = target;
32
+ this.howToProvide = howToProvide;
33
+ this.name = "MissingCredential";
34
+ }
35
+ };
36
+ /** Whatever was asked for, from the first provider that has it. */
37
+ function chainCredentials(...providers) {
38
+ return { async get(request, options) {
39
+ for (const provider of providers) {
40
+ const found = await provider.get(request, options);
41
+ if (found) return found;
42
+ }
43
+ } };
44
+ }
45
+ /**
46
+ * Credentials from the environment, then from what `gkm login` stored. What
47
+ * `deploy()` uses when it is handed no provider.
48
+ *
49
+ * - Dokploy: `DOKPLOY_API_TOKEN` / `DOKPLOY_ENDPOINT`, each falling back to
50
+ * the stored login, and the endpoint finally to `deploy.dokploy.endpoint`.
51
+ * Each half is read on its own: a token is a secret and belongs in the
52
+ * environment, an endpoint is configuration and belongs in the config.
53
+ * - Registry: `DOCKER_REGISTRY_USERNAME` / `DOCKER_REGISTRY_PASSWORD`.
54
+ * - AWS: `AWS_PROFILE` when it is set, and then nothing else; otherwise
55
+ * `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_SESSION_TOKEN`. The
56
+ * profile winning is `secretsStoreFor`'s rule: a profile is a choice of
57
+ * account someone made, exported keys may be left over from another.
58
+ * Read here, by name, and handed only to the command that deploys — the
59
+ * sandbox every other step runs in passes no `AWS_*` on.
60
+ */
61
+ function storedCredentials(options = {}) {
62
+ const env = options.env ?? process.env;
63
+ return { async get(asked) {
64
+ const request = asked;
65
+ switch (request.kind) {
66
+ case "dokploy": {
67
+ const stored = (await readCredentials(options.home ? { home: options.home } : void 0)).dokploy;
68
+ const token = env.DOKPLOY_API_TOKEN ?? stored?.token;
69
+ const endpoint = env.DOKPLOY_ENDPOINT ?? stored?.endpoint ?? request.endpoint;
70
+ if (!token || !endpoint) return void 0;
71
+ return {
72
+ endpoint: endpoint.replace(/\/$/, ""),
73
+ token
74
+ };
75
+ }
76
+ case "registry": {
77
+ const username = env.DOCKER_REGISTRY_USERNAME;
78
+ const password = env.DOCKER_REGISTRY_PASSWORD;
79
+ if (!username || !password) return void 0;
80
+ return {
81
+ username,
82
+ password
83
+ };
84
+ }
85
+ case "aws": {
86
+ const region = env.AWS_REGION ?? env.AWS_DEFAULT_REGION;
87
+ const where = region ? { region } : {};
88
+ if (env.AWS_PROFILE) return {
89
+ profile: env.AWS_PROFILE,
90
+ ...where
91
+ };
92
+ const accessKeyId = env.AWS_ACCESS_KEY_ID;
93
+ const secretAccessKey = env.AWS_SECRET_ACCESS_KEY;
94
+ if (!accessKeyId || !secretAccessKey) return void 0;
95
+ return {
96
+ accessKeyId,
97
+ secretAccessKey,
98
+ ...env.AWS_SESSION_TOKEN ? { sessionToken: env.AWS_SESSION_TOKEN } : {},
99
+ ...where
100
+ };
101
+ }
102
+ }
103
+ } };
104
+ }
105
+ //#endregion
106
+ export { chainCredentials as n, storedCredentials as r, MissingCredential as t };
107
+
108
+ //# sourceMappingURL=credentials-s0wMeZBU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials-s0wMeZBU.mjs","names":[],"sources":["../src/deploy/credentials.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\t/**\n\t * The AWS account a stage deploys to, for the SST target's `sst deploy`.\n\t * Handed to that one command's environment and to nothing else.\n\t */\n\taws: {\n\t\t/** The stage, for a provider that keeps one account per stage. */\n\t\trequest: { stage: string };\n\t\tvalue: AwsCredential;\n\t};\n}\n\n/**\n * Who to act as on AWS: a named profile, or keys.\n *\n * Never both. Given both, every AWS SDK takes the keys and ignores the\n * profile, so `--profile prod` with staging's keys still exported would deploy\n * production's stack into staging's account — the reason `secretsStoreFor`\n * resolves a named profile on its own, and why this cannot express the mix.\n */\nexport type AwsCredential =\n\t| {\n\t\t\t/** A profile in `~/.aws/config` — keys, SSO, an assumed role. */\n\t\t\tprofile: string;\n\t\t\tregion?: string;\n\t }\n\t| {\n\t\t\taccessKeyId: string;\n\t\t\tsecretAccessKey: string;\n\t\t\t/** Present for temporary keys: an assumed role, GitHub's OIDC. */\n\t\t\tsessionToken?: string;\n\t\t\tregion?: string;\n\t };\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\taws: \"Set AWS_PROFILE to the stage account's profile, or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (and AWS_SESSION_TOKEN) — in CI, the keys aws-actions/configure-aws-credentials exports — or pass them through the deploy's CredentialProvider.\",\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: kind === 'aws'\n\t\t\t\t\t\t? `No AWS credentials${target ? ` for the \"${target}\" stage` : ''}.`\n\t\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 * - AWS: `AWS_PROFILE` when it is set, and then nothing else; otherwise\n * `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_SESSION_TOKEN`. The\n * profile winning is `secretsStoreFor`'s rule: a profile is a choice of\n * account someone made, exported keys may be left over from another.\n * Read here, by name, and handed only to the command that deploys — the\n * sandbox every other step runs in passes no `AWS_*` on.\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\tcase 'aws': {\n\t\t\t\t\tconst region = env.AWS_REGION ?? env.AWS_DEFAULT_REGION;\n\t\t\t\t\tconst where = region ? { region } : {};\n\t\t\t\t\tif (env.AWS_PROFILE) {\n\t\t\t\t\t\treturn { profile: env.AWS_PROFILE, ...where } as never;\n\t\t\t\t\t}\n\t\t\t\t\tconst accessKeyId = env.AWS_ACCESS_KEY_ID;\n\t\t\t\t\tconst secretAccessKey = env.AWS_SECRET_ACCESS_KEY;\n\t\t\t\t\tif (!accessKeyId || !secretAccessKey) return undefined;\n\t\t\t\t\treturn {\n\t\t\t\t\t\taccessKeyId,\n\t\t\t\t\t\tsecretAccessKey,\n\t\t\t\t\t\t...(env.AWS_SESSION_TOKEN\n\t\t\t\t\t\t\t? { sessionToken: env.AWS_SESSION_TOKEN }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t...where,\n\t\t\t\t\t} 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"],"mappings":";;;;;;;;;;;;;;;;AAsGA,MAAM,iBAA0D;CAC/D,SACC;CACD,UACC;CACD,KAAK;AACN;;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,SAAS,QACR,qBAAqB,SAAS,aAAa,OAAO,WAAW,GAAG,KAChE,OAAO,OAAO,IAAI,EAAE,eAAe,SAAS,QAAQ,WAAW,GAAG;EACxE,MAAM,GAAG,KAAK,GAAG,cAAc;EAftB,KAAA,OAAA;EAEA,KAAA,SAAA;EAEA,KAAA,eAAA;EAYT,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;;;;;;;;;;;;;;;;;AA4BA,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,MAAM,gBACL,QAAQ,OAAO,EAAE,MAAM,QAAQ,KAAK,IAAI,KAAA,CACzC,EAAA,CACC;IACF,MAAM,QAAQ,IAAI,qBAAqB,QAAQ;IAC/C,MAAM,WACL,IAAI,oBAAoB,QAAQ,YAAY,QAAQ;IACrD,IAAI,CAAC,SAAS,CAAC,UAAU,OAAO,KAAA;IAChC,OAAO;KAAE,UAAU,SAAS,QAAQ,OAAO,EAAE;KAAG;IAAM;GACvD;GACA,KAAK,YAAY;IAChB,MAAM,WAAW,IAAI;IACrB,MAAM,WAAW,IAAI;IACrB,IAAI,CAAC,YAAY,CAAC,UAAU,OAAO,KAAA;IACnC,OAAO;KAAE;KAAU;IAAS;GAC7B;GACA,KAAK,OAAO;IACX,MAAM,SAAS,IAAI,cAAc,IAAI;IACrC,MAAM,QAAQ,SAAS,EAAE,OAAO,IAAI,CAAC;IACrC,IAAI,IAAI,aACP,OAAO;KAAE,SAAS,IAAI;KAAa,GAAG;IAAM;IAE7C,MAAM,cAAc,IAAI;IACxB,MAAM,kBAAkB,IAAI;IAC5B,IAAI,CAAC,eAAe,CAAC,iBAAiB,OAAO,KAAA;IAC7C,OAAO;KACN;KACA;KACA,GAAI,IAAI,oBACL,EAAE,cAAc,IAAI,kBAAkB,IACtC,CAAC;KACJ,GAAG;IACJ;GACD;EACD;CAGD,EACD;AACD"}
@@ -6,8 +6,7 @@ const BUILTIN_TARGETS = {
6
6
  },
7
7
  sst: {
8
8
  runtime: "aws",
9
- status: "external",
10
- instead: (stage) => `run \`gkm build && sst deploy --stage ${stage}\``
9
+ status: "available"
11
10
  },
12
11
  vercel: {
13
12
  runtime: "aws",
@@ -91,4 +90,4 @@ function isDeployTarget(value) {
91
90
  //#endregion
92
91
  export { UnknownDeployTarget as a, configuredTarget as c, DeployTargetNotYetSupported as i, isDeployTarget as n, builtinTarget as o, BUILTIN_TARGETS as r, configurableBuiltins as s, defineTarget as t };
93
92
 
94
- //# sourceMappingURL=define-CHBIEc5j.mjs.map
93
+ //# sourceMappingURL=define-CYs0PEfZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-CYs0PEfZ.mjs","names":[],"sources":["../src/target/builtins.ts","../src/target/define.ts"],"sourcesContent":["/**\n * The target names the CLI knows without being told, and how a name is\n * looked up.\n *\n * Plain data, so the config schema and `providerOf` — which `gkm dev` and\n * `gkm build` call synchronously on every start — can ask what a name means\n * without importing a deploy engine.\n */\n\nimport type { DeployRuntime, DeployTargetEntry } from './types';\n\n/**\n * - `available`: `gkm deploy` deploys through it.\n * - `external`: a valid `deploy.default` that builds and runs locally, but is\n * deployed by its own tool — `gkm deploy` refuses it and says which.\n * - `planned`: reserved, and refused everywhere.\n */\nexport type BuiltinStatus = 'available' | 'external' | 'planned';\n\nexport interface BuiltinTarget {\n\treadonly runtime: DeployRuntime;\n\treadonly status: BuiltinStatus;\n\t/** What to do instead, for a target `gkm deploy` cannot deploy through yet. */\n\treadonly instead?: (stage: string) => string;\n}\n\nexport const BUILTIN_TARGETS = {\n\tdokploy: { runtime: 'server', status: 'available' },\n\tsst: { runtime: 'aws', status: 'available' },\n\t// Neither runs containers the project controls, so both take the managed\n\t// defaults when they arrive.\n\tvercel: { runtime: 'aws', status: 'planned' },\n\tcloudflare: { runtime: 'aws', status: 'planned' },\n} as const satisfies Record<string, BuiltinTarget>;\n\nexport type BuiltinTargetName = keyof typeof BUILTIN_TARGETS;\n\n/** The built-in target called `name`, if one is. */\nexport function builtinTarget(name: string): BuiltinTarget | undefined {\n\treturn Object.hasOwn(BUILTIN_TARGETS, name)\n\t\t? BUILTIN_TARGETS[name as BuiltinTargetName]\n\t\t: undefined;\n}\n\n/** Built-in names a config may use. */\nexport function configurableBuiltins(): string[] {\n\treturn Object.entries(BUILTIN_TARGETS)\n\t\t.filter(([, target]) => target.status !== 'planned')\n\t\t.map(([name]) => name);\n}\n\n/** The `deploy.targets` entry called `name`, if the config has one. */\nexport function configuredTarget(\n\tdeploy: { targets?: Record<string, DeployTargetEntry> } | undefined,\n\tname: string,\n): DeployTargetEntry | undefined {\n\tconst targets = deploy?.targets;\n\treturn targets && Object.hasOwn(targets, name) ? targets[name] : undefined;\n}\n\n/** A target name that is neither built in nor in `deploy.targets`. */\nexport class UnknownDeployTarget extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\t/** The names that would have resolved. */\n\t\treadonly known: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Unknown deploy target \"${target}\". Use one of ${known.join(', ')}, or name the package that provides it in gkm.config.ts: deploy: { targets: { ${JSON.stringify(target)}: '<package>' } }.`,\n\t\t);\n\t\tthis.name = 'UnknownDeployTarget';\n\t}\n}\n\n/** A built-in target `gkm deploy` cannot deploy through yet. */\nexport class DeployTargetNotYetSupported extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\t/** What to do instead, when there is something. */\n\t\treadonly instead?: string,\n\t) {\n\t\tsuper(\n\t\t\tinstead\n\t\t\t\t? `gkm deploy cannot deploy through \"${target}\" yet: ${instead}.`\n\t\t\t\t: `Deploy target \"${target}\" is not supported yet. Deploy with dokploy, or name a target package in deploy.targets.`,\n\t\t);\n\t\tthis.name = 'DeployTargetNotYetSupported';\n\t}\n}\n","import type { AnyDeployTarget, DeployTarget } from './types';\n\n/**\n * A deploy target, typed from what it is written with: the options from its\n * `options` schema, the run state from what `validate` returns. Nothing\n * happens at runtime — it returns the target as given.\n *\n * ```ts\n * export default defineTarget({\n * name: 'fly',\n * runtime: 'server',\n * capabilities: { rollback: true, migrations: 'target', images: true },\n * options: z.object({ org: z.string() }),\n * async validate(ctx) {\n * return { org: ctx.options.org }; // ctx.options: { org: string }\n * },\n * async release(ctx, run) { … }, // run: { org: string }\n * …\n * });\n * ```\n */\nexport function defineTarget<Options = undefined, Run = void>(\n\ttarget: DeployTarget<Options, Run>,\n): DeployTarget<Options, Run> {\n\treturn target;\n}\n\n/** Whether `value` has the shape of a target. */\nexport function isDeployTarget(value: unknown): value is AnyDeployTarget {\n\tif (!value || typeof value !== 'object') return false;\n\tconst candidate = value as Record<string, unknown>;\n\treturn (\n\t\ttypeof candidate.name === 'string' &&\n\t\t(candidate.runtime === 'server' || candidate.runtime === 'aws') &&\n\t\ttypeof candidate.capabilities === 'object' &&\n\t\tcandidate.capabilities !== null &&\n\t\t['validate', 'plan', 'release', 'result'].every(\n\t\t\t(phase) => typeof candidate[phase] === 'function',\n\t\t)\n\t);\n}\n"],"mappings":";AA0BA,MAAa,kBAAkB;CAC9B,SAAS;EAAE,SAAS;EAAU,QAAQ;CAAY;CAClD,KAAK;EAAE,SAAS;EAAO,QAAQ;CAAY;CAG3C,QAAQ;EAAE,SAAS;EAAO,QAAQ;CAAU;CAC5C,YAAY;EAAE,SAAS;EAAO,QAAQ;CAAU;AACjD;;AAKA,SAAgB,cAAc,MAAyC;CACtE,OAAO,OAAO,OAAO,iBAAiB,IAAI,IACvC,gBAAgB,QAChB,KAAA;AACJ;;AAGA,SAAgB,uBAAiC;CAChD,OAAO,OAAO,QAAQ,eAAe,CAAC,CACpC,QAAQ,GAAG,YAAY,OAAO,WAAW,SAAS,CAAC,CACnD,KAAK,CAAC,UAAU,IAAI;AACvB;;AAGA,SAAgB,iBACf,QACA,MACgC;CAChC,MAAM,UAAU,QAAQ;CACxB,OAAO,WAAW,OAAO,OAAO,SAAS,IAAI,IAAI,QAAQ,QAAQ,KAAA;AAClE;;AAGA,IAAa,sBAAb,cAAyC,MAAM;CAEpC;CAEA;CAHV,YACC,QAEA,OACC;EACD,MACC,0BAA0B,OAAO,gBAAgB,MAAM,KAAK,IAAI,EAAE,gFAAgF,KAAK,UAAU,MAAM,EAAE,mBAC1K;EANS,KAAA,SAAA;EAEA,KAAA,QAAA;EAKT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,8BAAb,cAAiD,MAAM;CAE5C;CAEA;CAHV,YACC,QAEA,SACC;EACD,MACC,UACG,qCAAqC,OAAO,SAAS,QAAQ,KAC7D,kBAAkB,OAAO,yFAC7B;EARS,KAAA,SAAA;EAEA,KAAA,UAAA;EAOT,KAAK,OAAO;CACb;AACD;;;;;;;;;;;;;;;;;;;;;;ACnEA,SAAgB,aACf,QAC6B;CAC7B,OAAO;AACR;;AAGA,SAAgB,eAAe,OAA0C;CACxE,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,MAAM,YAAY;CAClB,OACC,OAAO,UAAU,SAAS,aACzB,UAAU,YAAY,YAAY,UAAU,YAAY,UACzD,OAAO,UAAU,iBAAiB,YAClC,UAAU,iBAAiB,QAC3B;EAAC;EAAY;EAAQ;EAAW;CAAQ,CAAC,CAAC,OACxC,UAAU,OAAO,UAAU,WAAW,UACxC;AAEF"}
@@ -6,8 +6,7 @@ const BUILTIN_TARGETS = {
6
6
  },
7
7
  sst: {
8
8
  runtime: "aws",
9
- status: "external",
10
- instead: (stage) => `run \`gkm build && sst deploy --stage ${stage}\``
9
+ status: "available"
11
10
  },
12
11
  vercel: {
13
12
  runtime: "aws",
@@ -138,4 +137,4 @@ Object.defineProperty(exports, "isDeployTarget", {
138
137
  }
139
138
  });
140
139
 
141
- //# sourceMappingURL=define-Cv_QvDrg.cjs.map
140
+ //# sourceMappingURL=define-zUsP72ym.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-zUsP72ym.cjs","names":[],"sources":["../src/target/builtins.ts","../src/target/define.ts"],"sourcesContent":["/**\n * The target names the CLI knows without being told, and how a name is\n * looked up.\n *\n * Plain data, so the config schema and `providerOf` — which `gkm dev` and\n * `gkm build` call synchronously on every start — can ask what a name means\n * without importing a deploy engine.\n */\n\nimport type { DeployRuntime, DeployTargetEntry } from './types';\n\n/**\n * - `available`: `gkm deploy` deploys through it.\n * - `external`: a valid `deploy.default` that builds and runs locally, but is\n * deployed by its own tool — `gkm deploy` refuses it and says which.\n * - `planned`: reserved, and refused everywhere.\n */\nexport type BuiltinStatus = 'available' | 'external' | 'planned';\n\nexport interface BuiltinTarget {\n\treadonly runtime: DeployRuntime;\n\treadonly status: BuiltinStatus;\n\t/** What to do instead, for a target `gkm deploy` cannot deploy through yet. */\n\treadonly instead?: (stage: string) => string;\n}\n\nexport const BUILTIN_TARGETS = {\n\tdokploy: { runtime: 'server', status: 'available' },\n\tsst: { runtime: 'aws', status: 'available' },\n\t// Neither runs containers the project controls, so both take the managed\n\t// defaults when they arrive.\n\tvercel: { runtime: 'aws', status: 'planned' },\n\tcloudflare: { runtime: 'aws', status: 'planned' },\n} as const satisfies Record<string, BuiltinTarget>;\n\nexport type BuiltinTargetName = keyof typeof BUILTIN_TARGETS;\n\n/** The built-in target called `name`, if one is. */\nexport function builtinTarget(name: string): BuiltinTarget | undefined {\n\treturn Object.hasOwn(BUILTIN_TARGETS, name)\n\t\t? BUILTIN_TARGETS[name as BuiltinTargetName]\n\t\t: undefined;\n}\n\n/** Built-in names a config may use. */\nexport function configurableBuiltins(): string[] {\n\treturn Object.entries(BUILTIN_TARGETS)\n\t\t.filter(([, target]) => target.status !== 'planned')\n\t\t.map(([name]) => name);\n}\n\n/** The `deploy.targets` entry called `name`, if the config has one. */\nexport function configuredTarget(\n\tdeploy: { targets?: Record<string, DeployTargetEntry> } | undefined,\n\tname: string,\n): DeployTargetEntry | undefined {\n\tconst targets = deploy?.targets;\n\treturn targets && Object.hasOwn(targets, name) ? targets[name] : undefined;\n}\n\n/** A target name that is neither built in nor in `deploy.targets`. */\nexport class UnknownDeployTarget extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\t/** The names that would have resolved. */\n\t\treadonly known: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`Unknown deploy target \"${target}\". Use one of ${known.join(', ')}, or name the package that provides it in gkm.config.ts: deploy: { targets: { ${JSON.stringify(target)}: '<package>' } }.`,\n\t\t);\n\t\tthis.name = 'UnknownDeployTarget';\n\t}\n}\n\n/** A built-in target `gkm deploy` cannot deploy through yet. */\nexport class DeployTargetNotYetSupported extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\t/** What to do instead, when there is something. */\n\t\treadonly instead?: string,\n\t) {\n\t\tsuper(\n\t\t\tinstead\n\t\t\t\t? `gkm deploy cannot deploy through \"${target}\" yet: ${instead}.`\n\t\t\t\t: `Deploy target \"${target}\" is not supported yet. Deploy with dokploy, or name a target package in deploy.targets.`,\n\t\t);\n\t\tthis.name = 'DeployTargetNotYetSupported';\n\t}\n}\n","import type { AnyDeployTarget, DeployTarget } from './types';\n\n/**\n * A deploy target, typed from what it is written with: the options from its\n * `options` schema, the run state from what `validate` returns. Nothing\n * happens at runtime — it returns the target as given.\n *\n * ```ts\n * export default defineTarget({\n * name: 'fly',\n * runtime: 'server',\n * capabilities: { rollback: true, migrations: 'target', images: true },\n * options: z.object({ org: z.string() }),\n * async validate(ctx) {\n * return { org: ctx.options.org }; // ctx.options: { org: string }\n * },\n * async release(ctx, run) { … }, // run: { org: string }\n * …\n * });\n * ```\n */\nexport function defineTarget<Options = undefined, Run = void>(\n\ttarget: DeployTarget<Options, Run>,\n): DeployTarget<Options, Run> {\n\treturn target;\n}\n\n/** Whether `value` has the shape of a target. */\nexport function isDeployTarget(value: unknown): value is AnyDeployTarget {\n\tif (!value || typeof value !== 'object') return false;\n\tconst candidate = value as Record<string, unknown>;\n\treturn (\n\t\ttypeof candidate.name === 'string' &&\n\t\t(candidate.runtime === 'server' || candidate.runtime === 'aws') &&\n\t\ttypeof candidate.capabilities === 'object' &&\n\t\tcandidate.capabilities !== null &&\n\t\t['validate', 'plan', 'release', 'result'].every(\n\t\t\t(phase) => typeof candidate[phase] === 'function',\n\t\t)\n\t);\n}\n"],"mappings":";AA0BA,MAAa,kBAAkB;CAC9B,SAAS;EAAE,SAAS;EAAU,QAAQ;CAAY;CAClD,KAAK;EAAE,SAAS;EAAO,QAAQ;CAAY;CAG3C,QAAQ;EAAE,SAAS;EAAO,QAAQ;CAAU;CAC5C,YAAY;EAAE,SAAS;EAAO,QAAQ;CAAU;AACjD;;AAKA,SAAgB,cAAc,MAAyC;CACtE,OAAO,OAAO,OAAO,iBAAiB,IAAI,IACvC,gBAAgB,QAChB,KAAA;AACJ;;AAGA,SAAgB,uBAAiC;CAChD,OAAO,OAAO,QAAQ,eAAe,CAAC,CACpC,QAAQ,GAAG,YAAY,OAAO,WAAW,SAAS,CAAC,CACnD,KAAK,CAAC,UAAU,IAAI;AACvB;;AAGA,SAAgB,iBACf,QACA,MACgC;CAChC,MAAM,UAAU,QAAQ;CACxB,OAAO,WAAW,OAAO,OAAO,SAAS,IAAI,IAAI,QAAQ,QAAQ,KAAA;AAClE;;AAGA,IAAa,sBAAb,cAAyC,MAAM;CAEpC;CAEA;CAHV,YACC,QAEA,OACC;EACD,MACC,0BAA0B,OAAO,gBAAgB,MAAM,KAAK,IAAI,EAAE,gFAAgF,KAAK,UAAU,MAAM,EAAE,mBAC1K;EANS,KAAA,SAAA;EAEA,KAAA,QAAA;EAKT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,8BAAb,cAAiD,MAAM;CAE5C;CAEA;CAHV,YACC,QAEA,SACC;EACD,MACC,UACG,qCAAqC,OAAO,SAAS,QAAQ,KAC7D,kBAAkB,OAAO,yFAC7B;EARS,KAAA,SAAA;EAEA,KAAA,UAAA;EAOT,KAAK,OAAO;CACb;AACD;;;;;;;;;;;;;;;;;;;;;;ACnEA,SAAgB,aACf,QAC6B;CAC7B,OAAO;AACR;;AAGA,SAAgB,eAAe,OAA0C;CACxE,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,MAAM,YAAY;CAClB,OACC,OAAO,UAAU,SAAS,aACzB,UAAU,YAAY,YAAY,UAAU,YAAY,UACzD,OAAO,UAAU,iBAAiB,YAClC,UAAU,iBAAiB,QAC3B;EAAC;EAAY;EAAQ;EAAW;CAAQ,CAAC,CAAC,OACxC,UAAU,OAAO,UAAU,WAAW,UACxC;AAEF"}
@@ -1,18 +1,157 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sniffer = require("../sniffer-BsfPa-GA.cjs");
3
- const require_home = require("../home-DOzBaWaL.cjs");
4
- const require_define = require("../define-Cv_QvDrg.cjs");
5
- const require_store = require("../store-KvNQwYaB.cjs");
6
- const require_runtime = require("../runtime-CMwtq0AL.cjs");
7
- const require_resolve = require("../resolve-wbv66HjD.cjs");
8
- const require_terminal = require("../terminal-6oL0vANs.cjs");
9
- const require_deploy = require("../deploy-D8Qr-Xto.cjs");
10
- const require_deploy$1 = require("../deploy-DSaCYvcO.cjs");
2
+ const require_sniffer = require("../sniffer-ByhbEW5A.cjs");
3
+ const require_local = require("../local-C7wnrcYK.cjs");
4
+ const require_discover = require("../discover-DHdECueV.cjs");
5
+ const require_sandbox = require("../sandbox-CL--ZDui.cjs");
6
+ const require_define = require("../define-zUsP72ym.cjs");
7
+ const require_config = require("../config.cjs");
8
+ const require_store = require("../store-D_2ByRtW.cjs");
9
+ const require_runtime = require("../runtime-BGNDrHzh.cjs");
10
+ const require_resolve = require("../resolve-BXsNQjMR.cjs");
11
+ const require_credentials = require("../credentials-B70vmLcm.cjs");
12
+ const require_sst = require("../sst-BdALKEas.cjs");
13
+ const require_terminal = require("../terminal-Bdv--jhY.cjs");
14
+ const require_deploy = require("../deploy-yUcR2OlW.cjs");
15
+ const require_deploy$1 = require("../deploy-55rJkdKz.cjs");
16
+ let node_path = require("node:path");
17
+ let node_fs = require("node:fs");
18
+ //#region src/sandbox/install.ts
19
+ /**
20
+ * Installing a project's dependencies in a sandbox, with or without their
21
+ * lifecycle scripts.
22
+ *
23
+ * `postinstall` is the oldest way into a build machine: any package in the
24
+ * lockfile — a dependency of a dependency — runs whatever it likes the moment
25
+ * it is installed. For a build the host trusts that is how native modules get
26
+ * built. For one it does not, the scripts are skipped, and the few packages
27
+ * that genuinely need theirs (esbuild's binary, a database driver) are named
28
+ * and rebuilt — with nothing but the sandbox's environment either way.
29
+ */
30
+ /** Long enough for a cold install of a large monorepo. */
31
+ const INSTALL_TIMEOUT_MS = 9e5;
32
+ /** A name in `allowScripts` that is not a package name. */
33
+ var InstallAllowlistNameInvalid = class extends Error {
34
+ packageName;
35
+ constructor(packageName) {
36
+ super(`'${packageName}' is not a package name, so its scripts cannot be allowed. Name the package as it appears in package.json — 'esbuild', '@prisma/client'.`);
37
+ this.packageName = packageName;
38
+ this.name = "InstallAllowlistNameInvalid";
39
+ }
40
+ };
41
+ /** The package manager has no way to run only some packages' scripts. */
42
+ var InstallScriptsAllowlistUnsupported = class extends Error {
43
+ packageManager;
44
+ allowScripts;
45
+ constructor(packageManager, allowScripts) {
46
+ super(`${packageManager} cannot rebuild named packages after an install without scripts, so ${allowScripts.join(", ")} cannot be allowed theirs. Use pnpm, npm or Yarn 2+, or install with every script skipped.`);
47
+ this.packageManager = packageManager;
48
+ this.allowScripts = allowScripts;
49
+ this.name = "InstallScriptsAllowlistUnsupported";
50
+ }
51
+ };
52
+ /**
53
+ * npm's package-name grammar, less a leading `-`: each name is an argument to
54
+ * `rebuild`, and must never be read as a flag.
55
+ */
56
+ const PACKAGE_NAME = /^(?:@[a-z0-9~][a-z0-9._~-]*\/)?[a-z0-9~][a-z0-9._~-]*$/;
57
+ /**
58
+ * The commands an install runs, in order. Exported for the tests, which
59
+ * check each package manager's flags without installing with all four.
60
+ */
61
+ function installCommands(packageManager, cwd, options = {}) {
62
+ const ignore = options.ignoreScripts ?? false;
63
+ const allow = ignore ? [...options.allowScripts ?? []] : [];
64
+ for (const name of allow) if (!PACKAGE_NAME.test(name)) throw new InstallAllowlistNameInvalid(name);
65
+ switch (packageManager) {
66
+ case "pnpm": return [["pnpm", [
67
+ "install",
68
+ "--frozen-lockfile",
69
+ ...ignore ? ["--ignore-scripts"] : []
70
+ ]], ...allow.length > 0 ? [["pnpm", [
71
+ "rebuild",
72
+ "--config.dangerouslyAllowAllBuilds=true",
73
+ ...allow
74
+ ]]] : []];
75
+ case "npm": return [["npm", [(0, node_fs.existsSync)((0, node_path.join)(cwd, "package-lock.json")) ? "ci" : "install", ...ignore ? ["--ignore-scripts"] : []]], ...allow.length > 0 ? [["npm", [
76
+ "rebuild",
77
+ "--dangerously-allow-all-scripts",
78
+ ...allow
79
+ ]]] : []];
80
+ case "yarn":
81
+ if ((0, node_fs.existsSync)((0, node_path.join)(cwd, ".yarnrc.yml"))) return [["yarn", [
82
+ "install",
83
+ "--immutable",
84
+ ...ignore ? ["--mode=skip-build"] : []
85
+ ]], ...allow.length > 0 ? [["yarn", ["rebuild", ...allow]]] : []];
86
+ if (allow.length > 0) throw new InstallScriptsAllowlistUnsupported("Yarn 1", allow);
87
+ return [["yarn", [
88
+ "install",
89
+ "--frozen-lockfile",
90
+ ...ignore ? ["--ignore-scripts"] : []
91
+ ]]];
92
+ case "bun":
93
+ if (allow.length > 0) throw new InstallScriptsAllowlistUnsupported("bun", allow);
94
+ return [["bun", [
95
+ "install",
96
+ "--frozen-lockfile",
97
+ ...ignore ? ["--ignore-scripts"] : []
98
+ ]]];
99
+ }
100
+ }
101
+ /**
102
+ * Install the project's dependencies in `sandbox`.
103
+ *
104
+ * ```ts
105
+ * // A checkout nobody has reviewed: no scripts but esbuild's.
106
+ * await installDependencies(sandbox, {
107
+ * ignoreScripts: true,
108
+ * allowScripts: ['esbuild'],
109
+ * });
110
+ * ```
111
+ *
112
+ * Resolves with each command's result, in order — with its output when
113
+ * `output` is `capture`.
114
+ *
115
+ * @throws {CommandFailed} when the package manager exits unsuccessfully.
116
+ * @throws {InstallScriptsAllowlistUnsupported} for an allowlist the package
117
+ * manager cannot honour, before anything is installed.
118
+ */
119
+ async function installDependencies(sandbox, options = {}) {
120
+ const cwd = options.cwd ?? sandbox.root;
121
+ const results = [];
122
+ const packageManager = options.packageManager ?? require_sniffer.detectPackageManager((0, node_path.resolve)(sandbox.root, cwd));
123
+ for (const [command, args] of installCommands(packageManager, (0, node_path.resolve)(sandbox.root, cwd), options)) {
124
+ const result = await sandbox.exec(command, args, {
125
+ cwd,
126
+ env: {
127
+ ...sandbox.env,
128
+ ...options.env
129
+ },
130
+ timeoutMs: options.timeoutMs ?? 9e5,
131
+ output: options.output ?? "inherit",
132
+ ...options.signal ? { signal: options.signal } : {}
133
+ });
134
+ results.push(result);
135
+ if (result.exitCode !== 0) throw new require_local.CommandFailed(command, args, result.exitCode, result.signal);
136
+ }
137
+ return results;
138
+ }
139
+ //#endregion
11
140
  exports.BackendDeployFailed = require_deploy$1.BackendDeployFailed;
141
+ exports.CommandFailed = require_local.CommandFailed;
142
+ exports.CommandTimedOut = require_local.CommandTimedOut;
143
+ exports.ConfigLoadFailed = require_config.ConfigLoadFailed;
144
+ exports.ConfigObjectNotSerializable = require_config.ConfigObjectNotSerializable;
145
+ exports.ConstructDiscoveryFailed = require_discover.ConstructDiscoveryFailed;
146
+ exports.ConstructsNotSerializable = require_discover.ConstructsNotSerializable;
12
147
  exports.DeployTargetNotYetSupported = require_define.DeployTargetNotYetSupported;
13
- exports.GKM_HOME_ENV = require_home.GKM_HOME_ENV;
148
+ exports.GKM_HOME_ENV = require_local.GKM_HOME_ENV;
149
+ exports.INSTALL_TIMEOUT_MS = INSTALL_TIMEOUT_MS;
150
+ exports.InstallAllowlistNameInvalid = InstallAllowlistNameInvalid;
151
+ exports.InstallScriptsAllowlistUnsupported = InstallScriptsAllowlistUnsupported;
14
152
  exports.InvalidTargetOptions = require_resolve.InvalidTargetOptions;
15
- exports.MissingCredential = require_terminal.MissingCredential;
153
+ exports.LocalSandbox = require_local.LocalSandbox;
154
+ exports.MissingCredential = require_credentials.MissingCredential;
16
155
  exports.MissingEnvVars = require_deploy$1.MissingEnvVars;
17
156
  exports.NoDeployableApps = require_terminal.NoDeployableApps;
18
157
  exports.ProjectNotOwned = require_deploy$1.ProjectNotOwned;
@@ -21,8 +160,16 @@ exports.RegistryAmbiguous = require_deploy$1.RegistryAmbiguous;
21
160
  exports.RegistryNotConfigured = require_deploy$1.RegistryNotConfigured;
22
161
  exports.RegistryNotFound = require_deploy$1.RegistryNotFound;
23
162
  exports.RollbackFailed = require_terminal.RollbackFailed;
163
+ exports.SANDBOX_ENV_ALLOWLIST = require_local.SANDBOX_ENV_ALLOWLIST;
164
+ exports.SECRETS_DIR_ENV = require_sandbox.SECRETS_DIR_ENV;
165
+ exports.SandboxCwdEscape = require_sandbox.SandboxCwdEscape;
166
+ exports.SandboxWorkerFailed = require_discover.SandboxWorkerFailed;
167
+ exports.SecretNameInvalid = require_sandbox.SecretNameInvalid;
168
+ exports.SstConfigNotFound = require_sst.SstConfigNotFound;
169
+ exports.SstOutputsUnreadable = require_sst.SstOutputsUnreadable;
24
170
  exports.StateLocked = require_sniffer.StateLocked;
25
171
  exports.StateVersionConflict = require_sniffer.StateVersionConflict;
172
+ exports.SurfacesUnhealthy = require_sst.SurfacesUnhealthy;
26
173
  exports.TargetEntryInvalid = require_resolve.TargetEntryInvalid;
27
174
  exports.TargetPackageInvalid = require_resolve.TargetPackageInvalid;
28
175
  exports.TargetPackageNotFound = require_runtime.TargetPackageNotFound;
@@ -30,8 +177,13 @@ exports.TargetRuntimeMismatch = require_resolve.TargetRuntimeMismatch;
30
177
  exports.TargetRuntimeUndeclared = require_runtime.TargetRuntimeUndeclared;
31
178
  exports.UnknownDeployApps = require_terminal.UnknownDeployApps;
32
179
  exports.UnknownDeployTarget = require_define.UnknownDeployTarget;
33
- exports.chainCredentials = require_terminal.chainCredentials;
180
+ exports.allowlistedEnv = require_local.allowlistedEnv;
181
+ exports.chainCredentials = require_credentials.chainCredentials;
182
+ exports.confineCwd = require_sandbox.confineCwd;
34
183
  exports.deploy = require_deploy.deploy;
35
184
  exports.deployIdentity = require_store.deployIdentity;
36
- exports.gkmHome = require_home.gkmHome;
37
- exports.storedCredentials = require_terminal.storedCredentials;
185
+ exports.gkmHome = require_local.gkmHome;
186
+ exports.installDependencies = installDependencies;
187
+ exports.storedCredentials = require_credentials.storedCredentials;
188
+
189
+ //# sourceMappingURL=public.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.cjs","names":["existsSync","join","detectPackageManager","resolve","CommandFailed"],"sources":["../../src/sandbox/install.ts"],"sourcesContent":["/**\n * Installing a project's dependencies in a sandbox, with or without their\n * lifecycle scripts.\n *\n * `postinstall` is the oldest way into a build machine: any package in the\n * lockfile — a dependency of a dependency — runs whatever it likes the moment\n * it is installed. For a build the host trusts that is how native modules get\n * built. For one it does not, the scripts are skipped, and the few packages\n * that genuinely need theirs (esbuild's binary, a database driver) are named\n * and rebuilt — with nothing but the sandbox's environment either way.\n */\n\nimport { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { detectPackageManager, type PackageManager } from '../docker/templates';\nimport { CommandFailed } from '../run';\nimport type { Sandbox, SandboxOutput, SandboxResult } from './sandbox';\n\n/** Long enough for a cold install of a large monorepo. */\nexport const INSTALL_TIMEOUT_MS = 15 * 60_000;\n\nexport interface InstallOptions {\n\t/** The directory to install in. Defaults to the sandbox's root. */\n\tcwd?: string;\n\t/** Defaults to the one the lockfile above `cwd` names. */\n\tpackageManager?: PackageManager;\n\t/**\n\t * Skip every lifecycle script — dependencies' and the project's own —\n\t * except those of {@link allowScripts}. Defaults to false: scripts run as\n\t * a plain install runs them, under the package manager's own policy —\n\t * npm 12 and pnpm 10 skip dependencies' scripts nobody approved.\n\t */\n\tignoreScripts?: boolean;\n\t/**\n\t * With `ignoreScripts`, the packages whose scripts still run: rebuilt by\n\t * name once the install is done.\n\t */\n\tallowScripts?: readonly string[];\n\t/** Variables the install needs beyond the sandbox's own. */\n\tenv?: Readonly<Record<string, string>>;\n\t/** Defaults to {@link INSTALL_TIMEOUT_MS}, for each command. */\n\ttimeoutMs?: number;\n\t/** Where the package manager's output goes. Defaults to `inherit`. */\n\toutput?: SandboxOutput;\n\tsignal?: AbortSignal;\n}\n\n/** A name in `allowScripts` that is not a package name. */\nexport class InstallAllowlistNameInvalid extends Error {\n\tconstructor(readonly packageName: string) {\n\t\tsuper(\n\t\t\t`'${packageName}' is not a package name, so its scripts cannot be ` +\n\t\t\t\t'allowed. Name the package as it appears in package.json — ' +\n\t\t\t\t\"'esbuild', '@prisma/client'.\",\n\t\t);\n\t\tthis.name = 'InstallAllowlistNameInvalid';\n\t}\n}\n\n/** The package manager has no way to run only some packages' scripts. */\nexport class InstallScriptsAllowlistUnsupported extends Error {\n\tconstructor(\n\t\treadonly packageManager: string,\n\t\treadonly allowScripts: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`${packageManager} cannot rebuild named packages after an install ` +\n\t\t\t\t`without scripts, so ${allowScripts.join(', ')} cannot be allowed ` +\n\t\t\t\t'theirs. Use pnpm, npm or Yarn 2+, or install with every script ' +\n\t\t\t\t'skipped.',\n\t\t);\n\t\tthis.name = 'InstallScriptsAllowlistUnsupported';\n\t}\n}\n\n/**\n * npm's package-name grammar, less a leading `-`: each name is an argument to\n * `rebuild`, and must never be read as a flag.\n */\nconst PACKAGE_NAME = /^(?:@[a-z0-9~][a-z0-9._~-]*\\/)?[a-z0-9~][a-z0-9._~-]*$/;\n\n/**\n * The commands an install runs, in order. Exported for the tests, which\n * check each package manager's flags without installing with all four.\n */\nexport function installCommands(\n\tpackageManager: PackageManager,\n\tcwd: string,\n\toptions: Pick<InstallOptions, 'ignoreScripts' | 'allowScripts'> = {},\n): [string, string[]][] {\n\tconst ignore = options.ignoreScripts ?? false;\n\tconst allow = ignore ? [...(options.allowScripts ?? [])] : [];\n\tfor (const name of allow) {\n\t\tif (!PACKAGE_NAME.test(name)) throw new InstallAllowlistNameInvalid(name);\n\t}\n\n\tswitch (packageManager) {\n\t\tcase 'pnpm':\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'pnpm',\n\t\t\t\t\t[\n\t\t\t\t\t\t'install',\n\t\t\t\t\t\t'--frozen-lockfile',\n\t\t\t\t\t\t...(ignore ? ['--ignore-scripts'] : []),\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t\t// pnpm 10 builds no dependency it was not told to, even by name;\n\t\t\t\t// this command names exactly the ones allowed, so it may build\n\t\t\t\t// what it names.\n\t\t\t\t...(allow.length > 0\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'pnpm',\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t'rebuild',\n\t\t\t\t\t\t\t\t\t'--config.dangerouslyAllowAllBuilds=true',\n\t\t\t\t\t\t\t\t\t...allow,\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t] as [string, string[]],\n\t\t\t\t\t\t]\n\t\t\t\t\t: []),\n\t\t\t];\n\t\tcase 'npm': {\n\t\t\tconst locked = existsSync(join(cwd, 'package-lock.json'));\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'npm',\n\t\t\t\t\t[locked ? 'ci' : 'install', ...(ignore ? ['--ignore-scripts'] : [])],\n\t\t\t\t],\n\t\t\t\t// npm 12 runs no dependency's install script its `allowScripts`\n\t\t\t\t// policy does not approve, rebuilt by name or not, and refuses\n\t\t\t\t// `--allow-scripts` on a project's command line. This command\n\t\t\t\t// names exactly the packages allowed, so it may run what it names.\n\t\t\t\t...(allow.length > 0\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'npm',\n\t\t\t\t\t\t\t\t['rebuild', '--dangerously-allow-all-scripts', ...allow],\n\t\t\t\t\t\t\t] as [string, string[]],\n\t\t\t\t\t\t]\n\t\t\t\t\t: []),\n\t\t\t];\n\t\t}\n\t\tcase 'yarn': {\n\t\t\t// Yarn 2+ keeps a `.yarnrc.yml`; it skips builds by mode and can\n\t\t\t// rebuild by name. Yarn 1 can only skip them all.\n\t\t\tconst berry = existsSync(join(cwd, '.yarnrc.yml'));\n\t\t\tif (berry) {\n\t\t\t\treturn [\n\t\t\t\t\t[\n\t\t\t\t\t\t'yarn',\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t'install',\n\t\t\t\t\t\t\t'--immutable',\n\t\t\t\t\t\t\t...(ignore ? ['--mode=skip-build'] : []),\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t\t...(allow.length > 0\n\t\t\t\t\t\t? [['yarn', ['rebuild', ...allow]] as [string, string[]]]\n\t\t\t\t\t\t: []),\n\t\t\t\t];\n\t\t\t}\n\t\t\tif (allow.length > 0) {\n\t\t\t\tthrow new InstallScriptsAllowlistUnsupported('Yarn 1', allow);\n\t\t\t}\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'yarn',\n\t\t\t\t\t[\n\t\t\t\t\t\t'install',\n\t\t\t\t\t\t'--frozen-lockfile',\n\t\t\t\t\t\t...(ignore ? ['--ignore-scripts'] : []),\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t];\n\t\t}\n\t\tcase 'bun':\n\t\t\tif (allow.length > 0) {\n\t\t\t\tthrow new InstallScriptsAllowlistUnsupported('bun', allow);\n\t\t\t}\n\t\t\treturn [\n\t\t\t\t[\n\t\t\t\t\t'bun',\n\t\t\t\t\t[\n\t\t\t\t\t\t'install',\n\t\t\t\t\t\t'--frozen-lockfile',\n\t\t\t\t\t\t...(ignore ? ['--ignore-scripts'] : []),\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t];\n\t}\n}\n\n/**\n * Install the project's dependencies in `sandbox`.\n *\n * ```ts\n * // A checkout nobody has reviewed: no scripts but esbuild's.\n * await installDependencies(sandbox, {\n * ignoreScripts: true,\n * allowScripts: ['esbuild'],\n * });\n * ```\n *\n * Resolves with each command's result, in order — with its output when\n * `output` is `capture`.\n *\n * @throws {CommandFailed} when the package manager exits unsuccessfully.\n * @throws {InstallScriptsAllowlistUnsupported} for an allowlist the package\n * manager cannot honour, before anything is installed.\n */\nexport async function installDependencies(\n\tsandbox: Sandbox,\n\toptions: InstallOptions = {},\n): Promise<SandboxResult[]> {\n\tconst cwd = options.cwd ?? sandbox.root;\n\tconst results: SandboxResult[] = [];\n\tconst packageManager =\n\t\toptions.packageManager ?? detectPackageManager(resolve(sandbox.root, cwd));\n\n\tfor (const [command, args] of installCommands(\n\t\tpackageManager,\n\t\tresolve(sandbox.root, cwd),\n\t\toptions,\n\t)) {\n\t\tconst result = await sandbox.exec(command, args, {\n\t\t\tcwd,\n\t\t\tenv: { ...sandbox.env, ...options.env },\n\t\t\ttimeoutMs: options.timeoutMs ?? INSTALL_TIMEOUT_MS,\n\t\t\toutput: options.output ?? 'inherit',\n\t\t\t...(options.signal ? { signal: options.signal } : {}),\n\t\t});\n\t\tresults.push(result);\n\t\tif (result.exitCode !== 0) {\n\t\t\tthrow new CommandFailed(\n\t\t\t\tcommand,\n\t\t\t\targs,\n\t\t\t\tresult.exitCode,\n\t\t\t\tresult.signal as NodeJS.Signals | null,\n\t\t\t);\n\t\t}\n\t}\n\treturn results;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAa,qBAAqB;;AA6BlC,IAAa,8BAAb,cAAiD,MAAM;CACjC;CAArB,YAAY,aAA8B;EACzC,MACC,IAAI,YAAY,yIAGjB;EALoB,KAAA,cAAA;EAMpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qCAAb,cAAwD,MAAM;CAEnD;CACA;CAFV,YACC,gBACA,cACC;EACD,MACC,GAAG,eAAe,sEACM,aAAa,KAAK,IAAI,EAAE,2FAGjD;EARS,KAAA,iBAAA;EACA,KAAA,eAAA;EAQT,KAAK,OAAO;CACb;AACD;;;;;AAMA,MAAM,eAAe;;;;;AAMrB,SAAgB,gBACf,gBACA,KACA,UAAkE,CAAC,GAC5C;CACvB,MAAM,SAAS,QAAQ,iBAAiB;CACxC,MAAM,QAAQ,SAAS,CAAC,GAAI,QAAQ,gBAAgB,CAAC,CAAE,IAAI,CAAC;CAC5D,KAAK,MAAM,QAAQ,OAClB,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,MAAM,IAAI,4BAA4B,IAAI;CAGzE,QAAQ,gBAAR;EACC,KAAK,QACJ,OAAO,CACN,CACC,QACA;GACC;GACA;GACA,GAAI,SAAS,CAAC,kBAAkB,IAAI,CAAC;EACtC,CACD,GAIA,GAAI,MAAM,SAAS,IAChB,CACA,CACC,QACA;GACC;GACA;GACA,GAAG;EACJ,CACD,CACD,IACC,CAAC,CACL;EACD,KAAK,OAEJ,OAAO,CACN,CACC,OACA,EAAA,GAJaA,QAAAA,WAAAA,EAAAA,GAAWC,UAAAA,KAAAA,CAAK,KAAK,mBAAmB,CAI/C,IAAI,OAAO,WAAW,GAAI,SAAS,CAAC,kBAAkB,IAAI,CAAC,CAAE,CACpE,GAKA,GAAI,MAAM,SAAS,IAChB,CACA,CACC,OACA;GAAC;GAAW;GAAmC,GAAG;EAAK,CACxD,CACD,IACC,CAAC,CACL;EAED,KAAK;GAIJ,KAAA,GADcD,QAAAA,WAAAA,EAAAA,GAAWC,UAAAA,KAAAA,CAAK,KAAK,aAAa,CACxC,GACP,OAAO,CACN,CACC,QACA;IACC;IACA;IACA,GAAI,SAAS,CAAC,mBAAmB,IAAI,CAAC;GACvC,CACD,GACA,GAAI,MAAM,SAAS,IAChB,CAAC,CAAC,QAAQ,CAAC,WAAW,GAAG,KAAK,CAAC,CAAuB,IACtD,CAAC,CACL;GAED,IAAI,MAAM,SAAS,GAClB,MAAM,IAAI,mCAAmC,UAAU,KAAK;GAE7D,OAAO,CACN,CACC,QACA;IACC;IACA;IACA,GAAI,SAAS,CAAC,kBAAkB,IAAI,CAAC;GACtC,CACD,CACD;EAED,KAAK;GACJ,IAAI,MAAM,SAAS,GAClB,MAAM,IAAI,mCAAmC,OAAO,KAAK;GAE1D,OAAO,CACN,CACC,OACA;IACC;IACA;IACA,GAAI,SAAS,CAAC,kBAAkB,IAAI,CAAC;GACtC,CACD,CACD;CACF;AACD;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,oBACrB,SACA,UAA0B,CAAC,GACA;CAC3B,MAAM,MAAM,QAAQ,OAAO,QAAQ;CACnC,MAAM,UAA2B,CAAC;CAClC,MAAM,iBACL,QAAQ,kBAAkBC,gBAAAA,sBAAAA,GAAqBC,UAAAA,QAAAA,CAAQ,QAAQ,MAAM,GAAG,CAAC;CAE1E,KAAK,MAAM,CAAC,SAAS,SAAS,gBAC7B,iBAAA,GACAA,UAAAA,QAAAA,CAAQ,QAAQ,MAAM,GAAG,GACzB,OACD,GAAG;EACF,MAAM,SAAS,MAAM,QAAQ,KAAK,SAAS,MAAM;GAChD;GACA,KAAK;IAAE,GAAG,QAAQ;IAAK,GAAG,QAAQ;GAAI;GACtC,WAAW,QAAQ,aAAA;GACnB,QAAQ,QAAQ,UAAU;GAC1B,GAAI,QAAQ,SAAS,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EACpD,CAAC;EACD,QAAQ,KAAK,MAAM;EACnB,IAAI,OAAO,aAAa,GACvB,MAAM,IAAIC,cAAAA,cACT,SACA,MACA,OAAO,UACP,OAAO,MACR;CAEF;CACA,OAAO;AACR"}