@hype-stack/cli 0.5.1 → 0.5.3
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-NswFvMgQ.js} +1608 -1338
- package/dist/cli.d.ts.map +1 -1
- package/dist/commands/compose.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 +8 -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 +33 -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/exec.d.ts +10 -0
- package/dist/utils/exec.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.3", j = "gh:BetterTyped/hype-stack", te = "stack.json", ne = "/schema/stack.json", M = "https://api.hype-stack.dev", N = "HYPE_STACK_API_URL", P = "https://www.hype-stack.dev", re = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, F = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -31,70 +31,70 @@ var 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
|
+
], ie = F.map((e) => e.value), ae = ".cursor/rules", oe = ".cursor", se = ".agents";
|
|
35
|
+
function I() {
|
|
36
36
|
let e = process.env.HYPE_STACK_API_URL;
|
|
37
|
-
return e ? (
|
|
37
|
+
return e ? (le(e), e.replace(/\/+$/, "")) : M;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function ce() {
|
|
40
40
|
let e = process.env.HYPE_STACK_WEB_URL;
|
|
41
|
-
return e ? (
|
|
41
|
+
return e ? (le(e), e.replace(/\/+$/, "")) : P;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function le(e) {
|
|
44
44
|
try {
|
|
45
45
|
let t = new URL(e);
|
|
46
|
-
if (!t.protocol.startsWith("http")) throw Error(`${
|
|
46
|
+
if (!t.protocol.startsWith("http")) throw Error(`${N} must use http or https protocol, got "${t.protocol}"`);
|
|
47
47
|
} catch (t) {
|
|
48
|
-
throw t instanceof TypeError ? Error(`${
|
|
48
|
+
throw t instanceof TypeError ? Error(`${N} is not a valid URL: "${e}"`, { cause: t }) : t;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return `${
|
|
51
|
+
function ue() {
|
|
52
|
+
return `${I()}${ne}`;
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/ui/theme.ts
|
|
56
|
-
var
|
|
57
|
-
orange:
|
|
58
|
-
orangeBright:
|
|
59
|
-
amber:
|
|
56
|
+
var de = (e) => `\x1b[38;5;208m${e}\x1b[39m`, fe = (e) => `\x1b[38;5;214m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;220m${e}\x1b[39m`, me = (e) => `\x1b[38;5;33m${e}\x1b[39m`, L = (e) => `\x1b[38;5;39m${e}\x1b[39m`, he = (e) => `\x1b[38;5;81m${e}\x1b[39m`, ge = {
|
|
57
|
+
orange: de,
|
|
58
|
+
orangeBright: fe,
|
|
59
|
+
amber: pe,
|
|
60
60
|
deepBlue: me,
|
|
61
|
-
skyBlue:
|
|
61
|
+
skyBlue: L,
|
|
62
62
|
lightBlue: he
|
|
63
|
-
},
|
|
64
|
-
brand: (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) =>
|
|
63
|
+
}, R = {
|
|
64
|
+
brand: (e) => de(e),
|
|
65
|
+
brandBold: (e) => b.bold(de(e)),
|
|
66
|
+
accent: (e) => L(e),
|
|
67
|
+
accentBold: (e) => b.bold(L(e)),
|
|
68
|
+
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(pe(e)),
|
|
76
|
+
label: (e) => b.dim(b.bold(e))
|
|
77
77
|
};
|
|
78
78
|
function _e(e, t = e) {
|
|
79
|
-
return `\x1b]8;;${e}\x07${
|
|
80
|
-
}
|
|
81
|
-
var
|
|
82
|
-
arrow:
|
|
83
|
-
bullet:
|
|
84
|
-
dash:
|
|
85
|
-
corner:
|
|
86
|
-
pipe:
|
|
87
|
-
dot:
|
|
88
|
-
spark:
|
|
89
|
-
sparkSmall:
|
|
90
|
-
bolt:
|
|
79
|
+
return `\x1b]8;;${e}\x07${L(t)}\x1b]8;;\x07`;
|
|
80
|
+
}
|
|
81
|
+
var z = {
|
|
82
|
+
arrow: de("›"),
|
|
83
|
+
bullet: R.muted("·"),
|
|
84
|
+
dash: R.muted("─"),
|
|
85
|
+
corner: R.muted("╰"),
|
|
86
|
+
pipe: R.muted("│"),
|
|
87
|
+
dot: R.muted("•"),
|
|
88
|
+
spark: pe("✦"),
|
|
89
|
+
sparkSmall: fe("✧"),
|
|
90
|
+
bolt: pe("⚡")
|
|
91
91
|
}, ve = [
|
|
92
|
-
|
|
93
|
-
F,
|
|
92
|
+
pe,
|
|
94
93
|
pe,
|
|
95
94
|
fe,
|
|
95
|
+
de,
|
|
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 `${ce()}/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
|
+
}, j = (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
|
+
}, te = () => {
|
|
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
|
+
}, ne = async ({ data: e, error: r, status: i, extra: a }) => {
|
|
1085
1085
|
let o = {
|
|
1086
1086
|
data: e,
|
|
1087
1087
|
error: r ?? null,
|
|
@@ -1106,50 +1106,50 @@ var It = /* @__PURE__ */ function(e) {
|
|
|
1106
1106
|
response: o
|
|
1107
1107
|
}
|
|
1108
1108
|
}), o;
|
|
1109
|
-
},
|
|
1109
|
+
}, M = Xt({
|
|
1110
1110
|
request: d,
|
|
1111
1111
|
requestId: t,
|
|
1112
1112
|
startTime: x,
|
|
1113
1113
|
logger: c,
|
|
1114
1114
|
resolve: n
|
|
1115
|
-
}),
|
|
1115
|
+
}), N = ({ status: e, extra: n }) => (c.error({
|
|
1116
1116
|
title: "Abort error",
|
|
1117
1117
|
type: "request",
|
|
1118
1118
|
extra: {
|
|
1119
1119
|
request: d,
|
|
1120
1120
|
requestId: t
|
|
1121
1121
|
}
|
|
1122
|
-
}),
|
|
1122
|
+
}), M({
|
|
1123
1123
|
error: i(H("abort")),
|
|
1124
1124
|
status: e,
|
|
1125
1125
|
extra: n
|
|
1126
|
-
})),
|
|
1126
|
+
})), P = ({ status: e, extra: n }) => (c.error({
|
|
1127
1127
|
title: "Timeout error",
|
|
1128
1128
|
type: "request",
|
|
1129
1129
|
extra: {
|
|
1130
1130
|
request: d,
|
|
1131
1131
|
requestId: t
|
|
1132
1132
|
}
|
|
1133
|
-
}),
|
|
1133
|
+
}), M({
|
|
1134
1134
|
error: H("timeout"),
|
|
1135
1135
|
status: e,
|
|
1136
1136
|
extra: n
|
|
1137
|
-
})),
|
|
1137
|
+
})), re = ({ status: e, extra: n }) => (c.error({
|
|
1138
1138
|
title: "Unexpected error",
|
|
1139
1139
|
type: "request",
|
|
1140
1140
|
extra: {
|
|
1141
1141
|
request: d,
|
|
1142
1142
|
requestId: t
|
|
1143
1143
|
}
|
|
1144
|
-
}),
|
|
1144
|
+
}), M({
|
|
1145
1145
|
error: H(),
|
|
1146
1146
|
status: e,
|
|
1147
1147
|
extra: n
|
|
1148
|
-
})),
|
|
1149
|
-
let i =
|
|
1150
|
-
if (!i) throw new
|
|
1148
|
+
})), F = () => a.getAbortController(v, t), ie = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1149
|
+
let i = F();
|
|
1150
|
+
if (!i) throw new At("Controller is not found");
|
|
1151
1151
|
let o = () => {
|
|
1152
|
-
|
|
1152
|
+
N({
|
|
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 ae = e.client.adapter.unstable_queryParamsMapper(d.queryParams), oe = e.client.adapter.unstable_endpointMapper(d.endpoint), se = e.client.adapter.unstable_headerMapper(d), { url: I } = e.client;
|
|
1173
1173
|
return {
|
|
1174
1174
|
request: d,
|
|
1175
1175
|
requestId: t,
|
|
1176
|
-
url:
|
|
1177
|
-
endpoint:
|
|
1178
|
-
queryParams:
|
|
1176
|
+
url: I,
|
|
1177
|
+
endpoint: oe,
|
|
1178
|
+
queryParams: ae,
|
|
1179
1179
|
payload: y,
|
|
1180
|
-
headers:
|
|
1180
|
+
headers: se,
|
|
1181
1181
|
adapter: e.client.adapter,
|
|
1182
1182
|
adapterOptions: b,
|
|
1183
|
-
getAbortController:
|
|
1183
|
+
getAbortController: F,
|
|
1184
1184
|
getRequestStartTimestamp: S,
|
|
1185
1185
|
getResponseStartTimestamp: C,
|
|
1186
|
-
createAbortListener:
|
|
1186
|
+
createAbortListener: ie,
|
|
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:
|
|
1198
|
-
onError:
|
|
1189
|
+
onRequestProgress: k,
|
|
1190
|
+
onRequestEnd: ee,
|
|
1191
|
+
onResponseStart: A,
|
|
1192
|
+
onResponseProgress: j,
|
|
1193
|
+
onResponseEnd: te,
|
|
1194
|
+
onSuccess: ne,
|
|
1195
|
+
onAbortError: N,
|
|
1196
|
+
onTimeoutError: P,
|
|
1197
|
+
onUnexpectedError: re,
|
|
1198
|
+
onError: M
|
|
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: I() });
|
|
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 });
|
|
2238
2235
|
}
|
|
2239
|
-
async function Kn(e
|
|
2240
|
-
|
|
2241
|
-
n.tokens[e] = t, await Wn(n);
|
|
2236
|
+
async function Kn(e) {
|
|
2237
|
+
return (await Wn()).tokens[e] ?? null;
|
|
2242
2238
|
}
|
|
2243
|
-
async function qn(e) {
|
|
2244
|
-
let
|
|
2245
|
-
|
|
2239
|
+
async function qn(e, t) {
|
|
2240
|
+
let n = await Wn();
|
|
2241
|
+
n.tokens[e] = t, await Gn(n);
|
|
2242
|
+
}
|
|
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 = I(), 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 = `${ce()}/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",
|
|
@@ -2378,115 +2378,117 @@ function q(e, t, n) {
|
|
|
2378
2378
|
});
|
|
2379
2379
|
});
|
|
2380
2380
|
}
|
|
2381
|
+
function ir(e, t, n) {
|
|
2382
|
+
return new Promise((r, i) => {
|
|
2383
|
+
let a = D(e, t, {
|
|
2384
|
+
cwd: n.cwd,
|
|
2385
|
+
stdio: "inherit"
|
|
2386
|
+
});
|
|
2387
|
+
a.on("error", i), a.on("close", (e) => {
|
|
2388
|
+
r({
|
|
2389
|
+
exitCode: e ?? 1,
|
|
2390
|
+
stdout: "",
|
|
2391
|
+
stderr: ""
|
|
2392
|
+
});
|
|
2393
|
+
});
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2381
2396
|
//#endregion
|
|
2382
2397
|
//#region src/utils/fs.ts
|
|
2383
|
-
async function
|
|
2384
|
-
return (await
|
|
2398
|
+
async function ar(e) {
|
|
2399
|
+
return (await y.stat(e).catch(() => null))?.isDirectory() ?? !1;
|
|
2385
2400
|
}
|
|
2386
|
-
async function
|
|
2387
|
-
return (await
|
|
2401
|
+
async function J(e) {
|
|
2402
|
+
return (await y.stat(e).catch(() => null))?.isFile() ?? !1;
|
|
2388
2403
|
}
|
|
2389
|
-
async function
|
|
2390
|
-
return (await
|
|
2404
|
+
async function or(e) {
|
|
2405
|
+
return (await y.readdir(e).catch(() => [])).length === 0;
|
|
2391
2406
|
}
|
|
2392
|
-
async function
|
|
2393
|
-
let t = await
|
|
2407
|
+
async function sr(e) {
|
|
2408
|
+
let t = await y.readFile(e, "utf-8").catch(() => null);
|
|
2394
2409
|
return t ? JSON.parse(t) : null;
|
|
2395
2410
|
}
|
|
2396
|
-
async function
|
|
2397
|
-
await
|
|
2411
|
+
async function cr(e, t) {
|
|
2412
|
+
await y.writeFile(e, JSON.stringify(t, null, 2) + "\n", "utf-8");
|
|
2398
2413
|
}
|
|
2399
|
-
async function
|
|
2414
|
+
async function lr(e) {
|
|
2400
2415
|
let t = {};
|
|
2401
|
-
if (!await
|
|
2402
|
-
let n = await
|
|
2403
|
-
for (let r of n) r.isDirectory() && await
|
|
2416
|
+
if (!await ar(e)) return t;
|
|
2417
|
+
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
2418
|
+
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
2419
|
return t;
|
|
2405
2420
|
}
|
|
2406
|
-
async function
|
|
2407
|
-
await
|
|
2421
|
+
async function ur(e) {
|
|
2422
|
+
await y.rm(e, {
|
|
2408
2423
|
recursive: !0,
|
|
2409
2424
|
force: !0
|
|
2410
2425
|
});
|
|
2411
2426
|
}
|
|
2412
|
-
function
|
|
2413
|
-
return
|
|
2427
|
+
function dr(e, t) {
|
|
2428
|
+
return T.basename(e) === t ? e : T.join(e, t);
|
|
2414
2429
|
}
|
|
2415
2430
|
//#endregion
|
|
2416
2431
|
//#region src/core/codegen.ts
|
|
2417
|
-
function
|
|
2418
|
-
|
|
2419
|
-
`${
|
|
2420
|
-
`${
|
|
2421
|
-
`${
|
|
2432
|
+
function fr(e) {
|
|
2433
|
+
s.log.info(R.muted("Run database setup yourself when ready:")), s.note([
|
|
2434
|
+
`${R.command(`cd ${e}`)}`,
|
|
2435
|
+
`${R.command("pnpm exec prisma generate")} ${R.muted("(regenerate the Prisma client)")}`,
|
|
2436
|
+
`${R.command("pnpm exec prisma migrate dev")} ${R.muted("(create + apply tables for new packs)")}`
|
|
2422
2437
|
].join("\n"), "Database Setup");
|
|
2423
2438
|
}
|
|
2424
|
-
async function
|
|
2425
|
-
let { projectRoot: t, paths: n, skipPrompts: r,
|
|
2426
|
-
if (!await
|
|
2427
|
-
if (r) {
|
|
2428
|
-
|
|
2439
|
+
async function pr(e) {
|
|
2440
|
+
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, runCommand: a = ir } = e, o = n.backend.root, c = T.join(t, o);
|
|
2441
|
+
if (!await J(T.join(c, "package.json"))) return;
|
|
2442
|
+
if (r || i === !1) {
|
|
2443
|
+
fr(o);
|
|
2429
2444
|
return;
|
|
2430
2445
|
}
|
|
2431
|
-
let
|
|
2432
|
-
message: `Run database setup now? (${
|
|
2446
|
+
let l = await s.confirm({
|
|
2447
|
+
message: `Run database setup now? (${R.command("prisma migrate dev")})`,
|
|
2433
2448
|
initialValue: !0
|
|
2434
2449
|
});
|
|
2435
|
-
if (
|
|
2436
|
-
|
|
2437
|
-
return;
|
|
2438
|
-
}
|
|
2439
|
-
let l = o.spinner();
|
|
2440
|
-
l.start("Generating Prisma client...");
|
|
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);
|
|
2450
|
+
if (s.isCancel(l) || !l) {
|
|
2451
|
+
fr(o);
|
|
2448
2452
|
return;
|
|
2449
2453
|
}
|
|
2450
|
-
|
|
2451
|
-
let
|
|
2452
|
-
d.start("Applying database schema...");
|
|
2453
|
-
let f = await i("pnpm", [
|
|
2454
|
+
s.log.step(R.muted(`Running ${R.command("prisma migrate dev --name add-packs")}...`));
|
|
2455
|
+
let u = await a("pnpm", [
|
|
2454
2456
|
"exec",
|
|
2455
2457
|
"prisma",
|
|
2456
2458
|
"migrate",
|
|
2457
2459
|
"dev",
|
|
2458
2460
|
"--name",
|
|
2459
2461
|
"add-packs"
|
|
2460
|
-
], { cwd:
|
|
2461
|
-
if (
|
|
2462
|
-
|
|
2462
|
+
], { cwd: c });
|
|
2463
|
+
if (u.exitCode !== 0) {
|
|
2464
|
+
s.log.error(R.muted("prisma migrate dev did not complete. See the output above, or finish setup manually:")), mr(u), fr(o);
|
|
2463
2465
|
return;
|
|
2464
2466
|
}
|
|
2465
|
-
|
|
2467
|
+
s.log.success("Database schema applied");
|
|
2466
2468
|
}
|
|
2467
|
-
function
|
|
2469
|
+
function mr(e) {
|
|
2468
2470
|
let t = (e.stderr || e.stdout).trim();
|
|
2469
|
-
t &&
|
|
2471
|
+
t && s.log.warn(R.muted(t));
|
|
2470
2472
|
}
|
|
2471
2473
|
//#endregion
|
|
2472
2474
|
//#region src/core/stack-config.ts
|
|
2473
|
-
async function
|
|
2474
|
-
return
|
|
2475
|
+
async function hr(e) {
|
|
2476
|
+
return sr(T.join(e, te));
|
|
2475
2477
|
}
|
|
2476
|
-
async function
|
|
2477
|
-
return
|
|
2478
|
+
async function gr(e) {
|
|
2479
|
+
return J(T.join(e, te));
|
|
2478
2480
|
}
|
|
2479
|
-
async function
|
|
2480
|
-
await
|
|
2481
|
+
async function _r(e, t) {
|
|
2482
|
+
await cr(T.join(e, te), t);
|
|
2481
2483
|
}
|
|
2482
|
-
async function
|
|
2483
|
-
let t =
|
|
2484
|
+
async function vr(e) {
|
|
2485
|
+
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([lr(t), lr(n)]);
|
|
2484
2486
|
return {
|
|
2485
2487
|
apps: r,
|
|
2486
2488
|
packages: i
|
|
2487
2489
|
};
|
|
2488
2490
|
}
|
|
2489
|
-
function
|
|
2491
|
+
function yr(e) {
|
|
2490
2492
|
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
2493
|
return {
|
|
2492
2494
|
backend: {
|
|
@@ -2520,23 +2522,23 @@ function gr(e) {
|
|
|
2520
2522
|
}
|
|
2521
2523
|
};
|
|
2522
2524
|
}
|
|
2523
|
-
function
|
|
2525
|
+
function br(e, t) {
|
|
2524
2526
|
return {
|
|
2525
|
-
$schema:
|
|
2527
|
+
$schema: ue(),
|
|
2526
2528
|
version: 1,
|
|
2527
2529
|
name: e,
|
|
2528
2530
|
apps: t.apps,
|
|
2529
2531
|
packages: t.packages,
|
|
2530
|
-
paths:
|
|
2532
|
+
paths: yr(t),
|
|
2531
2533
|
installedPacks: [],
|
|
2532
2534
|
licenseKey: null
|
|
2533
2535
|
};
|
|
2534
2536
|
}
|
|
2535
|
-
async function
|
|
2536
|
-
let t =
|
|
2537
|
+
async function xr(e) {
|
|
2538
|
+
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t), ar(n)]);
|
|
2537
2539
|
return r && i;
|
|
2538
2540
|
}
|
|
2539
|
-
function
|
|
2541
|
+
function Y(e, t) {
|
|
2540
2542
|
return e.replace(/\{\{(\w+)\.(\w+)\}\}/g, (n, r, i) => {
|
|
2541
2543
|
let a = t[r];
|
|
2542
2544
|
if (!a) throw Error(`Unknown app "${r}" in path template "${e}"`);
|
|
@@ -2547,7 +2549,7 @@ function X(e, t) {
|
|
|
2547
2549
|
}
|
|
2548
2550
|
//#endregion
|
|
2549
2551
|
//#region src/core/registry.ts
|
|
2550
|
-
async function
|
|
2552
|
+
async function Sr(e) {
|
|
2551
2553
|
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
2552
2554
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2553
2555
|
method: "GET"
|
|
@@ -2556,13 +2558,13 @@ async function yr(e) {
|
|
|
2556
2558
|
if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
|
|
2557
2559
|
return t;
|
|
2558
2560
|
}
|
|
2559
|
-
async function
|
|
2561
|
+
async function Cr(e, t = {}) {
|
|
2560
2562
|
let n = K.createRequest()({
|
|
2561
2563
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2562
2564
|
method: "POST"
|
|
2563
2565
|
}), r = {
|
|
2564
|
-
"X-Device-Id":
|
|
2565
|
-
"X-Client-Info":
|
|
2566
|
+
"X-Device-Id": Xn(),
|
|
2567
|
+
"X-Client-Info": Zn()
|
|
2566
2568
|
};
|
|
2567
2569
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2568
2570
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -2573,32 +2575,32 @@ async function br(e, t = {}) {
|
|
|
2573
2575
|
packs: i.packs ?? [],
|
|
2574
2576
|
expiresAt: i.expiresAt ?? null
|
|
2575
2577
|
};
|
|
2576
|
-
let s = await
|
|
2578
|
+
let s = await y.mkdtemp(T.join(w.tmpdir(), `hype-stack-pack-${e}-`));
|
|
2577
2579
|
return await Promise.all(i.files.map(async (e) => {
|
|
2578
|
-
let t =
|
|
2579
|
-
await
|
|
2580
|
+
let t = T.join(s, ...e.path.split("/"));
|
|
2581
|
+
await y.mkdir(T.dirname(t), { recursive: !0 }), await y.writeFile(t, Buffer.from(e.content, "base64"));
|
|
2580
2582
|
})), {
|
|
2581
2583
|
status: "ok",
|
|
2582
2584
|
packDir: s
|
|
2583
2585
|
};
|
|
2584
2586
|
}
|
|
2585
|
-
function
|
|
2586
|
-
let r =
|
|
2587
|
-
return
|
|
2587
|
+
function wr(e, t, n) {
|
|
2588
|
+
let r = Y(e, t);
|
|
2589
|
+
return T.resolve(n, r);
|
|
2588
2590
|
}
|
|
2589
|
-
function
|
|
2590
|
-
return
|
|
2591
|
+
function Tr(e, t) {
|
|
2592
|
+
return T.join(t, e);
|
|
2591
2593
|
}
|
|
2592
|
-
var
|
|
2594
|
+
var Er = K.createRequest()({
|
|
2593
2595
|
endpoint: "/packs/list",
|
|
2594
2596
|
method: "GET"
|
|
2595
2597
|
});
|
|
2596
|
-
async function
|
|
2597
|
-
let { data: e, error: t } = await
|
|
2598
|
+
async function Dr() {
|
|
2599
|
+
let { data: e, error: t } = await Er.send();
|
|
2598
2600
|
if (t || !e) throw Error(`Failed to fetch pack list: ${String(t)}`);
|
|
2599
2601
|
return e.packs;
|
|
2600
2602
|
}
|
|
2601
|
-
async function
|
|
2603
|
+
async function Or(e, t = {}) {
|
|
2602
2604
|
if (e.length === 0) return {};
|
|
2603
2605
|
let n = K.createRequest()({
|
|
2604
2606
|
endpoint: "/packs/authorize",
|
|
@@ -2614,35 +2616,35 @@ async function Tr(e, t = {}) {
|
|
|
2614
2616
|
}
|
|
2615
2617
|
//#endregion
|
|
2616
2618
|
//#region src/core/codemods.ts
|
|
2617
|
-
var
|
|
2618
|
-
function
|
|
2619
|
-
return
|
|
2619
|
+
var kr = "@hype-stack/";
|
|
2620
|
+
function Ar(e, t) {
|
|
2621
|
+
return Y(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
|
|
2620
2622
|
}
|
|
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
|
|
2623
|
+
async function jr(e, t, n) {
|
|
2624
|
+
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");
|
|
2625
|
+
if (await J(i)) {
|
|
2626
|
+
let t = await y.readFile(i, "utf-8");
|
|
2627
|
+
for (let n of e) t.includes(`from "${n.from}"`) || (t = Mr(t, n), t = Nr(t, n));
|
|
2628
|
+
await y.writeFile(i, t, "utf-8");
|
|
2627
2629
|
}
|
|
2628
|
-
if (await
|
|
2629
|
-
let t = await
|
|
2630
|
-
for (let n of e) t =
|
|
2631
|
-
await
|
|
2630
|
+
if (await J(a)) {
|
|
2631
|
+
let t = await y.readFile(a, "utf-8");
|
|
2632
|
+
for (let n of e) t = Pr(t, n);
|
|
2633
|
+
await y.writeFile(a, t, "utf-8");
|
|
2632
2634
|
}
|
|
2633
|
-
if (await
|
|
2634
|
-
let t = await
|
|
2635
|
-
for (let n of e) t =
|
|
2636
|
-
await
|
|
2635
|
+
if (await J(o)) {
|
|
2636
|
+
let t = await y.readFile(o, "utf-8");
|
|
2637
|
+
for (let n of e) t = Fr(t, n);
|
|
2638
|
+
await y.writeFile(o, t, "utf-8");
|
|
2637
2639
|
}
|
|
2638
2640
|
}
|
|
2639
|
-
function
|
|
2641
|
+
function Mr(e, t) {
|
|
2640
2642
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2641
2643
|
if (r === -1) return n + "\n" + e;
|
|
2642
2644
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2643
2645
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2644
2646
|
}
|
|
2645
|
-
function
|
|
2647
|
+
function Nr(e, t) {
|
|
2646
2648
|
let n = `.extend(${t.import}.shape)`;
|
|
2647
2649
|
if (e.includes(n)) return e;
|
|
2648
2650
|
let r = e.indexOf("export const envSchema = z.object({");
|
|
@@ -2657,27 +2659,27 @@ function Ar(e, t) {
|
|
|
2657
2659
|
let o = a + 2;
|
|
2658
2660
|
return e.slice(0, o) + n + e.slice(o);
|
|
2659
2661
|
}
|
|
2660
|
-
function
|
|
2662
|
+
function Pr(e, t) {
|
|
2661
2663
|
for (let n of Object.keys(t.envExample.vars)) if (e.includes(`${n}=`)) return e;
|
|
2662
2664
|
let n = [];
|
|
2663
2665
|
n.push(""), n.push(`# ${t.envExample.section}`);
|
|
2664
2666
|
for (let [e, r] of Object.entries(t.envExample.vars)) n.push(`${e}=${r}`);
|
|
2665
2667
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2666
2668
|
}
|
|
2667
|
-
function
|
|
2669
|
+
function Fr(e, t) {
|
|
2668
2670
|
for (let n of Object.keys(t.envTest)) if (e.includes(`${n}=`)) return e;
|
|
2669
2671
|
let n = [""];
|
|
2670
2672
|
for (let [e, r] of Object.entries(t.envTest)) n.push(`${e}=${r}`);
|
|
2671
2673
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2672
2674
|
}
|
|
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
|
|
2675
|
+
async function Ir(e, t, n) {
|
|
2676
|
+
let r = T.resolve(n, Y("{{backend.routes}}", t), "index.ts");
|
|
2677
|
+
if (!await J(r)) return;
|
|
2678
|
+
let i = await y.readFile(r, "utf-8");
|
|
2679
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Lr(i, t), i = Rr(i, t));
|
|
2680
|
+
await y.writeFile(r, i, "utf-8");
|
|
2679
2681
|
}
|
|
2680
|
-
function
|
|
2682
|
+
function Lr(e, t) {
|
|
2681
2683
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2682
2684
|
if (r !== -1) {
|
|
2683
2685
|
let t = e.indexOf("\n", r);
|
|
@@ -2686,7 +2688,7 @@ function Pr(e, t) {
|
|
|
2686
2688
|
let i = e.indexOf("export const registerRoutes");
|
|
2687
2689
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2688
2690
|
}
|
|
2689
|
-
function
|
|
2691
|
+
function Rr(e, t) {
|
|
2690
2692
|
let n = `.route("${t.prefix}", ${t.import})`, r = e.match(/\.route\([^)]+\);/g);
|
|
2691
2693
|
if (r) {
|
|
2692
2694
|
let t = r[r.length - 1], i = e.lastIndexOf(t) + t.length - 1;
|
|
@@ -2694,14 +2696,14 @@ function Fr(e, t) {
|
|
|
2694
2696
|
}
|
|
2695
2697
|
return e.replace("return app;", `return app\n ${n};`);
|
|
2696
2698
|
}
|
|
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
|
|
2699
|
+
async function zr(e, t, n) {
|
|
2700
|
+
let r = T.resolve(n, Y("{{backend.root}}", t), "src/context.ts");
|
|
2701
|
+
if (!await J(r)) return;
|
|
2702
|
+
let i = await y.readFile(r, "utf-8");
|
|
2703
|
+
for (let t of e) i.includes(`export let ${t.export}`) || (i = Br(i, t), i = Vr(i, t), i = Hr(i, t), i = Wr(i, t));
|
|
2704
|
+
await y.writeFile(r, i, "utf-8");
|
|
2703
2705
|
}
|
|
2704
|
-
function
|
|
2706
|
+
function Br(e, t) {
|
|
2705
2707
|
let n = `import { ${t.typeImport.name} } from "${t.typeImport.from}";`;
|
|
2706
2708
|
if (e.includes(`from "${t.typeImport.from}"`)) return e;
|
|
2707
2709
|
let r = e.lastIndexOf("import ");
|
|
@@ -2709,7 +2711,7 @@ function Lr(e, t) {
|
|
|
2709
2711
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2710
2712
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2711
2713
|
}
|
|
2712
|
-
function
|
|
2714
|
+
function Vr(e, t) {
|
|
2713
2715
|
let n = `export let ${t.export}: ${t.type};`, r = e.lastIndexOf("export let ");
|
|
2714
2716
|
if (r === -1) {
|
|
2715
2717
|
let t = e.indexOf("export const setupContext");
|
|
@@ -2718,15 +2720,15 @@ function Rr(e, t) {
|
|
|
2718
2720
|
let i = e.indexOf("\n", r);
|
|
2719
2721
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2720
2722
|
}
|
|
2721
|
-
function
|
|
2723
|
+
function Hr(e, t) {
|
|
2722
2724
|
let n = ` ${t.export} = ${t.init};`, r = e.match(/export const setupContext\s*=\s*async\s*\([^)]*\)\s*=>\s*\{/);
|
|
2723
2725
|
if (!r) return e;
|
|
2724
2726
|
let i = e.indexOf("{", e.indexOf(r[0]));
|
|
2725
2727
|
if (i === -1) return e;
|
|
2726
|
-
let a =
|
|
2728
|
+
let a = Ur(e, i);
|
|
2727
2729
|
return a === -1 ? e : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2728
2730
|
}
|
|
2729
|
-
function
|
|
2731
|
+
function Ur(e, t) {
|
|
2730
2732
|
let n = 0;
|
|
2731
2733
|
for (let r = t; r < e.length; r++) {
|
|
2732
2734
|
let t = e[r];
|
|
@@ -2735,20 +2737,20 @@ function Br(e, t) {
|
|
|
2735
2737
|
}
|
|
2736
2738
|
return -1;
|
|
2737
2739
|
}
|
|
2738
|
-
function
|
|
2740
|
+
function Wr(e, t) {
|
|
2739
2741
|
let n = ` ${t.export}: ${t.type};`, r = e.indexOf("export type ContextVariables = {");
|
|
2740
2742
|
if (r === -1) return e;
|
|
2741
2743
|
let i = e.indexOf("};", r);
|
|
2742
2744
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2743
2745
|
}
|
|
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
|
|
2746
|
+
async function Gr(e, t, n) {
|
|
2747
|
+
let r = T.resolve(n, Y("{{enums.src}}", t), "index.ts");
|
|
2748
|
+
if (!await J(r)) return;
|
|
2749
|
+
let i = await y.readFile(r, "utf-8");
|
|
2750
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Kr(i, t));
|
|
2751
|
+
await y.writeFile(r, i, "utf-8");
|
|
2750
2752
|
}
|
|
2751
|
-
function
|
|
2753
|
+
function Kr(e, t) {
|
|
2752
2754
|
let n = `export * from "${t.from}";`, r = e.lastIndexOf("export * from");
|
|
2753
2755
|
if (r !== -1) {
|
|
2754
2756
|
let t = e.indexOf("\n", r);
|
|
@@ -2756,14 +2758,14 @@ function Ur(e, t) {
|
|
|
2756
2758
|
}
|
|
2757
2759
|
return e.trim() === "" ? n + "\n" : e.trimEnd() + "\n" + n + "\n";
|
|
2758
2760
|
}
|
|
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
|
|
2761
|
+
async function qr(e, t, n) {
|
|
2762
|
+
let r = Y("{{backend.root}}", t), i = T.resolve(n, r, "src/sockets/index.ts");
|
|
2763
|
+
if (!await J(i)) return;
|
|
2764
|
+
let a = await y.readFile(i, "utf-8");
|
|
2765
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = Jr(a, t), a = Yr(a, t));
|
|
2766
|
+
await J(T.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a = Xr(a)), await y.writeFile(i, a, "utf-8");
|
|
2765
2767
|
}
|
|
2766
|
-
function
|
|
2768
|
+
function Jr(e, t) {
|
|
2767
2769
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2768
2770
|
if (r !== -1) {
|
|
2769
2771
|
let t = e.indexOf("\n", r);
|
|
@@ -2772,7 +2774,7 @@ function Gr(e, t) {
|
|
|
2772
2774
|
let i = e.indexOf("const sockets");
|
|
2773
2775
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2774
2776
|
}
|
|
2775
|
-
function
|
|
2777
|
+
function Yr(e, t) {
|
|
2776
2778
|
let n = `.socket("${t.prefix}", ${t.import})`, r = e.indexOf("const sockets");
|
|
2777
2779
|
if (r === -1) return e;
|
|
2778
2780
|
let i = e.indexOf("new SocketRouter", r);
|
|
@@ -2786,7 +2788,7 @@ function Kr(e, t) {
|
|
|
2786
2788
|
}
|
|
2787
2789
|
return e;
|
|
2788
2790
|
}
|
|
2789
|
-
function
|
|
2791
|
+
function Xr(e) {
|
|
2790
2792
|
if (e.includes("wsAuthenticate")) return e;
|
|
2791
2793
|
let t = e.indexOf("from \"@backend/libs/websocket/socket-router\""), n = e;
|
|
2792
2794
|
if (t !== -1) {
|
|
@@ -2795,14 +2797,14 @@ function qr(e) {
|
|
|
2795
2797
|
}
|
|
2796
2798
|
return n.replace("new SocketRouter()", "new SocketRouter({ authenticate: wsAuthenticate })");
|
|
2797
2799
|
}
|
|
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
|
|
2800
|
+
async function Zr(e, t, n) {
|
|
2801
|
+
let r = Y("{{frontend.root}}", t), i = T.resolve(n, r, "src/api/sdk.ts");
|
|
2802
|
+
if (!await J(i)) return;
|
|
2803
|
+
let a = await y.readFile(i, "utf-8");
|
|
2804
|
+
for (let t of e) a.includes(`.$configure(${t.import})`) || (a = Qr(a, t), a = $r(a, t));
|
|
2805
|
+
await y.writeFile(i, a, "utf-8");
|
|
2804
2806
|
}
|
|
2805
|
-
function
|
|
2807
|
+
function Qr(e, t) {
|
|
2806
2808
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2807
2809
|
if (e.includes(n)) return e;
|
|
2808
2810
|
let r = e.lastIndexOf("from \"./");
|
|
@@ -2813,20 +2815,20 @@ function Yr(e, t) {
|
|
|
2813
2815
|
let i = e.indexOf("export const sdk");
|
|
2814
2816
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2815
2817
|
}
|
|
2816
|
-
function
|
|
2818
|
+
function $r(e, t) {
|
|
2817
2819
|
let n = `.$configure(${t.import})`, r = e.indexOf("export const sdk");
|
|
2818
2820
|
if (r === -1) return e;
|
|
2819
2821
|
let i = e.indexOf(";", r);
|
|
2820
2822
|
return i === -1 ? e : e.slice(0, i) + "\n " + n + e.slice(i);
|
|
2821
2823
|
}
|
|
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
|
|
2824
|
+
async function ei(e, t, n) {
|
|
2825
|
+
let r = T.resolve(n, Y("{{backend.utils}}", t), "frontend-url/frontend-url.ts");
|
|
2826
|
+
if (!await J(r)) return;
|
|
2827
|
+
let i = await y.readFile(r, "utf-8");
|
|
2828
|
+
for (let t of e) i.includes(`"${t.path}"`) || (i = ti(i, t));
|
|
2829
|
+
await y.writeFile(r, i, "utf-8");
|
|
2828
2830
|
}
|
|
2829
|
-
function
|
|
2831
|
+
function ti(e, t) {
|
|
2830
2832
|
let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
|
|
2831
2833
|
if (r === -1) return e;
|
|
2832
2834
|
let i = e.indexOf("{", r);
|
|
@@ -2842,38 +2844,38 @@ function Qr(e, t) {
|
|
|
2842
2844
|
}
|
|
2843
2845
|
return o === -1 ? e : e.slice(0, o) + n + "\n" + e.slice(o);
|
|
2844
2846
|
}
|
|
2845
|
-
var
|
|
2847
|
+
var ni = "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", ri = {
|
|
2846
2848
|
primary: "primaryNav",
|
|
2847
2849
|
secondary: "secondaryNav",
|
|
2848
2850
|
tertiary: "tertiaryNav",
|
|
2849
2851
|
settings: "settingsNav"
|
|
2850
2852
|
};
|
|
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
|
|
2853
|
+
async function ii(e) {
|
|
2854
|
+
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Ar(i, n), o = T.resolve(r, a, "src/constants/nav.constants.ts"), s;
|
|
2855
|
+
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = ni);
|
|
2856
|
+
for (let e of t) s.includes(`label: "${e.label}"`) || (s = si(s, e));
|
|
2857
|
+
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s = li(s, e));
|
|
2858
|
+
await y.writeFile(o, s, "utf-8");
|
|
2859
|
+
}
|
|
2860
|
+
async function ai(e) {
|
|
2861
|
+
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Ar(i, n), o = T.resolve(r, a, "src/features/auth/constants/auth.constants.ts");
|
|
2862
|
+
if (!await J(o)) return;
|
|
2863
|
+
let s = await y.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
|
|
2862
2864
|
if (!c.test(s)) return;
|
|
2863
2865
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
2864
|
-
await
|
|
2866
|
+
await y.writeFile(o, l, "utf-8");
|
|
2865
2867
|
}
|
|
2866
|
-
function
|
|
2868
|
+
function oi(e) {
|
|
2867
2869
|
let t = [e.icon];
|
|
2868
2870
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
2869
2871
|
return t;
|
|
2870
2872
|
}
|
|
2871
|
-
function
|
|
2872
|
-
let n =
|
|
2873
|
-
for (let e of n) r =
|
|
2873
|
+
function si(e, t) {
|
|
2874
|
+
let n = oi(t), r = e;
|
|
2875
|
+
for (let e of n) r = ci(r, e);
|
|
2874
2876
|
return r;
|
|
2875
2877
|
}
|
|
2876
|
-
function
|
|
2878
|
+
function ci(e, t) {
|
|
2877
2879
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
2878
2880
|
if (!n) return e;
|
|
2879
2881
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -2881,21 +2883,21 @@ function ai(e, t) {
|
|
|
2881
2883
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
2882
2884
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
2883
2885
|
}
|
|
2884
|
-
function
|
|
2885
|
-
let n =
|
|
2886
|
+
function li(e, t) {
|
|
2887
|
+
let n = ri[t.group];
|
|
2886
2888
|
if (!n) return e;
|
|
2887
|
-
let r =
|
|
2889
|
+
let r = di(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
|
|
2888
2890
|
if (!a) return e;
|
|
2889
|
-
let o = e.indexOf(a[0]) + a[0].length, s =
|
|
2891
|
+
let o = e.indexOf(a[0]) + a[0].length, s = ui(e, o - 1);
|
|
2890
2892
|
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
2893
|
}
|
|
2892
|
-
function
|
|
2894
|
+
function ui(e, t) {
|
|
2893
2895
|
let n = 0;
|
|
2894
2896
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2895
2897
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2896
2898
|
return -1;
|
|
2897
2899
|
}
|
|
2898
|
-
function
|
|
2900
|
+
function di(e) {
|
|
2899
2901
|
let t = [];
|
|
2900
2902
|
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
2903
|
t.push(" items: [");
|
|
@@ -2911,14 +2913,14 @@ function ci(e) {
|
|
|
2911
2913
|
} else t.push(" items: [],");
|
|
2912
2914
|
return t.push(" },"), t.join("\n");
|
|
2913
2915
|
}
|
|
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
|
|
2916
|
+
async function fi(e, t, n) {
|
|
2917
|
+
let r = Y("{{backend.features}}", t), i = T.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
|
|
2918
|
+
if (!await J(i)) return;
|
|
2919
|
+
let a = await y.readFile(i, "utf-8");
|
|
2920
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = pi(a, t), a = mi(a, t));
|
|
2921
|
+
await y.writeFile(i, a, "utf-8");
|
|
2920
2922
|
}
|
|
2921
|
-
function
|
|
2923
|
+
function pi(e, t) {
|
|
2922
2924
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2923
2925
|
if (r !== -1) {
|
|
2924
2926
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -2926,38 +2928,38 @@ function ui(e, t) {
|
|
|
2926
2928
|
}
|
|
2927
2929
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
2928
2930
|
}
|
|
2929
|
-
function
|
|
2931
|
+
function mi(e, t) {
|
|
2930
2932
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
2931
2933
|
if (!r) return e;
|
|
2932
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2934
|
+
let i = e.indexOf(r[0]) + r[0].length, a = hi(e, i - 1);
|
|
2933
2935
|
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
2936
|
}
|
|
2935
|
-
function
|
|
2937
|
+
function hi(e, t) {
|
|
2936
2938
|
let n = 0;
|
|
2937
2939
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2938
2940
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2939
2941
|
return -1;
|
|
2940
2942
|
}
|
|
2941
|
-
var
|
|
2942
|
-
async function
|
|
2943
|
-
await
|
|
2943
|
+
var gi = "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";
|
|
2944
|
+
async function _i(e) {
|
|
2945
|
+
await yi({
|
|
2944
2946
|
...e,
|
|
2945
2947
|
arrayName: "navbarActions"
|
|
2946
2948
|
});
|
|
2947
2949
|
}
|
|
2948
|
-
async function
|
|
2949
|
-
await
|
|
2950
|
+
async function vi(e) {
|
|
2951
|
+
await yi({
|
|
2950
2952
|
...e,
|
|
2951
2953
|
arrayName: "userMenuActions"
|
|
2952
2954
|
});
|
|
2953
2955
|
}
|
|
2954
|
-
async function
|
|
2955
|
-
let a =
|
|
2956
|
-
await
|
|
2957
|
-
for (let n of e) s =
|
|
2958
|
-
await
|
|
2956
|
+
async function yi({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
|
|
2957
|
+
let a = Ar(i, n), o = T.resolve(r, a, "src/constants/navbar-actions.tsx"), s;
|
|
2958
|
+
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = gi);
|
|
2959
|
+
for (let n of e) s = bi(s, n), s = xi(s, n, t);
|
|
2960
|
+
await y.writeFile(o, s, "utf-8");
|
|
2959
2961
|
}
|
|
2960
|
-
function
|
|
2962
|
+
function bi(e, t) {
|
|
2961
2963
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2962
2964
|
if (e.includes(n)) return e;
|
|
2963
2965
|
let r = e.lastIndexOf("import ");
|
|
@@ -2965,38 +2967,38 @@ function _i(e, t) {
|
|
|
2965
2967
|
let i = e.indexOf("\n", r);
|
|
2966
2968
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2967
2969
|
}
|
|
2968
|
-
function
|
|
2970
|
+
function xi(e, t, n) {
|
|
2969
2971
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
2970
2972
|
if (!r) return e;
|
|
2971
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2973
|
+
let i = e.indexOf(r[0]) + r[0].length, a = Si(e, i - 1);
|
|
2972
2974
|
if (a === -1) return e;
|
|
2973
2975
|
let o = e.slice(i, a);
|
|
2974
2976
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
2975
2977
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
2976
2978
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
2977
2979
|
}
|
|
2978
|
-
function
|
|
2980
|
+
function Si(e, t) {
|
|
2979
2981
|
let n = 0;
|
|
2980
2982
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2981
2983
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2982
2984
|
return -1;
|
|
2983
2985
|
}
|
|
2984
|
-
var
|
|
2986
|
+
var Ci = new Set([
|
|
2985
2987
|
".ts",
|
|
2986
2988
|
".tsx",
|
|
2987
2989
|
".js",
|
|
2988
2990
|
".jsx"
|
|
2989
2991
|
]);
|
|
2990
|
-
async function
|
|
2992
|
+
async function wi(e) {
|
|
2991
2993
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
2992
2994
|
if (i === "hype-stack") return;
|
|
2993
2995
|
let a = `@${i}/`;
|
|
2994
2996
|
await Promise.all(t.map(async (e) => {
|
|
2995
|
-
let t =
|
|
2996
|
-
i?.isDirectory() ? await
|
|
2997
|
+
let t = wr(e.target, n, r), i = await y.stat(t).catch(() => null);
|
|
2998
|
+
i?.isDirectory() ? await Di(t, a) : i?.isFile() && Ci.has(T.extname(t)) && await Oi(t, a);
|
|
2997
2999
|
}));
|
|
2998
3000
|
}
|
|
2999
|
-
var
|
|
3001
|
+
var Ti = new Set([
|
|
3000
3002
|
".git",
|
|
3001
3003
|
"node_modules",
|
|
3002
3004
|
"dist",
|
|
@@ -3005,62 +3007,62 @@ var Si = new Set([
|
|
|
3005
3007
|
".next",
|
|
3006
3008
|
"coverage"
|
|
3007
3009
|
]);
|
|
3008
|
-
async function
|
|
3009
|
-
t !== "hype-stack" && await
|
|
3010
|
+
async function Ei(e, t) {
|
|
3011
|
+
t !== "hype-stack" && await Di(e, `@${t}/`);
|
|
3010
3012
|
}
|
|
3011
|
-
async function
|
|
3012
|
-
let n = await
|
|
3013
|
+
async function Di(e, t) {
|
|
3014
|
+
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3013
3015
|
await Promise.all(n.map(async (n) => {
|
|
3014
|
-
let r =
|
|
3016
|
+
let r = T.join(e, n.name);
|
|
3015
3017
|
if (n.isDirectory()) {
|
|
3016
|
-
if (
|
|
3017
|
-
await
|
|
3018
|
-
} else n.isFile() &&
|
|
3018
|
+
if (Ti.has(n.name)) return;
|
|
3019
|
+
await Di(r, t);
|
|
3020
|
+
} else n.isFile() && Ci.has(T.extname(n.name)) && await Oi(r, t);
|
|
3019
3021
|
}));
|
|
3020
3022
|
}
|
|
3021
|
-
async function
|
|
3022
|
-
let n = await
|
|
3023
|
-
if (!n.includes(
|
|
3024
|
-
let r = n.replaceAll(
|
|
3025
|
-
await
|
|
3023
|
+
async function Oi(e, t) {
|
|
3024
|
+
let n = await y.readFile(e, "utf-8");
|
|
3025
|
+
if (!n.includes(kr)) return;
|
|
3026
|
+
let r = n.replaceAll(kr, t);
|
|
3027
|
+
await y.writeFile(e, r, "utf-8");
|
|
3026
3028
|
}
|
|
3027
3029
|
//#endregion
|
|
3028
3030
|
//#region src/core/installer.ts
|
|
3029
|
-
function
|
|
3031
|
+
function ki(e, t) {
|
|
3030
3032
|
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3031
3033
|
}
|
|
3032
|
-
async function
|
|
3033
|
-
if ((await
|
|
3034
|
-
await
|
|
3035
|
-
let n = await
|
|
3036
|
-
for (let r of n) await
|
|
3037
|
-
} else await
|
|
3034
|
+
async function Ai(e, t) {
|
|
3035
|
+
if ((await y.stat(e)).isDirectory()) {
|
|
3036
|
+
await y.mkdir(t, { recursive: !0 });
|
|
3037
|
+
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3038
|
+
for (let r of n) await Ai(T.join(e, r.name), T.join(t, r.name));
|
|
3039
|
+
} else await y.mkdir(T.dirname(t), { recursive: !0 }), await y.copyFile(e, t);
|
|
3038
3040
|
}
|
|
3039
|
-
async function
|
|
3041
|
+
async function ji(e) {
|
|
3040
3042
|
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:
|
|
3043
|
+
if ((await y.stat(t)).isDirectory()) {
|
|
3044
|
+
await y.mkdir(n, { recursive: !0 });
|
|
3045
|
+
let e = await y.readdir(t, { withFileTypes: !0 });
|
|
3046
|
+
return (await Promise.all(e.map((e) => ji({
|
|
3047
|
+
src: T.join(t, e.name),
|
|
3048
|
+
dest: T.join(n, e.name),
|
|
3047
3049
|
projectRoot: r,
|
|
3048
3050
|
skip: i
|
|
3049
3051
|
})))).flat();
|
|
3050
3052
|
}
|
|
3051
|
-
return i.has(t) ? [] : (await
|
|
3053
|
+
return i.has(t) ? [] : (await y.mkdir(T.dirname(n), { recursive: !0 }), await y.copyFile(t, n), [T.relative(r, n)]);
|
|
3052
3054
|
}
|
|
3053
|
-
async function
|
|
3054
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a =
|
|
3055
|
+
async function Mi(e) {
|
|
3056
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = Tr(t.source, n), o = wr(t.target, r, i);
|
|
3055
3057
|
return {
|
|
3056
3058
|
sourcePath: a,
|
|
3057
3059
|
targetPath: o,
|
|
3058
|
-
sourceExists: await
|
|
3059
|
-
targetExists: await
|
|
3060
|
+
sourceExists: await J(a) || await ar(a),
|
|
3061
|
+
targetExists: await J(o) || await ar(o)
|
|
3060
3062
|
};
|
|
3061
3063
|
}
|
|
3062
|
-
async function
|
|
3063
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await
|
|
3064
|
+
async function Ni(e) {
|
|
3065
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await Mi({
|
|
3064
3066
|
file: t,
|
|
3065
3067
|
packDir: n,
|
|
3066
3068
|
paths: r,
|
|
@@ -3071,12 +3073,12 @@ async function Ai(e) {
|
|
|
3071
3073
|
case "create":
|
|
3072
3074
|
case "skip-if-exists":
|
|
3073
3075
|
case "override": return null;
|
|
3074
|
-
case "merge": return !c || !t.marker || (await
|
|
3076
|
+
case "merge": return !c || !t.marker || (await y.readFile(o, "utf-8")).includes(t.marker) ? null : `${t.target}: Marker "${t.marker}" not found`;
|
|
3075
3077
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3076
3078
|
}
|
|
3077
3079
|
}
|
|
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
|
|
3080
|
+
async function Pi(e) {
|
|
3081
|
+
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await Mi({
|
|
3080
3082
|
file: t,
|
|
3081
3083
|
packDir: n,
|
|
3082
3084
|
paths: r,
|
|
@@ -3094,7 +3096,7 @@ async function ji(e) {
|
|
|
3094
3096
|
status: "skipped",
|
|
3095
3097
|
path: t.target,
|
|
3096
3098
|
reason: "Already exists"
|
|
3097
|
-
} : (await
|
|
3099
|
+
} : (await Ai(s, c), {
|
|
3098
3100
|
status: "installed",
|
|
3099
3101
|
path: t.target
|
|
3100
3102
|
});
|
|
@@ -3103,20 +3105,20 @@ async function ji(e) {
|
|
|
3103
3105
|
status: "skipped",
|
|
3104
3106
|
path: t.target,
|
|
3105
3107
|
reason: "Already exists (skip-if-exists)"
|
|
3106
|
-
} : (await
|
|
3108
|
+
} : (await Ai(s, c), {
|
|
3107
3109
|
status: "installed",
|
|
3108
3110
|
path: t.target
|
|
3109
3111
|
});
|
|
3110
|
-
case "override": return await
|
|
3112
|
+
case "override": return await Ai(s, c), {
|
|
3111
3113
|
status: "installed",
|
|
3112
3114
|
path: t.target
|
|
3113
3115
|
};
|
|
3114
3116
|
case "merge": {
|
|
3115
|
-
if (!u) return await
|
|
3117
|
+
if (!u) return await Ai(s, c), {
|
|
3116
3118
|
status: "installed",
|
|
3117
3119
|
path: t.target
|
|
3118
3120
|
};
|
|
3119
|
-
let e = await
|
|
3121
|
+
let e = await y.readFile(s, "utf-8"), n = await y.readFile(c, "utf-8");
|
|
3120
3122
|
if (t.marker) {
|
|
3121
3123
|
let r = n.indexOf(t.marker);
|
|
3122
3124
|
if (r === -1) return {
|
|
@@ -3125,10 +3127,10 @@ async function ji(e) {
|
|
|
3125
3127
|
reason: `Marker "${t.marker}" not found`
|
|
3126
3128
|
};
|
|
3127
3129
|
let i = n.slice(0, r) + e + n.slice(r);
|
|
3128
|
-
await
|
|
3130
|
+
await y.writeFile(c, i);
|
|
3129
3131
|
} else {
|
|
3130
3132
|
let t = n + "\n" + e;
|
|
3131
|
-
await
|
|
3133
|
+
await y.writeFile(c, t);
|
|
3132
3134
|
}
|
|
3133
3135
|
return {
|
|
3134
3136
|
status: "installed",
|
|
@@ -3142,15 +3144,15 @@ async function ji(e) {
|
|
|
3142
3144
|
};
|
|
3143
3145
|
}
|
|
3144
3146
|
}
|
|
3145
|
-
async function
|
|
3147
|
+
async function Fi(e) {
|
|
3146
3148
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3147
3149
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3148
3150
|
let o = [], s = /* @__PURE__ */ new Set();
|
|
3149
3151
|
for (let e of t) {
|
|
3150
3152
|
let t = i?.get(e.manifest.name);
|
|
3151
3153
|
for (let n of e.manifest.files) {
|
|
3152
|
-
if (n.strategy !== "create" || !
|
|
3153
|
-
let { targetPath: i, targetExists: c } = await
|
|
3154
|
+
if (n.strategy !== "create" || !ki(n, t)) continue;
|
|
3155
|
+
let { targetPath: i, targetExists: c } = await Mi({
|
|
3154
3156
|
file: n,
|
|
3155
3157
|
packDir: e.packDir,
|
|
3156
3158
|
paths: a,
|
|
@@ -3165,13 +3167,13 @@ async function Mi(e) {
|
|
|
3165
3167
|
}
|
|
3166
3168
|
return o;
|
|
3167
3169
|
}
|
|
3168
|
-
async function
|
|
3170
|
+
async function Ii(e) {
|
|
3169
3171
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3170
3172
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3171
3173
|
let c = [];
|
|
3172
3174
|
for (let e of t.files) {
|
|
3173
|
-
if (!
|
|
3174
|
-
let t = await
|
|
3175
|
+
if (!ki(e, o)) continue;
|
|
3176
|
+
let t = await Ni({
|
|
3175
3177
|
file: e,
|
|
3176
3178
|
packDir: a,
|
|
3177
3179
|
paths: s,
|
|
@@ -3182,16 +3184,16 @@ async function Ni(e) {
|
|
|
3182
3184
|
}
|
|
3183
3185
|
return c;
|
|
3184
3186
|
}
|
|
3185
|
-
async function
|
|
3187
|
+
async function Li(e) {
|
|
3186
3188
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3187
3189
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3188
3190
|
let l = {
|
|
3189
3191
|
installed: [],
|
|
3190
3192
|
skipped: [],
|
|
3191
3193
|
errors: []
|
|
3192
|
-
}, u = t.files.filter((e) =>
|
|
3194
|
+
}, u = t.files.filter((e) => ki(e, s));
|
|
3193
3195
|
for (let e of u) {
|
|
3194
|
-
let t = await
|
|
3196
|
+
let t = await Pi({
|
|
3195
3197
|
file: e,
|
|
3196
3198
|
packDir: o,
|
|
3197
3199
|
paths: c,
|
|
@@ -3211,40 +3213,40 @@ async function Pi(e) {
|
|
|
3211
3213
|
break;
|
|
3212
3214
|
}
|
|
3213
3215
|
}
|
|
3214
|
-
await
|
|
3216
|
+
await wi({
|
|
3215
3217
|
files: u,
|
|
3216
3218
|
paths: c,
|
|
3217
3219
|
projectRoot: r,
|
|
3218
3220
|
projectName: n.name
|
|
3219
|
-
}), t.env && t.env.length > 0 && await
|
|
3221
|
+
}), t.env && t.env.length > 0 && await jr(t.env, c, r), t.routes && t.routes.length > 0 && await Ir(t.routes, c, r), t.context && t.context.length > 0 && await zr(t.context, c, r), t.sockets && t.sockets.length > 0 && await qr(t.sockets, c, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await Zr(t.sdkConfigurations, c, r), t.enums && t.enums.length > 0 && await Gr(t.enums, c, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await ei(t.frontendRoutes, c, r);
|
|
3220
3222
|
let d = s && s.length > 0 ? s : ["frontend"];
|
|
3221
|
-
for (let e of d) t.nav && t.nav.length > 0 && await
|
|
3223
|
+
for (let e of d) t.nav && t.nav.length > 0 && await ii({
|
|
3222
3224
|
entries: t.nav,
|
|
3223
3225
|
paths: c,
|
|
3224
3226
|
projectRoot: r,
|
|
3225
3227
|
slot: e
|
|
3226
|
-
}), t.navbarActions && t.navbarActions.length > 0 && await
|
|
3228
|
+
}), t.navbarActions && t.navbarActions.length > 0 && await _i({
|
|
3227
3229
|
actions: t.navbarActions,
|
|
3228
3230
|
paths: c,
|
|
3229
3231
|
projectRoot: r,
|
|
3230
3232
|
slot: e
|
|
3231
|
-
}), t.userMenuActions && t.userMenuActions.length > 0 && await
|
|
3233
|
+
}), t.userMenuActions && t.userMenuActions.length > 0 && await vi({
|
|
3232
3234
|
actions: t.userMenuActions,
|
|
3233
3235
|
paths: c,
|
|
3234
3236
|
projectRoot: r,
|
|
3235
3237
|
slot: e
|
|
3236
3238
|
});
|
|
3237
|
-
return t.onboardingSteps && t.onboardingSteps.length > 0 && await
|
|
3239
|
+
return t.onboardingSteps && t.onboardingSteps.length > 0 && await fi(t.onboardingSteps, c, r), t.postLoginRedirect && await ai({
|
|
3238
3240
|
postLoginRedirect: t.postLoginRedirect,
|
|
3239
3241
|
paths: c,
|
|
3240
3242
|
projectRoot: r,
|
|
3241
3243
|
slot: d[0]
|
|
3242
3244
|
}), l;
|
|
3243
3245
|
}
|
|
3244
|
-
async function
|
|
3246
|
+
async function Ri(e) {
|
|
3245
3247
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3246
3248
|
for (let e of t) {
|
|
3247
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3249
|
+
let t = o?.get(e.manifest.name), a = await Ii({
|
|
3248
3250
|
manifest: e.manifest,
|
|
3249
3251
|
config: n,
|
|
3250
3252
|
projectRoot: r,
|
|
@@ -3264,7 +3266,7 @@ async function Fi(e) {
|
|
|
3264
3266
|
};
|
|
3265
3267
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3266
3268
|
for (let e of t) {
|
|
3267
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3269
|
+
let t = o?.get(e.manifest.name), n = await Li({
|
|
3268
3270
|
manifest: e.manifest,
|
|
3269
3271
|
config: f,
|
|
3270
3272
|
projectRoot: r,
|
|
@@ -3273,7 +3275,7 @@ async function Fi(e) {
|
|
|
3273
3275
|
packDir: e.packDir,
|
|
3274
3276
|
slots: t
|
|
3275
3277
|
});
|
|
3276
|
-
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await
|
|
3278
|
+
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await zi(f, e.manifest.name, r), d.push(e.manifest.name);
|
|
3277
3279
|
}
|
|
3278
3280
|
return {
|
|
3279
3281
|
installed: c,
|
|
@@ -3284,26 +3286,26 @@ async function Fi(e) {
|
|
|
3284
3286
|
config: f
|
|
3285
3287
|
};
|
|
3286
3288
|
}
|
|
3287
|
-
async function
|
|
3289
|
+
async function zi(e, t, n) {
|
|
3288
3290
|
let r = {
|
|
3289
3291
|
...e,
|
|
3290
3292
|
installedPacks: [...e.installedPacks ?? [], t]
|
|
3291
3293
|
};
|
|
3292
|
-
return await
|
|
3294
|
+
return await _r(n, r), r;
|
|
3293
3295
|
}
|
|
3294
|
-
async function
|
|
3296
|
+
async function Bi(e) {
|
|
3295
3297
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3296
3298
|
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
|
|
3299
|
+
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) => Tr(e.source, i))), u = T.join(i, "files");
|
|
3300
|
+
if (await ar(u)) {
|
|
3301
|
+
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3300
3302
|
for (let t of e) {
|
|
3301
3303
|
if (!t.isDirectory()) continue;
|
|
3302
3304
|
let e = a[t.name]?.root;
|
|
3303
3305
|
if (!e) continue;
|
|
3304
|
-
let n = await
|
|
3305
|
-
src:
|
|
3306
|
-
dest:
|
|
3306
|
+
let n = await ji({
|
|
3307
|
+
src: T.join(u, t.name),
|
|
3308
|
+
dest: T.resolve(r, e),
|
|
3307
3309
|
projectRoot: r,
|
|
3308
3310
|
skip: l
|
|
3309
3311
|
});
|
|
@@ -3311,7 +3313,7 @@ async function Li(e) {
|
|
|
3311
3313
|
}
|
|
3312
3314
|
}
|
|
3313
3315
|
for (let e of c) {
|
|
3314
|
-
let t = await
|
|
3316
|
+
let t = await Pi({
|
|
3315
3317
|
file: e,
|
|
3316
3318
|
packDir: i,
|
|
3317
3319
|
paths: a,
|
|
@@ -3321,12 +3323,12 @@ async function Li(e) {
|
|
|
3321
3323
|
});
|
|
3322
3324
|
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3323
3325
|
}
|
|
3324
|
-
let d =
|
|
3325
|
-
return await
|
|
3326
|
+
let d = T.join(wr("{{frontend.root}}", a, r), "src", "routes"), f = T.join(d, "(public)", "index.tsx"), p = T.join(d, "(private)", "index.tsx");
|
|
3327
|
+
return await J(f) && await J(p) && await y.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await ei(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await ii({
|
|
3326
3328
|
entries: t.nav,
|
|
3327
3329
|
paths: a,
|
|
3328
3330
|
projectRoot: r
|
|
3329
|
-
}), t.postLoginRedirect && await
|
|
3331
|
+
}), t.postLoginRedirect && await ai({
|
|
3330
3332
|
postLoginRedirect: t.postLoginRedirect,
|
|
3331
3333
|
paths: a,
|
|
3332
3334
|
projectRoot: r
|
|
@@ -3337,28 +3339,28 @@ async function Li(e) {
|
|
|
3337
3339
|
}
|
|
3338
3340
|
//#endregion
|
|
3339
3341
|
//#region src/core/pack-categories.ts
|
|
3340
|
-
var
|
|
3342
|
+
var Vi = [
|
|
3341
3343
|
"starter",
|
|
3342
3344
|
"layout",
|
|
3343
3345
|
"feature"
|
|
3344
|
-
],
|
|
3346
|
+
], Hi = {
|
|
3345
3347
|
starter: "Starter",
|
|
3346
3348
|
layout: "Layout",
|
|
3347
3349
|
feature: "Features"
|
|
3348
|
-
},
|
|
3349
|
-
function
|
|
3350
|
+
}, Ui = new Set(["starter", "layout"]), Wi = "layout-basic";
|
|
3351
|
+
function Gi(e, t = {}) {
|
|
3350
3352
|
let n = [];
|
|
3351
|
-
for (let r of
|
|
3353
|
+
for (let r of Vi) {
|
|
3352
3354
|
let i = e.filter((e) => e.category === r);
|
|
3353
3355
|
if (i.length === 0) continue;
|
|
3354
|
-
let a =
|
|
3356
|
+
let a = Ui.has(r) ? "single" : "multiple";
|
|
3355
3357
|
if (r === "layout") {
|
|
3356
|
-
n.push(
|
|
3358
|
+
n.push(Ki("frontend", i)), t.adminAvailable && n.push(Ki("admin", i));
|
|
3357
3359
|
continue;
|
|
3358
3360
|
}
|
|
3359
3361
|
n.push({
|
|
3360
3362
|
category: r,
|
|
3361
|
-
label:
|
|
3363
|
+
label: Hi[r],
|
|
3362
3364
|
mode: a,
|
|
3363
3365
|
packs: i,
|
|
3364
3366
|
preselect: null
|
|
@@ -3366,53 +3368,53 @@ function Hi(e, t = {}) {
|
|
|
3366
3368
|
}
|
|
3367
3369
|
return n;
|
|
3368
3370
|
}
|
|
3369
|
-
function
|
|
3370
|
-
let n = t.some((e) => e.name ===
|
|
3371
|
+
function Ki(e, t) {
|
|
3372
|
+
let n = t.some((e) => e.name === Wi);
|
|
3371
3373
|
return {
|
|
3372
3374
|
category: "layout",
|
|
3373
3375
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3374
3376
|
mode: "single",
|
|
3375
3377
|
packs: t,
|
|
3376
|
-
preselect: n ?
|
|
3378
|
+
preselect: n ? Wi : null,
|
|
3377
3379
|
slot: e
|
|
3378
3380
|
};
|
|
3379
3381
|
}
|
|
3380
3382
|
//#endregion
|
|
3381
3383
|
//#region src/ui/logger.ts
|
|
3382
|
-
function
|
|
3383
|
-
|
|
3384
|
+
function qi(e) {
|
|
3385
|
+
s.note(e.map((e) => `${z.arrow} ${e}`).join("\n"), "Next steps");
|
|
3384
3386
|
}
|
|
3385
|
-
function
|
|
3386
|
-
|
|
3387
|
+
function X() {
|
|
3388
|
+
s.cancel(R.muted("Operation cancelled.")), process.exit(0);
|
|
3387
3389
|
}
|
|
3388
3390
|
//#endregion
|
|
3389
3391
|
//#region src/core/post-setup.ts
|
|
3390
|
-
async function
|
|
3392
|
+
async function Ji() {
|
|
3391
3393
|
return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3392
3394
|
}
|
|
3393
|
-
async function
|
|
3394
|
-
return
|
|
3395
|
+
async function Yi(e) {
|
|
3396
|
+
return J(`${e}/apps/backend/.env`);
|
|
3395
3397
|
}
|
|
3396
|
-
async function
|
|
3397
|
-
let r = n ? `Start services with ${
|
|
3398
|
+
async function Xi(e, t, n) {
|
|
3399
|
+
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
3400
|
message: r,
|
|
3399
3401
|
initialValue: !0
|
|
3400
3402
|
});
|
|
3401
|
-
if (
|
|
3402
|
-
let a =
|
|
3403
|
+
if (s.isCancel(i) && X(), !i) return s.log.info(R.muted("Skipping Docker services and database migrations.")), !1;
|
|
3404
|
+
let a = s.spinner();
|
|
3403
3405
|
a.start("Starting Docker services...");
|
|
3404
|
-
let
|
|
3406
|
+
let o = await q("docker", [
|
|
3405
3407
|
"compose",
|
|
3406
3408
|
"up",
|
|
3407
3409
|
"-d"
|
|
3408
3410
|
], { cwd: `${e}/apps/backend` });
|
|
3409
|
-
return
|
|
3411
|
+
return o.exitCode === 0 ? (a.stop(R.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), Zi(o), !1);
|
|
3410
3412
|
}
|
|
3411
|
-
function
|
|
3413
|
+
function Zi(e) {
|
|
3412
3414
|
let t = (e.stderr || e.stdout).trim();
|
|
3413
|
-
t &&
|
|
3415
|
+
t && s.log.warn(R.muted(t));
|
|
3414
3416
|
}
|
|
3415
|
-
async function
|
|
3417
|
+
async function Qi(e, t = 15, n = 2e3) {
|
|
3416
3418
|
for (let r = 0; r < t; r++) {
|
|
3417
3419
|
if ((await q("docker", [
|
|
3418
3420
|
"compose",
|
|
@@ -3427,54 +3429,58 @@ async function Yi(e, t = 15, n = 2e3) {
|
|
|
3427
3429
|
}
|
|
3428
3430
|
return !1;
|
|
3429
3431
|
}
|
|
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", [
|
|
3432
|
+
var $i = "Database schema is up to date";
|
|
3433
|
+
async function ea(e) {
|
|
3434
|
+
let t = await q("pnpm", [
|
|
3453
3435
|
"--filter",
|
|
3454
3436
|
"@internal/backend",
|
|
3455
|
-
"
|
|
3437
|
+
"exec",
|
|
3438
|
+
"prisma",
|
|
3439
|
+
"migrate",
|
|
3440
|
+
"status"
|
|
3456
3441
|
], { cwd: e });
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
let
|
|
3463
|
-
c.start("Generating Prisma client...");
|
|
3464
|
-
let l = await q("pnpm", [
|
|
3442
|
+
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes($i) : !1;
|
|
3443
|
+
}
|
|
3444
|
+
async function ta(e) {
|
|
3445
|
+
let t = s.spinner();
|
|
3446
|
+
t.start("Running database migrations...");
|
|
3447
|
+
let n = await q("pnpm", [
|
|
3465
3448
|
"--filter",
|
|
3466
3449
|
"@internal/backend",
|
|
3467
|
-
"
|
|
3450
|
+
"migration:latest"
|
|
3468
3451
|
], { cwd: e });
|
|
3469
|
-
|
|
3470
|
-
|
|
3452
|
+
return n.exitCode === 0 ? (t.stop(R.success("Database migrations applied")), !0) : (t.error("Migrations failed"), Zi(n), s.log.warn(R.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations.")), !1);
|
|
3453
|
+
}
|
|
3454
|
+
async function na(e, t, n = {}) {
|
|
3455
|
+
if (!await Xi(e, t, await Ji())) return !1;
|
|
3456
|
+
let r = s.spinner();
|
|
3457
|
+
return r.start("Waiting for Postgres to be ready..."), await Qi(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);
|
|
3458
|
+
}
|
|
3459
|
+
async function ra(e, t, n = {}) {
|
|
3460
|
+
if (!await na(e, t, n)) return;
|
|
3461
|
+
let r = t ? !0 : await s.confirm({
|
|
3462
|
+
message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
|
|
3463
|
+
initialValue: !0
|
|
3464
|
+
});
|
|
3465
|
+
if (s.isCancel(r) && X(), !r) {
|
|
3466
|
+
s.log.info(R.muted("Skipping database migrations."));
|
|
3471
3467
|
return;
|
|
3472
3468
|
}
|
|
3473
|
-
|
|
3469
|
+
await ta(e);
|
|
3470
|
+
}
|
|
3471
|
+
async function ia(e, t, n = {}) {
|
|
3472
|
+
if (!await Yi(e)) {
|
|
3473
|
+
s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3474
|
+
return;
|
|
3475
|
+
}
|
|
3476
|
+
await ra(e, t, n);
|
|
3477
|
+
}
|
|
3478
|
+
async function aa(e, t, n = {}) {
|
|
3479
|
+
return await Yi(e) ? na(e, t, n) : (s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker - configure it first.`), !1);
|
|
3474
3480
|
}
|
|
3475
3481
|
//#endregion
|
|
3476
3482
|
//#region src/core/resolve.ts
|
|
3477
|
-
function
|
|
3483
|
+
function oa(e) {
|
|
3478
3484
|
let t = /* @__PURE__ */ new Map();
|
|
3479
3485
|
for (let n of e) t.set(n.name, {
|
|
3480
3486
|
name: n.name,
|
|
@@ -3482,7 +3488,7 @@ function Zi(e) {
|
|
|
3482
3488
|
});
|
|
3483
3489
|
return t;
|
|
3484
3490
|
}
|
|
3485
|
-
function
|
|
3491
|
+
function sa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3486
3492
|
let r = /* @__PURE__ */ new Set();
|
|
3487
3493
|
function i(e) {
|
|
3488
3494
|
if (n.has(e)) return [];
|
|
@@ -3496,10 +3502,10 @@ function Qi(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3496
3502
|
}
|
|
3497
3503
|
return i(e);
|
|
3498
3504
|
}
|
|
3499
|
-
function
|
|
3505
|
+
function ca(e, t, n = []) {
|
|
3500
3506
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3501
3507
|
for (let n of e) {
|
|
3502
|
-
let e =
|
|
3508
|
+
let e = sa(n, t, new Set(i));
|
|
3503
3509
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3504
3510
|
}
|
|
3505
3511
|
return {
|
|
@@ -3507,7 +3513,7 @@ function $i(e, t, n = []) {
|
|
|
3507
3513
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3508
3514
|
};
|
|
3509
3515
|
}
|
|
3510
|
-
function
|
|
3516
|
+
function la(e) {
|
|
3511
3517
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3512
3518
|
for (let e of t) {
|
|
3513
3519
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3520,7 +3526,7 @@ function ea(e) {
|
|
|
3520
3526
|
}
|
|
3521
3527
|
//#endregion
|
|
3522
3528
|
//#region src/core/variants.ts
|
|
3523
|
-
function
|
|
3529
|
+
function ua(e, t = {}) {
|
|
3524
3530
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3525
3531
|
for (let i of e) {
|
|
3526
3532
|
let e = t[i.family] ?? i.default;
|
|
@@ -3532,14 +3538,14 @@ function ta(e, t = {}) {
|
|
|
3532
3538
|
familyOf: r
|
|
3533
3539
|
};
|
|
3534
3540
|
}
|
|
3535
|
-
function
|
|
3541
|
+
function da(e, t, n) {
|
|
3536
3542
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3537
3543
|
}
|
|
3538
|
-
function
|
|
3544
|
+
function fa(e, t) {
|
|
3539
3545
|
let n = t.familyOf.get(e);
|
|
3540
3546
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3541
3547
|
}
|
|
3542
|
-
function
|
|
3548
|
+
function pa(e, t) {
|
|
3543
3549
|
let n = /* @__PURE__ */ new Map();
|
|
3544
3550
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3545
3551
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3555,65 +3561,65 @@ function ia(e, t) {
|
|
|
3555
3561
|
familyOf: n
|
|
3556
3562
|
};
|
|
3557
3563
|
}
|
|
3558
|
-
function
|
|
3564
|
+
function ma(e, t) {
|
|
3559
3565
|
return e.map((e) => ({
|
|
3560
3566
|
...e,
|
|
3561
|
-
dependencies: e.dependencies.map((e) =>
|
|
3567
|
+
dependencies: e.dependencies.map((e) => fa(e, t))
|
|
3562
3568
|
}));
|
|
3563
3569
|
}
|
|
3564
3570
|
//#endregion
|
|
3565
3571
|
//#region src/ui/banner.ts
|
|
3566
|
-
var
|
|
3572
|
+
var ha = [
|
|
3567
3573
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3568
3574
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3569
3575
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3570
3576
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3571
3577
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3572
3578
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3573
|
-
],
|
|
3579
|
+
], ga = [
|
|
3574
3580
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3575
3581
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3576
3582
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3577
3583
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3578
3584
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3579
3585
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3580
|
-
],
|
|
3586
|
+
], _a = [
|
|
3581
3587
|
253,
|
|
3582
3588
|
176,
|
|
3583
3589
|
21
|
|
3584
|
-
],
|
|
3590
|
+
], va = [
|
|
3585
3591
|
245,
|
|
3586
3592
|
76,
|
|
3587
3593
|
2
|
|
3588
|
-
],
|
|
3594
|
+
], ya = 5, ba = [
|
|
3589
3595
|
17,
|
|
3590
3596
|
103,
|
|
3591
3597
|
248
|
|
3592
|
-
],
|
|
3598
|
+
], xa = [
|
|
3593
3599
|
42,
|
|
3594
3600
|
160,
|
|
3595
3601
|
250
|
|
3596
|
-
],
|
|
3597
|
-
function
|
|
3602
|
+
], Sa = .2;
|
|
3603
|
+
function Ca() {
|
|
3598
3604
|
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(` ${
|
|
3605
|
+
for (let e of xe(ha, {
|
|
3606
|
+
start: _a,
|
|
3607
|
+
end: va,
|
|
3608
|
+
angle: ya
|
|
3609
|
+
})) console.log(b.bold(e));
|
|
3610
|
+
for (let e of xe(ga, {
|
|
3611
|
+
start: ba,
|
|
3612
|
+
end: xa,
|
|
3613
|
+
angle: Sa
|
|
3614
|
+
})) console.log(b.bold(e));
|
|
3615
|
+
console.log(), console.log(` ${z.spark} ${b.dim("v" + A)} ${b.dim("·")} ${ye("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3616
|
+
}
|
|
3617
|
+
function wa() {
|
|
3618
|
+
console.log(), console.log(` ${z.bolt} ${ge.orange("Hype")}${ge.skyBlue("Stack")} ${b.dim("v" + A)}`), console.log();
|
|
3613
3619
|
}
|
|
3614
3620
|
//#endregion
|
|
3615
3621
|
//#region src/ui/pack-multiselect.ts
|
|
3616
|
-
var
|
|
3622
|
+
var Ta = class extends O {
|
|
3617
3623
|
options;
|
|
3618
3624
|
cursor = 0;
|
|
3619
3625
|
selected;
|
|
@@ -3679,50 +3685,82 @@ var ga = class extends D {
|
|
|
3679
3685
|
e === "a" && this.toggleAll();
|
|
3680
3686
|
}
|
|
3681
3687
|
renderFrame() {
|
|
3682
|
-
let e =
|
|
3688
|
+
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
3689
|
let n = e.label ?? String(e.value);
|
|
3684
|
-
if (e.disabled) return `${
|
|
3685
|
-
let r = this.selected.has(e.value) ?
|
|
3686
|
-
return `${t ? `${
|
|
3687
|
-
},
|
|
3690
|
+
if (e.disabled) return `${k("gray", d)} ${k(["strikethrough", "gray"], n)}`;
|
|
3691
|
+
let r = this.selected.has(e.value) ? k("green", f) : t ? k("cyan", u) : k("dim", d);
|
|
3692
|
+
return `${t ? `${k("green", p)} ` : " "}${r} ${t ? n : k("dim", n)}${t && e.hint ? ` ${k("dim", `(${e.hint})`)}` : ""}`;
|
|
3693
|
+
}, s = () => {
|
|
3688
3694
|
let e = this.atContinue;
|
|
3689
|
-
return `${e ? `${
|
|
3695
|
+
return `${e ? `${k("green", p)} ` : " "}${k(e ? "cyan" : "dim", this.continueLabel)}${e ? k("dim", " (enter to install)") : ""}`;
|
|
3690
3696
|
};
|
|
3691
3697
|
switch (this.state) {
|
|
3692
3698
|
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 ?
|
|
3699
|
+
let t = this.options.filter((e) => this.selected.has(e.value)).map((e) => e.label ?? String(e.value)).join(k("dim", ", ")) || k("dim", "none");
|
|
3700
|
+
return `${a}${e ? k("gray", c) : ""} ${k("dim", t)}`;
|
|
3695
3701
|
}
|
|
3696
3702
|
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 ?
|
|
3703
|
+
let t = this.options.filter((e) => this.selected.has(e.value)).map((e) => e.label ?? String(e.value)).join(k("dim", ", "));
|
|
3704
|
+
return t.trim() === "" ? `${a}${e ? k("gray", c) : ""}` : `${a}${e ? k("gray", c) : ""} ${k(["strikethrough", "dim"], t)}`;
|
|
3699
3705
|
}
|
|
3700
3706
|
default: {
|
|
3701
|
-
let t =
|
|
3707
|
+
let t = h({
|
|
3702
3708
|
cursor: Math.min(this.cursor, this.options.length - 1),
|
|
3703
3709
|
options: this.options,
|
|
3704
|
-
style: (e, t) => o(e, t),
|
|
3710
|
+
style: (e, t) => o(e, t && !this.atContinue),
|
|
3705
3711
|
output: this.output,
|
|
3706
3712
|
maxItems: this.maxItems,
|
|
3707
3713
|
columnPadding: e ? 3 : 0,
|
|
3708
3714
|
rowPadding: a.split("\n").length + (e ? 4 : 3)
|
|
3709
|
-
}).map((e) => `${r}${e}`), n = `${
|
|
3715
|
+
}).map((e) => `${r}${e}`), n = `${k("dim", "↑/↓ move · enter/space toggle · a all · enter on Continue to install")}`, c = [
|
|
3710
3716
|
...t,
|
|
3711
|
-
`${r}${
|
|
3717
|
+
`${r}${s()}`,
|
|
3712
3718
|
`${r}${n}`,
|
|
3713
3719
|
i
|
|
3714
3720
|
];
|
|
3715
|
-
return this.state === "error" &&
|
|
3721
|
+
return this.state === "error" && c.push(`${r}${k("yellow", this.error)}`), `${a}${c.join("\n")}\n`;
|
|
3716
3722
|
}
|
|
3717
3723
|
}
|
|
3718
3724
|
}
|
|
3719
3725
|
};
|
|
3720
|
-
function
|
|
3721
|
-
return new
|
|
3726
|
+
function Ea(e) {
|
|
3727
|
+
return new Ta(e).prompt();
|
|
3728
|
+
}
|
|
3729
|
+
//#endregion
|
|
3730
|
+
//#region src/utils/naming.ts
|
|
3731
|
+
function Da(e) {
|
|
3732
|
+
return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3733
|
+
}
|
|
3734
|
+
function Oa(e) {
|
|
3735
|
+
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3736
|
+
}
|
|
3737
|
+
//#endregion
|
|
3738
|
+
//#region src/utils/validate.ts
|
|
3739
|
+
function ka(e) {
|
|
3740
|
+
if (!e.trim()) return "Project name cannot be empty";
|
|
3741
|
+
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
3742
|
+
let t = Da(e);
|
|
3743
|
+
if (!re.test(t)) return "Project name must contain at least one letter or number";
|
|
3744
|
+
}
|
|
3745
|
+
//#endregion
|
|
3746
|
+
//#region src/core/apply-mode.ts
|
|
3747
|
+
var Aa = "src/hooks/use-theme.ts", ja = /(\bexport\s+const\s+defaultTheme\s*=\s*)(["'])(?:light|dark)\2/;
|
|
3748
|
+
function Ma(e, t) {
|
|
3749
|
+
return e.replace(ja, (e, n, r) => `${n}${r}${t}${r}`);
|
|
3750
|
+
}
|
|
3751
|
+
async function Na(e, t) {
|
|
3752
|
+
let n = T.resolve(e, Aa), r;
|
|
3753
|
+
try {
|
|
3754
|
+
r = await y.readFile(n, "utf-8");
|
|
3755
|
+
} catch {
|
|
3756
|
+
return !1;
|
|
3757
|
+
}
|
|
3758
|
+
let i = Ma(r, t);
|
|
3759
|
+
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3722
3760
|
}
|
|
3723
3761
|
//#endregion
|
|
3724
3762
|
//#region src/core/apply-theme.ts
|
|
3725
|
-
function
|
|
3763
|
+
function Pa(e, t) {
|
|
3726
3764
|
let n = e.indexOf(t);
|
|
3727
3765
|
if (n === -1) return null;
|
|
3728
3766
|
let r = e.indexOf("{", n);
|
|
@@ -3737,47 +3775,47 @@ function va(e, t) {
|
|
|
3737
3775
|
bodyEnd: a - 1
|
|
3738
3776
|
} : null;
|
|
3739
3777
|
}
|
|
3740
|
-
function
|
|
3778
|
+
function Fa(e, t) {
|
|
3741
3779
|
let n = e;
|
|
3742
3780
|
for (let [e, r] of Object.entries(t)) {
|
|
3743
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3781
|
+
let t = RegExp(`(^[ \\t]*--${Ia(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3744
3782
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3745
3783
|
}
|
|
3746
3784
|
return n;
|
|
3747
3785
|
}
|
|
3748
|
-
function
|
|
3786
|
+
function Ia(e) {
|
|
3749
3787
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3750
3788
|
}
|
|
3751
|
-
function
|
|
3752
|
-
let n =
|
|
3789
|
+
function La(e, t) {
|
|
3790
|
+
let n = Pa(e, ":root"), r = Pa(e, ".dark"), i = e;
|
|
3753
3791
|
if (n) {
|
|
3754
3792
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3755
|
-
i = e +
|
|
3793
|
+
i = e + Fa(r, t.light) + a;
|
|
3756
3794
|
}
|
|
3757
3795
|
if (r) {
|
|
3758
|
-
let e =
|
|
3796
|
+
let e = Pa(i, ".dark");
|
|
3759
3797
|
if (e) {
|
|
3760
3798
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3761
|
-
i = n +
|
|
3799
|
+
i = n + Fa(r, t.dark) + a;
|
|
3762
3800
|
}
|
|
3763
3801
|
}
|
|
3764
3802
|
return i;
|
|
3765
3803
|
}
|
|
3766
|
-
var
|
|
3767
|
-
async function
|
|
3768
|
-
let n =
|
|
3804
|
+
var Ra = "assets/styles.css";
|
|
3805
|
+
async function za(e, t) {
|
|
3806
|
+
let n = T.resolve(e, Ra), r;
|
|
3769
3807
|
try {
|
|
3770
|
-
r = await
|
|
3808
|
+
r = await y.readFile(n, "utf-8");
|
|
3771
3809
|
} catch {
|
|
3772
3810
|
return !1;
|
|
3773
3811
|
}
|
|
3774
|
-
let i =
|
|
3775
|
-
return i === r || await
|
|
3812
|
+
let i = La(r, t);
|
|
3813
|
+
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3776
3814
|
}
|
|
3777
3815
|
//#endregion
|
|
3778
3816
|
//#region src/core/clone.ts
|
|
3779
|
-
async function
|
|
3780
|
-
let t = await ee(
|
|
3817
|
+
async function Ba(e) {
|
|
3818
|
+
let t = await ee(j, {
|
|
3781
3819
|
dir: e,
|
|
3782
3820
|
force: !0
|
|
3783
3821
|
});
|
|
@@ -3788,7 +3826,7 @@ async function wa(e) {
|
|
|
3788
3826
|
}
|
|
3789
3827
|
//#endregion
|
|
3790
3828
|
//#region src/core/editor-config.ts
|
|
3791
|
-
function
|
|
3829
|
+
function Va(e) {
|
|
3792
3830
|
let t = {
|
|
3793
3831
|
globs: [],
|
|
3794
3832
|
alwaysApply: !1
|
|
@@ -3823,10 +3861,10 @@ function Ta(e) {
|
|
|
3823
3861
|
content: i
|
|
3824
3862
|
};
|
|
3825
3863
|
}
|
|
3826
|
-
function
|
|
3864
|
+
function Ha(e) {
|
|
3827
3865
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
3828
3866
|
}
|
|
3829
|
-
function
|
|
3867
|
+
function Ua(e) {
|
|
3830
3868
|
let t;
|
|
3831
3869
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
3832
3870
|
let n = [`trigger: ${t}`];
|
|
@@ -3836,30 +3874,30 @@ function Da(e) {
|
|
|
3836
3874
|
}
|
|
3837
3875
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
3838
3876
|
}
|
|
3839
|
-
function
|
|
3877
|
+
function Wa(e) {
|
|
3840
3878
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
3841
3879
|
}
|
|
3842
|
-
var
|
|
3880
|
+
var Ga = {
|
|
3843
3881
|
claude: {
|
|
3844
3882
|
rulesDir: ".claude/rules",
|
|
3845
3883
|
extension: ".md",
|
|
3846
|
-
convert:
|
|
3884
|
+
convert: Ha
|
|
3847
3885
|
},
|
|
3848
3886
|
windsurf: {
|
|
3849
3887
|
rulesDir: ".windsurf/rules",
|
|
3850
3888
|
extension: ".md",
|
|
3851
|
-
convert:
|
|
3889
|
+
convert: Ua
|
|
3852
3890
|
},
|
|
3853
3891
|
copilot: {
|
|
3854
3892
|
rulesDir: ".github/instructions",
|
|
3855
3893
|
extension: ".instructions.md",
|
|
3856
|
-
convert:
|
|
3894
|
+
convert: Wa
|
|
3857
3895
|
}
|
|
3858
3896
|
};
|
|
3859
|
-
async function
|
|
3860
|
-
let t =
|
|
3897
|
+
async function Ka(e) {
|
|
3898
|
+
let t = T.join(e, ae), n = (await y.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
3861
3899
|
return await Promise.all(n.map(async (e) => {
|
|
3862
|
-
let n =
|
|
3900
|
+
let n = T.join(t, e.name), { frontmatter: r, content: i } = Va(await y.readFile(n, "utf-8"));
|
|
3863
3901
|
return {
|
|
3864
3902
|
frontmatter: r,
|
|
3865
3903
|
content: i,
|
|
@@ -3867,43 +3905,43 @@ async function Aa(e) {
|
|
|
3867
3905
|
};
|
|
3868
3906
|
}));
|
|
3869
3907
|
}
|
|
3870
|
-
async function
|
|
3908
|
+
async function qa(e, t) {
|
|
3871
3909
|
if (t === "cursor") return;
|
|
3872
|
-
let n =
|
|
3873
|
-
await
|
|
3910
|
+
let n = Ga[t], r = await Ka(e), i = T.join(e, n.rulesDir);
|
|
3911
|
+
await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
3874
3912
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3875
|
-
return
|
|
3876
|
-
})), await
|
|
3913
|
+
return y.writeFile(T.join(i, r), t, "utf-8");
|
|
3914
|
+
})), await ur(T.join(e, oe)), await ur(T.join(e, se));
|
|
3877
3915
|
}
|
|
3878
3916
|
//#endregion
|
|
3879
3917
|
//#region src/core/env-files.ts
|
|
3880
|
-
var
|
|
3918
|
+
var Ja = [
|
|
3881
3919
|
"apps",
|
|
3882
3920
|
"packages",
|
|
3883
3921
|
"libs",
|
|
3884
3922
|
"shared"
|
|
3885
3923
|
];
|
|
3886
|
-
async function
|
|
3887
|
-
let t = await
|
|
3924
|
+
async function Ya(e) {
|
|
3925
|
+
let t = await Xa(e);
|
|
3888
3926
|
return (await Promise.all(t.map(async (t) => {
|
|
3889
|
-
let n =
|
|
3890
|
-
return await
|
|
3927
|
+
let n = T.join(T.dirname(t), ".env");
|
|
3928
|
+
return await J(n) ? null : (await y.copyFile(t, n), T.relative(e, n));
|
|
3891
3929
|
}))).filter((e) => e !== null).sort();
|
|
3892
3930
|
}
|
|
3893
|
-
async function
|
|
3894
|
-
let t = [
|
|
3895
|
-
let n =
|
|
3896
|
-
return (await
|
|
3931
|
+
async function Xa(e) {
|
|
3932
|
+
let t = [T.join(e, ".env.example")], n = await Promise.all(Ja.map(async (t) => {
|
|
3933
|
+
let n = T.join(e, t);
|
|
3934
|
+
return (await y.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => T.join(n, e.name, ".env.example"));
|
|
3897
3935
|
}));
|
|
3898
|
-
return t.push(...n.flat()), (await Promise.all(t.map(async (e) => await
|
|
3936
|
+
return t.push(...n.flat()), (await Promise.all(t.map(async (e) => await J(e) ? e : null))).filter((e) => e !== null);
|
|
3899
3937
|
}
|
|
3900
3938
|
//#endregion
|
|
3901
3939
|
//#region src/core/post-clone.ts
|
|
3902
|
-
var
|
|
3903
|
-
async function
|
|
3904
|
-
await
|
|
3940
|
+
var Z = "@hype-stack/", Za = "hype-stack";
|
|
3941
|
+
async function Qa(e) {
|
|
3942
|
+
await ur(T.join(e, ".git"));
|
|
3905
3943
|
}
|
|
3906
|
-
async function
|
|
3944
|
+
async function $a(e) {
|
|
3907
3945
|
await q("git", ["init"], { cwd: e }), await q("git", ["add", "."], { cwd: e }), await q("git", [
|
|
3908
3946
|
"-c",
|
|
3909
3947
|
"user.name=Hype Stack CLI",
|
|
@@ -3914,22 +3952,22 @@ async function La(e) {
|
|
|
3914
3952
|
"Initial commit from Hype Stack CLI"
|
|
3915
3953
|
], { cwd: e });
|
|
3916
3954
|
}
|
|
3917
|
-
async function
|
|
3918
|
-
let n = `@${t}/`, r = await
|
|
3955
|
+
async function eo(e, t) {
|
|
3956
|
+
let n = `@${t}/`, r = await co(e);
|
|
3919
3957
|
for (let e of r) {
|
|
3920
|
-
let t = await
|
|
3958
|
+
let t = await sr(e);
|
|
3921
3959
|
if (!t) continue;
|
|
3922
3960
|
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
|
|
3961
|
+
t.name?.startsWith(Z) && (t.name = t.name.replace(Z, n), r = !0), ao(t.dependencies, n) && (r = !0), ao(t.devDependencies, n) && (r = !0), t.nx && oo(t.nx, n) && (r = !0);
|
|
3962
|
+
let i = await y.readFile(e, "utf-8");
|
|
3963
|
+
if (i.includes(Z)) {
|
|
3964
|
+
let t = i.replaceAll(Z, n);
|
|
3965
|
+
await y.writeFile(e, t, "utf-8");
|
|
3966
|
+
} else r && await cr(e, t);
|
|
3929
3967
|
}
|
|
3930
|
-
await
|
|
3968
|
+
await Ei(e, t), await ro(e, t), await so(e, t);
|
|
3931
3969
|
}
|
|
3932
|
-
var
|
|
3970
|
+
var to = new Set([
|
|
3933
3971
|
".git",
|
|
3934
3972
|
"node_modules",
|
|
3935
3973
|
"dist",
|
|
@@ -3937,68 +3975,68 @@ var za = new Set([
|
|
|
3937
3975
|
".nx",
|
|
3938
3976
|
".next",
|
|
3939
3977
|
"coverage"
|
|
3940
|
-
]),
|
|
3941
|
-
async function
|
|
3942
|
-
if (t ===
|
|
3943
|
-
let n = await
|
|
3978
|
+
]), no = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
|
|
3979
|
+
async function ro(e, t) {
|
|
3980
|
+
if (t === Za) return;
|
|
3981
|
+
let n = await io(e);
|
|
3944
3982
|
await Promise.all(n.map(async (e) => {
|
|
3945
|
-
let n = await
|
|
3983
|
+
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
3946
3984
|
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
3947
3985
|
let r = n.replace(/^(name:[ \t]*)hype-stack/gm, `$1${t}`);
|
|
3948
|
-
await
|
|
3986
|
+
await y.writeFile(e, r, "utf-8");
|
|
3949
3987
|
}));
|
|
3950
3988
|
}
|
|
3951
|
-
async function
|
|
3952
|
-
let t = await
|
|
3989
|
+
async function io(e) {
|
|
3990
|
+
let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
3953
3991
|
return (await Promise.all(t.map(async (t) => {
|
|
3954
|
-
let n =
|
|
3955
|
-
return t.isDirectory() ?
|
|
3992
|
+
let n = T.join(e, t.name);
|
|
3993
|
+
return t.isDirectory() ? to.has(t.name) ? [] : io(n) : t.isFile() && no.test(t.name) ? [n] : [];
|
|
3956
3994
|
}))).flat();
|
|
3957
3995
|
}
|
|
3958
|
-
function
|
|
3996
|
+
function ao(e, t) {
|
|
3959
3997
|
if (!e) return !1;
|
|
3960
3998
|
let n = !1;
|
|
3961
|
-
for (let r of Object.keys(e)) if (r.startsWith(
|
|
3962
|
-
let i = r.replace(
|
|
3999
|
+
for (let r of Object.keys(e)) if (r.startsWith(Z)) {
|
|
4000
|
+
let i = r.replace(Z, t);
|
|
3963
4001
|
e[i] = e[r], delete e[r], n = !0;
|
|
3964
4002
|
}
|
|
3965
4003
|
return n;
|
|
3966
4004
|
}
|
|
3967
|
-
function
|
|
4005
|
+
function oo(e, t) {
|
|
3968
4006
|
if (!e) return !1;
|
|
3969
4007
|
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(
|
|
4008
|
+
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Z) ? (n = !0, e.replace(Z, t)) : e), e.targets) {
|
|
4009
|
+
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
4010
|
}
|
|
3973
4011
|
return n;
|
|
3974
4012
|
}
|
|
3975
|
-
async function
|
|
3976
|
-
let n =
|
|
4013
|
+
async function so(e, t) {
|
|
4014
|
+
let n = T.join(e, "packages/enums/src/app/index.ts"), r = await y.readFile(n, "utf-8").catch(() => null);
|
|
3977
4015
|
if (!r) return;
|
|
3978
|
-
let i = t
|
|
3979
|
-
await
|
|
4016
|
+
let i = Oa(t), a = r.replaceAll(`id: "${Za}"`, `id: "${t}"`).replaceAll(`name: "${Za}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
|
|
4017
|
+
await y.writeFile(n, a, "utf-8");
|
|
3980
4018
|
}
|
|
3981
|
-
async function
|
|
3982
|
-
let t = [], n =
|
|
3983
|
-
(await
|
|
4019
|
+
async function co(e) {
|
|
4020
|
+
let t = [], n = T.join(e, "package.json");
|
|
4021
|
+
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
3984
4022
|
for (let n of [
|
|
3985
4023
|
"apps",
|
|
3986
4024
|
"packages",
|
|
3987
4025
|
"libs",
|
|
3988
4026
|
"shared"
|
|
3989
4027
|
]) {
|
|
3990
|
-
let r =
|
|
4028
|
+
let r = T.join(e, n), i = await y.readdir(r, { withFileTypes: !0 }).catch(() => []);
|
|
3991
4029
|
for (let e of i) {
|
|
3992
4030
|
if (!e.isDirectory()) continue;
|
|
3993
|
-
let n =
|
|
3994
|
-
(await
|
|
4031
|
+
let n = T.join(r, e.name, "package.json");
|
|
4032
|
+
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
3995
4033
|
}
|
|
3996
4034
|
}
|
|
3997
4035
|
return t;
|
|
3998
4036
|
}
|
|
3999
4037
|
//#endregion
|
|
4000
4038
|
//#region src/core/readme.ts
|
|
4001
|
-
var
|
|
4039
|
+
var lo = {
|
|
4002
4040
|
cursor: {
|
|
4003
4041
|
label: "Cursor",
|
|
4004
4042
|
rulesDir: ".cursor/rules"
|
|
@@ -4015,24 +4053,21 @@ var qa = {
|
|
|
4015
4053
|
label: "GitHub Copilot",
|
|
4016
4054
|
rulesDir: ".github/instructions"
|
|
4017
4055
|
}
|
|
4018
|
-
},
|
|
4056
|
+
}, uo = {
|
|
4019
4057
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
4020
4058
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
4021
|
-
},
|
|
4059
|
+
}, fo = {
|
|
4022
4060
|
enums: "Shared enums and app config used across apps",
|
|
4023
4061
|
cli: "Project tooling and code generators"
|
|
4024
4062
|
};
|
|
4025
|
-
function
|
|
4026
|
-
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
4027
|
-
}
|
|
4028
|
-
function Za(e, t) {
|
|
4063
|
+
function po(e, t) {
|
|
4029
4064
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
4030
4065
|
let r = t[e];
|
|
4031
4066
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4032
4067
|
});
|
|
4033
4068
|
}
|
|
4034
|
-
function
|
|
4035
|
-
let { projectName: t, editor: n, workspace: r } = e, i =
|
|
4069
|
+
function mo(e) {
|
|
4070
|
+
let { projectName: t, editor: n, workspace: r } = e, i = Oa(t), a = lo[n], o = !!r.apps.backend, s = po(r.apps, uo), c = po(r.packages, fo), l = [];
|
|
4036
4071
|
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
4072
|
let u = [];
|
|
4038
4073
|
u.push(`# ${i}`), u.push([
|
|
@@ -4140,18 +4175,18 @@ function Qa(e) {
|
|
|
4140
4175
|
"stays useful."
|
|
4141
4176
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4142
4177
|
}
|
|
4143
|
-
async function
|
|
4144
|
-
let n =
|
|
4145
|
-
await
|
|
4178
|
+
async function ho(e, t) {
|
|
4179
|
+
let n = T.join(e, "README.md");
|
|
4180
|
+
await y.writeFile(n, mo(t), "utf-8");
|
|
4146
4181
|
}
|
|
4147
4182
|
//#endregion
|
|
4148
4183
|
//#region src/core/tracking.ts
|
|
4149
|
-
async function
|
|
4184
|
+
async function go(e) {
|
|
4150
4185
|
try {
|
|
4151
4186
|
let t = {
|
|
4152
|
-
"X-Device-Id":
|
|
4153
|
-
"X-Client-Info":
|
|
4154
|
-
}, n = await
|
|
4187
|
+
"X-Device-Id": Xn(),
|
|
4188
|
+
"X-Client-Info": Zn()
|
|
4189
|
+
}, n = await Kn(I()).catch(() => null);
|
|
4155
4190
|
n?.token && (t.Authorization = `Bearer ${n.token}`), await K.createRequest()({
|
|
4156
4191
|
endpoint: "/cli/track",
|
|
4157
4192
|
method: "POST"
|
|
@@ -4159,274 +4194,8 @@ async function eo(e) {
|
|
|
4159
4194
|
} catch {}
|
|
4160
4195
|
}
|
|
4161
4196
|
//#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
4197
|
//#region src/core/npm-deps.ts
|
|
4429
|
-
function
|
|
4198
|
+
function _o(e, t) {
|
|
4430
4199
|
let n = [], r = [];
|
|
4431
4200
|
if (!e) return {
|
|
4432
4201
|
errors: n,
|
|
@@ -4457,7 +4226,7 @@ function ho(e, t) {
|
|
|
4457
4226
|
operations: r
|
|
4458
4227
|
};
|
|
4459
4228
|
}
|
|
4460
|
-
function
|
|
4229
|
+
function vo(e) {
|
|
4461
4230
|
let t = {};
|
|
4462
4231
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4463
4232
|
...t[e],
|
|
@@ -4465,15 +4234,15 @@ function go(e) {
|
|
|
4465
4234
|
};
|
|
4466
4235
|
return t;
|
|
4467
4236
|
}
|
|
4468
|
-
async function
|
|
4237
|
+
async function yo(e, t, n = q) {
|
|
4469
4238
|
let r = [];
|
|
4470
4239
|
for (let i of e) {
|
|
4471
|
-
let e =
|
|
4472
|
-
if (!await
|
|
4240
|
+
let e = T.join(t, i.relativeDir);
|
|
4241
|
+
if (!await J(T.join(e, "package.json"))) {
|
|
4473
4242
|
r.push(`Cannot install npm dependencies under "${i.relativeDir}": package.json not found.`);
|
|
4474
4243
|
continue;
|
|
4475
4244
|
}
|
|
4476
|
-
let a =
|
|
4245
|
+
let a = T.normalize(i.relativeDir), o;
|
|
4477
4246
|
try {
|
|
4478
4247
|
o = await n("pnpm", [
|
|
4479
4248
|
"add",
|
|
@@ -4498,39 +4267,39 @@ async function _o(e, t, n = q) {
|
|
|
4498
4267
|
}
|
|
4499
4268
|
//#endregion
|
|
4500
4269
|
//#region src/commands/install-helpers.ts
|
|
4501
|
-
function
|
|
4270
|
+
function Q(e) {
|
|
4502
4271
|
return e instanceof Error ? e.message : String(e);
|
|
4503
4272
|
}
|
|
4504
|
-
async function
|
|
4273
|
+
async function bo(e, t, n) {
|
|
4505
4274
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4506
|
-
return r.length === 0 ? {} :
|
|
4275
|
+
return r.length === 0 ? {} : Or(r, n).catch(() => ({}));
|
|
4507
4276
|
}
|
|
4508
|
-
function
|
|
4509
|
-
return e === "free" ?
|
|
4277
|
+
function xo(e, t) {
|
|
4278
|
+
return e === "free" ? R.success("free") : e === "owned" ? R.accent("owned") : `${R.highlight(`$${t}`)} ${R.muted("locked")}`;
|
|
4510
4279
|
}
|
|
4511
|
-
async function
|
|
4280
|
+
async function So(e, t, n) {
|
|
4512
4281
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4513
|
-
i.length > 0 &&
|
|
4282
|
+
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
4283
|
name: e.name,
|
|
4515
4284
|
displayName: e.displayName,
|
|
4516
4285
|
price: e.price
|
|
4517
4286
|
})));
|
|
4518
4287
|
}
|
|
4519
|
-
function
|
|
4288
|
+
function Co(e, t) {
|
|
4520
4289
|
let n = e.map((e, n) => {
|
|
4521
4290
|
let r = t.get(e), i = r ? r.displayName : e;
|
|
4522
|
-
return ` ${
|
|
4291
|
+
return ` ${R.muted(`${n + 1}.`)} ${R.brand(i)}`;
|
|
4523
4292
|
});
|
|
4524
|
-
|
|
4293
|
+
s.note([
|
|
4525
4294
|
"These packs will be installed, in order:",
|
|
4526
4295
|
"",
|
|
4527
4296
|
...n
|
|
4528
4297
|
].join("\n"), "Install Plan");
|
|
4529
4298
|
}
|
|
4530
|
-
async function
|
|
4299
|
+
async function wo(e, t) {
|
|
4531
4300
|
let n = [];
|
|
4532
4301
|
for (let r of e) {
|
|
4533
|
-
let e = await
|
|
4302
|
+
let e = await Sr(r), i = await Cr(r, t);
|
|
4534
4303
|
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'npx @hype-stack/cli login' or check your license.`);
|
|
4535
4304
|
n.push({
|
|
4536
4305
|
manifest: e,
|
|
@@ -4539,245 +4308,508 @@ async function So(e, t) {
|
|
|
4539
4308
|
}
|
|
4540
4309
|
return n;
|
|
4541
4310
|
}
|
|
4542
|
-
async function
|
|
4543
|
-
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a =
|
|
4311
|
+
async function To(e) {
|
|
4312
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = _o(vo(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4544
4313
|
if (a.errors.length > 0) {
|
|
4545
|
-
for (let e of a.errors)
|
|
4314
|
+
for (let e of a.errors) s.log.error(e);
|
|
4546
4315
|
return;
|
|
4547
4316
|
}
|
|
4548
4317
|
if (a.operations.length === 0) return;
|
|
4549
4318
|
i.start("Installing npm dependencies...");
|
|
4550
|
-
let
|
|
4551
|
-
if (i.stop(
|
|
4319
|
+
let o = await yo(a.operations, r);
|
|
4320
|
+
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
4321
|
}
|
|
4553
|
-
function
|
|
4554
|
-
|
|
4555
|
-
n.length !== 0 && o.note(n.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Next Steps");
|
|
4322
|
+
function Eo() {
|
|
4323
|
+
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
4324
|
}
|
|
4557
|
-
function
|
|
4325
|
+
function Do(e) {
|
|
4558
4326
|
if (e.length === 0) return;
|
|
4559
4327
|
let t = e.map((e) => {
|
|
4560
4328
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
4561
|
-
return ` ${
|
|
4329
|
+
return ` ${R.muted("•")} ${R.path(t)}`;
|
|
4562
4330
|
});
|
|
4563
|
-
|
|
4331
|
+
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4564
4332
|
}
|
|
4565
|
-
async function
|
|
4566
|
-
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack:
|
|
4333
|
+
async function Oo(e) {
|
|
4334
|
+
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
|
|
4567
4335
|
if (i) return c;
|
|
4568
|
-
let l = await
|
|
4336
|
+
let l = await Fi({
|
|
4569
4337
|
packs: t,
|
|
4570
4338
|
config: n,
|
|
4571
4339
|
projectRoot: r,
|
|
4572
|
-
slotsByPack:
|
|
4340
|
+
slotsByPack: o
|
|
4573
4341
|
});
|
|
4574
4342
|
if (l.length === 0) return c;
|
|
4575
4343
|
if (a) {
|
|
4576
|
-
|
|
4344
|
+
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${R.command("--force")} to overwrite.`);
|
|
4577
4345
|
let e = l.map((e) => {
|
|
4578
|
-
let t =
|
|
4579
|
-
return ` ${
|
|
4346
|
+
let t = T.relative(r, e.targetPath) || e.target;
|
|
4347
|
+
return ` ${R.muted("•")} ${R.path(t)} ${R.muted(`(${e.packName})`)}`;
|
|
4580
4348
|
});
|
|
4581
|
-
return
|
|
4349
|
+
return s.note(e.join("\n"), "Kept existing files"), c;
|
|
4582
4350
|
}
|
|
4583
|
-
|
|
4351
|
+
s.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4584
4352
|
for (let e of l) {
|
|
4585
|
-
let t =
|
|
4586
|
-
message: `Overwrite ${
|
|
4353
|
+
let t = T.relative(r, e.targetPath) || e.target, n = await s.confirm({
|
|
4354
|
+
message: `Overwrite ${R.path(t)}? ${R.muted(`(${e.packName})`)}`,
|
|
4587
4355
|
initialValue: !1
|
|
4588
4356
|
});
|
|
4589
|
-
|
|
4357
|
+
s.isCancel(n) && (s.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
|
|
4590
4358
|
}
|
|
4591
4359
|
return c;
|
|
4592
4360
|
}
|
|
4593
4361
|
//#endregion
|
|
4362
|
+
//#region src/ui/swatch.ts
|
|
4363
|
+
function ko(e) {
|
|
4364
|
+
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4365
|
+
if (!t) return null;
|
|
4366
|
+
let n = t[1].trim().split(/\s+/);
|
|
4367
|
+
if (n.length < 3) return null;
|
|
4368
|
+
let r = n[0], i = Number(n[1]), a = Number(n[2]);
|
|
4369
|
+
if (Number.isNaN(i) || Number.isNaN(a)) return null;
|
|
4370
|
+
let o;
|
|
4371
|
+
if (r.endsWith("%")) {
|
|
4372
|
+
let e = Number(r.slice(0, -1));
|
|
4373
|
+
if (Number.isNaN(e)) return null;
|
|
4374
|
+
o = e / 100;
|
|
4375
|
+
} else if (o = Number(r), Number.isNaN(o)) return null;
|
|
4376
|
+
return {
|
|
4377
|
+
l: o,
|
|
4378
|
+
c: i,
|
|
4379
|
+
h: a
|
|
4380
|
+
};
|
|
4381
|
+
}
|
|
4382
|
+
function Ao(e) {
|
|
4383
|
+
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4384
|
+
}
|
|
4385
|
+
function jo(e) {
|
|
4386
|
+
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4387
|
+
}
|
|
4388
|
+
function Mo({ l: e, c: t, h: n }) {
|
|
4389
|
+
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;
|
|
4390
|
+
return [
|
|
4391
|
+
Ao(jo(f) * 255),
|
|
4392
|
+
Ao(jo(p) * 255),
|
|
4393
|
+
Ao(jo(m) * 255)
|
|
4394
|
+
];
|
|
4395
|
+
}
|
|
4396
|
+
var No = "\x1B[49m";
|
|
4397
|
+
function Po(e, t) {
|
|
4398
|
+
let n = e[t];
|
|
4399
|
+
if (!n) return b.dim(" ");
|
|
4400
|
+
let r = ko(n);
|
|
4401
|
+
if (!r) return b.dim(" ");
|
|
4402
|
+
let [i, a, o] = Mo(r);
|
|
4403
|
+
return `\x1b[48;2;${i};${a};${o}m ${No}`;
|
|
4404
|
+
}
|
|
4405
|
+
var Fo = [
|
|
4406
|
+
"primary",
|
|
4407
|
+
"secondary",
|
|
4408
|
+
"accent"
|
|
4409
|
+
];
|
|
4410
|
+
function Io(e) {
|
|
4411
|
+
return Fo.map((t) => Po(e, t)).join("");
|
|
4412
|
+
}
|
|
4413
|
+
function Lo(e) {
|
|
4414
|
+
return `${Io(e.light)} ${b.dim("·")} ${Io(e.dark)}`;
|
|
4415
|
+
}
|
|
4416
|
+
//#endregion
|
|
4417
|
+
//#region src/commands/create.ts
|
|
4418
|
+
async function Ro(e) {
|
|
4419
|
+
e.skipBanner || Ca(), s.intro(R.brandBold("Create a new Hype Stack project"));
|
|
4420
|
+
let o = e.yes === !0, c, l;
|
|
4421
|
+
if (o && e.name) {
|
|
4422
|
+
let t = ka(e.name);
|
|
4423
|
+
t && (s.log.error(t), X()), l = e.name, c = Da(e.name);
|
|
4424
|
+
} else {
|
|
4425
|
+
let t = await s.text({
|
|
4426
|
+
message: "What is your project named?",
|
|
4427
|
+
placeholder: "my-app",
|
|
4428
|
+
initialValue: e.name ?? "",
|
|
4429
|
+
validate: (e) => ka(e ?? "")
|
|
4430
|
+
});
|
|
4431
|
+
s.isCancel(t) && X(), l = t, c = Da(l);
|
|
4432
|
+
}
|
|
4433
|
+
l.trim() !== c && s.log.info(R.muted(`Using "${R.highlight(c)}" as the project name`));
|
|
4434
|
+
let u;
|
|
4435
|
+
if (e.directory !== void 0) u = e.directory;
|
|
4436
|
+
else {
|
|
4437
|
+
let t;
|
|
4438
|
+
if (e.parentDirectory !== void 0) t = e.parentDirectory;
|
|
4439
|
+
else if (o) t = ".";
|
|
4440
|
+
else {
|
|
4441
|
+
let e = await s.text({
|
|
4442
|
+
message: "Where should we create it? (parent folder, the project gets its own subfolder inside)",
|
|
4443
|
+
placeholder: ".",
|
|
4444
|
+
initialValue: "."
|
|
4445
|
+
});
|
|
4446
|
+
s.isCancel(e) && X(), t = e;
|
|
4447
|
+
}
|
|
4448
|
+
u = dr(t, c);
|
|
4449
|
+
}
|
|
4450
|
+
let d = T.resolve(u);
|
|
4451
|
+
o || s.note(R.path(d), "Project will be created at");
|
|
4452
|
+
let f = e.editor && ie.includes(e.editor) ? e.editor : null, p;
|
|
4453
|
+
if (f) p = f;
|
|
4454
|
+
else if (o) p = "cursor";
|
|
4455
|
+
else {
|
|
4456
|
+
let e = await s.select({
|
|
4457
|
+
message: "Which code editor do you use?",
|
|
4458
|
+
options: F.map((e) => ({
|
|
4459
|
+
value: e.value,
|
|
4460
|
+
label: e.label,
|
|
4461
|
+
hint: "hint" in e ? e.hint : void 0
|
|
4462
|
+
})),
|
|
4463
|
+
initialValue: "cursor"
|
|
4464
|
+
});
|
|
4465
|
+
s.isCancel(e) && X(), p = e;
|
|
4466
|
+
}
|
|
4467
|
+
let m = e.theme !== void 0 && a(e.theme), h = e.defaultTheme !== void 0 && a(e.defaultTheme) ? e.defaultTheme : t, g;
|
|
4468
|
+
if (m) g = e.theme;
|
|
4469
|
+
else if (o) g = h;
|
|
4470
|
+
else {
|
|
4471
|
+
let e = await s.select({
|
|
4472
|
+
message: "Pick a color theme",
|
|
4473
|
+
options: r.map((e) => ({
|
|
4474
|
+
value: e.name,
|
|
4475
|
+
label: `${Lo(e)} ${e.label}`
|
|
4476
|
+
})),
|
|
4477
|
+
initialValue: h
|
|
4478
|
+
});
|
|
4479
|
+
s.isCancel(e) && X(), g = e;
|
|
4480
|
+
}
|
|
4481
|
+
if (!o) {
|
|
4482
|
+
let e = F.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?` });
|
|
4483
|
+
(s.isCancel(r) || !r) && X();
|
|
4484
|
+
}
|
|
4485
|
+
if (await ar(d) && !await or(d)) {
|
|
4486
|
+
let e = await s.confirm({
|
|
4487
|
+
message: `Directory ${R.path(d)} is not empty. Continue anyway?`,
|
|
4488
|
+
initialValue: !1
|
|
4489
|
+
});
|
|
4490
|
+
(s.isCancel(e) || !e) && X();
|
|
4491
|
+
}
|
|
4492
|
+
let _ = s.spinner();
|
|
4493
|
+
_.start("Cloning Hype Stack template..."), await Ba(d), _.stop(R.success("Template cloned"));
|
|
4494
|
+
let v = s.spinner();
|
|
4495
|
+
v.start("Setting up project..."), await Qa(d), await eo(d, c), await qa(d, p);
|
|
4496
|
+
let y = await vr(d), b = br(c, y);
|
|
4497
|
+
await _r(d, b), await ho(d, {
|
|
4498
|
+
projectName: c,
|
|
4499
|
+
editor: p,
|
|
4500
|
+
workspace: y
|
|
4501
|
+
});
|
|
4502
|
+
let x = T.resolve(d, b.paths?.frontend.root ?? "apps/frontend");
|
|
4503
|
+
a(g) && (await za(x, i(g)) || s.log.warn(R.muted(`Could not find ${R.path("assets/styles.css")} to apply the ${g} theme`))), await Na(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"));
|
|
4504
|
+
let S = s.spinner();
|
|
4505
|
+
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.")));
|
|
4506
|
+
let C = s.spinner();
|
|
4507
|
+
C.start("Initializing git repository..."), await $a(d), C.stop(R.success("Git repository initialized with clean history"));
|
|
4508
|
+
let w = s.spinner();
|
|
4509
|
+
w.start("Creating .env files from examples...");
|
|
4510
|
+
let E = await Ya(d);
|
|
4511
|
+
if (E.length > 0) {
|
|
4512
|
+
let e = E.length;
|
|
4513
|
+
w.stop(R.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4514
|
+
} else w.stop(R.muted("No .env.example files to copy"));
|
|
4515
|
+
s.log.success(`${R.brandBold("Hype Stack")} project ${R.highlight(c)} is ready!`);
|
|
4516
|
+
let D = T.relative(process.cwd(), d) || ".", O = [`${R.command(`cd ${D}`)}`];
|
|
4517
|
+
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`), qi(O);
|
|
4518
|
+
let k = e.setup === !1;
|
|
4519
|
+
if (e.deferSetup) s.log.info(R.muted("Docker and migrations will run after your packs are installed."));
|
|
4520
|
+
else {
|
|
4521
|
+
let e = !k && (o || await s.confirm({
|
|
4522
|
+
message: "Would you like to start Docker services and run database migrations now?",
|
|
4523
|
+
initialValue: !0
|
|
4524
|
+
}));
|
|
4525
|
+
s.isCancel(e) && X(), e ? await ia(d, o) : s.log.info(R.muted("Docker and migrations can run later via `npx @hype-stack/cli onboard`.")), Eo();
|
|
4526
|
+
}
|
|
4527
|
+
return await go("project_create"), s.outro(R.muted("Happy building!")), d;
|
|
4528
|
+
}
|
|
4529
|
+
//#endregion
|
|
4530
|
+
//#region src/commands/init.ts
|
|
4531
|
+
async function zo(e) {
|
|
4532
|
+
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4533
|
+
if (n || (wa(), s.intro(R.brandBold("Initialize Hype Stack configuration"))), !await xr(t)) {
|
|
4534
|
+
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.`));
|
|
4535
|
+
return;
|
|
4536
|
+
}
|
|
4537
|
+
if (await gr(t)) {
|
|
4538
|
+
let e = await hr(t);
|
|
4539
|
+
if (e && !n) {
|
|
4540
|
+
s.log.info(`Found existing ${R.path("stack.json")} for project ${R.highlight(e.name)}`);
|
|
4541
|
+
let t = await s.confirm({
|
|
4542
|
+
message: "Overwrite existing configuration?",
|
|
4543
|
+
initialValue: !1
|
|
4544
|
+
});
|
|
4545
|
+
if (s.isCancel(t) || !t) {
|
|
4546
|
+
s.outro(R.muted("Keeping existing configuration."));
|
|
4547
|
+
return;
|
|
4548
|
+
}
|
|
4549
|
+
}
|
|
4550
|
+
}
|
|
4551
|
+
let r = await vr(t);
|
|
4552
|
+
if (!n) {
|
|
4553
|
+
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4554
|
+
if (e.length > 0) {
|
|
4555
|
+
s.log.info(R.bold("Detected apps:"));
|
|
4556
|
+
for (let [t, n] of e) s.log.message(` ${z.arrow} ${R.highlight(t)} ${R.muted(`→ ${n}`)}`);
|
|
4557
|
+
}
|
|
4558
|
+
if (t.length > 0) {
|
|
4559
|
+
s.log.info(R.bold("Detected packages:"));
|
|
4560
|
+
for (let [e, n] of t) s.log.message(` ${z.arrow} ${R.highlight(e)} ${R.muted(`→ ${n}`)}`);
|
|
4561
|
+
}
|
|
4562
|
+
e.length === 0 && t.length === 0 && s.log.warn("No apps or packages detected in the workspace.");
|
|
4563
|
+
}
|
|
4564
|
+
let i = (await sr(T.join(t, "package.json")))?.name?.replace(/^@/, "").replace(/\/source$/, "") ?? "my-app", a = i;
|
|
4565
|
+
if (!n) {
|
|
4566
|
+
let e = await s.text({
|
|
4567
|
+
message: "Project name for stack.json?",
|
|
4568
|
+
placeholder: i,
|
|
4569
|
+
initialValue: i,
|
|
4570
|
+
validate: (e) => ka(e ?? "")
|
|
4571
|
+
});
|
|
4572
|
+
s.isCancel(e) && X(), a = Da(e);
|
|
4573
|
+
}
|
|
4574
|
+
await _r(t, br(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.")));
|
|
4575
|
+
}
|
|
4576
|
+
async function Bo(e, t = {}, n) {
|
|
4577
|
+
if (await gr(e)) return {
|
|
4578
|
+
projectRoot: e,
|
|
4579
|
+
scaffolded: !1
|
|
4580
|
+
};
|
|
4581
|
+
let r = t.runInit ?? ((e) => zo({
|
|
4582
|
+
cwd: e,
|
|
4583
|
+
silent: !0
|
|
4584
|
+
})), i = t.runCreate ?? ((e, t) => Ro({
|
|
4585
|
+
parentDirectory: e,
|
|
4586
|
+
deferSetup: !0,
|
|
4587
|
+
skipBanner: !0,
|
|
4588
|
+
defaultTheme: t?.defaultTheme,
|
|
4589
|
+
defaultMode: t?.defaultMode
|
|
4590
|
+
}));
|
|
4591
|
+
if (await xr(e)) {
|
|
4592
|
+
s.log.warn(`No ${R.path("stack.json")} found in ${R.path(e)}.`);
|
|
4593
|
+
let t = await s.confirm({
|
|
4594
|
+
message: `Create ${R.path("stack.json")} now?`,
|
|
4595
|
+
initialValue: !0
|
|
4596
|
+
});
|
|
4597
|
+
if (s.isCancel(t) || !t) return null;
|
|
4598
|
+
await r(e);
|
|
4599
|
+
let n = await gr(e);
|
|
4600
|
+
return n && s.log.success(`${R.path("stack.json")} created`), n ? {
|
|
4601
|
+
projectRoot: e,
|
|
4602
|
+
scaffolded: !1
|
|
4603
|
+
} : null;
|
|
4604
|
+
}
|
|
4605
|
+
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${R.path("stack.json")} here.`);
|
|
4606
|
+
let a = await s.confirm({
|
|
4607
|
+
message: `Is ${R.path(e)} where you want to work?`,
|
|
4608
|
+
initialValue: !0
|
|
4609
|
+
});
|
|
4610
|
+
if (s.isCancel(a) || !a) return null;
|
|
4611
|
+
let o = await s.confirm({
|
|
4612
|
+
message: "Create a new Hype Stack project here?",
|
|
4613
|
+
initialValue: !0
|
|
4614
|
+
});
|
|
4615
|
+
if (s.isCancel(o) || !o) return null;
|
|
4616
|
+
let c = await i(e, n);
|
|
4617
|
+
return await gr(c) ? {
|
|
4618
|
+
projectRoot: c,
|
|
4619
|
+
scaffolded: !0
|
|
4620
|
+
} : null;
|
|
4621
|
+
}
|
|
4622
|
+
//#endregion
|
|
4594
4623
|
//#region src/commands/compose.ts
|
|
4595
|
-
async function
|
|
4624
|
+
async function Vo(e = {}) {
|
|
4596
4625
|
let t = e.cwd ?? process.cwd();
|
|
4597
|
-
|
|
4598
|
-
let n = await
|
|
4626
|
+
Ca();
|
|
4627
|
+
let n = await Bo(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4599
4628
|
try {
|
|
4600
|
-
a = await
|
|
4629
|
+
a = await hr(r ?? t);
|
|
4601
4630
|
} catch (e) {
|
|
4602
|
-
|
|
4631
|
+
s.cancel(`Could not parse ${R.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4603
4632
|
}
|
|
4604
|
-
a || (
|
|
4605
|
-
let
|
|
4606
|
-
|
|
4607
|
-
let c =
|
|
4633
|
+
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));
|
|
4634
|
+
let o = r ?? t;
|
|
4635
|
+
s.intro(R.brandBold("Compose your stack"));
|
|
4636
|
+
let c = s.spinner();
|
|
4608
4637
|
c.start("Loading packs...");
|
|
4609
4638
|
let l;
|
|
4610
4639
|
try {
|
|
4611
|
-
l = await
|
|
4640
|
+
l = await Dr();
|
|
4612
4641
|
} catch (e) {
|
|
4613
|
-
c.stop("Failed to load packs"),
|
|
4642
|
+
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
4643
|
}
|
|
4615
4644
|
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
|
|
4645
|
+
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(I()))?.token ?? null, h = await bo(l, d, {
|
|
4617
4646
|
token: m,
|
|
4618
4647
|
key: p
|
|
4619
4648
|
}), g = (e) => {
|
|
4620
4649
|
let t = f.get(e);
|
|
4621
4650
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4622
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked",
|
|
4651
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await Ho({
|
|
4623
4652
|
packs: l,
|
|
4624
4653
|
installedSet: d,
|
|
4625
4654
|
stateOf: g,
|
|
4626
4655
|
options: e,
|
|
4627
4656
|
adminAvailable: !!a.apps.admin
|
|
4628
4657
|
});
|
|
4629
|
-
if (
|
|
4630
|
-
|
|
4658
|
+
if (v === null && (s.cancel("Cancelled."), process.exit(0)), v.length === 0) {
|
|
4659
|
+
s.outro(R.muted("No packs selected. Nothing to do."));
|
|
4631
4660
|
return;
|
|
4632
4661
|
}
|
|
4633
|
-
let b =
|
|
4662
|
+
let b = Go(v), x = Ko(v), S = pa(l, b), C = oa(ma(l, S)), w;
|
|
4634
4663
|
try {
|
|
4635
|
-
w =
|
|
4664
|
+
w = ca(b, C, u);
|
|
4636
4665
|
} catch (e) {
|
|
4637
|
-
|
|
4666
|
+
s.cancel(Q(e)), process.exit(1);
|
|
4638
4667
|
}
|
|
4639
4668
|
if (w.order.length === 0) {
|
|
4640
|
-
|
|
4669
|
+
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(R.muted("Your selection is already part of the project."));
|
|
4641
4670
|
return;
|
|
4642
4671
|
}
|
|
4643
|
-
let T =
|
|
4672
|
+
let T = la({
|
|
4644
4673
|
order: w.order,
|
|
4645
4674
|
graph: C,
|
|
4646
4675
|
isLocked: _,
|
|
4647
4676
|
installed: u
|
|
4648
4677
|
});
|
|
4649
4678
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4650
|
-
let e = await
|
|
4651
|
-
e && (m = e, h = await
|
|
4679
|
+
let e = await nr();
|
|
4680
|
+
e && (m = e, h = await bo(l, d, {
|
|
4652
4681
|
token: m,
|
|
4653
4682
|
key: p
|
|
4654
|
-
}), T =
|
|
4683
|
+
}), T = la({
|
|
4655
4684
|
order: w.order,
|
|
4656
4685
|
graph: C,
|
|
4657
4686
|
isLocked: _,
|
|
4658
4687
|
installed: u
|
|
4659
4688
|
}));
|
|
4660
4689
|
}
|
|
4661
|
-
if (T.blocked.length > 0 && await
|
|
4662
|
-
|
|
4690
|
+
if (T.blocked.length > 0 && await So(T.blocked, _, f), T.installable.length === 0) {
|
|
4691
|
+
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
4663
4692
|
return;
|
|
4664
4693
|
}
|
|
4665
|
-
if (
|
|
4666
|
-
let e = await
|
|
4667
|
-
(
|
|
4694
|
+
if (Co(T.installable, f), !e.yes) {
|
|
4695
|
+
let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4696
|
+
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
4668
4697
|
}
|
|
4669
4698
|
c.start("Downloading packs...");
|
|
4670
4699
|
let E;
|
|
4671
4700
|
try {
|
|
4672
|
-
E = await
|
|
4701
|
+
E = await wo(T.installable, {
|
|
4673
4702
|
token: m,
|
|
4674
4703
|
key: p
|
|
4675
4704
|
});
|
|
4676
4705
|
} catch (e) {
|
|
4677
|
-
c.stop("Download failed"),
|
|
4706
|
+
c.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
|
|
4678
4707
|
}
|
|
4679
4708
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4680
|
-
let D = await
|
|
4709
|
+
let D = await Oo({
|
|
4681
4710
|
prepared: E,
|
|
4682
4711
|
config: a,
|
|
4683
|
-
cwd:
|
|
4712
|
+
cwd: o,
|
|
4684
4713
|
force: e.force ?? !1,
|
|
4685
4714
|
yes: e.yes ?? !1,
|
|
4686
4715
|
slotsByPack: x
|
|
4687
4716
|
});
|
|
4688
4717
|
try {
|
|
4689
4718
|
c.start("Installing pack files...");
|
|
4690
|
-
let t = await
|
|
4719
|
+
let t = await Ri({
|
|
4691
4720
|
packs: E,
|
|
4692
4721
|
config: a,
|
|
4693
|
-
projectRoot:
|
|
4722
|
+
projectRoot: o,
|
|
4694
4723
|
force: e.force ?? !1,
|
|
4695
4724
|
overwrite: D,
|
|
4696
4725
|
slotsByPack: x
|
|
4697
4726
|
});
|
|
4698
4727
|
if (t.aborted) {
|
|
4699
4728
|
c.stop("Installation aborted");
|
|
4700
|
-
for (let e of t.errors)
|
|
4701
|
-
|
|
4729
|
+
for (let e of t.errors) s.log.error(e);
|
|
4730
|
+
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4702
4731
|
}
|
|
4703
|
-
c.stop("Files installed"), t.installed.length > 0 &&
|
|
4704
|
-
for (let e of t.errors)
|
|
4705
|
-
await
|
|
4732
|
+
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)`), Do(t.skipped));
|
|
4733
|
+
for (let e of t.errors) s.log.error(e);
|
|
4734
|
+
await To({
|
|
4706
4735
|
prepared: E,
|
|
4707
4736
|
paths: a.paths,
|
|
4708
|
-
cwd:
|
|
4737
|
+
cwd: o,
|
|
4709
4738
|
spinner: c
|
|
4710
|
-
})
|
|
4711
|
-
|
|
4739
|
+
});
|
|
4740
|
+
let n;
|
|
4741
|
+
i && (n = await aa(o, e.yes ?? !1)), await pr({
|
|
4742
|
+
projectRoot: o,
|
|
4712
4743
|
paths: a.paths,
|
|
4713
|
-
skipPrompts: e.yes ?? !1
|
|
4714
|
-
|
|
4744
|
+
skipPrompts: e.yes ?? !1,
|
|
4745
|
+
dbReady: n
|
|
4746
|
+
}), Eo(), s.outro(R.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4715
4747
|
} finally {
|
|
4716
|
-
await Promise.all(E.map((e) =>
|
|
4748
|
+
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
4717
4749
|
recursive: !0,
|
|
4718
4750
|
force: !0
|
|
4719
4751
|
})));
|
|
4720
4752
|
}
|
|
4721
4753
|
}
|
|
4722
|
-
async function
|
|
4754
|
+
async function Ho(e) {
|
|
4723
4755
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4724
4756
|
if (i.packs && i.packs.length > 0) {
|
|
4725
|
-
let e = i.packs.map(
|
|
4726
|
-
return n.length > 0 && (
|
|
4757
|
+
let e = i.packs.map(Wo), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4758
|
+
return n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4727
4759
|
}
|
|
4728
|
-
let
|
|
4729
|
-
|
|
4760
|
+
let o = t.filter((e) => n.has(e.name));
|
|
4761
|
+
o.length > 0 && s.note(o.map((e) => ` ${R.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4730
4762
|
let c = t.filter((e) => !n.has(e.name));
|
|
4731
|
-
if (c.length === 0) return
|
|
4732
|
-
let l =
|
|
4733
|
-
|
|
4734
|
-
let u =
|
|
4763
|
+
if (c.length === 0) return s.outro(R.muted("Every available pack is already installed.")), [];
|
|
4764
|
+
let l = ce();
|
|
4765
|
+
s.note(c.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4766
|
+
let u = Gi(c, { adminAvailable: a }), d = [];
|
|
4735
4767
|
for (let e of u) {
|
|
4736
4768
|
let t = e.packs.map((e) => {
|
|
4737
4769
|
let t = r(e.name);
|
|
4738
4770
|
return {
|
|
4739
4771
|
value: e.name,
|
|
4740
|
-
label: `${e.displayName} ${
|
|
4772
|
+
label: `${e.displayName} ${xo(t, e.price)}`,
|
|
4741
4773
|
hint: e.description
|
|
4742
4774
|
};
|
|
4743
4775
|
});
|
|
4744
4776
|
if (e.mode === "single") {
|
|
4745
|
-
let n = await
|
|
4777
|
+
let n = await s.select({
|
|
4746
4778
|
message: `Choose a ${e.label.toLowerCase()}`,
|
|
4747
4779
|
options: t,
|
|
4748
4780
|
initialValue: e.preselect ?? e.packs[0].name
|
|
4749
4781
|
});
|
|
4750
|
-
if (
|
|
4782
|
+
if (s.isCancel(n)) return null;
|
|
4751
4783
|
d.push({
|
|
4752
4784
|
name: n,
|
|
4753
4785
|
slot: e.slot
|
|
4754
4786
|
});
|
|
4755
4787
|
continue;
|
|
4756
4788
|
}
|
|
4757
|
-
let n = await
|
|
4789
|
+
let n = await Ea({
|
|
4758
4790
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4759
4791
|
options: t,
|
|
4760
4792
|
required: !1
|
|
4761
4793
|
});
|
|
4762
|
-
if (
|
|
4794
|
+
if (m(n)) return null;
|
|
4763
4795
|
for (let e of n) d.push({ name: e });
|
|
4764
4796
|
}
|
|
4765
4797
|
return d;
|
|
4766
4798
|
}
|
|
4767
|
-
var
|
|
4768
|
-
function
|
|
4769
|
-
let t = e.match(
|
|
4799
|
+
var Uo = /@(frontend|admin)$/;
|
|
4800
|
+
function Wo(e) {
|
|
4801
|
+
let t = e.match(Uo);
|
|
4770
4802
|
return t ? {
|
|
4771
4803
|
name: e.slice(0, -t[0].length),
|
|
4772
4804
|
slot: t[1]
|
|
4773
4805
|
} : { name: e };
|
|
4774
4806
|
}
|
|
4775
|
-
function
|
|
4807
|
+
function Go(e) {
|
|
4776
4808
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4777
4809
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4778
4810
|
return n;
|
|
4779
4811
|
}
|
|
4780
|
-
function
|
|
4812
|
+
function Ko(e) {
|
|
4781
4813
|
let t = /* @__PURE__ */ new Map();
|
|
4782
4814
|
for (let n of e) {
|
|
4783
4815
|
if (!n.slot) continue;
|
|
@@ -4788,41 +4820,258 @@ function Mo(e) {
|
|
|
4788
4820
|
}
|
|
4789
4821
|
//#endregion
|
|
4790
4822
|
//#region src/commands/login.ts
|
|
4791
|
-
async function
|
|
4792
|
-
|
|
4823
|
+
async function qo() {
|
|
4824
|
+
wa(), s.intro(R.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
4793
4825
|
let e;
|
|
4794
4826
|
try {
|
|
4795
|
-
e = await
|
|
4796
|
-
|
|
4827
|
+
e = await tr({ onUrl: (e) => {
|
|
4828
|
+
s.log.info(`If your browser didn't open, visit:\n ${R.path(e)}`);
|
|
4797
4829
|
} });
|
|
4798
4830
|
} catch (e) {
|
|
4799
|
-
|
|
4831
|
+
s.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
|
|
4800
4832
|
}
|
|
4801
|
-
|
|
4833
|
+
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
4834
|
}
|
|
4803
4835
|
//#endregion
|
|
4804
4836
|
//#region src/commands/logout.ts
|
|
4805
|
-
async function
|
|
4806
|
-
|
|
4807
|
-
let e =
|
|
4837
|
+
async function Jo() {
|
|
4838
|
+
wa(), s.intro(R.brandBold("Log out of Hype Stack"));
|
|
4839
|
+
let e = I(), t = await Kn(e);
|
|
4808
4840
|
if (!t) {
|
|
4809
|
-
|
|
4841
|
+
s.outro(R.muted("You're not logged in."));
|
|
4842
|
+
return;
|
|
4843
|
+
}
|
|
4844
|
+
await Rn(t.token).catch(() => null), await Jn(e), s.outro(R.brand("Logged out."));
|
|
4845
|
+
}
|
|
4846
|
+
//#endregion
|
|
4847
|
+
//#region src/core/onboard-catalog.ts
|
|
4848
|
+
var $ = {
|
|
4849
|
+
Config: "config",
|
|
4850
|
+
Databases: "databases",
|
|
4851
|
+
Workos: "workos",
|
|
4852
|
+
BetterAuth: "betterauth",
|
|
4853
|
+
Stripe: "stripe",
|
|
4854
|
+
Polar: "polar",
|
|
4855
|
+
Resend: "resend",
|
|
4856
|
+
IpLocate: "iplocate",
|
|
4857
|
+
Sentry: "sentry"
|
|
4858
|
+
}, Yo = new Set(Object.values($));
|
|
4859
|
+
function Xo(e) {
|
|
4860
|
+
return e.toLowerCase().replace(/[^a-z0-9]+/g, "").trim();
|
|
4861
|
+
}
|
|
4862
|
+
function Zo(e) {
|
|
4863
|
+
let t = Xo(e);
|
|
4864
|
+
return Yo.has(t) ? t : void 0;
|
|
4865
|
+
}
|
|
4866
|
+
var Qo = {
|
|
4867
|
+
[$.Config]: { hint: "App URLs. Defaults work for local dev." },
|
|
4868
|
+
[$.Databases]: { hint: "Credentials for the local Docker Postgres and Valkey containers." },
|
|
4869
|
+
[$.Workos]: {
|
|
4870
|
+
link: "https://dashboard.workos.com/api-keys",
|
|
4871
|
+
hint: "Copy your API Key and Client ID from the WorkOS dashboard."
|
|
4872
|
+
},
|
|
4873
|
+
[$.BetterAuth]: {
|
|
4874
|
+
link: "https://www.better-auth.com/docs/installation#set-environment-variables",
|
|
4875
|
+
hint: "Generate a long random secret, set the app URL, add Google OAuth creds if you use Google."
|
|
4876
|
+
},
|
|
4877
|
+
[$.Stripe]: {
|
|
4878
|
+
link: "https://dashboard.stripe.com/apikeys",
|
|
4879
|
+
hint: "Copy your secret and publishable keys from the Stripe dashboard.",
|
|
4880
|
+
serviceChecklist: [
|
|
4881
|
+
"Recurring prices for Pro and Premier power checkout (set STRIPE_PRICE_PRO and STRIPE_PRICE_PREMIER).",
|
|
4882
|
+
"A webhook at /checkout/webhook keeps subscriptions in sync (subscription events plus invoice.payment_succeeded).",
|
|
4883
|
+
"Enable the Stripe billing portal so Manage Billing and invoices work.",
|
|
4884
|
+
"Enable 'Limit customers to one subscription' to prevent double-checkout races.",
|
|
4885
|
+
"Optional: disable Cash App Pay if you see a high checkout cancel rate."
|
|
4886
|
+
]
|
|
4887
|
+
},
|
|
4888
|
+
[$.Polar]: {
|
|
4889
|
+
link: "https://polar.sh",
|
|
4890
|
+
hint: "From your Polar org: access token, webhook secret, organization id, and the checkout product id."
|
|
4891
|
+
},
|
|
4892
|
+
[$.Resend]: {
|
|
4893
|
+
link: "https://resend.com/api-keys",
|
|
4894
|
+
hint: "Create an API key in Resend."
|
|
4895
|
+
},
|
|
4896
|
+
[$.IpLocate]: {
|
|
4897
|
+
link: "https://iplocate.io",
|
|
4898
|
+
hint: "Grab your API key from IP Locate."
|
|
4899
|
+
},
|
|
4900
|
+
[$.Sentry]: {
|
|
4901
|
+
link: "https://sentry.io",
|
|
4902
|
+
hint: "Your project DSN. Leave blank to skip Sentry for now."
|
|
4903
|
+
}
|
|
4904
|
+
}, $o = { hint: "Add your value, or press Enter to leave it blank." };
|
|
4905
|
+
function es(e) {
|
|
4906
|
+
let t = Zo(e);
|
|
4907
|
+
return t ? Qo[t] : $o;
|
|
4908
|
+
}
|
|
4909
|
+
var ts = {
|
|
4910
|
+
"starter-saas-workos": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4911
|
+
"starter-saas-betterauth": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4912
|
+
"pack-notifications": ["Notifications push over the `appChannel` socket channel; register it in your server startup to go live."],
|
|
4913
|
+
"pack-collaboration": ["Team and TeamMember are available as CASL subjects; project member and team management reuse the existing `Project` subject."]
|
|
4914
|
+
};
|
|
4915
|
+
function ns(e) {
|
|
4916
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4917
|
+
for (let r of e) {
|
|
4918
|
+
let e = ts[r];
|
|
4919
|
+
if (e) for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
4920
|
+
}
|
|
4921
|
+
return n;
|
|
4922
|
+
}
|
|
4923
|
+
//#endregion
|
|
4924
|
+
//#region src/core/onboard-env.ts
|
|
4925
|
+
function rs(e) {
|
|
4926
|
+
let t = [], n = "";
|
|
4927
|
+
for (let r of e.split(/\r?\n/)) {
|
|
4928
|
+
let e = r.trim();
|
|
4929
|
+
if (e === "") continue;
|
|
4930
|
+
if (e.startsWith("#")) {
|
|
4931
|
+
let t = e.replace(/^#+\s*/, "").trim();
|
|
4932
|
+
if (t === "" || /^[-=_]+$/.test(t) || t.includes("=")) continue;
|
|
4933
|
+
n = t;
|
|
4934
|
+
continue;
|
|
4935
|
+
}
|
|
4936
|
+
let i = e.indexOf("=");
|
|
4937
|
+
if (i === -1) continue;
|
|
4938
|
+
let a = e.slice(0, i).trim(), o = e.slice(i + 1).trim();
|
|
4939
|
+
if (!a) continue;
|
|
4940
|
+
let s = t.find((e) => e.section === n);
|
|
4941
|
+
s || (s = {
|
|
4942
|
+
section: n,
|
|
4943
|
+
vars: []
|
|
4944
|
+
}, t.push(s)), s.vars.push({
|
|
4945
|
+
key: a,
|
|
4946
|
+
value: o
|
|
4947
|
+
});
|
|
4948
|
+
}
|
|
4949
|
+
return t;
|
|
4950
|
+
}
|
|
4951
|
+
var is = [
|
|
4952
|
+
"replace-with",
|
|
4953
|
+
"examplepublickey",
|
|
4954
|
+
"change-me",
|
|
4955
|
+
"your-key-here"
|
|
4956
|
+
];
|
|
4957
|
+
function as(e) {
|
|
4958
|
+
let t = e.trim();
|
|
4959
|
+
if (t === "") return !0;
|
|
4960
|
+
let n = t.toLowerCase();
|
|
4961
|
+
return is.some((e) => n.includes(e));
|
|
4962
|
+
}
|
|
4963
|
+
function os(e, t, n) {
|
|
4964
|
+
let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
|
|
4965
|
+
if (i) return e;
|
|
4966
|
+
let r = e.trim();
|
|
4967
|
+
if (r.startsWith(`${t}=`) || r === t) return i = !0, `${t}=${n}`;
|
|
4968
|
+
let a = r.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
|
|
4969
|
+
return a && a[1] === t ? (i = !0, `${t}=${n}`) : e;
|
|
4970
|
+
});
|
|
4971
|
+
return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
|
|
4972
|
+
}
|
|
4973
|
+
async function ss(e) {
|
|
4974
|
+
return await J(e) ? y.readFile(e, "utf-8") : "";
|
|
4975
|
+
}
|
|
4976
|
+
async function cs(e) {
|
|
4977
|
+
let t = T.join(T.dirname(e), ".env");
|
|
4978
|
+
return await J(t) || await y.copyFile(e, t), t;
|
|
4979
|
+
}
|
|
4980
|
+
async function ls(e, t, n) {
|
|
4981
|
+
let r = os(await ss(e), t, n);
|
|
4982
|
+
await y.writeFile(e, r, "utf-8");
|
|
4983
|
+
}
|
|
4984
|
+
//#endregion
|
|
4985
|
+
//#region src/commands/onboard.ts
|
|
4986
|
+
async function us(e = {}) {
|
|
4987
|
+
let t = e.cwd ?? process.cwd();
|
|
4988
|
+
Ca(), s.intro(R.brandBold("Onboard your stack"));
|
|
4989
|
+
let n;
|
|
4990
|
+
try {
|
|
4991
|
+
n = await hr(t);
|
|
4992
|
+
} catch {
|
|
4993
|
+
n = null;
|
|
4994
|
+
}
|
|
4995
|
+
n || (s.cancel(`${R.path("stack.json")} not found. Run ${R.command("npx @hype-stack/cli init")} first.`), process.exit(1));
|
|
4996
|
+
let r = await Xa(t);
|
|
4997
|
+
r.length === 0 && s.log.warn(R.muted("No .env.example files found; skipping env setup."));
|
|
4998
|
+
for (let n of r) await ds(n, t, e.yes ?? !1);
|
|
4999
|
+
let i = ns(n.installedPacks ?? []);
|
|
5000
|
+
i.length > 0 && s.note(i.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await ms(t, e.yes ?? !1), s.outro(R.brand(`All set. Run ${R.command("pnpm dev")} to start your app.`));
|
|
5001
|
+
}
|
|
5002
|
+
async function ds(e, t, n) {
|
|
5003
|
+
let r = T.relative(t, e) || e, i = await cs(e), a = await ss(i), o = rs(await y.readFile(e, "utf-8")), c = R.path(r);
|
|
5004
|
+
s.log.step(`Env: ${c}`);
|
|
5005
|
+
for (let e of o) {
|
|
5006
|
+
let t = e.vars.filter((e) => as(e.value));
|
|
5007
|
+
if (t.length === 0) continue;
|
|
5008
|
+
let r = es(e.section), o = e.section ? R.bold(e.section) : R.bold("Variables");
|
|
5009
|
+
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));
|
|
5010
|
+
for (let e of t) {
|
|
5011
|
+
if (n) {
|
|
5012
|
+
s.log.info(`${R.label(e.key)} ${R.muted("skipped (non-interactive)")}`);
|
|
5013
|
+
continue;
|
|
5014
|
+
}
|
|
5015
|
+
let t = fs(a, e.key), o = await s.text({
|
|
5016
|
+
message: `${R.label(e.key)}`,
|
|
5017
|
+
placeholder: t || r.hint
|
|
5018
|
+
});
|
|
5019
|
+
s.isCancel(o) && X();
|
|
5020
|
+
let c = (o ?? "").trim();
|
|
5021
|
+
if (c === "") {
|
|
5022
|
+
s.log.warn(R.muted(`${e.key} left blank.`));
|
|
5023
|
+
continue;
|
|
5024
|
+
}
|
|
5025
|
+
await ls(i, e.key, c), s.log.success(`${e.key} saved`);
|
|
5026
|
+
}
|
|
5027
|
+
}
|
|
5028
|
+
}
|
|
5029
|
+
function fs(e, t) {
|
|
5030
|
+
for (let n of e.split(/\r?\n/)) {
|
|
5031
|
+
let e = n.match(RegExp(`^${ps(t)}\\s*=\\s*(.*)$`));
|
|
5032
|
+
if (e) return e[1].trim();
|
|
5033
|
+
}
|
|
5034
|
+
return "";
|
|
5035
|
+
}
|
|
5036
|
+
function ps(e) {
|
|
5037
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5038
|
+
}
|
|
5039
|
+
async function ms(e, t) {
|
|
5040
|
+
if (!await Ji() && !await Xi(e, t, !1)) {
|
|
5041
|
+
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")}.`));
|
|
4810
5042
|
return;
|
|
4811
5043
|
}
|
|
4812
|
-
|
|
5044
|
+
let n = s.spinner();
|
|
5045
|
+
if (n.start("Waiting for Postgres to be ready..."), !await Qi(e)) {
|
|
5046
|
+
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")}`));
|
|
5047
|
+
return;
|
|
5048
|
+
}
|
|
5049
|
+
if (n.stop(R.success("Postgres is ready")), await ea(e)) {
|
|
5050
|
+
s.log.info(R.muted("Migrations already applied, skipping."));
|
|
5051
|
+
return;
|
|
5052
|
+
}
|
|
5053
|
+
let r = t ? !0 : await s.confirm({
|
|
5054
|
+
message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
|
|
5055
|
+
initialValue: !0
|
|
5056
|
+
});
|
|
5057
|
+
if (s.isCancel(r) && X(), !r) {
|
|
5058
|
+
s.log.info(R.muted("Skipping database migrations."));
|
|
5059
|
+
return;
|
|
5060
|
+
}
|
|
5061
|
+
await ta(e);
|
|
4813
5062
|
}
|
|
4814
5063
|
//#endregion
|
|
4815
5064
|
//#region src/core/templates.ts
|
|
4816
|
-
var
|
|
5065
|
+
var hs = K.createRequest()({
|
|
4817
5066
|
endpoint: "/templates/list",
|
|
4818
5067
|
method: "GET"
|
|
4819
5068
|
});
|
|
4820
|
-
async function
|
|
4821
|
-
let { data: e, error: t } = await
|
|
5069
|
+
async function gs() {
|
|
5070
|
+
let { data: e, error: t } = await hs.send();
|
|
4822
5071
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
4823
5072
|
return e.templates;
|
|
4824
5073
|
}
|
|
4825
|
-
async function
|
|
5074
|
+
async function _s(e) {
|
|
4826
5075
|
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
4827
5076
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
4828
5077
|
method: "GET"
|
|
@@ -4831,13 +5080,13 @@ async function Lo(e) {
|
|
|
4831
5080
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
4832
5081
|
return t;
|
|
4833
5082
|
}
|
|
4834
|
-
async function
|
|
5083
|
+
async function vs(e, t = {}) {
|
|
4835
5084
|
let n = K.createRequest()({
|
|
4836
5085
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
4837
5086
|
method: "POST"
|
|
4838
5087
|
}), r = {
|
|
4839
|
-
"X-Device-Id":
|
|
4840
|
-
"X-Client-Info":
|
|
5088
|
+
"X-Device-Id": Xn(),
|
|
5089
|
+
"X-Client-Info": Zn()
|
|
4841
5090
|
};
|
|
4842
5091
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
4843
5092
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -4848,10 +5097,10 @@ async function Ro(e, t = {}) {
|
|
|
4848
5097
|
packs: i.packs ?? [],
|
|
4849
5098
|
expiresAt: i.expiresAt ?? null
|
|
4850
5099
|
};
|
|
4851
|
-
let s = await
|
|
5100
|
+
let s = await y.mkdtemp(T.join(w.tmpdir(), `hype-stack-template-${e}-`));
|
|
4852
5101
|
return await Promise.all(i.files.map(async (e) => {
|
|
4853
|
-
let t =
|
|
4854
|
-
await
|
|
5102
|
+
let t = T.join(s, ...e.path.split("/"));
|
|
5103
|
+
await y.mkdir(T.dirname(t), { recursive: !0 }), await y.writeFile(t, Buffer.from(e.content, "base64"));
|
|
4855
5104
|
})), {
|
|
4856
5105
|
status: "ok",
|
|
4857
5106
|
templateDir: s
|
|
@@ -4859,172 +5108,187 @@ async function Ro(e, t = {}) {
|
|
|
4859
5108
|
}
|
|
4860
5109
|
//#endregion
|
|
4861
5110
|
//#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;
|
|
5111
|
+
async function ys(t = {}) {
|
|
5112
|
+
let n = t.cwd ?? process.cwd();
|
|
5113
|
+
Ca();
|
|
5114
|
+
let r = s.spinner();
|
|
5115
|
+
r.start("Loading packs...");
|
|
5116
|
+
let o;
|
|
4877
5117
|
try {
|
|
4878
|
-
|
|
5118
|
+
o = await Dr();
|
|
4879
5119
|
} catch (e) {
|
|
4880
|
-
|
|
5120
|
+
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
5121
|
}
|
|
4882
|
-
|
|
4883
|
-
let
|
|
4884
|
-
u.start("Loading templates...");
|
|
4885
|
-
let _;
|
|
5122
|
+
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
5123
|
+
let c;
|
|
4886
5124
|
try {
|
|
4887
|
-
|
|
5125
|
+
c = await gs();
|
|
4888
5126
|
} catch (e) {
|
|
4889
|
-
|
|
4890
|
-
}
|
|
4891
|
-
let
|
|
4892
|
-
if (!
|
|
4893
|
-
|
|
4894
|
-
let
|
|
4895
|
-
|
|
4896
|
-
let n = await
|
|
5127
|
+
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);
|
|
5128
|
+
}
|
|
5129
|
+
let l = t.templateId;
|
|
5130
|
+
if (!l) {
|
|
5131
|
+
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");
|
|
5132
|
+
let e = ce();
|
|
5133
|
+
s.note(c.map((t) => ` ${z.arrow} ${R.highlight(t.name)} ${_e(`${e}/templates/${t.id}`)}`).join("\n"), "Browse templates");
|
|
5134
|
+
let n = await s.select({
|
|
4897
5135
|
message: "Choose a template",
|
|
4898
|
-
options:
|
|
5136
|
+
options: c.map((e) => ({
|
|
4899
5137
|
value: e.id,
|
|
4900
5138
|
label: e.name,
|
|
4901
5139
|
hint: e.description
|
|
4902
5140
|
}))
|
|
4903
5141
|
});
|
|
4904
|
-
|
|
4905
|
-
}
|
|
4906
|
-
let
|
|
4907
|
-
|
|
4908
|
-
let
|
|
4909
|
-
packs: d,
|
|
4910
|
-
templatePacks: C,
|
|
4911
|
-
installedSet: p,
|
|
4912
|
-
options: e
|
|
4913
|
-
}), E = [...C, ...T.filter((e) => !C.includes(e))], D = E.filter((e) => !m.has(e));
|
|
4914
|
-
D.length > 0 && (o.cancel(`Unknown pack${D.length === 1 ? "" : "s"}: ${D.join(", ")}`), process.exit(1));
|
|
4915
|
-
let O = aa(d, S), ee = Zi(O), k;
|
|
5142
|
+
s.isCancel(n) && (s.cancel("Cancelled."), process.exit(0)), l = n;
|
|
5143
|
+
}
|
|
5144
|
+
let u = c.find((e) => e.id === l);
|
|
5145
|
+
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}`);
|
|
5146
|
+
let d;
|
|
4916
5147
|
try {
|
|
4917
|
-
|
|
5148
|
+
d = await _s(u.id);
|
|
4918
5149
|
} catch (e) {
|
|
4919
|
-
|
|
5150
|
+
s.cancel(Q(e)), process.exit(1);
|
|
4920
5151
|
}
|
|
4921
|
-
|
|
4922
|
-
|
|
5152
|
+
let f = await Bo(n, {}, {
|
|
5153
|
+
defaultTheme: d.theme,
|
|
5154
|
+
defaultMode: d.defaultMode
|
|
5155
|
+
}), p = f?.projectRoot ?? null, m = f?.scaffolded ?? !1, h;
|
|
5156
|
+
try {
|
|
5157
|
+
h = await hr(p ?? n);
|
|
5158
|
+
} catch (e) {
|
|
5159
|
+
s.cancel(`Could not parse ${R.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
5160
|
+
}
|
|
5161
|
+
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));
|
|
5162
|
+
let g = p ?? n;
|
|
5163
|
+
s.intro(R.brandBold("Install a template"));
|
|
5164
|
+
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await Kn(I()))?.token ?? null, C = await bs(u, t.variants, t.yes ?? !1), w = ua(u.slots, C), E = da(u.slots, u.packs, w), D = await xs({
|
|
5165
|
+
packs: o,
|
|
5166
|
+
templatePacks: E,
|
|
5167
|
+
installedSet: v,
|
|
5168
|
+
options: t
|
|
5169
|
+
}), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
|
|
5170
|
+
k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
|
|
5171
|
+
let ee = ma(o, w), A = oa(ee), j;
|
|
5172
|
+
try {
|
|
5173
|
+
j = ca(O, A, _);
|
|
5174
|
+
} catch (e) {
|
|
5175
|
+
s.cancel(Q(e)), process.exit(1);
|
|
5176
|
+
}
|
|
5177
|
+
if (j.order.length === 0) {
|
|
5178
|
+
s.outro(R.muted("Every pack in this template is already installed."));
|
|
4923
5179
|
return;
|
|
4924
5180
|
}
|
|
4925
|
-
let te = await
|
|
4926
|
-
token:
|
|
4927
|
-
key:
|
|
5181
|
+
let te = await bo(ee, v, {
|
|
5182
|
+
token: S,
|
|
5183
|
+
key: x
|
|
4928
5184
|
}), ne = (e) => {
|
|
4929
|
-
let t =
|
|
5185
|
+
let t = b.get(e);
|
|
4930
5186
|
return !t || t.tier === "free" ? "free" : te[e]?.owned ? "owned" : "locked";
|
|
4931
|
-
},
|
|
4932
|
-
order:
|
|
4933
|
-
graph:
|
|
4934
|
-
isLocked:
|
|
4935
|
-
installed:
|
|
5187
|
+
}, M = (e) => !v.has(e) && ne(e) === "locked", N = la({
|
|
5188
|
+
order: j.order,
|
|
5189
|
+
graph: A,
|
|
5190
|
+
isLocked: M,
|
|
5191
|
+
installed: _
|
|
4936
5192
|
});
|
|
4937
|
-
if (
|
|
4938
|
-
let e = await
|
|
4939
|
-
e && (
|
|
4940
|
-
token:
|
|
4941
|
-
key:
|
|
4942
|
-
}),
|
|
4943
|
-
order:
|
|
4944
|
-
graph:
|
|
4945
|
-
isLocked:
|
|
4946
|
-
installed:
|
|
5193
|
+
if (N.blocked.length > 0 && !S && !x) {
|
|
5194
|
+
let e = await nr();
|
|
5195
|
+
e && (S = e, te = await bo(ee, v, {
|
|
5196
|
+
token: S,
|
|
5197
|
+
key: x
|
|
5198
|
+
}), N = la({
|
|
5199
|
+
order: j.order,
|
|
5200
|
+
graph: A,
|
|
5201
|
+
isLocked: M,
|
|
5202
|
+
installed: _
|
|
4947
5203
|
}));
|
|
4948
5204
|
}
|
|
4949
|
-
if (
|
|
4950
|
-
|
|
5205
|
+
if (N.blocked.length > 0 && await So(N.blocked, M, b), N.installable.length === 0) {
|
|
5206
|
+
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
4951
5207
|
return;
|
|
4952
5208
|
}
|
|
4953
|
-
if (
|
|
4954
|
-
let e = await
|
|
4955
|
-
(
|
|
5209
|
+
if (Co(N.installable, b), !t.yes) {
|
|
5210
|
+
let e = await s.confirm({ message: `Install template ${R.brandBold(u.name)} (${N.installable.length} pack${N.installable.length === 1 ? "" : "s"})?` });
|
|
5211
|
+
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
4956
5212
|
}
|
|
4957
|
-
|
|
4958
|
-
let
|
|
5213
|
+
r.start("Downloading packs...");
|
|
5214
|
+
let P;
|
|
4959
5215
|
try {
|
|
4960
|
-
|
|
4961
|
-
token:
|
|
4962
|
-
key:
|
|
5216
|
+
P = await wo(N.installable, {
|
|
5217
|
+
token: S,
|
|
5218
|
+
key: x
|
|
4963
5219
|
});
|
|
4964
5220
|
} catch (e) {
|
|
4965
|
-
|
|
4966
|
-
}
|
|
4967
|
-
|
|
4968
|
-
let
|
|
4969
|
-
prepared:
|
|
4970
|
-
config:
|
|
4971
|
-
cwd:
|
|
4972
|
-
force:
|
|
4973
|
-
yes:
|
|
4974
|
-
}),
|
|
5221
|
+
r.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
|
|
5222
|
+
}
|
|
5223
|
+
r.stop(`Downloaded ${P.length} pack${P.length === 1 ? "" : "s"}`);
|
|
5224
|
+
let re = await Oo({
|
|
5225
|
+
prepared: P,
|
|
5226
|
+
config: h,
|
|
5227
|
+
cwd: g,
|
|
5228
|
+
force: t.force ?? !1,
|
|
5229
|
+
yes: t.yes ?? !1
|
|
5230
|
+
}), F = null;
|
|
4975
5231
|
try {
|
|
4976
|
-
|
|
4977
|
-
let
|
|
4978
|
-
packs:
|
|
4979
|
-
config:
|
|
4980
|
-
projectRoot:
|
|
4981
|
-
force:
|
|
4982
|
-
overwrite:
|
|
5232
|
+
r.start("Installing pack files...");
|
|
5233
|
+
let n = await Ri({
|
|
5234
|
+
packs: P,
|
|
5235
|
+
config: h,
|
|
5236
|
+
projectRoot: g,
|
|
5237
|
+
force: t.force ?? !1,
|
|
5238
|
+
overwrite: re
|
|
4983
5239
|
});
|
|
4984
|
-
if (
|
|
4985
|
-
|
|
4986
|
-
for (let e of
|
|
4987
|
-
|
|
5240
|
+
if (n.aborted) {
|
|
5241
|
+
r.stop("Installation aborted");
|
|
5242
|
+
for (let e of n.errors) s.log.error(e);
|
|
5243
|
+
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4988
5244
|
}
|
|
4989
|
-
|
|
4990
|
-
for (let e of
|
|
4991
|
-
|
|
4992
|
-
let
|
|
4993
|
-
token:
|
|
4994
|
-
licenseKey:
|
|
5245
|
+
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)`), Do(n.skipped));
|
|
5246
|
+
for (let e of n.errors) s.log.error(e);
|
|
5247
|
+
r.start("Applying template overrides...");
|
|
5248
|
+
let o = await vs(u.id, {
|
|
5249
|
+
token: S,
|
|
5250
|
+
licenseKey: x
|
|
5251
|
+
});
|
|
5252
|
+
o.status === "denied" && (r.stop("Template download denied"), s.cancel(`Access to template "${u.id}" was denied (${o.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)), F = o.templateDir;
|
|
5253
|
+
let c = await Bi({
|
|
5254
|
+
manifest: d,
|
|
5255
|
+
config: h,
|
|
5256
|
+
projectRoot: g,
|
|
5257
|
+
templateDir: F
|
|
4995
5258
|
});
|
|
4996
|
-
|
|
4997
|
-
let
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5259
|
+
r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
|
|
5260
|
+
for (let e of c.errors) s.log.error(e);
|
|
5261
|
+
if (!m) {
|
|
5262
|
+
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5263
|
+
a(n) && (await za(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`)));
|
|
5264
|
+
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5265
|
+
await Na(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`));
|
|
5266
|
+
}
|
|
5267
|
+
await Ss({
|
|
5268
|
+
prepared: P,
|
|
5269
|
+
templateNpm: d.dependencies_npm,
|
|
5270
|
+
paths: h.paths,
|
|
5271
|
+
cwd: g,
|
|
5272
|
+
spinner: r
|
|
5002
5273
|
});
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
cwd: l,
|
|
5011
|
-
spinner: u
|
|
5012
|
-
}), s && await Xi(l, e.yes ?? !1), await ur({
|
|
5013
|
-
projectRoot: l,
|
|
5014
|
-
paths: c.paths,
|
|
5015
|
-
skipPrompts: e.yes ?? !1
|
|
5016
|
-
}), wo(j), n.postInstall && n.postInstall.length > 0 && o.note(n.postInstall.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Template Next Steps"), o.outro(L.brand(`Installed template ${b.name}.`));
|
|
5274
|
+
let l;
|
|
5275
|
+
m && (l = await aa(g, t.yes ?? !1)), await pr({
|
|
5276
|
+
projectRoot: g,
|
|
5277
|
+
paths: h.paths,
|
|
5278
|
+
skipPrompts: t.yes ?? !1,
|
|
5279
|
+
dbReady: l
|
|
5280
|
+
}), Eo(), s.outro(R.brand(`Installed template ${u.name}.`));
|
|
5017
5281
|
} finally {
|
|
5018
|
-
await Promise.all(
|
|
5282
|
+
await Promise.all(P.map((e) => y.rm(e.packDir, {
|
|
5019
5283
|
recursive: !0,
|
|
5020
5284
|
force: !0
|
|
5021
|
-
}))),
|
|
5285
|
+
}))), F && await y.rm(F, {
|
|
5022
5286
|
recursive: !0,
|
|
5023
5287
|
force: !0
|
|
5024
5288
|
});
|
|
5025
5289
|
}
|
|
5026
5290
|
}
|
|
5027
|
-
async function
|
|
5291
|
+
async function bs(e, t, n) {
|
|
5028
5292
|
let r = {};
|
|
5029
5293
|
for (let i of e.slots) {
|
|
5030
5294
|
if (t?.[i.family]) {
|
|
@@ -5039,56 +5303,56 @@ async function Bo(e, t, n) {
|
|
|
5039
5303
|
value: e,
|
|
5040
5304
|
label: e,
|
|
5041
5305
|
hint: e === i.default ? "default" : void 0
|
|
5042
|
-
})), a = await
|
|
5306
|
+
})), a = await s.select({
|
|
5043
5307
|
message: `Choose a ${i.family}`,
|
|
5044
5308
|
options: e,
|
|
5045
5309
|
initialValue: i.default
|
|
5046
5310
|
});
|
|
5047
|
-
|
|
5311
|
+
s.isCancel(a) && (s.cancel("Cancelled."), process.exit(0)), r[i.family] = a;
|
|
5048
5312
|
}
|
|
5049
5313
|
return r;
|
|
5050
5314
|
}
|
|
5051
|
-
async function
|
|
5315
|
+
async function xs(e) {
|
|
5052
5316
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5053
5317
|
if (i.packs && i.packs.length > 0) {
|
|
5054
5318
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
5055
|
-
return e.length > 0 && (
|
|
5319
|
+
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
5320
|
}
|
|
5057
5321
|
if (i.yes) return [];
|
|
5058
|
-
let
|
|
5059
|
-
if (
|
|
5060
|
-
let c =
|
|
5061
|
-
|
|
5062
|
-
let l = await
|
|
5322
|
+
let o = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
|
|
5323
|
+
if (o.length === 0) return [];
|
|
5324
|
+
let c = ce();
|
|
5325
|
+
s.note(o.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5326
|
+
let l = await Ea({
|
|
5063
5327
|
message: "Add extra packs on top of the template (optional)",
|
|
5064
|
-
options:
|
|
5328
|
+
options: o.map((e) => ({
|
|
5065
5329
|
value: e.name,
|
|
5066
5330
|
label: e.displayName,
|
|
5067
5331
|
hint: e.description
|
|
5068
5332
|
})),
|
|
5069
5333
|
required: !1
|
|
5070
5334
|
});
|
|
5071
|
-
return
|
|
5335
|
+
return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
|
|
5072
5336
|
}
|
|
5073
|
-
async function
|
|
5074
|
-
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e,
|
|
5337
|
+
async function Ss(e) {
|
|
5338
|
+
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o = vo(t.map((e) => e.manifest.dependencies_npm)), c = _o(n ? vo([o, n]) : o, r);
|
|
5075
5339
|
if (c.errors.length > 0) {
|
|
5076
|
-
for (let e of c.errors)
|
|
5340
|
+
for (let e of c.errors) s.log.error(e);
|
|
5077
5341
|
return;
|
|
5078
5342
|
}
|
|
5079
5343
|
if (c.operations.length === 0) return;
|
|
5080
5344
|
a.start("Installing npm dependencies...");
|
|
5081
|
-
let l = await
|
|
5082
|
-
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors)
|
|
5345
|
+
let l = await yo(c.operations, i);
|
|
5346
|
+
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
5347
|
}
|
|
5084
5348
|
//#endregion
|
|
5085
5349
|
//#region src/cli.ts
|
|
5086
|
-
function
|
|
5350
|
+
function Cs(e) {
|
|
5087
5351
|
if (!e) return;
|
|
5088
5352
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5089
5353
|
return t.length > 0 ? t : void 0;
|
|
5090
5354
|
}
|
|
5091
|
-
function
|
|
5355
|
+
function ws(e) {
|
|
5092
5356
|
if (!e) return;
|
|
5093
5357
|
let t = {};
|
|
5094
5358
|
for (let n of e.split(",")) {
|
|
@@ -5097,10 +5361,10 @@ function Wo(e) {
|
|
|
5097
5361
|
}
|
|
5098
5362
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5099
5363
|
}
|
|
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
|
|
5364
|
+
function Ts() {
|
|
5365
|
+
let e = new o();
|
|
5366
|
+
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) => {
|
|
5367
|
+
await Ro({
|
|
5104
5368
|
name: e.name,
|
|
5105
5369
|
directory: e.directory,
|
|
5106
5370
|
install: e.install,
|
|
@@ -5110,32 +5374,38 @@ function Go() {
|
|
|
5110
5374
|
setup: e.setup
|
|
5111
5375
|
});
|
|
5112
5376
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5113
|
-
await
|
|
5377
|
+
await zo({});
|
|
5378
|
+
}), 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) => {
|
|
5379
|
+
await us({
|
|
5380
|
+
cwd: e.cwd,
|
|
5381
|
+
yes: e.yes,
|
|
5382
|
+
skipMigrations: e.skipMigrations
|
|
5383
|
+
});
|
|
5114
5384
|
}), 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:
|
|
5385
|
+
await Vo({
|
|
5386
|
+
packs: Cs(e.packs),
|
|
5117
5387
|
force: e.force,
|
|
5118
5388
|
yes: e.yes,
|
|
5119
5389
|
licenseKey: e.key ?? e.licenseKey,
|
|
5120
5390
|
cwd: e.cwd
|
|
5121
5391
|
});
|
|
5122
5392
|
}), 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
|
|
5393
|
+
await ys({
|
|
5124
5394
|
templateId: e,
|
|
5125
|
-
variants:
|
|
5126
|
-
packs:
|
|
5395
|
+
variants: ws(t.variants),
|
|
5396
|
+
packs: Cs(t.packs),
|
|
5127
5397
|
force: t.force,
|
|
5128
5398
|
yes: t.yes,
|
|
5129
5399
|
licenseKey: t.key ?? t.licenseKey,
|
|
5130
5400
|
cwd: t.cwd
|
|
5131
5401
|
});
|
|
5132
5402
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5133
|
-
await
|
|
5403
|
+
await qo();
|
|
5134
5404
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5135
|
-
await
|
|
5405
|
+
await Jo();
|
|
5136
5406
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5137
|
-
await
|
|
5407
|
+
await qo();
|
|
5138
5408
|
}), e;
|
|
5139
5409
|
}
|
|
5140
5410
|
//#endregion
|
|
5141
|
-
export {
|
|
5411
|
+
export { Bo as a, Vo as i, Jo as n, zo as o, qo as r, Ro as s, Ts as t };
|