@hype-stack/cli 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-B_dUEkkB.js → cli-cPE06mGY.js} +1547 -1300
- 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/env-files.d.ts +1 -0
- package/dist/core/env-files.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.1", 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(
|
|
1675
|
+
onData: (t) => (e.on(vn(), t), () => e.removeListener(vn(), t)),
|
|
1676
|
+
onDataByKey: (t, n) => (e.on(_n(t), n), () => e.removeListener(_n(t), n)),
|
|
1677
|
+
onInvalidate: (t) => (e.on(pn(), t), () => e.removeListener(pn(), t)),
|
|
1678
|
+
onInvalidateByKey: (t, n) => (e.on(mn(t), n), () => e.removeListener(mn(t), n)),
|
|
1679
|
+
onDelete: (t) => (e.on(hn(), t), () => e.removeListener(hn(), t)),
|
|
1680
|
+
onDeleteByKey: (t, n) => (e.on(gn(t), n), () => e.removeListener(gn(t), n))
|
|
1681
1681
|
}), G = /* @__PURE__ */ function(e) {
|
|
1682
1682
|
return e.ONE_BY_ONE = "one-by-one", e.ALL_AT_ONCE = "all-at-once", e.PREVIOUS_CANCELED = "previous-canceled", e.DEDUPLICATED = "deduplicated", e;
|
|
1683
|
-
}({}),
|
|
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",
|
|
@@ -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 ?
|
|
2057
|
+
}, Sn = () => "drained-event", Cn = (e) => `${e}-drained-event`, wn = () => "status-event", Tn = (e) => `${e}-status-event`, En = () => "change-event", Dn = (e) => `${e}-change-event`, On = (e, t) => !!(t && e < t), kn = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, An = (e, t) => {
|
|
2058
|
+
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? kn(e, t) : !1;
|
|
2059
2059
|
return n ? G.ONE_BY_ONE : r ? G.PREVIOUS_CANCELED : a && i ? G.DEDUPLICATED : G.ALL_AT_ONCE;
|
|
2060
2060
|
};
|
|
2061
|
-
function
|
|
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 jn = 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 jn = async (e, t) => {
|
|
|
2128
2128
|
setCacheKeyMapper = (e) => (this.unstable_cacheKeyMapper = e, this);
|
|
2129
2129
|
setQueryKeyMapper = (e) => (this.unstable_queryKeyMapper = e, this);
|
|
2130
2130
|
setRequestIdMapper = (e) => (this.unstable_requestIdMapper = e, this);
|
|
2131
|
-
unstable_modifyAuth = async (e) =>
|
|
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 jn = 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 jn = async (e, t) => {
|
|
|
2166
2166
|
let t = this.adapter.unstable_endpointMapper(e.endpoint), n = {
|
|
2167
2167
|
...e,
|
|
2168
2168
|
endpoint: String(t)
|
|
2169
|
-
}, r = new
|
|
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,22 +2178,22 @@ var jn = 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 K =
|
|
2186
|
+
var K = In({ url: F() });
|
|
2187
2187
|
//#endregion
|
|
2188
2188
|
//#region src/core/auth-api.ts
|
|
2189
|
-
async function
|
|
2189
|
+
async function Ln(e) {
|
|
2190
2190
|
let { data: t, success: n } = await K.createRequest()({
|
|
2191
2191
|
endpoint: "/auth/cli/whoami",
|
|
2192
2192
|
method: "GET"
|
|
2193
2193
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2194
2194
|
return !n || !t ? null : t;
|
|
2195
2195
|
}
|
|
2196
|
-
async function
|
|
2196
|
+
async function Rn(e) {
|
|
2197
2197
|
await K.createRequest()({
|
|
2198
2198
|
endpoint: "/auth/cli/token",
|
|
2199
2199
|
method: "DELETE"
|
|
@@ -2201,78 +2201,78 @@ async function Ln(e) {
|
|
|
2201
2201
|
}
|
|
2202
2202
|
//#endregion
|
|
2203
2203
|
//#region src/core/auth-store.ts
|
|
2204
|
-
var
|
|
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 Wn(e) {
|
|
2233
|
-
let t = Vn();
|
|
2234
|
-
await v.mkdir(t, { recursive: !0 }), await v.writeFile(Hn(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2235
|
-
}
|
|
2236
2232
|
async function Gn(e) {
|
|
2237
|
-
|
|
2233
|
+
let t = Hn();
|
|
2234
|
+
await y.mkdir(t, { recursive: !0 }), await y.writeFile(Un(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2235
|
+
}
|
|
2236
|
+
async function Kn(e) {
|
|
2237
|
+
return (await Wn()).tokens[e] ?? null;
|
|
2238
2238
|
}
|
|
2239
|
-
async function
|
|
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 Yn() {
|
|
2257
|
-
let e = `${Jn()}:${C.hostname()}:${C.platform()}:${C.arch()}`;
|
|
2258
|
-
return b("sha256").update(e).digest("hex").slice(0, 16);
|
|
2259
|
-
}
|
|
2260
2256
|
function Xn() {
|
|
2261
|
-
|
|
2257
|
+
let e = `${Yn()}:${w.hostname()}:${w.platform()}:${w.arch()}`;
|
|
2258
|
+
return x("sha256").update(e).digest("hex").slice(0, 16);
|
|
2259
|
+
}
|
|
2260
|
+
function Zn() {
|
|
2261
|
+
return `hype-stack/${A} ${w.platform()} ${w.arch()} node/${process.version.slice(1)}`;
|
|
2262
2262
|
}
|
|
2263
2263
|
//#endregion
|
|
2264
2264
|
//#region src/core/open-browser.ts
|
|
2265
|
-
function
|
|
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 er(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 er(e = {}) {
|
|
|
2301
2301
|
}), r.on("error", (e) => {
|
|
2302
2302
|
o(), i(e);
|
|
2303
2303
|
}), r.listen(0, "127.0.0.1", () => {
|
|
2304
|
-
let { port: n } = r.address(), i = encodeURIComponent(
|
|
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
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 q(e, t, n) {
|
|
|
2380
2380
|
}
|
|
2381
2381
|
//#endregion
|
|
2382
2382
|
//#region src/utils/fs.ts
|
|
2383
|
+
async function ir(e) {
|
|
2384
|
+
return (await y.stat(e).catch(() => null))?.isDirectory() ?? !1;
|
|
2385
|
+
}
|
|
2383
2386
|
async function J(e) {
|
|
2384
|
-
return (await
|
|
2387
|
+
return (await y.stat(e).catch(() => null))?.isFile() ?? !1;
|
|
2385
2388
|
}
|
|
2386
|
-
async function
|
|
2387
|
-
return (await
|
|
2389
|
+
async function ar(e) {
|
|
2390
|
+
return (await y.readdir(e).catch(() => [])).length === 0;
|
|
2388
2391
|
}
|
|
2389
|
-
async function
|
|
2390
|
-
|
|
2391
|
-
}
|
|
2392
|
-
async function ir(e) {
|
|
2393
|
-
let t = await v.readFile(e, "utf-8").catch(() => null);
|
|
2392
|
+
async function or(e) {
|
|
2393
|
+
let t = await y.readFile(e, "utf-8").catch(() => null);
|
|
2394
2394
|
return t ? JSON.parse(t) : null;
|
|
2395
2395
|
}
|
|
2396
|
-
async function
|
|
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 = q } = e, a = n.backend.root,
|
|
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,7 +2535,7 @@ function X(e, t) {
|
|
|
2547
2535
|
}
|
|
2548
2536
|
//#endregion
|
|
2549
2537
|
//#region src/core/registry.ts
|
|
2550
|
-
async function
|
|
2538
|
+
async function xr(e) {
|
|
2551
2539
|
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
2552
2540
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2553
2541
|
method: "GET"
|
|
@@ -2556,13 +2544,13 @@ async function yr(e) {
|
|
|
2556
2544
|
if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
|
|
2557
2545
|
return t;
|
|
2558
2546
|
}
|
|
2559
|
-
async function
|
|
2547
|
+
async function Sr(e, t = {}) {
|
|
2560
2548
|
let n = K.createRequest()({
|
|
2561
2549
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2562
2550
|
method: "POST"
|
|
2563
2551
|
}), r = {
|
|
2564
|
-
"X-Device-Id":
|
|
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,32 +2561,32 @@ async function br(e, t = {}) {
|
|
|
2573
2561
|
packs: i.packs ?? [],
|
|
2574
2562
|
expiresAt: i.expiresAt ?? null
|
|
2575
2563
|
};
|
|
2576
|
-
let s = await
|
|
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
2591
|
let n = K.createRequest()({
|
|
2604
2592
|
endpoint: "/packs/authorize",
|
|
@@ -2614,35 +2602,35 @@ async function Tr(e, t = {}) {
|
|
|
2614
2602
|
}
|
|
2615
2603
|
//#endregion
|
|
2616
2604
|
//#region src/core/codemods.ts
|
|
2617
|
-
var
|
|
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,20 +2801,20 @@ function Yr(e, t) {
|
|
|
2813
2801
|
let i = e.indexOf("export const sdk");
|
|
2814
2802
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2815
2803
|
}
|
|
2816
|
-
function
|
|
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
2820
|
let i = e.indexOf("{", r);
|
|
@@ -2842,38 +2830,38 @@ function Qr(e, t) {
|
|
|
2842
2830
|
}
|
|
2843
2831
|
return o === -1 ? e : e.slice(0, o) + n + "\n" + e.slice(o);
|
|
2844
2832
|
}
|
|
2845
|
-
var
|
|
2833
|
+
var ti = "import { type LucideIcon } from \"lucide-react\";\n\n/* -------------------------------------------------------------------------------------------------\n * Types\n * -----------------------------------------------------------------------------------------------*/\n\nexport type NavItem = {\n label: string;\n icon: LucideIcon;\n to: string;\n params?: Record<string, string>;\n};\n\nexport type NavSection = {\n label: string;\n icon: LucideIcon;\n items: NavItem[];\n};\n\nexport type NavSectionLink = NavSection & { to: string; params?: Record<string, string> };\n\nexport type NavEntry = NavSection | NavSectionLink;\n\n/* -------------------------------------------------------------------------------------------------\n * Navigation\n * -----------------------------------------------------------------------------------------------*/\n\nexport const primaryNav: NavEntry[] = [];\n\nexport const secondaryNav: NavEntry[] = [];\n\nexport const tertiaryNav: NavEntry[] = [];\n\nexport const settingsNav: NavEntry[] = [];\n", ni = {
|
|
2846
2834
|
primary: "primaryNav",
|
|
2847
2835
|
secondary: "secondaryNav",
|
|
2848
2836
|
tertiary: "tertiaryNav",
|
|
2849
2837
|
settings: "settingsNav"
|
|
2850
2838
|
};
|
|
2851
|
-
async function
|
|
2852
|
-
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2853
|
-
await
|
|
2854
|
-
for (let e of t) s.includes(`label: "${e.label}"`) || (s =
|
|
2855
|
-
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s =
|
|
2856
|
-
await
|
|
2857
|
-
}
|
|
2858
|
-
async function
|
|
2859
|
-
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2860
|
-
if (!await
|
|
2861
|
-
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 = "[^"]*";/;
|
|
2862
2850
|
if (!c.test(s)) return;
|
|
2863
2851
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
2864
|
-
await
|
|
2852
|
+
await y.writeFile(o, l, "utf-8");
|
|
2865
2853
|
}
|
|
2866
|
-
function
|
|
2854
|
+
function ai(e) {
|
|
2867
2855
|
let t = [e.icon];
|
|
2868
2856
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
2869
2857
|
return t;
|
|
2870
2858
|
}
|
|
2871
|
-
function
|
|
2872
|
-
let n =
|
|
2873
|
-
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);
|
|
2874
2862
|
return r;
|
|
2875
2863
|
}
|
|
2876
|
-
function
|
|
2864
|
+
function si(e, t) {
|
|
2877
2865
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
2878
2866
|
if (!n) return e;
|
|
2879
2867
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -2881,21 +2869,21 @@ function ai(e, t) {
|
|
|
2881
2869
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
2882
2870
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
2883
2871
|
}
|
|
2884
|
-
function
|
|
2885
|
-
let n =
|
|
2872
|
+
function ci(e, t) {
|
|
2873
|
+
let n = ni[t.group];
|
|
2886
2874
|
if (!n) return e;
|
|
2887
|
-
let r =
|
|
2875
|
+
let r = ui(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
|
|
2888
2876
|
if (!a) return e;
|
|
2889
|
-
let o = e.indexOf(a[0]) + a[0].length, s =
|
|
2877
|
+
let o = e.indexOf(a[0]) + a[0].length, s = li(e, o - 1);
|
|
2890
2878
|
return s === -1 ? e : e.slice(o, s).trim() === "" ? e.slice(0, o) + "\n" + r + "\n" + e.slice(o) : e.slice(0, o) + "\n" + r + e.slice(o);
|
|
2891
2879
|
}
|
|
2892
|
-
function
|
|
2880
|
+
function li(e, t) {
|
|
2893
2881
|
let n = 0;
|
|
2894
2882
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2895
2883
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2896
2884
|
return -1;
|
|
2897
2885
|
}
|
|
2898
|
-
function
|
|
2886
|
+
function ui(e) {
|
|
2899
2887
|
let t = [];
|
|
2900
2888
|
if (t.push(" {"), t.push(` label: "${e.label}",`), t.push(` icon: ${e.icon},`), e.to && t.push(` to: "${e.to}",`), e.params && t.push(` params: ${e.params},`), e.items && e.items.length > 0) {
|
|
2901
2889
|
t.push(" items: [");
|
|
@@ -2911,14 +2899,14 @@ function ci(e) {
|
|
|
2911
2899
|
} else t.push(" items: [],");
|
|
2912
2900
|
return t.push(" },"), t.join("\n");
|
|
2913
2901
|
}
|
|
2914
|
-
async function
|
|
2915
|
-
let r =
|
|
2916
|
-
if (!await
|
|
2917
|
-
let a = await
|
|
2918
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2919
|
-
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");
|
|
2920
2908
|
}
|
|
2921
|
-
function
|
|
2909
|
+
function fi(e, t) {
|
|
2922
2910
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2923
2911
|
if (r !== -1) {
|
|
2924
2912
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -2926,38 +2914,38 @@ function ui(e, t) {
|
|
|
2926
2914
|
}
|
|
2927
2915
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
2928
2916
|
}
|
|
2929
|
-
function
|
|
2917
|
+
function pi(e, t) {
|
|
2930
2918
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
2931
2919
|
if (!r) return e;
|
|
2932
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2920
|
+
let i = e.indexOf(r[0]) + r[0].length, a = mi(e, i - 1);
|
|
2933
2921
|
return a === -1 ? e : e.slice(i, a).trim() === "" ? e.slice(0, a) + "\n" + n + "\n" + e.slice(a) : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2934
2922
|
}
|
|
2935
|
-
function
|
|
2923
|
+
function mi(e, t) {
|
|
2936
2924
|
let n = 0;
|
|
2937
2925
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2938
2926
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2939
2927
|
return -1;
|
|
2940
2928
|
}
|
|
2941
|
-
var
|
|
2942
|
-
async function
|
|
2943
|
-
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({
|
|
2944
2932
|
...e,
|
|
2945
2933
|
arrayName: "navbarActions"
|
|
2946
2934
|
});
|
|
2947
2935
|
}
|
|
2948
|
-
async function
|
|
2949
|
-
await
|
|
2936
|
+
async function _i(e) {
|
|
2937
|
+
await vi({
|
|
2950
2938
|
...e,
|
|
2951
2939
|
arrayName: "userMenuActions"
|
|
2952
2940
|
});
|
|
2953
2941
|
}
|
|
2954
|
-
async function
|
|
2955
|
-
let a =
|
|
2956
|
-
await
|
|
2957
|
-
for (let n of e) s =
|
|
2958
|
-
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");
|
|
2959
2947
|
}
|
|
2960
|
-
function
|
|
2948
|
+
function yi(e, t) {
|
|
2961
2949
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2962
2950
|
if (e.includes(n)) return e;
|
|
2963
2951
|
let r = e.lastIndexOf("import ");
|
|
@@ -2965,38 +2953,38 @@ function _i(e, t) {
|
|
|
2965
2953
|
let i = e.indexOf("\n", r);
|
|
2966
2954
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2967
2955
|
}
|
|
2968
|
-
function
|
|
2956
|
+
function bi(e, t, n) {
|
|
2969
2957
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
2970
2958
|
if (!r) return e;
|
|
2971
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2959
|
+
let i = e.indexOf(r[0]) + r[0].length, a = xi(e, i - 1);
|
|
2972
2960
|
if (a === -1) return e;
|
|
2973
2961
|
let o = e.slice(i, a);
|
|
2974
2962
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
2975
2963
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
2976
2964
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
2977
2965
|
}
|
|
2978
|
-
function
|
|
2966
|
+
function xi(e, t) {
|
|
2979
2967
|
let n = 0;
|
|
2980
2968
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2981
2969
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2982
2970
|
return -1;
|
|
2983
2971
|
}
|
|
2984
|
-
var
|
|
2972
|
+
var Si = new Set([
|
|
2985
2973
|
".ts",
|
|
2986
2974
|
".tsx",
|
|
2987
2975
|
".js",
|
|
2988
2976
|
".jsx"
|
|
2989
2977
|
]);
|
|
2990
|
-
async function
|
|
2978
|
+
async function Ci(e) {
|
|
2991
2979
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
2992
2980
|
if (i === "hype-stack") return;
|
|
2993
2981
|
let a = `@${i}/`;
|
|
2994
2982
|
await Promise.all(t.map(async (e) => {
|
|
2995
|
-
let t =
|
|
2996
|
-
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);
|
|
2997
2985
|
}));
|
|
2998
2986
|
}
|
|
2999
|
-
var
|
|
2987
|
+
var wi = new Set([
|
|
3000
2988
|
".git",
|
|
3001
2989
|
"node_modules",
|
|
3002
2990
|
"dist",
|
|
@@ -3005,62 +2993,62 @@ var Si = new Set([
|
|
|
3005
2993
|
".next",
|
|
3006
2994
|
"coverage"
|
|
3007
2995
|
]);
|
|
3008
|
-
async function
|
|
3009
|
-
t !== "hype-stack" && await
|
|
2996
|
+
async function Ti(e, t) {
|
|
2997
|
+
t !== "hype-stack" && await Ei(e, `@${t}/`);
|
|
3010
2998
|
}
|
|
3011
|
-
async function
|
|
3012
|
-
let n = await
|
|
2999
|
+
async function Ei(e, t) {
|
|
3000
|
+
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3013
3001
|
await Promise.all(n.map(async (n) => {
|
|
3014
|
-
let r =
|
|
3002
|
+
let r = T.join(e, n.name);
|
|
3015
3003
|
if (n.isDirectory()) {
|
|
3016
|
-
if (
|
|
3017
|
-
await
|
|
3018
|
-
} 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);
|
|
3019
3007
|
}));
|
|
3020
3008
|
}
|
|
3021
|
-
async function
|
|
3022
|
-
let n = await
|
|
3023
|
-
if (!n.includes(
|
|
3024
|
-
let r = n.replaceAll(
|
|
3025
|
-
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");
|
|
3026
3014
|
}
|
|
3027
3015
|
//#endregion
|
|
3028
3016
|
//#region src/core/installer.ts
|
|
3029
|
-
function
|
|
3017
|
+
function Oi(e, t) {
|
|
3030
3018
|
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3031
3019
|
}
|
|
3032
|
-
async function
|
|
3033
|
-
if ((await
|
|
3034
|
-
await
|
|
3035
|
-
let n = await
|
|
3036
|
-
for (let r of n) await
|
|
3037
|
-
} else await
|
|
3020
|
+
async function ki(e, t) {
|
|
3021
|
+
if ((await y.stat(e)).isDirectory()) {
|
|
3022
|
+
await y.mkdir(t, { recursive: !0 });
|
|
3023
|
+
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3024
|
+
for (let r of n) await ki(T.join(e, r.name), T.join(t, r.name));
|
|
3025
|
+
} else await y.mkdir(T.dirname(t), { recursive: !0 }), await y.copyFile(e, t);
|
|
3038
3026
|
}
|
|
3039
|
-
async function
|
|
3027
|
+
async function Ai(e) {
|
|
3040
3028
|
let { src: t, dest: n, projectRoot: r, skip: i } = e;
|
|
3041
|
-
if ((await
|
|
3042
|
-
await
|
|
3043
|
-
let e = await
|
|
3044
|
-
return (await Promise.all(e.map((e) =>
|
|
3045
|
-
src:
|
|
3046
|
-
dest:
|
|
3029
|
+
if ((await y.stat(t)).isDirectory()) {
|
|
3030
|
+
await y.mkdir(n, { recursive: !0 });
|
|
3031
|
+
let e = await y.readdir(t, { withFileTypes: !0 });
|
|
3032
|
+
return (await Promise.all(e.map((e) => Ai({
|
|
3033
|
+
src: T.join(t, e.name),
|
|
3034
|
+
dest: T.join(n, e.name),
|
|
3047
3035
|
projectRoot: r,
|
|
3048
3036
|
skip: i
|
|
3049
3037
|
})))).flat();
|
|
3050
3038
|
}
|
|
3051
|
-
return i.has(t) ? [] : (await
|
|
3039
|
+
return i.has(t) ? [] : (await y.mkdir(T.dirname(n), { recursive: !0 }), await y.copyFile(t, n), [T.relative(r, n)]);
|
|
3052
3040
|
}
|
|
3053
|
-
async function
|
|
3054
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a =
|
|
3041
|
+
async function ji(e) {
|
|
3042
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = wr(t.source, n), o = Cr(t.target, r, i);
|
|
3055
3043
|
return {
|
|
3056
3044
|
sourcePath: a,
|
|
3057
3045
|
targetPath: o,
|
|
3058
|
-
sourceExists: await
|
|
3059
|
-
targetExists: await
|
|
3046
|
+
sourceExists: await J(a) || await ir(a),
|
|
3047
|
+
targetExists: await J(o) || await ir(o)
|
|
3060
3048
|
};
|
|
3061
3049
|
}
|
|
3062
|
-
async function
|
|
3063
|
-
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({
|
|
3064
3052
|
file: t,
|
|
3065
3053
|
packDir: n,
|
|
3066
3054
|
paths: r,
|
|
@@ -3071,12 +3059,12 @@ async function Ai(e) {
|
|
|
3071
3059
|
case "create":
|
|
3072
3060
|
case "skip-if-exists":
|
|
3073
3061
|
case "override": return null;
|
|
3074
|
-
case "merge": return !c || !t.marker || (await
|
|
3062
|
+
case "merge": return !c || !t.marker || (await y.readFile(o, "utf-8")).includes(t.marker) ? null : `${t.target}: Marker "${t.marker}" not found`;
|
|
3075
3063
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3076
3064
|
}
|
|
3077
3065
|
}
|
|
3078
|
-
async function
|
|
3079
|
-
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({
|
|
3080
3068
|
file: t,
|
|
3081
3069
|
packDir: n,
|
|
3082
3070
|
paths: r,
|
|
@@ -3094,7 +3082,7 @@ async function ji(e) {
|
|
|
3094
3082
|
status: "skipped",
|
|
3095
3083
|
path: t.target,
|
|
3096
3084
|
reason: "Already exists"
|
|
3097
|
-
} : (await
|
|
3085
|
+
} : (await ki(s, c), {
|
|
3098
3086
|
status: "installed",
|
|
3099
3087
|
path: t.target
|
|
3100
3088
|
});
|
|
@@ -3103,20 +3091,20 @@ async function ji(e) {
|
|
|
3103
3091
|
status: "skipped",
|
|
3104
3092
|
path: t.target,
|
|
3105
3093
|
reason: "Already exists (skip-if-exists)"
|
|
3106
|
-
} : (await
|
|
3094
|
+
} : (await ki(s, c), {
|
|
3107
3095
|
status: "installed",
|
|
3108
3096
|
path: t.target
|
|
3109
3097
|
});
|
|
3110
|
-
case "override": return await
|
|
3098
|
+
case "override": return await ki(s, c), {
|
|
3111
3099
|
status: "installed",
|
|
3112
3100
|
path: t.target
|
|
3113
3101
|
};
|
|
3114
3102
|
case "merge": {
|
|
3115
|
-
if (!u) return await
|
|
3103
|
+
if (!u) return await ki(s, c), {
|
|
3116
3104
|
status: "installed",
|
|
3117
3105
|
path: t.target
|
|
3118
3106
|
};
|
|
3119
|
-
let e = await
|
|
3107
|
+
let e = await y.readFile(s, "utf-8"), n = await y.readFile(c, "utf-8");
|
|
3120
3108
|
if (t.marker) {
|
|
3121
3109
|
let r = n.indexOf(t.marker);
|
|
3122
3110
|
if (r === -1) return {
|
|
@@ -3125,10 +3113,10 @@ async function ji(e) {
|
|
|
3125
3113
|
reason: `Marker "${t.marker}" not found`
|
|
3126
3114
|
};
|
|
3127
3115
|
let i = n.slice(0, r) + e + n.slice(r);
|
|
3128
|
-
await
|
|
3116
|
+
await y.writeFile(c, i);
|
|
3129
3117
|
} else {
|
|
3130
3118
|
let t = n + "\n" + e;
|
|
3131
|
-
await
|
|
3119
|
+
await y.writeFile(c, t);
|
|
3132
3120
|
}
|
|
3133
3121
|
return {
|
|
3134
3122
|
status: "installed",
|
|
@@ -3142,15 +3130,15 @@ async function ji(e) {
|
|
|
3142
3130
|
};
|
|
3143
3131
|
}
|
|
3144
3132
|
}
|
|
3145
|
-
async function
|
|
3133
|
+
async function Pi(e) {
|
|
3146
3134
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3147
3135
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3148
3136
|
let o = [], s = /* @__PURE__ */ new Set();
|
|
3149
3137
|
for (let e of t) {
|
|
3150
3138
|
let t = i?.get(e.manifest.name);
|
|
3151
3139
|
for (let n of e.manifest.files) {
|
|
3152
|
-
if (n.strategy !== "create" || !
|
|
3153
|
-
let { targetPath: i, targetExists: c } = await
|
|
3140
|
+
if (n.strategy !== "create" || !Oi(n, t)) continue;
|
|
3141
|
+
let { targetPath: i, targetExists: c } = await ji({
|
|
3154
3142
|
file: n,
|
|
3155
3143
|
packDir: e.packDir,
|
|
3156
3144
|
paths: a,
|
|
@@ -3165,13 +3153,13 @@ async function Mi(e) {
|
|
|
3165
3153
|
}
|
|
3166
3154
|
return o;
|
|
3167
3155
|
}
|
|
3168
|
-
async function
|
|
3156
|
+
async function Fi(e) {
|
|
3169
3157
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3170
3158
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3171
3159
|
let c = [];
|
|
3172
3160
|
for (let e of t.files) {
|
|
3173
|
-
if (!
|
|
3174
|
-
let t = await
|
|
3161
|
+
if (!Oi(e, o)) continue;
|
|
3162
|
+
let t = await Mi({
|
|
3175
3163
|
file: e,
|
|
3176
3164
|
packDir: a,
|
|
3177
3165
|
paths: s,
|
|
@@ -3182,16 +3170,16 @@ async function Ni(e) {
|
|
|
3182
3170
|
}
|
|
3183
3171
|
return c;
|
|
3184
3172
|
}
|
|
3185
|
-
async function
|
|
3173
|
+
async function Ii(e) {
|
|
3186
3174
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3187
3175
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3188
3176
|
let l = {
|
|
3189
3177
|
installed: [],
|
|
3190
3178
|
skipped: [],
|
|
3191
3179
|
errors: []
|
|
3192
|
-
}, u = t.files.filter((e) =>
|
|
3180
|
+
}, u = t.files.filter((e) => Oi(e, s));
|
|
3193
3181
|
for (let e of u) {
|
|
3194
|
-
let t = await
|
|
3182
|
+
let t = await Ni({
|
|
3195
3183
|
file: e,
|
|
3196
3184
|
packDir: o,
|
|
3197
3185
|
paths: c,
|
|
@@ -3211,40 +3199,40 @@ async function Pi(e) {
|
|
|
3211
3199
|
break;
|
|
3212
3200
|
}
|
|
3213
3201
|
}
|
|
3214
|
-
await
|
|
3202
|
+
await Ci({
|
|
3215
3203
|
files: u,
|
|
3216
3204
|
paths: c,
|
|
3217
3205
|
projectRoot: r,
|
|
3218
3206
|
projectName: n.name
|
|
3219
|
-
}), t.env && t.env.length > 0 && await
|
|
3207
|
+
}), t.env && t.env.length > 0 && await Ar(t.env, c, r), t.routes && t.routes.length > 0 && await Fr(t.routes, c, r), t.context && t.context.length > 0 && await Rr(t.context, c, r), t.sockets && t.sockets.length > 0 && await Kr(t.sockets, c, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await Xr(t.sdkConfigurations, c, r), t.enums && t.enums.length > 0 && await Wr(t.enums, c, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await $r(t.frontendRoutes, c, r);
|
|
3220
3208
|
let d = s && s.length > 0 ? s : ["frontend"];
|
|
3221
|
-
for (let e of d) t.nav && t.nav.length > 0 && await
|
|
3209
|
+
for (let e of d) t.nav && t.nav.length > 0 && await ri({
|
|
3222
3210
|
entries: t.nav,
|
|
3223
3211
|
paths: c,
|
|
3224
3212
|
projectRoot: r,
|
|
3225
3213
|
slot: e
|
|
3226
|
-
}), t.navbarActions && t.navbarActions.length > 0 && await
|
|
3214
|
+
}), t.navbarActions && t.navbarActions.length > 0 && await gi({
|
|
3227
3215
|
actions: t.navbarActions,
|
|
3228
3216
|
paths: c,
|
|
3229
3217
|
projectRoot: r,
|
|
3230
3218
|
slot: e
|
|
3231
|
-
}), t.userMenuActions && t.userMenuActions.length > 0 && await
|
|
3219
|
+
}), t.userMenuActions && t.userMenuActions.length > 0 && await _i({
|
|
3232
3220
|
actions: t.userMenuActions,
|
|
3233
3221
|
paths: c,
|
|
3234
3222
|
projectRoot: r,
|
|
3235
3223
|
slot: e
|
|
3236
3224
|
});
|
|
3237
|
-
return t.onboardingSteps && t.onboardingSteps.length > 0 && await
|
|
3225
|
+
return t.onboardingSteps && t.onboardingSteps.length > 0 && await di(t.onboardingSteps, c, r), t.postLoginRedirect && await ii({
|
|
3238
3226
|
postLoginRedirect: t.postLoginRedirect,
|
|
3239
3227
|
paths: c,
|
|
3240
3228
|
projectRoot: r,
|
|
3241
3229
|
slot: d[0]
|
|
3242
3230
|
}), l;
|
|
3243
3231
|
}
|
|
3244
|
-
async function
|
|
3232
|
+
async function Li(e) {
|
|
3245
3233
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3246
3234
|
for (let e of t) {
|
|
3247
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3235
|
+
let t = o?.get(e.manifest.name), a = await Fi({
|
|
3248
3236
|
manifest: e.manifest,
|
|
3249
3237
|
config: n,
|
|
3250
3238
|
projectRoot: r,
|
|
@@ -3264,7 +3252,7 @@ async function Fi(e) {
|
|
|
3264
3252
|
};
|
|
3265
3253
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3266
3254
|
for (let e of t) {
|
|
3267
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3255
|
+
let t = o?.get(e.manifest.name), n = await Ii({
|
|
3268
3256
|
manifest: e.manifest,
|
|
3269
3257
|
config: f,
|
|
3270
3258
|
projectRoot: r,
|
|
@@ -3273,7 +3261,7 @@ async function Fi(e) {
|
|
|
3273
3261
|
packDir: e.packDir,
|
|
3274
3262
|
slots: t
|
|
3275
3263
|
});
|
|
3276
|
-
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await
|
|
3264
|
+
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await Ri(f, e.manifest.name, r), d.push(e.manifest.name);
|
|
3277
3265
|
}
|
|
3278
3266
|
return {
|
|
3279
3267
|
installed: c,
|
|
@@ -3284,26 +3272,26 @@ async function Fi(e) {
|
|
|
3284
3272
|
config: f
|
|
3285
3273
|
};
|
|
3286
3274
|
}
|
|
3287
|
-
async function
|
|
3275
|
+
async function Ri(e, t, n) {
|
|
3288
3276
|
let r = {
|
|
3289
3277
|
...e,
|
|
3290
3278
|
installedPacks: [...e.installedPacks ?? [], t]
|
|
3291
3279
|
};
|
|
3292
|
-
return await
|
|
3280
|
+
return await gr(n, r), r;
|
|
3293
3281
|
}
|
|
3294
|
-
async function
|
|
3282
|
+
async function zi(e) {
|
|
3295
3283
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3296
3284
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3297
|
-
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) =>
|
|
3298
|
-
if (await
|
|
3299
|
-
let e = await
|
|
3285
|
+
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) => wr(e.source, i))), u = T.join(i, "files");
|
|
3286
|
+
if (await ir(u)) {
|
|
3287
|
+
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3300
3288
|
for (let t of e) {
|
|
3301
3289
|
if (!t.isDirectory()) continue;
|
|
3302
3290
|
let e = a[t.name]?.root;
|
|
3303
3291
|
if (!e) continue;
|
|
3304
|
-
let n = await
|
|
3305
|
-
src:
|
|
3306
|
-
dest:
|
|
3292
|
+
let n = await Ai({
|
|
3293
|
+
src: T.join(u, t.name),
|
|
3294
|
+
dest: T.resolve(r, e),
|
|
3307
3295
|
projectRoot: r,
|
|
3308
3296
|
skip: l
|
|
3309
3297
|
});
|
|
@@ -3311,7 +3299,7 @@ async function Li(e) {
|
|
|
3311
3299
|
}
|
|
3312
3300
|
}
|
|
3313
3301
|
for (let e of c) {
|
|
3314
|
-
let t = await
|
|
3302
|
+
let t = await Ni({
|
|
3315
3303
|
file: e,
|
|
3316
3304
|
packDir: i,
|
|
3317
3305
|
paths: a,
|
|
@@ -3321,12 +3309,12 @@ async function Li(e) {
|
|
|
3321
3309
|
});
|
|
3322
3310
|
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3323
3311
|
}
|
|
3324
|
-
let d =
|
|
3325
|
-
return await
|
|
3312
|
+
let d = T.join(Cr("{{frontend.root}}", a, r), "src", "routes"), f = T.join(d, "(public)", "index.tsx"), p = T.join(d, "(private)", "index.tsx");
|
|
3313
|
+
return await J(f) && await J(p) && await y.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await $r(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await ri({
|
|
3326
3314
|
entries: t.nav,
|
|
3327
3315
|
paths: a,
|
|
3328
3316
|
projectRoot: r
|
|
3329
|
-
}), t.postLoginRedirect && await
|
|
3317
|
+
}), t.postLoginRedirect && await ii({
|
|
3330
3318
|
postLoginRedirect: t.postLoginRedirect,
|
|
3331
3319
|
paths: a,
|
|
3332
3320
|
projectRoot: r
|
|
@@ -3337,28 +3325,28 @@ async function Li(e) {
|
|
|
3337
3325
|
}
|
|
3338
3326
|
//#endregion
|
|
3339
3327
|
//#region src/core/pack-categories.ts
|
|
3340
|
-
var
|
|
3328
|
+
var Bi = [
|
|
3341
3329
|
"starter",
|
|
3342
3330
|
"layout",
|
|
3343
3331
|
"feature"
|
|
3344
|
-
],
|
|
3332
|
+
], Vi = {
|
|
3345
3333
|
starter: "Starter",
|
|
3346
3334
|
layout: "Layout",
|
|
3347
3335
|
feature: "Features"
|
|
3348
|
-
},
|
|
3349
|
-
function
|
|
3336
|
+
}, Hi = new Set(["starter", "layout"]), Ui = "layout-basic";
|
|
3337
|
+
function Wi(e, t = {}) {
|
|
3350
3338
|
let n = [];
|
|
3351
|
-
for (let r of
|
|
3339
|
+
for (let r of Bi) {
|
|
3352
3340
|
let i = e.filter((e) => e.category === r);
|
|
3353
3341
|
if (i.length === 0) continue;
|
|
3354
|
-
let a =
|
|
3342
|
+
let a = Hi.has(r) ? "single" : "multiple";
|
|
3355
3343
|
if (r === "layout") {
|
|
3356
|
-
n.push(
|
|
3344
|
+
n.push(Gi("frontend", i)), t.adminAvailable && n.push(Gi("admin", i));
|
|
3357
3345
|
continue;
|
|
3358
3346
|
}
|
|
3359
3347
|
n.push({
|
|
3360
3348
|
category: r,
|
|
3361
|
-
label:
|
|
3349
|
+
label: Vi[r],
|
|
3362
3350
|
mode: a,
|
|
3363
3351
|
packs: i,
|
|
3364
3352
|
preselect: null
|
|
@@ -3366,53 +3354,53 @@ function Hi(e, t = {}) {
|
|
|
3366
3354
|
}
|
|
3367
3355
|
return n;
|
|
3368
3356
|
}
|
|
3369
|
-
function
|
|
3370
|
-
let n = t.some((e) => e.name ===
|
|
3357
|
+
function Gi(e, t) {
|
|
3358
|
+
let n = t.some((e) => e.name === Ui);
|
|
3371
3359
|
return {
|
|
3372
3360
|
category: "layout",
|
|
3373
3361
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3374
3362
|
mode: "single",
|
|
3375
3363
|
packs: t,
|
|
3376
|
-
preselect: n ?
|
|
3364
|
+
preselect: n ? Ui : null,
|
|
3377
3365
|
slot: e
|
|
3378
3366
|
};
|
|
3379
3367
|
}
|
|
3380
3368
|
//#endregion
|
|
3381
3369
|
//#region src/ui/logger.ts
|
|
3382
|
-
function
|
|
3383
|
-
|
|
3370
|
+
function Ki(e) {
|
|
3371
|
+
s.note(e.map((e) => `${z.arrow} ${e}`).join("\n"), "Next steps");
|
|
3384
3372
|
}
|
|
3385
|
-
function
|
|
3386
|
-
|
|
3373
|
+
function X() {
|
|
3374
|
+
s.cancel(R.muted("Operation cancelled.")), process.exit(0);
|
|
3387
3375
|
}
|
|
3388
3376
|
//#endregion
|
|
3389
3377
|
//#region src/core/post-setup.ts
|
|
3390
|
-
async function
|
|
3378
|
+
async function qi() {
|
|
3391
3379
|
return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3392
3380
|
}
|
|
3393
|
-
async function
|
|
3394
|
-
return
|
|
3381
|
+
async function Ji(e) {
|
|
3382
|
+
return J(`${e}/apps/backend/.env`);
|
|
3395
3383
|
}
|
|
3396
|
-
async function
|
|
3397
|
-
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({
|
|
3398
3386
|
message: r,
|
|
3399
3387
|
initialValue: !0
|
|
3400
3388
|
});
|
|
3401
|
-
if (
|
|
3402
|
-
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();
|
|
3403
3391
|
a.start("Starting Docker services...");
|
|
3404
|
-
let
|
|
3392
|
+
let o = await q("docker", [
|
|
3405
3393
|
"compose",
|
|
3406
3394
|
"up",
|
|
3407
3395
|
"-d"
|
|
3408
3396
|
], { cwd: `${e}/apps/backend` });
|
|
3409
|
-
return
|
|
3397
|
+
return o.exitCode === 0 ? (a.stop(R.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), Xi(o), !1);
|
|
3410
3398
|
}
|
|
3411
|
-
function
|
|
3399
|
+
function Xi(e) {
|
|
3412
3400
|
let t = (e.stderr || e.stdout).trim();
|
|
3413
|
-
t &&
|
|
3401
|
+
t && s.log.warn(R.muted(t));
|
|
3414
3402
|
}
|
|
3415
|
-
async function
|
|
3403
|
+
async function Zi(e, t = 15, n = 2e3) {
|
|
3416
3404
|
for (let r = 0; r < t; r++) {
|
|
3417
3405
|
if ((await q("docker", [
|
|
3418
3406
|
"compose",
|
|
@@ -3427,54 +3415,55 @@ async function Yi(e, t = 15, n = 2e3) {
|
|
|
3427
3415
|
}
|
|
3428
3416
|
return !1;
|
|
3429
3417
|
}
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
return;
|
|
3434
|
-
}
|
|
3435
|
-
if (!await qi(e, t, await Gi())) return;
|
|
3436
|
-
let r = o.spinner();
|
|
3437
|
-
if (r.start("Waiting for Postgres to be ready..."), !await Yi(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3)) {
|
|
3438
|
-
r.error("Postgres health check timed out"), o.log.warn(L.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest"));
|
|
3439
|
-
return;
|
|
3440
|
-
}
|
|
3441
|
-
r.stop(L.success("Postgres is ready"));
|
|
3442
|
-
let i = t ? !0 : await o.confirm({
|
|
3443
|
-
message: `Run database migrations with ${L.command("prisma migrate deploy")}?`,
|
|
3444
|
-
initialValue: !0
|
|
3445
|
-
});
|
|
3446
|
-
if (o.isCancel(i) && Z(), !i) {
|
|
3447
|
-
o.log.info(L.muted("Skipping database migrations."));
|
|
3448
|
-
return;
|
|
3449
|
-
}
|
|
3450
|
-
let a = o.spinner();
|
|
3451
|
-
a.start("Running database migrations...");
|
|
3452
|
-
let s = await q("pnpm", [
|
|
3418
|
+
var Qi = "Database schema is up to date";
|
|
3419
|
+
async function $i(e) {
|
|
3420
|
+
let t = await q("pnpm", [
|
|
3453
3421
|
"--filter",
|
|
3454
3422
|
"@internal/backend",
|
|
3455
|
-
"
|
|
3423
|
+
"exec",
|
|
3424
|
+
"prisma",
|
|
3425
|
+
"migrate",
|
|
3426
|
+
"status"
|
|
3456
3427
|
], { cwd: e });
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
let
|
|
3463
|
-
c.start("Generating Prisma client...");
|
|
3464
|
-
let l = await q("pnpm", [
|
|
3428
|
+
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(Qi) : !1;
|
|
3429
|
+
}
|
|
3430
|
+
async function ea(e) {
|
|
3431
|
+
let t = s.spinner();
|
|
3432
|
+
t.start("Running database migrations...");
|
|
3433
|
+
let n = await q("pnpm", [
|
|
3465
3434
|
"--filter",
|
|
3466
3435
|
"@internal/backend",
|
|
3467
|
-
"
|
|
3436
|
+
"migration:latest"
|
|
3468
3437
|
], { cwd: e });
|
|
3469
|
-
|
|
3470
|
-
|
|
3438
|
+
return n.exitCode === 0 ? (t.stop(R.success("Database migrations applied")), !0) : (t.error("Migrations failed"), Xi(n), s.log.warn(R.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations.")), !1);
|
|
3439
|
+
}
|
|
3440
|
+
async function ta(e, t, n = {}) {
|
|
3441
|
+
if (!await Yi(e, t, await qi())) return !1;
|
|
3442
|
+
let r = s.spinner();
|
|
3443
|
+
return r.start("Waiting for Postgres to be ready..."), await Zi(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3) ? (r.stop(R.success("Postgres is ready")), !0) : (r.error("Postgres health check timed out"), s.log.warn(R.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest")), !1);
|
|
3444
|
+
}
|
|
3445
|
+
async function na(e, t, n = {}) {
|
|
3446
|
+
if (!await ta(e, t, n)) return;
|
|
3447
|
+
let r = t ? !0 : await s.confirm({
|
|
3448
|
+
message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
|
|
3449
|
+
initialValue: !0
|
|
3450
|
+
});
|
|
3451
|
+
if (s.isCancel(r) && X(), !r) {
|
|
3452
|
+
s.log.info(R.muted("Skipping database migrations."));
|
|
3471
3453
|
return;
|
|
3472
3454
|
}
|
|
3473
|
-
|
|
3455
|
+
await ea(e);
|
|
3456
|
+
}
|
|
3457
|
+
async function ra(e, t, n = {}) {
|
|
3458
|
+
if (!await Ji(e)) {
|
|
3459
|
+
s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3460
|
+
return;
|
|
3461
|
+
}
|
|
3462
|
+
await na(e, t, n);
|
|
3474
3463
|
}
|
|
3475
3464
|
//#endregion
|
|
3476
3465
|
//#region src/core/resolve.ts
|
|
3477
|
-
function
|
|
3466
|
+
function ia(e) {
|
|
3478
3467
|
let t = /* @__PURE__ */ new Map();
|
|
3479
3468
|
for (let n of e) t.set(n.name, {
|
|
3480
3469
|
name: n.name,
|
|
@@ -3482,7 +3471,7 @@ function Zi(e) {
|
|
|
3482
3471
|
});
|
|
3483
3472
|
return t;
|
|
3484
3473
|
}
|
|
3485
|
-
function
|
|
3474
|
+
function aa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3486
3475
|
let r = /* @__PURE__ */ new Set();
|
|
3487
3476
|
function i(e) {
|
|
3488
3477
|
if (n.has(e)) return [];
|
|
@@ -3496,10 +3485,10 @@ function Qi(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3496
3485
|
}
|
|
3497
3486
|
return i(e);
|
|
3498
3487
|
}
|
|
3499
|
-
function
|
|
3488
|
+
function oa(e, t, n = []) {
|
|
3500
3489
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3501
3490
|
for (let n of e) {
|
|
3502
|
-
let e =
|
|
3491
|
+
let e = aa(n, t, new Set(i));
|
|
3503
3492
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3504
3493
|
}
|
|
3505
3494
|
return {
|
|
@@ -3507,7 +3496,7 @@ function $i(e, t, n = []) {
|
|
|
3507
3496
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3508
3497
|
};
|
|
3509
3498
|
}
|
|
3510
|
-
function
|
|
3499
|
+
function sa(e) {
|
|
3511
3500
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3512
3501
|
for (let e of t) {
|
|
3513
3502
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3520,7 +3509,7 @@ function ea(e) {
|
|
|
3520
3509
|
}
|
|
3521
3510
|
//#endregion
|
|
3522
3511
|
//#region src/core/variants.ts
|
|
3523
|
-
function
|
|
3512
|
+
function ca(e, t = {}) {
|
|
3524
3513
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3525
3514
|
for (let i of e) {
|
|
3526
3515
|
let e = t[i.family] ?? i.default;
|
|
@@ -3532,14 +3521,14 @@ function ta(e, t = {}) {
|
|
|
3532
3521
|
familyOf: r
|
|
3533
3522
|
};
|
|
3534
3523
|
}
|
|
3535
|
-
function
|
|
3524
|
+
function la(e, t, n) {
|
|
3536
3525
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3537
3526
|
}
|
|
3538
|
-
function
|
|
3527
|
+
function ua(e, t) {
|
|
3539
3528
|
let n = t.familyOf.get(e);
|
|
3540
3529
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3541
3530
|
}
|
|
3542
|
-
function
|
|
3531
|
+
function da(e, t) {
|
|
3543
3532
|
let n = /* @__PURE__ */ new Map();
|
|
3544
3533
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3545
3534
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3555,65 +3544,65 @@ function ia(e, t) {
|
|
|
3555
3544
|
familyOf: n
|
|
3556
3545
|
};
|
|
3557
3546
|
}
|
|
3558
|
-
function
|
|
3547
|
+
function fa(e, t) {
|
|
3559
3548
|
return e.map((e) => ({
|
|
3560
3549
|
...e,
|
|
3561
|
-
dependencies: e.dependencies.map((e) =>
|
|
3550
|
+
dependencies: e.dependencies.map((e) => ua(e, t))
|
|
3562
3551
|
}));
|
|
3563
3552
|
}
|
|
3564
3553
|
//#endregion
|
|
3565
3554
|
//#region src/ui/banner.ts
|
|
3566
|
-
var
|
|
3555
|
+
var pa = [
|
|
3567
3556
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3568
3557
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3569
3558
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3570
3559
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3571
3560
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3572
3561
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3573
|
-
],
|
|
3562
|
+
], ma = [
|
|
3574
3563
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3575
3564
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3576
3565
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3577
3566
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3578
3567
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3579
3568
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3580
|
-
],
|
|
3569
|
+
], ha = [
|
|
3581
3570
|
253,
|
|
3582
3571
|
176,
|
|
3583
3572
|
21
|
|
3584
|
-
],
|
|
3573
|
+
], ga = [
|
|
3585
3574
|
245,
|
|
3586
3575
|
76,
|
|
3587
3576
|
2
|
|
3588
|
-
],
|
|
3577
|
+
], _a = 5, va = [
|
|
3589
3578
|
17,
|
|
3590
3579
|
103,
|
|
3591
3580
|
248
|
|
3592
|
-
],
|
|
3581
|
+
], ya = [
|
|
3593
3582
|
42,
|
|
3594
3583
|
160,
|
|
3595
3584
|
250
|
|
3596
|
-
],
|
|
3597
|
-
function
|
|
3585
|
+
], ba = .2;
|
|
3586
|
+
function xa() {
|
|
3598
3587
|
console.log();
|
|
3599
|
-
for (let e of xe(
|
|
3600
|
-
start:
|
|
3601
|
-
end:
|
|
3602
|
-
angle:
|
|
3603
|
-
})) console.log(
|
|
3604
|
-
for (let e of xe(
|
|
3605
|
-
start:
|
|
3606
|
-
end:
|
|
3607
|
-
angle:
|
|
3608
|
-
})) console.log(
|
|
3609
|
-
console.log(), console.log(` ${
|
|
3610
|
-
}
|
|
3611
|
-
function
|
|
3612
|
-
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();
|
|
3613
3602
|
}
|
|
3614
3603
|
//#endregion
|
|
3615
3604
|
//#region src/ui/pack-multiselect.ts
|
|
3616
|
-
var
|
|
3605
|
+
var Ca = class extends O {
|
|
3617
3606
|
options;
|
|
3618
3607
|
cursor = 0;
|
|
3619
3608
|
selected;
|
|
@@ -3679,50 +3668,82 @@ var ga = class extends D {
|
|
|
3679
3668
|
e === "a" && this.toggleAll();
|
|
3680
3669
|
}
|
|
3681
3670
|
renderFrame() {
|
|
3682
|
-
let e =
|
|
3671
|
+
let e = g.withGuide, t = _(this.state), n = v(this.state), r = e ? `${n} ` : "", i = e ? k("cyan", l) : "", a = `${e ? `${k("gray", c)}\n` : ""}${t} ${this.message}\n`, o = (e, t) => {
|
|
3683
3672
|
let n = e.label ?? String(e.value);
|
|
3684
|
-
if (e.disabled) return `${
|
|
3685
|
-
let r = this.selected.has(e.value) ?
|
|
3686
|
-
return `${t ? `${
|
|
3687
|
-
},
|
|
3673
|
+
if (e.disabled) return `${k("gray", d)} ${k(["strikethrough", "gray"], n)}`;
|
|
3674
|
+
let r = this.selected.has(e.value) ? k("green", f) : t ? k("cyan", u) : k("dim", d);
|
|
3675
|
+
return `${t ? `${k("green", p)} ` : " "}${r} ${t ? n : k("dim", n)}${t && e.hint ? ` ${k("dim", `(${e.hint})`)}` : ""}`;
|
|
3676
|
+
}, s = () => {
|
|
3688
3677
|
let e = this.atContinue;
|
|
3689
|
-
return `${e ? `${
|
|
3678
|
+
return `${e ? `${k("green", p)} ` : " "}${k(e ? "cyan" : "dim", this.continueLabel)}${e ? k("dim", " (enter to install)") : ""}`;
|
|
3690
3679
|
};
|
|
3691
3680
|
switch (this.state) {
|
|
3692
3681
|
case "submit": {
|
|
3693
|
-
let t = this.options.filter((e) => this.selected.has(e.value)).map((e) => e.label ?? String(e.value)).join(
|
|
3694
|
-
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)}`;
|
|
3695
3684
|
}
|
|
3696
3685
|
case "cancel": {
|
|
3697
|
-
let t = this.options.filter((e) => this.selected.has(e.value)).map((e) => e.label ?? String(e.value)).join(
|
|
3698
|
-
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)}`;
|
|
3699
3688
|
}
|
|
3700
3689
|
default: {
|
|
3701
|
-
let t =
|
|
3690
|
+
let t = h({
|
|
3702
3691
|
cursor: Math.min(this.cursor, this.options.length - 1),
|
|
3703
3692
|
options: this.options,
|
|
3704
|
-
style: (e, t) => o(e, t),
|
|
3693
|
+
style: (e, t) => o(e, t && !this.atContinue),
|
|
3705
3694
|
output: this.output,
|
|
3706
3695
|
maxItems: this.maxItems,
|
|
3707
3696
|
columnPadding: e ? 3 : 0,
|
|
3708
3697
|
rowPadding: a.split("\n").length + (e ? 4 : 3)
|
|
3709
|
-
}).map((e) => `${r}${e}`), n = `${
|
|
3698
|
+
}).map((e) => `${r}${e}`), n = `${k("dim", "↑/↓ move · enter/space toggle · a all · enter on Continue to install")}`, c = [
|
|
3710
3699
|
...t,
|
|
3711
|
-
`${r}${
|
|
3700
|
+
`${r}${s()}`,
|
|
3712
3701
|
`${r}${n}`,
|
|
3713
3702
|
i
|
|
3714
3703
|
];
|
|
3715
|
-
return this.state === "error" &&
|
|
3704
|
+
return this.state === "error" && c.push(`${r}${k("yellow", this.error)}`), `${a}${c.join("\n")}\n`;
|
|
3716
3705
|
}
|
|
3717
3706
|
}
|
|
3718
3707
|
}
|
|
3719
3708
|
};
|
|
3720
|
-
function
|
|
3721
|
-
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;
|
|
3722
3743
|
}
|
|
3723
3744
|
//#endregion
|
|
3724
3745
|
//#region src/core/apply-theme.ts
|
|
3725
|
-
function
|
|
3746
|
+
function Ma(e, t) {
|
|
3726
3747
|
let n = e.indexOf(t);
|
|
3727
3748
|
if (n === -1) return null;
|
|
3728
3749
|
let r = e.indexOf("{", n);
|
|
@@ -3737,46 +3758,46 @@ function va(e, t) {
|
|
|
3737
3758
|
bodyEnd: a - 1
|
|
3738
3759
|
} : null;
|
|
3739
3760
|
}
|
|
3740
|
-
function
|
|
3761
|
+
function Na(e, t) {
|
|
3741
3762
|
let n = e;
|
|
3742
3763
|
for (let [e, r] of Object.entries(t)) {
|
|
3743
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3764
|
+
let t = RegExp(`(^[ \\t]*--${Pa(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3744
3765
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3745
3766
|
}
|
|
3746
3767
|
return n;
|
|
3747
3768
|
}
|
|
3748
|
-
function
|
|
3769
|
+
function Pa(e) {
|
|
3749
3770
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3750
3771
|
}
|
|
3751
|
-
function
|
|
3752
|
-
let n =
|
|
3772
|
+
function Fa(e, t) {
|
|
3773
|
+
let n = Ma(e, ":root"), r = Ma(e, ".dark"), i = e;
|
|
3753
3774
|
if (n) {
|
|
3754
3775
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3755
|
-
i = e +
|
|
3776
|
+
i = e + Na(r, t.light) + a;
|
|
3756
3777
|
}
|
|
3757
3778
|
if (r) {
|
|
3758
|
-
let e =
|
|
3779
|
+
let e = Ma(i, ".dark");
|
|
3759
3780
|
if (e) {
|
|
3760
3781
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3761
|
-
i = n +
|
|
3782
|
+
i = n + Na(r, t.dark) + a;
|
|
3762
3783
|
}
|
|
3763
3784
|
}
|
|
3764
3785
|
return i;
|
|
3765
3786
|
}
|
|
3766
|
-
var
|
|
3767
|
-
async function
|
|
3768
|
-
let n =
|
|
3787
|
+
var Ia = "assets/styles.css";
|
|
3788
|
+
async function La(e, t) {
|
|
3789
|
+
let n = T.resolve(e, Ia), r;
|
|
3769
3790
|
try {
|
|
3770
|
-
r = await
|
|
3791
|
+
r = await y.readFile(n, "utf-8");
|
|
3771
3792
|
} catch {
|
|
3772
3793
|
return !1;
|
|
3773
3794
|
}
|
|
3774
|
-
let i =
|
|
3775
|
-
return i === r || await
|
|
3795
|
+
let i = Fa(r, t);
|
|
3796
|
+
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3776
3797
|
}
|
|
3777
3798
|
//#endregion
|
|
3778
3799
|
//#region src/core/clone.ts
|
|
3779
|
-
async function
|
|
3800
|
+
async function Ra(e) {
|
|
3780
3801
|
let t = await ee(te, {
|
|
3781
3802
|
dir: e,
|
|
3782
3803
|
force: !0
|
|
@@ -3788,7 +3809,7 @@ async function wa(e) {
|
|
|
3788
3809
|
}
|
|
3789
3810
|
//#endregion
|
|
3790
3811
|
//#region src/core/editor-config.ts
|
|
3791
|
-
function
|
|
3812
|
+
function za(e) {
|
|
3792
3813
|
let t = {
|
|
3793
3814
|
globs: [],
|
|
3794
3815
|
alwaysApply: !1
|
|
@@ -3823,10 +3844,10 @@ function Ta(e) {
|
|
|
3823
3844
|
content: i
|
|
3824
3845
|
};
|
|
3825
3846
|
}
|
|
3826
|
-
function
|
|
3847
|
+
function Ba(e) {
|
|
3827
3848
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
3828
3849
|
}
|
|
3829
|
-
function
|
|
3850
|
+
function Va(e) {
|
|
3830
3851
|
let t;
|
|
3831
3852
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
3832
3853
|
let n = [`trigger: ${t}`];
|
|
@@ -3836,30 +3857,30 @@ function Da(e) {
|
|
|
3836
3857
|
}
|
|
3837
3858
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
3838
3859
|
}
|
|
3839
|
-
function
|
|
3860
|
+
function Ha(e) {
|
|
3840
3861
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
3841
3862
|
}
|
|
3842
|
-
var
|
|
3863
|
+
var Ua = {
|
|
3843
3864
|
claude: {
|
|
3844
3865
|
rulesDir: ".claude/rules",
|
|
3845
3866
|
extension: ".md",
|
|
3846
|
-
convert:
|
|
3867
|
+
convert: Ba
|
|
3847
3868
|
},
|
|
3848
3869
|
windsurf: {
|
|
3849
3870
|
rulesDir: ".windsurf/rules",
|
|
3850
3871
|
extension: ".md",
|
|
3851
|
-
convert:
|
|
3872
|
+
convert: Va
|
|
3852
3873
|
},
|
|
3853
3874
|
copilot: {
|
|
3854
3875
|
rulesDir: ".github/instructions",
|
|
3855
3876
|
extension: ".instructions.md",
|
|
3856
|
-
convert:
|
|
3877
|
+
convert: Ha
|
|
3857
3878
|
}
|
|
3858
3879
|
};
|
|
3859
|
-
async function
|
|
3860
|
-
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"));
|
|
3861
3882
|
return await Promise.all(n.map(async (e) => {
|
|
3862
|
-
let n =
|
|
3883
|
+
let n = T.join(t, e.name), { frontmatter: r, content: i } = za(await y.readFile(n, "utf-8"));
|
|
3863
3884
|
return {
|
|
3864
3885
|
frontmatter: r,
|
|
3865
3886
|
content: i,
|
|
@@ -3867,43 +3888,43 @@ async function Aa(e) {
|
|
|
3867
3888
|
};
|
|
3868
3889
|
}));
|
|
3869
3890
|
}
|
|
3870
|
-
async function
|
|
3891
|
+
async function Ga(e, t) {
|
|
3871
3892
|
if (t === "cursor") return;
|
|
3872
|
-
let n =
|
|
3873
|
-
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) => {
|
|
3874
3895
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3875
|
-
return
|
|
3876
|
-
})), 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));
|
|
3877
3898
|
}
|
|
3878
3899
|
//#endregion
|
|
3879
3900
|
//#region src/core/env-files.ts
|
|
3880
|
-
var
|
|
3901
|
+
var Ka = [
|
|
3881
3902
|
"apps",
|
|
3882
3903
|
"packages",
|
|
3883
3904
|
"libs",
|
|
3884
3905
|
"shared"
|
|
3885
3906
|
];
|
|
3886
|
-
async function
|
|
3887
|
-
let t = await
|
|
3907
|
+
async function qa(e) {
|
|
3908
|
+
let t = await Ja(e);
|
|
3888
3909
|
return (await Promise.all(t.map(async (t) => {
|
|
3889
|
-
let n =
|
|
3890
|
-
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));
|
|
3891
3912
|
}))).filter((e) => e !== null).sort();
|
|
3892
3913
|
}
|
|
3893
|
-
async function
|
|
3894
|
-
let t = [
|
|
3895
|
-
let n =
|
|
3896
|
-
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"));
|
|
3897
3918
|
}));
|
|
3898
|
-
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);
|
|
3899
3920
|
}
|
|
3900
3921
|
//#endregion
|
|
3901
3922
|
//#region src/core/post-clone.ts
|
|
3902
|
-
var
|
|
3903
|
-
async function
|
|
3904
|
-
await
|
|
3923
|
+
var Z = "@hype-stack/", Ya = "hype-stack";
|
|
3924
|
+
async function Xa(e) {
|
|
3925
|
+
await lr(T.join(e, ".git"));
|
|
3905
3926
|
}
|
|
3906
|
-
async function
|
|
3927
|
+
async function Za(e) {
|
|
3907
3928
|
await q("git", ["init"], { cwd: e }), await q("git", ["add", "."], { cwd: e }), await q("git", [
|
|
3908
3929
|
"-c",
|
|
3909
3930
|
"user.name=Hype Stack CLI",
|
|
@@ -3914,22 +3935,22 @@ async function La(e) {
|
|
|
3914
3935
|
"Initial commit from Hype Stack CLI"
|
|
3915
3936
|
], { cwd: e });
|
|
3916
3937
|
}
|
|
3917
|
-
async function
|
|
3918
|
-
let n = `@${t}/`, r = await
|
|
3938
|
+
async function Qa(e, t) {
|
|
3939
|
+
let n = `@${t}/`, r = await oo(e);
|
|
3919
3940
|
for (let e of r) {
|
|
3920
|
-
let t = await
|
|
3941
|
+
let t = await or(e);
|
|
3921
3942
|
if (!t) continue;
|
|
3922
3943
|
let r = !1;
|
|
3923
|
-
t.name?.startsWith(
|
|
3924
|
-
let i = await
|
|
3925
|
-
if (i.includes(
|
|
3926
|
-
let t = i.replaceAll(
|
|
3927
|
-
await
|
|
3928
|
-
} 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);
|
|
3929
3950
|
}
|
|
3930
|
-
await
|
|
3951
|
+
await Ti(e, t), await to(e, t), await ao(e, t);
|
|
3931
3952
|
}
|
|
3932
|
-
var
|
|
3953
|
+
var $a = new Set([
|
|
3933
3954
|
".git",
|
|
3934
3955
|
"node_modules",
|
|
3935
3956
|
"dist",
|
|
@@ -3937,68 +3958,68 @@ var za = new Set([
|
|
|
3937
3958
|
".nx",
|
|
3938
3959
|
".next",
|
|
3939
3960
|
"coverage"
|
|
3940
|
-
]),
|
|
3941
|
-
async function
|
|
3942
|
-
if (t ===
|
|
3943
|
-
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);
|
|
3944
3965
|
await Promise.all(n.map(async (e) => {
|
|
3945
|
-
let n = await
|
|
3966
|
+
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
3946
3967
|
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
3947
3968
|
let r = n.replace(/^(name:[ \t]*)hype-stack/gm, `$1${t}`);
|
|
3948
|
-
await
|
|
3969
|
+
await y.writeFile(e, r, "utf-8");
|
|
3949
3970
|
}));
|
|
3950
3971
|
}
|
|
3951
|
-
async function
|
|
3952
|
-
let t = await
|
|
3972
|
+
async function no(e) {
|
|
3973
|
+
let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
3953
3974
|
return (await Promise.all(t.map(async (t) => {
|
|
3954
|
-
let n =
|
|
3955
|
-
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] : [];
|
|
3956
3977
|
}))).flat();
|
|
3957
3978
|
}
|
|
3958
|
-
function
|
|
3979
|
+
function ro(e, t) {
|
|
3959
3980
|
if (!e) return !1;
|
|
3960
3981
|
let n = !1;
|
|
3961
|
-
for (let r of Object.keys(e)) if (r.startsWith(
|
|
3962
|
-
let i = r.replace(
|
|
3982
|
+
for (let r of Object.keys(e)) if (r.startsWith(Z)) {
|
|
3983
|
+
let i = r.replace(Z, t);
|
|
3963
3984
|
e[i] = e[r], delete e[r], n = !0;
|
|
3964
3985
|
}
|
|
3965
3986
|
return n;
|
|
3966
3987
|
}
|
|
3967
|
-
function
|
|
3988
|
+
function io(e, t) {
|
|
3968
3989
|
if (!e) return !1;
|
|
3969
3990
|
let n = !1;
|
|
3970
|
-
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(
|
|
3971
|
-
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);
|
|
3972
3993
|
}
|
|
3973
3994
|
return n;
|
|
3974
3995
|
}
|
|
3975
|
-
async function
|
|
3976
|
-
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);
|
|
3977
3998
|
if (!r) return;
|
|
3978
|
-
let i = t
|
|
3979
|
-
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");
|
|
3980
4001
|
}
|
|
3981
|
-
async function
|
|
3982
|
-
let t = [], n =
|
|
3983
|
-
(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);
|
|
3984
4005
|
for (let n of [
|
|
3985
4006
|
"apps",
|
|
3986
4007
|
"packages",
|
|
3987
4008
|
"libs",
|
|
3988
4009
|
"shared"
|
|
3989
4010
|
]) {
|
|
3990
|
-
let r =
|
|
4011
|
+
let r = T.join(e, n), i = await y.readdir(r, { withFileTypes: !0 }).catch(() => []);
|
|
3991
4012
|
for (let e of i) {
|
|
3992
4013
|
if (!e.isDirectory()) continue;
|
|
3993
|
-
let n =
|
|
3994
|
-
(await
|
|
4014
|
+
let n = T.join(r, e.name, "package.json");
|
|
4015
|
+
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
3995
4016
|
}
|
|
3996
4017
|
}
|
|
3997
4018
|
return t;
|
|
3998
4019
|
}
|
|
3999
4020
|
//#endregion
|
|
4000
4021
|
//#region src/core/readme.ts
|
|
4001
|
-
var
|
|
4022
|
+
var so = {
|
|
4002
4023
|
cursor: {
|
|
4003
4024
|
label: "Cursor",
|
|
4004
4025
|
rulesDir: ".cursor/rules"
|
|
@@ -4015,24 +4036,21 @@ var qa = {
|
|
|
4015
4036
|
label: "GitHub Copilot",
|
|
4016
4037
|
rulesDir: ".github/instructions"
|
|
4017
4038
|
}
|
|
4018
|
-
},
|
|
4039
|
+
}, co = {
|
|
4019
4040
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
4020
4041
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
4021
|
-
},
|
|
4042
|
+
}, lo = {
|
|
4022
4043
|
enums: "Shared enums and app config used across apps",
|
|
4023
4044
|
cli: "Project tooling and code generators"
|
|
4024
4045
|
};
|
|
4025
|
-
function
|
|
4026
|
-
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
4027
|
-
}
|
|
4028
|
-
function Za(e, t) {
|
|
4046
|
+
function uo(e, t) {
|
|
4029
4047
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
4030
4048
|
let r = t[e];
|
|
4031
4049
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4032
4050
|
});
|
|
4033
4051
|
}
|
|
4034
|
-
function
|
|
4035
|
-
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 = [];
|
|
4036
4054
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
4037
4055
|
let u = [];
|
|
4038
4056
|
u.push(`# ${i}`), u.push([
|
|
@@ -4140,18 +4158,18 @@ function Qa(e) {
|
|
|
4140
4158
|
"stays useful."
|
|
4141
4159
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4142
4160
|
}
|
|
4143
|
-
async function
|
|
4144
|
-
let n =
|
|
4145
|
-
await
|
|
4161
|
+
async function po(e, t) {
|
|
4162
|
+
let n = T.join(e, "README.md");
|
|
4163
|
+
await y.writeFile(n, fo(t), "utf-8");
|
|
4146
4164
|
}
|
|
4147
4165
|
//#endregion
|
|
4148
4166
|
//#region src/core/tracking.ts
|
|
4149
|
-
async function
|
|
4167
|
+
async function mo(e) {
|
|
4150
4168
|
try {
|
|
4151
4169
|
let t = {
|
|
4152
|
-
"X-Device-Id":
|
|
4153
|
-
"X-Client-Info":
|
|
4154
|
-
}, n = await
|
|
4170
|
+
"X-Device-Id": Xn(),
|
|
4171
|
+
"X-Client-Info": Zn()
|
|
4172
|
+
}, n = await Kn(F()).catch(() => null);
|
|
4155
4173
|
n?.token && (t.Authorization = `Bearer ${n.token}`), await K.createRequest()({
|
|
4156
4174
|
endpoint: "/cli/track",
|
|
4157
4175
|
method: "POST"
|
|
@@ -4159,272 +4177,6 @@ async function eo(e) {
|
|
|
4159
4177
|
} catch {}
|
|
4160
4178
|
}
|
|
4161
4179
|
//#endregion
|
|
4162
|
-
//#region src/ui/swatch.ts
|
|
4163
|
-
function to(e) {
|
|
4164
|
-
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4165
|
-
if (!t) return null;
|
|
4166
|
-
let n = t[1].trim().split(/\s+/);
|
|
4167
|
-
if (n.length < 3) return null;
|
|
4168
|
-
let r = n[0], i = Number(n[1]), a = Number(n[2]);
|
|
4169
|
-
if (Number.isNaN(i) || Number.isNaN(a)) return null;
|
|
4170
|
-
let o;
|
|
4171
|
-
if (r.endsWith("%")) {
|
|
4172
|
-
let e = Number(r.slice(0, -1));
|
|
4173
|
-
if (Number.isNaN(e)) return null;
|
|
4174
|
-
o = e / 100;
|
|
4175
|
-
} else if (o = Number(r), Number.isNaN(o)) return null;
|
|
4176
|
-
return {
|
|
4177
|
-
l: o,
|
|
4178
|
-
c: i,
|
|
4179
|
-
h: a
|
|
4180
|
-
};
|
|
4181
|
-
}
|
|
4182
|
-
function no(e) {
|
|
4183
|
-
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4184
|
-
}
|
|
4185
|
-
function ro(e) {
|
|
4186
|
-
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4187
|
-
}
|
|
4188
|
-
function io({ l: e, c: t, h: n }) {
|
|
4189
|
-
let r = n * Math.PI / 180, i = t * Math.cos(r), a = t * Math.sin(r), o = e + .3963377774 * i + .2158037573 * a, s = e - .1055613458 * i - .0638541728 * a, c = e - .0894841775 * i - 1.291485548 * a, l = o ** 3, u = s ** 3, d = c ** 3, f = 4.0767416621 * l - 3.3077115913 * u + .2309699292 * d, p = -1.2684380042 * l + 2.6097570613 * u - .3413193965 * d, m = -.0041960863 * l - .7034186147 * u + 1.7076146937 * d;
|
|
4190
|
-
return [
|
|
4191
|
-
no(ro(f) * 255),
|
|
4192
|
-
no(ro(p) * 255),
|
|
4193
|
-
no(ro(m) * 255)
|
|
4194
|
-
];
|
|
4195
|
-
}
|
|
4196
|
-
var ao = "\x1B[49m";
|
|
4197
|
-
function oo(e, t) {
|
|
4198
|
-
let n = e[t];
|
|
4199
|
-
if (!n) return y.dim(" ");
|
|
4200
|
-
let r = to(n);
|
|
4201
|
-
if (!r) return y.dim(" ");
|
|
4202
|
-
let [i, a, o] = io(r);
|
|
4203
|
-
return `\x1b[48;2;${i};${a};${o}m ${ao}`;
|
|
4204
|
-
}
|
|
4205
|
-
var so = [
|
|
4206
|
-
"primary",
|
|
4207
|
-
"secondary",
|
|
4208
|
-
"accent"
|
|
4209
|
-
];
|
|
4210
|
-
function co(e) {
|
|
4211
|
-
return so.map((t) => oo(e, t)).join("");
|
|
4212
|
-
}
|
|
4213
|
-
function lo(e) {
|
|
4214
|
-
return `${co(e.light)} ${y.dim("·")} ${co(e.dark)}`;
|
|
4215
|
-
}
|
|
4216
|
-
//#endregion
|
|
4217
|
-
//#region src/utils/validate.ts
|
|
4218
|
-
function uo(e) {
|
|
4219
|
-
if (!e.trim()) return "Project name cannot be empty";
|
|
4220
|
-
if (!M.test(e)) return "Project name must be lowercase, alphanumeric, and may contain hyphens, dots, or underscores";
|
|
4221
|
-
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
4222
|
-
}
|
|
4223
|
-
//#endregion
|
|
4224
|
-
//#region src/commands/create.ts
|
|
4225
|
-
async function fo(a) {
|
|
4226
|
-
a.skipBanner || ma(), o.intro(L.brandBold("Create a new Hype Stack project"));
|
|
4227
|
-
let s = a.yes === !0, c;
|
|
4228
|
-
if (s && a.name) {
|
|
4229
|
-
let e = uo(a.name);
|
|
4230
|
-
e && (o.log.error(e), Z()), c = a.name;
|
|
4231
|
-
} else {
|
|
4232
|
-
let e = await o.text({
|
|
4233
|
-
message: "What is your project named?",
|
|
4234
|
-
placeholder: "my-app",
|
|
4235
|
-
initialValue: a.name ?? "",
|
|
4236
|
-
validate: (e) => uo(e ?? "")
|
|
4237
|
-
});
|
|
4238
|
-
o.isCancel(e) && Z(), c = e;
|
|
4239
|
-
}
|
|
4240
|
-
let l;
|
|
4241
|
-
if (a.directory !== void 0) l = a.directory;
|
|
4242
|
-
else {
|
|
4243
|
-
let e;
|
|
4244
|
-
if (a.parentDirectory !== void 0) e = a.parentDirectory;
|
|
4245
|
-
else if (s) e = ".";
|
|
4246
|
-
else {
|
|
4247
|
-
let t = await o.text({
|
|
4248
|
-
message: "Where should we create it? (parent folder, the project gets its own subfolder inside)",
|
|
4249
|
-
placeholder: ".",
|
|
4250
|
-
initialValue: "."
|
|
4251
|
-
});
|
|
4252
|
-
o.isCancel(t) && Z(), e = t;
|
|
4253
|
-
}
|
|
4254
|
-
l = cr(e, c);
|
|
4255
|
-
}
|
|
4256
|
-
let u = w.resolve(l);
|
|
4257
|
-
s || o.note(L.path(u), "Project will be created at");
|
|
4258
|
-
let d = a.editor && oe.includes(a.editor) ? a.editor : null, f;
|
|
4259
|
-
if (d) f = d;
|
|
4260
|
-
else if (s) f = "cursor";
|
|
4261
|
-
else {
|
|
4262
|
-
let e = await o.select({
|
|
4263
|
-
message: "Which code editor do you use?",
|
|
4264
|
-
options: ae.map((e) => ({
|
|
4265
|
-
value: e.value,
|
|
4266
|
-
label: e.label,
|
|
4267
|
-
hint: "hint" in e ? e.hint : void 0
|
|
4268
|
-
})),
|
|
4269
|
-
initialValue: "cursor"
|
|
4270
|
-
});
|
|
4271
|
-
o.isCancel(e) && Z(), f = e;
|
|
4272
|
-
}
|
|
4273
|
-
let p = a.theme !== void 0 && i(a.theme), m;
|
|
4274
|
-
if (p) m = a.theme;
|
|
4275
|
-
else if (s) m = e;
|
|
4276
|
-
else {
|
|
4277
|
-
let t = await o.select({
|
|
4278
|
-
message: "Pick a color theme",
|
|
4279
|
-
options: n.map((e) => ({
|
|
4280
|
-
value: e.name,
|
|
4281
|
-
label: `${lo(e)} ${e.label}`
|
|
4282
|
-
})),
|
|
4283
|
-
initialValue: e
|
|
4284
|
-
});
|
|
4285
|
-
o.isCancel(t) && Z(), m = t;
|
|
4286
|
-
}
|
|
4287
|
-
if (!s) {
|
|
4288
|
-
let e = ae.find((e) => e.value === f)?.label ?? f, n = t.find((e) => e.value === m)?.label ?? m, r = await o.confirm({ message: `Create ${L.highlight(c)} in ${L.path(u)} with ${L.highlight(e)} config and the ${L.highlight(n)} theme?` });
|
|
4289
|
-
(o.isCancel(r) || !r) && Z();
|
|
4290
|
-
}
|
|
4291
|
-
if (await J(u) && !await rr(u)) {
|
|
4292
|
-
let e = await o.confirm({
|
|
4293
|
-
message: `Directory ${L.path(u)} is not empty. Continue anyway?`,
|
|
4294
|
-
initialValue: !1
|
|
4295
|
-
});
|
|
4296
|
-
(o.isCancel(e) || !e) && Z();
|
|
4297
|
-
}
|
|
4298
|
-
let h = o.spinner();
|
|
4299
|
-
h.start("Cloning Hype Stack template..."), await wa(u), h.stop(L.success("Template cloned"));
|
|
4300
|
-
let g = o.spinner();
|
|
4301
|
-
g.start("Setting up project..."), await Ia(u), await Ra(u, c), await ja(u, f);
|
|
4302
|
-
let _ = await hr(u), v = _r(c, _);
|
|
4303
|
-
await mr(u, v), await $a(u, {
|
|
4304
|
-
projectName: c,
|
|
4305
|
-
editor: f,
|
|
4306
|
-
workspace: _
|
|
4307
|
-
}), i(m) && (await Ca(w.resolve(u, v.paths?.frontend.root ?? "apps/frontend"), r(m)) || o.log.warn(L.muted(`Could not find ${L.path("assets/styles.css")} to apply the ${m} theme`))), g.stop(L.success("Project configured"));
|
|
4308
|
-
let y = o.spinner();
|
|
4309
|
-
y.start("Installing dependencies..."), (await q("pnpm", ["install"], { cwd: u })).exitCode === 0 ? y.stop(L.success("Dependencies installed")) : (y.stop(L.warning("Dependencies installed with warnings")), o.log.warn(L.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4310
|
-
let b = o.spinner();
|
|
4311
|
-
b.start("Initializing git repository..."), await La(u), b.stop(L.success("Git repository initialized with clean history"));
|
|
4312
|
-
let x = o.spinner();
|
|
4313
|
-
x.start("Creating .env files from examples...");
|
|
4314
|
-
let S = await Na(u);
|
|
4315
|
-
if (S.length > 0) {
|
|
4316
|
-
let e = S.length;
|
|
4317
|
-
x.stop(L.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4318
|
-
} else x.stop(L.muted("No .env.example files to copy"));
|
|
4319
|
-
o.log.success(`${L.brandBold("Hype Stack")} project ${L.highlight(c)} is ready!`);
|
|
4320
|
-
let C = w.relative(process.cwd(), u) || ".", T = [`${L.command(`cd ${C}`)}`];
|
|
4321
|
-
S.length > 0 ? T.push(`Review your ${L.path(".env")} files and fill in any secrets`) : T.push(`Copy ${L.path(".env.example")} to ${L.path(".env")} and configure`), Wi(T);
|
|
4322
|
-
let E = a.setup === !1;
|
|
4323
|
-
if (a.deferSetup) o.log.info(L.muted("Docker and migrations will run after your packs are installed."));
|
|
4324
|
-
else {
|
|
4325
|
-
let e = !E && (s || await o.confirm({
|
|
4326
|
-
message: "Would you like to start Docker services and run database migrations now?",
|
|
4327
|
-
initialValue: !0
|
|
4328
|
-
}));
|
|
4329
|
-
o.isCancel(e) && Z(), e ? await Xi(u, s) : (o.log.info(L.muted("You can start services later:")), Wi([
|
|
4330
|
-
`${L.command("docker compose up -d")} ${L.muted("(in apps/backend - start Postgres, Valkey, RustFS)")}`,
|
|
4331
|
-
`${L.command("pnpm --filter @internal/backend migration:latest")} ${L.muted("(apply migrations)")}`,
|
|
4332
|
-
`${L.command("pnpm run generate")} ${L.muted("(generate Prisma client)")}`
|
|
4333
|
-
])), Wi([`${L.command("pnpm dev")} ${L.muted("(start frontend + backend)")}`]);
|
|
4334
|
-
}
|
|
4335
|
-
return await eo("project_create"), o.outro(L.muted("Happy building!")), u;
|
|
4336
|
-
}
|
|
4337
|
-
//#endregion
|
|
4338
|
-
//#region src/commands/init.ts
|
|
4339
|
-
async function po(e) {
|
|
4340
|
-
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4341
|
-
if (n || (ha(), o.intro(L.brandBold("Initialize Hype Stack configuration"))), !await vr(t)) {
|
|
4342
|
-
o.log.error(`This doesn't look like a Hype Stack project. ${L.muted("Expected apps/ directory and package.json")}`), o.outro(L.muted(`Run ${L.command("npx @hype-stack/cli create")} to scaffold a new project.`));
|
|
4343
|
-
return;
|
|
4344
|
-
}
|
|
4345
|
-
if (await pr(t)) {
|
|
4346
|
-
let e = await fr(t);
|
|
4347
|
-
if (e && !n) {
|
|
4348
|
-
o.log.info(`Found existing ${L.path("stack.json")} for project ${L.highlight(e.name)}`);
|
|
4349
|
-
let t = await o.confirm({
|
|
4350
|
-
message: "Overwrite existing configuration?",
|
|
4351
|
-
initialValue: !1
|
|
4352
|
-
});
|
|
4353
|
-
if (o.isCancel(t) || !t) {
|
|
4354
|
-
o.outro(L.muted("Keeping existing configuration."));
|
|
4355
|
-
return;
|
|
4356
|
-
}
|
|
4357
|
-
}
|
|
4358
|
-
}
|
|
4359
|
-
let r = await hr(t);
|
|
4360
|
-
if (!n) {
|
|
4361
|
-
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4362
|
-
if (e.length > 0) {
|
|
4363
|
-
o.log.info(L.bold("Detected apps:"));
|
|
4364
|
-
for (let [t, n] of e) o.log.message(` ${R.arrow} ${L.highlight(t)} ${L.muted(`→ ${n}`)}`);
|
|
4365
|
-
}
|
|
4366
|
-
if (t.length > 0) {
|
|
4367
|
-
o.log.info(L.bold("Detected packages:"));
|
|
4368
|
-
for (let [e, n] of t) o.log.message(` ${R.arrow} ${L.highlight(e)} ${L.muted(`→ ${n}`)}`);
|
|
4369
|
-
}
|
|
4370
|
-
e.length === 0 && t.length === 0 && o.log.warn("No apps or packages detected in the workspace.");
|
|
4371
|
-
}
|
|
4372
|
-
let i = (await ir(w.join(t, "package.json")))?.name?.replace(/^@/, "").replace(/\/source$/, "") ?? "my-app", a = i;
|
|
4373
|
-
if (!n) {
|
|
4374
|
-
let e = await o.text({
|
|
4375
|
-
message: "Project name for stack.json?",
|
|
4376
|
-
placeholder: i,
|
|
4377
|
-
initialValue: i
|
|
4378
|
-
});
|
|
4379
|
-
o.isCancel(e) && Z(), a = e;
|
|
4380
|
-
}
|
|
4381
|
-
await mr(t, _r(a, r)), n || (o.log.success(`${L.path("stack.json")} written successfully`), o.outro(L.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
|
|
4382
|
-
}
|
|
4383
|
-
async function mo(e, t = {}) {
|
|
4384
|
-
if (await pr(e)) return {
|
|
4385
|
-
projectRoot: e,
|
|
4386
|
-
scaffolded: !1
|
|
4387
|
-
};
|
|
4388
|
-
let n = t.runInit ?? ((e) => po({
|
|
4389
|
-
cwd: e,
|
|
4390
|
-
silent: !0
|
|
4391
|
-
})), r = t.runCreate ?? ((e) => fo({
|
|
4392
|
-
parentDirectory: e,
|
|
4393
|
-
deferSetup: !0,
|
|
4394
|
-
skipBanner: !0
|
|
4395
|
-
}));
|
|
4396
|
-
if (await vr(e)) {
|
|
4397
|
-
o.log.warn(`No ${L.path("stack.json")} found in ${L.path(e)}.`);
|
|
4398
|
-
let t = await o.confirm({
|
|
4399
|
-
message: `Create ${L.path("stack.json")} now?`,
|
|
4400
|
-
initialValue: !0
|
|
4401
|
-
});
|
|
4402
|
-
if (o.isCancel(t) || !t) return null;
|
|
4403
|
-
await n(e);
|
|
4404
|
-
let r = await pr(e);
|
|
4405
|
-
return r && o.log.success(`${L.path("stack.json")} created`), r ? {
|
|
4406
|
-
projectRoot: e,
|
|
4407
|
-
scaffolded: !1
|
|
4408
|
-
} : null;
|
|
4409
|
-
}
|
|
4410
|
-
o.log.warn(`This doesn't look like a Hype Stack project, and there's no ${L.path("stack.json")} here.`);
|
|
4411
|
-
let i = await o.confirm({
|
|
4412
|
-
message: `Is ${L.path(e)} where you want to work?`,
|
|
4413
|
-
initialValue: !0
|
|
4414
|
-
});
|
|
4415
|
-
if (o.isCancel(i) || !i) return null;
|
|
4416
|
-
let a = await o.confirm({
|
|
4417
|
-
message: "Create a new Hype Stack project here?",
|
|
4418
|
-
initialValue: !0
|
|
4419
|
-
});
|
|
4420
|
-
if (o.isCancel(a) || !a) return null;
|
|
4421
|
-
let s = await r(e);
|
|
4422
|
-
return await pr(s) ? {
|
|
4423
|
-
projectRoot: s,
|
|
4424
|
-
scaffolded: !0
|
|
4425
|
-
} : null;
|
|
4426
|
-
}
|
|
4427
|
-
//#endregion
|
|
4428
4180
|
//#region src/core/npm-deps.ts
|
|
4429
4181
|
function ho(e, t) {
|
|
4430
4182
|
let n = [], r = [];
|
|
@@ -4468,12 +4220,12 @@ function go(e) {
|
|
|
4468
4220
|
async function _o(e, t, n = q) {
|
|
4469
4221
|
let r = [];
|
|
4470
4222
|
for (let i of e) {
|
|
4471
|
-
let e =
|
|
4472
|
-
if (!await
|
|
4223
|
+
let e = T.join(t, i.relativeDir);
|
|
4224
|
+
if (!await J(T.join(e, "package.json"))) {
|
|
4473
4225
|
r.push(`Cannot install npm dependencies under "${i.relativeDir}": package.json not found.`);
|
|
4474
4226
|
continue;
|
|
4475
4227
|
}
|
|
4476
|
-
let a =
|
|
4228
|
+
let a = T.normalize(i.relativeDir), o;
|
|
4477
4229
|
try {
|
|
4478
4230
|
o = await n("pnpm", [
|
|
4479
4231
|
"add",
|
|
@@ -4498,19 +4250,19 @@ async function _o(e, t, n = q) {
|
|
|
4498
4250
|
}
|
|
4499
4251
|
//#endregion
|
|
4500
4252
|
//#region src/commands/install-helpers.ts
|
|
4501
|
-
function
|
|
4253
|
+
function Q(e) {
|
|
4502
4254
|
return e instanceof Error ? e.message : String(e);
|
|
4503
4255
|
}
|
|
4504
4256
|
async function vo(e, t, n) {
|
|
4505
4257
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4506
|
-
return r.length === 0 ? {} :
|
|
4258
|
+
return r.length === 0 ? {} : Dr(r, n).catch(() => ({}));
|
|
4507
4259
|
}
|
|
4508
4260
|
function yo(e, t) {
|
|
4509
|
-
return e === "free" ?
|
|
4261
|
+
return e === "free" ? R.success("free") : e === "owned" ? R.accent("owned") : `${R.highlight(`$${t}`)} ${R.muted("locked")}`;
|
|
4510
4262
|
}
|
|
4511
4263
|
async function bo(e, t, n) {
|
|
4512
4264
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4513
|
-
i.length > 0 &&
|
|
4265
|
+
i.length > 0 && s.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await rr(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4514
4266
|
name: e.name,
|
|
4515
4267
|
displayName: e.displayName,
|
|
4516
4268
|
price: e.price
|
|
@@ -4519,9 +4271,9 @@ async function bo(e, t, n) {
|
|
|
4519
4271
|
function xo(e, t) {
|
|
4520
4272
|
let n = e.map((e, n) => {
|
|
4521
4273
|
let r = t.get(e), i = r ? r.displayName : e;
|
|
4522
|
-
return ` ${
|
|
4274
|
+
return ` ${R.muted(`${n + 1}.`)} ${R.brand(i)}`;
|
|
4523
4275
|
});
|
|
4524
|
-
|
|
4276
|
+
s.note([
|
|
4525
4277
|
"These packs will be installed, in order:",
|
|
4526
4278
|
"",
|
|
4527
4279
|
...n
|
|
@@ -4530,7 +4282,7 @@ function xo(e, t) {
|
|
|
4530
4282
|
async function So(e, t) {
|
|
4531
4283
|
let n = [];
|
|
4532
4284
|
for (let r of e) {
|
|
4533
|
-
let e = await
|
|
4285
|
+
let e = await xr(r), i = await Sr(r, t);
|
|
4534
4286
|
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'npx @hype-stack/cli login' or check your license.`);
|
|
4535
4287
|
n.push({
|
|
4536
4288
|
manifest: e,
|
|
@@ -4542,116 +4294,376 @@ async function So(e, t) {
|
|
|
4542
4294
|
async function Co(e) {
|
|
4543
4295
|
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = ho(go(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4544
4296
|
if (a.errors.length > 0) {
|
|
4545
|
-
for (let e of a.errors)
|
|
4297
|
+
for (let e of a.errors) s.log.error(e);
|
|
4546
4298
|
return;
|
|
4547
4299
|
}
|
|
4548
4300
|
if (a.operations.length === 0) return;
|
|
4549
4301
|
i.start("Installing npm dependencies...");
|
|
4550
|
-
let
|
|
4551
|
-
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);
|
|
4552
4304
|
}
|
|
4553
|
-
function wo(
|
|
4554
|
-
|
|
4555
|
-
n.length !== 0 && o.note(n.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Next Steps");
|
|
4305
|
+
function wo() {
|
|
4306
|
+
s.note([` ${R.command("1. npx @hype-stack/cli onboard")} ${R.muted("(set up env vars + run migrations)")}`, ` ${R.command("2. pnpm dev")} ${R.muted("(start frontend + backend)")}`].join("\n"), "Next steps");
|
|
4556
4307
|
}
|
|
4557
4308
|
function To(e) {
|
|
4558
4309
|
if (e.length === 0) return;
|
|
4559
4310
|
let t = e.map((e) => {
|
|
4560
4311
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
4561
|
-
return ` ${
|
|
4312
|
+
return ` ${R.muted("•")} ${R.path(t)}`;
|
|
4562
4313
|
});
|
|
4563
|
-
|
|
4314
|
+
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4564
4315
|
}
|
|
4565
4316
|
async function Eo(e) {
|
|
4566
|
-
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack:
|
|
4317
|
+
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
|
|
4567
4318
|
if (i) return c;
|
|
4568
|
-
let l = await
|
|
4319
|
+
let l = await Pi({
|
|
4569
4320
|
packs: t,
|
|
4570
4321
|
config: n,
|
|
4571
4322
|
projectRoot: r,
|
|
4572
|
-
slotsByPack:
|
|
4323
|
+
slotsByPack: o
|
|
4573
4324
|
});
|
|
4574
4325
|
if (l.length === 0) return c;
|
|
4575
4326
|
if (a) {
|
|
4576
|
-
|
|
4327
|
+
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${R.command("--force")} to overwrite.`);
|
|
4577
4328
|
let e = l.map((e) => {
|
|
4578
|
-
let t =
|
|
4579
|
-
return ` ${
|
|
4329
|
+
let t = T.relative(r, e.targetPath) || e.target;
|
|
4330
|
+
return ` ${R.muted("•")} ${R.path(t)} ${R.muted(`(${e.packName})`)}`;
|
|
4580
4331
|
});
|
|
4581
|
-
return
|
|
4332
|
+
return s.note(e.join("\n"), "Kept existing files"), c;
|
|
4582
4333
|
}
|
|
4583
|
-
|
|
4334
|
+
s.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4584
4335
|
for (let e of l) {
|
|
4585
|
-
let t =
|
|
4586
|
-
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})`)}`,
|
|
4587
4338
|
initialValue: !1
|
|
4588
4339
|
});
|
|
4589
|
-
|
|
4340
|
+
s.isCancel(n) && (s.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
|
|
4590
4341
|
}
|
|
4591
4342
|
return c;
|
|
4592
4343
|
}
|
|
4593
4344
|
//#endregion
|
|
4345
|
+
//#region src/ui/swatch.ts
|
|
4346
|
+
function Do(e) {
|
|
4347
|
+
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4348
|
+
if (!t) return null;
|
|
4349
|
+
let n = t[1].trim().split(/\s+/);
|
|
4350
|
+
if (n.length < 3) return null;
|
|
4351
|
+
let r = n[0], i = Number(n[1]), a = Number(n[2]);
|
|
4352
|
+
if (Number.isNaN(i) || Number.isNaN(a)) return null;
|
|
4353
|
+
let o;
|
|
4354
|
+
if (r.endsWith("%")) {
|
|
4355
|
+
let e = Number(r.slice(0, -1));
|
|
4356
|
+
if (Number.isNaN(e)) return null;
|
|
4357
|
+
o = e / 100;
|
|
4358
|
+
} else if (o = Number(r), Number.isNaN(o)) return null;
|
|
4359
|
+
return {
|
|
4360
|
+
l: o,
|
|
4361
|
+
c: i,
|
|
4362
|
+
h: a
|
|
4363
|
+
};
|
|
4364
|
+
}
|
|
4365
|
+
function Oo(e) {
|
|
4366
|
+
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4367
|
+
}
|
|
4368
|
+
function ko(e) {
|
|
4369
|
+
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4370
|
+
}
|
|
4371
|
+
function Ao({ l: e, c: t, h: n }) {
|
|
4372
|
+
let r = n * Math.PI / 180, i = t * Math.cos(r), a = t * Math.sin(r), o = e + .3963377774 * i + .2158037573 * a, s = e - .1055613458 * i - .0638541728 * a, c = e - .0894841775 * i - 1.291485548 * a, l = o ** 3, u = s ** 3, d = c ** 3, f = 4.0767416621 * l - 3.3077115913 * u + .2309699292 * d, p = -1.2684380042 * l + 2.6097570613 * u - .3413193965 * d, m = -.0041960863 * l - .7034186147 * u + 1.7076146937 * d;
|
|
4373
|
+
return [
|
|
4374
|
+
Oo(ko(f) * 255),
|
|
4375
|
+
Oo(ko(p) * 255),
|
|
4376
|
+
Oo(ko(m) * 255)
|
|
4377
|
+
];
|
|
4378
|
+
}
|
|
4379
|
+
var jo = "\x1B[49m";
|
|
4380
|
+
function Mo(e, t) {
|
|
4381
|
+
let n = e[t];
|
|
4382
|
+
if (!n) return b.dim(" ");
|
|
4383
|
+
let r = Do(n);
|
|
4384
|
+
if (!r) return b.dim(" ");
|
|
4385
|
+
let [i, a, o] = Ao(r);
|
|
4386
|
+
return `\x1b[48;2;${i};${a};${o}m ${jo}`;
|
|
4387
|
+
}
|
|
4388
|
+
var No = [
|
|
4389
|
+
"primary",
|
|
4390
|
+
"secondary",
|
|
4391
|
+
"accent"
|
|
4392
|
+
];
|
|
4393
|
+
function Po(e) {
|
|
4394
|
+
return No.map((t) => Mo(e, t)).join("");
|
|
4395
|
+
}
|
|
4396
|
+
function Fo(e) {
|
|
4397
|
+
return `${Po(e.light)} ${b.dim("·")} ${Po(e.dark)}`;
|
|
4398
|
+
}
|
|
4399
|
+
//#endregion
|
|
4400
|
+
//#region src/commands/create.ts
|
|
4401
|
+
async function Io(e) {
|
|
4402
|
+
e.skipBanner || xa(), s.intro(R.brandBold("Create a new Hype Stack project"));
|
|
4403
|
+
let o = e.yes === !0, c, l;
|
|
4404
|
+
if (o && e.name) {
|
|
4405
|
+
let t = Da(e.name);
|
|
4406
|
+
t && (s.log.error(t), X()), l = e.name, c = Ta(e.name);
|
|
4407
|
+
} else {
|
|
4408
|
+
let t = await s.text({
|
|
4409
|
+
message: "What is your project named?",
|
|
4410
|
+
placeholder: "my-app",
|
|
4411
|
+
initialValue: e.name ?? "",
|
|
4412
|
+
validate: (e) => Da(e ?? "")
|
|
4413
|
+
});
|
|
4414
|
+
s.isCancel(t) && X(), l = t, c = Ta(l);
|
|
4415
|
+
}
|
|
4416
|
+
l.trim() !== c && s.log.info(R.muted(`Using "${R.highlight(c)}" as the project name`));
|
|
4417
|
+
let u;
|
|
4418
|
+
if (e.directory !== void 0) u = e.directory;
|
|
4419
|
+
else {
|
|
4420
|
+
let t;
|
|
4421
|
+
if (e.parentDirectory !== void 0) t = e.parentDirectory;
|
|
4422
|
+
else if (o) t = ".";
|
|
4423
|
+
else {
|
|
4424
|
+
let e = await s.text({
|
|
4425
|
+
message: "Where should we create it? (parent folder, the project gets its own subfolder inside)",
|
|
4426
|
+
placeholder: ".",
|
|
4427
|
+
initialValue: "."
|
|
4428
|
+
});
|
|
4429
|
+
s.isCancel(e) && X(), t = e;
|
|
4430
|
+
}
|
|
4431
|
+
u = ur(t, c);
|
|
4432
|
+
}
|
|
4433
|
+
let d = T.resolve(u);
|
|
4434
|
+
o || s.note(R.path(d), "Project will be created at");
|
|
4435
|
+
let f = e.editor && ae.includes(e.editor) ? e.editor : null, p;
|
|
4436
|
+
if (f) p = f;
|
|
4437
|
+
else if (o) p = "cursor";
|
|
4438
|
+
else {
|
|
4439
|
+
let e = await s.select({
|
|
4440
|
+
message: "Which code editor do you use?",
|
|
4441
|
+
options: P.map((e) => ({
|
|
4442
|
+
value: e.value,
|
|
4443
|
+
label: e.label,
|
|
4444
|
+
hint: "hint" in e ? e.hint : void 0
|
|
4445
|
+
})),
|
|
4446
|
+
initialValue: "cursor"
|
|
4447
|
+
});
|
|
4448
|
+
s.isCancel(e) && X(), p = e;
|
|
4449
|
+
}
|
|
4450
|
+
let m = e.theme !== void 0 && a(e.theme), h = e.defaultTheme !== void 0 && a(e.defaultTheme) ? e.defaultTheme : t, g;
|
|
4451
|
+
if (m) g = e.theme;
|
|
4452
|
+
else if (o) g = h;
|
|
4453
|
+
else {
|
|
4454
|
+
let e = await s.select({
|
|
4455
|
+
message: "Pick a color theme",
|
|
4456
|
+
options: r.map((e) => ({
|
|
4457
|
+
value: e.name,
|
|
4458
|
+
label: `${Fo(e)} ${e.label}`
|
|
4459
|
+
})),
|
|
4460
|
+
initialValue: h
|
|
4461
|
+
});
|
|
4462
|
+
s.isCancel(e) && X(), g = e;
|
|
4463
|
+
}
|
|
4464
|
+
if (!o) {
|
|
4465
|
+
let e = P.find((e) => e.value === p)?.label ?? p, t = n.find((e) => e.value === g)?.label ?? g, r = await s.confirm({ message: `Create ${R.highlight(c)} in ${R.path(d)} with ${R.highlight(e)} config and the ${R.highlight(t)} theme?` });
|
|
4466
|
+
(s.isCancel(r) || !r) && X();
|
|
4467
|
+
}
|
|
4468
|
+
if (await ir(d) && !await ar(d)) {
|
|
4469
|
+
let e = await s.confirm({
|
|
4470
|
+
message: `Directory ${R.path(d)} is not empty. Continue anyway?`,
|
|
4471
|
+
initialValue: !1
|
|
4472
|
+
});
|
|
4473
|
+
(s.isCancel(e) || !e) && X();
|
|
4474
|
+
}
|
|
4475
|
+
let _ = s.spinner();
|
|
4476
|
+
_.start("Cloning Hype Stack template..."), await Ra(d), _.stop(R.success("Template cloned"));
|
|
4477
|
+
let v = s.spinner();
|
|
4478
|
+
v.start("Setting up project..."), await Xa(d), await Qa(d, c), await Ga(d, p);
|
|
4479
|
+
let y = await _r(d), b = yr(c, y);
|
|
4480
|
+
await gr(d, b), await po(d, {
|
|
4481
|
+
projectName: c,
|
|
4482
|
+
editor: p,
|
|
4483
|
+
workspace: y
|
|
4484
|
+
});
|
|
4485
|
+
let x = T.resolve(d, b.paths?.frontend.root ?? "apps/frontend");
|
|
4486
|
+
a(g) && (await La(x, i(g)) || s.log.warn(R.muted(`Could not find ${R.path("assets/styles.css")} to apply the ${g} theme`))), await ja(x, e.defaultMode === "dark" || e.defaultMode === "light" ? e.defaultMode : "light") || s.log.warn(R.muted(`Could not find ${R.path("src/hooks/use-theme.ts")} to set the default color mode`)), v.stop(R.success("Project configured"));
|
|
4487
|
+
let S = s.spinner();
|
|
4488
|
+
S.start("Installing dependencies..."), (await q("pnpm", ["install"], { cwd: d })).exitCode === 0 ? S.stop(R.success("Dependencies installed")) : (S.stop(R.warning("Dependencies installed with warnings")), s.log.warn(R.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4489
|
+
let C = s.spinner();
|
|
4490
|
+
C.start("Initializing git repository..."), await Za(d), C.stop(R.success("Git repository initialized with clean history"));
|
|
4491
|
+
let w = s.spinner();
|
|
4492
|
+
w.start("Creating .env files from examples...");
|
|
4493
|
+
let E = await qa(d);
|
|
4494
|
+
if (E.length > 0) {
|
|
4495
|
+
let e = E.length;
|
|
4496
|
+
w.stop(R.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4497
|
+
} else w.stop(R.muted("No .env.example files to copy"));
|
|
4498
|
+
s.log.success(`${R.brandBold("Hype Stack")} project ${R.highlight(c)} is ready!`);
|
|
4499
|
+
let D = T.relative(process.cwd(), d) || ".", O = [`${R.command(`cd ${D}`)}`];
|
|
4500
|
+
E.length > 0 ? O.push(`Review your ${R.path(".env")} files and fill in any secrets`) : O.push(`Copy ${R.path(".env.example")} to ${R.path(".env")} and configure`), Ki(O);
|
|
4501
|
+
let k = e.setup === !1;
|
|
4502
|
+
if (e.deferSetup) s.log.info(R.muted("Docker and migrations will run after your packs are installed."));
|
|
4503
|
+
else {
|
|
4504
|
+
let e = !k && (o || await s.confirm({
|
|
4505
|
+
message: "Would you like to start Docker services and run database migrations now?",
|
|
4506
|
+
initialValue: !0
|
|
4507
|
+
}));
|
|
4508
|
+
s.isCancel(e) && X(), e ? await ra(d, o) : s.log.info(R.muted("Docker and migrations can run later via `npx @hype-stack/cli onboard`.")), wo();
|
|
4509
|
+
}
|
|
4510
|
+
return await mo("project_create"), s.outro(R.muted("Happy building!")), d;
|
|
4511
|
+
}
|
|
4512
|
+
//#endregion
|
|
4513
|
+
//#region src/commands/init.ts
|
|
4514
|
+
async function Lo(e) {
|
|
4515
|
+
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4516
|
+
if (n || (Sa(), s.intro(R.brandBold("Initialize Hype Stack configuration"))), !await br(t)) {
|
|
4517
|
+
s.log.error(`This doesn't look like a Hype Stack project. ${R.muted("Expected apps/ directory and package.json")}`), s.outro(R.muted(`Run ${R.command("npx @hype-stack/cli create")} to scaffold a new project.`));
|
|
4518
|
+
return;
|
|
4519
|
+
}
|
|
4520
|
+
if (await hr(t)) {
|
|
4521
|
+
let e = await mr(t);
|
|
4522
|
+
if (e && !n) {
|
|
4523
|
+
s.log.info(`Found existing ${R.path("stack.json")} for project ${R.highlight(e.name)}`);
|
|
4524
|
+
let t = await s.confirm({
|
|
4525
|
+
message: "Overwrite existing configuration?",
|
|
4526
|
+
initialValue: !1
|
|
4527
|
+
});
|
|
4528
|
+
if (s.isCancel(t) || !t) {
|
|
4529
|
+
s.outro(R.muted("Keeping existing configuration."));
|
|
4530
|
+
return;
|
|
4531
|
+
}
|
|
4532
|
+
}
|
|
4533
|
+
}
|
|
4534
|
+
let r = await _r(t);
|
|
4535
|
+
if (!n) {
|
|
4536
|
+
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4537
|
+
if (e.length > 0) {
|
|
4538
|
+
s.log.info(R.bold("Detected apps:"));
|
|
4539
|
+
for (let [t, n] of e) s.log.message(` ${z.arrow} ${R.highlight(t)} ${R.muted(`→ ${n}`)}`);
|
|
4540
|
+
}
|
|
4541
|
+
if (t.length > 0) {
|
|
4542
|
+
s.log.info(R.bold("Detected packages:"));
|
|
4543
|
+
for (let [e, n] of t) s.log.message(` ${z.arrow} ${R.highlight(e)} ${R.muted(`→ ${n}`)}`);
|
|
4544
|
+
}
|
|
4545
|
+
e.length === 0 && t.length === 0 && s.log.warn("No apps or packages detected in the workspace.");
|
|
4546
|
+
}
|
|
4547
|
+
let i = (await or(T.join(t, "package.json")))?.name?.replace(/^@/, "").replace(/\/source$/, "") ?? "my-app", a = i;
|
|
4548
|
+
if (!n) {
|
|
4549
|
+
let e = await s.text({
|
|
4550
|
+
message: "Project name for stack.json?",
|
|
4551
|
+
placeholder: i,
|
|
4552
|
+
initialValue: i,
|
|
4553
|
+
validate: (e) => Da(e ?? "")
|
|
4554
|
+
});
|
|
4555
|
+
s.isCancel(e) && X(), a = Ta(e);
|
|
4556
|
+
}
|
|
4557
|
+
await gr(t, yr(a, r)), n || (s.log.success(`${R.path("stack.json")} written successfully`), s.outro(R.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
|
|
4558
|
+
}
|
|
4559
|
+
async function Ro(e, t = {}, n) {
|
|
4560
|
+
if (await hr(e)) return {
|
|
4561
|
+
projectRoot: e,
|
|
4562
|
+
scaffolded: !1
|
|
4563
|
+
};
|
|
4564
|
+
let r = t.runInit ?? ((e) => Lo({
|
|
4565
|
+
cwd: e,
|
|
4566
|
+
silent: !0
|
|
4567
|
+
})), i = t.runCreate ?? ((e, t) => Io({
|
|
4568
|
+
parentDirectory: e,
|
|
4569
|
+
deferSetup: !0,
|
|
4570
|
+
skipBanner: !0,
|
|
4571
|
+
defaultTheme: t?.defaultTheme,
|
|
4572
|
+
defaultMode: t?.defaultMode
|
|
4573
|
+
}));
|
|
4574
|
+
if (await br(e)) {
|
|
4575
|
+
s.log.warn(`No ${R.path("stack.json")} found in ${R.path(e)}.`);
|
|
4576
|
+
let t = await s.confirm({
|
|
4577
|
+
message: `Create ${R.path("stack.json")} now?`,
|
|
4578
|
+
initialValue: !0
|
|
4579
|
+
});
|
|
4580
|
+
if (s.isCancel(t) || !t) return null;
|
|
4581
|
+
await r(e);
|
|
4582
|
+
let n = await hr(e);
|
|
4583
|
+
return n && s.log.success(`${R.path("stack.json")} created`), n ? {
|
|
4584
|
+
projectRoot: e,
|
|
4585
|
+
scaffolded: !1
|
|
4586
|
+
} : null;
|
|
4587
|
+
}
|
|
4588
|
+
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${R.path("stack.json")} here.`);
|
|
4589
|
+
let a = await s.confirm({
|
|
4590
|
+
message: `Is ${R.path(e)} where you want to work?`,
|
|
4591
|
+
initialValue: !0
|
|
4592
|
+
});
|
|
4593
|
+
if (s.isCancel(a) || !a) return null;
|
|
4594
|
+
let o = await s.confirm({
|
|
4595
|
+
message: "Create a new Hype Stack project here?",
|
|
4596
|
+
initialValue: !0
|
|
4597
|
+
});
|
|
4598
|
+
if (s.isCancel(o) || !o) return null;
|
|
4599
|
+
let c = await i(e, n);
|
|
4600
|
+
return await hr(c) ? {
|
|
4601
|
+
projectRoot: c,
|
|
4602
|
+
scaffolded: !0
|
|
4603
|
+
} : null;
|
|
4604
|
+
}
|
|
4605
|
+
//#endregion
|
|
4594
4606
|
//#region src/commands/compose.ts
|
|
4595
|
-
async function
|
|
4607
|
+
async function zo(e = {}) {
|
|
4596
4608
|
let t = e.cwd ?? process.cwd();
|
|
4597
|
-
|
|
4598
|
-
let n = await
|
|
4609
|
+
xa();
|
|
4610
|
+
let n = await Ro(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4599
4611
|
try {
|
|
4600
|
-
a = await
|
|
4612
|
+
a = await mr(r ?? t);
|
|
4601
4613
|
} catch (e) {
|
|
4602
|
-
|
|
4614
|
+
s.cancel(`Could not parse ${R.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4603
4615
|
}
|
|
4604
|
-
a || (
|
|
4605
|
-
let
|
|
4606
|
-
|
|
4607
|
-
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();
|
|
4608
4620
|
c.start("Loading packs...");
|
|
4609
4621
|
let l;
|
|
4610
4622
|
try {
|
|
4611
|
-
l = await
|
|
4623
|
+
l = await Er();
|
|
4612
4624
|
} catch (e) {
|
|
4613
|
-
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);
|
|
4614
4626
|
}
|
|
4615
4627
|
c.stop("Packs loaded");
|
|
4616
|
-
let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await
|
|
4628
|
+
let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await Kn(F()))?.token ?? null, h = await vo(l, d, {
|
|
4617
4629
|
token: m,
|
|
4618
4630
|
key: p
|
|
4619
4631
|
}), g = (e) => {
|
|
4620
4632
|
let t = f.get(e);
|
|
4621
4633
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4622
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked",
|
|
4634
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await Bo({
|
|
4623
4635
|
packs: l,
|
|
4624
4636
|
installedSet: d,
|
|
4625
4637
|
stateOf: g,
|
|
4626
4638
|
options: e,
|
|
4627
4639
|
adminAvailable: !!a.apps.admin
|
|
4628
4640
|
});
|
|
4629
|
-
if (
|
|
4630
|
-
|
|
4641
|
+
if (v === null && (s.cancel("Cancelled."), process.exit(0)), v.length === 0) {
|
|
4642
|
+
s.outro(R.muted("No packs selected. Nothing to do."));
|
|
4631
4643
|
return;
|
|
4632
4644
|
}
|
|
4633
|
-
let b =
|
|
4645
|
+
let b = Uo(v), x = Wo(v), S = da(l, b), C = ia(fa(l, S)), w;
|
|
4634
4646
|
try {
|
|
4635
|
-
w =
|
|
4647
|
+
w = oa(b, C, u);
|
|
4636
4648
|
} catch (e) {
|
|
4637
|
-
|
|
4649
|
+
s.cancel(Q(e)), process.exit(1);
|
|
4638
4650
|
}
|
|
4639
4651
|
if (w.order.length === 0) {
|
|
4640
|
-
|
|
4652
|
+
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(R.muted("Your selection is already part of the project."));
|
|
4641
4653
|
return;
|
|
4642
4654
|
}
|
|
4643
|
-
let T =
|
|
4655
|
+
let T = sa({
|
|
4644
4656
|
order: w.order,
|
|
4645
4657
|
graph: C,
|
|
4646
4658
|
isLocked: _,
|
|
4647
4659
|
installed: u
|
|
4648
4660
|
});
|
|
4649
4661
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4650
|
-
let e = await
|
|
4662
|
+
let e = await nr();
|
|
4651
4663
|
e && (m = e, h = await vo(l, d, {
|
|
4652
4664
|
token: m,
|
|
4653
4665
|
key: p
|
|
4654
|
-
}), T =
|
|
4666
|
+
}), T = sa({
|
|
4655
4667
|
order: w.order,
|
|
4656
4668
|
graph: C,
|
|
4657
4669
|
isLocked: _,
|
|
@@ -4659,12 +4671,12 @@ async function Do(e = {}) {
|
|
|
4659
4671
|
}));
|
|
4660
4672
|
}
|
|
4661
4673
|
if (T.blocked.length > 0 && await bo(T.blocked, _, f), T.installable.length === 0) {
|
|
4662
|
-
|
|
4674
|
+
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
4663
4675
|
return;
|
|
4664
4676
|
}
|
|
4665
4677
|
if (xo(T.installable, f), !e.yes) {
|
|
4666
|
-
let e = await
|
|
4667
|
-
(
|
|
4678
|
+
let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4679
|
+
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
4668
4680
|
}
|
|
4669
4681
|
c.start("Downloading packs...");
|
|
4670
4682
|
let E;
|
|
@@ -4674,64 +4686,64 @@ async function Do(e = {}) {
|
|
|
4674
4686
|
key: p
|
|
4675
4687
|
});
|
|
4676
4688
|
} catch (e) {
|
|
4677
|
-
c.stop("Download failed"),
|
|
4689
|
+
c.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
|
|
4678
4690
|
}
|
|
4679
4691
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4680
4692
|
let D = await Eo({
|
|
4681
4693
|
prepared: E,
|
|
4682
4694
|
config: a,
|
|
4683
|
-
cwd:
|
|
4695
|
+
cwd: o,
|
|
4684
4696
|
force: e.force ?? !1,
|
|
4685
4697
|
yes: e.yes ?? !1,
|
|
4686
4698
|
slotsByPack: x
|
|
4687
4699
|
});
|
|
4688
4700
|
try {
|
|
4689
4701
|
c.start("Installing pack files...");
|
|
4690
|
-
let t = await
|
|
4702
|
+
let t = await Li({
|
|
4691
4703
|
packs: E,
|
|
4692
4704
|
config: a,
|
|
4693
|
-
projectRoot:
|
|
4705
|
+
projectRoot: o,
|
|
4694
4706
|
force: e.force ?? !1,
|
|
4695
4707
|
overwrite: D,
|
|
4696
4708
|
slotsByPack: x
|
|
4697
4709
|
});
|
|
4698
4710
|
if (t.aborted) {
|
|
4699
4711
|
c.stop("Installation aborted");
|
|
4700
|
-
for (let e of t.errors)
|
|
4701
|
-
|
|
4712
|
+
for (let e of t.errors) s.log.error(e);
|
|
4713
|
+
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4702
4714
|
}
|
|
4703
|
-
c.stop("Files installed"), t.installed.length > 0 &&
|
|
4704
|
-
for (let e of t.errors)
|
|
4715
|
+
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${R.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (s.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`), To(t.skipped));
|
|
4716
|
+
for (let e of t.errors) s.log.error(e);
|
|
4705
4717
|
await Co({
|
|
4706
4718
|
prepared: E,
|
|
4707
4719
|
paths: a.paths,
|
|
4708
|
-
cwd:
|
|
4720
|
+
cwd: o,
|
|
4709
4721
|
spinner: c
|
|
4710
|
-
}), i && await
|
|
4711
|
-
projectRoot:
|
|
4722
|
+
}), i && await ra(o, e.yes ?? !1), await fr({
|
|
4723
|
+
projectRoot: o,
|
|
4712
4724
|
paths: a.paths,
|
|
4713
4725
|
skipPrompts: e.yes ?? !1
|
|
4714
|
-
}), wo(
|
|
4726
|
+
}), wo(), s.outro(R.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4715
4727
|
} finally {
|
|
4716
|
-
await Promise.all(E.map((e) =>
|
|
4728
|
+
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
4717
4729
|
recursive: !0,
|
|
4718
4730
|
force: !0
|
|
4719
4731
|
})));
|
|
4720
4732
|
}
|
|
4721
4733
|
}
|
|
4722
|
-
async function
|
|
4734
|
+
async function Bo(e) {
|
|
4723
4735
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4724
4736
|
if (i.packs && i.packs.length > 0) {
|
|
4725
|
-
let e = i.packs.map(
|
|
4726
|
-
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;
|
|
4727
4739
|
}
|
|
4728
|
-
let
|
|
4729
|
-
|
|
4740
|
+
let o = t.filter((e) => n.has(e.name));
|
|
4741
|
+
o.length > 0 && s.note(o.map((e) => ` ${R.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4730
4742
|
let c = t.filter((e) => !n.has(e.name));
|
|
4731
|
-
if (c.length === 0) return
|
|
4732
|
-
let l =
|
|
4733
|
-
|
|
4734
|
-
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 = [];
|
|
4735
4747
|
for (let e of u) {
|
|
4736
4748
|
let t = e.packs.map((e) => {
|
|
4737
4749
|
let t = r(e.name);
|
|
@@ -4742,42 +4754,42 @@ async function Oo(e) {
|
|
|
4742
4754
|
};
|
|
4743
4755
|
});
|
|
4744
4756
|
if (e.mode === "single") {
|
|
4745
|
-
let n = await
|
|
4757
|
+
let n = await s.select({
|
|
4746
4758
|
message: `Choose a ${e.label.toLowerCase()}`,
|
|
4747
4759
|
options: t,
|
|
4748
4760
|
initialValue: e.preselect ?? e.packs[0].name
|
|
4749
4761
|
});
|
|
4750
|
-
if (
|
|
4762
|
+
if (s.isCancel(n)) return null;
|
|
4751
4763
|
d.push({
|
|
4752
4764
|
name: n,
|
|
4753
4765
|
slot: e.slot
|
|
4754
4766
|
});
|
|
4755
4767
|
continue;
|
|
4756
4768
|
}
|
|
4757
|
-
let n = await
|
|
4769
|
+
let n = await wa({
|
|
4758
4770
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4759
4771
|
options: t,
|
|
4760
4772
|
required: !1
|
|
4761
4773
|
});
|
|
4762
|
-
if (
|
|
4774
|
+
if (m(n)) return null;
|
|
4763
4775
|
for (let e of n) d.push({ name: e });
|
|
4764
4776
|
}
|
|
4765
4777
|
return d;
|
|
4766
4778
|
}
|
|
4767
|
-
var
|
|
4768
|
-
function
|
|
4769
|
-
let t = e.match(
|
|
4779
|
+
var Vo = /@(frontend|admin)$/;
|
|
4780
|
+
function Ho(e) {
|
|
4781
|
+
let t = e.match(Vo);
|
|
4770
4782
|
return t ? {
|
|
4771
4783
|
name: e.slice(0, -t[0].length),
|
|
4772
4784
|
slot: t[1]
|
|
4773
4785
|
} : { name: e };
|
|
4774
4786
|
}
|
|
4775
|
-
function
|
|
4787
|
+
function Uo(e) {
|
|
4776
4788
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4777
4789
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4778
4790
|
return n;
|
|
4779
4791
|
}
|
|
4780
|
-
function
|
|
4792
|
+
function Wo(e) {
|
|
4781
4793
|
let t = /* @__PURE__ */ new Map();
|
|
4782
4794
|
for (let n of e) {
|
|
4783
4795
|
if (!n.slot) continue;
|
|
@@ -4788,41 +4800,258 @@ function Mo(e) {
|
|
|
4788
4800
|
}
|
|
4789
4801
|
//#endregion
|
|
4790
4802
|
//#region src/commands/login.ts
|
|
4791
|
-
async function
|
|
4792
|
-
|
|
4803
|
+
async function Go() {
|
|
4804
|
+
Sa(), s.intro(R.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
4793
4805
|
let e;
|
|
4794
4806
|
try {
|
|
4795
|
-
e = await
|
|
4796
|
-
|
|
4807
|
+
e = await tr({ onUrl: (e) => {
|
|
4808
|
+
s.log.info(`If your browser didn't open, visit:\n ${R.path(e)}`);
|
|
4797
4809
|
} });
|
|
4798
4810
|
} catch (e) {
|
|
4799
|
-
|
|
4811
|
+
s.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
|
|
4800
4812
|
}
|
|
4801
|
-
|
|
4813
|
+
s.outro(R.brand(e.email ? `Logged in as ${e.email}. You can now install packs your organization owns.` : "Logged in. You can now install packs your organization owns."));
|
|
4802
4814
|
}
|
|
4803
4815
|
//#endregion
|
|
4804
4816
|
//#region src/commands/logout.ts
|
|
4805
|
-
async function
|
|
4806
|
-
|
|
4807
|
-
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);
|
|
4808
4820
|
if (!t) {
|
|
4809
|
-
|
|
4821
|
+
s.outro(R.muted("You're not logged in."));
|
|
4822
|
+
return;
|
|
4823
|
+
}
|
|
4824
|
+
await Rn(t.token).catch(() => null), await Jn(e), s.outro(R.brand("Logged out."));
|
|
4825
|
+
}
|
|
4826
|
+
//#endregion
|
|
4827
|
+
//#region src/core/onboard-catalog.ts
|
|
4828
|
+
var $ = {
|
|
4829
|
+
Config: "config",
|
|
4830
|
+
Databases: "databases",
|
|
4831
|
+
Workos: "workos",
|
|
4832
|
+
BetterAuth: "betterauth",
|
|
4833
|
+
Stripe: "stripe",
|
|
4834
|
+
Polar: "polar",
|
|
4835
|
+
Resend: "resend",
|
|
4836
|
+
IpLocate: "iplocate",
|
|
4837
|
+
Sentry: "sentry"
|
|
4838
|
+
}, qo = new Set(Object.values($));
|
|
4839
|
+
function Jo(e) {
|
|
4840
|
+
return e.toLowerCase().replace(/[^a-z0-9]+/g, "").trim();
|
|
4841
|
+
}
|
|
4842
|
+
function Yo(e) {
|
|
4843
|
+
let t = Jo(e);
|
|
4844
|
+
return qo.has(t) ? t : void 0;
|
|
4845
|
+
}
|
|
4846
|
+
var Xo = {
|
|
4847
|
+
[$.Config]: { hint: "App URLs. Defaults work for local dev." },
|
|
4848
|
+
[$.Databases]: { hint: "Credentials for the local Docker Postgres and Valkey containers." },
|
|
4849
|
+
[$.Workos]: {
|
|
4850
|
+
link: "https://dashboard.workos.com/api-keys",
|
|
4851
|
+
hint: "Copy your API Key and Client ID from the WorkOS dashboard."
|
|
4852
|
+
},
|
|
4853
|
+
[$.BetterAuth]: {
|
|
4854
|
+
link: "https://www.better-auth.com/docs/installation#set-environment-variables",
|
|
4855
|
+
hint: "Generate a long random secret, set the app URL, add Google OAuth creds if you use Google."
|
|
4856
|
+
},
|
|
4857
|
+
[$.Stripe]: {
|
|
4858
|
+
link: "https://dashboard.stripe.com/apikeys",
|
|
4859
|
+
hint: "Copy your secret and publishable keys from the Stripe dashboard.",
|
|
4860
|
+
serviceChecklist: [
|
|
4861
|
+
"Recurring prices for Pro and Premier power checkout (set STRIPE_PRICE_PRO and STRIPE_PRICE_PREMIER).",
|
|
4862
|
+
"A webhook at /checkout/webhook keeps subscriptions in sync (subscription events plus invoice.payment_succeeded).",
|
|
4863
|
+
"Enable the Stripe billing portal so Manage Billing and invoices work.",
|
|
4864
|
+
"Enable 'Limit customers to one subscription' to prevent double-checkout races.",
|
|
4865
|
+
"Optional: disable Cash App Pay if you see a high checkout cancel rate."
|
|
4866
|
+
]
|
|
4867
|
+
},
|
|
4868
|
+
[$.Polar]: {
|
|
4869
|
+
link: "https://polar.sh",
|
|
4870
|
+
hint: "From your Polar org: access token, webhook secret, organization id, and the checkout product id."
|
|
4871
|
+
},
|
|
4872
|
+
[$.Resend]: {
|
|
4873
|
+
link: "https://resend.com/api-keys",
|
|
4874
|
+
hint: "Create an API key in Resend."
|
|
4875
|
+
},
|
|
4876
|
+
[$.IpLocate]: {
|
|
4877
|
+
link: "https://iplocate.io",
|
|
4878
|
+
hint: "Grab your API key from IP Locate."
|
|
4879
|
+
},
|
|
4880
|
+
[$.Sentry]: {
|
|
4881
|
+
link: "https://sentry.io",
|
|
4882
|
+
hint: "Your project DSN. Leave blank to skip Sentry for now."
|
|
4883
|
+
}
|
|
4884
|
+
}, Zo = { hint: "Add your value, or press Enter to leave it blank." };
|
|
4885
|
+
function Qo(e) {
|
|
4886
|
+
let t = Yo(e);
|
|
4887
|
+
return t ? Xo[t] : Zo;
|
|
4888
|
+
}
|
|
4889
|
+
var $o = {
|
|
4890
|
+
"starter-saas-workos": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4891
|
+
"starter-saas-betterauth": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4892
|
+
"pack-notifications": ["Notifications push over the `appChannel` socket channel; register it in your server startup to go live."],
|
|
4893
|
+
"pack-collaboration": ["Team and TeamMember are available as CASL subjects; project member and team management reuse the existing `Project` subject."]
|
|
4894
|
+
};
|
|
4895
|
+
function es(e) {
|
|
4896
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4897
|
+
for (let r of e) {
|
|
4898
|
+
let e = $o[r];
|
|
4899
|
+
if (e) for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
4900
|
+
}
|
|
4901
|
+
return n;
|
|
4902
|
+
}
|
|
4903
|
+
//#endregion
|
|
4904
|
+
//#region src/core/onboard-env.ts
|
|
4905
|
+
function ts(e) {
|
|
4906
|
+
let t = [], n = "";
|
|
4907
|
+
for (let r of e.split(/\r?\n/)) {
|
|
4908
|
+
let e = r.trim();
|
|
4909
|
+
if (e === "") continue;
|
|
4910
|
+
if (e.startsWith("#")) {
|
|
4911
|
+
let t = e.replace(/^#+\s*/, "").trim();
|
|
4912
|
+
if (t === "" || /^[-=_]+$/.test(t) || t.includes("=")) continue;
|
|
4913
|
+
n = t;
|
|
4914
|
+
continue;
|
|
4915
|
+
}
|
|
4916
|
+
let i = e.indexOf("=");
|
|
4917
|
+
if (i === -1) continue;
|
|
4918
|
+
let a = e.slice(0, i).trim(), o = e.slice(i + 1).trim();
|
|
4919
|
+
if (!a) continue;
|
|
4920
|
+
let s = t.find((e) => e.section === n);
|
|
4921
|
+
s || (s = {
|
|
4922
|
+
section: n,
|
|
4923
|
+
vars: []
|
|
4924
|
+
}, t.push(s)), s.vars.push({
|
|
4925
|
+
key: a,
|
|
4926
|
+
value: o
|
|
4927
|
+
});
|
|
4928
|
+
}
|
|
4929
|
+
return t;
|
|
4930
|
+
}
|
|
4931
|
+
var ns = [
|
|
4932
|
+
"replace-with",
|
|
4933
|
+
"examplepublickey",
|
|
4934
|
+
"change-me",
|
|
4935
|
+
"your-key-here"
|
|
4936
|
+
];
|
|
4937
|
+
function rs(e) {
|
|
4938
|
+
let t = e.trim();
|
|
4939
|
+
if (t === "") return !0;
|
|
4940
|
+
let n = t.toLowerCase();
|
|
4941
|
+
return ns.some((e) => n.includes(e));
|
|
4942
|
+
}
|
|
4943
|
+
function is(e, t, n) {
|
|
4944
|
+
let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
|
|
4945
|
+
if (i) return e;
|
|
4946
|
+
let r = e.trim();
|
|
4947
|
+
if (r.startsWith(`${t}=`) || r === t) return i = !0, `${t}=${n}`;
|
|
4948
|
+
let a = r.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
|
|
4949
|
+
return a && a[1] === t ? (i = !0, `${t}=${n}`) : e;
|
|
4950
|
+
});
|
|
4951
|
+
return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
|
|
4952
|
+
}
|
|
4953
|
+
async function as(e) {
|
|
4954
|
+
return await J(e) ? y.readFile(e, "utf-8") : "";
|
|
4955
|
+
}
|
|
4956
|
+
async function os(e) {
|
|
4957
|
+
let t = T.join(T.dirname(e), ".env");
|
|
4958
|
+
return await J(t) || await y.copyFile(e, t), t;
|
|
4959
|
+
}
|
|
4960
|
+
async function ss(e, t, n) {
|
|
4961
|
+
let r = is(await as(e), t, n);
|
|
4962
|
+
await y.writeFile(e, r, "utf-8");
|
|
4963
|
+
}
|
|
4964
|
+
//#endregion
|
|
4965
|
+
//#region src/commands/onboard.ts
|
|
4966
|
+
async function cs(e = {}) {
|
|
4967
|
+
let t = e.cwd ?? process.cwd();
|
|
4968
|
+
xa(), s.intro(R.brandBold("Onboard your stack"));
|
|
4969
|
+
let n;
|
|
4970
|
+
try {
|
|
4971
|
+
n = await mr(t);
|
|
4972
|
+
} catch {
|
|
4973
|
+
n = null;
|
|
4974
|
+
}
|
|
4975
|
+
n || (s.cancel(`${R.path("stack.json")} not found. Run ${R.command("npx @hype-stack/cli init")} first.`), process.exit(1));
|
|
4976
|
+
let r = await Ja(t);
|
|
4977
|
+
r.length === 0 && s.log.warn(R.muted("No .env.example files found; skipping env setup."));
|
|
4978
|
+
for (let n of r) await ls(n, t, e.yes ?? !1);
|
|
4979
|
+
let i = es(n.installedPacks ?? []);
|
|
4980
|
+
i.length > 0 && s.note(i.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await fs(t, e.yes ?? !1), s.outro(R.brand(`All set. Run ${R.command("pnpm dev")} to start your app.`));
|
|
4981
|
+
}
|
|
4982
|
+
async function ls(e, t, n) {
|
|
4983
|
+
let r = T.relative(t, e) || e, i = await os(e), a = await as(i), o = ts(await y.readFile(e, "utf-8")), c = R.path(r);
|
|
4984
|
+
s.log.step(`Env: ${c}`);
|
|
4985
|
+
for (let e of o) {
|
|
4986
|
+
let t = e.vars.filter((e) => rs(e.value));
|
|
4987
|
+
if (t.length === 0) continue;
|
|
4988
|
+
let r = Qo(e.section), o = e.section ? R.bold(e.section) : R.bold("Variables");
|
|
4989
|
+
s.log.step(o), r.link && (s.log.info(`${R.muted("Get your values:")} ${_e(r.link)}`), r.serviceChecklist && r.serviceChecklist.length > 0 && s.note(r.serviceChecklist.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Setup")), s.log.info(R.muted(r.hint));
|
|
4990
|
+
for (let e of t) {
|
|
4991
|
+
if (n) {
|
|
4992
|
+
s.log.info(`${R.label(e.key)} ${R.muted("skipped (non-interactive)")}`);
|
|
4993
|
+
continue;
|
|
4994
|
+
}
|
|
4995
|
+
let t = us(a, e.key), o = await s.text({
|
|
4996
|
+
message: `${R.label(e.key)}`,
|
|
4997
|
+
placeholder: t || r.hint
|
|
4998
|
+
});
|
|
4999
|
+
s.isCancel(o) && X();
|
|
5000
|
+
let c = (o ?? "").trim();
|
|
5001
|
+
if (c === "") {
|
|
5002
|
+
s.log.warn(R.muted(`${e.key} left blank.`));
|
|
5003
|
+
continue;
|
|
5004
|
+
}
|
|
5005
|
+
await ss(i, e.key, c), s.log.success(`${e.key} saved`);
|
|
5006
|
+
}
|
|
5007
|
+
}
|
|
5008
|
+
}
|
|
5009
|
+
function us(e, t) {
|
|
5010
|
+
for (let n of e.split(/\r?\n/)) {
|
|
5011
|
+
let e = n.match(RegExp(`^${ds(t)}\\s*=\\s*(.*)$`));
|
|
5012
|
+
if (e) return e[1].trim();
|
|
5013
|
+
}
|
|
5014
|
+
return "";
|
|
5015
|
+
}
|
|
5016
|
+
function ds(e) {
|
|
5017
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5018
|
+
}
|
|
5019
|
+
async function fs(e, t) {
|
|
5020
|
+
if (!await qi() && !await Yi(e, t, !1)) {
|
|
5021
|
+
s.log.info(R.muted(`Start services later with ${R.command("docker compose up -d")} (in apps/backend), then ${R.command("pnpm --filter @internal/backend migration:latest")}.`));
|
|
5022
|
+
return;
|
|
5023
|
+
}
|
|
5024
|
+
let n = s.spinner();
|
|
5025
|
+
if (n.start("Waiting for Postgres to be ready..."), !await Zi(e)) {
|
|
5026
|
+
n.error("Postgres health check timed out"), s.log.warn(R.muted(`Run migrations manually once Postgres is ready: ${R.command("pnpm --filter @internal/backend migration:latest")}`));
|
|
5027
|
+
return;
|
|
5028
|
+
}
|
|
5029
|
+
if (n.stop(R.success("Postgres is ready")), await $i(e)) {
|
|
5030
|
+
s.log.info(R.muted("Migrations already applied, skipping."));
|
|
4810
5031
|
return;
|
|
4811
5032
|
}
|
|
4812
|
-
|
|
5033
|
+
let r = t ? !0 : await s.confirm({
|
|
5034
|
+
message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
|
|
5035
|
+
initialValue: !0
|
|
5036
|
+
});
|
|
5037
|
+
if (s.isCancel(r) && X(), !r) {
|
|
5038
|
+
s.log.info(R.muted("Skipping database migrations."));
|
|
5039
|
+
return;
|
|
5040
|
+
}
|
|
5041
|
+
await ea(e);
|
|
4813
5042
|
}
|
|
4814
5043
|
//#endregion
|
|
4815
5044
|
//#region src/core/templates.ts
|
|
4816
|
-
var
|
|
5045
|
+
var ps = K.createRequest()({
|
|
4817
5046
|
endpoint: "/templates/list",
|
|
4818
5047
|
method: "GET"
|
|
4819
5048
|
});
|
|
4820
|
-
async function
|
|
4821
|
-
let { data: e, error: t } = await
|
|
5049
|
+
async function ms() {
|
|
5050
|
+
let { data: e, error: t } = await ps.send();
|
|
4822
5051
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
4823
5052
|
return e.templates;
|
|
4824
5053
|
}
|
|
4825
|
-
async function
|
|
5054
|
+
async function hs(e) {
|
|
4826
5055
|
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
4827
5056
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
4828
5057
|
method: "GET"
|
|
@@ -4831,13 +5060,13 @@ async function Lo(e) {
|
|
|
4831
5060
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
4832
5061
|
return t;
|
|
4833
5062
|
}
|
|
4834
|
-
async function
|
|
5063
|
+
async function gs(e, t = {}) {
|
|
4835
5064
|
let n = K.createRequest()({
|
|
4836
5065
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
4837
5066
|
method: "POST"
|
|
4838
5067
|
}), r = {
|
|
4839
|
-
"X-Device-Id":
|
|
4840
|
-
"X-Client-Info":
|
|
5068
|
+
"X-Device-Id": Xn(),
|
|
5069
|
+
"X-Client-Info": Zn()
|
|
4841
5070
|
};
|
|
4842
5071
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
4843
5072
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -4848,10 +5077,10 @@ async function Ro(e, t = {}) {
|
|
|
4848
5077
|
packs: i.packs ?? [],
|
|
4849
5078
|
expiresAt: i.expiresAt ?? null
|
|
4850
5079
|
};
|
|
4851
|
-
let s = await
|
|
5080
|
+
let s = await y.mkdtemp(T.join(w.tmpdir(), `hype-stack-template-${e}-`));
|
|
4852
5081
|
return await Promise.all(i.files.map(async (e) => {
|
|
4853
|
-
let t =
|
|
4854
|
-
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"));
|
|
4855
5084
|
})), {
|
|
4856
5085
|
status: "ok",
|
|
4857
5086
|
templateDir: s
|
|
@@ -4859,172 +5088,184 @@ async function Ro(e, t = {}) {
|
|
|
4859
5088
|
}
|
|
4860
5089
|
//#endregion
|
|
4861
5090
|
//#region src/commands/template.ts
|
|
4862
|
-
async function
|
|
4863
|
-
let
|
|
4864
|
-
|
|
4865
|
-
let
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
} catch (e) {
|
|
4869
|
-
o.cancel(`Could not parse ${L.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4870
|
-
}
|
|
4871
|
-
c || (o.cancel(a ? `Could not read ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), process.exit(1)), c.paths || (o.cancel(`${L.path("stack.json")} is missing ${L.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
4872
|
-
let l = a ?? t;
|
|
4873
|
-
o.intro(L.brandBold("Install a template"));
|
|
4874
|
-
let u = o.spinner();
|
|
4875
|
-
u.start("Loading packs...");
|
|
4876
|
-
let d;
|
|
5091
|
+
async function _s(t = {}) {
|
|
5092
|
+
let n = t.cwd ?? process.cwd();
|
|
5093
|
+
xa();
|
|
5094
|
+
let r = s.spinner();
|
|
5095
|
+
r.start("Loading packs...");
|
|
5096
|
+
let o;
|
|
4877
5097
|
try {
|
|
4878
|
-
|
|
5098
|
+
o = await Er();
|
|
4879
5099
|
} catch (e) {
|
|
4880
|
-
|
|
5100
|
+
r.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${Q(e)}`), process.exit(1);
|
|
4881
5101
|
}
|
|
4882
|
-
|
|
4883
|
-
let
|
|
4884
|
-
u.start("Loading templates...");
|
|
4885
|
-
let _;
|
|
5102
|
+
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
5103
|
+
let c;
|
|
4886
5104
|
try {
|
|
4887
|
-
|
|
5105
|
+
c = await ms();
|
|
4888
5106
|
} catch (e) {
|
|
4889
|
-
|
|
4890
|
-
}
|
|
4891
|
-
let
|
|
4892
|
-
if (!
|
|
4893
|
-
|
|
4894
|
-
let
|
|
4895
|
-
|
|
4896
|
-
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({
|
|
4897
5115
|
message: "Choose a template",
|
|
4898
|
-
options:
|
|
5116
|
+
options: c.map((e) => ({
|
|
4899
5117
|
value: e.id,
|
|
4900
5118
|
label: e.name,
|
|
4901
5119
|
hint: e.description
|
|
4902
5120
|
}))
|
|
4903
5121
|
});
|
|
4904
|
-
|
|
4905
|
-
}
|
|
4906
|
-
let
|
|
4907
|
-
|
|
4908
|
-
let
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
}
|
|
4914
|
-
|
|
4915
|
-
|
|
5122
|
+
s.isCancel(n) && (s.cancel("Cancelled."), process.exit(0)), l = n;
|
|
5123
|
+
}
|
|
5124
|
+
let u = c.find((e) => e.id === l);
|
|
5125
|
+
u || (r.stop("Template not found"), s.cancel(`Template "${l}" not found. Available: ${c.map((e) => e.id).join(", ") || "(none)"}`), process.exit(1)), r.stop(`Template: ${u.name}`);
|
|
5126
|
+
let d;
|
|
5127
|
+
try {
|
|
5128
|
+
d = await hs(u.id);
|
|
5129
|
+
} catch (e) {
|
|
5130
|
+
s.cancel(Q(e)), process.exit(1);
|
|
5131
|
+
}
|
|
5132
|
+
let f = await Ro(n, {}, {
|
|
5133
|
+
defaultTheme: d.theme,
|
|
5134
|
+
defaultMode: d.defaultMode
|
|
5135
|
+
}), p = f?.projectRoot ?? null, m = f?.scaffolded ?? !1, h;
|
|
5136
|
+
try {
|
|
5137
|
+
h = await mr(p ?? n);
|
|
5138
|
+
} catch (e) {
|
|
5139
|
+
s.cancel(`Could not parse ${R.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
5140
|
+
}
|
|
5141
|
+
h || (s.cancel(p ? `Could not read ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), process.exit(1)), h.paths || (s.cancel(`${R.path("stack.json")} is missing ${R.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
5142
|
+
let g = p ?? n;
|
|
5143
|
+
s.intro(R.brandBold("Install a template"));
|
|
5144
|
+
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await Kn(F()))?.token ?? null, C = await vs(u, t.variants, t.yes ?? !1), w = ca(u.slots, C), E = la(u.slots, u.packs, w), D = await ys({
|
|
5145
|
+
packs: o,
|
|
5146
|
+
templatePacks: E,
|
|
5147
|
+
installedSet: v,
|
|
5148
|
+
options: t
|
|
5149
|
+
}), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
|
|
5150
|
+
k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
|
|
5151
|
+
let ee = fa(o, w), A = ia(ee), te;
|
|
4916
5152
|
try {
|
|
4917
|
-
|
|
5153
|
+
te = oa(O, A, _);
|
|
4918
5154
|
} catch (e) {
|
|
4919
|
-
|
|
5155
|
+
s.cancel(Q(e)), process.exit(1);
|
|
4920
5156
|
}
|
|
4921
|
-
if (
|
|
4922
|
-
|
|
5157
|
+
if (te.order.length === 0) {
|
|
5158
|
+
s.outro(R.muted("Every pack in this template is already installed."));
|
|
4923
5159
|
return;
|
|
4924
5160
|
}
|
|
4925
|
-
let
|
|
4926
|
-
token:
|
|
4927
|
-
key:
|
|
4928
|
-
}),
|
|
4929
|
-
let t =
|
|
4930
|
-
return !t || t.tier === "free" ? "free" :
|
|
4931
|
-
},
|
|
4932
|
-
order:
|
|
4933
|
-
graph:
|
|
4934
|
-
isLocked:
|
|
4935
|
-
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: _
|
|
4936
5172
|
});
|
|
4937
|
-
if (
|
|
4938
|
-
let e = await
|
|
4939
|
-
e && (
|
|
4940
|
-
token:
|
|
4941
|
-
key:
|
|
4942
|
-
}),
|
|
4943
|
-
order:
|
|
4944
|
-
graph:
|
|
4945
|
-
isLocked:
|
|
4946
|
-
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: _
|
|
4947
5183
|
}));
|
|
4948
5184
|
}
|
|
4949
|
-
if (
|
|
4950
|
-
|
|
5185
|
+
if (M.blocked.length > 0 && await bo(M.blocked, j, b), M.installable.length === 0) {
|
|
5186
|
+
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
4951
5187
|
return;
|
|
4952
5188
|
}
|
|
4953
|
-
if (xo(
|
|
4954
|
-
let e = await
|
|
4955
|
-
(
|
|
5189
|
+
if (xo(M.installable, b), !t.yes) {
|
|
5190
|
+
let e = await s.confirm({ message: `Install template ${R.brandBold(u.name)} (${M.installable.length} pack${M.installable.length === 1 ? "" : "s"})?` });
|
|
5191
|
+
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
4956
5192
|
}
|
|
4957
|
-
|
|
4958
|
-
let
|
|
5193
|
+
r.start("Downloading packs...");
|
|
5194
|
+
let N;
|
|
4959
5195
|
try {
|
|
4960
|
-
|
|
4961
|
-
token:
|
|
4962
|
-
key:
|
|
5196
|
+
N = await So(M.installable, {
|
|
5197
|
+
token: S,
|
|
5198
|
+
key: x
|
|
4963
5199
|
});
|
|
4964
5200
|
} catch (e) {
|
|
4965
|
-
|
|
5201
|
+
r.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
|
|
4966
5202
|
}
|
|
4967
|
-
|
|
5203
|
+
r.stop(`Downloaded ${N.length} pack${N.length === 1 ? "" : "s"}`);
|
|
4968
5204
|
let ie = await Eo({
|
|
4969
|
-
prepared:
|
|
4970
|
-
config:
|
|
4971
|
-
cwd:
|
|
4972
|
-
force:
|
|
4973
|
-
yes:
|
|
4974
|
-
}),
|
|
5205
|
+
prepared: N,
|
|
5206
|
+
config: h,
|
|
5207
|
+
cwd: g,
|
|
5208
|
+
force: t.force ?? !1,
|
|
5209
|
+
yes: t.yes ?? !1
|
|
5210
|
+
}), P = null;
|
|
4975
5211
|
try {
|
|
4976
|
-
|
|
4977
|
-
let
|
|
4978
|
-
packs:
|
|
4979
|
-
config:
|
|
4980
|
-
projectRoot:
|
|
4981
|
-
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,
|
|
4982
5218
|
overwrite: ie
|
|
4983
5219
|
});
|
|
4984
|
-
if (
|
|
4985
|
-
|
|
4986
|
-
for (let e of
|
|
4987
|
-
|
|
5220
|
+
if (n.aborted) {
|
|
5221
|
+
r.stop("Installation aborted");
|
|
5222
|
+
for (let e of n.errors) s.log.error(e);
|
|
5223
|
+
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4988
5224
|
}
|
|
4989
|
-
|
|
4990
|
-
for (let e of
|
|
4991
|
-
|
|
4992
|
-
let
|
|
4993
|
-
token:
|
|
4994
|
-
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
|
|
4995
5231
|
});
|
|
4996
|
-
|
|
4997
|
-
let
|
|
4998
|
-
manifest:
|
|
4999
|
-
config:
|
|
5000
|
-
projectRoot:
|
|
5001
|
-
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
|
|
5002
5238
|
});
|
|
5003
|
-
|
|
5004
|
-
for (let e of
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
paths:
|
|
5015
|
-
|
|
5016
|
-
|
|
5239
|
+
r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
|
|
5240
|
+
for (let e of c.errors) s.log.error(e);
|
|
5241
|
+
if (!m) {
|
|
5242
|
+
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5243
|
+
a(n) && (await La(t, i(n)) ? s.log.success(`Applied the ${i(n).label} theme`) : s.log.warning(R.muted(`Could not find ${R.path("assets/styles.css")} to apply the theme`)));
|
|
5244
|
+
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5245
|
+
await ja(t, r) ? s.log.success(`Default color mode set to ${r}`) : s.log.warning(R.muted(`Could not find ${R.path("src/hooks/use-theme.ts")} to set the default color mode`));
|
|
5246
|
+
}
|
|
5247
|
+
await bs({
|
|
5248
|
+
prepared: N,
|
|
5249
|
+
templateNpm: d.dependencies_npm,
|
|
5250
|
+
paths: h.paths,
|
|
5251
|
+
cwd: g,
|
|
5252
|
+
spinner: r
|
|
5253
|
+
}), m && await ra(g, t.yes ?? !1), await fr({
|
|
5254
|
+
projectRoot: g,
|
|
5255
|
+
paths: h.paths,
|
|
5256
|
+
skipPrompts: t.yes ?? !1
|
|
5257
|
+
}), wo(), s.outro(R.brand(`Installed template ${u.name}.`));
|
|
5017
5258
|
} finally {
|
|
5018
|
-
await Promise.all(
|
|
5259
|
+
await Promise.all(N.map((e) => y.rm(e.packDir, {
|
|
5019
5260
|
recursive: !0,
|
|
5020
5261
|
force: !0
|
|
5021
|
-
}))),
|
|
5262
|
+
}))), P && await y.rm(P, {
|
|
5022
5263
|
recursive: !0,
|
|
5023
5264
|
force: !0
|
|
5024
5265
|
});
|
|
5025
5266
|
}
|
|
5026
5267
|
}
|
|
5027
|
-
async function
|
|
5268
|
+
async function vs(e, t, n) {
|
|
5028
5269
|
let r = {};
|
|
5029
5270
|
for (let i of e.slots) {
|
|
5030
5271
|
if (t?.[i.family]) {
|
|
@@ -5039,56 +5280,56 @@ async function Bo(e, t, n) {
|
|
|
5039
5280
|
value: e,
|
|
5040
5281
|
label: e,
|
|
5041
5282
|
hint: e === i.default ? "default" : void 0
|
|
5042
|
-
})), a = await
|
|
5283
|
+
})), a = await s.select({
|
|
5043
5284
|
message: `Choose a ${i.family}`,
|
|
5044
5285
|
options: e,
|
|
5045
5286
|
initialValue: i.default
|
|
5046
5287
|
});
|
|
5047
|
-
|
|
5288
|
+
s.isCancel(a) && (s.cancel("Cancelled."), process.exit(0)), r[i.family] = a;
|
|
5048
5289
|
}
|
|
5049
5290
|
return r;
|
|
5050
5291
|
}
|
|
5051
|
-
async function
|
|
5292
|
+
async function ys(e) {
|
|
5052
5293
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5053
5294
|
if (i.packs && i.packs.length > 0) {
|
|
5054
5295
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
5055
|
-
return e.length > 0 && (
|
|
5296
|
+
return e.length > 0 && (s.cancel(`Unknown pack${e.length === 1 ? "" : "s"}: ${e.join(", ")}`), process.exit(1)), i.packs.filter((e) => !a.has(e));
|
|
5056
5297
|
}
|
|
5057
5298
|
if (i.yes) return [];
|
|
5058
|
-
let
|
|
5059
|
-
if (
|
|
5060
|
-
let c =
|
|
5061
|
-
|
|
5062
|
-
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({
|
|
5063
5304
|
message: "Add extra packs on top of the template (optional)",
|
|
5064
|
-
options:
|
|
5305
|
+
options: o.map((e) => ({
|
|
5065
5306
|
value: e.name,
|
|
5066
5307
|
label: e.displayName,
|
|
5067
5308
|
hint: e.description
|
|
5068
5309
|
})),
|
|
5069
5310
|
required: !1
|
|
5070
5311
|
});
|
|
5071
|
-
return
|
|
5312
|
+
return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
|
|
5072
5313
|
}
|
|
5073
|
-
async function
|
|
5074
|
-
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);
|
|
5075
5316
|
if (c.errors.length > 0) {
|
|
5076
|
-
for (let e of c.errors)
|
|
5317
|
+
for (let e of c.errors) s.log.error(e);
|
|
5077
5318
|
return;
|
|
5078
5319
|
}
|
|
5079
5320
|
if (c.operations.length === 0) return;
|
|
5080
5321
|
a.start("Installing npm dependencies...");
|
|
5081
5322
|
let l = await _o(c.operations, i);
|
|
5082
|
-
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors)
|
|
5323
|
+
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) s.log.error(e);
|
|
5083
5324
|
}
|
|
5084
5325
|
//#endregion
|
|
5085
5326
|
//#region src/cli.ts
|
|
5086
|
-
function
|
|
5327
|
+
function xs(e) {
|
|
5087
5328
|
if (!e) return;
|
|
5088
5329
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5089
5330
|
return t.length > 0 ? t : void 0;
|
|
5090
5331
|
}
|
|
5091
|
-
function
|
|
5332
|
+
function Ss(e) {
|
|
5092
5333
|
if (!e) return;
|
|
5093
5334
|
let t = {};
|
|
5094
5335
|
for (let n of e.split(",")) {
|
|
@@ -5097,10 +5338,10 @@ function Wo(e) {
|
|
|
5097
5338
|
}
|
|
5098
5339
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5099
5340
|
}
|
|
5100
|
-
function
|
|
5101
|
-
let e = new
|
|
5102
|
-
return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(
|
|
5103
|
-
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({
|
|
5104
5345
|
name: e.name,
|
|
5105
5346
|
directory: e.directory,
|
|
5106
5347
|
install: e.install,
|
|
@@ -5110,32 +5351,38 @@ function Go() {
|
|
|
5110
5351
|
setup: e.setup
|
|
5111
5352
|
});
|
|
5112
5353
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5113
|
-
await
|
|
5354
|
+
await Lo({});
|
|
5355
|
+
}), e.command("onboard").description("Set up env vars, run migrations, and get the start command").option("-y, --yes", "Skip prompts, accept defaults").option("--skip-migrations", "Skip Docker services and database migrations").option("--cwd <path>", "Working directory").action(async (e) => {
|
|
5356
|
+
await cs({
|
|
5357
|
+
cwd: e.cwd,
|
|
5358
|
+
yes: e.yes,
|
|
5359
|
+
skipMigrations: e.skipMigrations
|
|
5360
|
+
});
|
|
5114
5361
|
}), e.command("compose").description("Choose feature packs to add to your project").option("--packs <list>", "Comma-separated pack names (non-interactive). Append @frontend or @admin to a layout pack to target that app shell, e.g. layout-basic@frontend,layout-native-app-shell@admin").option("--force", "Overwrite existing files").option("-y, --yes", "Skip confirmation prompts").option("-k, --key <key>", "License key").option("--license-key <key>", "License key (alias for --key)").option("--cwd <path>", "Working directory").action(async (e) => {
|
|
5115
|
-
await
|
|
5116
|
-
packs:
|
|
5362
|
+
await zo({
|
|
5363
|
+
packs: xs(e.packs),
|
|
5117
5364
|
force: e.force,
|
|
5118
5365
|
yes: e.yes,
|
|
5119
5366
|
licenseKey: e.key ?? e.licenseKey,
|
|
5120
5367
|
cwd: e.cwd
|
|
5121
5368
|
});
|
|
5122
5369
|
}), e.command("template").description("Install a template by id, with starter/layout variant swaps and extra packs on top").argument("[id]", "Template id (omit to pick interactively)").option("--variants <map>", "Preselect slot variants, e.g. starter-saas=starter-saas-better-auth,layout=layout-basic").option("--packs <list>", "Extra packs to add on top of the template (comma-separated)").option("--force", "Overwrite existing files").option("-y, --yes", "Skip confirmation prompts (requires <id>)").option("-k, --key <key>", "License key").option("--license-key <key>", "License key (alias for --key)").option("--cwd <path>", "Working directory").action(async (e, t) => {
|
|
5123
|
-
await
|
|
5370
|
+
await _s({
|
|
5124
5371
|
templateId: e,
|
|
5125
|
-
variants:
|
|
5126
|
-
packs:
|
|
5372
|
+
variants: Ss(t.variants),
|
|
5373
|
+
packs: xs(t.packs),
|
|
5127
5374
|
force: t.force,
|
|
5128
5375
|
yes: t.yes,
|
|
5129
5376
|
licenseKey: t.key ?? t.licenseKey,
|
|
5130
5377
|
cwd: t.cwd
|
|
5131
5378
|
});
|
|
5132
5379
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5133
|
-
await
|
|
5380
|
+
await Go();
|
|
5134
5381
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5135
|
-
await
|
|
5382
|
+
await Ko();
|
|
5136
5383
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5137
|
-
await
|
|
5384
|
+
await Go();
|
|
5138
5385
|
}), e;
|
|
5139
5386
|
}
|
|
5140
5387
|
//#endregion
|
|
5141
|
-
export {
|
|
5388
|
+
export { Ro as a, zo as i, Ko as n, Lo as o, Go as r, Io as s, Cs as t };
|