@hype-stack/cli 1.4.0 → 1.4.1

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.
@@ -19,7 +19,7 @@ import { McpServer as ue } from "@modelcontextprotocol/sdk/server/mcp.js";
19
19
  import { StdioServerTransport as de } from "@modelcontextprotocol/sdk/server/stdio.js";
20
20
  import { Writable as fe } from "node:stream";
21
21
  //#region src/constants/constants.ts
22
- var pe = "1.4.0", me = "BetterTyped/hype-stack", he = "main", ge = `gh:${me}`, _e = "HYPE_STACK_TEMPLATE_REF", ve = "/cli/template-channel", ye = "stack.json", be = "/schema/stack.json", xe = "https://api.hype-stack.dev", Se = "HYPE_STACK_API_URL", Ce = "https://www.hype-stack.dev", we = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, Te = [
22
+ var pe = "1.4.1", me = "BetterTyped/hype-stack", he = "main", ge = `gh:${me}`, _e = "HYPE_STACK_TEMPLATE_REF", ve = "/cli/template-channel", ye = "stack.json", be = "/schema/stack.json", xe = "https://api.hype-stack.dev", Se = "HYPE_STACK_API_URL", Ce = "https://www.hype-stack.dev", we = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, Te = [
23
23
  {
24
24
  value: "cursor",
25
25
  label: "Cursor",
@@ -5377,7 +5377,7 @@ async function Bl() {
5377
5377
  ref: e,
5378
5378
  source: "env"
5379
5379
  };
5380
- if (Nl === "1.4.0") return {
5380
+ if (Nl === "1.4.1") return {
5381
5381
  ref: he,
5382
5382
  source: "dev"
5383
5383
  };
@@ -7116,7 +7116,18 @@ function _f(e) {
7116
7116
  }
7117
7117
  return null;
7118
7118
  }
7119
- var vf = {
7119
+ function vf(e) {
7120
+ let t = Q(e);
7121
+ if (!Array.isArray(t)) return [];
7122
+ let n = [];
7123
+ for (let e of t) {
7124
+ if (typeof e != "object" || !e) continue;
7125
+ let t = e.Name ?? e.name;
7126
+ typeof t == "string" && t.length > 0 && n.push(t);
7127
+ }
7128
+ return n;
7129
+ }
7130
+ var yf = {
7120
7131
  id: "fly",
7121
7132
  async checkAuth(e) {
7122
7133
  let t = await e.runner.run({
@@ -7178,11 +7189,26 @@ var vf = {
7178
7189
  return n.external ? {
7179
7190
  outputs: n.external,
7180
7191
  note: "using the external values from stack.json"
7181
- } : n.service === "postgres" ? yf(e, t) : n.service === "valkey" ? Cf(e, t) : Tf(e, t);
7192
+ } : n.service === "postgres" ? bf(e, t) : n.service === "valkey" ? wf(e, t) : Ef(e, t);
7193
+ },
7194
+ async existingEnvKeys(e, t) {
7195
+ let n = await e.runner.run({
7196
+ command: "fly",
7197
+ args: [
7198
+ "secrets",
7199
+ "list",
7200
+ "--app",
7201
+ t.app,
7202
+ "--json"
7203
+ ],
7204
+ cwd: e.cwd,
7205
+ allowFailure: !0,
7206
+ label: `read ${t.app} secrets`
7207
+ }).catch(() => null);
7208
+ return !n || n.exitCode !== 0 ? [] : vf(n.stdout);
7182
7209
  },
7183
7210
  async setEnv(e, t) {
7184
- let n = Object.entries(t.env);
7185
- n.length !== 0 && await e.runner.run({
7211
+ let n = new Set(t.blankKeys ?? []), r = Object.entries(t.env), i = r.filter(([e]) => !n.has(e)), a = r.filter(([e]) => n.has(e)), o = (n, r) => e.runner.run({
7186
7212
  command: "fly",
7187
7213
  args: [
7188
7214
  "secrets",
@@ -7194,8 +7220,10 @@ var vf = {
7194
7220
  cwd: e.cwd,
7195
7221
  stdin: `${n.map(([e, t]) => `${e}=${t}`).join("\n")}\n`,
7196
7222
  secrets: t.secrets,
7223
+ allowFailure: r,
7197
7224
  label: `set ${n.length} secrets on ${t.target.app}`
7198
7225
  });
7226
+ i.length > 0 && await o(i, !1), a.length > 0 && await o(a, !0);
7199
7227
  },
7200
7228
  async deployTarget(e, t) {
7201
7229
  let { target: n } = t, r = n.spec.serveMode === "static", i, a;
@@ -7256,10 +7284,10 @@ var vf = {
7256
7284
  };
7257
7285
  }
7258
7286
  };
7259
- async function yf(e, t) {
7260
- let { service: n, backend: r, crossProvider: i } = t, a = await bf(e, n.name), o = a ?? await xf(e, t);
7287
+ async function bf(e, t) {
7288
+ let { service: n, backend: r, crossProvider: i } = t, a = await xf(e, n.name), o = a ?? await Sf(e, t);
7261
7289
  if (i || !r) {
7262
- let t = await Sf(e, o);
7290
+ let t = await Cf(e, o);
7263
7291
  if (!t) throw Error(`The Fly Postgres cluster "${n.name}" exists, but Fly did not return its connection string. Run \`fly mpg status ${o.id} --json\` and set deploy.services.postgres.external.DATABASE_URL in stack.json.`);
7264
7292
  return {
7265
7293
  outputs: { DATABASE_URL: t },
@@ -7289,14 +7317,14 @@ async function yf(e, t) {
7289
7317
  providedByProvider: ["DATABASE_URL"],
7290
7318
  note: `already attached to ${r.app}`
7291
7319
  };
7292
- let c = await Sf(e, o);
7320
+ let c = await Cf(e, o);
7293
7321
  if (!c) throw Error(`Could not attach the Fly Postgres cluster "${n.name}" to ${r.app}, and could not read its connection string either:\n${s.stderr.trim() || s.stdout.trim()}`);
7294
7322
  return {
7295
7323
  outputs: { DATABASE_URL: c },
7296
7324
  note: "attach failed, wired the connection string instead"
7297
7325
  };
7298
7326
  }
7299
- async function bf(e, t) {
7327
+ async function xf(e, t) {
7300
7328
  let n = await e.runner.run({
7301
7329
  command: "fly",
7302
7330
  args: [
@@ -7311,7 +7339,7 @@ async function bf(e, t) {
7311
7339
  });
7312
7340
  return n.exitCode === 0 ? gf(n.stdout, t) : null;
7313
7341
  }
7314
- async function xf(e, t) {
7342
+ async function Sf(e, t) {
7315
7343
  let { service: n } = t, r = await e.runner.run({
7316
7344
  command: "fly",
7317
7345
  args: [
@@ -7335,11 +7363,11 @@ async function xf(e, t) {
7335
7363
  id: i,
7336
7364
  name: n.name
7337
7365
  };
7338
- let a = await bf(e, n.name);
7366
+ let a = await xf(e, n.name);
7339
7367
  if (a) return a;
7340
7368
  throw Error(`Fly reported that the Postgres cluster "${n.name}" was created, but it is not in \`fly mpg list\`. Check https://fly.io/dashboard and run deploy again.`);
7341
7369
  }
7342
- async function Sf(e, t) {
7370
+ async function Cf(e, t) {
7343
7371
  let n = await e.runner.run({
7344
7372
  command: "fly",
7345
7373
  args: [
@@ -7354,7 +7382,7 @@ async function Sf(e, t) {
7354
7382
  });
7355
7383
  return _f(n.stdout) ?? hf(n.stdout);
7356
7384
  }
7357
- async function Cf(e, t) {
7385
+ async function wf(e, t) {
7358
7386
  let { service: n } = t, r = await e.runner.run({
7359
7387
  command: "fly",
7360
7388
  args: [
@@ -7367,7 +7395,7 @@ async function Cf(e, t) {
7367
7395
  label: `look for an existing valkey ${n.name}`
7368
7396
  }), i = r.exitCode === 0 ? pf(r.stdout + r.stderr) : null;
7369
7397
  if (i) return {
7370
- outputs: wf(i),
7398
+ outputs: Tf(i),
7371
7399
  note: "reusing the existing database"
7372
7400
  };
7373
7401
  let a = await e.runner.run({
@@ -7389,16 +7417,16 @@ async function Cf(e, t) {
7389
7417
  label: `create valkey ${n.name}`
7390
7418
  }), o = pf(a.stdout + a.stderr);
7391
7419
  if (!o) throw Error(`Could not read the connection URL for the Fly Redis database "${n.name}":\n${a.stderr.trim() || a.stdout.trim()}\nRun \`fly redis status ${n.name}\` and set deploy.services.valkey.external.VALKEY_URL in stack.json.`);
7392
- return { outputs: wf(o) };
7420
+ return { outputs: Tf(o) };
7393
7421
  }
7394
- function wf(e) {
7422
+ function Tf(e) {
7395
7423
  let t = mf(e);
7396
7424
  return {
7397
7425
  VALKEY_URL: e,
7398
7426
  ...t ? { VALKEY_PASSWORD: t } : {}
7399
7427
  };
7400
7428
  }
7401
- async function Tf(e, t) {
7429
+ async function Ef(e, t) {
7402
7430
  let { service: n, backend: r, crossProvider: i } = t, a = n.name, o = await e.runner.run({
7403
7431
  command: "fly",
7404
7432
  args: [
@@ -7412,23 +7440,23 @@ async function Tf(e, t) {
7412
7440
  cwd: e.cwd,
7413
7441
  allowFailure: !0,
7414
7442
  label: `create tigris bucket ${a}`
7415
- }), s = kf(ff(o.stdout + o.stderr), a);
7443
+ }), s = Af(ff(o.stdout + o.stderr), a);
7416
7444
  if (s) return { outputs: s };
7417
7445
  if (!of.test(o.stderr + o.stdout)) throw Error(`Could not read the Tigris credentials for "${a}":\n${o.stderr.trim() || o.stdout.trim()}\nRun \`fly storage create --name ${a}\` yourself and copy the credentials into deploy.services.bucket.external in stack.json.`);
7418
- if (!i && r && await Of(e, r.app)) return {
7446
+ if (!i && r && await kf(e, r.app)) return {
7419
7447
  outputs: {},
7420
- providedByProvider: [...Ef],
7448
+ providedByProvider: [...Df],
7421
7449
  note: `already set on ${r.app} by an earlier deploy`
7422
7450
  };
7423
7451
  throw Error(`The Tigris bucket "${a}" already exists and Fly will not show its keys again, and ${r ? `${r.app} does not have them set` : "there is no Fly app here holding them"}. Copy them into deploy.services.bucket.external in stack.json, or pick a different name with deploy.services.bucket.name.`);
7424
7452
  }
7425
- var Ef = [
7453
+ var Df = [
7426
7454
  "RUSTFS_ENDPOINT",
7427
7455
  "RUSTFS_ACCESS_KEY",
7428
7456
  "RUSTFS_SECRET_KEY",
7429
7457
  "BUCKET_NAME"
7430
7458
  ];
7431
- function Df(e) {
7459
+ function Of(e) {
7432
7460
  let t = Q(e);
7433
7461
  return Array.isArray(t) ? t.flatMap((e) => {
7434
7462
  if (typeof e != "object" || !e) return [];
@@ -7436,7 +7464,7 @@ function Df(e) {
7436
7464
  return typeof n == "string" ? [n] : [];
7437
7465
  }) : [];
7438
7466
  }
7439
- async function Of(e, t) {
7467
+ async function kf(e, t) {
7440
7468
  let n = await e.runner.run({
7441
7469
  command: "fly",
7442
7470
  args: [
@@ -7451,10 +7479,10 @@ async function Of(e, t) {
7451
7479
  label: `check the storage keys already on ${t}`
7452
7480
  });
7453
7481
  if (n.exitCode !== 0) return !1;
7454
- let r = new Set(Df(n.stdout));
7455
- return Ef.every((e) => r.has(e));
7482
+ let r = new Set(Of(n.stdout));
7483
+ return Df.every((e) => r.has(e));
7456
7484
  }
7457
- function kf(e, t) {
7485
+ function Af(e, t) {
7458
7486
  let n = e.AWS_ACCESS_KEY_ID, r = e.AWS_SECRET_ACCESS_KEY;
7459
7487
  return !n || !r ? null : {
7460
7488
  RUSTFS_ENDPOINT: e.AWS_ENDPOINT_URL_S3 ?? "https://t3.storage.dev",
@@ -7465,32 +7493,32 @@ function kf(e, t) {
7465
7493
  }
7466
7494
  //#endregion
7467
7495
  //#region src/deploy/runner.ts
7468
- var Af = class extends Error {
7496
+ var jf = class extends Error {
7469
7497
  spec;
7470
7498
  result;
7471
7499
  constructor(e, t) {
7472
7500
  let n = (t.stderr.trim() || t.stdout.trim()).split("\n").slice(-8).join("\n");
7473
- super(`${jf(e)} exited with ${t.exitCode}${n ? `\n${n}` : ""}`), this.name = "CommandFailedError", this.spec = e, this.result = t;
7501
+ super(`${Mf(e)} exited with ${t.exitCode}${n ? `\n${n}` : ""}`), this.name = "CommandFailedError", this.spec = e, this.result = t;
7474
7502
  }
7475
7503
  };
7476
- function jf(e) {
7477
- let t = [e.command, ...e.args].map(Nf).join(" ");
7478
- return Mf(e.stdin === void 0 ? t : `${t} < (stdin)`, e.secrets ?? []);
7504
+ function Mf(e) {
7505
+ let t = [e.command, ...e.args].map(Pf).join(" ");
7506
+ return Nf(e.stdin === void 0 ? t : `${t} < (stdin)`, e.secrets ?? []);
7479
7507
  }
7480
- function Mf(e, t) {
7508
+ function Nf(e, t) {
7481
7509
  let n = e;
7482
7510
  for (let e of t) !e || e.length < 4 || (n = n.split(e).join("***"));
7483
7511
  return n;
7484
7512
  }
7485
- function Nf(e) {
7513
+ function Pf(e) {
7486
7514
  return e === "" ? "\"\"" : /[\s"'$`\\]/.test(e) ? `"${e.replace(/(["\\$`])/g, "\\$1")}"` : e;
7487
7515
  }
7488
- function Pf(e = {}) {
7516
+ function Ff(e = {}) {
7489
7517
  let t = [];
7490
7518
  return {
7491
7519
  transcript: t,
7492
7520
  async run(n) {
7493
- let r = jf(n);
7521
+ let r = Mf(n);
7494
7522
  t.push(r), e.onCommand?.(r);
7495
7523
  let i = e.env || n.env ? {
7496
7524
  ...e.env,
@@ -7499,20 +7527,20 @@ function Pf(e = {}) {
7499
7527
  cwd: n.cwd,
7500
7528
  stdin: n.stdin,
7501
7529
  env: i,
7502
- onData: e.onOutput ? (t) => e.onOutput?.(Mf(t, n.secrets ?? [])) : void 0
7530
+ onData: e.onOutput ? (t) => e.onOutput?.(Nf(t, n.secrets ?? [])) : void 0
7503
7531
  });
7504
- if (a.exitCode !== 0 && !n.allowFailure) throw new Af(n, a);
7532
+ if (a.exitCode !== 0 && !n.allowFailure) throw new jf(n, a);
7505
7533
  return a;
7506
7534
  }
7507
7535
  };
7508
7536
  }
7509
- function Ff(e = {}) {
7537
+ function If(e = {}) {
7510
7538
  let t = [];
7511
7539
  return {
7512
7540
  transcript: t,
7513
7541
  dryRun: !0,
7514
7542
  run(n) {
7515
- let r = jf(n);
7543
+ let r = Mf(n);
7516
7544
  t.push(r), e.onCommand?.(r);
7517
7545
  let i = e.responses?.find((e) => r.includes(e.match)), a = typeof i?.stdout == "function" ? i.stdout(n) : i?.stdout ?? "";
7518
7546
  return Promise.resolve({
@@ -7525,46 +7553,46 @@ function Ff(e = {}) {
7525
7553
  }
7526
7554
  //#endregion
7527
7555
  //#region src/deploy/providers/railway.ts
7528
- var If = "Postgres", Lf = "valkey/valkey:latest", Rf = 6379, zf = "/data", Bf = "/bin/sh -c \"exec docker-entrypoint.sh valkey-server --port ${VALKEY_PORT} --requirepass ${VALKEY_PASSWORD} --appendonly yes\"", Vf = 12e4, Hf = 3e3, Uf = 20 * 6e4, Wf = 1e4, Gf = new Set(["SUCCESS", "SLEEPING"]), Kf = new Set([
7556
+ var Lf = "Postgres", Rf = "valkey/valkey:latest", zf = 6379, Bf = "/data", Vf = "/bin/sh -c \"exec docker-entrypoint.sh valkey-server --port ${VALKEY_PORT} --requirepass ${VALKEY_PASSWORD} --appendonly yes\"", Hf = 12e4, Uf = 3e3, Wf = 20 * 6e4, Gf = 1e4, Kf = new Set(["SUCCESS", "SLEEPING"]), qf = new Set([
7529
7557
  "FAILED",
7530
7558
  "CRASHED",
7531
7559
  "REMOVED",
7532
7560
  "SKIPPED"
7533
- ]), qf = "query Deployments($input: DeploymentListInput!) { deployments(input: $input, first: 1) { edges { node { id status } } } }", Jf = "query BuildLogs($deploymentId: String!, $limit: Int) { buildLogs(deploymentId: $deploymentId, limit: $limit) { message } }", Yf = "query DeploymentLogs($deploymentId: String!, $limit: Int) { deploymentLogs(deploymentId: $deploymentId, limit: $limit) { message } }", Xf = [
7561
+ ]), Jf = "query Deployments($input: DeploymentListInput!) { deployments(input: $input, first: 1) { edges { node { id status } } } }", Yf = "query BuildLogs($deploymentId: String!, $limit: Int) { buildLogs(deploymentId: $deploymentId, limit: $limit) { message } }", Xf = "query DeploymentLogs($deploymentId: String!, $limit: Int) { deploymentLogs(deploymentId: $deploymentId, limit: $limit) { message } }", Zf = [
7534
7562
  "sjc",
7535
7563
  "iad",
7536
7564
  "ams",
7537
7565
  "sin"
7538
- ], Zf = "iad", Qf = "rustfs/rustfs:latest", $f = 9e3, ep = "/data", tp = /already exists|duplicate|is already/i, np = /unrecognized subcommand|unknown subcommand|unexpected argument|not a valid subcommand/i;
7539
- function rp(e) {
7566
+ ], Qf = "iad", $f = "rustfs/rustfs:latest", ep = 9e3, tp = "/data", np = /already exists|duplicate|is already/i, rp = /unrecognized subcommand|unknown subcommand|unexpected argument|not a valid subcommand/i;
7567
+ function ip(e) {
7540
7568
  let t = e.trim();
7541
7569
  if (t.startsWith("{") || t.startsWith("[")) {
7542
- let e = Q(t), n = e === null ? null : ap(e);
7543
- if (n) return ip(n);
7570
+ let e = Q(t), n = e === null ? null : op(e);
7571
+ if (n) return ap(n);
7544
7572
  }
7545
7573
  let n = t.match(/[a-z0-9-]+(?:\.[a-z0-9-]+)*\.(?:up\.railway\.app|railway\.app)/i);
7546
- return n ? ip(n[0]) : null;
7574
+ return n ? ap(n[0]) : null;
7547
7575
  }
7548
- function ip(e) {
7576
+ function ap(e) {
7549
7577
  return `https://${e.replace(/^https?:\/\//i, "").replace(/\/+$/, "")}`;
7550
7578
  }
7551
- function ap(e) {
7579
+ function op(e) {
7552
7580
  if (typeof e == "string") return /\.railway\.app/i.test(e) ? e : null;
7553
7581
  if (Array.isArray(e)) {
7554
7582
  for (let t of e) {
7555
- let e = ap(t);
7583
+ let e = op(t);
7556
7584
  if (e) return e;
7557
7585
  }
7558
7586
  return null;
7559
7587
  }
7560
7588
  if (typeof e == "object" && e) for (let [t, n] of Object.entries(e)) {
7561
7589
  if ((t === "domain" || t === "url" || t === "host") && typeof n == "string" && n.length > 0) return n;
7562
- let e = ap(n);
7590
+ let e = op(n);
7563
7591
  if (e) return e;
7564
7592
  }
7565
7593
  return null;
7566
7594
  }
7567
- function op(e) {
7595
+ function sp(e) {
7568
7596
  let t = Q(e.trim());
7569
7597
  if (!Array.isArray(t)) return [];
7570
7598
  let n = [];
@@ -7578,7 +7606,7 @@ function op(e) {
7578
7606
  }
7579
7607
  return n;
7580
7608
  }
7581
- function sp(e) {
7609
+ function cp(e) {
7582
7610
  let t = Q(e.trim());
7583
7611
  if (typeof t != "object" || !t || Array.isArray(t)) return null;
7584
7612
  let n = t, r = n.id;
@@ -7587,7 +7615,7 @@ function sp(e) {
7587
7615
  name: typeof n.name == "string" ? n.name : ""
7588
7616
  };
7589
7617
  }
7590
- function cp(e) {
7618
+ function lp(e) {
7591
7619
  let t = e.trim();
7592
7620
  if (t.startsWith("{")) {
7593
7621
  let e = Q(t);
@@ -7604,7 +7632,7 @@ function cp(e) {
7604
7632
  }
7605
7633
  return n;
7606
7634
  }
7607
- var lp = {
7635
+ var up = {
7608
7636
  id: "railway",
7609
7637
  async checkAuth(e) {
7610
7638
  let t = await e.runner.run({
@@ -7634,16 +7662,16 @@ var lp = {
7634
7662
  scope: {
7635
7663
  label: "workspace",
7636
7664
  flag: "--railway-workspace",
7637
- list: yp,
7665
+ list: bp,
7638
7666
  current: (e) => e.railway.workspace,
7639
7667
  pin: (e, t) => {
7640
7668
  e.railway.workspace = t;
7641
7669
  }
7642
7670
  },
7643
7671
  async reserveTarget(e, t) {
7644
- await gp(e);
7672
+ await _p(e);
7645
7673
  let n = t.spec.serveMode === "static" ? vd : t.spec.port ?? 3e3;
7646
- if (!await Sp(e, t.app)) {
7674
+ if (!await Cp(e, t.app)) {
7647
7675
  let r = await e.runner.run({
7648
7676
  command: "railway",
7649
7677
  args: [
@@ -7658,7 +7686,7 @@ var lp = {
7658
7686
  allowFailure: !0,
7659
7687
  label: `create railway service ${t.app}`
7660
7688
  });
7661
- if (r.exitCode !== 0 && !tp.test(r.stderr + r.stdout)) throw Error(`Could not create the Railway service "${t.app}":\n${r.stderr.trim() || r.stdout.trim()}`);
7689
+ if (r.exitCode !== 0 && !np.test(r.stderr + r.stdout)) throw Error(`Could not create the Railway service "${t.app}":\n${r.stderr.trim() || r.stdout.trim()}`);
7662
7690
  }
7663
7691
  if (t.url) return t.url;
7664
7692
  let r = await e.runner.run({
@@ -7674,7 +7702,7 @@ var lp = {
7674
7702
  cwd: e.cwd,
7675
7703
  allowFailure: !0,
7676
7704
  label: `generate domain for ${t.app}`
7677
- }), i = rp(r.stdout + r.stderr);
7705
+ }), i = ip(r.stdout + r.stderr);
7678
7706
  if (!i) throw Error(`Railway did not return a domain for "${t.app}". Run \`railway domain --service ${t.app}\` and set deploy.targets.${t.target}.url in stack.json.`);
7679
7707
  return i;
7680
7708
  },
@@ -7683,50 +7711,56 @@ var lp = {
7683
7711
  return n.external ? {
7684
7712
  outputs: n.external,
7685
7713
  note: "using the external values from stack.json"
7686
- } : (await gp(e), n.service === "postgres" ? Dp(e, t.crossProvider) : n.service === "valkey" ? jp(e, t) : qp(e, t));
7714
+ } : (await _p(e), n.service === "postgres" ? Op(e, t.crossProvider) : n.service === "valkey" ? Mp(e, t) : Jp(e, t));
7715
+ },
7716
+ async existingEnvKeys(e, t) {
7717
+ let n = await Ep(e, t.app);
7718
+ return Object.entries(n).filter(([, e]) => e.trim() !== "").map(([e]) => e);
7687
7719
  },
7688
7720
  async setEnv(e, t) {
7689
- for (let [n, r] of Object.entries(t.env)) await e.runner.run({
7721
+ let n = new Set(t.blankKeys ?? []);
7722
+ for (let [r, i] of Object.entries(t.env)) await e.runner.run({
7690
7723
  command: "railway",
7691
7724
  args: [
7692
7725
  "variable",
7693
7726
  "set",
7694
- n,
7727
+ r,
7695
7728
  "--stdin",
7696
7729
  "--service",
7697
7730
  t.target.app,
7698
7731
  "--skip-deploys"
7699
7732
  ],
7700
7733
  cwd: e.cwd,
7701
- stdin: r,
7734
+ stdin: i,
7702
7735
  secrets: t.secrets,
7703
- label: `set ${n} on ${t.target.app}`
7736
+ allowFailure: n.has(r),
7737
+ label: `set ${r} on ${t.target.app}`
7704
7738
  });
7705
7739
  },
7706
7740
  async deployTarget(e, t) {
7707
- return t.target.spec.serveMode === "static" ? up(e, t) : dp(e, t);
7741
+ return t.target.spec.serveMode === "static" ? dp(e, t) : fp(e, t);
7708
7742
  },
7709
7743
  async awaitTarget(e, t) {
7710
7744
  if (e.runner.dryRun) return {
7711
7745
  ok: !0,
7712
7746
  detail: "not checked on a dry run"
7713
7747
  };
7714
- let n = await xp(e, t.app);
7748
+ let n = await Sp(e, t.app);
7715
7749
  if (!n) return {
7716
7750
  ok: !0,
7717
7751
  detail: `could not find the service "${t.app}" to check on it, so look at the Railway dashboard`
7718
7752
  };
7719
- let r = await Rp(e, {
7753
+ let r = await zp(e, {
7720
7754
  name: t.app,
7721
7755
  serviceId: n.id,
7722
- timeoutMs: Uf,
7723
- pollIntervalMs: Wf
7756
+ timeoutMs: Wf,
7757
+ pollIntervalMs: Gf
7724
7758
  });
7725
7759
  if (r.ok) return {
7726
7760
  ok: !0,
7727
7761
  detail: r.status === null ? r.note : "live"
7728
7762
  };
7729
- let i = r.deploymentId && r.status ? await Bp(e, {
7763
+ let i = r.deploymentId && r.status ? await Vp(e, {
7730
7764
  id: r.deploymentId,
7731
7765
  status: r.status
7732
7766
  }) : null, a = r.note ?? `the deployment ${r.status === "CRASHED" ? "crashed after starting" : "failed"}`;
@@ -7759,7 +7793,7 @@ var lp = {
7759
7793
  };
7760
7794
  }
7761
7795
  };
7762
- async function up(e, t) {
7796
+ async function dp(e, t) {
7763
7797
  let { target: n } = t, r = await af(e, t), i = await Md({
7764
7798
  projectRoot: e.cwd,
7765
7799
  target: n,
@@ -7779,7 +7813,7 @@ async function up(e, t) {
7779
7813
  cwd: e.cwd,
7780
7814
  label: `point ${n.app} at the bundled Dockerfile`
7781
7815
  }), {
7782
- url: rp((await fp(e, t, [
7816
+ url: ip((await pp(e, t, [
7783
7817
  i,
7784
7818
  "--path-as-root",
7785
7819
  "--no-gitignore"
@@ -7787,7 +7821,7 @@ async function up(e, t) {
7787
7821
  releaseRan: !1
7788
7822
  };
7789
7823
  }
7790
- async function dp(e, t) {
7824
+ async function fp(e, t) {
7791
7825
  let { target: n } = t, r = await Nd(e.cwd, n);
7792
7826
  if (!r) throw Error(`Railway builds the ${n.spec.label} from a Dockerfile, but there is none at ${n.spec.defaultRoot}/Dockerfile. Add one and run deploy again.`);
7793
7827
  await e.runner.run({
@@ -7803,21 +7837,21 @@ async function dp(e, t) {
7803
7837
  cwd: e.cwd,
7804
7838
  label: `point ${n.app} at ${r}`
7805
7839
  });
7806
- let i = await mp(e, {
7840
+ let i = await hp(e, {
7807
7841
  dockerfile: r,
7808
7842
  target: n,
7809
7843
  releaseCommand: t.releaseCommand
7810
7844
  });
7811
7845
  try {
7812
7846
  return {
7813
- url: rp((await fp(e, t, [])).stdout) ?? n.url,
7847
+ url: ip((await pp(e, t, [])).stdout) ?? n.url,
7814
7848
  releaseRan: i.preDeployRan
7815
7849
  };
7816
7850
  } finally {
7817
7851
  i.written && await Ed(e.cwd);
7818
7852
  }
7819
7853
  }
7820
- async function fp(e, t, n) {
7854
+ async function pp(e, t, n) {
7821
7855
  let r = {
7822
7856
  command: "railway",
7823
7857
  args: [
@@ -7833,10 +7867,10 @@ async function fp(e, t, n) {
7833
7867
  label: `deploy ${t.target.target} to railway`
7834
7868
  }, i = await e.runner.run(r);
7835
7869
  if (i.exitCode === 0) return i;
7836
- let a = new Af(r, i), o = await pp(e, t.target, i.stdout + i.stderr);
7870
+ let a = new jf(r, i), o = await mp(e, t.target, i.stdout + i.stderr);
7837
7871
  throw o ? /* @__PURE__ */ Error(`${a.message}\n\n${o}`) : a;
7838
7872
  }
7839
- async function pp(e, t, n) {
7873
+ async function mp(e, t, n) {
7840
7874
  let r = n.match(/Could not load ([\w@./-]+)/)?.[1];
7841
7875
  if (!r) return null;
7842
7876
  let i = [
@@ -7863,7 +7897,7 @@ async function pp(e, t, n) {
7863
7897
  label: `check whether ${o} is gitignored`
7864
7898
  })).exitCode === 0 ? `${o} exists here but is in .gitignore, and \`railway up\` only uploads what git would track, so the build on Railway cannot see it. Take it out of .gitignore (moving any secrets in it into environment variables first) and deploy again.` : null;
7865
7899
  }
7866
- async function mp(e, t) {
7900
+ async function hp(e, t) {
7867
7901
  let { dockerfile: n, target: r, releaseCommand: i } = t;
7868
7902
  if (await wd(e.cwd)) return e.log?.(`Keeping your ${xd}, so ${r.app} uses the settings in it`), {
7869
7903
  written: !1,
@@ -7882,11 +7916,11 @@ async function mp(e, t) {
7882
7916
  preDeployRan: o
7883
7917
  });
7884
7918
  }
7885
- var hp = /* @__PURE__ */ new WeakSet();
7886
- async function gp(e) {
7887
- hp.has(e) || (await _p(e), hp.add(e));
7888
- }
7919
+ var gp = /* @__PURE__ */ new WeakSet();
7889
7920
  async function _p(e) {
7921
+ gp.has(e) || (await vp(e), gp.add(e));
7922
+ }
7923
+ async function vp(e) {
7890
7924
  if ((await e.runner.run({
7891
7925
  command: "railway",
7892
7926
  args: ["status", "--json"],
@@ -7894,7 +7928,7 @@ async function _p(e) {
7894
7928
  allowFailure: !0,
7895
7929
  label: "check railway project link"
7896
7930
  })).exitCode === 0) return;
7897
- let t = await bp(e);
7931
+ let t = await xp(e);
7898
7932
  await e.runner.run({
7899
7933
  command: "railway",
7900
7934
  args: [
@@ -7907,7 +7941,7 @@ async function _p(e) {
7907
7941
  label: `create railway project ${e.plan.projectName}`
7908
7942
  });
7909
7943
  }
7910
- function vp(e) {
7944
+ function yp(e) {
7911
7945
  let t = Q(e);
7912
7946
  if (typeof t != "object" || !t) return [];
7913
7947
  let n = t.workspaces;
@@ -7917,7 +7951,7 @@ function vp(e) {
7917
7951
  return typeof n == "string" ? [n] : [];
7918
7952
  }) : [];
7919
7953
  }
7920
- async function yp(e) {
7954
+ async function bp(e) {
7921
7955
  let t = await e.runner.run({
7922
7956
  command: "railway",
7923
7957
  args: ["whoami", "--json"],
@@ -7925,17 +7959,17 @@ async function yp(e) {
7925
7959
  allowFailure: !0,
7926
7960
  label: "find your Railway workspace"
7927
7961
  });
7928
- return t.exitCode === 0 ? vp(t.stdout) : [];
7962
+ return t.exitCode === 0 ? yp(t.stdout) : [];
7929
7963
  }
7930
- async function bp(e) {
7964
+ async function xp(e) {
7931
7965
  if (e.plan.railway.workspace) return e.plan.railway.workspace;
7932
- let t = await yp(e);
7966
+ let t = await bp(e);
7933
7967
  if (t.length !== 0) {
7934
7968
  if (t.length > 1) throw Error(`Your Railway account belongs to ${t.length} workspaces (${t.join(", ")}). Pass --railway-workspace <name> so the project is created in the right one.`);
7935
7969
  return e.plan.railway.workspace = t[0], t[0];
7936
7970
  }
7937
7971
  }
7938
- async function xp(e, t) {
7972
+ async function Sp(e, t) {
7939
7973
  let n = await e.runner.run({
7940
7974
  command: "railway",
7941
7975
  args: [
@@ -7947,18 +7981,18 @@ async function xp(e, t) {
7947
7981
  allowFailure: !0,
7948
7982
  label: "list railway services"
7949
7983
  });
7950
- return n.exitCode === 0 ? op(n.stdout).find((e) => e.name === t) ?? null : null;
7984
+ return n.exitCode === 0 ? sp(n.stdout).find((e) => e.name === t) ?? null : null;
7951
7985
  }
7952
- async function Sp(e, t) {
7953
- return await xp(e, t) !== null;
7986
+ async function Cp(e, t) {
7987
+ return await Sp(e, t) !== null;
7954
7988
  }
7955
- function Cp(e, t) {
7989
+ function wp(e, t) {
7956
7990
  return `\${{${/^[\w-]+$/.test(e) ? e : `"${e}"`}.${t}}}`;
7957
7991
  }
7958
- function wp(e) {
7959
- return `https://${Cp(e, "RAILWAY_PUBLIC_DOMAIN")}`;
7992
+ function Tp(e) {
7993
+ return `https://${wp(e, "RAILWAY_PUBLIC_DOMAIN")}`;
7960
7994
  }
7961
- async function Tp(e, t) {
7995
+ async function Ep(e, t) {
7962
7996
  let n = await e.runner.run({
7963
7997
  command: "railway",
7964
7998
  args: [
@@ -7972,9 +8006,9 @@ async function Tp(e, t) {
7972
8006
  allowFailure: !0,
7973
8007
  label: `read ${t} connection details`
7974
8008
  });
7975
- return n.exitCode === 0 ? cp(n.stdout) : {};
8009
+ return n.exitCode === 0 ? lp(n.stdout) : {};
7976
8010
  }
7977
- var Ep = {
8011
+ var Dp = {
7978
8012
  DATABASE_URL: "DATABASE_URL",
7979
8013
  POSTGRES_DB: "PGDATABASE",
7980
8014
  POSTGRES_HOST: "PGHOST",
@@ -7982,8 +8016,8 @@ var Ep = {
7982
8016
  POSTGRES_USER: "PGUSER",
7983
8017
  POSTGRES_PASSWORD: "PGPASSWORD"
7984
8018
  };
7985
- async function Dp(e, t) {
7986
- if (!await Sp(e, "Postgres")) {
8019
+ async function Op(e, t) {
8020
+ if (!await Cp(e, "Postgres")) {
7987
8021
  let t = await e.runner.run({
7988
8022
  command: "railway",
7989
8023
  args: [
@@ -7996,28 +8030,28 @@ async function Dp(e, t) {
7996
8030
  allowFailure: !0,
7997
8031
  label: "add railway postgres"
7998
8032
  });
7999
- if (t.exitCode !== 0 && !tp.test(t.stderr + t.stdout)) throw Error(`Could not add a Railway postgres database:\n${t.stderr.trim()}`);
8033
+ if (t.exitCode !== 0 && !np.test(t.stderr + t.stdout)) throw Error(`Could not add a Railway postgres database:\n${t.stderr.trim()}`);
8000
8034
  }
8001
8035
  if (!t) {
8002
8036
  let e = {};
8003
- for (let [t, n] of Object.entries(Ep)) e[t] = Cp(If, n);
8037
+ for (let [t, n] of Object.entries(Dp)) e[t] = wp(Lf, n);
8004
8038
  return {
8005
8039
  outputs: e,
8006
- note: `wired as Railway references to ${If}`
8040
+ note: `wired as Railway references to ${Lf}`
8007
8041
  };
8008
8042
  }
8009
- let n = await Tp(e, If), r = n.DATABASE_PUBLIC_URL ?? n.DATABASE_URL;
8010
- if (!r) throw Error(`Could not read DATABASE_PUBLIC_URL from the Railway ${If} service. Enable a public proxy on it, or set ${Ld("services", "postgres", "external")} in ${X}.`);
8043
+ let n = await Ep(e, Lf), r = n.DATABASE_PUBLIC_URL ?? n.DATABASE_URL;
8044
+ if (!r) throw Error(`Could not read DATABASE_PUBLIC_URL from the Railway ${Lf} service. Enable a public proxy on it, or set ${Ld("services", "postgres", "external")} in ${X}.`);
8011
8045
  return { outputs: {
8012
8046
  DATABASE_URL: r,
8013
- ...Op(r)
8047
+ ...kp(r)
8014
8048
  } };
8015
8049
  }
8016
- function Op(e) {
8017
- let t = kp(e);
8050
+ function kp(e) {
8051
+ let t = Ap(e);
8018
8052
  if (!t) return {};
8019
8053
  let n = decodeURIComponent(t.pathname.replace(/^\//, ""));
8020
- return Ap({
8054
+ return jp({
8021
8055
  POSTGRES_HOST: t.hostname,
8022
8056
  POSTGRES_PORT: t.port,
8023
8057
  POSTGRES_USER: decodeURIComponent(t.username),
@@ -8025,43 +8059,43 @@ function Op(e) {
8025
8059
  POSTGRES_DB: n
8026
8060
  });
8027
8061
  }
8028
- function kp(e) {
8062
+ function Ap(e) {
8029
8063
  try {
8030
8064
  return new URL(e);
8031
8065
  } catch {
8032
8066
  return null;
8033
8067
  }
8034
8068
  }
8035
- function Ap(e) {
8069
+ function jp(e) {
8036
8070
  return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== ""));
8037
8071
  }
8038
- async function jp(e, t) {
8039
- let n = t.service.name, r = await xp(e, n);
8040
- if (r || await Mp(e, n), !t.crossProvider) return {
8072
+ async function Mp(e, t) {
8073
+ let n = t.service.name, r = await Sp(e, n);
8074
+ if (r || await Np(e, n), !t.crossProvider) return {
8041
8075
  outputs: {
8042
- VALKEY_URL: Cp(n, "VALKEY_URL"),
8043
- VALKEY_PASSWORD: Cp(n, "VALKEY_PASSWORD")
8076
+ VALKEY_URL: wp(n, "VALKEY_URL"),
8077
+ VALKEY_PASSWORD: wp(n, "VALKEY_PASSWORD")
8044
8078
  },
8045
- note: r ? "reusing the Valkey service already in the project" : `${Lf} with a volume and a password`
8079
+ note: r ? "reusing the Valkey service already in the project" : `${Rf} with a volume and a password`
8046
8080
  };
8047
- let i = await Tp(e, n), a = i.VALKEY_PUBLIC_URL ?? i.VALKEY_URL;
8048
- if (!a) throw Error(`Could not read VALKEY_PUBLIC_URL from the Railway Valkey service "${n}". Run \`railway tcp-proxy create --port ${Rf} --service ${n}\`, or set ${Ld("services", "valkey", "external")} in ${X}.`);
8049
- return { outputs: Ap({
8081
+ let i = await Ep(e, n), a = i.VALKEY_PUBLIC_URL ?? i.VALKEY_URL;
8082
+ if (!a) throw Error(`Could not read VALKEY_PUBLIC_URL from the Railway Valkey service "${n}". Run \`railway tcp-proxy create --port ${zf} --service ${n}\`, or set ${Ld("services", "valkey", "external")} in ${X}.`);
8083
+ return { outputs: jp({
8050
8084
  VALKEY_URL: a,
8051
8085
  VALKEY_PASSWORD: i.VALKEY_PASSWORD ?? ""
8052
8086
  }) };
8053
8087
  }
8054
- async function Mp(e, t) {
8088
+ async function Np(e, t) {
8055
8089
  let n = D(24).toString("base64url"), r = await e.runner.run({
8056
8090
  command: "railway",
8057
8091
  args: [
8058
8092
  "add",
8059
8093
  "--image",
8060
- Lf,
8094
+ Rf,
8061
8095
  "--service",
8062
8096
  t,
8063
8097
  "--variables",
8064
- `VALKEY_PORT=${Rf}`,
8098
+ `VALKEY_PORT=${zf}`,
8065
8099
  "--variables",
8066
8100
  `VALKEY_PASSWORD=${n}`,
8067
8101
  "--variables",
@@ -8076,32 +8110,32 @@ async function Mp(e, t) {
8076
8110
  label: `create valkey service ${t}`
8077
8111
  });
8078
8112
  if (r.exitCode !== 0) throw Error(`Could not create the Railway Valkey service "${t}":\n${r.stderr.trim()}`);
8079
- let i = sp(r.stdout)?.id;
8113
+ let i = cp(r.stdout)?.id;
8080
8114
  if (!i) throw Error(`Railway created the Valkey service "${t}" but did not report its id, which is needed to mount its volume and set its start command. Run \`railway service list --json\`, finish it from the dashboard, or set ${Ld("services", "valkey", "external")} in ${X}.`);
8081
- await Vp(e, {
8115
+ await Hp(e, {
8082
8116
  name: t,
8083
8117
  serviceId: i,
8084
- command: Bf
8085
- }), await em(e, {
8118
+ command: Vf
8119
+ }), await tm(e, {
8086
8120
  name: t,
8087
8121
  serviceId: i,
8088
- mountPath: zf,
8122
+ mountPath: Bf,
8089
8123
  consequence: "everything cached in it would be lost on the next restart"
8090
- }), await Gp(e, {
8124
+ }), await Kp(e, {
8091
8125
  name: t,
8092
- port: Rf
8093
- }), await Np(e, {
8126
+ port: zf
8127
+ }), await Pp(e, {
8094
8128
  name: t,
8095
8129
  serviceId: i
8096
8130
  }), e.log?.(`Waiting for ${t} to come up`);
8097
- let a = await Rp(e, {
8131
+ let a = await zp(e, {
8098
8132
  name: t,
8099
8133
  serviceId: i,
8100
- timeoutMs: Vf,
8101
- pollIntervalMs: Hf
8134
+ timeoutMs: Hf,
8135
+ pollIntervalMs: Uf
8102
8136
  });
8103
8137
  if (!a.ok) {
8104
- let n = a.deploymentId && a.status ? await Bp(e, {
8138
+ let n = a.deploymentId && a.status ? await Vp(e, {
8105
8139
  id: a.deploymentId,
8106
8140
  status: a.status
8107
8141
  }) : null;
@@ -8112,8 +8146,8 @@ async function Mp(e, t) {
8112
8146
  ].filter(Boolean).join("\n"));
8113
8147
  }
8114
8148
  }
8115
- async function Np(e, t) {
8116
- let n = await Up(e), r = await e.runner.run({
8149
+ async function Pp(e, t) {
8150
+ let n = await Wp(e), r = await e.runner.run({
8117
8151
  command: "railway",
8118
8152
  args: [
8119
8153
  "api",
@@ -8131,14 +8165,14 @@ async function Np(e, t) {
8131
8165
  });
8132
8166
  if (r.exitCode !== 0) throw Error(`The Railway service "${t.name}" is configured but its first deployment could not be started, so nothing is running yet:\n${r.stderr.trim() || r.stdout.trim()}\nDeploy it from the Railway dashboard and run deploy again.`);
8133
8167
  }
8134
- function Pp(e) {
8168
+ function Fp(e) {
8135
8169
  let t = Q(e.trim());
8136
- return t === null ? null : Fp(t);
8170
+ return t === null ? null : Ip(t);
8137
8171
  }
8138
- function Fp(e) {
8172
+ function Ip(e) {
8139
8173
  if (Array.isArray(e)) {
8140
8174
  for (let t of e) {
8141
- let e = Fp(t);
8175
+ let e = Ip(t);
8142
8176
  if (e) return e;
8143
8177
  }
8144
8178
  return null;
@@ -8150,35 +8184,35 @@ function Fp(e) {
8150
8184
  status: r
8151
8185
  };
8152
8186
  for (let e of Object.values(t)) {
8153
- let t = Fp(e);
8187
+ let t = Ip(e);
8154
8188
  if (t) return t;
8155
8189
  }
8156
8190
  }
8157
8191
  return null;
8158
8192
  }
8159
- function Ip(e) {
8193
+ function Lp(e) {
8160
8194
  let t = [];
8161
- return Lp(Q(e.trim()), t), t;
8195
+ return Rp(Q(e.trim()), t), t;
8162
8196
  }
8163
- function Lp(e, t) {
8197
+ function Rp(e, t) {
8164
8198
  if (Array.isArray(e)) {
8165
- for (let n of e) Lp(n, t);
8199
+ for (let n of e) Rp(n, t);
8166
8200
  return;
8167
8201
  }
8168
8202
  if (typeof e == "object" && e) {
8169
8203
  let n = e;
8170
8204
  typeof n.message == "string" && n.message.length > 0 && t.push(n.message);
8171
- for (let [e, r] of Object.entries(n)) e !== "message" && Lp(r, t);
8205
+ for (let [e, r] of Object.entries(n)) e !== "message" && Rp(r, t);
8172
8206
  }
8173
8207
  }
8174
- async function Rp(e, t) {
8175
- let n = await Up(e), r = Date.now() + t.timeoutMs;
8208
+ async function zp(e, t) {
8209
+ let n = await Wp(e), r = Date.now() + t.timeoutMs;
8176
8210
  for (;;) {
8177
8211
  let i = await e.runner.run({
8178
8212
  command: "railway",
8179
8213
  args: [
8180
8214
  "api",
8181
- qf,
8215
+ Jf,
8182
8216
  "--variables",
8183
8217
  JSON.stringify({ input: {
8184
8218
  serviceId: t.serviceId,
@@ -8194,18 +8228,18 @@ async function Rp(e, t) {
8194
8228
  ok: !0,
8195
8229
  status: null
8196
8230
  };
8197
- let a = i.exitCode === 0 ? Pp(i.stdout) : null;
8231
+ let a = i.exitCode === 0 ? Fp(i.stdout) : null;
8198
8232
  if (!a) return {
8199
8233
  ok: !0,
8200
8234
  status: null,
8201
8235
  note: `could not read the deployment status of ${t.name}, so check it in the Railway dashboard`
8202
8236
  };
8203
- if (Gf.has(a.status)) return {
8237
+ if (Kf.has(a.status)) return {
8204
8238
  ok: !0,
8205
8239
  status: a.status,
8206
8240
  deploymentId: a.id
8207
8241
  };
8208
- if (Kf.has(a.status)) return {
8242
+ if (qf.has(a.status)) return {
8209
8243
  ok: !1,
8210
8244
  status: a.status,
8211
8245
  deploymentId: a.id
@@ -8216,14 +8250,14 @@ async function Rp(e, t) {
8216
8250
  deploymentId: a.id,
8217
8251
  note: `still ${a.status.toLowerCase()} after ${Math.round(t.timeoutMs / 6e4)} minutes`
8218
8252
  };
8219
- e.log?.(`${t.name} is ${a.status.toLowerCase()}`), await zp(t.pollIntervalMs);
8253
+ e.log?.(`${t.name} is ${a.status.toLowerCase()}`), await Bp(t.pollIntervalMs);
8220
8254
  }
8221
8255
  }
8222
- function zp(e) {
8256
+ function Bp(e) {
8223
8257
  return new Promise((t) => setTimeout(t, e));
8224
8258
  }
8225
- async function Bp(e, t) {
8226
- let n = t.status === "CRASHED" ? Yf : Jf, r = await e.runner.run({
8259
+ async function Vp(e, t) {
8260
+ let n = t.status === "CRASHED" ? Xf : Yf, r = await e.runner.run({
8227
8261
  command: "railway",
8228
8262
  args: [
8229
8263
  "api",
@@ -8240,11 +8274,11 @@ async function Bp(e, t) {
8240
8274
  label: "read the failed deployment's logs"
8241
8275
  });
8242
8276
  if (r.exitCode !== 0) return null;
8243
- let i = Ip(r.stdout);
8277
+ let i = Lp(r.stdout);
8244
8278
  return i.length === 0 ? null : i.slice(-15).join("\n");
8245
8279
  }
8246
- async function Vp(e, t) {
8247
- let n = await Up(e), r = await e.runner.run({
8280
+ async function Hp(e, t) {
8281
+ let n = await Wp(e), r = await e.runner.run({
8248
8282
  command: "railway",
8249
8283
  args: [
8250
8284
  "api",
@@ -8262,15 +8296,15 @@ async function Vp(e, t) {
8262
8296
  label: `set the start command on ${t.name}`
8263
8297
  });
8264
8298
  if (r.exitCode !== 0) {
8265
- let e = r.stderr.trim() || r.stdout.trim(), n = np.test(e) ? "Your Railway CLI is too old for `railway api`. Update it with `npm i -g @railway/cli` and run deploy again." : `Set the start command on ${t.name} from the Railway dashboard: ${t.command}`;
8299
+ let e = r.stderr.trim() || r.stdout.trim(), n = rp.test(e) ? "Your Railway CLI is too old for `railway api`. Update it with `npm i -g @railway/cli` and run deploy again." : `Set the start command on ${t.name} from the Railway dashboard: ${t.command}`;
8266
8300
  throw Error(`Could not set the start command on the Railway service "${t.name}":\n${e}\n${n}`);
8267
8301
  }
8268
8302
  }
8269
- var Hp = /* @__PURE__ */ new WeakMap();
8270
- async function Up(e) {
8271
- let t = Hp.get(e);
8303
+ var Up = /* @__PURE__ */ new WeakMap();
8304
+ async function Wp(e) {
8305
+ let t = Up.get(e);
8272
8306
  if (t) return t;
8273
- let n = Wp((await e.runner.run({
8307
+ let n = Gp((await e.runner.run({
8274
8308
  command: "railway",
8275
8309
  args: ["status", "--json"],
8276
8310
  cwd: e.cwd,
@@ -8278,9 +8312,9 @@ async function Up(e) {
8278
8312
  label: "read the linked railway environment"
8279
8313
  })).stdout, e.plan.environment);
8280
8314
  if (!n) throw Error(`Could not find the Railway environment "${e.plan.environment}" in the linked project. Run \`railway status\` to check what is linked.`);
8281
- return Hp.set(e, n), n;
8315
+ return Up.set(e, n), n;
8282
8316
  }
8283
- function Wp(e, t) {
8317
+ function Gp(e, t) {
8284
8318
  let n = Q(e.trim());
8285
8319
  if (typeof n != "object" || !n) return null;
8286
8320
  let r = n.environments, i = typeof r == "object" && r ? r.edges : void 0;
@@ -8299,7 +8333,7 @@ function Wp(e, t) {
8299
8333
  let o = a.find((e) => e.name === t);
8300
8334
  return o ? o.id : a.length === 1 ? a[0].id : null;
8301
8335
  }
8302
- async function Gp(e, t) {
8336
+ async function Kp(e, t) {
8303
8337
  let n = await e.runner.run({
8304
8338
  command: "railway",
8305
8339
  args: [
@@ -8315,15 +8349,15 @@ async function Gp(e, t) {
8315
8349
  allowFailure: !0,
8316
8350
  label: `expose ${t.name} on a tcp proxy`
8317
8351
  });
8318
- n.exitCode !== 0 && !tp.test(n.stderr + n.stdout) && e.log?.(`Could not open a TCP proxy on ${t.name}, so it is only reachable from inside the Railway project: ${n.stderr.trim() || n.stdout.trim()}`);
8352
+ n.exitCode !== 0 && !np.test(n.stderr + n.stdout) && e.log?.(`Could not open a TCP proxy on ${t.name}, so it is only reachable from inside the Railway project: ${n.stderr.trim() || n.stdout.trim()}`);
8319
8353
  }
8320
- var Kp = {
8354
+ var qp = {
8321
8355
  RUSTFS_ENDPOINT: "ENDPOINT",
8322
8356
  RUSTFS_ACCESS_KEY: "ACCESS_KEY_ID",
8323
8357
  RUSTFS_SECRET_KEY: "SECRET_ACCESS_KEY",
8324
8358
  BUCKET_NAME: "BUCKET"
8325
8359
  };
8326
- async function qp(e, t) {
8360
+ async function Jp(e, t) {
8327
8361
  let { service: n, crossProvider: r } = t, i = n.name, a = await e.runner.run({
8328
8362
  command: "railway",
8329
8363
  args: [
@@ -8336,14 +8370,14 @@ async function qp(e, t) {
8336
8370
  label: "list railway buckets"
8337
8371
  });
8338
8372
  if (a.exitCode !== 0) {
8339
- if (!np.test(a.stderr + a.stdout)) throw Error(`Could not list the Railway buckets in this project:\n${a.stderr.trim()}`);
8340
- return e.log?.("This Railway CLI has no `bucket` command, so storage runs as a RustFS service instead"), $p(e, n);
8373
+ if (!rp.test(a.stderr + a.stdout)) throw Error(`Could not list the Railway buckets in this project:\n${a.stderr.trim()}`);
8374
+ return e.log?.("This Railway CLI has no `bucket` command, so storage runs as a RustFS service instead"), em(e, n);
8341
8375
  }
8342
- Xp(a.stdout).some((e) => e.name === i) || await Jp(e, n);
8343
- let o = await xp(e, i) !== null;
8376
+ Zp(a.stdout).some((e) => e.name === i) || await Yp(e, n);
8377
+ let o = await Sp(e, i) !== null;
8344
8378
  if (!r && !o) {
8345
8379
  let e = {};
8346
- for (let [t, n] of Object.entries(Kp)) e[t] = Cp(i, n);
8380
+ for (let [t, n] of Object.entries(qp)) e[t] = wp(i, n);
8347
8381
  return {
8348
8382
  outputs: e,
8349
8383
  note: `wired as Railway references to the ${i} bucket`
@@ -8361,14 +8395,14 @@ async function qp(e, t) {
8361
8395
  cwd: e.cwd,
8362
8396
  allowFailure: !0,
8363
8397
  label: `read the ${i} bucket credentials`
8364
- }), c = Qp(s.stdout);
8398
+ }), c = $p(s.stdout);
8365
8399
  if (!c) throw Error(`Could not read the credentials for the Railway bucket "${i}":\n${s.stderr.trim() || s.stdout.trim()}\nRun \`railway bucket credentials --bucket ${i}\` and set ${Ld("services", "bucket", "external")} in ${X}.`);
8366
8400
  return {
8367
8401
  outputs: c,
8368
8402
  note: o ? `set as values, because the service "${i}" shares the bucket's name. Delete it with \`railway service delete --service ${i}\` to switch to references` : "read from the bucket, since a Railway reference does not resolve off Railway"
8369
8403
  };
8370
8404
  }
8371
- async function Jp(e, t) {
8405
+ async function Yp(e, t) {
8372
8406
  let n = await e.runner.run({
8373
8407
  command: "railway",
8374
8408
  args: [
@@ -8376,20 +8410,20 @@ async function Jp(e, t) {
8376
8410
  "create",
8377
8411
  t.name,
8378
8412
  "--region",
8379
- Yp(t.region),
8413
+ Xp(t.region),
8380
8414
  "--json"
8381
8415
  ],
8382
8416
  cwd: e.cwd,
8383
8417
  allowFailure: !0,
8384
8418
  label: `create the ${t.name} bucket`
8385
8419
  });
8386
- if (n.exitCode !== 0 && !tp.test(n.stderr + n.stdout)) throw Error(`Could not create the Railway bucket "${t.name}":\n${n.stderr.trim()}`);
8387
- if (Zp(n.stdout)) throw Error(`The Railway bucket "${t.name}" was created but staged rather than deployed, because the environment has uncommitted changes. Commit them in the Railway dashboard and run deploy again.`);
8388
- }
8389
- function Yp(e) {
8390
- return e && Xf.includes(e) ? e : Zf;
8420
+ if (n.exitCode !== 0 && !np.test(n.stderr + n.stdout)) throw Error(`Could not create the Railway bucket "${t.name}":\n${n.stderr.trim()}`);
8421
+ if (Qp(n.stdout)) throw Error(`The Railway bucket "${t.name}" was created but staged rather than deployed, because the environment has uncommitted changes. Commit them in the Railway dashboard and run deploy again.`);
8391
8422
  }
8392
8423
  function Xp(e) {
8424
+ return e && Zf.includes(e) ? e : Qf;
8425
+ }
8426
+ function Zp(e) {
8393
8427
  let t = Q(e.trim());
8394
8428
  if (!Array.isArray(t)) return [];
8395
8429
  let n = [];
@@ -8403,11 +8437,11 @@ function Xp(e) {
8403
8437
  }
8404
8438
  return n;
8405
8439
  }
8406
- function Zp(e) {
8440
+ function Qp(e) {
8407
8441
  let t = Q(e.trim());
8408
8442
  return typeof t != "object" || !t ? !1 : t.staged === !0;
8409
8443
  }
8410
- function Qp(e) {
8444
+ function $p(e) {
8411
8445
  let t = Q(e.trim());
8412
8446
  if (typeof t != "object" || !t) return null;
8413
8447
  let n = t, r = (e) => typeof n[e] == "string" ? n[e] : "", i = r("endpoint"), a = r("accessKeyId"), o = r("secretAccessKey");
@@ -8418,15 +8452,15 @@ function Qp(e) {
8418
8452
  BUCKET_NAME: r("bucketName")
8419
8453
  };
8420
8454
  }
8421
- async function $p(e, t) {
8422
- let n = t.name, r = await xp(e, n), i = r ? await tm(e, n) : null, a = i?.accessKey ?? `hs${D(8).toString("hex")}`, o = i?.secretKey ?? D(24).toString("base64url"), s = r?.id;
8455
+ async function em(e, t) {
8456
+ let n = t.name, r = await Sp(e, n), i = r ? await nm(e, n) : null, a = i?.accessKey ?? `hs${D(8).toString("hex")}`, o = i?.secretKey ?? D(24).toString("base64url"), s = r?.id;
8423
8457
  if (!i) {
8424
8458
  let t = await e.runner.run({
8425
8459
  command: "railway",
8426
8460
  args: [
8427
8461
  "add",
8428
8462
  "--image",
8429
- Qf,
8463
+ $f,
8430
8464
  "--service",
8431
8465
  n,
8432
8466
  "--variables",
@@ -8434,7 +8468,7 @@ async function $p(e, t) {
8434
8468
  "--variables",
8435
8469
  `RUSTFS_SECRET_KEY=${o}`,
8436
8470
  "--variables",
8437
- `RUSTFS_ADDRESS=:${$f}`,
8471
+ `RUSTFS_ADDRESS=:${ep}`,
8438
8472
  "--json"
8439
8473
  ],
8440
8474
  cwd: e.cwd,
@@ -8442,14 +8476,14 @@ async function $p(e, t) {
8442
8476
  secrets: [o],
8443
8477
  label: `create object storage service ${n}`
8444
8478
  });
8445
- if (t.exitCode !== 0) throw tp.test(t.stderr + t.stdout) ? Error(`The Railway storage service "${n}" already exists, but its access keys could not be read back. Copy them from the dashboard into ${Ld("services", "bucket", "external")} in ${X}.`) : Error(`Could not create the Railway storage service "${n}":\n${t.stderr.trim()}`);
8446
- s = sp(t.stdout)?.id ?? s;
8479
+ if (t.exitCode !== 0) throw np.test(t.stderr + t.stdout) ? Error(`The Railway storage service "${n}" already exists, but its access keys could not be read back. Copy them from the dashboard into ${Ld("services", "bucket", "external")} in ${X}.`) : Error(`Could not create the Railway storage service "${n}":\n${t.stderr.trim()}`);
8480
+ s = cp(t.stdout)?.id ?? s;
8447
8481
  }
8448
8482
  if (!s) throw Error(`Could not find the id of the Railway storage service "${n}", which is what \`railway volume\` needs to mount a volume on it. Run \`railway service list --json\` to check the project, or set ${Ld("services", "bucket", "external")} in ${X} to use storage you run yourself.`);
8449
- await em(e, {
8483
+ await tm(e, {
8450
8484
  name: n,
8451
8485
  serviceId: s,
8452
- mountPath: ep,
8486
+ mountPath: tp,
8453
8487
  consequence: "anything uploaded to it would be lost on the next restart"
8454
8488
  });
8455
8489
  let c = await e.runner.run({
@@ -8459,14 +8493,14 @@ async function $p(e, t) {
8459
8493
  "--service",
8460
8494
  n,
8461
8495
  "--port",
8462
- String($f),
8496
+ String(ep),
8463
8497
  "--json"
8464
8498
  ],
8465
8499
  cwd: e.cwd,
8466
8500
  allowFailure: !0,
8467
8501
  label: `expose ${n}`
8468
- }), l = rp(c.stdout + c.stderr);
8469
- if (!l) throw Error(`Could not get a public endpoint for the Railway storage service "${n}". Run \`railway domain --service ${n} --port ${$f}\` and set ${Ld("services", "bucket", "external")} in ${X}.`);
8502
+ }), l = ip(c.stdout + c.stderr);
8503
+ if (!l) throw Error(`Could not get a public endpoint for the Railway storage service "${n}". Run \`railway domain --service ${n} --port ${ep}\` and set ${Ld("services", "bucket", "external")} in ${X}.`);
8470
8504
  return {
8471
8505
  outputs: {
8472
8506
  RUSTFS_ENDPOINT: l,
@@ -8474,10 +8508,10 @@ async function $p(e, t) {
8474
8508
  RUSTFS_SECRET_KEY: o,
8475
8509
  BUCKET_NAME: n
8476
8510
  },
8477
- note: i ? "reusing the existing RustFS service and its keys" : `RustFS on Railway, with a volume mounted at ${ep}`
8511
+ note: i ? "reusing the existing RustFS service and its keys" : `RustFS on Railway, with a volume mounted at ${tp}`
8478
8512
  };
8479
8513
  }
8480
- async function em(e, t) {
8514
+ async function tm(e, t) {
8481
8515
  let n = await e.runner.run({
8482
8516
  command: "railway",
8483
8517
  args: [
@@ -8493,10 +8527,10 @@ async function em(e, t) {
8493
8527
  allowFailure: !0,
8494
8528
  label: `attach a volume to ${t.name}`
8495
8529
  });
8496
- if (n.exitCode !== 0 && !tp.test(n.stderr + n.stdout)) throw Error(`The Railway service "${t.name}" has no persistent volume at ${t.mountPath}, so ${t.consequence}:\n${n.stderr.trim() || n.stdout.trim()}`);
8530
+ if (n.exitCode !== 0 && !np.test(n.stderr + n.stdout)) throw Error(`The Railway service "${t.name}" has no persistent volume at ${t.mountPath}, so ${t.consequence}:\n${n.stderr.trim() || n.stdout.trim()}`);
8497
8531
  }
8498
- async function tm(e, t) {
8499
- let n = await Tp(e, t), r = n.RUSTFS_ACCESS_KEY, i = n.RUSTFS_SECRET_KEY;
8532
+ async function nm(e, t) {
8533
+ let n = await Ep(e, t), r = n.RUSTFS_ACCESS_KEY, i = n.RUSTFS_SECRET_KEY;
8500
8534
  return r && i ? {
8501
8535
  accessKey: r,
8502
8536
  secretKey: i
@@ -8504,32 +8538,32 @@ async function tm(e, t) {
8504
8538
  }
8505
8539
  //#endregion
8506
8540
  //#region src/deploy/providers/index.ts
8507
- var nm = {
8508
- railway: lp,
8509
- fly: vf
8541
+ var rm = {
8542
+ railway: up,
8543
+ fly: yf
8510
8544
  };
8511
- function rm(e) {
8512
- return nm[e];
8545
+ function im(e) {
8546
+ return rm[e];
8513
8547
  }
8514
8548
  //#endregion
8515
8549
  //#region src/deploy/tools.ts
8516
- var im = "@railway/cli@5", am = "https://api.github.com/repos/superfly/flyctl/releases/latest";
8517
- function om() {
8550
+ var am = "@railway/cli@5", om = "https://api.github.com/repos/superfly/flyctl/releases/latest";
8551
+ function sm() {
8518
8552
  return T.join(w.homedir(), ".hype-stack", "tools");
8519
8553
  }
8520
- function sm(e) {
8554
+ function cm(e) {
8521
8555
  return T.join(e, "railway", "node_modules", ".bin");
8522
8556
  }
8523
- function cm(e) {
8557
+ function lm(e) {
8524
8558
  return T.join(e, "fly", "bin");
8525
8559
  }
8526
- function lm(e, t, n) {
8560
+ function um(e, t, n) {
8527
8561
  return [e, ...(t ?? "").split(n).filter((t) => t.length > 0 && t !== e)].join(n);
8528
8562
  }
8529
- function um(e) {
8530
- process.env.PATH = lm(e, process.env.PATH, T.delimiter);
8531
- }
8532
8563
  function dm(e) {
8564
+ process.env.PATH = um(e, process.env.PATH, T.delimiter);
8565
+ }
8566
+ function fm(e) {
8533
8567
  let t;
8534
8568
  try {
8535
8569
  t = JSON.parse(e);
@@ -8540,7 +8574,7 @@ function dm(e) {
8540
8574
  let n = t.tag_name;
8541
8575
  return typeof n == "string" && n.length > 0 ? n : null;
8542
8576
  }
8543
- function fm(e, t, n) {
8577
+ function pm(e, t, n) {
8544
8578
  let r = {
8545
8579
  darwin: "macOS",
8546
8580
  linux: "Linux",
@@ -8551,39 +8585,39 @@ function fm(e, t, n) {
8551
8585
  }[t];
8552
8586
  return !r || !i ? null : `flyctl_${n.replace(/^v/, "")}_${r}_${i}.${e === "win32" ? "zip" : "tar.gz"}`;
8553
8587
  }
8554
- function pm(e) {
8588
+ function mm(e) {
8555
8589
  return process.platform === "win32" ? `${e}.exe` : e;
8556
8590
  }
8557
- function mm() {
8591
+ function hm() {
8558
8592
  return process.platform === "win32" ? "npm.cmd" : "npm";
8559
8593
  }
8560
- async function hm(e) {
8561
- let t = sm(e);
8594
+ async function gm(e) {
8595
+ let t = cm(e);
8562
8596
  return le(T.join(t, "railway")) || le(T.join(t, "railway.cmd"));
8563
8597
  }
8564
- async function gm(e) {
8565
- if (await hm(e)) return sm(e);
8598
+ async function _m(e) {
8599
+ if (await gm(e)) return cm(e);
8566
8600
  let t = T.join(e, "railway");
8567
8601
  await C.mkdir(t, { recursive: !0 });
8568
- let n = await U(mm(), [
8602
+ let n = await U(hm(), [
8569
8603
  "install",
8570
- im,
8604
+ am,
8571
8605
  "--prefix",
8572
8606
  t,
8573
8607
  "--no-fund",
8574
8608
  "--no-audit",
8575
8609
  "--loglevel=error"
8576
8610
  ], { cwd: e }).catch(() => null);
8577
- return !n || n.exitCode !== 0 ? null : await hm(e) ? sm(e) : null;
8611
+ return !n || n.exitCode !== 0 ? null : await gm(e) ? cm(e) : null;
8578
8612
  }
8579
- async function _m(e) {
8580
- let t = cm(e), n = T.join(t, pm("fly"));
8613
+ async function vm(e) {
8614
+ let t = lm(e), n = T.join(t, mm("fly"));
8581
8615
  if (le(n)) return t;
8582
- let r = await fetch(am, { headers: { "user-agent": "hype-stack-cli" } }).catch(() => null);
8616
+ let r = await fetch(om, { headers: { "user-agent": "hype-stack-cli" } }).catch(() => null);
8583
8617
  if (!r?.ok) return null;
8584
- let i = dm(await r.text());
8618
+ let i = fm(await r.text());
8585
8619
  if (!i) return null;
8586
- let a = fm(process.platform, process.arch, i);
8620
+ let a = pm(process.platform, process.arch, i);
8587
8621
  if (!a) return null;
8588
8622
  let o = await fetch(`https://github.com/superfly/flyctl/releases/download/${i}/${a}`).catch(() => null);
8589
8623
  if (!o?.ok) return null;
@@ -8597,42 +8631,42 @@ async function _m(e) {
8597
8631
  t
8598
8632
  ], { cwd: t }).catch(() => null);
8599
8633
  if (await C.rm(s, { force: !0 }), !c || c.exitCode !== 0) return null;
8600
- let l = T.join(t, pm("flyctl"));
8634
+ let l = T.join(t, mm("flyctl"));
8601
8635
  return !le(n) && le(l) && await C.copyFile(l, n), le(n) ? (process.platform !== "win32" && await C.chmod(n, 493), t) : null;
8602
8636
  }
8603
- async function vm(e, t = om()) {
8604
- let n = e.id === "railway" ? await gm(t) : await _m(t);
8605
- return n && um(n), n;
8637
+ async function ym(e, t = sm()) {
8638
+ let n = e.id === "railway" ? await _m(t) : await vm(t);
8639
+ return n && dm(n), n;
8606
8640
  }
8607
8641
  //#endregion
8608
8642
  //#region src/deploy/auth.ts
8609
- function ym() {
8643
+ function bm() {
8610
8644
  return {
8611
- createRunner: (e) => Pf({ env: e }),
8645
+ createRunner: (e) => Ff({ env: e }),
8612
8646
  runInteractive: async (e, t, n) => (await li(e, t, { cwd: n })).exitCode,
8613
- bootstrapCli: (e) => vm(e),
8614
- confirmInstall: Am,
8615
- chooseMethod: jm,
8616
- readToken: Nm,
8617
- chooseScope: Mm
8647
+ bootstrapCli: (e) => ym(e),
8648
+ confirmInstall: jm,
8649
+ chooseMethod: Mm,
8650
+ readToken: Pm,
8651
+ chooseScope: Nm
8618
8652
  };
8619
8653
  }
8620
- async function bm(e) {
8621
- let t = e.io ?? ym(), n = {}, r = {};
8654
+ async function xm(e) {
8655
+ let t = e.io ?? bm(), n = {}, r = {};
8622
8656
  for (let i of e.providers) {
8623
- let a = Wd[i], o = e.adapters?.[i] ?? rm(i), s = {
8657
+ let a = Wd[i], o = e.adapters?.[i] ?? im(i), s = {
8624
8658
  io: t,
8625
8659
  spec: a,
8626
8660
  plan: e.plan,
8627
8661
  skipPrompts: e.skipPrompts,
8628
8662
  env: r
8629
8663
  };
8630
- await xm(s);
8631
- let c = await Tm({
8664
+ await Sm(s);
8665
+ let c = await Em({
8632
8666
  ...s,
8633
8667
  adapter: o
8634
8668
  });
8635
- r = c.env, c.account && (n[i] = c.account), await Em({
8669
+ r = c.env, c.account && (n[i] = c.account), await Dm({
8636
8670
  ...s,
8637
8671
  env: r,
8638
8672
  adapter: o
@@ -8643,20 +8677,20 @@ async function bm(e) {
8643
8677
  accounts: n
8644
8678
  };
8645
8679
  }
8646
- async function xm(e) {
8680
+ async function Sm(e) {
8647
8681
  let { io: t, spec: n, plan: r, skipPrompts: i } = e;
8648
- if (await Sm(e)) return;
8649
- if (t.bootstrapCli && (Tt(`Fetching the ${n.label} CLI (one-time, into ~/.hype-stack/tools)...`), await t.bootstrapCli(n).catch(() => null) && await Sm(e))) {
8682
+ if (await Cm(e)) return;
8683
+ if (t.bootstrapCli && (Tt(`Fetching the ${n.label} CLI (one-time, into ~/.hype-stack/tools)...`), await t.bootstrapCli(n).catch(() => null) && await Cm(e))) {
8650
8684
  Dt(n.label, "CLI ready");
8651
8685
  return;
8652
8686
  }
8653
8687
  let a = `The ${n.label} CLI is not on your PATH. Install it with ${N.command(n.install)} and run deploy again. ${P(n.docs)}`;
8654
- (i || !Cm()) && L(a, { reason: "input_required" }), ut({
8688
+ (i || !wm()) && L(a, { reason: "input_required" }), ut({
8655
8689
  reason: "input_required",
8656
8690
  message: a
8657
- }), await t.confirmInstall(n) || L(a, { reason: "input_required" }), await t.runInteractive("sh", ["-c", n.install], r.projectRoot), await Sm(e) || L(`That did not put ${N.command(n.bin)} on your PATH. ${a}`, { reason: "input_required" });
8691
+ }), await t.confirmInstall(n) || L(a, { reason: "input_required" }), await t.runInteractive("sh", ["-c", n.install], r.projectRoot), await Cm(e) || L(`That did not put ${N.command(n.bin)} on your PATH. ${a}`, { reason: "input_required" });
8658
8692
  }
8659
- async function Sm(e) {
8693
+ async function Cm(e) {
8660
8694
  let t = await e.io.createRunner(e.env).run({
8661
8695
  command: e.spec.bin,
8662
8696
  args: ["--version"],
@@ -8665,11 +8699,11 @@ async function Sm(e) {
8665
8699
  }).catch(() => null);
8666
8700
  return t !== null && t.exitCode === 0;
8667
8701
  }
8668
- function Cm() {
8702
+ function wm() {
8669
8703
  return process.platform !== "win32";
8670
8704
  }
8671
- var wm = 3;
8672
- async function Tm(e) {
8705
+ var Tm = 3;
8706
+ async function Em(e) {
8673
8707
  let { io: t, spec: n, plan: r, skipPrompts: i, adapter: a } = e, o = { ...e.env }, s = 0;
8674
8708
  for (;;) {
8675
8709
  let e = {
@@ -8681,26 +8715,26 @@ async function Tm(e) {
8681
8715
  account: c.account,
8682
8716
  env: o
8683
8717
  };
8684
- let l = Dm(n, o);
8718
+ let l = Om(n, o);
8685
8719
  if (l) {
8686
8720
  Object.assign(o, l);
8687
8721
  continue;
8688
8722
  }
8689
- i && L(km(n), { reason: "auth_required" }), ut({
8723
+ i && L(Am(n), { reason: "auth_required" }), ut({
8690
8724
  reason: "auth_required",
8691
- message: km(n)
8692
- }), s >= wm && L(`${n.label} still does not know who you are. ${km(n)}`, { reason: "auth_required" }), s += 1;
8725
+ message: Am(n)
8726
+ }), s >= Tm && L(`${n.label} still does not know who you are. ${Am(n)}`, { reason: "auth_required" }), s += 1;
8693
8727
  let u = await t.chooseMethod(n);
8694
8728
  if (u === "token") {
8695
8729
  let e = await t.readToken(n);
8696
- Object.assign(o, Om(n.conflictingTokenEnv), { [n.tokenEnv]: e });
8730
+ Object.assign(o, km(n.conflictingTokenEnv), { [n.tokenEnv]: e });
8697
8731
  continue;
8698
8732
  }
8699
8733
  let d = u === "browserless" ? n.browserlessLoginArgs ?? n.loginArgs : n.loginArgs;
8700
8734
  await t.runInteractive(n.bin, d, r.projectRoot);
8701
8735
  }
8702
8736
  }
8703
- async function Em(e) {
8737
+ async function Dm(e) {
8704
8738
  let { io: t, spec: n, plan: r, skipPrompts: i, env: a, adapter: o } = e, { scope: s } = o;
8705
8739
  if (!s || s.current(r)) return;
8706
8740
  let c = await s.list({
@@ -8718,27 +8752,27 @@ async function Em(e) {
8718
8752
  message: l
8719
8753
  }), s.pin(r, await t.chooseScope(n, s, c));
8720
8754
  }
8721
- function Dm(e, t) {
8755
+ function Om(e, t) {
8722
8756
  let n = (e.conflictingTokenEnv ?? []).filter((e) => !(e in t) && process.env[e] !== void 0);
8723
8757
  if (n.length === 0) return null;
8724
8758
  for (let t of n) wt(`${N.label(t)} is set in your shell, but it cannot create a ${e.label} project. Ignoring it for this run.`);
8725
- return Om(n);
8759
+ return km(n);
8726
8760
  }
8727
- function Om(e = []) {
8761
+ function km(e = []) {
8728
8762
  return Object.fromEntries(e.map((e) => [e, void 0]));
8729
8763
  }
8730
- function km(e) {
8764
+ function Am(e) {
8731
8765
  let t = N.command(`${e.bin} ${e.loginArgs.join(" ")}`);
8732
8766
  return `Not signed in to ${e.label}. Run ${t}, or set ${N.label(e.tokenEnv)} to a token from ${P(e.tokenUrl)}.`;
8733
8767
  }
8734
- async function Am(e) {
8768
+ async function jm(e) {
8735
8769
  let t = await c.confirm({
8736
8770
  message: `Deploying needs the ${N.highlight(e.label)} CLI. Install it with ${N.command(e.install)}?`,
8737
8771
  initialValue: !0
8738
8772
  });
8739
8773
  return c.isCancel(t) && R(), t;
8740
8774
  }
8741
- async function jm(e) {
8775
+ async function Mm(e) {
8742
8776
  let t = [{
8743
8777
  value: "browser",
8744
8778
  label: "Log in through the browser",
@@ -8760,7 +8794,7 @@ async function jm(e) {
8760
8794
  });
8761
8795
  return c.isCancel(n) && R(), n;
8762
8796
  }
8763
- async function Mm(e, t, n) {
8797
+ async function Nm(e, t, n) {
8764
8798
  let r = await c.select({
8765
8799
  message: `Which ${N.highlight(e.label)} ${t.label} should this project live in?`,
8766
8800
  options: n.map((e) => ({
@@ -8771,7 +8805,7 @@ async function Mm(e, t, n) {
8771
8805
  });
8772
8806
  return c.isCancel(r) && R(), r;
8773
8807
  }
8774
- async function Nm(e) {
8808
+ async function Pm(e) {
8775
8809
  c.log.info(`Create one at ${P(e.tokenUrl)}. Give it the workspace this project should live in, not a single project.`);
8776
8810
  let t = await c.password({
8777
8811
  message: `Paste your ${e.label} token`,
@@ -8781,59 +8815,59 @@ async function Nm(e) {
8781
8815
  }
8782
8816
  //#endregion
8783
8817
  //#region src/deploy/config.ts
8784
- var Pm = A.enum(Vd), Fm = A.object({
8785
- provider: Pm,
8818
+ var Fm = A.enum(Vd), Im = A.object({
8819
+ provider: Fm,
8786
8820
  app: A.string().min(1).optional(),
8787
8821
  region: A.string().min(1).optional(),
8788
8822
  url: A.string().url().optional()
8789
- }), Im = A.object({
8790
- provider: Pm,
8823
+ }), Lm = A.object({
8824
+ provider: Fm,
8791
8825
  name: A.string().min(1).optional(),
8792
8826
  region: A.string().min(1).optional(),
8793
8827
  external: A.record(A.string(), A.string()).optional()
8794
- }), Lm = A.object({
8828
+ }), Rm = A.object({
8795
8829
  org: A.string().min(1).optional(),
8796
8830
  postgresPlan: A.string().min(1).optional()
8797
- }), Rm = A.object({ workspace: A.string().min(1).optional() }), zm = A.object({
8831
+ }), zm = A.object({ workspace: A.string().min(1).optional() }), Bm = A.object({
8798
8832
  version: A.number().int().positive(),
8799
8833
  projectName: A.string().min(1),
8800
8834
  environment: A.string().min(1),
8801
- defaultProvider: Pm.optional(),
8835
+ defaultProvider: Fm.optional(),
8802
8836
  targets: A.object({
8803
- backend: Fm.optional(),
8804
- frontend: Fm.optional(),
8805
- admin: Fm.optional()
8837
+ backend: Im.optional(),
8838
+ frontend: Im.optional(),
8839
+ admin: Im.optional()
8806
8840
  }).default({}),
8807
8841
  services: A.object({
8808
- postgres: Im.optional(),
8809
- valkey: Im.optional(),
8810
- bucket: Im.optional()
8842
+ postgres: Lm.optional(),
8843
+ valkey: Lm.optional(),
8844
+ bucket: Lm.optional()
8811
8845
  }).default({}),
8812
- fly: Lm.optional(),
8813
- railway: Rm.optional()
8846
+ fly: Rm.optional(),
8847
+ railway: zm.optional()
8814
8848
  });
8815
- async function Bm(e) {
8849
+ async function Vm(e) {
8816
8850
  let t = await q(e).catch((e) => {
8817
8851
  throw Error(`Could not read ${X}: ${e instanceof Error ? e.message : String(e)}. Fix it, then run deploy again.`);
8818
8852
  });
8819
8853
  if (!t) throw Error(`No ${X} in this project, so there is nothing to deploy. Run "hype-stack init" to create one, or deploy from the root of a project made with "hype-stack create".`);
8820
8854
  return t;
8821
8855
  }
8822
- async function Vm(e) {
8823
- let t = (await Bm(e))[Id];
8856
+ async function Hm(e) {
8857
+ let t = (await Vm(e))[Id];
8824
8858
  if (t === void 0) return null;
8825
- let n = zm.safeParse(t);
8859
+ let n = Bm.safeParse(t);
8826
8860
  if (!n.success) throw Error(`Invalid "${Id}" block in ${X}:\n ${A.prettifyError(n.error)}`);
8827
8861
  if (n.data.version > 1) throw Error(`The "${Id}" block in ${X} was written by a newer CLI (version ${n.data.version}, this CLI understands 1). Upgrade with "npm i -g @hype-stack/cli".`);
8828
8862
  return n.data;
8829
8863
  }
8830
- async function Hm(e, t) {
8864
+ async function Um(e, t) {
8831
8865
  await qi(e, {
8832
- ...await Bm(e),
8833
- [Id]: Wm(t)
8866
+ ...await Vm(e),
8867
+ [Id]: Gm(t)
8834
8868
  });
8835
8869
  }
8836
- function Um(e, t = Rd) {
8870
+ function Wm(e, t = Rd) {
8837
8871
  return {
8838
8872
  version: 1,
8839
8873
  projectName: e,
@@ -8842,7 +8876,7 @@ function Um(e, t = Rd) {
8842
8876
  services: {}
8843
8877
  };
8844
8878
  }
8845
- function Wm(e) {
8879
+ function Gm(e) {
8846
8880
  let t = {
8847
8881
  version: e.version,
8848
8882
  projectName: e.projectName,
@@ -8872,7 +8906,7 @@ function Wm(e) {
8872
8906
  }
8873
8907
  //#endregion
8874
8908
  //#region src/deploy/detect.ts
8875
- var Gm = [
8909
+ var Km = [
8876
8910
  "@hono/node-server",
8877
8911
  "@tanstack/react-start",
8878
8912
  "@tanstack/start",
@@ -8880,32 +8914,32 @@ var Gm = [
8880
8914
  "express",
8881
8915
  "fastify"
8882
8916
  ];
8883
- function Km(e, t, n) {
8917
+ function qm(e, t, n) {
8884
8918
  let r = Hd[t], i = n?.paths?.[r.pathKey]?.root, a = n?.apps?.[t];
8885
8919
  return T.resolve(e, i ?? a ?? r.defaultRoot);
8886
8920
  }
8887
- async function qm(e, t) {
8921
+ async function Jm(e, t) {
8888
8922
  return (await Promise.all(zd.map(async (n) => {
8889
- let r = Km(e, n, t);
8923
+ let r = qm(e, n, t);
8890
8924
  return await G(T.join(r, "package.json")) ? n : null;
8891
8925
  }))).filter((e) => e !== null);
8892
8926
  }
8893
- var Jm = ["build:web", "build"];
8894
- async function Ym(e, t) {
8927
+ var Ym = ["build:web", "build"];
8928
+ async function Xm(e, t) {
8895
8929
  let [n, r] = await Promise.all([G(T.join(e, "Dockerfile")), fi(T.join(e, "package.json")).catch(() => null)]);
8896
8930
  if (n) return "node";
8897
8931
  if (Hd[t].serveMode === "node") return null;
8898
8932
  let i = r?.scripts ?? {}, a = {
8899
8933
  ...r?.dependencies,
8900
8934
  ...r?.devDependencies
8901
- }, o = Jm.some((e) => i[e] !== void 0), s = Gm.some((e) => a[e] !== void 0);
8935
+ }, o = Ym.some((e) => i[e] !== void 0), s = Km.some((e) => a[e] !== void 0);
8902
8936
  return o || !s ? "static" : null;
8903
8937
  }
8904
- async function Xm(e, t, n) {
8905
- let r = await Promise.all(t.map(async (t) => [t, await Ym(Km(e, t, n), t)]));
8938
+ async function Zm(e, t, n) {
8939
+ let r = await Promise.all(t.map(async (t) => [t, await Xm(qm(e, t, n), t)]));
8906
8940
  return Object.fromEntries(r);
8907
8941
  }
8908
- function Zm(e) {
8942
+ function Qm(e) {
8909
8943
  let t = {};
8910
8944
  for (let n of zd) {
8911
8945
  let r = e[n];
@@ -8913,7 +8947,7 @@ function Zm(e) {
8913
8947
  }
8914
8948
  return t;
8915
8949
  }
8916
- async function Qm(e, t) {
8950
+ async function $m(e, t) {
8917
8951
  let n = Hd[t].staticDir ?? "dist", r = [
8918
8952
  n,
8919
8953
  "dist",
@@ -8926,11 +8960,11 @@ async function Qm(e, t) {
8926
8960
  //#endregion
8927
8961
  //#region src/deploy/dry-run.ts
8928
8962
  var $ = "dry-run-placeholder";
8929
- function $m(e, t) {
8963
+ function eh(e, t) {
8930
8964
  let n = e.args.indexOf(t);
8931
8965
  return n === -1 ? "app" : e.args[n + 1] ?? "app";
8932
8966
  }
8933
- var eh = "dryrun00cluster", th = "dryrun00service", nh = [
8967
+ var th = "dryrun00cluster", nh = "dryrun00service", rh = [
8934
8968
  {
8935
8969
  match: "fly orgs list",
8936
8970
  stdout: JSON.stringify([{
@@ -8948,13 +8982,13 @@ var eh = "dryrun00cluster", th = "dryrun00service", nh = [
8948
8982
  },
8949
8983
  {
8950
8984
  match: "fly mpg create",
8951
- stdout: `Managed Postgres cluster created successfully!\n ID: ${eh}\n Connection string: postgres://hype:${$}@example.flympg.net:5432/postgres`
8985
+ stdout: `Managed Postgres cluster created successfully!\n ID: ${th}\n Connection string: postgres://hype:${$}@example.flympg.net:5432/postgres`
8952
8986
  },
8953
8987
  {
8954
8988
  match: "fly mpg status",
8955
8989
  stdout: JSON.stringify({
8956
8990
  data: {
8957
- id: eh,
8991
+ id: th,
8958
8992
  status: "ready"
8959
8993
  },
8960
8994
  credentials: { pgbouncer_uri: `postgres://hype:${$}@example.flympg.net:5432/postgres` }
@@ -8971,7 +9005,7 @@ var eh = "dryrun00cluster", th = "dryrun00service", nh = [
8971
9005
  {
8972
9006
  match: "fly storage create",
8973
9007
  stdout: (e) => [
8974
- `BUCKET_NAME: ${$m(e, "--name")}`,
9008
+ `BUCKET_NAME: ${eh(e, "--name")}`,
8975
9009
  "AWS_ENDPOINT_URL_S3: https://fly.storage.tigris.dev",
8976
9010
  `AWS_ACCESS_KEY_ID: ${$}`,
8977
9011
  `AWS_SECRET_ACCESS_KEY: ${$}`
@@ -8992,8 +9026,8 @@ var eh = "dryrun00cluster", th = "dryrun00service", nh = [
8992
9026
  {
8993
9027
  match: "railway add",
8994
9028
  stdout: (e) => JSON.stringify({
8995
- id: th,
8996
- name: $m(e, "--service")
9029
+ id: nh,
9030
+ name: eh(e, "--service")
8997
9031
  })
8998
9032
  },
8999
9033
  {
@@ -9008,7 +9042,7 @@ var eh = "dryrun00cluster", th = "dryrun00service", nh = [
9008
9042
  },
9009
9043
  {
9010
9044
  match: "railway domain",
9011
- stdout: (e) => JSON.stringify({ domain: `${$m(e, "--service")}-production.up.railway.app` })
9045
+ stdout: (e) => JSON.stringify({ domain: `${eh(e, "--service")}-production.up.railway.app` })
9012
9046
  },
9013
9047
  {
9014
9048
  match: "railway variable list",
@@ -9027,7 +9061,7 @@ var eh = "dryrun00cluster", th = "dryrun00service", nh = [
9027
9061
  stdout: (e) => JSON.stringify({
9028
9062
  id: "dryrun00bucket",
9029
9063
  name: e.args[2] ?? "bucket",
9030
- region: $m(e, "--region"),
9064
+ region: eh(e, "--region"),
9031
9065
  staged: !1,
9032
9066
  committed: !0
9033
9067
  })
@@ -9047,7 +9081,7 @@ var eh = "dryrun00cluster", th = "dryrun00service", nh = [
9047
9081
  match: "railway api",
9048
9082
  stdout: JSON.stringify({ data: { serviceInstanceUpdate: !0 } })
9049
9083
  }
9050
- ], rh = {
9084
+ ], ih = {
9051
9085
  backend: [
9052
9086
  "NODE_ENV",
9053
9087
  "APP_ENV",
@@ -9073,30 +9107,30 @@ var eh = "dryrun00cluster", th = "dryrun00service", nh = [
9073
9107
  "VITE_APP_TYPE",
9074
9108
  "VITE_ENVIRONMENT"
9075
9109
  ]
9076
- }, ih = new Set([
9110
+ }, ah = new Set([
9077
9111
  "VITE_SENTRY_AUTH_TOKEN",
9078
9112
  "POSTGRES_USER",
9079
9113
  "POSTGRES_PASSWORD",
9080
9114
  "POSTGRES_DB",
9081
9115
  "POSTGRES_HOST",
9082
9116
  "POSTGRES_PORT"
9083
- ]), ah = /(?:^|\/\/|@)(?:localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.internal)(?::\d+)?(?:\/|$)/i;
9084
- function oh(e) {
9117
+ ]), oh = /(?:^|\/\/|@)(?:localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.internal)(?::\d+)?(?:\/|$)/i;
9118
+ function sh(e) {
9085
9119
  let { plan: t, serviceOutputs: n, urls: r, localEnv: i = {}, declaredKeys: a = {}, exampleEnv: o = {}, externallyProvided: s = {} } = e;
9086
9120
  return t.targets.map((e) => {
9087
- let c = sh(e, t, r), l = ph({
9121
+ let c = ch(e, t, r), l = hh({
9088
9122
  target: e.target,
9089
9123
  environment: t.environment,
9090
9124
  port: e.spec.port,
9091
9125
  serviceOutputs: n,
9092
9126
  urls: c
9093
- }), u = a[e.target] ?? [], d = i[e.target] ?? {}, f = c[e.target], { forwarded: p, rehosted: m, skippedLocal: h } = hh({
9127
+ }), u = a[e.target] ?? [], d = i[e.target] ?? {}, f = c[e.target], { forwarded: p, rehosted: m, skippedLocal: h } = _h({
9094
9128
  declared: u,
9095
9129
  local: d,
9096
9130
  managed: l,
9097
9131
  origin: f,
9098
9132
  target: e.target
9099
- }), g = new Set(s[e.target] ?? []), _ = u.filter((e) => l[e] === void 0 && p[e] === void 0 && !ih.has(e) && !g.has(e)), { seeded: v, seededRehosted: y } = ch({
9133
+ }), g = new Set(s[e.target] ?? []), _ = u.filter((e) => l[e] === void 0 && p[e] === void 0 && !ah.has(e) && !g.has(e)), { seeded: v, seededRehosted: y } = lh({
9100
9134
  keys: _,
9101
9135
  example: o[e.target] ?? {},
9102
9136
  origin: f
@@ -9108,25 +9142,26 @@ function oh(e) {
9108
9142
  seeded: v,
9109
9143
  rehosted: [...m, ...y],
9110
9144
  missing: b,
9145
+ blank: uh(b, o[e.target] ?? {}),
9111
9146
  skippedLocal: h
9112
9147
  };
9113
9148
  });
9114
9149
  }
9115
- function sh(e, t, n) {
9150
+ function ch(e, t, n) {
9116
9151
  let r = e.provider === "railway" && e.target === "backend", i = {};
9117
- for (let e of t.targets) i[e.target] = r && e.provider === "railway" ? wp(e.app) : n[e.target];
9152
+ for (let e of t.targets) i[e.target] = r && e.provider === "railway" ? Tp(e.app) : n[e.target];
9118
9153
  return i;
9119
9154
  }
9120
- function ch(e) {
9155
+ function lh(e) {
9121
9156
  let t = {}, n = [];
9122
9157
  for (let r of e.keys) {
9123
9158
  let i = e.example[r];
9124
9159
  if (i === void 0 || i.trim() === "" || i.includes("${")) continue;
9125
- if (!ah.test(i)) {
9160
+ if (!oh.test(i)) {
9126
9161
  t[r] = i;
9127
9162
  continue;
9128
9163
  }
9129
- let a = lh(i, e.origin);
9164
+ let a = dh(i, e.origin);
9130
9165
  a && (t[r] = a, n.push(r));
9131
9166
  }
9132
9167
  return {
@@ -9134,7 +9169,13 @@ function ch(e) {
9134
9169
  seededRehosted: n
9135
9170
  };
9136
9171
  }
9137
- function lh(e, t) {
9172
+ function uh(e, t) {
9173
+ return e.filter((e) => {
9174
+ let n = t[e];
9175
+ return n !== void 0 && n.trim() === "";
9176
+ });
9177
+ }
9178
+ function dh(e, t) {
9138
9179
  if (!t) return null;
9139
9180
  let n;
9140
9181
  try {
@@ -9144,13 +9185,13 @@ function lh(e, t) {
9144
9185
  }
9145
9186
  return /^https?:$/.test(n.protocol) ? `${t.replace(/\/+$/, "")}${n.pathname === "/" && !e.trimEnd().endsWith("/") ? "" : n.pathname}${n.search}${n.hash}` : null;
9146
9187
  }
9147
- var uh = "(pending)", dh = "https://pending.invalid";
9148
- function fh(e) {
9188
+ var fh = "(pending)", ph = "https://pending.invalid";
9189
+ function mh(e) {
9149
9190
  let { plan: t, localEnv: n, declaredKeys: r, exampleEnv: i } = e, a = {};
9150
- for (let e of t.targets) a[e.target] = e.url ?? dh;
9191
+ for (let e of t.targets) a[e.target] = e.url ?? ph;
9151
9192
  let o = {};
9152
- for (let e of t.services) o[e.service] = e.external ?? Object.fromEntries(e.spec.provides.map((e) => [e, uh]));
9153
- return oh({
9193
+ for (let e of t.services) o[e.service] = e.external ?? Object.fromEntries(e.spec.provides.map((e) => [e, fh]));
9194
+ return sh({
9154
9195
  plan: t,
9155
9196
  serviceOutputs: o,
9156
9197
  urls: a,
@@ -9159,14 +9200,14 @@ function fh(e) {
9159
9200
  exampleEnv: i
9160
9201
  });
9161
9202
  }
9162
- function ph(e) {
9203
+ function hh(e) {
9163
9204
  let { target: t, environment: n, port: r, serviceOutputs: i, urls: a } = e;
9164
- return t === "backend" ? mh({
9205
+ return t === "backend" ? gh({
9165
9206
  environment: n,
9166
9207
  port: r,
9167
9208
  serviceOutputs: i,
9168
9209
  urls: a
9169
- }) : _h(t === "frontend" ? {
9210
+ }) : yh(t === "frontend" ? {
9170
9211
  VITE_API_BASE_URL: a.backend,
9171
9212
  VITE_ADMIN_URL: a.admin,
9172
9213
  VITE_ENVIRONMENT: n
@@ -9176,9 +9217,9 @@ function ph(e) {
9176
9217
  VITE_ENVIRONMENT: n
9177
9218
  });
9178
9219
  }
9179
- function mh(e) {
9220
+ function gh(e) {
9180
9221
  let { environment: t, port: n, serviceOutputs: r, urls: i } = e;
9181
- return _h({
9222
+ return yh({
9182
9223
  NODE_ENV: "production",
9183
9224
  APP_ENV: t,
9184
9225
  PORT: n === void 0 ? void 0 : String(n),
@@ -9190,14 +9231,14 @@ function mh(e) {
9190
9231
  SERVER_URL: i.backend
9191
9232
  });
9192
9233
  }
9193
- function hh(e) {
9194
- let { declared: t, local: n, managed: r, origin: i, target: a } = e, o = new Set(rh[a]), s = {}, c = [], l = [];
9234
+ function _h(e) {
9235
+ let { declared: t, local: n, managed: r, origin: i, target: a } = e, o = new Set(ih[a]), s = {}, c = [], l = [];
9195
9236
  for (let e of t) {
9196
- if (o.has(e) || r[e] !== void 0 || ih.has(e)) continue;
9237
+ if (o.has(e) || r[e] !== void 0 || ah.has(e)) continue;
9197
9238
  let t = n[e];
9198
9239
  if (!(t === void 0 || t.trim() === "") && !t.includes("${")) {
9199
- if (ah.test(t)) {
9200
- let n = lh(t, i);
9240
+ if (oh.test(t)) {
9241
+ let n = dh(t, i);
9201
9242
  if (!n) {
9202
9243
  l.push(e);
9203
9244
  continue;
@@ -9214,19 +9255,20 @@ function hh(e) {
9214
9255
  skippedLocal: l
9215
9256
  };
9216
9257
  }
9217
- function gh(e) {
9258
+ function vh(e) {
9218
9259
  return {
9260
+ ...Object.fromEntries(e.blank.map((e) => [e, ""])),
9219
9261
  ...e.seeded,
9220
9262
  ...e.forwarded,
9221
9263
  ...e.managed
9222
9264
  };
9223
9265
  }
9224
- function _h(e) {
9266
+ function yh(e) {
9225
9267
  let t = {};
9226
9268
  for (let [n, r] of Object.entries(e)) r !== void 0 && r !== "" && (t[n] = r);
9227
9269
  return t;
9228
9270
  }
9229
- function vh(e) {
9271
+ function bh(e) {
9230
9272
  let t = {};
9231
9273
  for (let n of e.split(/\r?\n/)) {
9232
9274
  let e = n.trim();
@@ -9234,27 +9276,27 @@ function vh(e) {
9234
9276
  let r = e.startsWith("export ") ? e.slice(7).trim() : e, i = r.indexOf("=");
9235
9277
  if (i <= 0) continue;
9236
9278
  let a = r.slice(0, i).trim();
9237
- /^[A-Za-z_][A-Za-z0-9_]*$/.test(a) && (t[a] = yh(r.slice(i + 1).trim()));
9279
+ /^[A-Za-z_][A-Za-z0-9_]*$/.test(a) && (t[a] = xh(r.slice(i + 1).trim()));
9238
9280
  }
9239
9281
  return t;
9240
9282
  }
9241
- function yh(e) {
9283
+ function xh(e) {
9242
9284
  if (e.length >= 2 && (e.startsWith("\"") && e.endsWith("\"") || e.startsWith("'") && e.endsWith("'"))) return e.slice(1, -1);
9243
9285
  let t = e.indexOf(" #");
9244
9286
  return t === -1 ? e : e.slice(0, t).trim();
9245
9287
  }
9246
- function bh(e) {
9247
- return [...new Set(Object.keys(vh(e)))];
9288
+ function Sh(e) {
9289
+ return [...new Set(Object.keys(bh(e)))];
9248
9290
  }
9249
9291
  //#endregion
9250
9292
  //#region src/deploy/migrations.ts
9251
- var xh = [
9293
+ var Ch = [
9252
9294
  "migration:latest",
9253
9295
  "migrate:deploy",
9254
9296
  "db:migrate:deploy"
9255
9297
  ];
9256
- async function Sh(e, t) {
9257
- let n = await fi(T.join(e, "package.json")).catch(() => null), r = xh.find((e) => typeof n?.scripts?.[e] == "string");
9298
+ async function wh(e, t) {
9299
+ let n = await fi(T.join(e, "package.json")).catch(() => null), r = Ch.find((e) => typeof n?.scripts?.[e] == "string");
9258
9300
  if (r && n?.name) return [
9259
9301
  "pnpm",
9260
9302
  "--filter",
@@ -9267,7 +9309,7 @@ async function Sh(e, t) {
9267
9309
  "run",
9268
9310
  r
9269
9311
  ];
9270
- let i = await Ch(e);
9312
+ let i = await Th(e);
9271
9313
  return [
9272
9314
  "npx",
9273
9315
  "prisma",
@@ -9277,7 +9319,7 @@ async function Sh(e, t) {
9277
9319
  T.relative(t, i).split(T.sep).join("/")
9278
9320
  ];
9279
9321
  }
9280
- async function Ch(e) {
9322
+ async function Th(e) {
9281
9323
  let t = T.join(e, "prisma"), n = T.join(t, "schema");
9282
9324
  if (await W(n)) return n;
9283
9325
  let r = T.join(t, "schema.prisma");
@@ -9285,16 +9327,16 @@ async function Ch(e) {
9285
9327
  }
9286
9328
  //#endregion
9287
9329
  //#region src/deploy/orchestrate.ts
9288
- async function wh(e) {
9330
+ async function Eh(e) {
9289
9331
  let { plan: t, runner: n, log: r } = e, i = [], a = {}, o = { ...e.knownServiceOutputs }, s = {}, c = [], l = {
9290
9332
  runner: n,
9291
9333
  plan: t,
9292
9334
  cwd: t.projectRoot,
9293
9335
  log: r
9294
- }, u = (t) => e.adapters?.[t] ?? rm(t), d = (e, n) => (i.push({
9336
+ }, u = (t) => e.adapters?.[t] ?? im(t), d = (e, n) => (i.push({
9295
9337
  ...e,
9296
9338
  status: "failed",
9297
- detail: Ah(n)
9339
+ detail: Mh(n)
9298
9340
  }), {
9299
9341
  plan: t,
9300
9342
  steps: i,
@@ -9303,7 +9345,7 @@ async function wh(e) {
9303
9345
  envPlans: c,
9304
9346
  ok: !1
9305
9347
  });
9306
- if (!e.skipAuthCheck) for (let n of Dh(t)) {
9348
+ if (!e.skipAuthCheck) for (let n of kh(t)) {
9307
9349
  let t = {
9308
9350
  id: `auth:${n}`,
9309
9351
  label: `Check ${n} login`
@@ -9368,13 +9410,19 @@ async function wh(e) {
9368
9410
  }, e.providedByProvider && f && (s[f.target] = [...s[f.target] ?? [], ...e.providedByProvider]), i.push({
9369
9411
  ...t,
9370
9412
  status: "ok",
9371
- detail: e.note ?? kh(e.outputs)
9413
+ detail: e.note ?? jh(e.outputs)
9372
9414
  });
9373
9415
  } catch (e) {
9374
9416
  return d(t, e);
9375
9417
  }
9376
9418
  }
9377
- c = oh({
9419
+ for (let e of t.targets) {
9420
+ let t = u(e.provider);
9421
+ if (!t.existingEnvKeys) continue;
9422
+ let n = await t.existingEnvKeys(l, e).catch(() => []);
9423
+ n.length > 0 && (s[e.target] = [...s[e.target] ?? [], ...n]);
9424
+ }
9425
+ c = sh({
9378
9426
  plan: t,
9379
9427
  serviceOutputs: o,
9380
9428
  urls: a,
@@ -9383,52 +9431,53 @@ async function wh(e) {
9383
9431
  exampleEnv: e.exampleEnv,
9384
9432
  externallyProvided: s
9385
9433
  });
9386
- let p = new Map(c.map((e) => [e.target, e])), m = f && !e.skipMigrations ? await Sh(f.root, t.projectRoot) : void 0, h = !1, g = /* @__PURE__ */ new Set();
9434
+ let p = new Map(c.map((e) => [e.target, e])), m = f && !e.skipMigrations ? await wh(f.root, t.projectRoot) : void 0, h = !1, g = /* @__PURE__ */ new Set();
9387
9435
  for (let e of t.targets) {
9388
- let t = p.get(e.target), n = t ? gh(t) : {}, o = Oh(n), s = u(e.provider), c = {
9436
+ let t = p.get(e.target), n = t ? vh(t) : {}, o = t?.blank ?? [], s = Ah(n), c = u(e.provider), d = {
9389
9437
  id: `env:${e.target}`,
9390
9438
  label: `Configure ${e.spec.label} env`
9391
9439
  };
9392
9440
  try {
9393
- r?.(`Setting ${Object.keys(n).length} env vars on ${e.app}`), await s.setEnv(l, {
9441
+ r?.(`Setting ${Object.keys(n).length} env vars on ${e.app}`), await c.setEnv(l, {
9394
9442
  target: e,
9395
9443
  env: n,
9396
- secrets: o
9444
+ secrets: s,
9445
+ blankKeys: o
9397
9446
  }), i.push({
9398
- ...c,
9447
+ ...d,
9399
9448
  status: "ok",
9400
9449
  detail: `${Object.keys(n).length} variables`
9401
9450
  });
9402
9451
  } catch (t) {
9403
9452
  i.push({
9404
- ...c,
9453
+ ...d,
9405
9454
  status: "failed",
9406
- detail: Ah(t)
9455
+ detail: Mh(t)
9407
9456
  }), g.add(e.target);
9408
9457
  continue;
9409
9458
  }
9410
- let d = {
9459
+ let _ = {
9411
9460
  id: `deploy:${e.target}`,
9412
9461
  label: `Deploy ${e.spec.label}`
9413
9462
  };
9414
9463
  try {
9415
9464
  r?.(`Deploying ${e.spec.label} to ${e.provider}`);
9416
- let t = await s.deployTarget(l, {
9465
+ let t = await c.deployTarget(l, {
9417
9466
  target: e,
9418
9467
  env: n,
9419
- secrets: o,
9468
+ secrets: s,
9420
9469
  releaseCommand: e === f ? m : void 0
9421
9470
  });
9422
9471
  t.url && (a[e.target] = t.url), t.releaseRan && (h = !0), i.push({
9423
- ...d,
9472
+ ..._,
9424
9473
  status: "ok",
9425
9474
  detail: t.url ?? t.note
9426
9475
  });
9427
9476
  } catch (t) {
9428
9477
  i.push({
9429
- ...d,
9478
+ ..._,
9430
9479
  status: "failed",
9431
- detail: Ah(t)
9480
+ detail: Mh(t)
9432
9481
  }), g.add(e.target);
9433
9482
  }
9434
9483
  }
@@ -9452,7 +9501,7 @@ async function wh(e) {
9452
9501
  i.push({
9453
9502
  ...n,
9454
9503
  status: "failed",
9455
- detail: Ah(t)
9504
+ detail: Mh(t)
9456
9505
  }), g.add(e.target);
9457
9506
  }
9458
9507
  }
@@ -9477,7 +9526,7 @@ async function wh(e) {
9477
9526
  detail: `${m.join(" ")} (ran with the release)`
9478
9527
  });
9479
9528
  else {
9480
- let e = await Th({
9529
+ let e = await Dh({
9481
9530
  ctx: l,
9482
9531
  adapter: u(f.provider),
9483
9532
  backend: f,
@@ -9498,7 +9547,7 @@ async function wh(e) {
9498
9547
  ok: i.every((e) => e.status !== "failed")
9499
9548
  };
9500
9549
  }
9501
- async function Th(e) {
9550
+ async function Dh(e) {
9502
9551
  let { ctx: t, adapter: n, backend: r, command: i } = e;
9503
9552
  if (!n.runRemote) return {
9504
9553
  status: "skipped",
@@ -9510,37 +9559,37 @@ async function Th(e) {
9510
9559
  status: "ok",
9511
9560
  detail: i.join(" ")
9512
9561
  };
9513
- let o = Eh(a.output);
9562
+ let o = Oh(a.output);
9514
9563
  return {
9515
9564
  status: "skipped",
9516
9565
  detail: `Could not run migrations remotely${o ? ` (${o})` : ""}. Run "${i.join(" ")}" against ${r.app}.`
9517
9566
  };
9518
9567
  }
9519
- function Eh(e) {
9568
+ function Oh(e) {
9520
9569
  let t = e.split(/\r?\n/).map((e) => e.trim()).find((e) => e.length > 0);
9521
9570
  if (t) return t.length > 160 ? `${t.slice(0, 157)}...` : t;
9522
9571
  }
9523
- function Dh(e) {
9572
+ function kh(e) {
9524
9573
  let t = /* @__PURE__ */ new Set();
9525
9574
  for (let n of e.targets) t.add(n.provider);
9526
9575
  for (let n of e.services) n.external || t.add(n.provider);
9527
9576
  return [...t];
9528
9577
  }
9529
- function Oh(e) {
9578
+ function Ah(e) {
9530
9579
  return Object.entries(e).filter(([e, t]) => t.length >= 8 && !e.startsWith("VITE_") && !/^https?:\/\//.test(t)).map(([, e]) => e);
9531
9580
  }
9532
- function kh(e) {
9581
+ function jh(e) {
9533
9582
  let t = Object.keys(e);
9534
9583
  return t.length === 0 ? void 0 : `set ${t.join(", ")}`;
9535
9584
  }
9536
- function Ah(e) {
9585
+ function Mh(e) {
9537
9586
  return e instanceof Error ? e.message : String(e);
9538
9587
  }
9539
9588
  //#endregion
9540
9589
  //#region src/deploy/plan.ts
9541
- function jh(e) {
9590
+ function Nh(e) {
9542
9591
  let { projectRoot: t, config: n, assignment: r, stackConfig: i, serveModes: a = {}, staticDirs: o = {} } = e, s = [];
9543
- for (let [e, c] of Nh(r)) {
9592
+ for (let [e, c] of Fh(r)) {
9544
9593
  let r = n.targets[e], l = Hd[e];
9545
9594
  s.push({
9546
9595
  target: e,
@@ -9553,7 +9602,7 @@ function jh(e) {
9553
9602
  app: r?.app ?? Xd(n.projectName, e, c),
9554
9603
  region: r?.region,
9555
9604
  url: r?.url,
9556
- root: Km(t, e, i)
9605
+ root: qm(t, e, i)
9557
9606
  });
9558
9607
  }
9559
9608
  let c = [];
@@ -9580,20 +9629,20 @@ function jh(e) {
9580
9629
  railway: n.railway ?? {}
9581
9630
  };
9582
9631
  }
9583
- var Mh = [
9632
+ var Ph = [
9584
9633
  "frontend",
9585
9634
  "admin",
9586
9635
  "backend"
9587
9636
  ];
9588
- function Nh(e) {
9637
+ function Fh(e) {
9589
9638
  let t = [];
9590
- for (let n of Mh) {
9639
+ for (let n of Ph) {
9591
9640
  let r = e.targets[n];
9592
9641
  r && t.push([n, r]);
9593
9642
  }
9594
9643
  return t;
9595
9644
  }
9596
- function Ph(e, t) {
9645
+ function Ih(e, t) {
9597
9646
  let n = {
9598
9647
  ...e,
9599
9648
  environment: t.environment,
@@ -9623,20 +9672,20 @@ function Ph(e, t) {
9623
9672
  }
9624
9673
  //#endregion
9625
9674
  //#region src/deploy/project-env.ts
9626
- async function Fh(e) {
9675
+ async function Lh(e) {
9627
9676
  return await G(e) ? C.readFile(e, "utf-8") : null;
9628
9677
  }
9629
- async function Ih(e, t) {
9630
- let n = vh(await Fh(T.join(e, ".env")) ?? ""), r = await Promise.all(t.map(async (e) => {
9631
- let [t, r] = await Promise.all([Fh(T.join(e.root, ".env")), Fh(T.join(e.root, ".env.example"))]);
9678
+ async function Rh(e, t) {
9679
+ let n = bh(await Lh(T.join(e, ".env")) ?? ""), r = await Promise.all(t.map(async (e) => {
9680
+ let [t, r] = await Promise.all([Lh(T.join(e.root, ".env")), Lh(T.join(e.root, ".env.example"))]);
9632
9681
  return {
9633
9682
  target: e.target,
9634
9683
  local: {
9635
9684
  ...n,
9636
- ...vh(t ?? "")
9685
+ ...bh(t ?? "")
9637
9686
  },
9638
- declared: bh(r ?? ""),
9639
- example: vh(r ?? "")
9687
+ declared: Sh(r ?? ""),
9688
+ example: bh(r ?? "")
9640
9689
  };
9641
9690
  })), i = {}, a = {}, o = {};
9642
9691
  for (let e of r) i[e.target] = e.local, a[e.target] = e.declared, o[e.target] = e.example;
@@ -9648,7 +9697,7 @@ async function Ih(e, t) {
9648
9697
  }
9649
9698
  //#endregion
9650
9699
  //#region src/deploy/report.ts
9651
- function Lh(e) {
9700
+ function zh(e) {
9652
9701
  let t = [];
9653
9702
  t.push(`${N.label("Project")} ${N.highlight(e.projectName)}`), t.push(`${N.label("Env")} ${N.highlight(e.environment)}`), t.push(""), t.push(N.bold("Apps"));
9654
9703
  for (let n of e.targets) {
@@ -9664,61 +9713,64 @@ function Lh(e) {
9664
9713
  }
9665
9714
  return t.join("\n");
9666
9715
  }
9667
- function Rh(e) {
9716
+ function Bh(e) {
9668
9717
  let t = [];
9669
9718
  for (let n of e) {
9670
9719
  let e = Object.keys(n.managed).length, r = Object.keys(n.forwarded).length;
9671
9720
  t.push(`${N.bold(Z(n.target))} ${N.muted(`${e} wired by deploy, ${r} carried over from .env`)}`);
9672
9721
  let i = Object.keys(n.seeded);
9673
- i.length > 0 && t.push(` ${N.warning("seeded")} ${N.muted(`${i.join(", ")} (placeholders from .env.example)`)}`), n.rehosted.length > 0 && t.push(` ${N.label("moved")} ${N.muted(`${n.rehosted.join(", ")} (localhost swapped for the deployed origin)`)}`), n.skippedLocal.length > 0 && t.push(` ${N.warning("skipped")} ${N.muted(`${n.skippedLocal.join(", ")} (points at localhost)`)}`), n.missing.length > 0 && t.push(` ${N.warning("unset")} ${N.muted(n.missing.join(", "))}`);
9722
+ i.length > 0 && t.push(` ${N.warning("seeded")} ${N.muted(`${i.join(", ")} (placeholders from .env.example)`)}`), n.rehosted.length > 0 && t.push(` ${N.label("moved")} ${N.muted(`${n.rehosted.join(", ")} (localhost swapped for the deployed origin)`)}`), n.skippedLocal.length > 0 && t.push(` ${N.warning("skipped")} ${N.muted(`${n.skippedLocal.join(", ")} (points at localhost)`)}`);
9723
+ let a = n.missing.filter((e) => !n.blank.includes(e));
9724
+ a.length > 0 && t.push(` ${N.warning("unset")} ${N.muted(a.join(", "))}`), n.blank.length > 0 && t.push(` ${N.warning("empty")} ${N.muted(`${n.blank.join(", ")} (declared but never filled in)`)}`);
9674
9725
  }
9675
9726
  return t.join("\n");
9676
9727
  }
9677
- function zh(e) {
9728
+ function Vh(e) {
9678
9729
  return e.steps.map((e) => {
9679
9730
  let t = e.status === "ok" ? N.success("✓") : e.status === "skipped" ? N.warning("-") : N.error("✗"), n = e.detail ? ` ${N.muted(e.detail)}` : "";
9680
9731
  return `${t} ${e.label}${n}`;
9681
9732
  }).join("\n");
9682
9733
  }
9683
- function Bh(e) {
9734
+ function Hh(e) {
9684
9735
  return e.plan.targets.map((t) => {
9685
9736
  let n = e.urls[t.target];
9686
9737
  return n ? `${N.label(t.spec.label)} ${P(n)}` : `${N.label(t.spec.label)} ${N.muted("no public URL")}`;
9687
9738
  }).join("\n");
9688
9739
  }
9689
- function Vh(e) {
9740
+ function Uh(e) {
9690
9741
  let t = [];
9691
9742
  for (let n of e.envPlans) {
9692
- n.missing.length > 0 && t.push(`${Z(n.target)} is missing ${n.missing.join(", ")}. The app will boot only once those are set.`);
9693
- let e = Object.keys(n.seeded);
9694
- e.length > 0 && t.push(`${Z(n.target)} got ${e.join(", ")} from .env.example, so the app boots but those features will not work until you set real values.`);
9743
+ let e = n.missing.filter((e) => !n.blank.includes(e));
9744
+ e.length > 0 && t.push(`${Z(n.target)} is missing ${e.join(", ")}. The app will boot only once those are set.`), n.blank.length > 0 && t.push(`${Z(n.target)} got ${n.blank.join(", ")} as empty values, the same as a fresh .env. The app boots without them; set real values to turn those features on.`);
9745
+ let r = Object.keys(n.seeded);
9746
+ r.length > 0 && t.push(`${Z(n.target)} got ${r.join(", ")} from .env.example, so the app boots but those features will not work until you set real values.`);
9695
9747
  }
9696
9748
  for (let n of e.steps) n.status === "skipped" && n.id === "migrate" && n.detail && t.push(n.detail);
9697
9749
  return t;
9698
9750
  }
9699
9751
  //#endregion
9700
9752
  //#region src/commands/deploy.ts
9701
- async function Hh(e = {}) {
9753
+ async function Wh(e = {}) {
9702
9754
  let t = T.resolve(e.cwd ?? process.cwd()), n = e.yes === !0;
9703
9755
  _l(), c.intro(N.brandBold("Deploy your stack")), await Zi(t) || L(`${N.path(t)} doesn't look like a Hype Stack project. Run this from the project root.`, { reason: "not_a_project" }), await Ki(t) || L(`${N.path(t)} has no ${N.path(ye)}, so it is not a Hype Stack project this CLI can deploy. Run "hype-stack init" here first, or deploy a project made with "hype-stack create".`, { reason: "not_a_project" });
9704
- let r = await q(t).catch(() => null), i = await Uh(t);
9705
- i ||= Um(Ci(r?.name ?? T.basename(t))), e.environment && (i.environment = e.environment), e.flyOrg && (i.fly = {
9756
+ let r = await q(t).catch(() => null), i = await Gh(t);
9757
+ i ||= Wm(Ci(r?.name ?? T.basename(t))), e.environment && (i.environment = e.environment), e.flyOrg && (i.fly = {
9706
9758
  ...i.fly,
9707
9759
  org: e.flyOrg
9708
9760
  }), e.railwayWorkspace && (i.railway = {
9709
9761
  ...i.railway,
9710
9762
  workspace: e.railwayWorkspace
9711
9763
  });
9712
- let a = await qm(t, r);
9764
+ let a = await Jm(t, r);
9713
9765
  a.length === 0 && L("Found no deployable apps. Expected at least one of apps/backend, apps/frontend, or apps/admin.");
9714
- let o = e.only ?? [], s = Gh(e.assign), l = Wh(e.provider, "--provider"), u = Zd({
9766
+ let o = e.only ?? [], s = qh(e.assign), l = Kh(e.provider, "--provider"), u = Zd({
9715
9767
  config: i,
9716
9768
  defaultProvider: l,
9717
9769
  overrides: s,
9718
9770
  availableTargets: a,
9719
9771
  only: o
9720
- }), d = await Xm(t, Qd(a, o), r);
9721
- n || (u = await qh({
9772
+ }), d = await Zm(t, Qd(a, o), r);
9773
+ n || (u = await Yh({
9722
9774
  assignment: u,
9723
9775
  availableTargets: a,
9724
9776
  requestedTargets: o
@@ -9730,12 +9782,12 @@ async function Hh(e = {}) {
9730
9782
  serveModes: d
9731
9783
  });
9732
9784
  f.length > 0 && (I(tf(f), "Cannot deploy yet"), L("Fix the assignments above and run deploy again.", { reason: "input_required" }));
9733
- let p = Zm(d), m = await Zh({
9785
+ let p = Qm(d), m = await $h({
9734
9786
  cwd: t,
9735
9787
  targets: u.targets,
9736
9788
  serveModes: p,
9737
9789
  stackConfig: r
9738
- }), h = jh({
9790
+ }), h = Nh({
9739
9791
  projectRoot: t,
9740
9792
  config: i,
9741
9793
  assignment: u,
@@ -9743,13 +9795,13 @@ async function Hh(e = {}) {
9743
9795
  serveModes: p,
9744
9796
  staticDirs: m
9745
9797
  });
9746
- I(Lh(h), e.dryRun ? "Deployment plan (dry run)" : "Deployment plan");
9798
+ I(zh(h), e.dryRun ? "Deployment plan (dry run)" : "Deployment plan");
9747
9799
  let g = e.dryRun ? {
9748
9800
  env: {},
9749
9801
  accounts: {}
9750
- } : await bm({
9802
+ } : await xm({
9751
9803
  plan: h,
9752
- providers: Dh(h),
9804
+ providers: kh(h),
9753
9805
  skipPrompts: n
9754
9806
  });
9755
9807
  if (!n && !e.dryRun) {
@@ -9758,27 +9810,27 @@ async function Hh(e = {}) {
9758
9810
  message: "Deploying creates billable infrastructure. Re-run with --yes to confirm non-interactively."
9759
9811
  });
9760
9812
  let e = await c.confirm({
9761
- message: `Create and deploy this on ${Qh(h.targets.map((e) => e.provider))}?`,
9813
+ message: `Create and deploy this on ${eg(h.targets.map((e) => e.provider))}?`,
9762
9814
  initialValue: !0
9763
9815
  });
9764
9816
  (c.isCancel(e) || !e) && R();
9765
9817
  }
9766
- let _ = await Ih(t, h.targets);
9767
- I(Rh(fh({
9818
+ let _ = await Rh(t, h.targets);
9819
+ I(Bh(mh({
9768
9820
  plan: h,
9769
9821
  localEnv: _.local,
9770
9822
  declaredKeys: _.declared,
9771
9823
  exampleEnv: _.example
9772
9824
  })), "Environment"), await Fd(t).catch(() => null);
9773
- let v = At(), y = [], b = e.dryRun ? Ff({
9825
+ let v = At(), y = [], b = e.dryRun ? If({
9774
9826
  onCommand: (e) => y.push(e),
9775
- responses: nh
9776
- }) : Pf({
9827
+ responses: rh
9828
+ }) : Ff({
9777
9829
  onCommand: (e) => y.push(e),
9778
9830
  env: g.env
9779
9831
  });
9780
9832
  v.start(e.dryRun ? "Walking the plan" : "Deploying");
9781
- let x = await wh({
9833
+ let x = await Eh({
9782
9834
  plan: h,
9783
9835
  runner: b,
9784
9836
  localEnv: _.local,
@@ -9790,61 +9842,61 @@ async function Hh(e = {}) {
9790
9842
  knownAccounts: g.accounts,
9791
9843
  log: (e) => v.message(e)
9792
9844
  });
9793
- if (v.stop(x.ok ? N.success("Deploy finished") : N.error("Deploy stopped")), I(zh(x), "Steps"), e.dryRun) {
9845
+ if (v.stop(x.ok ? N.success("Deploy finished") : N.error("Deploy stopped")), I(Vh(x), "Steps"), e.dryRun) {
9794
9846
  I(y.map((e) => N.command(e)).join("\n"), "Commands that would run"), c.outro(N.muted("Dry run only. No infrastructure was created."));
9795
9847
  return;
9796
9848
  }
9797
- if (await Hm(t, Ph(i, x.plan)), !x.ok) {
9849
+ if (await Um(t, Ih(i, x.plan)), !x.ok) {
9798
9850
  let e = x.steps.filter((e) => e.status === "failed");
9799
9851
  I(`${e.length > 0 ? e.map((e) => `${e.label} failed.${e.detail ? `\n${e.detail}` : ""}`).join("\n\n") : "A step failed."}\n\nWhat succeeded is saved in ${N.path(X)}, so re-running picks up from here.`, "Deploy failed"), L("Deploy did not finish.");
9800
9852
  }
9801
- I(Bh(x), "Live");
9802
- let S = Vh(x);
9853
+ I(Hh(x), "Live");
9854
+ let S = Uh(x);
9803
9855
  S.length > 0 && I(S.map((e) => `${N.warning("!")} ${e}`).join("\n\n"), "Still to do"), c.outro(N.brand("Shipped."));
9804
9856
  }
9805
- async function Uh(e) {
9857
+ async function Gh(e) {
9806
9858
  try {
9807
- return await Vm(e);
9859
+ return await Hm(e);
9808
9860
  } catch (e) {
9809
9861
  L(e instanceof Error ? e.message : String(e));
9810
9862
  }
9811
9863
  }
9812
- function Wh(e, t) {
9864
+ function Kh(e, t) {
9813
9865
  if (e) return Kd(e) || L(`Unknown provider "${e}" for ${t}. Pick one of ${Object.keys(Wd).join(", ")}.`), e;
9814
9866
  }
9815
- function Gh(e) {
9867
+ function qh(e) {
9816
9868
  let t = {};
9817
9869
  for (let [n, r] of Object.entries(e ?? {})) {
9818
- let e = Wh(r, `--${n}`);
9870
+ let e = Kh(r, `--${n}`);
9819
9871
  e && (t[n] = e);
9820
9872
  }
9821
9873
  return t;
9822
9874
  }
9823
- function Kh(e) {
9875
+ function Jh(e) {
9824
9876
  let { assignment: t, availableTargets: n, requestedTargets: r } = e, i = Qd(n, r).filter((e) => !t.targets[e]);
9825
9877
  return {
9826
9878
  targets: i,
9827
9879
  services: t.targets.backend !== void 0 || i.includes("backend") ? Bd.filter((e) => !t.services[e]) : []
9828
9880
  };
9829
9881
  }
9830
- async function qh(e) {
9882
+ async function Yh(e) {
9831
9883
  let t = {
9832
9884
  targets: { ...e.assignment.targets },
9833
9885
  services: { ...e.assignment.services }
9834
- }, { targets: n, services: r } = Kh(e);
9886
+ }, { targets: n, services: r } = Jh(e);
9835
9887
  if (n.length + r.length > 1) {
9836
- let e = await Jh();
9888
+ let e = await Xh();
9837
9889
  if (e) {
9838
9890
  for (let r of n) t.targets[r] = e;
9839
9891
  for (let n of r) t.services[n] = e;
9840
9892
  return t;
9841
9893
  }
9842
9894
  }
9843
- for (let e of n) t.targets[e] = await Xh(e, Jd(e));
9844
- for (let e of r) t.services[e] = await Xh(e, Jd(e));
9895
+ for (let e of n) t.targets[e] = await Qh(e, Jd(e));
9896
+ for (let e of r) t.services[e] = await Qh(e, Jd(e));
9845
9897
  return t;
9846
9898
  }
9847
- async function Jh() {
9899
+ async function Xh() {
9848
9900
  let e = await c.select({
9849
9901
  message: `Where should ${N.highlight("your stack")} live?`,
9850
9902
  options: [...Vd.map((e) => ({
@@ -9852,16 +9904,16 @@ async function Jh() {
9852
9904
  label: qd(e),
9853
9905
  hint: `everything on ${Wd[e].bin}`
9854
9906
  })), {
9855
- value: Yh,
9907
+ value: Zh,
9856
9908
  label: "Mix providers",
9857
9909
  hint: "choose for each app and service"
9858
9910
  }],
9859
9911
  initialValue: Vd[0]
9860
9912
  });
9861
- return c.isCancel(e) && R(), e === Yh ? void 0 : e;
9913
+ return c.isCancel(e) && R(), e === Zh ? void 0 : e;
9862
9914
  }
9863
- var Yh = "__mixed__";
9864
- async function Xh(e, t) {
9915
+ var Zh = "__mixed__";
9916
+ async function Qh(e, t) {
9865
9917
  if (t.length === 0 && L(`Nothing in this CLI can host ${Z(e)}. Provision it yourself and add it to the "${Id}" block of ${X}.`), t.length === 1) return t[0];
9866
9918
  let n = await c.select({
9867
9919
  message: `Where should ${N.highlight(Z(e))} live?`,
@@ -9874,17 +9926,17 @@ async function Xh(e, t) {
9874
9926
  });
9875
9927
  return c.isCancel(n) && R(), n;
9876
9928
  }
9877
- async function Zh(e) {
9878
- let { cwd: t, targets: n, serveModes: r, stackConfig: i } = e, a = Object.keys(n).filter((e) => Gd(e) && r[e] === "static"), o = await Promise.all(a.map(async (e) => [e, await Qm(Km(t, e, i), e)]));
9929
+ async function $h(e) {
9930
+ let { cwd: t, targets: n, serveModes: r, stackConfig: i } = e, a = Object.keys(n).filter((e) => Gd(e) && r[e] === "static"), o = await Promise.all(a.map(async (e) => [e, await $m(qm(t, e, i), e)]));
9879
9931
  return Object.fromEntries(o);
9880
9932
  }
9881
- function Qh(e) {
9933
+ function eg(e) {
9882
9934
  let t = [...new Set(e)].map(qd);
9883
9935
  return t.length <= 1 ? t[0] ?? "your provider" : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
9884
9936
  }
9885
9937
  //#endregion
9886
9938
  //#region src/commands/login.ts
9887
- async function $h() {
9939
+ async function tg() {
9888
9940
  vl(), c.intro(N.brandBold("Log in to Hype Stack")), Xe() && c.log.warn(`${Je} is set and takes priority over this login. Unset it to use the browser session.`), c.log.step("Opening your browser to sign in...");
9889
9941
  let e;
9890
9942
  try {
@@ -9898,7 +9950,7 @@ async function $h() {
9898
9950
  }
9899
9951
  //#endregion
9900
9952
  //#region src/commands/logout.ts
9901
- async function eg() {
9953
+ async function ng() {
9902
9954
  vl(), c.intro(N.brandBold("Log out of Hype Stack"));
9903
9955
  let e = j(), t = await Ze(e);
9904
9956
  if (!t) {
@@ -9909,8 +9961,8 @@ async function eg() {
9909
9961
  }
9910
9962
  //#endregion
9911
9963
  //#region src/commands/mcp.ts
9912
- async function tg(e = {}) {
9913
- let t = rg(e.editor), n = xu(t), r = ig(e.scope, t, n), i = ng(e.token);
9964
+ async function rg(e = {}) {
9965
+ let t = ag(e.editor), n = xu(t), r = og(e.scope, t, n), i = ig(e.token);
9914
9966
  if (e.print) {
9915
9967
  process.stdout.write(wu(t, i));
9916
9968
  return;
@@ -9924,19 +9976,19 @@ async function tg(e = {}) {
9924
9976
  });
9925
9977
  a.changed ? c.log.success(`Wrote ${N.path(a.configPath)}`) : c.log.info(N.muted(`${N.path(a.configPath)} is already up to date.`)), i && c.log.warn(N.muted(`${Je} is stored in plain text. Keep this file out of version control.`)), c.outro(N.muted("Restart your editor to pick up the server."));
9926
9978
  }
9927
- function ng(e) {
9979
+ function ig(e) {
9928
9980
  return e?.trim() || void 0;
9929
9981
  }
9930
- function rg(e) {
9982
+ function ag(e) {
9931
9983
  return e ? (vu(e) || L(`Unknown editor "${e}". Expected one of: ${hu.join(", ")}.`), e) : "cursor";
9932
9984
  }
9933
- function ig(e, t, n) {
9985
+ function og(e, t, n) {
9934
9986
  let r = e ?? n[0];
9935
9987
  return r !== "global" && r !== "project" && L(`Unknown scope "${r}". Expected global or project.`), n.includes(r) || L(`${t} does not support ${r} scope. Supported: ${n.join(", ")}.`), r;
9936
9988
  }
9937
9989
  //#endregion
9938
9990
  //#region src/ui/env-prompt.ts
9939
- var ag = S("✔", "√"), og = S("✘", "x"), sg = "\x1B[7m \x1B[27m", cg = class extends ae {
9991
+ var sg = S("✔", "√"), cg = S("✘", "x"), lg = "\x1B[7m \x1B[27m", ug = class extends ae {
9940
9992
  constructor(e) {
9941
9993
  super({
9942
9994
  input: e.input,
@@ -9951,9 +10003,9 @@ var ag = S("✔", "√"), og = S("✘", "x"), sg = "\x1B[7m \x1B[27m", cg = clas
9951
10003
  let { key: e, section: t, linkUrl: n, hint: r, checklist: i, currentMasked: a, progress: o } = this.promptOptions, s = y.withGuide, c = s ? `${k("gray", l)}\n` : "";
9952
10004
  if (this.state === "submit") {
9953
10005
  let t = (this.value ?? "").trim(), n = t ? N.muted(_s(t)) : a ? N.muted(`kept ${a}`) : N.muted("left empty");
9954
- return `${c}${k("green", ag)} ${N.bold(e)} ${n}`;
10006
+ return `${c}${k("green", sg)} ${N.bold(e)} ${n}`;
9955
10007
  }
9956
- if (this.state === "cancel") return `${c}${k("red", og)} ${k(["strikethrough", "dim"], e)}`;
10008
+ if (this.state === "cancel") return `${c}${k("red", cg)} ${k(["strikethrough", "dim"], e)}`;
9957
10009
  let d = x(this.state), f = s ? `${d} ` : "", p = b(this.state), m = o ? ` ${N.muted(o)}` : "", h = `${c}${p} ${N.bold(e)}${m}`, g = [];
9958
10010
  if (t) {
9959
10011
  let e = n ? ` ${P(n)}` : "";
@@ -9961,19 +10013,19 @@ var ag = S("✔", "√"), og = S("✘", "x"), sg = "\x1B[7m \x1B[27m", cg = clas
9961
10013
  }
9962
10014
  if (i && i.length > 0) for (let e of i) g.push(`${f}${F.bullet} ${N.description(e)}`);
9963
10015
  r && g.push(`${f}${N.description(r)}`);
9964
- let _ = this.userInput !== "", v = a ? `${a} (Enter keeps this)` : "type a value, or Enter to skip", S = _ ? `${f}${F.arrow} ${this.userInputWithCursor}` : `${f}${F.arrow} ${sg} ${N.muted(v)}`;
10016
+ let _ = this.userInput !== "", v = a ? `${a} (Enter keeps this)` : "type a value, or Enter to skip", S = _ ? `${f}${F.arrow} ${this.userInputWithCursor}` : `${f}${F.arrow} ${lg} ${N.muted(v)}`;
9965
10017
  g.push(S), this.state === "error" && g.push(`${f}${k("yellow", this.error)}`);
9966
10018
  let C = s ? this.state === "error" ? k("yellow", u) : k("cyan", u) : "";
9967
10019
  return `${h}\n${g.join("\n")}\n${C}`;
9968
10020
  }
9969
10021
  };
9970
- async function lg(e) {
9971
- let t = await new cg(e).prompt();
10022
+ async function dg(e) {
10023
+ let t = await new ug(e).prompt();
9972
10024
  return g(t) || typeof t == "string" ? t : "";
9973
10025
  }
9974
10026
  //#endregion
9975
10027
  //#region src/commands/onboard.ts
9976
- async function ug(e = {}) {
10028
+ async function fg(e = {}) {
9977
10029
  let t = e.cwd ?? process.cwd();
9978
10030
  e.skipBanner || _l(), c.intro(N.brandBold("Onboard your stack"));
9979
10031
  let n;
@@ -9988,12 +10040,12 @@ async function ug(e = {}) {
9988
10040
  for (let e of r) await bs(e);
9989
10041
  let i = await Ss(t, n);
9990
10042
  i.length > 0 && c.log.success(`Generated ${N.highlight(String(i.length))} secrets: ${i.map((e) => e.key).join(", ")}`);
9991
- let a = await dg(t, n, r), o = a.filter((e) => e.setup.setup === "required" && !e.isSet), s = a.filter((e) => e.setup.setup === "required" && e.isSet), l = a.filter((e) => e.setup.setup === "optional"), u = [];
9992
- e.yes ? u.push(...o, ...l.filter((e) => !e.isSet)) : (u.push(...await fg(o)), u.push(...await pg(l)), await mg(s)), yg(u, t);
10043
+ let a = await pg(t, n, r), o = a.filter((e) => e.setup.setup === "required" && !e.isSet), s = a.filter((e) => e.setup.setup === "required" && e.isSet), l = a.filter((e) => e.setup.setup === "optional"), u = [];
10044
+ e.yes ? u.push(...o, ...l.filter((e) => !e.isSet)) : (u.push(...await mg(o)), u.push(...await hg(l)), await gg(s)), xg(u, t);
9993
10045
  let d = Ii(n.installedPacks ?? []);
9994
10046
  d.length > 0 && I(d.map((e) => ` ${N.muted("·")} ${e}`).join("\n"), "Tips"), c.outro(N.brand(`All set. Run ${N.command("pnpm dev")} to start your app.`));
9995
10047
  }
9996
- async function dg(e, t, n) {
10048
+ async function pg(e, t, n) {
9997
10049
  let r = t.onboarding?.envVars ?? [], i = t.onboarding?.envSections ?? [], a = [];
9998
10050
  for (let e of n) {
9999
10051
  let t = T.join(T.dirname(e), ".env"), [n, o] = await Promise.all([C.readFile(e, "utf-8"), ys(t)]);
@@ -10013,40 +10065,40 @@ async function dg(e, t, n) {
10013
10065
  }
10014
10066
  return a;
10015
10067
  }
10016
- async function fg(e) {
10017
- let t = [], n = hg(e);
10068
+ async function mg(e) {
10069
+ let t = [], n = _g(e);
10018
10070
  if (n.size === 0) return t;
10019
10071
  let r = [...n.entries()].map(([e, t]) => `${N.bold(e)} ${N.muted(`(${t.length})`)}`).join(", ");
10020
10072
  c.log.step(`Keys needed for: ${r}`);
10021
10073
  for (let [e, r] of n) {
10022
10074
  let n = `${r.length} value${r.length === 1 ? "" : "s"}`;
10023
- if (!await gg(`Set up ${N.bold(e)} now? ${N.muted(`(${n})`)}`, !0)) {
10075
+ if (!await vg(`Set up ${N.bold(e)} now? ${N.muted(`(${n})`)}`, !0)) {
10024
10076
  t.push(...r);
10025
10077
  continue;
10026
10078
  }
10027
- await _g(r);
10079
+ await yg(r);
10028
10080
  }
10029
10081
  return t;
10030
10082
  }
10031
- async function pg(e) {
10083
+ async function hg(e) {
10032
10084
  let t = [];
10033
- for (let [n, r] of hg(e)) {
10085
+ for (let [n, r] of _g(e)) {
10034
10086
  let e = r.every((e) => e.isSet), i = `${r.length} value${r.length === 1 ? "" : "s"}`;
10035
- if (!await gg(e ? `Update ${N.bold(n)}? ${N.muted(`(${i}, already set)`)}` : `Set up ${N.bold(n)} now? ${N.muted(`(${i}, optional)`)}`)) {
10087
+ if (!await vg(e ? `Update ${N.bold(n)}? ${N.muted(`(${i}, already set)`)}` : `Set up ${N.bold(n)} now? ${N.muted(`(${i}, optional)`)}`)) {
10036
10088
  t.push(...r.filter((e) => !e.isSet));
10037
10089
  continue;
10038
10090
  }
10039
- await _g(r);
10091
+ await yg(r);
10040
10092
  }
10041
10093
  return t;
10042
10094
  }
10043
- async function mg(e) {
10044
- for (let [t, n] of hg(e)) {
10095
+ async function gg(e) {
10096
+ for (let [t, n] of _g(e)) {
10045
10097
  let e = `${n.length} value${n.length === 1 ? "" : "s"}`;
10046
- await gg(`Update ${N.bold(t)}? ${N.muted(`(${e}, already set)`)}`) && await _g(n);
10098
+ await vg(`Update ${N.bold(t)}? ${N.muted(`(${e}, already set)`)}`) && await yg(n);
10047
10099
  }
10048
10100
  }
10049
- function hg(e) {
10101
+ function _g(e) {
10050
10102
  let t = /* @__PURE__ */ new Map();
10051
10103
  for (let n of e) {
10052
10104
  let e = n.setup.group ?? n.section, r = t.get(e);
@@ -10054,20 +10106,20 @@ function hg(e) {
10054
10106
  }
10055
10107
  return t;
10056
10108
  }
10057
- async function gg(e, t = !1) {
10109
+ async function vg(e, t = !1) {
10058
10110
  let n = await c.confirm({
10059
10111
  message: e,
10060
10112
  initialValue: t
10061
10113
  });
10062
10114
  return c.isCancel(n) && R(), n === !0;
10063
10115
  }
10064
- async function _g(e) {
10116
+ async function yg(e) {
10065
10117
  let t = ji(e[0].section);
10066
10118
  t.link && c.log.info(N.muted(t.link));
10067
- for (let [t, n] of e.entries()) await vg(n, `${t + 1}/${e.length}`);
10119
+ for (let [t, n] of e.entries()) await bg(n, `${t + 1}/${e.length}`);
10068
10120
  }
10069
- async function vg(e, t) {
10070
- let n = ji(e.section), r = await lg({
10121
+ async function bg(e, t) {
10122
+ let n = ji(e.section), r = await dg({
10071
10123
  key: e.key,
10072
10124
  section: e.section,
10073
10125
  linkUrl: n.link,
@@ -10080,7 +10132,7 @@ async function vg(e, t) {
10080
10132
  let i = (typeof r == "string" ? r : "").trim();
10081
10133
  i !== "" && await xs(e.envPath, e.key, i);
10082
10134
  }
10083
- function yg(e, t) {
10135
+ function xg(e, t) {
10084
10136
  if (e.length === 0) return;
10085
10137
  let n = /* @__PURE__ */ new Map();
10086
10138
  for (let t of e) {
@@ -10100,16 +10152,16 @@ function yg(e, t) {
10100
10152
  }
10101
10153
  //#endregion
10102
10154
  //#region src/core/templates.ts
10103
- var bg = H.createRequest()({
10155
+ var Sg = H.createRequest()({
10104
10156
  endpoint: "/templates/list",
10105
10157
  method: "GET"
10106
10158
  });
10107
- async function xg() {
10108
- let { data: e, error: t } = await bg.send();
10159
+ async function Cg() {
10160
+ let { data: e, error: t } = await Sg.send();
10109
10161
  if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
10110
10162
  return e.templates;
10111
10163
  }
10112
- async function Sg(e) {
10164
+ async function wg(e) {
10113
10165
  let { data: t, error: n, status: r } = await H.createRequest()({
10114
10166
  endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
10115
10167
  method: "GET"
@@ -10118,7 +10170,7 @@ async function Sg(e) {
10118
10170
  if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
10119
10171
  return t;
10120
10172
  }
10121
- async function Cg(e, t = {}) {
10173
+ async function Tg(e, t = {}) {
10122
10174
  let n = H.createRequest()({
10123
10175
  endpoint: `/templates/${encodeURIComponent(e)}/download`,
10124
10176
  method: "POST"
@@ -10155,7 +10207,7 @@ async function Cg(e, t = {}) {
10155
10207
  }
10156
10208
  //#endregion
10157
10209
  //#region src/commands/template.ts
10158
- async function wg(t = {}) {
10210
+ async function Eg(t = {}) {
10159
10211
  let n = t.cwd ?? process.cwd();
10160
10212
  _l(), await $c();
10161
10213
  let r = c.spinner();
@@ -10169,7 +10221,7 @@ async function wg(t = {}) {
10169
10221
  r.stop("Packs loaded"), r.start("Loading templates...");
10170
10222
  let a;
10171
10223
  try {
10172
- a = await xg();
10224
+ a = await Cg();
10173
10225
  } catch (e) {
10174
10226
  r.stop("Failed to load templates"), L(`Could not reach Hype Stack. Check your connection and try again.\n${Xu(e)}`);
10175
10227
  }
@@ -10192,7 +10244,7 @@ async function wg(t = {}) {
10192
10244
  s || (r.stop("Template not found"), L(`Template "${o}" not found. Available: ${a.map((e) => e.id).join(", ") || "(none)"}`)), r.stop(`Template: ${s.name}`);
10193
10245
  let l;
10194
10246
  try {
10195
- l = await Sg(s.id);
10247
+ l = await wg(s.id);
10196
10248
  } catch (e) {
10197
10249
  L(Xu(e));
10198
10250
  }
@@ -10214,7 +10266,7 @@ async function wg(t = {}) {
10214
10266
  p || L(d ? `Could not read ${N.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${N.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), p.paths || L(`${N.path("stack.json")} is missing ${N.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`);
10215
10267
  let m = d ?? n;
10216
10268
  c.intro(N.brandBold("Install a template"));
10217
- let h = p.installedPacks ?? [], g = new Set(h), v = new Map(i.map((e) => [e.name, e])), y = (await Ye(j()))?.token ?? null, b = await Tg(s, t.variants, t.yes ?? !1), x = il(s.slots, b), S = al(s.slots, s.packs, x), w = await Eg({
10269
+ let h = p.installedPacks ?? [], g = new Set(h), v = new Map(i.map((e) => [e.name, e])), y = (await Ye(j()))?.token ?? null, b = await Dg(s, t.variants, t.yes ?? !1), x = il(s.slots, b), S = al(s.slots, s.packs, x), w = await Og({
10218
10270
  packs: i,
10219
10271
  templatePacks: S,
10220
10272
  installedSet: g,
@@ -10289,7 +10341,7 @@ async function wg(t = {}) {
10289
10341
  r.stop("Files installed"), n.installed.length > 0 && c.log.success(`${N.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && (c.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`), ad(n.skipped));
10290
10342
  for (let e of n.errors) c.log.error(e);
10291
10343
  r.start("Applying template overrides...");
10292
- let i = await Cg(s.id, { token: y });
10344
+ let i = await Tg(s.id, { token: y });
10293
10345
  i.status === "denied" && (r.stop("Template download denied"), L(td(s.id, i.reason))), se = i.templateDir;
10294
10346
  let a = await Tc({
10295
10347
  manifest: l,
@@ -10326,7 +10378,7 @@ async function wg(t = {}) {
10326
10378
  customization: n
10327
10379
  }), c.log.success(`Applied the ${nc(n.theme)} theme, ${e(n.radius)} corners, and ${n.mode} mode`);
10328
10380
  }
10329
- await Dg({
10381
+ await kg({
10330
10382
  prepared: ae,
10331
10383
  templateNpm: l.dependencies_npm,
10332
10384
  paths: p.paths,
@@ -10353,7 +10405,7 @@ async function wg(t = {}) {
10353
10405
  });
10354
10406
  }
10355
10407
  }
10356
- async function Tg(e, t, n) {
10408
+ async function Dg(e, t, n) {
10357
10409
  let r = {};
10358
10410
  for (let i of e.slots) {
10359
10411
  if (t?.[i.family]) {
@@ -10377,7 +10429,7 @@ async function Tg(e, t, n) {
10377
10429
  }
10378
10430
  return r;
10379
10431
  }
10380
- async function Eg(e) {
10432
+ async function Og(e) {
10381
10433
  let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
10382
10434
  if (i.packs && i.packs.length > 0) {
10383
10435
  let e = i.packs.filter((e) => !t.some((t) => t.name === e));
@@ -10399,7 +10451,7 @@ async function Eg(e) {
10399
10451
  });
10400
10452
  return _(c) && L("Cancelled.", { code: 0 }), c;
10401
10453
  }
10402
- async function Dg(e) {
10454
+ async function kg(e) {
10403
10455
  let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o = Ju(t.map((e) => e.manifest.dependencies_npm)), s = qu(n ? Ju([o, n]) : o, r);
10404
10456
  if (s.errors.length > 0) {
10405
10457
  for (let e of s.errors) c.log.error(e);
@@ -10412,9 +10464,9 @@ async function Dg(e) {
10412
10464
  }
10413
10465
  //#endregion
10414
10466
  //#region src/mcp/guard.ts
10415
- var Og = null;
10416
- function kg() {
10417
- if (Og) return Og.protocolStream;
10467
+ var Ag = null;
10468
+ function jg() {
10469
+ if (Ag) return Ag.protocolStream;
10418
10470
  let e = process.stdout.write.bind(process.stdout), t = process.stdout.write, n = console.log, r = console.info, i = console.debug, a = console.dir, o = new fe({
10419
10471
  write(t, n, r) {
10420
10472
  e(t, (e) => r(e ?? null));
@@ -10423,7 +10475,7 @@ function kg() {
10423
10475
  e();
10424
10476
  }
10425
10477
  }), s = ((e, t, n) => typeof t == "function" ? process.stderr.write(e, t) : process.stderr.write(e, t, n));
10426
- return process.stdout.write = s, console.log = console.error, console.info = console.error, console.debug = console.error, console.dir = console.error, Og = {
10478
+ return process.stdout.write = s, console.log = console.error, console.info = console.error, console.debug = console.error, console.dir = console.error, Ag = {
10427
10479
  protocolStream: o,
10428
10480
  restore: () => {
10429
10481
  process.stdout.write = t, console.log = n, console.info = r, console.debug = i, console.dir = a;
@@ -10432,22 +10484,22 @@ function kg() {
10432
10484
  }
10433
10485
  //#endregion
10434
10486
  //#region src/mcp/result.ts
10435
- async function Ag(e) {
10487
+ async function Mg(e) {
10436
10488
  ot();
10437
10489
  try {
10438
- return jg({
10490
+ return Ng({
10439
10491
  ...await e(),
10440
10492
  ok: !0,
10441
10493
  logs: st()
10442
10494
  }, !1);
10443
10495
  } catch (e) {
10444
- return lt(e) ? jg({
10496
+ return lt(e) ? Ng({
10445
10497
  ok: !1,
10446
10498
  reason: e.reason,
10447
10499
  message: e.message,
10448
10500
  details: e.details,
10449
10501
  logs: st()
10450
- }, !1) : jg({
10502
+ }, !1) : Ng({
10451
10503
  ok: !1,
10452
10504
  reason: "failed",
10453
10505
  message: e instanceof Error ? e.message : String(e),
@@ -10456,7 +10508,7 @@ async function Ag(e) {
10456
10508
  }, !0);
10457
10509
  }
10458
10510
  }
10459
- function jg(e, t) {
10511
+ function Ng(e, t) {
10460
10512
  return {
10461
10513
  content: [{
10462
10514
  type: "text",
@@ -10468,7 +10520,7 @@ function jg(e, t) {
10468
10520
  }
10469
10521
  //#endregion
10470
10522
  //#region src/mcp/tools/context.ts
10471
- async function Mg() {
10523
+ async function Pg() {
10472
10524
  let e = await Ye(j());
10473
10525
  return e ? {
10474
10526
  token: e.token,
@@ -10478,26 +10530,26 @@ async function Mg() {
10478
10530
  source: "none"
10479
10531
  };
10480
10532
  }
10481
- function Ng(e) {
10533
+ function Fg(e) {
10482
10534
  return T.resolve(e ?? process.cwd());
10483
10535
  }
10484
- var Pg = {
10536
+ var Ig = {
10485
10537
  envVar: Je,
10486
10538
  loginCommand: "npx @hype-stack/cli login"
10487
- }, Fg = {
10539
+ }, Lg = {
10488
10540
  packs: A.array(A.string()).min(1).describe("Pack names to install. Append @frontend or @admin to a layout pack to target one shell."),
10489
10541
  cwd: A.string().optional().describe("Project directory. Defaults to the workspace the server was started in."),
10490
10542
  onConflict: A.enum(["keep", "overwrite"]).default("keep").describe("What to do with files that already exist: keep them, or let the pack overwrite them")
10491
10543
  };
10492
- async function Ig(e) {
10493
- let t = Ng(e.cwd), n = await Lg(t);
10544
+ async function Rg(e) {
10545
+ let t = Fg(e.cwd), n = await zg(t);
10494
10546
  await ud({
10495
10547
  cwd: t,
10496
10548
  packs: e.packs,
10497
10549
  force: e.onConflict === "overwrite",
10498
10550
  yes: !0
10499
10551
  });
10500
- let r = await Lg(t), i = r.filter((e) => !n.includes(e));
10552
+ let r = await zg(t), i = r.filter((e) => !n.includes(e));
10501
10553
  return {
10502
10554
  cwd: t,
10503
10555
  installed: i,
@@ -10505,21 +10557,21 @@ async function Ig(e) {
10505
10557
  followUp: i.length > 0 ? [...Pc, "npx @hype-stack/cli onboard"] : []
10506
10558
  };
10507
10559
  }
10508
- async function Lg(e) {
10560
+ async function zg(e) {
10509
10561
  return (await q(e).catch(() => null))?.installedPacks ?? [];
10510
10562
  }
10511
10563
  //#endregion
10512
10564
  //#region src/mcp/tools/apply-template.ts
10513
- var Rg = {
10565
+ var Bg = {
10514
10566
  templateId: A.string().min(1).describe("Template id, e.g. vault. Use search_catalog to find one."),
10515
10567
  cwd: A.string().optional().describe("Project directory. Defaults to the workspace the server was started in."),
10516
10568
  variants: A.record(A.string(), A.string()).optional().describe("Slot overrides keyed by family, e.g. { \"starter-saas\": \"starter-saas-better-auth\" }"),
10517
10569
  packs: A.array(A.string()).optional().describe("Extra packs to install on top of the template"),
10518
10570
  onConflict: A.enum(["keep", "overwrite"]).default("keep").describe("What to do with files that already exist: keep them, or let the template overwrite them")
10519
10571
  };
10520
- async function zg(e) {
10521
- let t = Ng(e.cwd), n = await Bg(t);
10522
- await wg({
10572
+ async function Vg(e) {
10573
+ let t = Fg(e.cwd), n = await Hg(t);
10574
+ await Eg({
10523
10575
  cwd: t,
10524
10576
  templateId: e.templateId,
10525
10577
  variants: e.variants,
@@ -10527,7 +10579,7 @@ async function zg(e) {
10527
10579
  force: e.onConflict === "overwrite",
10528
10580
  yes: !0
10529
10581
  });
10530
- let r = await Bg(t);
10582
+ let r = await Hg(t);
10531
10583
  return {
10532
10584
  cwd: t,
10533
10585
  templateId: e.templateId,
@@ -10536,21 +10588,21 @@ async function zg(e) {
10536
10588
  followUp: [...Pc, "npx @hype-stack/cli onboard"]
10537
10589
  };
10538
10590
  }
10539
- async function Bg(e) {
10591
+ async function Hg(e) {
10540
10592
  return (await q(e).catch(() => null))?.installedPacks ?? [];
10541
10593
  }
10542
10594
  //#endregion
10543
10595
  //#region src/mcp/tools/auth-status.ts
10544
- var Vg = {};
10545
- async function Hg() {
10546
- let { token: e, source: t } = await Mg();
10596
+ var Ug = {};
10597
+ async function Wg() {
10598
+ let { token: e, source: t } = await Pg();
10547
10599
  if (!e) return {
10548
10600
  authenticated: !1,
10549
10601
  tokenSource: "none",
10550
10602
  apiUrl: j(),
10551
- hint: `Run '${Pg.loginCommand}' in your terminal, or add ${Pg.envVar} to this server's env block in your editor's MCP config.`,
10603
+ hint: `Run '${Ig.loginCommand}' in your terminal, or add ${Ig.envVar} to this server's env block in your editor's MCP config.`,
10552
10604
  apiKeysUrl: `${Re()}/api-keys`,
10553
- ...Pg
10605
+ ...Ig
10554
10606
  };
10555
10607
  let n = await Yr(e);
10556
10608
  return n ? {
@@ -10563,14 +10615,14 @@ async function Hg() {
10563
10615
  authenticated: !1,
10564
10616
  tokenSource: t,
10565
10617
  apiUrl: j(),
10566
- hint: t === "env" ? `The token in ${Pg.envVar} was rejected. It may be expired or revoked; mint a new one.` : `Your saved login was rejected. Run '${Pg.loginCommand}' again.`,
10618
+ hint: t === "env" ? `The token in ${Ig.envVar} was rejected. It may be expired or revoked; mint a new one.` : `Your saved login was rejected. Run '${Ig.loginCommand}' again.`,
10567
10619
  apiKeysUrl: `${Re()}/api-keys`,
10568
- ...Pg
10620
+ ...Ig
10569
10621
  };
10570
10622
  }
10571
10623
  //#endregion
10572
10624
  //#region src/mcp/tools/create-application.ts
10573
- var Ug = {
10625
+ var Gg = {
10574
10626
  name: A.string().min(1).describe("Application name. Becomes the folder name and the package scope."),
10575
10627
  directory: A.string().optional().describe("Parent folder to create the app inside. Defaults to the current workspace."),
10576
10628
  editors: A.array(A.enum(Ee)).optional().describe("AI editors to ship rule formats for. Pass every editor the team uses, they coexist. Defaults to cursor."),
@@ -10581,8 +10633,8 @@ var Ug = {
10581
10633
  adminRadius: A.string().optional().describe("Admin corner radius. Defaults to the frontend radius."),
10582
10634
  mode: A.enum(["light", "dark"]).optional().describe("Color mode the app boots in")
10583
10635
  };
10584
- async function Wg(e) {
10585
- let t = Ng(e.directory), n = Gg(e), r = await sd({
10636
+ async function Kg(e) {
10637
+ let t = Fg(e.directory), n = qg(e), r = await sd({
10586
10638
  name: e.name,
10587
10639
  parentDirectory: t,
10588
10640
  editors: n,
@@ -10598,19 +10650,19 @@ async function Wg(e) {
10598
10650
  return {
10599
10651
  projectRoot: r,
10600
10652
  editors: n,
10601
- mcpConfigPaths: Kg(n, r),
10653
+ mcpConfigPaths: Jg(n, r),
10602
10654
  followUp: [`cd ${r}`, ...Pc]
10603
10655
  };
10604
10656
  }
10605
- function Gg(e) {
10657
+ function qg(e) {
10606
10658
  let { editors: t, unknown: n } = Ae([...e.editors ?? [], ...e.editor ? [e.editor] : []]);
10607
10659
  if (n.length > 0) throw Error(`Unknown editor "${n.join(", ")}". Expected one of: ${Ee.join(", ")}.`);
10608
10660
  return t.length > 0 ? t : [De];
10609
10661
  }
10610
- function Kg(e, t) {
10611
- return bu(e).map((e) => qg(e, t)).filter((e) => e !== null);
10662
+ function Jg(e, t) {
10663
+ return bu(e).map((e) => Yg(e, t)).filter((e) => e !== null);
10612
10664
  }
10613
- function qg(e, t) {
10665
+ function Yg(e, t) {
10614
10666
  try {
10615
10667
  return Su({
10616
10668
  editor: e,
@@ -10623,8 +10675,8 @@ function qg(e, t) {
10623
10675
  }
10624
10676
  //#endregion
10625
10677
  //#region src/core/env-status.ts
10626
- async function Jg(e, t) {
10627
- let n = t?.onboarding?.envSections ?? [], r = t?.onboarding?.envVars ?? [], i = await ms(e), a = await Promise.all(i.map((t) => Yg({
10678
+ async function Xg(e, t) {
10679
+ let n = t?.onboarding?.envSections ?? [], r = t?.onboarding?.envVars ?? [], i = await ms(e), a = await Promise.all(i.map((t) => Zg({
10628
10680
  examplePath: t,
10629
10681
  projectRoot: e,
10630
10682
  installedEnvSections: n,
@@ -10635,7 +10687,7 @@ async function Jg(e, t) {
10635
10687
  missingCount: a.reduce((e, t) => e + t.sections.filter((e) => e.relevant).reduce((e, t) => e + t.vars.filter((e) => e.setup === "required" && e.state !== "filled").length, 0), 0)
10636
10688
  };
10637
10689
  }
10638
- async function Yg(e) {
10690
+ async function Zg(e) {
10639
10691
  let { examplePath: t, projectRoot: n, installedEnvSections: r, recorded: i } = e, a = T.join(T.dirname(t), ".env"), o = await C.readFile(t, "utf-8"), s = await ys(a), c = hs(o).map((e) => {
10640
10692
  let t = ji(e.section);
10641
10693
  return {
@@ -10646,7 +10698,7 @@ async function Yg(e) {
10646
10698
  let t = Ui(e.key, i, r);
10647
10699
  return {
10648
10700
  key: e.key,
10649
- state: Xg(gs(s, e.key), e.value),
10701
+ state: Qg(gs(s, e.key), e.value),
10650
10702
  setup: t?.setup ?? null,
10651
10703
  ...t?.group ? { group: t.group } : {}
10652
10704
  };
@@ -10660,20 +10712,20 @@ async function Yg(e) {
10660
10712
  sections: c
10661
10713
  };
10662
10714
  }
10663
- function Xg(e, t) {
10715
+ function Qg(e, t) {
10664
10716
  return e === "" ? "missing" : e === t.trim() ? "default" : "filled";
10665
10717
  }
10666
10718
  //#endregion
10667
10719
  //#region src/mcp/tools/env-status.ts
10668
- var Zg = { cwd: A.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
10669
- async function Qg(e) {
10670
- let t = Ng(e.cwd), n = await q(t).catch(() => null);
10720
+ var $g = { cwd: A.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
10721
+ async function e_(e) {
10722
+ let t = Fg(e.cwd), n = await q(t).catch(() => null);
10671
10723
  if (!n) throw new ct({
10672
10724
  reason: "not_a_project",
10673
10725
  message: `${t} has no stack.json, so there is nothing to check.`,
10674
10726
  details: { cwd: t }
10675
10727
  });
10676
- let r = await Jg(t, n);
10728
+ let r = await Xg(t, n);
10677
10729
  return {
10678
10730
  cwd: t,
10679
10731
  missingCount: r.missingCount,
@@ -10683,9 +10735,9 @@ async function Qg(e) {
10683
10735
  }
10684
10736
  //#endregion
10685
10737
  //#region src/mcp/tools/inspect-stack.ts
10686
- var $g = { cwd: A.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
10687
- async function e_(e) {
10688
- let t = Ng(e.cwd), n = await q(t).catch(() => null);
10738
+ var t_ = { cwd: A.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
10739
+ async function n_(e) {
10740
+ let t = Fg(e.cwd), n = await q(t).catch(() => null);
10689
10741
  if (!n) throw new ct({
10690
10742
  reason: "not_a_project",
10691
10743
  message: await Zi(t) ? `${t} is a Hype Stack project but has no stack.json. Run 'npx @hype-stack/cli init' in it.` : `${t} is not a Hype Stack project.`,
@@ -10713,12 +10765,12 @@ async function e_(e) {
10713
10765
  }
10714
10766
  //#endregion
10715
10767
  //#region src/mcp/tools/plan-install.ts
10716
- var t_ = {
10768
+ var r_ = {
10717
10769
  packs: A.array(A.string()).min(1).describe("Pack names to plan an install for"),
10718
10770
  cwd: A.string().optional().describe("Project directory. Defaults to the workspace the server was started in.")
10719
10771
  };
10720
- async function n_(e) {
10721
- let t = Ng(e.cwd), { token: n, source: r } = await Mg(), i = await q(t).catch(() => null), a = i?.installedPacks ?? [], o = await ra(), s = new Map(o.map((e) => [e.name, e])), c = e.packs.filter((e) => !s.has(e));
10772
+ async function i_(e) {
10773
+ let t = Fg(e.cwd), { token: n, source: r } = await Pg(), i = await q(t).catch(() => null), a = i?.installedPacks ?? [], o = await ra(), s = new Map(o.map((e) => [e.name, e])), c = e.packs.filter((e) => !s.has(e));
10722
10774
  if (c.length > 0) throw Error(`Unknown pack${c.length === 1 ? "" : "s"}: ${c.join(", ")}`);
10723
10775
  let l = el(o), u = nl(e.packs, l, a), d = await Zu(u.order.map((e) => s.get(e)).filter((e) => e !== void 0), new Set(a), { token: n }), f = (e) => {
10724
10776
  let t = s.get(e);
@@ -10747,12 +10799,12 @@ async function n_(e) {
10747
10799
  purchaseUrl: n ? jt(e) : null
10748
10800
  };
10749
10801
  }),
10750
- ...n === null ? { authHint: Pg } : {}
10802
+ ...n === null ? { authHint: Ig } : {}
10751
10803
  };
10752
10804
  }
10753
10805
  //#endregion
10754
10806
  //#region src/mcp/tools/search-catalog.ts
10755
- var r_ = {
10807
+ var a_ = {
10756
10808
  query: A.string().optional().describe("Free text matched against name, display name, and description"),
10757
10809
  kind: A.enum([
10758
10810
  "pack",
@@ -10765,31 +10817,31 @@ var r_ = {
10765
10817
  "paid",
10766
10818
  "all"
10767
10819
  ]).default("all").describe("Restrict packs by price tier")
10768
- }, i_ = (e, t) => {
10820
+ }, o_ = (e, t) => {
10769
10821
  let n = t.trim().toLowerCase();
10770
10822
  return n === "" ? !0 : e.some((e) => e.toLowerCase().includes(n));
10771
10823
  };
10772
- function a_(e, t) {
10824
+ function s_(e, t) {
10773
10825
  let { query: n = "", category: r, tier: i = "all" } = t;
10774
- return e.filter((e) => r && e.category !== r || i !== "all" && e.tier !== i ? !1 : i_([
10826
+ return e.filter((e) => r && e.category !== r || i !== "all" && e.tier !== i ? !1 : o_([
10775
10827
  e.name,
10776
10828
  e.displayName,
10777
10829
  e.description
10778
10830
  ], n));
10779
10831
  }
10780
- function o_(e, t) {
10832
+ function c_(e, t) {
10781
10833
  let { query: n = "", category: r } = t;
10782
- return e.filter((e) => r && e.category !== r ? !1 : i_([
10834
+ return e.filter((e) => r && e.category !== r ? !1 : o_([
10783
10835
  e.id,
10784
10836
  e.name,
10785
10837
  e.description,
10786
10838
  ...e.tags
10787
10839
  ], n));
10788
10840
  }
10789
- async function s_(e) {
10790
- let t = e.kind ?? "all", [n, r] = await Promise.all([t === "template" ? Promise.resolve([]) : ra(), t === "pack" ? Promise.resolve([]) : xg()]);
10841
+ async function l_(e) {
10842
+ let t = e.kind ?? "all", [n, r] = await Promise.all([t === "template" ? Promise.resolve([]) : ra(), t === "pack" ? Promise.resolve([]) : Cg()]);
10791
10843
  return {
10792
- packs: a_(n, e).map((e) => ({
10844
+ packs: s_(n, e).map((e) => ({
10793
10845
  name: e.name,
10794
10846
  displayName: e.displayName,
10795
10847
  description: e.description,
@@ -10798,7 +10850,7 @@ async function s_(e) {
10798
10850
  price: e.price,
10799
10851
  dependencies: e.dependencies
10800
10852
  })),
10801
- templates: o_(r, e).map((e) => ({
10853
+ templates: c_(r, e).map((e) => ({
10802
10854
  id: e.id,
10803
10855
  name: e.name,
10804
10856
  description: e.description,
@@ -10815,117 +10867,117 @@ async function s_(e) {
10815
10867
  }
10816
10868
  //#endregion
10817
10869
  //#region src/mcp/server.ts
10818
- var c_ = "hype-stack";
10819
- function l_() {
10870
+ var u_ = "hype-stack";
10871
+ function d_() {
10820
10872
  let e = new ue({
10821
- name: c_,
10873
+ name: u_,
10822
10874
  version: pe
10823
10875
  }, {
10824
10876
  capabilities: { tools: {} },
10825
- instructions: u_
10877
+ instructions: f_
10826
10878
  });
10827
10879
  return e.registerTool("search_catalog", {
10828
10880
  title: "Search the Hype Stack catalog",
10829
10881
  description: "Find feature packs and project templates by keyword, category, or price tier. Read-only. Start here when the user asks what is available.",
10830
- inputSchema: r_,
10882
+ inputSchema: a_,
10831
10883
  annotations: {
10832
10884
  readOnlyHint: !0,
10833
10885
  openWorldHint: !0
10834
10886
  }
10835
- }, (e) => Ag(() => s_(e))), e.registerTool("plan_install", {
10887
+ }, (e) => Mg(() => l_(e))), e.registerTool("plan_install", {
10836
10888
  title: "Plan a pack install",
10837
10889
  description: "Work out what installing a set of packs would do without writing anything: dependency order, packs already present, and which ones the current license does not cover. Call this before add_packs.",
10838
- inputSchema: t_,
10890
+ inputSchema: r_,
10839
10891
  annotations: {
10840
10892
  readOnlyHint: !0,
10841
10893
  openWorldHint: !0
10842
10894
  }
10843
- }, (e) => Ag(() => n_(e))), e.registerTool("create_application", {
10895
+ }, (e) => Mg(() => i_(e))), e.registerTool("create_application", {
10844
10896
  title: "Create a Hype Stack application",
10845
10897
  description: "Scaffold a new application into a folder. Runs the clone and dependency install; Docker and database migrations are returned as follow-up commands for the user to run.",
10846
- inputSchema: Ug,
10898
+ inputSchema: Gg,
10847
10899
  annotations: {
10848
10900
  readOnlyHint: !1,
10849
10901
  destructiveHint: !1,
10850
10902
  openWorldHint: !0
10851
10903
  }
10852
- }, (e) => Ag(() => Wg(e))), e.registerTool("add_packs", {
10904
+ }, (e) => Mg(() => Kg(e))), e.registerTool("add_packs", {
10853
10905
  title: "Add feature packs",
10854
10906
  description: "Install packs into an existing project. Requires an explicit onConflict policy because there is no prompt to fall back on.",
10855
- inputSchema: Fg,
10907
+ inputSchema: Lg,
10856
10908
  annotations: {
10857
10909
  readOnlyHint: !1,
10858
10910
  destructiveHint: !0,
10859
10911
  openWorldHint: !0
10860
10912
  }
10861
- }, (e) => Ag(() => Ig(e))), e.registerTool("apply_template", {
10913
+ }, (e) => Mg(() => Rg(e))), e.registerTool("apply_template", {
10862
10914
  title: "Apply a project template",
10863
10915
  description: "Install a template: its starter, layout, fixed packs, and frontend overrides. Pass variants to swap a slot away from the template default.",
10864
- inputSchema: Rg,
10916
+ inputSchema: Bg,
10865
10917
  annotations: {
10866
10918
  readOnlyHint: !1,
10867
10919
  destructiveHint: !0,
10868
10920
  openWorldHint: !0
10869
10921
  }
10870
- }, (e) => Ag(() => zg(e))), e.registerTool("inspect_stack", {
10922
+ }, (e) => Mg(() => Vg(e))), e.registerTool("inspect_stack", {
10871
10923
  title: "Inspect the project stack",
10872
10924
  description: "Read stack.json and the detected workspace layout: installed packs, app paths, and whether this is a Hype Stack project at all.",
10873
- inputSchema: $g,
10925
+ inputSchema: t_,
10874
10926
  annotations: {
10875
10927
  readOnlyHint: !0,
10876
10928
  openWorldHint: !1
10877
10929
  }
10878
- }, (e) => Ag(() => e_(e))), e.registerTool("env_status", {
10930
+ }, (e) => Mg(() => n_(e))), e.registerTool("env_status", {
10879
10931
  title: "Check environment variables",
10880
10932
  description: "Report which env vars the installed packs still need. Read-only; filling them in belongs in the user's own terminal via `hype-stack onboard`.",
10881
- inputSchema: Zg,
10933
+ inputSchema: $g,
10882
10934
  annotations: {
10883
10935
  readOnlyHint: !0,
10884
10936
  openWorldHint: !1
10885
10937
  }
10886
- }, (e) => Ag(() => Qg(e))), e.registerTool("auth_status", {
10938
+ }, (e) => Mg(() => e_(e))), e.registerTool("auth_status", {
10887
10939
  title: "Check Hype Stack authentication",
10888
10940
  description: "Who this server is authenticated as, and how to fix it when the answer is nobody. Call this whenever another tool fails with auth_required.",
10889
- inputSchema: Vg,
10941
+ inputSchema: Ug,
10890
10942
  annotations: {
10891
10943
  readOnlyHint: !0,
10892
10944
  openWorldHint: !0
10893
10945
  }
10894
- }, () => Ag(() => Hg())), e;
10946
+ }, () => Mg(() => Wg())), e;
10895
10947
  }
10896
- var u_ = "Tools for building with Hype Stack, a full-stack template you install feature packs into.\n\nThis server cannot prompt. When a tool returns ok: false, read the \"reason\" field and tell the user what to do:\n- auth_required: they need to run 'npx @hype-stack/cli login' in their own terminal, or set HYPE_STACK_TOKEN in this server's env block.\n- not_owned: the pack is paid and their organization does not have a license. The result carries a purchase URL.\n- not_a_project: run create_application first, or point the tool at the right directory with cwd.\n- conflicts: files already exist. Retry with onConflict set once the user has decided.\n\nInstalls never start Docker or touch a database. Anything the user has to run themselves comes back in \"followUp\".";
10897
- async function d_() {
10948
+ var f_ = "Tools for building with Hype Stack, a full-stack template you install feature packs into.\n\nThis server cannot prompt. When a tool returns ok: false, read the \"reason\" field and tell the user what to do:\n- auth_required: they need to run 'npx @hype-stack/cli login' in their own terminal, or set HYPE_STACK_TOKEN in this server's env block.\n- not_owned: the pack is paid and their organization does not have a license. The result carries a purchase URL.\n- not_a_project: run create_application first, or point the tool at the right directory with cwd.\n- conflicts: files already exist. Retry with onConflict set once the user has decided.\n\nInstalls never start Docker or touch a database. Anything the user has to run themselves comes back in \"followUp\".";
10949
+ async function p_() {
10898
10950
  tt("mcp");
10899
- let e = kg();
10900
- await l_().connect(new de(process.stdin, e));
10951
+ let e = jg();
10952
+ await d_().connect(new de(process.stdin, e));
10901
10953
  }
10902
10954
  //#endregion
10903
10955
  //#region src/cli.ts
10904
- function f_(e) {
10956
+ function m_(e) {
10905
10957
  if (!e) return;
10906
10958
  let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
10907
10959
  return t.length > 0 ? t : void 0;
10908
10960
  }
10909
- function p_(e, t) {
10961
+ function h_(e, t) {
10910
10962
  let n = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
10911
10963
  return [...t ?? [], ...n];
10912
10964
  }
10913
- function m_(e) {
10965
+ function g_(e) {
10914
10966
  return e === "light" || e === "dark" ? e : void 0;
10915
10967
  }
10916
- function h_(e) {
10968
+ function __(e) {
10917
10969
  return e.option("-t, --theme <theme>", `Frontend color theme (${i.join(", ")})`).option("--admin-theme <theme>", "Admin app color theme (defaults to --theme)").option("--radius <value>", `Frontend corner radius, a CSS length (e.g. ${t.map((e) => e.value).join(", ")})`).option("--admin-radius <value>", "Admin app corner radius (defaults to --radius)").option("--mode <mode>", "Color mode the app boots in (light, dark)");
10918
10970
  }
10919
- function g_(e) {
10971
+ function v_(e) {
10920
10972
  return {
10921
10973
  theme: e.theme,
10922
10974
  adminTheme: e.adminTheme,
10923
10975
  radius: e.radius,
10924
10976
  adminRadius: e.adminRadius,
10925
- mode: m_(e.mode)
10977
+ mode: g_(e.mode)
10926
10978
  };
10927
10979
  }
10928
- function __(e) {
10980
+ function y_(e) {
10929
10981
  if (!e) return;
10930
10982
  let t = {};
10931
10983
  for (let n of e.split(",")) {
@@ -10934,12 +10986,12 @@ function __(e) {
10934
10986
  }
10935
10987
  return Object.keys(t).length > 0 ? t : void 0;
10936
10988
  }
10937
- function v_(e) {
10989
+ function b_(e) {
10938
10990
  if (!e) return;
10939
10991
  let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
10940
10992
  return t.length > 0 ? t : void 0;
10941
10993
  }
10942
- function y_(e) {
10994
+ function x_(e) {
10943
10995
  let t = {};
10944
10996
  for (let n of [...zd, ...Bd]) {
10945
10997
  let r = e[n];
@@ -10947,10 +10999,10 @@ function y_(e) {
10947
10999
  }
10948
11000
  return t;
10949
11001
  }
10950
- function b_() {
11002
+ function S_() {
10951
11003
  let e = new s();
10952
- e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(pe, "-v, --version"), h_(e.command("create").description("Create a new Hype Stack project").option("-n, --name <name>", "Project name").option("-d, --directory <path>", "Target directory").option("-e, --editor <editors>", `AI editors to ship rules for, comma-separated or repeated (${Ee.join(", ")})`, p_)).option("--no-install", "Skip dependency installation").option("--no-setup", "Skip Docker services and database migrations after create").option("-y, --yes", "Skip confirmation prompts (requires --name)").action(async (e) => {
10953
- let t = g_(e);
11004
+ e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(pe, "-v, --version"), __(e.command("create").description("Create a new Hype Stack project").option("-n, --name <name>", "Project name").option("-d, --directory <path>", "Target directory").option("-e, --editor <editors>", `AI editors to ship rules for, comma-separated or repeated (${Ee.join(", ")})`, h_)).option("--no-install", "Skip dependency installation").option("--no-setup", "Skip Docker services and database migrations after create").option("-y, --yes", "Skip confirmation prompts (requires --name)").action(async (e) => {
11005
+ let t = v_(e);
10954
11006
  await sd({
10955
11007
  name: e.name,
10956
11008
  directory: e.directory,
@@ -10967,34 +11019,34 @@ function b_() {
10967
11019
  }), e.command("init").description("Initialize stack.json in the current project").action(async () => {
10968
11020
  await cd({});
10969
11021
  }), e.command("onboard").description("Set up env vars and get the start command").option("-y, --yes", "Skip prompts, accept defaults").option("--cwd <path>", "Working directory").action(async (e) => {
10970
- await ug({
11022
+ await fg({
10971
11023
  cwd: e.cwd,
10972
11024
  yes: e.yes
10973
11025
  });
10974
- }), h_(e.command("compose").description("Choose feature packs to add to your project").option("--packs <list>", "Comma-separated pack names (non-interactive). Append @frontend or @admin to a layout pack to target that app shell, e.g. layout-basic@frontend,layout-native-app-shell@admin")).option("--force", "Overwrite existing files").option("-y, --yes", "Skip confirmation prompts").option("--cwd <path>", "Working directory").action(async (e) => {
11026
+ }), __(e.command("compose").description("Choose feature packs to add to your project").option("--packs <list>", "Comma-separated pack names (non-interactive). Append @frontend or @admin to a layout pack to target that app shell, e.g. layout-basic@frontend,layout-native-app-shell@admin")).option("--force", "Overwrite existing files").option("-y, --yes", "Skip confirmation prompts").option("--cwd <path>", "Working directory").action(async (e) => {
10975
11027
  await ud({
10976
- packs: f_(e.packs),
11028
+ packs: m_(e.packs),
10977
11029
  force: e.force,
10978
11030
  yes: e.yes,
10979
11031
  cwd: e.cwd,
10980
- ...g_(e)
11032
+ ...v_(e)
10981
11033
  });
10982
- }), h_(e.command("template").description("Install a template by id, with starter/layout variant swaps and extra packs on top").argument("[id]", "Template id (omit to pick interactively)").option("--variants <map>", "Preselect slot variants, e.g. starter-saas=starter-saas-better-auth,layout=layout-basic").option("--packs <list>", "Extra packs to add on top of the template (comma-separated)")).option("--force", "Overwrite existing files").option("-y, --yes", "Skip confirmation prompts (requires <id>)").option("--cwd <path>", "Working directory").action(async (e, t) => {
10983
- await wg({
11034
+ }), __(e.command("template").description("Install a template by id, with starter/layout variant swaps and extra packs on top").argument("[id]", "Template id (omit to pick interactively)").option("--variants <map>", "Preselect slot variants, e.g. starter-saas=starter-saas-better-auth,layout=layout-basic").option("--packs <list>", "Extra packs to add on top of the template (comma-separated)")).option("--force", "Overwrite existing files").option("-y, --yes", "Skip confirmation prompts (requires <id>)").option("--cwd <path>", "Working directory").action(async (e, t) => {
11035
+ await Eg({
10984
11036
  templateId: e,
10985
- variants: __(t.variants),
10986
- packs: f_(t.packs),
11037
+ variants: y_(t.variants),
11038
+ packs: m_(t.packs),
10987
11039
  force: t.force,
10988
11040
  yes: t.yes,
10989
11041
  cwd: t.cwd,
10990
- ...g_(t)
11042
+ ...v_(t)
10991
11043
  });
10992
11044
  }), e.command("deploy").description("Deploy the frontend, admin, and backend, and provision Postgres, Valkey, and a bucket").option("-p, --provider <provider>", `Provider for everything not assigned separately (${Vd.join(", ")})`).option("--backend <provider>", "Provider hosting the backend API").option("--frontend <provider>", "Provider hosting the frontend").option("--admin <provider>", "Provider hosting the admin app").option("--postgres <provider>", "Provider for the Postgres database").option("--valkey <provider>", "Provider for the Valkey cache").option("--bucket <provider>", "Provider for object storage").option("--only <targets>", `Deploy just these apps, comma-separated (${zd.join(", ")})`).option("-e, --environment <name>", "Deployment environment name (default: production)").option("--fly-org <org>", "Fly organization slug, skips the picker when you belong to several").option("--railway-workspace <workspace>", "Railway workspace, skips the picker when you belong to several").option("--dry-run", "Print every command that would run without creating anything").option("--skip-provision", "Assume Postgres, Valkey, and the bucket already exist").option("--skip-migrations", "Do not run database migrations after the backend deploys").option("-y, --yes", "Skip confirmation prompts").option("--cwd <path>", "Project directory").action(async (e) => {
10993
- await Hh({
11045
+ await Wh({
10994
11046
  cwd: e.cwd,
10995
11047
  provider: e.provider,
10996
- assign: y_(e),
10997
- only: v_(e.only),
11048
+ assign: x_(e),
11049
+ only: b_(e.only),
10998
11050
  environment: e.environment,
10999
11051
  flyOrg: e.flyOrg,
11000
11052
  railwayWorkspace: e.railwayWorkspace,
@@ -11006,9 +11058,9 @@ function b_() {
11006
11058
  });
11007
11059
  let t = e.command("mcp").description("Run the Model Context Protocol server for AI editors");
11008
11060
  return t.action(async () => {
11009
- await d_();
11061
+ await p_();
11010
11062
  }), t.command("install").description("Register the MCP server in your editor's config").option("-e, --editor <editor>", `Editor (${hu.join(", ")})`, "cursor").option("-s, --scope <scope>", "global or project (defaults to global where supported)").option("--cwd <path>", "Project directory, for project scope").option("--token <token>", "API key to store in the config (optional, defaults to your saved login)").option("--print", "Print the JSON block instead of writing a file").action(async (e) => {
11011
- await tg({
11063
+ await rg({
11012
11064
  editor: e.editor,
11013
11065
  scope: e.scope,
11014
11066
  cwd: e.cwd,
@@ -11016,12 +11068,12 @@ function b_() {
11016
11068
  print: e.print
11017
11069
  });
11018
11070
  }), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
11019
- await $h();
11071
+ await tg();
11020
11072
  }), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
11021
- await eg();
11073
+ await ng();
11022
11074
  }), e.command("auth").description("Alias for `login`").action(async () => {
11023
- await $h();
11075
+ await tg();
11024
11076
  }), e;
11025
11077
  }
11026
11078
  //#endregion
11027
- export { Hh as a, cd as c, pe as d, $h as i, sd as l, kg as n, ud as o, eg as r, ld as s, b_ as t, tt as u };
11079
+ export { Wh as a, cd as c, pe as d, tg as i, sd as l, jg as n, ud as o, ng as r, ld as s, S_ as t, tt as u };