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

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 (114) hide show
  1. package/README.md +110 -178
  2. package/dist/{HostingerProvider-CY_VpVud.mjs → HostingerProvider-D85ayzTi.mjs} +2 -2
  3. package/dist/{HostingerProvider-CY_VpVud.mjs.map → HostingerProvider-D85ayzTi.mjs.map} +1 -1
  4. package/dist/{HostingerProvider-BznqRC2S.cjs → HostingerProvider-dxkwynSs.cjs} +2 -2
  5. package/dist/{HostingerProvider-BznqRC2S.cjs.map → HostingerProvider-dxkwynSs.cjs.map} +1 -1
  6. package/dist/{LegacyStateStore-BFcTT2QL.cjs → LegacyStateStore-BZiO9-Lw.cjs} +2 -2
  7. package/dist/{LegacyStateStore-BFcTT2QL.cjs.map → LegacyStateStore-BZiO9-Lw.cjs.map} +1 -1
  8. package/dist/{LegacyStateStore-CFheFo62.mjs → LegacyStateStore-C39UKwmf.mjs} +2 -2
  9. package/dist/{LegacyStateStore-CFheFo62.mjs.map → LegacyStateStore-C39UKwmf.mjs.map} +1 -1
  10. package/dist/{LocalStateStore-BVUexSvu.cjs → LocalStateStore-DHVsZLyF.cjs} +2 -2
  11. package/dist/{LocalStateStore-BVUexSvu.cjs.map → LocalStateStore-DHVsZLyF.cjs.map} +1 -1
  12. package/dist/{LocalStateStore-Bm3x9oOg.mjs → LocalStateStore-Dk3Wbvzk.mjs} +2 -2
  13. package/dist/{LocalStateStore-Bm3x9oOg.mjs.map → LocalStateStore-Dk3Wbvzk.mjs.map} +1 -1
  14. package/dist/{S3StateStore-CoXBhILd.cjs → S3StateStore--4tYVMAL.cjs} +2 -2
  15. package/dist/{S3StateStore-CoXBhILd.cjs.map → S3StateStore--4tYVMAL.cjs.map} +1 -1
  16. package/dist/{S3StateStore-BFHuctWM.mjs → S3StateStore-B_ZF9eHt.mjs} +2 -2
  17. package/dist/{S3StateStore-BFHuctWM.mjs.map → S3StateStore-B_ZF9eHt.mjs.map} +1 -1
  18. package/dist/{SSMStateStore-BqCA9TP2.cjs → SSMStateStore-ACZ8hRvZ.cjs} +2 -2
  19. package/dist/{SSMStateStore-BqCA9TP2.cjs.map → SSMStateStore-ACZ8hRvZ.cjs.map} +1 -1
  20. package/dist/{SSMStateStore-C1kvHScY.mjs → SSMStateStore-DjPuKqrm.mjs} +2 -2
  21. package/dist/{SSMStateStore-C1kvHScY.mjs.map → SSMStateStore-DjPuKqrm.mjs.map} +1 -1
  22. package/dist/{bundler-Dvaiud0h.mjs → bundler-Bq3HaLOZ.mjs} +20 -5
  23. package/dist/bundler-Bq3HaLOZ.mjs.map +1 -0
  24. package/dist/{bundler-orRqUJNZ.cjs → bundler-pyLj-gS0.cjs} +20 -5
  25. package/dist/bundler-pyLj-gS0.cjs.map +1 -0
  26. package/dist/{cli-CfHm0AO7.mjs → cli-C2Tjbn27.mjs} +4 -4
  27. package/dist/{cli-CfHm0AO7.mjs.map → cli-C2Tjbn27.mjs.map} +1 -1
  28. package/dist/{cli-D1JkkOwg.cjs → cli-DR7B2_fX.cjs} +4 -4
  29. package/dist/{cli-D1JkkOwg.cjs.map → cli-DR7B2_fX.cjs.map} +1 -1
  30. package/dist/{compose-jrLy7KGO.cjs → compose-5oNHAKNT.cjs} +135 -110
  31. package/dist/compose-5oNHAKNT.cjs.map +1 -0
  32. package/dist/{compose-CNQL8BnO.mjs → compose-BjToENzG.mjs} +128 -103
  33. package/dist/compose-BjToENzG.mjs.map +1 -0
  34. package/dist/{credentials-Bzbg23n8.cjs → credentials-BVs7mrtw.cjs} +239 -3
  35. package/dist/credentials-BVs7mrtw.cjs.map +1 -0
  36. package/dist/{credentials-Dq1MnWQf.mjs → credentials-pAtB70k3.mjs} +223 -5
  37. package/dist/credentials-pAtB70k3.mjs.map +1 -0
  38. package/dist/deploy/public.cjs +17 -17
  39. package/dist/deploy/public.cjs.map +1 -1
  40. package/dist/deploy/public.mjs +9 -9
  41. package/dist/{deploy-B7aJi_Ah.cjs → deploy-BucRfbvX.cjs} +9 -9
  42. package/dist/{deploy-B7aJi_Ah.cjs.map → deploy-BucRfbvX.cjs.map} +1 -1
  43. package/dist/{deploy-DWn7YfIc.mjs → deploy-DRAwTG72.mjs} +6 -6
  44. package/dist/{deploy-DWn7YfIc.mjs.map → deploy-DRAwTG72.mjs.map} +1 -1
  45. package/dist/{dokploy-DalwLML5.mjs → dokploy-DIt1IZl1.mjs} +2 -2
  46. package/dist/{dokploy-DalwLML5.mjs.map → dokploy-DIt1IZl1.mjs.map} +1 -1
  47. package/dist/{dokploy-B4LcYG1E.cjs → dokploy-m345Zx02.cjs} +2 -2
  48. package/dist/{dokploy-B4LcYG1E.cjs.map → dokploy-m345Zx02.cjs.map} +1 -1
  49. package/dist/{encryption-CPfENwWO.mjs → encryption-Ccbahik7.mjs} +2 -2
  50. package/dist/{encryption-CPfENwWO.mjs.map → encryption-Ccbahik7.mjs.map} +1 -1
  51. package/dist/{encryption-3KlGS1sl.cjs → encryption-rZ3BghXy.cjs} +2 -2
  52. package/dist/{encryption-3KlGS1sl.cjs.map → encryption-rZ3BghXy.cjs.map} +1 -1
  53. package/dist/{engine-DR6KurWX.cjs → engine-Cx_dvx9q.cjs} +9 -187
  54. package/dist/engine-Cx_dvx9q.cjs.map +1 -0
  55. package/dist/{engine-CunvOG3s.mjs → engine-Gs0abjuj.mjs} +5 -183
  56. package/dist/engine-Gs0abjuj.mjs.map +1 -0
  57. package/dist/{github-MXA9v7Ge.mjs → github-CJANTYqi.mjs} +2 -2
  58. package/dist/{github-MXA9v7Ge.mjs.map → github-CJANTYqi.mjs.map} +1 -1
  59. package/dist/{github-BJ5gh9bw.cjs → github-CrcGFkfD.cjs} +2 -2
  60. package/dist/{github-BJ5gh9bw.cjs.map → github-CrcGFkfD.cjs.map} +1 -1
  61. package/dist/index.cjs +51 -65
  62. package/dist/index.cjs.map +1 -1
  63. package/dist/index.mjs +47 -61
  64. package/dist/index.mjs.map +1 -1
  65. package/dist/{migrate-CF4J4GQS.cjs → migrate-CQdSpttI.cjs} +2 -2
  66. package/dist/{migrate-CF4J4GQS.cjs.map → migrate-CQdSpttI.cjs.map} +1 -1
  67. package/dist/{migrate-BJBcm4sG.mjs → migrate-DCVo5gLS.mjs} +2 -2
  68. package/dist/{migrate-BJBcm4sG.mjs.map → migrate-DCVo5gLS.mjs.map} +1 -1
  69. package/dist/{resolve-CVmch0wI.cjs → resolve-BexmDcsN.cjs} +4 -4
  70. package/dist/{resolve-CVmch0wI.cjs.map → resolve-BexmDcsN.cjs.map} +1 -1
  71. package/dist/{resolve-Db0tNlrW.mjs → resolve-DhZgtvZe.mjs} +4 -4
  72. package/dist/{resolve-Db0tNlrW.mjs.map → resolve-DhZgtvZe.mjs.map} +1 -1
  73. package/dist/{rollback-DxJK84hy.cjs → rollback-BnY7KuG_.cjs} +6 -7
  74. package/dist/{rollback-DxJK84hy.cjs.map → rollback-BnY7KuG_.cjs.map} +1 -1
  75. package/dist/{rollback-DvAo4OKS.mjs → rollback-m4Yeym5x.mjs} +5 -6
  76. package/dist/{rollback-DvAo4OKS.mjs.map → rollback-m4Yeym5x.mjs.map} +1 -1
  77. package/dist/run-BJLIerMM.mjs +133 -0
  78. package/dist/run-BJLIerMM.mjs.map +1 -0
  79. package/dist/run-fVZ-rLnc.cjs +174 -0
  80. package/dist/run-fVZ-rLnc.cjs.map +1 -0
  81. package/dist/{sniffer-BAQhLEsI.mjs → sniffer-BdFeLSmA.mjs} +8 -60
  82. package/dist/sniffer-BdFeLSmA.mjs.map +1 -0
  83. package/dist/{sniffer-5xmrkh2a.cjs → sniffer-D66HIvi9.cjs} +7 -77
  84. package/dist/{sniffer-5xmrkh2a.cjs.map → sniffer-D66HIvi9.cjs.map} +1 -1
  85. package/dist/{sst-B2HbrDR3.mjs → sst-DRi3H5TB.mjs} +3 -3
  86. package/dist/{sst-B2HbrDR3.mjs.map → sst-DRi3H5TB.mjs.map} +1 -1
  87. package/dist/{sst-DcfsVH6x.cjs → sst-hBrKouBy.cjs} +5 -5
  88. package/dist/{sst-DcfsVH6x.cjs.map → sst-hBrKouBy.cjs.map} +1 -1
  89. package/dist/{state-Y6ATakMX.cjs → state-DgmM4EKq.cjs} +3588 -3415
  90. package/dist/state-DgmM4EKq.cjs.map +1 -0
  91. package/dist/{state-uuYqnRVO.mjs → state-DkUStoqJ.mjs} +3528 -3385
  92. package/dist/state-DkUStoqJ.mjs.map +1 -0
  93. package/dist/target/public.cjs +1 -1
  94. package/dist/target/public.mjs +1 -1
  95. package/dist/{terminal-DUhcZ1ND.mjs → terminal-C3cv-OQu.mjs} +2 -2
  96. package/dist/{terminal-DUhcZ1ND.mjs.map → terminal-C3cv-OQu.mjs.map} +1 -1
  97. package/dist/{terminal-CHy_MdjG.cjs → terminal-DjzgLu6m.cjs} +2 -2
  98. package/dist/{terminal-CHy_MdjG.cjs.map → terminal-DjzgLu6m.cjs.map} +1 -1
  99. package/package.json +13 -13
  100. package/dist/bundler-Dvaiud0h.mjs.map +0 -1
  101. package/dist/bundler-orRqUJNZ.cjs.map +0 -1
  102. package/dist/compose-CNQL8BnO.mjs.map +0 -1
  103. package/dist/compose-jrLy7KGO.cjs.map +0 -1
  104. package/dist/credentials-Bzbg23n8.cjs.map +0 -1
  105. package/dist/credentials-Dq1MnWQf.mjs.map +0 -1
  106. package/dist/engine-CunvOG3s.mjs.map +0 -1
  107. package/dist/engine-DR6KurWX.cjs.map +0 -1
  108. package/dist/local-BdH4XN0E.cjs +0 -409
  109. package/dist/local-BdH4XN0E.cjs.map +0 -1
  110. package/dist/local-CWR4Y_kW.mjs +0 -350
  111. package/dist/local-CWR4Y_kW.mjs.map +0 -1
  112. package/dist/sniffer-BAQhLEsI.mjs.map +0 -1
  113. package/dist/state-Y6ATakMX.cjs.map +0 -1
  114. package/dist/state-uuYqnRVO.mjs.map +0 -1
