@hype-stack/cli 0.7.0 → 0.7.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-DTZHjJ1z.js → cli-DBnCO9P6.js} +962 -807
- package/dist/cli.d.ts.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/config/bin.js +1 -1
- package/dist/core/codemods.d.ts +36 -1
- 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/types/types.d.ts +41 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -11,9 +11,9 @@ import T from "node:path";
|
|
|
11
11
|
import { exec as E, spawn as D } from "node:child_process";
|
|
12
12
|
import { Prompt as O } from "@clack/core";
|
|
13
13
|
import { styleText as k } from "node:util";
|
|
14
|
-
import { downloadTemplate as
|
|
14
|
+
import { downloadTemplate as A } from "giget";
|
|
15
15
|
//#region src/constants/constants.ts
|
|
16
|
-
var
|
|
16
|
+
var j = "0.7.1", ee = "gh:BetterTyped/hype-stack", M = "stack.json", te = "/schema/stack.json", N = "https://api.hype-stack.dev", P = "HYPE_STACK_API_URL", F = "https://www.hype-stack.dev", ne = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, I = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -351,11 +351,11 @@ var Ee = Object.create, De = Object.defineProperty, Oe = Object.getOwnPropertyDe
|
|
|
351
351
|
isFocused;
|
|
352
352
|
constructor(e) {
|
|
353
353
|
this.options = e, this.emitter?.setMaxListeners(1e3);
|
|
354
|
-
let { initiallyFocused: t =
|
|
354
|
+
let { initiallyFocused: t = Ge.initiallyFocused, initiallyOnline: n = Ge.initiallyOnline } = this.options || Ge;
|
|
355
355
|
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser = Ve();
|
|
356
356
|
}
|
|
357
357
|
initialize = () => {
|
|
358
|
-
let { focusEvent: e =
|
|
358
|
+
let { focusEvent: e = Ge.focusEvent, onlineEvent: t = Ge.onlineEvent } = this.options || Ge;
|
|
359
359
|
e(this.setFocused), t(this.setOnline);
|
|
360
360
|
};
|
|
361
361
|
setInitialFocus = async (e) => {
|
|
@@ -403,7 +403,7 @@ var Ee = Object.create, De = Object.defineProperty, Oe = Object.getOwnPropertyDe
|
|
|
403
403
|
onOffline: (t) => (e.on(H.OFFLINE, t), () => e.removeListener(H.OFFLINE, t))
|
|
404
404
|
}), H = /* @__PURE__ */ function(e) {
|
|
405
405
|
return e.FOCUS = "focus", e.BLUR = "blur", e.ONLINE = "online", e.OFFLINE = "offline", e;
|
|
406
|
-
}({}),
|
|
406
|
+
}({}), Ge = {
|
|
407
407
|
initiallyFocused: !0,
|
|
408
408
|
initiallyOnline: !0,
|
|
409
409
|
focusEvent: (e) => {
|
|
@@ -412,9 +412,9 @@ var Ee = Object.create, De = Object.defineProperty, Oe = Object.getOwnPropertyDe
|
|
|
412
412
|
onlineEvent: (e) => {
|
|
413
413
|
He("online", () => e(!0)), He("offline", () => e(!1));
|
|
414
414
|
}
|
|
415
|
-
},
|
|
415
|
+
}, Ke = class {
|
|
416
416
|
emitter = new Re();
|
|
417
|
-
events =
|
|
417
|
+
events = St(this.emitter);
|
|
418
418
|
constructor() {
|
|
419
419
|
this.emitter?.setMaxListeners(1e3);
|
|
420
420
|
}
|
|
@@ -451,71 +451,71 @@ var Ee = Object.create, De = Object.defineProperty, Oe = Object.getOwnPropertyDe
|
|
|
451
451
|
});
|
|
452
452
|
});
|
|
453
453
|
};
|
|
454
|
-
},
|
|
454
|
+
}, qe = () => "loading-event-any", Je = (e) => `${e}-loading-event`, Ye = (e) => `${e}-loading-cache-event`, Xe = (e) => `${e}-loading-event-by-id`, Ze = () => "remove-event-any", Qe = (e) => `${e}-remove-event`, $e = (e) => `${e}-remove-event-by-id`, et = () => "request-abort-any", tt = (e) => `${e}-request-abort`, nt = (e) => `${e}-request-abort-by-id`, rt = () => "response-any", it = (e) => `${e}-response`, at = (e) => `${e}-response-by-id`, ot = () => "request-start-any", st = (e) => `${e}-request-start`, ct = (e) => `${e}-request-start-by-id`, lt = () => "response-start-any", ut = (e) => `${e}-response-start`, dt = (e) => `${e}-response-start-by-id`, ft = () => "request-progress-any", pt = (e) => `${e}-request-progress`, mt = (e) => `${e}-request-progress-by-id`, ht = () => "response-progress-any", gt = (e) => `${e}-response-progress`, _t = (e) => `${e}-response-progress-by-id`, vt = () => "request-deduplicated-any", yt = (e) => `${e}-query-request-deduplicated`, bt = (e) => `${e}-cache-request-deduplicated`, xt = (e) => `${e}-request-deduplicated-by-id`, St = (e) => ({
|
|
455
455
|
emitDeduplicated: (t, n = !1) => {
|
|
456
|
-
e.emit(
|
|
456
|
+
e.emit(vt(), t, n), e.emit(xt(t.requestId), t, n), e.emit(bt(t.request.cacheKey), t, n), e.emit(yt(t.request.queryKey), t, n);
|
|
457
457
|
},
|
|
458
458
|
emitLoading: (t, n = !1) => {
|
|
459
|
-
e.emit(
|
|
459
|
+
e.emit(qe(), t, n), e.emit(Xe(t.requestId), t, n), e.emit(Ye(t.request.cacheKey), t, n), e.emit(Je(t.request.queryKey), t, n);
|
|
460
460
|
},
|
|
461
461
|
emitRequestStart: (t, n = !1) => {
|
|
462
|
-
e.emit(
|
|
462
|
+
e.emit(ot(), t, n), e.emit(ct(t.requestId), t, n), e.emit(st(t.request.queryKey), t, n);
|
|
463
463
|
},
|
|
464
464
|
emitResponseStart: (t, n = !1) => {
|
|
465
|
-
e.emit(
|
|
465
|
+
e.emit(lt(), t, n), e.emit(dt(t.requestId), t, n), e.emit(ut(t.request.queryKey), t, n);
|
|
466
466
|
},
|
|
467
467
|
emitUploadProgress: (t, n = !1) => {
|
|
468
|
-
e.emit(
|
|
468
|
+
e.emit(ft(), t, n), e.emit(mt(t.requestId), t, n), e.emit(pt(t.request.queryKey), t, n);
|
|
469
469
|
},
|
|
470
470
|
emitDownloadProgress: (t, n = !1) => {
|
|
471
|
-
e.emit(
|
|
471
|
+
e.emit(ht(), t, n), e.emit(_t(t.requestId), t, n), e.emit(gt(t.request.queryKey), t, n);
|
|
472
472
|
},
|
|
473
473
|
emitResponse: (t, n = !1) => {
|
|
474
|
-
e.emit(
|
|
474
|
+
e.emit(rt(), t, n), e.emit(at(t.requestId), t, n), e.emit(it(t.request.cacheKey), t, n);
|
|
475
475
|
},
|
|
476
476
|
emitAbort: (t, n = !1) => {
|
|
477
|
-
e.emit(
|
|
477
|
+
e.emit(et(), t, n), e.emit(nt(t.requestId), t, n), e.emit(tt(t.request.abortKey), t, n);
|
|
478
478
|
},
|
|
479
479
|
emitRemove: (t, n = !1) => {
|
|
480
|
-
e.emit(
|
|
480
|
+
e.emit(Ze(), t, n), e.emit($e(t.requestId), t, n), e.emit(Qe(t.request.queryKey), t, n);
|
|
481
481
|
},
|
|
482
|
-
onDeduplicated: (t) => (e.on(
|
|
483
|
-
onDeduplicatedByQueue: (t, n) => (e.on(
|
|
484
|
-
onDeduplicatedByCache: (t, n) => (e.on(
|
|
485
|
-
onDeduplicatedById: (t, n) => (e.on(
|
|
486
|
-
onLoading: (t) => (e.on(
|
|
487
|
-
onLoadingByQueue: (t, n) => (e.on(
|
|
488
|
-
onLoadingByCache: (t, n) => (e.on(
|
|
489
|
-
onLoadingById: (t, n) => (e.on(
|
|
490
|
-
onRequestStart: (t) => (e.on(
|
|
491
|
-
onRequestStartByQueue: (t, n) => (e.on(
|
|
492
|
-
onRequestStartById: (t, n) => (e.on(
|
|
493
|
-
onResponseStart: (t) => (e.on(
|
|
494
|
-
onResponseStartByQueue: (t, n) => (e.on(
|
|
495
|
-
onResponseStartById: (t, n) => (e.on(
|
|
496
|
-
onUploadProgress: (t) => (e.on(
|
|
497
|
-
onUploadProgressByQueue: (t, n) => (e.on(
|
|
498
|
-
onUploadProgressById: (t, n) => (e.on(
|
|
499
|
-
onDownloadProgress: (t) => (e.on(
|
|
500
|
-
onDownloadProgressByQueue: (t, n) => (e.on(
|
|
501
|
-
onDownloadProgressById: (t, n) => (e.on(
|
|
502
|
-
onResponse: (t) => (e.on(
|
|
503
|
-
onResponseByCache: (t, n) => (e.on(
|
|
504
|
-
onResponseById: (t, n) => (e.on(
|
|
505
|
-
onAbort: (t) => (e.on(
|
|
506
|
-
onAbortByKey: (t, n) => (e.on(
|
|
507
|
-
onAbortById: (t, n) => (e.on(
|
|
508
|
-
onRemove: (t) => (e.on(
|
|
509
|
-
onRemoveByQueue: (t, n) => (e.on(
|
|
510
|
-
onRemoveById: (t, n) => (e.on(
|
|
511
|
-
}),
|
|
482
|
+
onDeduplicated: (t) => (e.on(vt(), t), () => e.removeListener(vt(), t)),
|
|
483
|
+
onDeduplicatedByQueue: (t, n) => (e.on(yt(t), n), () => e.removeListener(yt(t), n)),
|
|
484
|
+
onDeduplicatedByCache: (t, n) => (e.on(bt(t), n), () => e.removeListener(bt(t), n)),
|
|
485
|
+
onDeduplicatedById: (t, n) => (e.on(xt(t), n), () => e.removeListener(xt(t), n)),
|
|
486
|
+
onLoading: (t) => (e.on(qe(), t), () => e.removeListener(qe(), t)),
|
|
487
|
+
onLoadingByQueue: (t, n) => (e.on(Je(t), n), () => e.removeListener(Je(t), n)),
|
|
488
|
+
onLoadingByCache: (t, n) => (e.on(Ye(t), n), () => e.removeListener(Ye(t), n)),
|
|
489
|
+
onLoadingById: (t, n) => (e.on(Xe(t), n), () => e.removeListener(Xe(t), n)),
|
|
490
|
+
onRequestStart: (t) => (e.on(ot(), t), () => e.removeListener(ot(), t)),
|
|
491
|
+
onRequestStartByQueue: (t, n) => (e.on(st(t), n), () => e.removeListener(st(t), n)),
|
|
492
|
+
onRequestStartById: (t, n) => (e.on(ct(t), n), () => e.removeListener(ct(t), n)),
|
|
493
|
+
onResponseStart: (t) => (e.on(lt(), t), () => e.removeListener(lt(), t)),
|
|
494
|
+
onResponseStartByQueue: (t, n) => (e.on(ut(t), n), () => e.removeListener(ut(t), n)),
|
|
495
|
+
onResponseStartById: (t, n) => (e.on(dt(t), n), () => e.removeListener(dt(t), n)),
|
|
496
|
+
onUploadProgress: (t) => (e.on(ft(), t), () => e.removeListener(ft(), t)),
|
|
497
|
+
onUploadProgressByQueue: (t, n) => (e.on(pt(t), n), () => e.removeListener(pt(t), n)),
|
|
498
|
+
onUploadProgressById: (t, n) => (e.on(mt(t), n), () => e.removeListener(mt(t), n)),
|
|
499
|
+
onDownloadProgress: (t) => (e.on(ht(), t), () => e.removeListener(ht(), t)),
|
|
500
|
+
onDownloadProgressByQueue: (t, n) => (e.on(gt(t), n), () => e.removeListener(gt(t), n)),
|
|
501
|
+
onDownloadProgressById: (t, n) => (e.on(_t(t), n), () => e.removeListener(_t(t), n)),
|
|
502
|
+
onResponse: (t) => (e.on(rt(), t), () => e.removeListener(rt(), t)),
|
|
503
|
+
onResponseByCache: (t, n) => (e.on(it(t), n), () => e.removeListener(it(t), n)),
|
|
504
|
+
onResponseById: (t, n) => (e.on(at(t), n), () => e.removeListener(at(t), n)),
|
|
505
|
+
onAbort: (t) => (e.on(et(), t), () => e.removeListener(et(), t)),
|
|
506
|
+
onAbortByKey: (t, n) => (e.on(tt(t), n), () => e.removeListener(tt(t), n)),
|
|
507
|
+
onAbortById: (t, n) => (e.on(nt(t), n), () => e.removeListener(nt(t), n)),
|
|
508
|
+
onRemove: (t) => (e.on(Ze(), t), () => e.removeListener(Ze(), t)),
|
|
509
|
+
onRemoveByQueue: (t, n) => (e.on(Qe(t), n), () => e.removeListener(Qe(t), n)),
|
|
510
|
+
onRemoveById: (t, n) => (e.on($e(t), n), () => e.removeListener($e(t), n))
|
|
511
|
+
}), Ct = class {
|
|
512
512
|
logger;
|
|
513
513
|
level;
|
|
514
514
|
modules;
|
|
515
515
|
emitter = new Ie.default();
|
|
516
516
|
client;
|
|
517
517
|
constructor(e) {
|
|
518
|
-
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger ||
|
|
518
|
+
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger || Et, this.level = this.options?.level || "warning", this.modules = this.options?.modules;
|
|
519
519
|
}
|
|
520
520
|
setSeverity = (e) => {
|
|
521
521
|
this.level = e;
|
|
@@ -546,58 +546,58 @@ var Ee = Object.create, De = Object.defineProperty, Oe = Object.getOwnPropertyDe
|
|
|
546
546
|
})
|
|
547
547
|
});
|
|
548
548
|
log = (e) => {
|
|
549
|
-
this.client.debug && (
|
|
549
|
+
this.client.debug && (Dt.indexOf(this.level) <= Dt.indexOf(e.level) || this.modules && !this.modules.includes(e.module) || this.logger(e));
|
|
550
550
|
};
|
|
551
|
-
},
|
|
552
|
-
let t =
|
|
551
|
+
}, wt = () => `${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`, Tt = (e) => e.type === "request" || e.type === "response" ? `${e.extra.request.endpoint}` : `[${e.module}]`, Et = (e) => {
|
|
552
|
+
let t = kt[e.level], n = At[e.level], r = `%c[${wt()}]%c${e.title}%c${Tt(e)}`, i = `${t}${n}font-weight:600;border-radius: 4px 0 0 4px;`, a = `${t}${n}font-weight:600;`, o = `${t}font-weight:normal;border-radius: 0 4px 4px 0;`;
|
|
553
553
|
e.extra && Object.keys(e.extra)?.length ? (console.groupCollapsed(r, i, a, o), console.log(e.extra), console.groupEnd()) : console.log(r, t);
|
|
554
|
-
},
|
|
554
|
+
}, Dt = [
|
|
555
555
|
"error",
|
|
556
556
|
"warning",
|
|
557
557
|
"info",
|
|
558
558
|
"debug"
|
|
559
|
-
],
|
|
560
|
-
error: `${
|
|
561
|
-
warning: `${
|
|
562
|
-
info: `${
|
|
563
|
-
debug: `${
|
|
564
|
-
},
|
|
559
|
+
], Ot = "padding:2px 5px;", kt = {
|
|
560
|
+
error: `${Ot};background:#db252520;`,
|
|
561
|
+
warning: `${Ot};background:#e1941e20;`,
|
|
562
|
+
info: `${Ot};background:#1e74e120;`,
|
|
563
|
+
debug: `${Ot};background:#00000020;`
|
|
564
|
+
}, At = {
|
|
565
565
|
error: "color:#ff3737;",
|
|
566
566
|
warning: "color:#ffc107;",
|
|
567
567
|
info: "color:#34a8ff;",
|
|
568
568
|
debug: "color:#cccccc;"
|
|
569
|
-
},
|
|
569
|
+
}, jt = class extends Error {
|
|
570
570
|
constructor() {
|
|
571
571
|
super("Request timeout"), this.name = "TimeoutError";
|
|
572
572
|
}
|
|
573
|
-
},
|
|
573
|
+
}, Mt = class extends Error {
|
|
574
574
|
constructor() {
|
|
575
575
|
super("Request aborted"), this.name = "AbortError";
|
|
576
576
|
}
|
|
577
|
-
},
|
|
577
|
+
}, Nt = class extends Error {
|
|
578
578
|
constructor() {
|
|
579
579
|
super("Request deleted"), this.name = "DeletedError";
|
|
580
580
|
}
|
|
581
|
-
},
|
|
581
|
+
}, Pt = class extends Error {
|
|
582
582
|
description;
|
|
583
583
|
constructor(e) {
|
|
584
584
|
super("Request processing error"), this.description = e, this.name = "RequestProcessingError";
|
|
585
585
|
}
|
|
586
|
-
},
|
|
586
|
+
}, Ft = class extends Error {
|
|
587
587
|
description;
|
|
588
588
|
constructor(e) {
|
|
589
589
|
super("Unexpected error"), this.description = e, this.name = "UnexpectedError";
|
|
590
590
|
}
|
|
591
|
-
},
|
|
591
|
+
}, It = (e) => e === "timeout" ? new jt() : e === "abort" ? new Mt() : e === "deleted" ? new Nt() : e === "processing" ? new Pt() : new Ft(), Lt = (e) => {
|
|
592
592
|
try {
|
|
593
593
|
return JSON.stringify(e);
|
|
594
594
|
} catch {
|
|
595
595
|
return "";
|
|
596
596
|
}
|
|
597
|
-
},
|
|
597
|
+
}, Rt = (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
|
+
}, zt = (e) => Be() && e instanceof FormData ? e : Lt(e), Bt = [
|
|
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 Vt(e) {
|
|
610
610
|
let t = {
|
|
611
611
|
onBeforeSent: [],
|
|
612
612
|
onRequestStart: [],
|
|
@@ -616,7 +616,7 @@ function Bt(e) {
|
|
|
616
616
|
onResponse: [],
|
|
617
617
|
onRemove: []
|
|
618
618
|
};
|
|
619
|
-
e &&
|
|
619
|
+
e && Bt.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 Bt(e) {
|
|
|
638
638
|
},
|
|
639
639
|
__snapshot() {
|
|
640
640
|
let e = {};
|
|
641
|
-
return
|
|
641
|
+
return Bt.forEach((n) => {
|
|
642
642
|
e[n] = [...t[n]];
|
|
643
643
|
}), e;
|
|
644
644
|
}
|
|
645
645
|
};
|
|
646
646
|
}
|
|
647
|
-
var
|
|
647
|
+
var Ht = /* @__PURE__ */ function(e) {
|
|
648
648
|
return e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.PATCH = "PATCH", e.DELETE = "DELETE", e;
|
|
649
|
-
}({}),
|
|
649
|
+
}({}), U = (e, t) => t ? `${t}__${e}` : e, Ut = (e) => {
|
|
650
650
|
try {
|
|
651
651
|
if (typeof e == "string") return e;
|
|
652
652
|
if (e == null) return "";
|
|
@@ -656,13 +656,13 @@ var Vt = /* @__PURE__ */ function(e) {
|
|
|
656
656
|
} catch {
|
|
657
657
|
return "";
|
|
658
658
|
}
|
|
659
|
-
},
|
|
659
|
+
}, Wt = ({ loaded: e, total: t }) => !e || !t ? 0 : Number((e * 100 / t).toFixed(0)), Gt = (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
|
+
}, Kt = (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 Vt = /* @__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 } = Gt(e, t, n);
|
|
676
676
|
return {
|
|
677
|
-
progress:
|
|
677
|
+
progress: Wt(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
|
+
}, qt = (e) => `${e.method}_${e.requestOptions.endpoint}_${e.cancelable}`, Jt = (e, t) => `${Ut(e.method)}_${t ? e.requestOptions.endpoint : Ut(e.endpoint)}_${t ? "" : Ut(e.queryParams)}`, Yt = (e, t = "auto") => {
|
|
685
|
+
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method === Ht.GET, a = t === "auto" && i || t === "fetch";
|
|
686
686
|
return [a ? n : r, a];
|
|
687
|
-
},
|
|
687
|
+
}, Xt = 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
|
+
}, Zt = async (e, t) => {
|
|
691
|
+
let { client: n } = e, { requestManager: r } = n, [i] = Yt(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 Vt = /* @__PURE__ */ function(e) {
|
|
|
764
764
|
data: null,
|
|
765
765
|
status: null,
|
|
766
766
|
success: !1,
|
|
767
|
-
error:
|
|
767
|
+
error: It("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 Vt = /* @__PURE__ */ function(e) {
|
|
|
775
775
|
u(), d(), f(), p(), m(), h();
|
|
776
776
|
}
|
|
777
777
|
});
|
|
778
|
-
},
|
|
778
|
+
}, Qt = /* @__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
|
+
}({}), $t = class e {
|
|
781
781
|
endpoint;
|
|
782
782
|
headers;
|
|
783
783
|
auth;
|
|
@@ -801,7 +801,7 @@ var Vt = /* @__PURE__ */ function(e) {
|
|
|
801
801
|
deduplicate;
|
|
802
802
|
deduplicateTime;
|
|
803
803
|
scope;
|
|
804
|
-
$hooks =
|
|
804
|
+
$hooks = Vt();
|
|
805
805
|
isMockerEnabled = !1;
|
|
806
806
|
unstable_mock;
|
|
807
807
|
unstable_payloadMapper;
|
|
@@ -818,7 +818,7 @@ var Vt = /* @__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 = Qt.MIN * 5, cache: f = !0, staleTime: p = Qt.MIN * 5, queued: m = !1, offline: h = !0, abortKey: g, cacheKey: _, queryKey: v, deduplicate: y = !1, deduplicateTime: b = null } = {
|
|
822
822
|
...this.client.adapter.unstable_getRequestDefaults?.(t),
|
|
823
823
|
...t
|
|
824
824
|
};
|
|
@@ -928,11 +928,11 @@ var Vt = /* @__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 = Vt(this.$hooks.__snapshot()), r;
|
|
932
932
|
}
|
|
933
933
|
abort = () => {
|
|
934
934
|
let { requestManager: e } = this.client;
|
|
935
|
-
return e.abortByKey(
|
|
935
|
+
return e.abortByKey(U(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 Vt = /* @__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(U(this.cacheKey, this.scope));
|
|
951
951
|
if (r) return {
|
|
952
952
|
override: n,
|
|
953
953
|
cacheTime: this.cacheTime,
|
|
@@ -969,7 +969,7 @@ var Vt = /* @__PURE__ */ function(e) {
|
|
|
969
969
|
};
|
|
970
970
|
};
|
|
971
971
|
read() {
|
|
972
|
-
let e = this.client.cache.get(
|
|
972
|
+
let e = this.client.cache.get(U(this.cacheKey, this.scope));
|
|
973
973
|
if (e) return {
|
|
974
974
|
data: e.data,
|
|
975
975
|
error: e.error,
|
|
@@ -981,7 +981,7 @@ var Vt = /* @__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 = U(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 Vt = /* @__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 Zt(i, a);
|
|
995
995
|
let o = i.read();
|
|
996
|
-
if (n === "cache-first") return o ?
|
|
996
|
+
if (n === "cache-first") return o ? Xt(i, o) : Zt(i, a);
|
|
997
997
|
if (o) {
|
|
998
|
-
let e = await
|
|
999
|
-
return
|
|
998
|
+
let e = await Xt(i, o);
|
|
999
|
+
return Zt(i, a), e;
|
|
1000
1000
|
}
|
|
1001
|
-
return
|
|
1001
|
+
return Zt(i, a);
|
|
1002
1002
|
};
|
|
1003
1003
|
static fromJSON = (t, n) => new e(t, n.requestOptions, n);
|
|
1004
|
-
},
|
|
1004
|
+
}, en = 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 Vt = /* @__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 = U(_, 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 Vt = /* @__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 = Kt(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 = Kt(new Date(e), new Date(n), r);
|
|
1031
1031
|
h !== 100 && (h = i.total, a.events.emitDownloadProgress({
|
|
1032
1032
|
...i,
|
|
1033
1033
|
requestId: t,
|
|
@@ -1066,14 +1066,14 @@ var Vt = /* @__PURE__ */ function(e) {
|
|
|
1066
1066
|
total: f,
|
|
1067
1067
|
loaded: e.loaded || 0
|
|
1068
1068
|
}), t;
|
|
1069
|
-
},
|
|
1069
|
+
}, A = () => {
|
|
1070
1070
|
l ||= +/* @__PURE__ */ new Date();
|
|
1071
1071
|
let e = +/* @__PURE__ */ new Date();
|
|
1072
1072
|
return T(l, e, {
|
|
1073
1073
|
total: f,
|
|
1074
1074
|
loaded: f
|
|
1075
1075
|
}), e;
|
|
1076
|
-
},
|
|
1076
|
+
}, j = (e) => {
|
|
1077
1077
|
u = +/* @__PURE__ */ new Date(), p = w(p, e);
|
|
1078
1078
|
let n = {
|
|
1079
1079
|
total: p,
|
|
@@ -1083,7 +1083,7 @@ var Vt = /* @__PURE__ */ function(e) {
|
|
|
1083
1083
|
requestId: t,
|
|
1084
1084
|
request: d
|
|
1085
1085
|
}), u;
|
|
1086
|
-
},
|
|
1086
|
+
}, ee = (e) => {
|
|
1087
1087
|
u ||= +/* @__PURE__ */ new Date();
|
|
1088
1088
|
let t = +/* @__PURE__ */ new Date();
|
|
1089
1089
|
return p = w(p, e), E(u, t, {
|
|
@@ -1122,7 +1122,7 @@ var Vt = /* @__PURE__ */ function(e) {
|
|
|
1122
1122
|
response: o
|
|
1123
1123
|
}
|
|
1124
1124
|
}), o;
|
|
1125
|
-
}, N =
|
|
1125
|
+
}, N = tn({
|
|
1126
1126
|
request: d,
|
|
1127
1127
|
requestId: t,
|
|
1128
1128
|
startTime: x,
|
|
@@ -1136,7 +1136,7 @@ var Vt = /* @__PURE__ */ function(e) {
|
|
|
1136
1136
|
requestId: t
|
|
1137
1137
|
}
|
|
1138
1138
|
}), N({
|
|
1139
|
-
error: i(
|
|
1139
|
+
error: i(It("abort")),
|
|
1140
1140
|
status: e,
|
|
1141
1141
|
extra: n
|
|
1142
1142
|
})), F = ({ status: e, extra: n }) => (c.error({
|
|
@@ -1147,7 +1147,7 @@ var Vt = /* @__PURE__ */ function(e) {
|
|
|
1147
1147
|
requestId: t
|
|
1148
1148
|
}
|
|
1149
1149
|
}), N({
|
|
1150
|
-
error:
|
|
1150
|
+
error: It("timeout"),
|
|
1151
1151
|
status: e,
|
|
1152
1152
|
extra: n
|
|
1153
1153
|
})), ne = ({ status: e, extra: n }) => (c.error({
|
|
@@ -1158,12 +1158,12 @@ var Vt = /* @__PURE__ */ function(e) {
|
|
|
1158
1158
|
requestId: t
|
|
1159
1159
|
}
|
|
1160
1160
|
}), N({
|
|
1161
|
-
error:
|
|
1161
|
+
error: It(),
|
|
1162
1162
|
status: e,
|
|
1163
1163
|
extra: n
|
|
1164
1164
|
})), I = () => a.getAbortController(v, t), re = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1165
1165
|
let i = I();
|
|
1166
|
-
if (!i) throw new
|
|
1166
|
+
if (!i) throw new Pt("Controller is not found");
|
|
1167
1167
|
let o = () => {
|
|
1168
1168
|
P({
|
|
1169
1169
|
status: e,
|
|
@@ -1203,9 +1203,9 @@ var Vt = /* @__PURE__ */ function(e) {
|
|
|
1203
1203
|
onBeforeRequest: D,
|
|
1204
1204
|
onRequestStart: O,
|
|
1205
1205
|
onRequestProgress: k,
|
|
1206
|
-
onRequestEnd:
|
|
1207
|
-
onResponseStart:
|
|
1208
|
-
onResponseProgress:
|
|
1206
|
+
onRequestEnd: A,
|
|
1207
|
+
onResponseStart: j,
|
|
1208
|
+
onResponseProgress: ee,
|
|
1209
1209
|
onResponseEnd: M,
|
|
1210
1210
|
onSuccess: te,
|
|
1211
1211
|
onAbortError: P,
|
|
@@ -1214,7 +1214,7 @@ var Vt = /* @__PURE__ */ function(e) {
|
|
|
1214
1214
|
onError: N
|
|
1215
1215
|
};
|
|
1216
1216
|
};
|
|
1217
|
-
function
|
|
1217
|
+
function tn({ 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,8 +1243,8 @@ function en({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
|
1243
1243
|
}), l;
|
|
1244
1244
|
};
|
|
1245
1245
|
}
|
|
1246
|
-
var
|
|
1247
|
-
if (!e.unstable_mock) throw new
|
|
1246
|
+
var nn = 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
|
+
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,
|
|
1250
1250
|
requestId: t
|
|
@@ -1288,7 +1288,7 @@ var tn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1288
1288
|
status: C,
|
|
1289
1289
|
extra: T
|
|
1290
1290
|
}), h || r();
|
|
1291
|
-
},
|
|
1291
|
+
}, rn = (e) => e, an = class {
|
|
1292
1292
|
unstable_fetcher;
|
|
1293
1293
|
name;
|
|
1294
1294
|
defaultMethod;
|
|
@@ -1310,10 +1310,10 @@ var tn = 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 = Rt;
|
|
1314
|
+
unstable_payloadMapper = zt;
|
|
1315
|
+
unstable_endpointMapper = rn;
|
|
1316
|
+
unstable_queryParamsMapper = rn;
|
|
1317
1317
|
unstable_getAdapterDefaults;
|
|
1318
1318
|
unstable_getRequestDefaults;
|
|
1319
1319
|
unstable_devtoolsEndpointGetter = (e) => e;
|
|
@@ -1337,14 +1337,14 @@ var tn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1337
1337
|
async fetch(e, t) {
|
|
1338
1338
|
let n, r = async (r) => {
|
|
1339
1339
|
try {
|
|
1340
|
-
if (!this.initialized) throw new
|
|
1341
|
-
if (!this.unstable_fetcher) throw new
|
|
1340
|
+
if (!this.initialized) throw new Pt(`Adapter ${this.options.name} is not initialized`);
|
|
1341
|
+
if (!this.unstable_fetcher) throw new Pt(`Fetcher for ${this.options.name} adapter is not set`);
|
|
1342
1342
|
this.client.triggerPlugins("onAdapterFetch", {
|
|
1343
1343
|
adapter: this,
|
|
1344
1344
|
request: e,
|
|
1345
1345
|
requestId: t
|
|
1346
1346
|
});
|
|
1347
|
-
let i = await
|
|
1347
|
+
let i = await en({
|
|
1348
1348
|
request: e,
|
|
1349
1349
|
requestId: t,
|
|
1350
1350
|
resolve: r,
|
|
@@ -1353,9 +1353,9 @@ var tn = 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 nn(i) : this.unstable_fetcher(i);
|
|
1357
1357
|
} catch (i) {
|
|
1358
|
-
return
|
|
1358
|
+
return tn({
|
|
1359
1359
|
request: e,
|
|
1360
1360
|
requestId: t,
|
|
1361
1361
|
startTime: n || Date.now(),
|
|
@@ -1372,66 +1372,66 @@ var tn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1372
1372
|
r(e);
|
|
1373
1373
|
});
|
|
1374
1374
|
}
|
|
1375
|
-
},
|
|
1375
|
+
}, on = (e) => {
|
|
1376
1376
|
try {
|
|
1377
1377
|
return JSON.parse(e);
|
|
1378
1378
|
} catch {
|
|
1379
1379
|
return e;
|
|
1380
1380
|
}
|
|
1381
|
-
},
|
|
1381
|
+
}, sn = (e) => e ? on(e) : It(), cn = (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
|
+
}, W = (e, { encode: t, strict: n }) => t && n ? encodeURIComponent(e).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`) : t ? encodeURIComponent(e) : e, ln = (e, t, n) => {
|
|
1385
|
+
let r = !cn(n)(t);
|
|
1386
|
+
return !e || r ? "" : `${W(e, n)}=${W(t instanceof Date ? n.dateParser?.(t) || t.toISOString() : typeof t == "object" && !Array.isArray(t) ? n.objectParser?.(t) || JSON.stringify(t) : String(t), n)}`;
|
|
1387
|
+
}, un = (e, t, n) => {
|
|
1388
1388
|
let { arrayFormat: r, arraySeparator: i } = n;
|
|
1389
|
-
return t.filter(
|
|
1389
|
+
return t.filter(cn(n)).reduce((t, a, o) => {
|
|
1390
1390
|
switch (r) {
|
|
1391
1391
|
case "index": {
|
|
1392
|
-
let r = `${
|
|
1393
|
-
t.push(`${r}${
|
|
1392
|
+
let r = `${W(e, n)}[${W(String(o), n)}]=`;
|
|
1393
|
+
t.push(`${r}${W(String(a), n)}`);
|
|
1394
1394
|
break;
|
|
1395
1395
|
}
|
|
1396
1396
|
case "bracket": {
|
|
1397
|
-
let r = `${
|
|
1398
|
-
t.push(`${r}${
|
|
1397
|
+
let r = `${W(e, n)}[]=`;
|
|
1398
|
+
t.push(`${r}${W(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 && `${W(e, n)}=` || "";
|
|
1403
|
+
return [[...t, `${r}${W(String(a), n)}`].join(",")];
|
|
1404
1404
|
}
|
|
1405
1405
|
case "separator": {
|
|
1406
|
-
let r = !t.length && `${
|
|
1407
|
-
return [[...t, `${r}${
|
|
1406
|
+
let r = !t.length && `${W(e, n)}=` || "";
|
|
1407
|
+
return [[...t, `${r}${W(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 && `${W(e, n)}[]=` || "";
|
|
1411
|
+
return [[...t, `${r}${W(String(a), n)}`].join(i || "|")];
|
|
1412
1412
|
}
|
|
1413
1413
|
default: {
|
|
1414
|
-
let r = `${
|
|
1415
|
-
t.push(`${r}${
|
|
1414
|
+
let r = `${W(e, n)}=`;
|
|
1415
|
+
t.push(`${r}${W(String(a), n)}`);
|
|
1416
1416
|
}
|
|
1417
1417
|
}
|
|
1418
1418
|
return t;
|
|
1419
1419
|
}, []).join("&");
|
|
1420
|
-
},
|
|
1420
|
+
}, dn = (e, t = Bn) => {
|
|
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) ? un(e, n, t) : ln(e, n, t)).filter(Boolean).join("&");
|
|
1424
1424
|
return n ? `?${n}` : "";
|
|
1425
|
-
},
|
|
1425
|
+
}, fn = Qt.SEC * 5, pn = { headers: {} }, mn = () => new an({
|
|
1426
1426
|
name: "http",
|
|
1427
|
-
defaultMethod:
|
|
1428
|
-
defaultExtra:
|
|
1427
|
+
defaultMethod: Ht.GET,
|
|
1428
|
+
defaultExtra: pn,
|
|
1429
1429
|
systemErrorStatus: 0,
|
|
1430
|
-
systemErrorExtra:
|
|
1431
|
-
}).setQueryParamsMapper(
|
|
1432
|
-
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ?
|
|
1430
|
+
systemErrorExtra: pn
|
|
1431
|
+
}).setQueryParamsMapper(dn).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 ? dn(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = fn, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
|
|
1433
1433
|
status: 0,
|
|
1434
|
-
extra:
|
|
1434
|
+
extra: pn
|
|
1435
1435
|
});
|
|
1436
1436
|
C > 0 && S && (D = setTimeout(() => {
|
|
1437
1437
|
E = !0, O(), S.abort();
|
|
@@ -1463,7 +1463,7 @@ var tn = 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: sn(await t.text()),
|
|
1467
1467
|
status: l,
|
|
1468
1468
|
extra: c
|
|
1469
1469
|
});
|
|
@@ -1484,11 +1484,11 @@ var tn = 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: on(e),
|
|
1488
1488
|
status: l,
|
|
1489
1489
|
extra: c
|
|
1490
1490
|
}) : i({
|
|
1491
|
-
error:
|
|
1491
|
+
error: sn(e),
|
|
1492
1492
|
status: l,
|
|
1493
1493
|
extra: c
|
|
1494
1494
|
});
|
|
@@ -1497,17 +1497,17 @@ var tn = 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: pn
|
|
1501
1501
|
});
|
|
1502
1502
|
return;
|
|
1503
1503
|
}
|
|
1504
1504
|
i({
|
|
1505
1505
|
error: e,
|
|
1506
1506
|
status: 0,
|
|
1507
|
-
extra:
|
|
1507
|
+
extra: pn
|
|
1508
1508
|
});
|
|
1509
1509
|
}
|
|
1510
|
-
}),
|
|
1510
|
+
}), hn = () => mn(), gn = class {
|
|
1511
1511
|
emitter = new Re();
|
|
1512
1512
|
events;
|
|
1513
1513
|
storage;
|
|
@@ -1519,7 +1519,7 @@ var tn = 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 = wn(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 tn = 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 = U(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u = _n(c, l), d = {
|
|
1537
1537
|
...u,
|
|
1538
1538
|
scope: o,
|
|
1539
1539
|
staleTime: i,
|
|
@@ -1579,7 +1579,7 @@ var tn = 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 = U(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 tn = 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 $t ? n(U(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 tn = 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
|
+
}, _n = (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
|
+
}, vn = () => "invalidate", yn = (e) => `${e}_invalidate`, bn = () => "delete", xn = (e) => `${e}_delete`, Sn = (e) => `${e}_cache`, Cn = () => "cache", wn = (e) => ({
|
|
1682
1682
|
emitCacheData: (t, n = !1) => {
|
|
1683
|
-
e.emit(
|
|
1683
|
+
e.emit(Cn(), t, n), e.emit(Sn(t.cacheKey), t, n);
|
|
1684
1684
|
},
|
|
1685
1685
|
emitInvalidation: (t, n = !1) => {
|
|
1686
|
-
e.emit(
|
|
1686
|
+
e.emit(vn(), t, n), e.emit(yn(t), n);
|
|
1687
1687
|
},
|
|
1688
1688
|
emitDelete: (t, n = !1) => {
|
|
1689
|
-
e.emit(
|
|
1689
|
+
e.emit(bn(), t, n), e.emit(xn(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(Cn(), t), () => e.removeListener(Cn(), t)),
|
|
1692
|
+
onDataByKey: (t, n) => (e.on(Sn(t), n), () => e.removeListener(Sn(t), n)),
|
|
1693
|
+
onInvalidate: (t) => (e.on(vn(), t), () => e.removeListener(vn(), t)),
|
|
1694
|
+
onInvalidateByKey: (t, n) => (e.on(yn(t), n), () => e.removeListener(yn(t), n)),
|
|
1695
|
+
onDelete: (t) => (e.on(bn(), t), () => e.removeListener(bn(), t)),
|
|
1696
|
+
onDeleteByKey: (t, n) => (e.on(xn(t), n), () => e.removeListener(xn(t), n))
|
|
1697
|
+
}), G = /* @__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
|
+
}({}), Tn = (e) => ({
|
|
1700
1700
|
emitDrained: (t, n) => {
|
|
1701
|
-
e.emit(
|
|
1701
|
+
e.emit(Dn(), t, n), e.emit(On(t.queryKey), t, n);
|
|
1702
1702
|
},
|
|
1703
1703
|
emitQueueStatusChanged: (t, n) => {
|
|
1704
|
-
e.emit(
|
|
1704
|
+
e.emit(kn(), t, n), e.emit(An(t.queryKey), t, n);
|
|
1705
1705
|
},
|
|
1706
1706
|
emitQueueChanged: (t, n) => {
|
|
1707
|
-
e.emit(
|
|
1707
|
+
e.emit(jn(), t, n), e.emit(Mn(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(Dn(), t), () => e.removeListener(Dn(), t)),
|
|
1710
|
+
onDrainedByKey: (t, n) => (e.on(On(t), n), () => e.removeListener(On(t), n)),
|
|
1711
|
+
onQueueStatusChange: (t) => (e.on(kn(), t), () => e.removeListener(kn(), t)),
|
|
1712
|
+
onQueueStatusChangeByKey: (t, n) => (e.on(An(t), n), () => e.removeListener(An(t), n)),
|
|
1713
|
+
onQueueChange: (t) => (e.on(jn(), t), () => e.removeListener(jn(), t)),
|
|
1714
|
+
onQueueChangeByKey: (t, n) => (e.on(Mn(t), n), () => e.removeListener(Mn(t), n))
|
|
1715
|
+
}), En = class {
|
|
1716
1716
|
emitter = new Re();
|
|
1717
|
-
events =
|
|
1717
|
+
events = Tn(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 tn = 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 $t);
|
|
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 tn = 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 = U(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 = U(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 tn = 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 = U(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = Fn(e, i);
|
|
1886
1886
|
switch (this.logger.debug({
|
|
1887
1887
|
title: "Adding request to queue",
|
|
1888
1888
|
type: "system",
|
|
@@ -1892,9 +1892,9 @@ var tn = 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 G.ONE_BY_ONE: return this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1896
|
+
case G.PREVIOUS_CANCELED: return this.cancelRunningRequests(t), this.clearQueue(t), this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1897
|
+
case G.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 tn = 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 = U(a, c), u = U(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h = Nn(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 tn = 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 = It("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 tn = 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
|
+
}, Dn = () => "drained-event", On = (e) => `${e}-drained-event`, kn = () => "status-event", An = (e) => `${e}-status-event`, jn = () => "change-event", Mn = (e) => `${e}-change-event`, Nn = (e, t) => !!(t && e < t), Pn = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, Fn = (e, t) => {
|
|
2074
|
+
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? Pn(e, t) : !1;
|
|
2075
|
+
return n ? G.ONE_BY_ONE : r ? G.PREVIOUS_CANCELED : a && i ? G.DEDUPLICATED : G.ALL_AT_ONCE;
|
|
2076
2076
|
};
|
|
2077
|
-
function
|
|
2077
|
+
function In(e) {
|
|
2078
2078
|
return e === "client" || e === "server" ? e : typeof window < "u" && typeof document < "u" ? "client" : "server";
|
|
2079
2079
|
}
|
|
2080
|
-
var
|
|
2080
|
+
var Ln = 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
|
+
}, Rn = 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
|
+
}, zn = class {
|
|
2093
2093
|
url;
|
|
2094
2094
|
mode;
|
|
2095
2095
|
debug;
|
|
@@ -2098,8 +2098,8 @@ var In = async (e, t) => {
|
|
|
2098
2098
|
unstable_onResponseCallbacks = [];
|
|
2099
2099
|
unstable_onAuthCallbacks = [];
|
|
2100
2100
|
unstable_onRequestCallbacks = [];
|
|
2101
|
-
loggerManager = new
|
|
2102
|
-
requestManager = new
|
|
2101
|
+
loggerManager = new Ct();
|
|
2102
|
+
requestManager = new Ke();
|
|
2103
2103
|
appManager;
|
|
2104
2104
|
adapter;
|
|
2105
2105
|
cache;
|
|
@@ -2107,15 +2107,15 @@ var In = 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 = qt;
|
|
2111
|
+
unstable_cacheKeyMapper = Jt;
|
|
2112
|
+
unstable_queryKeyMapper = Jt;
|
|
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 = In(o), this.adapter = hn(), this.appManager = n?.() || new ze(), this.cache = r?.() || new gn(), this.fetchDispatcher = i?.() || new En(), this.submitDispatcher = a?.() || new En(), 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 In = 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) => Ln(this.unstable_onAuthCallbacks, e);
|
|
2148
|
+
unstable_modifyRequest = async (e) => Ln(this.unstable_onRequestCallbacks, e);
|
|
2149
|
+
unstable_modifyErrorResponse = async (e, t) => Rn(this.unstable_onErrorCallbacks, e, t);
|
|
2150
|
+
unstable_modifySuccessResponse = async (e, t) => Rn(this.unstable_onSuccessCallbacks, e, t);
|
|
2151
|
+
unstable_modifyResponse = async (e, t) => Rn(this.unstable_onResponseCallbacks, e, t);
|
|
2152
|
+
fromJSON = (e) => $t.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 gn(), this.appManager = e?.() || new ze(), this.fetchDispatcher = n?.() || new En(), this.submitDispatcher = r?.() || new En(), 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 In = 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(U(n, r))) return;
|
|
2173
|
+
let c = on(i);
|
|
2174
2174
|
this.cache.set({
|
|
2175
2175
|
...s,
|
|
2176
2176
|
cacheKey: n,
|
|
@@ -2182,10 +2182,10 @@ var In = 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 $t(this, n);
|
|
2186
2186
|
return this.plugins.forEach((e) => e.trigger("onRequestCreate", { request: r })), r;
|
|
2187
2187
|
};
|
|
2188
|
-
},
|
|
2188
|
+
}, Bn = {
|
|
2189
2189
|
strict: !0,
|
|
2190
2190
|
encode: !0,
|
|
2191
2191
|
arrayFormat: "bracket",
|
|
@@ -2194,101 +2194,101 @@ var In = async (e, t) => {
|
|
|
2194
2194
|
skipNull: !0,
|
|
2195
2195
|
skipEmptyString: !0
|
|
2196
2196
|
};
|
|
2197
|
-
function
|
|
2198
|
-
return new
|
|
2197
|
+
function Vn(e) {
|
|
2198
|
+
return new zn(e);
|
|
2199
2199
|
}
|
|
2200
2200
|
//#endregion
|
|
2201
2201
|
//#region src/core/client.ts
|
|
2202
|
-
var
|
|
2202
|
+
var K = Vn({ url: L() });
|
|
2203
2203
|
//#endregion
|
|
2204
2204
|
//#region src/core/auth-api.ts
|
|
2205
|
-
async function
|
|
2206
|
-
let { data: t, success: n } = await
|
|
2205
|
+
async function Hn(e) {
|
|
2206
|
+
let { data: t, success: n } = await K.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 Un(e) {
|
|
2213
|
+
await K.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 Wn = 1, Gn = "hype-stack", Kn = "auth.json";
|
|
2221
|
+
function qn() {
|
|
2222
2222
|
let e = process.env.HYPE_STACK_CONFIG_DIR;
|
|
2223
|
-
if (e) return T.join(e,
|
|
2223
|
+
if (e) return T.join(e, Gn);
|
|
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, Gn);
|
|
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", Gn);
|
|
2230
2230
|
let n = process.env.XDG_CONFIG_HOME ?? T.join(t, ".config");
|
|
2231
|
-
return T.join(n,
|
|
2231
|
+
return T.join(n, Gn);
|
|
2232
2232
|
}
|
|
2233
|
-
function
|
|
2234
|
-
return T.join(
|
|
2233
|
+
function Jn() {
|
|
2234
|
+
return T.join(qn(), Kn);
|
|
2235
2235
|
}
|
|
2236
|
-
async function
|
|
2237
|
-
let e = await y.readFile(
|
|
2236
|
+
async function Yn() {
|
|
2237
|
+
let e = await y.readFile(Jn(), "utf-8").catch(() => null);
|
|
2238
2238
|
if (!e) return {
|
|
2239
|
-
version:
|
|
2239
|
+
version: Wn,
|
|
2240
2240
|
tokens: {}
|
|
2241
2241
|
};
|
|
2242
2242
|
let t = JSON.parse(e);
|
|
2243
2243
|
return {
|
|
2244
|
-
version: t.version ??
|
|
2244
|
+
version: t.version ?? Wn,
|
|
2245
2245
|
tokens: t.tokens ?? {}
|
|
2246
2246
|
};
|
|
2247
2247
|
}
|
|
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
|
-
}
|
|
2252
2248
|
async function Xn(e) {
|
|
2253
|
-
|
|
2249
|
+
let t = qn();
|
|
2250
|
+
await y.mkdir(t, { recursive: !0 }), await y.writeFile(Jn(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2251
|
+
}
|
|
2252
|
+
async function Zn(e) {
|
|
2253
|
+
return (await Yn()).tokens[e] ?? null;
|
|
2254
2254
|
}
|
|
2255
|
-
async function
|
|
2256
|
-
let n = await
|
|
2257
|
-
n.tokens[e] = t, await
|
|
2255
|
+
async function Qn(e, t) {
|
|
2256
|
+
let n = await Yn();
|
|
2257
|
+
n.tokens[e] = t, await Xn(n);
|
|
2258
2258
|
}
|
|
2259
|
-
async function
|
|
2260
|
-
let t = await
|
|
2261
|
-
e in t.tokens && (delete t.tokens[e], await
|
|
2259
|
+
async function $n(e) {
|
|
2260
|
+
let t = await Yn();
|
|
2261
|
+
e in t.tokens && (delete t.tokens[e], await Xn(t));
|
|
2262
2262
|
}
|
|
2263
2263
|
//#endregion
|
|
2264
2264
|
//#region src/core/device.ts
|
|
2265
|
-
function
|
|
2265
|
+
function er() {
|
|
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 tr() {
|
|
2273
|
+
let e = `${er()}:${w.hostname()}:${w.platform()}:${w.arch()}`;
|
|
2274
2274
|
return x("sha256").update(e).digest("hex").slice(0, 16);
|
|
2275
2275
|
}
|
|
2276
|
-
function
|
|
2277
|
-
return `hype-stack/${
|
|
2276
|
+
function nr() {
|
|
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 rr(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
|
|
2286
|
+
var ir = 300 * 1e3, ar = (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 or(e = {}) {
|
|
2288
2288
|
let t = S(16).toString("hex"), n = L(), 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
|
+
}, ir);
|
|
2292
2292
|
function o() {
|
|
2293
2293
|
clearTimeout(a), r.close(), r.closeAllConnections?.();
|
|
2294
2294
|
}
|
|
@@ -2302,7 +2302,7 @@ async function ar(e = {}) {
|
|
|
2302
2302
|
r.writeHead(200, {
|
|
2303
2303
|
"Content-Type": "text/html",
|
|
2304
2304
|
Connection: "close"
|
|
2305
|
-
}), r.end(
|
|
2305
|
+
}), r.end(ar(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 ar(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(nr()), a = `${se()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
|
|
2321
|
+
e.onUrl?.(a), rr(a);
|
|
2322
2322
|
});
|
|
2323
|
-
}), a = await
|
|
2323
|
+
}), a = await Hn(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 Qn(n, o), o;
|
|
2329
2329
|
}
|
|
2330
2330
|
//#endregion
|
|
2331
2331
|
//#region src/core/access-prompts.ts
|
|
2332
|
-
async function
|
|
2332
|
+
async function sr() {
|
|
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 or({ 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 or() {
|
|
|
2342
2342
|
return s.log.error(e instanceof Error ? e.message : String(e)), null;
|
|
2343
2343
|
}
|
|
2344
2344
|
}
|
|
2345
|
-
async function
|
|
2345
|
+
async function cr(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 sr(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) rr(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 sr(e) {
|
|
|
2363
2363
|
}
|
|
2364
2364
|
//#endregion
|
|
2365
2365
|
//#region src/utils/exec.ts
|
|
2366
|
-
function
|
|
2366
|
+
function q(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 J(e, t, n) {
|
|
|
2394
2394
|
});
|
|
2395
2395
|
});
|
|
2396
2396
|
}
|
|
2397
|
-
function
|
|
2397
|
+
function lr(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 cr(e, t, n) {
|
|
|
2411
2411
|
}
|
|
2412
2412
|
//#endregion
|
|
2413
2413
|
//#region src/utils/fs.ts
|
|
2414
|
-
async function
|
|
2414
|
+
async function J(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 J(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 = lr, probeCommand: c = q } = 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")})...`));
|
|
@@ -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), J(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 K.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 = K.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": tr(),
|
|
2757
|
+
"X-Client-Info": nr()
|
|
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 = K.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 = K.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 = Yi(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);
|
|
@@ -3075,22 +3075,43 @@ function Mi(e, t) {
|
|
|
3075
3075
|
}
|
|
3076
3076
|
return o === -1 ? e : e.slice(0, o) + n + "\n" + e.slice(o);
|
|
3077
3077
|
}
|
|
3078
|
-
var Ni = "import { type LucideIcon } from \"lucide-react\";\n\n/* -------------------------------------------------------------------------------------------------\n * Types\n * -----------------------------------------------------------------------------------------------*/\n\nexport type NavPermission = {\n action: string;\n subject: string;\n};\n\nexport type NavItem = {\n label: string;\n icon: LucideIcon;\n to: string;\n params?: Record<string, string>;\n permission?: NavPermission;\n};\n\nexport type NavSection = {\n label: string;\n icon: LucideIcon;\n items: NavItem[];\n permission?: NavPermission;\n};\n\nexport type NavSectionLink = NavSection & { to: string; params?: Record<string, string> };\n\nexport type NavEntry = NavSection | NavSectionLink;\n\n/* -------------------------------------------------------------------------------------------------\n * Navigation\n * -----------------------------------------------------------------------------------------------*/\n\nexport const primaryNav: NavEntry[] = [];\n\nexport const secondaryNav: NavEntry[] = [];\n\nexport const tertiaryNav: NavEntry[] = [];\n\nexport const settingsNav: NavEntry[] = [];\n", Pi = {
|
|
3078
|
+
var Ni = "import { type LucideIcon } from \"lucide-react\";\n\n/* -------------------------------------------------------------------------------------------------\n * Types\n * -----------------------------------------------------------------------------------------------*/\n\nexport type NavPermission = {\n action: string;\n subject: string;\n};\n\nexport type NavItem = {\n label: string;\n icon: LucideIcon;\n to: string;\n params?: Record<string, string>;\n permission?: NavPermission;\n adminRole?: string;\n};\n\nexport type NavSection = {\n label: string;\n icon: LucideIcon;\n items: NavItem[];\n permission?: NavPermission;\n adminRole?: string;\n};\n\nexport type NavSectionLink = NavSection & { to: string; params?: Record<string, string> };\n\nexport type NavEntry = NavSection | NavSectionLink;\n\n// Section headers shown above each nav group. Empty by default so every layout\n// falls back to its own built-in label; the admin shell overrides these so its\n// sidebar reads the same across whichever layout it mounts.\nexport type NavGroupLabels = {\n primary?: string;\n secondary?: string;\n tertiary?: string;\n settings?: string;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Navigation\n * -----------------------------------------------------------------------------------------------*/\n\nexport const navGroupLabels: NavGroupLabels = {};\n\nexport const primaryNav: NavEntry[] = [];\n\nexport const secondaryNav: NavEntry[] = [];\n\nexport const tertiaryNav: NavEntry[] = [];\n\nexport const settingsNav: NavEntry[] = [];\n", Pi = {
|
|
3079
|
+
primary: "Analytics",
|
|
3080
|
+
secondary: "Platform",
|
|
3081
|
+
tertiary: "More"
|
|
3082
|
+
};
|
|
3083
|
+
function Fi(e) {
|
|
3084
|
+
let t = [
|
|
3085
|
+
"primary",
|
|
3086
|
+
"secondary",
|
|
3087
|
+
"tertiary",
|
|
3088
|
+
"settings"
|
|
3089
|
+
].filter((t) => typeof e[t] == "string").map((t) => `${t}: ${JSON.stringify(e[t])}`);
|
|
3090
|
+
return t.length > 0 ? `{ ${t.join(", ")} }` : "{}";
|
|
3091
|
+
}
|
|
3092
|
+
var Ii = /export const navGroupLabels: NavGroupLabels = \{[^}]*\};/, Li = "export type NavGroupLabels = {\n primary?: string;\n secondary?: string;\n tertiary?: string;\n settings?: string;\n};";
|
|
3093
|
+
async function Ri(e) {
|
|
3094
|
+
let { labels: t, paths: n, projectRoot: r, slot: i = "frontend", overwrite: a = !1 } = e, o = ni(i, n), s = T.resolve(r, o, "src/constants/nav.constants.ts"), c;
|
|
3095
|
+
await Y(s) ? c = await y.readFile(s, "utf-8") : (await y.mkdir(T.dirname(s), { recursive: !0 }), c = Ni);
|
|
3096
|
+
let l = `export const navGroupLabels: NavGroupLabels = ${Fi(t)};`;
|
|
3097
|
+
Ii.test(c) ? a && (c = c.replace(Ii, l)) : (c.includes("type NavGroupLabels") || (c = c.replace(/export type NavEntry = NavSection \| NavSectionLink;/, (e) => `${e}\n\n${Li}`)), c = `${c.trimEnd()}\n\n${l}\n`), await y.writeFile(s, c, "utf-8");
|
|
3098
|
+
}
|
|
3099
|
+
var zi = {
|
|
3079
3100
|
primary: "primaryNav",
|
|
3080
3101
|
secondary: "secondaryNav",
|
|
3081
3102
|
tertiary: "tertiaryNav",
|
|
3082
3103
|
settings: "settingsNav"
|
|
3083
|
-
},
|
|
3084
|
-
async function
|
|
3104
|
+
}, Bi = new Set(["primary", "secondary"]);
|
|
3105
|
+
async function Vi(e) {
|
|
3085
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;
|
|
3086
3107
|
await Y(s) ? c = await y.readFile(s, "utf-8") : (await y.mkdir(T.dirname(s), { recursive: !0 }), c = Ni);
|
|
3087
|
-
for (let e of t) !a && c.includes(`label: "${e.label}"`) || (c =
|
|
3088
|
-
if (a) for (let e of t) c.includes(`label: "${e.label}"`) && (c =
|
|
3089
|
-
for (let e of t)
|
|
3090
|
-
for (let e of t.toReversed())
|
|
3108
|
+
for (let e of t) !a && c.includes(`label: "${e.label}"`) || (c = Wi(c, e), c = Ki(c, e));
|
|
3109
|
+
if (a) for (let e of t) c.includes(`label: "${e.label}"`) && (c = Xi(c, e));
|
|
3110
|
+
for (let e of t) Bi.has(e.group) && (c.includes(`label: "${e.label}"`) || (c = Ji(c, e, "append")));
|
|
3111
|
+
for (let e of t.toReversed()) Bi.has(e.group) || c.includes(`label: "${e.label}"`) || (c = Ji(c, e, "prepend"));
|
|
3091
3112
|
await y.writeFile(s, c, "utf-8");
|
|
3092
3113
|
}
|
|
3093
|
-
async function
|
|
3114
|
+
async function Hi(e) {
|
|
3094
3115
|
let { postLoginRedirect: 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");
|
|
3095
3116
|
if (!await Y(o)) return;
|
|
3096
3117
|
let s = await y.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
|
|
@@ -3098,17 +3119,17 @@ async function Li(e) {
|
|
|
3098
3119
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
3099
3120
|
await y.writeFile(o, l, "utf-8");
|
|
3100
3121
|
}
|
|
3101
|
-
function
|
|
3122
|
+
function Ui(e) {
|
|
3102
3123
|
let t = [e.icon];
|
|
3103
3124
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
3104
3125
|
return t;
|
|
3105
3126
|
}
|
|
3106
|
-
function
|
|
3107
|
-
let n =
|
|
3108
|
-
for (let e of n) r =
|
|
3127
|
+
function Wi(e, t) {
|
|
3128
|
+
let n = Ui(t), r = e;
|
|
3129
|
+
for (let e of n) r = Gi(r, e);
|
|
3109
3130
|
return r;
|
|
3110
3131
|
}
|
|
3111
|
-
function
|
|
3132
|
+
function Gi(e, t) {
|
|
3112
3133
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
3113
3134
|
if (!n) return e;
|
|
3114
3135
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -3116,43 +3137,43 @@ function Bi(e, t) {
|
|
|
3116
3137
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
3117
3138
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
3118
3139
|
}
|
|
3119
|
-
function
|
|
3140
|
+
function Ki(e, t) {
|
|
3120
3141
|
if (!(t.permission || t.items?.some((e) => e.permission)) || e.includes("@hype-stack/enums\"")) return e;
|
|
3121
3142
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
3122
3143
|
if (!n) return `import { PermissionAction, PermissionSubject } from "@hype-stack/enums";\n\n${e}`;
|
|
3123
3144
|
let r = "import { PermissionAction, PermissionSubject } from \"@hype-stack/enums\";\n", i = e.indexOf("\n", n.index ?? 0);
|
|
3124
3145
|
return i === -1 ? r + e : e.slice(0, i + 1) + r + e.slice(i + 1);
|
|
3125
3146
|
}
|
|
3126
|
-
function
|
|
3147
|
+
function qi(e) {
|
|
3127
3148
|
return `{ action: PermissionAction.${e.action}, subject: PermissionSubject.${e.subject} }`;
|
|
3128
3149
|
}
|
|
3129
|
-
function
|
|
3130
|
-
let r =
|
|
3150
|
+
function Ji(e, t, n) {
|
|
3151
|
+
let r = zi[t.group];
|
|
3131
3152
|
if (!r) return e;
|
|
3132
|
-
let i =
|
|
3153
|
+
let i = Zi(t), a = RegExp(`export const ${r}: NavEntry\\[\\] = \\[`), o = e.match(a);
|
|
3133
3154
|
if (!o) return e;
|
|
3134
|
-
let s = e.indexOf(o[0]) + o[0].length, c =
|
|
3155
|
+
let s = e.indexOf(o[0]) + o[0].length, c = Yi(e, s - 1);
|
|
3135
3156
|
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);
|
|
3136
3157
|
}
|
|
3137
|
-
function
|
|
3158
|
+
function Yi(e, t) {
|
|
3138
3159
|
let n = 0;
|
|
3139
3160
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3140
3161
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3141
3162
|
return -1;
|
|
3142
3163
|
}
|
|
3143
|
-
function
|
|
3164
|
+
function Xi(e, t) {
|
|
3144
3165
|
let n = e.indexOf(`label: "${t.label}"`);
|
|
3145
3166
|
if (n === -1) return e;
|
|
3146
3167
|
let r = e.lastIndexOf("{", n);
|
|
3147
3168
|
if (r === -1) return e;
|
|
3148
3169
|
let i = gi(e, r);
|
|
3149
3170
|
if (i === -1) return e;
|
|
3150
|
-
let a =
|
|
3171
|
+
let a = Zi(t).trimStart().replace(/,\s*$/, "");
|
|
3151
3172
|
return e.slice(0, r) + a + e.slice(i + 1);
|
|
3152
3173
|
}
|
|
3153
|
-
function
|
|
3174
|
+
function Zi(e) {
|
|
3154
3175
|
let t = [];
|
|
3155
|
-
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: ${
|
|
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: ${qi(e.permission)},`), e.adminRole && t.push(` adminRole: "${e.adminRole}",`), e.items && e.items.length > 0) {
|
|
3156
3177
|
t.push(" items: [");
|
|
3157
3178
|
for (let n of e.items) {
|
|
3158
3179
|
let e = [
|
|
@@ -3160,20 +3181,20 @@ function Ki(e) {
|
|
|
3160
3181
|
`icon: ${n.icon}`,
|
|
3161
3182
|
`to: "${n.to}"`
|
|
3162
3183
|
];
|
|
3163
|
-
n.params && e.push(`params: ${n.params}`), n.permission && e.push(`permission: ${
|
|
3184
|
+
n.params && e.push(`params: ${n.params}`), n.permission && e.push(`permission: ${qi(n.permission)}`), n.adminRole && e.push(`adminRole: "${n.adminRole}"`), t.push(` { ${e.join(", ")} },`);
|
|
3164
3185
|
}
|
|
3165
3186
|
t.push(" ],");
|
|
3166
3187
|
} else t.push(" items: [],");
|
|
3167
3188
|
return t.push(" },"), t.join("\n");
|
|
3168
3189
|
}
|
|
3169
|
-
async function
|
|
3190
|
+
async function Qi(e, t, n) {
|
|
3170
3191
|
let r = Z("{{backend.features}}", t), i = T.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
|
|
3171
3192
|
if (!await Y(i)) return;
|
|
3172
3193
|
let a = await y.readFile(i, "utf-8");
|
|
3173
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
3194
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = $i(a, t), a = ea(a, t));
|
|
3174
3195
|
await y.writeFile(i, a, "utf-8");
|
|
3175
3196
|
}
|
|
3176
|
-
function
|
|
3197
|
+
function $i(e, t) {
|
|
3177
3198
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
3178
3199
|
if (r !== -1) {
|
|
3179
3200
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -3181,38 +3202,129 @@ function Ji(e, t) {
|
|
|
3181
3202
|
}
|
|
3182
3203
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
3183
3204
|
}
|
|
3184
|
-
function
|
|
3205
|
+
function ea(e, t) {
|
|
3185
3206
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
3186
3207
|
if (!r) return e;
|
|
3187
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
3208
|
+
let i = e.indexOf(r[0]) + r[0].length, a = ta(e, i - 1);
|
|
3188
3209
|
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);
|
|
3189
3210
|
}
|
|
3190
|
-
function
|
|
3211
|
+
function ta(e, t) {
|
|
3212
|
+
let n = 0;
|
|
3213
|
+
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3214
|
+
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3215
|
+
return -1;
|
|
3216
|
+
}
|
|
3217
|
+
var na = "import type { FC } from \"react\";\n\nexport const dashboardRows: FC[] = [];\n";
|
|
3218
|
+
async function ra(e, t, n) {
|
|
3219
|
+
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 = na);
|
|
3221
|
+
for (let t of e) a = ia(a, t);
|
|
3222
|
+
for (let t of e) t.position !== "prepend" && (a = aa(a, t, "append"));
|
|
3223
|
+
for (let t = e.length - 1; t >= 0; t--) {
|
|
3224
|
+
let n = e[t];
|
|
3225
|
+
n.position === "prepend" && (a = aa(a, n, "prepend"));
|
|
3226
|
+
}
|
|
3227
|
+
await y.writeFile(i, a, "utf-8");
|
|
3228
|
+
}
|
|
3229
|
+
function ia(e, t) {
|
|
3230
|
+
let n = `import { ${t.import} } from "${t.from}";`;
|
|
3231
|
+
if (e.includes(n)) return e;
|
|
3232
|
+
let r = e.lastIndexOf("import ");
|
|
3233
|
+
if (r === -1) return n + "\n" + e;
|
|
3234
|
+
let i = e.indexOf("\n", r);
|
|
3235
|
+
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
3236
|
+
}
|
|
3237
|
+
function aa(e, t, n) {
|
|
3238
|
+
let r = ` ${t.import},`, i = e.match(/export const dashboardRows[^=]*=\s*\[/);
|
|
3239
|
+
if (!i) return e;
|
|
3240
|
+
let a = e.indexOf(i[0]) + i[0].length, o = oa(e, a - 1);
|
|
3241
|
+
if (o === -1) return e;
|
|
3242
|
+
let s = e.slice(a, o);
|
|
3243
|
+
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
|
+
}
|
|
3245
|
+
function oa(e, t) {
|
|
3246
|
+
let n = 0;
|
|
3247
|
+
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3248
|
+
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3249
|
+
return -1;
|
|
3250
|
+
}
|
|
3251
|
+
var sa = "import type { FC } from \"react\";\n\nexport const organizationDetailsRows: FC<{ organizationId: string }>[] = [];\n", ca = "import type { FC } from \"react\";\n\nexport const organizationDetailsCards: FC<{ organizationId: string }>[] = [];\n";
|
|
3252
|
+
async function la({ components: e, paths: t, projectRoot: n, kind: r }) {
|
|
3253
|
+
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" ? sa : ca);
|
|
3255
|
+
let c = r === "rows" ? "organizationDetailsRows" : "organizationDetailsCards";
|
|
3256
|
+
for (let t of e) s = fa(s, t);
|
|
3257
|
+
for (let t of e) t.position !== "prepend" && (s = pa(s, t, {
|
|
3258
|
+
arrayName: c,
|
|
3259
|
+
position: "append"
|
|
3260
|
+
}));
|
|
3261
|
+
for (let t = e.length - 1; t >= 0; t--) {
|
|
3262
|
+
let n = e[t];
|
|
3263
|
+
n.position === "prepend" && (s = pa(s, n, {
|
|
3264
|
+
arrayName: c,
|
|
3265
|
+
position: "prepend"
|
|
3266
|
+
}));
|
|
3267
|
+
}
|
|
3268
|
+
await y.writeFile(o, s, "utf-8");
|
|
3269
|
+
}
|
|
3270
|
+
async function ua(e, t, n) {
|
|
3271
|
+
await la({
|
|
3272
|
+
components: e,
|
|
3273
|
+
paths: t,
|
|
3274
|
+
projectRoot: n,
|
|
3275
|
+
kind: "rows"
|
|
3276
|
+
});
|
|
3277
|
+
}
|
|
3278
|
+
async function da(e, t, n) {
|
|
3279
|
+
await la({
|
|
3280
|
+
components: e,
|
|
3281
|
+
paths: t,
|
|
3282
|
+
projectRoot: n,
|
|
3283
|
+
kind: "cards"
|
|
3284
|
+
});
|
|
3285
|
+
}
|
|
3286
|
+
function fa(e, t) {
|
|
3287
|
+
let n = `import { ${t.import} } from "${t.from}";`;
|
|
3288
|
+
if (e.includes(n)) return e;
|
|
3289
|
+
let r = e.lastIndexOf("import ");
|
|
3290
|
+
if (r === -1) return n + "\n" + e;
|
|
3291
|
+
let i = e.indexOf("\n", r);
|
|
3292
|
+
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
3293
|
+
}
|
|
3294
|
+
function pa(e, t, n) {
|
|
3295
|
+
let { arrayName: r, position: i } = n, a = ` ${t.import},`, o = e.match(RegExp(`export const ${r}[^=]*=\\s*\\[`));
|
|
3296
|
+
if (!o) return e;
|
|
3297
|
+
let s = e.indexOf(o[0]) + o[0].length, c = ma(e, s - 1);
|
|
3298
|
+
if (c === -1) return e;
|
|
3299
|
+
let l = e.slice(s, c);
|
|
3300
|
+
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
|
+
}
|
|
3302
|
+
function ma(e, t) {
|
|
3191
3303
|
let n = 0;
|
|
3192
3304
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3193
3305
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3194
3306
|
return -1;
|
|
3195
3307
|
}
|
|
3196
|
-
var
|
|
3197
|
-
async function
|
|
3198
|
-
await
|
|
3308
|
+
var ha = "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";
|
|
3309
|
+
async function ga(e) {
|
|
3310
|
+
await va({
|
|
3199
3311
|
...e,
|
|
3200
3312
|
arrayName: "navbarActions"
|
|
3201
3313
|
});
|
|
3202
3314
|
}
|
|
3203
|
-
async function
|
|
3204
|
-
await
|
|
3315
|
+
async function _a(e) {
|
|
3316
|
+
await va({
|
|
3205
3317
|
...e,
|
|
3206
3318
|
arrayName: "userMenuActions"
|
|
3207
3319
|
});
|
|
3208
3320
|
}
|
|
3209
|
-
async function
|
|
3321
|
+
async function va({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
|
|
3210
3322
|
let a = ni(i, n), o = T.resolve(r, a, "src/constants/navbar-actions.tsx"), s;
|
|
3211
|
-
await Y(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s =
|
|
3212
|
-
for (let n of e) s =
|
|
3323
|
+
await Y(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = ha);
|
|
3324
|
+
for (let n of e) s = ya(s, n), s = ba(s, n, t);
|
|
3213
3325
|
await y.writeFile(o, s, "utf-8");
|
|
3214
3326
|
}
|
|
3215
|
-
function
|
|
3327
|
+
function ya(e, t) {
|
|
3216
3328
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
3217
3329
|
if (e.includes(n)) return e;
|
|
3218
3330
|
let r = e.lastIndexOf("import ");
|
|
@@ -3220,38 +3332,38 @@ function ta(e, t) {
|
|
|
3220
3332
|
let i = e.indexOf("\n", r);
|
|
3221
3333
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
3222
3334
|
}
|
|
3223
|
-
function
|
|
3335
|
+
function ba(e, t, n) {
|
|
3224
3336
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
3225
3337
|
if (!r) return e;
|
|
3226
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
3338
|
+
let i = e.indexOf(r[0]) + r[0].length, a = xa(e, i - 1);
|
|
3227
3339
|
if (a === -1) return e;
|
|
3228
3340
|
let o = e.slice(i, a);
|
|
3229
3341
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
3230
3342
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
3231
3343
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
3232
3344
|
}
|
|
3233
|
-
function
|
|
3345
|
+
function xa(e, t) {
|
|
3234
3346
|
let n = 0;
|
|
3235
3347
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3236
3348
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3237
3349
|
return -1;
|
|
3238
3350
|
}
|
|
3239
|
-
var
|
|
3351
|
+
var Sa = new Set([
|
|
3240
3352
|
".ts",
|
|
3241
3353
|
".tsx",
|
|
3242
3354
|
".js",
|
|
3243
3355
|
".jsx"
|
|
3244
3356
|
]);
|
|
3245
|
-
async function
|
|
3357
|
+
async function Ca(e) {
|
|
3246
3358
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
3247
3359
|
if (i === "hype-stack") return;
|
|
3248
3360
|
let a = `@${i}/`;
|
|
3249
3361
|
await Promise.all(t.map(async (e) => {
|
|
3250
3362
|
let t = Gr(e.target, n, r), i = await y.stat(t).catch(() => null);
|
|
3251
|
-
i?.isDirectory() ? await
|
|
3363
|
+
i?.isDirectory() ? await Ta(t, a) : i?.isFile() && Sa.has(T.extname(t)) && await Ea(t, a);
|
|
3252
3364
|
}));
|
|
3253
3365
|
}
|
|
3254
|
-
var
|
|
3366
|
+
var wa = new Set([
|
|
3255
3367
|
".git",
|
|
3256
3368
|
"node_modules",
|
|
3257
3369
|
"dist",
|
|
@@ -3260,23 +3372,23 @@ var oa = new Set([
|
|
|
3260
3372
|
".next",
|
|
3261
3373
|
"coverage"
|
|
3262
3374
|
]);
|
|
3263
|
-
async function
|
|
3375
|
+
async function Ta(e, t) {
|
|
3264
3376
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3265
3377
|
await Promise.all(n.map(async (n) => {
|
|
3266
3378
|
let r = T.join(e, n.name);
|
|
3267
3379
|
if (n.isDirectory()) {
|
|
3268
|
-
if (
|
|
3269
|
-
await
|
|
3270
|
-
} else n.isFile() &&
|
|
3380
|
+
if (wa.has(n.name)) return;
|
|
3381
|
+
await Ta(r, t);
|
|
3382
|
+
} else n.isFile() && Sa.has(T.extname(n.name)) && await Ea(r, t);
|
|
3271
3383
|
}));
|
|
3272
3384
|
}
|
|
3273
|
-
async function
|
|
3385
|
+
async function Ea(e, t) {
|
|
3274
3386
|
let n = await y.readFile(e, "utf-8");
|
|
3275
3387
|
if (!n.includes(Xr)) return;
|
|
3276
3388
|
let r = ei(n, t);
|
|
3277
3389
|
r !== n && await y.writeFile(e, r, "utf-8");
|
|
3278
3390
|
}
|
|
3279
|
-
var
|
|
3391
|
+
var Da = new Set([
|
|
3280
3392
|
".git",
|
|
3281
3393
|
"node_modules",
|
|
3282
3394
|
"dist",
|
|
@@ -3286,12 +3398,12 @@ var la = new Set([
|
|
|
3286
3398
|
".turbo",
|
|
3287
3399
|
".cache",
|
|
3288
3400
|
"coverage"
|
|
3289
|
-
]),
|
|
3401
|
+
]), Oa = new Set([
|
|
3290
3402
|
"pnpm-lock.yaml",
|
|
3291
3403
|
"package-lock.json",
|
|
3292
3404
|
"yarn.lock",
|
|
3293
3405
|
"bun.lockb"
|
|
3294
|
-
]),
|
|
3406
|
+
]), ka = new Set([
|
|
3295
3407
|
".png",
|
|
3296
3408
|
".jpg",
|
|
3297
3409
|
".jpeg",
|
|
@@ -3318,21 +3430,21 @@ var la = new Set([
|
|
|
3318
3430
|
".mp3",
|
|
3319
3431
|
".wav"
|
|
3320
3432
|
]);
|
|
3321
|
-
async function
|
|
3322
|
-
t !== "hype-stack" && await
|
|
3433
|
+
async function Aa(e, t) {
|
|
3434
|
+
t !== "hype-stack" && await ja(e, t);
|
|
3323
3435
|
}
|
|
3324
|
-
async function
|
|
3436
|
+
async function ja(e, t) {
|
|
3325
3437
|
let n = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
3326
3438
|
await Promise.all(n.map(async (n) => {
|
|
3327
3439
|
let r = T.join(e, n.name);
|
|
3328
3440
|
if (n.isDirectory()) {
|
|
3329
|
-
if (
|
|
3330
|
-
await
|
|
3331
|
-
} else n.isFile() && await
|
|
3441
|
+
if (Da.has(n.name)) return;
|
|
3442
|
+
await ja(r, t);
|
|
3443
|
+
} else n.isFile() && await Ma(r, t);
|
|
3332
3444
|
}));
|
|
3333
3445
|
}
|
|
3334
|
-
async function
|
|
3335
|
-
if (
|
|
3446
|
+
async function Ma(e, t) {
|
|
3447
|
+
if (Oa.has(T.basename(e)) || ka.has(T.extname(e).toLowerCase())) return;
|
|
3336
3448
|
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
3337
3449
|
if (n === null || n.includes("\0") || !n.includes("hype-stack") && !n.includes(Qr)) return;
|
|
3338
3450
|
let r = ti(n, t);
|
|
@@ -3340,22 +3452,25 @@ async function ma(e, t) {
|
|
|
3340
3452
|
}
|
|
3341
3453
|
//#endregion
|
|
3342
3454
|
//#region src/core/installer.ts
|
|
3343
|
-
function
|
|
3344
|
-
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3455
|
+
function Na(e, t, n) {
|
|
3456
|
+
return e.slot ? t ? t.includes(e.slot) : e.slot === "admin" ? n : e.slot === "frontend" : !0;
|
|
3345
3457
|
}
|
|
3346
|
-
|
|
3458
|
+
function Pa(e) {
|
|
3459
|
+
return !!e.apps?.admin;
|
|
3460
|
+
}
|
|
3461
|
+
async function Fa(e, t) {
|
|
3347
3462
|
if ((await y.stat(e)).isDirectory()) {
|
|
3348
3463
|
await y.mkdir(t, { recursive: !0 });
|
|
3349
3464
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3350
|
-
for (let r of n) await
|
|
3465
|
+
for (let r of n) await Fa(T.join(e, r.name), T.join(t, r.name));
|
|
3351
3466
|
} else await y.mkdir(T.dirname(t), { recursive: !0 }), await y.copyFile(e, t);
|
|
3352
3467
|
}
|
|
3353
|
-
async function
|
|
3468
|
+
async function Ia(e) {
|
|
3354
3469
|
let { src: t, dest: n, projectRoot: r, skip: i } = e;
|
|
3355
3470
|
if ((await y.stat(t)).isDirectory()) {
|
|
3356
3471
|
await y.mkdir(n, { recursive: !0 });
|
|
3357
3472
|
let e = await y.readdir(t, { withFileTypes: !0 });
|
|
3358
|
-
return (await Promise.all(e.map((e) =>
|
|
3473
|
+
return (await Promise.all(e.map((e) => Ia({
|
|
3359
3474
|
src: T.join(t, e.name),
|
|
3360
3475
|
dest: T.join(n, e.name),
|
|
3361
3476
|
projectRoot: r,
|
|
@@ -3364,17 +3479,17 @@ async function _a(e) {
|
|
|
3364
3479
|
}
|
|
3365
3480
|
return i.has(t) ? [] : (await y.mkdir(T.dirname(n), { recursive: !0 }), await y.copyFile(t, n), [T.relative(r, n)]);
|
|
3366
3481
|
}
|
|
3367
|
-
async function
|
|
3482
|
+
async function La(e) {
|
|
3368
3483
|
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = Kr(t.source, n), o = Gr(t.target, r, i);
|
|
3369
3484
|
return {
|
|
3370
3485
|
sourcePath: a,
|
|
3371
3486
|
targetPath: o,
|
|
3372
|
-
sourceExists: await Y(a) || await
|
|
3373
|
-
targetExists: await Y(o) || await
|
|
3487
|
+
sourceExists: await Y(a) || await J(a),
|
|
3488
|
+
targetExists: await Y(o) || await J(o)
|
|
3374
3489
|
};
|
|
3375
3490
|
}
|
|
3376
|
-
async function
|
|
3377
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await
|
|
3491
|
+
async function Ra(e) {
|
|
3492
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await La({
|
|
3378
3493
|
file: t,
|
|
3379
3494
|
packDir: n,
|
|
3380
3495
|
paths: r,
|
|
@@ -3389,8 +3504,8 @@ async function ya(e) {
|
|
|
3389
3504
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3390
3505
|
}
|
|
3391
3506
|
}
|
|
3392
|
-
async function
|
|
3393
|
-
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await
|
|
3507
|
+
async function za(e) {
|
|
3508
|
+
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await La({
|
|
3394
3509
|
file: t,
|
|
3395
3510
|
packDir: n,
|
|
3396
3511
|
paths: r,
|
|
@@ -3408,7 +3523,7 @@ async function ba(e) {
|
|
|
3408
3523
|
status: "skipped",
|
|
3409
3524
|
path: t.target,
|
|
3410
3525
|
reason: "Already exists"
|
|
3411
|
-
} : (await
|
|
3526
|
+
} : (await Fa(s, c), {
|
|
3412
3527
|
status: "installed",
|
|
3413
3528
|
path: t.target
|
|
3414
3529
|
});
|
|
@@ -3417,16 +3532,16 @@ async function ba(e) {
|
|
|
3417
3532
|
status: "skipped",
|
|
3418
3533
|
path: t.target,
|
|
3419
3534
|
reason: "Already exists (skip-if-exists)"
|
|
3420
|
-
} : (await
|
|
3535
|
+
} : (await Fa(s, c), {
|
|
3421
3536
|
status: "installed",
|
|
3422
3537
|
path: t.target
|
|
3423
3538
|
});
|
|
3424
|
-
case "override": return await
|
|
3539
|
+
case "override": return await Fa(s, c), {
|
|
3425
3540
|
status: "installed",
|
|
3426
3541
|
path: t.target
|
|
3427
3542
|
};
|
|
3428
3543
|
case "merge": {
|
|
3429
|
-
if (!u) return await
|
|
3544
|
+
if (!u) return await Fa(s, c), {
|
|
3430
3545
|
status: "installed",
|
|
3431
3546
|
path: t.target
|
|
3432
3547
|
};
|
|
@@ -3456,21 +3571,21 @@ async function ba(e) {
|
|
|
3456
3571
|
};
|
|
3457
3572
|
}
|
|
3458
3573
|
}
|
|
3459
|
-
async function
|
|
3574
|
+
async function Ba(e) {
|
|
3460
3575
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3461
3576
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3462
|
-
let o = [], s = /* @__PURE__ */ new Set();
|
|
3577
|
+
let o = [], s = /* @__PURE__ */ new Set(), c = Pa(n);
|
|
3463
3578
|
for (let e of t) {
|
|
3464
3579
|
let t = i?.get(e.manifest.name);
|
|
3465
3580
|
for (let n of e.manifest.files) {
|
|
3466
|
-
if (n.strategy !== "create" || !
|
|
3467
|
-
let { targetPath: i, targetExists:
|
|
3581
|
+
if (n.strategy !== "create" || !Na(n, t, c)) continue;
|
|
3582
|
+
let { targetPath: i, targetExists: l } = await La({
|
|
3468
3583
|
file: n,
|
|
3469
3584
|
packDir: e.packDir,
|
|
3470
3585
|
paths: a,
|
|
3471
3586
|
projectRoot: r
|
|
3472
3587
|
});
|
|
3473
|
-
!
|
|
3588
|
+
!l || s.has(i) || (s.add(i), o.push({
|
|
3474
3589
|
packName: e.manifest.name,
|
|
3475
3590
|
target: n.target,
|
|
3476
3591
|
targetPath: i
|
|
@@ -3479,33 +3594,33 @@ async function xa(e) {
|
|
|
3479
3594
|
}
|
|
3480
3595
|
return o;
|
|
3481
3596
|
}
|
|
3482
|
-
async function
|
|
3597
|
+
async function Va(e) {
|
|
3483
3598
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3484
3599
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3485
|
-
let c = [];
|
|
3600
|
+
let c = Pa(n), l = [];
|
|
3486
3601
|
for (let e of t.files) {
|
|
3487
|
-
if (!
|
|
3488
|
-
let t = await
|
|
3602
|
+
if (!Na(e, o, c)) continue;
|
|
3603
|
+
let t = await Ra({
|
|
3489
3604
|
file: e,
|
|
3490
3605
|
packDir: a,
|
|
3491
3606
|
paths: s,
|
|
3492
3607
|
projectRoot: r,
|
|
3493
3608
|
force: i
|
|
3494
3609
|
});
|
|
3495
|
-
t &&
|
|
3610
|
+
t && l.push(t);
|
|
3496
3611
|
}
|
|
3497
|
-
return
|
|
3612
|
+
return l;
|
|
3498
3613
|
}
|
|
3499
|
-
async function
|
|
3614
|
+
async function Ha(e) {
|
|
3500
3615
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3501
3616
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3502
3617
|
let l = {
|
|
3503
3618
|
installed: [],
|
|
3504
3619
|
skipped: [],
|
|
3505
3620
|
errors: []
|
|
3506
|
-
}, u = t.files.filter((e) =>
|
|
3507
|
-
for (let e of
|
|
3508
|
-
let t = await
|
|
3621
|
+
}, u = Pa(n), d = t.files.filter((e) => Na(e, s, u));
|
|
3622
|
+
for (let e of d) {
|
|
3623
|
+
let t = await za({
|
|
3509
3624
|
file: e,
|
|
3510
3625
|
packDir: o,
|
|
3511
3626
|
paths: c,
|
|
@@ -3525,40 +3640,65 @@ async function Ca(e) {
|
|
|
3525
3640
|
break;
|
|
3526
3641
|
}
|
|
3527
3642
|
}
|
|
3528
|
-
await
|
|
3529
|
-
files:
|
|
3643
|
+
await Ca({
|
|
3644
|
+
files: d,
|
|
3530
3645
|
paths: c,
|
|
3531
3646
|
projectRoot: r,
|
|
3532
3647
|
projectName: n.name
|
|
3533
3648
|
}), t.env && t.env.length > 0 && await ri(t.env, c, r), t.routes && t.routes.length > 0 && await li(t.routes, c, r), t.context && t.context.length > 0 && await fi(t.context, c, r), t.sockets && t.sockets.length > 0 && await wi(t.sockets, c, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await Oi(t.sdkConfigurations, c, r), t.enums && t.enums.length > 0 && await vi(t.enums, c, r), t.permissions && t.permissions.length > 0 && await bi(t.permissions, c, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await ji(t.frontendRoutes, c, r);
|
|
3534
|
-
let
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3649
|
+
let f = s && s.length > 0 ? s : ["frontend"], p = (() => {
|
|
3650
|
+
let e = new Set(f);
|
|
3651
|
+
for (let n of t.nav ?? []) n.slot && (n.slot === "admin" && !u || e.add(n.slot));
|
|
3652
|
+
return [...e];
|
|
3653
|
+
})();
|
|
3654
|
+
for (let e of p) {
|
|
3655
|
+
if (t.nav && t.nav.length > 0) {
|
|
3656
|
+
let n = t.nav.filter((t) => !t.slot || t.slot === e);
|
|
3657
|
+
n.length > 0 && (await Vi({
|
|
3658
|
+
entries: n,
|
|
3659
|
+
paths: c,
|
|
3660
|
+
projectRoot: r,
|
|
3661
|
+
slot: e
|
|
3662
|
+
}), e === "admin" && await Ri({
|
|
3663
|
+
labels: Pi,
|
|
3664
|
+
paths: c,
|
|
3665
|
+
projectRoot: r,
|
|
3666
|
+
slot: e,
|
|
3667
|
+
overwrite: !0
|
|
3668
|
+
}));
|
|
3669
|
+
}
|
|
3670
|
+
if (f.includes(e)) {
|
|
3671
|
+
if (t.navbarActions && t.navbarActions.length > 0) {
|
|
3672
|
+
let n = t.navbarActions.filter((t) => !t.slot || t.slot === e);
|
|
3673
|
+
n.length > 0 && await ga({
|
|
3674
|
+
actions: n,
|
|
3675
|
+
paths: c,
|
|
3676
|
+
projectRoot: r,
|
|
3677
|
+
slot: e
|
|
3678
|
+
});
|
|
3679
|
+
}
|
|
3680
|
+
if (t.userMenuActions && t.userMenuActions.length > 0) {
|
|
3681
|
+
let n = t.userMenuActions.filter((t) => !t.slot || t.slot === e);
|
|
3682
|
+
n.length > 0 && await _a({
|
|
3683
|
+
actions: n,
|
|
3684
|
+
paths: c,
|
|
3685
|
+
projectRoot: r,
|
|
3686
|
+
slot: e
|
|
3687
|
+
});
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
}
|
|
3691
|
+
return t.onboardingSteps && t.onboardingSteps.length > 0 && await Qi(t.onboardingSteps, c, r), u && t.dashboardRows && t.dashboardRows.length > 0 && await ra(t.dashboardRows, c, r), u && t.orgDetailsRows && t.orgDetailsRows.length > 0 && await ua(t.orgDetailsRows, c, r), u && t.orgDetailsCards && t.orgDetailsCards.length > 0 && await da(t.orgDetailsCards, c, r), t.postLoginRedirect && await Hi({
|
|
3552
3692
|
postLoginRedirect: t.postLoginRedirect,
|
|
3553
3693
|
paths: c,
|
|
3554
3694
|
projectRoot: r,
|
|
3555
|
-
slot:
|
|
3695
|
+
slot: f[0]
|
|
3556
3696
|
}), l;
|
|
3557
3697
|
}
|
|
3558
|
-
async function
|
|
3698
|
+
async function Ua(e) {
|
|
3559
3699
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3560
3700
|
for (let e of t) {
|
|
3561
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3701
|
+
let t = o?.get(e.manifest.name), a = await Va({
|
|
3562
3702
|
manifest: e.manifest,
|
|
3563
3703
|
config: n,
|
|
3564
3704
|
projectRoot: r,
|
|
@@ -3578,7 +3718,7 @@ async function wa(e) {
|
|
|
3578
3718
|
};
|
|
3579
3719
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3580
3720
|
for (let e of t) {
|
|
3581
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3721
|
+
let t = o?.get(e.manifest.name), n = await Ha({
|
|
3582
3722
|
manifest: e.manifest,
|
|
3583
3723
|
config: f,
|
|
3584
3724
|
projectRoot: r,
|
|
@@ -3587,7 +3727,7 @@ async function wa(e) {
|
|
|
3587
3727
|
packDir: e.packDir,
|
|
3588
3728
|
slots: t
|
|
3589
3729
|
});
|
|
3590
|
-
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await
|
|
3730
|
+
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await Wa(f, e.manifest, r), d.push(e.manifest.name);
|
|
3591
3731
|
}
|
|
3592
3732
|
return {
|
|
3593
3733
|
installed: c,
|
|
@@ -3598,7 +3738,7 @@ async function wa(e) {
|
|
|
3598
3738
|
config: f
|
|
3599
3739
|
};
|
|
3600
3740
|
}
|
|
3601
|
-
async function
|
|
3741
|
+
async function Wa(e, t, n) {
|
|
3602
3742
|
let r = typeof t == "string" ? t : t.name, i = typeof t == "string" ? [] : Mr(t.env), a = Nr([...e.onboarding?.envSections ?? [], ...i]), o = {
|
|
3603
3743
|
...e,
|
|
3604
3744
|
installedPacks: [...e.installedPacks ?? [], r],
|
|
@@ -3609,17 +3749,17 @@ async function Ta(e, t, n) {
|
|
|
3609
3749
|
};
|
|
3610
3750
|
return await Rr(n, o), o;
|
|
3611
3751
|
}
|
|
3612
|
-
async function
|
|
3752
|
+
async function Ga(e) {
|
|
3613
3753
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3614
3754
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3615
3755
|
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");
|
|
3616
|
-
if (await
|
|
3756
|
+
if (await J(u)) {
|
|
3617
3757
|
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3618
3758
|
for (let t of e) {
|
|
3619
3759
|
if (!t.isDirectory()) continue;
|
|
3620
3760
|
let e = a[t.name]?.root;
|
|
3621
3761
|
if (!e) continue;
|
|
3622
|
-
let n = await
|
|
3762
|
+
let n = await Ia({
|
|
3623
3763
|
src: T.join(u, t.name),
|
|
3624
3764
|
dest: T.resolve(r, e),
|
|
3625
3765
|
projectRoot: r,
|
|
@@ -3629,7 +3769,7 @@ async function Ea(e) {
|
|
|
3629
3769
|
}
|
|
3630
3770
|
}
|
|
3631
3771
|
for (let e of c) {
|
|
3632
|
-
let t = await
|
|
3772
|
+
let t = await za({
|
|
3633
3773
|
file: e,
|
|
3634
3774
|
packDir: i,
|
|
3635
3775
|
paths: a,
|
|
@@ -3640,12 +3780,12 @@ async function Ea(e) {
|
|
|
3640
3780
|
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3641
3781
|
}
|
|
3642
3782
|
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");
|
|
3643
|
-
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
|
|
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({
|
|
3644
3784
|
entries: t.nav,
|
|
3645
3785
|
paths: a,
|
|
3646
3786
|
projectRoot: r,
|
|
3647
3787
|
override: !0
|
|
3648
|
-
}), t.postLoginRedirect && await
|
|
3788
|
+
}), t.postLoginRedirect && await Hi({
|
|
3649
3789
|
postLoginRedirect: t.postLoginRedirect,
|
|
3650
3790
|
paths: a,
|
|
3651
3791
|
projectRoot: r
|
|
@@ -3656,35 +3796,35 @@ async function Ea(e) {
|
|
|
3656
3796
|
}
|
|
3657
3797
|
//#endregion
|
|
3658
3798
|
//#region src/core/pack-categories.ts
|
|
3659
|
-
var
|
|
3799
|
+
var Ka = [
|
|
3660
3800
|
"starter",
|
|
3661
3801
|
"layout",
|
|
3662
3802
|
"feature"
|
|
3663
|
-
],
|
|
3803
|
+
], qa = {
|
|
3664
3804
|
starter: "Starter",
|
|
3665
3805
|
layout: "Layout",
|
|
3666
3806
|
feature: "Features"
|
|
3667
|
-
},
|
|
3668
|
-
function
|
|
3807
|
+
}, Ja = new Set(["starter", "layout"]), Ya = "starter-saas-betterauth", Xa = "layout-basic";
|
|
3808
|
+
function Za(e, t = {}) {
|
|
3669
3809
|
let n = [];
|
|
3670
|
-
for (let r of
|
|
3810
|
+
for (let r of Ka) {
|
|
3671
3811
|
let i = e.filter((e) => e.category === r);
|
|
3672
3812
|
if (i.length === 0) continue;
|
|
3673
|
-
let a =
|
|
3813
|
+
let a = Ja.has(r) ? "single" : "multiple";
|
|
3674
3814
|
if (r === "layout") {
|
|
3675
|
-
if (n.push(
|
|
3815
|
+
if (n.push($a("frontend", i)), t.adminAvailable) {
|
|
3676
3816
|
let e = i.filter((e) => e.adminCompatible);
|
|
3677
|
-
e.length > 0 && n.push(
|
|
3817
|
+
e.length > 0 && n.push($a("admin", e));
|
|
3678
3818
|
}
|
|
3679
3819
|
continue;
|
|
3680
3820
|
}
|
|
3681
3821
|
if (r === "starter") {
|
|
3682
|
-
n.push(
|
|
3822
|
+
n.push(Qa(i));
|
|
3683
3823
|
continue;
|
|
3684
3824
|
}
|
|
3685
3825
|
n.push({
|
|
3686
3826
|
category: r,
|
|
3687
|
-
label:
|
|
3827
|
+
label: qa[r],
|
|
3688
3828
|
mode: a,
|
|
3689
3829
|
packs: i,
|
|
3690
3830
|
preselect: null
|
|
@@ -3692,36 +3832,36 @@ function Ma(e, t = {}) {
|
|
|
3692
3832
|
}
|
|
3693
3833
|
return n;
|
|
3694
3834
|
}
|
|
3695
|
-
function
|
|
3696
|
-
let t = e.some((e) => e.name ===
|
|
3835
|
+
function Qa(e) {
|
|
3836
|
+
let t = e.some((e) => e.name === Ya);
|
|
3697
3837
|
return {
|
|
3698
3838
|
category: "starter",
|
|
3699
|
-
label:
|
|
3839
|
+
label: qa.starter,
|
|
3700
3840
|
mode: "single",
|
|
3701
3841
|
packs: e,
|
|
3702
|
-
preselect: t ?
|
|
3842
|
+
preselect: t ? Ya : null
|
|
3703
3843
|
};
|
|
3704
3844
|
}
|
|
3705
|
-
function
|
|
3706
|
-
let n = t.some((e) => e.name ===
|
|
3845
|
+
function $a(e, t) {
|
|
3846
|
+
let n = t.some((e) => e.name === Xa);
|
|
3707
3847
|
return {
|
|
3708
3848
|
category: "layout",
|
|
3709
3849
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3710
3850
|
mode: "single",
|
|
3711
3851
|
packs: t,
|
|
3712
|
-
preselect: n ?
|
|
3852
|
+
preselect: n ? Xa : null,
|
|
3713
3853
|
slot: e
|
|
3714
3854
|
};
|
|
3715
3855
|
}
|
|
3716
3856
|
//#endregion
|
|
3717
3857
|
//#region src/core/post-setup.ts
|
|
3718
|
-
async function
|
|
3719
|
-
return (await
|
|
3858
|
+
async function eo() {
|
|
3859
|
+
return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3720
3860
|
}
|
|
3721
|
-
async function
|
|
3861
|
+
async function to(e) {
|
|
3722
3862
|
return Y(`${e}/apps/backend/.env`);
|
|
3723
3863
|
}
|
|
3724
|
-
async function
|
|
3864
|
+
async function no(e, t, n) {
|
|
3725
3865
|
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({
|
|
3726
3866
|
message: r,
|
|
3727
3867
|
initialValue: !0
|
|
@@ -3729,37 +3869,37 @@ async function La(e, t, n) {
|
|
|
3729
3869
|
if (s.isCancel(i) && V(), !i) return s.log.info(R.muted("Skipping Docker services and database migrations.")), !1;
|
|
3730
3870
|
let a = s.spinner();
|
|
3731
3871
|
a.start("Starting Docker services...");
|
|
3732
|
-
let o = await
|
|
3872
|
+
let o = await q("docker", [
|
|
3733
3873
|
"compose",
|
|
3734
3874
|
"up",
|
|
3735
3875
|
"-d"
|
|
3736
3876
|
], { cwd: `${e}/apps/backend` });
|
|
3737
|
-
return o.exitCode === 0 ? (a.stop(R.success("Docker services started")), !0) : (a.error("Failed to start Docker services"),
|
|
3877
|
+
return o.exitCode === 0 ? (a.stop(R.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), so(o), !1);
|
|
3738
3878
|
}
|
|
3739
|
-
function
|
|
3879
|
+
function ro(e) {
|
|
3740
3880
|
let t = (e.stderr || e.stdout).trim();
|
|
3741
3881
|
t && s.log.warn(R.muted(t));
|
|
3742
3882
|
}
|
|
3743
|
-
function
|
|
3883
|
+
function io(e) {
|
|
3744
3884
|
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;
|
|
3745
3885
|
}
|
|
3746
|
-
function
|
|
3886
|
+
function ao(e) {
|
|
3747
3887
|
return e.match(/container name "\/?([^"]+)"/i)?.[1] ?? null;
|
|
3748
3888
|
}
|
|
3749
|
-
function
|
|
3889
|
+
function oo(e) {
|
|
3750
3890
|
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;
|
|
3751
3891
|
}
|
|
3752
|
-
function
|
|
3753
|
-
let t = (e.stderr || e.stdout).trim(), n =
|
|
3892
|
+
function so(e) {
|
|
3893
|
+
let t = (e.stderr || e.stdout).trim(), n = io(t);
|
|
3754
3894
|
if (!n) {
|
|
3755
3895
|
t && s.log.warn(R.muted(t));
|
|
3756
3896
|
return;
|
|
3757
3897
|
}
|
|
3758
3898
|
if (n === "container") {
|
|
3759
|
-
let e =
|
|
3899
|
+
let e = ao(t);
|
|
3760
3900
|
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.`));
|
|
3761
3901
|
} else {
|
|
3762
|
-
let e =
|
|
3902
|
+
let e = oo(t);
|
|
3763
3903
|
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.`));
|
|
3764
3904
|
}
|
|
3765
3905
|
B([
|
|
@@ -3768,9 +3908,9 @@ function Ha(e) {
|
|
|
3768
3908
|
R.muted("then re-run this command and start Docker again")
|
|
3769
3909
|
].join("\n"), "Free up Docker, then retry"), t && s.log.warn(R.muted(t));
|
|
3770
3910
|
}
|
|
3771
|
-
async function
|
|
3911
|
+
async function co(e, t = 15, n = 2e3) {
|
|
3772
3912
|
for (let r = 0; r < t; r++) {
|
|
3773
|
-
if ((await
|
|
3913
|
+
if ((await q("docker", [
|
|
3774
3914
|
"compose",
|
|
3775
3915
|
"exec",
|
|
3776
3916
|
"-T",
|
|
@@ -3783,9 +3923,9 @@ async function Ua(e, t = 15, n = 2e3) {
|
|
|
3783
3923
|
}
|
|
3784
3924
|
return !1;
|
|
3785
3925
|
}
|
|
3786
|
-
var
|
|
3787
|
-
async function
|
|
3788
|
-
let t = await
|
|
3926
|
+
var lo = "Database schema is up to date";
|
|
3927
|
+
async function uo(e) {
|
|
3928
|
+
let t = await q("pnpm", [
|
|
3789
3929
|
"--filter",
|
|
3790
3930
|
"@internal/backend",
|
|
3791
3931
|
"exec",
|
|
@@ -3793,25 +3933,25 @@ async function Ga(e) {
|
|
|
3793
3933
|
"migrate",
|
|
3794
3934
|
"status"
|
|
3795
3935
|
], { cwd: e });
|
|
3796
|
-
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(
|
|
3936
|
+
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(lo) : !1;
|
|
3797
3937
|
}
|
|
3798
|
-
async function
|
|
3938
|
+
async function fo(e) {
|
|
3799
3939
|
let t = s.spinner();
|
|
3800
3940
|
t.start("Running database migrations...");
|
|
3801
|
-
let n = await
|
|
3941
|
+
let n = await q("pnpm", [
|
|
3802
3942
|
"--filter",
|
|
3803
3943
|
"@internal/backend",
|
|
3804
3944
|
"migration:latest"
|
|
3805
3945
|
], { cwd: e });
|
|
3806
|
-
return n.exitCode === 0 ? (t.stop(R.success("Database migrations applied")), !0) : (t.error("Migrations failed"),
|
|
3946
|
+
return n.exitCode === 0 ? (t.stop(R.success("Database migrations applied")), !0) : (t.error("Migrations failed"), ro(n), s.log.warn(R.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations.")), !1);
|
|
3807
3947
|
}
|
|
3808
|
-
async function
|
|
3809
|
-
if (!await
|
|
3948
|
+
async function po(e, t, n = {}) {
|
|
3949
|
+
if (!await no(e, t, await eo())) return !1;
|
|
3810
3950
|
let r = s.spinner();
|
|
3811
|
-
return r.start("Waiting for Postgres to be ready..."), await
|
|
3951
|
+
return r.start("Waiting for Postgres to be ready..."), await co(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);
|
|
3812
3952
|
}
|
|
3813
|
-
async function
|
|
3814
|
-
if (!await
|
|
3953
|
+
async function mo(e, t, n = {}) {
|
|
3954
|
+
if (!await po(e, t, n)) return;
|
|
3815
3955
|
let r = t ? !0 : await s.confirm({
|
|
3816
3956
|
message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
|
|
3817
3957
|
initialValue: !0
|
|
@@ -3820,21 +3960,21 @@ async function Ja(e, t, n = {}) {
|
|
|
3820
3960
|
s.log.info(R.muted("Skipping database migrations."));
|
|
3821
3961
|
return;
|
|
3822
3962
|
}
|
|
3823
|
-
await
|
|
3963
|
+
await fo(e);
|
|
3824
3964
|
}
|
|
3825
|
-
async function
|
|
3826
|
-
if (!await
|
|
3965
|
+
async function ho(e, t, n = {}) {
|
|
3966
|
+
if (!await to(e)) {
|
|
3827
3967
|
s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3828
3968
|
return;
|
|
3829
3969
|
}
|
|
3830
|
-
await
|
|
3970
|
+
await mo(e, t, n);
|
|
3831
3971
|
}
|
|
3832
|
-
async function
|
|
3833
|
-
return await
|
|
3972
|
+
async function go(e, t, n = {}) {
|
|
3973
|
+
return await to(e) ? po(e, t, n) : (s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker - configure it first.`), !1);
|
|
3834
3974
|
}
|
|
3835
3975
|
//#endregion
|
|
3836
3976
|
//#region src/core/resolve.ts
|
|
3837
|
-
function
|
|
3977
|
+
function _o(e) {
|
|
3838
3978
|
let t = /* @__PURE__ */ new Map();
|
|
3839
3979
|
for (let n of e) t.set(n.name, {
|
|
3840
3980
|
name: n.name,
|
|
@@ -3842,7 +3982,7 @@ function Za(e) {
|
|
|
3842
3982
|
});
|
|
3843
3983
|
return t;
|
|
3844
3984
|
}
|
|
3845
|
-
function
|
|
3985
|
+
function vo(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3846
3986
|
let r = /* @__PURE__ */ new Set();
|
|
3847
3987
|
function i(e) {
|
|
3848
3988
|
if (n.has(e)) return [];
|
|
@@ -3856,10 +3996,10 @@ function Qa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3856
3996
|
}
|
|
3857
3997
|
return i(e);
|
|
3858
3998
|
}
|
|
3859
|
-
function
|
|
3999
|
+
function yo(e, t, n = []) {
|
|
3860
4000
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3861
4001
|
for (let n of e) {
|
|
3862
|
-
let e =
|
|
4002
|
+
let e = vo(n, t, new Set(i));
|
|
3863
4003
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3864
4004
|
}
|
|
3865
4005
|
return {
|
|
@@ -3867,7 +4007,7 @@ function $a(e, t, n = []) {
|
|
|
3867
4007
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3868
4008
|
};
|
|
3869
4009
|
}
|
|
3870
|
-
function
|
|
4010
|
+
function bo(e) {
|
|
3871
4011
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3872
4012
|
for (let e of t) {
|
|
3873
4013
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3880,7 +4020,7 @@ function eo(e) {
|
|
|
3880
4020
|
}
|
|
3881
4021
|
//#endregion
|
|
3882
4022
|
//#region src/core/variants.ts
|
|
3883
|
-
function
|
|
4023
|
+
function xo(e, t = {}) {
|
|
3884
4024
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3885
4025
|
for (let i of e) {
|
|
3886
4026
|
let e = t[i.family] ?? i.default;
|
|
@@ -3892,18 +4032,18 @@ function to(e, t = {}) {
|
|
|
3892
4032
|
familyOf: r
|
|
3893
4033
|
};
|
|
3894
4034
|
}
|
|
3895
|
-
function
|
|
4035
|
+
function So(e, t, n) {
|
|
3896
4036
|
let r = e.map((e) => n.chosen.get(e.family) ?? e.default), i = new Set(e.map((e) => e.family)), a = t.filter((e) => {
|
|
3897
4037
|
let t = n.familyOf.get(e);
|
|
3898
4038
|
return !(t && i.has(t));
|
|
3899
4039
|
});
|
|
3900
4040
|
return [...r, ...a];
|
|
3901
4041
|
}
|
|
3902
|
-
function
|
|
4042
|
+
function Co(e, t) {
|
|
3903
4043
|
let n = t.familyOf.get(e);
|
|
3904
4044
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3905
4045
|
}
|
|
3906
|
-
function
|
|
4046
|
+
function wo(e, t) {
|
|
3907
4047
|
let n = /* @__PURE__ */ new Map();
|
|
3908
4048
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3909
4049
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3919,65 +4059,65 @@ function io(e, t) {
|
|
|
3919
4059
|
familyOf: n
|
|
3920
4060
|
};
|
|
3921
4061
|
}
|
|
3922
|
-
function
|
|
4062
|
+
function To(e, t) {
|
|
3923
4063
|
return e.map((e) => ({
|
|
3924
4064
|
...e,
|
|
3925
|
-
dependencies: e.dependencies.map((e) =>
|
|
4065
|
+
dependencies: e.dependencies.map((e) => Co(e, t))
|
|
3926
4066
|
}));
|
|
3927
4067
|
}
|
|
3928
4068
|
//#endregion
|
|
3929
4069
|
//#region src/ui/banner.ts
|
|
3930
|
-
var
|
|
4070
|
+
var Eo = [
|
|
3931
4071
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3932
4072
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3933
4073
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3934
4074
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3935
4075
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3936
4076
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3937
|
-
],
|
|
4077
|
+
], Do = [
|
|
3938
4078
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3939
4079
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3940
4080
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3941
4081
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3942
4082
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3943
4083
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3944
|
-
],
|
|
4084
|
+
], Oo = [
|
|
3945
4085
|
253,
|
|
3946
4086
|
176,
|
|
3947
4087
|
21
|
|
3948
|
-
],
|
|
4088
|
+
], ko = [
|
|
3949
4089
|
245,
|
|
3950
4090
|
76,
|
|
3951
4091
|
2
|
|
3952
|
-
],
|
|
4092
|
+
], Ao = 5, jo = [
|
|
3953
4093
|
17,
|
|
3954
4094
|
103,
|
|
3955
4095
|
248
|
|
3956
|
-
],
|
|
4096
|
+
], Mo = [
|
|
3957
4097
|
42,
|
|
3958
4098
|
160,
|
|
3959
4099
|
250
|
|
3960
|
-
],
|
|
3961
|
-
function
|
|
4100
|
+
], No = .2;
|
|
4101
|
+
function Po() {
|
|
3962
4102
|
console.log();
|
|
3963
|
-
for (let e of xe(
|
|
3964
|
-
start:
|
|
3965
|
-
end:
|
|
3966
|
-
angle:
|
|
4103
|
+
for (let e of xe(Eo, {
|
|
4104
|
+
start: Oo,
|
|
4105
|
+
end: ko,
|
|
4106
|
+
angle: Ao
|
|
3967
4107
|
})) console.log(b.bold(e));
|
|
3968
|
-
for (let e of xe(
|
|
3969
|
-
start:
|
|
3970
|
-
end:
|
|
3971
|
-
angle:
|
|
4108
|
+
for (let e of xe(Do, {
|
|
4109
|
+
start: jo,
|
|
4110
|
+
end: Mo,
|
|
4111
|
+
angle: No
|
|
3972
4112
|
})) console.log(b.bold(e));
|
|
3973
|
-
console.log(), console.log(` ${z.spark} ${b.dim("v" +
|
|
4113
|
+
console.log(), console.log(` ${z.spark} ${b.dim("v" + j)} ${b.dim("·")} ${ye("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3974
4114
|
}
|
|
3975
|
-
function
|
|
3976
|
-
console.log(), console.log(` ${z.bolt} ${ge.orange("Hype")}${ge.skyBlue("Stack")} ${b.dim("v" +
|
|
4115
|
+
function Fo() {
|
|
4116
|
+
console.log(), console.log(` ${z.bolt} ${ge.orange("Hype")}${ge.skyBlue("Stack")} ${b.dim("v" + j)}`), console.log();
|
|
3977
4117
|
}
|
|
3978
4118
|
//#endregion
|
|
3979
4119
|
//#region src/ui/pack-multiselect.ts
|
|
3980
|
-
var
|
|
4120
|
+
var Io = class extends O {
|
|
3981
4121
|
options;
|
|
3982
4122
|
cursor = 0;
|
|
3983
4123
|
selected;
|
|
@@ -4081,12 +4221,12 @@ var _o = class extends O {
|
|
|
4081
4221
|
}
|
|
4082
4222
|
}
|
|
4083
4223
|
};
|
|
4084
|
-
function
|
|
4085
|
-
return new
|
|
4224
|
+
function Lo(e) {
|
|
4225
|
+
return new Io(e).prompt();
|
|
4086
4226
|
}
|
|
4087
4227
|
//#endregion
|
|
4088
4228
|
//#region src/utils/validate.ts
|
|
4089
|
-
function
|
|
4229
|
+
function Ro(e) {
|
|
4090
4230
|
if (!e.trim()) return "Project name cannot be empty";
|
|
4091
4231
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
4092
4232
|
let t = Sr(e);
|
|
@@ -4094,43 +4234,43 @@ function yo(e) {
|
|
|
4094
4234
|
}
|
|
4095
4235
|
//#endregion
|
|
4096
4236
|
//#region src/core/apply-mode.ts
|
|
4097
|
-
var
|
|
4098
|
-
function
|
|
4099
|
-
return e.replace(
|
|
4237
|
+
var zo = "src/hooks/use-theme.ts", Bo = /(\bexport\s+const\s+defaultTheme\s*=\s*)(["'])(?:light|dark)\2/;
|
|
4238
|
+
function Vo(e, t) {
|
|
4239
|
+
return e.replace(Bo, (e, n, r) => `${n}${r}${t}${r}`);
|
|
4100
4240
|
}
|
|
4101
|
-
async function
|
|
4102
|
-
let n = T.resolve(e,
|
|
4241
|
+
async function Ho(e, t) {
|
|
4242
|
+
let n = T.resolve(e, zo), r;
|
|
4103
4243
|
try {
|
|
4104
4244
|
r = await y.readFile(n, "utf-8");
|
|
4105
4245
|
} catch {
|
|
4106
4246
|
return !1;
|
|
4107
4247
|
}
|
|
4108
|
-
let i =
|
|
4248
|
+
let i = Vo(r, t);
|
|
4109
4249
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
4110
4250
|
}
|
|
4111
4251
|
//#endregion
|
|
4112
4252
|
//#region src/core/apply-radius.ts
|
|
4113
|
-
var
|
|
4114
|
-
function
|
|
4253
|
+
var Uo = /(^[ \t]*--radius(?![\w-])[ \t]*:[ \t]*)([^;\n]*);/gm;
|
|
4254
|
+
function Wo(e) {
|
|
4115
4255
|
return /^[0-9]*\.?[0-9]+(rem|em|px)$/.test(e.trim());
|
|
4116
4256
|
}
|
|
4117
|
-
function
|
|
4118
|
-
return e.replace(
|
|
4257
|
+
function Go(e, t) {
|
|
4258
|
+
return e.replace(Uo, (e, n) => `${n}${t};`);
|
|
4119
4259
|
}
|
|
4120
|
-
var
|
|
4121
|
-
async function
|
|
4122
|
-
let n = T.resolve(e,
|
|
4260
|
+
var Ko = "assets/styles.css";
|
|
4261
|
+
async function qo(e, t) {
|
|
4262
|
+
let n = T.resolve(e, Ko), r;
|
|
4123
4263
|
try {
|
|
4124
4264
|
r = await y.readFile(n, "utf-8");
|
|
4125
4265
|
} catch {
|
|
4126
4266
|
return !1;
|
|
4127
4267
|
}
|
|
4128
|
-
let i =
|
|
4268
|
+
let i = Go(r, t);
|
|
4129
4269
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
4130
4270
|
}
|
|
4131
4271
|
//#endregion
|
|
4132
4272
|
//#region src/core/apply-theme.ts
|
|
4133
|
-
function
|
|
4273
|
+
function Jo(e, t) {
|
|
4134
4274
|
let n = 0;
|
|
4135
4275
|
for (; n < e.length;) {
|
|
4136
4276
|
let r = e.indexOf(t, n);
|
|
@@ -4153,47 +4293,47 @@ function ko(e, t) {
|
|
|
4153
4293
|
}
|
|
4154
4294
|
return null;
|
|
4155
4295
|
}
|
|
4156
|
-
function
|
|
4296
|
+
function Yo(e, t) {
|
|
4157
4297
|
let n = e;
|
|
4158
4298
|
for (let [e, r] of Object.entries(t)) {
|
|
4159
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
4299
|
+
let t = RegExp(`(^[ \\t]*--${Xo(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
4160
4300
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
4161
4301
|
}
|
|
4162
4302
|
return n;
|
|
4163
4303
|
}
|
|
4164
|
-
function
|
|
4304
|
+
function Xo(e) {
|
|
4165
4305
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4166
4306
|
}
|
|
4167
|
-
function
|
|
4168
|
-
let n =
|
|
4307
|
+
function Zo(e, t) {
|
|
4308
|
+
let n = Jo(e, ":root"), r = Jo(e, ".dark"), i = e;
|
|
4169
4309
|
if (n) {
|
|
4170
4310
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
4171
|
-
i = e +
|
|
4311
|
+
i = e + Yo(r, t.light) + a;
|
|
4172
4312
|
}
|
|
4173
4313
|
if (r) {
|
|
4174
|
-
let e =
|
|
4314
|
+
let e = Jo(i, ".dark");
|
|
4175
4315
|
if (e) {
|
|
4176
4316
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
4177
|
-
i = n +
|
|
4317
|
+
i = n + Yo(r, t.dark) + a;
|
|
4178
4318
|
}
|
|
4179
4319
|
}
|
|
4180
4320
|
return i;
|
|
4181
4321
|
}
|
|
4182
|
-
var
|
|
4183
|
-
async function
|
|
4184
|
-
let n = T.resolve(e,
|
|
4322
|
+
var Qo = "assets/styles.css";
|
|
4323
|
+
async function $o(e, t) {
|
|
4324
|
+
let n = T.resolve(e, Qo), r;
|
|
4185
4325
|
try {
|
|
4186
4326
|
r = await y.readFile(n, "utf-8");
|
|
4187
4327
|
} catch {
|
|
4188
4328
|
return !1;
|
|
4189
4329
|
}
|
|
4190
|
-
let i =
|
|
4330
|
+
let i = Zo(r, t);
|
|
4191
4331
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
4192
4332
|
}
|
|
4193
4333
|
//#endregion
|
|
4194
4334
|
//#region src/core/clone.ts
|
|
4195
|
-
async function
|
|
4196
|
-
let t = await ee
|
|
4335
|
+
async function es(e) {
|
|
4336
|
+
let t = await A(ee, {
|
|
4197
4337
|
dir: e,
|
|
4198
4338
|
force: !0
|
|
4199
4339
|
});
|
|
@@ -4204,7 +4344,7 @@ async function Fo(e) {
|
|
|
4204
4344
|
}
|
|
4205
4345
|
//#endregion
|
|
4206
4346
|
//#region src/core/editor-config.ts
|
|
4207
|
-
function
|
|
4347
|
+
function ts(e) {
|
|
4208
4348
|
let t = {
|
|
4209
4349
|
globs: [],
|
|
4210
4350
|
alwaysApply: !1
|
|
@@ -4239,10 +4379,10 @@ function Io(e) {
|
|
|
4239
4379
|
content: i
|
|
4240
4380
|
};
|
|
4241
4381
|
}
|
|
4242
|
-
function
|
|
4382
|
+
function ns(e) {
|
|
4243
4383
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
4244
4384
|
}
|
|
4245
|
-
function
|
|
4385
|
+
function rs(e) {
|
|
4246
4386
|
let t;
|
|
4247
4387
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
4248
4388
|
let n = [`trigger: ${t}`];
|
|
@@ -4252,30 +4392,30 @@ function Ro(e) {
|
|
|
4252
4392
|
}
|
|
4253
4393
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
4254
4394
|
}
|
|
4255
|
-
function
|
|
4395
|
+
function is(e) {
|
|
4256
4396
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
4257
4397
|
}
|
|
4258
|
-
var
|
|
4398
|
+
var as = {
|
|
4259
4399
|
claude: {
|
|
4260
4400
|
rulesDir: ".claude/rules",
|
|
4261
4401
|
extension: ".md",
|
|
4262
|
-
convert:
|
|
4402
|
+
convert: ns
|
|
4263
4403
|
},
|
|
4264
4404
|
windsurf: {
|
|
4265
4405
|
rulesDir: ".windsurf/rules",
|
|
4266
4406
|
extension: ".md",
|
|
4267
|
-
convert:
|
|
4407
|
+
convert: rs
|
|
4268
4408
|
},
|
|
4269
4409
|
copilot: {
|
|
4270
4410
|
rulesDir: ".github/instructions",
|
|
4271
4411
|
extension: ".instructions.md",
|
|
4272
|
-
convert:
|
|
4412
|
+
convert: is
|
|
4273
4413
|
}
|
|
4274
4414
|
};
|
|
4275
|
-
async function
|
|
4415
|
+
async function os(e) {
|
|
4276
4416
|
let t = T.join(e, ie), n = (await y.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
4277
4417
|
return await Promise.all(n.map(async (e) => {
|
|
4278
|
-
let n = T.join(t, e.name), { frontmatter: r, content: i } =
|
|
4418
|
+
let n = T.join(t, e.name), { frontmatter: r, content: i } = ts(await y.readFile(n, "utf-8"));
|
|
4279
4419
|
return {
|
|
4280
4420
|
frontmatter: r,
|
|
4281
4421
|
content: i,
|
|
@@ -4283,9 +4423,9 @@ async function Vo(e) {
|
|
|
4283
4423
|
};
|
|
4284
4424
|
}));
|
|
4285
4425
|
}
|
|
4286
|
-
async function
|
|
4426
|
+
async function ss(e, t) {
|
|
4287
4427
|
if (t === "cursor") return;
|
|
4288
|
-
let n =
|
|
4428
|
+
let n = as[t], r = await os(e), i = T.join(e, n.rulesDir);
|
|
4289
4429
|
await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
4290
4430
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
4291
4431
|
return y.writeFile(T.join(i, r), t, "utf-8");
|
|
@@ -4293,21 +4433,21 @@ async function Ho(e, t) {
|
|
|
4293
4433
|
}
|
|
4294
4434
|
//#endregion
|
|
4295
4435
|
//#region src/core/env-files.ts
|
|
4296
|
-
var
|
|
4436
|
+
var cs = [
|
|
4297
4437
|
"apps",
|
|
4298
4438
|
"packages",
|
|
4299
4439
|
"libs",
|
|
4300
4440
|
"shared"
|
|
4301
4441
|
];
|
|
4302
|
-
async function
|
|
4303
|
-
let t = await
|
|
4442
|
+
async function ls(e) {
|
|
4443
|
+
let t = await us(e);
|
|
4304
4444
|
return (await Promise.all(t.map(async (t) => {
|
|
4305
4445
|
let n = T.join(T.dirname(t), ".env");
|
|
4306
4446
|
return await Y(n) ? null : (await y.copyFile(t, n), T.relative(e, n));
|
|
4307
4447
|
}))).filter((e) => e !== null).sort();
|
|
4308
4448
|
}
|
|
4309
|
-
async function
|
|
4310
|
-
let t = [T.join(e, ".env.example")], n = await Promise.all(
|
|
4449
|
+
async function us(e) {
|
|
4450
|
+
let t = [T.join(e, ".env.example")], n = await Promise.all(cs.map(async (t) => {
|
|
4311
4451
|
let n = T.join(e, t);
|
|
4312
4452
|
return (await y.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => T.join(n, e.name, ".env.example"));
|
|
4313
4453
|
}));
|
|
@@ -4315,12 +4455,12 @@ async function Go(e) {
|
|
|
4315
4455
|
}
|
|
4316
4456
|
//#endregion
|
|
4317
4457
|
//#region src/core/post-clone.ts
|
|
4318
|
-
var Q = "@hype-stack/",
|
|
4319
|
-
async function
|
|
4458
|
+
var Q = "@hype-stack/", ds = "hype-stack", fs = "@hype-stack/cli";
|
|
4459
|
+
async function ps(e) {
|
|
4320
4460
|
await mr(T.join(e, ".git"));
|
|
4321
4461
|
}
|
|
4322
|
-
async function
|
|
4323
|
-
await
|
|
4462
|
+
async function ms(e) {
|
|
4463
|
+
await q("git", ["init"], { cwd: e }), await q("git", ["add", "."], { cwd: e }), await q("git", [
|
|
4324
4464
|
"-c",
|
|
4325
4465
|
"user.name=Hype Stack CLI",
|
|
4326
4466
|
"-c",
|
|
@@ -4330,19 +4470,19 @@ async function Yo(e) {
|
|
|
4330
4470
|
"Initial commit from Hype Stack CLI"
|
|
4331
4471
|
], { cwd: e });
|
|
4332
4472
|
}
|
|
4333
|
-
async function
|
|
4334
|
-
let n = `@${t}/`, r = await
|
|
4473
|
+
async function hs(e, t) {
|
|
4474
|
+
let n = `@${t}/`, r = await Cs(e);
|
|
4335
4475
|
for (let e of r) {
|
|
4336
4476
|
let t = await dr(e);
|
|
4337
4477
|
if (!t) continue;
|
|
4338
4478
|
let r = !1;
|
|
4339
|
-
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0),
|
|
4479
|
+
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0), bs(t.dependencies, n) && (r = !0), bs(t.devDependencies, n) && (r = !0), t.nx && xs(t.nx, n) && (r = !0);
|
|
4340
4480
|
let i = await y.readFile(e, "utf-8"), a = ei(i, n);
|
|
4341
4481
|
a === i ? r && await fr(e, t) : await y.writeFile(e, a, "utf-8");
|
|
4342
4482
|
}
|
|
4343
|
-
await
|
|
4483
|
+
await Aa(e, t), await vs(e, t), await Ss(e, t);
|
|
4344
4484
|
}
|
|
4345
|
-
var
|
|
4485
|
+
var gs = new Set([
|
|
4346
4486
|
".git",
|
|
4347
4487
|
"node_modules",
|
|
4348
4488
|
"dist",
|
|
@@ -4350,10 +4490,10 @@ var Zo = new Set([
|
|
|
4350
4490
|
".nx",
|
|
4351
4491
|
".next",
|
|
4352
4492
|
"coverage"
|
|
4353
|
-
]),
|
|
4354
|
-
async function
|
|
4355
|
-
if (t ===
|
|
4356
|
-
let n = await
|
|
4493
|
+
]), _s = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
|
|
4494
|
+
async function vs(e, t) {
|
|
4495
|
+
if (t === ds) return;
|
|
4496
|
+
let n = await ys(e);
|
|
4357
4497
|
await Promise.all(n.map(async (e) => {
|
|
4358
4498
|
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
4359
4499
|
if (!n || !/^[ \t]*(?:name|container_name):[ \t]*hype-stack/m.test(n)) return;
|
|
@@ -4361,23 +4501,23 @@ async function $o(e, t) {
|
|
|
4361
4501
|
await y.writeFile(e, r, "utf-8");
|
|
4362
4502
|
}));
|
|
4363
4503
|
}
|
|
4364
|
-
async function
|
|
4504
|
+
async function ys(e) {
|
|
4365
4505
|
let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
4366
4506
|
return (await Promise.all(t.map(async (t) => {
|
|
4367
4507
|
let n = T.join(e, t.name);
|
|
4368
|
-
return t.isDirectory() ?
|
|
4508
|
+
return t.isDirectory() ? gs.has(t.name) ? [] : ys(n) : t.isFile() && _s.test(t.name) ? [n] : [];
|
|
4369
4509
|
}))).flat();
|
|
4370
4510
|
}
|
|
4371
|
-
function
|
|
4511
|
+
function bs(e, t) {
|
|
4372
4512
|
if (!e) return !1;
|
|
4373
4513
|
let n = !1;
|
|
4374
|
-
for (let r of Object.keys(e)) if (r !==
|
|
4514
|
+
for (let r of Object.keys(e)) if (r !== fs && r.startsWith(Q)) {
|
|
4375
4515
|
let i = r.replace(Q, t);
|
|
4376
4516
|
e[i] = e[r], delete e[r], n = !0;
|
|
4377
4517
|
}
|
|
4378
4518
|
return n;
|
|
4379
4519
|
}
|
|
4380
|
-
function
|
|
4520
|
+
function xs(e, t) {
|
|
4381
4521
|
if (!e) return !1;
|
|
4382
4522
|
let n = !1;
|
|
4383
4523
|
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Q) ? (n = !0, e.replace(Q, t)) : e), e.targets) {
|
|
@@ -4385,13 +4525,13 @@ function ns(e, t) {
|
|
|
4385
4525
|
}
|
|
4386
4526
|
return n;
|
|
4387
4527
|
}
|
|
4388
|
-
async function
|
|
4528
|
+
async function Ss(e, t) {
|
|
4389
4529
|
let n = T.join(e, "packages/enums/src/app/index.ts"), r = await y.readFile(n, "utf-8").catch(() => null);
|
|
4390
4530
|
if (!r) return;
|
|
4391
|
-
let i = Cr(t), a = r.replaceAll(`id: "${
|
|
4531
|
+
let i = Cr(t), a = r.replaceAll(`id: "${ds}"`, `id: "${t}"`).replaceAll(`name: "${ds}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
|
|
4392
4532
|
await y.writeFile(n, a, "utf-8");
|
|
4393
4533
|
}
|
|
4394
|
-
async function
|
|
4534
|
+
async function Cs(e) {
|
|
4395
4535
|
let t = [], n = T.join(e, "package.json");
|
|
4396
4536
|
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
4397
4537
|
for (let n of [
|
|
@@ -4411,7 +4551,7 @@ async function is(e) {
|
|
|
4411
4551
|
}
|
|
4412
4552
|
//#endregion
|
|
4413
4553
|
//#region src/core/readme.ts
|
|
4414
|
-
var
|
|
4554
|
+
var ws = {
|
|
4415
4555
|
cursor: {
|
|
4416
4556
|
label: "Cursor",
|
|
4417
4557
|
rulesDir: ".cursor/rules"
|
|
@@ -4428,21 +4568,21 @@ var as = {
|
|
|
4428
4568
|
label: "GitHub Copilot",
|
|
4429
4569
|
rulesDir: ".github/instructions"
|
|
4430
4570
|
}
|
|
4431
|
-
},
|
|
4571
|
+
}, Ts = {
|
|
4432
4572
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
4433
4573
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
4434
|
-
},
|
|
4574
|
+
}, Es = {
|
|
4435
4575
|
enums: "Shared enums and app config used across apps",
|
|
4436
4576
|
cli: "Project tooling and code generators"
|
|
4437
4577
|
};
|
|
4438
|
-
function
|
|
4578
|
+
function Ds(e, t) {
|
|
4439
4579
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
4440
4580
|
let r = t[e];
|
|
4441
4581
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4442
4582
|
});
|
|
4443
4583
|
}
|
|
4444
|
-
function
|
|
4445
|
-
let { projectName: t, editor: n, workspace: r } = e, i = Cr(t), a =
|
|
4584
|
+
function Os(e) {
|
|
4585
|
+
let { projectName: t, editor: n, workspace: r } = e, i = Cr(t), a = ws[n], o = !!r.apps.backend, s = Ds(r.apps, Ts), c = Ds(r.packages, Es), l = [];
|
|
4446
4586
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
4447
4587
|
let u = [];
|
|
4448
4588
|
u.push(`# ${i}`), u.push([
|
|
@@ -4545,27 +4685,82 @@ function ls(e) {
|
|
|
4545
4685
|
"stays useful."
|
|
4546
4686
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4547
4687
|
}
|
|
4548
|
-
async function
|
|
4688
|
+
async function ks(e, t) {
|
|
4549
4689
|
let n = T.join(e, "README.md");
|
|
4550
|
-
await y.writeFile(n,
|
|
4690
|
+
await y.writeFile(n, Os(t), "utf-8");
|
|
4551
4691
|
}
|
|
4552
4692
|
//#endregion
|
|
4553
4693
|
//#region src/core/tracking.ts
|
|
4554
|
-
async function
|
|
4694
|
+
async function As(e) {
|
|
4555
4695
|
try {
|
|
4556
4696
|
let t = {
|
|
4557
|
-
"X-Device-Id":
|
|
4558
|
-
"X-Client-Info":
|
|
4559
|
-
}, n = await
|
|
4560
|
-
n?.token && (t.Authorization = `Bearer ${n.token}`), await
|
|
4697
|
+
"X-Device-Id": tr(),
|
|
4698
|
+
"X-Client-Info": nr()
|
|
4699
|
+
}, n = await Zn(L()).catch(() => null);
|
|
4700
|
+
n?.token && (t.Authorization = `Bearer ${n.token}`), await K.createRequest()({
|
|
4561
4701
|
endpoint: "/cli/track",
|
|
4562
4702
|
method: "POST"
|
|
4563
4703
|
}).setPayload({ event: e }).setHeaders(t).send();
|
|
4564
4704
|
} catch {}
|
|
4565
4705
|
}
|
|
4566
4706
|
//#endregion
|
|
4707
|
+
//#region src/ui/swatch.ts
|
|
4708
|
+
function js(e) {
|
|
4709
|
+
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4710
|
+
if (!t) return null;
|
|
4711
|
+
let n = t[1].trim().split(/\s+/);
|
|
4712
|
+
if (n.length < 3) return null;
|
|
4713
|
+
let r = n[0], i = Number(n[1]), a = Number(n[2]);
|
|
4714
|
+
if (Number.isNaN(i) || Number.isNaN(a)) return null;
|
|
4715
|
+
let o;
|
|
4716
|
+
if (r.endsWith("%")) {
|
|
4717
|
+
let e = Number(r.slice(0, -1));
|
|
4718
|
+
if (Number.isNaN(e)) return null;
|
|
4719
|
+
o = e / 100;
|
|
4720
|
+
} else if (o = Number(r), Number.isNaN(o)) return null;
|
|
4721
|
+
return {
|
|
4722
|
+
l: o,
|
|
4723
|
+
c: i,
|
|
4724
|
+
h: a
|
|
4725
|
+
};
|
|
4726
|
+
}
|
|
4727
|
+
function Ms(e) {
|
|
4728
|
+
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4729
|
+
}
|
|
4730
|
+
function Ns(e) {
|
|
4731
|
+
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4732
|
+
}
|
|
4733
|
+
function Ps({ l: e, c: t, h: n }) {
|
|
4734
|
+
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
|
+
return [
|
|
4736
|
+
Ms(Ns(f) * 255),
|
|
4737
|
+
Ms(Ns(p) * 255),
|
|
4738
|
+
Ms(Ns(m) * 255)
|
|
4739
|
+
];
|
|
4740
|
+
}
|
|
4741
|
+
var Fs = "\x1B[49m";
|
|
4742
|
+
function Is(e, t) {
|
|
4743
|
+
let n = e[t];
|
|
4744
|
+
if (!n) return b.dim(" ");
|
|
4745
|
+
let r = js(n);
|
|
4746
|
+
if (!r) return b.dim(" ");
|
|
4747
|
+
let [i, a, o] = Ps(r);
|
|
4748
|
+
return `\x1b[48;2;${i};${a};${o}m ${Fs}`;
|
|
4749
|
+
}
|
|
4750
|
+
var Ls = [
|
|
4751
|
+
"primary",
|
|
4752
|
+
"secondary",
|
|
4753
|
+
"accent"
|
|
4754
|
+
];
|
|
4755
|
+
function Rs(e) {
|
|
4756
|
+
return Ls.map((t) => Is(e, t)).join("");
|
|
4757
|
+
}
|
|
4758
|
+
function zs(e) {
|
|
4759
|
+
return `${Rs(e.light)} ${b.dim("·")} ${Rs(e.dark)}`;
|
|
4760
|
+
}
|
|
4761
|
+
//#endregion
|
|
4567
4762
|
//#region src/core/npm-deps.ts
|
|
4568
|
-
function
|
|
4763
|
+
function Bs(e, t) {
|
|
4569
4764
|
let n = [], r = [];
|
|
4570
4765
|
if (!e) return {
|
|
4571
4766
|
errors: n,
|
|
@@ -4596,7 +4791,7 @@ function fs(e, t) {
|
|
|
4596
4791
|
operations: r
|
|
4597
4792
|
};
|
|
4598
4793
|
}
|
|
4599
|
-
function
|
|
4794
|
+
function Vs(e) {
|
|
4600
4795
|
let t = {};
|
|
4601
4796
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4602
4797
|
...t[e],
|
|
@@ -4604,7 +4799,7 @@ function ps(e) {
|
|
|
4604
4799
|
};
|
|
4605
4800
|
return t;
|
|
4606
4801
|
}
|
|
4607
|
-
async function
|
|
4802
|
+
async function Hs(e, t, n = q) {
|
|
4608
4803
|
let r = [];
|
|
4609
4804
|
for (let i of e) {
|
|
4610
4805
|
let e = T.join(t, i.relativeDir);
|
|
@@ -4640,22 +4835,22 @@ async function ms(e, t, n = J) {
|
|
|
4640
4835
|
function $(e) {
|
|
4641
4836
|
return e instanceof Error ? e.message : String(e);
|
|
4642
4837
|
}
|
|
4643
|
-
async function
|
|
4838
|
+
async function Us(e, t, n) {
|
|
4644
4839
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4645
4840
|
return r.length === 0 ? {} : Yr(r, n).catch(() => ({}));
|
|
4646
4841
|
}
|
|
4647
|
-
function
|
|
4842
|
+
function Ws(e, t) {
|
|
4648
4843
|
return e === "free" ? R.success("free") : e === "owned" ? R.accent("owned") : `${R.highlight(`$${t}`)} ${R.muted("locked")}`;
|
|
4649
4844
|
}
|
|
4650
|
-
async function
|
|
4845
|
+
async function Gs(e, t, n) {
|
|
4651
4846
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4652
|
-
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
|
|
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 cr(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4653
4848
|
name: e.name,
|
|
4654
4849
|
displayName: e.displayName,
|
|
4655
4850
|
price: e.price
|
|
4656
4851
|
})));
|
|
4657
4852
|
}
|
|
4658
|
-
function
|
|
4853
|
+
function Ks(e, t) {
|
|
4659
4854
|
B([
|
|
4660
4855
|
"These packs will be installed, in order:",
|
|
4661
4856
|
"",
|
|
@@ -4665,7 +4860,7 @@ function vs(e, t) {
|
|
|
4665
4860
|
})
|
|
4666
4861
|
].join("\n"), "Install Plan");
|
|
4667
4862
|
}
|
|
4668
|
-
async function
|
|
4863
|
+
async function qs(e, t) {
|
|
4669
4864
|
let n = [];
|
|
4670
4865
|
for (let r of e) {
|
|
4671
4866
|
let e = await Ur(r), i = await Wr(r, t);
|
|
@@ -4677,18 +4872,18 @@ async function ys(e, t) {
|
|
|
4677
4872
|
}
|
|
4678
4873
|
return n;
|
|
4679
4874
|
}
|
|
4680
|
-
async function
|
|
4681
|
-
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a =
|
|
4875
|
+
async function Js(e) {
|
|
4876
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = Bs(Vs(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4682
4877
|
if (a.errors.length > 0) {
|
|
4683
4878
|
for (let e of a.errors) s.log.error(e);
|
|
4684
4879
|
return;
|
|
4685
4880
|
}
|
|
4686
4881
|
if (a.operations.length === 0) return;
|
|
4687
4882
|
i.start("Installing npm dependencies...");
|
|
4688
|
-
let o = await
|
|
4883
|
+
let o = await Hs(a.operations, r);
|
|
4689
4884
|
if (i.stop(o.ok ? "npm dependencies installed" : "npm dependency installation failed"), !o.ok) for (let e of o.errors) s.log.error(e);
|
|
4690
4885
|
}
|
|
4691
|
-
function
|
|
4886
|
+
function Ys() {
|
|
4692
4887
|
we([{
|
|
4693
4888
|
command: "npx @hype-stack/cli onboard",
|
|
4694
4889
|
hint: "(set up env vars + run migrations)"
|
|
@@ -4697,7 +4892,7 @@ function xs() {
|
|
|
4697
4892
|
hint: "(start frontend + backend)"
|
|
4698
4893
|
}]);
|
|
4699
4894
|
}
|
|
4700
|
-
function
|
|
4895
|
+
function Xs(e) {
|
|
4701
4896
|
if (e.length === 0) return;
|
|
4702
4897
|
let t = e.map((e) => {
|
|
4703
4898
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
@@ -4705,10 +4900,10 @@ function Ss(e) {
|
|
|
4705
4900
|
});
|
|
4706
4901
|
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4707
4902
|
}
|
|
4708
|
-
async function
|
|
4903
|
+
async function Zs(e) {
|
|
4709
4904
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
|
|
4710
4905
|
if (i) return c;
|
|
4711
|
-
let l = await
|
|
4906
|
+
let l = await Ba({
|
|
4712
4907
|
packs: t,
|
|
4713
4908
|
config: n,
|
|
4714
4909
|
projectRoot: r,
|
|
@@ -4734,74 +4929,19 @@ async function Cs(e) {
|
|
|
4734
4929
|
return c;
|
|
4735
4930
|
}
|
|
4736
4931
|
//#endregion
|
|
4737
|
-
//#region src/ui/swatch.ts
|
|
4738
|
-
function ws(e) {
|
|
4739
|
-
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4740
|
-
if (!t) return null;
|
|
4741
|
-
let n = t[1].trim().split(/\s+/);
|
|
4742
|
-
if (n.length < 3) return null;
|
|
4743
|
-
let r = n[0], i = Number(n[1]), a = Number(n[2]);
|
|
4744
|
-
if (Number.isNaN(i) || Number.isNaN(a)) return null;
|
|
4745
|
-
let o;
|
|
4746
|
-
if (r.endsWith("%")) {
|
|
4747
|
-
let e = Number(r.slice(0, -1));
|
|
4748
|
-
if (Number.isNaN(e)) return null;
|
|
4749
|
-
o = e / 100;
|
|
4750
|
-
} else if (o = Number(r), Number.isNaN(o)) return null;
|
|
4751
|
-
return {
|
|
4752
|
-
l: o,
|
|
4753
|
-
c: i,
|
|
4754
|
-
h: a
|
|
4755
|
-
};
|
|
4756
|
-
}
|
|
4757
|
-
function Ts(e) {
|
|
4758
|
-
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4759
|
-
}
|
|
4760
|
-
function Es(e) {
|
|
4761
|
-
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4762
|
-
}
|
|
4763
|
-
function Ds({ l: e, c: t, h: n }) {
|
|
4764
|
-
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;
|
|
4765
|
-
return [
|
|
4766
|
-
Ts(Es(f) * 255),
|
|
4767
|
-
Ts(Es(p) * 255),
|
|
4768
|
-
Ts(Es(m) * 255)
|
|
4769
|
-
];
|
|
4770
|
-
}
|
|
4771
|
-
var Os = "\x1B[49m";
|
|
4772
|
-
function ks(e, t) {
|
|
4773
|
-
let n = e[t];
|
|
4774
|
-
if (!n) return b.dim(" ");
|
|
4775
|
-
let r = ws(n);
|
|
4776
|
-
if (!r) return b.dim(" ");
|
|
4777
|
-
let [i, a, o] = Ds(r);
|
|
4778
|
-
return `\x1b[48;2;${i};${a};${o}m ${Os}`;
|
|
4779
|
-
}
|
|
4780
|
-
var As = [
|
|
4781
|
-
"primary",
|
|
4782
|
-
"secondary",
|
|
4783
|
-
"accent"
|
|
4784
|
-
];
|
|
4785
|
-
function js(e) {
|
|
4786
|
-
return As.map((t) => ks(e, t)).join("");
|
|
4787
|
-
}
|
|
4788
|
-
function Ms(e) {
|
|
4789
|
-
return `${js(e.light)} ${b.dim("·")} ${js(e.dark)}`;
|
|
4790
|
-
}
|
|
4791
|
-
//#endregion
|
|
4792
4932
|
//#region src/commands/create.ts
|
|
4793
|
-
async function
|
|
4794
|
-
e.skipBanner ||
|
|
4933
|
+
async function Qs(e) {
|
|
4934
|
+
e.skipBanner || Po(), s.intro(R.brandBold("Create a new Hype Stack project"));
|
|
4795
4935
|
let o = e.yes === !0, c, l;
|
|
4796
4936
|
if (o && e.name) {
|
|
4797
|
-
let t =
|
|
4937
|
+
let t = Ro(e.name);
|
|
4798
4938
|
t && (s.log.error(t), V()), l = e.name, c = Sr(e.name);
|
|
4799
4939
|
} else {
|
|
4800
4940
|
let t = await s.text({
|
|
4801
4941
|
message: "What is your project named?",
|
|
4802
4942
|
placeholder: "my-app",
|
|
4803
4943
|
initialValue: e.name ?? "",
|
|
4804
|
-
validate: (e) =>
|
|
4944
|
+
validate: (e) => Ro(e ?? "")
|
|
4805
4945
|
});
|
|
4806
4946
|
s.isCancel(t) && V(), l = t, c = Sr(l);
|
|
4807
4947
|
}
|
|
@@ -4847,65 +4987,79 @@ async function Ns(e) {
|
|
|
4847
4987
|
message: "Pick a color theme",
|
|
4848
4988
|
options: r.map((e) => ({
|
|
4849
4989
|
value: e.name,
|
|
4850
|
-
label: `${
|
|
4990
|
+
label: `${zs(e)} ${e.label}`
|
|
4851
4991
|
})),
|
|
4852
4992
|
initialValue: h
|
|
4853
4993
|
});
|
|
4854
4994
|
s.isCancel(e) && V(), g = e;
|
|
4855
4995
|
}
|
|
4996
|
+
let _ = e.adminTheme !== void 0 && a(e.adminTheme), v;
|
|
4997
|
+
if (_) v = e.adminTheme;
|
|
4998
|
+
else if (o) v = g;
|
|
4999
|
+
else {
|
|
5000
|
+
let e = await s.select({
|
|
5001
|
+
message: "Pick a color theme for the admin app",
|
|
5002
|
+
options: r.map((e) => ({
|
|
5003
|
+
value: e.name,
|
|
5004
|
+
label: `${zs(e)} ${e.label}`
|
|
5005
|
+
})),
|
|
5006
|
+
initialValue: g
|
|
5007
|
+
});
|
|
5008
|
+
s.isCancel(e) && V(), v = e;
|
|
5009
|
+
}
|
|
4856
5010
|
if (!o) {
|
|
4857
|
-
let e = I.find((e) => e.value === p)?.label ?? p, t = n.find((e) => e.value === g)?.label ?? g, r = await s.confirm({ message: `Create ${R.highlight(c)} in ${R.path(d)} with ${R.highlight(e)} config and the ${R.highlight(
|
|
4858
|
-
(s.isCancel(
|
|
5011
|
+
let e = I.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
|
+
(s.isCancel(i) || !i) && V();
|
|
4859
5013
|
}
|
|
4860
|
-
if (await
|
|
5014
|
+
if (await J(d) && !await ur(d)) {
|
|
4861
5015
|
let e = await s.confirm({
|
|
4862
5016
|
message: `Directory ${R.path(d)} is not empty. Continue anyway?`,
|
|
4863
5017
|
initialValue: !1
|
|
4864
5018
|
});
|
|
4865
5019
|
(s.isCancel(e) || !e) && V();
|
|
4866
5020
|
}
|
|
4867
|
-
let
|
|
4868
|
-
|
|
4869
|
-
let
|
|
4870
|
-
|
|
4871
|
-
let
|
|
4872
|
-
await Rr(d,
|
|
5021
|
+
let y = s.spinner();
|
|
5022
|
+
y.start("Cloning Hype Stack template..."), await es(d), y.stop(R.success("Template cloned"));
|
|
5023
|
+
let b = s.spinner();
|
|
5024
|
+
b.start("Setting up project..."), await ps(d), await hs(d, c), await ss(d, p);
|
|
5025
|
+
let x = await zr(d), S = Vr(c, x);
|
|
5026
|
+
await Rr(d, S), await ks(d, {
|
|
4873
5027
|
projectName: c,
|
|
4874
5028
|
editor: p,
|
|
4875
|
-
workspace:
|
|
5029
|
+
workspace: x
|
|
4876
5030
|
});
|
|
4877
|
-
let
|
|
4878
|
-
a(g) && (await
|
|
4879
|
-
let S = s.spinner();
|
|
4880
|
-
S.start("Installing dependencies..."), (await J("pnpm", ["install"], { cwd: d })).exitCode === 0 ? S.stop(R.success("Dependencies installed")) : (S.stop(R.warning("Dependencies installed with warnings")), s.log.warn(R.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4881
|
-
let C = s.spinner();
|
|
4882
|
-
C.start("Initializing git repository..."), await Yo(d), C.stop(R.success("Git repository initialized with clean history"));
|
|
5031
|
+
let C = T.resolve(d, S.paths?.frontend.root ?? "apps/frontend");
|
|
5032
|
+
a(g) && (await $o(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 $o(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 && Wo(e.radius) && (await qo(C, e.radius) || s.log.warn(R.muted(`Could not find ${R.path("assets/styles.css")} to set the corner radius`))), await Ho(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"));
|
|
4883
5033
|
let w = s.spinner();
|
|
4884
|
-
w.start("
|
|
4885
|
-
let E =
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
5034
|
+
w.start("Installing dependencies..."), (await q("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
|
+
let E = s.spinner();
|
|
5036
|
+
E.start("Initializing git repository..."), await ms(d), E.stop(R.success("Git repository initialized with clean history"));
|
|
5037
|
+
let D = s.spinner();
|
|
5038
|
+
D.start("Creating .env files from examples...");
|
|
5039
|
+
let O = await ls(d);
|
|
5040
|
+
if (O.length > 0) {
|
|
5041
|
+
let e = O.length;
|
|
5042
|
+
D.stop(R.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
5043
|
+
} else D.stop(R.muted("No .env.example files to copy"));
|
|
4890
5044
|
s.log.success(`${R.brandBold("Hype Stack")} project ${R.highlight(c)} is ready!`);
|
|
4891
|
-
let
|
|
4892
|
-
|
|
4893
|
-
let
|
|
5045
|
+
let k = T.relative(process.cwd(), d) || ".", A = [{ command: R.command(`cd ${k}`) }];
|
|
5046
|
+
O.length > 0 ? A.push({ command: `Review your ${R.path(".env")} files and fill in any secrets` }) : A.push({ command: `Copy ${R.path(".env.example")} to ${R.path(".env")} and configure` }), we(A);
|
|
5047
|
+
let j = e.setup === !1;
|
|
4894
5048
|
if (e.deferSetup) s.log.info(R.muted("Docker and migrations will run after your packs are installed."));
|
|
4895
5049
|
else {
|
|
4896
|
-
let e = !
|
|
5050
|
+
let e = !j && (o || await s.confirm({
|
|
4897
5051
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
4898
5052
|
initialValue: !0
|
|
4899
5053
|
}));
|
|
4900
|
-
s.isCancel(e) && V(), e ? await
|
|
5054
|
+
s.isCancel(e) && V(), e ? await ho(d, o) : s.log.info(R.muted("Docker and migrations can run later via `npx @hype-stack/cli onboard`.")), Ys();
|
|
4901
5055
|
}
|
|
4902
|
-
return await
|
|
5056
|
+
return await As("project_create"), s.outro(R.muted("Happy building!")), d;
|
|
4903
5057
|
}
|
|
4904
5058
|
//#endregion
|
|
4905
5059
|
//#region src/commands/init.ts
|
|
4906
|
-
async function
|
|
5060
|
+
async function $s(e) {
|
|
4907
5061
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4908
|
-
if (n || (
|
|
5062
|
+
if (n || (Fo(), s.intro(R.brandBold("Initialize Hype Stack configuration"))), !await Hr(t)) {
|
|
4909
5063
|
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.`));
|
|
4910
5064
|
return;
|
|
4911
5065
|
}
|
|
@@ -4942,21 +5096,21 @@ async function Ps(e) {
|
|
|
4942
5096
|
message: "Project name for stack.json?",
|
|
4943
5097
|
placeholder: i,
|
|
4944
5098
|
initialValue: i,
|
|
4945
|
-
validate: (e) =>
|
|
5099
|
+
validate: (e) => Ro(e ?? "")
|
|
4946
5100
|
});
|
|
4947
5101
|
s.isCancel(e) && V(), a = Sr(e);
|
|
4948
5102
|
}
|
|
4949
5103
|
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.")));
|
|
4950
5104
|
}
|
|
4951
|
-
async function
|
|
5105
|
+
async function ec(e, t = {}, n) {
|
|
4952
5106
|
if (await Lr(e)) return {
|
|
4953
5107
|
projectRoot: e,
|
|
4954
5108
|
scaffolded: !1
|
|
4955
5109
|
};
|
|
4956
|
-
let r = t.runInit ?? ((e) =>
|
|
5110
|
+
let r = t.runInit ?? ((e) => $s({
|
|
4957
5111
|
cwd: e,
|
|
4958
5112
|
silent: !0
|
|
4959
|
-
})), i = t.runCreate ?? ((e, t) =>
|
|
5113
|
+
})), i = t.runCreate ?? ((e, t) => Qs({
|
|
4960
5114
|
parentDirectory: e,
|
|
4961
5115
|
deferSetup: !0,
|
|
4962
5116
|
skipBanner: !0,
|
|
@@ -4997,10 +5151,10 @@ async function Fs(e, t = {}, n) {
|
|
|
4997
5151
|
}
|
|
4998
5152
|
//#endregion
|
|
4999
5153
|
//#region src/commands/compose.ts
|
|
5000
|
-
async function
|
|
5154
|
+
async function tc(e = {}) {
|
|
5001
5155
|
let t = e.cwd ?? process.cwd();
|
|
5002
|
-
|
|
5003
|
-
let n = await
|
|
5156
|
+
Po();
|
|
5157
|
+
let n = await ec(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
5004
5158
|
try {
|
|
5005
5159
|
a = await Ir(r ?? t);
|
|
5006
5160
|
} catch (e) {
|
|
@@ -5018,13 +5172,13 @@ async function Is(e = {}) {
|
|
|
5018
5172
|
c.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
5019
5173
|
}
|
|
5020
5174
|
c.stop("Packs loaded");
|
|
5021
|
-
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
|
|
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 Zn(L()))?.token ?? null, h = await Us(l, d, {
|
|
5022
5176
|
token: m,
|
|
5023
5177
|
key: p
|
|
5024
5178
|
}), g = (e) => {
|
|
5025
5179
|
let t = f.get(e);
|
|
5026
5180
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
5027
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await
|
|
5181
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await nc({
|
|
5028
5182
|
packs: l,
|
|
5029
5183
|
installedSet: d,
|
|
5030
5184
|
stateOf: g,
|
|
@@ -5035,9 +5189,9 @@ async function Is(e = {}) {
|
|
|
5035
5189
|
s.outro(R.muted("No packs selected. Nothing to do."));
|
|
5036
5190
|
return;
|
|
5037
5191
|
}
|
|
5038
|
-
let b =
|
|
5192
|
+
let b = oc(v), x = sc(v), S = wo(l, b), C = _o(To(l, S)), w;
|
|
5039
5193
|
try {
|
|
5040
|
-
w =
|
|
5194
|
+
w = yo(b, C, u);
|
|
5041
5195
|
} catch (e) {
|
|
5042
5196
|
s.cancel($(e)), process.exit(1);
|
|
5043
5197
|
}
|
|
@@ -5045,36 +5199,36 @@ async function Is(e = {}) {
|
|
|
5045
5199
|
B(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(R.muted("Your selection is already part of the project."));
|
|
5046
5200
|
return;
|
|
5047
5201
|
}
|
|
5048
|
-
let T =
|
|
5202
|
+
let T = bo({
|
|
5049
5203
|
order: w.order,
|
|
5050
5204
|
graph: C,
|
|
5051
5205
|
isLocked: _,
|
|
5052
5206
|
installed: u
|
|
5053
5207
|
});
|
|
5054
5208
|
if (T.blocked.length > 0 && !m && !p) {
|
|
5055
|
-
let e = await
|
|
5056
|
-
e && (m = e, h = await
|
|
5209
|
+
let e = await sr();
|
|
5210
|
+
e && (m = e, h = await Us(l, d, {
|
|
5057
5211
|
token: m,
|
|
5058
5212
|
key: p
|
|
5059
|
-
}), T =
|
|
5213
|
+
}), T = bo({
|
|
5060
5214
|
order: w.order,
|
|
5061
5215
|
graph: C,
|
|
5062
5216
|
isLocked: _,
|
|
5063
5217
|
installed: u
|
|
5064
5218
|
}));
|
|
5065
5219
|
}
|
|
5066
|
-
if (T.blocked.length > 0 && await
|
|
5220
|
+
if (T.blocked.length > 0 && await Gs(T.blocked, _, f), T.installable.length === 0) {
|
|
5067
5221
|
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
5068
5222
|
return;
|
|
5069
5223
|
}
|
|
5070
|
-
if (
|
|
5224
|
+
if (Ks(T.installable, f), !e.yes) {
|
|
5071
5225
|
let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
5072
5226
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5073
5227
|
}
|
|
5074
5228
|
c.start("Downloading packs...");
|
|
5075
5229
|
let E;
|
|
5076
5230
|
try {
|
|
5077
|
-
E = await
|
|
5231
|
+
E = await qs(T.installable, {
|
|
5078
5232
|
token: m,
|
|
5079
5233
|
key: p
|
|
5080
5234
|
});
|
|
@@ -5082,7 +5236,7 @@ async function Is(e = {}) {
|
|
|
5082
5236
|
c.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
5083
5237
|
}
|
|
5084
5238
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
5085
|
-
let D = await
|
|
5239
|
+
let D = await Zs({
|
|
5086
5240
|
prepared: E,
|
|
5087
5241
|
config: a,
|
|
5088
5242
|
cwd: o,
|
|
@@ -5092,7 +5246,7 @@ async function Is(e = {}) {
|
|
|
5092
5246
|
});
|
|
5093
5247
|
try {
|
|
5094
5248
|
c.start("Installing pack files...");
|
|
5095
|
-
let t = await
|
|
5249
|
+
let t = await Ua({
|
|
5096
5250
|
packs: E,
|
|
5097
5251
|
config: a,
|
|
5098
5252
|
projectRoot: o,
|
|
@@ -5105,22 +5259,22 @@ async function Is(e = {}) {
|
|
|
5105
5259
|
for (let e of t.errors) s.log.error(e);
|
|
5106
5260
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5107
5261
|
}
|
|
5108
|
-
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)`),
|
|
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)`), Xs(t.skipped));
|
|
5109
5263
|
for (let e of t.errors) s.log.error(e);
|
|
5110
|
-
await
|
|
5264
|
+
await Aa(o, a.name), await Js({
|
|
5111
5265
|
prepared: E,
|
|
5112
5266
|
paths: a.paths,
|
|
5113
5267
|
cwd: o,
|
|
5114
5268
|
spinner: c
|
|
5115
5269
|
});
|
|
5116
5270
|
let n;
|
|
5117
|
-
i && (n = await
|
|
5271
|
+
i && (n = await go(o, e.yes ?? !1)), await br({
|
|
5118
5272
|
projectRoot: o,
|
|
5119
5273
|
paths: a.paths,
|
|
5120
5274
|
skipPrompts: e.yes ?? !1,
|
|
5121
5275
|
dbReady: n,
|
|
5122
5276
|
freshScaffold: i
|
|
5123
|
-
}),
|
|
5277
|
+
}), Ys(), s.outro(R.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
5124
5278
|
} finally {
|
|
5125
5279
|
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
5126
5280
|
recursive: !0,
|
|
@@ -5128,12 +5282,12 @@ async function Is(e = {}) {
|
|
|
5128
5282
|
})));
|
|
5129
5283
|
}
|
|
5130
5284
|
}
|
|
5131
|
-
async function
|
|
5285
|
+
async function nc(e) {
|
|
5132
5286
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
5133
5287
|
if (i.packs && i.packs.length > 0) {
|
|
5134
|
-
let e = i.packs.map(
|
|
5288
|
+
let e = i.packs.map(ac), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
5135
5289
|
n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1));
|
|
5136
|
-
let r =
|
|
5290
|
+
let r = rc(e, t);
|
|
5137
5291
|
if (r.length > 0) {
|
|
5138
5292
|
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.";
|
|
5139
5293
|
s.cancel(`Layout${r.length === 1 ? "" : "s"} not compatible with the admin app: ${r.join(", ")}.${n}`), process.exit(1);
|
|
@@ -5146,13 +5300,13 @@ async function Ls(e) {
|
|
|
5146
5300
|
if (c.length === 0) return s.outro(R.muted("Every available pack is already installed.")), [];
|
|
5147
5301
|
let l = se();
|
|
5148
5302
|
B(c.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5149
|
-
let u =
|
|
5303
|
+
let u = Za(c, { adminAvailable: a }), d = [];
|
|
5150
5304
|
for (let e of u) {
|
|
5151
5305
|
let t = e.packs.map((e) => {
|
|
5152
5306
|
let t = r(e.name);
|
|
5153
5307
|
return {
|
|
5154
5308
|
value: e.name,
|
|
5155
|
-
label: `${e.displayName} ${
|
|
5309
|
+
label: `${e.displayName} ${Ws(t, e.price)}`,
|
|
5156
5310
|
hint: e.description
|
|
5157
5311
|
};
|
|
5158
5312
|
});
|
|
@@ -5169,7 +5323,7 @@ async function Ls(e) {
|
|
|
5169
5323
|
});
|
|
5170
5324
|
continue;
|
|
5171
5325
|
}
|
|
5172
|
-
let n = await
|
|
5326
|
+
let n = await Lo({
|
|
5173
5327
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
5174
5328
|
options: t,
|
|
5175
5329
|
required: !1
|
|
@@ -5179,7 +5333,7 @@ async function Ls(e) {
|
|
|
5179
5333
|
}
|
|
5180
5334
|
return d;
|
|
5181
5335
|
}
|
|
5182
|
-
function
|
|
5336
|
+
function rc(e, t) {
|
|
5183
5337
|
let n = [];
|
|
5184
5338
|
for (let r of e) {
|
|
5185
5339
|
if (r.slot !== "admin") continue;
|
|
@@ -5188,20 +5342,20 @@ function Rs(e, t) {
|
|
|
5188
5342
|
}
|
|
5189
5343
|
return n;
|
|
5190
5344
|
}
|
|
5191
|
-
var
|
|
5192
|
-
function
|
|
5193
|
-
let t = e.match(
|
|
5345
|
+
var ic = /@(frontend|admin)$/;
|
|
5346
|
+
function ac(e) {
|
|
5347
|
+
let t = e.match(ic);
|
|
5194
5348
|
return t ? {
|
|
5195
5349
|
name: e.slice(0, -t[0].length),
|
|
5196
5350
|
slot: t[1]
|
|
5197
5351
|
} : { name: e };
|
|
5198
5352
|
}
|
|
5199
|
-
function
|
|
5353
|
+
function oc(e) {
|
|
5200
5354
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
5201
5355
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
5202
5356
|
return n;
|
|
5203
5357
|
}
|
|
5204
|
-
function
|
|
5358
|
+
function sc(e) {
|
|
5205
5359
|
let t = /* @__PURE__ */ new Map();
|
|
5206
5360
|
for (let n of e) {
|
|
5207
5361
|
if (!n.slot) continue;
|
|
@@ -5212,11 +5366,11 @@ function Hs(e) {
|
|
|
5212
5366
|
}
|
|
5213
5367
|
//#endregion
|
|
5214
5368
|
//#region src/commands/login.ts
|
|
5215
|
-
async function
|
|
5216
|
-
|
|
5369
|
+
async function cc() {
|
|
5370
|
+
Fo(), s.intro(R.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
5217
5371
|
let e;
|
|
5218
5372
|
try {
|
|
5219
|
-
e = await
|
|
5373
|
+
e = await or({ onUrl: (e) => {
|
|
5220
5374
|
s.log.info(`If your browser didn't open, visit:\n ${R.path(e)}`);
|
|
5221
5375
|
} });
|
|
5222
5376
|
} catch (e) {
|
|
@@ -5226,18 +5380,18 @@ async function Us() {
|
|
|
5226
5380
|
}
|
|
5227
5381
|
//#endregion
|
|
5228
5382
|
//#region src/commands/logout.ts
|
|
5229
|
-
async function
|
|
5230
|
-
|
|
5231
|
-
let e = L(), t = await
|
|
5383
|
+
async function lc() {
|
|
5384
|
+
Fo(), s.intro(R.brandBold("Log out of Hype Stack"));
|
|
5385
|
+
let e = L(), t = await Zn(e);
|
|
5232
5386
|
if (!t) {
|
|
5233
5387
|
s.outro(R.muted("You're not logged in."));
|
|
5234
5388
|
return;
|
|
5235
5389
|
}
|
|
5236
|
-
await
|
|
5390
|
+
await Un(t.token).catch(() => null), await $n(e), s.outro(R.brand("Logged out."));
|
|
5237
5391
|
}
|
|
5238
5392
|
//#endregion
|
|
5239
5393
|
//#region src/core/onboard-env.ts
|
|
5240
|
-
function
|
|
5394
|
+
function uc(e) {
|
|
5241
5395
|
let t = [], n = "";
|
|
5242
5396
|
for (let r of e.split(/\r?\n/)) {
|
|
5243
5397
|
let e = r.trim();
|
|
@@ -5263,14 +5417,14 @@ function Gs(e) {
|
|
|
5263
5417
|
}
|
|
5264
5418
|
return t;
|
|
5265
5419
|
}
|
|
5266
|
-
function
|
|
5420
|
+
function dc(e) {
|
|
5267
5421
|
let t = e.trim();
|
|
5268
5422
|
if (t === "") return "";
|
|
5269
5423
|
if (t.length <= 4) return "•".repeat(t.length);
|
|
5270
5424
|
let n = Math.min(t.length - 4, 8);
|
|
5271
5425
|
return `${"•".repeat(n)}${t.slice(-4)}`;
|
|
5272
5426
|
}
|
|
5273
|
-
function
|
|
5427
|
+
function fc(e, t, n) {
|
|
5274
5428
|
let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
|
|
5275
5429
|
if (i) return e;
|
|
5276
5430
|
let r = e.trim();
|
|
@@ -5280,22 +5434,22 @@ function qs(e, t, n) {
|
|
|
5280
5434
|
});
|
|
5281
5435
|
return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
|
|
5282
5436
|
}
|
|
5283
|
-
async function
|
|
5437
|
+
async function pc(e) {
|
|
5284
5438
|
return await Y(e) ? y.readFile(e, "utf-8") : "";
|
|
5285
5439
|
}
|
|
5286
|
-
async function
|
|
5440
|
+
async function mc(e) {
|
|
5287
5441
|
let t = T.join(T.dirname(e), ".env");
|
|
5288
5442
|
return await Y(t) || await y.copyFile(e, t), t;
|
|
5289
5443
|
}
|
|
5290
|
-
async function
|
|
5291
|
-
let r =
|
|
5444
|
+
async function hc(e, t, n) {
|
|
5445
|
+
let r = fc(await pc(e), t, n);
|
|
5292
5446
|
await y.writeFile(e, r, "utf-8");
|
|
5293
5447
|
}
|
|
5294
5448
|
//#endregion
|
|
5295
5449
|
//#region src/commands/onboard.ts
|
|
5296
|
-
async function
|
|
5450
|
+
async function gc(e = {}) {
|
|
5297
5451
|
let t = e.cwd ?? process.cwd();
|
|
5298
|
-
|
|
5452
|
+
Po(), s.intro(R.brandBold("Onboard your stack"));
|
|
5299
5453
|
let n;
|
|
5300
5454
|
try {
|
|
5301
5455
|
n = await Ir(t);
|
|
@@ -5303,19 +5457,19 @@ async function Zs(e = {}) {
|
|
|
5303
5457
|
n = null;
|
|
5304
5458
|
}
|
|
5305
5459
|
n || (s.cancel(`${R.path("stack.json")} not found. Run ${R.command("npx @hype-stack/cli init")} first.`), process.exit(1));
|
|
5306
|
-
let r = n.installedPacks ?? [], i = n.onboarding?.envSections ?? [], a = await
|
|
5460
|
+
let r = n.installedPacks ?? [], i = n.onboarding?.envSections ?? [], a = await us(t);
|
|
5307
5461
|
a.length === 0 && s.log.warn(R.muted("No .env.example files found; skipping env setup."));
|
|
5308
|
-
for (let n of a) await
|
|
5462
|
+
for (let n of a) await _c({
|
|
5309
5463
|
examplePath: n,
|
|
5310
5464
|
projectRoot: t,
|
|
5311
5465
|
skipPrompts: e.yes ?? !1,
|
|
5312
5466
|
installedEnvSections: i
|
|
5313
5467
|
});
|
|
5314
5468
|
let o = Fr(r);
|
|
5315
|
-
o.length > 0 && B(o.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await
|
|
5469
|
+
o.length > 0 && B(o.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await bc(t, e.yes ?? !1), s.outro(R.brand(`All set. Run ${R.command("pnpm dev")} to start your app.`));
|
|
5316
5470
|
}
|
|
5317
|
-
async function
|
|
5318
|
-
let { examplePath: t, projectRoot: n, skipPrompts: r, installedEnvSections: i } = e, a = T.relative(n, t) || t, o = await
|
|
5471
|
+
async function _c(e) {
|
|
5472
|
+
let { examplePath: t, projectRoot: n, skipPrompts: r, installedEnvSections: i } = e, a = T.relative(n, t) || t, o = await mc(t), c = await pc(o), l = uc(await y.readFile(t, "utf-8")), u = R.path(a);
|
|
5319
5473
|
s.log.step(`Env: ${u}`);
|
|
5320
5474
|
for (let e of l) {
|
|
5321
5475
|
if (e.vars.length === 0) continue;
|
|
@@ -5331,7 +5485,7 @@ async function Qs(e) {
|
|
|
5331
5485
|
s.log.info(`${R.label(n.key)} ${R.muted("skipped (non-interactive)")}`);
|
|
5332
5486
|
continue;
|
|
5333
5487
|
}
|
|
5334
|
-
let e =
|
|
5488
|
+
let e = dc(vc(c, n.key)), i = await s.text({
|
|
5335
5489
|
message: `${R.label(n.key)}`,
|
|
5336
5490
|
placeholder: e ? `${e} ${R.muted("(Enter keeps this)")}` : t.hint
|
|
5337
5491
|
});
|
|
@@ -5341,31 +5495,31 @@ async function Qs(e) {
|
|
|
5341
5495
|
s.log.info(R.muted(`${n.key} unchanged.`));
|
|
5342
5496
|
continue;
|
|
5343
5497
|
}
|
|
5344
|
-
await
|
|
5498
|
+
await hc(o, n.key, a), s.log.success(`${n.key} saved`);
|
|
5345
5499
|
}
|
|
5346
5500
|
}
|
|
5347
5501
|
}
|
|
5348
|
-
function
|
|
5502
|
+
function vc(e, t) {
|
|
5349
5503
|
for (let n of e.split(/\r?\n/)) {
|
|
5350
|
-
let e = n.match(RegExp(`^${
|
|
5504
|
+
let e = n.match(RegExp(`^${yc(t)}\\s*=\\s*(.*)$`));
|
|
5351
5505
|
if (e) return e[1].trim();
|
|
5352
5506
|
}
|
|
5353
5507
|
return "";
|
|
5354
5508
|
}
|
|
5355
|
-
function
|
|
5509
|
+
function yc(e) {
|
|
5356
5510
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5357
5511
|
}
|
|
5358
|
-
async function
|
|
5359
|
-
if (!await
|
|
5512
|
+
async function bc(e, t) {
|
|
5513
|
+
if (!await eo() && !await no(e, t, !1)) {
|
|
5360
5514
|
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")}.`));
|
|
5361
5515
|
return;
|
|
5362
5516
|
}
|
|
5363
5517
|
let n = s.spinner();
|
|
5364
|
-
if (n.start("Waiting for Postgres to be ready..."), !await
|
|
5518
|
+
if (n.start("Waiting for Postgres to be ready..."), !await co(e)) {
|
|
5365
5519
|
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")}`));
|
|
5366
5520
|
return;
|
|
5367
5521
|
}
|
|
5368
|
-
if (n.stop(R.success("Postgres is ready")), await
|
|
5522
|
+
if (n.stop(R.success("Postgres is ready")), await uo(e)) {
|
|
5369
5523
|
s.log.info(R.muted("Migrations already applied, skipping."));
|
|
5370
5524
|
return;
|
|
5371
5525
|
}
|
|
@@ -5377,21 +5531,21 @@ async function tc(e, t) {
|
|
|
5377
5531
|
s.log.info(R.muted("Skipping database migrations."));
|
|
5378
5532
|
return;
|
|
5379
5533
|
}
|
|
5380
|
-
await
|
|
5534
|
+
await fo(e);
|
|
5381
5535
|
}
|
|
5382
5536
|
//#endregion
|
|
5383
5537
|
//#region src/core/templates.ts
|
|
5384
|
-
var
|
|
5538
|
+
var xc = K.createRequest()({
|
|
5385
5539
|
endpoint: "/templates/list",
|
|
5386
5540
|
method: "GET"
|
|
5387
5541
|
});
|
|
5388
|
-
async function
|
|
5389
|
-
let { data: e, error: t } = await
|
|
5542
|
+
async function Sc() {
|
|
5543
|
+
let { data: e, error: t } = await xc.send();
|
|
5390
5544
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
5391
5545
|
return e.templates;
|
|
5392
5546
|
}
|
|
5393
|
-
async function
|
|
5394
|
-
let { data: t, error: n, status: r } = await
|
|
5547
|
+
async function Cc(e) {
|
|
5548
|
+
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
5395
5549
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
5396
5550
|
method: "GET"
|
|
5397
5551
|
}).send();
|
|
@@ -5399,13 +5553,13 @@ async function ic(e) {
|
|
|
5399
5553
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
5400
5554
|
return t;
|
|
5401
5555
|
}
|
|
5402
|
-
async function
|
|
5403
|
-
let n =
|
|
5556
|
+
async function wc(e, t = {}) {
|
|
5557
|
+
let n = K.createRequest()({
|
|
5404
5558
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
5405
5559
|
method: "POST"
|
|
5406
5560
|
}), r = {
|
|
5407
|
-
"X-Device-Id":
|
|
5408
|
-
"X-Client-Info":
|
|
5561
|
+
"X-Device-Id": tr(),
|
|
5562
|
+
"X-Client-Info": nr()
|
|
5409
5563
|
};
|
|
5410
5564
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
5411
5565
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -5427,9 +5581,9 @@ async function ac(e, t = {}) {
|
|
|
5427
5581
|
}
|
|
5428
5582
|
//#endregion
|
|
5429
5583
|
//#region src/commands/template.ts
|
|
5430
|
-
async function
|
|
5584
|
+
async function Tc(t = {}) {
|
|
5431
5585
|
let n = t.cwd ?? process.cwd();
|
|
5432
|
-
|
|
5586
|
+
Po();
|
|
5433
5587
|
let r = s.spinner();
|
|
5434
5588
|
r.start("Loading packs...");
|
|
5435
5589
|
let o;
|
|
@@ -5441,7 +5595,7 @@ async function oc(t = {}) {
|
|
|
5441
5595
|
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
5442
5596
|
let c;
|
|
5443
5597
|
try {
|
|
5444
|
-
c = await
|
|
5598
|
+
c = await Sc();
|
|
5445
5599
|
} catch (e) {
|
|
5446
5600
|
r.stop("Failed to load templates"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
5447
5601
|
}
|
|
@@ -5464,11 +5618,11 @@ async function oc(t = {}) {
|
|
|
5464
5618
|
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}`);
|
|
5465
5619
|
let d;
|
|
5466
5620
|
try {
|
|
5467
|
-
d = await
|
|
5621
|
+
d = await Cc(u.id);
|
|
5468
5622
|
} catch (e) {
|
|
5469
5623
|
s.cancel($(e)), process.exit(1);
|
|
5470
5624
|
}
|
|
5471
|
-
let f = await
|
|
5625
|
+
let f = await ec(n, {}, {
|
|
5472
5626
|
defaultTheme: d.theme,
|
|
5473
5627
|
defaultMode: d.defaultMode,
|
|
5474
5628
|
radius: d.radius
|
|
@@ -5481,59 +5635,59 @@ async function oc(t = {}) {
|
|
|
5481
5635
|
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));
|
|
5482
5636
|
let g = p ?? n;
|
|
5483
5637
|
s.intro(R.brandBold("Install a template"));
|
|
5484
|
-
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await
|
|
5638
|
+
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await Zn(L()))?.token ?? null, C = await Ec(u, t.variants, t.yes ?? !1), w = xo(u.slots, C), E = So(u.slots, u.packs, w), D = await Dc({
|
|
5485
5639
|
packs: o,
|
|
5486
5640
|
templatePacks: E,
|
|
5487
5641
|
installedSet: v,
|
|
5488
5642
|
options: t
|
|
5489
5643
|
}), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
|
|
5490
5644
|
k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
|
|
5491
|
-
let
|
|
5645
|
+
let A = To(o, w), j = _o(A), ee;
|
|
5492
5646
|
try {
|
|
5493
|
-
|
|
5647
|
+
ee = yo(O, j, _);
|
|
5494
5648
|
} catch (e) {
|
|
5495
5649
|
s.cancel($(e)), process.exit(1);
|
|
5496
5650
|
}
|
|
5497
|
-
if (
|
|
5651
|
+
if (ee.order.length === 0) {
|
|
5498
5652
|
s.outro(R.muted("Every pack in this template is already installed."));
|
|
5499
5653
|
return;
|
|
5500
5654
|
}
|
|
5501
|
-
let M = await
|
|
5655
|
+
let M = await Us(A, v, {
|
|
5502
5656
|
token: S,
|
|
5503
5657
|
key: x
|
|
5504
5658
|
}), te = (e) => {
|
|
5505
5659
|
let t = b.get(e);
|
|
5506
5660
|
return !t || t.tier === "free" ? "free" : M[e]?.owned ? "owned" : "locked";
|
|
5507
|
-
}, N = (e) => !v.has(e) && te(e) === "locked", P =
|
|
5508
|
-
order:
|
|
5509
|
-
graph:
|
|
5661
|
+
}, N = (e) => !v.has(e) && te(e) === "locked", P = bo({
|
|
5662
|
+
order: ee.order,
|
|
5663
|
+
graph: j,
|
|
5510
5664
|
isLocked: N,
|
|
5511
5665
|
installed: _
|
|
5512
5666
|
});
|
|
5513
5667
|
if (P.blocked.length > 0 && !S && !x) {
|
|
5514
|
-
let e = await
|
|
5515
|
-
e && (S = e, M = await
|
|
5668
|
+
let e = await sr();
|
|
5669
|
+
e && (S = e, M = await Us(A, v, {
|
|
5516
5670
|
token: S,
|
|
5517
5671
|
key: x
|
|
5518
|
-
}), P =
|
|
5519
|
-
order:
|
|
5520
|
-
graph:
|
|
5672
|
+
}), P = bo({
|
|
5673
|
+
order: ee.order,
|
|
5674
|
+
graph: j,
|
|
5521
5675
|
isLocked: N,
|
|
5522
5676
|
installed: _
|
|
5523
5677
|
}));
|
|
5524
5678
|
}
|
|
5525
|
-
if (P.blocked.length > 0 && await
|
|
5679
|
+
if (P.blocked.length > 0 && await Gs(P.blocked, N, b), P.installable.length === 0) {
|
|
5526
5680
|
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
5527
5681
|
return;
|
|
5528
5682
|
}
|
|
5529
|
-
if (
|
|
5683
|
+
if (Ks(P.installable, b), !t.yes) {
|
|
5530
5684
|
let e = await s.confirm({ message: `Install template ${R.brandBold(u.name)} (${P.installable.length} pack${P.installable.length === 1 ? "" : "s"})?` });
|
|
5531
5685
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5532
5686
|
}
|
|
5533
5687
|
r.start("Downloading packs...");
|
|
5534
5688
|
let F;
|
|
5535
5689
|
try {
|
|
5536
|
-
F = await
|
|
5690
|
+
F = await qs(P.installable, {
|
|
5537
5691
|
token: S,
|
|
5538
5692
|
key: x
|
|
5539
5693
|
});
|
|
@@ -5541,7 +5695,7 @@ async function oc(t = {}) {
|
|
|
5541
5695
|
r.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
5542
5696
|
}
|
|
5543
5697
|
r.stop(`Downloaded ${F.length} pack${F.length === 1 ? "" : "s"}`);
|
|
5544
|
-
let ne = await
|
|
5698
|
+
let ne = await Zs({
|
|
5545
5699
|
prepared: F,
|
|
5546
5700
|
config: h,
|
|
5547
5701
|
cwd: g,
|
|
@@ -5550,7 +5704,7 @@ async function oc(t = {}) {
|
|
|
5550
5704
|
}), I = null;
|
|
5551
5705
|
try {
|
|
5552
5706
|
r.start("Installing pack files...");
|
|
5553
|
-
let n = await
|
|
5707
|
+
let n = await Ua({
|
|
5554
5708
|
packs: F,
|
|
5555
5709
|
config: h,
|
|
5556
5710
|
projectRoot: g,
|
|
@@ -5562,15 +5716,15 @@ async function oc(t = {}) {
|
|
|
5562
5716
|
for (let e of n.errors) s.log.error(e);
|
|
5563
5717
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5564
5718
|
}
|
|
5565
|
-
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)`),
|
|
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)`), Xs(n.skipped));
|
|
5566
5720
|
for (let e of n.errors) s.log.error(e);
|
|
5567
5721
|
r.start("Applying template overrides...");
|
|
5568
|
-
let o = await
|
|
5722
|
+
let o = await wc(u.id, {
|
|
5569
5723
|
token: S,
|
|
5570
5724
|
licenseKey: x
|
|
5571
5725
|
});
|
|
5572
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)), I = o.templateDir;
|
|
5573
|
-
let c = await
|
|
5727
|
+
let c = await Ga({
|
|
5574
5728
|
manifest: d,
|
|
5575
5729
|
config: h,
|
|
5576
5730
|
projectRoot: g,
|
|
@@ -5578,13 +5732,13 @@ async function oc(t = {}) {
|
|
|
5578
5732
|
});
|
|
5579
5733
|
r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
|
|
5580
5734
|
for (let e of c.errors) s.log.error(e);
|
|
5581
|
-
if (await
|
|
5735
|
+
if (await Aa(g, h.name), !m) {
|
|
5582
5736
|
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5583
|
-
a(n) && (await
|
|
5737
|
+
a(n) && (await $o(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 && Wo(d.radius) && (await qo(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`)));
|
|
5584
5738
|
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5585
|
-
await
|
|
5739
|
+
await Ho(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`));
|
|
5586
5740
|
}
|
|
5587
|
-
await
|
|
5741
|
+
await Oc({
|
|
5588
5742
|
prepared: F,
|
|
5589
5743
|
templateNpm: d.dependencies_npm,
|
|
5590
5744
|
paths: h.paths,
|
|
@@ -5592,13 +5746,13 @@ async function oc(t = {}) {
|
|
|
5592
5746
|
spinner: r
|
|
5593
5747
|
});
|
|
5594
5748
|
let l;
|
|
5595
|
-
m && (l = await
|
|
5749
|
+
m && (l = await go(g, t.yes ?? !1)), await br({
|
|
5596
5750
|
projectRoot: g,
|
|
5597
5751
|
paths: h.paths,
|
|
5598
5752
|
skipPrompts: t.yes ?? !1,
|
|
5599
5753
|
dbReady: l,
|
|
5600
5754
|
freshScaffold: m
|
|
5601
|
-
}),
|
|
5755
|
+
}), Ys(), s.outro(R.brand(`Installed template ${u.name}.`));
|
|
5602
5756
|
} finally {
|
|
5603
5757
|
await Promise.all(F.map((e) => y.rm(e.packDir, {
|
|
5604
5758
|
recursive: !0,
|
|
@@ -5609,7 +5763,7 @@ async function oc(t = {}) {
|
|
|
5609
5763
|
});
|
|
5610
5764
|
}
|
|
5611
5765
|
}
|
|
5612
|
-
async function
|
|
5766
|
+
async function Ec(e, t, n) {
|
|
5613
5767
|
let r = {};
|
|
5614
5768
|
for (let i of e.slots) {
|
|
5615
5769
|
if (t?.[i.family]) {
|
|
@@ -5633,7 +5787,7 @@ async function sc(e, t, n) {
|
|
|
5633
5787
|
}
|
|
5634
5788
|
return r;
|
|
5635
5789
|
}
|
|
5636
|
-
async function
|
|
5790
|
+
async function Dc(e) {
|
|
5637
5791
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5638
5792
|
if (i.packs && i.packs.length > 0) {
|
|
5639
5793
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -5644,7 +5798,7 @@ async function cc(e) {
|
|
|
5644
5798
|
if (o.length === 0) return [];
|
|
5645
5799
|
let c = se();
|
|
5646
5800
|
B(o.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5647
|
-
let l = await
|
|
5801
|
+
let l = await Lo({
|
|
5648
5802
|
message: "Add extra packs on top of the template (optional)",
|
|
5649
5803
|
options: o.map((e) => ({
|
|
5650
5804
|
value: e.name,
|
|
@@ -5655,25 +5809,25 @@ async function cc(e) {
|
|
|
5655
5809
|
});
|
|
5656
5810
|
return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
|
|
5657
5811
|
}
|
|
5658
|
-
async function
|
|
5659
|
-
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o =
|
|
5812
|
+
async function Oc(e) {
|
|
5813
|
+
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o = Vs(t.map((e) => e.manifest.dependencies_npm)), c = Bs(n ? Vs([o, n]) : o, r);
|
|
5660
5814
|
if (c.errors.length > 0) {
|
|
5661
5815
|
for (let e of c.errors) s.log.error(e);
|
|
5662
5816
|
return;
|
|
5663
5817
|
}
|
|
5664
5818
|
if (c.operations.length === 0) return;
|
|
5665
5819
|
a.start("Installing npm dependencies...");
|
|
5666
|
-
let l = await
|
|
5820
|
+
let l = await Hs(c.operations, i);
|
|
5667
5821
|
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) s.log.error(e);
|
|
5668
5822
|
}
|
|
5669
5823
|
//#endregion
|
|
5670
5824
|
//#region src/cli.ts
|
|
5671
|
-
function
|
|
5825
|
+
function kc(e) {
|
|
5672
5826
|
if (!e) return;
|
|
5673
5827
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5674
5828
|
return t.length > 0 ? t : void 0;
|
|
5675
5829
|
}
|
|
5676
|
-
function
|
|
5830
|
+
function Ac(e) {
|
|
5677
5831
|
if (!e) return;
|
|
5678
5832
|
let t = {};
|
|
5679
5833
|
for (let n of e.split(",")) {
|
|
@@ -5682,51 +5836,52 @@ function dc(e) {
|
|
|
5682
5836
|
}
|
|
5683
5837
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5684
5838
|
}
|
|
5685
|
-
function
|
|
5839
|
+
function jc() {
|
|
5686
5840
|
let e = new o();
|
|
5687
|
-
return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(
|
|
5688
|
-
await
|
|
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 Qs({
|
|
5689
5843
|
name: e.name,
|
|
5690
5844
|
directory: e.directory,
|
|
5691
5845
|
install: e.install,
|
|
5692
5846
|
editor: e.editor,
|
|
5693
5847
|
theme: e.theme,
|
|
5848
|
+
adminTheme: e.adminTheme,
|
|
5694
5849
|
yes: e.yes,
|
|
5695
5850
|
setup: e.setup
|
|
5696
5851
|
});
|
|
5697
5852
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5698
|
-
await
|
|
5853
|
+
await $s({});
|
|
5699
5854
|
}), 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) => {
|
|
5700
|
-
await
|
|
5855
|
+
await gc({
|
|
5701
5856
|
cwd: e.cwd,
|
|
5702
5857
|
yes: e.yes,
|
|
5703
5858
|
skipMigrations: e.skipMigrations
|
|
5704
5859
|
});
|
|
5705
5860
|
}), 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) => {
|
|
5706
|
-
await
|
|
5707
|
-
packs:
|
|
5861
|
+
await tc({
|
|
5862
|
+
packs: kc(e.packs),
|
|
5708
5863
|
force: e.force,
|
|
5709
5864
|
yes: e.yes,
|
|
5710
5865
|
licenseKey: e.key ?? e.licenseKey,
|
|
5711
5866
|
cwd: e.cwd
|
|
5712
5867
|
});
|
|
5713
5868
|
}), 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) => {
|
|
5714
|
-
await
|
|
5869
|
+
await Tc({
|
|
5715
5870
|
templateId: e,
|
|
5716
|
-
variants:
|
|
5717
|
-
packs:
|
|
5871
|
+
variants: Ac(t.variants),
|
|
5872
|
+
packs: kc(t.packs),
|
|
5718
5873
|
force: t.force,
|
|
5719
5874
|
yes: t.yes,
|
|
5720
5875
|
licenseKey: t.key ?? t.licenseKey,
|
|
5721
5876
|
cwd: t.cwd
|
|
5722
5877
|
});
|
|
5723
5878
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5724
|
-
await
|
|
5879
|
+
await cc();
|
|
5725
5880
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5726
|
-
await
|
|
5881
|
+
await lc();
|
|
5727
5882
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5728
|
-
await
|
|
5883
|
+
await cc();
|
|
5729
5884
|
}), e;
|
|
5730
5885
|
}
|
|
5731
5886
|
//#endregion
|
|
5732
|
-
export {
|
|
5887
|
+
export { ec as a, tc as i, lc as n, $s as o, cc as r, Qs as s, jc as t };
|