@hype-stack/cli 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/{cli-B_dUEkkB.js → cli-cPE06mGY.js} +1547 -1300
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/commands/create.d.ts.map +1 -1
  4. package/dist/commands/init.d.ts +9 -2
  5. package/dist/commands/init.d.ts.map +1 -1
  6. package/dist/commands/install-helpers.d.ts +1 -1
  7. package/dist/commands/install-helpers.d.ts.map +1 -1
  8. package/dist/commands/onboard.d.ts +3 -0
  9. package/dist/commands/onboard.d.ts.map +1 -0
  10. package/dist/commands/template.d.ts.map +1 -1
  11. package/dist/config/bin.js +1 -1
  12. package/dist/constants/themes.d.ts +9 -0
  13. package/dist/constants/themes.d.ts.map +1 -1
  14. package/dist/core/apply-mode.d.ts +23 -0
  15. package/dist/core/apply-mode.d.ts.map +1 -0
  16. package/dist/core/codegen.d.ts +6 -4
  17. package/dist/core/codegen.d.ts.map +1 -1
  18. package/dist/core/env-files.d.ts +1 -0
  19. package/dist/core/env-files.d.ts.map +1 -1
  20. package/dist/core/onboard-catalog.d.ts +55 -0
  21. package/dist/core/onboard-catalog.d.ts.map +1 -0
  22. package/dist/core/onboard-env.d.ts +36 -0
  23. package/dist/core/onboard-env.d.ts.map +1 -0
  24. package/dist/core/post-clone.d.ts.map +1 -1
  25. package/dist/core/post-setup.d.ts +23 -0
  26. package/dist/core/post-setup.d.ts.map +1 -1
  27. package/dist/core/readme.d.ts +2 -1
  28. package/dist/core/readme.d.ts.map +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/themes.js +29 -25
  31. package/dist/types/types.d.ts +27 -0
  32. package/dist/types/types.d.ts.map +1 -1
  33. package/dist/ui/pack-multiselect.d.ts.map +1 -1
  34. package/dist/utils/naming.d.ts +17 -0
  35. package/dist/utils/naming.d.ts.map +1 -0
  36. package/dist/utils/validate.d.ts +6 -0
  37. package/dist/utils/validate.d.ts.map +1 -1
  38. package/package.json +1 -1
@@ -1,19 +1,19 @@
1
- import { DEFAULT_THEME as e, THEME_CHOICES as t, THEME_LIST as n, getTheme as r, isThemeName as i } from "./themes.js";
2
- import { Command as a } from "commander";
3
- import * as o from "@clack/prompts";
4
- import { S_BAR as s, S_BAR_END as c, S_CHECKBOX_ACTIVE as l, S_CHECKBOX_INACTIVE as u, S_CHECKBOX_SELECTED as d, S_RADIO_ACTIVE as f, isCancel as p, limitOptions as m, settings as h, symbol as g, symbolBar as _ } from "@clack/prompts";
5
- import v from "node:fs/promises";
6
- import y from "picocolors";
7
- import { createHash as b, randomBytes as x } from "node:crypto";
8
- import S from "node:http";
9
- import C from "node:os";
10
- import w from "node:path";
11
- import { exec as T, spawn as E } from "node:child_process";
12
- import { Prompt as D } from "@clack/core";
13
- import { styleText as O } from "node:util";
1
+ import { DEFAULT_MODE as e, DEFAULT_THEME as t, THEME_CHOICES as n, THEME_LIST as r, getTheme as i, isThemeName as a } from "./themes.js";
2
+ import { Command as o } from "commander";
3
+ import * as s from "@clack/prompts";
4
+ import { S_BAR as c, S_BAR_END as l, S_CHECKBOX_ACTIVE as u, S_CHECKBOX_INACTIVE as d, S_CHECKBOX_SELECTED as f, S_RADIO_ACTIVE as p, isCancel as m, limitOptions as h, settings as g, symbol as _, symbolBar as v } from "@clack/prompts";
5
+ import y from "node:fs/promises";
6
+ import b from "picocolors";
7
+ import { createHash as x, randomBytes as S } from "node:crypto";
8
+ import C from "node:http";
9
+ import w from "node:os";
10
+ import T from "node:path";
11
+ import { exec as E, spawn as D } from "node:child_process";
12
+ import { Prompt as O } from "@clack/core";
13
+ import { styleText as k } from "node:util";
14
14
  import { downloadTemplate as ee } from "giget";
15
15
  //#region src/constants/constants.ts
