@hype-stack/cli 1.5.1 → 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.1", me = "BetterTyped/hype-stack", he = "main", ge = `gh:${me}`, _e = "HYPE_STACK_TEMPLATE_REF", ve = "/cli/template-channel", ye = "stack.json", be = "/schema/stack.json", xe = "https://api.hype-stack.dev", Se = "HYPE_STACK_API_URL", Ce = "https://www.hype-stack.dev", we = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, Te = [
23
+ 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.1") return {
5757
+ if (ku === "1.5.3") return {
5758
5758
  ref: he,
5759
5759
  commit: null,
5760
5760
  source: "dev"
@@ -7411,7 +7411,7 @@ function rp(e) {
7411
7411
  if (typeof e != "object" || !e) return [];
7412
7412
  let t = e, n = t.slug ?? t.Slug;
7413
7413
  return typeof n == "string" ? [n] : [];
7414
- }) : typeof t == "object" && t ? Object.values(t).filter((e) => typeof e == "string") : [];
7414
+ }) : typeof t == "object" && t ? Object.keys(t) : [];
7415
7415
  }
7416
7416
  async function ip(e) {
7417
7417
  let t = await e.runner.run({
@@ -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,18 +9377,15 @@ 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
- stdout: JSON.stringify([{
9374
- slug: "personal",
9375
- name: "Personal"
9376
- }])
9388
+ stdout: JSON.stringify({ personal: "Personal" })
9377
9389
  },
9378
9390
  {
9379
9391
  match: "fly secrets list",
@@ -9385,21 +9397,21 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9385
9397
  },
9386
9398
  {
9387
9399
  match: "fly mpg create",
9388
- 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`
9389
9401
  },
9390
9402
  {
9391
9403
  match: "fly mpg status",
9392
9404
  stdout: JSON.stringify({
9393
9405
  data: {
9394
- id: tg,
9406
+ id: ng,
9395
9407
  status: "ready"
9396
9408
  },
9397
- credentials: { pgbouncer_uri: `postgres://hype:${$h}@example.flympg.net:5432/postgres` }
9409
+ credentials: { pgbouncer_uri: `postgres://hype:${eg}@example.flympg.net:5432/postgres` }
9398
9410
  })
9399
9411
  },
9400
9412
  {
9401
9413
  match: "fly redis create",
9402
- 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`
9403
9415
  },
9404
9416
  {
9405
9417
  match: "fly redis status",
@@ -9408,10 +9420,10 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9408
9420
  {
9409
9421
  match: "fly storage create",
9410
9422
  stdout: (e) => [
9411
- `BUCKET_NAME: ${eg(e, "--name")}`,
9423
+ `BUCKET_NAME: ${tg(e, "--name")}`,
9412
9424
  "AWS_ENDPOINT_URL_S3: https://fly.storage.tigris.dev",
9413
- `AWS_ACCESS_KEY_ID: ${$h}`,
9414
- `AWS_SECRET_ACCESS_KEY: ${$h}`
9425
+ `AWS_ACCESS_KEY_ID: ${eg}`,
9426
+ `AWS_SECRET_ACCESS_KEY: ${eg}`
9415
9427
  ].join("\n")
9416
9428
  },
9417
9429
  {
@@ -9429,8 +9441,8 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9429
9441
  {
9430
9442
  match: "railway add",
9431
9443
  stdout: (e) => JSON.stringify({
9432
- id: ng,
9433
- name: eg(e, "--service")
9444
+ id: rg,
9445
+ name: tg(e, "--service")
9434
9446
  })
9435
9447
  },
9436
9448
  {
@@ -9445,18 +9457,18 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9445
9457
  },
9446
9458
  {
9447
9459
  match: "railway domain list",
9448
- 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` }] })
9449
9461
  },
9450
9462
  {
9451
9463
  match: "railway domain",
9452
- 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` })
9453
9465
  },
9454
9466
  {
9455
9467
  match: "railway variable list",
9456
9468
  stdout: [
9457
- `DATABASE_PUBLIC_URL=postgres://postgres:${$h}@example.proxy.rlwy.net:5432/railway`,
9458
- `VALKEY_PUBLIC_URL=redis://default:${$h}@example.proxy.rlwy.net:6379`,
9459
- `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}`
9460
9472
  ].join("\n")
9461
9473
  },
9462
9474
  {
@@ -9468,7 +9480,7 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9468
9480
  stdout: (e) => JSON.stringify({
9469
9481
  id: "dryrun00bucket",
9470
9482
  name: e.args[2] ?? "bucket",
9471
- region: eg(e, "--region"),
9483
+ region: tg(e, "--region"),
9472
9484
  staged: !1,
9473
9485
  committed: !0
9474
9486
  })
@@ -9477,9 +9489,9 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9477
9489
  match: "railway bucket credentials",
9478
9490
  stdout: JSON.stringify({
9479
9491
  endpoint: "https://storage.railway.app",
9480
- accessKeyId: $h,
9481
- secretAccessKey: $h,
9482
- bucketName: `dry-run-bucket-${$h}`,
9492
+ accessKeyId: eg,
9493
+ secretAccessKey: eg,
9494
+ bucketName: `dry-run-bucket-${eg}`,
9483
9495
  region: "auto",
9484
9496
  urlStyle: "virtual"
9485
9497
  })
@@ -9488,7 +9500,7 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9488
9500
  match: "railway api",
9489
9501
  stdout: JSON.stringify({ data: { serviceInstanceUpdate: !0 } })
9490
9502
  }
