@hype-stack/cli 0.7.1 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-DBnCO9P6.js → cli-BgRjXUgD.js} +778 -752
- package/dist/commands/template.d.ts.map +1 -1
- package/dist/config/bin.js +939 -651
- package/dist/constants/themes.d.ts +7 -1
- package/dist/constants/themes.d.ts.map +1 -1
- package/dist/core/codemods.d.ts +14 -0
- package/dist/core/codemods.d.ts.map +1 -1
- package/dist/core/installer.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/themes.js +272 -27
- package/dist/types/types.d.ts +24 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -13,7 +13,7 @@ import { Prompt as O } from "@clack/core";
|
|
|
13
13
|
import { styleText as k } from "node:util";
|
|
14
14
|
import { downloadTemplate as A } from "giget";
|
|
15
15
|
//#region src/constants/constants.ts
|
|
16
|
-
var j = "0.
|
|
16
|
+
var j = "0.8.1", ee = "gh:BetterTyped/hype-stack", te = "stack.json", ne = "/schema/stack.json", M = "https://api.hype-stack.dev", N = "HYPE_STACK_API_URL", P = "https://www.hype-stack.dev", re = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, F = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -31,70 +31,70 @@ var j = "0.7.1", ee = "gh:BetterTyped/hype-stack", M = "stack.json", te = "/sche
|
|
|
31
31
|
value: "copilot",
|
|
32
32
|
label: "GitHub Copilot"
|
|
33
33
|
}
|
|
34
|
-
],
|
|
35
|
-
function
|
|
34
|
+
], ie = F.map((e) => e.value), ae = ".cursor/rules", oe = ".cursor", se = ".agents";
|
|
35
|
+
function I() {
|
|
36
36
|
let e = process.env.HYPE_STACK_API_URL;
|
|
37
|
-
return e ? (
|
|
37
|
+
return e ? (le(e), e.replace(/\/+$/, "")) : M;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function ce() {
|
|
40
40
|
let e = process.env.HYPE_STACK_WEB_URL;
|
|
41
|
-
return e ? (
|
|
41
|
+
return e ? (le(e), e.replace(/\/+$/, "")) : P;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function le(e) {
|
|
44
44
|
try {
|
|
45
45
|
let t = new URL(e);
|
|
46
|
-
if (!t.protocol.startsWith("http")) throw Error(`${
|
|
46
|
+
if (!t.protocol.startsWith("http")) throw Error(`${N} must use http or https protocol, got "${t.protocol}"`);
|
|
47
47
|
} catch (t) {
|
|
48
|
-
throw t instanceof TypeError ? Error(`${
|
|
48
|
+
throw t instanceof TypeError ? Error(`${N} is not a valid URL: "${e}"`, { cause: t }) : t;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return `${
|
|
51
|
+
function ue() {
|
|
52
|
+
return `${I()}${ne}`;
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/ui/theme.ts
|
|
56
|
-
var
|
|
57
|
-
orange:
|
|
58
|
-
orangeBright:
|
|
59
|
-
amber:
|
|
60
|
-
deepBlue:
|
|
61
|
-
skyBlue:
|
|
56
|
+
var de = (e) => `\x1b[38;5;208m${e}\x1b[39m`, fe = (e) => `\x1b[38;5;214m${e}\x1b[39m`, pe = (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
|
+
orange: de,
|
|
58
|
+
orangeBright: fe,
|
|
59
|
+
amber: pe,
|
|
60
|
+
deepBlue: me,
|
|
61
|
+
skyBlue: L,
|
|
62
62
|
lightBlue: he
|
|
63
63
|
}, R = {
|
|
64
|
-
brand: (e) =>
|
|
65
|
-
brandBold: (e) => b.bold(
|
|
66
|
-
accent: (e) =>
|
|
67
|
-
accentBold: (e) => b.bold(
|
|
64
|
+
brand: (e) => de(e),
|
|
65
|
+
brandBold: (e) => b.bold(de(e)),
|
|
66
|
+
accent: (e) => L(e),
|
|
67
|
+
accentBold: (e) => b.bold(L(e)),
|
|
68
68
|
success: (e) => b.green(e),
|
|
69
69
|
error: (e) => b.red(e),
|
|
70
70
|
warning: (e) => b.yellow(e),
|
|
71
71
|
muted: (e) => b.dim(e),
|
|
72
72
|
bold: (e) => b.bold(e),
|
|
73
73
|
highlight: (e) => b.bold(b.white(e)),
|
|
74
|
-
path: (e) => b.underline(
|
|
75
|
-
command: (e) => b.bold(
|
|
74
|
+
path: (e) => b.underline(L(e)),
|
|
75
|
+
command: (e) => b.bold(pe(e)),
|
|
76
76
|
label: (e) => b.dim(b.bold(e))
|
|
77
77
|
};
|
|
78
78
|
function _e(e, t = e) {
|
|
79
|
-
return `\x1b]8;;${e}\x07${
|
|
79
|
+
return `\x1b]8;;${e}\x07${L(t)}\x1b]8;;\x07`;
|
|
80
80
|
}
|
|
81
81
|
var z = {
|
|
82
|
-
arrow:
|
|
82
|
+
arrow: de("›"),
|
|
83
83
|
bullet: R.muted("·"),
|
|
84
84
|
dash: R.muted("─"),
|
|
85
85
|
corner: R.muted("╰"),
|
|
86
86
|
pipe: R.muted("│"),
|
|
87
87
|
dot: R.muted("•"),
|
|
88
|
-
spark:
|
|
89
|
-
sparkSmall:
|
|
90
|
-
bolt:
|
|
88
|
+
spark: pe("✦"),
|
|
89
|
+
sparkSmall: fe("✧"),
|
|
90
|
+
bolt: pe("⚡")
|
|
91
91
|
}, ve = [
|
|
92
|
-
|
|
92
|
+
pe,
|
|
93
|
+
pe,
|
|
93
94
|
fe,
|
|
94
95
|
de,
|
|
95
|
-
ue,
|
|
96
|
-
pe,
|
|
97
96
|
me,
|
|
97
|
+
L,
|
|
98
98
|
he,
|
|
99
99
|
he
|
|
100
100
|
];
|
|
@@ -136,7 +136,7 @@ function V() {
|
|
|
136
136
|
//#endregion
|
|
137
137
|
//#region src/core/license.ts
|
|
138
138
|
function Te(e) {
|
|
139
|
-
return `${
|
|
139
|
+
return `${ce()}/packs/${e}`;
|
|
140
140
|
}
|
|
141
141
|
//#endregion
|
|
142
142
|
//#region ../../node_modules/.pnpm/@hyper-fetch+core@8.1.1/node_modules/@hyper-fetch/core/dist/index.mjs
|
|
@@ -588,16 +588,16 @@ var Ee = Object.create, De = Object.defineProperty, Oe = Object.getOwnPropertyDe
|
|
|
588
588
|
constructor(e) {
|
|
589
589
|
super("Unexpected error"), this.description = e, this.name = "UnexpectedError";
|
|
590
590
|
}
|
|
591
|
-
},
|
|
591
|
+
}, U = (e) => e === "timeout" ? new jt() : e === "abort" ? new Mt() : e === "deleted" ? new Nt() : e === "processing" ? new Pt() : new Ft(), It = (e) => {
|
|
592
592
|
try {
|
|
593
593
|
return JSON.stringify(e);
|
|
594
594
|
} catch {
|
|
595
595
|
return "";
|
|
596
596
|
}
|
|
597
|
-
},
|
|
597
|
+
}, Lt = (e) => {
|
|
598
598
|
let t = Be() && e.payload instanceof FormData, n = typeof e.payload == "object" && e.payload !== null, r = {};
|
|
599
599
|
return !t && n && (r["Content-Type"] = "application/json"), Object.assign(r, e.headers), r;
|
|
600
|
-
},
|
|
600
|
+
}, Rt = (e) => Be() && e instanceof FormData ? e : It(e), zt = [
|
|
601
601
|
"onBeforeSent",
|
|
602
602
|
"onRequestStart",
|
|
603
603
|
"onResponseStart",
|
|
@@ -606,7 +606,7 @@ var Ee = Object.create, De = Object.defineProperty, Oe = Object.getOwnPropertyDe
|
|
|
606
606
|
"onResponse",
|
|
607
607
|
"onRemove"
|
|
608
608
|
];
|
|
609
|
-
function
|
|
609
|
+
function Bt(e) {
|
|
610
610
|
let t = {
|
|
611
611
|
onBeforeSent: [],
|
|
612
612
|
onRequestStart: [],
|
|
@@ -616,7 +616,7 @@ function Vt(e) {
|
|
|
616
616
|
onResponse: [],
|
|
617
617
|
onRemove: []
|
|
618
618
|
};
|
|
619
|
-
e &&
|
|
619
|
+
e && zt.forEach((n) => {
|
|
620
620
|
t[n] = [...e[n]];
|
|
621
621
|
});
|
|
622
622
|
let n = (e) => (n) => (t[e].push(n), () => {
|
|
@@ -638,15 +638,15 @@ function Vt(e) {
|
|
|
638
638
|
},
|
|
639
639
|
__snapshot() {
|
|
640
640
|
let e = {};
|
|
641
|
-
return
|
|
641
|
+
return zt.forEach((n) => {
|
|
642
642
|
e[n] = [...t[n]];
|
|
643
643
|
}), e;
|
|
644
644
|
}
|
|
645
645
|
};
|
|
646
646
|
}
|
|
647
|
-
var
|
|
647
|
+
var Vt = /* @__PURE__ */ function(e) {
|
|
648
648
|
return e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.PATCH = "PATCH", e.DELETE = "DELETE", e;
|
|
649
|
-
}({}),
|
|
649
|
+
}({}), W = (e, t) => t ? `${t}__${e}` : e, Ht = (e) => {
|
|
650
650
|
try {
|
|
651
651
|
if (typeof e == "string") return e;
|
|
652
652
|
if (e == null) return "";
|
|
@@ -656,13 +656,13 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
656
656
|
} catch {
|
|
657
657
|
return "";
|
|
658
658
|
}
|
|
659
|
-
},
|
|
659
|
+
}, Ut = ({ loaded: e, total: t }) => !e || !t ? 0 : Number((e * 100 / t).toFixed(0)), Wt = (e, t, { total: n, loaded: r }) => {
|
|
660
660
|
let i = r / (t - +e || 1), a = Math.max(n, r), o = a - r, s = i ? o / i : null;
|
|
661
661
|
return {
|
|
662
662
|
timeLeft: a === r ? 0 : s,
|
|
663
663
|
sizeLeft: o
|
|
664
664
|
};
|
|
665
|
-
},
|
|
665
|
+
}, Gt = (e, t, n) => {
|
|
666
666
|
let { total: r, loaded: i } = n;
|
|
667
667
|
if (Number.isNaN(r) || Number.isNaN(i)) return {
|
|
668
668
|
progress: 0,
|
|
@@ -672,23 +672,23 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
672
672
|
loaded: 0,
|
|
673
673
|
startTimestamp: +e
|
|
674
674
|
};
|
|
675
|
-
let { timeLeft: a, sizeLeft: o } =
|
|
675
|
+
let { timeLeft: a, sizeLeft: o } = Wt(e, t, n);
|
|
676
676
|
return {
|
|
677
|
-
progress:
|
|
677
|
+
progress: Ut(n),
|
|
678
678
|
timeLeft: a,
|
|
679
679
|
sizeLeft: o,
|
|
680
680
|
total: r,
|
|
681
681
|
loaded: i,
|
|
682
682
|
startTimestamp: +e
|
|
683
683
|
};
|
|
684
|
-
},
|
|
685
|
-
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method ===
|
|
684
|
+
}, Kt = (e) => `${e.method}_${e.requestOptions.endpoint}_${e.cancelable}`, qt = (e, t) => `${Ht(e.method)}_${t ? e.requestOptions.endpoint : Ht(e.endpoint)}_${t ? "" : Ht(e.queryParams)}`, Jt = (e, t = "auto") => {
|
|
685
|
+
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method === Vt.GET, a = t === "auto" && i || t === "fetch";
|
|
686
686
|
return [a ? n : r, a];
|
|
687
|
-
},
|
|
687
|
+
}, Yt = async (e, t) => {
|
|
688
688
|
let n = e.unstable_responseMapper?.(t);
|
|
689
689
|
return n instanceof Promise ? await n : n || t;
|
|
690
|
-
},
|
|
691
|
-
let { client: n } = e, { requestManager: r } = n, [i] =
|
|
690
|
+
}, Xt = async (e, t) => {
|
|
691
|
+
let { client: n } = e, { requestManager: r } = n, [i] = Jt(e, t?.dispatcherType), a;
|
|
692
692
|
if (e.optimistic) try {
|
|
693
693
|
a = await e.optimistic({
|
|
694
694
|
request: e,
|
|
@@ -764,7 +764,7 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
764
764
|
data: null,
|
|
765
765
|
status: null,
|
|
766
766
|
success: !1,
|
|
767
|
-
error:
|
|
767
|
+
error: U("deleted"),
|
|
768
768
|
extra: e.client.adapter.defaultExtra,
|
|
769
769
|
requestTimestamp: +/* @__PURE__ */ new Date(),
|
|
770
770
|
responseTimestamp: +/* @__PURE__ */ new Date()
|
|
@@ -775,9 +775,9 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
775
775
|
u(), d(), f(), p(), m(), h();
|
|
776
776
|
}
|
|
777
777
|
});
|
|
778
|
-
},
|
|
778
|
+
}, Zt = /* @__PURE__ */ function(e) {
|
|
779
779
|
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;
|
|
780
|
-
}({}),
|
|
780
|
+
}({}), Qt = class e {
|
|
781
781
|
endpoint;
|
|
782
782
|
headers;
|
|
783
783
|
auth;
|
|
@@ -801,7 +801,7 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
801
801
|
deduplicate;
|
|
802
802
|
deduplicateTime;
|
|
803
803
|
scope;
|
|
804
|
-
$hooks =
|
|
804
|
+
$hooks = Bt();
|
|
805
805
|
isMockerEnabled = !1;
|
|
806
806
|
unstable_mock;
|
|
807
807
|
unstable_payloadMapper;
|
|
@@ -818,7 +818,7 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
818
818
|
updatedQueryKey;
|
|
819
819
|
constructor(e, t, n) {
|
|
820
820
|
this.client = e, this.requestOptions = t, this.initialRequestConfiguration = n;
|
|
821
|
-
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 =
|
|
821
|
+
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 = Zt.MIN * 5, cache: f = !0, staleTime: p = Zt.MIN * 5, queued: m = !1, offline: h = !0, abortKey: g, cacheKey: _, queryKey: v, deduplicate: y = !1, deduplicateTime: b = null } = {
|
|
822
822
|
...this.client.adapter.unstable_getRequestDefaults?.(t),
|
|
823
823
|
...t
|
|
824
824
|
};
|
|
@@ -928,11 +928,11 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
928
928
|
payload: t?.payload || this.payload,
|
|
929
929
|
params: t?.params || this.params
|
|
930
930
|
}, r = new e(this.client, this.requestOptions, n);
|
|
931
|
-
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 =
|
|
931
|
+
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 = Bt(this.$hooks.__snapshot()), r;
|
|
932
932
|
}
|
|
933
933
|
abort = () => {
|
|
934
934
|
let { requestManager: e } = this.client;
|
|
935
|
-
return e.abortByKey(
|
|
935
|
+
return e.abortByKey(W(this.abortKey, this.scope)), this.clone();
|
|
936
936
|
};
|
|
937
937
|
dehydrate = (e) => {
|
|
938
938
|
let { response: t, override: n = !0 } = e || {};
|
|
@@ -947,7 +947,7 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
947
947
|
cache: !0,
|
|
948
948
|
response: t
|
|
949
949
|
};
|
|
950
|
-
let r = this.client.cache.get(
|
|
950
|
+
let r = this.client.cache.get(W(this.cacheKey, this.scope));
|
|
951
951
|
if (r) return {
|
|
952
952
|
override: n,
|
|
953
953
|
cacheTime: this.cacheTime,
|
|
@@ -969,7 +969,7 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
969
969
|
};
|
|
970
970
|
};
|
|
971
971
|
read() {
|
|
972
|
-
let e = this.client.cache.get(
|
|
972
|
+
let e = this.client.cache.get(W(this.cacheKey, this.scope));
|
|
973
973
|
if (e) return {
|
|
974
974
|
data: e.data,
|
|
975
975
|
error: e.error,
|
|
@@ -981,7 +981,7 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
981
981
|
};
|
|
982
982
|
}
|
|
983
983
|
exec = async (e) => {
|
|
984
|
-
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a =
|
|
984
|
+
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a = W(this.abortKey, this.scope);
|
|
985
985
|
n.addAbortController(a, i);
|
|
986
986
|
let o = await t.fetch(r, i);
|
|
987
987
|
return n.removeAbortController(a, i), r.unstable_responseMapper ? r.unstable_responseMapper(o) : o;
|
|
@@ -991,17 +991,17 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
991
991
|
...e,
|
|
992
992
|
cachePolicy: void 0
|
|
993
993
|
};
|
|
994
|
-
if (n === "network-only") return
|
|
994
|
+
if (n === "network-only") return Xt(i, a);
|
|
995
995
|
let o = i.read();
|
|
996
|
-
if (n === "cache-first") return o ?
|
|
996
|
+
if (n === "cache-first") return o ? Yt(i, o) : Xt(i, a);
|
|
997
997
|
if (o) {
|
|
998
|
-
let e = await
|
|
999
|
-
return
|
|
998
|
+
let e = await Yt(i, o);
|
|
999
|
+
return Xt(i, a), e;
|
|
1000
1000
|
}
|
|
1001
|
-
return
|
|
1001
|
+
return Xt(i, a);
|
|
1002
1002
|
};
|
|
1003
1003
|
static fromJSON = (t, n) => new e(t, n.requestOptions, n);
|
|
1004
|
-
},
|
|
1004
|
+
}, $t = async ({ request: e, requestId: t, resolve: n, onStartTime: r, internalErrorMapping: i }) => {
|
|
1005
1005
|
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;
|
|
1006
1006
|
c.debug({
|
|
1007
1007
|
title: "Running middleware callbacks",
|
|
@@ -1011,7 +1011,7 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
1011
1011
|
requestId: t
|
|
1012
1012
|
}
|
|
1013
1013
|
}), d = await d.client.unstable_modifyRequest(d), d.auth && (d = await d.client.unstable_modifyAuth(d)), d.unstable_requestMapper && (d = await d.unstable_requestMapper(d, t));
|
|
1014
|
-
let { client: g, abortKey: _ } = d, v =
|
|
1014
|
+
let { client: g, abortKey: _ } = d, v = W(_, d.scope), y = d.payload;
|
|
1015
1015
|
d.unstable_payloadMapper ? y = await d.unstable_payloadMapper(d.payload) : s && (y = await s(y));
|
|
1016
1016
|
let b = d.options, x = +/* @__PURE__ */ new Date();
|
|
1017
1017
|
r(x);
|
|
@@ -1020,14 +1020,14 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
1020
1020
|
let n = Number(t.total || 0), r = Number(t.loaded || 0);
|
|
1021
1021
|
return Math.max(n, r, e);
|
|
1022
1022
|
}, T = (e, n, r) => {
|
|
1023
|
-
let i =
|
|
1023
|
+
let i = Gt(new Date(e), new Date(n), r);
|
|
1024
1024
|
m !== 100 && (m = i.total, a.events.emitUploadProgress({
|
|
1025
1025
|
...i,
|
|
1026
1026
|
requestId: t,
|
|
1027
1027
|
request: d
|
|
1028
1028
|
}));
|
|
1029
1029
|
}, E = (e, n, r) => {
|
|
1030
|
-
let i =
|
|
1030
|
+
let i = Gt(new Date(e), new Date(n), r);
|
|
1031
1031
|
h !== 100 && (h = i.total, a.events.emitDownloadProgress({
|
|
1032
1032
|
...i,
|
|
1033
1033
|
requestId: t,
|
|
@@ -1090,14 +1090,14 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
1090
1090
|
total: e.total || p,
|
|
1091
1091
|
loaded: e.loaded || 0
|
|
1092
1092
|
}), t;
|
|
1093
|
-
},
|
|
1093
|
+
}, te = () => {
|
|
1094
1094
|
u ||= +/* @__PURE__ */ new Date();
|
|
1095
1095
|
let e = +/* @__PURE__ */ new Date();
|
|
1096
1096
|
return E(u, e, {
|
|
1097
1097
|
total: p,
|
|
1098
1098
|
loaded: p
|
|
1099
1099
|
}), e;
|
|
1100
|
-
},
|
|
1100
|
+
}, ne = async ({ data: e, error: r, status: i, extra: a }) => {
|
|
1101
1101
|
let o = {
|
|
1102
1102
|
data: e,
|
|
1103
1103
|
error: r ?? null,
|
|
@@ -1122,50 +1122,50 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
1122
1122
|
response: o
|
|
1123
1123
|
}
|
|
1124
1124
|
}), o;
|
|
1125
|
-
},
|
|
1125
|
+
}, M = en({
|
|
1126
1126
|
request: d,
|
|
1127
1127
|
requestId: t,
|
|
1128
1128
|
startTime: x,
|
|
1129
1129
|
logger: c,
|
|
1130
1130
|
resolve: n
|
|
1131
|
-
}),
|
|
1131
|
+
}), N = ({ status: e, extra: n }) => (c.error({
|
|
1132
1132
|
title: "Abort error",
|
|
1133
1133
|
type: "request",
|
|
1134
1134
|
extra: {
|
|
1135
1135
|
request: d,
|
|
1136
1136
|
requestId: t
|
|
1137
1137
|
}
|
|
1138
|
-
}),
|
|
1139
|
-
error: i(
|
|
1138
|
+
}), M({
|
|
1139
|
+
error: i(U("abort")),
|
|
1140
1140
|
status: e,
|
|
1141
1141
|
extra: n
|
|
1142
|
-
})),
|
|
1142
|
+
})), P = ({ status: e, extra: n }) => (c.error({
|
|
1143
1143
|
title: "Timeout error",
|
|
1144
1144
|
type: "request",
|
|
1145
1145
|
extra: {
|
|
1146
1146
|
request: d,
|
|
1147
1147
|
requestId: t
|
|
1148
1148
|
}
|
|
1149
|
-
}),
|
|
1150
|
-
error:
|
|
1149
|
+
}), M({
|
|
1150
|
+
error: U("timeout"),
|
|
1151
1151
|
status: e,
|
|
1152
1152
|
extra: n
|
|
1153
|
-
})),
|
|
1153
|
+
})), re = ({ status: e, extra: n }) => (c.error({
|
|
1154
1154
|
title: "Unexpected error",
|
|
1155
1155
|
type: "request",
|
|
1156
1156
|
extra: {
|
|
1157
1157
|
request: d,
|
|
1158
1158
|
requestId: t
|
|
1159
1159
|
}
|
|
1160
|
-
}),
|
|
1161
|
-
error:
|
|
1160
|
+
}), M({
|
|
1161
|
+
error: U(),
|
|
1162
1162
|
status: e,
|
|
1163
1163
|
extra: n
|
|
1164
|
-
})),
|
|
1165
|
-
let i =
|
|
1164
|
+
})), F = () => a.getAbortController(v, t), ie = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1165
|
+
let i = F();
|
|
1166
1166
|
if (!i) throw new Pt("Controller is not found");
|
|
1167
1167
|
let o = () => {
|
|
1168
|
-
|
|
1168
|
+
N({
|
|
1169
1169
|
status: e,
|
|
1170
1170
|
extra: n
|
|
1171
1171
|
}), r(), a.events.emitAbort({
|
|
@@ -1185,36 +1185,36 @@ var Ht = /* @__PURE__ */ function(e) {
|
|
|
1185
1185
|
adapterOptions: b
|
|
1186
1186
|
}
|
|
1187
1187
|
});
|
|
1188
|
-
let
|
|
1188
|
+
let ae = e.client.adapter.unstable_queryParamsMapper(d.queryParams), oe = e.client.adapter.unstable_endpointMapper(d.endpoint), se = e.client.adapter.unstable_headerMapper(d), { url: I } = e.client;
|
|
1189
1189
|
return {
|
|
1190
1190
|
request: d,
|
|
1191
1191
|
requestId: t,
|
|
1192
|
-
url:
|
|
1193
|
-
endpoint:
|
|
1194
|
-
queryParams:
|
|
1192
|
+
url: I,
|
|
1193
|
+
endpoint: oe,
|
|
1194
|
+
queryParams: ae,
|
|
1195
1195
|
payload: y,
|
|
1196
|
-
headers:
|
|
1196
|
+
headers: se,
|
|
1197
1197
|
adapter: e.client.adapter,
|
|
1198
1198
|
adapterOptions: b,
|
|
1199
|
-
getAbortController:
|
|
1199
|
+
getAbortController: F,
|
|
1200
1200
|
getRequestStartTimestamp: S,
|
|
1201
1201
|
getResponseStartTimestamp: C,
|
|
1202
|
-
createAbortListener:
|
|
1202
|
+
createAbortListener: ie,
|
|
1203
1203
|
onBeforeRequest: D,
|
|
1204
1204
|
onRequestStart: O,
|
|
1205
1205
|
onRequestProgress: k,
|
|
1206
1206
|
onRequestEnd: A,
|
|
1207
1207
|
onResponseStart: j,
|
|
1208
1208
|
onResponseProgress: ee,
|
|
1209
|
-
onResponseEnd:
|
|
1210
|
-
onSuccess:
|
|
1211
|
-
onAbortError:
|
|
1212
|
-
onTimeoutError:
|
|
1213
|
-
onUnexpectedError:
|
|
1214
|
-
onError:
|
|
1209
|
+
onResponseEnd: te,
|
|
1210
|
+
onSuccess: ne,
|
|
1211
|
+
onAbortError: N,
|
|
1212
|
+
onTimeoutError: P,
|
|
1213
|
+
onUnexpectedError: re,
|
|
1214
|
+
onError: M
|
|
1215
1215
|
};
|
|
1216
1216
|
};
|
|
1217
|
-
function
|
|
1217
|
+
function en({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
1218
1218
|
let { client: a } = e;
|
|
1219
1219
|
return async ({ error: o, status: s, extra: c }) => {
|
|
1220
1220
|
let l = {
|
|
@@ -1243,7 +1243,7 @@ function tn({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
|
1243
1243
|
}), l;
|
|
1244
1244
|
};
|
|
1245
1245
|
}
|
|
1246
|
-
var
|
|
1246
|
+
var tn = 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 }) => {
|
|
1247
1247
|
if (!e.unstable_mock) throw new Pt("Mock should be defined when calling mocker");
|
|
1248
1248
|
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({
|
|
1249
1249
|
request: e,
|
|
@@ -1288,7 +1288,7 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1288
1288
|
status: C,
|
|
1289
1289
|
extra: T
|
|
1290
1290
|
}), h || r();
|
|
1291
|
-
},
|
|
1291
|
+
}, nn = (e) => e, rn = class {
|
|
1292
1292
|
unstable_fetcher;
|
|
1293
1293
|
name;
|
|
1294
1294
|
defaultMethod;
|
|
@@ -1310,10 +1310,10 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1310
1310
|
initialize = (e) => (this.logger = e.loggerManager.initialize(e, "Adapter"), this.initialized = !0, this.client = e, this.unstable_onInitializeCallback?.({ client: e }), this);
|
|
1311
1311
|
onInitialize = (e) => (this.unstable_onInitializeCallback = e, this);
|
|
1312
1312
|
unstable_internalErrorMapping = (e) => e;
|
|
1313
|
-
unstable_headerMapper =
|
|
1314
|
-
unstable_payloadMapper =
|
|
1315
|
-
unstable_endpointMapper =
|
|
1316
|
-
unstable_queryParamsMapper =
|
|
1313
|
+
unstable_headerMapper = Lt;
|
|
1314
|
+
unstable_payloadMapper = Rt;
|
|
1315
|
+
unstable_endpointMapper = nn;
|
|
1316
|
+
unstable_queryParamsMapper = nn;
|
|
1317
1317
|
unstable_getAdapterDefaults;
|
|
1318
1318
|
unstable_getRequestDefaults;
|
|
1319
1319
|
unstable_devtoolsEndpointGetter = (e) => e;
|
|
@@ -1344,7 +1344,7 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1344
1344
|
request: e,
|
|
1345
1345
|
requestId: t
|
|
1346
1346
|
});
|
|
1347
|
-
let i = await
|
|
1347
|
+
let i = await $t({
|
|
1348
1348
|
request: e,
|
|
1349
1349
|
requestId: t,
|
|
1350
1350
|
resolve: r,
|
|
@@ -1353,9 +1353,9 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1353
1353
|
n = e;
|
|
1354
1354
|
}
|
|
1355
1355
|
});
|
|
1356
|
-
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await
|
|
1356
|
+
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await tn(i) : this.unstable_fetcher(i);
|
|
1357
1357
|
} catch (i) {
|
|
1358
|
-
return
|
|
1358
|
+
return en({
|
|
1359
1359
|
request: e,
|
|
1360
1360
|
requestId: t,
|
|
1361
1361
|
startTime: n || Date.now(),
|
|
@@ -1372,66 +1372,66 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1372
1372
|
r(e);
|
|
1373
1373
|
});
|
|
1374
1374
|
}
|
|
1375
|
-
},
|
|
1375
|
+
}, an = (e) => {
|
|
1376
1376
|
try {
|
|
1377
1377
|
return JSON.parse(e);
|
|
1378
1378
|
} catch {
|
|
1379
1379
|
return e;
|
|
1380
1380
|
}
|
|
1381
|
-
},
|
|
1381
|
+
}, on = (e) => e ? an(e) : U(), sn = (e) => (t) => {
|
|
1382
1382
|
let { skipNull: n, skipEmptyString: r } = e;
|
|
1383
1383
|
return !(r && t === void 0 || r && t === "" || n && t === null);
|
|
1384
|
-
},
|
|
1385
|
-
let r = !
|
|
1386
|
-
return !e || r ? "" : `${
|
|
1387
|
-
},
|
|
1384
|
+
}, G = (e, { encode: t, strict: n }) => t && n ? encodeURIComponent(e).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`) : t ? encodeURIComponent(e) : e, cn = (e, t, n) => {
|
|
1385
|
+
let r = !sn(n)(t);
|
|
1386
|
+
return !e || r ? "" : `${G(e, n)}=${G(t instanceof Date ? n.dateParser?.(t) || t.toISOString() : typeof t == "object" && !Array.isArray(t) ? n.objectParser?.(t) || JSON.stringify(t) : String(t), n)}`;
|
|
1387
|
+
}, ln = (e, t, n) => {
|
|
1388
1388
|
let { arrayFormat: r, arraySeparator: i } = n;
|
|
1389
|
-
return t.filter(
|
|
1389
|
+
return t.filter(sn(n)).reduce((t, a, o) => {
|
|
1390
1390
|
switch (r) {
|
|
1391
1391
|
case "index": {
|
|
1392
|
-
let r = `${
|
|
1393
|
-
t.push(`${r}${
|
|
1392
|
+
let r = `${G(e, n)}[${G(String(o), n)}]=`;
|
|
1393
|
+
t.push(`${r}${G(String(a), n)}`);
|
|
1394
1394
|
break;
|
|
1395
1395
|
}
|
|
1396
1396
|
case "bracket": {
|
|
1397
|
-
let r = `${
|
|
1398
|
-
t.push(`${r}${
|
|
1397
|
+
let r = `${G(e, n)}[]=`;
|
|
1398
|
+
t.push(`${r}${G(String(a), n)}`);
|
|
1399
1399
|
break;
|
|
1400
1400
|
}
|
|
1401
1401
|
case "comma": {
|
|
1402
|
-
let r = !t.length && `${
|
|
1403
|
-
return [[...t, `${r}${
|
|
1402
|
+
let r = !t.length && `${G(e, n)}=` || "";
|
|
1403
|
+
return [[...t, `${r}${G(String(a), n)}`].join(",")];
|
|
1404
1404
|
}
|
|
1405
1405
|
case "separator": {
|
|
1406
|
-
let r = !t.length && `${
|
|
1407
|
-
return [[...t, `${r}${
|
|
1406
|
+
let r = !t.length && `${G(e, n)}=` || "";
|
|
1407
|
+
return [[...t, `${r}${G(String(a), n)}`].join(i || "|")];
|
|
1408
1408
|
}
|
|
1409
1409
|
case "bracket-separator": {
|
|
1410
|
-
let r = !t.length && `${
|
|
1411
|
-
return [[...t, `${r}${
|
|
1410
|
+
let r = !t.length && `${G(e, n)}[]=` || "";
|
|
1411
|
+
return [[...t, `${r}${G(String(a), n)}`].join(i || "|")];
|
|
1412
1412
|
}
|
|
1413
1413
|
default: {
|
|
1414
|
-
let r = `${
|
|
1415
|
-
t.push(`${r}${
|
|
1414
|
+
let r = `${G(e, n)}=`;
|
|
1415
|
+
t.push(`${r}${G(String(a), n)}`);
|
|
1416
1416
|
}
|
|
1417
1417
|
}
|
|
1418
1418
|
return t;
|
|
1419
1419
|
}, []).join("&");
|
|
1420
|
-
},
|
|
1420
|
+
}, un = (e, t = zn) => {
|
|
1421
1421
|
if (!e || !Object.keys(e).length) return "";
|
|
1422
1422
|
if (typeof e == "string") return e[0] === "?" ? e : `?${e}`;
|
|
1423
|
-
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ?
|
|
1423
|
+
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ? ln(e, n, t) : cn(e, n, t)).filter(Boolean).join("&");
|
|
1424
1424
|
return n ? `?${n}` : "";
|
|
1425
|
-
},
|
|
1425
|
+
}, dn = Zt.SEC * 5, fn = { headers: {} }, pn = () => new rn({
|
|
1426
1426
|
name: "http",
|
|
1427
|
-
defaultMethod:
|
|
1428
|
-
defaultExtra:
|
|
1427
|
+
defaultMethod: Vt.GET,
|
|
1428
|
+
defaultExtra: fn,
|
|
1429
1429
|
systemErrorStatus: 0,
|
|
1430
|
-
systemErrorExtra:
|
|
1431
|
-
}).setQueryParamsMapper(
|
|
1432
|
-
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ?
|
|
1430
|
+
systemErrorExtra: fn
|
|
1431
|
+
}).setQueryParamsMapper(un).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 }) => {
|
|
1432
|
+
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ? un(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = dn, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
|
|
1433
1433
|
status: 0,
|
|
1434
|
-
extra:
|
|
1434
|
+
extra: fn
|
|
1435
1435
|
});
|
|
1436
1436
|
C > 0 && S && (D = setTimeout(() => {
|
|
1437
1437
|
E = !0, O(), S.abort();
|
|
@@ -1463,7 +1463,7 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1463
1463
|
status: l,
|
|
1464
1464
|
extra: c
|
|
1465
1465
|
}) : i({
|
|
1466
|
-
error:
|
|
1466
|
+
error: on(await t.text()),
|
|
1467
1467
|
status: l,
|
|
1468
1468
|
extra: c
|
|
1469
1469
|
});
|
|
@@ -1484,11 +1484,11 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1484
1484
|
e = new TextDecoder().decode(o);
|
|
1485
1485
|
} else e = await t.text();
|
|
1486
1486
|
a(), O(), t.ok ? h({
|
|
1487
|
-
data:
|
|
1487
|
+
data: an(e),
|
|
1488
1488
|
status: l,
|
|
1489
1489
|
extra: c
|
|
1490
1490
|
}) : i({
|
|
1491
|
-
error:
|
|
1491
|
+
error: on(e),
|
|
1492
1492
|
status: l,
|
|
1493
1493
|
extra: c
|
|
1494
1494
|
});
|
|
@@ -1497,17 +1497,17 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1497
1497
|
if (D && clearTimeout(D), O(), S?.signal?.aborted) {
|
|
1498
1498
|
E && o({
|
|
1499
1499
|
status: 0,
|
|
1500
|
-
extra:
|
|
1500
|
+
extra: fn
|
|
1501
1501
|
});
|
|
1502
1502
|
return;
|
|
1503
1503
|
}
|
|
1504
1504
|
i({
|
|
1505
1505
|
error: e,
|
|
1506
1506
|
status: 0,
|
|
1507
|
-
extra:
|
|
1507
|
+
extra: fn
|
|
1508
1508
|
});
|
|
1509
1509
|
}
|
|
1510
|
-
}),
|
|
1510
|
+
}), mn = () => pn(), hn = class {
|
|
1511
1511
|
emitter = new Re();
|
|
1512
1512
|
events;
|
|
1513
1513
|
storage;
|
|
@@ -1519,7 +1519,7 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1519
1519
|
constructor(e) {
|
|
1520
1520
|
this.options = e;
|
|
1521
1521
|
let { storage: t = /* @__PURE__ */ new Map(), lazyStorage: n, version: r = "0.0.1" } = e ?? {};
|
|
1522
|
-
this.emitter?.setMaxListeners(1e3), this.events =
|
|
1522
|
+
this.emitter?.setMaxListeners(1e3), this.events = Cn(this.emitter), this.storage = t, this.version = r, this.lazyStorage = n;
|
|
1523
1523
|
}
|
|
1524
1524
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Cache"), e.appManager.events.onOnline(() => {
|
|
1525
1525
|
[...this.storage.keys()].forEach(this.scheduleGarbageCollector);
|
|
@@ -1533,7 +1533,7 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1533
1533
|
response: t
|
|
1534
1534
|
}
|
|
1535
1535
|
});
|
|
1536
|
-
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s =
|
|
1536
|
+
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = W(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u = gn(c, l), d = {
|
|
1537
1537
|
...u,
|
|
1538
1538
|
scope: o,
|
|
1539
1539
|
staleTime: i,
|
|
@@ -1579,7 +1579,7 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1579
1579
|
partialResponse: t
|
|
1580
1580
|
}
|
|
1581
1581
|
});
|
|
1582
|
-
let { cacheKey: n, scope: r } = e, i =
|
|
1582
|
+
let { cacheKey: n, scope: r } = e, i = W(n, r), a = this.storage.get(i), o = typeof t == "function" ? t(a || null) : t;
|
|
1583
1583
|
a && this.set(e, {
|
|
1584
1584
|
...a,
|
|
1585
1585
|
...o
|
|
@@ -1617,7 +1617,7 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1617
1617
|
cacheKey: t
|
|
1618
1618
|
}), this.events.emitInvalidation(t);
|
|
1619
1619
|
};
|
|
1620
|
-
e instanceof
|
|
1620
|
+
e instanceof Qt ? n(W(e.cacheKey, e.scope), e.cacheKey) : typeof e == "string" ? n(e) : t.length && t.forEach((t) => {
|
|
1621
1621
|
e.test(t) && n(t);
|
|
1622
1622
|
});
|
|
1623
1623
|
};
|
|
@@ -1672,49 +1672,49 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1672
1672
|
clear = async () => {
|
|
1673
1673
|
this.garbageCollectors.forEach((e) => clearTimeout(e)), this.storage.clear();
|
|
1674
1674
|
};
|
|
1675
|
-
},
|
|
1675
|
+
}, gn = (e, t) => {
|
|
1676
1676
|
let { data: n, success: r } = t, i = !r && e ? e.data : null, a = n || i;
|
|
1677
1677
|
return {
|
|
1678
1678
|
...t,
|
|
1679
1679
|
data: a
|
|
1680
1680
|
};
|
|
1681
|
-
},
|
|
1681
|
+
}, _n = () => "invalidate", vn = (e) => `${e}_invalidate`, yn = () => "delete", bn = (e) => `${e}_delete`, xn = (e) => `${e}_cache`, Sn = () => "cache", Cn = (e) => ({
|
|
1682
1682
|
emitCacheData: (t, n = !1) => {
|
|
1683
|
-
e.emit(
|
|
1683
|
+
e.emit(Sn(), t, n), e.emit(xn(t.cacheKey), t, n);
|
|
1684
1684
|
},
|
|
1685
1685
|
emitInvalidation: (t, n = !1) => {
|
|
1686
|
-
e.emit(
|
|
1686
|
+
e.emit(_n(), t, n), e.emit(vn(t), n);
|
|
1687
1687
|
},
|
|
1688
1688
|
emitDelete: (t, n = !1) => {
|
|
1689
|
-
e.emit(
|
|
1689
|
+
e.emit(yn(), t, n), e.emit(bn(t), n);
|
|
1690
1690
|
},
|
|
1691
|
-
onData: (t) => (e.on(
|
|
1692
|
-
onDataByKey: (t, n) => (e.on(
|
|
1693
|
-
onInvalidate: (t) => (e.on(
|
|
1694
|
-
onInvalidateByKey: (t, n) => (e.on(
|
|
1695
|
-
onDelete: (t) => (e.on(
|
|
1696
|
-
onDeleteByKey: (t, n) => (e.on(
|
|
1697
|
-
}),
|
|
1691
|
+
onData: (t) => (e.on(Sn(), t), () => e.removeListener(Sn(), t)),
|
|
1692
|
+
onDataByKey: (t, n) => (e.on(xn(t), n), () => e.removeListener(xn(t), n)),
|
|
1693
|
+
onInvalidate: (t) => (e.on(_n(), t), () => e.removeListener(_n(), t)),
|
|
1694
|
+
onInvalidateByKey: (t, n) => (e.on(vn(t), n), () => e.removeListener(vn(t), n)),
|
|
1695
|
+
onDelete: (t) => (e.on(yn(), t), () => e.removeListener(yn(), t)),
|
|
1696
|
+
onDeleteByKey: (t, n) => (e.on(bn(t), n), () => e.removeListener(bn(t), n))
|
|
1697
|
+
}), K = /* @__PURE__ */ function(e) {
|
|
1698
1698
|
return e.ONE_BY_ONE = "one-by-one", e.ALL_AT_ONCE = "all-at-once", e.PREVIOUS_CANCELED = "previous-canceled", e.DEDUPLICATED = "deduplicated", e;
|
|
1699
|
-
}({}),
|
|
1699
|
+
}({}), wn = (e) => ({
|
|
1700
1700
|
emitDrained: (t, n) => {
|
|
1701
|
-
e.emit(
|
|
1701
|
+
e.emit(En(), t, n), e.emit(Dn(t.queryKey), t, n);
|
|
1702
1702
|
},
|
|
1703
1703
|
emitQueueStatusChanged: (t, n) => {
|
|
1704
|
-
e.emit(
|
|
1704
|
+
e.emit(On(), t, n), e.emit(kn(t.queryKey), t, n);
|
|
1705
1705
|
},
|
|
1706
1706
|
emitQueueChanged: (t, n) => {
|
|
1707
|
-
e.emit(
|
|
1707
|
+
e.emit(An(), t, n), e.emit(jn(t.queryKey), t, n);
|
|
1708
1708
|
},
|
|
1709
|
-
onDrained: (t) => (e.on(
|
|
1710
|
-
onDrainedByKey: (t, n) => (e.on(
|
|
1711
|
-
onQueueStatusChange: (t) => (e.on(
|
|
1712
|
-
onQueueStatusChangeByKey: (t, n) => (e.on(
|
|
1713
|
-
onQueueChange: (t) => (e.on(
|
|
1714
|
-
onQueueChangeByKey: (t, n) => (e.on(
|
|
1715
|
-
}),
|
|
1709
|
+
onDrained: (t) => (e.on(En(), t), () => e.removeListener(En(), t)),
|
|
1710
|
+
onDrainedByKey: (t, n) => (e.on(Dn(t), n), () => e.removeListener(Dn(t), n)),
|
|
1711
|
+
onQueueStatusChange: (t) => (e.on(On(), t), () => e.removeListener(On(), t)),
|
|
1712
|
+
onQueueStatusChangeByKey: (t, n) => (e.on(kn(t), n), () => e.removeListener(kn(t), n)),
|
|
1713
|
+
onQueueChange: (t) => (e.on(An(), t), () => e.removeListener(An(), t)),
|
|
1714
|
+
onQueueChangeByKey: (t, n) => (e.on(jn(t), n), () => e.removeListener(jn(t), n))
|
|
1715
|
+
}), Tn = class {
|
|
1716
1716
|
emitter = new Re();
|
|
1717
|
-
events =
|
|
1717
|
+
events = wn(this.emitter);
|
|
1718
1718
|
storage = /* @__PURE__ */ new Map();
|
|
1719
1719
|
requestCount = /* @__PURE__ */ new Map();
|
|
1720
1720
|
runningRequests = /* @__PURE__ */ new Map();
|
|
@@ -1723,7 +1723,7 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1723
1723
|
constructor(e) {
|
|
1724
1724
|
this.options = e, this.emitter?.setMaxListeners(1e3), this.options?.storage && (this.storage = this.options.storage);
|
|
1725
1725
|
}
|
|
1726
|
-
isRequestJSON = (e) => !(e instanceof
|
|
1726
|
+
isRequestJSON = (e) => !(e instanceof Qt);
|
|
1727
1727
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Dispatcher"), this.client.appManager.events.onOnline(() => {
|
|
1728
1728
|
this.flush();
|
|
1729
1729
|
}), this);
|
|
@@ -1847,14 +1847,14 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1847
1847
|
hasRunningRequest = (e, t) => !!this.getRunningRequests(e).find((e) => e.requestId === t);
|
|
1848
1848
|
cancelRunningRequests = (e) => {
|
|
1849
1849
|
this.runningRequests.get(e)?.forEach((e) => {
|
|
1850
|
-
let t =
|
|
1850
|
+
let t = W(e.request.abortKey, e.request.scope);
|
|
1851
1851
|
this.client.requestManager.abortByRequestId(t, e.requestId);
|
|
1852
1852
|
}), this.deleteRunningRequests(e);
|
|
1853
1853
|
};
|
|
1854
1854
|
cancelRunningRequest = (e, t) => {
|
|
1855
1855
|
let n = this.getRunningRequests(e).filter((e) => {
|
|
1856
1856
|
if (e.requestId === t) {
|
|
1857
|
-
let t =
|
|
1857
|
+
let t = W(e.request.abortKey, e.request.scope);
|
|
1858
1858
|
return this.client.requestManager.abortByRequestId(t, e.requestId), !1;
|
|
1859
1859
|
}
|
|
1860
1860
|
return !0;
|
|
@@ -1882,7 +1882,7 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1882
1882
|
resolved: !1
|
|
1883
1883
|
});
|
|
1884
1884
|
add = (e) => {
|
|
1885
|
-
let t =
|
|
1885
|
+
let t = W(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = Pn(e, i);
|
|
1886
1886
|
switch (this.logger.debug({
|
|
1887
1887
|
title: "Adding request to queue",
|
|
1888
1888
|
type: "system",
|
|
@@ -1892,9 +1892,9 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1892
1892
|
requestId: r
|
|
1893
1893
|
}
|
|
1894
1894
|
}), a) {
|
|
1895
|
-
case
|
|
1896
|
-
case
|
|
1897
|
-
case
|
|
1895
|
+
case K.ONE_BY_ONE: return this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1896
|
+
case K.PREVIOUS_CANCELED: return this.cancelRunningRequests(t), this.clearQueue(t), this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1897
|
+
case K.DEDUPLICATED: return this.client.requestManager.events.emitDeduplicated({
|
|
1898
1898
|
request: i.request,
|
|
1899
1899
|
requestId: r,
|
|
1900
1900
|
deduplicatedRequest: e
|
|
@@ -1936,7 +1936,7 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1936
1936
|
requestId: n
|
|
1937
1937
|
}
|
|
1938
1938
|
});
|
|
1939
|
-
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l =
|
|
1939
|
+
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = W(a, c), u = W(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h = Mn(e.retries, r), g = !m.isOnline && s, _ = this.hasRunningRequest(l, n), v = e.stopped;
|
|
1940
1940
|
if (g || _ || v) return this.logger.warning({
|
|
1941
1941
|
title: "Unable to perform request",
|
|
1942
1942
|
type: "system",
|
|
@@ -1956,7 +1956,7 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1956
1956
|
}), this.incrementQueueRequestCount(l), f.addAbortController(u, n);
|
|
1957
1957
|
let b = await d.fetch(t, n);
|
|
1958
1958
|
e.resolved = !0, f.removeAbortController(u, n);
|
|
1959
|
-
let x = !m.isOnline, S =
|
|
1959
|
+
let x = !m.isOnline, S = U("abort").message === b.error?.message, C = !this.hasRunningRequest(l, n) || S;
|
|
1960
1960
|
this.deleteRunningRequest(l, n);
|
|
1961
1961
|
let w = b.success || !h || !t.retryOnError || t.retryOnError(b), T = !b.success && h && w && !C && !x, E = {
|
|
1962
1962
|
isCanceled: C,
|
|
@@ -2070,26 +2070,26 @@ var nn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
2070
2070
|
}
|
|
2071
2071
|
}), this.delete(l, n, u));
|
|
2072
2072
|
};
|
|
2073
|
-
},
|
|
2074
|
-
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ?
|
|
2075
|
-
return n ?
|
|
2073
|
+
}, En = () => "drained-event", Dn = (e) => `${e}-drained-event`, On = () => "status-event", kn = (e) => `${e}-status-event`, An = () => "change-event", jn = (e) => `${e}-change-event`, Mn = (e, t) => !!(t && e < t), Nn = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, Pn = (e, t) => {
|
|
2074
|
+
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? Nn(e, t) : !1;
|
|
2075
|
+
return n ? K.ONE_BY_ONE : r ? K.PREVIOUS_CANCELED : a && i ? K.DEDUPLICATED : K.ALL_AT_ONCE;
|
|
2076
2076
|
};
|
|
2077
|
-
function
|
|
2077
|
+
function Fn(e) {
|
|
2078
2078
|
return e === "client" || e === "server" ? e : typeof window < "u" && typeof document < "u" ? "client" : "server";
|
|
2079
2079
|
}
|
|
2080
|
-
var
|
|
2080
|
+
var In = async (e, t) => {
|
|
2081
2081
|
let n = t;
|
|
2082
2082
|
if (!t.requestOptions.disableRequestInterceptors) {
|
|
2083
2083
|
for (let r of e) if (n = await r(t), !n) throw Error("Request modifier must return request");
|
|
2084
2084
|
}
|
|
2085
2085
|
return n;
|
|
2086
|
-
},
|
|
2086
|
+
}, Ln = async (e, t, n) => {
|
|
2087
2087
|
let r = t;
|
|
2088
2088
|
if (!n.requestOptions.disableResponseInterceptors) {
|
|
2089
2089
|
for (let i of e) if (r = await i(t, n), !r) throw Error("Response modifier must return data");
|
|
2090
2090
|
}
|
|
2091
2091
|
return r;
|
|
2092
|
-
},
|
|
2092
|
+
}, Rn = class {
|
|
2093
2093
|
url;
|
|
2094
2094
|
mode;
|
|
2095
2095
|
debug;
|
|
@@ -2107,15 +2107,15 @@ var Ln = async (e, t) => {
|
|
|
2107
2107
|
submitDispatcher;
|
|
2108
2108
|
isMockerEnabled = !0;
|
|
2109
2109
|
plugins = [];
|
|
2110
|
-
unstable_abortKeyMapper =
|
|
2111
|
-
unstable_cacheKeyMapper =
|
|
2112
|
-
unstable_queryKeyMapper =
|
|
2110
|
+
unstable_abortKeyMapper = Kt;
|
|
2111
|
+
unstable_cacheKeyMapper = qt;
|
|
2112
|
+
unstable_queryKeyMapper = qt;
|
|
2113
2113
|
unstable_requestIdMapper = Fe;
|
|
2114
2114
|
logger = this.loggerManager.initialize(this, "Client");
|
|
2115
2115
|
constructor(e) {
|
|
2116
2116
|
this.options = e;
|
|
2117
2117
|
let { url: t, appManager: n, cache: r, fetchDispatcher: i, submitDispatcher: a, mode: o } = this.options;
|
|
2118
|
-
this.url = t, this.mode =
|
|
2118
|
+
this.url = t, this.mode = Fn(o), this.adapter = mn(), this.appManager = n?.() || new ze(), this.cache = r?.() || new hn(), this.fetchDispatcher = i?.() || new Tn(), this.submitDispatcher = a?.() || new Tn(), this.adapter.initialize(this), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2119
2119
|
}
|
|
2120
2120
|
setDebug = (e) => (this.debug = e, this);
|
|
2121
2121
|
setLogLevel = (e) => (this.loggerManager.setSeverity(e), this);
|
|
@@ -2144,15 +2144,15 @@ var Ln = async (e, t) => {
|
|
|
2144
2144
|
setCacheKeyMapper = (e) => (this.unstable_cacheKeyMapper = e, this);
|
|
2145
2145
|
setQueryKeyMapper = (e) => (this.unstable_queryKeyMapper = e, this);
|
|
2146
2146
|
setRequestIdMapper = (e) => (this.unstable_requestIdMapper = e, this);
|
|
2147
|
-
unstable_modifyAuth = async (e) =>
|
|
2148
|
-
unstable_modifyRequest = async (e) =>
|
|
2149
|
-
unstable_modifyErrorResponse = async (e, t) =>
|
|
2150
|
-
unstable_modifySuccessResponse = async (e, t) =>
|
|
2151
|
-
unstable_modifyResponse = async (e, t) =>
|
|
2152
|
-
fromJSON = (e) =>
|
|
2147
|
+
unstable_modifyAuth = async (e) => In(this.unstable_onAuthCallbacks, e);
|
|
2148
|
+
unstable_modifyRequest = async (e) => In(this.unstable_onRequestCallbacks, e);
|
|
2149
|
+
unstable_modifyErrorResponse = async (e, t) => Ln(this.unstable_onErrorCallbacks, e, t);
|
|
2150
|
+
unstable_modifySuccessResponse = async (e, t) => Ln(this.unstable_onSuccessCallbacks, e, t);
|
|
2151
|
+
unstable_modifyResponse = async (e, t) => Ln(this.unstable_onResponseCallbacks, e, t);
|
|
2152
|
+
fromJSON = (e) => Qt.fromJSON(this, e);
|
|
2153
2153
|
clear = () => {
|
|
2154
2154
|
let { appManager: e, cache: t, fetchDispatcher: n, submitDispatcher: r } = this.options;
|
|
2155
|
-
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
|
|
2155
|
+
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 hn(), this.appManager = e?.() || new ze(), this.fetchDispatcher = n?.() || new Tn(), this.submitDispatcher = r?.() || new Tn(), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2156
2156
|
};
|
|
2157
2157
|
hydrate = (e, t) => {
|
|
2158
2158
|
e?.forEach((e) => {
|
|
@@ -2169,8 +2169,8 @@ var Ln = async (e, t) => {
|
|
|
2169
2169
|
...a,
|
|
2170
2170
|
...t
|
|
2171
2171
|
};
|
|
2172
|
-
if (!s.override && this.cache.get(
|
|
2173
|
-
let c =
|
|
2172
|
+
if (!s.override && this.cache.get(W(n, r))) return;
|
|
2173
|
+
let c = an(i);
|
|
2174
2174
|
this.cache.set({
|
|
2175
2175
|
...s,
|
|
2176
2176
|
cacheKey: n,
|
|
@@ -2182,10 +2182,10 @@ var Ln = async (e, t) => {
|
|
|
2182
2182
|
let t = this.adapter.unstable_endpointMapper(e.endpoint), n = {
|
|
2183
2183
|
...e,
|
|
2184
2184
|
endpoint: String(t)
|
|
2185
|
-
}, r = new
|
|
2185
|
+
}, r = new Qt(this, n);
|
|
2186
2186
|
return this.plugins.forEach((e) => e.trigger("onRequestCreate", { request: r })), r;
|
|
2187
2187
|
};
|
|
2188
|
-
},
|
|
2188
|
+
}, zn = {
|
|
2189
2189
|
strict: !0,
|
|
2190
2190
|
encode: !0,
|
|
2191
2191
|
arrayFormat: "bracket",
|
|
@@ -2194,101 +2194,101 @@ var Ln = async (e, t) => {
|
|
|
2194
2194
|
skipNull: !0,
|
|
2195
2195
|
skipEmptyString: !0
|
|
2196
2196
|
};
|
|
2197
|
-
function
|
|
2198
|
-
return new
|
|
2197
|
+
function Bn(e) {
|
|
2198
|
+
return new Rn(e);
|
|
2199
2199
|
}
|
|
2200
2200
|
//#endregion
|
|
2201
2201
|
//#region src/core/client.ts
|
|
2202
|
-
var
|
|
2202
|
+
var q = Bn({ url: I() });
|
|
2203
2203
|
//#endregion
|
|
2204
2204
|
//#region src/core/auth-api.ts
|
|
2205
|
-
async function
|
|
2206
|
-
let { data: t, success: n } = await
|
|
2205
|
+
async function Vn(e) {
|
|
2206
|
+
let { data: t, success: n } = await q.createRequest()({
|
|
2207
2207
|
endpoint: "/auth/cli/whoami",
|
|
2208
2208
|
method: "GET"
|
|
2209
2209
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2210
2210
|
return !n || !t ? null : t;
|
|
2211
2211
|
}
|
|
2212
|
-
async function
|
|
2213
|
-
await
|
|
2212
|
+
async function Hn(e) {
|
|
2213
|
+
await q.createRequest()({
|
|
2214
2214
|
endpoint: "/auth/cli/token",
|
|
2215
2215
|
method: "DELETE"
|
|
2216
2216
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2217
2217
|
}
|
|
2218
2218
|
//#endregion
|
|
2219
2219
|
//#region src/core/auth-store.ts
|
|
2220
|
-
var
|
|
2221
|
-
function
|
|
2220
|
+
var Un = 1, Wn = "hype-stack", Gn = "auth.json";
|
|
2221
|
+
function Kn() {
|
|
2222
2222
|
let e = process.env.HYPE_STACK_CONFIG_DIR;
|
|
2223
|
-
if (e) return T.join(e,
|
|
2223
|
+
if (e) return T.join(e, Wn);
|
|
2224
2224
|
let t = w.homedir();
|
|
2225
2225
|
if (process.platform === "win32") {
|
|
2226
2226
|
let e = process.env.APPDATA ?? T.join(t, "AppData", "Roaming");
|
|
2227
|
-
return T.join(e,
|
|
2227
|
+
return T.join(e, Wn);
|
|
2228
2228
|
}
|
|
2229
|
-
if (process.platform === "darwin") return T.join(t, "Library", "Application Support",
|
|
2229
|
+
if (process.platform === "darwin") return T.join(t, "Library", "Application Support", Wn);
|
|
2230
2230
|
let n = process.env.XDG_CONFIG_HOME ?? T.join(t, ".config");
|
|
2231
|
-
return T.join(n,
|
|
2231
|
+
return T.join(n, Wn);
|
|
2232
2232
|
}
|
|
2233
|
-
function
|
|
2234
|
-
return T.join(
|
|
2233
|
+
function qn() {
|
|
2234
|
+
return T.join(Kn(), Gn);
|
|
2235
2235
|
}
|
|
2236
|
-
async function
|
|
2237
|
-
let e = await y.readFile(
|
|
2236
|
+
async function Jn() {
|
|
2237
|
+
let e = await y.readFile(qn(), "utf-8").catch(() => null);
|
|
2238
2238
|
if (!e) return {
|
|
2239
|
-
version:
|
|
2239
|
+
version: Un,
|
|
2240
2240
|
tokens: {}
|
|
2241
2241
|
};
|
|
2242
2242
|
let t = JSON.parse(e);
|
|
2243
2243
|
return {
|
|
2244
|
-
version: t.version ??
|
|
2244
|
+
version: t.version ?? Un,
|
|
2245
2245
|
tokens: t.tokens ?? {}
|
|
2246
2246
|
};
|
|
2247
2247
|
}
|
|
2248
|
-
async function
|
|
2249
|
-
let t =
|
|
2250
|
-
await y.mkdir(t, { recursive: !0 }), await y.writeFile(
|
|
2248
|
+
async function Yn(e) {
|
|
2249
|
+
let t = Kn();
|
|
2250
|
+
await y.mkdir(t, { recursive: !0 }), await y.writeFile(qn(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2251
2251
|
}
|
|
2252
|
-
async function
|
|
2253
|
-
return (await
|
|
2252
|
+
async function Xn(e) {
|
|
2253
|
+
return (await Jn()).tokens[e] ?? null;
|
|
2254
2254
|
}
|
|
2255
|
-
async function
|
|
2256
|
-
let n = await
|
|
2257
|
-
n.tokens[e] = t, await
|
|
2255
|
+
async function Zn(e, t) {
|
|
2256
|
+
let n = await Jn();
|
|
2257
|
+
n.tokens[e] = t, await Yn(n);
|
|
2258
2258
|
}
|
|
2259
|
-
async function
|
|
2260
|
-
let t = await
|
|
2261
|
-
e in t.tokens && (delete t.tokens[e], await
|
|
2259
|
+
async function Qn(e) {
|
|
2260
|
+
let t = await Jn();
|
|
2261
|
+
e in t.tokens && (delete t.tokens[e], await Yn(t));
|
|
2262
2262
|
}
|
|
2263
2263
|
//#endregion
|
|
2264
2264
|
//#region src/core/device.ts
|
|
2265
|
-
function
|
|
2265
|
+
function $n() {
|
|
2266
2266
|
let e = w.networkInterfaces();
|
|
2267
2267
|
for (let t of Object.values(e)) if (t) {
|
|
2268
2268
|
for (let e of t) if (!e.internal && e.mac !== "00:00:00:00:00:00") return e.mac;
|
|
2269
2269
|
}
|
|
2270
2270
|
return "unknown";
|
|
2271
2271
|
}
|
|
2272
|
-
function
|
|
2273
|
-
let e = `${
|
|
2272
|
+
function er() {
|
|
2273
|
+
let e = `${$n()}:${w.hostname()}:${w.platform()}:${w.arch()}`;
|
|
2274
2274
|
return x("sha256").update(e).digest("hex").slice(0, 16);
|
|
2275
2275
|
}
|
|
2276
|
-
function
|
|
2276
|
+
function tr() {
|
|
2277
2277
|
return `hype-stack/${j} ${w.platform()} ${w.arch()} node/${process.version.slice(1)}`;
|
|
2278
2278
|
}
|
|
2279
2279
|
//#endregion
|
|
2280
2280
|
//#region src/core/open-browser.ts
|
|
2281
|
-
function
|
|
2281
|
+
function nr(e) {
|
|
2282
2282
|
E(process.platform === "darwin" ? `open "${e}"` : process.platform === "win32" ? `start "" "${e}"` : `xdg-open "${e}"`);
|
|
2283
2283
|
}
|
|
2284
2284
|
//#endregion
|
|
2285
2285
|
//#region src/core/login.ts
|
|
2286
|
-
var
|
|
2287
|
-
async function
|
|
2288
|
-
let t = S(16).toString("hex"), n =
|
|
2286
|
+
var rr = 300 * 1e3, ir = (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>`;
|
|
2287
|
+
async function ar(e = {}) {
|
|
2288
|
+
let t = S(16).toString("hex"), n = I(), r = C.createServer(), i = await new Promise((n, i) => {
|
|
2289
2289
|
let a = setTimeout(() => {
|
|
2290
2290
|
o(), i(/* @__PURE__ */ Error("Login timed out. Run `npx @hype-stack/cli login` again."));
|
|
2291
|
-
},
|
|
2291
|
+
}, rr);
|
|
2292
2292
|
function o() {
|
|
2293
2293
|
clearTimeout(a), r.close(), r.closeAllConnections?.();
|
|
2294
2294
|
}
|
|
@@ -2302,7 +2302,7 @@ async function or(e = {}) {
|
|
|
2302
2302
|
r.writeHead(200, {
|
|
2303
2303
|
"Content-Type": "text/html",
|
|
2304
2304
|
Connection: "close"
|
|
2305
|
-
}), r.end(
|
|
2305
|
+
}), r.end(ir(e));
|
|
2306
2306
|
};
|
|
2307
2307
|
if (a.searchParams.get("state") !== t) {
|
|
2308
2308
|
s("Login failed."), o(), i(/* @__PURE__ */ Error("Login failed: state mismatch. Run `npx @hype-stack/cli login` again."));
|
|
@@ -2317,24 +2317,24 @@ async function or(e = {}) {
|
|
|
2317
2317
|
}), r.on("error", (e) => {
|
|
2318
2318
|
o(), i(e);
|
|
2319
2319
|
}), r.listen(0, "127.0.0.1", () => {
|
|
2320
|
-
let { port: n } = r.address(), i = encodeURIComponent(
|
|
2321
|
-
e.onUrl?.(a),
|
|
2320
|
+
let { port: n } = r.address(), i = encodeURIComponent(tr()), a = `${ce()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
|
|
2321
|
+
e.onUrl?.(a), nr(a);
|
|
2322
2322
|
});
|
|
2323
|
-
}), a = await
|
|
2323
|
+
}), a = await Vn(i).catch(() => null), o = {
|
|
2324
2324
|
token: i,
|
|
2325
2325
|
email: a?.email,
|
|
2326
2326
|
organizationId: a?.organizationId
|
|
2327
2327
|
};
|
|
2328
|
-
return await
|
|
2328
|
+
return await Zn(n, o), o;
|
|
2329
2329
|
}
|
|
2330
2330
|
//#endregion
|
|
2331
2331
|
//#region src/core/access-prompts.ts
|
|
2332
|
-
async function
|
|
2332
|
+
async function or() {
|
|
2333
2333
|
let e = await s.confirm({ message: "Log in to install packs your organization owns? (opens your browser)" });
|
|
2334
2334
|
if (s.isCancel(e) || !e) return null;
|
|
2335
2335
|
s.log.step("Opening your browser to sign in...");
|
|
2336
2336
|
try {
|
|
2337
|
-
let e = await
|
|
2337
|
+
let e = await ar({ onUrl: (e) => {
|
|
2338
2338
|
s.log.info(`If your browser didn't open, visit:\n ${R.path(e)}`);
|
|
2339
2339
|
} });
|
|
2340
2340
|
return s.log.success(e.email ? `Logged in as ${e.email}` : "Logged in"), e.token;
|
|
@@ -2342,7 +2342,7 @@ async function sr() {
|
|
|
2342
2342
|
return s.log.error(e instanceof Error ? e.message : String(e)), null;
|
|
2343
2343
|
}
|
|
2344
2344
|
}
|
|
2345
|
-
async function
|
|
2345
|
+
async function sr(e) {
|
|
2346
2346
|
if (e.length === 0) return;
|
|
2347
2347
|
B([
|
|
2348
2348
|
"These packs need a purchase before they can be installed:",
|
|
@@ -2354,7 +2354,7 @@ async function cr(e) {
|
|
|
2354
2354
|
s.log.info(R.muted("Run 'npx @hype-stack/cli login' after purchasing, then 'npx @hype-stack/cli compose' again."));
|
|
2355
2355
|
return;
|
|
2356
2356
|
}
|
|
2357
|
-
for (let t of e)
|
|
2357
|
+
for (let t of e) nr(Te(t.name));
|
|
2358
2358
|
s.log.info([
|
|
2359
2359
|
R.muted("After purchasing, run:"),
|
|
2360
2360
|
` ${R.highlight("npx @hype-stack/cli login")} ${R.muted("Save your access")}`,
|
|
@@ -2363,7 +2363,7 @@ async function cr(e) {
|
|
|
2363
2363
|
}
|
|
2364
2364
|
//#endregion
|
|
2365
2365
|
//#region src/utils/exec.ts
|
|
2366
|
-
function
|
|
2366
|
+
function J(e, t, n) {
|
|
2367
2367
|
return new Promise((r, i) => {
|
|
2368
2368
|
let a = D(e, t, {
|
|
2369
2369
|
cwd: n.cwd,
|
|
@@ -2394,7 +2394,7 @@ function q(e, t, n) {
|
|
|
2394
2394
|
});
|
|
2395
2395
|
});
|
|
2396
2396
|
}
|
|
2397
|
-
function
|
|
2397
|
+
function cr(e, t, n) {
|
|
2398
2398
|
return new Promise((r, i) => {
|
|
2399
2399
|
let a = D(e, t, {
|
|
2400
2400
|
cwd: n.cwd,
|
|
@@ -2411,7 +2411,7 @@ function lr(e, t, n) {
|
|
|
2411
2411
|
}
|
|
2412
2412
|
//#endregion
|
|
2413
2413
|
//#region src/utils/fs.ts
|
|
2414
|
-
async function
|
|
2414
|
+
async function lr(e) {
|
|
2415
2415
|
return (await y.stat(e).catch(() => null))?.isDirectory() ?? !1;
|
|
2416
2416
|
}
|
|
2417
2417
|
async function Y(e) {
|
|
@@ -2429,7 +2429,7 @@ async function fr(e, t) {
|
|
|
2429
2429
|
}
|
|
2430
2430
|
async function pr(e) {
|
|
2431
2431
|
let t = {};
|
|
2432
|
-
if (!await
|
|
2432
|
+
if (!await lr(e)) return t;
|
|
2433
2433
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
2434
2434
|
for (let r of n) r.isDirectory() && await Y(T.join(e, r.name, "package.json")) && (t[r.name] = T.relative(T.dirname(e), T.join(e, r.name)));
|
|
2435
2435
|
return t;
|
|
@@ -2470,7 +2470,7 @@ function yr(e) {
|
|
|
2470
2470
|
].join("\n"), "Database not reachable");
|
|
2471
2471
|
}
|
|
2472
2472
|
async function br(e) {
|
|
2473
|
-
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, freshScaffold: a, runCommand: o =
|
|
2473
|
+
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, freshScaffold: a, runCommand: o = cr, probeCommand: c = J } = e, l = n.backend.root, u = T.join(t, l);
|
|
2474
2474
|
if (!await Y(T.join(u, "package.json"))) return;
|
|
2475
2475
|
if (!r) {
|
|
2476
2476
|
s.log.step(R.muted(`Generating Prisma client (${R.command("prisma generate")})...`));
|
|
@@ -2663,13 +2663,13 @@ function Fr(e) {
|
|
|
2663
2663
|
//#endregion
|
|
2664
2664
|
//#region src/core/stack-config.ts
|
|
2665
2665
|
async function Ir(e) {
|
|
2666
|
-
return dr(T.join(e,
|
|
2666
|
+
return dr(T.join(e, te));
|
|
2667
2667
|
}
|
|
2668
2668
|
async function Lr(e) {
|
|
2669
|
-
return Y(T.join(e,
|
|
2669
|
+
return Y(T.join(e, te));
|
|
2670
2670
|
}
|
|
2671
2671
|
async function Rr(e, t) {
|
|
2672
|
-
await fr(T.join(e,
|
|
2672
|
+
await fr(T.join(e, te), t);
|
|
2673
2673
|
}
|
|
2674
2674
|
async function zr(e) {
|
|
2675
2675
|
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([pr(t), pr(n)]);
|
|
@@ -2714,7 +2714,7 @@ function Br(e) {
|
|
|
2714
2714
|
}
|
|
2715
2715
|
function Vr(e, t) {
|
|
2716
2716
|
return {
|
|
2717
|
-
$schema:
|
|
2717
|
+
$schema: ue(),
|
|
2718
2718
|
version: 1,
|
|
2719
2719
|
name: e,
|
|
2720
2720
|
apps: t.apps,
|
|
@@ -2725,7 +2725,7 @@ function Vr(e, t) {
|
|
|
2725
2725
|
};
|
|
2726
2726
|
}
|
|
2727
2727
|
async function Hr(e) {
|
|
2728
|
-
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([Y(t),
|
|
2728
|
+
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([Y(t), lr(n)]);
|
|
2729
2729
|
return r && i;
|
|
2730
2730
|
}
|
|
2731
2731
|
function Z(e, t) {
|
|
@@ -2740,7 +2740,7 @@ function Z(e, t) {
|
|
|
2740
2740
|
//#endregion
|
|
2741
2741
|
//#region src/core/registry.ts
|
|
2742
2742
|
async function Ur(e) {
|
|
2743
|
-
let { data: t, error: n, status: r } = await
|
|
2743
|
+
let { data: t, error: n, status: r } = await q.createRequest()({
|
|
2744
2744
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2745
2745
|
method: "GET"
|
|
2746
2746
|
}).send();
|
|
@@ -2749,12 +2749,12 @@ async function Ur(e) {
|
|
|
2749
2749
|
return t;
|
|
2750
2750
|
}
|
|
2751
2751
|
async function Wr(e, t = {}) {
|
|
2752
|
-
let n =
|
|
2752
|
+
let n = q.createRequest()({
|
|
2753
2753
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2754
2754
|
method: "POST"
|
|
2755
2755
|
}), r = {
|
|
2756
|
-
"X-Device-Id":
|
|
2757
|
-
"X-Client-Info":
|
|
2756
|
+
"X-Device-Id": er(),
|
|
2757
|
+
"X-Client-Info": tr()
|
|
2758
2758
|
};
|
|
2759
2759
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2760
2760
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -2781,7 +2781,7 @@ function Gr(e, t, n) {
|
|
|
2781
2781
|
function Kr(e, t) {
|
|
2782
2782
|
return T.join(t, e);
|
|
2783
2783
|
}
|
|
2784
|
-
var qr =
|
|
2784
|
+
var qr = q.createRequest()({
|
|
2785
2785
|
endpoint: "/packs/list",
|
|
2786
2786
|
method: "GET"
|
|
2787
2787
|
});
|
|
@@ -2792,7 +2792,7 @@ async function Jr() {
|
|
|
2792
2792
|
}
|
|
2793
2793
|
async function Yr(e, t = {}) {
|
|
2794
2794
|
if (e.length === 0) return {};
|
|
2795
|
-
let n =
|
|
2795
|
+
let n = q.createRequest()({
|
|
2796
2796
|
endpoint: "/packs/authorize",
|
|
2797
2797
|
method: "POST"
|
|
2798
2798
|
}), r = {};
|
|
@@ -2984,7 +2984,7 @@ function Ci(e, t) {
|
|
|
2984
2984
|
if (e.includes(o)) return e;
|
|
2985
2985
|
let s = RegExp(`\\[${a.replace(".", "\\.")}\\]: \\[`), c = e.match(s);
|
|
2986
2986
|
if (!c || c.index === void 0) return e;
|
|
2987
|
-
let l = c.index + c[0].length, u =
|
|
2987
|
+
let l = c.index + c[0].length, u = Xi(e, l - 1);
|
|
2988
2988
|
if (u === -1) return e;
|
|
2989
2989
|
let d = e.slice(l, u), f = d.trim(), p = f !== "" && !f.endsWith(",") ? "," : "", m = f === "" ? `\n ${o},\n ` : d.includes("\n") ? `${d}${p}\n ${o},` : `\n ${f}${p}\n ${o},\n `;
|
|
2990
2990
|
return e.slice(0, l) + m + e.slice(u);
|
|
@@ -3105,10 +3105,10 @@ var zi = {
|
|
|
3105
3105
|
async function Vi(e) {
|
|
3106
3106
|
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend", override: a = !1 } = e, o = ni(i, n), s = T.resolve(r, o, "src/constants/nav.constants.ts"), c;
|
|
3107
3107
|
await Y(s) ? c = await y.readFile(s, "utf-8") : (await y.mkdir(T.dirname(s), { recursive: !0 }), c = Ni);
|
|
3108
|
-
for (let e of t) !a && c.includes(`label: "${e.label}"`) || (c =
|
|
3109
|
-
if (a) for (let e of t) c.includes(`label: "${e.label}"`) && (c =
|
|
3110
|
-
for (let e of t) Bi.has(e.group) && (c.includes(`label: "${e.label}"`) || (c =
|
|
3111
|
-
for (let e of t.toReversed()) Bi.has(e.group) || c.includes(`label: "${e.label}"`) || (c =
|
|
3108
|
+
for (let e of t) !a && c.includes(`label: "${e.label}"`) || (c = Gi(c, e), c = qi(c, e));
|
|
3109
|
+
if (a) for (let e of t) c.includes(`label: "${e.label}"`) && (c = Zi(c, e));
|
|
3110
|
+
for (let e of t) Bi.has(e.group) && (c.includes(`label: "${e.label}"`) || (c = Yi(c, e, "append")));
|
|
3111
|
+
for (let e of t.toReversed()) Bi.has(e.group) || c.includes(`label: "${e.label}"`) || (c = Yi(c, e, "prepend"));
|
|
3112
3112
|
await y.writeFile(s, c, "utf-8");
|
|
3113
3113
|
}
|
|
3114
3114
|
async function Hi(e) {
|
|
@@ -3119,17 +3119,25 @@ async function Hi(e) {
|
|
|
3119
3119
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
3120
3120
|
await y.writeFile(o, l, "utf-8");
|
|
3121
3121
|
}
|
|
3122
|
-
function Ui(e) {
|
|
3122
|
+
async function Ui(e) {
|
|
3123
|
+
let { shouldInvertLogo: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = ni(i, n), o = T.resolve(r, a, "src/features/auth/constants/auth.constants.ts");
|
|
3124
|
+
if (!await Y(o)) return;
|
|
3125
|
+
let s = await y.readFile(o, "utf-8"), c = /export const SHOULD_INVERT_LOGO = (?:true|false);/;
|
|
3126
|
+
if (!c.test(s)) return;
|
|
3127
|
+
let l = s.replace(c, `export const SHOULD_INVERT_LOGO = ${t};`);
|
|
3128
|
+
await y.writeFile(o, l, "utf-8");
|
|
3129
|
+
}
|
|
3130
|
+
function Wi(e) {
|
|
3123
3131
|
let t = [e.icon];
|
|
3124
3132
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
3125
3133
|
return t;
|
|
3126
3134
|
}
|
|
3127
|
-
function
|
|
3128
|
-
let n =
|
|
3129
|
-
for (let e of n) r =
|
|
3135
|
+
function Gi(e, t) {
|
|
3136
|
+
let n = Wi(t), r = e;
|
|
3137
|
+
for (let e of n) r = Ki(r, e);
|
|
3130
3138
|
return r;
|
|
3131
3139
|
}
|
|
3132
|
-
function
|
|
3140
|
+
function Ki(e, t) {
|
|
3133
3141
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
3134
3142
|
if (!n) return e;
|
|
3135
3143
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -3137,43 +3145,43 @@ function Gi(e, t) {
|
|
|
3137
3145
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
3138
3146
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
3139
3147
|
}
|
|
3140
|
-
function
|
|
3148
|
+
function qi(e, t) {
|
|
3141
3149
|
if (!(t.permission || t.items?.some((e) => e.permission)) || e.includes("@hype-stack/enums\"")) return e;
|
|
3142
3150
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
3143
3151
|
if (!n) return `import { PermissionAction, PermissionSubject } from "@hype-stack/enums";\n\n${e}`;
|
|
3144
3152
|
let r = "import { PermissionAction, PermissionSubject } from \"@hype-stack/enums\";\n", i = e.indexOf("\n", n.index ?? 0);
|
|
3145
3153
|
return i === -1 ? r + e : e.slice(0, i + 1) + r + e.slice(i + 1);
|
|
3146
3154
|
}
|
|
3147
|
-
function
|
|
3155
|
+
function Ji(e) {
|
|
3148
3156
|
return `{ action: PermissionAction.${e.action}, subject: PermissionSubject.${e.subject} }`;
|
|
3149
3157
|
}
|
|
3150
|
-
function
|
|
3158
|
+
function Yi(e, t, n) {
|
|
3151
3159
|
let r = zi[t.group];
|
|
3152
3160
|
if (!r) return e;
|
|
3153
|
-
let i =
|
|
3161
|
+
let i = Qi(t), a = RegExp(`export const ${r}: NavEntry\\[\\] = \\[`), o = e.match(a);
|
|
3154
3162
|
if (!o) return e;
|
|
3155
|
-
let s = e.indexOf(o[0]) + o[0].length, c =
|
|
3163
|
+
let s = e.indexOf(o[0]) + o[0].length, c = Xi(e, s - 1);
|
|
3156
3164
|
return c === -1 ? e : e.slice(s, c).trim() === "" ? e.slice(0, s) + "\n" + i + "\n" + e.slice(s) : n === "append" ? e.slice(0, c) + i + "\n" + e.slice(c) : e.slice(0, s) + "\n" + i + e.slice(s);
|
|
3157
3165
|
}
|
|
3158
|
-
function
|
|
3166
|
+
function Xi(e, t) {
|
|
3159
3167
|
let n = 0;
|
|
3160
3168
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3161
3169
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3162
3170
|
return -1;
|
|
3163
3171
|
}
|
|
3164
|
-
function
|
|
3172
|
+
function Zi(e, t) {
|
|
3165
3173
|
let n = e.indexOf(`label: "${t.label}"`);
|
|
3166
3174
|
if (n === -1) return e;
|
|
3167
3175
|
let r = e.lastIndexOf("{", n);
|
|
3168
3176
|
if (r === -1) return e;
|
|
3169
3177
|
let i = gi(e, r);
|
|
3170
3178
|
if (i === -1) return e;
|
|
3171
|
-
let a =
|
|
3179
|
+
let a = Qi(t).trimStart().replace(/,\s*$/, "");
|
|
3172
3180
|
return e.slice(0, r) + a + e.slice(i + 1);
|
|
3173
3181
|
}
|
|
3174
|
-
function
|
|
3182
|
+
function Qi(e) {
|
|
3175
3183
|
let t = [];
|
|
3176
|
-
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.permission && t.push(` permission: ${
|
|
3184
|
+
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.permission && t.push(` permission: ${Ji(e.permission)},`), e.adminRole && t.push(` adminRole: "${e.adminRole}",`), e.items && e.items.length > 0) {
|
|
3177
3185
|
t.push(" items: [");
|
|
3178
3186
|
for (let n of e.items) {
|
|
3179
3187
|
let e = [
|
|
@@ -3181,20 +3189,20 @@ function Zi(e) {
|
|
|
3181
3189
|
`icon: ${n.icon}`,
|
|
3182
3190
|
`to: "${n.to}"`
|
|
3183
3191
|
];
|
|
3184
|
-
n.params && e.push(`params: ${n.params}`), n.permission && e.push(`permission: ${
|
|
3192
|
+
n.params && e.push(`params: ${n.params}`), n.permission && e.push(`permission: ${Ji(n.permission)}`), n.adminRole && e.push(`adminRole: "${n.adminRole}"`), t.push(` { ${e.join(", ")} },`);
|
|
3185
3193
|
}
|
|
3186
3194
|
t.push(" ],");
|
|
3187
3195
|
} else t.push(" items: [],");
|
|
3188
3196
|
return t.push(" },"), t.join("\n");
|
|
3189
3197
|
}
|
|
3190
|
-
async function
|
|
3198
|
+
async function $i(e, t, n) {
|
|
3191
3199
|
let r = Z("{{backend.features}}", t), i = T.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
|
|
3192
3200
|
if (!await Y(i)) return;
|
|
3193
3201
|
let a = await y.readFile(i, "utf-8");
|
|
3194
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
3202
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = ea(a, t), a = ta(a, t));
|
|
3195
3203
|
await y.writeFile(i, a, "utf-8");
|
|
3196
3204
|
}
|
|
3197
|
-
function
|
|
3205
|
+
function ea(e, t) {
|
|
3198
3206
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
3199
3207
|
if (r !== -1) {
|
|
3200
3208
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -3202,31 +3210,31 @@ function $i(e, t) {
|
|
|
3202
3210
|
}
|
|
3203
3211
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
3204
3212
|
}
|
|
3205
|
-
function
|
|
3213
|
+
function ta(e, t) {
|
|
3206
3214
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
3207
3215
|
if (!r) return e;
|
|
3208
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
3216
|
+
let i = e.indexOf(r[0]) + r[0].length, a = na(e, i - 1);
|
|
3209
3217
|
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);
|
|
3210
3218
|
}
|
|
3211
|
-
function
|
|
3219
|
+
function na(e, t) {
|
|
3212
3220
|
let n = 0;
|
|
3213
3221
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3214
3222
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3215
3223
|
return -1;
|
|
3216
3224
|
}
|
|
3217
|
-
var
|
|
3218
|
-
async function
|
|
3225
|
+
var ra = "import type { FC } from \"react\";\n\nexport const dashboardRows: FC[] = [];\n";
|
|
3226
|
+
async function ia(e, t, n) {
|
|
3219
3227
|
let r = Z("{{admin.root}}", t), i = T.resolve(n, r, "src/features/dashboard/constants/dashboard.rows.tsx"), a;
|
|
3220
|
-
await Y(i) ? a = await y.readFile(i, "utf-8") : (await y.mkdir(T.dirname(i), { recursive: !0 }), a =
|
|
3221
|
-
for (let t of e) a =
|
|
3222
|
-
for (let t of e) t.position !== "prepend" && (a =
|
|
3228
|
+
await Y(i) ? a = await y.readFile(i, "utf-8") : (await y.mkdir(T.dirname(i), { recursive: !0 }), a = ra);
|
|
3229
|
+
for (let t of e) a = aa(a, t);
|
|
3230
|
+
for (let t of e) t.position !== "prepend" && (a = oa(a, t, "append"));
|
|
3223
3231
|
for (let t = e.length - 1; t >= 0; t--) {
|
|
3224
3232
|
let n = e[t];
|
|
3225
|
-
n.position === "prepend" && (a =
|
|
3233
|
+
n.position === "prepend" && (a = oa(a, n, "prepend"));
|
|
3226
3234
|
}
|
|
3227
3235
|
await y.writeFile(i, a, "utf-8");
|
|
3228
3236
|
}
|
|
3229
|
-
function
|
|
3237
|
+
function aa(e, t) {
|
|
3230
3238
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
3231
3239
|
if (e.includes(n)) return e;
|
|
3232
3240
|
let r = e.lastIndexOf("import ");
|
|
@@ -3234,56 +3242,56 @@ function ia(e, t) {
|
|
|
3234
3242
|
let i = e.indexOf("\n", r);
|
|
3235
3243
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
3236
3244
|
}
|
|
3237
|
-
function
|
|
3245
|
+
function oa(e, t, n) {
|
|
3238
3246
|
let r = ` ${t.import},`, i = e.match(/export const dashboardRows[^=]*=\s*\[/);
|
|
3239
3247
|
if (!i) return e;
|
|
3240
|
-
let a = e.indexOf(i[0]) + i[0].length, o =
|
|
3248
|
+
let a = e.indexOf(i[0]) + i[0].length, o = sa(e, a - 1);
|
|
3241
3249
|
if (o === -1) return e;
|
|
3242
3250
|
let s = e.slice(a, o);
|
|
3243
3251
|
return s.includes(r) ? e : s.trim() === "" ? e.slice(0, a) + "\n" + r + "\n" + e.slice(a) : n === "append" ? e.slice(0, o) + r + "\n" + e.slice(o) : e.slice(0, a) + "\n" + r + e.slice(a);
|
|
3244
3252
|
}
|
|
3245
|
-
function
|
|
3253
|
+
function sa(e, t) {
|
|
3246
3254
|
let n = 0;
|
|
3247
3255
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3248
3256
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3249
3257
|
return -1;
|
|
3250
3258
|
}
|
|
3251
|
-
var
|
|
3252
|
-
async function
|
|
3259
|
+
var ca = "import type { FC } from \"react\";\n\nexport const organizationDetailsRows: FC<{ organizationId: string }>[] = [];\n", la = "import type { FC } from \"react\";\n\nexport const organizationDetailsCards: FC<{ organizationId: string }>[] = [];\n";
|
|
3260
|
+
async function ua({ components: e, paths: t, projectRoot: n, kind: r }) {
|
|
3253
3261
|
let i = Z("{{admin.root}}", t), a = r === "rows" ? "organization-details.rows.tsx" : "organization-details.cards.tsx", o = T.resolve(n, i, "src/features/organizations/constants", a), s;
|
|
3254
|
-
await Y(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = r === "rows" ?
|
|
3262
|
+
await Y(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = r === "rows" ? ca : la);
|
|
3255
3263
|
let c = r === "rows" ? "organizationDetailsRows" : "organizationDetailsCards";
|
|
3256
|
-
for (let t of e) s =
|
|
3257
|
-
for (let t of e) t.position !== "prepend" && (s =
|
|
3264
|
+
for (let t of e) s = pa(s, t);
|
|
3265
|
+
for (let t of e) t.position !== "prepend" && (s = ma(s, t, {
|
|
3258
3266
|
arrayName: c,
|
|
3259
3267
|
position: "append"
|
|
3260
3268
|
}));
|
|
3261
3269
|
for (let t = e.length - 1; t >= 0; t--) {
|
|
3262
3270
|
let n = e[t];
|
|
3263
|
-
n.position === "prepend" && (s =
|
|
3271
|
+
n.position === "prepend" && (s = ma(s, n, {
|
|
3264
3272
|
arrayName: c,
|
|
3265
3273
|
position: "prepend"
|
|
3266
3274
|
}));
|
|
3267
3275
|
}
|
|
3268
3276
|
await y.writeFile(o, s, "utf-8");
|
|
3269
3277
|
}
|
|
3270
|
-
async function
|
|
3271
|
-
await
|
|
3278
|
+
async function da(e, t, n) {
|
|
3279
|
+
await ua({
|
|
3272
3280
|
components: e,
|
|
3273
3281
|
paths: t,
|
|
3274
3282
|
projectRoot: n,
|
|
3275
3283
|
kind: "rows"
|
|
3276
3284
|
});
|
|
3277
3285
|
}
|
|
3278
|
-
async function
|
|
3279
|
-
await
|
|
3286
|
+
async function fa(e, t, n) {
|
|
3287
|
+
await ua({
|
|
3280
3288
|
components: e,
|
|
3281
3289
|
paths: t,
|
|
3282
3290
|
projectRoot: n,
|
|
3283
3291
|
kind: "cards"
|
|
3284
3292
|
});
|
|
3285
3293
|
}
|
|
3286
|
-
function
|
|
3294
|
+
function pa(e, t) {
|
|
3287
3295
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
3288
3296
|
if (e.includes(n)) return e;
|
|
3289
3297
|
let r = e.lastIndexOf("import ");
|
|
@@ -3291,40 +3299,40 @@ function fa(e, t) {
|
|
|
3291
3299
|
let i = e.indexOf("\n", r);
|
|
3292
3300
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
3293
3301
|
}
|
|
3294
|
-
function
|
|
3302
|
+
function ma(e, t, n) {
|
|
3295
3303
|
let { arrayName: r, position: i } = n, a = ` ${t.import},`, o = e.match(RegExp(`export const ${r}[^=]*=\\s*\\[`));
|
|
3296
3304
|
if (!o) return e;
|
|
3297
|
-
let s = e.indexOf(o[0]) + o[0].length, c =
|
|
3305
|
+
let s = e.indexOf(o[0]) + o[0].length, c = ha(e, s - 1);
|
|
3298
3306
|
if (c === -1) return e;
|
|
3299
3307
|
let l = e.slice(s, c);
|
|
3300
3308
|
return l.includes(a) ? e : l.trim() === "" ? e.slice(0, s) + "\n" + a + "\n" + e.slice(s) : i === "append" ? e.slice(0, c) + a + "\n" + e.slice(c) : e.slice(0, s) + "\n" + a + e.slice(s);
|
|
3301
3309
|
}
|
|
3302
|
-
function
|
|
3310
|
+
function ha(e, t) {
|
|
3303
3311
|
let n = 0;
|
|
3304
3312
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3305
3313
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3306
3314
|
return -1;
|
|
3307
3315
|
}
|
|
3308
|
-
var
|
|
3309
|
-
async function
|
|
3310
|
-
await
|
|
3316
|
+
var ga = "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";
|
|
3317
|
+
async function _a(e) {
|
|
3318
|
+
await ya({
|
|
3311
3319
|
...e,
|
|
3312
3320
|
arrayName: "navbarActions"
|
|
3313
3321
|
});
|
|
3314
3322
|
}
|
|
3315
|
-
async function
|
|
3316
|
-
await
|
|
3323
|
+
async function va(e) {
|
|
3324
|
+
await ya({
|
|
3317
3325
|
...e,
|
|
3318
3326
|
arrayName: "userMenuActions"
|
|
3319
3327
|
});
|
|
3320
3328
|
}
|
|
3321
|
-
async function
|
|
3329
|
+
async function ya({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
|
|
3322
3330
|
let a = ni(i, n), o = T.resolve(r, a, "src/constants/navbar-actions.tsx"), s;
|
|
3323
|
-
await Y(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s =
|
|
3324
|
-
for (let n of e) s =
|
|
3331
|
+
await Y(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = ga);
|
|
3332
|
+
for (let n of e) s = ba(s, n), s = xa(s, n, t);
|
|
3325
3333
|
await y.writeFile(o, s, "utf-8");
|
|
3326
3334
|
}
|
|
3327
|
-
function
|
|
3335
|
+
function ba(e, t) {
|
|
3328
3336
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
3329
3337
|
if (e.includes(n)) return e;
|
|
3330
3338
|
let r = e.lastIndexOf("import ");
|
|
@@ -3332,38 +3340,38 @@ function ya(e, t) {
|
|
|
3332
3340
|
let i = e.indexOf("\n", r);
|
|
3333
3341
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
3334
3342
|
}
|
|
3335
|
-
function
|
|
3343
|
+
function xa(e, t, n) {
|
|
3336
3344
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
3337
3345
|
if (!r) return e;
|
|
3338
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
3346
|
+
let i = e.indexOf(r[0]) + r[0].length, a = Sa(e, i - 1);
|
|
3339
3347
|
if (a === -1) return e;
|
|
3340
3348
|
let o = e.slice(i, a);
|
|
3341
3349
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
3342
3350
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
3343
3351
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
3344
3352
|
}
|
|
3345
|
-
function
|
|
3353
|
+
function Sa(e, t) {
|
|
3346
3354
|
let n = 0;
|
|
3347
3355
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3348
3356
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3349
3357
|
return -1;
|
|
3350
3358
|
}
|
|
3351
|
-
var
|
|
3359
|
+
var Ca = new Set([
|
|
3352
3360
|
".ts",
|
|
3353
3361
|
".tsx",
|
|
3354
3362
|
".js",
|
|
3355
3363
|
".jsx"
|
|
3356
3364
|
]);
|
|
3357
|
-
async function
|
|
3365
|
+
async function wa(e) {
|
|
3358
3366
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
3359
3367
|
if (i === "hype-stack") return;
|
|
3360
3368
|
let a = `@${i}/`;
|
|
3361
3369
|
await Promise.all(t.map(async (e) => {
|
|
3362
3370
|
let t = Gr(e.target, n, r), i = await y.stat(t).catch(() => null);
|
|
3363
|
-
i?.isDirectory() ? await
|
|
3371
|
+
i?.isDirectory() ? await Ea(t, a) : i?.isFile() && Ca.has(T.extname(t)) && await Da(t, a);
|
|
3364
3372
|
}));
|
|
3365
3373
|
}
|
|
3366
|
-
var
|
|
3374
|
+
var Ta = new Set([
|
|
3367
3375
|
".git",
|
|
3368
3376
|
"node_modules",
|
|
3369
3377
|
"dist",
|
|
@@ -3372,23 +3380,23 @@ var wa = new Set([
|
|
|
3372
3380
|
".next",
|
|
3373
3381
|
"coverage"
|
|
3374
3382
|
]);
|
|
3375
|
-
async function
|
|
3383
|
+
async function Ea(e, t) {
|
|
3376
3384
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3377
3385
|
await Promise.all(n.map(async (n) => {
|
|
3378
3386
|
let r = T.join(e, n.name);
|
|
3379
3387
|
if (n.isDirectory()) {
|
|
3380
|
-
if (
|
|
3381
|
-
await
|
|
3382
|
-
} else n.isFile() &&
|
|
3388
|
+
if (Ta.has(n.name)) return;
|
|
3389
|
+
await Ea(r, t);
|
|
3390
|
+
} else n.isFile() && Ca.has(T.extname(n.name)) && await Da(r, t);
|
|
3383
3391
|
}));
|
|
3384
3392
|
}
|
|
3385
|
-
async function
|
|
3393
|
+
async function Da(e, t) {
|
|
3386
3394
|
let n = await y.readFile(e, "utf-8");
|
|
3387
3395
|
if (!n.includes(Xr)) return;
|
|
3388
3396
|
let r = ei(n, t);
|
|
3389
3397
|
r !== n && await y.writeFile(e, r, "utf-8");
|
|
3390
3398
|
}
|
|
3391
|
-
var
|
|
3399
|
+
var Oa = new Set([
|
|
3392
3400
|
".git",
|
|
3393
3401
|
"node_modules",
|
|
3394
3402
|
"dist",
|
|
@@ -3398,12 +3406,12 @@ var Da = new Set([
|
|
|
3398
3406
|
".turbo",
|
|
3399
3407
|
".cache",
|
|
3400
3408
|
"coverage"
|
|
3401
|
-
]),
|
|
3409
|
+
]), ka = new Set([
|
|
3402
3410
|
"pnpm-lock.yaml",
|
|
3403
3411
|
"package-lock.json",
|
|
3404
3412
|
"yarn.lock",
|
|
3405
3413
|
"bun.lockb"
|
|
3406
|
-
]),
|
|
3414
|
+
]), Aa = new Set([
|
|
3407
3415
|
".png",
|
|
3408
3416
|
".jpg",
|
|
3409
3417
|
".jpeg",
|
|
@@ -3430,21 +3438,21 @@ var Da = new Set([
|
|
|
3430
3438
|
".mp3",
|
|
3431
3439
|
".wav"
|
|
3432
3440
|
]);
|
|
3433
|
-
async function Aa(e, t) {
|
|
3434
|
-
t !== "hype-stack" && await ja(e, t);
|
|
3435
|
-
}
|
|
3436
3441
|
async function ja(e, t) {
|
|
3442
|
+
t !== "hype-stack" && await Ma(e, t);
|
|
3443
|
+
}
|
|
3444
|
+
async function Ma(e, t) {
|
|
3437
3445
|
let n = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
3438
3446
|
await Promise.all(n.map(async (n) => {
|
|
3439
3447
|
let r = T.join(e, n.name);
|
|
3440
3448
|
if (n.isDirectory()) {
|
|
3441
|
-
if (
|
|
3442
|
-
await
|
|
3443
|
-
} else n.isFile() && await
|
|
3449
|
+
if (Oa.has(n.name)) return;
|
|
3450
|
+
await Ma(r, t);
|
|
3451
|
+
} else n.isFile() && await Na(r, t);
|
|
3444
3452
|
}));
|
|
3445
3453
|
}
|
|
3446
|
-
async function
|
|
3447
|
-
if (
|
|
3454
|
+
async function Na(e, t) {
|
|
3455
|
+
if (ka.has(T.basename(e)) || Aa.has(T.extname(e).toLowerCase())) return;
|
|
3448
3456
|
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
3449
3457
|
if (n === null || n.includes("\0") || !n.includes("hype-stack") && !n.includes(Qr)) return;
|
|
3450
3458
|
let r = ti(n, t);
|
|
@@ -3452,25 +3460,25 @@ async function Ma(e, t) {
|
|
|
3452
3460
|
}
|
|
3453
3461
|
//#endregion
|
|
3454
3462
|
//#region src/core/installer.ts
|
|
3455
|
-
function
|
|
3463
|
+
function Pa(e, t, n) {
|
|
3456
3464
|
return e.slot ? t ? t.includes(e.slot) : e.slot === "admin" ? n : e.slot === "frontend" : !0;
|
|
3457
3465
|
}
|
|
3458
|
-
function
|
|
3466
|
+
function Fa(e) {
|
|
3459
3467
|
return !!e.apps?.admin;
|
|
3460
3468
|
}
|
|
3461
|
-
async function
|
|
3469
|
+
async function Ia(e, t) {
|
|
3462
3470
|
if ((await y.stat(e)).isDirectory()) {
|
|
3463
3471
|
await y.mkdir(t, { recursive: !0 });
|
|
3464
3472
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3465
|
-
for (let r of n) await
|
|
3473
|
+
for (let r of n) await Ia(T.join(e, r.name), T.join(t, r.name));
|
|
3466
3474
|
} else await y.mkdir(T.dirname(t), { recursive: !0 }), await y.copyFile(e, t);
|
|
3467
3475
|
}
|
|
3468
|
-
async function
|
|
3476
|
+
async function La(e) {
|
|
3469
3477
|
let { src: t, dest: n, projectRoot: r, skip: i } = e;
|
|
3470
3478
|
if ((await y.stat(t)).isDirectory()) {
|
|
3471
3479
|
await y.mkdir(n, { recursive: !0 });
|
|
3472
3480
|
let e = await y.readdir(t, { withFileTypes: !0 });
|
|
3473
|
-
return (await Promise.all(e.map((e) =>
|
|
3481
|
+
return (await Promise.all(e.map((e) => La({
|
|
3474
3482
|
src: T.join(t, e.name),
|
|
3475
3483
|
dest: T.join(n, e.name),
|
|
3476
3484
|
projectRoot: r,
|
|
@@ -3479,17 +3487,17 @@ async function Ia(e) {
|
|
|
3479
3487
|
}
|
|
3480
3488
|
return i.has(t) ? [] : (await y.mkdir(T.dirname(n), { recursive: !0 }), await y.copyFile(t, n), [T.relative(r, n)]);
|
|
3481
3489
|
}
|
|
3482
|
-
async function
|
|
3490
|
+
async function Ra(e) {
|
|
3483
3491
|
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = Kr(t.source, n), o = Gr(t.target, r, i);
|
|
3484
3492
|
return {
|
|
3485
3493
|
sourcePath: a,
|
|
3486
3494
|
targetPath: o,
|
|
3487
|
-
sourceExists: await Y(a) || await
|
|
3488
|
-
targetExists: await Y(o) || await
|
|
3495
|
+
sourceExists: await Y(a) || await lr(a),
|
|
3496
|
+
targetExists: await Y(o) || await lr(o)
|
|
3489
3497
|
};
|
|
3490
3498
|
}
|
|
3491
|
-
async function
|
|
3492
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await
|
|
3499
|
+
async function za(e) {
|
|
3500
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await Ra({
|
|
3493
3501
|
file: t,
|
|
3494
3502
|
packDir: n,
|
|
3495
3503
|
paths: r,
|
|
@@ -3504,8 +3512,8 @@ async function Ra(e) {
|
|
|
3504
3512
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3505
3513
|
}
|
|
3506
3514
|
}
|
|
3507
|
-
async function
|
|
3508
|
-
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await
|
|
3515
|
+
async function Ba(e) {
|
|
3516
|
+
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await Ra({
|
|
3509
3517
|
file: t,
|
|
3510
3518
|
packDir: n,
|
|
3511
3519
|
paths: r,
|
|
@@ -3523,7 +3531,7 @@ async function za(e) {
|
|
|
3523
3531
|
status: "skipped",
|
|
3524
3532
|
path: t.target,
|
|
3525
3533
|
reason: "Already exists"
|
|
3526
|
-
} : (await
|
|
3534
|
+
} : (await Ia(s, c), {
|
|
3527
3535
|
status: "installed",
|
|
3528
3536
|
path: t.target
|
|
3529
3537
|
});
|
|
@@ -3532,16 +3540,16 @@ async function za(e) {
|
|
|
3532
3540
|
status: "skipped",
|
|
3533
3541
|
path: t.target,
|
|
3534
3542
|
reason: "Already exists (skip-if-exists)"
|
|
3535
|
-
} : (await
|
|
3543
|
+
} : (await Ia(s, c), {
|
|
3536
3544
|
status: "installed",
|
|
3537
3545
|
path: t.target
|
|
3538
3546
|
});
|
|
3539
|
-
case "override": return await
|
|
3547
|
+
case "override": return await Ia(s, c), {
|
|
3540
3548
|
status: "installed",
|
|
3541
3549
|
path: t.target
|
|
3542
3550
|
};
|
|
3543
3551
|
case "merge": {
|
|
3544
|
-
if (!u) return await
|
|
3552
|
+
if (!u) return await Ia(s, c), {
|
|
3545
3553
|
status: "installed",
|
|
3546
3554
|
path: t.target
|
|
3547
3555
|
};
|
|
@@ -3571,15 +3579,15 @@ async function za(e) {
|
|
|
3571
3579
|
};
|
|
3572
3580
|
}
|
|
3573
3581
|
}
|
|
3574
|
-
async function
|
|
3582
|
+
async function Va(e) {
|
|
3575
3583
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3576
3584
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3577
|
-
let o = [], s = /* @__PURE__ */ new Set(), c =
|
|
3585
|
+
let o = [], s = /* @__PURE__ */ new Set(), c = Fa(n);
|
|
3578
3586
|
for (let e of t) {
|
|
3579
3587
|
let t = i?.get(e.manifest.name);
|
|
3580
3588
|
for (let n of e.manifest.files) {
|
|
3581
|
-
if (n.strategy !== "create" || !
|
|
3582
|
-
let { targetPath: i, targetExists: l } = await
|
|
3589
|
+
if (n.strategy !== "create" || !Pa(n, t, c)) continue;
|
|
3590
|
+
let { targetPath: i, targetExists: l } = await Ra({
|
|
3583
3591
|
file: n,
|
|
3584
3592
|
packDir: e.packDir,
|
|
3585
3593
|
paths: a,
|
|
@@ -3594,13 +3602,13 @@ async function Ba(e) {
|
|
|
3594
3602
|
}
|
|
3595
3603
|
return o;
|
|
3596
3604
|
}
|
|
3597
|
-
async function
|
|
3605
|
+
async function Ha(e) {
|
|
3598
3606
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3599
3607
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3600
|
-
let c =
|
|
3608
|
+
let c = Fa(n), l = [];
|
|
3601
3609
|
for (let e of t.files) {
|
|
3602
|
-
if (!
|
|
3603
|
-
let t = await
|
|
3610
|
+
if (!Pa(e, o, c)) continue;
|
|
3611
|
+
let t = await za({
|
|
3604
3612
|
file: e,
|
|
3605
3613
|
packDir: a,
|
|
3606
3614
|
paths: s,
|
|
@@ -3611,16 +3619,16 @@ async function Va(e) {
|
|
|
3611
3619
|
}
|
|
3612
3620
|
return l;
|
|
3613
3621
|
}
|
|
3614
|
-
async function
|
|
3622
|
+
async function Ua(e) {
|
|
3615
3623
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3616
3624
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3617
3625
|
let l = {
|
|
3618
3626
|
installed: [],
|
|
3619
3627
|
skipped: [],
|
|
3620
3628
|
errors: []
|
|
3621
|
-
}, u =
|
|
3629
|
+
}, u = Fa(n), d = t.files.filter((e) => Pa(e, s, u));
|
|
3622
3630
|
for (let e of d) {
|
|
3623
|
-
let t = await
|
|
3631
|
+
let t = await Ba({
|
|
3624
3632
|
file: e,
|
|
3625
3633
|
packDir: o,
|
|
3626
3634
|
paths: c,
|
|
@@ -3640,7 +3648,7 @@ async function Ha(e) {
|
|
|
3640
3648
|
break;
|
|
3641
3649
|
}
|
|
3642
3650
|
}
|
|
3643
|
-
await
|
|
3651
|
+
await wa({
|
|
3644
3652
|
files: d,
|
|
3645
3653
|
paths: c,
|
|
3646
3654
|
projectRoot: r,
|
|
@@ -3670,7 +3678,7 @@ async function Ha(e) {
|
|
|
3670
3678
|
if (f.includes(e)) {
|
|
3671
3679
|
if (t.navbarActions && t.navbarActions.length > 0) {
|
|
3672
3680
|
let n = t.navbarActions.filter((t) => !t.slot || t.slot === e);
|
|
3673
|
-
n.length > 0 && await
|
|
3681
|
+
n.length > 0 && await _a({
|
|
3674
3682
|
actions: n,
|
|
3675
3683
|
paths: c,
|
|
3676
3684
|
projectRoot: r,
|
|
@@ -3679,7 +3687,7 @@ async function Ha(e) {
|
|
|
3679
3687
|
}
|
|
3680
3688
|
if (t.userMenuActions && t.userMenuActions.length > 0) {
|
|
3681
3689
|
let n = t.userMenuActions.filter((t) => !t.slot || t.slot === e);
|
|
3682
|
-
n.length > 0 && await
|
|
3690
|
+
n.length > 0 && await va({
|
|
3683
3691
|
actions: n,
|
|
3684
3692
|
paths: c,
|
|
3685
3693
|
projectRoot: r,
|
|
@@ -3688,17 +3696,22 @@ async function Ha(e) {
|
|
|
3688
3696
|
}
|
|
3689
3697
|
}
|
|
3690
3698
|
}
|
|
3691
|
-
return t.onboardingSteps && t.onboardingSteps.length > 0 && await
|
|
3699
|
+
return t.onboardingSteps && t.onboardingSteps.length > 0 && await $i(t.onboardingSteps, c, r), u && t.dashboardRows && t.dashboardRows.length > 0 && await ia(t.dashboardRows, c, r), u && t.orgDetailsRows && t.orgDetailsRows.length > 0 && await da(t.orgDetailsRows, c, r), u && t.orgDetailsCards && t.orgDetailsCards.length > 0 && await fa(t.orgDetailsCards, c, r), t.postLoginRedirect && await Hi({
|
|
3692
3700
|
postLoginRedirect: t.postLoginRedirect,
|
|
3693
3701
|
paths: c,
|
|
3694
3702
|
projectRoot: r,
|
|
3695
3703
|
slot: f[0]
|
|
3704
|
+
}), t.shouldInvertLogo !== void 0 && await Ui({
|
|
3705
|
+
shouldInvertLogo: t.shouldInvertLogo,
|
|
3706
|
+
paths: c,
|
|
3707
|
+
projectRoot: r,
|
|
3708
|
+
slot: f[0]
|
|
3696
3709
|
}), l;
|
|
3697
3710
|
}
|
|
3698
|
-
async function
|
|
3711
|
+
async function Wa(e) {
|
|
3699
3712
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3700
3713
|
for (let e of t) {
|
|
3701
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3714
|
+
let t = o?.get(e.manifest.name), a = await Ha({
|
|
3702
3715
|
manifest: e.manifest,
|
|
3703
3716
|
config: n,
|
|
3704
3717
|
projectRoot: r,
|
|
@@ -3718,7 +3731,7 @@ async function Ua(e) {
|
|
|
3718
3731
|
};
|
|
3719
3732
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3720
3733
|
for (let e of t) {
|
|
3721
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3734
|
+
let t = o?.get(e.manifest.name), n = await Ua({
|
|
3722
3735
|
manifest: e.manifest,
|
|
3723
3736
|
config: f,
|
|
3724
3737
|
projectRoot: r,
|
|
@@ -3727,7 +3740,7 @@ async function Ua(e) {
|
|
|
3727
3740
|
packDir: e.packDir,
|
|
3728
3741
|
slots: t
|
|
3729
3742
|
});
|
|
3730
|
-
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await
|
|
3743
|
+
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await Ga(f, e.manifest, r), d.push(e.manifest.name);
|
|
3731
3744
|
}
|
|
3732
3745
|
return {
|
|
3733
3746
|
installed: c,
|
|
@@ -3738,7 +3751,7 @@ async function Ua(e) {
|
|
|
3738
3751
|
config: f
|
|
3739
3752
|
};
|
|
3740
3753
|
}
|
|
3741
|
-
async function
|
|
3754
|
+
async function Ga(e, t, n) {
|
|
3742
3755
|
let r = typeof t == "string" ? t : t.name, i = typeof t == "string" ? [] : Mr(t.env), a = Nr([...e.onboarding?.envSections ?? [], ...i]), o = {
|
|
3743
3756
|
...e,
|
|
3744
3757
|
installedPacks: [...e.installedPacks ?? [], r],
|
|
@@ -3749,17 +3762,17 @@ async function Wa(e, t, n) {
|
|
|
3749
3762
|
};
|
|
3750
3763
|
return await Rr(n, o), o;
|
|
3751
3764
|
}
|
|
3752
|
-
async function
|
|
3765
|
+
async function Ka(e) {
|
|
3753
3766
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3754
3767
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3755
3768
|
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) => Kr(e.source, i))), u = T.join(i, "files");
|
|
3756
|
-
if (await
|
|
3769
|
+
if (await lr(u)) {
|
|
3757
3770
|
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3758
3771
|
for (let t of e) {
|
|
3759
3772
|
if (!t.isDirectory()) continue;
|
|
3760
3773
|
let e = a[t.name]?.root;
|
|
3761
3774
|
if (!e) continue;
|
|
3762
|
-
let n = await
|
|
3775
|
+
let n = await La({
|
|
3763
3776
|
src: T.join(u, t.name),
|
|
3764
3777
|
dest: T.resolve(r, e),
|
|
3765
3778
|
projectRoot: r,
|
|
@@ -3769,7 +3782,7 @@ async function Ga(e) {
|
|
|
3769
3782
|
}
|
|
3770
3783
|
}
|
|
3771
3784
|
for (let e of c) {
|
|
3772
|
-
let t = await
|
|
3785
|
+
let t = await Ba({
|
|
3773
3786
|
file: e,
|
|
3774
3787
|
packDir: i,
|
|
3775
3788
|
paths: a,
|
|
@@ -3780,7 +3793,7 @@ async function Ga(e) {
|
|
|
3780
3793
|
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3781
3794
|
}
|
|
3782
3795
|
let d = T.join(Gr("{{frontend.root}}", a, r), "src", "routes"), f = T.join(d, "(public)", "index.tsx"), p = T.join(d, "(private)", "index.tsx");
|
|
3783
|
-
return await Y(f) && await Y(p) && await y.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await ji(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await Vi({
|
|
3796
|
+
return await Y(f) && await Y(p) && await y.rm(p, { force: !0 }), t.routes && t.routes.length > 0 && await li(t.routes, a, r), t.sockets && t.sockets.length > 0 && await wi(t.sockets, a, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await Oi(t.sdkConfigurations, a, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await ji(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await Vi({
|
|
3784
3797
|
entries: t.nav,
|
|
3785
3798
|
paths: a,
|
|
3786
3799
|
projectRoot: r,
|
|
@@ -3789,6 +3802,10 @@ async function Ga(e) {
|
|
|
3789
3802
|
postLoginRedirect: t.postLoginRedirect,
|
|
3790
3803
|
paths: a,
|
|
3791
3804
|
projectRoot: r
|
|
3805
|
+
}), t.shouldInvertLogo !== void 0 && await Ui({
|
|
3806
|
+
shouldInvertLogo: t.shouldInvertLogo,
|
|
3807
|
+
paths: a,
|
|
3808
|
+
projectRoot: r
|
|
3792
3809
|
}), {
|
|
3793
3810
|
installed: o,
|
|
3794
3811
|
errors: s
|
|
@@ -3796,35 +3813,35 @@ async function Ga(e) {
|
|
|
3796
3813
|
}
|
|
3797
3814
|
//#endregion
|
|
3798
3815
|
//#region src/core/pack-categories.ts
|
|
3799
|
-
var
|
|
3816
|
+
var qa = [
|
|
3800
3817
|
"starter",
|
|
3801
3818
|
"layout",
|
|
3802
3819
|
"feature"
|
|
3803
|
-
],
|
|
3820
|
+
], Ja = {
|
|
3804
3821
|
starter: "Starter",
|
|
3805
3822
|
layout: "Layout",
|
|
3806
3823
|
feature: "Features"
|
|
3807
|
-
},
|
|
3808
|
-
function
|
|
3824
|
+
}, Ya = new Set(["starter", "layout"]), Xa = "starter-saas-betterauth", Za = "layout-basic";
|
|
3825
|
+
function Qa(e, t = {}) {
|
|
3809
3826
|
let n = [];
|
|
3810
|
-
for (let r of
|
|
3827
|
+
for (let r of qa) {
|
|
3811
3828
|
let i = e.filter((e) => e.category === r);
|
|
3812
3829
|
if (i.length === 0) continue;
|
|
3813
|
-
let a =
|
|
3830
|
+
let a = Ya.has(r) ? "single" : "multiple";
|
|
3814
3831
|
if (r === "layout") {
|
|
3815
|
-
if (n.push(
|
|
3832
|
+
if (n.push(eo("frontend", i)), t.adminAvailable) {
|
|
3816
3833
|
let e = i.filter((e) => e.adminCompatible);
|
|
3817
|
-
e.length > 0 && n.push(
|
|
3834
|
+
e.length > 0 && n.push(eo("admin", e));
|
|
3818
3835
|
}
|
|
3819
3836
|
continue;
|
|
3820
3837
|
}
|
|
3821
3838
|
if (r === "starter") {
|
|
3822
|
-
n.push(
|
|
3839
|
+
n.push($a(i));
|
|
3823
3840
|
continue;
|
|
3824
3841
|
}
|
|
3825
3842
|
n.push({
|
|
3826
3843
|
category: r,
|
|
3827
|
-
label:
|
|
3844
|
+
label: Ja[r],
|
|
3828
3845
|
mode: a,
|
|
3829
3846
|
packs: i,
|
|
3830
3847
|
preselect: null
|
|
@@ -3832,36 +3849,36 @@ function Za(e, t = {}) {
|
|
|
3832
3849
|
}
|
|
3833
3850
|
return n;
|
|
3834
3851
|
}
|
|
3835
|
-
function
|
|
3836
|
-
let t = e.some((e) => e.name ===
|
|
3852
|
+
function $a(e) {
|
|
3853
|
+
let t = e.some((e) => e.name === Xa);
|
|
3837
3854
|
return {
|
|
3838
3855
|
category: "starter",
|
|
3839
|
-
label:
|
|
3856
|
+
label: Ja.starter,
|
|
3840
3857
|
mode: "single",
|
|
3841
3858
|
packs: e,
|
|
3842
|
-
preselect: t ?
|
|
3859
|
+
preselect: t ? Xa : null
|
|
3843
3860
|
};
|
|
3844
3861
|
}
|
|
3845
|
-
function
|
|
3846
|
-
let n = t.some((e) => e.name ===
|
|
3862
|
+
function eo(e, t) {
|
|
3863
|
+
let n = t.some((e) => e.name === Za);
|
|
3847
3864
|
return {
|
|
3848
3865
|
category: "layout",
|
|
3849
3866
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3850
3867
|
mode: "single",
|
|
3851
3868
|
packs: t,
|
|
3852
|
-
preselect: n ?
|
|
3869
|
+
preselect: n ? Za : null,
|
|
3853
3870
|
slot: e
|
|
3854
3871
|
};
|
|
3855
3872
|
}
|
|
3856
3873
|
//#endregion
|
|
3857
3874
|
//#region src/core/post-setup.ts
|
|
3858
|
-
async function
|
|
3859
|
-
return (await
|
|
3875
|
+
async function to() {
|
|
3876
|
+
return (await J("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3860
3877
|
}
|
|
3861
|
-
async function
|
|
3878
|
+
async function no(e) {
|
|
3862
3879
|
return Y(`${e}/apps/backend/.env`);
|
|
3863
3880
|
}
|
|
3864
|
-
async function
|
|
3881
|
+
async function ro(e, t, n) {
|
|
3865
3882
|
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({
|
|
3866
3883
|
message: r,
|
|
3867
3884
|
initialValue: !0
|
|
@@ -3869,37 +3886,37 @@ async function no(e, t, n) {
|
|
|
3869
3886
|
if (s.isCancel(i) && V(), !i) return s.log.info(R.muted("Skipping Docker services and database migrations.")), !1;
|
|
3870
3887
|
let a = s.spinner();
|
|
3871
3888
|
a.start("Starting Docker services...");
|
|
3872
|
-
let o = await
|
|
3889
|
+
let o = await J("docker", [
|
|
3873
3890
|
"compose",
|
|
3874
3891
|
"up",
|
|
3875
3892
|
"-d"
|
|
3876
3893
|
], { cwd: `${e}/apps/backend` });
|
|
3877
|
-
return o.exitCode === 0 ? (a.stop(R.success("Docker services started")), !0) : (a.error("Failed to start Docker services"),
|
|
3894
|
+
return o.exitCode === 0 ? (a.stop(R.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), co(o), !1);
|
|
3878
3895
|
}
|
|
3879
|
-
function
|
|
3896
|
+
function io(e) {
|
|
3880
3897
|
let t = (e.stderr || e.stdout).trim();
|
|
3881
3898
|
t && s.log.warn(R.muted(t));
|
|
3882
3899
|
}
|
|
3883
|
-
function
|
|
3900
|
+
function ao(e) {
|
|
3884
3901
|
return /is already in use by container|Conflict\. The container name/i.test(e) ? "container" : /port is already allocated|address already in use|Bind for .+ failed|failed to (?:bind|set up) .*port/i.test(e) ? "port" : null;
|
|
3885
3902
|
}
|
|
3886
|
-
function
|
|
3903
|
+
function oo(e) {
|
|
3887
3904
|
return e.match(/container name "\/?([^"]+)"/i)?.[1] ?? null;
|
|
3888
3905
|
}
|
|
3889
|
-
function
|
|
3906
|
+
function so(e) {
|
|
3890
3907
|
return e.match(/Bind for [^:]*:(\d{2,5})/i)?.[1] ?? e.match(/:(\d{2,5})(?:->|\b)[^\n]*(?:already allocated|already in use)/i)?.[1] ?? null;
|
|
3891
3908
|
}
|
|
3892
|
-
function
|
|
3893
|
-
let t = (e.stderr || e.stdout).trim(), n =
|
|
3909
|
+
function co(e) {
|
|
3910
|
+
let t = (e.stderr || e.stdout).trim(), n = ao(t);
|
|
3894
3911
|
if (!n) {
|
|
3895
3912
|
t && s.log.warn(R.muted(t));
|
|
3896
3913
|
return;
|
|
3897
3914
|
}
|
|
3898
3915
|
if (n === "container") {
|
|
3899
|
-
let e =
|
|
3916
|
+
let e = oo(t);
|
|
3900
3917
|
s.log.warn(R.muted(`${e ? `Container ${R.command(e)}` : "One of this project's containers"} is already running, most likely from another Hype Stack project. The template uses fixed container names, so two projects can't run their services at the same time.`));
|
|
3901
3918
|
} else {
|
|
3902
|
-
let e =
|
|
3919
|
+
let e = so(t);
|
|
3903
3920
|
s.log.warn(R.muted(`${e ? `Host port ${R.command(e)}` : "A host port this project needs"} is already taken, most likely by another Hype Stack project. The template uses fixed ports, so two projects can't run their services at the same time.`));
|
|
3904
3921
|
}
|
|
3905
3922
|
B([
|
|
@@ -3908,9 +3925,9 @@ function so(e) {
|
|
|
3908
3925
|
R.muted("then re-run this command and start Docker again")
|
|
3909
3926
|
].join("\n"), "Free up Docker, then retry"), t && s.log.warn(R.muted(t));
|
|
3910
3927
|
}
|
|
3911
|
-
async function
|
|
3928
|
+
async function lo(e, t = 15, n = 2e3) {
|
|
3912
3929
|
for (let r = 0; r < t; r++) {
|
|
3913
|
-
if ((await
|
|
3930
|
+
if ((await J("docker", [
|
|
3914
3931
|
"compose",
|
|
3915
3932
|
"exec",
|
|
3916
3933
|
"-T",
|
|
@@ -3923,9 +3940,9 @@ async function co(e, t = 15, n = 2e3) {
|
|
|
3923
3940
|
}
|
|
3924
3941
|
return !1;
|
|
3925
3942
|
}
|
|
3926
|
-
var
|
|
3927
|
-
async function
|
|
3928
|
-
let t = await
|
|
3943
|
+
var uo = "Database schema is up to date";
|
|
3944
|
+
async function fo(e) {
|
|
3945
|
+
let t = await J("pnpm", [
|
|
3929
3946
|
"--filter",
|
|
3930
3947
|
"@internal/backend",
|
|
3931
3948
|
"exec",
|
|
@@ -3933,25 +3950,25 @@ async function uo(e) {
|
|
|
3933
3950
|
"migrate",
|
|
3934
3951
|
"status"
|
|
3935
3952
|
], { cwd: e });
|
|
3936
|
-
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(
|
|
3953
|
+
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(uo) : !1;
|
|
3937
3954
|
}
|
|
3938
|
-
async function
|
|
3955
|
+
async function po(e) {
|
|
3939
3956
|
let t = s.spinner();
|
|
3940
3957
|
t.start("Running database migrations...");
|
|
3941
|
-
let n = await
|
|
3958
|
+
let n = await J("pnpm", [
|
|
3942
3959
|
"--filter",
|
|
3943
3960
|
"@internal/backend",
|
|
3944
3961
|
"migration:latest"
|
|
3945
3962
|
], { cwd: e });
|
|
3946
|
-
return n.exitCode === 0 ? (t.stop(R.success("Database migrations applied")), !0) : (t.error("Migrations failed"),
|
|
3963
|
+
return n.exitCode === 0 ? (t.stop(R.success("Database migrations applied")), !0) : (t.error("Migrations failed"), io(n), s.log.warn(R.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations.")), !1);
|
|
3947
3964
|
}
|
|
3948
|
-
async function
|
|
3949
|
-
if (!await
|
|
3965
|
+
async function mo(e, t, n = {}) {
|
|
3966
|
+
if (!await ro(e, t, await to())) return !1;
|
|
3950
3967
|
let r = s.spinner();
|
|
3951
|
-
return r.start("Waiting for Postgres to be ready..."), await
|
|
3968
|
+
return r.start("Waiting for Postgres to be ready..."), await lo(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);
|
|
3952
3969
|
}
|
|
3953
|
-
async function
|
|
3954
|
-
if (!await
|
|
3970
|
+
async function ho(e, t, n = {}) {
|
|
3971
|
+
if (!await mo(e, t, n)) return;
|
|
3955
3972
|
let r = t ? !0 : await s.confirm({
|
|
3956
3973
|
message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
|
|
3957
3974
|
initialValue: !0
|
|
@@ -3960,21 +3977,21 @@ async function mo(e, t, n = {}) {
|
|
|
3960
3977
|
s.log.info(R.muted("Skipping database migrations."));
|
|
3961
3978
|
return;
|
|
3962
3979
|
}
|
|
3963
|
-
await
|
|
3980
|
+
await po(e);
|
|
3964
3981
|
}
|
|
3965
|
-
async function
|
|
3966
|
-
if (!await
|
|
3982
|
+
async function go(e, t, n = {}) {
|
|
3983
|
+
if (!await no(e)) {
|
|
3967
3984
|
s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3968
3985
|
return;
|
|
3969
3986
|
}
|
|
3970
|
-
await
|
|
3987
|
+
await ho(e, t, n);
|
|
3971
3988
|
}
|
|
3972
|
-
async function
|
|
3973
|
-
return await
|
|
3989
|
+
async function _o(e, t, n = {}) {
|
|
3990
|
+
return await no(e) ? mo(e, t, n) : (s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker - configure it first.`), !1);
|
|
3974
3991
|
}
|
|
3975
3992
|
//#endregion
|
|
3976
3993
|
//#region src/core/resolve.ts
|
|
3977
|
-
function
|
|
3994
|
+
function vo(e) {
|
|
3978
3995
|
let t = /* @__PURE__ */ new Map();
|
|
3979
3996
|
for (let n of e) t.set(n.name, {
|
|
3980
3997
|
name: n.name,
|
|
@@ -3982,7 +3999,7 @@ function _o(e) {
|
|
|
3982
3999
|
});
|
|
3983
4000
|
return t;
|
|
3984
4001
|
}
|
|
3985
|
-
function
|
|
4002
|
+
function yo(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3986
4003
|
let r = /* @__PURE__ */ new Set();
|
|
3987
4004
|
function i(e) {
|
|
3988
4005
|
if (n.has(e)) return [];
|
|
@@ -3996,10 +4013,10 @@ function vo(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3996
4013
|
}
|
|
3997
4014
|
return i(e);
|
|
3998
4015
|
}
|
|
3999
|
-
function
|
|
4016
|
+
function bo(e, t, n = []) {
|
|
4000
4017
|
let r = new Set(n), i = new Set(n), a = [];
|
|
4001
4018
|
for (let n of e) {
|
|
4002
|
-
let e =
|
|
4019
|
+
let e = yo(n, t, new Set(i));
|
|
4003
4020
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
4004
4021
|
}
|
|
4005
4022
|
return {
|
|
@@ -4007,7 +4024,7 @@ function yo(e, t, n = []) {
|
|
|
4007
4024
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
4008
4025
|
};
|
|
4009
4026
|
}
|
|
4010
|
-
function
|
|
4027
|
+
function xo(e) {
|
|
4011
4028
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
4012
4029
|
for (let e of t) {
|
|
4013
4030
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -4020,7 +4037,7 @@ function bo(e) {
|
|
|
4020
4037
|
}
|
|
4021
4038
|
//#endregion
|
|
4022
4039
|
//#region src/core/variants.ts
|
|
4023
|
-
function
|
|
4040
|
+
function So(e, t = {}) {
|
|
4024
4041
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
4025
4042
|
for (let i of e) {
|
|
4026
4043
|
let e = t[i.family] ?? i.default;
|
|
@@ -4032,18 +4049,18 @@ function xo(e, t = {}) {
|
|
|
4032
4049
|
familyOf: r
|
|
4033
4050
|
};
|
|
4034
4051
|
}
|
|
4035
|
-
function
|
|
4052
|
+
function Co(e, t, n) {
|
|
4036
4053
|
let r = e.map((e) => n.chosen.get(e.family) ?? e.default), i = new Set(e.map((e) => e.family)), a = t.filter((e) => {
|
|
4037
4054
|
let t = n.familyOf.get(e);
|
|
4038
4055
|
return !(t && i.has(t));
|
|
4039
4056
|
});
|
|
4040
4057
|
return [...r, ...a];
|
|
4041
4058
|
}
|
|
4042
|
-
function
|
|
4059
|
+
function wo(e, t) {
|
|
4043
4060
|
let n = t.familyOf.get(e);
|
|
4044
4061
|
return n ? t.chosen.get(n) ?? e : e;
|
|
4045
4062
|
}
|
|
4046
|
-
function
|
|
4063
|
+
function To(e, t) {
|
|
4047
4064
|
let n = /* @__PURE__ */ new Map();
|
|
4048
4065
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
4049
4066
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -4059,65 +4076,65 @@ function wo(e, t) {
|
|
|
4059
4076
|
familyOf: n
|
|
4060
4077
|
};
|
|
4061
4078
|
}
|
|
4062
|
-
function
|
|
4079
|
+
function Eo(e, t) {
|
|
4063
4080
|
return e.map((e) => ({
|
|
4064
4081
|
...e,
|
|
4065
|
-
dependencies: e.dependencies.map((e) =>
|
|
4082
|
+
dependencies: e.dependencies.map((e) => wo(e, t))
|
|
4066
4083
|
}));
|
|
4067
4084
|
}
|
|
4068
4085
|
//#endregion
|
|
4069
4086
|
//#region src/ui/banner.ts
|
|
4070
|
-
var
|
|
4087
|
+
var Do = [
|
|
4071
4088
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
4072
4089
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
4073
4090
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
4074
4091
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
4075
4092
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
4076
4093
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
4077
|
-
],
|
|
4094
|
+
], Oo = [
|
|
4078
4095
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
4079
4096
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
4080
4097
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
4081
4098
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
4082
4099
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
4083
4100
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
4084
|
-
],
|
|
4101
|
+
], ko = [
|
|
4085
4102
|
253,
|
|
4086
4103
|
176,
|
|
4087
4104
|
21
|
|
4088
|
-
],
|
|
4105
|
+
], Ao = [
|
|
4089
4106
|
245,
|
|
4090
4107
|
76,
|
|
4091
4108
|
2
|
|
4092
|
-
],
|
|
4109
|
+
], jo = 5, Mo = [
|
|
4093
4110
|
17,
|
|
4094
4111
|
103,
|
|
4095
4112
|
248
|
|
4096
|
-
],
|
|
4113
|
+
], No = [
|
|
4097
4114
|
42,
|
|
4098
4115
|
160,
|
|
4099
4116
|
250
|
|
4100
|
-
],
|
|
4101
|
-
function
|
|
4117
|
+
], Po = .2;
|
|
4118
|
+
function Fo() {
|
|
4102
4119
|
console.log();
|
|
4103
|
-
for (let e of xe(Eo, {
|
|
4104
|
-
start: Oo,
|
|
4105
|
-
end: ko,
|
|
4106
|
-
angle: Ao
|
|
4107
|
-
})) console.log(b.bold(e));
|
|
4108
4120
|
for (let e of xe(Do, {
|
|
4109
|
-
start:
|
|
4110
|
-
end:
|
|
4111
|
-
angle:
|
|
4121
|
+
start: ko,
|
|
4122
|
+
end: Ao,
|
|
4123
|
+
angle: jo
|
|
4124
|
+
})) console.log(b.bold(e));
|
|
4125
|
+
for (let e of xe(Oo, {
|
|
4126
|
+
start: Mo,
|
|
4127
|
+
end: No,
|
|
4128
|
+
angle: Po
|
|
4112
4129
|
})) console.log(b.bold(e));
|
|
4113
4130
|
console.log(), console.log(` ${z.spark} ${b.dim("v" + j)} ${b.dim("·")} ${ye("Ship web + desktop apps from one codebase")}`), console.log();
|
|
4114
4131
|
}
|
|
4115
|
-
function
|
|
4132
|
+
function Io() {
|
|
4116
4133
|
console.log(), console.log(` ${z.bolt} ${ge.orange("Hype")}${ge.skyBlue("Stack")} ${b.dim("v" + j)}`), console.log();
|
|
4117
4134
|
}
|
|
4118
4135
|
//#endregion
|
|
4119
4136
|
//#region src/ui/pack-multiselect.ts
|
|
4120
|
-
var
|
|
4137
|
+
var Lo = class extends O {
|
|
4121
4138
|
options;
|
|
4122
4139
|
cursor = 0;
|
|
4123
4140
|
selected;
|
|
@@ -4221,56 +4238,56 @@ var Io = class extends O {
|
|
|
4221
4238
|
}
|
|
4222
4239
|
}
|
|
4223
4240
|
};
|
|
4224
|
-
function
|
|
4225
|
-
return new
|
|
4241
|
+
function Ro(e) {
|
|
4242
|
+
return new Lo(e).prompt();
|
|
4226
4243
|
}
|
|
4227
4244
|
//#endregion
|
|
4228
4245
|
//#region src/utils/validate.ts
|
|
4229
|
-
function
|
|
4246
|
+
function zo(e) {
|
|
4230
4247
|
if (!e.trim()) return "Project name cannot be empty";
|
|
4231
4248
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
4232
4249
|
let t = Sr(e);
|
|
4233
|
-
if (!
|
|
4250
|
+
if (!re.test(t)) return "Project name must contain at least one letter or number";
|
|
4234
4251
|
}
|
|
4235
4252
|
//#endregion
|
|
4236
4253
|
//#region src/core/apply-mode.ts
|
|
4237
|
-
var
|
|
4238
|
-
function
|
|
4239
|
-
return e.replace(
|
|
4254
|
+
var Bo = "src/hooks/use-theme.ts", Vo = /(\bexport\s+const\s+defaultTheme\s*=\s*)(["'])(?:light|dark)\2/;
|
|
4255
|
+
function Ho(e, t) {
|
|
4256
|
+
return e.replace(Vo, (e, n, r) => `${n}${r}${t}${r}`);
|
|
4240
4257
|
}
|
|
4241
|
-
async function
|
|
4242
|
-
let n = T.resolve(e,
|
|
4258
|
+
async function Uo(e, t) {
|
|
4259
|
+
let n = T.resolve(e, Bo), r;
|
|
4243
4260
|
try {
|
|
4244
4261
|
r = await y.readFile(n, "utf-8");
|
|
4245
4262
|
} catch {
|
|
4246
4263
|
return !1;
|
|
4247
4264
|
}
|
|
4248
|
-
let i =
|
|
4265
|
+
let i = Ho(r, t);
|
|
4249
4266
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
4250
4267
|
}
|
|
4251
4268
|
//#endregion
|
|
4252
4269
|
//#region src/core/apply-radius.ts
|
|
4253
|
-
var
|
|
4254
|
-
function
|
|
4270
|
+
var Wo = /(^[ \t]*--radius(?![\w-])[ \t]*:[ \t]*)([^;\n]*);/gm;
|
|
4271
|
+
function Go(e) {
|
|
4255
4272
|
return /^[0-9]*\.?[0-9]+(rem|em|px)$/.test(e.trim());
|
|
4256
4273
|
}
|
|
4257
|
-
function
|
|
4258
|
-
return e.replace(
|
|
4274
|
+
function Ko(e, t) {
|
|
4275
|
+
return e.replace(Wo, (e, n) => `${n}${t};`);
|
|
4259
4276
|
}
|
|
4260
|
-
var
|
|
4261
|
-
async function
|
|
4262
|
-
let n = T.resolve(e,
|
|
4277
|
+
var qo = "assets/styles.css";
|
|
4278
|
+
async function Jo(e, t) {
|
|
4279
|
+
let n = T.resolve(e, qo), r;
|
|
4263
4280
|
try {
|
|
4264
4281
|
r = await y.readFile(n, "utf-8");
|
|
4265
4282
|
} catch {
|
|
4266
4283
|
return !1;
|
|
4267
4284
|
}
|
|
4268
|
-
let i =
|
|
4285
|
+
let i = Ko(r, t);
|
|
4269
4286
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
4270
4287
|
}
|
|
4271
4288
|
//#endregion
|
|
4272
4289
|
//#region src/core/apply-theme.ts
|
|
4273
|
-
function
|
|
4290
|
+
function Yo(e, t) {
|
|
4274
4291
|
let n = 0;
|
|
4275
4292
|
for (; n < e.length;) {
|
|
4276
4293
|
let r = e.indexOf(t, n);
|
|
@@ -4293,46 +4310,46 @@ function Jo(e, t) {
|
|
|
4293
4310
|
}
|
|
4294
4311
|
return null;
|
|
4295
4312
|
}
|
|
4296
|
-
function
|
|
4313
|
+
function Xo(e, t) {
|
|
4297
4314
|
let n = e;
|
|
4298
4315
|
for (let [e, r] of Object.entries(t)) {
|
|
4299
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
4316
|
+
let t = RegExp(`(^[ \\t]*--${Zo(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
4300
4317
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
4301
4318
|
}
|
|
4302
4319
|
return n;
|
|
4303
4320
|
}
|
|
4304
|
-
function
|
|
4321
|
+
function Zo(e) {
|
|
4305
4322
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4306
4323
|
}
|
|
4307
|
-
function
|
|
4308
|
-
let n =
|
|
4324
|
+
function Qo(e, t) {
|
|
4325
|
+
let n = Yo(e, ":root"), r = Yo(e, ".dark"), i = e;
|
|
4309
4326
|
if (n) {
|
|
4310
4327
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
4311
|
-
i = e +
|
|
4328
|
+
i = e + Xo(r, t.light) + a;
|
|
4312
4329
|
}
|
|
4313
4330
|
if (r) {
|
|
4314
|
-
let e =
|
|
4331
|
+
let e = Yo(i, ".dark");
|
|
4315
4332
|
if (e) {
|
|
4316
4333
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
4317
|
-
i = n +
|
|
4334
|
+
i = n + Xo(r, t.dark) + a;
|
|
4318
4335
|
}
|
|
4319
4336
|
}
|
|
4320
4337
|
return i;
|
|
4321
4338
|
}
|
|
4322
|
-
var
|
|
4323
|
-
async function
|
|
4324
|
-
let n = T.resolve(e,
|
|
4339
|
+
var $o = "assets/styles.css";
|
|
4340
|
+
async function es(e, t) {
|
|
4341
|
+
let n = T.resolve(e, $o), r;
|
|
4325
4342
|
try {
|
|
4326
4343
|
r = await y.readFile(n, "utf-8");
|
|
4327
4344
|
} catch {
|
|
4328
4345
|
return !1;
|
|
4329
4346
|
}
|
|
4330
|
-
let i =
|
|
4347
|
+
let i = Qo(r, t);
|
|
4331
4348
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
4332
4349
|
}
|
|
4333
4350
|
//#endregion
|
|
4334
4351
|
//#region src/core/clone.ts
|
|
4335
|
-
async function
|
|
4352
|
+
async function ts(e) {
|
|
4336
4353
|
let t = await A(ee, {
|
|
4337
4354
|
dir: e,
|
|
4338
4355
|
force: !0
|
|
@@ -4344,7 +4361,7 @@ async function es(e) {
|
|
|
4344
4361
|
}
|
|
4345
4362
|
//#endregion
|
|
4346
4363
|
//#region src/core/editor-config.ts
|
|
4347
|
-
function
|
|
4364
|
+
function ns(e) {
|
|
4348
4365
|
let t = {
|
|
4349
4366
|
globs: [],
|
|
4350
4367
|
alwaysApply: !1
|
|
@@ -4379,10 +4396,10 @@ function ts(e) {
|
|
|
4379
4396
|
content: i
|
|
4380
4397
|
};
|
|
4381
4398
|
}
|
|
4382
|
-
function
|
|
4399
|
+
function rs(e) {
|
|
4383
4400
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
4384
4401
|
}
|
|
4385
|
-
function
|
|
4402
|
+
function is(e) {
|
|
4386
4403
|
let t;
|
|
4387
4404
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
4388
4405
|
let n = [`trigger: ${t}`];
|
|
@@ -4392,30 +4409,30 @@ function rs(e) {
|
|
|
4392
4409
|
}
|
|
4393
4410
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
4394
4411
|
}
|
|
4395
|
-
function
|
|
4412
|
+
function as(e) {
|
|
4396
4413
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
4397
4414
|
}
|
|
4398
|
-
var
|
|
4415
|
+
var os = {
|
|
4399
4416
|
claude: {
|
|
4400
4417
|
rulesDir: ".claude/rules",
|
|
4401
4418
|
extension: ".md",
|
|
4402
|
-
convert:
|
|
4419
|
+
convert: rs
|
|
4403
4420
|
},
|
|
4404
4421
|
windsurf: {
|
|
4405
4422
|
rulesDir: ".windsurf/rules",
|
|
4406
4423
|
extension: ".md",
|
|
4407
|
-
convert:
|
|
4424
|
+
convert: is
|
|
4408
4425
|
},
|
|
4409
4426
|
copilot: {
|
|
4410
4427
|
rulesDir: ".github/instructions",
|
|
4411
4428
|
extension: ".instructions.md",
|
|
4412
|
-
convert:
|
|
4429
|
+
convert: as
|
|
4413
4430
|
}
|
|
4414
4431
|
};
|
|
4415
|
-
async function
|
|
4416
|
-
let t = T.join(e,
|
|
4432
|
+
async function ss(e) {
|
|
4433
|
+
let t = T.join(e, ae), n = (await y.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
4417
4434
|
return await Promise.all(n.map(async (e) => {
|
|
4418
|
-
let n = T.join(t, e.name), { frontmatter: r, content: i } =
|
|
4435
|
+
let n = T.join(t, e.name), { frontmatter: r, content: i } = ns(await y.readFile(n, "utf-8"));
|
|
4419
4436
|
return {
|
|
4420
4437
|
frontmatter: r,
|
|
4421
4438
|
content: i,
|
|
@@ -4423,31 +4440,31 @@ async function os(e) {
|
|
|
4423
4440
|
};
|
|
4424
4441
|
}));
|
|
4425
4442
|
}
|
|
4426
|
-
async function
|
|
4443
|
+
async function cs(e, t) {
|
|
4427
4444
|
if (t === "cursor") return;
|
|
4428
|
-
let n =
|
|
4445
|
+
let n = os[t], r = await ss(e), i = T.join(e, n.rulesDir);
|
|
4429
4446
|
await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
4430
4447
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
4431
4448
|
return y.writeFile(T.join(i, r), t, "utf-8");
|
|
4432
|
-
})), await mr(T.join(e,
|
|
4449
|
+
})), await mr(T.join(e, oe)), await mr(T.join(e, se));
|
|
4433
4450
|
}
|
|
4434
4451
|
//#endregion
|
|
4435
4452
|
//#region src/core/env-files.ts
|
|
4436
|
-
var
|
|
4453
|
+
var ls = [
|
|
4437
4454
|
"apps",
|
|
4438
4455
|
"packages",
|
|
4439
4456
|
"libs",
|
|
4440
4457
|
"shared"
|
|
4441
4458
|
];
|
|
4442
|
-
async function
|
|
4443
|
-
let t = await
|
|
4459
|
+
async function us(e) {
|
|
4460
|
+
let t = await ds(e);
|
|
4444
4461
|
return (await Promise.all(t.map(async (t) => {
|
|
4445
4462
|
let n = T.join(T.dirname(t), ".env");
|
|
4446
4463
|
return await Y(n) ? null : (await y.copyFile(t, n), T.relative(e, n));
|
|
4447
4464
|
}))).filter((e) => e !== null).sort();
|
|
4448
4465
|
}
|
|
4449
|
-
async function
|
|
4450
|
-
let t = [T.join(e, ".env.example")], n = await Promise.all(
|
|
4466
|
+
async function ds(e) {
|
|
4467
|
+
let t = [T.join(e, ".env.example")], n = await Promise.all(ls.map(async (t) => {
|
|
4451
4468
|
let n = T.join(e, t);
|
|
4452
4469
|
return (await y.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => T.join(n, e.name, ".env.example"));
|
|
4453
4470
|
}));
|
|
@@ -4455,12 +4472,12 @@ async function us(e) {
|
|
|
4455
4472
|
}
|
|
4456
4473
|
//#endregion
|
|
4457
4474
|
//#region src/core/post-clone.ts
|
|
4458
|
-
var Q = "@hype-stack/",
|
|
4459
|
-
async function
|
|
4475
|
+
var Q = "@hype-stack/", fs = "hype-stack", ps = "@hype-stack/cli";
|
|
4476
|
+
async function ms(e) {
|
|
4460
4477
|
await mr(T.join(e, ".git"));
|
|
4461
4478
|
}
|
|
4462
|
-
async function
|
|
4463
|
-
await
|
|
4479
|
+
async function hs(e) {
|
|
4480
|
+
await J("git", ["init"], { cwd: e }), await J("git", ["add", "."], { cwd: e }), await J("git", [
|
|
4464
4481
|
"-c",
|
|
4465
4482
|
"user.name=Hype Stack CLI",
|
|
4466
4483
|
"-c",
|
|
@@ -4470,19 +4487,19 @@ async function ms(e) {
|
|
|
4470
4487
|
"Initial commit from Hype Stack CLI"
|
|
4471
4488
|
], { cwd: e });
|
|
4472
4489
|
}
|
|
4473
|
-
async function
|
|
4474
|
-
let n = `@${t}/`, r = await
|
|
4490
|
+
async function gs(e, t) {
|
|
4491
|
+
let n = `@${t}/`, r = await ws(e);
|
|
4475
4492
|
for (let e of r) {
|
|
4476
4493
|
let t = await dr(e);
|
|
4477
4494
|
if (!t) continue;
|
|
4478
4495
|
let r = !1;
|
|
4479
|
-
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0),
|
|
4496
|
+
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0), xs(t.dependencies, n) && (r = !0), xs(t.devDependencies, n) && (r = !0), t.nx && Ss(t.nx, n) && (r = !0);
|
|
4480
4497
|
let i = await y.readFile(e, "utf-8"), a = ei(i, n);
|
|
4481
4498
|
a === i ? r && await fr(e, t) : await y.writeFile(e, a, "utf-8");
|
|
4482
4499
|
}
|
|
4483
|
-
await
|
|
4500
|
+
await ja(e, t), await ys(e, t), await Cs(e, t);
|
|
4484
4501
|
}
|
|
4485
|
-
var
|
|
4502
|
+
var _s = new Set([
|
|
4486
4503
|
".git",
|
|
4487
4504
|
"node_modules",
|
|
4488
4505
|
"dist",
|
|
@@ -4490,10 +4507,10 @@ var gs = new Set([
|
|
|
4490
4507
|
".nx",
|
|
4491
4508
|
".next",
|
|
4492
4509
|
"coverage"
|
|
4493
|
-
]),
|
|
4494
|
-
async function
|
|
4495
|
-
if (t ===
|
|
4496
|
-
let n = await
|
|
4510
|
+
]), vs = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
|
|
4511
|
+
async function ys(e, t) {
|
|
4512
|
+
if (t === fs) return;
|
|
4513
|
+
let n = await bs(e);
|
|
4497
4514
|
await Promise.all(n.map(async (e) => {
|
|
4498
4515
|
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
4499
4516
|
if (!n || !/^[ \t]*(?:name|container_name):[ \t]*hype-stack/m.test(n)) return;
|
|
@@ -4501,23 +4518,23 @@ async function vs(e, t) {
|
|
|
4501
4518
|
await y.writeFile(e, r, "utf-8");
|
|
4502
4519
|
}));
|
|
4503
4520
|
}
|
|
4504
|
-
async function
|
|
4521
|
+
async function bs(e) {
|
|
4505
4522
|
let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
4506
4523
|
return (await Promise.all(t.map(async (t) => {
|
|
4507
4524
|
let n = T.join(e, t.name);
|
|
4508
|
-
return t.isDirectory() ?
|
|
4525
|
+
return t.isDirectory() ? _s.has(t.name) ? [] : bs(n) : t.isFile() && vs.test(t.name) ? [n] : [];
|
|
4509
4526
|
}))).flat();
|
|
4510
4527
|
}
|
|
4511
|
-
function
|
|
4528
|
+
function xs(e, t) {
|
|
4512
4529
|
if (!e) return !1;
|
|
4513
4530
|
let n = !1;
|
|
4514
|
-
for (let r of Object.keys(e)) if (r !==
|
|
4531
|
+
for (let r of Object.keys(e)) if (r !== ps && r.startsWith(Q)) {
|
|
4515
4532
|
let i = r.replace(Q, t);
|
|
4516
4533
|
e[i] = e[r], delete e[r], n = !0;
|
|
4517
4534
|
}
|
|
4518
4535
|
return n;
|
|
4519
4536
|
}
|
|
4520
|
-
function
|
|
4537
|
+
function Ss(e, t) {
|
|
4521
4538
|
if (!e) return !1;
|
|
4522
4539
|
let n = !1;
|
|
4523
4540
|
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Q) ? (n = !0, e.replace(Q, t)) : e), e.targets) {
|
|
@@ -4525,13 +4542,13 @@ function xs(e, t) {
|
|
|
4525
4542
|
}
|
|
4526
4543
|
return n;
|
|
4527
4544
|
}
|
|
4528
|
-
async function
|
|
4545
|
+
async function Cs(e, t) {
|
|
4529
4546
|
let n = T.join(e, "packages/enums/src/app/index.ts"), r = await y.readFile(n, "utf-8").catch(() => null);
|
|
4530
4547
|
if (!r) return;
|
|
4531
|
-
let i = Cr(t), a = r.replaceAll(`id: "${
|
|
4548
|
+
let i = Cr(t), a = r.replaceAll(`id: "${fs}"`, `id: "${t}"`).replaceAll(`name: "${fs}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
|
|
4532
4549
|
await y.writeFile(n, a, "utf-8");
|
|
4533
4550
|
}
|
|
4534
|
-
async function
|
|
4551
|
+
async function ws(e) {
|
|
4535
4552
|
let t = [], n = T.join(e, "package.json");
|
|
4536
4553
|
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
4537
4554
|
for (let n of [
|
|
@@ -4551,7 +4568,7 @@ async function Cs(e) {
|
|
|
4551
4568
|
}
|
|
4552
4569
|
//#endregion
|
|
4553
4570
|
//#region src/core/readme.ts
|
|
4554
|
-
var
|
|
4571
|
+
var Ts = {
|
|
4555
4572
|
cursor: {
|
|
4556
4573
|
label: "Cursor",
|
|
4557
4574
|
rulesDir: ".cursor/rules"
|
|
@@ -4568,21 +4585,21 @@ var ws = {
|
|
|
4568
4585
|
label: "GitHub Copilot",
|
|
4569
4586
|
rulesDir: ".github/instructions"
|
|
4570
4587
|
}
|
|
4571
|
-
},
|
|
4588
|
+
}, Es = {
|
|
4572
4589
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
4573
4590
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
4574
|
-
},
|
|
4591
|
+
}, Ds = {
|
|
4575
4592
|
enums: "Shared enums and app config used across apps",
|
|
4576
4593
|
cli: "Project tooling and code generators"
|
|
4577
4594
|
};
|
|
4578
|
-
function
|
|
4595
|
+
function Os(e, t) {
|
|
4579
4596
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
4580
4597
|
let r = t[e];
|
|
4581
4598
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4582
4599
|
});
|
|
4583
4600
|
}
|
|
4584
|
-
function
|
|
4585
|
-
let { projectName: t, editor: n, workspace: r } = e, i = Cr(t), a =
|
|
4601
|
+
function ks(e) {
|
|
4602
|
+
let { projectName: t, editor: n, workspace: r } = e, i = Cr(t), a = Ts[n], o = !!r.apps.backend, s = Os(r.apps, Es), c = Os(r.packages, Ds), l = [];
|
|
4586
4603
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
4587
4604
|
let u = [];
|
|
4588
4605
|
u.push(`# ${i}`), u.push([
|
|
@@ -4685,19 +4702,19 @@ function Os(e) {
|
|
|
4685
4702
|
"stays useful."
|
|
4686
4703
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4687
4704
|
}
|
|
4688
|
-
async function
|
|
4705
|
+
async function As(e, t) {
|
|
4689
4706
|
let n = T.join(e, "README.md");
|
|
4690
|
-
await y.writeFile(n,
|
|
4707
|
+
await y.writeFile(n, ks(t), "utf-8");
|
|
4691
4708
|
}
|
|
4692
4709
|
//#endregion
|
|
4693
4710
|
//#region src/core/tracking.ts
|
|
4694
|
-
async function
|
|
4711
|
+
async function js(e) {
|
|
4695
4712
|
try {
|
|
4696
4713
|
let t = {
|
|
4697
|
-
"X-Device-Id":
|
|
4698
|
-
"X-Client-Info":
|
|
4699
|
-
}, n = await
|
|
4700
|
-
n?.token && (t.Authorization = `Bearer ${n.token}`), await
|
|
4714
|
+
"X-Device-Id": er(),
|
|
4715
|
+
"X-Client-Info": tr()
|
|
4716
|
+
}, n = await Xn(I()).catch(() => null);
|
|
4717
|
+
n?.token && (t.Authorization = `Bearer ${n.token}`), await q.createRequest()({
|
|
4701
4718
|
endpoint: "/cli/track",
|
|
4702
4719
|
method: "POST"
|
|
4703
4720
|
}).setPayload({ event: e }).setHeaders(t).send();
|
|
@@ -4705,7 +4722,7 @@ async function As(e) {
|
|
|
4705
4722
|
}
|
|
4706
4723
|
//#endregion
|
|
4707
4724
|
//#region src/ui/swatch.ts
|
|
4708
|
-
function
|
|
4725
|
+
function Ms(e) {
|
|
4709
4726
|
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4710
4727
|
if (!t) return null;
|
|
4711
4728
|
let n = t[1].trim().split(/\s+/);
|
|
@@ -4724,43 +4741,43 @@ function js(e) {
|
|
|
4724
4741
|
h: a
|
|
4725
4742
|
};
|
|
4726
4743
|
}
|
|
4727
|
-
function
|
|
4744
|
+
function Ns(e) {
|
|
4728
4745
|
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4729
4746
|
}
|
|
4730
|
-
function
|
|
4747
|
+
function Ps(e) {
|
|
4731
4748
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4732
4749
|
}
|
|
4733
|
-
function
|
|
4750
|
+
function Fs({ l: e, c: t, h: n }) {
|
|
4734
4751
|
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;
|
|
4735
4752
|
return [
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4753
|
+
Ns(Ps(f) * 255),
|
|
4754
|
+
Ns(Ps(p) * 255),
|
|
4755
|
+
Ns(Ps(m) * 255)
|
|
4739
4756
|
];
|
|
4740
4757
|
}
|
|
4741
|
-
var
|
|
4742
|
-
function
|
|
4758
|
+
var Is = "\x1B[49m";
|
|
4759
|
+
function Ls(e, t) {
|
|
4743
4760
|
let n = e[t];
|
|
4744
4761
|
if (!n) return b.dim(" ");
|
|
4745
|
-
let r =
|
|
4762
|
+
let r = Ms(n);
|
|
4746
4763
|
if (!r) return b.dim(" ");
|
|
4747
|
-
let [i, a, o] =
|
|
4748
|
-
return `\x1b[48;2;${i};${a};${o}m ${
|
|
4764
|
+
let [i, a, o] = Fs(r);
|
|
4765
|
+
return `\x1b[48;2;${i};${a};${o}m ${Is}`;
|
|
4749
4766
|
}
|
|
4750
|
-
var
|
|
4767
|
+
var Rs = [
|
|
4751
4768
|
"primary",
|
|
4752
4769
|
"secondary",
|
|
4753
4770
|
"accent"
|
|
4754
4771
|
];
|
|
4755
|
-
function Rs(e) {
|
|
4756
|
-
return Ls.map((t) => Is(e, t)).join("");
|
|
4757
|
-
}
|
|
4758
4772
|
function zs(e) {
|
|
4759
|
-
return
|
|
4773
|
+
return Rs.map((t) => Ls(e, t)).join("");
|
|
4774
|
+
}
|
|
4775
|
+
function Bs(e) {
|
|
4776
|
+
return `${zs(e.light)} ${b.dim("·")} ${zs(e.dark)}`;
|
|
4760
4777
|
}
|
|
4761
4778
|
//#endregion
|
|
4762
4779
|
//#region src/core/npm-deps.ts
|
|
4763
|
-
function
|
|
4780
|
+
function Vs(e, t) {
|
|
4764
4781
|
let n = [], r = [];
|
|
4765
4782
|
if (!e) return {
|
|
4766
4783
|
errors: n,
|
|
@@ -4791,7 +4808,7 @@ function Bs(e, t) {
|
|
|
4791
4808
|
operations: r
|
|
4792
4809
|
};
|
|
4793
4810
|
}
|
|
4794
|
-
function
|
|
4811
|
+
function Hs(e) {
|
|
4795
4812
|
let t = {};
|
|
4796
4813
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4797
4814
|
...t[e],
|
|
@@ -4799,7 +4816,7 @@ function Vs(e) {
|
|
|
4799
4816
|
};
|
|
4800
4817
|
return t;
|
|
4801
4818
|
}
|
|
4802
|
-
async function
|
|
4819
|
+
async function Us(e, t, n = J) {
|
|
4803
4820
|
let r = [];
|
|
4804
4821
|
for (let i of e) {
|
|
4805
4822
|
let e = T.join(t, i.relativeDir);
|
|
@@ -4835,22 +4852,22 @@ async function Hs(e, t, n = q) {
|
|
|
4835
4852
|
function $(e) {
|
|
4836
4853
|
return e instanceof Error ? e.message : String(e);
|
|
4837
4854
|
}
|
|
4838
|
-
async function
|
|
4855
|
+
async function Ws(e, t, n) {
|
|
4839
4856
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4840
4857
|
return r.length === 0 ? {} : Yr(r, n).catch(() => ({}));
|
|
4841
4858
|
}
|
|
4842
|
-
function
|
|
4859
|
+
function Gs(e, t) {
|
|
4843
4860
|
return e === "free" ? R.success("free") : e === "owned" ? R.accent("owned") : `${R.highlight(`$${t}`)} ${R.muted("locked")}`;
|
|
4844
4861
|
}
|
|
4845
|
-
async function
|
|
4862
|
+
async function Ks(e, t, n) {
|
|
4846
4863
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4847
|
-
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
|
|
4864
|
+
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 sr(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4848
4865
|
name: e.name,
|
|
4849
4866
|
displayName: e.displayName,
|
|
4850
4867
|
price: e.price
|
|
4851
4868
|
})));
|
|
4852
4869
|
}
|
|
4853
|
-
function
|
|
4870
|
+
function qs(e, t) {
|
|
4854
4871
|
B([
|
|
4855
4872
|
"These packs will be installed, in order:",
|
|
4856
4873
|
"",
|
|
@@ -4860,7 +4877,7 @@ function Ks(e, t) {
|
|
|
4860
4877
|
})
|
|
4861
4878
|
].join("\n"), "Install Plan");
|
|
4862
4879
|
}
|
|
4863
|
-
async function
|
|
4880
|
+
async function Js(e, t) {
|
|
4864
4881
|
let n = [];
|
|
4865
4882
|
for (let r of e) {
|
|
4866
4883
|
let e = await Ur(r), i = await Wr(r, t);
|
|
@@ -4872,18 +4889,18 @@ async function qs(e, t) {
|
|
|
4872
4889
|
}
|
|
4873
4890
|
return n;
|
|
4874
4891
|
}
|
|
4875
|
-
async function
|
|
4876
|
-
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a =
|
|
4892
|
+
async function Ys(e) {
|
|
4893
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = Vs(Hs(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4877
4894
|
if (a.errors.length > 0) {
|
|
4878
4895
|
for (let e of a.errors) s.log.error(e);
|
|
4879
4896
|
return;
|
|
4880
4897
|
}
|
|
4881
4898
|
if (a.operations.length === 0) return;
|
|
4882
4899
|
i.start("Installing npm dependencies...");
|
|
4883
|
-
let o = await
|
|
4900
|
+
let o = await Us(a.operations, r);
|
|
4884
4901
|
if (i.stop(o.ok ? "npm dependencies installed" : "npm dependency installation failed"), !o.ok) for (let e of o.errors) s.log.error(e);
|
|
4885
4902
|
}
|
|
4886
|
-
function
|
|
4903
|
+
function Xs() {
|
|
4887
4904
|
we([{
|
|
4888
4905
|
command: "npx @hype-stack/cli onboard",
|
|
4889
4906
|
hint: "(set up env vars + run migrations)"
|
|
@@ -4892,7 +4909,7 @@ function Ys() {
|
|
|
4892
4909
|
hint: "(start frontend + backend)"
|
|
4893
4910
|
}]);
|
|
4894
4911
|
}
|
|
4895
|
-
function
|
|
4912
|
+
function Zs(e) {
|
|
4896
4913
|
if (e.length === 0) return;
|
|
4897
4914
|
let t = e.map((e) => {
|
|
4898
4915
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
@@ -4900,10 +4917,10 @@ function Xs(e) {
|
|
|
4900
4917
|
});
|
|
4901
4918
|
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4902
4919
|
}
|
|
4903
|
-
async function
|
|
4920
|
+
async function Qs(e) {
|
|
4904
4921
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
|
|
4905
4922
|
if (i) return c;
|
|
4906
|
-
let l = await
|
|
4923
|
+
let l = await Va({
|
|
4907
4924
|
packs: t,
|
|
4908
4925
|
config: n,
|
|
4909
4926
|
projectRoot: r,
|
|
@@ -4930,18 +4947,18 @@ async function Zs(e) {
|
|
|
4930
4947
|
}
|
|
4931
4948
|
//#endregion
|
|
4932
4949
|
//#region src/commands/create.ts
|
|
4933
|
-
async function
|
|
4934
|
-
e.skipBanner ||
|
|
4950
|
+
async function $s(e) {
|
|
4951
|
+
e.skipBanner || Fo(), s.intro(R.brandBold("Create a new Hype Stack project"));
|
|
4935
4952
|
let o = e.yes === !0, c, l;
|
|
4936
4953
|
if (o && e.name) {
|
|
4937
|
-
let t =
|
|
4954
|
+
let t = zo(e.name);
|
|
4938
4955
|
t && (s.log.error(t), V()), l = e.name, c = Sr(e.name);
|
|
4939
4956
|
} else {
|
|
4940
4957
|
let t = await s.text({
|
|
4941
4958
|
message: "What is your project named?",
|
|
4942
4959
|
placeholder: "my-app",
|
|
4943
4960
|
initialValue: e.name ?? "",
|
|
4944
|
-
validate: (e) =>
|
|
4961
|
+
validate: (e) => zo(e ?? "")
|
|
4945
4962
|
});
|
|
4946
4963
|
s.isCancel(t) && V(), l = t, c = Sr(l);
|
|
4947
4964
|
}
|
|
@@ -4964,13 +4981,13 @@ async function Qs(e) {
|
|
|
4964
4981
|
}
|
|
4965
4982
|
let d = T.resolve(u);
|
|
4966
4983
|
o || s.note(R.path(d), "Project will be created at");
|
|
4967
|
-
let f = e.editor &&
|
|
4984
|
+
let f = e.editor && ie.includes(e.editor) ? e.editor : null, p;
|
|
4968
4985
|
if (f) p = f;
|
|
4969
4986
|
else if (o) p = "cursor";
|
|
4970
4987
|
else {
|
|
4971
4988
|
let e = await s.select({
|
|
4972
4989
|
message: "Which code editor do you use?",
|
|
4973
|
-
options:
|
|
4990
|
+
options: F.map((e) => ({
|
|
4974
4991
|
value: e.value,
|
|
4975
4992
|
label: e.label,
|
|
4976
4993
|
hint: "hint" in e ? e.hint : void 0
|
|
@@ -4987,7 +5004,7 @@ async function Qs(e) {
|
|
|
4987
5004
|
message: "Pick a color theme",
|
|
4988
5005
|
options: r.map((e) => ({
|
|
4989
5006
|
value: e.name,
|
|
4990
|
-
label: `${
|
|
5007
|
+
label: `${Bs(e)} ${e.label}`
|
|
4991
5008
|
})),
|
|
4992
5009
|
initialValue: h
|
|
4993
5010
|
});
|
|
@@ -5001,17 +5018,17 @@ async function Qs(e) {
|
|
|
5001
5018
|
message: "Pick a color theme for the admin app",
|
|
5002
5019
|
options: r.map((e) => ({
|
|
5003
5020
|
value: e.name,
|
|
5004
|
-
label: `${
|
|
5021
|
+
label: `${Bs(e)} ${e.label}`
|
|
5005
5022
|
})),
|
|
5006
5023
|
initialValue: g
|
|
5007
5024
|
});
|
|
5008
5025
|
s.isCancel(e) && V(), v = e;
|
|
5009
5026
|
}
|
|
5010
5027
|
if (!o) {
|
|
5011
|
-
let e =
|
|
5028
|
+
let e = F.find((e) => e.value === p)?.label ?? p, t = n.find((e) => e.value === g)?.label ?? g, r = n.find((e) => e.value === v)?.label ?? v, i = await s.confirm({ message: `Create ${R.highlight(c)} in ${R.path(d)} with ${R.highlight(e)} config, the ${R.highlight(t)} frontend theme, and the ${R.highlight(r)} admin theme?` });
|
|
5012
5029
|
(s.isCancel(i) || !i) && V();
|
|
5013
5030
|
}
|
|
5014
|
-
if (await
|
|
5031
|
+
if (await lr(d) && !await ur(d)) {
|
|
5015
5032
|
let e = await s.confirm({
|
|
5016
5033
|
message: `Directory ${R.path(d)} is not empty. Continue anyway?`,
|
|
5017
5034
|
initialValue: !1
|
|
@@ -5019,24 +5036,24 @@ async function Qs(e) {
|
|
|
5019
5036
|
(s.isCancel(e) || !e) && V();
|
|
5020
5037
|
}
|
|
5021
5038
|
let y = s.spinner();
|
|
5022
|
-
y.start("Cloning Hype Stack template..."), await
|
|
5039
|
+
y.start("Cloning Hype Stack template..."), await ts(d), y.stop(R.success("Template cloned"));
|
|
5023
5040
|
let b = s.spinner();
|
|
5024
|
-
b.start("Setting up project..."), await
|
|
5041
|
+
b.start("Setting up project..."), await ms(d), await gs(d, c), await cs(d, p);
|
|
5025
5042
|
let x = await zr(d), S = Vr(c, x);
|
|
5026
|
-
await Rr(d, S), await
|
|
5043
|
+
await Rr(d, S), await As(d, {
|
|
5027
5044
|
projectName: c,
|
|
5028
5045
|
editor: p,
|
|
5029
5046
|
workspace: x
|
|
5030
5047
|
});
|
|
5031
5048
|
let C = T.resolve(d, S.paths?.frontend.root ?? "apps/frontend");
|
|
5032
|
-
a(g) && (await
|
|
5049
|
+
a(g) && (await es(C, i(g)) || s.log.warn(R.muted(`Could not find ${R.path("assets/styles.css")} to apply the ${g} theme`))), S.apps.admin !== void 0 && a(v) && (await es(T.resolve(d, S.paths?.admin?.root ?? "apps/admin"), i(v)) || s.log.warn(R.muted(`Could not find ${R.path("assets/styles.css")} to apply the ${v} admin theme`))), e.radius !== void 0 && Go(e.radius) && (await Jo(C, e.radius) || s.log.warn(R.muted(`Could not find ${R.path("assets/styles.css")} to set the corner radius`))), await Uo(C, 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`)), b.stop(R.success("Project configured"));
|
|
5033
5050
|
let w = s.spinner();
|
|
5034
|
-
w.start("Installing dependencies..."), (await
|
|
5051
|
+
w.start("Installing dependencies..."), (await J("pnpm", ["install"], { cwd: d })).exitCode === 0 ? w.stop(R.success("Dependencies installed")) : (w.stop(R.warning("Dependencies installed with warnings")), s.log.warn(R.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
5035
5052
|
let E = s.spinner();
|
|
5036
|
-
E.start("Initializing git repository..."), await
|
|
5053
|
+
E.start("Initializing git repository..."), await hs(d), E.stop(R.success("Git repository initialized with clean history"));
|
|
5037
5054
|
let D = s.spinner();
|
|
5038
5055
|
D.start("Creating .env files from examples...");
|
|
5039
|
-
let O = await
|
|
5056
|
+
let O = await us(d);
|
|
5040
5057
|
if (O.length > 0) {
|
|
5041
5058
|
let e = O.length;
|
|
5042
5059
|
D.stop(R.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
@@ -5051,15 +5068,15 @@ async function Qs(e) {
|
|
|
5051
5068
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
5052
5069
|
initialValue: !0
|
|
5053
5070
|
}));
|
|
5054
|
-
s.isCancel(e) && V(), e ? await
|
|
5071
|
+
s.isCancel(e) && V(), e ? await go(d, o) : s.log.info(R.muted("Docker and migrations can run later via `npx @hype-stack/cli onboard`.")), Xs();
|
|
5055
5072
|
}
|
|
5056
|
-
return await
|
|
5073
|
+
return await js("project_create"), s.outro(R.muted("Happy building!")), d;
|
|
5057
5074
|
}
|
|
5058
5075
|
//#endregion
|
|
5059
5076
|
//#region src/commands/init.ts
|
|
5060
|
-
async function
|
|
5077
|
+
async function ec(e) {
|
|
5061
5078
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
5062
|
-
if (n || (
|
|
5079
|
+
if (n || (Io(), s.intro(R.brandBold("Initialize Hype Stack configuration"))), !await Hr(t)) {
|
|
5063
5080
|
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.`));
|
|
5064
5081
|
return;
|
|
5065
5082
|
}
|
|
@@ -5096,21 +5113,21 @@ async function $s(e) {
|
|
|
5096
5113
|
message: "Project name for stack.json?",
|
|
5097
5114
|
placeholder: i,
|
|
5098
5115
|
initialValue: i,
|
|
5099
|
-
validate: (e) =>
|
|
5116
|
+
validate: (e) => zo(e ?? "")
|
|
5100
5117
|
});
|
|
5101
5118
|
s.isCancel(e) && V(), a = Sr(e);
|
|
5102
5119
|
}
|
|
5103
5120
|
await Rr(t, Vr(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.")));
|
|
5104
5121
|
}
|
|
5105
|
-
async function
|
|
5122
|
+
async function tc(e, t = {}, n) {
|
|
5106
5123
|
if (await Lr(e)) return {
|
|
5107
5124
|
projectRoot: e,
|
|
5108
5125
|
scaffolded: !1
|
|
5109
5126
|
};
|
|
5110
|
-
let r = t.runInit ?? ((e) =>
|
|
5127
|
+
let r = t.runInit ?? ((e) => ec({
|
|
5111
5128
|
cwd: e,
|
|
5112
5129
|
silent: !0
|
|
5113
|
-
})), i = t.runCreate ?? ((e, t) =>
|
|
5130
|
+
})), i = t.runCreate ?? ((e, t) => $s({
|
|
5114
5131
|
parentDirectory: e,
|
|
5115
5132
|
deferSetup: !0,
|
|
5116
5133
|
skipBanner: !0,
|
|
@@ -5151,10 +5168,10 @@ async function ec(e, t = {}, n) {
|
|
|
5151
5168
|
}
|
|
5152
5169
|
//#endregion
|
|
5153
5170
|
//#region src/commands/compose.ts
|
|
5154
|
-
async function
|
|
5171
|
+
async function nc(e = {}) {
|
|
5155
5172
|
let t = e.cwd ?? process.cwd();
|
|
5156
|
-
|
|
5157
|
-
let n = await
|
|
5173
|
+
Fo();
|
|
5174
|
+
let n = await tc(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
5158
5175
|
try {
|
|
5159
5176
|
a = await Ir(r ?? t);
|
|
5160
5177
|
} catch (e) {
|
|
@@ -5172,13 +5189,13 @@ async function tc(e = {}) {
|
|
|
5172
5189
|
c.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
5173
5190
|
}
|
|
5174
5191
|
c.stop("Packs loaded");
|
|
5175
|
-
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
|
|
5192
|
+
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 Xn(I()))?.token ?? null, h = await Ws(l, d, {
|
|
5176
5193
|
token: m,
|
|
5177
5194
|
key: p
|
|
5178
5195
|
}), g = (e) => {
|
|
5179
5196
|
let t = f.get(e);
|
|
5180
5197
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
5181
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await
|
|
5198
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await rc({
|
|
5182
5199
|
packs: l,
|
|
5183
5200
|
installedSet: d,
|
|
5184
5201
|
stateOf: g,
|
|
@@ -5189,9 +5206,9 @@ async function tc(e = {}) {
|
|
|
5189
5206
|
s.outro(R.muted("No packs selected. Nothing to do."));
|
|
5190
5207
|
return;
|
|
5191
5208
|
}
|
|
5192
|
-
let b =
|
|
5209
|
+
let b = sc(v), x = cc(v), S = To(l, b), C = vo(Eo(l, S)), w;
|
|
5193
5210
|
try {
|
|
5194
|
-
w =
|
|
5211
|
+
w = bo(b, C, u);
|
|
5195
5212
|
} catch (e) {
|
|
5196
5213
|
s.cancel($(e)), process.exit(1);
|
|
5197
5214
|
}
|
|
@@ -5199,36 +5216,36 @@ async function tc(e = {}) {
|
|
|
5199
5216
|
B(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(R.muted("Your selection is already part of the project."));
|
|
5200
5217
|
return;
|
|
5201
5218
|
}
|
|
5202
|
-
let T =
|
|
5219
|
+
let T = xo({
|
|
5203
5220
|
order: w.order,
|
|
5204
5221
|
graph: C,
|
|
5205
5222
|
isLocked: _,
|
|
5206
5223
|
installed: u
|
|
5207
5224
|
});
|
|
5208
5225
|
if (T.blocked.length > 0 && !m && !p) {
|
|
5209
|
-
let e = await
|
|
5210
|
-
e && (m = e, h = await
|
|
5226
|
+
let e = await or();
|
|
5227
|
+
e && (m = e, h = await Ws(l, d, {
|
|
5211
5228
|
token: m,
|
|
5212
5229
|
key: p
|
|
5213
|
-
}), T =
|
|
5230
|
+
}), T = xo({
|
|
5214
5231
|
order: w.order,
|
|
5215
5232
|
graph: C,
|
|
5216
5233
|
isLocked: _,
|
|
5217
5234
|
installed: u
|
|
5218
5235
|
}));
|
|
5219
5236
|
}
|
|
5220
|
-
if (T.blocked.length > 0 && await
|
|
5237
|
+
if (T.blocked.length > 0 && await Ks(T.blocked, _, f), T.installable.length === 0) {
|
|
5221
5238
|
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
5222
5239
|
return;
|
|
5223
5240
|
}
|
|
5224
|
-
if (
|
|
5241
|
+
if (qs(T.installable, f), !e.yes) {
|
|
5225
5242
|
let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
5226
5243
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5227
5244
|
}
|
|
5228
5245
|
c.start("Downloading packs...");
|
|
5229
5246
|
let E;
|
|
5230
5247
|
try {
|
|
5231
|
-
E = await
|
|
5248
|
+
E = await Js(T.installable, {
|
|
5232
5249
|
token: m,
|
|
5233
5250
|
key: p
|
|
5234
5251
|
});
|
|
@@ -5236,7 +5253,7 @@ async function tc(e = {}) {
|
|
|
5236
5253
|
c.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
5237
5254
|
}
|
|
5238
5255
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
5239
|
-
let D = await
|
|
5256
|
+
let D = await Qs({
|
|
5240
5257
|
prepared: E,
|
|
5241
5258
|
config: a,
|
|
5242
5259
|
cwd: o,
|
|
@@ -5246,7 +5263,7 @@ async function tc(e = {}) {
|
|
|
5246
5263
|
});
|
|
5247
5264
|
try {
|
|
5248
5265
|
c.start("Installing pack files...");
|
|
5249
|
-
let t = await
|
|
5266
|
+
let t = await Wa({
|
|
5250
5267
|
packs: E,
|
|
5251
5268
|
config: a,
|
|
5252
5269
|
projectRoot: o,
|
|
@@ -5259,22 +5276,22 @@ async function tc(e = {}) {
|
|
|
5259
5276
|
for (let e of t.errors) s.log.error(e);
|
|
5260
5277
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5261
5278
|
}
|
|
5262
|
-
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)`),
|
|
5279
|
+
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)`), Zs(t.skipped));
|
|
5263
5280
|
for (let e of t.errors) s.log.error(e);
|
|
5264
|
-
await
|
|
5281
|
+
await ja(o, a.name), await Ys({
|
|
5265
5282
|
prepared: E,
|
|
5266
5283
|
paths: a.paths,
|
|
5267
5284
|
cwd: o,
|
|
5268
5285
|
spinner: c
|
|
5269
5286
|
});
|
|
5270
5287
|
let n;
|
|
5271
|
-
i && (n = await
|
|
5288
|
+
i && (n = await _o(o, e.yes ?? !1)), await br({
|
|
5272
5289
|
projectRoot: o,
|
|
5273
5290
|
paths: a.paths,
|
|
5274
5291
|
skipPrompts: e.yes ?? !1,
|
|
5275
5292
|
dbReady: n,
|
|
5276
5293
|
freshScaffold: i
|
|
5277
|
-
}),
|
|
5294
|
+
}), Xs(), s.outro(R.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
5278
5295
|
} finally {
|
|
5279
5296
|
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
5280
5297
|
recursive: !0,
|
|
@@ -5282,12 +5299,12 @@ async function tc(e = {}) {
|
|
|
5282
5299
|
})));
|
|
5283
5300
|
}
|
|
5284
5301
|
}
|
|
5285
|
-
async function
|
|
5302
|
+
async function rc(e) {
|
|
5286
5303
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
5287
5304
|
if (i.packs && i.packs.length > 0) {
|
|
5288
|
-
let e = i.packs.map(
|
|
5305
|
+
let e = i.packs.map(oc), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
5289
5306
|
n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1));
|
|
5290
|
-
let r =
|
|
5307
|
+
let r = ic(e, t);
|
|
5291
5308
|
if (r.length > 0) {
|
|
5292
5309
|
let e = t.filter((e) => e.category === "layout" && e.adminCompatible).map((e) => e.name), n = e.length > 0 ? ` Admin supports: ${e.join(", ")}.` : " No layout supports the admin app yet.";
|
|
5293
5310
|
s.cancel(`Layout${r.length === 1 ? "" : "s"} not compatible with the admin app: ${r.join(", ")}.${n}`), process.exit(1);
|
|
@@ -5298,15 +5315,15 @@ async function nc(e) {
|
|
|
5298
5315
|
o.length > 0 && B(o.map((e) => ` ${R.success("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
5299
5316
|
let c = t.filter((e) => !n.has(e.name));
|
|
5300
5317
|
if (c.length === 0) return s.outro(R.muted("Every available pack is already installed.")), [];
|
|
5301
|
-
let l =
|
|
5318
|
+
let l = ce();
|
|
5302
5319
|
B(c.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5303
|
-
let u =
|
|
5320
|
+
let u = Qa(c, { adminAvailable: a }), d = [];
|
|
5304
5321
|
for (let e of u) {
|
|
5305
5322
|
let t = e.packs.map((e) => {
|
|
5306
5323
|
let t = r(e.name);
|
|
5307
5324
|
return {
|
|
5308
5325
|
value: e.name,
|
|
5309
|
-
label: `${e.displayName} ${
|
|
5326
|
+
label: `${e.displayName} ${Gs(t, e.price)}`,
|
|
5310
5327
|
hint: e.description
|
|
5311
5328
|
};
|
|
5312
5329
|
});
|
|
@@ -5323,7 +5340,7 @@ async function nc(e) {
|
|
|
5323
5340
|
});
|
|
5324
5341
|
continue;
|
|
5325
5342
|
}
|
|
5326
|
-
let n = await
|
|
5343
|
+
let n = await Ro({
|
|
5327
5344
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
5328
5345
|
options: t,
|
|
5329
5346
|
required: !1
|
|
@@ -5333,7 +5350,7 @@ async function nc(e) {
|
|
|
5333
5350
|
}
|
|
5334
5351
|
return d;
|
|
5335
5352
|
}
|
|
5336
|
-
function
|
|
5353
|
+
function ic(e, t) {
|
|
5337
5354
|
let n = [];
|
|
5338
5355
|
for (let r of e) {
|
|
5339
5356
|
if (r.slot !== "admin") continue;
|
|
@@ -5342,20 +5359,20 @@ function rc(e, t) {
|
|
|
5342
5359
|
}
|
|
5343
5360
|
return n;
|
|
5344
5361
|
}
|
|
5345
|
-
var
|
|
5346
|
-
function
|
|
5347
|
-
let t = e.match(
|
|
5362
|
+
var ac = /@(frontend|admin)$/;
|
|
5363
|
+
function oc(e) {
|
|
5364
|
+
let t = e.match(ac);
|
|
5348
5365
|
return t ? {
|
|
5349
5366
|
name: e.slice(0, -t[0].length),
|
|
5350
5367
|
slot: t[1]
|
|
5351
5368
|
} : { name: e };
|
|
5352
5369
|
}
|
|
5353
|
-
function
|
|
5370
|
+
function sc(e) {
|
|
5354
5371
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
5355
5372
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
5356
5373
|
return n;
|
|
5357
5374
|
}
|
|
5358
|
-
function
|
|
5375
|
+
function cc(e) {
|
|
5359
5376
|
let t = /* @__PURE__ */ new Map();
|
|
5360
5377
|
for (let n of e) {
|
|
5361
5378
|
if (!n.slot) continue;
|
|
@@ -5366,11 +5383,11 @@ function sc(e) {
|
|
|
5366
5383
|
}
|
|
5367
5384
|
//#endregion
|
|
5368
5385
|
//#region src/commands/login.ts
|
|
5369
|
-
async function
|
|
5370
|
-
|
|
5386
|
+
async function lc() {
|
|
5387
|
+
Io(), s.intro(R.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
5371
5388
|
let e;
|
|
5372
5389
|
try {
|
|
5373
|
-
e = await
|
|
5390
|
+
e = await ar({ onUrl: (e) => {
|
|
5374
5391
|
s.log.info(`If your browser didn't open, visit:\n ${R.path(e)}`);
|
|
5375
5392
|
} });
|
|
5376
5393
|
} catch (e) {
|
|
@@ -5380,18 +5397,18 @@ async function cc() {
|
|
|
5380
5397
|
}
|
|
5381
5398
|
//#endregion
|
|
5382
5399
|
//#region src/commands/logout.ts
|
|
5383
|
-
async function
|
|
5384
|
-
|
|
5385
|
-
let e =
|
|
5400
|
+
async function uc() {
|
|
5401
|
+
Io(), s.intro(R.brandBold("Log out of Hype Stack"));
|
|
5402
|
+
let e = I(), t = await Xn(e);
|
|
5386
5403
|
if (!t) {
|
|
5387
5404
|
s.outro(R.muted("You're not logged in."));
|
|
5388
5405
|
return;
|
|
5389
5406
|
}
|
|
5390
|
-
await
|
|
5407
|
+
await Hn(t.token).catch(() => null), await Qn(e), s.outro(R.brand("Logged out."));
|
|
5391
5408
|
}
|
|
5392
5409
|
//#endregion
|
|
5393
5410
|
//#region src/core/onboard-env.ts
|
|
5394
|
-
function
|
|
5411
|
+
function dc(e) {
|
|
5395
5412
|
let t = [], n = "";
|
|
5396
5413
|
for (let r of e.split(/\r?\n/)) {
|
|
5397
5414
|
let e = r.trim();
|
|
@@ -5417,14 +5434,14 @@ function uc(e) {
|
|
|
5417
5434
|
}
|
|
5418
5435
|
return t;
|
|
5419
5436
|
}
|
|
5420
|
-
function
|
|
5437
|
+
function fc(e) {
|
|
5421
5438
|
let t = e.trim();
|
|
5422
5439
|
if (t === "") return "";
|
|
5423
5440
|
if (t.length <= 4) return "•".repeat(t.length);
|
|
5424
5441
|
let n = Math.min(t.length - 4, 8);
|
|
5425
5442
|
return `${"•".repeat(n)}${t.slice(-4)}`;
|
|
5426
5443
|
}
|
|
5427
|
-
function
|
|
5444
|
+
function pc(e, t, n) {
|
|
5428
5445
|
let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
|
|
5429
5446
|
if (i) return e;
|
|
5430
5447
|
let r = e.trim();
|
|
@@ -5434,22 +5451,22 @@ function fc(e, t, n) {
|
|
|
5434
5451
|
});
|
|
5435
5452
|
return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
|
|
5436
5453
|
}
|
|
5437
|
-
async function
|
|
5454
|
+
async function mc(e) {
|
|
5438
5455
|
return await Y(e) ? y.readFile(e, "utf-8") : "";
|
|
5439
5456
|
}
|
|
5440
|
-
async function
|
|
5457
|
+
async function hc(e) {
|
|
5441
5458
|
let t = T.join(T.dirname(e), ".env");
|
|
5442
5459
|
return await Y(t) || await y.copyFile(e, t), t;
|
|
5443
5460
|
}
|
|
5444
|
-
async function
|
|
5445
|
-
let r =
|
|
5461
|
+
async function gc(e, t, n) {
|
|
5462
|
+
let r = pc(await mc(e), t, n);
|
|
5446
5463
|
await y.writeFile(e, r, "utf-8");
|
|
5447
5464
|
}
|
|
5448
5465
|
//#endregion
|
|
5449
5466
|
//#region src/commands/onboard.ts
|
|
5450
|
-
async function
|
|
5467
|
+
async function _c(e = {}) {
|
|
5451
5468
|
let t = e.cwd ?? process.cwd();
|
|
5452
|
-
|
|
5469
|
+
Fo(), s.intro(R.brandBold("Onboard your stack"));
|
|
5453
5470
|
let n;
|
|
5454
5471
|
try {
|
|
5455
5472
|
n = await Ir(t);
|
|
@@ -5457,19 +5474,19 @@ async function gc(e = {}) {
|
|
|
5457
5474
|
n = null;
|
|
5458
5475
|
}
|
|
5459
5476
|
n || (s.cancel(`${R.path("stack.json")} not found. Run ${R.command("npx @hype-stack/cli init")} first.`), process.exit(1));
|
|
5460
|
-
let r = n.installedPacks ?? [], i = n.onboarding?.envSections ?? [], a = await
|
|
5477
|
+
let r = n.installedPacks ?? [], i = n.onboarding?.envSections ?? [], a = await ds(t);
|
|
5461
5478
|
a.length === 0 && s.log.warn(R.muted("No .env.example files found; skipping env setup."));
|
|
5462
|
-
for (let n of a) await
|
|
5479
|
+
for (let n of a) await vc({
|
|
5463
5480
|
examplePath: n,
|
|
5464
5481
|
projectRoot: t,
|
|
5465
5482
|
skipPrompts: e.yes ?? !1,
|
|
5466
5483
|
installedEnvSections: i
|
|
5467
5484
|
});
|
|
5468
5485
|
let o = Fr(r);
|
|
5469
|
-
o.length > 0 && B(o.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await
|
|
5486
|
+
o.length > 0 && B(o.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await xc(t, e.yes ?? !1), s.outro(R.brand(`All set. Run ${R.command("pnpm dev")} to start your app.`));
|
|
5470
5487
|
}
|
|
5471
|
-
async function
|
|
5472
|
-
let { examplePath: t, projectRoot: n, skipPrompts: r, installedEnvSections: i } = e, a = T.relative(n, t) || t, o = await
|
|
5488
|
+
async function vc(e) {
|
|
5489
|
+
let { examplePath: t, projectRoot: n, skipPrompts: r, installedEnvSections: i } = e, a = T.relative(n, t) || t, o = await hc(t), c = await mc(o), l = dc(await y.readFile(t, "utf-8")), u = R.path(a);
|
|
5473
5490
|
s.log.step(`Env: ${u}`);
|
|
5474
5491
|
for (let e of l) {
|
|
5475
5492
|
if (e.vars.length === 0) continue;
|
|
@@ -5485,7 +5502,7 @@ async function _c(e) {
|
|
|
5485
5502
|
s.log.info(`${R.label(n.key)} ${R.muted("skipped (non-interactive)")}`);
|
|
5486
5503
|
continue;
|
|
5487
5504
|
}
|
|
5488
|
-
let e =
|
|
5505
|
+
let e = fc(yc(c, n.key)), i = await s.text({
|
|
5489
5506
|
message: `${R.label(n.key)}`,
|
|
5490
5507
|
placeholder: e ? `${e} ${R.muted("(Enter keeps this)")}` : t.hint
|
|
5491
5508
|
});
|
|
@@ -5495,31 +5512,31 @@ async function _c(e) {
|
|
|
5495
5512
|
s.log.info(R.muted(`${n.key} unchanged.`));
|
|
5496
5513
|
continue;
|
|
5497
5514
|
}
|
|
5498
|
-
await
|
|
5515
|
+
await gc(o, n.key, a), s.log.success(`${n.key} saved`);
|
|
5499
5516
|
}
|
|
5500
5517
|
}
|
|
5501
5518
|
}
|
|
5502
|
-
function
|
|
5519
|
+
function yc(e, t) {
|
|
5503
5520
|
for (let n of e.split(/\r?\n/)) {
|
|
5504
|
-
let e = n.match(RegExp(`^${
|
|
5521
|
+
let e = n.match(RegExp(`^${bc(t)}\\s*=\\s*(.*)$`));
|
|
5505
5522
|
if (e) return e[1].trim();
|
|
5506
5523
|
}
|
|
5507
5524
|
return "";
|
|
5508
5525
|
}
|
|
5509
|
-
function
|
|
5526
|
+
function bc(e) {
|
|
5510
5527
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5511
5528
|
}
|
|
5512
|
-
async function
|
|
5513
|
-
if (!await
|
|
5529
|
+
async function xc(e, t) {
|
|
5530
|
+
if (!await to() && !await ro(e, t, !1)) {
|
|
5514
5531
|
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")}.`));
|
|
5515
5532
|
return;
|
|
5516
5533
|
}
|
|
5517
5534
|
let n = s.spinner();
|
|
5518
|
-
if (n.start("Waiting for Postgres to be ready..."), !await
|
|
5535
|
+
if (n.start("Waiting for Postgres to be ready..."), !await lo(e)) {
|
|
5519
5536
|
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")}`));
|
|
5520
5537
|
return;
|
|
5521
5538
|
}
|
|
5522
|
-
if (n.stop(R.success("Postgres is ready")), await
|
|
5539
|
+
if (n.stop(R.success("Postgres is ready")), await fo(e)) {
|
|
5523
5540
|
s.log.info(R.muted("Migrations already applied, skipping."));
|
|
5524
5541
|
return;
|
|
5525
5542
|
}
|
|
@@ -5531,21 +5548,21 @@ async function bc(e, t) {
|
|
|
5531
5548
|
s.log.info(R.muted("Skipping database migrations."));
|
|
5532
5549
|
return;
|
|
5533
5550
|
}
|
|
5534
|
-
await
|
|
5551
|
+
await po(e);
|
|
5535
5552
|
}
|
|
5536
5553
|
//#endregion
|
|
5537
5554
|
//#region src/core/templates.ts
|
|
5538
|
-
var
|
|
5555
|
+
var Sc = q.createRequest()({
|
|
5539
5556
|
endpoint: "/templates/list",
|
|
5540
5557
|
method: "GET"
|
|
5541
5558
|
});
|
|
5542
|
-
async function
|
|
5543
|
-
let { data: e, error: t } = await
|
|
5559
|
+
async function Cc() {
|
|
5560
|
+
let { data: e, error: t } = await Sc.send();
|
|
5544
5561
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
5545
5562
|
return e.templates;
|
|
5546
5563
|
}
|
|
5547
|
-
async function
|
|
5548
|
-
let { data: t, error: n, status: r } = await
|
|
5564
|
+
async function wc(e) {
|
|
5565
|
+
let { data: t, error: n, status: r } = await q.createRequest()({
|
|
5549
5566
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
5550
5567
|
method: "GET"
|
|
5551
5568
|
}).send();
|
|
@@ -5553,13 +5570,13 @@ async function Cc(e) {
|
|
|
5553
5570
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
5554
5571
|
return t;
|
|
5555
5572
|
}
|
|
5556
|
-
async function
|
|
5557
|
-
let n =
|
|
5573
|
+
async function Tc(e, t = {}) {
|
|
5574
|
+
let n = q.createRequest()({
|
|
5558
5575
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
5559
5576
|
method: "POST"
|
|
5560
5577
|
}), r = {
|
|
5561
|
-
"X-Device-Id":
|
|
5562
|
-
"X-Client-Info":
|
|
5578
|
+
"X-Device-Id": er(),
|
|
5579
|
+
"X-Client-Info": tr()
|
|
5563
5580
|
};
|
|
5564
5581
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
5565
5582
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -5581,9 +5598,9 @@ async function wc(e, t = {}) {
|
|
|
5581
5598
|
}
|
|
5582
5599
|
//#endregion
|
|
5583
5600
|
//#region src/commands/template.ts
|
|
5584
|
-
async function
|
|
5601
|
+
async function Ec(t = {}) {
|
|
5585
5602
|
let n = t.cwd ?? process.cwd();
|
|
5586
|
-
|
|
5603
|
+
Fo();
|
|
5587
5604
|
let r = s.spinner();
|
|
5588
5605
|
r.start("Loading packs...");
|
|
5589
5606
|
let o;
|
|
@@ -5595,14 +5612,14 @@ async function Tc(t = {}) {
|
|
|
5595
5612
|
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
5596
5613
|
let c;
|
|
5597
5614
|
try {
|
|
5598
|
-
c = await
|
|
5615
|
+
c = await Cc();
|
|
5599
5616
|
} catch (e) {
|
|
5600
5617
|
r.stop("Failed to load templates"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
5601
5618
|
}
|
|
5602
5619
|
let l = t.templateId;
|
|
5603
5620
|
if (!l) {
|
|
5604
5621
|
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");
|
|
5605
|
-
let e =
|
|
5622
|
+
let e = ce();
|
|
5606
5623
|
B(c.map((t) => ` ${z.arrow} ${R.highlight(t.name)} ${_e(`${e}/templates/${t.id}`)}`).join("\n"), "Browse templates");
|
|
5607
5624
|
let n = await s.select({
|
|
5608
5625
|
message: "Choose a template",
|
|
@@ -5618,11 +5635,11 @@ async function Tc(t = {}) {
|
|
|
5618
5635
|
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}`);
|
|
5619
5636
|
let d;
|
|
5620
5637
|
try {
|
|
5621
|
-
d = await
|
|
5638
|
+
d = await wc(u.id);
|
|
5622
5639
|
} catch (e) {
|
|
5623
5640
|
s.cancel($(e)), process.exit(1);
|
|
5624
5641
|
}
|
|
5625
|
-
let f = await
|
|
5642
|
+
let f = await tc(n, {}, {
|
|
5626
5643
|
defaultTheme: d.theme,
|
|
5627
5644
|
defaultMode: d.defaultMode,
|
|
5628
5645
|
radius: d.radius
|
|
@@ -5635,16 +5652,16 @@ async function Tc(t = {}) {
|
|
|
5635
5652
|
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));
|
|
5636
5653
|
let g = p ?? n;
|
|
5637
5654
|
s.intro(R.brandBold("Install a template"));
|
|
5638
|
-
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await
|
|
5655
|
+
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await Xn(I()))?.token ?? null, C = await Dc(u, t.variants, t.yes ?? !1), w = So(u.slots, C), E = Co(u.slots, u.packs, w), D = await Oc({
|
|
5639
5656
|
packs: o,
|
|
5640
5657
|
templatePacks: E,
|
|
5641
5658
|
installedSet: v,
|
|
5642
5659
|
options: t
|
|
5643
5660
|
}), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
|
|
5644
5661
|
k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
|
|
5645
|
-
let A =
|
|
5662
|
+
let A = Eo(o, w), j = vo(A), ee;
|
|
5646
5663
|
try {
|
|
5647
|
-
ee =
|
|
5664
|
+
ee = bo(O, j, _);
|
|
5648
5665
|
} catch (e) {
|
|
5649
5666
|
s.cancel($(e)), process.exit(1);
|
|
5650
5667
|
}
|
|
@@ -5652,118 +5669,127 @@ async function Tc(t = {}) {
|
|
|
5652
5669
|
s.outro(R.muted("Every pack in this template is already installed."));
|
|
5653
5670
|
return;
|
|
5654
5671
|
}
|
|
5655
|
-
let
|
|
5672
|
+
let te = await Ws(A, v, {
|
|
5656
5673
|
token: S,
|
|
5657
5674
|
key: x
|
|
5658
|
-
}),
|
|
5675
|
+
}), ne = (e) => {
|
|
5659
5676
|
let t = b.get(e);
|
|
5660
|
-
return !t || t.tier === "free" ? "free" :
|
|
5661
|
-
},
|
|
5677
|
+
return !t || t.tier === "free" ? "free" : te[e]?.owned ? "owned" : "locked";
|
|
5678
|
+
}, M = (e) => !v.has(e) && ne(e) === "locked", N = xo({
|
|
5662
5679
|
order: ee.order,
|
|
5663
5680
|
graph: j,
|
|
5664
|
-
isLocked:
|
|
5681
|
+
isLocked: M,
|
|
5665
5682
|
installed: _
|
|
5666
5683
|
});
|
|
5667
|
-
if (
|
|
5668
|
-
let e = await
|
|
5669
|
-
e && (S = e,
|
|
5684
|
+
if (N.blocked.length > 0 && !S && !x) {
|
|
5685
|
+
let e = await or();
|
|
5686
|
+
e && (S = e, te = await Ws(A, v, {
|
|
5670
5687
|
token: S,
|
|
5671
5688
|
key: x
|
|
5672
|
-
}),
|
|
5689
|
+
}), N = xo({
|
|
5673
5690
|
order: ee.order,
|
|
5674
5691
|
graph: j,
|
|
5675
|
-
isLocked:
|
|
5692
|
+
isLocked: M,
|
|
5676
5693
|
installed: _
|
|
5677
5694
|
}));
|
|
5678
5695
|
}
|
|
5679
|
-
if (
|
|
5696
|
+
if (N.blocked.length > 0 && await Ks(N.blocked, M, b), N.installable.length === 0) {
|
|
5680
5697
|
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
5681
5698
|
return;
|
|
5682
5699
|
}
|
|
5683
|
-
if (
|
|
5684
|
-
let e = await s.confirm({ message: `Install template ${R.brandBold(u.name)} (${
|
|
5700
|
+
if (qs(N.installable, b), !t.yes) {
|
|
5701
|
+
let e = await s.confirm({ message: `Install template ${R.brandBold(u.name)} (${N.installable.length} pack${N.installable.length === 1 ? "" : "s"})?` });
|
|
5685
5702
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5686
5703
|
}
|
|
5687
5704
|
r.start("Downloading packs...");
|
|
5688
|
-
let
|
|
5705
|
+
let P;
|
|
5689
5706
|
try {
|
|
5690
|
-
|
|
5707
|
+
P = await Js(N.installable, {
|
|
5691
5708
|
token: S,
|
|
5692
5709
|
key: x
|
|
5693
5710
|
});
|
|
5694
5711
|
} catch (e) {
|
|
5695
5712
|
r.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
5696
5713
|
}
|
|
5697
|
-
r.stop(`Downloaded ${
|
|
5698
|
-
let
|
|
5699
|
-
prepared:
|
|
5714
|
+
r.stop(`Downloaded ${P.length} pack${P.length === 1 ? "" : "s"}`);
|
|
5715
|
+
let re = await Qs({
|
|
5716
|
+
prepared: P,
|
|
5700
5717
|
config: h,
|
|
5701
5718
|
cwd: g,
|
|
5702
5719
|
force: t.force ?? !1,
|
|
5703
5720
|
yes: t.yes ?? !1
|
|
5704
|
-
}),
|
|
5721
|
+
}), F = null;
|
|
5705
5722
|
try {
|
|
5706
5723
|
r.start("Installing pack files...");
|
|
5707
|
-
let n = await
|
|
5708
|
-
packs:
|
|
5724
|
+
let n = await Wa({
|
|
5725
|
+
packs: P,
|
|
5709
5726
|
config: h,
|
|
5710
5727
|
projectRoot: g,
|
|
5711
5728
|
force: t.force ?? !1,
|
|
5712
|
-
overwrite:
|
|
5729
|
+
overwrite: re
|
|
5713
5730
|
});
|
|
5714
5731
|
if (n.aborted) {
|
|
5715
5732
|
r.stop("Installation aborted");
|
|
5716
5733
|
for (let e of n.errors) s.log.error(e);
|
|
5717
5734
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5718
5735
|
}
|
|
5719
|
-
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)`),
|
|
5736
|
+
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)`), Zs(n.skipped));
|
|
5720
5737
|
for (let e of n.errors) s.log.error(e);
|
|
5721
5738
|
r.start("Applying template overrides...");
|
|
5722
|
-
let o = await
|
|
5739
|
+
let o = await Tc(u.id, {
|
|
5723
5740
|
token: S,
|
|
5724
5741
|
licenseKey: x
|
|
5725
5742
|
});
|
|
5726
|
-
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)),
|
|
5727
|
-
let c = await
|
|
5743
|
+
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)), F = o.templateDir;
|
|
5744
|
+
let c = await Ka({
|
|
5728
5745
|
manifest: d,
|
|
5729
5746
|
config: h,
|
|
5730
5747
|
projectRoot: g,
|
|
5731
|
-
templateDir:
|
|
5748
|
+
templateDir: F
|
|
5732
5749
|
});
|
|
5733
5750
|
r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
|
|
5734
5751
|
for (let e of c.errors) s.log.error(e);
|
|
5735
|
-
if (
|
|
5752
|
+
if (d.navbarActions && d.navbarActions.length > 0 && h.paths) {
|
|
5753
|
+
let e = d.navbarActions.filter((e) => !e.slot || e.slot === "frontend");
|
|
5754
|
+
e.length > 0 && await _a({
|
|
5755
|
+
actions: e,
|
|
5756
|
+
paths: h.paths,
|
|
5757
|
+
projectRoot: g,
|
|
5758
|
+
slot: "frontend"
|
|
5759
|
+
});
|
|
5760
|
+
}
|
|
5761
|
+
if (await ja(g, h.name), !m) {
|
|
5736
5762
|
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5737
|
-
a(n) && (await
|
|
5763
|
+
a(n) && (await es(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`))), d.radius !== void 0 && Go(d.radius) && (await Jo(t, d.radius) ? s.log.success(`Set the corner radius to ${d.radius}`) : s.log.warning(R.muted(`Could not find ${R.path("assets/styles.css")} to set the corner radius`)));
|
|
5738
5764
|
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5739
|
-
await
|
|
5765
|
+
await Uo(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`));
|
|
5740
5766
|
}
|
|
5741
|
-
await
|
|
5742
|
-
prepared:
|
|
5767
|
+
await kc({
|
|
5768
|
+
prepared: P,
|
|
5743
5769
|
templateNpm: d.dependencies_npm,
|
|
5744
5770
|
paths: h.paths,
|
|
5745
5771
|
cwd: g,
|
|
5746
5772
|
spinner: r
|
|
5747
5773
|
});
|
|
5748
5774
|
let l;
|
|
5749
|
-
m && (l = await
|
|
5775
|
+
m && (l = await _o(g, t.yes ?? !1)), await br({
|
|
5750
5776
|
projectRoot: g,
|
|
5751
5777
|
paths: h.paths,
|
|
5752
5778
|
skipPrompts: t.yes ?? !1,
|
|
5753
5779
|
dbReady: l,
|
|
5754
5780
|
freshScaffold: m
|
|
5755
|
-
}),
|
|
5781
|
+
}), Xs(), s.outro(R.brand(`Installed template ${u.name}.`));
|
|
5756
5782
|
} finally {
|
|
5757
|
-
await Promise.all(
|
|
5783
|
+
await Promise.all(P.map((e) => y.rm(e.packDir, {
|
|
5758
5784
|
recursive: !0,
|
|
5759
5785
|
force: !0
|
|
5760
|
-
}))),
|
|
5786
|
+
}))), F && await y.rm(F, {
|
|
5761
5787
|
recursive: !0,
|
|
5762
5788
|
force: !0
|
|
5763
5789
|
});
|
|
5764
5790
|
}
|
|
5765
5791
|
}
|
|
5766
|
-
async function
|
|
5792
|
+
async function Dc(e, t, n) {
|
|
5767
5793
|
let r = {};
|
|
5768
5794
|
for (let i of e.slots) {
|
|
5769
5795
|
if (t?.[i.family]) {
|
|
@@ -5787,7 +5813,7 @@ async function Ec(e, t, n) {
|
|
|
5787
5813
|
}
|
|
5788
5814
|
return r;
|
|
5789
5815
|
}
|
|
5790
|
-
async function
|
|
5816
|
+
async function Oc(e) {
|
|
5791
5817
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5792
5818
|
if (i.packs && i.packs.length > 0) {
|
|
5793
5819
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -5796,9 +5822,9 @@ async function Dc(e) {
|
|
|
5796
5822
|
if (i.yes) return [];
|
|
5797
5823
|
let o = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
|
|
5798
5824
|
if (o.length === 0) return [];
|
|
5799
|
-
let c =
|
|
5825
|
+
let c = ce();
|
|
5800
5826
|
B(o.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5801
|
-
let l = await
|
|
5827
|
+
let l = await Ro({
|
|
5802
5828
|
message: "Add extra packs on top of the template (optional)",
|
|
5803
5829
|
options: o.map((e) => ({
|
|
5804
5830
|
value: e.name,
|
|
@@ -5809,25 +5835,25 @@ async function Dc(e) {
|
|
|
5809
5835
|
});
|
|
5810
5836
|
return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
|
|
5811
5837
|
}
|
|
5812
|
-
async function
|
|
5813
|
-
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o =
|
|
5838
|
+
async function kc(e) {
|
|
5839
|
+
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o = Hs(t.map((e) => e.manifest.dependencies_npm)), c = Vs(n ? Hs([o, n]) : o, r);
|
|
5814
5840
|
if (c.errors.length > 0) {
|
|
5815
5841
|
for (let e of c.errors) s.log.error(e);
|
|
5816
5842
|
return;
|
|
5817
5843
|
}
|
|
5818
5844
|
if (c.operations.length === 0) return;
|
|
5819
5845
|
a.start("Installing npm dependencies...");
|
|
5820
|
-
let l = await
|
|
5846
|
+
let l = await Us(c.operations, i);
|
|
5821
5847
|
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) s.log.error(e);
|
|
5822
5848
|
}
|
|
5823
5849
|
//#endregion
|
|
5824
5850
|
//#region src/cli.ts
|
|
5825
|
-
function
|
|
5851
|
+
function Ac(e) {
|
|
5826
5852
|
if (!e) return;
|
|
5827
5853
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5828
5854
|
return t.length > 0 ? t : void 0;
|
|
5829
5855
|
}
|
|
5830
|
-
function
|
|
5856
|
+
function jc(e) {
|
|
5831
5857
|
if (!e) return;
|
|
5832
5858
|
let t = {};
|
|
5833
5859
|
for (let n of e.split(",")) {
|
|
@@ -5836,10 +5862,10 @@ function Ac(e) {
|
|
|
5836
5862
|
}
|
|
5837
5863
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5838
5864
|
}
|
|
5839
|
-
function
|
|
5865
|
+
function Mc() {
|
|
5840
5866
|
let e = new o();
|
|
5841
|
-
return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(j, "-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>", "Frontend color theme (default, slate, rose, emerald, violet, amber, ocean, zinc-mono, crimson, midnight)").option("--admin-theme <theme>", "Admin app color theme (defaults to --theme when omitted)").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) => {
|
|
5842
|
-
await
|
|
5867
|
+
return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(j, "-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>", "Frontend color theme (default, slate, rose, emerald, violet, amber, ocean, zinc-mono, crimson, midnight, black)").option("--admin-theme <theme>", "Admin app color theme (defaults to --theme when omitted)").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) => {
|
|
5868
|
+
await $s({
|
|
5843
5869
|
name: e.name,
|
|
5844
5870
|
directory: e.directory,
|
|
5845
5871
|
install: e.install,
|
|
@@ -5850,38 +5876,38 @@ function jc() {
|
|
|
5850
5876
|
setup: e.setup
|
|
5851
5877
|
});
|
|
5852
5878
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5853
|
-
await
|
|
5879
|
+
await ec({});
|
|
5854
5880
|
}), 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) => {
|
|
5855
|
-
await
|
|
5881
|
+
await _c({
|
|
5856
5882
|
cwd: e.cwd,
|
|
5857
5883
|
yes: e.yes,
|
|
5858
5884
|
skipMigrations: e.skipMigrations
|
|
5859
5885
|
});
|
|
5860
5886
|
}), 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) => {
|
|
5861
|
-
await
|
|
5862
|
-
packs:
|
|
5887
|
+
await nc({
|
|
5888
|
+
packs: Ac(e.packs),
|
|
5863
5889
|
force: e.force,
|
|
5864
5890
|
yes: e.yes,
|
|
5865
5891
|
licenseKey: e.key ?? e.licenseKey,
|
|
5866
5892
|
cwd: e.cwd
|
|
5867
5893
|
});
|
|
5868
5894
|
}), 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) => {
|
|
5869
|
-
await
|
|
5895
|
+
await Ec({
|
|
5870
5896
|
templateId: e,
|
|
5871
|
-
variants:
|
|
5872
|
-
packs:
|
|
5897
|
+
variants: jc(t.variants),
|
|
5898
|
+
packs: Ac(t.packs),
|
|
5873
5899
|
force: t.force,
|
|
5874
5900
|
yes: t.yes,
|
|
5875
5901
|
licenseKey: t.key ?? t.licenseKey,
|
|
5876
5902
|
cwd: t.cwd
|
|
5877
5903
|
});
|
|
5878
5904
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5879
|
-
await cc();
|
|
5880
|
-
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5881
5905
|
await lc();
|
|
5906
|
+
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5907
|
+
await uc();
|
|
5882
5908
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5883
|
-
await
|
|
5909
|
+
await lc();
|
|
5884
5910
|
}), e;
|
|
5885
5911
|
}
|
|
5886
5912
|
//#endregion
|
|
5887
|
-
export {
|
|
5913
|
+
export { tc as a, nc as i, uc as n, ec as o, lc as r, $s as s, Mc as t };
|