@@ -1,7 +1,10 @@
1
- import { u as gkmHome } from "./local-CWR4Y_kW.mjs";
2
- import { join } from "node:path";
1
+ import { n as CommandTimedOut, s as gkmHome } from "./run-BJLIerMM.mjs";
2
+ import { a as assertSecretNames, o as confineCwd, t as SECRETS_DIR_ENV } from "./sandbox-Dm247NGx.mjs";
3
+ import { join, resolve } from "node:path";
3
4
  import { existsSync, mkdirSync } from "node:fs";
4
- import { readFile, writeFile } from "node:fs/promises";
5
+ import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
6
+ import { tmpdir } from "node:os";
7
+ import { spawn } from "node:child_process";
5
8
  //#region src/auth/credentials.ts
6
9
  /**
7
10
  * Get the path to the credentials directory
@@ -124,6 +127,221 @@ async function getHostingerToken(options) {
124
127
  return (await readCredentials(options)).hostinger?.token ?? null;
125
128
  }
126
129
  //#endregion
130
+ //#region src/sandbox/env.ts
131
+ /**
132
+ * What of the host's environment a local sandbox passes on.
133
+ *
134
+ * An allowlist, not a denylist: a credential's variable has any name its
135
+ * owner chose (`DOKPLOY_TOKEN`, `AWS_SECRET_ACCESS_KEY`, `MY_VAULT_TOKEN`), so
136
+ * the only safe default is to name what a program needs to *run* and pass
137
+ * nothing else.
138
+ */
139
+ /**
140
+ * Variables a command needs to find programs, write temp files, print in the
141
+ * user's locale and reach the network through the host's proxy — and nothing
142
+ * that authenticates as anyone.
143
+ *
144
+ * Deliberately left out:
145
+ * - `NODE_OPTIONS`: it can `--require` or `--import` code into every node
146
+ * process, and CI often holds `--import tsx` there. A step that needs a
147
+ * loader passes its own.
148
+ * - `NODE_AUTH_TOKEN`, `NPM_TOKEN`, `npm_config_*`: registry tokens
149
+ * (`actions/setup-node` writes `NODE_AUTH_TOKEN`), which is why there is no
150
+ * `NODE_*` wildcard.
151
+ * - `AWS_*`, `DOCKER_*`, `DOKPLOY_*`, `GITHUB_TOKEN`, `TURBO_TOKEN`, `GKM_*`:
152
+ * credentials, or where the deploy keeps them.
153
+ * - `SHELL`, `EDITOR` and the rest of a login session: nothing here starts a
154
+ * shell.
155
+ *
156
+ * Proxies are passed: behind one, nothing installs or builds without it. A
157
+ * proxy URL with a password in it reaches the command too — a host that keeps
158
+ * one there and builds code it does not trust should pass a sandbox of its
159
+ * own.
160
+ */
161
+ const SANDBOX_ENV_ALLOWLIST = [
162
+ "PATH",
163
+ "HOME",
164
+ "USER",
165
+ "LOGNAME",
166
+ "TMPDIR",
167
+ "TMP",
168
+ "TEMP",
169
+ "LANG",
170
+ "LANGUAGE",
171
+ "TZ",
172
+ /^LC_[A-Z]+$/,
173
+ "TERM",
174
+ "COLORTERM",
175
+ "NO_COLOR",
176
+ "FORCE_COLOR",
177
+ "CI",
178
+ "NODE_ENV",
179
+ "NODE_EXTRA_CA_CERTS",
180
+ "COREPACK_HOME",
181
+ "PNPM_HOME",
182
+ "XDG_CACHE_HOME",
183
+ "XDG_DATA_HOME",
184
+ "HTTP_PROXY",
185
+ "HTTPS_PROXY",
186
+ "NO_PROXY",
187
+ "http_proxy",
188
+ "https_proxy",
189
+ "no_proxy",
190
+ "SystemRoot",
191
+ "SYSTEMROOT",
192
+ "windir",
193
+ "WINDIR",
194
+ "ComSpec",
195
+ "COMSPEC",
196
+ "PATHEXT",
197
+ "USERPROFILE",
198
+ "APPDATA",
199
+ "LOCALAPPDATA"
200
+ ];
201
+ function allowed(name) {
202
+ return SANDBOX_ENV_ALLOWLIST.some((entry) => typeof entry === "string" ? entry === name : entry.test(name));
203
+ }
204
+ /**
205
+ * The allowlisted part of `source`, plus each of `extra` the host chose to
206
+ * pass on by name.
207
+ */
208
+ function allowlistedEnv(source = process.env, extra = []) {
209
+ const env = {};
210
+ for (const [name, value] of Object.entries(source)) {
211
+ if (value === void 0) continue;
212
+ if (allowed(name) || extra.includes(name)) env[name] = value;
213
+ }
214
+ return env;
215
+ }
216
+ //#endregion
217
+ //#region src/sandbox/local.ts
218
+ /** How long a timed-out command has to exit on SIGTERM before SIGKILL. */
219
+ const KILL_GRACE_MS = 5e3;
220
+ /** Where `output` sends a child's streams. */
221
+ const STDIO = {
222
+ capture: [
223
+ "ignore",
224
+ "pipe",
225
+ "pipe"
226
+ ],
227
+ inherit: "inherit",
228
+ stderr: [
229
+ "ignore",
230
+ 2,
231
+ 2
232
+ ],
233
+ ignore: "ignore"
234
+ };
235
+ /**
236
+ * A child process on this machine, as this user, with an allowlisted
237
+ * environment.
238
+ *
239
+ * What it withholds from the command: the host's environment beyond
240
+ * {@link SANDBOX_ENV_ALLOWLIST}, a shell, a working directory outside the
241
+ * project, and any time past the timeout. What it does not: the host's
242
+ * filesystem, which the command can read and write as the user running the
243
+ * deploy. So it is not `isolating`, and it is the default for projects the
244
+ * host already trusts — the developer's own, a team's own CI. Code nobody
245
+ * vetted belongs in a sandbox that is.
246
+ *
247
+ * A timed-out command is sent SIGTERM, then SIGKILL; processes it started
248
+ * itself are its to stop.
249
+ */
250
+ var LocalSandbox = class {
251
+ root;
252
+ isolating = false;
253
+ env;
254
+ constructor(options) {
255
+ this.root = resolve(options.root);
256
+ this.env = {
257
+ ...allowlistedEnv(options.hostEnv ?? process.env, options.passEnv),
258
+ ...options.home ? {
259
+ HOME: options.home,
260
+ USERPROFILE: options.home
261
+ } : {}
262
+ };
263
+ }
264
+ async exec(command, args, options) {
265
+ const cwd = confineCwd(this.root, options.cwd);
266
+ assertSecretNames(options.secrets);
267
+ options.signal?.throwIfAborted();
268
+ const secretsDir = await mountSecrets(options.secrets);
269
+ try {
270
+ return await spawnConfined(command, args, {
271
+ ...options,
272
+ cwd,
273
+ env: secretsDir ? {
274
+ ...options.env,
275
+ [SECRETS_DIR_ENV]: secretsDir
276
+ } : options.env
277
+ });
278
+ } finally {
279
+ if (secretsDir) await rm(secretsDir, {
280
+ recursive: true,
281
+ force: true
282
+ });
283
+ }
284
+ }
285
+ };
286
+ /**
287
+ * Each secret as a 0600 file in a fresh 0700 directory outside the project —
288
+ * where nothing the build writes, packs or commits will pick it up.
289
+ */
290
+ async function mountSecrets(secrets) {
291
+ if (!secrets || Object.keys(secrets).length === 0) return void 0;
292
+ const dir = await mkdtemp(join(tmpdir(), "gkm-secrets-"));
293
+ for (const [name, value] of Object.entries(secrets)) await writeFile(join(dir, name), value, { mode: 384 });
294
+ return dir;
295
+ }
296
+ function spawnConfined(command, args, options) {
297
+ const { output = "capture", signal, timeoutMs } = options;
298
+ return new Promise((resolvePromise, reject) => {
299
+ const child = spawn(command, [...args], {
300
+ cwd: options.cwd,
301
+ env: { ...options.env },
302
+ stdio: STDIO[output],
303
+ shell: false,
304
+ ...signal ? { signal } : {}
305
+ });
306
+ let stdout = "";
307
+ let stderr = "";
308
+ child.stdout?.on("data", (chunk) => {
309
+ stdout += chunk.toString();
310
+ });
311
+ child.stderr?.on("data", (chunk) => {
312
+ stderr += chunk.toString();
313
+ });
314
+ let timedOut = false;
315
+ let killer;
316
+ const timer = setTimeout(() => {
317
+ timedOut = true;
318
+ child.kill("SIGTERM");
319
+ killer = setTimeout(() => child.kill("SIGKILL"), KILL_GRACE_MS);
320
+ killer.unref?.();
321
+ }, timeoutMs);
322
+ timer.unref?.();
323
+ const settle = () => {
324
+ clearTimeout(timer);
325
+ if (killer) clearTimeout(killer);
326
+ };
327
+ child.on("error", (error) => {
328
+ settle();
329
+ reject(signal?.aborted ? signal.reason : error);
330
+ });
331
+ child.on("close", (code, killedBy) => {
332
+ settle();
333
+ if (signal?.aborted) reject(signal.reason);
334
+ else if (timedOut) reject(new CommandTimedOut(command, args, timeoutMs));
335
+ else resolvePromise({
336
+ exitCode: code,
337
+ signal: killedBy ?? null,
338
+ stdout,
339
+ stderr
340
+ });
341
+ });
342
+ });
343
+ }
344
+ //#endregion
127
345
  //#region src/deploy/credentials.ts
