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