@hype-stack/cli 1.5.2 → 1.5.3

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.
@@ -20,7 +20,7 @@ import { McpServer as ue } from "@modelcontextprotocol/sdk/server/mcp.js";
20
20
  import { StdioServerTransport as de } from "@modelcontextprotocol/sdk/server/stdio.js";
21
21
  import { Writable as fe } from "node:stream";
22
22
  //#region src/constants/constants.ts
23
- var pe = "1.5.2", 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
+ var pe = "1.5.3", 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 = [
24
24
  {
25
25
  value: "cursor",
26
26
  label: "Cursor",
@@ -5754,7 +5754,7 @@ async function Ru() {
5754
5754
  commit: null,
5755
5755
  source: "env"
5756
5756
  };
5757
- if (ku === "1.5.2") return {
5757
+ if (ku === "1.5.3") return {
5758
5758
  ref: he,
5759
5759
  commit: null,
5760
5760
  source: "dev"
@@ -7439,7 +7439,10 @@ async function op(e) {
7439
7439
  let t = await ap(e);
7440
7440
  return t ? ["--org", t] : [];
7441
7441
  }
7442
- function sp(e) {
7442
+ function sp(e, t) {
7443
+ return /disabled for trial organizations/i.test(e) ? `Your Fly organization is still on the free trial, and Fly does not let trial organizations create ${t}. Nothing failed on your side. Add a payment card at ${e.match(/https:\/\/fly\.io\/dashboard\/\S+/)?.[0]?.replace(/[.,)]+$/, "") ?? "https://fly.io/dashboard (your organization's Billing page)"}, then run deploy again; it picks up right where it stopped.` : null;
7444
+ }
7445
+ function cp(e) {
7443
7446
  let t = {};
7444
7447
  for (let n of e.split(/\r?\n/)) {
7445
7448
  let e = n.match(/^\s*([A-Za-z][A-Za-z0-9_ ]*?)\s*[:=]\s*(\S.*?)\s*$/);
@@ -7449,19 +7452,19 @@ function sp(e) {
7449
7452
  }
7450
7453
  return t;
7451
7454
  }
7452
- function cp(e) {
7455
+ function lp(e) {
7453
7456
  let t = e.match(/\brediss?:\/\/\S+/);
7454
7457
  return t ? t[0].replace(/[.,)]+$/, "") : null;
7455
7458
  }
7456
- function lp(e) {
7459
+ function up(e) {
7457
7460
  let t = e.match(/^\w+:\/\/[^/@:]*:([^@]+)@/);
7458
7461
  return t ? decodeURIComponent(t[1]) : null;
7459
7462
  }
7460
- function up(e) {
7463
+ function dp(e) {
7461
7464
  let t = e.match(/\bpostgres(?:ql)?:\/\/\S+/);
7462
7465
  return t ? t[0].replace(/[.,)]+$/, "") : null;
7463
7466
  }
7464
- function dp(e, t) {
7467
+ function fp(e, t) {
7465
7468
  let n = $(e);
7466
7469
  if (!Array.isArray(n)) return null;
7467
7470
  for (let e of n) {
@@ -7474,7 +7477,7 @@ function dp(e, t) {
7474
7477
  }
7475
7478
  return null;
7476
7479
  }
7477
- function fp(e) {
7480
+ function pp(e) {
7478
7481
  let t = $(e);
7479
7482
  if (typeof t != "object" || !t) return null;
7480
7483
  let n = t.credentials;
@@ -7486,7 +7489,7 @@ function fp(e) {
7486
7489
  }
7487
7490
  return null;
7488
7491
  }
7489
- function pp(e) {
7492
+ function mp(e) {
7490
7493
  let t = $(e);
7491
7494
  if (!Array.isArray(t)) return [];
7492
7495
  let n = [];
@@ -7497,7 +7500,7 @@ function pp(e) {
7497
7500
  }
7498
7501
  return n;
7499
7502
  }
7500
- var mp = {
7503
+ var hp = {
7501
7504
  id: "fly",
7502
7505
  async checkAuth(e) {
7503
7506
  let t = await e.runner.run({
@@ -7559,8 +7562,9 @@ var mp = {
7559
7562
  return n.external ? {
7560
7563
  outputs: n.external,
7561
7564
  note: "using the external values from stack.json"
7562
- } : n.service === "postgres" ? hp(e, t) : n.service === "valkey" ? yp(e, t) : xp(e, t);
7565
+ } : n.service === "postgres" ? gp(e, t) : n.service === "valkey" ? bp(e, t) : Sp(e, t);
7563
7566
  },
7567
+ provisionsEarly: (e) => e.service !== "postgres",
7564
7568
  async existingEnvKeys(e, t) {
7565
7569
  let n = await e.runner.run({
7566
7570
  command: "fly",
@@ -7575,7 +7579,7 @@ var mp = {
7575
7579
  allowFailure: !0,
7576
7580
  label: `read ${t.app} secrets`
7577
7581
  }).catch(() => null);
7578
- return !n || n.exitCode !== 0 ? [] : pp(n.stdout);
7582
+ return !n || n.exitCode !== 0 ? [] : mp(n.stdout);
7579
7583
  },
7580
7584
  async setEnv(e, t) {
7581
7585
  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({
@@ -7654,10 +7658,10 @@ var mp = {
7654
7658
  };
7655
7659
  }
7656
7660
  };
7657
- async function hp(e, t) {
7658
- let { service: n, backend: r, crossProvider: i } = t, a = await gp(e, n.name), o = a ?? await _p(e, t);
7661
+ async function gp(e, t) {
7662
+ let { service: n, backend: r, crossProvider: i } = t, a = await _p(e, n.name), o = a ?? await vp(e, t);
7659
7663
  if (i || !r) {
7660
- let t = await vp(e, o);
7664
+ let t = await yp(e, o);
7661
7665
  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.`);
7662
7666
  return {
7663
7667
  outputs: { DATABASE_URL: t },
@@ -7687,14 +7691,14 @@ async function hp(e, t) {
7687
7691
  providedByProvider: ["DATABASE_URL"],
7688
7692
  note: `already attached to ${r.app}`
7689
7693
  };
7690
- let c = await vp(e, o);
7694
+ let c = await yp(e, o);
7691
7695
  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()}`);
7692
7696
  return {
7693
7697
  outputs: { DATABASE_URL: c },
7694
7698
  note: "attach failed, wired the connection string instead"
7695
7699
  };
7696
7700
  }
7697
- async function gp(e, t) {
7701
+ async function _p(e, t) {
7698
7702
  let n = await e.runner.run({
7699
7703
  command: "fly",
7700
7704
  args: [
@@ -7707,9 +7711,9 @@ async function gp(e, t) {
7707
7711
  allowFailure: !0,
7708
7712
  label: "look for an existing postgres cluster"
7709
7713
  });
7710
- return n.exitCode === 0 ? dp(n.stdout, t) : null;
7714
+ return n.exitCode === 0 ? fp(n.stdout, t) : null;
7711
7715
  }
7712
- async function _p(e, t) {
7716
+ async function vp(e, t) {
7713
7717
  let { service: n } = t, r = await e.runner.run({
7714
7718
  command: "fly",
7715
7719
  args: [
@@ -7727,17 +7731,20 @@ async function _p(e, t) {
7727
7731
  allowFailure: !0,
7728
7732
  label: `create managed postgres ${n.name}`
7729
7733
  });
7730
- if (r.exitCode !== 0 && !tp.test(r.stderr + r.stdout)) throw Error(`Could not create the Fly Postgres cluster "${n.name}":\n${r.stderr.trim() || r.stdout.trim()}`);
7734
+ if (r.exitCode !== 0 && !tp.test(r.stderr + r.stdout)) {
7735
+ let e = sp(r.stderr + r.stdout, "a Managed Postgres cluster");
7736
+ throw Error(e || `Could not create the Fly Postgres cluster "${n.name}":\n${r.stderr.trim() || r.stdout.trim()}`);
7737
+ }
7731
7738
  let i = r.stdout.match(/^\s*ID:\s*(\S+)\s*$/m)?.[1];
7732
7739
  if (i) return {
7733
7740
  id: i,
7734
7741
  name: n.name
7735
7742
  };
7736
- let a = await gp(e, n.name);
7743
+ let a = await _p(e, n.name);
7737
7744
  if (a) return a;
7738
7745
  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.`);
7739
7746
  }
7740
- async function vp(e, t) {
7747
+ async function yp(e, t) {
7741
7748
  let n = await e.runner.run({
7742
7749
  command: "fly",
7743
7750
  args: [
@@ -7750,9 +7757,9 @@ async function vp(e, t) {
7750
7757
  allowFailure: !0,
7751
7758
  label: `read postgres status ${t.name}`
7752
7759
  });
7753
- return fp(n.stdout) ?? up(n.stdout);
7760
+ return pp(n.stdout) ?? dp(n.stdout);
7754
7761
  }
7755
- async function yp(e, t) {
7762
+ async function bp(e, t) {
7756
7763
  let { service: n } = t, r = await e.runner.run({
7757
7764
  command: "fly",
7758
7765
  args: [
@@ -7763,9 +7770,9 @@ async function yp(e, t) {
7763
7770
  cwd: e.cwd,
7764
7771
  allowFailure: !0,
7765
7772
  label: `look for an existing valkey ${n.name}`
7766
- }), i = r.exitCode === 0 ? cp(r.stdout + r.stderr) : null;
7773
+ }), i = r.exitCode === 0 ? lp(r.stdout + r.stderr) : null;
7767
7774
  if (i) return {
7768
- outputs: bp(i),
7775
+ outputs: xp(i),
7769
7776
  note: "reusing the existing database"
7770
7777
  };
7771
7778
  let a = await e.runner.run({
@@ -7785,18 +7792,23 @@ async function yp(e, t) {
7785
7792
  cwd: e.cwd,
7786
7793
  allowFailure: !0,
7787
7794
  label: `create valkey ${n.name}`
7788
- }), o = cp(a.stdout + a.stderr);
7789
- 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.`);
7790
- return { outputs: bp(o) };
7795
+ }), o = a.stderr.trim() || a.stdout.trim();
7796
+ if (a.exitCode !== 0) {
7797
+ let e = sp(o, "a Valkey database");
7798
+ throw Error(e || `Could not create the Valkey database "${n.name}" on Fly:\n${o}\nFix what Fly is rejecting there, or point deploy at a database you already run by setting deploy.services.valkey.external.VALKEY_URL in stack.json.`);
7799
+ }
7800
+ let s = lp(a.stdout + a.stderr);
7801
+ if (!s) throw Error(`Could not read the connection URL for the Valkey database "${n.name}":\n${o}\nRun \`fly redis status ${n.name}\` and set deploy.services.valkey.external.VALKEY_URL in stack.json.`);
7802
+ return { outputs: xp(s) };
7791
7803
  }
7792
- function bp(e) {
7793
- let t = lp(e);
7804
+ function xp(e) {
7805
+ let t = up(e);
7794
7806
  return {
7795
7807
  VALKEY_URL: e,
7796
7808
  ...t ? { VALKEY_PASSWORD: t } : {}
7797
7809
  };
7798
7810
  }
7799
- async function xp(e, t) {
7811
+ async function Sp(e, t) {
7800
7812
  let { service: n, backend: r, crossProvider: i } = t, a = n.name, o = await e.runner.run({
7801
7813
  command: "fly",
7802
7814
  args: [
@@ -7810,23 +7822,26 @@ async function xp(e, t) {
7810
7822
  cwd: e.cwd,
7811
7823
  allowFailure: !0,
7812
7824
  label: `create tigris bucket ${a}`
7813
- }), s = Tp(sp(o.stdout + o.stderr), a);
7825
+ }), s = Ep(cp(o.stdout + o.stderr), a);
7814
7826
  if (s) return { outputs: s };
7815
- if (!tp.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.`);
7816
- if (!i && r && await wp(e, r.app)) return {
7827
+ if (!tp.test(o.stderr + o.stdout)) {
7828
+ let e = sp(o.stderr + o.stdout, "a Tigris storage bucket");
7829
+ throw Error(e || `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.`);
7830
+ }
7831
+ if (!i && r && await Tp(e, r.app)) return {
7817
7832
  outputs: {},
7818
- providedByProvider: [...Sp],
7833
+ providedByProvider: [...Cp],
7819
7834
  note: `already set on ${r.app} by an earlier deploy`
7820
7835
  };
7821
7836
  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.`);
7822
7837
  }
7823
- var Sp = [
7838
+ var Cp = [
7824
7839
  "RUSTFS_ENDPOINT",
7825
7840
  "RUSTFS_ACCESS_KEY",
7826
7841
  "RUSTFS_SECRET_KEY",
7827
7842
  "BUCKET_NAME"
7828
7843
  ];
7829
- function Cp(e) {
7844
+ function wp(e) {
7830
7845
  let t = $(e);
7831
7846
  return Array.isArray(t) ? t.flatMap((e) => {
7832
7847
  if (typeof e != "object" || !e) return [];
@@ -7834,7 +7849,7 @@ function Cp(e) {
7834
7849
  return typeof n == "string" ? [n] : [];
7835
7850
  }) : [];
7836
7851
  }
7837
- async function wp(e, t) {
7852
+ async function Tp(e, t) {
7838
7853
  let n = await e.runner.run({
7839
7854
  command: "fly",
7840
7855
  args: [
@@ -7849,10 +7864,10 @@ async function wp(e, t) {
7849
7864
  label: `check the storage keys already on ${t}`
7850
7865
  });
7851
7866
  if (n.exitCode !== 0) return !1;
7852
- let r = new Set(Cp(n.stdout));
7853
- return Sp.every((e) => r.has(e));
7867
+ let r = new Set(wp(n.stdout));
7868
+ return Cp.every((e) => r.has(e));
7854
7869
  }
7855
- function Tp(e, t) {
7870
+ function Ep(e, t) {
7856
7871
  let n = e.AWS_ACCESS_KEY_ID, r = e.AWS_SECRET_ACCESS_KEY;
7857
7872
  return !n || !r ? null : {
7858
7873
  RUSTFS_ENDPOINT: e.AWS_ENDPOINT_URL_S3 ?? "https://t3.storage.dev",
@@ -7863,32 +7878,32 @@ function Tp(e, t) {
7863
7878
  }
7864
7879
  //#endregion
7865
7880
  //#region src/deploy/runner.ts
7866
- var Ep = class extends Error {
7881
+ var Dp = class extends Error {
7867
7882
  spec;
7868
7883
  result;
7869
7884
  constructor(e, t) {
7870
7885
  let n = (t.stderr.trim() || t.stdout.trim()).split("\n").slice(-8).join("\n");
7871
- super(`${Dp(e)} exited with ${t.exitCode}${n ? `\n${n}` : ""}`), this.name = "CommandFailedError", this.spec = e, this.result = t;
7886
+ super(`${Op(e)} exited with ${t.exitCode}${n ? `\n${n}` : ""}`), this.name = "CommandFailedError", this.spec = e, this.result = t;
7872
7887
  }
7873
7888
  };
7874
- function Dp(e) {
7875
- let t = [e.command, ...e.args].map(kp).join(" ");
7876
- return Op(e.stdin === void 0 ? t : `${t} < (stdin)`, e.secrets ?? []);
7889
+ function Op(e) {
7890
+ let t = [e.command, ...e.args].map(Ap).join(" ");
7891
+ return kp(e.stdin === void 0 ? t : `${t} < (stdin)`, e.secrets ?? []);
7877
7892
  }
7878
- function Op(e, t) {
7893
+ function kp(e, t) {
7879
7894
  let n = e;
7880
7895
  for (let e of t) !e || e.length < 4 || (n = n.split(e).join("***"));
7881
7896
  return n;
7882
7897
  }
7883
- function kp(e) {
7898
+ function Ap(e) {
7884
7899
  return e === "" ? "\"\"" : /[\s"'$`\\]/.test(e) ? `"${e.replace(/(["\\$`])/g, "\\$1")}"` : e;
7885
7900
  }
7886
- function Ap(e = {}) {
7901
+ function jp(e = {}) {
7887
7902
  let t = [];
7888
7903
  return {
7889
7904
  transcript: t,
7890
7905
  async run(n) {
7891
- let r = Dp(n);
7906
+ let r = Op(n);
7892
7907
  t.push(r), e.onCommand?.(r);
7893
7908
  let i = e.env || n.env ? {
7894
7909
  ...e.env,
@@ -7897,20 +7912,20 @@ function Ap(e = {}) {
7897
7912
  cwd: n.cwd,
7898
7913
  stdin: n.stdin,
7899
7914
  env: i,
7900
- onData: e.onOutput ? (t) => e.onOutput?.(Op(t, n.secrets ?? [])) : void 0
7915
+ onData: e.onOutput ? (t) => e.onOutput?.(kp(t, n.secrets ?? [])) : void 0
7901
7916
  });
7902
- if (a.exitCode !== 0 && !n.allowFailure) throw new Ep(n, a);
7917
+ if (a.exitCode !== 0 && !n.allowFailure) throw new Dp(n, a);
7903
7918
  return a;
7904
7919
  }
7905
7920
  };
7906
7921
  }
7907
- function jp(e = {}) {
7922
+ function Mp(e = {}) {
7908
7923
  let t = [];
7909
7924
  return {
7910
7925
  transcript: t,
7911
7926
  dryRun: !0,
7912
7927
  run(n) {
7913
- let r = Dp(n);
7928
+ let r = Op(n);
7914
7929
  t.push(r), e.onCommand?.(r);
7915
7930
  let i = e.responses?.find((e) => r.includes(e.match)), a = typeof i?.stdout == "function" ? i.stdout(n) : i?.stdout ?? "";
7916
7931
  return Promise.resolve({
@@ -7923,42 +7938,42 @@ function jp(e = {}) {
7923
7938
  }
7924
7939
  //#endregion
7925
7940
  //#region src/deploy/providers/railway.ts
7926
- var Mp = "Postgres", Np = "valkey/valkey:latest", Pp = 6379, Fp = "/data", Ip = "/bin/sh -c \"exec docker-entrypoint.sh valkey-server --port ${VALKEY_PORT} --requirepass ${VALKEY_PASSWORD} --appendonly yes\"", Lp = 12e4, Rp = 3e3, zp = 20 * 6e4, Bp = 1e4, Vp = new Set(["SUCCESS", "SLEEPING"]), Hp = new Set([
7941
+ var Np = "Postgres", Pp = "valkey/valkey:latest", Fp = 6379, Ip = "/data", Lp = "/bin/sh -c \"exec docker-entrypoint.sh valkey-server --port ${VALKEY_PORT} --requirepass ${VALKEY_PASSWORD} --appendonly yes\"", Rp = 12e4, zp = 3e3, Bp = 20 * 6e4, Vp = 1e4, Hp = new Set(["SUCCESS", "SLEEPING"]), Up = new Set([
7927
7942
  "FAILED",
7928
7943
  "CRASHED",
7929
7944
  "REMOVED",
7930
7945
  "SKIPPED"
7931
- ]), Up = "query Deployments($input: DeploymentListInput!) { deployments(input: $input, first: 1) { edges { node { id status } } } }", Wp = "query BuildLogs($deploymentId: String!, $limit: Int) { buildLogs(deploymentId: $deploymentId, limit: $limit) { message } }", Gp = "query DeploymentLogs($deploymentId: String!, $limit: Int) { deploymentLogs(deploymentId: $deploymentId, limit: $limit) { message } }", Kp = [
7946
+ ]), Wp = "query Deployments($input: DeploymentListInput!) { deployments(input: $input, first: 1) { edges { node { id status } } } }", Gp = "query BuildLogs($deploymentId: String!, $limit: Int) { buildLogs(deploymentId: $deploymentId, limit: $limit) { message } }", Kp = "query DeploymentLogs($deploymentId: String!, $limit: Int) { deploymentLogs(deploymentId: $deploymentId, limit: $limit) { message } }", qp = [
7932
7947
  "sjc",
7933
7948
  "iad",
7934
7949
  "ams",
7935
7950
  "sin"
7936
- ], qp = "iad", Jp = "rustfs/rustfs:latest", Yp = 9e3, Xp = "/data", Zp = /already exists|duplicate|is already/i, Qp = /unrecognized subcommand|unknown subcommand|unexpected argument|not a valid subcommand/i;
7937
- function $p(e) {
7951
+ ], Jp = "iad", Yp = "rustfs/rustfs:latest", Xp = 9e3, Zp = "/data", Qp = /already exists|duplicate|is already/i, $p = /unrecognized subcommand|unknown subcommand|unexpected argument|not a valid subcommand/i;
7952
+ function em(e) {
7938
7953
  let t = e.trim();
7939
7954
  if (t.startsWith("{") || t.startsWith("[")) {
7940
- let e = $(t), n = e === null ? null : am(e);
7941
- if (n) return im(n);
7955
+ let e = $(t), n = e === null ? null : om(e);
7956
+ if (n) return am(n);
7942
7957
  }
7943
7958
  let n = t.match(/[a-z0-9-]+(?:\.[a-z0-9-]+)*\.(?:up\.railway\.app|railway\.app)/i);
7944
- return n ? im(n[0]) : null;
7959
+ return n ? am(n[0]) : null;
7945
7960
  }
7946
- function em(e) {
7961
+ function tm(e) {
7947
7962
  let t = $(e.trim()), n = typeof t == "object" && t ? t.domains : null;
7948
7963
  if (!Array.isArray(n)) return [];
7949
7964
  let r = [];
7950
7965
  for (let e of n) {
7951
- let t = typeof e == "string" ? e : tm(e);
7966
+ let t = typeof e == "string" ? e : nm(e);
7952
7967
  t && r.push(t);
7953
7968
  }
7954
7969
  return r;
7955
7970
  }
7956
- function tm(e) {
7971
+ function nm(e) {
7957
7972
  if (typeof e != "object" || !e) return null;
7958
7973
  let t = e.domain;
7959
7974
  return typeof t == "string" && t.length > 0 ? t : null;
7960
7975
  }
7961
- async function nm(e, t) {
7976
+ async function rm(e, t) {
7962
7977
  let n = await e.runner.run({
7963
7978
  command: "railway",
7964
7979
  args: [
@@ -7972,12 +7987,12 @@ async function nm(e, t) {
7972
7987
  allowFailure: !0,
7973
7988
  label: `list domains for ${t}`
7974
7989
  });
7975
- return n.exitCode === 0 ? em(n.stdout) : Qp.test(n.stderr + n.stdout) ? null : [];
7990
+ return n.exitCode === 0 ? tm(n.stdout) : $p.test(n.stderr + n.stdout) ? null : [];
7976
7991
  }
7977
- async function rm(e, t, n) {
7978
- let r = await nm(e, t);
7992
+ async function im(e, t, n) {
7993
+ let r = await rm(e, t);
7979
7994
  if (r !== null && r.length > 0) return {
7980
- url: im(r[0]),
7995
+ url: am(r[0]),
7981
7996
  output: ""
7982
7997
  };
7983
7998
  let i = await e.runner.run({
@@ -7993,35 +8008,35 @@ async function rm(e, t, n) {
7993
8008
  cwd: e.cwd,
7994
8009
  allowFailure: !0,
7995
8010
  label: `expose ${t} on a public domain`
7996
- }), a = (i.stderr.trim() || i.stdout.trim()).split("\n").slice(-8).join("\n"), o = await nm(e, t);
8011
+ }), a = (i.stderr.trim() || i.stdout.trim()).split("\n").slice(-8).join("\n"), o = await rm(e, t);
7997
8012
  return o !== null && o.length > 0 ? {
7998
- url: im(o[0]),
8013
+ url: am(o[0]),
7999
8014
  output: a
8000
8015
  } : {
8001
- url: o === null ? $p(i.stdout + i.stderr) : null,
8016
+ url: o === null ? em(i.stdout + i.stderr) : null,
8002
8017
  output: a
8003
8018
  };
8004
8019
  }
8005
- function im(e) {
8020
+ function am(e) {
8006
8021
  return `https://${e.replace(/^https?:\/\//i, "").replace(/\/+$/, "")}`;
8007
8022
  }
8008
- function am(e) {
8023
+ function om(e) {
8009
8024
  if (typeof e == "string") return /\.railway\.app/i.test(e) ? e : null;
8010
8025
  if (Array.isArray(e)) {
8011
8026
  for (let t of e) {
8012
- let e = am(t);
8027
+ let e = om(t);
8013
8028
  if (e) return e;
8014
8029
  }
8015
8030
  return null;
8016
8031
  }
8017
8032
  if (typeof e == "object" && e) for (let [t, n] of Object.entries(e)) {
8018
8033
  if ((t === "domain" || t === "url" || t === "host") && typeof n == "string" && n.length > 0) return n;
8019
- let e = am(n);
8034
+ let e = om(n);
8020
8035
  if (e) return e;
8021
8036
  }
8022
8037
  return null;
8023
8038
  }
8024
- function om(e) {
8039
+ function sm(e) {
8025
8040
  let t = $(e.trim());
8026
8041
  if (!Array.isArray(t)) return [];
8027
8042
  let n = [];
@@ -8035,7 +8050,7 @@ function om(e) {
8035
8050
  }
8036
8051
  return n;
8037
8052
  }
8038
- function sm(e) {
8053
+ function cm(e) {
8039
8054
  let t = $(e.trim());
8040
8055
  if (typeof t != "object" || !t || Array.isArray(t)) return null;
8041
8056
  let n = t, r = n.id;
@@ -8044,7 +8059,7 @@ function sm(e) {
8044
8059
  name: typeof n.name == "string" ? n.name : ""
8045
8060
  };
8046
8061
  }
8047
- function cm(e) {
8062
+ function lm(e) {
8048
8063
  let t = e.trim();
8049
8064
  if (t.startsWith("{")) {
8050
8065
  let e = $(t);
@@ -8061,7 +8076,7 @@ function cm(e) {
8061
8076
  }
8062
8077
  return n;
8063
8078
  }
8064
- var lm = {
8079
+ var um = {
8065
8080
  id: "railway",
8066
8081
  async checkAuth(e) {
8067
8082
  let t = await e.runner.run({
@@ -8091,16 +8106,16 @@ var lm = {
8091
8106
  scope: {
8092
8107
  label: "workspace",
8093
8108
  flag: "--railway-workspace",
8094
- list: ym,
8109
+ list: bm,
8095
8110
  current: (e) => e.railway.workspace,
8096
8111
  pin: (e, t) => {
8097
8112
  e.railway.workspace = t;
8098
8113
  }
8099
8114
  },
8100
8115
  async reserveTarget(e, t) {
8101
- await gm(e);
8116
+ await _m(e);
8102
8117
  let n = t.spec.serveMode === "static" ? mf : t.spec.port ?? 3e3;
8103
- if (!await Sm(e, t.app)) {
8118
+ if (!await Cm(e, t.app)) {
8104
8119
  let r = await e.runner.run({
8105
8120
  command: "railway",
8106
8121
  args: [
@@ -8115,9 +8130,9 @@ var lm = {
8115
8130
  allowFailure: !0,
8116
8131
  label: `create railway service ${t.app}`
8117
8132
  });
8118
- if (r.exitCode !== 0 && !Zp.test(r.stderr + r.stdout)) throw Error(`Could not create the Railway service "${t.app}":\n${r.stderr.trim() || r.stdout.trim()}`);
8133
+ if (r.exitCode !== 0 && !Qp.test(r.stderr + r.stdout)) throw Error(`Could not create the Railway service "${t.app}":\n${r.stderr.trim() || r.stdout.trim()}`);
8119
8134
  }
8120
- let r = await rm(e, t.app, n);
8135
+ let r = await im(e, t.app, n);
8121
8136
  if (t.url) return t.url;
8122
8137
  if (!r.url) throw Error(`Railway gave "${t.app}" no public domain, so the app would go up unreachable.` + (r.output ? `\n${r.output}` : "") + `\nGenerate one with \`railway domain --service ${t.app} --port ${n}\`, or add it under the service's Settings > Networking, then run deploy again. To point at a domain you own instead, set ${Nf("targets", t.target, "url")} in ${Z}.`);
8123
8138
  return r.url;
@@ -8127,10 +8142,10 @@ var lm = {
8127
8142
  return n.external ? {
8128
8143
  outputs: n.external,
8129
8144
  note: "using the external values from stack.json"
8130
- } : (await gm(e), n.service === "postgres" ? Dm(e, t.crossProvider) : n.service === "valkey" ? jm(e, t) : qm(e, t));
8145
+ } : (await _m(e), n.service === "postgres" ? Om(e, t.crossProvider) : n.service === "valkey" ? Mm(e, t) : Jm(e, t));
8131
8146
  },
8132
8147
  async existingEnvKeys(e, t) {
8133
- let n = await Tm(e, t.app);
8148
+ let n = await Em(e, t.app);
8134
8149
  return Object.entries(n).filter(([, e]) => e.trim() !== "").map(([e]) => e);
8135
8150
  },
8136
8151
  async setEnv(e, t) {
@@ -8154,29 +8169,29 @@ var lm = {
8154
8169
  });
8155
8170
  },
8156
8171
  async deployTarget(e, t) {
8157
- return t.target.spec.serveMode === "static" ? um(e, t) : dm(e, t);
8172
+ return t.target.spec.serveMode === "static" ? dm(e, t) : fm(e, t);
8158
8173
  },
8159
8174
  async awaitTarget(e, t) {
8160
8175
  if (e.runner.dryRun) return {
8161
8176
  ok: !0,
8162
8177
  detail: "not checked on a dry run"
8163
8178
  };
8164
- let n = await xm(e, t.app);
8179
+ let n = await Sm(e, t.app);
8165
8180
  if (!n) return {
8166
8181
  ok: !0,
8167
8182
  detail: `could not find the service "${t.app}" to check on it, so look at the Railway dashboard`
8168
8183
  };
8169
- let r = await Rm(e, {
8184
+ let r = await zm(e, {
8170
8185
  name: t.app,
8171
8186
  serviceId: n.id,
8172
- timeoutMs: zp,
8173
- pollIntervalMs: Bp
8187
+ timeoutMs: Bp,
8188
+ pollIntervalMs: Vp
8174
8189
  });
8175
8190
  if (r.ok) return {
8176
8191
  ok: !0,
8177
8192
  detail: r.status === null ? r.note : "live"
8178
8193
  };
8179
- let i = r.deploymentId && r.status ? await Bm(e, {
8194
+ let i = r.deploymentId && r.status ? await Vm(e, {
8180
8195
  id: r.deploymentId,
8181
8196
  status: r.status
8182
8197
  }) : null, a = r.note ?? `the deployment ${r.status === "CRASHED" ? "crashed after starting" : "failed"}`;
@@ -8209,7 +8224,7 @@ var lm = {
8209
8224
  };
8210
8225
  }
8211
8226
  };
8212
- async function um(e, t) {
8227
+ async function dm(e, t) {
8213
8228
  let { target: n } = t, r = await ep(e, t), i = await Of({
8214
8229
  projectRoot: e.cwd,
8215
8230
  target: n,
@@ -8229,7 +8244,7 @@ async function um(e, t) {
8229
8244
  cwd: e.cwd,
8230
8245
  label: `point ${n.app} at the bundled Dockerfile`
8231
8246
  }), {
8232
- url: $p((await fm(e, t, [
8247
+ url: em((await pm(e, t, [
8233
8248
  i,
8234
8249
  "--path-as-root",
8235
8250
  "--no-gitignore"
@@ -8237,7 +8252,7 @@ async function um(e, t) {
8237
8252
  releaseRan: !1
8238
8253
  };
8239
8254
  }
8240
- async function dm(e, t) {
8255
+ async function fm(e, t) {
8241
8256
  let { target: n } = t, r = await kf(e.cwd, n);
8242
8257
  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.`);
8243
8258
  await e.runner.run({
@@ -8253,21 +8268,21 @@ async function dm(e, t) {
8253
8268
  cwd: e.cwd,
8254
8269
  label: `point ${n.app} at ${r}`
8255
8270
  });
8256
- let i = await mm(e, {
8271
+ let i = await hm(e, {
8257
8272
  dockerfile: r,
8258
8273
  target: n,
8259
8274
  releaseCommand: t.releaseCommand
8260
8275
  });
8261
8276
  try {
8262
8277
  return {
8263
- url: $p((await fm(e, t, [])).stdout) ?? n.url,
8278
+ url: em((await pm(e, t, [])).stdout) ?? n.url,
8264
8279
  releaseRan: i.preDeployRan
8265
8280
  };
8266
8281
  } finally {
8267
8282
  i.written && await Sf(e.cwd);
8268
8283
  }
8269
8284
  }
8270
- async function fm(e, t, n) {
8285
+ async function pm(e, t, n) {
8271
8286
  let r = {
8272
8287
  command: "railway",
8273
8288
  args: [
@@ -8283,10 +8298,10 @@ async function fm(e, t, n) {
8283
8298
  label: `deploy ${t.target.target} to railway`
8284
8299
  }, i = await e.runner.run(r);
8285
8300
  if (i.exitCode === 0) return i;
8286
- let a = new Ep(r, i), o = await pm(e, t.target, i.stdout + i.stderr);
8301
+ let a = new Dp(r, i), o = await mm(e, t.target, i.stdout + i.stderr);
8287
8302
  throw o ? /* @__PURE__ */ Error(`${a.message}\n\n${o}`) : a;
8288
8303
  }
8289
- async function pm(e, t, n) {
8304
+ async function mm(e, t, n) {
8290
8305
  let r = n.match(/Could not load ([\w@./-]+)/)?.[1];
8291
8306
  if (!r) return null;
8292
8307
  let i = [
@@ -8313,7 +8328,7 @@ async function pm(e, t, n) {
8313
8328
  label: `check whether ${o} is gitignored`
8314
8329
  })).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;
8315
8330
  }
8316
- async function mm(e, t) {
8331
+ async function hm(e, t) {
8317
8332
  let { dockerfile: n, target: r, releaseCommand: i } = t;
8318
8333
  if (await bf(e.cwd)) return e.log?.(`Keeping your ${_f}, so ${r.app} uses the settings in it`), {
8319
8334
  written: !1,
@@ -8332,11 +8347,11 @@ async function mm(e, t) {
8332
8347
  preDeployRan: o
8333
8348
  });
8334
8349
  }
8335
- var hm = /* @__PURE__ */ new WeakSet();
8336
- async function gm(e) {
8337
- hm.has(e) || (await _m(e), hm.add(e));
8338
- }
8350
+ var gm = /* @__PURE__ */ new WeakSet();
8339
8351
  async function _m(e) {
8352
+ gm.has(e) || (await vm(e), gm.add(e));
8353
+ }
8354
+ async function vm(e) {
8340
8355
  if ((await e.runner.run({
8341
8356
  command: "railway",
8342
8357
  args: ["status", "--json"],
@@ -8344,7 +8359,7 @@ async function _m(e) {
8344
8359
  allowFailure: !0,
8345
8360
  label: "check railway project link"
8346
8361
  })).exitCode === 0) return;
8347
- let t = await bm(e);
8362
+ let t = await xm(e);
8348
8363
  await e.runner.run({
8349
8364
  command: "railway",
8350
8365
  args: [
@@ -8357,7 +8372,7 @@ async function _m(e) {
8357
8372
  label: `create railway project ${e.plan.projectName}`
8358
8373
  });
8359
8374
  }
8360
- function vm(e) {
8375
+ function ym(e) {
8361
8376
  let t = $(e);
8362
8377
  if (typeof t != "object" || !t) return [];
8363
8378
  let n = t.workspaces;
@@ -8367,7 +8382,7 @@ function vm(e) {
8367
8382
  return typeof n == "string" ? [n] : [];
8368
8383
  }) : [];
8369
8384
  }
8370
- async function ym(e) {
8385
+ async function bm(e) {
8371
8386
  let t = await e.runner.run({
8372
8387
  command: "railway",
8373
8388
  args: ["whoami", "--json"],
@@ -8375,17 +8390,17 @@ async function ym(e) {
8375
8390
  allowFailure: !0,
8376
8391
  label: "find your Railway workspace"
8377
8392
  });
8378
- return t.exitCode === 0 ? vm(t.stdout) : [];
8393
+ return t.exitCode === 0 ? ym(t.stdout) : [];
8379
8394
  }
8380
- async function bm(e) {
8395
+ async function xm(e) {
8381
8396
  if (e.plan.railway.workspace) return e.plan.railway.workspace;
8382
- let t = await ym(e);
8397
+ let t = await bm(e);
8383
8398
  if (t.length !== 0) {
8384
8399
  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.`);
8385
8400
  return e.plan.railway.workspace = t[0], t[0];
8386
8401
  }
8387
8402
  }
8388
- async function xm(e, t) {
8403
+ async function Sm(e, t) {
8389
8404
  let n = await e.runner.run({
8390
8405
  command: "railway",
8391
8406
  args: [
@@ -8397,18 +8412,18 @@ async function xm(e, t) {
8397
8412
  allowFailure: !0,
8398
8413
  label: "list railway services"
8399
8414
  });
8400
- return n.exitCode === 0 ? om(n.stdout).find((e) => e.name === t) ?? null : null;
8415
+ return n.exitCode === 0 ? sm(n.stdout).find((e) => e.name === t) ?? null : null;
8401
8416
  }
8402
- async function Sm(e, t) {
8403
- return await xm(e, t) !== null;
8417
+ async function Cm(e, t) {
8418
+ return await Sm(e, t) !== null;
8404
8419
  }
8405
- function Cm(e, t) {
8420
+ function wm(e, t) {
8406
8421
  return `\${{${/^[\w-]+$/.test(e) ? e : `"${e}"`}.${t}}}`;
8407
8422
  }
8408
- function wm(e) {
8409
- return `https://${Cm(e, "RAILWAY_PUBLIC_DOMAIN")}`;
8423
+ function Tm(e) {
8424
+ return `https://${wm(e, "RAILWAY_PUBLIC_DOMAIN")}`;
8410
8425
  }
8411
- async function Tm(e, t) {
8426
+ async function Em(e, t) {
8412
8427
  let n = await e.runner.run({
8413
8428
  command: "railway",
8414
8429
  args: [
@@ -8422,9 +8437,9 @@ async function Tm(e, t) {
8422
8437
  allowFailure: !0,
8423
8438
  label: `read ${t} connection details`
8424
8439
  });
8425
- return n.exitCode === 0 ? cm(n.stdout) : {};
8440
+ return n.exitCode === 0 ? lm(n.stdout) : {};
8426
8441
  }
8427
- var Em = {
8442
+ var Dm = {
8428
8443
  DATABASE_URL: "DATABASE_URL",
8429
8444
  POSTGRES_DB: "PGDATABASE",
8430
8445
  POSTGRES_HOST: "PGHOST",
@@ -8432,8 +8447,8 @@ var Em = {
8432
8447
  POSTGRES_USER: "PGUSER",
8433
8448
  POSTGRES_PASSWORD: "PGPASSWORD"
8434
8449
  };
8435
- async function Dm(e, t) {
8436
- if (!await Sm(e, "Postgres")) {
8450
+ async function Om(e, t) {
8451
+ if (!await Cm(e, "Postgres")) {
8437
8452
  let t = await e.runner.run({
8438
8453
  command: "railway",
8439
8454
  args: [
@@ -8446,28 +8461,28 @@ async function Dm(e, t) {
8446
8461
  allowFailure: !0,
8447
8462
  label: "add railway postgres"
8448
8463
  });
8449
- if (t.exitCode !== 0 && !Zp.test(t.stderr + t.stdout)) throw Error(`Could not add a Railway postgres database:\n${t.stderr.trim()}`);
8464
+ if (t.exitCode !== 0 && !Qp.test(t.stderr + t.stdout)) throw Error(`Could not add a Railway postgres database:\n${t.stderr.trim()}`);
8450
8465
  }
8451
8466
  if (!t) {
8452
8467
  let e = {};
8453
- for (let [t, n] of Object.entries(Em)) e[t] = Cm(Mp, n);
8468
+ for (let [t, n] of Object.entries(Dm)) e[t] = wm(Np, n);
8454
8469
  return {
8455
8470
  outputs: e,
8456
- note: `wired as Railway references to ${Mp}`
8471
+ note: `wired as Railway references to ${Np}`
8457
8472
  };
8458
8473
  }
8459
- let n = await Tm(e, Mp), r = n.DATABASE_PUBLIC_URL ?? n.DATABASE_URL;
8460
- if (!r) throw Error(`Could not read DATABASE_PUBLIC_URL from the Railway ${Mp} service. Enable a public proxy on it, or set ${Nf("services", "postgres", "external")} in ${Z}.`);
8474
+ let n = await Em(e, Np), r = n.DATABASE_PUBLIC_URL ?? n.DATABASE_URL;
8475
+ if (!r) throw Error(`Could not read DATABASE_PUBLIC_URL from the Railway ${Np} service. Enable a public proxy on it, or set ${Nf("services", "postgres", "external")} in ${Z}.`);
8461
8476
  return { outputs: {
8462
8477
  DATABASE_URL: r,
8463
- ...Om(r)
8478
+ ...km(r)
8464
8479
  } };
8465
8480
  }
8466
- function Om(e) {
8467
- let t = km(e);
8481
+ function km(e) {
8482
+ let t = Am(e);
8468
8483
  if (!t) return {};
8469
8484
  let n = decodeURIComponent(t.pathname.replace(/^\//, ""));
8470
- return Am({
8485
+ return jm({
8471
8486
  POSTGRES_HOST: t.hostname,
8472
8487
  POSTGRES_PORT: t.port,
8473
8488
  POSTGRES_USER: decodeURIComponent(t.username),
@@ -8475,43 +8490,43 @@ function Om(e) {
8475
8490
  POSTGRES_DB: n
8476
8491
  });
8477
8492
  }
8478
- function km(e) {
8493
+ function Am(e) {
8479
8494
  try {
8480
8495
  return new URL(e);
8481
8496
  } catch {
8482
8497
  return null;
8483
8498
  }
8484
8499
  }
8485
- function Am(e) {
8500
+ function jm(e) {
8486
8501
  return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== ""));
8487
8502
  }
8488
- async function jm(e, t) {
8489
- let n = t.service.name, r = await xm(e, n);
8490
- if (r || await Mm(e, n), !t.crossProvider) return {
8503
+ async function Mm(e, t) {
8504
+ let n = t.service.name, r = await Sm(e, n);
8505
+ if (r || await Nm(e, n), !t.crossProvider) return {
8491
8506
  outputs: {
8492
- VALKEY_URL: Cm(n, "VALKEY_URL"),
8493
- VALKEY_PASSWORD: Cm(n, "VALKEY_PASSWORD")
8507
+ VALKEY_URL: wm(n, "VALKEY_URL"),
8508
+ VALKEY_PASSWORD: wm(n, "VALKEY_PASSWORD")
8494
8509
  },
8495
- note: r ? "reusing the Valkey service already in the project" : `${Np} with a volume and a password`
8510
+ note: r ? "reusing the Valkey service already in the project" : `${Pp} with a volume and a password`
8496
8511
  };
8497
- let i = await Tm(e, n), a = i.VALKEY_PUBLIC_URL ?? i.VALKEY_URL;
8498
- if (!a) throw Error(`Could not read VALKEY_PUBLIC_URL from the Railway Valkey service "${n}". Run \`railway tcp-proxy create --port ${Pp} --service ${n}\`, or set ${Nf("services", "valkey", "external")} in ${Z}.`);
8499
- return { outputs: Am({
8512
+ let i = await Em(e, n), a = i.VALKEY_PUBLIC_URL ?? i.VALKEY_URL;
8513
+ if (!a) throw Error(`Could not read VALKEY_PUBLIC_URL from the Railway Valkey service "${n}". Run \`railway tcp-proxy create --port ${Fp} --service ${n}\`, or set ${Nf("services", "valkey", "external")} in ${Z}.`);
8514
+ return { outputs: jm({
8500
8515
  VALKEY_URL: a,
8501
8516
  VALKEY_PASSWORD: i.VALKEY_PASSWORD ?? ""
8502
8517
  }) };
8503
8518
  }
8504
- async function Mm(e, t) {
8519
+ async function Nm(e, t) {
8505
8520
  let n = O(24).toString("base64url"), r = await e.runner.run({
8506
8521
  command: "railway",
8507
8522
  args: [
8508
8523
  "add",
8509
8524
  "--image",
8510
- Np,
8525
+ Pp,
8511
8526
  "--service",
8512
8527
  t,
8513
8528
  "--variables",
8514
- `VALKEY_PORT=${Pp}`,
8529
+ `VALKEY_PORT=${Fp}`,
8515
8530
  "--variables",
8516
8531
  `VALKEY_PASSWORD=${n}`,
8517
8532
  "--variables",
@@ -8526,32 +8541,32 @@ async function Mm(e, t) {
8526
8541
  label: `create valkey service ${t}`
8527
8542
  });
8528
8543
  if (r.exitCode !== 0) throw Error(`Could not create the Railway Valkey service "${t}":\n${r.stderr.trim()}`);
8529
- let i = sm(r.stdout)?.id;
8544
+ let i = cm(r.stdout)?.id;
8530
8545
  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 ${Nf("services", "valkey", "external")} in ${Z}.`);
8531
- await Vm(e, {
8546
+ await Hm(e, {
8532
8547
  name: t,
8533
8548
  serviceId: i,
8534
- command: Ip
8535
- }), await eh(e, {
8549
+ command: Lp
8550
+ }), await th(e, {
8536
8551
  name: t,
8537
8552
  serviceId: i,
8538
- mountPath: Fp,
8553
+ mountPath: Ip,
8539
8554
  consequence: "everything cached in it would be lost on the next restart"
8540
- }), await Gm(e, {
8555
+ }), await Km(e, {
8541
8556
  name: t,
8542
- port: Pp
8543
- }), await Nm(e, {
8557
+ port: Fp
8558
+ }), await Pm(e, {
8544
8559
  name: t,
8545
8560
  serviceId: i
8546
8561
  }), e.log?.(`Waiting for ${t} to come up`);
8547
- let a = await Rm(e, {
8562
+ let a = await zm(e, {
8548
8563
  name: t,
8549
8564
  serviceId: i,
8550
- timeoutMs: Lp,
8551
- pollIntervalMs: Rp
8565
+ timeoutMs: Rp,
8566
+ pollIntervalMs: zp
8552
8567
  });
8553
8568
  if (!a.ok) {
8554
- let n = a.deploymentId && a.status ? await Bm(e, {
8569
+ let n = a.deploymentId && a.status ? await Vm(e, {
8555
8570
  id: a.deploymentId,
8556
8571
  status: a.status
8557
8572
  }) : null;
@@ -8562,8 +8577,8 @@ async function Mm(e, t) {
8562
8577
  ].filter(Boolean).join("\n"));
8563
8578
  }
8564
8579
  }
8565
- async function Nm(e, t) {
8566
- let n = await Um(e), r = await e.runner.run({
8580
+ async function Pm(e, t) {
8581
+ let n = await Wm(e), r = await e.runner.run({
8567
8582
  command: "railway",
8568
8583
  args: [
8569
8584
  "api",
@@ -8581,14 +8596,14 @@ async function Nm(e, t) {
8581
8596
  });
8582
8597
  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.`);
8583
8598
  }
8584
- function Pm(e) {
8599
+ function Fm(e) {
8585
8600
  let t = $(e.trim());
8586
- return t === null ? null : Fm(t);
8601
+ return t === null ? null : Im(t);
8587
8602
  }
8588
- function Fm(e) {
8603
+ function Im(e) {
8589
8604
  if (Array.isArray(e)) {
8590
8605
  for (let t of e) {
8591
- let e = Fm(t);
8606
+ let e = Im(t);
8592
8607
  if (e) return e;
8593
8608
  }
8594
8609
  return null;
@@ -8600,35 +8615,35 @@ function Fm(e) {
8600
8615
  status: r
8601
8616
  };
8602
8617
  for (let e of Object.values(t)) {
8603
- let t = Fm(e);
8618
+ let t = Im(e);
8604
8619
  if (t) return t;
8605
8620
  }
8606
8621
  }
8607
8622
  return null;
8608
8623
  }
8609
- function Im(e) {
8624
+ function Lm(e) {
8610
8625
  let t = [];
8611
- return Lm($(e.trim()), t), t;
8626
+ return Rm($(e.trim()), t), t;
8612
8627
  }
8613
- function Lm(e, t) {
8628
+ function Rm(e, t) {
8614
8629
  if (Array.isArray(e)) {
8615
- for (let n of e) Lm(n, t);
8630
+ for (let n of e) Rm(n, t);
8616
8631
  return;
8617
8632
  }
8618
8633
  if (typeof e == "object" && e) {
8619
8634
  let n = e;
8620
8635
  typeof n.message == "string" && n.message.length > 0 && t.push(n.message);
8621
- for (let [e, r] of Object.entries(n)) e !== "message" && Lm(r, t);
8636
+ for (let [e, r] of Object.entries(n)) e !== "message" && Rm(r, t);
8622
8637
  }
8623
8638
  }
8624
- async function Rm(e, t) {
8625
- let n = await Um(e), r = Date.now() + t.timeoutMs;
8639
+ async function zm(e, t) {
8640
+ let n = await Wm(e), r = Date.now() + t.timeoutMs;
8626
8641
  for (;;) {
8627
8642
  let i = await e.runner.run({
8628
8643
  command: "railway",
8629
8644
  args: [
8630
8645
  "api",
8631
- Up,
8646
+ Wp,
8632
8647
  "--variables",
8633
8648
  JSON.stringify({ input: {
8634
8649
  serviceId: t.serviceId,
@@ -8644,18 +8659,18 @@ async function Rm(e, t) {
8644
8659
  ok: !0,
8645
8660
  status: null
8646
8661
  };
8647
- let a = i.exitCode === 0 ? Pm(i.stdout) : null;
8662
+ let a = i.exitCode === 0 ? Fm(i.stdout) : null;
8648
8663
  if (!a) return {
8649
8664
  ok: !0,
8650
8665
  status: null,
8651
8666
  note: `could not read the deployment status of ${t.name}, so check it in the Railway dashboard`
8652
8667
  };
8653
- if (Vp.has(a.status)) return {
8668
+ if (Hp.has(a.status)) return {
8654
8669
  ok: !0,
8655
8670
  status: a.status,
8656
8671
  deploymentId: a.id
8657
8672
  };
8658
- if (Hp.has(a.status)) return {
8673
+ if (Up.has(a.status)) return {
8659
8674
  ok: !1,
8660
8675
  status: a.status,
8661
8676
  deploymentId: a.id
@@ -8666,14 +8681,14 @@ async function Rm(e, t) {
8666
8681
  deploymentId: a.id,
8667
8682
  note: `still ${a.status.toLowerCase()} after ${Math.round(t.timeoutMs / 6e4)} minutes`
8668
8683
  };
8669
- e.log?.(`${t.name} is ${a.status.toLowerCase()}`), await zm(t.pollIntervalMs);
8684
+ e.log?.(`${t.name} is ${a.status.toLowerCase()}`), await Bm(t.pollIntervalMs);
8670
8685
  }
8671
8686
  }
8672
- function zm(e) {
8687
+ function Bm(e) {
8673
8688
  return new Promise((t) => setTimeout(t, e));
8674
8689
  }
8675
- async function Bm(e, t) {
8676
- let n = t.status === "CRASHED" ? Gp : Wp, r = await e.runner.run({
8690
+ async function Vm(e, t) {
8691
+ let n = t.status === "CRASHED" ? Kp : Gp, r = await e.runner.run({
8677
8692
  command: "railway",
8678
8693
  args: [
8679
8694
  "api",
@@ -8690,11 +8705,11 @@ async function Bm(e, t) {
8690
8705
  label: "read the failed deployment's logs"
8691
8706
  });
8692
8707
  if (r.exitCode !== 0) return null;
8693
- let i = Im(r.stdout);
8708
+ let i = Lm(r.stdout);
8694
8709
  return i.length === 0 ? null : i.slice(-15).join("\n");
8695
8710
  }
8696
- async function Vm(e, t) {
8697
- let n = await Um(e), r = await e.runner.run({
8711
+ async function Hm(e, t) {
8712
+ let n = await Wm(e), r = await e.runner.run({
8698
8713
  command: "railway",
8699
8714
  args: [
8700
8715
  "api",
@@ -8712,15 +8727,15 @@ async function Vm(e, t) {
8712
8727
  label: `set the start command on ${t.name}`
8713
8728
  });
8714
8729
  if (r.exitCode !== 0) {
8715
- let e = r.stderr.trim() || r.stdout.trim(), n = Qp.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}`;
8730
+ let e = r.stderr.trim() || r.stdout.trim(), n = $p.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}`;
8716
8731
  throw Error(`Could not set the start command on the Railway service "${t.name}":\n${e}\n${n}`);
8717
8732
  }
8718
8733
  }
8719
- var Hm = /* @__PURE__ */ new WeakMap();
8720
- async function Um(e) {
8721
- let t = Hm.get(e);
8734
+ var Um = /* @__PURE__ */ new WeakMap();
8735
+ async function Wm(e) {
8736
+ let t = Um.get(e);
8722
8737
  if (t) return t;
8723
- let n = Wm((await e.runner.run({
8738
+ let n = Gm((await e.runner.run({
8724
8739
  command: "railway",
8725
8740
  args: ["status", "--json"],
8726
8741
  cwd: e.cwd,
@@ -8728,9 +8743,9 @@ async function Um(e) {
8728
8743
  label: "read the linked railway environment"
8729
8744
  })).stdout, e.plan.environment);
8730
8745
  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.`);
8731
- return Hm.set(e, n), n;
8746
+ return Um.set(e, n), n;
8732
8747
  }
8733
- function Wm(e, t) {
8748
+ function Gm(e, t) {
8734
8749
  let n = $(e.trim());
8735
8750
  if (typeof n != "object" || !n) return null;
8736
8751
  let r = n.environments, i = typeof r == "object" && r ? r.edges : void 0;
@@ -8749,7 +8764,7 @@ function Wm(e, t) {
8749
8764
  let o = a.find((e) => e.name === t);
8750
8765
  return o ? o.id : a.length === 1 ? a[0].id : null;
8751
8766
  }
8752
- async function Gm(e, t) {
8767
+ async function Km(e, t) {
8753
8768
  let n = await e.runner.run({
8754
8769
  command: "railway",
8755
8770
  args: [
@@ -8765,15 +8780,15 @@ async function Gm(e, t) {
8765
8780
  allowFailure: !0,
8766
8781
  label: `expose ${t.name} on a tcp proxy`
8767
8782
  });
8768
- n.exitCode !== 0 && !Zp.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()}`);
8783
+ n.exitCode !== 0 && !Qp.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()}`);
8769
8784
  }
8770
- var Km = {
8785
+ var qm = {
8771
8786
  RUSTFS_ENDPOINT: "ENDPOINT",
8772
8787
  RUSTFS_ACCESS_KEY: "ACCESS_KEY_ID",
8773
8788
  RUSTFS_SECRET_KEY: "SECRET_ACCESS_KEY",
8774
8789
  BUCKET_NAME: "BUCKET"
8775
8790
  };
8776
- async function qm(e, t) {
8791
+ async function Jm(e, t) {
8777
8792
  let { service: n, crossProvider: r } = t, i = n.name, a = await e.runner.run({
8778
8793
  command: "railway",
8779
8794
  args: [
@@ -8786,14 +8801,14 @@ async function qm(e, t) {
8786
8801
  label: "list railway buckets"
8787
8802
  });
8788
8803
  if (a.exitCode !== 0) {
8789
- if (!Qp.test(a.stderr + a.stdout)) throw Error(`Could not list the Railway buckets in this project:\n${a.stderr.trim()}`);
8790
- return e.log?.("This Railway CLI has no `bucket` command, so storage runs as a RustFS service instead"), $m(e, n);
8804
+ if (!$p.test(a.stderr + a.stdout)) throw Error(`Could not list the Railway buckets in this project:\n${a.stderr.trim()}`);
8805
+ return e.log?.("This Railway CLI has no `bucket` command, so storage runs as a RustFS service instead"), eh(e, n);
8791
8806
  }
8792
- Xm(a.stdout).some((e) => e.name === i) || await Jm(e, n);
8793
- let o = await xm(e, i) !== null;
8807
+ Zm(a.stdout).some((e) => e.name === i) || await Ym(e, n);
8808
+ let o = await Sm(e, i) !== null;
8794
8809
  if (!r && !o) {
8795
8810
  let e = {};
8796
- for (let [t, n] of Object.entries(Km)) e[t] = Cm(i, n);
8811
+ for (let [t, n] of Object.entries(qm)) e[t] = wm(i, n);
8797
8812
  return {
8798
8813
  outputs: e,
8799
8814
  note: `wired as Railway references to the ${i} bucket`
@@ -8811,14 +8826,14 @@ async function qm(e, t) {
8811
8826
  cwd: e.cwd,
8812
8827
  allowFailure: !0,
8813
8828
  label: `read the ${i} bucket credentials`
8814
- }), c = Qm(s.stdout);
8829
+ }), c = $m(s.stdout);
8815
8830
  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 ${Nf("services", "bucket", "external")} in ${Z}.`);
8816
8831
  return {
8817
8832
  outputs: c,
8818
8833
  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"
8819
8834
  };
8820
8835
  }
8821
- async function Jm(e, t) {
8836
+ async function Ym(e, t) {
8822
8837
  let n = await e.runner.run({
8823
8838
  command: "railway",
8824
8839
  args: [
@@ -8826,20 +8841,20 @@ async function Jm(e, t) {
8826
8841
  "create",
8827
8842
  t.name,
8828
8843
  "--region",
8829
- Ym(t.region),
8844
+ Xm(t.region),
8830
8845
  "--json"
8831
8846
  ],
8832
8847
  cwd: e.cwd,
8833
8848
  allowFailure: !0,
8834
8849
  label: `create the ${t.name} bucket`
8835
8850
  });
8836
- if (n.exitCode !== 0 && !Zp.test(n.stderr + n.stdout)) throw Error(`Could not create the Railway bucket "${t.name}":\n${n.stderr.trim()}`);
8837
- if (Zm(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.`);
8838
- }
8839
- function Ym(e) {
8840
- return e && Kp.includes(e) ? e : qp;
8851
+ if (n.exitCode !== 0 && !Qp.test(n.stderr + n.stdout)) throw Error(`Could not create the Railway bucket "${t.name}":\n${n.stderr.trim()}`);
8852
+ if (Qm(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.`);
8841
8853
  }
8842
8854
  function Xm(e) {
8855
+ return e && qp.includes(e) ? e : Jp;
8856
+ }
8857
+ function Zm(e) {
8843
8858
  let t = $(e.trim());
8844
8859
  if (!Array.isArray(t)) return [];
8845
8860
  let n = [];
@@ -8853,11 +8868,11 @@ function Xm(e) {
8853
8868
  }
8854
8869
  return n;
8855
8870
  }
8856
- function Zm(e) {
8871
+ function Qm(e) {
8857
8872
  let t = $(e.trim());
8858
8873
  return typeof t != "object" || !t ? !1 : t.staged === !0;
8859
8874
  }
8860
- function Qm(e) {
8875
+ function $m(e) {
8861
8876
  let t = $(e.trim());
8862
8877
  if (typeof t != "object" || !t) return null;
8863
8878
  let n = t, r = (e) => typeof n[e] == "string" ? n[e] : "", i = r("endpoint"), a = r("accessKeyId"), o = r("secretAccessKey");
@@ -8868,15 +8883,15 @@ function Qm(e) {
8868
8883
  BUCKET_NAME: r("bucketName")
8869
8884
  };
8870
8885
  }
8871
- async function $m(e, t) {
8872
- let n = t.name, r = await xm(e, n), i = r ? await th(e, n) : null, a = i?.accessKey ?? `hs${O(8).toString("hex")}`, o = i?.secretKey ?? O(24).toString("base64url"), s = r?.id;
8886
+ async function eh(e, t) {
8887
+ let n = t.name, r = await Sm(e, n), i = r ? await nh(e, n) : null, a = i?.accessKey ?? `hs${O(8).toString("hex")}`, o = i?.secretKey ?? O(24).toString("base64url"), s = r?.id;
8873
8888
  if (!i) {
8874
8889
  let t = await e.runner.run({
8875
8890
  command: "railway",
8876
8891
  args: [
8877
8892
  "add",
8878
8893
  "--image",
8879
- Jp,
8894
+ Yp,
8880
8895
  "--service",
8881
8896
  n,
8882
8897
  "--variables",
@@ -8884,7 +8899,7 @@ async function $m(e, t) {
8884
8899
  "--variables",
8885
8900
  `RUSTFS_SECRET_KEY=${o}`,
8886
8901
  "--variables",
8887
- `RUSTFS_ADDRESS=:${Yp}`,
8902
+ `RUSTFS_ADDRESS=:${Xp}`,
8888
8903
  "--json"
8889
8904
  ],
8890
8905
  cwd: e.cwd,
@@ -8892,18 +8907,18 @@ async function $m(e, t) {
8892
8907
  secrets: [o],
8893
8908
  label: `create object storage service ${n}`
8894
8909
  });
8895
- if (t.exitCode !== 0) throw Zp.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 ${Nf("services", "bucket", "external")} in ${Z}.`) : Error(`Could not create the Railway storage service "${n}":\n${t.stderr.trim()}`);
8896
- s = sm(t.stdout)?.id ?? s;
8910
+ if (t.exitCode !== 0) throw Qp.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 ${Nf("services", "bucket", "external")} in ${Z}.`) : Error(`Could not create the Railway storage service "${n}":\n${t.stderr.trim()}`);
8911
+ s = cm(t.stdout)?.id ?? s;
8897
8912
  }
8898
8913
  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 ${Nf("services", "bucket", "external")} in ${Z} to use storage you run yourself.`);
8899
- await eh(e, {
8914
+ await th(e, {
8900
8915
  name: n,
8901
8916
  serviceId: s,
8902
- mountPath: Xp,
8917
+ mountPath: Zp,
8903
8918
  consequence: "anything uploaded to it would be lost on the next restart"
8904
8919
  });
8905
- let c = await rm(e, n, Yp), l = c.url;
8906
- if (!l) throw Error(`Could not get a public endpoint for the Railway storage service "${n}".` + (c.output ? `\n${c.output}` : "") + `\nRun \`railway domain --service ${n} --port ${Yp}\` and set ${Nf("services", "bucket", "external")} in ${Z}.`);
8920
+ let c = await im(e, n, Xp), l = c.url;
8921
+ if (!l) throw Error(`Could not get a public endpoint for the Railway storage service "${n}".` + (c.output ? `\n${c.output}` : "") + `\nRun \`railway domain --service ${n} --port ${Xp}\` and set ${Nf("services", "bucket", "external")} in ${Z}.`);
8907
8922
  return {
8908
8923
  outputs: {
8909
8924
  RUSTFS_ENDPOINT: l,
@@ -8911,10 +8926,10 @@ async function $m(e, t) {
8911
8926
  RUSTFS_SECRET_KEY: o,
8912
8927
  BUCKET_NAME: n
8913
8928
  },
8914
- note: i ? "reusing the existing RustFS service and its keys" : `RustFS on Railway, with a volume mounted at ${Xp}`
8929
+ note: i ? "reusing the existing RustFS service and its keys" : `RustFS on Railway, with a volume mounted at ${Zp}`
8915
8930
  };
8916
8931
  }
8917
- async function eh(e, t) {
8932
+ async function th(e, t) {
8918
8933
  let n = await e.runner.run({
8919
8934
  command: "railway",
8920
8935
  args: [
@@ -8930,10 +8945,10 @@ async function eh(e, t) {
8930
8945
  allowFailure: !0,
8931
8946
  label: `attach a volume to ${t.name}`
8932
8947
  });
8933
- if (n.exitCode !== 0 && !Zp.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()}`);
8948
+ if (n.exitCode !== 0 && !Qp.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()}`);
8934
8949
  }
8935
- async function th(e, t) {
8936
- let n = await Tm(e, t), r = n.RUSTFS_ACCESS_KEY, i = n.RUSTFS_SECRET_KEY;
8950
+ async function nh(e, t) {
8951
+ let n = await Em(e, t), r = n.RUSTFS_ACCESS_KEY, i = n.RUSTFS_SECRET_KEY;
8937
8952
  return r && i ? {
8938
8953
  accessKey: r,
8939
8954
  secretKey: i
@@ -8941,32 +8956,32 @@ async function th(e, t) {
8941
8956
  }
8942
8957
  //#endregion
8943
8958
  //#region src/deploy/providers/index.ts
8944
- var nh = {
8945
- railway: lm,
8946
- fly: mp
8959
+ var rh = {
8960
+ railway: um,
8961
+ fly: hp
8947
8962
  };
8948
- function rh(e) {
8949
- return nh[e];
8963
+ function ih(e) {
8964
+ return rh[e];
8950
8965
  }
8951
8966
  //#endregion
8952
8967
  //#region src/deploy/tools.ts
8953
- var ih = "@railway/cli@5", ah = "https://api.github.com/repos/superfly/flyctl/releases/latest";
8954
- function oh() {
8968
+ var ah = "@railway/cli@5", oh = "https://api.github.com/repos/superfly/flyctl/releases/latest";
8969
+ function sh() {
8955
8970
  return T.join(w.homedir(), ".hype-stack", "tools");
8956
8971
  }
8957
- function sh(e) {
8972
+ function ch(e) {
8958
8973
  return T.join(e, "railway", "node_modules", ".bin");
8959
8974
  }
8960
- function ch(e) {
8975
+ function lh(e) {
8961
8976
  return T.join(e, "fly", "bin");
8962
8977
  }
8963
- function lh(e, t, n) {
8978
+ function uh(e, t, n) {
8964
8979
  return [e, ...(t ?? "").split(n).filter((t) => t.length > 0 && t !== e)].join(n);
8965
8980
  }
8966
- function uh(e) {
8967
- process.env.PATH = lh(e, process.env.PATH, T.delimiter);
8968
- }
8969
8981
  function dh(e) {
8982
+ process.env.PATH = uh(e, process.env.PATH, T.delimiter);
8983
+ }
8984
+ function fh(e) {
8970
8985
  let t;
8971
8986
  try {
8972
8987
  t = JSON.parse(e);
@@ -8977,7 +8992,7 @@ function dh(e) {
8977
8992
  let n = t.tag_name;
8978
8993
  return typeof n == "string" && n.length > 0 ? n : null;
8979
8994
  }
8980
- function fh(e, t, n) {
8995
+ function ph(e, t, n) {
8981
8996
  let r = {
8982
8997
  darwin: "macOS",
8983
8998
  linux: "Linux",
@@ -8988,39 +9003,39 @@ function fh(e, t, n) {
8988
9003
  }[t];
8989
9004
  return !r || !i ? null : `flyctl_${n.replace(/^v/, "")}_${r}_${i}.${e === "win32" ? "zip" : "tar.gz"}`;
8990
9005
  }
8991
- function ph(e) {
9006
+ function mh(e) {
8992
9007
  return process.platform === "win32" ? `${e}.exe` : e;
8993
9008
  }
8994
- function mh() {
9009
+ function hh() {
8995
9010
  return process.platform === "win32" ? "npm.cmd" : "npm";
8996
9011
  }
8997
- async function hh(e) {
8998
- let t = sh(e);
9012
+ async function gh(e) {
9013
+ let t = ch(e);
8999
9014
  return le(T.join(t, "railway")) || le(T.join(t, "railway.cmd"));
9000
9015
  }
9001
- async function gh(e) {
9002
- if (await hh(e)) return sh(e);
9016
+ async function _h(e) {
9017
+ if (await gh(e)) return ch(e);
9003
9018
  let t = T.join(e, "railway");
9004
9019
  await C.mkdir(t, { recursive: !0 });
9005
- let n = await W(mh(), [
9020
+ let n = await W(hh(), [
9006
9021
  "install",
9007
- ih,
9022
+ ah,
9008
9023
  "--prefix",
9009
9024
  t,
9010
9025
  "--no-fund",
9011
9026
  "--no-audit",
9012
9027
  "--loglevel=error"
9013
9028
  ], { cwd: e }).catch(() => null);
9014
- return !n || n.exitCode !== 0 ? null : await hh(e) ? sh(e) : null;
9029
+ return !n || n.exitCode !== 0 ? null : await gh(e) ? ch(e) : null;
9015
9030
  }
9016
- async function _h(e) {
9017
- let t = ch(e), n = T.join(t, ph("fly"));
9031
+ async function vh(e) {
9032
+ let t = lh(e), n = T.join(t, mh("fly"));
9018
9033
  if (le(n)) return t;
9019
- let r = await fetch(ah, { headers: { "user-agent": "hype-stack-cli" } }).catch(() => null);
9034
+ let r = await fetch(oh, { headers: { "user-agent": "hype-stack-cli" } }).catch(() => null);
9020
9035
  if (!r?.ok) return null;
9021
- let i = dh(await r.text());
9036
+ let i = fh(await r.text());
9022
9037
  if (!i) return null;
9023
- let a = fh(process.platform, process.arch, i);
9038
+ let a = ph(process.platform, process.arch, i);
9024
9039
  if (!a) return null;
9025
9040
  let o = await fetch(`https://github.com/superfly/flyctl/releases/download/${i}/${a}`).catch(() => null);
9026
9041
  if (!o?.ok) return null;
@@ -9034,42 +9049,42 @@ async function _h(e) {
9034
9049
  t
9035
9050
  ], { cwd: t }).catch(() => null);
9036
9051
  if (await C.rm(s, { force: !0 }), !c || c.exitCode !== 0) return null;
9037
- let l = T.join(t, ph("flyctl"));
9052
+ let l = T.join(t, mh("flyctl"));
9038
9053
  return !le(n) && le(l) && await C.copyFile(l, n), le(n) ? (process.platform !== "win32" && await C.chmod(n, 493), t) : null;
9039
9054
  }
9040
- async function vh(e, t = oh()) {
9041
- let n = e.id === "railway" ? await gh(t) : await _h(t);
9042
- return n && uh(n), n;
9055
+ async function yh(e, t = sh()) {
9056
+ let n = e.id === "railway" ? await _h(t) : await vh(t);
9057
+ return n && dh(n), n;
9043
9058
  }
9044
9059
  //#endregion
9045
9060
  //#region src/deploy/auth.ts
9046
- function yh() {
9061
+ function bh() {
9047
9062
  return {
9048
- createRunner: (e) => Ap({ env: e }),
9063
+ createRunner: (e) => jp({ env: e }),
9049
9064
  runInteractive: async (e, t, n) => (await Ci(e, t, { cwd: n })).exitCode,
9050
- bootstrapCli: (e) => vh(e),
9051
- confirmInstall: Ah,
9052
- chooseMethod: jh,
9053
- readToken: Nh,
9054
- chooseScope: Mh
9065
+ bootstrapCli: (e) => yh(e),
9066
+ confirmInstall: jh,
9067
+ chooseMethod: Mh,
9068
+ readToken: Ph,
9069
+ chooseScope: Nh
9055
9070
  };
9056
9071
  }
9057
- async function bh(e) {
9058
- let t = e.io ?? yh(), n = {}, r = {};
9072
+ async function xh(e) {
9073
+ let t = e.io ?? bh(), n = {}, r = {};
9059
9074
  for (let i of e.providers) {
9060
- let a = Bf[i], o = e.adapters?.[i] ?? rh(i), s = {
9075
+ let a = Bf[i], o = e.adapters?.[i] ?? ih(i), s = {
9061
9076
  io: t,
9062
9077
  spec: a,
9063
9078
  plan: e.plan,
9064
9079
  skipPrompts: e.skipPrompts,
9065
9080
  env: r
9066
9081
  };
9067
- await xh(s);
9068
- let c = await Th({
9082
+ await Sh(s);
9083
+ let c = await Eh({
9069
9084
  ...s,
9070
9085
  adapter: o
9071
9086
  });
9072
- r = c.env, c.account && (n[i] = c.account), await Eh({
9087
+ r = c.env, c.account && (n[i] = c.account), await Dh({
9073
9088
  ...s,
9074
9089
  env: r,
9075
9090
  adapter: o
@@ -9080,20 +9095,20 @@ async function bh(e) {
9080
9095
  accounts: n
9081
9096
  };
9082
9097
  }
9083
- async function xh(e) {
9098
+ async function Sh(e) {
9084
9099
  let { io: t, spec: n, plan: r, skipPrompts: i } = e;
9085
- if (await Sh(e)) return;
9086
- if (t.bootstrapCli && (Tt(`Fetching the ${n.label} CLI (one-time, into ~/.hype-stack/tools)...`), await t.bootstrapCli(n).catch(() => null) && await Sh(e))) {
9100
+ if (await Ch(e)) return;
9101
+ if (t.bootstrapCli && (Tt(`Fetching the ${n.label} CLI (one-time, into ~/.hype-stack/tools)...`), await t.bootstrapCli(n).catch(() => null) && await Ch(e))) {
9087
9102
  Dt(n.label, "CLI ready");
9088
9103
  return;
9089
9104
  }
9090
9105
  let a = `The ${n.label} CLI is not on your PATH. Install it with ${P.command(n.install)} and run deploy again. ${F(n.docs)}`;
9091
- (i || !Ch()) && R(a, { reason: "input_required" }), ut({
9106
+ (i || !wh()) && R(a, { reason: "input_required" }), ut({
9092
9107
  reason: "input_required",
9093
9108
  message: a
9094
- }), await t.confirmInstall(n) || R(a, { reason: "input_required" }), await t.runInteractive("sh", ["-c", n.install], r.projectRoot), await Sh(e) || R(`That did not put ${P.command(n.bin)} on your PATH. ${a}`, { reason: "input_required" });
9109
+ }), await t.confirmInstall(n) || R(a, { reason: "input_required" }), await t.runInteractive("sh", ["-c", n.install], r.projectRoot), await Ch(e) || R(`That did not put ${P.command(n.bin)} on your PATH. ${a}`, { reason: "input_required" });
9095
9110
  }
9096
- async function Sh(e) {
9111
+ async function Ch(e) {
9097
9112
  let t = await e.io.createRunner(e.env).run({
9098
9113
  command: e.spec.bin,
9099
9114
  args: ["--version"],
@@ -9102,11 +9117,11 @@ async function Sh(e) {
9102
9117
  }).catch(() => null);
9103
9118
  return t !== null && t.exitCode === 0;
9104
9119
  }
9105
- function Ch() {
9120
+ function wh() {
9106
9121
  return process.platform !== "win32";
9107
9122
  }
9108
- var wh = 3;
9109
- async function Th(e) {
9123
+ var Th = 3;
9124
+ async function Eh(e) {
9110
9125
  let { io: t, spec: n, plan: r, skipPrompts: i, adapter: a } = e, o = { ...e.env }, s = 0;
9111
9126
  for (;;) {
9112
9127
  let e = {
@@ -9118,26 +9133,26 @@ async function Th(e) {
9118
9133
  account: c.account,
9119
9134
  env: o
9120
9135
  };
9121
- let l = Dh(n, o);
9136
+ let l = Oh(n, o);
9122
9137
  if (l) {
9123
9138
  Object.assign(o, l);
9124
9139
  continue;
9125
9140
  }
9126
- i && R(kh(n), { reason: "auth_required" }), ut({
9141
+ i && R(Ah(n), { reason: "auth_required" }), ut({
9127
9142
  reason: "auth_required",
9128
- message: kh(n)
9129
- }), s >= wh && R(`${n.label} still does not know who you are. ${kh(n)}`, { reason: "auth_required" }), s += 1;
9143
+ message: Ah(n)
9144
+ }), s >= Th && R(`${n.label} still does not know who you are. ${Ah(n)}`, { reason: "auth_required" }), s += 1;
9130
9145
  let u = await t.chooseMethod(n);
9131
9146
  if (u === "token") {
9132
9147
  let e = await t.readToken(n);
9133
- Object.assign(o, Oh(n.conflictingTokenEnv), { [n.tokenEnv]: e });
9148
+ Object.assign(o, kh(n.conflictingTokenEnv), { [n.tokenEnv]: e });
9134
9149
  continue;
9135
9150
  }
9136
9151
  let d = u === "browserless" ? n.browserlessLoginArgs ?? n.loginArgs : n.loginArgs;
9137
9152
  await t.runInteractive(n.bin, d, r.projectRoot);
9138
9153
  }
9139
9154
  }
9140
- async function Eh(e) {
9155
+ async function Dh(e) {
9141
9156
  let { io: t, spec: n, plan: r, skipPrompts: i, env: a, adapter: o } = e, { scope: s } = o;
9142
9157
  if (!s || s.current(r)) return;
9143
9158
  let c = await s.list({
@@ -9155,27 +9170,27 @@ async function Eh(e) {
9155
9170
  message: l
9156
9171
  }), s.pin(r, await t.chooseScope(n, s, c));
9157
9172
  }
9158
- function Dh(e, t) {
9173
+ function Oh(e, t) {
9159
9174
  let n = (e.conflictingTokenEnv ?? []).filter((e) => !(e in t) && process.env[e] !== void 0);
9160
9175
  if (n.length === 0) return null;
9161
9176
  for (let t of n) wt(`${P.label(t)} is set in your shell, but it cannot create a ${e.label} project. Ignoring it for this run.`);
9162
- return Oh(n);
9177
+ return kh(n);
9163
9178
  }
9164
- function Oh(e = []) {
9179
+ function kh(e = []) {
9165
9180
  return Object.fromEntries(e.map((e) => [e, void 0]));
9166
9181
  }
9167
- function kh(e) {
9182
+ function Ah(e) {
9168
9183
  let t = P.command(`${e.bin} ${e.loginArgs.join(" ")}`);
9169
9184
  return `Not signed in to ${e.label}. Run ${t}, or set ${P.label(e.tokenEnv)} to a token from ${F(e.tokenUrl)}.`;
9170
9185
  }
9171
- async function Ah(e) {
9186
+ async function jh(e) {
9172
9187
  let t = await c.confirm({
9173
9188
  message: `Deploying needs the ${P.highlight(e.label)} CLI. Install it with ${P.command(e.install)}?`,
9174
9189
  initialValue: !0
9175
9190
  });
9176
9191
  return c.isCancel(t) && z(), t;
9177
9192
  }
9178
- async function jh(e) {
9193
+ async function Mh(e) {
9179
9194
  let t = [{
9180
9195
  value: "browser",
9181
9196
  label: "Log in through the browser",
@@ -9197,7 +9212,7 @@ async function jh(e) {
9197
9212
  });
9198
9213
  return c.isCancel(n) && z(), n;
9199
9214
  }
9200
- async function Mh(e, t, n) {
9215
+ async function Nh(e, t, n) {
9201
9216
  let r = await c.select({
9202
9217
  message: `Which ${P.highlight(e.label)} ${t.label} should this project live in?`,
9203
9218
  options: n.map((e) => ({
@@ -9208,7 +9223,7 @@ async function Mh(e, t, n) {
9208
9223
  });
9209
9224
  return c.isCancel(r) && z(), r;
9210
9225
  }
9211
- async function Nh(e) {
9226
+ async function Ph(e) {
9212
9227
  c.log.info(`Create one at ${F(e.tokenUrl)}. Give it the workspace this project should live in, not a single project.`);
9213
9228
  let t = await c.password({
9214
9229
  message: `Paste your ${e.label} token`,
@@ -9218,59 +9233,59 @@ async function Nh(e) {
9218
9233
  }
9219
9234
  //#endregion
9220
9235
  //#region src/deploy/config.ts
9221
- var Ph = j.enum(Lf), Fh = j.object({
9222
- provider: Ph,
9236
+ var Fh = j.enum(Lf), Ih = j.object({
9237
+ provider: Fh,
9223
9238
  app: j.string().min(1).optional(),
9224
9239
  region: j.string().min(1).optional(),
9225
9240
  url: j.string().url().optional()
9226
- }), Ih = j.object({
9227
- provider: Ph,
9241
+ }), Lh = j.object({
9242
+ provider: Fh,
9228
9243
  name: j.string().min(1).optional(),
9229
9244
  region: j.string().min(1).optional(),
9230
9245
  external: j.record(j.string(), j.string()).optional()
9231
- }), Lh = j.object({
9246
+ }), Rh = j.object({
9232
9247
  org: j.string().min(1).optional(),
9233
9248
  postgresPlan: j.string().min(1).optional()
9234
- }), Rh = j.object({ workspace: j.string().min(1).optional() }), zh = j.object({
9249
+ }), zh = j.object({ workspace: j.string().min(1).optional() }), Bh = j.object({
9235
9250
  version: j.number().int().positive(),
9236
9251
  projectName: j.string().min(1),
9237
9252
  environment: j.string().min(1),
9238
- defaultProvider: Ph.optional(),
9253
+ defaultProvider: Fh.optional(),
9239
9254
  targets: j.object({
9240
- backend: Fh.optional(),
9241
- frontend: Fh.optional(),
9242
- admin: Fh.optional()
9255
+ backend: Ih.optional(),
9256
+ frontend: Ih.optional(),
9257
+ admin: Ih.optional()
9243
9258
  }).default({}),
9244
9259
  services: j.object({
9245
- postgres: Ih.optional(),
9246
- valkey: Ih.optional(),
9247
- bucket: Ih.optional()
9260
+ postgres: Lh.optional(),
9261
+ valkey: Lh.optional(),
9262
+ bucket: Lh.optional()
9248
9263
  }).default({}),
9249
- fly: Lh.optional(),
9250
- railway: Rh.optional()
9264
+ fly: Rh.optional(),
9265
+ railway: zh.optional()
9251
9266
  });
9252
- async function Bh(e) {
9267
+ async function Vh(e) {
9253
9268
  let t = await J(e).catch((e) => {
9254
9269
  throw Error(`Could not read ${Z}: ${e instanceof Error ? e.message : String(e)}. Fix it, then run deploy again.`);
9255
9270
  });
9256
9271
  if (!t) throw Error(`No ${Z} 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".`);
9257
9272
  return t;
9258
9273
  }
9259
- async function Vh(e) {
9260
- let t = (await Bh(e))[Mf];
9274
+ async function Hh(e) {
9275
+ let t = (await Vh(e))[Mf];
9261
9276
  if (t === void 0) return null;
9262
- let n = zh.safeParse(t);
9277
+ let n = Bh.safeParse(t);
9263
9278
  if (!n.success) throw Error(`Invalid "${Mf}" block in ${Z}:\n ${j.prettifyError(n.error)}`);
9264
9279
  if (n.data.version > 1) throw Error(`The "${Mf}" block in ${Z} was written by a newer CLI (version ${n.data.version}, this CLI understands 1). Upgrade with "npm i -g @hype-stack/cli".`);
9265
9280
  return n.data;
9266
9281
  }
9267
- async function Hh(e, t) {
9282
+ async function Uh(e, t) {
9268
9283
  await ma(e, {
9269
- ...await Bh(e),
9270
- [Mf]: Wh(t)
9284
+ ...await Vh(e),
9285
+ [Mf]: Gh(t)
9271
9286
  });
9272
9287
  }
9273
- function Uh(e, t = Pf) {
9288
+ function Wh(e, t = Pf) {
9274
9289
  return {
9275
9290
  version: 1,
9276
9291
  projectName: e,
@@ -9279,7 +9294,7 @@ function Uh(e, t = Pf) {
9279
9294
  services: {}
9280
9295
  };
9281
9296
  }
9282
- function Wh(e) {
9297
+ function Gh(e) {
9283
9298
  let t = {
9284
9299
  version: e.version,
9285
9300
  projectName: e.projectName,
@@ -9309,7 +9324,7 @@ function Wh(e) {
9309
9324
  }
9310
9325
  //#endregion
9311
9326
  //#region src/deploy/detect.ts
9312
- var Gh = [
9327
+ var Kh = [
9313
9328
  "@hono/node-server",
9314
9329
  "@tanstack/react-start",
9315
9330
  "@tanstack/start",
@@ -9317,32 +9332,32 @@ var Gh = [
9317
9332
  "express",
9318
9333
  "fastify"
9319
9334
  ];
9320
- function Kh(e, t, n) {
9335
+ function qh(e, t, n) {
9321
9336
  let r = Rf[t], i = n?.paths?.[r.pathKey]?.root, a = n?.apps?.[t];
9322
9337
  return T.resolve(e, i ?? a ?? r.defaultRoot);
9323
9338
  }
9324
- async function qh(e, t) {
9339
+ async function Jh(e, t) {
9325
9340
  return (await Promise.all(Ff.map(async (n) => {
9326
- let r = Kh(e, n, t);
9341
+ let r = qh(e, n, t);
9327
9342
  return await K(T.join(r, "package.json")) ? n : null;
9328
9343
  }))).filter((e) => e !== null);
9329
9344
  }
9330
- var Jh = ["build:web", "build"];
9331
- async function Yh(e, t) {
9345
+ var Yh = ["build:web", "build"];
9346
+ async function Xh(e, t) {
9332
9347
  let [n, r] = await Promise.all([K(T.join(e, "Dockerfile")), Ei(T.join(e, "package.json")).catch(() => null)]);
9333
9348
  if (n) return "node";
9334
9349
  if (Rf[t].serveMode === "node") return null;
9335
9350
  let i = r?.scripts ?? {}, a = {
9336
9351
  ...r?.dependencies,
9337
9352
  ...r?.devDependencies
9338
- }, o = Jh.some((e) => i[e] !== void 0), s = Gh.some((e) => a[e] !== void 0);
9353
+ }, o = Yh.some((e) => i[e] !== void 0), s = Kh.some((e) => a[e] !== void 0);
9339
9354
  return o || !s ? "static" : null;
9340
9355
  }
9341
- async function Xh(e, t, n) {
9342
- let r = await Promise.all(t.map(async (t) => [t, await Yh(Kh(e, t, n), t)]));
9356
+ async function Zh(e, t, n) {
9357
+ let r = await Promise.all(t.map(async (t) => [t, await Xh(qh(e, t, n), t)]));
9343
9358
  return Object.fromEntries(r);
9344
9359
  }
9345
- function Zh(e) {
9360
+ function Qh(e) {
9346
9361
  let t = {};
9347
9362
  for (let n of Ff) {
9348
9363
  let r = e[n];
@@ -9350,7 +9365,7 @@ function Zh(e) {
9350
9365
  }
9351
9366
  return t;
9352
9367
  }
9353
- async function Qh(e, t) {
9368
+ async function $h(e, t) {
9354
9369
  let n = Rf[t].staticDir ?? "dist", r = [
9355
9370
  n,
9356
9371
  "dist",
@@ -9362,12 +9377,12 @@ async function Qh(e, t) {
9362
9377
  }
9363
9378
  //#endregion
9364
9379
  //#region src/deploy/dry-run.ts
9365
- var $h = "dry-run-placeholder";
9366
- function eg(e, t) {
9380
+ var eg = "dry-run-placeholder";
9381
+ function tg(e, t) {
9367
9382
  let n = e.args.indexOf(t);
9368
9383
  return n === -1 ? "app" : e.args[n + 1] ?? "app";
9369
9384
  }
9370
- var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9385
+ var ng = "dryrun00cluster", rg = "dryrun00service", ig = [
9371
9386
  {
9372
9387
  match: "fly orgs list",
9373
9388
  stdout: JSON.stringify({ personal: "Personal" })
@@ -9382,21 +9397,21 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9382
9397
  },
9383
9398
  {
9384
9399
  match: "fly mpg create",
9385
- stdout: `Managed Postgres cluster created successfully!\n ID: ${tg}\n Connection string: postgres://hype:${$h}@example.flympg.net:5432/postgres`
9400
+ stdout: `Managed Postgres cluster created successfully!\n ID: ${ng}\n Connection string: postgres://hype:${eg}@example.flympg.net:5432/postgres`
9386
9401
  },
9387
9402
  {
9388
9403
  match: "fly mpg status",
9389
9404
  stdout: JSON.stringify({
9390
9405
  data: {
9391
- id: tg,
9406
+ id: ng,
9392
9407
  status: "ready"
9393
9408
  },
9394
- credentials: { pgbouncer_uri: `postgres://hype:${$h}@example.flympg.net:5432/postgres` }
9409
+ credentials: { pgbouncer_uri: `postgres://hype:${eg}@example.flympg.net:5432/postgres` }
9395
9410
  })
9396
9411
  },
9397
9412
  {
9398
9413
  match: "fly redis create",
9399
- stdout: `Your Upstash Redis database is ready.\nPrivate URL = redis://default:${$h}@example.upstash.io:6379`
9414
+ stdout: `Your Upstash Redis database is ready.\nPrivate URL = redis://default:${eg}@example.upstash.io:6379`
9400
9415
  },
9401
9416
  {
9402
9417
  match: "fly redis status",
@@ -9405,10 +9420,10 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9405
9420
  {
9406
9421
  match: "fly storage create",
9407
9422
  stdout: (e) => [
9408
- `BUCKET_NAME: ${eg(e, "--name")}`,
9423
+ `BUCKET_NAME: ${tg(e, "--name")}`,
9409
9424
  "AWS_ENDPOINT_URL_S3: https://fly.storage.tigris.dev",
9410
- `AWS_ACCESS_KEY_ID: ${$h}`,
9411
- `AWS_SECRET_ACCESS_KEY: ${$h}`
9425
+ `AWS_ACCESS_KEY_ID: ${eg}`,
9426
+ `AWS_SECRET_ACCESS_KEY: ${eg}`
9412
9427
  ].join("\n")
9413
9428
  },
9414
9429
  {
@@ -9426,8 +9441,8 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9426
9441
  {
9427
9442
  match: "railway add",
9428
9443
  stdout: (e) => JSON.stringify({
9429
- id: ng,
9430
- name: eg(e, "--service")
9444
+ id: rg,
9445
+ name: tg(e, "--service")
9431
9446
  })
9432
9447
  },
9433
9448
  {
@@ -9442,18 +9457,18 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9442
9457
  },
9443
9458
  {
9444
9459
  match: "railway domain list",
9445
- stdout: (e) => JSON.stringify({ domains: [{ domain: `${eg(e, "--service")}-production.up.railway.app` }] })
9460
+ stdout: (e) => JSON.stringify({ domains: [{ domain: `${tg(e, "--service")}-production.up.railway.app` }] })
9446
9461
  },
9447
9462
  {
9448
9463
  match: "railway domain",
9449
- stdout: (e) => JSON.stringify({ domain: `${eg(e, "--service")}-production.up.railway.app` })
9464
+ stdout: (e) => JSON.stringify({ domain: `${tg(e, "--service")}-production.up.railway.app` })
9450
9465
  },
9451
9466
  {
9452
9467
  match: "railway variable list",
9453
9468
  stdout: [
9454
- `DATABASE_PUBLIC_URL=postgres://postgres:${$h}@example.proxy.rlwy.net:5432/railway`,
9455
- `VALKEY_PUBLIC_URL=redis://default:${$h}@example.proxy.rlwy.net:6379`,
9456
- `VALKEY_PASSWORD=${$h}`
9469
+ `DATABASE_PUBLIC_URL=postgres://postgres:${eg}@example.proxy.rlwy.net:5432/railway`,
9470
+ `VALKEY_PUBLIC_URL=redis://default:${eg}@example.proxy.rlwy.net:6379`,
9471
+ `VALKEY_PASSWORD=${eg}`
9457
9472
  ].join("\n")
9458
9473
  },
9459
9474
  {
@@ -9465,7 +9480,7 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9465
9480
  stdout: (e) => JSON.stringify({
9466
9481
  id: "dryrun00bucket",
9467
9482
  name: e.args[2] ?? "bucket",
9468
- region: eg(e, "--region"),
9483
+ region: tg(e, "--region"),
9469
9484
  staged: !1,
9470
9485
  committed: !0
9471
9486
  })
@@ -9474,9 +9489,9 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9474
9489
  match: "railway bucket credentials",
9475
9490
  stdout: JSON.stringify({
9476
9491
  endpoint: "https://storage.railway.app",
9477
- accessKeyId: $h,
9478
- secretAccessKey: $h,
9479
- bucketName: `dry-run-bucket-${$h}`,
9492
+ accessKeyId: eg,
9493
+ secretAccessKey: eg,
9494
+ bucketName: `dry-run-bucket-${eg}`,
9480
9495
  region: "auto",
9481
9496
  urlStyle: "virtual"
9482
9497
  })
@@ -9485,7 +9500,7 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9485
9500
  match: "railway api",
9486
9501
  stdout: JSON.stringify({ data: { serviceInstanceUpdate: !0 } })
9487
9502
  }
9488
- ], ig = {
9503
+ ], ag = {
9489
9504
  backend: [
9490
9505
  "NODE_ENV",
9491
9506
  "APP_ENV",
@@ -9511,30 +9526,30 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9511
9526
  "VITE_APP_TYPE",
9512
9527
  "VITE_ENVIRONMENT"
9513
9528
  ]
9514
- }, ag = new Set([
9529
+ }, og = new Set([
9515
9530
  "VITE_SENTRY_AUTH_TOKEN",
9516
9531
  "POSTGRES_USER",
9517
9532
  "POSTGRES_PASSWORD",
9518
9533
  "POSTGRES_DB",
9519
9534
  "POSTGRES_HOST",
9520
9535
  "POSTGRES_PORT"
9521
- ]), og = /(?:^|\/\/|@)(?:localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.internal)(?::\d+)?(?:\/|$)/i;
9522
- function sg(e) {
9536
+ ]), sg = /(?:^|\/\/|@)(?:localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.internal)(?::\d+)?(?:\/|$)/i;
9537
+ function cg(e) {
9523
9538
  let { plan: t, serviceOutputs: n, urls: r, localEnv: i = {}, declaredKeys: a = {}, exampleEnv: o = {}, externallyProvided: s = {} } = e;
9524
9539
  return t.targets.map((e) => {
9525
- let c = cg(e, t, r), l = hg({
9540
+ let c = lg(e, t, r), l = gg({
9526
9541
  target: e.target,
9527
9542
  environment: t.environment,
9528
9543
  port: e.spec.port,
9529
9544
  serviceOutputs: n,
9530
9545
  urls: c
9531
- }), u = a[e.target] ?? [], d = i[e.target] ?? {}, f = c[e.target], { forwarded: p, rehosted: m, skippedLocal: h } = _g({
9546
+ }), u = a[e.target] ?? [], d = i[e.target] ?? {}, f = c[e.target], { forwarded: p, rehosted: m, skippedLocal: h } = vg({
9532
9547
  declared: u,
9533
9548
  local: d,
9534
9549
  managed: l,
9535
9550
  origin: f,
9536
9551
  target: e.target
9537
- }), g = new Set(s[e.target] ?? []), _ = u.filter((e) => l[e] === void 0 && p[e] === void 0 && !ag.has(e) && !g.has(e)), { seeded: v, seededRehosted: y } = lg({
9552
+ }), g = new Set(s[e.target] ?? []), _ = u.filter((e) => l[e] === void 0 && p[e] === void 0 && !og.has(e) && !g.has(e)), { seeded: v, seededRehosted: y } = ug({
9538
9553
  keys: _,
9539
9554
  example: o[e.target] ?? {},
9540
9555
  origin: f
@@ -9546,26 +9561,26 @@ function sg(e) {
9546
9561
  seeded: v,
9547
9562
  rehosted: [...m, ...y],
9548
9563
  missing: b,
9549
- blank: ug(b, o[e.target] ?? {}),
9564
+ blank: dg(b, o[e.target] ?? {}),
9550
9565
  skippedLocal: h
9551
9566
  };
9552
9567
  });
9553
9568
  }
9554
- function cg(e, t, n) {
9569
+ function lg(e, t, n) {
9555
9570
  let r = e.provider === "railway" && e.target === "backend", i = {};
9556
- for (let e of t.targets) i[e.target] = r && e.provider === "railway" ? wm(e.app) : n[e.target];
9571
+ for (let e of t.targets) i[e.target] = r && e.provider === "railway" ? Tm(e.app) : n[e.target];
9557
9572
  return i;
9558
9573
  }
9559
- function lg(e) {
9574
+ function ug(e) {
9560
9575
  let t = {}, n = [];
9561
9576
  for (let r of e.keys) {
9562
9577
  let i = e.example[r];
9563
9578
  if (i === void 0 || i.trim() === "" || i.includes("${")) continue;
9564
- if (!og.test(i)) {
9579
+ if (!sg.test(i)) {
9565
9580
  t[r] = i;
9566
9581
  continue;
9567
9582
  }
9568
- let a = dg(i, e.origin);
9583
+ let a = fg(i, e.origin);
9569
9584
  a && (t[r] = a, n.push(r));
9570
9585
  }
9571
9586
  return {
@@ -9573,13 +9588,13 @@ function lg(e) {
9573
9588
  seededRehosted: n
9574
9589
  };
9575
9590
  }
9576
- function ug(e, t) {
9591
+ function dg(e, t) {
9577
9592
  return e.filter((e) => {
9578
9593
  let n = t[e];
9579
9594
  return n !== void 0 && n.trim() === "";
9580
9595
  });
9581
9596
  }
9582
- function dg(e, t) {
9597
+ function fg(e, t) {
9583
9598
  if (!t) return null;
9584
9599
  let n;
9585
9600
  try {
@@ -9589,13 +9604,13 @@ function dg(e, t) {
9589
9604
  }
9590
9605
  return /^https?:$/.test(n.protocol) ? `${t.replace(/\/+$/, "")}${n.pathname === "/" && !e.trimEnd().endsWith("/") ? "" : n.pathname}${n.search}${n.hash}` : null;
9591
9606
  }
9592
- var fg = "(pending)", pg = "https://pending.invalid";
9593
- function mg(e) {
9607
+ var pg = "(pending)", mg = "https://pending.invalid";
9608
+ function hg(e) {
9594
9609
  let { plan: t, localEnv: n, declaredKeys: r, exampleEnv: i } = e, a = {};
9595
- for (let e of t.targets) a[e.target] = e.url ?? pg;
9610
+ for (let e of t.targets) a[e.target] = e.url ?? mg;
9596
9611
  let o = {};
9597
- for (let e of t.services) o[e.service] = e.external ?? Object.fromEntries(e.spec.provides.map((e) => [e, fg]));
9598
- return sg({
9612
+ for (let e of t.services) o[e.service] = e.external ?? Object.fromEntries(e.spec.provides.map((e) => [e, pg]));
9613
+ return cg({
9599
9614
  plan: t,
9600
9615
  serviceOutputs: o,
9601
9616
  urls: a,
@@ -9604,14 +9619,14 @@ function mg(e) {
9604
9619
  exampleEnv: i
9605
9620
  });
9606
9621
  }
9607
- function hg(e) {
9622
+ function gg(e) {
9608
9623
  let { target: t, environment: n, port: r, serviceOutputs: i, urls: a } = e;
9609
- return t === "backend" ? gg({
9624
+ return t === "backend" ? _g({
9610
9625
  environment: n,
9611
9626
  port: r,
9612
9627
  serviceOutputs: i,
9613
9628
  urls: a
9614
- }) : yg(t === "frontend" ? {
9629
+ }) : bg(t === "frontend" ? {
9615
9630
  VITE_API_BASE_URL: a.backend,
9616
9631
  VITE_ADMIN_URL: a.admin,
9617
9632
  VITE_ENVIRONMENT: n
@@ -9621,9 +9636,9 @@ function hg(e) {
9621
9636
  VITE_ENVIRONMENT: n
9622
9637
  });
9623
9638
  }
9624
- function gg(e) {
9639
+ function _g(e) {
9625
9640
  let { environment: t, port: n, serviceOutputs: r, urls: i } = e;
9626
- return yg({
9641
+ return bg({
9627
9642
  NODE_ENV: "production",
9628
9643
  APP_ENV: t,
9629
9644
  PORT: n === void 0 ? void 0 : String(n),
@@ -9635,14 +9650,14 @@ function gg(e) {
9635
9650
  SERVER_URL: i.backend
9636
9651
  });
9637
9652
  }
9638
- function _g(e) {
9639
- let { declared: t, local: n, managed: r, origin: i, target: a } = e, o = new Set(ig[a]), s = {}, c = [], l = [];
9653
+ function vg(e) {
9654
+ let { declared: t, local: n, managed: r, origin: i, target: a } = e, o = new Set(ag[a]), s = {}, c = [], l = [];
9640
9655
  for (let e of t) {
9641
- if (o.has(e) || r[e] !== void 0 || ag.has(e)) continue;
9656
+ if (o.has(e) || r[e] !== void 0 || og.has(e)) continue;
9642
9657
  let t = n[e];
9643
9658
  if (!(t === void 0 || t.trim() === "") && !t.includes("${")) {
9644
- if (og.test(t)) {
9645
- let n = dg(t, i);
9659
+ if (sg.test(t)) {
9660
+ let n = fg(t, i);
9646
9661
  if (!n) {
9647
9662
  l.push(e);
9648
9663
  continue;
@@ -9659,7 +9674,7 @@ function _g(e) {
9659
9674
  skippedLocal: l
9660
9675
  };
9661
9676
  }
9662
- function vg(e) {
9677
+ function yg(e) {
9663
9678
  return {
9664
9679
  ...Object.fromEntries(e.blank.map((e) => [e, " "])),
9665
9680
  ...e.seeded,
@@ -9667,12 +9682,12 @@ function vg(e) {
9667
9682
  ...e.managed
9668
9683
  };
9669
9684
  }
9670
- function yg(e) {
9685
+ function bg(e) {
9671
9686
  let t = {};
9672
9687
  for (let [n, r] of Object.entries(e)) r !== void 0 && r !== "" && (t[n] = r);
9673
9688
  return t;
9674
9689
  }
9675
- function bg(e) {
9690
+ function xg(e) {
9676
9691
  let t = {};
9677
9692
  for (let n of e.split(/\r?\n/)) {
9678
9693
  let e = n.trim();
@@ -9680,27 +9695,27 @@ function bg(e) {
9680
9695
  let r = e.startsWith("export ") ? e.slice(7).trim() : e, i = r.indexOf("=");
9681
9696
  if (i <= 0) continue;
9682
9697
  let a = r.slice(0, i).trim();
9683
- /^[A-Za-z_][A-Za-z0-9_]*$/.test(a) && (t[a] = xg(r.slice(i + 1).trim()));
9698
+ /^[A-Za-z_][A-Za-z0-9_]*$/.test(a) && (t[a] = Sg(r.slice(i + 1).trim()));
9684
9699
  }
9685
9700
  return t;
9686
9701
  }
9687
- function xg(e) {
9702
+ function Sg(e) {
9688
9703
  if (e.length >= 2 && (e.startsWith("\"") && e.endsWith("\"") || e.startsWith("'") && e.endsWith("'"))) return e.slice(1, -1);
9689
9704
  let t = e.indexOf(" #");
9690
9705
  return t === -1 ? e : e.slice(0, t).trim();
9691
9706
  }
9692
- function Sg(e) {
9693
- return [...new Set(Object.keys(bg(e)))];
9707
+ function Cg(e) {
9708
+ return [...new Set(Object.keys(xg(e)))];
9694
9709
  }
9695
9710
  //#endregion
9696
9711
  //#region src/deploy/migrations.ts
9697
- var Cg = [
9712
+ var wg = [
9698
9713
  "migration:latest",
9699
9714
  "migrate:deploy",
9700
9715
  "db:migrate:deploy"
9701
9716
  ];
9702
- async function wg(e, t) {
9703
- let n = await Ei(T.join(e, "package.json")).catch(() => null), r = Cg.find((e) => typeof n?.scripts?.[e] == "string");
9717
+ async function Tg(e, t) {
9718
+ let n = await Ei(T.join(e, "package.json")).catch(() => null), r = wg.find((e) => typeof n?.scripts?.[e] == "string");
9704
9719
  if (r && n?.name) return [
9705
9720
  "pnpm",
9706
9721
  "--filter",
@@ -9713,7 +9728,7 @@ async function wg(e, t) {
9713
9728
  "run",
9714
9729
  r
9715
9730
  ];
9716
- let i = await Tg(e);
9731
+ let i = await Eg(e);
9717
9732
  return [
9718
9733
  "npx",
9719
9734
  "prisma",
@@ -9723,7 +9738,7 @@ async function wg(e, t) {
9723
9738
  T.relative(t, i).split(T.sep).join("/")
9724
9739
  ];
9725
9740
  }
9726
- async function Tg(e) {
9741
+ async function Eg(e) {
9727
9742
  let t = T.join(e, "prisma"), n = T.join(t, "schema");
9728
9743
  if (await G(n)) return n;
9729
9744
  let r = T.join(t, "schema.prisma");
@@ -9731,16 +9746,16 @@ async function Tg(e) {
9731
9746
  }
9732
9747
  //#endregion
9733
9748
  //#region src/deploy/orchestrate.ts
9734
- async function Eg(e) {
9749
+ async function Dg(e) {
9735
9750
  let { plan: t, runner: n, log: r } = e, i = [], a = {}, o = { ...e.knownServiceOutputs }, s = {}, c = [], l = {
9736
9751
  runner: n,
9737
9752
  plan: t,
9738
9753
  cwd: t.projectRoot,
9739
9754
  log: r
9740
- }, u = (t) => e.adapters?.[t] ?? rh(t), d = (e, n) => (i.push({
9755
+ }, u = (t) => e.adapters?.[t] ?? ih(t), d = (e, n) => (i.push({
9741
9756
  ...e,
9742
9757
  status: "failed",
9743
- detail: Mg(n)
9758
+ detail: Ng(n)
9744
9759
  }), {
9745
9760
  plan: t,
9746
9761
  steps: i,
@@ -9749,7 +9764,7 @@ async function Eg(e) {
9749
9764
  envPlans: c,
9750
9765
  ok: !1
9751
9766
  });
9752
- if (!e.skipAuthCheck) for (let n of kg(t)) {
9767
+ if (!e.skipAuthCheck) for (let n of Ag(t)) {
9753
9768
  let t = {
9754
9769
  id: `auth:${n}`,
9755
9770
  label: `Check ${n} login`
@@ -9770,6 +9785,39 @@ async function Eg(e) {
9770
9785
  detail: a.account
9771
9786
  });
9772
9787
  }
9788
+ let f = t.targets.find((e) => e.target === "backend"), p = async (t) => {
9789
+ let n = {
9790
+ id: `provision:${t.service}`,
9791
+ label: `Provision ${Q(t.service)}`
9792
+ };
9793
+ if (e.skipProvision) return i.push({
9794
+ ...n,
9795
+ status: "skipped",
9796
+ detail: "--skip-provision"
9797
+ }), null;
9798
+ try {
9799
+ r?.(`Provisioning ${Q(t.service)} on ${t.provider}`);
9800
+ let e = await u(t.provider).provisionService(l, {
9801
+ service: t,
9802
+ backend: f,
9803
+ crossProvider: f !== void 0 && f.provider !== t.provider
9804
+ });
9805
+ return o[t.service] = {
9806
+ ...o[t.service],
9807
+ ...e.outputs
9808
+ }, e.providedByProvider && f && (s[f.target] = [...s[f.target] ?? [], ...e.providedByProvider]), i.push({
9809
+ ...n,
9810
+ status: "ok",
9811
+ detail: e.note ?? Mg(e.outputs)
9812
+ }), null;
9813
+ } catch (e) {
9814
+ return d(n, e);
9815
+ }
9816
+ }, m = (e) => u(e.provider).provisionsEarly?.(e) ?? !1;
9817
+ for (let e of t.services.filter(m)) {
9818
+ let t = await p(e);
9819
+ if (t) return t;
9820
+ }
9773
9821
  for (let e of t.targets) {
9774
9822
  let t = {
9775
9823
  id: `reserve:${e.target}`,
@@ -9787,38 +9835,9 @@ async function Eg(e) {
9787
9835
  return d(t, e);
9788
9836
  }
9789
9837
  }
9790
- let f = t.targets.find((e) => e.target === "backend");
9791
- for (let n of t.services) {
9792
- let t = {
9793
- id: `provision:${n.service}`,
9794
- label: `Provision ${Q(n.service)}`
9795
- };
9796
- if (e.skipProvision) {
9797
- i.push({
9798
- ...t,
9799
- status: "skipped",
9800
- detail: "--skip-provision"
9801
- });
9802
- continue;
9803
- }
9804
- try {
9805
- r?.(`Provisioning ${Q(n.service)} on ${n.provider}`);
9806
- let e = await u(n.provider).provisionService(l, {
9807
- service: n,
9808
- backend: f,
9809
- crossProvider: f !== void 0 && f.provider !== n.provider
9810
- });
9811
- o[n.service] = {
9812
- ...o[n.service],
9813
- ...e.outputs
9814
- }, e.providedByProvider && f && (s[f.target] = [...s[f.target] ?? [], ...e.providedByProvider]), i.push({
9815
- ...t,
9816
- status: "ok",
9817
- detail: e.note ?? jg(e.outputs)
9818
- });
9819
- } catch (e) {
9820
- return d(t, e);
9821
- }
9838
+ for (let e of t.services.filter((e) => !m(e))) {
9839
+ let t = await p(e);
9840
+ if (t) return t;
9822
9841
  }
9823
9842
  for (let e of t.targets) {
9824
9843
  let t = u(e.provider);
@@ -9826,7 +9845,7 @@ async function Eg(e) {
9826
9845
  let n = await t.existingEnvKeys(l, e).catch(() => []);
9827
9846
  n.length > 0 && (s[e.target] = [...s[e.target] ?? [], ...n]);
9828
9847
  }
9829
- c = sg({
9848
+ c = cg({
9830
9849
  plan: t,
9831
9850
  serviceOutputs: o,
9832
9851
  urls: a,
@@ -9835,9 +9854,9 @@ async function Eg(e) {
9835
9854
  exampleEnv: e.exampleEnv,
9836
9855
  externallyProvided: s
9837
9856
  });
9838
- let p = new Map(c.map((e) => [e.target, e])), m = f && !e.skipMigrations ? await wg(f.root, t.projectRoot) : void 0, h = !1, g = /* @__PURE__ */ new Set();
9857
+ let h = new Map(c.map((e) => [e.target, e])), g = f && !e.skipMigrations ? await Tg(f.root, t.projectRoot) : void 0, _ = !1, v = /* @__PURE__ */ new Set();
9839
9858
  for (let e of t.targets) {
9840
- let t = p.get(e.target), n = t ? vg(t) : {}, o = t?.blank ?? [], s = Ag(n), c = u(e.provider), d = {
9859
+ let t = h.get(e.target), n = t ? yg(t) : {}, o = t?.blank ?? [], s = jg(n), c = u(e.provider), d = {
9841
9860
  id: `env:${e.target}`,
9842
9861
  label: `Configure ${e.spec.label} env`
9843
9862
  };
@@ -9856,11 +9875,11 @@ async function Eg(e) {
9856
9875
  i.push({
9857
9876
  ...d,
9858
9877
  status: "failed",
9859
- detail: Mg(t)
9860
- }), g.add(e.target);
9878
+ detail: Ng(t)
9879
+ }), v.add(e.target);
9861
9880
  continue;
9862
9881
  }
9863
- let _ = {
9882
+ let p = {
9864
9883
  id: `deploy:${e.target}`,
9865
9884
  label: `Deploy ${e.spec.label}`
9866
9885
  };
@@ -9870,23 +9889,23 @@ async function Eg(e) {
9870
9889
  target: e,
9871
9890
  env: n,
9872
9891
  secrets: s,
9873
- releaseCommand: e === f ? m : void 0
9892
+ releaseCommand: e === f ? g : void 0
9874
9893
  });
9875
- t.url && (a[e.target] = t.url), t.releaseRan && (h = !0), i.push({
9876
- ..._,
9894
+ t.url && (a[e.target] = t.url), t.releaseRan && (_ = !0), i.push({
9895
+ ...p,
9877
9896
  status: "ok",
9878
9897
  detail: t.url ?? t.note
9879
9898
  });
9880
9899
  } catch (t) {
9881
9900
  i.push({
9882
- ..._,
9901
+ ...p,
9883
9902
  status: "failed",
9884
- detail: Mg(t)
9885
- }), g.add(e.target);
9903
+ detail: Ng(t)
9904
+ }), v.add(e.target);
9886
9905
  }
9887
9906
  }
9888
9907
  for (let e of t.targets) {
9889
- if (g.has(e.target)) continue;
9908
+ if (v.has(e.target)) continue;
9890
9909
  let t = u(e.provider);
9891
9910
  if (!t.awaitTarget) continue;
9892
9911
  let n = {
@@ -9900,13 +9919,13 @@ async function Eg(e) {
9900
9919
  ...n,
9901
9920
  status: a.ok ? "ok" : "failed",
9902
9921
  detail: a.detail
9903
- }), a.ok || g.add(e.target);
9922
+ }), a.ok || v.add(e.target);
9904
9923
  } catch (t) {
9905
9924
  i.push({
9906
9925
  ...n,
9907
9926
  status: "failed",
9908
- detail: Mg(t)
9909
- }), g.add(e.target);
9927
+ detail: Ng(t)
9928
+ }), v.add(e.target);
9910
9929
  }
9911
9930
  }
9912
9931
  if (f) {
@@ -9914,27 +9933,27 @@ async function Eg(e) {
9914
9933
  id: "migrate",
9915
9934
  label: "Apply database migrations"
9916
9935
  };
9917
- if (g.has(f.target)) i.push({
9936
+ if (v.has(f.target)) i.push({
9918
9937
  ...t,
9919
9938
  status: "skipped",
9920
9939
  detail: `not run because the ${f.spec.label} deploy failed`
9921
9940
  });
9922
- else if (e.skipMigrations || !m) i.push({
9941
+ else if (e.skipMigrations || !g) i.push({
9923
9942
  ...t,
9924
9943
  status: "skipped",
9925
9944
  detail: "--skip-migrations"
9926
9945
  });
9927
- else if (h) i.push({
9946
+ else if (_) i.push({
9928
9947
  ...t,
9929
9948
  status: "ok",
9930
- detail: `${m.join(" ")} (ran with the release)`
9949
+ detail: `${g.join(" ")} (ran with the release)`
9931
9950
  });
9932
9951
  else {
9933
- let e = await Dg({
9952
+ let e = await Og({
9934
9953
  ctx: l,
9935
9954
  adapter: u(f.provider),
9936
9955
  backend: f,
9937
- command: m
9956
+ command: g
9938
9957
  });
9939
9958
  i.push({
9940
9959
  ...t,
@@ -9951,7 +9970,7 @@ async function Eg(e) {
9951
9970
  ok: i.every((e) => e.status !== "failed")
9952
9971
  };
9953
9972
  }
9954
- async function Dg(e) {
9973
+ async function Og(e) {
9955
9974
  let { ctx: t, adapter: n, backend: r, command: i } = e;
9956
9975
  if (!n.runRemote) return {
9957
9976
  status: "skipped",
@@ -9963,37 +9982,37 @@ async function Dg(e) {
9963
9982
  status: "ok",
9964
9983
  detail: i.join(" ")
9965
9984
  };
9966
- let o = Og(a.output);
9985
+ let o = kg(a.output);
9967
9986
  return {
9968
9987
  status: "skipped",
9969
9988
  detail: `Could not run migrations remotely${o ? ` (${o})` : ""}. Run "${i.join(" ")}" against ${r.app}.`
9970
9989
  };
9971
9990
  }
9972
- function Og(e) {
9991
+ function kg(e) {
9973
9992
  let t = e.split(/\r?\n/).map((e) => e.trim()).find((e) => e.length > 0);
9974
9993
  if (t) return t.length > 160 ? `${t.slice(0, 157)}...` : t;
9975
9994
  }
9976
- function kg(e) {
9995
+ function Ag(e) {
9977
9996
  let t = /* @__PURE__ */ new Set();
9978
9997
  for (let n of e.targets) t.add(n.provider);
9979
9998
  for (let n of e.services) n.external || t.add(n.provider);
9980
9999
  return [...t];
9981
10000
  }
9982
- function Ag(e) {
10001
+ function jg(e) {
9983
10002
  return Object.entries(e).filter(([e, t]) => t.length >= 8 && !e.startsWith("VITE_") && !/^https?:\/\//.test(t)).map(([, e]) => e);
9984
10003
  }
9985
- function jg(e) {
10004
+ function Mg(e) {
9986
10005
  let t = Object.keys(e);
9987
10006
  return t.length === 0 ? void 0 : `set ${t.join(", ")}`;
9988
10007
  }
9989
- function Mg(e) {
10008
+ function Ng(e) {
9990
10009
  return e instanceof Error ? e.message : String(e);
9991
10010
  }
9992
10011
  //#endregion
9993
10012
  //#region src/deploy/plan.ts
9994
- function Ng(e) {
10013
+ function Pg(e) {
9995
10014
  let { projectRoot: t, config: n, assignment: r, stackConfig: i, serveModes: a = {}, staticDirs: o = {} } = e, s = [];
9996
- for (let [e, c] of Fg(r)) {
10015
+ for (let [e, c] of Ig(r)) {
9997
10016
  let r = n.targets[e], l = Rf[e];
9998
10017
  s.push({
9999
10018
  target: e,
@@ -10006,7 +10025,7 @@ function Ng(e) {
10006
10025
  app: r?.app ?? Kf(n.projectName, e, c),
10007
10026
  region: r?.region,
10008
10027
  url: r?.url,
10009
- root: Kh(t, e, i)
10028
+ root: qh(t, e, i)
10010
10029
  });
10011
10030
  }
10012
10031
  let c = [];
@@ -10033,20 +10052,20 @@ function Ng(e) {
10033
10052
  railway: n.railway ?? {}
10034
10053
  };
10035
10054
  }
10036
- var Pg = [
10055
+ var Fg = [
10037
10056
  "frontend",
10038
10057
  "admin",
10039
10058
  "backend"
10040
10059
  ];
10041
- function Fg(e) {
10060
+ function Ig(e) {
10042
10061
  let t = [];
10043
- for (let n of Pg) {
10062
+ for (let n of Fg) {
10044
10063
  let r = e.targets[n];
10045
10064
  r && t.push([n, r]);
10046
10065
  }
10047
10066
  return t;
10048
10067
  }
10049
- function Ig(e, t) {
10068
+ function Lg(e, t) {
10050
10069
  let n = {
10051
10070
  ...e,
10052
10071
  environment: t.environment,
@@ -10076,20 +10095,20 @@ function Ig(e, t) {
10076
10095
  }
10077
10096
  //#endregion
10078
10097
  //#region src/deploy/project-env.ts
10079
- async function Lg(e) {
10098
+ async function Rg(e) {
10080
10099
  return await K(e) ? C.readFile(e, "utf-8") : null;
10081
10100
  }
10082
- async function Rg(e, t) {
10083
- let n = bg(await Lg(T.join(e, ".env")) ?? ""), r = await Promise.all(t.map(async (e) => {
10084
- let [t, r] = await Promise.all([Lg(T.join(e.root, ".env")), Lg(T.join(e.root, ".env.example"))]);
10101
+ async function zg(e, t) {
10102
+ let n = xg(await Rg(T.join(e, ".env")) ?? ""), r = await Promise.all(t.map(async (e) => {
10103
+ let [t, r] = await Promise.all([Rg(T.join(e.root, ".env")), Rg(T.join(e.root, ".env.example"))]);
10085
10104
  return {
10086
10105
  target: e.target,
10087
10106
  local: {
10088
10107
  ...n,
10089
- ...bg(t ?? "")
10108
+ ...xg(t ?? "")
10090
10109
  },
10091
- declared: Sg(r ?? ""),
10092
- example: bg(r ?? "")
10110
+ declared: Cg(r ?? ""),
10111
+ example: xg(r ?? "")
10093
10112
  };
10094
10113
  })), i = {}, a = {}, o = {};
10095
10114
  for (let e of r) i[e.target] = e.local, a[e.target] = e.declared, o[e.target] = e.example;
@@ -10101,7 +10120,7 @@ async function Rg(e, t) {
10101
10120
  }
10102
10121
  //#endregion
10103
10122
  //#region src/deploy/report.ts
10104
- function zg(e) {
10123
+ function Bg(e) {
10105
10124
  let t = [];
10106
10125
  t.push(`${P.label("Project")} ${P.highlight(e.projectName)}`), t.push(`${P.label("Env")} ${P.highlight(e.environment)}`), t.push(""), t.push(P.bold("Apps"));
10107
10126
  for (let n of e.targets) {
@@ -10117,7 +10136,7 @@ function zg(e) {
10117
10136
  }
10118
10137
  return t.join("\n");
10119
10138
  }
10120
- function Bg(e) {
10139
+ function Vg(e) {
10121
10140
  let t = [];
10122
10141
  for (let n of e) {
10123
10142
  let e = Object.keys(n.managed).length, r = Object.keys(n.forwarded).length;
@@ -10129,19 +10148,19 @@ function Bg(e) {
10129
10148
  }
10130
10149
  return t.join("\n");
10131
10150
  }
10132
- function Vg(e) {
10151
+ function Hg(e) {
10133
10152
  return e.steps.map((e) => {
10134
10153
  let t = e.status === "ok" ? P.success("✓") : e.status === "skipped" ? P.warning("-") : P.error("✗"), n = e.detail ? ` ${P.muted(e.detail)}` : "";
10135
10154
  return `${t} ${e.label}${n}`;
10136
10155
  }).join("\n");
10137
10156
  }
10138
- function Hg(e) {
10157
+ function Ug(e) {
10139
10158
  return e.plan.targets.map((t) => {
10140
10159
  let n = e.urls[t.target];
10141
10160
  return n ? `${P.label(t.spec.label)} ${F(n)}` : `${P.label(t.spec.label)} ${P.muted("no public URL")}`;
10142
10161
  }).join("\n");
10143
10162
  }
10144
- function Ug(e) {
10163
+ function Wg(e) {
10145
10164
  let t = [];
10146
10165
  for (let n of e.envPlans) {
10147
10166
  let e = n.missing.filter((e) => !n.blank.includes(e));
@@ -10154,27 +10173,27 @@ function Ug(e) {
10154
10173
  }
10155
10174
  //#endregion
10156
10175
  //#region src/commands/deploy.ts
10157
- async function Wg(e = {}) {
10176
+ async function Gg(e = {}) {
10158
10177
  let t = T.resolve(e.cwd ?? process.cwd()), n = e.yes === !0;
10159
10178
  pu(), c.intro(P.brandBold("Deploy your stack")), await va(t) || R(`${P.path(t)} doesn't look like a Hype Stack project. Run this from the project root.`, { reason: "not_a_project" }), await pa(t) || R(`${P.path(t)} has no ${P.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" });
10160
- let r = await J(t).catch(() => null), i = await Gg(t);
10161
- i ||= Uh(Wi(r?.name ?? T.basename(t))), e.environment && (i.environment = e.environment), e.flyOrg && (i.fly = {
10179
+ let r = await J(t).catch(() => null), i = await Kg(t);
10180
+ i ||= Wh(Wi(r?.name ?? T.basename(t))), e.environment && (i.environment = e.environment), e.flyOrg && (i.fly = {
10162
10181
  ...i.fly,
10163
10182
  org: e.flyOrg
10164
10183
  }), e.railwayWorkspace && (i.railway = {
10165
10184
  ...i.railway,
10166
10185
  workspace: e.railwayWorkspace
10167
10186
  });
10168
- let a = await qh(t, r);
10187
+ let a = await Jh(t, r);
10169
10188
  a.length === 0 && R("Found no deployable apps. Expected at least one of apps/backend, apps/frontend, or apps/admin.");
10170
- let o = e.only ?? [], s = qg(e.assign), l = Kg(e.provider, "--provider"), u = qf({
10189
+ let o = e.only ?? [], s = Jg(e.assign), l = qg(e.provider, "--provider"), u = qf({
10171
10190
  config: i,
10172
10191
  defaultProvider: l,
10173
10192
  overrides: s,
10174
10193
  availableTargets: a,
10175
10194
  only: o
10176
- }), d = await Xh(t, Jf(a, o), r);
10177
- n || (u = await Yg({
10195
+ }), d = await Zh(t, Jf(a, o), r);
10196
+ n || (u = await Xg({
10178
10197
  assignment: u,
10179
10198
  availableTargets: a,
10180
10199
  requestedTargets: o
@@ -10186,12 +10205,12 @@ async function Wg(e = {}) {
10186
10205
  serveModes: d
10187
10206
  });
10188
10207
  f.length > 0 && (L(Zf(f), "Cannot deploy yet"), R("Fix the assignments above and run deploy again.", { reason: "input_required" }));
10189
- let p = Zh(d), m = await $g({
10208
+ let p = Qh(d), m = await e_({
10190
10209
  cwd: t,
10191
10210
  targets: u.targets,
10192
10211
  serveModes: p,
10193
10212
  stackConfig: r
10194
- }), h = Ng({
10213
+ }), h = Pg({
10195
10214
  projectRoot: t,
10196
10215
  config: i,
10197
10216
  assignment: u,
@@ -10199,13 +10218,13 @@ async function Wg(e = {}) {
10199
10218
  serveModes: p,
10200
10219
  staticDirs: m
10201
10220
  });
10202
- L(zg(h), e.dryRun ? "Deployment plan (dry run)" : "Deployment plan");
10221
+ L(Bg(h), e.dryRun ? "Deployment plan (dry run)" : "Deployment plan");
10203
10222
  let g = e.dryRun ? {
10204
10223
  env: {},
10205
10224
  accounts: {}
10206
- } : await bh({
10225
+ } : await xh({
10207
10226
  plan: h,
10208
- providers: kg(h),
10227
+ providers: Ag(h),
10209
10228
  skipPrompts: n
10210
10229
  });
10211
10230
  if (!n && !e.dryRun) {
@@ -10214,27 +10233,27 @@ async function Wg(e = {}) {
10214
10233
  message: "Deploying creates billable infrastructure. Re-run with --yes to confirm non-interactively."
10215
10234
  });
10216
10235
  let e = await c.confirm({
10217
- message: `Create and deploy this on ${e_(h.targets.map((e) => e.provider))}?`,
10236
+ message: `Create and deploy this on ${t_(h.targets.map((e) => e.provider))}?`,
10218
10237
  initialValue: !0
10219
10238
  });
10220
10239
  (c.isCancel(e) || !e) && z();
10221
10240
  }
10222
- let _ = await Rg(t, h.targets);
10223
- L(Bg(mg({
10241
+ let _ = await zg(t, h.targets);
10242
+ L(Vg(hg({
10224
10243
  plan: h,
10225
10244
  localEnv: _.local,
10226
10245
  declaredKeys: _.declared,
10227
10246
  exampleEnv: _.example
10228
10247
  })), "Environment"), await jf(t).catch(() => null);
10229
- let v = At(), y = [], b = e.dryRun ? jp({
10248
+ let v = At(), y = [], b = e.dryRun ? Mp({
10230
10249
  onCommand: (e) => y.push(e),
10231
- responses: rg
10232
- }) : Ap({
10250
+ responses: ig
10251
+ }) : jp({
10233
10252
  onCommand: (e) => y.push(e),
10234
10253
  env: g.env
10235
10254
  });
10236
10255
  v.start(e.dryRun ? "Walking the plan" : "Deploying");
10237
- let x = await Eg({
10256
+ let x = await Dg({
10238
10257
  plan: h,
10239
10258
  runner: b,
10240
10259
  localEnv: _.local,
@@ -10246,61 +10265,61 @@ async function Wg(e = {}) {
10246
10265
  knownAccounts: g.accounts,
10247
10266
  log: (e) => v.message(e)
10248
10267
  });
10249
- if (v.stop(x.ok ? P.success("Deploy finished") : P.error("Deploy stopped")), L(Vg(x), "Steps"), e.dryRun) {
10268
+ if (v.stop(x.ok ? P.success("Deploy finished") : P.error("Deploy stopped")), L(Hg(x), "Steps"), e.dryRun) {
10250
10269
  L(y.map((e) => P.command(e)).join("\n"), "Commands that would run"), c.outro(P.muted("Dry run only. No infrastructure was created."));
10251
10270
  return;
10252
10271
  }
10253
- if (await Hh(t, Ig(i, x.plan)), !x.ok) {
10272
+ if (await Uh(t, Lg(i, x.plan)), !x.ok) {
10254
10273
  let e = x.steps.filter((e) => e.status === "failed");
10255
10274
  L(`${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 ${P.path(Z)}, so re-running picks up from here.`, "Deploy failed"), R("Deploy did not finish.");
10256
10275
  }
10257
- L(Hg(x), "Live");
10258
- let S = Ug(x);
10276
+ L(Ug(x), "Live");
10277
+ let S = Wg(x);
10259
10278
  S.length > 0 && L(S.map((e) => `${P.warning("!")} ${e}`).join("\n\n"), "Still to do"), c.outro(P.brand("Shipped."));
10260
10279
  }
10261
- async function Gg(e) {
10280
+ async function Kg(e) {
10262
10281
  try {
10263
- return await Vh(e);
10282
+ return await Hh(e);
10264
10283
  } catch (e) {
10265
10284
  R(e instanceof Error ? e.message : String(e));
10266
10285
  }
10267
10286
  }
10268
- function Kg(e, t) {
10287
+ function qg(e, t) {
10269
10288
  if (e) return Hf(e) || R(`Unknown provider "${e}" for ${t}. Pick one of ${Object.keys(Bf).join(", ")}.`), e;
10270
10289
  }
10271
- function qg(e) {
10290
+ function Jg(e) {
10272
10291
  let t = {};
10273
10292
  for (let [n, r] of Object.entries(e ?? {})) {
10274
- let e = Kg(r, `--${n}`);
10293
+ let e = qg(r, `--${n}`);
10275
10294
  e && (t[n] = e);
10276
10295
  }
10277
10296
  return t;
10278
10297
  }
10279
- function Jg(e) {
10298
+ function Yg(e) {
10280
10299
  let { assignment: t, availableTargets: n, requestedTargets: r } = e, i = Jf(n, r).filter((e) => !t.targets[e]);
10281
10300
  return {
10282
10301
  targets: i,
10283
10302
  services: t.targets.backend !== void 0 || i.includes("backend") ? If.filter((e) => !t.services[e]) : []
10284
10303
  };
10285
10304
  }
10286
- async function Yg(e) {
10305
+ async function Xg(e) {
10287
10306
  let t = {
10288
10307
  targets: { ...e.assignment.targets },
10289
10308
  services: { ...e.assignment.services }
10290
- }, { targets: n, services: r } = Jg(e);
10309
+ }, { targets: n, services: r } = Yg(e);
10291
10310
  if (n.length + r.length > 1) {
10292
- let e = await Xg();
10311
+ let e = await Zg();
10293
10312
  if (e) {
10294
10313
  for (let r of n) t.targets[r] = e;
10295
10314
  for (let n of r) t.services[n] = e;
10296
10315
  return t;
10297
10316
  }
10298
10317
  }
10299
- for (let e of n) t.targets[e] = await Qg(e, Wf(e));
10300
- for (let e of r) t.services[e] = await Qg(e, Wf(e));
10318
+ for (let e of n) t.targets[e] = await $g(e, Wf(e));
10319
+ for (let e of r) t.services[e] = await $g(e, Wf(e));
10301
10320
  return t;
10302
10321
  }
10303
- async function Xg() {
10322
+ async function Zg() {
10304
10323
  let e = await c.select({
10305
10324
  message: `Where should ${P.highlight("your stack")} live?`,
10306
10325
  options: [...Lf.map((e) => ({
@@ -10308,16 +10327,16 @@ async function Xg() {
10308
10327
  label: Uf(e),
10309
10328
  hint: `everything on ${Bf[e].bin}`
10310
10329
  })), {
10311
- value: Zg,
10330
+ value: Qg,
10312
10331
  label: "Mix providers",
10313
10332
  hint: "choose for each app and service"
10314
10333
  }],
10315
10334
  initialValue: Lf[0]
10316
10335
  });
10317
- return c.isCancel(e) && z(), e === Zg ? void 0 : e;
10336
+ return c.isCancel(e) && z(), e === Qg ? void 0 : e;
10318
10337
  }
10319
- var Zg = "__mixed__";
10320
- async function Qg(e, t) {
10338
+ var Qg = "__mixed__";
10339
+ async function $g(e, t) {
10321
10340
  if (t.length === 0 && R(`Nothing in this CLI can host ${Q(e)}. Provision it yourself and add it to the "${Mf}" block of ${Z}.`), t.length === 1) return t[0];
10322
10341
  let n = await c.select({
10323
10342
  message: `Where should ${P.highlight(Q(e))} live?`,
@@ -10330,17 +10349,17 @@ async function Qg(e, t) {
10330
10349
  });
10331
10350
  return c.isCancel(n) && z(), n;
10332
10351
  }
10333
- async function $g(e) {
10334
- let { cwd: t, targets: n, serveModes: r, stackConfig: i } = e, a = Object.keys(n).filter((e) => Vf(e) && r[e] === "static"), o = await Promise.all(a.map(async (e) => [e, await Qh(Kh(t, e, i), e)]));
10352
+ async function e_(e) {
10353
+ let { cwd: t, targets: n, serveModes: r, stackConfig: i } = e, a = Object.keys(n).filter((e) => Vf(e) && r[e] === "static"), o = await Promise.all(a.map(async (e) => [e, await $h(qh(t, e, i), e)]));
10335
10354
  return Object.fromEntries(o);
10336
10355
  }
10337
- function e_(e) {
10356
+ function t_(e) {
10338
10357
  let t = [...new Set(e)].map(Uf);
10339
10358
  return t.length <= 1 ? t[0] ?? "your provider" : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
10340
10359
  }
10341
10360
  //#endregion
10342
10361
  //#region src/commands/login.ts
10343
- async function t_() {
10362
+ async function n_() {
10344
10363
  mu(), c.intro(P.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...");
10345
10364
  let e;
10346
10365
  try {
@@ -10354,7 +10373,7 @@ async function t_() {
10354
10373
  }
10355
10374
  //#endregion
10356
10375
  //#region src/commands/logout.ts
10357
- async function n_() {
10376
+ async function r_() {
10358
10377
  mu(), c.intro(P.brandBold("Log out of Hype Stack"));
10359
10378
  let e = M(), t = await Ze(e);
10360
10379
  if (!t) {
@@ -10365,8 +10384,8 @@ async function n_() {
10365
10384
  }
10366
10385
  //#endregion
10367
10386
  //#region src/commands/mcp.ts
10368
- async function r_(e = {}) {
10369
- let t = a_(e.editor), n = yd(t), r = o_(e.scope, t, n), i = i_(e.token);
10387
+ async function i_(e = {}) {
10388
+ let t = o_(e.editor), n = yd(t), r = s_(e.scope, t, n), i = a_(e.token);
10370
10389
  if (e.print) {
10371
10390
  process.stdout.write(Sd(t, i));
10372
10391
  return;
@@ -10380,19 +10399,19 @@ async function r_(e = {}) {
10380
10399
  });
10381
10400
  a.changed ? c.log.success(`Wrote ${P.path(a.configPath)}`) : c.log.info(P.muted(`${P.path(a.configPath)} is already up to date.`)), i && c.log.warn(P.muted(`${Je} is stored in plain text. Keep this file out of version control.`)), c.outro(P.muted("Restart your editor to pick up the server."));
10382
10401
  }
10383
- function i_(e) {
10402
+ function a_(e) {
10384
10403
  return e?.trim() || void 0;
10385
10404
  }
10386
- function a_(e) {
10405
+ function o_(e) {
10387
10406
  return e ? (gd(e) || R(`Unknown editor "${e}". Expected one of: ${pd.join(", ")}.`), e) : "cursor";
10388
10407
  }
10389
- function o_(e, t, n) {
10408
+ function s_(e, t, n) {
10390
10409
  let r = e ?? n[0];
10391
10410
  return r !== "global" && r !== "project" && R(`Unknown scope "${r}". Expected global or project.`), n.includes(r) || R(`${t} does not support ${r} scope. Supported: ${n.join(", ")}.`), r;
10392
10411
  }
10393
10412
  //#endregion
10394
10413
  //#region src/ui/env-prompt.ts
10395
- var s_ = S("✔", "√"), c_ = S("✘", "x"), l_ = "\x1B[7m \x1B[27m", u_ = class extends oe {
10414
+ var c_ = S("✔", "√"), l_ = S("✘", "x"), u_ = "\x1B[7m \x1B[27m", d_ = class extends oe {
10396
10415
  constructor(e) {
10397
10416
  super({
10398
10417
  input: e.input,
@@ -10407,9 +10426,9 @@ var s_ = S("✔", "√"), c_ = S("✘", "x"), l_ = "\x1B[7m \x1B[27m", u_ = clas
10407
10426
  let { key: e, section: t, linkUrl: n, hint: r, checklist: i, currentMasked: a, progress: o } = this.promptOptions, s = y.withGuide, c = s ? `${A("gray", l)}\n` : "";
10408
10427
  if (this.state === "submit") {
10409
10428
  let t = (this.value ?? "").trim(), n = t ? P.muted(Xs(t)) : a ? P.muted(`kept ${a}`) : P.muted("left empty");
10410
- return `${c}${A("green", s_)} ${P.bold(e)} ${n}`;
10429
+ return `${c}${A("green", c_)} ${P.bold(e)} ${n}`;
10411
10430
  }
10412
- if (this.state === "cancel") return `${c}${A("red", c_)} ${A(["strikethrough", "dim"], e)}`;
10431
+ if (this.state === "cancel") return `${c}${A("red", l_)} ${A(["strikethrough", "dim"], e)}`;
10413
10432
  let d = x(this.state), f = s ? `${d} ` : "", p = b(this.state), m = o ? ` ${P.muted(o)}` : "", h = `${c}${p} ${P.bold(e)}${m}`, g = [];
10414
10433
  if (t) {
10415
10434
  let e = n ? ` ${F(n)}` : "";
@@ -10417,19 +10436,19 @@ var s_ = S("✔", "√"), c_ = S("✘", "x"), l_ = "\x1B[7m \x1B[27m", u_ = clas
10417
10436
  }
10418
10437
  if (i && i.length > 0) for (let e of i) g.push(`${f}${I.bullet} ${P.description(e)}`);
10419
10438
  r && g.push(`${f}${P.description(r)}`);
10420
- let _ = this.userInput !== "", v = a ? `${a} (Enter keeps this)` : "type a value, or Enter to skip", S = _ ? `${f}${I.arrow} ${this.userInputWithCursor}` : `${f}${I.arrow} ${l_} ${P.muted(v)}`;
10439
+ let _ = this.userInput !== "", v = a ? `${a} (Enter keeps this)` : "type a value, or Enter to skip", S = _ ? `${f}${I.arrow} ${this.userInputWithCursor}` : `${f}${I.arrow} ${u_} ${P.muted(v)}`;
10421
10440
  g.push(S), this.state === "error" && g.push(`${f}${A("yellow", this.error)}`);
10422
10441
  let C = s ? this.state === "error" ? A("yellow", u) : A("cyan", u) : "";
10423
10442
  return `${h}\n${g.join("\n")}\n${C}`;
10424
10443
  }
10425
10444
  };
10426
- async function d_(e) {
10427
- let t = await new u_(e).prompt();
10445
+ async function f_(e) {
10446
+ let t = await new d_(e).prompt();
10428
10447
  return g(t) || typeof t == "string" ? t : "";
10429
10448
  }
10430
10449
  //#endregion
10431
10450
  //#region src/commands/onboard.ts
10432
- async function f_(e = {}) {
10451
+ async function p_(e = {}) {
10433
10452
  let t = e.cwd ?? process.cwd();
10434
10453
  e.skipBanner || pu(), c.intro(P.brandBold("Onboard your stack"));
10435
10454
  let n;
@@ -10444,12 +10463,12 @@ async function f_(e = {}) {
10444
10463
  for (let e of r) await $s(e);
10445
10464
  let i = await tc(t, n);
10446
10465
  i.length > 0 && c.log.success(`Generated ${P.highlight(String(i.length))} secrets: ${i.map((e) => e.key).join(", ")}`);
10447
- let a = await p_(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 = [];
10448
- e.yes ? u.push(...o, ...l.filter((e) => !e.isSet)) : (u.push(...await m_(o)), u.push(...await h_(l)), await g_(s)), x_(u, t);
10466
+ let a = await m_(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 = [];
10467
+ e.yes ? u.push(...o, ...l.filter((e) => !e.isSet)) : (u.push(...await h_(o)), u.push(...await g_(l)), await __(s)), S_(u, t);
10449
10468
  let d = ra(n.installedPacks ?? []);
10450
10469
  d.length > 0 && L(d.map((e) => ` ${P.muted("·")} ${e}`).join("\n"), "Tips"), c.outro(P.brand(`All set. Run ${P.command("pnpm dev")} to start your app.`));
10451
10470
  }
10452
- async function p_(e, t, n) {
10471
+ async function m_(e, t, n) {
10453
10472
  let r = t.onboarding?.envVars ?? [], i = t.onboarding?.envSections ?? [], a = [];
10454
10473
  for (let e of n) {
10455
10474
  let t = T.join(T.dirname(e), ".env"), [n, o] = await Promise.all([C.readFile(e, "utf-8"), Qs(t)]);
@@ -10469,40 +10488,40 @@ async function p_(e, t, n) {
10469
10488
  }
10470
10489
  return a;
10471
10490
  }
10472
- async function m_(e) {
10473
- let t = [], n = __(e);
10491
+ async function h_(e) {
10492
+ let t = [], n = v_(e);
10474
10493
  if (n.size === 0) return t;
10475
10494
  let r = [...n.entries()].map(([e, t]) => `${P.bold(e)} ${P.muted(`(${t.length})`)}`).join(", ");
10476
10495
  c.log.step(`Keys needed for: ${r}`);
10477
10496
  for (let [e, r] of n) {
10478
10497
  let n = `${r.length} value${r.length === 1 ? "" : "s"}`;
10479
- if (!await v_(`Set up ${P.bold(e)} now? ${P.muted(`(${n})`)}`, !0)) {
10498
+ if (!await y_(`Set up ${P.bold(e)} now? ${P.muted(`(${n})`)}`, !0)) {
10480
10499
  t.push(...r);
10481
10500
  continue;
10482
10501
  }
10483
- await y_(r);
10502
+ await b_(r);
10484
10503
  }
10485
10504
  return t;
10486
10505
  }
10487
- async function h_(e) {
10506
+ async function g_(e) {
10488
10507
  let t = [];
10489
- for (let [n, r] of __(e)) {
10508
+ for (let [n, r] of v_(e)) {
10490
10509
  let e = r.every((e) => e.isSet), i = `${r.length} value${r.length === 1 ? "" : "s"}`;
10491
- if (!await v_(e ? `Update ${P.bold(n)}? ${P.muted(`(${i}, already set)`)}` : `Set up ${P.bold(n)} now? ${P.muted(`(${i}, optional)`)}`)) {
10510
+ if (!await y_(e ? `Update ${P.bold(n)}? ${P.muted(`(${i}, already set)`)}` : `Set up ${P.bold(n)} now? ${P.muted(`(${i}, optional)`)}`)) {
10492
10511
  t.push(...r.filter((e) => !e.isSet));
10493
10512
  continue;
10494
10513
  }
10495
- await y_(r);
10514
+ await b_(r);
10496
10515
  }
10497
10516
  return t;
10498
10517
  }
10499
- async function g_(e) {
10500
- for (let [t, n] of __(e)) {
10518
+ async function __(e) {
10519
+ for (let [t, n] of v_(e)) {
10501
10520
  let e = `${n.length} value${n.length === 1 ? "" : "s"}`;
10502
- await v_(`Update ${P.bold(t)}? ${P.muted(`(${e}, already set)`)}`) && await y_(n);
10521
+ await y_(`Update ${P.bold(t)}? ${P.muted(`(${e}, already set)`)}`) && await b_(n);
10503
10522
  }
10504
10523
  }
10505
- function __(e) {
10524
+ function v_(e) {
10506
10525
  let t = /* @__PURE__ */ new Map();
10507
10526
  for (let n of e) {
10508
10527
  let e = n.setup.group ?? n.section, r = t.get(e);
@@ -10510,20 +10529,20 @@ function __(e) {
10510
10529
  }
10511
10530
  return t;
10512
10531
  }
10513
- async function v_(e, t = !1) {
10532
+ async function y_(e, t = !1) {
10514
10533
  let n = await c.confirm({
10515
10534
  message: e,
10516
10535
  initialValue: t
10517
10536
  });
10518
10537
  return c.isCancel(n) && z(), n === !0;
10519
10538
  }
10520
- async function y_(e) {
10539
+ async function b_(e) {
10521
10540
  let t = Qi(e[0].section);
10522
10541
  t.link && c.log.info(P.muted(t.link));
10523
- for (let [t, n] of e.entries()) await b_(n, `${t + 1}/${e.length}`);
10542
+ for (let [t, n] of e.entries()) await x_(n, `${t + 1}/${e.length}`);
10524
10543
  }
10525
- async function b_(e, t) {
10526
- let n = Qi(e.section), r = await d_({
10544
+ async function x_(e, t) {
10545
+ let n = Qi(e.section), r = await f_({
10527
10546
  key: e.key,
10528
10547
  section: e.section,
10529
10548
  linkUrl: n.link,
@@ -10536,7 +10555,7 @@ async function b_(e, t) {
10536
10555
  let i = (typeof r == "string" ? r : "").trim();
10537
10556
  i !== "" && await ec(e.envPath, e.key, i);
10538
10557
  }
10539
- function x_(e, t) {
10558
+ function S_(e, t) {
10540
10559
  if (e.length === 0) return;
10541
10560
  let n = /* @__PURE__ */ new Map();
10542
10561
  for (let t of e) {
@@ -10556,16 +10575,16 @@ function x_(e, t) {
10556
10575
  }
10557
10576
  //#endregion
10558
10577
  //#region src/core/templates.ts
10559
- var S_ = U.createRequest()({
10578
+ var C_ = U.createRequest()({
10560
10579
  endpoint: "/templates/list",
10561
10580
  method: "GET"
10562
10581
  });
10563
- async function C_() {
10564
- let { data: e, error: t } = await S_.send();
10582
+ async function w_() {
10583
+ let { data: e, error: t } = await C_.send();
10565
10584
  if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
10566
10585
  return e.templates;
10567
10586
  }
10568
- async function w_(e) {
10587
+ async function T_(e) {
10569
10588
  let { data: t, error: n, status: r } = await U.createRequest()({
10570
10589
  endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
10571
10590
  method: "GET"
@@ -10574,7 +10593,7 @@ async function w_(e) {
10574
10593
  if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
10575
10594
  return t;
10576
10595
  }
10577
- async function T_(e, t = {}) {
10596
+ async function E_(e, t = {}) {
10578
10597
  let n = U.createRequest()({
10579
10598
  endpoint: `/templates/${encodeURIComponent(e)}/download`,
10580
10599
  method: "POST"
@@ -10611,7 +10630,7 @@ async function T_(e, t = {}) {
10611
10630
  }
10612
10631
  //#endregion
10613
10632
  //#region src/commands/template.ts
10614
- async function E_(t = {}) {
10633
+ async function D_(t = {}) {
10615
10634
  let n = t.cwd ?? process.cwd();
10616
10635
  pu(), await Yl();
10617
10636
  let r = c.spinner();
@@ -10625,7 +10644,7 @@ async function E_(t = {}) {
10625
10644
  r.stop("Packs loaded"), r.start("Loading templates...");
10626
10645
  let a;
10627
10646
  try {
10628
- a = await C_();
10647
+ a = await w_();
10629
10648
  } catch (e) {
10630
10649
  r.stop("Failed to load templates"), R(`Could not reach Hype Stack. Check your connection and try again.\n${qd(e)}`);
10631
10650
  }
@@ -10648,7 +10667,7 @@ async function E_(t = {}) {
10648
10667
  s || (r.stop("Template not found"), R(`Template "${o}" not found. Available: ${a.map((e) => e.id).join(", ") || "(none)"}`)), r.stop(`Template: ${s.name}`);
10649
10668
  let l;
10650
10669
  try {
10651
- l = await w_(s.id);
10670
+ l = await T_(s.id);
10652
10671
  } catch (e) {
10653
10672
  R(qd(e));
10654
10673
  }
@@ -10670,7 +10689,7 @@ async function E_(t = {}) {
10670
10689
  p || R(d ? `Could not read ${P.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${P.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), p.paths || R(`${P.path("stack.json")} is missing ${P.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`);
10671
10690
  let m = d ?? n;
10672
10691
  c.intro(P.brandBold("Install a template"));
10673
- let h = p.installedPacks ?? [], g = new Set(h), v = new Map(i.map((e) => [e.name, e])), y = (await Ye(M()))?.token ?? null, b = await D_(s, t.variants, t.yes ?? !1), x = eu(s.slots, b), S = tu(s.slots, s.packs, x), w = await O_({
10692
+ let h = p.installedPacks ?? [], g = new Set(h), v = new Map(i.map((e) => [e.name, e])), y = (await Ye(M()))?.token ?? null, b = await O_(s, t.variants, t.yes ?? !1), x = eu(s.slots, b), S = tu(s.slots, s.packs, x), w = await k_({
10674
10693
  packs: i,
10675
10694
  templatePacks: S,
10676
10695
  installedSet: g,
@@ -10752,7 +10771,7 @@ async function E_(t = {}) {
10752
10771
  r.stop("Files installed"), n.installed.length > 0 && c.log.success(`${P.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && (c.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`), nf(n.skipped));
10753
10772
  for (let e of n.errors) c.log.error(e);
10754
10773
  r.start("Applying template overrides...");
10755
- let i = await T_(s.id, { token: y });
10774
+ let i = await E_(s.id, { token: y });
10756
10775
  i.status === "denied" && (r.stop("Template download denied"), R(Qd(s.id, i.reason))), ce = i.templateDir;
10757
10776
  let a = await il({
10758
10777
  manifest: l,
@@ -10793,7 +10812,7 @@ async function E_(t = {}) {
10793
10812
  customization: n
10794
10813
  }), c.log.success(`Applied the ${Fc(n.theme)} theme, ${e(n.radius)} corners, and ${n.mode} mode`);
10795
10814
  }
10796
- await k_({
10815
+ await A_({
10797
10816
  prepared: se,
10798
10817
  templateNpm: l.dependencies_npm,
10799
10818
  paths: p.paths,
@@ -10823,7 +10842,7 @@ async function E_(t = {}) {
10823
10842
  });
10824
10843
  }
10825
10844
  }
10826
- async function D_(e, t, n) {
10845
+ async function O_(e, t, n) {
10827
10846
  let r = {};
10828
10847
  for (let i of e.slots) {
10829
10848
  if (t?.[i.family]) {
@@ -10847,7 +10866,7 @@ async function D_(e, t, n) {
10847
10866
  }
10848
10867
  return r;
10849
10868
  }
10850
- async function O_(e) {
10869
+ async function k_(e) {
10851
10870
  let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
10852
10871
  if (i.packs && i.packs.length > 0) {
10853
10872
  let e = i.packs.filter((e) => !t.some((t) => t.name === e));
@@ -10869,7 +10888,7 @@ async function O_(e) {
10869
10888
  });
10870
10889
  return _(c) && R("Cancelled.", { code: 0 }), c;
10871
10890
  }
10872
- async function k_(e) {
10891
+ async function A_(e) {
10873
10892
  let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o = Gd(t.map((e) => e.manifest.dependencies_npm)), s = Wd(n ? Gd([o, n]) : o, r);
10874
10893
  if (s.errors.length > 0) {
10875
10894
  for (let e of s.errors) c.log.error(e);
@@ -10882,9 +10901,9 @@ async function k_(e) {
10882
10901
  }
10883
10902
  //#endregion
10884
10903
  //#region src/mcp/guard.ts
10885
- var A_ = null;
10886
- function j_() {
10887
- if (A_) return A_.protocolStream;
10904
+ var j_ = null;
10905
+ function M_() {
10906
+ if (j_) return j_.protocolStream;
10888
10907
  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({
10889
10908
  write(t, n, r) {
10890
10909
  e(t, (e) => r(e ?? null));
@@ -10893,7 +10912,7 @@ function j_() {
10893
10912
  e();
10894
10913
  }
10895
10914
  }), s = ((e, t, n) => typeof t == "function" ? process.stderr.write(e, t) : process.stderr.write(e, t, n));
10896
- return process.stdout.write = s, console.log = console.error, console.info = console.error, console.debug = console.error, console.dir = console.error, A_ = {
10915
+ return process.stdout.write = s, console.log = console.error, console.info = console.error, console.debug = console.error, console.dir = console.error, j_ = {
10897
10916
  protocolStream: o,
10898
10917
  restore: () => {
10899
10918
  process.stdout.write = t, console.log = n, console.info = r, console.debug = i, console.dir = a;
@@ -10902,22 +10921,22 @@ function j_() {
10902
10921
  }
10903
10922
  //#endregion
10904
10923
  //#region src/mcp/result.ts
10905
- async function M_(e) {
10924
+ async function N_(e) {
10906
10925
  ot();
10907
10926
  try {
10908
- return N_({
10927
+ return P_({
10909
10928
  ...await e(),
10910
10929
  ok: !0,
10911
10930
  logs: st()
10912
10931
  }, !1);
10913
10932
  } catch (e) {
10914
- return lt(e) ? N_({
10933
+ return lt(e) ? P_({
10915
10934
  ok: !1,
10916
10935
  reason: e.reason,
10917
10936
  message: e.message,
10918
10937
  details: e.details,
10919
10938
  logs: st()
10920
- }, !1) : N_({
10939
+ }, !1) : P_({
10921
10940
  ok: !1,
10922
10941
  reason: "failed",
10923
10942
  message: e instanceof Error ? e.message : String(e),
@@ -10926,7 +10945,7 @@ async function M_(e) {
10926
10945
  }, !0);
10927
10946
  }
10928
10947
  }
10929
- function N_(e, t) {
10948
+ function P_(e, t) {
10930
10949
  return {
10931
10950
  content: [{
10932
10951
  type: "text",
@@ -10938,7 +10957,7 @@ function N_(e, t) {
10938
10957
  }
10939
10958
  //#endregion
10940
10959
  //#region src/mcp/tools/context.ts
10941
- async function P_() {
10960
+ async function F_() {
10942
10961
  let e = await Ye(M());
10943
10962
  return e ? {
10944
10963
  token: e.token,
@@ -10948,26 +10967,26 @@ async function P_() {
10948
10967
  source: "none"
10949
10968
  };
10950
10969
  }
10951
- function F_(e) {
10970
+ function I_(e) {
10952
10971
  return T.resolve(e ?? process.cwd());
10953
10972
  }
10954
- var I_ = {
10973
+ var L_ = {
10955
10974
  envVar: Je,
10956
10975
  loginCommand: "npx @hype-stack/cli login"
10957
- }, L_ = {
10976
+ }, R_ = {
10958
10977
  packs: j.array(j.string()).min(1).describe("Pack names to install. Append @frontend or @admin to a layout pack to target one shell."),
10959
10978
  cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in."),
10960
10979
  onConflict: j.enum(["keep", "overwrite"]).default("keep").describe("What to do with files that already exist: keep them, or let the pack overwrite them")
10961
10980
  };
10962
- async function R_(e) {
10963
- let t = F_(e.cwd), n = await z_(t);
10981
+ async function z_(e) {
10982
+ let t = I_(e.cwd), n = await B_(t);
10964
10983
  await cf({
10965
10984
  cwd: t,
10966
10985
  packs: e.packs,
10967
10986
  force: e.onConflict === "overwrite",
10968
10987
  yes: !0
10969
10988
  });
10970
- let r = await z_(t), i = r.filter((e) => !n.includes(e));
10989
+ let r = await B_(t), i = r.filter((e) => !n.includes(e));
10971
10990
  return {
10972
10991
  cwd: t,
10973
10992
  installed: i,
@@ -10975,21 +10994,21 @@ async function R_(e) {
10975
10994
  followUp: i.length > 0 ? [...hl, "npx @hype-stack/cli onboard"] : []
10976
10995
  };
10977
10996
  }
10978
- async function z_(e) {
10997
+ async function B_(e) {
10979
10998
  return (await J(e).catch(() => null))?.installedPacks ?? [];
10980
10999
  }
10981
11000
  //#endregion
10982
11001
  //#region src/mcp/tools/apply-template.ts
10983
- var B_ = {
11002
+ var V_ = {
10984
11003
  templateId: j.string().min(1).describe("Template id, e.g. vault. Use search_catalog to find one."),
10985
11004
  cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in."),
10986
11005
  variants: j.record(j.string(), j.string()).optional().describe("Slot overrides keyed by family, e.g. { \"starter-saas\": \"starter-saas-better-auth\" }"),
10987
11006
  packs: j.array(j.string()).optional().describe("Extra packs to install on top of the template"),
10988
11007
  onConflict: j.enum(["keep", "overwrite"]).default("keep").describe("What to do with files that already exist: keep them, or let the template overwrite them")
10989
11008
  };
10990
- async function V_(e) {
10991
- let t = F_(e.cwd), n = await H_(t);
10992
- await E_({
11009
+ async function H_(e) {
11010
+ let t = I_(e.cwd), n = await U_(t);
11011
+ await D_({
10993
11012
  cwd: t,
10994
11013
  templateId: e.templateId,
10995
11014
  variants: e.variants,
@@ -10997,7 +11016,7 @@ async function V_(e) {
10997
11016
  force: e.onConflict === "overwrite",
10998
11017
  yes: !0
10999
11018
  });
11000
- let r = await H_(t);
11019
+ let r = await U_(t);
11001
11020
  return {
11002
11021
  cwd: t,
11003
11022
  templateId: e.templateId,
@@ -11006,21 +11025,21 @@ async function V_(e) {
11006
11025
  followUp: [...hl, "npx @hype-stack/cli onboard"]
11007
11026
  };
11008
11027
  }
11009
- async function H_(e) {
11028
+ async function U_(e) {
11010
11029
  return (await J(e).catch(() => null))?.installedPacks ?? [];
11011
11030
  }
11012
11031
  //#endregion
11013
11032
  //#region src/mcp/tools/auth-status.ts
11014
- var U_ = {};
11015
- async function W_() {
11016
- let { token: e, source: t } = await P_();
11033
+ var W_ = {};
11034
+ async function G_() {
11035
+ let { token: e, source: t } = await F_();
11017
11036
  if (!e) return {
11018
11037
  authenticated: !1,
11019
11038
  tokenSource: "none",
11020
11039
  apiUrl: M(),
11021
- hint: `Run '${I_.loginCommand}' in your terminal, or add ${I_.envVar} to this server's env block in your editor's MCP config.`,
11040
+ hint: `Run '${L_.loginCommand}' in your terminal, or add ${L_.envVar} to this server's env block in your editor's MCP config.`,
11022
11041
  apiKeysUrl: `${Re()}/api-keys`,
11023
- ...I_
11042
+ ...L_
11024
11043
  };
11025
11044
  let n = await Yr(e);
11026
11045
  return n ? {
@@ -11033,14 +11052,14 @@ async function W_() {
11033
11052
  authenticated: !1,
11034
11053
  tokenSource: t,
11035
11054
  apiUrl: M(),
11036
- hint: t === "env" ? `The token in ${I_.envVar} was rejected. It may be expired or revoked; mint a new one.` : `Your saved login was rejected. Run '${I_.loginCommand}' again.`,
11055
+ hint: t === "env" ? `The token in ${L_.envVar} was rejected. It may be expired or revoked; mint a new one.` : `Your saved login was rejected. Run '${L_.loginCommand}' again.`,
11037
11056
  apiKeysUrl: `${Re()}/api-keys`,
11038
- ...I_
11057
+ ...L_
11039
11058
  };
11040
11059
  }
11041
11060
  //#endregion
11042
11061
  //#region src/mcp/tools/create-application.ts
11043
- var G_ = {
11062
+ var K_ = {
11044
11063
  name: j.string().min(1).describe("Application name. Becomes the folder name and the package scope."),
11045
11064
  directory: j.string().optional().describe("Parent folder to create the app inside. Defaults to the current workspace."),
11046
11065
  editors: j.array(j.enum(Ee)).optional().describe("AI editors to ship rule formats for. Pass every editor the team uses, they coexist. Defaults to cursor."),
@@ -11051,8 +11070,8 @@ var G_ = {
11051
11070
  adminRadius: j.string().optional().describe("Admin corner radius. Defaults to the frontend radius."),
11052
11071
  mode: j.enum(["light", "dark"]).optional().describe("Color mode the app boots in")
11053
11072
  };
11054
- async function K_(e) {
11055
- let t = F_(e.directory), n = q_(e), r = await af({
11073
+ async function q_(e) {
11074
+ let t = I_(e.directory), n = J_(e), r = await af({
11056
11075
  name: e.name,
11057
11076
  parentDirectory: t,
11058
11077
  editors: n,
@@ -11068,19 +11087,19 @@ async function K_(e) {
11068
11087
  return {
11069
11088
  projectRoot: r,
11070
11089
  editors: n,
11071
- mcpConfigPaths: J_(n, r),
11090
+ mcpConfigPaths: Y_(n, r),
11072
11091
  followUp: [`cd ${r}`, ...hl]
11073
11092
  };
11074
11093
  }
11075
- function q_(e) {
11094
+ function J_(e) {
11076
11095
  let { editors: t, unknown: n } = Ae([...e.editors ?? [], ...e.editor ? [e.editor] : []]);
11077
11096
  if (n.length > 0) throw Error(`Unknown editor "${n.join(", ")}". Expected one of: ${Ee.join(", ")}.`);
11078
11097
  return t.length > 0 ? t : [De];
11079
11098
  }
11080
- function J_(e, t) {
11081
- return vd(e).map((e) => Y_(e, t)).filter((e) => e !== null);
11082
- }
11083
11099
  function Y_(e, t) {
11100
+ return vd(e).map((e) => X_(e, t)).filter((e) => e !== null);
11101
+ }
11102
+ function X_(e, t) {
11084
11103
  try {
11085
11104
  return bd({
11086
11105
  editor: e,
@@ -11093,8 +11112,8 @@ function Y_(e, t) {
11093
11112
  }
11094
11113
  //#endregion
11095
11114
  //#region src/core/env-status.ts
11096
- async function X_(e, t) {
11097
- let n = t?.onboarding?.envSections ?? [], r = t?.onboarding?.envVars ?? [], i = await qs(e), a = await Promise.all(i.map((t) => Z_({
11115
+ async function Z_(e, t) {
11116
+ let n = t?.onboarding?.envSections ?? [], r = t?.onboarding?.envVars ?? [], i = await qs(e), a = await Promise.all(i.map((t) => Q_({
11098
11117
  examplePath: t,
11099
11118
  projectRoot: e,
11100
11119
  installedEnvSections: n,
@@ -11105,7 +11124,7 @@ async function X_(e, t) {
11105
11124
  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)
11106
11125
  };
11107
11126
  }
11108
- async function Z_(e) {
11127
+ async function Q_(e) {
11109
11128
  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 Qs(a), c = Js(o).map((e) => {
11110
11129
  let t = Qi(e.section);
11111
11130
  return {
@@ -11116,7 +11135,7 @@ async function Z_(e) {
11116
11135
  let t = ua(e.key, i, r);
11117
11136
  return {
11118
11137
  key: e.key,
11119
- state: Q_(Ys(s, e.key), e.value),
11138
+ state: $_(Ys(s, e.key), e.value),
11120
11139
  setup: t?.setup ?? null,
11121
11140
  ...t?.group ? { group: t.group } : {}
11122
11141
  };
@@ -11130,20 +11149,20 @@ async function Z_(e) {
11130
11149
  sections: c
11131
11150
  };
11132
11151
  }
11133
- function Q_(e, t) {
11152
+ function $_(e, t) {
11134
11153
  return e === "" ? "missing" : e === t.trim() ? "default" : "filled";
11135
11154
  }
11136
11155
  //#endregion
11137
11156
  //#region src/mcp/tools/env-status.ts
11138
- var $_ = { cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
11139
- async function ev(e) {
11140
- let t = F_(e.cwd), n = await J(t).catch(() => null);
11157
+ var ev = { cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
11158
+ async function tv(e) {
11159
+ let t = I_(e.cwd), n = await J(t).catch(() => null);
11141
11160
  if (!n) throw new ct({
11142
11161
  reason: "not_a_project",
11143
11162
  message: `${t} has no stack.json, so there is nothing to check.`,
11144
11163
  details: { cwd: t }
11145
11164
  });
11146
- let r = await X_(t, n);
11165
+ let r = await Z_(t, n);
11147
11166
  return {
11148
11167
  cwd: t,
11149
11168
  missingCount: r.missingCount,
@@ -11153,9 +11172,9 @@ async function ev(e) {
11153
11172
  }
11154
11173
  //#endregion
11155
11174
  //#region src/mcp/tools/inspect-stack.ts
11156
- var tv = { cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
11157
- async function nv(e) {
11158
- let t = F_(e.cwd), n = await J(t).catch(() => null);
11175
+ var nv = { cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
11176
+ async function rv(e) {
11177
+ let t = I_(e.cwd), n = await J(t).catch(() => null);
11159
11178
  if (!n) throw new ct({
11160
11179
  reason: "not_a_project",
11161
11180
  message: await va(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.`,
@@ -11183,12 +11202,12 @@ async function nv(e) {
11183
11202
  }
11184
11203
  //#endregion
11185
11204
  //#region src/mcp/tools/plan-install.ts
11186
- var rv = {
11205
+ var iv = {
11187
11206
  packs: j.array(j.string()).min(1).describe("Pack names to plan an install for"),
11188
11207
  cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in.")
11189
11208
  };
11190
- async function iv(e) {
11191
- let t = F_(e.cwd), { token: n, source: r } = await P_(), i = await J(t).catch(() => null), a = i?.installedPacks ?? [], o = await wa(), s = new Map(o.map((e) => [e.name, e])), c = e.packs.filter((e) => !s.has(e));
11209
+ async function av(e) {
11210
+ let t = I_(e.cwd), { token: n, source: r } = await F_(), i = await J(t).catch(() => null), a = i?.installedPacks ?? [], o = await wa(), s = new Map(o.map((e) => [e.name, e])), c = e.packs.filter((e) => !s.has(e));
11192
11211
  if (c.length > 0) throw Error(`Unknown pack${c.length === 1 ? "" : "s"}: ${c.join(", ")}`);
11193
11212
  let l = Xl(o), u = Ql(e.packs, l, a), d = await Jd(u.order.map((e) => s.get(e)).filter((e) => e !== void 0), new Set(a), { token: n }), f = (e) => {
11194
11213
  let t = s.get(e);
@@ -11217,12 +11236,12 @@ async function iv(e) {
11217
11236
  purchaseUrl: n ? jt(e) : null
11218
11237
  };
11219
11238
  }),
11220
- ...n === null ? { authHint: I_ } : {}
11239
+ ...n === null ? { authHint: L_ } : {}
11221
11240
  };
11222
11241
  }
11223
11242
  //#endregion
11224
11243
  //#region src/mcp/tools/search-catalog.ts
11225
- var av = {
11244
+ var ov = {
11226
11245
  query: j.string().optional().describe("Free text matched against name, display name, and description"),
11227
11246
  kind: j.enum([
11228
11247
  "pack",
@@ -11235,31 +11254,31 @@ var av = {
11235
11254
  "paid",
11236
11255
  "all"
11237
11256
  ]).default("all").describe("Restrict packs by price tier")
11238
- }, ov = (e, t) => {
11257
+ }, sv = (e, t) => {
11239
11258
  let n = t.trim().toLowerCase();
11240
11259
  return n === "" ? !0 : e.some((e) => e.toLowerCase().includes(n));
11241
11260
  };
11242
- function sv(e, t) {
11261
+ function cv(e, t) {
11243
11262
  let { query: n = "", category: r, tier: i = "all" } = t;
11244
- return e.filter((e) => r && e.category !== r || i !== "all" && e.tier !== i ? !1 : ov([
11263
+ return e.filter((e) => r && e.category !== r || i !== "all" && e.tier !== i ? !1 : sv([
11245
11264
  e.name,
11246
11265
  e.displayName,
11247
11266
  e.description
11248
11267
  ], n));
11249
11268
  }
11250
- function cv(e, t) {
11269
+ function lv(e, t) {
11251
11270
  let { query: n = "", category: r } = t;
11252
- return e.filter((e) => r && e.category !== r ? !1 : ov([
11271
+ return e.filter((e) => r && e.category !== r ? !1 : sv([
11253
11272
  e.id,
11254
11273
  e.name,
11255
11274
  e.description,
11256
11275
  ...e.tags
11257
11276
  ], n));
11258
11277
  }
11259
- async function lv(e) {
11260
- let t = e.kind ?? "all", [n, r] = await Promise.all([t === "template" ? Promise.resolve([]) : wa(), t === "pack" ? Promise.resolve([]) : C_()]);
11278
+ async function uv(e) {
11279
+ let t = e.kind ?? "all", [n, r] = await Promise.all([t === "template" ? Promise.resolve([]) : wa(), t === "pack" ? Promise.resolve([]) : w_()]);
11261
11280
  return {
11262
- packs: sv(n, e).map((e) => ({
11281
+ packs: cv(n, e).map((e) => ({
11263
11282
  name: e.name,
11264
11283
  displayName: e.displayName,
11265
11284
  description: e.description,
@@ -11268,7 +11287,7 @@ async function lv(e) {
11268
11287
  price: e.price,
11269
11288
  dependencies: e.dependencies
11270
11289
  })),
11271
- templates: cv(r, e).map((e) => ({
11290
+ templates: lv(r, e).map((e) => ({
11272
11291
  id: e.id,
11273
11292
  name: e.name,
11274
11293
  description: e.description,
@@ -11285,117 +11304,117 @@ async function lv(e) {
11285
11304
  }
11286
11305
  //#endregion
11287
11306
  //#region src/mcp/server.ts
11288
- var uv = "hype-stack";
11289
- function dv() {
11307
+ var dv = "hype-stack";
11308
+ function fv() {
11290
11309
  let e = new ue({
11291
- name: uv,
11310
+ name: dv,
11292
11311
  version: pe
11293
11312
  }, {
11294
11313
  capabilities: { tools: {} },
11295
- instructions: fv
11314
+ instructions: pv
11296
11315
  });
11297
11316
  return e.registerTool("search_catalog", {
11298
11317
  title: "Search the Hype Stack catalog",
11299
11318
  description: "Find feature packs and project templates by keyword, category, or price tier. Read-only. Start here when the user asks what is available.",
11300
- inputSchema: av,
11319
+ inputSchema: ov,
11301
11320
  annotations: {
11302
11321
  readOnlyHint: !0,
11303
11322
  openWorldHint: !0
11304
11323
  }
11305
- }, (e) => M_(() => lv(e))), e.registerTool("plan_install", {
11324
+ }, (e) => N_(() => uv(e))), e.registerTool("plan_install", {
11306
11325
  title: "Plan a pack install",
11307
11326
  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.",
11308
- inputSchema: rv,
11327
+ inputSchema: iv,
11309
11328
  annotations: {
11310
11329
  readOnlyHint: !0,
11311
11330
  openWorldHint: !0
11312
11331
  }
11313
- }, (e) => M_(() => iv(e))), e.registerTool("create_application", {
11332
+ }, (e) => N_(() => av(e))), e.registerTool("create_application", {
11314
11333
  title: "Create a Hype Stack application",
11315
11334
  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.",
11316
- inputSchema: G_,
11335
+ inputSchema: K_,
11317
11336
  annotations: {
11318
11337
  readOnlyHint: !1,
11319
11338
  destructiveHint: !1,
11320
11339
  openWorldHint: !0
11321
11340
  }
11322
- }, (e) => M_(() => K_(e))), e.registerTool("add_packs", {
11341
+ }, (e) => N_(() => q_(e))), e.registerTool("add_packs", {
11323
11342
  title: "Add feature packs",
11324
11343
  description: "Install packs into an existing project. Requires an explicit onConflict policy because there is no prompt to fall back on.",
11325
- inputSchema: L_,
11344
+ inputSchema: R_,
11326
11345
  annotations: {
11327
11346
  readOnlyHint: !1,
11328
11347
  destructiveHint: !0,
11329
11348
  openWorldHint: !0
11330
11349
  }
11331
- }, (e) => M_(() => R_(e))), e.registerTool("apply_template", {
11350
+ }, (e) => N_(() => z_(e))), e.registerTool("apply_template", {
11332
11351
  title: "Apply a project template",
11333
11352
  description: "Install a template: its starter, layout, fixed packs, and frontend overrides. Pass variants to swap a slot away from the template default.",
11334
- inputSchema: B_,
11353
+ inputSchema: V_,
11335
11354
  annotations: {
11336
11355
  readOnlyHint: !1,
11337
11356
  destructiveHint: !0,
11338
11357
  openWorldHint: !0
11339
11358
  }
11340
- }, (e) => M_(() => V_(e))), e.registerTool("inspect_stack", {
11359
+ }, (e) => N_(() => H_(e))), e.registerTool("inspect_stack", {
11341
11360
  title: "Inspect the project stack",
11342
11361
  description: "Read stack.json and the detected workspace layout: installed packs, app paths, and whether this is a Hype Stack project at all.",
11343
- inputSchema: tv,
11362
+ inputSchema: nv,
11344
11363
  annotations: {
11345
11364
  readOnlyHint: !0,
11346
11365
  openWorldHint: !1
11347
11366
  }
11348
- }, (e) => M_(() => nv(e))), e.registerTool("env_status", {
11367
+ }, (e) => N_(() => rv(e))), e.registerTool("env_status", {
11349
11368
  title: "Check environment variables",
11350
11369
  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`.",
11351
- inputSchema: $_,
11370
+ inputSchema: ev,
11352
11371
  annotations: {
11353
11372
  readOnlyHint: !0,
11354
11373
  openWorldHint: !1
11355
11374
  }
11356
- }, (e) => M_(() => ev(e))), e.registerTool("auth_status", {
11375
+ }, (e) => N_(() => tv(e))), e.registerTool("auth_status", {
11357
11376
  title: "Check Hype Stack authentication",
11358
11377
  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.",
11359
- inputSchema: U_,
11378
+ inputSchema: W_,
11360
11379
  annotations: {
11361
11380
  readOnlyHint: !0,
11362
11381
  openWorldHint: !0
11363
11382
  }
11364
- }, () => M_(() => W_())), e;
11383
+ }, () => N_(() => G_())), e;
11365
11384
  }
11366
- var fv = "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\".";
11367
- async function pv() {
11385
+ var pv = "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\".";
11386
+ async function mv() {
11368
11387
  tt("mcp");
11369
- let e = j_();
11370
- await dv().connect(new de(process.stdin, e));
11388
+ let e = M_();
11389
+ await fv().connect(new de(process.stdin, e));
11371
11390
  }
11372
11391
  //#endregion
11373
11392
  //#region src/cli.ts
11374
- function mv(e) {
11393
+ function hv(e) {
11375
11394
  if (!e) return;
11376
11395
  let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
11377
11396
  return t.length > 0 ? t : void 0;
11378
11397
  }
11379
- function hv(e, t) {
11398
+ function gv(e, t) {
11380
11399
  let n = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
11381
11400
  return [...t ?? [], ...n];
11382
11401
  }
11383
- function gv(e) {
11402
+ function _v(e) {
11384
11403
  return e === "light" || e === "dark" ? e : void 0;
11385
11404
  }
11386
- function _v(e) {
11405
+ function vv(e) {
11387
11406
  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)");
11388
11407
  }
11389
- function vv(e) {
11408
+ function yv(e) {
11390
11409
  return {
11391
11410
  theme: e.theme,
11392
11411
  adminTheme: e.adminTheme,
11393
11412
  radius: e.radius,
11394
11413
  adminRadius: e.adminRadius,
11395
- mode: gv(e.mode)
11414
+ mode: _v(e.mode)
11396
11415
  };
11397
11416
  }
11398
- function yv(e) {
11417
+ function bv(e) {
11399
11418
  if (!e) return;
11400
11419
  let t = {};
11401
11420
  for (let n of e.split(",")) {
@@ -11404,12 +11423,12 @@ function yv(e) {
11404
11423
  }
11405
11424
  return Object.keys(t).length > 0 ? t : void 0;
11406
11425
  }
11407
- function bv(e) {
11426
+ function xv(e) {
11408
11427
  if (!e) return;
11409
11428
  let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
11410
11429
  return t.length > 0 ? t : void 0;
11411
11430
  }
11412
- function xv(e) {
11431
+ function Sv(e) {
11413
11432
  let t = {};
11414
11433
  for (let n of [...Ff, ...If]) {
11415
11434
  let r = e[n];
@@ -11417,10 +11436,10 @@ function xv(e) {
11417
11436
  }
11418
11437
  return t;
11419
11438
  }
11420
- function Sv() {
11439
+ function Cv() {
11421
11440
  let e = new s();
11422
- e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(pe, "-v, --version"), _v(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(", ")})`, hv)).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) => {
11423
- let t = vv(e);
11441
+ e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(pe, "-v, --version"), vv(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(", ")})`, gv)).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) => {
11442
+ let t = yv(e);
11424
11443
  await af({
11425
11444
  name: e.name,
11426
11445
  directory: e.directory,
@@ -11437,34 +11456,34 @@ function Sv() {
11437
11456
  }), e.command("init").description("Initialize stack.json in the current project").action(async () => {
11438
11457
  await of({});
11439
11458
  }), 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) => {
11440
- await f_({
11459
+ await p_({
11441
11460
  cwd: e.cwd,
11442
11461
  yes: e.yes
11443
11462
  });
11444
- }), _v(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) => {
11463
+ }), vv(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) => {
11445
11464
  await cf({
11446
- packs: mv(e.packs),
11465
+ packs: hv(e.packs),
11447
11466
  force: e.force,
11448
11467
  yes: e.yes,
11449
11468
  cwd: e.cwd,
11450
- ...vv(e)
11469
+ ...yv(e)
11451
11470
  });
11452
- }), _v(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) => {
11453
- await E_({
11471
+ }), vv(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) => {
11472
+ await D_({
11454
11473
  templateId: e,
11455
- variants: yv(t.variants),
11456
- packs: mv(t.packs),
11474
+ variants: bv(t.variants),
11475
+ packs: hv(t.packs),
11457
11476
  force: t.force,
11458
11477
  yes: t.yes,
11459
11478
  cwd: t.cwd,
11460
- ...vv(t)
11479
+ ...yv(t)
11461
11480
  });
11462
11481
  }), 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 (${Lf.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 (${Ff.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) => {
11463
- await Wg({
11482
+ await Gg({
11464
11483
  cwd: e.cwd,
11465
11484
  provider: e.provider,
11466
- assign: xv(e),
11467
- only: bv(e.only),
11485
+ assign: Sv(e),
11486
+ only: xv(e.only),
11468
11487
  environment: e.environment,
11469
11488
  flyOrg: e.flyOrg,
11470
11489
  railwayWorkspace: e.railwayWorkspace,
@@ -11476,9 +11495,9 @@ function Sv() {
11476
11495
  });
11477
11496
  let t = e.command("mcp").description("Run the Model Context Protocol server for AI editors");
11478
11497
  return t.action(async () => {
11479
- await pv();
11498
+ await mv();
11480
11499
  }), t.command("install").description("Register the MCP server in your editor's config").option("-e, --editor <editor>", `Editor (${pd.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) => {
11481
- await r_({
11500
+ await i_({
11482
11501
  editor: e.editor,
11483
11502
  scope: e.scope,
11484
11503
  cwd: e.cwd,
@@ -11486,12 +11505,12 @@ function Sv() {
11486
11505
  print: e.print
11487
11506
  });
11488
11507
  }), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
11489
- await t_();
11490
- }), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
11491
11508
  await n_();
11509
+ }), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
11510
+ await r_();
11492
11511
  }), e.command("auth").description("Alias for `login`").action(async () => {
11493
- await t_();
11512
+ await n_();
11494
11513
  }), e;
11495
11514
  }
11496
11515
  //#endregion
11497
- export { Wg as a, of as c, pe as d, t_ as i, af as l, j_ as n, cf as o, n_ as r, sf as s, Sv as t, tt as u };
11516
+ export { Gg as a, of as c, pe as d, n_ as i, af as l, M_ as n, cf as o, r_ as r, sf as s, Cv as t, tt as u };