128
346
  /**
129
347
  * How a deploy gets the credentials it acts with.
@@ -228,6 +446,6 @@ function storedCredentials(options = {}) {
228
446
  } };
229
447
  }
230
448
  //#endregion
231
- export { getDokployCredentials as a, getHostingerToken as c, storeHostingerToken as d, getCredentialsPath as i, removeDokployCredentials as l, chainCredentials as n, getDokployRegistryId as o, storedCredentials as r, getDokployToken as s, MissingCredential as t, storeDokployCredentials as u };
449
+ export { SANDBOX_ENV_ALLOWLIST as a, getDokployCredentials as c, getHostingerToken as d, removeDokployCredentials as f, LocalSandbox as i, getDokployRegistryId as l, storeHostingerToken as m, chainCredentials as n, allowlistedEnv as o, storeDokployCredentials as p, storedCredentials as r, getCredentialsPath as s, MissingCredential as t, getDokployToken as u };
232
450
 
233
- //# sourceMappingURL=credentials-Dq1MnWQf.mjs.map
451
+ //# sourceMappingURL=credentials-pAtB70k3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials-pAtB70k3.mjs","names":[],"sources":["../src/auth/credentials.ts","../src/sandbox/env.ts","../src/sandbox/local.ts","../src/deploy/credentials.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { readFile, unlink, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { gkmHome } from '../home';\n\n/**\n * Stored credentials for various services\n */\nexport interface StoredCredentials {\n\tdokploy?: {\n\t\t/** API token */\n\t\ttoken: string;\n\t\t/** Dokploy endpoint URL */\n\t\tendpoint: string;\n\t\t/** Registry ID in Dokploy (for Docker image pulls) */\n\t\tregistryId?: string;\n\t\t/** When the credentials were stored */\n\t\tstoredAt: string;\n\t};\n\thostinger?: {\n\t\t/** API token from hpanel.hostinger.com/profile/api */\n\t\ttoken: string;\n\t\t/** When the credentials were stored */\n\t\tstoredAt: string;\n\t};\n}\n\n/**\n * Options for credential operations\n */\nexport interface CredentialOptions {\n\t/**\n\t * A directory whose `.gkm` holds the credentials. Default: the CLI's home\n\t * (`GKM_HOME`, else `~/.gkm`).\n\t */\n\troot?: string;\n\t/** The CLI's home itself, holding `credentials.json`. Wins over `root`. */\n\thome?: string;\n}\n\n/**\n * Get the path to the credentials directory\n */\nexport function getCredentialsDir(options?: CredentialOptions): string {\n\tif (options?.home) return options.home;\n\treturn options?.root ? join(options.root, '.gkm') : gkmHome();\n}\n\n/**\n * Get the path to the credentials file\n */\nexport function getCredentialsPath(options?: CredentialOptions): string {\n\treturn join(getCredentialsDir(options), 'credentials.json');\n}\n\n/**\n * Ensure the credentials directory exists\n */\nfunction ensureCredentialsDir(options?: CredentialOptions): void {\n\tconst dir = getCredentialsDir(options);\n\tif (!existsSync(dir)) {\n\t\tmkdirSync(dir, { recursive: true, mode: 0o700 });\n\t}\n}\n\n/**\n * Read stored credentials from disk\n */\nexport async function readCredentials(\n\toptions?: CredentialOptions,\n): Promise<StoredCredentials> {\n\tconst path = getCredentialsPath(options);\n\n\tif (!existsSync(path)) {\n\t\treturn {};\n\t}\n\n\ttry {\n\t\tconst content = await readFile(path, 'utf-8');\n\t\treturn JSON.parse(content) as StoredCredentials;\n\t} catch {\n\t\treturn {};\n\t}\n}\n\n/**\n * Write credentials to disk\n */\nexport async function writeCredentials(\n\tcredentials: StoredCredentials,\n\toptions?: CredentialOptions,\n): Promise<void> {\n\tensureCredentialsDir(options);\n\tconst path = getCredentialsPath(options);\n\n\tawait writeFile(path, JSON.stringify(credentials, null, 2), {\n\t\tmode: 0o600, // Owner read/write only\n\t});\n}\n\n/**\n * Store Dokploy credentials\n */\nexport async function storeDokployCredentials(\n\ttoken: string,\n\tendpoint: string,\n\toptions?: CredentialOptions,\n): Promise<void> {\n\tconst credentials = await readCredentials(options);\n\n\tcredentials.dokploy = {\n\t\ttoken,\n\t\tendpoint,\n\t\tstoredAt: new Date().toISOString(),\n\t};\n\n\tawait writeCredentials(credentials, options);\n}\n\n/**\n * Get stored Dokploy credentials\n */\nexport async function getDokployCredentials(\n\toptions?: CredentialOptions,\n): Promise<{\n\ttoken: string;\n\tendpoint: string;\n\tregistryId?: string;\n} | null> {\n\tconst credentials = await readCredentials(options);\n\n\t// The environment first, and each half independently.\n\t//\n\t// `getDokployToken` has always read `DOKPLOY_API_TOKEN` while this — the\n\t// function the deploy path actually calls — read only the file. So a CI job\n\t// given the token as a secret had a token and nowhere to send it, and the\n\t// only way through was committing a credentials file or running an\n\t// interactive login on the runner.\n\t//\n\t// Read separately rather than as a pair because they arrive separately: a\n\t// token is a secret and belongs in the environment, while an endpoint is\n\t// configuration and usually belongs in `deploy.dokploy.endpoint`. Requiring\n\t// both from the same place is what made either one useless alone.\n\tconst token = process.env.DOKPLOY_API_TOKEN ?? credentials.dokploy?.token;\n\tconst endpoint =\n\t\tprocess.env.DOKPLOY_ENDPOINT ?? credentials.dokploy?.endpoint;\n\n\tif (!token || !endpoint) return null;\n\n\treturn {\n\t\ttoken,\n\t\tendpoint: endpoint.replace(/\\/$/, ''),\n\t\t...(credentials.dokploy?.registryId\n\t\t\t? { registryId: credentials.dokploy.registryId }\n\t\t\t: {}),\n\t};\n}\n\n/**\n * Remove Dokploy credentials\n */\nexport async function removeDokployCredentials(\n\toptions?: CredentialOptions,\n): Promise<boolean> {\n\tconst credentials = await readCredentials(options);\n\n\tif (!credentials.dokploy) {\n\t\treturn false;\n\t}\n\n\tdelete credentials.dokploy;\n\tawait writeCredentials(credentials, options);\n\treturn true;\n}\n\n/**\n * Remove all stored credentials\n */\nexport async function removeAllCredentials(\n\toptions?: CredentialOptions,\n): Promise<void> {\n\tconst path = getCredentialsPath(options);\n\n\tif (existsSync(path)) {\n\t\tawait unlink(path);\n\t}\n}\n\n/**\n * Get Dokploy API token, checking stored credentials first, then environment\n */\nexport async function getDokployToken(\n\toptions?: CredentialOptions,\n): Promise<string | null> {\n\t// First check environment variable (takes precedence)\n\tconst envToken = process.env.DOKPLOY_API_TOKEN;\n\tif (envToken) {\n\t\treturn envToken;\n\t}\n\n\t// Then check stored credentials\n\tconst stored = await getDokployCredentials(options);\n\tif (stored) {\n\t\treturn stored.token;\n\t}\n\n\treturn null;\n}\n\n/**\n * Get Dokploy endpoint from stored credentials\n */\nexport async function getDokployEndpoint(\n\toptions?: CredentialOptions,\n): Promise<string | null> {\n\tconst stored = await getDokployCredentials(options);\n\treturn stored?.endpoint ?? null;\n}\n\n/**\n * Store Dokploy registry ID\n */\nexport async function storeDokployRegistryId(\n\tregistryId: string,\n\toptions?: CredentialOptions,\n): Promise<void> {\n\tconst credentials = await readCredentials(options);\n\n\tif (!credentials.dokploy) {\n\t\tthrow new Error(\n\t\t\t'Dokploy credentials not found. Run \"gkm login --service dokploy\" first.',\n\t\t);\n\t}\n\n\tcredentials.dokploy.registryId = registryId;\n\tawait writeCredentials(credentials, options);\n}\n\n/**\n * Get Dokploy registry ID from stored credentials\n */\nexport async function getDokployRegistryId(\n\toptions?: CredentialOptions,\n): Promise<string | undefined> {\n\tconst stored = await getDokployCredentials(options);\n\treturn stored?.registryId ?? undefined;\n}\n\n// ============================================\n// Hostinger credentials\n// ============================================\n\n/**\n * Store Hostinger API token\n *\n * @param token - API token from hpanel.hostinger.com/profile/api\n */\nexport async function storeHostingerToken(\n\ttoken: string,\n\toptions?: CredentialOptions,\n): Promise<void> {\n\tconst credentials = await readCredentials(options);\n\n\tcredentials.hostinger = {\n\t\ttoken,\n\t\tstoredAt: new Date().toISOString(),\n\t};\n\n\tawait writeCredentials(credentials, options);\n}\n\n/**\n * Get stored Hostinger API token\n *\n * Checks environment variable first (HOSTINGER_API_TOKEN),\n * then falls back to stored credentials.\n */\nexport async function getHostingerToken(\n\toptions?: CredentialOptions,\n): Promise<string | null> {\n\t// First check environment variable (takes precedence)\n\tconst envToken = process.env.HOSTINGER_API_TOKEN;\n\tif (envToken) {\n\t\treturn envToken;\n\t}\n\n\t// Then check stored credentials\n\tconst credentials = await readCredentials(options);\n\treturn credentials.hostinger?.token ?? null;\n}\n\n/**\n * Remove Hostinger credentials\n */\nexport async function removeHostingerCredentials(\n\toptions?: CredentialOptions,\n): Promise<boolean> {\n\tconst credentials = await readCredentials(options);\n\n\tif (!credentials.hostinger) {\n\t\treturn false;\n\t}\n\n\tdelete credentials.hostinger;\n\tawait writeCredentials(credentials, options);\n\treturn true;\n}\n","/**\n * What of the host's environment a local sandbox passes on.\n *\n * An allowlist, not a denylist: a credential's variable has any name its\n * owner chose (`DOKPLOY_TOKEN`, `AWS_SECRET_ACCESS_KEY`, `MY_VAULT_TOKEN`), so\n * the only safe default is to name what a program needs to *run* and pass\n * nothing else.\n */\n\n/**\n * Variables a command needs to find programs, write temp files, print in the\n * user's locale and reach the network through the host's proxy — and nothing\n * that authenticates as anyone.\n *\n * Deliberately left out:\n * - `NODE_OPTIONS`: it can `--require` or `--import` code into every node\n * process, and CI often holds `--import tsx` there. A step that needs a\n * loader passes its own.\n * - `NODE_AUTH_TOKEN`, `NPM_TOKEN`, `npm_config_*`: registry tokens\n * (`actions/setup-node` writes `NODE_AUTH_TOKEN`), which is why there is no\n * `NODE_*` wildcard.\n * - `AWS_*`, `DOCKER_*`, `DOKPLOY_*`, `GITHUB_TOKEN`, `TURBO_TOKEN`, `GKM_*`:\n * credentials, or where the deploy keeps them.\n * - `SHELL`, `EDITOR` and the rest of a login session: nothing here starts a\n * shell.\n *\n * Proxies are passed: behind one, nothing installs or builds without it. A\n * proxy URL with a password in it reaches the command too — a host that keeps\n * one there and builds code it does not trust should pass a sandbox of its\n * own.\n */\nexport const SANDBOX_ENV_ALLOWLIST: readonly (string | RegExp)[] = [\n\t// Finding programs and a home to cache in.\n\t'PATH',\n\t'HOME',\n\t'USER',\n\t'LOGNAME',\n\t'TMPDIR',\n\t'TMP',\n\t'TEMP',\n\t// Locale and terminal: output a person reads should look the same.\n\t'LANG',\n\t'LANGUAGE',\n\t'TZ',\n\t/^LC_[A-Z]+$/,\n\t'TERM',\n\t'COLORTERM',\n\t'NO_COLOR',\n\t'FORCE_COLOR',\n\t'CI',\n\t// Node: the mode a build runs in, and the CAs a corporate network adds.\n\t'NODE_ENV',\n\t'NODE_EXTRA_CA_CERTS',\n\t// Package managers' own homes, so a build reuses the host's store.\n\t'COREPACK_HOME',\n\t'PNPM_HOME',\n\t'XDG_CACHE_HOME',\n\t'XDG_DATA_HOME',\n\t// The network, through the host's proxy.\n\t'HTTP_PROXY',\n\t'HTTPS_PROXY',\n\t'NO_PROXY',\n\t'http_proxy',\n\t'https_proxy',\n\t'no_proxy',\n\t// Windows: without these, nothing starts.\n\t'SystemRoot',\n\t'SYSTEMROOT',\n\t'windir',\n\t'WINDIR',\n\t'ComSpec',\n\t'COMSPEC',\n\t'PATHEXT',\n\t'USERPROFILE',\n\t'APPDATA',\n\t'LOCALAPPDATA',\n];\n\nfunction allowed(name: string): boolean {\n\treturn SANDBOX_ENV_ALLOWLIST.some((entry) =>\n\t\ttypeof entry === 'string' ? entry === name : entry.test(name),\n\t);\n}\n\n/**\n * The allowlisted part of `source`, plus each of `extra` the host chose to\n * pass on by name.\n */\nexport function allowlistedEnv(\n\tsource: NodeJS.ProcessEnv = process.env,\n\textra: readonly string[] = [],\n): Record<string, string> {\n\tconst env: Record<string, string> = {};\n\tfor (const [name, value] of Object.entries(source)) {\n\t\tif (value === undefined) continue;\n\t\tif (allowed(name) || extra.includes(name)) env[name] = value;\n\t}\n\treturn env;\n}\n","import { type SpawnOptions, spawn } from 'node:child_process';\nimport { mkdtemp, rm, writeFile } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport { join, resolve } from 'node:path';\nimport { CommandTimedOut } from '../run';\nimport { allowlistedEnv } from './env';\nimport {\n\tassertSecretNames,\n\tconfineCwd,\n\ttype Sandbox,\n\ttype SandboxExecOptions,\n\ttype SandboxOutput,\n\ttype SandboxResult,\n\tSECRETS_DIR_ENV,\n} from './sandbox';\n\n/** How long a timed-out command has to exit on SIGTERM before SIGKILL. */\nconst KILL_GRACE_MS = 5_000;\n\nexport interface LocalSandboxOptions {\n\t/** The project. Every command runs at or below it. */\n\troot: string;\n\t/**\n\t * `HOME` for every command. Defaults to the host's, because a build\n\t * reuses the caches kept there — the pnpm store, corepack's package\n\t * managers, turbo's cache — and a cold one re-downloads all of them.\n\t * Point it at an empty directory to keep `~/.aws`, `~/.npmrc` and\n\t * `~/.docker` out of reach of an SDK's default lookup — though, sharing\n\t * the host's filesystem, a command that goes looking still finds them.\n\t */\n\thome?: string;\n\t/**\n\t * Host variables to pass on beyond the allowlist, by name — a remote\n\t * cache's `TURBO_TOKEN`, for a build the host trusts with it.\n\t */\n\tpassEnv?: readonly string[];\n\t/** Where the allowlisted variables are read from. Defaults to `process.env`. */\n\thostEnv?: NodeJS.ProcessEnv;\n}\n\n/** Where `output` sends a child's streams. */\nconst STDIO: Record<SandboxOutput, SpawnOptions['stdio']> = {\n\tcapture: ['ignore', 'pipe', 'pipe'],\n\tinherit: 'inherit',\n\tstderr: ['ignore', 2, 2],\n\tignore: 'ignore',\n};\n\n/**\n * A child process on this machine, as this user, with an allowlisted\n * environment.\n *\n * What it withholds from the command: the host's environment beyond\n * {@link SANDBOX_ENV_ALLOWLIST}, a shell, a working directory outside the\n * project, and any time past the timeout. What it does not: the host's\n * filesystem, which the command can read and write as the user running the\n * deploy. So it is not `isolating`, and it is the default for projects the\n * host already trusts — the developer's own, a team's own CI. Code nobody\n * vetted belongs in a sandbox that is.\n *\n * A timed-out command is sent SIGTERM, then SIGKILL; processes it started\n * itself are its to stop.\n */\nexport class LocalSandbox implements Sandbox {\n\treadonly root: string;\n\treadonly isolating = false;\n\treadonly env: Readonly<Record<string, string>>;\n\n\tconstructor(options: LocalSandboxOptions) {\n\t\tthis.root = resolve(options.root);\n\t\tthis.env = {\n\t\t\t...allowlistedEnv(options.hostEnv ?? process.env, options.passEnv),\n\t\t\t...(options.home\n\t\t\t\t? { HOME: options.home, USERPROFILE: options.home }\n\t\t\t\t: {}),\n\t\t};\n\t}\n\n\tasync exec(\n\t\tcommand: string,\n\t\targs: readonly string[],\n\t\toptions: SandboxExecOptions,\n\t): Promise<SandboxResult> {\n\t\tconst cwd = confineCwd(this.root, options.cwd);\n\t\tassertSecretNames(options.secrets);\n\t\toptions.signal?.throwIfAborted();\n\n\t\tconst secretsDir = await mountSecrets(options.secrets);\n\t\ttry {\n\t\t\treturn await spawnConfined(command, args, {\n\t\t\t\t...options,\n\t\t\t\tcwd,\n\t\t\t\tenv: secretsDir\n\t\t\t\t\t? { ...options.env, [SECRETS_DIR_ENV]: secretsDir }\n\t\t\t\t\t: options.env,\n\t\t\t});\n\t\t} finally {\n\t\t\tif (secretsDir) await rm(secretsDir, { recursive: true, force: true });\n\t\t}\n\t}\n}\n\n/**\n * Each secret as a 0600 file in a fresh 0700 directory outside the project —\n * where nothing the build writes, packs or commits will pick it up.\n */\nasync function mountSecrets(\n\tsecrets: Readonly<Record<string, string>> | undefined,\n): Promise<string | undefined> {\n\tif (!secrets || Object.keys(secrets).length === 0) return undefined;\n\n\tconst dir = await mkdtemp(join(tmpdir(), 'gkm-secrets-'));\n\tfor (const [name, value] of Object.entries(secrets)) {\n\t\tawait writeFile(join(dir, name), value, { mode: 0o600 });\n\t}\n\treturn dir;\n}\n\nfunction spawnConfined(\n\tcommand: string,\n\targs: readonly string[],\n\toptions: SandboxExecOptions,\n): Promise<SandboxResult> {\n\tconst { output = 'capture', signal, timeoutMs } = options;\n\n\treturn new Promise<SandboxResult>((resolvePromise, reject) => {\n\t\tconst child = spawn(command, [...args], {\n\t\t\tcwd: options.cwd,\n\t\t\t// The whole environment, as given. `spawn` reads `process.env` only\n\t\t\t// when this is left out.\n\t\t\tenv: { ...options.env },\n\t\t\tstdio: STDIO[output],\n\t\t\tshell: false,\n\t\t\t...(signal ? { signal } : {}),\n\t\t});\n\n\t\tlet stdout = '';\n\t\tlet stderr = '';\n\t\tchild.stdout?.on('data', (chunk: Buffer) => {\n\t\t\tstdout += chunk.toString();\n\t\t});\n\t\tchild.stderr?.on('data', (chunk: Buffer) => {\n\t\t\tstderr += chunk.toString();\n\t\t});\n\n\t\tlet timedOut = false;\n\t\tlet killer: NodeJS.Timeout | undefined;\n\t\tconst timer = setTimeout(() => {\n\t\t\ttimedOut = true;\n\t\t\tchild.kill('SIGTERM');\n\t\t\t// A command that ignores SIGTERM would otherwise outlive its timeout.\n\t\t\tkiller = setTimeout(() => child.kill('SIGKILL'), KILL_GRACE_MS);\n\t\t\tkiller.unref?.();\n\t\t}, timeoutMs);\n\t\ttimer.unref?.();\n\n\t\tconst settle = () => {\n\t\t\tclearTimeout(timer);\n\t\t\tif (killer) clearTimeout(killer);\n\t\t};\n\n\t\tchild.on('error', (error) => {\n\t\t\tsettle();\n\t\t\t// Node reports an abort as its own `AbortError`; the caller asked\n\t\t\t// with a reason, and that is what it gets back.\n\t\t\treject(signal?.aborted ? signal.reason : error);\n\t\t});\n\n\t\tchild.on('close', (code: number | null, killedBy: string | null) => {\n\t\t\tsettle();\n\t\t\tif (signal?.aborted) reject(signal.reason);\n\t\t\telse if (timedOut) reject(new CommandTimedOut(command, args, timeoutMs));\n\t\t\telse\n\t\t\t\tresolvePromise({\n\t\t\t\t\texitCode: code,\n\t\t\t\t\tsignal: killedBy ?? null,\n\t\t\t\t\tstdout,\n\t\t\t\t\tstderr,\n\t\t\t\t});\n\t\t});\n\t});\n}\n","/**\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.registry` and one has to be\n\t * created.\n\t */\n\tregistry: {\n\t\t/** `deploy.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":";;;;;;;;;;;AA2CA,SAAgB,kBAAkB,SAAqC;CACtE,IAAI,SAAS,MAAM,OAAO,QAAQ;CAClC,OAAO,SAAS,OAAO,KAAK,QAAQ,MAAM,MAAM,IAAI,QAAQ;AAC7D;;;;AAKA,SAAgB,mBAAmB,SAAqC;CACvE,OAAO,KAAK,kBAAkB,OAAO,GAAG,kBAAkB;AAC3D;;;;AAKA,SAAS,qBAAqB,SAAmC;CAChE,MAAM,MAAM,kBAAkB,OAAO;CACrC,IAAI,CAAC,WAAW,GAAG,GAClB,UAAU,KAAK;EAAE,WAAW;EAAM,MAAM;CAAM,CAAC;AAEjD;;;;AAKA,eAAsB,gBACrB,SAC6B;CAC7B,MAAM,OAAO,mBAAmB,OAAO;CAEvC,IAAI,CAAC,WAAW,IAAI,GACnB,OA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AkB,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"}
@@ -1,18 +1,18 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_local = require("../local-BdH4XN0E.cjs");
3
- const require_credentials = require("../credentials-Bzbg23n8.cjs");
2
+ const require_run = require("../run-fVZ-rLnc.cjs");
3
+ const require_credentials = require("../credentials-BVs7mrtw.cjs");
4
4
  const require_discover = require("../discover-OEfZ9OkA.cjs");
5
5
  const require_sandbox = require("../sandbox-CL--ZDui.cjs");
6
6
  const require_define = require("../define-DzRz8FgH.cjs");
7
7
  const require_config = require("../config.cjs");
8
- const require_state = require("../state-Y6ATakMX.cjs");
9
- const require_sniffer = require("../sniffer-5xmrkh2a.cjs");
10
- const require_resolve = require("../resolve-CVmch0wI.cjs");
11
- const require_deploy = require("../deploy-B7aJi_Ah.cjs");
12
- const require_engine = require("../engine-DR6KurWX.cjs");
13
- const require_rollback = require("../rollback-DxJK84hy.cjs");
8
+ const require_state = require("../state-DgmM4EKq.cjs");
9
+ const require_sniffer = require("../sniffer-D66HIvi9.cjs");
10
+ const require_resolve = require("../resolve-BexmDcsN.cjs");
11
+ const require_deploy = require("../deploy-BucRfbvX.cjs");
12
+ const require_engine = require("../engine-Cx_dvx9q.cjs");
13
+ const require_rollback = require("../rollback-BnY7KuG_.cjs");
14
14
  const require_provider = require("../provider-C9_-45d5.cjs");
15
- const require_sst = require("../sst-DcfsVH6x.cjs");
15
+ const require_sst = require("../sst-hBrKouBy.cjs");
16
16
  let node_path = require("node:path");
17
17
  let node_fs = require("node:fs");
18
18
  //#region src/sandbox/install.ts
@@ -132,14 +132,14 @@ async function installDependencies(sandbox, options = {}) {
132
132
  ...options.signal ? { signal: options.signal } : {}
133
133
  });
134
134
  results.push(result);
135
- if (result.exitCode !== 0) throw new require_local.CommandFailed(command, args, result.exitCode, result.signal);
135
+ if (result.exitCode !== 0) throw new require_run.CommandFailed(command, args, result.exitCode, result.signal);
136
136
  }
137
137
  return results;
138
138
  }
