@hype-stack/cli 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-BG-vvtIY.js → cli-DtOSziUq.js} +1081 -1038
- package/dist/commands/compose.d.ts.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/init.d.ts +11 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/template.d.ts.map +1 -1
- package/dist/config/bin.js +1 -1
- package/dist/core/post-clone.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/types.d.ts +6 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import { Prompt as D } from "@clack/core";
|
|
|
13
13
|
import { styleText as O } from "node:util";
|
|
14
14
|
import { downloadTemplate as ee } from "giget";
|
|
15
15
|
//#region src/constants/constants.ts
|
|
16
|
-
var k = "0.0.1",
|
|
16
|
+
var k = "0.0.1", te = "gh:BetterTyped/hype-stack", ne = "stack.json", re = "/schema/stack.json", A = "https://api.hype-stack.dev", j = "HYPE_STACK_API_URL", ie = "https://www.hype-stack.dev", M = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, ae = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -31,109 +31,109 @@ var k = "0.0.1", A = "gh:BetterTyped/hype-stack", j = "stack.json", M = "/schema
|
|
|
31
31
|
value: "copilot",
|
|
32
32
|
label: "GitHub Copilot"
|
|
33
33
|
}
|
|
34
|
-
],
|
|
35
|
-
function
|
|
34
|
+
], oe = ae.map((e) => e.value), se = ".cursor/rules", ce = ".cursor", le = ".agents";
|
|
35
|
+
function N() {
|
|
36
36
|
let e = process.env.HYPE_STACK_API_URL;
|
|
37
|
-
return e ? (
|
|
37
|
+
return e ? (ue(e), e.replace(/\/+$/, "")) : A;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function P() {
|
|
40
40
|
let e = process.env.HYPE_STACK_WEB_URL;
|
|
41
|
-
return e ? (
|
|
41
|
+
return e ? (ue(e), e.replace(/\/+$/, "")) : ie;
|
|
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(`${j} 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(`${j} is not a valid URL: "${e}"`, { cause: t }) : t;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return `${
|
|
51
|
+
function de() {
|
|
52
|
+
return `${N()}${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) => y.bold(
|
|
66
|
-
accent: (e) =>
|
|
67
|
-
accentBold: (e) => y.bold(
|
|
56
|
+
var fe = (e) => `\x1b[38;5;208m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;214m${e}\x1b[39m`, F = (e) => `\x1b[38;5;220m${e}\x1b[39m`, me = (e) => `\x1b[38;5;33m${e}\x1b[39m`, I = (e) => `\x1b[38;5;39m${e}\x1b[39m`, he = (e) => `\x1b[38;5;81m${e}\x1b[39m`, ge = {
|
|
57
|
+
orange: fe,
|
|
58
|
+
orangeBright: pe,
|
|
59
|
+
amber: F,
|
|
60
|
+
deepBlue: me,
|
|
61
|
+
skyBlue: I,
|
|
62
|
+
lightBlue: he
|
|
63
|
+
}, L = {
|
|
64
|
+
brand: (e) => fe(e),
|
|
65
|
+
brandBold: (e) => y.bold(fe(e)),
|
|
66
|
+
accent: (e) => I(e),
|
|
67
|
+
accentBold: (e) => y.bold(I(e)),
|
|
68
68
|
success: (e) => y.green(e),
|
|
69
69
|
error: (e) => y.red(e),
|
|
70
70
|
warning: (e) => y.yellow(e),
|
|
71
71
|
muted: (e) => y.dim(e),
|
|
72
72
|
bold: (e) => y.bold(e),
|
|
73
73
|
highlight: (e) => y.bold(y.white(e)),
|
|
74
|
-
path: (e) => y.underline(
|
|
75
|
-
command: (e) => y.bold(
|
|
74
|
+
path: (e) => y.underline(I(e)),
|
|
75
|
+
command: (e) => y.bold(F(e)),
|
|
76
76
|
label: (e) => y.dim(y.bold(e))
|
|
77
77
|
};
|
|
78
|
-
function
|
|
79
|
-
return `\x1b]8;;${e}\x07${
|
|
80
|
-
}
|
|
81
|
-
var
|
|
82
|
-
arrow:
|
|
83
|
-
bullet:
|
|
84
|
-
dash:
|
|
85
|
-
corner:
|
|
86
|
-
pipe:
|
|
87
|
-
dot:
|
|
88
|
-
spark:
|
|
89
|
-
sparkSmall:
|
|
90
|
-
bolt:
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
fe,
|
|
95
|
-
de,
|
|
78
|
+
function _e(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: F("✦"),
|
|
89
|
+
sparkSmall: pe("✧"),
|
|
90
|
+
bolt: F("⚡")
|
|
91
|
+
}, ve = [
|
|
92
|
+
F,
|
|
93
|
+
F,
|
|
96
94
|
pe,
|
|
97
|
-
|
|
95
|
+
fe,
|
|
98
96
|
me,
|
|
99
|
-
|
|
97
|
+
I,
|
|
98
|
+
he,
|
|
99
|
+
he
|
|
100
100
|
];
|
|
101
|
-
function
|
|
101
|
+
function ye(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 ve[Math.min(Math.floor(r * ve.length), ve.length - 1)](e);
|
|
107
107
|
}).join("");
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function be(e, t, n) {
|
|
110
110
|
return Math.round(e + (t - e) * n);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function xe(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;${be(n[0], r[0], u)};${be(n[1], r[1], u)};${be(n[2], r[2], u)}m${e}\x1b[39m`;
|
|
118
118
|
}).join(""));
|
|
119
119
|
}
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/core/license.ts
|
|
122
|
-
function
|
|
123
|
-
return `${
|
|
122
|
+
function Se(e) {
|
|
123
|
+
return `${P()}/packs/${e}`;
|
|
124
124
|
}
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region ../../node_modules/.pnpm/@hyper-fetch+core@8.1.1/node_modules/@hyper-fetch/core/dist/index.mjs
|
|
127
|
-
var
|
|
128
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i =
|
|
127
|
+
var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDescriptor, Ee = Object.getOwnPropertyNames, De = Object.getPrototypeOf, Oe = Object.prototype.hasOwnProperty, ke = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), Ae = (e, t, n, r) => {
|
|
128
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = Ee(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !Oe.call(e, s) && s !== n && we(e, s, {
|
|
129
129
|
get: ((e) => t[e]).bind(null, s),
|
|
130
|
-
enumerable: !(r =
|
|
130
|
+
enumerable: !(r = Te(t, s)) || r.enumerable
|
|
131
131
|
});
|
|
132
132
|
return e;
|
|
133
|
-
},
|
|
133
|
+
}, je = (e, t, n) => (n = e == null ? {} : Ce(De(e)), Ae(t || !e || !e.__esModule ? we(n, "default", {
|
|
134
134
|
value: e,
|
|
135
135
|
enumerable: !0
|
|
136
|
-
}) : n, e)),
|
|
136
|
+
}) : n, e)), Me = (e) => `${e.queryKey}_${Date.now().toString(36)}_${Math.random().toString(36).substring(2)}`, Ne = /* @__PURE__ */ je((/* @__PURE__ */ ke(((e, t) => {
|
|
137
137
|
var n = typeof Reflect == "object" ? Reflect : null, r = n && typeof n.apply == "function" ? n.apply : function(e, t, n) {
|
|
138
138
|
return Function.prototype.apply.call(e, t, n);
|
|
139
139
|
}, i = n && typeof n.ownKeys == "function" ? n.ownKeys : Object.getOwnPropertySymbols ? function(e) {
|
|
@@ -308,7 +308,7 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
308
308
|
});
|
|
309
309
|
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
310
310
|
}
|
|
311
|
-
})))()),
|
|
311
|
+
})))()), Pe = (e) => `listen_${String(e)}`, Fe = class extends Ne.default {
|
|
312
312
|
emitCallbacks = [];
|
|
313
313
|
constructor(e) {
|
|
314
314
|
super(e);
|
|
@@ -320,26 +320,26 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
320
320
|
onEmit = (e) => (this.emitCallbacks?.push(e), () => {
|
|
321
321
|
this.emitCallbacks = this.emitCallbacks?.filter((t) => t !== e);
|
|
322
322
|
});
|
|
323
|
-
onListener = (e, t) => (super.on(
|
|
324
|
-
super.off(
|
|
323
|
+
onListener = (e, t) => (super.on(Pe(e), t), () => {
|
|
324
|
+
super.off(Pe(e), t);
|
|
325
325
|
});
|
|
326
|
-
on = (e, t) => (super.on(e, t), super.emit(
|
|
327
|
-
off = (e, t) => (super.off(e, t), super.emit(
|
|
326
|
+
on = (e, t) => (super.on(e, t), super.emit(Pe(e), super.listeners(e).length), this);
|
|
327
|
+
off = (e, t) => (super.off(e, t), super.emit(Pe(e), super.listeners(e).length), this);
|
|
328
328
|
addListener = this.on;
|
|
329
329
|
removeListener = this.off;
|
|
330
|
-
},
|
|
331
|
-
emitter = new
|
|
332
|
-
events =
|
|
330
|
+
}, Ie = class {
|
|
331
|
+
emitter = new Fe();
|
|
332
|
+
events = Ve(this.emitter);
|
|
333
333
|
isBrowser;
|
|
334
334
|
isOnline;
|
|
335
335
|
isFocused;
|
|
336
336
|
constructor(e) {
|
|
337
337
|
this.options = e, this.emitter?.setMaxListeners(1e3);
|
|
338
|
-
let { initiallyFocused: t =
|
|
339
|
-
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser =
|
|
338
|
+
let { initiallyFocused: t = B.initiallyFocused, initiallyOnline: n = B.initiallyOnline } = this.options || B;
|
|
339
|
+
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser = Re();
|
|
340
340
|
}
|
|
341
341
|
initialize = () => {
|
|
342
|
-
let { focusEvent: e =
|
|
342
|
+
let { focusEvent: e = B.focusEvent, onlineEvent: t = B.onlineEvent } = this.options || B;
|
|
343
343
|
e(this.setFocused), t(this.setOnline);
|
|
344
344
|
};
|
|
345
345
|
setInitialFocus = async (e) => {
|
|
@@ -354,51 +354,51 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
354
354
|
setOnline = (e) => {
|
|
355
355
|
this.isOnline = e, e ? this.events.emitOnline() : this.events.emitOffline();
|
|
356
356
|
};
|
|
357
|
-
},
|
|
357
|
+
}, Le = () => {
|
|
358
358
|
try {
|
|
359
359
|
return !!(window && window.addEventListener);
|
|
360
360
|
} catch {
|
|
361
361
|
/* istanbul ignore next */
|
|
362
362
|
return !1;
|
|
363
363
|
}
|
|
364
|
-
},
|
|
364
|
+
}, Re = () => {
|
|
365
365
|
try {
|
|
366
|
-
return !!(
|
|
366
|
+
return !!(Le() && window.document && window.document.addEventListener);
|
|
367
367
|
} catch {
|
|
368
368
|
/* istanbul ignore next */
|
|
369
369
|
return !1;
|
|
370
370
|
}
|
|
371
|
-
},
|
|
371
|
+
}, ze = (e, t, n) => Le() ? (window.addEventListener(e, t, n), () => window.removeEventListener(e, t, n)) : () => null, Be = (e, t, n) => Re() ? (window.document.addEventListener(e, t, n), () => window.document.removeEventListener(e, t, n)) : () => null, Ve = (e) => ({
|
|
372
372
|
emitFocus: () => {
|
|
373
|
-
e.emit(
|
|
373
|
+
e.emit(z.FOCUS);
|
|
374
374
|
},
|
|
375
375
|
emitBlur: () => {
|
|
376
|
-
e.emit(
|
|
376
|
+
e.emit(z.BLUR);
|
|
377
377
|
},
|
|
378
378
|
emitOnline: () => {
|
|
379
|
-
e.emit(
|
|
379
|
+
e.emit(z.ONLINE);
|
|
380
380
|
},
|
|
381
381
|
emitOffline: () => {
|
|
382
|
-
e.emit(
|
|
382
|
+
e.emit(z.OFFLINE);
|
|
383
383
|
},
|
|
384
|
-
onFocus: (t) => (e.on(
|
|
385
|
-
onBlur: (t) => (e.on(
|
|
386
|
-
onOnline: (t) => (e.on(
|
|
387
|
-
onOffline: (t) => (e.on(
|
|
388
|
-
}),
|
|
384
|
+
onFocus: (t) => (e.on(z.FOCUS, t), () => e.removeListener(z.FOCUS, t)),
|
|
385
|
+
onBlur: (t) => (e.on(z.BLUR, t), () => e.removeListener(z.BLUR, t)),
|
|
386
|
+
onOnline: (t) => (e.on(z.ONLINE, t), () => e.removeListener(z.ONLINE, t)),
|
|
387
|
+
onOffline: (t) => (e.on(z.OFFLINE, t), () => e.removeListener(z.OFFLINE, t))
|
|
388
|
+
}), z = /* @__PURE__ */ function(e) {
|
|
389
389
|
return e.FOCUS = "focus", e.BLUR = "blur", e.ONLINE = "online", e.OFFLINE = "offline", e;
|
|
390
|
-
}({}),
|
|
390
|
+
}({}), B = {
|
|
391
391
|
initiallyFocused: !0,
|
|
392
392
|
initiallyOnline: !0,
|
|
393
393
|
focusEvent: (e) => {
|
|
394
|
-
|
|
394
|
+
Be("visibilitychange", () => e(!0)), ze("focus", () => e(!0)), ze("blur", () => e(!1));
|
|
395
395
|
},
|
|
396
396
|
onlineEvent: (e) => {
|
|
397
|
-
|
|
397
|
+
ze("online", () => e(!0)), ze("offline", () => e(!1));
|
|
398
398
|
}
|
|
399
|
-
},
|
|
400
|
-
emitter = new
|
|
401
|
-
events =
|
|
399
|
+
}, He = class {
|
|
400
|
+
emitter = new Fe();
|
|
401
|
+
events = vt(this.emitter);
|
|
402
402
|
constructor() {
|
|
403
403
|
this.emitter?.setMaxListeners(1e3);
|
|
404
404
|
}
|
|
@@ -435,71 +435,71 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
435
435
|
});
|
|
436
436
|
});
|
|
437
437
|
};
|
|
438
|
-
},
|
|
438
|
+
}, Ue = () => "loading-event-any", We = (e) => `${e}-loading-event`, Ge = (e) => `${e}-loading-cache-event`, Ke = (e) => `${e}-loading-event-by-id`, qe = () => "remove-event-any", Je = (e) => `${e}-remove-event`, Ye = (e) => `${e}-remove-event-by-id`, Xe = () => "request-abort-any", Ze = (e) => `${e}-request-abort`, Qe = (e) => `${e}-request-abort-by-id`, $e = () => "response-any", et = (e) => `${e}-response`, tt = (e) => `${e}-response-by-id`, nt = () => "request-start-any", rt = (e) => `${e}-request-start`, it = (e) => `${e}-request-start-by-id`, at = () => "response-start-any", ot = (e) => `${e}-response-start`, st = (e) => `${e}-response-start-by-id`, ct = () => "request-progress-any", lt = (e) => `${e}-request-progress`, ut = (e) => `${e}-request-progress-by-id`, dt = () => "response-progress-any", ft = (e) => `${e}-response-progress`, pt = (e) => `${e}-response-progress-by-id`, mt = () => "request-deduplicated-any", ht = (e) => `${e}-query-request-deduplicated`, gt = (e) => `${e}-cache-request-deduplicated`, _t = (e) => `${e}-request-deduplicated-by-id`, vt = (e) => ({
|
|
439
439
|
emitDeduplicated: (t, n = !1) => {
|
|
440
|
-
e.emit(
|
|
440
|
+
e.emit(mt(), t, n), e.emit(_t(t.requestId), t, n), e.emit(gt(t.request.cacheKey), t, n), e.emit(ht(t.request.queryKey), t, n);
|
|
441
441
|
},
|
|
442
442
|
emitLoading: (t, n = !1) => {
|
|
443
|
-
e.emit(
|
|
443
|
+
e.emit(Ue(), t, n), e.emit(Ke(t.requestId), t, n), e.emit(Ge(t.request.cacheKey), t, n), e.emit(We(t.request.queryKey), t, n);
|
|
444
444
|
},
|
|
445
445
|
emitRequestStart: (t, n = !1) => {
|
|
446
|
-
e.emit(
|
|
446
|
+
e.emit(nt(), t, n), e.emit(it(t.requestId), t, n), e.emit(rt(t.request.queryKey), t, n);
|
|
447
447
|
},
|
|
448
448
|
emitResponseStart: (t, n = !1) => {
|
|
449
|
-
e.emit(
|
|
449
|
+
e.emit(at(), t, n), e.emit(st(t.requestId), t, n), e.emit(ot(t.request.queryKey), t, n);
|
|
450
450
|
},
|
|
451
451
|
emitUploadProgress: (t, n = !1) => {
|
|
452
|
-
e.emit(
|
|
452
|
+
e.emit(ct(), t, n), e.emit(ut(t.requestId), t, n), e.emit(lt(t.request.queryKey), t, n);
|
|
453
453
|
},
|
|
454
454
|
emitDownloadProgress: (t, n = !1) => {
|
|
455
|
-
e.emit(
|
|
455
|
+
e.emit(dt(), t, n), e.emit(pt(t.requestId), t, n), e.emit(ft(t.request.queryKey), t, n);
|
|
456
456
|
},
|
|
457
457
|
emitResponse: (t, n = !1) => {
|
|
458
|
-
e.emit(
|
|
458
|
+
e.emit($e(), t, n), e.emit(tt(t.requestId), t, n), e.emit(et(t.request.cacheKey), t, n);
|
|
459
459
|
},
|
|
460
460
|
emitAbort: (t, n = !1) => {
|
|
461
|
-
e.emit(
|
|
461
|
+
e.emit(Xe(), t, n), e.emit(Qe(t.requestId), t, n), e.emit(Ze(t.request.abortKey), t, n);
|
|
462
462
|
},
|
|
463
463
|
emitRemove: (t, n = !1) => {
|
|
464
|
-
e.emit(
|
|
464
|
+
e.emit(qe(), t, n), e.emit(Ye(t.requestId), t, n), e.emit(Je(t.request.queryKey), t, n);
|
|
465
465
|
},
|
|
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
|
-
}),
|
|
466
|
+
onDeduplicated: (t) => (e.on(mt(), t), () => e.removeListener(mt(), t)),
|
|
467
|
+
onDeduplicatedByQueue: (t, n) => (e.on(ht(t), n), () => e.removeListener(ht(t), n)),
|
|
468
|
+
onDeduplicatedByCache: (t, n) => (e.on(gt(t), n), () => e.removeListener(gt(t), n)),
|
|
469
|
+
onDeduplicatedById: (t, n) => (e.on(_t(t), n), () => e.removeListener(_t(t), n)),
|
|
470
|
+
onLoading: (t) => (e.on(Ue(), t), () => e.removeListener(Ue(), t)),
|
|
471
|
+
onLoadingByQueue: (t, n) => (e.on(We(t), n), () => e.removeListener(We(t), n)),
|
|
472
|
+
onLoadingByCache: (t, n) => (e.on(Ge(t), n), () => e.removeListener(Ge(t), n)),
|
|
473
|
+
onLoadingById: (t, n) => (e.on(Ke(t), n), () => e.removeListener(Ke(t), n)),
|
|
474
|
+
onRequestStart: (t) => (e.on(nt(), t), () => e.removeListener(nt(), t)),
|
|
475
|
+
onRequestStartByQueue: (t, n) => (e.on(rt(t), n), () => e.removeListener(rt(t), n)),
|
|
476
|
+
onRequestStartById: (t, n) => (e.on(it(t), n), () => e.removeListener(it(t), n)),
|
|
477
|
+
onResponseStart: (t) => (e.on(at(), t), () => e.removeListener(at(), t)),
|
|
478
|
+
onResponseStartByQueue: (t, n) => (e.on(ot(t), n), () => e.removeListener(ot(t), n)),
|
|
479
|
+
onResponseStartById: (t, n) => (e.on(st(t), n), () => e.removeListener(st(t), n)),
|
|
480
|
+
onUploadProgress: (t) => (e.on(ct(), t), () => e.removeListener(ct(), t)),
|
|
481
|
+
onUploadProgressByQueue: (t, n) => (e.on(lt(t), n), () => e.removeListener(lt(t), n)),
|
|
482
|
+
onUploadProgressById: (t, n) => (e.on(ut(t), n), () => e.removeListener(ut(t), n)),
|
|
483
|
+
onDownloadProgress: (t) => (e.on(dt(), t), () => e.removeListener(dt(), t)),
|
|
484
|
+
onDownloadProgressByQueue: (t, n) => (e.on(ft(t), n), () => e.removeListener(ft(t), n)),
|
|
485
|
+
onDownloadProgressById: (t, n) => (e.on(pt(t), n), () => e.removeListener(pt(t), n)),
|
|
486
|
+
onResponse: (t) => (e.on($e(), t), () => e.removeListener($e(), t)),
|
|
487
|
+
onResponseByCache: (t, n) => (e.on(et(t), n), () => e.removeListener(et(t), n)),
|
|
488
|
+
onResponseById: (t, n) => (e.on(tt(t), n), () => e.removeListener(tt(t), n)),
|
|
489
|
+
onAbort: (t) => (e.on(Xe(), t), () => e.removeListener(Xe(), t)),
|
|
490
|
+
onAbortByKey: (t, n) => (e.on(Ze(t), n), () => e.removeListener(Ze(t), n)),
|
|
491
|
+
onAbortById: (t, n) => (e.on(Qe(t), n), () => e.removeListener(Qe(t), n)),
|
|
492
|
+
onRemove: (t) => (e.on(qe(), t), () => e.removeListener(qe(), t)),
|
|
493
|
+
onRemoveByQueue: (t, n) => (e.on(Je(t), n), () => e.removeListener(Je(t), n)),
|
|
494
|
+
onRemoveById: (t, n) => (e.on(Ye(t), n), () => e.removeListener(Ye(t), n))
|
|
495
|
+
}), yt = class {
|
|
496
496
|
logger;
|
|
497
497
|
level;
|
|
498
498
|
modules;
|
|
499
|
-
emitter = new
|
|
499
|
+
emitter = new Ne.default();
|
|
500
500
|
client;
|
|
501
501
|
constructor(e) {
|
|
502
|
-
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger ||
|
|
502
|
+
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger || St, this.level = this.options?.level || "warning", this.modules = this.options?.modules;
|
|
503
503
|
}
|
|
504
504
|
setSeverity = (e) => {
|
|
505
505
|
this.level = e;
|
|
@@ -530,39 +530,39 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
530
530
|
})
|
|
531
531
|
});
|
|
532
532
|
log = (e) => {
|
|
533
|
-
this.client.debug && (
|
|
533
|
+
this.client.debug && (Ct.indexOf(this.level) <= Ct.indexOf(e.level) || this.modules && !this.modules.includes(e.module) || this.logger(e));
|
|
534
534
|
};
|
|
535
|
-
},
|
|
536
|
-
let t =
|
|
535
|
+
}, bt = () => `${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`, xt = (e) => e.type === "request" || e.type === "response" ? `${e.extra.request.endpoint}` : `[${e.module}]`, St = (e) => {
|
|
536
|
+
let t = Tt[e.level], n = Et[e.level], r = `%c[${bt()}]%c${e.title}%c${xt(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
537
|
e.extra && Object.keys(e.extra)?.length ? (console.groupCollapsed(r, i, a, o), console.log(e.extra), console.groupEnd()) : console.log(r, t);
|
|
538
|
-
},
|
|
538
|
+
}, Ct = [
|
|
539
539
|
"error",
|
|
540
540
|
"warning",
|
|
541
541
|
"info",
|
|
542
542
|
"debug"
|
|
543
|
-
],
|
|
544
|
-
error: `${
|
|
545
|
-
warning: `${
|
|
546
|
-
info: `${
|
|
547
|
-
debug: `${
|
|
548
|
-
},
|
|
543
|
+
], wt = "padding:2px 5px;", Tt = {
|
|
544
|
+
error: `${wt};background:#db252520;`,
|
|
545
|
+
warning: `${wt};background:#e1941e20;`,
|
|
546
|
+
info: `${wt};background:#1e74e120;`,
|
|
547
|
+
debug: `${wt};background:#00000020;`
|
|
548
|
+
}, Et = {
|
|
549
549
|
error: "color:#ff3737;",
|
|
550
550
|
warning: "color:#ffc107;",
|
|
551
551
|
info: "color:#34a8ff;",
|
|
552
552
|
debug: "color:#cccccc;"
|
|
553
|
-
},
|
|
553
|
+
}, Dt = class extends Error {
|
|
554
554
|
constructor() {
|
|
555
555
|
super("Request timeout"), this.name = "TimeoutError";
|
|
556
556
|
}
|
|
557
|
-
},
|
|
557
|
+
}, Ot = class extends Error {
|
|
558
558
|
constructor() {
|
|
559
559
|
super("Request aborted"), this.name = "AbortError";
|
|
560
560
|
}
|
|
561
|
-
},
|
|
561
|
+
}, kt = class extends Error {
|
|
562
562
|
constructor() {
|
|
563
563
|
super("Request deleted"), this.name = "DeletedError";
|
|
564
564
|
}
|
|
565
|
-
},
|
|
565
|
+
}, V = class extends Error {
|
|
566
566
|
description;
|
|
567
567
|
constructor(e) {
|
|
568
568
|
super("Request processing error"), this.description = e, this.name = "RequestProcessingError";
|
|
@@ -572,16 +572,16 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
572
572
|
constructor(e) {
|
|
573
573
|
super("Unexpected error"), this.description = e, this.name = "UnexpectedError";
|
|
574
574
|
}
|
|
575
|
-
}, H = (e) => e === "timeout" ? new
|
|
575
|
+
}, H = (e) => e === "timeout" ? new Dt() : e === "abort" ? new Ot() : e === "deleted" ? new kt() : e === "processing" ? new V() : new At(), jt = (e) => {
|
|
576
576
|
try {
|
|
577
577
|
return JSON.stringify(e);
|
|
578
578
|
} catch {
|
|
579
579
|
return "";
|
|
580
580
|
}
|
|
581
581
|
}, Mt = (e) => {
|
|
582
|
-
let t =
|
|
582
|
+
let t = Le() && e.payload instanceof FormData, n = typeof e.payload == "object" && e.payload !== null, r = {};
|
|
583
583
|
return !t && n && (r["Content-Type"] = "application/json"), Object.assign(r, e.headers), r;
|
|
584
|
-
}, Nt = (e) =>
|
|
584
|
+
}, Nt = (e) => Le() && e instanceof FormData ? e : jt(e), Pt = [
|
|
585
585
|
"onBeforeSent",
|
|
586
586
|
"onRequestStart",
|
|
587
587
|
"onResponseStart",
|
|
@@ -1057,7 +1057,7 @@ var It = /* @__PURE__ */ function(e) {
|
|
|
1057
1057
|
total: f,
|
|
1058
1058
|
loaded: f
|
|
1059
1059
|
}), e;
|
|
1060
|
-
},
|
|
1060
|
+
}, te = (e) => {
|
|
1061
1061
|
u = +/* @__PURE__ */ new Date(), p = w(p, e);
|
|
1062
1062
|
let n = {
|
|
1063
1063
|
total: p,
|
|
@@ -1067,21 +1067,21 @@ var It = /* @__PURE__ */ function(e) {
|
|
|
1067
1067
|
requestId: t,
|
|
1068
1068
|
request: d
|
|
1069
1069
|
}), u;
|
|
1070
|
-
},
|
|
1070
|
+
}, ne = (e) => {
|
|
1071
1071
|
u ||= +/* @__PURE__ */ new Date();
|
|
1072
1072
|
let t = +/* @__PURE__ */ new Date();
|
|
1073
1073
|
return p = w(p, e), E(u, t, {
|
|
1074
1074
|
total: e.total || p,
|
|
1075
1075
|
loaded: e.loaded || 0
|
|
1076
1076
|
}), t;
|
|
1077
|
-
},
|
|
1077
|
+
}, re = () => {
|
|
1078
1078
|
u ||= +/* @__PURE__ */ new Date();
|
|
1079
1079
|
let e = +/* @__PURE__ */ new Date();
|
|
1080
1080
|
return E(u, e, {
|
|
1081
1081
|
total: p,
|
|
1082
1082
|
loaded: p
|
|
1083
1083
|
}), e;
|
|
1084
|
-
},
|
|
1084
|
+
}, A = async ({ data: e, error: r, status: i, extra: a }) => {
|
|
1085
1085
|
let o = {
|
|
1086
1086
|
data: e,
|
|
1087
1087
|
error: r ?? null,
|
|
@@ -1106,50 +1106,50 @@ var It = /* @__PURE__ */ function(e) {
|
|
|
1106
1106
|
response: o
|
|
1107
1107
|
}
|
|
1108
1108
|
}), o;
|
|
1109
|
-
},
|
|
1109
|
+
}, j = Yt({
|
|
1110
1110
|
request: d,
|
|
1111
1111
|
requestId: t,
|
|
1112
1112
|
startTime: x,
|
|
1113
1113
|
logger: c,
|
|
1114
1114
|
resolve: n
|
|
1115
|
-
}),
|
|
1115
|
+
}), ie = ({ status: e, extra: n }) => (c.error({
|
|
1116
1116
|
title: "Abort error",
|
|
1117
1117
|
type: "request",
|
|
1118
1118
|
extra: {
|
|
1119
1119
|
request: d,
|
|
1120
1120
|
requestId: t
|
|
1121
1121
|
}
|
|
1122
|
-
}),
|
|
1122
|
+
}), j({
|
|
1123
1123
|
error: i(H("abort")),
|
|
1124
1124
|
status: e,
|
|
1125
1125
|
extra: n
|
|
1126
|
-
})),
|
|
1126
|
+
})), M = ({ status: e, extra: n }) => (c.error({
|
|
1127
1127
|
title: "Timeout error",
|
|
1128
1128
|
type: "request",
|
|
1129
1129
|
extra: {
|
|
1130
1130
|
request: d,
|
|
1131
1131
|
requestId: t
|
|
1132
1132
|
}
|
|
1133
|
-
}),
|
|
1133
|
+
}), j({
|
|
1134
1134
|
error: H("timeout"),
|
|
1135
1135
|
status: e,
|
|
1136
1136
|
extra: n
|
|
1137
|
-
})),
|
|
1137
|
+
})), ae = ({ status: e, extra: n }) => (c.error({
|
|
1138
1138
|
title: "Unexpected error",
|
|
1139
1139
|
type: "request",
|
|
1140
1140
|
extra: {
|
|
1141
1141
|
request: d,
|
|
1142
1142
|
requestId: t
|
|
1143
1143
|
}
|
|
1144
|
-
}),
|
|
1144
|
+
}), j({
|
|
1145
1145
|
error: H(),
|
|
1146
1146
|
status: e,
|
|
1147
1147
|
extra: n
|
|
1148
|
-
})),
|
|
1149
|
-
let i =
|
|
1150
|
-
if (!i) throw new
|
|
1148
|
+
})), oe = () => a.getAbortController(v, t), se = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1149
|
+
let i = oe();
|
|
1150
|
+
if (!i) throw new V("Controller is not found");
|
|
1151
1151
|
let o = () => {
|
|
1152
|
-
|
|
1152
|
+
ie({
|
|
1153
1153
|
status: e,
|
|
1154
1154
|
extra: n
|
|
1155
1155
|
}), r(), a.events.emitAbort({
|
|
@@ -1169,33 +1169,33 @@ var It = /* @__PURE__ */ function(e) {
|
|
|
1169
1169
|
adapterOptions: b
|
|
1170
1170
|
}
|
|
1171
1171
|
});
|
|
1172
|
-
let
|
|
1172
|
+
let ce = e.client.adapter.unstable_queryParamsMapper(d.queryParams), le = e.client.adapter.unstable_endpointMapper(d.endpoint), N = e.client.adapter.unstable_headerMapper(d), { url: P } = e.client;
|
|
1173
1173
|
return {
|
|
1174
1174
|
request: d,
|
|
1175
1175
|
requestId: t,
|
|
1176
|
-
url:
|
|
1177
|
-
endpoint:
|
|
1178
|
-
queryParams:
|
|
1176
|
+
url: P,
|
|
1177
|
+
endpoint: le,
|
|
1178
|
+
queryParams: ce,
|
|
1179
1179
|
payload: y,
|
|
1180
|
-
headers:
|
|
1180
|
+
headers: N,
|
|
1181
1181
|
adapter: e.client.adapter,
|
|
1182
1182
|
adapterOptions: b,
|
|
1183
|
-
getAbortController:
|
|
1183
|
+
getAbortController: oe,
|
|
1184
1184
|
getRequestStartTimestamp: S,
|
|
1185
1185
|
getResponseStartTimestamp: C,
|
|
1186
|
-
createAbortListener:
|
|
1186
|
+
createAbortListener: se,
|
|
1187
1187
|
onBeforeRequest: D,
|
|
1188
1188
|
onRequestStart: O,
|
|
1189
1189
|
onRequestProgress: ee,
|
|
1190
1190
|
onRequestEnd: k,
|
|
1191
|
-
onResponseStart:
|
|
1192
|
-
onResponseProgress:
|
|
1193
|
-
onResponseEnd:
|
|
1194
|
-
onSuccess:
|
|
1195
|
-
onAbortError:
|
|
1196
|
-
onTimeoutError:
|
|
1197
|
-
onUnexpectedError:
|
|
1198
|
-
onError:
|
|
1191
|
+
onResponseStart: te,
|
|
1192
|
+
onResponseProgress: ne,
|
|
1193
|
+
onResponseEnd: re,
|
|
1194
|
+
onSuccess: A,
|
|
1195
|
+
onAbortError: ie,
|
|
1196
|
+
onTimeoutError: M,
|
|
1197
|
+
onUnexpectedError: ae,
|
|
1198
|
+
onError: j
|
|
1199
1199
|
};
|
|
1200
1200
|
};
|
|
1201
1201
|
function Yt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
@@ -1228,7 +1228,7 @@ function Yt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
|
1228
1228
|
};
|
|
1229
1229
|
}
|
|
1230
1230
|
var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTimeoutError: i, onRequestEnd: a, createAbortListener: o, onResponseProgress: s, onRequestProgress: c, onResponseStart: l, onBeforeRequest: u, onRequestStart: d, onSuccess: f, onAbortError: p, adapter: m }) => {
|
|
1231
|
-
if (!e.unstable_mock) throw new
|
|
1231
|
+
if (!e.unstable_mock) throw new V("Mock should be defined when calling mocker");
|
|
1232
1232
|
let h = !1, { requestTime: g = 20, responseTime: _ = 20, totalUploaded: v = 1e3, totalDownloaded: y = 1e3, timeout: b } = e.unstable_mock.config, { data: x, error: S, status: C, success: w = !0, extra: T = e.client.adapter.defaultExtra } = await e.unstable_mock.fn({
|
|
1233
1233
|
request: e,
|
|
1234
1234
|
requestId: t
|
|
@@ -1321,8 +1321,8 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1321
1321
|
async fetch(e, t) {
|
|
1322
1322
|
let n, r = async (r) => {
|
|
1323
1323
|
try {
|
|
1324
|
-
if (!this.initialized) throw new
|
|
1325
|
-
if (!this.unstable_fetcher) throw new
|
|
1324
|
+
if (!this.initialized) throw new V(`Adapter ${this.options.name} is not initialized`);
|
|
1325
|
+
if (!this.unstable_fetcher) throw new V(`Fetcher for ${this.options.name} adapter is not set`);
|
|
1326
1326
|
this.client.triggerPlugins("onAdapterFetch", {
|
|
1327
1327
|
adapter: this,
|
|
1328
1328
|
request: e,
|
|
@@ -1401,21 +1401,21 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1401
1401
|
}
|
|
1402
1402
|
return t;
|
|
1403
1403
|
}, []).join("&");
|
|
1404
|
-
}, an = (e, t =
|
|
1404
|
+
}, an = (e, t = Nn) => {
|
|
1405
1405
|
if (!e || !Object.keys(e).length) return "";
|
|
1406
1406
|
if (typeof e == "string") return e[0] === "?" ? e : `?${e}`;
|
|
1407
1407
|
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ? rn(e, n, t) : nn(e, n, t)).filter(Boolean).join("&");
|
|
1408
1408
|
return n ? `?${n}` : "";
|
|
1409
|
-
}, on = Kt.SEC * 5,
|
|
1409
|
+
}, on = Kt.SEC * 5, G = { headers: {} }, sn = () => new Qt({
|
|
1410
1410
|
name: "http",
|
|
1411
1411
|
defaultMethod: It.GET,
|
|
1412
|
-
defaultExtra:
|
|
1412
|
+
defaultExtra: G,
|
|
1413
1413
|
systemErrorStatus: 0,
|
|
1414
|
-
systemErrorExtra:
|
|
1414
|
+
systemErrorExtra: G
|
|
1415
1415
|
}).setQueryParamsMapper(an).setFetcher(async ({ request: e, adapterOptions: t, headers: n, payload: r, onError: i, onResponseEnd: a, onTimeoutError: o, onRequestEnd: s, createAbortListener: c, getAbortController: l, onResponseProgress: u, onResponseStart: d, onBeforeRequest: f, onRequestStart: p, onRequestProgress: m, onSuccess: h }) => {
|
|
1416
1416
|
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ? an(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = on, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
|
|
1417
1417
|
status: 0,
|
|
1418
|
-
extra:
|
|
1418
|
+
extra: G
|
|
1419
1419
|
});
|
|
1420
1420
|
C > 0 && S && (D = setTimeout(() => {
|
|
1421
1421
|
E = !0, O(), S.abort();
|
|
@@ -1481,18 +1481,18 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1481
1481
|
if (D && clearTimeout(D), O(), S?.signal?.aborted) {
|
|
1482
1482
|
E && o({
|
|
1483
1483
|
status: 0,
|
|
1484
|
-
extra:
|
|
1484
|
+
extra: G
|
|
1485
1485
|
});
|
|
1486
1486
|
return;
|
|
1487
1487
|
}
|
|
1488
1488
|
i({
|
|
1489
1489
|
error: e,
|
|
1490
1490
|
status: 0,
|
|
1491
|
-
extra:
|
|
1491
|
+
extra: G
|
|
1492
1492
|
});
|
|
1493
1493
|
}
|
|
1494
|
-
}),
|
|
1495
|
-
emitter = new
|
|
1494
|
+
}), cn = () => sn(), ln = class {
|
|
1495
|
+
emitter = new Fe();
|
|
1496
1496
|
events;
|
|
1497
1497
|
storage;
|
|
1498
1498
|
lazyStorage;
|
|
@@ -1503,7 +1503,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1503
1503
|
constructor(e) {
|
|
1504
1504
|
this.options = e;
|
|
1505
1505
|
let { storage: t = /* @__PURE__ */ new Map(), lazyStorage: n, version: r = "0.0.1" } = e ?? {};
|
|
1506
|
-
this.emitter?.setMaxListeners(1e3), this.events =
|
|
1506
|
+
this.emitter?.setMaxListeners(1e3), this.events = _n(this.emitter), this.storage = t, this.version = r, this.lazyStorage = n;
|
|
1507
1507
|
}
|
|
1508
1508
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Cache"), e.appManager.events.onOnline(() => {
|
|
1509
1509
|
[...this.storage.keys()].forEach(this.scheduleGarbageCollector);
|
|
@@ -1517,7 +1517,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1517
1517
|
response: t
|
|
1518
1518
|
}
|
|
1519
1519
|
});
|
|
1520
|
-
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = U(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u =
|
|
1520
|
+
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = U(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u = un(c, l), d = {
|
|
1521
1521
|
...u,
|
|
1522
1522
|
scope: o,
|
|
1523
1523
|
staleTime: i,
|
|
@@ -1656,49 +1656,49 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1656
1656
|
clear = async () => {
|
|
1657
1657
|
this.garbageCollectors.forEach((e) => clearTimeout(e)), this.storage.clear();
|
|
1658
1658
|
};
|
|
1659
|
-
},
|
|
1659
|
+
}, un = (e, t) => {
|
|
1660
1660
|
let { data: n, success: r } = t, i = !r && e ? e.data : null, a = n || i;
|
|
1661
1661
|
return {
|
|
1662
1662
|
...t,
|
|
1663
1663
|
data: a
|
|
1664
1664
|
};
|
|
1665
|
-
},
|
|
1665
|
+
}, dn = () => "invalidate", fn = (e) => `${e}_invalidate`, pn = () => "delete", mn = (e) => `${e}_delete`, hn = (e) => `${e}_cache`, gn = () => "cache", _n = (e) => ({
|
|
1666
1666
|
emitCacheData: (t, n = !1) => {
|
|
1667
|
-
e.emit(
|
|
1667
|
+
e.emit(gn(), t, n), e.emit(hn(t.cacheKey), t, n);
|
|
1668
1668
|
},
|
|
1669
1669
|
emitInvalidation: (t, n = !1) => {
|
|
1670
|
-
e.emit(
|
|
1670
|
+
e.emit(dn(), t, n), e.emit(fn(t), n);
|
|
1671
1671
|
},
|
|
1672
1672
|
emitDelete: (t, n = !1) => {
|
|
1673
|
-
e.emit(
|
|
1673
|
+
e.emit(pn(), t, n), e.emit(mn(t), n);
|
|
1674
1674
|
},
|
|
1675
|
-
onData: (t) => (e.on(
|
|
1676
|
-
onDataByKey: (t, n) => (e.on(
|
|
1677
|
-
onInvalidate: (t) => (e.on(
|
|
1678
|
-
onInvalidateByKey: (t, n) => (e.on(
|
|
1679
|
-
onDelete: (t) => (e.on(
|
|
1680
|
-
onDeleteByKey: (t, n) => (e.on(
|
|
1681
|
-
}),
|
|
1675
|
+
onData: (t) => (e.on(gn(), t), () => e.removeListener(gn(), t)),
|
|
1676
|
+
onDataByKey: (t, n) => (e.on(hn(t), n), () => e.removeListener(hn(t), n)),
|
|
1677
|
+
onInvalidate: (t) => (e.on(dn(), t), () => e.removeListener(dn(), t)),
|
|
1678
|
+
onInvalidateByKey: (t, n) => (e.on(fn(t), n), () => e.removeListener(fn(t), n)),
|
|
1679
|
+
onDelete: (t) => (e.on(pn(), t), () => e.removeListener(pn(), t)),
|
|
1680
|
+
onDeleteByKey: (t, n) => (e.on(mn(t), n), () => e.removeListener(mn(t), n))
|
|
1681
|
+
}), K = /* @__PURE__ */ function(e) {
|
|
1682
1682
|
return e.ONE_BY_ONE = "one-by-one", e.ALL_AT_ONCE = "all-at-once", e.PREVIOUS_CANCELED = "previous-canceled", e.DEDUPLICATED = "deduplicated", e;
|
|
1683
|
-
}({}),
|
|
1683
|
+
}({}), vn = (e) => ({
|
|
1684
1684
|
emitDrained: (t, n) => {
|
|
1685
|
-
e.emit(
|
|
1685
|
+
e.emit(bn(), t, n), e.emit(xn(t.queryKey), t, n);
|
|
1686
1686
|
},
|
|
1687
1687
|
emitQueueStatusChanged: (t, n) => {
|
|
1688
|
-
e.emit(
|
|
1688
|
+
e.emit(Sn(), t, n), e.emit(Cn(t.queryKey), t, n);
|
|
1689
1689
|
},
|
|
1690
1690
|
emitQueueChanged: (t, n) => {
|
|
1691
|
-
e.emit(
|
|
1691
|
+
e.emit(wn(), t, n), e.emit(Tn(t.queryKey), t, n);
|
|
1692
1692
|
},
|
|
1693
|
-
onDrained: (t) => (e.on(
|
|
1694
|
-
onDrainedByKey: (t, n) => (e.on(
|
|
1695
|
-
onQueueStatusChange: (t) => (e.on(
|
|
1696
|
-
onQueueStatusChangeByKey: (t, n) => (e.on(
|
|
1697
|
-
onQueueChange: (t) => (e.on(
|
|
1698
|
-
onQueueChangeByKey: (t, n) => (e.on(
|
|
1699
|
-
}),
|
|
1700
|
-
emitter = new
|
|
1701
|
-
events =
|
|
1693
|
+
onDrained: (t) => (e.on(bn(), t), () => e.removeListener(bn(), t)),
|
|
1694
|
+
onDrainedByKey: (t, n) => (e.on(xn(t), n), () => e.removeListener(xn(t), n)),
|
|
1695
|
+
onQueueStatusChange: (t) => (e.on(Sn(), t), () => e.removeListener(Sn(), t)),
|
|
1696
|
+
onQueueStatusChangeByKey: (t, n) => (e.on(Cn(t), n), () => e.removeListener(Cn(t), n)),
|
|
1697
|
+
onQueueChange: (t) => (e.on(wn(), t), () => e.removeListener(wn(), t)),
|
|
1698
|
+
onQueueChangeByKey: (t, n) => (e.on(Tn(t), n), () => e.removeListener(Tn(t), n))
|
|
1699
|
+
}), yn = class {
|
|
1700
|
+
emitter = new Fe();
|
|
1701
|
+
events = vn(this.emitter);
|
|
1702
1702
|
storage = /* @__PURE__ */ new Map();
|
|
1703
1703
|
requestCount = /* @__PURE__ */ new Map();
|
|
1704
1704
|
runningRequests = /* @__PURE__ */ new Map();
|
|
@@ -1866,7 +1866,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1866
1866
|
resolved: !1
|
|
1867
1867
|
});
|
|
1868
1868
|
add = (e) => {
|
|
1869
|
-
let t = U(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a =
|
|
1869
|
+
let t = U(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = On(e, i);
|
|
1870
1870
|
switch (this.logger.debug({
|
|
1871
1871
|
title: "Adding request to queue",
|
|
1872
1872
|
type: "system",
|
|
@@ -1876,9 +1876,9 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1876
1876
|
requestId: r
|
|
1877
1877
|
}
|
|
1878
1878
|
}), a) {
|
|
1879
|
-
case
|
|
1880
|
-
case
|
|
1881
|
-
case
|
|
1879
|
+
case K.ONE_BY_ONE: return this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1880
|
+
case K.PREVIOUS_CANCELED: return this.cancelRunningRequests(t), this.clearQueue(t), this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1881
|
+
case K.DEDUPLICATED: return this.client.requestManager.events.emitDeduplicated({
|
|
1882
1882
|
request: i.request,
|
|
1883
1883
|
requestId: r,
|
|
1884
1884
|
deduplicatedRequest: e
|
|
@@ -1920,7 +1920,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1920
1920
|
requestId: n
|
|
1921
1921
|
}
|
|
1922
1922
|
});
|
|
1923
|
-
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = U(a, c), u = U(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h =
|
|
1923
|
+
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = U(a, c), u = U(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h = En(e.retries, r), g = !m.isOnline && s, _ = this.hasRunningRequest(l, n), v = e.stopped;
|
|
1924
1924
|
if (g || _ || v) return this.logger.warning({
|
|
1925
1925
|
title: "Unable to perform request",
|
|
1926
1926
|
type: "system",
|
|
@@ -2054,26 +2054,26 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
2054
2054
|
}
|
|
2055
2055
|
}), this.delete(l, n, u));
|
|
2056
2056
|
};
|
|
2057
|
-
},
|
|
2058
|
-
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ?
|
|
2059
|
-
return n ?
|
|
2057
|
+
}, bn = () => "drained-event", xn = (e) => `${e}-drained-event`, Sn = () => "status-event", Cn = (e) => `${e}-status-event`, wn = () => "change-event", Tn = (e) => `${e}-change-event`, En = (e, t) => !!(t && e < t), Dn = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, On = (e, t) => {
|
|
2058
|
+
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? Dn(e, t) : !1;
|
|
2059
|
+
return n ? K.ONE_BY_ONE : r ? K.PREVIOUS_CANCELED : a && i ? K.DEDUPLICATED : K.ALL_AT_ONCE;
|
|
2060
2060
|
};
|
|
2061
|
-
function
|
|
2061
|
+
function kn(e) {
|
|
2062
2062
|
return e === "client" || e === "server" ? e : typeof window < "u" && typeof document < "u" ? "client" : "server";
|
|
2063
2063
|
}
|
|
2064
|
-
var
|
|
2064
|
+
var An = async (e, t) => {
|
|
2065
2065
|
let n = t;
|
|
2066
2066
|
if (!t.requestOptions.disableRequestInterceptors) {
|
|
2067
2067
|
for (let r of e) if (n = await r(t), !n) throw Error("Request modifier must return request");
|
|
2068
2068
|
}
|
|
2069
2069
|
return n;
|
|
2070
|
-
},
|
|
2070
|
+
}, jn = async (e, t, n) => {
|
|
2071
2071
|
let r = t;
|
|
2072
2072
|
if (!n.requestOptions.disableResponseInterceptors) {
|
|
2073
2073
|
for (let i of e) if (r = await i(t, n), !r) throw Error("Response modifier must return data");
|
|
2074
2074
|
}
|
|
2075
2075
|
return r;
|
|
2076
|
-
},
|
|
2076
|
+
}, Mn = class {
|
|
2077
2077
|
url;
|
|
2078
2078
|
mode;
|
|
2079
2079
|
debug;
|
|
@@ -2082,8 +2082,8 @@ var jn = async (e, t) => {
|
|
|
2082
2082
|
unstable_onResponseCallbacks = [];
|
|
2083
2083
|
unstable_onAuthCallbacks = [];
|
|
2084
2084
|
unstable_onRequestCallbacks = [];
|
|
2085
|
-
loggerManager = new
|
|
2086
|
-
requestManager = new
|
|
2085
|
+
loggerManager = new yt();
|
|
2086
|
+
requestManager = new He();
|
|
2087
2087
|
appManager;
|
|
2088
2088
|
adapter;
|
|
2089
2089
|
cache;
|
|
@@ -2094,12 +2094,12 @@ var jn = async (e, t) => {
|
|
|
2094
2094
|
unstable_abortKeyMapper = Vt;
|
|
2095
2095
|
unstable_cacheKeyMapper = Ht;
|
|
2096
2096
|
unstable_queryKeyMapper = Ht;
|
|
2097
|
-
unstable_requestIdMapper =
|
|
2097
|
+
unstable_requestIdMapper = Me;
|
|
2098
2098
|
logger = this.loggerManager.initialize(this, "Client");
|
|
2099
2099
|
constructor(e) {
|
|
2100
2100
|
this.options = e;
|
|
2101
2101
|
let { url: t, appManager: n, cache: r, fetchDispatcher: i, submitDispatcher: a, mode: o } = this.options;
|
|
2102
|
-
this.url = t, this.mode =
|
|
2102
|
+
this.url = t, this.mode = kn(o), this.adapter = cn(), this.appManager = n?.() || new Ie(), this.cache = r?.() || new ln(), this.fetchDispatcher = i?.() || new yn(), this.submitDispatcher = a?.() || new yn(), this.adapter.initialize(this), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2103
2103
|
}
|
|
2104
2104
|
setDebug = (e) => (this.debug = e, this);
|
|
2105
2105
|
setLogLevel = (e) => (this.loggerManager.setSeverity(e), this);
|
|
@@ -2128,15 +2128,15 @@ var jn = async (e, t) => {
|
|
|
2128
2128
|
setCacheKeyMapper = (e) => (this.unstable_cacheKeyMapper = e, this);
|
|
2129
2129
|
setQueryKeyMapper = (e) => (this.unstable_queryKeyMapper = e, this);
|
|
2130
2130
|
setRequestIdMapper = (e) => (this.unstable_requestIdMapper = e, this);
|
|
2131
|
-
unstable_modifyAuth = async (e) =>
|
|
2132
|
-
unstable_modifyRequest = async (e) =>
|
|
2133
|
-
unstable_modifyErrorResponse = async (e, t) =>
|
|
2134
|
-
unstable_modifySuccessResponse = async (e, t) =>
|
|
2135
|
-
unstable_modifyResponse = async (e, t) =>
|
|
2131
|
+
unstable_modifyAuth = async (e) => An(this.unstable_onAuthCallbacks, e);
|
|
2132
|
+
unstable_modifyRequest = async (e) => An(this.unstable_onRequestCallbacks, e);
|
|
2133
|
+
unstable_modifyErrorResponse = async (e, t) => jn(this.unstable_onErrorCallbacks, e, t);
|
|
2134
|
+
unstable_modifySuccessResponse = async (e, t) => jn(this.unstable_onSuccessCallbacks, e, t);
|
|
2135
|
+
unstable_modifyResponse = async (e, t) => jn(this.unstable_onResponseCallbacks, e, t);
|
|
2136
2136
|
fromJSON = (e) => qt.fromJSON(this, e);
|
|
2137
2137
|
clear = () => {
|
|
2138
2138
|
let { appManager: e, cache: t, fetchDispatcher: n, submitDispatcher: r } = this.options;
|
|
2139
|
-
this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new
|
|
2139
|
+
this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new ln(), this.appManager = e?.() || new Ie(), this.fetchDispatcher = n?.() || new yn(), this.submitDispatcher = r?.() || new yn(), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2140
2140
|
};
|
|
2141
2141
|
hydrate = (e, t) => {
|
|
2142
2142
|
e?.forEach((e) => {
|
|
@@ -2169,7 +2169,7 @@ var jn = async (e, t) => {
|
|
|
2169
2169
|
}, r = new qt(this, n);
|
|
2170
2170
|
return this.plugins.forEach((e) => e.trigger("onRequestCreate", { request: r })), r;
|
|
2171
2171
|
};
|
|
2172
|
-
},
|
|
2172
|
+
}, Nn = {
|
|
2173
2173
|
strict: !0,
|
|
2174
2174
|
encode: !0,
|
|
2175
2175
|
arrayFormat: "bracket",
|
|
@@ -2178,101 +2178,101 @@ var jn = async (e, t) => {
|
|
|
2178
2178
|
skipNull: !0,
|
|
2179
2179
|
skipEmptyString: !0
|
|
2180
2180
|
};
|
|
2181
|
-
function
|
|
2182
|
-
return new
|
|
2181
|
+
function Pn(e) {
|
|
2182
|
+
return new Mn(e);
|
|
2183
2183
|
}
|
|
2184
2184
|
//#endregion
|
|
2185
2185
|
//#region src/core/client.ts
|
|
2186
|
-
var
|
|
2186
|
+
var q = Pn({ url: N() });
|
|
2187
2187
|
//#endregion
|
|
2188
2188
|
//#region src/core/auth-api.ts
|
|
2189
|
-
async function
|
|
2190
|
-
let { data: t, success: n } = await
|
|
2189
|
+
async function Fn(e) {
|
|
2190
|
+
let { data: t, success: n } = await q.createRequest()({
|
|
2191
2191
|
endpoint: "/auth/cli/whoami",
|
|
2192
2192
|
method: "GET"
|
|
2193
2193
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2194
2194
|
return !n || !t ? null : t;
|
|
2195
2195
|
}
|
|
2196
|
-
async function
|
|
2197
|
-
await
|
|
2196
|
+
async function In(e) {
|
|
2197
|
+
await q.createRequest()({
|
|
2198
2198
|
endpoint: "/auth/cli/token",
|
|
2199
2199
|
method: "DELETE"
|
|
2200
2200
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2201
2201
|
}
|
|
2202
2202
|
//#endregion
|
|
2203
2203
|
//#region src/core/auth-store.ts
|
|
2204
|
-
var
|
|
2205
|
-
function
|
|
2204
|
+
var Ln = 1, Rn = "hype-stack", zn = "auth.json";
|
|
2205
|
+
function Bn() {
|
|
2206
2206
|
let e = process.env.HYPE_STACK_CONFIG_DIR;
|
|
2207
|
-
if (e) return w.join(e,
|
|
2207
|
+
if (e) return w.join(e, Rn);
|
|
2208
2208
|
let t = C.homedir();
|
|
2209
2209
|
if (process.platform === "win32") {
|
|
2210
2210
|
let e = process.env.APPDATA ?? w.join(t, "AppData", "Roaming");
|
|
2211
|
-
return w.join(e,
|
|
2211
|
+
return w.join(e, Rn);
|
|
2212
2212
|
}
|
|
2213
|
-
if (process.platform === "darwin") return w.join(t, "Library", "Application Support",
|
|
2213
|
+
if (process.platform === "darwin") return w.join(t, "Library", "Application Support", Rn);
|
|
2214
2214
|
let n = process.env.XDG_CONFIG_HOME ?? w.join(t, ".config");
|
|
2215
|
-
return w.join(n,
|
|
2215
|
+
return w.join(n, Rn);
|
|
2216
2216
|
}
|
|
2217
|
-
function
|
|
2218
|
-
return w.join(
|
|
2217
|
+
function Vn() {
|
|
2218
|
+
return w.join(Bn(), zn);
|
|
2219
2219
|
}
|
|
2220
|
-
async function
|
|
2221
|
-
let e = await v.readFile(
|
|
2220
|
+
async function Hn() {
|
|
2221
|
+
let e = await v.readFile(Vn(), "utf-8").catch(() => null);
|
|
2222
2222
|
if (!e) return {
|
|
2223
|
-
version:
|
|
2223
|
+
version: Ln,
|
|
2224
2224
|
tokens: {}
|
|
2225
2225
|
};
|
|
2226
2226
|
let t = JSON.parse(e);
|
|
2227
2227
|
return {
|
|
2228
|
-
version: t.version ??
|
|
2228
|
+
version: t.version ?? Ln,
|
|
2229
2229
|
tokens: t.tokens ?? {}
|
|
2230
2230
|
};
|
|
2231
2231
|
}
|
|
2232
|
-
async function
|
|
2233
|
-
let t =
|
|
2234
|
-
await v.mkdir(t, { recursive: !0 }), await v.writeFile(
|
|
2232
|
+
async function Un(e) {
|
|
2233
|
+
let t = Bn();
|
|
2234
|
+
await v.mkdir(t, { recursive: !0 }), await v.writeFile(Vn(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2235
2235
|
}
|
|
2236
|
-
async function
|
|
2237
|
-
return (await
|
|
2236
|
+
async function Wn(e) {
|
|
2237
|
+
return (await Hn()).tokens[e] ?? null;
|
|
2238
2238
|
}
|
|
2239
|
-
async function
|
|
2240
|
-
let n = await
|
|
2241
|
-
n.tokens[e] = t, await
|
|
2239
|
+
async function Gn(e, t) {
|
|
2240
|
+
let n = await Hn();
|
|
2241
|
+
n.tokens[e] = t, await Un(n);
|
|
2242
2242
|
}
|
|
2243
|
-
async function
|
|
2244
|
-
let t = await
|
|
2245
|
-
e in t.tokens && (delete t.tokens[e], await
|
|
2243
|
+
async function Kn(e) {
|
|
2244
|
+
let t = await Hn();
|
|
2245
|
+
e in t.tokens && (delete t.tokens[e], await Un(t));
|
|
2246
2246
|
}
|
|
2247
2247
|
//#endregion
|
|
2248
2248
|
//#region src/core/device.ts
|
|
2249
|
-
function
|
|
2249
|
+
function qn() {
|
|
2250
2250
|
let e = C.networkInterfaces();
|
|
2251
2251
|
for (let t of Object.values(e)) if (t) {
|
|
2252
2252
|
for (let e of t) if (!e.internal && e.mac !== "00:00:00:00:00:00") return e.mac;
|
|
2253
2253
|
}
|
|
2254
2254
|
return "unknown";
|
|
2255
2255
|
}
|
|
2256
|
-
function
|
|
2257
|
-
let e = `${
|
|
2256
|
+
function Jn() {
|
|
2257
|
+
let e = `${qn()}:${C.hostname()}:${C.platform()}:${C.arch()}`;
|
|
2258
2258
|
return b("sha256").update(e).digest("hex").slice(0, 16);
|
|
2259
2259
|
}
|
|
2260
|
-
function
|
|
2260
|
+
function Yn() {
|
|
2261
2261
|
return `hype-stack/${k} ${C.platform()} ${C.arch()} node/${process.version.slice(1)}`;
|
|
2262
2262
|
}
|
|
2263
2263
|
//#endregion
|
|
2264
2264
|
//#region src/core/open-browser.ts
|
|
2265
|
-
function
|
|
2265
|
+
function Xn(e) {
|
|
2266
2266
|
T(process.platform === "darwin" ? `open "${e}"` : process.platform === "win32" ? `start "" "${e}"` : `xdg-open "${e}"`);
|
|
2267
2267
|
}
|
|
2268
2268
|
//#endregion
|
|
2269
2269
|
//#region src/core/login.ts
|
|
2270
|
-
var
|
|
2271
|
-
async function
|
|
2272
|
-
let t = x(16).toString("hex"), n =
|
|
2270
|
+
var Zn = 300 * 1e3, Qn = (e) => `<!doctype html><html><head><meta charset="utf-8"><title>Hype Stack CLI</title></head><body style="font-family:system-ui,sans-serif;text-align:center;padding-top:4rem;color:#111"><h2>${e}</h2><p>You can close this tab and return to your terminal.</p></body></html>`;
|
|
2271
|
+
async function $n(e = {}) {
|
|
2272
|
+
let t = x(16).toString("hex"), n = N(), r = S.createServer(), i = await new Promise((n, i) => {
|
|
2273
2273
|
let a = setTimeout(() => {
|
|
2274
2274
|
o(), i(/* @__PURE__ */ Error("Login timed out. Run `npx @hype-stack/cli login` again."));
|
|
2275
|
-
},
|
|
2275
|
+
}, Zn);
|
|
2276
2276
|
function o() {
|
|
2277
2277
|
clearTimeout(a), r.close(), r.closeAllConnections?.();
|
|
2278
2278
|
}
|
|
@@ -2286,7 +2286,7 @@ async function er(e = {}) {
|
|
|
2286
2286
|
r.writeHead(200, {
|
|
2287
2287
|
"Content-Type": "text/html",
|
|
2288
2288
|
Connection: "close"
|
|
2289
|
-
}), r.end(
|
|
2289
|
+
}), r.end(Qn(e));
|
|
2290
2290
|
};
|
|
2291
2291
|
if (a.searchParams.get("state") !== t) {
|
|
2292
2292
|
s("Login failed."), o(), i(/* @__PURE__ */ Error("Login failed: state mismatch. Run `npx @hype-stack/cli login` again."));
|
|
@@ -2301,53 +2301,53 @@ async function er(e = {}) {
|
|
|
2301
2301
|
}), r.on("error", (e) => {
|
|
2302
2302
|
o(), i(e);
|
|
2303
2303
|
}), r.listen(0, "127.0.0.1", () => {
|
|
2304
|
-
let { port: n } = r.address(), i = encodeURIComponent(
|
|
2305
|
-
e.onUrl?.(a),
|
|
2304
|
+
let { port: n } = r.address(), i = encodeURIComponent(Yn()), a = `${P()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
|
|
2305
|
+
e.onUrl?.(a), Xn(a);
|
|
2306
2306
|
});
|
|
2307
|
-
}), a = await
|
|
2307
|
+
}), a = await Fn(i).catch(() => null), o = {
|
|
2308
2308
|
token: i,
|
|
2309
2309
|
email: a?.email,
|
|
2310
2310
|
organizationId: a?.organizationId
|
|
2311
2311
|
};
|
|
2312
|
-
return await
|
|
2312
|
+
return await Gn(n, o), o;
|
|
2313
2313
|
}
|
|
2314
2314
|
//#endregion
|
|
2315
2315
|
//#region src/core/access-prompts.ts
|
|
2316
|
-
async function
|
|
2316
|
+
async function er() {
|
|
2317
2317
|
let e = await o.confirm({ message: "Log in to install packs your organization owns? (opens your browser)" });
|
|
2318
2318
|
if (o.isCancel(e) || !e) return null;
|
|
2319
2319
|
o.log.step("Opening your browser to sign in...");
|
|
2320
2320
|
try {
|
|
2321
|
-
let e = await
|
|
2322
|
-
o.log.info(`If your browser didn't open, visit:\n ${
|
|
2321
|
+
let e = await $n({ onUrl: (e) => {
|
|
2322
|
+
o.log.info(`If your browser didn't open, visit:\n ${L.path(e)}`);
|
|
2323
2323
|
} });
|
|
2324
2324
|
return o.log.success(e.email ? `Logged in as ${e.email}` : "Logged in"), e.token;
|
|
2325
2325
|
} catch (e) {
|
|
2326
2326
|
return o.log.error(e instanceof Error ? e.message : String(e)), null;
|
|
2327
2327
|
}
|
|
2328
2328
|
}
|
|
2329
|
-
async function
|
|
2329
|
+
async function tr(e) {
|
|
2330
2330
|
if (e.length === 0) return;
|
|
2331
2331
|
o.note([
|
|
2332
2332
|
"These packs need a purchase before they can be installed:",
|
|
2333
2333
|
"",
|
|
2334
|
-
...e.map((e) => ` ${
|
|
2334
|
+
...e.map((e) => ` ${L.brand(e.displayName)} ${L.highlight(`$${e.price}`)}`)
|
|
2335
2335
|
].join("\n"), "Locked Packs");
|
|
2336
2336
|
let t = await o.confirm({ message: `Open the purchase ${e.length === 1 ? "page" : "pages"} in your browser?` });
|
|
2337
2337
|
if (o.isCancel(t) || !t) {
|
|
2338
|
-
o.log.info(
|
|
2338
|
+
o.log.info(L.muted("Run 'npx @hype-stack/cli login' after purchasing, then 'npx @hype-stack/cli compose' again."));
|
|
2339
2339
|
return;
|
|
2340
2340
|
}
|
|
2341
|
-
for (let t of e)
|
|
2341
|
+
for (let t of e) Xn(Se(t.name));
|
|
2342
2342
|
o.log.info([
|
|
2343
|
-
|
|
2344
|
-
` ${
|
|
2345
|
-
` ${
|
|
2343
|
+
L.muted("After purchasing, run:"),
|
|
2344
|
+
` ${L.highlight("npx @hype-stack/cli login")} ${L.muted("Save your access")}`,
|
|
2345
|
+
` ${L.highlight("npx @hype-stack/cli compose")} ${L.muted("Install the packs")}`
|
|
2346
2346
|
].join("\n"));
|
|
2347
2347
|
}
|
|
2348
2348
|
//#endregion
|
|
2349
2349
|
//#region src/utils/exec.ts
|
|
2350
|
-
function
|
|
2350
|
+
function J(e, t, n) {
|
|
2351
2351
|
return new Promise((r, i) => {
|
|
2352
2352
|
let a = E(e, t, {
|
|
2353
2353
|
cwd: n.cwd,
|
|
@@ -2380,60 +2380,60 @@ function q(e, t, n) {
|
|
|
2380
2380
|
}
|
|
2381
2381
|
//#endregion
|
|
2382
2382
|
//#region src/utils/fs.ts
|
|
2383
|
-
async function
|
|
2383
|
+
async function nr(e) {
|
|
2384
2384
|
return (await v.stat(e).catch(() => null))?.isDirectory() ?? !1;
|
|
2385
2385
|
}
|
|
2386
|
-
async function
|
|
2386
|
+
async function Y(e) {
|
|
2387
2387
|
return (await v.stat(e).catch(() => null))?.isFile() ?? !1;
|
|
2388
2388
|
}
|
|
2389
|
-
async function
|
|
2389
|
+
async function rr(e) {
|
|
2390
2390
|
return (await v.readdir(e).catch(() => [])).length === 0;
|
|
2391
2391
|
}
|
|
2392
|
-
async function
|
|
2392
|
+
async function ir(e) {
|
|
2393
2393
|
let t = await v.readFile(e, "utf-8").catch(() => null);
|
|
2394
2394
|
return t ? JSON.parse(t) : null;
|
|
2395
2395
|
}
|
|
2396
|
-
async function
|
|
2396
|
+
async function ar(e, t) {
|
|
2397
2397
|
await v.writeFile(e, JSON.stringify(t, null, 2) + "\n", "utf-8");
|
|
2398
2398
|
}
|
|
2399
|
-
async function
|
|
2399
|
+
async function or(e) {
|
|
2400
2400
|
let t = {};
|
|
2401
|
-
if (!await
|
|
2401
|
+
if (!await nr(e)) return t;
|
|
2402
2402
|
let n = await v.readdir(e, { withFileTypes: !0 });
|
|
2403
|
-
for (let r of n) r.isDirectory() && await
|
|
2403
|
+
for (let r of n) r.isDirectory() && await Y(w.join(e, r.name, "package.json")) && (t[r.name] = w.relative(w.dirname(e), w.join(e, r.name)));
|
|
2404
2404
|
return t;
|
|
2405
2405
|
}
|
|
2406
|
-
async function
|
|
2406
|
+
async function sr(e) {
|
|
2407
2407
|
await v.rm(e, {
|
|
2408
2408
|
recursive: !0,
|
|
2409
2409
|
force: !0
|
|
2410
2410
|
});
|
|
2411
2411
|
}
|
|
2412
|
-
function
|
|
2412
|
+
function cr(e, t) {
|
|
2413
2413
|
return w.basename(e) === t ? e : w.join(e, t);
|
|
2414
2414
|
}
|
|
2415
2415
|
//#endregion
|
|
2416
2416
|
//#region src/core/codegen.ts
|
|
2417
|
-
function
|
|
2418
|
-
o.log.info(
|
|
2419
|
-
`${
|
|
2420
|
-
`${
|
|
2421
|
-
`${
|
|
2417
|
+
function lr(e) {
|
|
2418
|
+
o.log.info(L.muted("Run database setup yourself when ready:")), o.note([
|
|
2419
|
+
`${L.command(`cd ${e}`)}`,
|
|
2420
|
+
`${L.command("pnpm exec prisma generate")} ${L.muted("(regenerate the Prisma client)")}`,
|
|
2421
|
+
`${L.command("pnpm exec prisma migrate dev")} ${L.muted("(create + apply tables for new packs)")}`
|
|
2422
2422
|
].join("\n"), "Database Setup");
|
|
2423
2423
|
}
|
|
2424
|
-
async function
|
|
2425
|
-
let { projectRoot: t, paths: n, skipPrompts: r, runCommand: i =
|
|
2426
|
-
if (!await
|
|
2424
|
+
async function ur(e) {
|
|
2425
|
+
let { projectRoot: t, paths: n, skipPrompts: r, runCommand: i = J } = e, a = n.backend.root, s = w.join(t, a);
|
|
2426
|
+
if (!await Y(w.join(s, "package.json"))) return;
|
|
2427
2427
|
if (r) {
|
|
2428
|
-
|
|
2428
|
+
lr(a);
|
|
2429
2429
|
return;
|
|
2430
2430
|
}
|
|
2431
2431
|
let c = await o.confirm({
|
|
2432
|
-
message: `Run database setup now? (${
|
|
2432
|
+
message: `Run database setup now? (${L.command("prisma generate")} + ${L.command("prisma migrate")})`,
|
|
2433
2433
|
initialValue: !0
|
|
2434
2434
|
});
|
|
2435
2435
|
if (o.isCancel(c) || !c) {
|
|
2436
|
-
|
|
2436
|
+
lr(a);
|
|
2437
2437
|
return;
|
|
2438
2438
|
}
|
|
2439
2439
|
let l = o.spinner();
|
|
@@ -2442,10 +2442,10 @@ async function dr(e) {
|
|
|
2442
2442
|
"prisma",
|
|
2443
2443
|
"generate"
|
|
2444
2444
|
], { cwd: s })).exitCode !== 0) {
|
|
2445
|
-
l.stop(
|
|
2445
|
+
l.stop(L.warning("Prisma client generation failed")), lr(a);
|
|
2446
2446
|
return;
|
|
2447
2447
|
}
|
|
2448
|
-
l.stop(
|
|
2448
|
+
l.stop(L.success("Prisma client generated"));
|
|
2449
2449
|
let u = o.spinner();
|
|
2450
2450
|
if (u.start("Applying database schema..."), (await i("pnpm", [
|
|
2451
2451
|
"exec",
|
|
@@ -2455,30 +2455,30 @@ async function dr(e) {
|
|
|
2455
2455
|
"--name",
|
|
2456
2456
|
"add-packs"
|
|
2457
2457
|
], { cwd: s })).exitCode !== 0) {
|
|
2458
|
-
u.stop(
|
|
2458
|
+
u.stop(L.warning("Database migration failed (is your database running?)")), lr(a);
|
|
2459
2459
|
return;
|
|
2460
2460
|
}
|
|
2461
|
-
u.stop(
|
|
2461
|
+
u.stop(L.success("Database schema applied"));
|
|
2462
2462
|
}
|
|
2463
2463
|
//#endregion
|
|
2464
2464
|
//#region src/core/stack-config.ts
|
|
2465
|
-
async function
|
|
2466
|
-
return
|
|
2465
|
+
async function dr(e) {
|
|
2466
|
+
return ir(w.join(e, ne));
|
|
2467
2467
|
}
|
|
2468
|
-
async function
|
|
2469
|
-
return
|
|
2468
|
+
async function fr(e) {
|
|
2469
|
+
return Y(w.join(e, ne));
|
|
2470
2470
|
}
|
|
2471
|
-
async function
|
|
2472
|
-
await
|
|
2471
|
+
async function pr(e, t) {
|
|
2472
|
+
await ar(w.join(e, ne), t);
|
|
2473
2473
|
}
|
|
2474
|
-
async function
|
|
2475
|
-
let t = w.join(e, "apps"), n = w.join(e, "packages"), [r, i] = await Promise.all([
|
|
2474
|
+
async function mr(e) {
|
|
2475
|
+
let t = w.join(e, "apps"), n = w.join(e, "packages"), [r, i] = await Promise.all([or(t), or(n)]);
|
|
2476
2476
|
return {
|
|
2477
2477
|
apps: r,
|
|
2478
2478
|
packages: i
|
|
2479
2479
|
};
|
|
2480
2480
|
}
|
|
2481
|
-
function
|
|
2481
|
+
function hr(e) {
|
|
2482
2482
|
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";
|
|
2483
2483
|
return {
|
|
2484
2484
|
backend: {
|
|
@@ -2512,23 +2512,23 @@ function gr(e) {
|
|
|
2512
2512
|
}
|
|
2513
2513
|
};
|
|
2514
2514
|
}
|
|
2515
|
-
function
|
|
2515
|
+
function gr(e, t) {
|
|
2516
2516
|
return {
|
|
2517
|
-
$schema:
|
|
2517
|
+
$schema: de(),
|
|
2518
2518
|
version: 1,
|
|
2519
2519
|
name: e,
|
|
2520
2520
|
apps: t.apps,
|
|
2521
2521
|
packages: t.packages,
|
|
2522
|
-
paths:
|
|
2522
|
+
paths: hr(t),
|
|
2523
2523
|
installedPacks: [],
|
|
2524
2524
|
licenseKey: null
|
|
2525
2525
|
};
|
|
2526
2526
|
}
|
|
2527
|
-
async function
|
|
2528
|
-
let t = w.join(e, "package.json"), n = w.join(e, "apps"), [r, i] = await Promise.all([
|
|
2527
|
+
async function _r(e) {
|
|
2528
|
+
let t = w.join(e, "package.json"), n = w.join(e, "apps"), [r, i] = await Promise.all([Y(t), nr(n)]);
|
|
2529
2529
|
return r && i;
|
|
2530
2530
|
}
|
|
2531
|
-
function
|
|
2531
|
+
function X(e, t) {
|
|
2532
2532
|
return e.replace(/\{\{(\w+)\.(\w+)\}\}/g, (n, r, i) => {
|
|
2533
2533
|
let a = t[r];
|
|
2534
2534
|
if (!a) throw Error(`Unknown app "${r}" in path template "${e}"`);
|
|
@@ -2539,8 +2539,8 @@ function Y(e, t) {
|
|
|
2539
2539
|
}
|
|
2540
2540
|
//#endregion
|
|
2541
2541
|
//#region src/core/registry.ts
|
|
2542
|
-
async function
|
|
2543
|
-
let { data: t, error: n, status: r } = await
|
|
2542
|
+
async function vr(e) {
|
|
2543
|
+
let { data: t, error: n, status: r } = await q.createRequest()({
|
|
2544
2544
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2545
2545
|
method: "GET"
|
|
2546
2546
|
}).send();
|
|
@@ -2548,13 +2548,13 @@ async function yr(e) {
|
|
|
2548
2548
|
if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
|
|
2549
2549
|
return t;
|
|
2550
2550
|
}
|
|
2551
|
-
async function
|
|
2552
|
-
let n =
|
|
2551
|
+
async function yr(e, t = {}) {
|
|
2552
|
+
let n = q.createRequest()({
|
|
2553
2553
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2554
2554
|
method: "POST"
|
|
2555
2555
|
}), r = {
|
|
2556
|
-
"X-Device-Id":
|
|
2557
|
-
"X-Client-Info":
|
|
2556
|
+
"X-Device-Id": Jn(),
|
|
2557
|
+
"X-Client-Info": Yn()
|
|
2558
2558
|
};
|
|
2559
2559
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2560
2560
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -2574,25 +2574,25 @@ async function br(e, t = {}) {
|
|
|
2574
2574
|
packDir: s
|
|
2575
2575
|
};
|
|
2576
2576
|
}
|
|
2577
|
-
function
|
|
2578
|
-
let r =
|
|
2577
|
+
function br(e, t, n) {
|
|
2578
|
+
let r = X(e, t);
|
|
2579
2579
|
return w.resolve(n, r);
|
|
2580
2580
|
}
|
|
2581
|
-
function
|
|
2581
|
+
function xr(e, t) {
|
|
2582
2582
|
return w.join(t, e);
|
|
2583
2583
|
}
|
|
2584
|
-
var
|
|
2584
|
+
var Sr = q.createRequest()({
|
|
2585
2585
|
endpoint: "/packs/list",
|
|
2586
2586
|
method: "GET"
|
|
2587
2587
|
});
|
|
2588
|
-
async function
|
|
2589
|
-
let { data: e, error: t } = await
|
|
2588
|
+
async function Cr() {
|
|
2589
|
+
let { data: e, error: t } = await Sr.send();
|
|
2590
2590
|
if (t || !e) throw Error(`Failed to fetch pack list: ${String(t)}`);
|
|
2591
2591
|
return e.packs;
|
|
2592
2592
|
}
|
|
2593
|
-
async function
|
|
2593
|
+
async function wr(e, t = {}) {
|
|
2594
2594
|
if (e.length === 0) return {};
|
|
2595
|
-
let n =
|
|
2595
|
+
let n = q.createRequest()({
|
|
2596
2596
|
endpoint: "/packs/authorize",
|
|
2597
2597
|
method: "POST"
|
|
2598
2598
|
}), r = {};
|
|
@@ -2606,35 +2606,35 @@ async function Tr(e, t = {}) {
|
|
|
2606
2606
|
}
|
|
2607
2607
|
//#endregion
|
|
2608
2608
|
//#region src/core/codemods.ts
|
|
2609
|
-
var
|
|
2610
|
-
function
|
|
2611
|
-
return
|
|
2609
|
+
var Tr = "@hype-stack/";
|
|
2610
|
+
function Er(e, t) {
|
|
2611
|
+
return X(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
|
|
2612
2612
|
}
|
|
2613
|
-
async function
|
|
2614
|
-
let r =
|
|
2615
|
-
if (await
|
|
2613
|
+
async function Dr(e, t, n) {
|
|
2614
|
+
let r = X("{{backend.root}}", t), i = w.resolve(n, r, "src/config/env/env.config.ts"), a = w.resolve(n, r, ".env.example"), o = w.resolve(n, r, ".env.test");
|
|
2615
|
+
if (await Y(i)) {
|
|
2616
2616
|
let t = await v.readFile(i, "utf-8");
|
|
2617
|
-
for (let n of e) t.includes(`from "${n.from}"`) || (t =
|
|
2617
|
+
for (let n of e) t.includes(`from "${n.from}"`) || (t = Or(t, n), t = kr(t, n));
|
|
2618
2618
|
await v.writeFile(i, t, "utf-8");
|
|
2619
2619
|
}
|
|
2620
|
-
if (await
|
|
2620
|
+
if (await Y(a)) {
|
|
2621
2621
|
let t = await v.readFile(a, "utf-8");
|
|
2622
|
-
for (let n of e) t =
|
|
2622
|
+
for (let n of e) t = Ar(t, n);
|
|
2623
2623
|
await v.writeFile(a, t, "utf-8");
|
|
2624
2624
|
}
|
|
2625
|
-
if (await
|
|
2625
|
+
if (await Y(o)) {
|
|
2626
2626
|
let t = await v.readFile(o, "utf-8");
|
|
2627
|
-
for (let n of e) t =
|
|
2627
|
+
for (let n of e) t = jr(t, n);
|
|
2628
2628
|
await v.writeFile(o, t, "utf-8");
|
|
2629
2629
|
}
|
|
2630
2630
|
}
|
|
2631
|
-
function
|
|
2631
|
+
function Or(e, t) {
|
|
2632
2632
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2633
2633
|
if (r === -1) return n + "\n" + e;
|
|
2634
2634
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2635
2635
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2636
2636
|
}
|
|
2637
|
-
function
|
|
2637
|
+
function kr(e, t) {
|
|
2638
2638
|
let n = `.extend(${t.import}.shape)`;
|
|
2639
2639
|
if (e.includes(n)) return e;
|
|
2640
2640
|
let r = e.indexOf("export const envSchema = z.object({");
|
|
@@ -2649,27 +2649,27 @@ function Ar(e, t) {
|
|
|
2649
2649
|
let o = a + 2;
|
|
2650
2650
|
return e.slice(0, o) + n + e.slice(o);
|
|
2651
2651
|
}
|
|
2652
|
-
function
|
|
2652
|
+
function Ar(e, t) {
|
|
2653
2653
|
for (let n of Object.keys(t.envExample.vars)) if (e.includes(`${n}=`)) return e;
|
|
2654
2654
|
let n = [];
|
|
2655
2655
|
n.push(""), n.push(`# ${t.envExample.section}`);
|
|
2656
2656
|
for (let [e, r] of Object.entries(t.envExample.vars)) n.push(`${e}=${r}`);
|
|
2657
2657
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2658
2658
|
}
|
|
2659
|
-
function
|
|
2659
|
+
function jr(e, t) {
|
|
2660
2660
|
for (let n of Object.keys(t.envTest)) if (e.includes(`${n}=`)) return e;
|
|
2661
2661
|
let n = [""];
|
|
2662
2662
|
for (let [e, r] of Object.entries(t.envTest)) n.push(`${e}=${r}`);
|
|
2663
2663
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2664
2664
|
}
|
|
2665
|
-
async function
|
|
2666
|
-
let r = w.resolve(n,
|
|
2667
|
-
if (!await
|
|
2665
|
+
async function Mr(e, t, n) {
|
|
2666
|
+
let r = w.resolve(n, X("{{backend.routes}}", t), "index.ts");
|
|
2667
|
+
if (!await Y(r)) return;
|
|
2668
2668
|
let i = await v.readFile(r, "utf-8");
|
|
2669
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2669
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Nr(i, t), i = Pr(i, t));
|
|
2670
2670
|
await v.writeFile(r, i, "utf-8");
|
|
2671
2671
|
}
|
|
2672
|
-
function
|
|
2672
|
+
function Nr(e, t) {
|
|
2673
2673
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2674
2674
|
if (r !== -1) {
|
|
2675
2675
|
let t = e.indexOf("\n", r);
|
|
@@ -2678,7 +2678,7 @@ function Pr(e, t) {
|
|
|
2678
2678
|
let i = e.indexOf("export const registerRoutes");
|
|
2679
2679
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2680
2680
|
}
|
|
2681
|
-
function
|
|
2681
|
+
function Pr(e, t) {
|
|
2682
2682
|
let n = `.route("${t.prefix}", ${t.import})`, r = e.match(/\.route\([^)]+\);/g);
|
|
2683
2683
|
if (r) {
|
|
2684
2684
|
let t = r[r.length - 1], i = e.lastIndexOf(t) + t.length - 1;
|
|
@@ -2686,14 +2686,14 @@ function Fr(e, t) {
|
|
|
2686
2686
|
}
|
|
2687
2687
|
return e.replace("return app;", `return app\n ${n};`);
|
|
2688
2688
|
}
|
|
2689
|
-
async function
|
|
2690
|
-
let r = w.resolve(n,
|
|
2691
|
-
if (!await
|
|
2689
|
+
async function Fr(e, t, n) {
|
|
2690
|
+
let r = w.resolve(n, X("{{backend.root}}", t), "src/context.ts");
|
|
2691
|
+
if (!await Y(r)) return;
|
|
2692
2692
|
let i = await v.readFile(r, "utf-8");
|
|
2693
|
-
for (let t of e) i.includes(`export let ${t.export}`) || (i =
|
|
2693
|
+
for (let t of e) i.includes(`export let ${t.export}`) || (i = Ir(i, t), i = Lr(i, t), i = Rr(i, t), i = Br(i, t));
|
|
2694
2694
|
await v.writeFile(r, i, "utf-8");
|
|
2695
2695
|
}
|
|
2696
|
-
function
|
|
2696
|
+
function Ir(e, t) {
|
|
2697
2697
|
let n = `import { ${t.typeImport.name} } from "${t.typeImport.from}";`;
|
|
2698
2698
|
if (e.includes(`from "${t.typeImport.from}"`)) return e;
|
|
2699
2699
|
let r = e.lastIndexOf("import ");
|
|
@@ -2701,7 +2701,7 @@ function Lr(e, t) {
|
|
|
2701
2701
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2702
2702
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2703
2703
|
}
|
|
2704
|
-
function
|
|
2704
|
+
function Lr(e, t) {
|
|
2705
2705
|
let n = `export let ${t.export}: ${t.type};`, r = e.lastIndexOf("export let ");
|
|
2706
2706
|
if (r === -1) {
|
|
2707
2707
|
let t = e.indexOf("export const setupContext");
|
|
@@ -2710,15 +2710,15 @@ function Rr(e, t) {
|
|
|
2710
2710
|
let i = e.indexOf("\n", r);
|
|
2711
2711
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2712
2712
|
}
|
|
2713
|
-
function
|
|
2713
|
+
function Rr(e, t) {
|
|
2714
2714
|
let n = ` ${t.export} = ${t.init};`, r = e.match(/export const setupContext\s*=\s*async\s*\([^)]*\)\s*=>\s*\{/);
|
|
2715
2715
|
if (!r) return e;
|
|
2716
2716
|
let i = e.indexOf("{", e.indexOf(r[0]));
|
|
2717
2717
|
if (i === -1) return e;
|
|
2718
|
-
let a =
|
|
2718
|
+
let a = zr(e, i);
|
|
2719
2719
|
return a === -1 ? e : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2720
2720
|
}
|
|
2721
|
-
function
|
|
2721
|
+
function zr(e, t) {
|
|
2722
2722
|
let n = 0;
|
|
2723
2723
|
for (let r = t; r < e.length; r++) {
|
|
2724
2724
|
let t = e[r];
|
|
@@ -2727,20 +2727,20 @@ function Br(e, t) {
|
|
|
2727
2727
|
}
|
|
2728
2728
|
return -1;
|
|
2729
2729
|
}
|
|
2730
|
-
function
|
|
2730
|
+
function Br(e, t) {
|
|
2731
2731
|
let n = ` ${t.export}: ${t.type};`, r = e.indexOf("export type ContextVariables = {");
|
|
2732
2732
|
if (r === -1) return e;
|
|
2733
2733
|
let i = e.indexOf("};", r);
|
|
2734
2734
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2735
2735
|
}
|
|
2736
|
-
async function
|
|
2737
|
-
let r = w.resolve(n,
|
|
2738
|
-
if (!await
|
|
2736
|
+
async function Vr(e, t, n) {
|
|
2737
|
+
let r = w.resolve(n, X("{{enums.src}}", t), "index.ts");
|
|
2738
|
+
if (!await Y(r)) return;
|
|
2739
2739
|
let i = await v.readFile(r, "utf-8");
|
|
2740
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2740
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Hr(i, t));
|
|
2741
2741
|
await v.writeFile(r, i, "utf-8");
|
|
2742
2742
|
}
|
|
2743
|
-
function
|
|
2743
|
+
function Hr(e, t) {
|
|
2744
2744
|
let n = `export * from "${t.from}";`, r = e.lastIndexOf("export * from");
|
|
2745
2745
|
if (r !== -1) {
|
|
2746
2746
|
let t = e.indexOf("\n", r);
|
|
@@ -2748,14 +2748,14 @@ function Ur(e, t) {
|
|
|
2748
2748
|
}
|
|
2749
2749
|
return e.trim() === "" ? n + "\n" : e.trimEnd() + "\n" + n + "\n";
|
|
2750
2750
|
}
|
|
2751
|
-
async function
|
|
2752
|
-
let r =
|
|
2753
|
-
if (!await
|
|
2751
|
+
async function Ur(e, t, n) {
|
|
2752
|
+
let r = X("{{backend.root}}", t), i = w.resolve(n, r, "src/sockets/index.ts");
|
|
2753
|
+
if (!await Y(i)) return;
|
|
2754
2754
|
let a = await v.readFile(i, "utf-8");
|
|
2755
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2756
|
-
await
|
|
2755
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = Wr(a, t), a = Gr(a, t));
|
|
2756
|
+
await Y(w.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a = Kr(a)), await v.writeFile(i, a, "utf-8");
|
|
2757
2757
|
}
|
|
2758
|
-
function
|
|
2758
|
+
function Wr(e, t) {
|
|
2759
2759
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2760
2760
|
if (r !== -1) {
|
|
2761
2761
|
let t = e.indexOf("\n", r);
|
|
@@ -2764,7 +2764,7 @@ function Gr(e, t) {
|
|
|
2764
2764
|
let i = e.indexOf("const sockets");
|
|
2765
2765
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2766
2766
|
}
|
|
2767
|
-
function
|
|
2767
|
+
function Gr(e, t) {
|
|
2768
2768
|
let n = `.socket("${t.prefix}", ${t.import})`, r = e.indexOf("const sockets");
|
|
2769
2769
|
if (r === -1) return e;
|
|
2770
2770
|
let i = e.indexOf("new SocketRouter", r);
|
|
@@ -2778,7 +2778,7 @@ function Kr(e, t) {
|
|
|
2778
2778
|
}
|
|
2779
2779
|
return e;
|
|
2780
2780
|
}
|
|
2781
|
-
function
|
|
2781
|
+
function Kr(e) {
|
|
2782
2782
|
if (e.includes("wsAuthenticate")) return e;
|
|
2783
2783
|
let t = e.indexOf("from \"@backend/libs/websocket/socket-router\""), n = e;
|
|
2784
2784
|
if (t !== -1) {
|
|
@@ -2787,14 +2787,14 @@ function qr(e) {
|
|
|
2787
2787
|
}
|
|
2788
2788
|
return n.replace("new SocketRouter()", "new SocketRouter({ authenticate: wsAuthenticate })");
|
|
2789
2789
|
}
|
|
2790
|
-
async function
|
|
2791
|
-
let r =
|
|
2792
|
-
if (!await
|
|
2790
|
+
async function qr(e, t, n) {
|
|
2791
|
+
let r = X("{{frontend.root}}", t), i = w.resolve(n, r, "src/api/sdk.ts");
|
|
2792
|
+
if (!await Y(i)) return;
|
|
2793
2793
|
let a = await v.readFile(i, "utf-8");
|
|
2794
|
-
for (let t of e) a.includes(`.$configure(${t.import})`) || (a =
|
|
2794
|
+
for (let t of e) a.includes(`.$configure(${t.import})`) || (a = Jr(a, t), a = Yr(a, t));
|
|
2795
2795
|
await v.writeFile(i, a, "utf-8");
|
|
2796
2796
|
}
|
|
2797
|
-
function
|
|
2797
|
+
function Jr(e, t) {
|
|
2798
2798
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2799
2799
|
if (e.includes(n)) return e;
|
|
2800
2800
|
let r = e.lastIndexOf("from \"./");
|
|
@@ -2805,57 +2805,57 @@ function Yr(e, t) {
|
|
|
2805
2805
|
let i = e.indexOf("export const sdk");
|
|
2806
2806
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2807
2807
|
}
|
|
2808
|
-
function
|
|
2808
|
+
function Yr(e, t) {
|
|
2809
2809
|
let n = `.$configure(${t.import})`, r = e.indexOf("export const sdk");
|
|
2810
2810
|
if (r === -1) return e;
|
|
2811
2811
|
let i = e.indexOf(";", r);
|
|
2812
2812
|
return i === -1 ? e : e.slice(0, i) + "\n " + n + e.slice(i);
|
|
2813
2813
|
}
|
|
2814
|
-
async function
|
|
2815
|
-
let r = w.resolve(n,
|
|
2816
|
-
if (!await
|
|
2814
|
+
async function Xr(e, t, n) {
|
|
2815
|
+
let r = w.resolve(n, X("{{backend.utils}}", t), "frontend-url/frontend-url.ts");
|
|
2816
|
+
if (!await Y(r)) return;
|
|
2817
2817
|
let i = await v.readFile(r, "utf-8");
|
|
2818
|
-
for (let t of e) i.includes(`"${t.path}"`) || (i =
|
|
2818
|
+
for (let t of e) i.includes(`"${t.path}"`) || (i = Zr(i, t));
|
|
2819
2819
|
await v.writeFile(r, i, "utf-8");
|
|
2820
2820
|
}
|
|
2821
|
-
function
|
|
2821
|
+
function Zr(e, t) {
|
|
2822
2822
|
let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
|
|
2823
2823
|
if (r === -1) return e;
|
|
2824
2824
|
let i = e.indexOf("};", r);
|
|
2825
2825
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2826
2826
|
}
|
|
2827
|
-
var
|
|
2827
|
+
var Qr = "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", $r = {
|
|
2828
2828
|
primary: "primaryNav",
|
|
2829
2829
|
secondary: "secondaryNav",
|
|
2830
2830
|
tertiary: "tertiaryNav",
|
|
2831
2831
|
settings: "settingsNav"
|
|
2832
2832
|
};
|
|
2833
|
-
async function
|
|
2834
|
-
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2835
|
-
await
|
|
2836
|
-
for (let e of t) s.includes(`label: "${e.label}"`) || (s =
|
|
2837
|
-
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s =
|
|
2833
|
+
async function ei(e) {
|
|
2834
|
+
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Er(i, n), o = w.resolve(r, a, "src/constants/nav.constants.ts"), s;
|
|
2835
|
+
await Y(o) ? s = await v.readFile(o, "utf-8") : (await v.mkdir(w.dirname(o), { recursive: !0 }), s = Qr);
|
|
2836
|
+
for (let e of t) s.includes(`label: "${e.label}"`) || (s = ri(s, e));
|
|
2837
|
+
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s = ai(s, e));
|
|
2838
2838
|
await v.writeFile(o, s, "utf-8");
|
|
2839
2839
|
}
|
|
2840
|
-
async function
|
|
2841
|
-
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2842
|
-
if (!await
|
|
2840
|
+
async function ti(e) {
|
|
2841
|
+
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Er(i, n), o = w.resolve(r, a, "src/features/auth/constants/auth.constants.ts");
|
|
2842
|
+
if (!await Y(o)) return;
|
|
2843
2843
|
let s = await v.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
|
|
2844
2844
|
if (!c.test(s)) return;
|
|
2845
2845
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
2846
2846
|
await v.writeFile(o, l, "utf-8");
|
|
2847
2847
|
}
|
|
2848
|
-
function
|
|
2848
|
+
function ni(e) {
|
|
2849
2849
|
let t = [e.icon];
|
|
2850
2850
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
2851
2851
|
return t;
|
|
2852
2852
|
}
|
|
2853
|
-
function
|
|
2854
|
-
let n =
|
|
2855
|
-
for (let e of n) r =
|
|
2853
|
+
function ri(e, t) {
|
|
2854
|
+
let n = ni(t), r = e;
|
|
2855
|
+
for (let e of n) r = ii(r, e);
|
|
2856
2856
|
return r;
|
|
2857
2857
|
}
|
|
2858
|
-
function
|
|
2858
|
+
function ii(e, t) {
|
|
2859
2859
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
2860
2860
|
if (!n) return e;
|
|
2861
2861
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -2863,21 +2863,21 @@ function ai(e, t) {
|
|
|
2863
2863
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
2864
2864
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
2865
2865
|
}
|
|
2866
|
-
function
|
|
2867
|
-
let n =
|
|
2866
|
+
function ai(e, t) {
|
|
2867
|
+
let n = $r[t.group];
|
|
2868
2868
|
if (!n) return e;
|
|
2869
|
-
let r =
|
|
2869
|
+
let r = si(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
|
|
2870
2870
|
if (!a) return e;
|
|
2871
|
-
let o = e.indexOf(a[0]) + a[0].length, s =
|
|
2871
|
+
let o = e.indexOf(a[0]) + a[0].length, s = oi(e, o - 1);
|
|
2872
2872
|
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);
|
|
2873
2873
|
}
|
|
2874
|
-
function
|
|
2874
|
+
function oi(e, t) {
|
|
2875
2875
|
let n = 0;
|
|
2876
2876
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2877
2877
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2878
2878
|
return -1;
|
|
2879
2879
|
}
|
|
2880
|
-
function
|
|
2880
|
+
function si(e) {
|
|
2881
2881
|
let t = [];
|
|
2882
2882
|
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) {
|
|
2883
2883
|
t.push(" items: [");
|
|
@@ -2893,14 +2893,14 @@ function ci(e) {
|
|
|
2893
2893
|
} else t.push(" items: [],");
|
|
2894
2894
|
return t.push(" },"), t.join("\n");
|
|
2895
2895
|
}
|
|
2896
|
-
async function
|
|
2897
|
-
let r =
|
|
2898
|
-
if (!await
|
|
2896
|
+
async function ci(e, t, n) {
|
|
2897
|
+
let r = X("{{backend.features}}", t), i = w.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
|
|
2898
|
+
if (!await Y(i)) return;
|
|
2899
2899
|
let a = await v.readFile(i, "utf-8");
|
|
2900
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2900
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = li(a, t), a = ui(a, t));
|
|
2901
2901
|
await v.writeFile(i, a, "utf-8");
|
|
2902
2902
|
}
|
|
2903
|
-
function
|
|
2903
|
+
function li(e, t) {
|
|
2904
2904
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2905
2905
|
if (r !== -1) {
|
|
2906
2906
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -2908,38 +2908,38 @@ function ui(e, t) {
|
|
|
2908
2908
|
}
|
|
2909
2909
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
2910
2910
|
}
|
|
2911
|
-
function
|
|
2911
|
+
function ui(e, t) {
|
|
2912
2912
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
2913
2913
|
if (!r) return e;
|
|
2914
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2914
|
+
let i = e.indexOf(r[0]) + r[0].length, a = di(e, i - 1);
|
|
2915
2915
|
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);
|
|
2916
2916
|
}
|
|
2917
|
-
function
|
|
2917
|
+
function di(e, t) {
|
|
2918
2918
|
let n = 0;
|
|
2919
2919
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2920
2920
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2921
2921
|
return -1;
|
|
2922
2922
|
}
|
|
2923
|
-
var
|
|
2924
|
-
async function
|
|
2925
|
-
await
|
|
2923
|
+
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";
|
|
2924
|
+
async function pi(e) {
|
|
2925
|
+
await hi({
|
|
2926
2926
|
...e,
|
|
2927
2927
|
arrayName: "navbarActions"
|
|
2928
2928
|
});
|
|
2929
2929
|
}
|
|
2930
|
-
async function
|
|
2931
|
-
await
|
|
2930
|
+
async function mi(e) {
|
|
2931
|
+
await hi({
|
|
2932
2932
|
...e,
|
|
2933
2933
|
arrayName: "userMenuActions"
|
|
2934
2934
|
});
|
|
2935
2935
|
}
|
|
2936
|
-
async function
|
|
2937
|
-
let a =
|
|
2938
|
-
await
|
|
2939
|
-
for (let n of e) s =
|
|
2936
|
+
async function hi({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
|
|
2937
|
+
let a = Er(i, n), o = w.resolve(r, a, "src/constants/navbar-actions.tsx"), s;
|
|
2938
|
+
await Y(o) ? s = await v.readFile(o, "utf-8") : (await v.mkdir(w.dirname(o), { recursive: !0 }), s = fi);
|
|
2939
|
+
for (let n of e) s = gi(s, n), s = _i(s, n, t);
|
|
2940
2940
|
await v.writeFile(o, s, "utf-8");
|
|
2941
2941
|
}
|
|
2942
|
-
function
|
|
2942
|
+
function gi(e, t) {
|
|
2943
2943
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2944
2944
|
if (e.includes(n)) return e;
|
|
2945
2945
|
let r = e.lastIndexOf("import ");
|
|
@@ -2947,38 +2947,38 @@ function _i(e, t) {
|
|
|
2947
2947
|
let i = e.indexOf("\n", r);
|
|
2948
2948
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2949
2949
|
}
|
|
2950
|
-
function
|
|
2950
|
+
function _i(e, t, n) {
|
|
2951
2951
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
2952
2952
|
if (!r) return e;
|
|
2953
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2953
|
+
let i = e.indexOf(r[0]) + r[0].length, a = vi(e, i - 1);
|
|
2954
2954
|
if (a === -1) return e;
|
|
2955
2955
|
let o = e.slice(i, a);
|
|
2956
2956
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
2957
2957
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
2958
2958
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
2959
2959
|
}
|
|
2960
|
-
function
|
|
2960
|
+
function vi(e, t) {
|
|
2961
2961
|
let n = 0;
|
|
2962
2962
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2963
2963
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2964
2964
|
return -1;
|
|
2965
2965
|
}
|
|
2966
|
-
var
|
|
2966
|
+
var yi = new Set([
|
|
2967
2967
|
".ts",
|
|
2968
2968
|
".tsx",
|
|
2969
2969
|
".js",
|
|
2970
2970
|
".jsx"
|
|
2971
2971
|
]);
|
|
2972
|
-
async function
|
|
2972
|
+
async function bi(e) {
|
|
2973
2973
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
2974
2974
|
if (i === "hype-stack") return;
|
|
2975
2975
|
let a = `@${i}/`;
|
|
2976
2976
|
await Promise.all(t.map(async (e) => {
|
|
2977
|
-
let t =
|
|
2978
|
-
i?.isDirectory() ? await
|
|
2977
|
+
let t = br(e.target, n, r), i = await v.stat(t).catch(() => null);
|
|
2978
|
+
i?.isDirectory() ? await Ci(t, a) : i?.isFile() && yi.has(w.extname(t)) && await wi(t, a);
|
|
2979
2979
|
}));
|
|
2980
2980
|
}
|
|
2981
|
-
var
|
|
2981
|
+
var xi = new Set([
|
|
2982
2982
|
".git",
|
|
2983
2983
|
"node_modules",
|
|
2984
2984
|
"dist",
|
|
@@ -2987,48 +2987,48 @@ var Si = new Set([
|
|
|
2987
2987
|
".next",
|
|
2988
2988
|
"coverage"
|
|
2989
2989
|
]);
|
|
2990
|
-
async function
|
|
2991
|
-
t !== "hype-stack" && await
|
|
2990
|
+
async function Si(e, t) {
|
|
2991
|
+
t !== "hype-stack" && await Ci(e, `@${t}/`);
|
|
2992
2992
|
}
|
|
2993
|
-
async function
|
|
2993
|
+
async function Ci(e, t) {
|
|
2994
2994
|
let n = await v.readdir(e, { withFileTypes: !0 });
|
|
2995
2995
|
await Promise.all(n.map(async (n) => {
|
|
2996
2996
|
let r = w.join(e, n.name);
|
|
2997
2997
|
if (n.isDirectory()) {
|
|
2998
|
-
if (
|
|
2999
|
-
await
|
|
3000
|
-
} else n.isFile() &&
|
|
2998
|
+
if (xi.has(n.name)) return;
|
|
2999
|
+
await Ci(r, t);
|
|
3000
|
+
} else n.isFile() && yi.has(w.extname(n.name)) && await wi(r, t);
|
|
3001
3001
|
}));
|
|
3002
3002
|
}
|
|
3003
|
-
async function
|
|
3003
|
+
async function wi(e, t) {
|
|
3004
3004
|
let n = await v.readFile(e, "utf-8");
|
|
3005
|
-
if (!n.includes(
|
|
3006
|
-
let r = n.replaceAll(
|
|
3005
|
+
if (!n.includes(Tr)) return;
|
|
3006
|
+
let r = n.replaceAll(Tr, t);
|
|
3007
3007
|
await v.writeFile(e, r, "utf-8");
|
|
3008
3008
|
}
|
|
3009
3009
|
//#endregion
|
|
3010
3010
|
//#region src/core/installer.ts
|
|
3011
|
-
function
|
|
3011
|
+
function Ti(e, t) {
|
|
3012
3012
|
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3013
3013
|
}
|
|
3014
|
-
async function
|
|
3014
|
+
async function Ei(e, t) {
|
|
3015
3015
|
if ((await v.stat(e)).isDirectory()) {
|
|
3016
3016
|
await v.mkdir(t, { recursive: !0 });
|
|
3017
3017
|
let n = await v.readdir(e, { withFileTypes: !0 });
|
|
3018
|
-
for (let r of n) await
|
|
3018
|
+
for (let r of n) await Ei(w.join(e, r.name), w.join(t, r.name));
|
|
3019
3019
|
} else await v.mkdir(w.dirname(t), { recursive: !0 }), await v.copyFile(e, t);
|
|
3020
3020
|
}
|
|
3021
|
-
async function
|
|
3022
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a =
|
|
3021
|
+
async function Di(e) {
|
|
3022
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = xr(t.source, n), o = br(t.target, r, i);
|
|
3023
3023
|
return {
|
|
3024
3024
|
sourcePath: a,
|
|
3025
3025
|
targetPath: o,
|
|
3026
|
-
sourceExists: await
|
|
3027
|
-
targetExists: await
|
|
3026
|
+
sourceExists: await Y(a) || await nr(a),
|
|
3027
|
+
targetExists: await Y(o) || await nr(o)
|
|
3028
3028
|
};
|
|
3029
3029
|
}
|
|
3030
|
-
async function
|
|
3031
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await
|
|
3030
|
+
async function Oi(e) {
|
|
3031
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await Di({
|
|
3032
3032
|
file: t,
|
|
3033
3033
|
packDir: n,
|
|
3034
3034
|
paths: r,
|
|
@@ -3043,8 +3043,8 @@ async function ki(e) {
|
|
|
3043
3043
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3044
3044
|
}
|
|
3045
3045
|
}
|
|
3046
|
-
async function
|
|
3047
|
-
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await
|
|
3046
|
+
async function ki(e) {
|
|
3047
|
+
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await Di({
|
|
3048
3048
|
file: t,
|
|
3049
3049
|
packDir: n,
|
|
3050
3050
|
paths: r,
|
|
@@ -3062,7 +3062,7 @@ async function Ai(e) {
|
|
|
3062
3062
|
status: "skipped",
|
|
3063
3063
|
path: t.target,
|
|
3064
3064
|
reason: "Already exists"
|
|
3065
|
-
} : (await
|
|
3065
|
+
} : (await Ei(s, c), {
|
|
3066
3066
|
status: "installed",
|
|
3067
3067
|
path: t.target
|
|
3068
3068
|
});
|
|
@@ -3071,16 +3071,16 @@ async function Ai(e) {
|
|
|
3071
3071
|
status: "skipped",
|
|
3072
3072
|
path: t.target,
|
|
3073
3073
|
reason: "Already exists (skip-if-exists)"
|
|
3074
|
-
} : (await
|
|
3074
|
+
} : (await Ei(s, c), {
|
|
3075
3075
|
status: "installed",
|
|
3076
3076
|
path: t.target
|
|
3077
3077
|
});
|
|
3078
|
-
case "override": return await
|
|
3078
|
+
case "override": return await Ei(s, c), {
|
|
3079
3079
|
status: "installed",
|
|
3080
3080
|
path: t.target
|
|
3081
3081
|
};
|
|
3082
3082
|
case "merge": {
|
|
3083
|
-
if (!u) return await
|
|
3083
|
+
if (!u) return await Ei(s, c), {
|
|
3084
3084
|
status: "installed",
|
|
3085
3085
|
path: t.target
|
|
3086
3086
|
};
|
|
@@ -3110,15 +3110,15 @@ async function Ai(e) {
|
|
|
3110
3110
|
};
|
|
3111
3111
|
}
|
|
3112
3112
|
}
|
|
3113
|
-
async function
|
|
3113
|
+
async function Ai(e) {
|
|
3114
3114
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3115
3115
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3116
3116
|
let o = [], s = /* @__PURE__ */ new Set();
|
|
3117
3117
|
for (let e of t) {
|
|
3118
3118
|
let t = i?.get(e.manifest.name);
|
|
3119
3119
|
for (let n of e.manifest.files) {
|
|
3120
|
-
if (n.strategy !== "create" || !
|
|
3121
|
-
let { targetPath: i, targetExists: c } = await
|
|
3120
|
+
if (n.strategy !== "create" || !Ti(n, t)) continue;
|
|
3121
|
+
let { targetPath: i, targetExists: c } = await Di({
|
|
3122
3122
|
file: n,
|
|
3123
3123
|
packDir: e.packDir,
|
|
3124
3124
|
paths: a,
|
|
@@ -3133,13 +3133,13 @@ async function ji(e) {
|
|
|
3133
3133
|
}
|
|
3134
3134
|
return o;
|
|
3135
3135
|
}
|
|
3136
|
-
async function
|
|
3136
|
+
async function ji(e) {
|
|
3137
3137
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3138
3138
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3139
3139
|
let c = [];
|
|
3140
3140
|
for (let e of t.files) {
|
|
3141
|
-
if (!
|
|
3142
|
-
let t = await
|
|
3141
|
+
if (!Ti(e, o)) continue;
|
|
3142
|
+
let t = await Oi({
|
|
3143
3143
|
file: e,
|
|
3144
3144
|
packDir: a,
|
|
3145
3145
|
paths: s,
|
|
@@ -3150,16 +3150,16 @@ async function Mi(e) {
|
|
|
3150
3150
|
}
|
|
3151
3151
|
return c;
|
|
3152
3152
|
}
|
|
3153
|
-
async function
|
|
3153
|
+
async function Mi(e) {
|
|
3154
3154
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3155
3155
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3156
3156
|
let l = {
|
|
3157
3157
|
installed: [],
|
|
3158
3158
|
skipped: [],
|
|
3159
3159
|
errors: []
|
|
3160
|
-
}, u = t.files.filter((e) =>
|
|
3160
|
+
}, u = t.files.filter((e) => Ti(e, s));
|
|
3161
3161
|
for (let e of u) {
|
|
3162
|
-
let t = await
|
|
3162
|
+
let t = await ki({
|
|
3163
3163
|
file: e,
|
|
3164
3164
|
packDir: o,
|
|
3165
3165
|
paths: c,
|
|
@@ -3179,40 +3179,40 @@ async function Ni(e) {
|
|
|
3179
3179
|
break;
|
|
3180
3180
|
}
|
|
3181
3181
|
}
|
|
3182
|
-
await
|
|
3182
|
+
await bi({
|
|
3183
3183
|
files: u,
|
|
3184
3184
|
paths: c,
|
|
3185
3185
|
projectRoot: r,
|
|
3186
3186
|
projectName: n.name
|
|
3187
|
-
}), t.env && t.env.length > 0 && await
|
|
3187
|
+
}), t.env && t.env.length > 0 && await Dr(t.env, c, r), t.routes && t.routes.length > 0 && await Mr(t.routes, c, r), t.context && t.context.length > 0 && await Fr(t.context, c, r), t.sockets && t.sockets.length > 0 && await Ur(t.sockets, c, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await qr(t.sdkConfigurations, c, r), t.enums && t.enums.length > 0 && await Vr(t.enums, c, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await Xr(t.frontendRoutes, c, r);
|
|
3188
3188
|
let d = s && s.length > 0 ? s : ["frontend"];
|
|
3189
|
-
for (let e of d) t.nav && t.nav.length > 0 && await
|
|
3189
|
+
for (let e of d) t.nav && t.nav.length > 0 && await ei({
|
|
3190
3190
|
entries: t.nav,
|
|
3191
3191
|
paths: c,
|
|
3192
3192
|
projectRoot: r,
|
|
3193
3193
|
slot: e
|
|
3194
|
-
}), t.navbarActions && t.navbarActions.length > 0 && await
|
|
3194
|
+
}), t.navbarActions && t.navbarActions.length > 0 && await pi({
|
|
3195
3195
|
actions: t.navbarActions,
|
|
3196
3196
|
paths: c,
|
|
3197
3197
|
projectRoot: r,
|
|
3198
3198
|
slot: e
|
|
3199
|
-
}), t.userMenuActions && t.userMenuActions.length > 0 && await
|
|
3199
|
+
}), t.userMenuActions && t.userMenuActions.length > 0 && await mi({
|
|
3200
3200
|
actions: t.userMenuActions,
|
|
3201
3201
|
paths: c,
|
|
3202
3202
|
projectRoot: r,
|
|
3203
3203
|
slot: e
|
|
3204
3204
|
});
|
|
3205
|
-
return t.onboardingSteps && t.onboardingSteps.length > 0 && await
|
|
3205
|
+
return t.onboardingSteps && t.onboardingSteps.length > 0 && await ci(t.onboardingSteps, c, r), t.postLoginRedirect && await ti({
|
|
3206
3206
|
postLoginRedirect: t.postLoginRedirect,
|
|
3207
3207
|
paths: c,
|
|
3208
3208
|
projectRoot: r,
|
|
3209
3209
|
slot: d[0]
|
|
3210
3210
|
}), l;
|
|
3211
3211
|
}
|
|
3212
|
-
async function
|
|
3212
|
+
async function Ni(e) {
|
|
3213
3213
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3214
3214
|
for (let e of t) {
|
|
3215
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3215
|
+
let t = o?.get(e.manifest.name), a = await ji({
|
|
3216
3216
|
manifest: e.manifest,
|
|
3217
3217
|
config: n,
|
|
3218
3218
|
projectRoot: r,
|
|
@@ -3232,7 +3232,7 @@ async function Pi(e) {
|
|
|
3232
3232
|
};
|
|
3233
3233
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3234
3234
|
for (let e of t) {
|
|
3235
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3235
|
+
let t = o?.get(e.manifest.name), n = await Mi({
|
|
3236
3236
|
manifest: e.manifest,
|
|
3237
3237
|
config: f,
|
|
3238
3238
|
projectRoot: r,
|
|
@@ -3241,7 +3241,7 @@ async function Pi(e) {
|
|
|
3241
3241
|
packDir: e.packDir,
|
|
3242
3242
|
slots: t
|
|
3243
3243
|
});
|
|
3244
|
-
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await
|
|
3244
|
+
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await Pi(f, e.manifest.name, r), d.push(e.manifest.name);
|
|
3245
3245
|
}
|
|
3246
3246
|
return {
|
|
3247
3247
|
installed: c,
|
|
@@ -3252,19 +3252,19 @@ async function Pi(e) {
|
|
|
3252
3252
|
config: f
|
|
3253
3253
|
};
|
|
3254
3254
|
}
|
|
3255
|
-
async function
|
|
3255
|
+
async function Pi(e, t, n) {
|
|
3256
3256
|
let r = {
|
|
3257
3257
|
...e,
|
|
3258
3258
|
installedPacks: [...e.installedPacks ?? [], t]
|
|
3259
3259
|
};
|
|
3260
|
-
return await
|
|
3260
|
+
return await pr(n, r), r;
|
|
3261
3261
|
}
|
|
3262
|
-
async function
|
|
3262
|
+
async function Fi(e) {
|
|
3263
3263
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3264
3264
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3265
3265
|
let o = [], s = [];
|
|
3266
3266
|
for (let e of t.files) {
|
|
3267
|
-
let t = await
|
|
3267
|
+
let t = await ki({
|
|
3268
3268
|
file: e,
|
|
3269
3269
|
packDir: i,
|
|
3270
3270
|
paths: a,
|
|
@@ -3282,11 +3282,11 @@ async function Ii(e) {
|
|
|
3282
3282
|
case "skipped": break;
|
|
3283
3283
|
}
|
|
3284
3284
|
}
|
|
3285
|
-
return t.frontendRoutes && t.frontendRoutes.length > 0 && await
|
|
3285
|
+
return t.frontendRoutes && t.frontendRoutes.length > 0 && await Xr(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await ei({
|
|
3286
3286
|
entries: t.nav,
|
|
3287
3287
|
paths: a,
|
|
3288
3288
|
projectRoot: r
|
|
3289
|
-
}), t.postLoginRedirect && await
|
|
3289
|
+
}), t.postLoginRedirect && await ti({
|
|
3290
3290
|
postLoginRedirect: t.postLoginRedirect,
|
|
3291
3291
|
paths: a,
|
|
3292
3292
|
projectRoot: r
|
|
@@ -3297,28 +3297,28 @@ async function Ii(e) {
|
|
|
3297
3297
|
}
|
|
3298
3298
|
//#endregion
|
|
3299
3299
|
//#region src/core/pack-categories.ts
|
|
3300
|
-
var
|
|
3300
|
+
var Ii = [
|
|
3301
3301
|
"starter",
|
|
3302
3302
|
"layout",
|
|
3303
3303
|
"feature"
|
|
3304
|
-
],
|
|
3304
|
+
], Li = {
|
|
3305
3305
|
starter: "Starter",
|
|
3306
3306
|
layout: "Layout",
|
|
3307
3307
|
feature: "Features"
|
|
3308
|
-
},
|
|
3309
|
-
function
|
|
3308
|
+
}, Ri = new Set(["starter", "layout"]), zi = "layout-basic";
|
|
3309
|
+
function Bi(e, t = {}) {
|
|
3310
3310
|
let n = [];
|
|
3311
|
-
for (let r of
|
|
3311
|
+
for (let r of Ii) {
|
|
3312
3312
|
let i = e.filter((e) => e.category === r);
|
|
3313
3313
|
if (i.length === 0) continue;
|
|
3314
|
-
let a =
|
|
3314
|
+
let a = Ri.has(r) ? "single" : "multiple";
|
|
3315
3315
|
if (r === "layout") {
|
|
3316
|
-
n.push(
|
|
3316
|
+
n.push(Vi("frontend", i)), t.adminAvailable && n.push(Vi("admin", i));
|
|
3317
3317
|
continue;
|
|
3318
3318
|
}
|
|
3319
3319
|
n.push({
|
|
3320
3320
|
category: r,
|
|
3321
|
-
label:
|
|
3321
|
+
label: Li[r],
|
|
3322
3322
|
mode: a,
|
|
3323
3323
|
packs: i,
|
|
3324
3324
|
preselect: null
|
|
@@ -3326,20 +3326,105 @@ function Vi(e, t = {}) {
|
|
|
3326
3326
|
}
|
|
3327
3327
|
return n;
|
|
3328
3328
|
}
|
|
3329
|
-
function
|
|
3330
|
-
let n = t.some((e) => e.name ===
|
|
3329
|
+
function Vi(e, t) {
|
|
3330
|
+
let n = t.some((e) => e.name === zi);
|
|
3331
3331
|
return {
|
|
3332
3332
|
category: "layout",
|
|
3333
3333
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3334
3334
|
mode: "single",
|
|
3335
3335
|
packs: t,
|
|
3336
|
-
preselect: n ?
|
|
3336
|
+
preselect: n ? zi : null,
|
|
3337
3337
|
slot: e
|
|
3338
3338
|
};
|
|
3339
3339
|
}
|
|
3340
3340
|
//#endregion
|
|
3341
|
+
//#region src/ui/logger.ts
|
|
3342
|
+
function Hi(e) {
|
|
3343
|
+
o.note(e.map((e) => `${R.arrow} ${e}`).join("\n"), "Next steps");
|
|
3344
|
+
}
|
|
3345
|
+
function Z() {
|
|
3346
|
+
o.cancel(L.muted("Operation cancelled.")), process.exit(0);
|
|
3347
|
+
}
|
|
3348
|
+
//#endregion
|
|
3349
|
+
//#region src/core/post-setup.ts
|
|
3350
|
+
async function Ui() {
|
|
3351
|
+
return (await J("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3352
|
+
}
|
|
3353
|
+
async function Wi(e) {
|
|
3354
|
+
return Y(`${e}/apps/backend/.env`);
|
|
3355
|
+
}
|
|
3356
|
+
async function Gi(e, t, n) {
|
|
3357
|
+
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 o.confirm({
|
|
3358
|
+
message: r,
|
|
3359
|
+
initialValue: !0
|
|
3360
|
+
});
|
|
3361
|
+
if (o.isCancel(i) && Z(), !i) return o.log.info(L.muted("Skipping Docker services and database migrations.")), !1;
|
|
3362
|
+
let a = o.spinner();
|
|
3363
|
+
return a.start("Starting Docker services..."), (await J("docker", [
|
|
3364
|
+
"compose",
|
|
3365
|
+
"up",
|
|
3366
|
+
"-d"
|
|
3367
|
+
], { cwd: `${e}/apps/backend` })).exitCode === 0 ? (a.stop(L.success("Docker services started")), !0) : (a.stop(L.warning("Failed to start Docker services")), o.log.warn(L.muted("Run `docker compose up -d` in apps/backend manually to start services.")), o.log.info(L.muted("Skipping database migrations.")), !1);
|
|
3368
|
+
}
|
|
3369
|
+
async function Ki(e, t = 15, n = 2e3) {
|
|
3370
|
+
for (let r = 0; r < t; r++) {
|
|
3371
|
+
if ((await J("docker", [
|
|
3372
|
+
"compose",
|
|
3373
|
+
"exec",
|
|
3374
|
+
"-T",
|
|
3375
|
+
"postgres",
|
|
3376
|
+
"pg_isready",
|
|
3377
|
+
"-U",
|
|
3378
|
+
"postgres"
|
|
3379
|
+
], { cwd: `${e}/apps/backend` })).exitCode === 0) return !0;
|
|
3380
|
+
await new Promise((e) => setTimeout(e, n));
|
|
3381
|
+
}
|
|
3382
|
+
return !1;
|
|
3383
|
+
}
|
|
3384
|
+
async function qi(e, t, n = {}) {
|
|
3385
|
+
if (!await Wi(e)) {
|
|
3386
|
+
o.log.warn(`${L.path(".env")} not found in ${L.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3387
|
+
return;
|
|
3388
|
+
}
|
|
3389
|
+
if (!await Gi(e, t, await Ui())) return;
|
|
3390
|
+
let r = o.spinner();
|
|
3391
|
+
if (r.start("Waiting for Postgres to be ready..."), !await Ki(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3)) {
|
|
3392
|
+
r.stop(L.warning("Postgres health check timed out")), o.log.warn(L.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest"));
|
|
3393
|
+
return;
|
|
3394
|
+
}
|
|
3395
|
+
r.stop(L.success("Postgres is ready"));
|
|
3396
|
+
let i = t ? !0 : await o.confirm({
|
|
3397
|
+
message: `Run database migrations with ${L.command("prisma migrate deploy")}?`,
|
|
3398
|
+
initialValue: !0
|
|
3399
|
+
});
|
|
3400
|
+
if (o.isCancel(i) && Z(), !i) {
|
|
3401
|
+
o.log.info(L.muted("Skipping database migrations."));
|
|
3402
|
+
return;
|
|
3403
|
+
}
|
|
3404
|
+
let a = o.spinner();
|
|
3405
|
+
if (a.start("Running database migrations..."), (await J("pnpm", [
|
|
3406
|
+
"--filter",
|
|
3407
|
+
"@internal/backend",
|
|
3408
|
+
"migration:latest"
|
|
3409
|
+
], { cwd: e })).exitCode !== 0) {
|
|
3410
|
+
a.stop(L.warning("Migrations failed")), o.log.warn(L.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations."));
|
|
3411
|
+
return;
|
|
3412
|
+
}
|
|
3413
|
+
a.stop(L.success("Database migrations applied"));
|
|
3414
|
+
let s = o.spinner();
|
|
3415
|
+
if (s.start("Generating Prisma client..."), (await J("pnpm", [
|
|
3416
|
+
"--filter",
|
|
3417
|
+
"@internal/backend",
|
|
3418
|
+
"generate"
|
|
3419
|
+
], { cwd: e })).exitCode !== 0) {
|
|
3420
|
+
s.stop(L.warning("Prisma client generation failed")), o.log.warn(L.muted("Run `pnpm --filter @internal/backend generate` manually."));
|
|
3421
|
+
return;
|
|
3422
|
+
}
|
|
3423
|
+
s.stop(L.success("Prisma client generated"));
|
|
3424
|
+
}
|
|
3425
|
+
//#endregion
|
|
3341
3426
|
//#region src/core/resolve.ts
|
|
3342
|
-
function
|
|
3427
|
+
function Ji(e) {
|
|
3343
3428
|
let t = /* @__PURE__ */ new Map();
|
|
3344
3429
|
for (let n of e) t.set(n.name, {
|
|
3345
3430
|
name: n.name,
|
|
@@ -3347,7 +3432,7 @@ function Ui(e) {
|
|
|
3347
3432
|
});
|
|
3348
3433
|
return t;
|
|
3349
3434
|
}
|
|
3350
|
-
function
|
|
3435
|
+
function Yi(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3351
3436
|
let r = /* @__PURE__ */ new Set();
|
|
3352
3437
|
function i(e) {
|
|
3353
3438
|
if (n.has(e)) return [];
|
|
@@ -3361,10 +3446,10 @@ function Wi(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3361
3446
|
}
|
|
3362
3447
|
return i(e);
|
|
3363
3448
|
}
|
|
3364
|
-
function
|
|
3449
|
+
function Xi(e, t, n = []) {
|
|
3365
3450
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3366
3451
|
for (let n of e) {
|
|
3367
|
-
let e =
|
|
3452
|
+
let e = Yi(n, t, new Set(i));
|
|
3368
3453
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3369
3454
|
}
|
|
3370
3455
|
return {
|
|
@@ -3372,7 +3457,7 @@ function Gi(e, t, n = []) {
|
|
|
3372
3457
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3373
3458
|
};
|
|
3374
3459
|
}
|
|
3375
|
-
function
|
|
3460
|
+
function Zi(e) {
|
|
3376
3461
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3377
3462
|
for (let e of t) {
|
|
3378
3463
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3385,7 +3470,7 @@ function Ki(e) {
|
|
|
3385
3470
|
}
|
|
3386
3471
|
//#endregion
|
|
3387
3472
|
//#region src/core/variants.ts
|
|
3388
|
-
function
|
|
3473
|
+
function Qi(e, t = {}) {
|
|
3389
3474
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3390
3475
|
for (let i of e) {
|
|
3391
3476
|
let e = t[i.family] ?? i.default;
|
|
@@ -3397,14 +3482,14 @@ function qi(e, t = {}) {
|
|
|
3397
3482
|
familyOf: r
|
|
3398
3483
|
};
|
|
3399
3484
|
}
|
|
3400
|
-
function
|
|
3485
|
+
function $i(e, t, n) {
|
|
3401
3486
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3402
3487
|
}
|
|
3403
|
-
function
|
|
3488
|
+
function ea(e, t) {
|
|
3404
3489
|
let n = t.familyOf.get(e);
|
|
3405
3490
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3406
3491
|
}
|
|
3407
|
-
function
|
|
3492
|
+
function ta(e, t) {
|
|
3408
3493
|
let n = /* @__PURE__ */ new Map();
|
|
3409
3494
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3410
3495
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3420,65 +3505,65 @@ function Xi(e, t) {
|
|
|
3420
3505
|
familyOf: n
|
|
3421
3506
|
};
|
|
3422
3507
|
}
|
|
3423
|
-
function
|
|
3508
|
+
function na(e, t) {
|
|
3424
3509
|
return e.map((e) => ({
|
|
3425
3510
|
...e,
|
|
3426
|
-
dependencies: e.dependencies.map((e) =>
|
|
3511
|
+
dependencies: e.dependencies.map((e) => ea(e, t))
|
|
3427
3512
|
}));
|
|
3428
3513
|
}
|
|
3429
3514
|
//#endregion
|
|
3430
3515
|
//#region src/ui/banner.ts
|
|
3431
|
-
var
|
|
3516
|
+
var ra = [
|
|
3432
3517
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3433
3518
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3434
3519
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3435
3520
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3436
3521
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3437
3522
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3438
|
-
],
|
|
3523
|
+
], ia = [
|
|
3439
3524
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3440
3525
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3441
3526
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3442
3527
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3443
3528
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3444
3529
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3445
|
-
],
|
|
3530
|
+
], aa = [
|
|
3446
3531
|
253,
|
|
3447
3532
|
176,
|
|
3448
3533
|
21
|
|
3449
|
-
],
|
|
3534
|
+
], oa = [
|
|
3450
3535
|
245,
|
|
3451
3536
|
76,
|
|
3452
3537
|
2
|
|
3453
|
-
],
|
|
3538
|
+
], sa = 5, ca = [
|
|
3454
3539
|
17,
|
|
3455
3540
|
103,
|
|
3456
3541
|
248
|
|
3457
|
-
],
|
|
3542
|
+
], la = [
|
|
3458
3543
|
42,
|
|
3459
3544
|
160,
|
|
3460
3545
|
250
|
|
3461
|
-
],
|
|
3462
|
-
function
|
|
3546
|
+
], ua = .2;
|
|
3547
|
+
function da() {
|
|
3463
3548
|
console.log();
|
|
3464
|
-
for (let e of
|
|
3465
|
-
start:
|
|
3466
|
-
end:
|
|
3467
|
-
angle:
|
|
3549
|
+
for (let e of xe(ra, {
|
|
3550
|
+
start: aa,
|
|
3551
|
+
end: oa,
|
|
3552
|
+
angle: sa
|
|
3468
3553
|
})) console.log(y.bold(e));
|
|
3469
|
-
for (let e of
|
|
3470
|
-
start:
|
|
3471
|
-
end:
|
|
3472
|
-
angle:
|
|
3554
|
+
for (let e of xe(ia, {
|
|
3555
|
+
start: ca,
|
|
3556
|
+
end: la,
|
|
3557
|
+
angle: ua
|
|
3473
3558
|
})) console.log(y.bold(e));
|
|
3474
|
-
console.log(), console.log(` ${
|
|
3559
|
+
console.log(), console.log(` ${R.spark} ${y.dim("v" + k)} ${y.dim("·")} ${ye("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3475
3560
|
}
|
|
3476
|
-
function
|
|
3477
|
-
console.log(), console.log(` ${
|
|
3561
|
+
function fa() {
|
|
3562
|
+
console.log(), console.log(` ${R.bolt} ${ge.orange("Hype")}${ge.skyBlue("Stack")} ${y.dim("v" + k)}`), console.log();
|
|
3478
3563
|
}
|
|
3479
3564
|
//#endregion
|
|
3480
3565
|
//#region src/ui/pack-multiselect.ts
|
|
3481
|
-
var
|
|
3566
|
+
var pa = class extends D {
|
|
3482
3567
|
options;
|
|
3483
3568
|
cursor = 0;
|
|
3484
3569
|
selected;
|
|
@@ -3582,20 +3667,12 @@ var sa = class extends D {
|
|
|
3582
3667
|
}
|
|
3583
3668
|
}
|
|
3584
3669
|
};
|
|
3585
|
-
function
|
|
3586
|
-
return new
|
|
3587
|
-
}
|
|
3588
|
-
//#endregion
|
|
3589
|
-
//#region src/ui/logger.ts
|
|
3590
|
-
function la(e) {
|
|
3591
|
-
o.note(e.map((e) => `${z.arrow} ${e}`).join("\n"), "Next steps");
|
|
3592
|
-
}
|
|
3593
|
-
function Z() {
|
|
3594
|
-
o.cancel(R.muted("Operation cancelled.")), process.exit(0);
|
|
3670
|
+
function ma(e) {
|
|
3671
|
+
return new pa(e).prompt();
|
|
3595
3672
|
}
|
|
3596
3673
|
//#endregion
|
|
3597
3674
|
//#region src/core/apply-theme.ts
|
|
3598
|
-
function
|
|
3675
|
+
function ha(e, t) {
|
|
3599
3676
|
let n = e.indexOf(t);
|
|
3600
3677
|
if (n === -1) return null;
|
|
3601
3678
|
let r = e.indexOf("{", n);
|
|
@@ -3610,47 +3687,47 @@ function ua(e, t) {
|
|
|
3610
3687
|
bodyEnd: a - 1
|
|
3611
3688
|
} : null;
|
|
3612
3689
|
}
|
|
3613
|
-
function
|
|
3690
|
+
function ga(e, t) {
|
|
3614
3691
|
let n = e;
|
|
3615
3692
|
for (let [e, r] of Object.entries(t)) {
|
|
3616
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3693
|
+
let t = RegExp(`(^[ \\t]*--${_a(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3617
3694
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3618
3695
|
}
|
|
3619
3696
|
return n;
|
|
3620
3697
|
}
|
|
3621
|
-
function
|
|
3698
|
+
function _a(e) {
|
|
3622
3699
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3623
3700
|
}
|
|
3624
|
-
function
|
|
3625
|
-
let n =
|
|
3701
|
+
function va(e, t) {
|
|
3702
|
+
let n = ha(e, ":root"), r = ha(e, ".dark"), i = e;
|
|
3626
3703
|
if (n) {
|
|
3627
3704
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3628
|
-
i = e +
|
|
3705
|
+
i = e + ga(r, t.light) + a;
|
|
3629
3706
|
}
|
|
3630
3707
|
if (r) {
|
|
3631
|
-
let e =
|
|
3708
|
+
let e = ha(i, ".dark");
|
|
3632
3709
|
if (e) {
|
|
3633
3710
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3634
|
-
i = n +
|
|
3711
|
+
i = n + ga(r, t.dark) + a;
|
|
3635
3712
|
}
|
|
3636
3713
|
}
|
|
3637
3714
|
return i;
|
|
3638
3715
|
}
|
|
3639
|
-
var
|
|
3640
|
-
async function
|
|
3641
|
-
let n = w.resolve(e,
|
|
3716
|
+
var ya = "assets/styles.css";
|
|
3717
|
+
async function ba(e, t) {
|
|
3718
|
+
let n = w.resolve(e, ya), r;
|
|
3642
3719
|
try {
|
|
3643
3720
|
r = await v.readFile(n, "utf-8");
|
|
3644
3721
|
} catch {
|
|
3645
3722
|
return !1;
|
|
3646
3723
|
}
|
|
3647
|
-
let i =
|
|
3724
|
+
let i = va(r, t);
|
|
3648
3725
|
return i === r || await v.writeFile(n, i, "utf-8"), !0;
|
|
3649
3726
|
}
|
|
3650
3727
|
//#endregion
|
|
3651
3728
|
//#region src/core/clone.ts
|
|
3652
|
-
async function
|
|
3653
|
-
let t = await ee(
|
|
3729
|
+
async function xa(e) {
|
|
3730
|
+
let t = await ee(te, {
|
|
3654
3731
|
dir: e,
|
|
3655
3732
|
force: !0
|
|
3656
3733
|
});
|
|
@@ -3661,7 +3738,7 @@ async function ga(e) {
|
|
|
3661
3738
|
}
|
|
3662
3739
|
//#endregion
|
|
3663
3740
|
//#region src/core/editor-config.ts
|
|
3664
|
-
function
|
|
3741
|
+
function Sa(e) {
|
|
3665
3742
|
let t = {
|
|
3666
3743
|
globs: [],
|
|
3667
3744
|
alwaysApply: !1
|
|
@@ -3696,10 +3773,10 @@ function _a(e) {
|
|
|
3696
3773
|
content: i
|
|
3697
3774
|
};
|
|
3698
3775
|
}
|
|
3699
|
-
function
|
|
3776
|
+
function Ca(e) {
|
|
3700
3777
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
3701
3778
|
}
|
|
3702
|
-
function
|
|
3779
|
+
function wa(e) {
|
|
3703
3780
|
let t;
|
|
3704
3781
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
3705
3782
|
let n = [`trigger: ${t}`];
|
|
@@ -3709,30 +3786,30 @@ function ya(e) {
|
|
|
3709
3786
|
}
|
|
3710
3787
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
3711
3788
|
}
|
|
3712
|
-
function
|
|
3789
|
+
function Ta(e) {
|
|
3713
3790
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
3714
3791
|
}
|
|
3715
|
-
var
|
|
3792
|
+
var Ea = {
|
|
3716
3793
|
claude: {
|
|
3717
3794
|
rulesDir: ".claude/rules",
|
|
3718
3795
|
extension: ".md",
|
|
3719
|
-
convert:
|
|
3796
|
+
convert: Ca
|
|
3720
3797
|
},
|
|
3721
3798
|
windsurf: {
|
|
3722
3799
|
rulesDir: ".windsurf/rules",
|
|
3723
3800
|
extension: ".md",
|
|
3724
|
-
convert:
|
|
3801
|
+
convert: wa
|
|
3725
3802
|
},
|
|
3726
3803
|
copilot: {
|
|
3727
3804
|
rulesDir: ".github/instructions",
|
|
3728
3805
|
extension: ".instructions.md",
|
|
3729
|
-
convert:
|
|
3806
|
+
convert: Ta
|
|
3730
3807
|
}
|
|
3731
3808
|
};
|
|
3732
|
-
async function
|
|
3733
|
-
let t = w.join(e,
|
|
3809
|
+
async function Da(e) {
|
|
3810
|
+
let t = w.join(e, se), n = (await v.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
3734
3811
|
return await Promise.all(n.map(async (e) => {
|
|
3735
|
-
let n = w.join(t, e.name), { frontmatter: r, content: i } =
|
|
3812
|
+
let n = w.join(t, e.name), { frontmatter: r, content: i } = Sa(await v.readFile(n, "utf-8"));
|
|
3736
3813
|
return {
|
|
3737
3814
|
frontmatter: r,
|
|
3738
3815
|
content: i,
|
|
@@ -3740,44 +3817,44 @@ async function Sa(e) {
|
|
|
3740
3817
|
};
|
|
3741
3818
|
}));
|
|
3742
3819
|
}
|
|
3743
|
-
async function
|
|
3820
|
+
async function Oa(e, t) {
|
|
3744
3821
|
if (t === "cursor") return;
|
|
3745
|
-
let n =
|
|
3822
|
+
let n = Ea[t], r = await Da(e), i = w.join(e, n.rulesDir);
|
|
3746
3823
|
await v.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
3747
3824
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3748
3825
|
return v.writeFile(w.join(i, r), t, "utf-8");
|
|
3749
|
-
})), await
|
|
3826
|
+
})), await sr(w.join(e, ce)), await sr(w.join(e, le));
|
|
3750
3827
|
}
|
|
3751
3828
|
//#endregion
|
|
3752
3829
|
//#region src/core/env-files.ts
|
|
3753
|
-
var
|
|
3830
|
+
var ka = [
|
|
3754
3831
|
"apps",
|
|
3755
3832
|
"packages",
|
|
3756
3833
|
"libs",
|
|
3757
3834
|
"shared"
|
|
3758
3835
|
];
|
|
3759
|
-
async function
|
|
3760
|
-
let t = await
|
|
3836
|
+
async function Aa(e) {
|
|
3837
|
+
let t = await ja(e);
|
|
3761
3838
|
return (await Promise.all(t.map(async (t) => {
|
|
3762
3839
|
let n = w.join(w.dirname(t), ".env");
|
|
3763
|
-
return await
|
|
3840
|
+
return await Y(n) ? null : (await v.copyFile(t, n), w.relative(e, n));
|
|
3764
3841
|
}))).filter((e) => e !== null).sort();
|
|
3765
3842
|
}
|
|
3766
|
-
async function
|
|
3767
|
-
let t = [w.join(e, ".env.example")], n = await Promise.all(
|
|
3843
|
+
async function ja(e) {
|
|
3844
|
+
let t = [w.join(e, ".env.example")], n = await Promise.all(ka.map(async (t) => {
|
|
3768
3845
|
let n = w.join(e, t);
|
|
3769
3846
|
return (await v.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => w.join(n, e.name, ".env.example"));
|
|
3770
3847
|
}));
|
|
3771
|
-
return t.push(...n.flat()), (await Promise.all(t.map(async (e) => await
|
|
3848
|
+
return t.push(...n.flat()), (await Promise.all(t.map(async (e) => await Y(e) ? e : null))).filter((e) => e !== null);
|
|
3772
3849
|
}
|
|
3773
3850
|
//#endregion
|
|
3774
3851
|
//#region src/core/post-clone.ts
|
|
3775
|
-
var Q = "@hype-stack/",
|
|
3776
|
-
async function
|
|
3777
|
-
await
|
|
3852
|
+
var Q = "@hype-stack/", Ma = "hype-stack";
|
|
3853
|
+
async function Na(e) {
|
|
3854
|
+
await sr(w.join(e, ".git"));
|
|
3778
3855
|
}
|
|
3779
|
-
async function
|
|
3780
|
-
await
|
|
3856
|
+
async function Pa(e) {
|
|
3857
|
+
await J("git", ["init"], { cwd: e }), await J("git", ["add", "."], { cwd: e }), await J("git", [
|
|
3781
3858
|
"-c",
|
|
3782
3859
|
"user.name=Hype Stack CLI",
|
|
3783
3860
|
"-c",
|
|
@@ -3787,22 +3864,48 @@ async function ka(e) {
|
|
|
3787
3864
|
"Initial commit from Hype Stack CLI"
|
|
3788
3865
|
], { cwd: e });
|
|
3789
3866
|
}
|
|
3790
|
-
async function
|
|
3791
|
-
let n = `@${t}/`, r = await
|
|
3867
|
+
async function Fa(e, t) {
|
|
3868
|
+
let n = `@${t}/`, r = await Ua(e);
|
|
3792
3869
|
for (let e of r) {
|
|
3793
|
-
let t = await
|
|
3870
|
+
let t = await ir(e);
|
|
3794
3871
|
if (!t) continue;
|
|
3795
3872
|
let r = !1;
|
|
3796
|
-
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0),
|
|
3873
|
+
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0), Ba(t.dependencies, n) && (r = !0), Ba(t.devDependencies, n) && (r = !0), t.nx && Va(t.nx, n) && (r = !0);
|
|
3797
3874
|
let i = await v.readFile(e, "utf-8");
|
|
3798
3875
|
if (i.includes(Q)) {
|
|
3799
3876
|
let t = i.replaceAll(Q, n);
|
|
3800
3877
|
await v.writeFile(e, t, "utf-8");
|
|
3801
|
-
} else r && await
|
|
3878
|
+
} else r && await ar(e, t);
|
|
3802
3879
|
}
|
|
3803
|
-
await
|
|
3880
|
+
await Si(e, t), await Ra(e, t), await Ha(e, t);
|
|
3804
3881
|
}
|
|
3805
|
-
|
|
3882
|
+
var Ia = new Set([
|
|
3883
|
+
".git",
|
|
3884
|
+
"node_modules",
|
|
3885
|
+
"dist",
|
|
3886
|
+
"build",
|
|
3887
|
+
".nx",
|
|
3888
|
+
".next",
|
|
3889
|
+
"coverage"
|
|
3890
|
+
]), La = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
|
|
3891
|
+
async function Ra(e, t) {
|
|
3892
|
+
if (t === Ma) return;
|
|
3893
|
+
let n = await za(e);
|
|
3894
|
+
await Promise.all(n.map(async (e) => {
|
|
3895
|
+
let n = await v.readFile(e, "utf-8").catch(() => null);
|
|
3896
|
+
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
3897
|
+
let r = n.replace(/^(name:[ \t]*)hype-stack/gm, `$1${t}`);
|
|
3898
|
+
await v.writeFile(e, r, "utf-8");
|
|
3899
|
+
}));
|
|
3900
|
+
}
|
|
3901
|
+
async function za(e) {
|
|
3902
|
+
let t = await v.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
3903
|
+
return (await Promise.all(t.map(async (t) => {
|
|
3904
|
+
let n = w.join(e, t.name);
|
|
3905
|
+
return t.isDirectory() ? Ia.has(t.name) ? [] : za(n) : t.isFile() && La.test(t.name) ? [n] : [];
|
|
3906
|
+
}))).flat();
|
|
3907
|
+
}
|
|
3908
|
+
function Ba(e, t) {
|
|
3806
3909
|
if (!e) return !1;
|
|
3807
3910
|
let n = !1;
|
|
3808
3911
|
for (let r of Object.keys(e)) if (r.startsWith(Q)) {
|
|
@@ -3811,7 +3914,7 @@ function ja(e, t) {
|
|
|
3811
3914
|
}
|
|
3812
3915
|
return n;
|
|
3813
3916
|
}
|
|
3814
|
-
function
|
|
3917
|
+
function Va(e, t) {
|
|
3815
3918
|
if (!e) return !1;
|
|
3816
3919
|
let n = !1;
|
|
3817
3920
|
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Q) ? (n = !0, e.replace(Q, t)) : e), e.targets) {
|
|
@@ -3819,13 +3922,13 @@ function Ma(e, t) {
|
|
|
3819
3922
|
}
|
|
3820
3923
|
return n;
|
|
3821
3924
|
}
|
|
3822
|
-
async function
|
|
3925
|
+
async function Ha(e, t) {
|
|
3823
3926
|
let n = w.join(e, "packages/enums/src/app/index.ts"), r = await v.readFile(n, "utf-8").catch(() => null);
|
|
3824
3927
|
if (!r) return;
|
|
3825
|
-
let i = t.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" "), a = r.replaceAll(`id: "${
|
|
3928
|
+
let i = t.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" "), a = r.replaceAll(`id: "${Ma}"`, `id: "${t}"`).replaceAll(`name: "${Ma}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
|
|
3826
3929
|
await v.writeFile(n, a, "utf-8");
|
|
3827
3930
|
}
|
|
3828
|
-
async function
|
|
3931
|
+
async function Ua(e) {
|
|
3829
3932
|
let t = [], n = w.join(e, "package.json");
|
|
3830
3933
|
(await v.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
3831
3934
|
for (let n of [
|
|
@@ -3844,85 +3947,8 @@ async function Pa(e) {
|
|
|
3844
3947
|
return t;
|
|
3845
3948
|
}
|
|
3846
3949
|
//#endregion
|
|
3847
|
-
//#region src/core/post-setup.ts
|
|
3848
|
-
async function Fa() {
|
|
3849
|
-
return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3850
|
-
}
|
|
3851
|
-
async function Ia(e) {
|
|
3852
|
-
return J(`${e}/apps/backend/.env`);
|
|
3853
|
-
}
|
|
3854
|
-
async function La(e, t, n) {
|
|
3855
|
-
let r = n ? `Start services with ${R.command("docker compose up -d")}?` : `Docker is not running. Start services with ${R.command("docker compose up -d")}?`, i = t ? !0 : await o.confirm({
|
|
3856
|
-
message: r,
|
|
3857
|
-
initialValue: !0
|
|
3858
|
-
});
|
|
3859
|
-
if (o.isCancel(i) && Z(), !i) return o.log.info(R.muted("Skipping Docker services and database migrations.")), !1;
|
|
3860
|
-
let a = o.spinner();
|
|
3861
|
-
return a.start("Starting Docker services..."), (await q("docker", [
|
|
3862
|
-
"compose",
|
|
3863
|
-
"up",
|
|
3864
|
-
"-d"
|
|
3865
|
-
], { cwd: `${e}/apps/backend` })).exitCode === 0 ? (a.stop(R.success("Docker services started")), !0) : (a.stop(R.warning("Failed to start Docker services")), o.log.warn(R.muted("Run `docker compose up -d` in apps/backend manually to start services.")), o.log.info(R.muted("Skipping database migrations.")), !1);
|
|
3866
|
-
}
|
|
3867
|
-
async function Ra(e, t = 15, n = 2e3) {
|
|
3868
|
-
for (let r = 0; r < t; r++) {
|
|
3869
|
-
if ((await q("docker", [
|
|
3870
|
-
"compose",
|
|
3871
|
-
"exec",
|
|
3872
|
-
"-T",
|
|
3873
|
-
"postgres",
|
|
3874
|
-
"pg_isready",
|
|
3875
|
-
"-U",
|
|
3876
|
-
"postgres"
|
|
3877
|
-
], { cwd: `${e}/apps/backend` })).exitCode === 0) return !0;
|
|
3878
|
-
await new Promise((e) => setTimeout(e, n));
|
|
3879
|
-
}
|
|
3880
|
-
return !1;
|
|
3881
|
-
}
|
|
3882
|
-
async function za(e, t, n = {}) {
|
|
3883
|
-
if (!await Ia(e)) {
|
|
3884
|
-
o.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3885
|
-
return;
|
|
3886
|
-
}
|
|
3887
|
-
if (!await La(e, t, await Fa())) return;
|
|
3888
|
-
let r = o.spinner();
|
|
3889
|
-
if (r.start("Waiting for Postgres to be ready..."), !await Ra(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3)) {
|
|
3890
|
-
r.stop(R.warning("Postgres health check timed out")), o.log.warn(R.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest"));
|
|
3891
|
-
return;
|
|
3892
|
-
}
|
|
3893
|
-
r.stop(R.success("Postgres is ready"));
|
|
3894
|
-
let i = t ? !0 : await o.confirm({
|
|
3895
|
-
message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
|
|
3896
|
-
initialValue: !0
|
|
3897
|
-
});
|
|
3898
|
-
if (o.isCancel(i) && Z(), !i) {
|
|
3899
|
-
o.log.info(R.muted("Skipping database migrations."));
|
|
3900
|
-
return;
|
|
3901
|
-
}
|
|
3902
|
-
let a = o.spinner();
|
|
3903
|
-
if (a.start("Running database migrations..."), (await q("pnpm", [
|
|
3904
|
-
"--filter",
|
|
3905
|
-
"@internal/backend",
|
|
3906
|
-
"migration:latest"
|
|
3907
|
-
], { cwd: e })).exitCode !== 0) {
|
|
3908
|
-
a.stop(R.warning("Migrations failed")), o.log.warn(R.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations."));
|
|
3909
|
-
return;
|
|
3910
|
-
}
|
|
3911
|
-
a.stop(R.success("Database migrations applied"));
|
|
3912
|
-
let s = o.spinner();
|
|
3913
|
-
if (s.start("Generating Prisma client..."), (await q("pnpm", [
|
|
3914
|
-
"--filter",
|
|
3915
|
-
"@internal/backend",
|
|
3916
|
-
"generate"
|
|
3917
|
-
], { cwd: e })).exitCode !== 0) {
|
|
3918
|
-
s.stop(R.warning("Prisma client generation failed")), o.log.warn(R.muted("Run `pnpm --filter @internal/backend generate` manually."));
|
|
3919
|
-
return;
|
|
3920
|
-
}
|
|
3921
|
-
s.stop(R.success("Prisma client generated"));
|
|
3922
|
-
}
|
|
3923
|
-
//#endregion
|
|
3924
3950
|
//#region src/core/readme.ts
|
|
3925
|
-
var
|
|
3951
|
+
var Wa = {
|
|
3926
3952
|
cursor: {
|
|
3927
3953
|
label: "Cursor",
|
|
3928
3954
|
rulesDir: ".cursor/rules"
|
|
@@ -3939,24 +3965,24 @@ var Ba = {
|
|
|
3939
3965
|
label: "GitHub Copilot",
|
|
3940
3966
|
rulesDir: ".github/instructions"
|
|
3941
3967
|
}
|
|
3942
|
-
},
|
|
3968
|
+
}, Ga = {
|
|
3943
3969
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
3944
3970
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
3945
|
-
},
|
|
3971
|
+
}, Ka = {
|
|
3946
3972
|
enums: "Shared enums and app config used across apps",
|
|
3947
3973
|
cli: "Project tooling and code generators"
|
|
3948
3974
|
};
|
|
3949
|
-
function
|
|
3975
|
+
function qa(e) {
|
|
3950
3976
|
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3951
3977
|
}
|
|
3952
|
-
function
|
|
3978
|
+
function Ja(e, t) {
|
|
3953
3979
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
3954
3980
|
let r = t[e];
|
|
3955
3981
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
3956
3982
|
});
|
|
3957
3983
|
}
|
|
3958
|
-
function
|
|
3959
|
-
let { projectName: t, editor: n, workspace: r } = e, i =
|
|
3984
|
+
function Ya(e) {
|
|
3985
|
+
let { projectName: t, editor: n, workspace: r } = e, i = qa(t), a = Wa[n], o = !!r.apps.backend, s = Ja(r.apps, Ga), c = Ja(r.packages, Ka), l = [];
|
|
3960
3986
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
3961
3987
|
let u = [];
|
|
3962
3988
|
u.push(`# ${i}`), u.push([
|
|
@@ -4064,19 +4090,19 @@ function Ga(e) {
|
|
|
4064
4090
|
"stays useful."
|
|
4065
4091
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4066
4092
|
}
|
|
4067
|
-
async function
|
|
4093
|
+
async function Xa(e, t) {
|
|
4068
4094
|
let n = w.join(e, "README.md");
|
|
4069
|
-
await v.writeFile(n,
|
|
4095
|
+
await v.writeFile(n, Ya(t), "utf-8");
|
|
4070
4096
|
}
|
|
4071
4097
|
//#endregion
|
|
4072
4098
|
//#region src/core/tracking.ts
|
|
4073
|
-
async function
|
|
4099
|
+
async function Za(e) {
|
|
4074
4100
|
try {
|
|
4075
4101
|
let t = {
|
|
4076
|
-
"X-Device-Id":
|
|
4077
|
-
"X-Client-Info":
|
|
4078
|
-
}, n = await
|
|
4079
|
-
n?.token && (t.Authorization = `Bearer ${n.token}`), await
|
|
4102
|
+
"X-Device-Id": Jn(),
|
|
4103
|
+
"X-Client-Info": Yn()
|
|
4104
|
+
}, n = await Wn(N()).catch(() => null);
|
|
4105
|
+
n?.token && (t.Authorization = `Bearer ${n.token}`), await q.createRequest()({
|
|
4080
4106
|
endpoint: "/cli/track",
|
|
4081
4107
|
method: "POST"
|
|
4082
4108
|
}).setPayload({ event: e }).setHeaders(t).send();
|
|
@@ -4084,7 +4110,7 @@ async function qa(e) {
|
|
|
4084
4110
|
}
|
|
4085
4111
|
//#endregion
|
|
4086
4112
|
//#region src/ui/swatch.ts
|
|
4087
|
-
function
|
|
4113
|
+
function Qa(e) {
|
|
4088
4114
|
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4089
4115
|
if (!t) return null;
|
|
4090
4116
|
let n = t[1].trim().split(/\s+/);
|
|
@@ -4103,61 +4129,61 @@ function Ja(e) {
|
|
|
4103
4129
|
h: a
|
|
4104
4130
|
};
|
|
4105
4131
|
}
|
|
4106
|
-
function
|
|
4132
|
+
function $a(e) {
|
|
4107
4133
|
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4108
4134
|
}
|
|
4109
|
-
function
|
|
4135
|
+
function eo(e) {
|
|
4110
4136
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4111
4137
|
}
|
|
4112
|
-
function
|
|
4138
|
+
function to({ l: e, c: t, h: n }) {
|
|
4113
4139
|
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;
|
|
4114
4140
|
return [
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4141
|
+
$a(eo(f) * 255),
|
|
4142
|
+
$a(eo(p) * 255),
|
|
4143
|
+
$a(eo(m) * 255)
|
|
4118
4144
|
];
|
|
4119
4145
|
}
|
|
4120
|
-
var
|
|
4121
|
-
function
|
|
4146
|
+
var no = "\x1B[49m";
|
|
4147
|
+
function ro(e, t) {
|
|
4122
4148
|
let n = e[t];
|
|
4123
4149
|
if (!n) return y.dim(" ");
|
|
4124
|
-
let r =
|
|
4150
|
+
let r = Qa(n);
|
|
4125
4151
|
if (!r) return y.dim(" ");
|
|
4126
|
-
let [i, a, o] =
|
|
4127
|
-
return `\x1b[48;2;${i};${a};${o}m ${
|
|
4152
|
+
let [i, a, o] = to(r);
|
|
4153
|
+
return `\x1b[48;2;${i};${a};${o}m ${no}`;
|
|
4128
4154
|
}
|
|
4129
|
-
var
|
|
4155
|
+
var io = [
|
|
4130
4156
|
"primary",
|
|
4131
4157
|
"secondary",
|
|
4132
4158
|
"accent"
|
|
4133
4159
|
];
|
|
4134
|
-
function
|
|
4135
|
-
return
|
|
4160
|
+
function ao(e) {
|
|
4161
|
+
return io.map((t) => ro(e, t)).join("");
|
|
4136
4162
|
}
|
|
4137
|
-
function
|
|
4138
|
-
return `${
|
|
4163
|
+
function oo(e) {
|
|
4164
|
+
return `${ao(e.light)} ${y.dim("·")} ${ao(e.dark)}`;
|
|
4139
4165
|
}
|
|
4140
4166
|
//#endregion
|
|
4141
4167
|
//#region src/utils/validate.ts
|
|
4142
|
-
function
|
|
4168
|
+
function so(e) {
|
|
4143
4169
|
if (!e.trim()) return "Project name cannot be empty";
|
|
4144
|
-
if (!
|
|
4170
|
+
if (!M.test(e)) return "Project name must be lowercase, alphanumeric, and may contain hyphens, dots, or underscores";
|
|
4145
4171
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
4146
4172
|
}
|
|
4147
4173
|
//#endregion
|
|
4148
4174
|
//#region src/commands/create.ts
|
|
4149
|
-
async function
|
|
4150
|
-
|
|
4175
|
+
async function co(a) {
|
|
4176
|
+
da(), o.intro(L.brandBold("Create a new Hype Stack project"));
|
|
4151
4177
|
let s = a.yes === !0, c;
|
|
4152
4178
|
if (s && a.name) {
|
|
4153
|
-
let e =
|
|
4179
|
+
let e = so(a.name);
|
|
4154
4180
|
e && (o.log.error(e), Z()), c = a.name;
|
|
4155
4181
|
} else {
|
|
4156
4182
|
let e = await o.text({
|
|
4157
4183
|
message: "What is your project named?",
|
|
4158
4184
|
placeholder: "my-app",
|
|
4159
4185
|
initialValue: a.name ?? "",
|
|
4160
|
-
validate: (e) =>
|
|
4186
|
+
validate: (e) => so(e ?? "")
|
|
4161
4187
|
});
|
|
4162
4188
|
o.isCancel(e) && Z(), c = e;
|
|
4163
4189
|
}
|
|
@@ -4175,17 +4201,17 @@ async function io(a) {
|
|
|
4175
4201
|
});
|
|
4176
4202
|
o.isCancel(t) && Z(), e = t;
|
|
4177
4203
|
}
|
|
4178
|
-
l =
|
|
4204
|
+
l = cr(e, c);
|
|
4179
4205
|
}
|
|
4180
4206
|
let u = w.resolve(l);
|
|
4181
|
-
s || o.note(
|
|
4182
|
-
let d = a.editor &&
|
|
4207
|
+
s || o.note(L.path(u), "Project will be created at");
|
|
4208
|
+
let d = a.editor && oe.includes(a.editor) ? a.editor : null, f;
|
|
4183
4209
|
if (d) f = d;
|
|
4184
4210
|
else if (s) f = "cursor";
|
|
4185
4211
|
else {
|
|
4186
4212
|
let e = await o.select({
|
|
4187
4213
|
message: "Which code editor do you use?",
|
|
4188
|
-
options:
|
|
4214
|
+
options: ae.map((e) => ({
|
|
4189
4215
|
value: e.value,
|
|
4190
4216
|
label: e.label,
|
|
4191
4217
|
hint: "hint" in e ? e.hint : void 0
|
|
@@ -4202,93 +4228,98 @@ async function io(a) {
|
|
|
4202
4228
|
message: "Pick a color theme",
|
|
4203
4229
|
options: n.map((e) => ({
|
|
4204
4230
|
value: e.name,
|
|
4205
|
-
label: `${
|
|
4231
|
+
label: `${oo(e)} ${e.label}`
|
|
4206
4232
|
})),
|
|
4207
4233
|
initialValue: e
|
|
4208
4234
|
});
|
|
4209
4235
|
o.isCancel(t) && Z(), m = t;
|
|
4210
4236
|
}
|
|
4211
4237
|
if (!s) {
|
|
4212
|
-
let e =
|
|
4238
|
+
let e = ae.find((e) => e.value === f)?.label ?? f, n = t.find((e) => e.value === m)?.label ?? m, r = await o.confirm({ message: `Create ${L.highlight(c)} in ${L.path(u)} with ${L.highlight(e)} config and the ${L.highlight(n)} theme?` });
|
|
4213
4239
|
(o.isCancel(r) || !r) && Z();
|
|
4214
4240
|
}
|
|
4215
|
-
if (await
|
|
4241
|
+
if (await nr(u) && !await rr(u)) {
|
|
4216
4242
|
let e = await o.confirm({
|
|
4217
|
-
message: `Directory ${
|
|
4243
|
+
message: `Directory ${L.path(u)} is not empty. Continue anyway?`,
|
|
4218
4244
|
initialValue: !1
|
|
4219
4245
|
});
|
|
4220
4246
|
(o.isCancel(e) || !e) && Z();
|
|
4221
4247
|
}
|
|
4222
4248
|
let h = o.spinner();
|
|
4223
|
-
h.start("Cloning Hype Stack template..."), await
|
|
4249
|
+
h.start("Cloning Hype Stack template..."), await xa(u), h.stop(L.success("Template cloned"));
|
|
4224
4250
|
let g = o.spinner();
|
|
4225
|
-
g.start("Setting up project..."), await
|
|
4226
|
-
let _ = await
|
|
4227
|
-
await
|
|
4251
|
+
g.start("Setting up project..."), await Na(u), await Fa(u, c), await Oa(u, f);
|
|
4252
|
+
let _ = await mr(u), v = gr(c, _);
|
|
4253
|
+
await pr(u, v), await Xa(u, {
|
|
4228
4254
|
projectName: c,
|
|
4229
4255
|
editor: f,
|
|
4230
4256
|
workspace: _
|
|
4231
|
-
}), i(m) && (await
|
|
4257
|
+
}), i(m) && (await ba(w.resolve(u, v.paths?.frontend.root ?? "apps/frontend"), r(m)) || o.log.warn(L.muted(`Could not find ${L.path("assets/styles.css")} to apply the ${m} theme`))), g.stop(L.success("Project configured"));
|
|
4232
4258
|
let y = o.spinner();
|
|
4233
|
-
y.start("Installing dependencies..."), (await
|
|
4259
|
+
y.start("Installing dependencies..."), (await J("pnpm", ["install"], { cwd: u })).exitCode === 0 ? y.stop(L.success("Dependencies installed")) : (y.stop(L.warning("Dependencies installed with warnings")), o.log.warn(L.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4234
4260
|
let b = o.spinner();
|
|
4235
|
-
b.start("Initializing git repository..."), await
|
|
4261
|
+
b.start("Initializing git repository..."), await Pa(u), b.stop(L.success("Git repository initialized with clean history"));
|
|
4236
4262
|
let x = o.spinner();
|
|
4237
4263
|
x.start("Creating .env files from examples...");
|
|
4238
|
-
let S = await
|
|
4264
|
+
let S = await Aa(u);
|
|
4239
4265
|
if (S.length > 0) {
|
|
4240
4266
|
let e = S.length;
|
|
4241
|
-
x.stop(
|
|
4242
|
-
} else x.stop(
|
|
4243
|
-
o.log.success(`${
|
|
4244
|
-
let C = w.relative(process.cwd(), u) || ".", T = [`${
|
|
4245
|
-
S.length > 0 ? T.push(`Review your ${
|
|
4246
|
-
let E = a.setup
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4267
|
+
x.stop(L.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4268
|
+
} else x.stop(L.muted("No .env.example files to copy"));
|
|
4269
|
+
o.log.success(`${L.brandBold("Hype Stack")} project ${L.highlight(c)} is ready!`);
|
|
4270
|
+
let C = w.relative(process.cwd(), u) || ".", T = [`${L.command(`cd ${C}`)}`];
|
|
4271
|
+
S.length > 0 ? T.push(`Review your ${L.path(".env")} files and fill in any secrets`) : T.push(`Copy ${L.path(".env.example")} to ${L.path(".env")} and configure`), Hi(T);
|
|
4272
|
+
let E = a.setup === !1;
|
|
4273
|
+
if (a.deferSetup) o.log.info(L.muted("Docker and migrations will run after your packs are installed."));
|
|
4274
|
+
else {
|
|
4275
|
+
let e = !E && (s || await o.confirm({
|
|
4276
|
+
message: "Would you like to start Docker services and run database migrations now?",
|
|
4277
|
+
initialValue: !0
|
|
4278
|
+
}));
|
|
4279
|
+
o.isCancel(e) && Z(), e ? await qi(u, s) : (o.log.info(L.muted("You can start services later:")), Hi([
|
|
4280
|
+
`${L.command("docker compose up -d")} ${L.muted("(in apps/backend - start Postgres, Valkey, RustFS)")}`,
|
|
4281
|
+
`${L.command("pnpm --filter @internal/backend migration:latest")} ${L.muted("(apply migrations)")}`,
|
|
4282
|
+
`${L.command("pnpm run generate")} ${L.muted("(generate Prisma client)")}`
|
|
4283
|
+
])), Hi([`${L.command("pnpm dev")} ${L.muted("(start frontend + backend)")}`]);
|
|
4284
|
+
}
|
|
4285
|
+
return await Za("project_create"), o.outro(L.muted("Happy building!")), u;
|
|
4255
4286
|
}
|
|
4256
4287
|
//#endregion
|
|
4257
4288
|
//#region src/commands/init.ts
|
|
4258
|
-
async function
|
|
4289
|
+
async function lo(e) {
|
|
4259
4290
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4260
|
-
if (n || (
|
|
4261
|
-
o.log.error(`This doesn't look like a Hype Stack project. ${
|
|
4291
|
+
if (n || (fa(), o.intro(L.brandBold("Initialize Hype Stack configuration"))), !await _r(t)) {
|
|
4292
|
+
o.log.error(`This doesn't look like a Hype Stack project. ${L.muted("Expected apps/ directory and package.json")}`), o.outro(L.muted(`Run ${L.command("npx @hype-stack/cli create")} to scaffold a new project.`));
|
|
4262
4293
|
return;
|
|
4263
4294
|
}
|
|
4264
|
-
if (await
|
|
4265
|
-
let e = await
|
|
4295
|
+
if (await fr(t)) {
|
|
4296
|
+
let e = await dr(t);
|
|
4266
4297
|
if (e && !n) {
|
|
4267
|
-
o.log.info(`Found existing ${
|
|
4298
|
+
o.log.info(`Found existing ${L.path("stack.json")} for project ${L.highlight(e.name)}`);
|
|
4268
4299
|
let t = await o.confirm({
|
|
4269
4300
|
message: "Overwrite existing configuration?",
|
|
4270
4301
|
initialValue: !1
|
|
4271
4302
|
});
|
|
4272
4303
|
if (o.isCancel(t) || !t) {
|
|
4273
|
-
o.outro(
|
|
4304
|
+
o.outro(L.muted("Keeping existing configuration."));
|
|
4274
4305
|
return;
|
|
4275
4306
|
}
|
|
4276
4307
|
}
|
|
4277
4308
|
}
|
|
4278
|
-
let r = await
|
|
4309
|
+
let r = await mr(t);
|
|
4279
4310
|
if (!n) {
|
|
4280
4311
|
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4281
4312
|
if (e.length > 0) {
|
|
4282
|
-
o.log.info(
|
|
4283
|
-
for (let [t, n] of e) o.log.message(` ${
|
|
4313
|
+
o.log.info(L.bold("Detected apps:"));
|
|
4314
|
+
for (let [t, n] of e) o.log.message(` ${R.arrow} ${L.highlight(t)} ${L.muted(`→ ${n}`)}`);
|
|
4284
4315
|
}
|
|
4285
4316
|
if (t.length > 0) {
|
|
4286
|
-
o.log.info(
|
|
4287
|
-
for (let [e, n] of t) o.log.message(` ${
|
|
4317
|
+
o.log.info(L.bold("Detected packages:"));
|
|
4318
|
+
for (let [e, n] of t) o.log.message(` ${R.arrow} ${L.highlight(e)} ${L.muted(`→ ${n}`)}`);
|
|
4288
4319
|
}
|
|
4289
4320
|
e.length === 0 && t.length === 0 && o.log.warn("No apps or packages detected in the workspace.");
|
|
4290
4321
|
}
|
|
4291
|
-
let i = (await
|
|
4322
|
+
let i = (await ir(w.join(t, "package.json")))?.name?.replace(/^@/, "").replace(/\/source$/, "") ?? "my-app", a = i;
|
|
4292
4323
|
if (!n) {
|
|
4293
4324
|
let e = await o.text({
|
|
4294
4325
|
message: "Project name for stack.json?",
|
|
@@ -4297,28 +4328,37 @@ async function ao(e) {
|
|
|
4297
4328
|
});
|
|
4298
4329
|
o.isCancel(e) && Z(), a = e;
|
|
4299
4330
|
}
|
|
4300
|
-
await
|
|
4331
|
+
await pr(t, gr(a, r)), n || (o.log.success(`${L.path("stack.json")} written successfully`), o.outro(L.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
|
|
4301
4332
|
}
|
|
4302
|
-
async function
|
|
4303
|
-
if (await
|
|
4304
|
-
|
|
4333
|
+
async function uo(e, t = {}) {
|
|
4334
|
+
if (await fr(e)) return {
|
|
4335
|
+
projectRoot: e,
|
|
4336
|
+
scaffolded: !1
|
|
4337
|
+
};
|
|
4338
|
+
let n = t.runInit ?? ((e) => lo({
|
|
4305
4339
|
cwd: e,
|
|
4306
4340
|
silent: !0
|
|
4307
|
-
})), r = t.runCreate ?? ((e) =>
|
|
4308
|
-
|
|
4309
|
-
|
|
4341
|
+
})), r = t.runCreate ?? ((e) => co({
|
|
4342
|
+
parentDirectory: e,
|
|
4343
|
+
deferSetup: !0
|
|
4344
|
+
}));
|
|
4345
|
+
if (await _r(e)) {
|
|
4346
|
+
o.log.warn(`No ${L.path("stack.json")} found in ${L.path(e)}.`);
|
|
4310
4347
|
let t = await o.confirm({
|
|
4311
|
-
message: `Create ${
|
|
4348
|
+
message: `Create ${L.path("stack.json")} now?`,
|
|
4312
4349
|
initialValue: !0
|
|
4313
4350
|
});
|
|
4314
4351
|
if (o.isCancel(t) || !t) return null;
|
|
4315
4352
|
await n(e);
|
|
4316
|
-
let r = await
|
|
4317
|
-
return r && o.log.success(`${
|
|
4353
|
+
let r = await fr(e);
|
|
4354
|
+
return r && o.log.success(`${L.path("stack.json")} created`), r ? {
|
|
4355
|
+
projectRoot: e,
|
|
4356
|
+
scaffolded: !1
|
|
4357
|
+
} : null;
|
|
4318
4358
|
}
|
|
4319
|
-
o.log.warn(`This doesn't look like a Hype Stack project, and there's no ${
|
|
4359
|
+
o.log.warn(`This doesn't look like a Hype Stack project, and there's no ${L.path("stack.json")} here.`);
|
|
4320
4360
|
let i = await o.confirm({
|
|
4321
|
-
message: `Is ${
|
|
4361
|
+
message: `Is ${L.path(e)} where you want to work?`,
|
|
4322
4362
|
initialValue: !0
|
|
4323
4363
|
});
|
|
4324
4364
|
if (o.isCancel(i) || !i) return null;
|
|
@@ -4328,11 +4368,14 @@ async function oo(e, t = {}) {
|
|
|
4328
4368
|
});
|
|
4329
4369
|
if (o.isCancel(a) || !a) return null;
|
|
4330
4370
|
let s = await r(e);
|
|
4331
|
-
return await
|
|
4371
|
+
return await fr(s) ? {
|
|
4372
|
+
projectRoot: s,
|
|
4373
|
+
scaffolded: !0
|
|
4374
|
+
} : null;
|
|
4332
4375
|
}
|
|
4333
4376
|
//#endregion
|
|
4334
4377
|
//#region src/core/npm-deps.ts
|
|
4335
|
-
function
|
|
4378
|
+
function fo(e, t) {
|
|
4336
4379
|
let n = [], r = [];
|
|
4337
4380
|
if (!e) return {
|
|
4338
4381
|
errors: n,
|
|
@@ -4363,7 +4406,7 @@ function so(e, t) {
|
|
|
4363
4406
|
operations: r
|
|
4364
4407
|
};
|
|
4365
4408
|
}
|
|
4366
|
-
function
|
|
4409
|
+
function po(e) {
|
|
4367
4410
|
let t = {};
|
|
4368
4411
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4369
4412
|
...t[e],
|
|
@@ -4371,11 +4414,11 @@ function co(e) {
|
|
|
4371
4414
|
};
|
|
4372
4415
|
return t;
|
|
4373
4416
|
}
|
|
4374
|
-
async function
|
|
4417
|
+
async function mo(e, t, n = J) {
|
|
4375
4418
|
let r = [];
|
|
4376
4419
|
for (let i of e) {
|
|
4377
4420
|
let e = w.join(t, i.relativeDir);
|
|
4378
|
-
if (!await
|
|
4421
|
+
if (!await Y(w.join(e, "package.json"))) {
|
|
4379
4422
|
r.push(`Cannot install npm dependencies under "${i.relativeDir}": package.json not found.`);
|
|
4380
4423
|
continue;
|
|
4381
4424
|
}
|
|
@@ -4407,25 +4450,25 @@ async function lo(e, t, n = q) {
|
|
|
4407
4450
|
function $(e) {
|
|
4408
4451
|
return e instanceof Error ? e.message : String(e);
|
|
4409
4452
|
}
|
|
4410
|
-
async function
|
|
4453
|
+
async function ho(e, t, n) {
|
|
4411
4454
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4412
|
-
return r.length === 0 ? {} :
|
|
4455
|
+
return r.length === 0 ? {} : wr(r, n).catch(() => ({}));
|
|
4413
4456
|
}
|
|
4414
|
-
function
|
|
4415
|
-
return e === "free" ?
|
|
4457
|
+
function go(e, t) {
|
|
4458
|
+
return e === "free" ? L.success("free") : e === "owned" ? L.accent("owned") : `${L.highlight(`$${t}`)} ${L.muted("locked")}`;
|
|
4416
4459
|
}
|
|
4417
|
-
async function
|
|
4460
|
+
async function _o(e, t, n) {
|
|
4418
4461
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4419
|
-
i.length > 0 && o.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await
|
|
4462
|
+
i.length > 0 && o.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await tr(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4420
4463
|
name: e.name,
|
|
4421
4464
|
displayName: e.displayName,
|
|
4422
4465
|
price: e.price
|
|
4423
4466
|
})));
|
|
4424
4467
|
}
|
|
4425
|
-
function
|
|
4468
|
+
function vo(e, t) {
|
|
4426
4469
|
let n = e.map((e, n) => {
|
|
4427
4470
|
let r = t.get(e), i = r ? r.displayName : e;
|
|
4428
|
-
return ` ${
|
|
4471
|
+
return ` ${L.muted(`${n + 1}.`)} ${L.brand(i)}`;
|
|
4429
4472
|
});
|
|
4430
4473
|
o.note([
|
|
4431
4474
|
"These packs will be installed, in order:",
|
|
@@ -4433,10 +4476,10 @@ function mo(e, t) {
|
|
|
4433
4476
|
...n
|
|
4434
4477
|
].join("\n"), "Install Plan");
|
|
4435
4478
|
}
|
|
4436
|
-
async function
|
|
4479
|
+
async function yo(e, t) {
|
|
4437
4480
|
let n = [];
|
|
4438
4481
|
for (let r of e) {
|
|
4439
|
-
let e = await
|
|
4482
|
+
let e = await vr(r), i = await yr(r, t);
|
|
4440
4483
|
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'npx @hype-stack/cli login' or check your license.`);
|
|
4441
4484
|
n.push({
|
|
4442
4485
|
manifest: e,
|
|
@@ -4445,36 +4488,36 @@ async function ho(e, t) {
|
|
|
4445
4488
|
}
|
|
4446
4489
|
return n;
|
|
4447
4490
|
}
|
|
4448
|
-
async function
|
|
4449
|
-
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a =
|
|
4491
|
+
async function bo(e) {
|
|
4492
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = fo(po(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4450
4493
|
if (a.errors.length > 0) {
|
|
4451
4494
|
for (let e of a.errors) o.log.error(e);
|
|
4452
4495
|
return;
|
|
4453
4496
|
}
|
|
4454
4497
|
if (a.operations.length === 0) return;
|
|
4455
4498
|
i.start("Installing npm dependencies...");
|
|
4456
|
-
let s = await
|
|
4499
|
+
let s = await mo(a.operations, r);
|
|
4457
4500
|
if (i.stop(s.ok ? "npm dependencies installed" : "npm dependency installation failed"), !s.ok) for (let e of s.errors) o.log.error(e);
|
|
4458
4501
|
}
|
|
4459
|
-
function
|
|
4502
|
+
function xo(e) {
|
|
4460
4503
|
let t = e.flatMap((e) => e.manifest.postInstall ?? []), n = [...new Set(t)];
|
|
4461
|
-
n.length !== 0 && o.note(n.map((e) => ` ${
|
|
4504
|
+
n.length !== 0 && o.note(n.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Next Steps");
|
|
4462
4505
|
}
|
|
4463
|
-
async function
|
|
4506
|
+
async function So(e) {
|
|
4464
4507
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: s } = e, c = /* @__PURE__ */ new Set();
|
|
4465
4508
|
if (i) return c;
|
|
4466
|
-
let l = await
|
|
4509
|
+
let l = await Ai({
|
|
4467
4510
|
packs: t,
|
|
4468
4511
|
config: n,
|
|
4469
4512
|
projectRoot: r,
|
|
4470
4513
|
slotsByPack: s
|
|
4471
4514
|
});
|
|
4472
4515
|
if (l.length === 0) return c;
|
|
4473
|
-
if (a) return o.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${
|
|
4516
|
+
if (a) return o.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${L.command("--force")} to overwrite.`), c;
|
|
4474
4517
|
o.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4475
4518
|
for (let e of l) {
|
|
4476
4519
|
let t = w.relative(r, e.targetPath) || e.target, n = await o.confirm({
|
|
4477
|
-
message: `Overwrite ${
|
|
4520
|
+
message: `Overwrite ${L.path(t)}? ${L.muted(`(${e.packName})`)}`,
|
|
4478
4521
|
initialValue: !1
|
|
4479
4522
|
});
|
|
4480
4523
|
o.isCancel(n) && (o.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
|
|
@@ -4483,152 +4526,152 @@ async function vo(e) {
|
|
|
4483
4526
|
}
|
|
4484
4527
|
//#endregion
|
|
4485
4528
|
//#region src/commands/compose.ts
|
|
4486
|
-
async function
|
|
4529
|
+
async function Co(e = {}) {
|
|
4487
4530
|
let t = e.cwd ?? process.cwd();
|
|
4488
|
-
|
|
4489
|
-
let n = await
|
|
4531
|
+
fa();
|
|
4532
|
+
let n = await uo(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4490
4533
|
try {
|
|
4491
|
-
|
|
4534
|
+
a = await dr(r ?? t);
|
|
4492
4535
|
} catch (e) {
|
|
4493
|
-
o.cancel(`Could not parse ${
|
|
4536
|
+
o.cancel(`Could not parse ${L.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4494
4537
|
}
|
|
4495
|
-
|
|
4496
|
-
let
|
|
4497
|
-
o.intro(
|
|
4498
|
-
let
|
|
4499
|
-
|
|
4500
|
-
let
|
|
4538
|
+
a || (o.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 || (o.cancel(`${L.path("stack.json")} is missing ${L.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
4539
|
+
let s = r ?? t;
|
|
4540
|
+
o.intro(L.brandBold("Compose your stack"));
|
|
4541
|
+
let c = o.spinner();
|
|
4542
|
+
c.start("Loading packs...");
|
|
4543
|
+
let l;
|
|
4501
4544
|
try {
|
|
4502
|
-
|
|
4545
|
+
l = await Cr();
|
|
4503
4546
|
} catch (e) {
|
|
4504
|
-
|
|
4505
|
-
}
|
|
4506
|
-
|
|
4507
|
-
let
|
|
4508
|
-
token:
|
|
4509
|
-
key:
|
|
4510
|
-
}),
|
|
4511
|
-
let t =
|
|
4512
|
-
return !t || t.tier === "free" ? "free" :
|
|
4513
|
-
},
|
|
4514
|
-
packs:
|
|
4515
|
-
installedSet:
|
|
4516
|
-
stateOf:
|
|
4547
|
+
c.stop("Failed to load packs"), o.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4548
|
+
}
|
|
4549
|
+
c.stop("Packs loaded");
|
|
4550
|
+
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 Wn(N()))?.token ?? null, h = await ho(l, d, {
|
|
4551
|
+
token: m,
|
|
4552
|
+
key: p
|
|
4553
|
+
}), g = (e) => {
|
|
4554
|
+
let t = f.get(e);
|
|
4555
|
+
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4556
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", y = await wo({
|
|
4557
|
+
packs: l,
|
|
4558
|
+
installedSet: d,
|
|
4559
|
+
stateOf: g,
|
|
4517
4560
|
options: e,
|
|
4518
|
-
adminAvailable: !!
|
|
4561
|
+
adminAvailable: !!a.apps.admin
|
|
4519
4562
|
});
|
|
4520
|
-
if (
|
|
4521
|
-
o.outro(
|
|
4563
|
+
if (y === null && (o.cancel("Cancelled."), process.exit(0)), y.length === 0) {
|
|
4564
|
+
o.outro(L.muted("No packs selected. Nothing to do."));
|
|
4522
4565
|
return;
|
|
4523
4566
|
}
|
|
4524
|
-
let
|
|
4567
|
+
let b = Do(y), x = Oo(y), S = ta(l, b), C = Ji(na(l, S)), w;
|
|
4525
4568
|
try {
|
|
4526
|
-
|
|
4569
|
+
w = Xi(b, C, u);
|
|
4527
4570
|
} catch (e) {
|
|
4528
4571
|
o.cancel($(e)), process.exit(1);
|
|
4529
4572
|
}
|
|
4530
|
-
if (
|
|
4531
|
-
o.note(`${
|
|
4573
|
+
if (w.order.length === 0) {
|
|
4574
|
+
o.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), o.outro(L.muted("Your selection is already part of the project."));
|
|
4532
4575
|
return;
|
|
4533
4576
|
}
|
|
4534
|
-
let
|
|
4535
|
-
order:
|
|
4536
|
-
graph:
|
|
4537
|
-
isLocked:
|
|
4538
|
-
installed:
|
|
4577
|
+
let T = Zi({
|
|
4578
|
+
order: w.order,
|
|
4579
|
+
graph: C,
|
|
4580
|
+
isLocked: _,
|
|
4581
|
+
installed: u
|
|
4539
4582
|
});
|
|
4540
|
-
if (
|
|
4541
|
-
let e = await
|
|
4542
|
-
e && (
|
|
4543
|
-
token:
|
|
4544
|
-
key:
|
|
4545
|
-
}),
|
|
4546
|
-
order:
|
|
4547
|
-
graph:
|
|
4548
|
-
isLocked:
|
|
4549
|
-
installed:
|
|
4583
|
+
if (T.blocked.length > 0 && !m && !p) {
|
|
4584
|
+
let e = await er();
|
|
4585
|
+
e && (m = e, h = await ho(l, d, {
|
|
4586
|
+
token: m,
|
|
4587
|
+
key: p
|
|
4588
|
+
}), T = Zi({
|
|
4589
|
+
order: w.order,
|
|
4590
|
+
graph: C,
|
|
4591
|
+
isLocked: _,
|
|
4592
|
+
installed: u
|
|
4550
4593
|
}));
|
|
4551
4594
|
}
|
|
4552
|
-
if (
|
|
4553
|
-
o.outro(
|
|
4595
|
+
if (T.blocked.length > 0 && await _o(T.blocked, _, f), T.installable.length === 0) {
|
|
4596
|
+
o.outro(L.muted("Nothing left to install once locked packs are removed."));
|
|
4554
4597
|
return;
|
|
4555
4598
|
}
|
|
4556
|
-
if (
|
|
4557
|
-
let e = await o.confirm({ message: `Install ${
|
|
4599
|
+
if (vo(T.installable, f), !e.yes) {
|
|
4600
|
+
let e = await o.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4558
4601
|
(o.isCancel(e) || !e) && (o.cancel("Installation cancelled."), process.exit(0));
|
|
4559
4602
|
}
|
|
4560
|
-
|
|
4561
|
-
let
|
|
4603
|
+
c.start("Downloading packs...");
|
|
4604
|
+
let E;
|
|
4562
4605
|
try {
|
|
4563
|
-
|
|
4564
|
-
token:
|
|
4565
|
-
key:
|
|
4606
|
+
E = await yo(T.installable, {
|
|
4607
|
+
token: m,
|
|
4608
|
+
key: p
|
|
4566
4609
|
});
|
|
4567
4610
|
} catch (e) {
|
|
4568
|
-
|
|
4611
|
+
c.stop("Download failed"), o.cancel($(e)), process.exit(1);
|
|
4569
4612
|
}
|
|
4570
|
-
|
|
4571
|
-
let
|
|
4572
|
-
prepared:
|
|
4573
|
-
config:
|
|
4574
|
-
cwd:
|
|
4613
|
+
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4614
|
+
let D = await So({
|
|
4615
|
+
prepared: E,
|
|
4616
|
+
config: a,
|
|
4617
|
+
cwd: s,
|
|
4575
4618
|
force: e.force ?? !1,
|
|
4576
4619
|
yes: e.yes ?? !1,
|
|
4577
|
-
slotsByPack:
|
|
4620
|
+
slotsByPack: x
|
|
4578
4621
|
});
|
|
4579
4622
|
try {
|
|
4580
|
-
|
|
4581
|
-
let t = await
|
|
4582
|
-
packs:
|
|
4583
|
-
config:
|
|
4584
|
-
projectRoot:
|
|
4623
|
+
c.start("Installing pack files...");
|
|
4624
|
+
let t = await Ni({
|
|
4625
|
+
packs: E,
|
|
4626
|
+
config: a,
|
|
4627
|
+
projectRoot: s,
|
|
4585
4628
|
force: e.force ?? !1,
|
|
4586
|
-
overwrite:
|
|
4587
|
-
slotsByPack:
|
|
4629
|
+
overwrite: D,
|
|
4630
|
+
slotsByPack: x
|
|
4588
4631
|
});
|
|
4589
4632
|
if (t.aborted) {
|
|
4590
|
-
|
|
4633
|
+
c.stop("Installation aborted");
|
|
4591
4634
|
for (let e of t.errors) o.log.error(e);
|
|
4592
4635
|
o.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4593
4636
|
}
|
|
4594
|
-
|
|
4637
|
+
c.stop("Files installed"), t.installed.length > 0 && o.log.success(`${L.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && o.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`);
|
|
4595
4638
|
for (let e of t.errors) o.log.error(e);
|
|
4596
|
-
await
|
|
4597
|
-
prepared:
|
|
4598
|
-
paths:
|
|
4599
|
-
cwd:
|
|
4600
|
-
spinner:
|
|
4601
|
-
}), await
|
|
4602
|
-
projectRoot:
|
|
4603
|
-
paths:
|
|
4639
|
+
await bo({
|
|
4640
|
+
prepared: E,
|
|
4641
|
+
paths: a.paths,
|
|
4642
|
+
cwd: s,
|
|
4643
|
+
spinner: c
|
|
4644
|
+
}), i && await qi(s, e.yes ?? !1), await ur({
|
|
4645
|
+
projectRoot: s,
|
|
4646
|
+
paths: a.paths,
|
|
4604
4647
|
skipPrompts: e.yes ?? !1
|
|
4605
|
-
}),
|
|
4648
|
+
}), xo(E), o.outro(L.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4606
4649
|
} finally {
|
|
4607
|
-
await Promise.all(
|
|
4650
|
+
await Promise.all(E.map((e) => v.rm(e.packDir, {
|
|
4608
4651
|
recursive: !0,
|
|
4609
4652
|
force: !0
|
|
4610
4653
|
})));
|
|
4611
4654
|
}
|
|
4612
4655
|
}
|
|
4613
|
-
async function
|
|
4656
|
+
async function wo(e) {
|
|
4614
4657
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4615
4658
|
if (i.packs && i.packs.length > 0) {
|
|
4616
|
-
let e = i.packs.map(
|
|
4659
|
+
let e = i.packs.map(Eo), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4617
4660
|
return n.length > 0 && (o.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4618
4661
|
}
|
|
4619
4662
|
let s = t.filter((e) => n.has(e.name));
|
|
4620
|
-
s.length > 0 && o.note(s.map((e) => ` ${
|
|
4663
|
+
s.length > 0 && o.note(s.map((e) => ` ${L.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4621
4664
|
let c = t.filter((e) => !n.has(e.name));
|
|
4622
|
-
if (c.length === 0) return o.outro(
|
|
4623
|
-
let l =
|
|
4624
|
-
o.note(c.map((e) => ` ${
|
|
4625
|
-
let u =
|
|
4665
|
+
if (c.length === 0) return o.outro(L.muted("Every available pack is already installed.")), [];
|
|
4666
|
+
let l = P();
|
|
4667
|
+
o.note(c.map((e) => ` ${R.arrow} ${L.highlight(e.displayName)} ${_e(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4668
|
+
let u = Bi(c, { adminAvailable: a }), d = [];
|
|
4626
4669
|
for (let e of u) {
|
|
4627
4670
|
let t = e.packs.map((e) => {
|
|
4628
4671
|
let t = r(e.name);
|
|
4629
4672
|
return {
|
|
4630
4673
|
value: e.name,
|
|
4631
|
-
label: `${e.displayName} ${
|
|
4674
|
+
label: `${e.displayName} ${go(t, e.price)}`,
|
|
4632
4675
|
hint: e.description
|
|
4633
4676
|
};
|
|
4634
4677
|
});
|
|
@@ -4645,7 +4688,7 @@ async function bo(e) {
|
|
|
4645
4688
|
});
|
|
4646
4689
|
continue;
|
|
4647
4690
|
}
|
|
4648
|
-
let n = await
|
|
4691
|
+
let n = await ma({
|
|
4649
4692
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4650
4693
|
options: t,
|
|
4651
4694
|
required: !1
|
|
@@ -4655,20 +4698,20 @@ async function bo(e) {
|
|
|
4655
4698
|
}
|
|
4656
4699
|
return d;
|
|
4657
4700
|
}
|
|
4658
|
-
var
|
|
4659
|
-
function
|
|
4660
|
-
let t = e.match(
|
|
4701
|
+
var To = /@(frontend|admin)$/;
|
|
4702
|
+
function Eo(e) {
|
|
4703
|
+
let t = e.match(To);
|
|
4661
4704
|
return t ? {
|
|
4662
4705
|
name: e.slice(0, -t[0].length),
|
|
4663
4706
|
slot: t[1]
|
|
4664
4707
|
} : { name: e };
|
|
4665
4708
|
}
|
|
4666
|
-
function
|
|
4709
|
+
function Do(e) {
|
|
4667
4710
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4668
4711
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4669
4712
|
return n;
|
|
4670
4713
|
}
|
|
4671
|
-
function
|
|
4714
|
+
function Oo(e) {
|
|
4672
4715
|
let t = /* @__PURE__ */ new Map();
|
|
4673
4716
|
for (let n of e) {
|
|
4674
4717
|
if (!n.slot) continue;
|
|
@@ -4679,42 +4722,42 @@ function wo(e) {
|
|
|
4679
4722
|
}
|
|
4680
4723
|
//#endregion
|
|
4681
4724
|
//#region src/commands/login.ts
|
|
4682
|
-
async function
|
|
4683
|
-
|
|
4725
|
+
async function ko() {
|
|
4726
|
+
fa(), o.intro(L.brandBold("Log in to Hype Stack")), o.log.step("Opening your browser to sign in...");
|
|
4684
4727
|
let e;
|
|
4685
4728
|
try {
|
|
4686
|
-
e = await
|
|
4687
|
-
o.log.info(`If your browser didn't open, visit:\n ${
|
|
4729
|
+
e = await $n({ onUrl: (e) => {
|
|
4730
|
+
o.log.info(`If your browser didn't open, visit:\n ${L.path(e)}`);
|
|
4688
4731
|
} });
|
|
4689
4732
|
} catch (e) {
|
|
4690
4733
|
o.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
|
|
4691
4734
|
}
|
|
4692
|
-
o.outro(
|
|
4735
|
+
o.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."));
|
|
4693
4736
|
}
|
|
4694
4737
|
//#endregion
|
|
4695
4738
|
//#region src/commands/logout.ts
|
|
4696
|
-
async function
|
|
4697
|
-
|
|
4698
|
-
let e =
|
|
4739
|
+
async function Ao() {
|
|
4740
|
+
fa(), o.intro(L.brandBold("Log out of Hype Stack"));
|
|
4741
|
+
let e = N(), t = await Wn(e);
|
|
4699
4742
|
if (!t) {
|
|
4700
|
-
o.outro(
|
|
4743
|
+
o.outro(L.muted("You're not logged in."));
|
|
4701
4744
|
return;
|
|
4702
4745
|
}
|
|
4703
|
-
await
|
|
4746
|
+
await In(t.token).catch(() => null), await Kn(e), o.outro(L.brand("Logged out."));
|
|
4704
4747
|
}
|
|
4705
4748
|
//#endregion
|
|
4706
4749
|
//#region src/core/templates.ts
|
|
4707
|
-
var
|
|
4750
|
+
var jo = q.createRequest()({
|
|
4708
4751
|
endpoint: "/templates/list",
|
|
4709
4752
|
method: "GET"
|
|
4710
4753
|
});
|
|
4711
|
-
async function
|
|
4712
|
-
let { data: e, error: t } = await
|
|
4754
|
+
async function Mo() {
|
|
4755
|
+
let { data: e, error: t } = await jo.send();
|
|
4713
4756
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
4714
4757
|
return e.templates;
|
|
4715
4758
|
}
|
|
4716
|
-
async function
|
|
4717
|
-
let { data: t, error: n, status: r } = await
|
|
4759
|
+
async function No(e) {
|
|
4760
|
+
let { data: t, error: n, status: r } = await q.createRequest()({
|
|
4718
4761
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
4719
4762
|
method: "GET"
|
|
4720
4763
|
}).send();
|
|
@@ -4722,13 +4765,13 @@ async function ko(e) {
|
|
|
4722
4765
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
4723
4766
|
return t;
|
|
4724
4767
|
}
|
|
4725
|
-
async function
|
|
4726
|
-
let n =
|
|
4768
|
+
async function Po(e, t = {}) {
|
|
4769
|
+
let n = q.createRequest()({
|
|
4727
4770
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
4728
4771
|
method: "POST"
|
|
4729
4772
|
}), r = {
|
|
4730
|
-
"X-Device-Id":
|
|
4731
|
-
"X-Client-Info":
|
|
4773
|
+
"X-Device-Id": Jn(),
|
|
4774
|
+
"X-Client-Info": Yn()
|
|
4732
4775
|
};
|
|
4733
4776
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
4734
4777
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -4750,172 +4793,172 @@ async function Ao(e, t = {}) {
|
|
|
4750
4793
|
}
|
|
4751
4794
|
//#endregion
|
|
4752
4795
|
//#region src/commands/template.ts
|
|
4753
|
-
async function
|
|
4796
|
+
async function Fo(e = {}) {
|
|
4754
4797
|
let t = e.cwd ?? process.cwd();
|
|
4755
|
-
|
|
4756
|
-
let n = await
|
|
4798
|
+
fa();
|
|
4799
|
+
let n = await uo(t), a = n?.projectRoot ?? null, s = n?.scaffolded ?? !1, c;
|
|
4757
4800
|
try {
|
|
4758
|
-
|
|
4801
|
+
c = await dr(a ?? t);
|
|
4759
4802
|
} catch (e) {
|
|
4760
|
-
o.cancel(`Could not parse ${
|
|
4803
|
+
o.cancel(`Could not parse ${L.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4761
4804
|
}
|
|
4762
|
-
|
|
4763
|
-
let
|
|
4764
|
-
o.intro(
|
|
4765
|
-
let
|
|
4766
|
-
|
|
4767
|
-
let
|
|
4805
|
+
c || (o.cancel(a ? `Could not read ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${L.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), process.exit(1)), c.paths || (o.cancel(`${L.path("stack.json")} is missing ${L.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
4806
|
+
let l = a ?? t;
|
|
4807
|
+
o.intro(L.brandBold("Install a template"));
|
|
4808
|
+
let u = o.spinner();
|
|
4809
|
+
u.start("Loading packs...");
|
|
4810
|
+
let d;
|
|
4768
4811
|
try {
|
|
4769
|
-
|
|
4812
|
+
d = await Cr();
|
|
4770
4813
|
} catch (e) {
|
|
4771
|
-
|
|
4814
|
+
u.stop("Failed to load packs"), o.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4772
4815
|
}
|
|
4773
|
-
|
|
4774
|
-
let
|
|
4775
|
-
|
|
4776
|
-
let
|
|
4816
|
+
u.stop("Packs loaded");
|
|
4817
|
+
let f = c.installedPacks ?? [], p = new Set(f), m = new Map(d.map((e) => [e.name, e])), h = e.licenseKey ?? c.licenseKey ?? null, g = (await Wn(N()))?.token ?? null;
|
|
4818
|
+
u.start("Loading templates...");
|
|
4819
|
+
let _;
|
|
4777
4820
|
try {
|
|
4778
|
-
|
|
4821
|
+
_ = await Mo();
|
|
4779
4822
|
} catch (e) {
|
|
4780
|
-
|
|
4823
|
+
u.stop("Failed to load templates"), o.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4781
4824
|
}
|
|
4782
|
-
let
|
|
4783
|
-
if (!
|
|
4784
|
-
e.yes && (
|
|
4785
|
-
let t =
|
|
4786
|
-
o.note(
|
|
4825
|
+
let y = e.templateId;
|
|
4826
|
+
if (!y) {
|
|
4827
|
+
e.yes && (u.stop("Template id required"), o.cancel("Pass a template id with `npx @hype-stack/cli template <id>` (required in --yes mode)."), process.exit(1)), _.length === 0 && (u.stop("No templates available"), o.cancel("No templates are available yet. Check back later."), process.exit(1)), u.stop("Templates loaded");
|
|
4828
|
+
let t = P();
|
|
4829
|
+
o.note(_.map((e) => ` ${R.arrow} ${L.highlight(e.name)} ${_e(`${t}/templates/${e.id}`)}`).join("\n"), "Browse templates");
|
|
4787
4830
|
let n = await o.select({
|
|
4788
4831
|
message: "Choose a template",
|
|
4789
|
-
options:
|
|
4832
|
+
options: _.map((e) => ({
|
|
4790
4833
|
value: e.id,
|
|
4791
4834
|
label: e.name,
|
|
4792
4835
|
hint: e.description
|
|
4793
4836
|
}))
|
|
4794
4837
|
});
|
|
4795
|
-
o.isCancel(n) && (o.cancel("Cancelled."), process.exit(0)),
|
|
4796
|
-
}
|
|
4797
|
-
let
|
|
4798
|
-
|
|
4799
|
-
let
|
|
4800
|
-
packs:
|
|
4801
|
-
templatePacks:
|
|
4802
|
-
installedSet:
|
|
4838
|
+
o.isCancel(n) && (o.cancel("Cancelled."), process.exit(0)), y = n;
|
|
4839
|
+
}
|
|
4840
|
+
let b = _.find((e) => e.id === y);
|
|
4841
|
+
b || (u.stop("Template not found"), o.cancel(`Template "${y}" not found. Available: ${_.map((e) => e.id).join(", ") || "(none)"}`), process.exit(1)), u.stop(`Template: ${b.name}`);
|
|
4842
|
+
let x = await Io(b, e.variants, e.yes ?? !1), S = Qi(b.slots, x), C = $i(b.slots, b.packs, S), T = await Lo({
|
|
4843
|
+
packs: d,
|
|
4844
|
+
templatePacks: C,
|
|
4845
|
+
installedSet: p,
|
|
4803
4846
|
options: e
|
|
4804
|
-
}),
|
|
4805
|
-
|
|
4806
|
-
let
|
|
4847
|
+
}), E = [...C, ...T.filter((e) => !C.includes(e))], D = E.filter((e) => !m.has(e));
|
|
4848
|
+
D.length > 0 && (o.cancel(`Unknown pack${D.length === 1 ? "" : "s"}: ${D.join(", ")}`), process.exit(1));
|
|
4849
|
+
let O = na(d, S), ee = Ji(O), k;
|
|
4807
4850
|
try {
|
|
4808
|
-
|
|
4851
|
+
k = Xi(E, ee, f);
|
|
4809
4852
|
} catch (e) {
|
|
4810
4853
|
o.cancel($(e)), process.exit(1);
|
|
4811
4854
|
}
|
|
4812
|
-
if (
|
|
4813
|
-
o.outro(
|
|
4855
|
+
if (k.order.length === 0) {
|
|
4856
|
+
o.outro(L.muted("Every pack in this template is already installed."));
|
|
4814
4857
|
return;
|
|
4815
4858
|
}
|
|
4816
|
-
let
|
|
4817
|
-
token:
|
|
4818
|
-
key:
|
|
4819
|
-
}),
|
|
4820
|
-
let t =
|
|
4821
|
-
return !t || t.tier === "free" ? "free" :
|
|
4822
|
-
},
|
|
4823
|
-
order:
|
|
4824
|
-
graph:
|
|
4825
|
-
isLocked:
|
|
4826
|
-
installed:
|
|
4859
|
+
let te = await ho(O, p, {
|
|
4860
|
+
token: g,
|
|
4861
|
+
key: h
|
|
4862
|
+
}), ne = (e) => {
|
|
4863
|
+
let t = m.get(e);
|
|
4864
|
+
return !t || t.tier === "free" ? "free" : te[e]?.owned ? "owned" : "locked";
|
|
4865
|
+
}, re = (e) => !p.has(e) && ne(e) === "locked", A = Zi({
|
|
4866
|
+
order: k.order,
|
|
4867
|
+
graph: ee,
|
|
4868
|
+
isLocked: re,
|
|
4869
|
+
installed: f
|
|
4827
4870
|
});
|
|
4828
|
-
if (
|
|
4829
|
-
let e = await
|
|
4830
|
-
e && (
|
|
4831
|
-
token:
|
|
4832
|
-
key:
|
|
4833
|
-
}),
|
|
4834
|
-
order:
|
|
4835
|
-
graph:
|
|
4836
|
-
isLocked:
|
|
4837
|
-
installed:
|
|
4871
|
+
if (A.blocked.length > 0 && !g && !h) {
|
|
4872
|
+
let e = await er();
|
|
4873
|
+
e && (g = e, te = await ho(O, p, {
|
|
4874
|
+
token: g,
|
|
4875
|
+
key: h
|
|
4876
|
+
}), A = Zi({
|
|
4877
|
+
order: k.order,
|
|
4878
|
+
graph: ee,
|
|
4879
|
+
isLocked: re,
|
|
4880
|
+
installed: f
|
|
4838
4881
|
}));
|
|
4839
4882
|
}
|
|
4840
|
-
if (
|
|
4841
|
-
o.outro(
|
|
4883
|
+
if (A.blocked.length > 0 && await _o(A.blocked, re, m), A.installable.length === 0) {
|
|
4884
|
+
o.outro(L.muted("Nothing left to install once locked packs are removed."));
|
|
4842
4885
|
return;
|
|
4843
4886
|
}
|
|
4844
|
-
if (
|
|
4845
|
-
let e = await o.confirm({ message: `Install template ${
|
|
4887
|
+
if (vo(A.installable, m), !e.yes) {
|
|
4888
|
+
let e = await o.confirm({ message: `Install template ${L.brandBold(b.name)} (${A.installable.length} pack${A.installable.length === 1 ? "" : "s"})?` });
|
|
4846
4889
|
(o.isCancel(e) || !e) && (o.cancel("Installation cancelled."), process.exit(0));
|
|
4847
4890
|
}
|
|
4848
|
-
|
|
4849
|
-
let
|
|
4891
|
+
u.start("Downloading packs...");
|
|
4892
|
+
let j;
|
|
4850
4893
|
try {
|
|
4851
|
-
|
|
4852
|
-
token:
|
|
4853
|
-
key:
|
|
4894
|
+
j = await yo(A.installable, {
|
|
4895
|
+
token: g,
|
|
4896
|
+
key: h
|
|
4854
4897
|
});
|
|
4855
4898
|
} catch (e) {
|
|
4856
|
-
|
|
4899
|
+
u.stop("Download failed"), o.cancel($(e)), process.exit(1);
|
|
4857
4900
|
}
|
|
4858
|
-
|
|
4859
|
-
let
|
|
4860
|
-
prepared:
|
|
4861
|
-
config:
|
|
4862
|
-
cwd:
|
|
4901
|
+
u.stop(`Downloaded ${j.length} pack${j.length === 1 ? "" : "s"}`);
|
|
4902
|
+
let ie = await So({
|
|
4903
|
+
prepared: j,
|
|
4904
|
+
config: c,
|
|
4905
|
+
cwd: l,
|
|
4863
4906
|
force: e.force ?? !1,
|
|
4864
4907
|
yes: e.yes ?? !1
|
|
4865
|
-
}),
|
|
4908
|
+
}), M = null;
|
|
4866
4909
|
try {
|
|
4867
|
-
|
|
4868
|
-
let t = await
|
|
4869
|
-
packs:
|
|
4870
|
-
config:
|
|
4871
|
-
projectRoot:
|
|
4910
|
+
u.start("Installing pack files...");
|
|
4911
|
+
let t = await Ni({
|
|
4912
|
+
packs: j,
|
|
4913
|
+
config: c,
|
|
4914
|
+
projectRoot: l,
|
|
4872
4915
|
force: e.force ?? !1,
|
|
4873
|
-
overwrite:
|
|
4916
|
+
overwrite: ie
|
|
4874
4917
|
});
|
|
4875
4918
|
if (t.aborted) {
|
|
4876
|
-
|
|
4919
|
+
u.stop("Installation aborted");
|
|
4877
4920
|
for (let e of t.errors) o.log.error(e);
|
|
4878
4921
|
o.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4879
4922
|
}
|
|
4880
|
-
|
|
4923
|
+
u.stop("Files installed"), t.installed.length > 0 && o.log.success(`${L.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && o.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`);
|
|
4881
4924
|
for (let e of t.errors) o.log.error(e);
|
|
4882
|
-
|
|
4883
|
-
let n = await
|
|
4884
|
-
token:
|
|
4885
|
-
licenseKey:
|
|
4925
|
+
u.start("Applying template overrides...");
|
|
4926
|
+
let n = await No(b.id), a = await Po(b.id, {
|
|
4927
|
+
token: g,
|
|
4928
|
+
licenseKey: h
|
|
4886
4929
|
});
|
|
4887
|
-
|
|
4888
|
-
let
|
|
4930
|
+
a.status === "denied" && (u.stop("Template download denied"), o.cancel(`Access to template "${b.id}" was denied (${a.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)), M = a.templateDir;
|
|
4931
|
+
let d = await Fi({
|
|
4889
4932
|
manifest: n,
|
|
4890
|
-
config:
|
|
4891
|
-
projectRoot:
|
|
4892
|
-
templateDir:
|
|
4933
|
+
config: c,
|
|
4934
|
+
projectRoot: l,
|
|
4935
|
+
templateDir: M
|
|
4893
4936
|
});
|
|
4894
|
-
|
|
4895
|
-
for (let e of
|
|
4896
|
-
let
|
|
4897
|
-
i(
|
|
4898
|
-
prepared:
|
|
4937
|
+
u.stop("Template overrides applied"), d.installed.length > 0 && o.log.success(`${d.installed.length} template file${d.installed.length === 1 ? "" : "s"} applied`);
|
|
4938
|
+
for (let e of d.errors) o.log.error(e);
|
|
4939
|
+
let f = n.theme ?? "zinc-mono";
|
|
4940
|
+
i(f) && (await ba(w.resolve(l, c.paths?.frontend.root ?? "apps/frontend"), r(f)) ? o.log.success(`Applied the ${r(f).label} theme`) : o.log.warning(L.muted(`Could not find ${L.path("assets/styles.css")} to apply the theme`))), await Ro({
|
|
4941
|
+
prepared: j,
|
|
4899
4942
|
templateNpm: n.dependencies_npm,
|
|
4900
|
-
paths:
|
|
4901
|
-
cwd:
|
|
4902
|
-
spinner:
|
|
4903
|
-
}), await
|
|
4904
|
-
projectRoot:
|
|
4905
|
-
paths:
|
|
4943
|
+
paths: c.paths,
|
|
4944
|
+
cwd: l,
|
|
4945
|
+
spinner: u
|
|
4946
|
+
}), s && await qi(l, e.yes ?? !1), await ur({
|
|
4947
|
+
projectRoot: l,
|
|
4948
|
+
paths: c.paths,
|
|
4906
4949
|
skipPrompts: e.yes ?? !1
|
|
4907
|
-
}),
|
|
4950
|
+
}), xo(j), n.postInstall && n.postInstall.length > 0 && o.note(n.postInstall.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Template Next Steps"), o.outro(L.brand(`Installed template ${b.name}.`));
|
|
4908
4951
|
} finally {
|
|
4909
|
-
await Promise.all(
|
|
4952
|
+
await Promise.all(j.map((e) => v.rm(e.packDir, {
|
|
4910
4953
|
recursive: !0,
|
|
4911
4954
|
force: !0
|
|
4912
|
-
}))),
|
|
4955
|
+
}))), M && await v.rm(M, {
|
|
4913
4956
|
recursive: !0,
|
|
4914
4957
|
force: !0
|
|
4915
4958
|
});
|
|
4916
4959
|
}
|
|
4917
4960
|
}
|
|
4918
|
-
async function
|
|
4961
|
+
async function Io(e, t, n) {
|
|
4919
4962
|
let r = {};
|
|
4920
4963
|
for (let i of e.slots) {
|
|
4921
4964
|
if (t?.[i.family]) {
|
|
@@ -4939,7 +4982,7 @@ async function Mo(e, t, n) {
|
|
|
4939
4982
|
}
|
|
4940
4983
|
return r;
|
|
4941
4984
|
}
|
|
4942
|
-
async function
|
|
4985
|
+
async function Lo(e) {
|
|
4943
4986
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
4944
4987
|
if (i.packs && i.packs.length > 0) {
|
|
4945
4988
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -4948,9 +4991,9 @@ async function No(e) {
|
|
|
4948
4991
|
if (i.yes) return [];
|
|
4949
4992
|
let s = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
|
|
4950
4993
|
if (s.length === 0) return [];
|
|
4951
|
-
let c =
|
|
4952
|
-
o.note(s.map((e) => ` ${
|
|
4953
|
-
let l = await
|
|
4994
|
+
let c = P();
|
|
4995
|
+
o.note(s.map((e) => ` ${R.arrow} ${L.highlight(e.displayName)} ${_e(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4996
|
+
let l = await ma({
|
|
4954
4997
|
message: "Add extra packs on top of the template (optional)",
|
|
4955
4998
|
options: s.map((e) => ({
|
|
4956
4999
|
value: e.name,
|
|
@@ -4961,25 +5004,25 @@ async function No(e) {
|
|
|
4961
5004
|
});
|
|
4962
5005
|
return p(l) && (o.cancel("Cancelled."), process.exit(0)), l;
|
|
4963
5006
|
}
|
|
4964
|
-
async function
|
|
4965
|
-
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, s =
|
|
5007
|
+
async function Ro(e) {
|
|
5008
|
+
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, s = po(t.map((e) => e.manifest.dependencies_npm)), c = fo(n ? po([s, n]) : s, r);
|
|
4966
5009
|
if (c.errors.length > 0) {
|
|
4967
5010
|
for (let e of c.errors) o.log.error(e);
|
|
4968
5011
|
return;
|
|
4969
5012
|
}
|
|
4970
5013
|
if (c.operations.length === 0) return;
|
|
4971
5014
|
a.start("Installing npm dependencies...");
|
|
4972
|
-
let l = await
|
|
5015
|
+
let l = await mo(c.operations, i);
|
|
4973
5016
|
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) o.log.error(e);
|
|
4974
5017
|
}
|
|
4975
5018
|
//#endregion
|
|
4976
5019
|
//#region src/cli.ts
|
|
4977
|
-
function
|
|
5020
|
+
function zo(e) {
|
|
4978
5021
|
if (!e) return;
|
|
4979
5022
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
4980
5023
|
return t.length > 0 ? t : void 0;
|
|
4981
5024
|
}
|
|
4982
|
-
function
|
|
5025
|
+
function Bo(e) {
|
|
4983
5026
|
if (!e) return;
|
|
4984
5027
|
let t = {};
|
|
4985
5028
|
for (let n of e.split(",")) {
|
|
@@ -4988,10 +5031,10 @@ function Io(e) {
|
|
|
4988
5031
|
}
|
|
4989
5032
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
4990
5033
|
}
|
|
4991
|
-
function
|
|
5034
|
+
function Vo() {
|
|
4992
5035
|
let e = new a();
|
|
4993
5036
|
return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(k, "-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) => {
|
|
4994
|
-
await
|
|
5037
|
+
await co({
|
|
4995
5038
|
name: e.name,
|
|
4996
5039
|
directory: e.directory,
|
|
4997
5040
|
install: e.install,
|
|
@@ -5001,32 +5044,32 @@ function Lo() {
|
|
|
5001
5044
|
setup: e.setup
|
|
5002
5045
|
});
|
|
5003
5046
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5004
|
-
await
|
|
5047
|
+
await lo({});
|
|
5005
5048
|
}), 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) => {
|
|
5006
|
-
await
|
|
5007
|
-
packs:
|
|
5049
|
+
await Co({
|
|
5050
|
+
packs: zo(e.packs),
|
|
5008
5051
|
force: e.force,
|
|
5009
5052
|
yes: e.yes,
|
|
5010
5053
|
licenseKey: e.key ?? e.licenseKey,
|
|
5011
5054
|
cwd: e.cwd
|
|
5012
5055
|
});
|
|
5013
5056
|
}), 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) => {
|
|
5014
|
-
await
|
|
5057
|
+
await Fo({
|
|
5015
5058
|
templateId: e,
|
|
5016
|
-
variants:
|
|
5017
|
-
packs:
|
|
5059
|
+
variants: Bo(t.variants),
|
|
5060
|
+
packs: zo(t.packs),
|
|
5018
5061
|
force: t.force,
|
|
5019
5062
|
yes: t.yes,
|
|
5020
5063
|
licenseKey: t.key ?? t.licenseKey,
|
|
5021
5064
|
cwd: t.cwd
|
|
5022
5065
|
});
|
|
5023
5066
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5024
|
-
await
|
|
5067
|
+
await ko();
|
|
5025
5068
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5026
|
-
await
|
|
5069
|
+
await Ao();
|
|
5027
5070
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5028
|
-
await
|
|
5071
|
+
await ko();
|
|
5029
5072
|
}), e;
|
|
5030
5073
|
}
|
|
5031
5074
|
//#endregion
|
|
5032
|
-
export {
|
|
5075
|
+
export { uo as a, Co as i, Ao as n, lo as o, ko as r, co as s, Vo as t };
|