16
- var k = "0.5.1", te = "gh:BetterTyped/hype-stack", ne = "stack.json", re = "/schema/stack.json", A = "https://api.hype-stack.dev", j = "HYPE_STACK_API_URL", ie = "https://www.hype-stack.dev", M = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, ae = [
16
+ var A = "0.5.2", te = "gh:BetterTyped/hype-stack", ne = "stack.json", re = "/schema/stack.json", j = "https://api.hype-stack.dev", M = "HYPE_STACK_API_URL", N = "https://www.hype-stack.dev", ie = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, P = [
17
17
  {
18
18
  value: "cursor",
19
19
  label: "Cursor",
@@ -31,70 +31,70 @@ var k = "0.5.1", te = "gh:BetterTyped/hype-stack", ne = "stack.json", re = "/sch
31
31
  value: "copilot",
32
32
  label: "GitHub Copilot"
33
33
  }
34
- ], oe = ae.map((e) => e.value), se = ".cursor/rules", ce = ".cursor", le = ".agents";
35
- function N() {
34
+ ], ae = P.map((e) => e.value), oe = ".cursor/rules", se = ".cursor", ce = ".agents";
35
+ function F() {
36
36
  let e = process.env.HYPE_STACK_API_URL;
37
- return e ? (ue(e), e.replace(/\/+$/, "")) : A;
37
+ return e ? (ue(e), e.replace(/\/+$/, "")) : j;
38
38
  }
39
- function P() {
39
+ function le() {
40
40
  let e = process.env.HYPE_STACK_WEB_URL;
41
- return e ? (ue(e), e.replace(/\/+$/, "")) : ie;
41
+ return e ? (ue(e), e.replace(/\/+$/, "")) : N;
42
42
  }
43
43
  function ue(e) {
44
44
  try {
45
45
  let t = new URL(e);
46
- if (!t.protocol.startsWith("http")) throw Error(`${j} must use http or https protocol, got "${t.protocol}"`);
46
+ if (!t.protocol.startsWith("http")) throw Error(`${M} must use http or https protocol, got "${t.protocol}"`);
47
47
  } catch (t) {
48
- throw t instanceof TypeError ? Error(`${j} is not a valid URL: "${e}"`, { cause: t }) : t;
48
+ throw t instanceof TypeError ? Error(`${M} is not a valid URL: "${e}"`, { cause: t }) : t;
49
49
  }
50
50
  }
51
51
  function de() {
52
- return `${N()}${re}`;
52
+ return `${F()}${re}`;
53
53
  }
54
54
  //#endregion
55
55
  //#region src/ui/theme.ts
56
- var fe = (e) => `\x1b[38;5;208m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;214m${e}\x1b[39m`, F = (e) => `\x1b[38;5;220m${e}\x1b[39m`, me = (e) => `\x1b[38;5;33m${e}\x1b[39m`, I = (e) => `\x1b[38;5;39m${e}\x1b[39m`, he = (e) => `\x1b[38;5;81m${e}\x1b[39m`, ge = {
56
+ var fe = (e) => `\x1b[38;5;208m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;214m${e}\x1b[39m`, I = (e) => `\x1b[38;5;220m${e}\x1b[39m`, me = (e) => `\x1b[38;5;33m${e}\x1b[39m`, L = (e) => `\x1b[38;5;39m${e}\x1b[39m`, he = (e) => `\x1b[38;5;81m${e}\x1b[39m`, ge = {
57
57
  orange: fe,
58
58
  orangeBright: pe,
59
- amber: F,
59
+ amber: I,
60
60
  deepBlue: me,
61
- skyBlue: I,
61
+ skyBlue: L,
62
62
  lightBlue: he
63
- }, L = {
63
+ }, R = {
64
64
  brand: (e) => fe(e),
65
- brandBold: (e) => y.bold(fe(e)),
66
- accent: (e) => I(e),
67
- accentBold: (e) => y.bold(I(e)),
68
- success: (e) => y.green(e),
69
- error: (e) => y.red(e),
70
- warning: (e) => y.yellow(e),
71
- muted: (e) => y.dim(e),
72
- bold: (e) => y.bold(e),
73
- highlight: (e) => y.bold(y.white(e)),
74
- path: (e) => y.underline(I(e)),
75
- command: (e) => y.bold(F(e)),
76
- label: (e) => y.dim(y.bold(e))
65
+ brandBold: (e) => b.bold(fe(e)),
66
+ accent: (e) => L(e),
67
+ accentBold: (e) => b.bold(L(e)),
68
+ success: (e) => b.green(e),
69
+ error: (e) => b.red(e),
70
+ warning: (e) => b.yellow(e),
71
+ muted: (e) => b.dim(e),
72
+ bold: (e) => b.bold(e),
73
+ highlight: (e) => b.bold(b.white(e)),
74
+ path: (e) => b.underline(L(e)),
75
+ command: (e) => b.bold(I(e)),
76
+ label: (e) => b.dim(b.bold(e))
77
77
  };
78
78
  function _e(e, t = e) {
79
- return `\x1b]8;;${e}\x07${I(t)}\x1b]8;;\x07`;
79
+ return `\x1b]8;;${e}\x07${L(t)}\x1b]8;;\x07`;
80
80
  }
81
- var R = {
81
+ var z = {
82
82
  arrow: fe("›"),
83
- bullet: L.muted("·"),
84
- dash: L.muted("─"),
85
- corner: L.muted("╰"),
86
- pipe: L.muted("│"),
87
- dot: L.muted("•"),
88
- spark: F("✦"),
83
+ bullet: R.muted("·"),
84
+ dash: R.muted("─"),
85
+ corner: R.muted("╰"),
86
+ pipe: R.muted("│"),
87
+ dot: R.muted("•"),
88
+ spark: I("✦"),
89
89
  sparkSmall: pe("✧"),
90
- bolt: F("⚡")
90
+ bolt: I("⚡")
91
91
  }, ve = [
92
- F,
93
- F,
92
+ I,
93
+ I,
94
94
  pe,
95
95
  fe,
96
96
  me,
97
- I,
97
+ L,
98
98
  he,
99
99
  he
100
100
  ];
@@ -120,7 +120,7 @@ function xe(e, t) {
120
120
  //#endregion
121
121
  //#region src/core/license.ts
122
122
  function Se(e) {
123
- return `${P()}/packs/${e}`;
123
+ return `${le()}/packs/${e}`;
124
124
  }
125
125
  //#endregion
126
126
  //#region ../../node_modules/.pnpm/@hyper-fetch+core@8.1.1/node_modules/@hyper-fetch/core/dist/index.mjs
@@ -335,11 +335,11 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
335
335
  isFocused;
336
336
  constructor(e) {
337
337
  this.options = e, this.emitter?.setMaxListeners(1e3);
338
- let { initiallyFocused: t = B.initiallyFocused, initiallyOnline: n = B.initiallyOnline } = this.options || B;
338
+ let { initiallyFocused: t = V.initiallyFocused, initiallyOnline: n = V.initiallyOnline } = this.options || V;
339
339
  this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser = Re();
340
340
  }
341
341
  initialize = () => {
342
- let { focusEvent: e = B.focusEvent, onlineEvent: t = B.onlineEvent } = this.options || B;
342
+ let { focusEvent: e = V.focusEvent, onlineEvent: t = V.onlineEvent } = this.options || V;
343
343
  e(this.setFocused), t(this.setOnline);
344
344
  };
345
345
  setInitialFocus = async (e) => {
@@ -370,24 +370,24 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
370
370
  }
371
371
  }, ze = (e, t, n) => Le() ? (window.addEventListener(e, t, n), () => window.removeEventListener(e, t, n)) : () => null, Be = (e, t, n) => Re() ? (window.document.addEventListener(e, t, n), () => window.document.removeEventListener(e, t, n)) : () => null, Ve = (e) => ({
372
372
  emitFocus: () => {
373
- e.emit(z.FOCUS);
373
+ e.emit(B.FOCUS);
374
374
  },
375
375
  emitBlur: () => {
376
- e.emit(z.BLUR);
376
+ e.emit(B.BLUR);
377
377
  },
378
378
  emitOnline: () => {
379
- e.emit(z.ONLINE);
379
+ e.emit(B.ONLINE);
380
380
  },
381
381
  emitOffline: () => {
382
- e.emit(z.OFFLINE);
382
+ e.emit(B.OFFLINE);
383
383
  },
384
- onFocus: (t) => (e.on(z.FOCUS, t), () => e.removeListener(z.FOCUS, t)),
385
- onBlur: (t) => (e.on(z.BLUR, t), () => e.removeListener(z.BLUR, t)),
386
- onOnline: (t) => (e.on(z.ONLINE, t), () => e.removeListener(z.ONLINE, t)),
387
- onOffline: (t) => (e.on(z.OFFLINE, t), () => e.removeListener(z.OFFLINE, t))
388
- }), z = /* @__PURE__ */ function(e) {
384
+ onFocus: (t) => (e.on(B.FOCUS, t), () => e.removeListener(B.FOCUS, t)),
385
+ onBlur: (t) => (e.on(B.BLUR, t), () => e.removeListener(B.BLUR, t)),
386
+ onOnline: (t) => (e.on(B.ONLINE, t), () => e.removeListener(B.ONLINE, t)),
387
+ onOffline: (t) => (e.on(B.OFFLINE, t), () => e.removeListener(B.OFFLINE, t))
388
+ }), B = /* @__PURE__ */ function(e) {
389
389
  return e.FOCUS = "focus", e.BLUR = "blur", e.ONLINE = "online", e.OFFLINE = "offline", e;
390
- }({}), B = {
390
+ }({}), V = {
391
391
  initiallyFocused: !0,
392
392
  initiallyOnline: !0,
393
393
  focusEvent: (e) => {
@@ -562,26 +562,26 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
562
562
  constructor() {
563
563
  super("Request deleted"), this.name = "DeletedError";
564
564
  }
565
- }, V = class extends Error {
565
+ }, At = class extends Error {
566
566
  description;
567
567
  constructor(e) {
568
568
  super("Request processing error"), this.description = e, this.name = "RequestProcessingError";
569
569
  }
570
- }, At = class extends Error {
570
+ }, jt = class extends Error {
571
571
  description;
572
572
  constructor(e) {
573
573
  super("Unexpected error"), this.description = e, this.name = "UnexpectedError";
574
574
  }
575
- }, H = (e) => e === "timeout" ? new Dt() : e === "abort" ? new Ot() : e === "deleted" ? new kt() : e === "processing" ? new V() : new At(), jt = (e) => {
575
+ }, H = (e) => e === "timeout" ? new Dt() : e === "abort" ? new Ot() : e === "deleted" ? new kt() : e === "processing" ? new At() : new jt(), Mt = (e) => {
576
576
  try {
577
577
  return JSON.stringify(e);
578
578
  } catch {
579
579
  return "";
580
580
  }
581
- }, Mt = (e) => {
581
+ }, Nt = (e) => {
582
582
  let t = Le() && e.payload instanceof FormData, n = typeof e.payload == "object" && e.payload !== null, r = {};
583
583
  return !t && n && (r["Content-Type"] = "application/json"), Object.assign(r, e.headers), r;
584
- }, Nt = (e) => Le() && e instanceof FormData ? e : jt(e), Pt = [
584
+ }, Pt = (e) => Le() && e instanceof FormData ? e : Mt(e), Ft = [
585
585
  "onBeforeSent",
586
586
  "onRequestStart",
587
587
  "onResponseStart",
@@ -590,7 +590,7 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
590
590
  "onResponse",
591
591
  "onRemove"
592
592
  ];
593
- function Ft(e) {
593
+ function It(e) {
594
594
  let t = {
595
595
  onBeforeSent: [],
596
596
  onRequestStart: [],
@@ -600,7 +600,7 @@ function Ft(e) {
600
600
  onResponse: [],
601
601
  onRemove: []
602
602
  };
603
- e && Pt.forEach((n) => {
603
+ e && Ft.forEach((n) => {
604
604
  t[n] = [...e[n]];
605
605
  });
606
606
  let n = (e) => (n) => (t[e].push(n), () => {
@@ -622,15 +622,15 @@ function Ft(e) {
622
622
  },
623
623
  __snapshot() {
624
624
  let e = {};
625
- return Pt.forEach((n) => {
625
+ return Ft.forEach((n) => {
626
626
  e[n] = [...t[n]];
627
627
  }), e;
628
628
  }
629
629
  };
630
630
  }
631
- var It = /* @__PURE__ */ function(e) {
631
+ var Lt = /* @__PURE__ */ function(e) {
632
632
  return e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.PATCH = "PATCH", e.DELETE = "DELETE", e;
633
- }({}), U = (e, t) => t ? `${t}__${e}` : e, Lt = (e) => {
633
+ }({}), U = (e, t) => t ? `${t}__${e}` : e, Rt = (e) => {
634
634
  try {
635
635
  if (typeof e == "string") return e;
636
636
  if (e == null) return "";
@@ -640,13 +640,13 @@ var It = /* @__PURE__ */ function(e) {
640
640
  } catch {
641
641
  return "";
642
642
  }
643
- }, Rt = ({ loaded: e, total: t }) => !e || !t ? 0 : Number((e * 100 / t).toFixed(0)), zt = (e, t, { total: n, loaded: r }) => {
643
+ }, zt = ({ loaded: e, total: t }) => !e || !t ? 0 : Number((e * 100 / t).toFixed(0)), Bt = (e, t, { total: n, loaded: r }) => {
644
644
  let i = r / (t - +e || 1), a = Math.max(n, r), o = a - r, s = i ? o / i : null;
645
645
  return {
646
646
  timeLeft: a === r ? 0 : s,
647
647
  sizeLeft: o
648
648
  };
649
- }, Bt = (e, t, n) => {
649
+ }, Vt = (e, t, n) => {
650
650
  let { total: r, loaded: i } = n;
651
651
  if (Number.isNaN(r) || Number.isNaN(i)) return {
652
652
  progress: 0,
@@ -656,23 +656,23 @@ var It = /* @__PURE__ */ function(e) {
656
656
  loaded: 0,
657
657
  startTimestamp: +e
658
658
  };
659
- let { timeLeft: a, sizeLeft: o } = zt(e, t, n);
659
+ let { timeLeft: a, sizeLeft: o } = Bt(e, t, n);
660
660
  return {
661
- progress: Rt(n),
661
+ progress: zt(n),
662
662
  timeLeft: a,
663
663
  sizeLeft: o,
664
664
  total: r,
665
665
  loaded: i,
666
666
  startTimestamp: +e
667
667
  };
668
- }, Vt = (e) => `${e.method}_${e.requestOptions.endpoint}_${e.cancelable}`, Ht = (e, t) => `${Lt(e.method)}_${t ? e.requestOptions.endpoint : Lt(e.endpoint)}_${t ? "" : Lt(e.queryParams)}`, Ut = (e, t = "auto") => {
669
- let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method === It.GET, a = t === "auto" && i || t === "fetch";
668
+ }, Ht = (e) => `${e.method}_${e.requestOptions.endpoint}_${e.cancelable}`, Ut = (e, t) => `${Rt(e.method)}_${t ? e.requestOptions.endpoint : Rt(e.endpoint)}_${t ? "" : Rt(e.queryParams)}`, Wt = (e, t = "auto") => {
669
+ let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method === Lt.GET, a = t === "auto" && i || t === "fetch";
670
670
  return [a ? n : r, a];
671
- }, Wt = async (e, t) => {
671
+ }, Gt = async (e, t) => {
672
672
  let n = e.unstable_responseMapper?.(t);
673
673
  return n instanceof Promise ? await n : n || t;
674
- }, Gt = async (e, t) => {
675
- let { client: n } = e, { requestManager: r } = n, [i] = Ut(e, t?.dispatcherType), a;
674
+ }, Kt = async (e, t) => {
675
+ let { client: n } = e, { requestManager: r } = n, [i] = Wt(e, t?.dispatcherType), a;
676
676
  if (e.optimistic) try {
677
677
  a = await e.optimistic({
678
678
  request: e,
@@ -759,9 +759,9 @@ var It = /* @__PURE__ */ function(e) {
759
759
  u(), d(), f(), p(), m(), h();
760
760
  }
761
761
  });
762
- }, Kt = /* @__PURE__ */ function(e) {
762
+ }, qt = /* @__PURE__ */ function(e) {
763
763
  return e[e.SEC = 1e3] = "SEC", e[e.MIN = 6e4] = "MIN", e[e.HOUR = 36e5] = "HOUR", e[e.DAY = 864e5] = "DAY", e[e.WEEK = 6048e5] = "WEEK", e[e.MONTH_30 = 2592e6] = "MONTH_30", e[e.MONTH_31 = 26784e5] = "MONTH_31", e[e.YEAR = 31536e6] = "YEAR", e[e.YEAR_LEAP = 316224e5] = "YEAR_LEAP", e;
764
- }({}), qt = class e {
764
+ }({}), Jt = class e {
765
765
  endpoint;
766
766
  headers;
767
767
  auth;
@@ -785,7 +785,7 @@ var It = /* @__PURE__ */ function(e) {
785
785
  deduplicate;
786
786
  deduplicateTime;
787
787
  scope;
788
- $hooks = Ft();
788
+ $hooks = It();
789
789
  isMockerEnabled = !1;
790
790
  unstable_mock;
791
791
  unstable_payloadMapper;
@@ -802,7 +802,7 @@ var It = /* @__PURE__ */ function(e) {
802
802
  updatedQueryKey;
803
803
  constructor(e, t, n) {
804
804
  this.client = e, this.requestOptions = t, this.initialRequestConfiguration = n;
805
- let { endpoint: r, headers: i, auth: a = !0, method: o = e.adapter.defaultMethod, options: s, cancelable: c = !1, retry: l = 0, retryTime: u = 500, cacheTime: d = Kt.MIN * 5, cache: f = !0, staleTime: p = Kt.MIN * 5, queued: m = !1, offline: h = !0, abortKey: g, cacheKey: _, queryKey: v, deduplicate: y = !1, deduplicateTime: b = null } = {
805
+ let { endpoint: r, headers: i, auth: a = !0, method: o = e.adapter.defaultMethod, options: s, cancelable: c = !1, retry: l = 0, retryTime: u = 500, cacheTime: d = qt.MIN * 5, cache: f = !0, staleTime: p = qt.MIN * 5, queued: m = !1, offline: h = !0, abortKey: g, cacheKey: _, queryKey: v, deduplicate: y = !1, deduplicateTime: b = null } = {
806
806
  ...this.client.adapter.unstable_getRequestDefaults?.(t),
807
807
  ...t
808
808
  };
@@ -912,7 +912,7 @@ var It = /* @__PURE__ */ function(e) {
912
912
  payload: t?.payload || this.payload,
913
913
  params: t?.params || this.params
914
914
  }, r = new e(this.client, this.requestOptions, n);
915
- return r.unstable_payloadMapper = this.unstable_payloadMapper, r.unstable_responseMapper = this.unstable_responseMapper, r.unstable_requestMapper = this.unstable_requestMapper, r.retryOnError = this.retryOnError, r.unstable_mock = this.unstable_mock, r.isMockerEnabled = this.isMockerEnabled, r.optimistic = this.optimistic, r.$hooks = Ft(this.$hooks.__snapshot()), r;
915
+ return r.unstable_payloadMapper = this.unstable_payloadMapper, r.unstable_responseMapper = this.unstable_responseMapper, r.unstable_requestMapper = this.unstable_requestMapper, r.retryOnError = this.retryOnError, r.unstable_mock = this.unstable_mock, r.isMockerEnabled = this.isMockerEnabled, r.optimistic = this.optimistic, r.$hooks = It(this.$hooks.__snapshot()), r;
916
916
  }
917
917
  abort = () => {
918
918
  let { requestManager: e } = this.client;
@@ -975,17 +975,17 @@ var It = /* @__PURE__ */ function(e) {
975
975
  ...e,
976
976
  cachePolicy: void 0
977
977
  };
978
- if (n === "network-only") return Gt(i, a);
978
+ if (n === "network-only") return Kt(i, a);
979
979
  let o = i.read();
980
- if (n === "cache-first") return o ? Wt(i, o) : Gt(i, a);
980
+ if (n === "cache-first") return o ? Gt(i, o) : Kt(i, a);
981
981
  if (o) {
982
- let e = await Wt(i, o);
983
- return Gt(i, a), e;
982
+ let e = await Gt(i, o);
983
+ return Kt(i, a), e;
984
984
  }
985
- return Gt(i, a);
985
+ return Kt(i, a);
986
986
  };
987
987
  static fromJSON = (t, n) => new e(t, n.requestOptions, n);
988
- }, Jt = async ({ request: e, requestId: t, resolve: n, onStartTime: r, internalErrorMapping: i }) => {
988
+ }, Yt = async ({ request: e, requestId: t, resolve: n, onStartTime: r, internalErrorMapping: i }) => {
989
989
  let { requestManager: a, loggerManager: o } = e.client, { unstable_payloadMapper: s } = e.client.adapter, c = o.initialize(e.client, "Adapter"), l = null, u = null, d = e, f = 1, p = 1, m = 0, h = 0;
990
990
  c.debug({
991
991
  title: "Running middleware callbacks",
@@ -1004,14 +1004,14 @@ var It = /* @__PURE__ */ function(e) {
1004
1004
  let n = Number(t.total || 0), r = Number(t.loaded || 0);
1005
1005
  return Math.max(n, r, e);
1006
1006
  }, T = (e, n, r) => {
1007
- let i = Bt(new Date(e), new Date(n), r);
1007
+ let i = Vt(new Date(e), new Date(n), r);
1008
1008
  m !== 100 && (m = i.total, a.events.emitUploadProgress({
1009
1009
  ...i,
1010
1010
  requestId: t,
1011
1011
  request: d
1012
1012
  }));
1013
1013
  }, E = (e, n, r) => {
1014
- let i = Bt(new Date(e), new Date(n), r);
1014
+ let i = Vt(new Date(e), new Date(n), r);
1015
1015
  h !== 100 && (h = i.total, a.events.emitDownloadProgress({
1016
1016
  ...i,
1017
1017
  requestId: t,
@@ -1043,21 +1043,21 @@ var It = /* @__PURE__ */ function(e) {
1043
1043
  requestId: t,
1044
1044
  request: d
1045
1045
  }), l;
1046
- }, ee = (e) => {
1046
+ }, k = (e) => {
1047
1047
  l ||= +/* @__PURE__ */ new Date(), f = w(f, e);
1048
1048
  let t = +/* @__PURE__ */ new Date();
1049
1049
  return T(l, t, {
1050
1050
  total: f,
1051
1051
  loaded: e.loaded || 0
1052
1052
  }), t;
1053
- }, k = () => {
1053
+ }, ee = () => {
1054
1054
  l ||= +/* @__PURE__ */ new Date();
1055
1055
  let e = +/* @__PURE__ */ new Date();
1056
1056
  return T(l, e, {
1057
1057
  total: f,
1058
1058
  loaded: f
1059
1059
  }), e;
1060
- }, te = (e) => {
1060
+ }, A = (e) => {
1061
1061
  u = +/* @__PURE__ */ new Date(), p = w(p, e);
1062
1062
  let n = {
1063
1063
  total: p,
@@ -1067,21 +1067,21 @@ var It = /* @__PURE__ */ function(e) {
1067
1067
  requestId: t,
1068
1068
  request: d
1069
1069
  }), u;
1070
- }, ne = (e) => {
1070
+ }, te = (e) => {
1071
1071
  u ||= +/* @__PURE__ */ new Date();
1072
1072
  let t = +/* @__PURE__ */ new Date();
1073
1073
  return p = w(p, e), E(u, t, {
1074
1074
  total: e.total || p,
1075
1075
  loaded: e.loaded || 0
1076
1076
  }), t;
1077
- }, re = () => {
1077
+ }, ne = () => {
1078
1078
  u ||= +/* @__PURE__ */ new Date();
1079
1079
  let e = +/* @__PURE__ */ new Date();
1080
1080
  return E(u, e, {
1081
1081
  total: p,
1082
1082
  loaded: p
1083
1083
  }), e;
1084
- }, A = async ({ data: e, error: r, status: i, extra: a }) => {
1084
+ }, re = async ({ data: e, error: r, status: i, extra: a }) => {
1085
1085
  let o = {
1086
1086
  data: e,
1087
1087
  error: r ?? null,
@@ -1106,13 +1106,13 @@ var It = /* @__PURE__ */ function(e) {
1106
1106
  response: o
1107
1107
  }
1108
1108
  }), o;
1109
- }, j = Yt({
1109
+ }, j = Xt({
1110
1110
  request: d,
1111
1111
  requestId: t,
1112
1112
  startTime: x,
1113
1113
  logger: c,
1114
1114
  resolve: n
1115
- }), ie = ({ status: e, extra: n }) => (c.error({
1115
+ }), M = ({ status: e, extra: n }) => (c.error({
1116
1116
  title: "Abort error",
1117
1117
  type: "request",
1118
1118
  extra: {
@@ -1123,7 +1123,7 @@ var It = /* @__PURE__ */ function(e) {
1123
1123
  error: i(H("abort")),
1124
1124
  status: e,
1125
1125
  extra: n
1126
- })), M = ({ status: e, extra: n }) => (c.error({
1126
+ })), N = ({ status: e, extra: n }) => (c.error({
1127
1127
  title: "Timeout error",
1128
1128
  type: "request",
1129
1129
  extra: {
@@ -1134,7 +1134,7 @@ var It = /* @__PURE__ */ function(e) {
1134
1134
  error: H("timeout"),
1135
1135
  status: e,
1136
1136
  extra: n
1137
- })), ae = ({ status: e, extra: n }) => (c.error({
1137
+ })), ie = ({ status: e, extra: n }) => (c.error({
1138
1138
  title: "Unexpected error",
1139
1139
  type: "request",
1140
1140
  extra: {
@@ -1145,11 +1145,11 @@ var It = /* @__PURE__ */ function(e) {
1145
1145
  error: H(),
1146
1146
  status: e,
1147
1147
  extra: n
1148
- })), oe = () => a.getAbortController(v, t), se = ({ status: e, extra: n, onAbort: r = () => {} }) => {
1149
- let i = oe();
1150
- if (!i) throw new V("Controller is not found");
1148
+ })), P = () => a.getAbortController(v, t), ae = ({ status: e, extra: n, onAbort: r = () => {} }) => {
1149
+ let i = P();
1150
+ if (!i) throw new At("Controller is not found");
1151
1151
  let o = () => {
1152
- ie({
1152
+ M({
1153
1153
  status: e,
1154
1154
  extra: n
1155
1155
  }), r(), a.events.emitAbort({
@@ -1169,36 +1169,36 @@ var It = /* @__PURE__ */ function(e) {
1169
1169
  adapterOptions: b
1170
1170
  }
1171
1171
  });
1172
- let ce = e.client.adapter.unstable_queryParamsMapper(d.queryParams), le = e.client.adapter.unstable_endpointMapper(d.endpoint), N = e.client.adapter.unstable_headerMapper(d), { url: P } = e.client;
1172
+ let oe = e.client.adapter.unstable_queryParamsMapper(d.queryParams), se = e.client.adapter.unstable_endpointMapper(d.endpoint), ce = e.client.adapter.unstable_headerMapper(d), { url: F } = e.client;
1173
1173
  return {
1174
1174
  request: d,
1175
1175
  requestId: t,
1176
- url: P,
1177
- endpoint: le,
1178
- queryParams: ce,
1176
+ url: F,
1177
+ endpoint: se,
1178
+ queryParams: oe,
1179
1179
  payload: y,
1180
- headers: N,
1180
+ headers: ce,
1181
1181
  adapter: e.client.adapter,
1182
1182
  adapterOptions: b,
1183
- getAbortController: oe,
1183
+ getAbortController: P,
1184
1184
  getRequestStartTimestamp: S,
1185
1185
  getResponseStartTimestamp: C,
1186
- createAbortListener: se,
1186
+ createAbortListener: ae,
1187
1187
  onBeforeRequest: D,
1188
1188
  onRequestStart: O,
1189
- onRequestProgress: ee,
1190
- onRequestEnd: k,
1191
- onResponseStart: te,
1192
- onResponseProgress: ne,
1193
- onResponseEnd: re,
1194
- onSuccess: A,
1195
- onAbortError: ie,
1196
- onTimeoutError: M,
1197
- onUnexpectedError: ae,
1189
+ onRequestProgress: k,
1190
+ onRequestEnd: ee,
1191
+ onResponseStart: A,
1192
+ onResponseProgress: te,
1193
+ onResponseEnd: ne,
1194
+ onSuccess: re,
1195
+ onAbortError: M,
1196
+ onTimeoutError: N,
1197
+ onUnexpectedError: ie,
1198
1198
  onError: j
1199
1199
  };
1200
1200
  };
1201
- function Yt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
1201
+ function Xt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
1202
1202
  let { client: a } = e;
1203
1203
  return async ({ error: o, status: s, extra: c }) => {
1204
1204
  let l = {
@@ -1227,8 +1227,8 @@ function Yt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
1227
1227
  }), l;
1228
1228
  };
1229
1229
  }
1230
- var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTimeoutError: i, onRequestEnd: a, createAbortListener: o, onResponseProgress: s, onRequestProgress: c, onResponseStart: l, onBeforeRequest: u, onRequestStart: d, onSuccess: f, onAbortError: p, adapter: m }) => {
1231
- if (!e.unstable_mock) throw new V("Mock should be defined when calling mocker");
1230
+ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTimeoutError: i, onRequestEnd: a, createAbortListener: o, onResponseProgress: s, onRequestProgress: c, onResponseStart: l, onBeforeRequest: u, onRequestStart: d, onSuccess: f, onAbortError: p, adapter: m }) => {
1231
+ if (!e.unstable_mock) throw new At("Mock should be defined when calling mocker");
1232
1232
  let h = !1, { requestTime: g = 20, responseTime: _ = 20, totalUploaded: v = 1e3, totalDownloaded: y = 1e3, timeout: b } = e.unstable_mock.config, { data: x, error: S, status: C, success: w = !0, extra: T = e.client.adapter.defaultExtra } = await e.unstable_mock.fn({
1233
1233
  request: e,
1234
1234
  requestId: t
@@ -1272,7 +1272,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1272
1272
  status: C,
1273
1273
  extra: T
1274
1274
  }), h || r();
1275
- }, Zt = (e) => e, Qt = class {
1275
+ }, Qt = (e) => e, $t = class {
1276
1276
  unstable_fetcher;
1277
1277
  name;
1278
1278
  defaultMethod;
@@ -1294,10 +1294,10 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1294
1294
  initialize = (e) => (this.logger = e.loggerManager.initialize(e, "Adapter"), this.initialized = !0, this.client = e, this.unstable_onInitializeCallback?.({ client: e }), this);
1295
1295
  onInitialize = (e) => (this.unstable_onInitializeCallback = e, this);
1296
1296
  unstable_internalErrorMapping = (e) => e;
1297
- unstable_headerMapper = Mt;
1298
- unstable_payloadMapper = Nt;
1299
- unstable_endpointMapper = Zt;
1300
- unstable_queryParamsMapper = Zt;
1297
+ unstable_headerMapper = Nt;
1298
+ unstable_payloadMapper = Pt;
1299
+ unstable_endpointMapper = Qt;
1300
+ unstable_queryParamsMapper = Qt;
1301
1301
  unstable_getAdapterDefaults;
1302
1302
  unstable_getRequestDefaults;
1303
1303
  unstable_devtoolsEndpointGetter = (e) => e;
@@ -1321,14 +1321,14 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1321
1321
  async fetch(e, t) {
1322
1322
  let n, r = async (r) => {
1323
1323
  try {
1324
- if (!this.initialized) throw new V(`Adapter ${this.options.name} is not initialized`);
1325
- if (!this.unstable_fetcher) throw new V(`Fetcher for ${this.options.name} adapter is not set`);
1324
+ if (!this.initialized) throw new At(`Adapter ${this.options.name} is not initialized`);
1325
+ if (!this.unstable_fetcher) throw new At(`Fetcher for ${this.options.name} adapter is not set`);
1326
1326
  this.client.triggerPlugins("onAdapterFetch", {
1327
1327
  adapter: this,
1328
1328
  request: e,
1329
1329
  requestId: t
1330
1330
  });
1331
- let i = await Jt({
1331
+ let i = await Yt({
1332
1332
  request: e,
1333
1333
  requestId: t,
1334
1334
  resolve: r,
@@ -1337,9 +1337,9 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1337
1337
  n = e;
1338
1338
  }
1339
1339
  });
1340
- return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await Xt(i) : this.unstable_fetcher(i);
1340
+ return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await Zt(i) : this.unstable_fetcher(i);
1341
1341
  } catch (i) {
1342
- return Yt({
1342
+ return Xt({
1343
1343
  request: e,
1344
1344
  requestId: t,
1345
1345
  startTime: n || Date.now(),
@@ -1356,21 +1356,21 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1356
1356
  r(e);
1357
1357
  });
1358
1358
  }
1359
- }, $t = (e) => {
1359
+ }, en = (e) => {
1360
1360
  try {
1361
1361
  return JSON.parse(e);
1362
1362
  } catch {
1363
1363
  return e;
1364
1364
  }
1365
- }, en = (e) => e ? $t(e) : H(), tn = (e) => (t) => {
1365
+ }, tn = (e) => e ? en(e) : H(), nn = (e) => (t) => {
1366
1366
  let { skipNull: n, skipEmptyString: r } = e;
1367
1367
  return !(r && t === void 0 || r && t === "" || n && t === null);
1368
- }, W = (e, { encode: t, strict: n }) => t && n ? encodeURIComponent(e).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`) : t ? encodeURIComponent(e) : e, nn = (e, t, n) => {
1369
- let r = !tn(n)(t);
1368
+ }, W = (e, { encode: t, strict: n }) => t && n ? encodeURIComponent(e).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`) : t ? encodeURIComponent(e) : e, rn = (e, t, n) => {
1369
+ let r = !nn(n)(t);
1370
1370
  return !e || r ? "" : `${W(e, n)}=${W(t instanceof Date ? n.dateParser?.(t) || t.toISOString() : typeof t == "object" && !Array.isArray(t) ? n.objectParser?.(t) || JSON.stringify(t) : String(t), n)}`;
1371
- }, rn = (e, t, n) => {
1371
+ }, an = (e, t, n) => {
1372
1372
  let { arrayFormat: r, arraySeparator: i } = n;
1373
- return t.filter(tn(n)).reduce((t, a, o) => {
1373
+ return t.filter(nn(n)).reduce((t, a, o) => {
1374
1374
  switch (r) {
1375
1375
  case "index": {
1376
1376
  let r = `${W(e, n)}[${W(String(o), n)}]=`;
@@ -1401,21 +1401,21 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1401
1401
  }
1402
1402
  return t;
1403
1403
  }, []).join("&");
1404
- }, an = (e, t = Pn) => {
1404
+ }, on = (e, t = Fn) => {
1405
1405
  if (!e || !Object.keys(e).length) return "";
1406
1406
  if (typeof e == "string") return e[0] === "?" ? e : `?${e}`;
1407
- let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ? rn(e, n, t) : nn(e, n, t)).filter(Boolean).join("&");
1407
+ let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ? an(e, n, t) : rn(e, n, t)).filter(Boolean).join("&");
1408
1408
  return n ? `?${n}` : "";
1409
- }, on = Kt.SEC * 5, sn = { headers: {} }, cn = () => new Qt({
1409
+ }, sn = qt.SEC * 5, cn = { headers: {} }, ln = () => new $t({
1410
1410
  name: "http",
1411
- defaultMethod: It.GET,
1412
- defaultExtra: sn,
1411
+ defaultMethod: Lt.GET,
1412
+ defaultExtra: cn,
1413
1413
  systemErrorStatus: 0,
1414
- systemErrorExtra: sn
1415
- }).setQueryParamsMapper(an).setFetcher(async ({ request: e, adapterOptions: t, headers: n, payload: r, onError: i, onResponseEnd: a, onTimeoutError: o, onRequestEnd: s, createAbortListener: c, getAbortController: l, onResponseProgress: u, onResponseStart: d, onBeforeRequest: f, onRequestStart: p, onRequestProgress: m, onSuccess: h }) => {
1416
- let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ? an(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = on, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
1414
+ systemErrorExtra: cn
1415
+ }).setQueryParamsMapper(on).setFetcher(async ({ request: e, adapterOptions: t, headers: n, payload: r, onError: i, onResponseEnd: a, onTimeoutError: o, onRequestEnd: s, createAbortListener: c, getAbortController: l, onResponseProgress: u, onResponseStart: d, onBeforeRequest: f, onRequestStart: p, onRequestProgress: m, onSuccess: h }) => {
1416
+ let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ? on(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = sn, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
1417
1417
  status: 0,
1418
- extra: sn
1418
+ extra: cn
1419
1419
  });
1420
1420
  C > 0 && S && (D = setTimeout(() => {
1421
1421
  E = !0, O(), S.abort();
@@ -1447,7 +1447,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1447
1447
  status: l,
1448
1448
  extra: c
1449
1449
  }) : i({
1450
- error: en(await t.text()),
1450
+ error: tn(await t.text()),
1451
1451
  status: l,
1452
1452
  extra: c
1453
1453
  });
@@ -1468,11 +1468,11 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1468
1468
  e = new TextDecoder().decode(o);
1469
1469
  } else e = await t.text();
1470
1470
  a(), O(), t.ok ? h({
1471
- data: $t(e),
1471
+ data: en(e),
1472
1472
  status: l,
1473
1473
  extra: c
1474
1474
  }) : i({
1475
- error: en(e),
1475
+ error: tn(e),
1476
1476
  status: l,
1477
1477
  extra: c
1478
1478
  });
@@ -1481,17 +1481,17 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1481
1481
  if (D && clearTimeout(D), O(), S?.signal?.aborted) {
1482
1482
  E && o({
1483
1483
  status: 0,
1484
- extra: sn
1484
+ extra: cn
1485
1485
  });
1486
1486
  return;
1487
1487
  }
1488
1488
  i({
1489
1489
  error: e,
1490
1490
  status: 0,
1491
- extra: sn
1491
+ extra: cn
1492
1492
  });
1493
1493
  }
1494
- }), ln = () => cn(), un = class {
1494
+ }), un = () => ln(), dn = class {
1495
1495
  emitter = new Fe();
1496
1496
  events;
1497
1497
  storage;
@@ -1503,7 +1503,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1503
1503
  constructor(e) {
1504
1504
  this.options = e;
1505
1505
  let { storage: t = /* @__PURE__ */ new Map(), lazyStorage: n, version: r = "0.0.1" } = e ?? {};
1506
- this.emitter?.setMaxListeners(1e3), this.events = vn(this.emitter), this.storage = t, this.version = r, this.lazyStorage = n;
1506
+ this.emitter?.setMaxListeners(1e3), this.events = yn(this.emitter), this.storage = t, this.version = r, this.lazyStorage = n;
1507
1507
  }
1508
1508
  initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Cache"), e.appManager.events.onOnline(() => {
1509
1509
  [...this.storage.keys()].forEach(this.scheduleGarbageCollector);
@@ -1517,7 +1517,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1517
1517
  response: t
1518
1518
  }
1519
1519
  });
1520
- let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = U(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u = dn(c, l), d = {
1520
+ let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = U(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u = fn(c, l), d = {
1521
1521
  ...u,
1522
1522
  scope: o,
1523
1523
  staleTime: i,
@@ -1601,7 +1601,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1601
1601
  cacheKey: t
1602
1602
  }), this.events.emitInvalidation(t);
1603
1603
  };
1604
- e instanceof qt ? n(U(e.cacheKey, e.scope), e.cacheKey) : typeof e == "string" ? n(e) : t.length && t.forEach((t) => {
1604
+ e instanceof Jt ? n(U(e.cacheKey, e.scope), e.cacheKey) : typeof e == "string" ? n(e) : t.length && t.forEach((t) => {
1605
1605
  e.test(t) && n(t);
1606
1606
  });
1607
1607
  };
@@ -1656,49 +1656,49 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1656
1656
  clear = async () => {
1657
1657
  this.garbageCollectors.forEach((e) => clearTimeout(e)), this.storage.clear();
1658
1658
  };
1659
- }, dn = (e, t) => {
1659
+ }, fn = (e, t) => {
1660
1660
  let { data: n, success: r } = t, i = !r && e ? e.data : null, a = n || i;
1661
1661
  return {
1662
1662
  ...t,
1663
1663
  data: a
1664
1664
  };
1665
- }, fn = () => "invalidate", pn = (e) => `${e}_invalidate`, mn = () => "delete", hn = (e) => `${e}_delete`, gn = (e) => `${e}_cache`, _n = () => "cache", vn = (e) => ({
1665
+ }, pn = () => "invalidate", mn = (e) => `${e}_invalidate`, hn = () => "delete", gn = (e) => `${e}_delete`, _n = (e) => `${e}_cache`, vn = () => "cache", yn = (e) => ({
1666
1666
  emitCacheData: (t, n = !1) => {
1667
- e.emit(_n(), t, n), e.emit(gn(t.cacheKey), t, n);
1667
+ e.emit(vn(), t, n), e.emit(_n(t.cacheKey), t, n);
1668
1668
  },
1669
1669
  emitInvalidation: (t, n = !1) => {
1670
- e.emit(fn(), t, n), e.emit(pn(t), n);
1670
+ e.emit(pn(), t, n), e.emit(mn(t), n);
1671
1671
  },
1672
1672
  emitDelete: (t, n = !1) => {
1673
- e.emit(mn(), t, n), e.emit(hn(t), n);
1673
+ e.emit(hn(), t, n), e.emit(gn(t), n);
1674
1674
  },
1675
- onData: (t) => (e.on(_n(), t), () => e.removeListener(_n(), t)),
1676
- onDataByKey: (t, n) => (e.on(gn(t), n), () => e.removeListener(gn(t), n)),
1677
- onInvalidate: (t) => (e.on(fn(), t), () => e.removeListener(fn(), t)),
1678
- onInvalidateByKey: (t, n) => (e.on(pn(t), n), () => e.removeListener(pn(t), n)),
1679
- onDelete: (t) => (e.on(mn(), t), () => e.removeListener(mn(), t)),
1680
- onDeleteByKey: (t, n) => (e.on(hn(t), n), () => e.removeListener(hn(t), n))
1675
+ onData: (t) => (e.on(vn(), t), () => e.removeListener(vn(), t)),
1676
+ onDataByKey: (t, n) => (e.on(_n(t), n), () => e.removeListener(_n(t), n)),
1677
+ onInvalidate: (t) => (e.on(pn(), t), () => e.removeListener(pn(), t)),
1678
+ onInvalidateByKey: (t, n) => (e.on(mn(t), n), () => e.removeListener(mn(t), n)),
1679
+ onDelete: (t) => (e.on(hn(), t), () => e.removeListener(hn(), t)),
1680
+ onDeleteByKey: (t, n) => (e.on(gn(t), n), () => e.removeListener(gn(t), n))
1681
1681
  }), G = /* @__PURE__ */ function(e) {
1682
1682
  return e.ONE_BY_ONE = "one-by-one", e.ALL_AT_ONCE = "all-at-once", e.PREVIOUS_CANCELED = "previous-canceled", e.DEDUPLICATED = "deduplicated", e;
1683
- }({}), yn = (e) => ({
1683
+ }({}), bn = (e) => ({
1684
1684
  emitDrained: (t, n) => {
1685
- e.emit(xn(), t, n), e.emit(Sn(t.queryKey), t, n);
1685
+ e.emit(Sn(), t, n), e.emit(Cn(t.queryKey), t, n);
1686
1686
  },
1687
1687
  emitQueueStatusChanged: (t, n) => {
1688
- e.emit(Cn(), t, n), e.emit(wn(t.queryKey), t, n);
1688
+ e.emit(wn(), t, n), e.emit(Tn(t.queryKey), t, n);
1689
1689
  },
1690
1690
  emitQueueChanged: (t, n) => {
1691
- e.emit(Tn(), t, n), e.emit(En(t.queryKey), t, n);
1691
+ e.emit(En(), t, n), e.emit(Dn(t.queryKey), t, n);
1692
1692
  },
1693
- onDrained: (t) => (e.on(xn(), t), () => e.removeListener(xn(), t)),
1694
- onDrainedByKey: (t, n) => (e.on(Sn(t), n), () => e.removeListener(Sn(t), n)),
1695
- onQueueStatusChange: (t) => (e.on(Cn(), t), () => e.removeListener(Cn(), t)),
1696
- onQueueStatusChangeByKey: (t, n) => (e.on(wn(t), n), () => e.removeListener(wn(t), n)),
1697
- onQueueChange: (t) => (e.on(Tn(), t), () => e.removeListener(Tn(), t)),
1698
- onQueueChangeByKey: (t, n) => (e.on(En(t), n), () => e.removeListener(En(t), n))
1699
- }), bn = class {
1693
+ onDrained: (t) => (e.on(Sn(), t), () => e.removeListener(Sn(), t)),
1694
+ onDrainedByKey: (t, n) => (e.on(Cn(t), n), () => e.removeListener(Cn(t), n)),
1695
+ onQueueStatusChange: (t) => (e.on(wn(), t), () => e.removeListener(wn(), t)),
1696
+ onQueueStatusChangeByKey: (t, n) => (e.on(Tn(t), n), () => e.removeListener(Tn(t), n)),
1697
+ onQueueChange: (t) => (e.on(En(), t), () => e.removeListener(En(), t)),
1698
+ onQueueChangeByKey: (t, n) => (e.on(Dn(t), n), () => e.removeListener(Dn(t), n))
1699
+ }), xn = class {
1700
1700
  emitter = new Fe();
1701
- events = yn(this.emitter);
1701
+ events = bn(this.emitter);
1702
1702
  storage = /* @__PURE__ */ new Map();
1703
1703
  requestCount = /* @__PURE__ */ new Map();
1704
1704
  runningRequests = /* @__PURE__ */ new Map();
@@ -1707,7 +1707,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1707
1707
  constructor(e) {
1708
1708
  this.options = e, this.emitter?.setMaxListeners(1e3), this.options?.storage && (this.storage = this.options.storage);
1709
1709
  }
1710
- isRequestJSON = (e) => !(e instanceof qt);
1710
+ isRequestJSON = (e) => !(e instanceof Jt);
1711
1711
  initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Dispatcher"), this.client.appManager.events.onOnline(() => {
1712
1712
  this.flush();
1713
1713
  }), this);
@@ -1866,7 +1866,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1866
1866
  resolved: !1
1867
1867
  });
1868
1868
  add = (e) => {
1869
- let t = U(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = kn(e, i);
1869
+ let t = U(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = An(e, i);
1870
1870
  switch (this.logger.debug({
1871
1871
  title: "Adding request to queue",
1872
1872
  type: "system",
@@ -1920,7 +1920,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
1920
1920
  requestId: n
1921
1921
  }
1922
1922
  });
1923
- let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = U(a, c), u = U(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h = Dn(e.retries, r), g = !m.isOnline && s, _ = this.hasRunningRequest(l, n), v = e.stopped;
1923
+ let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = U(a, c), u = U(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h = On(e.retries, r), g = !m.isOnline && s, _ = this.hasRunningRequest(l, n), v = e.stopped;
1924
1924
  if (g || _ || v) return this.logger.warning({
1925
1925
  title: "Unable to perform request",
1926
1926
  type: "system",
@@ -2054,26 +2054,26 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
2054
2054
  }
2055
2055
  }), this.delete(l, n, u));
2056
2056
  };
2057
- }, xn = () => "drained-event", Sn = (e) => `${e}-drained-event`, Cn = () => "status-event", wn = (e) => `${e}-status-event`, Tn = () => "change-event", En = (e) => `${e}-change-event`, Dn = (e, t) => !!(t && e < t), On = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, kn = (e, t) => {
2058
- let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? On(e, t) : !1;
2057
+ }, Sn = () => "drained-event", Cn = (e) => `${e}-drained-event`, wn = () => "status-event", Tn = (e) => `${e}-status-event`, En = () => "change-event", Dn = (e) => `${e}-change-event`, On = (e, t) => !!(t && e < t), kn = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, An = (e, t) => {
2058
+ let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? kn(e, t) : !1;
2059
2059
  return n ? G.ONE_BY_ONE : r ? G.PREVIOUS_CANCELED : a && i ? G.DEDUPLICATED : G.ALL_AT_ONCE;
2060
2060
  };
2061
- function An(e) {
2061
+ function jn(e) {
2062
2062
  return e === "client" || e === "server" ? e : typeof window < "u" && typeof document < "u" ? "client" : "server";
2063
2063
  }
2064
- var jn = async (e, t) => {
2064
+ var Mn = async (e, t) => {
2065
2065
  let n = t;
2066
2066
  if (!t.requestOptions.disableRequestInterceptors) {
2067
2067
  for (let r of e) if (n = await r(t), !n) throw Error("Request modifier must return request");
2068
2068
  }
2069
2069
  return n;
2070
- }, Mn = async (e, t, n) => {
2070
+ }, Nn = async (e, t, n) => {
2071
2071
  let r = t;
2072
2072
  if (!n.requestOptions.disableResponseInterceptors) {
2073
2073
  for (let i of e) if (r = await i(t, n), !r) throw Error("Response modifier must return data");
2074
2074
  }
2075
2075
  return r;
2076
- }, Nn = class {
2076
+ }, Pn = class {
2077
2077
  url;
2078
2078
  mode;
2079
2079
  debug;
@@ -2091,15 +2091,15 @@ var jn = async (e, t) => {
2091
2091
  submitDispatcher;
2092
2092
  isMockerEnabled = !0;
2093
2093
  plugins = [];
2094
- unstable_abortKeyMapper = Vt;
2095
- unstable_cacheKeyMapper = Ht;
2096
- unstable_queryKeyMapper = Ht;
2094
+ unstable_abortKeyMapper = Ht;
2095
+ unstable_cacheKeyMapper = Ut;
2096
+ unstable_queryKeyMapper = Ut;
2097
2097
  unstable_requestIdMapper = Me;
2098
2098
  logger = this.loggerManager.initialize(this, "Client");
2099
2099
  constructor(e) {
2100
2100
  this.options = e;
2101
2101
  let { url: t, appManager: n, cache: r, fetchDispatcher: i, submitDispatcher: a, mode: o } = this.options;
2102
- this.url = t, this.mode = An(o), this.adapter = ln(), this.appManager = n?.() || new Ie(), this.cache = r?.() || new un(), this.fetchDispatcher = i?.() || new bn(), this.submitDispatcher = a?.() || new bn(), this.adapter.initialize(this), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
2102
+ this.url = t, this.mode = jn(o), this.adapter = un(), this.appManager = n?.() || new Ie(), this.cache = r?.() || new dn(), this.fetchDispatcher = i?.() || new xn(), this.submitDispatcher = a?.() || new xn(), this.adapter.initialize(this), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
2103
2103
  }
2104
2104
  setDebug = (e) => (this.debug = e, this);
2105
2105
  setLogLevel = (e) => (this.loggerManager.setSeverity(e), this);
@@ -2128,15 +2128,15 @@ var jn = async (e, t) => {
2128
2128
  setCacheKeyMapper = (e) => (this.unstable_cacheKeyMapper = e, this);
2129
2129
  setQueryKeyMapper = (e) => (this.unstable_queryKeyMapper = e, this);
2130
2130
  setRequestIdMapper = (e) => (this.unstable_requestIdMapper = e, this);
2131
- unstable_modifyAuth = async (e) => jn(this.unstable_onAuthCallbacks, e);
2132
- unstable_modifyRequest = async (e) => jn(this.unstable_onRequestCallbacks, e);
2133
- unstable_modifyErrorResponse = async (e, t) => Mn(this.unstable_onErrorCallbacks, e, t);
2134
- unstable_modifySuccessResponse = async (e, t) => Mn(this.unstable_onSuccessCallbacks, e, t);
2135
- unstable_modifyResponse = async (e, t) => Mn(this.unstable_onResponseCallbacks, e, t);
2136
- fromJSON = (e) => qt.fromJSON(this, e);
2131
+ unstable_modifyAuth = async (e) => Mn(this.unstable_onAuthCallbacks, e);
2132
+ unstable_modifyRequest = async (e) => Mn(this.unstable_onRequestCallbacks, e);
2133
+ unstable_modifyErrorResponse = async (e, t) => Nn(this.unstable_onErrorCallbacks, e, t);
2134
+ unstable_modifySuccessResponse = async (e, t) => Nn(this.unstable_onSuccessCallbacks, e, t);
2135
+ unstable_modifyResponse = async (e, t) => Nn(this.unstable_onResponseCallbacks, e, t);
2136
+ fromJSON = (e) => Jt.fromJSON(this, e);
2137
2137
  clear = () => {
2138
2138
  let { appManager: e, cache: t, fetchDispatcher: n, submitDispatcher: r } = this.options;
2139
- this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new un(), this.appManager = e?.() || new Ie(), this.fetchDispatcher = n?.() || new bn(), this.submitDispatcher = r?.() || new bn(), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
2139
+ this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new dn(), this.appManager = e?.() || new Ie(), this.fetchDispatcher = n?.() || new xn(), this.submitDispatcher = r?.() || new xn(), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
2140
2140
  };
2141
2141
  hydrate = (e, t) => {
2142
2142
  e?.forEach((e) => {
@@ -2154,7 +2154,7 @@ var jn = async (e, t) => {
2154
2154
  ...t
2155
2155
  };
2156
2156
  if (!s.override && this.cache.get(U(n, r))) return;
2157
- let c = $t(i);
2157
+ let c = en(i);
2158
2158
  this.cache.set({
2159
2159
  ...s,
2160
2160
  cacheKey: n,
@@ -2166,10 +2166,10 @@ var jn = async (e, t) => {
2166
2166
  let t = this.adapter.unstable_endpointMapper(e.endpoint), n = {
2167
2167
  ...e,
2168
2168
  endpoint: String(t)
2169
- }, r = new qt(this, n);
2169
+ }, r = new Jt(this, n);
2170
2170
  return this.plugins.forEach((e) => e.trigger("onRequestCreate", { request: r })), r;
2171
2171
  };
2172
- }, Pn = {
2172
+ }, Fn = {
2173
2173
  strict: !0,
2174
2174
  encode: !0,
2175
2175
  arrayFormat: "bracket",
@@ -2178,22 +2178,22 @@ var jn = async (e, t) => {
2178
2178
  skipNull: !0,
2179
2179
  skipEmptyString: !0
2180
2180
  };
2181
- function Fn(e) {
2182
- return new Nn(e);
2181
+ function In(e) {
2182
+ return new Pn(e);
2183
2183
  }
2184
2184
  //#endregion
2185
2185
  //#region src/core/client.ts
2186
- var K = Fn({ url: N() });
2186
+ var K = In({ url: F() });
2187
2187
  //#endregion
2188
2188
  //#region src/core/auth-api.ts
2189
- async function In(e) {
2189
+ async function Ln(e) {
2190
2190
  let { data: t, success: n } = await K.createRequest()({
2191
2191
  endpoint: "/auth/cli/whoami",
2192
2192
  method: "GET"
2193
2193
  }).setHeaders({ Authorization: `Bearer ${e}` }).send();
2194
2194
  return !n || !t ? null : t;
2195
2195
  }
2196
- async function Ln(e) {
2196
+ async function Rn(e) {
2197
2197
  await K.createRequest()({
2198
2198
  endpoint: "/auth/cli/token",
2199
2199
  method: "DELETE"
@@ -2201,78 +2201,78 @@ async function Ln(e) {
2201
2201
  }
2202
2202
  //#endregion
2203
2203
  //#region src/core/auth-store.ts
2204
- var Rn = 1, zn = "hype-stack", Bn = "auth.json";
2205
- function Vn() {
2204
+ var zn = 1, Bn = "hype-stack", Vn = "auth.json";
2205
+ function Hn() {
2206
2206
  let e = process.env.HYPE_STACK_CONFIG_DIR;
2207
- if (e) return w.join(e, zn);
2208
- let t = C.homedir();
2207
+ if (e) return T.join(e, Bn);
2208
+ let t = w.homedir();
2209
2209
  if (process.platform === "win32") {
2210
- let e = process.env.APPDATA ?? w.join(t, "AppData", "Roaming");
2211
- return w.join(e, zn);
2210
+ let e = process.env.APPDATA ?? T.join(t, "AppData", "Roaming");
2211
+ return T.join(e, Bn);
2212
2212
  }
2213
- if (process.platform === "darwin") return w.join(t, "Library", "Application Support", zn);
2214
- let n = process.env.XDG_CONFIG_HOME ?? w.join(t, ".config");
2215
- return w.join(n, zn);
2213
+ if (process.platform === "darwin") return T.join(t, "Library", "Application Support", Bn);
2214
+ let n = process.env.XDG_CONFIG_HOME ?? T.join(t, ".config");
2215
+ return T.join(n, Bn);
2216
2216
  }
2217
- function Hn() {
2218
- return w.join(Vn(), Bn);
2217
+ function Un() {
2218
+ return T.join(Hn(), Vn);
2219
2219
  }
2220
- async function Un() {
2221
- let e = await v.readFile(Hn(), "utf-8").catch(() => null);
2220
+ async function Wn() {
2221
+ let e = await y.readFile(Un(), "utf-8").catch(() => null);
2222
2222
  if (!e) return {
2223
- version: Rn,
2223
+ version: zn,
2224
2224
  tokens: {}
2225
2225
  };
2226
2226
  let t = JSON.parse(e);
2227
2227
  return {
2228
- version: t.version ?? Rn,
2228
+ version: t.version ?? zn,
2229
2229
  tokens: t.tokens ?? {}
2230
2230
  };
2231
2231
  }
2232
- async function Wn(e) {
2233
- let t = Vn();
2234
- await v.mkdir(t, { recursive: !0 }), await v.writeFile(Hn(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
2235
- }
2236
2232
  async function Gn(e) {
2237
- return (await Un()).tokens[e] ?? null;
2233
+ let t = Hn();
2234
+ await y.mkdir(t, { recursive: !0 }), await y.writeFile(Un(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
2235
+ }
2236
+ async function Kn(e) {
2237
+ return (await Wn()).tokens[e] ?? null;
2238
2238
  }
2239
- async function Kn(e, t) {
2240
- let n = await Un();
2241
- n.tokens[e] = t, await Wn(n);
2239
+ async function qn(e, t) {
2240
+ let n = await Wn();
2241
+ n.tokens[e] = t, await Gn(n);
2242
2242
  }
2243
- async function qn(e) {
2244
- let t = await Un();
2245
- e in t.tokens && (delete t.tokens[e], await Wn(t));
2243
+ async function Jn(e) {
2244
+ let t = await Wn();
2245
+ e in t.tokens && (delete t.tokens[e], await Gn(t));
2246
2246
  }
2247
2247
  //#endregion
2248
2248
  //#region src/core/device.ts
2249
- function Jn() {
2250
- let e = C.networkInterfaces();
2249
+ function Yn() {
2250
+ let e = w.networkInterfaces();
2251
2251
  for (let t of Object.values(e)) if (t) {
2252
2252
  for (let e of t) if (!e.internal && e.mac !== "00:00:00:00:00:00") return e.mac;
2253
2253
  }
2254
2254
  return "unknown";
2255
2255
  }
2256
- function Yn() {
2257
- let e = `${Jn()}:${C.hostname()}:${C.platform()}:${C.arch()}`;
2258
- return b("sha256").update(e).digest("hex").slice(0, 16);
2259
- }
2260
2256
  function Xn() {
2261
- return `hype-stack/${k} ${C.platform()} ${C.arch()} node/${process.version.slice(1)}`;
2257
+ let e = `${Yn()}:${w.hostname()}:${w.platform()}:${w.arch()}`;
2258
+ return x("sha256").update(e).digest("hex").slice(0, 16);
2259
+ }
2260
+ function Zn() {
2261
+ return `hype-stack/${A} ${w.platform()} ${w.arch()} node/${process.version.slice(1)}`;
2262
2262
  }
2263
2263
  //#endregion
2264
2264
  //#region src/core/open-browser.ts
2265
- function Zn(e) {
2266
- T(process.platform === "darwin" ? `open "${e}"` : process.platform === "win32" ? `start "" "${e}"` : `xdg-open "${e}"`);
2265
+ function Qn(e) {
2266
+ E(process.platform === "darwin" ? `open "${e}"` : process.platform === "win32" ? `start "" "${e}"` : `xdg-open "${e}"`);
2267
2267
  }
2268
2268
  //#endregion
2269
2269
  //#region src/core/login.ts
2270
- var Qn = 300 * 1e3, $n = (e) => `<!doctype html><html><head><meta charset="utf-8"><title>Hype Stack CLI</title></head><body style="font-family:system-ui,sans-serif;text-align:center;padding-top:4rem;color:#111"><h2>${e}</h2><p>You can close this tab and return to your terminal.</p></body></html>`;
2271
- async function er(e = {}) {
2272
- let t = x(16).toString("hex"), n = N(), r = S.createServer(), i = await new Promise((n, i) => {
2270
+ var $n = 300 * 1e3, er = (e) => `<!doctype html><html><head><meta charset="utf-8"><title>Hype Stack CLI</title></head><body style="font-family:system-ui,sans-serif;text-align:center;padding-top:4rem;color:#111"><h2>${e}</h2><p>You can close this tab and return to your terminal.</p></body></html>`;
2271
+ async function tr(e = {}) {
2272
+ let t = S(16).toString("hex"), n = F(), r = C.createServer(), i = await new Promise((n, i) => {
2273
2273
  let a = setTimeout(() => {
2274
2274
  o(), i(/* @__PURE__ */ Error("Login timed out. Run `npx @hype-stack/cli login` again."));
2275
- }, Qn);
2275
+ }, $n);
2276
2276
  function o() {
2277
2277
  clearTimeout(a), r.close(), r.closeAllConnections?.();
2278
2278
  }
@@ -2286,7 +2286,7 @@ async function er(e = {}) {
2286
2286
  r.writeHead(200, {
2287
2287
  "Content-Type": "text/html",
2288
2288
  Connection: "close"
2289
- }), r.end($n(e));
2289
+ }), r.end(er(e));
2290
2290
  };
2291
2291
  if (a.searchParams.get("state") !== t) {
2292
2292
  s("Login failed."), o(), i(/* @__PURE__ */ Error("Login failed: state mismatch. Run `npx @hype-stack/cli login` again."));
@@ -2301,55 +2301,55 @@ async function er(e = {}) {
2301
2301
  }), r.on("error", (e) => {
2302
2302
  o(), i(e);
2303
2303
  }), r.listen(0, "127.0.0.1", () => {
2304
- let { port: n } = r.address(), i = encodeURIComponent(Xn()), a = `${P()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
2305
- e.onUrl?.(a), Zn(a);
2304
+ let { port: n } = r.address(), i = encodeURIComponent(Zn()), a = `${le()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
2305
+ e.onUrl?.(a), Qn(a);
2306
2306
  });
2307
- }), a = await In(i).catch(() => null), o = {
2307
+ }), a = await Ln(i).catch(() => null), o = {
2308
2308
  token: i,
2309
2309
  email: a?.email,
2310
2310
  organizationId: a?.organizationId
2311
2311
  };
2312
- return await Kn(n, o), o;
2312
+ return await qn(n, o), o;
2313
2313
  }
2314
2314
  //#endregion
2315
2315
  //#region src/core/access-prompts.ts
2316
- async function tr() {
2317
- let e = await o.confirm({ message: "Log in to install packs your organization owns? (opens your browser)" });
2318
- if (o.isCancel(e) || !e) return null;
2319
- o.log.step("Opening your browser to sign in...");
2316
+ async function nr() {
2317
+ let e = await s.confirm({ message: "Log in to install packs your organization owns? (opens your browser)" });
2318
+ if (s.isCancel(e) || !e) return null;
2319
+ s.log.step("Opening your browser to sign in...");
2320
2320
  try {
2321
- let e = await er({ onUrl: (e) => {
2322
- o.log.info(`If your browser didn't open, visit:\n ${L.path(e)}`);
2321
+ let e = await tr({ onUrl: (e) => {
2322
+ s.log.info(`If your browser didn't open, visit:\n ${R.path(e)}`);
2323
2323
  } });
2324
- return o.log.success(e.email ? `Logged in as ${e.email}` : "Logged in"), e.token;
2324
+ return s.log.success(e.email ? `Logged in as ${e.email}` : "Logged in"), e.token;
2325
2325
  } catch (e) {
2326
- return o.log.error(e instanceof Error ? e.message : String(e)), null;
2326
+ return s.log.error(e instanceof Error ? e.message : String(e)), null;
2327
2327
  }
2328
2328
  }
2329
- async function nr(e) {
2329
+ async function rr(e) {
2330
2330
  if (e.length === 0) return;
2331
- o.note([
2331
+ s.note([
2332
2332
  "These packs need a purchase before they can be installed:",
2333
2333
  "",
2334
- ...e.map((e) => ` ${L.brand(e.displayName)} ${L.highlight(`$${e.price}`)}`)
2334
+ ...e.map((e) => ` ${R.brand(e.displayName)} ${R.highlight(`$${e.price}`)}`)
2335
2335
  ].join("\n"), "Locked Packs");
2336
- let t = await o.confirm({ message: `Open the purchase ${e.length === 1 ? "page" : "pages"} in your browser?` });
2337
- if (o.isCancel(t) || !t) {
2338
- o.log.info(L.muted("Run 'npx @hype-stack/cli login' after purchasing, then 'npx @hype-stack/cli compose' again."));
2336
+ let t = await s.confirm({ message: `Open the purchase ${e.length === 1 ? "page" : "pages"} in your browser?` });
2337
+ if (s.isCancel(t) || !t) {
2338
+ s.log.info(R.muted("Run 'npx @hype-stack/cli login' after purchasing, then 'npx @hype-stack/cli compose' again."));
2339
2339
  return;
2340
2340
  }
2341
- for (let t of e) Zn(Se(t.name));
2342
- o.log.info([
2343
- L.muted("After purchasing, run:"),
2344
- ` ${L.highlight("npx @hype-stack/cli login")} ${L.muted("Save your access")}`,
2345
- ` ${L.highlight("npx @hype-stack/cli compose")} ${L.muted("Install the packs")}`
2341
+ for (let t of e) Qn(Se(t.name));
2342
+ s.log.info([
2343
+ R.muted("After purchasing, run:"),
2344
+ ` ${R.highlight("npx @hype-stack/cli login")} ${R.muted("Save your access")}`,
2345
+ ` ${R.highlight("npx @hype-stack/cli compose")} ${R.muted("Install the packs")}`
2346
2346
  ].join("\n"));
2347
2347
  }
2348
2348
  //#endregion
2349
2349
  //#region src/utils/exec.ts
2350
2350
  function q(e, t, n) {
2351
2351
  return new Promise((r, i) => {
2352
- let a = E(e, t, {
2352
+ let a = D(e, t, {
2353
2353
  cwd: n.cwd,
2354
2354
  stdio: [
2355
2355
  "ignore",
@@ -2380,113 +2380,101 @@ function q(e, t, n) {
2380
2380
  }
2381
2381
  //#endregion
2382
2382
  //#region src/utils/fs.ts
2383
+ async function ir(e) {
2384
+ return (await y.stat(e).catch(() => null))?.isDirectory() ?? !1;
2385
+ }
2383
2386
  async function J(e) {
2384
- return (await v.stat(e).catch(() => null))?.isDirectory() ?? !1;
2387
+ return (await y.stat(e).catch(() => null))?.isFile() ?? !1;
2385
2388
  }
2386
- async function Y(e) {
2387
- return (await v.stat(e).catch(() => null))?.isFile() ?? !1;
2389
+ async function ar(e) {
2390
+ return (await y.readdir(e).catch(() => [])).length === 0;
2388
2391
  }
2389
- async function rr(e) {
2390
- return (await v.readdir(e).catch(() => [])).length === 0;
2391
- }
2392
- async function ir(e) {
2393
- let t = await v.readFile(e, "utf-8").catch(() => null);
2392
+ async function or(e) {
2393
+ let t = await y.readFile(e, "utf-8").catch(() => null);
2394
2394
  return t ? JSON.parse(t) : null;
2395
2395
  }
2396
- async function ar(e, t) {
2397
- await v.writeFile(e, JSON.stringify(t, null, 2) + "\n", "utf-8");
2396
+ async function sr(e, t) {
2397
+ await y.writeFile(e, JSON.stringify(t, null, 2) + "\n", "utf-8");
2398
2398
  }
2399
- async function or(e) {
2399
+ async function cr(e) {
2400
2400
  let t = {};
2401
- if (!await J(e)) return t;
2402
- let n = await v.readdir(e, { withFileTypes: !0 });
2403
- for (let r of n) r.isDirectory() && await Y(w.join(e, r.name, "package.json")) && (t[r.name] = w.relative(w.dirname(e), w.join(e, r.name)));
2401
+ if (!await ir(e)) return t;
2402
+ let n = await y.readdir(e, { withFileTypes: !0 });
2403
+ for (let r of n) r.isDirectory() && await J(T.join(e, r.name, "package.json")) && (t[r.name] = T.relative(T.dirname(e), T.join(e, r.name)));
2404
2404
  return t;
2405
2405
  }
2406
- async function sr(e) {
2407
- await v.rm(e, {
2406
+ async function lr(e) {
2407
+ await y.rm(e, {
2408
2408
  recursive: !0,
2409
2409
  force: !0
2410
2410
  });
2411
2411
  }
2412
- function cr(e, t) {
2413
- return w.basename(e) === t ? e : w.join(e, t);
2412
+ function ur(e, t) {
2413
+ return T.basename(e) === t ? e : T.join(e, t);
2414
2414
  }
2415
2415
  //#endregion
2416
2416
  //#region src/core/codegen.ts
2417
- function lr(e) {
2418
- o.log.info(L.muted("Run database setup yourself when ready:")), o.note([
2419
- `${L.command(`cd ${e}`)}`,
2420
- `${L.command("pnpm exec prisma generate")} ${L.muted("(regenerate the Prisma client)")}`,
2421
- `${L.command("pnpm exec prisma migrate dev")} ${L.muted("(create + apply tables for new packs)")}`
2417
+ function dr(e) {
2418
+ s.log.info(R.muted("Run database setup yourself when ready:")), s.note([
2419
+ `${R.command(`cd ${e}`)}`,
2420
+ `${R.command("pnpm exec prisma generate")} ${R.muted("(regenerate the Prisma client)")}`,
2421
+ `${R.command("pnpm exec prisma migrate dev")} ${R.muted("(create + apply tables for new packs)")}`
2422
2422
  ].join("\n"), "Database Setup");
2423
2423
  }
2424
- async function ur(e) {
2425
- let { projectRoot: t, paths: n, skipPrompts: r, runCommand: i = q } = e, a = n.backend.root, s = w.join(t, a);
2426
- if (!await Y(w.join(s, "package.json"))) return;
2424
+ async function fr(e) {
2425
+ let { projectRoot: t, paths: n, skipPrompts: r, runCommand: i = q } = e, a = n.backend.root, o = T.join(t, a);
2426
+ if (!await J(T.join(o, "package.json"))) return;
2427
2427
  if (r) {
2428
- lr(a);
2428
+ dr(a);
2429
2429
  return;
2430
2430
  }
2431
- let c = await o.confirm({
2432
- message: `Run database setup now? (${L.command("prisma generate")} + ${L.command("prisma migrate")})`,
2431
+ let c = await s.confirm({
2432
+ message: `Run database setup now? (${R.command("prisma migrate dev")})`,
2433
2433
  initialValue: !0
2434
2434
  });
2435
- if (o.isCancel(c) || !c) {
2436
- lr(a);
2435
+ if (s.isCancel(c) || !c) {
2436
+ dr(a);
2437
2437
  return;
2438
2438
  }
2439
- let l = o.spinner();
2440
- l.start("Generating Prisma client...");
2439
+ let l = s.spinner();
2440
+ l.start("Applying database schema...");
2441
2441
  let u = await i("pnpm", [
2442
- "exec",
2443
- "prisma",
2444
- "generate"
2445
- ], { cwd: s });
2446
- if (u.exitCode !== 0) {
2447
- l.error("Prisma client generation failed"), dr(u), lr(a);
2448
- return;
2449
- }
2450
- l.stop(L.success("Prisma client generated"));
2451
- let d = o.spinner();
2452
- d.start("Applying database schema...");
2453
- let f = await i("pnpm", [
2454
2442
  "exec",
2455
2443
  "prisma",
2456
2444
  "migrate",
2457
2445
  "dev",
2458
2446
  "--name",
2459
2447
  "add-packs"
2460
- ], { cwd: s });
2461
- if (f.exitCode !== 0) {
2462
- d.error("Database migration failed (is your database running?)"), dr(f), lr(a);
2448
+ ], { cwd: o });
2449
+ if (u.exitCode !== 0) {
2450
+ l.error("Database migration failed (is your database running?)"), pr(u), dr(a);
2463
2451
  return;
2464
2452
  }
2465
- d.stop(L.success("Database schema applied"));
2453
+ l.stop(R.success("Database schema applied"));
2466
2454
  }
2467
- function dr(e) {
2455
+ function pr(e) {
2468
2456
  let t = (e.stderr || e.stdout).trim();
2469
- t && o.log.warn(L.muted(t));
2457
+ t && s.log.warn(R.muted(t));
2470
2458
  }
2471
2459
  //#endregion
2472
2460
  //#region src/core/stack-config.ts
2473
- async function fr(e) {
2474
- return ir(w.join(e, ne));
2461
+ async function mr(e) {
2462
+ return or(T.join(e, ne));
2475
2463
  }
2476
- async function pr(e) {
2477
- return Y(w.join(e, ne));
2464
+ async function hr(e) {
2465
+ return J(T.join(e, ne));
2478
2466
  }
2479
- async function mr(e, t) {
2480
- await ar(w.join(e, ne), t);
2467
+ async function gr(e, t) {
2468
+ await sr(T.join(e, ne), t);
2481
2469
  }
2482
- async function hr(e) {
2483
- let t = w.join(e, "apps"), n = w.join(e, "packages"), [r, i] = await Promise.all([or(t), or(n)]);
2470
+ async function _r(e) {
2471
+ let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([cr(t), cr(n)]);
2484
2472
  return {
2485
2473
  apps: r,
2486
2474
  packages: i
2487
2475
  };
2488
2476
  }
2489
- function gr(e) {
2477
+ function vr(e) {
2490
2478
  let t = e.apps.backend ?? "apps/backend", n = e.apps.frontend ?? "apps/frontend", r = e.apps.admin ?? "apps/admin", i = e.packages.enums ?? "packages/enums";
2491
2479
  return {
2492
2480
  backend: {
@@ -2520,23 +2508,23 @@ function gr(e) {
2520
2508
  }
2521
2509
  };
2522
2510
  }
2523
- function _r(e, t) {
2511
+ function yr(e, t) {
2524
2512
  return {
2525
2513
  $schema: de(),
2526
2514
  version: 1,
2527
2515
  name: e,
2528
2516
  apps: t.apps,
2529
2517
  packages: t.packages,
2530
- paths: gr(t),
2518
+ paths: vr(t),
2531
2519
  installedPacks: [],
2532
2520
  licenseKey: null
2533
2521
  };
2534
2522
  }
2535
- async function vr(e) {
2536
- let t = w.join(e, "package.json"), n = w.join(e, "apps"), [r, i] = await Promise.all([Y(t), J(n)]);
2523
+ async function br(e) {
2524
+ let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t), ir(n)]);
2537
2525
  return r && i;
2538
2526
  }
2539
- function X(e, t) {
2527
+ function Y(e, t) {
2540
2528
  return e.replace(/\{\{(\w+)\.(\w+)\}\}/g, (n, r, i) => {
2541
2529
  let a = t[r];
2542
2530
  if (!a) throw Error(`Unknown app "${r}" in path template "${e}"`);
@@ -2547,7 +2535,7 @@ function X(e, t) {
2547
2535
  }
2548
2536
  //#endregion
2549
2537
  //#region src/core/registry.ts
2550
- async function yr(e) {
2538
+ async function xr(e) {
2551
2539
  let { data: t, error: n, status: r } = await K.createRequest()({
2552
2540
  endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
2553
2541
  method: "GET"
@@ -2556,13 +2544,13 @@ async function yr(e) {
2556
2544
  if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
2557
2545
  return t;
2558
2546
  }
2559
- async function br(e, t = {}) {
2547
+ async function Sr(e, t = {}) {
2560
2548
  let n = K.createRequest()({
2561
2549
  endpoint: `/packs/${encodeURIComponent(e)}/download`,
2562
2550
  method: "POST"
2563
2551
  }), r = {
2564
- "X-Device-Id": Yn(),
2565
- "X-Client-Info": Xn()
2552
+ "X-Device-Id": Xn(),
2553
+ "X-Client-Info": Zn()
2566
2554
  };
2567
2555
  t.token && (r.Authorization = `Bearer ${t.token}`);
2568
2556
  let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
@@ -2573,32 +2561,32 @@ async function br(e, t = {}) {
2573
2561
  packs: i.packs ?? [],
2574
2562
  expiresAt: i.expiresAt ?? null
2575
2563
  };
2576
- let s = await v.mkdtemp(w.join(C.tmpdir(), `hype-stack-pack-${e}-`));
2564
+ let s = await y.mkdtemp(T.join(w.tmpdir(), `hype-stack-pack-${e}-`));
2577
2565
  return await Promise.all(i.files.map(async (e) => {
2578
- let t = w.join(s, ...e.path.split("/"));
2579
- await v.mkdir(w.dirname(t), { recursive: !0 }), await v.writeFile(t, Buffer.from(e.content, "base64"));
2566
+ let t = T.join(s, ...e.path.split("/"));
2567
+ await y.mkdir(T.dirname(t), { recursive: !0 }), await y.writeFile(t, Buffer.from(e.content, "base64"));
2580
2568
  })), {
2581
2569
  status: "ok",
2582
2570
  packDir: s
2583
2571
  };
2584
2572
  }
2585
- function xr(e, t, n) {
2586
- let r = X(e, t);
2587
- return w.resolve(n, r);
2573
+ function Cr(e, t, n) {
2574
+ let r = Y(e, t);
2575
+ return T.resolve(n, r);
2588
2576
  }
2589
- function Sr(e, t) {
2590
- return w.join(t, e);
2577
+ function wr(e, t) {
2578
+ return T.join(t, e);
2591
2579
  }
2592
- var Cr = K.createRequest()({
2580
+ var Tr = K.createRequest()({
2593
2581
  endpoint: "/packs/list",
2594
2582
  method: "GET"
2595
2583
  });
2596
- async function wr() {
2597
- let { data: e, error: t } = await Cr.send();
2584
+ async function Er() {
2585
+ let { data: e, error: t } = await Tr.send();
2598
2586
  if (t || !e) throw Error(`Failed to fetch pack list: ${String(t)}`);
2599
2587
  return e.packs;
2600
2588
  }
2601
- async function Tr(e, t = {}) {
2589
+ async function Dr(e, t = {}) {
2602
2590
  if (e.length === 0) return {};
2603
2591
  let n = K.createRequest()({
2604
2592
  endpoint: "/packs/authorize",
@@ -2614,35 +2602,35 @@ async function Tr(e, t = {}) {
2614
2602
  }
2615
2603
  //#endregion
2616
2604
  //#region src/core/codemods.ts
2617
- var Er = "@hype-stack/";
2618
- function Dr(e, t) {
2619
- return X(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
2605
+ var Or = "@hype-stack/";
2606
+ function kr(e, t) {
2607
+ return Y(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
2620
2608
  }
2621
- async function Or(e, t, n) {
2622
- let r = X("{{backend.root}}", t), i = w.resolve(n, r, "src/config/env/env.config.ts"), a = w.resolve(n, r, ".env.example"), o = w.resolve(n, r, ".env.test");
2623
- if (await Y(i)) {
2624
- let t = await v.readFile(i, "utf-8");
2625
- for (let n of e) t.includes(`from "${n.from}"`) || (t = kr(t, n), t = Ar(t, n));
2626
- await v.writeFile(i, t, "utf-8");
2609
+ async function Ar(e, t, n) {
2610
+ let r = Y("{{backend.root}}", t), i = T.resolve(n, r, "src/config/env/env.config.ts"), a = T.resolve(n, r, ".env.example"), o = T.resolve(n, r, ".env.test");
2611
+ if (await J(i)) {
2612
+ let t = await y.readFile(i, "utf-8");
2613
+ for (let n of e) t.includes(`from "${n.from}"`) || (t = jr(t, n), t = Mr(t, n));
2614
+ await y.writeFile(i, t, "utf-8");
2627
2615
  }
2628
- if (await Y(a)) {
2629
- let t = await v.readFile(a, "utf-8");
2630
- for (let n of e) t = jr(t, n);
2631
- await v.writeFile(a, t, "utf-8");
2616
+ if (await J(a)) {
2617
+ let t = await y.readFile(a, "utf-8");
2618
+ for (let n of e) t = Nr(t, n);
2619
+ await y.writeFile(a, t, "utf-8");
2632
2620
  }
2633
- if (await Y(o)) {
2634
- let t = await v.readFile(o, "utf-8");
2635
- for (let n of e) t = Mr(t, n);
2636
- await v.writeFile(o, t, "utf-8");
2621
+ if (await J(o)) {
2622
+ let t = await y.readFile(o, "utf-8");
2623
+ for (let n of e) t = Pr(t, n);
2624
+ await y.writeFile(o, t, "utf-8");
2637
2625
  }
2638
2626
  }
2639
- function kr(e, t) {
2627
+ function jr(e, t) {
2640
2628
  let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
2641
2629
  if (r === -1) return n + "\n" + e;
2642
2630
  let i = e.indexOf("\n", e.indexOf(";", r));
2643
2631
  return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
2644
2632
  }
2645
- function Ar(e, t) {
2633
+ function Mr(e, t) {
2646
2634
  let n = `.extend(${t.import}.shape)`;
2647
2635
  if (e.includes(n)) return e;
2648
2636
  let r = e.indexOf("export const envSchema = z.object({");
@@ -2657,27 +2645,27 @@ function Ar(e, t) {
2657
2645
  let o = a + 2;
2658
2646
  return e.slice(0, o) + n + e.slice(o);
2659
2647
  }
2660
- function jr(e, t) {
2648
+ function Nr(e, t) {
2661
2649
  for (let n of Object.keys(t.envExample.vars)) if (e.includes(`${n}=`)) return e;
2662
2650
  let n = [];
2663
2651
  n.push(""), n.push(`# ${t.envExample.section}`);
2664
2652
  for (let [e, r] of Object.entries(t.envExample.vars)) n.push(`${e}=${r}`);
2665
2653
  return e.trimEnd() + "\n" + n.join("\n") + "\n";
2666
2654
  }
2667
- function Mr(e, t) {
2655
+ function Pr(e, t) {
2668
2656
  for (let n of Object.keys(t.envTest)) if (e.includes(`${n}=`)) return e;
2669
2657
  let n = [""];
2670
2658
  for (let [e, r] of Object.entries(t.envTest)) n.push(`${e}=${r}`);
2671
2659
  return e.trimEnd() + "\n" + n.join("\n") + "\n";
2672
2660
  }
2673
- async function Nr(e, t, n) {
2674
- let r = w.resolve(n, X("{{backend.routes}}", t), "index.ts");
2675
- if (!await Y(r)) return;
2676
- let i = await v.readFile(r, "utf-8");
2677
- for (let t of e) i.includes(`from "${t.from}"`) || (i = Pr(i, t), i = Fr(i, t));
2678
- await v.writeFile(r, i, "utf-8");
2661
+ async function Fr(e, t, n) {
2662
+ let r = T.resolve(n, Y("{{backend.routes}}", t), "index.ts");
2663
+ if (!await J(r)) return;
2664
+ let i = await y.readFile(r, "utf-8");
2665
+ for (let t of e) i.includes(`from "${t.from}"`) || (i = Ir(i, t), i = Lr(i, t));
2666
+ await y.writeFile(r, i, "utf-8");
2679
2667
  }
2680
- function Pr(e, t) {
2668
+ function Ir(e, t) {
2681
2669
  let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
2682
2670
  if (r !== -1) {
2683
2671
  let t = e.indexOf("\n", r);
@@ -2686,7 +2674,7 @@ function Pr(e, t) {
2686
2674
  let i = e.indexOf("export const registerRoutes");
2687
2675
  return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
2688
2676
  }
2689
- function Fr(e, t) {
2677
+ function Lr(e, t) {
2690
2678
  let n = `.route("${t.prefix}", ${t.import})`, r = e.match(/\.route\([^)]+\);/g);
2691
2679
  if (r) {
2692
2680
  let t = r[r.length - 1], i = e.lastIndexOf(t) + t.length - 1;
@@ -2694,14 +2682,14 @@ function Fr(e, t) {
2694
2682
  }
2695
2683
  return e.replace("return app;", `return app\n ${n};`);
2696
2684
  }
2697
- async function Ir(e, t, n) {
2698
- let r = w.resolve(n, X("{{backend.root}}", t), "src/context.ts");
2699
- if (!await Y(r)) return;
2700
- let i = await v.readFile(r, "utf-8");
2701
- for (let t of e) i.includes(`export let ${t.export}`) || (i = Lr(i, t), i = Rr(i, t), i = zr(i, t), i = Vr(i, t));
2702
- await v.writeFile(r, i, "utf-8");
2685
+ async function Rr(e, t, n) {
2686
+ let r = T.resolve(n, Y("{{backend.root}}", t), "src/context.ts");
2687
+ if (!await J(r)) return;
2688
+ let i = await y.readFile(r, "utf-8");
2689
+ for (let t of e) i.includes(`export let ${t.export}`) || (i = zr(i, t), i = Br(i, t), i = Vr(i, t), i = Ur(i, t));
2690
+ await y.writeFile(r, i, "utf-8");
2703
2691
  }
2704
- function Lr(e, t) {
2692
+ function zr(e, t) {
2705
2693
  let n = `import { ${t.typeImport.name} } from "${t.typeImport.from}";`;
2706
2694
  if (e.includes(`from "${t.typeImport.from}"`)) return e;
2707
2695
  let r = e.lastIndexOf("import ");
@@ -2709,7 +2697,7 @@ function Lr(e, t) {
2709
2697
  let i = e.indexOf("\n", e.indexOf(";", r));
2710
2698
  return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
2711
2699
  }
2712
- function Rr(e, t) {
2700
+ function Br(e, t) {
2713
2701
  let n = `export let ${t.export}: ${t.type};`, r = e.lastIndexOf("export let ");
2714
2702
  if (r === -1) {
2715
2703
  let t = e.indexOf("export const setupContext");
@@ -2718,15 +2706,15 @@ function Rr(e, t) {
2718
2706
  let i = e.indexOf("\n", r);
2719
2707
  return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
2720
2708
  }
2721
- function zr(e, t) {
2709
+ function Vr(e, t) {
2722
2710
  let n = ` ${t.export} = ${t.init};`, r = e.match(/export const setupContext\s*=\s*async\s*\([^)]*\)\s*=>\s*\{/);
2723
2711
  if (!r) return e;
2724
2712
  let i = e.indexOf("{", e.indexOf(r[0]));
2725
2713
  if (i === -1) return e;
2726
- let a = Br(e, i);
2714
+ let a = Hr(e, i);
2727
2715
  return a === -1 ? e : e.slice(0, a) + n + "\n" + e.slice(a);
2728
2716
  }
2729
- function Br(e, t) {
2717
+ function Hr(e, t) {
2730
2718
  let n = 0;
2731
2719
  for (let r = t; r < e.length; r++) {
2732
2720
  let t = e[r];
@@ -2735,20 +2723,20 @@ function Br(e, t) {
2735
2723
  }
2736
2724
  return -1;
2737
2725
  }
2738
- function Vr(e, t) {
2726
+ function Ur(e, t) {
2739
2727
  let n = ` ${t.export}: ${t.type};`, r = e.indexOf("export type ContextVariables = {");
2740
2728
  if (r === -1) return e;
2741
2729
  let i = e.indexOf("};", r);
2742
2730
  return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
2743
2731
  }
2744
- async function Hr(e, t, n) {
2745
- let r = w.resolve(n, X("{{enums.src}}", t), "index.ts");
2746
- if (!await Y(r)) return;
2747
- let i = await v.readFile(r, "utf-8");
2748
- for (let t of e) i.includes(`from "${t.from}"`) || (i = Ur(i, t));
2749
- await v.writeFile(r, i, "utf-8");
2732
+ async function Wr(e, t, n) {
2733
+ let r = T.resolve(n, Y("{{enums.src}}", t), "index.ts");
2734
+ if (!await J(r)) return;
2735
+ let i = await y.readFile(r, "utf-8");
2736
+ for (let t of e) i.includes(`from "${t.from}"`) || (i = Gr(i, t));
2737
+ await y.writeFile(r, i, "utf-8");
2750
2738
  }
2751
- function Ur(e, t) {
2739
+ function Gr(e, t) {
2752
2740
  let n = `export * from "${t.from}";`, r = e.lastIndexOf("export * from");
2753
2741
  if (r !== -1) {
2754
2742
  let t = e.indexOf("\n", r);
@@ -2756,14 +2744,14 @@ function Ur(e, t) {
2756
2744
  }
2757
2745
  return e.trim() === "" ? n + "\n" : e.trimEnd() + "\n" + n + "\n";
2758
2746
  }
2759
- async function Wr(e, t, n) {
2760
- let r = X("{{backend.root}}", t), i = w.resolve(n, r, "src/sockets/index.ts");
2761
- if (!await Y(i)) return;
2762
- let a = await v.readFile(i, "utf-8");
2763
- for (let t of e) a.includes(`from "${t.from}"`) || (a = Gr(a, t), a = Kr(a, t));
2764
- await Y(w.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a = qr(a)), await v.writeFile(i, a, "utf-8");
2747
+ async function Kr(e, t, n) {
2748
+ let r = Y("{{backend.root}}", t), i = T.resolve(n, r, "src/sockets/index.ts");
2749
+ if (!await J(i)) return;
2750
+ let a = await y.readFile(i, "utf-8");
2751
+ for (let t of e) a.includes(`from "${t.from}"`) || (a = qr(a, t), a = Jr(a, t));
2752
+ await J(T.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a = Yr(a)), await y.writeFile(i, a, "utf-8");
2765
2753
  }
2766
- function Gr(e, t) {
2754
+ function qr(e, t) {
2767
2755
  let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
2768
2756
  if (r !== -1) {
2769
2757
  let t = e.indexOf("\n", r);
@@ -2772,7 +2760,7 @@ function Gr(e, t) {
2772
2760
  let i = e.indexOf("const sockets");
2773
2761
  return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
2774
2762
  }
2775
- function Kr(e, t) {
2763
+ function Jr(e, t) {
2776
2764
  let n = `.socket("${t.prefix}", ${t.import})`, r = e.indexOf("const sockets");
2777
2765
  if (r === -1) return e;
2778
2766
  let i = e.indexOf("new SocketRouter", r);
@@ -2786,7 +2774,7 @@ function Kr(e, t) {
2786
2774
  }
2787
2775
  return e;
2788
2776
  }
2789
- function qr(e) {
2777
+ function Yr(e) {
2790
2778
  if (e.includes("wsAuthenticate")) return e;
2791
2779
  let t = e.indexOf("from \"@backend/libs/websocket/socket-router\""), n = e;
2792
2780
  if (t !== -1) {
@@ -2795,14 +2783,14 @@ function qr(e) {
2795
2783
  }
2796
2784
  return n.replace("new SocketRouter()", "new SocketRouter({ authenticate: wsAuthenticate })");
2797
2785
  }
2798
- async function Jr(e, t, n) {
2799
- let r = X("{{frontend.root}}", t), i = w.resolve(n, r, "src/api/sdk.ts");
2800
- if (!await Y(i)) return;
2801
- let a = await v.readFile(i, "utf-8");
2802
- for (let t of e) a.includes(`.$configure(${t.import})`) || (a = Yr(a, t), a = Xr(a, t));
2803
- await v.writeFile(i, a, "utf-8");
2786
+ async function Xr(e, t, n) {
2787
+ let r = Y("{{frontend.root}}", t), i = T.resolve(n, r, "src/api/sdk.ts");
2788
+ if (!await J(i)) return;
2789
+ let a = await y.readFile(i, "utf-8");
2790
+ for (let t of e) a.includes(`.$configure(${t.import})`) || (a = Zr(a, t), a = Qr(a, t));
2791
+ await y.writeFile(i, a, "utf-8");
2804
2792
  }
2805
- function Yr(e, t) {
2793
+ function Zr(e, t) {
2806
2794
  let n = `import { ${t.import} } from "${t.from}";`;
2807
2795
  if (e.includes(n)) return e;
2808
2796
  let r = e.lastIndexOf("from \"./");
@@ -2813,20 +2801,20 @@ function Yr(e, t) {
2813
2801
  let i = e.indexOf("export const sdk");
2814
2802
  return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
2815
2803
  }
2816
- function Xr(e, t) {
2804
+ function Qr(e, t) {
2817
2805
  let n = `.$configure(${t.import})`, r = e.indexOf("export const sdk");
2818
2806
  if (r === -1) return e;
2819
2807
  let i = e.indexOf(";", r);
2820
2808
  return i === -1 ? e : e.slice(0, i) + "\n " + n + e.slice(i);
2821
2809
  }
2822
- async function Zr(e, t, n) {
2823
- let r = w.resolve(n, X("{{backend.utils}}", t), "frontend-url/frontend-url.ts");
2824
- if (!await Y(r)) return;
2825
- let i = await v.readFile(r, "utf-8");
2826
- for (let t of e) i.includes(`"${t.path}"`) || (i = Qr(i, t));
2827
- await v.writeFile(r, i, "utf-8");
2810
+ async function $r(e, t, n) {
2811
+ let r = T.resolve(n, Y("{{backend.utils}}", t), "frontend-url/frontend-url.ts");
2812
+ if (!await J(r)) return;
2813
+ let i = await y.readFile(r, "utf-8");
2814
+ for (let t of e) i.includes(`"${t.path}"`) || (i = ei(i, t));
2815
+ await y.writeFile(r, i, "utf-8");
2828
2816
  }
2829
- function Qr(e, t) {
2817
+ function ei(e, t) {
2830
2818
  let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
2831
2819
  if (r === -1) return e;
2832
2820
  let i = e.indexOf("{", r);
@@ -2842,38 +2830,38 @@ function Qr(e, t) {
2842
2830
  }
2843
2831
  return o === -1 ? e : e.slice(0, o) + n + "\n" + e.slice(o);
2844
2832
  }
2845
- var $r = "import { type LucideIcon } from \"lucide-react\";\n\n/* -------------------------------------------------------------------------------------------------\n * Types\n * -----------------------------------------------------------------------------------------------*/\n\nexport type NavItem = {\n label: string;\n icon: LucideIcon;\n to: string;\n params?: Record<string, string>;\n};\n\nexport type NavSection = {\n label: string;\n icon: LucideIcon;\n items: NavItem[];\n};\n\nexport type NavSectionLink = NavSection & { to: string; params?: Record<string, string> };\n\nexport type NavEntry = NavSection | NavSectionLink;\n\n/* -------------------------------------------------------------------------------------------------\n * Navigation\n * -----------------------------------------------------------------------------------------------*/\n\nexport const primaryNav: NavEntry[] = [];\n\nexport const secondaryNav: NavEntry[] = [];\n\nexport const tertiaryNav: NavEntry[] = [];\n\nexport const settingsNav: NavEntry[] = [];\n", ei = {
2833
+ var ti = "import { type LucideIcon } from \"lucide-react\";\n\n/* -------------------------------------------------------------------------------------------------\n * Types\n * -----------------------------------------------------------------------------------------------*/\n\nexport type NavItem = {\n label: string;\n icon: LucideIcon;\n to: string;\n params?: Record<string, string>;\n};\n\nexport type NavSection = {\n label: string;\n icon: LucideIcon;\n items: NavItem[];\n};\n\nexport type NavSectionLink = NavSection & { to: string; params?: Record<string, string> };\n\nexport type NavEntry = NavSection | NavSectionLink;\n\n/* -------------------------------------------------------------------------------------------------\n * Navigation\n * -----------------------------------------------------------------------------------------------*/\n\nexport const primaryNav: NavEntry[] = [];\n\nexport const secondaryNav: NavEntry[] = [];\n\nexport const tertiaryNav: NavEntry[] = [];\n\nexport const settingsNav: NavEntry[] = [];\n", ni = {
2846
2834
  primary: "primaryNav",
2847
2835
  secondary: "secondaryNav",
2848
2836
  tertiary: "tertiaryNav",
2849
2837
  settings: "settingsNav"
2850
2838
  };
2851
- async function ti(e) {
2852
- let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Dr(i, n), o = w.resolve(r, a, "src/constants/nav.constants.ts"), s;
2853
- await Y(o) ? s = await v.readFile(o, "utf-8") : (await v.mkdir(w.dirname(o), { recursive: !0 }), s = $r);
2854
- for (let e of t) s.includes(`label: "${e.label}"`) || (s = ii(s, e));
2855
- for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s = oi(s, e));
2856
- await v.writeFile(o, s, "utf-8");
2857
- }
2858
- async function ni(e) {
2859
- let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Dr(i, n), o = w.resolve(r, a, "src/features/auth/constants/auth.constants.ts");
2860
- if (!await Y(o)) return;
2861
- let s = await v.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
2839
+ async function ri(e) {
2840
+ let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = kr(i, n), o = T.resolve(r, a, "src/constants/nav.constants.ts"), s;
2841
+ await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = ti);
2842
+ for (let e of t) s.includes(`label: "${e.label}"`) || (s = oi(s, e));
2843
+ for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s = ci(s, e));
2844
+ await y.writeFile(o, s, "utf-8");
2845
+ }
2846
+ async function ii(e) {
2847
+ let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = kr(i, n), o = T.resolve(r, a, "src/features/auth/constants/auth.constants.ts");
2848
+ if (!await J(o)) return;
2849
+ let s = await y.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
2862
2850
  if (!c.test(s)) return;
2863
2851
  let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
2864
- await v.writeFile(o, l, "utf-8");
2852
+ await y.writeFile(o, l, "utf-8");
2865
2853
  }
2866
- function ri(e) {
2854
+ function ai(e) {
2867
2855
  let t = [e.icon];
2868
2856
  if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
2869
2857
  return t;
2870
2858
  }
2871
- function ii(e, t) {
2872
- let n = ri(t), r = e;
2873
- for (let e of n) r = ai(r, e);
2859
+ function oi(e, t) {
2860
+ let n = ai(t), r = e;
2861
+ for (let e of n) r = si(r, e);
2874
2862
  return r;
2875
2863
  }
2876
- function ai(e, t) {
2864
+ function si(e, t) {
2877
2865
  let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
2878
2866
  if (!n) return e;
2879
2867
  let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
@@ -2881,21 +2869,21 @@ function ai(e, t) {
2881
2869
  let i = r.findIndex((e) => e.startsWith("type "));
2882
2870
  return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
2883
2871
  }
2884
- function oi(e, t) {
2885
- let n = ei[t.group];
2872
+ function ci(e, t) {
2873
+ let n = ni[t.group];
2886
2874
  if (!n) return e;
2887
- let r = ci(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
2875
+ let r = ui(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
2888
2876
  if (!a) return e;
2889
- let o = e.indexOf(a[0]) + a[0].length, s = si(e, o - 1);
2877
+ let o = e.indexOf(a[0]) + a[0].length, s = li(e, o - 1);
2890
2878
  return s === -1 ? e : e.slice(o, s).trim() === "" ? e.slice(0, o) + "\n" + r + "\n" + e.slice(o) : e.slice(0, o) + "\n" + r + e.slice(o);
2891
2879
  }
2892
- function si(e, t) {
2880
+ function li(e, t) {
2893
2881
  let n = 0;
2894
2882
  for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
2895
2883
  else if (e[r] === "]" && (n--, n === 0)) return r;
2896
2884
  return -1;
2897
2885
  }
2898
- function ci(e) {
2886
+ function ui(e) {
2899
2887
  let t = [];
2900
2888
  if (t.push(" {"), t.push(` label: "${e.label}",`), t.push(` icon: ${e.icon},`), e.to && t.push(` to: "${e.to}",`), e.params && t.push(` params: ${e.params},`), e.items && e.items.length > 0) {
2901
2889
  t.push(" items: [");
@@ -2911,14 +2899,14 @@ function ci(e) {
2911
2899
  } else t.push(" items: [],");
2912
2900
  return t.push(" },"), t.join("\n");
2913
2901
  }
2914
- async function li(e, t, n) {
2915
- let r = X("{{backend.features}}", t), i = w.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
2916
- if (!await Y(i)) return;
2917
- let a = await v.readFile(i, "utf-8");
2918
- for (let t of e) a.includes(`from "${t.from}"`) || (a = ui(a, t), a = di(a, t));
2919
- await v.writeFile(i, a, "utf-8");
2902
+ async function di(e, t, n) {
2903
+ let r = Y("{{backend.features}}", t), i = T.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
2904
+ if (!await J(i)) return;
2905
+ let a = await y.readFile(i, "utf-8");
2906
+ for (let t of e) a.includes(`from "${t.from}"`) || (a = fi(a, t), a = pi(a, t));
2907
+ await y.writeFile(i, a, "utf-8");
2920
2908
  }
2921
- function ui(e, t) {
2909
+ function fi(e, t) {
2922
2910
  let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
2923
2911
  if (r !== -1) {
2924
2912
  let t = e.indexOf("\n", e.indexOf(";", r));
@@ -2926,38 +2914,38 @@ function ui(e, t) {
2926
2914
  }
2927
2915
  return e.indexOf("type "), n + "\n\n" + e;
2928
2916
  }
2929
- function di(e, t) {
2917
+ function pi(e, t) {
2930
2918
  let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
2931
2919
  if (!r) return e;
2932
- let i = e.indexOf(r[0]) + r[0].length, a = fi(e, i - 1);
2920
+ let i = e.indexOf(r[0]) + r[0].length, a = mi(e, i - 1);
2933
2921
  return a === -1 ? e : e.slice(i, a).trim() === "" ? e.slice(0, a) + "\n" + n + "\n" + e.slice(a) : e.slice(0, a) + n + "\n" + e.slice(a);
2934
2922
  }
2935
- function fi(e, t) {
2923
+ function mi(e, t) {
2936
2924
  let n = 0;
2937
2925
  for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
2938
2926
  else if (e[r] === "]" && (n--, n === 0)) return r;
2939
2927
  return -1;
2940
2928
  }
2941
- var pi = "import { type ComponentType } from \"react\";\n\nexport type NavbarAction = {\n id: string;\n component: ComponentType;\n};\n\nexport const navbarActions: NavbarAction[] = [];\n\nexport const userMenuActions: NavbarAction[] = [];\n";
2942
- async function mi(e) {
2943
- await gi({
2929
+ var hi = "import { type ComponentType } from \"react\";\n\nexport type NavbarAction = {\n id: string;\n component: ComponentType;\n};\n\nexport const navbarActions: NavbarAction[] = [];\n\nexport const userMenuActions: NavbarAction[] = [];\n";
2930
+ async function gi(e) {
2931
+ await vi({
2944
2932
  ...e,
2945
2933
  arrayName: "navbarActions"
2946
2934
  });
2947
2935
  }
2948
- async function hi(e) {
2949
- await gi({
2936
+ async function _i(e) {
2937
+ await vi({
2950
2938
  ...e,
2951
2939
  arrayName: "userMenuActions"
2952
2940
  });
2953
2941
  }
2954
- async function gi({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
2955
- let a = Dr(i, n), o = w.resolve(r, a, "src/constants/navbar-actions.tsx"), s;
2956
- await Y(o) ? s = await v.readFile(o, "utf-8") : (await v.mkdir(w.dirname(o), { recursive: !0 }), s = pi);
2957
- for (let n of e) s = _i(s, n), s = vi(s, n, t);
2958
- await v.writeFile(o, s, "utf-8");
2942
+ async function vi({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
2943
+ let a = kr(i, n), o = T.resolve(r, a, "src/constants/navbar-actions.tsx"), s;
2944
+ await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = hi);
2945
+ for (let n of e) s = yi(s, n), s = bi(s, n, t);
2946
+ await y.writeFile(o, s, "utf-8");
2959
2947
  }
2960
- function _i(e, t) {
2948
+ function yi(e, t) {
2961
2949
  let n = `import { ${t.import} } from "${t.from}";`;
2962
2950
  if (e.includes(n)) return e;
2963
2951
  let r = e.lastIndexOf("import ");
@@ -2965,38 +2953,38 @@ function _i(e, t) {
2965
2953
  let i = e.indexOf("\n", r);
2966
2954
  return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
2967
2955
  }
2968
- function vi(e, t, n) {
2956
+ function bi(e, t, n) {
2969
2957
  let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
2970
2958
  if (!r) return e;
2971
- let i = e.indexOf(r[0]) + r[0].length, a = yi(e, i - 1);
2959
+ let i = e.indexOf(r[0]) + r[0].length, a = xi(e, i - 1);
2972
2960
  if (a === -1) return e;
2973
2961
  let o = e.slice(i, a);
2974
2962
  if (o.includes(`id: "${t.id}"`)) return e;
2975
2963
  let s = ` { id: "${t.id}", component: ${t.import} },`;
2976
2964
  return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
2977
2965
  }
2978
- function yi(e, t) {
2966
+ function xi(e, t) {
2979
2967
  let n = 0;
2980
2968
  for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
2981
2969
  else if (e[r] === "]" && (n--, n === 0)) return r;
2982
2970
  return -1;
2983
2971
  }
2984
- var bi = new Set([
2972
+ var Si = new Set([
2985
2973
  ".ts",
2986
2974
  ".tsx",
2987
2975
  ".js",
2988
2976
  ".jsx"
2989
2977
  ]);
2990
- async function xi(e) {
2978
+ async function Ci(e) {
2991
2979
  let { files: t, paths: n, projectRoot: r, projectName: i } = e;
2992
2980
  if (i === "hype-stack") return;
2993
2981
  let a = `@${i}/`;
2994
2982
  await Promise.all(t.map(async (e) => {
2995
- let t = xr(e.target, n, r), i = await v.stat(t).catch(() => null);
2996
- i?.isDirectory() ? await wi(t, a) : i?.isFile() && bi.has(w.extname(t)) && await Ti(t, a);
2983
+ let t = Cr(e.target, n, r), i = await y.stat(t).catch(() => null);
2984
+ i?.isDirectory() ? await Ei(t, a) : i?.isFile() && Si.has(T.extname(t)) && await Di(t, a);
2997
2985
  }));
2998
2986
  }
2999
- var Si = new Set([
2987
+ var wi = new Set([
3000
2988
  ".git",
3001
2989
  "node_modules",
3002
2990
  "dist",
@@ -3005,62 +2993,62 @@ var Si = new Set([
3005
2993
  ".next",
3006
2994
  "coverage"
3007
2995
  ]);
3008
- async function Ci(e, t) {
3009
- t !== "hype-stack" && await wi(e, `@${t}/`);
2996
+ async function Ti(e, t) {
2997
+ t !== "hype-stack" && await Ei(e, `@${t}/`);
3010
2998
  }
3011
- async function wi(e, t) {
3012
- let n = await v.readdir(e, { withFileTypes: !0 });
2999
+ async function Ei(e, t) {
3000
+ let n = await y.readdir(e, { withFileTypes: !0 });
3013
3001
  await Promise.all(n.map(async (n) => {
3014
- let r = w.join(e, n.name);
3002
+ let r = T.join(e, n.name);
3015
3003
  if (n.isDirectory()) {
3016
- if (Si.has(n.name)) return;
3017
- await wi(r, t);
3018
- } else n.isFile() && bi.has(w.extname(n.name)) && await Ti(r, t);
3004
+ if (wi.has(n.name)) return;
3005
+ await Ei(r, t);
3006
+ } else n.isFile() && Si.has(T.extname(n.name)) && await Di(r, t);
3019
3007
  }));
3020
3008
  }
3021
- async function Ti(e, t) {
3022
- let n = await v.readFile(e, "utf-8");
3023
- if (!n.includes(Er)) return;
3024
- let r = n.replaceAll(Er, t);
3025
- await v.writeFile(e, r, "utf-8");
3009
+ async function Di(e, t) {
3010
+ let n = await y.readFile(e, "utf-8");
3011
+ if (!n.includes(Or)) return;
3012
+ let r = n.replaceAll(Or, t);
3013
+ await y.writeFile(e, r, "utf-8");
3026
3014
  }
3027
3015
  //#endregion
3028
3016
  //#region src/core/installer.ts
3029
- function Ei(e, t) {
3017
+ function Oi(e, t) {
3030
3018
  return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
3031
3019
  }
3032
- async function Di(e, t) {
3033
- if ((await v.stat(e)).isDirectory()) {
3034
- await v.mkdir(t, { recursive: !0 });
3035
- let n = await v.readdir(e, { withFileTypes: !0 });
3036
- for (let r of n) await Di(w.join(e, r.name), w.join(t, r.name));
3037
- } else await v.mkdir(w.dirname(t), { recursive: !0 }), await v.copyFile(e, t);
3020
+ async function ki(e, t) {
3021
+ if ((await y.stat(e)).isDirectory()) {
3022
+ await y.mkdir(t, { recursive: !0 });
3023
+ let n = await y.readdir(e, { withFileTypes: !0 });
3024
+ for (let r of n) await ki(T.join(e, r.name), T.join(t, r.name));
3025
+ } else await y.mkdir(T.dirname(t), { recursive: !0 }), await y.copyFile(e, t);
3038
3026
  }
3039
- async function Oi(e) {
3027
+ async function Ai(e) {
3040
3028
  let { src: t, dest: n, projectRoot: r, skip: i } = e;
3041
- if ((await v.stat(t)).isDirectory()) {
3042
- await v.mkdir(n, { recursive: !0 });
3043
- let e = await v.readdir(t, { withFileTypes: !0 });
3044
- return (await Promise.all(e.map((e) => Oi({
3045
- src: w.join(t, e.name),
3046
- dest: w.join(n, e.name),
3029
+ if ((await y.stat(t)).isDirectory()) {
3030
+ await y.mkdir(n, { recursive: !0 });
3031
+ let e = await y.readdir(t, { withFileTypes: !0 });
3032
+ return (await Promise.all(e.map((e) => Ai({
3033
+ src: T.join(t, e.name),
3034
+ dest: T.join(n, e.name),
3047
3035
  projectRoot: r,
3048
3036
  skip: i
3049
3037
  })))).flat();
3050
3038
  }
3051
- return i.has(t) ? [] : (await v.mkdir(w.dirname(n), { recursive: !0 }), await v.copyFile(t, n), [w.relative(r, n)]);
3039
+ return i.has(t) ? [] : (await y.mkdir(T.dirname(n), { recursive: !0 }), await y.copyFile(t, n), [T.relative(r, n)]);
3052
3040
  }
3053
- async function ki(e) {
3054
- let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = Sr(t.source, n), o = xr(t.target, r, i);
3041
+ async function ji(e) {
3042
+ let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = wr(t.source, n), o = Cr(t.target, r, i);
3055
3043
  return {
3056
3044
  sourcePath: a,
3057
3045
  targetPath: o,
3058
- sourceExists: await Y(a) || await J(a),
3059
- targetExists: await Y(o) || await J(o)
3046
+ sourceExists: await J(a) || await ir(a),
3047
+ targetExists: await J(o) || await ir(o)
3060
3048
  };
3061
3049
  }
3062
- async function Ai(e) {
3063
- let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await ki({
3050
+ async function Mi(e) {
3051
+ let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await ji({
3064
3052
  file: t,
3065
3053
  packDir: n,
3066
3054
  paths: r,
@@ -3071,12 +3059,12 @@ async function Ai(e) {
3071
3059
  case "create":
3072
3060
  case "skip-if-exists":
3073
3061
  case "override": return null;
3074
- case "merge": return !c || !t.marker || (await v.readFile(o, "utf-8")).includes(t.marker) ? null : `${t.target}: Marker "${t.marker}" not found`;
3062
+ case "merge": return !c || !t.marker || (await y.readFile(o, "utf-8")).includes(t.marker) ? null : `${t.target}: Marker "${t.marker}" not found`;
3075
3063
  default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
3076
3064
  }
3077
3065
  }
3078
- async function ji(e) {
3079
- let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await ki({
3066
+ async function Ni(e) {
3067
+ let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await ji({
3080
3068
  file: t,
3081
3069
  packDir: n,
3082
3070
  paths: r,
@@ -3094,7 +3082,7 @@ async function ji(e) {
3094
3082
  status: "skipped",
3095
3083
  path: t.target,
3096
3084
  reason: "Already exists"
3097
- } : (await Di(s, c), {
3085
+ } : (await ki(s, c), {
3098
3086
  status: "installed",
3099
3087
  path: t.target
3100
3088
  });
@@ -3103,20 +3091,20 @@ async function ji(e) {
3103
3091
  status: "skipped",
3104
3092
  path: t.target,
3105
3093
  reason: "Already exists (skip-if-exists)"
3106
- } : (await Di(s, c), {
3094
+ } : (await ki(s, c), {
3107
3095
  status: "installed",
3108
3096
  path: t.target
3109
3097
  });
3110
- case "override": return await Di(s, c), {
3098
+ case "override": return await ki(s, c), {
3111
3099
  status: "installed",
3112
3100
  path: t.target
3113
3101
  };
3114
3102
  case "merge": {
3115
- if (!u) return await Di(s, c), {
3103
+ if (!u) return await ki(s, c), {
3116
3104
  status: "installed",
3117
3105
  path: t.target
3118
3106
  };
3119
- let e = await v.readFile(s, "utf-8"), n = await v.readFile(c, "utf-8");
3107
+ let e = await y.readFile(s, "utf-8"), n = await y.readFile(c, "utf-8");
3120
3108
  if (t.marker) {
3121
3109
  let r = n.indexOf(t.marker);
3122
3110
  if (r === -1) return {
@@ -3125,10 +3113,10 @@ async function ji(e) {
3125
3113
  reason: `Marker "${t.marker}" not found`
3126
3114
  };
3127
3115
  let i = n.slice(0, r) + e + n.slice(r);
3128
- await v.writeFile(c, i);
3116
+ await y.writeFile(c, i);
3129
3117
  } else {
3130
3118
  let t = n + "\n" + e;
3131
- await v.writeFile(c, t);
3119
+ await y.writeFile(c, t);
3132
3120
  }
3133
3121
  return {
3134
3122
  status: "installed",
@@ -3142,15 +3130,15 @@ async function ji(e) {
3142
3130
  };
3143
3131
  }
3144
3132
  }
3145
- async function Mi(e) {
3133
+ async function Pi(e) {
3146
3134
  let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
3147
3135
  if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
3148
3136
  let o = [], s = /* @__PURE__ */ new Set();
3149
3137
  for (let e of t) {
3150
3138
  let t = i?.get(e.manifest.name);
3151
3139
  for (let n of e.manifest.files) {
3152
- if (n.strategy !== "create" || !Ei(n, t)) continue;
3153
- let { targetPath: i, targetExists: c } = await ki({
3140
+ if (n.strategy !== "create" || !Oi(n, t)) continue;
3141
+ let { targetPath: i, targetExists: c } = await ji({
3154
3142
  file: n,
3155
3143
  packDir: e.packDir,
3156
3144
  paths: a,
@@ -3165,13 +3153,13 @@ async function Mi(e) {
3165
3153
  }
3166
3154
  return o;
3167
3155
  }
3168
- async function Ni(e) {
3156
+ async function Fi(e) {
3169
3157
  let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
3170
3158
  if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
3171
3159
  let c = [];
3172
3160
  for (let e of t.files) {
3173
- if (!Ei(e, o)) continue;
3174
- let t = await Ai({
3161
+ if (!Oi(e, o)) continue;
3162
+ let t = await Mi({
3175
3163
  file: e,
3176
3164
  packDir: a,
3177
3165
  paths: s,
@@ -3182,16 +3170,16 @@ async function Ni(e) {
3182
3170
  }
3183
3171
  return c;
3184
3172
  }
3185
- async function Pi(e) {
3173
+ async function Ii(e) {
3186
3174
  let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
3187
3175
  if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
3188
3176
  let l = {
3189
3177
  installed: [],
3190
3178
  skipped: [],
3191
3179
  errors: []
3192
- }, u = t.files.filter((e) => Ei(e, s));
3180
+ }, u = t.files.filter((e) => Oi(e, s));
3193
3181
  for (let e of u) {
3194
- let t = await ji({
3182
+ let t = await Ni({
3195
3183
  file: e,
3196
3184
  packDir: o,
3197
3185
  paths: c,
@@ -3211,40 +3199,40 @@ async function Pi(e) {
3211
3199
  break;
3212
3200
  }
3213
3201
  }
3214
- await xi({
3202
+ await Ci({
3215
3203
  files: u,
3216
3204
  paths: c,
3217
3205
  projectRoot: r,
3218
3206
  projectName: n.name
3219
- }), t.env && t.env.length > 0 && await Or(t.env, c, r), t.routes && t.routes.length > 0 && await Nr(t.routes, c, r), t.context && t.context.length > 0 && await Ir(t.context, c, r), t.sockets && t.sockets.length > 0 && await Wr(t.sockets, c, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await Jr(t.sdkConfigurations, c, r), t.enums && t.enums.length > 0 && await Hr(t.enums, c, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await Zr(t.frontendRoutes, c, r);
3207
+ }), t.env && t.env.length > 0 && await Ar(t.env, c, r), t.routes && t.routes.length > 0 && await Fr(t.routes, c, r), t.context && t.context.length > 0 && await Rr(t.context, c, r), t.sockets && t.sockets.length > 0 && await Kr(t.sockets, c, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await Xr(t.sdkConfigurations, c, r), t.enums && t.enums.length > 0 && await Wr(t.enums, c, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await $r(t.frontendRoutes, c, r);
3220
3208
  let d = s && s.length > 0 ? s : ["frontend"];
3221
- for (let e of d) t.nav && t.nav.length > 0 && await ti({
3209
+ for (let e of d) t.nav && t.nav.length > 0 && await ri({
3222
3210
  entries: t.nav,
3223
3211
  paths: c,
3224
3212
  projectRoot: r,
3225
3213
  slot: e
3226
- }), t.navbarActions && t.navbarActions.length > 0 && await mi({
3214
+ }), t.navbarActions && t.navbarActions.length > 0 && await gi({
3227
3215
  actions: t.navbarActions,
3228
3216
  paths: c,
3229
3217
  projectRoot: r,
3230
3218
  slot: e
3231
- }), t.userMenuActions && t.userMenuActions.length > 0 && await hi({
3219
+ }), t.userMenuActions && t.userMenuActions.length > 0 && await _i({
3232
3220
  actions: t.userMenuActions,
3233
3221
  paths: c,
3234
3222
  projectRoot: r,
3235
3223
  slot: e
3236
3224
  });
3237
- return t.onboardingSteps && t.onboardingSteps.length > 0 && await li(t.onboardingSteps, c, r), t.postLoginRedirect && await ni({
3225
+ return t.onboardingSteps && t.onboardingSteps.length > 0 && await di(t.onboardingSteps, c, r), t.postLoginRedirect && await ii({
3238
3226
  postLoginRedirect: t.postLoginRedirect,
3239
3227
  paths: c,
3240
3228
  projectRoot: r,
3241
3229
  slot: d[0]
3242
3230
  }), l;
3243
3231
  }
3244
- async function Fi(e) {
3232
+ async function Li(e) {
3245
3233
  let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
3246
3234
  for (let e of t) {
3247
- let t = o?.get(e.manifest.name), a = await Ni({
3235
+ let t = o?.get(e.manifest.name), a = await Fi({
3248
3236
  manifest: e.manifest,
3249
3237
  config: n,
3250
3238
  projectRoot: r,
@@ -3264,7 +3252,7 @@ async function Fi(e) {
3264
3252
  };
3265
3253
  let c = [], l = [], u = [], d = [], f = n;
3266
3254
  for (let e of t) {
3267
- let t = o?.get(e.manifest.name), n = await Pi({
3255
+ let t = o?.get(e.manifest.name), n = await Ii({
3268
3256
  manifest: e.manifest,
3269
3257
  config: f,
3270
3258
  projectRoot: r,
@@ -3273,7 +3261,7 @@ async function Fi(e) {
3273
3261
  packDir: e.packDir,
3274
3262
  slots: t
3275
3263
  });
3276
- c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await Ii(f, e.manifest.name, r), d.push(e.manifest.name);
3264
+ c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await Ri(f, e.manifest.name, r), d.push(e.manifest.name);
3277
3265
  }
3278
3266
  return {
3279
3267
  installed: c,
@@ -3284,26 +3272,26 @@ async function Fi(e) {
3284
3272
  config: f
3285
3273
  };
3286
3274
  }
3287
- async function Ii(e, t, n) {
3275
+ async function Ri(e, t, n) {
3288
3276
  let r = {
3289
3277
  ...e,
3290
3278
  installedPacks: [...e.installedPacks ?? [], t]
3291
3279
  };
3292
- return await mr(n, r), r;
3280
+ return await gr(n, r), r;
3293
3281
  }
3294
- async function Li(e) {
3282
+ async function zi(e) {
3295
3283
  let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
3296
3284
  if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
3297
- let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) => Sr(e.source, i))), u = w.join(i, "files");
3298
- if (await J(u)) {
3299
- let e = await v.readdir(u, { withFileTypes: !0 });
3285
+ let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) => wr(e.source, i))), u = T.join(i, "files");
3286
+ if (await ir(u)) {
3287
+ let e = await y.readdir(u, { withFileTypes: !0 });
3300
3288
  for (let t of e) {
3301
3289
  if (!t.isDirectory()) continue;
3302
3290
  let e = a[t.name]?.root;
3303
3291
  if (!e) continue;
3304
- let n = await Oi({
3305
- src: w.join(u, t.name),
3306
- dest: w.resolve(r, e),
3292
+ let n = await Ai({
3293
+ src: T.join(u, t.name),
3294
+ dest: T.resolve(r, e),
3307
3295
  projectRoot: r,
3308
3296
  skip: l
3309
3297
  });
@@ -3311,7 +3299,7 @@ async function Li(e) {
3311
3299
  }
3312
3300
  }
3313
3301
  for (let e of c) {
3314
- let t = await ji({
3302
+ let t = await Ni({
3315
3303
  file: e,
3316
3304
  packDir: i,
3317
3305
  paths: a,
@@ -3321,12 +3309,12 @@ async function Li(e) {
3321
3309
  });
3322
3310
  t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
3323
3311
  }
3324
- let d = w.join(xr("{{frontend.root}}", a, r), "src", "routes"), f = w.join(d, "(public)", "index.tsx"), p = w.join(d, "(private)", "index.tsx");
3325
- return await Y(f) && await Y(p) && await v.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await Zr(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await ti({
3312
+ let d = T.join(Cr("{{frontend.root}}", a, r), "src", "routes"), f = T.join(d, "(public)", "index.tsx"), p = T.join(d, "(private)", "index.tsx");
3313
+ return await J(f) && await J(p) && await y.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await $r(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await ri({
3326
3314
  entries: t.nav,
3327
3315
  paths: a,
3328
3316
  projectRoot: r
3329
- }), t.postLoginRedirect && await ni({
3317
+ }), t.postLoginRedirect && await ii({
3330
3318
  postLoginRedirect: t.postLoginRedirect,
3331
3319
  paths: a,
3332
3320
  projectRoot: r
@@ -3337,28 +3325,28 @@ async function Li(e) {
3337
3325
  }
3338
3326
  //#endregion
3339
3327
  //#region src/core/pack-categories.ts
3340
- var Ri = [
3328
+ var Bi = [
3341
3329
  "starter",
3342
3330
  "layout",
3343
3331
  "feature"
3344
- ], zi = {
3332
+ ], Vi = {
3345
3333
  starter: "Starter",
3346
3334
  layout: "Layout",
3347
3335
  feature: "Features"
3348
- }, Bi = new Set(["starter", "layout"]), Vi = "layout-basic";
3349
- function Hi(e, t = {}) {
3336
+ }, Hi = new Set(["starter", "layout"]), Ui = "layout-basic";
3337
+ function Wi(e, t = {}) {
3350
3338
  let n = [];
3351
- for (let r of Ri) {
3339
+ for (let r of Bi) {
3352
3340
  let i = e.filter((e) => e.category === r);
3353
3341
  if (i.length === 0) continue;
3354
- let a = Bi.has(r) ? "single" : "multiple";
3342
+ let a = Hi.has(r) ? "single" : "multiple";
3355
3343
  if (r === "layout") {
3356
- n.push(Ui("frontend", i)), t.adminAvailable && n.push(Ui("admin", i));
3344
+ n.push(Gi("frontend", i)), t.adminAvailable && n.push(Gi("admin", i));
3357
3345
  continue;
3358
3346
  }
3359
3347
  n.push({
3360
3348
  category: r,
3361
- label: zi[r],
3349
+ label: Vi[r],
3362
3350
  mode: a,
3363
3351
  packs: i,
3364
3352
  preselect: null
@@ -3366,53 +3354,53 @@ function Hi(e, t = {}) {
3366
3354
  }
3367
3355
  return n;
3368
3356
  }
3369
- function Ui(e, t) {
3370
- let n = t.some((e) => e.name === Vi);
3357
+ function Gi(e, t) {
3358
+ let n = t.some((e) => e.name === Ui);
3371
3359
  return {
3372
3360
  category: "layout",
3373
3361
  label: e === "admin" ? "Admin Layout" : "Layout",
3374
3362
  mode: "single",
3375
3363
  packs: t,
3376
- preselect: n ? Vi : null,
3364
+ preselect: n ? Ui : null,
3377
3365
  slot: e
3378
3366
  };
3379
3367
  }
3380
3368
  //#endregion
3381
3369
  //#region src/ui/logger.ts
3382
- function Wi(e) {
3383
- o.note(e.map((e) => `${R.arrow} ${e}`).join("\n"), "Next steps");
3370
+ function Ki(e) {
3371
+ s.note(e.map((e) => `${z.arrow} ${e}`).join("\n"), "Next steps");
3384
3372
  }
3385
- function Z() {
3386
- o.cancel(L.muted("Operation cancelled.")), process.exit(0);
3373
+ function X() {
3374
+ s.cancel(R.muted("Operation cancelled.")), process.exit(0);
3387
3375
  }
3388
3376
  //#endregion
3389
3377
  //#region src/core/post-setup.ts
3390
- async function Gi() {
3378
+ async function qi() {
3391
3379
  return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
3392
3380
  }
3393
- async function Ki(e) {
3394
- return Y(`${e}/apps/backend/.env`);
3381
+ async function Ji(e) {
3382
+ return J(`${e}/apps/backend/.env`);
3395
3383
  }
3396
- async function qi(e, t, n) {
3397
- let r = n ? `Start services with ${L.command("docker compose up -d")}?` : `Docker is not running. Start services with ${L.command("docker compose up -d")}?`, i = t ? !0 : await o.confirm({
3384
+ async function Yi(e, t, n) {
3385
+ let r = n ? `Start services with ${R.command("docker compose up -d")}?` : `Docker is not running. Start services with ${R.command("docker compose up -d")}?`, i = t ? !0 : await s.confirm({
3398
3386
  message: r,
3399
3387
  initialValue: !0
3400
3388
  });
3401
- if (o.isCancel(i) && Z(), !i) return o.log.info(L.muted("Skipping Docker services and database migrations.")), !1;
3402
- let a = o.spinner();
3389
+ if (s.isCancel(i) && X(), !i) return s.log.info(R.muted("Skipping Docker services and database migrations.")), !1;
3390
+ let a = s.spinner();
3403
3391
  a.start("Starting Docker services...");
3404
- let s = await q("docker", [
3392
+ let o = await q("docker", [
3405
3393
  "compose",
3406
3394
  "up",
3407
3395
  "-d"
3408
3396
  ], { cwd: `${e}/apps/backend` });
3409
- return s.exitCode === 0 ? (a.stop(L.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), Ji(s), !1);
3397
+ return o.exitCode === 0 ? (a.stop(R.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), Xi(o), !1);
3410
3398
  }
3411
- function Ji(e) {
3399
+ function Xi(e) {
3412
3400
  let t = (e.stderr || e.stdout).trim();
3413
- t && o.log.warn(L.muted(t));
3401
+ t && s.log.warn(R.muted(t));
3414
3402
  }
3415
- async function Yi(e, t = 15, n = 2e3) {
3403
+ async function Zi(e, t = 15, n = 2e3) {
3416
3404
  for (let r = 0; r < t; r++) {
3417
3405
  if ((await q("docker", [
3418
3406
  "compose",
@@ -3427,54 +3415,55 @@ async function Yi(e, t = 15, n = 2e3) {
3427
3415
  }
3428
3416
  return !1;
3429
3417
  }
3430
- async function Xi(e, t, n = {}) {
3431
- if (!await Ki(e)) {
3432
- o.log.warn(`${L.path(".env")} not found in ${L.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
3433
- return;
3434
- }
3435
- if (!await qi(e, t, await Gi())) return;
3436
- let r = o.spinner();
3437
- if (r.start("Waiting for Postgres to be ready..."), !await Yi(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3)) {
3438
- r.error("Postgres health check timed out"), o.log.warn(L.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest"));
3439
- return;
3440
- }
3441
- r.stop(L.success("Postgres is ready"));
3442
- let i = t ? !0 : await o.confirm({
3443
- message: `Run database migrations with ${L.command("prisma migrate deploy")}?`,
3444
- initialValue: !0
3445
- });
3446
- if (o.isCancel(i) && Z(), !i) {
3447
- o.log.info(L.muted("Skipping database migrations."));
3448
- return;
3449
- }
3450
- let a = o.spinner();
3451
- a.start("Running database migrations...");
3452
- let s = await q("pnpm", [
3418
+ var Qi = "Database schema is up to date";
3419
+ async function $i(e) {
3420
+ let t = await q("pnpm", [
3453
3421
  "--filter",
3454
3422
  "@internal/backend",
3455
- "migration:latest"
3423
+ "exec",
3424
+ "prisma",
3425
+ "migrate",
3426
+ "status"
3456
3427
  ], { cwd: e });
3457
- if (s.exitCode !== 0) {
3458
- a.error("Migrations failed"), Ji(s), o.log.warn(L.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations."));
3459
- return;
3460
- }
3461
- a.stop(L.success("Database migrations applied"));
3462
- let c = o.spinner();
3463
- c.start("Generating Prisma client...");
3464
- let l = await q("pnpm", [
3428
+ return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(Qi) : !1;
3429
+ }
3430
+ async function ea(e) {
3431
+ let t = s.spinner();
3432
+ t.start("Running database migrations...");
3433
+ let n = await q("pnpm", [
3465
3434
  "--filter",
3466
3435
  "@internal/backend",
3467
- "generate"
3436
+ "migration:latest"
3468
3437
  ], { cwd: e });
3469
- if (l.exitCode !== 0) {
3470
- c.error("Prisma client generation failed"), Ji(l), o.log.warn(L.muted("Run `pnpm --filter @internal/backend generate` manually."));
3438
+ return n.exitCode === 0 ? (t.stop(R.success("Database migrations applied")), !0) : (t.error("Migrations failed"), Xi(n), s.log.warn(R.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations.")), !1);
3439
+ }
3440
+ async function ta(e, t, n = {}) {
3441
+ if (!await Yi(e, t, await qi())) return !1;
3442
+ let r = s.spinner();
3443
+ return r.start("Waiting for Postgres to be ready..."), await Zi(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3) ? (r.stop(R.success("Postgres is ready")), !0) : (r.error("Postgres health check timed out"), s.log.warn(R.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest")), !1);
3444
+ }
3445
+ async function na(e, t, n = {}) {
3446
+ if (!await ta(e, t, n)) return;
3447
+ let r = t ? !0 : await s.confirm({
3448
+ message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
3449
+ initialValue: !0
3450
+ });
3451
+ if (s.isCancel(r) && X(), !r) {
3452
+ s.log.info(R.muted("Skipping database migrations."));
3471
3453
  return;
3472
3454
  }
3473
- c.stop(L.success("Prisma client generated"));
3455
+ await ea(e);
3456
+ }
3457
+ async function ra(e, t, n = {}) {
3458
+ if (!await Ji(e)) {
3459
+ s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
3460
+ return;
3461
+ }
3462
+ await na(e, t, n);
3474
3463
  }
3475
3464
  //#endregion
3476
3465
  //#region src/core/resolve.ts
3477
- function Zi(e) {
3466
+ function ia(e) {
3478
3467
  let t = /* @__PURE__ */ new Map();
3479
3468
  for (let n of e) t.set(n.name, {
3480
3469
  name: n.name,
@@ -3482,7 +3471,7 @@ function Zi(e) {
3482
3471
  });
3483
3472
  return t;
3484
3473
  }
3485
- function Qi(e, t, n = /* @__PURE__ */ new Set()) {
3474
+ function aa(e, t, n = /* @__PURE__ */ new Set()) {
3486
3475
  let r = /* @__PURE__ */ new Set();
3487
3476
  function i(e) {
3488
3477
  if (n.has(e)) return [];
@@ -3496,10 +3485,10 @@ function Qi(e, t, n = /* @__PURE__ */ new Set()) {
3496
3485
  }
3497
3486
  return i(e);
3498
3487
  }
3499
- function $i(e, t, n = []) {
3488
+ function oa(e, t, n = []) {
3500
3489
  let r = new Set(n), i = new Set(n), a = [];
3501
3490
  for (let n of e) {
3502
- let e = Qi(n, t, new Set(i));
3491
+ let e = aa(n, t, new Set(i));
3503
3492
  for (let t of e) i.has(t) || (i.add(t), a.push(t));
3504
3493
  }
3505
3494
  return {
@@ -3507,7 +3496,7 @@ function $i(e, t, n = []) {
3507
3496
  alreadyInstalled: e.filter((e) => r.has(e))
3508
3497
  };
3509
3498
  }
3510
- function ea(e) {
3499
+ function sa(e) {
3511
3500
  let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
3512
3501
  for (let e of t) {
3513
3502
  let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
@@ -3520,7 +3509,7 @@ function ea(e) {
3520
3509
  }
3521
3510
  //#endregion
3522
3511
  //#region src/core/variants.ts
3523
- function ta(e, t = {}) {
3512
+ function ca(e, t = {}) {
3524
3513
  let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
3525
3514
  for (let i of e) {
3526
3515
  let e = t[i.family] ?? i.default;
@@ -3532,14 +3521,14 @@ function ta(e, t = {}) {
3532
3521
  familyOf: r
3533
3522
  };
3534
3523
  }
3535
- function na(e, t, n) {
3524
+ function la(e, t, n) {
3536
3525
  return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
3537
3526
  }
3538
- function ra(e, t) {
3527
+ function ua(e, t) {
3539
3528
  let n = t.familyOf.get(e);
3540
3529
  return n ? t.chosen.get(n) ?? e : e;
3541
3530
  }
3542
- function ia(e, t) {
3531
+ function da(e, t) {
3543
3532
  let n = /* @__PURE__ */ new Map();
3544
3533
  for (let t of e) t.family && n.set(t.name, t.family);
3545
3534
  let r = new Set(t), i = /* @__PURE__ */ new Map();
@@ -3555,65 +3544,65 @@ function ia(e, t) {
3555
3544
  familyOf: n
3556
3545
  };
3557
3546
  }
3558
- function aa(e, t) {
3547
+ function fa(e, t) {
3559
3548
  return e.map((e) => ({
3560
3549
  ...e,
3561
- dependencies: e.dependencies.map((e) => ra(e, t))
3550
+ dependencies: e.dependencies.map((e) => ua(e, t))
3562
3551
  }));
3563
3552
  }
3564
3553
  //#endregion
3565
3554
  //#region src/ui/banner.ts
3566
- var oa = [
3555
+ var pa = [
3567
3556
  " ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
3568
3557
  " ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
3569
3558
  " ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
3570
3559
  " ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
3571
3560
  " ██║ ██║ ██║ ██║ ███████╗",
3572
3561
  " ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
3573
- ], sa = [
3562
+ ], ma = [
3574
3563
  " ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
3575
3564
  " ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
3576
3565
  " ███████╗ ██║ ███████║ ██║ █████╔╝ ",
3577
3566
  " ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
3578
3567
  " ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
3579
3568
  " ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
3580
- ], ca = [
3569
+ ], ha = [
3581
3570
  253,
3582
3571
  176,
3583
3572
  21
3584
- ], la = [
3573
+ ], ga = [
3585
3574
  245,
3586
3575
  76,
3587
3576
  2
3588
- ], ua = 5, da = [
3577
+ ], _a = 5, va = [
3589
3578
  17,
3590
3579
  103,
3591
3580
  248
3592
- ], fa = [
3581
+ ], ya = [
3593
3582
  42,
3594
3583
  160,
3595
3584
  250
3596
- ], pa = .2;
3597
- function ma() {
3585
+ ], ba = .2;
3586
+ function xa() {
3598
3587
  console.log();
3599
- for (let e of xe(oa, {
3600
- start: ca,
3601
- end: la,
3602
- angle: ua
3603
- })) console.log(y.bold(e));
3604
- for (let e of xe(sa, {
3605
- start: da,
3606
- end: fa,
3607
- angle: pa
3608
- })) console.log(y.bold(e));
3609
- console.log(), console.log(` ${R.spark} ${y.dim("v" + k)} ${y.dim("·")} ${ye("Ship web + desktop apps from one codebase")}`), console.log();
3610
- }
3611
- function ha() {
3612
- console.log(), console.log(` ${R.bolt} ${ge.orange("Hype")}${ge.skyBlue("Stack")} ${y.dim("v" + k)}`), console.log();
3588
+ for (let e of xe(pa, {
3589
+ start: ha,
3590
+ end: ga,
3591
+ angle: _a
3592
+ })) console.log(b.bold(e));
3593
+ for (let e of xe(ma, {
3594
+ start: va,
3595
+ end: ya,
3596
+ angle: ba
3597
+ })) console.log(b.bold(e));
3598
+ console.log(), console.log(` ${z.spark} ${b.dim("v" + A)} ${b.dim("·")} ${ye("Ship web + desktop apps from one codebase")}`), console.log();
3599
+ }
3600
+ function Sa() {
3601
+ console.log(), console.log(` ${z.bolt} ${ge.orange("Hype")}${ge.skyBlue("Stack")} ${b.dim("v" + A)}`), console.log();
3613
3602
  }
3614
3603
  //#endregion
3615
3604
  //#region src/ui/pack-multiselect.ts
3616
- var ga = class extends D {
3605
+ var Ca = class extends O {
3617
3606
  options;
3618
3607
  cursor = 0;
3619
3608
  selected;
@@ -3679,50 +3668,82 @@ var ga = class extends D {
3679
3668
  e === "a" && this.toggleAll();
3680
3669
  }
3681
3670
  renderFrame() {
3682
- let e = h.withGuide, t = g(this.state), n = _(this.state), r = e ? `${n} ` : "", i = e ? O("cyan", c) : "", a = `${e ? `${O("gray", s)}\n` : ""}${t} ${this.message}\n`, o = (e, t) => {
3671
+ let e = g.withGuide, t = _(this.state), n = v(this.state), r = e ? `${n} ` : "", i = e ? k("cyan", l) : "", a = `${e ? `${k("gray", c)}\n` : ""}${t} ${this.message}\n`, o = (e, t) => {
3683
3672
  let n = e.label ?? String(e.value);
3684
- if (e.disabled) return `${O("gray", u)} ${O(["strikethrough", "gray"], n)}`;
3685
- let r = this.selected.has(e.value) ? O("green", d) : t ? O("cyan", l) : O("dim", u);
3686
- return `${t ? `${O("green", f)} ` : " "}${r} ${t ? n : O("dim", n)}${t && e.hint ? ` ${O("dim", `(${e.hint})`)}` : ""}`;
3687
- }, p = () => {
3673
+ if (e.disabled) return `${k("gray", d)} ${k(["strikethrough", "gray"], n)}`;
3674
+ let r = this.selected.has(e.value) ? k("green", f) : t ? k("cyan", u) : k("dim", d);
3675
+ return `${t ? `${k("green", p)} ` : " "}${r} ${t ? n : k("dim", n)}${t && e.hint ? ` ${k("dim", `(${e.hint})`)}` : ""}`;
3676
+ }, s = () => {
3688
3677
  let e = this.atContinue;
3689
- return `${e ? `${O("green", f)} ` : " "}${O(e ? "cyan" : "dim", this.continueLabel)}${e ? O("dim", " (enter to install)") : ""}`;
3678
+ return `${e ? `${k("green", p)} ` : " "}${k(e ? "cyan" : "dim", this.continueLabel)}${e ? k("dim", " (enter to install)") : ""}`;
3690
3679
  };
3691
3680
  switch (this.state) {
3692
3681
  case "submit": {
3693
- let t = this.options.filter((e) => this.selected.has(e.value)).map((e) => e.label ?? String(e.value)).join(O("dim", ", ")) || O("dim", "none");
3694
- return `${a}${e ? O("gray", s) : ""} ${O("dim", t)}`;
3682
+ let t = this.options.filter((e) => this.selected.has(e.value)).map((e) => e.label ?? String(e.value)).join(k("dim", ", ")) || k("dim", "none");
3683
+ return `${a}${e ? k("gray", c) : ""} ${k("dim", t)}`;
3695
3684
  }
3696
3685
  case "cancel": {
3697
- let t = this.options.filter((e) => this.selected.has(e.value)).map((e) => e.label ?? String(e.value)).join(O("dim", ", "));
3698
- return t.trim() === "" ? `${a}${e ? O("gray", s) : ""}` : `${a}${e ? O("gray", s) : ""} ${O(["strikethrough", "dim"], t)}`;
3686
+ let t = this.options.filter((e) => this.selected.has(e.value)).map((e) => e.label ?? String(e.value)).join(k("dim", ", "));
3687
+ return t.trim() === "" ? `${a}${e ? k("gray", c) : ""}` : `${a}${e ? k("gray", c) : ""} ${k(["strikethrough", "dim"], t)}`;
3699
3688
  }
3700
3689
  default: {
3701
- let t = m({
3690
+ let t = h({
3702
3691
  cursor: Math.min(this.cursor, this.options.length - 1),
3703
3692
  options: this.options,
3704
- style: (e, t) => o(e, t),
3693
+ style: (e, t) => o(e, t && !this.atContinue),
3705
3694
  output: this.output,
3706
3695
  maxItems: this.maxItems,
3707
3696
  columnPadding: e ? 3 : 0,
3708
3697
  rowPadding: a.split("\n").length + (e ? 4 : 3)
3709
- }).map((e) => `${r}${e}`), n = `${O("dim", "↑/↓ move · enter/space toggle · a all · enter on Continue to install")}`, s = [
3698
+ }).map((e) => `${r}${e}`), n = `${k("dim", "↑/↓ move · enter/space toggle · a all · enter on Continue to install")}`, c = [
3710
3699
  ...t,
3711
- `${r}${p()}`,
3700
+ `${r}${s()}`,
3712
3701
  `${r}${n}`,
3713
3702
  i
3714
3703
  ];
3715
- return this.state === "error" && s.push(`${r}${O("yellow", this.error)}`), `${a}${s.join("\n")}\n`;
3704
+ return this.state === "error" && c.push(`${r}${k("yellow", this.error)}`), `${a}${c.join("\n")}\n`;
3716
3705
  }
3717
3706
  }
3718
3707
  }
3719
3708
  };
3720
- function _a(e) {
3721
- return new ga(e).prompt();
3709
+ function wa(e) {
3710
+ return new Ca(e).prompt();
3711
+ }
3712
+ //#endregion
3713
+ //#region src/utils/naming.ts
3714
+ function Ta(e) {
3715
+ return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
3716
+ }
3717
+ function Ea(e) {
3718
+ return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
3719
+ }
3720
+ //#endregion
3721
+ //#region src/utils/validate.ts
3722
+ function Da(e) {
3723
+ if (!e.trim()) return "Project name cannot be empty";
3724
+ if (e.length > 214) return "Project name is too long (max 214 characters)";
3725
+ let t = Ta(e);
3726
+ if (!ie.test(t)) return "Project name must contain at least one letter or number";
3727
+ }
3728
+ //#endregion
3729
+ //#region src/core/apply-mode.ts
3730
+ var Oa = "src/hooks/use-theme.ts", ka = /(\bexport\s+const\s+defaultTheme\s*=\s*)(["'])(?:light|dark)\2/;
3731
+ function Aa(e, t) {
3732
+ return e.replace(ka, (e, n, r) => `${n}${r}${t}${r}`);
3733
+ }
3734
+ async function ja(e, t) {
3735
+ let n = T.resolve(e, Oa), r;
3736
+ try {
3737
+ r = await y.readFile(n, "utf-8");
3738
+ } catch {
3739
+ return !1;
3740
+ }
3741
+ let i = Aa(r, t);
3742
+ return i === r || await y.writeFile(n, i, "utf-8"), !0;
3722
3743
  }
3723
3744
  //#endregion
3724
3745
  //#region src/core/apply-theme.ts
3725
- function va(e, t) {
3746
+ function Ma(e, t) {
3726
3747
  let n = e.indexOf(t);
3727
3748
  if (n === -1) return null;
3728
3749
  let r = e.indexOf("{", n);
@@ -3737,46 +3758,46 @@ function va(e, t) {
3737
3758
  bodyEnd: a - 1
3738
3759
  } : null;
3739
3760
  }
3740
- function ya(e, t) {
3761
+ function Na(e, t) {
3741
3762
  let n = e;
3742
3763
  for (let [e, r] of Object.entries(t)) {
3743
- let t = RegExp(`(^[ \\t]*--${ba(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
3764
+ let t = RegExp(`(^[ \\t]*--${Pa(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
3744
3765
  n = n.replace(t, (e, t) => `${t}${r};`);
3745
3766
  }
3746
3767
  return n;
3747
3768
  }
3748
- function ba(e) {
3769
+ function Pa(e) {
3749
3770
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3750
3771
  }
3751
- function xa(e, t) {
3752
- let n = va(e, ":root"), r = va(e, ".dark"), i = e;
3772
+ function Fa(e, t) {
3773
+ let n = Ma(e, ":root"), r = Ma(e, ".dark"), i = e;
3753
3774
  if (n) {
3754
3775
  let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
3755
- i = e + ya(r, t.light) + a;
3776
+ i = e + Na(r, t.light) + a;
3756
3777
  }
3757
3778
  if (r) {
3758
- let e = va(i, ".dark");
3779
+ let e = Ma(i, ".dark");
3759
3780
  if (e) {
3760
3781
  let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
3761
- i = n + ya(r, t.dark) + a;
3782
+ i = n + Na(r, t.dark) + a;
3762
3783
  }
3763
3784
  }
3764
3785
  return i;
3765
3786
  }
3766
- var Sa = "assets/styles.css";
3767
- async function Ca(e, t) {
3768
- let n = w.resolve(e, Sa), r;
3787
+ var Ia = "assets/styles.css";
3788
+ async function La(e, t) {
3789
+ let n = T.resolve(e, Ia), r;
3769
3790
  try {
3770
- r = await v.readFile(n, "utf-8");
3791
+ r = await y.readFile(n, "utf-8");
3771
3792
  } catch {
3772
3793
  return !1;
3773
3794
  }
3774
- let i = xa(r, t);
3775
- return i === r || await v.writeFile(n, i, "utf-8"), !0;
3795
+ let i = Fa(r, t);
3796
+ return i === r || await y.writeFile(n, i, "utf-8"), !0;
3776
3797
  }
3777
3798
  //#endregion
3778
3799
  //#region src/core/clone.ts
3779
- async function wa(e) {
3800
+ async function Ra(e) {
3780
3801
  let t = await ee(te, {
3781
3802
  dir: e,
3782
3803
  force: !0
@@ -3788,7 +3809,7 @@ async function wa(e) {
3788
3809
  }
3789
3810
  //#endregion
3790
3811
  //#region src/core/editor-config.ts
3791
- function Ta(e) {
3812
+ function za(e) {
3792
3813
  let t = {
3793
3814
  globs: [],
3794
3815
  alwaysApply: !1
@@ -3823,10 +3844,10 @@ function Ta(e) {
3823
3844
  content: i
3824
3845
  };
3825
3846
  }
3826
- function Ea(e) {
3847
+ function Ba(e) {
3827
3848
  return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
3828
3849
  }
3829
- function Da(e) {
3850
+ function Va(e) {
3830
3851
  let t;
3831
3852
  t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
3832
3853
  let n = [`trigger: ${t}`];
@@ -3836,30 +3857,30 @@ function Da(e) {
3836
3857
  }
3837
3858
  return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
3838
3859
  }
3839
- function Oa(e) {
3860
+ function Ha(e) {
3840
3861
  return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
3841
3862
  }
3842
- var ka = {
3863
+ var Ua = {
3843
3864
  claude: {
3844
3865
  rulesDir: ".claude/rules",
3845
3866
  extension: ".md",
3846
- convert: Ea
3867
+ convert: Ba
3847
3868
  },
3848
3869
  windsurf: {
3849
3870
  rulesDir: ".windsurf/rules",
3850
3871
  extension: ".md",
3851
- convert: Da
3872
+ convert: Va
3852
3873
  },
3853
3874
  copilot: {
3854
3875
  rulesDir: ".github/instructions",
3855
3876
  extension: ".instructions.md",
3856
- convert: Oa
3877
+ convert: Ha
3857
3878
  }
3858
3879
  };
3859
- async function Aa(e) {
3860
- let t = w.join(e, se), n = (await v.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
3880
+ async function Wa(e) {
3881
+ let t = T.join(e, oe), n = (await y.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
3861
3882
  return await Promise.all(n.map(async (e) => {
3862
- let n = w.join(t, e.name), { frontmatter: r, content: i } = Ta(await v.readFile(n, "utf-8"));
3883
+ let n = T.join(t, e.name), { frontmatter: r, content: i } = za(await y.readFile(n, "utf-8"));
3863
3884
  return {
3864
3885
  frontmatter: r,
3865
3886
  content: i,
@@ -3867,43 +3888,43 @@ async function Aa(e) {
3867
3888
  };
3868
3889
  }));
3869
3890
  }
3870
- async function ja(e, t) {
3891
+ async function Ga(e, t) {
3871
3892
  if (t === "cursor") return;
3872
- let n = ka[t], r = await Aa(e), i = w.join(e, n.rulesDir);
3873
- await v.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
3893
+ let n = Ua[t], r = await Wa(e), i = T.join(e, n.rulesDir);
3894
+ await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
3874
3895
  let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
3875
- return v.writeFile(w.join(i, r), t, "utf-8");
3876
- })), await sr(w.join(e, ce)), await sr(w.join(e, le));
3896
+ return y.writeFile(T.join(i, r), t, "utf-8");
3897
+ })), await lr(T.join(e, se)), await lr(T.join(e, ce));
3877
3898
  }
3878
3899
  //#endregion
3879
3900
  //#region src/core/env-files.ts
3880
- var Ma = [
3901
+ var Ka = [
3881
3902
  "apps",
3882
3903
  "packages",
3883
3904
  "libs",
3884
3905
  "shared"
3885
3906
  ];
3886
- async function Na(e) {
3887
- let t = await Pa(e);
3907
+ async function qa(e) {
3908
+ let t = await Ja(e);
3888
3909
  return (await Promise.all(t.map(async (t) => {
3889
- let n = w.join(w.dirname(t), ".env");
3890
- return await Y(n) ? null : (await v.copyFile(t, n), w.relative(e, n));
3910
+ let n = T.join(T.dirname(t), ".env");
3911
+ return await J(n) ? null : (await y.copyFile(t, n), T.relative(e, n));
3891
3912
  }))).filter((e) => e !== null).sort();
3892
3913
  }
3893
- async function Pa(e) {
3894
- let t = [w.join(e, ".env.example")], n = await Promise.all(Ma.map(async (t) => {
3895
- let n = w.join(e, t);
3896
- return (await v.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => w.join(n, e.name, ".env.example"));
3914
+ async function Ja(e) {
3915
+ let t = [T.join(e, ".env.example")], n = await Promise.all(Ka.map(async (t) => {
3916
+ let n = T.join(e, t);
3917
+ return (await y.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => T.join(n, e.name, ".env.example"));
3897
3918
  }));
3898
- return t.push(...n.flat()), (await Promise.all(t.map(async (e) => await Y(e) ? e : null))).filter((e) => e !== null);
3919
+ return t.push(...n.flat()), (await Promise.all(t.map(async (e) => await J(e) ? e : null))).filter((e) => e !== null);
3899
3920
  }
3900
3921
  //#endregion
3901
3922
  //#region src/core/post-clone.ts
3902
- var Q = "@hype-stack/", Fa = "hype-stack";
3903
- async function Ia(e) {
3904
- await sr(w.join(e, ".git"));
3923
+ var Z = "@hype-stack/", Ya = "hype-stack";
3924
+ async function Xa(e) {
3925
+ await lr(T.join(e, ".git"));
3905
3926
  }
3906
- async function La(e) {
3927
+ async function Za(e) {
3907
3928
  await q("git", ["init"], { cwd: e }), await q("git", ["add", "."], { cwd: e }), await q("git", [
3908
3929
  "-c",
3909
3930
  "user.name=Hype Stack CLI",
@@ -3914,22 +3935,22 @@ async function La(e) {
3914
3935
  "Initial commit from Hype Stack CLI"
3915
3936
  ], { cwd: e });
3916
3937
  }
3917
- async function Ra(e, t) {
3918
- let n = `@${t}/`, r = await Ka(e);
3938
+ async function Qa(e, t) {
3939
+ let n = `@${t}/`, r = await oo(e);
3919
3940
  for (let e of r) {
3920
- let t = await ir(e);
3941
+ let t = await or(e);
3921
3942
  if (!t) continue;
3922
3943
  let r = !1;
3923
- t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0), Ua(t.dependencies, n) && (r = !0), Ua(t.devDependencies, n) && (r = !0), t.nx && Wa(t.nx, n) && (r = !0);
3924
- let i = await v.readFile(e, "utf-8");
3925
- if (i.includes(Q)) {
3926
- let t = i.replaceAll(Q, n);
3927
- await v.writeFile(e, t, "utf-8");
3928
- } else r && await ar(e, t);
3944
+ t.name?.startsWith(Z) && (t.name = t.name.replace(Z, n), r = !0), ro(t.dependencies, n) && (r = !0), ro(t.devDependencies, n) && (r = !0), t.nx && io(t.nx, n) && (r = !0);
3945
+ let i = await y.readFile(e, "utf-8");
3946
+ if (i.includes(Z)) {
3947
+ let t = i.replaceAll(Z, n);
3948
+ await y.writeFile(e, t, "utf-8");
3949
+ } else r && await sr(e, t);
3929
3950
  }
3930
- await Ci(e, t), await Va(e, t), await Ga(e, t);
3951
+ await Ti(e, t), await to(e, t), await ao(e, t);
3931
3952
  }
3932
- var za = new Set([
3953
+ var $a = new Set([
3933
3954
  ".git",
3934
3955
  "node_modules",
3935
3956
  "dist",
@@ -3937,68 +3958,68 @@ var za = new Set([
3937
3958
  ".nx",
3938
3959
  ".next",
3939
3960
  "coverage"
3940
- ]), Ba = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
3941
- async function Va(e, t) {
3942
- if (t === Fa) return;
3943
- let n = await Ha(e);
3961
+ ]), eo = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
3962
+ async function to(e, t) {
3963
+ if (t === Ya) return;
3964
+ let n = await no(e);
3944
3965
  await Promise.all(n.map(async (e) => {
3945
- let n = await v.readFile(e, "utf-8").catch(() => null);
3966
+ let n = await y.readFile(e, "utf-8").catch(() => null);
3946
3967
  if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
3947
3968
  let r = n.replace(/^(name:[ \t]*)hype-stack/gm, `$1${t}`);
3948
- await v.writeFile(e, r, "utf-8");
3969
+ await y.writeFile(e, r, "utf-8");
3949
3970
  }));
3950
3971
  }
3951
- async function Ha(e) {
3952
- let t = await v.readdir(e, { withFileTypes: !0 }).catch(() => []);
3972
+ async function no(e) {
3973
+ let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
3953
3974
  return (await Promise.all(t.map(async (t) => {
3954
- let n = w.join(e, t.name);
3955
- return t.isDirectory() ? za.has(t.name) ? [] : Ha(n) : t.isFile() && Ba.test(t.name) ? [n] : [];
3975
+ let n = T.join(e, t.name);
3976
+ return t.isDirectory() ? $a.has(t.name) ? [] : no(n) : t.isFile() && eo.test(t.name) ? [n] : [];
3956
3977
  }))).flat();
3957
3978
  }
3958
- function Ua(e, t) {
3979
+ function ro(e, t) {
3959
3980
  if (!e) return !1;
3960
3981
  let n = !1;
3961
- for (let r of Object.keys(e)) if (r.startsWith(Q)) {
3962
- let i = r.replace(Q, t);
3982
+ for (let r of Object.keys(e)) if (r.startsWith(Z)) {
3983
+ let i = r.replace(Z, t);
3963
3984
  e[i] = e[r], delete e[r], n = !0;
3964
3985
  }
3965
3986
  return n;
3966
3987
  }
3967
- function Wa(e, t) {
3988
+ function io(e, t) {
3968
3989
  if (!e) return !1;
3969
3990
  let n = !1;
3970
- if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Q) ? (n = !0, e.replace(Q, t)) : e), e.targets) {
3971
- for (let r of Object.values(e.targets)) if (r.buildTarget?.includes(Q) && (r.buildTarget = r.buildTarget.replaceAll(Q, t), n = !0), r.dependsOn &&= r.dependsOn.map((e) => e.includes(Q) ? (n = !0, e.replaceAll(Q, t)) : e), r.configurations) for (let e of Object.values(r.configurations)) e.buildTarget?.includes(Q) && (e.buildTarget = e.buildTarget.replaceAll(Q, t), n = !0);
3991
+ if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Z) ? (n = !0, e.replace(Z, t)) : e), e.targets) {
3992
+ for (let r of Object.values(e.targets)) if (r.buildTarget?.includes(Z) && (r.buildTarget = r.buildTarget.replaceAll(Z, t), n = !0), r.dependsOn &&= r.dependsOn.map((e) => e.includes(Z) ? (n = !0, e.replaceAll(Z, t)) : e), r.configurations) for (let e of Object.values(r.configurations)) e.buildTarget?.includes(Z) && (e.buildTarget = e.buildTarget.replaceAll(Z, t), n = !0);
3972
3993
  }
3973
3994
  return n;
3974
3995
  }
3975
- async function Ga(e, t) {
3976
- let n = w.join(e, "packages/enums/src/app/index.ts"), r = await v.readFile(n, "utf-8").catch(() => null);
3996
+ async function ao(e, t) {
3997
+ let n = T.join(e, "packages/enums/src/app/index.ts"), r = await y.readFile(n, "utf-8").catch(() => null);
3977
3998
  if (!r) return;
3978
- let i = t.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" "), a = r.replaceAll(`id: "${Fa}"`, `id: "${t}"`).replaceAll(`name: "${Fa}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
3979
- await v.writeFile(n, a, "utf-8");
3999
+ let i = Ea(t), a = r.replaceAll(`id: "${Ya}"`, `id: "${t}"`).replaceAll(`name: "${Ya}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
4000
+ await y.writeFile(n, a, "utf-8");
3980
4001
  }
3981
- async function Ka(e) {
3982
- let t = [], n = w.join(e, "package.json");
3983
- (await v.stat(n).catch(() => null))?.isFile() && t.push(n);
4002
+ async function oo(e) {
4003
+ let t = [], n = T.join(e, "package.json");
4004
+ (await y.stat(n).catch(() => null))?.isFile() && t.push(n);
3984
4005
  for (let n of [
3985
4006
  "apps",
3986
4007
  "packages",
3987
4008
  "libs",
3988
4009
  "shared"
3989
4010
  ]) {
3990
- let r = w.join(e, n), i = await v.readdir(r, { withFileTypes: !0 }).catch(() => []);
4011
+ let r = T.join(e, n), i = await y.readdir(r, { withFileTypes: !0 }).catch(() => []);
3991
4012
  for (let e of i) {
3992
4013
  if (!e.isDirectory()) continue;
3993
- let n = w.join(r, e.name, "package.json");
3994
- (await v.stat(n).catch(() => null))?.isFile() && t.push(n);
4014
+ let n = T.join(r, e.name, "package.json");
4015
+ (await y.stat(n).catch(() => null))?.isFile() && t.push(n);
3995
4016
  }
3996
4017
  }
3997
4018
  return t;
3998
4019
  }
3999
4020
  //#endregion
4000
4021
  //#region src/core/readme.ts
4001
- var qa = {
4022
+ var so = {
4002
4023
  cursor: {
4003
4024
  label: "Cursor",
4004
4025
  rulesDir: ".cursor/rules"
@@ -4015,24 +4036,21 @@ var qa = {
4015
4036
  label: "GitHub Copilot",
4016
4037
  rulesDir: ".github/instructions"
4017
4038
  }
4018
- }, Ja = {
4039
+ }, co = {
4019
4040
  backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
4020
4041
  frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
4021
- }, Ya = {
4042
+ }, lo = {
4022
4043
  enums: "Shared enums and app config used across apps",
4023
4044
  cli: "Project tooling and code generators"
4024
4045
  };
4025
- function Xa(e) {
4026
- return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
4027
- }
4028
- function Za(e, t) {
4046
+ function uo(e, t) {
4029
4047
  return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
4030
4048
  let r = t[e];
4031
4049
  return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
4032
4050
  });
4033
4051
  }
4034
- function Qa(e) {
4035
- let { projectName: t, editor: n, workspace: r } = e, i = Xa(t), a = qa[n], o = !!r.apps.backend, s = Za(r.apps, Ja), c = Za(r.packages, Ya), l = [];
4052
+ function fo(e) {
4053
+ let { projectName: t, editor: n, workspace: r } = e, i = Ea(t), a = so[n], o = !!r.apps.backend, s = uo(r.apps, co), c = uo(r.packages, lo), l = [];
4036
4054
  s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
4037
4055
  let u = [];
4038
4056
  u.push(`# ${i}`), u.push([
@@ -4140,18 +4158,18 @@ function Qa(e) {
4140
4158
  "stays useful."
4141
4159
  ].join("\n")), u.join("\n\n") + "\n";
4142
4160
  }
4143
- async function $a(e, t) {
4144
- let n = w.join(e, "README.md");
4145
- await v.writeFile(n, Qa(t), "utf-8");
4161
+ async function po(e, t) {
4162
+ let n = T.join(e, "README.md");
4163
+ await y.writeFile(n, fo(t), "utf-8");
4146
4164
  }
4147
4165
  //#endregion
4148
4166
  //#region src/core/tracking.ts
4149
- async function eo(e) {
4167
+ async function mo(e) {
4150
4168
  try {
4151
4169
  let t = {
4152
- "X-Device-Id": Yn(),
4153
- "X-Client-Info": Xn()
4154
- }, n = await Gn(N()).catch(() => null);
4170
+ "X-Device-Id": Xn(),
4171
+ "X-Client-Info": Zn()
4172
+ }, n = await Kn(F()).catch(() => null);
4155
4173
  n?.token && (t.Authorization = `Bearer ${n.token}`), await K.createRequest()({
4156
4174
  endpoint: "/cli/track",
4157
4175
  method: "POST"
@@ -4159,272 +4177,6 @@ async function eo(e) {
4159
4177
  } catch {}
4160
4178
  }
4161
4179
  //#endregion
4162
- //#region src/ui/swatch.ts
4163
- function to(e) {
4164
- let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
4165
- if (!t) return null;
4166
- let n = t[1].trim().split(/\s+/);
4167
- if (n.length < 3) return null;
4168
- let r = n[0], i = Number(n[1]), a = Number(n[2]);
4169
- if (Number.isNaN(i) || Number.isNaN(a)) return null;
4170
- let o;
4171
- if (r.endsWith("%")) {
4172
- let e = Number(r.slice(0, -1));
4173
- if (Number.isNaN(e)) return null;
4174
- o = e / 100;
4175
- } else if (o = Number(r), Number.isNaN(o)) return null;
4176
- return {
4177
- l: o,
4178
- c: i,
4179
- h: a
4180
- };
4181
- }
4182
- function no(e) {
4183
- return Math.min(255, Math.max(0, Math.round(e)));
4184
- }
4185
- function ro(e) {
4186
- return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
4187
- }
4188
- function io({ l: e, c: t, h: n }) {
4189
- let r = n * Math.PI / 180, i = t * Math.cos(r), a = t * Math.sin(r), o = e + .3963377774 * i + .2158037573 * a, s = e - .1055613458 * i - .0638541728 * a, c = e - .0894841775 * i - 1.291485548 * a, l = o ** 3, u = s ** 3, d = c ** 3, f = 4.0767416621 * l - 3.3077115913 * u + .2309699292 * d, p = -1.2684380042 * l + 2.6097570613 * u - .3413193965 * d, m = -.0041960863 * l - .7034186147 * u + 1.7076146937 * d;
4190
- return [
4191
- no(ro(f) * 255),
4192
- no(ro(p) * 255),
4193
- no(ro(m) * 255)
4194
- ];
4195
- }
4196
- var ao = "\x1B[49m";
4197
- function oo(e, t) {
4198
- let n = e[t];
4199
- if (!n) return y.dim(" ");
4200
- let r = to(n);
4201
- if (!r) return y.dim(" ");
4202
- let [i, a, o] = io(r);
4203
- return `\x1b[48;2;${i};${a};${o}m ${ao}`;
4204
- }
4205
- var so = [
4206
- "primary",
4207
- "secondary",
4208
- "accent"
4209
- ];
4210
- function co(e) {
4211
- return so.map((t) => oo(e, t)).join("");
4212
- }
4213
- function lo(e) {
4214
- return `${co(e.light)} ${y.dim("·")} ${co(e.dark)}`;
4215
- }
4216
- //#endregion
4217
- //#region src/utils/validate.ts
4218
- function uo(e) {
4219
- if (!e.trim()) return "Project name cannot be empty";
4220
- if (!M.test(e)) return "Project name must be lowercase, alphanumeric, and may contain hyphens, dots, or underscores";
4221
- if (e.length > 214) return "Project name is too long (max 214 characters)";
4222
- }
4223
- //#endregion
4224
- //#region src/commands/create.ts
4225
- async function fo(a) {
4226
- a.skipBanner || ma(), o.intro(L.brandBold("Create a new Hype Stack project"));
4227
- let s = a.yes === !0, c;
4228
- if (s && a.name) {
4229
- let e = uo(a.name);
4230
- e && (o.log.error(e), Z()), c = a.name;
4231
- } else {
4232
- let e = await o.text({
4233
- message: "What is your project named?",
4234
- placeholder: "my-app",
4235
- initialValue: a.name ?? "",
4236
- validate: (e) => uo(e ?? "")
4237
- });
4238
- o.isCancel(e) && Z(), c = e;
4239
- }
4240
- let l;
4241
- if (a.directory !== void 0) l = a.directory;
4242
- else {
4243
- let e;
4244
- if (a.parentDirectory !== void 0) e = a.parentDirectory;
4245
- else if (s) e = ".";
4246
- else {
4247
- let t = await o.text({
4248
- message: "Where should we create it? (parent folder, the project gets its own subfolder inside)",
4249
- placeholder: ".",
4250
- initialValue: "."
4251
- });
4252
- o.isCancel(t) && Z(), e = t;
4253
- }
4254
- l = cr(e, c);
4255
- }
4256
- let u = w.resolve(l);
4257
- s || o.note(L.path(u), "Project will be created at");
4258
- let d = a.editor && oe.includes(a.editor) ? a.editor : null, f;
4259
- if (d) f = d;
4260
- else if (s) f = "cursor";
4261
- else {
4262
- let e = await o.select({
4263
- message: "Which code editor do you use?",
4264
- options: ae.map((e) => ({
4265
- value: e.value,
4266
- label: e.label,
4267
- hint: "hint" in e ? e.hint : void 0
4268
- })),
4269
- initialValue: "cursor"
4270
- });
4271
- o.isCancel(e) && Z(), f = e;
4272
- }
4273
- let p = a.theme !== void 0 && i(a.theme), m;
4274
- if (p) m = a.theme;
4275
- else if (s) m = e;
4276
- else {
4277
- let t = await o.select({
4278
- message: "Pick a color theme",
4279
- options: n.map((e) => ({
4280
- value: e.name,
4281
- label: `${lo(e)} ${e.label}`
4282
- })),
4283
- initialValue: e
4284
- });
4285
- o.isCancel(t) && Z(), m = t;
4286
- }
4287
- if (!s) {
4288
- let e = ae.find((e) => e.value === f)?.label ?? f, n = t.find((e) => e.value === m)?.label ?? m, r = await o.confirm({ message: `Create ${L.highlight(c)} in ${L.path(u)} with ${L.highlight(e)} config and the ${L.highlight(n)} theme?` });
4289
- (o.isCancel(r) || !r) && Z();
4290
- }
4291
- if (await J(u) && !await rr(u)) {
4292
- let e = await o.confirm({
4293
- message: `Directory ${L.path(u)} is not empty. Continue anyway?`,
4294
- initialValue: !1
4295
- });
4296
- (o.isCancel(e) || !e) && Z();
4297
- }
4298
- let h = o.spinner();
4299
- h.start("Cloning Hype Stack template..."), await wa(u), h.stop(L.success("Template cloned"));
4300
- let g = o.spinner();
4301
- g.start("Setting up project..."), await Ia(u), await Ra(u, c), await ja(u, f);
4302
- let _ = await hr(u), v = _r(c, _);
4303
- await mr(u, v), await $a(u, {
4304
- projectName: c,
4305
- editor: f,
4306
- workspace: _
4307
- }), i(m) && (await Ca(w.resolve(u, v.paths?.frontend.root ?? "apps/frontend"), r(m)) || o.log.warn(L.muted(`Could not find ${L.path("assets/styles.css")} to apply the ${m} theme`))), g.stop(L.success("Project configured"));
4308
- let y = o.spinner();
4309
- y.start("Installing dependencies..."), (await q("pnpm", ["install"], { cwd: u })).exitCode === 0 ? y.stop(L.success("Dependencies installed")) : (y.stop(L.warning("Dependencies installed with warnings")), o.log.warn(L.muted("You may need to run `pnpm install` manually to resolve issues.")));
4310
- let b = o.spinner();
4311
- b.start("Initializing git repository..."), await La(u), b.stop(L.success("Git repository initialized with clean history"));
4312
- let x = o.spinner();
4313
- x.start("Creating .env files from examples...");
4314
- let S = await Na(u);
4315
- if (S.length > 0) {
4316
- let e = S.length;
4317
- x.stop(L.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
4318
- } else x.stop(L.muted("No .env.example files to copy"));
4319
- o.log.success(`${L.brandBold("Hype Stack")} project ${L.highlight(c)} is ready!`);
4320
- let C = w.relative(process.cwd(), u) || ".", T = [`${L.command(`cd ${C}`)}`];
4321
- S.length > 0 ? T.push(`Review your ${L.path(".env")} files and fill in any secrets`) : T.push(`Copy ${L.path(".env.example")} to ${L.path(".env")} and configure`), Wi(T);
4322
- let E = a.setup === !1;
4323
- if (a.deferSetup) o.log.info(L.muted("Docker and migrations will run after your packs are installed."));
4324
- else {
4325
- let e = !E && (s || await o.confirm({
4326
- message: "Would you like to start Docker services and run database migrations now?",
4327
- initialValue: !0
4328
- }));
4329
- o.isCancel(e) && Z(), e ? await Xi(u, s) : (o.log.info(L.muted("You can start services later:")), Wi([
4330
- `${L.command("docker compose up -d")} ${L.muted("(in apps/backend - start Postgres, Valkey, RustFS)")}`,
4331
- `${L.command("pnpm --filter @internal/backend migration:latest")} ${L.muted("(apply migrations)")}`,
4332
- `${L.command("pnpm run generate")} ${L.muted("(generate Prisma client)")}`
4333
- ])), Wi([`${L.command("pnpm dev")} ${L.muted("(start frontend + backend)")}`]);
4334
- }
4335
- return await eo("project_create"), o.outro(L.muted("Happy building!")), u;
4336
- }
4337
- //#endregion
4338
- //#region src/commands/init.ts
4339
- async function po(e) {
4340
- let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
4341
- if (n || (ha(), o.intro(L.brandBold("Initialize Hype Stack configuration"))), !await vr(t)) {
4342
- o.log.error(`This doesn't look like a Hype Stack project. ${L.muted("Expected apps/ directory and package.json")}`), o.outro(L.muted(`Run ${L.command("npx @hype-stack/cli create")} to scaffold a new project.`));
4343
- return;
4344
- }
4345
- if (await pr(t)) {
4346
- let e = await fr(t);
4347
- if (e && !n) {
4348
- o.log.info(`Found existing ${L.path("stack.json")} for project ${L.highlight(e.name)}`);
4349
- let t = await o.confirm({
4350
- message: "Overwrite existing configuration?",
4351
- initialValue: !1
4352
- });
4353
- if (o.isCancel(t) || !t) {
4354
- o.outro(L.muted("Keeping existing configuration."));
4355
- return;
4356
- }
4357
- }
4358
- }
4359
- let r = await hr(t);
4360
- if (!n) {
4361
- let e = Object.entries(r.apps), t = Object.entries(r.packages);
4362
- if (e.length > 0) {
4363
- o.log.info(L.bold("Detected apps:"));
4364
- for (let [t, n] of e) o.log.message(` ${R.arrow} ${L.highlight(t)} ${L.muted(`→ ${n}`)}`);
4365
- }
4366
- if (t.length > 0) {
4367
- o.log.info(L.bold("Detected packages:"));
4368
- for (let [e, n] of t) o.log.message(` ${R.arrow} ${L.highlight(e)} ${L.muted(`→ ${n}`)}`);
4369
- }
4370
- e.length === 0 && t.length === 0 && o.log.warn("No apps or packages detected in the workspace.");
4371
- }
4372
- let i = (await ir(w.join(t, "package.json")))?.name?.replace(/^@/, "").replace(/\/source$/, "") ?? "my-app", a = i;
4373
- if (!n) {
4374
- let e = await o.text({
4375
- message: "Project name for stack.json?",
4376
- placeholder: i,
4377
- initialValue: i
4378
- });
4379
- o.isCancel(e) && Z(), a = e;
4380
- }
4381
- await mr(t, _r(a, r)), n || (o.log.success(`${L.path("stack.json")} written successfully`), o.outro(L.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
4382
- }
4383
- async function mo(e, t = {}) {
4384
- if (await pr(e)) return {
4385
- projectRoot: e,
4386
- scaffolded: !1
4387
- };
4388
- let n = t.runInit ?? ((e) => po({
4389
- cwd: e,
4390
- silent: !0
4391
- })), r = t.runCreate ?? ((e) => fo({
4392
- parentDirectory: e,
4393
- deferSetup: !0,
4394
- skipBanner: !0
4395
- }));
4396
- if (await vr(e)) {
4397
- o.log.warn(`No ${L.path("stack.json")} found in ${L.path(e)}.`);
4398
- let t = await o.confirm({
4399
- message: `Create ${L.path("stack.json")} now?`,
4400
- initialValue: !0
4401
- });
4402
- if (o.isCancel(t) || !t) return null;
4403
- await n(e);
4404
- let r = await pr(e);
4405
- return r && o.log.success(`${L.path("stack.json")} created`), r ? {
4406
- projectRoot: e,
4407
- scaffolded: !1
4408
- } : null;
4409
- }
4410
- o.log.warn(`This doesn't look like a Hype Stack project, and there's no ${L.path("stack.json")} here.`);
4411
- let i = await o.confirm({
4412
- message: `Is ${L.path(e)} where you want to work?`,
4413
- initialValue: !0
4414
- });
4415
- if (o.isCancel(i) || !i) return null;
4416
- let a = await o.confirm({
4417
- message: "Create a new Hype Stack project here?",
4418
- initialValue: !0
4419
- });
4420
- if (o.isCancel(a) || !a) return null;
4421
- let s = await r(e);
4422
- return await pr(s) ? {
4423
- projectRoot: s,
4424
- scaffolded: !0
4425
- } : null;
4426
- }
4427
- //#endregion
4428
4180
  //#region src/core/npm-deps.ts
4429
4181
  function ho(e, t) {
4430
4182
  let n = [], r = [];
@@ -4468,12 +4220,12 @@ function go(e) {
4468
4220
  async function _o(e, t, n = q) {
4469
4221
  let r = [];
4470
4222
  for (let i of e) {
4471
- let e = w.join(t, i.relativeDir);
4472
- if (!await Y(w.join(e, "package.json"))) {
4223
+ let e = T.join(t, i.relativeDir);
4224
+ if (!await J(T.join(e, "package.json"))) {
4473
4225
  r.push(`Cannot install npm dependencies under "${i.relativeDir}": package.json not found.`);
4474
4226
  continue;
4475
4227
  }
4476
- let a = w.normalize(i.relativeDir), o;
4228
+ let a = T.normalize(i.relativeDir), o;
4477
4229
  try {
4478
4230
  o = await n("pnpm", [
4479
4231
  "add",
@@ -4498,19 +4250,19 @@ async function _o(e, t, n = q) {
4498
4250
  }
4499
4251
  //#endregion
4500
4252
  //#region src/commands/install-helpers.ts
4501
- function $(e) {
4253
+ function Q(e) {
4502
4254
  return e instanceof Error ? e.message : String(e);
4503
4255
  }
4504
4256
  async function vo(e, t, n) {
4505
4257
  let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
4506
- return r.length === 0 ? {} : Tr(r, n).catch(() => ({}));
4258
+ return r.length === 0 ? {} : Dr(r, n).catch(() => ({}));
4507
4259
  }
4508
4260
  function yo(e, t) {
4509
- return e === "free" ? L.success("free") : e === "owned" ? L.accent("owned") : `${L.highlight(`$${t}`)} ${L.muted("locked")}`;
4261
+ return e === "free" ? R.success("free") : e === "owned" ? R.accent("owned") : `${R.highlight(`$${t}`)} ${R.muted("locked")}`;
4510
4262
  }
4511
4263
  async function bo(e, t, n) {
4512
4264
  let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
4513
- i.length > 0 && o.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await nr(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
4265
+ i.length > 0 && s.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await rr(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
4514
4266
  name: e.name,
4515
4267
  displayName: e.displayName,
4516
4268
  price: e.price
@@ -4519,9 +4271,9 @@ async function bo(e, t, n) {
4519
4271
  function xo(e, t) {
4520
4272
  let n = e.map((e, n) => {
4521
4273
  let r = t.get(e), i = r ? r.displayName : e;
4522
- return ` ${L.muted(`${n + 1}.`)} ${L.brand(i)}`;
4274
+ return ` ${R.muted(`${n + 1}.`)} ${R.brand(i)}`;
4523
4275
  });
4524
- o.note([
4276
+ s.note([
4525
4277
  "These packs will be installed, in order:",
4526
4278
  "",
4527
4279
  ...n
@@ -4530,7 +4282,7 @@ function xo(e, t) {
4530
4282
  async function So(e, t) {
4531
4283
  let n = [];
4532
4284
  for (let r of e) {
4533
- let e = await yr(r), i = await br(r, t);
4285
+ let e = await xr(r), i = await Sr(r, t);
4534
4286
  if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'npx @hype-stack/cli login' or check your license.`);
4535
4287
  n.push({
4536
4288
  manifest: e,
@@ -4542,116 +4294,376 @@ async function So(e, t) {
4542
4294
  async function Co(e) {
4543
4295
  let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = ho(go(t.map((e) => e.manifest.dependencies_npm)), n);
4544
4296
  if (a.errors.length > 0) {
4545
- for (let e of a.errors) o.log.error(e);
4297
+ for (let e of a.errors) s.log.error(e);
4546
4298
  return;
4547
4299
  }
4548
4300
  if (a.operations.length === 0) return;
4549
4301
  i.start("Installing npm dependencies...");
4550
- let s = await _o(a.operations, r);
4551
- if (i.stop(s.ok ? "npm dependencies installed" : "npm dependency installation failed"), !s.ok) for (let e of s.errors) o.log.error(e);
4302
+ let o = await _o(a.operations, r);
4303
+ if (i.stop(o.ok ? "npm dependencies installed" : "npm dependency installation failed"), !o.ok) for (let e of o.errors) s.log.error(e);
4552
4304
  }
4553
- function wo(e) {
4554
- let t = e.flatMap((e) => e.manifest.postInstall ?? []), n = [...new Set(t)];
4555
- n.length !== 0 && o.note(n.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Next Steps");
4305
+ function wo() {
4306
+ s.note([` ${R.command("1. npx @hype-stack/cli onboard")} ${R.muted("(set up env vars + run migrations)")}`, ` ${R.command("2. pnpm dev")} ${R.muted("(start frontend + backend)")}`].join("\n"), "Next steps");
4556
4307
  }
4557
4308
  function To(e) {
4558
4309
  if (e.length === 0) return;
4559
4310
  let t = e.map((e) => {
4560
4311
  let t = e.replace(/^\{\{[^}]+\}\}\//, "");
4561
- return ` ${L.muted("•")} ${L.path(t)}`;
4312
+ return ` ${R.muted("•")} ${R.path(t)}`;
4562
4313
  });
4563
- o.note(t.join("\n"), "Skipped (already exist)");
4314
+ s.note(t.join("\n"), "Skipped (already exist)");
4564
4315
  }
4565
4316
  async function Eo(e) {
4566
- let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: s } = e, c = /* @__PURE__ */ new Set();
4317
+ let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
4567
4318
  if (i) return c;
4568
- let l = await Mi({
4319
+ let l = await Pi({
4569
4320
  packs: t,
4570
4321
  config: n,
4571
4322
  projectRoot: r,
4572
- slotsByPack: s
4323
+ slotsByPack: o
4573
4324
  });
4574
4325
  if (l.length === 0) return c;
4575
4326
  if (a) {
4576
- o.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${L.command("--force")} to overwrite.`);
4327
+ s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${R.command("--force")} to overwrite.`);
4577
4328
  let e = l.map((e) => {
4578
- let t = w.relative(r, e.targetPath) || e.target;
4579
- return ` ${L.muted("•")} ${L.path(t)} ${L.muted(`(${e.packName})`)}`;
4329
+ let t = T.relative(r, e.targetPath) || e.target;
4330
+ return ` ${R.muted("•")} ${R.path(t)} ${R.muted(`(${e.packName})`)}`;
4580
4331
  });
4581
- return o.note(e.join("\n"), "Kept existing files"), c;
4332
+ return s.note(e.join("\n"), "Kept existing files"), c;
4582
4333
  }
4583
- o.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
4334
+ s.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
4584
4335
  for (let e of l) {
4585
- let t = w.relative(r, e.targetPath) || e.target, n = await o.confirm({
4586
- message: `Overwrite ${L.path(t)}? ${L.muted(`(${e.packName})`)}`,
4336
+ let t = T.relative(r, e.targetPath) || e.target, n = await s.confirm({
4337
+ message: `Overwrite ${R.path(t)}? ${R.muted(`(${e.packName})`)}`,
4587
4338
  initialValue: !1
4588
4339
  });
4589
- o.isCancel(n) && (o.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
4340
+ s.isCancel(n) && (s.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
4590
4341
  }
4591
4342
  return c;
4592
4343
  }
4593
4344
  //#endregion
4345
+ //#region src/ui/swatch.ts
4346
+ function Do(e) {
4347
+ let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
4348
+ if (!t) return null;
4349
+ let n = t[1].trim().split(/\s+/);
4350
+ if (n.length < 3) return null;
4351
+ let r = n[0], i = Number(n[1]), a = Number(n[2]);
4352
+ if (Number.isNaN(i) || Number.isNaN(a)) return null;
4353
+ let o;
4354
+ if (r.endsWith("%")) {
4355
+ let e = Number(r.slice(0, -1));
4356
+ if (Number.isNaN(e)) return null;
4357
+ o = e / 100;
4358
+ } else if (o = Number(r), Number.isNaN(o)) return null;
4359
+ return {
4360
+ l: o,
4361
+ c: i,
4362
+ h: a
4363
+ };
4364
+ }
4365
+ function Oo(e) {
4366
+ return Math.min(255, Math.max(0, Math.round(e)));
4367
+ }
4368
+ function ko(e) {
4369
+ return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
4370
+ }
4371
+ function Ao({ l: e, c: t, h: n }) {
4372
+ let r = n * Math.PI / 180, i = t * Math.cos(r), a = t * Math.sin(r), o = e + .3963377774 * i + .2158037573 * a, s = e - .1055613458 * i - .0638541728 * a, c = e - .0894841775 * i - 1.291485548 * a, l = o ** 3, u = s ** 3, d = c ** 3, f = 4.0767416621 * l - 3.3077115913 * u + .2309699292 * d, p = -1.2684380042 * l + 2.6097570613 * u - .3413193965 * d, m = -.0041960863 * l - .7034186147 * u + 1.7076146937 * d;
4373
+ return [
4374
+ Oo(ko(f) * 255),
4375
+ Oo(ko(p) * 255),
4376
+ Oo(ko(m) * 255)
4377
+ ];
4378
+ }
4379
+ var jo = "\x1B[49m";
4380
+ function Mo(e, t) {
4381
+ let n = e[t];
4382
+ if (!n) return b.dim(" ");
4383
+ let r = Do(n);
4384
+ if (!r) return b.dim(" ");
4385
+ let [i, a, o] = Ao(r);
4386
+ return `\x1b[48;2;${i};${a};${o}m ${jo}`;
4387
+ }
4388
+ var No = [
4389
+ "primary",
4390
+ "secondary",
4391
+ "accent"
4392
+ ];
4393
+ function Po(e) {
4394
+ return No.map((t) => Mo(e, t)).join("");
4395
+ }
4396
+ function Fo(e) {
4397
+ return `${Po(e.light)} ${b.dim("·")} ${Po(e.dark)}`;
4398
+ }
4399
+ //#endregion
4400
+ //#region src/commands/create.ts
4401
+ async function Io(e) {
4402
+ e.skipBanner || xa(), s.intro(R.brandBold("Create a new Hype Stack project"));
4403
+ let o = e.yes === !0, c, l;
4404
+ if (o && e.name) {
4405
+ let t = Da(e.name);
4406
+ t && (s.log.error(t), X()), l = e.name, c = Ta(e.name);
4407
+ } else {
4408
+ let t = await s.text({
4409
+ message: "What is your project named?",
4410
+ placeholder: "my-app",
4411
+ initialValue: e.name ?? "",
4412
+ validate: (e) => Da(e ?? "")
4413
+ });
4414
+ s.isCancel(t) && X(), l = t, c = Ta(l);
4415
+ }
4416
+ l.trim() !== c && s.log.info(R.muted(`Using "${R.highlight(c)}" as the project name`));
4417
+ let u;
4418
+ if (e.directory !== void 0) u = e.directory;
4419
+ else {
4420
+ let t;
4421
+ if (e.parentDirectory !== void 0) t = e.parentDirectory;
4422
+ else if (o) t = ".";
4423
+ else {
4424
+ let e = await s.text({
4425
+ message: "Where should we create it? (parent folder, the project gets its own subfolder inside)",
4426
+ placeholder: ".",
4427
+ initialValue: "."
4428
+ });
4429
+ s.isCancel(e) && X(), t = e;
4430
+ }
4431
+ u = ur(t, c);
4432
+ }
4433
+ let d = T.resolve(u);
4434
+ o || s.note(R.path(d), "Project will be created at");
4435
+ let f = e.editor && ae.includes(e.editor) ? e.editor : null, p;
4436
+ if (f) p = f;
4437
+ else if (o) p = "cursor";
4438
+ else {
4439
+ let e = await s.select({
4440
+ message: "Which code editor do you use?",
4441
+ options: P.map((e) => ({
4442
+ value: e.value,
4443
+ label: e.label,
4444
+ hint: "hint" in e ? e.hint : void 0
4445
+ })),
4446
+ initialValue: "cursor"
4447
+ });
4448
+ s.isCancel(e) && X(), p = e;
4449
+ }
4450
+ let m = e.theme !== void 0 && a(e.theme), h = e.defaultTheme !== void 0 && a(e.defaultTheme) ? e.defaultTheme : t, g;
4451
+ if (m) g = e.theme;
4452
+ else if (o) g = h;
4453
+ else {
4454
+ let e = await s.select({
4455
+ message: "Pick a color theme",
4456
+ options: r.map((e) => ({
4457
+ value: e.name,
4458
+ label: `${Fo(e)} ${e.label}`
4459
+ })),
4460
+ initialValue: h
4461
+ });
4462
+ s.isCancel(e) && X(), g = e;
4463
+ }
4464
+ if (!o) {
4465
+ let e = P.find((e) => e.value === p)?.label ?? p, t = n.find((e) => e.value === g)?.label ?? g, r = await s.confirm({ message: `Create ${R.highlight(c)} in ${R.path(d)} with ${R.highlight(e)} config and the ${R.highlight(t)} theme?` });
4466
+ (s.isCancel(r) || !r) && X();
4467
+ }
4468
+ if (await ir(d) && !await ar(d)) {
4469
+ let e = await s.confirm({
4470
+ message: `Directory ${R.path(d)} is not empty. Continue anyway?`,
4471
+ initialValue: !1
4472
+ });
4473
+ (s.isCancel(e) || !e) && X();
4474
+ }
4475
+ let _ = s.spinner();
4476
+ _.start("Cloning Hype Stack template..."), await Ra(d), _.stop(R.success("Template cloned"));
4477
+ let v = s.spinner();
4478
+ v.start("Setting up project..."), await Xa(d), await Qa(d, c), await Ga(d, p);
4479
+ let y = await _r(d), b = yr(c, y);
4480
+ await gr(d, b), await po(d, {
4481
+ projectName: c,
4482
+ editor: p,
4483
+ workspace: y
4484
+ });
4485
+ let x = T.resolve(d, b.paths?.frontend.root ?? "apps/frontend");
4486
+ a(g) && (await La(x, i(g)) || s.log.warn(R.muted(`Could not find ${R.path("assets/styles.css")} to apply the ${g} theme`))), await ja(x, e.defaultMode === "dark" || e.defaultMode === "light" ? e.defaultMode : "light") || s.log.warn(R.muted(`Could not find ${R.path("src/hooks/use-theme.ts")} to set the default color mode`)), v.stop(R.success("Project configured"));
4487
+ let S = s.spinner();
4488
+ S.start("Installing dependencies..."), (await q("pnpm", ["install"], { cwd: d })).exitCode === 0 ? S.stop(R.success("Dependencies installed")) : (S.stop(R.warning("Dependencies installed with warnings")), s.log.warn(R.muted("You may need to run `pnpm install` manually to resolve issues.")));
4489
+ let C = s.spinner();
4490
+ C.start("Initializing git repository..."), await Za(d), C.stop(R.success("Git repository initialized with clean history"));
4491
+ let w = s.spinner();
4492
+ w.start("Creating .env files from examples...");
4493
+ let E = await qa(d);
4494
+ if (E.length > 0) {
4495
+ let e = E.length;
4496
+ w.stop(R.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
4497
+ } else w.stop(R.muted("No .env.example files to copy"));
4498
+ s.log.success(`${R.brandBold("Hype Stack")} project ${R.highlight(c)} is ready!`);
4499
+ let D = T.relative(process.cwd(), d) || ".", O = [`${R.command(`cd ${D}`)}`];
4500
+ E.length > 0 ? O.push(`Review your ${R.path(".env")} files and fill in any secrets`) : O.push(`Copy ${R.path(".env.example")} to ${R.path(".env")} and configure`), Ki(O);
4501
+ let k = e.setup === !1;
4502
+ if (e.deferSetup) s.log.info(R.muted("Docker and migrations will run after your packs are installed."));
4503
+ else {
4504
+ let e = !k && (o || await s.confirm({
4505
+ message: "Would you like to start Docker services and run database migrations now?",
4506
+ initialValue: !0
4507
+ }));
4508
+ s.isCancel(e) && X(), e ? await ra(d, o) : s.log.info(R.muted("Docker and migrations can run later via `npx @hype-stack/cli onboard`.")), wo();
4509
+ }
4510
+ return await mo("project_create"), s.outro(R.muted("Happy building!")), d;
4511
+ }
4512
+ //#endregion
4513
+ //#region src/commands/init.ts
4514
+ async function Lo(e) {
4515
+ let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
4516
+ if (n || (Sa(), s.intro(R.brandBold("Initialize Hype Stack configuration"))), !await br(t)) {
4517
+ s.log.error(`This doesn't look like a Hype Stack project. ${R.muted("Expected apps/ directory and package.json")}`), s.outro(R.muted(`Run ${R.command("npx @hype-stack/cli create")} to scaffold a new project.`));
4518
+ return;
4519
+ }
4520
+ if (await hr(t)) {
4521
+ let e = await mr(t);
4522
+ if (e && !n) {
4523
+ s.log.info(`Found existing ${R.path("stack.json")} for project ${R.highlight(e.name)}`);
4524
+ let t = await s.confirm({
4525
+ message: "Overwrite existing configuration?",
4526
+ initialValue: !1
4527
+ });
4528
+ if (s.isCancel(t) || !t) {
4529
+ s.outro(R.muted("Keeping existing configuration."));
4530
+ return;
4531
+ }
4532
+ }
4533
+ }
4534
+ let r = await _r(t);
4535
+ if (!n) {
4536
+ let e = Object.entries(r.apps), t = Object.entries(r.packages);
4537
+ if (e.length > 0) {
4538
+ s.log.info(R.bold("Detected apps:"));
4539
+ for (let [t, n] of e) s.log.message(` ${z.arrow} ${R.highlight(t)} ${R.muted(`→ ${n}`)}`);
4540
+ }
4541
+ if (t.length > 0) {
4542
+ s.log.info(R.bold("Detected packages:"));
4543
+ for (let [e, n] of t) s.log.message(` ${z.arrow} ${R.highlight(e)} ${R.muted(`→ ${n}`)}`);
4544
+ }
4545
+ e.length === 0 && t.length === 0 && s.log.warn("No apps or packages detected in the workspace.");
4546
+ }
4547
+ let i = (await or(T.join(t, "package.json")))?.name?.replace(/^@/, "").replace(/\/source$/, "") ?? "my-app", a = i;
4548
+ if (!n) {
4549
+ let e = await s.text({
4550
+ message: "Project name for stack.json?",
4551
+ placeholder: i,
4552
+ initialValue: i,
4553
+ validate: (e) => Da(e ?? "")
4554
+ });
4555
+ s.isCancel(e) && X(), a = Ta(e);
4556
+ }
4557
+ await gr(t, yr(a, r)), n || (s.log.success(`${R.path("stack.json")} written successfully`), s.outro(R.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
4558
+ }
4559
+ async function Ro(e, t = {}, n) {
4560
+ if (await hr(e)) return {
4561
+ projectRoot: e,
4562
+ scaffolded: !1
4563
+ };
4564
+ let r = t.runInit ?? ((e) => Lo({
4565
+ cwd: e,
4566
+ silent: !0
4567
+ })), i = t.runCreate ?? ((e, t) => Io({
4568
+ parentDirectory: e,
4569
+ deferSetup: !0,
4570
+ skipBanner: !0,
4571
+ defaultTheme: t?.defaultTheme,
4572
+ defaultMode: t?.defaultMode
4573
+ }));
4574
+ if (await br(e)) {
4575
+ s.log.warn(`No ${R.path("stack.json")} found in ${R.path(e)}.`);
4576
+ let t = await s.confirm({
4577
+ message: `Create ${R.path("stack.json")} now?`,
4578
+ initialValue: !0
4579
+ });
4580
+ if (s.isCancel(t) || !t) return null;
4581
+ await r(e);
4582
+ let n = await hr(e);
4583
+ return n && s.log.success(`${R.path("stack.json")} created`), n ? {
4584
+ projectRoot: e,
4585
+ scaffolded: !1
4586
+ } : null;
4587
+ }
4588
+ s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${R.path("stack.json")} here.`);
4589
+ let a = await s.confirm({
4590
+ message: `Is ${R.path(e)} where you want to work?`,
4591
+ initialValue: !0
4592
+ });
4593
+ if (s.isCancel(a) || !a) return null;
4594
+ let o = await s.confirm({
4595
+ message: "Create a new Hype Stack project here?",
4596
+ initialValue: !0
4597
+ });
4598
+ if (s.isCancel(o) || !o) return null;
4599
+ let c = await i(e, n);
4600
+ return await hr(c) ? {
4601
+ projectRoot: c,
4602
+ scaffolded: !0
4603
+ } : null;
4604
+ }
4605
+ //#endregion
4594
4606
  //#region src/commands/compose.ts
4595
- async function Do(e = {}) {
4607
+ async function zo(e = {}) {
4596
4608
  let t = e.cwd ?? process.cwd();
4597
- ma();
4598
- let n = await mo(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
4609
+ xa();
4610
+ let n = await Ro(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
4599
4611
  try {
4600
- a = await fr(r ?? t);
4612
+ a = await mr(r ?? t);
4601
4613
  } catch (e) {
4602
- o.cancel(`Could not parse ${L.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
4614
+ s.cancel(`Could not parse ${R.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
4603
4615
  }
4604
- a || (o.cancel(r ? `Could not read ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli compose' again.` : `No ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli compose'.`), process.exit(1)), a.paths || (o.cancel(`${L.path("stack.json")} is missing ${L.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
4605
- let s = r ?? t;
4606
- o.intro(L.brandBold("Compose your stack"));
4607
- let c = o.spinner();
4616
+ a || (s.cancel(r ? `Could not read ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli compose' again.` : `No ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli compose'.`), process.exit(1)), a.paths || (s.cancel(`${R.path("stack.json")} is missing ${R.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
4617
+ let o = r ?? t;
4618
+ s.intro(R.brandBold("Compose your stack"));
4619
+ let c = s.spinner();
4608
4620
  c.start("Loading packs...");
4609
4621
  let l;
4610
4622
  try {
4611
- l = await wr();
4623
+ l = await Er();
4612
4624
  } catch (e) {
4613
- c.stop("Failed to load packs"), o.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
4625
+ c.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${Q(e)}`), process.exit(1);
4614
4626
  }
4615
4627
  c.stop("Packs loaded");
4616
- let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await Gn(N()))?.token ?? null, h = await vo(l, d, {
4628
+ let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await Kn(F()))?.token ?? null, h = await vo(l, d, {
4617
4629
  token: m,
4618
4630
  key: p
4619
4631
  }), g = (e) => {
4620
4632
  let t = f.get(e);
4621
4633
  return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
4622
- }, _ = (e) => !d.has(e) && g(e) === "locked", y = await Oo({
4634
+ }, _ = (e) => !d.has(e) && g(e) === "locked", v = await Bo({
4623
4635
  packs: l,
4624
4636
  installedSet: d,
4625
4637
  stateOf: g,
4626
4638
  options: e,
4627
4639
  adminAvailable: !!a.apps.admin
4628
4640
  });
4629
- if (y === null && (o.cancel("Cancelled."), process.exit(0)), y.length === 0) {
4630
- o.outro(L.muted("No packs selected. Nothing to do."));
4641
+ if (v === null && (s.cancel("Cancelled."), process.exit(0)), v.length === 0) {
4642
+ s.outro(R.muted("No packs selected. Nothing to do."));
4631
4643
  return;
4632
4644
  }
4633
- let b = jo(y), x = Mo(y), S = ia(l, b), C = Zi(aa(l, S)), w;
4645
+ let b = Uo(v), x = Wo(v), S = da(l, b), C = ia(fa(l, S)), w;
4634
4646
  try {
4635
- w = $i(b, C, u);
4647
+ w = oa(b, C, u);
4636
4648
  } catch (e) {
4637
- o.cancel($(e)), process.exit(1);
4649
+ s.cancel(Q(e)), process.exit(1);
4638
4650
  }
4639
4651
  if (w.order.length === 0) {
4640
- o.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), o.outro(L.muted("Your selection is already part of the project."));
4652
+ s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(R.muted("Your selection is already part of the project."));
4641
4653
  return;
4642
4654
  }
4643
- let T = ea({
4655
+ let T = sa({
4644
4656
  order: w.order,
4645
4657
  graph: C,
4646
4658
  isLocked: _,
4647
4659
  installed: u
4648
4660
  });
4649
4661
  if (T.blocked.length > 0 && !m && !p) {
4650
- let e = await tr();
4662
+ let e = await nr();
4651
4663
  e && (m = e, h = await vo(l, d, {
4652
4664
  token: m,
4653
4665
  key: p
4654
- }), T = ea({
4666
+ }), T = sa({
4655
4667
  order: w.order,
4656
4668
  graph: C,
4657
4669
  isLocked: _,
@@ -4659,12 +4671,12 @@ async function Do(e = {}) {
4659
4671
  }));
4660
4672
  }
4661
4673
  if (T.blocked.length > 0 && await bo(T.blocked, _, f), T.installable.length === 0) {
4662
- o.outro(L.muted("Nothing left to install once locked packs are removed."));
4674
+ s.outro(R.muted("Nothing left to install once locked packs are removed."));
4663
4675
  return;
4664
4676
  }
4665
4677
  if (xo(T.installable, f), !e.yes) {
4666
- let e = await o.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
4667
- (o.isCancel(e) || !e) && (o.cancel("Installation cancelled."), process.exit(0));
4678
+ let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
4679
+ (s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
4668
4680
  }
4669
4681
  c.start("Downloading packs...");
4670
4682
  let E;
@@ -4674,64 +4686,64 @@ async function Do(e = {}) {
4674
4686
  key: p
4675
4687
  });
4676
4688
  } catch (e) {
4677
- c.stop("Download failed"), o.cancel($(e)), process.exit(1);
4689
+ c.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
4678
4690
  }
4679
4691
  c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
4680
4692
  let D = await Eo({
4681
4693
  prepared: E,
4682
4694
  config: a,
4683
- cwd: s,
4695
+ cwd: o,
4684
4696
  force: e.force ?? !1,
4685
4697
  yes: e.yes ?? !1,
4686
4698
  slotsByPack: x
4687
4699
  });
4688
4700
  try {
4689
4701
  c.start("Installing pack files...");
4690
- let t = await Fi({
4702
+ let t = await Li({
4691
4703
  packs: E,
4692
4704
  config: a,
4693
- projectRoot: s,
4705
+ projectRoot: o,
4694
4706
  force: e.force ?? !1,
4695
4707
  overwrite: D,
4696
4708
  slotsByPack: x
4697
4709
  });
4698
4710
  if (t.aborted) {
4699
4711
  c.stop("Installation aborted");
4700
- for (let e of t.errors) o.log.error(e);
4701
- o.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
4712
+ for (let e of t.errors) s.log.error(e);
4713
+ s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
4702
4714
  }
4703
- c.stop("Files installed"), t.installed.length > 0 && o.log.success(`${L.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (o.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`), To(t.skipped));
4704
- for (let e of t.errors) o.log.error(e);
4715
+ c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${R.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (s.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`), To(t.skipped));
4716
+ for (let e of t.errors) s.log.error(e);
4705
4717
  await Co({
4706
4718
  prepared: E,
4707
4719
  paths: a.paths,
4708
- cwd: s,
4720
+ cwd: o,
4709
4721
  spinner: c
4710
- }), i && await Xi(s, e.yes ?? !1), await ur({
4711
- projectRoot: s,
4722
+ }), i && await ra(o, e.yes ?? !1), await fr({
4723
+ projectRoot: o,
4712
4724
  paths: a.paths,
4713
4725
  skipPrompts: e.yes ?? !1
4714
- }), wo(E), o.outro(L.brand(`Installed ${t.appliedPacks.join(", ")}.`));
4726
+ }), wo(), s.outro(R.brand(`Installed ${t.appliedPacks.join(", ")}.`));
4715
4727
  } finally {
4716
- await Promise.all(E.map((e) => v.rm(e.packDir, {
4728
+ await Promise.all(E.map((e) => y.rm(e.packDir, {
4717
4729
  recursive: !0,
4718
4730
  force: !0
4719
4731
  })));
4720
4732
  }
4721
4733
  }
4722
- async function Oo(e) {
4734
+ async function Bo(e) {
4723
4735
  let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
4724
4736
  if (i.packs && i.packs.length > 0) {
4725
- let e = i.packs.map(Ao), n = e.filter((e) => !t.some((t) => t.name === e.name));
4726
- return n.length > 0 && (o.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
4737
+ let e = i.packs.map(Ho), n = e.filter((e) => !t.some((t) => t.name === e.name));
4738
+ return n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
4727
4739
  }
4728
- let s = t.filter((e) => n.has(e.name));
4729
- s.length > 0 && o.note(s.map((e) => ` ${L.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
4740
+ let o = t.filter((e) => n.has(e.name));
4741
+ o.length > 0 && s.note(o.map((e) => ` ${R.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
4730
4742
  let c = t.filter((e) => !n.has(e.name));
4731
- if (c.length === 0) return o.outro(L.muted("Every available pack is already installed.")), [];
4732
- let l = P();
4733
- o.note(c.map((e) => ` ${R.arrow} ${L.highlight(e.displayName)} ${_e(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
4734
- let u = Hi(c, { adminAvailable: a }), d = [];
4743
+ if (c.length === 0) return s.outro(R.muted("Every available pack is already installed.")), [];
4744
+ let l = le();
4745
+ s.note(c.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
4746
+ let u = Wi(c, { adminAvailable: a }), d = [];
4735
4747
  for (let e of u) {
4736
4748
  let t = e.packs.map((e) => {
4737
4749
  let t = r(e.name);
@@ -4742,42 +4754,42 @@ async function Oo(e) {
4742
4754
  };
4743
4755
  });
4744
4756
  if (e.mode === "single") {
4745
- let n = await o.select({
4757
+ let n = await s.select({
4746
4758
  message: `Choose a ${e.label.toLowerCase()}`,
4747
4759
  options: t,
4748
4760
  initialValue: e.preselect ?? e.packs[0].name
4749
4761
  });
4750
- if (o.isCancel(n)) return null;
4762
+ if (s.isCancel(n)) return null;
4751
4763
  d.push({
4752
4764
  name: n,
4753
4765
  slot: e.slot
4754
4766
  });
4755
4767
  continue;
4756
4768
  }
4757
- let n = await _a({
4769
+ let n = await wa({
4758
4770
  message: `Select ${e.label.toLowerCase()} to add (optional)`,
4759
4771
  options: t,
4760
4772
  required: !1
4761
4773
  });
4762
- if (p(n)) return null;
4774
+ if (m(n)) return null;
4763
4775
  for (let e of n) d.push({ name: e });
4764
4776
  }
4765
4777
  return d;
4766
4778
  }
4767
- var ko = /@(frontend|admin)$/;
4768
- function Ao(e) {
4769
- let t = e.match(ko);
4779
+ var Vo = /@(frontend|admin)$/;
4780
+ function Ho(e) {
4781
+ let t = e.match(Vo);
4770
4782
  return t ? {
4771
4783
  name: e.slice(0, -t[0].length),
4772
4784
  slot: t[1]
4773
4785
  } : { name: e };
4774
4786
  }
4775
- function jo(e) {
4787
+ function Uo(e) {
4776
4788
  let t = /* @__PURE__ */ new Set(), n = [];
4777
4789
  for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
4778
4790
  return n;
4779
4791
  }
4780
- function Mo(e) {
4792
+ function Wo(e) {
4781
4793
  let t = /* @__PURE__ */ new Map();
4782
4794
  for (let n of e) {
4783
4795
  if (!n.slot) continue;
@@ -4788,41 +4800,258 @@ function Mo(e) {
4788
4800
  }
4789
4801
  //#endregion
4790
4802
  //#region src/commands/login.ts
4791
- async function No() {
4792
- ha(), o.intro(L.brandBold("Log in to Hype Stack")), o.log.step("Opening your browser to sign in...");
4803
+ async function Go() {
4804
+ Sa(), s.intro(R.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
4793
4805
  let e;
4794
4806
  try {
4795
- e = await er({ onUrl: (e) => {
4796
- o.log.info(`If your browser didn't open, visit:\n ${L.path(e)}`);
4807
+ e = await tr({ onUrl: (e) => {
4808
+ s.log.info(`If your browser didn't open, visit:\n ${R.path(e)}`);
4797
4809
  } });
4798
4810
  } catch (e) {
4799
- o.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
4811
+ s.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
4800
4812
  }
4801
- o.outro(L.brand(e.email ? `Logged in as ${e.email}. You can now install packs your organization owns.` : "Logged in. You can now install packs your organization owns."));
4813
+ s.outro(R.brand(e.email ? `Logged in as ${e.email}. You can now install packs your organization owns.` : "Logged in. You can now install packs your organization owns."));
4802
4814
  }
4803
4815
  //#endregion
4804
4816
  //#region src/commands/logout.ts
4805
- async function Po() {
4806
- ha(), o.intro(L.brandBold("Log out of Hype Stack"));
4807
- let e = N(), t = await Gn(e);
4817
+ async function Ko() {
4818
+ Sa(), s.intro(R.brandBold("Log out of Hype Stack"));
4819
+ let e = F(), t = await Kn(e);
4808
4820
  if (!t) {
4809
- o.outro(L.muted("You're not logged in."));
4821
+ s.outro(R.muted("You're not logged in."));
4822
+ return;
4823
+ }
4824
+ await Rn(t.token).catch(() => null), await Jn(e), s.outro(R.brand("Logged out."));
4825
+ }
4826
+ //#endregion
4827
+ //#region src/core/onboard-catalog.ts
4828
+ var $ = {
4829
+ Config: "config",
4830
+ Databases: "databases",
4831
+ Workos: "workos",
4832
+ BetterAuth: "betterauth",
4833
+ Stripe: "stripe",
4834
+ Polar: "polar",
4835
+ Resend: "resend",
4836
+ IpLocate: "iplocate",
4837
+ Sentry: "sentry"
4838
+ }, qo = new Set(Object.values($));
4839
+ function Jo(e) {
4840
+ return e.toLowerCase().replace(/[^a-z0-9]+/g, "").trim();
4841
+ }
4842
+ function Yo(e) {
4843
+ let t = Jo(e);
4844
+ return qo.has(t) ? t : void 0;
4845
+ }
4846
+ var Xo = {
4847
+ [$.Config]: { hint: "App URLs. Defaults work for local dev." },
4848
+ [$.Databases]: { hint: "Credentials for the local Docker Postgres and Valkey containers." },
4849
+ [$.Workos]: {
4850
+ link: "https://dashboard.workos.com/api-keys",
4851
+ hint: "Copy your API Key and Client ID from the WorkOS dashboard."
4852
+ },
4853
+ [$.BetterAuth]: {
4854
+ link: "https://www.better-auth.com/docs/installation#set-environment-variables",
4855
+ hint: "Generate a long random secret, set the app URL, add Google OAuth creds if you use Google."
4856
+ },
4857
+ [$.Stripe]: {
4858
+ link: "https://dashboard.stripe.com/apikeys",
4859
+ hint: "Copy your secret and publishable keys from the Stripe dashboard.",
4860
+ serviceChecklist: [
4861
+ "Recurring prices for Pro and Premier power checkout (set STRIPE_PRICE_PRO and STRIPE_PRICE_PREMIER).",
4862
+ "A webhook at /checkout/webhook keeps subscriptions in sync (subscription events plus invoice.payment_succeeded).",
4863
+ "Enable the Stripe billing portal so Manage Billing and invoices work.",
4864
+ "Enable 'Limit customers to one subscription' to prevent double-checkout races.",
4865
+ "Optional: disable Cash App Pay if you see a high checkout cancel rate."
4866
+ ]
4867
+ },
4868
+ [$.Polar]: {
4869
+ link: "https://polar.sh",
4870
+ hint: "From your Polar org: access token, webhook secret, organization id, and the checkout product id."
4871
+ },
4872
+ [$.Resend]: {
4873
+ link: "https://resend.com/api-keys",
4874
+ hint: "Create an API key in Resend."
4875
+ },
4876
+ [$.IpLocate]: {
4877
+ link: "https://iplocate.io",
4878
+ hint: "Grab your API key from IP Locate."
4879
+ },
4880
+ [$.Sentry]: {
4881
+ link: "https://sentry.io",
4882
+ hint: "Your project DSN. Leave blank to skip Sentry for now."
4883
+ }
4884
+ }, Zo = { hint: "Add your value, or press Enter to leave it blank." };
4885
+ function Qo(e) {
4886
+ let t = Yo(e);
4887
+ return t ? Xo[t] : Zo;
4888
+ }
4889
+ var $o = {
4890
+ "starter-saas-workos": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
4891
+ "starter-saas-betterauth": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
4892
+ "pack-notifications": ["Notifications push over the `appChannel` socket channel; register it in your server startup to go live."],
4893
+ "pack-collaboration": ["Team and TeamMember are available as CASL subjects; project member and team management reuse the existing `Project` subject."]
4894
+ };
4895
+ function es(e) {
4896
+ let t = /* @__PURE__ */ new Set(), n = [];
4897
+ for (let r of e) {
4898
+ let e = $o[r];
4899
+ if (e) for (let r of e) t.has(r) || (t.add(r), n.push(r));
4900
+ }
4901
+ return n;
4902
+ }
4903
+ //#endregion
4904
+ //#region src/core/onboard-env.ts
4905
+ function ts(e) {
4906
+ let t = [], n = "";
4907
+ for (let r of e.split(/\r?\n/)) {
4908
+ let e = r.trim();
4909
+ if (e === "") continue;
4910
+ if (e.startsWith("#")) {
4911
+ let t = e.replace(/^#+\s*/, "").trim();
4912
+ if (t === "" || /^[-=_]+$/.test(t) || t.includes("=")) continue;
4913
+ n = t;
4914
+ continue;
4915
+ }
4916
+ let i = e.indexOf("=");
4917
+ if (i === -1) continue;
4918
+ let a = e.slice(0, i).trim(), o = e.slice(i + 1).trim();
4919
+ if (!a) continue;
4920
+ let s = t.find((e) => e.section === n);
4921
+ s || (s = {
4922
+ section: n,
4923
+ vars: []
4924
+ }, t.push(s)), s.vars.push({
4925
+ key: a,
4926
+ value: o
4927
+ });
4928
+ }
4929
+ return t;
4930
+ }
4931
+ var ns = [
4932
+ "replace-with",
4933
+ "examplepublickey",
4934
+ "change-me",
4935
+ "your-key-here"
4936
+ ];
4937
+ function rs(e) {
4938
+ let t = e.trim();
4939
+ if (t === "") return !0;
4940
+ let n = t.toLowerCase();
4941
+ return ns.some((e) => n.includes(e));
4942
+ }
4943
+ function is(e, t, n) {
4944
+ let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
4945
+ if (i) return e;
4946
+ let r = e.trim();
4947
+ if (r.startsWith(`${t}=`) || r === t) return i = !0, `${t}=${n}`;
4948
+ let a = r.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
4949
+ return a && a[1] === t ? (i = !0, `${t}=${n}`) : e;
4950
+ });
4951
+ return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
4952
+ }
4953
+ async function as(e) {
4954
+ return await J(e) ? y.readFile(e, "utf-8") : "";
4955
+ }
4956
+ async function os(e) {
4957
+ let t = T.join(T.dirname(e), ".env");
4958
+ return await J(t) || await y.copyFile(e, t), t;
4959
+ }
4960
+ async function ss(e, t, n) {
4961
+ let r = is(await as(e), t, n);
4962
+ await y.writeFile(e, r, "utf-8");
4963
+ }
4964
+ //#endregion
4965
+ //#region src/commands/onboard.ts
4966
+ async function cs(e = {}) {
4967
+ let t = e.cwd ?? process.cwd();
4968
+ xa(), s.intro(R.brandBold("Onboard your stack"));
4969
+ let n;
4970
+ try {
4971
+ n = await mr(t);
4972
+ } catch {
4973
+ n = null;
4974
+ }
4975
+ n || (s.cancel(`${R.path("stack.json")} not found. Run ${R.command("npx @hype-stack/cli init")} first.`), process.exit(1));
4976
+ let r = await Ja(t);
4977
+ r.length === 0 && s.log.warn(R.muted("No .env.example files found; skipping env setup."));
4978
+ for (let n of r) await ls(n, t, e.yes ?? !1);
4979
+ let i = es(n.installedPacks ?? []);
4980
+ i.length > 0 && s.note(i.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await fs(t, e.yes ?? !1), s.outro(R.brand(`All set. Run ${R.command("pnpm dev")} to start your app.`));
4981
+ }
4982
+ async function ls(e, t, n) {
4983
+ let r = T.relative(t, e) || e, i = await os(e), a = await as(i), o = ts(await y.readFile(e, "utf-8")), c = R.path(r);
4984
+ s.log.step(`Env: ${c}`);
4985
+ for (let e of o) {
4986
+ let t = e.vars.filter((e) => rs(e.value));
4987
+ if (t.length === 0) continue;
4988
+ let r = Qo(e.section), o = e.section ? R.bold(e.section) : R.bold("Variables");
4989
+ s.log.step(o), r.link && (s.log.info(`${R.muted("Get your values:")} ${_e(r.link)}`), r.serviceChecklist && r.serviceChecklist.length > 0 && s.note(r.serviceChecklist.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Setup")), s.log.info(R.muted(r.hint));
4990
+ for (let e of t) {
4991
+ if (n) {
4992
+ s.log.info(`${R.label(e.key)} ${R.muted("skipped (non-interactive)")}`);
4993
+ continue;
4994
+ }
4995
+ let t = us(a, e.key), o = await s.text({
4996
+ message: `${R.label(e.key)}`,
4997
+ placeholder: t || r.hint
4998
+ });
4999
+ s.isCancel(o) && X();
5000
+ let c = (o ?? "").trim();
5001
+ if (c === "") {
5002
+ s.log.warn(R.muted(`${e.key} left blank.`));
5003
+ continue;
5004
+ }
5005
+ await ss(i, e.key, c), s.log.success(`${e.key} saved`);
5006
+ }
5007
+ }
5008
+ }
5009
+ function us(e, t) {
5010
+ for (let n of e.split(/\r?\n/)) {
5011
+ let e = n.match(RegExp(`^${ds(t)}\\s*=\\s*(.*)$`));
5012
+ if (e) return e[1].trim();
5013
+ }
5014
+ return "";
5015
+ }
5016
+ function ds(e) {
5017
+ return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5018
+ }
5019
+ async function fs(e, t) {
5020
+ if (!await qi() && !await Yi(e, t, !1)) {
5021
+ s.log.info(R.muted(`Start services later with ${R.command("docker compose up -d")} (in apps/backend), then ${R.command("pnpm --filter @internal/backend migration:latest")}.`));
5022
+ return;
5023
+ }
5024
+ let n = s.spinner();
5025
+ if (n.start("Waiting for Postgres to be ready..."), !await Zi(e)) {
5026
+ n.error("Postgres health check timed out"), s.log.warn(R.muted(`Run migrations manually once Postgres is ready: ${R.command("pnpm --filter @internal/backend migration:latest")}`));
5027
+ return;
5028
+ }
5029
+ if (n.stop(R.success("Postgres is ready")), await $i(e)) {
5030
+ s.log.info(R.muted("Migrations already applied, skipping."));
4810
5031
  return;
4811
5032
  }
4812
- await Ln(t.token).catch(() => null), await qn(e), o.outro(L.brand("Logged out."));
5033
+ let r = t ? !0 : await s.confirm({
5034
+ message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
5035
+ initialValue: !0
5036
+ });
5037
+ if (s.isCancel(r) && X(), !r) {
5038
+ s.log.info(R.muted("Skipping database migrations."));
5039
+ return;
5040
+ }
5041
+ await ea(e);
4813
5042
  }
4814
5043
  //#endregion
4815
5044
  //#region src/core/templates.ts
4816
- var Fo = K.createRequest()({
5045
+ var ps = K.createRequest()({
4817
5046
  endpoint: "/templates/list",
4818
5047
  method: "GET"
4819
5048
  });
4820
- async function Io() {
4821
- let { data: e, error: t } = await Fo.send();
5049
+ async function ms() {
5050
+ let { data: e, error: t } = await ps.send();
4822
5051
  if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
4823
5052
  return e.templates;
4824
5053
  }
4825
- async function Lo(e) {
5054
+ async function hs(e) {
4826
5055
  let { data: t, error: n, status: r } = await K.createRequest()({
4827
5056
  endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
4828
5057
  method: "GET"
@@ -4831,13 +5060,13 @@ async function Lo(e) {
4831
5060
  if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
4832
5061
  return t;
4833
5062
  }
4834
- async function Ro(e, t = {}) {
5063
+ async function gs(e, t = {}) {
4835
5064
  let n = K.createRequest()({
4836
5065
  endpoint: `/templates/${encodeURIComponent(e)}/download`,
4837
5066
  method: "POST"
4838
5067
  }), r = {
4839
- "X-Device-Id": Yn(),
4840
- "X-Client-Info": Xn()
5068
+ "X-Device-Id": Xn(),
5069
+ "X-Client-Info": Zn()
4841
5070
  };
4842
5071
  t.token && (r.Authorization = `Bearer ${t.token}`);
4843
5072
  let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
@@ -4848,10 +5077,10 @@ async function Ro(e, t = {}) {
4848
5077
  packs: i.packs ?? [],
4849
5078
  expiresAt: i.expiresAt ?? null
4850
5079
  };
4851
- let s = await v.mkdtemp(w.join(C.tmpdir(), `hype-stack-template-${e}-`));
5080
+ let s = await y.mkdtemp(T.join(w.tmpdir(), `hype-stack-template-${e}-`));
4852
5081
  return await Promise.all(i.files.map(async (e) => {
4853
- let t = w.join(s, ...e.path.split("/"));
4854
- await v.mkdir(w.dirname(t), { recursive: !0 }), await v.writeFile(t, Buffer.from(e.content, "base64"));
5082
+ let t = T.join(s, ...e.path.split("/"));
5083
+ await y.mkdir(T.dirname(t), { recursive: !0 }), await y.writeFile(t, Buffer.from(e.content, "base64"));
4855
5084
  })), {
4856
5085
  status: "ok",
4857
5086
  templateDir: s
@@ -4859,172 +5088,184 @@ async function Ro(e, t = {}) {
4859
5088
  }
4860
5089
  //#endregion
4861
5090
  //#region src/commands/template.ts
4862
- async function zo(e = {}) {
4863
- let t = e.cwd ?? process.cwd();
4864
- ma();
4865
- let n = await mo(t), a = n?.projectRoot ?? null, s = n?.scaffolded ?? !1, c;
4866
- try {
4867
- c = await fr(a ?? t);
4868
- } catch (e) {
4869
- o.cancel(`Could not parse ${L.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
4870
- }
4871
- c || (o.cancel(a ? `Could not read ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), process.exit(1)), c.paths || (o.cancel(`${L.path("stack.json")} is missing ${L.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
4872
- let l = a ?? t;
4873
- o.intro(L.brandBold("Install a template"));
4874
- let u = o.spinner();
4875
- u.start("Loading packs...");
4876
- let d;
5091
+ async function _s(t = {}) {
5092
+ let n = t.cwd ?? process.cwd();
5093
+ xa();
5094
+ let r = s.spinner();
5095
+ r.start("Loading packs...");
5096
+ let o;
4877
5097
  try {
4878
- d = await wr();
5098
+ o = await Er();
4879
5099
  } catch (e) {
4880
- u.stop("Failed to load packs"), o.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
5100
+ r.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${Q(e)}`), process.exit(1);
4881
5101
  }
4882
- u.stop("Packs loaded");
4883
- let f = c.installedPacks ?? [], p = new Set(f), m = new Map(d.map((e) => [e.name, e])), h = e.licenseKey ?? c.licenseKey ?? null, g = (await Gn(N()))?.token ?? null;
4884
- u.start("Loading templates...");
4885
- let _;
5102
+ r.stop("Packs loaded"), r.start("Loading templates...");
5103
+ let c;
4886
5104
  try {
4887
- _ = await Io();
5105
+ c = await ms();
4888
5106
  } catch (e) {
4889
- u.stop("Failed to load templates"), o.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
4890
- }
4891
- let y = e.templateId;
4892
- if (!y) {
4893
- e.yes && (u.stop("Template id required"), o.cancel("Pass a template id with `npx @hype-stack/cli template <id>` (required in --yes mode)."), process.exit(1)), _.length === 0 && (u.stop("No templates available"), o.cancel("No templates are available yet. Check back later."), process.exit(1)), u.stop("Templates loaded");
4894
- let t = P();
4895
- o.note(_.map((e) => ` ${R.arrow} ${L.highlight(e.name)} ${_e(`${t}/templates/${e.id}`)}`).join("\n"), "Browse templates");
4896
- let n = await o.select({
5107
+ r.stop("Failed to load templates"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${Q(e)}`), process.exit(1);
5108
+ }
5109
+ let l = t.templateId;
5110
+ if (!l) {
5111
+ t.yes && (r.stop("Template id required"), s.cancel("Pass a template id with `npx @hype-stack/cli template <id>` (required in --yes mode)."), process.exit(1)), c.length === 0 && (r.stop("No templates available"), s.cancel("No templates are available yet. Check back later."), process.exit(1)), r.stop("Templates loaded");
5112
+ let e = le();
5113
+ s.note(c.map((t) => ` ${z.arrow} ${R.highlight(t.name)} ${_e(`${e}/templates/${t.id}`)}`).join("\n"), "Browse templates");
5114
+ let n = await s.select({
4897
5115
  message: "Choose a template",
4898
- options: _.map((e) => ({
5116
+ options: c.map((e) => ({
4899
5117
  value: e.id,
4900
5118
  label: e.name,
4901
5119
  hint: e.description
4902
5120
  }))
4903
5121
  });
4904
- o.isCancel(n) && (o.cancel("Cancelled."), process.exit(0)), y = n;
4905
- }
4906
- let b = _.find((e) => e.id === y);
4907
- b || (u.stop("Template not found"), o.cancel(`Template "${y}" not found. Available: ${_.map((e) => e.id).join(", ") || "(none)"}`), process.exit(1)), u.stop(`Template: ${b.name}`);
4908
- let x = await Bo(b, e.variants, e.yes ?? !1), S = ta(b.slots, x), C = na(b.slots, b.packs, S), T = await Vo({
4909
- packs: d,
4910
- templatePacks: C,
4911
- installedSet: p,
4912
- options: e
4913
- }), E = [...C, ...T.filter((e) => !C.includes(e))], D = E.filter((e) => !m.has(e));
4914
- D.length > 0 && (o.cancel(`Unknown pack${D.length === 1 ? "" : "s"}: ${D.join(", ")}`), process.exit(1));
4915
- let O = aa(d, S), ee = Zi(O), k;
5122
+ s.isCancel(n) && (s.cancel("Cancelled."), process.exit(0)), l = n;
5123
+ }
5124
+ let u = c.find((e) => e.id === l);
5125
+ u || (r.stop("Template not found"), s.cancel(`Template "${l}" not found. Available: ${c.map((e) => e.id).join(", ") || "(none)"}`), process.exit(1)), r.stop(`Template: ${u.name}`);
5126
+ let d;
5127
+ try {
5128
+ d = await hs(u.id);
5129
+ } catch (e) {
5130
+ s.cancel(Q(e)), process.exit(1);
5131
+ }
5132
+ let f = await Ro(n, {}, {
5133
+ defaultTheme: d.theme,
5134
+ defaultMode: d.defaultMode
5135
+ }), p = f?.projectRoot ?? null, m = f?.scaffolded ?? !1, h;
5136
+ try {
5137
+ h = await mr(p ?? n);
5138
+ } catch (e) {
5139
+ s.cancel(`Could not parse ${R.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
5140
+ }
5141
+ h || (s.cancel(p ? `Could not read ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), process.exit(1)), h.paths || (s.cancel(`${R.path("stack.json")} is missing ${R.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
5142
+ let g = p ?? n;
5143
+ s.intro(R.brandBold("Install a template"));
5144
+ let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await Kn(F()))?.token ?? null, C = await vs(u, t.variants, t.yes ?? !1), w = ca(u.slots, C), E = la(u.slots, u.packs, w), D = await ys({
5145
+ packs: o,
5146
+ templatePacks: E,
5147
+ installedSet: v,
5148
+ options: t
5149
+ }), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
5150
+ k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
5151
+ let ee = fa(o, w), A = ia(ee), te;
4916
5152
  try {
4917
- k = $i(E, ee, f);
5153
+ te = oa(O, A, _);
4918
5154
  } catch (e) {
4919
- o.cancel($(e)), process.exit(1);
5155
+ s.cancel(Q(e)), process.exit(1);
4920
5156
  }
4921
- if (k.order.length === 0) {
4922
- o.outro(L.muted("Every pack in this template is already installed."));
5157
+ if (te.order.length === 0) {
5158
+ s.outro(R.muted("Every pack in this template is already installed."));
4923
5159
  return;
4924
5160
  }
4925
- let te = await vo(O, p, {
4926
- token: g,
4927
- key: h
4928
- }), ne = (e) => {
4929
- let t = m.get(e);
4930
- return !t || t.tier === "free" ? "free" : te[e]?.owned ? "owned" : "locked";
4931
- }, re = (e) => !p.has(e) && ne(e) === "locked", A = ea({
4932
- order: k.order,
4933
- graph: ee,
4934
- isLocked: re,
4935
- installed: f
5161
+ let ne = await vo(ee, v, {
5162
+ token: S,
5163
+ key: x
5164
+ }), re = (e) => {
5165
+ let t = b.get(e);
5166
+ return !t || t.tier === "free" ? "free" : ne[e]?.owned ? "owned" : "locked";
5167
+ }, j = (e) => !v.has(e) && re(e) === "locked", M = sa({
5168
+ order: te.order,
5169
+ graph: A,
5170
+ isLocked: j,
5171
+ installed: _
4936
5172
  });
4937
- if (A.blocked.length > 0 && !g && !h) {
4938
- let e = await tr();
4939
- e && (g = e, te = await vo(O, p, {
4940
- token: g,
4941
- key: h
4942
- }), A = ea({
4943
- order: k.order,
4944
- graph: ee,
4945
- isLocked: re,
4946
- installed: f
5173
+ if (M.blocked.length > 0 && !S && !x) {
5174
+ let e = await nr();
5175
+ e && (S = e, ne = await vo(ee, v, {
5176
+ token: S,
5177
+ key: x
5178
+ }), M = sa({
5179
+ order: te.order,
5180
+ graph: A,
5181
+ isLocked: j,
5182
+ installed: _
4947
5183
  }));
4948
5184
  }
4949
- if (A.blocked.length > 0 && await bo(A.blocked, re, m), A.installable.length === 0) {
4950
- o.outro(L.muted("Nothing left to install once locked packs are removed."));
5185
+ if (M.blocked.length > 0 && await bo(M.blocked, j, b), M.installable.length === 0) {
5186
+ s.outro(R.muted("Nothing left to install once locked packs are removed."));
4951
5187
  return;
4952
5188
  }
4953
- if (xo(A.installable, m), !e.yes) {
4954
- let e = await o.confirm({ message: `Install template ${L.brandBold(b.name)} (${A.installable.length} pack${A.installable.length === 1 ? "" : "s"})?` });
4955
- (o.isCancel(e) || !e) && (o.cancel("Installation cancelled."), process.exit(0));
5189
+ if (xo(M.installable, b), !t.yes) {
5190
+ let e = await s.confirm({ message: `Install template ${R.brandBold(u.name)} (${M.installable.length} pack${M.installable.length === 1 ? "" : "s"})?` });
5191
+ (s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
4956
5192
  }
4957
- u.start("Downloading packs...");
4958
- let j;
5193
+ r.start("Downloading packs...");
5194
+ let N;
4959
5195
  try {
4960
- j = await So(A.installable, {
4961
- token: g,
4962
- key: h
5196
+ N = await So(M.installable, {
5197
+ token: S,
5198
+ key: x
4963
5199
  });
4964
5200
  } catch (e) {
4965
- u.stop("Download failed"), o.cancel($(e)), process.exit(1);
5201
+ r.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
4966
5202
  }
4967
- u.stop(`Downloaded ${j.length} pack${j.length === 1 ? "" : "s"}`);
5203
+ r.stop(`Downloaded ${N.length} pack${N.length === 1 ? "" : "s"}`);
4968
5204
  let ie = await Eo({
4969
- prepared: j,
4970
- config: c,
4971
- cwd: l,
4972
- force: e.force ?? !1,
4973
- yes: e.yes ?? !1
4974
- }), M = null;
5205
+ prepared: N,
5206
+ config: h,
5207
+ cwd: g,
5208
+ force: t.force ?? !1,
5209
+ yes: t.yes ?? !1
5210
+ }), P = null;
4975
5211
  try {
4976
- u.start("Installing pack files...");
4977
- let t = await Fi({
4978
- packs: j,
4979
- config: c,
4980
- projectRoot: l,
4981
- force: e.force ?? !1,
5212
+ r.start("Installing pack files...");
5213
+ let n = await Li({
5214
+ packs: N,
5215
+ config: h,
5216
+ projectRoot: g,
5217
+ force: t.force ?? !1,
4982
5218
  overwrite: ie
4983
5219
  });
4984
- if (t.aborted) {
4985
- u.stop("Installation aborted");
4986
- for (let e of t.errors) o.log.error(e);
4987
- o.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
5220
+ if (n.aborted) {
5221
+ r.stop("Installation aborted");
5222
+ for (let e of n.errors) s.log.error(e);
5223
+ s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
4988
5224
  }
4989
- u.stop("Files installed"), t.installed.length > 0 && o.log.success(`${L.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (o.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`), To(t.skipped));
4990
- for (let e of t.errors) o.log.error(e);
4991
- u.start("Applying template overrides...");
4992
- let n = await Lo(b.id), a = await Ro(b.id, {
4993
- token: g,
4994
- licenseKey: h
5225
+ r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${R.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && (s.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`), To(n.skipped));
5226
+ for (let e of n.errors) s.log.error(e);
5227
+ r.start("Applying template overrides...");
5228
+ let o = await gs(u.id, {
5229
+ token: S,
5230
+ licenseKey: x
4995
5231
  });
4996
- a.status === "denied" && (u.stop("Template download denied"), o.cancel(`Access to template "${b.id}" was denied (${a.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)), M = a.templateDir;
4997
- let d = await Li({
4998
- manifest: n,
4999
- config: c,
5000
- projectRoot: l,
5001
- templateDir: M
5232
+ o.status === "denied" && (r.stop("Template download denied"), s.cancel(`Access to template "${u.id}" was denied (${o.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)), P = o.templateDir;
5233
+ let c = await zi({
5234
+ manifest: d,
5235
+ config: h,
5236
+ projectRoot: g,
5237
+ templateDir: P
5002
5238
  });
5003
- u.stop("Template overrides applied"), d.installed.length > 0 && o.log.success(`${d.installed.length} template file${d.installed.length === 1 ? "" : "s"} applied`);
5004
- for (let e of d.errors) o.log.error(e);
5005
- let f = n.theme ?? "zinc-mono";
5006
- i(f) && (await Ca(w.resolve(l, c.paths?.frontend.root ?? "apps/frontend"), r(f)) ? o.log.success(`Applied the ${r(f).label} theme`) : o.log.warning(L.muted(`Could not find ${L.path("assets/styles.css")} to apply the theme`))), await Ho({
5007
- prepared: j,
5008
- templateNpm: n.dependencies_npm,
5009
- paths: c.paths,
5010
- cwd: l,
5011
- spinner: u
5012
- }), s && await Xi(l, e.yes ?? !1), await ur({
5013
- projectRoot: l,
5014
- paths: c.paths,
5015
- skipPrompts: e.yes ?? !1
5016
- }), wo(j), n.postInstall && n.postInstall.length > 0 && o.note(n.postInstall.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Template Next Steps"), o.outro(L.brand(`Installed template ${b.name}.`));
5239
+ r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
5240
+ for (let e of c.errors) s.log.error(e);
5241
+ if (!m) {
5242
+ let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
5243
+ a(n) && (await La(t, i(n)) ? s.log.success(`Applied the ${i(n).label} theme`) : s.log.warning(R.muted(`Could not find ${R.path("assets/styles.css")} to apply the theme`)));
5244
+ let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
5245
+ await ja(t, r) ? s.log.success(`Default color mode set to ${r}`) : s.log.warning(R.muted(`Could not find ${R.path("src/hooks/use-theme.ts")} to set the default color mode`));
5246
+ }
5247
+ await bs({
5248
+ prepared: N,
5249
+ templateNpm: d.dependencies_npm,
5250
+ paths: h.paths,
5251
+ cwd: g,
5252
+ spinner: r
5253
+ }), m && await ra(g, t.yes ?? !1), await fr({
5254
+ projectRoot: g,
5255
+ paths: h.paths,
5256
+ skipPrompts: t.yes ?? !1
5257
+ }), wo(), s.outro(R.brand(`Installed template ${u.name}.`));
5017
5258
  } finally {
5018
- await Promise.all(j.map((e) => v.rm(e.packDir, {
5259
+ await Promise.all(N.map((e) => y.rm(e.packDir, {
5019
5260
  recursive: !0,
5020
5261
  force: !0
5021
- }))), M && await v.rm(M, {
5262
+ }))), P && await y.rm(P, {
5022
5263
  recursive: !0,
5023
5264
  force: !0
5024
5265
  });
5025
5266
  }
5026
5267
  }
5027
- async function Bo(e, t, n) {
5268
+ async function vs(e, t, n) {
5028
5269
  let r = {};
5029
5270
  for (let i of e.slots) {
5030
5271
  if (t?.[i.family]) {
@@ -5039,56 +5280,56 @@ async function Bo(e, t, n) {
5039
5280
  value: e,
5040
5281
  label: e,
5041
5282
  hint: e === i.default ? "default" : void 0
5042
- })), a = await o.select({
5283
+ })), a = await s.select({
5043
5284
  message: `Choose a ${i.family}`,
5044
5285
  options: e,
5045
5286
  initialValue: i.default
5046
5287
  });
5047
- o.isCancel(a) && (o.cancel("Cancelled."), process.exit(0)), r[i.family] = a;
5288
+ s.isCancel(a) && (s.cancel("Cancelled."), process.exit(0)), r[i.family] = a;
5048
5289
  }
5049
5290
  return r;
5050
5291
  }
5051
- async function Vo(e) {
5292
+ async function ys(e) {
5052
5293
  let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
5053
5294
  if (i.packs && i.packs.length > 0) {
5054
5295
  let e = i.packs.filter((e) => !t.some((t) => t.name === e));
5055
- return e.length > 0 && (o.cancel(`Unknown pack${e.length === 1 ? "" : "s"}: ${e.join(", ")}`), process.exit(1)), i.packs.filter((e) => !a.has(e));
5296
+ return e.length > 0 && (s.cancel(`Unknown pack${e.length === 1 ? "" : "s"}: ${e.join(", ")}`), process.exit(1)), i.packs.filter((e) => !a.has(e));
5056
5297
  }
5057
5298
  if (i.yes) return [];
5058
- let s = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
5059
- if (s.length === 0) return [];
5060
- let c = P();
5061
- o.note(s.map((e) => ` ${R.arrow} ${L.highlight(e.displayName)} ${_e(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
5062
- let l = await _a({
5299
+ let o = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
5300
+ if (o.length === 0) return [];
5301
+ let c = le();
5302
+ s.note(o.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
5303
+ let l = await wa({
5063
5304
  message: "Add extra packs on top of the template (optional)",
5064
- options: s.map((e) => ({
5305
+ options: o.map((e) => ({
5065
5306
  value: e.name,
5066
5307
  label: e.displayName,
5067
5308
  hint: e.description
5068
5309
  })),
5069
5310
  required: !1
5070
5311
  });
5071
- return p(l) && (o.cancel("Cancelled."), process.exit(0)), l;
5312
+ return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
5072
5313
  }
5073
- async function Ho(e) {
5074
- let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, s = go(t.map((e) => e.manifest.dependencies_npm)), c = ho(n ? go([s, n]) : s, r);
5314
+ async function bs(e) {
5315
+ let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o = go(t.map((e) => e.manifest.dependencies_npm)), c = ho(n ? go([o, n]) : o, r);
5075
5316
  if (c.errors.length > 0) {
5076
- for (let e of c.errors) o.log.error(e);
5317
+ for (let e of c.errors) s.log.error(e);
5077
5318
  return;
5078
5319
  }
5079
5320
  if (c.operations.length === 0) return;
5080
5321
  a.start("Installing npm dependencies...");
5081
5322
  let l = await _o(c.operations, i);
5082
- if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) o.log.error(e);
5323
+ if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) s.log.error(e);
5083
5324
  }
5084
5325
  //#endregion
5085
5326
  //#region src/cli.ts
5086
- function Uo(e) {
5327
+ function xs(e) {
5087
5328
  if (!e) return;
5088
5329
  let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
5089
5330
  return t.length > 0 ? t : void 0;
5090
5331
  }
5091
- function Wo(e) {
5332
+ function Ss(e) {
5092
5333
  if (!e) return;
5093
5334
  let t = {};
5094
5335
  for (let n of e.split(",")) {
@@ -5097,10 +5338,10 @@ function Wo(e) {
5097
5338
  }
5098
5339
  return Object.keys(t).length > 0 ? t : void 0;
5099
5340
  }
5100
- function Go() {
5101
- let e = new a();
5102
- return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(k, "-v, --version"), e.command("create").description("Create a new Hype Stack project").option("-n, --name <name>", "Project name").option("-d, --directory <path>", "Target directory").option("-e, --editor <editor>", "Code editor (cursor, claude, windsurf, copilot)").option("-t, --theme <theme>", "Color theme (default, slate, rose, emerald, violet, amber, ocean, zinc-mono, crimson, midnight)").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) => {
5103
- await fo({
5341
+ function Cs() {
5342
+ let e = new o();
5343
+ return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(A, "-v, --version"), e.command("create").description("Create a new Hype Stack project").option("-n, --name <name>", "Project name").option("-d, --directory <path>", "Target directory").option("-e, --editor <editor>", "Code editor (cursor, claude, windsurf, copilot)").option("-t, --theme <theme>", "Color theme (default, slate, rose, emerald, violet, amber, ocean, zinc-mono, crimson, midnight)").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) => {
5344
+ await Io({
5104
5345
  name: e.name,
5105
5346
  directory: e.directory,
5106
5347
  install: e.install,
@@ -5110,32 +5351,38 @@ function Go() {
5110
5351
  setup: e.setup
5111
5352
  });
5112
5353
  }), e.command("init").description("Initialize stack.json in the current project").action(async () => {
5113
- await po({});
5354
+ await Lo({});
5355
+ }), e.command("onboard").description("Set up env vars, run migrations, and get the start command").option("-y, --yes", "Skip prompts, accept defaults").option("--skip-migrations", "Skip Docker services and database migrations").option("--cwd <path>", "Working directory").action(async (e) => {
5356
+ await cs({
5357
+ cwd: e.cwd,
5358
+ yes: e.yes,
5359
+ skipMigrations: e.skipMigrations
5360
+ });
5114
5361
  }), 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("-k, --key <key>", "License key").option("--license-key <key>", "License key (alias for --key)").option("--cwd <path>", "Working directory").action(async (e) => {
5115
- await Do({
5116
- packs: Uo(e.packs),
5362
+ await zo({
5363
+ packs: xs(e.packs),
5117
5364
  force: e.force,
5118
5365
  yes: e.yes,
5119
5366
  licenseKey: e.key ?? e.licenseKey,
5120
5367
  cwd: e.cwd
5121
5368
  });
5122
5369
  }), 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("-k, --key <key>", "License key").option("--license-key <key>", "License key (alias for --key)").option("--cwd <path>", "Working directory").action(async (e, t) => {
5123
- await zo({
5370
+ await _s({
5124
5371
  templateId: e,
5125
- variants: Wo(t.variants),
5126
- packs: Uo(t.packs),
5372
+ variants: Ss(t.variants),
5373
+ packs: xs(t.packs),
5127
5374
  force: t.force,
5128
5375
  yes: t.yes,
5129
5376
  licenseKey: t.key ?? t.licenseKey,
5130
5377
  cwd: t.cwd
5131
5378
  });
5132
5379
  }), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
5133
- await No();
5380
+ await Go();
5134
5381
  }), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
5135
- await Po();
5382
+ await Ko();
5136
5383
  }), e.command("auth").description("Alias for `login`").action(async () => {
5137
- await No();
5384
+ await Go();
5138
5385
  }), e;
5139
5386
  }
5140
5387
  //#endregion
5141
- export { mo as a, Do as i, Po as n, po as o, No as r, fo as s, Go as t };
5388
+ export { Ro as a, zo as i, Ko as n, Lo as o, Go as r, Io as s, Cs as t };