139
139
  //#endregion
140
140
  exports.BackendDeployFailed = require_engine.BackendDeployFailed;
141
- exports.CommandFailed = require_local.CommandFailed;
142
- exports.CommandTimedOut = require_local.CommandTimedOut;
141
+ exports.CommandFailed = require_run.CommandFailed;
142
+ exports.CommandTimedOut = require_run.CommandTimedOut;
143
143
  exports.ConfigLoadFailed = require_config.ConfigLoadFailed;
144
144
  exports.ConfigObjectNotSerializable = require_config.ConfigObjectNotSerializable;
145
145
  exports.ConstructDiscoveryFailed = require_discover.ConstructDiscoveryFailed;
@@ -149,13 +149,13 @@ exports.DeployTargetNotYetSupported = require_define.DeployTargetNotYetSupported
149
149
  exports.DeploymentFailed = require_sniffer.DeploymentFailed;
150
150
  exports.DeploymentTimedOut = require_sniffer.DeploymentTimedOut;
151
151
  exports.FrontendDeployFailed = require_engine.FrontendDeployFailed;
152
- exports.GKM_HOME_ENV = require_local.GKM_HOME_ENV;
152
+ exports.GKM_HOME_ENV = require_run.GKM_HOME_ENV;
153
153
  exports.HealthCheckTimedOut = require_engine.HealthCheckTimedOut;
