@hype-stack/cli 0.5.5 → 0.5.6
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-DKFOY4GJ.js → cli-BOykXnFK.js} +790 -763
- package/dist/config/bin.js +1 -1
- package/dist/core/codegen.d.ts +10 -7
- package/dist/core/codegen.d.ts.map +1 -1
- package/dist/core/pack-categories.d.ts +5 -5
- package/dist/core/pack-categories.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import { Prompt as O } from "@clack/core";
|
|
|
13
13
|
import { styleText as k } from "node:util";
|
|
14
14
|
import { downloadTemplate as ee } from "giget";
|
|
15
15
|
//#region src/constants/constants.ts
|
|
16
|
-
var A = "0.5.
|
|
16
|
+
var A = "0.5.6", j = "gh:BetterTyped/hype-stack", te = "stack.json", ne = "/schema/stack.json", M = "https://api.hype-stack.dev", N = "HYPE_STACK_API_URL", P = "https://www.hype-stack.dev", re = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, F = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -31,109 +31,109 @@ var A = "0.5.5", j = "gh:BetterTyped/hype-stack", M = "stack.json", te = "/schem
|
|
|
31
31
|
value: "copilot",
|
|
32
32
|
label: "GitHub Copilot"
|
|
33
33
|
}
|
|
34
|
-
],
|
|
35
|
-
function
|
|
34
|
+
], ie = F.map((e) => e.value), ae = ".cursor/rules", oe = ".cursor", se = ".agents";
|
|
35
|
+
function I() {
|
|
36
36
|
let e = process.env.HYPE_STACK_API_URL;
|
|
37
|
-
return e ? (
|
|
37
|
+
return e ? (le(e), e.replace(/\/+$/, "")) : M;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function ce() {
|
|
40
40
|
let e = process.env.HYPE_STACK_WEB_URL;
|
|
41
|
-
return e ? (
|
|
41
|
+
return e ? (le(e), e.replace(/\/+$/, "")) : P;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function le(e) {
|
|
44
44
|
try {
|
|
45
45
|
let t = new URL(e);
|
|
46
|
-
if (!t.protocol.startsWith("http")) throw Error(`${
|
|
46
|
+
if (!t.protocol.startsWith("http")) throw Error(`${N} must use http or https protocol, got "${t.protocol}"`);
|
|
47
47
|
} catch (t) {
|
|
48
|
-
throw t instanceof TypeError ? Error(`${
|
|
48
|
+
throw t instanceof TypeError ? Error(`${N} is not a valid URL: "${e}"`, { cause: t }) : t;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return `${
|
|
51
|
+
function ue() {
|
|
52
|
+
return `${I()}${ne}`;
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/ui/theme.ts
|
|
56
|
-
var
|
|
57
|
-
orange:
|
|
58
|
-
orangeBright:
|
|
59
|
-
amber:
|
|
60
|
-
deepBlue:
|
|
61
|
-
skyBlue:
|
|
62
|
-
lightBlue:
|
|
63
|
-
},
|
|
64
|
-
brand: (e) =>
|
|
65
|
-
brandBold: (e) => b.bold(
|
|
66
|
-
accent: (e) =>
|
|
67
|
-
accentBold: (e) => b.bold(
|
|
56
|
+
var de = (e) => `\x1b[38;5;208m${e}\x1b[39m`, fe = (e) => `\x1b[38;5;214m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;220m${e}\x1b[39m`, me = (e) => `\x1b[38;5;33m${e}\x1b[39m`, L = (e) => `\x1b[38;5;39m${e}\x1b[39m`, he = (e) => `\x1b[38;5;81m${e}\x1b[39m`, ge = {
|
|
57
|
+
orange: de,
|
|
58
|
+
orangeBright: fe,
|
|
59
|
+
amber: pe,
|
|
60
|
+
deepBlue: me,
|
|
61
|
+
skyBlue: L,
|
|
62
|
+
lightBlue: he
|
|
63
|
+
}, R = {
|
|
64
|
+
brand: (e) => de(e),
|
|
65
|
+
brandBold: (e) => b.bold(de(e)),
|
|
66
|
+
accent: (e) => L(e),
|
|
67
|
+
accentBold: (e) => b.bold(L(e)),
|
|
68
68
|
success: (e) => b.green(e),
|
|
69
69
|
error: (e) => b.red(e),
|
|
70
70
|
warning: (e) => b.yellow(e),
|
|
71
71
|
muted: (e) => b.dim(e),
|
|
72
72
|
bold: (e) => b.bold(e),
|
|
73
73
|
highlight: (e) => b.bold(b.white(e)),
|
|
74
|
-
path: (e) => b.underline(
|
|
75
|
-
command: (e) => b.bold(
|
|
74
|
+
path: (e) => b.underline(L(e)),
|
|
75
|
+
command: (e) => b.bold(pe(e)),
|
|
76
76
|
label: (e) => b.dim(b.bold(e))
|
|
77
77
|
};
|
|
78
|
-
function
|
|
79
|
-
return `\x1b]8;;${e}\x07${
|
|
80
|
-
}
|
|
81
|
-
var
|
|
82
|
-
arrow:
|
|
83
|
-
bullet:
|
|
84
|
-
dash:
|
|
85
|
-
corner:
|
|
86
|
-
pipe:
|
|
87
|
-
dot:
|
|
88
|
-
spark:
|
|
89
|
-
sparkSmall:
|
|
90
|
-
bolt:
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
R,
|
|
94
|
-
de,
|
|
95
|
-
ue,
|
|
96
|
-
fe,
|
|
78
|
+
function _e(e, t = e) {
|
|
79
|
+
return `\x1b]8;;${e}\x07${L(t)}\x1b]8;;\x07`;
|
|
80
|
+
}
|
|
81
|
+
var z = {
|
|
82
|
+
arrow: de("›"),
|
|
83
|
+
bullet: R.muted("·"),
|
|
84
|
+
dash: R.muted("─"),
|
|
85
|
+
corner: R.muted("╰"),
|
|
86
|
+
pipe: R.muted("│"),
|
|
87
|
+
dot: R.muted("•"),
|
|
88
|
+
spark: pe("✦"),
|
|
89
|
+
sparkSmall: fe("✧"),
|
|
90
|
+
bolt: pe("⚡")
|
|
91
|
+
}, ve = [
|
|
92
|
+
pe,
|
|
97
93
|
pe,
|
|
94
|
+
fe,
|
|
95
|
+
de,
|
|
98
96
|
me,
|
|
99
|
-
|
|
97
|
+
L,
|
|
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 `${ce()}/packs/${e}`;
|
|
124
124
|
}
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region ../../node_modules/.pnpm/@hyper-fetch+core@8.1.1/node_modules/@hyper-fetch/core/dist/index.mjs
|
|
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 = V.initiallyFocused, initiallyOnline: n = V.initiallyOnline } = this.options || V;
|
|
339
|
+
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser = Re();
|
|
340
340
|
}
|
|
341
341
|
initialize = () => {
|
|
342
|
-
let { focusEvent: e =
|
|
342
|
+
let { focusEvent: e = V.focusEvent, onlineEvent: t = V.onlineEvent } = this.options || V;
|
|
343
343
|
e(this.setFocused), t(this.setOnline);
|
|
344
344
|
};
|
|
345
345
|
setInitialFocus = async (e) => {
|
|
@@ -354,50 +354,50 @@ 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(B.FOCUS);
|
|
374
374
|
},
|
|
375
375
|
emitBlur: () => {
|
|
376
|
-
e.emit(
|
|
376
|
+
e.emit(B.BLUR);
|
|
377
377
|
},
|
|
378
378
|
emitOnline: () => {
|
|
379
|
-
e.emit(
|
|
379
|
+
e.emit(B.ONLINE);
|
|
380
380
|
},
|
|
381
381
|
emitOffline: () => {
|
|
382
|
-
e.emit(
|
|
382
|
+
e.emit(B.OFFLINE);
|
|
383
383
|
},
|
|
384
|
-
onFocus: (t) => (e.on(
|
|
385
|
-
onBlur: (t) => (e.on(
|
|
386
|
-
onOnline: (t) => (e.on(
|
|
387
|
-
onOffline: (t) => (e.on(
|
|
388
|
-
}),
|
|
384
|
+
onFocus: (t) => (e.on(B.FOCUS, t), () => e.removeListener(B.FOCUS, t)),
|
|
385
|
+
onBlur: (t) => (e.on(B.BLUR, t), () => e.removeListener(B.BLUR, t)),
|
|
386
|
+
onOnline: (t) => (e.on(B.ONLINE, t), () => e.removeListener(B.ONLINE, t)),
|
|
387
|
+
onOffline: (t) => (e.on(B.OFFLINE, t), () => e.removeListener(B.OFFLINE, t))
|
|
388
|
+
}), B = /* @__PURE__ */ function(e) {
|
|
389
389
|
return e.FOCUS = "focus", e.BLUR = "blur", e.ONLINE = "online", e.OFFLINE = "offline", e;
|
|
390
|
-
}({}),
|
|
390
|
+
}({}), V = {
|
|
391
391
|
initiallyFocused: !0,
|
|
392
392
|
initiallyOnline: !0,
|
|
393
393
|
focusEvent: (e) => {
|
|
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
399
|
}, He = class {
|
|
400
|
-
emitter = new
|
|
400
|
+
emitter = new Fe();
|
|
401
401
|
events = vt(this.emitter);
|
|
402
402
|
constructor() {
|
|
403
403
|
this.emitter?.setMaxListeners(1e3);
|
|
@@ -496,7 +496,7 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
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
502
|
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger || St, this.level = this.options?.level || "warning", this.modules = this.options?.modules;
|
|
@@ -572,16 +572,16 @@ var 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
|
-
},
|
|
575
|
+
}, H = (e) => e === "timeout" ? new Dt() : e === "abort" ? new Ot() : e === "deleted" ? new kt() : e === "processing" ? new At() : new jt(), Mt = (e) => {
|
|
576
576
|
try {
|
|
577
577
|
return JSON.stringify(e);
|
|
578
578
|
} catch {
|
|
579
579
|
return "";
|
|
580
580
|
}
|
|
581
|
-
},
|
|
582
|
-
let t =
|
|
581
|
+
}, Nt = (e) => {
|
|
582
|
+
let t = Le() && e.payload instanceof FormData, n = typeof e.payload == "object" && e.payload !== null, r = {};
|
|
583
583
|
return !t && n && (r["Content-Type"] = "application/json"), Object.assign(r, e.headers), r;
|
|
584
|
-
},
|
|
584
|
+
}, Pt = (e) => Le() && e instanceof FormData ? e : Mt(e), Ft = [
|
|
585
585
|
"onBeforeSent",
|
|
586
586
|
"onRequestStart",
|
|
587
587
|
"onResponseStart",
|
|
@@ -590,7 +590,7 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
590
590
|
"onResponse",
|
|
591
591
|
"onRemove"
|
|
592
592
|
];
|
|
593
|
-
function
|
|
593
|
+
function It(e) {
|
|
594
594
|
let t = {
|
|
595
595
|
onBeforeSent: [],
|
|
596
596
|
onRequestStart: [],
|
|
@@ -600,7 +600,7 @@ function Lt(e) {
|
|
|
600
600
|
onResponse: [],
|
|
601
601
|
onRemove: []
|
|
602
602
|
};
|
|
603
|
-
e &&
|
|
603
|
+
e && Ft.forEach((n) => {
|
|
604
604
|
t[n] = [...e[n]];
|
|
605
605
|
});
|
|
606
606
|
let n = (e) => (n) => (t[e].push(n), () => {
|
|
@@ -622,15 +622,15 @@ function Lt(e) {
|
|
|
622
622
|
},
|
|
623
623
|
__snapshot() {
|
|
624
624
|
let e = {};
|
|
625
|
-
return
|
|
625
|
+
return Ft.forEach((n) => {
|
|
626
626
|
e[n] = [...t[n]];
|
|
627
627
|
}), e;
|
|
628
628
|
}
|
|
629
629
|
};
|
|
630
630
|
}
|
|
631
|
-
var
|
|
631
|
+
var Lt = /* @__PURE__ */ function(e) {
|
|
632
632
|
return e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.PATCH = "PATCH", e.DELETE = "DELETE", e;
|
|
633
|
-
}({}),
|
|
633
|
+
}({}), U = (e, t) => t ? `${t}__${e}` : e, Rt = (e) => {
|
|
634
634
|
try {
|
|
635
635
|
if (typeof e == "string") return e;
|
|
636
636
|
if (e == null) return "";
|
|
@@ -640,13 +640,13 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
640
640
|
} catch {
|
|
641
641
|
return "";
|
|
642
642
|
}
|
|
643
|
-
},
|
|
643
|
+
}, zt = ({ loaded: e, total: t }) => !e || !t ? 0 : Number((e * 100 / t).toFixed(0)), Bt = (e, t, { total: n, loaded: r }) => {
|
|
644
644
|
let i = r / (t - +e || 1), a = Math.max(n, r), o = a - r, s = i ? o / i : null;
|
|
645
645
|
return {
|
|
646
646
|
timeLeft: a === r ? 0 : s,
|
|
647
647
|
sizeLeft: o
|
|
648
648
|
};
|
|
649
|
-
},
|
|
649
|
+
}, Vt = (e, t, n) => {
|
|
650
650
|
let { total: r, loaded: i } = n;
|
|
651
651
|
if (Number.isNaN(r) || Number.isNaN(i)) return {
|
|
652
652
|
progress: 0,
|
|
@@ -656,23 +656,23 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
656
656
|
loaded: 0,
|
|
657
657
|
startTimestamp: +e
|
|
658
658
|
};
|
|
659
|
-
let { timeLeft: a, sizeLeft: o } =
|
|
659
|
+
let { timeLeft: a, sizeLeft: o } = Bt(e, t, n);
|
|
660
660
|
return {
|
|
661
|
-
progress:
|
|
661
|
+
progress: zt(n),
|
|
662
662
|
timeLeft: a,
|
|
663
663
|
sizeLeft: o,
|
|
664
664
|
total: r,
|
|
665
665
|
loaded: i,
|
|
666
666
|
startTimestamp: +e
|
|
667
667
|
};
|
|
668
|
-
},
|
|
669
|
-
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method ===
|
|
668
|
+
}, Ht = (e) => `${e.method}_${e.requestOptions.endpoint}_${e.cancelable}`, Ut = (e, t) => `${Rt(e.method)}_${t ? e.requestOptions.endpoint : Rt(e.endpoint)}_${t ? "" : Rt(e.queryParams)}`, Wt = (e, t = "auto") => {
|
|
669
|
+
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method === Lt.GET, a = t === "auto" && i || t === "fetch";
|
|
670
670
|
return [a ? n : r, a];
|
|
671
|
-
},
|
|
671
|
+
}, Gt = async (e, t) => {
|
|
672
672
|
let n = e.unstable_responseMapper?.(t);
|
|
673
673
|
return n instanceof Promise ? await n : n || t;
|
|
674
|
-
},
|
|
675
|
-
let { client: n } = e, { requestManager: r } = n, [i] =
|
|
674
|
+
}, Kt = async (e, t) => {
|
|
675
|
+
let { client: n } = e, { requestManager: r } = n, [i] = Wt(e, t?.dispatcherType), a;
|
|
676
676
|
if (e.optimistic) try {
|
|
677
677
|
a = await e.optimistic({
|
|
678
678
|
request: e,
|
|
@@ -748,7 +748,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
748
748
|
data: null,
|
|
749
749
|
status: null,
|
|
750
750
|
success: !1,
|
|
751
|
-
error:
|
|
751
|
+
error: H("deleted"),
|
|
752
752
|
extra: e.client.adapter.defaultExtra,
|
|
753
753
|
requestTimestamp: +/* @__PURE__ */ new Date(),
|
|
754
754
|
responseTimestamp: +/* @__PURE__ */ new Date()
|
|
@@ -759,9 +759,9 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
759
759
|
u(), d(), f(), p(), m(), h();
|
|
760
760
|
}
|
|
761
761
|
});
|
|
762
|
-
},
|
|
762
|
+
}, qt = /* @__PURE__ */ function(e) {
|
|
763
763
|
return e[e.SEC = 1e3] = "SEC", e[e.MIN = 6e4] = "MIN", e[e.HOUR = 36e5] = "HOUR", e[e.DAY = 864e5] = "DAY", e[e.WEEK = 6048e5] = "WEEK", e[e.MONTH_30 = 2592e6] = "MONTH_30", e[e.MONTH_31 = 26784e5] = "MONTH_31", e[e.YEAR = 31536e6] = "YEAR", e[e.YEAR_LEAP = 316224e5] = "YEAR_LEAP", e;
|
|
764
|
-
}({}),
|
|
764
|
+
}({}), Jt = class e {
|
|
765
765
|
endpoint;
|
|
766
766
|
headers;
|
|
767
767
|
auth;
|
|
@@ -785,7 +785,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
785
785
|
deduplicate;
|
|
786
786
|
deduplicateTime;
|
|
787
787
|
scope;
|
|
788
|
-
$hooks =
|
|
788
|
+
$hooks = It();
|
|
789
789
|
isMockerEnabled = !1;
|
|
790
790
|
unstable_mock;
|
|
791
791
|
unstable_payloadMapper;
|
|
@@ -802,7 +802,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
802
802
|
updatedQueryKey;
|
|
803
803
|
constructor(e, t, n) {
|
|
804
804
|
this.client = e, this.requestOptions = t, this.initialRequestConfiguration = n;
|
|
805
|
-
let { endpoint: r, headers: i, auth: a = !0, method: o = e.adapter.defaultMethod, options: s, cancelable: c = !1, retry: l = 0, retryTime: u = 500, cacheTime: d =
|
|
805
|
+
let { endpoint: r, headers: i, auth: a = !0, method: o = e.adapter.defaultMethod, options: s, cancelable: c = !1, retry: l = 0, retryTime: u = 500, cacheTime: d = qt.MIN * 5, cache: f = !0, staleTime: p = qt.MIN * 5, queued: m = !1, offline: h = !0, abortKey: g, cacheKey: _, queryKey: v, deduplicate: y = !1, deduplicateTime: b = null } = {
|
|
806
806
|
...this.client.adapter.unstable_getRequestDefaults?.(t),
|
|
807
807
|
...t
|
|
808
808
|
};
|
|
@@ -912,11 +912,11 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
912
912
|
payload: t?.payload || this.payload,
|
|
913
913
|
params: t?.params || this.params
|
|
914
914
|
}, r = new e(this.client, this.requestOptions, n);
|
|
915
|
-
return r.unstable_payloadMapper = this.unstable_payloadMapper, r.unstable_responseMapper = this.unstable_responseMapper, r.unstable_requestMapper = this.unstable_requestMapper, r.retryOnError = this.retryOnError, r.unstable_mock = this.unstable_mock, r.isMockerEnabled = this.isMockerEnabled, r.optimistic = this.optimistic, r.$hooks =
|
|
915
|
+
return r.unstable_payloadMapper = this.unstable_payloadMapper, r.unstable_responseMapper = this.unstable_responseMapper, r.unstable_requestMapper = this.unstable_requestMapper, r.retryOnError = this.retryOnError, r.unstable_mock = this.unstable_mock, r.isMockerEnabled = this.isMockerEnabled, r.optimistic = this.optimistic, r.$hooks = It(this.$hooks.__snapshot()), r;
|
|
916
916
|
}
|
|
917
917
|
abort = () => {
|
|
918
918
|
let { requestManager: e } = this.client;
|
|
919
|
-
return e.abortByKey(
|
|
919
|
+
return e.abortByKey(U(this.abortKey, this.scope)), this.clone();
|
|
920
920
|
};
|
|
921
921
|
dehydrate = (e) => {
|
|
922
922
|
let { response: t, override: n = !0 } = e || {};
|
|
@@ -931,7 +931,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
931
931
|
cache: !0,
|
|
932
932
|
response: t
|
|
933
933
|
};
|
|
934
|
-
let r = this.client.cache.get(
|
|
934
|
+
let r = this.client.cache.get(U(this.cacheKey, this.scope));
|
|
935
935
|
if (r) return {
|
|
936
936
|
override: n,
|
|
937
937
|
cacheTime: this.cacheTime,
|
|
@@ -953,7 +953,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
953
953
|
};
|
|
954
954
|
};
|
|
955
955
|
read() {
|
|
956
|
-
let e = this.client.cache.get(
|
|
956
|
+
let e = this.client.cache.get(U(this.cacheKey, this.scope));
|
|
957
957
|
if (e) return {
|
|
958
958
|
data: e.data,
|
|
959
959
|
error: e.error,
|
|
@@ -965,7 +965,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
965
965
|
};
|
|
966
966
|
}
|
|
967
967
|
exec = async (e) => {
|
|
968
|
-
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a =
|
|
968
|
+
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a = U(this.abortKey, this.scope);
|
|
969
969
|
n.addAbortController(a, i);
|
|
970
970
|
let o = await t.fetch(r, i);
|
|
971
971
|
return n.removeAbortController(a, i), r.unstable_responseMapper ? r.unstable_responseMapper(o) : o;
|
|
@@ -975,17 +975,17 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
975
975
|
...e,
|
|
976
976
|
cachePolicy: void 0
|
|
977
977
|
};
|
|
978
|
-
if (n === "network-only") return
|
|
978
|
+
if (n === "network-only") return Kt(i, a);
|
|
979
979
|
let o = i.read();
|
|
980
|
-
if (n === "cache-first") return o ?
|
|
980
|
+
if (n === "cache-first") return o ? Gt(i, o) : Kt(i, a);
|
|
981
981
|
if (o) {
|
|
982
|
-
let e = await
|
|
983
|
-
return
|
|
982
|
+
let e = await Gt(i, o);
|
|
983
|
+
return Kt(i, a), e;
|
|
984
984
|
}
|
|
985
|
-
return
|
|
985
|
+
return Kt(i, a);
|
|
986
986
|
};
|
|
987
987
|
static fromJSON = (t, n) => new e(t, n.requestOptions, n);
|
|
988
|
-
},
|
|
988
|
+
}, Yt = async ({ request: e, requestId: t, resolve: n, onStartTime: r, internalErrorMapping: i }) => {
|
|
989
989
|
let { requestManager: a, loggerManager: o } = e.client, { unstable_payloadMapper: s } = e.client.adapter, c = o.initialize(e.client, "Adapter"), l = null, u = null, d = e, f = 1, p = 1, m = 0, h = 0;
|
|
990
990
|
c.debug({
|
|
991
991
|
title: "Running middleware callbacks",
|
|
@@ -995,7 +995,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
995
995
|
requestId: t
|
|
996
996
|
}
|
|
997
997
|
}), d = await d.client.unstable_modifyRequest(d), d.auth && (d = await d.client.unstable_modifyAuth(d)), d.unstable_requestMapper && (d = await d.unstable_requestMapper(d, t));
|
|
998
|
-
let { client: g, abortKey: _ } = d, v =
|
|
998
|
+
let { client: g, abortKey: _ } = d, v = U(_, d.scope), y = d.payload;
|
|
999
999
|
d.unstable_payloadMapper ? y = await d.unstable_payloadMapper(d.payload) : s && (y = await s(y));
|
|
1000
1000
|
let b = d.options, x = +/* @__PURE__ */ new Date();
|
|
1001
1001
|
r(x);
|
|
@@ -1004,14 +1004,14 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
1004
1004
|
let n = Number(t.total || 0), r = Number(t.loaded || 0);
|
|
1005
1005
|
return Math.max(n, r, e);
|
|
1006
1006
|
}, T = (e, n, r) => {
|
|
1007
|
-
let i =
|
|
1007
|
+
let i = Vt(new Date(e), new Date(n), r);
|
|
1008
1008
|
m !== 100 && (m = i.total, a.events.emitUploadProgress({
|
|
1009
1009
|
...i,
|
|
1010
1010
|
requestId: t,
|
|
1011
1011
|
request: d
|
|
1012
1012
|
}));
|
|
1013
1013
|
}, E = (e, n, r) => {
|
|
1014
|
-
let i =
|
|
1014
|
+
let i = Vt(new Date(e), new Date(n), r);
|
|
1015
1015
|
h !== 100 && (h = i.total, a.events.emitDownloadProgress({
|
|
1016
1016
|
...i,
|
|
1017
1017
|
requestId: t,
|
|
@@ -1074,14 +1074,14 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
1074
1074
|
total: e.total || p,
|
|
1075
1075
|
loaded: e.loaded || 0
|
|
1076
1076
|
}), t;
|
|
1077
|
-
},
|
|
1077
|
+
}, te = () => {
|
|
1078
1078
|
u ||= +/* @__PURE__ */ new Date();
|
|
1079
1079
|
let e = +/* @__PURE__ */ new Date();
|
|
1080
1080
|
return E(u, e, {
|
|
1081
1081
|
total: p,
|
|
1082
1082
|
loaded: p
|
|
1083
1083
|
}), e;
|
|
1084
|
-
},
|
|
1084
|
+
}, ne = async ({ data: e, error: r, status: i, extra: a }) => {
|
|
1085
1085
|
let o = {
|
|
1086
1086
|
data: e,
|
|
1087
1087
|
error: r ?? null,
|
|
@@ -1106,50 +1106,50 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
1106
1106
|
response: o
|
|
1107
1107
|
}
|
|
1108
1108
|
}), o;
|
|
1109
|
-
},
|
|
1109
|
+
}, M = Xt({
|
|
1110
1110
|
request: d,
|
|
1111
1111
|
requestId: t,
|
|
1112
1112
|
startTime: x,
|
|
1113
1113
|
logger: c,
|
|
1114
1114
|
resolve: n
|
|
1115
|
-
}),
|
|
1115
|
+
}), N = ({ status: e, extra: n }) => (c.error({
|
|
1116
1116
|
title: "Abort error",
|
|
1117
1117
|
type: "request",
|
|
1118
1118
|
extra: {
|
|
1119
1119
|
request: d,
|
|
1120
1120
|
requestId: t
|
|
1121
1121
|
}
|
|
1122
|
-
}),
|
|
1123
|
-
error: i(
|
|
1122
|
+
}), M({
|
|
1123
|
+
error: i(H("abort")),
|
|
1124
1124
|
status: e,
|
|
1125
1125
|
extra: n
|
|
1126
|
-
})),
|
|
1126
|
+
})), P = ({ status: e, extra: n }) => (c.error({
|
|
1127
1127
|
title: "Timeout error",
|
|
1128
1128
|
type: "request",
|
|
1129
1129
|
extra: {
|
|
1130
1130
|
request: d,
|
|
1131
1131
|
requestId: t
|
|
1132
1132
|
}
|
|
1133
|
-
}),
|
|
1134
|
-
error:
|
|
1133
|
+
}), M({
|
|
1134
|
+
error: H("timeout"),
|
|
1135
1135
|
status: e,
|
|
1136
1136
|
extra: n
|
|
1137
|
-
})),
|
|
1137
|
+
})), re = ({ status: e, extra: n }) => (c.error({
|
|
1138
1138
|
title: "Unexpected error",
|
|
1139
1139
|
type: "request",
|
|
1140
1140
|
extra: {
|
|
1141
1141
|
request: d,
|
|
1142
1142
|
requestId: t
|
|
1143
1143
|
}
|
|
1144
|
-
}),
|
|
1145
|
-
error:
|
|
1144
|
+
}), M({
|
|
1145
|
+
error: H(),
|
|
1146
1146
|
status: e,
|
|
1147
1147
|
extra: n
|
|
1148
|
-
})),
|
|
1149
|
-
let i =
|
|
1148
|
+
})), F = () => a.getAbortController(v, t), ie = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1149
|
+
let i = F();
|
|
1150
1150
|
if (!i) throw new At("Controller is not found");
|
|
1151
1151
|
let o = () => {
|
|
1152
|
-
|
|
1152
|
+
N({
|
|
1153
1153
|
status: e,
|
|
1154
1154
|
extra: n
|
|
1155
1155
|
}), r(), a.events.emitAbort({
|
|
@@ -1169,36 +1169,36 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
1169
1169
|
adapterOptions: b
|
|
1170
1170
|
}
|
|
1171
1171
|
});
|
|
1172
|
-
let
|
|
1172
|
+
let ae = e.client.adapter.unstable_queryParamsMapper(d.queryParams), oe = e.client.adapter.unstable_endpointMapper(d.endpoint), se = e.client.adapter.unstable_headerMapper(d), { url: I } = e.client;
|
|
1173
1173
|
return {
|
|
1174
1174
|
request: d,
|
|
1175
1175
|
requestId: t,
|
|
1176
|
-
url:
|
|
1177
|
-
endpoint:
|
|
1178
|
-
queryParams:
|
|
1176
|
+
url: I,
|
|
1177
|
+
endpoint: oe,
|
|
1178
|
+
queryParams: ae,
|
|
1179
1179
|
payload: y,
|
|
1180
|
-
headers:
|
|
1180
|
+
headers: se,
|
|
1181
1181
|
adapter: e.client.adapter,
|
|
1182
1182
|
adapterOptions: b,
|
|
1183
|
-
getAbortController:
|
|
1183
|
+
getAbortController: F,
|
|
1184
1184
|
getRequestStartTimestamp: S,
|
|
1185
1185
|
getResponseStartTimestamp: C,
|
|
1186
|
-
createAbortListener:
|
|
1186
|
+
createAbortListener: ie,
|
|
1187
1187
|
onBeforeRequest: D,
|
|
1188
1188
|
onRequestStart: O,
|
|
1189
1189
|
onRequestProgress: k,
|
|
1190
1190
|
onRequestEnd: ee,
|
|
1191
1191
|
onResponseStart: A,
|
|
1192
1192
|
onResponseProgress: j,
|
|
1193
|
-
onResponseEnd:
|
|
1194
|
-
onSuccess:
|
|
1195
|
-
onAbortError:
|
|
1196
|
-
onTimeoutError:
|
|
1197
|
-
onUnexpectedError:
|
|
1198
|
-
onError:
|
|
1193
|
+
onResponseEnd: te,
|
|
1194
|
+
onSuccess: ne,
|
|
1195
|
+
onAbortError: N,
|
|
1196
|
+
onTimeoutError: P,
|
|
1197
|
+
onUnexpectedError: re,
|
|
1198
|
+
onError: M
|
|
1199
1199
|
};
|
|
1200
1200
|
};
|
|
1201
|
-
function
|
|
1201
|
+
function Xt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
1202
1202
|
let { client: a } = e;
|
|
1203
1203
|
return async ({ error: o, status: s, extra: c }) => {
|
|
1204
1204
|
let l = {
|
|
@@ -1227,7 +1227,7 @@ function Zt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
|
1227
1227
|
}), l;
|
|
1228
1228
|
};
|
|
1229
1229
|
}
|
|
1230
|
-
var
|
|
1230
|
+
var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTimeoutError: i, onRequestEnd: a, createAbortListener: o, onResponseProgress: s, onRequestProgress: c, onResponseStart: l, onBeforeRequest: u, onRequestStart: d, onSuccess: f, onAbortError: p, adapter: m }) => {
|
|
1231
1231
|
if (!e.unstable_mock) throw new At("Mock should be defined when calling mocker");
|
|
1232
1232
|
let h = !1, { requestTime: g = 20, responseTime: _ = 20, totalUploaded: v = 1e3, totalDownloaded: y = 1e3, timeout: b } = e.unstable_mock.config, { data: x, error: S, status: C, success: w = !0, extra: T = e.client.adapter.defaultExtra } = await e.unstable_mock.fn({
|
|
1233
1233
|
request: e,
|
|
@@ -1272,7 +1272,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1272
1272
|
status: C,
|
|
1273
1273
|
extra: T
|
|
1274
1274
|
}), h || r();
|
|
1275
|
-
},
|
|
1275
|
+
}, Qt = (e) => e, $t = class {
|
|
1276
1276
|
unstable_fetcher;
|
|
1277
1277
|
name;
|
|
1278
1278
|
defaultMethod;
|
|
@@ -1294,10 +1294,10 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1294
1294
|
initialize = (e) => (this.logger = e.loggerManager.initialize(e, "Adapter"), this.initialized = !0, this.client = e, this.unstable_onInitializeCallback?.({ client: e }), this);
|
|
1295
1295
|
onInitialize = (e) => (this.unstable_onInitializeCallback = e, this);
|
|
1296
1296
|
unstable_internalErrorMapping = (e) => e;
|
|
1297
|
-
unstable_headerMapper =
|
|
1298
|
-
unstable_payloadMapper =
|
|
1299
|
-
unstable_endpointMapper =
|
|
1300
|
-
unstable_queryParamsMapper =
|
|
1297
|
+
unstable_headerMapper = Nt;
|
|
1298
|
+
unstable_payloadMapper = Pt;
|
|
1299
|
+
unstable_endpointMapper = Qt;
|
|
1300
|
+
unstable_queryParamsMapper = Qt;
|
|
1301
1301
|
unstable_getAdapterDefaults;
|
|
1302
1302
|
unstable_getRequestDefaults;
|
|
1303
1303
|
unstable_devtoolsEndpointGetter = (e) => e;
|
|
@@ -1328,7 +1328,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1328
1328
|
request: e,
|
|
1329
1329
|
requestId: t
|
|
1330
1330
|
});
|
|
1331
|
-
let i = await
|
|
1331
|
+
let i = await Yt({
|
|
1332
1332
|
request: e,
|
|
1333
1333
|
requestId: t,
|
|
1334
1334
|
resolve: r,
|
|
@@ -1337,9 +1337,9 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1337
1337
|
n = e;
|
|
1338
1338
|
}
|
|
1339
1339
|
});
|
|
1340
|
-
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await
|
|
1340
|
+
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await Zt(i) : this.unstable_fetcher(i);
|
|
1341
1341
|
} catch (i) {
|
|
1342
|
-
return
|
|
1342
|
+
return Xt({
|
|
1343
1343
|
request: e,
|
|
1344
1344
|
requestId: t,
|
|
1345
1345
|
startTime: n || Date.now(),
|
|
@@ -1356,66 +1356,66 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1356
1356
|
r(e);
|
|
1357
1357
|
});
|
|
1358
1358
|
}
|
|
1359
|
-
},
|
|
1359
|
+
}, en = (e) => {
|
|
1360
1360
|
try {
|
|
1361
1361
|
return JSON.parse(e);
|
|
1362
1362
|
} catch {
|
|
1363
1363
|
return e;
|
|
1364
1364
|
}
|
|
1365
|
-
},
|
|
1365
|
+
}, tn = (e) => e ? en(e) : H(), nn = (e) => (t) => {
|
|
1366
1366
|
let { skipNull: n, skipEmptyString: r } = e;
|
|
1367
1367
|
return !(r && t === void 0 || r && t === "" || n && t === null);
|
|
1368
|
-
},
|
|
1369
|
-
let r = !
|
|
1370
|
-
return !e || r ? "" : `${
|
|
1371
|
-
},
|
|
1368
|
+
}, W = (e, { encode: t, strict: n }) => t && n ? encodeURIComponent(e).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`) : t ? encodeURIComponent(e) : e, rn = (e, t, n) => {
|
|
1369
|
+
let r = !nn(n)(t);
|
|
1370
|
+
return !e || r ? "" : `${W(e, n)}=${W(t instanceof Date ? n.dateParser?.(t) || t.toISOString() : typeof t == "object" && !Array.isArray(t) ? n.objectParser?.(t) || JSON.stringify(t) : String(t), n)}`;
|
|
1371
|
+
}, an = (e, t, n) => {
|
|
1372
1372
|
let { arrayFormat: r, arraySeparator: i } = n;
|
|
1373
|
-
return t.filter(
|
|
1373
|
+
return t.filter(nn(n)).reduce((t, a, o) => {
|
|
1374
1374
|
switch (r) {
|
|
1375
1375
|
case "index": {
|
|
1376
|
-
let r = `${
|
|
1377
|
-
t.push(`${r}${
|
|
1376
|
+
let r = `${W(e, n)}[${W(String(o), n)}]=`;
|
|
1377
|
+
t.push(`${r}${W(String(a), n)}`);
|
|
1378
1378
|
break;
|
|
1379
1379
|
}
|
|
1380
1380
|
case "bracket": {
|
|
1381
|
-
let r = `${
|
|
1382
|
-
t.push(`${r}${
|
|
1381
|
+
let r = `${W(e, n)}[]=`;
|
|
1382
|
+
t.push(`${r}${W(String(a), n)}`);
|
|
1383
1383
|
break;
|
|
1384
1384
|
}
|
|
1385
1385
|
case "comma": {
|
|
1386
|
-
let r = !t.length && `${
|
|
1387
|
-
return [[...t, `${r}${
|
|
1386
|
+
let r = !t.length && `${W(e, n)}=` || "";
|
|
1387
|
+
return [[...t, `${r}${W(String(a), n)}`].join(",")];
|
|
1388
1388
|
}
|
|
1389
1389
|
case "separator": {
|
|
1390
|
-
let r = !t.length && `${
|
|
1391
|
-
return [[...t, `${r}${
|
|
1390
|
+
let r = !t.length && `${W(e, n)}=` || "";
|
|
1391
|
+
return [[...t, `${r}${W(String(a), n)}`].join(i || "|")];
|
|
1392
1392
|
}
|
|
1393
1393
|
case "bracket-separator": {
|
|
1394
|
-
let r = !t.length && `${
|
|
1395
|
-
return [[...t, `${r}${
|
|
1394
|
+
let r = !t.length && `${W(e, n)}[]=` || "";
|
|
1395
|
+
return [[...t, `${r}${W(String(a), n)}`].join(i || "|")];
|
|
1396
1396
|
}
|
|
1397
1397
|
default: {
|
|
1398
|
-
let r = `${
|
|
1399
|
-
t.push(`${r}${
|
|
1398
|
+
let r = `${W(e, n)}=`;
|
|
1399
|
+
t.push(`${r}${W(String(a), n)}`);
|
|
1400
1400
|
}
|
|
1401
1401
|
}
|
|
1402
1402
|
return t;
|
|
1403
1403
|
}, []).join("&");
|
|
1404
|
-
},
|
|
1404
|
+
}, on = (e, t = Fn) => {
|
|
1405
1405
|
if (!e || !Object.keys(e).length) return "";
|
|
1406
1406
|
if (typeof e == "string") return e[0] === "?" ? e : `?${e}`;
|
|
1407
|
-
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ?
|
|
1407
|
+
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ? an(e, n, t) : rn(e, n, t)).filter(Boolean).join("&");
|
|
1408
1408
|
return n ? `?${n}` : "";
|
|
1409
|
-
},
|
|
1409
|
+
}, sn = qt.SEC * 5, cn = { headers: {} }, ln = () => new $t({
|
|
1410
1410
|
name: "http",
|
|
1411
|
-
defaultMethod:
|
|
1412
|
-
defaultExtra:
|
|
1411
|
+
defaultMethod: Lt.GET,
|
|
1412
|
+
defaultExtra: cn,
|
|
1413
1413
|
systemErrorStatus: 0,
|
|
1414
|
-
systemErrorExtra:
|
|
1415
|
-
}).setQueryParamsMapper(
|
|
1416
|
-
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ?
|
|
1414
|
+
systemErrorExtra: cn
|
|
1415
|
+
}).setQueryParamsMapper(on).setFetcher(async ({ request: e, adapterOptions: t, headers: n, payload: r, onError: i, onResponseEnd: a, onTimeoutError: o, onRequestEnd: s, createAbortListener: c, getAbortController: l, onResponseProgress: u, onResponseStart: d, onBeforeRequest: f, onRequestStart: p, onRequestProgress: m, onSuccess: h }) => {
|
|
1416
|
+
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ? on(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = sn, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
|
|
1417
1417
|
status: 0,
|
|
1418
|
-
extra:
|
|
1418
|
+
extra: cn
|
|
1419
1419
|
});
|
|
1420
1420
|
C > 0 && S && (D = setTimeout(() => {
|
|
1421
1421
|
E = !0, O(), S.abort();
|
|
@@ -1447,7 +1447,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1447
1447
|
status: l,
|
|
1448
1448
|
extra: c
|
|
1449
1449
|
}) : i({
|
|
1450
|
-
error:
|
|
1450
|
+
error: tn(await t.text()),
|
|
1451
1451
|
status: l,
|
|
1452
1452
|
extra: c
|
|
1453
1453
|
});
|
|
@@ -1468,11 +1468,11 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1468
1468
|
e = new TextDecoder().decode(o);
|
|
1469
1469
|
} else e = await t.text();
|
|
1470
1470
|
a(), O(), t.ok ? h({
|
|
1471
|
-
data:
|
|
1471
|
+
data: en(e),
|
|
1472
1472
|
status: l,
|
|
1473
1473
|
extra: c
|
|
1474
1474
|
}) : i({
|
|
1475
|
-
error:
|
|
1475
|
+
error: tn(e),
|
|
1476
1476
|
status: l,
|
|
1477
1477
|
extra: c
|
|
1478
1478
|
});
|
|
@@ -1481,18 +1481,18 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1481
1481
|
if (D && clearTimeout(D), O(), S?.signal?.aborted) {
|
|
1482
1482
|
E && o({
|
|
1483
1483
|
status: 0,
|
|
1484
|
-
extra:
|
|
1484
|
+
extra: cn
|
|
1485
1485
|
});
|
|
1486
1486
|
return;
|
|
1487
1487
|
}
|
|
1488
1488
|
i({
|
|
1489
1489
|
error: e,
|
|
1490
1490
|
status: 0,
|
|
1491
|
-
extra:
|
|
1491
|
+
extra: cn
|
|
1492
1492
|
});
|
|
1493
1493
|
}
|
|
1494
|
-
}),
|
|
1495
|
-
emitter = new
|
|
1494
|
+
}), un = () => ln(), dn = class {
|
|
1495
|
+
emitter = new Fe();
|
|
1496
1496
|
events;
|
|
1497
1497
|
storage;
|
|
1498
1498
|
lazyStorage;
|
|
@@ -1503,7 +1503,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1503
1503
|
constructor(e) {
|
|
1504
1504
|
this.options = e;
|
|
1505
1505
|
let { storage: t = /* @__PURE__ */ new Map(), lazyStorage: n, version: r = "0.0.1" } = e ?? {};
|
|
1506
|
-
this.emitter?.setMaxListeners(1e3), this.events =
|
|
1506
|
+
this.emitter?.setMaxListeners(1e3), this.events = yn(this.emitter), this.storage = t, this.version = r, this.lazyStorage = n;
|
|
1507
1507
|
}
|
|
1508
1508
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Cache"), e.appManager.events.onOnline(() => {
|
|
1509
1509
|
[...this.storage.keys()].forEach(this.scheduleGarbageCollector);
|
|
@@ -1517,7 +1517,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1517
1517
|
response: t
|
|
1518
1518
|
}
|
|
1519
1519
|
});
|
|
1520
|
-
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s =
|
|
1520
|
+
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = U(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u = fn(c, l), d = {
|
|
1521
1521
|
...u,
|
|
1522
1522
|
scope: o,
|
|
1523
1523
|
staleTime: i,
|
|
@@ -1563,7 +1563,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1563
1563
|
partialResponse: t
|
|
1564
1564
|
}
|
|
1565
1565
|
});
|
|
1566
|
-
let { cacheKey: n, scope: r } = e, i =
|
|
1566
|
+
let { cacheKey: n, scope: r } = e, i = U(n, r), a = this.storage.get(i), o = typeof t == "function" ? t(a || null) : t;
|
|
1567
1567
|
a && this.set(e, {
|
|
1568
1568
|
...a,
|
|
1569
1569
|
...o
|
|
@@ -1601,7 +1601,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1601
1601
|
cacheKey: t
|
|
1602
1602
|
}), this.events.emitInvalidation(t);
|
|
1603
1603
|
};
|
|
1604
|
-
e instanceof
|
|
1604
|
+
e instanceof Jt ? n(U(e.cacheKey, e.scope), e.cacheKey) : typeof e == "string" ? n(e) : t.length && t.forEach((t) => {
|
|
1605
1605
|
e.test(t) && n(t);
|
|
1606
1606
|
});
|
|
1607
1607
|
};
|
|
@@ -1656,49 +1656,49 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1656
1656
|
clear = async () => {
|
|
1657
1657
|
this.garbageCollectors.forEach((e) => clearTimeout(e)), this.storage.clear();
|
|
1658
1658
|
};
|
|
1659
|
-
},
|
|
1659
|
+
}, fn = (e, t) => {
|
|
1660
1660
|
let { data: n, success: r } = t, i = !r && e ? e.data : null, a = n || i;
|
|
1661
1661
|
return {
|
|
1662
1662
|
...t,
|
|
1663
1663
|
data: a
|
|
1664
1664
|
};
|
|
1665
|
-
},
|
|
1665
|
+
}, pn = () => "invalidate", mn = (e) => `${e}_invalidate`, hn = () => "delete", gn = (e) => `${e}_delete`, _n = (e) => `${e}_cache`, vn = () => "cache", yn = (e) => ({
|
|
1666
1666
|
emitCacheData: (t, n = !1) => {
|
|
1667
|
-
e.emit(
|
|
1667
|
+
e.emit(vn(), t, n), e.emit(_n(t.cacheKey), t, n);
|
|
1668
1668
|
},
|
|
1669
1669
|
emitInvalidation: (t, n = !1) => {
|
|
1670
|
-
e.emit(
|
|
1670
|
+
e.emit(pn(), t, n), e.emit(mn(t), n);
|
|
1671
1671
|
},
|
|
1672
1672
|
emitDelete: (t, n = !1) => {
|
|
1673
|
-
e.emit(
|
|
1673
|
+
e.emit(hn(), t, n), e.emit(gn(t), n);
|
|
1674
1674
|
},
|
|
1675
|
-
onData: (t) => (e.on(
|
|
1676
|
-
onDataByKey: (t, n) => (e.on(
|
|
1677
|
-
onInvalidate: (t) => (e.on(
|
|
1678
|
-
onInvalidateByKey: (t, n) => (e.on(
|
|
1679
|
-
onDelete: (t) => (e.on(
|
|
1680
|
-
onDeleteByKey: (t, n) => (e.on(
|
|
1681
|
-
}),
|
|
1675
|
+
onData: (t) => (e.on(vn(), t), () => e.removeListener(vn(), t)),
|
|
1676
|
+
onDataByKey: (t, n) => (e.on(_n(t), n), () => e.removeListener(_n(t), n)),
|
|
1677
|
+
onInvalidate: (t) => (e.on(pn(), t), () => e.removeListener(pn(), t)),
|
|
1678
|
+
onInvalidateByKey: (t, n) => (e.on(mn(t), n), () => e.removeListener(mn(t), n)),
|
|
1679
|
+
onDelete: (t) => (e.on(hn(), t), () => e.removeListener(hn(), t)),
|
|
1680
|
+
onDeleteByKey: (t, n) => (e.on(gn(t), n), () => e.removeListener(gn(t), n))
|
|
1681
|
+
}), G = /* @__PURE__ */ function(e) {
|
|
1682
1682
|
return e.ONE_BY_ONE = "one-by-one", e.ALL_AT_ONCE = "all-at-once", e.PREVIOUS_CANCELED = "previous-canceled", e.DEDUPLICATED = "deduplicated", e;
|
|
1683
|
-
}({}),
|
|
1683
|
+
}({}), bn = (e) => ({
|
|
1684
1684
|
emitDrained: (t, n) => {
|
|
1685
|
-
e.emit(
|
|
1685
|
+
e.emit(Sn(), t, n), e.emit(Cn(t.queryKey), t, n);
|
|
1686
1686
|
},
|
|
1687
1687
|
emitQueueStatusChanged: (t, n) => {
|
|
1688
|
-
e.emit(
|
|
1688
|
+
e.emit(wn(), t, n), e.emit(Tn(t.queryKey), t, n);
|
|
1689
1689
|
},
|
|
1690
1690
|
emitQueueChanged: (t, n) => {
|
|
1691
|
-
e.emit(
|
|
1691
|
+
e.emit(En(), t, n), e.emit(Dn(t.queryKey), t, n);
|
|
1692
1692
|
},
|
|
1693
|
-
onDrained: (t) => (e.on(
|
|
1694
|
-
onDrainedByKey: (t, n) => (e.on(
|
|
1695
|
-
onQueueStatusChange: (t) => (e.on(
|
|
1696
|
-
onQueueStatusChangeByKey: (t, n) => (e.on(
|
|
1697
|
-
onQueueChange: (t) => (e.on(
|
|
1698
|
-
onQueueChangeByKey: (t, n) => (e.on(
|
|
1699
|
-
}),
|
|
1700
|
-
emitter = new
|
|
1701
|
-
events =
|
|
1693
|
+
onDrained: (t) => (e.on(Sn(), t), () => e.removeListener(Sn(), t)),
|
|
1694
|
+
onDrainedByKey: (t, n) => (e.on(Cn(t), n), () => e.removeListener(Cn(t), n)),
|
|
1695
|
+
onQueueStatusChange: (t) => (e.on(wn(), t), () => e.removeListener(wn(), t)),
|
|
1696
|
+
onQueueStatusChangeByKey: (t, n) => (e.on(Tn(t), n), () => e.removeListener(Tn(t), n)),
|
|
1697
|
+
onQueueChange: (t) => (e.on(En(), t), () => e.removeListener(En(), t)),
|
|
1698
|
+
onQueueChangeByKey: (t, n) => (e.on(Dn(t), n), () => e.removeListener(Dn(t), n))
|
|
1699
|
+
}), xn = class {
|
|
1700
|
+
emitter = new Fe();
|
|
1701
|
+
events = bn(this.emitter);
|
|
1702
1702
|
storage = /* @__PURE__ */ new Map();
|
|
1703
1703
|
requestCount = /* @__PURE__ */ new Map();
|
|
1704
1704
|
runningRequests = /* @__PURE__ */ new Map();
|
|
@@ -1707,7 +1707,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1707
1707
|
constructor(e) {
|
|
1708
1708
|
this.options = e, this.emitter?.setMaxListeners(1e3), this.options?.storage && (this.storage = this.options.storage);
|
|
1709
1709
|
}
|
|
1710
|
-
isRequestJSON = (e) => !(e instanceof
|
|
1710
|
+
isRequestJSON = (e) => !(e instanceof Jt);
|
|
1711
1711
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Dispatcher"), this.client.appManager.events.onOnline(() => {
|
|
1712
1712
|
this.flush();
|
|
1713
1713
|
}), this);
|
|
@@ -1831,14 +1831,14 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1831
1831
|
hasRunningRequest = (e, t) => !!this.getRunningRequests(e).find((e) => e.requestId === t);
|
|
1832
1832
|
cancelRunningRequests = (e) => {
|
|
1833
1833
|
this.runningRequests.get(e)?.forEach((e) => {
|
|
1834
|
-
let t =
|
|
1834
|
+
let t = U(e.request.abortKey, e.request.scope);
|
|
1835
1835
|
this.client.requestManager.abortByRequestId(t, e.requestId);
|
|
1836
1836
|
}), this.deleteRunningRequests(e);
|
|
1837
1837
|
};
|
|
1838
1838
|
cancelRunningRequest = (e, t) => {
|
|
1839
1839
|
let n = this.getRunningRequests(e).filter((e) => {
|
|
1840
1840
|
if (e.requestId === t) {
|
|
1841
|
-
let t =
|
|
1841
|
+
let t = U(e.request.abortKey, e.request.scope);
|
|
1842
1842
|
return this.client.requestManager.abortByRequestId(t, e.requestId), !1;
|
|
1843
1843
|
}
|
|
1844
1844
|
return !0;
|
|
@@ -1866,7 +1866,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1866
1866
|
resolved: !1
|
|
1867
1867
|
});
|
|
1868
1868
|
add = (e) => {
|
|
1869
|
-
let t =
|
|
1869
|
+
let t = U(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = An(e, i);
|
|
1870
1870
|
switch (this.logger.debug({
|
|
1871
1871
|
title: "Adding request to queue",
|
|
1872
1872
|
type: "system",
|
|
@@ -1876,9 +1876,9 @@ var Qt = 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 G.ONE_BY_ONE: return this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1880
|
+
case G.PREVIOUS_CANCELED: return this.cancelRunningRequests(t), this.clearQueue(t), this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1881
|
+
case G.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 Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1920
1920
|
requestId: n
|
|
1921
1921
|
}
|
|
1922
1922
|
});
|
|
1923
|
-
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l =
|
|
1923
|
+
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = U(a, c), u = U(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h = On(e.retries, r), g = !m.isOnline && s, _ = this.hasRunningRequest(l, n), v = e.stopped;
|
|
1924
1924
|
if (g || _ || v) return this.logger.warning({
|
|
1925
1925
|
title: "Unable to perform request",
|
|
1926
1926
|
type: "system",
|
|
@@ -1940,7 +1940,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1940
1940
|
}), this.incrementQueueRequestCount(l), f.addAbortController(u, n);
|
|
1941
1941
|
let b = await d.fetch(t, n);
|
|
1942
1942
|
e.resolved = !0, f.removeAbortController(u, n);
|
|
1943
|
-
let x = !m.isOnline, S =
|
|
1943
|
+
let x = !m.isOnline, S = H("abort").message === b.error?.message, C = !this.hasRunningRequest(l, n) || S;
|
|
1944
1944
|
this.deleteRunningRequest(l, n);
|
|
1945
1945
|
let w = b.success || !h || !t.retryOnError || t.retryOnError(b), T = !b.success && h && w && !C && !x, E = {
|
|
1946
1946
|
isCanceled: C,
|
|
@@ -2054,26 +2054,26 @@ var Qt = 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
|
+
}, Sn = () => "drained-event", Cn = (e) => `${e}-drained-event`, wn = () => "status-event", Tn = (e) => `${e}-status-event`, En = () => "change-event", Dn = (e) => `${e}-change-event`, On = (e, t) => !!(t && e < t), kn = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, An = (e, t) => {
|
|
2058
|
+
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? kn(e, t) : !1;
|
|
2059
|
+
return n ? G.ONE_BY_ONE : r ? G.PREVIOUS_CANCELED : a && i ? G.DEDUPLICATED : G.ALL_AT_ONCE;
|
|
2060
2060
|
};
|
|
2061
|
-
function
|
|
2061
|
+
function jn(e) {
|
|
2062
2062
|
return e === "client" || e === "server" ? e : typeof window < "u" && typeof document < "u" ? "client" : "server";
|
|
2063
2063
|
}
|
|
2064
|
-
var
|
|
2064
|
+
var Mn = async (e, t) => {
|
|
2065
2065
|
let n = t;
|
|
2066
2066
|
if (!t.requestOptions.disableRequestInterceptors) {
|
|
2067
2067
|
for (let r of e) if (n = await r(t), !n) throw Error("Request modifier must return request");
|
|
2068
2068
|
}
|
|
2069
2069
|
return n;
|
|
2070
|
-
},
|
|
2070
|
+
}, Nn = async (e, t, n) => {
|
|
2071
2071
|
let r = t;
|
|
2072
2072
|
if (!n.requestOptions.disableResponseInterceptors) {
|
|
2073
2073
|
for (let i of e) if (r = await i(t, n), !r) throw Error("Response modifier must return data");
|
|
2074
2074
|
}
|
|
2075
2075
|
return r;
|
|
2076
|
-
},
|
|
2076
|
+
}, Pn = class {
|
|
2077
2077
|
url;
|
|
2078
2078
|
mode;
|
|
2079
2079
|
debug;
|
|
@@ -2091,15 +2091,15 @@ var Nn = async (e, t) => {
|
|
|
2091
2091
|
submitDispatcher;
|
|
2092
2092
|
isMockerEnabled = !0;
|
|
2093
2093
|
plugins = [];
|
|
2094
|
-
unstable_abortKeyMapper =
|
|
2095
|
-
unstable_cacheKeyMapper =
|
|
2096
|
-
unstable_queryKeyMapper =
|
|
2097
|
-
unstable_requestIdMapper =
|
|
2094
|
+
unstable_abortKeyMapper = Ht;
|
|
2095
|
+
unstable_cacheKeyMapper = Ut;
|
|
2096
|
+
unstable_queryKeyMapper = Ut;
|
|
2097
|
+
unstable_requestIdMapper = Me;
|
|
2098
2098
|
logger = this.loggerManager.initialize(this, "Client");
|
|
2099
2099
|
constructor(e) {
|
|
2100
2100
|
this.options = e;
|
|
2101
2101
|
let { url: t, appManager: n, cache: r, fetchDispatcher: i, submitDispatcher: a, mode: o } = this.options;
|
|
2102
|
-
this.url = t, this.mode =
|
|
2102
|
+
this.url = t, this.mode = jn(o), this.adapter = un(), this.appManager = n?.() || new Ie(), this.cache = r?.() || new dn(), this.fetchDispatcher = i?.() || new xn(), this.submitDispatcher = a?.() || new xn(), this.adapter.initialize(this), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2103
2103
|
}
|
|
2104
2104
|
setDebug = (e) => (this.debug = e, this);
|
|
2105
2105
|
setLogLevel = (e) => (this.loggerManager.setSeverity(e), this);
|
|
@@ -2128,15 +2128,15 @@ var Nn = async (e, t) => {
|
|
|
2128
2128
|
setCacheKeyMapper = (e) => (this.unstable_cacheKeyMapper = e, this);
|
|
2129
2129
|
setQueryKeyMapper = (e) => (this.unstable_queryKeyMapper = e, this);
|
|
2130
2130
|
setRequestIdMapper = (e) => (this.unstable_requestIdMapper = e, this);
|
|
2131
|
-
unstable_modifyAuth = async (e) =>
|
|
2132
|
-
unstable_modifyRequest = async (e) =>
|
|
2133
|
-
unstable_modifyErrorResponse = async (e, t) =>
|
|
2134
|
-
unstable_modifySuccessResponse = async (e, t) =>
|
|
2135
|
-
unstable_modifyResponse = async (e, t) =>
|
|
2136
|
-
fromJSON = (e) =>
|
|
2131
|
+
unstable_modifyAuth = async (e) => Mn(this.unstable_onAuthCallbacks, e);
|
|
2132
|
+
unstable_modifyRequest = async (e) => Mn(this.unstable_onRequestCallbacks, e);
|
|
2133
|
+
unstable_modifyErrorResponse = async (e, t) => Nn(this.unstable_onErrorCallbacks, e, t);
|
|
2134
|
+
unstable_modifySuccessResponse = async (e, t) => Nn(this.unstable_onSuccessCallbacks, e, t);
|
|
2135
|
+
unstable_modifyResponse = async (e, t) => Nn(this.unstable_onResponseCallbacks, e, t);
|
|
2136
|
+
fromJSON = (e) => Jt.fromJSON(this, e);
|
|
2137
2137
|
clear = () => {
|
|
2138
2138
|
let { appManager: e, cache: t, fetchDispatcher: n, submitDispatcher: r } = this.options;
|
|
2139
|
-
this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new
|
|
2139
|
+
this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new dn(), this.appManager = e?.() || new Ie(), this.fetchDispatcher = n?.() || new xn(), this.submitDispatcher = r?.() || new xn(), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2140
2140
|
};
|
|
2141
2141
|
hydrate = (e, t) => {
|
|
2142
2142
|
e?.forEach((e) => {
|
|
@@ -2153,8 +2153,8 @@ var Nn = async (e, t) => {
|
|
|
2153
2153
|
...a,
|
|
2154
2154
|
...t
|
|
2155
2155
|
};
|
|
2156
|
-
if (!s.override && this.cache.get(
|
|
2157
|
-
let c =
|
|
2156
|
+
if (!s.override && this.cache.get(U(n, r))) return;
|
|
2157
|
+
let c = en(i);
|
|
2158
2158
|
this.cache.set({
|
|
2159
2159
|
...s,
|
|
2160
2160
|
cacheKey: n,
|
|
@@ -2166,10 +2166,10 @@ var Nn = async (e, t) => {
|
|
|
2166
2166
|
let t = this.adapter.unstable_endpointMapper(e.endpoint), n = {
|
|
2167
2167
|
...e,
|
|
2168
2168
|
endpoint: String(t)
|
|
2169
|
-
}, r = new
|
|
2169
|
+
}, r = new Jt(this, n);
|
|
2170
2170
|
return this.plugins.forEach((e) => e.trigger("onRequestCreate", { request: r })), r;
|
|
2171
2171
|
};
|
|
2172
|
-
},
|
|
2172
|
+
}, Fn = {
|
|
2173
2173
|
strict: !0,
|
|
2174
2174
|
encode: !0,
|
|
2175
2175
|
arrayFormat: "bracket",
|
|
@@ -2178,101 +2178,101 @@ var Nn = async (e, t) => {
|
|
|
2178
2178
|
skipNull: !0,
|
|
2179
2179
|
skipEmptyString: !0
|
|
2180
2180
|
};
|
|
2181
|
-
function
|
|
2182
|
-
return new
|
|
2181
|
+
function In(e) {
|
|
2182
|
+
return new Pn(e);
|
|
2183
2183
|
}
|
|
2184
2184
|
//#endregion
|
|
2185
2185
|
//#region src/core/client.ts
|
|
2186
|
-
var
|
|
2186
|
+
var K = In({ url: I() });
|
|
2187
2187
|
//#endregion
|
|
2188
2188
|
//#region src/core/auth-api.ts
|
|
2189
|
-
async function
|
|
2190
|
-
let { data: t, success: n } = await
|
|
2189
|
+
async function Ln(e) {
|
|
2190
|
+
let { data: t, success: n } = await K.createRequest()({
|
|
2191
2191
|
endpoint: "/auth/cli/whoami",
|
|
2192
2192
|
method: "GET"
|
|
2193
2193
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2194
2194
|
return !n || !t ? null : t;
|
|
2195
2195
|
}
|
|
2196
|
-
async function
|
|
2197
|
-
await
|
|
2196
|
+
async function Rn(e) {
|
|
2197
|
+
await K.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 zn = 1, Bn = "hype-stack", Vn = "auth.json";
|
|
2205
|
+
function Hn() {
|
|
2206
2206
|
let e = process.env.HYPE_STACK_CONFIG_DIR;
|
|
2207
|
-
if (e) return T.join(e,
|
|
2207
|
+
if (e) return T.join(e, Bn);
|
|
2208
2208
|
let t = w.homedir();
|
|
2209
2209
|
if (process.platform === "win32") {
|
|
2210
2210
|
let e = process.env.APPDATA ?? T.join(t, "AppData", "Roaming");
|
|
2211
|
-
return T.join(e,
|
|
2211
|
+
return T.join(e, Bn);
|
|
2212
2212
|
}
|
|
2213
|
-
if (process.platform === "darwin") return T.join(t, "Library", "Application Support",
|
|
2213
|
+
if (process.platform === "darwin") return T.join(t, "Library", "Application Support", Bn);
|
|
2214
2214
|
let n = process.env.XDG_CONFIG_HOME ?? T.join(t, ".config");
|
|
2215
|
-
return T.join(n,
|
|
2215
|
+
return T.join(n, Bn);
|
|
2216
2216
|
}
|
|
2217
|
-
function
|
|
2218
|
-
return T.join(
|
|
2217
|
+
function Un() {
|
|
2218
|
+
return T.join(Hn(), Vn);
|
|
2219
2219
|
}
|
|
2220
|
-
async function
|
|
2221
|
-
let e = await y.readFile(
|
|
2220
|
+
async function Wn() {
|
|
2221
|
+
let e = await y.readFile(Un(), "utf-8").catch(() => null);
|
|
2222
2222
|
if (!e) return {
|
|
2223
|
-
version:
|
|
2223
|
+
version: zn,
|
|
2224
2224
|
tokens: {}
|
|
2225
2225
|
};
|
|
2226
2226
|
let t = JSON.parse(e);
|
|
2227
2227
|
return {
|
|
2228
|
-
version: t.version ??
|
|
2228
|
+
version: t.version ?? zn,
|
|
2229
2229
|
tokens: t.tokens ?? {}
|
|
2230
2230
|
};
|
|
2231
2231
|
}
|
|
2232
|
-
async function
|
|
2233
|
-
let t =
|
|
2234
|
-
await y.mkdir(t, { recursive: !0 }), await y.writeFile(
|
|
2232
|
+
async function Gn(e) {
|
|
2233
|
+
let t = Hn();
|
|
2234
|
+
await y.mkdir(t, { recursive: !0 }), await y.writeFile(Un(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2235
2235
|
}
|
|
2236
|
-
async function
|
|
2237
|
-
return (await
|
|
2236
|
+
async function Kn(e) {
|
|
2237
|
+
return (await Wn()).tokens[e] ?? null;
|
|
2238
2238
|
}
|
|
2239
|
-
async function
|
|
2240
|
-
let n = await
|
|
2241
|
-
n.tokens[e] = t, await
|
|
2239
|
+
async function qn(e, t) {
|
|
2240
|
+
let n = await Wn();
|
|
2241
|
+
n.tokens[e] = t, await Gn(n);
|
|
2242
2242
|
}
|
|
2243
|
-
async function
|
|
2244
|
-
let t = await
|
|
2245
|
-
e in t.tokens && (delete t.tokens[e], await
|
|
2243
|
+
async function Jn(e) {
|
|
2244
|
+
let t = await Wn();
|
|
2245
|
+
e in t.tokens && (delete t.tokens[e], await Gn(t));
|
|
2246
2246
|
}
|
|
2247
2247
|
//#endregion
|
|
2248
2248
|
//#region src/core/device.ts
|
|
2249
|
-
function
|
|
2249
|
+
function Yn() {
|
|
2250
2250
|
let e = w.networkInterfaces();
|
|
2251
2251
|
for (let t of Object.values(e)) if (t) {
|
|
2252
2252
|
for (let e of t) if (!e.internal && e.mac !== "00:00:00:00:00:00") return e.mac;
|
|
2253
2253
|
}
|
|
2254
2254
|
return "unknown";
|
|
2255
2255
|
}
|
|
2256
|
-
function
|
|
2257
|
-
let e = `${
|
|
2256
|
+
function Xn() {
|
|
2257
|
+
let e = `${Yn()}:${w.hostname()}:${w.platform()}:${w.arch()}`;
|
|
2258
2258
|
return x("sha256").update(e).digest("hex").slice(0, 16);
|
|
2259
2259
|
}
|
|
2260
|
-
function
|
|
2260
|
+
function Zn() {
|
|
2261
2261
|
return `hype-stack/${A} ${w.platform()} ${w.arch()} node/${process.version.slice(1)}`;
|
|
2262
2262
|
}
|
|
2263
2263
|
//#endregion
|
|
2264
2264
|
//#region src/core/open-browser.ts
|
|
2265
|
-
function
|
|
2265
|
+
function Qn(e) {
|
|
2266
2266
|
E(process.platform === "darwin" ? `open "${e}"` : process.platform === "win32" ? `start "" "${e}"` : `xdg-open "${e}"`);
|
|
2267
2267
|
}
|
|
2268
2268
|
//#endregion
|
|
2269
2269
|
//#region src/core/login.ts
|
|
2270
|
-
var
|
|
2271
|
-
async function
|
|
2272
|
-
let t = S(16).toString("hex"), n =
|
|
2270
|
+
var $n = 300 * 1e3, er = (e) => `<!doctype html><html><head><meta charset="utf-8"><title>Hype Stack CLI</title></head><body style="font-family:system-ui,sans-serif;text-align:center;padding-top:4rem;color:#111"><h2>${e}</h2><p>You can close this tab and return to your terminal.</p></body></html>`;
|
|
2271
|
+
async function tr(e = {}) {
|
|
2272
|
+
let t = S(16).toString("hex"), n = I(), r = C.createServer(), i = await new Promise((n, i) => {
|
|
2273
2273
|
let a = setTimeout(() => {
|
|
2274
2274
|
o(), i(/* @__PURE__ */ Error("Login timed out. Run `npx @hype-stack/cli login` again."));
|
|
2275
|
-
},
|
|
2275
|
+
}, $n);
|
|
2276
2276
|
function o() {
|
|
2277
2277
|
clearTimeout(a), r.close(), r.closeAllConnections?.();
|
|
2278
2278
|
}
|
|
@@ -2286,7 +2286,7 @@ async function nr(e = {}) {
|
|
|
2286
2286
|
r.writeHead(200, {
|
|
2287
2287
|
"Content-Type": "text/html",
|
|
2288
2288
|
Connection: "close"
|
|
2289
|
-
}), r.end(
|
|
2289
|
+
}), r.end(er(e));
|
|
2290
2290
|
};
|
|
2291
2291
|
if (a.searchParams.get("state") !== t) {
|
|
2292
2292
|
s("Login failed."), o(), i(/* @__PURE__ */ Error("Login failed: state mismatch. Run `npx @hype-stack/cli login` again."));
|
|
@@ -2301,53 +2301,53 @@ async function nr(e = {}) {
|
|
|
2301
2301
|
}), r.on("error", (e) => {
|
|
2302
2302
|
o(), i(e);
|
|
2303
2303
|
}), r.listen(0, "127.0.0.1", () => {
|
|
2304
|
-
let { port: n } = r.address(), i = encodeURIComponent(
|
|
2305
|
-
e.onUrl?.(a),
|
|
2304
|
+
let { port: n } = r.address(), i = encodeURIComponent(Zn()), a = `${ce()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
|
|
2305
|
+
e.onUrl?.(a), Qn(a);
|
|
2306
2306
|
});
|
|
2307
|
-
}), a = await
|
|
2307
|
+
}), a = await Ln(i).catch(() => null), o = {
|
|
2308
2308
|
token: i,
|
|
2309
2309
|
email: a?.email,
|
|
2310
2310
|
organizationId: a?.organizationId
|
|
2311
2311
|
};
|
|
2312
|
-
return await
|
|
2312
|
+
return await qn(n, o), o;
|
|
2313
2313
|
}
|
|
2314
2314
|
//#endregion
|
|
2315
2315
|
//#region src/core/access-prompts.ts
|
|
2316
|
-
async function
|
|
2316
|
+
async function nr() {
|
|
2317
2317
|
let e = await s.confirm({ message: "Log in to install packs your organization owns? (opens your browser)" });
|
|
2318
2318
|
if (s.isCancel(e) || !e) return null;
|
|
2319
2319
|
s.log.step("Opening your browser to sign in...");
|
|
2320
2320
|
try {
|
|
2321
|
-
let e = await
|
|
2322
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
2321
|
+
let e = await tr({ onUrl: (e) => {
|
|
2322
|
+
s.log.info(`If your browser didn't open, visit:\n ${R.path(e)}`);
|
|
2323
2323
|
} });
|
|
2324
2324
|
return s.log.success(e.email ? `Logged in as ${e.email}` : "Logged in"), e.token;
|
|
2325
2325
|
} catch (e) {
|
|
2326
2326
|
return s.log.error(e instanceof Error ? e.message : String(e)), null;
|
|
2327
2327
|
}
|
|
2328
2328
|
}
|
|
2329
|
-
async function
|
|
2329
|
+
async function rr(e) {
|
|
2330
2330
|
if (e.length === 0) return;
|
|
2331
2331
|
s.note([
|
|
2332
2332
|
"These packs need a purchase before they can be installed:",
|
|
2333
2333
|
"",
|
|
2334
|
-
...e.map((e) => ` ${
|
|
2334
|
+
...e.map((e) => ` ${R.brand(e.displayName)} ${R.highlight(`$${e.price}`)}`)
|
|
2335
2335
|
].join("\n"), "Locked Packs");
|
|
2336
2336
|
let t = await s.confirm({ message: `Open the purchase ${e.length === 1 ? "page" : "pages"} in your browser?` });
|
|
2337
2337
|
if (s.isCancel(t) || !t) {
|
|
2338
|
-
s.log.info(
|
|
2338
|
+
s.log.info(R.muted("Run 'npx @hype-stack/cli login' after purchasing, then 'npx @hype-stack/cli compose' again."));
|
|
2339
2339
|
return;
|
|
2340
2340
|
}
|
|
2341
|
-
for (let t of e)
|
|
2341
|
+
for (let t of e) Qn(Se(t.name));
|
|
2342
2342
|
s.log.info([
|
|
2343
|
-
|
|
2344
|
-
` ${
|
|
2345
|
-
` ${
|
|
2343
|
+
R.muted("After purchasing, run:"),
|
|
2344
|
+
` ${R.highlight("npx @hype-stack/cli login")} ${R.muted("Save your access")}`,
|
|
2345
|
+
` ${R.highlight("npx @hype-stack/cli compose")} ${R.muted("Install the packs")}`
|
|
2346
2346
|
].join("\n"));
|
|
2347
2347
|
}
|
|
2348
2348
|
//#endregion
|
|
2349
2349
|
//#region src/utils/exec.ts
|
|
2350
|
-
function
|
|
2350
|
+
function q(e, t, n) {
|
|
2351
2351
|
return new Promise((r, i) => {
|
|
2352
2352
|
let a = D(e, t, {
|
|
2353
2353
|
cwd: n.cwd,
|
|
@@ -2378,7 +2378,7 @@ function K(e, t, n) {
|
|
|
2378
2378
|
});
|
|
2379
2379
|
});
|
|
2380
2380
|
}
|
|
2381
|
-
function
|
|
2381
|
+
function ir(e, t, n) {
|
|
2382
2382
|
return new Promise((r, i) => {
|
|
2383
2383
|
let a = D(e, t, {
|
|
2384
2384
|
cwd: n.cwd,
|
|
@@ -2395,7 +2395,7 @@ function ar(e, t, n) {
|
|
|
2395
2395
|
}
|
|
2396
2396
|
//#endregion
|
|
2397
2397
|
//#region src/utils/fs.ts
|
|
2398
|
-
async function
|
|
2398
|
+
async function ar(e) {
|
|
2399
2399
|
return (await y.stat(e).catch(() => null))?.isDirectory() ?? !1;
|
|
2400
2400
|
}
|
|
2401
2401
|
async function J(e) {
|
|
@@ -2413,7 +2413,7 @@ async function cr(e, t) {
|
|
|
2413
2413
|
}
|
|
2414
2414
|
async function lr(e) {
|
|
2415
2415
|
let t = {};
|
|
2416
|
-
if (!await
|
|
2416
|
+
if (!await ar(e)) return t;
|
|
2417
2417
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
2418
2418
|
for (let r of n) r.isDirectory() && await J(T.join(e, r.name, "package.json")) && (t[r.name] = T.relative(T.dirname(e), T.join(e, r.name)));
|
|
2419
2419
|
return t;
|
|
@@ -2430,28 +2430,41 @@ function dr(e, t) {
|
|
|
2430
2430
|
//#endregion
|
|
2431
2431
|
//#region src/core/codegen.ts
|
|
2432
2432
|
function fr(e) {
|
|
2433
|
-
s.log.info(
|
|
2434
|
-
`${
|
|
2435
|
-
`${
|
|
2436
|
-
`${
|
|
2433
|
+
s.log.info(R.muted("Run database setup yourself when ready:")), s.note([
|
|
2434
|
+
`${R.command(`cd ${e}`)}`,
|
|
2435
|
+
`${R.command("pnpm exec prisma generate")} ${R.muted("(regenerate the Prisma client)")}`,
|
|
2436
|
+
`${R.command("pnpm exec prisma migrate dev")} ${R.muted("(create + apply tables for new packs)")}`
|
|
2437
2437
|
].join("\n"), "Database Setup");
|
|
2438
2438
|
}
|
|
2439
2439
|
async function pr(e) {
|
|
2440
|
-
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, freshScaffold: a, runCommand: o =
|
|
2440
|
+
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, freshScaffold: a, runCommand: o = ir } = e, c = n.backend.root, l = T.join(t, c);
|
|
2441
2441
|
if (!await J(T.join(l, "package.json"))) return;
|
|
2442
|
+
if (!r) {
|
|
2443
|
+
s.log.step(R.muted(`Generating Prisma client (${R.command("prisma generate")})...`));
|
|
2444
|
+
let e = await o("pnpm", [
|
|
2445
|
+
"exec",
|
|
2446
|
+
"prisma",
|
|
2447
|
+
"generate"
|
|
2448
|
+
], { cwd: l });
|
|
2449
|
+
if (e.exitCode !== 0) {
|
|
2450
|
+
s.log.error(R.muted("prisma generate failed. See the output above, or finish setup manually:")), mr(e), fr(c);
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
s.log.success("Prisma client generated");
|
|
2454
|
+
}
|
|
2442
2455
|
if (r || i === !1) {
|
|
2443
2456
|
fr(c);
|
|
2444
2457
|
return;
|
|
2445
2458
|
}
|
|
2446
2459
|
let u = await s.confirm({
|
|
2447
|
-
message: `Run database setup now? (${
|
|
2460
|
+
message: `Run database setup now? (${R.command("prisma migrate dev")})`,
|
|
2448
2461
|
initialValue: !0
|
|
2449
2462
|
});
|
|
2450
2463
|
if (s.isCancel(u) || !u) {
|
|
2451
2464
|
fr(c);
|
|
2452
2465
|
return;
|
|
2453
2466
|
}
|
|
2454
|
-
s.log.step(
|
|
2467
|
+
s.log.step(R.muted(`Running ${R.command("prisma migrate dev --name add-packs")}...`));
|
|
2455
2468
|
let d = await o("pnpm", [
|
|
2456
2469
|
"exec",
|
|
2457
2470
|
"prisma",
|
|
@@ -2466,7 +2479,7 @@ async function pr(e) {
|
|
|
2466
2479
|
initialValue: !0
|
|
2467
2480
|
});
|
|
2468
2481
|
if (!s.isCancel(e) && e) {
|
|
2469
|
-
s.log.step(
|
|
2482
|
+
s.log.step(R.muted(`Resetting dev database (${R.command("prisma migrate reset --force")})...`));
|
|
2470
2483
|
let e = await o("pnpm", [
|
|
2471
2484
|
"exec",
|
|
2472
2485
|
"prisma",
|
|
@@ -2474,7 +2487,7 @@ async function pr(e) {
|
|
|
2474
2487
|
"reset",
|
|
2475
2488
|
"--force"
|
|
2476
2489
|
], { cwd: l });
|
|
2477
|
-
if (e.exitCode === 0) s.log.step(
|
|
2490
|
+
if (e.exitCode === 0) s.log.step(R.muted(`Running ${R.command("prisma migrate dev --name add-packs")}...`)), d = await o("pnpm", [
|
|
2478
2491
|
"exec",
|
|
2479
2492
|
"prisma",
|
|
2480
2493
|
"migrate",
|
|
@@ -2483,31 +2496,31 @@ async function pr(e) {
|
|
|
2483
2496
|
"add-packs"
|
|
2484
2497
|
], { cwd: l });
|
|
2485
2498
|
else {
|
|
2486
|
-
s.log.error(
|
|
2499
|
+
s.log.error(R.muted("prisma migrate reset did not complete. See the output above, or finish setup manually:")), mr(e), fr(c);
|
|
2487
2500
|
return;
|
|
2488
2501
|
}
|
|
2489
2502
|
}
|
|
2490
2503
|
}
|
|
2491
2504
|
if (d.exitCode !== 0) {
|
|
2492
|
-
s.log.error(
|
|
2505
|
+
s.log.error(R.muted("prisma migrate dev did not complete. See the output above, or finish setup manually:")), mr(d), fr(c);
|
|
2493
2506
|
return;
|
|
2494
2507
|
}
|
|
2495
2508
|
s.log.success("Database schema applied");
|
|
2496
2509
|
}
|
|
2497
2510
|
function mr(e) {
|
|
2498
2511
|
let t = (e.stderr || e.stdout).trim();
|
|
2499
|
-
t && s.log.warn(
|
|
2512
|
+
t && s.log.warn(R.muted(t));
|
|
2500
2513
|
}
|
|
2501
2514
|
//#endregion
|
|
2502
2515
|
//#region src/core/stack-config.ts
|
|
2503
2516
|
async function hr(e) {
|
|
2504
|
-
return sr(T.join(e,
|
|
2517
|
+
return sr(T.join(e, te));
|
|
2505
2518
|
}
|
|
2506
2519
|
async function gr(e) {
|
|
2507
|
-
return J(T.join(e,
|
|
2520
|
+
return J(T.join(e, te));
|
|
2508
2521
|
}
|
|
2509
2522
|
async function _r(e, t) {
|
|
2510
|
-
await cr(T.join(e,
|
|
2523
|
+
await cr(T.join(e, te), t);
|
|
2511
2524
|
}
|
|
2512
2525
|
async function vr(e) {
|
|
2513
2526
|
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([lr(t), lr(n)]);
|
|
@@ -2552,7 +2565,7 @@ function yr(e) {
|
|
|
2552
2565
|
}
|
|
2553
2566
|
function br(e, t) {
|
|
2554
2567
|
return {
|
|
2555
|
-
$schema:
|
|
2568
|
+
$schema: ue(),
|
|
2556
2569
|
version: 1,
|
|
2557
2570
|
name: e,
|
|
2558
2571
|
apps: t.apps,
|
|
@@ -2563,7 +2576,7 @@ function br(e, t) {
|
|
|
2563
2576
|
};
|
|
2564
2577
|
}
|
|
2565
2578
|
async function xr(e) {
|
|
2566
|
-
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t),
|
|
2579
|
+
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t), ar(n)]);
|
|
2567
2580
|
return r && i;
|
|
2568
2581
|
}
|
|
2569
2582
|
function Y(e, t) {
|
|
@@ -2578,7 +2591,7 @@ function Y(e, t) {
|
|
|
2578
2591
|
//#endregion
|
|
2579
2592
|
//#region src/core/registry.ts
|
|
2580
2593
|
async function Sr(e) {
|
|
2581
|
-
let { data: t, error: n, status: r } = await
|
|
2594
|
+
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
2582
2595
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2583
2596
|
method: "GET"
|
|
2584
2597
|
}).send();
|
|
@@ -2587,12 +2600,12 @@ async function Sr(e) {
|
|
|
2587
2600
|
return t;
|
|
2588
2601
|
}
|
|
2589
2602
|
async function Cr(e, t = {}) {
|
|
2590
|
-
let n =
|
|
2603
|
+
let n = K.createRequest()({
|
|
2591
2604
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2592
2605
|
method: "POST"
|
|
2593
2606
|
}), r = {
|
|
2594
|
-
"X-Device-Id":
|
|
2595
|
-
"X-Client-Info":
|
|
2607
|
+
"X-Device-Id": Xn(),
|
|
2608
|
+
"X-Client-Info": Zn()
|
|
2596
2609
|
};
|
|
2597
2610
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2598
2611
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -2619,7 +2632,7 @@ function wr(e, t, n) {
|
|
|
2619
2632
|
function Tr(e, t) {
|
|
2620
2633
|
return T.join(t, e);
|
|
2621
2634
|
}
|
|
2622
|
-
var Er =
|
|
2635
|
+
var Er = K.createRequest()({
|
|
2623
2636
|
endpoint: "/packs/list",
|
|
2624
2637
|
method: "GET"
|
|
2625
2638
|
});
|
|
@@ -2630,7 +2643,7 @@ async function Dr() {
|
|
|
2630
2643
|
}
|
|
2631
2644
|
async function Or(e, t = {}) {
|
|
2632
2645
|
if (e.length === 0) return {};
|
|
2633
|
-
let n =
|
|
2646
|
+
let n = K.createRequest()({
|
|
2634
2647
|
endpoint: "/packs/authorize",
|
|
2635
2648
|
method: "POST"
|
|
2636
2649
|
}), r = {};
|
|
@@ -3085,8 +3098,8 @@ async function Mi(e) {
|
|
|
3085
3098
|
return {
|
|
3086
3099
|
sourcePath: a,
|
|
3087
3100
|
targetPath: o,
|
|
3088
|
-
sourceExists: await J(a) || await
|
|
3089
|
-
targetExists: await J(o) || await
|
|
3101
|
+
sourceExists: await J(a) || await ar(a),
|
|
3102
|
+
targetExists: await J(o) || await ar(o)
|
|
3090
3103
|
};
|
|
3091
3104
|
}
|
|
3092
3105
|
async function Ni(e) {
|
|
@@ -3325,7 +3338,7 @@ async function Bi(e) {
|
|
|
3325
3338
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3326
3339
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3327
3340
|
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) => Tr(e.source, i))), u = T.join(i, "files");
|
|
3328
|
-
if (await
|
|
3341
|
+
if (await ar(u)) {
|
|
3329
3342
|
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3330
3343
|
for (let t of e) {
|
|
3331
3344
|
if (!t.isDirectory()) continue;
|
|
@@ -3375,15 +3388,19 @@ var Vi = [
|
|
|
3375
3388
|
starter: "Starter",
|
|
3376
3389
|
layout: "Layout",
|
|
3377
3390
|
feature: "Features"
|
|
3378
|
-
}, Ui = new Set(["starter", "layout"]), Wi = "layout-basic";
|
|
3379
|
-
function
|
|
3391
|
+
}, Ui = new Set(["starter", "layout"]), Wi = "starter-saas-betterauth", Gi = "layout-basic";
|
|
3392
|
+
function Ki(e, t = {}) {
|
|
3380
3393
|
let n = [];
|
|
3381
3394
|
for (let r of Vi) {
|
|
3382
3395
|
let i = e.filter((e) => e.category === r);
|
|
3383
3396
|
if (i.length === 0) continue;
|
|
3384
3397
|
let a = Ui.has(r) ? "single" : "multiple";
|
|
3385
3398
|
if (r === "layout") {
|
|
3386
|
-
n.push(
|
|
3399
|
+
n.push(Ji("frontend", i)), t.adminAvailable && n.push(Ji("admin", i));
|
|
3400
|
+
continue;
|
|
3401
|
+
}
|
|
3402
|
+
if (r === "starter") {
|
|
3403
|
+
n.push(qi(i));
|
|
3387
3404
|
continue;
|
|
3388
3405
|
}
|
|
3389
3406
|
n.push({
|
|
@@ -3396,55 +3413,65 @@ function Gi(e, t = {}) {
|
|
|
3396
3413
|
}
|
|
3397
3414
|
return n;
|
|
3398
3415
|
}
|
|
3399
|
-
function
|
|
3400
|
-
let
|
|
3416
|
+
function qi(e) {
|
|
3417
|
+
let t = e.some((e) => e.name === Wi);
|
|
3418
|
+
return {
|
|
3419
|
+
category: "starter",
|
|
3420
|
+
label: Hi.starter,
|
|
3421
|
+
mode: "single",
|
|
3422
|
+
packs: e,
|
|
3423
|
+
preselect: t ? Wi : null
|
|
3424
|
+
};
|
|
3425
|
+
}
|
|
3426
|
+
function Ji(e, t) {
|
|
3427
|
+
let n = t.some((e) => e.name === Gi);
|
|
3401
3428
|
return {
|
|
3402
3429
|
category: "layout",
|
|
3403
3430
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3404
3431
|
mode: "single",
|
|
3405
3432
|
packs: t,
|
|
3406
|
-
preselect: n ?
|
|
3433
|
+
preselect: n ? Gi : null,
|
|
3407
3434
|
slot: e
|
|
3408
3435
|
};
|
|
3409
3436
|
}
|
|
3410
3437
|
//#endregion
|
|
3411
3438
|
//#region src/ui/logger.ts
|
|
3412
|
-
function
|
|
3413
|
-
s.note(e.map((e) => `${
|
|
3439
|
+
function Yi(e) {
|
|
3440
|
+
s.note(e.map((e) => `${z.arrow} ${e}`).join("\n"), "Next steps");
|
|
3414
3441
|
}
|
|
3415
3442
|
function X() {
|
|
3416
|
-
s.cancel(
|
|
3443
|
+
s.cancel(R.muted("Operation cancelled.")), process.exit(0);
|
|
3417
3444
|
}
|
|
3418
3445
|
//#endregion
|
|
3419
3446
|
//#region src/core/post-setup.ts
|
|
3420
|
-
async function
|
|
3421
|
-
return (await
|
|
3447
|
+
async function Xi() {
|
|
3448
|
+
return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3422
3449
|
}
|
|
3423
|
-
async function
|
|
3450
|
+
async function Zi(e) {
|
|
3424
3451
|
return J(`${e}/apps/backend/.env`);
|
|
3425
3452
|
}
|
|
3426
|
-
async function
|
|
3427
|
-
let r = n ? `Start services with ${
|
|
3453
|
+
async function Qi(e, t, n) {
|
|
3454
|
+
let r = n ? `Start services with ${R.command("docker compose up -d")}?` : `Docker is not running. Start services with ${R.command("docker compose up -d")}?`, i = t ? !0 : await s.confirm({
|
|
3428
3455
|
message: r,
|
|
3429
3456
|
initialValue: !0
|
|
3430
3457
|
});
|
|
3431
|
-
if (s.isCancel(i) && X(), !i) return s.log.info(
|
|
3458
|
+
if (s.isCancel(i) && X(), !i) return s.log.info(R.muted("Skipping Docker services and database migrations.")), !1;
|
|
3432
3459
|
let a = s.spinner();
|
|
3433
3460
|
a.start("Starting Docker services...");
|
|
3434
|
-
let o = await
|
|
3461
|
+
let o = await q("docker", [
|
|
3435
3462
|
"compose",
|
|
3436
3463
|
"up",
|
|
3437
3464
|
"-d"
|
|
3438
3465
|
], { cwd: `${e}/apps/backend` });
|
|
3439
|
-
return o.exitCode === 0 ? (a.stop(
|
|
3466
|
+
return o.exitCode === 0 ? (a.stop(R.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), $i(o), !1);
|
|
3440
3467
|
}
|
|
3441
|
-
function
|
|
3468
|
+
function $i(e) {
|
|
3442
3469
|
let t = (e.stderr || e.stdout).trim();
|
|
3443
|
-
t && s.log.warn(
|
|
3470
|
+
t && s.log.warn(R.muted(t));
|
|
3444
3471
|
}
|
|
3445
|
-
async function
|
|
3472
|
+
async function ea(e, t = 15, n = 2e3) {
|
|
3446
3473
|
for (let r = 0; r < t; r++) {
|
|
3447
|
-
if ((await
|
|
3474
|
+
if ((await q("docker", [
|
|
3448
3475
|
"compose",
|
|
3449
3476
|
"exec",
|
|
3450
3477
|
"-T",
|
|
@@ -3457,9 +3484,9 @@ async function Qi(e, t = 15, n = 2e3) {
|
|
|
3457
3484
|
}
|
|
3458
3485
|
return !1;
|
|
3459
3486
|
}
|
|
3460
|
-
var
|
|
3461
|
-
async function
|
|
3462
|
-
let t = await
|
|
3487
|
+
var ta = "Database schema is up to date";
|
|
3488
|
+
async function na(e) {
|
|
3489
|
+
let t = await q("pnpm", [
|
|
3463
3490
|
"--filter",
|
|
3464
3491
|
"@internal/backend",
|
|
3465
3492
|
"exec",
|
|
@@ -3467,48 +3494,48 @@ async function ea(e) {
|
|
|
3467
3494
|
"migrate",
|
|
3468
3495
|
"status"
|
|
3469
3496
|
], { cwd: e });
|
|
3470
|
-
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(
|
|
3497
|
+
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(ta) : !1;
|
|
3471
3498
|
}
|
|
3472
|
-
async function
|
|
3499
|
+
async function ra(e) {
|
|
3473
3500
|
let t = s.spinner();
|
|
3474
3501
|
t.start("Running database migrations...");
|
|
3475
|
-
let n = await
|
|
3502
|
+
let n = await q("pnpm", [
|
|
3476
3503
|
"--filter",
|
|
3477
3504
|
"@internal/backend",
|
|
3478
3505
|
"migration:latest"
|
|
3479
3506
|
], { cwd: e });
|
|
3480
|
-
return n.exitCode === 0 ? (t.stop(
|
|
3507
|
+
return n.exitCode === 0 ? (t.stop(R.success("Database migrations applied")), !0) : (t.error("Migrations failed"), $i(n), s.log.warn(R.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations.")), !1);
|
|
3481
3508
|
}
|
|
3482
|
-
async function
|
|
3483
|
-
if (!await
|
|
3509
|
+
async function ia(e, t, n = {}) {
|
|
3510
|
+
if (!await Qi(e, t, await Xi())) return !1;
|
|
3484
3511
|
let r = s.spinner();
|
|
3485
|
-
return r.start("Waiting for Postgres to be ready..."), await
|
|
3512
|
+
return r.start("Waiting for Postgres to be ready..."), await ea(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3) ? (r.stop(R.success("Postgres is ready")), !0) : (r.error("Postgres health check timed out"), s.log.warn(R.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest")), !1);
|
|
3486
3513
|
}
|
|
3487
|
-
async function
|
|
3488
|
-
if (!await
|
|
3514
|
+
async function aa(e, t, n = {}) {
|
|
3515
|
+
if (!await ia(e, t, n)) return;
|
|
3489
3516
|
let r = t ? !0 : await s.confirm({
|
|
3490
|
-
message: `Run database migrations with ${
|
|
3517
|
+
message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
|
|
3491
3518
|
initialValue: !0
|
|
3492
3519
|
});
|
|
3493
3520
|
if (s.isCancel(r) && X(), !r) {
|
|
3494
|
-
s.log.info(
|
|
3521
|
+
s.log.info(R.muted("Skipping database migrations."));
|
|
3495
3522
|
return;
|
|
3496
3523
|
}
|
|
3497
|
-
await
|
|
3524
|
+
await ra(e);
|
|
3498
3525
|
}
|
|
3499
|
-
async function
|
|
3500
|
-
if (!await
|
|
3501
|
-
s.log.warn(`${
|
|
3526
|
+
async function oa(e, t, n = {}) {
|
|
3527
|
+
if (!await Zi(e)) {
|
|
3528
|
+
s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3502
3529
|
return;
|
|
3503
3530
|
}
|
|
3504
|
-
await
|
|
3531
|
+
await aa(e, t, n);
|
|
3505
3532
|
}
|
|
3506
|
-
async function
|
|
3507
|
-
return await
|
|
3533
|
+
async function sa(e, t, n = {}) {
|
|
3534
|
+
return await Zi(e) ? ia(e, t, n) : (s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker - configure it first.`), !1);
|
|
3508
3535
|
}
|
|
3509
3536
|
//#endregion
|
|
3510
3537
|
//#region src/core/resolve.ts
|
|
3511
|
-
function
|
|
3538
|
+
function ca(e) {
|
|
3512
3539
|
let t = /* @__PURE__ */ new Map();
|
|
3513
3540
|
for (let n of e) t.set(n.name, {
|
|
3514
3541
|
name: n.name,
|
|
@@ -3516,7 +3543,7 @@ function oa(e) {
|
|
|
3516
3543
|
});
|
|
3517
3544
|
return t;
|
|
3518
3545
|
}
|
|
3519
|
-
function
|
|
3546
|
+
function la(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3520
3547
|
let r = /* @__PURE__ */ new Set();
|
|
3521
3548
|
function i(e) {
|
|
3522
3549
|
if (n.has(e)) return [];
|
|
@@ -3530,10 +3557,10 @@ function sa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3530
3557
|
}
|
|
3531
3558
|
return i(e);
|
|
3532
3559
|
}
|
|
3533
|
-
function
|
|
3560
|
+
function ua(e, t, n = []) {
|
|
3534
3561
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3535
3562
|
for (let n of e) {
|
|
3536
|
-
let e =
|
|
3563
|
+
let e = la(n, t, new Set(i));
|
|
3537
3564
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3538
3565
|
}
|
|
3539
3566
|
return {
|
|
@@ -3541,7 +3568,7 @@ function ca(e, t, n = []) {
|
|
|
3541
3568
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3542
3569
|
};
|
|
3543
3570
|
}
|
|
3544
|
-
function
|
|
3571
|
+
function da(e) {
|
|
3545
3572
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3546
3573
|
for (let e of t) {
|
|
3547
3574
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3554,7 +3581,7 @@ function la(e) {
|
|
|
3554
3581
|
}
|
|
3555
3582
|
//#endregion
|
|
3556
3583
|
//#region src/core/variants.ts
|
|
3557
|
-
function
|
|
3584
|
+
function fa(e, t = {}) {
|
|
3558
3585
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3559
3586
|
for (let i of e) {
|
|
3560
3587
|
let e = t[i.family] ?? i.default;
|
|
@@ -3566,14 +3593,14 @@ function ua(e, t = {}) {
|
|
|
3566
3593
|
familyOf: r
|
|
3567
3594
|
};
|
|
3568
3595
|
}
|
|
3569
|
-
function
|
|
3596
|
+
function pa(e, t, n) {
|
|
3570
3597
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3571
3598
|
}
|
|
3572
|
-
function
|
|
3599
|
+
function ma(e, t) {
|
|
3573
3600
|
let n = t.familyOf.get(e);
|
|
3574
3601
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3575
3602
|
}
|
|
3576
|
-
function
|
|
3603
|
+
function ha(e, t) {
|
|
3577
3604
|
let n = /* @__PURE__ */ new Map();
|
|
3578
3605
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3579
3606
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3589,65 +3616,65 @@ function pa(e, t) {
|
|
|
3589
3616
|
familyOf: n
|
|
3590
3617
|
};
|
|
3591
3618
|
}
|
|
3592
|
-
function
|
|
3619
|
+
function ga(e, t) {
|
|
3593
3620
|
return e.map((e) => ({
|
|
3594
3621
|
...e,
|
|
3595
|
-
dependencies: e.dependencies.map((e) =>
|
|
3622
|
+
dependencies: e.dependencies.map((e) => ma(e, t))
|
|
3596
3623
|
}));
|
|
3597
3624
|
}
|
|
3598
3625
|
//#endregion
|
|
3599
3626
|
//#region src/ui/banner.ts
|
|
3600
|
-
var
|
|
3627
|
+
var _a = [
|
|
3601
3628
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3602
3629
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3603
3630
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3604
3631
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3605
3632
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3606
3633
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3607
|
-
],
|
|
3634
|
+
], va = [
|
|
3608
3635
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3609
3636
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3610
3637
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3611
3638
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3612
3639
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3613
3640
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3614
|
-
],
|
|
3641
|
+
], ya = [
|
|
3615
3642
|
253,
|
|
3616
3643
|
176,
|
|
3617
3644
|
21
|
|
3618
|
-
],
|
|
3645
|
+
], ba = [
|
|
3619
3646
|
245,
|
|
3620
3647
|
76,
|
|
3621
3648
|
2
|
|
3622
|
-
],
|
|
3649
|
+
], xa = 5, Sa = [
|
|
3623
3650
|
17,
|
|
3624
3651
|
103,
|
|
3625
3652
|
248
|
|
3626
|
-
],
|
|
3653
|
+
], Ca = [
|
|
3627
3654
|
42,
|
|
3628
3655
|
160,
|
|
3629
3656
|
250
|
|
3630
|
-
],
|
|
3631
|
-
function
|
|
3657
|
+
], wa = .2;
|
|
3658
|
+
function Ta() {
|
|
3632
3659
|
console.log();
|
|
3633
|
-
for (let e of
|
|
3634
|
-
start:
|
|
3635
|
-
end:
|
|
3636
|
-
angle:
|
|
3660
|
+
for (let e of xe(_a, {
|
|
3661
|
+
start: ya,
|
|
3662
|
+
end: ba,
|
|
3663
|
+
angle: xa
|
|
3637
3664
|
})) console.log(b.bold(e));
|
|
3638
|
-
for (let e of
|
|
3639
|
-
start:
|
|
3640
|
-
end:
|
|
3641
|
-
angle:
|
|
3665
|
+
for (let e of xe(va, {
|
|
3666
|
+
start: Sa,
|
|
3667
|
+
end: Ca,
|
|
3668
|
+
angle: wa
|
|
3642
3669
|
})) console.log(b.bold(e));
|
|
3643
|
-
console.log(), console.log(` ${
|
|
3670
|
+
console.log(), console.log(` ${z.spark} ${b.dim("v" + A)} ${b.dim("·")} ${ye("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3644
3671
|
}
|
|
3645
|
-
function
|
|
3646
|
-
console.log(), console.log(` ${
|
|
3672
|
+
function Ea() {
|
|
3673
|
+
console.log(), console.log(` ${z.bolt} ${ge.orange("Hype")}${ge.skyBlue("Stack")} ${b.dim("v" + A)}`), console.log();
|
|
3647
3674
|
}
|
|
3648
3675
|
//#endregion
|
|
3649
3676
|
//#region src/ui/pack-multiselect.ts
|
|
3650
|
-
var
|
|
3677
|
+
var Da = class extends O {
|
|
3651
3678
|
options;
|
|
3652
3679
|
cursor = 0;
|
|
3653
3680
|
selected;
|
|
@@ -3751,44 +3778,44 @@ var Ta = class extends O {
|
|
|
3751
3778
|
}
|
|
3752
3779
|
}
|
|
3753
3780
|
};
|
|
3754
|
-
function
|
|
3755
|
-
return new
|
|
3781
|
+
function Oa(e) {
|
|
3782
|
+
return new Da(e).prompt();
|
|
3756
3783
|
}
|
|
3757
3784
|
//#endregion
|
|
3758
3785
|
//#region src/utils/naming.ts
|
|
3759
|
-
function
|
|
3786
|
+
function ka(e) {
|
|
3760
3787
|
return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3761
3788
|
}
|
|
3762
|
-
function
|
|
3789
|
+
function Aa(e) {
|
|
3763
3790
|
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3764
3791
|
}
|
|
3765
3792
|
//#endregion
|
|
3766
3793
|
//#region src/utils/validate.ts
|
|
3767
|
-
function
|
|
3794
|
+
function ja(e) {
|
|
3768
3795
|
if (!e.trim()) return "Project name cannot be empty";
|
|
3769
3796
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
3770
|
-
let t =
|
|
3771
|
-
if (!
|
|
3797
|
+
let t = ka(e);
|
|
3798
|
+
if (!re.test(t)) return "Project name must contain at least one letter or number";
|
|
3772
3799
|
}
|
|
3773
3800
|
//#endregion
|
|
3774
3801
|
//#region src/core/apply-mode.ts
|
|
3775
|
-
var
|
|
3776
|
-
function
|
|
3777
|
-
return e.replace(
|
|
3802
|
+
var Ma = "src/hooks/use-theme.ts", Na = /(\bexport\s+const\s+defaultTheme\s*=\s*)(["'])(?:light|dark)\2/;
|
|
3803
|
+
function Pa(e, t) {
|
|
3804
|
+
return e.replace(Na, (e, n, r) => `${n}${r}${t}${r}`);
|
|
3778
3805
|
}
|
|
3779
|
-
async function
|
|
3780
|
-
let n = T.resolve(e,
|
|
3806
|
+
async function Fa(e, t) {
|
|
3807
|
+
let n = T.resolve(e, Ma), r;
|
|
3781
3808
|
try {
|
|
3782
3809
|
r = await y.readFile(n, "utf-8");
|
|
3783
3810
|
} catch {
|
|
3784
3811
|
return !1;
|
|
3785
3812
|
}
|
|
3786
|
-
let i =
|
|
3813
|
+
let i = Pa(r, t);
|
|
3787
3814
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3788
3815
|
}
|
|
3789
3816
|
//#endregion
|
|
3790
3817
|
//#region src/core/apply-theme.ts
|
|
3791
|
-
function
|
|
3818
|
+
function Ia(e, t) {
|
|
3792
3819
|
let n = e.indexOf(t);
|
|
3793
3820
|
if (n === -1) return null;
|
|
3794
3821
|
let r = e.indexOf("{", n);
|
|
@@ -3803,46 +3830,46 @@ function Pa(e, t) {
|
|
|
3803
3830
|
bodyEnd: a - 1
|
|
3804
3831
|
} : null;
|
|
3805
3832
|
}
|
|
3806
|
-
function
|
|
3833
|
+
function La(e, t) {
|
|
3807
3834
|
let n = e;
|
|
3808
3835
|
for (let [e, r] of Object.entries(t)) {
|
|
3809
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3836
|
+
let t = RegExp(`(^[ \\t]*--${Ra(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3810
3837
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3811
3838
|
}
|
|
3812
3839
|
return n;
|
|
3813
3840
|
}
|
|
3814
|
-
function
|
|
3841
|
+
function Ra(e) {
|
|
3815
3842
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3816
3843
|
}
|
|
3817
|
-
function
|
|
3818
|
-
let n =
|
|
3844
|
+
function za(e, t) {
|
|
3845
|
+
let n = Ia(e, ":root"), r = Ia(e, ".dark"), i = e;
|
|
3819
3846
|
if (n) {
|
|
3820
3847
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3821
|
-
i = e +
|
|
3848
|
+
i = e + La(r, t.light) + a;
|
|
3822
3849
|
}
|
|
3823
3850
|
if (r) {
|
|
3824
|
-
let e =
|
|
3851
|
+
let e = Ia(i, ".dark");
|
|
3825
3852
|
if (e) {
|
|
3826
3853
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3827
|
-
i = n +
|
|
3854
|
+
i = n + La(r, t.dark) + a;
|
|
3828
3855
|
}
|
|
3829
3856
|
}
|
|
3830
3857
|
return i;
|
|
3831
3858
|
}
|
|
3832
|
-
var
|
|
3833
|
-
async function
|
|
3834
|
-
let n = T.resolve(e,
|
|
3859
|
+
var Ba = "assets/styles.css";
|
|
3860
|
+
async function Va(e, t) {
|
|
3861
|
+
let n = T.resolve(e, Ba), r;
|
|
3835
3862
|
try {
|
|
3836
3863
|
r = await y.readFile(n, "utf-8");
|
|
3837
3864
|
} catch {
|
|
3838
3865
|
return !1;
|
|
3839
3866
|
}
|
|
3840
|
-
let i =
|
|
3867
|
+
let i = za(r, t);
|
|
3841
3868
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3842
3869
|
}
|
|
3843
3870
|
//#endregion
|
|
3844
3871
|
//#region src/core/clone.ts
|
|
3845
|
-
async function
|
|
3872
|
+
async function Ha(e) {
|
|
3846
3873
|
let t = await ee(j, {
|
|
3847
3874
|
dir: e,
|
|
3848
3875
|
force: !0
|
|
@@ -3854,7 +3881,7 @@ async function Ba(e) {
|
|
|
3854
3881
|
}
|
|
3855
3882
|
//#endregion
|
|
3856
3883
|
//#region src/core/editor-config.ts
|
|
3857
|
-
function
|
|
3884
|
+
function Ua(e) {
|
|
3858
3885
|
let t = {
|
|
3859
3886
|
globs: [],
|
|
3860
3887
|
alwaysApply: !1
|
|
@@ -3889,10 +3916,10 @@ function Va(e) {
|
|
|
3889
3916
|
content: i
|
|
3890
3917
|
};
|
|
3891
3918
|
}
|
|
3892
|
-
function
|
|
3919
|
+
function Wa(e) {
|
|
3893
3920
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
3894
3921
|
}
|
|
3895
|
-
function
|
|
3922
|
+
function Ga(e) {
|
|
3896
3923
|
let t;
|
|
3897
3924
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
3898
3925
|
let n = [`trigger: ${t}`];
|
|
@@ -3902,30 +3929,30 @@ function Ua(e) {
|
|
|
3902
3929
|
}
|
|
3903
3930
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
3904
3931
|
}
|
|
3905
|
-
function
|
|
3932
|
+
function Ka(e) {
|
|
3906
3933
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
3907
3934
|
}
|
|
3908
|
-
var
|
|
3935
|
+
var qa = {
|
|
3909
3936
|
claude: {
|
|
3910
3937
|
rulesDir: ".claude/rules",
|
|
3911
3938
|
extension: ".md",
|
|
3912
|
-
convert:
|
|
3939
|
+
convert: Wa
|
|
3913
3940
|
},
|
|
3914
3941
|
windsurf: {
|
|
3915
3942
|
rulesDir: ".windsurf/rules",
|
|
3916
3943
|
extension: ".md",
|
|
3917
|
-
convert:
|
|
3944
|
+
convert: Ga
|
|
3918
3945
|
},
|
|
3919
3946
|
copilot: {
|
|
3920
3947
|
rulesDir: ".github/instructions",
|
|
3921
3948
|
extension: ".instructions.md",
|
|
3922
|
-
convert:
|
|
3949
|
+
convert: Ka
|
|
3923
3950
|
}
|
|
3924
3951
|
};
|
|
3925
|
-
async function
|
|
3926
|
-
let t = T.join(e,
|
|
3952
|
+
async function Ja(e) {
|
|
3953
|
+
let t = T.join(e, ae), n = (await y.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
3927
3954
|
return await Promise.all(n.map(async (e) => {
|
|
3928
|
-
let n = T.join(t, e.name), { frontmatter: r, content: i } =
|
|
3955
|
+
let n = T.join(t, e.name), { frontmatter: r, content: i } = Ua(await y.readFile(n, "utf-8"));
|
|
3929
3956
|
return {
|
|
3930
3957
|
frontmatter: r,
|
|
3931
3958
|
content: i,
|
|
@@ -3933,31 +3960,31 @@ async function Ka(e) {
|
|
|
3933
3960
|
};
|
|
3934
3961
|
}));
|
|
3935
3962
|
}
|
|
3936
|
-
async function
|
|
3963
|
+
async function Ya(e, t) {
|
|
3937
3964
|
if (t === "cursor") return;
|
|
3938
|
-
let n =
|
|
3965
|
+
let n = qa[t], r = await Ja(e), i = T.join(e, n.rulesDir);
|
|
3939
3966
|
await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
3940
3967
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3941
3968
|
return y.writeFile(T.join(i, r), t, "utf-8");
|
|
3942
|
-
})), await ur(T.join(e,
|
|
3969
|
+
})), await ur(T.join(e, oe)), await ur(T.join(e, se));
|
|
3943
3970
|
}
|
|
3944
3971
|
//#endregion
|
|
3945
3972
|
//#region src/core/env-files.ts
|
|
3946
|
-
var
|
|
3973
|
+
var Xa = [
|
|
3947
3974
|
"apps",
|
|
3948
3975
|
"packages",
|
|
3949
3976
|
"libs",
|
|
3950
3977
|
"shared"
|
|
3951
3978
|
];
|
|
3952
|
-
async function
|
|
3953
|
-
let t = await
|
|
3979
|
+
async function Za(e) {
|
|
3980
|
+
let t = await Qa(e);
|
|
3954
3981
|
return (await Promise.all(t.map(async (t) => {
|
|
3955
3982
|
let n = T.join(T.dirname(t), ".env");
|
|
3956
3983
|
return await J(n) ? null : (await y.copyFile(t, n), T.relative(e, n));
|
|
3957
3984
|
}))).filter((e) => e !== null).sort();
|
|
3958
3985
|
}
|
|
3959
|
-
async function
|
|
3960
|
-
let t = [T.join(e, ".env.example")], n = await Promise.all(
|
|
3986
|
+
async function Qa(e) {
|
|
3987
|
+
let t = [T.join(e, ".env.example")], n = await Promise.all(Xa.map(async (t) => {
|
|
3961
3988
|
let n = T.join(e, t);
|
|
3962
3989
|
return (await y.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => T.join(n, e.name, ".env.example"));
|
|
3963
3990
|
}));
|
|
@@ -3965,12 +3992,12 @@ async function Xa(e) {
|
|
|
3965
3992
|
}
|
|
3966
3993
|
//#endregion
|
|
3967
3994
|
//#region src/core/post-clone.ts
|
|
3968
|
-
var Z = "@hype-stack/",
|
|
3969
|
-
async function
|
|
3995
|
+
var Z = "@hype-stack/", $a = "hype-stack";
|
|
3996
|
+
async function eo(e) {
|
|
3970
3997
|
await ur(T.join(e, ".git"));
|
|
3971
3998
|
}
|
|
3972
|
-
async function
|
|
3973
|
-
await
|
|
3999
|
+
async function to(e) {
|
|
4000
|
+
await q("git", ["init"], { cwd: e }), await q("git", ["add", "."], { cwd: e }), await q("git", [
|
|
3974
4001
|
"-c",
|
|
3975
4002
|
"user.name=Hype Stack CLI",
|
|
3976
4003
|
"-c",
|
|
@@ -3980,22 +4007,22 @@ async function $a(e) {
|
|
|
3980
4007
|
"Initial commit from Hype Stack CLI"
|
|
3981
4008
|
], { cwd: e });
|
|
3982
4009
|
}
|
|
3983
|
-
async function
|
|
3984
|
-
let n = `@${t}/`, r = await
|
|
4010
|
+
async function no(e, t) {
|
|
4011
|
+
let n = `@${t}/`, r = await uo(e);
|
|
3985
4012
|
for (let e of r) {
|
|
3986
4013
|
let t = await sr(e);
|
|
3987
4014
|
if (!t) continue;
|
|
3988
4015
|
let r = !1;
|
|
3989
|
-
t.name?.startsWith(Z) && (t.name = t.name.replace(Z, n), r = !0),
|
|
4016
|
+
t.name?.startsWith(Z) && (t.name = t.name.replace(Z, n), r = !0), so(t.dependencies, n) && (r = !0), so(t.devDependencies, n) && (r = !0), t.nx && co(t.nx, n) && (r = !0);
|
|
3990
4017
|
let i = await y.readFile(e, "utf-8");
|
|
3991
4018
|
if (i.includes(Z)) {
|
|
3992
4019
|
let t = i.replaceAll(Z, n);
|
|
3993
4020
|
await y.writeFile(e, t, "utf-8");
|
|
3994
4021
|
} else r && await cr(e, t);
|
|
3995
4022
|
}
|
|
3996
|
-
await Ei(e, t), await
|
|
4023
|
+
await Ei(e, t), await ao(e, t), await lo(e, t);
|
|
3997
4024
|
}
|
|
3998
|
-
var
|
|
4025
|
+
var ro = new Set([
|
|
3999
4026
|
".git",
|
|
4000
4027
|
"node_modules",
|
|
4001
4028
|
"dist",
|
|
@@ -4003,10 +4030,10 @@ var to = new Set([
|
|
|
4003
4030
|
".nx",
|
|
4004
4031
|
".next",
|
|
4005
4032
|
"coverage"
|
|
4006
|
-
]),
|
|
4007
|
-
async function
|
|
4008
|
-
if (t ===
|
|
4009
|
-
let n = await
|
|
4033
|
+
]), io = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
|
|
4034
|
+
async function ao(e, t) {
|
|
4035
|
+
if (t === $a) return;
|
|
4036
|
+
let n = await oo(e);
|
|
4010
4037
|
await Promise.all(n.map(async (e) => {
|
|
4011
4038
|
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
4012
4039
|
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
@@ -4014,14 +4041,14 @@ async function ro(e, t) {
|
|
|
4014
4041
|
await y.writeFile(e, r, "utf-8");
|
|
4015
4042
|
}));
|
|
4016
4043
|
}
|
|
4017
|
-
async function
|
|
4044
|
+
async function oo(e) {
|
|
4018
4045
|
let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
4019
4046
|
return (await Promise.all(t.map(async (t) => {
|
|
4020
4047
|
let n = T.join(e, t.name);
|
|
4021
|
-
return t.isDirectory() ?
|
|
4048
|
+
return t.isDirectory() ? ro.has(t.name) ? [] : oo(n) : t.isFile() && io.test(t.name) ? [n] : [];
|
|
4022
4049
|
}))).flat();
|
|
4023
4050
|
}
|
|
4024
|
-
function
|
|
4051
|
+
function so(e, t) {
|
|
4025
4052
|
if (!e) return !1;
|
|
4026
4053
|
let n = !1;
|
|
4027
4054
|
for (let r of Object.keys(e)) if (r.startsWith(Z)) {
|
|
@@ -4030,7 +4057,7 @@ function ao(e, t) {
|
|
|
4030
4057
|
}
|
|
4031
4058
|
return n;
|
|
4032
4059
|
}
|
|
4033
|
-
function
|
|
4060
|
+
function co(e, t) {
|
|
4034
4061
|
if (!e) return !1;
|
|
4035
4062
|
let n = !1;
|
|
4036
4063
|
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Z) ? (n = !0, e.replace(Z, t)) : e), e.targets) {
|
|
@@ -4038,13 +4065,13 @@ function oo(e, t) {
|
|
|
4038
4065
|
}
|
|
4039
4066
|
return n;
|
|
4040
4067
|
}
|
|
4041
|
-
async function
|
|
4068
|
+
async function lo(e, t) {
|
|
4042
4069
|
let n = T.join(e, "packages/enums/src/app/index.ts"), r = await y.readFile(n, "utf-8").catch(() => null);
|
|
4043
4070
|
if (!r) return;
|
|
4044
|
-
let i =
|
|
4071
|
+
let i = Aa(t), a = r.replaceAll(`id: "${$a}"`, `id: "${t}"`).replaceAll(`name: "${$a}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
|
|
4045
4072
|
await y.writeFile(n, a, "utf-8");
|
|
4046
4073
|
}
|
|
4047
|
-
async function
|
|
4074
|
+
async function uo(e) {
|
|
4048
4075
|
let t = [], n = T.join(e, "package.json");
|
|
4049
4076
|
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
4050
4077
|
for (let n of [
|
|
@@ -4064,7 +4091,7 @@ async function co(e) {
|
|
|
4064
4091
|
}
|
|
4065
4092
|
//#endregion
|
|
4066
4093
|
//#region src/core/readme.ts
|
|
4067
|
-
var
|
|
4094
|
+
var fo = {
|
|
4068
4095
|
cursor: {
|
|
4069
4096
|
label: "Cursor",
|
|
4070
4097
|
rulesDir: ".cursor/rules"
|
|
@@ -4081,21 +4108,21 @@ var lo = {
|
|
|
4081
4108
|
label: "GitHub Copilot",
|
|
4082
4109
|
rulesDir: ".github/instructions"
|
|
4083
4110
|
}
|
|
4084
|
-
},
|
|
4111
|
+
}, po = {
|
|
4085
4112
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
4086
4113
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
4087
|
-
},
|
|
4114
|
+
}, mo = {
|
|
4088
4115
|
enums: "Shared enums and app config used across apps",
|
|
4089
4116
|
cli: "Project tooling and code generators"
|
|
4090
4117
|
};
|
|
4091
|
-
function
|
|
4118
|
+
function ho(e, t) {
|
|
4092
4119
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
4093
4120
|
let r = t[e];
|
|
4094
4121
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4095
4122
|
});
|
|
4096
4123
|
}
|
|
4097
|
-
function
|
|
4098
|
-
let { projectName: t, editor: n, workspace: r } = e, i =
|
|
4124
|
+
function go(e) {
|
|
4125
|
+
let { projectName: t, editor: n, workspace: r } = e, i = Aa(t), a = fo[n], o = !!r.apps.backend, s = ho(r.apps, po), c = ho(r.packages, mo), l = [];
|
|
4099
4126
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
4100
4127
|
let u = [];
|
|
4101
4128
|
u.push(`# ${i}`), u.push([
|
|
@@ -4198,19 +4225,19 @@ function mo(e) {
|
|
|
4198
4225
|
"stays useful."
|
|
4199
4226
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4200
4227
|
}
|
|
4201
|
-
async function
|
|
4228
|
+
async function _o(e, t) {
|
|
4202
4229
|
let n = T.join(e, "README.md");
|
|
4203
|
-
await y.writeFile(n,
|
|
4230
|
+
await y.writeFile(n, go(t), "utf-8");
|
|
4204
4231
|
}
|
|
4205
4232
|
//#endregion
|
|
4206
4233
|
//#region src/core/tracking.ts
|
|
4207
|
-
async function
|
|
4234
|
+
async function vo(e) {
|
|
4208
4235
|
try {
|
|
4209
4236
|
let t = {
|
|
4210
|
-
"X-Device-Id":
|
|
4211
|
-
"X-Client-Info":
|
|
4212
|
-
}, n = await
|
|
4213
|
-
n?.token && (t.Authorization = `Bearer ${n.token}`), await
|
|
4237
|
+
"X-Device-Id": Xn(),
|
|
4238
|
+
"X-Client-Info": Zn()
|
|
4239
|
+
}, n = await Kn(I()).catch(() => null);
|
|
4240
|
+
n?.token && (t.Authorization = `Bearer ${n.token}`), await K.createRequest()({
|
|
4214
4241
|
endpoint: "/cli/track",
|
|
4215
4242
|
method: "POST"
|
|
4216
4243
|
}).setPayload({ event: e }).setHeaders(t).send();
|
|
@@ -4218,7 +4245,7 @@ async function go(e) {
|
|
|
4218
4245
|
}
|
|
4219
4246
|
//#endregion
|
|
4220
4247
|
//#region src/core/npm-deps.ts
|
|
4221
|
-
function
|
|
4248
|
+
function yo(e, t) {
|
|
4222
4249
|
let n = [], r = [];
|
|
4223
4250
|
if (!e) return {
|
|
4224
4251
|
errors: n,
|
|
@@ -4249,7 +4276,7 @@ function _o(e, t) {
|
|
|
4249
4276
|
operations: r
|
|
4250
4277
|
};
|
|
4251
4278
|
}
|
|
4252
|
-
function
|
|
4279
|
+
function bo(e) {
|
|
4253
4280
|
let t = {};
|
|
4254
4281
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4255
4282
|
...t[e],
|
|
@@ -4257,7 +4284,7 @@ function vo(e) {
|
|
|
4257
4284
|
};
|
|
4258
4285
|
return t;
|
|
4259
4286
|
}
|
|
4260
|
-
async function
|
|
4287
|
+
async function xo(e, t, n = q) {
|
|
4261
4288
|
let r = [];
|
|
4262
4289
|
for (let i of e) {
|
|
4263
4290
|
let e = T.join(t, i.relativeDir);
|
|
@@ -4293,25 +4320,25 @@ async function yo(e, t, n = K) {
|
|
|
4293
4320
|
function Q(e) {
|
|
4294
4321
|
return e instanceof Error ? e.message : String(e);
|
|
4295
4322
|
}
|
|
4296
|
-
async function
|
|
4323
|
+
async function So(e, t, n) {
|
|
4297
4324
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4298
4325
|
return r.length === 0 ? {} : Or(r, n).catch(() => ({}));
|
|
4299
4326
|
}
|
|
4300
|
-
function
|
|
4301
|
-
return e === "free" ?
|
|
4327
|
+
function Co(e, t) {
|
|
4328
|
+
return e === "free" ? R.success("free") : e === "owned" ? R.accent("owned") : `${R.highlight(`$${t}`)} ${R.muted("locked")}`;
|
|
4302
4329
|
}
|
|
4303
|
-
async function
|
|
4330
|
+
async function wo(e, t, n) {
|
|
4304
4331
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4305
|
-
i.length > 0 && s.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await
|
|
4332
|
+
i.length > 0 && s.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await rr(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4306
4333
|
name: e.name,
|
|
4307
4334
|
displayName: e.displayName,
|
|
4308
4335
|
price: e.price
|
|
4309
4336
|
})));
|
|
4310
4337
|
}
|
|
4311
|
-
function
|
|
4338
|
+
function To(e, t) {
|
|
4312
4339
|
let n = e.map((e, n) => {
|
|
4313
4340
|
let r = t.get(e), i = r ? r.displayName : e;
|
|
4314
|
-
return ` ${
|
|
4341
|
+
return ` ${R.muted(`${n + 1}.`)} ${R.brand(i)}`;
|
|
4315
4342
|
});
|
|
4316
4343
|
s.note([
|
|
4317
4344
|
"These packs will be installed, in order:",
|
|
@@ -4319,7 +4346,7 @@ function Co(e, t) {
|
|
|
4319
4346
|
...n
|
|
4320
4347
|
].join("\n"), "Install Plan");
|
|
4321
4348
|
}
|
|
4322
|
-
async function
|
|
4349
|
+
async function Eo(e, t) {
|
|
4323
4350
|
let n = [];
|
|
4324
4351
|
for (let r of e) {
|
|
4325
4352
|
let e = await Sr(r), i = await Cr(r, t);
|
|
@@ -4331,29 +4358,29 @@ async function wo(e, t) {
|
|
|
4331
4358
|
}
|
|
4332
4359
|
return n;
|
|
4333
4360
|
}
|
|
4334
|
-
async function
|
|
4335
|
-
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a =
|
|
4361
|
+
async function Do(e) {
|
|
4362
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = yo(bo(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4336
4363
|
if (a.errors.length > 0) {
|
|
4337
4364
|
for (let e of a.errors) s.log.error(e);
|
|
4338
4365
|
return;
|
|
4339
4366
|
}
|
|
4340
4367
|
if (a.operations.length === 0) return;
|
|
4341
4368
|
i.start("Installing npm dependencies...");
|
|
4342
|
-
let o = await
|
|
4369
|
+
let o = await xo(a.operations, r);
|
|
4343
4370
|
if (i.stop(o.ok ? "npm dependencies installed" : "npm dependency installation failed"), !o.ok) for (let e of o.errors) s.log.error(e);
|
|
4344
4371
|
}
|
|
4345
|
-
function
|
|
4346
|
-
s.note([` ${
|
|
4372
|
+
function Oo() {
|
|
4373
|
+
s.note([` ${R.command("1. npx @hype-stack/cli onboard")} ${R.muted("(set up env vars + run migrations)")}`, ` ${R.command("2. pnpm dev")} ${R.muted("(start frontend + backend)")}`].join("\n"), "Next steps");
|
|
4347
4374
|
}
|
|
4348
|
-
function
|
|
4375
|
+
function ko(e) {
|
|
4349
4376
|
if (e.length === 0) return;
|
|
4350
4377
|
let t = e.map((e) => {
|
|
4351
4378
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
4352
|
-
return ` ${
|
|
4379
|
+
return ` ${R.muted("•")} ${R.path(t)}`;
|
|
4353
4380
|
});
|
|
4354
4381
|
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4355
4382
|
}
|
|
4356
|
-
async function
|
|
4383
|
+
async function Ao(e) {
|
|
4357
4384
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
|
|
4358
4385
|
if (i) return c;
|
|
4359
4386
|
let l = await Fi({
|
|
@@ -4364,17 +4391,17 @@ async function Oo(e) {
|
|
|
4364
4391
|
});
|
|
4365
4392
|
if (l.length === 0) return c;
|
|
4366
4393
|
if (a) {
|
|
4367
|
-
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${
|
|
4394
|
+
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${R.command("--force")} to overwrite.`);
|
|
4368
4395
|
let e = l.map((e) => {
|
|
4369
4396
|
let t = T.relative(r, e.targetPath) || e.target;
|
|
4370
|
-
return ` ${
|
|
4397
|
+
return ` ${R.muted("•")} ${R.path(t)} ${R.muted(`(${e.packName})`)}`;
|
|
4371
4398
|
});
|
|
4372
4399
|
return s.note(e.join("\n"), "Kept existing files"), c;
|
|
4373
4400
|
}
|
|
4374
4401
|
s.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4375
4402
|
for (let e of l) {
|
|
4376
4403
|
let t = T.relative(r, e.targetPath) || e.target, n = await s.confirm({
|
|
4377
|
-
message: `Overwrite ${
|
|
4404
|
+
message: `Overwrite ${R.path(t)}? ${R.muted(`(${e.packName})`)}`,
|
|
4378
4405
|
initialValue: !1
|
|
4379
4406
|
});
|
|
4380
4407
|
s.isCancel(n) && (s.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
|
|
@@ -4383,7 +4410,7 @@ async function Oo(e) {
|
|
|
4383
4410
|
}
|
|
4384
4411
|
//#endregion
|
|
4385
4412
|
//#region src/ui/swatch.ts
|
|
4386
|
-
function
|
|
4413
|
+
function jo(e) {
|
|
4387
4414
|
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4388
4415
|
if (!t) return null;
|
|
4389
4416
|
let n = t[1].trim().split(/\s+/);
|
|
@@ -4402,58 +4429,58 @@ function ko(e) {
|
|
|
4402
4429
|
h: a
|
|
4403
4430
|
};
|
|
4404
4431
|
}
|
|
4405
|
-
function
|
|
4432
|
+
function Mo(e) {
|
|
4406
4433
|
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4407
4434
|
}
|
|
4408
|
-
function
|
|
4435
|
+
function No(e) {
|
|
4409
4436
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4410
4437
|
}
|
|
4411
|
-
function
|
|
4438
|
+
function Po({ l: e, c: t, h: n }) {
|
|
4412
4439
|
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;
|
|
4413
4440
|
return [
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4441
|
+
Mo(No(f) * 255),
|
|
4442
|
+
Mo(No(p) * 255),
|
|
4443
|
+
Mo(No(m) * 255)
|
|
4417
4444
|
];
|
|
4418
4445
|
}
|
|
4419
|
-
var
|
|
4420
|
-
function
|
|
4446
|
+
var Fo = "\x1B[49m";
|
|
4447
|
+
function Io(e, t) {
|
|
4421
4448
|
let n = e[t];
|
|
4422
4449
|
if (!n) return b.dim(" ");
|
|
4423
|
-
let r =
|
|
4450
|
+
let r = jo(n);
|
|
4424
4451
|
if (!r) return b.dim(" ");
|
|
4425
|
-
let [i, a, o] =
|
|
4426
|
-
return `\x1b[48;2;${i};${a};${o}m ${
|
|
4452
|
+
let [i, a, o] = Po(r);
|
|
4453
|
+
return `\x1b[48;2;${i};${a};${o}m ${Fo}`;
|
|
4427
4454
|
}
|
|
4428
|
-
var
|
|
4455
|
+
var Lo = [
|
|
4429
4456
|
"primary",
|
|
4430
4457
|
"secondary",
|
|
4431
4458
|
"accent"
|
|
4432
4459
|
];
|
|
4433
|
-
function
|
|
4434
|
-
return
|
|
4460
|
+
function Ro(e) {
|
|
4461
|
+
return Lo.map((t) => Io(e, t)).join("");
|
|
4435
4462
|
}
|
|
4436
|
-
function
|
|
4437
|
-
return `${
|
|
4463
|
+
function zo(e) {
|
|
4464
|
+
return `${Ro(e.light)} ${b.dim("·")} ${Ro(e.dark)}`;
|
|
4438
4465
|
}
|
|
4439
4466
|
//#endregion
|
|
4440
4467
|
//#region src/commands/create.ts
|
|
4441
|
-
async function
|
|
4442
|
-
e.skipBanner ||
|
|
4468
|
+
async function Bo(e) {
|
|
4469
|
+
e.skipBanner || Ta(), s.intro(R.brandBold("Create a new Hype Stack project"));
|
|
4443
4470
|
let o = e.yes === !0, c, l;
|
|
4444
4471
|
if (o && e.name) {
|
|
4445
|
-
let t =
|
|
4446
|
-
t && (s.log.error(t), X()), l = e.name, c =
|
|
4472
|
+
let t = ja(e.name);
|
|
4473
|
+
t && (s.log.error(t), X()), l = e.name, c = ka(e.name);
|
|
4447
4474
|
} else {
|
|
4448
4475
|
let t = await s.text({
|
|
4449
4476
|
message: "What is your project named?",
|
|
4450
4477
|
placeholder: "my-app",
|
|
4451
4478
|
initialValue: e.name ?? "",
|
|
4452
|
-
validate: (e) =>
|
|
4479
|
+
validate: (e) => ja(e ?? "")
|
|
4453
4480
|
});
|
|
4454
|
-
s.isCancel(t) && X(), l = t, c =
|
|
4481
|
+
s.isCancel(t) && X(), l = t, c = ka(l);
|
|
4455
4482
|
}
|
|
4456
|
-
l.trim() !== c && s.log.info(
|
|
4483
|
+
l.trim() !== c && s.log.info(R.muted(`Using "${R.highlight(c)}" as the project name`));
|
|
4457
4484
|
let u;
|
|
4458
4485
|
if (e.directory !== void 0) u = e.directory;
|
|
4459
4486
|
else {
|
|
@@ -4471,14 +4498,14 @@ async function Ro(e) {
|
|
|
4471
4498
|
u = dr(t, c);
|
|
4472
4499
|
}
|
|
4473
4500
|
let d = T.resolve(u);
|
|
4474
|
-
o || s.note(
|
|
4475
|
-
let f = e.editor &&
|
|
4501
|
+
o || s.note(R.path(d), "Project will be created at");
|
|
4502
|
+
let f = e.editor && ie.includes(e.editor) ? e.editor : null, p;
|
|
4476
4503
|
if (f) p = f;
|
|
4477
4504
|
else if (o) p = "cursor";
|
|
4478
4505
|
else {
|
|
4479
4506
|
let e = await s.select({
|
|
4480
4507
|
message: "Which code editor do you use?",
|
|
4481
|
-
options:
|
|
4508
|
+
options: F.map((e) => ({
|
|
4482
4509
|
value: e.value,
|
|
4483
4510
|
label: e.label,
|
|
4484
4511
|
hint: "hint" in e ? e.hint : void 0
|
|
@@ -4495,78 +4522,78 @@ async function Ro(e) {
|
|
|
4495
4522
|
message: "Pick a color theme",
|
|
4496
4523
|
options: r.map((e) => ({
|
|
4497
4524
|
value: e.name,
|
|
4498
|
-
label: `${
|
|
4525
|
+
label: `${zo(e)} ${e.label}`
|
|
4499
4526
|
})),
|
|
4500
4527
|
initialValue: h
|
|
4501
4528
|
});
|
|
4502
4529
|
s.isCancel(e) && X(), g = e;
|
|
4503
4530
|
}
|
|
4504
4531
|
if (!o) {
|
|
4505
|
-
let e =
|
|
4532
|
+
let e = F.find((e) => e.value === p)?.label ?? p, t = n.find((e) => e.value === g)?.label ?? g, r = await s.confirm({ message: `Create ${R.highlight(c)} in ${R.path(d)} with ${R.highlight(e)} config and the ${R.highlight(t)} theme?` });
|
|
4506
4533
|
(s.isCancel(r) || !r) && X();
|
|
4507
4534
|
}
|
|
4508
|
-
if (await
|
|
4535
|
+
if (await ar(d) && !await or(d)) {
|
|
4509
4536
|
let e = await s.confirm({
|
|
4510
|
-
message: `Directory ${
|
|
4537
|
+
message: `Directory ${R.path(d)} is not empty. Continue anyway?`,
|
|
4511
4538
|
initialValue: !1
|
|
4512
4539
|
});
|
|
4513
4540
|
(s.isCancel(e) || !e) && X();
|
|
4514
4541
|
}
|
|
4515
4542
|
let _ = s.spinner();
|
|
4516
|
-
_.start("Cloning Hype Stack template..."), await
|
|
4543
|
+
_.start("Cloning Hype Stack template..."), await Ha(d), _.stop(R.success("Template cloned"));
|
|
4517
4544
|
let v = s.spinner();
|
|
4518
|
-
v.start("Setting up project..."), await
|
|
4545
|
+
v.start("Setting up project..."), await eo(d), await no(d, c), await Ya(d, p);
|
|
4519
4546
|
let y = await vr(d), b = br(c, y);
|
|
4520
|
-
await _r(d, b), await
|
|
4547
|
+
await _r(d, b), await _o(d, {
|
|
4521
4548
|
projectName: c,
|
|
4522
4549
|
editor: p,
|
|
4523
4550
|
workspace: y
|
|
4524
4551
|
});
|
|
4525
4552
|
let x = T.resolve(d, b.paths?.frontend.root ?? "apps/frontend");
|
|
4526
|
-
a(g) && (await
|
|
4553
|
+
a(g) && (await Va(x, i(g)) || s.log.warn(R.muted(`Could not find ${R.path("assets/styles.css")} to apply the ${g} theme`))), await Fa(x, e.defaultMode === "dark" || e.defaultMode === "light" ? e.defaultMode : "light") || s.log.warn(R.muted(`Could not find ${R.path("src/hooks/use-theme.ts")} to set the default color mode`)), v.stop(R.success("Project configured"));
|
|
4527
4554
|
let S = s.spinner();
|
|
4528
|
-
S.start("Installing dependencies..."), (await
|
|
4555
|
+
S.start("Installing dependencies..."), (await q("pnpm", ["install"], { cwd: d })).exitCode === 0 ? S.stop(R.success("Dependencies installed")) : (S.stop(R.warning("Dependencies installed with warnings")), s.log.warn(R.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4529
4556
|
let C = s.spinner();
|
|
4530
|
-
C.start("Initializing git repository..."), await
|
|
4557
|
+
C.start("Initializing git repository..."), await to(d), C.stop(R.success("Git repository initialized with clean history"));
|
|
4531
4558
|
let w = s.spinner();
|
|
4532
4559
|
w.start("Creating .env files from examples...");
|
|
4533
|
-
let E = await
|
|
4560
|
+
let E = await Za(d);
|
|
4534
4561
|
if (E.length > 0) {
|
|
4535
4562
|
let e = E.length;
|
|
4536
|
-
w.stop(
|
|
4537
|
-
} else w.stop(
|
|
4538
|
-
s.log.success(`${
|
|
4539
|
-
let D = T.relative(process.cwd(), d) || ".", O = [`${
|
|
4540
|
-
E.length > 0 ? O.push(`Review your ${
|
|
4563
|
+
w.stop(R.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4564
|
+
} else w.stop(R.muted("No .env.example files to copy"));
|
|
4565
|
+
s.log.success(`${R.brandBold("Hype Stack")} project ${R.highlight(c)} is ready!`);
|
|
4566
|
+
let D = T.relative(process.cwd(), d) || ".", O = [`${R.command(`cd ${D}`)}`];
|
|
4567
|
+
E.length > 0 ? O.push(`Review your ${R.path(".env")} files and fill in any secrets`) : O.push(`Copy ${R.path(".env.example")} to ${R.path(".env")} and configure`), Yi(O);
|
|
4541
4568
|
let k = e.setup === !1;
|
|
4542
|
-
if (e.deferSetup) s.log.info(
|
|
4569
|
+
if (e.deferSetup) s.log.info(R.muted("Docker and migrations will run after your packs are installed."));
|
|
4543
4570
|
else {
|
|
4544
4571
|
let e = !k && (o || await s.confirm({
|
|
4545
4572
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
4546
4573
|
initialValue: !0
|
|
4547
4574
|
}));
|
|
4548
|
-
s.isCancel(e) && X(), e ? await
|
|
4575
|
+
s.isCancel(e) && X(), e ? await oa(d, o) : s.log.info(R.muted("Docker and migrations can run later via `npx @hype-stack/cli onboard`.")), Oo();
|
|
4549
4576
|
}
|
|
4550
|
-
return await
|
|
4577
|
+
return await vo("project_create"), s.outro(R.muted("Happy building!")), d;
|
|
4551
4578
|
}
|
|
4552
4579
|
//#endregion
|
|
4553
4580
|
//#region src/commands/init.ts
|
|
4554
|
-
async function
|
|
4581
|
+
async function Vo(e) {
|
|
4555
4582
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4556
|
-
if (n || (
|
|
4557
|
-
s.log.error(`This doesn't look like a Hype Stack project. ${
|
|
4583
|
+
if (n || (Ea(), s.intro(R.brandBold("Initialize Hype Stack configuration"))), !await xr(t)) {
|
|
4584
|
+
s.log.error(`This doesn't look like a Hype Stack project. ${R.muted("Expected apps/ directory and package.json")}`), s.outro(R.muted(`Run ${R.command("npx @hype-stack/cli create")} to scaffold a new project.`));
|
|
4558
4585
|
return;
|
|
4559
4586
|
}
|
|
4560
4587
|
if (await gr(t)) {
|
|
4561
4588
|
let e = await hr(t);
|
|
4562
4589
|
if (e && !n) {
|
|
4563
|
-
s.log.info(`Found existing ${
|
|
4590
|
+
s.log.info(`Found existing ${R.path("stack.json")} for project ${R.highlight(e.name)}`);
|
|
4564
4591
|
let t = await s.confirm({
|
|
4565
4592
|
message: "Overwrite existing configuration?",
|
|
4566
4593
|
initialValue: !1
|
|
4567
4594
|
});
|
|
4568
4595
|
if (s.isCancel(t) || !t) {
|
|
4569
|
-
s.outro(
|
|
4596
|
+
s.outro(R.muted("Keeping existing configuration."));
|
|
4570
4597
|
return;
|
|
4571
4598
|
}
|
|
4572
4599
|
}
|
|
@@ -4575,12 +4602,12 @@ async function zo(e) {
|
|
|
4575
4602
|
if (!n) {
|
|
4576
4603
|
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4577
4604
|
if (e.length > 0) {
|
|
4578
|
-
s.log.info(
|
|
4579
|
-
for (let [t, n] of e) s.log.message(` ${
|
|
4605
|
+
s.log.info(R.bold("Detected apps:"));
|
|
4606
|
+
for (let [t, n] of e) s.log.message(` ${z.arrow} ${R.highlight(t)} ${R.muted(`→ ${n}`)}`);
|
|
4580
4607
|
}
|
|
4581
4608
|
if (t.length > 0) {
|
|
4582
|
-
s.log.info(
|
|
4583
|
-
for (let [e, n] of t) s.log.message(` ${
|
|
4609
|
+
s.log.info(R.bold("Detected packages:"));
|
|
4610
|
+
for (let [e, n] of t) s.log.message(` ${z.arrow} ${R.highlight(e)} ${R.muted(`→ ${n}`)}`);
|
|
4584
4611
|
}
|
|
4585
4612
|
e.length === 0 && t.length === 0 && s.log.warn("No apps or packages detected in the workspace.");
|
|
4586
4613
|
}
|
|
@@ -4590,21 +4617,21 @@ async function zo(e) {
|
|
|
4590
4617
|
message: "Project name for stack.json?",
|
|
4591
4618
|
placeholder: i,
|
|
4592
4619
|
initialValue: i,
|
|
4593
|
-
validate: (e) =>
|
|
4620
|
+
validate: (e) => ja(e ?? "")
|
|
4594
4621
|
});
|
|
4595
|
-
s.isCancel(e) && X(), a =
|
|
4622
|
+
s.isCancel(e) && X(), a = ka(e);
|
|
4596
4623
|
}
|
|
4597
|
-
await _r(t, br(a, r)), n || (s.log.success(`${
|
|
4624
|
+
await _r(t, br(a, r)), n || (s.log.success(`${R.path("stack.json")} written successfully`), s.outro(R.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
|
|
4598
4625
|
}
|
|
4599
|
-
async function
|
|
4626
|
+
async function Ho(e, t = {}, n) {
|
|
4600
4627
|
if (await gr(e)) return {
|
|
4601
4628
|
projectRoot: e,
|
|
4602
4629
|
scaffolded: !1
|
|
4603
4630
|
};
|
|
4604
|
-
let r = t.runInit ?? ((e) =>
|
|
4631
|
+
let r = t.runInit ?? ((e) => Vo({
|
|
4605
4632
|
cwd: e,
|
|
4606
4633
|
silent: !0
|
|
4607
|
-
})), i = t.runCreate ?? ((e, t) =>
|
|
4634
|
+
})), i = t.runCreate ?? ((e, t) => Bo({
|
|
4608
4635
|
parentDirectory: e,
|
|
4609
4636
|
deferSetup: !0,
|
|
4610
4637
|
skipBanner: !0,
|
|
@@ -4612,22 +4639,22 @@ async function Bo(e, t = {}, n) {
|
|
|
4612
4639
|
defaultMode: t?.defaultMode
|
|
4613
4640
|
}));
|
|
4614
4641
|
if (await xr(e)) {
|
|
4615
|
-
s.log.warn(`No ${
|
|
4642
|
+
s.log.warn(`No ${R.path("stack.json")} found in ${R.path(e)}.`);
|
|
4616
4643
|
let t = await s.confirm({
|
|
4617
|
-
message: `Create ${
|
|
4644
|
+
message: `Create ${R.path("stack.json")} now?`,
|
|
4618
4645
|
initialValue: !0
|
|
4619
4646
|
});
|
|
4620
4647
|
if (s.isCancel(t) || !t) return null;
|
|
4621
4648
|
await r(e);
|
|
4622
4649
|
let n = await gr(e);
|
|
4623
|
-
return n && s.log.success(`${
|
|
4650
|
+
return n && s.log.success(`${R.path("stack.json")} created`), n ? {
|
|
4624
4651
|
projectRoot: e,
|
|
4625
4652
|
scaffolded: !1
|
|
4626
4653
|
} : null;
|
|
4627
4654
|
}
|
|
4628
|
-
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${
|
|
4655
|
+
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${R.path("stack.json")} here.`);
|
|
4629
4656
|
let a = await s.confirm({
|
|
4630
|
-
message: `Is ${
|
|
4657
|
+
message: `Is ${R.path(e)} where you want to work?`,
|
|
4631
4658
|
initialValue: !0
|
|
4632
4659
|
});
|
|
4633
4660
|
if (s.isCancel(a) || !a) return null;
|
|
@@ -4644,18 +4671,18 @@ async function Bo(e, t = {}, n) {
|
|
|
4644
4671
|
}
|
|
4645
4672
|
//#endregion
|
|
4646
4673
|
//#region src/commands/compose.ts
|
|
4647
|
-
async function
|
|
4674
|
+
async function Uo(e = {}) {
|
|
4648
4675
|
let t = e.cwd ?? process.cwd();
|
|
4649
|
-
|
|
4650
|
-
let n = await
|
|
4676
|
+
Ta();
|
|
4677
|
+
let n = await Ho(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4651
4678
|
try {
|
|
4652
4679
|
a = await hr(r ?? t);
|
|
4653
4680
|
} catch (e) {
|
|
4654
|
-
s.cancel(`Could not parse ${
|
|
4681
|
+
s.cancel(`Could not parse ${R.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4655
4682
|
}
|
|
4656
|
-
a || (s.cancel(r ? `Could not read ${
|
|
4683
|
+
a || (s.cancel(r ? `Could not read ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli compose' again.` : `No ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli compose'.`), process.exit(1)), a.paths || (s.cancel(`${R.path("stack.json")} is missing ${R.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
4657
4684
|
let o = r ?? t;
|
|
4658
|
-
s.intro(
|
|
4685
|
+
s.intro(R.brandBold("Compose your stack"));
|
|
4659
4686
|
let c = s.spinner();
|
|
4660
4687
|
c.start("Loading packs...");
|
|
4661
4688
|
let l;
|
|
@@ -4665,13 +4692,13 @@ async function Vo(e = {}) {
|
|
|
4665
4692
|
c.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${Q(e)}`), process.exit(1);
|
|
4666
4693
|
}
|
|
4667
4694
|
c.stop("Packs loaded");
|
|
4668
|
-
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
|
|
4695
|
+
let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await Kn(I()))?.token ?? null, h = await So(l, d, {
|
|
4669
4696
|
token: m,
|
|
4670
4697
|
key: p
|
|
4671
4698
|
}), g = (e) => {
|
|
4672
4699
|
let t = f.get(e);
|
|
4673
4700
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4674
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await
|
|
4701
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await Wo({
|
|
4675
4702
|
packs: l,
|
|
4676
4703
|
installedSet: d,
|
|
4677
4704
|
stateOf: g,
|
|
@@ -4679,49 +4706,49 @@ async function Vo(e = {}) {
|
|
|
4679
4706
|
adminAvailable: !!a.apps.admin
|
|
4680
4707
|
});
|
|
4681
4708
|
if (v === null && (s.cancel("Cancelled."), process.exit(0)), v.length === 0) {
|
|
4682
|
-
s.outro(
|
|
4709
|
+
s.outro(R.muted("No packs selected. Nothing to do."));
|
|
4683
4710
|
return;
|
|
4684
4711
|
}
|
|
4685
|
-
let b =
|
|
4712
|
+
let b = qo(v), x = Jo(v), S = ha(l, b), C = ca(ga(l, S)), w;
|
|
4686
4713
|
try {
|
|
4687
|
-
w =
|
|
4714
|
+
w = ua(b, C, u);
|
|
4688
4715
|
} catch (e) {
|
|
4689
4716
|
s.cancel(Q(e)), process.exit(1);
|
|
4690
4717
|
}
|
|
4691
4718
|
if (w.order.length === 0) {
|
|
4692
|
-
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(
|
|
4719
|
+
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(R.muted("Your selection is already part of the project."));
|
|
4693
4720
|
return;
|
|
4694
4721
|
}
|
|
4695
|
-
let T =
|
|
4722
|
+
let T = da({
|
|
4696
4723
|
order: w.order,
|
|
4697
4724
|
graph: C,
|
|
4698
4725
|
isLocked: _,
|
|
4699
4726
|
installed: u
|
|
4700
4727
|
});
|
|
4701
4728
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4702
|
-
let e = await
|
|
4703
|
-
e && (m = e, h = await
|
|
4729
|
+
let e = await nr();
|
|
4730
|
+
e && (m = e, h = await So(l, d, {
|
|
4704
4731
|
token: m,
|
|
4705
4732
|
key: p
|
|
4706
|
-
}), T =
|
|
4733
|
+
}), T = da({
|
|
4707
4734
|
order: w.order,
|
|
4708
4735
|
graph: C,
|
|
4709
4736
|
isLocked: _,
|
|
4710
4737
|
installed: u
|
|
4711
4738
|
}));
|
|
4712
4739
|
}
|
|
4713
|
-
if (T.blocked.length > 0 && await
|
|
4714
|
-
s.outro(
|
|
4740
|
+
if (T.blocked.length > 0 && await wo(T.blocked, _, f), T.installable.length === 0) {
|
|
4741
|
+
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
4715
4742
|
return;
|
|
4716
4743
|
}
|
|
4717
|
-
if (
|
|
4744
|
+
if (To(T.installable, f), !e.yes) {
|
|
4718
4745
|
let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4719
4746
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
4720
4747
|
}
|
|
4721
4748
|
c.start("Downloading packs...");
|
|
4722
4749
|
let E;
|
|
4723
4750
|
try {
|
|
4724
|
-
E = await
|
|
4751
|
+
E = await Eo(T.installable, {
|
|
4725
4752
|
token: m,
|
|
4726
4753
|
key: p
|
|
4727
4754
|
});
|
|
@@ -4729,7 +4756,7 @@ async function Vo(e = {}) {
|
|
|
4729
4756
|
c.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
|
|
4730
4757
|
}
|
|
4731
4758
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4732
|
-
let D = await
|
|
4759
|
+
let D = await Ao({
|
|
4733
4760
|
prepared: E,
|
|
4734
4761
|
config: a,
|
|
4735
4762
|
cwd: o,
|
|
@@ -4752,22 +4779,22 @@ async function Vo(e = {}) {
|
|
|
4752
4779
|
for (let e of t.errors) s.log.error(e);
|
|
4753
4780
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4754
4781
|
}
|
|
4755
|
-
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${
|
|
4782
|
+
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${R.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (s.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`), ko(t.skipped));
|
|
4756
4783
|
for (let e of t.errors) s.log.error(e);
|
|
4757
|
-
await
|
|
4784
|
+
await Do({
|
|
4758
4785
|
prepared: E,
|
|
4759
4786
|
paths: a.paths,
|
|
4760
4787
|
cwd: o,
|
|
4761
4788
|
spinner: c
|
|
4762
4789
|
});
|
|
4763
4790
|
let n;
|
|
4764
|
-
i && (n = await
|
|
4791
|
+
i && (n = await sa(o, e.yes ?? !1)), await pr({
|
|
4765
4792
|
projectRoot: o,
|
|
4766
4793
|
paths: a.paths,
|
|
4767
4794
|
skipPrompts: e.yes ?? !1,
|
|
4768
4795
|
dbReady: n,
|
|
4769
4796
|
freshScaffold: i
|
|
4770
|
-
}),
|
|
4797
|
+
}), Oo(), s.outro(R.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4771
4798
|
} finally {
|
|
4772
4799
|
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
4773
4800
|
recursive: !0,
|
|
@@ -4775,25 +4802,25 @@ async function Vo(e = {}) {
|
|
|
4775
4802
|
})));
|
|
4776
4803
|
}
|
|
4777
4804
|
}
|
|
4778
|
-
async function
|
|
4805
|
+
async function Wo(e) {
|
|
4779
4806
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4780
4807
|
if (i.packs && i.packs.length > 0) {
|
|
4781
|
-
let e = i.packs.map(
|
|
4808
|
+
let e = i.packs.map(Ko), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4782
4809
|
return n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4783
4810
|
}
|
|
4784
4811
|
let o = t.filter((e) => n.has(e.name));
|
|
4785
|
-
o.length > 0 && s.note(o.map((e) => ` ${
|
|
4812
|
+
o.length > 0 && s.note(o.map((e) => ` ${R.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4786
4813
|
let c = t.filter((e) => !n.has(e.name));
|
|
4787
|
-
if (c.length === 0) return s.outro(
|
|
4788
|
-
let l =
|
|
4789
|
-
s.note(c.map((e) => ` ${
|
|
4790
|
-
let u =
|
|
4814
|
+
if (c.length === 0) return s.outro(R.muted("Every available pack is already installed.")), [];
|
|
4815
|
+
let l = ce();
|
|
4816
|
+
s.note(c.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4817
|
+
let u = Ki(c, { adminAvailable: a }), d = [];
|
|
4791
4818
|
for (let e of u) {
|
|
4792
4819
|
let t = e.packs.map((e) => {
|
|
4793
4820
|
let t = r(e.name);
|
|
4794
4821
|
return {
|
|
4795
4822
|
value: e.name,
|
|
4796
|
-
label: `${e.displayName} ${
|
|
4823
|
+
label: `${e.displayName} ${Co(t, e.price)}`,
|
|
4797
4824
|
hint: e.description
|
|
4798
4825
|
};
|
|
4799
4826
|
});
|
|
@@ -4810,7 +4837,7 @@ async function Ho(e) {
|
|
|
4810
4837
|
});
|
|
4811
4838
|
continue;
|
|
4812
4839
|
}
|
|
4813
|
-
let n = await
|
|
4840
|
+
let n = await Oa({
|
|
4814
4841
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4815
4842
|
options: t,
|
|
4816
4843
|
required: !1
|
|
@@ -4820,20 +4847,20 @@ async function Ho(e) {
|
|
|
4820
4847
|
}
|
|
4821
4848
|
return d;
|
|
4822
4849
|
}
|
|
4823
|
-
var
|
|
4824
|
-
function
|
|
4825
|
-
let t = e.match(
|
|
4850
|
+
var Go = /@(frontend|admin)$/;
|
|
4851
|
+
function Ko(e) {
|
|
4852
|
+
let t = e.match(Go);
|
|
4826
4853
|
return t ? {
|
|
4827
4854
|
name: e.slice(0, -t[0].length),
|
|
4828
4855
|
slot: t[1]
|
|
4829
4856
|
} : { name: e };
|
|
4830
4857
|
}
|
|
4831
|
-
function
|
|
4858
|
+
function qo(e) {
|
|
4832
4859
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4833
4860
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4834
4861
|
return n;
|
|
4835
4862
|
}
|
|
4836
|
-
function
|
|
4863
|
+
function Jo(e) {
|
|
4837
4864
|
let t = /* @__PURE__ */ new Map();
|
|
4838
4865
|
for (let n of e) {
|
|
4839
4866
|
if (!n.slot) continue;
|
|
@@ -4844,28 +4871,28 @@ function Ko(e) {
|
|
|
4844
4871
|
}
|
|
4845
4872
|
//#endregion
|
|
4846
4873
|
//#region src/commands/login.ts
|
|
4847
|
-
async function
|
|
4848
|
-
|
|
4874
|
+
async function Yo() {
|
|
4875
|
+
Ea(), s.intro(R.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
4849
4876
|
let e;
|
|
4850
4877
|
try {
|
|
4851
|
-
e = await
|
|
4852
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
4878
|
+
e = await tr({ onUrl: (e) => {
|
|
4879
|
+
s.log.info(`If your browser didn't open, visit:\n ${R.path(e)}`);
|
|
4853
4880
|
} });
|
|
4854
4881
|
} catch (e) {
|
|
4855
4882
|
s.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
|
|
4856
4883
|
}
|
|
4857
|
-
s.outro(
|
|
4884
|
+
s.outro(R.brand(e.email ? `Logged in as ${e.email}. You can now install packs your organization owns.` : "Logged in. You can now install packs your organization owns."));
|
|
4858
4885
|
}
|
|
4859
4886
|
//#endregion
|
|
4860
4887
|
//#region src/commands/logout.ts
|
|
4861
|
-
async function
|
|
4862
|
-
|
|
4863
|
-
let e =
|
|
4888
|
+
async function Xo() {
|
|
4889
|
+
Ea(), s.intro(R.brandBold("Log out of Hype Stack"));
|
|
4890
|
+
let e = I(), t = await Kn(e);
|
|
4864
4891
|
if (!t) {
|
|
4865
|
-
s.outro(
|
|
4892
|
+
s.outro(R.muted("You're not logged in."));
|
|
4866
4893
|
return;
|
|
4867
4894
|
}
|
|
4868
|
-
await
|
|
4895
|
+
await Rn(t.token).catch(() => null), await Jn(e), s.outro(R.brand("Logged out."));
|
|
4869
4896
|
}
|
|
4870
4897
|
//#endregion
|
|
4871
4898
|
//#region src/core/onboard-catalog.ts
|
|
@@ -4879,15 +4906,15 @@ var $ = {
|
|
|
4879
4906
|
Resend: "resend",
|
|
4880
4907
|
IpLocate: "iplocate",
|
|
4881
4908
|
Sentry: "sentry"
|
|
4882
|
-
},
|
|
4883
|
-
function
|
|
4909
|
+
}, Zo = new Set(Object.values($));
|
|
4910
|
+
function Qo(e) {
|
|
4884
4911
|
return e.toLowerCase().replace(/[^a-z0-9]+/g, "").trim();
|
|
4885
4912
|
}
|
|
4886
|
-
function
|
|
4887
|
-
let t =
|
|
4888
|
-
return
|
|
4913
|
+
function $o(e) {
|
|
4914
|
+
let t = Qo(e);
|
|
4915
|
+
return Zo.has(t) ? t : void 0;
|
|
4889
4916
|
}
|
|
4890
|
-
var
|
|
4917
|
+
var es = {
|
|
4891
4918
|
[$.Config]: { hint: "App URLs. Defaults work for local dev." },
|
|
4892
4919
|
[$.Databases]: { hint: "Credentials for the local Docker Postgres and Valkey containers." },
|
|
4893
4920
|
[$.Workos]: {
|
|
@@ -4925,28 +4952,28 @@ var Qo = {
|
|
|
4925
4952
|
link: "https://sentry.io",
|
|
4926
4953
|
hint: "Your project DSN. Leave blank to skip Sentry for now."
|
|
4927
4954
|
}
|
|
4928
|
-
},
|
|
4929
|
-
function
|
|
4930
|
-
let t =
|
|
4931
|
-
return t ?
|
|
4955
|
+
}, ts = { hint: "Add your value, or press Enter to leave it blank." };
|
|
4956
|
+
function ns(e) {
|
|
4957
|
+
let t = $o(e);
|
|
4958
|
+
return t ? es[t] : ts;
|
|
4932
4959
|
}
|
|
4933
|
-
var
|
|
4960
|
+
var rs = {
|
|
4934
4961
|
"starter-saas-workos": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4935
4962
|
"starter-saas-betterauth": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4936
4963
|
"pack-notifications": ["Notifications push over the `appChannel` socket channel; register it in your server startup to go live."],
|
|
4937
4964
|
"pack-collaboration": ["Team and TeamMember are available as CASL subjects; project member and team management reuse the existing `Project` subject."]
|
|
4938
4965
|
};
|
|
4939
|
-
function
|
|
4966
|
+
function is(e) {
|
|
4940
4967
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4941
4968
|
for (let r of e) {
|
|
4942
|
-
let e =
|
|
4969
|
+
let e = rs[r];
|
|
4943
4970
|
if (e) for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
4944
4971
|
}
|
|
4945
4972
|
return n;
|
|
4946
4973
|
}
|
|
4947
4974
|
//#endregion
|
|
4948
4975
|
//#region src/core/onboard-env.ts
|
|
4949
|
-
function
|
|
4976
|
+
function as(e) {
|
|
4950
4977
|
let t = [], n = "";
|
|
4951
4978
|
for (let r of e.split(/\r?\n/)) {
|
|
4952
4979
|
let e = r.trim();
|
|
@@ -4972,19 +4999,19 @@ function rs(e) {
|
|
|
4972
4999
|
}
|
|
4973
5000
|
return t;
|
|
4974
5001
|
}
|
|
4975
|
-
var
|
|
5002
|
+
var os = [
|
|
4976
5003
|
"replace-with",
|
|
4977
5004
|
"examplepublickey",
|
|
4978
5005
|
"change-me",
|
|
4979
5006
|
"your-key-here"
|
|
4980
5007
|
];
|
|
4981
|
-
function
|
|
5008
|
+
function ss(e) {
|
|
4982
5009
|
let t = e.trim();
|
|
4983
5010
|
if (t === "") return !0;
|
|
4984
5011
|
let n = t.toLowerCase();
|
|
4985
|
-
return
|
|
5012
|
+
return os.some((e) => n.includes(e));
|
|
4986
5013
|
}
|
|
4987
|
-
function
|
|
5014
|
+
function cs(e, t, n) {
|
|
4988
5015
|
let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
|
|
4989
5016
|
if (i) return e;
|
|
4990
5017
|
let r = e.trim();
|
|
@@ -4994,109 +5021,109 @@ function os(e, t, n) {
|
|
|
4994
5021
|
});
|
|
4995
5022
|
return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
|
|
4996
5023
|
}
|
|
4997
|
-
async function
|
|
5024
|
+
async function ls(e) {
|
|
4998
5025
|
return await J(e) ? y.readFile(e, "utf-8") : "";
|
|
4999
5026
|
}
|
|
5000
|
-
async function
|
|
5027
|
+
async function us(e) {
|
|
5001
5028
|
let t = T.join(T.dirname(e), ".env");
|
|
5002
5029
|
return await J(t) || await y.copyFile(e, t), t;
|
|
5003
5030
|
}
|
|
5004
|
-
async function
|
|
5005
|
-
let r =
|
|
5031
|
+
async function ds(e, t, n) {
|
|
5032
|
+
let r = cs(await ls(e), t, n);
|
|
5006
5033
|
await y.writeFile(e, r, "utf-8");
|
|
5007
5034
|
}
|
|
5008
5035
|
//#endregion
|
|
5009
5036
|
//#region src/commands/onboard.ts
|
|
5010
|
-
async function
|
|
5037
|
+
async function fs(e = {}) {
|
|
5011
5038
|
let t = e.cwd ?? process.cwd();
|
|
5012
|
-
|
|
5039
|
+
Ta(), s.intro(R.brandBold("Onboard your stack"));
|
|
5013
5040
|
let n;
|
|
5014
5041
|
try {
|
|
5015
5042
|
n = await hr(t);
|
|
5016
5043
|
} catch {
|
|
5017
5044
|
n = null;
|
|
5018
5045
|
}
|
|
5019
|
-
n || (s.cancel(`${
|
|
5020
|
-
let r = await
|
|
5021
|
-
r.length === 0 && s.log.warn(
|
|
5022
|
-
for (let n of r) await
|
|
5023
|
-
let i =
|
|
5024
|
-
i.length > 0 && s.note(i.map((e) => ` ${
|
|
5046
|
+
n || (s.cancel(`${R.path("stack.json")} not found. Run ${R.command("npx @hype-stack/cli init")} first.`), process.exit(1));
|
|
5047
|
+
let r = await Qa(t);
|
|
5048
|
+
r.length === 0 && s.log.warn(R.muted("No .env.example files found; skipping env setup."));
|
|
5049
|
+
for (let n of r) await ps(n, t, e.yes ?? !1);
|
|
5050
|
+
let i = is(n.installedPacks ?? []);
|
|
5051
|
+
i.length > 0 && s.note(i.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await gs(t, e.yes ?? !1), s.outro(R.brand(`All set. Run ${R.command("pnpm dev")} to start your app.`));
|
|
5025
5052
|
}
|
|
5026
|
-
async function
|
|
5027
|
-
let r = T.relative(t, e) || e, i = await
|
|
5053
|
+
async function ps(e, t, n) {
|
|
5054
|
+
let r = T.relative(t, e) || e, i = await us(e), a = await ls(i), o = as(await y.readFile(e, "utf-8")), c = R.path(r);
|
|
5028
5055
|
s.log.step(`Env: ${c}`);
|
|
5029
5056
|
for (let e of o) {
|
|
5030
|
-
let t = e.vars.filter((e) =>
|
|
5057
|
+
let t = e.vars.filter((e) => ss(e.value));
|
|
5031
5058
|
if (t.length === 0) continue;
|
|
5032
|
-
let r =
|
|
5033
|
-
s.log.step(o), r.link && (s.log.info(`${
|
|
5059
|
+
let r = ns(e.section), o = e.section ? R.bold(e.section) : R.bold("Variables");
|
|
5060
|
+
s.log.step(o), r.link && (s.log.info(`${R.muted("Get your values:")} ${_e(r.link)}`), r.serviceChecklist && r.serviceChecklist.length > 0 && s.note(r.serviceChecklist.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Setup")), s.log.info(R.muted(r.hint));
|
|
5034
5061
|
for (let e of t) {
|
|
5035
5062
|
if (n) {
|
|
5036
|
-
s.log.info(`${
|
|
5063
|
+
s.log.info(`${R.label(e.key)} ${R.muted("skipped (non-interactive)")}`);
|
|
5037
5064
|
continue;
|
|
5038
5065
|
}
|
|
5039
|
-
let t =
|
|
5040
|
-
message: `${
|
|
5066
|
+
let t = ms(a, e.key), o = await s.text({
|
|
5067
|
+
message: `${R.label(e.key)}`,
|
|
5041
5068
|
placeholder: t || r.hint
|
|
5042
5069
|
});
|
|
5043
5070
|
s.isCancel(o) && X();
|
|
5044
5071
|
let c = (o ?? "").trim();
|
|
5045
5072
|
if (c === "") {
|
|
5046
|
-
s.log.warn(
|
|
5073
|
+
s.log.warn(R.muted(`${e.key} left blank.`));
|
|
5047
5074
|
continue;
|
|
5048
5075
|
}
|
|
5049
|
-
await
|
|
5076
|
+
await ds(i, e.key, c), s.log.success(`${e.key} saved`);
|
|
5050
5077
|
}
|
|
5051
5078
|
}
|
|
5052
5079
|
}
|
|
5053
|
-
function
|
|
5080
|
+
function ms(e, t) {
|
|
5054
5081
|
for (let n of e.split(/\r?\n/)) {
|
|
5055
|
-
let e = n.match(RegExp(`^${
|
|
5082
|
+
let e = n.match(RegExp(`^${hs(t)}\\s*=\\s*(.*)$`));
|
|
5056
5083
|
if (e) return e[1].trim();
|
|
5057
5084
|
}
|
|
5058
5085
|
return "";
|
|
5059
5086
|
}
|
|
5060
|
-
function
|
|
5087
|
+
function hs(e) {
|
|
5061
5088
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5062
5089
|
}
|
|
5063
|
-
async function
|
|
5064
|
-
if (!await
|
|
5065
|
-
s.log.info(
|
|
5090
|
+
async function gs(e, t) {
|
|
5091
|
+
if (!await Xi() && !await Qi(e, t, !1)) {
|
|
5092
|
+
s.log.info(R.muted(`Start services later with ${R.command("docker compose up -d")} (in apps/backend), then ${R.command("pnpm --filter @internal/backend migration:latest")}.`));
|
|
5066
5093
|
return;
|
|
5067
5094
|
}
|
|
5068
5095
|
let n = s.spinner();
|
|
5069
|
-
if (n.start("Waiting for Postgres to be ready..."), !await
|
|
5070
|
-
n.error("Postgres health check timed out"), s.log.warn(
|
|
5096
|
+
if (n.start("Waiting for Postgres to be ready..."), !await ea(e)) {
|
|
5097
|
+
n.error("Postgres health check timed out"), s.log.warn(R.muted(`Run migrations manually once Postgres is ready: ${R.command("pnpm --filter @internal/backend migration:latest")}`));
|
|
5071
5098
|
return;
|
|
5072
5099
|
}
|
|
5073
|
-
if (n.stop(
|
|
5074
|
-
s.log.info(
|
|
5100
|
+
if (n.stop(R.success("Postgres is ready")), await na(e)) {
|
|
5101
|
+
s.log.info(R.muted("Migrations already applied, skipping."));
|
|
5075
5102
|
return;
|
|
5076
5103
|
}
|
|
5077
5104
|
let r = t ? !0 : await s.confirm({
|
|
5078
|
-
message: `Run database migrations with ${
|
|
5105
|
+
message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
|
|
5079
5106
|
initialValue: !0
|
|
5080
5107
|
});
|
|
5081
5108
|
if (s.isCancel(r) && X(), !r) {
|
|
5082
|
-
s.log.info(
|
|
5109
|
+
s.log.info(R.muted("Skipping database migrations."));
|
|
5083
5110
|
return;
|
|
5084
5111
|
}
|
|
5085
|
-
await
|
|
5112
|
+
await ra(e);
|
|
5086
5113
|
}
|
|
5087
5114
|
//#endregion
|
|
5088
5115
|
//#region src/core/templates.ts
|
|
5089
|
-
var
|
|
5116
|
+
var _s = K.createRequest()({
|
|
5090
5117
|
endpoint: "/templates/list",
|
|
5091
5118
|
method: "GET"
|
|
5092
5119
|
});
|
|
5093
|
-
async function
|
|
5094
|
-
let { data: e, error: t } = await
|
|
5120
|
+
async function vs() {
|
|
5121
|
+
let { data: e, error: t } = await _s.send();
|
|
5095
5122
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
5096
5123
|
return e.templates;
|
|
5097
5124
|
}
|
|
5098
|
-
async function
|
|
5099
|
-
let { data: t, error: n, status: r } = await
|
|
5125
|
+
async function ys(e) {
|
|
5126
|
+
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
5100
5127
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
5101
5128
|
method: "GET"
|
|
5102
5129
|
}).send();
|
|
@@ -5104,13 +5131,13 @@ async function _s(e) {
|
|
|
5104
5131
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
5105
5132
|
return t;
|
|
5106
5133
|
}
|
|
5107
|
-
async function
|
|
5108
|
-
let n =
|
|
5134
|
+
async function bs(e, t = {}) {
|
|
5135
|
+
let n = K.createRequest()({
|
|
5109
5136
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
5110
5137
|
method: "POST"
|
|
5111
5138
|
}), r = {
|
|
5112
|
-
"X-Device-Id":
|
|
5113
|
-
"X-Client-Info":
|
|
5139
|
+
"X-Device-Id": Xn(),
|
|
5140
|
+
"X-Client-Info": Zn()
|
|
5114
5141
|
};
|
|
5115
5142
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
5116
5143
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -5132,9 +5159,9 @@ async function vs(e, t = {}) {
|
|
|
5132
5159
|
}
|
|
5133
5160
|
//#endregion
|
|
5134
5161
|
//#region src/commands/template.ts
|
|
5135
|
-
async function
|
|
5162
|
+
async function xs(t = {}) {
|
|
5136
5163
|
let n = t.cwd ?? process.cwd();
|
|
5137
|
-
|
|
5164
|
+
Ta();
|
|
5138
5165
|
let r = s.spinner();
|
|
5139
5166
|
r.start("Loading packs...");
|
|
5140
5167
|
let o;
|
|
@@ -5146,15 +5173,15 @@ async function ys(t = {}) {
|
|
|
5146
5173
|
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
5147
5174
|
let c;
|
|
5148
5175
|
try {
|
|
5149
|
-
c = await
|
|
5176
|
+
c = await vs();
|
|
5150
5177
|
} catch (e) {
|
|
5151
5178
|
r.stop("Failed to load templates"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${Q(e)}`), process.exit(1);
|
|
5152
5179
|
}
|
|
5153
5180
|
let l = t.templateId;
|
|
5154
5181
|
if (!l) {
|
|
5155
5182
|
t.yes && (r.stop("Template id required"), s.cancel("Pass a template id with `npx @hype-stack/cli template <id>` (required in --yes mode)."), process.exit(1)), c.length === 0 && (r.stop("No templates available"), s.cancel("No templates are available yet. Check back later."), process.exit(1)), r.stop("Templates loaded");
|
|
5156
|
-
let e =
|
|
5157
|
-
s.note(c.map((t) => ` ${
|
|
5183
|
+
let e = ce();
|
|
5184
|
+
s.note(c.map((t) => ` ${z.arrow} ${R.highlight(t.name)} ${_e(`${e}/templates/${t.id}`)}`).join("\n"), "Browse templates");
|
|
5158
5185
|
let n = await s.select({
|
|
5159
5186
|
message: "Choose a template",
|
|
5160
5187
|
options: c.map((e) => ({
|
|
@@ -5169,151 +5196,151 @@ async function ys(t = {}) {
|
|
|
5169
5196
|
u || (r.stop("Template not found"), s.cancel(`Template "${l}" not found. Available: ${c.map((e) => e.id).join(", ") || "(none)"}`), process.exit(1)), r.stop(`Template: ${u.name}`);
|
|
5170
5197
|
let d;
|
|
5171
5198
|
try {
|
|
5172
|
-
d = await
|
|
5199
|
+
d = await ys(u.id);
|
|
5173
5200
|
} catch (e) {
|
|
5174
5201
|
s.cancel(Q(e)), process.exit(1);
|
|
5175
5202
|
}
|
|
5176
|
-
let f = await
|
|
5203
|
+
let f = await Ho(n, {}, {
|
|
5177
5204
|
defaultTheme: d.theme,
|
|
5178
5205
|
defaultMode: d.defaultMode
|
|
5179
5206
|
}), p = f?.projectRoot ?? null, m = f?.scaffolded ?? !1, h;
|
|
5180
5207
|
try {
|
|
5181
5208
|
h = await hr(p ?? n);
|
|
5182
5209
|
} catch (e) {
|
|
5183
|
-
s.cancel(`Could not parse ${
|
|
5210
|
+
s.cancel(`Could not parse ${R.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
5184
5211
|
}
|
|
5185
|
-
h || (s.cancel(p ? `Could not read ${
|
|
5212
|
+
h || (s.cancel(p ? `Could not read ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), process.exit(1)), h.paths || (s.cancel(`${R.path("stack.json")} is missing ${R.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
5186
5213
|
let g = p ?? n;
|
|
5187
|
-
s.intro(
|
|
5188
|
-
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await
|
|
5214
|
+
s.intro(R.brandBold("Install a template"));
|
|
5215
|
+
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await Kn(I()))?.token ?? null, C = await Ss(u, t.variants, t.yes ?? !1), w = fa(u.slots, C), E = pa(u.slots, u.packs, w), D = await Cs({
|
|
5189
5216
|
packs: o,
|
|
5190
5217
|
templatePacks: E,
|
|
5191
5218
|
installedSet: v,
|
|
5192
5219
|
options: t
|
|
5193
5220
|
}), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
|
|
5194
5221
|
k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
|
|
5195
|
-
let ee =
|
|
5222
|
+
let ee = ga(o, w), A = ca(ee), j;
|
|
5196
5223
|
try {
|
|
5197
|
-
j =
|
|
5224
|
+
j = ua(O, A, _);
|
|
5198
5225
|
} catch (e) {
|
|
5199
5226
|
s.cancel(Q(e)), process.exit(1);
|
|
5200
5227
|
}
|
|
5201
5228
|
if (j.order.length === 0) {
|
|
5202
|
-
s.outro(
|
|
5229
|
+
s.outro(R.muted("Every pack in this template is already installed."));
|
|
5203
5230
|
return;
|
|
5204
5231
|
}
|
|
5205
|
-
let
|
|
5232
|
+
let te = await So(ee, v, {
|
|
5206
5233
|
token: S,
|
|
5207
5234
|
key: x
|
|
5208
|
-
}),
|
|
5235
|
+
}), ne = (e) => {
|
|
5209
5236
|
let t = b.get(e);
|
|
5210
|
-
return !t || t.tier === "free" ? "free" :
|
|
5211
|
-
},
|
|
5237
|
+
return !t || t.tier === "free" ? "free" : te[e]?.owned ? "owned" : "locked";
|
|
5238
|
+
}, M = (e) => !v.has(e) && ne(e) === "locked", N = da({
|
|
5212
5239
|
order: j.order,
|
|
5213
5240
|
graph: A,
|
|
5214
|
-
isLocked:
|
|
5241
|
+
isLocked: M,
|
|
5215
5242
|
installed: _
|
|
5216
5243
|
});
|
|
5217
|
-
if (
|
|
5218
|
-
let e = await
|
|
5219
|
-
e && (S = e,
|
|
5244
|
+
if (N.blocked.length > 0 && !S && !x) {
|
|
5245
|
+
let e = await nr();
|
|
5246
|
+
e && (S = e, te = await So(ee, v, {
|
|
5220
5247
|
token: S,
|
|
5221
5248
|
key: x
|
|
5222
|
-
}),
|
|
5249
|
+
}), N = da({
|
|
5223
5250
|
order: j.order,
|
|
5224
5251
|
graph: A,
|
|
5225
|
-
isLocked:
|
|
5252
|
+
isLocked: M,
|
|
5226
5253
|
installed: _
|
|
5227
5254
|
}));
|
|
5228
5255
|
}
|
|
5229
|
-
if (
|
|
5230
|
-
s.outro(
|
|
5256
|
+
if (N.blocked.length > 0 && await wo(N.blocked, M, b), N.installable.length === 0) {
|
|
5257
|
+
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
5231
5258
|
return;
|
|
5232
5259
|
}
|
|
5233
|
-
if (
|
|
5234
|
-
let e = await s.confirm({ message: `Install template ${
|
|
5260
|
+
if (To(N.installable, b), !t.yes) {
|
|
5261
|
+
let e = await s.confirm({ message: `Install template ${R.brandBold(u.name)} (${N.installable.length} pack${N.installable.length === 1 ? "" : "s"})?` });
|
|
5235
5262
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5236
5263
|
}
|
|
5237
5264
|
r.start("Downloading packs...");
|
|
5238
|
-
let
|
|
5265
|
+
let P;
|
|
5239
5266
|
try {
|
|
5240
|
-
|
|
5267
|
+
P = await Eo(N.installable, {
|
|
5241
5268
|
token: S,
|
|
5242
5269
|
key: x
|
|
5243
5270
|
});
|
|
5244
5271
|
} catch (e) {
|
|
5245
5272
|
r.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
|
|
5246
5273
|
}
|
|
5247
|
-
r.stop(`Downloaded ${
|
|
5248
|
-
let
|
|
5249
|
-
prepared:
|
|
5274
|
+
r.stop(`Downloaded ${P.length} pack${P.length === 1 ? "" : "s"}`);
|
|
5275
|
+
let re = await Ao({
|
|
5276
|
+
prepared: P,
|
|
5250
5277
|
config: h,
|
|
5251
5278
|
cwd: g,
|
|
5252
5279
|
force: t.force ?? !1,
|
|
5253
5280
|
yes: t.yes ?? !1
|
|
5254
|
-
}),
|
|
5281
|
+
}), F = null;
|
|
5255
5282
|
try {
|
|
5256
5283
|
r.start("Installing pack files...");
|
|
5257
5284
|
let n = await Ri({
|
|
5258
|
-
packs:
|
|
5285
|
+
packs: P,
|
|
5259
5286
|
config: h,
|
|
5260
5287
|
projectRoot: g,
|
|
5261
5288
|
force: t.force ?? !1,
|
|
5262
|
-
overwrite:
|
|
5289
|
+
overwrite: re
|
|
5263
5290
|
});
|
|
5264
5291
|
if (n.aborted) {
|
|
5265
5292
|
r.stop("Installation aborted");
|
|
5266
5293
|
for (let e of n.errors) s.log.error(e);
|
|
5267
5294
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5268
5295
|
}
|
|
5269
|
-
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${
|
|
5296
|
+
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${R.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && (s.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`), ko(n.skipped));
|
|
5270
5297
|
for (let e of n.errors) s.log.error(e);
|
|
5271
5298
|
r.start("Applying template overrides...");
|
|
5272
|
-
let o = await
|
|
5299
|
+
let o = await bs(u.id, {
|
|
5273
5300
|
token: S,
|
|
5274
5301
|
licenseKey: x
|
|
5275
5302
|
});
|
|
5276
|
-
o.status === "denied" && (r.stop("Template download denied"), s.cancel(`Access to template "${u.id}" was denied (${o.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)),
|
|
5303
|
+
o.status === "denied" && (r.stop("Template download denied"), s.cancel(`Access to template "${u.id}" was denied (${o.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)), F = o.templateDir;
|
|
5277
5304
|
let c = await Bi({
|
|
5278
5305
|
manifest: d,
|
|
5279
5306
|
config: h,
|
|
5280
5307
|
projectRoot: g,
|
|
5281
|
-
templateDir:
|
|
5308
|
+
templateDir: F
|
|
5282
5309
|
});
|
|
5283
5310
|
r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
|
|
5284
5311
|
for (let e of c.errors) s.log.error(e);
|
|
5285
5312
|
if (!m) {
|
|
5286
5313
|
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5287
|
-
a(n) && (await
|
|
5314
|
+
a(n) && (await Va(t, i(n)) ? s.log.success(`Applied the ${i(n).label} theme`) : s.log.warning(R.muted(`Could not find ${R.path("assets/styles.css")} to apply the theme`)));
|
|
5288
5315
|
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5289
|
-
await
|
|
5316
|
+
await Fa(t, r) ? s.log.success(`Default color mode set to ${r}`) : s.log.warning(R.muted(`Could not find ${R.path("src/hooks/use-theme.ts")} to set the default color mode`));
|
|
5290
5317
|
}
|
|
5291
|
-
await
|
|
5292
|
-
prepared:
|
|
5318
|
+
await ws({
|
|
5319
|
+
prepared: P,
|
|
5293
5320
|
templateNpm: d.dependencies_npm,
|
|
5294
5321
|
paths: h.paths,
|
|
5295
5322
|
cwd: g,
|
|
5296
5323
|
spinner: r
|
|
5297
5324
|
});
|
|
5298
5325
|
let l;
|
|
5299
|
-
m && (l = await
|
|
5326
|
+
m && (l = await sa(g, t.yes ?? !1)), await pr({
|
|
5300
5327
|
projectRoot: g,
|
|
5301
5328
|
paths: h.paths,
|
|
5302
5329
|
skipPrompts: t.yes ?? !1,
|
|
5303
5330
|
dbReady: l,
|
|
5304
5331
|
freshScaffold: m
|
|
5305
|
-
}),
|
|
5332
|
+
}), Oo(), s.outro(R.brand(`Installed template ${u.name}.`));
|
|
5306
5333
|
} finally {
|
|
5307
|
-
await Promise.all(
|
|
5334
|
+
await Promise.all(P.map((e) => y.rm(e.packDir, {
|
|
5308
5335
|
recursive: !0,
|
|
5309
5336
|
force: !0
|
|
5310
|
-
}))),
|
|
5337
|
+
}))), F && await y.rm(F, {
|
|
5311
5338
|
recursive: !0,
|
|
5312
5339
|
force: !0
|
|
5313
5340
|
});
|
|
5314
5341
|
}
|
|
5315
5342
|
}
|
|
5316
|
-
async function
|
|
5343
|
+
async function Ss(e, t, n) {
|
|
5317
5344
|
let r = {};
|
|
5318
5345
|
for (let i of e.slots) {
|
|
5319
5346
|
if (t?.[i.family]) {
|
|
@@ -5337,7 +5364,7 @@ async function bs(e, t, n) {
|
|
|
5337
5364
|
}
|
|
5338
5365
|
return r;
|
|
5339
5366
|
}
|
|
5340
|
-
async function
|
|
5367
|
+
async function Cs(e) {
|
|
5341
5368
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5342
5369
|
if (i.packs && i.packs.length > 0) {
|
|
5343
5370
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -5346,9 +5373,9 @@ async function xs(e) {
|
|
|
5346
5373
|
if (i.yes) return [];
|
|
5347
5374
|
let o = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
|
|
5348
5375
|
if (o.length === 0) return [];
|
|
5349
|
-
let c =
|
|
5350
|
-
s.note(o.map((e) => ` ${
|
|
5351
|
-
let l = await
|
|
5376
|
+
let c = ce();
|
|
5377
|
+
s.note(o.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5378
|
+
let l = await Oa({
|
|
5352
5379
|
message: "Add extra packs on top of the template (optional)",
|
|
5353
5380
|
options: o.map((e) => ({
|
|
5354
5381
|
value: e.name,
|
|
@@ -5359,25 +5386,25 @@ async function xs(e) {
|
|
|
5359
5386
|
});
|
|
5360
5387
|
return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
|
|
5361
5388
|
}
|
|
5362
|
-
async function
|
|
5363
|
-
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o =
|
|
5389
|
+
async function ws(e) {
|
|
5390
|
+
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o = bo(t.map((e) => e.manifest.dependencies_npm)), c = yo(n ? bo([o, n]) : o, r);
|
|
5364
5391
|
if (c.errors.length > 0) {
|
|
5365
5392
|
for (let e of c.errors) s.log.error(e);
|
|
5366
5393
|
return;
|
|
5367
5394
|
}
|
|
5368
5395
|
if (c.operations.length === 0) return;
|
|
5369
5396
|
a.start("Installing npm dependencies...");
|
|
5370
|
-
let l = await
|
|
5397
|
+
let l = await xo(c.operations, i);
|
|
5371
5398
|
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) s.log.error(e);
|
|
5372
5399
|
}
|
|
5373
5400
|
//#endregion
|
|
5374
5401
|
//#region src/cli.ts
|
|
5375
|
-
function
|
|
5402
|
+
function Ts(e) {
|
|
5376
5403
|
if (!e) return;
|
|
5377
5404
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5378
5405
|
return t.length > 0 ? t : void 0;
|
|
5379
5406
|
}
|
|
5380
|
-
function
|
|
5407
|
+
function Es(e) {
|
|
5381
5408
|
if (!e) return;
|
|
5382
5409
|
let t = {};
|
|
5383
5410
|
for (let n of e.split(",")) {
|
|
@@ -5386,10 +5413,10 @@ function ws(e) {
|
|
|
5386
5413
|
}
|
|
5387
5414
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5388
5415
|
}
|
|
5389
|
-
function
|
|
5416
|
+
function Ds() {
|
|
5390
5417
|
let e = new o();
|
|
5391
5418
|
return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(A, "-v, --version"), e.command("create").description("Create a new Hype Stack project").option("-n, --name <name>", "Project name").option("-d, --directory <path>", "Target directory").option("-e, --editor <editor>", "Code editor (cursor, claude, windsurf, copilot)").option("-t, --theme <theme>", "Color theme (default, slate, rose, emerald, violet, amber, ocean, zinc-mono, crimson, midnight)").option("--no-install", "Skip dependency installation").option("--no-setup", "Skip Docker services and database migrations after create").option("-y, --yes", "Skip confirmation prompts (requires --name)").action(async (e) => {
|
|
5392
|
-
await
|
|
5419
|
+
await Bo({
|
|
5393
5420
|
name: e.name,
|
|
5394
5421
|
directory: e.directory,
|
|
5395
5422
|
install: e.install,
|
|
@@ -5399,38 +5426,38 @@ function Ts() {
|
|
|
5399
5426
|
setup: e.setup
|
|
5400
5427
|
});
|
|
5401
5428
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5402
|
-
await
|
|
5429
|
+
await Vo({});
|
|
5403
5430
|
}), e.command("onboard").description("Set up env vars, run migrations, and get the start command").option("-y, --yes", "Skip prompts, accept defaults").option("--skip-migrations", "Skip Docker services and database migrations").option("--cwd <path>", "Working directory").action(async (e) => {
|
|
5404
|
-
await
|
|
5431
|
+
await fs({
|
|
5405
5432
|
cwd: e.cwd,
|
|
5406
5433
|
yes: e.yes,
|
|
5407
5434
|
skipMigrations: e.skipMigrations
|
|
5408
5435
|
});
|
|
5409
5436
|
}), 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) => {
|
|
5410
|
-
await
|
|
5411
|
-
packs:
|
|
5437
|
+
await Uo({
|
|
5438
|
+
packs: Ts(e.packs),
|
|
5412
5439
|
force: e.force,
|
|
5413
5440
|
yes: e.yes,
|
|
5414
5441
|
licenseKey: e.key ?? e.licenseKey,
|
|
5415
5442
|
cwd: e.cwd
|
|
5416
5443
|
});
|
|
5417
5444
|
}), 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) => {
|
|
5418
|
-
await
|
|
5445
|
+
await xs({
|
|
5419
5446
|
templateId: e,
|
|
5420
|
-
variants:
|
|
5421
|
-
packs:
|
|
5447
|
+
variants: Es(t.variants),
|
|
5448
|
+
packs: Ts(t.packs),
|
|
5422
5449
|
force: t.force,
|
|
5423
5450
|
yes: t.yes,
|
|
5424
5451
|
licenseKey: t.key ?? t.licenseKey,
|
|
5425
5452
|
cwd: t.cwd
|
|
5426
5453
|
});
|
|
5427
5454
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5428
|
-
await
|
|
5455
|
+
await Yo();
|
|
5429
5456
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5430
|
-
await
|
|
5457
|
+
await Xo();
|
|
5431
5458
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5432
|
-
await
|
|
5459
|
+
await Yo();
|
|
5433
5460
|
}), e;
|
|
5434
5461
|
}
|
|
5435
5462
|
//#endregion
|
|
5436
|
-
export {
|
|
5463
|
+
export { Ho as a, Uo as i, Xo as n, Vo as o, Yo as r, Bo as s, Ds as t };
|