@hype-stack/cli 0.5.2 → 0.5.4
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-cPE06mGY.js → cli-CwXodW3B.js} +1016 -963
- package/dist/commands/compose.d.ts.map +1 -1
- package/dist/commands/template.d.ts.map +1 -1
- package/dist/config/bin.js +1 -1
- package/dist/core/codegen.d.ts +4 -0
- package/dist/core/codegen.d.ts.map +1 -1
- package/dist/core/post-setup.d.ts +10 -0
- package/dist/core/post-setup.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/exec.d.ts +10 -0
- package/dist/utils/exec.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import { Prompt as O } from "@clack/core";
|
|
|
13
13
|
import { styleText as k } from "node:util";
|
|
14
14
|
import { downloadTemplate as ee } from "giget";
|
|
15
15
|
//#region src/constants/constants.ts
|
|
16
|
-
var A = "0.5.
|
|
16
|
+
var A = "0.5.4", j = "gh:BetterTyped/hype-stack", M = "stack.json", te = "/schema/stack.json", N = "https://api.hype-stack.dev", P = "HYPE_STACK_API_URL", F = "https://www.hype-stack.dev", ne = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, I = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -31,109 +31,109 @@ var A = "0.5.2", 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
|
+
], re = I.map((e) => e.value), ie = ".cursor/rules", ae = ".cursor", oe = ".agents";
|
|
35
|
+
function L() {
|
|
36
36
|
let e = process.env.HYPE_STACK_API_URL;
|
|
37
|
-
return e ? (
|
|
37
|
+
return e ? (ce(e), e.replace(/\/+$/, "")) : N;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function se() {
|
|
40
40
|
let e = process.env.HYPE_STACK_WEB_URL;
|
|
41
|
-
return e ? (
|
|
41
|
+
return e ? (ce(e), e.replace(/\/+$/, "")) : F;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function ce(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(`${P} 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(`${P} is not a valid URL: "${e}"`, { cause: t }) : t;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return `${
|
|
51
|
+
function le() {
|
|
52
|
+
return `${L()}${te}`;
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/ui/theme.ts
|
|
56
|
-
var
|
|
57
|
-
orange:
|
|
58
|
-
orangeBright:
|
|
59
|
-
amber:
|
|
60
|
-
deepBlue:
|
|
61
|
-
skyBlue:
|
|
62
|
-
lightBlue:
|
|
63
|
-
},
|
|
64
|
-
brand: (e) =>
|
|
65
|
-
brandBold: (e) => b.bold(
|
|
66
|
-
accent: (e) =>
|
|
67
|
-
accentBold: (e) => b.bold(
|
|
56
|
+
var ue = (e) => `\x1b[38;5;208m${e}\x1b[39m`, de = (e) => `\x1b[38;5;214m${e}\x1b[39m`, R = (e) => `\x1b[38;5;220m${e}\x1b[39m`, fe = (e) => `\x1b[38;5;33m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;39m${e}\x1b[39m`, me = (e) => `\x1b[38;5;81m${e}\x1b[39m`, he = {
|
|
57
|
+
orange: ue,
|
|
58
|
+
orangeBright: de,
|
|
59
|
+
amber: R,
|
|
60
|
+
deepBlue: fe,
|
|
61
|
+
skyBlue: pe,
|
|
62
|
+
lightBlue: me
|
|
63
|
+
}, z = {
|
|
64
|
+
brand: (e) => ue(e),
|
|
65
|
+
brandBold: (e) => b.bold(ue(e)),
|
|
66
|
+
accent: (e) => pe(e),
|
|
67
|
+
accentBold: (e) => b.bold(pe(e)),
|
|
68
68
|
success: (e) => b.green(e),
|
|
69
69
|
error: (e) => b.red(e),
|
|
70
70
|
warning: (e) => b.yellow(e),
|
|
71
71
|
muted: (e) => b.dim(e),
|
|
72
72
|
bold: (e) => b.bold(e),
|
|
73
73
|
highlight: (e) => b.bold(b.white(e)),
|
|
74
|
-
path: (e) => b.underline(
|
|
75
|
-
command: (e) => b.bold(
|
|
74
|
+
path: (e) => b.underline(pe(e)),
|
|
75
|
+
command: (e) => b.bold(R(e)),
|
|
76
76
|
label: (e) => b.dim(b.bold(e))
|
|
77
77
|
};
|
|
78
|
-
function
|
|
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:
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
78
|
+
function ge(e, t = e) {
|
|
79
|
+
return `\x1b]8;;${e}\x07${pe(t)}\x1b]8;;\x07`;
|
|
80
|
+
}
|
|
81
|
+
var B = {
|
|
82
|
+
arrow: ue("›"),
|
|
83
|
+
bullet: z.muted("·"),
|
|
84
|
+
dash: z.muted("─"),
|
|
85
|
+
corner: z.muted("╰"),
|
|
86
|
+
pipe: z.muted("│"),
|
|
87
|
+
dot: z.muted("•"),
|
|
88
|
+
spark: R("✦"),
|
|
89
|
+
sparkSmall: de("✧"),
|
|
90
|
+
bolt: R("⚡")
|
|
91
|
+
}, _e = [
|
|
92
|
+
R,
|
|
93
|
+
R,
|
|
94
|
+
de,
|
|
95
|
+
ue,
|
|
95
96
|
fe,
|
|
97
|
+
pe,
|
|
96
98
|
me,
|
|
97
|
-
|
|
98
|
-
he,
|
|
99
|
-
he
|
|
99
|
+
me
|
|
100
100
|
];
|
|
101
|
-
function
|
|
101
|
+
function ve(e) {
|
|
102
102
|
let t = [...e], n = t.length;
|
|
103
103
|
return t.map((e, t) => {
|
|
104
104
|
if (e === " " || e === "\n") return e;
|
|
105
105
|
let r = t / Math.max(n - 1, 1);
|
|
106
|
-
return
|
|
106
|
+
return _e[Math.min(Math.floor(r * _e.length), _e.length - 1)](e);
|
|
107
107
|
}).join("");
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function ye(e, t, n) {
|
|
110
110
|
return Math.round(e + (t - e) * n);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function be(e, t) {
|
|
113
113
|
let { start: n, end: r, angle: i = 1 } = t, a = Math.max(...e.map((e) => e.length), 1), o = Math.max(e.length - 1, 1);
|
|
114
114
|
return e.map((e, t) => [...e].map((e, s) => {
|
|
115
115
|
if (e === " ") return e;
|
|
116
116
|
let c = s / Math.max(a - 1, 1), l = t / o, u = Math.min((c + l * i) / (1 + i), 1);
|
|
117
|
-
return `\x1b[38;2;${
|
|
117
|
+
return `\x1b[38;2;${ye(n[0], r[0], u)};${ye(n[1], r[1], u)};${ye(n[2], r[2], u)}m${e}\x1b[39m`;
|
|
118
118
|
}).join(""));
|
|
119
119
|
}
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/core/license.ts
|
|
122
|
-
function
|
|
123
|
-
return `${
|
|
122
|
+
function xe(e) {
|
|
123
|
+
return `${se()}/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
|
|
127
|
-
var
|
|
128
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i =
|
|
127
|
+
var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDescriptor, Te = Object.getOwnPropertyNames, Ee = Object.getPrototypeOf, De = Object.prototype.hasOwnProperty, Oe = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), ke = (e, t, n, r) => {
|
|
128
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = Te(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !De.call(e, s) && s !== n && Ce(e, s, {
|
|
129
129
|
get: ((e) => t[e]).bind(null, s),
|
|
130
|
-
enumerable: !(r =
|
|
130
|
+
enumerable: !(r = we(t, s)) || r.enumerable
|
|
131
131
|
});
|
|
132
132
|
return e;
|
|
133
|
-
},
|
|
133
|
+
}, Ae = (e, t, n) => (n = e == null ? {} : Se(Ee(e)), ke(t || !e || !e.__esModule ? Ce(n, "default", {
|
|
134
134
|
value: e,
|
|
135
135
|
enumerable: !0
|
|
136
|
-
}) : n, e)),
|
|
136
|
+
}) : n, e)), je = (e) => `${e.queryKey}_${Date.now().toString(36)}_${Math.random().toString(36).substring(2)}`, Me = /* @__PURE__ */ Ae((/* @__PURE__ */ Oe(((e, t) => {
|
|
137
137
|
var n = typeof Reflect == "object" ? Reflect : null, r = n && typeof n.apply == "function" ? n.apply : function(e, t, n) {
|
|
138
138
|
return Function.prototype.apply.call(e, t, n);
|
|
139
139
|
}, i = n && typeof n.ownKeys == "function" ? n.ownKeys : Object.getOwnPropertySymbols ? function(e) {
|
|
@@ -308,7 +308,7 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
308
308
|
});
|
|
309
309
|
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
310
310
|
}
|
|
311
|
-
})))()),
|
|
311
|
+
})))()), Ne = (e) => `listen_${String(e)}`, Pe = class extends Me.default {
|
|
312
312
|
emitCallbacks = [];
|
|
313
313
|
constructor(e) {
|
|
314
314
|
super(e);
|
|
@@ -320,26 +320,26 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
320
320
|
onEmit = (e) => (this.emitCallbacks?.push(e), () => {
|
|
321
321
|
this.emitCallbacks = this.emitCallbacks?.filter((t) => t !== e);
|
|
322
322
|
});
|
|
323
|
-
onListener = (e, t) => (super.on(
|
|
324
|
-
super.off(
|
|
323
|
+
onListener = (e, t) => (super.on(Ne(e), t), () => {
|
|
324
|
+
super.off(Ne(e), t);
|
|
325
325
|
});
|
|
326
|
-
on = (e, t) => (super.on(e, t), super.emit(
|
|
327
|
-
off = (e, t) => (super.off(e, t), super.emit(
|
|
326
|
+
on = (e, t) => (super.on(e, t), super.emit(Ne(e), super.listeners(e).length), this);
|
|
327
|
+
off = (e, t) => (super.off(e, t), super.emit(Ne(e), super.listeners(e).length), this);
|
|
328
328
|
addListener = this.on;
|
|
329
329
|
removeListener = this.off;
|
|
330
|
-
},
|
|
331
|
-
emitter = new
|
|
332
|
-
events =
|
|
330
|
+
}, Fe = class {
|
|
331
|
+
emitter = new Pe();
|
|
332
|
+
events = Be(this.emitter);
|
|
333
333
|
isBrowser;
|
|
334
334
|
isOnline;
|
|
335
335
|
isFocused;
|
|
336
336
|
constructor(e) {
|
|
337
337
|
this.options = e, this.emitter?.setMaxListeners(1e3);
|
|
338
|
-
let { initiallyFocused: t =
|
|
339
|
-
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser =
|
|
338
|
+
let { initiallyFocused: t = Ve.initiallyFocused, initiallyOnline: n = Ve.initiallyOnline } = this.options || Ve;
|
|
339
|
+
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser = Le();
|
|
340
340
|
}
|
|
341
341
|
initialize = () => {
|
|
342
|
-
let { focusEvent: e =
|
|
342
|
+
let { focusEvent: e = Ve.focusEvent, onlineEvent: t = Ve.onlineEvent } = this.options || Ve;
|
|
343
343
|
e(this.setFocused), t(this.setOnline);
|
|
344
344
|
};
|
|
345
345
|
setInitialFocus = async (e) => {
|
|
@@ -354,50 +354,50 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
354
354
|
setOnline = (e) => {
|
|
355
355
|
this.isOnline = e, e ? this.events.emitOnline() : this.events.emitOffline();
|
|
356
356
|
};
|
|
357
|
-
},
|
|
357
|
+
}, Ie = () => {
|
|
358
358
|
try {
|
|
359
359
|
return !!(window && window.addEventListener);
|
|
360
360
|
} catch {
|
|
361
361
|
/* istanbul ignore next */
|
|
362
362
|
return !1;
|
|
363
363
|
}
|
|
364
|
-
},
|
|
364
|
+
}, Le = () => {
|
|
365
365
|
try {
|
|
366
|
-
return !!(
|
|
366
|
+
return !!(Ie() && window.document && window.document.addEventListener);
|
|
367
367
|
} catch {
|
|
368
368
|
/* istanbul ignore next */
|
|
369
369
|
return !1;
|
|
370
370
|
}
|
|
371
|
-
},
|
|
371
|
+
}, Re = (e, t, n) => Ie() ? (window.addEventListener(e, t, n), () => window.removeEventListener(e, t, n)) : () => null, ze = (e, t, n) => Le() ? (window.document.addEventListener(e, t, n), () => window.document.removeEventListener(e, t, n)) : () => null, Be = (e) => ({
|
|
372
372
|
emitFocus: () => {
|
|
373
|
-
e.emit(
|
|
373
|
+
e.emit(V.FOCUS);
|
|
374
374
|
},
|
|
375
375
|
emitBlur: () => {
|
|
376
|
-
e.emit(
|
|
376
|
+
e.emit(V.BLUR);
|
|
377
377
|
},
|
|
378
378
|
emitOnline: () => {
|
|
379
|
-
e.emit(
|
|
379
|
+
e.emit(V.ONLINE);
|
|
380
380
|
},
|
|
381
381
|
emitOffline: () => {
|
|
382
|
-
e.emit(
|
|
382
|
+
e.emit(V.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(V.FOCUS, t), () => e.removeListener(V.FOCUS, t)),
|
|
385
|
+
onBlur: (t) => (e.on(V.BLUR, t), () => e.removeListener(V.BLUR, t)),
|
|
386
|
+
onOnline: (t) => (e.on(V.ONLINE, t), () => e.removeListener(V.ONLINE, t)),
|
|
387
|
+
onOffline: (t) => (e.on(V.OFFLINE, t), () => e.removeListener(V.OFFLINE, t))
|
|
388
|
+
}), V = /* @__PURE__ */ function(e) {
|
|
389
389
|
return e.FOCUS = "focus", e.BLUR = "blur", e.ONLINE = "online", e.OFFLINE = "offline", e;
|
|
390
|
-
}({}),
|
|
390
|
+
}({}), Ve = {
|
|
391
391
|
initiallyFocused: !0,
|
|
392
392
|
initiallyOnline: !0,
|
|
393
393
|
focusEvent: (e) => {
|
|
394
|
-
|
|
394
|
+
ze("visibilitychange", () => e(!0)), Re("focus", () => e(!0)), Re("blur", () => e(!1));
|
|
395
395
|
},
|
|
396
396
|
onlineEvent: (e) => {
|
|
397
|
-
|
|
397
|
+
Re("online", () => e(!0)), Re("offline", () => e(!1));
|
|
398
398
|
}
|
|
399
399
|
}, He = class {
|
|
400
|
-
emitter = new
|
|
400
|
+
emitter = new Pe();
|
|
401
401
|
events = vt(this.emitter);
|
|
402
402
|
constructor() {
|
|
403
403
|
this.emitter?.setMaxListeners(1e3);
|
|
@@ -496,7 +496,7 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
496
496
|
logger;
|
|
497
497
|
level;
|
|
498
498
|
modules;
|
|
499
|
-
emitter = new
|
|
499
|
+
emitter = new Me.default();
|
|
500
500
|
client;
|
|
501
501
|
constructor(e) {
|
|
502
502
|
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger || St, this.level = this.options?.level || "warning", this.modules = this.options?.modules;
|
|
@@ -572,16 +572,16 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
572
572
|
constructor(e) {
|
|
573
573
|
super("Unexpected error"), this.description = e, this.name = "UnexpectedError";
|
|
574
574
|
}
|
|
575
|
-
},
|
|
575
|
+
}, Mt = (e) => e === "timeout" ? new Dt() : e === "abort" ? new Ot() : e === "deleted" ? new kt() : e === "processing" ? new At() : new jt(), Nt = (e) => {
|
|
576
576
|
try {
|
|
577
577
|
return JSON.stringify(e);
|
|
578
578
|
} catch {
|
|
579
579
|
return "";
|
|
580
580
|
}
|
|
581
|
-
},
|
|
582
|
-
let t =
|
|
581
|
+
}, Pt = (e) => {
|
|
582
|
+
let t = Ie() && 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
|
+
}, Ft = (e) => Ie() && e instanceof FormData ? e : Nt(e), It = [
|
|
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 Lt(e) {
|
|
594
594
|
let t = {
|
|
595
595
|
onBeforeSent: [],
|
|
596
596
|
onRequestStart: [],
|
|
@@ -600,7 +600,7 @@ function It(e) {
|
|
|
600
600
|
onResponse: [],
|
|
601
601
|
onRemove: []
|
|
602
602
|
};
|
|
603
|
-
e &&
|
|
603
|
+
e && It.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 It(e) {
|
|
|
622
622
|
},
|
|
623
623
|
__snapshot() {
|
|
624
624
|
let e = {};
|
|
625
|
-
return
|
|
625
|
+
return It.forEach((n) => {
|
|
626
626
|
e[n] = [...t[n]];
|
|
627
627
|
}), e;
|
|
628
628
|
}
|
|
629
629
|
};
|
|
630
630
|
}
|
|
631
|
-
var
|
|
631
|
+
var Rt = /* @__PURE__ */ function(e) {
|
|
632
632
|
return e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.PATCH = "PATCH", e.DELETE = "DELETE", e;
|
|
633
|
-
}({}),
|
|
633
|
+
}({}), H = (e, t) => t ? `${t}__${e}` : e, zt = (e) => {
|
|
634
634
|
try {
|
|
635
635
|
if (typeof e == "string") return e;
|
|
636
636
|
if (e == null) return "";
|
|
@@ -640,13 +640,13 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
640
640
|
} catch {
|
|
641
641
|
return "";
|
|
642
642
|
}
|
|
643
|
-
},
|
|
643
|
+
}, Bt = ({ loaded: e, total: t }) => !e || !t ? 0 : Number((e * 100 / t).toFixed(0)), Vt = (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
|
+
}, Ht = (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 Lt = /* @__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 } = Vt(e, t, n);
|
|
660
660
|
return {
|
|
661
|
-
progress:
|
|
661
|
+
progress: Bt(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
|
+
}, Ut = (e) => `${e.method}_${e.requestOptions.endpoint}_${e.cancelable}`, Wt = (e, t) => `${zt(e.method)}_${t ? e.requestOptions.endpoint : zt(e.endpoint)}_${t ? "" : zt(e.queryParams)}`, Gt = (e, t = "auto") => {
|
|
669
|
+
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method === Rt.GET, a = t === "auto" && i || t === "fetch";
|
|
670
670
|
return [a ? n : r, a];
|
|
671
|
-
},
|
|
671
|
+
}, Kt = 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
|
+
}, qt = async (e, t) => {
|
|
675
|
+
let { client: n } = e, { requestManager: r } = n, [i] = Gt(e, t?.dispatcherType), a;
|
|
676
676
|
if (e.optimistic) try {
|
|
677
677
|
a = await e.optimistic({
|
|
678
678
|
request: e,
|
|
@@ -748,7 +748,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
748
748
|
data: null,
|
|
749
749
|
status: null,
|
|
750
750
|
success: !1,
|
|
751
|
-
error:
|
|
751
|
+
error: Mt("deleted"),
|
|
752
752
|
extra: e.client.adapter.defaultExtra,
|
|
753
753
|
requestTimestamp: +/* @__PURE__ */ new Date(),
|
|
754
754
|
responseTimestamp: +/* @__PURE__ */ new Date()
|
|
@@ -759,9 +759,9 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
759
759
|
u(), d(), f(), p(), m(), h();
|
|
760
760
|
}
|
|
761
761
|
});
|
|
762
|
-
},
|
|
762
|
+
}, Jt = /* @__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
|
+
}({}), Yt = class e {
|
|
765
765
|
endpoint;
|
|
766
766
|
headers;
|
|
767
767
|
auth;
|
|
@@ -785,7 +785,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
785
785
|
deduplicate;
|
|
786
786
|
deduplicateTime;
|
|
787
787
|
scope;
|
|
788
|
-
$hooks =
|
|
788
|
+
$hooks = Lt();
|
|
789
789
|
isMockerEnabled = !1;
|
|
790
790
|
unstable_mock;
|
|
791
791
|
unstable_payloadMapper;
|
|
@@ -802,7 +802,7 @@ var Lt = /* @__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 = Jt.MIN * 5, cache: f = !0, staleTime: p = Jt.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,11 +912,11 @@ var Lt = /* @__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 = Lt(this.$hooks.__snapshot()), r;
|
|
916
916
|
}
|
|
917
917
|
abort = () => {
|
|
918
918
|
let { requestManager: e } = this.client;
|
|
919
|
-
return e.abortByKey(
|
|
919
|
+
return e.abortByKey(H(this.abortKey, this.scope)), this.clone();
|
|
920
920
|
};
|
|
921
921
|
dehydrate = (e) => {
|
|
922
922
|
let { response: t, override: n = !0 } = e || {};
|
|
@@ -931,7 +931,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
931
931
|
cache: !0,
|
|
932
932
|
response: t
|
|
933
933
|
};
|
|
934
|
-
let r = this.client.cache.get(
|
|
934
|
+
let r = this.client.cache.get(H(this.cacheKey, this.scope));
|
|
935
935
|
if (r) return {
|
|
936
936
|
override: n,
|
|
937
937
|
cacheTime: this.cacheTime,
|
|
@@ -953,7 +953,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
953
953
|
};
|
|
954
954
|
};
|
|
955
955
|
read() {
|
|
956
|
-
let e = this.client.cache.get(
|
|
956
|
+
let e = this.client.cache.get(H(this.cacheKey, this.scope));
|
|
957
957
|
if (e) return {
|
|
958
958
|
data: e.data,
|
|
959
959
|
error: e.error,
|
|
@@ -965,7 +965,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
965
965
|
};
|
|
966
966
|
}
|
|
967
967
|
exec = async (e) => {
|
|
968
|
-
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a =
|
|
968
|
+
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a = H(this.abortKey, this.scope);
|
|
969
969
|
n.addAbortController(a, i);
|
|
970
970
|
let o = await t.fetch(r, i);
|
|
971
971
|
return n.removeAbortController(a, i), r.unstable_responseMapper ? r.unstable_responseMapper(o) : o;
|
|
@@ -975,17 +975,17 @@ var Lt = /* @__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 qt(i, a);
|
|
979
979
|
let o = i.read();
|
|
980
|
-
if (n === "cache-first") return o ?
|
|
980
|
+
if (n === "cache-first") return o ? Kt(i, o) : qt(i, a);
|
|
981
981
|
if (o) {
|
|
982
|
-
let e = await
|
|
983
|
-
return
|
|
982
|
+
let e = await Kt(i, o);
|
|
983
|
+
return qt(i, a), e;
|
|
984
984
|
}
|
|
985
|
-
return
|
|
985
|
+
return qt(i, a);
|
|
986
986
|
};
|
|
987
987
|
static fromJSON = (t, n) => new e(t, n.requestOptions, n);
|
|
988
|
-
},
|
|
988
|
+
}, Xt = 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",
|
|
@@ -995,7 +995,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
995
995
|
requestId: t
|
|
996
996
|
}
|
|
997
997
|
}), d = await d.client.unstable_modifyRequest(d), d.auth && (d = await d.client.unstable_modifyAuth(d)), d.unstable_requestMapper && (d = await d.unstable_requestMapper(d, t));
|
|
998
|
-
let { client: g, abortKey: _ } = d, v =
|
|
998
|
+
let { client: g, abortKey: _ } = d, v = H(_, d.scope), y = d.payload;
|
|
999
999
|
d.unstable_payloadMapper ? y = await d.unstable_payloadMapper(d.payload) : s && (y = await s(y));
|
|
1000
1000
|
let b = d.options, x = +/* @__PURE__ */ new Date();
|
|
1001
1001
|
r(x);
|
|
@@ -1004,14 +1004,14 @@ var Lt = /* @__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 = Ht(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 = Ht(new Date(e), new Date(n), r);
|
|
1015
1015
|
h !== 100 && (h = i.total, a.events.emitDownloadProgress({
|
|
1016
1016
|
...i,
|
|
1017
1017
|
requestId: t,
|
|
@@ -1067,21 +1067,21 @@ var Lt = /* @__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
|
+
}, M = () => {
|
|
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
|
+
}, te = 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 Lt = /* @__PURE__ */ function(e) {
|
|
|
1106
1106
|
response: o
|
|
1107
1107
|
}
|
|
1108
1108
|
}), o;
|
|
1109
|
-
},
|
|
1109
|
+
}, N = Zt({
|
|
1110
1110
|
request: d,
|
|
1111
1111
|
requestId: t,
|
|
1112
1112
|
startTime: x,
|
|
1113
1113
|
logger: c,
|
|
1114
1114
|
resolve: n
|
|
1115
|
-
}),
|
|
1115
|
+
}), P = ({ 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
|
-
}),
|
|
1123
|
-
error: i(
|
|
1122
|
+
}), N({
|
|
1123
|
+
error: i(Mt("abort")),
|
|
1124
1124
|
status: e,
|
|
1125
1125
|
extra: n
|
|
1126
|
-
})),
|
|
1126
|
+
})), F = ({ 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
|
-
}),
|
|
1134
|
-
error:
|
|
1133
|
+
}), N({
|
|
1134
|
+
error: Mt("timeout"),
|
|
1135
1135
|
status: e,
|
|
1136
1136
|
extra: n
|
|
1137
|
-
})),
|
|
1137
|
+
})), ne = ({ 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
|
-
}),
|
|
1145
|
-
error:
|
|
1144
|
+
}), N({
|
|
1145
|
+
error: Mt(),
|
|
1146
1146
|
status: e,
|
|
1147
1147
|
extra: n
|
|
1148
|
-
})),
|
|
1149
|
-
let i =
|
|
1148
|
+
})), I = () => a.getAbortController(v, t), re = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1149
|
+
let i = I();
|
|
1150
1150
|
if (!i) throw new At("Controller is not found");
|
|
1151
1151
|
let o = () => {
|
|
1152
|
-
|
|
1152
|
+
P({
|
|
1153
1153
|
status: e,
|
|
1154
1154
|
extra: n
|
|
1155
1155
|
}), r(), a.events.emitAbort({
|
|
@@ -1169,36 +1169,36 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1169
1169
|
adapterOptions: b
|
|
1170
1170
|
}
|
|
1171
1171
|
});
|
|
1172
|
-
let
|
|
1172
|
+
let ie = e.client.adapter.unstable_queryParamsMapper(d.queryParams), ae = e.client.adapter.unstable_endpointMapper(d.endpoint), oe = e.client.adapter.unstable_headerMapper(d), { url: L } = e.client;
|
|
1173
1173
|
return {
|
|
1174
1174
|
request: d,
|
|
1175
1175
|
requestId: t,
|
|
1176
|
-
url:
|
|
1177
|
-
endpoint:
|
|
1178
|
-
queryParams:
|
|
1176
|
+
url: L,
|
|
1177
|
+
endpoint: ae,
|
|
1178
|
+
queryParams: ie,
|
|
1179
1179
|
payload: y,
|
|
1180
|
-
headers:
|
|
1180
|
+
headers: oe,
|
|
1181
1181
|
adapter: e.client.adapter,
|
|
1182
1182
|
adapterOptions: b,
|
|
1183
|
-
getAbortController:
|
|
1183
|
+
getAbortController: I,
|
|
1184
1184
|
getRequestStartTimestamp: S,
|
|
1185
1185
|
getResponseStartTimestamp: C,
|
|
1186
|
-
createAbortListener:
|
|
1186
|
+
createAbortListener: re,
|
|
1187
1187
|
onBeforeRequest: D,
|
|
1188
1188
|
onRequestStart: O,
|
|
1189
1189
|
onRequestProgress: k,
|
|
1190
1190
|
onRequestEnd: ee,
|
|
1191
1191
|
onResponseStart: A,
|
|
1192
|
-
onResponseProgress:
|
|
1193
|
-
onResponseEnd:
|
|
1194
|
-
onSuccess:
|
|
1195
|
-
onAbortError:
|
|
1196
|
-
onTimeoutError:
|
|
1197
|
-
onUnexpectedError:
|
|
1198
|
-
onError:
|
|
1192
|
+
onResponseProgress: j,
|
|
1193
|
+
onResponseEnd: M,
|
|
1194
|
+
onSuccess: te,
|
|
1195
|
+
onAbortError: P,
|
|
1196
|
+
onTimeoutError: F,
|
|
1197
|
+
onUnexpectedError: ne,
|
|
1198
|
+
onError: N
|
|
1199
1199
|
};
|
|
1200
1200
|
};
|
|
1201
|
-
function
|
|
1201
|
+
function Zt({ 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,7 +1227,7 @@ function Xt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
|
1227
1227
|
}), l;
|
|
1228
1228
|
};
|
|
1229
1229
|
}
|
|
1230
|
-
var
|
|
1230
|
+
var Qt = 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
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,
|
|
@@ -1272,7 +1272,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1272
1272
|
status: C,
|
|
1273
1273
|
extra: T
|
|
1274
1274
|
}), h || r();
|
|
1275
|
-
},
|
|
1275
|
+
}, $t = (e) => e, en = class {
|
|
1276
1276
|
unstable_fetcher;
|
|
1277
1277
|
name;
|
|
1278
1278
|
defaultMethod;
|
|
@@ -1294,10 +1294,10 @@ var Zt = 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 = Pt;
|
|
1298
|
+
unstable_payloadMapper = Ft;
|
|
1299
|
+
unstable_endpointMapper = $t;
|
|
1300
|
+
unstable_queryParamsMapper = $t;
|
|
1301
1301
|
unstable_getAdapterDefaults;
|
|
1302
1302
|
unstable_getRequestDefaults;
|
|
1303
1303
|
unstable_devtoolsEndpointGetter = (e) => e;
|
|
@@ -1328,7 +1328,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1328
1328
|
request: e,
|
|
1329
1329
|
requestId: t
|
|
1330
1330
|
});
|
|
1331
|
-
let i = await
|
|
1331
|
+
let i = await Xt({
|
|
1332
1332
|
request: e,
|
|
1333
1333
|
requestId: t,
|
|
1334
1334
|
resolve: r,
|
|
@@ -1337,9 +1337,9 @@ var Zt = 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 Qt(i) : this.unstable_fetcher(i);
|
|
1341
1341
|
} catch (i) {
|
|
1342
|
-
return
|
|
1342
|
+
return Zt({
|
|
1343
1343
|
request: e,
|
|
1344
1344
|
requestId: t,
|
|
1345
1345
|
startTime: n || Date.now(),
|
|
@@ -1356,66 +1356,66 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1356
1356
|
r(e);
|
|
1357
1357
|
});
|
|
1358
1358
|
}
|
|
1359
|
-
},
|
|
1359
|
+
}, tn = (e) => {
|
|
1360
1360
|
try {
|
|
1361
1361
|
return JSON.parse(e);
|
|
1362
1362
|
} catch {
|
|
1363
1363
|
return e;
|
|
1364
1364
|
}
|
|
1365
|
-
},
|
|
1365
|
+
}, nn = (e) => e ? tn(e) : Mt(), rn = (e) => (t) => {
|
|
1366
1366
|
let { skipNull: n, skipEmptyString: r } = e;
|
|
1367
1367
|
return !(r && t === void 0 || r && t === "" || n && t === null);
|
|
1368
|
-
},
|
|
1369
|
-
let r = !
|
|
1370
|
-
return !e || r ? "" : `${
|
|
1371
|
-
},
|
|
1368
|
+
}, U = (e, { encode: t, strict: n }) => t && n ? encodeURIComponent(e).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`) : t ? encodeURIComponent(e) : e, an = (e, t, n) => {
|
|
1369
|
+
let r = !rn(n)(t);
|
|
1370
|
+
return !e || r ? "" : `${U(e, n)}=${U(t instanceof Date ? n.dateParser?.(t) || t.toISOString() : typeof t == "object" && !Array.isArray(t) ? n.objectParser?.(t) || JSON.stringify(t) : String(t), n)}`;
|
|
1371
|
+
}, on = (e, t, n) => {
|
|
1372
1372
|
let { arrayFormat: r, arraySeparator: i } = n;
|
|
1373
|
-
return t.filter(
|
|
1373
|
+
return t.filter(rn(n)).reduce((t, a, o) => {
|
|
1374
1374
|
switch (r) {
|
|
1375
1375
|
case "index": {
|
|
1376
|
-
let r = `${
|
|
1377
|
-
t.push(`${r}${
|
|
1376
|
+
let r = `${U(e, n)}[${U(String(o), n)}]=`;
|
|
1377
|
+
t.push(`${r}${U(String(a), n)}`);
|
|
1378
1378
|
break;
|
|
1379
1379
|
}
|
|
1380
1380
|
case "bracket": {
|
|
1381
|
-
let r = `${
|
|
1382
|
-
t.push(`${r}${
|
|
1381
|
+
let r = `${U(e, n)}[]=`;
|
|
1382
|
+
t.push(`${r}${U(String(a), n)}`);
|
|
1383
1383
|
break;
|
|
1384
1384
|
}
|
|
1385
1385
|
case "comma": {
|
|
1386
|
-
let r = !t.length && `${
|
|
1387
|
-
return [[...t, `${r}${
|
|
1386
|
+
let r = !t.length && `${U(e, n)}=` || "";
|
|
1387
|
+
return [[...t, `${r}${U(String(a), n)}`].join(",")];
|
|
1388
1388
|
}
|
|
1389
1389
|
case "separator": {
|
|
1390
|
-
let r = !t.length && `${
|
|
1391
|
-
return [[...t, `${r}${
|
|
1390
|
+
let r = !t.length && `${U(e, n)}=` || "";
|
|
1391
|
+
return [[...t, `${r}${U(String(a), n)}`].join(i || "|")];
|
|
1392
1392
|
}
|
|
1393
1393
|
case "bracket-separator": {
|
|
1394
|
-
let r = !t.length && `${
|
|
1395
|
-
return [[...t, `${r}${
|
|
1394
|
+
let r = !t.length && `${U(e, n)}[]=` || "";
|
|
1395
|
+
return [[...t, `${r}${U(String(a), n)}`].join(i || "|")];
|
|
1396
1396
|
}
|
|
1397
1397
|
default: {
|
|
1398
|
-
let r = `${
|
|
1399
|
-
t.push(`${r}${
|
|
1398
|
+
let r = `${U(e, n)}=`;
|
|
1399
|
+
t.push(`${r}${U(String(a), n)}`);
|
|
1400
1400
|
}
|
|
1401
1401
|
}
|
|
1402
1402
|
return t;
|
|
1403
1403
|
}, []).join("&");
|
|
1404
|
-
},
|
|
1404
|
+
}, sn = (e, t = In) => {
|
|
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) ? on(e, n, t) : an(e, n, t)).filter(Boolean).join("&");
|
|
1408
1408
|
return n ? `?${n}` : "";
|
|
1409
|
-
},
|
|
1409
|
+
}, cn = Jt.SEC * 5, ln = { headers: {} }, un = () => new en({
|
|
1410
1410
|
name: "http",
|
|
1411
|
-
defaultMethod:
|
|
1412
|
-
defaultExtra:
|
|
1411
|
+
defaultMethod: Rt.GET,
|
|
1412
|
+
defaultExtra: ln,
|
|
1413
1413
|
systemErrorStatus: 0,
|
|
1414
|
-
systemErrorExtra:
|
|
1415
|
-
}).setQueryParamsMapper(
|
|
1416
|
-
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ?
|
|
1414
|
+
systemErrorExtra: ln
|
|
1415
|
+
}).setQueryParamsMapper(sn).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 ? sn(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = cn, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
|
|
1417
1417
|
status: 0,
|
|
1418
|
-
extra:
|
|
1418
|
+
extra: ln
|
|
1419
1419
|
});
|
|
1420
1420
|
C > 0 && S && (D = setTimeout(() => {
|
|
1421
1421
|
E = !0, O(), S.abort();
|
|
@@ -1447,7 +1447,7 @@ var Zt = 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: nn(await t.text()),
|
|
1451
1451
|
status: l,
|
|
1452
1452
|
extra: c
|
|
1453
1453
|
});
|
|
@@ -1468,11 +1468,11 @@ var Zt = 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: tn(e),
|
|
1472
1472
|
status: l,
|
|
1473
1473
|
extra: c
|
|
1474
1474
|
}) : i({
|
|
1475
|
-
error:
|
|
1475
|
+
error: nn(e),
|
|
1476
1476
|
status: l,
|
|
1477
1477
|
extra: c
|
|
1478
1478
|
});
|
|
@@ -1481,18 +1481,18 @@ var Zt = 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: ln
|
|
1485
1485
|
});
|
|
1486
1486
|
return;
|
|
1487
1487
|
}
|
|
1488
1488
|
i({
|
|
1489
1489
|
error: e,
|
|
1490
1490
|
status: 0,
|
|
1491
|
-
extra:
|
|
1491
|
+
extra: ln
|
|
1492
1492
|
});
|
|
1493
1493
|
}
|
|
1494
|
-
}),
|
|
1495
|
-
emitter = new
|
|
1494
|
+
}), dn = () => un(), fn = class {
|
|
1495
|
+
emitter = new Pe();
|
|
1496
1496
|
events;
|
|
1497
1497
|
storage;
|
|
1498
1498
|
lazyStorage;
|
|
@@ -1503,7 +1503,7 @@ var Zt = 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 = bn(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 Zt = 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 =
|
|
1520
|
+
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = H(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u = pn(c, l), d = {
|
|
1521
1521
|
...u,
|
|
1522
1522
|
scope: o,
|
|
1523
1523
|
staleTime: i,
|
|
@@ -1563,7 +1563,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1563
1563
|
partialResponse: t
|
|
1564
1564
|
}
|
|
1565
1565
|
});
|
|
1566
|
-
let { cacheKey: n, scope: r } = e, i =
|
|
1566
|
+
let { cacheKey: n, scope: r } = e, i = H(n, r), a = this.storage.get(i), o = typeof t == "function" ? t(a || null) : t;
|
|
1567
1567
|
a && this.set(e, {
|
|
1568
1568
|
...a,
|
|
1569
1569
|
...o
|
|
@@ -1601,7 +1601,7 @@ var Zt = 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 Yt ? n(H(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 Zt = 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
|
+
}, pn = (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
|
+
}, mn = () => "invalidate", hn = (e) => `${e}_invalidate`, gn = () => "delete", _n = (e) => `${e}_delete`, vn = (e) => `${e}_cache`, yn = () => "cache", bn = (e) => ({
|
|
1666
1666
|
emitCacheData: (t, n = !1) => {
|
|
1667
|
-
e.emit(
|
|
1667
|
+
e.emit(yn(), t, n), e.emit(vn(t.cacheKey), t, n);
|
|
1668
1668
|
},
|
|
1669
1669
|
emitInvalidation: (t, n = !1) => {
|
|
1670
|
-
e.emit(
|
|
1670
|
+
e.emit(mn(), t, n), e.emit(hn(t), n);
|
|
1671
1671
|
},
|
|
1672
1672
|
emitDelete: (t, n = !1) => {
|
|
1673
|
-
e.emit(
|
|
1673
|
+
e.emit(gn(), t, n), e.emit(_n(t), n);
|
|
1674
1674
|
},
|
|
1675
|
-
onData: (t) => (e.on(
|
|
1676
|
-
onDataByKey: (t, n) => (e.on(
|
|
1677
|
-
onInvalidate: (t) => (e.on(
|
|
1678
|
-
onInvalidateByKey: (t, n) => (e.on(
|
|
1679
|
-
onDelete: (t) => (e.on(
|
|
1680
|
-
onDeleteByKey: (t, n) => (e.on(
|
|
1681
|
-
}),
|
|
1675
|
+
onData: (t) => (e.on(yn(), t), () => e.removeListener(yn(), t)),
|
|
1676
|
+
onDataByKey: (t, n) => (e.on(vn(t), n), () => e.removeListener(vn(t), n)),
|
|
1677
|
+
onInvalidate: (t) => (e.on(mn(), t), () => e.removeListener(mn(), t)),
|
|
1678
|
+
onInvalidateByKey: (t, n) => (e.on(hn(t), n), () => e.removeListener(hn(t), n)),
|
|
1679
|
+
onDelete: (t) => (e.on(gn(), t), () => e.removeListener(gn(), t)),
|
|
1680
|
+
onDeleteByKey: (t, n) => (e.on(_n(t), n), () => e.removeListener(_n(t), n))
|
|
1681
|
+
}), W = /* @__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
|
+
}({}), xn = (e) => ({
|
|
1684
1684
|
emitDrained: (t, n) => {
|
|
1685
|
-
e.emit(
|
|
1685
|
+
e.emit(Cn(), t, n), e.emit(wn(t.queryKey), t, n);
|
|
1686
1686
|
},
|
|
1687
1687
|
emitQueueStatusChanged: (t, n) => {
|
|
1688
|
-
e.emit(
|
|
1688
|
+
e.emit(Tn(), t, n), e.emit(En(t.queryKey), t, n);
|
|
1689
1689
|
},
|
|
1690
1690
|
emitQueueChanged: (t, n) => {
|
|
1691
|
-
e.emit(
|
|
1691
|
+
e.emit(Dn(), t, n), e.emit(On(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
|
-
}),
|
|
1700
|
-
emitter = new
|
|
1701
|
-
events =
|
|
1693
|
+
onDrained: (t) => (e.on(Cn(), t), () => e.removeListener(Cn(), t)),
|
|
1694
|
+
onDrainedByKey: (t, n) => (e.on(wn(t), n), () => e.removeListener(wn(t), n)),
|
|
1695
|
+
onQueueStatusChange: (t) => (e.on(Tn(), t), () => e.removeListener(Tn(), t)),
|
|
1696
|
+
onQueueStatusChangeByKey: (t, n) => (e.on(En(t), n), () => e.removeListener(En(t), n)),
|
|
1697
|
+
onQueueChange: (t) => (e.on(Dn(), t), () => e.removeListener(Dn(), t)),
|
|
1698
|
+
onQueueChangeByKey: (t, n) => (e.on(On(t), n), () => e.removeListener(On(t), n))
|
|
1699
|
+
}), Sn = class {
|
|
1700
|
+
emitter = new Pe();
|
|
1701
|
+
events = xn(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 Zt = 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 Yt);
|
|
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);
|
|
@@ -1831,14 +1831,14 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1831
1831
|
hasRunningRequest = (e, t) => !!this.getRunningRequests(e).find((e) => e.requestId === t);
|
|
1832
1832
|
cancelRunningRequests = (e) => {
|
|
1833
1833
|
this.runningRequests.get(e)?.forEach((e) => {
|
|
1834
|
-
let t =
|
|
1834
|
+
let t = H(e.request.abortKey, e.request.scope);
|
|
1835
1835
|
this.client.requestManager.abortByRequestId(t, e.requestId);
|
|
1836
1836
|
}), this.deleteRunningRequests(e);
|
|
1837
1837
|
};
|
|
1838
1838
|
cancelRunningRequest = (e, t) => {
|
|
1839
1839
|
let n = this.getRunningRequests(e).filter((e) => {
|
|
1840
1840
|
if (e.requestId === t) {
|
|
1841
|
-
let t =
|
|
1841
|
+
let t = H(e.request.abortKey, e.request.scope);
|
|
1842
1842
|
return this.client.requestManager.abortByRequestId(t, e.requestId), !1;
|
|
1843
1843
|
}
|
|
1844
1844
|
return !0;
|
|
@@ -1866,7 +1866,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1866
1866
|
resolved: !1
|
|
1867
1867
|
});
|
|
1868
1868
|
add = (e) => {
|
|
1869
|
-
let t =
|
|
1869
|
+
let t = H(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = jn(e, i);
|
|
1870
1870
|
switch (this.logger.debug({
|
|
1871
1871
|
title: "Adding request to queue",
|
|
1872
1872
|
type: "system",
|
|
@@ -1876,9 +1876,9 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1876
1876
|
requestId: r
|
|
1877
1877
|
}
|
|
1878
1878
|
}), a) {
|
|
1879
|
-
case
|
|
1880
|
-
case
|
|
1881
|
-
case
|
|
1879
|
+
case W.ONE_BY_ONE: return this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1880
|
+
case W.PREVIOUS_CANCELED: return this.cancelRunningRequests(t), this.clearQueue(t), this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1881
|
+
case W.DEDUPLICATED: return this.client.requestManager.events.emitDeduplicated({
|
|
1882
1882
|
request: i.request,
|
|
1883
1883
|
requestId: r,
|
|
1884
1884
|
deduplicatedRequest: e
|
|
@@ -1920,7 +1920,7 @@ var Zt = 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 =
|
|
1923
|
+
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = H(a, c), u = H(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h = kn(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",
|
|
@@ -1940,7 +1940,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1940
1940
|
}), this.incrementQueueRequestCount(l), f.addAbortController(u, n);
|
|
1941
1941
|
let b = await d.fetch(t, n);
|
|
1942
1942
|
e.resolved = !0, f.removeAbortController(u, n);
|
|
1943
|
-
let x = !m.isOnline, S =
|
|
1943
|
+
let x = !m.isOnline, S = Mt("abort").message === b.error?.message, C = !this.hasRunningRequest(l, n) || S;
|
|
1944
1944
|
this.deleteRunningRequest(l, n);
|
|
1945
1945
|
let w = b.success || !h || !t.retryOnError || t.retryOnError(b), T = !b.success && h && w && !C && !x, E = {
|
|
1946
1946
|
isCanceled: C,
|
|
@@ -2054,26 +2054,26 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
2054
2054
|
}
|
|
2055
2055
|
}), this.delete(l, n, u));
|
|
2056
2056
|
};
|
|
2057
|
-
},
|
|
2058
|
-
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ?
|
|
2059
|
-
return n ?
|
|
2057
|
+
}, Cn = () => "drained-event", wn = (e) => `${e}-drained-event`, Tn = () => "status-event", En = (e) => `${e}-status-event`, Dn = () => "change-event", On = (e) => `${e}-change-event`, kn = (e, t) => !!(t && e < t), An = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, jn = (e, t) => {
|
|
2058
|
+
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? An(e, t) : !1;
|
|
2059
|
+
return n ? W.ONE_BY_ONE : r ? W.PREVIOUS_CANCELED : a && i ? W.DEDUPLICATED : W.ALL_AT_ONCE;
|
|
2060
2060
|
};
|
|
2061
|
-
function
|
|
2061
|
+
function Mn(e) {
|
|
2062
2062
|
return e === "client" || e === "server" ? e : typeof window < "u" && typeof document < "u" ? "client" : "server";
|
|
2063
2063
|
}
|
|
2064
|
-
var
|
|
2064
|
+
var Nn = 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
|
+
}, Pn = 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
|
+
}, Fn = class {
|
|
2077
2077
|
url;
|
|
2078
2078
|
mode;
|
|
2079
2079
|
debug;
|
|
@@ -2091,15 +2091,15 @@ var Mn = async (e, t) => {
|
|
|
2091
2091
|
submitDispatcher;
|
|
2092
2092
|
isMockerEnabled = !0;
|
|
2093
2093
|
plugins = [];
|
|
2094
|
-
unstable_abortKeyMapper =
|
|
2095
|
-
unstable_cacheKeyMapper =
|
|
2096
|
-
unstable_queryKeyMapper =
|
|
2097
|
-
unstable_requestIdMapper =
|
|
2094
|
+
unstable_abortKeyMapper = Ut;
|
|
2095
|
+
unstable_cacheKeyMapper = Wt;
|
|
2096
|
+
unstable_queryKeyMapper = Wt;
|
|
2097
|
+
unstable_requestIdMapper = je;
|
|
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 = Mn(o), this.adapter = dn(), this.appManager = n?.() || new Fe(), this.cache = r?.() || new fn(), this.fetchDispatcher = i?.() || new Sn(), this.submitDispatcher = a?.() || new Sn(), 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 Mn = 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) => Nn(this.unstable_onAuthCallbacks, e);
|
|
2132
|
+
unstable_modifyRequest = async (e) => Nn(this.unstable_onRequestCallbacks, e);
|
|
2133
|
+
unstable_modifyErrorResponse = async (e, t) => Pn(this.unstable_onErrorCallbacks, e, t);
|
|
2134
|
+
unstable_modifySuccessResponse = async (e, t) => Pn(this.unstable_onSuccessCallbacks, e, t);
|
|
2135
|
+
unstable_modifyResponse = async (e, t) => Pn(this.unstable_onResponseCallbacks, e, t);
|
|
2136
|
+
fromJSON = (e) => Yt.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 fn(), this.appManager = e?.() || new Fe(), this.fetchDispatcher = n?.() || new Sn(), this.submitDispatcher = r?.() || new Sn(), 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) => {
|
|
@@ -2153,8 +2153,8 @@ var Mn = async (e, t) => {
|
|
|
2153
2153
|
...a,
|
|
2154
2154
|
...t
|
|
2155
2155
|
};
|
|
2156
|
-
if (!s.override && this.cache.get(
|
|
2157
|
-
let c =
|
|
2156
|
+
if (!s.override && this.cache.get(H(n, r))) return;
|
|
2157
|
+
let c = tn(i);
|
|
2158
2158
|
this.cache.set({
|
|
2159
2159
|
...s,
|
|
2160
2160
|
cacheKey: n,
|
|
@@ -2166,10 +2166,10 @@ var Mn = 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 Yt(this, n);
|
|
2170
2170
|
return this.plugins.forEach((e) => e.trigger("onRequestCreate", { request: r })), r;
|
|
2171
2171
|
};
|
|
2172
|
-
},
|
|
2172
|
+
}, In = {
|
|
2173
2173
|
strict: !0,
|
|
2174
2174
|
encode: !0,
|
|
2175
2175
|
arrayFormat: "bracket",
|
|
@@ -2178,101 +2178,101 @@ var Mn = async (e, t) => {
|
|
|
2178
2178
|
skipNull: !0,
|
|
2179
2179
|
skipEmptyString: !0
|
|
2180
2180
|
};
|
|
2181
|
-
function
|
|
2182
|
-
return new
|
|
2181
|
+
function Ln(e) {
|
|
2182
|
+
return new Fn(e);
|
|
2183
2183
|
}
|
|
2184
2184
|
//#endregion
|
|
2185
2185
|
//#region src/core/client.ts
|
|
2186
|
-
var
|
|
2186
|
+
var G = Ln({ url: L() });
|
|
2187
2187
|
//#endregion
|
|
2188
2188
|
//#region src/core/auth-api.ts
|
|
2189
|
-
async function
|
|
2190
|
-
let { data: t, success: n } = await
|
|
2189
|
+
async function Rn(e) {
|
|
2190
|
+
let { data: t, success: n } = await G.createRequest()({
|
|
2191
2191
|
endpoint: "/auth/cli/whoami",
|
|
2192
2192
|
method: "GET"
|
|
2193
2193
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2194
2194
|
return !n || !t ? null : t;
|
|
2195
2195
|
}
|
|
2196
|
-
async function
|
|
2197
|
-
await
|
|
2196
|
+
async function zn(e) {
|
|
2197
|
+
await G.createRequest()({
|
|
2198
2198
|
endpoint: "/auth/cli/token",
|
|
2199
2199
|
method: "DELETE"
|
|
2200
2200
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2201
2201
|
}
|
|
2202
2202
|
//#endregion
|
|
2203
2203
|
//#region src/core/auth-store.ts
|
|
2204
|
-
var
|
|
2205
|
-
function
|
|
2204
|
+
var Bn = 1, Vn = "hype-stack", Hn = "auth.json";
|
|
2205
|
+
function Un() {
|
|
2206
2206
|
let e = process.env.HYPE_STACK_CONFIG_DIR;
|
|
2207
|
-
if (e) return T.join(e,
|
|
2207
|
+
if (e) return T.join(e, Vn);
|
|
2208
2208
|
let t = w.homedir();
|
|
2209
2209
|
if (process.platform === "win32") {
|
|
2210
2210
|
let e = process.env.APPDATA ?? T.join(t, "AppData", "Roaming");
|
|
2211
|
-
return T.join(e,
|
|
2211
|
+
return T.join(e, Vn);
|
|
2212
2212
|
}
|
|
2213
|
-
if (process.platform === "darwin") return T.join(t, "Library", "Application Support",
|
|
2213
|
+
if (process.platform === "darwin") return T.join(t, "Library", "Application Support", Vn);
|
|
2214
2214
|
let n = process.env.XDG_CONFIG_HOME ?? T.join(t, ".config");
|
|
2215
|
-
return T.join(n,
|
|
2215
|
+
return T.join(n, Vn);
|
|
2216
2216
|
}
|
|
2217
|
-
function
|
|
2218
|
-
return T.join(
|
|
2217
|
+
function Wn() {
|
|
2218
|
+
return T.join(Un(), Hn);
|
|
2219
2219
|
}
|
|
2220
|
-
async function
|
|
2221
|
-
let e = await y.readFile(
|
|
2220
|
+
async function Gn() {
|
|
2221
|
+
let e = await y.readFile(Wn(), "utf-8").catch(() => null);
|
|
2222
2222
|
if (!e) return {
|
|
2223
|
-
version:
|
|
2223
|
+
version: Bn,
|
|
2224
2224
|
tokens: {}
|
|
2225
2225
|
};
|
|
2226
2226
|
let t = JSON.parse(e);
|
|
2227
2227
|
return {
|
|
2228
|
-
version: t.version ??
|
|
2228
|
+
version: t.version ?? Bn,
|
|
2229
2229
|
tokens: t.tokens ?? {}
|
|
2230
2230
|
};
|
|
2231
2231
|
}
|
|
2232
|
-
async function Gn(e) {
|
|
2233
|
-
let t = Hn();
|
|
2234
|
-
await y.mkdir(t, { recursive: !0 }), await y.writeFile(Un(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2235
|
-
}
|
|
2236
2232
|
async function Kn(e) {
|
|
2237
|
-
|
|
2233
|
+
let t = Un();
|
|
2234
|
+
await y.mkdir(t, { recursive: !0 }), await y.writeFile(Wn(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2238
2235
|
}
|
|
2239
|
-
async function qn(e
|
|
2240
|
-
|
|
2241
|
-
n.tokens[e] = t, await Gn(n);
|
|
2236
|
+
async function qn(e) {
|
|
2237
|
+
return (await Gn()).tokens[e] ?? null;
|
|
2242
2238
|
}
|
|
2243
|
-
async function Jn(e) {
|
|
2244
|
-
let
|
|
2245
|
-
|
|
2239
|
+
async function Jn(e, t) {
|
|
2240
|
+
let n = await Gn();
|
|
2241
|
+
n.tokens[e] = t, await Kn(n);
|
|
2242
|
+
}
|
|
2243
|
+
async function Yn(e) {
|
|
2244
|
+
let t = await Gn();
|
|
2245
|
+
e in t.tokens && (delete t.tokens[e], await Kn(t));
|
|
2246
2246
|
}
|
|
2247
2247
|
//#endregion
|
|
2248
2248
|
//#region src/core/device.ts
|
|
2249
|
-
function
|
|
2249
|
+
function Xn() {
|
|
2250
2250
|
let e = w.networkInterfaces();
|
|
2251
2251
|
for (let t of Object.values(e)) if (t) {
|
|
2252
2252
|
for (let e of t) if (!e.internal && e.mac !== "00:00:00:00:00:00") return e.mac;
|
|
2253
2253
|
}
|
|
2254
2254
|
return "unknown";
|
|
2255
2255
|
}
|
|
2256
|
-
function
|
|
2257
|
-
let e = `${
|
|
2256
|
+
function Zn() {
|
|
2257
|
+
let e = `${Xn()}:${w.hostname()}:${w.platform()}:${w.arch()}`;
|
|
2258
2258
|
return x("sha256").update(e).digest("hex").slice(0, 16);
|
|
2259
2259
|
}
|
|
2260
|
-
function
|
|
2260
|
+
function Qn() {
|
|
2261
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
|
|
2265
|
+
function $n(e) {
|
|
2266
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 = S(16).toString("hex"), n =
|
|
2270
|
+
var er = 300 * 1e3, tr = (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 nr(e = {}) {
|
|
2272
|
+
let t = S(16).toString("hex"), n = L(), 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
|
+
}, er);
|
|
2276
2276
|
function o() {
|
|
2277
2277
|
clearTimeout(a), r.close(), r.closeAllConnections?.();
|
|
2278
2278
|
}
|
|
@@ -2286,7 +2286,7 @@ async function tr(e = {}) {
|
|
|
2286
2286
|
r.writeHead(200, {
|
|
2287
2287
|
"Content-Type": "text/html",
|
|
2288
2288
|
Connection: "close"
|
|
2289
|
-
}), r.end(
|
|
2289
|
+
}), r.end(tr(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,53 +2301,53 @@ async function tr(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(Qn()), a = `${se()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
|
|
2305
|
+
e.onUrl?.(a), $n(a);
|
|
2306
2306
|
});
|
|
2307
|
-
}), a = await
|
|
2307
|
+
}), a = await Rn(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 Jn(n, o), o;
|
|
2313
2313
|
}
|
|
2314
2314
|
//#endregion
|
|
2315
2315
|
//#region src/core/access-prompts.ts
|
|
2316
|
-
async function
|
|
2316
|
+
async function rr() {
|
|
2317
2317
|
let e = await s.confirm({ message: "Log in to install packs your organization owns? (opens your browser)" });
|
|
2318
2318
|
if (s.isCancel(e) || !e) return null;
|
|
2319
2319
|
s.log.step("Opening your browser to sign in...");
|
|
2320
2320
|
try {
|
|
2321
|
-
let e = await
|
|
2322
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
2321
|
+
let e = await nr({ onUrl: (e) => {
|
|
2322
|
+
s.log.info(`If your browser didn't open, visit:\n ${z.path(e)}`);
|
|
2323
2323
|
} });
|
|
2324
2324
|
return s.log.success(e.email ? `Logged in as ${e.email}` : "Logged in"), e.token;
|
|
2325
2325
|
} catch (e) {
|
|
2326
2326
|
return s.log.error(e instanceof Error ? e.message : String(e)), null;
|
|
2327
2327
|
}
|
|
2328
2328
|
}
|
|
2329
|
-
async function
|
|
2329
|
+
async function ir(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) => ` ${z.brand(e.displayName)} ${z.highlight(`$${e.price}`)}`)
|
|
2335
2335
|
].join("\n"), "Locked Packs");
|
|
2336
2336
|
let t = await s.confirm({ message: `Open the purchase ${e.length === 1 ? "page" : "pages"} in your browser?` });
|
|
2337
2337
|
if (s.isCancel(t) || !t) {
|
|
2338
|
-
s.log.info(
|
|
2338
|
+
s.log.info(z.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)
|
|
2341
|
+
for (let t of e) $n(xe(t.name));
|
|
2342
2342
|
s.log.info([
|
|
2343
|
-
|
|
2344
|
-
` ${
|
|
2345
|
-
` ${
|
|
2343
|
+
z.muted("After purchasing, run:"),
|
|
2344
|
+
` ${z.highlight("npx @hype-stack/cli login")} ${z.muted("Save your access")}`,
|
|
2345
|
+
` ${z.highlight("npx @hype-stack/cli compose")} ${z.muted("Install the packs")}`
|
|
2346
2346
|
].join("\n"));
|
|
2347
2347
|
}
|
|
2348
2348
|
//#endregion
|
|
2349
2349
|
//#region src/utils/exec.ts
|
|
2350
|
-
function
|
|
2350
|
+
function K(e, t, n) {
|
|
2351
2351
|
return new Promise((r, i) => {
|
|
2352
2352
|
let a = D(e, t, {
|
|
2353
2353
|
cwd: n.cwd,
|
|
@@ -2378,103 +2378,145 @@ function q(e, t, n) {
|
|
|
2378
2378
|
});
|
|
2379
2379
|
});
|
|
2380
2380
|
}
|
|
2381
|
+
function ar(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
|
|
2398
|
+
async function q(e) {
|
|
2384
2399
|
return (await y.stat(e).catch(() => null))?.isDirectory() ?? !1;
|
|
2385
2400
|
}
|
|
2386
2401
|
async function J(e) {
|
|
2387
2402
|
return (await y.stat(e).catch(() => null))?.isFile() ?? !1;
|
|
2388
2403
|
}
|
|
2389
|
-
async function
|
|
2404
|
+
async function or(e) {
|
|
2390
2405
|
return (await y.readdir(e).catch(() => [])).length === 0;
|
|
2391
2406
|
}
|
|
2392
|
-
async function
|
|
2407
|
+
async function sr(e) {
|
|
2393
2408
|
let t = await y.readFile(e, "utf-8").catch(() => null);
|
|
2394
2409
|
return t ? JSON.parse(t) : null;
|
|
2395
2410
|
}
|
|
2396
|
-
async function
|
|
2411
|
+
async function cr(e, t) {
|
|
2397
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
|
|
2416
|
+
if (!await q(e)) return t;
|
|
2402
2417
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
2403
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
|
|
2421
|
+
async function ur(e) {
|
|
2407
2422
|
await y.rm(e, {
|
|
2408
2423
|
recursive: !0,
|
|
2409
2424
|
force: !0
|
|
2410
2425
|
});
|
|
2411
2426
|
}
|
|
2412
|
-
function
|
|
2427
|
+
function dr(e, t) {
|
|
2413
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
|
-
s.log.info(
|
|
2419
|
-
`${
|
|
2420
|
-
`${
|
|
2421
|
-
`${
|
|
2432
|
+
function fr(e) {
|
|
2433
|
+
s.log.info(z.muted("Run database setup yourself when ready:")), s.note([
|
|
2434
|
+
`${z.command(`cd ${e}`)}`,
|
|
2435
|
+
`${z.command("pnpm exec prisma generate")} ${z.muted("(regenerate the Prisma client)")}`,
|
|
2436
|
+
`${z.command("pnpm exec prisma migrate dev")} ${z.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 J(T.join(
|
|
2427
|
-
if (r) {
|
|
2428
|
-
|
|
2439
|
+
async function pr(e) {
|
|
2440
|
+
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, freshScaffold: a, runCommand: o = ar } = e, c = n.backend.root, l = T.join(t, c);
|
|
2441
|
+
if (!await J(T.join(l, "package.json"))) return;
|
|
2442
|
+
if (r || i === !1) {
|
|
2443
|
+
fr(c);
|
|
2429
2444
|
return;
|
|
2430
2445
|
}
|
|
2431
|
-
let
|
|
2432
|
-
message: `Run database setup now? (${
|
|
2446
|
+
let u = await s.confirm({
|
|
2447
|
+
message: `Run database setup now? (${z.command("prisma migrate dev")})`,
|
|
2433
2448
|
initialValue: !0
|
|
2434
2449
|
});
|
|
2435
|
-
if (s.isCancel(
|
|
2436
|
-
|
|
2450
|
+
if (s.isCancel(u) || !u) {
|
|
2451
|
+
fr(c);
|
|
2437
2452
|
return;
|
|
2438
2453
|
}
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
let u = await i("pnpm", [
|
|
2454
|
+
s.log.step(z.muted(`Running ${z.command("prisma migrate dev --name add-packs")}...`));
|
|
2455
|
+
let d = await o("pnpm", [
|
|
2442
2456
|
"exec",
|
|
2443
2457
|
"prisma",
|
|
2444
2458
|
"migrate",
|
|
2445
2459
|
"dev",
|
|
2446
2460
|
"--name",
|
|
2447
2461
|
"add-packs"
|
|
2448
|
-
], { cwd:
|
|
2449
|
-
if (
|
|
2450
|
-
|
|
2462
|
+
], { cwd: l });
|
|
2463
|
+
if (d.exitCode !== 0 && a) {
|
|
2464
|
+
let e = await s.confirm({
|
|
2465
|
+
message: "migrate dev hit drift between the database and the local migrations. Reset the dev database and retry?",
|
|
2466
|
+
initialValue: !0
|
|
2467
|
+
});
|
|
2468
|
+
if (!s.isCancel(e) && e) {
|
|
2469
|
+
s.log.step(z.muted(`Resetting dev database (${z.command("prisma migrate reset --force")})...`));
|
|
2470
|
+
let e = await o("pnpm", [
|
|
2471
|
+
"exec",
|
|
2472
|
+
"prisma",
|
|
2473
|
+
"migrate",
|
|
2474
|
+
"reset",
|
|
2475
|
+
"--force"
|
|
2476
|
+
], { cwd: l });
|
|
2477
|
+
if (e.exitCode === 0) s.log.step(z.muted(`Running ${z.command("prisma migrate dev --name add-packs")}...`)), d = await o("pnpm", [
|
|
2478
|
+
"exec",
|
|
2479
|
+
"prisma",
|
|
2480
|
+
"migrate",
|
|
2481
|
+
"dev",
|
|
2482
|
+
"--name",
|
|
2483
|
+
"add-packs"
|
|
2484
|
+
], { cwd: l });
|
|
2485
|
+
else {
|
|
2486
|
+
s.log.error(z.muted("prisma migrate reset did not complete. See the output above, or finish setup manually:")), mr(e), fr(c);
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
if (d.exitCode !== 0) {
|
|
2492
|
+
s.log.error(z.muted("prisma migrate dev did not complete. See the output above, or finish setup manually:")), mr(d), fr(c);
|
|
2451
2493
|
return;
|
|
2452
2494
|
}
|
|
2453
|
-
|
|
2495
|
+
s.log.success("Database schema applied");
|
|
2454
2496
|
}
|
|
2455
|
-
function
|
|
2497
|
+
function mr(e) {
|
|
2456
2498
|
let t = (e.stderr || e.stdout).trim();
|
|
2457
|
-
t && s.log.warn(
|
|
2499
|
+
t && s.log.warn(z.muted(t));
|
|
2458
2500
|
}
|
|
2459
2501
|
//#endregion
|
|
2460
2502
|
//#region src/core/stack-config.ts
|
|
2461
|
-
async function mr(e) {
|
|
2462
|
-
return or(T.join(e, ne));
|
|
2463
|
-
}
|
|
2464
2503
|
async function hr(e) {
|
|
2465
|
-
return
|
|
2504
|
+
return sr(T.join(e, M));
|
|
2505
|
+
}
|
|
2506
|
+
async function gr(e) {
|
|
2507
|
+
return J(T.join(e, M));
|
|
2466
2508
|
}
|
|
2467
|
-
async function
|
|
2468
|
-
await
|
|
2509
|
+
async function _r(e, t) {
|
|
2510
|
+
await cr(T.join(e, M), t);
|
|
2469
2511
|
}
|
|
2470
|
-
async function
|
|
2471
|
-
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([
|
|
2512
|
+
async function vr(e) {
|
|
2513
|
+
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([lr(t), lr(n)]);
|
|
2472
2514
|
return {
|
|
2473
2515
|
apps: r,
|
|
2474
2516
|
packages: i
|
|
2475
2517
|
};
|
|
2476
2518
|
}
|
|
2477
|
-
function
|
|
2519
|
+
function yr(e) {
|
|
2478
2520
|
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";
|
|
2479
2521
|
return {
|
|
2480
2522
|
backend: {
|
|
@@ -2508,20 +2550,20 @@ function vr(e) {
|
|
|
2508
2550
|
}
|
|
2509
2551
|
};
|
|
2510
2552
|
}
|
|
2511
|
-
function
|
|
2553
|
+
function br(e, t) {
|
|
2512
2554
|
return {
|
|
2513
|
-
$schema:
|
|
2555
|
+
$schema: le(),
|
|
2514
2556
|
version: 1,
|
|
2515
2557
|
name: e,
|
|
2516
2558
|
apps: t.apps,
|
|
2517
2559
|
packages: t.packages,
|
|
2518
|
-
paths:
|
|
2560
|
+
paths: yr(t),
|
|
2519
2561
|
installedPacks: [],
|
|
2520
2562
|
licenseKey: null
|
|
2521
2563
|
};
|
|
2522
2564
|
}
|
|
2523
|
-
async function
|
|
2524
|
-
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t),
|
|
2565
|
+
async function xr(e) {
|
|
2566
|
+
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t), q(n)]);
|
|
2525
2567
|
return r && i;
|
|
2526
2568
|
}
|
|
2527
2569
|
function Y(e, t) {
|
|
@@ -2535,8 +2577,8 @@ function Y(e, t) {
|
|
|
2535
2577
|
}
|
|
2536
2578
|
//#endregion
|
|
2537
2579
|
//#region src/core/registry.ts
|
|
2538
|
-
async function
|
|
2539
|
-
let { data: t, error: n, status: r } = await
|
|
2580
|
+
async function Sr(e) {
|
|
2581
|
+
let { data: t, error: n, status: r } = await G.createRequest()({
|
|
2540
2582
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2541
2583
|
method: "GET"
|
|
2542
2584
|
}).send();
|
|
@@ -2544,13 +2586,13 @@ async function xr(e) {
|
|
|
2544
2586
|
if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
|
|
2545
2587
|
return t;
|
|
2546
2588
|
}
|
|
2547
|
-
async function
|
|
2548
|
-
let n =
|
|
2589
|
+
async function Cr(e, t = {}) {
|
|
2590
|
+
let n = G.createRequest()({
|
|
2549
2591
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2550
2592
|
method: "POST"
|
|
2551
2593
|
}), r = {
|
|
2552
|
-
"X-Device-Id":
|
|
2553
|
-
"X-Client-Info":
|
|
2594
|
+
"X-Device-Id": Zn(),
|
|
2595
|
+
"X-Client-Info": Qn()
|
|
2554
2596
|
};
|
|
2555
2597
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2556
2598
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -2570,25 +2612,25 @@ async function Sr(e, t = {}) {
|
|
|
2570
2612
|
packDir: s
|
|
2571
2613
|
};
|
|
2572
2614
|
}
|
|
2573
|
-
function
|
|
2615
|
+
function wr(e, t, n) {
|
|
2574
2616
|
let r = Y(e, t);
|
|
2575
2617
|
return T.resolve(n, r);
|
|
2576
2618
|
}
|
|
2577
|
-
function
|
|
2619
|
+
function Tr(e, t) {
|
|
2578
2620
|
return T.join(t, e);
|
|
2579
2621
|
}
|
|
2580
|
-
var
|
|
2622
|
+
var Er = G.createRequest()({
|
|
2581
2623
|
endpoint: "/packs/list",
|
|
2582
2624
|
method: "GET"
|
|
2583
2625
|
});
|
|
2584
|
-
async function
|
|
2585
|
-
let { data: e, error: t } = await
|
|
2626
|
+
async function Dr() {
|
|
2627
|
+
let { data: e, error: t } = await Er.send();
|
|
2586
2628
|
if (t || !e) throw Error(`Failed to fetch pack list: ${String(t)}`);
|
|
2587
2629
|
return e.packs;
|
|
2588
2630
|
}
|
|
2589
|
-
async function
|
|
2631
|
+
async function Or(e, t = {}) {
|
|
2590
2632
|
if (e.length === 0) return {};
|
|
2591
|
-
let n =
|
|
2633
|
+
let n = G.createRequest()({
|
|
2592
2634
|
endpoint: "/packs/authorize",
|
|
2593
2635
|
method: "POST"
|
|
2594
2636
|
}), r = {};
|
|
@@ -2602,35 +2644,35 @@ async function Dr(e, t = {}) {
|
|
|
2602
2644
|
}
|
|
2603
2645
|
//#endregion
|
|
2604
2646
|
//#region src/core/codemods.ts
|
|
2605
|
-
var
|
|
2606
|
-
function
|
|
2647
|
+
var kr = "@hype-stack/";
|
|
2648
|
+
function Ar(e, t) {
|
|
2607
2649
|
return Y(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
|
|
2608
2650
|
}
|
|
2609
|
-
async function
|
|
2651
|
+
async function jr(e, t, n) {
|
|
2610
2652
|
let r = Y("{{backend.root}}", t), i = T.resolve(n, r, "src/config/env/env.config.ts"), a = T.resolve(n, r, ".env.example"), o = T.resolve(n, r, ".env.test");
|
|
2611
2653
|
if (await J(i)) {
|
|
2612
2654
|
let t = await y.readFile(i, "utf-8");
|
|
2613
|
-
for (let n of e) t.includes(`from "${n.from}"`) || (t =
|
|
2655
|
+
for (let n of e) t.includes(`from "${n.from}"`) || (t = Mr(t, n), t = Nr(t, n));
|
|
2614
2656
|
await y.writeFile(i, t, "utf-8");
|
|
2615
2657
|
}
|
|
2616
2658
|
if (await J(a)) {
|
|
2617
2659
|
let t = await y.readFile(a, "utf-8");
|
|
2618
|
-
for (let n of e) t =
|
|
2660
|
+
for (let n of e) t = Pr(t, n);
|
|
2619
2661
|
await y.writeFile(a, t, "utf-8");
|
|
2620
2662
|
}
|
|
2621
2663
|
if (await J(o)) {
|
|
2622
2664
|
let t = await y.readFile(o, "utf-8");
|
|
2623
|
-
for (let n of e) t =
|
|
2665
|
+
for (let n of e) t = Fr(t, n);
|
|
2624
2666
|
await y.writeFile(o, t, "utf-8");
|
|
2625
2667
|
}
|
|
2626
2668
|
}
|
|
2627
|
-
function
|
|
2669
|
+
function Mr(e, t) {
|
|
2628
2670
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2629
2671
|
if (r === -1) return n + "\n" + e;
|
|
2630
2672
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2631
2673
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2632
2674
|
}
|
|
2633
|
-
function
|
|
2675
|
+
function Nr(e, t) {
|
|
2634
2676
|
let n = `.extend(${t.import}.shape)`;
|
|
2635
2677
|
if (e.includes(n)) return e;
|
|
2636
2678
|
let r = e.indexOf("export const envSchema = z.object({");
|
|
@@ -2645,27 +2687,27 @@ function Mr(e, t) {
|
|
|
2645
2687
|
let o = a + 2;
|
|
2646
2688
|
return e.slice(0, o) + n + e.slice(o);
|
|
2647
2689
|
}
|
|
2648
|
-
function
|
|
2690
|
+
function Pr(e, t) {
|
|
2649
2691
|
for (let n of Object.keys(t.envExample.vars)) if (e.includes(`${n}=`)) return e;
|
|
2650
2692
|
let n = [];
|
|
2651
2693
|
n.push(""), n.push(`# ${t.envExample.section}`);
|
|
2652
2694
|
for (let [e, r] of Object.entries(t.envExample.vars)) n.push(`${e}=${r}`);
|
|
2653
2695
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2654
2696
|
}
|
|
2655
|
-
function
|
|
2697
|
+
function Fr(e, t) {
|
|
2656
2698
|
for (let n of Object.keys(t.envTest)) if (e.includes(`${n}=`)) return e;
|
|
2657
2699
|
let n = [""];
|
|
2658
2700
|
for (let [e, r] of Object.entries(t.envTest)) n.push(`${e}=${r}`);
|
|
2659
2701
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2660
2702
|
}
|
|
2661
|
-
async function
|
|
2703
|
+
async function Ir(e, t, n) {
|
|
2662
2704
|
let r = T.resolve(n, Y("{{backend.routes}}", t), "index.ts");
|
|
2663
2705
|
if (!await J(r)) return;
|
|
2664
2706
|
let i = await y.readFile(r, "utf-8");
|
|
2665
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2707
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Lr(i, t), i = Rr(i, t));
|
|
2666
2708
|
await y.writeFile(r, i, "utf-8");
|
|
2667
2709
|
}
|
|
2668
|
-
function
|
|
2710
|
+
function Lr(e, t) {
|
|
2669
2711
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2670
2712
|
if (r !== -1) {
|
|
2671
2713
|
let t = e.indexOf("\n", r);
|
|
@@ -2674,7 +2716,7 @@ function Ir(e, t) {
|
|
|
2674
2716
|
let i = e.indexOf("export const registerRoutes");
|
|
2675
2717
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2676
2718
|
}
|
|
2677
|
-
function
|
|
2719
|
+
function Rr(e, t) {
|
|
2678
2720
|
let n = `.route("${t.prefix}", ${t.import})`, r = e.match(/\.route\([^)]+\);/g);
|
|
2679
2721
|
if (r) {
|
|
2680
2722
|
let t = r[r.length - 1], i = e.lastIndexOf(t) + t.length - 1;
|
|
@@ -2682,14 +2724,14 @@ function Lr(e, t) {
|
|
|
2682
2724
|
}
|
|
2683
2725
|
return e.replace("return app;", `return app\n ${n};`);
|
|
2684
2726
|
}
|
|
2685
|
-
async function
|
|
2727
|
+
async function zr(e, t, n) {
|
|
2686
2728
|
let r = T.resolve(n, Y("{{backend.root}}", t), "src/context.ts");
|
|
2687
2729
|
if (!await J(r)) return;
|
|
2688
2730
|
let i = await y.readFile(r, "utf-8");
|
|
2689
|
-
for (let t of e) i.includes(`export let ${t.export}`) || (i =
|
|
2731
|
+
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));
|
|
2690
2732
|
await y.writeFile(r, i, "utf-8");
|
|
2691
2733
|
}
|
|
2692
|
-
function
|
|
2734
|
+
function Br(e, t) {
|
|
2693
2735
|
let n = `import { ${t.typeImport.name} } from "${t.typeImport.from}";`;
|
|
2694
2736
|
if (e.includes(`from "${t.typeImport.from}"`)) return e;
|
|
2695
2737
|
let r = e.lastIndexOf("import ");
|
|
@@ -2697,7 +2739,7 @@ function zr(e, t) {
|
|
|
2697
2739
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2698
2740
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2699
2741
|
}
|
|
2700
|
-
function
|
|
2742
|
+
function Vr(e, t) {
|
|
2701
2743
|
let n = `export let ${t.export}: ${t.type};`, r = e.lastIndexOf("export let ");
|
|
2702
2744
|
if (r === -1) {
|
|
2703
2745
|
let t = e.indexOf("export const setupContext");
|
|
@@ -2706,15 +2748,15 @@ function Br(e, t) {
|
|
|
2706
2748
|
let i = e.indexOf("\n", r);
|
|
2707
2749
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2708
2750
|
}
|
|
2709
|
-
function
|
|
2751
|
+
function Hr(e, t) {
|
|
2710
2752
|
let n = ` ${t.export} = ${t.init};`, r = e.match(/export const setupContext\s*=\s*async\s*\([^)]*\)\s*=>\s*\{/);
|
|
2711
2753
|
if (!r) return e;
|
|
2712
2754
|
let i = e.indexOf("{", e.indexOf(r[0]));
|
|
2713
2755
|
if (i === -1) return e;
|
|
2714
|
-
let a =
|
|
2756
|
+
let a = Ur(e, i);
|
|
2715
2757
|
return a === -1 ? e : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2716
2758
|
}
|
|
2717
|
-
function
|
|
2759
|
+
function Ur(e, t) {
|
|
2718
2760
|
let n = 0;
|
|
2719
2761
|
for (let r = t; r < e.length; r++) {
|
|
2720
2762
|
let t = e[r];
|
|
@@ -2723,20 +2765,20 @@ function Hr(e, t) {
|
|
|
2723
2765
|
}
|
|
2724
2766
|
return -1;
|
|
2725
2767
|
}
|
|
2726
|
-
function
|
|
2768
|
+
function Wr(e, t) {
|
|
2727
2769
|
let n = ` ${t.export}: ${t.type};`, r = e.indexOf("export type ContextVariables = {");
|
|
2728
2770
|
if (r === -1) return e;
|
|
2729
2771
|
let i = e.indexOf("};", r);
|
|
2730
2772
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2731
2773
|
}
|
|
2732
|
-
async function
|
|
2774
|
+
async function Gr(e, t, n) {
|
|
2733
2775
|
let r = T.resolve(n, Y("{{enums.src}}", t), "index.ts");
|
|
2734
2776
|
if (!await J(r)) return;
|
|
2735
2777
|
let i = await y.readFile(r, "utf-8");
|
|
2736
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2778
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Kr(i, t));
|
|
2737
2779
|
await y.writeFile(r, i, "utf-8");
|
|
2738
2780
|
}
|
|
2739
|
-
function
|
|
2781
|
+
function Kr(e, t) {
|
|
2740
2782
|
let n = `export * from "${t.from}";`, r = e.lastIndexOf("export * from");
|
|
2741
2783
|
if (r !== -1) {
|
|
2742
2784
|
let t = e.indexOf("\n", r);
|
|
@@ -2744,14 +2786,14 @@ function Gr(e, t) {
|
|
|
2744
2786
|
}
|
|
2745
2787
|
return e.trim() === "" ? n + "\n" : e.trimEnd() + "\n" + n + "\n";
|
|
2746
2788
|
}
|
|
2747
|
-
async function
|
|
2789
|
+
async function qr(e, t, n) {
|
|
2748
2790
|
let r = Y("{{backend.root}}", t), i = T.resolve(n, r, "src/sockets/index.ts");
|
|
2749
2791
|
if (!await J(i)) return;
|
|
2750
2792
|
let a = await y.readFile(i, "utf-8");
|
|
2751
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2752
|
-
await J(T.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a =
|
|
2793
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = Jr(a, t), a = Yr(a, t));
|
|
2794
|
+
await J(T.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a = Xr(a)), await y.writeFile(i, a, "utf-8");
|
|
2753
2795
|
}
|
|
2754
|
-
function
|
|
2796
|
+
function Jr(e, t) {
|
|
2755
2797
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2756
2798
|
if (r !== -1) {
|
|
2757
2799
|
let t = e.indexOf("\n", r);
|
|
@@ -2760,7 +2802,7 @@ function qr(e, t) {
|
|
|
2760
2802
|
let i = e.indexOf("const sockets");
|
|
2761
2803
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2762
2804
|
}
|
|
2763
|
-
function
|
|
2805
|
+
function Yr(e, t) {
|
|
2764
2806
|
let n = `.socket("${t.prefix}", ${t.import})`, r = e.indexOf("const sockets");
|
|
2765
2807
|
if (r === -1) return e;
|
|
2766
2808
|
let i = e.indexOf("new SocketRouter", r);
|
|
@@ -2774,7 +2816,7 @@ function Jr(e, t) {
|
|
|
2774
2816
|
}
|
|
2775
2817
|
return e;
|
|
2776
2818
|
}
|
|
2777
|
-
function
|
|
2819
|
+
function Xr(e) {
|
|
2778
2820
|
if (e.includes("wsAuthenticate")) return e;
|
|
2779
2821
|
let t = e.indexOf("from \"@backend/libs/websocket/socket-router\""), n = e;
|
|
2780
2822
|
if (t !== -1) {
|
|
@@ -2783,14 +2825,14 @@ function Yr(e) {
|
|
|
2783
2825
|
}
|
|
2784
2826
|
return n.replace("new SocketRouter()", "new SocketRouter({ authenticate: wsAuthenticate })");
|
|
2785
2827
|
}
|
|
2786
|
-
async function
|
|
2828
|
+
async function Zr(e, t, n) {
|
|
2787
2829
|
let r = Y("{{frontend.root}}", t), i = T.resolve(n, r, "src/api/sdk.ts");
|
|
2788
2830
|
if (!await J(i)) return;
|
|
2789
2831
|
let a = await y.readFile(i, "utf-8");
|
|
2790
|
-
for (let t of e) a.includes(`.$configure(${t.import})`) || (a =
|
|
2832
|
+
for (let t of e) a.includes(`.$configure(${t.import})`) || (a = Qr(a, t), a = $r(a, t));
|
|
2791
2833
|
await y.writeFile(i, a, "utf-8");
|
|
2792
2834
|
}
|
|
2793
|
-
function
|
|
2835
|
+
function Qr(e, t) {
|
|
2794
2836
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2795
2837
|
if (e.includes(n)) return e;
|
|
2796
2838
|
let r = e.lastIndexOf("from \"./");
|
|
@@ -2801,20 +2843,20 @@ function Zr(e, t) {
|
|
|
2801
2843
|
let i = e.indexOf("export const sdk");
|
|
2802
2844
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2803
2845
|
}
|
|
2804
|
-
function
|
|
2846
|
+
function $r(e, t) {
|
|
2805
2847
|
let n = `.$configure(${t.import})`, r = e.indexOf("export const sdk");
|
|
2806
2848
|
if (r === -1) return e;
|
|
2807
2849
|
let i = e.indexOf(";", r);
|
|
2808
2850
|
return i === -1 ? e : e.slice(0, i) + "\n " + n + e.slice(i);
|
|
2809
2851
|
}
|
|
2810
|
-
async function
|
|
2852
|
+
async function ei(e, t, n) {
|
|
2811
2853
|
let r = T.resolve(n, Y("{{backend.utils}}", t), "frontend-url/frontend-url.ts");
|
|
2812
2854
|
if (!await J(r)) return;
|
|
2813
2855
|
let i = await y.readFile(r, "utf-8");
|
|
2814
|
-
for (let t of e) i.includes(`"${t.path}"`) || (i =
|
|
2856
|
+
for (let t of e) i.includes(`"${t.path}"`) || (i = ti(i, t));
|
|
2815
2857
|
await y.writeFile(r, i, "utf-8");
|
|
2816
2858
|
}
|
|
2817
|
-
function
|
|
2859
|
+
function ti(e, t) {
|
|
2818
2860
|
let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
|
|
2819
2861
|
if (r === -1) return e;
|
|
2820
2862
|
let i = e.indexOf("{", r);
|
|
@@ -2830,38 +2872,38 @@ function ei(e, t) {
|
|
|
2830
2872
|
}
|
|
2831
2873
|
return o === -1 ? e : e.slice(0, o) + n + "\n" + e.slice(o);
|
|
2832
2874
|
}
|
|
2833
|
-
var
|
|
2875
|
+
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 = {
|
|
2834
2876
|
primary: "primaryNav",
|
|
2835
2877
|
secondary: "secondaryNav",
|
|
2836
2878
|
tertiary: "tertiaryNav",
|
|
2837
2879
|
settings: "settingsNav"
|
|
2838
2880
|
};
|
|
2839
|
-
async function
|
|
2840
|
-
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2841
|
-
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s =
|
|
2842
|
-
for (let e of t) s.includes(`label: "${e.label}"`) || (s =
|
|
2843
|
-
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s =
|
|
2881
|
+
async function ii(e) {
|
|
2882
|
+
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;
|
|
2883
|
+
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = ni);
|
|
2884
|
+
for (let e of t) s.includes(`label: "${e.label}"`) || (s = si(s, e));
|
|
2885
|
+
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s = li(s, e));
|
|
2844
2886
|
await y.writeFile(o, s, "utf-8");
|
|
2845
2887
|
}
|
|
2846
|
-
async function
|
|
2847
|
-
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2888
|
+
async function ai(e) {
|
|
2889
|
+
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");
|
|
2848
2890
|
if (!await J(o)) return;
|
|
2849
2891
|
let s = await y.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
|
|
2850
2892
|
if (!c.test(s)) return;
|
|
2851
2893
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
2852
2894
|
await y.writeFile(o, l, "utf-8");
|
|
2853
2895
|
}
|
|
2854
|
-
function
|
|
2896
|
+
function oi(e) {
|
|
2855
2897
|
let t = [e.icon];
|
|
2856
2898
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
2857
2899
|
return t;
|
|
2858
2900
|
}
|
|
2859
|
-
function
|
|
2860
|
-
let n =
|
|
2861
|
-
for (let e of n) r =
|
|
2901
|
+
function si(e, t) {
|
|
2902
|
+
let n = oi(t), r = e;
|
|
2903
|
+
for (let e of n) r = ci(r, e);
|
|
2862
2904
|
return r;
|
|
2863
2905
|
}
|
|
2864
|
-
function
|
|
2906
|
+
function ci(e, t) {
|
|
2865
2907
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
2866
2908
|
if (!n) return e;
|
|
2867
2909
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -2869,21 +2911,21 @@ function si(e, t) {
|
|
|
2869
2911
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
2870
2912
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
2871
2913
|
}
|
|
2872
|
-
function
|
|
2873
|
-
let n =
|
|
2914
|
+
function li(e, t) {
|
|
2915
|
+
let n = ri[t.group];
|
|
2874
2916
|
if (!n) return e;
|
|
2875
|
-
let r =
|
|
2917
|
+
let r = di(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
|
|
2876
2918
|
if (!a) return e;
|
|
2877
|
-
let o = e.indexOf(a[0]) + a[0].length, s =
|
|
2919
|
+
let o = e.indexOf(a[0]) + a[0].length, s = ui(e, o - 1);
|
|
2878
2920
|
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);
|
|
2879
2921
|
}
|
|
2880
|
-
function
|
|
2922
|
+
function ui(e, t) {
|
|
2881
2923
|
let n = 0;
|
|
2882
2924
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2883
2925
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2884
2926
|
return -1;
|
|
2885
2927
|
}
|
|
2886
|
-
function
|
|
2928
|
+
function di(e) {
|
|
2887
2929
|
let t = [];
|
|
2888
2930
|
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) {
|
|
2889
2931
|
t.push(" items: [");
|
|
@@ -2899,14 +2941,14 @@ function ui(e) {
|
|
|
2899
2941
|
} else t.push(" items: [],");
|
|
2900
2942
|
return t.push(" },"), t.join("\n");
|
|
2901
2943
|
}
|
|
2902
|
-
async function
|
|
2944
|
+
async function fi(e, t, n) {
|
|
2903
2945
|
let r = Y("{{backend.features}}", t), i = T.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
|
|
2904
2946
|
if (!await J(i)) return;
|
|
2905
2947
|
let a = await y.readFile(i, "utf-8");
|
|
2906
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2948
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = pi(a, t), a = mi(a, t));
|
|
2907
2949
|
await y.writeFile(i, a, "utf-8");
|
|
2908
2950
|
}
|
|
2909
|
-
function
|
|
2951
|
+
function pi(e, t) {
|
|
2910
2952
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2911
2953
|
if (r !== -1) {
|
|
2912
2954
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -2914,38 +2956,38 @@ function fi(e, t) {
|
|
|
2914
2956
|
}
|
|
2915
2957
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
2916
2958
|
}
|
|
2917
|
-
function
|
|
2959
|
+
function mi(e, t) {
|
|
2918
2960
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
2919
2961
|
if (!r) return e;
|
|
2920
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2962
|
+
let i = e.indexOf(r[0]) + r[0].length, a = hi(e, i - 1);
|
|
2921
2963
|
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);
|
|
2922
2964
|
}
|
|
2923
|
-
function
|
|
2965
|
+
function hi(e, t) {
|
|
2924
2966
|
let n = 0;
|
|
2925
2967
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2926
2968
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2927
2969
|
return -1;
|
|
2928
2970
|
}
|
|
2929
|
-
var
|
|
2930
|
-
async function
|
|
2931
|
-
await
|
|
2971
|
+
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";
|
|
2972
|
+
async function _i(e) {
|
|
2973
|
+
await yi({
|
|
2932
2974
|
...e,
|
|
2933
2975
|
arrayName: "navbarActions"
|
|
2934
2976
|
});
|
|
2935
2977
|
}
|
|
2936
|
-
async function
|
|
2937
|
-
await
|
|
2978
|
+
async function vi(e) {
|
|
2979
|
+
await yi({
|
|
2938
2980
|
...e,
|
|
2939
2981
|
arrayName: "userMenuActions"
|
|
2940
2982
|
});
|
|
2941
2983
|
}
|
|
2942
|
-
async function
|
|
2943
|
-
let a =
|
|
2944
|
-
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s =
|
|
2945
|
-
for (let n of e) s =
|
|
2984
|
+
async function yi({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
|
|
2985
|
+
let a = Ar(i, n), o = T.resolve(r, a, "src/constants/navbar-actions.tsx"), s;
|
|
2986
|
+
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = gi);
|
|
2987
|
+
for (let n of e) s = bi(s, n), s = xi(s, n, t);
|
|
2946
2988
|
await y.writeFile(o, s, "utf-8");
|
|
2947
2989
|
}
|
|
2948
|
-
function
|
|
2990
|
+
function bi(e, t) {
|
|
2949
2991
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2950
2992
|
if (e.includes(n)) return e;
|
|
2951
2993
|
let r = e.lastIndexOf("import ");
|
|
@@ -2953,38 +2995,38 @@ function yi(e, t) {
|
|
|
2953
2995
|
let i = e.indexOf("\n", r);
|
|
2954
2996
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2955
2997
|
}
|
|
2956
|
-
function
|
|
2998
|
+
function xi(e, t, n) {
|
|
2957
2999
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
2958
3000
|
if (!r) return e;
|
|
2959
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
3001
|
+
let i = e.indexOf(r[0]) + r[0].length, a = Si(e, i - 1);
|
|
2960
3002
|
if (a === -1) return e;
|
|
2961
3003
|
let o = e.slice(i, a);
|
|
2962
3004
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
2963
3005
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
2964
3006
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
2965
3007
|
}
|
|
2966
|
-
function
|
|
3008
|
+
function Si(e, t) {
|
|
2967
3009
|
let n = 0;
|
|
2968
3010
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2969
3011
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2970
3012
|
return -1;
|
|
2971
3013
|
}
|
|
2972
|
-
var
|
|
3014
|
+
var Ci = new Set([
|
|
2973
3015
|
".ts",
|
|
2974
3016
|
".tsx",
|
|
2975
3017
|
".js",
|
|
2976
3018
|
".jsx"
|
|
2977
3019
|
]);
|
|
2978
|
-
async function
|
|
3020
|
+
async function wi(e) {
|
|
2979
3021
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
2980
3022
|
if (i === "hype-stack") return;
|
|
2981
3023
|
let a = `@${i}/`;
|
|
2982
3024
|
await Promise.all(t.map(async (e) => {
|
|
2983
|
-
let t =
|
|
2984
|
-
i?.isDirectory() ? await
|
|
3025
|
+
let t = wr(e.target, n, r), i = await y.stat(t).catch(() => null);
|
|
3026
|
+
i?.isDirectory() ? await Di(t, a) : i?.isFile() && Ci.has(T.extname(t)) && await Oi(t, a);
|
|
2985
3027
|
}));
|
|
2986
3028
|
}
|
|
2987
|
-
var
|
|
3029
|
+
var Ti = new Set([
|
|
2988
3030
|
".git",
|
|
2989
3031
|
"node_modules",
|
|
2990
3032
|
"dist",
|
|
@@ -2993,43 +3035,43 @@ var wi = new Set([
|
|
|
2993
3035
|
".next",
|
|
2994
3036
|
"coverage"
|
|
2995
3037
|
]);
|
|
2996
|
-
async function Ti(e, t) {
|
|
2997
|
-
t !== "hype-stack" && await Ei(e, `@${t}/`);
|
|
2998
|
-
}
|
|
2999
3038
|
async function Ei(e, t) {
|
|
3039
|
+
t !== "hype-stack" && await Di(e, `@${t}/`);
|
|
3040
|
+
}
|
|
3041
|
+
async function Di(e, t) {
|
|
3000
3042
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3001
3043
|
await Promise.all(n.map(async (n) => {
|
|
3002
3044
|
let r = T.join(e, n.name);
|
|
3003
3045
|
if (n.isDirectory()) {
|
|
3004
|
-
if (
|
|
3005
|
-
await
|
|
3006
|
-
} else n.isFile() &&
|
|
3046
|
+
if (Ti.has(n.name)) return;
|
|
3047
|
+
await Di(r, t);
|
|
3048
|
+
} else n.isFile() && Ci.has(T.extname(n.name)) && await Oi(r, t);
|
|
3007
3049
|
}));
|
|
3008
3050
|
}
|
|
3009
|
-
async function
|
|
3051
|
+
async function Oi(e, t) {
|
|
3010
3052
|
let n = await y.readFile(e, "utf-8");
|
|
3011
|
-
if (!n.includes(
|
|
3012
|
-
let r = n.replaceAll(
|
|
3053
|
+
if (!n.includes(kr)) return;
|
|
3054
|
+
let r = n.replaceAll(kr, t);
|
|
3013
3055
|
await y.writeFile(e, r, "utf-8");
|
|
3014
3056
|
}
|
|
3015
3057
|
//#endregion
|
|
3016
3058
|
//#region src/core/installer.ts
|
|
3017
|
-
function
|
|
3059
|
+
function ki(e, t) {
|
|
3018
3060
|
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3019
3061
|
}
|
|
3020
|
-
async function
|
|
3062
|
+
async function Ai(e, t) {
|
|
3021
3063
|
if ((await y.stat(e)).isDirectory()) {
|
|
3022
3064
|
await y.mkdir(t, { recursive: !0 });
|
|
3023
3065
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3024
|
-
for (let r of n) await
|
|
3066
|
+
for (let r of n) await Ai(T.join(e, r.name), T.join(t, r.name));
|
|
3025
3067
|
} else await y.mkdir(T.dirname(t), { recursive: !0 }), await y.copyFile(e, t);
|
|
3026
3068
|
}
|
|
3027
|
-
async function
|
|
3069
|
+
async function ji(e) {
|
|
3028
3070
|
let { src: t, dest: n, projectRoot: r, skip: i } = e;
|
|
3029
3071
|
if ((await y.stat(t)).isDirectory()) {
|
|
3030
3072
|
await y.mkdir(n, { recursive: !0 });
|
|
3031
3073
|
let e = await y.readdir(t, { withFileTypes: !0 });
|
|
3032
|
-
return (await Promise.all(e.map((e) =>
|
|
3074
|
+
return (await Promise.all(e.map((e) => ji({
|
|
3033
3075
|
src: T.join(t, e.name),
|
|
3034
3076
|
dest: T.join(n, e.name),
|
|
3035
3077
|
projectRoot: r,
|
|
@@ -3038,17 +3080,17 @@ async function Ai(e) {
|
|
|
3038
3080
|
}
|
|
3039
3081
|
return i.has(t) ? [] : (await y.mkdir(T.dirname(n), { recursive: !0 }), await y.copyFile(t, n), [T.relative(r, n)]);
|
|
3040
3082
|
}
|
|
3041
|
-
async function
|
|
3042
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a =
|
|
3083
|
+
async function Mi(e) {
|
|
3084
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = Tr(t.source, n), o = wr(t.target, r, i);
|
|
3043
3085
|
return {
|
|
3044
3086
|
sourcePath: a,
|
|
3045
3087
|
targetPath: o,
|
|
3046
|
-
sourceExists: await J(a) || await
|
|
3047
|
-
targetExists: await J(o) || await
|
|
3088
|
+
sourceExists: await J(a) || await q(a),
|
|
3089
|
+
targetExists: await J(o) || await q(o)
|
|
3048
3090
|
};
|
|
3049
3091
|
}
|
|
3050
|
-
async function
|
|
3051
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await
|
|
3092
|
+
async function Ni(e) {
|
|
3093
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await Mi({
|
|
3052
3094
|
file: t,
|
|
3053
3095
|
packDir: n,
|
|
3054
3096
|
paths: r,
|
|
@@ -3063,8 +3105,8 @@ async function Mi(e) {
|
|
|
3063
3105
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3064
3106
|
}
|
|
3065
3107
|
}
|
|
3066
|
-
async function
|
|
3067
|
-
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await
|
|
3108
|
+
async function Pi(e) {
|
|
3109
|
+
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await Mi({
|
|
3068
3110
|
file: t,
|
|
3069
3111
|
packDir: n,
|
|
3070
3112
|
paths: r,
|
|
@@ -3082,7 +3124,7 @@ async function Ni(e) {
|
|
|
3082
3124
|
status: "skipped",
|
|
3083
3125
|
path: t.target,
|
|
3084
3126
|
reason: "Already exists"
|
|
3085
|
-
} : (await
|
|
3127
|
+
} : (await Ai(s, c), {
|
|
3086
3128
|
status: "installed",
|
|
3087
3129
|
path: t.target
|
|
3088
3130
|
});
|
|
@@ -3091,16 +3133,16 @@ async function Ni(e) {
|
|
|
3091
3133
|
status: "skipped",
|
|
3092
3134
|
path: t.target,
|
|
3093
3135
|
reason: "Already exists (skip-if-exists)"
|
|
3094
|
-
} : (await
|
|
3136
|
+
} : (await Ai(s, c), {
|
|
3095
3137
|
status: "installed",
|
|
3096
3138
|
path: t.target
|
|
3097
3139
|
});
|
|
3098
|
-
case "override": return await
|
|
3140
|
+
case "override": return await Ai(s, c), {
|
|
3099
3141
|
status: "installed",
|
|
3100
3142
|
path: t.target
|
|
3101
3143
|
};
|
|
3102
3144
|
case "merge": {
|
|
3103
|
-
if (!u) return await
|
|
3145
|
+
if (!u) return await Ai(s, c), {
|
|
3104
3146
|
status: "installed",
|
|
3105
3147
|
path: t.target
|
|
3106
3148
|
};
|
|
@@ -3130,15 +3172,15 @@ async function Ni(e) {
|
|
|
3130
3172
|
};
|
|
3131
3173
|
}
|
|
3132
3174
|
}
|
|
3133
|
-
async function
|
|
3175
|
+
async function Fi(e) {
|
|
3134
3176
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3135
3177
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3136
3178
|
let o = [], s = /* @__PURE__ */ new Set();
|
|
3137
3179
|
for (let e of t) {
|
|
3138
3180
|
let t = i?.get(e.manifest.name);
|
|
3139
3181
|
for (let n of e.manifest.files) {
|
|
3140
|
-
if (n.strategy !== "create" || !
|
|
3141
|
-
let { targetPath: i, targetExists: c } = await
|
|
3182
|
+
if (n.strategy !== "create" || !ki(n, t)) continue;
|
|
3183
|
+
let { targetPath: i, targetExists: c } = await Mi({
|
|
3142
3184
|
file: n,
|
|
3143
3185
|
packDir: e.packDir,
|
|
3144
3186
|
paths: a,
|
|
@@ -3153,13 +3195,13 @@ async function Pi(e) {
|
|
|
3153
3195
|
}
|
|
3154
3196
|
return o;
|
|
3155
3197
|
}
|
|
3156
|
-
async function
|
|
3198
|
+
async function Ii(e) {
|
|
3157
3199
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3158
3200
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3159
3201
|
let c = [];
|
|
3160
3202
|
for (let e of t.files) {
|
|
3161
|
-
if (!
|
|
3162
|
-
let t = await
|
|
3203
|
+
if (!ki(e, o)) continue;
|
|
3204
|
+
let t = await Ni({
|
|
3163
3205
|
file: e,
|
|
3164
3206
|
packDir: a,
|
|
3165
3207
|
paths: s,
|
|
@@ -3170,16 +3212,16 @@ async function Fi(e) {
|
|
|
3170
3212
|
}
|
|
3171
3213
|
return c;
|
|
3172
3214
|
}
|
|
3173
|
-
async function
|
|
3215
|
+
async function Li(e) {
|
|
3174
3216
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3175
3217
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3176
3218
|
let l = {
|
|
3177
3219
|
installed: [],
|
|
3178
3220
|
skipped: [],
|
|
3179
3221
|
errors: []
|
|
3180
|
-
}, u = t.files.filter((e) =>
|
|
3222
|
+
}, u = t.files.filter((e) => ki(e, s));
|
|
3181
3223
|
for (let e of u) {
|
|
3182
|
-
let t = await
|
|
3224
|
+
let t = await Pi({
|
|
3183
3225
|
file: e,
|
|
3184
3226
|
packDir: o,
|
|
3185
3227
|
paths: c,
|
|
@@ -3199,40 +3241,40 @@ async function Ii(e) {
|
|
|
3199
3241
|
break;
|
|
3200
3242
|
}
|
|
3201
3243
|
}
|
|
3202
|
-
await
|
|
3244
|
+
await wi({
|
|
3203
3245
|
files: u,
|
|
3204
3246
|
paths: c,
|
|
3205
3247
|
projectRoot: r,
|
|
3206
3248
|
projectName: n.name
|
|
3207
|
-
}), t.env && t.env.length > 0 && await
|
|
3249
|
+
}), 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);
|
|
3208
3250
|
let d = s && s.length > 0 ? s : ["frontend"];
|
|
3209
|
-
for (let e of d) t.nav && t.nav.length > 0 && await
|
|
3251
|
+
for (let e of d) t.nav && t.nav.length > 0 && await ii({
|
|
3210
3252
|
entries: t.nav,
|
|
3211
3253
|
paths: c,
|
|
3212
3254
|
projectRoot: r,
|
|
3213
3255
|
slot: e
|
|
3214
|
-
}), t.navbarActions && t.navbarActions.length > 0 && await
|
|
3256
|
+
}), t.navbarActions && t.navbarActions.length > 0 && await _i({
|
|
3215
3257
|
actions: t.navbarActions,
|
|
3216
3258
|
paths: c,
|
|
3217
3259
|
projectRoot: r,
|
|
3218
3260
|
slot: e
|
|
3219
|
-
}), t.userMenuActions && t.userMenuActions.length > 0 && await
|
|
3261
|
+
}), t.userMenuActions && t.userMenuActions.length > 0 && await vi({
|
|
3220
3262
|
actions: t.userMenuActions,
|
|
3221
3263
|
paths: c,
|
|
3222
3264
|
projectRoot: r,
|
|
3223
3265
|
slot: e
|
|
3224
3266
|
});
|
|
3225
|
-
return t.onboardingSteps && t.onboardingSteps.length > 0 && await
|
|
3267
|
+
return t.onboardingSteps && t.onboardingSteps.length > 0 && await fi(t.onboardingSteps, c, r), t.postLoginRedirect && await ai({
|
|
3226
3268
|
postLoginRedirect: t.postLoginRedirect,
|
|
3227
3269
|
paths: c,
|
|
3228
3270
|
projectRoot: r,
|
|
3229
3271
|
slot: d[0]
|
|
3230
3272
|
}), l;
|
|
3231
3273
|
}
|
|
3232
|
-
async function
|
|
3274
|
+
async function Ri(e) {
|
|
3233
3275
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3234
3276
|
for (let e of t) {
|
|
3235
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3277
|
+
let t = o?.get(e.manifest.name), a = await Ii({
|
|
3236
3278
|
manifest: e.manifest,
|
|
3237
3279
|
config: n,
|
|
3238
3280
|
projectRoot: r,
|
|
@@ -3252,7 +3294,7 @@ async function Li(e) {
|
|
|
3252
3294
|
};
|
|
3253
3295
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3254
3296
|
for (let e of t) {
|
|
3255
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3297
|
+
let t = o?.get(e.manifest.name), n = await Li({
|
|
3256
3298
|
manifest: e.manifest,
|
|
3257
3299
|
config: f,
|
|
3258
3300
|
projectRoot: r,
|
|
@@ -3261,7 +3303,7 @@ async function Li(e) {
|
|
|
3261
3303
|
packDir: e.packDir,
|
|
3262
3304
|
slots: t
|
|
3263
3305
|
});
|
|
3264
|
-
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await
|
|
3306
|
+
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);
|
|
3265
3307
|
}
|
|
3266
3308
|
return {
|
|
3267
3309
|
installed: c,
|
|
@@ -3272,24 +3314,24 @@ async function Li(e) {
|
|
|
3272
3314
|
config: f
|
|
3273
3315
|
};
|
|
3274
3316
|
}
|
|
3275
|
-
async function
|
|
3317
|
+
async function zi(e, t, n) {
|
|
3276
3318
|
let r = {
|
|
3277
3319
|
...e,
|
|
3278
3320
|
installedPacks: [...e.installedPacks ?? [], t]
|
|
3279
3321
|
};
|
|
3280
|
-
return await
|
|
3322
|
+
return await _r(n, r), r;
|
|
3281
3323
|
}
|
|
3282
|
-
async function
|
|
3324
|
+
async function Bi(e) {
|
|
3283
3325
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3284
3326
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3285
|
-
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) =>
|
|
3286
|
-
if (await
|
|
3327
|
+
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");
|
|
3328
|
+
if (await q(u)) {
|
|
3287
3329
|
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3288
3330
|
for (let t of e) {
|
|
3289
3331
|
if (!t.isDirectory()) continue;
|
|
3290
3332
|
let e = a[t.name]?.root;
|
|
3291
3333
|
if (!e) continue;
|
|
3292
|
-
let n = await
|
|
3334
|
+
let n = await ji({
|
|
3293
3335
|
src: T.join(u, t.name),
|
|
3294
3336
|
dest: T.resolve(r, e),
|
|
3295
3337
|
projectRoot: r,
|
|
@@ -3299,7 +3341,7 @@ async function zi(e) {
|
|
|
3299
3341
|
}
|
|
3300
3342
|
}
|
|
3301
3343
|
for (let e of c) {
|
|
3302
|
-
let t = await
|
|
3344
|
+
let t = await Pi({
|
|
3303
3345
|
file: e,
|
|
3304
3346
|
packDir: i,
|
|
3305
3347
|
paths: a,
|
|
@@ -3309,12 +3351,12 @@ async function zi(e) {
|
|
|
3309
3351
|
});
|
|
3310
3352
|
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3311
3353
|
}
|
|
3312
|
-
let d = T.join(
|
|
3313
|
-
return await J(f) && await J(p) && await y.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await
|
|
3354
|
+
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");
|
|
3355
|
+
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({
|
|
3314
3356
|
entries: t.nav,
|
|
3315
3357
|
paths: a,
|
|
3316
3358
|
projectRoot: r
|
|
3317
|
-
}), t.postLoginRedirect && await
|
|
3359
|
+
}), t.postLoginRedirect && await ai({
|
|
3318
3360
|
postLoginRedirect: t.postLoginRedirect,
|
|
3319
3361
|
paths: a,
|
|
3320
3362
|
projectRoot: r
|
|
@@ -3325,28 +3367,28 @@ async function zi(e) {
|
|
|
3325
3367
|
}
|
|
3326
3368
|
//#endregion
|
|
3327
3369
|
//#region src/core/pack-categories.ts
|
|
3328
|
-
var
|
|
3370
|
+
var Vi = [
|
|
3329
3371
|
"starter",
|
|
3330
3372
|
"layout",
|
|
3331
3373
|
"feature"
|
|
3332
|
-
],
|
|
3374
|
+
], Hi = {
|
|
3333
3375
|
starter: "Starter",
|
|
3334
3376
|
layout: "Layout",
|
|
3335
3377
|
feature: "Features"
|
|
3336
|
-
},
|
|
3337
|
-
function
|
|
3378
|
+
}, Ui = new Set(["starter", "layout"]), Wi = "layout-basic";
|
|
3379
|
+
function Gi(e, t = {}) {
|
|
3338
3380
|
let n = [];
|
|
3339
|
-
for (let r of
|
|
3381
|
+
for (let r of Vi) {
|
|
3340
3382
|
let i = e.filter((e) => e.category === r);
|
|
3341
3383
|
if (i.length === 0) continue;
|
|
3342
|
-
let a =
|
|
3384
|
+
let a = Ui.has(r) ? "single" : "multiple";
|
|
3343
3385
|
if (r === "layout") {
|
|
3344
|
-
n.push(
|
|
3386
|
+
n.push(Ki("frontend", i)), t.adminAvailable && n.push(Ki("admin", i));
|
|
3345
3387
|
continue;
|
|
3346
3388
|
}
|
|
3347
3389
|
n.push({
|
|
3348
3390
|
category: r,
|
|
3349
|
-
label:
|
|
3391
|
+
label: Hi[r],
|
|
3350
3392
|
mode: a,
|
|
3351
3393
|
packs: i,
|
|
3352
3394
|
preselect: null
|
|
@@ -3354,55 +3396,55 @@ function Wi(e, t = {}) {
|
|
|
3354
3396
|
}
|
|
3355
3397
|
return n;
|
|
3356
3398
|
}
|
|
3357
|
-
function
|
|
3358
|
-
let n = t.some((e) => e.name ===
|
|
3399
|
+
function Ki(e, t) {
|
|
3400
|
+
let n = t.some((e) => e.name === Wi);
|
|
3359
3401
|
return {
|
|
3360
3402
|
category: "layout",
|
|
3361
3403
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3362
3404
|
mode: "single",
|
|
3363
3405
|
packs: t,
|
|
3364
|
-
preselect: n ?
|
|
3406
|
+
preselect: n ? Wi : null,
|
|
3365
3407
|
slot: e
|
|
3366
3408
|
};
|
|
3367
3409
|
}
|
|
3368
3410
|
//#endregion
|
|
3369
3411
|
//#region src/ui/logger.ts
|
|
3370
|
-
function
|
|
3371
|
-
s.note(e.map((e) => `${
|
|
3412
|
+
function qi(e) {
|
|
3413
|
+
s.note(e.map((e) => `${B.arrow} ${e}`).join("\n"), "Next steps");
|
|
3372
3414
|
}
|
|
3373
3415
|
function X() {
|
|
3374
|
-
s.cancel(
|
|
3416
|
+
s.cancel(z.muted("Operation cancelled.")), process.exit(0);
|
|
3375
3417
|
}
|
|
3376
3418
|
//#endregion
|
|
3377
3419
|
//#region src/core/post-setup.ts
|
|
3378
|
-
async function
|
|
3379
|
-
return (await
|
|
3420
|
+
async function Ji() {
|
|
3421
|
+
return (await K("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3380
3422
|
}
|
|
3381
|
-
async function
|
|
3423
|
+
async function Yi(e) {
|
|
3382
3424
|
return J(`${e}/apps/backend/.env`);
|
|
3383
3425
|
}
|
|
3384
|
-
async function
|
|
3385
|
-
let r = n ? `Start services with ${
|
|
3426
|
+
async function Xi(e, t, n) {
|
|
3427
|
+
let r = n ? `Start services with ${z.command("docker compose up -d")}?` : `Docker is not running. Start services with ${z.command("docker compose up -d")}?`, i = t ? !0 : await s.confirm({
|
|
3386
3428
|
message: r,
|
|
3387
3429
|
initialValue: !0
|
|
3388
3430
|
});
|
|
3389
|
-
if (s.isCancel(i) && X(), !i) return s.log.info(
|
|
3431
|
+
if (s.isCancel(i) && X(), !i) return s.log.info(z.muted("Skipping Docker services and database migrations.")), !1;
|
|
3390
3432
|
let a = s.spinner();
|
|
3391
3433
|
a.start("Starting Docker services...");
|
|
3392
|
-
let o = await
|
|
3434
|
+
let o = await K("docker", [
|
|
3393
3435
|
"compose",
|
|
3394
3436
|
"up",
|
|
3395
3437
|
"-d"
|
|
3396
3438
|
], { cwd: `${e}/apps/backend` });
|
|
3397
|
-
return o.exitCode === 0 ? (a.stop(
|
|
3439
|
+
return o.exitCode === 0 ? (a.stop(z.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), Zi(o), !1);
|
|
3398
3440
|
}
|
|
3399
|
-
function
|
|
3441
|
+
function Zi(e) {
|
|
3400
3442
|
let t = (e.stderr || e.stdout).trim();
|
|
3401
|
-
t && s.log.warn(
|
|
3443
|
+
t && s.log.warn(z.muted(t));
|
|
3402
3444
|
}
|
|
3403
|
-
async function
|
|
3445
|
+
async function Qi(e, t = 15, n = 2e3) {
|
|
3404
3446
|
for (let r = 0; r < t; r++) {
|
|
3405
|
-
if ((await
|
|
3447
|
+
if ((await K("docker", [
|
|
3406
3448
|
"compose",
|
|
3407
3449
|
"exec",
|
|
3408
3450
|
"-T",
|
|
@@ -3415,9 +3457,9 @@ async function Zi(e, t = 15, n = 2e3) {
|
|
|
3415
3457
|
}
|
|
3416
3458
|
return !1;
|
|
3417
3459
|
}
|
|
3418
|
-
var
|
|
3419
|
-
async function
|
|
3420
|
-
let t = await
|
|
3460
|
+
var $i = "Database schema is up to date";
|
|
3461
|
+
async function ea(e) {
|
|
3462
|
+
let t = await K("pnpm", [
|
|
3421
3463
|
"--filter",
|
|
3422
3464
|
"@internal/backend",
|
|
3423
3465
|
"exec",
|
|
@@ -3425,45 +3467,48 @@ async function $i(e) {
|
|
|
3425
3467
|
"migrate",
|
|
3426
3468
|
"status"
|
|
3427
3469
|
], { cwd: e });
|
|
3428
|
-
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(
|
|
3470
|
+
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes($i) : !1;
|
|
3429
3471
|
}
|
|
3430
|
-
async function
|
|
3472
|
+
async function ta(e) {
|
|
3431
3473
|
let t = s.spinner();
|
|
3432
3474
|
t.start("Running database migrations...");
|
|
3433
|
-
let n = await
|
|
3475
|
+
let n = await K("pnpm", [
|
|
3434
3476
|
"--filter",
|
|
3435
3477
|
"@internal/backend",
|
|
3436
3478
|
"migration:latest"
|
|
3437
3479
|
], { cwd: e });
|
|
3438
|
-
return n.exitCode === 0 ? (t.stop(
|
|
3480
|
+
return n.exitCode === 0 ? (t.stop(z.success("Database migrations applied")), !0) : (t.error("Migrations failed"), Zi(n), s.log.warn(z.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations.")), !1);
|
|
3439
3481
|
}
|
|
3440
|
-
async function
|
|
3441
|
-
if (!await
|
|
3482
|
+
async function na(e, t, n = {}) {
|
|
3483
|
+
if (!await Xi(e, t, await Ji())) return !1;
|
|
3442
3484
|
let r = s.spinner();
|
|
3443
|
-
return r.start("Waiting for Postgres to be ready..."), await
|
|
3485
|
+
return r.start("Waiting for Postgres to be ready..."), await Qi(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3) ? (r.stop(z.success("Postgres is ready")), !0) : (r.error("Postgres health check timed out"), s.log.warn(z.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest")), !1);
|
|
3444
3486
|
}
|
|
3445
|
-
async function
|
|
3446
|
-
if (!await
|
|
3487
|
+
async function ra(e, t, n = {}) {
|
|
3488
|
+
if (!await na(e, t, n)) return;
|
|
3447
3489
|
let r = t ? !0 : await s.confirm({
|
|
3448
|
-
message: `Run database migrations with ${
|
|
3490
|
+
message: `Run database migrations with ${z.command("prisma migrate deploy")}?`,
|
|
3449
3491
|
initialValue: !0
|
|
3450
3492
|
});
|
|
3451
3493
|
if (s.isCancel(r) && X(), !r) {
|
|
3452
|
-
s.log.info(
|
|
3494
|
+
s.log.info(z.muted("Skipping database migrations."));
|
|
3453
3495
|
return;
|
|
3454
3496
|
}
|
|
3455
|
-
await
|
|
3497
|
+
await ta(e);
|
|
3456
3498
|
}
|
|
3457
|
-
async function
|
|
3458
|
-
if (!await
|
|
3459
|
-
s.log.warn(`${
|
|
3499
|
+
async function ia(e, t, n = {}) {
|
|
3500
|
+
if (!await Yi(e)) {
|
|
3501
|
+
s.log.warn(`${z.path(".env")} not found in ${z.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3460
3502
|
return;
|
|
3461
3503
|
}
|
|
3462
|
-
await
|
|
3504
|
+
await ra(e, t, n);
|
|
3505
|
+
}
|
|
3506
|
+
async function aa(e, t, n = {}) {
|
|
3507
|
+
return await Yi(e) ? na(e, t, n) : (s.log.warn(`${z.path(".env")} not found in ${z.path("apps/backend")}. Skipping Docker - configure it first.`), !1);
|
|
3463
3508
|
}
|
|
3464
3509
|
//#endregion
|
|
3465
3510
|
//#region src/core/resolve.ts
|
|
3466
|
-
function
|
|
3511
|
+
function oa(e) {
|
|
3467
3512
|
let t = /* @__PURE__ */ new Map();
|
|
3468
3513
|
for (let n of e) t.set(n.name, {
|
|
3469
3514
|
name: n.name,
|
|
@@ -3471,7 +3516,7 @@ function ia(e) {
|
|
|
3471
3516
|
});
|
|
3472
3517
|
return t;
|
|
3473
3518
|
}
|
|
3474
|
-
function
|
|
3519
|
+
function sa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3475
3520
|
let r = /* @__PURE__ */ new Set();
|
|
3476
3521
|
function i(e) {
|
|
3477
3522
|
if (n.has(e)) return [];
|
|
@@ -3485,10 +3530,10 @@ function aa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3485
3530
|
}
|
|
3486
3531
|
return i(e);
|
|
3487
3532
|
}
|
|
3488
|
-
function
|
|
3533
|
+
function ca(e, t, n = []) {
|
|
3489
3534
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3490
3535
|
for (let n of e) {
|
|
3491
|
-
let e =
|
|
3536
|
+
let e = sa(n, t, new Set(i));
|
|
3492
3537
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3493
3538
|
}
|
|
3494
3539
|
return {
|
|
@@ -3496,7 +3541,7 @@ function oa(e, t, n = []) {
|
|
|
3496
3541
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3497
3542
|
};
|
|
3498
3543
|
}
|
|
3499
|
-
function
|
|
3544
|
+
function la(e) {
|
|
3500
3545
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3501
3546
|
for (let e of t) {
|
|
3502
3547
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3509,7 +3554,7 @@ function sa(e) {
|
|
|
3509
3554
|
}
|
|
3510
3555
|
//#endregion
|
|
3511
3556
|
//#region src/core/variants.ts
|
|
3512
|
-
function
|
|
3557
|
+
function ua(e, t = {}) {
|
|
3513
3558
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3514
3559
|
for (let i of e) {
|
|
3515
3560
|
let e = t[i.family] ?? i.default;
|
|
@@ -3521,14 +3566,14 @@ function ca(e, t = {}) {
|
|
|
3521
3566
|
familyOf: r
|
|
3522
3567
|
};
|
|
3523
3568
|
}
|
|
3524
|
-
function
|
|
3569
|
+
function da(e, t, n) {
|
|
3525
3570
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3526
3571
|
}
|
|
3527
|
-
function
|
|
3572
|
+
function fa(e, t) {
|
|
3528
3573
|
let n = t.familyOf.get(e);
|
|
3529
3574
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3530
3575
|
}
|
|
3531
|
-
function
|
|
3576
|
+
function pa(e, t) {
|
|
3532
3577
|
let n = /* @__PURE__ */ new Map();
|
|
3533
3578
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3534
3579
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3544,65 +3589,65 @@ function da(e, t) {
|
|
|
3544
3589
|
familyOf: n
|
|
3545
3590
|
};
|
|
3546
3591
|
}
|
|
3547
|
-
function
|
|
3592
|
+
function ma(e, t) {
|
|
3548
3593
|
return e.map((e) => ({
|
|
3549
3594
|
...e,
|
|
3550
|
-
dependencies: e.dependencies.map((e) =>
|
|
3595
|
+
dependencies: e.dependencies.map((e) => fa(e, t))
|
|
3551
3596
|
}));
|
|
3552
3597
|
}
|
|
3553
3598
|
//#endregion
|
|
3554
3599
|
//#region src/ui/banner.ts
|
|
3555
|
-
var
|
|
3600
|
+
var ha = [
|
|
3556
3601
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3557
3602
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3558
3603
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3559
3604
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3560
3605
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3561
3606
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3562
|
-
],
|
|
3607
|
+
], ga = [
|
|
3563
3608
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3564
3609
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3565
3610
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3566
3611
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3567
3612
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3568
3613
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3569
|
-
],
|
|
3614
|
+
], _a = [
|
|
3570
3615
|
253,
|
|
3571
3616
|
176,
|
|
3572
3617
|
21
|
|
3573
|
-
],
|
|
3618
|
+
], va = [
|
|
3574
3619
|
245,
|
|
3575
3620
|
76,
|
|
3576
3621
|
2
|
|
3577
|
-
],
|
|
3622
|
+
], ya = 5, ba = [
|
|
3578
3623
|
17,
|
|
3579
3624
|
103,
|
|
3580
3625
|
248
|
|
3581
|
-
],
|
|
3626
|
+
], xa = [
|
|
3582
3627
|
42,
|
|
3583
3628
|
160,
|
|
3584
3629
|
250
|
|
3585
|
-
],
|
|
3586
|
-
function
|
|
3630
|
+
], Sa = .2;
|
|
3631
|
+
function Ca() {
|
|
3587
3632
|
console.log();
|
|
3588
|
-
for (let e of
|
|
3589
|
-
start:
|
|
3590
|
-
end:
|
|
3591
|
-
angle:
|
|
3633
|
+
for (let e of be(ha, {
|
|
3634
|
+
start: _a,
|
|
3635
|
+
end: va,
|
|
3636
|
+
angle: ya
|
|
3592
3637
|
})) console.log(b.bold(e));
|
|
3593
|
-
for (let e of
|
|
3594
|
-
start:
|
|
3595
|
-
end:
|
|
3596
|
-
angle:
|
|
3638
|
+
for (let e of be(ga, {
|
|
3639
|
+
start: ba,
|
|
3640
|
+
end: xa,
|
|
3641
|
+
angle: Sa
|
|
3597
3642
|
})) console.log(b.bold(e));
|
|
3598
|
-
console.log(), console.log(` ${
|
|
3643
|
+
console.log(), console.log(` ${B.spark} ${b.dim("v" + A)} ${b.dim("·")} ${ve("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3599
3644
|
}
|
|
3600
|
-
function
|
|
3601
|
-
console.log(), console.log(` ${
|
|
3645
|
+
function wa() {
|
|
3646
|
+
console.log(), console.log(` ${B.bolt} ${he.orange("Hype")}${he.skyBlue("Stack")} ${b.dim("v" + A)}`), console.log();
|
|
3602
3647
|
}
|
|
3603
3648
|
//#endregion
|
|
3604
3649
|
//#region src/ui/pack-multiselect.ts
|
|
3605
|
-
var
|
|
3650
|
+
var Ta = class extends O {
|
|
3606
3651
|
options;
|
|
3607
3652
|
cursor = 0;
|
|
3608
3653
|
selected;
|
|
@@ -3706,44 +3751,44 @@ var Ca = class extends O {
|
|
|
3706
3751
|
}
|
|
3707
3752
|
}
|
|
3708
3753
|
};
|
|
3709
|
-
function
|
|
3710
|
-
return new
|
|
3754
|
+
function Ea(e) {
|
|
3755
|
+
return new Ta(e).prompt();
|
|
3711
3756
|
}
|
|
3712
3757
|
//#endregion
|
|
3713
3758
|
//#region src/utils/naming.ts
|
|
3714
|
-
function
|
|
3759
|
+
function Da(e) {
|
|
3715
3760
|
return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3716
3761
|
}
|
|
3717
|
-
function
|
|
3762
|
+
function Oa(e) {
|
|
3718
3763
|
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3719
3764
|
}
|
|
3720
3765
|
//#endregion
|
|
3721
3766
|
//#region src/utils/validate.ts
|
|
3722
|
-
function
|
|
3767
|
+
function ka(e) {
|
|
3723
3768
|
if (!e.trim()) return "Project name cannot be empty";
|
|
3724
3769
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
3725
|
-
let t =
|
|
3726
|
-
if (!
|
|
3770
|
+
let t = Da(e);
|
|
3771
|
+
if (!ne.test(t)) return "Project name must contain at least one letter or number";
|
|
3727
3772
|
}
|
|
3728
3773
|
//#endregion
|
|
3729
3774
|
//#region src/core/apply-mode.ts
|
|
3730
|
-
var
|
|
3731
|
-
function
|
|
3732
|
-
return e.replace(
|
|
3775
|
+
var Aa = "src/hooks/use-theme.ts", ja = /(\bexport\s+const\s+defaultTheme\s*=\s*)(["'])(?:light|dark)\2/;
|
|
3776
|
+
function Ma(e, t) {
|
|
3777
|
+
return e.replace(ja, (e, n, r) => `${n}${r}${t}${r}`);
|
|
3733
3778
|
}
|
|
3734
|
-
async function
|
|
3735
|
-
let n = T.resolve(e,
|
|
3779
|
+
async function Na(e, t) {
|
|
3780
|
+
let n = T.resolve(e, Aa), r;
|
|
3736
3781
|
try {
|
|
3737
3782
|
r = await y.readFile(n, "utf-8");
|
|
3738
3783
|
} catch {
|
|
3739
3784
|
return !1;
|
|
3740
3785
|
}
|
|
3741
|
-
let i =
|
|
3786
|
+
let i = Ma(r, t);
|
|
3742
3787
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3743
3788
|
}
|
|
3744
3789
|
//#endregion
|
|
3745
3790
|
//#region src/core/apply-theme.ts
|
|
3746
|
-
function
|
|
3791
|
+
function Pa(e, t) {
|
|
3747
3792
|
let n = e.indexOf(t);
|
|
3748
3793
|
if (n === -1) return null;
|
|
3749
3794
|
let r = e.indexOf("{", n);
|
|
@@ -3758,47 +3803,47 @@ function Ma(e, t) {
|
|
|
3758
3803
|
bodyEnd: a - 1
|
|
3759
3804
|
} : null;
|
|
3760
3805
|
}
|
|
3761
|
-
function
|
|
3806
|
+
function Fa(e, t) {
|
|
3762
3807
|
let n = e;
|
|
3763
3808
|
for (let [e, r] of Object.entries(t)) {
|
|
3764
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3809
|
+
let t = RegExp(`(^[ \\t]*--${Ia(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3765
3810
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3766
3811
|
}
|
|
3767
3812
|
return n;
|
|
3768
3813
|
}
|
|
3769
|
-
function
|
|
3814
|
+
function Ia(e) {
|
|
3770
3815
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3771
3816
|
}
|
|
3772
|
-
function
|
|
3773
|
-
let n =
|
|
3817
|
+
function La(e, t) {
|
|
3818
|
+
let n = Pa(e, ":root"), r = Pa(e, ".dark"), i = e;
|
|
3774
3819
|
if (n) {
|
|
3775
3820
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3776
|
-
i = e +
|
|
3821
|
+
i = e + Fa(r, t.light) + a;
|
|
3777
3822
|
}
|
|
3778
3823
|
if (r) {
|
|
3779
|
-
let e =
|
|
3824
|
+
let e = Pa(i, ".dark");
|
|
3780
3825
|
if (e) {
|
|
3781
3826
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3782
|
-
i = n +
|
|
3827
|
+
i = n + Fa(r, t.dark) + a;
|
|
3783
3828
|
}
|
|
3784
3829
|
}
|
|
3785
3830
|
return i;
|
|
3786
3831
|
}
|
|
3787
|
-
var
|
|
3788
|
-
async function
|
|
3789
|
-
let n = T.resolve(e,
|
|
3832
|
+
var Ra = "assets/styles.css";
|
|
3833
|
+
async function za(e, t) {
|
|
3834
|
+
let n = T.resolve(e, Ra), r;
|
|
3790
3835
|
try {
|
|
3791
3836
|
r = await y.readFile(n, "utf-8");
|
|
3792
3837
|
} catch {
|
|
3793
3838
|
return !1;
|
|
3794
3839
|
}
|
|
3795
|
-
let i =
|
|
3840
|
+
let i = La(r, t);
|
|
3796
3841
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3797
3842
|
}
|
|
3798
3843
|
//#endregion
|
|
3799
3844
|
//#region src/core/clone.ts
|
|
3800
|
-
async function
|
|
3801
|
-
let t = await ee(
|
|
3845
|
+
async function Ba(e) {
|
|
3846
|
+
let t = await ee(j, {
|
|
3802
3847
|
dir: e,
|
|
3803
3848
|
force: !0
|
|
3804
3849
|
});
|
|
@@ -3809,7 +3854,7 @@ async function Ra(e) {
|
|
|
3809
3854
|
}
|
|
3810
3855
|
//#endregion
|
|
3811
3856
|
//#region src/core/editor-config.ts
|
|
3812
|
-
function
|
|
3857
|
+
function Va(e) {
|
|
3813
3858
|
let t = {
|
|
3814
3859
|
globs: [],
|
|
3815
3860
|
alwaysApply: !1
|
|
@@ -3844,10 +3889,10 @@ function za(e) {
|
|
|
3844
3889
|
content: i
|
|
3845
3890
|
};
|
|
3846
3891
|
}
|
|
3847
|
-
function
|
|
3892
|
+
function Ha(e) {
|
|
3848
3893
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
3849
3894
|
}
|
|
3850
|
-
function
|
|
3895
|
+
function Ua(e) {
|
|
3851
3896
|
let t;
|
|
3852
3897
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
3853
3898
|
let n = [`trigger: ${t}`];
|
|
@@ -3857,30 +3902,30 @@ function Va(e) {
|
|
|
3857
3902
|
}
|
|
3858
3903
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
3859
3904
|
}
|
|
3860
|
-
function
|
|
3905
|
+
function Wa(e) {
|
|
3861
3906
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
3862
3907
|
}
|
|
3863
|
-
var
|
|
3908
|
+
var Ga = {
|
|
3864
3909
|
claude: {
|
|
3865
3910
|
rulesDir: ".claude/rules",
|
|
3866
3911
|
extension: ".md",
|
|
3867
|
-
convert:
|
|
3912
|
+
convert: Ha
|
|
3868
3913
|
},
|
|
3869
3914
|
windsurf: {
|
|
3870
3915
|
rulesDir: ".windsurf/rules",
|
|
3871
3916
|
extension: ".md",
|
|
3872
|
-
convert:
|
|
3917
|
+
convert: Ua
|
|
3873
3918
|
},
|
|
3874
3919
|
copilot: {
|
|
3875
3920
|
rulesDir: ".github/instructions",
|
|
3876
3921
|
extension: ".instructions.md",
|
|
3877
|
-
convert:
|
|
3922
|
+
convert: Wa
|
|
3878
3923
|
}
|
|
3879
3924
|
};
|
|
3880
|
-
async function
|
|
3881
|
-
let t = T.join(e,
|
|
3925
|
+
async function Ka(e) {
|
|
3926
|
+
let t = T.join(e, ie), n = (await y.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
3882
3927
|
return await Promise.all(n.map(async (e) => {
|
|
3883
|
-
let n = T.join(t, e.name), { frontmatter: r, content: i } =
|
|
3928
|
+
let n = T.join(t, e.name), { frontmatter: r, content: i } = Va(await y.readFile(n, "utf-8"));
|
|
3884
3929
|
return {
|
|
3885
3930
|
frontmatter: r,
|
|
3886
3931
|
content: i,
|
|
@@ -3888,31 +3933,31 @@ async function Wa(e) {
|
|
|
3888
3933
|
};
|
|
3889
3934
|
}));
|
|
3890
3935
|
}
|
|
3891
|
-
async function
|
|
3936
|
+
async function qa(e, t) {
|
|
3892
3937
|
if (t === "cursor") return;
|
|
3893
|
-
let n =
|
|
3938
|
+
let n = Ga[t], r = await Ka(e), i = T.join(e, n.rulesDir);
|
|
3894
3939
|
await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
3895
3940
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3896
3941
|
return y.writeFile(T.join(i, r), t, "utf-8");
|
|
3897
|
-
})), await
|
|
3942
|
+
})), await ur(T.join(e, ae)), await ur(T.join(e, oe));
|
|
3898
3943
|
}
|
|
3899
3944
|
//#endregion
|
|
3900
3945
|
//#region src/core/env-files.ts
|
|
3901
|
-
var
|
|
3946
|
+
var Ja = [
|
|
3902
3947
|
"apps",
|
|
3903
3948
|
"packages",
|
|
3904
3949
|
"libs",
|
|
3905
3950
|
"shared"
|
|
3906
3951
|
];
|
|
3907
|
-
async function
|
|
3908
|
-
let t = await
|
|
3952
|
+
async function Ya(e) {
|
|
3953
|
+
let t = await Xa(e);
|
|
3909
3954
|
return (await Promise.all(t.map(async (t) => {
|
|
3910
3955
|
let n = T.join(T.dirname(t), ".env");
|
|
3911
3956
|
return await J(n) ? null : (await y.copyFile(t, n), T.relative(e, n));
|
|
3912
3957
|
}))).filter((e) => e !== null).sort();
|
|
3913
3958
|
}
|
|
3914
|
-
async function
|
|
3915
|
-
let t = [T.join(e, ".env.example")], n = await Promise.all(
|
|
3959
|
+
async function Xa(e) {
|
|
3960
|
+
let t = [T.join(e, ".env.example")], n = await Promise.all(Ja.map(async (t) => {
|
|
3916
3961
|
let n = T.join(e, t);
|
|
3917
3962
|
return (await y.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => T.join(n, e.name, ".env.example"));
|
|
3918
3963
|
}));
|
|
@@ -3920,12 +3965,12 @@ async function Ja(e) {
|
|
|
3920
3965
|
}
|
|
3921
3966
|
//#endregion
|
|
3922
3967
|
//#region src/core/post-clone.ts
|
|
3923
|
-
var Z = "@hype-stack/",
|
|
3924
|
-
async function
|
|
3925
|
-
await
|
|
3968
|
+
var Z = "@hype-stack/", Za = "hype-stack";
|
|
3969
|
+
async function Qa(e) {
|
|
3970
|
+
await ur(T.join(e, ".git"));
|
|
3926
3971
|
}
|
|
3927
|
-
async function
|
|
3928
|
-
await
|
|
3972
|
+
async function $a(e) {
|
|
3973
|
+
await K("git", ["init"], { cwd: e }), await K("git", ["add", "."], { cwd: e }), await K("git", [
|
|
3929
3974
|
"-c",
|
|
3930
3975
|
"user.name=Hype Stack CLI",
|
|
3931
3976
|
"-c",
|
|
@@ -3935,22 +3980,22 @@ async function Za(e) {
|
|
|
3935
3980
|
"Initial commit from Hype Stack CLI"
|
|
3936
3981
|
], { cwd: e });
|
|
3937
3982
|
}
|
|
3938
|
-
async function
|
|
3939
|
-
let n = `@${t}/`, r = await
|
|
3983
|
+
async function eo(e, t) {
|
|
3984
|
+
let n = `@${t}/`, r = await co(e);
|
|
3940
3985
|
for (let e of r) {
|
|
3941
|
-
let t = await
|
|
3986
|
+
let t = await sr(e);
|
|
3942
3987
|
if (!t) continue;
|
|
3943
3988
|
let r = !1;
|
|
3944
|
-
t.name?.startsWith(Z) && (t.name = t.name.replace(Z, n), r = !0),
|
|
3989
|
+
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);
|
|
3945
3990
|
let i = await y.readFile(e, "utf-8");
|
|
3946
3991
|
if (i.includes(Z)) {
|
|
3947
3992
|
let t = i.replaceAll(Z, n);
|
|
3948
3993
|
await y.writeFile(e, t, "utf-8");
|
|
3949
|
-
} else r && await
|
|
3994
|
+
} else r && await cr(e, t);
|
|
3950
3995
|
}
|
|
3951
|
-
await
|
|
3996
|
+
await Ei(e, t), await ro(e, t), await so(e, t);
|
|
3952
3997
|
}
|
|
3953
|
-
var
|
|
3998
|
+
var to = new Set([
|
|
3954
3999
|
".git",
|
|
3955
4000
|
"node_modules",
|
|
3956
4001
|
"dist",
|
|
@@ -3958,10 +4003,10 @@ var $a = new Set([
|
|
|
3958
4003
|
".nx",
|
|
3959
4004
|
".next",
|
|
3960
4005
|
"coverage"
|
|
3961
|
-
]),
|
|
3962
|
-
async function
|
|
3963
|
-
if (t ===
|
|
3964
|
-
let n = await
|
|
4006
|
+
]), no = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
|
|
4007
|
+
async function ro(e, t) {
|
|
4008
|
+
if (t === Za) return;
|
|
4009
|
+
let n = await io(e);
|
|
3965
4010
|
await Promise.all(n.map(async (e) => {
|
|
3966
4011
|
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
3967
4012
|
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
@@ -3969,14 +4014,14 @@ async function to(e, t) {
|
|
|
3969
4014
|
await y.writeFile(e, r, "utf-8");
|
|
3970
4015
|
}));
|
|
3971
4016
|
}
|
|
3972
|
-
async function
|
|
4017
|
+
async function io(e) {
|
|
3973
4018
|
let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
3974
4019
|
return (await Promise.all(t.map(async (t) => {
|
|
3975
4020
|
let n = T.join(e, t.name);
|
|
3976
|
-
return t.isDirectory() ?
|
|
4021
|
+
return t.isDirectory() ? to.has(t.name) ? [] : io(n) : t.isFile() && no.test(t.name) ? [n] : [];
|
|
3977
4022
|
}))).flat();
|
|
3978
4023
|
}
|
|
3979
|
-
function
|
|
4024
|
+
function ao(e, t) {
|
|
3980
4025
|
if (!e) return !1;
|
|
3981
4026
|
let n = !1;
|
|
3982
4027
|
for (let r of Object.keys(e)) if (r.startsWith(Z)) {
|
|
@@ -3985,7 +4030,7 @@ function ro(e, t) {
|
|
|
3985
4030
|
}
|
|
3986
4031
|
return n;
|
|
3987
4032
|
}
|
|
3988
|
-
function
|
|
4033
|
+
function oo(e, t) {
|
|
3989
4034
|
if (!e) return !1;
|
|
3990
4035
|
let n = !1;
|
|
3991
4036
|
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Z) ? (n = !0, e.replace(Z, t)) : e), e.targets) {
|
|
@@ -3993,13 +4038,13 @@ function io(e, t) {
|
|
|
3993
4038
|
}
|
|
3994
4039
|
return n;
|
|
3995
4040
|
}
|
|
3996
|
-
async function
|
|
4041
|
+
async function so(e, t) {
|
|
3997
4042
|
let n = T.join(e, "packages/enums/src/app/index.ts"), r = await y.readFile(n, "utf-8").catch(() => null);
|
|
3998
4043
|
if (!r) return;
|
|
3999
|
-
let i =
|
|
4044
|
+
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"`);
|
|
4000
4045
|
await y.writeFile(n, a, "utf-8");
|
|
4001
4046
|
}
|
|
4002
|
-
async function
|
|
4047
|
+
async function co(e) {
|
|
4003
4048
|
let t = [], n = T.join(e, "package.json");
|
|
4004
4049
|
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
4005
4050
|
for (let n of [
|
|
@@ -4019,7 +4064,7 @@ async function oo(e) {
|
|
|
4019
4064
|
}
|
|
4020
4065
|
//#endregion
|
|
4021
4066
|
//#region src/core/readme.ts
|
|
4022
|
-
var
|
|
4067
|
+
var lo = {
|
|
4023
4068
|
cursor: {
|
|
4024
4069
|
label: "Cursor",
|
|
4025
4070
|
rulesDir: ".cursor/rules"
|
|
@@ -4036,21 +4081,21 @@ var so = {
|
|
|
4036
4081
|
label: "GitHub Copilot",
|
|
4037
4082
|
rulesDir: ".github/instructions"
|
|
4038
4083
|
}
|
|
4039
|
-
},
|
|
4084
|
+
}, uo = {
|
|
4040
4085
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
4041
4086
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
4042
|
-
},
|
|
4087
|
+
}, fo = {
|
|
4043
4088
|
enums: "Shared enums and app config used across apps",
|
|
4044
4089
|
cli: "Project tooling and code generators"
|
|
4045
4090
|
};
|
|
4046
|
-
function
|
|
4091
|
+
function po(e, t) {
|
|
4047
4092
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
4048
4093
|
let r = t[e];
|
|
4049
4094
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4050
4095
|
});
|
|
4051
4096
|
}
|
|
4052
|
-
function
|
|
4053
|
-
let { projectName: t, editor: n, workspace: r } = e, i =
|
|
4097
|
+
function mo(e) {
|
|
4098
|
+
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 = [];
|
|
4054
4099
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
4055
4100
|
let u = [];
|
|
4056
4101
|
u.push(`# ${i}`), u.push([
|
|
@@ -4158,19 +4203,19 @@ function fo(e) {
|
|
|
4158
4203
|
"stays useful."
|
|
4159
4204
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4160
4205
|
}
|
|
4161
|
-
async function
|
|
4206
|
+
async function ho(e, t) {
|
|
4162
4207
|
let n = T.join(e, "README.md");
|
|
4163
|
-
await y.writeFile(n,
|
|
4208
|
+
await y.writeFile(n, mo(t), "utf-8");
|
|
4164
4209
|
}
|
|
4165
4210
|
//#endregion
|
|
4166
4211
|
//#region src/core/tracking.ts
|
|
4167
|
-
async function
|
|
4212
|
+
async function go(e) {
|
|
4168
4213
|
try {
|
|
4169
4214
|
let t = {
|
|
4170
|
-
"X-Device-Id":
|
|
4171
|
-
"X-Client-Info":
|
|
4172
|
-
}, n = await
|
|
4173
|
-
n?.token && (t.Authorization = `Bearer ${n.token}`), await
|
|
4215
|
+
"X-Device-Id": Zn(),
|
|
4216
|
+
"X-Client-Info": Qn()
|
|
4217
|
+
}, n = await qn(L()).catch(() => null);
|
|
4218
|
+
n?.token && (t.Authorization = `Bearer ${n.token}`), await G.createRequest()({
|
|
4174
4219
|
endpoint: "/cli/track",
|
|
4175
4220
|
method: "POST"
|
|
4176
4221
|
}).setPayload({ event: e }).setHeaders(t).send();
|
|
@@ -4178,7 +4223,7 @@ async function mo(e) {
|
|
|
4178
4223
|
}
|
|
4179
4224
|
//#endregion
|
|
4180
4225
|
//#region src/core/npm-deps.ts
|
|
4181
|
-
function
|
|
4226
|
+
function _o(e, t) {
|
|
4182
4227
|
let n = [], r = [];
|
|
4183
4228
|
if (!e) return {
|
|
4184
4229
|
errors: n,
|
|
@@ -4209,7 +4254,7 @@ function ho(e, t) {
|
|
|
4209
4254
|
operations: r
|
|
4210
4255
|
};
|
|
4211
4256
|
}
|
|
4212
|
-
function
|
|
4257
|
+
function vo(e) {
|
|
4213
4258
|
let t = {};
|
|
4214
4259
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4215
4260
|
...t[e],
|
|
@@ -4217,7 +4262,7 @@ function go(e) {
|
|
|
4217
4262
|
};
|
|
4218
4263
|
return t;
|
|
4219
4264
|
}
|
|
4220
|
-
async function
|
|
4265
|
+
async function yo(e, t, n = K) {
|
|
4221
4266
|
let r = [];
|
|
4222
4267
|
for (let i of e) {
|
|
4223
4268
|
let e = T.join(t, i.relativeDir);
|
|
@@ -4253,25 +4298,25 @@ async function _o(e, t, n = q) {
|
|
|
4253
4298
|
function Q(e) {
|
|
4254
4299
|
return e instanceof Error ? e.message : String(e);
|
|
4255
4300
|
}
|
|
4256
|
-
async function
|
|
4301
|
+
async function bo(e, t, n) {
|
|
4257
4302
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4258
|
-
return r.length === 0 ? {} :
|
|
4303
|
+
return r.length === 0 ? {} : Or(r, n).catch(() => ({}));
|
|
4259
4304
|
}
|
|
4260
|
-
function
|
|
4261
|
-
return e === "free" ?
|
|
4305
|
+
function xo(e, t) {
|
|
4306
|
+
return e === "free" ? z.success("free") : e === "owned" ? z.accent("owned") : `${z.highlight(`$${t}`)} ${z.muted("locked")}`;
|
|
4262
4307
|
}
|
|
4263
|
-
async function
|
|
4308
|
+
async function So(e, t, n) {
|
|
4264
4309
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4265
|
-
i.length > 0 && s.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await
|
|
4310
|
+
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 ir(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4266
4311
|
name: e.name,
|
|
4267
4312
|
displayName: e.displayName,
|
|
4268
4313
|
price: e.price
|
|
4269
4314
|
})));
|
|
4270
4315
|
}
|
|
4271
|
-
function
|
|
4316
|
+
function Co(e, t) {
|
|
4272
4317
|
let n = e.map((e, n) => {
|
|
4273
4318
|
let r = t.get(e), i = r ? r.displayName : e;
|
|
4274
|
-
return ` ${
|
|
4319
|
+
return ` ${z.muted(`${n + 1}.`)} ${z.brand(i)}`;
|
|
4275
4320
|
});
|
|
4276
4321
|
s.note([
|
|
4277
4322
|
"These packs will be installed, in order:",
|
|
@@ -4279,10 +4324,10 @@ function xo(e, t) {
|
|
|
4279
4324
|
...n
|
|
4280
4325
|
].join("\n"), "Install Plan");
|
|
4281
4326
|
}
|
|
4282
|
-
async function
|
|
4327
|
+
async function wo(e, t) {
|
|
4283
4328
|
let n = [];
|
|
4284
4329
|
for (let r of e) {
|
|
4285
|
-
let e = await
|
|
4330
|
+
let e = await Sr(r), i = await Cr(r, t);
|
|
4286
4331
|
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'npx @hype-stack/cli login' or check your license.`);
|
|
4287
4332
|
n.push({
|
|
4288
4333
|
manifest: e,
|
|
@@ -4291,32 +4336,32 @@ async function So(e, t) {
|
|
|
4291
4336
|
}
|
|
4292
4337
|
return n;
|
|
4293
4338
|
}
|
|
4294
|
-
async function
|
|
4295
|
-
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a =
|
|
4339
|
+
async function To(e) {
|
|
4340
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = _o(vo(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4296
4341
|
if (a.errors.length > 0) {
|
|
4297
4342
|
for (let e of a.errors) s.log.error(e);
|
|
4298
4343
|
return;
|
|
4299
4344
|
}
|
|
4300
4345
|
if (a.operations.length === 0) return;
|
|
4301
4346
|
i.start("Installing npm dependencies...");
|
|
4302
|
-
let o = await
|
|
4347
|
+
let o = await yo(a.operations, r);
|
|
4303
4348
|
if (i.stop(o.ok ? "npm dependencies installed" : "npm dependency installation failed"), !o.ok) for (let e of o.errors) s.log.error(e);
|
|
4304
4349
|
}
|
|
4305
|
-
function
|
|
4306
|
-
s.note([` ${
|
|
4350
|
+
function Eo() {
|
|
4351
|
+
s.note([` ${z.command("1. npx @hype-stack/cli onboard")} ${z.muted("(set up env vars + run migrations)")}`, ` ${z.command("2. pnpm dev")} ${z.muted("(start frontend + backend)")}`].join("\n"), "Next steps");
|
|
4307
4352
|
}
|
|
4308
|
-
function
|
|
4353
|
+
function Do(e) {
|
|
4309
4354
|
if (e.length === 0) return;
|
|
4310
4355
|
let t = e.map((e) => {
|
|
4311
4356
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
4312
|
-
return ` ${
|
|
4357
|
+
return ` ${z.muted("•")} ${z.path(t)}`;
|
|
4313
4358
|
});
|
|
4314
4359
|
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4315
4360
|
}
|
|
4316
|
-
async function
|
|
4361
|
+
async function Oo(e) {
|
|
4317
4362
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
|
|
4318
4363
|
if (i) return c;
|
|
4319
|
-
let l = await
|
|
4364
|
+
let l = await Fi({
|
|
4320
4365
|
packs: t,
|
|
4321
4366
|
config: n,
|
|
4322
4367
|
projectRoot: r,
|
|
@@ -4324,17 +4369,17 @@ async function Eo(e) {
|
|
|
4324
4369
|
});
|
|
4325
4370
|
if (l.length === 0) return c;
|
|
4326
4371
|
if (a) {
|
|
4327
|
-
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${
|
|
4372
|
+
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${z.command("--force")} to overwrite.`);
|
|
4328
4373
|
let e = l.map((e) => {
|
|
4329
4374
|
let t = T.relative(r, e.targetPath) || e.target;
|
|
4330
|
-
return ` ${
|
|
4375
|
+
return ` ${z.muted("•")} ${z.path(t)} ${z.muted(`(${e.packName})`)}`;
|
|
4331
4376
|
});
|
|
4332
4377
|
return s.note(e.join("\n"), "Kept existing files"), c;
|
|
4333
4378
|
}
|
|
4334
4379
|
s.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4335
4380
|
for (let e of l) {
|
|
4336
4381
|
let t = T.relative(r, e.targetPath) || e.target, n = await s.confirm({
|
|
4337
|
-
message: `Overwrite ${
|
|
4382
|
+
message: `Overwrite ${z.path(t)}? ${z.muted(`(${e.packName})`)}`,
|
|
4338
4383
|
initialValue: !1
|
|
4339
4384
|
});
|
|
4340
4385
|
s.isCancel(n) && (s.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
|
|
@@ -4343,7 +4388,7 @@ async function Eo(e) {
|
|
|
4343
4388
|
}
|
|
4344
4389
|
//#endregion
|
|
4345
4390
|
//#region src/ui/swatch.ts
|
|
4346
|
-
function
|
|
4391
|
+
function ko(e) {
|
|
4347
4392
|
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4348
4393
|
if (!t) return null;
|
|
4349
4394
|
let n = t[1].trim().split(/\s+/);
|
|
@@ -4362,58 +4407,58 @@ function Do(e) {
|
|
|
4362
4407
|
h: a
|
|
4363
4408
|
};
|
|
4364
4409
|
}
|
|
4365
|
-
function
|
|
4410
|
+
function Ao(e) {
|
|
4366
4411
|
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4367
4412
|
}
|
|
4368
|
-
function
|
|
4413
|
+
function jo(e) {
|
|
4369
4414
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4370
4415
|
}
|
|
4371
|
-
function
|
|
4416
|
+
function Mo({ l: e, c: t, h: n }) {
|
|
4372
4417
|
let r = n * Math.PI / 180, i = t * Math.cos(r), a = t * Math.sin(r), o = e + .3963377774 * i + .2158037573 * a, s = e - .1055613458 * i - .0638541728 * a, c = e - .0894841775 * i - 1.291485548 * a, l = o ** 3, u = s ** 3, d = c ** 3, f = 4.0767416621 * l - 3.3077115913 * u + .2309699292 * d, p = -1.2684380042 * l + 2.6097570613 * u - .3413193965 * d, m = -.0041960863 * l - .7034186147 * u + 1.7076146937 * d;
|
|
4373
4418
|
return [
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4419
|
+
Ao(jo(f) * 255),
|
|
4420
|
+
Ao(jo(p) * 255),
|
|
4421
|
+
Ao(jo(m) * 255)
|
|
4377
4422
|
];
|
|
4378
4423
|
}
|
|
4379
|
-
var
|
|
4380
|
-
function
|
|
4424
|
+
var No = "\x1B[49m";
|
|
4425
|
+
function Po(e, t) {
|
|
4381
4426
|
let n = e[t];
|
|
4382
4427
|
if (!n) return b.dim(" ");
|
|
4383
|
-
let r =
|
|
4428
|
+
let r = ko(n);
|
|
4384
4429
|
if (!r) return b.dim(" ");
|
|
4385
|
-
let [i, a, o] =
|
|
4386
|
-
return `\x1b[48;2;${i};${a};${o}m ${
|
|
4430
|
+
let [i, a, o] = Mo(r);
|
|
4431
|
+
return `\x1b[48;2;${i};${a};${o}m ${No}`;
|
|
4387
4432
|
}
|
|
4388
|
-
var
|
|
4433
|
+
var Fo = [
|
|
4389
4434
|
"primary",
|
|
4390
4435
|
"secondary",
|
|
4391
4436
|
"accent"
|
|
4392
4437
|
];
|
|
4393
|
-
function
|
|
4394
|
-
return
|
|
4438
|
+
function Io(e) {
|
|
4439
|
+
return Fo.map((t) => Po(e, t)).join("");
|
|
4395
4440
|
}
|
|
4396
|
-
function
|
|
4397
|
-
return `${
|
|
4441
|
+
function Lo(e) {
|
|
4442
|
+
return `${Io(e.light)} ${b.dim("·")} ${Io(e.dark)}`;
|
|
4398
4443
|
}
|
|
4399
4444
|
//#endregion
|
|
4400
4445
|
//#region src/commands/create.ts
|
|
4401
|
-
async function
|
|
4402
|
-
e.skipBanner ||
|
|
4446
|
+
async function Ro(e) {
|
|
4447
|
+
e.skipBanner || Ca(), s.intro(z.brandBold("Create a new Hype Stack project"));
|
|
4403
4448
|
let o = e.yes === !0, c, l;
|
|
4404
4449
|
if (o && e.name) {
|
|
4405
|
-
let t =
|
|
4406
|
-
t && (s.log.error(t), X()), l = e.name, c =
|
|
4450
|
+
let t = ka(e.name);
|
|
4451
|
+
t && (s.log.error(t), X()), l = e.name, c = Da(e.name);
|
|
4407
4452
|
} else {
|
|
4408
4453
|
let t = await s.text({
|
|
4409
4454
|
message: "What is your project named?",
|
|
4410
4455
|
placeholder: "my-app",
|
|
4411
4456
|
initialValue: e.name ?? "",
|
|
4412
|
-
validate: (e) =>
|
|
4457
|
+
validate: (e) => ka(e ?? "")
|
|
4413
4458
|
});
|
|
4414
|
-
s.isCancel(t) && X(), l = t, c =
|
|
4459
|
+
s.isCancel(t) && X(), l = t, c = Da(l);
|
|
4415
4460
|
}
|
|
4416
|
-
l.trim() !== c && s.log.info(
|
|
4461
|
+
l.trim() !== c && s.log.info(z.muted(`Using "${z.highlight(c)}" as the project name`));
|
|
4417
4462
|
let u;
|
|
4418
4463
|
if (e.directory !== void 0) u = e.directory;
|
|
4419
4464
|
else {
|
|
@@ -4428,17 +4473,17 @@ async function Io(e) {
|
|
|
4428
4473
|
});
|
|
4429
4474
|
s.isCancel(e) && X(), t = e;
|
|
4430
4475
|
}
|
|
4431
|
-
u =
|
|
4476
|
+
u = dr(t, c);
|
|
4432
4477
|
}
|
|
4433
4478
|
let d = T.resolve(u);
|
|
4434
|
-
o || s.note(
|
|
4435
|
-
let f = e.editor &&
|
|
4479
|
+
o || s.note(z.path(d), "Project will be created at");
|
|
4480
|
+
let f = e.editor && re.includes(e.editor) ? e.editor : null, p;
|
|
4436
4481
|
if (f) p = f;
|
|
4437
4482
|
else if (o) p = "cursor";
|
|
4438
4483
|
else {
|
|
4439
4484
|
let e = await s.select({
|
|
4440
4485
|
message: "Which code editor do you use?",
|
|
4441
|
-
options:
|
|
4486
|
+
options: I.map((e) => ({
|
|
4442
4487
|
value: e.value,
|
|
4443
4488
|
label: e.label,
|
|
4444
4489
|
hint: "hint" in e ? e.hint : void 0
|
|
@@ -4455,139 +4500,139 @@ async function Io(e) {
|
|
|
4455
4500
|
message: "Pick a color theme",
|
|
4456
4501
|
options: r.map((e) => ({
|
|
4457
4502
|
value: e.name,
|
|
4458
|
-
label: `${
|
|
4503
|
+
label: `${Lo(e)} ${e.label}`
|
|
4459
4504
|
})),
|
|
4460
4505
|
initialValue: h
|
|
4461
4506
|
});
|
|
4462
4507
|
s.isCancel(e) && X(), g = e;
|
|
4463
4508
|
}
|
|
4464
4509
|
if (!o) {
|
|
4465
|
-
let e =
|
|
4510
|
+
let e = I.find((e) => e.value === p)?.label ?? p, t = n.find((e) => e.value === g)?.label ?? g, r = await s.confirm({ message: `Create ${z.highlight(c)} in ${z.path(d)} with ${z.highlight(e)} config and the ${z.highlight(t)} theme?` });
|
|
4466
4511
|
(s.isCancel(r) || !r) && X();
|
|
4467
4512
|
}
|
|
4468
|
-
if (await
|
|
4513
|
+
if (await q(d) && !await or(d)) {
|
|
4469
4514
|
let e = await s.confirm({
|
|
4470
|
-
message: `Directory ${
|
|
4515
|
+
message: `Directory ${z.path(d)} is not empty. Continue anyway?`,
|
|
4471
4516
|
initialValue: !1
|
|
4472
4517
|
});
|
|
4473
4518
|
(s.isCancel(e) || !e) && X();
|
|
4474
4519
|
}
|
|
4475
4520
|
let _ = s.spinner();
|
|
4476
|
-
_.start("Cloning Hype Stack template..."), await
|
|
4521
|
+
_.start("Cloning Hype Stack template..."), await Ba(d), _.stop(z.success("Template cloned"));
|
|
4477
4522
|
let v = s.spinner();
|
|
4478
|
-
v.start("Setting up project..."), await
|
|
4479
|
-
let y = await
|
|
4480
|
-
await
|
|
4523
|
+
v.start("Setting up project..."), await Qa(d), await eo(d, c), await qa(d, p);
|
|
4524
|
+
let y = await vr(d), b = br(c, y);
|
|
4525
|
+
await _r(d, b), await ho(d, {
|
|
4481
4526
|
projectName: c,
|
|
4482
4527
|
editor: p,
|
|
4483
4528
|
workspace: y
|
|
4484
4529
|
});
|
|
4485
4530
|
let x = T.resolve(d, b.paths?.frontend.root ?? "apps/frontend");
|
|
4486
|
-
a(g) && (await
|
|
4531
|
+
a(g) && (await za(x, i(g)) || s.log.warn(z.muted(`Could not find ${z.path("assets/styles.css")} to apply the ${g} theme`))), await Na(x, e.defaultMode === "dark" || e.defaultMode === "light" ? e.defaultMode : "light") || s.log.warn(z.muted(`Could not find ${z.path("src/hooks/use-theme.ts")} to set the default color mode`)), v.stop(z.success("Project configured"));
|
|
4487
4532
|
let S = s.spinner();
|
|
4488
|
-
S.start("Installing dependencies..."), (await
|
|
4533
|
+
S.start("Installing dependencies..."), (await K("pnpm", ["install"], { cwd: d })).exitCode === 0 ? S.stop(z.success("Dependencies installed")) : (S.stop(z.warning("Dependencies installed with warnings")), s.log.warn(z.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4489
4534
|
let C = s.spinner();
|
|
4490
|
-
C.start("Initializing git repository..."), await
|
|
4535
|
+
C.start("Initializing git repository..."), await $a(d), C.stop(z.success("Git repository initialized with clean history"));
|
|
4491
4536
|
let w = s.spinner();
|
|
4492
4537
|
w.start("Creating .env files from examples...");
|
|
4493
|
-
let E = await
|
|
4538
|
+
let E = await Ya(d);
|
|
4494
4539
|
if (E.length > 0) {
|
|
4495
4540
|
let e = E.length;
|
|
4496
|
-
w.stop(
|
|
4497
|
-
} else w.stop(
|
|
4498
|
-
s.log.success(`${
|
|
4499
|
-
let D = T.relative(process.cwd(), d) || ".", O = [`${
|
|
4500
|
-
E.length > 0 ? O.push(`Review your ${
|
|
4541
|
+
w.stop(z.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4542
|
+
} else w.stop(z.muted("No .env.example files to copy"));
|
|
4543
|
+
s.log.success(`${z.brandBold("Hype Stack")} project ${z.highlight(c)} is ready!`);
|
|
4544
|
+
let D = T.relative(process.cwd(), d) || ".", O = [`${z.command(`cd ${D}`)}`];
|
|
4545
|
+
E.length > 0 ? O.push(`Review your ${z.path(".env")} files and fill in any secrets`) : O.push(`Copy ${z.path(".env.example")} to ${z.path(".env")} and configure`), qi(O);
|
|
4501
4546
|
let k = e.setup === !1;
|
|
4502
|
-
if (e.deferSetup) s.log.info(
|
|
4547
|
+
if (e.deferSetup) s.log.info(z.muted("Docker and migrations will run after your packs are installed."));
|
|
4503
4548
|
else {
|
|
4504
4549
|
let e = !k && (o || await s.confirm({
|
|
4505
4550
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
4506
4551
|
initialValue: !0
|
|
4507
4552
|
}));
|
|
4508
|
-
s.isCancel(e) && X(), e ? await
|
|
4553
|
+
s.isCancel(e) && X(), e ? await ia(d, o) : s.log.info(z.muted("Docker and migrations can run later via `npx @hype-stack/cli onboard`.")), Eo();
|
|
4509
4554
|
}
|
|
4510
|
-
return await
|
|
4555
|
+
return await go("project_create"), s.outro(z.muted("Happy building!")), d;
|
|
4511
4556
|
}
|
|
4512
4557
|
//#endregion
|
|
4513
4558
|
//#region src/commands/init.ts
|
|
4514
|
-
async function
|
|
4559
|
+
async function zo(e) {
|
|
4515
4560
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4516
|
-
if (n || (
|
|
4517
|
-
s.log.error(`This doesn't look like a Hype Stack project. ${
|
|
4561
|
+
if (n || (wa(), s.intro(z.brandBold("Initialize Hype Stack configuration"))), !await xr(t)) {
|
|
4562
|
+
s.log.error(`This doesn't look like a Hype Stack project. ${z.muted("Expected apps/ directory and package.json")}`), s.outro(z.muted(`Run ${z.command("npx @hype-stack/cli create")} to scaffold a new project.`));
|
|
4518
4563
|
return;
|
|
4519
4564
|
}
|
|
4520
|
-
if (await
|
|
4521
|
-
let e = await
|
|
4565
|
+
if (await gr(t)) {
|
|
4566
|
+
let e = await hr(t);
|
|
4522
4567
|
if (e && !n) {
|
|
4523
|
-
s.log.info(`Found existing ${
|
|
4568
|
+
s.log.info(`Found existing ${z.path("stack.json")} for project ${z.highlight(e.name)}`);
|
|
4524
4569
|
let t = await s.confirm({
|
|
4525
4570
|
message: "Overwrite existing configuration?",
|
|
4526
4571
|
initialValue: !1
|
|
4527
4572
|
});
|
|
4528
4573
|
if (s.isCancel(t) || !t) {
|
|
4529
|
-
s.outro(
|
|
4574
|
+
s.outro(z.muted("Keeping existing configuration."));
|
|
4530
4575
|
return;
|
|
4531
4576
|
}
|
|
4532
4577
|
}
|
|
4533
4578
|
}
|
|
4534
|
-
let r = await
|
|
4579
|
+
let r = await vr(t);
|
|
4535
4580
|
if (!n) {
|
|
4536
4581
|
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4537
4582
|
if (e.length > 0) {
|
|
4538
|
-
s.log.info(
|
|
4539
|
-
for (let [t, n] of e) s.log.message(` ${
|
|
4583
|
+
s.log.info(z.bold("Detected apps:"));
|
|
4584
|
+
for (let [t, n] of e) s.log.message(` ${B.arrow} ${z.highlight(t)} ${z.muted(`→ ${n}`)}`);
|
|
4540
4585
|
}
|
|
4541
4586
|
if (t.length > 0) {
|
|
4542
|
-
s.log.info(
|
|
4543
|
-
for (let [e, n] of t) s.log.message(` ${
|
|
4587
|
+
s.log.info(z.bold("Detected packages:"));
|
|
4588
|
+
for (let [e, n] of t) s.log.message(` ${B.arrow} ${z.highlight(e)} ${z.muted(`→ ${n}`)}`);
|
|
4544
4589
|
}
|
|
4545
4590
|
e.length === 0 && t.length === 0 && s.log.warn("No apps or packages detected in the workspace.");
|
|
4546
4591
|
}
|
|
4547
|
-
let i = (await
|
|
4592
|
+
let i = (await sr(T.join(t, "package.json")))?.name?.replace(/^@/, "").replace(/\/source$/, "") ?? "my-app", a = i;
|
|
4548
4593
|
if (!n) {
|
|
4549
4594
|
let e = await s.text({
|
|
4550
4595
|
message: "Project name for stack.json?",
|
|
4551
4596
|
placeholder: i,
|
|
4552
4597
|
initialValue: i,
|
|
4553
|
-
validate: (e) =>
|
|
4598
|
+
validate: (e) => ka(e ?? "")
|
|
4554
4599
|
});
|
|
4555
|
-
s.isCancel(e) && X(), a =
|
|
4600
|
+
s.isCancel(e) && X(), a = Da(e);
|
|
4556
4601
|
}
|
|
4557
|
-
await
|
|
4602
|
+
await _r(t, br(a, r)), n || (s.log.success(`${z.path("stack.json")} written successfully`), s.outro(z.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
|
|
4558
4603
|
}
|
|
4559
|
-
async function
|
|
4560
|
-
if (await
|
|
4604
|
+
async function Bo(e, t = {}, n) {
|
|
4605
|
+
if (await gr(e)) return {
|
|
4561
4606
|
projectRoot: e,
|
|
4562
4607
|
scaffolded: !1
|
|
4563
4608
|
};
|
|
4564
|
-
let r = t.runInit ?? ((e) =>
|
|
4609
|
+
let r = t.runInit ?? ((e) => zo({
|
|
4565
4610
|
cwd: e,
|
|
4566
4611
|
silent: !0
|
|
4567
|
-
})), i = t.runCreate ?? ((e, t) =>
|
|
4612
|
+
})), i = t.runCreate ?? ((e, t) => Ro({
|
|
4568
4613
|
parentDirectory: e,
|
|
4569
4614
|
deferSetup: !0,
|
|
4570
4615
|
skipBanner: !0,
|
|
4571
4616
|
defaultTheme: t?.defaultTheme,
|
|
4572
4617
|
defaultMode: t?.defaultMode
|
|
4573
4618
|
}));
|
|
4574
|
-
if (await
|
|
4575
|
-
s.log.warn(`No ${
|
|
4619
|
+
if (await xr(e)) {
|
|
4620
|
+
s.log.warn(`No ${z.path("stack.json")} found in ${z.path(e)}.`);
|
|
4576
4621
|
let t = await s.confirm({
|
|
4577
|
-
message: `Create ${
|
|
4622
|
+
message: `Create ${z.path("stack.json")} now?`,
|
|
4578
4623
|
initialValue: !0
|
|
4579
4624
|
});
|
|
4580
4625
|
if (s.isCancel(t) || !t) return null;
|
|
4581
4626
|
await r(e);
|
|
4582
|
-
let n = await
|
|
4583
|
-
return n && s.log.success(`${
|
|
4627
|
+
let n = await gr(e);
|
|
4628
|
+
return n && s.log.success(`${z.path("stack.json")} created`), n ? {
|
|
4584
4629
|
projectRoot: e,
|
|
4585
4630
|
scaffolded: !1
|
|
4586
4631
|
} : null;
|
|
4587
4632
|
}
|
|
4588
|
-
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${
|
|
4633
|
+
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${z.path("stack.json")} here.`);
|
|
4589
4634
|
let a = await s.confirm({
|
|
4590
|
-
message: `Is ${
|
|
4635
|
+
message: `Is ${z.path(e)} where you want to work?`,
|
|
4591
4636
|
initialValue: !0
|
|
4592
4637
|
});
|
|
4593
4638
|
if (s.isCancel(a) || !a) return null;
|
|
@@ -4597,41 +4642,41 @@ async function Ro(e, t = {}, n) {
|
|
|
4597
4642
|
});
|
|
4598
4643
|
if (s.isCancel(o) || !o) return null;
|
|
4599
4644
|
let c = await i(e, n);
|
|
4600
|
-
return await
|
|
4645
|
+
return await gr(c) ? {
|
|
4601
4646
|
projectRoot: c,
|
|
4602
4647
|
scaffolded: !0
|
|
4603
4648
|
} : null;
|
|
4604
4649
|
}
|
|
4605
4650
|
//#endregion
|
|
4606
4651
|
//#region src/commands/compose.ts
|
|
4607
|
-
async function
|
|
4652
|
+
async function Vo(e = {}) {
|
|
4608
4653
|
let t = e.cwd ?? process.cwd();
|
|
4609
|
-
|
|
4610
|
-
let n = await
|
|
4654
|
+
Ca();
|
|
4655
|
+
let n = await Bo(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4611
4656
|
try {
|
|
4612
|
-
a = await
|
|
4657
|
+
a = await hr(r ?? t);
|
|
4613
4658
|
} catch (e) {
|
|
4614
|
-
s.cancel(`Could not parse ${
|
|
4659
|
+
s.cancel(`Could not parse ${z.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4615
4660
|
}
|
|
4616
|
-
a || (s.cancel(r ? `Could not read ${
|
|
4661
|
+
a || (s.cancel(r ? `Could not read ${z.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli compose' again.` : `No ${z.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli compose'.`), process.exit(1)), a.paths || (s.cancel(`${z.path("stack.json")} is missing ${z.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
4617
4662
|
let o = r ?? t;
|
|
4618
|
-
s.intro(
|
|
4663
|
+
s.intro(z.brandBold("Compose your stack"));
|
|
4619
4664
|
let c = s.spinner();
|
|
4620
4665
|
c.start("Loading packs...");
|
|
4621
4666
|
let l;
|
|
4622
4667
|
try {
|
|
4623
|
-
l = await
|
|
4668
|
+
l = await Dr();
|
|
4624
4669
|
} catch (e) {
|
|
4625
4670
|
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);
|
|
4626
4671
|
}
|
|
4627
4672
|
c.stop("Packs loaded");
|
|
4628
|
-
let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await
|
|
4673
|
+
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 qn(L()))?.token ?? null, h = await bo(l, d, {
|
|
4629
4674
|
token: m,
|
|
4630
4675
|
key: p
|
|
4631
4676
|
}), g = (e) => {
|
|
4632
4677
|
let t = f.get(e);
|
|
4633
4678
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4634
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await
|
|
4679
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await Ho({
|
|
4635
4680
|
packs: l,
|
|
4636
4681
|
installedSet: d,
|
|
4637
4682
|
stateOf: g,
|
|
@@ -4639,49 +4684,49 @@ async function zo(e = {}) {
|
|
|
4639
4684
|
adminAvailable: !!a.apps.admin
|
|
4640
4685
|
});
|
|
4641
4686
|
if (v === null && (s.cancel("Cancelled."), process.exit(0)), v.length === 0) {
|
|
4642
|
-
s.outro(
|
|
4687
|
+
s.outro(z.muted("No packs selected. Nothing to do."));
|
|
4643
4688
|
return;
|
|
4644
4689
|
}
|
|
4645
|
-
let b =
|
|
4690
|
+
let b = Go(v), x = Ko(v), S = pa(l, b), C = oa(ma(l, S)), w;
|
|
4646
4691
|
try {
|
|
4647
|
-
w =
|
|
4692
|
+
w = ca(b, C, u);
|
|
4648
4693
|
} catch (e) {
|
|
4649
4694
|
s.cancel(Q(e)), process.exit(1);
|
|
4650
4695
|
}
|
|
4651
4696
|
if (w.order.length === 0) {
|
|
4652
|
-
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(
|
|
4697
|
+
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(z.muted("Your selection is already part of the project."));
|
|
4653
4698
|
return;
|
|
4654
4699
|
}
|
|
4655
|
-
let T =
|
|
4700
|
+
let T = la({
|
|
4656
4701
|
order: w.order,
|
|
4657
4702
|
graph: C,
|
|
4658
4703
|
isLocked: _,
|
|
4659
4704
|
installed: u
|
|
4660
4705
|
});
|
|
4661
4706
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4662
|
-
let e = await
|
|
4663
|
-
e && (m = e, h = await
|
|
4707
|
+
let e = await rr();
|
|
4708
|
+
e && (m = e, h = await bo(l, d, {
|
|
4664
4709
|
token: m,
|
|
4665
4710
|
key: p
|
|
4666
|
-
}), T =
|
|
4711
|
+
}), T = la({
|
|
4667
4712
|
order: w.order,
|
|
4668
4713
|
graph: C,
|
|
4669
4714
|
isLocked: _,
|
|
4670
4715
|
installed: u
|
|
4671
4716
|
}));
|
|
4672
4717
|
}
|
|
4673
|
-
if (T.blocked.length > 0 && await
|
|
4674
|
-
s.outro(
|
|
4718
|
+
if (T.blocked.length > 0 && await So(T.blocked, _, f), T.installable.length === 0) {
|
|
4719
|
+
s.outro(z.muted("Nothing left to install once locked packs are removed."));
|
|
4675
4720
|
return;
|
|
4676
4721
|
}
|
|
4677
|
-
if (
|
|
4722
|
+
if (Co(T.installable, f), !e.yes) {
|
|
4678
4723
|
let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4679
4724
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
4680
4725
|
}
|
|
4681
4726
|
c.start("Downloading packs...");
|
|
4682
4727
|
let E;
|
|
4683
4728
|
try {
|
|
4684
|
-
E = await
|
|
4729
|
+
E = await wo(T.installable, {
|
|
4685
4730
|
token: m,
|
|
4686
4731
|
key: p
|
|
4687
4732
|
});
|
|
@@ -4689,7 +4734,7 @@ async function zo(e = {}) {
|
|
|
4689
4734
|
c.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
|
|
4690
4735
|
}
|
|
4691
4736
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4692
|
-
let D = await
|
|
4737
|
+
let D = await Oo({
|
|
4693
4738
|
prepared: E,
|
|
4694
4739
|
config: a,
|
|
4695
4740
|
cwd: o,
|
|
@@ -4699,7 +4744,7 @@ async function zo(e = {}) {
|
|
|
4699
4744
|
});
|
|
4700
4745
|
try {
|
|
4701
4746
|
c.start("Installing pack files...");
|
|
4702
|
-
let t = await
|
|
4747
|
+
let t = await Ri({
|
|
4703
4748
|
packs: E,
|
|
4704
4749
|
config: a,
|
|
4705
4750
|
projectRoot: o,
|
|
@@ -4712,18 +4757,22 @@ async function zo(e = {}) {
|
|
|
4712
4757
|
for (let e of t.errors) s.log.error(e);
|
|
4713
4758
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4714
4759
|
}
|
|
4715
|
-
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${
|
|
4760
|
+
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${z.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));
|
|
4716
4761
|
for (let e of t.errors) s.log.error(e);
|
|
4717
|
-
await
|
|
4762
|
+
await To({
|
|
4718
4763
|
prepared: E,
|
|
4719
4764
|
paths: a.paths,
|
|
4720
4765
|
cwd: o,
|
|
4721
4766
|
spinner: c
|
|
4722
|
-
})
|
|
4767
|
+
});
|
|
4768
|
+
let n;
|
|
4769
|
+
i && (n = await aa(o, e.yes ?? !1)), await pr({
|
|
4723
4770
|
projectRoot: o,
|
|
4724
4771
|
paths: a.paths,
|
|
4725
|
-
skipPrompts: e.yes ?? !1
|
|
4726
|
-
|
|
4772
|
+
skipPrompts: e.yes ?? !1,
|
|
4773
|
+
dbReady: n,
|
|
4774
|
+
freshScaffold: i
|
|
4775
|
+
}), Eo(), s.outro(z.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4727
4776
|
} finally {
|
|
4728
4777
|
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
4729
4778
|
recursive: !0,
|
|
@@ -4731,25 +4780,25 @@ async function zo(e = {}) {
|
|
|
4731
4780
|
})));
|
|
4732
4781
|
}
|
|
4733
4782
|
}
|
|
4734
|
-
async function
|
|
4783
|
+
async function Ho(e) {
|
|
4735
4784
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4736
4785
|
if (i.packs && i.packs.length > 0) {
|
|
4737
|
-
let e = i.packs.map(
|
|
4786
|
+
let e = i.packs.map(Wo), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4738
4787
|
return n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4739
4788
|
}
|
|
4740
4789
|
let o = t.filter((e) => n.has(e.name));
|
|
4741
|
-
o.length > 0 && s.note(o.map((e) => ` ${
|
|
4790
|
+
o.length > 0 && s.note(o.map((e) => ` ${z.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4742
4791
|
let c = t.filter((e) => !n.has(e.name));
|
|
4743
|
-
if (c.length === 0) return s.outro(
|
|
4744
|
-
let l =
|
|
4745
|
-
s.note(c.map((e) => ` ${
|
|
4746
|
-
let u =
|
|
4792
|
+
if (c.length === 0) return s.outro(z.muted("Every available pack is already installed.")), [];
|
|
4793
|
+
let l = se();
|
|
4794
|
+
s.note(c.map((e) => ` ${B.arrow} ${z.highlight(e.displayName)} ${ge(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4795
|
+
let u = Gi(c, { adminAvailable: a }), d = [];
|
|
4747
4796
|
for (let e of u) {
|
|
4748
4797
|
let t = e.packs.map((e) => {
|
|
4749
4798
|
let t = r(e.name);
|
|
4750
4799
|
return {
|
|
4751
4800
|
value: e.name,
|
|
4752
|
-
label: `${e.displayName} ${
|
|
4801
|
+
label: `${e.displayName} ${xo(t, e.price)}`,
|
|
4753
4802
|
hint: e.description
|
|
4754
4803
|
};
|
|
4755
4804
|
});
|
|
@@ -4766,7 +4815,7 @@ async function Bo(e) {
|
|
|
4766
4815
|
});
|
|
4767
4816
|
continue;
|
|
4768
4817
|
}
|
|
4769
|
-
let n = await
|
|
4818
|
+
let n = await Ea({
|
|
4770
4819
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4771
4820
|
options: t,
|
|
4772
4821
|
required: !1
|
|
@@ -4776,20 +4825,20 @@ async function Bo(e) {
|
|
|
4776
4825
|
}
|
|
4777
4826
|
return d;
|
|
4778
4827
|
}
|
|
4779
|
-
var
|
|
4780
|
-
function
|
|
4781
|
-
let t = e.match(
|
|
4828
|
+
var Uo = /@(frontend|admin)$/;
|
|
4829
|
+
function Wo(e) {
|
|
4830
|
+
let t = e.match(Uo);
|
|
4782
4831
|
return t ? {
|
|
4783
4832
|
name: e.slice(0, -t[0].length),
|
|
4784
4833
|
slot: t[1]
|
|
4785
4834
|
} : { name: e };
|
|
4786
4835
|
}
|
|
4787
|
-
function
|
|
4836
|
+
function Go(e) {
|
|
4788
4837
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4789
4838
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4790
4839
|
return n;
|
|
4791
4840
|
}
|
|
4792
|
-
function
|
|
4841
|
+
function Ko(e) {
|
|
4793
4842
|
let t = /* @__PURE__ */ new Map();
|
|
4794
4843
|
for (let n of e) {
|
|
4795
4844
|
if (!n.slot) continue;
|
|
@@ -4800,28 +4849,28 @@ function Wo(e) {
|
|
|
4800
4849
|
}
|
|
4801
4850
|
//#endregion
|
|
4802
4851
|
//#region src/commands/login.ts
|
|
4803
|
-
async function
|
|
4804
|
-
|
|
4852
|
+
async function qo() {
|
|
4853
|
+
wa(), s.intro(z.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
4805
4854
|
let e;
|
|
4806
4855
|
try {
|
|
4807
|
-
e = await
|
|
4808
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
4856
|
+
e = await nr({ onUrl: (e) => {
|
|
4857
|
+
s.log.info(`If your browser didn't open, visit:\n ${z.path(e)}`);
|
|
4809
4858
|
} });
|
|
4810
4859
|
} catch (e) {
|
|
4811
4860
|
s.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
|
|
4812
4861
|
}
|
|
4813
|
-
s.outro(
|
|
4862
|
+
s.outro(z.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."));
|
|
4814
4863
|
}
|
|
4815
4864
|
//#endregion
|
|
4816
4865
|
//#region src/commands/logout.ts
|
|
4817
|
-
async function
|
|
4818
|
-
|
|
4819
|
-
let e =
|
|
4866
|
+
async function Jo() {
|
|
4867
|
+
wa(), s.intro(z.brandBold("Log out of Hype Stack"));
|
|
4868
|
+
let e = L(), t = await qn(e);
|
|
4820
4869
|
if (!t) {
|
|
4821
|
-
s.outro(
|
|
4870
|
+
s.outro(z.muted("You're not logged in."));
|
|
4822
4871
|
return;
|
|
4823
4872
|
}
|
|
4824
|
-
await
|
|
4873
|
+
await zn(t.token).catch(() => null), await Yn(e), s.outro(z.brand("Logged out."));
|
|
4825
4874
|
}
|
|
4826
4875
|
//#endregion
|
|
4827
4876
|
//#region src/core/onboard-catalog.ts
|
|
@@ -4835,15 +4884,15 @@ var $ = {
|
|
|
4835
4884
|
Resend: "resend",
|
|
4836
4885
|
IpLocate: "iplocate",
|
|
4837
4886
|
Sentry: "sentry"
|
|
4838
|
-
},
|
|
4839
|
-
function
|
|
4887
|
+
}, Yo = new Set(Object.values($));
|
|
4888
|
+
function Xo(e) {
|
|
4840
4889
|
return e.toLowerCase().replace(/[^a-z0-9]+/g, "").trim();
|
|
4841
4890
|
}
|
|
4842
|
-
function
|
|
4843
|
-
let t =
|
|
4844
|
-
return
|
|
4891
|
+
function Zo(e) {
|
|
4892
|
+
let t = Xo(e);
|
|
4893
|
+
return Yo.has(t) ? t : void 0;
|
|
4845
4894
|
}
|
|
4846
|
-
var
|
|
4895
|
+
var Qo = {
|
|
4847
4896
|
[$.Config]: { hint: "App URLs. Defaults work for local dev." },
|
|
4848
4897
|
[$.Databases]: { hint: "Credentials for the local Docker Postgres and Valkey containers." },
|
|
4849
4898
|
[$.Workos]: {
|
|
@@ -4881,28 +4930,28 @@ var Xo = {
|
|
|
4881
4930
|
link: "https://sentry.io",
|
|
4882
4931
|
hint: "Your project DSN. Leave blank to skip Sentry for now."
|
|
4883
4932
|
}
|
|
4884
|
-
},
|
|
4885
|
-
function
|
|
4886
|
-
let t =
|
|
4887
|
-
return t ?
|
|
4933
|
+
}, $o = { hint: "Add your value, or press Enter to leave it blank." };
|
|
4934
|
+
function es(e) {
|
|
4935
|
+
let t = Zo(e);
|
|
4936
|
+
return t ? Qo[t] : $o;
|
|
4888
4937
|
}
|
|
4889
|
-
var
|
|
4938
|
+
var ts = {
|
|
4890
4939
|
"starter-saas-workos": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4891
4940
|
"starter-saas-betterauth": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4892
4941
|
"pack-notifications": ["Notifications push over the `appChannel` socket channel; register it in your server startup to go live."],
|
|
4893
4942
|
"pack-collaboration": ["Team and TeamMember are available as CASL subjects; project member and team management reuse the existing `Project` subject."]
|
|
4894
4943
|
};
|
|
4895
|
-
function
|
|
4944
|
+
function ns(e) {
|
|
4896
4945
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4897
4946
|
for (let r of e) {
|
|
4898
|
-
let e =
|
|
4947
|
+
let e = ts[r];
|
|
4899
4948
|
if (e) for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
4900
4949
|
}
|
|
4901
4950
|
return n;
|
|
4902
4951
|
}
|
|
4903
4952
|
//#endregion
|
|
4904
4953
|
//#region src/core/onboard-env.ts
|
|
4905
|
-
function
|
|
4954
|
+
function rs(e) {
|
|
4906
4955
|
let t = [], n = "";
|
|
4907
4956
|
for (let r of e.split(/\r?\n/)) {
|
|
4908
4957
|
let e = r.trim();
|
|
@@ -4928,19 +4977,19 @@ function ts(e) {
|
|
|
4928
4977
|
}
|
|
4929
4978
|
return t;
|
|
4930
4979
|
}
|
|
4931
|
-
var
|
|
4980
|
+
var is = [
|
|
4932
4981
|
"replace-with",
|
|
4933
4982
|
"examplepublickey",
|
|
4934
4983
|
"change-me",
|
|
4935
4984
|
"your-key-here"
|
|
4936
4985
|
];
|
|
4937
|
-
function
|
|
4986
|
+
function as(e) {
|
|
4938
4987
|
let t = e.trim();
|
|
4939
4988
|
if (t === "") return !0;
|
|
4940
4989
|
let n = t.toLowerCase();
|
|
4941
|
-
return
|
|
4990
|
+
return is.some((e) => n.includes(e));
|
|
4942
4991
|
}
|
|
4943
|
-
function
|
|
4992
|
+
function os(e, t, n) {
|
|
4944
4993
|
let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
|
|
4945
4994
|
if (i) return e;
|
|
4946
4995
|
let r = e.trim();
|
|
@@ -4950,109 +4999,109 @@ function is(e, t, n) {
|
|
|
4950
4999
|
});
|
|
4951
5000
|
return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
|
|
4952
5001
|
}
|
|
4953
|
-
async function
|
|
5002
|
+
async function ss(e) {
|
|
4954
5003
|
return await J(e) ? y.readFile(e, "utf-8") : "";
|
|
4955
5004
|
}
|
|
4956
|
-
async function
|
|
5005
|
+
async function cs(e) {
|
|
4957
5006
|
let t = T.join(T.dirname(e), ".env");
|
|
4958
5007
|
return await J(t) || await y.copyFile(e, t), t;
|
|
4959
5008
|
}
|
|
4960
|
-
async function
|
|
4961
|
-
let r =
|
|
5009
|
+
async function ls(e, t, n) {
|
|
5010
|
+
let r = os(await ss(e), t, n);
|
|
4962
5011
|
await y.writeFile(e, r, "utf-8");
|
|
4963
5012
|
}
|
|
4964
5013
|
//#endregion
|
|
4965
5014
|
//#region src/commands/onboard.ts
|
|
4966
|
-
async function
|
|
5015
|
+
async function us(e = {}) {
|
|
4967
5016
|
let t = e.cwd ?? process.cwd();
|
|
4968
|
-
|
|
5017
|
+
Ca(), s.intro(z.brandBold("Onboard your stack"));
|
|
4969
5018
|
let n;
|
|
4970
5019
|
try {
|
|
4971
|
-
n = await
|
|
5020
|
+
n = await hr(t);
|
|
4972
5021
|
} catch {
|
|
4973
5022
|
n = null;
|
|
4974
5023
|
}
|
|
4975
|
-
n || (s.cancel(`${
|
|
4976
|
-
let r = await
|
|
4977
|
-
r.length === 0 && s.log.warn(
|
|
4978
|
-
for (let n of r) await
|
|
4979
|
-
let i =
|
|
4980
|
-
i.length > 0 && s.note(i.map((e) => ` ${
|
|
5024
|
+
n || (s.cancel(`${z.path("stack.json")} not found. Run ${z.command("npx @hype-stack/cli init")} first.`), process.exit(1));
|
|
5025
|
+
let r = await Xa(t);
|
|
5026
|
+
r.length === 0 && s.log.warn(z.muted("No .env.example files found; skipping env setup."));
|
|
5027
|
+
for (let n of r) await ds(n, t, e.yes ?? !1);
|
|
5028
|
+
let i = ns(n.installedPacks ?? []);
|
|
5029
|
+
i.length > 0 && s.note(i.map((e) => ` ${z.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await ms(t, e.yes ?? !1), s.outro(z.brand(`All set. Run ${z.command("pnpm dev")} to start your app.`));
|
|
4981
5030
|
}
|
|
4982
|
-
async function
|
|
4983
|
-
let r = T.relative(t, e) || e, i = await
|
|
5031
|
+
async function ds(e, t, n) {
|
|
5032
|
+
let r = T.relative(t, e) || e, i = await cs(e), a = await ss(i), o = rs(await y.readFile(e, "utf-8")), c = z.path(r);
|
|
4984
5033
|
s.log.step(`Env: ${c}`);
|
|
4985
5034
|
for (let e of o) {
|
|
4986
|
-
let t = e.vars.filter((e) =>
|
|
5035
|
+
let t = e.vars.filter((e) => as(e.value));
|
|
4987
5036
|
if (t.length === 0) continue;
|
|
4988
|
-
let r =
|
|
4989
|
-
s.log.step(o), r.link && (s.log.info(`${
|
|
5037
|
+
let r = es(e.section), o = e.section ? z.bold(e.section) : z.bold("Variables");
|
|
5038
|
+
s.log.step(o), r.link && (s.log.info(`${z.muted("Get your values:")} ${ge(r.link)}`), r.serviceChecklist && r.serviceChecklist.length > 0 && s.note(r.serviceChecklist.map((e) => ` ${z.muted("·")} ${e}`).join("\n"), "Setup")), s.log.info(z.muted(r.hint));
|
|
4990
5039
|
for (let e of t) {
|
|
4991
5040
|
if (n) {
|
|
4992
|
-
s.log.info(`${
|
|
5041
|
+
s.log.info(`${z.label(e.key)} ${z.muted("skipped (non-interactive)")}`);
|
|
4993
5042
|
continue;
|
|
4994
5043
|
}
|
|
4995
|
-
let t =
|
|
4996
|
-
message: `${
|
|
5044
|
+
let t = fs(a, e.key), o = await s.text({
|
|
5045
|
+
message: `${z.label(e.key)}`,
|
|
4997
5046
|
placeholder: t || r.hint
|
|
4998
5047
|
});
|
|
4999
5048
|
s.isCancel(o) && X();
|
|
5000
5049
|
let c = (o ?? "").trim();
|
|
5001
5050
|
if (c === "") {
|
|
5002
|
-
s.log.warn(
|
|
5051
|
+
s.log.warn(z.muted(`${e.key} left blank.`));
|
|
5003
5052
|
continue;
|
|
5004
5053
|
}
|
|
5005
|
-
await
|
|
5054
|
+
await ls(i, e.key, c), s.log.success(`${e.key} saved`);
|
|
5006
5055
|
}
|
|
5007
5056
|
}
|
|
5008
5057
|
}
|
|
5009
|
-
function
|
|
5058
|
+
function fs(e, t) {
|
|
5010
5059
|
for (let n of e.split(/\r?\n/)) {
|
|
5011
|
-
let e = n.match(RegExp(`^${
|
|
5060
|
+
let e = n.match(RegExp(`^${ps(t)}\\s*=\\s*(.*)$`));
|
|
5012
5061
|
if (e) return e[1].trim();
|
|
5013
5062
|
}
|
|
5014
5063
|
return "";
|
|
5015
5064
|
}
|
|
5016
|
-
function
|
|
5065
|
+
function ps(e) {
|
|
5017
5066
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5018
5067
|
}
|
|
5019
|
-
async function
|
|
5020
|
-
if (!await
|
|
5021
|
-
s.log.info(
|
|
5068
|
+
async function ms(e, t) {
|
|
5069
|
+
if (!await Ji() && !await Xi(e, t, !1)) {
|
|
5070
|
+
s.log.info(z.muted(`Start services later with ${z.command("docker compose up -d")} (in apps/backend), then ${z.command("pnpm --filter @internal/backend migration:latest")}.`));
|
|
5022
5071
|
return;
|
|
5023
5072
|
}
|
|
5024
5073
|
let n = s.spinner();
|
|
5025
|
-
if (n.start("Waiting for Postgres to be ready..."), !await
|
|
5026
|
-
n.error("Postgres health check timed out"), s.log.warn(
|
|
5074
|
+
if (n.start("Waiting for Postgres to be ready..."), !await Qi(e)) {
|
|
5075
|
+
n.error("Postgres health check timed out"), s.log.warn(z.muted(`Run migrations manually once Postgres is ready: ${z.command("pnpm --filter @internal/backend migration:latest")}`));
|
|
5027
5076
|
return;
|
|
5028
5077
|
}
|
|
5029
|
-
if (n.stop(
|
|
5030
|
-
s.log.info(
|
|
5078
|
+
if (n.stop(z.success("Postgres is ready")), await ea(e)) {
|
|
5079
|
+
s.log.info(z.muted("Migrations already applied, skipping."));
|
|
5031
5080
|
return;
|
|
5032
5081
|
}
|
|
5033
5082
|
let r = t ? !0 : await s.confirm({
|
|
5034
|
-
message: `Run database migrations with ${
|
|
5083
|
+
message: `Run database migrations with ${z.command("prisma migrate deploy")}?`,
|
|
5035
5084
|
initialValue: !0
|
|
5036
5085
|
});
|
|
5037
5086
|
if (s.isCancel(r) && X(), !r) {
|
|
5038
|
-
s.log.info(
|
|
5087
|
+
s.log.info(z.muted("Skipping database migrations."));
|
|
5039
5088
|
return;
|
|
5040
5089
|
}
|
|
5041
|
-
await
|
|
5090
|
+
await ta(e);
|
|
5042
5091
|
}
|
|
5043
5092
|
//#endregion
|
|
5044
5093
|
//#region src/core/templates.ts
|
|
5045
|
-
var
|
|
5094
|
+
var hs = G.createRequest()({
|
|
5046
5095
|
endpoint: "/templates/list",
|
|
5047
5096
|
method: "GET"
|
|
5048
5097
|
});
|
|
5049
|
-
async function
|
|
5050
|
-
let { data: e, error: t } = await
|
|
5098
|
+
async function gs() {
|
|
5099
|
+
let { data: e, error: t } = await hs.send();
|
|
5051
5100
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
5052
5101
|
return e.templates;
|
|
5053
5102
|
}
|
|
5054
|
-
async function
|
|
5055
|
-
let { data: t, error: n, status: r } = await
|
|
5103
|
+
async function _s(e) {
|
|
5104
|
+
let { data: t, error: n, status: r } = await G.createRequest()({
|
|
5056
5105
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
5057
5106
|
method: "GET"
|
|
5058
5107
|
}).send();
|
|
@@ -5060,13 +5109,13 @@ async function hs(e) {
|
|
|
5060
5109
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
5061
5110
|
return t;
|
|
5062
5111
|
}
|
|
5063
|
-
async function
|
|
5064
|
-
let n =
|
|
5112
|
+
async function vs(e, t = {}) {
|
|
5113
|
+
let n = G.createRequest()({
|
|
5065
5114
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
5066
5115
|
method: "POST"
|
|
5067
5116
|
}), r = {
|
|
5068
|
-
"X-Device-Id":
|
|
5069
|
-
"X-Client-Info":
|
|
5117
|
+
"X-Device-Id": Zn(),
|
|
5118
|
+
"X-Client-Info": Qn()
|
|
5070
5119
|
};
|
|
5071
5120
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
5072
5121
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -5088,29 +5137,29 @@ async function gs(e, t = {}) {
|
|
|
5088
5137
|
}
|
|
5089
5138
|
//#endregion
|
|
5090
5139
|
//#region src/commands/template.ts
|
|
5091
|
-
async function
|
|
5140
|
+
async function ys(t = {}) {
|
|
5092
5141
|
let n = t.cwd ?? process.cwd();
|
|
5093
|
-
|
|
5142
|
+
Ca();
|
|
5094
5143
|
let r = s.spinner();
|
|
5095
5144
|
r.start("Loading packs...");
|
|
5096
5145
|
let o;
|
|
5097
5146
|
try {
|
|
5098
|
-
o = await
|
|
5147
|
+
o = await Dr();
|
|
5099
5148
|
} catch (e) {
|
|
5100
5149
|
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);
|
|
5101
5150
|
}
|
|
5102
5151
|
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
5103
5152
|
let c;
|
|
5104
5153
|
try {
|
|
5105
|
-
c = await
|
|
5154
|
+
c = await gs();
|
|
5106
5155
|
} catch (e) {
|
|
5107
5156
|
r.stop("Failed to load templates"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${Q(e)}`), process.exit(1);
|
|
5108
5157
|
}
|
|
5109
5158
|
let l = t.templateId;
|
|
5110
5159
|
if (!l) {
|
|
5111
5160
|
t.yes && (r.stop("Template id required"), s.cancel("Pass a template id with `npx @hype-stack/cli template <id>` (required in --yes mode)."), process.exit(1)), c.length === 0 && (r.stop("No templates available"), s.cancel("No templates are available yet. Check back later."), process.exit(1)), r.stop("Templates loaded");
|
|
5112
|
-
let e =
|
|
5113
|
-
s.note(c.map((t) => ` ${
|
|
5161
|
+
let e = se();
|
|
5162
|
+
s.note(c.map((t) => ` ${B.arrow} ${z.highlight(t.name)} ${ge(`${e}/templates/${t.id}`)}`).join("\n"), "Browse templates");
|
|
5114
5163
|
let n = await s.select({
|
|
5115
5164
|
message: "Choose a template",
|
|
5116
5165
|
options: c.map((e) => ({
|
|
@@ -5125,147 +5174,151 @@ async function _s(t = {}) {
|
|
|
5125
5174
|
u || (r.stop("Template not found"), s.cancel(`Template "${l}" not found. Available: ${c.map((e) => e.id).join(", ") || "(none)"}`), process.exit(1)), r.stop(`Template: ${u.name}`);
|
|
5126
5175
|
let d;
|
|
5127
5176
|
try {
|
|
5128
|
-
d = await
|
|
5177
|
+
d = await _s(u.id);
|
|
5129
5178
|
} catch (e) {
|
|
5130
5179
|
s.cancel(Q(e)), process.exit(1);
|
|
5131
5180
|
}
|
|
5132
|
-
let f = await
|
|
5181
|
+
let f = await Bo(n, {}, {
|
|
5133
5182
|
defaultTheme: d.theme,
|
|
5134
5183
|
defaultMode: d.defaultMode
|
|
5135
5184
|
}), p = f?.projectRoot ?? null, m = f?.scaffolded ?? !1, h;
|
|
5136
5185
|
try {
|
|
5137
|
-
h = await
|
|
5186
|
+
h = await hr(p ?? n);
|
|
5138
5187
|
} catch (e) {
|
|
5139
|
-
s.cancel(`Could not parse ${
|
|
5188
|
+
s.cancel(`Could not parse ${z.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
5140
5189
|
}
|
|
5141
|
-
h || (s.cancel(p ? `Could not read ${
|
|
5190
|
+
h || (s.cancel(p ? `Could not read ${z.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${z.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), process.exit(1)), h.paths || (s.cancel(`${z.path("stack.json")} is missing ${z.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
5142
5191
|
let g = p ?? n;
|
|
5143
|
-
s.intro(
|
|
5144
|
-
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await
|
|
5192
|
+
s.intro(z.brandBold("Install a template"));
|
|
5193
|
+
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await qn(L()))?.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({
|
|
5145
5194
|
packs: o,
|
|
5146
5195
|
templatePacks: E,
|
|
5147
5196
|
installedSet: v,
|
|
5148
5197
|
options: t
|
|
5149
5198
|
}), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
|
|
5150
5199
|
k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
|
|
5151
|
-
let ee =
|
|
5200
|
+
let ee = ma(o, w), A = oa(ee), j;
|
|
5152
5201
|
try {
|
|
5153
|
-
|
|
5202
|
+
j = ca(O, A, _);
|
|
5154
5203
|
} catch (e) {
|
|
5155
5204
|
s.cancel(Q(e)), process.exit(1);
|
|
5156
5205
|
}
|
|
5157
|
-
if (
|
|
5158
|
-
s.outro(
|
|
5206
|
+
if (j.order.length === 0) {
|
|
5207
|
+
s.outro(z.muted("Every pack in this template is already installed."));
|
|
5159
5208
|
return;
|
|
5160
5209
|
}
|
|
5161
|
-
let
|
|
5210
|
+
let M = await bo(ee, v, {
|
|
5162
5211
|
token: S,
|
|
5163
5212
|
key: x
|
|
5164
|
-
}),
|
|
5213
|
+
}), te = (e) => {
|
|
5165
5214
|
let t = b.get(e);
|
|
5166
|
-
return !t || t.tier === "free" ? "free" :
|
|
5167
|
-
},
|
|
5168
|
-
order:
|
|
5215
|
+
return !t || t.tier === "free" ? "free" : M[e]?.owned ? "owned" : "locked";
|
|
5216
|
+
}, N = (e) => !v.has(e) && te(e) === "locked", P = la({
|
|
5217
|
+
order: j.order,
|
|
5169
5218
|
graph: A,
|
|
5170
|
-
isLocked:
|
|
5219
|
+
isLocked: N,
|
|
5171
5220
|
installed: _
|
|
5172
5221
|
});
|
|
5173
|
-
if (
|
|
5174
|
-
let e = await
|
|
5175
|
-
e && (S = e,
|
|
5222
|
+
if (P.blocked.length > 0 && !S && !x) {
|
|
5223
|
+
let e = await rr();
|
|
5224
|
+
e && (S = e, M = await bo(ee, v, {
|
|
5176
5225
|
token: S,
|
|
5177
5226
|
key: x
|
|
5178
|
-
}),
|
|
5179
|
-
order:
|
|
5227
|
+
}), P = la({
|
|
5228
|
+
order: j.order,
|
|
5180
5229
|
graph: A,
|
|
5181
|
-
isLocked:
|
|
5230
|
+
isLocked: N,
|
|
5182
5231
|
installed: _
|
|
5183
5232
|
}));
|
|
5184
5233
|
}
|
|
5185
|
-
if (
|
|
5186
|
-
s.outro(
|
|
5234
|
+
if (P.blocked.length > 0 && await So(P.blocked, N, b), P.installable.length === 0) {
|
|
5235
|
+
s.outro(z.muted("Nothing left to install once locked packs are removed."));
|
|
5187
5236
|
return;
|
|
5188
5237
|
}
|
|
5189
|
-
if (
|
|
5190
|
-
let e = await s.confirm({ message: `Install template ${
|
|
5238
|
+
if (Co(P.installable, b), !t.yes) {
|
|
5239
|
+
let e = await s.confirm({ message: `Install template ${z.brandBold(u.name)} (${P.installable.length} pack${P.installable.length === 1 ? "" : "s"})?` });
|
|
5191
5240
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5192
5241
|
}
|
|
5193
5242
|
r.start("Downloading packs...");
|
|
5194
|
-
let
|
|
5243
|
+
let F;
|
|
5195
5244
|
try {
|
|
5196
|
-
|
|
5245
|
+
F = await wo(P.installable, {
|
|
5197
5246
|
token: S,
|
|
5198
5247
|
key: x
|
|
5199
5248
|
});
|
|
5200
5249
|
} catch (e) {
|
|
5201
5250
|
r.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
|
|
5202
5251
|
}
|
|
5203
|
-
r.stop(`Downloaded ${
|
|
5204
|
-
let
|
|
5205
|
-
prepared:
|
|
5252
|
+
r.stop(`Downloaded ${F.length} pack${F.length === 1 ? "" : "s"}`);
|
|
5253
|
+
let ne = await Oo({
|
|
5254
|
+
prepared: F,
|
|
5206
5255
|
config: h,
|
|
5207
5256
|
cwd: g,
|
|
5208
5257
|
force: t.force ?? !1,
|
|
5209
5258
|
yes: t.yes ?? !1
|
|
5210
|
-
}),
|
|
5259
|
+
}), I = null;
|
|
5211
5260
|
try {
|
|
5212
5261
|
r.start("Installing pack files...");
|
|
5213
|
-
let n = await
|
|
5214
|
-
packs:
|
|
5262
|
+
let n = await Ri({
|
|
5263
|
+
packs: F,
|
|
5215
5264
|
config: h,
|
|
5216
5265
|
projectRoot: g,
|
|
5217
5266
|
force: t.force ?? !1,
|
|
5218
|
-
overwrite:
|
|
5267
|
+
overwrite: ne
|
|
5219
5268
|
});
|
|
5220
5269
|
if (n.aborted) {
|
|
5221
5270
|
r.stop("Installation aborted");
|
|
5222
5271
|
for (let e of n.errors) s.log.error(e);
|
|
5223
5272
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5224
5273
|
}
|
|
5225
|
-
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${
|
|
5274
|
+
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${z.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));
|
|
5226
5275
|
for (let e of n.errors) s.log.error(e);
|
|
5227
5276
|
r.start("Applying template overrides...");
|
|
5228
|
-
let o = await
|
|
5277
|
+
let o = await vs(u.id, {
|
|
5229
5278
|
token: S,
|
|
5230
5279
|
licenseKey: x
|
|
5231
5280
|
});
|
|
5232
|
-
o.status === "denied" && (r.stop("Template download denied"), s.cancel(`Access to template "${u.id}" was denied (${o.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)),
|
|
5233
|
-
let c = await
|
|
5281
|
+
o.status === "denied" && (r.stop("Template download denied"), s.cancel(`Access to template "${u.id}" was denied (${o.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)), I = o.templateDir;
|
|
5282
|
+
let c = await Bi({
|
|
5234
5283
|
manifest: d,
|
|
5235
5284
|
config: h,
|
|
5236
5285
|
projectRoot: g,
|
|
5237
|
-
templateDir:
|
|
5286
|
+
templateDir: I
|
|
5238
5287
|
});
|
|
5239
5288
|
r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
|
|
5240
5289
|
for (let e of c.errors) s.log.error(e);
|
|
5241
5290
|
if (!m) {
|
|
5242
5291
|
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5243
|
-
a(n) && (await
|
|
5292
|
+
a(n) && (await za(t, i(n)) ? s.log.success(`Applied the ${i(n).label} theme`) : s.log.warning(z.muted(`Could not find ${z.path("assets/styles.css")} to apply the theme`)));
|
|
5244
5293
|
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5245
|
-
await
|
|
5294
|
+
await Na(t, r) ? s.log.success(`Default color mode set to ${r}`) : s.log.warning(z.muted(`Could not find ${z.path("src/hooks/use-theme.ts")} to set the default color mode`));
|
|
5246
5295
|
}
|
|
5247
|
-
await
|
|
5248
|
-
prepared:
|
|
5296
|
+
await Ss({
|
|
5297
|
+
prepared: F,
|
|
5249
5298
|
templateNpm: d.dependencies_npm,
|
|
5250
5299
|
paths: h.paths,
|
|
5251
5300
|
cwd: g,
|
|
5252
5301
|
spinner: r
|
|
5253
|
-
})
|
|
5302
|
+
});
|
|
5303
|
+
let l;
|
|
5304
|
+
m && (l = await aa(g, t.yes ?? !1)), await pr({
|
|
5254
5305
|
projectRoot: g,
|
|
5255
5306
|
paths: h.paths,
|
|
5256
|
-
skipPrompts: t.yes ?? !1
|
|
5257
|
-
|
|
5307
|
+
skipPrompts: t.yes ?? !1,
|
|
5308
|
+
dbReady: l,
|
|
5309
|
+
freshScaffold: m
|
|
5310
|
+
}), Eo(), s.outro(z.brand(`Installed template ${u.name}.`));
|
|
5258
5311
|
} finally {
|
|
5259
|
-
await Promise.all(
|
|
5312
|
+
await Promise.all(F.map((e) => y.rm(e.packDir, {
|
|
5260
5313
|
recursive: !0,
|
|
5261
5314
|
force: !0
|
|
5262
|
-
}))),
|
|
5315
|
+
}))), I && await y.rm(I, {
|
|
5263
5316
|
recursive: !0,
|
|
5264
5317
|
force: !0
|
|
5265
5318
|
});
|
|
5266
5319
|
}
|
|
5267
5320
|
}
|
|
5268
|
-
async function
|
|
5321
|
+
async function bs(e, t, n) {
|
|
5269
5322
|
let r = {};
|
|
5270
5323
|
for (let i of e.slots) {
|
|
5271
5324
|
if (t?.[i.family]) {
|
|
@@ -5289,7 +5342,7 @@ async function vs(e, t, n) {
|
|
|
5289
5342
|
}
|
|
5290
5343
|
return r;
|
|
5291
5344
|
}
|
|
5292
|
-
async function
|
|
5345
|
+
async function xs(e) {
|
|
5293
5346
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5294
5347
|
if (i.packs && i.packs.length > 0) {
|
|
5295
5348
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -5298,9 +5351,9 @@ async function ys(e) {
|
|
|
5298
5351
|
if (i.yes) return [];
|
|
5299
5352
|
let o = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
|
|
5300
5353
|
if (o.length === 0) return [];
|
|
5301
|
-
let c =
|
|
5302
|
-
s.note(o.map((e) => ` ${
|
|
5303
|
-
let l = await
|
|
5354
|
+
let c = se();
|
|
5355
|
+
s.note(o.map((e) => ` ${B.arrow} ${z.highlight(e.displayName)} ${ge(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5356
|
+
let l = await Ea({
|
|
5304
5357
|
message: "Add extra packs on top of the template (optional)",
|
|
5305
5358
|
options: o.map((e) => ({
|
|
5306
5359
|
value: e.name,
|
|
@@ -5311,25 +5364,25 @@ async function ys(e) {
|
|
|
5311
5364
|
});
|
|
5312
5365
|
return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
|
|
5313
5366
|
}
|
|
5314
|
-
async function
|
|
5315
|
-
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o =
|
|
5367
|
+
async function Ss(e) {
|
|
5368
|
+
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);
|
|
5316
5369
|
if (c.errors.length > 0) {
|
|
5317
5370
|
for (let e of c.errors) s.log.error(e);
|
|
5318
5371
|
return;
|
|
5319
5372
|
}
|
|
5320
5373
|
if (c.operations.length === 0) return;
|
|
5321
5374
|
a.start("Installing npm dependencies...");
|
|
5322
|
-
let l = await
|
|
5375
|
+
let l = await yo(c.operations, i);
|
|
5323
5376
|
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) s.log.error(e);
|
|
5324
5377
|
}
|
|
5325
5378
|
//#endregion
|
|
5326
5379
|
//#region src/cli.ts
|
|
5327
|
-
function
|
|
5380
|
+
function Cs(e) {
|
|
5328
5381
|
if (!e) return;
|
|
5329
5382
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5330
5383
|
return t.length > 0 ? t : void 0;
|
|
5331
5384
|
}
|
|
5332
|
-
function
|
|
5385
|
+
function ws(e) {
|
|
5333
5386
|
if (!e) return;
|
|
5334
5387
|
let t = {};
|
|
5335
5388
|
for (let n of e.split(",")) {
|
|
@@ -5338,10 +5391,10 @@ function Ss(e) {
|
|
|
5338
5391
|
}
|
|
5339
5392
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5340
5393
|
}
|
|
5341
|
-
function
|
|
5394
|
+
function Ts() {
|
|
5342
5395
|
let e = new o();
|
|
5343
5396
|
return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(A, "-v, --version"), e.command("create").description("Create a new Hype Stack project").option("-n, --name <name>", "Project name").option("-d, --directory <path>", "Target directory").option("-e, --editor <editor>", "Code editor (cursor, claude, windsurf, copilot)").option("-t, --theme <theme>", "Color theme (default, slate, rose, emerald, violet, amber, ocean, zinc-mono, crimson, midnight)").option("--no-install", "Skip dependency installation").option("--no-setup", "Skip Docker services and database migrations after create").option("-y, --yes", "Skip confirmation prompts (requires --name)").action(async (e) => {
|
|
5344
|
-
await
|
|
5397
|
+
await Ro({
|
|
5345
5398
|
name: e.name,
|
|
5346
5399
|
directory: e.directory,
|
|
5347
5400
|
install: e.install,
|
|
@@ -5351,38 +5404,38 @@ function Cs() {
|
|
|
5351
5404
|
setup: e.setup
|
|
5352
5405
|
});
|
|
5353
5406
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5354
|
-
await
|
|
5407
|
+
await zo({});
|
|
5355
5408
|
}), e.command("onboard").description("Set up env vars, run migrations, and get the start command").option("-y, --yes", "Skip prompts, accept defaults").option("--skip-migrations", "Skip Docker services and database migrations").option("--cwd <path>", "Working directory").action(async (e) => {
|
|
5356
|
-
await
|
|
5409
|
+
await us({
|
|
5357
5410
|
cwd: e.cwd,
|
|
5358
5411
|
yes: e.yes,
|
|
5359
5412
|
skipMigrations: e.skipMigrations
|
|
5360
5413
|
});
|
|
5361
5414
|
}), 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) => {
|
|
5362
|
-
await
|
|
5363
|
-
packs:
|
|
5415
|
+
await Vo({
|
|
5416
|
+
packs: Cs(e.packs),
|
|
5364
5417
|
force: e.force,
|
|
5365
5418
|
yes: e.yes,
|
|
5366
5419
|
licenseKey: e.key ?? e.licenseKey,
|
|
5367
5420
|
cwd: e.cwd
|
|
5368
5421
|
});
|
|
5369
5422
|
}), 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) => {
|
|
5370
|
-
await
|
|
5423
|
+
await ys({
|
|
5371
5424
|
templateId: e,
|
|
5372
|
-
variants:
|
|
5373
|
-
packs:
|
|
5425
|
+
variants: ws(t.variants),
|
|
5426
|
+
packs: Cs(t.packs),
|
|
5374
5427
|
force: t.force,
|
|
5375
5428
|
yes: t.yes,
|
|
5376
5429
|
licenseKey: t.key ?? t.licenseKey,
|
|
5377
5430
|
cwd: t.cwd
|
|
5378
5431
|
});
|
|
5379
5432
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5380
|
-
await
|
|
5433
|
+
await qo();
|
|
5381
5434
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5382
|
-
await
|
|
5435
|
+
await Jo();
|
|
5383
5436
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5384
|
-
await
|
|
5437
|
+
await qo();
|
|
5385
5438
|
}), e;
|
|
5386
5439
|
}
|
|
5387
5440
|
//#endregion
|
|
5388
|
-
export {
|
|
5441
|
+
export { Bo as a, Vo as i, Jo as n, zo as o, qo as r, Ro as s, Ts as t };
|