154
154
  exports.INSTALL_TIMEOUT_MS = INSTALL_TIMEOUT_MS;
155
155
  exports.InstallAllowlistNameInvalid = InstallAllowlistNameInvalid;
156
156
  exports.InstallScriptsAllowlistUnsupported = InstallScriptsAllowlistUnsupported;
157
157
  exports.InvalidTargetOptions = require_resolve.InvalidTargetOptions;
158
- exports.LocalSandbox = require_local.LocalSandbox;
158
+ exports.LocalSandbox = require_credentials.LocalSandbox;
159
159
  exports.MissingCredential = require_credentials.MissingCredential;
160
160
  exports.MissingEnvVars = require_engine.MissingEnvVars;
161
161
  exports.NoDeployableApps = require_deploy.NoDeployableApps;
@@ -167,7 +167,7 @@ exports.RegistryNotConfigured = require_engine.RegistryNotConfigured;
167
167
  exports.RegistryNotFound = require_engine.RegistryNotFound;
168
168
  exports.RollbackFailed = require_deploy.RollbackFailed;
169
169
  exports.RollbackNeedsApp = require_rollback.RollbackNeedsApp;
170
- exports.SANDBOX_ENV_ALLOWLIST = require_local.SANDBOX_ENV_ALLOWLIST;
170
+ exports.SANDBOX_ENV_ALLOWLIST = require_credentials.SANDBOX_ENV_ALLOWLIST;
171
171
  exports.SECRETS_DIR_ENV = require_sandbox.SECRETS_DIR_ENV;
