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

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 (202) hide show
  1. package/README.md +2 -0
  2. package/dist/{HostingerProvider-DI_Pr2VE.mjs → HostingerProvider-DBBwpDjn.mjs} +2 -2
  3. package/dist/{HostingerProvider-DI_Pr2VE.mjs.map → HostingerProvider-DBBwpDjn.mjs.map} +1 -1
  4. package/dist/{HostingerProvider-CgDaD8VR.cjs → HostingerProvider-mJ7YruxH.cjs} +2 -2
  5. package/dist/{HostingerProvider-CgDaD8VR.cjs.map → HostingerProvider-mJ7YruxH.cjs.map} +1 -1
  6. package/dist/{LegacyStateStore-JbBVFp_2.cjs → LegacyStateStore-CP7SZwTP.cjs} +2 -2
  7. package/dist/{LegacyStateStore-JbBVFp_2.cjs.map → LegacyStateStore-CP7SZwTP.cjs.map} +1 -1
  8. package/dist/{LegacyStateStore-C7vFAxbu.mjs → LegacyStateStore-Q3GmKOdw.mjs} +2 -2
  9. package/dist/{LegacyStateStore-C7vFAxbu.mjs.map → LegacyStateStore-Q3GmKOdw.mjs.map} +1 -1
  10. package/dist/{LocalStateStore-DfUwQsL8.mjs → LocalStateStore-BGIXcrvX.mjs} +2 -2
  11. package/dist/{LocalStateStore-DfUwQsL8.mjs.map → LocalStateStore-BGIXcrvX.mjs.map} +1 -1
  12. package/dist/{LocalStateStore-DHj_-CQB.cjs → LocalStateStore-sS8mvLeq.cjs} +2 -2
  13. package/dist/{LocalStateStore-DHj_-CQB.cjs.map → LocalStateStore-sS8mvLeq.cjs.map} +1 -1
  14. package/dist/{OpenApiTsGenerator-BSrgw7B0.cjs → OpenApiTsGenerator-CjHWFRDd.cjs} +2 -2
  15. package/dist/{OpenApiTsGenerator-BSrgw7B0.cjs.map → OpenApiTsGenerator-CjHWFRDd.cjs.map} +1 -1
  16. package/dist/{OpenApiTsGenerator-q5B0z8Xg.mjs → OpenApiTsGenerator-CnAwhGxi.mjs} +2 -2
  17. package/dist/{OpenApiTsGenerator-q5B0z8Xg.mjs.map → OpenApiTsGenerator-CnAwhGxi.mjs.map} +1 -1
  18. package/dist/{S3StateStore-xqnpUrzy.cjs → S3StateStore-6jqITH2F.cjs} +2 -2
  19. package/dist/{S3StateStore-xqnpUrzy.cjs.map → S3StateStore-6jqITH2F.cjs.map} +1 -1
  20. package/dist/{S3StateStore-Dq6hHtzY.mjs → S3StateStore-D7l_lWJ3.mjs} +2 -2
  21. package/dist/{S3StateStore-Dq6hHtzY.mjs.map → S3StateStore-D7l_lWJ3.mjs.map} +1 -1
  22. package/dist/{SSMStateStore-5dBRwVlJ.cjs → SSMStateStore-B__F7IJa.cjs} +2 -2
  23. package/dist/{SSMStateStore-5dBRwVlJ.cjs.map → SSMStateStore-B__F7IJa.cjs.map} +1 -1
  24. package/dist/{SSMStateStore-SUmvAbLi.mjs → SSMStateStore-CAQDVpoc.mjs} +2 -2
  25. package/dist/{SSMStateStore-SUmvAbLi.mjs.map → SSMStateStore-CAQDVpoc.mjs.map} +1 -1
  26. package/dist/{bundler-DXATpO1T.cjs → bundler-DLfOn0ls.cjs} +3 -3
  27. package/dist/{bundler-DXATpO1T.cjs.map → bundler-DLfOn0ls.cjs.map} +1 -1
  28. package/dist/{bundler-B5VsKW-_.mjs → bundler-DyWI41Iy.mjs} +2 -2
  29. package/dist/{bundler-B5VsKW-_.mjs.map → bundler-DyWI41Iy.mjs.map} +1 -1
  30. package/dist/{cli-DQdrVkj2.cjs → cli-D-ZM-X2s.cjs} +12 -16
  31. package/dist/cli-D-ZM-X2s.cjs.map +1 -0
  32. package/dist/{cli-DEA_J3Sa.mjs → cli-PkVF28LM.mjs} +10 -14
  33. package/dist/cli-PkVF28LM.mjs.map +1 -0
  34. package/dist/{config-DXnkCEq0.cjs → config-BEJYKd4s.cjs} +132 -18
  35. package/dist/config-BEJYKd4s.cjs.map +1 -0
  36. package/dist/config-C2BUosLm.d.mts +256 -0
  37. package/dist/config-C2BUosLm.d.mts.map +1 -0
  38. package/dist/config-CemHVcIr.d.cts +256 -0
  39. package/dist/config-CemHVcIr.d.cts.map +1 -0
  40. package/dist/{config-C5-EEdmr.mjs → config-LKKCVCnC.mjs} +109 -19
  41. package/dist/config-LKKCVCnC.mjs.map +1 -0
  42. package/dist/config.cjs +6 -2
  43. package/dist/config.d.cts +4 -211
  44. package/dist/config.d.mts +4 -211
  45. package/dist/config.mjs +3 -3
  46. package/dist/define-CHBIEc5j.mjs +94 -0
  47. package/dist/define-CHBIEc5j.mjs.map +1 -0
  48. package/dist/define-Cv_QvDrg.cjs +141 -0
  49. package/dist/define-Cv_QvDrg.cjs.map +1 -0
  50. package/dist/deploy/public.cjs +174 -13
  51. package/dist/deploy/public.cjs.map +1 -0
  52. package/dist/deploy/public.d.cts +200 -292
  53. package/dist/deploy/public.d.cts.map +1 -1
  54. package/dist/deploy/public.d.mts +200 -292
  55. package/dist/deploy/public.d.mts.map +1 -1
  56. package/dist/deploy/public.mjs +136 -3
  57. package/dist/deploy/public.mjs.map +1 -0
  58. package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
  59. package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
  60. package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
  61. package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
  62. package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
  63. package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
  64. package/dist/{deploy-BbJdgQ2b.cjs → deploy-ABBI0lf1.cjs} +169 -561
  65. package/dist/deploy-ABBI0lf1.cjs.map +1 -0
  66. package/dist/deploy-BiMrP9i7.cjs +140 -0
  67. package/dist/deploy-BiMrP9i7.cjs.map +1 -0
  68. package/dist/{deploy-BJcLmVTc.mjs → deploy-CG8bfFij.mjs} +152 -532
  69. package/dist/deploy-CG8bfFij.mjs.map +1 -0
  70. package/dist/deploy-CGW-QY9D.mjs +135 -0
  71. package/dist/deploy-CGW-QY9D.mjs.map +1 -0
  72. package/dist/discover-B6yPpvRV.d.mts +99 -0
  73. package/dist/discover-B6yPpvRV.d.mts.map +1 -0
  74. package/dist/discover-B_IkPukx.d.cts +99 -0
  75. package/dist/discover-B_IkPukx.d.cts.map +1 -0
  76. package/dist/discover-BaT6bpnA.mjs +614 -0
  77. package/dist/discover-BaT6bpnA.mjs.map +1 -0
  78. package/dist/discover-C_6COHEv.cjs +729 -0
  79. package/dist/discover-C_6COHEv.cjs.map +1 -0
  80. package/dist/dokploy-CwdmlyQL.mjs +32 -0
  81. package/dist/dokploy-CwdmlyQL.mjs.map +1 -0
  82. package/dist/dokploy-QJxMhxdf.cjs +32 -0
  83. package/dist/dokploy-QJxMhxdf.cjs.map +1 -0
  84. package/dist/{encryption-DaA9gRXr.mjs → encryption-CbQG_ayW.mjs} +4 -4
  85. package/dist/{encryption-DaA9gRXr.mjs.map → encryption-CbQG_ayW.mjs.map} +1 -1
  86. package/dist/{encryption-ojzUo7-z.cjs → encryption-DXw3jj0c.cjs} +4 -4
  87. package/dist/{encryption-ojzUo7-z.cjs.map → encryption-DXw3jj0c.cjs.map} +1 -1
  88. package/dist/fakes-C9RiT6XG.mjs.map +1 -1
  89. package/dist/fakes-zW-jNAbQ.cjs.map +1 -1
  90. package/dist/{github-Cq57poPj.cjs → github-BH_mETav.cjs} +3 -3
  91. package/dist/{github-Cq57poPj.cjs.map → github-BH_mETav.cjs.map} +1 -1
  92. package/dist/{github-DmCj2u95.mjs → github-ciwbIwVa.mjs} +3 -3
  93. package/dist/{github-DmCj2u95.mjs.map → github-ciwbIwVa.mjs.map} +1 -1
  94. package/dist/{index-UiWCaGzU.d.cts → index-BtXDZQuF.d.cts} +2 -2
  95. package/dist/{index-Da1-oa9W.d.mts.map → index-BtXDZQuF.d.cts.map} +1 -1
  96. package/dist/{index-Da1-oa9W.d.mts → index-DrKzpHl-.d.mts} +2 -2
  97. package/dist/{index-UiWCaGzU.d.cts.map → index-DrKzpHl-.d.mts.map} +1 -1
  98. package/dist/index.cjs +60 -52
  99. package/dist/index.cjs.map +1 -1
  100. package/dist/index.mjs +57 -49
  101. package/dist/index.mjs.map +1 -1
  102. package/dist/{migrate-BScRpCEx.cjs → migrate-6oa9y_f2.cjs} +5 -5
  103. package/dist/{migrate-BScRpCEx.cjs.map → migrate-6oa9y_f2.cjs.map} +1 -1
  104. package/dist/{migrate-5_J5JySj.mjs → migrate-ImBKTBcW.mjs} +5 -5
  105. package/dist/{migrate-5_J5JySj.mjs.map → migrate-ImBKTBcW.mjs.map} +1 -1
  106. package/dist/openapi.cjs +3 -3
  107. package/dist/openapi.d.cts +1 -1
  108. package/dist/openapi.d.mts +1 -1
  109. package/dist/openapi.mjs +3 -3
  110. package/dist/{ready-XlNx-Gbo.cjs → ready-BiG0rt4h.cjs} +3 -3
  111. package/dist/{ready-XlNx-Gbo.cjs.map → ready-BiG0rt4h.cjs.map} +1 -1
  112. package/dist/{ready-DQIy21W5.mjs → ready-Bpdnn2ON.mjs} +3 -3
  113. package/dist/{ready-DQIy21W5.mjs.map → ready-Bpdnn2ON.mjs.map} +1 -1
  114. package/dist/reconcile/public.cjs +1 -1
  115. package/dist/reconcile/public.d.cts +4 -77
  116. package/dist/reconcile/public.d.cts.map +1 -1
  117. package/dist/reconcile/public.d.mts +4 -77
  118. package/dist/reconcile/public.d.mts.map +1 -1
  119. package/dist/reconcile/public.mjs +1 -1
  120. package/dist/resolve-B1T0hUaR.mjs +170 -0
  121. package/dist/resolve-B1T0hUaR.mjs.map +1 -0
  122. package/dist/resolve-xytBTtG4.cjs +217 -0
  123. package/dist/resolve-xytBTtG4.cjs.map +1 -0
  124. package/dist/runtime-CMwtq0AL.cjs +163 -0
  125. package/dist/runtime-CMwtq0AL.cjs.map +1 -0
  126. package/dist/runtime-CXPlkZzs.d.mts +90 -0
  127. package/dist/runtime-CXPlkZzs.d.mts.map +1 -0
  128. package/dist/runtime-DbakJS8u.mjs +134 -0
  129. package/dist/runtime-DbakJS8u.mjs.map +1 -0
  130. package/dist/runtime-Dn_n-29S.d.cts +90 -0
  131. package/dist/runtime-Dn_n-29S.d.cts.map +1 -0
  132. package/dist/sandbox/config-worker.cjs +43 -0
  133. package/dist/sandbox/config-worker.cjs.map +1 -0
  134. package/dist/sandbox/config-worker.d.cts +1 -0
  135. package/dist/sandbox/config-worker.d.mts +1 -0
  136. package/dist/sandbox/config-worker.mjs +44 -0
  137. package/dist/sandbox/config-worker.mjs.map +1 -0
  138. package/dist/sandbox/discover-worker.cjs +44 -0
  139. package/dist/sandbox/discover-worker.cjs.map +1 -0
  140. package/dist/sandbox/discover-worker.d.cts +1 -0
  141. package/dist/sandbox/discover-worker.d.mts +1 -0
  142. package/dist/sandbox/discover-worker.mjs +45 -0
  143. package/dist/sandbox/discover-worker.mjs.map +1 -0
  144. package/dist/sandbox-M8UnLhXE.d.cts +126 -0
  145. package/dist/sandbox-M8UnLhXE.d.cts.map +1 -0
  146. package/dist/sandbox-M8UnLhXE.d.mts +126 -0
  147. package/dist/sandbox-M8UnLhXE.d.mts.map +1 -0
  148. package/dist/{workspace-Bp1xVaOz.mjs → schemas-Ckm_aBnF.cjs} +264 -969
  149. package/dist/schemas-Ckm_aBnF.cjs.map +1 -0
  150. package/dist/{workspace-B64Xk1Mb.cjs → schemas-D2LCF689.mjs} +195 -1155
  151. package/dist/schemas-D2LCF689.mjs.map +1 -0
  152. package/dist/{sniffer-CQmJnNJM.cjs → sniffer-D_SYc_pO.cjs} +379 -214
  153. package/dist/sniffer-D_SYc_pO.cjs.map +1 -0
  154. package/dist/{sniffer-bdleks5l.mjs → sniffer-aO_-s5vq.mjs} +346 -211
  155. package/dist/sniffer-aO_-s5vq.mjs.map +1 -0
  156. package/dist/target/public.cjs +15 -0
  157. package/dist/target/public.d.cts +28 -0
  158. package/dist/target/public.d.cts.map +1 -0
  159. package/dist/target/public.d.mts +28 -0
  160. package/dist/target/public.d.mts.map +1 -0
  161. package/dist/target/public.mjs +4 -0
  162. package/dist/terminal-D0f1u0LG.cjs +576 -0
  163. package/dist/terminal-D0f1u0LG.cjs.map +1 -0
  164. package/dist/terminal-gMxAo9Dj.mjs +517 -0
  165. package/dist/terminal-gMxAo9Dj.mjs.map +1 -0
  166. package/dist/{types-efNLu9xu.d.cts → types-CfLKGfC_.d.mts} +624 -34
  167. package/dist/types-CfLKGfC_.d.mts.map +1 -0
  168. package/dist/{types-Bp1mVxG0.d.mts → types-DIA7Li-J.d.cts} +626 -34
  169. package/dist/types-DIA7Li-J.d.cts.map +1 -0
  170. package/dist/vitest.cjs +2 -2
  171. package/dist/vitest.mjs +2 -2
  172. package/dist/workerRuntime-BXfhbe13.cjs +108 -0
  173. package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
  174. package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
  175. package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
  176. package/dist/workspace/index.cjs +1 -1
  177. package/dist/workspace/index.d.cts +3 -3
  178. package/dist/workspace/index.d.mts +3 -3
  179. package/dist/workspace/index.mjs +1 -1
  180. package/dist/workspace-Dh7rr7l4.mjs +1024 -0
  181. package/dist/workspace-Dh7rr7l4.mjs.map +1 -0
  182. package/dist/workspace-Kl4NG9IH.cjs +1196 -0
  183. package/dist/workspace-Kl4NG9IH.cjs.map +1 -0
  184. package/package.json +23 -13
  185. package/dist/cli-DEA_J3Sa.mjs.map +0 -1
  186. package/dist/cli-DQdrVkj2.cjs.map +0 -1
  187. package/dist/config-C5-EEdmr.mjs.map +0 -1
  188. package/dist/config-DXnkCEq0.cjs.map +0 -1
  189. package/dist/config.d.cts.map +0 -1
  190. package/dist/config.d.mts.map +0 -1
  191. package/dist/deploy-BJcLmVTc.mjs.map +0 -1
  192. package/dist/deploy-BbJdgQ2b.cjs.map +0 -1
  193. package/dist/discover-Bc-4eA_p.cjs +0 -299
  194. package/dist/discover-Bc-4eA_p.cjs.map +0 -1
  195. package/dist/discover-FrYvzkeC.mjs +0 -262
  196. package/dist/discover-FrYvzkeC.mjs.map +0 -1
  197. package/dist/sniffer-CQmJnNJM.cjs.map +0 -1
  198. package/dist/sniffer-bdleks5l.mjs.map +0 -1
  199. package/dist/types-Bp1mVxG0.d.mts.map +0 -1
  200. package/dist/types-efNLu9xu.d.cts.map +0 -1
  201. package/dist/workspace-B64Xk1Mb.cjs.map +0 -1
  202. package/dist/workspace-Bp1xVaOz.mjs.map +0 -1