9491
- ], ig = {
9503
+ ], ag = {
9492
9504
  backend: [
9493
9505
  "NODE_ENV",
9494
9506
  "APP_ENV",
@@ -9514,30 +9526,30 @@ var tg = "dryrun00cluster", ng = "dryrun00service", rg = [
9514
9526
  "VITE_APP_TYPE",
9515
9527
  "VITE_ENVIRONMENT"
9516
9528
  ]
9517
- }, ag = new Set([
9529
+ }, og = new Set([
9518
9530
  "VITE_SENTRY_AUTH_TOKEN",
9519
9531
  "POSTGRES_USER",
9520
9532
  "POSTGRES_PASSWORD",
9521
9533
  "POSTGRES_DB",
9522
9534
  "POSTGRES_HOST",
9523
9535
  "POSTGRES_PORT"
9524
- ]), og = /(?:^|\/\/|@)(?:localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.internal)(?::\d+)?(?:\/|$)/i;
9525
- function sg(e) {
9536
+ ]), sg = /(?:^|\/\/|@)(?:localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.internal)(?::\d+)?(?:\/|$)/i;
9537
+ function cg(e) {
9526
9538
  let { plan: t, serviceOutputs: n, urls: r, localEnv: i = {}, declaredKeys: a = {}, exampleEnv: o = {}, externallyProvided: s = {} } = e;
9527
9539
  return t.targets.map((e) => {
9528
- let c = cg(e, t, r), l = hg({
9540
+ let c = lg(e, t, r), l = gg({
9529
9541
  target: e.target,
9530
9542
  environment: t.environment,
9531
9543
  port: e.spec.port,
9532
9544
  serviceOutputs: n,
9533
9545
  urls: c
9534
- }), 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({
9535
9547
  declared: u,
9536
9548
  local: d,
9537
9549
  managed: l,
9538
9550
  origin: f,
9539
9551
  target: e.target
9540
- }), 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({
9541
9553
  keys: _,
9542
9554
  example: o[e.target] ?? {},
9543
9555
  origin: f
@@ -9549,26 +9561,26 @@ function sg(e) {
9549
9561
  seeded: v,
9550
9562
  rehosted: [...m, ...y],
9551
9563
  missing: b,
9552
- blank: ug(b, o[e.target] ?? {}),
9564
+ blank: dg(b, o[e.target] ?? {}),
9553
9565
  skippedLocal: h
9554
9566
  };
9555
9567
  });
9556
9568
  }
9557
- function cg(e, t, n) {
9569
+ function lg(e, t, n) {
9558
9570
  let r = e.provider === "railway" && e.target === "backend", i = {};
9559
- 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];
9560
9572
  return i;
9561
9573
  }
9562
- function lg(e) {
9574
+ function ug(e) {
9563
9575
  let t = {}, n = [];
9564
9576
  for (let r of e.keys) {
9565
9577
  let i = e.example[r];
9566
9578
  if (i === void 0 || i.trim() === "" || i.includes("${")) continue;
9567
- if (!og.test(i)) {
9579
+ if (!sg.test(i)) {
9568
9580
  t[r] = i;
9569
9581
  continue;
9570
9582
  }
9571
- let a = dg(i, e.origin);
9583
+ let a = fg(i, e.origin);
9572
9584
  a && (t[r] = a, n.push(r));
9573
9585
  }
9574
9586
  return {
@@ -9576,13 +9588,13 @@ function lg(e) {
9576
9588
  seededRehosted: n
9577
9589
  };
9578
9590
  }
9579
- function ug(e, t) {
9591
+ function dg(e, t) {
9580
9592
  return e.filter((e) => {
9581
9593
  let n = t[e];
9582
9594
  return n !== void 0 && n.trim() === "";
9583
9595
  });
9584
9596
  }
9585
- function dg(e, t) {
9597
+ function fg(e, t) {
9586
9598
  if (!t) return null;
9587
9599
  let n;
9588
9600
  try {
@@ -9592,13 +9604,13 @@ function dg(e, t) {
9592
9604
  }
9593
9605
  return /^https?:$/.test(n.protocol) ? `${t.replace(/\/+$/, "")}${n.pathname === "/" && !e.trimEnd().endsWith("/") ? "" : n.pathname}${n.search}${n.hash}` : null;
9594
9606
  }
9595
- var fg = "(pending)", pg = "https://pending.invalid";
9596
- function mg(e) {
9607
+ var pg = "(pending)", mg = "https://pending.invalid";
9608
+ function hg(e) {
9597
9609
  let { plan: t, localEnv: n, declaredKeys: r, exampleEnv: i } = e, a = {};
9598
- 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;
9599
9611
  let o = {};
9600
- for (let e of t.services) o[e.service] = e.external ?? Object.fromEntries(e.spec.provides.map((e) => [e, fg]));
9601
- 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({
9602
9614
  plan: t,
9603
9615
  serviceOutputs: o,
9604
9616
  urls: a,
@@ -9607,14 +9619,14 @@ function mg(e) {
9607
9619
  exampleEnv: i
9608
9620
  });
9609
9621
  }
9610
- function hg(e) {
9622
+ function gg(e) {
9611
9623
  let { target: t, environment: n, port: r, serviceOutputs: i, urls: a } = e;
9612
- return t === "backend" ? gg({
9624
+ return t === "backend" ? _g({
9613
9625
  environment: n,
9614
9626
  port: r,
9615
9627
  serviceOutputs: i,
9616
9628
  urls: a
9617
- }) : yg(t === "frontend" ? {
9629
+ }) : bg(t === "frontend" ? {
9618
9630
  VITE_API_BASE_URL: a.backend,
9619
9631
  VITE_ADMIN_URL: a.admin,
9620
9632
  VITE_ENVIRONMENT: n
@@ -9624,9 +9636,9 @@ function hg(e) {
9624
9636
  VITE_ENVIRONMENT: n
9625
9637
  });
9626
9638
  }
9627
- function gg(e) {
9639
+ function _g(e) {
9628
9640
  let { environment: t, port: n, serviceOutputs: r, urls: i } = e;
9629
- return yg({
9641
+ return bg({
9630
9642
  NODE_ENV: "production",
9631
9643
  APP_ENV: t,
9632
9644
  PORT: n === void 0 ? void 0 : String(n),
@@ -9638,14 +9650,14 @@ function gg(e) {
9638
9650
  SERVER_URL: i.backend
9639
9651
  });
9640
9652
  }
9641
- function _g(e) {
9642
- 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 = [];
9643
9655
  for (let e of t) {
9644
- 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;
9645
9657
  let t = n[e];
9646
9658
  if (!(t === void 0 || t.trim() === "") && !t.includes("${")) {
9647
- if (og.test(t)) {
9648
- let n = dg(t, i);
9659
+ if (sg.test(t)) {
9660
+ let n = fg(t, i);
9649
9661
  if (!n) {
9650
9662
  l.push(e);
9651
9663
  continue;
@@ -9662,7 +9674,7 @@ function _g(e) {
9662
9674
  skippedLocal: l
9663
9675
  };
9664
9676
  }
9665
- function vg(e) {
9677
+ function yg(e) {
9666
9678
  return {
9667
9679
  ...Object.fromEntries(e.blank.map((e) => [e, " "])),
9668
9680
  ...e.seeded,
@@ -9670,12 +9682,12 @@ function vg(e) {
9670
9682
  ...e.managed
9671
9683
  };
9672
9684
  }
9673
- function yg(e) {
9685
+ function bg(e) {
9674
9686
  let t = {};
9675
9687
  for (let [n, r] of Object.entries(e)) r !== void 0 && r !== "" && (t[n] = r);
9676
9688
  return t;
9677
9689
  }
9678
- function bg(e) {
9690
+ function xg(e) {
9679
9691
  let t = {};
9680
9692
  for (let n of e.split(/\r?\n/)) {
9681
9693
  let e = n.trim();
@@ -9683,27 +9695,27 @@ function bg(e) {
9683
9695
  let r = e.startsWith("export ") ? e.slice(7).trim() : e, i = r.indexOf("=");
9684
9696
  if (i <= 0) continue;
9685
9697
  let a = r.slice(0, i).trim();
9686
- /^[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()));
9687
9699
  }
9688
9700
  return t;
9689
9701
  }
9690
- function xg(e) {
9702
+ function Sg(e) {
9691
9703
  if (e.length >= 2 && (e.startsWith("\"") && e.endsWith("\"") || e.startsWith("'") && e.endsWith("'"))) return e.slice(1, -1);
9692
9704
  let t = e.indexOf(" #");
9693
9705
  return t === -1 ? e : e.slice(0, t).trim();
9694
9706
  }
9695
- function Sg(e) {
9696
- return [...new Set(Object.keys(bg(e)))];
9707
+ function Cg(e) {
9708
+ return [...new Set(Object.keys(xg(e)))];
9697
9709
  }
9698
9710
  //#endregion
9699
9711
  //#region src/deploy/migrations.ts
9700
- var Cg = [
9712
+ var wg = [
9701
9713
  "migration:latest",
9702
9714
  "migrate:deploy",
9703
9715
  "db:migrate:deploy"
9704
9716
  ];
9705
- async function wg(e, t) {
9706
- 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");
9707
9719
  if (r && n?.name) return [
9708
9720
  "pnpm",
9709
9721
  "--filter",
@@ -9716,7 +9728,7 @@ async function wg(e, t) {
9716
9728
  "run",
9717
9729
  r
9718
9730
  ];
9719
- let i = await Tg(e);
9731
+ let i = await Eg(e);
9720
9732
  return [
9721
9733
  "npx",
9722
9734
  "prisma",
@@ -9726,7 +9738,7 @@ async function wg(e, t) {
9726
9738
  T.relative(t, i).split(T.sep).join("/")
9727
9739
  ];
9728
9740
  }
9729
- async function Tg(e) {
9741
+ async function Eg(e) {
9730
9742
  let t = T.join(e, "prisma"), n = T.join(t, "schema");
9731
9743
  if (await G(n)) return n;
9732
9744
  let r = T.join(t, "schema.prisma");
@@ -9734,16 +9746,16 @@ async function Tg(e) {
9734
9746
  }
9735
9747
  //#endregion
9736
9748
  //#region src/deploy/orchestrate.ts
9737
- async function Eg(e) {
9749
+ async function Dg(e) {
9738
9750
  let { plan: t, runner: n, log: r } = e, i = [], a = {}, o = { ...e.knownServiceOutputs }, s = {}, c = [], l = {
9739
9751
  runner: n,
9740
9752
  plan: t,
9741
9753
  cwd: t.projectRoot,
9742
9754
  log: r
9743
- }, 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({
9744
9756
  ...e,
9745
9757
  status: "failed",
9746
- detail: Mg(n)
9758
+ detail: Ng(n)
9747
9759
  }), {
9748
9760
  plan: t,
9749
9761
  steps: i,
@@ -9752,7 +9764,7 @@ async function Eg(e) {
9752
9764
  envPlans: c,
9753
9765
  ok: !1
9754
9766
  });
9755
- if (!e.skipAuthCheck) for (let n of kg(t)) {
9767
+ if (!e.skipAuthCheck) for (let n of Ag(t)) {
9756
9768
  let t = {
9757
9769
  id: `auth:${n}`,
9758
9770
  label: `Check ${n} login`
@@ -9773,6 +9785,39 @@ async function Eg(e) {
9773
9785
  detail: a.account
9774
9786
  });
9775
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
+ }
9776
9821
  for (let e of t.targets) {
9777
9822
  let t = {
9778
9823
  id: `reserve:${e.target}`,
@@ -9790,38 +9835,9 @@ async function Eg(e) {
9790
9835
  return d(t, e);
9791
9836
  }
9792
9837
  }
9793
- let f = t.targets.find((e) => e.target === "backend");
9794
- for (let n of t.services) {
9795
- let t = {
9796
- id: `provision:${n.service}`,
9797
- label: `Provision ${Q(n.service)}`
9798
- };
9799
- if (e.skipProvision) {
9800
- i.push({
9801
- ...t,
9802
- status: "skipped",
9803
- detail: "--skip-provision"
9804
- });
9805
- continue;
9806
- }
9807
- try {
9808
- r?.(`Provisioning ${Q(n.service)} on ${n.provider}`);
9809
- let e = await u(n.provider).provisionService(l, {
9810
- service: n,
9811
- backend: f,
9812
- crossProvider: f !== void 0 && f.provider !== n.provider
9813
- });
9814
- o[n.service] = {
9815
- ...o[n.service],
9816
- ...e.outputs
9817
- }, e.providedByProvider && f && (s[f.target] = [...s[f.target] ?? [], ...e.providedByProvider]), i.push({
9818
- ...t,
9819
- status: "ok",
9820
- detail: e.note ?? jg(e.outputs)
9821
- });
9822
- } catch (e) {
9823
- return d(t, e);
9824
- }
9838
+ for (let e of t.services.filter((e) => !m(e))) {
9839
+ let t = await p(e);
9840
+ if (t) return t;
9825
9841
  }
9826
9842
  for (let e of t.targets) {
9827
9843
  let t = u(e.provider);
@@ -9829,7 +9845,7 @@ async function Eg(e) {
9829
9845
  let n = await t.existingEnvKeys(l, e).catch(() => []);
9830
9846
  n.length > 0 && (s[e.target] = [...s[e.target] ?? [], ...n]);
9831
9847
  }
9832
- c = sg({
9848
+ c = cg({
9833
9849
  plan: t,
9834
9850
  serviceOutputs: o,
9835
9851
  urls: a,
@@ -9838,9 +9854,9 @@ async function Eg(e) {
9838
9854
  exampleEnv: e.exampleEnv,
9839
9855
  externallyProvided: s
9840
9856
  });
9841
- 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();
9842
9858
  for (let e of t.targets) {
9843
- 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 = {
9844
9860
  id: `env:${e.target}`,
9845
9861
  label: `Configure ${e.spec.label} env`
9846
9862
  };
@@ -9859,11 +9875,11 @@ async function Eg(e) {
9859
9875
  i.push({
9860
9876
  ...d,
9861
9877
  status: "failed",
9862
- detail: Mg(t)
9863
- }), g.add(e.target);
9878
+ detail: Ng(t)
9879
+ }), v.add(e.target);
9864
9880
  continue;
9865
9881
  }
9866
- let _ = {
9882
+ let p = {
9867
9883
  id: `deploy:${e.target}`,
9868
9884
  label: `Deploy ${e.spec.label}`
9869
9885
  };
@@ -9873,23 +9889,23 @@ async function Eg(e) {
9873
9889
  target: e,
9874
9890
  env: n,
9875
9891
  secrets: s,
9876
- releaseCommand: e === f ? m : void 0
9892
+ releaseCommand: e === f ? g : void 0
9877
9893
  });
9878
- t.url && (a[e.target] = t.url), t.releaseRan && (h = !0), i.push({
9879
- ..._,
9894
+ t.url && (a[e.target] = t.url), t.releaseRan && (_ = !0), i.push({
9895
+ ...p,
9880
9896
  status: "ok",
9881
9897
  detail: t.url ?? t.note
9882
9898
  });
9883
9899
  } catch (t) {
9884
9900
  i.push({
9885
- ..._,
9901
+ ...p,
9886
9902
  status: "failed",
9887
- detail: Mg(t)
9888
- }), g.add(e.target);
9903
+ detail: Ng(t)
9904
+ }), v.add(e.target);
9889
9905
  }
9890
9906
  }
9891
9907
  for (let e of t.targets) {
9892
- if (g.has(e.target)) continue;
9908
+ if (v.has(e.target)) continue;
9893
9909
  let t = u(e.provider);
9894
9910
  if (!t.awaitTarget) continue;
9895
9911
  let n = {
@@ -9903,13 +9919,13 @@ async function Eg(e) {
9903
9919
  ...n,
9904
9920
  status: a.ok ? "ok" : "failed",
9905
9921
  detail: a.detail
9906
- }), a.ok || g.add(e.target);
9922
+ }), a.ok || v.add(e.target);
9907
9923
  } catch (t) {
9908
9924
  i.push({
9909
9925
  ...n,
9910
9926
  status: "failed",
9911
- detail: Mg(t)
9912
- }), g.add(e.target);
9927
+ detail: Ng(t)
9928
+ }), v.add(e.target);
9913
9929
  }
9914
9930
  }
9915
9931
  if (f) {
@@ -9917,27 +9933,27 @@ async function Eg(e) {
9917
9933
  id: "migrate",
9918
9934
  label: "Apply database migrations"
9919
9935
  };
9920
- if (g.has(f.target)) i.push({
9936
+ if (v.has(f.target)) i.push({
9921
9937
  ...t,
9922
9938
  status: "skipped",
9923
9939
  detail: `not run because the ${f.spec.label} deploy failed`
9924
9940
  });
9925
- else if (e.skipMigrations || !m) i.push({
9941
+ else if (e.skipMigrations || !g) i.push({
9926
9942
  ...t,
9927
9943
  status: "skipped",
9928
9944
  detail: "--skip-migrations"
9929
9945
  });
9930
- else if (h) i.push({
9946
+ else if (_) i.push({
9931
9947
  ...t,
9932
9948
  status: "ok",
9933
- detail: `${m.join(" ")} (ran with the release)`
9949
+ detail: `${g.join(" ")} (ran with the release)`
9934
9950
  });
9935
9951
  else {
9936
- let e = await Dg({
9952
+ let e = await Og({
9937
9953
  ctx: l,
9938
9954
  adapter: u(f.provider),
9939
9955
  backend: f,
9940
- command: m
9956
+ command: g
9941
9957
  });
9942
9958
  i.push({
9943
9959
  ...t,
@@ -9954,7 +9970,7 @@ async function Eg(e) {
9954
9970
  ok: i.every((e) => e.status !== "failed")
9955
9971
  };
9956
9972
  }
9957
- async function Dg(e) {
9973
+ async function Og(e) {
9958
9974
  let { ctx: t, adapter: n, backend: r, command: i } = e;
9959
9975
  if (!n.runRemote) return {
9960
9976
  status: "skipped",
@@ -9966,37 +9982,37 @@ async function Dg(e) {
9966
9982
  status: "ok",
9967
9983
  detail: i.join(" ")
9968
9984
  };
9969
- let o = Og(a.output);
9985
+ let o = kg(a.output);
9970
9986
  return {
9971
9987
  status: "skipped",
9972
9988
  detail: `Could not run migrations remotely${o ? ` (${o})` : ""}. Run "${i.join(" ")}" against ${r.app}.`
9973
9989
  };
9974
9990
  }
9975
- function Og(e) {
9991
+ function kg(e) {
9976
9992
  let t = e.split(/\r?\n/).map((e) => e.trim()).find((e) => e.length > 0);
9977
9993
  if (t) return t.length > 160 ? `${t.slice(0, 157)}...` : t;
9978
9994
  }
9979
- function kg(e) {
9995
+ function Ag(e) {
9980
9996
  let t = /* @__PURE__ */ new Set();
9981
9997
  for (let n of e.targets) t.add(n.provider);
9982
9998
  for (let n of e.services) n.external || t.add(n.provider);
9983
9999
  return [...t];
9984
10000
  }
9985
- function Ag(e) {
10001
+ function jg(e) {
9986
10002
  return Object.entries(e).filter(([e, t]) => t.length >= 8 && !e.startsWith("VITE_") && !/^https?:\/\//.test(t)).map(([, e]) => e);
9987
10003
  }
9988
- function jg(e) {
10004
+ function Mg(e) {
9989
10005
  let t = Object.keys(e);
9990
10006
  return t.length === 0 ? void 0 : `set ${t.join(", ")}`;
9991
10007
  }
9992
- function Mg(e) {
10008
+ function Ng(e) {
9993
10009
  return e instanceof Error ? e.message : String(e);
9994
10010
  }
9995
10011
  //#endregion
9996
10012
  //#region src/deploy/plan.ts
9997
- function Ng(e) {
10013
+ function Pg(e) {
9998
10014
  let { projectRoot: t, config: n, assignment: r, stackConfig: i, serveModes: a = {}, staticDirs: o = {} } = e, s = [];
9999
- for (let [e, c] of Fg(r)) {
10015
+ for (let [e, c] of Ig(r)) {
10000
10016
  let r = n.targets[e], l = Rf[e];
10001
10017
  s.push({
10002
10018
  target: e,
@@ -10009,7 +10025,7 @@ function Ng(e) {
10009
10025
  app: r?.app ?? Kf(n.projectName, e, c),
10010
10026
  region: r?.region,
10011
10027
  url: r?.url,
10012
- root: Kh(t, e, i)
10028
+ root: qh(t, e, i)
10013
10029
  });
10014
10030
  }
10015
10031
  let c = [];
@@ -10036,20 +10052,20 @@ function Ng(e) {
10036
10052
  railway: n.railway ?? {}
10037
10053
  };
10038
10054
  }
10039
- var Pg = [
10055
+ var Fg = [
10040
10056
  "frontend",
10041
10057
  "admin",
10042
10058
  "backend"
10043
10059
  ];
10044
- function Fg(e) {
10060
+ function Ig(e) {
10045
10061
  let t = [];
10046
- for (let n of Pg) {
10062
+ for (let n of Fg) {
10047
10063
  let r = e.targets[n];
10048
10064
  r && t.push([n, r]);
10049
10065
  }
10050
10066
  return t;
10051
10067
  }
10052
- function Ig(e, t) {
10068
+ function Lg(e, t) {
10053
10069
  let n = {
10054
10070
  ...e,
10055
10071
  environment: t.environment,
@@ -10079,20 +10095,20 @@ function Ig(e, t) {
10079
10095
  }
10080
10096
  //#endregion
10081
10097
  //#region src/deploy/project-env.ts
10082
- async function Lg(e) {
10098
+ async function Rg(e) {
10083
10099
  return await K(e) ? C.readFile(e, "utf-8") : null;
10084
10100
  }
10085
- async function Rg(e, t) {
10086
- let n = bg(await Lg(T.join(e, ".env")) ?? ""), r = await Promise.all(t.map(async (e) => {
10087
- 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"))]);
10088
10104
  return {
10089
10105
  target: e.target,
10090
10106
  local: {
10091
10107
  ...n,
10092
- ...bg(t ?? "")
10108
+ ...xg(t ?? "")
10093
10109
  },
10094
- declared: Sg(r ?? ""),
10095
- example: bg(r ?? "")
10110
+ declared: Cg(r ?? ""),
10111
+ example: xg(r ?? "")
10096
10112
  };
10097
10113
  })), i = {}, a = {}, o = {};
10098
10114
  for (let e of r) i[e.target] = e.local, a[e.target] = e.declared, o[e.target] = e.example;
@@ -10104,7 +10120,7 @@ async function Rg(e, t) {
10104
10120
  }
10105
10121
  //#endregion
10106
10122
  //#region src/deploy/report.ts
10107
- function zg(e) {
10123
+ function Bg(e) {
10108
10124
  let t = [];
10109
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"));
10110
10126
  for (let n of e.targets) {
@@ -10120,7 +10136,7 @@ function zg(e) {
10120
10136
  }
10121
10137
  return t.join("\n");
10122
10138
  }
10123
- function Bg(e) {
10139
+ function Vg(e) {
10124
10140
  let t = [];
10125
10141
  for (let n of e) {
10126
10142
  let e = Object.keys(n.managed).length, r = Object.keys(n.forwarded).length;
@@ -10132,19 +10148,19 @@ function Bg(e) {
10132
10148
  }
10133
10149
  return t.join("\n");
10134
10150
  }
10135
- function Vg(e) {
10151
+ function Hg(e) {
10136
10152
  return e.steps.map((e) => {
10137
10153
  let t = e.status === "ok" ? P.success("✓") : e.status === "skipped" ? P.warning("-") : P.error("✗"), n = e.detail ? ` ${P.muted(e.detail)}` : "";
10138
10154
  return `${t} ${e.label}${n}`;
10139
10155
  }).join("\n");
10140
10156
  }
10141
- function Hg(e) {
10157
+ function Ug(e) {
10142
10158
  return e.plan.targets.map((t) => {
10143
10159
  let n = e.urls[t.target];
10144
10160
  return n ? `${P.label(t.spec.label)} ${F(n)}` : `${P.label(t.spec.label)} ${P.muted("no public URL")}`;
10145
10161
  }).join("\n");
10146
10162
  }
10147
- function Ug(e) {
10163
+ function Wg(e) {
10148
10164
  let t = [];
10149
10165
  for (let n of e.envPlans) {
10150
10166
  let e = n.missing.filter((e) => !n.blank.includes(e));
@@ -10157,27 +10173,27 @@ function Ug(e) {
10157
10173
  }
10158
10174
  //#endregion
10159
10175
  //#region src/commands/deploy.ts
10160
- async function Wg(e = {}) {
10176
+ async function Gg(e = {}) {
10161
10177
  let t = T.resolve(e.cwd ?? process.cwd()), n = e.yes === !0;
10162
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" });
10163
- let r = await J(t).catch(() => null), i = await Gg(t);
10164
- 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 = {
10165
10181
  ...i.fly,
10166
10182
  org: e.flyOrg
10167
10183
  }), e.railwayWorkspace && (i.railway = {
10168
10184
  ...i.railway,
10169
10185
  workspace: e.railwayWorkspace
10170
10186
  });
10171
- let a = await qh(t, r);
10187
+ let a = await Jh(t, r);
10172
10188
  a.length === 0 && R("Found no deployable apps. Expected at least one of apps/backend, apps/frontend, or apps/admin.");
10173
- 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({
10174
10190
  config: i,
10175
10191
  defaultProvider: l,
10176
10192
  overrides: s,
10177
10193
  availableTargets: a,
10178
10194
  only: o
10179
- }), d = await Xh(t, Jf(a, o), r);
10180
- n || (u = await Yg({
10195
+ }), d = await Zh(t, Jf(a, o), r);
10196
+ n || (u = await Xg({
10181
10197
  assignment: u,
10182
10198
  availableTargets: a,
10183
10199
  requestedTargets: o
@@ -10189,12 +10205,12 @@ async function Wg(e = {}) {
10189
10205
  serveModes: d
10190
10206
  });
10191
10207
  f.length > 0 && (L(Zf(f), "Cannot deploy yet"), R("Fix the assignments above and run deploy again.", { reason: "input_required" }));
10192
- let p = Zh(d), m = await $g({
10208
+ let p = Qh(d), m = await e_({
10193
10209
  cwd: t,
10194
10210
  targets: u.targets,
10195
10211
  serveModes: p,
10196
10212
  stackConfig: r
10197
- }), h = Ng({
10213
+ }), h = Pg({
10198
10214
  projectRoot: t,
10199
10215
  config: i,
10200
10216
  assignment: u,
@@ -10202,13 +10218,13 @@ async function Wg(e = {}) {
10202
10218
  serveModes: p,
10203
10219
  staticDirs: m
10204
10220
  });
10205
- L(zg(h), e.dryRun ? "Deployment plan (dry run)" : "Deployment plan");
10221
+ L(Bg(h), e.dryRun ? "Deployment plan (dry run)" : "Deployment plan");
10206
10222
  let g = e.dryRun ? {
10207
10223
  env: {},
10208
10224
  accounts: {}
10209
- } : await bh({
10225
+ } : await xh({
10210
10226
  plan: h,
10211
- providers: kg(h),
10227
+ providers: Ag(h),
10212
10228
  skipPrompts: n
10213
10229
  });
10214
10230
  if (!n && !e.dryRun) {
@@ -10217,27 +10233,27 @@ async function Wg(e = {}) {
10217
10233
  message: "Deploying creates billable infrastructure. Re-run with --yes to confirm non-interactively."
10218
10234
  });
10219
10235
  let e = await c.confirm({
10220
- 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))}?`,
10221
10237
  initialValue: !0
10222
10238
  });
10223
10239
  (c.isCancel(e) || !e) && z();
10224
10240
  }
10225
- let _ = await Rg(t, h.targets);
10226
- L(Bg(mg({
10241
+ let _ = await zg(t, h.targets);
10242
+ L(Vg(hg({
10227
10243
  plan: h,
10228
10244
  localEnv: _.local,
10229
10245
  declaredKeys: _.declared,
10230
10246
  exampleEnv: _.example
10231
10247
  })), "Environment"), await jf(t).catch(() => null);
10232
- let v = At(), y = [], b = e.dryRun ? jp({
10248
+ let v = At(), y = [], b = e.dryRun ? Mp({
10233
10249
  onCommand: (e) => y.push(e),
10234
- responses: rg
10235
- }) : Ap({
10250
+ responses: ig
10251
+ }) : jp({
10236
10252
  onCommand: (e) => y.push(e),
10237
10253
  env: g.env
10238
10254
  });
10239
10255
  v.start(e.dryRun ? "Walking the plan" : "Deploying");
10240
- let x = await Eg({
10256
+ let x = await Dg({
10241
10257
  plan: h,
10242
10258
  runner: b,
10243
10259
  localEnv: _.local,
@@ -10249,61 +10265,61 @@ async function Wg(e = {}) {
10249
10265
  knownAccounts: g.accounts,
10250
10266
  log: (e) => v.message(e)
10251
10267
  });
10252
- 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) {
10253
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."));
10254
10270
  return;
10255
10271
  }
10256
- if (await Hh(t, Ig(i, x.plan)), !x.ok) {
10272
+ if (await Uh(t, Lg(i, x.plan)), !x.ok) {
10257
10273
  let e = x.steps.filter((e) => e.status === "failed");
10258
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.");
10259
10275
  }
10260
- L(Hg(x), "Live");
10261
- let S = Ug(x);
10276
+ L(Ug(x), "Live");
10277
+ let S = Wg(x);
10262
10278
  S.length > 0 && L(S.map((e) => `${P.warning("!")} ${e}`).join("\n\n"), "Still to do"), c.outro(P.brand("Shipped."));
10263
10279
  }
10264
- async function Gg(e) {
10280
+ async function Kg(e) {
10265
10281
  try {
10266
- return await Vh(e);
10282
+ return await Hh(e);
10267
10283
  } catch (e) {
10268
10284
  R(e instanceof Error ? e.message : String(e));
10269
10285
  }
10270
10286
  }
10271
- function Kg(e, t) {
10287
+ function qg(e, t) {
10272
10288
  if (e) return Hf(e) || R(`Unknown provider "${e}" for ${t}. Pick one of ${Object.keys(Bf).join(", ")}.`), e;
10273
10289
  }
10274
- function qg(e) {
10290
+ function Jg(e) {
10275
10291
  let t = {};
10276
10292
  for (let [n, r] of Object.entries(e ?? {})) {
10277
- let e = Kg(r, `--${n}`);
10293
+ let e = qg(r, `--${n}`);
10278
10294
  e && (t[n] = e);
10279
10295
  }
10280
10296
  return t;
10281
10297
  }
10282
- function Jg(e) {
10298
+ function Yg(e) {
10283
10299
  let { assignment: t, availableTargets: n, requestedTargets: r } = e, i = Jf(n, r).filter((e) => !t.targets[e]);
10284
10300
  return {
10285
10301
  targets: i,
10286
10302
  services: t.targets.backend !== void 0 || i.includes("backend") ? If.filter((e) => !t.services[e]) : []
10287
10303
  };
10288
10304
  }
10289
- async function Yg(e) {
10305
+ async function Xg(e) {
10290
10306
  let t = {
10291
10307
  targets: { ...e.assignment.targets },
10292
10308
  services: { ...e.assignment.services }
10293
- }, { targets: n, services: r } = Jg(e);
10309
+ }, { targets: n, services: r } = Yg(e);
10294
10310
  if (n.length + r.length > 1) {
10295
- let e = await Xg();
10311
+ let e = await Zg();
10296
10312
  if (e) {
10297
10313
  for (let r of n) t.targets[r] = e;
10298
10314
  for (let n of r) t.services[n] = e;
10299
10315
  return t;
10300
10316
  }
10301
10317
  }
10302
- for (let e of n) t.targets[e] = await Qg(e, Wf(e));
10303
- 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));
10304
10320
  return t;
10305
10321
  }
10306
- async function Xg() {
10322
+ async function Zg() {
10307
10323
  let e = await c.select({
10308
10324
  message: `Where should ${P.highlight("your stack")} live?`,
10309
10325
  options: [...Lf.map((e) => ({
@@ -10311,16 +10327,16 @@ async function Xg() {
10311
10327
  label: Uf(e),
10312
10328
  hint: `everything on ${Bf[e].bin}`
10313
10329
  })), {
10314
- value: Zg,
10330
+ value: Qg,
10315
10331
  label: "Mix providers",
10316
10332
  hint: "choose for each app and service"
10317
10333
  }],
10318
10334
  initialValue: Lf[0]
10319
10335
  });
10320
- return c.isCancel(e) && z(), e === Zg ? void 0 : e;
10336
+ return c.isCancel(e) && z(), e === Qg ? void 0 : e;
10321
10337
  }
10322
- var Zg = "__mixed__";
10323
- async function Qg(e, t) {
10338
+ var Qg = "__mixed__";
10339
+ async function $g(e, t) {
10324
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];
10325
10341
  let n = await c.select({
10326
10342
  message: `Where should ${P.highlight(Q(e))} live?`,
@@ -10333,17 +10349,17 @@ async function Qg(e, t) {
10333
10349
  });
10334
10350
  return c.isCancel(n) && z(), n;
10335
10351
  }
10336
- async function $g(e) {
10337
- 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)]));
10338
10354
  return Object.fromEntries(o);
10339
10355
  }
10340
- function e_(e) {
10356
+ function t_(e) {
10341
10357
  let t = [...new Set(e)].map(Uf);
10342
10358
  return t.length <= 1 ? t[0] ?? "your provider" : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
10343
10359
  }
10344
10360
  //#endregion
10345
10361
  //#region src/commands/login.ts
10346
- async function t_() {
10362
+ async function n_() {
10347
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...");
10348
10364
  let e;
10349
10365
  try {
@@ -10357,7 +10373,7 @@ async function t_() {
10357
10373
  }
10358
10374
  //#endregion
10359
10375
  //#region src/commands/logout.ts
10360
- async function n_() {
10376
+ async function r_() {
10361
10377
  mu(), c.intro(P.brandBold("Log out of Hype Stack"));
10362
10378
  let e = M(), t = await Ze(e);
10363
10379
  if (!t) {
@@ -10368,8 +10384,8 @@ async function n_() {
10368
10384
  }
10369
10385
  //#endregion
10370
10386
  //#region src/commands/mcp.ts
10371
- async function r_(e = {}) {
10372
- 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);
10373
10389
  if (e.print) {
10374
10390
  process.stdout.write(Sd(t, i));
10375
10391
  return;
@@ -10383,19 +10399,19 @@ async function r_(e = {}) {
10383
10399
  });
10384
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."));
10385
10401
  }
10386
- function i_(e) {
10402
+ function a_(e) {
10387
10403
  return e?.trim() || void 0;
10388
10404
  }
10389
- function a_(e) {
10405
+ function o_(e) {
10390
10406
  return e ? (gd(e) || R(`Unknown editor "${e}". Expected one of: ${pd.join(", ")}.`), e) : "cursor";
10391
10407
  }
10392
- function o_(e, t, n) {
10408
+ function s_(e, t, n) {
10393
10409
  let r = e ?? n[0];
10394
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;
10395
10411
  }
10396
10412
  //#endregion
10397
10413
  //#region src/ui/env-prompt.ts
10398
- 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 {
10399
10415
  constructor(e) {
10400
10416
  super({
10401
10417
  input: e.input,
@@ -10410,9 +10426,9 @@ var s_ = S("✔", "√"), c_ = S("✘", "x"), l_ = "\x1B[7m \x1B[27m", u_ = clas
10410
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` : "";
10411
10427
  if (this.state === "submit") {
10412
10428
  let t = (this.value ?? "").trim(), n = t ? P.muted(Xs(t)) : a ? P.muted(`kept ${a}`) : P.muted("left empty");
10413
- return `${c}${A("green", s_)} ${P.bold(e)} ${n}`;
10429
+ return `${c}${A("green", c_)} ${P.bold(e)} ${n}`;
10414
10430
  }
10415
- 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)}`;
10416
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 = [];
10417
10433
  if (t) {
10418
10434
  let e = n ? ` ${F(n)}` : "";
@@ -10420,19 +10436,19 @@ var s_ = S("✔", "√"), c_ = S("✘", "x"), l_ = "\x1B[7m \x1B[27m", u_ = clas
10420
10436
  }
10421
10437
  if (i && i.length > 0) for (let e of i) g.push(`${f}${I.bullet} ${P.description(e)}`);
10422
10438
  r && g.push(`${f}${P.description(r)}`);
10423
- 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)}`;
10424
10440
  g.push(S), this.state === "error" && g.push(`${f}${A("yellow", this.error)}`);
10425
10441
  let C = s ? this.state === "error" ? A("yellow", u) : A("cyan", u) : "";
10426
10442
  return `${h}\n${g.join("\n")}\n${C}`;
10427
10443
  }
10428
10444
  };
10429
- async function d_(e) {
10430
- let t = await new u_(e).prompt();
10445
+ async function f_(e) {
10446
+ let t = await new d_(e).prompt();
10431
10447
  return g(t) || typeof t == "string" ? t : "";
10432
10448
  }
10433
10449
  //#endregion
10434
10450
  //#region src/commands/onboard.ts
10435
- async function f_(e = {}) {
10451
+ async function p_(e = {}) {
10436
10452
  let t = e.cwd ?? process.cwd();
10437
10453
  e.skipBanner || pu(), c.intro(P.brandBold("Onboard your stack"));
10438
10454
  let n;
@@ -10447,12 +10463,12 @@ async function f_(e = {}) {
10447
10463
  for (let e of r) await $s(e);
10448
10464
  let i = await tc(t, n);
10449
10465
  i.length > 0 && c.log.success(`Generated ${P.highlight(String(i.length))} secrets: ${i.map((e) => e.key).join(", ")}`);
10450
- 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 = [];
10451
- 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);
10452
10468
  let d = ra(n.installedPacks ?? []);
10453
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.`));
10454
10470
  }
10455
- async function p_(e, t, n) {
10471
+ async function m_(e, t, n) {
10456
10472
  let r = t.onboarding?.envVars ?? [], i = t.onboarding?.envSections ?? [], a = [];
10457
10473
  for (let e of n) {
10458
10474
  let t = T.join(T.dirname(e), ".env"), [n, o] = await Promise.all([C.readFile(e, "utf-8"), Qs(t)]);
@@ -10472,40 +10488,40 @@ async function p_(e, t, n) {
10472
10488
  }
10473
10489
  return a;
10474
10490
  }
10475
- async function m_(e) {
10476
- let t = [], n = __(e);
10491
+ async function h_(e) {
10492
+ let t = [], n = v_(e);
10477
10493
  if (n.size === 0) return t;
10478
10494
  let r = [...n.entries()].map(([e, t]) => `${P.bold(e)} ${P.muted(`(${t.length})`)}`).join(", ");
10479
10495
  c.log.step(`Keys needed for: ${r}`);
10480
10496
  for (let [e, r] of n) {
10481
10497
  let n = `${r.length} value${r.length === 1 ? "" : "s"}`;
10482
- 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)) {
10483
10499
  t.push(...r);
10484
10500
  continue;
10485
10501
  }
10486
- await y_(r);
10502
+ await b_(r);
10487
10503
  }
10488
10504
  return t;
10489
10505
  }
10490
- async function h_(e) {
10506
+ async function g_(e) {
10491
10507
  let t = [];
10492
- for (let [n, r] of __(e)) {
10508
+ for (let [n, r] of v_(e)) {
10493
10509
  let e = r.every((e) => e.isSet), i = `${r.length} value${r.length === 1 ? "" : "s"}`;
10494
- 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)`)}`)) {
10495
10511
  t.push(...r.filter((e) => !e.isSet));
10496
10512
  continue;
10497
10513
  }
10498
- await y_(r);
10514
+ await b_(r);
10499
10515
  }
10500
10516
  return t;
10501
10517
  }
10502
- async function g_(e) {
10503
- for (let [t, n] of __(e)) {
10518
+ async function __(e) {
10519
+ for (let [t, n] of v_(e)) {
10504
10520
  let e = `${n.length} value${n.length === 1 ? "" : "s"}`;
10505
- 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);
10506
10522
  }
10507
10523
  }
10508
- function __(e) {
10524
+ function v_(e) {
10509
10525
  let t = /* @__PURE__ */ new Map();
10510
10526
  for (let n of e) {
10511
10527
  let e = n.setup.group ?? n.section, r = t.get(e);
@@ -10513,20 +10529,20 @@ function __(e) {
10513
10529
  }
10514
10530
  return t;
10515
10531
  }
10516
- async function v_(e, t = !1) {
10532
+ async function y_(e, t = !1) {
10517
10533
  let n = await c.confirm({
10518
10534
  message: e,
10519
10535
  initialValue: t
10520
10536
  });
10521
10537
  return c.isCancel(n) && z(), n === !0;
10522
10538
  }
10523
- async function y_(e) {
10539
+ async function b_(e) {
10524
10540
  let t = Qi(e[0].section);
10525
10541
  t.link && c.log.info(P.muted(t.link));
10526
- 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}`);
10527
10543
  }
10528
- async function b_(e, t) {
10529
- let n = Qi(e.section), r = await d_({
10544
+ async function x_(e, t) {
10545
+ let n = Qi(e.section), r = await f_({
10530
10546
  key: e.key,
10531
10547
  section: e.section,
10532
10548
  linkUrl: n.link,
@@ -10539,7 +10555,7 @@ async function b_(e, t) {
10539
10555
  let i = (typeof r == "string" ? r : "").trim();
10540
10556
  i !== "" && await ec(e.envPath, e.key, i);
10541
10557
  }
10542
- function x_(e, t) {
10558
+ function S_(e, t) {
10543
10559
  if (e.length === 0) return;
10544
10560
  let n = /* @__PURE__ */ new Map();
10545
10561
  for (let t of e) {
@@ -10559,16 +10575,16 @@ function x_(e, t) {
10559
10575
  }
10560
10576
  //#endregion
10561
10577
  //#region src/core/templates.ts
10562
- var S_ = U.createRequest()({
10578
+ var C_ = U.createRequest()({
10563
10579
  endpoint: "/templates/list",
10564
10580
  method: "GET"
10565
10581
  });
10566
- async function C_() {
10567
- let { data: e, error: t } = await S_.send();
10582
+ async function w_() {
10583
+ let { data: e, error: t } = await C_.send();
10568
10584
  if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
10569
10585
  return e.templates;
10570
10586
  }
10571
- async function w_(e) {
10587
+ async function T_(e) {
10572
10588
  let { data: t, error: n, status: r } = await U.createRequest()({
10573
10589
  endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
10574
10590
  method: "GET"
@@ -10577,7 +10593,7 @@ async function w_(e) {
10577
10593
  if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
10578
10594
  return t;
10579
10595
  }
10580
- async function T_(e, t = {}) {
10596
+ async function E_(e, t = {}) {
10581
10597
  let n = U.createRequest()({
10582
10598
  endpoint: `/templates/${encodeURIComponent(e)}/download`,
10583
10599
  method: "POST"
@@ -10614,7 +10630,7 @@ async function T_(e, t = {}) {
10614
10630
  }
10615
10631
  //#endregion
10616
10632
  //#region src/commands/template.ts
10617
- async function E_(t = {}) {
10633
+ async function D_(t = {}) {
10618
10634
  let n = t.cwd ?? process.cwd();
10619
10635
  pu(), await Yl();
10620
10636
  let r = c.spinner();
@@ -10628,7 +10644,7 @@ async function E_(t = {}) {
10628
10644
  r.stop("Packs loaded"), r.start("Loading templates...");
10629
10645
  let a;
10630
10646
  try {
10631
- a = await C_();
10647
+ a = await w_();
10632
10648
  } catch (e) {
10633
10649
  r.stop("Failed to load templates"), R(`Could not reach Hype Stack. Check your connection and try again.\n${qd(e)}`);
10634
10650
  }
@@ -10651,7 +10667,7 @@ async function E_(t = {}) {
10651
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}`);
10652
10668
  let l;
10653
10669
  try {
10654
- l = await w_(s.id);
10670
+ l = await T_(s.id);
10655
10671
  } catch (e) {
10656
10672
  R(qd(e));
10657
10673
  }
@@ -10673,7 +10689,7 @@ async function E_(t = {}) {
10673
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.`);
10674
10690
  let m = d ?? n;
10675
10691
  c.intro(P.brandBold("Install a template"));
10676
- 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_({
10677
10693
  packs: i,
10678
10694
  templatePacks: S,
10679
10695
  installedSet: g,
@@ -10755,7 +10771,7 @@ async function E_(t = {}) {
10755
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));
10756
10772
  for (let e of n.errors) c.log.error(e);
10757
10773
  r.start("Applying template overrides...");
10758
- let i = await T_(s.id, { token: y });
10774
+ let i = await E_(s.id, { token: y });
10759
10775
  i.status === "denied" && (r.stop("Template download denied"), R(Qd(s.id, i.reason))), ce = i.templateDir;
10760
10776
  let a = await il({
10761
10777
  manifest: l,
@@ -10796,7 +10812,7 @@ async function E_(t = {}) {
10796
10812
  customization: n
10797
10813
  }), c.log.success(`Applied the ${Fc(n.theme)} theme, ${e(n.radius)} corners, and ${n.mode} mode`);
10798
10814
  }
10799
- await k_({
10815
+ await A_({
10800
10816
  prepared: se,
10801
10817
  templateNpm: l.dependencies_npm,
10802
10818
  paths: p.paths,
@@ -10826,7 +10842,7 @@ async function E_(t = {}) {
10826
10842
  });
10827
10843
  }
10828
10844
  }
10829
- async function D_(e, t, n) {
10845
+ async function O_(e, t, n) {
10830
10846
  let r = {};
10831
10847
  for (let i of e.slots) {
10832
10848
  if (t?.[i.family]) {
@@ -10850,7 +10866,7 @@ async function D_(e, t, n) {
10850
10866
  }
10851
10867
  return r;
10852
10868
  }
10853
- async function O_(e) {
10869
+ async function k_(e) {
10854
10870
  let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
10855
10871
  if (i.packs && i.packs.length > 0) {
10856
10872
  let e = i.packs.filter((e) => !t.some((t) => t.name === e));
@@ -10872,7 +10888,7 @@ async function O_(e) {
10872
10888
  });
10873
10889
  return _(c) && R("Cancelled.", { code: 0 }), c;
10874
10890
  }
10875
- async function k_(e) {
10891
+ async function A_(e) {
10876
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);
10877
10893
  if (s.errors.length > 0) {
10878
10894
  for (let e of s.errors) c.log.error(e);
@@ -10885,9 +10901,9 @@ async function k_(e) {
10885
10901
  }
10886
10902
  //#endregion
10887
10903
  //#region src/mcp/guard.ts
10888
- var A_ = null;
10889
- function j_() {
10890
- if (A_) return A_.protocolStream;
10904
+ var j_ = null;
10905
+ function M_() {
10906
+ if (j_) return j_.protocolStream;
10891
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({
10892
10908
  write(t, n, r) {
10893
10909
  e(t, (e) => r(e ?? null));
@@ -10896,7 +10912,7 @@ function j_() {
10896
10912
  e();
10897
10913
  }
10898
10914
  }), s = ((e, t, n) => typeof t == "function" ? process.stderr.write(e, t) : process.stderr.write(e, t, n));
10899
- 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_ = {
10900
10916
  protocolStream: o,
10901
10917
  restore: () => {
10902
10918
  process.stdout.write = t, console.log = n, console.info = r, console.debug = i, console.dir = a;
@@ -10905,22 +10921,22 @@ function j_() {
10905
10921
  }
10906
10922
  //#endregion
10907
10923
  //#region src/mcp/result.ts
10908
- async function M_(e) {
10924
+ async function N_(e) {
10909
10925
  ot();
10910
10926
  try {
10911
- return N_({
10927
+ return P_({
10912
10928
  ...await e(),
10913
10929
  ok: !0,
10914
10930
  logs: st()
10915
10931
  }, !1);
10916
10932
  } catch (e) {
10917
- return lt(e) ? N_({
10933
+ return lt(e) ? P_({
10918
10934
  ok: !1,
10919
10935
  reason: e.reason,
10920
10936
  message: e.message,
10921
10937
  details: e.details,
10922
10938
  logs: st()
10923
- }, !1) : N_({
10939
+ }, !1) : P_({
10924
10940
  ok: !1,
10925
10941
  reason: "failed",
10926
10942
  message: e instanceof Error ? e.message : String(e),
@@ -10929,7 +10945,7 @@ async function M_(e) {
10929
10945
  }, !0);
10930
10946
  }
10931
10947
  }
10932
- function N_(e, t) {
10948
+ function P_(e, t) {
10933
10949
  return {
10934
10950
  content: [{
10935
10951
  type: "text",
@@ -10941,7 +10957,7 @@ function N_(e, t) {
10941
10957
  }
10942
10958
  //#endregion
10943
10959
  //#region src/mcp/tools/context.ts
10944
- async function P_() {
10960
+ async function F_() {
10945
10961
  let e = await Ye(M());
10946
10962
  return e ? {
10947
10963
  token: e.token,
@@ -10951,26 +10967,26 @@ async function P_() {
10951
10967
  source: "none"
10952
10968
  };
10953
10969
  }
10954
- function F_(e) {
10970
+ function I_(e) {
10955
10971
  return T.resolve(e ?? process.cwd());
10956
10972
  }
10957
- var I_ = {
10973
+ var L_ = {
10958
10974
  envVar: Je,
10959
10975
  loginCommand: "npx @hype-stack/cli login"
10960
- }, L_ = {
10976
+ }, R_ = {
10961
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."),
10962
10978
  cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in."),
10963
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")
10964
10980
  };
10965
- async function R_(e) {
10966
- let t = F_(e.cwd), n = await z_(t);
10981
+ async function z_(e) {
10982
+ let t = I_(e.cwd), n = await B_(t);
10967
10983
  await cf({
10968
10984
  cwd: t,
10969
10985
  packs: e.packs,
10970
10986
  force: e.onConflict === "overwrite",
10971
10987
  yes: !0
10972
10988
  });
10973
- 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));
10974
10990
  return {
10975
10991
  cwd: t,
10976
10992
  installed: i,
@@ -10978,21 +10994,21 @@ async function R_(e) {
10978
10994
  followUp: i.length > 0 ? [...hl, "npx @hype-stack/cli onboard"] : []
10979
10995
  };
10980
10996
  }
10981
- async function z_(e) {
10997
+ async function B_(e) {
10982
10998
  return (await J(e).catch(() => null))?.installedPacks ?? [];
10983
10999
  }
10984
11000
  //#endregion
10985
11001
  //#region src/mcp/tools/apply-template.ts
10986
- var B_ = {
11002
+ var V_ = {
10987
11003
  templateId: j.string().min(1).describe("Template id, e.g. vault. Use search_catalog to find one."),
10988
11004
  cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in."),
10989
11005
  variants: j.record(j.string(), j.string()).optional().describe("Slot overrides keyed by family, e.g. { \"starter-saas\": \"starter-saas-better-auth\" }"),
10990
11006
  packs: j.array(j.string()).optional().describe("Extra packs to install on top of the template"),
10991
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")
10992
11008
  };
10993
- async function V_(e) {
10994
- let t = F_(e.cwd), n = await H_(t);
10995
- await E_({
11009
+ async function H_(e) {
11010
+ let t = I_(e.cwd), n = await U_(t);
11011
+ await D_({
10996
11012
  cwd: t,
10997
11013
  templateId: e.templateId,
10998
11014
  variants: e.variants,
@@ -11000,7 +11016,7 @@ async function V_(e) {
11000
11016
  force: e.onConflict === "overwrite",
11001
11017
  yes: !0
11002
11018
  });
11003
- let r = await H_(t);
11019
+ let r = await U_(t);
11004
11020
  return {
11005
11021
  cwd: t,
11006
11022
  templateId: e.templateId,
@@ -11009,21 +11025,21 @@ async function V_(e) {
11009
11025
  followUp: [...hl, "npx @hype-stack/cli onboard"]
11010
11026
  };
11011
11027
  }
11012
- async function H_(e) {
11028
+ async function U_(e) {
11013
11029
  return (await J(e).catch(() => null))?.installedPacks ?? [];
11014
11030
  }
11015
11031
  //#endregion
11016
11032
  //#region src/mcp/tools/auth-status.ts
11017
- var U_ = {};
11018
- async function W_() {
11019
- let { token: e, source: t } = await P_();
11033
+ var W_ = {};
11034
+ async function G_() {
11035
+ let { token: e, source: t } = await F_();
11020
11036
  if (!e) return {
11021
11037
  authenticated: !1,
11022
11038
  tokenSource: "none",
11023
11039
  apiUrl: M(),
11024
- 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.`,
11025
11041
  apiKeysUrl: `${Re()}/api-keys`,
11026
- ...I_
11042
+ ...L_
11027
11043
  };
11028
11044
  let n = await Yr(e);
11029
11045
  return n ? {
@@ -11036,14 +11052,14 @@ async function W_() {
11036
11052
  authenticated: !1,
11037
11053
  tokenSource: t,
11038
11054
  apiUrl: M(),
11039
- 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.`,
11040
11056
  apiKeysUrl: `${Re()}/api-keys`,
11041
- ...I_
11057
+ ...L_
11042
11058
  };
11043
11059
  }
11044
11060
  //#endregion
11045
11061
  //#region src/mcp/tools/create-application.ts
11046
- var G_ = {
11062
+ var K_ = {
11047
11063
  name: j.string().min(1).describe("Application name. Becomes the folder name and the package scope."),
11048
11064
  directory: j.string().optional().describe("Parent folder to create the app inside. Defaults to the current workspace."),
11049
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."),
@@ -11054,8 +11070,8 @@ var G_ = {
11054
11070
  adminRadius: j.string().optional().describe("Admin corner radius. Defaults to the frontend radius."),
11055
11071
  mode: j.enum(["light", "dark"]).optional().describe("Color mode the app boots in")
11056
11072
  };
11057
- async function K_(e) {
11058
- 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({
11059
11075
  name: e.name,
11060
11076
  parentDirectory: t,
11061
11077
  editors: n,
@@ -11071,19 +11087,19 @@ async function K_(e) {
11071
11087
  return {
11072
11088
  projectRoot: r,
11073
11089
  editors: n,
11074
- mcpConfigPaths: J_(n, r),
11090
+ mcpConfigPaths: Y_(n, r),
11075
11091
  followUp: [`cd ${r}`, ...hl]
11076
11092
  };
11077
11093
  }
11078
- function q_(e) {
11094
+ function J_(e) {
11079
11095
  let { editors: t, unknown: n } = Ae([...e.editors ?? [], ...e.editor ? [e.editor] : []]);
11080
11096
  if (n.length > 0) throw Error(`Unknown editor "${n.join(", ")}". Expected one of: ${Ee.join(", ")}.`);
11081
11097
  return t.length > 0 ? t : [De];
11082
11098
  }
11083
- function J_(e, t) {
11084
- return vd(e).map((e) => Y_(e, t)).filter((e) => e !== null);
11085
- }
11086
11099
  function Y_(e, t) {
11100
+ return vd(e).map((e) => X_(e, t)).filter((e) => e !== null);
11101
+ }
11102
+ function X_(e, t) {
11087
11103
  try {
11088
11104
  return bd({
11089
11105
  editor: e,
@@ -11096,8 +11112,8 @@ function Y_(e, t) {
11096
11112
  }
11097
11113
  //#endregion
11098
11114
  //#region src/core/env-status.ts
11099
- async function X_(e, t) {
11100
- 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_({
11101
11117
  examplePath: t,
11102
11118
  projectRoot: e,
11103
11119
  installedEnvSections: n,
@@ -11108,7 +11124,7 @@ async function X_(e, t) {
11108
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)
11109
11125
  };
11110
11126
  }
11111
- async function Z_(e) {
11127
+ async function Q_(e) {
11112
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) => {
11113
11129
  let t = Qi(e.section);
11114
11130
  return {
@@ -11119,7 +11135,7 @@ async function Z_(e) {
11119
11135
  let t = ua(e.key, i, r);
11120
11136
  return {
11121
11137
  key: e.key,
11122
- state: Q_(Ys(s, e.key), e.value),
11138
+ state: $_(Ys(s, e.key), e.value),
11123
11139
  setup: t?.setup ?? null,
11124
11140
  ...t?.group ? { group: t.group } : {}
11125
11141
  };
@@ -11133,20 +11149,20 @@ async function Z_(e) {
11133
11149
  sections: c
11134
11150
  };
11135
11151
  }
11136
- function Q_(e, t) {
11152
+ function $_(e, t) {
11137
11153
  return e === "" ? "missing" : e === t.trim() ? "default" : "filled";
11138
11154
  }
11139
11155
  //#endregion
11140
11156
  //#region src/mcp/tools/env-status.ts
11141
- var $_ = { cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
11142
- async function ev(e) {
11143
- 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);
11144
11160
  if (!n) throw new ct({
11145
11161
  reason: "not_a_project",
11146
11162
  message: `${t} has no stack.json, so there is nothing to check.`,
11147
11163
  details: { cwd: t }
11148
11164
  });
11149
- let r = await X_(t, n);
11165
+ let r = await Z_(t, n);
11150
11166
  return {
11151
11167
  cwd: t,
11152
11168
  missingCount: r.missingCount,
@@ -11156,9 +11172,9 @@ async function ev(e) {
11156
11172
  }
11157
11173
  //#endregion
11158
11174
  //#region src/mcp/tools/inspect-stack.ts
11159
- var tv = { cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
11160
- async function nv(e) {
11161
- 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);
11162
11178
  if (!n) throw new ct({
11163
11179
  reason: "not_a_project",
11164
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.`,
@@ -11186,12 +11202,12 @@ async function nv(e) {
11186
11202
  }
11187
11203
  //#endregion
11188
11204
  //#region src/mcp/tools/plan-install.ts
11189
- var rv = {
11205
+ var iv = {
11190
11206
  packs: j.array(j.string()).min(1).describe("Pack names to plan an install for"),
11191
11207
  cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in.")
11192
11208
  };
11193
- async function iv(e) {
11194
- 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));
11195
11211
  if (c.length > 0) throw Error(`Unknown pack${c.length === 1 ? "" : "s"}: ${c.join(", ")}`);
11196
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) => {
11197
11213
  let t = s.get(e);
@@ -11220,12 +11236,12 @@ async function iv(e) {
11220
11236
  purchaseUrl: n ? jt(e) : null
11221
11237
  };
11222
11238
  }),
11223
- ...n === null ? { authHint: I_ } : {}
11239
+ ...n === null ? { authHint: L_ } : {}
11224
11240
  };
11225
11241
  }
11226
11242
  //#endregion
11227
11243
  //#region src/mcp/tools/search-catalog.ts
11228
- var av = {
11244
+ var ov = {
11229
11245
  query: j.string().optional().describe("Free text matched against name, display name, and description"),
11230
11246
  kind: j.enum([
11231
11247
  "pack",
@@ -11238,31 +11254,31 @@ var av = {
11238
11254
  "paid",
11239
11255
  "all"
11240
11256
  ]).default("all").describe("Restrict packs by price tier")
11241
- }, ov = (e, t) => {
11257
+ }, sv = (e, t) => {
11242
11258
  let n = t.trim().toLowerCase();
11243
11259
  return n === "" ? !0 : e.some((e) => e.toLowerCase().includes(n));
11244
11260
  };
11245
- function sv(e, t) {
11261
+ function cv(e, t) {
11246
11262
  let { query: n = "", category: r, tier: i = "all" } = t;
11247
- 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([
11248
11264
  e.name,
11249
11265
  e.displayName,
11250
11266
  e.description
11251
11267
  ], n));
11252
11268
  }
11253
- function cv(e, t) {
11269
+ function lv(e, t) {
11254
11270
  let { query: n = "", category: r } = t;
11255
- return e.filter((e) => r && e.category !== r ? !1 : ov([
11271
+ return e.filter((e) => r && e.category !== r ? !1 : sv([
11256
11272
  e.id,
11257
11273
  e.name,
11258
11274
  e.description,
11259
11275
  ...e.tags
11260
11276
  ], n));
11261
11277
  }
11262
- async function lv(e) {
11263
- 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_()]);
11264
11280
  return {
11265
- packs: sv(n, e).map((e) => ({
11281
+ packs: cv(n, e).map((e) => ({
11266
11282
  name: e.name,
11267
11283
  displayName: e.displayName,
11268
11284
  description: e.description,
@@ -11271,7 +11287,7 @@ async function lv(e) {
11271
11287
  price: e.price,
11272
11288
  dependencies: e.dependencies
11273
11289
  })),
11274
- templates: cv(r, e).map((e) => ({
11290
+ templates: lv(r, e).map((e) => ({
11275
11291
  id: e.id,
11276
11292
  name: e.name,
11277
11293
  description: e.description,
@@ -11288,117 +11304,117 @@ async function lv(e) {
11288
11304
  }
11289
11305
  //#endregion
11290
11306
  //#region src/mcp/server.ts
11291
- var uv = "hype-stack";
11292
- function dv() {
11307
+ var dv = "hype-stack";
11308
+ function fv() {
11293
11309
  let e = new ue({
11294
- name: uv,
11310
+ name: dv,
11295
11311
  version: pe
11296
11312
  }, {
11297
11313
  capabilities: { tools: {} },
11298
- instructions: fv
11314
+ instructions: pv
11299
11315
  });
11300
11316
  return e.registerTool("search_catalog", {
11301
11317
  title: "Search the Hype Stack catalog",
11302
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.",
11303
- inputSchema: av,
11319
+ inputSchema: ov,
11304
11320
  annotations: {
11305
11321
  readOnlyHint: !0,
11306
11322
  openWorldHint: !0
11307
11323
  }
11308
- }, (e) => M_(() => lv(e))), e.registerTool("plan_install", {
11324
+ }, (e) => N_(() => uv(e))), e.registerTool("plan_install", {
11309
11325
  title: "Plan a pack install",
11310
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.",
11311
- inputSchema: rv,
11327
+ inputSchema: iv,
11312
11328
  annotations: {
11313
11329
  readOnlyHint: !0,
11314
11330
  openWorldHint: !0
11315
11331
  }
11316
- }, (e) => M_(() => iv(e))), e.registerTool("create_application", {
11332
+ }, (e) => N_(() => av(e))), e.registerTool("create_application", {
11317
11333
  title: "Create a Hype Stack application",
11318
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.",
11319
- inputSchema: G_,
11335
+ inputSchema: K_,
11320
11336
  annotations: {
11321
11337
  readOnlyHint: !1,
11322
11338
  destructiveHint: !1,
11323
11339
  openWorldHint: !0
11324
11340
  }
11325
- }, (e) => M_(() => K_(e))), e.registerTool("add_packs", {
11341
+ }, (e) => N_(() => q_(e))), e.registerTool("add_packs", {
11326
11342
  title: "Add feature packs",
11327
11343
  description: "Install packs into an existing project. Requires an explicit onConflict policy because there is no prompt to fall back on.",
11328
- inputSchema: L_,
11344
+ inputSchema: R_,
11329
11345
  annotations: {
11330
11346
  readOnlyHint: !1,
11331
11347
  destructiveHint: !0,
11332
11348
  openWorldHint: !0
11333
11349
  }
11334
- }, (e) => M_(() => R_(e))), e.registerTool("apply_template", {
11350
+ }, (e) => N_(() => z_(e))), e.registerTool("apply_template", {
11335
11351
  title: "Apply a project template",
11336
11352
  description: "Install a template: its starter, layout, fixed packs, and frontend overrides. Pass variants to swap a slot away from the template default.",
11337
- inputSchema: B_,
11353
+ inputSchema: V_,
11338
11354
  annotations: {
11339
11355
  readOnlyHint: !1,
11340
11356
  destructiveHint: !0,
11341
11357
  openWorldHint: !0
11342
11358
  }
11343
- }, (e) => M_(() => V_(e))), e.registerTool("inspect_stack", {
11359
+ }, (e) => N_(() => H_(e))), e.registerTool("inspect_stack", {
11344
11360
  title: "Inspect the project stack",
11345
11361
  description: "Read stack.json and the detected workspace layout: installed packs, app paths, and whether this is a Hype Stack project at all.",
11346
- inputSchema: tv,
11362
+ inputSchema: nv,
11347
11363
  annotations: {
11348
11364
  readOnlyHint: !0,
11349
11365
  openWorldHint: !1
11350
11366
  }
11351
- }, (e) => M_(() => nv(e))), e.registerTool("env_status", {
11367
+ }, (e) => N_(() => rv(e))), e.registerTool("env_status", {
11352
11368
  title: "Check environment variables",
11353
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`.",
11354
- inputSchema: $_,
11370
+ inputSchema: ev,
11355
11371
  annotations: {
11356
11372
  readOnlyHint: !0,
11357
11373
  openWorldHint: !1
11358
11374
  }
11359
- }, (e) => M_(() => ev(e))), e.registerTool("auth_status", {
11375
+ }, (e) => N_(() => tv(e))), e.registerTool("auth_status", {
11360
11376
  title: "Check Hype Stack authentication",
11361
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.",
11362
- inputSchema: U_,
11378
+ inputSchema: W_,
11363
11379
  annotations: {
11364
11380
  readOnlyHint: !0,
11365
11381
  openWorldHint: !0
11366
11382
  }
11367
- }, () => M_(() => W_())), e;
11383
+ }, () => N_(() => G_())), e;
11368
11384
  }
11369
- 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\".";
11370
- 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() {
11371
11387
  tt("mcp");
11372
- let e = j_();
11373
- await dv().connect(new de(process.stdin, e));
11388
+ let e = M_();
11389
+ await fv().connect(new de(process.stdin, e));
11374
11390
  }
11375
11391
  //#endregion
11376
11392
  //#region src/cli.ts
11377
- function mv(e) {
11393
+ function hv(e) {
11378
11394
  if (!e) return;
11379
11395
  let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
11380
11396
  return t.length > 0 ? t : void 0;
11381
11397
  }
11382
- function hv(e, t) {
11398
+ function gv(e, t) {
11383
11399
  let n = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
11384
11400
  return [...t ?? [], ...n];
11385
11401
  }
11386
- function gv(e) {
11402
+ function _v(e) {
11387
11403
  return e === "light" || e === "dark" ? e : void 0;
11388
11404
  }
11389
- function _v(e) {
11405
+ function vv(e) {
11390
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)");
11391
11407
  }
11392
- function vv(e) {
11408
+ function yv(e) {
11393
11409
  return {
11394
11410
  theme: e.theme,
11395
11411
  adminTheme: e.adminTheme,
11396
11412
  radius: e.radius,
11397
11413
  adminRadius: e.adminRadius,
11398
- mode: gv(e.mode)
11414
+ mode: _v(e.mode)
11399
11415
  };
11400
11416
  }
11401
- function yv(e) {
11417
+ function bv(e) {
11402
11418
  if (!e) return;
11403
11419
  let t = {};
11404
11420
  for (let n of e.split(",")) {
@@ -11407,12 +11423,12 @@ function yv(e) {
11407
11423
  }
11408
11424
  return Object.keys(t).length > 0 ? t : void 0;
11409
11425
  }
11410
- function bv(e) {
11426
+ function xv(e) {
11411
11427
  if (!e) return;
11412
11428
  let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
11413
11429
  return t.length > 0 ? t : void 0;
11414
11430
  }
11415
- function xv(e) {
11431
+ function Sv(e) {
11416
11432
  let t = {};
11417
11433
  for (let n of [...Ff, ...If]) {
11418
11434
  let r = e[n];
@@ -11420,10 +11436,10 @@ function xv(e) {
11420
11436
  }
11421
11437
  return t;
11422
11438
  }
11423
- function Sv() {
11439
+ function Cv() {
11424
11440
  let e = new s();
11425
- 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) => {
11426
- 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);
11427
11443
  await af({
11428
11444
  name: e.name,
11429
11445
  directory: e.directory,
@@ -11440,34 +11456,34 @@ function Sv() {
11440
11456
  }), e.command("init").description("Initialize stack.json in the current project").action(async () => {
11441
11457
  await of({});
11442
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) => {
11443
- await f_({
11459
+ await p_({
11444
11460
  cwd: e.cwd,
11445
11461
  yes: e.yes
11446
11462
  });
11447
- }), _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) => {
11448
11464
  await cf({
11449
- packs: mv(e.packs),
11465
+ packs: hv(e.packs),
11450
11466
  force: e.force,
11451
11467
  yes: e.yes,
11452
11468
  cwd: e.cwd,
11453
- ...vv(e)
11469
+ ...yv(e)
11454
11470
  });
11455
- }), _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) => {
11456
- 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_({
11457
11473
  templateId: e,
11458
- variants: yv(t.variants),
11459
- packs: mv(t.packs),
11474
+ variants: bv(t.variants),
11475
+ packs: hv(t.packs),
11460
11476
  force: t.force,
11461
11477
  yes: t.yes,
11462
11478
  cwd: t.cwd,
11463
- ...vv(t)
11479
+ ...yv(t)
11464
11480
  });
11465
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) => {
11466
- await Wg({
11482
+ await Gg({
11467
11483
  cwd: e.cwd,
11468
11484
  provider: e.provider,
11469
- assign: xv(e),
11470
- only: bv(e.only),
11485
+ assign: Sv(e),
11486
+ only: xv(e.only),
11471
11487
  environment: e.environment,
11472
11488
  flyOrg: e.flyOrg,
11473
11489
  railwayWorkspace: e.railwayWorkspace,
@@ -11479,9 +11495,9 @@ function Sv() {
11479
11495
  });
11480
11496
  let t = e.command("mcp").description("Run the Model Context Protocol server for AI editors");
11481
11497
  return t.action(async () => {
11482
- await pv();
11498
+ await mv();
11483
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) => {
11484
- await r_({
11500
+ await i_({
11485
11501
  editor: e.editor,
11486
11502
  scope: e.scope,
11487
11503
  cwd: e.cwd,
@@ -11489,12 +11505,12 @@ function Sv() {
11489
11505
  print: e.print
11490
11506
  });
11491
11507
  }), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
11492
- await t_();
11493
- }), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
11494
11508
  await n_();
11509
+ }), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
11510
+ await r_();
11495
11511
  }), e.command("auth").description("Alias for `login`").action(async () => {
11496
- await t_();
11512
+ await n_();
11497
11513
  }), e;
11498
11514
  }
11499
11515
  //#endregion
11500
- 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 };