172
172
  exports.SandboxCwdEscape = require_sandbox.SandboxCwdEscape;
173
173
  exports.SandboxWorkerFailed = require_discover.SandboxWorkerFailed;
@@ -185,12 +185,12 @@ exports.TargetRuntimeMismatch = require_resolve.TargetRuntimeMismatch;
185
185
  exports.TargetRuntimeUndeclared = require_resolve.TargetRuntimeUndeclared;
186
186
  exports.UnknownDeployApps = require_deploy.UnknownDeployApps;
187
187
  exports.UnknownDeployTarget = require_define.UnknownDeployTarget;
188
- exports.allowlistedEnv = require_local.allowlistedEnv;
188
+ exports.allowlistedEnv = require_credentials.allowlistedEnv;
189
189
  exports.chainCredentials = require_credentials.chainCredentials;
190
190
  exports.confineCwd = require_sandbox.confineCwd;
191
191
  exports.deploy = require_deploy.deploy;
192
192
  exports.deployIdentity = require_state.deployIdentity;
193
- exports.gkmHome = require_local.gkmHome;
193
+ exports.gkmHome = require_run.gkmHome;
194
194
  exports.installDependencies = installDependencies;
195
195
  exports.rollbackStage = require_rollback.rollbackStage;
196
196
  exports.storedCredentials = require_credentials.storedCredentials;
