@hype-stack/cli 0.5.11 → 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-DROj2oQA.js → cli-Cm8dj5Gp.js} +1125 -1158
- 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/core/codemods.d.ts +2 -12
- package/dist/core/codemods.d.ts.map +1 -1
- package/dist/core/installer.d.ts.map +1 -1
- package/dist/core/onboard-catalog.d.ts +10 -9
- package/dist/core/onboard-catalog.d.ts.map +1 -1
- package/dist/core/onboard-env.d.ts +8 -0
- package/dist/core/onboard-env.d.ts.map +1 -1
- package/dist/core/post-clone.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/types.d.ts +0 -2
- package/dist/types/types.d.ts.map +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.11", j = "gh:BetterTyped/hype-stack", te = "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,23 +336,23 @@ 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
354
|
let { initiallyFocused: t = H.initiallyFocused, initiallyOnline: n = H.initiallyOnline } = this.options || H;
|
|
339
|
-
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser =
|
|
355
|
+
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser = He();
|
|
340
356
|
}
|
|
341
357
|
initialize = () => {
|
|
342
358
|
let { focusEvent: e = H.focusEvent, onlineEvent: t = H.onlineEvent } = this.options || H;
|
|
@@ -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
|
},
|
|
@@ -391,14 +407,14 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
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,
|
|
@@ -1067,21 +1083,21 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1067
1083
|
requestId: t,
|
|
1068
1084
|
request: d
|
|
1069
1085
|
}), u;
|
|
1070
|
-
},
|
|
1086
|
+
}, te = (e) => {
|
|
1071
1087
|
u ||= +/* @__PURE__ */ new Date();
|
|
1072
1088
|
let t = +/* @__PURE__ */ new Date();
|
|
1073
1089
|
return p = w(p, e), E(u, t, {
|
|
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
|
-
onResponseProgress:
|
|
1193
|
-
onResponseEnd:
|
|
1194
|
-
onSuccess:
|
|
1195
|
-
onAbortError:
|
|
1196
|
-
onTimeoutError:
|
|
1197
|
-
onUnexpectedError:
|
|
1198
|
-
onError:
|
|
1208
|
+
onResponseProgress: te,
|
|
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,82 +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 ?
|
|
2586
|
-
}
|
|
2587
|
-
var Sr = new Set([
|
|
2588
|
-
Y.Config,
|
|
2589
|
-
Y.Databases,
|
|
2590
|
-
Y.Sentry,
|
|
2591
|
-
Y.Resend
|
|
2592
|
-
]);
|
|
2593
|
-
function Cr(e, t) {
|
|
2594
|
-
let n = vr(e);
|
|
2595
|
-
return n && Sr.has(n) || t.length === 0 ? !0 : n ? t.includes(n) : !1;
|
|
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;
|
|
2596
2602
|
}
|
|
2597
|
-
function
|
|
2603
|
+
function Er(e, t) {
|
|
2604
|
+
if (t.length === 0) return !0;
|
|
2605
|
+
let n = Sr(e);
|
|
2606
|
+
return n ? t.includes(n) : !1;
|
|
2607
|
+
}
|
|
2608
|
+
function Dr(e) {
|
|
2598
2609
|
return e ? e.map((e) => {
|
|
2599
|
-
let t =
|
|
2600
|
-
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(", ")}.`);
|
|
2601
2612
|
return t;
|
|
2602
2613
|
}) : [];
|
|
2603
2614
|
}
|
|
2604
|
-
function
|
|
2615
|
+
function Or(e) {
|
|
2605
2616
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2606
2617
|
for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
2607
2618
|
return n;
|
|
2608
2619
|
}
|
|
2609
|
-
var
|
|
2620
|
+
var kr = {
|
|
2610
2621
|
"starter-saas-workos": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
2611
2622
|
"starter-saas-betterauth": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
2612
2623
|
"pack-notifications": ["Notifications push over the `appChannel` socket channel; register it in your server startup to go live."],
|
|
2613
2624
|
"pack-collaboration": ["Team and TeamMember are available as CASL subjects; project member and team management reuse the existing `Project` subject."]
|
|
2614
2625
|
};
|
|
2615
|
-
function
|
|
2626
|
+
function Ar(e) {
|
|
2616
2627
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2617
2628
|
for (let r of e) {
|
|
2618
|
-
let e =
|
|
2629
|
+
let e = kr[r];
|
|
2619
2630
|
if (e) for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
2620
2631
|
}
|
|
2621
2632
|
return n;
|
|
2622
2633
|
}
|
|
2623
2634
|
//#endregion
|
|
2624
2635
|
//#region src/core/stack-config.ts
|
|
2625
|
-
async function
|
|
2626
|
-
return
|
|
2636
|
+
async function jr(e) {
|
|
2637
|
+
return dr(T.join(e, ne));
|
|
2627
2638
|
}
|
|
2628
|
-
async function
|
|
2629
|
-
return
|
|
2639
|
+
async function Mr(e) {
|
|
2640
|
+
return Y(T.join(e, ne));
|
|
2630
2641
|
}
|
|
2631
|
-
async function
|
|
2632
|
-
await
|
|
2642
|
+
async function Nr(e, t) {
|
|
2643
|
+
await fr(T.join(e, ne), t);
|
|
2633
2644
|
}
|
|
2634
|
-
async function
|
|
2635
|
-
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)]);
|
|
2636
2647
|
return {
|
|
2637
2648
|
apps: r,
|
|
2638
2649
|
packages: i
|
|
2639
2650
|
};
|
|
2640
2651
|
}
|
|
2641
|
-
function
|
|
2652
|
+
function Fr(e) {
|
|
2642
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";
|
|
2643
2654
|
return {
|
|
2644
2655
|
backend: {
|
|
@@ -2672,23 +2683,23 @@ function Mr(e) {
|
|
|
2672
2683
|
}
|
|
2673
2684
|
};
|
|
2674
2685
|
}
|
|
2675
|
-
function
|
|
2686
|
+
function Ir(e, t) {
|
|
2676
2687
|
return {
|
|
2677
|
-
$schema:
|
|
2688
|
+
$schema: de(),
|
|
2678
2689
|
version: 1,
|
|
2679
2690
|
name: e,
|
|
2680
2691
|
apps: t.apps,
|
|
2681
2692
|
packages: t.packages,
|
|
2682
|
-
paths:
|
|
2693
|
+
paths: Fr(t),
|
|
2683
2694
|
installedPacks: [],
|
|
2684
2695
|
licenseKey: null
|
|
2685
2696
|
};
|
|
2686
2697
|
}
|
|
2687
|
-
async function
|
|
2688
|
-
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)]);
|
|
2689
2700
|
return r && i;
|
|
2690
2701
|
}
|
|
2691
|
-
function
|
|
2702
|
+
function Z(e, t) {
|
|
2692
2703
|
return e.replace(/\{\{(\w+)\.(\w+)\}\}/g, (n, r, i) => {
|
|
2693
2704
|
let a = t[r];
|
|
2694
2705
|
if (!a) throw Error(`Unknown app "${r}" in path template "${e}"`);
|
|
@@ -2699,8 +2710,8 @@ function X(e, t) {
|
|
|
2699
2710
|
}
|
|
2700
2711
|
//#endregion
|
|
2701
2712
|
//#region src/core/registry.ts
|
|
2702
|
-
async function
|
|
2703
|
-
let { data: t, error: n, status: r } = await
|
|
2713
|
+
async function Rr(e) {
|
|
2714
|
+
let { data: t, error: n, status: r } = await q.createRequest()({
|
|
2704
2715
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2705
2716
|
method: "GET"
|
|
2706
2717
|
}).send();
|
|
@@ -2708,13 +2719,13 @@ async function Fr(e) {
|
|
|
2708
2719
|
if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
|
|
2709
2720
|
return t;
|
|
2710
2721
|
}
|
|
2711
|
-
async function
|
|
2712
|
-
let n =
|
|
2722
|
+
async function zr(e, t = {}) {
|
|
2723
|
+
let n = q.createRequest()({
|
|
2713
2724
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2714
2725
|
method: "POST"
|
|
2715
2726
|
}), r = {
|
|
2716
|
-
"X-Device-Id":
|
|
2717
|
-
"X-Client-Info":
|
|
2727
|
+
"X-Device-Id": er(),
|
|
2728
|
+
"X-Client-Info": tr()
|
|
2718
2729
|
};
|
|
2719
2730
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2720
2731
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -2734,25 +2745,25 @@ async function Ir(e, t = {}) {
|
|
|
2734
2745
|
packDir: s
|
|
2735
2746
|
};
|
|
2736
2747
|
}
|
|
2737
|
-
function
|
|
2738
|
-
let r =
|
|
2748
|
+
function Br(e, t, n) {
|
|
2749
|
+
let r = Z(e, t);
|
|
2739
2750
|
return T.resolve(n, r);
|
|
2740
2751
|
}
|
|
2741
|
-
function
|
|
2752
|
+
function Vr(e, t) {
|
|
2742
2753
|
return T.join(t, e);
|
|
2743
2754
|
}
|
|
2744
|
-
var
|
|
2755
|
+
var Hr = q.createRequest()({
|
|
2745
2756
|
endpoint: "/packs/list",
|
|
2746
2757
|
method: "GET"
|
|
2747
2758
|
});
|
|
2748
|
-
async function
|
|
2749
|
-
let { data: e, error: t } = await
|
|
2759
|
+
async function Ur() {
|
|
2760
|
+
let { data: e, error: t } = await Hr.send();
|
|
2750
2761
|
if (t || !e) throw Error(`Failed to fetch pack list: ${String(t)}`);
|
|
2751
2762
|
return e.packs;
|
|
2752
2763
|
}
|
|
2753
|
-
async function
|
|
2764
|
+
async function Wr(e, t = {}) {
|
|
2754
2765
|
if (e.length === 0) return {};
|
|
2755
|
-
let n =
|
|
2766
|
+
let n = q.createRequest()({
|
|
2756
2767
|
endpoint: "/packs/authorize",
|
|
2757
2768
|
method: "POST"
|
|
2758
2769
|
}), r = {};
|
|
@@ -2766,30 +2777,33 @@ async function Vr(e, t = {}) {
|
|
|
2766
2777
|
}
|
|
2767
2778
|
//#endregion
|
|
2768
2779
|
//#region src/core/codemods.ts
|
|
2769
|
-
var
|
|
2770
|
-
function
|
|
2771
|
-
return
|
|
2780
|
+
var Gr = "@hype-stack/", Kr = /@hype-stack\/(?!cli\b)/g;
|
|
2781
|
+
function qr(e, t) {
|
|
2782
|
+
return e.replace(Kr, t);
|
|
2783
|
+
}
|
|
2784
|
+
function Jr(e, t) {
|
|
2785
|
+
return Z(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
|
|
2772
2786
|
}
|
|
2773
|
-
async function
|
|
2774
|
-
let r =
|
|
2775
|
-
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)) {
|
|
2776
2790
|
let t = await y.readFile(i, "utf-8");
|
|
2777
|
-
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));
|
|
2778
2792
|
await y.writeFile(i, t, "utf-8");
|
|
2779
2793
|
}
|
|
2780
|
-
if (await Promise.all([a, o].map((t) =>
|
|
2794
|
+
if (await Promise.all([a, o].map((t) => Qr(t, e))), await Y(s)) {
|
|
2781
2795
|
let t = await y.readFile(s, "utf-8");
|
|
2782
|
-
for (let n of e) t =
|
|
2796
|
+
for (let n of e) t = ei(t, n);
|
|
2783
2797
|
await y.writeFile(s, t, "utf-8");
|
|
2784
2798
|
}
|
|
2785
2799
|
}
|
|
2786
|
-
function
|
|
2800
|
+
function Xr(e, t) {
|
|
2787
2801
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2788
2802
|
if (r === -1) return n + "\n" + e;
|
|
2789
2803
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2790
2804
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2791
2805
|
}
|
|
2792
|
-
function
|
|
2806
|
+
function Zr(e, t) {
|
|
2793
2807
|
let n = `.extend(${t.import}.shape)`;
|
|
2794
2808
|
if (e.includes(n)) return e;
|
|
2795
2809
|
let r = e.indexOf("export const envSchema = z.object({");
|
|
@@ -2804,33 +2818,33 @@ function Kr(e, t) {
|
|
|
2804
2818
|
let o = a + 2;
|
|
2805
2819
|
return e.slice(0, o) + n + e.slice(o);
|
|
2806
2820
|
}
|
|
2807
|
-
async function
|
|
2808
|
-
if (!await
|
|
2821
|
+
async function Qr(e, t) {
|
|
2822
|
+
if (!await Y(e)) return;
|
|
2809
2823
|
let n = await y.readFile(e, "utf-8");
|
|
2810
|
-
for (let e of t) n =
|
|
2824
|
+
for (let e of t) n = $r(n, e);
|
|
2811
2825
|
await y.writeFile(e, n, "utf-8");
|
|
2812
2826
|
}
|
|
2813
|
-
function
|
|
2827
|
+
function $r(e, t) {
|
|
2814
2828
|
for (let n of Object.keys(t.envExample.vars)) if (e.includes(`${n}=`)) return e;
|
|
2815
2829
|
let n = [];
|
|
2816
|
-
n.push(""), n.push(`# ${
|
|
2830
|
+
n.push(""), n.push(`# ${yr[t.envExample.section]}`);
|
|
2817
2831
|
for (let [e, r] of Object.entries(t.envExample.vars)) n.push(`${e}=${r}`);
|
|
2818
2832
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2819
2833
|
}
|
|
2820
|
-
function
|
|
2834
|
+
function ei(e, t) {
|
|
2821
2835
|
for (let n of Object.keys(t.envTest)) if (e.includes(`${n}=`)) return e;
|
|
2822
2836
|
let n = [""];
|
|
2823
2837
|
for (let [e, r] of Object.entries(t.envTest)) n.push(`${e}=${r}`);
|
|
2824
2838
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2825
2839
|
}
|
|
2826
|
-
async function
|
|
2827
|
-
let r = T.resolve(n,
|
|
2828
|
-
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;
|
|
2829
2843
|
let i = await y.readFile(r, "utf-8");
|
|
2830
|
-
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));
|
|
2831
2845
|
await y.writeFile(r, i, "utf-8");
|
|
2832
2846
|
}
|
|
2833
|
-
function
|
|
2847
|
+
function ni(e, t) {
|
|
2834
2848
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2835
2849
|
if (r !== -1) {
|
|
2836
2850
|
let t = e.indexOf("\n", r);
|
|
@@ -2839,7 +2853,7 @@ function Zr(e, t) {
|
|
|
2839
2853
|
let i = e.indexOf("export const registerRoutes");
|
|
2840
2854
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2841
2855
|
}
|
|
2842
|
-
function
|
|
2856
|
+
function ri(e, t) {
|
|
2843
2857
|
let n = `.route("${t.prefix}", ${t.import})`, r = e.match(/\.route\([^)]+\);/g);
|
|
2844
2858
|
if (r) {
|
|
2845
2859
|
let t = r[r.length - 1], i = e.lastIndexOf(t) + t.length - 1;
|
|
@@ -2847,14 +2861,14 @@ function Qr(e, t) {
|
|
|
2847
2861
|
}
|
|
2848
2862
|
return e.replace("return app;", `return app\n ${n};`);
|
|
2849
2863
|
}
|
|
2850
|
-
async function
|
|
2851
|
-
let r = T.resolve(n,
|
|
2852
|
-
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;
|
|
2853
2867
|
let i = await y.readFile(r, "utf-8");
|
|
2854
|
-
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));
|
|
2855
2869
|
await y.writeFile(r, i, "utf-8");
|
|
2856
2870
|
}
|
|
2857
|
-
function
|
|
2871
|
+
function ai(e, t) {
|
|
2858
2872
|
let n = `import { ${t.typeImport.name} } from "${t.typeImport.from}";`;
|
|
2859
2873
|
if (e.includes(`from "${t.typeImport.from}"`)) return e;
|
|
2860
2874
|
let r = e.lastIndexOf("import ");
|
|
@@ -2862,7 +2876,7 @@ function ei(e, t) {
|
|
|
2862
2876
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2863
2877
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2864
2878
|
}
|
|
2865
|
-
function
|
|
2879
|
+
function oi(e, t) {
|
|
2866
2880
|
let n = `export let ${t.export}: ${t.type};`, r = e.lastIndexOf("export let ");
|
|
2867
2881
|
if (r === -1) {
|
|
2868
2882
|
let t = e.indexOf("export const setupContext");
|
|
@@ -2871,15 +2885,15 @@ function ti(e, t) {
|
|
|
2871
2885
|
let i = e.indexOf("\n", r);
|
|
2872
2886
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2873
2887
|
}
|
|
2874
|
-
function
|
|
2888
|
+
function si(e, t) {
|
|
2875
2889
|
let n = ` ${t.export} = ${t.init};`, r = e.match(/export const setupContext\s*=\s*async\s*\([^)]*\)\s*=>\s*\{/);
|
|
2876
2890
|
if (!r) return e;
|
|
2877
2891
|
let i = e.indexOf("{", e.indexOf(r[0]));
|
|
2878
2892
|
if (i === -1) return e;
|
|
2879
|
-
let a =
|
|
2893
|
+
let a = ci(e, i);
|
|
2880
2894
|
return a === -1 ? e : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2881
2895
|
}
|
|
2882
|
-
function
|
|
2896
|
+
function ci(e, t) {
|
|
2883
2897
|
let n = 0;
|
|
2884
2898
|
for (let r = t; r < e.length; r++) {
|
|
2885
2899
|
let t = e[r];
|
|
@@ -2888,63 +2902,20 @@ function ri(e, t) {
|
|
|
2888
2902
|
}
|
|
2889
2903
|
return -1;
|
|
2890
2904
|
}
|
|
2891
|
-
function
|
|
2905
|
+
function li(e, t) {
|
|
2892
2906
|
let n = ` ${t.export}: ${t.type};`, r = e.indexOf("export type ContextVariables = {");
|
|
2893
2907
|
if (r === -1) return e;
|
|
2894
2908
|
let i = e.indexOf("};", r);
|
|
2895
2909
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2896
2910
|
}
|
|
2897
|
-
async function
|
|
2898
|
-
let r = T.resolve(n,
|
|
2899
|
-
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;
|
|
2900
2914
|
let i = await y.readFile(r, "utf-8");
|
|
2901
|
-
for (let t of e) i =
|
|
2915
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = di(i, t));
|
|
2902
2916
|
await y.writeFile(r, i, "utf-8");
|
|
2903
2917
|
}
|
|
2904
|
-
function oi(e, t) {
|
|
2905
|
-
let n = si(t), r = RegExp(`^[ \\t]*export let ${n}[ \\t]*:[ \\t]*([^;\\n]+);[ \\t]*$`, "m"), i = e.match(r)?.[1] ?? "", a = e;
|
|
2906
|
-
a = ci(a, r), a = ci(a, RegExp(`^[ \\t]*${n}[ \\t]*:[ \\t]*[^;\\n]+;[ \\t]*$`, "m")), a = ci(a, RegExp(`^[ \\t]*${n}[ \\t]*=[ \\t]*[^;\\n]*;[ \\t]*$`, "m"));
|
|
2907
|
-
for (let e of li(i)) ui(a, e) || (a = di(a, e));
|
|
2908
|
-
return a;
|
|
2909
|
-
}
|
|
2910
|
-
function si(e) {
|
|
2911
|
-
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2912
|
-
}
|
|
2913
|
-
function ci(e, t) {
|
|
2914
|
-
let n = t.exec(e);
|
|
2915
|
-
if (!n || n.index === void 0) return e;
|
|
2916
|
-
let r = n.index, i = r + n[0].length;
|
|
2917
|
-
return e[i] === "\n" && (i += 1), e.slice(0, r) + e.slice(i);
|
|
2918
|
-
}
|
|
2919
|
-
function li(e) {
|
|
2920
|
-
let t = e.match(/[A-Za-z_$][A-Za-z0-9_$]*/g) ?? [];
|
|
2921
|
-
return [...new Set(t)];
|
|
2922
|
-
}
|
|
2923
|
-
function ui(e, t) {
|
|
2924
|
-
let n = RegExp(`\\b${si(t)}\\b`);
|
|
2925
|
-
return e.split("\n").filter((e) => !e.trimStart().startsWith("import ")).some((e) => n.test(e));
|
|
2926
|
-
}
|
|
2927
2918
|
function di(e, t) {
|
|
2928
|
-
let n = RegExp(`\\b${si(t)}\\b`);
|
|
2929
|
-
return e.split("\n").flatMap((e) => {
|
|
2930
|
-
if (!e.trimStart().startsWith("import ") || !n.test(e)) return [e];
|
|
2931
|
-
let r = e.match(/^(\s*import\s+(?:type\s+)?)\{([^}]*)\}(\s+from\s+["'][^"']+["'];?\s*)$/);
|
|
2932
|
-
if (r) {
|
|
2933
|
-
let e = r[2].split(",").map((e) => e.trim()).filter(Boolean).filter((e) => e.replace(/^type\s+/, "") !== t);
|
|
2934
|
-
return e.length === 0 ? [] : [`${r[1]}{ ${e.join(", ")} }${r[3]}`];
|
|
2935
|
-
}
|
|
2936
|
-
let i = e.match(/^\s*import\s+(?:type\s+)?([A-Za-z0-9_$]+)\s+from\s+["'][^"']+["'];?\s*$/);
|
|
2937
|
-
return i && i[1] === t ? [] : [e];
|
|
2938
|
-
}).join("\n");
|
|
2939
|
-
}
|
|
2940
|
-
async function fi(e, t, n) {
|
|
2941
|
-
let r = T.resolve(n, X("{{enums.src}}", t), "index.ts");
|
|
2942
|
-
if (!await J(r)) return;
|
|
2943
|
-
let i = await y.readFile(r, "utf-8");
|
|
2944
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i = pi(i, t));
|
|
2945
|
-
await y.writeFile(r, i, "utf-8");
|
|
2946
|
-
}
|
|
2947
|
-
function pi(e, t) {
|
|
2948
2919
|
let n = `export * from "${t.from}";`, r = e.lastIndexOf("export * from");
|
|
2949
2920
|
if (r !== -1) {
|
|
2950
2921
|
let t = e.indexOf("\n", r);
|
|
@@ -2952,14 +2923,14 @@ function pi(e, t) {
|
|
|
2952
2923
|
}
|
|
2953
2924
|
return e.trim() === "" ? n + "\n" : e.trimEnd() + "\n" + n + "\n";
|
|
2954
2925
|
}
|
|
2955
|
-
async function
|
|
2956
|
-
let r =
|
|
2957
|
-
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;
|
|
2958
2929
|
let a = await y.readFile(i, "utf-8");
|
|
2959
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2960
|
-
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");
|
|
2961
2932
|
}
|
|
2962
|
-
function
|
|
2933
|
+
function pi(e, t) {
|
|
2963
2934
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2964
2935
|
if (r !== -1) {
|
|
2965
2936
|
let t = e.indexOf("\n", r);
|
|
@@ -2968,7 +2939,7 @@ function hi(e, t) {
|
|
|
2968
2939
|
let i = e.indexOf("const sockets");
|
|
2969
2940
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2970
2941
|
}
|
|
2971
|
-
function
|
|
2942
|
+
function mi(e, t) {
|
|
2972
2943
|
let n = `.socket("${t.prefix}", ${t.import})`, r = e.indexOf("const sockets");
|
|
2973
2944
|
if (r === -1) return e;
|
|
2974
2945
|
let i = e.indexOf("new SocketRouter", r);
|
|
@@ -2982,7 +2953,7 @@ function gi(e, t) {
|
|
|
2982
2953
|
}
|
|
2983
2954
|
return e;
|
|
2984
2955
|
}
|
|
2985
|
-
function
|
|
2956
|
+
function hi(e) {
|
|
2986
2957
|
if (e.includes("wsAuthenticate")) return e;
|
|
2987
2958
|
let t = e.indexOf("from \"@backend/libs/websocket/socket-router\""), n = e;
|
|
2988
2959
|
if (t !== -1) {
|
|
@@ -2991,14 +2962,14 @@ function _i(e) {
|
|
|
2991
2962
|
}
|
|
2992
2963
|
return n.replace("new SocketRouter()", "new SocketRouter({ authenticate: wsAuthenticate })");
|
|
2993
2964
|
}
|
|
2994
|
-
async function
|
|
2995
|
-
let r =
|
|
2996
|
-
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;
|
|
2997
2968
|
let a = await y.readFile(i, "utf-8");
|
|
2998
|
-
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));
|
|
2999
2970
|
await y.writeFile(i, a, "utf-8");
|
|
3000
2971
|
}
|
|
3001
|
-
function
|
|
2972
|
+
function _i(e, t) {
|
|
3002
2973
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
3003
2974
|
if (e.includes(n)) return e;
|
|
3004
2975
|
let r = e.lastIndexOf("from \"./");
|
|
@@ -3009,20 +2980,20 @@ function yi(e, t) {
|
|
|
3009
2980
|
let i = e.indexOf("export const sdk");
|
|
3010
2981
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
3011
2982
|
}
|
|
3012
|
-
function
|
|
2983
|
+
function vi(e, t) {
|
|
3013
2984
|
let n = `.$configure(${t.import})`, r = e.indexOf("export const sdk");
|
|
3014
2985
|
if (r === -1) return e;
|
|
3015
2986
|
let i = e.indexOf(";", r);
|
|
3016
2987
|
return i === -1 ? e : e.slice(0, i) + "\n " + n + e.slice(i);
|
|
3017
2988
|
}
|
|
3018
|
-
async function
|
|
3019
|
-
let r = T.resolve(n,
|
|
3020
|
-
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;
|
|
3021
2992
|
let i = await y.readFile(r, "utf-8");
|
|
3022
|
-
for (let t of e) i.includes(`"${t.path}"`) || (i =
|
|
2993
|
+
for (let t of e) i.includes(`"${t.path}"`) || (i = bi(i, t));
|
|
3023
2994
|
await y.writeFile(r, i, "utf-8");
|
|
3024
2995
|
}
|
|
3025
|
-
function
|
|
2996
|
+
function bi(e, t) {
|
|
3026
2997
|
let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
|
|
3027
2998
|
if (r === -1) return e;
|
|
3028
2999
|
let i = e.indexOf("{", r);
|
|
@@ -3038,38 +3009,38 @@ function Si(e, t) {
|
|
|
3038
3009
|
}
|
|
3039
3010
|
return o === -1 ? e : e.slice(0, o) + n + "\n" + e.slice(o);
|
|
3040
3011
|
}
|
|
3041
|
-
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 = {
|
|
3042
3013
|
primary: "primaryNav",
|
|
3043
3014
|
secondary: "secondaryNav",
|
|
3044
3015
|
tertiary: "tertiaryNav",
|
|
3045
3016
|
settings: "settingsNav"
|
|
3046
3017
|
};
|
|
3047
|
-
async function
|
|
3048
|
-
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
3049
|
-
await
|
|
3050
|
-
for (let e of t) s.includes(`label: "${e.label}"`) || (s =
|
|
3051
|
-
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));
|
|
3052
3023
|
await y.writeFile(o, s, "utf-8");
|
|
3053
3024
|
}
|
|
3054
|
-
async function
|
|
3055
|
-
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
3056
|
-
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;
|
|
3057
3028
|
let s = await y.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
|
|
3058
3029
|
if (!c.test(s)) return;
|
|
3059
3030
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
3060
3031
|
await y.writeFile(o, l, "utf-8");
|
|
3061
3032
|
}
|
|
3062
|
-
function
|
|
3033
|
+
function Ti(e) {
|
|
3063
3034
|
let t = [e.icon];
|
|
3064
3035
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
3065
3036
|
return t;
|
|
3066
3037
|
}
|
|
3067
|
-
function
|
|
3068
|
-
let n =
|
|
3069
|
-
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);
|
|
3070
3041
|
return r;
|
|
3071
3042
|
}
|
|
3072
|
-
function
|
|
3043
|
+
function Di(e, t) {
|
|
3073
3044
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
3074
3045
|
if (!n) return e;
|
|
3075
3046
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -3077,21 +3048,21 @@ function ki(e, t) {
|
|
|
3077
3048
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
3078
3049
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
3079
3050
|
}
|
|
3080
|
-
function
|
|
3081
|
-
let n =
|
|
3051
|
+
function Oi(e, t) {
|
|
3052
|
+
let n = Si[t.group];
|
|
3082
3053
|
if (!n) return e;
|
|
3083
|
-
let r =
|
|
3054
|
+
let r = Ai(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
|
|
3084
3055
|
if (!a) return e;
|
|
3085
|
-
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);
|
|
3086
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);
|
|
3087
3058
|
}
|
|
3088
|
-
function
|
|
3059
|
+
function ki(e, t) {
|
|
3089
3060
|
let n = 0;
|
|
3090
3061
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3091
3062
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3092
3063
|
return -1;
|
|
3093
3064
|
}
|
|
3094
|
-
function
|
|
3065
|
+
function Ai(e) {
|
|
3095
3066
|
let t = [];
|
|
3096
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) {
|
|
3097
3068
|
t.push(" items: [");
|
|
@@ -3107,14 +3078,14 @@ function Mi(e) {
|
|
|
3107
3078
|
} else t.push(" items: [],");
|
|
3108
3079
|
return t.push(" },"), t.join("\n");
|
|
3109
3080
|
}
|
|
3110
|
-
async function
|
|
3111
|
-
let r =
|
|
3112
|
-
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;
|
|
3113
3084
|
let a = await y.readFile(i, "utf-8");
|
|
3114
|
-
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));
|
|
3115
3086
|
await y.writeFile(i, a, "utf-8");
|
|
3116
3087
|
}
|
|
3117
|
-
function
|
|
3088
|
+
function Mi(e, t) {
|
|
3118
3089
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
3119
3090
|
if (r !== -1) {
|
|
3120
3091
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -3122,38 +3093,38 @@ function Pi(e, t) {
|
|
|
3122
3093
|
}
|
|
3123
3094
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
3124
3095
|
}
|
|
3125
|
-
function
|
|
3096
|
+
function Ni(e, t) {
|
|
3126
3097
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
3127
3098
|
if (!r) return e;
|
|
3128
|
-
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);
|
|
3129
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);
|
|
3130
3101
|
}
|
|
3131
|
-
function
|
|
3102
|
+
function Pi(e, t) {
|
|
3132
3103
|
let n = 0;
|
|
3133
3104
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3134
3105
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3135
3106
|
return -1;
|
|
3136
3107
|
}
|
|
3137
|
-
var
|
|
3138
|
-
async function
|
|
3139
|
-
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({
|
|
3140
3111
|
...e,
|
|
3141
3112
|
arrayName: "navbarActions"
|
|
3142
3113
|
});
|
|
3143
3114
|
}
|
|
3144
|
-
async function
|
|
3145
|
-
await
|
|
3115
|
+
async function Li(e) {
|
|
3116
|
+
await Ri({
|
|
3146
3117
|
...e,
|
|
3147
3118
|
arrayName: "userMenuActions"
|
|
3148
3119
|
});
|
|
3149
3120
|
}
|
|
3150
|
-
async function
|
|
3151
|
-
let a =
|
|
3152
|
-
await
|
|
3153
|
-
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);
|
|
3154
3125
|
await y.writeFile(o, s, "utf-8");
|
|
3155
3126
|
}
|
|
3156
|
-
function
|
|
3127
|
+
function zi(e, t) {
|
|
3157
3128
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
3158
3129
|
if (e.includes(n)) return e;
|
|
3159
3130
|
let r = e.lastIndexOf("import ");
|
|
@@ -3161,38 +3132,38 @@ function Vi(e, t) {
|
|
|
3161
3132
|
let i = e.indexOf("\n", r);
|
|
3162
3133
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
3163
3134
|
}
|
|
3164
|
-
function
|
|
3135
|
+
function Bi(e, t, n) {
|
|
3165
3136
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
3166
3137
|
if (!r) return e;
|
|
3167
|
-
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);
|
|
3168
3139
|
if (a === -1) return e;
|
|
3169
3140
|
let o = e.slice(i, a);
|
|
3170
3141
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
3171
3142
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
3172
3143
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
3173
3144
|
}
|
|
3174
|
-
function
|
|
3145
|
+
function Vi(e, t) {
|
|
3175
3146
|
let n = 0;
|
|
3176
3147
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3177
3148
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3178
3149
|
return -1;
|
|
3179
3150
|
}
|
|
3180
|
-
var
|
|
3151
|
+
var Hi = new Set([
|
|
3181
3152
|
".ts",
|
|
3182
3153
|
".tsx",
|
|
3183
3154
|
".js",
|
|
3184
3155
|
".jsx"
|
|
3185
3156
|
]);
|
|
3186
|
-
async function
|
|
3157
|
+
async function Ui(e) {
|
|
3187
3158
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
3188
3159
|
if (i === "hype-stack") return;
|
|
3189
3160
|
let a = `@${i}/`;
|
|
3190
3161
|
await Promise.all(t.map(async (e) => {
|
|
3191
|
-
let t =
|
|
3192
|
-
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);
|
|
3193
3164
|
}));
|
|
3194
3165
|
}
|
|
3195
|
-
var
|
|
3166
|
+
var Wi = new Set([
|
|
3196
3167
|
".git",
|
|
3197
3168
|
"node_modules",
|
|
3198
3169
|
"dist",
|
|
@@ -3201,43 +3172,43 @@ var Ki = new Set([
|
|
|
3201
3172
|
".next",
|
|
3202
3173
|
"coverage"
|
|
3203
3174
|
]);
|
|
3204
|
-
async function
|
|
3205
|
-
t !== "hype-stack" && await
|
|
3175
|
+
async function Gi(e, t) {
|
|
3176
|
+
t !== "hype-stack" && await Ki(e, `@${t}/`);
|
|
3206
3177
|
}
|
|
3207
|
-
async function
|
|
3178
|
+
async function Ki(e, t) {
|
|
3208
3179
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3209
3180
|
await Promise.all(n.map(async (n) => {
|
|
3210
3181
|
let r = T.join(e, n.name);
|
|
3211
3182
|
if (n.isDirectory()) {
|
|
3212
|
-
if (
|
|
3213
|
-
await
|
|
3214
|
-
} 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);
|
|
3215
3186
|
}));
|
|
3216
3187
|
}
|
|
3217
|
-
async function
|
|
3188
|
+
async function qi(e, t) {
|
|
3218
3189
|
let n = await y.readFile(e, "utf-8");
|
|
3219
|
-
if (!n.includes(
|
|
3220
|
-
let r = n
|
|
3221
|
-
await y.writeFile(e, r, "utf-8");
|
|
3190
|
+
if (!n.includes(Gr)) return;
|
|
3191
|
+
let r = qr(n, t);
|
|
3192
|
+
r !== n && await y.writeFile(e, r, "utf-8");
|
|
3222
3193
|
}
|
|
3223
3194
|
//#endregion
|
|
3224
3195
|
//#region src/core/installer.ts
|
|
3225
|
-
function
|
|
3196
|
+
function Ji(e, t) {
|
|
3226
3197
|
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3227
3198
|
}
|
|
3228
|
-
async function
|
|
3199
|
+
async function Yi(e, t) {
|
|
3229
3200
|
if ((await y.stat(e)).isDirectory()) {
|
|
3230
3201
|
await y.mkdir(t, { recursive: !0 });
|
|
3231
3202
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3232
|
-
for (let r of n) await
|
|
3203
|
+
for (let r of n) await Yi(T.join(e, r.name), T.join(t, r.name));
|
|
3233
3204
|
} else await y.mkdir(T.dirname(t), { recursive: !0 }), await y.copyFile(e, t);
|
|
3234
3205
|
}
|
|
3235
|
-
async function
|
|
3206
|
+
async function Xi(e) {
|
|
3236
3207
|
let { src: t, dest: n, projectRoot: r, skip: i } = e;
|
|
3237
3208
|
if ((await y.stat(t)).isDirectory()) {
|
|
3238
3209
|
await y.mkdir(n, { recursive: !0 });
|
|
3239
3210
|
let e = await y.readdir(t, { withFileTypes: !0 });
|
|
3240
|
-
return (await Promise.all(e.map((e) =>
|
|
3211
|
+
return (await Promise.all(e.map((e) => Xi({
|
|
3241
3212
|
src: T.join(t, e.name),
|
|
3242
3213
|
dest: T.join(n, e.name),
|
|
3243
3214
|
projectRoot: r,
|
|
@@ -3246,17 +3217,17 @@ async function Qi(e) {
|
|
|
3246
3217
|
}
|
|
3247
3218
|
return i.has(t) ? [] : (await y.mkdir(T.dirname(n), { recursive: !0 }), await y.copyFile(t, n), [T.relative(r, n)]);
|
|
3248
3219
|
}
|
|
3249
|
-
async function
|
|
3250
|
-
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);
|
|
3251
3222
|
return {
|
|
3252
3223
|
sourcePath: a,
|
|
3253
3224
|
targetPath: o,
|
|
3254
|
-
sourceExists: await
|
|
3255
|
-
targetExists: await
|
|
3225
|
+
sourceExists: await Y(a) || await lr(a),
|
|
3226
|
+
targetExists: await Y(o) || await lr(o)
|
|
3256
3227
|
};
|
|
3257
3228
|
}
|
|
3258
|
-
async function
|
|
3259
|
-
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({
|
|
3260
3231
|
file: t,
|
|
3261
3232
|
packDir: n,
|
|
3262
3233
|
paths: r,
|
|
@@ -3271,8 +3242,8 @@ async function ea(e) {
|
|
|
3271
3242
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3272
3243
|
}
|
|
3273
3244
|
}
|
|
3274
|
-
async function
|
|
3275
|
-
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({
|
|
3276
3247
|
file: t,
|
|
3277
3248
|
packDir: n,
|
|
3278
3249
|
paths: r,
|
|
@@ -3290,7 +3261,7 @@ async function ta(e) {
|
|
|
3290
3261
|
status: "skipped",
|
|
3291
3262
|
path: t.target,
|
|
3292
3263
|
reason: "Already exists"
|
|
3293
|
-
} : (await
|
|
3264
|
+
} : (await Yi(s, c), {
|
|
3294
3265
|
status: "installed",
|
|
3295
3266
|
path: t.target
|
|
3296
3267
|
});
|
|
@@ -3299,16 +3270,16 @@ async function ta(e) {
|
|
|
3299
3270
|
status: "skipped",
|
|
3300
3271
|
path: t.target,
|
|
3301
3272
|
reason: "Already exists (skip-if-exists)"
|
|
3302
|
-
} : (await
|
|
3273
|
+
} : (await Yi(s, c), {
|
|
3303
3274
|
status: "installed",
|
|
3304
3275
|
path: t.target
|
|
3305
3276
|
});
|
|
3306
|
-
case "override": return await
|
|
3277
|
+
case "override": return await Yi(s, c), {
|
|
3307
3278
|
status: "installed",
|
|
3308
3279
|
path: t.target
|
|
3309
3280
|
};
|
|
3310
3281
|
case "merge": {
|
|
3311
|
-
if (!u) return await
|
|
3282
|
+
if (!u) return await Yi(s, c), {
|
|
3312
3283
|
status: "installed",
|
|
3313
3284
|
path: t.target
|
|
3314
3285
|
};
|
|
@@ -3338,15 +3309,15 @@ async function ta(e) {
|
|
|
3338
3309
|
};
|
|
3339
3310
|
}
|
|
3340
3311
|
}
|
|
3341
|
-
async function
|
|
3312
|
+
async function ea(e) {
|
|
3342
3313
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3343
3314
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3344
3315
|
let o = [], s = /* @__PURE__ */ new Set();
|
|
3345
3316
|
for (let e of t) {
|
|
3346
3317
|
let t = i?.get(e.manifest.name);
|
|
3347
3318
|
for (let n of e.manifest.files) {
|
|
3348
|
-
if (n.strategy !== "create" || !
|
|
3349
|
-
let { targetPath: i, targetExists: c } = await
|
|
3319
|
+
if (n.strategy !== "create" || !Ji(n, t)) continue;
|
|
3320
|
+
let { targetPath: i, targetExists: c } = await Zi({
|
|
3350
3321
|
file: n,
|
|
3351
3322
|
packDir: e.packDir,
|
|
3352
3323
|
paths: a,
|
|
@@ -3361,13 +3332,13 @@ async function na(e) {
|
|
|
3361
3332
|
}
|
|
3362
3333
|
return o;
|
|
3363
3334
|
}
|
|
3364
|
-
async function
|
|
3335
|
+
async function ta(e) {
|
|
3365
3336
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3366
3337
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3367
3338
|
let c = [];
|
|
3368
3339
|
for (let e of t.files) {
|
|
3369
|
-
if (!
|
|
3370
|
-
let t = await
|
|
3340
|
+
if (!Ji(e, o)) continue;
|
|
3341
|
+
let t = await Qi({
|
|
3371
3342
|
file: e,
|
|
3372
3343
|
packDir: a,
|
|
3373
3344
|
paths: s,
|
|
@@ -3378,16 +3349,16 @@ async function ra(e) {
|
|
|
3378
3349
|
}
|
|
3379
3350
|
return c;
|
|
3380
3351
|
}
|
|
3381
|
-
async function
|
|
3352
|
+
async function na(e) {
|
|
3382
3353
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3383
3354
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3384
3355
|
let l = {
|
|
3385
3356
|
installed: [],
|
|
3386
3357
|
skipped: [],
|
|
3387
3358
|
errors: []
|
|
3388
|
-
}, u = t.files.filter((e) =>
|
|
3359
|
+
}, u = t.files.filter((e) => Ji(e, s));
|
|
3389
3360
|
for (let e of u) {
|
|
3390
|
-
let t = await
|
|
3361
|
+
let t = await $i({
|
|
3391
3362
|
file: e,
|
|
3392
3363
|
packDir: o,
|
|
3393
3364
|
paths: c,
|
|
@@ -3407,40 +3378,40 @@ async function ia(e) {
|
|
|
3407
3378
|
break;
|
|
3408
3379
|
}
|
|
3409
3380
|
}
|
|
3410
|
-
await
|
|
3381
|
+
await Ui({
|
|
3411
3382
|
files: u,
|
|
3412
3383
|
paths: c,
|
|
3413
3384
|
projectRoot: r,
|
|
3414
3385
|
projectName: n.name
|
|
3415
|
-
}), 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);
|
|
3416
3387
|
let d = s && s.length > 0 ? s : ["frontend"];
|
|
3417
|
-
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({
|
|
3418
3389
|
entries: t.nav,
|
|
3419
3390
|
paths: c,
|
|
3420
3391
|
projectRoot: r,
|
|
3421
3392
|
slot: e
|
|
3422
|
-
}), t.navbarActions && t.navbarActions.length > 0 && await
|
|
3393
|
+
}), t.navbarActions && t.navbarActions.length > 0 && await Ii({
|
|
3423
3394
|
actions: t.navbarActions,
|
|
3424
3395
|
paths: c,
|
|
3425
3396
|
projectRoot: r,
|
|
3426
3397
|
slot: e
|
|
3427
|
-
}), t.userMenuActions && t.userMenuActions.length > 0 && await
|
|
3398
|
+
}), t.userMenuActions && t.userMenuActions.length > 0 && await Li({
|
|
3428
3399
|
actions: t.userMenuActions,
|
|
3429
3400
|
paths: c,
|
|
3430
3401
|
projectRoot: r,
|
|
3431
3402
|
slot: e
|
|
3432
3403
|
});
|
|
3433
|
-
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({
|
|
3434
3405
|
postLoginRedirect: t.postLoginRedirect,
|
|
3435
3406
|
paths: c,
|
|
3436
3407
|
projectRoot: r,
|
|
3437
3408
|
slot: d[0]
|
|
3438
3409
|
}), l;
|
|
3439
3410
|
}
|
|
3440
|
-
async function
|
|
3411
|
+
async function ra(e) {
|
|
3441
3412
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3442
3413
|
for (let e of t) {
|
|
3443
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3414
|
+
let t = o?.get(e.manifest.name), a = await ta({
|
|
3444
3415
|
manifest: e.manifest,
|
|
3445
3416
|
config: n,
|
|
3446
3417
|
projectRoot: r,
|
|
@@ -3460,7 +3431,7 @@ async function aa(e) {
|
|
|
3460
3431
|
};
|
|
3461
3432
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3462
3433
|
for (let e of t) {
|
|
3463
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3434
|
+
let t = o?.get(e.manifest.name), n = await na({
|
|
3464
3435
|
manifest: e.manifest,
|
|
3465
3436
|
config: f,
|
|
3466
3437
|
projectRoot: r,
|
|
@@ -3469,7 +3440,7 @@ async function aa(e) {
|
|
|
3469
3440
|
packDir: e.packDir,
|
|
3470
3441
|
slots: t
|
|
3471
3442
|
});
|
|
3472
|
-
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);
|
|
3473
3444
|
}
|
|
3474
3445
|
return {
|
|
3475
3446
|
installed: c,
|
|
@@ -3480,8 +3451,8 @@ async function aa(e) {
|
|
|
3480
3451
|
config: f
|
|
3481
3452
|
};
|
|
3482
3453
|
}
|
|
3483
|
-
async function
|
|
3484
|
-
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 = {
|
|
3485
3456
|
...e,
|
|
3486
3457
|
installedPacks: [...e.installedPacks ?? [], r],
|
|
3487
3458
|
onboarding: {
|
|
@@ -3489,19 +3460,19 @@ async function oa(e, t, n) {
|
|
|
3489
3460
|
envSections: a
|
|
3490
3461
|
}
|
|
3491
3462
|
};
|
|
3492
|
-
return await
|
|
3463
|
+
return await Nr(n, o), o;
|
|
3493
3464
|
}
|
|
3494
|
-
async function
|
|
3465
|
+
async function aa(e) {
|
|
3495
3466
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3496
3467
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3497
|
-
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) =>
|
|
3498
|
-
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)) {
|
|
3499
3470
|
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3500
3471
|
for (let t of e) {
|
|
3501
3472
|
if (!t.isDirectory()) continue;
|
|
3502
3473
|
let e = a[t.name]?.root;
|
|
3503
3474
|
if (!e) continue;
|
|
3504
|
-
let n = await
|
|
3475
|
+
let n = await Xi({
|
|
3505
3476
|
src: T.join(u, t.name),
|
|
3506
3477
|
dest: T.resolve(r, e),
|
|
3507
3478
|
projectRoot: r,
|
|
@@ -3511,7 +3482,7 @@ async function sa(e) {
|
|
|
3511
3482
|
}
|
|
3512
3483
|
}
|
|
3513
3484
|
for (let e of c) {
|
|
3514
|
-
let t = await
|
|
3485
|
+
let t = await $i({
|
|
3515
3486
|
file: e,
|
|
3516
3487
|
packDir: i,
|
|
3517
3488
|
paths: a,
|
|
@@ -3521,12 +3492,12 @@ async function sa(e) {
|
|
|
3521
3492
|
});
|
|
3522
3493
|
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3523
3494
|
}
|
|
3524
|
-
let d = T.join(
|
|
3525
|
-
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({
|
|
3526
3497
|
entries: t.nav,
|
|
3527
3498
|
paths: a,
|
|
3528
3499
|
projectRoot: r
|
|
3529
|
-
}), t.postLoginRedirect && await
|
|
3500
|
+
}), t.postLoginRedirect && await wi({
|
|
3530
3501
|
postLoginRedirect: t.postLoginRedirect,
|
|
3531
3502
|
paths: a,
|
|
3532
3503
|
projectRoot: r
|
|
@@ -3537,32 +3508,32 @@ async function sa(e) {
|
|
|
3537
3508
|
}
|
|
3538
3509
|
//#endregion
|
|
3539
3510
|
//#region src/core/pack-categories.ts
|
|
3540
|
-
var
|
|
3511
|
+
var oa = [
|
|
3541
3512
|
"starter",
|
|
3542
3513
|
"layout",
|
|
3543
3514
|
"feature"
|
|
3544
|
-
],
|
|
3515
|
+
], sa = {
|
|
3545
3516
|
starter: "Starter",
|
|
3546
3517
|
layout: "Layout",
|
|
3547
3518
|
feature: "Features"
|
|
3548
|
-
},
|
|
3549
|
-
function
|
|
3519
|
+
}, ca = new Set(["starter", "layout"]), la = "starter-saas-betterauth", ua = "layout-basic";
|
|
3520
|
+
function da(e, t = {}) {
|
|
3550
3521
|
let n = [];
|
|
3551
|
-
for (let r of
|
|
3522
|
+
for (let r of oa) {
|
|
3552
3523
|
let i = e.filter((e) => e.category === r);
|
|
3553
3524
|
if (i.length === 0) continue;
|
|
3554
|
-
let a =
|
|
3525
|
+
let a = ca.has(r) ? "single" : "multiple";
|
|
3555
3526
|
if (r === "layout") {
|
|
3556
|
-
n.push(
|
|
3527
|
+
n.push(pa("frontend", i)), t.adminAvailable && n.push(pa("admin", i));
|
|
3557
3528
|
continue;
|
|
3558
3529
|
}
|
|
3559
3530
|
if (r === "starter") {
|
|
3560
|
-
n.push(
|
|
3531
|
+
n.push(fa(i));
|
|
3561
3532
|
continue;
|
|
3562
3533
|
}
|
|
3563
3534
|
n.push({
|
|
3564
3535
|
category: r,
|
|
3565
|
-
label:
|
|
3536
|
+
label: sa[r],
|
|
3566
3537
|
mode: a,
|
|
3567
3538
|
packs: i,
|
|
3568
3539
|
preselect: null
|
|
@@ -3570,70 +3541,57 @@ function pa(e, t = {}) {
|
|
|
3570
3541
|
}
|
|
3571
3542
|
return n;
|
|
3572
3543
|
}
|
|
3573
|
-
function
|
|
3574
|
-
let t = e.some((e) => e.name ===
|
|
3544
|
+
function fa(e) {
|
|
3545
|
+
let t = e.some((e) => e.name === la);
|
|
3575
3546
|
return {
|
|
3576
3547
|
category: "starter",
|
|
3577
|
-
label:
|
|
3548
|
+
label: sa.starter,
|
|
3578
3549
|
mode: "single",
|
|
3579
3550
|
packs: e,
|
|
3580
|
-
preselect: t ?
|
|
3551
|
+
preselect: t ? la : null
|
|
3581
3552
|
};
|
|
3582
3553
|
}
|
|
3583
|
-
function
|
|
3584
|
-
let n = t.some((e) => e.name ===
|
|
3554
|
+
function pa(e, t) {
|
|
3555
|
+
let n = t.some((e) => e.name === ua);
|
|
3585
3556
|
return {
|
|
3586
3557
|
category: "layout",
|
|
3587
3558
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3588
3559
|
mode: "single",
|
|
3589
3560
|
packs: t,
|
|
3590
|
-
preselect: n ?
|
|
3561
|
+
preselect: n ? ua : null,
|
|
3591
3562
|
slot: e
|
|
3592
3563
|
};
|
|
3593
3564
|
}
|
|
3594
3565
|
//#endregion
|
|
3595
|
-
//#region src/ui/logger.ts
|
|
3596
|
-
var ga = [he.orangeBright, he.skyBlue];
|
|
3597
|
-
function _a(e) {
|
|
3598
|
-
let t = e.map((e, t) => {
|
|
3599
|
-
let n = ga[t % ga.length];
|
|
3600
|
-
return `${z.bold(n(`${t + 1}.`))} ${z.bold(e)}`;
|
|
3601
|
-
}).join("\n");
|
|
3602
|
-
s.note(t, "Next steps");
|
|
3603
|
-
}
|
|
3604
|
-
function Z() {
|
|
3605
|
-
s.cancel(z.muted("Operation cancelled.")), process.exit(0);
|
|
3606
|
-
}
|
|
3607
|
-
//#endregion
|
|
3608
3566
|
//#region src/core/post-setup.ts
|
|
3609
|
-
async function
|
|
3610
|
-
return (await
|
|
3567
|
+
async function ma() {
|
|
3568
|
+
return (await J("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3611
3569
|
}
|
|
3612
|
-
async function
|
|
3613
|
-
return
|
|
3570
|
+
async function ha(e) {
|
|
3571
|
+
return Y(`${e}/apps/backend/.env`);
|
|
3614
3572
|
}
|
|
3615
|
-
async function
|
|
3616
|
-
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({
|
|
3617
3575
|
message: r,
|
|
3618
3576
|
initialValue: !0
|
|
3619
3577
|
});
|
|
3620
|
-
if (s.isCancel(i) &&
|
|
3578
|
+
if (s.isCancel(i) && B(), !i) return s.log.info(L.muted("Skipping Docker services and database migrations.")), !1;
|
|
3621
3579
|
let a = s.spinner();
|
|
3622
3580
|
a.start("Starting Docker services...");
|
|
3623
|
-
let o = await
|
|
3581
|
+
let o = await J("docker", [
|
|
3624
3582
|
"compose",
|
|
3625
3583
|
"up",
|
|
3626
3584
|
"-d"
|
|
3627
3585
|
], { cwd: `${e}/apps/backend` });
|
|
3628
|
-
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);
|
|
3629
3587
|
}
|
|
3630
|
-
function
|
|
3588
|
+
function _a(e) {
|
|
3631
3589
|
let t = (e.stderr || e.stdout).trim();
|
|
3632
|
-
t && s.log.warn(
|
|
3590
|
+
t && s.log.warn(L.muted(t));
|
|
3633
3591
|
}
|
|
3634
|
-
async function
|
|
3592
|
+
async function va(e, t = 15, n = 2e3) {
|
|
3635
3593
|
for (let r = 0; r < t; r++) {
|
|
3636
|
-
if ((await
|
|
3594
|
+
if ((await J("docker", [
|
|
3637
3595
|
"compose",
|
|
3638
3596
|
"exec",
|
|
3639
3597
|
"-T",
|
|
@@ -3646,9 +3604,9 @@ async function Sa(e, t = 15, n = 2e3) {
|
|
|
3646
3604
|
}
|
|
3647
3605
|
return !1;
|
|
3648
3606
|
}
|
|
3649
|
-
var
|
|
3650
|
-
async function
|
|
3651
|
-
let t = await
|
|
3607
|
+
var ya = "Database schema is up to date";
|
|
3608
|
+
async function ba(e) {
|
|
3609
|
+
let t = await J("pnpm", [
|
|
3652
3610
|
"--filter",
|
|
3653
3611
|
"@internal/backend",
|
|
3654
3612
|
"exec",
|
|
@@ -3656,48 +3614,48 @@ async function wa(e) {
|
|
|
3656
3614
|
"migrate",
|
|
3657
3615
|
"status"
|
|
3658
3616
|
], { cwd: e });
|
|
3659
|
-
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(
|
|
3617
|
+
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(ya) : !1;
|
|
3660
3618
|
}
|
|
3661
|
-
async function
|
|
3619
|
+
async function xa(e) {
|
|
3662
3620
|
let t = s.spinner();
|
|
3663
3621
|
t.start("Running database migrations...");
|
|
3664
|
-
let n = await
|
|
3622
|
+
let n = await J("pnpm", [
|
|
3665
3623
|
"--filter",
|
|
3666
3624
|
"@internal/backend",
|
|
3667
3625
|
"migration:latest"
|
|
3668
3626
|
], { cwd: e });
|
|
3669
|
-
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);
|
|
3670
3628
|
}
|
|
3671
|
-
async function
|
|
3672
|
-
if (!await
|
|
3629
|
+
async function Sa(e, t, n = {}) {
|
|
3630
|
+
if (!await ga(e, t, await ma())) return !1;
|
|
3673
3631
|
let r = s.spinner();
|
|
3674
|
-
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);
|
|
3675
3633
|
}
|
|
3676
|
-
async function
|
|
3677
|
-
if (!await
|
|
3634
|
+
async function Ca(e, t, n = {}) {
|
|
3635
|
+
if (!await Sa(e, t, n)) return;
|
|
3678
3636
|
let r = t ? !0 : await s.confirm({
|
|
3679
|
-
message: `Run database migrations with ${
|
|
3637
|
+
message: `Run database migrations with ${L.command("prisma migrate deploy")}?`,
|
|
3680
3638
|
initialValue: !0
|
|
3681
3639
|
});
|
|
3682
|
-
if (s.isCancel(r) &&
|
|
3683
|
-
s.log.info(
|
|
3640
|
+
if (s.isCancel(r) && B(), !r) {
|
|
3641
|
+
s.log.info(L.muted("Skipping database migrations."));
|
|
3684
3642
|
return;
|
|
3685
3643
|
}
|
|
3686
|
-
await
|
|
3644
|
+
await xa(e);
|
|
3687
3645
|
}
|
|
3688
|
-
async function
|
|
3689
|
-
if (!await
|
|
3690
|
-
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.`);
|
|
3691
3649
|
return;
|
|
3692
3650
|
}
|
|
3693
|
-
await
|
|
3651
|
+
await Ca(e, t, n);
|
|
3694
3652
|
}
|
|
3695
|
-
async function
|
|
3696
|
-
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);
|
|
3697
3655
|
}
|
|
3698
3656
|
//#endregion
|
|
3699
3657
|
//#region src/core/resolve.ts
|
|
3700
|
-
function
|
|
3658
|
+
function Ea(e) {
|
|
3701
3659
|
let t = /* @__PURE__ */ new Map();
|
|
3702
3660
|
for (let n of e) t.set(n.name, {
|
|
3703
3661
|
name: n.name,
|
|
@@ -3705,7 +3663,7 @@ function Aa(e) {
|
|
|
3705
3663
|
});
|
|
3706
3664
|
return t;
|
|
3707
3665
|
}
|
|
3708
|
-
function
|
|
3666
|
+
function Da(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3709
3667
|
let r = /* @__PURE__ */ new Set();
|
|
3710
3668
|
function i(e) {
|
|
3711
3669
|
if (n.has(e)) return [];
|
|
@@ -3719,10 +3677,10 @@ function ja(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3719
3677
|
}
|
|
3720
3678
|
return i(e);
|
|
3721
3679
|
}
|
|
3722
|
-
function
|
|
3680
|
+
function Oa(e, t, n = []) {
|
|
3723
3681
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3724
3682
|
for (let n of e) {
|
|
3725
|
-
let e =
|
|
3683
|
+
let e = Da(n, t, new Set(i));
|
|
3726
3684
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3727
3685
|
}
|
|
3728
3686
|
return {
|
|
@@ -3730,7 +3688,7 @@ function Ma(e, t, n = []) {
|
|
|
3730
3688
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3731
3689
|
};
|
|
3732
3690
|
}
|
|
3733
|
-
function
|
|
3691
|
+
function ka(e) {
|
|
3734
3692
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3735
3693
|
for (let e of t) {
|
|
3736
3694
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3743,7 +3701,7 @@ function Na(e) {
|
|
|
3743
3701
|
}
|
|
3744
3702
|
//#endregion
|
|
3745
3703
|
//#region src/core/variants.ts
|
|
3746
|
-
function
|
|
3704
|
+
function Aa(e, t = {}) {
|
|
3747
3705
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3748
3706
|
for (let i of e) {
|
|
3749
3707
|
let e = t[i.family] ?? i.default;
|
|
@@ -3755,14 +3713,14 @@ function Pa(e, t = {}) {
|
|
|
3755
3713
|
familyOf: r
|
|
3756
3714
|
};
|
|
3757
3715
|
}
|
|
3758
|
-
function
|
|
3716
|
+
function ja(e, t, n) {
|
|
3759
3717
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3760
3718
|
}
|
|
3761
|
-
function
|
|
3719
|
+
function Ma(e, t) {
|
|
3762
3720
|
let n = t.familyOf.get(e);
|
|
3763
3721
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3764
3722
|
}
|
|
3765
|
-
function
|
|
3723
|
+
function Na(e, t) {
|
|
3766
3724
|
let n = /* @__PURE__ */ new Map();
|
|
3767
3725
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3768
3726
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3778,65 +3736,65 @@ function La(e, t) {
|
|
|
3778
3736
|
familyOf: n
|
|
3779
3737
|
};
|
|
3780
3738
|
}
|
|
3781
|
-
function
|
|
3739
|
+
function Pa(e, t) {
|
|
3782
3740
|
return e.map((e) => ({
|
|
3783
3741
|
...e,
|
|
3784
|
-
dependencies: e.dependencies.map((e) =>
|
|
3742
|
+
dependencies: e.dependencies.map((e) => Ma(e, t))
|
|
3785
3743
|
}));
|
|
3786
3744
|
}
|
|
3787
3745
|
//#endregion
|
|
3788
3746
|
//#region src/ui/banner.ts
|
|
3789
|
-
var
|
|
3747
|
+
var Fa = [
|
|
3790
3748
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3791
3749
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3792
3750
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3793
3751
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3794
3752
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3795
3753
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3796
|
-
],
|
|
3754
|
+
], Ia = [
|
|
3797
3755
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3798
3756
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3799
3757
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3800
3758
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3801
3759
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3802
3760
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3803
|
-
],
|
|
3761
|
+
], La = [
|
|
3804
3762
|
253,
|
|
3805
3763
|
176,
|
|
3806
3764
|
21
|
|
3807
|
-
],
|
|
3765
|
+
], Ra = [
|
|
3808
3766
|
245,
|
|
3809
3767
|
76,
|
|
3810
3768
|
2
|
|
3811
|
-
],
|
|
3769
|
+
], za = 5, Ba = [
|
|
3812
3770
|
17,
|
|
3813
3771
|
103,
|
|
3814
3772
|
248
|
|
3815
|
-
],
|
|
3773
|
+
], Va = [
|
|
3816
3774
|
42,
|
|
3817
3775
|
160,
|
|
3818
3776
|
250
|
|
3819
|
-
],
|
|
3820
|
-
function
|
|
3777
|
+
], Ha = .2;
|
|
3778
|
+
function Ua() {
|
|
3821
3779
|
console.log();
|
|
3822
|
-
for (let e of
|
|
3823
|
-
start:
|
|
3824
|
-
end:
|
|
3825
|
-
angle:
|
|
3780
|
+
for (let e of Se(Fa, {
|
|
3781
|
+
start: La,
|
|
3782
|
+
end: Ra,
|
|
3783
|
+
angle: za
|
|
3826
3784
|
})) console.log(b.bold(e));
|
|
3827
|
-
for (let e of
|
|
3828
|
-
start:
|
|
3829
|
-
end:
|
|
3830
|
-
angle:
|
|
3785
|
+
for (let e of Se(Ia, {
|
|
3786
|
+
start: Ba,
|
|
3787
|
+
end: Va,
|
|
3788
|
+
angle: Ha
|
|
3831
3789
|
})) console.log(b.bold(e));
|
|
3832
|
-
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();
|
|
3833
3791
|
}
|
|
3834
|
-
function
|
|
3835
|
-
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();
|
|
3836
3794
|
}
|
|
3837
3795
|
//#endregion
|
|
3838
3796
|
//#region src/ui/pack-multiselect.ts
|
|
3839
|
-
var
|
|
3797
|
+
var Ga = class extends O {
|
|
3840
3798
|
options;
|
|
3841
3799
|
cursor = 0;
|
|
3842
3800
|
selected;
|
|
@@ -3940,44 +3898,44 @@ var Ya = class extends O {
|
|
|
3940
3898
|
}
|
|
3941
3899
|
}
|
|
3942
3900
|
};
|
|
3943
|
-
function
|
|
3944
|
-
return new
|
|
3901
|
+
function Ka(e) {
|
|
3902
|
+
return new Ga(e).prompt();
|
|
3945
3903
|
}
|
|
3946
3904
|
//#endregion
|
|
3947
3905
|
//#region src/utils/naming.ts
|
|
3948
|
-
function
|
|
3906
|
+
function qa(e) {
|
|
3949
3907
|
return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3950
3908
|
}
|
|
3951
|
-
function
|
|
3909
|
+
function Ja(e) {
|
|
3952
3910
|
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3953
3911
|
}
|
|
3954
3912
|
//#endregion
|
|
3955
3913
|
//#region src/utils/validate.ts
|
|
3956
|
-
function
|
|
3914
|
+
function Ya(e) {
|
|
3957
3915
|
if (!e.trim()) return "Project name cannot be empty";
|
|
3958
3916
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
3959
|
-
let t =
|
|
3960
|
-
if (!
|
|
3917
|
+
let t = qa(e);
|
|
3918
|
+
if (!ie.test(t)) return "Project name must contain at least one letter or number";
|
|
3961
3919
|
}
|
|
3962
3920
|
//#endregion
|
|
3963
3921
|
//#region src/core/apply-mode.ts
|
|
3964
|
-
var
|
|
3965
|
-
function
|
|
3966
|
-
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}`);
|
|
3967
3925
|
}
|
|
3968
|
-
async function
|
|
3969
|
-
let n = T.resolve(e,
|
|
3926
|
+
async function $a(e, t) {
|
|
3927
|
+
let n = T.resolve(e, Xa), r;
|
|
3970
3928
|
try {
|
|
3971
3929
|
r = await y.readFile(n, "utf-8");
|
|
3972
3930
|
} catch {
|
|
3973
3931
|
return !1;
|
|
3974
3932
|
}
|
|
3975
|
-
let i =
|
|
3933
|
+
let i = Qa(r, t);
|
|
3976
3934
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3977
3935
|
}
|
|
3978
3936
|
//#endregion
|
|
3979
3937
|
//#region src/core/apply-theme.ts
|
|
3980
|
-
function
|
|
3938
|
+
function eo(e, t) {
|
|
3981
3939
|
let n = 0;
|
|
3982
3940
|
for (; n < e.length;) {
|
|
3983
3941
|
let r = e.indexOf(t, n);
|
|
@@ -4000,47 +3958,47 @@ function io(e, t) {
|
|
|
4000
3958
|
}
|
|
4001
3959
|
return null;
|
|
4002
3960
|
}
|
|
4003
|
-
function
|
|
3961
|
+
function to(e, t) {
|
|
4004
3962
|
let n = e;
|
|
4005
3963
|
for (let [e, r] of Object.entries(t)) {
|
|
4006
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3964
|
+
let t = RegExp(`(^[ \\t]*--${no(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
4007
3965
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
4008
3966
|
}
|
|
4009
3967
|
return n;
|
|
4010
3968
|
}
|
|
4011
|
-
function
|
|
3969
|
+
function no(e) {
|
|
4012
3970
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4013
3971
|
}
|
|
4014
|
-
function
|
|
4015
|
-
let n =
|
|
3972
|
+
function ro(e, t) {
|
|
3973
|
+
let n = eo(e, ":root"), r = eo(e, ".dark"), i = e;
|
|
4016
3974
|
if (n) {
|
|
4017
3975
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
4018
|
-
i = e +
|
|
3976
|
+
i = e + to(r, t.light) + a;
|
|
4019
3977
|
}
|
|
4020
3978
|
if (r) {
|
|
4021
|
-
let e =
|
|
3979
|
+
let e = eo(i, ".dark");
|
|
4022
3980
|
if (e) {
|
|
4023
3981
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
4024
|
-
i = n +
|
|
3982
|
+
i = n + to(r, t.dark) + a;
|
|
4025
3983
|
}
|
|
4026
3984
|
}
|
|
4027
3985
|
return i;
|
|
4028
3986
|
}
|
|
4029
|
-
var
|
|
4030
|
-
async function
|
|
4031
|
-
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;
|
|
4032
3990
|
try {
|
|
4033
3991
|
r = await y.readFile(n, "utf-8");
|
|
4034
3992
|
} catch {
|
|
4035
3993
|
return !1;
|
|
4036
3994
|
}
|
|
4037
|
-
let i =
|
|
3995
|
+
let i = ro(r, t);
|
|
4038
3996
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
4039
3997
|
}
|
|
4040
3998
|
//#endregion
|
|
4041
3999
|
//#region src/core/clone.ts
|
|
4042
|
-
async function
|
|
4043
|
-
let t = await ee(
|
|
4000
|
+
async function oo(e) {
|
|
4001
|
+
let t = await ee(te, {
|
|
4044
4002
|
dir: e,
|
|
4045
4003
|
force: !0
|
|
4046
4004
|
});
|
|
@@ -4051,7 +4009,7 @@ async function uo(e) {
|
|
|
4051
4009
|
}
|
|
4052
4010
|
//#endregion
|
|
4053
4011
|
//#region src/core/editor-config.ts
|
|
4054
|
-
function
|
|
4012
|
+
function so(e) {
|
|
4055
4013
|
let t = {
|
|
4056
4014
|
globs: [],
|
|
4057
4015
|
alwaysApply: !1
|
|
@@ -4086,10 +4044,10 @@ function fo(e) {
|
|
|
4086
4044
|
content: i
|
|
4087
4045
|
};
|
|
4088
4046
|
}
|
|
4089
|
-
function
|
|
4047
|
+
function co(e) {
|
|
4090
4048
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
4091
4049
|
}
|
|
4092
|
-
function
|
|
4050
|
+
function lo(e) {
|
|
4093
4051
|
let t;
|
|
4094
4052
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
4095
4053
|
let n = [`trigger: ${t}`];
|
|
@@ -4099,30 +4057,30 @@ function mo(e) {
|
|
|
4099
4057
|
}
|
|
4100
4058
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
4101
4059
|
}
|
|
4102
|
-
function
|
|
4060
|
+
function uo(e) {
|
|
4103
4061
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
4104
4062
|
}
|
|
4105
|
-
var
|
|
4063
|
+
var fo = {
|
|
4106
4064
|
claude: {
|
|
4107
4065
|
rulesDir: ".claude/rules",
|
|
4108
4066
|
extension: ".md",
|
|
4109
|
-
convert:
|
|
4067
|
+
convert: co
|
|
4110
4068
|
},
|
|
4111
4069
|
windsurf: {
|
|
4112
4070
|
rulesDir: ".windsurf/rules",
|
|
4113
4071
|
extension: ".md",
|
|
4114
|
-
convert:
|
|
4072
|
+
convert: lo
|
|
4115
4073
|
},
|
|
4116
4074
|
copilot: {
|
|
4117
4075
|
rulesDir: ".github/instructions",
|
|
4118
4076
|
extension: ".instructions.md",
|
|
4119
|
-
convert:
|
|
4077
|
+
convert: uo
|
|
4120
4078
|
}
|
|
4121
4079
|
};
|
|
4122
|
-
async function
|
|
4123
|
-
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"));
|
|
4124
4082
|
return await Promise.all(n.map(async (e) => {
|
|
4125
|
-
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"));
|
|
4126
4084
|
return {
|
|
4127
4085
|
frontmatter: r,
|
|
4128
4086
|
content: i,
|
|
@@ -4130,44 +4088,44 @@ async function _o(e) {
|
|
|
4130
4088
|
};
|
|
4131
4089
|
}));
|
|
4132
4090
|
}
|
|
4133
|
-
async function
|
|
4091
|
+
async function mo(e, t) {
|
|
4134
4092
|
if (t === "cursor") return;
|
|
4135
|
-
let n =
|
|
4093
|
+
let n = fo[t], r = await po(e), i = T.join(e, n.rulesDir);
|
|
4136
4094
|
await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
4137
4095
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
4138
4096
|
return y.writeFile(T.join(i, r), t, "utf-8");
|
|
4139
|
-
})), await
|
|
4097
|
+
})), await mr(T.join(e, se)), await mr(T.join(e, ce));
|
|
4140
4098
|
}
|
|
4141
4099
|
//#endregion
|
|
4142
4100
|
//#region src/core/env-files.ts
|
|
4143
|
-
var
|
|
4101
|
+
var ho = [
|
|
4144
4102
|
"apps",
|
|
4145
4103
|
"packages",
|
|
4146
4104
|
"libs",
|
|
4147
4105
|
"shared"
|
|
4148
4106
|
];
|
|
4149
|
-
async function
|
|
4150
|
-
let t = await
|
|
4107
|
+
async function go(e) {
|
|
4108
|
+
let t = await _o(e);
|
|
4151
4109
|
return (await Promise.all(t.map(async (t) => {
|
|
4152
4110
|
let n = T.join(T.dirname(t), ".env");
|
|
4153
|
-
return await
|
|
4111
|
+
return await Y(n) ? null : (await y.copyFile(t, n), T.relative(e, n));
|
|
4154
4112
|
}))).filter((e) => e !== null).sort();
|
|
4155
4113
|
}
|
|
4156
|
-
async function
|
|
4157
|
-
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) => {
|
|
4158
4116
|
let n = T.join(e, t);
|
|
4159
4117
|
return (await y.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => T.join(n, e.name, ".env.example"));
|
|
4160
4118
|
}));
|
|
4161
|
-
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);
|
|
4162
4120
|
}
|
|
4163
4121
|
//#endregion
|
|
4164
4122
|
//#region src/core/post-clone.ts
|
|
4165
|
-
var Q = "@hype-stack/",
|
|
4166
|
-
async function
|
|
4167
|
-
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"));
|
|
4168
4126
|
}
|
|
4169
|
-
async function
|
|
4170
|
-
await
|
|
4127
|
+
async function xo(e) {
|
|
4128
|
+
await J("git", ["init"], { cwd: e }), await J("git", ["add", "."], { cwd: e }), await J("git", [
|
|
4171
4129
|
"-c",
|
|
4172
4130
|
"user.name=Hype Stack CLI",
|
|
4173
4131
|
"-c",
|
|
@@ -4177,22 +4135,19 @@ async function wo(e) {
|
|
|
4177
4135
|
"Initial commit from Hype Stack CLI"
|
|
4178
4136
|
], { cwd: e });
|
|
4179
4137
|
}
|
|
4180
|
-
async function
|
|
4181
|
-
let n = `@${t}/`, r = await
|
|
4138
|
+
async function So(e, t) {
|
|
4139
|
+
let n = `@${t}/`, r = await Ao(e);
|
|
4182
4140
|
for (let e of r) {
|
|
4183
|
-
let t = await
|
|
4141
|
+
let t = await dr(e);
|
|
4184
4142
|
if (!t) continue;
|
|
4185
4143
|
let r = !1;
|
|
4186
|
-
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0),
|
|
4187
|
-
let i = await y.readFile(e, "utf-8");
|
|
4188
|
-
|
|
4189
|
-
let t = i.replaceAll(Q, n);
|
|
4190
|
-
await y.writeFile(e, t, "utf-8");
|
|
4191
|
-
} else r && await cr(e, t);
|
|
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");
|
|
4192
4147
|
}
|
|
4193
|
-
await
|
|
4148
|
+
await Gi(e, t), await To(e, t), await ko(e, t);
|
|
4194
4149
|
}
|
|
4195
|
-
var
|
|
4150
|
+
var Co = new Set([
|
|
4196
4151
|
".git",
|
|
4197
4152
|
"node_modules",
|
|
4198
4153
|
"dist",
|
|
@@ -4200,10 +4155,10 @@ var Eo = new Set([
|
|
|
4200
4155
|
".nx",
|
|
4201
4156
|
".next",
|
|
4202
4157
|
"coverage"
|
|
4203
|
-
]),
|
|
4204
|
-
async function
|
|
4205
|
-
if (t ===
|
|
4206
|
-
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);
|
|
4207
4162
|
await Promise.all(n.map(async (e) => {
|
|
4208
4163
|
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
4209
4164
|
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
@@ -4211,23 +4166,23 @@ async function Oo(e, t) {
|
|
|
4211
4166
|
await y.writeFile(e, r, "utf-8");
|
|
4212
4167
|
}));
|
|
4213
4168
|
}
|
|
4214
|
-
async function
|
|
4169
|
+
async function Eo(e) {
|
|
4215
4170
|
let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
4216
4171
|
return (await Promise.all(t.map(async (t) => {
|
|
4217
4172
|
let n = T.join(e, t.name);
|
|
4218
|
-
return t.isDirectory() ?
|
|
4173
|
+
return t.isDirectory() ? Co.has(t.name) ? [] : Eo(n) : t.isFile() && wo.test(t.name) ? [n] : [];
|
|
4219
4174
|
}))).flat();
|
|
4220
4175
|
}
|
|
4221
|
-
function
|
|
4176
|
+
function Do(e, t) {
|
|
4222
4177
|
if (!e) return !1;
|
|
4223
4178
|
let n = !1;
|
|
4224
|
-
for (let r of Object.keys(e)) if (r.startsWith(Q)) {
|
|
4179
|
+
for (let r of Object.keys(e)) if (r !== yo && r.startsWith(Q)) {
|
|
4225
4180
|
let i = r.replace(Q, t);
|
|
4226
4181
|
e[i] = e[r], delete e[r], n = !0;
|
|
4227
4182
|
}
|
|
4228
4183
|
return n;
|
|
4229
4184
|
}
|
|
4230
|
-
function
|
|
4185
|
+
function Oo(e, t) {
|
|
4231
4186
|
if (!e) return !1;
|
|
4232
4187
|
let n = !1;
|
|
4233
4188
|
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Q) ? (n = !0, e.replace(Q, t)) : e), e.targets) {
|
|
@@ -4235,13 +4190,13 @@ function jo(e, t) {
|
|
|
4235
4190
|
}
|
|
4236
4191
|
return n;
|
|
4237
4192
|
}
|
|
4238
|
-
async function
|
|
4193
|
+
async function ko(e, t) {
|
|
4239
4194
|
let n = T.join(e, "packages/enums/src/app/index.ts"), r = await y.readFile(n, "utf-8").catch(() => null);
|
|
4240
4195
|
if (!r) return;
|
|
4241
|
-
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"`);
|
|
4242
4197
|
await y.writeFile(n, a, "utf-8");
|
|
4243
4198
|
}
|
|
4244
|
-
async function
|
|
4199
|
+
async function Ao(e) {
|
|
4245
4200
|
let t = [], n = T.join(e, "package.json");
|
|
4246
4201
|
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
4247
4202
|
for (let n of [
|
|
@@ -4261,7 +4216,7 @@ async function No(e) {
|
|
|
4261
4216
|
}
|
|
4262
4217
|
//#endregion
|
|
4263
4218
|
//#region src/core/readme.ts
|
|
4264
|
-
var
|
|
4219
|
+
var jo = {
|
|
4265
4220
|
cursor: {
|
|
4266
4221
|
label: "Cursor",
|
|
4267
4222
|
rulesDir: ".cursor/rules"
|
|
@@ -4278,21 +4233,21 @@ var Po = {
|
|
|
4278
4233
|
label: "GitHub Copilot",
|
|
4279
4234
|
rulesDir: ".github/instructions"
|
|
4280
4235
|
}
|
|
4281
|
-
},
|
|
4236
|
+
}, Mo = {
|
|
4282
4237
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
4283
4238
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
4284
|
-
},
|
|
4239
|
+
}, No = {
|
|
4285
4240
|
enums: "Shared enums and app config used across apps",
|
|
4286
4241
|
cli: "Project tooling and code generators"
|
|
4287
4242
|
};
|
|
4288
|
-
function
|
|
4243
|
+
function Po(e, t) {
|
|
4289
4244
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
4290
4245
|
let r = t[e];
|
|
4291
4246
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4292
4247
|
});
|
|
4293
4248
|
}
|
|
4294
|
-
function
|
|
4295
|
-
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 = [];
|
|
4296
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)");
|
|
4297
4252
|
let u = [];
|
|
4298
4253
|
u.push(`# ${i}`), u.push([
|
|
@@ -4395,19 +4350,19 @@ function Ro(e) {
|
|
|
4395
4350
|
"stays useful."
|
|
4396
4351
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4397
4352
|
}
|
|
4398
|
-
async function
|
|
4353
|
+
async function Io(e, t) {
|
|
4399
4354
|
let n = T.join(e, "README.md");
|
|
4400
|
-
await y.writeFile(n,
|
|
4355
|
+
await y.writeFile(n, Fo(t), "utf-8");
|
|
4401
4356
|
}
|
|
4402
4357
|
//#endregion
|
|
4403
4358
|
//#region src/core/tracking.ts
|
|
4404
|
-
async function
|
|
4359
|
+
async function Lo(e) {
|
|
4405
4360
|
try {
|
|
4406
4361
|
let t = {
|
|
4407
|
-
"X-Device-Id":
|
|
4408
|
-
"X-Client-Info":
|
|
4409
|
-
}, n = await
|
|
4410
|
-
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()({
|
|
4411
4366
|
endpoint: "/cli/track",
|
|
4412
4367
|
method: "POST"
|
|
4413
4368
|
}).setPayload({ event: e }).setHeaders(t).send();
|
|
@@ -4415,7 +4370,7 @@ async function Bo(e) {
|
|
|
4415
4370
|
}
|
|
4416
4371
|
//#endregion
|
|
4417
4372
|
//#region src/core/npm-deps.ts
|
|
4418
|
-
function
|
|
4373
|
+
function Ro(e, t) {
|
|
4419
4374
|
let n = [], r = [];
|
|
4420
4375
|
if (!e) return {
|
|
4421
4376
|
errors: n,
|
|
@@ -4446,7 +4401,7 @@ function Vo(e, t) {
|
|
|
4446
4401
|
operations: r
|
|
4447
4402
|
};
|
|
4448
4403
|
}
|
|
4449
|
-
function
|
|
4404
|
+
function zo(e) {
|
|
4450
4405
|
let t = {};
|
|
4451
4406
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4452
4407
|
...t[e],
|
|
@@ -4454,11 +4409,11 @@ function Ho(e) {
|
|
|
4454
4409
|
};
|
|
4455
4410
|
return t;
|
|
4456
4411
|
}
|
|
4457
|
-
async function
|
|
4412
|
+
async function Bo(e, t, n = J) {
|
|
4458
4413
|
let r = [];
|
|
4459
4414
|
for (let i of e) {
|
|
4460
4415
|
let e = T.join(t, i.relativeDir);
|
|
4461
|
-
if (!await
|
|
4416
|
+
if (!await Y(T.join(e, "package.json"))) {
|
|
4462
4417
|
r.push(`Cannot install npm dependencies under "${i.relativeDir}": package.json not found.`);
|
|
4463
4418
|
continue;
|
|
4464
4419
|
}
|
|
@@ -4490,36 +4445,35 @@ async function Uo(e, t, n = q) {
|
|
|
4490
4445
|
function $(e) {
|
|
4491
4446
|
return e instanceof Error ? e.message : String(e);
|
|
4492
4447
|
}
|
|
4493
|
-
async function
|
|
4448
|
+
async function Vo(e, t, n) {
|
|
4494
4449
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4495
|
-
return r.length === 0 ? {} :
|
|
4450
|
+
return r.length === 0 ? {} : Wr(r, n).catch(() => ({}));
|
|
4496
4451
|
}
|
|
4497
|
-
function
|
|
4498
|
-
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")}`;
|
|
4499
4454
|
}
|
|
4500
|
-
async function
|
|
4455
|
+
async function Uo(e, t, n) {
|
|
4501
4456
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4502
|
-
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) => ({
|
|
4503
4458
|
name: e.name,
|
|
4504
4459
|
displayName: e.displayName,
|
|
4505
4460
|
price: e.price
|
|
4506
4461
|
})));
|
|
4507
4462
|
}
|
|
4508
|
-
function
|
|
4509
|
-
|
|
4510
|
-
let r = t.get(e), i = r ? r.displayName : e;
|
|
4511
|
-
return ` ${z.muted(`${n + 1}.`)} ${z.brand(i)}`;
|
|
4512
|
-
});
|
|
4513
|
-
s.note([
|
|
4463
|
+
function Wo(e, t) {
|
|
4464
|
+
z([
|
|
4514
4465
|
"These packs will be installed, in order:",
|
|
4515
4466
|
"",
|
|
4516
|
-
...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
|
+
})
|
|
4517
4471
|
].join("\n"), "Install Plan");
|
|
4518
4472
|
}
|
|
4519
|
-
async function
|
|
4473
|
+
async function Go(e, t) {
|
|
4520
4474
|
let n = [];
|
|
4521
4475
|
for (let r of e) {
|
|
4522
|
-
let e = await
|
|
4476
|
+
let e = await Rr(r), i = await zr(r, t);
|
|
4523
4477
|
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'npx @hype-stack/cli login' or check your license.`);
|
|
4524
4478
|
n.push({
|
|
4525
4479
|
manifest: e,
|
|
@@ -4528,32 +4482,38 @@ async function Jo(e, t) {
|
|
|
4528
4482
|
}
|
|
4529
4483
|
return n;
|
|
4530
4484
|
}
|
|
4531
|
-
async function
|
|
4532
|
-
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);
|
|
4533
4487
|
if (a.errors.length > 0) {
|
|
4534
4488
|
for (let e of a.errors) s.log.error(e);
|
|
4535
4489
|
return;
|
|
4536
4490
|
}
|
|
4537
4491
|
if (a.operations.length === 0) return;
|
|
4538
4492
|
i.start("Installing npm dependencies...");
|
|
4539
|
-
let o = await
|
|
4493
|
+
let o = await Bo(a.operations, r);
|
|
4540
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);
|
|
4541
4495
|
}
|
|
4542
|
-
function
|
|
4543
|
-
|
|
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
|
+
}]);
|
|
4544
4504
|
}
|
|
4545
|
-
function
|
|
4505
|
+
function Jo(e) {
|
|
4546
4506
|
if (e.length === 0) return;
|
|
4547
4507
|
let t = e.map((e) => {
|
|
4548
4508
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
4549
|
-
return ` ${
|
|
4509
|
+
return ` ${L.muted("•")} ${L.path(t)}`;
|
|
4550
4510
|
});
|
|
4551
4511
|
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4552
4512
|
}
|
|
4553
|
-
async function
|
|
4513
|
+
async function Yo(e) {
|
|
4554
4514
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
|
|
4555
4515
|
if (i) return c;
|
|
4556
|
-
let l = await
|
|
4516
|
+
let l = await ea({
|
|
4557
4517
|
packs: t,
|
|
4558
4518
|
config: n,
|
|
4559
4519
|
projectRoot: r,
|
|
@@ -4561,17 +4521,17 @@ async function Qo(e) {
|
|
|
4561
4521
|
});
|
|
4562
4522
|
if (l.length === 0) return c;
|
|
4563
4523
|
if (a) {
|
|
4564
|
-
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.`);
|
|
4565
4525
|
let e = l.map((e) => {
|
|
4566
4526
|
let t = T.relative(r, e.targetPath) || e.target;
|
|
4567
|
-
return ` ${
|
|
4527
|
+
return ` ${L.muted("•")} ${L.path(t)} ${L.muted(`(${e.packName})`)}`;
|
|
4568
4528
|
});
|
|
4569
4529
|
return s.note(e.join("\n"), "Kept existing files"), c;
|
|
4570
4530
|
}
|
|
4571
4531
|
s.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4572
4532
|
for (let e of l) {
|
|
4573
4533
|
let t = T.relative(r, e.targetPath) || e.target, n = await s.confirm({
|
|
4574
|
-
message: `Overwrite ${
|
|
4534
|
+
message: `Overwrite ${L.path(t)}? ${L.muted(`(${e.packName})`)}`,
|
|
4575
4535
|
initialValue: !1
|
|
4576
4536
|
});
|
|
4577
4537
|
s.isCancel(n) && (s.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
|
|
@@ -4580,7 +4540,7 @@ async function Qo(e) {
|
|
|
4580
4540
|
}
|
|
4581
4541
|
//#endregion
|
|
4582
4542
|
//#region src/ui/swatch.ts
|
|
4583
|
-
function
|
|
4543
|
+
function Xo(e) {
|
|
4584
4544
|
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4585
4545
|
if (!t) return null;
|
|
4586
4546
|
let n = t[1].trim().split(/\s+/);
|
|
@@ -4599,58 +4559,58 @@ function $o(e) {
|
|
|
4599
4559
|
h: a
|
|
4600
4560
|
};
|
|
4601
4561
|
}
|
|
4602
|
-
function
|
|
4562
|
+
function Zo(e) {
|
|
4603
4563
|
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4604
4564
|
}
|
|
4605
|
-
function
|
|
4565
|
+
function Qo(e) {
|
|
4606
4566
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4607
4567
|
}
|
|
4608
|
-
function
|
|
4568
|
+
function $o({ l: e, c: t, h: n }) {
|
|
4609
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;
|
|
4610
4570
|
return [
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4571
|
+
Zo(Qo(f) * 255),
|
|
4572
|
+
Zo(Qo(p) * 255),
|
|
4573
|
+
Zo(Qo(m) * 255)
|
|
4614
4574
|
];
|
|
4615
4575
|
}
|
|
4616
|
-
var
|
|
4617
|
-
function
|
|
4576
|
+
var es = "\x1B[49m";
|
|
4577
|
+
function ts(e, t) {
|
|
4618
4578
|
let n = e[t];
|
|
4619
4579
|
if (!n) return b.dim(" ");
|
|
4620
|
-
let r =
|
|
4580
|
+
let r = Xo(n);
|
|
4621
4581
|
if (!r) return b.dim(" ");
|
|
4622
|
-
let [i, a, o] =
|
|
4623
|
-
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}`;
|
|
4624
4584
|
}
|
|
4625
|
-
var
|
|
4585
|
+
var ns = [
|
|
4626
4586
|
"primary",
|
|
4627
4587
|
"secondary",
|
|
4628
4588
|
"accent"
|
|
4629
4589
|
];
|
|
4630
|
-
function
|
|
4631
|
-
return
|
|
4590
|
+
function rs(e) {
|
|
4591
|
+
return ns.map((t) => ts(e, t)).join("");
|
|
4632
4592
|
}
|
|
4633
|
-
function
|
|
4634
|
-
return `${
|
|
4593
|
+
function is(e) {
|
|
4594
|
+
return `${rs(e.light)} ${b.dim("·")} ${rs(e.dark)}`;
|
|
4635
4595
|
}
|
|
4636
4596
|
//#endregion
|
|
4637
4597
|
//#region src/commands/create.ts
|
|
4638
|
-
async function
|
|
4639
|
-
e.skipBanner ||
|
|
4598
|
+
async function as(e) {
|
|
4599
|
+
e.skipBanner || Ua(), s.intro(L.brandBold("Create a new Hype Stack project"));
|
|
4640
4600
|
let o = e.yes === !0, c, l;
|
|
4641
4601
|
if (o && e.name) {
|
|
4642
|
-
let t =
|
|
4643
|
-
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);
|
|
4644
4604
|
} else {
|
|
4645
4605
|
let t = await s.text({
|
|
4646
4606
|
message: "What is your project named?",
|
|
4647
4607
|
placeholder: "my-app",
|
|
4648
4608
|
initialValue: e.name ?? "",
|
|
4649
|
-
validate: (e) =>
|
|
4609
|
+
validate: (e) => Ya(e ?? "")
|
|
4650
4610
|
});
|
|
4651
|
-
s.isCancel(t) &&
|
|
4611
|
+
s.isCancel(t) && B(), l = t, c = qa(l);
|
|
4652
4612
|
}
|
|
4653
|
-
l.trim() !== c && s.log.info(
|
|
4613
|
+
l.trim() !== c && s.log.info(L.muted(`Using "${L.highlight(c)}" as the project name`));
|
|
4654
4614
|
let u;
|
|
4655
4615
|
if (e.directory !== void 0) u = e.directory;
|
|
4656
4616
|
else {
|
|
@@ -4663,26 +4623,26 @@ async function cs(e) {
|
|
|
4663
4623
|
placeholder: ".",
|
|
4664
4624
|
initialValue: "."
|
|
4665
4625
|
});
|
|
4666
|
-
s.isCancel(e) &&
|
|
4626
|
+
s.isCancel(e) && B(), t = e;
|
|
4667
4627
|
}
|
|
4668
|
-
u =
|
|
4628
|
+
u = hr(t, c);
|
|
4669
4629
|
}
|
|
4670
4630
|
let d = T.resolve(u);
|
|
4671
|
-
o || s.note(
|
|
4672
|
-
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;
|
|
4673
4633
|
if (f) p = f;
|
|
4674
4634
|
else if (o) p = "cursor";
|
|
4675
4635
|
else {
|
|
4676
4636
|
let e = await s.select({
|
|
4677
4637
|
message: "Which code editor do you use?",
|
|
4678
|
-
options:
|
|
4638
|
+
options: P.map((e) => ({
|
|
4679
4639
|
value: e.value,
|
|
4680
4640
|
label: e.label,
|
|
4681
4641
|
hint: "hint" in e ? e.hint : void 0
|
|
4682
4642
|
})),
|
|
4683
4643
|
initialValue: "cursor"
|
|
4684
4644
|
});
|
|
4685
|
-
s.isCancel(e) &&
|
|
4645
|
+
s.isCancel(e) && B(), p = e;
|
|
4686
4646
|
}
|
|
4687
4647
|
let m = e.theme !== void 0 && a(e.theme), h = e.defaultTheme !== void 0 && a(e.defaultTheme) ? e.defaultTheme : t, g;
|
|
4688
4648
|
if (m) g = e.theme;
|
|
@@ -4692,139 +4652,139 @@ async function cs(e) {
|
|
|
4692
4652
|
message: "Pick a color theme",
|
|
4693
4653
|
options: r.map((e) => ({
|
|
4694
4654
|
value: e.name,
|
|
4695
|
-
label: `${
|
|
4655
|
+
label: `${is(e)} ${e.label}`
|
|
4696
4656
|
})),
|
|
4697
4657
|
initialValue: h
|
|
4698
4658
|
});
|
|
4699
|
-
s.isCancel(e) &&
|
|
4659
|
+
s.isCancel(e) && B(), g = e;
|
|
4700
4660
|
}
|
|
4701
4661
|
if (!o) {
|
|
4702
|
-
let e =
|
|
4703
|
-
(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();
|
|
4704
4664
|
}
|
|
4705
|
-
if (await
|
|
4665
|
+
if (await lr(d) && !await ur(d)) {
|
|
4706
4666
|
let e = await s.confirm({
|
|
4707
|
-
message: `Directory ${
|
|
4667
|
+
message: `Directory ${L.path(d)} is not empty. Continue anyway?`,
|
|
4708
4668
|
initialValue: !1
|
|
4709
4669
|
});
|
|
4710
|
-
(s.isCancel(e) || !e) &&
|
|
4670
|
+
(s.isCancel(e) || !e) && B();
|
|
4711
4671
|
}
|
|
4712
4672
|
let _ = s.spinner();
|
|
4713
|
-
_.start("Cloning Hype Stack template..."), await
|
|
4673
|
+
_.start("Cloning Hype Stack template..."), await oo(d), _.stop(L.success("Template cloned"));
|
|
4714
4674
|
let v = s.spinner();
|
|
4715
|
-
v.start("Setting up project..."), await
|
|
4716
|
-
let y = await
|
|
4717
|
-
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, {
|
|
4718
4678
|
projectName: c,
|
|
4719
4679
|
editor: p,
|
|
4720
4680
|
workspace: y
|
|
4721
4681
|
});
|
|
4722
4682
|
let x = T.resolve(d, b.paths?.frontend.root ?? "apps/frontend");
|
|
4723
|
-
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"));
|
|
4724
4684
|
let S = s.spinner();
|
|
4725
|
-
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.")));
|
|
4726
4686
|
let C = s.spinner();
|
|
4727
|
-
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"));
|
|
4728
4688
|
let w = s.spinner();
|
|
4729
4689
|
w.start("Creating .env files from examples...");
|
|
4730
|
-
let E = await
|
|
4690
|
+
let E = await go(d);
|
|
4731
4691
|
if (E.length > 0) {
|
|
4732
4692
|
let e = E.length;
|
|
4733
|
-
w.stop(
|
|
4734
|
-
} else w.stop(
|
|
4735
|
-
s.log.success(`${
|
|
4736
|
-
let D = T.relative(process.cwd(), d) || ".", O = [`${
|
|
4737
|
-
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);
|
|
4738
4698
|
let k = e.setup === !1;
|
|
4739
|
-
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."));
|
|
4740
4700
|
else {
|
|
4741
4701
|
let e = !k && (o || await s.confirm({
|
|
4742
4702
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
4743
4703
|
initialValue: !0
|
|
4744
4704
|
}));
|
|
4745
|
-
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();
|
|
4746
4706
|
}
|
|
4747
|
-
return await
|
|
4707
|
+
return await Lo("project_create"), s.outro(L.muted("Happy building!")), d;
|
|
4748
4708
|
}
|
|
4749
4709
|
//#endregion
|
|
4750
4710
|
//#region src/commands/init.ts
|
|
4751
|
-
async function
|
|
4711
|
+
async function os(e) {
|
|
4752
4712
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4753
|
-
if (n || (
|
|
4754
|
-
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.`));
|
|
4755
4715
|
return;
|
|
4756
4716
|
}
|
|
4757
|
-
if (await
|
|
4758
|
-
let e = await
|
|
4717
|
+
if (await Mr(t)) {
|
|
4718
|
+
let e = await jr(t);
|
|
4759
4719
|
if (e && !n) {
|
|
4760
|
-
s.log.info(`Found existing ${
|
|
4720
|
+
s.log.info(`Found existing ${L.path("stack.json")} for project ${L.highlight(e.name)}`);
|
|
4761
4721
|
let t = await s.confirm({
|
|
4762
4722
|
message: "Overwrite existing configuration?",
|
|
4763
4723
|
initialValue: !1
|
|
4764
4724
|
});
|
|
4765
4725
|
if (s.isCancel(t) || !t) {
|
|
4766
|
-
s.outro(
|
|
4726
|
+
s.outro(L.muted("Keeping existing configuration."));
|
|
4767
4727
|
return;
|
|
4768
4728
|
}
|
|
4769
4729
|
}
|
|
4770
4730
|
}
|
|
4771
|
-
let r = await
|
|
4731
|
+
let r = await Pr(t);
|
|
4772
4732
|
if (!n) {
|
|
4773
4733
|
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4774
4734
|
if (e.length > 0) {
|
|
4775
|
-
s.log.info(
|
|
4776
|
-
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}`)}`);
|
|
4777
4737
|
}
|
|
4778
4738
|
if (t.length > 0) {
|
|
4779
|
-
s.log.info(
|
|
4780
|
-
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}`)}`);
|
|
4781
4741
|
}
|
|
4782
4742
|
e.length === 0 && t.length === 0 && s.log.warn("No apps or packages detected in the workspace.");
|
|
4783
4743
|
}
|
|
4784
|
-
let i = (await
|
|
4744
|
+
let i = (await dr(T.join(t, "package.json")))?.name?.replace(/^@/, "").replace(/\/source$/, "") ?? "my-app", a = i;
|
|
4785
4745
|
if (!n) {
|
|
4786
4746
|
let e = await s.text({
|
|
4787
4747
|
message: "Project name for stack.json?",
|
|
4788
4748
|
placeholder: i,
|
|
4789
4749
|
initialValue: i,
|
|
4790
|
-
validate: (e) =>
|
|
4750
|
+
validate: (e) => Ya(e ?? "")
|
|
4791
4751
|
});
|
|
4792
|
-
s.isCancel(e) &&
|
|
4752
|
+
s.isCancel(e) && B(), a = qa(e);
|
|
4793
4753
|
}
|
|
4794
|
-
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.")));
|
|
4795
4755
|
}
|
|
4796
|
-
async function
|
|
4797
|
-
if (await
|
|
4756
|
+
async function ss(e, t = {}, n) {
|
|
4757
|
+
if (await Mr(e)) return {
|
|
4798
4758
|
projectRoot: e,
|
|
4799
4759
|
scaffolded: !1
|
|
4800
4760
|
};
|
|
4801
|
-
let r = t.runInit ?? ((e) =>
|
|
4761
|
+
let r = t.runInit ?? ((e) => os({
|
|
4802
4762
|
cwd: e,
|
|
4803
4763
|
silent: !0
|
|
4804
|
-
})), i = t.runCreate ?? ((e, t) =>
|
|
4764
|
+
})), i = t.runCreate ?? ((e, t) => as({
|
|
4805
4765
|
parentDirectory: e,
|
|
4806
4766
|
deferSetup: !0,
|
|
4807
4767
|
skipBanner: !0,
|
|
4808
4768
|
defaultTheme: t?.defaultTheme,
|
|
4809
4769
|
defaultMode: t?.defaultMode
|
|
4810
4770
|
}));
|
|
4811
|
-
if (await
|
|
4812
|
-
s.log.warn(`No ${
|
|
4771
|
+
if (await Lr(e)) {
|
|
4772
|
+
s.log.warn(`No ${L.path("stack.json")} found in ${L.path(e)}.`);
|
|
4813
4773
|
let t = await s.confirm({
|
|
4814
|
-
message: `Create ${
|
|
4774
|
+
message: `Create ${L.path("stack.json")} now?`,
|
|
4815
4775
|
initialValue: !0
|
|
4816
4776
|
});
|
|
4817
4777
|
if (s.isCancel(t) || !t) return null;
|
|
4818
4778
|
await r(e);
|
|
4819
|
-
let n = await
|
|
4820
|
-
return n && s.log.success(`${
|
|
4779
|
+
let n = await Mr(e);
|
|
4780
|
+
return n && s.log.success(`${L.path("stack.json")} created`), n ? {
|
|
4821
4781
|
projectRoot: e,
|
|
4822
4782
|
scaffolded: !1
|
|
4823
4783
|
} : null;
|
|
4824
4784
|
}
|
|
4825
|
-
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.`);
|
|
4826
4786
|
let a = await s.confirm({
|
|
4827
|
-
message: `Is ${
|
|
4787
|
+
message: `Is ${L.path(e)} where you want to work?`,
|
|
4828
4788
|
initialValue: !0
|
|
4829
4789
|
});
|
|
4830
4790
|
if (s.isCancel(a) || !a) return null;
|
|
@@ -4834,41 +4794,41 @@ async function us(e, t = {}, n) {
|
|
|
4834
4794
|
});
|
|
4835
4795
|
if (s.isCancel(o) || !o) return null;
|
|
4836
4796
|
let c = await i(e, n);
|
|
4837
|
-
return await
|
|
4797
|
+
return await Mr(c) ? {
|
|
4838
4798
|
projectRoot: c,
|
|
4839
4799
|
scaffolded: !0
|
|
4840
4800
|
} : null;
|
|
4841
4801
|
}
|
|
4842
4802
|
//#endregion
|
|
4843
4803
|
//#region src/commands/compose.ts
|
|
4844
|
-
async function
|
|
4804
|
+
async function cs(e = {}) {
|
|
4845
4805
|
let t = e.cwd ?? process.cwd();
|
|
4846
|
-
|
|
4847
|
-
let n = await
|
|
4806
|
+
Ua();
|
|
4807
|
+
let n = await ss(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4848
4808
|
try {
|
|
4849
|
-
a = await
|
|
4809
|
+
a = await jr(r ?? t);
|
|
4850
4810
|
} catch (e) {
|
|
4851
|
-
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);
|
|
4852
4812
|
}
|
|
4853
|
-
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));
|
|
4854
4814
|
let o = r ?? t;
|
|
4855
|
-
s.intro(
|
|
4815
|
+
s.intro(L.brandBold("Compose your stack"));
|
|
4856
4816
|
let c = s.spinner();
|
|
4857
4817
|
c.start("Loading packs...");
|
|
4858
4818
|
let l;
|
|
4859
4819
|
try {
|
|
4860
|
-
l = await
|
|
4820
|
+
l = await Ur();
|
|
4861
4821
|
} catch (e) {
|
|
4862
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);
|
|
4863
4823
|
}
|
|
4864
4824
|
c.stop("Packs loaded");
|
|
4865
|
-
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, {
|
|
4866
4826
|
token: m,
|
|
4867
4827
|
key: p
|
|
4868
4828
|
}), g = (e) => {
|
|
4869
4829
|
let t = f.get(e);
|
|
4870
4830
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4871
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await
|
|
4831
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await ls({
|
|
4872
4832
|
packs: l,
|
|
4873
4833
|
installedSet: d,
|
|
4874
4834
|
stateOf: g,
|
|
@@ -4876,49 +4836,49 @@ async function ds(e = {}) {
|
|
|
4876
4836
|
adminAvailable: !!a.apps.admin
|
|
4877
4837
|
});
|
|
4878
4838
|
if (v === null && (s.cancel("Cancelled."), process.exit(0)), v.length === 0) {
|
|
4879
|
-
s.outro(
|
|
4839
|
+
s.outro(L.muted("No packs selected. Nothing to do."));
|
|
4880
4840
|
return;
|
|
4881
4841
|
}
|
|
4882
|
-
let b =
|
|
4842
|
+
let b = fs(v), x = ps(v), S = Na(l, b), C = Ea(Pa(l, S)), w;
|
|
4883
4843
|
try {
|
|
4884
|
-
w =
|
|
4844
|
+
w = Oa(b, C, u);
|
|
4885
4845
|
} catch (e) {
|
|
4886
4846
|
s.cancel($(e)), process.exit(1);
|
|
4887
4847
|
}
|
|
4888
4848
|
if (w.order.length === 0) {
|
|
4889
|
-
|
|
4849
|
+
z(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(L.muted("Your selection is already part of the project."));
|
|
4890
4850
|
return;
|
|
4891
4851
|
}
|
|
4892
|
-
let T =
|
|
4852
|
+
let T = ka({
|
|
4893
4853
|
order: w.order,
|
|
4894
4854
|
graph: C,
|
|
4895
4855
|
isLocked: _,
|
|
4896
4856
|
installed: u
|
|
4897
4857
|
});
|
|
4898
4858
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4899
|
-
let e = await
|
|
4900
|
-
e && (m = e, h = await
|
|
4859
|
+
let e = await or();
|
|
4860
|
+
e && (m = e, h = await Vo(l, d, {
|
|
4901
4861
|
token: m,
|
|
4902
4862
|
key: p
|
|
4903
|
-
}), T =
|
|
4863
|
+
}), T = ka({
|
|
4904
4864
|
order: w.order,
|
|
4905
4865
|
graph: C,
|
|
4906
4866
|
isLocked: _,
|
|
4907
4867
|
installed: u
|
|
4908
4868
|
}));
|
|
4909
4869
|
}
|
|
4910
|
-
if (T.blocked.length > 0 && await
|
|
4911
|
-
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."));
|
|
4912
4872
|
return;
|
|
4913
4873
|
}
|
|
4914
|
-
if (
|
|
4874
|
+
if (Wo(T.installable, f), !e.yes) {
|
|
4915
4875
|
let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4916
4876
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
4917
4877
|
}
|
|
4918
4878
|
c.start("Downloading packs...");
|
|
4919
4879
|
let E;
|
|
4920
4880
|
try {
|
|
4921
|
-
E = await
|
|
4881
|
+
E = await Go(T.installable, {
|
|
4922
4882
|
token: m,
|
|
4923
4883
|
key: p
|
|
4924
4884
|
});
|
|
@@ -4926,7 +4886,7 @@ async function ds(e = {}) {
|
|
|
4926
4886
|
c.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
4927
4887
|
}
|
|
4928
4888
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4929
|
-
let D = await
|
|
4889
|
+
let D = await Yo({
|
|
4930
4890
|
prepared: E,
|
|
4931
4891
|
config: a,
|
|
4932
4892
|
cwd: o,
|
|
@@ -4936,7 +4896,7 @@ async function ds(e = {}) {
|
|
|
4936
4896
|
});
|
|
4937
4897
|
try {
|
|
4938
4898
|
c.start("Installing pack files...");
|
|
4939
|
-
let t = await
|
|
4899
|
+
let t = await ra({
|
|
4940
4900
|
packs: E,
|
|
4941
4901
|
config: a,
|
|
4942
4902
|
projectRoot: o,
|
|
@@ -4949,22 +4909,22 @@ async function ds(e = {}) {
|
|
|
4949
4909
|
for (let e of t.errors) s.log.error(e);
|
|
4950
4910
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4951
4911
|
}
|
|
4952
|
-
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));
|
|
4953
4913
|
for (let e of t.errors) s.log.error(e);
|
|
4954
|
-
await
|
|
4914
|
+
await Ko({
|
|
4955
4915
|
prepared: E,
|
|
4956
4916
|
paths: a.paths,
|
|
4957
4917
|
cwd: o,
|
|
4958
4918
|
spinner: c
|
|
4959
4919
|
});
|
|
4960
4920
|
let n;
|
|
4961
|
-
i && (n = await
|
|
4921
|
+
i && (n = await Ta(o, e.yes ?? !1)), await _r({
|
|
4962
4922
|
projectRoot: o,
|
|
4963
4923
|
paths: a.paths,
|
|
4964
4924
|
skipPrompts: e.yes ?? !1,
|
|
4965
4925
|
dbReady: n,
|
|
4966
4926
|
freshScaffold: i
|
|
4967
|
-
}),
|
|
4927
|
+
}), qo(), s.outro(L.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4968
4928
|
} finally {
|
|
4969
4929
|
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
4970
4930
|
recursive: !0,
|
|
@@ -4972,25 +4932,25 @@ async function ds(e = {}) {
|
|
|
4972
4932
|
})));
|
|
4973
4933
|
}
|
|
4974
4934
|
}
|
|
4975
|
-
async function
|
|
4935
|
+
async function ls(e) {
|
|
4976
4936
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4977
4937
|
if (i.packs && i.packs.length > 0) {
|
|
4978
|
-
let e = i.packs.map(
|
|
4938
|
+
let e = i.packs.map(ds), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4979
4939
|
return n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4980
4940
|
}
|
|
4981
4941
|
let o = t.filter((e) => n.has(e.name));
|
|
4982
|
-
o.length > 0 &&
|
|
4942
|
+
o.length > 0 && z(o.map((e) => ` ${L.success("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4983
4943
|
let c = t.filter((e) => !n.has(e.name));
|
|
4984
|
-
if (c.length === 0) return s.outro(
|
|
4985
|
-
let l =
|
|
4986
|
-
|
|
4987
|
-
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 = [];
|
|
4988
4948
|
for (let e of u) {
|
|
4989
4949
|
let t = e.packs.map((e) => {
|
|
4990
4950
|
let t = r(e.name);
|
|
4991
4951
|
return {
|
|
4992
4952
|
value: e.name,
|
|
4993
|
-
label: `${e.displayName} ${
|
|
4953
|
+
label: `${e.displayName} ${Ho(t, e.price)}`,
|
|
4994
4954
|
hint: e.description
|
|
4995
4955
|
};
|
|
4996
4956
|
});
|
|
@@ -5007,7 +4967,7 @@ async function fs(e) {
|
|
|
5007
4967
|
});
|
|
5008
4968
|
continue;
|
|
5009
4969
|
}
|
|
5010
|
-
let n = await
|
|
4970
|
+
let n = await Ka({
|
|
5011
4971
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
5012
4972
|
options: t,
|
|
5013
4973
|
required: !1
|
|
@@ -5017,20 +4977,20 @@ async function fs(e) {
|
|
|
5017
4977
|
}
|
|
5018
4978
|
return d;
|
|
5019
4979
|
}
|
|
5020
|
-
var
|
|
5021
|
-
function
|
|
5022
|
-
let t = e.match(
|
|
4980
|
+
var us = /@(frontend|admin)$/;
|
|
4981
|
+
function ds(e) {
|
|
4982
|
+
let t = e.match(us);
|
|
5023
4983
|
return t ? {
|
|
5024
4984
|
name: e.slice(0, -t[0].length),
|
|
5025
4985
|
slot: t[1]
|
|
5026
4986
|
} : { name: e };
|
|
5027
4987
|
}
|
|
5028
|
-
function
|
|
4988
|
+
function fs(e) {
|
|
5029
4989
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
5030
4990
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
5031
4991
|
return n;
|
|
5032
4992
|
}
|
|
5033
|
-
function
|
|
4993
|
+
function ps(e) {
|
|
5034
4994
|
let t = /* @__PURE__ */ new Map();
|
|
5035
4995
|
for (let n of e) {
|
|
5036
4996
|
if (!n.slot) continue;
|
|
@@ -5041,32 +5001,32 @@ function gs(e) {
|
|
|
5041
5001
|
}
|
|
5042
5002
|
//#endregion
|
|
5043
5003
|
//#region src/commands/login.ts
|
|
5044
|
-
async function
|
|
5045
|
-
|
|
5004
|
+
async function ms() {
|
|
5005
|
+
Wa(), s.intro(L.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
5046
5006
|
let e;
|
|
5047
5007
|
try {
|
|
5048
|
-
e = await
|
|
5049
|
-
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)}`);
|
|
5050
5010
|
} });
|
|
5051
5011
|
} catch (e) {
|
|
5052
5012
|
s.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
|
|
5053
5013
|
}
|
|
5054
|
-
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."));
|
|
5055
5015
|
}
|
|
5056
5016
|
//#endregion
|
|
5057
5017
|
//#region src/commands/logout.ts
|
|
5058
|
-
async function
|
|
5059
|
-
|
|
5060
|
-
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);
|
|
5061
5021
|
if (!t) {
|
|
5062
|
-
s.outro(
|
|
5022
|
+
s.outro(L.muted("You're not logged in."));
|
|
5063
5023
|
return;
|
|
5064
5024
|
}
|
|
5065
|
-
await
|
|
5025
|
+
await Hn(t.token).catch(() => null), await Qn(e), s.outro(L.brand("Logged out."));
|
|
5066
5026
|
}
|
|
5067
5027
|
//#endregion
|
|
5068
5028
|
//#region src/core/onboard-env.ts
|
|
5069
|
-
function
|
|
5029
|
+
function gs(e) {
|
|
5070
5030
|
let t = [], n = "";
|
|
5071
5031
|
for (let r of e.split(/\r?\n/)) {
|
|
5072
5032
|
let e = r.trim();
|
|
@@ -5092,7 +5052,14 @@ function ys(e) {
|
|
|
5092
5052
|
}
|
|
5093
5053
|
return t;
|
|
5094
5054
|
}
|
|
5095
|
-
function
|
|
5055
|
+
function _s(e) {
|
|
5056
|
+
let t = e.trim();
|
|
5057
|
+
if (t === "") return "";
|
|
5058
|
+
if (t.length <= 4) return "•".repeat(t.length);
|
|
5059
|
+
let n = Math.min(t.length - 4, 8);
|
|
5060
|
+
return `${"•".repeat(n)}${t.slice(-4)}`;
|
|
5061
|
+
}
|
|
5062
|
+
function vs(e, t, n) {
|
|
5096
5063
|
let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
|
|
5097
5064
|
if (i) return e;
|
|
5098
5065
|
let r = e.trim();
|
|
@@ -5102,118 +5069,118 @@ function bs(e, t, n) {
|
|
|
5102
5069
|
});
|
|
5103
5070
|
return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
|
|
5104
5071
|
}
|
|
5105
|
-
async function
|
|
5106
|
-
return await
|
|
5072
|
+
async function ys(e) {
|
|
5073
|
+
return await Y(e) ? y.readFile(e, "utf-8") : "";
|
|
5107
5074
|
}
|
|
5108
|
-
async function
|
|
5075
|
+
async function bs(e) {
|
|
5109
5076
|
let t = T.join(T.dirname(e), ".env");
|
|
5110
|
-
return await
|
|
5077
|
+
return await Y(t) || await y.copyFile(e, t), t;
|
|
5111
5078
|
}
|
|
5112
|
-
async function
|
|
5113
|
-
let r =
|
|
5079
|
+
async function xs(e, t, n) {
|
|
5080
|
+
let r = vs(await ys(e), t, n);
|
|
5114
5081
|
await y.writeFile(e, r, "utf-8");
|
|
5115
5082
|
}
|
|
5116
5083
|
//#endregion
|
|
5117
5084
|
//#region src/commands/onboard.ts
|
|
5118
|
-
async function
|
|
5085
|
+
async function Ss(e = {}) {
|
|
5119
5086
|
let t = e.cwd ?? process.cwd();
|
|
5120
|
-
|
|
5087
|
+
Ua(), s.intro(L.brandBold("Onboard your stack"));
|
|
5121
5088
|
let n;
|
|
5122
5089
|
try {
|
|
5123
|
-
n = await
|
|
5090
|
+
n = await jr(t);
|
|
5124
5091
|
} catch {
|
|
5125
5092
|
n = null;
|
|
5126
5093
|
}
|
|
5127
|
-
n || (s.cancel(`${
|
|
5128
|
-
let r = n.installedPacks ?? [], i = n.onboarding?.envSections ?? [], a = await
|
|
5129
|
-
a.length === 0 && s.log.warn(
|
|
5130
|
-
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({
|
|
5131
5098
|
examplePath: n,
|
|
5132
5099
|
projectRoot: t,
|
|
5133
5100
|
skipPrompts: e.yes ?? !1,
|
|
5134
5101
|
installedEnvSections: i
|
|
5135
5102
|
});
|
|
5136
|
-
let o =
|
|
5137
|
-
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.`));
|
|
5138
5105
|
}
|
|
5139
|
-
async function
|
|
5140
|
-
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);
|
|
5141
5108
|
s.log.step(`Env: ${u}`);
|
|
5142
5109
|
for (let e of l) {
|
|
5143
5110
|
if (e.vars.length === 0) continue;
|
|
5144
|
-
if (!
|
|
5145
|
-
let t = e.section ?
|
|
5146
|
-
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)")}`);
|
|
5147
5114
|
continue;
|
|
5148
5115
|
}
|
|
5149
|
-
let t =
|
|
5150
|
-
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."));
|
|
5151
5118
|
for (let n of e.vars) {
|
|
5152
5119
|
if (r) {
|
|
5153
|
-
s.log.info(`${
|
|
5120
|
+
s.log.info(`${L.label(n.key)} ${L.muted("skipped (non-interactive)")}`);
|
|
5154
5121
|
continue;
|
|
5155
5122
|
}
|
|
5156
|
-
let e =
|
|
5157
|
-
message: `${
|
|
5158
|
-
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
|
|
5159
5126
|
});
|
|
5160
|
-
s.isCancel(i) &&
|
|
5127
|
+
s.isCancel(i) && B();
|
|
5161
5128
|
let a = (i ?? "").trim();
|
|
5162
5129
|
if (a === "") {
|
|
5163
|
-
s.log.info(
|
|
5130
|
+
s.log.info(L.muted(`${n.key} unchanged.`));
|
|
5164
5131
|
continue;
|
|
5165
5132
|
}
|
|
5166
|
-
await
|
|
5133
|
+
await xs(o, n.key, a), s.log.success(`${n.key} saved`);
|
|
5167
5134
|
}
|
|
5168
5135
|
}
|
|
5169
5136
|
}
|
|
5170
|
-
function
|
|
5137
|
+
function ws(e, t) {
|
|
5171
5138
|
for (let n of e.split(/\r?\n/)) {
|
|
5172
|
-
let e = n.match(RegExp(`^${
|
|
5139
|
+
let e = n.match(RegExp(`^${Ts(t)}\\s*=\\s*(.*)$`));
|
|
5173
5140
|
if (e) return e[1].trim();
|
|
5174
5141
|
}
|
|
5175
5142
|
return "";
|
|
5176
5143
|
}
|
|
5177
|
-
function
|
|
5144
|
+
function Ts(e) {
|
|
5178
5145
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5179
5146
|
}
|
|
5180
|
-
async function
|
|
5181
|
-
if (!await
|
|
5182
|
-
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")}.`));
|
|
5183
5150
|
return;
|
|
5184
5151
|
}
|
|
5185
5152
|
let n = s.spinner();
|
|
5186
|
-
if (n.start("Waiting for Postgres to be ready..."), !await
|
|
5187
|
-
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")}`));
|
|
5188
5155
|
return;
|
|
5189
5156
|
}
|
|
5190
|
-
if (n.stop(
|
|
5191
|
-
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."));
|
|
5192
5159
|
return;
|
|
5193
5160
|
}
|
|
5194
5161
|
let r = t ? !0 : await s.confirm({
|
|
5195
|
-
message: `Run database migrations with ${
|
|
5162
|
+
message: `Run database migrations with ${L.command("prisma migrate deploy")}?`,
|
|
5196
5163
|
initialValue: !0
|
|
5197
5164
|
});
|
|
5198
|
-
if (s.isCancel(r) &&
|
|
5199
|
-
s.log.info(
|
|
5165
|
+
if (s.isCancel(r) && B(), !r) {
|
|
5166
|
+
s.log.info(L.muted("Skipping database migrations."));
|
|
5200
5167
|
return;
|
|
5201
5168
|
}
|
|
5202
|
-
await
|
|
5169
|
+
await xa(e);
|
|
5203
5170
|
}
|
|
5204
5171
|
//#endregion
|
|
5205
5172
|
//#region src/core/templates.ts
|
|
5206
|
-
var
|
|
5173
|
+
var Ds = q.createRequest()({
|
|
5207
5174
|
endpoint: "/templates/list",
|
|
5208
5175
|
method: "GET"
|
|
5209
5176
|
});
|
|
5210
|
-
async function
|
|
5211
|
-
let { data: e, error: t } = await
|
|
5177
|
+
async function Os() {
|
|
5178
|
+
let { data: e, error: t } = await Ds.send();
|
|
5212
5179
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
5213
5180
|
return e.templates;
|
|
5214
5181
|
}
|
|
5215
|
-
async function
|
|
5216
|
-
let { data: t, error: n, status: r } = await
|
|
5182
|
+
async function ks(e) {
|
|
5183
|
+
let { data: t, error: n, status: r } = await q.createRequest()({
|
|
5217
5184
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
5218
5185
|
method: "GET"
|
|
5219
5186
|
}).send();
|
|
@@ -5221,13 +5188,13 @@ async function js(e) {
|
|
|
5221
5188
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
5222
5189
|
return t;
|
|
5223
5190
|
}
|
|
5224
|
-
async function
|
|
5225
|
-
let n =
|
|
5191
|
+
async function As(e, t = {}) {
|
|
5192
|
+
let n = q.createRequest()({
|
|
5226
5193
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
5227
5194
|
method: "POST"
|
|
5228
5195
|
}), r = {
|
|
5229
|
-
"X-Device-Id":
|
|
5230
|
-
"X-Client-Info":
|
|
5196
|
+
"X-Device-Id": er(),
|
|
5197
|
+
"X-Client-Info": tr()
|
|
5231
5198
|
};
|
|
5232
5199
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
5233
5200
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -5249,29 +5216,29 @@ async function Ms(e, t = {}) {
|
|
|
5249
5216
|
}
|
|
5250
5217
|
//#endregion
|
|
5251
5218
|
//#region src/commands/template.ts
|
|
5252
|
-
async function
|
|
5219
|
+
async function js(t = {}) {
|
|
5253
5220
|
let n = t.cwd ?? process.cwd();
|
|
5254
|
-
|
|
5221
|
+
Ua();
|
|
5255
5222
|
let r = s.spinner();
|
|
5256
5223
|
r.start("Loading packs...");
|
|
5257
5224
|
let o;
|
|
5258
5225
|
try {
|
|
5259
|
-
o = await
|
|
5226
|
+
o = await Ur();
|
|
5260
5227
|
} catch (e) {
|
|
5261
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);
|
|
5262
5229
|
}
|
|
5263
5230
|
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
5264
5231
|
let c;
|
|
5265
5232
|
try {
|
|
5266
|
-
c = await
|
|
5233
|
+
c = await Os();
|
|
5267
5234
|
} catch (e) {
|
|
5268
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);
|
|
5269
5236
|
}
|
|
5270
5237
|
let l = t.templateId;
|
|
5271
5238
|
if (!l) {
|
|
5272
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");
|
|
5273
|
-
let e =
|
|
5274
|
-
|
|
5240
|
+
let e = le();
|
|
5241
|
+
z(c.map((t) => ` ${R.arrow} ${L.highlight(t.name)} ${ve(`${e}/templates/${t.id}`)}`).join("\n"), "Browse templates");
|
|
5275
5242
|
let n = await s.select({
|
|
5276
5243
|
message: "Choose a template",
|
|
5277
5244
|
options: c.map((e) => ({
|
|
@@ -5286,151 +5253,151 @@ async function Ns(t = {}) {
|
|
|
5286
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}`);
|
|
5287
5254
|
let d;
|
|
5288
5255
|
try {
|
|
5289
|
-
d = await
|
|
5256
|
+
d = await ks(u.id);
|
|
5290
5257
|
} catch (e) {
|
|
5291
5258
|
s.cancel($(e)), process.exit(1);
|
|
5292
5259
|
}
|
|
5293
|
-
let f = await
|
|
5260
|
+
let f = await ss(n, {}, {
|
|
5294
5261
|
defaultTheme: d.theme,
|
|
5295
5262
|
defaultMode: d.defaultMode
|
|
5296
5263
|
}), p = f?.projectRoot ?? null, m = f?.scaffolded ?? !1, h;
|
|
5297
5264
|
try {
|
|
5298
|
-
h = await
|
|
5265
|
+
h = await jr(p ?? n);
|
|
5299
5266
|
} catch (e) {
|
|
5300
|
-
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);
|
|
5301
5268
|
}
|
|
5302
|
-
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));
|
|
5303
5270
|
let g = p ?? n;
|
|
5304
|
-
s.intro(
|
|
5305
|
-
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({
|
|
5306
5273
|
packs: o,
|
|
5307
5274
|
templatePacks: E,
|
|
5308
5275
|
installedSet: v,
|
|
5309
5276
|
options: t
|
|
5310
5277
|
}), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
|
|
5311
5278
|
k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
|
|
5312
|
-
let ee =
|
|
5279
|
+
let ee = Pa(o, w), A = Ea(ee), te;
|
|
5313
5280
|
try {
|
|
5314
|
-
|
|
5281
|
+
te = Oa(O, A, _);
|
|
5315
5282
|
} catch (e) {
|
|
5316
5283
|
s.cancel($(e)), process.exit(1);
|
|
5317
5284
|
}
|
|
5318
|
-
if (
|
|
5319
|
-
s.outro(
|
|
5285
|
+
if (te.order.length === 0) {
|
|
5286
|
+
s.outro(L.muted("Every pack in this template is already installed."));
|
|
5320
5287
|
return;
|
|
5321
5288
|
}
|
|
5322
|
-
let
|
|
5289
|
+
let ne = await Vo(ee, v, {
|
|
5323
5290
|
token: S,
|
|
5324
5291
|
key: x
|
|
5325
|
-
}),
|
|
5292
|
+
}), re = (e) => {
|
|
5326
5293
|
let t = b.get(e);
|
|
5327
|
-
return !t || t.tier === "free" ? "free" :
|
|
5328
|
-
},
|
|
5329
|
-
order:
|
|
5294
|
+
return !t || t.tier === "free" ? "free" : ne[e]?.owned ? "owned" : "locked";
|
|
5295
|
+
}, j = (e) => !v.has(e) && re(e) === "locked", M = ka({
|
|
5296
|
+
order: te.order,
|
|
5330
5297
|
graph: A,
|
|
5331
|
-
isLocked:
|
|
5298
|
+
isLocked: j,
|
|
5332
5299
|
installed: _
|
|
5333
5300
|
});
|
|
5334
|
-
if (
|
|
5335
|
-
let e = await
|
|
5336
|
-
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, {
|
|
5337
5304
|
token: S,
|
|
5338
5305
|
key: x
|
|
5339
|
-
}),
|
|
5340
|
-
order:
|
|
5306
|
+
}), M = ka({
|
|
5307
|
+
order: te.order,
|
|
5341
5308
|
graph: A,
|
|
5342
|
-
isLocked:
|
|
5309
|
+
isLocked: j,
|
|
5343
5310
|
installed: _
|
|
5344
5311
|
}));
|
|
5345
5312
|
}
|
|
5346
|
-
if (
|
|
5347
|
-
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."));
|
|
5348
5315
|
return;
|
|
5349
5316
|
}
|
|
5350
|
-
if (
|
|
5351
|
-
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"})?` });
|
|
5352
5319
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5353
5320
|
}
|
|
5354
5321
|
r.start("Downloading packs...");
|
|
5355
|
-
let
|
|
5322
|
+
let N;
|
|
5356
5323
|
try {
|
|
5357
|
-
|
|
5324
|
+
N = await Go(M.installable, {
|
|
5358
5325
|
token: S,
|
|
5359
5326
|
key: x
|
|
5360
5327
|
});
|
|
5361
5328
|
} catch (e) {
|
|
5362
5329
|
r.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
5363
5330
|
}
|
|
5364
|
-
r.stop(`Downloaded ${
|
|
5365
|
-
let
|
|
5366
|
-
prepared:
|
|
5331
|
+
r.stop(`Downloaded ${N.length} pack${N.length === 1 ? "" : "s"}`);
|
|
5332
|
+
let ie = await Yo({
|
|
5333
|
+
prepared: N,
|
|
5367
5334
|
config: h,
|
|
5368
5335
|
cwd: g,
|
|
5369
5336
|
force: t.force ?? !1,
|
|
5370
5337
|
yes: t.yes ?? !1
|
|
5371
|
-
}),
|
|
5338
|
+
}), P = null;
|
|
5372
5339
|
try {
|
|
5373
5340
|
r.start("Installing pack files...");
|
|
5374
|
-
let n = await
|
|
5375
|
-
packs:
|
|
5341
|
+
let n = await ra({
|
|
5342
|
+
packs: N,
|
|
5376
5343
|
config: h,
|
|
5377
5344
|
projectRoot: g,
|
|
5378
5345
|
force: t.force ?? !1,
|
|
5379
|
-
overwrite:
|
|
5346
|
+
overwrite: ie
|
|
5380
5347
|
});
|
|
5381
5348
|
if (n.aborted) {
|
|
5382
5349
|
r.stop("Installation aborted");
|
|
5383
5350
|
for (let e of n.errors) s.log.error(e);
|
|
5384
5351
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5385
5352
|
}
|
|
5386
|
-
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));
|
|
5387
5354
|
for (let e of n.errors) s.log.error(e);
|
|
5388
5355
|
r.start("Applying template overrides...");
|
|
5389
|
-
let o = await
|
|
5356
|
+
let o = await As(u.id, {
|
|
5390
5357
|
token: S,
|
|
5391
5358
|
licenseKey: x
|
|
5392
5359
|
});
|
|
5393
|
-
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)),
|
|
5394
|
-
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({
|
|
5395
5362
|
manifest: d,
|
|
5396
5363
|
config: h,
|
|
5397
5364
|
projectRoot: g,
|
|
5398
|
-
templateDir:
|
|
5365
|
+
templateDir: P
|
|
5399
5366
|
});
|
|
5400
5367
|
r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
|
|
5401
5368
|
for (let e of c.errors) s.log.error(e);
|
|
5402
5369
|
if (!m) {
|
|
5403
5370
|
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5404
|
-
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`)));
|
|
5405
5372
|
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5406
|
-
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`));
|
|
5407
5374
|
}
|
|
5408
|
-
await
|
|
5409
|
-
prepared:
|
|
5375
|
+
await Ps({
|
|
5376
|
+
prepared: N,
|
|
5410
5377
|
templateNpm: d.dependencies_npm,
|
|
5411
5378
|
paths: h.paths,
|
|
5412
5379
|
cwd: g,
|
|
5413
5380
|
spinner: r
|
|
5414
5381
|
});
|
|
5415
5382
|
let l;
|
|
5416
|
-
m && (l = await
|
|
5383
|
+
m && (l = await Ta(g, t.yes ?? !1)), await _r({
|
|
5417
5384
|
projectRoot: g,
|
|
5418
5385
|
paths: h.paths,
|
|
5419
5386
|
skipPrompts: t.yes ?? !1,
|
|
5420
5387
|
dbReady: l,
|
|
5421
5388
|
freshScaffold: m
|
|
5422
|
-
}),
|
|
5389
|
+
}), qo(), s.outro(L.brand(`Installed template ${u.name}.`));
|
|
5423
5390
|
} finally {
|
|
5424
|
-
await Promise.all(
|
|
5391
|
+
await Promise.all(N.map((e) => y.rm(e.packDir, {
|
|
5425
5392
|
recursive: !0,
|
|
5426
5393
|
force: !0
|
|
5427
|
-
}))),
|
|
5394
|
+
}))), P && await y.rm(P, {
|
|
5428
5395
|
recursive: !0,
|
|
5429
5396
|
force: !0
|
|
5430
5397
|
});
|
|
5431
5398
|
}
|
|
5432
5399
|
}
|
|
5433
|
-
async function
|
|
5400
|
+
async function Ms(e, t, n) {
|
|
5434
5401
|
let r = {};
|
|
5435
5402
|
for (let i of e.slots) {
|
|
5436
5403
|
if (t?.[i.family]) {
|
|
@@ -5454,7 +5421,7 @@ async function Ps(e, t, n) {
|
|
|
5454
5421
|
}
|
|
5455
5422
|
return r;
|
|
5456
5423
|
}
|
|
5457
|
-
async function
|
|
5424
|
+
async function Ns(e) {
|
|
5458
5425
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5459
5426
|
if (i.packs && i.packs.length > 0) {
|
|
5460
5427
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -5463,9 +5430,9 @@ async function Fs(e) {
|
|
|
5463
5430
|
if (i.yes) return [];
|
|
5464
5431
|
let o = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
|
|
5465
5432
|
if (o.length === 0) return [];
|
|
5466
|
-
let c =
|
|
5467
|
-
|
|
5468
|
-
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({
|
|
5469
5436
|
message: "Add extra packs on top of the template (optional)",
|
|
5470
5437
|
options: o.map((e) => ({
|
|
5471
5438
|
value: e.name,
|
|
@@ -5476,25 +5443,25 @@ async function Fs(e) {
|
|
|
5476
5443
|
});
|
|
5477
5444
|
return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
|
|
5478
5445
|
}
|
|
5479
|
-
async function
|
|
5480
|
-
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);
|
|
5481
5448
|
if (c.errors.length > 0) {
|
|
5482
5449
|
for (let e of c.errors) s.log.error(e);
|
|
5483
5450
|
return;
|
|
5484
5451
|
}
|
|
5485
5452
|
if (c.operations.length === 0) return;
|
|
5486
5453
|
a.start("Installing npm dependencies...");
|
|
5487
|
-
let l = await
|
|
5454
|
+
let l = await Bo(c.operations, i);
|
|
5488
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);
|
|
5489
5456
|
}
|
|
5490
5457
|
//#endregion
|
|
5491
5458
|
//#region src/cli.ts
|
|
5492
|
-
function
|
|
5459
|
+
function Fs(e) {
|
|
5493
5460
|
if (!e) return;
|
|
5494
5461
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5495
5462
|
return t.length > 0 ? t : void 0;
|
|
5496
5463
|
}
|
|
5497
|
-
function
|
|
5464
|
+
function Is(e) {
|
|
5498
5465
|
if (!e) return;
|
|
5499
5466
|
let t = {};
|
|
5500
5467
|
for (let n of e.split(",")) {
|
|
@@ -5503,10 +5470,10 @@ function Rs(e) {
|
|
|
5503
5470
|
}
|
|
5504
5471
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5505
5472
|
}
|
|
5506
|
-
function
|
|
5473
|
+
function Ls() {
|
|
5507
5474
|
let e = new o();
|
|
5508
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) => {
|
|
5509
|
-
await
|
|
5476
|
+
await as({
|
|
5510
5477
|
name: e.name,
|
|
5511
5478
|
directory: e.directory,
|
|
5512
5479
|
install: e.install,
|
|
@@ -5516,38 +5483,38 @@ function zs() {
|
|
|
5516
5483
|
setup: e.setup
|
|
5517
5484
|
});
|
|
5518
5485
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5519
|
-
await
|
|
5486
|
+
await os({});
|
|
5520
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) => {
|
|
5521
|
-
await
|
|
5488
|
+
await Ss({
|
|
5522
5489
|
cwd: e.cwd,
|
|
5523
5490
|
yes: e.yes,
|
|
5524
5491
|
skipMigrations: e.skipMigrations
|
|
5525
5492
|
});
|
|
5526
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) => {
|
|
5527
|
-
await
|
|
5528
|
-
packs:
|
|
5494
|
+
await cs({
|
|
5495
|
+
packs: Fs(e.packs),
|
|
5529
5496
|
force: e.force,
|
|
5530
5497
|
yes: e.yes,
|
|
5531
5498
|
licenseKey: e.key ?? e.licenseKey,
|
|
5532
5499
|
cwd: e.cwd
|
|
5533
5500
|
});
|
|
5534
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) => {
|
|
5535
|
-
await
|
|
5502
|
+
await js({
|
|
5536
5503
|
templateId: e,
|
|
5537
|
-
variants:
|
|
5538
|
-
packs:
|
|
5504
|
+
variants: Is(t.variants),
|
|
5505
|
+
packs: Fs(t.packs),
|
|
5539
5506
|
force: t.force,
|
|
5540
5507
|
yes: t.yes,
|
|
5541
5508
|
licenseKey: t.key ?? t.licenseKey,
|
|
5542
5509
|
cwd: t.cwd
|
|
5543
5510
|
});
|
|
5544
5511
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5545
|
-
await
|
|
5512
|
+
await ms();
|
|
5546
5513
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5547
|
-
await
|
|
5514
|
+
await hs();
|
|
5548
5515
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5549
|
-
await
|
|
5516
|
+
await ms();
|
|
5550
5517
|
}), e;
|
|
5551
5518
|
}
|
|
5552
5519
|
//#endregion
|
|
5553
|
-
export {
|
|
5520
|
+
export { ss as a, cs as i, hs as n, os as o, ms as r, as as s, Ls as t };
|