@hype-stack/cli 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-NswFvMgQ.js → cli-CwXodW3B.js} +533 -503
- package/dist/commands/compose.d.ts.map +1 -1
- package/dist/commands/template.d.ts.map +1 -1
- package/dist/config/bin.js +1 -1
- package/dist/core/codegen.d.ts +2 -0
- package/dist/core/codegen.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.4", j = "gh:BetterTyped/hype-stack", M = "stack.json", te = "/schema/stack.json", N = "https://api.hype-stack.dev", P = "HYPE_STACK_API_URL", F = "https://www.hype-stack.dev", ne = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, I = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -31,109 +31,109 @@ var A = "0.5.3", j = "gh:BetterTyped/hype-stack", te = "stack.json", ne = "/sche
|
|
|
31
31
|
value: "copilot",
|
|
32
32
|
label: "GitHub Copilot"
|
|
33
33
|
}
|
|
34
|
-
],
|
|
35
|
-
function
|
|
34
|
+
], re = I.map((e) => e.value), ie = ".cursor/rules", ae = ".cursor", oe = ".agents";
|
|
35
|
+
function L() {
|
|
36
36
|
let e = process.env.HYPE_STACK_API_URL;
|
|
37
|
-
return e ? (
|
|
37
|
+
return e ? (ce(e), e.replace(/\/+$/, "")) : N;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function se() {
|
|
40
40
|
let e = process.env.HYPE_STACK_WEB_URL;
|
|
41
|
-
return e ? (
|
|
41
|
+
return e ? (ce(e), e.replace(/\/+$/, "")) : F;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function ce(e) {
|
|
44
44
|
try {
|
|
45
45
|
let t = new URL(e);
|
|
46
|
-
if (!t.protocol.startsWith("http")) throw Error(`${
|
|
46
|
+
if (!t.protocol.startsWith("http")) throw Error(`${P} must use http or https protocol, got "${t.protocol}"`);
|
|
47
47
|
} catch (t) {
|
|
48
|
-
throw t instanceof TypeError ? Error(`${
|
|
48
|
+
throw t instanceof TypeError ? Error(`${P} is not a valid URL: "${e}"`, { cause: t }) : t;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return `${
|
|
51
|
+
function le() {
|
|
52
|
+
return `${L()}${te}`;
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/ui/theme.ts
|
|
56
|
-
var
|
|
57
|
-
orange:
|
|
58
|
-
orangeBright:
|
|
59
|
-
amber:
|
|
60
|
-
deepBlue:
|
|
61
|
-
skyBlue:
|
|
62
|
-
lightBlue:
|
|
63
|
-
},
|
|
64
|
-
brand: (e) =>
|
|
65
|
-
brandBold: (e) => b.bold(
|
|
66
|
-
accent: (e) =>
|
|
67
|
-
accentBold: (e) => b.bold(
|
|
56
|
+
var ue = (e) => `\x1b[38;5;208m${e}\x1b[39m`, de = (e) => `\x1b[38;5;214m${e}\x1b[39m`, R = (e) => `\x1b[38;5;220m${e}\x1b[39m`, fe = (e) => `\x1b[38;5;33m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;39m${e}\x1b[39m`, me = (e) => `\x1b[38;5;81m${e}\x1b[39m`, he = {
|
|
57
|
+
orange: ue,
|
|
58
|
+
orangeBright: de,
|
|
59
|
+
amber: R,
|
|
60
|
+
deepBlue: fe,
|
|
61
|
+
skyBlue: pe,
|
|
62
|
+
lightBlue: me
|
|
63
|
+
}, z = {
|
|
64
|
+
brand: (e) => ue(e),
|
|
65
|
+
brandBold: (e) => b.bold(ue(e)),
|
|
66
|
+
accent: (e) => pe(e),
|
|
67
|
+
accentBold: (e) => b.bold(pe(e)),
|
|
68
68
|
success: (e) => b.green(e),
|
|
69
69
|
error: (e) => b.red(e),
|
|
70
70
|
warning: (e) => b.yellow(e),
|
|
71
71
|
muted: (e) => b.dim(e),
|
|
72
72
|
bold: (e) => b.bold(e),
|
|
73
73
|
highlight: (e) => b.bold(b.white(e)),
|
|
74
|
-
path: (e) => b.underline(
|
|
75
|
-
command: (e) => b.bold(
|
|
74
|
+
path: (e) => b.underline(pe(e)),
|
|
75
|
+
command: (e) => b.bold(R(e)),
|
|
76
76
|
label: (e) => b.dim(b.bold(e))
|
|
77
77
|
};
|
|
78
|
-
function
|
|
79
|
-
return `\x1b]8;;${e}\x07${
|
|
80
|
-
}
|
|
81
|
-
var
|
|
82
|
-
arrow:
|
|
83
|
-
bullet:
|
|
84
|
-
dash:
|
|
85
|
-
corner:
|
|
86
|
-
pipe:
|
|
87
|
-
dot:
|
|
88
|
-
spark:
|
|
89
|
-
sparkSmall:
|
|
90
|
-
bolt:
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
fe,
|
|
78
|
+
function ge(e, t = e) {
|
|
79
|
+
return `\x1b]8;;${e}\x07${pe(t)}\x1b]8;;\x07`;
|
|
80
|
+
}
|
|
81
|
+
var B = {
|
|
82
|
+
arrow: ue("›"),
|
|
83
|
+
bullet: z.muted("·"),
|
|
84
|
+
dash: z.muted("─"),
|
|
85
|
+
corner: z.muted("╰"),
|
|
86
|
+
pipe: z.muted("│"),
|
|
87
|
+
dot: z.muted("•"),
|
|
88
|
+
spark: R("✦"),
|
|
89
|
+
sparkSmall: de("✧"),
|
|
90
|
+
bolt: R("⚡")
|
|
91
|
+
}, _e = [
|
|
92
|
+
R,
|
|
93
|
+
R,
|
|
95
94
|
de,
|
|
95
|
+
ue,
|
|
96
|
+
fe,
|
|
97
|
+
pe,
|
|
96
98
|
me,
|
|
97
|
-
|
|
98
|
-
he,
|
|
99
|
-
he
|
|
99
|
+
me
|
|
100
100
|
];
|
|
101
|
-
function
|
|
101
|
+
function ve(e) {
|
|
102
102
|
let t = [...e], n = t.length;
|
|
103
103
|
return t.map((e, t) => {
|
|
104
104
|
if (e === " " || e === "\n") return e;
|
|
105
105
|
let r = t / Math.max(n - 1, 1);
|
|
106
|
-
return
|
|
106
|
+
return _e[Math.min(Math.floor(r * _e.length), _e.length - 1)](e);
|
|
107
107
|
}).join("");
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function ye(e, t, n) {
|
|
110
110
|
return Math.round(e + (t - e) * n);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function be(e, t) {
|
|
113
113
|
let { start: n, end: r, angle: i = 1 } = t, a = Math.max(...e.map((e) => e.length), 1), o = Math.max(e.length - 1, 1);
|
|
114
114
|
return e.map((e, t) => [...e].map((e, s) => {
|
|
115
115
|
if (e === " ") return e;
|
|
116
116
|
let c = s / Math.max(a - 1, 1), l = t / o, u = Math.min((c + l * i) / (1 + i), 1);
|
|
117
|
-
return `\x1b[38;2;${
|
|
117
|
+
return `\x1b[38;2;${ye(n[0], r[0], u)};${ye(n[1], r[1], u)};${ye(n[2], r[2], u)}m${e}\x1b[39m`;
|
|
118
118
|
}).join(""));
|
|
119
119
|
}
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/core/license.ts
|
|
122
|
-
function
|
|
123
|
-
return `${
|
|
122
|
+
function xe(e) {
|
|
123
|
+
return `${se()}/packs/${e}`;
|
|
124
124
|
}
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region ../../node_modules/.pnpm/@hyper-fetch+core@8.1.1/node_modules/@hyper-fetch/core/dist/index.mjs
|
|
127
|
-
var
|
|
128
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i =
|
|
127
|
+
var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDescriptor, Te = Object.getOwnPropertyNames, Ee = Object.getPrototypeOf, De = Object.prototype.hasOwnProperty, Oe = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), ke = (e, t, n, r) => {
|
|
128
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = Te(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !De.call(e, s) && s !== n && Ce(e, s, {
|
|
129
129
|
get: ((e) => t[e]).bind(null, s),
|
|
130
|
-
enumerable: !(r =
|
|
130
|
+
enumerable: !(r = we(t, s)) || r.enumerable
|
|
131
131
|
});
|
|
132
132
|
return e;
|
|
133
|
-
},
|
|
133
|
+
}, Ae = (e, t, n) => (n = e == null ? {} : Se(Ee(e)), ke(t || !e || !e.__esModule ? Ce(n, "default", {
|
|
134
134
|
value: e,
|
|
135
135
|
enumerable: !0
|
|
136
|
-
}) : n, e)),
|
|
136
|
+
}) : n, e)), je = (e) => `${e.queryKey}_${Date.now().toString(36)}_${Math.random().toString(36).substring(2)}`, Me = /* @__PURE__ */ Ae((/* @__PURE__ */ Oe(((e, t) => {
|
|
137
137
|
var n = typeof Reflect == "object" ? Reflect : null, r = n && typeof n.apply == "function" ? n.apply : function(e, t, n) {
|
|
138
138
|
return Function.prototype.apply.call(e, t, n);
|
|
139
139
|
}, i = n && typeof n.ownKeys == "function" ? n.ownKeys : Object.getOwnPropertySymbols ? function(e) {
|
|
@@ -308,7 +308,7 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
308
308
|
});
|
|
309
309
|
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
310
310
|
}
|
|
311
|
-
})))()),
|
|
311
|
+
})))()), Ne = (e) => `listen_${String(e)}`, Pe = class extends Me.default {
|
|
312
312
|
emitCallbacks = [];
|
|
313
313
|
constructor(e) {
|
|
314
314
|
super(e);
|
|
@@ -320,26 +320,26 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
320
320
|
onEmit = (e) => (this.emitCallbacks?.push(e), () => {
|
|
321
321
|
this.emitCallbacks = this.emitCallbacks?.filter((t) => t !== e);
|
|
322
322
|
});
|
|
323
|
-
onListener = (e, t) => (super.on(
|
|
324
|
-
super.off(
|
|
323
|
+
onListener = (e, t) => (super.on(Ne(e), t), () => {
|
|
324
|
+
super.off(Ne(e), t);
|
|
325
325
|
});
|
|
326
|
-
on = (e, t) => (super.on(e, t), super.emit(
|
|
327
|
-
off = (e, t) => (super.off(e, t), super.emit(
|
|
326
|
+
on = (e, t) => (super.on(e, t), super.emit(Ne(e), super.listeners(e).length), this);
|
|
327
|
+
off = (e, t) => (super.off(e, t), super.emit(Ne(e), super.listeners(e).length), this);
|
|
328
328
|
addListener = this.on;
|
|
329
329
|
removeListener = this.off;
|
|
330
|
-
},
|
|
331
|
-
emitter = new
|
|
332
|
-
events =
|
|
330
|
+
}, Fe = class {
|
|
331
|
+
emitter = new Pe();
|
|
332
|
+
events = Be(this.emitter);
|
|
333
333
|
isBrowser;
|
|
334
334
|
isOnline;
|
|
335
335
|
isFocused;
|
|
336
336
|
constructor(e) {
|
|
337
337
|
this.options = e, this.emitter?.setMaxListeners(1e3);
|
|
338
|
-
let { initiallyFocused: t =
|
|
339
|
-
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser =
|
|
338
|
+
let { initiallyFocused: t = Ve.initiallyFocused, initiallyOnline: n = Ve.initiallyOnline } = this.options || Ve;
|
|
339
|
+
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser = Le();
|
|
340
340
|
}
|
|
341
341
|
initialize = () => {
|
|
342
|
-
let { focusEvent: e =
|
|
342
|
+
let { focusEvent: e = Ve.focusEvent, onlineEvent: t = Ve.onlineEvent } = this.options || Ve;
|
|
343
343
|
e(this.setFocused), t(this.setOnline);
|
|
344
344
|
};
|
|
345
345
|
setInitialFocus = async (e) => {
|
|
@@ -354,50 +354,50 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
354
354
|
setOnline = (e) => {
|
|
355
355
|
this.isOnline = e, e ? this.events.emitOnline() : this.events.emitOffline();
|
|
356
356
|
};
|
|
357
|
-
},
|
|
357
|
+
}, Ie = () => {
|
|
358
358
|
try {
|
|
359
359
|
return !!(window && window.addEventListener);
|
|
360
360
|
} catch {
|
|
361
361
|
/* istanbul ignore next */
|
|
362
362
|
return !1;
|
|
363
363
|
}
|
|
364
|
-
},
|
|
364
|
+
}, Le = () => {
|
|
365
365
|
try {
|
|
366
|
-
return !!(
|
|
366
|
+
return !!(Ie() && window.document && window.document.addEventListener);
|
|
367
367
|
} catch {
|
|
368
368
|
/* istanbul ignore next */
|
|
369
369
|
return !1;
|
|
370
370
|
}
|
|
371
|
-
},
|
|
371
|
+
}, Re = (e, t, n) => Ie() ? (window.addEventListener(e, t, n), () => window.removeEventListener(e, t, n)) : () => null, ze = (e, t, n) => Le() ? (window.document.addEventListener(e, t, n), () => window.document.removeEventListener(e, t, n)) : () => null, Be = (e) => ({
|
|
372
372
|
emitFocus: () => {
|
|
373
|
-
e.emit(
|
|
373
|
+
e.emit(V.FOCUS);
|
|
374
374
|
},
|
|
375
375
|
emitBlur: () => {
|
|
376
|
-
e.emit(
|
|
376
|
+
e.emit(V.BLUR);
|
|
377
377
|
},
|
|
378
378
|
emitOnline: () => {
|
|
379
|
-
e.emit(
|
|
379
|
+
e.emit(V.ONLINE);
|
|
380
380
|
},
|
|
381
381
|
emitOffline: () => {
|
|
382
|
-
e.emit(
|
|
382
|
+
e.emit(V.OFFLINE);
|
|
383
383
|
},
|
|
384
|
-
onFocus: (t) => (e.on(
|
|
385
|
-
onBlur: (t) => (e.on(
|
|
386
|
-
onOnline: (t) => (e.on(
|
|
387
|
-
onOffline: (t) => (e.on(
|
|
388
|
-
}),
|
|
384
|
+
onFocus: (t) => (e.on(V.FOCUS, t), () => e.removeListener(V.FOCUS, t)),
|
|
385
|
+
onBlur: (t) => (e.on(V.BLUR, t), () => e.removeListener(V.BLUR, t)),
|
|
386
|
+
onOnline: (t) => (e.on(V.ONLINE, t), () => e.removeListener(V.ONLINE, t)),
|
|
387
|
+
onOffline: (t) => (e.on(V.OFFLINE, t), () => e.removeListener(V.OFFLINE, t))
|
|
388
|
+
}), V = /* @__PURE__ */ function(e) {
|
|
389
389
|
return e.FOCUS = "focus", e.BLUR = "blur", e.ONLINE = "online", e.OFFLINE = "offline", e;
|
|
390
|
-
}({}),
|
|
390
|
+
}({}), Ve = {
|
|
391
391
|
initiallyFocused: !0,
|
|
392
392
|
initiallyOnline: !0,
|
|
393
393
|
focusEvent: (e) => {
|
|
394
|
-
|
|
394
|
+
ze("visibilitychange", () => e(!0)), Re("focus", () => e(!0)), Re("blur", () => e(!1));
|
|
395
395
|
},
|
|
396
396
|
onlineEvent: (e) => {
|
|
397
|
-
|
|
397
|
+
Re("online", () => e(!0)), Re("offline", () => e(!1));
|
|
398
398
|
}
|
|
399
399
|
}, He = class {
|
|
400
|
-
emitter = new
|
|
400
|
+
emitter = new Pe();
|
|
401
401
|
events = vt(this.emitter);
|
|
402
402
|
constructor() {
|
|
403
403
|
this.emitter?.setMaxListeners(1e3);
|
|
@@ -496,7 +496,7 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
496
496
|
logger;
|
|
497
497
|
level;
|
|
498
498
|
modules;
|
|
499
|
-
emitter = new
|
|
499
|
+
emitter = new Me.default();
|
|
500
500
|
client;
|
|
501
501
|
constructor(e) {
|
|
502
502
|
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger || St, this.level = this.options?.level || "warning", this.modules = this.options?.modules;
|
|
@@ -572,16 +572,16 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
572
572
|
constructor(e) {
|
|
573
573
|
super("Unexpected error"), this.description = e, this.name = "UnexpectedError";
|
|
574
574
|
}
|
|
575
|
-
},
|
|
575
|
+
}, Mt = (e) => e === "timeout" ? new Dt() : e === "abort" ? new Ot() : e === "deleted" ? new kt() : e === "processing" ? new At() : new jt(), Nt = (e) => {
|
|
576
576
|
try {
|
|
577
577
|
return JSON.stringify(e);
|
|
578
578
|
} catch {
|
|
579
579
|
return "";
|
|
580
580
|
}
|
|
581
|
-
},
|
|
582
|
-
let t =
|
|
581
|
+
}, Pt = (e) => {
|
|
582
|
+
let t = Ie() && e.payload instanceof FormData, n = typeof e.payload == "object" && e.payload !== null, r = {};
|
|
583
583
|
return !t && n && (r["Content-Type"] = "application/json"), Object.assign(r, e.headers), r;
|
|
584
|
-
},
|
|
584
|
+
}, Ft = (e) => Ie() && e instanceof FormData ? e : Nt(e), It = [
|
|
585
585
|
"onBeforeSent",
|
|
586
586
|
"onRequestStart",
|
|
587
587
|
"onResponseStart",
|
|
@@ -590,7 +590,7 @@ var Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
590
590
|
"onResponse",
|
|
591
591
|
"onRemove"
|
|
592
592
|
];
|
|
593
|
-
function
|
|
593
|
+
function Lt(e) {
|
|
594
594
|
let t = {
|
|
595
595
|
onBeforeSent: [],
|
|
596
596
|
onRequestStart: [],
|
|
@@ -600,7 +600,7 @@ function It(e) {
|
|
|
600
600
|
onResponse: [],
|
|
601
601
|
onRemove: []
|
|
602
602
|
};
|
|
603
|
-
e &&
|
|
603
|
+
e && It.forEach((n) => {
|
|
604
604
|
t[n] = [...e[n]];
|
|
605
605
|
});
|
|
606
606
|
let n = (e) => (n) => (t[e].push(n), () => {
|
|
@@ -622,15 +622,15 @@ function It(e) {
|
|
|
622
622
|
},
|
|
623
623
|
__snapshot() {
|
|
624
624
|
let e = {};
|
|
625
|
-
return
|
|
625
|
+
return It.forEach((n) => {
|
|
626
626
|
e[n] = [...t[n]];
|
|
627
627
|
}), e;
|
|
628
628
|
}
|
|
629
629
|
};
|
|
630
630
|
}
|
|
631
|
-
var
|
|
631
|
+
var Rt = /* @__PURE__ */ function(e) {
|
|
632
632
|
return e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.PATCH = "PATCH", e.DELETE = "DELETE", e;
|
|
633
|
-
}({}),
|
|
633
|
+
}({}), H = (e, t) => t ? `${t}__${e}` : e, zt = (e) => {
|
|
634
634
|
try {
|
|
635
635
|
if (typeof e == "string") return e;
|
|
636
636
|
if (e == null) return "";
|
|
@@ -640,13 +640,13 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
640
640
|
} catch {
|
|
641
641
|
return "";
|
|
642
642
|
}
|
|
643
|
-
},
|
|
643
|
+
}, Bt = ({ loaded: e, total: t }) => !e || !t ? 0 : Number((e * 100 / t).toFixed(0)), Vt = (e, t, { total: n, loaded: r }) => {
|
|
644
644
|
let i = r / (t - +e || 1), a = Math.max(n, r), o = a - r, s = i ? o / i : null;
|
|
645
645
|
return {
|
|
646
646
|
timeLeft: a === r ? 0 : s,
|
|
647
647
|
sizeLeft: o
|
|
648
648
|
};
|
|
649
|
-
},
|
|
649
|
+
}, Ht = (e, t, n) => {
|
|
650
650
|
let { total: r, loaded: i } = n;
|
|
651
651
|
if (Number.isNaN(r) || Number.isNaN(i)) return {
|
|
652
652
|
progress: 0,
|
|
@@ -656,23 +656,23 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
656
656
|
loaded: 0,
|
|
657
657
|
startTimestamp: +e
|
|
658
658
|
};
|
|
659
|
-
let { timeLeft: a, sizeLeft: o } =
|
|
659
|
+
let { timeLeft: a, sizeLeft: o } = Vt(e, t, n);
|
|
660
660
|
return {
|
|
661
|
-
progress:
|
|
661
|
+
progress: Bt(n),
|
|
662
662
|
timeLeft: a,
|
|
663
663
|
sizeLeft: o,
|
|
664
664
|
total: r,
|
|
665
665
|
loaded: i,
|
|
666
666
|
startTimestamp: +e
|
|
667
667
|
};
|
|
668
|
-
},
|
|
669
|
-
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method ===
|
|
668
|
+
}, Ut = (e) => `${e.method}_${e.requestOptions.endpoint}_${e.cancelable}`, Wt = (e, t) => `${zt(e.method)}_${t ? e.requestOptions.endpoint : zt(e.endpoint)}_${t ? "" : zt(e.queryParams)}`, Gt = (e, t = "auto") => {
|
|
669
|
+
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method === Rt.GET, a = t === "auto" && i || t === "fetch";
|
|
670
670
|
return [a ? n : r, a];
|
|
671
|
-
},
|
|
671
|
+
}, Kt = async (e, t) => {
|
|
672
672
|
let n = e.unstable_responseMapper?.(t);
|
|
673
673
|
return n instanceof Promise ? await n : n || t;
|
|
674
|
-
},
|
|
675
|
-
let { client: n } = e, { requestManager: r } = n, [i] =
|
|
674
|
+
}, qt = async (e, t) => {
|
|
675
|
+
let { client: n } = e, { requestManager: r } = n, [i] = Gt(e, t?.dispatcherType), a;
|
|
676
676
|
if (e.optimistic) try {
|
|
677
677
|
a = await e.optimistic({
|
|
678
678
|
request: e,
|
|
@@ -748,7 +748,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
748
748
|
data: null,
|
|
749
749
|
status: null,
|
|
750
750
|
success: !1,
|
|
751
|
-
error:
|
|
751
|
+
error: Mt("deleted"),
|
|
752
752
|
extra: e.client.adapter.defaultExtra,
|
|
753
753
|
requestTimestamp: +/* @__PURE__ */ new Date(),
|
|
754
754
|
responseTimestamp: +/* @__PURE__ */ new Date()
|
|
@@ -759,9 +759,9 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
759
759
|
u(), d(), f(), p(), m(), h();
|
|
760
760
|
}
|
|
761
761
|
});
|
|
762
|
-
},
|
|
762
|
+
}, Jt = /* @__PURE__ */ function(e) {
|
|
763
763
|
return e[e.SEC = 1e3] = "SEC", e[e.MIN = 6e4] = "MIN", e[e.HOUR = 36e5] = "HOUR", e[e.DAY = 864e5] = "DAY", e[e.WEEK = 6048e5] = "WEEK", e[e.MONTH_30 = 2592e6] = "MONTH_30", e[e.MONTH_31 = 26784e5] = "MONTH_31", e[e.YEAR = 31536e6] = "YEAR", e[e.YEAR_LEAP = 316224e5] = "YEAR_LEAP", e;
|
|
764
|
-
}({}),
|
|
764
|
+
}({}), Yt = class e {
|
|
765
765
|
endpoint;
|
|
766
766
|
headers;
|
|
767
767
|
auth;
|
|
@@ -785,7 +785,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
785
785
|
deduplicate;
|
|
786
786
|
deduplicateTime;
|
|
787
787
|
scope;
|
|
788
|
-
$hooks =
|
|
788
|
+
$hooks = Lt();
|
|
789
789
|
isMockerEnabled = !1;
|
|
790
790
|
unstable_mock;
|
|
791
791
|
unstable_payloadMapper;
|
|
@@ -802,7 +802,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
802
802
|
updatedQueryKey;
|
|
803
803
|
constructor(e, t, n) {
|
|
804
804
|
this.client = e, this.requestOptions = t, this.initialRequestConfiguration = n;
|
|
805
|
-
let { endpoint: r, headers: i, auth: a = !0, method: o = e.adapter.defaultMethod, options: s, cancelable: c = !1, retry: l = 0, retryTime: u = 500, cacheTime: d =
|
|
805
|
+
let { endpoint: r, headers: i, auth: a = !0, method: o = e.adapter.defaultMethod, options: s, cancelable: c = !1, retry: l = 0, retryTime: u = 500, cacheTime: d = Jt.MIN * 5, cache: f = !0, staleTime: p = Jt.MIN * 5, queued: m = !1, offline: h = !0, abortKey: g, cacheKey: _, queryKey: v, deduplicate: y = !1, deduplicateTime: b = null } = {
|
|
806
806
|
...this.client.adapter.unstable_getRequestDefaults?.(t),
|
|
807
807
|
...t
|
|
808
808
|
};
|
|
@@ -912,11 +912,11 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
912
912
|
payload: t?.payload || this.payload,
|
|
913
913
|
params: t?.params || this.params
|
|
914
914
|
}, r = new e(this.client, this.requestOptions, n);
|
|
915
|
-
return r.unstable_payloadMapper = this.unstable_payloadMapper, r.unstable_responseMapper = this.unstable_responseMapper, r.unstable_requestMapper = this.unstable_requestMapper, r.retryOnError = this.retryOnError, r.unstable_mock = this.unstable_mock, r.isMockerEnabled = this.isMockerEnabled, r.optimistic = this.optimistic, r.$hooks =
|
|
915
|
+
return r.unstable_payloadMapper = this.unstable_payloadMapper, r.unstable_responseMapper = this.unstable_responseMapper, r.unstable_requestMapper = this.unstable_requestMapper, r.retryOnError = this.retryOnError, r.unstable_mock = this.unstable_mock, r.isMockerEnabled = this.isMockerEnabled, r.optimistic = this.optimistic, r.$hooks = Lt(this.$hooks.__snapshot()), r;
|
|
916
916
|
}
|
|
917
917
|
abort = () => {
|
|
918
918
|
let { requestManager: e } = this.client;
|
|
919
|
-
return e.abortByKey(
|
|
919
|
+
return e.abortByKey(H(this.abortKey, this.scope)), this.clone();
|
|
920
920
|
};
|
|
921
921
|
dehydrate = (e) => {
|
|
922
922
|
let { response: t, override: n = !0 } = e || {};
|
|
@@ -931,7 +931,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
931
931
|
cache: !0,
|
|
932
932
|
response: t
|
|
933
933
|
};
|
|
934
|
-
let r = this.client.cache.get(
|
|
934
|
+
let r = this.client.cache.get(H(this.cacheKey, this.scope));
|
|
935
935
|
if (r) return {
|
|
936
936
|
override: n,
|
|
937
937
|
cacheTime: this.cacheTime,
|
|
@@ -953,7 +953,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
953
953
|
};
|
|
954
954
|
};
|
|
955
955
|
read() {
|
|
956
|
-
let e = this.client.cache.get(
|
|
956
|
+
let e = this.client.cache.get(H(this.cacheKey, this.scope));
|
|
957
957
|
if (e) return {
|
|
958
958
|
data: e.data,
|
|
959
959
|
error: e.error,
|
|
@@ -965,7 +965,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
965
965
|
};
|
|
966
966
|
}
|
|
967
967
|
exec = async (e) => {
|
|
968
|
-
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a =
|
|
968
|
+
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a = H(this.abortKey, this.scope);
|
|
969
969
|
n.addAbortController(a, i);
|
|
970
970
|
let o = await t.fetch(r, i);
|
|
971
971
|
return n.removeAbortController(a, i), r.unstable_responseMapper ? r.unstable_responseMapper(o) : o;
|
|
@@ -975,17 +975,17 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
975
975
|
...e,
|
|
976
976
|
cachePolicy: void 0
|
|
977
977
|
};
|
|
978
|
-
if (n === "network-only") return
|
|
978
|
+
if (n === "network-only") return qt(i, a);
|
|
979
979
|
let o = i.read();
|
|
980
|
-
if (n === "cache-first") return o ?
|
|
980
|
+
if (n === "cache-first") return o ? Kt(i, o) : qt(i, a);
|
|
981
981
|
if (o) {
|
|
982
|
-
let e = await
|
|
983
|
-
return
|
|
982
|
+
let e = await Kt(i, o);
|
|
983
|
+
return qt(i, a), e;
|
|
984
984
|
}
|
|
985
|
-
return
|
|
985
|
+
return qt(i, a);
|
|
986
986
|
};
|
|
987
987
|
static fromJSON = (t, n) => new e(t, n.requestOptions, n);
|
|
988
|
-
},
|
|
988
|
+
}, Xt = async ({ request: e, requestId: t, resolve: n, onStartTime: r, internalErrorMapping: i }) => {
|
|
989
989
|
let { requestManager: a, loggerManager: o } = e.client, { unstable_payloadMapper: s } = e.client.adapter, c = o.initialize(e.client, "Adapter"), l = null, u = null, d = e, f = 1, p = 1, m = 0, h = 0;
|
|
990
990
|
c.debug({
|
|
991
991
|
title: "Running middleware callbacks",
|
|
@@ -995,7 +995,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
995
995
|
requestId: t
|
|
996
996
|
}
|
|
997
997
|
}), d = await d.client.unstable_modifyRequest(d), d.auth && (d = await d.client.unstable_modifyAuth(d)), d.unstable_requestMapper && (d = await d.unstable_requestMapper(d, t));
|
|
998
|
-
let { client: g, abortKey: _ } = d, v =
|
|
998
|
+
let { client: g, abortKey: _ } = d, v = H(_, d.scope), y = d.payload;
|
|
999
999
|
d.unstable_payloadMapper ? y = await d.unstable_payloadMapper(d.payload) : s && (y = await s(y));
|
|
1000
1000
|
let b = d.options, x = +/* @__PURE__ */ new Date();
|
|
1001
1001
|
r(x);
|
|
@@ -1004,14 +1004,14 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1004
1004
|
let n = Number(t.total || 0), r = Number(t.loaded || 0);
|
|
1005
1005
|
return Math.max(n, r, e);
|
|
1006
1006
|
}, T = (e, n, r) => {
|
|
1007
|
-
let i =
|
|
1007
|
+
let i = Ht(new Date(e), new Date(n), r);
|
|
1008
1008
|
m !== 100 && (m = i.total, a.events.emitUploadProgress({
|
|
1009
1009
|
...i,
|
|
1010
1010
|
requestId: t,
|
|
1011
1011
|
request: d
|
|
1012
1012
|
}));
|
|
1013
1013
|
}, E = (e, n, r) => {
|
|
1014
|
-
let i =
|
|
1014
|
+
let i = Ht(new Date(e), new Date(n), r);
|
|
1015
1015
|
h !== 100 && (h = i.total, a.events.emitDownloadProgress({
|
|
1016
1016
|
...i,
|
|
1017
1017
|
requestId: t,
|
|
@@ -1074,14 +1074,14 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1074
1074
|
total: e.total || p,
|
|
1075
1075
|
loaded: e.loaded || 0
|
|
1076
1076
|
}), t;
|
|
1077
|
-
},
|
|
1077
|
+
}, M = () => {
|
|
1078
1078
|
u ||= +/* @__PURE__ */ new Date();
|
|
1079
1079
|
let e = +/* @__PURE__ */ new Date();
|
|
1080
1080
|
return E(u, e, {
|
|
1081
1081
|
total: p,
|
|
1082
1082
|
loaded: p
|
|
1083
1083
|
}), e;
|
|
1084
|
-
},
|
|
1084
|
+
}, te = async ({ data: e, error: r, status: i, extra: a }) => {
|
|
1085
1085
|
let o = {
|
|
1086
1086
|
data: e,
|
|
1087
1087
|
error: r ?? null,
|
|
@@ -1106,50 +1106,50 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1106
1106
|
response: o
|
|
1107
1107
|
}
|
|
1108
1108
|
}), o;
|
|
1109
|
-
},
|
|
1109
|
+
}, N = Zt({
|
|
1110
1110
|
request: d,
|
|
1111
1111
|
requestId: t,
|
|
1112
1112
|
startTime: x,
|
|
1113
1113
|
logger: c,
|
|
1114
1114
|
resolve: n
|
|
1115
|
-
}),
|
|
1115
|
+
}), P = ({ status: e, extra: n }) => (c.error({
|
|
1116
1116
|
title: "Abort error",
|
|
1117
1117
|
type: "request",
|
|
1118
1118
|
extra: {
|
|
1119
1119
|
request: d,
|
|
1120
1120
|
requestId: t
|
|
1121
1121
|
}
|
|
1122
|
-
}),
|
|
1123
|
-
error: i(
|
|
1122
|
+
}), N({
|
|
1123
|
+
error: i(Mt("abort")),
|
|
1124
1124
|
status: e,
|
|
1125
1125
|
extra: n
|
|
1126
|
-
})),
|
|
1126
|
+
})), F = ({ status: e, extra: n }) => (c.error({
|
|
1127
1127
|
title: "Timeout error",
|
|
1128
1128
|
type: "request",
|
|
1129
1129
|
extra: {
|
|
1130
1130
|
request: d,
|
|
1131
1131
|
requestId: t
|
|
1132
1132
|
}
|
|
1133
|
-
}),
|
|
1134
|
-
error:
|
|
1133
|
+
}), N({
|
|
1134
|
+
error: Mt("timeout"),
|
|
1135
1135
|
status: e,
|
|
1136
1136
|
extra: n
|
|
1137
|
-
})),
|
|
1137
|
+
})), ne = ({ status: e, extra: n }) => (c.error({
|
|
1138
1138
|
title: "Unexpected error",
|
|
1139
1139
|
type: "request",
|
|
1140
1140
|
extra: {
|
|
1141
1141
|
request: d,
|
|
1142
1142
|
requestId: t
|
|
1143
1143
|
}
|
|
1144
|
-
}),
|
|
1145
|
-
error:
|
|
1144
|
+
}), N({
|
|
1145
|
+
error: Mt(),
|
|
1146
1146
|
status: e,
|
|
1147
1147
|
extra: n
|
|
1148
|
-
})),
|
|
1149
|
-
let i =
|
|
1148
|
+
})), I = () => a.getAbortController(v, t), re = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1149
|
+
let i = I();
|
|
1150
1150
|
if (!i) throw new At("Controller is not found");
|
|
1151
1151
|
let o = () => {
|
|
1152
|
-
|
|
1152
|
+
P({
|
|
1153
1153
|
status: e,
|
|
1154
1154
|
extra: n
|
|
1155
1155
|
}), r(), a.events.emitAbort({
|
|
@@ -1169,36 +1169,36 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1169
1169
|
adapterOptions: b
|
|
1170
1170
|
}
|
|
1171
1171
|
});
|
|
1172
|
-
let
|
|
1172
|
+
let ie = e.client.adapter.unstable_queryParamsMapper(d.queryParams), ae = e.client.adapter.unstable_endpointMapper(d.endpoint), oe = e.client.adapter.unstable_headerMapper(d), { url: L } = e.client;
|
|
1173
1173
|
return {
|
|
1174
1174
|
request: d,
|
|
1175
1175
|
requestId: t,
|
|
1176
|
-
url:
|
|
1177
|
-
endpoint:
|
|
1178
|
-
queryParams:
|
|
1176
|
+
url: L,
|
|
1177
|
+
endpoint: ae,
|
|
1178
|
+
queryParams: ie,
|
|
1179
1179
|
payload: y,
|
|
1180
|
-
headers:
|
|
1180
|
+
headers: oe,
|
|
1181
1181
|
adapter: e.client.adapter,
|
|
1182
1182
|
adapterOptions: b,
|
|
1183
|
-
getAbortController:
|
|
1183
|
+
getAbortController: I,
|
|
1184
1184
|
getRequestStartTimestamp: S,
|
|
1185
1185
|
getResponseStartTimestamp: C,
|
|
1186
|
-
createAbortListener:
|
|
1186
|
+
createAbortListener: re,
|
|
1187
1187
|
onBeforeRequest: D,
|
|
1188
1188
|
onRequestStart: O,
|
|
1189
1189
|
onRequestProgress: k,
|
|
1190
1190
|
onRequestEnd: ee,
|
|
1191
1191
|
onResponseStart: A,
|
|
1192
1192
|
onResponseProgress: j,
|
|
1193
|
-
onResponseEnd:
|
|
1194
|
-
onSuccess:
|
|
1195
|
-
onAbortError:
|
|
1196
|
-
onTimeoutError:
|
|
1197
|
-
onUnexpectedError:
|
|
1198
|
-
onError:
|
|
1193
|
+
onResponseEnd: M,
|
|
1194
|
+
onSuccess: te,
|
|
1195
|
+
onAbortError: P,
|
|
1196
|
+
onTimeoutError: F,
|
|
1197
|
+
onUnexpectedError: ne,
|
|
1198
|
+
onError: N
|
|
1199
1199
|
};
|
|
1200
1200
|
};
|
|
1201
|
-
function
|
|
1201
|
+
function Zt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
1202
1202
|
let { client: a } = e;
|
|
1203
1203
|
return async ({ error: o, status: s, extra: c }) => {
|
|
1204
1204
|
let l = {
|
|
@@ -1227,7 +1227,7 @@ function Xt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
|
1227
1227
|
}), l;
|
|
1228
1228
|
};
|
|
1229
1229
|
}
|
|
1230
|
-
var
|
|
1230
|
+
var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTimeoutError: i, onRequestEnd: a, createAbortListener: o, onResponseProgress: s, onRequestProgress: c, onResponseStart: l, onBeforeRequest: u, onRequestStart: d, onSuccess: f, onAbortError: p, adapter: m }) => {
|
|
1231
1231
|
if (!e.unstable_mock) throw new At("Mock should be defined when calling mocker");
|
|
1232
1232
|
let h = !1, { requestTime: g = 20, responseTime: _ = 20, totalUploaded: v = 1e3, totalDownloaded: y = 1e3, timeout: b } = e.unstable_mock.config, { data: x, error: S, status: C, success: w = !0, extra: T = e.client.adapter.defaultExtra } = await e.unstable_mock.fn({
|
|
1233
1233
|
request: e,
|
|
@@ -1272,7 +1272,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1272
1272
|
status: C,
|
|
1273
1273
|
extra: T
|
|
1274
1274
|
}), h || r();
|
|
1275
|
-
},
|
|
1275
|
+
}, $t = (e) => e, en = class {
|
|
1276
1276
|
unstable_fetcher;
|
|
1277
1277
|
name;
|
|
1278
1278
|
defaultMethod;
|
|
@@ -1294,10 +1294,10 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1294
1294
|
initialize = (e) => (this.logger = e.loggerManager.initialize(e, "Adapter"), this.initialized = !0, this.client = e, this.unstable_onInitializeCallback?.({ client: e }), this);
|
|
1295
1295
|
onInitialize = (e) => (this.unstable_onInitializeCallback = e, this);
|
|
1296
1296
|
unstable_internalErrorMapping = (e) => e;
|
|
1297
|
-
unstable_headerMapper =
|
|
1298
|
-
unstable_payloadMapper =
|
|
1299
|
-
unstable_endpointMapper =
|
|
1300
|
-
unstable_queryParamsMapper =
|
|
1297
|
+
unstable_headerMapper = Pt;
|
|
1298
|
+
unstable_payloadMapper = Ft;
|
|
1299
|
+
unstable_endpointMapper = $t;
|
|
1300
|
+
unstable_queryParamsMapper = $t;
|
|
1301
1301
|
unstable_getAdapterDefaults;
|
|
1302
1302
|
unstable_getRequestDefaults;
|
|
1303
1303
|
unstable_devtoolsEndpointGetter = (e) => e;
|
|
@@ -1328,7 +1328,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1328
1328
|
request: e,
|
|
1329
1329
|
requestId: t
|
|
1330
1330
|
});
|
|
1331
|
-
let i = await
|
|
1331
|
+
let i = await Xt({
|
|
1332
1332
|
request: e,
|
|
1333
1333
|
requestId: t,
|
|
1334
1334
|
resolve: r,
|
|
@@ -1337,9 +1337,9 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1337
1337
|
n = e;
|
|
1338
1338
|
}
|
|
1339
1339
|
});
|
|
1340
|
-
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await
|
|
1340
|
+
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await Qt(i) : this.unstable_fetcher(i);
|
|
1341
1341
|
} catch (i) {
|
|
1342
|
-
return
|
|
1342
|
+
return Zt({
|
|
1343
1343
|
request: e,
|
|
1344
1344
|
requestId: t,
|
|
1345
1345
|
startTime: n || Date.now(),
|
|
@@ -1356,66 +1356,66 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1356
1356
|
r(e);
|
|
1357
1357
|
});
|
|
1358
1358
|
}
|
|
1359
|
-
},
|
|
1359
|
+
}, tn = (e) => {
|
|
1360
1360
|
try {
|
|
1361
1361
|
return JSON.parse(e);
|
|
1362
1362
|
} catch {
|
|
1363
1363
|
return e;
|
|
1364
1364
|
}
|
|
1365
|
-
},
|
|
1365
|
+
}, nn = (e) => e ? tn(e) : Mt(), rn = (e) => (t) => {
|
|
1366
1366
|
let { skipNull: n, skipEmptyString: r } = e;
|
|
1367
1367
|
return !(r && t === void 0 || r && t === "" || n && t === null);
|
|
1368
|
-
},
|
|
1369
|
-
let r = !
|
|
1370
|
-
return !e || r ? "" : `${
|
|
1371
|
-
},
|
|
1368
|
+
}, U = (e, { encode: t, strict: n }) => t && n ? encodeURIComponent(e).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`) : t ? encodeURIComponent(e) : e, an = (e, t, n) => {
|
|
1369
|
+
let r = !rn(n)(t);
|
|
1370
|
+
return !e || r ? "" : `${U(e, n)}=${U(t instanceof Date ? n.dateParser?.(t) || t.toISOString() : typeof t == "object" && !Array.isArray(t) ? n.objectParser?.(t) || JSON.stringify(t) : String(t), n)}`;
|
|
1371
|
+
}, on = (e, t, n) => {
|
|
1372
1372
|
let { arrayFormat: r, arraySeparator: i } = n;
|
|
1373
|
-
return t.filter(
|
|
1373
|
+
return t.filter(rn(n)).reduce((t, a, o) => {
|
|
1374
1374
|
switch (r) {
|
|
1375
1375
|
case "index": {
|
|
1376
|
-
let r = `${
|
|
1377
|
-
t.push(`${r}${
|
|
1376
|
+
let r = `${U(e, n)}[${U(String(o), n)}]=`;
|
|
1377
|
+
t.push(`${r}${U(String(a), n)}`);
|
|
1378
1378
|
break;
|
|
1379
1379
|
}
|
|
1380
1380
|
case "bracket": {
|
|
1381
|
-
let r = `${
|
|
1382
|
-
t.push(`${r}${
|
|
1381
|
+
let r = `${U(e, n)}[]=`;
|
|
1382
|
+
t.push(`${r}${U(String(a), n)}`);
|
|
1383
1383
|
break;
|
|
1384
1384
|
}
|
|
1385
1385
|
case "comma": {
|
|
1386
|
-
let r = !t.length && `${
|
|
1387
|
-
return [[...t, `${r}${
|
|
1386
|
+
let r = !t.length && `${U(e, n)}=` || "";
|
|
1387
|
+
return [[...t, `${r}${U(String(a), n)}`].join(",")];
|
|
1388
1388
|
}
|
|
1389
1389
|
case "separator": {
|
|
1390
|
-
let r = !t.length && `${
|
|
1391
|
-
return [[...t, `${r}${
|
|
1390
|
+
let r = !t.length && `${U(e, n)}=` || "";
|
|
1391
|
+
return [[...t, `${r}${U(String(a), n)}`].join(i || "|")];
|
|
1392
1392
|
}
|
|
1393
1393
|
case "bracket-separator": {
|
|
1394
|
-
let r = !t.length && `${
|
|
1395
|
-
return [[...t, `${r}${
|
|
1394
|
+
let r = !t.length && `${U(e, n)}[]=` || "";
|
|
1395
|
+
return [[...t, `${r}${U(String(a), n)}`].join(i || "|")];
|
|
1396
1396
|
}
|
|
1397
1397
|
default: {
|
|
1398
|
-
let r = `${
|
|
1399
|
-
t.push(`${r}${
|
|
1398
|
+
let r = `${U(e, n)}=`;
|
|
1399
|
+
t.push(`${r}${U(String(a), n)}`);
|
|
1400
1400
|
}
|
|
1401
1401
|
}
|
|
1402
1402
|
return t;
|
|
1403
1403
|
}, []).join("&");
|
|
1404
|
-
},
|
|
1404
|
+
}, sn = (e, t = In) => {
|
|
1405
1405
|
if (!e || !Object.keys(e).length) return "";
|
|
1406
1406
|
if (typeof e == "string") return e[0] === "?" ? e : `?${e}`;
|
|
1407
|
-
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ?
|
|
1407
|
+
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ? on(e, n, t) : an(e, n, t)).filter(Boolean).join("&");
|
|
1408
1408
|
return n ? `?${n}` : "";
|
|
1409
|
-
},
|
|
1409
|
+
}, cn = Jt.SEC * 5, ln = { headers: {} }, un = () => new en({
|
|
1410
1410
|
name: "http",
|
|
1411
|
-
defaultMethod:
|
|
1412
|
-
defaultExtra:
|
|
1411
|
+
defaultMethod: Rt.GET,
|
|
1412
|
+
defaultExtra: ln,
|
|
1413
1413
|
systemErrorStatus: 0,
|
|
1414
|
-
systemErrorExtra:
|
|
1415
|
-
}).setQueryParamsMapper(
|
|
1416
|
-
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ?
|
|
1414
|
+
systemErrorExtra: ln
|
|
1415
|
+
}).setQueryParamsMapper(sn).setFetcher(async ({ request: e, adapterOptions: t, headers: n, payload: r, onError: i, onResponseEnd: a, onTimeoutError: o, onRequestEnd: s, createAbortListener: c, getAbortController: l, onResponseProgress: u, onResponseStart: d, onBeforeRequest: f, onRequestStart: p, onRequestProgress: m, onSuccess: h }) => {
|
|
1416
|
+
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ? sn(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = cn, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
|
|
1417
1417
|
status: 0,
|
|
1418
|
-
extra:
|
|
1418
|
+
extra: ln
|
|
1419
1419
|
});
|
|
1420
1420
|
C > 0 && S && (D = setTimeout(() => {
|
|
1421
1421
|
E = !0, O(), S.abort();
|
|
@@ -1447,7 +1447,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1447
1447
|
status: l,
|
|
1448
1448
|
extra: c
|
|
1449
1449
|
}) : i({
|
|
1450
|
-
error:
|
|
1450
|
+
error: nn(await t.text()),
|
|
1451
1451
|
status: l,
|
|
1452
1452
|
extra: c
|
|
1453
1453
|
});
|
|
@@ -1468,11 +1468,11 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1468
1468
|
e = new TextDecoder().decode(o);
|
|
1469
1469
|
} else e = await t.text();
|
|
1470
1470
|
a(), O(), t.ok ? h({
|
|
1471
|
-
data:
|
|
1471
|
+
data: tn(e),
|
|
1472
1472
|
status: l,
|
|
1473
1473
|
extra: c
|
|
1474
1474
|
}) : i({
|
|
1475
|
-
error:
|
|
1475
|
+
error: nn(e),
|
|
1476
1476
|
status: l,
|
|
1477
1477
|
extra: c
|
|
1478
1478
|
});
|
|
@@ -1481,18 +1481,18 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1481
1481
|
if (D && clearTimeout(D), O(), S?.signal?.aborted) {
|
|
1482
1482
|
E && o({
|
|
1483
1483
|
status: 0,
|
|
1484
|
-
extra:
|
|
1484
|
+
extra: ln
|
|
1485
1485
|
});
|
|
1486
1486
|
return;
|
|
1487
1487
|
}
|
|
1488
1488
|
i({
|
|
1489
1489
|
error: e,
|
|
1490
1490
|
status: 0,
|
|
1491
|
-
extra:
|
|
1491
|
+
extra: ln
|
|
1492
1492
|
});
|
|
1493
1493
|
}
|
|
1494
|
-
}),
|
|
1495
|
-
emitter = new
|
|
1494
|
+
}), dn = () => un(), fn = class {
|
|
1495
|
+
emitter = new Pe();
|
|
1496
1496
|
events;
|
|
1497
1497
|
storage;
|
|
1498
1498
|
lazyStorage;
|
|
@@ -1503,7 +1503,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1503
1503
|
constructor(e) {
|
|
1504
1504
|
this.options = e;
|
|
1505
1505
|
let { storage: t = /* @__PURE__ */ new Map(), lazyStorage: n, version: r = "0.0.1" } = e ?? {};
|
|
1506
|
-
this.emitter?.setMaxListeners(1e3), this.events =
|
|
1506
|
+
this.emitter?.setMaxListeners(1e3), this.events = bn(this.emitter), this.storage = t, this.version = r, this.lazyStorage = n;
|
|
1507
1507
|
}
|
|
1508
1508
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Cache"), e.appManager.events.onOnline(() => {
|
|
1509
1509
|
[...this.storage.keys()].forEach(this.scheduleGarbageCollector);
|
|
@@ -1517,7 +1517,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1517
1517
|
response: t
|
|
1518
1518
|
}
|
|
1519
1519
|
});
|
|
1520
|
-
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s =
|
|
1520
|
+
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = H(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u = pn(c, l), d = {
|
|
1521
1521
|
...u,
|
|
1522
1522
|
scope: o,
|
|
1523
1523
|
staleTime: i,
|
|
@@ -1563,7 +1563,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1563
1563
|
partialResponse: t
|
|
1564
1564
|
}
|
|
1565
1565
|
});
|
|
1566
|
-
let { cacheKey: n, scope: r } = e, i =
|
|
1566
|
+
let { cacheKey: n, scope: r } = e, i = H(n, r), a = this.storage.get(i), o = typeof t == "function" ? t(a || null) : t;
|
|
1567
1567
|
a && this.set(e, {
|
|
1568
1568
|
...a,
|
|
1569
1569
|
...o
|
|
@@ -1601,7 +1601,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1601
1601
|
cacheKey: t
|
|
1602
1602
|
}), this.events.emitInvalidation(t);
|
|
1603
1603
|
};
|
|
1604
|
-
e instanceof
|
|
1604
|
+
e instanceof Yt ? n(H(e.cacheKey, e.scope), e.cacheKey) : typeof e == "string" ? n(e) : t.length && t.forEach((t) => {
|
|
1605
1605
|
e.test(t) && n(t);
|
|
1606
1606
|
});
|
|
1607
1607
|
};
|
|
@@ -1656,49 +1656,49 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1656
1656
|
clear = async () => {
|
|
1657
1657
|
this.garbageCollectors.forEach((e) => clearTimeout(e)), this.storage.clear();
|
|
1658
1658
|
};
|
|
1659
|
-
},
|
|
1659
|
+
}, pn = (e, t) => {
|
|
1660
1660
|
let { data: n, success: r } = t, i = !r && e ? e.data : null, a = n || i;
|
|
1661
1661
|
return {
|
|
1662
1662
|
...t,
|
|
1663
1663
|
data: a
|
|
1664
1664
|
};
|
|
1665
|
-
},
|
|
1665
|
+
}, mn = () => "invalidate", hn = (e) => `${e}_invalidate`, gn = () => "delete", _n = (e) => `${e}_delete`, vn = (e) => `${e}_cache`, yn = () => "cache", bn = (e) => ({
|
|
1666
1666
|
emitCacheData: (t, n = !1) => {
|
|
1667
|
-
e.emit(
|
|
1667
|
+
e.emit(yn(), t, n), e.emit(vn(t.cacheKey), t, n);
|
|
1668
1668
|
},
|
|
1669
1669
|
emitInvalidation: (t, n = !1) => {
|
|
1670
|
-
e.emit(
|
|
1670
|
+
e.emit(mn(), t, n), e.emit(hn(t), n);
|
|
1671
1671
|
},
|
|
1672
1672
|
emitDelete: (t, n = !1) => {
|
|
1673
|
-
e.emit(
|
|
1673
|
+
e.emit(gn(), t, n), e.emit(_n(t), n);
|
|
1674
1674
|
},
|
|
1675
|
-
onData: (t) => (e.on(
|
|
1676
|
-
onDataByKey: (t, n) => (e.on(
|
|
1677
|
-
onInvalidate: (t) => (e.on(
|
|
1678
|
-
onInvalidateByKey: (t, n) => (e.on(
|
|
1679
|
-
onDelete: (t) => (e.on(
|
|
1680
|
-
onDeleteByKey: (t, n) => (e.on(
|
|
1681
|
-
}),
|
|
1675
|
+
onData: (t) => (e.on(yn(), t), () => e.removeListener(yn(), t)),
|
|
1676
|
+
onDataByKey: (t, n) => (e.on(vn(t), n), () => e.removeListener(vn(t), n)),
|
|
1677
|
+
onInvalidate: (t) => (e.on(mn(), t), () => e.removeListener(mn(), t)),
|
|
1678
|
+
onInvalidateByKey: (t, n) => (e.on(hn(t), n), () => e.removeListener(hn(t), n)),
|
|
1679
|
+
onDelete: (t) => (e.on(gn(), t), () => e.removeListener(gn(), t)),
|
|
1680
|
+
onDeleteByKey: (t, n) => (e.on(_n(t), n), () => e.removeListener(_n(t), n))
|
|
1681
|
+
}), W = /* @__PURE__ */ function(e) {
|
|
1682
1682
|
return e.ONE_BY_ONE = "one-by-one", e.ALL_AT_ONCE = "all-at-once", e.PREVIOUS_CANCELED = "previous-canceled", e.DEDUPLICATED = "deduplicated", e;
|
|
1683
|
-
}({}),
|
|
1683
|
+
}({}), xn = (e) => ({
|
|
1684
1684
|
emitDrained: (t, n) => {
|
|
1685
|
-
e.emit(
|
|
1685
|
+
e.emit(Cn(), t, n), e.emit(wn(t.queryKey), t, n);
|
|
1686
1686
|
},
|
|
1687
1687
|
emitQueueStatusChanged: (t, n) => {
|
|
1688
|
-
e.emit(
|
|
1688
|
+
e.emit(Tn(), t, n), e.emit(En(t.queryKey), t, n);
|
|
1689
1689
|
},
|
|
1690
1690
|
emitQueueChanged: (t, n) => {
|
|
1691
|
-
e.emit(
|
|
1691
|
+
e.emit(Dn(), t, n), e.emit(On(t.queryKey), t, n);
|
|
1692
1692
|
},
|
|
1693
|
-
onDrained: (t) => (e.on(
|
|
1694
|
-
onDrainedByKey: (t, n) => (e.on(
|
|
1695
|
-
onQueueStatusChange: (t) => (e.on(
|
|
1696
|
-
onQueueStatusChangeByKey: (t, n) => (e.on(
|
|
1697
|
-
onQueueChange: (t) => (e.on(
|
|
1698
|
-
onQueueChangeByKey: (t, n) => (e.on(
|
|
1699
|
-
}),
|
|
1700
|
-
emitter = new
|
|
1701
|
-
events =
|
|
1693
|
+
onDrained: (t) => (e.on(Cn(), t), () => e.removeListener(Cn(), t)),
|
|
1694
|
+
onDrainedByKey: (t, n) => (e.on(wn(t), n), () => e.removeListener(wn(t), n)),
|
|
1695
|
+
onQueueStatusChange: (t) => (e.on(Tn(), t), () => e.removeListener(Tn(), t)),
|
|
1696
|
+
onQueueStatusChangeByKey: (t, n) => (e.on(En(t), n), () => e.removeListener(En(t), n)),
|
|
1697
|
+
onQueueChange: (t) => (e.on(Dn(), t), () => e.removeListener(Dn(), t)),
|
|
1698
|
+
onQueueChangeByKey: (t, n) => (e.on(On(t), n), () => e.removeListener(On(t), n))
|
|
1699
|
+
}), Sn = class {
|
|
1700
|
+
emitter = new Pe();
|
|
1701
|
+
events = xn(this.emitter);
|
|
1702
1702
|
storage = /* @__PURE__ */ new Map();
|
|
1703
1703
|
requestCount = /* @__PURE__ */ new Map();
|
|
1704
1704
|
runningRequests = /* @__PURE__ */ new Map();
|
|
@@ -1707,7 +1707,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1707
1707
|
constructor(e) {
|
|
1708
1708
|
this.options = e, this.emitter?.setMaxListeners(1e3), this.options?.storage && (this.storage = this.options.storage);
|
|
1709
1709
|
}
|
|
1710
|
-
isRequestJSON = (e) => !(e instanceof
|
|
1710
|
+
isRequestJSON = (e) => !(e instanceof Yt);
|
|
1711
1711
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Dispatcher"), this.client.appManager.events.onOnline(() => {
|
|
1712
1712
|
this.flush();
|
|
1713
1713
|
}), this);
|
|
@@ -1831,14 +1831,14 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1831
1831
|
hasRunningRequest = (e, t) => !!this.getRunningRequests(e).find((e) => e.requestId === t);
|
|
1832
1832
|
cancelRunningRequests = (e) => {
|
|
1833
1833
|
this.runningRequests.get(e)?.forEach((e) => {
|
|
1834
|
-
let t =
|
|
1834
|
+
let t = H(e.request.abortKey, e.request.scope);
|
|
1835
1835
|
this.client.requestManager.abortByRequestId(t, e.requestId);
|
|
1836
1836
|
}), this.deleteRunningRequests(e);
|
|
1837
1837
|
};
|
|
1838
1838
|
cancelRunningRequest = (e, t) => {
|
|
1839
1839
|
let n = this.getRunningRequests(e).filter((e) => {
|
|
1840
1840
|
if (e.requestId === t) {
|
|
1841
|
-
let t =
|
|
1841
|
+
let t = H(e.request.abortKey, e.request.scope);
|
|
1842
1842
|
return this.client.requestManager.abortByRequestId(t, e.requestId), !1;
|
|
1843
1843
|
}
|
|
1844
1844
|
return !0;
|
|
@@ -1866,7 +1866,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1866
1866
|
resolved: !1
|
|
1867
1867
|
});
|
|
1868
1868
|
add = (e) => {
|
|
1869
|
-
let t =
|
|
1869
|
+
let t = H(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = jn(e, i);
|
|
1870
1870
|
switch (this.logger.debug({
|
|
1871
1871
|
title: "Adding request to queue",
|
|
1872
1872
|
type: "system",
|
|
@@ -1876,9 +1876,9 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1876
1876
|
requestId: r
|
|
1877
1877
|
}
|
|
1878
1878
|
}), a) {
|
|
1879
|
-
case
|
|
1880
|
-
case
|
|
1881
|
-
case
|
|
1879
|
+
case W.ONE_BY_ONE: return this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1880
|
+
case W.PREVIOUS_CANCELED: return this.cancelRunningRequests(t), this.clearQueue(t), this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1881
|
+
case W.DEDUPLICATED: return this.client.requestManager.events.emitDeduplicated({
|
|
1882
1882
|
request: i.request,
|
|
1883
1883
|
requestId: r,
|
|
1884
1884
|
deduplicatedRequest: e
|
|
@@ -1920,7 +1920,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1920
1920
|
requestId: n
|
|
1921
1921
|
}
|
|
1922
1922
|
});
|
|
1923
|
-
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l =
|
|
1923
|
+
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = H(a, c), u = H(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h = kn(e.retries, r), g = !m.isOnline && s, _ = this.hasRunningRequest(l, n), v = e.stopped;
|
|
1924
1924
|
if (g || _ || v) return this.logger.warning({
|
|
1925
1925
|
title: "Unable to perform request",
|
|
1926
1926
|
type: "system",
|
|
@@ -1940,7 +1940,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1940
1940
|
}), this.incrementQueueRequestCount(l), f.addAbortController(u, n);
|
|
1941
1941
|
let b = await d.fetch(t, n);
|
|
1942
1942
|
e.resolved = !0, f.removeAbortController(u, n);
|
|
1943
|
-
let x = !m.isOnline, S =
|
|
1943
|
+
let x = !m.isOnline, S = Mt("abort").message === b.error?.message, C = !this.hasRunningRequest(l, n) || S;
|
|
1944
1944
|
this.deleteRunningRequest(l, n);
|
|
1945
1945
|
let w = b.success || !h || !t.retryOnError || t.retryOnError(b), T = !b.success && h && w && !C && !x, E = {
|
|
1946
1946
|
isCanceled: C,
|
|
@@ -2054,26 +2054,26 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
2054
2054
|
}
|
|
2055
2055
|
}), this.delete(l, n, u));
|
|
2056
2056
|
};
|
|
2057
|
-
},
|
|
2058
|
-
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ?
|
|
2059
|
-
return n ?
|
|
2057
|
+
}, Cn = () => "drained-event", wn = (e) => `${e}-drained-event`, Tn = () => "status-event", En = (e) => `${e}-status-event`, Dn = () => "change-event", On = (e) => `${e}-change-event`, kn = (e, t) => !!(t && e < t), An = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, jn = (e, t) => {
|
|
2058
|
+
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? An(e, t) : !1;
|
|
2059
|
+
return n ? W.ONE_BY_ONE : r ? W.PREVIOUS_CANCELED : a && i ? W.DEDUPLICATED : W.ALL_AT_ONCE;
|
|
2060
2060
|
};
|
|
2061
|
-
function
|
|
2061
|
+
function Mn(e) {
|
|
2062
2062
|
return e === "client" || e === "server" ? e : typeof window < "u" && typeof document < "u" ? "client" : "server";
|
|
2063
2063
|
}
|
|
2064
|
-
var
|
|
2064
|
+
var Nn = async (e, t) => {
|
|
2065
2065
|
let n = t;
|
|
2066
2066
|
if (!t.requestOptions.disableRequestInterceptors) {
|
|
2067
2067
|
for (let r of e) if (n = await r(t), !n) throw Error("Request modifier must return request");
|
|
2068
2068
|
}
|
|
2069
2069
|
return n;
|
|
2070
|
-
},
|
|
2070
|
+
}, Pn = async (e, t, n) => {
|
|
2071
2071
|
let r = t;
|
|
2072
2072
|
if (!n.requestOptions.disableResponseInterceptors) {
|
|
2073
2073
|
for (let i of e) if (r = await i(t, n), !r) throw Error("Response modifier must return data");
|
|
2074
2074
|
}
|
|
2075
2075
|
return r;
|
|
2076
|
-
},
|
|
2076
|
+
}, Fn = class {
|
|
2077
2077
|
url;
|
|
2078
2078
|
mode;
|
|
2079
2079
|
debug;
|
|
@@ -2091,15 +2091,15 @@ var Mn = async (e, t) => {
|
|
|
2091
2091
|
submitDispatcher;
|
|
2092
2092
|
isMockerEnabled = !0;
|
|
2093
2093
|
plugins = [];
|
|
2094
|
-
unstable_abortKeyMapper =
|
|
2095
|
-
unstable_cacheKeyMapper =
|
|
2096
|
-
unstable_queryKeyMapper =
|
|
2097
|
-
unstable_requestIdMapper =
|
|
2094
|
+
unstable_abortKeyMapper = Ut;
|
|
2095
|
+
unstable_cacheKeyMapper = Wt;
|
|
2096
|
+
unstable_queryKeyMapper = Wt;
|
|
2097
|
+
unstable_requestIdMapper = je;
|
|
2098
2098
|
logger = this.loggerManager.initialize(this, "Client");
|
|
2099
2099
|
constructor(e) {
|
|
2100
2100
|
this.options = e;
|
|
2101
2101
|
let { url: t, appManager: n, cache: r, fetchDispatcher: i, submitDispatcher: a, mode: o } = this.options;
|
|
2102
|
-
this.url = t, this.mode =
|
|
2102
|
+
this.url = t, this.mode = Mn(o), this.adapter = dn(), this.appManager = n?.() || new Fe(), this.cache = r?.() || new fn(), this.fetchDispatcher = i?.() || new Sn(), this.submitDispatcher = a?.() || new Sn(), this.adapter.initialize(this), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2103
2103
|
}
|
|
2104
2104
|
setDebug = (e) => (this.debug = e, this);
|
|
2105
2105
|
setLogLevel = (e) => (this.loggerManager.setSeverity(e), this);
|
|
@@ -2128,15 +2128,15 @@ var Mn = async (e, t) => {
|
|
|
2128
2128
|
setCacheKeyMapper = (e) => (this.unstable_cacheKeyMapper = e, this);
|
|
2129
2129
|
setQueryKeyMapper = (e) => (this.unstable_queryKeyMapper = e, this);
|
|
2130
2130
|
setRequestIdMapper = (e) => (this.unstable_requestIdMapper = e, this);
|
|
2131
|
-
unstable_modifyAuth = async (e) =>
|
|
2132
|
-
unstable_modifyRequest = async (e) =>
|
|
2133
|
-
unstable_modifyErrorResponse = async (e, t) =>
|
|
2134
|
-
unstable_modifySuccessResponse = async (e, t) =>
|
|
2135
|
-
unstable_modifyResponse = async (e, t) =>
|
|
2136
|
-
fromJSON = (e) =>
|
|
2131
|
+
unstable_modifyAuth = async (e) => Nn(this.unstable_onAuthCallbacks, e);
|
|
2132
|
+
unstable_modifyRequest = async (e) => Nn(this.unstable_onRequestCallbacks, e);
|
|
2133
|
+
unstable_modifyErrorResponse = async (e, t) => Pn(this.unstable_onErrorCallbacks, e, t);
|
|
2134
|
+
unstable_modifySuccessResponse = async (e, t) => Pn(this.unstable_onSuccessCallbacks, e, t);
|
|
2135
|
+
unstable_modifyResponse = async (e, t) => Pn(this.unstable_onResponseCallbacks, e, t);
|
|
2136
|
+
fromJSON = (e) => Yt.fromJSON(this, e);
|
|
2137
2137
|
clear = () => {
|
|
2138
2138
|
let { appManager: e, cache: t, fetchDispatcher: n, submitDispatcher: r } = this.options;
|
|
2139
|
-
this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new
|
|
2139
|
+
this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new fn(), this.appManager = e?.() || new Fe(), this.fetchDispatcher = n?.() || new Sn(), this.submitDispatcher = r?.() || new Sn(), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2140
2140
|
};
|
|
2141
2141
|
hydrate = (e, t) => {
|
|
2142
2142
|
e?.forEach((e) => {
|
|
@@ -2153,8 +2153,8 @@ var Mn = async (e, t) => {
|
|
|
2153
2153
|
...a,
|
|
2154
2154
|
...t
|
|
2155
2155
|
};
|
|
2156
|
-
if (!s.override && this.cache.get(
|
|
2157
|
-
let c =
|
|
2156
|
+
if (!s.override && this.cache.get(H(n, r))) return;
|
|
2157
|
+
let c = tn(i);
|
|
2158
2158
|
this.cache.set({
|
|
2159
2159
|
...s,
|
|
2160
2160
|
cacheKey: n,
|
|
@@ -2166,10 +2166,10 @@ var Mn = async (e, t) => {
|
|
|
2166
2166
|
let t = this.adapter.unstable_endpointMapper(e.endpoint), n = {
|
|
2167
2167
|
...e,
|
|
2168
2168
|
endpoint: String(t)
|
|
2169
|
-
}, r = new
|
|
2169
|
+
}, r = new Yt(this, n);
|
|
2170
2170
|
return this.plugins.forEach((e) => e.trigger("onRequestCreate", { request: r })), r;
|
|
2171
2171
|
};
|
|
2172
|
-
},
|
|
2172
|
+
}, In = {
|
|
2173
2173
|
strict: !0,
|
|
2174
2174
|
encode: !0,
|
|
2175
2175
|
arrayFormat: "bracket",
|
|
@@ -2178,101 +2178,101 @@ var Mn = async (e, t) => {
|
|
|
2178
2178
|
skipNull: !0,
|
|
2179
2179
|
skipEmptyString: !0
|
|
2180
2180
|
};
|
|
2181
|
-
function
|
|
2182
|
-
return new
|
|
2181
|
+
function Ln(e) {
|
|
2182
|
+
return new Fn(e);
|
|
2183
2183
|
}
|
|
2184
2184
|
//#endregion
|
|
2185
2185
|
//#region src/core/client.ts
|
|
2186
|
-
var
|
|
2186
|
+
var G = Ln({ url: L() });
|
|
2187
2187
|
//#endregion
|
|
2188
2188
|
//#region src/core/auth-api.ts
|
|
2189
|
-
async function
|
|
2190
|
-
let { data: t, success: n } = await
|
|
2189
|
+
async function Rn(e) {
|
|
2190
|
+
let { data: t, success: n } = await G.createRequest()({
|
|
2191
2191
|
endpoint: "/auth/cli/whoami",
|
|
2192
2192
|
method: "GET"
|
|
2193
2193
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2194
2194
|
return !n || !t ? null : t;
|
|
2195
2195
|
}
|
|
2196
|
-
async function
|
|
2197
|
-
await
|
|
2196
|
+
async function zn(e) {
|
|
2197
|
+
await G.createRequest()({
|
|
2198
2198
|
endpoint: "/auth/cli/token",
|
|
2199
2199
|
method: "DELETE"
|
|
2200
2200
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2201
2201
|
}
|
|
2202
2202
|
//#endregion
|
|
2203
2203
|
//#region src/core/auth-store.ts
|
|
2204
|
-
var
|
|
2205
|
-
function
|
|
2204
|
+
var Bn = 1, Vn = "hype-stack", Hn = "auth.json";
|
|
2205
|
+
function Un() {
|
|
2206
2206
|
let e = process.env.HYPE_STACK_CONFIG_DIR;
|
|
2207
|
-
if (e) return T.join(e,
|
|
2207
|
+
if (e) return T.join(e, Vn);
|
|
2208
2208
|
let t = w.homedir();
|
|
2209
2209
|
if (process.platform === "win32") {
|
|
2210
2210
|
let e = process.env.APPDATA ?? T.join(t, "AppData", "Roaming");
|
|
2211
|
-
return T.join(e,
|
|
2211
|
+
return T.join(e, Vn);
|
|
2212
2212
|
}
|
|
2213
|
-
if (process.platform === "darwin") return T.join(t, "Library", "Application Support",
|
|
2213
|
+
if (process.platform === "darwin") return T.join(t, "Library", "Application Support", Vn);
|
|
2214
2214
|
let n = process.env.XDG_CONFIG_HOME ?? T.join(t, ".config");
|
|
2215
|
-
return T.join(n,
|
|
2215
|
+
return T.join(n, Vn);
|
|
2216
2216
|
}
|
|
2217
|
-
function
|
|
2218
|
-
return T.join(
|
|
2217
|
+
function Wn() {
|
|
2218
|
+
return T.join(Un(), Hn);
|
|
2219
2219
|
}
|
|
2220
|
-
async function
|
|
2221
|
-
let e = await y.readFile(
|
|
2220
|
+
async function Gn() {
|
|
2221
|
+
let e = await y.readFile(Wn(), "utf-8").catch(() => null);
|
|
2222
2222
|
if (!e) return {
|
|
2223
|
-
version:
|
|
2223
|
+
version: Bn,
|
|
2224
2224
|
tokens: {}
|
|
2225
2225
|
};
|
|
2226
2226
|
let t = JSON.parse(e);
|
|
2227
2227
|
return {
|
|
2228
|
-
version: t.version ??
|
|
2228
|
+
version: t.version ?? Bn,
|
|
2229
2229
|
tokens: t.tokens ?? {}
|
|
2230
2230
|
};
|
|
2231
2231
|
}
|
|
2232
|
-
async function Gn(e) {
|
|
2233
|
-
let t = Hn();
|
|
2234
|
-
await y.mkdir(t, { recursive: !0 }), await y.writeFile(Un(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2235
|
-
}
|
|
2236
2232
|
async function Kn(e) {
|
|
2237
|
-
|
|
2233
|
+
let t = Un();
|
|
2234
|
+
await y.mkdir(t, { recursive: !0 }), await y.writeFile(Wn(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2238
2235
|
}
|
|
2239
|
-
async function qn(e
|
|
2240
|
-
|
|
2241
|
-
n.tokens[e] = t, await Gn(n);
|
|
2236
|
+
async function qn(e) {
|
|
2237
|
+
return (await Gn()).tokens[e] ?? null;
|
|
2242
2238
|
}
|
|
2243
|
-
async function Jn(e) {
|
|
2244
|
-
let
|
|
2245
|
-
|
|
2239
|
+
async function Jn(e, t) {
|
|
2240
|
+
let n = await Gn();
|
|
2241
|
+
n.tokens[e] = t, await Kn(n);
|
|
2242
|
+
}
|
|
2243
|
+
async function Yn(e) {
|
|
2244
|
+
let t = await Gn();
|
|
2245
|
+
e in t.tokens && (delete t.tokens[e], await Kn(t));
|
|
2246
2246
|
}
|
|
2247
2247
|
//#endregion
|
|
2248
2248
|
//#region src/core/device.ts
|
|
2249
|
-
function
|
|
2249
|
+
function Xn() {
|
|
2250
2250
|
let e = w.networkInterfaces();
|
|
2251
2251
|
for (let t of Object.values(e)) if (t) {
|
|
2252
2252
|
for (let e of t) if (!e.internal && e.mac !== "00:00:00:00:00:00") return e.mac;
|
|
2253
2253
|
}
|
|
2254
2254
|
return "unknown";
|
|
2255
2255
|
}
|
|
2256
|
-
function
|
|
2257
|
-
let e = `${
|
|
2256
|
+
function Zn() {
|
|
2257
|
+
let e = `${Xn()}:${w.hostname()}:${w.platform()}:${w.arch()}`;
|
|
2258
2258
|
return x("sha256").update(e).digest("hex").slice(0, 16);
|
|
2259
2259
|
}
|
|
2260
|
-
function
|
|
2260
|
+
function Qn() {
|
|
2261
2261
|
return `hype-stack/${A} ${w.platform()} ${w.arch()} node/${process.version.slice(1)}`;
|
|
2262
2262
|
}
|
|
2263
2263
|
//#endregion
|
|
2264
2264
|
//#region src/core/open-browser.ts
|
|
2265
|
-
function
|
|
2265
|
+
function $n(e) {
|
|
2266
2266
|
E(process.platform === "darwin" ? `open "${e}"` : process.platform === "win32" ? `start "" "${e}"` : `xdg-open "${e}"`);
|
|
2267
2267
|
}
|
|
2268
2268
|
//#endregion
|
|
2269
2269
|
//#region src/core/login.ts
|
|
2270
|
-
var
|
|
2271
|
-
async function
|
|
2272
|
-
let t = S(16).toString("hex"), n =
|
|
2270
|
+
var er = 300 * 1e3, tr = (e) => `<!doctype html><html><head><meta charset="utf-8"><title>Hype Stack CLI</title></head><body style="font-family:system-ui,sans-serif;text-align:center;padding-top:4rem;color:#111"><h2>${e}</h2><p>You can close this tab and return to your terminal.</p></body></html>`;
|
|
2271
|
+
async function nr(e = {}) {
|
|
2272
|
+
let t = S(16).toString("hex"), n = L(), r = C.createServer(), i = await new Promise((n, i) => {
|
|
2273
2273
|
let a = setTimeout(() => {
|
|
2274
2274
|
o(), i(/* @__PURE__ */ Error("Login timed out. Run `npx @hype-stack/cli login` again."));
|
|
2275
|
-
},
|
|
2275
|
+
}, er);
|
|
2276
2276
|
function o() {
|
|
2277
2277
|
clearTimeout(a), r.close(), r.closeAllConnections?.();
|
|
2278
2278
|
}
|
|
@@ -2286,7 +2286,7 @@ async function tr(e = {}) {
|
|
|
2286
2286
|
r.writeHead(200, {
|
|
2287
2287
|
"Content-Type": "text/html",
|
|
2288
2288
|
Connection: "close"
|
|
2289
|
-
}), r.end(
|
|
2289
|
+
}), r.end(tr(e));
|
|
2290
2290
|
};
|
|
2291
2291
|
if (a.searchParams.get("state") !== t) {
|
|
2292
2292
|
s("Login failed."), o(), i(/* @__PURE__ */ Error("Login failed: state mismatch. Run `npx @hype-stack/cli login` again."));
|
|
@@ -2301,53 +2301,53 @@ async function tr(e = {}) {
|
|
|
2301
2301
|
}), r.on("error", (e) => {
|
|
2302
2302
|
o(), i(e);
|
|
2303
2303
|
}), r.listen(0, "127.0.0.1", () => {
|
|
2304
|
-
let { port: n } = r.address(), i = encodeURIComponent(
|
|
2305
|
-
e.onUrl?.(a),
|
|
2304
|
+
let { port: n } = r.address(), i = encodeURIComponent(Qn()), a = `${se()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
|
|
2305
|
+
e.onUrl?.(a), $n(a);
|
|
2306
2306
|
});
|
|
2307
|
-
}), a = await
|
|
2307
|
+
}), a = await Rn(i).catch(() => null), o = {
|
|
2308
2308
|
token: i,
|
|
2309
2309
|
email: a?.email,
|
|
2310
2310
|
organizationId: a?.organizationId
|
|
2311
2311
|
};
|
|
2312
|
-
return await
|
|
2312
|
+
return await Jn(n, o), o;
|
|
2313
2313
|
}
|
|
2314
2314
|
//#endregion
|
|
2315
2315
|
//#region src/core/access-prompts.ts
|
|
2316
|
-
async function
|
|
2316
|
+
async function rr() {
|
|
2317
2317
|
let e = await s.confirm({ message: "Log in to install packs your organization owns? (opens your browser)" });
|
|
2318
2318
|
if (s.isCancel(e) || !e) return null;
|
|
2319
2319
|
s.log.step("Opening your browser to sign in...");
|
|
2320
2320
|
try {
|
|
2321
|
-
let e = await
|
|
2322
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
2321
|
+
let e = await nr({ onUrl: (e) => {
|
|
2322
|
+
s.log.info(`If your browser didn't open, visit:\n ${z.path(e)}`);
|
|
2323
2323
|
} });
|
|
2324
2324
|
return s.log.success(e.email ? `Logged in as ${e.email}` : "Logged in"), e.token;
|
|
2325
2325
|
} catch (e) {
|
|
2326
2326
|
return s.log.error(e instanceof Error ? e.message : String(e)), null;
|
|
2327
2327
|
}
|
|
2328
2328
|
}
|
|
2329
|
-
async function
|
|
2329
|
+
async function ir(e) {
|
|
2330
2330
|
if (e.length === 0) return;
|
|
2331
2331
|
s.note([
|
|
2332
2332
|
"These packs need a purchase before they can be installed:",
|
|
2333
2333
|
"",
|
|
2334
|
-
...e.map((e) => ` ${
|
|
2334
|
+
...e.map((e) => ` ${z.brand(e.displayName)} ${z.highlight(`$${e.price}`)}`)
|
|
2335
2335
|
].join("\n"), "Locked Packs");
|
|
2336
2336
|
let t = await s.confirm({ message: `Open the purchase ${e.length === 1 ? "page" : "pages"} in your browser?` });
|
|
2337
2337
|
if (s.isCancel(t) || !t) {
|
|
2338
|
-
s.log.info(
|
|
2338
|
+
s.log.info(z.muted("Run 'npx @hype-stack/cli login' after purchasing, then 'npx @hype-stack/cli compose' again."));
|
|
2339
2339
|
return;
|
|
2340
2340
|
}
|
|
2341
|
-
for (let t of e)
|
|
2341
|
+
for (let t of e) $n(xe(t.name));
|
|
2342
2342
|
s.log.info([
|
|
2343
|
-
|
|
2344
|
-
` ${
|
|
2345
|
-
` ${
|
|
2343
|
+
z.muted("After purchasing, run:"),
|
|
2344
|
+
` ${z.highlight("npx @hype-stack/cli login")} ${z.muted("Save your access")}`,
|
|
2345
|
+
` ${z.highlight("npx @hype-stack/cli compose")} ${z.muted("Install the packs")}`
|
|
2346
2346
|
].join("\n"));
|
|
2347
2347
|
}
|
|
2348
2348
|
//#endregion
|
|
2349
2349
|
//#region src/utils/exec.ts
|
|
2350
|
-
function
|
|
2350
|
+
function K(e, t, n) {
|
|
2351
2351
|
return new Promise((r, i) => {
|
|
2352
2352
|
let a = D(e, t, {
|
|
2353
2353
|
cwd: n.cwd,
|
|
@@ -2378,7 +2378,7 @@ function q(e, t, n) {
|
|
|
2378
2378
|
});
|
|
2379
2379
|
});
|
|
2380
2380
|
}
|
|
2381
|
-
function
|
|
2381
|
+
function ar(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 ir(e, t, n) {
|
|
|
2395
2395
|
}
|
|
2396
2396
|
//#endregion
|
|
2397
2397
|
//#region src/utils/fs.ts
|
|
2398
|
-
async function
|
|
2398
|
+
async function q(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 q(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,56 +2430,84 @@ 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(z.muted("Run database setup yourself when ready:")), s.note([
|
|
2434
|
+
`${z.command(`cd ${e}`)}`,
|
|
2435
|
+
`${z.command("pnpm exec prisma generate")} ${z.muted("(regenerate the Prisma client)")}`,
|
|
2436
|
+
`${z.command("pnpm exec prisma migrate dev")} ${z.muted("(create + apply tables for new packs)")}`
|
|
2437
2437
|
].join("\n"), "Database Setup");
|
|
2438
2438
|
}
|
|
2439
2439
|
async function pr(e) {
|
|
2440
|
-
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i,
|
|
2441
|
-
if (!await J(T.join(
|
|
2440
|
+
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, freshScaffold: a, runCommand: o = ar } = e, c = n.backend.root, l = T.join(t, c);
|
|
2441
|
+
if (!await J(T.join(l, "package.json"))) return;
|
|
2442
2442
|
if (r || i === !1) {
|
|
2443
|
-
fr(
|
|
2443
|
+
fr(c);
|
|
2444
2444
|
return;
|
|
2445
2445
|
}
|
|
2446
|
-
let
|
|
2447
|
-
message: `Run database setup now? (${
|
|
2446
|
+
let u = await s.confirm({
|
|
2447
|
+
message: `Run database setup now? (${z.command("prisma migrate dev")})`,
|
|
2448
2448
|
initialValue: !0
|
|
2449
2449
|
});
|
|
2450
|
-
if (s.isCancel(
|
|
2451
|
-
fr(
|
|
2450
|
+
if (s.isCancel(u) || !u) {
|
|
2451
|
+
fr(c);
|
|
2452
2452
|
return;
|
|
2453
2453
|
}
|
|
2454
|
-
s.log.step(
|
|
2455
|
-
let
|
|
2454
|
+
s.log.step(z.muted(`Running ${z.command("prisma migrate dev --name add-packs")}...`));
|
|
2455
|
+
let d = await o("pnpm", [
|
|
2456
2456
|
"exec",
|
|
2457
2457
|
"prisma",
|
|
2458
2458
|
"migrate",
|
|
2459
2459
|
"dev",
|
|
2460
2460
|
"--name",
|
|
2461
2461
|
"add-packs"
|
|
2462
|
-
], { cwd:
|
|
2463
|
-
if (
|
|
2464
|
-
|
|
2462
|
+
], { cwd: l });
|
|
2463
|
+
if (d.exitCode !== 0 && a) {
|
|
2464
|
+
let e = await s.confirm({
|
|
2465
|
+
message: "migrate dev hit drift between the database and the local migrations. Reset the dev database and retry?",
|
|
2466
|
+
initialValue: !0
|
|
2467
|
+
});
|
|
2468
|
+
if (!s.isCancel(e) && e) {
|
|
2469
|
+
s.log.step(z.muted(`Resetting dev database (${z.command("prisma migrate reset --force")})...`));
|
|
2470
|
+
let e = await o("pnpm", [
|
|
2471
|
+
"exec",
|
|
2472
|
+
"prisma",
|
|
2473
|
+
"migrate",
|
|
2474
|
+
"reset",
|
|
2475
|
+
"--force"
|
|
2476
|
+
], { cwd: l });
|
|
2477
|
+
if (e.exitCode === 0) s.log.step(z.muted(`Running ${z.command("prisma migrate dev --name add-packs")}...`)), d = await o("pnpm", [
|
|
2478
|
+
"exec",
|
|
2479
|
+
"prisma",
|
|
2480
|
+
"migrate",
|
|
2481
|
+
"dev",
|
|
2482
|
+
"--name",
|
|
2483
|
+
"add-packs"
|
|
2484
|
+
], { cwd: l });
|
|
2485
|
+
else {
|
|
2486
|
+
s.log.error(z.muted("prisma migrate reset did not complete. See the output above, or finish setup manually:")), mr(e), fr(c);
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
if (d.exitCode !== 0) {
|
|
2492
|
+
s.log.error(z.muted("prisma migrate dev did not complete. See the output above, or finish setup manually:")), mr(d), fr(c);
|
|
2465
2493
|
return;
|
|
2466
2494
|
}
|
|
2467
2495
|
s.log.success("Database schema applied");
|
|
2468
2496
|
}
|
|
2469
2497
|
function mr(e) {
|
|
2470
2498
|
let t = (e.stderr || e.stdout).trim();
|
|
2471
|
-
t && s.log.warn(
|
|
2499
|
+
t && s.log.warn(z.muted(t));
|
|
2472
2500
|
}
|
|
2473
2501
|
//#endregion
|
|
2474
2502
|
//#region src/core/stack-config.ts
|
|
2475
2503
|
async function hr(e) {
|
|
2476
|
-
return sr(T.join(e,
|
|
2504
|
+
return sr(T.join(e, M));
|
|
2477
2505
|
}
|
|
2478
2506
|
async function gr(e) {
|
|
2479
|
-
return J(T.join(e,
|
|
2507
|
+
return J(T.join(e, M));
|
|
2480
2508
|
}
|
|
2481
2509
|
async function _r(e, t) {
|
|
2482
|
-
await cr(T.join(e,
|
|
2510
|
+
await cr(T.join(e, M), t);
|
|
2483
2511
|
}
|
|
2484
2512
|
async function vr(e) {
|
|
2485
2513
|
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([lr(t), lr(n)]);
|
|
@@ -2524,7 +2552,7 @@ function yr(e) {
|
|
|
2524
2552
|
}
|
|
2525
2553
|
function br(e, t) {
|
|
2526
2554
|
return {
|
|
2527
|
-
$schema:
|
|
2555
|
+
$schema: le(),
|
|
2528
2556
|
version: 1,
|
|
2529
2557
|
name: e,
|
|
2530
2558
|
apps: t.apps,
|
|
@@ -2535,7 +2563,7 @@ function br(e, t) {
|
|
|
2535
2563
|
};
|
|
2536
2564
|
}
|
|
2537
2565
|
async function xr(e) {
|
|
2538
|
-
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t),
|
|
2566
|
+
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t), q(n)]);
|
|
2539
2567
|
return r && i;
|
|
2540
2568
|
}
|
|
2541
2569
|
function Y(e, t) {
|
|
@@ -2550,7 +2578,7 @@ function Y(e, t) {
|
|
|
2550
2578
|
//#endregion
|
|
2551
2579
|
//#region src/core/registry.ts
|
|
2552
2580
|
async function Sr(e) {
|
|
2553
|
-
let { data: t, error: n, status: r } = await
|
|
2581
|
+
let { data: t, error: n, status: r } = await G.createRequest()({
|
|
2554
2582
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2555
2583
|
method: "GET"
|
|
2556
2584
|
}).send();
|
|
@@ -2559,12 +2587,12 @@ async function Sr(e) {
|
|
|
2559
2587
|
return t;
|
|
2560
2588
|
}
|
|
2561
2589
|
async function Cr(e, t = {}) {
|
|
2562
|
-
let n =
|
|
2590
|
+
let n = G.createRequest()({
|
|
2563
2591
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2564
2592
|
method: "POST"
|
|
2565
2593
|
}), r = {
|
|
2566
|
-
"X-Device-Id":
|
|
2567
|
-
"X-Client-Info":
|
|
2594
|
+
"X-Device-Id": Zn(),
|
|
2595
|
+
"X-Client-Info": Qn()
|
|
2568
2596
|
};
|
|
2569
2597
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2570
2598
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -2591,7 +2619,7 @@ function wr(e, t, n) {
|
|
|
2591
2619
|
function Tr(e, t) {
|
|
2592
2620
|
return T.join(t, e);
|
|
2593
2621
|
}
|
|
2594
|
-
var Er =
|
|
2622
|
+
var Er = G.createRequest()({
|
|
2595
2623
|
endpoint: "/packs/list",
|
|
2596
2624
|
method: "GET"
|
|
2597
2625
|
});
|
|
@@ -2602,7 +2630,7 @@ async function Dr() {
|
|
|
2602
2630
|
}
|
|
2603
2631
|
async function Or(e, t = {}) {
|
|
2604
2632
|
if (e.length === 0) return {};
|
|
2605
|
-
let n =
|
|
2633
|
+
let n = G.createRequest()({
|
|
2606
2634
|
endpoint: "/packs/authorize",
|
|
2607
2635
|
method: "POST"
|
|
2608
2636
|
}), r = {};
|
|
@@ -3057,8 +3085,8 @@ async function Mi(e) {
|
|
|
3057
3085
|
return {
|
|
3058
3086
|
sourcePath: a,
|
|
3059
3087
|
targetPath: o,
|
|
3060
|
-
sourceExists: await J(a) || await
|
|
3061
|
-
targetExists: await J(o) || await
|
|
3088
|
+
sourceExists: await J(a) || await q(a),
|
|
3089
|
+
targetExists: await J(o) || await q(o)
|
|
3062
3090
|
};
|
|
3063
3091
|
}
|
|
3064
3092
|
async function Ni(e) {
|
|
@@ -3297,7 +3325,7 @@ async function Bi(e) {
|
|
|
3297
3325
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3298
3326
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3299
3327
|
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) => Tr(e.source, i))), u = T.join(i, "files");
|
|
3300
|
-
if (await
|
|
3328
|
+
if (await q(u)) {
|
|
3301
3329
|
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3302
3330
|
for (let t of e) {
|
|
3303
3331
|
if (!t.isDirectory()) continue;
|
|
@@ -3382,41 +3410,41 @@ function Ki(e, t) {
|
|
|
3382
3410
|
//#endregion
|
|
3383
3411
|
//#region src/ui/logger.ts
|
|
3384
3412
|
function qi(e) {
|
|
3385
|
-
s.note(e.map((e) => `${
|
|
3413
|
+
s.note(e.map((e) => `${B.arrow} ${e}`).join("\n"), "Next steps");
|
|
3386
3414
|
}
|
|
3387
3415
|
function X() {
|
|
3388
|
-
s.cancel(
|
|
3416
|
+
s.cancel(z.muted("Operation cancelled.")), process.exit(0);
|
|
3389
3417
|
}
|
|
3390
3418
|
//#endregion
|
|
3391
3419
|
//#region src/core/post-setup.ts
|
|
3392
3420
|
async function Ji() {
|
|
3393
|
-
return (await
|
|
3421
|
+
return (await K("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3394
3422
|
}
|
|
3395
3423
|
async function Yi(e) {
|
|
3396
3424
|
return J(`${e}/apps/backend/.env`);
|
|
3397
3425
|
}
|
|
3398
3426
|
async function Xi(e, t, n) {
|
|
3399
|
-
let r = n ? `Start services with ${
|
|
3427
|
+
let r = n ? `Start services with ${z.command("docker compose up -d")}?` : `Docker is not running. Start services with ${z.command("docker compose up -d")}?`, i = t ? !0 : await s.confirm({
|
|
3400
3428
|
message: r,
|
|
3401
3429
|
initialValue: !0
|
|
3402
3430
|
});
|
|
3403
|
-
if (s.isCancel(i) && X(), !i) return s.log.info(
|
|
3431
|
+
if (s.isCancel(i) && X(), !i) return s.log.info(z.muted("Skipping Docker services and database migrations.")), !1;
|
|
3404
3432
|
let a = s.spinner();
|
|
3405
3433
|
a.start("Starting Docker services...");
|
|
3406
|
-
let o = await
|
|
3434
|
+
let o = await K("docker", [
|
|
3407
3435
|
"compose",
|
|
3408
3436
|
"up",
|
|
3409
3437
|
"-d"
|
|
3410
3438
|
], { cwd: `${e}/apps/backend` });
|
|
3411
|
-
return o.exitCode === 0 ? (a.stop(
|
|
3439
|
+
return o.exitCode === 0 ? (a.stop(z.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), Zi(o), !1);
|
|
3412
3440
|
}
|
|
3413
3441
|
function Zi(e) {
|
|
3414
3442
|
let t = (e.stderr || e.stdout).trim();
|
|
3415
|
-
t && s.log.warn(
|
|
3443
|
+
t && s.log.warn(z.muted(t));
|
|
3416
3444
|
}
|
|
3417
3445
|
async function Qi(e, t = 15, n = 2e3) {
|
|
3418
3446
|
for (let r = 0; r < t; r++) {
|
|
3419
|
-
if ((await
|
|
3447
|
+
if ((await K("docker", [
|
|
3420
3448
|
"compose",
|
|
3421
3449
|
"exec",
|
|
3422
3450
|
"-T",
|
|
@@ -3431,7 +3459,7 @@ async function Qi(e, t = 15, n = 2e3) {
|
|
|
3431
3459
|
}
|
|
3432
3460
|
var $i = "Database schema is up to date";
|
|
3433
3461
|
async function ea(e) {
|
|
3434
|
-
let t = await
|
|
3462
|
+
let t = await K("pnpm", [
|
|
3435
3463
|
"--filter",
|
|
3436
3464
|
"@internal/backend",
|
|
3437
3465
|
"exec",
|
|
@@ -3444,39 +3472,39 @@ async function ea(e) {
|
|
|
3444
3472
|
async function ta(e) {
|
|
3445
3473
|
let t = s.spinner();
|
|
3446
3474
|
t.start("Running database migrations...");
|
|
3447
|
-
let n = await
|
|
3475
|
+
let n = await K("pnpm", [
|
|
3448
3476
|
"--filter",
|
|
3449
3477
|
"@internal/backend",
|
|
3450
3478
|
"migration:latest"
|
|
3451
3479
|
], { cwd: e });
|
|
3452
|
-
return n.exitCode === 0 ? (t.stop(
|
|
3480
|
+
return n.exitCode === 0 ? (t.stop(z.success("Database migrations applied")), !0) : (t.error("Migrations failed"), Zi(n), s.log.warn(z.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations.")), !1);
|
|
3453
3481
|
}
|
|
3454
3482
|
async function na(e, t, n = {}) {
|
|
3455
3483
|
if (!await Xi(e, t, await Ji())) return !1;
|
|
3456
3484
|
let r = s.spinner();
|
|
3457
|
-
return r.start("Waiting for Postgres to be ready..."), await Qi(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3) ? (r.stop(
|
|
3485
|
+
return r.start("Waiting for Postgres to be ready..."), await Qi(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3) ? (r.stop(z.success("Postgres is ready")), !0) : (r.error("Postgres health check timed out"), s.log.warn(z.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest")), !1);
|
|
3458
3486
|
}
|
|
3459
3487
|
async function ra(e, t, n = {}) {
|
|
3460
3488
|
if (!await na(e, t, n)) return;
|
|
3461
3489
|
let r = t ? !0 : await s.confirm({
|
|
3462
|
-
message: `Run database migrations with ${
|
|
3490
|
+
message: `Run database migrations with ${z.command("prisma migrate deploy")}?`,
|
|
3463
3491
|
initialValue: !0
|
|
3464
3492
|
});
|
|
3465
3493
|
if (s.isCancel(r) && X(), !r) {
|
|
3466
|
-
s.log.info(
|
|
3494
|
+
s.log.info(z.muted("Skipping database migrations."));
|
|
3467
3495
|
return;
|
|
3468
3496
|
}
|
|
3469
3497
|
await ta(e);
|
|
3470
3498
|
}
|
|
3471
3499
|
async function ia(e, t, n = {}) {
|
|
3472
3500
|
if (!await Yi(e)) {
|
|
3473
|
-
s.log.warn(`${
|
|
3501
|
+
s.log.warn(`${z.path(".env")} not found in ${z.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3474
3502
|
return;
|
|
3475
3503
|
}
|
|
3476
3504
|
await ra(e, t, n);
|
|
3477
3505
|
}
|
|
3478
3506
|
async function aa(e, t, n = {}) {
|
|
3479
|
-
return await Yi(e) ? na(e, t, n) : (s.log.warn(`${
|
|
3507
|
+
return await Yi(e) ? na(e, t, n) : (s.log.warn(`${z.path(".env")} not found in ${z.path("apps/backend")}. Skipping Docker - configure it first.`), !1);
|
|
3480
3508
|
}
|
|
3481
3509
|
//#endregion
|
|
3482
3510
|
//#region src/core/resolve.ts
|
|
@@ -3602,20 +3630,20 @@ var ha = [
|
|
|
3602
3630
|
], Sa = .2;
|
|
3603
3631
|
function Ca() {
|
|
3604
3632
|
console.log();
|
|
3605
|
-
for (let e of
|
|
3633
|
+
for (let e of be(ha, {
|
|
3606
3634
|
start: _a,
|
|
3607
3635
|
end: va,
|
|
3608
3636
|
angle: ya
|
|
3609
3637
|
})) console.log(b.bold(e));
|
|
3610
|
-
for (let e of
|
|
3638
|
+
for (let e of be(ga, {
|
|
3611
3639
|
start: ba,
|
|
3612
3640
|
end: xa,
|
|
3613
3641
|
angle: Sa
|
|
3614
3642
|
})) console.log(b.bold(e));
|
|
3615
|
-
console.log(), console.log(` ${
|
|
3643
|
+
console.log(), console.log(` ${B.spark} ${b.dim("v" + A)} ${b.dim("·")} ${ve("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3616
3644
|
}
|
|
3617
3645
|
function wa() {
|
|
3618
|
-
console.log(), console.log(` ${
|
|
3646
|
+
console.log(), console.log(` ${B.bolt} ${he.orange("Hype")}${he.skyBlue("Stack")} ${b.dim("v" + A)}`), console.log();
|
|
3619
3647
|
}
|
|
3620
3648
|
//#endregion
|
|
3621
3649
|
//#region src/ui/pack-multiselect.ts
|
|
@@ -3740,7 +3768,7 @@ function ka(e) {
|
|
|
3740
3768
|
if (!e.trim()) return "Project name cannot be empty";
|
|
3741
3769
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
3742
3770
|
let t = Da(e);
|
|
3743
|
-
if (!
|
|
3771
|
+
if (!ne.test(t)) return "Project name must contain at least one letter or number";
|
|
3744
3772
|
}
|
|
3745
3773
|
//#endregion
|
|
3746
3774
|
//#region src/core/apply-mode.ts
|
|
@@ -3895,7 +3923,7 @@ var Ga = {
|
|
|
3895
3923
|
}
|
|
3896
3924
|
};
|
|
3897
3925
|
async function Ka(e) {
|
|
3898
|
-
let t = T.join(e,
|
|
3926
|
+
let t = T.join(e, ie), n = (await y.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
3899
3927
|
return await Promise.all(n.map(async (e) => {
|
|
3900
3928
|
let n = T.join(t, e.name), { frontmatter: r, content: i } = Va(await y.readFile(n, "utf-8"));
|
|
3901
3929
|
return {
|
|
@@ -3911,7 +3939,7 @@ async function qa(e, t) {
|
|
|
3911
3939
|
await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
3912
3940
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3913
3941
|
return y.writeFile(T.join(i, r), t, "utf-8");
|
|
3914
|
-
})), await ur(T.join(e,
|
|
3942
|
+
})), await ur(T.join(e, ae)), await ur(T.join(e, oe));
|
|
3915
3943
|
}
|
|
3916
3944
|
//#endregion
|
|
3917
3945
|
//#region src/core/env-files.ts
|
|
@@ -3942,7 +3970,7 @@ async function Qa(e) {
|
|
|
3942
3970
|
await ur(T.join(e, ".git"));
|
|
3943
3971
|
}
|
|
3944
3972
|
async function $a(e) {
|
|
3945
|
-
await
|
|
3973
|
+
await K("git", ["init"], { cwd: e }), await K("git", ["add", "."], { cwd: e }), await K("git", [
|
|
3946
3974
|
"-c",
|
|
3947
3975
|
"user.name=Hype Stack CLI",
|
|
3948
3976
|
"-c",
|
|
@@ -4184,10 +4212,10 @@ async function ho(e, t) {
|
|
|
4184
4212
|
async function go(e) {
|
|
4185
4213
|
try {
|
|
4186
4214
|
let t = {
|
|
4187
|
-
"X-Device-Id":
|
|
4188
|
-
"X-Client-Info":
|
|
4189
|
-
}, n = await
|
|
4190
|
-
n?.token && (t.Authorization = `Bearer ${n.token}`), await
|
|
4215
|
+
"X-Device-Id": Zn(),
|
|
4216
|
+
"X-Client-Info": Qn()
|
|
4217
|
+
}, n = await qn(L()).catch(() => null);
|
|
4218
|
+
n?.token && (t.Authorization = `Bearer ${n.token}`), await G.createRequest()({
|
|
4191
4219
|
endpoint: "/cli/track",
|
|
4192
4220
|
method: "POST"
|
|
4193
4221
|
}).setPayload({ event: e }).setHeaders(t).send();
|
|
@@ -4234,7 +4262,7 @@ function vo(e) {
|
|
|
4234
4262
|
};
|
|
4235
4263
|
return t;
|
|
4236
4264
|
}
|
|
4237
|
-
async function yo(e, t, n =
|
|
4265
|
+
async function yo(e, t, n = K) {
|
|
4238
4266
|
let r = [];
|
|
4239
4267
|
for (let i of e) {
|
|
4240
4268
|
let e = T.join(t, i.relativeDir);
|
|
@@ -4275,11 +4303,11 @@ async function bo(e, t, n) {
|
|
|
4275
4303
|
return r.length === 0 ? {} : Or(r, n).catch(() => ({}));
|
|
4276
4304
|
}
|
|
4277
4305
|
function xo(e, t) {
|
|
4278
|
-
return e === "free" ?
|
|
4306
|
+
return e === "free" ? z.success("free") : e === "owned" ? z.accent("owned") : `${z.highlight(`$${t}`)} ${z.muted("locked")}`;
|
|
4279
4307
|
}
|
|
4280
4308
|
async function So(e, t, n) {
|
|
4281
4309
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4282
|
-
i.length > 0 && s.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await
|
|
4310
|
+
i.length > 0 && s.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await ir(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4283
4311
|
name: e.name,
|
|
4284
4312
|
displayName: e.displayName,
|
|
4285
4313
|
price: e.price
|
|
@@ -4288,7 +4316,7 @@ async function So(e, t, n) {
|
|
|
4288
4316
|
function Co(e, t) {
|
|
4289
4317
|
let n = e.map((e, n) => {
|
|
4290
4318
|
let r = t.get(e), i = r ? r.displayName : e;
|
|
4291
|
-
return ` ${
|
|
4319
|
+
return ` ${z.muted(`${n + 1}.`)} ${z.brand(i)}`;
|
|
4292
4320
|
});
|
|
4293
4321
|
s.note([
|
|
4294
4322
|
"These packs will be installed, in order:",
|
|
@@ -4320,13 +4348,13 @@ async function To(e) {
|
|
|
4320
4348
|
if (i.stop(o.ok ? "npm dependencies installed" : "npm dependency installation failed"), !o.ok) for (let e of o.errors) s.log.error(e);
|
|
4321
4349
|
}
|
|
4322
4350
|
function Eo() {
|
|
4323
|
-
s.note([` ${
|
|
4351
|
+
s.note([` ${z.command("1. npx @hype-stack/cli onboard")} ${z.muted("(set up env vars + run migrations)")}`, ` ${z.command("2. pnpm dev")} ${z.muted("(start frontend + backend)")}`].join("\n"), "Next steps");
|
|
4324
4352
|
}
|
|
4325
4353
|
function Do(e) {
|
|
4326
4354
|
if (e.length === 0) return;
|
|
4327
4355
|
let t = e.map((e) => {
|
|
4328
4356
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
4329
|
-
return ` ${
|
|
4357
|
+
return ` ${z.muted("•")} ${z.path(t)}`;
|
|
4330
4358
|
});
|
|
4331
4359
|
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4332
4360
|
}
|
|
@@ -4341,17 +4369,17 @@ async function Oo(e) {
|
|
|
4341
4369
|
});
|
|
4342
4370
|
if (l.length === 0) return c;
|
|
4343
4371
|
if (a) {
|
|
4344
|
-
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${
|
|
4372
|
+
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${z.command("--force")} to overwrite.`);
|
|
4345
4373
|
let e = l.map((e) => {
|
|
4346
4374
|
let t = T.relative(r, e.targetPath) || e.target;
|
|
4347
|
-
return ` ${
|
|
4375
|
+
return ` ${z.muted("•")} ${z.path(t)} ${z.muted(`(${e.packName})`)}`;
|
|
4348
4376
|
});
|
|
4349
4377
|
return s.note(e.join("\n"), "Kept existing files"), c;
|
|
4350
4378
|
}
|
|
4351
4379
|
s.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4352
4380
|
for (let e of l) {
|
|
4353
4381
|
let t = T.relative(r, e.targetPath) || e.target, n = await s.confirm({
|
|
4354
|
-
message: `Overwrite ${
|
|
4382
|
+
message: `Overwrite ${z.path(t)}? ${z.muted(`(${e.packName})`)}`,
|
|
4355
4383
|
initialValue: !1
|
|
4356
4384
|
});
|
|
4357
4385
|
s.isCancel(n) && (s.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
|
|
@@ -4416,7 +4444,7 @@ function Lo(e) {
|
|
|
4416
4444
|
//#endregion
|
|
4417
4445
|
//#region src/commands/create.ts
|
|
4418
4446
|
async function Ro(e) {
|
|
4419
|
-
e.skipBanner || Ca(), s.intro(
|
|
4447
|
+
e.skipBanner || Ca(), s.intro(z.brandBold("Create a new Hype Stack project"));
|
|
4420
4448
|
let o = e.yes === !0, c, l;
|
|
4421
4449
|
if (o && e.name) {
|
|
4422
4450
|
let t = ka(e.name);
|
|
@@ -4430,7 +4458,7 @@ async function Ro(e) {
|
|
|
4430
4458
|
});
|
|
4431
4459
|
s.isCancel(t) && X(), l = t, c = Da(l);
|
|
4432
4460
|
}
|
|
4433
|
-
l.trim() !== c && s.log.info(
|
|
4461
|
+
l.trim() !== c && s.log.info(z.muted(`Using "${z.highlight(c)}" as the project name`));
|
|
4434
4462
|
let u;
|
|
4435
4463
|
if (e.directory !== void 0) u = e.directory;
|
|
4436
4464
|
else {
|
|
@@ -4448,14 +4476,14 @@ async function Ro(e) {
|
|
|
4448
4476
|
u = dr(t, c);
|
|
4449
4477
|
}
|
|
4450
4478
|
let d = T.resolve(u);
|
|
4451
|
-
o || s.note(
|
|
4452
|
-
let f = e.editor &&
|
|
4479
|
+
o || s.note(z.path(d), "Project will be created at");
|
|
4480
|
+
let f = e.editor && re.includes(e.editor) ? e.editor : null, p;
|
|
4453
4481
|
if (f) p = f;
|
|
4454
4482
|
else if (o) p = "cursor";
|
|
4455
4483
|
else {
|
|
4456
4484
|
let e = await s.select({
|
|
4457
4485
|
message: "Which code editor do you use?",
|
|
4458
|
-
options:
|
|
4486
|
+
options: I.map((e) => ({
|
|
4459
4487
|
value: e.value,
|
|
4460
4488
|
label: e.label,
|
|
4461
4489
|
hint: "hint" in e ? e.hint : void 0
|
|
@@ -4479,18 +4507,18 @@ async function Ro(e) {
|
|
|
4479
4507
|
s.isCancel(e) && X(), g = e;
|
|
4480
4508
|
}
|
|
4481
4509
|
if (!o) {
|
|
4482
|
-
let e =
|
|
4510
|
+
let e = I.find((e) => e.value === p)?.label ?? p, t = n.find((e) => e.value === g)?.label ?? g, r = await s.confirm({ message: `Create ${z.highlight(c)} in ${z.path(d)} with ${z.highlight(e)} config and the ${z.highlight(t)} theme?` });
|
|
4483
4511
|
(s.isCancel(r) || !r) && X();
|
|
4484
4512
|
}
|
|
4485
|
-
if (await
|
|
4513
|
+
if (await q(d) && !await or(d)) {
|
|
4486
4514
|
let e = await s.confirm({
|
|
4487
|
-
message: `Directory ${
|
|
4515
|
+
message: `Directory ${z.path(d)} is not empty. Continue anyway?`,
|
|
4488
4516
|
initialValue: !1
|
|
4489
4517
|
});
|
|
4490
4518
|
(s.isCancel(e) || !e) && X();
|
|
4491
4519
|
}
|
|
4492
4520
|
let _ = s.spinner();
|
|
4493
|
-
_.start("Cloning Hype Stack template..."), await Ba(d), _.stop(
|
|
4521
|
+
_.start("Cloning Hype Stack template..."), await Ba(d), _.stop(z.success("Template cloned"));
|
|
4494
4522
|
let v = s.spinner();
|
|
4495
4523
|
v.start("Setting up project..."), await Qa(d), await eo(d, c), await qa(d, p);
|
|
4496
4524
|
let y = await vr(d), b = br(c, y);
|
|
@@ -4500,50 +4528,50 @@ async function Ro(e) {
|
|
|
4500
4528
|
workspace: y
|
|
4501
4529
|
});
|
|
4502
4530
|
let x = T.resolve(d, b.paths?.frontend.root ?? "apps/frontend");
|
|
4503
|
-
a(g) && (await za(x, i(g)) || s.log.warn(
|
|
4531
|
+
a(g) && (await za(x, i(g)) || s.log.warn(z.muted(`Could not find ${z.path("assets/styles.css")} to apply the ${g} theme`))), await Na(x, e.defaultMode === "dark" || e.defaultMode === "light" ? e.defaultMode : "light") || s.log.warn(z.muted(`Could not find ${z.path("src/hooks/use-theme.ts")} to set the default color mode`)), v.stop(z.success("Project configured"));
|
|
4504
4532
|
let S = s.spinner();
|
|
4505
|
-
S.start("Installing dependencies..."), (await
|
|
4533
|
+
S.start("Installing dependencies..."), (await K("pnpm", ["install"], { cwd: d })).exitCode === 0 ? S.stop(z.success("Dependencies installed")) : (S.stop(z.warning("Dependencies installed with warnings")), s.log.warn(z.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4506
4534
|
let C = s.spinner();
|
|
4507
|
-
C.start("Initializing git repository..."), await $a(d), C.stop(
|
|
4535
|
+
C.start("Initializing git repository..."), await $a(d), C.stop(z.success("Git repository initialized with clean history"));
|
|
4508
4536
|
let w = s.spinner();
|
|
4509
4537
|
w.start("Creating .env files from examples...");
|
|
4510
4538
|
let E = await Ya(d);
|
|
4511
4539
|
if (E.length > 0) {
|
|
4512
4540
|
let e = E.length;
|
|
4513
|
-
w.stop(
|
|
4514
|
-
} else w.stop(
|
|
4515
|
-
s.log.success(`${
|
|
4516
|
-
let D = T.relative(process.cwd(), d) || ".", O = [`${
|
|
4517
|
-
E.length > 0 ? O.push(`Review your ${
|
|
4541
|
+
w.stop(z.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4542
|
+
} else w.stop(z.muted("No .env.example files to copy"));
|
|
4543
|
+
s.log.success(`${z.brandBold("Hype Stack")} project ${z.highlight(c)} is ready!`);
|
|
4544
|
+
let D = T.relative(process.cwd(), d) || ".", O = [`${z.command(`cd ${D}`)}`];
|
|
4545
|
+
E.length > 0 ? O.push(`Review your ${z.path(".env")} files and fill in any secrets`) : O.push(`Copy ${z.path(".env.example")} to ${z.path(".env")} and configure`), qi(O);
|
|
4518
4546
|
let k = e.setup === !1;
|
|
4519
|
-
if (e.deferSetup) s.log.info(
|
|
4547
|
+
if (e.deferSetup) s.log.info(z.muted("Docker and migrations will run after your packs are installed."));
|
|
4520
4548
|
else {
|
|
4521
4549
|
let e = !k && (o || await s.confirm({
|
|
4522
4550
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
4523
4551
|
initialValue: !0
|
|
4524
4552
|
}));
|
|
4525
|
-
s.isCancel(e) && X(), e ? await ia(d, o) : s.log.info(
|
|
4553
|
+
s.isCancel(e) && X(), e ? await ia(d, o) : s.log.info(z.muted("Docker and migrations can run later via `npx @hype-stack/cli onboard`.")), Eo();
|
|
4526
4554
|
}
|
|
4527
|
-
return await go("project_create"), s.outro(
|
|
4555
|
+
return await go("project_create"), s.outro(z.muted("Happy building!")), d;
|
|
4528
4556
|
}
|
|
4529
4557
|
//#endregion
|
|
4530
4558
|
//#region src/commands/init.ts
|
|
4531
4559
|
async function zo(e) {
|
|
4532
4560
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4533
|
-
if (n || (wa(), s.intro(
|
|
4534
|
-
s.log.error(`This doesn't look like a Hype Stack project. ${
|
|
4561
|
+
if (n || (wa(), s.intro(z.brandBold("Initialize Hype Stack configuration"))), !await xr(t)) {
|
|
4562
|
+
s.log.error(`This doesn't look like a Hype Stack project. ${z.muted("Expected apps/ directory and package.json")}`), s.outro(z.muted(`Run ${z.command("npx @hype-stack/cli create")} to scaffold a new project.`));
|
|
4535
4563
|
return;
|
|
4536
4564
|
}
|
|
4537
4565
|
if (await gr(t)) {
|
|
4538
4566
|
let e = await hr(t);
|
|
4539
4567
|
if (e && !n) {
|
|
4540
|
-
s.log.info(`Found existing ${
|
|
4568
|
+
s.log.info(`Found existing ${z.path("stack.json")} for project ${z.highlight(e.name)}`);
|
|
4541
4569
|
let t = await s.confirm({
|
|
4542
4570
|
message: "Overwrite existing configuration?",
|
|
4543
4571
|
initialValue: !1
|
|
4544
4572
|
});
|
|
4545
4573
|
if (s.isCancel(t) || !t) {
|
|
4546
|
-
s.outro(
|
|
4574
|
+
s.outro(z.muted("Keeping existing configuration."));
|
|
4547
4575
|
return;
|
|
4548
4576
|
}
|
|
4549
4577
|
}
|
|
@@ -4552,12 +4580,12 @@ async function zo(e) {
|
|
|
4552
4580
|
if (!n) {
|
|
4553
4581
|
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4554
4582
|
if (e.length > 0) {
|
|
4555
|
-
s.log.info(
|
|
4556
|
-
for (let [t, n] of e) s.log.message(` ${
|
|
4583
|
+
s.log.info(z.bold("Detected apps:"));
|
|
4584
|
+
for (let [t, n] of e) s.log.message(` ${B.arrow} ${z.highlight(t)} ${z.muted(`→ ${n}`)}`);
|
|
4557
4585
|
}
|
|
4558
4586
|
if (t.length > 0) {
|
|
4559
|
-
s.log.info(
|
|
4560
|
-
for (let [e, n] of t) s.log.message(` ${
|
|
4587
|
+
s.log.info(z.bold("Detected packages:"));
|
|
4588
|
+
for (let [e, n] of t) s.log.message(` ${B.arrow} ${z.highlight(e)} ${z.muted(`→ ${n}`)}`);
|
|
4561
4589
|
}
|
|
4562
4590
|
e.length === 0 && t.length === 0 && s.log.warn("No apps or packages detected in the workspace.");
|
|
4563
4591
|
}
|
|
@@ -4571,7 +4599,7 @@ async function zo(e) {
|
|
|
4571
4599
|
});
|
|
4572
4600
|
s.isCancel(e) && X(), a = Da(e);
|
|
4573
4601
|
}
|
|
4574
|
-
await _r(t, br(a, r)), n || (s.log.success(`${
|
|
4602
|
+
await _r(t, br(a, r)), n || (s.log.success(`${z.path("stack.json")} written successfully`), s.outro(z.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
|
|
4575
4603
|
}
|
|
4576
4604
|
async function Bo(e, t = {}, n) {
|
|
4577
4605
|
if (await gr(e)) return {
|
|
@@ -4589,22 +4617,22 @@ async function Bo(e, t = {}, n) {
|
|
|
4589
4617
|
defaultMode: t?.defaultMode
|
|
4590
4618
|
}));
|
|
4591
4619
|
if (await xr(e)) {
|
|
4592
|
-
s.log.warn(`No ${
|
|
4620
|
+
s.log.warn(`No ${z.path("stack.json")} found in ${z.path(e)}.`);
|
|
4593
4621
|
let t = await s.confirm({
|
|
4594
|
-
message: `Create ${
|
|
4622
|
+
message: `Create ${z.path("stack.json")} now?`,
|
|
4595
4623
|
initialValue: !0
|
|
4596
4624
|
});
|
|
4597
4625
|
if (s.isCancel(t) || !t) return null;
|
|
4598
4626
|
await r(e);
|
|
4599
4627
|
let n = await gr(e);
|
|
4600
|
-
return n && s.log.success(`${
|
|
4628
|
+
return n && s.log.success(`${z.path("stack.json")} created`), n ? {
|
|
4601
4629
|
projectRoot: e,
|
|
4602
4630
|
scaffolded: !1
|
|
4603
4631
|
} : null;
|
|
4604
4632
|
}
|
|
4605
|
-
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${
|
|
4633
|
+
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${z.path("stack.json")} here.`);
|
|
4606
4634
|
let a = await s.confirm({
|
|
4607
|
-
message: `Is ${
|
|
4635
|
+
message: `Is ${z.path(e)} where you want to work?`,
|
|
4608
4636
|
initialValue: !0
|
|
4609
4637
|
});
|
|
4610
4638
|
if (s.isCancel(a) || !a) return null;
|
|
@@ -4628,11 +4656,11 @@ async function Vo(e = {}) {
|
|
|
4628
4656
|
try {
|
|
4629
4657
|
a = await hr(r ?? t);
|
|
4630
4658
|
} catch (e) {
|
|
4631
|
-
s.cancel(`Could not parse ${
|
|
4659
|
+
s.cancel(`Could not parse ${z.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4632
4660
|
}
|
|
4633
|
-
a || (s.cancel(r ? `Could not read ${
|
|
4661
|
+
a || (s.cancel(r ? `Could not read ${z.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli compose' again.` : `No ${z.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli compose'.`), process.exit(1)), a.paths || (s.cancel(`${z.path("stack.json")} is missing ${z.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
4634
4662
|
let o = r ?? t;
|
|
4635
|
-
s.intro(
|
|
4663
|
+
s.intro(z.brandBold("Compose your stack"));
|
|
4636
4664
|
let c = s.spinner();
|
|
4637
4665
|
c.start("Loading packs...");
|
|
4638
4666
|
let l;
|
|
@@ -4642,7 +4670,7 @@ async function Vo(e = {}) {
|
|
|
4642
4670
|
c.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${Q(e)}`), process.exit(1);
|
|
4643
4671
|
}
|
|
4644
4672
|
c.stop("Packs loaded");
|
|
4645
|
-
let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await
|
|
4673
|
+
let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await qn(L()))?.token ?? null, h = await bo(l, d, {
|
|
4646
4674
|
token: m,
|
|
4647
4675
|
key: p
|
|
4648
4676
|
}), g = (e) => {
|
|
@@ -4656,7 +4684,7 @@ async function Vo(e = {}) {
|
|
|
4656
4684
|
adminAvailable: !!a.apps.admin
|
|
4657
4685
|
});
|
|
4658
4686
|
if (v === null && (s.cancel("Cancelled."), process.exit(0)), v.length === 0) {
|
|
4659
|
-
s.outro(
|
|
4687
|
+
s.outro(z.muted("No packs selected. Nothing to do."));
|
|
4660
4688
|
return;
|
|
4661
4689
|
}
|
|
4662
4690
|
let b = Go(v), x = Ko(v), S = pa(l, b), C = oa(ma(l, S)), w;
|
|
@@ -4666,7 +4694,7 @@ async function Vo(e = {}) {
|
|
|
4666
4694
|
s.cancel(Q(e)), process.exit(1);
|
|
4667
4695
|
}
|
|
4668
4696
|
if (w.order.length === 0) {
|
|
4669
|
-
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(
|
|
4697
|
+
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(z.muted("Your selection is already part of the project."));
|
|
4670
4698
|
return;
|
|
4671
4699
|
}
|
|
4672
4700
|
let T = la({
|
|
@@ -4676,7 +4704,7 @@ async function Vo(e = {}) {
|
|
|
4676
4704
|
installed: u
|
|
4677
4705
|
});
|
|
4678
4706
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4679
|
-
let e = await
|
|
4707
|
+
let e = await rr();
|
|
4680
4708
|
e && (m = e, h = await bo(l, d, {
|
|
4681
4709
|
token: m,
|
|
4682
4710
|
key: p
|
|
@@ -4688,7 +4716,7 @@ async function Vo(e = {}) {
|
|
|
4688
4716
|
}));
|
|
4689
4717
|
}
|
|
4690
4718
|
if (T.blocked.length > 0 && await So(T.blocked, _, f), T.installable.length === 0) {
|
|
4691
|
-
s.outro(
|
|
4719
|
+
s.outro(z.muted("Nothing left to install once locked packs are removed."));
|
|
4692
4720
|
return;
|
|
4693
4721
|
}
|
|
4694
4722
|
if (Co(T.installable, f), !e.yes) {
|
|
@@ -4729,7 +4757,7 @@ async function Vo(e = {}) {
|
|
|
4729
4757
|
for (let e of t.errors) s.log.error(e);
|
|
4730
4758
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4731
4759
|
}
|
|
4732
|
-
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${
|
|
4760
|
+
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${z.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (s.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`), Do(t.skipped));
|
|
4733
4761
|
for (let e of t.errors) s.log.error(e);
|
|
4734
4762
|
await To({
|
|
4735
4763
|
prepared: E,
|
|
@@ -4742,8 +4770,9 @@ async function Vo(e = {}) {
|
|
|
4742
4770
|
projectRoot: o,
|
|
4743
4771
|
paths: a.paths,
|
|
4744
4772
|
skipPrompts: e.yes ?? !1,
|
|
4745
|
-
dbReady: n
|
|
4746
|
-
|
|
4773
|
+
dbReady: n,
|
|
4774
|
+
freshScaffold: i
|
|
4775
|
+
}), Eo(), s.outro(z.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4747
4776
|
} finally {
|
|
4748
4777
|
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
4749
4778
|
recursive: !0,
|
|
@@ -4758,11 +4787,11 @@ async function Ho(e) {
|
|
|
4758
4787
|
return n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4759
4788
|
}
|
|
4760
4789
|
let o = t.filter((e) => n.has(e.name));
|
|
4761
|
-
o.length > 0 && s.note(o.map((e) => ` ${
|
|
4790
|
+
o.length > 0 && s.note(o.map((e) => ` ${z.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4762
4791
|
let c = t.filter((e) => !n.has(e.name));
|
|
4763
|
-
if (c.length === 0) return s.outro(
|
|
4764
|
-
let l =
|
|
4765
|
-
s.note(c.map((e) => ` ${
|
|
4792
|
+
if (c.length === 0) return s.outro(z.muted("Every available pack is already installed.")), [];
|
|
4793
|
+
let l = se();
|
|
4794
|
+
s.note(c.map((e) => ` ${B.arrow} ${z.highlight(e.displayName)} ${ge(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4766
4795
|
let u = Gi(c, { adminAvailable: a }), d = [];
|
|
4767
4796
|
for (let e of u) {
|
|
4768
4797
|
let t = e.packs.map((e) => {
|
|
@@ -4821,27 +4850,27 @@ function Ko(e) {
|
|
|
4821
4850
|
//#endregion
|
|
4822
4851
|
//#region src/commands/login.ts
|
|
4823
4852
|
async function qo() {
|
|
4824
|
-
wa(), s.intro(
|
|
4853
|
+
wa(), s.intro(z.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
4825
4854
|
let e;
|
|
4826
4855
|
try {
|
|
4827
|
-
e = await
|
|
4828
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
4856
|
+
e = await nr({ onUrl: (e) => {
|
|
4857
|
+
s.log.info(`If your browser didn't open, visit:\n ${z.path(e)}`);
|
|
4829
4858
|
} });
|
|
4830
4859
|
} catch (e) {
|
|
4831
4860
|
s.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
|
|
4832
4861
|
}
|
|
4833
|
-
s.outro(
|
|
4862
|
+
s.outro(z.brand(e.email ? `Logged in as ${e.email}. You can now install packs your organization owns.` : "Logged in. You can now install packs your organization owns."));
|
|
4834
4863
|
}
|
|
4835
4864
|
//#endregion
|
|
4836
4865
|
//#region src/commands/logout.ts
|
|
4837
4866
|
async function Jo() {
|
|
4838
|
-
wa(), s.intro(
|
|
4839
|
-
let e =
|
|
4867
|
+
wa(), s.intro(z.brandBold("Log out of Hype Stack"));
|
|
4868
|
+
let e = L(), t = await qn(e);
|
|
4840
4869
|
if (!t) {
|
|
4841
|
-
s.outro(
|
|
4870
|
+
s.outro(z.muted("You're not logged in."));
|
|
4842
4871
|
return;
|
|
4843
4872
|
}
|
|
4844
|
-
await
|
|
4873
|
+
await zn(t.token).catch(() => null), await Yn(e), s.outro(z.brand("Logged out."));
|
|
4845
4874
|
}
|
|
4846
4875
|
//#endregion
|
|
4847
4876
|
//#region src/core/onboard-catalog.ts
|
|
@@ -4985,41 +5014,41 @@ async function ls(e, t, n) {
|
|
|
4985
5014
|
//#region src/commands/onboard.ts
|
|
4986
5015
|
async function us(e = {}) {
|
|
4987
5016
|
let t = e.cwd ?? process.cwd();
|
|
4988
|
-
Ca(), s.intro(
|
|
5017
|
+
Ca(), s.intro(z.brandBold("Onboard your stack"));
|
|
4989
5018
|
let n;
|
|
4990
5019
|
try {
|
|
4991
5020
|
n = await hr(t);
|
|
4992
5021
|
} catch {
|
|
4993
5022
|
n = null;
|
|
4994
5023
|
}
|
|
4995
|
-
n || (s.cancel(`${
|
|
5024
|
+
n || (s.cancel(`${z.path("stack.json")} not found. Run ${z.command("npx @hype-stack/cli init")} first.`), process.exit(1));
|
|
4996
5025
|
let r = await Xa(t);
|
|
4997
|
-
r.length === 0 && s.log.warn(
|
|
5026
|
+
r.length === 0 && s.log.warn(z.muted("No .env.example files found; skipping env setup."));
|
|
4998
5027
|
for (let n of r) await ds(n, t, e.yes ?? !1);
|
|
4999
5028
|
let i = ns(n.installedPacks ?? []);
|
|
5000
|
-
i.length > 0 && s.note(i.map((e) => ` ${
|
|
5029
|
+
i.length > 0 && s.note(i.map((e) => ` ${z.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await ms(t, e.yes ?? !1), s.outro(z.brand(`All set. Run ${z.command("pnpm dev")} to start your app.`));
|
|
5001
5030
|
}
|
|
5002
5031
|
async function ds(e, t, n) {
|
|
5003
|
-
let r = T.relative(t, e) || e, i = await cs(e), a = await ss(i), o = rs(await y.readFile(e, "utf-8")), c =
|
|
5032
|
+
let r = T.relative(t, e) || e, i = await cs(e), a = await ss(i), o = rs(await y.readFile(e, "utf-8")), c = z.path(r);
|
|
5004
5033
|
s.log.step(`Env: ${c}`);
|
|
5005
5034
|
for (let e of o) {
|
|
5006
5035
|
let t = e.vars.filter((e) => as(e.value));
|
|
5007
5036
|
if (t.length === 0) continue;
|
|
5008
|
-
let r = es(e.section), o = e.section ?
|
|
5009
|
-
s.log.step(o), r.link && (s.log.info(`${
|
|
5037
|
+
let r = es(e.section), o = e.section ? z.bold(e.section) : z.bold("Variables");
|
|
5038
|
+
s.log.step(o), r.link && (s.log.info(`${z.muted("Get your values:")} ${ge(r.link)}`), r.serviceChecklist && r.serviceChecklist.length > 0 && s.note(r.serviceChecklist.map((e) => ` ${z.muted("·")} ${e}`).join("\n"), "Setup")), s.log.info(z.muted(r.hint));
|
|
5010
5039
|
for (let e of t) {
|
|
5011
5040
|
if (n) {
|
|
5012
|
-
s.log.info(`${
|
|
5041
|
+
s.log.info(`${z.label(e.key)} ${z.muted("skipped (non-interactive)")}`);
|
|
5013
5042
|
continue;
|
|
5014
5043
|
}
|
|
5015
5044
|
let t = fs(a, e.key), o = await s.text({
|
|
5016
|
-
message: `${
|
|
5045
|
+
message: `${z.label(e.key)}`,
|
|
5017
5046
|
placeholder: t || r.hint
|
|
5018
5047
|
});
|
|
5019
5048
|
s.isCancel(o) && X();
|
|
5020
5049
|
let c = (o ?? "").trim();
|
|
5021
5050
|
if (c === "") {
|
|
5022
|
-
s.log.warn(
|
|
5051
|
+
s.log.warn(z.muted(`${e.key} left blank.`));
|
|
5023
5052
|
continue;
|
|
5024
5053
|
}
|
|
5025
5054
|
await ls(i, e.key, c), s.log.success(`${e.key} saved`);
|
|
@@ -5038,31 +5067,31 @@ function ps(e) {
|
|
|
5038
5067
|
}
|
|
5039
5068
|
async function ms(e, t) {
|
|
5040
5069
|
if (!await Ji() && !await Xi(e, t, !1)) {
|
|
5041
|
-
s.log.info(
|
|
5070
|
+
s.log.info(z.muted(`Start services later with ${z.command("docker compose up -d")} (in apps/backend), then ${z.command("pnpm --filter @internal/backend migration:latest")}.`));
|
|
5042
5071
|
return;
|
|
5043
5072
|
}
|
|
5044
5073
|
let n = s.spinner();
|
|
5045
5074
|
if (n.start("Waiting for Postgres to be ready..."), !await Qi(e)) {
|
|
5046
|
-
n.error("Postgres health check timed out"), s.log.warn(
|
|
5075
|
+
n.error("Postgres health check timed out"), s.log.warn(z.muted(`Run migrations manually once Postgres is ready: ${z.command("pnpm --filter @internal/backend migration:latest")}`));
|
|
5047
5076
|
return;
|
|
5048
5077
|
}
|
|
5049
|
-
if (n.stop(
|
|
5050
|
-
s.log.info(
|
|
5078
|
+
if (n.stop(z.success("Postgres is ready")), await ea(e)) {
|
|
5079
|
+
s.log.info(z.muted("Migrations already applied, skipping."));
|
|
5051
5080
|
return;
|
|
5052
5081
|
}
|
|
5053
5082
|
let r = t ? !0 : await s.confirm({
|
|
5054
|
-
message: `Run database migrations with ${
|
|
5083
|
+
message: `Run database migrations with ${z.command("prisma migrate deploy")}?`,
|
|
5055
5084
|
initialValue: !0
|
|
5056
5085
|
});
|
|
5057
5086
|
if (s.isCancel(r) && X(), !r) {
|
|
5058
|
-
s.log.info(
|
|
5087
|
+
s.log.info(z.muted("Skipping database migrations."));
|
|
5059
5088
|
return;
|
|
5060
5089
|
}
|
|
5061
5090
|
await ta(e);
|
|
5062
5091
|
}
|
|
5063
5092
|
//#endregion
|
|
5064
5093
|
//#region src/core/templates.ts
|
|
5065
|
-
var hs =
|
|
5094
|
+
var hs = G.createRequest()({
|
|
5066
5095
|
endpoint: "/templates/list",
|
|
5067
5096
|
method: "GET"
|
|
5068
5097
|
});
|
|
@@ -5072,7 +5101,7 @@ async function gs() {
|
|
|
5072
5101
|
return e.templates;
|
|
5073
5102
|
}
|
|
5074
5103
|
async function _s(e) {
|
|
5075
|
-
let { data: t, error: n, status: r } = await
|
|
5104
|
+
let { data: t, error: n, status: r } = await G.createRequest()({
|
|
5076
5105
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
5077
5106
|
method: "GET"
|
|
5078
5107
|
}).send();
|
|
@@ -5081,12 +5110,12 @@ async function _s(e) {
|
|
|
5081
5110
|
return t;
|
|
5082
5111
|
}
|
|
5083
5112
|
async function vs(e, t = {}) {
|
|
5084
|
-
let n =
|
|
5113
|
+
let n = G.createRequest()({
|
|
5085
5114
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
5086
5115
|
method: "POST"
|
|
5087
5116
|
}), r = {
|
|
5088
|
-
"X-Device-Id":
|
|
5089
|
-
"X-Client-Info":
|
|
5117
|
+
"X-Device-Id": Zn(),
|
|
5118
|
+
"X-Client-Info": Qn()
|
|
5090
5119
|
};
|
|
5091
5120
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
5092
5121
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -5129,8 +5158,8 @@ async function ys(t = {}) {
|
|
|
5129
5158
|
let l = t.templateId;
|
|
5130
5159
|
if (!l) {
|
|
5131
5160
|
t.yes && (r.stop("Template id required"), s.cancel("Pass a template id with `npx @hype-stack/cli template <id>` (required in --yes mode)."), process.exit(1)), c.length === 0 && (r.stop("No templates available"), s.cancel("No templates are available yet. Check back later."), process.exit(1)), r.stop("Templates loaded");
|
|
5132
|
-
let e =
|
|
5133
|
-
s.note(c.map((t) => ` ${
|
|
5161
|
+
let e = se();
|
|
5162
|
+
s.note(c.map((t) => ` ${B.arrow} ${z.highlight(t.name)} ${ge(`${e}/templates/${t.id}`)}`).join("\n"), "Browse templates");
|
|
5134
5163
|
let n = await s.select({
|
|
5135
5164
|
message: "Choose a template",
|
|
5136
5165
|
options: c.map((e) => ({
|
|
@@ -5156,12 +5185,12 @@ async function ys(t = {}) {
|
|
|
5156
5185
|
try {
|
|
5157
5186
|
h = await hr(p ?? n);
|
|
5158
5187
|
} catch (e) {
|
|
5159
|
-
s.cancel(`Could not parse ${
|
|
5188
|
+
s.cancel(`Could not parse ${z.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
5160
5189
|
}
|
|
5161
|
-
h || (s.cancel(p ? `Could not read ${
|
|
5190
|
+
h || (s.cancel(p ? `Could not read ${z.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${z.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), process.exit(1)), h.paths || (s.cancel(`${z.path("stack.json")} is missing ${z.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
5162
5191
|
let g = p ?? n;
|
|
5163
|
-
s.intro(
|
|
5164
|
-
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await
|
|
5192
|
+
s.intro(z.brandBold("Install a template"));
|
|
5193
|
+
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await qn(L()))?.token ?? null, C = await bs(u, t.variants, t.yes ?? !1), w = ua(u.slots, C), E = da(u.slots, u.packs, w), D = await xs({
|
|
5165
5194
|
packs: o,
|
|
5166
5195
|
templatePacks: E,
|
|
5167
5196
|
installedSet: v,
|
|
@@ -5175,97 +5204,97 @@ async function ys(t = {}) {
|
|
|
5175
5204
|
s.cancel(Q(e)), process.exit(1);
|
|
5176
5205
|
}
|
|
5177
5206
|
if (j.order.length === 0) {
|
|
5178
|
-
s.outro(
|
|
5207
|
+
s.outro(z.muted("Every pack in this template is already installed."));
|
|
5179
5208
|
return;
|
|
5180
5209
|
}
|
|
5181
|
-
let
|
|
5210
|
+
let M = await bo(ee, v, {
|
|
5182
5211
|
token: S,
|
|
5183
5212
|
key: x
|
|
5184
|
-
}),
|
|
5213
|
+
}), te = (e) => {
|
|
5185
5214
|
let t = b.get(e);
|
|
5186
|
-
return !t || t.tier === "free" ? "free" :
|
|
5187
|
-
},
|
|
5215
|
+
return !t || t.tier === "free" ? "free" : M[e]?.owned ? "owned" : "locked";
|
|
5216
|
+
}, N = (e) => !v.has(e) && te(e) === "locked", P = la({
|
|
5188
5217
|
order: j.order,
|
|
5189
5218
|
graph: A,
|
|
5190
|
-
isLocked:
|
|
5219
|
+
isLocked: N,
|
|
5191
5220
|
installed: _
|
|
5192
5221
|
});
|
|
5193
|
-
if (
|
|
5194
|
-
let e = await
|
|
5195
|
-
e && (S = e,
|
|
5222
|
+
if (P.blocked.length > 0 && !S && !x) {
|
|
5223
|
+
let e = await rr();
|
|
5224
|
+
e && (S = e, M = await bo(ee, v, {
|
|
5196
5225
|
token: S,
|
|
5197
5226
|
key: x
|
|
5198
|
-
}),
|
|
5227
|
+
}), P = la({
|
|
5199
5228
|
order: j.order,
|
|
5200
5229
|
graph: A,
|
|
5201
|
-
isLocked:
|
|
5230
|
+
isLocked: N,
|
|
5202
5231
|
installed: _
|
|
5203
5232
|
}));
|
|
5204
5233
|
}
|
|
5205
|
-
if (
|
|
5206
|
-
s.outro(
|
|
5234
|
+
if (P.blocked.length > 0 && await So(P.blocked, N, b), P.installable.length === 0) {
|
|
5235
|
+
s.outro(z.muted("Nothing left to install once locked packs are removed."));
|
|
5207
5236
|
return;
|
|
5208
5237
|
}
|
|
5209
|
-
if (Co(
|
|
5210
|
-
let e = await s.confirm({ message: `Install template ${
|
|
5238
|
+
if (Co(P.installable, b), !t.yes) {
|
|
5239
|
+
let e = await s.confirm({ message: `Install template ${z.brandBold(u.name)} (${P.installable.length} pack${P.installable.length === 1 ? "" : "s"})?` });
|
|
5211
5240
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5212
5241
|
}
|
|
5213
5242
|
r.start("Downloading packs...");
|
|
5214
|
-
let
|
|
5243
|
+
let F;
|
|
5215
5244
|
try {
|
|
5216
|
-
|
|
5245
|
+
F = await wo(P.installable, {
|
|
5217
5246
|
token: S,
|
|
5218
5247
|
key: x
|
|
5219
5248
|
});
|
|
5220
5249
|
} catch (e) {
|
|
5221
5250
|
r.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
|
|
5222
5251
|
}
|
|
5223
|
-
r.stop(`Downloaded ${
|
|
5224
|
-
let
|
|
5225
|
-
prepared:
|
|
5252
|
+
r.stop(`Downloaded ${F.length} pack${F.length === 1 ? "" : "s"}`);
|
|
5253
|
+
let ne = await Oo({
|
|
5254
|
+
prepared: F,
|
|
5226
5255
|
config: h,
|
|
5227
5256
|
cwd: g,
|
|
5228
5257
|
force: t.force ?? !1,
|
|
5229
5258
|
yes: t.yes ?? !1
|
|
5230
|
-
}),
|
|
5259
|
+
}), I = null;
|
|
5231
5260
|
try {
|
|
5232
5261
|
r.start("Installing pack files...");
|
|
5233
5262
|
let n = await Ri({
|
|
5234
|
-
packs:
|
|
5263
|
+
packs: F,
|
|
5235
5264
|
config: h,
|
|
5236
5265
|
projectRoot: g,
|
|
5237
5266
|
force: t.force ?? !1,
|
|
5238
|
-
overwrite:
|
|
5267
|
+
overwrite: ne
|
|
5239
5268
|
});
|
|
5240
5269
|
if (n.aborted) {
|
|
5241
5270
|
r.stop("Installation aborted");
|
|
5242
5271
|
for (let e of n.errors) s.log.error(e);
|
|
5243
5272
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5244
5273
|
}
|
|
5245
|
-
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${
|
|
5274
|
+
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${z.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && (s.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`), Do(n.skipped));
|
|
5246
5275
|
for (let e of n.errors) s.log.error(e);
|
|
5247
5276
|
r.start("Applying template overrides...");
|
|
5248
5277
|
let o = await vs(u.id, {
|
|
5249
5278
|
token: S,
|
|
5250
5279
|
licenseKey: x
|
|
5251
5280
|
});
|
|
5252
|
-
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)),
|
|
5281
|
+
o.status === "denied" && (r.stop("Template download denied"), s.cancel(`Access to template "${u.id}" was denied (${o.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)), I = o.templateDir;
|
|
5253
5282
|
let c = await Bi({
|
|
5254
5283
|
manifest: d,
|
|
5255
5284
|
config: h,
|
|
5256
5285
|
projectRoot: g,
|
|
5257
|
-
templateDir:
|
|
5286
|
+
templateDir: I
|
|
5258
5287
|
});
|
|
5259
5288
|
r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
|
|
5260
5289
|
for (let e of c.errors) s.log.error(e);
|
|
5261
5290
|
if (!m) {
|
|
5262
5291
|
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5263
|
-
a(n) && (await za(t, i(n)) ? s.log.success(`Applied the ${i(n).label} theme`) : s.log.warning(
|
|
5292
|
+
a(n) && (await za(t, i(n)) ? s.log.success(`Applied the ${i(n).label} theme`) : s.log.warning(z.muted(`Could not find ${z.path("assets/styles.css")} to apply the theme`)));
|
|
5264
5293
|
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5265
|
-
await Na(t, r) ? s.log.success(`Default color mode set to ${r}`) : s.log.warning(
|
|
5294
|
+
await Na(t, r) ? s.log.success(`Default color mode set to ${r}`) : s.log.warning(z.muted(`Could not find ${z.path("src/hooks/use-theme.ts")} to set the default color mode`));
|
|
5266
5295
|
}
|
|
5267
5296
|
await Ss({
|
|
5268
|
-
prepared:
|
|
5297
|
+
prepared: F,
|
|
5269
5298
|
templateNpm: d.dependencies_npm,
|
|
5270
5299
|
paths: h.paths,
|
|
5271
5300
|
cwd: g,
|
|
@@ -5276,13 +5305,14 @@ async function ys(t = {}) {
|
|
|
5276
5305
|
projectRoot: g,
|
|
5277
5306
|
paths: h.paths,
|
|
5278
5307
|
skipPrompts: t.yes ?? !1,
|
|
5279
|
-
dbReady: l
|
|
5280
|
-
|
|
5308
|
+
dbReady: l,
|
|
5309
|
+
freshScaffold: m
|
|
5310
|
+
}), Eo(), s.outro(z.brand(`Installed template ${u.name}.`));
|
|
5281
5311
|
} finally {
|
|
5282
|
-
await Promise.all(
|
|
5312
|
+
await Promise.all(F.map((e) => y.rm(e.packDir, {
|
|
5283
5313
|
recursive: !0,
|
|
5284
5314
|
force: !0
|
|
5285
|
-
}))),
|
|
5315
|
+
}))), I && await y.rm(I, {
|
|
5286
5316
|
recursive: !0,
|
|
5287
5317
|
force: !0
|
|
5288
5318
|
});
|
|
@@ -5321,8 +5351,8 @@ async function xs(e) {
|
|
|
5321
5351
|
if (i.yes) return [];
|
|
5322
5352
|
let o = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
|
|
5323
5353
|
if (o.length === 0) return [];
|
|
5324
|
-
let c =
|
|
5325
|
-
s.note(o.map((e) => ` ${
|
|
5354
|
+
let c = se();
|
|
5355
|
+
s.note(o.map((e) => ` ${B.arrow} ${z.highlight(e.displayName)} ${ge(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5326
5356
|
let l = await Ea({
|
|
5327
5357
|
message: "Add extra packs on top of the template (optional)",
|
|
5328
5358
|
options: o.map((e) => ({
|