@@ -1 +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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Q;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"}
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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C,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,cAAAA,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,YAAAA,cACT,SACA,MACA,OAAO,UACP,OAAO,MACR;CAEF;CACA,OAAO;AACR"}
@@ -1,17 +1,17 @@
1
- import { a as CommandTimedOut, i as CommandFailed, l as GKM_HOME_ENV, n as SANDBOX_ENV_ALLOWLIST, r as allowlistedEnv, t as LocalSandbox, u as gkmHome } from "../local-CWR4Y_kW.mjs";
2
- import { n as chainCredentials, r as storedCredentials, t as MissingCredential } from "../credentials-Dq1MnWQf.mjs";
1
+ import { n as CommandTimedOut, o as GKM_HOME_ENV, s as gkmHome, t as CommandFailed } from "../run-BJLIerMM.mjs";
2
+ import { a as SANDBOX_ENV_ALLOWLIST, i as LocalSandbox, n as chainCredentials, o as allowlistedEnv, r as storedCredentials, t as MissingCredential } from "../credentials-pAtB70k3.mjs";
3
3
  import { n as ConstructsNotSerializable, o as SandboxWorkerFailed, t as ConstructDiscoveryFailed } from "../discover-BFoJWKGD.mjs";
4
4
  import { n as SandboxCwdEscape, o as confineCwd, r as SecretNameInvalid, t as SECRETS_DIR_ENV } from "../sandbox-Dm247NGx.mjs";
