@hype-stack/cli 0.5.12 → 0.5.13
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-CHPFj1jR.js → cli-Cm8dj5Gp.js} +1112 -1104
- 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/access-prompts.d.ts.map +1 -1
- package/dist/core/codegen.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/ui/logger.d.ts +6 -1
- package/dist/ui/logger.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.13", te = "gh:BetterTyped/hype-stack", ne = "stack.json", re = "/schema/stack.json", j = "https://api.hype-stack.dev", M = "HYPE_STACK_API_URL", N = "https://www.hype-stack.dev", ie = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, P = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -31,109 +31,125 @@ var A = "0.5.12", te = "gh:BetterTyped/hype-stack", j = "stack.json", ne = "/sch
|
|
|
31
31
|
value: "copilot",
|
|
32
32
|
label: "GitHub Copilot"
|
|
33
33
|
}
|
|
34
|
-
],
|
|
35
|
-
function
|
|
34
|
+
], ae = P.map((e) => e.value), oe = ".cursor/rules", se = ".cursor", ce = ".agents";
|
|
35
|
+
function F() {
|
|
36
36
|
let e = process.env.HYPE_STACK_API_URL;
|
|
37
|
-
return e ? (
|
|
37
|
+
return e ? (ue(e), e.replace(/\/+$/, "")) : j;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function le() {
|
|
40
40
|
let e = process.env.HYPE_STACK_WEB_URL;
|
|
41
|
-
return e ? (
|
|
41
|
+
return e ? (ue(e), e.replace(/\/+$/, "")) : N;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function ue(e) {
|
|
44
44
|
try {
|
|
45
45
|
let t = new URL(e);
|
|
46
|
-
if (!t.protocol.startsWith("http")) throw Error(`${
|
|
46
|
+
if (!t.protocol.startsWith("http")) throw Error(`${M} must use http or https protocol, got "${t.protocol}"`);
|
|
47
47
|
} catch (t) {
|
|
48
|
-
throw t instanceof TypeError ? Error(`${
|
|
48
|
+
throw t instanceof TypeError ? Error(`${M} is not a valid URL: "${e}"`, { cause: t }) : t;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return `${
|
|
51
|
+
function de() {
|
|
52
|
+
return `${F()}${re}`;
|
|
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 fe = (e) => `\x1b[38;5;208m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;214m${e}\x1b[39m`, me = (e) => `\x1b[38;5;220m${e}\x1b[39m`, he = (e) => `\x1b[38;5;33m${e}\x1b[39m`, I = (e) => `\x1b[38;5;39m${e}\x1b[39m`, ge = (e) => `\x1b[38;5;81m${e}\x1b[39m`, _e = {
|
|
57
|
+
orange: fe,
|
|
58
|
+
orangeBright: pe,
|
|
59
|
+
amber: me,
|
|
60
|
+
deepBlue: he,
|
|
61
|
+
skyBlue: I,
|
|
62
|
+
lightBlue: ge
|
|
63
|
+
}, L = {
|
|
64
|
+
brand: (e) => fe(e),
|
|
65
|
+
brandBold: (e) => b.bold(fe(e)),
|
|
66
|
+
accent: (e) => I(e),
|
|
67
|
+
accentBold: (e) => b.bold(I(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(I(e)),
|
|
75
|
+
command: (e) => b.bold(me(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
|
-
L,
|
|
93
|
-
L,
|
|
94
|
-
fe,
|
|
95
|
-
de,
|
|
96
|
-
pe,
|
|
97
|
-
R,
|
|
78
|
+
function ve(e, t = e) {
|
|
79
|
+
return `\x1b]8;;${e}\x07${I(t)}\x1b]8;;\x07`;
|
|
80
|
+
}
|
|
81
|
+
var R = {
|
|
82
|
+
arrow: fe("›"),
|
|
83
|
+
bullet: L.muted("·"),
|
|
84
|
+
dash: L.muted("─"),
|
|
85
|
+
corner: L.muted("╰"),
|
|
86
|
+
pipe: L.muted("│"),
|
|
87
|
+
dot: L.muted("•"),
|
|
88
|
+
spark: me("✦"),
|
|
89
|
+
sparkSmall: pe("✧"),
|
|
90
|
+
bolt: me("⚡")
|
|
91
|
+
}, ye = [
|
|
98
92
|
me,
|
|
99
|
-
me
|
|
93
|
+
me,
|
|
94
|
+
pe,
|
|
95
|
+
fe,
|
|
96
|
+
he,
|
|
97
|
+
I,
|
|
98
|
+
ge,
|
|
99
|
+
ge
|
|
100
100
|
];
|
|
101
|
-
function
|
|
101
|
+
function be(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 ye[Math.min(Math.floor(r * ye.length), ye.length - 1)](e);
|
|
107
107
|
}).join("");
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function xe(e, t, n) {
|
|
110
110
|
return Math.round(e + (t - e) * n);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function Se(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;${xe(n[0], r[0], u)};${xe(n[1], r[1], u)};${xe(n[2], r[2], u)}m${e}\x1b[39m`;
|
|
118
118
|
}).join(""));
|
|
119
119
|
}
|
|
120
120
|
//#endregion
|
|
121
|
+
//#region src/ui/logger.ts
|
|
122
|
+
var Ce = (e) => e;
|
|
123
|
+
function z(e, t) {
|
|
124
|
+
s.note(e, t, { format: Ce });
|
|
125
|
+
}
|
|
126
|
+
var we = [_e.orangeBright, _e.skyBlue];
|
|
127
|
+
function Te(e) {
|
|
128
|
+
z(e.map(({ command: e, hint: t }, n) => {
|
|
129
|
+
let r = we[n % we.length];
|
|
130
|
+
return `${L.bold(r(`${n + 1}.`))} ${L.bold(r(e))}${t ? ` ${L.muted(t)}` : ""}`;
|
|
131
|
+
}).join("\n"), "Next steps");
|
|
132
|
+
}
|
|
133
|
+
function B() {
|
|
134
|
+
s.cancel(L.muted("Operation cancelled.")), process.exit(0);
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
121
137
|
//#region src/core/license.ts
|
|
122
|
-
function
|
|
123
|
-
return `${
|
|
138
|
+
function Ee(e) {
|
|
139
|
+
return `${le()}/packs/${e}`;
|
|
124
140
|
}
|
|
125
141
|
//#endregion
|
|
126
142
|
//#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 =
|
|
143
|
+
var De = Object.create, Oe = Object.defineProperty, ke = Object.getOwnPropertyDescriptor, Ae = Object.getOwnPropertyNames, je = Object.getPrototypeOf, Me = Object.prototype.hasOwnProperty, Ne = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), Pe = (e, t, n, r) => {
|
|
144
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = Ae(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !Me.call(e, s) && s !== n && Oe(e, s, {
|
|
129
145
|
get: ((e) => t[e]).bind(null, s),
|
|
130
|
-
enumerable: !(r =
|
|
146
|
+
enumerable: !(r = ke(t, s)) || r.enumerable
|
|
131
147
|
});
|
|
132
148
|
return e;
|
|
133
|
-
},
|
|
149
|
+
}, Fe = (e, t, n) => (n = e == null ? {} : De(je(e)), Pe(t || !e || !e.__esModule ? Oe(n, "default", {
|
|
134
150
|
value: e,
|
|
135
151
|
enumerable: !0
|
|
136
|
-
}) : n, e)),
|
|
152
|
+
}) : n, e)), Ie = (e) => `${e.queryKey}_${Date.now().toString(36)}_${Math.random().toString(36).substring(2)}`, Le = /* @__PURE__ */ Fe((/* @__PURE__ */ Ne(((e, t) => {
|
|
137
153
|
var n = typeof Reflect == "object" ? Reflect : null, r = n && typeof n.apply == "function" ? n.apply : function(e, t, n) {
|
|
138
154
|
return Function.prototype.apply.call(e, t, n);
|
|
139
155
|
}, i = n && typeof n.ownKeys == "function" ? n.ownKeys : Object.getOwnPropertySymbols ? function(e) {
|
|
@@ -308,7 +324,7 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
308
324
|
});
|
|
309
325
|
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
310
326
|
}
|
|
311
|
-
})))()),
|
|
327
|
+
})))()), Re = (e) => `listen_${String(e)}`, ze = class extends Le.default {
|
|
312
328
|
emitCallbacks = [];
|
|
313
329
|
constructor(e) {
|
|
314
330
|
super(e);
|
|
@@ -320,26 +336,26 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
320
336
|
onEmit = (e) => (this.emitCallbacks?.push(e), () => {
|
|
321
337
|
this.emitCallbacks = this.emitCallbacks?.filter((t) => t !== e);
|
|
322
338
|
});
|
|
323
|
-
onListener = (e, t) => (super.on(
|
|
324
|
-
super.off(
|
|
339
|
+
onListener = (e, t) => (super.on(Re(e), t), () => {
|
|
340
|
+
super.off(Re(e), t);
|
|
325
341
|
});
|
|
326
|
-
on = (e, t) => (super.on(e, t), super.emit(
|
|
327
|
-
off = (e, t) => (super.off(e, t), super.emit(
|
|
342
|
+
on = (e, t) => (super.on(e, t), super.emit(Re(e), super.listeners(e).length), this);
|
|
343
|
+
off = (e, t) => (super.off(e, t), super.emit(Re(e), super.listeners(e).length), this);
|
|
328
344
|
addListener = this.on;
|
|
329
345
|
removeListener = this.off;
|
|
330
|
-
},
|
|
331
|
-
emitter = new
|
|
332
|
-
events =
|
|
346
|
+
}, Be = class {
|
|
347
|
+
emitter = new ze();
|
|
348
|
+
events = Ge(this.emitter);
|
|
333
349
|
isBrowser;
|
|
334
350
|
isOnline;
|
|
335
351
|
isFocused;
|
|
336
352
|
constructor(e) {
|
|
337
353
|
this.options = e, this.emitter?.setMaxListeners(1e3);
|
|
338
|
-
let { initiallyFocused: t =
|
|
339
|
-
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser =
|
|
354
|
+
let { initiallyFocused: t = H.initiallyFocused, initiallyOnline: n = H.initiallyOnline } = this.options || H;
|
|
355
|
+
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser = He();
|
|
340
356
|
}
|
|
341
357
|
initialize = () => {
|
|
342
|
-
let { focusEvent: e =
|
|
358
|
+
let { focusEvent: e = H.focusEvent, onlineEvent: t = H.onlineEvent } = this.options || H;
|
|
343
359
|
e(this.setFocused), t(this.setOnline);
|
|
344
360
|
};
|
|
345
361
|
setInitialFocus = async (e) => {
|
|
@@ -354,21 +370,21 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
354
370
|
setOnline = (e) => {
|
|
355
371
|
this.isOnline = e, e ? this.events.emitOnline() : this.events.emitOffline();
|
|
356
372
|
};
|
|
357
|
-
},
|
|
373
|
+
}, Ve = () => {
|
|
358
374
|
try {
|
|
359
375
|
return !!(window && window.addEventListener);
|
|
360
376
|
} catch {
|
|
361
377
|
/* istanbul ignore next */
|
|
362
378
|
return !1;
|
|
363
379
|
}
|
|
364
|
-
},
|
|
380
|
+
}, He = () => {
|
|
365
381
|
try {
|
|
366
|
-
return !!(
|
|
382
|
+
return !!(Ve() && window.document && window.document.addEventListener);
|
|
367
383
|
} catch {
|
|
368
384
|
/* istanbul ignore next */
|
|
369
385
|
return !1;
|
|
370
386
|
}
|
|
371
|
-
},
|
|
387
|
+
}, Ue = (e, t, n) => Ve() ? (window.addEventListener(e, t, n), () => window.removeEventListener(e, t, n)) : () => null, We = (e, t, n) => He() ? (window.document.addEventListener(e, t, n), () => window.document.removeEventListener(e, t, n)) : () => null, Ge = (e) => ({
|
|
372
388
|
emitFocus: () => {
|
|
373
389
|
e.emit(V.FOCUS);
|
|
374
390
|
},
|
|
@@ -387,18 +403,18 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
387
403
|
onOffline: (t) => (e.on(V.OFFLINE, t), () => e.removeListener(V.OFFLINE, t))
|
|
388
404
|
}), V = /* @__PURE__ */ function(e) {
|
|
389
405
|
return e.FOCUS = "focus", e.BLUR = "blur", e.ONLINE = "online", e.OFFLINE = "offline", e;
|
|
390
|
-
}({}),
|
|
406
|
+
}({}), H = {
|
|
391
407
|
initiallyFocused: !0,
|
|
392
408
|
initiallyOnline: !0,
|
|
393
409
|
focusEvent: (e) => {
|
|
394
|
-
|
|
410
|
+
We("visibilitychange", () => e(!0)), Ue("focus", () => e(!0)), Ue("blur", () => e(!1));
|
|
395
411
|
},
|
|
396
412
|
onlineEvent: (e) => {
|
|
397
|
-
|
|
413
|
+
Ue("online", () => e(!0)), Ue("offline", () => e(!1));
|
|
398
414
|
}
|
|
399
|
-
},
|
|
400
|
-
emitter = new
|
|
401
|
-
events =
|
|
415
|
+
}, Ke = class {
|
|
416
|
+
emitter = new ze();
|
|
417
|
+
events = St(this.emitter);
|
|
402
418
|
constructor() {
|
|
403
419
|
this.emitter?.setMaxListeners(1e3);
|
|
404
420
|
}
|
|
@@ -435,71 +451,71 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
435
451
|
});
|
|
436
452
|
});
|
|
437
453
|
};
|
|
438
|
-
},
|
|
454
|
+
}, qe = () => "loading-event-any", Je = (e) => `${e}-loading-event`, Ye = (e) => `${e}-loading-cache-event`, Xe = (e) => `${e}-loading-event-by-id`, Ze = () => "remove-event-any", Qe = (e) => `${e}-remove-event`, $e = (e) => `${e}-remove-event-by-id`, et = () => "request-abort-any", tt = (e) => `${e}-request-abort`, nt = (e) => `${e}-request-abort-by-id`, rt = () => "response-any", it = (e) => `${e}-response`, at = (e) => `${e}-response-by-id`, ot = () => "request-start-any", st = (e) => `${e}-request-start`, ct = (e) => `${e}-request-start-by-id`, lt = () => "response-start-any", ut = (e) => `${e}-response-start`, dt = (e) => `${e}-response-start-by-id`, ft = () => "request-progress-any", pt = (e) => `${e}-request-progress`, mt = (e) => `${e}-request-progress-by-id`, ht = () => "response-progress-any", gt = (e) => `${e}-response-progress`, _t = (e) => `${e}-response-progress-by-id`, vt = () => "request-deduplicated-any", yt = (e) => `${e}-query-request-deduplicated`, bt = (e) => `${e}-cache-request-deduplicated`, xt = (e) => `${e}-request-deduplicated-by-id`, St = (e) => ({
|
|
439
455
|
emitDeduplicated: (t, n = !1) => {
|
|
440
|
-
e.emit(
|
|
456
|
+
e.emit(vt(), t, n), e.emit(xt(t.requestId), t, n), e.emit(bt(t.request.cacheKey), t, n), e.emit(yt(t.request.queryKey), t, n);
|
|
441
457
|
},
|
|
442
458
|
emitLoading: (t, n = !1) => {
|
|
443
|
-
e.emit(
|
|
459
|
+
e.emit(qe(), t, n), e.emit(Xe(t.requestId), t, n), e.emit(Ye(t.request.cacheKey), t, n), e.emit(Je(t.request.queryKey), t, n);
|
|
444
460
|
},
|
|
445
461
|
emitRequestStart: (t, n = !1) => {
|
|
446
|
-
e.emit(
|
|
462
|
+
e.emit(ot(), t, n), e.emit(ct(t.requestId), t, n), e.emit(st(t.request.queryKey), t, n);
|
|
447
463
|
},
|
|
448
464
|
emitResponseStart: (t, n = !1) => {
|
|
449
|
-
e.emit(
|
|
465
|
+
e.emit(lt(), t, n), e.emit(dt(t.requestId), t, n), e.emit(ut(t.request.queryKey), t, n);
|
|
450
466
|
},
|
|
451
467
|
emitUploadProgress: (t, n = !1) => {
|
|
452
|
-
e.emit(
|
|
468
|
+
e.emit(ft(), t, n), e.emit(mt(t.requestId), t, n), e.emit(pt(t.request.queryKey), t, n);
|
|
453
469
|
},
|
|
454
470
|
emitDownloadProgress: (t, n = !1) => {
|
|
455
|
-
e.emit(
|
|
471
|
+
e.emit(ht(), t, n), e.emit(_t(t.requestId), t, n), e.emit(gt(t.request.queryKey), t, n);
|
|
456
472
|
},
|
|
457
473
|
emitResponse: (t, n = !1) => {
|
|
458
|
-
e.emit(
|
|
474
|
+
e.emit(rt(), t, n), e.emit(at(t.requestId), t, n), e.emit(it(t.request.cacheKey), t, n);
|
|
459
475
|
},
|
|
460
476
|
emitAbort: (t, n = !1) => {
|
|
461
|
-
e.emit(
|
|
477
|
+
e.emit(et(), t, n), e.emit(nt(t.requestId), t, n), e.emit(tt(t.request.abortKey), t, n);
|
|
462
478
|
},
|
|
463
479
|
emitRemove: (t, n = !1) => {
|
|
464
|
-
e.emit(
|
|
480
|
+
e.emit(Ze(), t, n), e.emit($e(t.requestId), t, n), e.emit(Qe(t.request.queryKey), t, n);
|
|
465
481
|
},
|
|
466
|
-
onDeduplicated: (t) => (e.on(
|
|
467
|
-
onDeduplicatedByQueue: (t, n) => (e.on(
|
|
468
|
-
onDeduplicatedByCache: (t, n) => (e.on(
|
|
469
|
-
onDeduplicatedById: (t, n) => (e.on(
|
|
470
|
-
onLoading: (t) => (e.on(
|
|
471
|
-
onLoadingByQueue: (t, n) => (e.on(
|
|
472
|
-
onLoadingByCache: (t, n) => (e.on(
|
|
473
|
-
onLoadingById: (t, n) => (e.on(
|
|
474
|
-
onRequestStart: (t) => (e.on(
|
|
475
|
-
onRequestStartByQueue: (t, n) => (e.on(
|
|
476
|
-
onRequestStartById: (t, n) => (e.on(
|
|
477
|
-
onResponseStart: (t) => (e.on(
|
|
478
|
-
onResponseStartByQueue: (t, n) => (e.on(
|
|
479
|
-
onResponseStartById: (t, n) => (e.on(
|
|
480
|
-
onUploadProgress: (t) => (e.on(
|
|
481
|
-
onUploadProgressByQueue: (t, n) => (e.on(
|
|
482
|
-
onUploadProgressById: (t, n) => (e.on(
|
|
483
|
-
onDownloadProgress: (t) => (e.on(
|
|
484
|
-
onDownloadProgressByQueue: (t, n) => (e.on(
|
|
485
|
-
onDownloadProgressById: (t, n) => (e.on(
|
|
486
|
-
onResponse: (t) => (e.on(
|
|
487
|
-
onResponseByCache: (t, n) => (e.on(
|
|
488
|
-
onResponseById: (t, n) => (e.on(
|
|
489
|
-
onAbort: (t) => (e.on(
|
|
490
|
-
onAbortByKey: (t, n) => (e.on(
|
|
491
|
-
onAbortById: (t, n) => (e.on(
|
|
492
|
-
onRemove: (t) => (e.on(
|
|
493
|
-
onRemoveByQueue: (t, n) => (e.on(
|
|
494
|
-
onRemoveById: (t, n) => (e.on(
|
|
495
|
-
}),
|
|
482
|
+
onDeduplicated: (t) => (e.on(vt(), t), () => e.removeListener(vt(), t)),
|
|
483
|
+
onDeduplicatedByQueue: (t, n) => (e.on(yt(t), n), () => e.removeListener(yt(t), n)),
|
|
484
|
+
onDeduplicatedByCache: (t, n) => (e.on(bt(t), n), () => e.removeListener(bt(t), n)),
|
|
485
|
+
onDeduplicatedById: (t, n) => (e.on(xt(t), n), () => e.removeListener(xt(t), n)),
|
|
486
|
+
onLoading: (t) => (e.on(qe(), t), () => e.removeListener(qe(), t)),
|
|
487
|
+
onLoadingByQueue: (t, n) => (e.on(Je(t), n), () => e.removeListener(Je(t), n)),
|
|
488
|
+
onLoadingByCache: (t, n) => (e.on(Ye(t), n), () => e.removeListener(Ye(t), n)),
|
|
489
|
+
onLoadingById: (t, n) => (e.on(Xe(t), n), () => e.removeListener(Xe(t), n)),
|
|
490
|
+
onRequestStart: (t) => (e.on(ot(), t), () => e.removeListener(ot(), t)),
|
|
491
|
+
onRequestStartByQueue: (t, n) => (e.on(st(t), n), () => e.removeListener(st(t), n)),
|
|
492
|
+
onRequestStartById: (t, n) => (e.on(ct(t), n), () => e.removeListener(ct(t), n)),
|
|
493
|
+
onResponseStart: (t) => (e.on(lt(), t), () => e.removeListener(lt(), t)),
|
|
494
|
+
onResponseStartByQueue: (t, n) => (e.on(ut(t), n), () => e.removeListener(ut(t), n)),
|
|
495
|
+
onResponseStartById: (t, n) => (e.on(dt(t), n), () => e.removeListener(dt(t), n)),
|
|
496
|
+
onUploadProgress: (t) => (e.on(ft(), t), () => e.removeListener(ft(), t)),
|
|
497
|
+
onUploadProgressByQueue: (t, n) => (e.on(pt(t), n), () => e.removeListener(pt(t), n)),
|
|
498
|
+
onUploadProgressById: (t, n) => (e.on(mt(t), n), () => e.removeListener(mt(t), n)),
|
|
499
|
+
onDownloadProgress: (t) => (e.on(ht(), t), () => e.removeListener(ht(), t)),
|
|
500
|
+
onDownloadProgressByQueue: (t, n) => (e.on(gt(t), n), () => e.removeListener(gt(t), n)),
|
|
501
|
+
onDownloadProgressById: (t, n) => (e.on(_t(t), n), () => e.removeListener(_t(t), n)),
|
|
502
|
+
onResponse: (t) => (e.on(rt(), t), () => e.removeListener(rt(), t)),
|
|
503
|
+
onResponseByCache: (t, n) => (e.on(it(t), n), () => e.removeListener(it(t), n)),
|
|
504
|
+
onResponseById: (t, n) => (e.on(at(t), n), () => e.removeListener(at(t), n)),
|
|
505
|
+
onAbort: (t) => (e.on(et(), t), () => e.removeListener(et(), t)),
|
|
506
|
+
onAbortByKey: (t, n) => (e.on(tt(t), n), () => e.removeListener(tt(t), n)),
|
|
507
|
+
onAbortById: (t, n) => (e.on(nt(t), n), () => e.removeListener(nt(t), n)),
|
|
508
|
+
onRemove: (t) => (e.on(Ze(), t), () => e.removeListener(Ze(), t)),
|
|
509
|
+
onRemoveByQueue: (t, n) => (e.on(Qe(t), n), () => e.removeListener(Qe(t), n)),
|
|
510
|
+
onRemoveById: (t, n) => (e.on($e(t), n), () => e.removeListener($e(t), n))
|
|
511
|
+
}), Ct = class {
|
|
496
512
|
logger;
|
|
497
513
|
level;
|
|
498
514
|
modules;
|
|
499
|
-
emitter = new
|
|
515
|
+
emitter = new Le.default();
|
|
500
516
|
client;
|
|
501
517
|
constructor(e) {
|
|
502
|
-
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger ||
|
|
518
|
+
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger || Et, this.level = this.options?.level || "warning", this.modules = this.options?.modules;
|
|
503
519
|
}
|
|
504
520
|
setSeverity = (e) => {
|
|
505
521
|
this.level = e;
|
|
@@ -530,58 +546,58 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
530
546
|
})
|
|
531
547
|
});
|
|
532
548
|
log = (e) => {
|
|
533
|
-
this.client.debug && (
|
|
549
|
+
this.client.debug && (Dt.indexOf(this.level) <= Dt.indexOf(e.level) || this.modules && !this.modules.includes(e.module) || this.logger(e));
|
|
534
550
|
};
|
|
535
|
-
},
|
|
536
|
-
let t =
|
|
551
|
+
}, wt = () => `${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`, Tt = (e) => e.type === "request" || e.type === "response" ? `${e.extra.request.endpoint}` : `[${e.module}]`, Et = (e) => {
|
|
552
|
+
let t = kt[e.level], n = At[e.level], r = `%c[${wt()}]%c${e.title}%c${Tt(e)}`, i = `${t}${n}font-weight:600;border-radius: 4px 0 0 4px;`, a = `${t}${n}font-weight:600;`, o = `${t}font-weight:normal;border-radius: 0 4px 4px 0;`;
|
|
537
553
|
e.extra && Object.keys(e.extra)?.length ? (console.groupCollapsed(r, i, a, o), console.log(e.extra), console.groupEnd()) : console.log(r, t);
|
|
538
|
-
},
|
|
554
|
+
}, Dt = [
|
|
539
555
|
"error",
|
|
540
556
|
"warning",
|
|
541
557
|
"info",
|
|
542
558
|
"debug"
|
|
543
|
-
],
|
|
544
|
-
error: `${
|
|
545
|
-
warning: `${
|
|
546
|
-
info: `${
|
|
547
|
-
debug: `${
|
|
548
|
-
},
|
|
559
|
+
], Ot = "padding:2px 5px;", kt = {
|
|
560
|
+
error: `${Ot};background:#db252520;`,
|
|
561
|
+
warning: `${Ot};background:#e1941e20;`,
|
|
562
|
+
info: `${Ot};background:#1e74e120;`,
|
|
563
|
+
debug: `${Ot};background:#00000020;`
|
|
564
|
+
}, At = {
|
|
549
565
|
error: "color:#ff3737;",
|
|
550
566
|
warning: "color:#ffc107;",
|
|
551
567
|
info: "color:#34a8ff;",
|
|
552
568
|
debug: "color:#cccccc;"
|
|
553
|
-
},
|
|
569
|
+
}, jt = class extends Error {
|
|
554
570
|
constructor() {
|
|
555
571
|
super("Request timeout"), this.name = "TimeoutError";
|
|
556
572
|
}
|
|
557
|
-
},
|
|
573
|
+
}, Mt = class extends Error {
|
|
558
574
|
constructor() {
|
|
559
575
|
super("Request aborted"), this.name = "AbortError";
|
|
560
576
|
}
|
|
561
|
-
},
|
|
577
|
+
}, Nt = class extends Error {
|
|
562
578
|
constructor() {
|
|
563
579
|
super("Request deleted"), this.name = "DeletedError";
|
|
564
580
|
}
|
|
565
|
-
},
|
|
581
|
+
}, Pt = class extends Error {
|
|
566
582
|
description;
|
|
567
583
|
constructor(e) {
|
|
568
584
|
super("Request processing error"), this.description = e, this.name = "RequestProcessingError";
|
|
569
585
|
}
|
|
570
|
-
},
|
|
586
|
+
}, Ft = class extends Error {
|
|
571
587
|
description;
|
|
572
588
|
constructor(e) {
|
|
573
589
|
super("Unexpected error"), this.description = e, this.name = "UnexpectedError";
|
|
574
590
|
}
|
|
575
|
-
},
|
|
591
|
+
}, U = (e) => e === "timeout" ? new jt() : e === "abort" ? new Mt() : e === "deleted" ? new Nt() : e === "processing" ? new Pt() : new Ft(), It = (e) => {
|
|
576
592
|
try {
|
|
577
593
|
return JSON.stringify(e);
|
|
578
594
|
} catch {
|
|
579
595
|
return "";
|
|
580
596
|
}
|
|
581
|
-
},
|
|
582
|
-
let t =
|
|
597
|
+
}, Lt = (e) => {
|
|
598
|
+
let t = Ve() && e.payload instanceof FormData, n = typeof e.payload == "object" && e.payload !== null, r = {};
|
|
583
599
|
return !t && n && (r["Content-Type"] = "application/json"), Object.assign(r, e.headers), r;
|
|
584
|
-
},
|
|
600
|
+
}, Rt = (e) => Ve() && e instanceof FormData ? e : It(e), zt = [
|
|
585
601
|
"onBeforeSent",
|
|
586
602
|
"onRequestStart",
|
|
587
603
|
"onResponseStart",
|
|
@@ -590,7 +606,7 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
590
606
|
"onResponse",
|
|
591
607
|
"onRemove"
|
|
592
608
|
];
|
|
593
|
-
function
|
|
609
|
+
function Bt(e) {
|
|
594
610
|
let t = {
|
|
595
611
|
onBeforeSent: [],
|
|
596
612
|
onRequestStart: [],
|
|
@@ -600,7 +616,7 @@ function It(e) {
|
|
|
600
616
|
onResponse: [],
|
|
601
617
|
onRemove: []
|
|
602
618
|
};
|
|
603
|
-
e &&
|
|
619
|
+
e && zt.forEach((n) => {
|
|
604
620
|
t[n] = [...e[n]];
|
|
605
621
|
});
|
|
606
622
|
let n = (e) => (n) => (t[e].push(n), () => {
|
|
@@ -622,15 +638,15 @@ function It(e) {
|
|
|
622
638
|
},
|
|
623
639
|
__snapshot() {
|
|
624
640
|
let e = {};
|
|
625
|
-
return
|
|
641
|
+
return zt.forEach((n) => {
|
|
626
642
|
e[n] = [...t[n]];
|
|
627
643
|
}), e;
|
|
628
644
|
}
|
|
629
645
|
};
|
|
630
646
|
}
|
|
631
|
-
var
|
|
647
|
+
var Vt = /* @__PURE__ */ function(e) {
|
|
632
648
|
return e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.PATCH = "PATCH", e.DELETE = "DELETE", e;
|
|
633
|
-
}({}),
|
|
649
|
+
}({}), W = (e, t) => t ? `${t}__${e}` : e, Ht = (e) => {
|
|
634
650
|
try {
|
|
635
651
|
if (typeof e == "string") return e;
|
|
636
652
|
if (e == null) return "";
|
|
@@ -640,13 +656,13 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
640
656
|
} catch {
|
|
641
657
|
return "";
|
|
642
658
|
}
|
|
643
|
-
},
|
|
659
|
+
}, Ut = ({ loaded: e, total: t }) => !e || !t ? 0 : Number((e * 100 / t).toFixed(0)), Wt = (e, t, { total: n, loaded: r }) => {
|
|
644
660
|
let i = r / (t - +e || 1), a = Math.max(n, r), o = a - r, s = i ? o / i : null;
|
|
645
661
|
return {
|
|
646
662
|
timeLeft: a === r ? 0 : s,
|
|
647
663
|
sizeLeft: o
|
|
648
664
|
};
|
|
649
|
-
},
|
|
665
|
+
}, Gt = (e, t, n) => {
|
|
650
666
|
let { total: r, loaded: i } = n;
|
|
651
667
|
if (Number.isNaN(r) || Number.isNaN(i)) return {
|
|
652
668
|
progress: 0,
|
|
@@ -656,23 +672,23 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
656
672
|
loaded: 0,
|
|
657
673
|
startTimestamp: +e
|
|
658
674
|
};
|
|
659
|
-
let { timeLeft: a, sizeLeft: o } =
|
|
675
|
+
let { timeLeft: a, sizeLeft: o } = Wt(e, t, n);
|
|
660
676
|
return {
|
|
661
|
-
progress:
|
|
677
|
+
progress: Ut(n),
|
|
662
678
|
timeLeft: a,
|
|
663
679
|
sizeLeft: o,
|
|
664
680
|
total: r,
|
|
665
681
|
loaded: i,
|
|
666
682
|
startTimestamp: +e
|
|
667
683
|
};
|
|
668
|
-
},
|
|
669
|
-
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method ===
|
|
684
|
+
}, Kt = (e) => `${e.method}_${e.requestOptions.endpoint}_${e.cancelable}`, qt = (e, t) => `${Ht(e.method)}_${t ? e.requestOptions.endpoint : Ht(e.endpoint)}_${t ? "" : Ht(e.queryParams)}`, Jt = (e, t = "auto") => {
|
|
685
|
+
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method === Vt.GET, a = t === "auto" && i || t === "fetch";
|
|
670
686
|
return [a ? n : r, a];
|
|
671
|
-
},
|
|
687
|
+
}, Yt = async (e, t) => {
|
|
672
688
|
let n = e.unstable_responseMapper?.(t);
|
|
673
689
|
return n instanceof Promise ? await n : n || t;
|
|
674
|
-
},
|
|
675
|
-
let { client: n } = e, { requestManager: r } = n, [i] =
|
|
690
|
+
}, Xt = async (e, t) => {
|
|
691
|
+
let { client: n } = e, { requestManager: r } = n, [i] = Jt(e, t?.dispatcherType), a;
|
|
676
692
|
if (e.optimistic) try {
|
|
677
693
|
a = await e.optimistic({
|
|
678
694
|
request: e,
|
|
@@ -748,7 +764,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
748
764
|
data: null,
|
|
749
765
|
status: null,
|
|
750
766
|
success: !1,
|
|
751
|
-
error:
|
|
767
|
+
error: U("deleted"),
|
|
752
768
|
extra: e.client.adapter.defaultExtra,
|
|
753
769
|
requestTimestamp: +/* @__PURE__ */ new Date(),
|
|
754
770
|
responseTimestamp: +/* @__PURE__ */ new Date()
|
|
@@ -759,9 +775,9 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
759
775
|
u(), d(), f(), p(), m(), h();
|
|
760
776
|
}
|
|
761
777
|
});
|
|
762
|
-
},
|
|
778
|
+
}, Zt = /* @__PURE__ */ function(e) {
|
|
763
779
|
return e[e.SEC = 1e3] = "SEC", e[e.MIN = 6e4] = "MIN", e[e.HOUR = 36e5] = "HOUR", e[e.DAY = 864e5] = "DAY", e[e.WEEK = 6048e5] = "WEEK", e[e.MONTH_30 = 2592e6] = "MONTH_30", e[e.MONTH_31 = 26784e5] = "MONTH_31", e[e.YEAR = 31536e6] = "YEAR", e[e.YEAR_LEAP = 316224e5] = "YEAR_LEAP", e;
|
|
764
|
-
}({}),
|
|
780
|
+
}({}), Qt = class e {
|
|
765
781
|
endpoint;
|
|
766
782
|
headers;
|
|
767
783
|
auth;
|
|
@@ -785,7 +801,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
785
801
|
deduplicate;
|
|
786
802
|
deduplicateTime;
|
|
787
803
|
scope;
|
|
788
|
-
$hooks =
|
|
804
|
+
$hooks = Bt();
|
|
789
805
|
isMockerEnabled = !1;
|
|
790
806
|
unstable_mock;
|
|
791
807
|
unstable_payloadMapper;
|
|
@@ -802,7 +818,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
802
818
|
updatedQueryKey;
|
|
803
819
|
constructor(e, t, n) {
|
|
804
820
|
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 =
|
|
821
|
+
let { endpoint: r, headers: i, auth: a = !0, method: o = e.adapter.defaultMethod, options: s, cancelable: c = !1, retry: l = 0, retryTime: u = 500, cacheTime: d = Zt.MIN * 5, cache: f = !0, staleTime: p = Zt.MIN * 5, queued: m = !1, offline: h = !0, abortKey: g, cacheKey: _, queryKey: v, deduplicate: y = !1, deduplicateTime: b = null } = {
|
|
806
822
|
...this.client.adapter.unstable_getRequestDefaults?.(t),
|
|
807
823
|
...t
|
|
808
824
|
};
|
|
@@ -912,11 +928,11 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
912
928
|
payload: t?.payload || this.payload,
|
|
913
929
|
params: t?.params || this.params
|
|
914
930
|
}, 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 =
|
|
931
|
+
return r.unstable_payloadMapper = this.unstable_payloadMapper, r.unstable_responseMapper = this.unstable_responseMapper, r.unstable_requestMapper = this.unstable_requestMapper, r.retryOnError = this.retryOnError, r.unstable_mock = this.unstable_mock, r.isMockerEnabled = this.isMockerEnabled, r.optimistic = this.optimistic, r.$hooks = Bt(this.$hooks.__snapshot()), r;
|
|
916
932
|
}
|
|
917
933
|
abort = () => {
|
|
918
934
|
let { requestManager: e } = this.client;
|
|
919
|
-
return e.abortByKey(
|
|
935
|
+
return e.abortByKey(W(this.abortKey, this.scope)), this.clone();
|
|
920
936
|
};
|
|
921
937
|
dehydrate = (e) => {
|
|
922
938
|
let { response: t, override: n = !0 } = e || {};
|
|
@@ -931,7 +947,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
931
947
|
cache: !0,
|
|
932
948
|
response: t
|
|
933
949
|
};
|
|
934
|
-
let r = this.client.cache.get(
|
|
950
|
+
let r = this.client.cache.get(W(this.cacheKey, this.scope));
|
|
935
951
|
if (r) return {
|
|
936
952
|
override: n,
|
|
937
953
|
cacheTime: this.cacheTime,
|
|
@@ -953,7 +969,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
953
969
|
};
|
|
954
970
|
};
|
|
955
971
|
read() {
|
|
956
|
-
let e = this.client.cache.get(
|
|
972
|
+
let e = this.client.cache.get(W(this.cacheKey, this.scope));
|
|
957
973
|
if (e) return {
|
|
958
974
|
data: e.data,
|
|
959
975
|
error: e.error,
|
|
@@ -965,7 +981,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
965
981
|
};
|
|
966
982
|
}
|
|
967
983
|
exec = async (e) => {
|
|
968
|
-
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a =
|
|
984
|
+
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a = W(this.abortKey, this.scope);
|
|
969
985
|
n.addAbortController(a, i);
|
|
970
986
|
let o = await t.fetch(r, i);
|
|
971
987
|
return n.removeAbortController(a, i), r.unstable_responseMapper ? r.unstable_responseMapper(o) : o;
|
|
@@ -975,17 +991,17 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
975
991
|
...e,
|
|
976
992
|
cachePolicy: void 0
|
|
977
993
|
};
|
|
978
|
-
if (n === "network-only") return
|
|
994
|
+
if (n === "network-only") return Xt(i, a);
|
|
979
995
|
let o = i.read();
|
|
980
|
-
if (n === "cache-first") return o ?
|
|
996
|
+
if (n === "cache-first") return o ? Yt(i, o) : Xt(i, a);
|
|
981
997
|
if (o) {
|
|
982
|
-
let e = await
|
|
983
|
-
return
|
|
998
|
+
let e = await Yt(i, o);
|
|
999
|
+
return Xt(i, a), e;
|
|
984
1000
|
}
|
|
985
|
-
return
|
|
1001
|
+
return Xt(i, a);
|
|
986
1002
|
};
|
|
987
1003
|
static fromJSON = (t, n) => new e(t, n.requestOptions, n);
|
|
988
|
-
},
|
|
1004
|
+
}, $t = async ({ request: e, requestId: t, resolve: n, onStartTime: r, internalErrorMapping: i }) => {
|
|
989
1005
|
let { requestManager: a, loggerManager: o } = e.client, { unstable_payloadMapper: s } = e.client.adapter, c = o.initialize(e.client, "Adapter"), l = null, u = null, d = e, f = 1, p = 1, m = 0, h = 0;
|
|
990
1006
|
c.debug({
|
|
991
1007
|
title: "Running middleware callbacks",
|
|
@@ -995,7 +1011,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
995
1011
|
requestId: t
|
|
996
1012
|
}
|
|
997
1013
|
}), d = await d.client.unstable_modifyRequest(d), d.auth && (d = await d.client.unstable_modifyAuth(d)), d.unstable_requestMapper && (d = await d.unstable_requestMapper(d, t));
|
|
998
|
-
let { client: g, abortKey: _ } = d, v =
|
|
1014
|
+
let { client: g, abortKey: _ } = d, v = W(_, d.scope), y = d.payload;
|
|
999
1015
|
d.unstable_payloadMapper ? y = await d.unstable_payloadMapper(d.payload) : s && (y = await s(y));
|
|
1000
1016
|
let b = d.options, x = +/* @__PURE__ */ new Date();
|
|
1001
1017
|
r(x);
|
|
@@ -1004,14 +1020,14 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1004
1020
|
let n = Number(t.total || 0), r = Number(t.loaded || 0);
|
|
1005
1021
|
return Math.max(n, r, e);
|
|
1006
1022
|
}, T = (e, n, r) => {
|
|
1007
|
-
let i =
|
|
1023
|
+
let i = Gt(new Date(e), new Date(n), r);
|
|
1008
1024
|
m !== 100 && (m = i.total, a.events.emitUploadProgress({
|
|
1009
1025
|
...i,
|
|
1010
1026
|
requestId: t,
|
|
1011
1027
|
request: d
|
|
1012
1028
|
}));
|
|
1013
1029
|
}, E = (e, n, r) => {
|
|
1014
|
-
let i =
|
|
1030
|
+
let i = Gt(new Date(e), new Date(n), r);
|
|
1015
1031
|
h !== 100 && (h = i.total, a.events.emitDownloadProgress({
|
|
1016
1032
|
...i,
|
|
1017
1033
|
requestId: t,
|
|
@@ -1074,14 +1090,14 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1074
1090
|
total: e.total || p,
|
|
1075
1091
|
loaded: e.loaded || 0
|
|
1076
1092
|
}), t;
|
|
1077
|
-
},
|
|
1093
|
+
}, ne = () => {
|
|
1078
1094
|
u ||= +/* @__PURE__ */ new Date();
|
|
1079
1095
|
let e = +/* @__PURE__ */ new Date();
|
|
1080
1096
|
return E(u, e, {
|
|
1081
1097
|
total: p,
|
|
1082
1098
|
loaded: p
|
|
1083
1099
|
}), e;
|
|
1084
|
-
},
|
|
1100
|
+
}, re = async ({ data: e, error: r, status: i, extra: a }) => {
|
|
1085
1101
|
let o = {
|
|
1086
1102
|
data: e,
|
|
1087
1103
|
error: r ?? null,
|
|
@@ -1106,50 +1122,50 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1106
1122
|
response: o
|
|
1107
1123
|
}
|
|
1108
1124
|
}), o;
|
|
1109
|
-
},
|
|
1125
|
+
}, j = en({
|
|
1110
1126
|
request: d,
|
|
1111
1127
|
requestId: t,
|
|
1112
1128
|
startTime: x,
|
|
1113
1129
|
logger: c,
|
|
1114
1130
|
resolve: n
|
|
1115
|
-
}),
|
|
1131
|
+
}), M = ({ status: e, extra: n }) => (c.error({
|
|
1116
1132
|
title: "Abort error",
|
|
1117
1133
|
type: "request",
|
|
1118
1134
|
extra: {
|
|
1119
1135
|
request: d,
|
|
1120
1136
|
requestId: t
|
|
1121
1137
|
}
|
|
1122
|
-
}),
|
|
1123
|
-
error: i(
|
|
1138
|
+
}), j({
|
|
1139
|
+
error: i(U("abort")),
|
|
1124
1140
|
status: e,
|
|
1125
1141
|
extra: n
|
|
1126
|
-
})),
|
|
1142
|
+
})), N = ({ status: e, extra: n }) => (c.error({
|
|
1127
1143
|
title: "Timeout error",
|
|
1128
1144
|
type: "request",
|
|
1129
1145
|
extra: {
|
|
1130
1146
|
request: d,
|
|
1131
1147
|
requestId: t
|
|
1132
1148
|
}
|
|
1133
|
-
}),
|
|
1134
|
-
error:
|
|
1149
|
+
}), j({
|
|
1150
|
+
error: U("timeout"),
|
|
1135
1151
|
status: e,
|
|
1136
1152
|
extra: n
|
|
1137
|
-
})),
|
|
1153
|
+
})), ie = ({ status: e, extra: n }) => (c.error({
|
|
1138
1154
|
title: "Unexpected error",
|
|
1139
1155
|
type: "request",
|
|
1140
1156
|
extra: {
|
|
1141
1157
|
request: d,
|
|
1142
1158
|
requestId: t
|
|
1143
1159
|
}
|
|
1144
|
-
}),
|
|
1145
|
-
error:
|
|
1160
|
+
}), j({
|
|
1161
|
+
error: U(),
|
|
1146
1162
|
status: e,
|
|
1147
1163
|
extra: n
|
|
1148
|
-
})),
|
|
1149
|
-
let i =
|
|
1150
|
-
if (!i) throw new
|
|
1164
|
+
})), P = () => a.getAbortController(v, t), ae = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1165
|
+
let i = P();
|
|
1166
|
+
if (!i) throw new Pt("Controller is not found");
|
|
1151
1167
|
let o = () => {
|
|
1152
|
-
|
|
1168
|
+
M({
|
|
1153
1169
|
status: e,
|
|
1154
1170
|
extra: n
|
|
1155
1171
|
}), r(), a.events.emitAbort({
|
|
@@ -1169,36 +1185,36 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1169
1185
|
adapterOptions: b
|
|
1170
1186
|
}
|
|
1171
1187
|
});
|
|
1172
|
-
let
|
|
1188
|
+
let oe = e.client.adapter.unstable_queryParamsMapper(d.queryParams), se = e.client.adapter.unstable_endpointMapper(d.endpoint), ce = e.client.adapter.unstable_headerMapper(d), { url: F } = e.client;
|
|
1173
1189
|
return {
|
|
1174
1190
|
request: d,
|
|
1175
1191
|
requestId: t,
|
|
1176
|
-
url:
|
|
1177
|
-
endpoint:
|
|
1178
|
-
queryParams:
|
|
1192
|
+
url: F,
|
|
1193
|
+
endpoint: se,
|
|
1194
|
+
queryParams: oe,
|
|
1179
1195
|
payload: y,
|
|
1180
|
-
headers:
|
|
1196
|
+
headers: ce,
|
|
1181
1197
|
adapter: e.client.adapter,
|
|
1182
1198
|
adapterOptions: b,
|
|
1183
|
-
getAbortController:
|
|
1199
|
+
getAbortController: P,
|
|
1184
1200
|
getRequestStartTimestamp: S,
|
|
1185
1201
|
getResponseStartTimestamp: C,
|
|
1186
|
-
createAbortListener:
|
|
1202
|
+
createAbortListener: ae,
|
|
1187
1203
|
onBeforeRequest: D,
|
|
1188
1204
|
onRequestStart: O,
|
|
1189
1205
|
onRequestProgress: k,
|
|
1190
1206
|
onRequestEnd: ee,
|
|
1191
1207
|
onResponseStart: A,
|
|
1192
1208
|
onResponseProgress: te,
|
|
1193
|
-
onResponseEnd:
|
|
1194
|
-
onSuccess:
|
|
1195
|
-
onAbortError:
|
|
1196
|
-
onTimeoutError:
|
|
1197
|
-
onUnexpectedError:
|
|
1198
|
-
onError:
|
|
1209
|
+
onResponseEnd: ne,
|
|
1210
|
+
onSuccess: re,
|
|
1211
|
+
onAbortError: M,
|
|
1212
|
+
onTimeoutError: N,
|
|
1213
|
+
onUnexpectedError: ie,
|
|
1214
|
+
onError: j
|
|
1199
1215
|
};
|
|
1200
1216
|
};
|
|
1201
|
-
function
|
|
1217
|
+
function en({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
1202
1218
|
let { client: a } = e;
|
|
1203
1219
|
return async ({ error: o, status: s, extra: c }) => {
|
|
1204
1220
|
let l = {
|
|
@@ -1227,8 +1243,8 @@ function Xt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
|
1227
1243
|
}), l;
|
|
1228
1244
|
};
|
|
1229
1245
|
}
|
|
1230
|
-
var
|
|
1231
|
-
if (!e.unstable_mock) throw new
|
|
1246
|
+
var tn = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTimeoutError: i, onRequestEnd: a, createAbortListener: o, onResponseProgress: s, onRequestProgress: c, onResponseStart: l, onBeforeRequest: u, onRequestStart: d, onSuccess: f, onAbortError: p, adapter: m }) => {
|
|
1247
|
+
if (!e.unstable_mock) throw new Pt("Mock should be defined when calling mocker");
|
|
1232
1248
|
let h = !1, { requestTime: g = 20, responseTime: _ = 20, totalUploaded: v = 1e3, totalDownloaded: y = 1e3, timeout: b } = e.unstable_mock.config, { data: x, error: S, status: C, success: w = !0, extra: T = e.client.adapter.defaultExtra } = await e.unstable_mock.fn({
|
|
1233
1249
|
request: e,
|
|
1234
1250
|
requestId: t
|
|
@@ -1272,7 +1288,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1272
1288
|
status: C,
|
|
1273
1289
|
extra: T
|
|
1274
1290
|
}), h || r();
|
|
1275
|
-
},
|
|
1291
|
+
}, nn = (e) => e, rn = class {
|
|
1276
1292
|
unstable_fetcher;
|
|
1277
1293
|
name;
|
|
1278
1294
|
defaultMethod;
|
|
@@ -1294,10 +1310,10 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1294
1310
|
initialize = (e) => (this.logger = e.loggerManager.initialize(e, "Adapter"), this.initialized = !0, this.client = e, this.unstable_onInitializeCallback?.({ client: e }), this);
|
|
1295
1311
|
onInitialize = (e) => (this.unstable_onInitializeCallback = e, this);
|
|
1296
1312
|
unstable_internalErrorMapping = (e) => e;
|
|
1297
|
-
unstable_headerMapper =
|
|
1298
|
-
unstable_payloadMapper =
|
|
1299
|
-
unstable_endpointMapper =
|
|
1300
|
-
unstable_queryParamsMapper =
|
|
1313
|
+
unstable_headerMapper = Lt;
|
|
1314
|
+
unstable_payloadMapper = Rt;
|
|
1315
|
+
unstable_endpointMapper = nn;
|
|
1316
|
+
unstable_queryParamsMapper = nn;
|
|
1301
1317
|
unstable_getAdapterDefaults;
|
|
1302
1318
|
unstable_getRequestDefaults;
|
|
1303
1319
|
unstable_devtoolsEndpointGetter = (e) => e;
|
|
@@ -1321,14 +1337,14 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1321
1337
|
async fetch(e, t) {
|
|
1322
1338
|
let n, r = async (r) => {
|
|
1323
1339
|
try {
|
|
1324
|
-
if (!this.initialized) throw new
|
|
1325
|
-
if (!this.unstable_fetcher) throw new
|
|
1340
|
+
if (!this.initialized) throw new Pt(`Adapter ${this.options.name} is not initialized`);
|
|
1341
|
+
if (!this.unstable_fetcher) throw new Pt(`Fetcher for ${this.options.name} adapter is not set`);
|
|
1326
1342
|
this.client.triggerPlugins("onAdapterFetch", {
|
|
1327
1343
|
adapter: this,
|
|
1328
1344
|
request: e,
|
|
1329
1345
|
requestId: t
|
|
1330
1346
|
});
|
|
1331
|
-
let i = await
|
|
1347
|
+
let i = await $t({
|
|
1332
1348
|
request: e,
|
|
1333
1349
|
requestId: t,
|
|
1334
1350
|
resolve: r,
|
|
@@ -1337,9 +1353,9 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1337
1353
|
n = e;
|
|
1338
1354
|
}
|
|
1339
1355
|
});
|
|
1340
|
-
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await
|
|
1356
|
+
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await tn(i) : this.unstable_fetcher(i);
|
|
1341
1357
|
} catch (i) {
|
|
1342
|
-
return
|
|
1358
|
+
return en({
|
|
1343
1359
|
request: e,
|
|
1344
1360
|
requestId: t,
|
|
1345
1361
|
startTime: n || Date.now(),
|
|
@@ -1356,66 +1372,66 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1356
1372
|
r(e);
|
|
1357
1373
|
});
|
|
1358
1374
|
}
|
|
1359
|
-
},
|
|
1375
|
+
}, an = (e) => {
|
|
1360
1376
|
try {
|
|
1361
1377
|
return JSON.parse(e);
|
|
1362
1378
|
} catch {
|
|
1363
1379
|
return e;
|
|
1364
1380
|
}
|
|
1365
|
-
},
|
|
1381
|
+
}, on = (e) => e ? an(e) : U(), sn = (e) => (t) => {
|
|
1366
1382
|
let { skipNull: n, skipEmptyString: r } = e;
|
|
1367
1383
|
return !(r && t === void 0 || r && t === "" || n && t === null);
|
|
1368
|
-
},
|
|
1369
|
-
let r = !
|
|
1370
|
-
return !e || r ? "" : `${
|
|
1371
|
-
},
|
|
1384
|
+
}, G = (e, { encode: t, strict: n }) => t && n ? encodeURIComponent(e).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`) : t ? encodeURIComponent(e) : e, cn = (e, t, n) => {
|
|
1385
|
+
let r = !sn(n)(t);
|
|
1386
|
+
return !e || r ? "" : `${G(e, n)}=${G(t instanceof Date ? n.dateParser?.(t) || t.toISOString() : typeof t == "object" && !Array.isArray(t) ? n.objectParser?.(t) || JSON.stringify(t) : String(t), n)}`;
|
|
1387
|
+
}, ln = (e, t, n) => {
|
|
1372
1388
|
let { arrayFormat: r, arraySeparator: i } = n;
|
|
1373
|
-
return t.filter(
|
|
1389
|
+
return t.filter(sn(n)).reduce((t, a, o) => {
|
|
1374
1390
|
switch (r) {
|
|
1375
1391
|
case "index": {
|
|
1376
|
-
let r = `${
|
|
1377
|
-
t.push(`${r}${
|
|
1392
|
+
let r = `${G(e, n)}[${G(String(o), n)}]=`;
|
|
1393
|
+
t.push(`${r}${G(String(a), n)}`);
|
|
1378
1394
|
break;
|
|
1379
1395
|
}
|
|
1380
1396
|
case "bracket": {
|
|
1381
|
-
let r = `${
|
|
1382
|
-
t.push(`${r}${
|
|
1397
|
+
let r = `${G(e, n)}[]=`;
|
|
1398
|
+
t.push(`${r}${G(String(a), n)}`);
|
|
1383
1399
|
break;
|
|
1384
1400
|
}
|
|
1385
1401
|
case "comma": {
|
|
1386
|
-
let r = !t.length && `${
|
|
1387
|
-
return [[...t, `${r}${
|
|
1402
|
+
let r = !t.length && `${G(e, n)}=` || "";
|
|
1403
|
+
return [[...t, `${r}${G(String(a), n)}`].join(",")];
|
|
1388
1404
|
}
|
|
1389
1405
|
case "separator": {
|
|
1390
|
-
let r = !t.length && `${
|
|
1391
|
-
return [[...t, `${r}${
|
|
1406
|
+
let r = !t.length && `${G(e, n)}=` || "";
|
|
1407
|
+
return [[...t, `${r}${G(String(a), n)}`].join(i || "|")];
|
|
1392
1408
|
}
|
|
1393
1409
|
case "bracket-separator": {
|
|
1394
|
-
let r = !t.length && `${
|
|
1395
|
-
return [[...t, `${r}${
|
|
1410
|
+
let r = !t.length && `${G(e, n)}[]=` || "";
|
|
1411
|
+
return [[...t, `${r}${G(String(a), n)}`].join(i || "|")];
|
|
1396
1412
|
}
|
|
1397
1413
|
default: {
|
|
1398
|
-
let r = `${
|
|
1399
|
-
t.push(`${r}${
|
|
1414
|
+
let r = `${G(e, n)}=`;
|
|
1415
|
+
t.push(`${r}${G(String(a), n)}`);
|
|
1400
1416
|
}
|
|
1401
1417
|
}
|
|
1402
1418
|
return t;
|
|
1403
1419
|
}, []).join("&");
|
|
1404
|
-
},
|
|
1420
|
+
}, un = (e, t = zn) => {
|
|
1405
1421
|
if (!e || !Object.keys(e).length) return "";
|
|
1406
1422
|
if (typeof e == "string") return e[0] === "?" ? e : `?${e}`;
|
|
1407
|
-
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ?
|
|
1423
|
+
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ? ln(e, n, t) : cn(e, n, t)).filter(Boolean).join("&");
|
|
1408
1424
|
return n ? `?${n}` : "";
|
|
1409
|
-
},
|
|
1425
|
+
}, dn = Zt.SEC * 5, fn = { headers: {} }, pn = () => new rn({
|
|
1410
1426
|
name: "http",
|
|
1411
|
-
defaultMethod:
|
|
1412
|
-
defaultExtra:
|
|
1427
|
+
defaultMethod: Vt.GET,
|
|
1428
|
+
defaultExtra: fn,
|
|
1413
1429
|
systemErrorStatus: 0,
|
|
1414
|
-
systemErrorExtra:
|
|
1415
|
-
}).setQueryParamsMapper(
|
|
1416
|
-
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ?
|
|
1430
|
+
systemErrorExtra: fn
|
|
1431
|
+
}).setQueryParamsMapper(un).setFetcher(async ({ request: e, adapterOptions: t, headers: n, payload: r, onError: i, onResponseEnd: a, onTimeoutError: o, onRequestEnd: s, createAbortListener: c, getAbortController: l, onResponseProgress: u, onResponseStart: d, onBeforeRequest: f, onRequestStart: p, onRequestProgress: m, onSuccess: h }) => {
|
|
1432
|
+
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ? un(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = dn, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
|
|
1417
1433
|
status: 0,
|
|
1418
|
-
extra:
|
|
1434
|
+
extra: fn
|
|
1419
1435
|
});
|
|
1420
1436
|
C > 0 && S && (D = setTimeout(() => {
|
|
1421
1437
|
E = !0, O(), S.abort();
|
|
@@ -1447,7 +1463,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1447
1463
|
status: l,
|
|
1448
1464
|
extra: c
|
|
1449
1465
|
}) : i({
|
|
1450
|
-
error:
|
|
1466
|
+
error: on(await t.text()),
|
|
1451
1467
|
status: l,
|
|
1452
1468
|
extra: c
|
|
1453
1469
|
});
|
|
@@ -1468,11 +1484,11 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1468
1484
|
e = new TextDecoder().decode(o);
|
|
1469
1485
|
} else e = await t.text();
|
|
1470
1486
|
a(), O(), t.ok ? h({
|
|
1471
|
-
data:
|
|
1487
|
+
data: an(e),
|
|
1472
1488
|
status: l,
|
|
1473
1489
|
extra: c
|
|
1474
1490
|
}) : i({
|
|
1475
|
-
error:
|
|
1491
|
+
error: on(e),
|
|
1476
1492
|
status: l,
|
|
1477
1493
|
extra: c
|
|
1478
1494
|
});
|
|
@@ -1481,18 +1497,18 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1481
1497
|
if (D && clearTimeout(D), O(), S?.signal?.aborted) {
|
|
1482
1498
|
E && o({
|
|
1483
1499
|
status: 0,
|
|
1484
|
-
extra:
|
|
1500
|
+
extra: fn
|
|
1485
1501
|
});
|
|
1486
1502
|
return;
|
|
1487
1503
|
}
|
|
1488
1504
|
i({
|
|
1489
1505
|
error: e,
|
|
1490
1506
|
status: 0,
|
|
1491
|
-
extra:
|
|
1507
|
+
extra: fn
|
|
1492
1508
|
});
|
|
1493
1509
|
}
|
|
1494
|
-
}),
|
|
1495
|
-
emitter = new
|
|
1510
|
+
}), mn = () => pn(), hn = class {
|
|
1511
|
+
emitter = new ze();
|
|
1496
1512
|
events;
|
|
1497
1513
|
storage;
|
|
1498
1514
|
lazyStorage;
|
|
@@ -1503,7 +1519,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1503
1519
|
constructor(e) {
|
|
1504
1520
|
this.options = e;
|
|
1505
1521
|
let { storage: t = /* @__PURE__ */ new Map(), lazyStorage: n, version: r = "0.0.1" } = e ?? {};
|
|
1506
|
-
this.emitter?.setMaxListeners(1e3), this.events =
|
|
1522
|
+
this.emitter?.setMaxListeners(1e3), this.events = Cn(this.emitter), this.storage = t, this.version = r, this.lazyStorage = n;
|
|
1507
1523
|
}
|
|
1508
1524
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Cache"), e.appManager.events.onOnline(() => {
|
|
1509
1525
|
[...this.storage.keys()].forEach(this.scheduleGarbageCollector);
|
|
@@ -1517,7 +1533,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1517
1533
|
response: t
|
|
1518
1534
|
}
|
|
1519
1535
|
});
|
|
1520
|
-
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s =
|
|
1536
|
+
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = W(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u = gn(c, l), d = {
|
|
1521
1537
|
...u,
|
|
1522
1538
|
scope: o,
|
|
1523
1539
|
staleTime: i,
|
|
@@ -1563,7 +1579,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1563
1579
|
partialResponse: t
|
|
1564
1580
|
}
|
|
1565
1581
|
});
|
|
1566
|
-
let { cacheKey: n, scope: r } = e, i =
|
|
1582
|
+
let { cacheKey: n, scope: r } = e, i = W(n, r), a = this.storage.get(i), o = typeof t == "function" ? t(a || null) : t;
|
|
1567
1583
|
a && this.set(e, {
|
|
1568
1584
|
...a,
|
|
1569
1585
|
...o
|
|
@@ -1601,7 +1617,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1601
1617
|
cacheKey: t
|
|
1602
1618
|
}), this.events.emitInvalidation(t);
|
|
1603
1619
|
};
|
|
1604
|
-
e instanceof
|
|
1620
|
+
e instanceof Qt ? n(W(e.cacheKey, e.scope), e.cacheKey) : typeof e == "string" ? n(e) : t.length && t.forEach((t) => {
|
|
1605
1621
|
e.test(t) && n(t);
|
|
1606
1622
|
});
|
|
1607
1623
|
};
|
|
@@ -1656,49 +1672,49 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1656
1672
|
clear = async () => {
|
|
1657
1673
|
this.garbageCollectors.forEach((e) => clearTimeout(e)), this.storage.clear();
|
|
1658
1674
|
};
|
|
1659
|
-
},
|
|
1675
|
+
}, gn = (e, t) => {
|
|
1660
1676
|
let { data: n, success: r } = t, i = !r && e ? e.data : null, a = n || i;
|
|
1661
1677
|
return {
|
|
1662
1678
|
...t,
|
|
1663
1679
|
data: a
|
|
1664
1680
|
};
|
|
1665
|
-
},
|
|
1681
|
+
}, _n = () => "invalidate", vn = (e) => `${e}_invalidate`, yn = () => "delete", bn = (e) => `${e}_delete`, xn = (e) => `${e}_cache`, Sn = () => "cache", Cn = (e) => ({
|
|
1666
1682
|
emitCacheData: (t, n = !1) => {
|
|
1667
|
-
e.emit(
|
|
1683
|
+
e.emit(Sn(), t, n), e.emit(xn(t.cacheKey), t, n);
|
|
1668
1684
|
},
|
|
1669
1685
|
emitInvalidation: (t, n = !1) => {
|
|
1670
|
-
e.emit(
|
|
1686
|
+
e.emit(_n(), t, n), e.emit(vn(t), n);
|
|
1671
1687
|
},
|
|
1672
1688
|
emitDelete: (t, n = !1) => {
|
|
1673
|
-
e.emit(
|
|
1689
|
+
e.emit(yn(), t, n), e.emit(bn(t), n);
|
|
1674
1690
|
},
|
|
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
|
-
}),
|
|
1691
|
+
onData: (t) => (e.on(Sn(), t), () => e.removeListener(Sn(), t)),
|
|
1692
|
+
onDataByKey: (t, n) => (e.on(xn(t), n), () => e.removeListener(xn(t), n)),
|
|
1693
|
+
onInvalidate: (t) => (e.on(_n(), t), () => e.removeListener(_n(), t)),
|
|
1694
|
+
onInvalidateByKey: (t, n) => (e.on(vn(t), n), () => e.removeListener(vn(t), n)),
|
|
1695
|
+
onDelete: (t) => (e.on(yn(), t), () => e.removeListener(yn(), t)),
|
|
1696
|
+
onDeleteByKey: (t, n) => (e.on(bn(t), n), () => e.removeListener(bn(t), n))
|
|
1697
|
+
}), K = /* @__PURE__ */ function(e) {
|
|
1682
1698
|
return e.ONE_BY_ONE = "one-by-one", e.ALL_AT_ONCE = "all-at-once", e.PREVIOUS_CANCELED = "previous-canceled", e.DEDUPLICATED = "deduplicated", e;
|
|
1683
|
-
}({}),
|
|
1699
|
+
}({}), wn = (e) => ({
|
|
1684
1700
|
emitDrained: (t, n) => {
|
|
1685
|
-
e.emit(
|
|
1701
|
+
e.emit(En(), t, n), e.emit(Dn(t.queryKey), t, n);
|
|
1686
1702
|
},
|
|
1687
1703
|
emitQueueStatusChanged: (t, n) => {
|
|
1688
|
-
e.emit(
|
|
1704
|
+
e.emit(On(), t, n), e.emit(kn(t.queryKey), t, n);
|
|
1689
1705
|
},
|
|
1690
1706
|
emitQueueChanged: (t, n) => {
|
|
1691
|
-
e.emit(
|
|
1707
|
+
e.emit(An(), t, n), e.emit(jn(t.queryKey), t, n);
|
|
1692
1708
|
},
|
|
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 =
|
|
1709
|
+
onDrained: (t) => (e.on(En(), t), () => e.removeListener(En(), t)),
|
|
1710
|
+
onDrainedByKey: (t, n) => (e.on(Dn(t), n), () => e.removeListener(Dn(t), n)),
|
|
1711
|
+
onQueueStatusChange: (t) => (e.on(On(), t), () => e.removeListener(On(), t)),
|
|
1712
|
+
onQueueStatusChangeByKey: (t, n) => (e.on(kn(t), n), () => e.removeListener(kn(t), n)),
|
|
1713
|
+
onQueueChange: (t) => (e.on(An(), t), () => e.removeListener(An(), t)),
|
|
1714
|
+
onQueueChangeByKey: (t, n) => (e.on(jn(t), n), () => e.removeListener(jn(t), n))
|
|
1715
|
+
}), Tn = class {
|
|
1716
|
+
emitter = new ze();
|
|
1717
|
+
events = wn(this.emitter);
|
|
1702
1718
|
storage = /* @__PURE__ */ new Map();
|
|
1703
1719
|
requestCount = /* @__PURE__ */ new Map();
|
|
1704
1720
|
runningRequests = /* @__PURE__ */ new Map();
|
|
@@ -1707,7 +1723,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1707
1723
|
constructor(e) {
|
|
1708
1724
|
this.options = e, this.emitter?.setMaxListeners(1e3), this.options?.storage && (this.storage = this.options.storage);
|
|
1709
1725
|
}
|
|
1710
|
-
isRequestJSON = (e) => !(e instanceof
|
|
1726
|
+
isRequestJSON = (e) => !(e instanceof Qt);
|
|
1711
1727
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Dispatcher"), this.client.appManager.events.onOnline(() => {
|
|
1712
1728
|
this.flush();
|
|
1713
1729
|
}), this);
|
|
@@ -1831,14 +1847,14 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1831
1847
|
hasRunningRequest = (e, t) => !!this.getRunningRequests(e).find((e) => e.requestId === t);
|
|
1832
1848
|
cancelRunningRequests = (e) => {
|
|
1833
1849
|
this.runningRequests.get(e)?.forEach((e) => {
|
|
1834
|
-
let t =
|
|
1850
|
+
let t = W(e.request.abortKey, e.request.scope);
|
|
1835
1851
|
this.client.requestManager.abortByRequestId(t, e.requestId);
|
|
1836
1852
|
}), this.deleteRunningRequests(e);
|
|
1837
1853
|
};
|
|
1838
1854
|
cancelRunningRequest = (e, t) => {
|
|
1839
1855
|
let n = this.getRunningRequests(e).filter((e) => {
|
|
1840
1856
|
if (e.requestId === t) {
|
|
1841
|
-
let t =
|
|
1857
|
+
let t = W(e.request.abortKey, e.request.scope);
|
|
1842
1858
|
return this.client.requestManager.abortByRequestId(t, e.requestId), !1;
|
|
1843
1859
|
}
|
|
1844
1860
|
return !0;
|
|
@@ -1866,7 +1882,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1866
1882
|
resolved: !1
|
|
1867
1883
|
});
|
|
1868
1884
|
add = (e) => {
|
|
1869
|
-
let t =
|
|
1885
|
+
let t = W(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = Pn(e, i);
|
|
1870
1886
|
switch (this.logger.debug({
|
|
1871
1887
|
title: "Adding request to queue",
|
|
1872
1888
|
type: "system",
|
|
@@ -1876,9 +1892,9 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1876
1892
|
requestId: r
|
|
1877
1893
|
}
|
|
1878
1894
|
}), a) {
|
|
1879
|
-
case
|
|
1880
|
-
case
|
|
1881
|
-
case
|
|
1895
|
+
case K.ONE_BY_ONE: return this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1896
|
+
case K.PREVIOUS_CANCELED: return this.cancelRunningRequests(t), this.clearQueue(t), this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1897
|
+
case K.DEDUPLICATED: return this.client.requestManager.events.emitDeduplicated({
|
|
1882
1898
|
request: i.request,
|
|
1883
1899
|
requestId: r,
|
|
1884
1900
|
deduplicatedRequest: e
|
|
@@ -1920,7 +1936,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1920
1936
|
requestId: n
|
|
1921
1937
|
}
|
|
1922
1938
|
});
|
|
1923
|
-
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l =
|
|
1939
|
+
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = W(a, c), u = W(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h = Mn(e.retries, r), g = !m.isOnline && s, _ = this.hasRunningRequest(l, n), v = e.stopped;
|
|
1924
1940
|
if (g || _ || v) return this.logger.warning({
|
|
1925
1941
|
title: "Unable to perform request",
|
|
1926
1942
|
type: "system",
|
|
@@ -1940,7 +1956,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1940
1956
|
}), this.incrementQueueRequestCount(l), f.addAbortController(u, n);
|
|
1941
1957
|
let b = await d.fetch(t, n);
|
|
1942
1958
|
e.resolved = !0, f.removeAbortController(u, n);
|
|
1943
|
-
let x = !m.isOnline, S =
|
|
1959
|
+
let x = !m.isOnline, S = U("abort").message === b.error?.message, C = !this.hasRunningRequest(l, n) || S;
|
|
1944
1960
|
this.deleteRunningRequest(l, n);
|
|
1945
1961
|
let w = b.success || !h || !t.retryOnError || t.retryOnError(b), T = !b.success && h && w && !C && !x, E = {
|
|
1946
1962
|
isCanceled: C,
|
|
@@ -2054,26 +2070,26 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
2054
2070
|
}
|
|
2055
2071
|
}), this.delete(l, n, u));
|
|
2056
2072
|
};
|
|
2057
|
-
},
|
|
2058
|
-
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ?
|
|
2059
|
-
return n ?
|
|
2073
|
+
}, En = () => "drained-event", Dn = (e) => `${e}-drained-event`, On = () => "status-event", kn = (e) => `${e}-status-event`, An = () => "change-event", jn = (e) => `${e}-change-event`, Mn = (e, t) => !!(t && e < t), Nn = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, Pn = (e, t) => {
|
|
2074
|
+
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? Nn(e, t) : !1;
|
|
2075
|
+
return n ? K.ONE_BY_ONE : r ? K.PREVIOUS_CANCELED : a && i ? K.DEDUPLICATED : K.ALL_AT_ONCE;
|
|
2060
2076
|
};
|
|
2061
|
-
function
|
|
2077
|
+
function Fn(e) {
|
|
2062
2078
|
return e === "client" || e === "server" ? e : typeof window < "u" && typeof document < "u" ? "client" : "server";
|
|
2063
2079
|
}
|
|
2064
|
-
var
|
|
2080
|
+
var In = async (e, t) => {
|
|
2065
2081
|
let n = t;
|
|
2066
2082
|
if (!t.requestOptions.disableRequestInterceptors) {
|
|
2067
2083
|
for (let r of e) if (n = await r(t), !n) throw Error("Request modifier must return request");
|
|
2068
2084
|
}
|
|
2069
2085
|
return n;
|
|
2070
|
-
},
|
|
2086
|
+
}, Ln = async (e, t, n) => {
|
|
2071
2087
|
let r = t;
|
|
2072
2088
|
if (!n.requestOptions.disableResponseInterceptors) {
|
|
2073
2089
|
for (let i of e) if (r = await i(t, n), !r) throw Error("Response modifier must return data");
|
|
2074
2090
|
}
|
|
2075
2091
|
return r;
|
|
2076
|
-
},
|
|
2092
|
+
}, Rn = class {
|
|
2077
2093
|
url;
|
|
2078
2094
|
mode;
|
|
2079
2095
|
debug;
|
|
@@ -2082,8 +2098,8 @@ var Mn = async (e, t) => {
|
|
|
2082
2098
|
unstable_onResponseCallbacks = [];
|
|
2083
2099
|
unstable_onAuthCallbacks = [];
|
|
2084
2100
|
unstable_onRequestCallbacks = [];
|
|
2085
|
-
loggerManager = new
|
|
2086
|
-
requestManager = new
|
|
2101
|
+
loggerManager = new Ct();
|
|
2102
|
+
requestManager = new Ke();
|
|
2087
2103
|
appManager;
|
|
2088
2104
|
adapter;
|
|
2089
2105
|
cache;
|
|
@@ -2091,15 +2107,15 @@ var Mn = async (e, t) => {
|
|
|
2091
2107
|
submitDispatcher;
|
|
2092
2108
|
isMockerEnabled = !0;
|
|
2093
2109
|
plugins = [];
|
|
2094
|
-
unstable_abortKeyMapper =
|
|
2095
|
-
unstable_cacheKeyMapper =
|
|
2096
|
-
unstable_queryKeyMapper =
|
|
2097
|
-
unstable_requestIdMapper =
|
|
2110
|
+
unstable_abortKeyMapper = Kt;
|
|
2111
|
+
unstable_cacheKeyMapper = qt;
|
|
2112
|
+
unstable_queryKeyMapper = qt;
|
|
2113
|
+
unstable_requestIdMapper = Ie;
|
|
2098
2114
|
logger = this.loggerManager.initialize(this, "Client");
|
|
2099
2115
|
constructor(e) {
|
|
2100
2116
|
this.options = e;
|
|
2101
2117
|
let { url: t, appManager: n, cache: r, fetchDispatcher: i, submitDispatcher: a, mode: o } = this.options;
|
|
2102
|
-
this.url = t, this.mode =
|
|
2118
|
+
this.url = t, this.mode = Fn(o), this.adapter = mn(), this.appManager = n?.() || new Be(), this.cache = r?.() || new hn(), this.fetchDispatcher = i?.() || new Tn(), this.submitDispatcher = a?.() || new Tn(), this.adapter.initialize(this), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2103
2119
|
}
|
|
2104
2120
|
setDebug = (e) => (this.debug = e, this);
|
|
2105
2121
|
setLogLevel = (e) => (this.loggerManager.setSeverity(e), this);
|
|
@@ -2128,15 +2144,15 @@ var Mn = async (e, t) => {
|
|
|
2128
2144
|
setCacheKeyMapper = (e) => (this.unstable_cacheKeyMapper = e, this);
|
|
2129
2145
|
setQueryKeyMapper = (e) => (this.unstable_queryKeyMapper = e, this);
|
|
2130
2146
|
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) =>
|
|
2147
|
+
unstable_modifyAuth = async (e) => In(this.unstable_onAuthCallbacks, e);
|
|
2148
|
+
unstable_modifyRequest = async (e) => In(this.unstable_onRequestCallbacks, e);
|
|
2149
|
+
unstable_modifyErrorResponse = async (e, t) => Ln(this.unstable_onErrorCallbacks, e, t);
|
|
2150
|
+
unstable_modifySuccessResponse = async (e, t) => Ln(this.unstable_onSuccessCallbacks, e, t);
|
|
2151
|
+
unstable_modifyResponse = async (e, t) => Ln(this.unstable_onResponseCallbacks, e, t);
|
|
2152
|
+
fromJSON = (e) => Qt.fromJSON(this, e);
|
|
2137
2153
|
clear = () => {
|
|
2138
2154
|
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
|
|
2155
|
+
this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new hn(), this.appManager = e?.() || new Be(), this.fetchDispatcher = n?.() || new Tn(), this.submitDispatcher = r?.() || new Tn(), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2140
2156
|
};
|
|
2141
2157
|
hydrate = (e, t) => {
|
|
2142
2158
|
e?.forEach((e) => {
|
|
@@ -2153,8 +2169,8 @@ var Mn = async (e, t) => {
|
|
|
2153
2169
|
...a,
|
|
2154
2170
|
...t
|
|
2155
2171
|
};
|
|
2156
|
-
if (!s.override && this.cache.get(
|
|
2157
|
-
let c =
|
|
2172
|
+
if (!s.override && this.cache.get(W(n, r))) return;
|
|
2173
|
+
let c = an(i);
|
|
2158
2174
|
this.cache.set({
|
|
2159
2175
|
...s,
|
|
2160
2176
|
cacheKey: n,
|
|
@@ -2166,10 +2182,10 @@ var Mn = async (e, t) => {
|
|
|
2166
2182
|
let t = this.adapter.unstable_endpointMapper(e.endpoint), n = {
|
|
2167
2183
|
...e,
|
|
2168
2184
|
endpoint: String(t)
|
|
2169
|
-
}, r = new
|
|
2185
|
+
}, r = new Qt(this, n);
|
|
2170
2186
|
return this.plugins.forEach((e) => e.trigger("onRequestCreate", { request: r })), r;
|
|
2171
2187
|
};
|
|
2172
|
-
},
|
|
2188
|
+
}, zn = {
|
|
2173
2189
|
strict: !0,
|
|
2174
2190
|
encode: !0,
|
|
2175
2191
|
arrayFormat: "bracket",
|
|
@@ -2178,101 +2194,101 @@ var Mn = async (e, t) => {
|
|
|
2178
2194
|
skipNull: !0,
|
|
2179
2195
|
skipEmptyString: !0
|
|
2180
2196
|
};
|
|
2181
|
-
function
|
|
2182
|
-
return new
|
|
2197
|
+
function Bn(e) {
|
|
2198
|
+
return new Rn(e);
|
|
2183
2199
|
}
|
|
2184
2200
|
//#endregion
|
|
2185
2201
|
//#region src/core/client.ts
|
|
2186
|
-
var
|
|
2202
|
+
var q = Bn({ url: F() });
|
|
2187
2203
|
//#endregion
|
|
2188
2204
|
//#region src/core/auth-api.ts
|
|
2189
|
-
async function
|
|
2190
|
-
let { data: t, success: n } = await
|
|
2205
|
+
async function Vn(e) {
|
|
2206
|
+
let { data: t, success: n } = await q.createRequest()({
|
|
2191
2207
|
endpoint: "/auth/cli/whoami",
|
|
2192
2208
|
method: "GET"
|
|
2193
2209
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2194
2210
|
return !n || !t ? null : t;
|
|
2195
2211
|
}
|
|
2196
|
-
async function
|
|
2197
|
-
await
|
|
2212
|
+
async function Hn(e) {
|
|
2213
|
+
await q.createRequest()({
|
|
2198
2214
|
endpoint: "/auth/cli/token",
|
|
2199
2215
|
method: "DELETE"
|
|
2200
2216
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2201
2217
|
}
|
|
2202
2218
|
//#endregion
|
|
2203
2219
|
//#region src/core/auth-store.ts
|
|
2204
|
-
var
|
|
2205
|
-
function
|
|
2220
|
+
var Un = 1, Wn = "hype-stack", Gn = "auth.json";
|
|
2221
|
+
function Kn() {
|
|
2206
2222
|
let e = process.env.HYPE_STACK_CONFIG_DIR;
|
|
2207
|
-
if (e) return T.join(e,
|
|
2223
|
+
if (e) return T.join(e, Wn);
|
|
2208
2224
|
let t = w.homedir();
|
|
2209
2225
|
if (process.platform === "win32") {
|
|
2210
2226
|
let e = process.env.APPDATA ?? T.join(t, "AppData", "Roaming");
|
|
2211
|
-
return T.join(e,
|
|
2227
|
+
return T.join(e, Wn);
|
|
2212
2228
|
}
|
|
2213
|
-
if (process.platform === "darwin") return T.join(t, "Library", "Application Support",
|
|
2229
|
+
if (process.platform === "darwin") return T.join(t, "Library", "Application Support", Wn);
|
|
2214
2230
|
let n = process.env.XDG_CONFIG_HOME ?? T.join(t, ".config");
|
|
2215
|
-
return T.join(n,
|
|
2231
|
+
return T.join(n, Wn);
|
|
2216
2232
|
}
|
|
2217
|
-
function
|
|
2218
|
-
return T.join(
|
|
2233
|
+
function qn() {
|
|
2234
|
+
return T.join(Kn(), Gn);
|
|
2219
2235
|
}
|
|
2220
|
-
async function
|
|
2221
|
-
let e = await y.readFile(
|
|
2236
|
+
async function Jn() {
|
|
2237
|
+
let e = await y.readFile(qn(), "utf-8").catch(() => null);
|
|
2222
2238
|
if (!e) return {
|
|
2223
|
-
version:
|
|
2239
|
+
version: Un,
|
|
2224
2240
|
tokens: {}
|
|
2225
2241
|
};
|
|
2226
2242
|
let t = JSON.parse(e);
|
|
2227
2243
|
return {
|
|
2228
|
-
version: t.version ??
|
|
2244
|
+
version: t.version ?? Un,
|
|
2229
2245
|
tokens: t.tokens ?? {}
|
|
2230
2246
|
};
|
|
2231
2247
|
}
|
|
2232
|
-
async function
|
|
2233
|
-
let t =
|
|
2234
|
-
await y.mkdir(t, { recursive: !0 }), await y.writeFile(
|
|
2248
|
+
async function Yn(e) {
|
|
2249
|
+
let t = Kn();
|
|
2250
|
+
await y.mkdir(t, { recursive: !0 }), await y.writeFile(qn(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2235
2251
|
}
|
|
2236
|
-
async function
|
|
2237
|
-
return (await
|
|
2252
|
+
async function Xn(e) {
|
|
2253
|
+
return (await Jn()).tokens[e] ?? null;
|
|
2238
2254
|
}
|
|
2239
|
-
async function
|
|
2240
|
-
let n = await
|
|
2241
|
-
n.tokens[e] = t, await
|
|
2255
|
+
async function Zn(e, t) {
|
|
2256
|
+
let n = await Jn();
|
|
2257
|
+
n.tokens[e] = t, await Yn(n);
|
|
2242
2258
|
}
|
|
2243
|
-
async function
|
|
2244
|
-
let t = await
|
|
2245
|
-
e in t.tokens && (delete t.tokens[e], await
|
|
2259
|
+
async function Qn(e) {
|
|
2260
|
+
let t = await Jn();
|
|
2261
|
+
e in t.tokens && (delete t.tokens[e], await Yn(t));
|
|
2246
2262
|
}
|
|
2247
2263
|
//#endregion
|
|
2248
2264
|
//#region src/core/device.ts
|
|
2249
|
-
function
|
|
2265
|
+
function $n() {
|
|
2250
2266
|
let e = w.networkInterfaces();
|
|
2251
2267
|
for (let t of Object.values(e)) if (t) {
|
|
2252
2268
|
for (let e of t) if (!e.internal && e.mac !== "00:00:00:00:00:00") return e.mac;
|
|
2253
2269
|
}
|
|
2254
2270
|
return "unknown";
|
|
2255
2271
|
}
|
|
2256
|
-
function
|
|
2257
|
-
let e = `${
|
|
2272
|
+
function er() {
|
|
2273
|
+
let e = `${$n()}:${w.hostname()}:${w.platform()}:${w.arch()}`;
|
|
2258
2274
|
return x("sha256").update(e).digest("hex").slice(0, 16);
|
|
2259
2275
|
}
|
|
2260
|
-
function
|
|
2276
|
+
function tr() {
|
|
2261
2277
|
return `hype-stack/${A} ${w.platform()} ${w.arch()} node/${process.version.slice(1)}`;
|
|
2262
2278
|
}
|
|
2263
2279
|
//#endregion
|
|
2264
2280
|
//#region src/core/open-browser.ts
|
|
2265
|
-
function
|
|
2281
|
+
function nr(e) {
|
|
2266
2282
|
E(process.platform === "darwin" ? `open "${e}"` : process.platform === "win32" ? `start "" "${e}"` : `xdg-open "${e}"`);
|
|
2267
2283
|
}
|
|
2268
2284
|
//#endregion
|
|
2269
2285
|
//#region src/core/login.ts
|
|
2270
|
-
var
|
|
2271
|
-
async function
|
|
2272
|
-
let t = S(16).toString("hex"), n =
|
|
2286
|
+
var rr = 300 * 1e3, ir = (e) => `<!doctype html><html><head><meta charset="utf-8"><title>Hype Stack CLI</title></head><body style="font-family:system-ui,sans-serif;text-align:center;padding-top:4rem;color:#111"><h2>${e}</h2><p>You can close this tab and return to your terminal.</p></body></html>`;
|
|
2287
|
+
async function ar(e = {}) {
|
|
2288
|
+
let t = S(16).toString("hex"), n = F(), r = C.createServer(), i = await new Promise((n, i) => {
|
|
2273
2289
|
let a = setTimeout(() => {
|
|
2274
2290
|
o(), i(/* @__PURE__ */ Error("Login timed out. Run `npx @hype-stack/cli login` again."));
|
|
2275
|
-
},
|
|
2291
|
+
}, rr);
|
|
2276
2292
|
function o() {
|
|
2277
2293
|
clearTimeout(a), r.close(), r.closeAllConnections?.();
|
|
2278
2294
|
}
|
|
@@ -2286,7 +2302,7 @@ async function tr(e = {}) {
|
|
|
2286
2302
|
r.writeHead(200, {
|
|
2287
2303
|
"Content-Type": "text/html",
|
|
2288
2304
|
Connection: "close"
|
|
2289
|
-
}), r.end(
|
|
2305
|
+
}), r.end(ir(e));
|
|
2290
2306
|
};
|
|
2291
2307
|
if (a.searchParams.get("state") !== t) {
|
|
2292
2308
|
s("Login failed."), o(), i(/* @__PURE__ */ Error("Login failed: state mismatch. Run `npx @hype-stack/cli login` again."));
|
|
@@ -2301,53 +2317,53 @@ async function tr(e = {}) {
|
|
|
2301
2317
|
}), r.on("error", (e) => {
|
|
2302
2318
|
o(), i(e);
|
|
2303
2319
|
}), r.listen(0, "127.0.0.1", () => {
|
|
2304
|
-
let { port: n } = r.address(), i = encodeURIComponent(
|
|
2305
|
-
e.onUrl?.(a),
|
|
2320
|
+
let { port: n } = r.address(), i = encodeURIComponent(tr()), a = `${le()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
|
|
2321
|
+
e.onUrl?.(a), nr(a);
|
|
2306
2322
|
});
|
|
2307
|
-
}), a = await
|
|
2323
|
+
}), a = await Vn(i).catch(() => null), o = {
|
|
2308
2324
|
token: i,
|
|
2309
2325
|
email: a?.email,
|
|
2310
2326
|
organizationId: a?.organizationId
|
|
2311
2327
|
};
|
|
2312
|
-
return await
|
|
2328
|
+
return await Zn(n, o), o;
|
|
2313
2329
|
}
|
|
2314
2330
|
//#endregion
|
|
2315
2331
|
//#region src/core/access-prompts.ts
|
|
2316
|
-
async function
|
|
2332
|
+
async function or() {
|
|
2317
2333
|
let e = await s.confirm({ message: "Log in to install packs your organization owns? (opens your browser)" });
|
|
2318
2334
|
if (s.isCancel(e) || !e) return null;
|
|
2319
2335
|
s.log.step("Opening your browser to sign in...");
|
|
2320
2336
|
try {
|
|
2321
|
-
let e = await
|
|
2322
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
2337
|
+
let e = await ar({ onUrl: (e) => {
|
|
2338
|
+
s.log.info(`If your browser didn't open, visit:\n ${L.path(e)}`);
|
|
2323
2339
|
} });
|
|
2324
2340
|
return s.log.success(e.email ? `Logged in as ${e.email}` : "Logged in"), e.token;
|
|
2325
2341
|
} catch (e) {
|
|
2326
2342
|
return s.log.error(e instanceof Error ? e.message : String(e)), null;
|
|
2327
2343
|
}
|
|
2328
2344
|
}
|
|
2329
|
-
async function
|
|
2345
|
+
async function sr(e) {
|
|
2330
2346
|
if (e.length === 0) return;
|
|
2331
|
-
|
|
2347
|
+
z([
|
|
2332
2348
|
"These packs need a purchase before they can be installed:",
|
|
2333
2349
|
"",
|
|
2334
|
-
...e.map((e) => ` ${
|
|
2350
|
+
...e.map((e) => ` ${L.brand(e.displayName)} ${L.highlight(`$${e.price}`)}`)
|
|
2335
2351
|
].join("\n"), "Locked Packs");
|
|
2336
2352
|
let t = await s.confirm({ message: `Open the purchase ${e.length === 1 ? "page" : "pages"} in your browser?` });
|
|
2337
2353
|
if (s.isCancel(t) || !t) {
|
|
2338
|
-
s.log.info(
|
|
2354
|
+
s.log.info(L.muted("Run 'npx @hype-stack/cli login' after purchasing, then 'npx @hype-stack/cli compose' again."));
|
|
2339
2355
|
return;
|
|
2340
2356
|
}
|
|
2341
|
-
for (let t of e)
|
|
2357
|
+
for (let t of e) nr(Ee(t.name));
|
|
2342
2358
|
s.log.info([
|
|
2343
|
-
|
|
2344
|
-
` ${
|
|
2345
|
-
` ${
|
|
2359
|
+
L.muted("After purchasing, run:"),
|
|
2360
|
+
` ${L.highlight("npx @hype-stack/cli login")} ${L.muted("Save your access")}`,
|
|
2361
|
+
` ${L.highlight("npx @hype-stack/cli compose")} ${L.muted("Install the packs")}`
|
|
2346
2362
|
].join("\n"));
|
|
2347
2363
|
}
|
|
2348
2364
|
//#endregion
|
|
2349
2365
|
//#region src/utils/exec.ts
|
|
2350
|
-
function
|
|
2366
|
+
function J(e, t, n) {
|
|
2351
2367
|
return new Promise((r, i) => {
|
|
2352
2368
|
let a = D(e, t, {
|
|
2353
2369
|
cwd: n.cwd,
|
|
@@ -2378,7 +2394,7 @@ function q(e, t, n) {
|
|
|
2378
2394
|
});
|
|
2379
2395
|
});
|
|
2380
2396
|
}
|
|
2381
|
-
function
|
|
2397
|
+
function cr(e, t, n) {
|
|
2382
2398
|
return new Promise((r, i) => {
|
|
2383
2399
|
let a = D(e, t, {
|
|
2384
2400
|
cwd: n.cwd,
|
|
@@ -2395,76 +2411,76 @@ function ir(e, t, n) {
|
|
|
2395
2411
|
}
|
|
2396
2412
|
//#endregion
|
|
2397
2413
|
//#region src/utils/fs.ts
|
|
2398
|
-
async function
|
|
2414
|
+
async function lr(e) {
|
|
2399
2415
|
return (await y.stat(e).catch(() => null))?.isDirectory() ?? !1;
|
|
2400
2416
|
}
|
|
2401
|
-
async function
|
|
2417
|
+
async function Y(e) {
|
|
2402
2418
|
return (await y.stat(e).catch(() => null))?.isFile() ?? !1;
|
|
2403
2419
|
}
|
|
2404
|
-
async function
|
|
2420
|
+
async function ur(e) {
|
|
2405
2421
|
return (await y.readdir(e).catch(() => [])).length === 0;
|
|
2406
2422
|
}
|
|
2407
|
-
async function
|
|
2423
|
+
async function dr(e) {
|
|
2408
2424
|
let t = await y.readFile(e, "utf-8").catch(() => null);
|
|
2409
2425
|
return t ? JSON.parse(t) : null;
|
|
2410
2426
|
}
|
|
2411
|
-
async function
|
|
2427
|
+
async function fr(e, t) {
|
|
2412
2428
|
await y.writeFile(e, JSON.stringify(t, null, 2) + "\n", "utf-8");
|
|
2413
2429
|
}
|
|
2414
|
-
async function
|
|
2430
|
+
async function pr(e) {
|
|
2415
2431
|
let t = {};
|
|
2416
|
-
if (!await
|
|
2432
|
+
if (!await lr(e)) return t;
|
|
2417
2433
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
2418
|
-
for (let r of n) r.isDirectory() && await
|
|
2434
|
+
for (let r of n) r.isDirectory() && await Y(T.join(e, r.name, "package.json")) && (t[r.name] = T.relative(T.dirname(e), T.join(e, r.name)));
|
|
2419
2435
|
return t;
|
|
2420
2436
|
}
|
|
2421
|
-
async function
|
|
2437
|
+
async function mr(e) {
|
|
2422
2438
|
await y.rm(e, {
|
|
2423
2439
|
recursive: !0,
|
|
2424
2440
|
force: !0
|
|
2425
2441
|
});
|
|
2426
2442
|
}
|
|
2427
|
-
function
|
|
2443
|
+
function hr(e, t) {
|
|
2428
2444
|
return T.basename(e) === t ? e : T.join(e, t);
|
|
2429
2445
|
}
|
|
2430
2446
|
//#endregion
|
|
2431
2447
|
//#region src/core/codegen.ts
|
|
2432
|
-
function
|
|
2433
|
-
s.log.info(
|
|
2434
|
-
`${
|
|
2435
|
-
`${
|
|
2436
|
-
`${
|
|
2448
|
+
function gr(e) {
|
|
2449
|
+
s.log.info(L.muted("Run database setup yourself when ready:")), z([
|
|
2450
|
+
`${L.command(`cd ${e}`)}`,
|
|
2451
|
+
`${L.command("pnpm exec prisma generate")} ${L.muted("(regenerate the Prisma client)")}`,
|
|
2452
|
+
`${L.command("pnpm exec prisma migrate dev")} ${L.muted("(create + apply tables for new packs)")}`
|
|
2437
2453
|
].join("\n"), "Database Setup");
|
|
2438
2454
|
}
|
|
2439
|
-
async function
|
|
2440
|
-
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, freshScaffold: a, runCommand: o =
|
|
2441
|
-
if (!await
|
|
2455
|
+
async function _r(e) {
|
|
2456
|
+
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, freshScaffold: a, runCommand: o = cr } = e, c = n.backend.root, l = T.join(t, c);
|
|
2457
|
+
if (!await Y(T.join(l, "package.json"))) return;
|
|
2442
2458
|
if (!r) {
|
|
2443
|
-
s.log.step(
|
|
2459
|
+
s.log.step(L.muted(`Generating Prisma client (${L.command("prisma generate")})...`));
|
|
2444
2460
|
let e = await o("pnpm", [
|
|
2445
2461
|
"exec",
|
|
2446
2462
|
"prisma",
|
|
2447
2463
|
"generate"
|
|
2448
2464
|
], { cwd: l });
|
|
2449
2465
|
if (e.exitCode !== 0) {
|
|
2450
|
-
s.log.error(
|
|
2466
|
+
s.log.error(L.muted("prisma generate failed. See the output above, or finish setup manually:")), vr(e), gr(c);
|
|
2451
2467
|
return;
|
|
2452
2468
|
}
|
|
2453
2469
|
s.log.success("Prisma client generated");
|
|
2454
2470
|
}
|
|
2455
2471
|
if (r || i === !1) {
|
|
2456
|
-
|
|
2472
|
+
gr(c);
|
|
2457
2473
|
return;
|
|
2458
2474
|
}
|
|
2459
2475
|
let u = await s.confirm({
|
|
2460
|
-
message: `Run database setup now? (${
|
|
2476
|
+
message: `Run database setup now? (${L.command("prisma migrate dev")})`,
|
|
2461
2477
|
initialValue: !0
|
|
2462
2478
|
});
|
|
2463
2479
|
if (s.isCancel(u) || !u) {
|
|
2464
|
-
|
|
2480
|
+
gr(c);
|
|
2465
2481
|
return;
|
|
2466
2482
|
}
|
|
2467
|
-
s.log.step(
|
|
2483
|
+
s.log.step(L.muted(`Running ${L.command("prisma migrate dev --name add-packs")}...`));
|
|
2468
2484
|
let d = await o("pnpm", [
|
|
2469
2485
|
"exec",
|
|
2470
2486
|
"prisma",
|
|
@@ -2479,7 +2495,7 @@ async function pr(e) {
|
|
|
2479
2495
|
initialValue: !0
|
|
2480
2496
|
});
|
|
2481
2497
|
if (!s.isCancel(e) && e) {
|
|
2482
|
-
s.log.step(
|
|
2498
|
+
s.log.step(L.muted(`Resetting dev database (${L.command("prisma migrate reset --force")})...`));
|
|
2483
2499
|
let e = await o("pnpm", [
|
|
2484
2500
|
"exec",
|
|
2485
2501
|
"prisma",
|
|
@@ -2487,7 +2503,7 @@ async function pr(e) {
|
|
|
2487
2503
|
"reset",
|
|
2488
2504
|
"--force"
|
|
2489
2505
|
], { cwd: l });
|
|
2490
|
-
if (e.exitCode === 0) s.log.step(
|
|
2506
|
+
if (e.exitCode === 0) s.log.step(L.muted(`Running ${L.command("prisma migrate dev --name add-packs")}...`)), d = await o("pnpm", [
|
|
2491
2507
|
"exec",
|
|
2492
2508
|
"prisma",
|
|
2493
2509
|
"migrate",
|
|
@@ -2496,24 +2512,24 @@ async function pr(e) {
|
|
|
2496
2512
|
"add-packs"
|
|
2497
2513
|
], { cwd: l });
|
|
2498
2514
|
else {
|
|
2499
|
-
s.log.error(
|
|
2515
|
+
s.log.error(L.muted("prisma migrate reset did not complete. See the output above, or finish setup manually:")), vr(e), gr(c);
|
|
2500
2516
|
return;
|
|
2501
2517
|
}
|
|
2502
2518
|
}
|
|
2503
2519
|
}
|
|
2504
2520
|
if (d.exitCode !== 0) {
|
|
2505
|
-
s.log.error(
|
|
2521
|
+
s.log.error(L.muted("prisma migrate dev did not complete. See the output above, or finish setup manually:")), vr(d), gr(c);
|
|
2506
2522
|
return;
|
|
2507
2523
|
}
|
|
2508
2524
|
s.log.success("Database schema applied");
|
|
2509
2525
|
}
|
|
2510
|
-
function
|
|
2526
|
+
function vr(e) {
|
|
2511
2527
|
let t = (e.stderr || e.stdout).trim();
|
|
2512
|
-
t && s.log.warn(
|
|
2528
|
+
t && s.log.warn(L.muted(t));
|
|
2513
2529
|
}
|
|
2514
2530
|
//#endregion
|
|
2515
2531
|
//#region src/core/onboard-catalog.ts
|
|
2516
|
-
var
|
|
2532
|
+
var X = {
|
|
2517
2533
|
Config: "config",
|
|
2518
2534
|
Databases: "databases",
|
|
2519
2535
|
Workos: "workos",
|
|
@@ -2523,36 +2539,36 @@ var Y = {
|
|
|
2523
2539
|
Resend: "resend",
|
|
2524
2540
|
IpLocate: "iplocate",
|
|
2525
2541
|
Sentry: "sentry"
|
|
2526
|
-
},
|
|
2527
|
-
[
|
|
2528
|
-
[
|
|
2529
|
-
[
|
|
2530
|
-
[
|
|
2531
|
-
[
|
|
2532
|
-
[
|
|
2533
|
-
[
|
|
2534
|
-
[
|
|
2535
|
-
[
|
|
2536
|
-
},
|
|
2537
|
-
function
|
|
2542
|
+
}, yr = {
|
|
2543
|
+
[X.Config]: "Config",
|
|
2544
|
+
[X.Databases]: "Databases",
|
|
2545
|
+
[X.Workos]: "WorkOS",
|
|
2546
|
+
[X.BetterAuth]: "Better Auth",
|
|
2547
|
+
[X.Stripe]: "Stripe",
|
|
2548
|
+
[X.Polar]: "Polar",
|
|
2549
|
+
[X.Resend]: "Resend",
|
|
2550
|
+
[X.IpLocate]: "IP Locate",
|
|
2551
|
+
[X.Sentry]: "Sentry"
|
|
2552
|
+
}, br = new Set(Object.values(X));
|
|
2553
|
+
function xr(e) {
|
|
2538
2554
|
return e.toLowerCase().replace(/[^a-z0-9]+/g, "").trim();
|
|
2539
2555
|
}
|
|
2540
|
-
function
|
|
2541
|
-
let t =
|
|
2542
|
-
return
|
|
2556
|
+
function Sr(e) {
|
|
2557
|
+
let t = xr(e);
|
|
2558
|
+
return br.has(t) ? t : void 0;
|
|
2543
2559
|
}
|
|
2544
|
-
var
|
|
2545
|
-
[
|
|
2546
|
-
[
|
|
2547
|
-
[
|
|
2560
|
+
var Cr = {
|
|
2561
|
+
[X.Config]: { hint: "App URLs. Defaults work for local dev." },
|
|
2562
|
+
[X.Databases]: { hint: "Credentials for the local Docker Postgres and Valkey containers." },
|
|
2563
|
+
[X.Workos]: {
|
|
2548
2564
|
link: "https://dashboard.workos.com/api-keys",
|
|
2549
2565
|
hint: "Copy your API Key and Client ID from the WorkOS dashboard."
|
|
2550
2566
|
},
|
|
2551
|
-
[
|
|
2567
|
+
[X.BetterAuth]: {
|
|
2552
2568
|
link: "https://www.better-auth.com/docs/installation#set-environment-variables",
|
|
2553
2569
|
hint: "Generate a long random secret, set the app URL, add Google OAuth creds if you use Google."
|
|
2554
2570
|
},
|
|
2555
|
-
[
|
|
2571
|
+
[X.Stripe]: {
|
|
2556
2572
|
link: "https://dashboard.stripe.com/apikeys",
|
|
2557
2573
|
hint: "Copy your secret and publishable keys from the Stripe dashboard.",
|
|
2558
2574
|
serviceChecklist: [
|
|
@@ -2563,77 +2579,77 @@ var yr = {
|
|
|
2563
2579
|
"Optional: disable Cash App Pay if you see a high checkout cancel rate."
|
|
2564
2580
|
]
|
|
2565
2581
|
},
|
|
2566
|
-
[
|
|
2582
|
+
[X.Polar]: {
|
|
2567
2583
|
link: "https://polar.sh",
|
|
2568
2584
|
hint: "From your Polar org: access token, webhook secret, organization id, and the checkout product id."
|
|
2569
2585
|
},
|
|
2570
|
-
[
|
|
2586
|
+
[X.Resend]: {
|
|
2571
2587
|
link: "https://resend.com/api-keys",
|
|
2572
2588
|
hint: "Create an API key in Resend."
|
|
2573
2589
|
},
|
|
2574
|
-
[
|
|
2590
|
+
[X.IpLocate]: {
|
|
2575
2591
|
link: "https://iplocate.io",
|
|
2576
2592
|
hint: "Grab your API key from IP Locate."
|
|
2577
2593
|
},
|
|
2578
|
-
[
|
|
2594
|
+
[X.Sentry]: {
|
|
2579
2595
|
link: "https://sentry.io",
|
|
2580
2596
|
hint: "Your project DSN. Leave blank to skip Sentry for now."
|
|
2581
2597
|
}
|
|
2582
|
-
},
|
|
2583
|
-
function
|
|
2584
|
-
let t =
|
|
2585
|
-
return t ?
|
|
2598
|
+
}, wr = { hint: "Add your value, or press Enter to leave it blank." };
|
|
2599
|
+
function Tr(e) {
|
|
2600
|
+
let t = Sr(e);
|
|
2601
|
+
return t ? Cr[t] : wr;
|
|
2586
2602
|
}
|
|
2587
|
-
function
|
|
2603
|
+
function Er(e, t) {
|
|
2588
2604
|
if (t.length === 0) return !0;
|
|
2589
|
-
let n =
|
|
2605
|
+
let n = Sr(e);
|
|
2590
2606
|
return n ? t.includes(n) : !1;
|
|
2591
2607
|
}
|
|
2592
|
-
function
|
|
2608
|
+
function Dr(e) {
|
|
2593
2609
|
return e ? e.map((e) => {
|
|
2594
|
-
let t =
|
|
2595
|
-
if (!t) throw Error(`Unknown onboarding env section "${e.envExample.section}". Known sections: ${Object.values(
|
|
2610
|
+
let t = Sr(e.envExample.section);
|
|
2611
|
+
if (!t) throw Error(`Unknown onboarding env section "${e.envExample.section}". Known sections: ${Object.values(X).join(", ")}.`);
|
|
2596
2612
|
return t;
|
|
2597
2613
|
}) : [];
|
|
2598
2614
|
}
|
|
2599
|
-
function
|
|
2615
|
+
function Or(e) {
|
|
2600
2616
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2601
2617
|
for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
2602
2618
|
return n;
|
|
2603
2619
|
}
|
|
2604
|
-
var
|
|
2620
|
+
var kr = {
|
|
2605
2621
|
"starter-saas-workos": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
2606
2622
|
"starter-saas-betterauth": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
2607
2623
|
"pack-notifications": ["Notifications push over the `appChannel` socket channel; register it in your server startup to go live."],
|
|
2608
2624
|
"pack-collaboration": ["Team and TeamMember are available as CASL subjects; project member and team management reuse the existing `Project` subject."]
|
|
2609
2625
|
};
|
|
2610
|
-
function
|
|
2626
|
+
function Ar(e) {
|
|
2611
2627
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2612
2628
|
for (let r of e) {
|
|
2613
|
-
let e =
|
|
2629
|
+
let e = kr[r];
|
|
2614
2630
|
if (e) for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
2615
2631
|
}
|
|
2616
2632
|
return n;
|
|
2617
2633
|
}
|
|
2618
2634
|
//#endregion
|
|
2619
2635
|
//#region src/core/stack-config.ts
|
|
2620
|
-
async function
|
|
2621
|
-
return
|
|
2636
|
+
async function jr(e) {
|
|
2637
|
+
return dr(T.join(e, ne));
|
|
2622
2638
|
}
|
|
2623
|
-
async function
|
|
2624
|
-
return
|
|
2639
|
+
async function Mr(e) {
|
|
2640
|
+
return Y(T.join(e, ne));
|
|
2625
2641
|
}
|
|
2626
|
-
async function
|
|
2627
|
-
await
|
|
2642
|
+
async function Nr(e, t) {
|
|
2643
|
+
await fr(T.join(e, ne), t);
|
|
2628
2644
|
}
|
|
2629
|
-
async function
|
|
2630
|
-
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([
|
|
2645
|
+
async function Pr(e) {
|
|
2646
|
+
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([pr(t), pr(n)]);
|
|
2631
2647
|
return {
|
|
2632
2648
|
apps: r,
|
|
2633
2649
|
packages: i
|
|
2634
2650
|
};
|
|
2635
2651
|
}
|
|
2636
|
-
function
|
|
2652
|
+
function Fr(e) {
|
|
2637
2653
|
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";
|
|
2638
2654
|
return {
|
|
2639
2655
|
backend: {
|
|
@@ -2667,23 +2683,23 @@ function jr(e) {
|
|
|
2667
2683
|
}
|
|
2668
2684
|
};
|
|
2669
2685
|
}
|
|
2670
|
-
function
|
|
2686
|
+
function Ir(e, t) {
|
|
2671
2687
|
return {
|
|
2672
|
-
$schema:
|
|
2688
|
+
$schema: de(),
|
|
2673
2689
|
version: 1,
|
|
2674
2690
|
name: e,
|
|
2675
2691
|
apps: t.apps,
|
|
2676
2692
|
packages: t.packages,
|
|
2677
|
-
paths:
|
|
2693
|
+
paths: Fr(t),
|
|
2678
2694
|
installedPacks: [],
|
|
2679
2695
|
licenseKey: null
|
|
2680
2696
|
};
|
|
2681
2697
|
}
|
|
2682
|
-
async function
|
|
2683
|
-
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([
|
|
2698
|
+
async function Lr(e) {
|
|
2699
|
+
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([Y(t), lr(n)]);
|
|
2684
2700
|
return r && i;
|
|
2685
2701
|
}
|
|
2686
|
-
function
|
|
2702
|
+
function Z(e, t) {
|
|
2687
2703
|
return e.replace(/\{\{(\w+)\.(\w+)\}\}/g, (n, r, i) => {
|
|
2688
2704
|
let a = t[r];
|
|
2689
2705
|
if (!a) throw Error(`Unknown app "${r}" in path template "${e}"`);
|
|
@@ -2694,8 +2710,8 @@ function X(e, t) {
|
|
|
2694
2710
|
}
|
|
2695
2711
|
//#endregion
|
|
2696
2712
|
//#region src/core/registry.ts
|
|
2697
|
-
async function
|
|
2698
|
-
let { data: t, error: n, status: r } = await
|
|
2713
|
+
async function Rr(e) {
|
|
2714
|
+
let { data: t, error: n, status: r } = await q.createRequest()({
|
|
2699
2715
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2700
2716
|
method: "GET"
|
|
2701
2717
|
}).send();
|
|
@@ -2703,13 +2719,13 @@ async function Pr(e) {
|
|
|
2703
2719
|
if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
|
|
2704
2720
|
return t;
|
|
2705
2721
|
}
|
|
2706
|
-
async function
|
|
2707
|
-
let n =
|
|
2722
|
+
async function zr(e, t = {}) {
|
|
2723
|
+
let n = q.createRequest()({
|
|
2708
2724
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2709
2725
|
method: "POST"
|
|
2710
2726
|
}), r = {
|
|
2711
|
-
"X-Device-Id":
|
|
2712
|
-
"X-Client-Info":
|
|
2727
|
+
"X-Device-Id": er(),
|
|
2728
|
+
"X-Client-Info": tr()
|
|
2713
2729
|
};
|
|
2714
2730
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2715
2731
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -2729,25 +2745,25 @@ async function Fr(e, t = {}) {
|
|
|
2729
2745
|
packDir: s
|
|
2730
2746
|
};
|
|
2731
2747
|
}
|
|
2732
|
-
function
|
|
2733
|
-
let r =
|
|
2748
|
+
function Br(e, t, n) {
|
|
2749
|
+
let r = Z(e, t);
|
|
2734
2750
|
return T.resolve(n, r);
|
|
2735
2751
|
}
|
|
2736
|
-
function
|
|
2752
|
+
function Vr(e, t) {
|
|
2737
2753
|
return T.join(t, e);
|
|
2738
2754
|
}
|
|
2739
|
-
var
|
|
2755
|
+
var Hr = q.createRequest()({
|
|
2740
2756
|
endpoint: "/packs/list",
|
|
2741
2757
|
method: "GET"
|
|
2742
2758
|
});
|
|
2743
|
-
async function
|
|
2744
|
-
let { data: e, error: t } = await
|
|
2759
|
+
async function Ur() {
|
|
2760
|
+
let { data: e, error: t } = await Hr.send();
|
|
2745
2761
|
if (t || !e) throw Error(`Failed to fetch pack list: ${String(t)}`);
|
|
2746
2762
|
return e.packs;
|
|
2747
2763
|
}
|
|
2748
|
-
async function
|
|
2764
|
+
async function Wr(e, t = {}) {
|
|
2749
2765
|
if (e.length === 0) return {};
|
|
2750
|
-
let n =
|
|
2766
|
+
let n = q.createRequest()({
|
|
2751
2767
|
endpoint: "/packs/authorize",
|
|
2752
2768
|
method: "POST"
|
|
2753
2769
|
}), r = {};
|
|
@@ -2761,33 +2777,33 @@ async function Br(e, t = {}) {
|
|
|
2761
2777
|
}
|
|
2762
2778
|
//#endregion
|
|
2763
2779
|
//#region src/core/codemods.ts
|
|
2764
|
-
var
|
|
2765
|
-
function
|
|
2766
|
-
return e.replace(
|
|
2780
|
+
var Gr = "@hype-stack/", Kr = /@hype-stack\/(?!cli\b)/g;
|
|
2781
|
+
function qr(e, t) {
|
|
2782
|
+
return e.replace(Kr, t);
|
|
2767
2783
|
}
|
|
2768
|
-
function
|
|
2769
|
-
return
|
|
2784
|
+
function Jr(e, t) {
|
|
2785
|
+
return Z(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
|
|
2770
2786
|
}
|
|
2771
|
-
async function
|
|
2772
|
-
let r =
|
|
2773
|
-
if (await
|
|
2787
|
+
async function Yr(e, t, n) {
|
|
2788
|
+
let r = Z("{{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"), s = T.resolve(n, r, ".env.test");
|
|
2789
|
+
if (await Y(i)) {
|
|
2774
2790
|
let t = await y.readFile(i, "utf-8");
|
|
2775
|
-
for (let n of e) t.includes(`from "${n.from}"`) || (t =
|
|
2791
|
+
for (let n of e) t.includes(`from "${n.from}"`) || (t = Xr(t, n), t = Zr(t, n));
|
|
2776
2792
|
await y.writeFile(i, t, "utf-8");
|
|
2777
2793
|
}
|
|
2778
|
-
if (await Promise.all([a, o].map((t) =>
|
|
2794
|
+
if (await Promise.all([a, o].map((t) => Qr(t, e))), await Y(s)) {
|
|
2779
2795
|
let t = await y.readFile(s, "utf-8");
|
|
2780
|
-
for (let n of e) t =
|
|
2796
|
+
for (let n of e) t = ei(t, n);
|
|
2781
2797
|
await y.writeFile(s, t, "utf-8");
|
|
2782
2798
|
}
|
|
2783
2799
|
}
|
|
2784
|
-
function
|
|
2800
|
+
function Xr(e, t) {
|
|
2785
2801
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2786
2802
|
if (r === -1) return n + "\n" + e;
|
|
2787
2803
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2788
2804
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2789
2805
|
}
|
|
2790
|
-
function
|
|
2806
|
+
function Zr(e, t) {
|
|
2791
2807
|
let n = `.extend(${t.import}.shape)`;
|
|
2792
2808
|
if (e.includes(n)) return e;
|
|
2793
2809
|
let r = e.indexOf("export const envSchema = z.object({");
|
|
@@ -2802,33 +2818,33 @@ function qr(e, t) {
|
|
|
2802
2818
|
let o = a + 2;
|
|
2803
2819
|
return e.slice(0, o) + n + e.slice(o);
|
|
2804
2820
|
}
|
|
2805
|
-
async function
|
|
2806
|
-
if (!await
|
|
2821
|
+
async function Qr(e, t) {
|
|
2822
|
+
if (!await Y(e)) return;
|
|
2807
2823
|
let n = await y.readFile(e, "utf-8");
|
|
2808
|
-
for (let e of t) n =
|
|
2824
|
+
for (let e of t) n = $r(n, e);
|
|
2809
2825
|
await y.writeFile(e, n, "utf-8");
|
|
2810
2826
|
}
|
|
2811
|
-
function
|
|
2827
|
+
function $r(e, t) {
|
|
2812
2828
|
for (let n of Object.keys(t.envExample.vars)) if (e.includes(`${n}=`)) return e;
|
|
2813
2829
|
let n = [];
|
|
2814
|
-
n.push(""), n.push(`# ${
|
|
2830
|
+
n.push(""), n.push(`# ${yr[t.envExample.section]}`);
|
|
2815
2831
|
for (let [e, r] of Object.entries(t.envExample.vars)) n.push(`${e}=${r}`);
|
|
2816
2832
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2817
2833
|
}
|
|
2818
|
-
function
|
|
2834
|
+
function ei(e, t) {
|
|
2819
2835
|
for (let n of Object.keys(t.envTest)) if (e.includes(`${n}=`)) return e;
|
|
2820
2836
|
let n = [""];
|
|
2821
2837
|
for (let [e, r] of Object.entries(t.envTest)) n.push(`${e}=${r}`);
|
|
2822
2838
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2823
2839
|
}
|
|
2824
|
-
async function
|
|
2825
|
-
let r = T.resolve(n,
|
|
2826
|
-
if (!await
|
|
2840
|
+
async function ti(e, t, n) {
|
|
2841
|
+
let r = T.resolve(n, Z("{{backend.routes}}", t), "index.ts");
|
|
2842
|
+
if (!await Y(r)) return;
|
|
2827
2843
|
let i = await y.readFile(r, "utf-8");
|
|
2828
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2844
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = ni(i, t), i = ri(i, t));
|
|
2829
2845
|
await y.writeFile(r, i, "utf-8");
|
|
2830
2846
|
}
|
|
2831
|
-
function
|
|
2847
|
+
function ni(e, t) {
|
|
2832
2848
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2833
2849
|
if (r !== -1) {
|
|
2834
2850
|
let t = e.indexOf("\n", r);
|
|
@@ -2837,7 +2853,7 @@ function Qr(e, t) {
|
|
|
2837
2853
|
let i = e.indexOf("export const registerRoutes");
|
|
2838
2854
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2839
2855
|
}
|
|
2840
|
-
function
|
|
2856
|
+
function ri(e, t) {
|
|
2841
2857
|
let n = `.route("${t.prefix}", ${t.import})`, r = e.match(/\.route\([^)]+\);/g);
|
|
2842
2858
|
if (r) {
|
|
2843
2859
|
let t = r[r.length - 1], i = e.lastIndexOf(t) + t.length - 1;
|
|
@@ -2845,14 +2861,14 @@ function $r(e, t) {
|
|
|
2845
2861
|
}
|
|
2846
2862
|
return e.replace("return app;", `return app\n ${n};`);
|
|
2847
2863
|
}
|
|
2848
|
-
async function
|
|
2849
|
-
let r = T.resolve(n,
|
|
2850
|
-
if (!await
|
|
2864
|
+
async function ii(e, t, n) {
|
|
2865
|
+
let r = T.resolve(n, Z("{{backend.root}}", t), "src/context.ts");
|
|
2866
|
+
if (!await Y(r)) return;
|
|
2851
2867
|
let i = await y.readFile(r, "utf-8");
|
|
2852
|
-
for (let t of e) i.includes(`export let ${t.export}`) || (i =
|
|
2868
|
+
for (let t of e) i.includes(`export let ${t.export}`) || (i = ai(i, t), i = oi(i, t), i = si(i, t), i = li(i, t));
|
|
2853
2869
|
await y.writeFile(r, i, "utf-8");
|
|
2854
2870
|
}
|
|
2855
|
-
function
|
|
2871
|
+
function ai(e, t) {
|
|
2856
2872
|
let n = `import { ${t.typeImport.name} } from "${t.typeImport.from}";`;
|
|
2857
2873
|
if (e.includes(`from "${t.typeImport.from}"`)) return e;
|
|
2858
2874
|
let r = e.lastIndexOf("import ");
|
|
@@ -2860,7 +2876,7 @@ function ti(e, t) {
|
|
|
2860
2876
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2861
2877
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2862
2878
|
}
|
|
2863
|
-
function
|
|
2879
|
+
function oi(e, t) {
|
|
2864
2880
|
let n = `export let ${t.export}: ${t.type};`, r = e.lastIndexOf("export let ");
|
|
2865
2881
|
if (r === -1) {
|
|
2866
2882
|
let t = e.indexOf("export const setupContext");
|
|
@@ -2869,15 +2885,15 @@ function ni(e, t) {
|
|
|
2869
2885
|
let i = e.indexOf("\n", r);
|
|
2870
2886
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2871
2887
|
}
|
|
2872
|
-
function
|
|
2888
|
+
function si(e, t) {
|
|
2873
2889
|
let n = ` ${t.export} = ${t.init};`, r = e.match(/export const setupContext\s*=\s*async\s*\([^)]*\)\s*=>\s*\{/);
|
|
2874
2890
|
if (!r) return e;
|
|
2875
2891
|
let i = e.indexOf("{", e.indexOf(r[0]));
|
|
2876
2892
|
if (i === -1) return e;
|
|
2877
|
-
let a =
|
|
2893
|
+
let a = ci(e, i);
|
|
2878
2894
|
return a === -1 ? e : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2879
2895
|
}
|
|
2880
|
-
function
|
|
2896
|
+
function ci(e, t) {
|
|
2881
2897
|
let n = 0;
|
|
2882
2898
|
for (let r = t; r < e.length; r++) {
|
|
2883
2899
|
let t = e[r];
|
|
@@ -2886,20 +2902,20 @@ function ii(e, t) {
|
|
|
2886
2902
|
}
|
|
2887
2903
|
return -1;
|
|
2888
2904
|
}
|
|
2889
|
-
function
|
|
2905
|
+
function li(e, t) {
|
|
2890
2906
|
let n = ` ${t.export}: ${t.type};`, r = e.indexOf("export type ContextVariables = {");
|
|
2891
2907
|
if (r === -1) return e;
|
|
2892
2908
|
let i = e.indexOf("};", r);
|
|
2893
2909
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2894
2910
|
}
|
|
2895
|
-
async function
|
|
2896
|
-
let r = T.resolve(n,
|
|
2897
|
-
if (!await
|
|
2911
|
+
async function ui(e, t, n) {
|
|
2912
|
+
let r = T.resolve(n, Z("{{enums.src}}", t), "index.ts");
|
|
2913
|
+
if (!await Y(r)) return;
|
|
2898
2914
|
let i = await y.readFile(r, "utf-8");
|
|
2899
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2915
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = di(i, t));
|
|
2900
2916
|
await y.writeFile(r, i, "utf-8");
|
|
2901
2917
|
}
|
|
2902
|
-
function
|
|
2918
|
+
function di(e, t) {
|
|
2903
2919
|
let n = `export * from "${t.from}";`, r = e.lastIndexOf("export * from");
|
|
2904
2920
|
if (r !== -1) {
|
|
2905
2921
|
let t = e.indexOf("\n", r);
|
|
@@ -2907,14 +2923,14 @@ function si(e, t) {
|
|
|
2907
2923
|
}
|
|
2908
2924
|
return e.trim() === "" ? n + "\n" : e.trimEnd() + "\n" + n + "\n";
|
|
2909
2925
|
}
|
|
2910
|
-
async function
|
|
2911
|
-
let r =
|
|
2912
|
-
if (!await
|
|
2926
|
+
async function fi(e, t, n) {
|
|
2927
|
+
let r = Z("{{backend.root}}", t), i = T.resolve(n, r, "src/sockets/index.ts");
|
|
2928
|
+
if (!await Y(i)) return;
|
|
2913
2929
|
let a = await y.readFile(i, "utf-8");
|
|
2914
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2915
|
-
await
|
|
2930
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = pi(a, t), a = mi(a, t));
|
|
2931
|
+
await Y(T.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a = hi(a)), await y.writeFile(i, a, "utf-8");
|
|
2916
2932
|
}
|
|
2917
|
-
function
|
|
2933
|
+
function pi(e, t) {
|
|
2918
2934
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2919
2935
|
if (r !== -1) {
|
|
2920
2936
|
let t = e.indexOf("\n", r);
|
|
@@ -2923,7 +2939,7 @@ function li(e, t) {
|
|
|
2923
2939
|
let i = e.indexOf("const sockets");
|
|
2924
2940
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2925
2941
|
}
|
|
2926
|
-
function
|
|
2942
|
+
function mi(e, t) {
|
|
2927
2943
|
let n = `.socket("${t.prefix}", ${t.import})`, r = e.indexOf("const sockets");
|
|
2928
2944
|
if (r === -1) return e;
|
|
2929
2945
|
let i = e.indexOf("new SocketRouter", r);
|
|
@@ -2937,7 +2953,7 @@ function ui(e, t) {
|
|
|
2937
2953
|
}
|
|
2938
2954
|
return e;
|
|
2939
2955
|
}
|
|
2940
|
-
function
|
|
2956
|
+
function hi(e) {
|
|
2941
2957
|
if (e.includes("wsAuthenticate")) return e;
|
|
2942
2958
|
let t = e.indexOf("from \"@backend/libs/websocket/socket-router\""), n = e;
|
|
2943
2959
|
if (t !== -1) {
|
|
@@ -2946,14 +2962,14 @@ function di(e) {
|
|
|
2946
2962
|
}
|
|
2947
2963
|
return n.replace("new SocketRouter()", "new SocketRouter({ authenticate: wsAuthenticate })");
|
|
2948
2964
|
}
|
|
2949
|
-
async function
|
|
2950
|
-
let r =
|
|
2951
|
-
if (!await
|
|
2965
|
+
async function gi(e, t, n) {
|
|
2966
|
+
let r = Z("{{frontend.root}}", t), i = T.resolve(n, r, "src/api/sdk.ts");
|
|
2967
|
+
if (!await Y(i)) return;
|
|
2952
2968
|
let a = await y.readFile(i, "utf-8");
|
|
2953
|
-
for (let t of e) a.includes(`.$configure(${t.import})`) || (a =
|
|
2969
|
+
for (let t of e) a.includes(`.$configure(${t.import})`) || (a = _i(a, t), a = vi(a, t));
|
|
2954
2970
|
await y.writeFile(i, a, "utf-8");
|
|
2955
2971
|
}
|
|
2956
|
-
function
|
|
2972
|
+
function _i(e, t) {
|
|
2957
2973
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2958
2974
|
if (e.includes(n)) return e;
|
|
2959
2975
|
let r = e.lastIndexOf("from \"./");
|
|
@@ -2964,20 +2980,20 @@ function pi(e, t) {
|
|
|
2964
2980
|
let i = e.indexOf("export const sdk");
|
|
2965
2981
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2966
2982
|
}
|
|
2967
|
-
function
|
|
2983
|
+
function vi(e, t) {
|
|
2968
2984
|
let n = `.$configure(${t.import})`, r = e.indexOf("export const sdk");
|
|
2969
2985
|
if (r === -1) return e;
|
|
2970
2986
|
let i = e.indexOf(";", r);
|
|
2971
2987
|
return i === -1 ? e : e.slice(0, i) + "\n " + n + e.slice(i);
|
|
2972
2988
|
}
|
|
2973
|
-
async function
|
|
2974
|
-
let r = T.resolve(n,
|
|
2975
|
-
if (!await
|
|
2989
|
+
async function yi(e, t, n) {
|
|
2990
|
+
let r = T.resolve(n, Z("{{backend.utils}}", t), "frontend-url/frontend-url.ts");
|
|
2991
|
+
if (!await Y(r)) return;
|
|
2976
2992
|
let i = await y.readFile(r, "utf-8");
|
|
2977
|
-
for (let t of e) i.includes(`"${t.path}"`) || (i =
|
|
2993
|
+
for (let t of e) i.includes(`"${t.path}"`) || (i = bi(i, t));
|
|
2978
2994
|
await y.writeFile(r, i, "utf-8");
|
|
2979
2995
|
}
|
|
2980
|
-
function
|
|
2996
|
+
function bi(e, t) {
|
|
2981
2997
|
let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
|
|
2982
2998
|
if (r === -1) return e;
|
|
2983
2999
|
let i = e.indexOf("{", r);
|
|
@@ -2993,38 +3009,38 @@ function gi(e, t) {
|
|
|
2993
3009
|
}
|
|
2994
3010
|
return o === -1 ? e : e.slice(0, o) + n + "\n" + e.slice(o);
|
|
2995
3011
|
}
|
|
2996
|
-
var
|
|
3012
|
+
var xi = "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", Si = {
|
|
2997
3013
|
primary: "primaryNav",
|
|
2998
3014
|
secondary: "secondaryNav",
|
|
2999
3015
|
tertiary: "tertiaryNav",
|
|
3000
3016
|
settings: "settingsNav"
|
|
3001
3017
|
};
|
|
3002
|
-
async function
|
|
3003
|
-
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
3004
|
-
await
|
|
3005
|
-
for (let e of t) s.includes(`label: "${e.label}"`) || (s =
|
|
3006
|
-
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s =
|
|
3018
|
+
async function Ci(e) {
|
|
3019
|
+
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Jr(i, n), o = T.resolve(r, a, "src/constants/nav.constants.ts"), s;
|
|
3020
|
+
await Y(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = xi);
|
|
3021
|
+
for (let e of t) s.includes(`label: "${e.label}"`) || (s = Ei(s, e));
|
|
3022
|
+
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s = Oi(s, e));
|
|
3007
3023
|
await y.writeFile(o, s, "utf-8");
|
|
3008
3024
|
}
|
|
3009
|
-
async function
|
|
3010
|
-
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
3011
|
-
if (!await
|
|
3025
|
+
async function wi(e) {
|
|
3026
|
+
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Jr(i, n), o = T.resolve(r, a, "src/features/auth/constants/auth.constants.ts");
|
|
3027
|
+
if (!await Y(o)) return;
|
|
3012
3028
|
let s = await y.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
|
|
3013
3029
|
if (!c.test(s)) return;
|
|
3014
3030
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
3015
3031
|
await y.writeFile(o, l, "utf-8");
|
|
3016
3032
|
}
|
|
3017
|
-
function
|
|
3033
|
+
function Ti(e) {
|
|
3018
3034
|
let t = [e.icon];
|
|
3019
3035
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
3020
3036
|
return t;
|
|
3021
3037
|
}
|
|
3022
|
-
function
|
|
3023
|
-
let n =
|
|
3024
|
-
for (let e of n) r =
|
|
3038
|
+
function Ei(e, t) {
|
|
3039
|
+
let n = Ti(t), r = e;
|
|
3040
|
+
for (let e of n) r = Di(r, e);
|
|
3025
3041
|
return r;
|
|
3026
3042
|
}
|
|
3027
|
-
function
|
|
3043
|
+
function Di(e, t) {
|
|
3028
3044
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
3029
3045
|
if (!n) return e;
|
|
3030
3046
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -3032,21 +3048,21 @@ function Ci(e, t) {
|
|
|
3032
3048
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
3033
3049
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
3034
3050
|
}
|
|
3035
|
-
function
|
|
3036
|
-
let n =
|
|
3051
|
+
function Oi(e, t) {
|
|
3052
|
+
let n = Si[t.group];
|
|
3037
3053
|
if (!n) return e;
|
|
3038
|
-
let r =
|
|
3054
|
+
let r = Ai(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
|
|
3039
3055
|
if (!a) return e;
|
|
3040
|
-
let o = e.indexOf(a[0]) + a[0].length, s =
|
|
3056
|
+
let o = e.indexOf(a[0]) + a[0].length, s = ki(e, o - 1);
|
|
3041
3057
|
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);
|
|
3042
3058
|
}
|
|
3043
|
-
function
|
|
3059
|
+
function ki(e, t) {
|
|
3044
3060
|
let n = 0;
|
|
3045
3061
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3046
3062
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3047
3063
|
return -1;
|
|
3048
3064
|
}
|
|
3049
|
-
function
|
|
3065
|
+
function Ai(e) {
|
|
3050
3066
|
let t = [];
|
|
3051
3067
|
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) {
|
|
3052
3068
|
t.push(" items: [");
|
|
@@ -3062,14 +3078,14 @@ function Ei(e) {
|
|
|
3062
3078
|
} else t.push(" items: [],");
|
|
3063
3079
|
return t.push(" },"), t.join("\n");
|
|
3064
3080
|
}
|
|
3065
|
-
async function
|
|
3066
|
-
let r =
|
|
3067
|
-
if (!await
|
|
3081
|
+
async function ji(e, t, n) {
|
|
3082
|
+
let r = Z("{{backend.features}}", t), i = T.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
|
|
3083
|
+
if (!await Y(i)) return;
|
|
3068
3084
|
let a = await y.readFile(i, "utf-8");
|
|
3069
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
3085
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = Mi(a, t), a = Ni(a, t));
|
|
3070
3086
|
await y.writeFile(i, a, "utf-8");
|
|
3071
3087
|
}
|
|
3072
|
-
function
|
|
3088
|
+
function Mi(e, t) {
|
|
3073
3089
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
3074
3090
|
if (r !== -1) {
|
|
3075
3091
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -3077,38 +3093,38 @@ function Oi(e, t) {
|
|
|
3077
3093
|
}
|
|
3078
3094
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
3079
3095
|
}
|
|
3080
|
-
function
|
|
3096
|
+
function Ni(e, t) {
|
|
3081
3097
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
3082
3098
|
if (!r) return e;
|
|
3083
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
3099
|
+
let i = e.indexOf(r[0]) + r[0].length, a = Pi(e, i - 1);
|
|
3084
3100
|
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);
|
|
3085
3101
|
}
|
|
3086
|
-
function
|
|
3102
|
+
function Pi(e, t) {
|
|
3087
3103
|
let n = 0;
|
|
3088
3104
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3089
3105
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3090
3106
|
return -1;
|
|
3091
3107
|
}
|
|
3092
|
-
var
|
|
3093
|
-
async function
|
|
3094
|
-
await
|
|
3108
|
+
var Fi = "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";
|
|
3109
|
+
async function Ii(e) {
|
|
3110
|
+
await Ri({
|
|
3095
3111
|
...e,
|
|
3096
3112
|
arrayName: "navbarActions"
|
|
3097
3113
|
});
|
|
3098
3114
|
}
|
|
3099
|
-
async function
|
|
3100
|
-
await
|
|
3115
|
+
async function Li(e) {
|
|
3116
|
+
await Ri({
|
|
3101
3117
|
...e,
|
|
3102
3118
|
arrayName: "userMenuActions"
|
|
3103
3119
|
});
|
|
3104
3120
|
}
|
|
3105
|
-
async function
|
|
3106
|
-
let a =
|
|
3107
|
-
await
|
|
3108
|
-
for (let n of e) s =
|
|
3121
|
+
async function Ri({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
|
|
3122
|
+
let a = Jr(i, n), o = T.resolve(r, a, "src/constants/navbar-actions.tsx"), s;
|
|
3123
|
+
await Y(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = Fi);
|
|
3124
|
+
for (let n of e) s = zi(s, n), s = Bi(s, n, t);
|
|
3109
3125
|
await y.writeFile(o, s, "utf-8");
|
|
3110
3126
|
}
|
|
3111
|
-
function
|
|
3127
|
+
function zi(e, t) {
|
|
3112
3128
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
3113
3129
|
if (e.includes(n)) return e;
|
|
3114
3130
|
let r = e.lastIndexOf("import ");
|
|
@@ -3116,38 +3132,38 @@ function Fi(e, t) {
|
|
|
3116
3132
|
let i = e.indexOf("\n", r);
|
|
3117
3133
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
3118
3134
|
}
|
|
3119
|
-
function
|
|
3135
|
+
function Bi(e, t, n) {
|
|
3120
3136
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
3121
3137
|
if (!r) return e;
|
|
3122
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
3138
|
+
let i = e.indexOf(r[0]) + r[0].length, a = Vi(e, i - 1);
|
|
3123
3139
|
if (a === -1) return e;
|
|
3124
3140
|
let o = e.slice(i, a);
|
|
3125
3141
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
3126
3142
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
3127
3143
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
3128
3144
|
}
|
|
3129
|
-
function
|
|
3145
|
+
function Vi(e, t) {
|
|
3130
3146
|
let n = 0;
|
|
3131
3147
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3132
3148
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3133
3149
|
return -1;
|
|
3134
3150
|
}
|
|
3135
|
-
var
|
|
3151
|
+
var Hi = new Set([
|
|
3136
3152
|
".ts",
|
|
3137
3153
|
".tsx",
|
|
3138
3154
|
".js",
|
|
3139
3155
|
".jsx"
|
|
3140
3156
|
]);
|
|
3141
|
-
async function
|
|
3157
|
+
async function Ui(e) {
|
|
3142
3158
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
3143
3159
|
if (i === "hype-stack") return;
|
|
3144
3160
|
let a = `@${i}/`;
|
|
3145
3161
|
await Promise.all(t.map(async (e) => {
|
|
3146
|
-
let t =
|
|
3147
|
-
i?.isDirectory() ? await
|
|
3162
|
+
let t = Br(e.target, n, r), i = await y.stat(t).catch(() => null);
|
|
3163
|
+
i?.isDirectory() ? await Ki(t, a) : i?.isFile() && Hi.has(T.extname(t)) && await qi(t, a);
|
|
3148
3164
|
}));
|
|
3149
3165
|
}
|
|
3150
|
-
var
|
|
3166
|
+
var Wi = new Set([
|
|
3151
3167
|
".git",
|
|
3152
3168
|
"node_modules",
|
|
3153
3169
|
"dist",
|
|
@@ -3156,43 +3172,43 @@ var Bi = new Set([
|
|
|
3156
3172
|
".next",
|
|
3157
3173
|
"coverage"
|
|
3158
3174
|
]);
|
|
3159
|
-
async function
|
|
3160
|
-
t !== "hype-stack" && await
|
|
3175
|
+
async function Gi(e, t) {
|
|
3176
|
+
t !== "hype-stack" && await Ki(e, `@${t}/`);
|
|
3161
3177
|
}
|
|
3162
|
-
async function
|
|
3178
|
+
async function Ki(e, t) {
|
|
3163
3179
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3164
3180
|
await Promise.all(n.map(async (n) => {
|
|
3165
3181
|
let r = T.join(e, n.name);
|
|
3166
3182
|
if (n.isDirectory()) {
|
|
3167
|
-
if (
|
|
3168
|
-
await
|
|
3169
|
-
} else n.isFile() &&
|
|
3183
|
+
if (Wi.has(n.name)) return;
|
|
3184
|
+
await Ki(r, t);
|
|
3185
|
+
} else n.isFile() && Hi.has(T.extname(n.name)) && await qi(r, t);
|
|
3170
3186
|
}));
|
|
3171
3187
|
}
|
|
3172
|
-
async function
|
|
3188
|
+
async function qi(e, t) {
|
|
3173
3189
|
let n = await y.readFile(e, "utf-8");
|
|
3174
|
-
if (!n.includes(
|
|
3175
|
-
let r =
|
|
3190
|
+
if (!n.includes(Gr)) return;
|
|
3191
|
+
let r = qr(n, t);
|
|
3176
3192
|
r !== n && await y.writeFile(e, r, "utf-8");
|
|
3177
3193
|
}
|
|
3178
3194
|
//#endregion
|
|
3179
3195
|
//#region src/core/installer.ts
|
|
3180
|
-
function
|
|
3196
|
+
function Ji(e, t) {
|
|
3181
3197
|
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3182
3198
|
}
|
|
3183
|
-
async function
|
|
3199
|
+
async function Yi(e, t) {
|
|
3184
3200
|
if ((await y.stat(e)).isDirectory()) {
|
|
3185
3201
|
await y.mkdir(t, { recursive: !0 });
|
|
3186
3202
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3187
|
-
for (let r of n) await
|
|
3203
|
+
for (let r of n) await Yi(T.join(e, r.name), T.join(t, r.name));
|
|
3188
3204
|
} else await y.mkdir(T.dirname(t), { recursive: !0 }), await y.copyFile(e, t);
|
|
3189
3205
|
}
|
|
3190
|
-
async function
|
|
3206
|
+
async function Xi(e) {
|
|
3191
3207
|
let { src: t, dest: n, projectRoot: r, skip: i } = e;
|
|
3192
3208
|
if ((await y.stat(t)).isDirectory()) {
|
|
3193
3209
|
await y.mkdir(n, { recursive: !0 });
|
|
3194
3210
|
let e = await y.readdir(t, { withFileTypes: !0 });
|
|
3195
|
-
return (await Promise.all(e.map((e) =>
|
|
3211
|
+
return (await Promise.all(e.map((e) => Xi({
|
|
3196
3212
|
src: T.join(t, e.name),
|
|
3197
3213
|
dest: T.join(n, e.name),
|
|
3198
3214
|
projectRoot: r,
|
|
@@ -3201,17 +3217,17 @@ async function Ki(e) {
|
|
|
3201
3217
|
}
|
|
3202
3218
|
return i.has(t) ? [] : (await y.mkdir(T.dirname(n), { recursive: !0 }), await y.copyFile(t, n), [T.relative(r, n)]);
|
|
3203
3219
|
}
|
|
3204
|
-
async function
|
|
3205
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a =
|
|
3220
|
+
async function Zi(e) {
|
|
3221
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = Vr(t.source, n), o = Br(t.target, r, i);
|
|
3206
3222
|
return {
|
|
3207
3223
|
sourcePath: a,
|
|
3208
3224
|
targetPath: o,
|
|
3209
|
-
sourceExists: await
|
|
3210
|
-
targetExists: await
|
|
3225
|
+
sourceExists: await Y(a) || await lr(a),
|
|
3226
|
+
targetExists: await Y(o) || await lr(o)
|
|
3211
3227
|
};
|
|
3212
3228
|
}
|
|
3213
|
-
async function
|
|
3214
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await
|
|
3229
|
+
async function Qi(e) {
|
|
3230
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await Zi({
|
|
3215
3231
|
file: t,
|
|
3216
3232
|
packDir: n,
|
|
3217
3233
|
paths: r,
|
|
@@ -3226,8 +3242,8 @@ async function Ji(e) {
|
|
|
3226
3242
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3227
3243
|
}
|
|
3228
3244
|
}
|
|
3229
|
-
async function
|
|
3230
|
-
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await
|
|
3245
|
+
async function $i(e) {
|
|
3246
|
+
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await Zi({
|
|
3231
3247
|
file: t,
|
|
3232
3248
|
packDir: n,
|
|
3233
3249
|
paths: r,
|
|
@@ -3245,7 +3261,7 @@ async function Yi(e) {
|
|
|
3245
3261
|
status: "skipped",
|
|
3246
3262
|
path: t.target,
|
|
3247
3263
|
reason: "Already exists"
|
|
3248
|
-
} : (await
|
|
3264
|
+
} : (await Yi(s, c), {
|
|
3249
3265
|
status: "installed",
|
|
3250
3266
|
path: t.target
|
|
3251
3267
|
});
|
|
@@ -3254,16 +3270,16 @@ async function Yi(e) {
|
|
|
3254
3270
|
status: "skipped",
|
|
3255
3271
|
path: t.target,
|
|
3256
3272
|
reason: "Already exists (skip-if-exists)"
|
|
3257
|
-
} : (await
|
|
3273
|
+
} : (await Yi(s, c), {
|
|
3258
3274
|
status: "installed",
|
|
3259
3275
|
path: t.target
|
|
3260
3276
|
});
|
|
3261
|
-
case "override": return await
|
|
3277
|
+
case "override": return await Yi(s, c), {
|
|
3262
3278
|
status: "installed",
|
|
3263
3279
|
path: t.target
|
|
3264
3280
|
};
|
|
3265
3281
|
case "merge": {
|
|
3266
|
-
if (!u) return await
|
|
3282
|
+
if (!u) return await Yi(s, c), {
|
|
3267
3283
|
status: "installed",
|
|
3268
3284
|
path: t.target
|
|
3269
3285
|
};
|
|
@@ -3293,15 +3309,15 @@ async function Yi(e) {
|
|
|
3293
3309
|
};
|
|
3294
3310
|
}
|
|
3295
3311
|
}
|
|
3296
|
-
async function
|
|
3312
|
+
async function ea(e) {
|
|
3297
3313
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3298
3314
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3299
3315
|
let o = [], s = /* @__PURE__ */ new Set();
|
|
3300
3316
|
for (let e of t) {
|
|
3301
3317
|
let t = i?.get(e.manifest.name);
|
|
3302
3318
|
for (let n of e.manifest.files) {
|
|
3303
|
-
if (n.strategy !== "create" || !
|
|
3304
|
-
let { targetPath: i, targetExists: c } = await
|
|
3319
|
+
if (n.strategy !== "create" || !Ji(n, t)) continue;
|
|
3320
|
+
let { targetPath: i, targetExists: c } = await Zi({
|
|
3305
3321
|
file: n,
|
|
3306
3322
|
packDir: e.packDir,
|
|
3307
3323
|
paths: a,
|
|
@@ -3316,13 +3332,13 @@ async function Xi(e) {
|
|
|
3316
3332
|
}
|
|
3317
3333
|
return o;
|
|
3318
3334
|
}
|
|
3319
|
-
async function
|
|
3335
|
+
async function ta(e) {
|
|
3320
3336
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3321
3337
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3322
3338
|
let c = [];
|
|
3323
3339
|
for (let e of t.files) {
|
|
3324
|
-
if (!
|
|
3325
|
-
let t = await
|
|
3340
|
+
if (!Ji(e, o)) continue;
|
|
3341
|
+
let t = await Qi({
|
|
3326
3342
|
file: e,
|
|
3327
3343
|
packDir: a,
|
|
3328
3344
|
paths: s,
|
|
@@ -3333,16 +3349,16 @@ async function Zi(e) {
|
|
|
3333
3349
|
}
|
|
3334
3350
|
return c;
|
|
3335
3351
|
}
|
|
3336
|
-
async function
|
|
3352
|
+
async function na(e) {
|
|
3337
3353
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3338
3354
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3339
3355
|
let l = {
|
|
3340
3356
|
installed: [],
|
|
3341
3357
|
skipped: [],
|
|
3342
3358
|
errors: []
|
|
3343
|
-
}, u = t.files.filter((e) =>
|
|
3359
|
+
}, u = t.files.filter((e) => Ji(e, s));
|
|
3344
3360
|
for (let e of u) {
|
|
3345
|
-
let t = await
|
|
3361
|
+
let t = await $i({
|
|
3346
3362
|
file: e,
|
|
3347
3363
|
packDir: o,
|
|
3348
3364
|
paths: c,
|
|
@@ -3362,40 +3378,40 @@ async function Qi(e) {
|
|
|
3362
3378
|
break;
|
|
3363
3379
|
}
|
|
3364
3380
|
}
|
|
3365
|
-
await
|
|
3381
|
+
await Ui({
|
|
3366
3382
|
files: u,
|
|
3367
3383
|
paths: c,
|
|
3368
3384
|
projectRoot: r,
|
|
3369
3385
|
projectName: n.name
|
|
3370
|
-
}), t.env && t.env.length > 0 && await
|
|
3386
|
+
}), t.env && t.env.length > 0 && await Yr(t.env, c, r), t.routes && t.routes.length > 0 && await ti(t.routes, c, r), t.context && t.context.length > 0 && await ii(t.context, c, r), t.sockets && t.sockets.length > 0 && await fi(t.sockets, c, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await gi(t.sdkConfigurations, c, r), t.enums && t.enums.length > 0 && await ui(t.enums, c, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await yi(t.frontendRoutes, c, r);
|
|
3371
3387
|
let d = s && s.length > 0 ? s : ["frontend"];
|
|
3372
|
-
for (let e of d) t.nav && t.nav.length > 0 && await
|
|
3388
|
+
for (let e of d) t.nav && t.nav.length > 0 && await Ci({
|
|
3373
3389
|
entries: t.nav,
|
|
3374
3390
|
paths: c,
|
|
3375
3391
|
projectRoot: r,
|
|
3376
3392
|
slot: e
|
|
3377
|
-
}), t.navbarActions && t.navbarActions.length > 0 && await
|
|
3393
|
+
}), t.navbarActions && t.navbarActions.length > 0 && await Ii({
|
|
3378
3394
|
actions: t.navbarActions,
|
|
3379
3395
|
paths: c,
|
|
3380
3396
|
projectRoot: r,
|
|
3381
3397
|
slot: e
|
|
3382
|
-
}), t.userMenuActions && t.userMenuActions.length > 0 && await
|
|
3398
|
+
}), t.userMenuActions && t.userMenuActions.length > 0 && await Li({
|
|
3383
3399
|
actions: t.userMenuActions,
|
|
3384
3400
|
paths: c,
|
|
3385
3401
|
projectRoot: r,
|
|
3386
3402
|
slot: e
|
|
3387
3403
|
});
|
|
3388
|
-
return t.onboardingSteps && t.onboardingSteps.length > 0 && await
|
|
3404
|
+
return t.onboardingSteps && t.onboardingSteps.length > 0 && await ji(t.onboardingSteps, c, r), t.postLoginRedirect && await wi({
|
|
3389
3405
|
postLoginRedirect: t.postLoginRedirect,
|
|
3390
3406
|
paths: c,
|
|
3391
3407
|
projectRoot: r,
|
|
3392
3408
|
slot: d[0]
|
|
3393
3409
|
}), l;
|
|
3394
3410
|
}
|
|
3395
|
-
async function
|
|
3411
|
+
async function ra(e) {
|
|
3396
3412
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3397
3413
|
for (let e of t) {
|
|
3398
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3414
|
+
let t = o?.get(e.manifest.name), a = await ta({
|
|
3399
3415
|
manifest: e.manifest,
|
|
3400
3416
|
config: n,
|
|
3401
3417
|
projectRoot: r,
|
|
@@ -3415,7 +3431,7 @@ async function $i(e) {
|
|
|
3415
3431
|
};
|
|
3416
3432
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3417
3433
|
for (let e of t) {
|
|
3418
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3434
|
+
let t = o?.get(e.manifest.name), n = await na({
|
|
3419
3435
|
manifest: e.manifest,
|
|
3420
3436
|
config: f,
|
|
3421
3437
|
projectRoot: r,
|
|
@@ -3424,7 +3440,7 @@ async function $i(e) {
|
|
|
3424
3440
|
packDir: e.packDir,
|
|
3425
3441
|
slots: t
|
|
3426
3442
|
});
|
|
3427
|
-
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await
|
|
3443
|
+
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await ia(f, e.manifest, r), d.push(e.manifest.name);
|
|
3428
3444
|
}
|
|
3429
3445
|
return {
|
|
3430
3446
|
installed: c,
|
|
@@ -3435,8 +3451,8 @@ async function $i(e) {
|
|
|
3435
3451
|
config: f
|
|
3436
3452
|
};
|
|
3437
3453
|
}
|
|
3438
|
-
async function
|
|
3439
|
-
let r = typeof t == "string" ? t : t.name, i = typeof t == "string" ? [] :
|
|
3454
|
+
async function ia(e, t, n) {
|
|
3455
|
+
let r = typeof t == "string" ? t : t.name, i = typeof t == "string" ? [] : Dr(t.env), a = Or([...e.onboarding?.envSections ?? [], ...i]), o = {
|
|
3440
3456
|
...e,
|
|
3441
3457
|
installedPacks: [...e.installedPacks ?? [], r],
|
|
3442
3458
|
onboarding: {
|
|
@@ -3444,19 +3460,19 @@ async function ea(e, t, n) {
|
|
|
3444
3460
|
envSections: a
|
|
3445
3461
|
}
|
|
3446
3462
|
};
|
|
3447
|
-
return await
|
|
3463
|
+
return await Nr(n, o), o;
|
|
3448
3464
|
}
|
|
3449
|
-
async function
|
|
3465
|
+
async function aa(e) {
|
|
3450
3466
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3451
3467
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3452
|
-
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) =>
|
|
3453
|
-
if (await
|
|
3468
|
+
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) => Vr(e.source, i))), u = T.join(i, "files");
|
|
3469
|
+
if (await lr(u)) {
|
|
3454
3470
|
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3455
3471
|
for (let t of e) {
|
|
3456
3472
|
if (!t.isDirectory()) continue;
|
|
3457
3473
|
let e = a[t.name]?.root;
|
|
3458
3474
|
if (!e) continue;
|
|
3459
|
-
let n = await
|
|
3475
|
+
let n = await Xi({
|
|
3460
3476
|
src: T.join(u, t.name),
|
|
3461
3477
|
dest: T.resolve(r, e),
|
|
3462
3478
|
projectRoot: r,
|
|
@@ -3466,7 +3482,7 @@ async function ta(e) {
|
|
|
3466
3482
|
}
|
|
3467
3483
|
}
|
|
3468
3484
|
for (let e of c) {
|
|
3469
|
-
let t = await
|
|
3485
|
+
let t = await $i({
|
|
3470
3486
|
file: e,
|
|
3471
3487
|
packDir: i,
|
|
3472
3488
|
paths: a,
|
|
@@ -3476,12 +3492,12 @@ async function ta(e) {
|
|
|
3476
3492
|
});
|
|
3477
3493
|
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3478
3494
|
}
|
|
3479
|
-
let d = T.join(
|
|
3480
|
-
return await
|
|
3495
|
+
let d = T.join(Br("{{frontend.root}}", a, r), "src", "routes"), f = T.join(d, "(public)", "index.tsx"), p = T.join(d, "(private)", "index.tsx");
|
|
3496
|
+
return await Y(f) && await Y(p) && await y.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await yi(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await Ci({
|
|
3481
3497
|
entries: t.nav,
|
|
3482
3498
|
paths: a,
|
|
3483
3499
|
projectRoot: r
|
|
3484
|
-
}), t.postLoginRedirect && await
|
|
3500
|
+
}), t.postLoginRedirect && await wi({
|
|
3485
3501
|
postLoginRedirect: t.postLoginRedirect,
|
|
3486
3502
|
paths: a,
|
|
3487
3503
|
projectRoot: r
|
|
@@ -3492,32 +3508,32 @@ async function ta(e) {
|
|
|
3492
3508
|
}
|
|
3493
3509
|
//#endregion
|
|
3494
3510
|
//#region src/core/pack-categories.ts
|
|
3495
|
-
var
|
|
3511
|
+
var oa = [
|
|
3496
3512
|
"starter",
|
|
3497
3513
|
"layout",
|
|
3498
3514
|
"feature"
|
|
3499
|
-
],
|
|
3515
|
+
], sa = {
|
|
3500
3516
|
starter: "Starter",
|
|
3501
3517
|
layout: "Layout",
|
|
3502
3518
|
feature: "Features"
|
|
3503
|
-
},
|
|
3504
|
-
function
|
|
3519
|
+
}, ca = new Set(["starter", "layout"]), la = "starter-saas-betterauth", ua = "layout-basic";
|
|
3520
|
+
function da(e, t = {}) {
|
|
3505
3521
|
let n = [];
|
|
3506
|
-
for (let r of
|
|
3522
|
+
for (let r of oa) {
|
|
3507
3523
|
let i = e.filter((e) => e.category === r);
|
|
3508
3524
|
if (i.length === 0) continue;
|
|
3509
|
-
let a =
|
|
3525
|
+
let a = ca.has(r) ? "single" : "multiple";
|
|
3510
3526
|
if (r === "layout") {
|
|
3511
|
-
n.push(
|
|
3527
|
+
n.push(pa("frontend", i)), t.adminAvailable && n.push(pa("admin", i));
|
|
3512
3528
|
continue;
|
|
3513
3529
|
}
|
|
3514
3530
|
if (r === "starter") {
|
|
3515
|
-
n.push(
|
|
3531
|
+
n.push(fa(i));
|
|
3516
3532
|
continue;
|
|
3517
3533
|
}
|
|
3518
3534
|
n.push({
|
|
3519
3535
|
category: r,
|
|
3520
|
-
label:
|
|
3536
|
+
label: sa[r],
|
|
3521
3537
|
mode: a,
|
|
3522
3538
|
packs: i,
|
|
3523
3539
|
preselect: null
|
|
@@ -3525,70 +3541,57 @@ function sa(e, t = {}) {
|
|
|
3525
3541
|
}
|
|
3526
3542
|
return n;
|
|
3527
3543
|
}
|
|
3528
|
-
function
|
|
3529
|
-
let t = e.some((e) => e.name ===
|
|
3544
|
+
function fa(e) {
|
|
3545
|
+
let t = e.some((e) => e.name === la);
|
|
3530
3546
|
return {
|
|
3531
3547
|
category: "starter",
|
|
3532
|
-
label:
|
|
3548
|
+
label: sa.starter,
|
|
3533
3549
|
mode: "single",
|
|
3534
3550
|
packs: e,
|
|
3535
|
-
preselect: t ?
|
|
3551
|
+
preselect: t ? la : null
|
|
3536
3552
|
};
|
|
3537
3553
|
}
|
|
3538
|
-
function
|
|
3539
|
-
let n = t.some((e) => e.name ===
|
|
3554
|
+
function pa(e, t) {
|
|
3555
|
+
let n = t.some((e) => e.name === ua);
|
|
3540
3556
|
return {
|
|
3541
3557
|
category: "layout",
|
|
3542
3558
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3543
3559
|
mode: "single",
|
|
3544
3560
|
packs: t,
|
|
3545
|
-
preselect: n ?
|
|
3561
|
+
preselect: n ? ua : null,
|
|
3546
3562
|
slot: e
|
|
3547
3563
|
};
|
|
3548
3564
|
}
|
|
3549
3565
|
//#endregion
|
|
3550
|
-
//#region src/ui/logger.ts
|
|
3551
|
-
var ua = [he.orangeBright, he.skyBlue];
|
|
3552
|
-
function da(e) {
|
|
3553
|
-
let t = e.map((e, t) => {
|
|
3554
|
-
let n = ua[t % ua.length];
|
|
3555
|
-
return `${z.bold(n(`${t + 1}.`))} ${z.bold(e)}`;
|
|
3556
|
-
}).join("\n");
|
|
3557
|
-
s.note(t, "Next steps");
|
|
3558
|
-
}
|
|
3559
|
-
function Z() {
|
|
3560
|
-
s.cancel(z.muted("Operation cancelled.")), process.exit(0);
|
|
3561
|
-
}
|
|
3562
|
-
//#endregion
|
|
3563
3566
|
//#region src/core/post-setup.ts
|
|
3564
|
-
async function
|
|
3565
|
-
return (await
|
|
3567
|
+
async function ma() {
|
|
3568
|
+
return (await J("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3566
3569
|
}
|
|
3567
|
-
async function
|
|
3568
|
-
return
|
|
3570
|
+
async function ha(e) {
|
|
3571
|
+
return Y(`${e}/apps/backend/.env`);
|
|
3569
3572
|
}
|
|
3570
|
-
async function
|
|
3571
|
-
let r = n ? `Start services with ${
|
|
3573
|
+
async function ga(e, t, n) {
|
|
3574
|
+
let r = n ? `Start services with ${L.command("docker compose up -d")}?` : `Docker is not running. Start services with ${L.command("docker compose up -d")}?`, i = t ? !0 : await s.confirm({
|
|
3572
3575
|
message: r,
|
|
3573
3576
|
initialValue: !0
|
|
3574
3577
|
});
|
|
3575
|
-
if (s.isCancel(i) &&
|
|
3578
|
+
if (s.isCancel(i) && B(), !i) return s.log.info(L.muted("Skipping Docker services and database migrations.")), !1;
|
|
3576
3579
|
let a = s.spinner();
|
|
3577
3580
|
a.start("Starting Docker services...");
|
|
3578
|
-
let o = await
|
|
3581
|
+
let o = await J("docker", [
|
|
3579
3582
|
"compose",
|
|
3580
3583
|
"up",
|
|
3581
3584
|
"-d"
|
|
3582
3585
|
], { cwd: `${e}/apps/backend` });
|
|
3583
|
-
return o.exitCode === 0 ? (a.stop(
|
|
3586
|
+
return o.exitCode === 0 ? (a.stop(L.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), _a(o), !1);
|
|
3584
3587
|
}
|
|
3585
|
-
function
|
|
3588
|
+
function _a(e) {
|
|
3586
3589
|
let t = (e.stderr || e.stdout).trim();
|
|
3587
|
-
t && s.log.warn(
|
|
3590
|
+
t && s.log.warn(L.muted(t));
|
|
3588
3591
|
}
|
|
3589
|
-
async function
|
|
3592
|
+
async function va(e, t = 15, n = 2e3) {
|
|
3590
3593
|
for (let r = 0; r < t; r++) {
|
|
3591
|
-
if ((await
|
|
3594
|
+
if ((await J("docker", [
|
|
3592
3595
|
"compose",
|
|
3593
3596
|
"exec",
|
|
3594
3597
|
"-T",
|
|
@@ -3601,9 +3604,9 @@ async function ga(e, t = 15, n = 2e3) {
|
|
|
3601
3604
|
}
|
|
3602
3605
|
return !1;
|
|
3603
3606
|
}
|
|
3604
|
-
var
|
|
3605
|
-
async function
|
|
3606
|
-
let t = await
|
|
3607
|
+
var ya = "Database schema is up to date";
|
|
3608
|
+
async function ba(e) {
|
|
3609
|
+
let t = await J("pnpm", [
|
|
3607
3610
|
"--filter",
|
|
3608
3611
|
"@internal/backend",
|
|
3609
3612
|
"exec",
|
|
@@ -3611,48 +3614,48 @@ async function va(e) {
|
|
|
3611
3614
|
"migrate",
|
|
3612
3615
|
"status"
|
|
3613
3616
|
], { cwd: e });
|
|
3614
|
-
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(
|
|
3617
|
+
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(ya) : !1;
|
|
3615
3618
|
}
|
|
3616
|
-
async function
|
|
3619
|
+
async function xa(e) {
|
|
3617
3620
|
let t = s.spinner();
|
|
3618
3621
|
t.start("Running database migrations...");
|
|
3619
|
-
let n = await
|
|
3622
|
+
let n = await J("pnpm", [
|
|
3620
3623
|
"--filter",
|
|
3621
3624
|
"@internal/backend",
|
|
3622
3625
|
"migration:latest"
|
|
3623
3626
|
], { cwd: e });
|
|
3624
|
-
return n.exitCode === 0 ? (t.stop(
|
|
3627
|
+
return n.exitCode === 0 ? (t.stop(L.success("Database migrations applied")), !0) : (t.error("Migrations failed"), _a(n), s.log.warn(L.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations.")), !1);
|
|
3625
3628
|
}
|
|
3626
|
-
async function
|
|
3627
|
-
if (!await
|
|
3629
|
+
async function Sa(e, t, n = {}) {
|
|
3630
|
+
if (!await ga(e, t, await ma())) return !1;
|
|
3628
3631
|
let r = s.spinner();
|
|
3629
|
-
return r.start("Waiting for Postgres to be ready..."), await
|
|
3632
|
+
return r.start("Waiting for Postgres to be ready..."), await va(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3) ? (r.stop(L.success("Postgres is ready")), !0) : (r.error("Postgres health check timed out"), s.log.warn(L.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest")), !1);
|
|
3630
3633
|
}
|
|
3631
|
-
async function
|
|
3632
|
-
if (!await
|
|
3634
|
+
async function Ca(e, t, n = {}) {
|
|
3635
|
+
if (!await Sa(e, t, n)) return;
|
|
3633
3636
|
let r = t ? !0 : await s.confirm({
|
|
3634
|
-
message: `Run database migrations with ${
|
|
3637
|
+
message: `Run database migrations with ${L.command("prisma migrate deploy")}?`,
|
|
3635
3638
|
initialValue: !0
|
|
3636
3639
|
});
|
|
3637
|
-
if (s.isCancel(r) &&
|
|
3638
|
-
s.log.info(
|
|
3640
|
+
if (s.isCancel(r) && B(), !r) {
|
|
3641
|
+
s.log.info(L.muted("Skipping database migrations."));
|
|
3639
3642
|
return;
|
|
3640
3643
|
}
|
|
3641
|
-
await
|
|
3644
|
+
await xa(e);
|
|
3642
3645
|
}
|
|
3643
|
-
async function
|
|
3644
|
-
if (!await
|
|
3645
|
-
s.log.warn(`${
|
|
3646
|
+
async function wa(e, t, n = {}) {
|
|
3647
|
+
if (!await ha(e)) {
|
|
3648
|
+
s.log.warn(`${L.path(".env")} not found in ${L.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3646
3649
|
return;
|
|
3647
3650
|
}
|
|
3648
|
-
await
|
|
3651
|
+
await Ca(e, t, n);
|
|
3649
3652
|
}
|
|
3650
|
-
async function
|
|
3651
|
-
return await
|
|
3653
|
+
async function Ta(e, t, n = {}) {
|
|
3654
|
+
return await ha(e) ? Sa(e, t, n) : (s.log.warn(`${L.path(".env")} not found in ${L.path("apps/backend")}. Skipping Docker - configure it first.`), !1);
|
|
3652
3655
|
}
|
|
3653
3656
|
//#endregion
|
|
3654
3657
|
//#region src/core/resolve.ts
|
|
3655
|
-
function
|
|
3658
|
+
function Ea(e) {
|
|
3656
3659
|
let t = /* @__PURE__ */ new Map();
|
|
3657
3660
|
for (let n of e) t.set(n.name, {
|
|
3658
3661
|
name: n.name,
|
|
@@ -3660,7 +3663,7 @@ function wa(e) {
|
|
|
3660
3663
|
});
|
|
3661
3664
|
return t;
|
|
3662
3665
|
}
|
|
3663
|
-
function
|
|
3666
|
+
function Da(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3664
3667
|
let r = /* @__PURE__ */ new Set();
|
|
3665
3668
|
function i(e) {
|
|
3666
3669
|
if (n.has(e)) return [];
|
|
@@ -3674,10 +3677,10 @@ function Ta(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3674
3677
|
}
|
|
3675
3678
|
return i(e);
|
|
3676
3679
|
}
|
|
3677
|
-
function
|
|
3680
|
+
function Oa(e, t, n = []) {
|
|
3678
3681
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3679
3682
|
for (let n of e) {
|
|
3680
|
-
let e =
|
|
3683
|
+
let e = Da(n, t, new Set(i));
|
|
3681
3684
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3682
3685
|
}
|
|
3683
3686
|
return {
|
|
@@ -3685,7 +3688,7 @@ function Ea(e, t, n = []) {
|
|
|
3685
3688
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3686
3689
|
};
|
|
3687
3690
|
}
|
|
3688
|
-
function
|
|
3691
|
+
function ka(e) {
|
|
3689
3692
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3690
3693
|
for (let e of t) {
|
|
3691
3694
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3698,7 +3701,7 @@ function Da(e) {
|
|
|
3698
3701
|
}
|
|
3699
3702
|
//#endregion
|
|
3700
3703
|
//#region src/core/variants.ts
|
|
3701
|
-
function
|
|
3704
|
+
function Aa(e, t = {}) {
|
|
3702
3705
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3703
3706
|
for (let i of e) {
|
|
3704
3707
|
let e = t[i.family] ?? i.default;
|
|
@@ -3710,14 +3713,14 @@ function Oa(e, t = {}) {
|
|
|
3710
3713
|
familyOf: r
|
|
3711
3714
|
};
|
|
3712
3715
|
}
|
|
3713
|
-
function
|
|
3716
|
+
function ja(e, t, n) {
|
|
3714
3717
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3715
3718
|
}
|
|
3716
|
-
function
|
|
3719
|
+
function Ma(e, t) {
|
|
3717
3720
|
let n = t.familyOf.get(e);
|
|
3718
3721
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3719
3722
|
}
|
|
3720
|
-
function
|
|
3723
|
+
function Na(e, t) {
|
|
3721
3724
|
let n = /* @__PURE__ */ new Map();
|
|
3722
3725
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3723
3726
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3733,65 +3736,65 @@ function ja(e, t) {
|
|
|
3733
3736
|
familyOf: n
|
|
3734
3737
|
};
|
|
3735
3738
|
}
|
|
3736
|
-
function
|
|
3739
|
+
function Pa(e, t) {
|
|
3737
3740
|
return e.map((e) => ({
|
|
3738
3741
|
...e,
|
|
3739
|
-
dependencies: e.dependencies.map((e) =>
|
|
3742
|
+
dependencies: e.dependencies.map((e) => Ma(e, t))
|
|
3740
3743
|
}));
|
|
3741
3744
|
}
|
|
3742
3745
|
//#endregion
|
|
3743
3746
|
//#region src/ui/banner.ts
|
|
3744
|
-
var
|
|
3747
|
+
var Fa = [
|
|
3745
3748
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3746
3749
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3747
3750
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3748
3751
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3749
3752
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3750
3753
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3751
|
-
],
|
|
3754
|
+
], Ia = [
|
|
3752
3755
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3753
3756
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3754
3757
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3755
3758
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3756
3759
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3757
3760
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3758
|
-
],
|
|
3761
|
+
], La = [
|
|
3759
3762
|
253,
|
|
3760
3763
|
176,
|
|
3761
3764
|
21
|
|
3762
|
-
],
|
|
3765
|
+
], Ra = [
|
|
3763
3766
|
245,
|
|
3764
3767
|
76,
|
|
3765
3768
|
2
|
|
3766
|
-
],
|
|
3769
|
+
], za = 5, Ba = [
|
|
3767
3770
|
17,
|
|
3768
3771
|
103,
|
|
3769
3772
|
248
|
|
3770
|
-
],
|
|
3773
|
+
], Va = [
|
|
3771
3774
|
42,
|
|
3772
3775
|
160,
|
|
3773
3776
|
250
|
|
3774
|
-
],
|
|
3775
|
-
function
|
|
3777
|
+
], Ha = .2;
|
|
3778
|
+
function Ua() {
|
|
3776
3779
|
console.log();
|
|
3777
|
-
for (let e of
|
|
3778
|
-
start:
|
|
3779
|
-
end:
|
|
3780
|
-
angle:
|
|
3780
|
+
for (let e of Se(Fa, {
|
|
3781
|
+
start: La,
|
|
3782
|
+
end: Ra,
|
|
3783
|
+
angle: za
|
|
3781
3784
|
})) console.log(b.bold(e));
|
|
3782
|
-
for (let e of
|
|
3783
|
-
start:
|
|
3784
|
-
end:
|
|
3785
|
-
angle:
|
|
3785
|
+
for (let e of Se(Ia, {
|
|
3786
|
+
start: Ba,
|
|
3787
|
+
end: Va,
|
|
3788
|
+
angle: Ha
|
|
3786
3789
|
})) console.log(b.bold(e));
|
|
3787
|
-
console.log(), console.log(` ${
|
|
3790
|
+
console.log(), console.log(` ${R.spark} ${b.dim("v" + A)} ${b.dim("·")} ${be("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3788
3791
|
}
|
|
3789
|
-
function
|
|
3790
|
-
console.log(), console.log(` ${
|
|
3792
|
+
function Wa() {
|
|
3793
|
+
console.log(), console.log(` ${R.bolt} ${_e.orange("Hype")}${_e.skyBlue("Stack")} ${b.dim("v" + A)}`), console.log();
|
|
3791
3794
|
}
|
|
3792
3795
|
//#endregion
|
|
3793
3796
|
//#region src/ui/pack-multiselect.ts
|
|
3794
|
-
var
|
|
3797
|
+
var Ga = class extends O {
|
|
3795
3798
|
options;
|
|
3796
3799
|
cursor = 0;
|
|
3797
3800
|
selected;
|
|
@@ -3895,44 +3898,44 @@ var Ua = class extends O {
|
|
|
3895
3898
|
}
|
|
3896
3899
|
}
|
|
3897
3900
|
};
|
|
3898
|
-
function
|
|
3899
|
-
return new
|
|
3901
|
+
function Ka(e) {
|
|
3902
|
+
return new Ga(e).prompt();
|
|
3900
3903
|
}
|
|
3901
3904
|
//#endregion
|
|
3902
3905
|
//#region src/utils/naming.ts
|
|
3903
|
-
function
|
|
3906
|
+
function qa(e) {
|
|
3904
3907
|
return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3905
3908
|
}
|
|
3906
|
-
function
|
|
3909
|
+
function Ja(e) {
|
|
3907
3910
|
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3908
3911
|
}
|
|
3909
3912
|
//#endregion
|
|
3910
3913
|
//#region src/utils/validate.ts
|
|
3911
|
-
function
|
|
3914
|
+
function Ya(e) {
|
|
3912
3915
|
if (!e.trim()) return "Project name cannot be empty";
|
|
3913
3916
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
3914
|
-
let t =
|
|
3915
|
-
if (!
|
|
3917
|
+
let t = qa(e);
|
|
3918
|
+
if (!ie.test(t)) return "Project name must contain at least one letter or number";
|
|
3916
3919
|
}
|
|
3917
3920
|
//#endregion
|
|
3918
3921
|
//#region src/core/apply-mode.ts
|
|
3919
|
-
var
|
|
3920
|
-
function
|
|
3921
|
-
return e.replace(
|
|
3922
|
+
var Xa = "src/hooks/use-theme.ts", Za = /(\bexport\s+const\s+defaultTheme\s*=\s*)(["'])(?:light|dark)\2/;
|
|
3923
|
+
function Qa(e, t) {
|
|
3924
|
+
return e.replace(Za, (e, n, r) => `${n}${r}${t}${r}`);
|
|
3922
3925
|
}
|
|
3923
|
-
async function
|
|
3924
|
-
let n = T.resolve(e,
|
|
3926
|
+
async function $a(e, t) {
|
|
3927
|
+
let n = T.resolve(e, Xa), r;
|
|
3925
3928
|
try {
|
|
3926
3929
|
r = await y.readFile(n, "utf-8");
|
|
3927
3930
|
} catch {
|
|
3928
3931
|
return !1;
|
|
3929
3932
|
}
|
|
3930
|
-
let i =
|
|
3933
|
+
let i = Qa(r, t);
|
|
3931
3934
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3932
3935
|
}
|
|
3933
3936
|
//#endregion
|
|
3934
3937
|
//#region src/core/apply-theme.ts
|
|
3935
|
-
function
|
|
3938
|
+
function eo(e, t) {
|
|
3936
3939
|
let n = 0;
|
|
3937
3940
|
for (; n < e.length;) {
|
|
3938
3941
|
let r = e.indexOf(t, n);
|
|
@@ -3955,46 +3958,46 @@ function Qa(e, t) {
|
|
|
3955
3958
|
}
|
|
3956
3959
|
return null;
|
|
3957
3960
|
}
|
|
3958
|
-
function
|
|
3961
|
+
function to(e, t) {
|
|
3959
3962
|
let n = e;
|
|
3960
3963
|
for (let [e, r] of Object.entries(t)) {
|
|
3961
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3964
|
+
let t = RegExp(`(^[ \\t]*--${no(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3962
3965
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3963
3966
|
}
|
|
3964
3967
|
return n;
|
|
3965
3968
|
}
|
|
3966
|
-
function
|
|
3969
|
+
function no(e) {
|
|
3967
3970
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3968
3971
|
}
|
|
3969
|
-
function
|
|
3970
|
-
let n =
|
|
3972
|
+
function ro(e, t) {
|
|
3973
|
+
let n = eo(e, ":root"), r = eo(e, ".dark"), i = e;
|
|
3971
3974
|
if (n) {
|
|
3972
3975
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3973
|
-
i = e +
|
|
3976
|
+
i = e + to(r, t.light) + a;
|
|
3974
3977
|
}
|
|
3975
3978
|
if (r) {
|
|
3976
|
-
let e =
|
|
3979
|
+
let e = eo(i, ".dark");
|
|
3977
3980
|
if (e) {
|
|
3978
3981
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3979
|
-
i = n +
|
|
3982
|
+
i = n + to(r, t.dark) + a;
|
|
3980
3983
|
}
|
|
3981
3984
|
}
|
|
3982
3985
|
return i;
|
|
3983
3986
|
}
|
|
3984
|
-
var
|
|
3985
|
-
async function
|
|
3986
|
-
let n = T.resolve(e,
|
|
3987
|
+
var io = "assets/styles.css";
|
|
3988
|
+
async function ao(e, t) {
|
|
3989
|
+
let n = T.resolve(e, io), r;
|
|
3987
3990
|
try {
|
|
3988
3991
|
r = await y.readFile(n, "utf-8");
|
|
3989
3992
|
} catch {
|
|
3990
3993
|
return !1;
|
|
3991
3994
|
}
|
|
3992
|
-
let i =
|
|
3995
|
+
let i = ro(r, t);
|
|
3993
3996
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3994
3997
|
}
|
|
3995
3998
|
//#endregion
|
|
3996
3999
|
//#region src/core/clone.ts
|
|
3997
|
-
async function
|
|
4000
|
+
async function oo(e) {
|
|
3998
4001
|
let t = await ee(te, {
|
|
3999
4002
|
dir: e,
|
|
4000
4003
|
force: !0
|
|
@@ -4006,7 +4009,7 @@ async function io(e) {
|
|
|
4006
4009
|
}
|
|
4007
4010
|
//#endregion
|
|
4008
4011
|
//#region src/core/editor-config.ts
|
|
4009
|
-
function
|
|
4012
|
+
function so(e) {
|
|
4010
4013
|
let t = {
|
|
4011
4014
|
globs: [],
|
|
4012
4015
|
alwaysApply: !1
|
|
@@ -4041,10 +4044,10 @@ function ao(e) {
|
|
|
4041
4044
|
content: i
|
|
4042
4045
|
};
|
|
4043
4046
|
}
|
|
4044
|
-
function
|
|
4047
|
+
function co(e) {
|
|
4045
4048
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
4046
4049
|
}
|
|
4047
|
-
function
|
|
4050
|
+
function lo(e) {
|
|
4048
4051
|
let t;
|
|
4049
4052
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
4050
4053
|
let n = [`trigger: ${t}`];
|
|
@@ -4054,30 +4057,30 @@ function so(e) {
|
|
|
4054
4057
|
}
|
|
4055
4058
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
4056
4059
|
}
|
|
4057
|
-
function
|
|
4060
|
+
function uo(e) {
|
|
4058
4061
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
4059
4062
|
}
|
|
4060
|
-
var
|
|
4063
|
+
var fo = {
|
|
4061
4064
|
claude: {
|
|
4062
4065
|
rulesDir: ".claude/rules",
|
|
4063
4066
|
extension: ".md",
|
|
4064
|
-
convert:
|
|
4067
|
+
convert: co
|
|
4065
4068
|
},
|
|
4066
4069
|
windsurf: {
|
|
4067
4070
|
rulesDir: ".windsurf/rules",
|
|
4068
4071
|
extension: ".md",
|
|
4069
|
-
convert:
|
|
4072
|
+
convert: lo
|
|
4070
4073
|
},
|
|
4071
4074
|
copilot: {
|
|
4072
4075
|
rulesDir: ".github/instructions",
|
|
4073
4076
|
extension: ".instructions.md",
|
|
4074
|
-
convert:
|
|
4077
|
+
convert: uo
|
|
4075
4078
|
}
|
|
4076
4079
|
};
|
|
4077
|
-
async function
|
|
4078
|
-
let t = T.join(e,
|
|
4080
|
+
async function po(e) {
|
|
4081
|
+
let t = T.join(e, oe), n = (await y.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
4079
4082
|
return await Promise.all(n.map(async (e) => {
|
|
4080
|
-
let n = T.join(t, e.name), { frontmatter: r, content: i } =
|
|
4083
|
+
let n = T.join(t, e.name), { frontmatter: r, content: i } = so(await y.readFile(n, "utf-8"));
|
|
4081
4084
|
return {
|
|
4082
4085
|
frontmatter: r,
|
|
4083
4086
|
content: i,
|
|
@@ -4085,44 +4088,44 @@ async function uo(e) {
|
|
|
4085
4088
|
};
|
|
4086
4089
|
}));
|
|
4087
4090
|
}
|
|
4088
|
-
async function
|
|
4091
|
+
async function mo(e, t) {
|
|
4089
4092
|
if (t === "cursor") return;
|
|
4090
|
-
let n =
|
|
4093
|
+
let n = fo[t], r = await po(e), i = T.join(e, n.rulesDir);
|
|
4091
4094
|
await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
4092
4095
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
4093
4096
|
return y.writeFile(T.join(i, r), t, "utf-8");
|
|
4094
|
-
})), await
|
|
4097
|
+
})), await mr(T.join(e, se)), await mr(T.join(e, ce));
|
|
4095
4098
|
}
|
|
4096
4099
|
//#endregion
|
|
4097
4100
|
//#region src/core/env-files.ts
|
|
4098
|
-
var
|
|
4101
|
+
var ho = [
|
|
4099
4102
|
"apps",
|
|
4100
4103
|
"packages",
|
|
4101
4104
|
"libs",
|
|
4102
4105
|
"shared"
|
|
4103
4106
|
];
|
|
4104
|
-
async function
|
|
4105
|
-
let t = await
|
|
4107
|
+
async function go(e) {
|
|
4108
|
+
let t = await _o(e);
|
|
4106
4109
|
return (await Promise.all(t.map(async (t) => {
|
|
4107
4110
|
let n = T.join(T.dirname(t), ".env");
|
|
4108
|
-
return await
|
|
4111
|
+
return await Y(n) ? null : (await y.copyFile(t, n), T.relative(e, n));
|
|
4109
4112
|
}))).filter((e) => e !== null).sort();
|
|
4110
4113
|
}
|
|
4111
|
-
async function
|
|
4112
|
-
let t = [T.join(e, ".env.example")], n = await Promise.all(
|
|
4114
|
+
async function _o(e) {
|
|
4115
|
+
let t = [T.join(e, ".env.example")], n = await Promise.all(ho.map(async (t) => {
|
|
4113
4116
|
let n = T.join(e, t);
|
|
4114
4117
|
return (await y.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => T.join(n, e.name, ".env.example"));
|
|
4115
4118
|
}));
|
|
4116
|
-
return t.push(...n.flat()), (await Promise.all(t.map(async (e) => await
|
|
4119
|
+
return t.push(...n.flat()), (await Promise.all(t.map(async (e) => await Y(e) ? e : null))).filter((e) => e !== null);
|
|
4117
4120
|
}
|
|
4118
4121
|
//#endregion
|
|
4119
4122
|
//#region src/core/post-clone.ts
|
|
4120
|
-
var Q = "@hype-stack/",
|
|
4121
|
-
async function
|
|
4122
|
-
await
|
|
4123
|
+
var Q = "@hype-stack/", vo = "hype-stack", yo = "@hype-stack/cli";
|
|
4124
|
+
async function bo(e) {
|
|
4125
|
+
await mr(T.join(e, ".git"));
|
|
4123
4126
|
}
|
|
4124
|
-
async function
|
|
4125
|
-
await
|
|
4127
|
+
async function xo(e) {
|
|
4128
|
+
await J("git", ["init"], { cwd: e }), await J("git", ["add", "."], { cwd: e }), await J("git", [
|
|
4126
4129
|
"-c",
|
|
4127
4130
|
"user.name=Hype Stack CLI",
|
|
4128
4131
|
"-c",
|
|
@@ -4132,19 +4135,19 @@ async function yo(e) {
|
|
|
4132
4135
|
"Initial commit from Hype Stack CLI"
|
|
4133
4136
|
], { cwd: e });
|
|
4134
4137
|
}
|
|
4135
|
-
async function
|
|
4136
|
-
let n = `@${t}/`, r = await
|
|
4138
|
+
async function So(e, t) {
|
|
4139
|
+
let n = `@${t}/`, r = await Ao(e);
|
|
4137
4140
|
for (let e of r) {
|
|
4138
|
-
let t = await
|
|
4141
|
+
let t = await dr(e);
|
|
4139
4142
|
if (!t) continue;
|
|
4140
4143
|
let r = !1;
|
|
4141
|
-
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0),
|
|
4142
|
-
let i = await y.readFile(e, "utf-8"), a =
|
|
4143
|
-
a === i ? r && await
|
|
4144
|
+
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0), Do(t.dependencies, n) && (r = !0), Do(t.devDependencies, n) && (r = !0), t.nx && Oo(t.nx, n) && (r = !0);
|
|
4145
|
+
let i = await y.readFile(e, "utf-8"), a = qr(i, n);
|
|
4146
|
+
a === i ? r && await fr(e, t) : await y.writeFile(e, a, "utf-8");
|
|
4144
4147
|
}
|
|
4145
|
-
await
|
|
4148
|
+
await Gi(e, t), await To(e, t), await ko(e, t);
|
|
4146
4149
|
}
|
|
4147
|
-
var
|
|
4150
|
+
var Co = new Set([
|
|
4148
4151
|
".git",
|
|
4149
4152
|
"node_modules",
|
|
4150
4153
|
"dist",
|
|
@@ -4152,10 +4155,10 @@ var xo = new Set([
|
|
|
4152
4155
|
".nx",
|
|
4153
4156
|
".next",
|
|
4154
4157
|
"coverage"
|
|
4155
|
-
]),
|
|
4156
|
-
async function
|
|
4157
|
-
if (t ===
|
|
4158
|
-
let n = await
|
|
4158
|
+
]), wo = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
|
|
4159
|
+
async function To(e, t) {
|
|
4160
|
+
if (t === vo) return;
|
|
4161
|
+
let n = await Eo(e);
|
|
4159
4162
|
await Promise.all(n.map(async (e) => {
|
|
4160
4163
|
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
4161
4164
|
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
@@ -4163,23 +4166,23 @@ async function Co(e, t) {
|
|
|
4163
4166
|
await y.writeFile(e, r, "utf-8");
|
|
4164
4167
|
}));
|
|
4165
4168
|
}
|
|
4166
|
-
async function
|
|
4169
|
+
async function Eo(e) {
|
|
4167
4170
|
let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
4168
4171
|
return (await Promise.all(t.map(async (t) => {
|
|
4169
4172
|
let n = T.join(e, t.name);
|
|
4170
|
-
return t.isDirectory() ?
|
|
4173
|
+
return t.isDirectory() ? Co.has(t.name) ? [] : Eo(n) : t.isFile() && wo.test(t.name) ? [n] : [];
|
|
4171
4174
|
}))).flat();
|
|
4172
4175
|
}
|
|
4173
|
-
function
|
|
4176
|
+
function Do(e, t) {
|
|
4174
4177
|
if (!e) return !1;
|
|
4175
4178
|
let n = !1;
|
|
4176
|
-
for (let r of Object.keys(e)) if (r !==
|
|
4179
|
+
for (let r of Object.keys(e)) if (r !== yo && r.startsWith(Q)) {
|
|
4177
4180
|
let i = r.replace(Q, t);
|
|
4178
4181
|
e[i] = e[r], delete e[r], n = !0;
|
|
4179
4182
|
}
|
|
4180
4183
|
return n;
|
|
4181
4184
|
}
|
|
4182
|
-
function
|
|
4185
|
+
function Oo(e, t) {
|
|
4183
4186
|
if (!e) return !1;
|
|
4184
4187
|
let n = !1;
|
|
4185
4188
|
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Q) ? (n = !0, e.replace(Q, t)) : e), e.targets) {
|
|
@@ -4187,13 +4190,13 @@ function Eo(e, t) {
|
|
|
4187
4190
|
}
|
|
4188
4191
|
return n;
|
|
4189
4192
|
}
|
|
4190
|
-
async function
|
|
4193
|
+
async function ko(e, t) {
|
|
4191
4194
|
let n = T.join(e, "packages/enums/src/app/index.ts"), r = await y.readFile(n, "utf-8").catch(() => null);
|
|
4192
4195
|
if (!r) return;
|
|
4193
|
-
let i =
|
|
4196
|
+
let i = Ja(t), a = r.replaceAll(`id: "${vo}"`, `id: "${t}"`).replaceAll(`name: "${vo}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
|
|
4194
4197
|
await y.writeFile(n, a, "utf-8");
|
|
4195
4198
|
}
|
|
4196
|
-
async function
|
|
4199
|
+
async function Ao(e) {
|
|
4197
4200
|
let t = [], n = T.join(e, "package.json");
|
|
4198
4201
|
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
4199
4202
|
for (let n of [
|
|
@@ -4213,7 +4216,7 @@ async function Oo(e) {
|
|
|
4213
4216
|
}
|
|
4214
4217
|
//#endregion
|
|
4215
4218
|
//#region src/core/readme.ts
|
|
4216
|
-
var
|
|
4219
|
+
var jo = {
|
|
4217
4220
|
cursor: {
|
|
4218
4221
|
label: "Cursor",
|
|
4219
4222
|
rulesDir: ".cursor/rules"
|
|
@@ -4230,21 +4233,21 @@ var ko = {
|
|
|
4230
4233
|
label: "GitHub Copilot",
|
|
4231
4234
|
rulesDir: ".github/instructions"
|
|
4232
4235
|
}
|
|
4233
|
-
},
|
|
4236
|
+
}, Mo = {
|
|
4234
4237
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
4235
4238
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
4236
|
-
},
|
|
4239
|
+
}, No = {
|
|
4237
4240
|
enums: "Shared enums and app config used across apps",
|
|
4238
4241
|
cli: "Project tooling and code generators"
|
|
4239
4242
|
};
|
|
4240
|
-
function
|
|
4243
|
+
function Po(e, t) {
|
|
4241
4244
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
4242
4245
|
let r = t[e];
|
|
4243
4246
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4244
4247
|
});
|
|
4245
4248
|
}
|
|
4246
|
-
function
|
|
4247
|
-
let { projectName: t, editor: n, workspace: r } = e, i =
|
|
4249
|
+
function Fo(e) {
|
|
4250
|
+
let { projectName: t, editor: n, workspace: r } = e, i = Ja(t), a = jo[n], o = !!r.apps.backend, s = Po(r.apps, Mo), c = Po(r.packages, No), l = [];
|
|
4248
4251
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
4249
4252
|
let u = [];
|
|
4250
4253
|
u.push(`# ${i}`), u.push([
|
|
@@ -4347,19 +4350,19 @@ function No(e) {
|
|
|
4347
4350
|
"stays useful."
|
|
4348
4351
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4349
4352
|
}
|
|
4350
|
-
async function
|
|
4353
|
+
async function Io(e, t) {
|
|
4351
4354
|
let n = T.join(e, "README.md");
|
|
4352
|
-
await y.writeFile(n,
|
|
4355
|
+
await y.writeFile(n, Fo(t), "utf-8");
|
|
4353
4356
|
}
|
|
4354
4357
|
//#endregion
|
|
4355
4358
|
//#region src/core/tracking.ts
|
|
4356
|
-
async function
|
|
4359
|
+
async function Lo(e) {
|
|
4357
4360
|
try {
|
|
4358
4361
|
let t = {
|
|
4359
|
-
"X-Device-Id":
|
|
4360
|
-
"X-Client-Info":
|
|
4361
|
-
}, n = await
|
|
4362
|
-
n?.token && (t.Authorization = `Bearer ${n.token}`), await
|
|
4362
|
+
"X-Device-Id": er(),
|
|
4363
|
+
"X-Client-Info": tr()
|
|
4364
|
+
}, n = await Xn(F()).catch(() => null);
|
|
4365
|
+
n?.token && (t.Authorization = `Bearer ${n.token}`), await q.createRequest()({
|
|
4363
4366
|
endpoint: "/cli/track",
|
|
4364
4367
|
method: "POST"
|
|
4365
4368
|
}).setPayload({ event: e }).setHeaders(t).send();
|
|
@@ -4367,7 +4370,7 @@ async function Fo(e) {
|
|
|
4367
4370
|
}
|
|
4368
4371
|
//#endregion
|
|
4369
4372
|
//#region src/core/npm-deps.ts
|
|
4370
|
-
function
|
|
4373
|
+
function Ro(e, t) {
|
|
4371
4374
|
let n = [], r = [];
|
|
4372
4375
|
if (!e) return {
|
|
4373
4376
|
errors: n,
|
|
@@ -4398,7 +4401,7 @@ function Io(e, t) {
|
|
|
4398
4401
|
operations: r
|
|
4399
4402
|
};
|
|
4400
4403
|
}
|
|
4401
|
-
function
|
|
4404
|
+
function zo(e) {
|
|
4402
4405
|
let t = {};
|
|
4403
4406
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4404
4407
|
...t[e],
|
|
@@ -4406,11 +4409,11 @@ function Lo(e) {
|
|
|
4406
4409
|
};
|
|
4407
4410
|
return t;
|
|
4408
4411
|
}
|
|
4409
|
-
async function
|
|
4412
|
+
async function Bo(e, t, n = J) {
|
|
4410
4413
|
let r = [];
|
|
4411
4414
|
for (let i of e) {
|
|
4412
4415
|
let e = T.join(t, i.relativeDir);
|
|
4413
|
-
if (!await
|
|
4416
|
+
if (!await Y(T.join(e, "package.json"))) {
|
|
4414
4417
|
r.push(`Cannot install npm dependencies under "${i.relativeDir}": package.json not found.`);
|
|
4415
4418
|
continue;
|
|
4416
4419
|
}
|
|
@@ -4442,36 +4445,35 @@ async function Ro(e, t, n = q) {
|
|
|
4442
4445
|
function $(e) {
|
|
4443
4446
|
return e instanceof Error ? e.message : String(e);
|
|
4444
4447
|
}
|
|
4445
|
-
async function
|
|
4448
|
+
async function Vo(e, t, n) {
|
|
4446
4449
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4447
|
-
return r.length === 0 ? {} :
|
|
4450
|
+
return r.length === 0 ? {} : Wr(r, n).catch(() => ({}));
|
|
4448
4451
|
}
|
|
4449
|
-
function
|
|
4450
|
-
return e === "free" ?
|
|
4452
|
+
function Ho(e, t) {
|
|
4453
|
+
return e === "free" ? L.success("free") : e === "owned" ? L.accent("owned") : `${L.highlight(`$${t}`)} ${L.muted("locked")}`;
|
|
4451
4454
|
}
|
|
4452
|
-
async function
|
|
4455
|
+
async function Uo(e, t, n) {
|
|
4453
4456
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4454
|
-
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
|
|
4457
|
+
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 sr(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4455
4458
|
name: e.name,
|
|
4456
4459
|
displayName: e.displayName,
|
|
4457
4460
|
price: e.price
|
|
4458
4461
|
})));
|
|
4459
4462
|
}
|
|
4460
|
-
function
|
|
4461
|
-
|
|
4462
|
-
let r = t.get(e), i = r ? r.displayName : e;
|
|
4463
|
-
return ` ${z.muted(`${n + 1}.`)} ${z.brand(i)}`;
|
|
4464
|
-
});
|
|
4465
|
-
s.note([
|
|
4463
|
+
function Wo(e, t) {
|
|
4464
|
+
z([
|
|
4466
4465
|
"These packs will be installed, in order:",
|
|
4467
4466
|
"",
|
|
4468
|
-
...n
|
|
4467
|
+
...e.map((e, n) => {
|
|
4468
|
+
let r = t.get(e), i = r ? r.displayName : e;
|
|
4469
|
+
return ` ${L.muted(`${n + 1}.`)} ${L.brand(i)}`;
|
|
4470
|
+
})
|
|
4469
4471
|
].join("\n"), "Install Plan");
|
|
4470
4472
|
}
|
|
4471
|
-
async function
|
|
4473
|
+
async function Go(e, t) {
|
|
4472
4474
|
let n = [];
|
|
4473
4475
|
for (let r of e) {
|
|
4474
|
-
let e = await
|
|
4476
|
+
let e = await Rr(r), i = await zr(r, t);
|
|
4475
4477
|
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'npx @hype-stack/cli login' or check your license.`);
|
|
4476
4478
|
n.push({
|
|
4477
4479
|
manifest: e,
|
|
@@ -4480,32 +4482,38 @@ async function Uo(e, t) {
|
|
|
4480
4482
|
}
|
|
4481
4483
|
return n;
|
|
4482
4484
|
}
|
|
4483
|
-
async function
|
|
4484
|
-
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a =
|
|
4485
|
+
async function Ko(e) {
|
|
4486
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = Ro(zo(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4485
4487
|
if (a.errors.length > 0) {
|
|
4486
4488
|
for (let e of a.errors) s.log.error(e);
|
|
4487
4489
|
return;
|
|
4488
4490
|
}
|
|
4489
4491
|
if (a.operations.length === 0) return;
|
|
4490
4492
|
i.start("Installing npm dependencies...");
|
|
4491
|
-
let o = await
|
|
4493
|
+
let o = await Bo(a.operations, r);
|
|
4492
4494
|
if (i.stop(o.ok ? "npm dependencies installed" : "npm dependency installation failed"), !o.ok) for (let e of o.errors) s.log.error(e);
|
|
4493
4495
|
}
|
|
4494
|
-
function
|
|
4495
|
-
|
|
4496
|
+
function qo() {
|
|
4497
|
+
Te([{
|
|
4498
|
+
command: "npx @hype-stack/cli onboard",
|
|
4499
|
+
hint: "(set up env vars + run migrations)"
|
|
4500
|
+
}, {
|
|
4501
|
+
command: "pnpm dev",
|
|
4502
|
+
hint: "(start frontend + backend)"
|
|
4503
|
+
}]);
|
|
4496
4504
|
}
|
|
4497
|
-
function
|
|
4505
|
+
function Jo(e) {
|
|
4498
4506
|
if (e.length === 0) return;
|
|
4499
4507
|
let t = e.map((e) => {
|
|
4500
4508
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
4501
|
-
return ` ${
|
|
4509
|
+
return ` ${L.muted("•")} ${L.path(t)}`;
|
|
4502
4510
|
});
|
|
4503
4511
|
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4504
4512
|
}
|
|
4505
|
-
async function
|
|
4513
|
+
async function Yo(e) {
|
|
4506
4514
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
|
|
4507
4515
|
if (i) return c;
|
|
4508
|
-
let l = await
|
|
4516
|
+
let l = await ea({
|
|
4509
4517
|
packs: t,
|
|
4510
4518
|
config: n,
|
|
4511
4519
|
projectRoot: r,
|
|
@@ -4513,17 +4521,17 @@ async function qo(e) {
|
|
|
4513
4521
|
});
|
|
4514
4522
|
if (l.length === 0) return c;
|
|
4515
4523
|
if (a) {
|
|
4516
|
-
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${
|
|
4524
|
+
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${L.command("--force")} to overwrite.`);
|
|
4517
4525
|
let e = l.map((e) => {
|
|
4518
4526
|
let t = T.relative(r, e.targetPath) || e.target;
|
|
4519
|
-
return ` ${
|
|
4527
|
+
return ` ${L.muted("•")} ${L.path(t)} ${L.muted(`(${e.packName})`)}`;
|
|
4520
4528
|
});
|
|
4521
4529
|
return s.note(e.join("\n"), "Kept existing files"), c;
|
|
4522
4530
|
}
|
|
4523
4531
|
s.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4524
4532
|
for (let e of l) {
|
|
4525
4533
|
let t = T.relative(r, e.targetPath) || e.target, n = await s.confirm({
|
|
4526
|
-
message: `Overwrite ${
|
|
4534
|
+
message: `Overwrite ${L.path(t)}? ${L.muted(`(${e.packName})`)}`,
|
|
4527
4535
|
initialValue: !1
|
|
4528
4536
|
});
|
|
4529
4537
|
s.isCancel(n) && (s.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
|
|
@@ -4532,7 +4540,7 @@ async function qo(e) {
|
|
|
4532
4540
|
}
|
|
4533
4541
|
//#endregion
|
|
4534
4542
|
//#region src/ui/swatch.ts
|
|
4535
|
-
function
|
|
4543
|
+
function Xo(e) {
|
|
4536
4544
|
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4537
4545
|
if (!t) return null;
|
|
4538
4546
|
let n = t[1].trim().split(/\s+/);
|
|
@@ -4551,58 +4559,58 @@ function Jo(e) {
|
|
|
4551
4559
|
h: a
|
|
4552
4560
|
};
|
|
4553
4561
|
}
|
|
4554
|
-
function
|
|
4562
|
+
function Zo(e) {
|
|
4555
4563
|
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4556
4564
|
}
|
|
4557
|
-
function
|
|
4565
|
+
function Qo(e) {
|
|
4558
4566
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4559
4567
|
}
|
|
4560
|
-
function
|
|
4568
|
+
function $o({ l: e, c: t, h: n }) {
|
|
4561
4569
|
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;
|
|
4562
4570
|
return [
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4571
|
+
Zo(Qo(f) * 255),
|
|
4572
|
+
Zo(Qo(p) * 255),
|
|
4573
|
+
Zo(Qo(m) * 255)
|
|
4566
4574
|
];
|
|
4567
4575
|
}
|
|
4568
|
-
var
|
|
4569
|
-
function
|
|
4576
|
+
var es = "\x1B[49m";
|
|
4577
|
+
function ts(e, t) {
|
|
4570
4578
|
let n = e[t];
|
|
4571
4579
|
if (!n) return b.dim(" ");
|
|
4572
|
-
let r =
|
|
4580
|
+
let r = Xo(n);
|
|
4573
4581
|
if (!r) return b.dim(" ");
|
|
4574
|
-
let [i, a, o] =
|
|
4575
|
-
return `\x1b[48;2;${i};${a};${o}m ${
|
|
4582
|
+
let [i, a, o] = $o(r);
|
|
4583
|
+
return `\x1b[48;2;${i};${a};${o}m ${es}`;
|
|
4576
4584
|
}
|
|
4577
|
-
var
|
|
4585
|
+
var ns = [
|
|
4578
4586
|
"primary",
|
|
4579
4587
|
"secondary",
|
|
4580
4588
|
"accent"
|
|
4581
4589
|
];
|
|
4582
|
-
function
|
|
4583
|
-
return
|
|
4590
|
+
function rs(e) {
|
|
4591
|
+
return ns.map((t) => ts(e, t)).join("");
|
|
4584
4592
|
}
|
|
4585
|
-
function
|
|
4586
|
-
return `${
|
|
4593
|
+
function is(e) {
|
|
4594
|
+
return `${rs(e.light)} ${b.dim("·")} ${rs(e.dark)}`;
|
|
4587
4595
|
}
|
|
4588
4596
|
//#endregion
|
|
4589
4597
|
//#region src/commands/create.ts
|
|
4590
|
-
async function
|
|
4591
|
-
e.skipBanner ||
|
|
4598
|
+
async function as(e) {
|
|
4599
|
+
e.skipBanner || Ua(), s.intro(L.brandBold("Create a new Hype Stack project"));
|
|
4592
4600
|
let o = e.yes === !0, c, l;
|
|
4593
4601
|
if (o && e.name) {
|
|
4594
|
-
let t =
|
|
4595
|
-
t && (s.log.error(t),
|
|
4602
|
+
let t = Ya(e.name);
|
|
4603
|
+
t && (s.log.error(t), B()), l = e.name, c = qa(e.name);
|
|
4596
4604
|
} else {
|
|
4597
4605
|
let t = await s.text({
|
|
4598
4606
|
message: "What is your project named?",
|
|
4599
4607
|
placeholder: "my-app",
|
|
4600
4608
|
initialValue: e.name ?? "",
|
|
4601
|
-
validate: (e) =>
|
|
4609
|
+
validate: (e) => Ya(e ?? "")
|
|
4602
4610
|
});
|
|
4603
|
-
s.isCancel(t) &&
|
|
4611
|
+
s.isCancel(t) && B(), l = t, c = qa(l);
|
|
4604
4612
|
}
|
|
4605
|
-
l.trim() !== c && s.log.info(
|
|
4613
|
+
l.trim() !== c && s.log.info(L.muted(`Using "${L.highlight(c)}" as the project name`));
|
|
4606
4614
|
let u;
|
|
4607
4615
|
if (e.directory !== void 0) u = e.directory;
|
|
4608
4616
|
else {
|
|
@@ -4615,26 +4623,26 @@ async function rs(e) {
|
|
|
4615
4623
|
placeholder: ".",
|
|
4616
4624
|
initialValue: "."
|
|
4617
4625
|
});
|
|
4618
|
-
s.isCancel(e) &&
|
|
4626
|
+
s.isCancel(e) && B(), t = e;
|
|
4619
4627
|
}
|
|
4620
|
-
u =
|
|
4628
|
+
u = hr(t, c);
|
|
4621
4629
|
}
|
|
4622
4630
|
let d = T.resolve(u);
|
|
4623
|
-
o || s.note(
|
|
4624
|
-
let f = e.editor &&
|
|
4631
|
+
o || s.note(L.path(d), "Project will be created at");
|
|
4632
|
+
let f = e.editor && ae.includes(e.editor) ? e.editor : null, p;
|
|
4625
4633
|
if (f) p = f;
|
|
4626
4634
|
else if (o) p = "cursor";
|
|
4627
4635
|
else {
|
|
4628
4636
|
let e = await s.select({
|
|
4629
4637
|
message: "Which code editor do you use?",
|
|
4630
|
-
options:
|
|
4638
|
+
options: P.map((e) => ({
|
|
4631
4639
|
value: e.value,
|
|
4632
4640
|
label: e.label,
|
|
4633
4641
|
hint: "hint" in e ? e.hint : void 0
|
|
4634
4642
|
})),
|
|
4635
4643
|
initialValue: "cursor"
|
|
4636
4644
|
});
|
|
4637
|
-
s.isCancel(e) &&
|
|
4645
|
+
s.isCancel(e) && B(), p = e;
|
|
4638
4646
|
}
|
|
4639
4647
|
let m = e.theme !== void 0 && a(e.theme), h = e.defaultTheme !== void 0 && a(e.defaultTheme) ? e.defaultTheme : t, g;
|
|
4640
4648
|
if (m) g = e.theme;
|
|
@@ -4644,139 +4652,139 @@ async function rs(e) {
|
|
|
4644
4652
|
message: "Pick a color theme",
|
|
4645
4653
|
options: r.map((e) => ({
|
|
4646
4654
|
value: e.name,
|
|
4647
|
-
label: `${
|
|
4655
|
+
label: `${is(e)} ${e.label}`
|
|
4648
4656
|
})),
|
|
4649
4657
|
initialValue: h
|
|
4650
4658
|
});
|
|
4651
|
-
s.isCancel(e) &&
|
|
4659
|
+
s.isCancel(e) && B(), g = e;
|
|
4652
4660
|
}
|
|
4653
4661
|
if (!o) {
|
|
4654
|
-
let e =
|
|
4655
|
-
(s.isCancel(r) || !r) &&
|
|
4662
|
+
let e = P.find((e) => e.value === p)?.label ?? p, t = n.find((e) => e.value === g)?.label ?? g, r = await s.confirm({ message: `Create ${L.highlight(c)} in ${L.path(d)} with ${L.highlight(e)} config and the ${L.highlight(t)} theme?` });
|
|
4663
|
+
(s.isCancel(r) || !r) && B();
|
|
4656
4664
|
}
|
|
4657
|
-
if (await
|
|
4665
|
+
if (await lr(d) && !await ur(d)) {
|
|
4658
4666
|
let e = await s.confirm({
|
|
4659
|
-
message: `Directory ${
|
|
4667
|
+
message: `Directory ${L.path(d)} is not empty. Continue anyway?`,
|
|
4660
4668
|
initialValue: !1
|
|
4661
4669
|
});
|
|
4662
|
-
(s.isCancel(e) || !e) &&
|
|
4670
|
+
(s.isCancel(e) || !e) && B();
|
|
4663
4671
|
}
|
|
4664
4672
|
let _ = s.spinner();
|
|
4665
|
-
_.start("Cloning Hype Stack template..."), await
|
|
4673
|
+
_.start("Cloning Hype Stack template..."), await oo(d), _.stop(L.success("Template cloned"));
|
|
4666
4674
|
let v = s.spinner();
|
|
4667
|
-
v.start("Setting up project..."), await
|
|
4668
|
-
let y = await
|
|
4669
|
-
await
|
|
4675
|
+
v.start("Setting up project..."), await bo(d), await So(d, c), await mo(d, p);
|
|
4676
|
+
let y = await Pr(d), b = Ir(c, y);
|
|
4677
|
+
await Nr(d, b), await Io(d, {
|
|
4670
4678
|
projectName: c,
|
|
4671
4679
|
editor: p,
|
|
4672
4680
|
workspace: y
|
|
4673
4681
|
});
|
|
4674
4682
|
let x = T.resolve(d, b.paths?.frontend.root ?? "apps/frontend");
|
|
4675
|
-
a(g) && (await
|
|
4683
|
+
a(g) && (await ao(x, i(g)) || s.log.warn(L.muted(`Could not find ${L.path("assets/styles.css")} to apply the ${g} theme`))), await $a(x, e.defaultMode === "dark" || e.defaultMode === "light" ? e.defaultMode : "light") || s.log.warn(L.muted(`Could not find ${L.path("src/hooks/use-theme.ts")} to set the default color mode`)), v.stop(L.success("Project configured"));
|
|
4676
4684
|
let S = s.spinner();
|
|
4677
|
-
S.start("Installing dependencies..."), (await
|
|
4685
|
+
S.start("Installing dependencies..."), (await J("pnpm", ["install"], { cwd: d })).exitCode === 0 ? S.stop(L.success("Dependencies installed")) : (S.stop(L.warning("Dependencies installed with warnings")), s.log.warn(L.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4678
4686
|
let C = s.spinner();
|
|
4679
|
-
C.start("Initializing git repository..."), await
|
|
4687
|
+
C.start("Initializing git repository..."), await xo(d), C.stop(L.success("Git repository initialized with clean history"));
|
|
4680
4688
|
let w = s.spinner();
|
|
4681
4689
|
w.start("Creating .env files from examples...");
|
|
4682
|
-
let E = await
|
|
4690
|
+
let E = await go(d);
|
|
4683
4691
|
if (E.length > 0) {
|
|
4684
4692
|
let e = E.length;
|
|
4685
|
-
w.stop(
|
|
4686
|
-
} else w.stop(
|
|
4687
|
-
s.log.success(`${
|
|
4688
|
-
let D = T.relative(process.cwd(), d) || ".", O = [`${
|
|
4689
|
-
E.length > 0 ? O.push(`Review your ${
|
|
4693
|
+
w.stop(L.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4694
|
+
} else w.stop(L.muted("No .env.example files to copy"));
|
|
4695
|
+
s.log.success(`${L.brandBold("Hype Stack")} project ${L.highlight(c)} is ready!`);
|
|
4696
|
+
let D = T.relative(process.cwd(), d) || ".", O = [`${L.command(`cd ${D}`)}`];
|
|
4697
|
+
E.length > 0 ? O.push(`Review your ${L.path(".env")} files and fill in any secrets`) : O.push(`Copy ${L.path(".env.example")} to ${L.path(".env")} and configure`), Te(O);
|
|
4690
4698
|
let k = e.setup === !1;
|
|
4691
|
-
if (e.deferSetup) s.log.info(
|
|
4699
|
+
if (e.deferSetup) s.log.info(L.muted("Docker and migrations will run after your packs are installed."));
|
|
4692
4700
|
else {
|
|
4693
4701
|
let e = !k && (o || await s.confirm({
|
|
4694
4702
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
4695
4703
|
initialValue: !0
|
|
4696
4704
|
}));
|
|
4697
|
-
s.isCancel(e) &&
|
|
4705
|
+
s.isCancel(e) && B(), e ? await wa(d, o) : s.log.info(L.muted("Docker and migrations can run later via `npx @hype-stack/cli onboard`.")), qo();
|
|
4698
4706
|
}
|
|
4699
|
-
return await
|
|
4707
|
+
return await Lo("project_create"), s.outro(L.muted("Happy building!")), d;
|
|
4700
4708
|
}
|
|
4701
4709
|
//#endregion
|
|
4702
4710
|
//#region src/commands/init.ts
|
|
4703
|
-
async function
|
|
4711
|
+
async function os(e) {
|
|
4704
4712
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4705
|
-
if (n || (
|
|
4706
|
-
s.log.error(`This doesn't look like a Hype Stack project. ${
|
|
4713
|
+
if (n || (Wa(), s.intro(L.brandBold("Initialize Hype Stack configuration"))), !await Lr(t)) {
|
|
4714
|
+
s.log.error(`This doesn't look like a Hype Stack project. ${L.muted("Expected apps/ directory and package.json")}`), s.outro(L.muted(`Run ${L.command("npx @hype-stack/cli create")} to scaffold a new project.`));
|
|
4707
4715
|
return;
|
|
4708
4716
|
}
|
|
4709
|
-
if (await
|
|
4710
|
-
let e = await
|
|
4717
|
+
if (await Mr(t)) {
|
|
4718
|
+
let e = await jr(t);
|
|
4711
4719
|
if (e && !n) {
|
|
4712
|
-
s.log.info(`Found existing ${
|
|
4720
|
+
s.log.info(`Found existing ${L.path("stack.json")} for project ${L.highlight(e.name)}`);
|
|
4713
4721
|
let t = await s.confirm({
|
|
4714
4722
|
message: "Overwrite existing configuration?",
|
|
4715
4723
|
initialValue: !1
|
|
4716
4724
|
});
|
|
4717
4725
|
if (s.isCancel(t) || !t) {
|
|
4718
|
-
s.outro(
|
|
4726
|
+
s.outro(L.muted("Keeping existing configuration."));
|
|
4719
4727
|
return;
|
|
4720
4728
|
}
|
|
4721
4729
|
}
|
|
4722
4730
|
}
|
|
4723
|
-
let r = await
|
|
4731
|
+
let r = await Pr(t);
|
|
4724
4732
|
if (!n) {
|
|
4725
4733
|
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4726
4734
|
if (e.length > 0) {
|
|
4727
|
-
s.log.info(
|
|
4728
|
-
for (let [t, n] of e) s.log.message(` ${
|
|
4735
|
+
s.log.info(L.bold("Detected apps:"));
|
|
4736
|
+
for (let [t, n] of e) s.log.message(` ${R.arrow} ${L.highlight(t)} ${L.muted(`→ ${n}`)}`);
|
|
4729
4737
|
}
|
|
4730
4738
|
if (t.length > 0) {
|
|
4731
|
-
s.log.info(
|
|
4732
|
-
for (let [e, n] of t) s.log.message(` ${
|
|
4739
|
+
s.log.info(L.bold("Detected packages:"));
|
|
4740
|
+
for (let [e, n] of t) s.log.message(` ${R.arrow} ${L.highlight(e)} ${L.muted(`→ ${n}`)}`);
|
|
4733
4741
|
}
|
|
4734
4742
|
e.length === 0 && t.length === 0 && s.log.warn("No apps or packages detected in the workspace.");
|
|
4735
4743
|
}
|
|
4736
|
-
let i = (await
|
|
4744
|
+
let i = (await dr(T.join(t, "package.json")))?.name?.replace(/^@/, "").replace(/\/source$/, "") ?? "my-app", a = i;
|
|
4737
4745
|
if (!n) {
|
|
4738
4746
|
let e = await s.text({
|
|
4739
4747
|
message: "Project name for stack.json?",
|
|
4740
4748
|
placeholder: i,
|
|
4741
4749
|
initialValue: i,
|
|
4742
|
-
validate: (e) =>
|
|
4750
|
+
validate: (e) => Ya(e ?? "")
|
|
4743
4751
|
});
|
|
4744
|
-
s.isCancel(e) &&
|
|
4752
|
+
s.isCancel(e) && B(), a = qa(e);
|
|
4745
4753
|
}
|
|
4746
|
-
await
|
|
4754
|
+
await Nr(t, Ir(a, r)), n || (s.log.success(`${L.path("stack.json")} written successfully`), s.outro(L.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
|
|
4747
4755
|
}
|
|
4748
|
-
async function
|
|
4749
|
-
if (await
|
|
4756
|
+
async function ss(e, t = {}, n) {
|
|
4757
|
+
if (await Mr(e)) return {
|
|
4750
4758
|
projectRoot: e,
|
|
4751
4759
|
scaffolded: !1
|
|
4752
4760
|
};
|
|
4753
|
-
let r = t.runInit ?? ((e) =>
|
|
4761
|
+
let r = t.runInit ?? ((e) => os({
|
|
4754
4762
|
cwd: e,
|
|
4755
4763
|
silent: !0
|
|
4756
|
-
})), i = t.runCreate ?? ((e, t) =>
|
|
4764
|
+
})), i = t.runCreate ?? ((e, t) => as({
|
|
4757
4765
|
parentDirectory: e,
|
|
4758
4766
|
deferSetup: !0,
|
|
4759
4767
|
skipBanner: !0,
|
|
4760
4768
|
defaultTheme: t?.defaultTheme,
|
|
4761
4769
|
defaultMode: t?.defaultMode
|
|
4762
4770
|
}));
|
|
4763
|
-
if (await
|
|
4764
|
-
s.log.warn(`No ${
|
|
4771
|
+
if (await Lr(e)) {
|
|
4772
|
+
s.log.warn(`No ${L.path("stack.json")} found in ${L.path(e)}.`);
|
|
4765
4773
|
let t = await s.confirm({
|
|
4766
|
-
message: `Create ${
|
|
4774
|
+
message: `Create ${L.path("stack.json")} now?`,
|
|
4767
4775
|
initialValue: !0
|
|
4768
4776
|
});
|
|
4769
4777
|
if (s.isCancel(t) || !t) return null;
|
|
4770
4778
|
await r(e);
|
|
4771
|
-
let n = await
|
|
4772
|
-
return n && s.log.success(`${
|
|
4779
|
+
let n = await Mr(e);
|
|
4780
|
+
return n && s.log.success(`${L.path("stack.json")} created`), n ? {
|
|
4773
4781
|
projectRoot: e,
|
|
4774
4782
|
scaffolded: !1
|
|
4775
4783
|
} : null;
|
|
4776
4784
|
}
|
|
4777
|
-
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${
|
|
4785
|
+
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${L.path("stack.json")} here.`);
|
|
4778
4786
|
let a = await s.confirm({
|
|
4779
|
-
message: `Is ${
|
|
4787
|
+
message: `Is ${L.path(e)} where you want to work?`,
|
|
4780
4788
|
initialValue: !0
|
|
4781
4789
|
});
|
|
4782
4790
|
if (s.isCancel(a) || !a) return null;
|
|
@@ -4786,41 +4794,41 @@ async function as(e, t = {}, n) {
|
|
|
4786
4794
|
});
|
|
4787
4795
|
if (s.isCancel(o) || !o) return null;
|
|
4788
4796
|
let c = await i(e, n);
|
|
4789
|
-
return await
|
|
4797
|
+
return await Mr(c) ? {
|
|
4790
4798
|
projectRoot: c,
|
|
4791
4799
|
scaffolded: !0
|
|
4792
4800
|
} : null;
|
|
4793
4801
|
}
|
|
4794
4802
|
//#endregion
|
|
4795
4803
|
//#region src/commands/compose.ts
|
|
4796
|
-
async function
|
|
4804
|
+
async function cs(e = {}) {
|
|
4797
4805
|
let t = e.cwd ?? process.cwd();
|
|
4798
|
-
|
|
4799
|
-
let n = await
|
|
4806
|
+
Ua();
|
|
4807
|
+
let n = await ss(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4800
4808
|
try {
|
|
4801
|
-
a = await
|
|
4809
|
+
a = await jr(r ?? t);
|
|
4802
4810
|
} catch (e) {
|
|
4803
|
-
s.cancel(`Could not parse ${
|
|
4811
|
+
s.cancel(`Could not parse ${L.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4804
4812
|
}
|
|
4805
|
-
a || (s.cancel(r ? `Could not read ${
|
|
4813
|
+
a || (s.cancel(r ? `Could not read ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli compose' again.` : `No ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli compose'.`), process.exit(1)), a.paths || (s.cancel(`${L.path("stack.json")} is missing ${L.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
4806
4814
|
let o = r ?? t;
|
|
4807
|
-
s.intro(
|
|
4815
|
+
s.intro(L.brandBold("Compose your stack"));
|
|
4808
4816
|
let c = s.spinner();
|
|
4809
4817
|
c.start("Loading packs...");
|
|
4810
4818
|
let l;
|
|
4811
4819
|
try {
|
|
4812
|
-
l = await
|
|
4820
|
+
l = await Ur();
|
|
4813
4821
|
} catch (e) {
|
|
4814
4822
|
c.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4815
4823
|
}
|
|
4816
4824
|
c.stop("Packs loaded");
|
|
4817
|
-
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
|
|
4825
|
+
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 Xn(F()))?.token ?? null, h = await Vo(l, d, {
|
|
4818
4826
|
token: m,
|
|
4819
4827
|
key: p
|
|
4820
4828
|
}), g = (e) => {
|
|
4821
4829
|
let t = f.get(e);
|
|
4822
4830
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4823
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await
|
|
4831
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await ls({
|
|
4824
4832
|
packs: l,
|
|
4825
4833
|
installedSet: d,
|
|
4826
4834
|
stateOf: g,
|
|
@@ -4828,49 +4836,49 @@ async function os(e = {}) {
|
|
|
4828
4836
|
adminAvailable: !!a.apps.admin
|
|
4829
4837
|
});
|
|
4830
4838
|
if (v === null && (s.cancel("Cancelled."), process.exit(0)), v.length === 0) {
|
|
4831
|
-
s.outro(
|
|
4839
|
+
s.outro(L.muted("No packs selected. Nothing to do."));
|
|
4832
4840
|
return;
|
|
4833
4841
|
}
|
|
4834
|
-
let b =
|
|
4842
|
+
let b = fs(v), x = ps(v), S = Na(l, b), C = Ea(Pa(l, S)), w;
|
|
4835
4843
|
try {
|
|
4836
|
-
w =
|
|
4844
|
+
w = Oa(b, C, u);
|
|
4837
4845
|
} catch (e) {
|
|
4838
4846
|
s.cancel($(e)), process.exit(1);
|
|
4839
4847
|
}
|
|
4840
4848
|
if (w.order.length === 0) {
|
|
4841
|
-
|
|
4849
|
+
z(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(L.muted("Your selection is already part of the project."));
|
|
4842
4850
|
return;
|
|
4843
4851
|
}
|
|
4844
|
-
let T =
|
|
4852
|
+
let T = ka({
|
|
4845
4853
|
order: w.order,
|
|
4846
4854
|
graph: C,
|
|
4847
4855
|
isLocked: _,
|
|
4848
4856
|
installed: u
|
|
4849
4857
|
});
|
|
4850
4858
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4851
|
-
let e = await
|
|
4852
|
-
e && (m = e, h = await
|
|
4859
|
+
let e = await or();
|
|
4860
|
+
e && (m = e, h = await Vo(l, d, {
|
|
4853
4861
|
token: m,
|
|
4854
4862
|
key: p
|
|
4855
|
-
}), T =
|
|
4863
|
+
}), T = ka({
|
|
4856
4864
|
order: w.order,
|
|
4857
4865
|
graph: C,
|
|
4858
4866
|
isLocked: _,
|
|
4859
4867
|
installed: u
|
|
4860
4868
|
}));
|
|
4861
4869
|
}
|
|
4862
|
-
if (T.blocked.length > 0 && await
|
|
4863
|
-
s.outro(
|
|
4870
|
+
if (T.blocked.length > 0 && await Uo(T.blocked, _, f), T.installable.length === 0) {
|
|
4871
|
+
s.outro(L.muted("Nothing left to install once locked packs are removed."));
|
|
4864
4872
|
return;
|
|
4865
4873
|
}
|
|
4866
|
-
if (
|
|
4874
|
+
if (Wo(T.installable, f), !e.yes) {
|
|
4867
4875
|
let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4868
4876
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
4869
4877
|
}
|
|
4870
4878
|
c.start("Downloading packs...");
|
|
4871
4879
|
let E;
|
|
4872
4880
|
try {
|
|
4873
|
-
E = await
|
|
4881
|
+
E = await Go(T.installable, {
|
|
4874
4882
|
token: m,
|
|
4875
4883
|
key: p
|
|
4876
4884
|
});
|
|
@@ -4878,7 +4886,7 @@ async function os(e = {}) {
|
|
|
4878
4886
|
c.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
4879
4887
|
}
|
|
4880
4888
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4881
|
-
let D = await
|
|
4889
|
+
let D = await Yo({
|
|
4882
4890
|
prepared: E,
|
|
4883
4891
|
config: a,
|
|
4884
4892
|
cwd: o,
|
|
@@ -4888,7 +4896,7 @@ async function os(e = {}) {
|
|
|
4888
4896
|
});
|
|
4889
4897
|
try {
|
|
4890
4898
|
c.start("Installing pack files...");
|
|
4891
|
-
let t = await
|
|
4899
|
+
let t = await ra({
|
|
4892
4900
|
packs: E,
|
|
4893
4901
|
config: a,
|
|
4894
4902
|
projectRoot: o,
|
|
@@ -4901,22 +4909,22 @@ async function os(e = {}) {
|
|
|
4901
4909
|
for (let e of t.errors) s.log.error(e);
|
|
4902
4910
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4903
4911
|
}
|
|
4904
|
-
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${
|
|
4912
|
+
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${L.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (s.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`), Jo(t.skipped));
|
|
4905
4913
|
for (let e of t.errors) s.log.error(e);
|
|
4906
|
-
await
|
|
4914
|
+
await Ko({
|
|
4907
4915
|
prepared: E,
|
|
4908
4916
|
paths: a.paths,
|
|
4909
4917
|
cwd: o,
|
|
4910
4918
|
spinner: c
|
|
4911
4919
|
});
|
|
4912
4920
|
let n;
|
|
4913
|
-
i && (n = await
|
|
4921
|
+
i && (n = await Ta(o, e.yes ?? !1)), await _r({
|
|
4914
4922
|
projectRoot: o,
|
|
4915
4923
|
paths: a.paths,
|
|
4916
4924
|
skipPrompts: e.yes ?? !1,
|
|
4917
4925
|
dbReady: n,
|
|
4918
4926
|
freshScaffold: i
|
|
4919
|
-
}),
|
|
4927
|
+
}), qo(), s.outro(L.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4920
4928
|
} finally {
|
|
4921
4929
|
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
4922
4930
|
recursive: !0,
|
|
@@ -4924,25 +4932,25 @@ async function os(e = {}) {
|
|
|
4924
4932
|
})));
|
|
4925
4933
|
}
|
|
4926
4934
|
}
|
|
4927
|
-
async function
|
|
4935
|
+
async function ls(e) {
|
|
4928
4936
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4929
4937
|
if (i.packs && i.packs.length > 0) {
|
|
4930
|
-
let e = i.packs.map(
|
|
4938
|
+
let e = i.packs.map(ds), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4931
4939
|
return n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4932
4940
|
}
|
|
4933
4941
|
let o = t.filter((e) => n.has(e.name));
|
|
4934
|
-
o.length > 0 &&
|
|
4942
|
+
o.length > 0 && z(o.map((e) => ` ${L.success("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4935
4943
|
let c = t.filter((e) => !n.has(e.name));
|
|
4936
|
-
if (c.length === 0) return s.outro(
|
|
4937
|
-
let l =
|
|
4938
|
-
|
|
4939
|
-
let u =
|
|
4944
|
+
if (c.length === 0) return s.outro(L.muted("Every available pack is already installed.")), [];
|
|
4945
|
+
let l = le();
|
|
4946
|
+
z(c.map((e) => ` ${R.arrow} ${L.highlight(e.displayName)} ${ve(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4947
|
+
let u = da(c, { adminAvailable: a }), d = [];
|
|
4940
4948
|
for (let e of u) {
|
|
4941
4949
|
let t = e.packs.map((e) => {
|
|
4942
4950
|
let t = r(e.name);
|
|
4943
4951
|
return {
|
|
4944
4952
|
value: e.name,
|
|
4945
|
-
label: `${e.displayName} ${
|
|
4953
|
+
label: `${e.displayName} ${Ho(t, e.price)}`,
|
|
4946
4954
|
hint: e.description
|
|
4947
4955
|
};
|
|
4948
4956
|
});
|
|
@@ -4959,7 +4967,7 @@ async function ss(e) {
|
|
|
4959
4967
|
});
|
|
4960
4968
|
continue;
|
|
4961
4969
|
}
|
|
4962
|
-
let n = await
|
|
4970
|
+
let n = await Ka({
|
|
4963
4971
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4964
4972
|
options: t,
|
|
4965
4973
|
required: !1
|
|
@@ -4969,20 +4977,20 @@ async function ss(e) {
|
|
|
4969
4977
|
}
|
|
4970
4978
|
return d;
|
|
4971
4979
|
}
|
|
4972
|
-
var
|
|
4973
|
-
function
|
|
4974
|
-
let t = e.match(
|
|
4980
|
+
var us = /@(frontend|admin)$/;
|
|
4981
|
+
function ds(e) {
|
|
4982
|
+
let t = e.match(us);
|
|
4975
4983
|
return t ? {
|
|
4976
4984
|
name: e.slice(0, -t[0].length),
|
|
4977
4985
|
slot: t[1]
|
|
4978
4986
|
} : { name: e };
|
|
4979
4987
|
}
|
|
4980
|
-
function
|
|
4988
|
+
function fs(e) {
|
|
4981
4989
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4982
4990
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4983
4991
|
return n;
|
|
4984
4992
|
}
|
|
4985
|
-
function
|
|
4993
|
+
function ps(e) {
|
|
4986
4994
|
let t = /* @__PURE__ */ new Map();
|
|
4987
4995
|
for (let n of e) {
|
|
4988
4996
|
if (!n.slot) continue;
|
|
@@ -4993,32 +5001,32 @@ function ds(e) {
|
|
|
4993
5001
|
}
|
|
4994
5002
|
//#endregion
|
|
4995
5003
|
//#region src/commands/login.ts
|
|
4996
|
-
async function
|
|
4997
|
-
|
|
5004
|
+
async function ms() {
|
|
5005
|
+
Wa(), s.intro(L.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
4998
5006
|
let e;
|
|
4999
5007
|
try {
|
|
5000
|
-
e = await
|
|
5001
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
5008
|
+
e = await ar({ onUrl: (e) => {
|
|
5009
|
+
s.log.info(`If your browser didn't open, visit:\n ${L.path(e)}`);
|
|
5002
5010
|
} });
|
|
5003
5011
|
} catch (e) {
|
|
5004
5012
|
s.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
|
|
5005
5013
|
}
|
|
5006
|
-
s.outro(
|
|
5014
|
+
s.outro(L.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."));
|
|
5007
5015
|
}
|
|
5008
5016
|
//#endregion
|
|
5009
5017
|
//#region src/commands/logout.ts
|
|
5010
|
-
async function
|
|
5011
|
-
|
|
5012
|
-
let e =
|
|
5018
|
+
async function hs() {
|
|
5019
|
+
Wa(), s.intro(L.brandBold("Log out of Hype Stack"));
|
|
5020
|
+
let e = F(), t = await Xn(e);
|
|
5013
5021
|
if (!t) {
|
|
5014
|
-
s.outro(
|
|
5022
|
+
s.outro(L.muted("You're not logged in."));
|
|
5015
5023
|
return;
|
|
5016
5024
|
}
|
|
5017
|
-
await
|
|
5025
|
+
await Hn(t.token).catch(() => null), await Qn(e), s.outro(L.brand("Logged out."));
|
|
5018
5026
|
}
|
|
5019
5027
|
//#endregion
|
|
5020
5028
|
//#region src/core/onboard-env.ts
|
|
5021
|
-
function
|
|
5029
|
+
function gs(e) {
|
|
5022
5030
|
let t = [], n = "";
|
|
5023
5031
|
for (let r of e.split(/\r?\n/)) {
|
|
5024
5032
|
let e = r.trim();
|
|
@@ -5044,14 +5052,14 @@ function ms(e) {
|
|
|
5044
5052
|
}
|
|
5045
5053
|
return t;
|
|
5046
5054
|
}
|
|
5047
|
-
function
|
|
5055
|
+
function _s(e) {
|
|
5048
5056
|
let t = e.trim();
|
|
5049
5057
|
if (t === "") return "";
|
|
5050
5058
|
if (t.length <= 4) return "•".repeat(t.length);
|
|
5051
5059
|
let n = Math.min(t.length - 4, 8);
|
|
5052
5060
|
return `${"•".repeat(n)}${t.slice(-4)}`;
|
|
5053
5061
|
}
|
|
5054
|
-
function
|
|
5062
|
+
function vs(e, t, n) {
|
|
5055
5063
|
let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
|
|
5056
5064
|
if (i) return e;
|
|
5057
5065
|
let r = e.trim();
|
|
@@ -5061,118 +5069,118 @@ function gs(e, t, n) {
|
|
|
5061
5069
|
});
|
|
5062
5070
|
return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
|
|
5063
5071
|
}
|
|
5064
|
-
async function
|
|
5065
|
-
return await
|
|
5072
|
+
async function ys(e) {
|
|
5073
|
+
return await Y(e) ? y.readFile(e, "utf-8") : "";
|
|
5066
5074
|
}
|
|
5067
|
-
async function
|
|
5075
|
+
async function bs(e) {
|
|
5068
5076
|
let t = T.join(T.dirname(e), ".env");
|
|
5069
|
-
return await
|
|
5077
|
+
return await Y(t) || await y.copyFile(e, t), t;
|
|
5070
5078
|
}
|
|
5071
|
-
async function
|
|
5072
|
-
let r =
|
|
5079
|
+
async function xs(e, t, n) {
|
|
5080
|
+
let r = vs(await ys(e), t, n);
|
|
5073
5081
|
await y.writeFile(e, r, "utf-8");
|
|
5074
5082
|
}
|
|
5075
5083
|
//#endregion
|
|
5076
5084
|
//#region src/commands/onboard.ts
|
|
5077
|
-
async function
|
|
5085
|
+
async function Ss(e = {}) {
|
|
5078
5086
|
let t = e.cwd ?? process.cwd();
|
|
5079
|
-
|
|
5087
|
+
Ua(), s.intro(L.brandBold("Onboard your stack"));
|
|
5080
5088
|
let n;
|
|
5081
5089
|
try {
|
|
5082
|
-
n = await
|
|
5090
|
+
n = await jr(t);
|
|
5083
5091
|
} catch {
|
|
5084
5092
|
n = null;
|
|
5085
5093
|
}
|
|
5086
|
-
n || (s.cancel(`${
|
|
5087
|
-
let r = n.installedPacks ?? [], i = n.onboarding?.envSections ?? [], a = await
|
|
5088
|
-
a.length === 0 && s.log.warn(
|
|
5089
|
-
for (let n of a) await
|
|
5094
|
+
n || (s.cancel(`${L.path("stack.json")} not found. Run ${L.command("npx @hype-stack/cli init")} first.`), process.exit(1));
|
|
5095
|
+
let r = n.installedPacks ?? [], i = n.onboarding?.envSections ?? [], a = await _o(t);
|
|
5096
|
+
a.length === 0 && s.log.warn(L.muted("No .env.example files found; skipping env setup."));
|
|
5097
|
+
for (let n of a) await Cs({
|
|
5090
5098
|
examplePath: n,
|
|
5091
5099
|
projectRoot: t,
|
|
5092
5100
|
skipPrompts: e.yes ?? !1,
|
|
5093
5101
|
installedEnvSections: i
|
|
5094
5102
|
});
|
|
5095
|
-
let o =
|
|
5096
|
-
o.length > 0 &&
|
|
5103
|
+
let o = Ar(r);
|
|
5104
|
+
o.length > 0 && z(o.map((e) => ` ${L.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await Es(t, e.yes ?? !1), s.outro(L.brand(`All set. Run ${L.command("pnpm dev")} to start your app.`));
|
|
5097
5105
|
}
|
|
5098
|
-
async function
|
|
5099
|
-
let { examplePath: t, projectRoot: n, skipPrompts: r, installedEnvSections: i } = e, a = T.relative(n, t) || t, o = await
|
|
5106
|
+
async function Cs(e) {
|
|
5107
|
+
let { examplePath: t, projectRoot: n, skipPrompts: r, installedEnvSections: i } = e, a = T.relative(n, t) || t, o = await bs(t), c = await ys(o), l = gs(await y.readFile(t, "utf-8")), u = L.path(a);
|
|
5100
5108
|
s.log.step(`Env: ${u}`);
|
|
5101
5109
|
for (let e of l) {
|
|
5102
5110
|
if (e.vars.length === 0) continue;
|
|
5103
|
-
if (!
|
|
5104
|
-
let t = e.section ?
|
|
5105
|
-
s.log.info(`${t} ${
|
|
5111
|
+
if (!Er(e.section, i)) {
|
|
5112
|
+
let t = e.section ? L.bold(e.section) : L.bold("Variables");
|
|
5113
|
+
s.log.info(`${t} ${L.muted("skipped (not owned by an installed pack)")}`);
|
|
5106
5114
|
continue;
|
|
5107
5115
|
}
|
|
5108
|
-
let t =
|
|
5109
|
-
s.log.step(n), t.link && (s.log.info(`${
|
|
5116
|
+
let t = Tr(e.section), n = e.section ? L.bold(e.section) : L.bold("Variables");
|
|
5117
|
+
s.log.step(n), t.link && (s.log.info(`${L.muted("Get your values:")} ${ve(t.link)}`), t.serviceChecklist && t.serviceChecklist.length > 0 && z(t.serviceChecklist.map((e) => ` ${L.muted("·")} ${e}`).join("\n"), "Setup")), s.log.info(L.muted(t.hint)), s.log.info(L.muted("Press Enter to keep the current value."));
|
|
5110
5118
|
for (let n of e.vars) {
|
|
5111
5119
|
if (r) {
|
|
5112
|
-
s.log.info(`${
|
|
5120
|
+
s.log.info(`${L.label(n.key)} ${L.muted("skipped (non-interactive)")}`);
|
|
5113
5121
|
continue;
|
|
5114
5122
|
}
|
|
5115
|
-
let e =
|
|
5116
|
-
message: `${
|
|
5117
|
-
placeholder: e ? `${e} ${
|
|
5123
|
+
let e = _s(ws(c, n.key)), i = await s.text({
|
|
5124
|
+
message: `${L.label(n.key)}`,
|
|
5125
|
+
placeholder: e ? `${e} ${L.muted("(Enter keeps this)")}` : t.hint
|
|
5118
5126
|
});
|
|
5119
|
-
s.isCancel(i) &&
|
|
5127
|
+
s.isCancel(i) && B();
|
|
5120
5128
|
let a = (i ?? "").trim();
|
|
5121
5129
|
if (a === "") {
|
|
5122
|
-
s.log.info(
|
|
5130
|
+
s.log.info(L.muted(`${n.key} unchanged.`));
|
|
5123
5131
|
continue;
|
|
5124
5132
|
}
|
|
5125
|
-
await
|
|
5133
|
+
await xs(o, n.key, a), s.log.success(`${n.key} saved`);
|
|
5126
5134
|
}
|
|
5127
5135
|
}
|
|
5128
5136
|
}
|
|
5129
|
-
function
|
|
5137
|
+
function ws(e, t) {
|
|
5130
5138
|
for (let n of e.split(/\r?\n/)) {
|
|
5131
|
-
let e = n.match(RegExp(`^${
|
|
5139
|
+
let e = n.match(RegExp(`^${Ts(t)}\\s*=\\s*(.*)$`));
|
|
5132
5140
|
if (e) return e[1].trim();
|
|
5133
5141
|
}
|
|
5134
5142
|
return "";
|
|
5135
5143
|
}
|
|
5136
|
-
function
|
|
5144
|
+
function Ts(e) {
|
|
5137
5145
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5138
5146
|
}
|
|
5139
|
-
async function
|
|
5140
|
-
if (!await
|
|
5141
|
-
s.log.info(
|
|
5147
|
+
async function Es(e, t) {
|
|
5148
|
+
if (!await ma() && !await ga(e, t, !1)) {
|
|
5149
|
+
s.log.info(L.muted(`Start services later with ${L.command("docker compose up -d")} (in apps/backend), then ${L.command("pnpm --filter @internal/backend migration:latest")}.`));
|
|
5142
5150
|
return;
|
|
5143
5151
|
}
|
|
5144
5152
|
let n = s.spinner();
|
|
5145
|
-
if (n.start("Waiting for Postgres to be ready..."), !await
|
|
5146
|
-
n.error("Postgres health check timed out"), s.log.warn(
|
|
5153
|
+
if (n.start("Waiting for Postgres to be ready..."), !await va(e)) {
|
|
5154
|
+
n.error("Postgres health check timed out"), s.log.warn(L.muted(`Run migrations manually once Postgres is ready: ${L.command("pnpm --filter @internal/backend migration:latest")}`));
|
|
5147
5155
|
return;
|
|
5148
5156
|
}
|
|
5149
|
-
if (n.stop(
|
|
5150
|
-
s.log.info(
|
|
5157
|
+
if (n.stop(L.success("Postgres is ready")), await ba(e)) {
|
|
5158
|
+
s.log.info(L.muted("Migrations already applied, skipping."));
|
|
5151
5159
|
return;
|
|
5152
5160
|
}
|
|
5153
5161
|
let r = t ? !0 : await s.confirm({
|
|
5154
|
-
message: `Run database migrations with ${
|
|
5162
|
+
message: `Run database migrations with ${L.command("prisma migrate deploy")}?`,
|
|
5155
5163
|
initialValue: !0
|
|
5156
5164
|
});
|
|
5157
|
-
if (s.isCancel(r) &&
|
|
5158
|
-
s.log.info(
|
|
5165
|
+
if (s.isCancel(r) && B(), !r) {
|
|
5166
|
+
s.log.info(L.muted("Skipping database migrations."));
|
|
5159
5167
|
return;
|
|
5160
5168
|
}
|
|
5161
|
-
await
|
|
5169
|
+
await xa(e);
|
|
5162
5170
|
}
|
|
5163
5171
|
//#endregion
|
|
5164
5172
|
//#region src/core/templates.ts
|
|
5165
|
-
var
|
|
5173
|
+
var Ds = q.createRequest()({
|
|
5166
5174
|
endpoint: "/templates/list",
|
|
5167
5175
|
method: "GET"
|
|
5168
5176
|
});
|
|
5169
|
-
async function
|
|
5170
|
-
let { data: e, error: t } = await
|
|
5177
|
+
async function Os() {
|
|
5178
|
+
let { data: e, error: t } = await Ds.send();
|
|
5171
5179
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
5172
5180
|
return e.templates;
|
|
5173
5181
|
}
|
|
5174
|
-
async function
|
|
5175
|
-
let { data: t, error: n, status: r } = await
|
|
5182
|
+
async function ks(e) {
|
|
5183
|
+
let { data: t, error: n, status: r } = await q.createRequest()({
|
|
5176
5184
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
5177
5185
|
method: "GET"
|
|
5178
5186
|
}).send();
|
|
@@ -5180,13 +5188,13 @@ async function Ds(e) {
|
|
|
5180
5188
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
5181
5189
|
return t;
|
|
5182
5190
|
}
|
|
5183
|
-
async function
|
|
5184
|
-
let n =
|
|
5191
|
+
async function As(e, t = {}) {
|
|
5192
|
+
let n = q.createRequest()({
|
|
5185
5193
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
5186
5194
|
method: "POST"
|
|
5187
5195
|
}), r = {
|
|
5188
|
-
"X-Device-Id":
|
|
5189
|
-
"X-Client-Info":
|
|
5196
|
+
"X-Device-Id": er(),
|
|
5197
|
+
"X-Client-Info": tr()
|
|
5190
5198
|
};
|
|
5191
5199
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
5192
5200
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -5208,29 +5216,29 @@ async function Os(e, t = {}) {
|
|
|
5208
5216
|
}
|
|
5209
5217
|
//#endregion
|
|
5210
5218
|
//#region src/commands/template.ts
|
|
5211
|
-
async function
|
|
5219
|
+
async function js(t = {}) {
|
|
5212
5220
|
let n = t.cwd ?? process.cwd();
|
|
5213
|
-
|
|
5221
|
+
Ua();
|
|
5214
5222
|
let r = s.spinner();
|
|
5215
5223
|
r.start("Loading packs...");
|
|
5216
5224
|
let o;
|
|
5217
5225
|
try {
|
|
5218
|
-
o = await
|
|
5226
|
+
o = await Ur();
|
|
5219
5227
|
} catch (e) {
|
|
5220
5228
|
r.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
5221
5229
|
}
|
|
5222
5230
|
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
5223
5231
|
let c;
|
|
5224
5232
|
try {
|
|
5225
|
-
c = await
|
|
5233
|
+
c = await Os();
|
|
5226
5234
|
} catch (e) {
|
|
5227
5235
|
r.stop("Failed to load templates"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
5228
5236
|
}
|
|
5229
5237
|
let l = t.templateId;
|
|
5230
5238
|
if (!l) {
|
|
5231
5239
|
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");
|
|
5232
|
-
let e =
|
|
5233
|
-
|
|
5240
|
+
let e = le();
|
|
5241
|
+
z(c.map((t) => ` ${R.arrow} ${L.highlight(t.name)} ${ve(`${e}/templates/${t.id}`)}`).join("\n"), "Browse templates");
|
|
5234
5242
|
let n = await s.select({
|
|
5235
5243
|
message: "Choose a template",
|
|
5236
5244
|
options: c.map((e) => ({
|
|
@@ -5245,151 +5253,151 @@ async function ks(t = {}) {
|
|
|
5245
5253
|
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}`);
|
|
5246
5254
|
let d;
|
|
5247
5255
|
try {
|
|
5248
|
-
d = await
|
|
5256
|
+
d = await ks(u.id);
|
|
5249
5257
|
} catch (e) {
|
|
5250
5258
|
s.cancel($(e)), process.exit(1);
|
|
5251
5259
|
}
|
|
5252
|
-
let f = await
|
|
5260
|
+
let f = await ss(n, {}, {
|
|
5253
5261
|
defaultTheme: d.theme,
|
|
5254
5262
|
defaultMode: d.defaultMode
|
|
5255
5263
|
}), p = f?.projectRoot ?? null, m = f?.scaffolded ?? !1, h;
|
|
5256
5264
|
try {
|
|
5257
|
-
h = await
|
|
5265
|
+
h = await jr(p ?? n);
|
|
5258
5266
|
} catch (e) {
|
|
5259
|
-
s.cancel(`Could not parse ${
|
|
5267
|
+
s.cancel(`Could not parse ${L.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
5260
5268
|
}
|
|
5261
|
-
h || (s.cancel(p ? `Could not read ${
|
|
5269
|
+
h || (s.cancel(p ? `Could not read ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), process.exit(1)), h.paths || (s.cancel(`${L.path("stack.json")} is missing ${L.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
5262
5270
|
let g = p ?? n;
|
|
5263
|
-
s.intro(
|
|
5264
|
-
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await
|
|
5271
|
+
s.intro(L.brandBold("Install a template"));
|
|
5272
|
+
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await Xn(F()))?.token ?? null, C = await Ms(u, t.variants, t.yes ?? !1), w = Aa(u.slots, C), E = ja(u.slots, u.packs, w), D = await Ns({
|
|
5265
5273
|
packs: o,
|
|
5266
5274
|
templatePacks: E,
|
|
5267
5275
|
installedSet: v,
|
|
5268
5276
|
options: t
|
|
5269
5277
|
}), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
|
|
5270
5278
|
k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
|
|
5271
|
-
let ee =
|
|
5279
|
+
let ee = Pa(o, w), A = Ea(ee), te;
|
|
5272
5280
|
try {
|
|
5273
|
-
te =
|
|
5281
|
+
te = Oa(O, A, _);
|
|
5274
5282
|
} catch (e) {
|
|
5275
5283
|
s.cancel($(e)), process.exit(1);
|
|
5276
5284
|
}
|
|
5277
5285
|
if (te.order.length === 0) {
|
|
5278
|
-
s.outro(
|
|
5286
|
+
s.outro(L.muted("Every pack in this template is already installed."));
|
|
5279
5287
|
return;
|
|
5280
5288
|
}
|
|
5281
|
-
let
|
|
5289
|
+
let ne = await Vo(ee, v, {
|
|
5282
5290
|
token: S,
|
|
5283
5291
|
key: x
|
|
5284
|
-
}),
|
|
5292
|
+
}), re = (e) => {
|
|
5285
5293
|
let t = b.get(e);
|
|
5286
|
-
return !t || t.tier === "free" ? "free" :
|
|
5287
|
-
},
|
|
5294
|
+
return !t || t.tier === "free" ? "free" : ne[e]?.owned ? "owned" : "locked";
|
|
5295
|
+
}, j = (e) => !v.has(e) && re(e) === "locked", M = ka({
|
|
5288
5296
|
order: te.order,
|
|
5289
5297
|
graph: A,
|
|
5290
|
-
isLocked:
|
|
5298
|
+
isLocked: j,
|
|
5291
5299
|
installed: _
|
|
5292
5300
|
});
|
|
5293
|
-
if (
|
|
5294
|
-
let e = await
|
|
5295
|
-
e && (S = e,
|
|
5301
|
+
if (M.blocked.length > 0 && !S && !x) {
|
|
5302
|
+
let e = await or();
|
|
5303
|
+
e && (S = e, ne = await Vo(ee, v, {
|
|
5296
5304
|
token: S,
|
|
5297
5305
|
key: x
|
|
5298
|
-
}),
|
|
5306
|
+
}), M = ka({
|
|
5299
5307
|
order: te.order,
|
|
5300
5308
|
graph: A,
|
|
5301
|
-
isLocked:
|
|
5309
|
+
isLocked: j,
|
|
5302
5310
|
installed: _
|
|
5303
5311
|
}));
|
|
5304
5312
|
}
|
|
5305
|
-
if (
|
|
5306
|
-
s.outro(
|
|
5313
|
+
if (M.blocked.length > 0 && await Uo(M.blocked, j, b), M.installable.length === 0) {
|
|
5314
|
+
s.outro(L.muted("Nothing left to install once locked packs are removed."));
|
|
5307
5315
|
return;
|
|
5308
5316
|
}
|
|
5309
|
-
if (
|
|
5310
|
-
let e = await s.confirm({ message: `Install template ${
|
|
5317
|
+
if (Wo(M.installable, b), !t.yes) {
|
|
5318
|
+
let e = await s.confirm({ message: `Install template ${L.brandBold(u.name)} (${M.installable.length} pack${M.installable.length === 1 ? "" : "s"})?` });
|
|
5311
5319
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5312
5320
|
}
|
|
5313
5321
|
r.start("Downloading packs...");
|
|
5314
|
-
let
|
|
5322
|
+
let N;
|
|
5315
5323
|
try {
|
|
5316
|
-
|
|
5324
|
+
N = await Go(M.installable, {
|
|
5317
5325
|
token: S,
|
|
5318
5326
|
key: x
|
|
5319
5327
|
});
|
|
5320
5328
|
} catch (e) {
|
|
5321
5329
|
r.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
5322
5330
|
}
|
|
5323
|
-
r.stop(`Downloaded ${
|
|
5324
|
-
let
|
|
5325
|
-
prepared:
|
|
5331
|
+
r.stop(`Downloaded ${N.length} pack${N.length === 1 ? "" : "s"}`);
|
|
5332
|
+
let ie = await Yo({
|
|
5333
|
+
prepared: N,
|
|
5326
5334
|
config: h,
|
|
5327
5335
|
cwd: g,
|
|
5328
5336
|
force: t.force ?? !1,
|
|
5329
5337
|
yes: t.yes ?? !1
|
|
5330
|
-
}),
|
|
5338
|
+
}), P = null;
|
|
5331
5339
|
try {
|
|
5332
5340
|
r.start("Installing pack files...");
|
|
5333
|
-
let n = await
|
|
5334
|
-
packs:
|
|
5341
|
+
let n = await ra({
|
|
5342
|
+
packs: N,
|
|
5335
5343
|
config: h,
|
|
5336
5344
|
projectRoot: g,
|
|
5337
5345
|
force: t.force ?? !1,
|
|
5338
|
-
overwrite:
|
|
5346
|
+
overwrite: ie
|
|
5339
5347
|
});
|
|
5340
5348
|
if (n.aborted) {
|
|
5341
5349
|
r.stop("Installation aborted");
|
|
5342
5350
|
for (let e of n.errors) s.log.error(e);
|
|
5343
5351
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5344
5352
|
}
|
|
5345
|
-
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${
|
|
5353
|
+
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${L.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && (s.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`), Jo(n.skipped));
|
|
5346
5354
|
for (let e of n.errors) s.log.error(e);
|
|
5347
5355
|
r.start("Applying template overrides...");
|
|
5348
|
-
let o = await
|
|
5356
|
+
let o = await As(u.id, {
|
|
5349
5357
|
token: S,
|
|
5350
5358
|
licenseKey: x
|
|
5351
5359
|
});
|
|
5352
|
-
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)),
|
|
5353
|
-
let c = await
|
|
5360
|
+
o.status === "denied" && (r.stop("Template download denied"), s.cancel(`Access to template "${u.id}" was denied (${o.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)), P = o.templateDir;
|
|
5361
|
+
let c = await aa({
|
|
5354
5362
|
manifest: d,
|
|
5355
5363
|
config: h,
|
|
5356
5364
|
projectRoot: g,
|
|
5357
|
-
templateDir:
|
|
5365
|
+
templateDir: P
|
|
5358
5366
|
});
|
|
5359
5367
|
r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
|
|
5360
5368
|
for (let e of c.errors) s.log.error(e);
|
|
5361
5369
|
if (!m) {
|
|
5362
5370
|
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5363
|
-
a(n) && (await
|
|
5371
|
+
a(n) && (await ao(t, i(n)) ? s.log.success(`Applied the ${i(n).label} theme`) : s.log.warning(L.muted(`Could not find ${L.path("assets/styles.css")} to apply the theme`)));
|
|
5364
5372
|
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5365
|
-
await
|
|
5373
|
+
await $a(t, r) ? s.log.success(`Default color mode set to ${r}`) : s.log.warning(L.muted(`Could not find ${L.path("src/hooks/use-theme.ts")} to set the default color mode`));
|
|
5366
5374
|
}
|
|
5367
|
-
await
|
|
5368
|
-
prepared:
|
|
5375
|
+
await Ps({
|
|
5376
|
+
prepared: N,
|
|
5369
5377
|
templateNpm: d.dependencies_npm,
|
|
5370
5378
|
paths: h.paths,
|
|
5371
5379
|
cwd: g,
|
|
5372
5380
|
spinner: r
|
|
5373
5381
|
});
|
|
5374
5382
|
let l;
|
|
5375
|
-
m && (l = await
|
|
5383
|
+
m && (l = await Ta(g, t.yes ?? !1)), await _r({
|
|
5376
5384
|
projectRoot: g,
|
|
5377
5385
|
paths: h.paths,
|
|
5378
5386
|
skipPrompts: t.yes ?? !1,
|
|
5379
5387
|
dbReady: l,
|
|
5380
5388
|
freshScaffold: m
|
|
5381
|
-
}),
|
|
5389
|
+
}), qo(), s.outro(L.brand(`Installed template ${u.name}.`));
|
|
5382
5390
|
} finally {
|
|
5383
|
-
await Promise.all(
|
|
5391
|
+
await Promise.all(N.map((e) => y.rm(e.packDir, {
|
|
5384
5392
|
recursive: !0,
|
|
5385
5393
|
force: !0
|
|
5386
|
-
}))),
|
|
5394
|
+
}))), P && await y.rm(P, {
|
|
5387
5395
|
recursive: !0,
|
|
5388
5396
|
force: !0
|
|
5389
5397
|
});
|
|
5390
5398
|
}
|
|
5391
5399
|
}
|
|
5392
|
-
async function
|
|
5400
|
+
async function Ms(e, t, n) {
|
|
5393
5401
|
let r = {};
|
|
5394
5402
|
for (let i of e.slots) {
|
|
5395
5403
|
if (t?.[i.family]) {
|
|
@@ -5413,7 +5421,7 @@ async function As(e, t, n) {
|
|
|
5413
5421
|
}
|
|
5414
5422
|
return r;
|
|
5415
5423
|
}
|
|
5416
|
-
async function
|
|
5424
|
+
async function Ns(e) {
|
|
5417
5425
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5418
5426
|
if (i.packs && i.packs.length > 0) {
|
|
5419
5427
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -5422,9 +5430,9 @@ async function js(e) {
|
|
|
5422
5430
|
if (i.yes) return [];
|
|
5423
5431
|
let o = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
|
|
5424
5432
|
if (o.length === 0) return [];
|
|
5425
|
-
let c =
|
|
5426
|
-
|
|
5427
|
-
let l = await
|
|
5433
|
+
let c = le();
|
|
5434
|
+
z(o.map((e) => ` ${R.arrow} ${L.highlight(e.displayName)} ${ve(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5435
|
+
let l = await Ka({
|
|
5428
5436
|
message: "Add extra packs on top of the template (optional)",
|
|
5429
5437
|
options: o.map((e) => ({
|
|
5430
5438
|
value: e.name,
|
|
@@ -5435,25 +5443,25 @@ async function js(e) {
|
|
|
5435
5443
|
});
|
|
5436
5444
|
return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
|
|
5437
5445
|
}
|
|
5438
|
-
async function
|
|
5439
|
-
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o =
|
|
5446
|
+
async function Ps(e) {
|
|
5447
|
+
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o = zo(t.map((e) => e.manifest.dependencies_npm)), c = Ro(n ? zo([o, n]) : o, r);
|
|
5440
5448
|
if (c.errors.length > 0) {
|
|
5441
5449
|
for (let e of c.errors) s.log.error(e);
|
|
5442
5450
|
return;
|
|
5443
5451
|
}
|
|
5444
5452
|
if (c.operations.length === 0) return;
|
|
5445
5453
|
a.start("Installing npm dependencies...");
|
|
5446
|
-
let l = await
|
|
5454
|
+
let l = await Bo(c.operations, i);
|
|
5447
5455
|
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) s.log.error(e);
|
|
5448
5456
|
}
|
|
5449
5457
|
//#endregion
|
|
5450
5458
|
//#region src/cli.ts
|
|
5451
|
-
function
|
|
5459
|
+
function Fs(e) {
|
|
5452
5460
|
if (!e) return;
|
|
5453
5461
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5454
5462
|
return t.length > 0 ? t : void 0;
|
|
5455
5463
|
}
|
|
5456
|
-
function
|
|
5464
|
+
function Is(e) {
|
|
5457
5465
|
if (!e) return;
|
|
5458
5466
|
let t = {};
|
|
5459
5467
|
for (let n of e.split(",")) {
|
|
@@ -5462,10 +5470,10 @@ function Ps(e) {
|
|
|
5462
5470
|
}
|
|
5463
5471
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5464
5472
|
}
|
|
5465
|
-
function
|
|
5473
|
+
function Ls() {
|
|
5466
5474
|
let e = new o();
|
|
5467
5475
|
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) => {
|
|
5468
|
-
await
|
|
5476
|
+
await as({
|
|
5469
5477
|
name: e.name,
|
|
5470
5478
|
directory: e.directory,
|
|
5471
5479
|
install: e.install,
|
|
@@ -5475,38 +5483,38 @@ function Fs() {
|
|
|
5475
5483
|
setup: e.setup
|
|
5476
5484
|
});
|
|
5477
5485
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5478
|
-
await
|
|
5486
|
+
await os({});
|
|
5479
5487
|
}), 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) => {
|
|
5480
|
-
await
|
|
5488
|
+
await Ss({
|
|
5481
5489
|
cwd: e.cwd,
|
|
5482
5490
|
yes: e.yes,
|
|
5483
5491
|
skipMigrations: e.skipMigrations
|
|
5484
5492
|
});
|
|
5485
5493
|
}), 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) => {
|
|
5486
|
-
await
|
|
5487
|
-
packs:
|
|
5494
|
+
await cs({
|
|
5495
|
+
packs: Fs(e.packs),
|
|
5488
5496
|
force: e.force,
|
|
5489
5497
|
yes: e.yes,
|
|
5490
5498
|
licenseKey: e.key ?? e.licenseKey,
|
|
5491
5499
|
cwd: e.cwd
|
|
5492
5500
|
});
|
|
5493
5501
|
}), 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) => {
|
|
5494
|
-
await
|
|
5502
|
+
await js({
|
|
5495
5503
|
templateId: e,
|
|
5496
|
-
variants:
|
|
5497
|
-
packs:
|
|
5504
|
+
variants: Is(t.variants),
|
|
5505
|
+
packs: Fs(t.packs),
|
|
5498
5506
|
force: t.force,
|
|
5499
5507
|
yes: t.yes,
|
|
5500
5508
|
licenseKey: t.key ?? t.licenseKey,
|
|
5501
5509
|
cwd: t.cwd
|
|
5502
5510
|
});
|
|
5503
5511
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5504
|
-
await
|
|
5512
|
+
await ms();
|
|
5505
5513
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5506
|
-
await
|
|
5514
|
+
await hs();
|
|
5507
5515
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5508
|
-
await
|
|
5516
|
+
await ms();
|
|
5509
5517
|
}), e;
|
|
5510
5518
|
}
|
|
5511
5519
|
//#endregion
|
|
5512
|
-
export {
|
|
5520
|
+
export { ss as a, cs as i, hs as n, os as o, ms as r, as as s, Ls as t };
|