@@ -1,5 +1,138 @@
1
- import { M as StateVersionConflict, k as StateLocked } from "../sniffer-bdleks5l.mjs";
1
+ import { B as LocalSandbox, H as allowlistedEnv, M as StateVersionConflict, U as CommandFailed, V as SANDBOX_ENV_ALLOWLIST, W as CommandTimedOut, k as StateLocked, u as detectPackageManager } from "../sniffer-aO_-s5vq.mjs";
2
2
  import { n as gkmHome, t as GKM_HOME_ENV } from "../home-GI7pJl1M.mjs";
3
+ import { d as SandboxCwdEscape, f as SecretNameInvalid, h as confineCwd, n as ConstructsNotSerializable, o as SandboxWorkerFailed, t as ConstructDiscoveryFailed, u as SECRETS_DIR_ENV } from "../discover-BaT6bpnA.mjs";
4
+ import { i as ConfigObjectNotSerializable, n as ConfigLoadFailed } from "../config-LKKCVCnC.mjs";
5
+ import { a as UnknownDeployTarget, i as DeployTargetNotYetSupported } from "../define-CHBIEc5j.mjs";
3
6
  import { u as deployIdentity } from "../store-BS8A7NcA.mjs";
4
- import { a as NoDeployableApps, c as RegistryAmbiguous, d as ProjectNotOwned, f as MissingCredential, i as MissingEnvVars, l as RegistryNotConfigured, m as storedCredentials, n as BackendDeployFailed, o as UnknownDeployApps, p as chainCredentials, t as deploy, u as RegistryNotFound } from "../deploy-BJcLmVTc.mjs";
5
- export { BackendDeployFailed, GKM_HOME_ENV, MissingCredential, MissingEnvVars, NoDeployableApps, ProjectNotOwned, RegistryAmbiguous, RegistryNotConfigured, RegistryNotFound, StateLocked, StateVersionConflict, UnknownDeployApps, chainCredentials, deploy, deployIdentity, gkmHome, storedCredentials };
7
+ import { i as TargetPackageNotFound, t as TargetRuntimeUndeclared } from "../runtime-DbakJS8u.mjs";
8
+ import { i as TargetRuntimeMismatch, n as TargetEntryInvalid, r as TargetPackageInvalid, s as ProviderRemoved, t as InvalidTargetOptions } from "../resolve-B1T0hUaR.mjs";
9
+ import { c as MissingCredential, i as UnknownDeployApps, l as chainCredentials, n as NoDeployableApps, r as RollbackFailed, u as storedCredentials } from "../terminal-gMxAo9Dj.mjs";
10
+ import { t as deploy } from "../deploy-CGW-QY9D.mjs";
11
+ import { d as RegistryNotFound, f as ProjectNotOwned, l as RegistryAmbiguous, n as MissingEnvVars, t as BackendDeployFailed, u as RegistryNotConfigured } from "../deploy-CG8bfFij.mjs";
12
+ import { join, resolve } from "node:path";
13
+ import { existsSync } from "node:fs";
14
+ //#region src/sandbox/install.ts
15
+ /**
16
+ * Installing a project's dependencies in a sandbox, with or without their
17
+ * lifecycle scripts.
18
+ *
19
+ * `postinstall` is the oldest way into a build machine: any package in the
20
+ * lockfile — a dependency of a dependency — runs whatever it likes the moment
21
+ * it is installed. For a build the host trusts that is how native modules get
22
+ * built. For one it does not, the scripts are skipped, and the few packages
23
+ * that genuinely need theirs (esbuild's binary, a database driver) are named
24
+ * and rebuilt — with nothing but the sandbox's environment either way.
25
+ */
26
+ /** Long enough for a cold install of a large monorepo. */
27
+ const INSTALL_TIMEOUT_MS = 9e5;
28
+ /** A name in `allowScripts` that is not a package name. */
29
+ var InstallAllowlistNameInvalid = class extends Error {
30
+ packageName;
31
+ constructor(packageName) {
32
+ 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'.`);
33
+ this.packageName = packageName;
34
+ this.name = "InstallAllowlistNameInvalid";
35
+ }
36
+ };
37
+ /** The package manager has no way to run only some packages' scripts. */
38
+ var InstallScriptsAllowlistUnsupported = class extends Error {
39
+ packageManager;
40
+ allowScripts;
41
+ constructor(packageManager, allowScripts) {
42
+ 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.`);
43
+ this.packageManager = packageManager;
44
+ this.allowScripts = allowScripts;
45
+ this.name = "InstallScriptsAllowlistUnsupported";
46
+ }
47
+ };
48
+ /**
49
+ * npm's package-name grammar, less a leading `-`: each name is an argument to
50
+ * `rebuild`, and must never be read as a flag.
51
+ */
52
+ const PACKAGE_NAME = /^(?:@[a-z0-9~][a-z0-9._~-]*\/)?[a-z0-9~][a-z0-9._~-]*$/;
53
+ /**
54
+ * The commands an install runs, in order. Exported for the tests, which
55
+ * check each package manager's flags without installing with all four.
56
+ */
57
+ function installCommands(packageManager, cwd, options = {}) {
58
+ const ignore = options.ignoreScripts ?? false;
59
+ const allow = ignore ? [...options.allowScripts ?? []] : [];
60
+ for (const name of allow) if (!PACKAGE_NAME.test(name)) throw new InstallAllowlistNameInvalid(name);
61
+ switch (packageManager) {
62
+ case "pnpm": return [["pnpm", [
63
+ "install",
64
+ "--frozen-lockfile",
65
+ ...ignore ? ["--ignore-scripts"] : []
66
+ ]], ...allow.length > 0 ? [["pnpm", [
67
+ "rebuild",
68
+ "--config.dangerouslyAllowAllBuilds=true",
69
+ ...allow
70
+ ]]] : []];
71
+ case "npm": return [["npm", [existsSync(join(cwd, "package-lock.json")) ? "ci" : "install", ...ignore ? ["--ignore-scripts"] : []]], ...allow.length > 0 ? [["npm", [
72
+ "rebuild",
73
+ "--dangerously-allow-all-scripts",
74
+ ...allow
75
+ ]]] : []];
76
+ case "yarn":
77
+ if (existsSync(join(cwd, ".yarnrc.yml"))) return [["yarn", [
78
+ "install",
79
+ "--immutable",
80
+ ...ignore ? ["--mode=skip-build"] : []
81
+ ]], ...allow.length > 0 ? [["yarn", ["rebuild", ...allow]]] : []];
82
+ if (allow.length > 0) throw new InstallScriptsAllowlistUnsupported("Yarn 1", allow);
83
+ return [["yarn", [
84
+ "install",
85
+ "--frozen-lockfile",
86
+ ...ignore ? ["--ignore-scripts"] : []
87
+ ]]];
88
+ case "bun":
89
+ if (allow.length > 0) throw new InstallScriptsAllowlistUnsupported("bun", allow);
90
+ return [["bun", [
91
+ "install",
92
+ "--frozen-lockfile",
93
+ ...ignore ? ["--ignore-scripts"] : []
94
+ ]]];
95
+ }
96
+ }
97
+ /**
98
+ * Install the project's dependencies in `sandbox`.
99
+ *
100
+ * ```ts
101
+ * // A checkout nobody has reviewed: no scripts but esbuild's.
102
+ * await installDependencies(sandbox, {
103
+ * ignoreScripts: true,
104
+ * allowScripts: ['esbuild'],
105
+ * });
106
+ * ```
107
+ *
108
+ * Resolves with each command's result, in order — with its output when
109
+ * `output` is `capture`.
110
+ *
111
+ * @throws {CommandFailed} when the package manager exits unsuccessfully.
112
+ * @throws {InstallScriptsAllowlistUnsupported} for an allowlist the package
113
+ * manager cannot honour, before anything is installed.
114
+ */
115
+ async function installDependencies(sandbox, options = {}) {
116
+ const cwd = options.cwd ?? sandbox.root;
117
+ const results = [];
118
+ const packageManager = options.packageManager ?? detectPackageManager(resolve(sandbox.root, cwd));
119
+ for (const [command, args] of installCommands(packageManager, resolve(sandbox.root, cwd), options)) {
120
+ const result = await sandbox.exec(command, args, {
121
+ cwd,
122
+ env: {
123
+ ...sandbox.env,
124
+ ...options.env
125
+ },
126
+ timeoutMs: options.timeoutMs ?? 9e5,
127
+ output: options.output ?? "inherit",
128
+ ...options.signal ? { signal: options.signal } : {}
129
+ });
130
+ results.push(result);
131
+ if (result.exitCode !== 0) throw new CommandFailed(command, args, result.exitCode, result.signal);
132
+ }
133
+ return results;
134
+ }
135
+ //#endregion
136
+ export { BackendDeployFailed, CommandFailed, CommandTimedOut, ConfigLoadFailed, ConfigObjectNotSerializable, ConstructDiscoveryFailed, ConstructsNotSerializable, DeployTargetNotYetSupported, GKM_HOME_ENV, INSTALL_TIMEOUT_MS, InstallAllowlistNameInvalid, InstallScriptsAllowlistUnsupported, InvalidTargetOptions, LocalSandbox, MissingCredential, MissingEnvVars, NoDeployableApps, ProjectNotOwned, ProviderRemoved, RegistryAmbiguous, RegistryNotConfigured, RegistryNotFound, RollbackFailed, SANDBOX_ENV_ALLOWLIST, SECRETS_DIR_ENV, SandboxCwdEscape, SandboxWorkerFailed, SecretNameInvalid, StateLocked, StateVersionConflict, TargetEntryInvalid, TargetPackageInvalid, TargetPackageNotFound, TargetRuntimeMismatch, TargetRuntimeUndeclared, UnknownDeployApps, UnknownDeployTarget, allowlistedEnv, chainCredentials, confineCwd, deploy, deployIdentity, gkmHome, installDependencies, storedCredentials };
137
+
138
+ //# sourceMappingURL=public.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.mjs","names":[],"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":"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"}
@@ -0,0 +1,54 @@
1
+ let node_url = require("node:url");
2
+ let _geekmidas_envkit_sniffer = require("@geekmidas/envkit/sniffer");
3
+ //#region src/deploy/sniffer-envparser-worker.ts
4
+ /**
5
+ * Subprocess worker for envParser sniffing.
6
+ *
7
+ * Imports an app's envParser module, hands it a SnifferEnvironmentParser and
8
+ * reports which variables it read. A subprocess, like the entry and route
9
+ * sniffers, so the module runs in the sandbox rather than in the deploy, with
10
+ * none of the deploy's environment.
11
+ *
12
+ * Usage:
13
+ * node --import tsx ./sniffer-envparser-worker.ts /path/to/env.ts envParser
14
+ *
15
+ * Output (JSON, last line of stdout):
16
+ * { "envVars": [...], "optionalEnvVars": [...], "unhandledRejections": [...],
17
+ * "warnings": [...], "error": null }
18
+ */
19
+ const modulePath = process.argv[2];
20
+ const exportName = process.argv[3] ?? "default";
21
+ async function sniff() {
22
+ const warnings = [];
23
+ const sniffer = new _geekmidas_envkit_sniffer.SnifferEnvironmentParser();
24
+ const result = await (0, _geekmidas_envkit_sniffer.sniffWithFireAndForget)(sniffer, async () => {
25
+ if (!modulePath) throw new TypeError("No envParser module was given.");
26
+ const envParser = (await import((0, node_url.pathToFileURL)(modulePath).href))[exportName];
27
+ if (typeof envParser !== "function") {
28
+ warnings.push(`[sniffer] Export "${exportName}" from "${modulePath}" is not a function`);
29
+ return;
30
+ }
31
+ const parser = envParser(sniffer);
32
+ if (parser && typeof parser.parse === "function") try {
33
+ parser.parse();
34
+ } catch {}
35
+ });
36
+ const line = JSON.stringify({
37
+ envVars: result.envVars,
38
+ optionalEnvVars: result.optionalEnvVars,
39
+ unhandledRejections: result.unhandledRejections.map((e) => e.message),
40
+ warnings,
41
+ error: result.error ? result.error.message : null
42
+ });
43
+ process.stdout.write(`${line}\n`, () => process.exit(0));
44
+ }
45
+ sniff().catch((e) => {
46
+ console.log(JSON.stringify({
47
+ envVars: [],
48
+ error: e.message || String(e)
49
+ }));
50
+ process.exit(1);
51
+ });
52
+ //#endregion
53
+
54
+ //# sourceMappingURL=sniffer-envparser-worker.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sniffer-envparser-worker.cjs","names":["SnifferEnvironmentParser","sniffWithFireAndForget","pathToFileURL"],"sources":["../../src/deploy/sniffer-envparser-worker.ts"],"sourcesContent":["/**\n * Subprocess worker for envParser sniffing.\n *\n * Imports an app's envParser module, hands it a SnifferEnvironmentParser and\n * reports which variables it read. A subprocess, like the entry and route\n * sniffers, so the module runs in the sandbox rather than in the deploy, with\n * none of the deploy's environment.\n *\n * Usage:\n * node --import tsx ./sniffer-envparser-worker.ts /path/to/env.ts envParser\n *\n * Output (JSON, last line of stdout):\n * { \"envVars\": [...], \"optionalEnvVars\": [...], \"unhandledRejections\": [...],\n * \"warnings\": [...], \"error\": null }\n */\n\nimport { pathToFileURL } from 'node:url';\nimport {\n\tSnifferEnvironmentParser,\n\tsniffWithFireAndForget,\n} from '@geekmidas/envkit/sniffer';\n\nconst modulePath = process.argv[2];\nconst exportName = process.argv[3] ?? 'default';\n\nasync function sniff(): Promise<void> {\n\tconst warnings: string[] = [];\n\tconst sniffer = new SnifferEnvironmentParser();\n\n\tconst result = await sniffWithFireAndForget(sniffer, async () => {\n\t\tif (!modulePath) throw new TypeError('No envParser module was given.');\n\t\tconst module = await import(pathToFileURL(modulePath).href);\n\n\t\tconst envParser = module[exportName];\n\t\tif (typeof envParser !== 'function') {\n\t\t\twarnings.push(\n\t\t\t\t`[sniffer] Export \"${exportName}\" from \"${modulePath}\" is not a function`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// The envParser function typically creates and configures an\n\t\t// EnvironmentParser; the sniffer implements the same interface.\n\t\tconst parser = envParser(sniffer);\n\n\t\t// A ConfigParser's parse() is what reads the variables.\n\t\tif (parser && typeof parser.parse === 'function') {\n\t\t\ttry {\n\t\t\t\tparser.parse();\n\t\t\t} catch {\n\t\t\t\t// Parsing may fail on the sniffer's mock values; expected.\n\t\t\t}\n\t\t}\n\t});\n\n\tconst line = JSON.stringify({\n\t\tenvVars: result.envVars,\n\t\toptionalEnvVars: result.optionalEnvVars,\n\t\tunhandledRejections: result.unhandledRejections.map((e) => e.message),\n\t\twarnings,\n\t\terror: result.error ? result.error.message : null,\n\t});\n\t// The module may have left a pool or a timer open, so exit — once the\n\t// answer has drained: a pipe on macOS is written asynchronously.\n\tprocess.stdout.write(`${line}\\n`, () => process.exit(0));\n}\n\nsniff().catch((e) => {\n\tconsole.log(JSON.stringify({ envVars: [], error: e.message || String(e) }));\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,MAAM,aAAa,QAAQ,KAAK;AAChC,MAAM,aAAa,QAAQ,KAAK,MAAM;AAEtC,eAAe,QAAuB;CACrC,MAAM,WAAqB,CAAC;CAC5B,MAAM,UAAU,IAAIA,0BAAAA,yBAAyB;CAE7C,MAAM,SAAS,OAAA,GAAMC,0BAAAA,uBAAAA,CAAuB,SAAS,YAAY;EAChE,IAAI,CAAC,YAAY,MAAM,IAAI,UAAU,gCAAgC;EAGrE,MAAM,aAAY,MAFG,QAAA,GAAOC,SAAAA,cAAAA,CAAc,UAAU,CAAC,CAAC,MAAA,CAE7B;EACzB,IAAI,OAAO,cAAc,YAAY;GACpC,SAAS,KACR,qBAAqB,WAAW,UAAU,WAAW,oBACtD;GACA;EACD;EAIA,MAAM,SAAS,UAAU,OAAO;EAGhC,IAAI,UAAU,OAAO,OAAO,UAAU,YACrC,IAAI;GACH,OAAO,MAAM;EACd,QAAQ,CAER;CAEF,CAAC;CAED,MAAM,OAAO,KAAK,UAAU;EAC3B,SAAS,OAAO;EAChB,iBAAiB,OAAO;EACxB,qBAAqB,OAAO,oBAAoB,KAAK,MAAM,EAAE,OAAO;EACpE;EACA,OAAO,OAAO,QAAQ,OAAO,MAAM,UAAU;CAC9C,CAAC;CAGD,QAAQ,OAAO,MAAM,GAAG,KAAK,WAAW,QAAQ,KAAK,CAAC,CAAC;AACxD;AAEA,MAAM,CAAC,CAAC,OAAO,MAAM;CACpB,QAAQ,IAAI,KAAK,UAAU;EAAE,SAAS,CAAC;EAAG,OAAO,EAAE,WAAW,OAAO,CAAC;CAAE,CAAC,CAAC;CAC1E,QAAQ,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,55 @@
1
+ import { pathToFileURL } from "node:url";
2
+ import { SnifferEnvironmentParser, sniffWithFireAndForget } from "@geekmidas/envkit/sniffer";
3
+ //#region src/deploy/sniffer-envparser-worker.ts
4
+ /**
5
+ * Subprocess worker for envParser sniffing.
6
+ *
7
+ * Imports an app's envParser module, hands it a SnifferEnvironmentParser and
8
+ * reports which variables it read. A subprocess, like the entry and route
9
+ * sniffers, so the module runs in the sandbox rather than in the deploy, with
10
+ * none of the deploy's environment.
11
+ *
12
+ * Usage:
13
+ * node --import tsx ./sniffer-envparser-worker.ts /path/to/env.ts envParser
14
+ *
15
+ * Output (JSON, last line of stdout):
16
+ * { "envVars": [...], "optionalEnvVars": [...], "unhandledRejections": [...],
17
+ * "warnings": [...], "error": null }
18
+ */
19
+ const modulePath = process.argv[2];
20
+ const exportName = process.argv[3] ?? "default";
21
+ async function sniff() {
22
+ const warnings = [];
23
+ const sniffer = new SnifferEnvironmentParser();
24
+ const result = await sniffWithFireAndForget(sniffer, async () => {
25
+ if (!modulePath) throw new TypeError("No envParser module was given.");
26
+ const envParser = (await import(pathToFileURL(modulePath).href))[exportName];
27
+ if (typeof envParser !== "function") {
28
+ warnings.push(`[sniffer] Export "${exportName}" from "${modulePath}" is not a function`);
29
+ return;
30
+ }
31
+ const parser = envParser(sniffer);
32
+ if (parser && typeof parser.parse === "function") try {
33
+ parser.parse();
34
+ } catch {}
35
+ });
36
+ const line = JSON.stringify({
37
+ envVars: result.envVars,
38
+ optionalEnvVars: result.optionalEnvVars,
39
+ unhandledRejections: result.unhandledRejections.map((e) => e.message),
40
+ warnings,
41
+ error: result.error ? result.error.message : null
42
+ });
43
+ process.stdout.write(`${line}\n`, () => process.exit(0));
44
+ }
45
+ sniff().catch((e) => {
46
+ console.log(JSON.stringify({
47
+ envVars: [],
48
+ error: e.message || String(e)
49
+ }));
50
+ process.exit(1);
51
+ });
52
+ //#endregion
53
+ export {};
54
+
55
+ //# sourceMappingURL=sniffer-envparser-worker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sniffer-envparser-worker.mjs","names":[],"sources":["../../src/deploy/sniffer-envparser-worker.ts"],"sourcesContent":["/**\n * Subprocess worker for envParser sniffing.\n *\n * Imports an app's envParser module, hands it a SnifferEnvironmentParser and\n * reports which variables it read. A subprocess, like the entry and route\n * sniffers, so the module runs in the sandbox rather than in the deploy, with\n * none of the deploy's environment.\n *\n * Usage:\n * node --import tsx ./sniffer-envparser-worker.ts /path/to/env.ts envParser\n *\n * Output (JSON, last line of stdout):\n * { \"envVars\": [...], \"optionalEnvVars\": [...], \"unhandledRejections\": [...],\n * \"warnings\": [...], \"error\": null }\n */\n\nimport { pathToFileURL } from 'node:url';\nimport {\n\tSnifferEnvironmentParser,\n\tsniffWithFireAndForget,\n} from '@geekmidas/envkit/sniffer';\n\nconst modulePath = process.argv[2];\nconst exportName = process.argv[3] ?? 'default';\n\nasync function sniff(): Promise<void> {\n\tconst warnings: string[] = [];\n\tconst sniffer = new SnifferEnvironmentParser();\n\n\tconst result = await sniffWithFireAndForget(sniffer, async () => {\n\t\tif (!modulePath) throw new TypeError('No envParser module was given.');\n\t\tconst module = await import(pathToFileURL(modulePath).href);\n\n\t\tconst envParser = module[exportName];\n\t\tif (typeof envParser !== 'function') {\n\t\t\twarnings.push(\n\t\t\t\t`[sniffer] Export \"${exportName}\" from \"${modulePath}\" is not a function`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// The envParser function typically creates and configures an\n\t\t// EnvironmentParser; the sniffer implements the same interface.\n\t\tconst parser = envParser(sniffer);\n\n\t\t// A ConfigParser's parse() is what reads the variables.\n\t\tif (parser && typeof parser.parse === 'function') {\n\t\t\ttry {\n\t\t\t\tparser.parse();\n\t\t\t} catch {\n\t\t\t\t// Parsing may fail on the sniffer's mock values; expected.\n\t\t\t}\n\t\t}\n\t});\n\n\tconst line = JSON.stringify({\n\t\tenvVars: result.envVars,\n\t\toptionalEnvVars: result.optionalEnvVars,\n\t\tunhandledRejections: result.unhandledRejections.map((e) => e.message),\n\t\twarnings,\n\t\terror: result.error ? result.error.message : null,\n\t});\n\t// The module may have left a pool or a timer open, so exit — once the\n\t// answer has drained: a pipe on macOS is written asynchronously.\n\tprocess.stdout.write(`${line}\\n`, () => process.exit(0));\n}\n\nsniff().catch((e) => {\n\tconsole.log(JSON.stringify({ envVars: [], error: e.message || String(e) }));\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,MAAM,aAAa,QAAQ,KAAK;AAChC,MAAM,aAAa,QAAQ,KAAK,MAAM;AAEtC,eAAe,QAAuB;CACrC,MAAM,WAAqB,CAAC;CAC5B,MAAM,UAAU,IAAI,yBAAyB;CAE7C,MAAM,SAAS,MAAM,uBAAuB,SAAS,YAAY;EAChE,IAAI,CAAC,YAAY,MAAM,IAAI,UAAU,gCAAgC;EAGrE,MAAM,aAAY,MAFG,OAAO,cAAc,UAAU,CAAC,CAAC,MAAA,CAE7B;EACzB,IAAI,OAAO,cAAc,YAAY;GACpC,SAAS,KACR,qBAAqB,WAAW,UAAU,WAAW,oBACtD;GACA;EACD;EAIA,MAAM,SAAS,UAAU,OAAO;EAGhC,IAAI,UAAU,OAAO,OAAO,UAAU,YACrC,IAAI;GACH,OAAO,MAAM;EACd,QAAQ,CAER;CAEF,CAAC;CAED,MAAM,OAAO,KAAK,UAAU;EAC3B,SAAS,OAAO;EAChB,iBAAiB,OAAO;EACxB,qBAAqB,OAAO,oBAAoB,KAAK,MAAM,EAAE,OAAO;EACpE;EACA,OAAO,OAAO,QAAQ,OAAO,MAAM,UAAU;CAC9C,CAAC;CAGD,QAAQ,OAAO,MAAM,GAAG,KAAK,WAAW,QAAQ,KAAK,CAAC,CAAC;AACxD;AAEA,MAAM,CAAC,CAAC,OAAO,MAAM;CACpB,QAAQ,IAAI,KAAK,UAAU;EAAE,SAAS,CAAC;EAAG,OAAO,EAAE,WAAW,OAAO,CAAC;CAAE,CAAC,CAAC;CAC1E,QAAQ,KAAK,CAAC;AACf,CAAC"}