5
5
  import { a as UnknownDeployTarget, i as DeployTargetNotYetSupported } from "../define-DR8xGYfL.mjs";
6
6
  import { ConfigLoadFailed, ConfigObjectNotSerializable } from "../config.mjs";
7
- import { b as detectPackageManager, yt as deployIdentity } from "../state-uuYqnRVO.mjs";
8
- import { a as DeploymentTimedOut, d as StateLocked, i as DeploymentFailed, m as StateVersionConflict } from "../sniffer-BAQhLEsI.mjs";
9
- import { i as TargetRuntimeMismatch, l as TargetPackageNotFound, n as TargetEntryInvalid, r as TargetPackageInvalid, s as TargetRuntimeUndeclared, t as InvalidTargetOptions } from "../resolve-Db0tNlrW.mjs";
10
- import { i as UnknownDeployApps, n as NoDeployableApps, r as RollbackFailed, t as deploy } from "../deploy-DWn7YfIc.mjs";
11
- import { _ as RegistryNotConfigured, g as RegistryAmbiguous, h as HealthCheckTimedOut, m as DeployMigrationsFailed, n as FrontendDeployFailed, r as MissingEnvVars, t as BackendDeployFailed, v as RegistryNotFound, y as ProjectNotOwned } from "../engine-CunvOG3s.mjs";
12
- import { i as rollbackStage, n as RollbackNeedsApp, r as StageNeverDeployed, t as NothingToRollBack } from "../rollback-DvAo4OKS.mjs";
7
+ import { Z as detectPackageManager, wt as deployIdentity } from "../state-DkUStoqJ.mjs";
8
+ import { a as DeploymentTimedOut, d as StateLocked, i as DeploymentFailed, m as StateVersionConflict } from "../sniffer-BdFeLSmA.mjs";
9
+ import { i as TargetRuntimeMismatch, l as TargetPackageNotFound, n as TargetEntryInvalid, r as TargetPackageInvalid, s as TargetRuntimeUndeclared, t as InvalidTargetOptions } from "../resolve-DhZgtvZe.mjs";
10
+ import { i as UnknownDeployApps, n as NoDeployableApps, r as RollbackFailed, t as deploy } from "../deploy-DRAwTG72.mjs";
11
+ import { _ as RegistryNotConfigured, g as RegistryAmbiguous, h as HealthCheckTimedOut, m as DeployMigrationsFailed, n as FrontendDeployFailed, r as MissingEnvVars, t as BackendDeployFailed, v as RegistryNotFound, y as ProjectNotOwned } from "../engine-Gs0abjuj.mjs";
12
+ import { i as rollbackStage, n as RollbackNeedsApp, r as StageNeverDeployed, t as NothingToRollBack } from "../rollback-m4Yeym5x.mjs";
13
13
  import { t as ProviderRemoved } from "../provider-q4lsYzYG.mjs";
14
- import { i as SurfacesUnhealthy, r as SstOutputsUnreadable, t as SstConfigNotFound } from "../sst-B2HbrDR3.mjs";
14
+ import { i as SurfacesUnhealthy, r as SstOutputsUnreadable, t as SstConfigNotFound } from "../sst-DRi3H5TB.mjs";
15
15
  import { join, resolve } from "node:path";
16
16
  import { existsSync } from "node:fs";
17
17
  //#region src/sandbox/install.ts
@@ -1,14 +1,14 @@
1
- const require_local = require("./local-BdH4XN0E.cjs");
2
- const require_credentials = require("./credentials-Bzbg23n8.cjs");
1
+ const require_run = require("./run-fVZ-rLnc.cjs");
2
+ const require_credentials = require("./credentials-BVs7mrtw.cjs");
3
3
  const require_discover = require("./discover-OEfZ9OkA.cjs");
4
4
  const require_sandbox = require("./sandbox-CL--ZDui.cjs");
5
5
  const require_derive = require("./derive-DAbo49sm.cjs");
6
6
  const require_define = require("./define-DzRz8FgH.cjs");
7
7
  const require_workspace = require("./workspace-ON-bqiJz.cjs");
8
8
  const require_config = require("./config.cjs");
9
- const require_state = require("./state-Y6ATakMX.cjs");
10
- const require_sniffer = require("./sniffer-5xmrkh2a.cjs");
11
- const require_resolve = require("./resolve-CVmch0wI.cjs");
9
+ const require_state = require("./state-DgmM4EKq.cjs");
10
+ const require_sniffer = require("./sniffer-D66HIvi9.cjs");
11
+ const require_resolve = require("./resolve-BexmDcsN.cjs");
12
12
  let node_path = require("node:path");
13
13
  //#region src/target/secrets.ts
14
14
  /**
@@ -430,9 +430,9 @@ function deploy(input) {
430
430
  };
431
431
  const ctx = {
432
432
  emit,
433
- credentials: input.credentials ?? require_credentials.storedCredentials({ home: input.home ?? require_local.gkmHome() }),
433
+ credentials: input.credentials ?? require_credentials.storedCredentials({ home: input.home ?? require_run.gkmHome() }),
434
434
  dryRun: input.dryRun ?? false,
435
- home: input.home ?? require_local.gkmHome(),
435
+ home: input.home ?? require_run.gkmHome(),
436
436
  redactor,
437
437
  ...input.signal ? { signal: input.signal } : {},
438
438
  ...input.childOutput ? { childOutput: input.childOutput } : {},
@@ -445,7 +445,7 @@ function deploy(input) {
445
445
  }), async () => {
446
446
  try {
447
447
  input.signal?.throwIfAborted();
448
- const sandbox = input.sandbox ?? new require_local.LocalSandbox({ root: require_config.findWorkspaceRoot((0, node_path.resolve)(input.cwd)) });
448
+ const sandbox = input.sandbox ?? new require_credentials.LocalSandbox({ root: require_config.findWorkspaceRoot((0, node_path.resolve)(input.cwd)) });
449
449
  const deployed = await require_sandbox.withSandbox(sandbox, () => runDeploy(() => load(input, sandbox), {
450
450
  stage: input.stage,
451
451
  ...input.target ? { target: input.target } : {},
@@ -508,4 +508,4 @@ Object.defineProperty(exports, "deploy", {
508
508
  }
509
509
  });
510
510
 
511
- //# sourceMappingURL=deploy-B7aJi_Ah.cjs.map
511
+ //# sourceMappingURL=deploy-BucRfbvX.cjs.map