@hype-stack/cli 0.2.0 → 0.2.1
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-CPOgUkiJ.js → cli-B_p3GdS8.js} +2047 -1258
- package/dist/cli.d.ts.map +1 -1
- package/dist/commands/compose.d.ts +14 -1
- package/dist/commands/compose.d.ts.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/init.d.ts +23 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/install-helpers.d.ts +41 -0
- package/dist/commands/install-helpers.d.ts.map +1 -0
- package/dist/commands/template.d.ts +13 -0
- package/dist/commands/template.d.ts.map +1 -0
- package/dist/config/bin.js +453 -454
- package/dist/config/env.d.ts +0 -1
- package/dist/config/env.d.ts.map +1 -1
- package/dist/constants/constants.d.ts +1 -3
- package/dist/constants/constants.d.ts.map +1 -1
- package/dist/constants/themes.d.ts +40 -0
- package/dist/constants/themes.d.ts.map +1 -0
- package/dist/core/apply-theme.d.ts +17 -0
- package/dist/core/apply-theme.d.ts.map +1 -0
- package/dist/core/codemods.d.ts +42 -3
- package/dist/core/codemods.d.ts.map +1 -1
- package/dist/core/installer.d.ts +50 -3
- package/dist/core/installer.d.ts.map +1 -1
- package/dist/core/license.d.ts +5 -0
- package/dist/core/license.d.ts.map +1 -1
- package/dist/core/login.d.ts.map +1 -1
- package/dist/core/pack-categories.d.ts +40 -0
- package/dist/core/pack-categories.d.ts.map +1 -0
- package/dist/core/post-clone.d.ts.map +1 -1
- package/dist/core/stack-config.d.ts.map +1 -1
- package/dist/core/templates.d.ts +15 -0
- package/dist/core/templates.d.ts.map +1 -0
- package/dist/core/tracking.d.ts +9 -0
- package/dist/core/tracking.d.ts.map +1 -0
- package/dist/core/variants.d.ts +47 -0
- package/dist/core/variants.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/themes.js +833 -0
- package/dist/types/types.d.ts +127 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/ui/banner.d.ts.map +1 -1
- package/dist/ui/theme.d.ts +13 -0
- package/dist/ui/theme.d.ts.map +1 -1
- package/package.json +31 -1
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
1
|
+
import { DEFAULT_THEME as e, THEME_CHOICES as t, getTheme as n, isThemeName as r } from "./themes.js";
|
|
2
|
+
import { Command as i } from "commander";
|
|
3
|
+
import * as a from "@clack/prompts";
|
|
4
|
+
import o from "node:fs/promises";
|
|
5
|
+
import s from "picocolors";
|
|
6
|
+
import c from "node:os";
|
|
7
|
+
import l from "node:path";
|
|
8
|
+
import { exec as u, spawn as d } from "node:child_process";
|
|
9
|
+
import { downloadTemplate as f } from "giget";
|
|
9
10
|
//#region \0rolldown/runtime.js
|
|
10
|
-
var
|
|
11
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i =
|
|
11
|
+
var p = Object.create, m = Object.defineProperty, h = Object.getOwnPropertyDescriptor, g = Object.getOwnPropertyNames, _ = Object.getPrototypeOf, v = Object.prototype.hasOwnProperty, y = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), b = (e, t, n, r) => {
|
|
12
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = g(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !v.call(e, s) && s !== n && m(e, s, {
|
|
12
13
|
get: ((e) => t[e]).bind(null, s),
|
|
13
|
-
enumerable: !(r =
|
|
14
|
+
enumerable: !(r = h(t, s)) || r.enumerable
|
|
14
15
|
});
|
|
15
16
|
return e;
|
|
16
|
-
},
|
|
17
|
+
}, x = (e, t, n) => (n = e == null ? {} : p(_(e)), b(t || !e || !e.__esModule ? m(n, "default", {
|
|
17
18
|
value: e,
|
|
18
19
|
enumerable: !0
|
|
19
|
-
}) : n, e)),
|
|
20
|
+
}) : n, e)), S = "0.0.1", C = "gh:BetterTyped/hype-stack", w = "stack.json", T = "/schema/stack.json", E = "https://hype-stack.dev", D = "HYPE_STACK_API_URL", O = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, k = [
|
|
20
21
|
{
|
|
21
22
|
value: "cursor",
|
|
22
23
|
label: "Cursor",
|
|
@@ -34,89 +35,107 @@ var l = Object.create, u = Object.defineProperty, d = Object.getOwnPropertyDescr
|
|
|
34
35
|
value: "copilot",
|
|
35
36
|
label: "GitHub Copilot"
|
|
36
37
|
}
|
|
37
|
-
],
|
|
38
|
-
function
|
|
38
|
+
], ee = k.map((e) => e.value), A = ".cursor/rules", j = ".cursor", te = ".agents";
|
|
39
|
+
function M() {
|
|
39
40
|
let e = process.env.HYPE_STACK_API_URL;
|
|
40
|
-
return e ? (ne(e), e.replace(/\/+$/, "")) :
|
|
41
|
+
return e ? (ne(e), e.replace(/\/+$/, "")) : E;
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function N() {
|
|
43
44
|
let e = process.env.HYPE_STACK_WEB_URL;
|
|
44
|
-
return e ? (ne(e), e.replace(/\/+$/, "")) :
|
|
45
|
+
return e ? (ne(e), e.replace(/\/+$/, "")) : M();
|
|
45
46
|
}
|
|
46
47
|
function ne(e) {
|
|
47
48
|
try {
|
|
48
49
|
let t = new URL(e);
|
|
49
|
-
if (!t.protocol.startsWith("http")) throw Error(`${
|
|
50
|
+
if (!t.protocol.startsWith("http")) throw Error(`${D} must use http or https protocol, got "${t.protocol}"`);
|
|
50
51
|
} catch (t) {
|
|
51
|
-
throw t instanceof TypeError ? Error(`${
|
|
52
|
+
throw t instanceof TypeError ? Error(`${D} is not a valid URL: "${e}"`, { cause: t }) : t;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
function re() {
|
|
55
|
-
return `${
|
|
56
|
+
return `${M()}${T}`;
|
|
56
57
|
}
|
|
57
58
|
//#endregion
|
|
58
59
|
//#region src/ui/theme.ts
|
|
59
|
-
var
|
|
60
|
-
orange:
|
|
61
|
-
orangeBright:
|
|
62
|
-
amber:
|
|
63
|
-
deepBlue:
|
|
64
|
-
skyBlue:
|
|
65
|
-
lightBlue:
|
|
66
|
-
}, I = {
|
|
67
|
-
brand: (e) => A(e),
|
|
68
|
-
brandBold: (e) => r.bold(A(e)),
|
|
69
|
-
accent: (e) => N(e),
|
|
70
|
-
accentBold: (e) => r.bold(N(e)),
|
|
71
|
-
success: (e) => r.green(e),
|
|
72
|
-
error: (e) => r.red(e),
|
|
73
|
-
warning: (e) => r.yellow(e),
|
|
74
|
-
muted: (e) => r.dim(e),
|
|
75
|
-
bold: (e) => r.bold(e),
|
|
76
|
-
highlight: (e) => r.bold(r.white(e)),
|
|
77
|
-
path: (e) => r.underline(N(e)),
|
|
78
|
-
command: (e) => r.bold(M(e)),
|
|
79
|
-
label: (e) => r.dim(r.bold(e))
|
|
60
|
+
var P = (e) => `\x1b[38;5;208m${e}\x1b[39m`, ie = (e) => `\x1b[38;5;214m${e}\x1b[39m`, F = (e) => `\x1b[38;5;220m${e}\x1b[39m`, ae = (e) => `\x1b[38;5;33m${e}\x1b[39m`, I = (e) => `\x1b[38;5;39m${e}\x1b[39m`, oe = (e) => `\x1b[38;5;81m${e}\x1b[39m`, se = {
|
|
61
|
+
orange: P,
|
|
62
|
+
orangeBright: ie,
|
|
63
|
+
amber: F,
|
|
64
|
+
deepBlue: ae,
|
|
65
|
+
skyBlue: I,
|
|
66
|
+
lightBlue: oe
|
|
80
67
|
}, L = {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
68
|
+
brand: (e) => P(e),
|
|
69
|
+
brandBold: (e) => s.bold(P(e)),
|
|
70
|
+
accent: (e) => I(e),
|
|
71
|
+
accentBold: (e) => s.bold(I(e)),
|
|
72
|
+
success: (e) => s.green(e),
|
|
73
|
+
error: (e) => s.red(e),
|
|
74
|
+
warning: (e) => s.yellow(e),
|
|
75
|
+
muted: (e) => s.dim(e),
|
|
76
|
+
bold: (e) => s.bold(e),
|
|
77
|
+
highlight: (e) => s.bold(s.white(e)),
|
|
78
|
+
path: (e) => s.underline(I(e)),
|
|
79
|
+
command: (e) => s.bold(F(e)),
|
|
80
|
+
label: (e) => s.dim(s.bold(e))
|
|
81
|
+
}, R = {
|
|
82
|
+
arrow: P("›"),
|
|
83
|
+
bullet: L.muted("·"),
|
|
84
|
+
dash: L.muted("─"),
|
|
85
|
+
corner: L.muted("╰"),
|
|
86
|
+
pipe: L.muted("│"),
|
|
87
|
+
dot: L.muted("•"),
|
|
88
|
+
spark: F("✦"),
|
|
89
|
+
sparkSmall: ie("✧"),
|
|
90
|
+
bolt: F("⚡")
|
|
91
|
+
}, ce = [
|
|
92
|
+
F,
|
|
93
|
+
F,
|
|
95
94
|
ie,
|
|
96
|
-
N,
|
|
97
95
|
P,
|
|
98
|
-
|
|
96
|
+
ae,
|
|
97
|
+
I,
|
|
98
|
+
oe,
|
|
99
|
+
oe
|
|
99
100
|
];
|
|
100
|
-
function
|
|
101
|
+
function le(e) {
|
|
101
102
|
let t = [...e], n = t.length;
|
|
102
103
|
return t.map((e, t) => {
|
|
103
104
|
if (e === " " || e === "\n") return e;
|
|
104
105
|
let r = t / Math.max(n - 1, 1);
|
|
105
|
-
return
|
|
106
|
+
return ce[Math.min(Math.floor(r * ce.length), ce.length - 1)](e);
|
|
106
107
|
}).join("");
|
|
107
108
|
}
|
|
109
|
+
function ue(e, t, n) {
|
|
110
|
+
return Math.round(e + (t - e) * n);
|
|
111
|
+
}
|
|
112
|
+
function de(e, t) {
|
|
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
|
+
return e.map((e, t) => [...e].map((e, s) => {
|
|
115
|
+
if (e === " ") return e;
|
|
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;${ue(n[0], r[0], u)};${ue(n[1], r[1], u)};${ue(n[2], r[2], u)}m${e}\x1b[39m`;
|
|
118
|
+
}).join(""));
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/core/license.ts
|
|
122
|
+
function fe(e) {
|
|
123
|
+
return `${N()}/packs/${e}`;
|
|
124
|
+
}
|
|
108
125
|
//#endregion
|
|
109
126
|
//#region ../../node_modules/.pnpm/@hyper-fetch+core@8.1.1/node_modules/@hyper-fetch/core/dist/index.mjs
|
|
110
|
-
var
|
|
111
|
-
|
|
127
|
+
var pe = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
|
|
128
|
+
t.exports = {};
|
|
129
|
+
})))(), 1), me = Object.create, he = Object.defineProperty, ge = Object.getOwnPropertyDescriptor, _e = Object.getOwnPropertyNames, ve = Object.getPrototypeOf, ye = Object.prototype.hasOwnProperty, be = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), xe = (e, t, n, r) => {
|
|
130
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = _e(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !ye.call(e, s) && s !== n && he(e, s, {
|
|
112
131
|
get: ((e) => t[e]).bind(null, s),
|
|
113
|
-
enumerable: !(r =
|
|
132
|
+
enumerable: !(r = ge(t, s)) || r.enumerable
|
|
114
133
|
});
|
|
115
134
|
return e;
|
|
116
|
-
},
|
|
135
|
+
}, Se = (e, t, n) => (n = e == null ? {} : me(ve(e)), xe(t || !e || !e.__esModule ? he(n, "default", {
|
|
117
136
|
value: e,
|
|
118
137
|
enumerable: !0
|
|
119
|
-
}) : n, e)),
|
|
138
|
+
}) : n, e)), Ce = (e) => `${e.queryKey}_${Date.now().toString(36)}_${Math.random().toString(36).substring(2)}`, we = /* @__PURE__ */ Se((/* @__PURE__ */ be(((e, t) => {
|
|
120
139
|
var n = typeof Reflect == "object" ? Reflect : null, r = n && typeof n.apply == "function" ? n.apply : function(e, t, n) {
|
|
121
140
|
return Function.prototype.apply.call(e, t, n);
|
|
122
141
|
}, i = n && typeof n.ownKeys == "function" ? n.ownKeys : Object.getOwnPropertySymbols ? function(e) {
|
|
@@ -291,7 +310,7 @@ var se = Object.create, ce = Object.defineProperty, le = Object.getOwnPropertyDe
|
|
|
291
310
|
});
|
|
292
311
|
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
293
312
|
}
|
|
294
|
-
})))()),
|
|
313
|
+
})))()), Te = (e) => `listen_${String(e)}`, Ee = class extends we.default {
|
|
295
314
|
emitCallbacks = [];
|
|
296
315
|
constructor(e) {
|
|
297
316
|
super(e);
|
|
@@ -303,26 +322,26 @@ var se = Object.create, ce = Object.defineProperty, le = Object.getOwnPropertyDe
|
|
|
303
322
|
onEmit = (e) => (this.emitCallbacks?.push(e), () => {
|
|
304
323
|
this.emitCallbacks = this.emitCallbacks?.filter((t) => t !== e);
|
|
305
324
|
});
|
|
306
|
-
onListener = (e, t) => (super.on(
|
|
307
|
-
super.off(
|
|
325
|
+
onListener = (e, t) => (super.on(Te(e), t), () => {
|
|
326
|
+
super.off(Te(e), t);
|
|
308
327
|
});
|
|
309
|
-
on = (e, t) => (super.on(e, t), super.emit(
|
|
310
|
-
off = (e, t) => (super.off(e, t), super.emit(
|
|
328
|
+
on = (e, t) => (super.on(e, t), super.emit(Te(e), super.listeners(e).length), this);
|
|
329
|
+
off = (e, t) => (super.off(e, t), super.emit(Te(e), super.listeners(e).length), this);
|
|
311
330
|
addListener = this.on;
|
|
312
331
|
removeListener = this.off;
|
|
313
|
-
},
|
|
314
|
-
emitter = new
|
|
315
|
-
events =
|
|
332
|
+
}, De = class {
|
|
333
|
+
emitter = new Ee();
|
|
334
|
+
events = Me(this.emitter);
|
|
316
335
|
isBrowser;
|
|
317
336
|
isOnline;
|
|
318
337
|
isFocused;
|
|
319
338
|
constructor(e) {
|
|
320
339
|
this.options = e, this.emitter?.setMaxListeners(1e3);
|
|
321
|
-
let { initiallyFocused: t =
|
|
322
|
-
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser =
|
|
340
|
+
let { initiallyFocused: t = B.initiallyFocused, initiallyOnline: n = B.initiallyOnline } = this.options || B;
|
|
341
|
+
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser = ke();
|
|
323
342
|
}
|
|
324
343
|
initialize = () => {
|
|
325
|
-
let { focusEvent: e =
|
|
344
|
+
let { focusEvent: e = B.focusEvent, onlineEvent: t = B.onlineEvent } = this.options || B;
|
|
326
345
|
e(this.setFocused), t(this.setOnline);
|
|
327
346
|
};
|
|
328
347
|
setInitialFocus = async (e) => {
|
|
@@ -337,51 +356,51 @@ var se = Object.create, ce = Object.defineProperty, le = Object.getOwnPropertyDe
|
|
|
337
356
|
setOnline = (e) => {
|
|
338
357
|
this.isOnline = e, e ? this.events.emitOnline() : this.events.emitOffline();
|
|
339
358
|
};
|
|
340
|
-
},
|
|
359
|
+
}, Oe = () => {
|
|
341
360
|
try {
|
|
342
361
|
return !!(window && window.addEventListener);
|
|
343
362
|
} catch {
|
|
344
363
|
/* istanbul ignore next */
|
|
345
364
|
return !1;
|
|
346
365
|
}
|
|
347
|
-
},
|
|
366
|
+
}, ke = () => {
|
|
348
367
|
try {
|
|
349
|
-
return !!(
|
|
368
|
+
return !!(Oe() && window.document && window.document.addEventListener);
|
|
350
369
|
} catch {
|
|
351
370
|
/* istanbul ignore next */
|
|
352
371
|
return !1;
|
|
353
372
|
}
|
|
354
|
-
},
|
|
373
|
+
}, Ae = (e, t, n) => Oe() ? (window.addEventListener(e, t, n), () => window.removeEventListener(e, t, n)) : () => null, je = (e, t, n) => ke() ? (window.document.addEventListener(e, t, n), () => window.document.removeEventListener(e, t, n)) : () => null, Me = (e) => ({
|
|
355
374
|
emitFocus: () => {
|
|
356
|
-
e.emit(
|
|
375
|
+
e.emit(z.FOCUS);
|
|
357
376
|
},
|
|
358
377
|
emitBlur: () => {
|
|
359
|
-
e.emit(
|
|
378
|
+
e.emit(z.BLUR);
|
|
360
379
|
},
|
|
361
380
|
emitOnline: () => {
|
|
362
|
-
e.emit(
|
|
381
|
+
e.emit(z.ONLINE);
|
|
363
382
|
},
|
|
364
383
|
emitOffline: () => {
|
|
365
|
-
e.emit(
|
|
384
|
+
e.emit(z.OFFLINE);
|
|
366
385
|
},
|
|
367
|
-
onFocus: (t) => (e.on(
|
|
368
|
-
onBlur: (t) => (e.on(
|
|
369
|
-
onOnline: (t) => (e.on(
|
|
370
|
-
onOffline: (t) => (e.on(
|
|
371
|
-
}),
|
|
386
|
+
onFocus: (t) => (e.on(z.FOCUS, t), () => e.removeListener(z.FOCUS, t)),
|
|
387
|
+
onBlur: (t) => (e.on(z.BLUR, t), () => e.removeListener(z.BLUR, t)),
|
|
388
|
+
onOnline: (t) => (e.on(z.ONLINE, t), () => e.removeListener(z.ONLINE, t)),
|
|
389
|
+
onOffline: (t) => (e.on(z.OFFLINE, t), () => e.removeListener(z.OFFLINE, t))
|
|
390
|
+
}), z = /* @__PURE__ */ function(e) {
|
|
372
391
|
return e.FOCUS = "focus", e.BLUR = "blur", e.ONLINE = "online", e.OFFLINE = "offline", e;
|
|
373
|
-
}({}),
|
|
392
|
+
}({}), B = {
|
|
374
393
|
initiallyFocused: !0,
|
|
375
394
|
initiallyOnline: !0,
|
|
376
395
|
focusEvent: (e) => {
|
|
377
|
-
|
|
396
|
+
je("visibilitychange", () => e(!0)), Ae("focus", () => e(!0)), Ae("blur", () => e(!1));
|
|
378
397
|
},
|
|
379
398
|
onlineEvent: (e) => {
|
|
380
|
-
|
|
399
|
+
Ae("online", () => e(!0)), Ae("offline", () => e(!1));
|
|
381
400
|
}
|
|
382
|
-
},
|
|
383
|
-
emitter = new
|
|
384
|
-
events =
|
|
401
|
+
}, Ne = class {
|
|
402
|
+
emitter = new Ee();
|
|
403
|
+
events = lt(this.emitter);
|
|
385
404
|
constructor() {
|
|
386
405
|
this.emitter?.setMaxListeners(1e3);
|
|
387
406
|
}
|
|
@@ -418,71 +437,71 @@ var se = Object.create, ce = Object.defineProperty, le = Object.getOwnPropertyDe
|
|
|
418
437
|
});
|
|
419
438
|
});
|
|
420
439
|
};
|
|
421
|
-
},
|
|
440
|
+
}, Pe = () => "loading-event-any", Fe = (e) => `${e}-loading-event`, Ie = (e) => `${e}-loading-cache-event`, Le = (e) => `${e}-loading-event-by-id`, Re = () => "remove-event-any", ze = (e) => `${e}-remove-event`, Be = (e) => `${e}-remove-event-by-id`, Ve = () => "request-abort-any", He = (e) => `${e}-request-abort`, Ue = (e) => `${e}-request-abort-by-id`, We = () => "response-any", Ge = (e) => `${e}-response`, Ke = (e) => `${e}-response-by-id`, qe = () => "request-start-any", Je = (e) => `${e}-request-start`, Ye = (e) => `${e}-request-start-by-id`, Xe = () => "response-start-any", Ze = (e) => `${e}-response-start`, Qe = (e) => `${e}-response-start-by-id`, $e = () => "request-progress-any", et = (e) => `${e}-request-progress`, tt = (e) => `${e}-request-progress-by-id`, nt = () => "response-progress-any", rt = (e) => `${e}-response-progress`, it = (e) => `${e}-response-progress-by-id`, at = () => "request-deduplicated-any", ot = (e) => `${e}-query-request-deduplicated`, st = (e) => `${e}-cache-request-deduplicated`, ct = (e) => `${e}-request-deduplicated-by-id`, lt = (e) => ({
|
|
422
441
|
emitDeduplicated: (t, n = !1) => {
|
|
423
|
-
e.emit(
|
|
442
|
+
e.emit(at(), t, n), e.emit(ct(t.requestId), t, n), e.emit(st(t.request.cacheKey), t, n), e.emit(ot(t.request.queryKey), t, n);
|
|
424
443
|
},
|
|
425
444
|
emitLoading: (t, n = !1) => {
|
|
426
|
-
e.emit(
|
|
445
|
+
e.emit(Pe(), t, n), e.emit(Le(t.requestId), t, n), e.emit(Ie(t.request.cacheKey), t, n), e.emit(Fe(t.request.queryKey), t, n);
|
|
427
446
|
},
|
|
428
447
|
emitRequestStart: (t, n = !1) => {
|
|
429
|
-
e.emit(
|
|
448
|
+
e.emit(qe(), t, n), e.emit(Ye(t.requestId), t, n), e.emit(Je(t.request.queryKey), t, n);
|
|
430
449
|
},
|
|
431
450
|
emitResponseStart: (t, n = !1) => {
|
|
432
|
-
e.emit(
|
|
451
|
+
e.emit(Xe(), t, n), e.emit(Qe(t.requestId), t, n), e.emit(Ze(t.request.queryKey), t, n);
|
|
433
452
|
},
|
|
434
453
|
emitUploadProgress: (t, n = !1) => {
|
|
435
|
-
e.emit(
|
|
454
|
+
e.emit($e(), t, n), e.emit(tt(t.requestId), t, n), e.emit(et(t.request.queryKey), t, n);
|
|
436
455
|
},
|
|
437
456
|
emitDownloadProgress: (t, n = !1) => {
|
|
438
|
-
e.emit(
|
|
457
|
+
e.emit(nt(), t, n), e.emit(it(t.requestId), t, n), e.emit(rt(t.request.queryKey), t, n);
|
|
439
458
|
},
|
|
440
459
|
emitResponse: (t, n = !1) => {
|
|
441
|
-
e.emit(
|
|
460
|
+
e.emit(We(), t, n), e.emit(Ke(t.requestId), t, n), e.emit(Ge(t.request.cacheKey), t, n);
|
|
442
461
|
},
|
|
443
462
|
emitAbort: (t, n = !1) => {
|
|
444
|
-
e.emit(
|
|
463
|
+
e.emit(Ve(), t, n), e.emit(Ue(t.requestId), t, n), e.emit(He(t.request.abortKey), t, n);
|
|
445
464
|
},
|
|
446
465
|
emitRemove: (t, n = !1) => {
|
|
447
|
-
e.emit(
|
|
466
|
+
e.emit(Re(), t, n), e.emit(Be(t.requestId), t, n), e.emit(ze(t.request.queryKey), t, n);
|
|
448
467
|
},
|
|
449
|
-
onDeduplicated: (t) => (e.on(
|
|
450
|
-
onDeduplicatedByQueue: (t, n) => (e.on(
|
|
451
|
-
onDeduplicatedByCache: (t, n) => (e.on(
|
|
452
|
-
onDeduplicatedById: (t, n) => (e.on(
|
|
453
|
-
onLoading: (t) => (e.on(
|
|
454
|
-
onLoadingByQueue: (t, n) => (e.on(
|
|
455
|
-
onLoadingByCache: (t, n) => (e.on(
|
|
456
|
-
onLoadingById: (t, n) => (e.on(
|
|
457
|
-
onRequestStart: (t) => (e.on(
|
|
458
|
-
onRequestStartByQueue: (t, n) => (e.on(
|
|
459
|
-
onRequestStartById: (t, n) => (e.on(
|
|
460
|
-
onResponseStart: (t) => (e.on(
|
|
461
|
-
onResponseStartByQueue: (t, n) => (e.on(
|
|
462
|
-
onResponseStartById: (t, n) => (e.on(
|
|
463
|
-
onUploadProgress: (t) => (e.on(
|
|
464
|
-
onUploadProgressByQueue: (t, n) => (e.on(
|
|
465
|
-
onUploadProgressById: (t, n) => (e.on(
|
|
466
|
-
onDownloadProgress: (t) => (e.on(
|
|
467
|
-
onDownloadProgressByQueue: (t, n) => (e.on(
|
|
468
|
-
onDownloadProgressById: (t, n) => (e.on(
|
|
469
|
-
onResponse: (t) => (e.on(
|
|
470
|
-
onResponseByCache: (t, n) => (e.on(
|
|
471
|
-
onResponseById: (t, n) => (e.on(
|
|
472
|
-
onAbort: (t) => (e.on(
|
|
473
|
-
onAbortByKey: (t, n) => (e.on(
|
|
474
|
-
onAbortById: (t, n) => (e.on(
|
|
475
|
-
onRemove: (t) => (e.on(
|
|
476
|
-
onRemoveByQueue: (t, n) => (e.on(
|
|
477
|
-
onRemoveById: (t, n) => (e.on(
|
|
478
|
-
}),
|
|
468
|
+
onDeduplicated: (t) => (e.on(at(), t), () => e.removeListener(at(), t)),
|
|
469
|
+
onDeduplicatedByQueue: (t, n) => (e.on(ot(t), n), () => e.removeListener(ot(t), n)),
|
|
470
|
+
onDeduplicatedByCache: (t, n) => (e.on(st(t), n), () => e.removeListener(st(t), n)),
|
|
471
|
+
onDeduplicatedById: (t, n) => (e.on(ct(t), n), () => e.removeListener(ct(t), n)),
|
|
472
|
+
onLoading: (t) => (e.on(Pe(), t), () => e.removeListener(Pe(), t)),
|
|
473
|
+
onLoadingByQueue: (t, n) => (e.on(Fe(t), n), () => e.removeListener(Fe(t), n)),
|
|
474
|
+
onLoadingByCache: (t, n) => (e.on(Ie(t), n), () => e.removeListener(Ie(t), n)),
|
|
475
|
+
onLoadingById: (t, n) => (e.on(Le(t), n), () => e.removeListener(Le(t), n)),
|
|
476
|
+
onRequestStart: (t) => (e.on(qe(), t), () => e.removeListener(qe(), t)),
|
|
477
|
+
onRequestStartByQueue: (t, n) => (e.on(Je(t), n), () => e.removeListener(Je(t), n)),
|
|
478
|
+
onRequestStartById: (t, n) => (e.on(Ye(t), n), () => e.removeListener(Ye(t), n)),
|
|
479
|
+
onResponseStart: (t) => (e.on(Xe(), t), () => e.removeListener(Xe(), t)),
|
|
480
|
+
onResponseStartByQueue: (t, n) => (e.on(Ze(t), n), () => e.removeListener(Ze(t), n)),
|
|
481
|
+
onResponseStartById: (t, n) => (e.on(Qe(t), n), () => e.removeListener(Qe(t), n)),
|
|
482
|
+
onUploadProgress: (t) => (e.on($e(), t), () => e.removeListener($e(), t)),
|
|
483
|
+
onUploadProgressByQueue: (t, n) => (e.on(et(t), n), () => e.removeListener(et(t), n)),
|
|
484
|
+
onUploadProgressById: (t, n) => (e.on(tt(t), n), () => e.removeListener(tt(t), n)),
|
|
485
|
+
onDownloadProgress: (t) => (e.on(nt(), t), () => e.removeListener(nt(), t)),
|
|
486
|
+
onDownloadProgressByQueue: (t, n) => (e.on(rt(t), n), () => e.removeListener(rt(t), n)),
|
|
487
|
+
onDownloadProgressById: (t, n) => (e.on(it(t), n), () => e.removeListener(it(t), n)),
|
|
488
|
+
onResponse: (t) => (e.on(We(), t), () => e.removeListener(We(), t)),
|
|
489
|
+
onResponseByCache: (t, n) => (e.on(Ge(t), n), () => e.removeListener(Ge(t), n)),
|
|
490
|
+
onResponseById: (t, n) => (e.on(Ke(t), n), () => e.removeListener(Ke(t), n)),
|
|
491
|
+
onAbort: (t) => (e.on(Ve(), t), () => e.removeListener(Ve(), t)),
|
|
492
|
+
onAbortByKey: (t, n) => (e.on(He(t), n), () => e.removeListener(He(t), n)),
|
|
493
|
+
onAbortById: (t, n) => (e.on(Ue(t), n), () => e.removeListener(Ue(t), n)),
|
|
494
|
+
onRemove: (t) => (e.on(Re(), t), () => e.removeListener(Re(), t)),
|
|
495
|
+
onRemoveByQueue: (t, n) => (e.on(ze(t), n), () => e.removeListener(ze(t), n)),
|
|
496
|
+
onRemoveById: (t, n) => (e.on(Be(t), n), () => e.removeListener(Be(t), n))
|
|
497
|
+
}), ut = class {
|
|
479
498
|
logger;
|
|
480
499
|
level;
|
|
481
500
|
modules;
|
|
482
|
-
emitter = new
|
|
501
|
+
emitter = new we.default();
|
|
483
502
|
client;
|
|
484
503
|
constructor(e) {
|
|
485
|
-
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger ||
|
|
504
|
+
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger || pt, this.level = this.options?.level || "warning", this.modules = this.options?.modules;
|
|
486
505
|
}
|
|
487
506
|
setSeverity = (e) => {
|
|
488
507
|
this.level = e;
|
|
@@ -513,58 +532,58 @@ var se = Object.create, ce = Object.defineProperty, le = Object.getOwnPropertyDe
|
|
|
513
532
|
})
|
|
514
533
|
});
|
|
515
534
|
log = (e) => {
|
|
516
|
-
this.client.debug && (
|
|
535
|
+
this.client.debug && (mt.indexOf(this.level) <= mt.indexOf(e.level) || this.modules && !this.modules.includes(e.module) || this.logger(e));
|
|
517
536
|
};
|
|
518
|
-
},
|
|
519
|
-
let t =
|
|
537
|
+
}, dt = () => `${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`, ft = (e) => e.type === "request" || e.type === "response" ? `${e.extra.request.endpoint}` : `[${e.module}]`, pt = (e) => {
|
|
538
|
+
let t = gt[e.level], n = _t[e.level], r = `%c[${dt()}]%c${e.title}%c${ft(e)}`, i = `${t}${n}font-weight:600;border-radius: 4px 0 0 4px;`, a = `${t}${n}font-weight:600;`, o = `${t}font-weight:normal;border-radius: 0 4px 4px 0;`;
|
|
520
539
|
e.extra && Object.keys(e.extra)?.length ? (console.groupCollapsed(r, i, a, o), console.log(e.extra), console.groupEnd()) : console.log(r, t);
|
|
521
|
-
},
|
|
540
|
+
}, mt = [
|
|
522
541
|
"error",
|
|
523
542
|
"warning",
|
|
524
543
|
"info",
|
|
525
544
|
"debug"
|
|
526
|
-
],
|
|
527
|
-
error: `${
|
|
528
|
-
warning: `${
|
|
529
|
-
info: `${
|
|
530
|
-
debug: `${
|
|
531
|
-
},
|
|
545
|
+
], ht = "padding:2px 5px;", gt = {
|
|
546
|
+
error: `${ht};background:#db252520;`,
|
|
547
|
+
warning: `${ht};background:#e1941e20;`,
|
|
548
|
+
info: `${ht};background:#1e74e120;`,
|
|
549
|
+
debug: `${ht};background:#00000020;`
|
|
550
|
+
}, _t = {
|
|
532
551
|
error: "color:#ff3737;",
|
|
533
552
|
warning: "color:#ffc107;",
|
|
534
553
|
info: "color:#34a8ff;",
|
|
535
554
|
debug: "color:#cccccc;"
|
|
536
|
-
},
|
|
555
|
+
}, vt = class extends Error {
|
|
537
556
|
constructor() {
|
|
538
557
|
super("Request timeout"), this.name = "TimeoutError";
|
|
539
558
|
}
|
|
540
|
-
},
|
|
559
|
+
}, yt = class extends Error {
|
|
541
560
|
constructor() {
|
|
542
561
|
super("Request aborted"), this.name = "AbortError";
|
|
543
562
|
}
|
|
544
|
-
},
|
|
563
|
+
}, bt = class extends Error {
|
|
545
564
|
constructor() {
|
|
546
565
|
super("Request deleted"), this.name = "DeletedError";
|
|
547
566
|
}
|
|
548
|
-
},
|
|
567
|
+
}, xt = class extends Error {
|
|
549
568
|
description;
|
|
550
569
|
constructor(e) {
|
|
551
570
|
super("Request processing error"), this.description = e, this.name = "RequestProcessingError";
|
|
552
571
|
}
|
|
553
|
-
},
|
|
572
|
+
}, St = class extends Error {
|
|
554
573
|
description;
|
|
555
574
|
constructor(e) {
|
|
556
575
|
super("Unexpected error"), this.description = e, this.name = "UnexpectedError";
|
|
557
576
|
}
|
|
558
|
-
},
|
|
577
|
+
}, V = (e) => e === "timeout" ? new vt() : e === "abort" ? new yt() : e === "deleted" ? new bt() : e === "processing" ? new xt() : new St(), Ct = (e) => {
|
|
559
578
|
try {
|
|
560
579
|
return JSON.stringify(e);
|
|
561
580
|
} catch {
|
|
562
581
|
return "";
|
|
563
582
|
}
|
|
564
|
-
},
|
|
565
|
-
let t =
|
|
583
|
+
}, wt = (e) => {
|
|
584
|
+
let t = Oe() && e.payload instanceof FormData, n = typeof e.payload == "object" && e.payload !== null, r = {};
|
|
566
585
|
return !t && n && (r["Content-Type"] = "application/json"), Object.assign(r, e.headers), r;
|
|
567
|
-
},
|
|
586
|
+
}, Tt = (e) => Oe() && e instanceof FormData ? e : Ct(e), Et = [
|
|
568
587
|
"onBeforeSent",
|
|
569
588
|
"onRequestStart",
|
|
570
589
|
"onResponseStart",
|
|
@@ -573,7 +592,7 @@ var se = Object.create, ce = Object.defineProperty, le = Object.getOwnPropertyDe
|
|
|
573
592
|
"onResponse",
|
|
574
593
|
"onRemove"
|
|
575
594
|
];
|
|
576
|
-
function
|
|
595
|
+
function Dt(e) {
|
|
577
596
|
let t = {
|
|
578
597
|
onBeforeSent: [],
|
|
579
598
|
onRequestStart: [],
|
|
@@ -583,7 +602,7 @@ function vt(e) {
|
|
|
583
602
|
onResponse: [],
|
|
584
603
|
onRemove: []
|
|
585
604
|
};
|
|
586
|
-
e &&
|
|
605
|
+
e && Et.forEach((n) => {
|
|
587
606
|
t[n] = [...e[n]];
|
|
588
607
|
});
|
|
589
608
|
let n = (e) => (n) => (t[e].push(n), () => {
|
|
@@ -605,15 +624,15 @@ function vt(e) {
|
|
|
605
624
|
},
|
|
606
625
|
__snapshot() {
|
|
607
626
|
let e = {};
|
|
608
|
-
return
|
|
627
|
+
return Et.forEach((n) => {
|
|
609
628
|
e[n] = [...t[n]];
|
|
610
629
|
}), e;
|
|
611
630
|
}
|
|
612
631
|
};
|
|
613
632
|
}
|
|
614
|
-
var
|
|
633
|
+
var Ot = /* @__PURE__ */ function(e) {
|
|
615
634
|
return e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.PATCH = "PATCH", e.DELETE = "DELETE", e;
|
|
616
|
-
}({}),
|
|
635
|
+
}({}), H = (e, t) => t ? `${t}__${e}` : e, kt = (e) => {
|
|
617
636
|
try {
|
|
618
637
|
if (typeof e == "string") return e;
|
|
619
638
|
if (e == null) return "";
|
|
@@ -623,13 +642,13 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
623
642
|
} catch {
|
|
624
643
|
return "";
|
|
625
644
|
}
|
|
626
|
-
},
|
|
645
|
+
}, At = ({ loaded: e, total: t }) => !e || !t ? 0 : Number((e * 100 / t).toFixed(0)), jt = (e, t, { total: n, loaded: r }) => {
|
|
627
646
|
let i = r / (t - +e || 1), a = Math.max(n, r), o = a - r, s = i ? o / i : null;
|
|
628
647
|
return {
|
|
629
648
|
timeLeft: a === r ? 0 : s,
|
|
630
649
|
sizeLeft: o
|
|
631
650
|
};
|
|
632
|
-
},
|
|
651
|
+
}, Mt = (e, t, n) => {
|
|
633
652
|
let { total: r, loaded: i } = n;
|
|
634
653
|
if (Number.isNaN(r) || Number.isNaN(i)) return {
|
|
635
654
|
progress: 0,
|
|
@@ -639,23 +658,23 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
639
658
|
loaded: 0,
|
|
640
659
|
startTimestamp: +e
|
|
641
660
|
};
|
|
642
|
-
let { timeLeft: a, sizeLeft: o } =
|
|
661
|
+
let { timeLeft: a, sizeLeft: o } = jt(e, t, n);
|
|
643
662
|
return {
|
|
644
|
-
progress:
|
|
663
|
+
progress: At(n),
|
|
645
664
|
timeLeft: a,
|
|
646
665
|
sizeLeft: o,
|
|
647
666
|
total: r,
|
|
648
667
|
loaded: i,
|
|
649
668
|
startTimestamp: +e
|
|
650
669
|
};
|
|
651
|
-
},
|
|
652
|
-
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method ===
|
|
670
|
+
}, Nt = (e) => `${e.method}_${e.requestOptions.endpoint}_${e.cancelable}`, Pt = (e, t) => `${kt(e.method)}_${t ? e.requestOptions.endpoint : kt(e.endpoint)}_${t ? "" : kt(e.queryParams)}`, Ft = (e, t = "auto") => {
|
|
671
|
+
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method === Ot.GET, a = t === "auto" && i || t === "fetch";
|
|
653
672
|
return [a ? n : r, a];
|
|
654
|
-
},
|
|
673
|
+
}, It = async (e, t) => {
|
|
655
674
|
let n = e.unstable_responseMapper?.(t);
|
|
656
675
|
return n instanceof Promise ? await n : n || t;
|
|
657
|
-
},
|
|
658
|
-
let { client: n } = e, { requestManager: r } = n, [i] =
|
|
676
|
+
}, Lt = async (e, t) => {
|
|
677
|
+
let { client: n } = e, { requestManager: r } = n, [i] = Ft(e, t?.dispatcherType), a;
|
|
659
678
|
if (e.optimistic) try {
|
|
660
679
|
a = await e.optimistic({
|
|
661
680
|
request: e,
|
|
@@ -731,7 +750,7 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
731
750
|
data: null,
|
|
732
751
|
status: null,
|
|
733
752
|
success: !1,
|
|
734
|
-
error:
|
|
753
|
+
error: V("deleted"),
|
|
735
754
|
extra: e.client.adapter.defaultExtra,
|
|
736
755
|
requestTimestamp: +/* @__PURE__ */ new Date(),
|
|
737
756
|
responseTimestamp: +/* @__PURE__ */ new Date()
|
|
@@ -742,9 +761,9 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
742
761
|
u(), d(), f(), p(), m(), h();
|
|
743
762
|
}
|
|
744
763
|
});
|
|
745
|
-
},
|
|
764
|
+
}, Rt = /* @__PURE__ */ function(e) {
|
|
746
765
|
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;
|
|
747
|
-
}({}),
|
|
766
|
+
}({}), zt = class e {
|
|
748
767
|
endpoint;
|
|
749
768
|
headers;
|
|
750
769
|
auth;
|
|
@@ -768,7 +787,7 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
768
787
|
deduplicate;
|
|
769
788
|
deduplicateTime;
|
|
770
789
|
scope;
|
|
771
|
-
$hooks =
|
|
790
|
+
$hooks = Dt();
|
|
772
791
|
isMockerEnabled = !1;
|
|
773
792
|
unstable_mock;
|
|
774
793
|
unstable_payloadMapper;
|
|
@@ -785,7 +804,7 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
785
804
|
updatedQueryKey;
|
|
786
805
|
constructor(e, t, n) {
|
|
787
806
|
this.client = e, this.requestOptions = t, this.initialRequestConfiguration = n;
|
|
788
|
-
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 =
|
|
807
|
+
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 = Rt.MIN * 5, cache: f = !0, staleTime: p = Rt.MIN * 5, queued: m = !1, offline: h = !0, abortKey: g, cacheKey: _, queryKey: v, deduplicate: y = !1, deduplicateTime: b = null } = {
|
|
789
808
|
...this.client.adapter.unstable_getRequestDefaults?.(t),
|
|
790
809
|
...t
|
|
791
810
|
};
|
|
@@ -895,11 +914,11 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
895
914
|
payload: t?.payload || this.payload,
|
|
896
915
|
params: t?.params || this.params
|
|
897
916
|
}, r = new e(this.client, this.requestOptions, n);
|
|
898
|
-
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 =
|
|
917
|
+
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 = Dt(this.$hooks.__snapshot()), r;
|
|
899
918
|
}
|
|
900
919
|
abort = () => {
|
|
901
920
|
let { requestManager: e } = this.client;
|
|
902
|
-
return e.abortByKey(
|
|
921
|
+
return e.abortByKey(H(this.abortKey, this.scope)), this.clone();
|
|
903
922
|
};
|
|
904
923
|
dehydrate = (e) => {
|
|
905
924
|
let { response: t, override: n = !0 } = e || {};
|
|
@@ -914,7 +933,7 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
914
933
|
cache: !0,
|
|
915
934
|
response: t
|
|
916
935
|
};
|
|
917
|
-
let r = this.client.cache.get(
|
|
936
|
+
let r = this.client.cache.get(H(this.cacheKey, this.scope));
|
|
918
937
|
if (r) return {
|
|
919
938
|
override: n,
|
|
920
939
|
cacheTime: this.cacheTime,
|
|
@@ -936,7 +955,7 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
936
955
|
};
|
|
937
956
|
};
|
|
938
957
|
read() {
|
|
939
|
-
let e = this.client.cache.get(
|
|
958
|
+
let e = this.client.cache.get(H(this.cacheKey, this.scope));
|
|
940
959
|
if (e) return {
|
|
941
960
|
data: e.data,
|
|
942
961
|
error: e.error,
|
|
@@ -948,7 +967,7 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
948
967
|
};
|
|
949
968
|
}
|
|
950
969
|
exec = async (e) => {
|
|
951
|
-
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a =
|
|
970
|
+
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a = H(this.abortKey, this.scope);
|
|
952
971
|
n.addAbortController(a, i);
|
|
953
972
|
let o = await t.fetch(r, i);
|
|
954
973
|
return n.removeAbortController(a, i), r.unstable_responseMapper ? r.unstable_responseMapper(o) : o;
|
|
@@ -958,17 +977,17 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
958
977
|
...e,
|
|
959
978
|
cachePolicy: void 0
|
|
960
979
|
};
|
|
961
|
-
if (n === "network-only") return
|
|
980
|
+
if (n === "network-only") return Lt(i, a);
|
|
962
981
|
let o = i.read();
|
|
963
|
-
if (n === "cache-first") return o ?
|
|
982
|
+
if (n === "cache-first") return o ? It(i, o) : Lt(i, a);
|
|
964
983
|
if (o) {
|
|
965
|
-
let e = await
|
|
966
|
-
return
|
|
984
|
+
let e = await It(i, o);
|
|
985
|
+
return Lt(i, a), e;
|
|
967
986
|
}
|
|
968
|
-
return
|
|
987
|
+
return Lt(i, a);
|
|
969
988
|
};
|
|
970
989
|
static fromJSON = (t, n) => new e(t, n.requestOptions, n);
|
|
971
|
-
},
|
|
990
|
+
}, Bt = async ({ request: e, requestId: t, resolve: n, onStartTime: r, internalErrorMapping: i }) => {
|
|
972
991
|
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;
|
|
973
992
|
c.debug({
|
|
974
993
|
title: "Running middleware callbacks",
|
|
@@ -978,7 +997,7 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
978
997
|
requestId: t
|
|
979
998
|
}
|
|
980
999
|
}), 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));
|
|
981
|
-
let { client: g, abortKey: _ } = d, v =
|
|
1000
|
+
let { client: g, abortKey: _ } = d, v = H(_, d.scope), y = d.payload;
|
|
982
1001
|
d.unstable_payloadMapper ? y = await d.unstable_payloadMapper(d.payload) : s && (y = await s(y));
|
|
983
1002
|
let b = d.options, x = +/* @__PURE__ */ new Date();
|
|
984
1003
|
r(x);
|
|
@@ -987,14 +1006,14 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
987
1006
|
let n = Number(t.total || 0), r = Number(t.loaded || 0);
|
|
988
1007
|
return Math.max(n, r, e);
|
|
989
1008
|
}, T = (e, n, r) => {
|
|
990
|
-
let i =
|
|
1009
|
+
let i = Mt(new Date(e), new Date(n), r);
|
|
991
1010
|
m !== 100 && (m = i.total, a.events.emitUploadProgress({
|
|
992
1011
|
...i,
|
|
993
1012
|
requestId: t,
|
|
994
1013
|
request: d
|
|
995
1014
|
}));
|
|
996
1015
|
}, E = (e, n, r) => {
|
|
997
|
-
let i =
|
|
1016
|
+
let i = Mt(new Date(e), new Date(n), r);
|
|
998
1017
|
h !== 100 && (h = i.total, a.events.emitDownloadProgress({
|
|
999
1018
|
...i,
|
|
1000
1019
|
requestId: t,
|
|
@@ -1026,21 +1045,21 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
1026
1045
|
requestId: t,
|
|
1027
1046
|
request: d
|
|
1028
1047
|
}), l;
|
|
1029
|
-
},
|
|
1048
|
+
}, k = (e) => {
|
|
1030
1049
|
l ||= +/* @__PURE__ */ new Date(), f = w(f, e);
|
|
1031
1050
|
let t = +/* @__PURE__ */ new Date();
|
|
1032
1051
|
return T(l, t, {
|
|
1033
1052
|
total: f,
|
|
1034
1053
|
loaded: e.loaded || 0
|
|
1035
1054
|
}), t;
|
|
1036
|
-
},
|
|
1055
|
+
}, ee = () => {
|
|
1037
1056
|
l ||= +/* @__PURE__ */ new Date();
|
|
1038
1057
|
let e = +/* @__PURE__ */ new Date();
|
|
1039
1058
|
return T(l, e, {
|
|
1040
1059
|
total: f,
|
|
1041
1060
|
loaded: f
|
|
1042
1061
|
}), e;
|
|
1043
|
-
},
|
|
1062
|
+
}, A = (e) => {
|
|
1044
1063
|
u = +/* @__PURE__ */ new Date(), p = w(p, e);
|
|
1045
1064
|
let n = {
|
|
1046
1065
|
total: p,
|
|
@@ -1050,21 +1069,21 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
1050
1069
|
requestId: t,
|
|
1051
1070
|
request: d
|
|
1052
1071
|
}), u;
|
|
1053
|
-
},
|
|
1072
|
+
}, j = (e) => {
|
|
1054
1073
|
u ||= +/* @__PURE__ */ new Date();
|
|
1055
1074
|
let t = +/* @__PURE__ */ new Date();
|
|
1056
1075
|
return p = w(p, e), E(u, t, {
|
|
1057
1076
|
total: e.total || p,
|
|
1058
1077
|
loaded: e.loaded || 0
|
|
1059
1078
|
}), t;
|
|
1060
|
-
},
|
|
1079
|
+
}, te = () => {
|
|
1061
1080
|
u ||= +/* @__PURE__ */ new Date();
|
|
1062
1081
|
let e = +/* @__PURE__ */ new Date();
|
|
1063
1082
|
return E(u, e, {
|
|
1064
1083
|
total: p,
|
|
1065
1084
|
loaded: p
|
|
1066
1085
|
}), e;
|
|
1067
|
-
},
|
|
1086
|
+
}, M = async ({ data: e, error: r, status: i, extra: a }) => {
|
|
1068
1087
|
let o = {
|
|
1069
1088
|
data: e,
|
|
1070
1089
|
error: r ?? null,
|
|
@@ -1089,50 +1108,50 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
1089
1108
|
response: o
|
|
1090
1109
|
}
|
|
1091
1110
|
}), o;
|
|
1092
|
-
},
|
|
1111
|
+
}, N = Vt({
|
|
1093
1112
|
request: d,
|
|
1094
1113
|
requestId: t,
|
|
1095
1114
|
startTime: x,
|
|
1096
1115
|
logger: c,
|
|
1097
1116
|
resolve: n
|
|
1098
|
-
}),
|
|
1117
|
+
}), ne = ({ status: e, extra: n }) => (c.error({
|
|
1099
1118
|
title: "Abort error",
|
|
1100
1119
|
type: "request",
|
|
1101
1120
|
extra: {
|
|
1102
1121
|
request: d,
|
|
1103
1122
|
requestId: t
|
|
1104
1123
|
}
|
|
1105
|
-
}),
|
|
1106
|
-
error: i(
|
|
1124
|
+
}), N({
|
|
1125
|
+
error: i(V("abort")),
|
|
1107
1126
|
status: e,
|
|
1108
1127
|
extra: n
|
|
1109
|
-
})),
|
|
1128
|
+
})), re = ({ status: e, extra: n }) => (c.error({
|
|
1110
1129
|
title: "Timeout error",
|
|
1111
1130
|
type: "request",
|
|
1112
1131
|
extra: {
|
|
1113
1132
|
request: d,
|
|
1114
1133
|
requestId: t
|
|
1115
1134
|
}
|
|
1116
|
-
}),
|
|
1117
|
-
error:
|
|
1135
|
+
}), N({
|
|
1136
|
+
error: V("timeout"),
|
|
1118
1137
|
status: e,
|
|
1119
1138
|
extra: n
|
|
1120
|
-
})),
|
|
1139
|
+
})), P = ({ status: e, extra: n }) => (c.error({
|
|
1121
1140
|
title: "Unexpected error",
|
|
1122
1141
|
type: "request",
|
|
1123
1142
|
extra: {
|
|
1124
1143
|
request: d,
|
|
1125
1144
|
requestId: t
|
|
1126
1145
|
}
|
|
1127
|
-
}),
|
|
1128
|
-
error:
|
|
1146
|
+
}), N({
|
|
1147
|
+
error: V(),
|
|
1129
1148
|
status: e,
|
|
1130
1149
|
extra: n
|
|
1131
|
-
})),
|
|
1132
|
-
let i =
|
|
1133
|
-
if (!i) throw new
|
|
1150
|
+
})), ie = () => a.getAbortController(v, t), F = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1151
|
+
let i = ie();
|
|
1152
|
+
if (!i) throw new xt("Controller is not found");
|
|
1134
1153
|
let o = () => {
|
|
1135
|
-
|
|
1154
|
+
ne({
|
|
1136
1155
|
status: e,
|
|
1137
1156
|
extra: n
|
|
1138
1157
|
}), r(), a.events.emitAbort({
|
|
@@ -1152,36 +1171,36 @@ var yt = /* @__PURE__ */ function(e) {
|
|
|
1152
1171
|
adapterOptions: b
|
|
1153
1172
|
}
|
|
1154
1173
|
});
|
|
1155
|
-
let
|
|
1174
|
+
let ae = e.client.adapter.unstable_queryParamsMapper(d.queryParams), I = e.client.adapter.unstable_endpointMapper(d.endpoint), oe = e.client.adapter.unstable_headerMapper(d), { url: se } = e.client;
|
|
1156
1175
|
return {
|
|
1157
1176
|
request: d,
|
|
1158
1177
|
requestId: t,
|
|
1159
|
-
url:
|
|
1160
|
-
endpoint:
|
|
1161
|
-
queryParams:
|
|
1178
|
+
url: se,
|
|
1179
|
+
endpoint: I,
|
|
1180
|
+
queryParams: ae,
|
|
1162
1181
|
payload: y,
|
|
1163
|
-
headers:
|
|
1182
|
+
headers: oe,
|
|
1164
1183
|
adapter: e.client.adapter,
|
|
1165
1184
|
adapterOptions: b,
|
|
1166
|
-
getAbortController:
|
|
1185
|
+
getAbortController: ie,
|
|
1167
1186
|
getRequestStartTimestamp: S,
|
|
1168
1187
|
getResponseStartTimestamp: C,
|
|
1169
1188
|
createAbortListener: F,
|
|
1170
1189
|
onBeforeRequest: D,
|
|
1171
1190
|
onRequestStart: O,
|
|
1172
|
-
onRequestProgress:
|
|
1173
|
-
onRequestEnd:
|
|
1174
|
-
onResponseStart:
|
|
1175
|
-
onResponseProgress:
|
|
1176
|
-
onResponseEnd:
|
|
1177
|
-
onSuccess:
|
|
1178
|
-
onAbortError:
|
|
1179
|
-
onTimeoutError:
|
|
1180
|
-
onUnexpectedError:
|
|
1181
|
-
onError:
|
|
1191
|
+
onRequestProgress: k,
|
|
1192
|
+
onRequestEnd: ee,
|
|
1193
|
+
onResponseStart: A,
|
|
1194
|
+
onResponseProgress: j,
|
|
1195
|
+
onResponseEnd: te,
|
|
1196
|
+
onSuccess: M,
|
|
1197
|
+
onAbortError: ne,
|
|
1198
|
+
onTimeoutError: re,
|
|
1199
|
+
onUnexpectedError: P,
|
|
1200
|
+
onError: N
|
|
1182
1201
|
};
|
|
1183
1202
|
};
|
|
1184
|
-
function
|
|
1203
|
+
function Vt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
1185
1204
|
let { client: a } = e;
|
|
1186
1205
|
return async ({ error: o, status: s, extra: c }) => {
|
|
1187
1206
|
let l = {
|
|
@@ -1210,8 +1229,8 @@ function Mt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
|
1210
1229
|
}), l;
|
|
1211
1230
|
};
|
|
1212
1231
|
}
|
|
1213
|
-
var
|
|
1214
|
-
if (!e.unstable_mock) throw new
|
|
1232
|
+
var Ht = 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 }) => {
|
|
1233
|
+
if (!e.unstable_mock) throw new xt("Mock should be defined when calling mocker");
|
|
1215
1234
|
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({
|
|
1216
1235
|
request: e,
|
|
1217
1236
|
requestId: t
|
|
@@ -1255,7 +1274,7 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1255
1274
|
status: C,
|
|
1256
1275
|
extra: T
|
|
1257
1276
|
}), h || r();
|
|
1258
|
-
},
|
|
1277
|
+
}, Ut = (e) => e, Wt = class {
|
|
1259
1278
|
unstable_fetcher;
|
|
1260
1279
|
name;
|
|
1261
1280
|
defaultMethod;
|
|
@@ -1277,10 +1296,10 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1277
1296
|
initialize = (e) => (this.logger = e.loggerManager.initialize(e, "Adapter"), this.initialized = !0, this.client = e, this.unstable_onInitializeCallback?.({ client: e }), this);
|
|
1278
1297
|
onInitialize = (e) => (this.unstable_onInitializeCallback = e, this);
|
|
1279
1298
|
unstable_internalErrorMapping = (e) => e;
|
|
1280
|
-
unstable_headerMapper =
|
|
1281
|
-
unstable_payloadMapper =
|
|
1282
|
-
unstable_endpointMapper =
|
|
1283
|
-
unstable_queryParamsMapper =
|
|
1299
|
+
unstable_headerMapper = wt;
|
|
1300
|
+
unstable_payloadMapper = Tt;
|
|
1301
|
+
unstable_endpointMapper = Ut;
|
|
1302
|
+
unstable_queryParamsMapper = Ut;
|
|
1284
1303
|
unstable_getAdapterDefaults;
|
|
1285
1304
|
unstable_getRequestDefaults;
|
|
1286
1305
|
unstable_devtoolsEndpointGetter = (e) => e;
|
|
@@ -1304,14 +1323,14 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1304
1323
|
async fetch(e, t) {
|
|
1305
1324
|
let n, r = async (r) => {
|
|
1306
1325
|
try {
|
|
1307
|
-
if (!this.initialized) throw new
|
|
1308
|
-
if (!this.unstable_fetcher) throw new
|
|
1326
|
+
if (!this.initialized) throw new xt(`Adapter ${this.options.name} is not initialized`);
|
|
1327
|
+
if (!this.unstable_fetcher) throw new xt(`Fetcher for ${this.options.name} adapter is not set`);
|
|
1309
1328
|
this.client.triggerPlugins("onAdapterFetch", {
|
|
1310
1329
|
adapter: this,
|
|
1311
1330
|
request: e,
|
|
1312
1331
|
requestId: t
|
|
1313
1332
|
});
|
|
1314
|
-
let i = await
|
|
1333
|
+
let i = await Bt({
|
|
1315
1334
|
request: e,
|
|
1316
1335
|
requestId: t,
|
|
1317
1336
|
resolve: r,
|
|
@@ -1320,9 +1339,9 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1320
1339
|
n = e;
|
|
1321
1340
|
}
|
|
1322
1341
|
});
|
|
1323
|
-
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await
|
|
1342
|
+
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await Ht(i) : this.unstable_fetcher(i);
|
|
1324
1343
|
} catch (i) {
|
|
1325
|
-
return
|
|
1344
|
+
return Vt({
|
|
1326
1345
|
request: e,
|
|
1327
1346
|
requestId: t,
|
|
1328
1347
|
startTime: n || Date.now(),
|
|
@@ -1339,66 +1358,66 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1339
1358
|
r(e);
|
|
1340
1359
|
});
|
|
1341
1360
|
}
|
|
1342
|
-
},
|
|
1361
|
+
}, Gt = (e) => {
|
|
1343
1362
|
try {
|
|
1344
1363
|
return JSON.parse(e);
|
|
1345
1364
|
} catch {
|
|
1346
1365
|
return e;
|
|
1347
1366
|
}
|
|
1348
|
-
},
|
|
1367
|
+
}, Kt = (e) => e ? Gt(e) : V(), qt = (e) => (t) => {
|
|
1349
1368
|
let { skipNull: n, skipEmptyString: r } = e;
|
|
1350
1369
|
return !(r && t === void 0 || r && t === "" || n && t === null);
|
|
1351
|
-
},
|
|
1352
|
-
let r = !
|
|
1353
|
-
return !e || r ? "" : `${
|
|
1354
|
-
},
|
|
1370
|
+
}, U = (e, { encode: t, strict: n }) => t && n ? encodeURIComponent(e).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`) : t ? encodeURIComponent(e) : e, Jt = (e, t, n) => {
|
|
1371
|
+
let r = !qt(n)(t);
|
|
1372
|
+
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)}`;
|
|
1373
|
+
}, Yt = (e, t, n) => {
|
|
1355
1374
|
let { arrayFormat: r, arraySeparator: i } = n;
|
|
1356
|
-
return t.filter(
|
|
1375
|
+
return t.filter(qt(n)).reduce((t, a, o) => {
|
|
1357
1376
|
switch (r) {
|
|
1358
1377
|
case "index": {
|
|
1359
|
-
let r = `${
|
|
1360
|
-
t.push(`${r}${
|
|
1378
|
+
let r = `${U(e, n)}[${U(String(o), n)}]=`;
|
|
1379
|
+
t.push(`${r}${U(String(a), n)}`);
|
|
1361
1380
|
break;
|
|
1362
1381
|
}
|
|
1363
1382
|
case "bracket": {
|
|
1364
|
-
let r = `${
|
|
1365
|
-
t.push(`${r}${
|
|
1383
|
+
let r = `${U(e, n)}[]=`;
|
|
1384
|
+
t.push(`${r}${U(String(a), n)}`);
|
|
1366
1385
|
break;
|
|
1367
1386
|
}
|
|
1368
1387
|
case "comma": {
|
|
1369
|
-
let r = !t.length && `${
|
|
1370
|
-
return [[...t, `${r}${
|
|
1388
|
+
let r = !t.length && `${U(e, n)}=` || "";
|
|
1389
|
+
return [[...t, `${r}${U(String(a), n)}`].join(",")];
|
|
1371
1390
|
}
|
|
1372
1391
|
case "separator": {
|
|
1373
|
-
let r = !t.length && `${
|
|
1374
|
-
return [[...t, `${r}${
|
|
1392
|
+
let r = !t.length && `${U(e, n)}=` || "";
|
|
1393
|
+
return [[...t, `${r}${U(String(a), n)}`].join(i || "|")];
|
|
1375
1394
|
}
|
|
1376
1395
|
case "bracket-separator": {
|
|
1377
|
-
let r = !t.length && `${
|
|
1378
|
-
return [[...t, `${r}${
|
|
1396
|
+
let r = !t.length && `${U(e, n)}[]=` || "";
|
|
1397
|
+
return [[...t, `${r}${U(String(a), n)}`].join(i || "|")];
|
|
1379
1398
|
}
|
|
1380
1399
|
default: {
|
|
1381
|
-
let r = `${
|
|
1382
|
-
t.push(`${r}${
|
|
1400
|
+
let r = `${U(e, n)}=`;
|
|
1401
|
+
t.push(`${r}${U(String(a), n)}`);
|
|
1383
1402
|
}
|
|
1384
1403
|
}
|
|
1385
1404
|
return t;
|
|
1386
1405
|
}, []).join("&");
|
|
1387
|
-
},
|
|
1406
|
+
}, Xt = (e, t = Tn) => {
|
|
1388
1407
|
if (!e || !Object.keys(e).length) return "";
|
|
1389
1408
|
if (typeof e == "string") return e[0] === "?" ? e : `?${e}`;
|
|
1390
|
-
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ?
|
|
1409
|
+
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ? Yt(e, n, t) : Jt(e, n, t)).filter(Boolean).join("&");
|
|
1391
1410
|
return n ? `?${n}` : "";
|
|
1392
|
-
},
|
|
1411
|
+
}, Zt = Rt.SEC * 5, W = { headers: {} }, Qt = () => new Wt({
|
|
1393
1412
|
name: "http",
|
|
1394
|
-
defaultMethod:
|
|
1395
|
-
defaultExtra:
|
|
1413
|
+
defaultMethod: Ot.GET,
|
|
1414
|
+
defaultExtra: W,
|
|
1396
1415
|
systemErrorStatus: 0,
|
|
1397
|
-
systemErrorExtra:
|
|
1398
|
-
}).setQueryParamsMapper(
|
|
1399
|
-
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ?
|
|
1416
|
+
systemErrorExtra: W
|
|
1417
|
+
}).setQueryParamsMapper(Xt).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 }) => {
|
|
1418
|
+
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ? Xt(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = Zt, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
|
|
1400
1419
|
status: 0,
|
|
1401
|
-
extra:
|
|
1420
|
+
extra: W
|
|
1402
1421
|
});
|
|
1403
1422
|
C > 0 && S && (D = setTimeout(() => {
|
|
1404
1423
|
E = !0, O(), S.abort();
|
|
@@ -1430,7 +1449,7 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1430
1449
|
status: l,
|
|
1431
1450
|
extra: c
|
|
1432
1451
|
}) : i({
|
|
1433
|
-
error:
|
|
1452
|
+
error: Kt(await t.text()),
|
|
1434
1453
|
status: l,
|
|
1435
1454
|
extra: c
|
|
1436
1455
|
});
|
|
@@ -1451,11 +1470,11 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1451
1470
|
e = new TextDecoder().decode(o);
|
|
1452
1471
|
} else e = await t.text();
|
|
1453
1472
|
a(), O(), t.ok ? h({
|
|
1454
|
-
data:
|
|
1473
|
+
data: Gt(e),
|
|
1455
1474
|
status: l,
|
|
1456
1475
|
extra: c
|
|
1457
1476
|
}) : i({
|
|
1458
|
-
error:
|
|
1477
|
+
error: Kt(e),
|
|
1459
1478
|
status: l,
|
|
1460
1479
|
extra: c
|
|
1461
1480
|
});
|
|
@@ -1464,18 +1483,18 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1464
1483
|
if (D && clearTimeout(D), O(), S?.signal?.aborted) {
|
|
1465
1484
|
E && o({
|
|
1466
1485
|
status: 0,
|
|
1467
|
-
extra:
|
|
1486
|
+
extra: W
|
|
1468
1487
|
});
|
|
1469
1488
|
return;
|
|
1470
1489
|
}
|
|
1471
1490
|
i({
|
|
1472
1491
|
error: e,
|
|
1473
1492
|
status: 0,
|
|
1474
|
-
extra:
|
|
1493
|
+
extra: W
|
|
1475
1494
|
});
|
|
1476
1495
|
}
|
|
1477
|
-
}),
|
|
1478
|
-
emitter = new
|
|
1496
|
+
}), $t = () => Qt(), en = class {
|
|
1497
|
+
emitter = new Ee();
|
|
1479
1498
|
events;
|
|
1480
1499
|
storage;
|
|
1481
1500
|
lazyStorage;
|
|
@@ -1486,7 +1505,7 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1486
1505
|
constructor(e) {
|
|
1487
1506
|
this.options = e;
|
|
1488
1507
|
let { storage: t = /* @__PURE__ */ new Map(), lazyStorage: n, version: r = "0.0.1" } = e ?? {};
|
|
1489
|
-
this.emitter?.setMaxListeners(1e3), this.events =
|
|
1508
|
+
this.emitter?.setMaxListeners(1e3), this.events = ln(this.emitter), this.storage = t, this.version = r, this.lazyStorage = n;
|
|
1490
1509
|
}
|
|
1491
1510
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Cache"), e.appManager.events.onOnline(() => {
|
|
1492
1511
|
[...this.storage.keys()].forEach(this.scheduleGarbageCollector);
|
|
@@ -1500,7 +1519,7 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1500
1519
|
response: t
|
|
1501
1520
|
}
|
|
1502
1521
|
});
|
|
1503
|
-
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s =
|
|
1522
|
+
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 = tn(c, l), d = {
|
|
1504
1523
|
...u,
|
|
1505
1524
|
scope: o,
|
|
1506
1525
|
staleTime: i,
|
|
@@ -1546,7 +1565,7 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1546
1565
|
partialResponse: t
|
|
1547
1566
|
}
|
|
1548
1567
|
});
|
|
1549
|
-
let { cacheKey: n, scope: r } = e, i =
|
|
1568
|
+
let { cacheKey: n, scope: r } = e, i = H(n, r), a = this.storage.get(i), o = typeof t == "function" ? t(a || null) : t;
|
|
1550
1569
|
a && this.set(e, {
|
|
1551
1570
|
...a,
|
|
1552
1571
|
...o
|
|
@@ -1584,7 +1603,7 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1584
1603
|
cacheKey: t
|
|
1585
1604
|
}), this.events.emitInvalidation(t);
|
|
1586
1605
|
};
|
|
1587
|
-
e instanceof
|
|
1606
|
+
e instanceof zt ? n(H(e.cacheKey, e.scope), e.cacheKey) : typeof e == "string" ? n(e) : t.length && t.forEach((t) => {
|
|
1588
1607
|
e.test(t) && n(t);
|
|
1589
1608
|
});
|
|
1590
1609
|
};
|
|
@@ -1639,49 +1658,49 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1639
1658
|
clear = async () => {
|
|
1640
1659
|
this.garbageCollectors.forEach((e) => clearTimeout(e)), this.storage.clear();
|
|
1641
1660
|
};
|
|
1642
|
-
},
|
|
1661
|
+
}, tn = (e, t) => {
|
|
1643
1662
|
let { data: n, success: r } = t, i = !r && e ? e.data : null, a = n || i;
|
|
1644
1663
|
return {
|
|
1645
1664
|
...t,
|
|
1646
1665
|
data: a
|
|
1647
1666
|
};
|
|
1648
|
-
},
|
|
1667
|
+
}, nn = () => "invalidate", rn = (e) => `${e}_invalidate`, an = () => "delete", on = (e) => `${e}_delete`, sn = (e) => `${e}_cache`, cn = () => "cache", ln = (e) => ({
|
|
1649
1668
|
emitCacheData: (t, n = !1) => {
|
|
1650
|
-
e.emit(
|
|
1669
|
+
e.emit(cn(), t, n), e.emit(sn(t.cacheKey), t, n);
|
|
1651
1670
|
},
|
|
1652
1671
|
emitInvalidation: (t, n = !1) => {
|
|
1653
|
-
e.emit(
|
|
1672
|
+
e.emit(nn(), t, n), e.emit(rn(t), n);
|
|
1654
1673
|
},
|
|
1655
1674
|
emitDelete: (t, n = !1) => {
|
|
1656
|
-
e.emit(
|
|
1675
|
+
e.emit(an(), t, n), e.emit(on(t), n);
|
|
1657
1676
|
},
|
|
1658
|
-
onData: (t) => (e.on(
|
|
1659
|
-
onDataByKey: (t, n) => (e.on(
|
|
1660
|
-
onInvalidate: (t) => (e.on(
|
|
1661
|
-
onInvalidateByKey: (t, n) => (e.on(
|
|
1662
|
-
onDelete: (t) => (e.on(
|
|
1663
|
-
onDeleteByKey: (t, n) => (e.on(
|
|
1664
|
-
}),
|
|
1677
|
+
onData: (t) => (e.on(cn(), t), () => e.removeListener(cn(), t)),
|
|
1678
|
+
onDataByKey: (t, n) => (e.on(sn(t), n), () => e.removeListener(sn(t), n)),
|
|
1679
|
+
onInvalidate: (t) => (e.on(nn(), t), () => e.removeListener(nn(), t)),
|
|
1680
|
+
onInvalidateByKey: (t, n) => (e.on(rn(t), n), () => e.removeListener(rn(t), n)),
|
|
1681
|
+
onDelete: (t) => (e.on(an(), t), () => e.removeListener(an(), t)),
|
|
1682
|
+
onDeleteByKey: (t, n) => (e.on(on(t), n), () => e.removeListener(on(t), n))
|
|
1683
|
+
}), G = /* @__PURE__ */ function(e) {
|
|
1665
1684
|
return e.ONE_BY_ONE = "one-by-one", e.ALL_AT_ONCE = "all-at-once", e.PREVIOUS_CANCELED = "previous-canceled", e.DEDUPLICATED = "deduplicated", e;
|
|
1666
|
-
}({}),
|
|
1685
|
+
}({}), un = (e) => ({
|
|
1667
1686
|
emitDrained: (t, n) => {
|
|
1668
|
-
e.emit(
|
|
1687
|
+
e.emit(fn(), t, n), e.emit(pn(t.queryKey), t, n);
|
|
1669
1688
|
},
|
|
1670
1689
|
emitQueueStatusChanged: (t, n) => {
|
|
1671
|
-
e.emit(
|
|
1690
|
+
e.emit(mn(), t, n), e.emit(hn(t.queryKey), t, n);
|
|
1672
1691
|
},
|
|
1673
1692
|
emitQueueChanged: (t, n) => {
|
|
1674
|
-
e.emit(
|
|
1693
|
+
e.emit(gn(), t, n), e.emit(_n(t.queryKey), t, n);
|
|
1675
1694
|
},
|
|
1676
|
-
onDrained: (t) => (e.on(
|
|
1677
|
-
onDrainedByKey: (t, n) => (e.on(
|
|
1678
|
-
onQueueStatusChange: (t) => (e.on(
|
|
1679
|
-
onQueueStatusChangeByKey: (t, n) => (e.on(
|
|
1680
|
-
onQueueChange: (t) => (e.on(
|
|
1681
|
-
onQueueChangeByKey: (t, n) => (e.on(
|
|
1682
|
-
}),
|
|
1683
|
-
emitter = new
|
|
1684
|
-
events =
|
|
1695
|
+
onDrained: (t) => (e.on(fn(), t), () => e.removeListener(fn(), t)),
|
|
1696
|
+
onDrainedByKey: (t, n) => (e.on(pn(t), n), () => e.removeListener(pn(t), n)),
|
|
1697
|
+
onQueueStatusChange: (t) => (e.on(mn(), t), () => e.removeListener(mn(), t)),
|
|
1698
|
+
onQueueStatusChangeByKey: (t, n) => (e.on(hn(t), n), () => e.removeListener(hn(t), n)),
|
|
1699
|
+
onQueueChange: (t) => (e.on(gn(), t), () => e.removeListener(gn(), t)),
|
|
1700
|
+
onQueueChangeByKey: (t, n) => (e.on(_n(t), n), () => e.removeListener(_n(t), n))
|
|
1701
|
+
}), dn = class {
|
|
1702
|
+
emitter = new Ee();
|
|
1703
|
+
events = un(this.emitter);
|
|
1685
1704
|
storage = /* @__PURE__ */ new Map();
|
|
1686
1705
|
requestCount = /* @__PURE__ */ new Map();
|
|
1687
1706
|
runningRequests = /* @__PURE__ */ new Map();
|
|
@@ -1690,7 +1709,7 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1690
1709
|
constructor(e) {
|
|
1691
1710
|
this.options = e, this.emitter?.setMaxListeners(1e3), this.options?.storage && (this.storage = this.options.storage);
|
|
1692
1711
|
}
|
|
1693
|
-
isRequestJSON = (e) => !(e instanceof
|
|
1712
|
+
isRequestJSON = (e) => !(e instanceof zt);
|
|
1694
1713
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Dispatcher"), this.client.appManager.events.onOnline(() => {
|
|
1695
1714
|
this.flush();
|
|
1696
1715
|
}), this);
|
|
@@ -1814,14 +1833,14 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1814
1833
|
hasRunningRequest = (e, t) => !!this.getRunningRequests(e).find((e) => e.requestId === t);
|
|
1815
1834
|
cancelRunningRequests = (e) => {
|
|
1816
1835
|
this.runningRequests.get(e)?.forEach((e) => {
|
|
1817
|
-
let t =
|
|
1836
|
+
let t = H(e.request.abortKey, e.request.scope);
|
|
1818
1837
|
this.client.requestManager.abortByRequestId(t, e.requestId);
|
|
1819
1838
|
}), this.deleteRunningRequests(e);
|
|
1820
1839
|
};
|
|
1821
1840
|
cancelRunningRequest = (e, t) => {
|
|
1822
1841
|
let n = this.getRunningRequests(e).filter((e) => {
|
|
1823
1842
|
if (e.requestId === t) {
|
|
1824
|
-
let t =
|
|
1843
|
+
let t = H(e.request.abortKey, e.request.scope);
|
|
1825
1844
|
return this.client.requestManager.abortByRequestId(t, e.requestId), !1;
|
|
1826
1845
|
}
|
|
1827
1846
|
return !0;
|
|
@@ -1849,7 +1868,7 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1849
1868
|
resolved: !1
|
|
1850
1869
|
});
|
|
1851
1870
|
add = (e) => {
|
|
1852
|
-
let t =
|
|
1871
|
+
let t = H(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = bn(e, i);
|
|
1853
1872
|
switch (this.logger.debug({
|
|
1854
1873
|
title: "Adding request to queue",
|
|
1855
1874
|
type: "system",
|
|
@@ -1859,9 +1878,9 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1859
1878
|
requestId: r
|
|
1860
1879
|
}
|
|
1861
1880
|
}), a) {
|
|
1862
|
-
case
|
|
1863
|
-
case
|
|
1864
|
-
case
|
|
1881
|
+
case G.ONE_BY_ONE: return this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1882
|
+
case G.PREVIOUS_CANCELED: return this.cancelRunningRequests(t), this.clearQueue(t), this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1883
|
+
case G.DEDUPLICATED: return this.client.requestManager.events.emitDeduplicated({
|
|
1865
1884
|
request: i.request,
|
|
1866
1885
|
requestId: r,
|
|
1867
1886
|
deduplicatedRequest: e
|
|
@@ -1903,7 +1922,7 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1903
1922
|
requestId: n
|
|
1904
1923
|
}
|
|
1905
1924
|
});
|
|
1906
|
-
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l =
|
|
1925
|
+
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 = vn(e.retries, r), g = !m.isOnline && s, _ = this.hasRunningRequest(l, n), v = e.stopped;
|
|
1907
1926
|
if (g || _ || v) return this.logger.warning({
|
|
1908
1927
|
title: "Unable to perform request",
|
|
1909
1928
|
type: "system",
|
|
@@ -1923,7 +1942,7 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1923
1942
|
}), this.incrementQueueRequestCount(l), f.addAbortController(u, n);
|
|
1924
1943
|
let b = await d.fetch(t, n);
|
|
1925
1944
|
e.resolved = !0, f.removeAbortController(u, n);
|
|
1926
|
-
let x = !m.isOnline, S =
|
|
1945
|
+
let x = !m.isOnline, S = V("abort").message === b.error?.message, C = !this.hasRunningRequest(l, n) || S;
|
|
1927
1946
|
this.deleteRunningRequest(l, n);
|
|
1928
1947
|
let w = b.success || !h || !t.retryOnError || t.retryOnError(b), T = !b.success && h && w && !C && !x, E = {
|
|
1929
1948
|
isCanceled: C,
|
|
@@ -2037,26 +2056,26 @@ var Nt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
2037
2056
|
}
|
|
2038
2057
|
}), this.delete(l, n, u));
|
|
2039
2058
|
};
|
|
2040
|
-
},
|
|
2041
|
-
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ?
|
|
2042
|
-
return n ?
|
|
2059
|
+
}, fn = () => "drained-event", pn = (e) => `${e}-drained-event`, mn = () => "status-event", hn = (e) => `${e}-status-event`, gn = () => "change-event", _n = (e) => `${e}-change-event`, vn = (e, t) => !!(t && e < t), yn = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, bn = (e, t) => {
|
|
2060
|
+
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? yn(e, t) : !1;
|
|
2061
|
+
return n ? G.ONE_BY_ONE : r ? G.PREVIOUS_CANCELED : a && i ? G.DEDUPLICATED : G.ALL_AT_ONCE;
|
|
2043
2062
|
};
|
|
2044
|
-
function
|
|
2063
|
+
function xn(e) {
|
|
2045
2064
|
return e === "client" || e === "server" ? e : typeof window < "u" && typeof document < "u" ? "client" : "server";
|
|
2046
2065
|
}
|
|
2047
|
-
var
|
|
2066
|
+
var Sn = async (e, t) => {
|
|
2048
2067
|
let n = t;
|
|
2049
2068
|
if (!t.requestOptions.disableRequestInterceptors) {
|
|
2050
2069
|
for (let r of e) if (n = await r(t), !n) throw Error("Request modifier must return request");
|
|
2051
2070
|
}
|
|
2052
2071
|
return n;
|
|
2053
|
-
},
|
|
2072
|
+
}, Cn = async (e, t, n) => {
|
|
2054
2073
|
let r = t;
|
|
2055
2074
|
if (!n.requestOptions.disableResponseInterceptors) {
|
|
2056
2075
|
for (let i of e) if (r = await i(t, n), !r) throw Error("Response modifier must return data");
|
|
2057
2076
|
}
|
|
2058
2077
|
return r;
|
|
2059
|
-
},
|
|
2078
|
+
}, wn = class {
|
|
2060
2079
|
url;
|
|
2061
2080
|
mode;
|
|
2062
2081
|
debug;
|
|
@@ -2065,8 +2084,8 @@ var pn = async (e, t) => {
|
|
|
2065
2084
|
unstable_onResponseCallbacks = [];
|
|
2066
2085
|
unstable_onAuthCallbacks = [];
|
|
2067
2086
|
unstable_onRequestCallbacks = [];
|
|
2068
|
-
loggerManager = new
|
|
2069
|
-
requestManager = new
|
|
2087
|
+
loggerManager = new ut();
|
|
2088
|
+
requestManager = new Ne();
|
|
2070
2089
|
appManager;
|
|
2071
2090
|
adapter;
|
|
2072
2091
|
cache;
|
|
@@ -2074,15 +2093,15 @@ var pn = async (e, t) => {
|
|
|
2074
2093
|
submitDispatcher;
|
|
2075
2094
|
isMockerEnabled = !0;
|
|
2076
2095
|
plugins = [];
|
|
2077
|
-
unstable_abortKeyMapper =
|
|
2078
|
-
unstable_cacheKeyMapper =
|
|
2079
|
-
unstable_queryKeyMapper =
|
|
2080
|
-
unstable_requestIdMapper =
|
|
2096
|
+
unstable_abortKeyMapper = Nt;
|
|
2097
|
+
unstable_cacheKeyMapper = Pt;
|
|
2098
|
+
unstable_queryKeyMapper = Pt;
|
|
2099
|
+
unstable_requestIdMapper = Ce;
|
|
2081
2100
|
logger = this.loggerManager.initialize(this, "Client");
|
|
2082
2101
|
constructor(e) {
|
|
2083
2102
|
this.options = e;
|
|
2084
2103
|
let { url: t, appManager: n, cache: r, fetchDispatcher: i, submitDispatcher: a, mode: o } = this.options;
|
|
2085
|
-
this.url = t, this.mode =
|
|
2104
|
+
this.url = t, this.mode = xn(o), this.adapter = $t(), this.appManager = n?.() || new De(), this.cache = r?.() || new en(), this.fetchDispatcher = i?.() || new dn(), this.submitDispatcher = a?.() || new dn(), this.adapter.initialize(this), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2086
2105
|
}
|
|
2087
2106
|
setDebug = (e) => (this.debug = e, this);
|
|
2088
2107
|
setLogLevel = (e) => (this.loggerManager.setSeverity(e), this);
|
|
@@ -2111,15 +2130,15 @@ var pn = async (e, t) => {
|
|
|
2111
2130
|
setCacheKeyMapper = (e) => (this.unstable_cacheKeyMapper = e, this);
|
|
2112
2131
|
setQueryKeyMapper = (e) => (this.unstable_queryKeyMapper = e, this);
|
|
2113
2132
|
setRequestIdMapper = (e) => (this.unstable_requestIdMapper = e, this);
|
|
2114
|
-
unstable_modifyAuth = async (e) =>
|
|
2115
|
-
unstable_modifyRequest = async (e) =>
|
|
2116
|
-
unstable_modifyErrorResponse = async (e, t) =>
|
|
2117
|
-
unstable_modifySuccessResponse = async (e, t) =>
|
|
2118
|
-
unstable_modifyResponse = async (e, t) =>
|
|
2119
|
-
fromJSON = (e) =>
|
|
2133
|
+
unstable_modifyAuth = async (e) => Sn(this.unstable_onAuthCallbacks, e);
|
|
2134
|
+
unstable_modifyRequest = async (e) => Sn(this.unstable_onRequestCallbacks, e);
|
|
2135
|
+
unstable_modifyErrorResponse = async (e, t) => Cn(this.unstable_onErrorCallbacks, e, t);
|
|
2136
|
+
unstable_modifySuccessResponse = async (e, t) => Cn(this.unstable_onSuccessCallbacks, e, t);
|
|
2137
|
+
unstable_modifyResponse = async (e, t) => Cn(this.unstable_onResponseCallbacks, e, t);
|
|
2138
|
+
fromJSON = (e) => zt.fromJSON(this, e);
|
|
2120
2139
|
clear = () => {
|
|
2121
2140
|
let { appManager: e, cache: t, fetchDispatcher: n, submitDispatcher: r } = this.options;
|
|
2122
|
-
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
|
|
2141
|
+
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 en(), this.appManager = e?.() || new De(), this.fetchDispatcher = n?.() || new dn(), this.submitDispatcher = r?.() || new dn(), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2123
2142
|
};
|
|
2124
2143
|
hydrate = (e, t) => {
|
|
2125
2144
|
e?.forEach((e) => {
|
|
@@ -2136,8 +2155,8 @@ var pn = async (e, t) => {
|
|
|
2136
2155
|
...a,
|
|
2137
2156
|
...t
|
|
2138
2157
|
};
|
|
2139
|
-
if (!s.override && this.cache.get(
|
|
2140
|
-
let c =
|
|
2158
|
+
if (!s.override && this.cache.get(H(n, r))) return;
|
|
2159
|
+
let c = Gt(i);
|
|
2141
2160
|
this.cache.set({
|
|
2142
2161
|
...s,
|
|
2143
2162
|
cacheKey: n,
|
|
@@ -2149,10 +2168,10 @@ var pn = async (e, t) => {
|
|
|
2149
2168
|
let t = this.adapter.unstable_endpointMapper(e.endpoint), n = {
|
|
2150
2169
|
...e,
|
|
2151
2170
|
endpoint: String(t)
|
|
2152
|
-
}, r = new
|
|
2171
|
+
}, r = new zt(this, n);
|
|
2153
2172
|
return this.plugins.forEach((e) => e.trigger("onRequestCreate", { request: r })), r;
|
|
2154
2173
|
};
|
|
2155
|
-
},
|
|
2174
|
+
}, Tn = {
|
|
2156
2175
|
strict: !0,
|
|
2157
2176
|
encode: !0,
|
|
2158
2177
|
arrayFormat: "bracket",
|
|
@@ -2161,111 +2180,103 @@ var pn = async (e, t) => {
|
|
|
2161
2180
|
skipNull: !0,
|
|
2162
2181
|
skipEmptyString: !0
|
|
2163
2182
|
};
|
|
2164
|
-
function
|
|
2165
|
-
return new
|
|
2183
|
+
function En(e) {
|
|
2184
|
+
return new wn(e);
|
|
2166
2185
|
}
|
|
2167
2186
|
//#endregion
|
|
2168
2187
|
//#region src/core/client.ts
|
|
2169
|
-
var
|
|
2170
|
-
//#endregion
|
|
2171
|
-
//#region src/core/license.ts
|
|
2172
|
-
function vn(e) {
|
|
2173
|
-
return `${q.url}/packs/${e}/checkout`;
|
|
2174
|
-
}
|
|
2188
|
+
var K = En({ url: M() });
|
|
2175
2189
|
//#endregion
|
|
2176
2190
|
//#region src/core/auth-api.ts
|
|
2177
|
-
|
|
2178
|
-
t
|
|
2179
|
-
})))(), 1);
|
|
2180
|
-
async function bn(e) {
|
|
2181
|
-
let { data: t, success: n } = await q.createRequest()({
|
|
2191
|
+
async function Dn(e) {
|
|
2192
|
+
let { data: t, success: n } = await K.createRequest()({
|
|
2182
2193
|
endpoint: "/auth/cli/whoami",
|
|
2183
2194
|
method: "GET"
|
|
2184
2195
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2185
2196
|
return !n || !t ? null : t;
|
|
2186
2197
|
}
|
|
2187
|
-
async function
|
|
2188
|
-
await
|
|
2198
|
+
async function On(e) {
|
|
2199
|
+
await K.createRequest()({
|
|
2189
2200
|
endpoint: "/auth/cli/token",
|
|
2190
2201
|
method: "DELETE"
|
|
2191
2202
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2192
2203
|
}
|
|
2193
2204
|
//#endregion
|
|
2194
2205
|
//#region src/core/auth-store.ts
|
|
2195
|
-
var
|
|
2196
|
-
function
|
|
2206
|
+
var kn = 1, An = "hype-stack", jn = "auth.json";
|
|
2207
|
+
function Mn() {
|
|
2197
2208
|
let e = process.env.HYPE_STACK_CONFIG_DIR;
|
|
2198
|
-
if (e) return
|
|
2199
|
-
let t =
|
|
2209
|
+
if (e) return l.join(e, An);
|
|
2210
|
+
let t = c.homedir();
|
|
2200
2211
|
if (process.platform === "win32") {
|
|
2201
|
-
let e = process.env.APPDATA ??
|
|
2202
|
-
return
|
|
2212
|
+
let e = process.env.APPDATA ?? l.join(t, "AppData", "Roaming");
|
|
2213
|
+
return l.join(e, An);
|
|
2203
2214
|
}
|
|
2204
|
-
if (process.platform === "darwin") return
|
|
2205
|
-
let n = process.env.XDG_CONFIG_HOME ??
|
|
2206
|
-
return
|
|
2215
|
+
if (process.platform === "darwin") return l.join(t, "Library", "Application Support", An);
|
|
2216
|
+
let n = process.env.XDG_CONFIG_HOME ?? l.join(t, ".config");
|
|
2217
|
+
return l.join(n, An);
|
|
2207
2218
|
}
|
|
2208
|
-
function
|
|
2209
|
-
return
|
|
2219
|
+
function Nn() {
|
|
2220
|
+
return l.join(Mn(), jn);
|
|
2210
2221
|
}
|
|
2211
|
-
async function
|
|
2212
|
-
let e = await
|
|
2222
|
+
async function Pn() {
|
|
2223
|
+
let e = await o.readFile(Nn(), "utf-8").catch(() => null);
|
|
2213
2224
|
if (!e) return {
|
|
2214
|
-
version:
|
|
2225
|
+
version: kn,
|
|
2215
2226
|
tokens: {}
|
|
2216
2227
|
};
|
|
2217
2228
|
let t = JSON.parse(e);
|
|
2218
2229
|
return {
|
|
2219
|
-
version: t.version ??
|
|
2230
|
+
version: t.version ?? kn,
|
|
2220
2231
|
tokens: t.tokens ?? {}
|
|
2221
2232
|
};
|
|
2222
2233
|
}
|
|
2223
|
-
async function
|
|
2224
|
-
let t =
|
|
2225
|
-
await
|
|
2234
|
+
async function Fn(e) {
|
|
2235
|
+
let t = Mn();
|
|
2236
|
+
await o.mkdir(t, { recursive: !0 }), await o.writeFile(Nn(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2226
2237
|
}
|
|
2227
|
-
async function
|
|
2228
|
-
return (await
|
|
2238
|
+
async function In(e) {
|
|
2239
|
+
return (await Pn()).tokens[e] ?? null;
|
|
2229
2240
|
}
|
|
2230
|
-
async function
|
|
2231
|
-
let n = await
|
|
2232
|
-
n.tokens[e] = t, await
|
|
2241
|
+
async function Ln(e, t) {
|
|
2242
|
+
let n = await Pn();
|
|
2243
|
+
n.tokens[e] = t, await Fn(n);
|
|
2233
2244
|
}
|
|
2234
|
-
async function
|
|
2235
|
-
let t = await
|
|
2236
|
-
e in t.tokens && (delete t.tokens[e], await
|
|
2245
|
+
async function Rn(e) {
|
|
2246
|
+
let t = await Pn();
|
|
2247
|
+
e in t.tokens && (delete t.tokens[e], await Fn(t));
|
|
2237
2248
|
}
|
|
2238
2249
|
//#endregion
|
|
2239
2250
|
//#region src/core/device.ts
|
|
2240
|
-
function
|
|
2241
|
-
let e =
|
|
2251
|
+
function zn() {
|
|
2252
|
+
let e = c.networkInterfaces();
|
|
2242
2253
|
for (let t of Object.values(e)) if (t) {
|
|
2243
2254
|
for (let e of t) if (!e.internal && e.mac !== "00:00:00:00:00:00") return e.mac;
|
|
2244
2255
|
}
|
|
2245
2256
|
return "unknown";
|
|
2246
2257
|
}
|
|
2247
|
-
function
|
|
2248
|
-
let e = `${
|
|
2249
|
-
return (0,
|
|
2258
|
+
function Bn() {
|
|
2259
|
+
let e = `${zn()}:${c.hostname()}:${c.platform()}:${c.arch()}`;
|
|
2260
|
+
return (0, pe.createHash)("sha256").update(e).digest("hex").slice(0, 16);
|
|
2250
2261
|
}
|
|
2251
|
-
function
|
|
2252
|
-
return `hype-stack/${
|
|
2262
|
+
function Vn() {
|
|
2263
|
+
return `hype-stack/${S} ${c.platform()} ${c.arch()} node/${process.version.slice(1)}`;
|
|
2253
2264
|
}
|
|
2254
2265
|
//#endregion
|
|
2255
2266
|
//#region src/core/open-browser.ts
|
|
2256
|
-
function
|
|
2257
|
-
|
|
2267
|
+
function Hn(e) {
|
|
2268
|
+
u(process.platform === "darwin" ? `open "${e}"` : process.platform === "win32" ? `start "" "${e}"` : `xdg-open "${e}"`);
|
|
2258
2269
|
}
|
|
2259
2270
|
//#endregion
|
|
2260
2271
|
//#region src/core/login.ts
|
|
2261
|
-
var
|
|
2262
|
-
async function
|
|
2263
|
-
let t = (0,
|
|
2272
|
+
var Un = 300 * 1e3, Wn = (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>`;
|
|
2273
|
+
async function Gn(e = {}) {
|
|
2274
|
+
let t = (0, pe.randomBytes)(16).toString("hex"), n = M(), r = pe.default.createServer(), i = await new Promise((n, i) => {
|
|
2264
2275
|
let a = setTimeout(() => {
|
|
2265
2276
|
o(), i(/* @__PURE__ */ Error("Login timed out. Run `hype-stack login` again."));
|
|
2266
|
-
},
|
|
2277
|
+
}, Un);
|
|
2267
2278
|
function o() {
|
|
2268
|
-
clearTimeout(a), r.close();
|
|
2279
|
+
clearTimeout(a), r.close(), r.closeAllConnections?.();
|
|
2269
2280
|
}
|
|
2270
2281
|
r.on("request", (e, r) => {
|
|
2271
2282
|
let a = new URL(e.url ?? "/", "http://127.0.0.1");
|
|
@@ -2274,7 +2285,10 @@ async function Rn(e = {}) {
|
|
|
2274
2285
|
return;
|
|
2275
2286
|
}
|
|
2276
2287
|
let s = (e) => {
|
|
2277
|
-
r.writeHead(200, {
|
|
2288
|
+
r.writeHead(200, {
|
|
2289
|
+
"Content-Type": "text/html",
|
|
2290
|
+
Connection: "close"
|
|
2291
|
+
}), r.end(Wn(e));
|
|
2278
2292
|
};
|
|
2279
2293
|
if (a.searchParams.get("state") !== t) {
|
|
2280
2294
|
s("Login failed."), o(), i(/* @__PURE__ */ Error("Login failed: state mismatch. Run `hype-stack login` again."));
|
|
@@ -2289,62 +2303,62 @@ async function Rn(e = {}) {
|
|
|
2289
2303
|
}), r.on("error", (e) => {
|
|
2290
2304
|
o(), i(e);
|
|
2291
2305
|
}), r.listen(0, "127.0.0.1", () => {
|
|
2292
|
-
let { port: n } = r.address(), i = encodeURIComponent(
|
|
2293
|
-
e.onUrl?.(a),
|
|
2306
|
+
let { port: n } = r.address(), i = encodeURIComponent(Vn()), a = `${N()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
|
|
2307
|
+
e.onUrl?.(a), Hn(a);
|
|
2294
2308
|
});
|
|
2295
|
-
}), a = await
|
|
2309
|
+
}), a = await Dn(i).catch(() => null), o = {
|
|
2296
2310
|
token: i,
|
|
2297
2311
|
email: a?.email,
|
|
2298
2312
|
organizationId: a?.organizationId
|
|
2299
2313
|
};
|
|
2300
|
-
return await
|
|
2314
|
+
return await Ln(n, o), o;
|
|
2301
2315
|
}
|
|
2302
2316
|
//#endregion
|
|
2303
2317
|
//#region src/core/access-prompts.ts
|
|
2304
|
-
async function
|
|
2305
|
-
let e = await
|
|
2306
|
-
if (
|
|
2307
|
-
|
|
2318
|
+
async function Kn() {
|
|
2319
|
+
let e = await a.confirm({ message: "Log in to install packs your organization owns? (opens your browser)" });
|
|
2320
|
+
if (a.isCancel(e) || !e) return null;
|
|
2321
|
+
a.log.step("Opening your browser to sign in...");
|
|
2308
2322
|
try {
|
|
2309
|
-
let e = await
|
|
2310
|
-
|
|
2323
|
+
let e = await Gn({ onUrl: (e) => {
|
|
2324
|
+
a.log.info(`If your browser didn't open, visit:\n ${L.path(e)}`);
|
|
2311
2325
|
} });
|
|
2312
|
-
return
|
|
2326
|
+
return a.log.success(e.email ? `Logged in as ${e.email}` : "Logged in"), e.token;
|
|
2313
2327
|
} catch (e) {
|
|
2314
|
-
return
|
|
2328
|
+
return a.log.error(e instanceof Error ? e.message : String(e)), null;
|
|
2315
2329
|
}
|
|
2316
2330
|
}
|
|
2317
|
-
async function
|
|
2331
|
+
async function qn(e) {
|
|
2318
2332
|
if (e.length === 0) return;
|
|
2319
|
-
|
|
2333
|
+
a.note([
|
|
2320
2334
|
"These packs need a purchase before they can be installed:",
|
|
2321
2335
|
"",
|
|
2322
|
-
...e.map((e) => ` ${
|
|
2336
|
+
...e.map((e) => ` ${L.brand(e.displayName)} ${L.highlight(`$${e.price}`)}`)
|
|
2323
2337
|
].join("\n"), "Locked Packs");
|
|
2324
|
-
let
|
|
2325
|
-
if (
|
|
2326
|
-
|
|
2338
|
+
let t = await a.confirm({ message: `Open the purchase ${e.length === 1 ? "page" : "pages"} in your browser?` });
|
|
2339
|
+
if (a.isCancel(t) || !t) {
|
|
2340
|
+
a.log.info(L.muted("Run 'hype-stack login' after purchasing, then 'hype-stack compose' again."));
|
|
2327
2341
|
return;
|
|
2328
2342
|
}
|
|
2329
|
-
for (let t of e)
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
` ${
|
|
2333
|
-
` ${
|
|
2343
|
+
for (let t of e) Hn(fe(t.name));
|
|
2344
|
+
a.log.info([
|
|
2345
|
+
L.muted("After purchasing, run:"),
|
|
2346
|
+
` ${L.highlight("hype-stack login")} ${L.muted("Save your access")}`,
|
|
2347
|
+
` ${L.highlight("hype-stack compose")} ${L.muted("Install the packs")}`
|
|
2334
2348
|
].join("\n"));
|
|
2335
2349
|
}
|
|
2336
2350
|
//#endregion
|
|
2337
2351
|
//#region src/utils/exec.ts
|
|
2338
|
-
function
|
|
2352
|
+
function q(e, t, n) {
|
|
2339
2353
|
return new Promise((r, i) => {
|
|
2340
|
-
let a =
|
|
2354
|
+
let a = d(e, t, {
|
|
2341
2355
|
cwd: n.cwd,
|
|
2342
2356
|
stdio: [
|
|
2343
2357
|
"ignore",
|
|
2344
2358
|
"pipe",
|
|
2345
2359
|
"pipe"
|
|
2346
2360
|
]
|
|
2347
|
-
}), o = "",
|
|
2361
|
+
}), o = "", s = "";
|
|
2348
2362
|
a.stdout.on("data", (e) => {
|
|
2349
2363
|
let t = e.toString();
|
|
2350
2364
|
if (o += t, n.onData) {
|
|
@@ -2353,7 +2367,7 @@ function J(e, t, n) {
|
|
|
2353
2367
|
}
|
|
2354
2368
|
}), a.stderr.on("data", (e) => {
|
|
2355
2369
|
let t = e.toString();
|
|
2356
|
-
if (
|
|
2370
|
+
if (s += t, n.onData) {
|
|
2357
2371
|
let e = t.split("\n").filter(Boolean);
|
|
2358
2372
|
for (let t of e) n.onData(t);
|
|
2359
2373
|
}
|
|
@@ -2361,110 +2375,110 @@ function J(e, t, n) {
|
|
|
2361
2375
|
r({
|
|
2362
2376
|
exitCode: e ?? 1,
|
|
2363
2377
|
stdout: o,
|
|
2364
|
-
stderr:
|
|
2378
|
+
stderr: s
|
|
2365
2379
|
});
|
|
2366
2380
|
});
|
|
2367
2381
|
});
|
|
2368
2382
|
}
|
|
2369
2383
|
//#endregion
|
|
2370
2384
|
//#region src/utils/fs.ts
|
|
2371
|
-
async function
|
|
2372
|
-
return (await
|
|
2385
|
+
async function Jn(e) {
|
|
2386
|
+
return (await o.stat(e).catch(() => null))?.isDirectory() ?? !1;
|
|
2373
2387
|
}
|
|
2374
|
-
async function
|
|
2375
|
-
return (await
|
|
2388
|
+
async function J(e) {
|
|
2389
|
+
return (await o.stat(e).catch(() => null))?.isFile() ?? !1;
|
|
2376
2390
|
}
|
|
2377
|
-
async function
|
|
2378
|
-
return (await
|
|
2391
|
+
async function Yn(e) {
|
|
2392
|
+
return (await o.readdir(e).catch(() => [])).length === 0;
|
|
2379
2393
|
}
|
|
2380
|
-
async function
|
|
2381
|
-
let t = await
|
|
2394
|
+
async function Xn(e) {
|
|
2395
|
+
let t = await o.readFile(e, "utf-8").catch(() => null);
|
|
2382
2396
|
return t ? JSON.parse(t) : null;
|
|
2383
2397
|
}
|
|
2384
|
-
async function
|
|
2385
|
-
await
|
|
2398
|
+
async function Zn(e, t) {
|
|
2399
|
+
await o.writeFile(e, JSON.stringify(t, null, 2) + "\n", "utf-8");
|
|
2386
2400
|
}
|
|
2387
|
-
async function
|
|
2401
|
+
async function Qn(e) {
|
|
2388
2402
|
let t = {};
|
|
2389
|
-
if (!await
|
|
2390
|
-
let
|
|
2391
|
-
for (let
|
|
2403
|
+
if (!await Jn(e)) return t;
|
|
2404
|
+
let n = await o.readdir(e, { withFileTypes: !0 });
|
|
2405
|
+
for (let r of n) r.isDirectory() && await J(l.join(e, r.name, "package.json")) && (t[r.name] = l.relative(l.dirname(e), l.join(e, r.name)));
|
|
2392
2406
|
return t;
|
|
2393
2407
|
}
|
|
2394
|
-
async function
|
|
2395
|
-
await
|
|
2408
|
+
async function $n(e) {
|
|
2409
|
+
await o.rm(e, {
|
|
2396
2410
|
recursive: !0,
|
|
2397
2411
|
force: !0
|
|
2398
2412
|
});
|
|
2399
2413
|
}
|
|
2400
2414
|
//#endregion
|
|
2401
2415
|
//#region src/core/codegen.ts
|
|
2402
|
-
function
|
|
2403
|
-
|
|
2404
|
-
`${
|
|
2405
|
-
`${
|
|
2406
|
-
`${
|
|
2416
|
+
function er(e) {
|
|
2417
|
+
a.log.info(L.muted("Run database setup yourself when ready:")), a.note([
|
|
2418
|
+
`${L.command(`cd ${e}`)}`,
|
|
2419
|
+
`${L.command("pnpm exec prisma generate")} ${L.muted("(regenerate the Prisma client)")}`,
|
|
2420
|
+
`${L.command("pnpm exec prisma migrate dev")} ${L.muted("(create + apply tables for new packs)")}`
|
|
2407
2421
|
].join("\n"), "Database Setup");
|
|
2408
2422
|
}
|
|
2409
|
-
async function
|
|
2410
|
-
let { projectRoot:
|
|
2411
|
-
if (!await
|
|
2412
|
-
if (
|
|
2413
|
-
|
|
2423
|
+
async function tr(e) {
|
|
2424
|
+
let { projectRoot: t, paths: n, skipPrompts: r, runCommand: i = q } = e, o = n.backend.root, s = l.join(t, o);
|
|
2425
|
+
if (!await J(l.join(s, "package.json"))) return;
|
|
2426
|
+
if (r) {
|
|
2427
|
+
er(o);
|
|
2414
2428
|
return;
|
|
2415
2429
|
}
|
|
2416
|
-
let
|
|
2417
|
-
message: `Run database setup now? (${
|
|
2430
|
+
let c = await a.confirm({
|
|
2431
|
+
message: `Run database setup now? (${L.command("prisma generate")} + ${L.command("prisma migrate")})`,
|
|
2418
2432
|
initialValue: !0
|
|
2419
2433
|
});
|
|
2420
|
-
if (
|
|
2421
|
-
|
|
2434
|
+
if (a.isCancel(c) || !c) {
|
|
2435
|
+
er(o);
|
|
2422
2436
|
return;
|
|
2423
2437
|
}
|
|
2424
|
-
let u =
|
|
2425
|
-
if (u.start("Generating Prisma client..."), (await
|
|
2438
|
+
let u = a.spinner();
|
|
2439
|
+
if (u.start("Generating Prisma client..."), (await i("pnpm", [
|
|
2426
2440
|
"exec",
|
|
2427
2441
|
"prisma",
|
|
2428
2442
|
"generate"
|
|
2429
|
-
], { cwd:
|
|
2430
|
-
u.stop(
|
|
2443
|
+
], { cwd: s })).exitCode !== 0) {
|
|
2444
|
+
u.stop(L.warning("Prisma client generation failed")), er(o);
|
|
2431
2445
|
return;
|
|
2432
2446
|
}
|
|
2433
|
-
u.stop(
|
|
2434
|
-
let d =
|
|
2435
|
-
if (d.start("Applying database schema..."), (await
|
|
2447
|
+
u.stop(L.success("Prisma client generated"));
|
|
2448
|
+
let d = a.spinner();
|
|
2449
|
+
if (d.start("Applying database schema..."), (await i("pnpm", [
|
|
2436
2450
|
"exec",
|
|
2437
2451
|
"prisma",
|
|
2438
2452
|
"migrate",
|
|
2439
2453
|
"dev",
|
|
2440
2454
|
"--name",
|
|
2441
2455
|
"add-packs"
|
|
2442
|
-
], { cwd:
|
|
2443
|
-
d.stop(
|
|
2456
|
+
], { cwd: s })).exitCode !== 0) {
|
|
2457
|
+
d.stop(L.warning("Database migration failed (is your database running?)")), er(o);
|
|
2444
2458
|
return;
|
|
2445
2459
|
}
|
|
2446
|
-
d.stop(
|
|
2460
|
+
d.stop(L.success("Database schema applied"));
|
|
2447
2461
|
}
|
|
2448
2462
|
//#endregion
|
|
2449
2463
|
//#region src/core/stack-config.ts
|
|
2450
|
-
async function
|
|
2451
|
-
return
|
|
2464
|
+
async function nr(e) {
|
|
2465
|
+
return Xn(l.join(e, w));
|
|
2452
2466
|
}
|
|
2453
|
-
async function
|
|
2454
|
-
return
|
|
2467
|
+
async function rr(e) {
|
|
2468
|
+
return J(l.join(e, w));
|
|
2455
2469
|
}
|
|
2456
|
-
async function
|
|
2457
|
-
await
|
|
2470
|
+
async function ir(e, t) {
|
|
2471
|
+
await Zn(l.join(e, w), t);
|
|
2458
2472
|
}
|
|
2459
|
-
async function
|
|
2460
|
-
let t =
|
|
2473
|
+
async function ar(e) {
|
|
2474
|
+
let t = l.join(e, "apps"), n = l.join(e, "packages"), [r, i] = await Promise.all([Qn(t), Qn(n)]);
|
|
2461
2475
|
return {
|
|
2462
2476
|
apps: r,
|
|
2463
2477
|
packages: i
|
|
2464
2478
|
};
|
|
2465
2479
|
}
|
|
2466
|
-
function
|
|
2467
|
-
let t = e.apps.backend ?? "apps/backend", n = e.apps.frontend ?? "apps/frontend", r = e.packages.enums ?? "packages/enums";
|
|
2480
|
+
function or(e) {
|
|
2481
|
+
let t = e.apps.backend ?? "apps/backend", n = e.apps.frontend ?? "apps/frontend", r = e.apps.admin ?? "apps/admin", i = e.packages.enums ?? "packages/enums";
|
|
2468
2482
|
return {
|
|
2469
2483
|
backend: {
|
|
2470
2484
|
root: t,
|
|
@@ -2483,29 +2497,37 @@ function Qn(e) {
|
|
|
2483
2497
|
hooks: `${n}/src/hooks`,
|
|
2484
2498
|
utils: `${n}/src/lib`
|
|
2485
2499
|
},
|
|
2486
|
-
|
|
2500
|
+
admin: {
|
|
2487
2501
|
root: r,
|
|
2488
|
-
|
|
2502
|
+
features: `${r}/src/features`,
|
|
2503
|
+
components: `${r}/src/components`,
|
|
2504
|
+
layouts: `${r}/src/components/layouts`,
|
|
2505
|
+
hooks: `${r}/src/hooks`,
|
|
2506
|
+
utils: `${r}/src/lib`
|
|
2507
|
+
},
|
|
2508
|
+
enums: {
|
|
2509
|
+
root: i,
|
|
2510
|
+
src: `${i}/src`
|
|
2489
2511
|
}
|
|
2490
2512
|
};
|
|
2491
2513
|
}
|
|
2492
|
-
function
|
|
2514
|
+
function sr(e, t) {
|
|
2493
2515
|
return {
|
|
2494
2516
|
$schema: re(),
|
|
2495
2517
|
version: 1,
|
|
2496
2518
|
name: e,
|
|
2497
2519
|
apps: t.apps,
|
|
2498
2520
|
packages: t.packages,
|
|
2499
|
-
paths:
|
|
2521
|
+
paths: or(t),
|
|
2500
2522
|
installedPacks: [],
|
|
2501
2523
|
licenseKey: null
|
|
2502
2524
|
};
|
|
2503
2525
|
}
|
|
2504
|
-
async function
|
|
2505
|
-
let t =
|
|
2526
|
+
async function cr(e) {
|
|
2527
|
+
let t = l.join(e, "package.json"), n = l.join(e, "apps"), [r, i] = await Promise.all([J(t), Jn(n)]);
|
|
2506
2528
|
return r && i;
|
|
2507
2529
|
}
|
|
2508
|
-
function
|
|
2530
|
+
function Y(e, t) {
|
|
2509
2531
|
return e.replace(/\{\{(\w+)\.(\w+)\}\}/g, (n, r, i) => {
|
|
2510
2532
|
let a = t[r];
|
|
2511
2533
|
if (!a) throw Error(`Unknown app "${r}" in path template "${e}"`);
|
|
@@ -2516,8 +2538,8 @@ function Z(e, t) {
|
|
|
2516
2538
|
}
|
|
2517
2539
|
//#endregion
|
|
2518
2540
|
//#region src/core/registry.ts
|
|
2519
|
-
async function
|
|
2520
|
-
let { data: t, error: n, status: r } = await
|
|
2541
|
+
async function lr(e) {
|
|
2542
|
+
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
2521
2543
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2522
2544
|
method: "GET"
|
|
2523
2545
|
}).send();
|
|
@@ -2525,51 +2547,51 @@ async function tr(e) {
|
|
|
2525
2547
|
if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
|
|
2526
2548
|
return t;
|
|
2527
2549
|
}
|
|
2528
|
-
async function
|
|
2529
|
-
let
|
|
2550
|
+
async function ur(e, t = {}) {
|
|
2551
|
+
let n = K.createRequest()({
|
|
2530
2552
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2531
2553
|
method: "POST"
|
|
2532
|
-
}),
|
|
2533
|
-
"X-Device-Id":
|
|
2534
|
-
"X-Client-Info":
|
|
2535
|
-
};
|
|
2536
|
-
t.token && (
|
|
2537
|
-
let { data:
|
|
2538
|
-
if (!
|
|
2539
|
-
if (!
|
|
2554
|
+
}), r = {
|
|
2555
|
+
"X-Device-Id": Bn(),
|
|
2556
|
+
"X-Client-Info": Vn()
|
|
2557
|
+
};
|
|
2558
|
+
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2559
|
+
let { data: i, error: a, success: s } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
2560
|
+
if (!s || !i) throw Error(`Failed to download pack "${e}": ${String(a)}`);
|
|
2561
|
+
if (!i.ok) return {
|
|
2540
2562
|
status: "denied",
|
|
2541
|
-
reason:
|
|
2542
|
-
packs:
|
|
2543
|
-
expiresAt:
|
|
2544
|
-
};
|
|
2545
|
-
let u = await
|
|
2546
|
-
return await Promise.all(
|
|
2547
|
-
let t =
|
|
2548
|
-
await
|
|
2563
|
+
reason: i.reason,
|
|
2564
|
+
packs: i.packs ?? [],
|
|
2565
|
+
expiresAt: i.expiresAt ?? null
|
|
2566
|
+
};
|
|
2567
|
+
let u = await o.mkdtemp(l.join(c.tmpdir(), `hype-stack-pack-${e}-`));
|
|
2568
|
+
return await Promise.all(i.files.map(async (e) => {
|
|
2569
|
+
let t = l.join(u, ...e.path.split("/"));
|
|
2570
|
+
await o.mkdir(l.dirname(t), { recursive: !0 }), await o.writeFile(t, Buffer.from(e.content, "base64"));
|
|
2549
2571
|
})), {
|
|
2550
2572
|
status: "ok",
|
|
2551
2573
|
packDir: u
|
|
2552
2574
|
};
|
|
2553
2575
|
}
|
|
2554
|
-
function
|
|
2555
|
-
let r =
|
|
2556
|
-
return
|
|
2576
|
+
function dr(e, t, n) {
|
|
2577
|
+
let r = Y(e, t);
|
|
2578
|
+
return l.resolve(n, r);
|
|
2557
2579
|
}
|
|
2558
|
-
function
|
|
2559
|
-
return
|
|
2580
|
+
function fr(e, t) {
|
|
2581
|
+
return l.join(t, e);
|
|
2560
2582
|
}
|
|
2561
|
-
var
|
|
2583
|
+
var pr = K.createRequest()({
|
|
2562
2584
|
endpoint: "/packs/list",
|
|
2563
2585
|
method: "GET"
|
|
2564
2586
|
});
|
|
2565
|
-
async function
|
|
2566
|
-
let { data: e, error: t } = await
|
|
2587
|
+
async function mr() {
|
|
2588
|
+
let { data: e, error: t } = await pr.send();
|
|
2567
2589
|
if (t || !e) throw Error(`Failed to fetch pack list: ${String(t)}`);
|
|
2568
2590
|
return e.packs;
|
|
2569
2591
|
}
|
|
2570
|
-
async function
|
|
2592
|
+
async function hr(e, t = {}) {
|
|
2571
2593
|
if (e.length === 0) return {};
|
|
2572
|
-
let n =
|
|
2594
|
+
let n = K.createRequest()({
|
|
2573
2595
|
endpoint: "/packs/authorize",
|
|
2574
2596
|
method: "POST"
|
|
2575
2597
|
}), r = {};
|
|
@@ -2583,58 +2605,70 @@ async function sr(e, t = {}) {
|
|
|
2583
2605
|
}
|
|
2584
2606
|
//#endregion
|
|
2585
2607
|
//#region src/core/codemods.ts
|
|
2586
|
-
var
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2608
|
+
var gr = "@hype-stack/";
|
|
2609
|
+
function _r(e, t) {
|
|
2610
|
+
return Y(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
|
|
2611
|
+
}
|
|
2612
|
+
async function vr(e, t, n) {
|
|
2613
|
+
let r = Y("{{backend.root}}", t), i = l.resolve(n, r, "src/config/env/env.config.ts"), a = l.resolve(n, r, ".env.example"), s = l.resolve(n, r, ".env.test");
|
|
2614
|
+
if (await J(i)) {
|
|
2615
|
+
let t = await o.readFile(i, "utf-8");
|
|
2616
|
+
for (let n of e) t.includes(`from "${n.from}"`) || (t = yr(t, n), t = br(t, n));
|
|
2617
|
+
await o.writeFile(i, t, "utf-8");
|
|
2618
|
+
}
|
|
2619
|
+
if (await J(a)) {
|
|
2620
|
+
let t = await o.readFile(a, "utf-8");
|
|
2621
|
+
for (let n of e) t = xr(t, n);
|
|
2622
|
+
await o.writeFile(a, t, "utf-8");
|
|
2623
|
+
}
|
|
2624
|
+
if (await J(s)) {
|
|
2625
|
+
let t = await o.readFile(s, "utf-8");
|
|
2626
|
+
for (let n of e) t = Sr(t, n);
|
|
2627
|
+
await o.writeFile(s, t, "utf-8");
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
function yr(e, t) {
|
|
2606
2631
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2607
2632
|
if (r === -1) return n + "\n" + e;
|
|
2608
2633
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2609
2634
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2610
2635
|
}
|
|
2611
|
-
function
|
|
2612
|
-
let n =
|
|
2613
|
-
if (
|
|
2614
|
-
let
|
|
2615
|
-
|
|
2636
|
+
function br(e, t) {
|
|
2637
|
+
let n = `.extend(${t.import}.shape)`;
|
|
2638
|
+
if (e.includes(n)) return e;
|
|
2639
|
+
let r = e.indexOf("export const envSchema = z.object({");
|
|
2640
|
+
if (r === -1) return e;
|
|
2641
|
+
let i = 0, a = r + 35 - 1;
|
|
2642
|
+
for (; a < e.length; a++) {
|
|
2643
|
+
let t = e[a];
|
|
2644
|
+
if (t === "{") i++;
|
|
2645
|
+
else if (t === "}" && (i--, i === 0)) break;
|
|
2646
|
+
}
|
|
2647
|
+
if (e[a + 1] !== ")") return e;
|
|
2648
|
+
let o = a + 2;
|
|
2649
|
+
return e.slice(0, o) + n + e.slice(o);
|
|
2616
2650
|
}
|
|
2617
|
-
function
|
|
2651
|
+
function xr(e, t) {
|
|
2618
2652
|
for (let n of Object.keys(t.envExample.vars)) if (e.includes(`${n}=`)) return e;
|
|
2619
2653
|
let n = [];
|
|
2620
2654
|
n.push(""), n.push(`# ${t.envExample.section}`);
|
|
2621
2655
|
for (let [e, r] of Object.entries(t.envExample.vars)) n.push(`${e}=${r}`);
|
|
2622
2656
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2623
2657
|
}
|
|
2624
|
-
function
|
|
2658
|
+
function Sr(e, t) {
|
|
2625
2659
|
for (let n of Object.keys(t.envTest)) if (e.includes(`${n}=`)) return e;
|
|
2626
2660
|
let n = [""];
|
|
2627
2661
|
for (let [e, r] of Object.entries(t.envTest)) n.push(`${e}=${r}`);
|
|
2628
2662
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2629
2663
|
}
|
|
2630
|
-
async function
|
|
2631
|
-
let
|
|
2632
|
-
if (!await
|
|
2633
|
-
let
|
|
2634
|
-
for (let t of e)
|
|
2635
|
-
await
|
|
2664
|
+
async function Cr(e, t, n) {
|
|
2665
|
+
let r = l.resolve(n, Y("{{backend.routes}}", t), "index.ts");
|
|
2666
|
+
if (!await J(r)) return;
|
|
2667
|
+
let i = await o.readFile(r, "utf-8");
|
|
2668
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = wr(i, t), i = Tr(i, t));
|
|
2669
|
+
await o.writeFile(r, i, "utf-8");
|
|
2636
2670
|
}
|
|
2637
|
-
function
|
|
2671
|
+
function wr(e, t) {
|
|
2638
2672
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2639
2673
|
if (r !== -1) {
|
|
2640
2674
|
let t = e.indexOf("\n", r);
|
|
@@ -2643,7 +2677,7 @@ function hr(e, t) {
|
|
|
2643
2677
|
let i = e.indexOf("export const registerRoutes");
|
|
2644
2678
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2645
2679
|
}
|
|
2646
|
-
function
|
|
2680
|
+
function Tr(e, t) {
|
|
2647
2681
|
let n = `.route("${t.prefix}", ${t.import})`, r = e.match(/\.route\([^)]+\);/g);
|
|
2648
2682
|
if (r) {
|
|
2649
2683
|
let t = r[r.length - 1], i = e.lastIndexOf(t) + t.length - 1;
|
|
@@ -2651,14 +2685,14 @@ function gr(e, t) {
|
|
|
2651
2685
|
}
|
|
2652
2686
|
return e.replace("return app;", `return app\n ${n};`);
|
|
2653
2687
|
}
|
|
2654
|
-
async function
|
|
2655
|
-
let
|
|
2656
|
-
if (!await
|
|
2657
|
-
let
|
|
2658
|
-
for (let t of e)
|
|
2659
|
-
await
|
|
2688
|
+
async function Er(e, t, n) {
|
|
2689
|
+
let r = l.resolve(n, Y("{{backend.root}}", t), "src/context.ts");
|
|
2690
|
+
if (!await J(r)) return;
|
|
2691
|
+
let i = await o.readFile(r, "utf-8");
|
|
2692
|
+
for (let t of e) i.includes(`export let ${t.export}`) || (i = Dr(i, t), i = Or(i, t), i = kr(i, t), i = jr(i, t));
|
|
2693
|
+
await o.writeFile(r, i, "utf-8");
|
|
2660
2694
|
}
|
|
2661
|
-
function
|
|
2695
|
+
function Dr(e, t) {
|
|
2662
2696
|
let n = `import { ${t.typeImport.name} } from "${t.typeImport.from}";`;
|
|
2663
2697
|
if (e.includes(`from "${t.typeImport.from}"`)) return e;
|
|
2664
2698
|
let r = e.lastIndexOf("import ");
|
|
@@ -2666,7 +2700,7 @@ function vr(e, t) {
|
|
|
2666
2700
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2667
2701
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2668
2702
|
}
|
|
2669
|
-
function
|
|
2703
|
+
function Or(e, t) {
|
|
2670
2704
|
let n = `export let ${t.export}: ${t.type};`, r = e.lastIndexOf("export let ");
|
|
2671
2705
|
if (r === -1) {
|
|
2672
2706
|
let t = e.indexOf("export const setupContext");
|
|
@@ -2675,26 +2709,37 @@ function yr(e, t) {
|
|
|
2675
2709
|
let i = e.indexOf("\n", r);
|
|
2676
2710
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2677
2711
|
}
|
|
2678
|
-
function
|
|
2712
|
+
function kr(e, t) {
|
|
2679
2713
|
let n = ` ${t.export} = ${t.init};`, r = e.match(/export const setupContext\s*=\s*async\s*\([^)]*\)\s*=>\s*\{/);
|
|
2680
2714
|
if (!r) return e;
|
|
2681
2715
|
let i = e.indexOf("{", e.indexOf(r[0]));
|
|
2682
|
-
|
|
2716
|
+
if (i === -1) return e;
|
|
2717
|
+
let a = Ar(e, i);
|
|
2718
|
+
return a === -1 ? e : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2683
2719
|
}
|
|
2684
|
-
function
|
|
2720
|
+
function Ar(e, t) {
|
|
2721
|
+
let n = 0;
|
|
2722
|
+
for (let r = t; r < e.length; r++) {
|
|
2723
|
+
let t = e[r];
|
|
2724
|
+
if (t === "{") n++;
|
|
2725
|
+
else if (t === "}" && (n--, n === 0)) return r;
|
|
2726
|
+
}
|
|
2727
|
+
return -1;
|
|
2728
|
+
}
|
|
2729
|
+
function jr(e, t) {
|
|
2685
2730
|
let n = ` ${t.export}: ${t.type};`, r = e.indexOf("export type ContextVariables = {");
|
|
2686
2731
|
if (r === -1) return e;
|
|
2687
2732
|
let i = e.indexOf("};", r);
|
|
2688
2733
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2689
2734
|
}
|
|
2690
|
-
async function
|
|
2691
|
-
let
|
|
2692
|
-
if (!await
|
|
2693
|
-
let
|
|
2694
|
-
for (let t of e)
|
|
2695
|
-
await
|
|
2735
|
+
async function Mr(e, t, n) {
|
|
2736
|
+
let r = l.resolve(n, Y("{{enums.src}}", t), "index.ts");
|
|
2737
|
+
if (!await J(r)) return;
|
|
2738
|
+
let i = await o.readFile(r, "utf-8");
|
|
2739
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Nr(i, t));
|
|
2740
|
+
await o.writeFile(r, i, "utf-8");
|
|
2696
2741
|
}
|
|
2697
|
-
function
|
|
2742
|
+
function Nr(e, t) {
|
|
2698
2743
|
let n = `export * from "${t.from}";`, r = e.lastIndexOf("export * from");
|
|
2699
2744
|
if (r !== -1) {
|
|
2700
2745
|
let t = e.indexOf("\n", r);
|
|
@@ -2702,14 +2747,14 @@ function Cr(e, t) {
|
|
|
2702
2747
|
}
|
|
2703
2748
|
return e.trim() === "" ? n + "\n" : e.trimEnd() + "\n" + n + "\n";
|
|
2704
2749
|
}
|
|
2705
|
-
async function
|
|
2706
|
-
let
|
|
2707
|
-
if (!await
|
|
2708
|
-
let
|
|
2709
|
-
for (let t of e)
|
|
2710
|
-
await
|
|
2750
|
+
async function Pr(e, t, n) {
|
|
2751
|
+
let r = Y("{{backend.root}}", t), i = l.resolve(n, r, "src/sockets/index.ts");
|
|
2752
|
+
if (!await J(i)) return;
|
|
2753
|
+
let a = await o.readFile(i, "utf-8");
|
|
2754
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = Fr(a, t), a = Ir(a, t));
|
|
2755
|
+
await J(l.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a = Lr(a)), await o.writeFile(i, a, "utf-8");
|
|
2711
2756
|
}
|
|
2712
|
-
function
|
|
2757
|
+
function Fr(e, t) {
|
|
2713
2758
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2714
2759
|
if (r !== -1) {
|
|
2715
2760
|
let t = e.indexOf("\n", r);
|
|
@@ -2718,15 +2763,21 @@ function Tr(e, t) {
|
|
|
2718
2763
|
let i = e.indexOf("const sockets");
|
|
2719
2764
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2720
2765
|
}
|
|
2721
|
-
function
|
|
2722
|
-
let n = `.socket("${t.prefix}", ${t.import})`, r = e.
|
|
2723
|
-
if (r)
|
|
2724
|
-
|
|
2725
|
-
|
|
2766
|
+
function Ir(e, t) {
|
|
2767
|
+
let n = `.socket("${t.prefix}", ${t.import})`, r = e.indexOf("const sockets");
|
|
2768
|
+
if (r === -1) return e;
|
|
2769
|
+
let i = e.indexOf("new SocketRouter", r);
|
|
2770
|
+
if (i === -1) return e;
|
|
2771
|
+
let a = 0, o = !1;
|
|
2772
|
+
for (let t = i; t < e.length; t++) {
|
|
2773
|
+
let r = e[t];
|
|
2774
|
+
if (r === "(" || r === "{" || r === "[") a++, o = !0;
|
|
2775
|
+
else if (r === ")" || r === "}" || r === "]") a--;
|
|
2776
|
+
else if (r === ";" && o && a === 0) return e.slice(0, t) + "\n " + n + e.slice(t);
|
|
2726
2777
|
}
|
|
2727
|
-
return e
|
|
2778
|
+
return e;
|
|
2728
2779
|
}
|
|
2729
|
-
function
|
|
2780
|
+
function Lr(e) {
|
|
2730
2781
|
if (e.includes("wsAuthenticate")) return e;
|
|
2731
2782
|
let t = e.indexOf("from \"@backend/libs/websocket/socket-router\""), n = e;
|
|
2732
2783
|
if (t !== -1) {
|
|
@@ -2735,42 +2786,75 @@ function Dr(e) {
|
|
|
2735
2786
|
}
|
|
2736
2787
|
return n.replace("new SocketRouter()", "new SocketRouter({ authenticate: wsAuthenticate })");
|
|
2737
2788
|
}
|
|
2738
|
-
async function
|
|
2739
|
-
let
|
|
2740
|
-
if (!await
|
|
2741
|
-
let
|
|
2742
|
-
for (let t of e)
|
|
2743
|
-
await
|
|
2789
|
+
async function Rr(e, t, n) {
|
|
2790
|
+
let r = Y("{{frontend.root}}", t), i = l.resolve(n, r, "src/api/sdk.ts");
|
|
2791
|
+
if (!await J(i)) return;
|
|
2792
|
+
let a = await o.readFile(i, "utf-8");
|
|
2793
|
+
for (let t of e) a.includes(`.$configure(${t.import})`) || (a = zr(a, t), a = Br(a, t));
|
|
2794
|
+
await o.writeFile(i, a, "utf-8");
|
|
2744
2795
|
}
|
|
2745
|
-
function
|
|
2796
|
+
function zr(e, t) {
|
|
2797
|
+
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2798
|
+
if (e.includes(n)) return e;
|
|
2799
|
+
let r = e.lastIndexOf("from \"./");
|
|
2800
|
+
if (r !== -1) {
|
|
2801
|
+
let t = e.indexOf("\n", r);
|
|
2802
|
+
return t === -1 ? e : e.slice(0, t + 1) + n + "\n" + e.slice(t + 1);
|
|
2803
|
+
}
|
|
2804
|
+
let i = e.indexOf("export const sdk");
|
|
2805
|
+
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2806
|
+
}
|
|
2807
|
+
function Br(e, t) {
|
|
2808
|
+
let n = `.$configure(${t.import})`, r = e.indexOf("export const sdk");
|
|
2809
|
+
if (r === -1) return e;
|
|
2810
|
+
let i = e.indexOf(";", r);
|
|
2811
|
+
return i === -1 ? e : e.slice(0, i) + "\n " + n + e.slice(i);
|
|
2812
|
+
}
|
|
2813
|
+
async function Vr(e, t, n) {
|
|
2814
|
+
let r = l.resolve(n, Y("{{backend.utils}}", t), "frontend-url/frontend-url.ts");
|
|
2815
|
+
if (!await J(r)) return;
|
|
2816
|
+
let i = await o.readFile(r, "utf-8");
|
|
2817
|
+
for (let t of e) i.includes(`"${t.path}"`) || (i = Hr(i, t));
|
|
2818
|
+
await o.writeFile(r, i, "utf-8");
|
|
2819
|
+
}
|
|
2820
|
+
function Hr(e, t) {
|
|
2746
2821
|
let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
|
|
2747
2822
|
if (r === -1) return e;
|
|
2748
2823
|
let i = e.indexOf("};", r);
|
|
2749
2824
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2750
2825
|
}
|
|
2751
|
-
var
|
|
2826
|
+
var Ur = "import { type LucideIcon } from \"lucide-react\";\n\n/* -------------------------------------------------------------------------------------------------\n * Types\n * -----------------------------------------------------------------------------------------------*/\n\nexport type NavItem = {\n label: string;\n icon: LucideIcon;\n to: string;\n params?: Record<string, string>;\n};\n\nexport type NavSection = {\n label: string;\n icon: LucideIcon;\n items: NavItem[];\n};\n\nexport type NavSectionLink = NavSection & { to: string; params?: Record<string, string> };\n\nexport type NavEntry = NavSection | NavSectionLink;\n\n/* -------------------------------------------------------------------------------------------------\n * Navigation\n * -----------------------------------------------------------------------------------------------*/\n\nexport const primaryNav: NavEntry[] = [];\n\nexport const secondaryNav: NavEntry[] = [];\n\nexport const tertiaryNav: NavEntry[] = [];\n\nexport const settingsNav: NavEntry[] = [];\n", Wr = {
|
|
2752
2827
|
primary: "primaryNav",
|
|
2753
2828
|
secondary: "secondaryNav",
|
|
2754
2829
|
tertiary: "tertiaryNav",
|
|
2755
2830
|
settings: "settingsNav"
|
|
2756
2831
|
};
|
|
2757
|
-
async function
|
|
2758
|
-
let i =
|
|
2759
|
-
await
|
|
2760
|
-
for (let
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2832
|
+
async function Gr(e) {
|
|
2833
|
+
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = _r(i, n), s = l.resolve(r, a, "src/constants/nav.constants.ts"), c;
|
|
2834
|
+
await J(s) ? c = await o.readFile(s, "utf-8") : (await o.mkdir(l.dirname(s), { recursive: !0 }), c = Ur);
|
|
2835
|
+
for (let e of t) c.includes(`label: "${e.label}"`) || (c = Jr(c, e));
|
|
2836
|
+
for (let e of t.toReversed()) c.includes(`label: "${e.label}"`) || (c = Xr(c, e));
|
|
2837
|
+
await o.writeFile(s, c, "utf-8");
|
|
2838
|
+
}
|
|
2839
|
+
async function Kr(e) {
|
|
2840
|
+
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = _r(i, n), s = l.resolve(r, a, "src/features/auth/constants/auth.constants.ts");
|
|
2841
|
+
if (!await J(s)) return;
|
|
2842
|
+
let c = await o.readFile(s, "utf-8"), u = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
|
|
2843
|
+
if (!u.test(c)) return;
|
|
2844
|
+
let d = c.replace(u, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
2845
|
+
await o.writeFile(s, d, "utf-8");
|
|
2846
|
+
}
|
|
2847
|
+
function qr(e) {
|
|
2764
2848
|
let t = [e.icon];
|
|
2765
2849
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
2766
2850
|
return t;
|
|
2767
2851
|
}
|
|
2768
|
-
function
|
|
2769
|
-
let n =
|
|
2770
|
-
for (let e of n) r =
|
|
2852
|
+
function Jr(e, t) {
|
|
2853
|
+
let n = qr(t), r = e;
|
|
2854
|
+
for (let e of n) r = Yr(r, e);
|
|
2771
2855
|
return r;
|
|
2772
2856
|
}
|
|
2773
|
-
function
|
|
2857
|
+
function Yr(e, t) {
|
|
2774
2858
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
2775
2859
|
if (!n) return e;
|
|
2776
2860
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -2778,21 +2862,21 @@ function Fr(e, t) {
|
|
|
2778
2862
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
2779
2863
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
2780
2864
|
}
|
|
2781
|
-
function
|
|
2782
|
-
let n =
|
|
2865
|
+
function Xr(e, t) {
|
|
2866
|
+
let n = Wr[t.group];
|
|
2783
2867
|
if (!n) return e;
|
|
2784
|
-
let r =
|
|
2868
|
+
let r = Qr(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
|
|
2785
2869
|
if (!a) return e;
|
|
2786
|
-
let o = e.indexOf(a[0]) + a[0].length, s =
|
|
2787
|
-
return s === -1 ? e : e.slice(o, s).trim() === "" ? e.slice(0,
|
|
2870
|
+
let o = e.indexOf(a[0]) + a[0].length, s = Zr(e, o - 1);
|
|
2871
|
+
return s === -1 ? e : e.slice(o, s).trim() === "" ? e.slice(0, o) + "\n" + r + "\n" + e.slice(o) : e.slice(0, o) + "\n" + r + e.slice(o);
|
|
2788
2872
|
}
|
|
2789
|
-
function
|
|
2873
|
+
function Zr(e, t) {
|
|
2790
2874
|
let n = 0;
|
|
2791
2875
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2792
2876
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2793
2877
|
return -1;
|
|
2794
2878
|
}
|
|
2795
|
-
function
|
|
2879
|
+
function Qr(e) {
|
|
2796
2880
|
let t = [];
|
|
2797
2881
|
if (t.push(" {"), t.push(` label: "${e.label}",`), t.push(` icon: ${e.icon},`), e.to && t.push(` to: "${e.to}",`), e.params && t.push(` params: ${e.params},`), e.items && e.items.length > 0) {
|
|
2798
2882
|
t.push(" items: [");
|
|
@@ -2808,14 +2892,14 @@ function Rr(e) {
|
|
|
2808
2892
|
} else t.push(" items: [],");
|
|
2809
2893
|
return t.push(" },"), t.join("\n");
|
|
2810
2894
|
}
|
|
2811
|
-
async function
|
|
2812
|
-
let
|
|
2813
|
-
if (!await
|
|
2814
|
-
let
|
|
2815
|
-
for (let t of e)
|
|
2816
|
-
await
|
|
2895
|
+
async function $r(e, t, n) {
|
|
2896
|
+
let r = Y("{{backend.features}}", t), i = l.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
|
|
2897
|
+
if (!await J(i)) return;
|
|
2898
|
+
let a = await o.readFile(i, "utf-8");
|
|
2899
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = ei(a, t), a = ti(a, t));
|
|
2900
|
+
await o.writeFile(i, a, "utf-8");
|
|
2817
2901
|
}
|
|
2818
|
-
function
|
|
2902
|
+
function ei(e, t) {
|
|
2819
2903
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2820
2904
|
if (r !== -1) {
|
|
2821
2905
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -2823,26 +2907,38 @@ function Br(e, t) {
|
|
|
2823
2907
|
}
|
|
2824
2908
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
2825
2909
|
}
|
|
2826
|
-
function
|
|
2910
|
+
function ti(e, t) {
|
|
2827
2911
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
2828
2912
|
if (!r) return e;
|
|
2829
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2913
|
+
let i = e.indexOf(r[0]) + r[0].length, a = ni(e, i - 1);
|
|
2830
2914
|
return a === -1 ? e : e.slice(i, a).trim() === "" ? e.slice(0, a) + "\n" + n + "\n" + e.slice(a) : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2831
2915
|
}
|
|
2832
|
-
function
|
|
2916
|
+
function ni(e, t) {
|
|
2833
2917
|
let n = 0;
|
|
2834
2918
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2835
2919
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2836
2920
|
return -1;
|
|
2837
2921
|
}
|
|
2838
|
-
var
|
|
2839
|
-
async function
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2922
|
+
var ri = "import { type ComponentType } from \"react\";\n\nexport type NavbarAction = {\n id: string;\n component: ComponentType;\n};\n\nexport const navbarActions: NavbarAction[] = [];\n\nexport const userMenuActions: NavbarAction[] = [];\n";
|
|
2923
|
+
async function ii(e) {
|
|
2924
|
+
await oi({
|
|
2925
|
+
...e,
|
|
2926
|
+
arrayName: "navbarActions"
|
|
2927
|
+
});
|
|
2928
|
+
}
|
|
2929
|
+
async function ai(e) {
|
|
2930
|
+
await oi({
|
|
2931
|
+
...e,
|
|
2932
|
+
arrayName: "userMenuActions"
|
|
2933
|
+
});
|
|
2934
|
+
}
|
|
2935
|
+
async function oi({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
|
|
2936
|
+
let a = _r(i, n), s = l.resolve(r, a, "src/constants/navbar-actions.tsx"), c;
|
|
2937
|
+
await J(s) ? c = await o.readFile(s, "utf-8") : (await o.mkdir(l.dirname(s), { recursive: !0 }), c = ri);
|
|
2938
|
+
for (let n of e) c = si(c, n), c = ci(c, n, t);
|
|
2939
|
+
await o.writeFile(s, c, "utf-8");
|
|
2844
2940
|
}
|
|
2845
|
-
function
|
|
2941
|
+
function si(e, t) {
|
|
2846
2942
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2847
2943
|
if (e.includes(n)) return e;
|
|
2848
2944
|
let r = e.lastIndexOf("import ");
|
|
@@ -2850,126 +2946,156 @@ function Gr(e, t) {
|
|
|
2850
2946
|
let i = e.indexOf("\n", r);
|
|
2851
2947
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2852
2948
|
}
|
|
2853
|
-
function
|
|
2854
|
-
let
|
|
2949
|
+
function ci(e, t, n) {
|
|
2950
|
+
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
2855
2951
|
if (!r) return e;
|
|
2856
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2952
|
+
let i = e.indexOf(r[0]) + r[0].length, a = li(e, i - 1);
|
|
2953
|
+
if (a === -1) return e;
|
|
2954
|
+
let o = e.slice(i, a);
|
|
2955
|
+
if (o.includes(`id: "${t.id}"`)) return e;
|
|
2956
|
+
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
2957
|
+
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
2958
|
+
}
|
|
2959
|
+
function li(e, t) {
|
|
2860
2960
|
let n = 0;
|
|
2861
2961
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2862
2962
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2863
2963
|
return -1;
|
|
2864
2964
|
}
|
|
2865
|
-
var
|
|
2965
|
+
var ui = new Set([
|
|
2866
2966
|
".ts",
|
|
2867
2967
|
".tsx",
|
|
2868
2968
|
".js",
|
|
2869
2969
|
".jsx"
|
|
2870
2970
|
]);
|
|
2871
|
-
async function
|
|
2872
|
-
let { files: t, paths:
|
|
2873
|
-
if (
|
|
2874
|
-
let
|
|
2971
|
+
async function di(e) {
|
|
2972
|
+
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
2973
|
+
if (i === "hype-stack") return;
|
|
2974
|
+
let a = `@${i}/`;
|
|
2875
2975
|
await Promise.all(t.map(async (e) => {
|
|
2876
|
-
let t =
|
|
2877
|
-
|
|
2976
|
+
let t = dr(e.target, n, r), i = await o.stat(t).catch(() => null);
|
|
2977
|
+
i?.isDirectory() ? await mi(t, a) : i?.isFile() && ui.has(l.extname(t)) && await hi(t, a);
|
|
2878
2978
|
}));
|
|
2879
2979
|
}
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2980
|
+
var fi = new Set([
|
|
2981
|
+
".git",
|
|
2982
|
+
"node_modules",
|
|
2983
|
+
"dist",
|
|
2984
|
+
"build",
|
|
2985
|
+
".nx",
|
|
2986
|
+
".next",
|
|
2987
|
+
"coverage"
|
|
2988
|
+
]);
|
|
2989
|
+
async function pi(e, t) {
|
|
2990
|
+
t !== "hype-stack" && await mi(e, `@${t}/`);
|
|
2991
|
+
}
|
|
2992
|
+
async function mi(e, t) {
|
|
2993
|
+
let n = await o.readdir(e, { withFileTypes: !0 });
|
|
2994
|
+
await Promise.all(n.map(async (n) => {
|
|
2995
|
+
let r = l.join(e, n.name);
|
|
2996
|
+
if (n.isDirectory()) {
|
|
2997
|
+
if (fi.has(n.name)) return;
|
|
2998
|
+
await mi(r, t);
|
|
2999
|
+
} else n.isFile() && ui.has(l.extname(n.name)) && await hi(r, t);
|
|
2885
3000
|
}));
|
|
2886
3001
|
}
|
|
2887
|
-
async function
|
|
2888
|
-
let
|
|
2889
|
-
if (!
|
|
2890
|
-
let
|
|
2891
|
-
await
|
|
3002
|
+
async function hi(e, t) {
|
|
3003
|
+
let n = await o.readFile(e, "utf-8");
|
|
3004
|
+
if (!n.includes(gr)) return;
|
|
3005
|
+
let r = n.replaceAll(gr, t);
|
|
3006
|
+
await o.writeFile(e, r, "utf-8");
|
|
2892
3007
|
}
|
|
2893
3008
|
//#endregion
|
|
2894
3009
|
//#region src/core/installer.ts
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
}
|
|
2902
|
-
|
|
2903
|
-
|
|
3010
|
+
function gi(e, t) {
|
|
3011
|
+
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3012
|
+
}
|
|
3013
|
+
async function _i(e, t) {
|
|
3014
|
+
if ((await o.stat(e)).isDirectory()) {
|
|
3015
|
+
await o.mkdir(t, { recursive: !0 });
|
|
3016
|
+
let n = await o.readdir(e, { withFileTypes: !0 });
|
|
3017
|
+
for (let r of n) await _i(l.join(e, r.name), l.join(t, r.name));
|
|
3018
|
+
} else await o.mkdir(l.dirname(t), { recursive: !0 }), await o.copyFile(e, t);
|
|
3019
|
+
}
|
|
3020
|
+
async function vi(e) {
|
|
3021
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = fr(t.source, n), o = dr(t.target, r, i);
|
|
2904
3022
|
return {
|
|
2905
3023
|
sourcePath: a,
|
|
2906
3024
|
targetPath: o,
|
|
2907
|
-
sourceExists: await
|
|
2908
|
-
targetExists: await
|
|
3025
|
+
sourceExists: await J(a) || await Jn(a),
|
|
3026
|
+
targetExists: await J(o) || await Jn(o)
|
|
2909
3027
|
};
|
|
2910
3028
|
}
|
|
2911
|
-
async function
|
|
2912
|
-
let { file: t, packDir:
|
|
3029
|
+
async function yi(e) {
|
|
3030
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: s, sourceExists: c, targetExists: l } = await vi({
|
|
2913
3031
|
file: t,
|
|
2914
|
-
packDir:
|
|
2915
|
-
paths:
|
|
2916
|
-
projectRoot:
|
|
3032
|
+
packDir: n,
|
|
3033
|
+
paths: r,
|
|
3034
|
+
projectRoot: i
|
|
2917
3035
|
});
|
|
2918
|
-
if (!c) return `${t.source}: Source not found (${
|
|
3036
|
+
if (!c) return `${t.source}: Source not found (${a})`;
|
|
2919
3037
|
switch (t.strategy) {
|
|
2920
3038
|
case "create":
|
|
2921
|
-
case "skip-if-exists":
|
|
2922
|
-
case "
|
|
3039
|
+
case "skip-if-exists":
|
|
3040
|
+
case "override": return null;
|
|
3041
|
+
case "merge": return !l || !t.marker || (await o.readFile(s, "utf-8")).includes(t.marker) ? null : `${t.target}: Marker "${t.marker}" not found`;
|
|
2923
3042
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
2924
3043
|
}
|
|
2925
3044
|
}
|
|
2926
|
-
async function
|
|
2927
|
-
let { file: t, packDir:
|
|
3045
|
+
async function bi(e) {
|
|
3046
|
+
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: s } = e, { sourcePath: c, targetPath: l, sourceExists: u, targetExists: d } = await vi({
|
|
2928
3047
|
file: t,
|
|
2929
|
-
packDir:
|
|
2930
|
-
paths:
|
|
2931
|
-
projectRoot:
|
|
3048
|
+
packDir: n,
|
|
3049
|
+
paths: r,
|
|
3050
|
+
projectRoot: i
|
|
2932
3051
|
});
|
|
2933
|
-
if (!
|
|
3052
|
+
if (!u) return {
|
|
2934
3053
|
status: "error",
|
|
2935
3054
|
path: t.source,
|
|
2936
3055
|
reason: "Source not found"
|
|
2937
3056
|
};
|
|
2938
3057
|
switch (t.strategy) {
|
|
2939
|
-
case "create":
|
|
3058
|
+
case "create": {
|
|
3059
|
+
let e = a || (s?.has(l) ?? !1);
|
|
3060
|
+
return d && !e ? {
|
|
3061
|
+
status: "skipped",
|
|
3062
|
+
path: t.target,
|
|
3063
|
+
reason: "Already exists"
|
|
3064
|
+
} : (await _i(c, l), {
|
|
3065
|
+
status: "installed",
|
|
3066
|
+
path: t.target
|
|
3067
|
+
});
|
|
3068
|
+
}
|
|
3069
|
+
case "skip-if-exists": return d ? {
|
|
2940
3070
|
status: "skipped",
|
|
2941
3071
|
path: t.target,
|
|
2942
|
-
reason: "Already exists"
|
|
2943
|
-
} : (await
|
|
3072
|
+
reason: "Already exists (skip-if-exists)"
|
|
3073
|
+
} : (await _i(c, l), {
|
|
2944
3074
|
status: "installed",
|
|
2945
3075
|
path: t.target
|
|
2946
3076
|
});
|
|
2947
|
-
case "
|
|
2948
|
-
status: "skipped",
|
|
2949
|
-
path: t.target,
|
|
2950
|
-
reason: "Already exists (skip-if-exists)"
|
|
2951
|
-
} : (await Qr(s, c), {
|
|
3077
|
+
case "override": return await _i(c, l), {
|
|
2952
3078
|
status: "installed",
|
|
2953
3079
|
path: t.target
|
|
2954
|
-
}
|
|
3080
|
+
};
|
|
2955
3081
|
case "merge": {
|
|
2956
|
-
if (!
|
|
3082
|
+
if (!d) return await _i(c, l), {
|
|
2957
3083
|
status: "installed",
|
|
2958
3084
|
path: t.target
|
|
2959
3085
|
};
|
|
2960
|
-
let e = await
|
|
3086
|
+
let e = await o.readFile(c, "utf-8"), n = await o.readFile(l, "utf-8");
|
|
2961
3087
|
if (t.marker) {
|
|
2962
|
-
let
|
|
2963
|
-
if (
|
|
3088
|
+
let r = n.indexOf(t.marker);
|
|
3089
|
+
if (r === -1) return {
|
|
2964
3090
|
status: "error",
|
|
2965
3091
|
path: t.target,
|
|
2966
3092
|
reason: `Marker "${t.marker}" not found`
|
|
2967
3093
|
};
|
|
2968
|
-
let
|
|
2969
|
-
await
|
|
3094
|
+
let i = n.slice(0, r) + e + n.slice(r);
|
|
3095
|
+
await o.writeFile(l, i);
|
|
2970
3096
|
} else {
|
|
2971
|
-
let t =
|
|
2972
|
-
await
|
|
3097
|
+
let t = n + "\n" + e;
|
|
3098
|
+
await o.writeFile(l, t);
|
|
2973
3099
|
}
|
|
2974
3100
|
return {
|
|
2975
3101
|
status: "installed",
|
|
@@ -2983,179 +3109,236 @@ async function ti(e) {
|
|
|
2983
3109
|
};
|
|
2984
3110
|
}
|
|
2985
3111
|
}
|
|
2986
|
-
async function
|
|
2987
|
-
let {
|
|
2988
|
-
if (!
|
|
2989
|
-
let
|
|
3112
|
+
async function xi(e) {
|
|
3113
|
+
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3114
|
+
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'hype-stack init' to set it up.");
|
|
3115
|
+
let o = [], s = /* @__PURE__ */ new Set();
|
|
3116
|
+
for (let e of t) {
|
|
3117
|
+
let t = i?.get(e.manifest.name);
|
|
3118
|
+
for (let n of e.manifest.files) {
|
|
3119
|
+
if (n.strategy !== "create" || !gi(n, t)) continue;
|
|
3120
|
+
let { targetPath: i, targetExists: c } = await vi({
|
|
3121
|
+
file: n,
|
|
3122
|
+
packDir: e.packDir,
|
|
3123
|
+
paths: a,
|
|
3124
|
+
projectRoot: r
|
|
3125
|
+
});
|
|
3126
|
+
!c || s.has(i) || (s.add(i), o.push({
|
|
3127
|
+
packName: e.manifest.name,
|
|
3128
|
+
target: n.target,
|
|
3129
|
+
targetPath: i
|
|
3130
|
+
}));
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
return o;
|
|
3134
|
+
}
|
|
3135
|
+
async function Si(e) {
|
|
3136
|
+
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3137
|
+
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'hype-stack init' to set it up.");
|
|
3138
|
+
let c = [];
|
|
2990
3139
|
for (let e of t.files) {
|
|
2991
|
-
|
|
3140
|
+
if (!gi(e, o)) continue;
|
|
3141
|
+
let t = await yi({
|
|
2992
3142
|
file: e,
|
|
2993
3143
|
packDir: a,
|
|
2994
|
-
paths:
|
|
3144
|
+
paths: s,
|
|
2995
3145
|
projectRoot: r,
|
|
2996
3146
|
force: i
|
|
2997
3147
|
});
|
|
2998
|
-
t &&
|
|
3148
|
+
t && c.push(t);
|
|
2999
3149
|
}
|
|
3000
|
-
return
|
|
3150
|
+
return c;
|
|
3001
3151
|
}
|
|
3002
|
-
async function
|
|
3003
|
-
let { manifest: t, config: n, projectRoot: r, force: i,
|
|
3004
|
-
if (!
|
|
3005
|
-
let
|
|
3152
|
+
async function Ci(e) {
|
|
3153
|
+
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3154
|
+
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'hype-stack init' to set it up.");
|
|
3155
|
+
let l = {
|
|
3006
3156
|
installed: [],
|
|
3007
3157
|
skipped: [],
|
|
3008
3158
|
errors: []
|
|
3009
|
-
};
|
|
3010
|
-
for (let e of
|
|
3011
|
-
let t = await
|
|
3159
|
+
}, u = t.files.filter((e) => gi(e, s));
|
|
3160
|
+
for (let e of u) {
|
|
3161
|
+
let t = await bi({
|
|
3012
3162
|
file: e,
|
|
3013
|
-
packDir:
|
|
3014
|
-
paths:
|
|
3163
|
+
packDir: o,
|
|
3164
|
+
paths: c,
|
|
3015
3165
|
projectRoot: r,
|
|
3016
|
-
force: i
|
|
3166
|
+
force: i,
|
|
3167
|
+
overwrite: a
|
|
3017
3168
|
});
|
|
3018
3169
|
switch (t.status) {
|
|
3019
3170
|
case "installed":
|
|
3020
|
-
|
|
3171
|
+
l.installed.push(t.path);
|
|
3021
3172
|
break;
|
|
3022
3173
|
case "skipped":
|
|
3023
|
-
|
|
3174
|
+
l.skipped.push(`${t.path} (${t.reason})`);
|
|
3024
3175
|
break;
|
|
3025
3176
|
case "error":
|
|
3026
|
-
|
|
3177
|
+
l.errors.push(`${t.path}: ${t.reason}`);
|
|
3027
3178
|
break;
|
|
3028
3179
|
}
|
|
3029
3180
|
}
|
|
3030
|
-
|
|
3031
|
-
files:
|
|
3032
|
-
paths:
|
|
3181
|
+
await di({
|
|
3182
|
+
files: u,
|
|
3183
|
+
paths: c,
|
|
3033
3184
|
projectRoot: r,
|
|
3034
3185
|
projectName: n.name
|
|
3035
|
-
}), t.env && t.env.length > 0 && await
|
|
3186
|
+
}), t.env && t.env.length > 0 && await vr(t.env, c, r), t.routes && t.routes.length > 0 && await Cr(t.routes, c, r), t.context && t.context.length > 0 && await Er(t.context, c, r), t.sockets && t.sockets.length > 0 && await Pr(t.sockets, c, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await Rr(t.sdkConfigurations, c, r), t.enums && t.enums.length > 0 && await Mr(t.enums, c, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await Vr(t.frontendRoutes, c, r);
|
|
3187
|
+
let d = s && s.length > 0 ? s : ["frontend"];
|
|
3188
|
+
for (let e of d) t.nav && t.nav.length > 0 && await Gr({
|
|
3189
|
+
entries: t.nav,
|
|
3190
|
+
paths: c,
|
|
3191
|
+
projectRoot: r,
|
|
3192
|
+
slot: e
|
|
3193
|
+
}), t.navbarActions && t.navbarActions.length > 0 && await ii({
|
|
3194
|
+
actions: t.navbarActions,
|
|
3195
|
+
paths: c,
|
|
3196
|
+
projectRoot: r,
|
|
3197
|
+
slot: e
|
|
3198
|
+
}), t.userMenuActions && t.userMenuActions.length > 0 && await ai({
|
|
3199
|
+
actions: t.userMenuActions,
|
|
3200
|
+
paths: c,
|
|
3201
|
+
projectRoot: r,
|
|
3202
|
+
slot: e
|
|
3203
|
+
});
|
|
3204
|
+
return t.onboardingSteps && t.onboardingSteps.length > 0 && await $r(t.onboardingSteps, c, r), t.postLoginRedirect && await Kr({
|
|
3205
|
+
postLoginRedirect: t.postLoginRedirect,
|
|
3206
|
+
paths: c,
|
|
3207
|
+
projectRoot: r,
|
|
3208
|
+
slot: d[0]
|
|
3209
|
+
}), l;
|
|
3036
3210
|
}
|
|
3037
|
-
async function
|
|
3038
|
-
let { packs: t, config: n, projectRoot: r, force: i } = e,
|
|
3211
|
+
async function wi(e) {
|
|
3212
|
+
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3039
3213
|
for (let e of t) {
|
|
3040
|
-
let t = await
|
|
3214
|
+
let t = o?.get(e.manifest.name), a = await Si({
|
|
3041
3215
|
manifest: e.manifest,
|
|
3042
3216
|
config: n,
|
|
3043
3217
|
projectRoot: r,
|
|
3044
3218
|
force: i,
|
|
3045
|
-
packDir: e.packDir
|
|
3219
|
+
packDir: e.packDir,
|
|
3220
|
+
slots: t
|
|
3046
3221
|
});
|
|
3047
|
-
for (let
|
|
3222
|
+
for (let t of a) s.push(`${e.manifest.name}: ${t}`);
|
|
3048
3223
|
}
|
|
3049
|
-
if (
|
|
3224
|
+
if (s.length > 0) return {
|
|
3050
3225
|
installed: [],
|
|
3051
3226
|
skipped: [],
|
|
3052
|
-
errors:
|
|
3227
|
+
errors: s,
|
|
3053
3228
|
appliedPacks: [],
|
|
3054
3229
|
aborted: !0,
|
|
3055
3230
|
config: n
|
|
3056
3231
|
};
|
|
3057
|
-
let
|
|
3232
|
+
let c = [], l = [], u = [], d = [], f = n;
|
|
3058
3233
|
for (let e of t) {
|
|
3059
|
-
let t = await
|
|
3234
|
+
let t = o?.get(e.manifest.name), n = await Ci({
|
|
3060
3235
|
manifest: e.manifest,
|
|
3061
|
-
config:
|
|
3236
|
+
config: f,
|
|
3062
3237
|
projectRoot: r,
|
|
3063
3238
|
force: i,
|
|
3064
|
-
|
|
3239
|
+
overwrite: a,
|
|
3240
|
+
packDir: e.packDir,
|
|
3241
|
+
slots: t
|
|
3065
3242
|
});
|
|
3066
|
-
|
|
3243
|
+
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await Ti(f, e.manifest.name, r), d.push(e.manifest.name);
|
|
3067
3244
|
}
|
|
3068
3245
|
return {
|
|
3069
|
-
installed:
|
|
3070
|
-
skipped:
|
|
3071
|
-
errors:
|
|
3072
|
-
appliedPacks:
|
|
3246
|
+
installed: c,
|
|
3247
|
+
skipped: l,
|
|
3248
|
+
errors: u,
|
|
3249
|
+
appliedPacks: d,
|
|
3073
3250
|
aborted: !1,
|
|
3074
|
-
config:
|
|
3251
|
+
config: f
|
|
3075
3252
|
};
|
|
3076
3253
|
}
|
|
3077
|
-
async function
|
|
3254
|
+
async function Ti(e, t, n) {
|
|
3078
3255
|
let r = {
|
|
3079
3256
|
...e,
|
|
3080
3257
|
installedPacks: [...e.installedPacks ?? [], t]
|
|
3081
3258
|
};
|
|
3082
|
-
return await
|
|
3259
|
+
return await ir(n, r), r;
|
|
3083
3260
|
}
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
let
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
continue;
|
|
3097
|
-
}
|
|
3098
|
-
let o = [];
|
|
3099
|
-
for (let [e, t] of Object.entries(a)) {
|
|
3100
|
-
let r = t.trim();
|
|
3101
|
-
if (!r) {
|
|
3102
|
-
n.push(`Empty version range for npm package "${e}" under dependencies_npm.${i}.`);
|
|
3103
|
-
continue;
|
|
3104
|
-
}
|
|
3105
|
-
o.push(`${e}@${r}`);
|
|
3106
|
-
}
|
|
3107
|
-
o.length > 0 && r.push({
|
|
3108
|
-
relativeDir: e.root,
|
|
3109
|
-
specs: o
|
|
3261
|
+
async function Ei(e) {
|
|
3262
|
+
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3263
|
+
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'hype-stack init' to set it up.");
|
|
3264
|
+
let o = [], s = [];
|
|
3265
|
+
for (let e of t.files) {
|
|
3266
|
+
let t = await bi({
|
|
3267
|
+
file: e,
|
|
3268
|
+
packDir: i,
|
|
3269
|
+
paths: a,
|
|
3270
|
+
projectRoot: r,
|
|
3271
|
+
force: !0,
|
|
3272
|
+
overwrite: /* @__PURE__ */ new Set()
|
|
3110
3273
|
});
|
|
3274
|
+
switch (t.status) {
|
|
3275
|
+
case "installed":
|
|
3276
|
+
o.push(t.path);
|
|
3277
|
+
break;
|
|
3278
|
+
case "error":
|
|
3279
|
+
s.push(`${t.path}: ${t.reason}`);
|
|
3280
|
+
break;
|
|
3281
|
+
case "skipped": break;
|
|
3282
|
+
}
|
|
3111
3283
|
}
|
|
3112
|
-
return {
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
}
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3284
|
+
return t.frontendRoutes && t.frontendRoutes.length > 0 && await Vr(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await Gr({
|
|
3285
|
+
entries: t.nav,
|
|
3286
|
+
paths: a,
|
|
3287
|
+
projectRoot: r
|
|
3288
|
+
}), t.postLoginRedirect && await Kr({
|
|
3289
|
+
postLoginRedirect: t.postLoginRedirect,
|
|
3290
|
+
paths: a,
|
|
3291
|
+
projectRoot: r
|
|
3292
|
+
}), {
|
|
3293
|
+
installed: o,
|
|
3294
|
+
errors: s
|
|
3122
3295
|
};
|
|
3123
|
-
return t;
|
|
3124
3296
|
}
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3297
|
+
//#endregion
|
|
3298
|
+
//#region src/core/pack-categories.ts
|
|
3299
|
+
var Di = [
|
|
3300
|
+
"starter",
|
|
3301
|
+
"layout",
|
|
3302
|
+
"feature"
|
|
3303
|
+
], Oi = {
|
|
3304
|
+
starter: "Starter",
|
|
3305
|
+
layout: "Layout",
|
|
3306
|
+
feature: "Features"
|
|
3307
|
+
}, ki = new Set(["starter", "layout"]), Ai = "layout-basic";
|
|
3308
|
+
function ji(e, t = {}) {
|
|
3309
|
+
let n = [];
|
|
3310
|
+
for (let r of Di) {
|
|
3311
|
+
let i = e.filter((e) => e.category === r);
|
|
3312
|
+
if (i.length === 0) continue;
|
|
3313
|
+
let a = ki.has(r) ? "single" : "multiple";
|
|
3314
|
+
if (r === "layout") {
|
|
3315
|
+
n.push(Mi("frontend", i)), t.adminAvailable && n.push(Mi("admin", i));
|
|
3144
3316
|
continue;
|
|
3145
3317
|
}
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3318
|
+
n.push({
|
|
3319
|
+
category: r,
|
|
3320
|
+
label: Oi[r],
|
|
3321
|
+
mode: a,
|
|
3322
|
+
packs: i,
|
|
3323
|
+
preselect: null
|
|
3324
|
+
});
|
|
3150
3325
|
}
|
|
3326
|
+
return n;
|
|
3327
|
+
}
|
|
3328
|
+
function Mi(e, t) {
|
|
3329
|
+
let n = t.some((e) => e.name === Ai);
|
|
3151
3330
|
return {
|
|
3152
|
-
|
|
3153
|
-
|
|
3331
|
+
category: "layout",
|
|
3332
|
+
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3333
|
+
mode: "single",
|
|
3334
|
+
packs: t,
|
|
3335
|
+
preselect: n ? Ai : null,
|
|
3336
|
+
slot: e
|
|
3154
3337
|
};
|
|
3155
3338
|
}
|
|
3156
3339
|
//#endregion
|
|
3157
3340
|
//#region src/core/resolve.ts
|
|
3158
|
-
function
|
|
3341
|
+
function Ni(e) {
|
|
3159
3342
|
let t = /* @__PURE__ */ new Map();
|
|
3160
3343
|
for (let n of e) t.set(n.name, {
|
|
3161
3344
|
name: n.name,
|
|
@@ -3163,7 +3346,7 @@ function li(e) {
|
|
|
3163
3346
|
});
|
|
3164
3347
|
return t;
|
|
3165
3348
|
}
|
|
3166
|
-
function
|
|
3349
|
+
function Pi(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3167
3350
|
let r = /* @__PURE__ */ new Set();
|
|
3168
3351
|
function i(e) {
|
|
3169
3352
|
if (n.has(e)) return [];
|
|
@@ -3177,10 +3360,10 @@ function ui(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3177
3360
|
}
|
|
3178
3361
|
return i(e);
|
|
3179
3362
|
}
|
|
3180
|
-
function
|
|
3363
|
+
function Fi(e, t, n = []) {
|
|
3181
3364
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3182
3365
|
for (let n of e) {
|
|
3183
|
-
let e =
|
|
3366
|
+
let e = Pi(n, t, new Set(i));
|
|
3184
3367
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3185
3368
|
}
|
|
3186
3369
|
return {
|
|
@@ -3188,7 +3371,7 @@ function di(e, t, n = []) {
|
|
|
3188
3371
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3189
3372
|
};
|
|
3190
3373
|
}
|
|
3191
|
-
function
|
|
3374
|
+
function Ii(e) {
|
|
3192
3375
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3193
3376
|
for (let e of t) {
|
|
3194
3377
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3200,297 +3383,175 @@ function fi(e) {
|
|
|
3200
3383
|
};
|
|
3201
3384
|
}
|
|
3202
3385
|
//#endregion
|
|
3386
|
+
//#region src/core/variants.ts
|
|
3387
|
+
function Li(e, t = {}) {
|
|
3388
|
+
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3389
|
+
for (let i of e) {
|
|
3390
|
+
let e = t[i.family] ?? i.default;
|
|
3391
|
+
n.set(i.family, e);
|
|
3392
|
+
for (let e of i.variants) r.set(e, i.family);
|
|
3393
|
+
}
|
|
3394
|
+
return {
|
|
3395
|
+
chosen: n,
|
|
3396
|
+
familyOf: r
|
|
3397
|
+
};
|
|
3398
|
+
}
|
|
3399
|
+
function Ri(e, t, n) {
|
|
3400
|
+
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3401
|
+
}
|
|
3402
|
+
function zi(e, t) {
|
|
3403
|
+
let n = t.familyOf.get(e);
|
|
3404
|
+
return n ? t.chosen.get(n) ?? e : e;
|
|
3405
|
+
}
|
|
3406
|
+
function Bi(e, t) {
|
|
3407
|
+
let n = /* @__PURE__ */ new Map();
|
|
3408
|
+
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3409
|
+
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
3410
|
+
for (let [e, t] of n) if (r.has(e)) {
|
|
3411
|
+
if (i.has(t)) {
|
|
3412
|
+
i.delete(t);
|
|
3413
|
+
continue;
|
|
3414
|
+
}
|
|
3415
|
+
i.set(t, e);
|
|
3416
|
+
}
|
|
3417
|
+
return {
|
|
3418
|
+
chosen: i,
|
|
3419
|
+
familyOf: n
|
|
3420
|
+
};
|
|
3421
|
+
}
|
|
3422
|
+
function Vi(e, t) {
|
|
3423
|
+
return e.map((e) => ({
|
|
3424
|
+
...e,
|
|
3425
|
+
dependencies: e.dependencies.map((e) => zi(e, t))
|
|
3426
|
+
}));
|
|
3427
|
+
}
|
|
3428
|
+
//#endregion
|
|
3203
3429
|
//#region src/ui/banner.ts
|
|
3204
|
-
var
|
|
3430
|
+
var Hi = [
|
|
3205
3431
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3206
3432
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3207
3433
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3208
3434
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3209
3435
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3210
3436
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3211
|
-
],
|
|
3437
|
+
], Ui = [
|
|
3212
3438
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3213
3439
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3214
3440
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3215
3441
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3216
3442
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3217
3443
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3218
|
-
]
|
|
3219
|
-
|
|
3444
|
+
], Wi = [
|
|
3445
|
+
253,
|
|
3446
|
+
176,
|
|
3447
|
+
21
|
|
3448
|
+
], Gi = [
|
|
3449
|
+
245,
|
|
3450
|
+
76,
|
|
3451
|
+
2
|
|
3452
|
+
], Ki = 5, qi = [
|
|
3453
|
+
17,
|
|
3454
|
+
103,
|
|
3455
|
+
248
|
|
3456
|
+
], Ji = [
|
|
3457
|
+
42,
|
|
3458
|
+
160,
|
|
3459
|
+
250
|
|
3460
|
+
], Yi = .2;
|
|
3461
|
+
function Xi() {
|
|
3220
3462
|
console.log();
|
|
3221
|
-
for (let e of
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3463
|
+
for (let e of de(Hi, {
|
|
3464
|
+
start: Wi,
|
|
3465
|
+
end: Gi,
|
|
3466
|
+
angle: Ki
|
|
3467
|
+
})) console.log(s.bold(e));
|
|
3468
|
+
for (let e of de(Ui, {
|
|
3469
|
+
start: qi,
|
|
3470
|
+
end: Ji,
|
|
3471
|
+
angle: Yi
|
|
3472
|
+
})) console.log(s.bold(e));
|
|
3473
|
+
console.log(), console.log(` ${R.spark} ${s.dim("v" + S)} ${s.dim("·")} ${le("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3474
|
+
}
|
|
3475
|
+
function X() {
|
|
3476
|
+
console.log(), console.log(` ${R.bolt} ${se.orange("Hype")}${se.skyBlue("Stack")} ${s.dim("v" + S)}`), console.log();
|
|
3227
3477
|
}
|
|
3228
3478
|
//#endregion
|
|
3229
3479
|
//#region src/ui/logger.ts
|
|
3230
|
-
function
|
|
3231
|
-
|
|
3480
|
+
function Zi(e) {
|
|
3481
|
+
a.note(e.map((e) => `${R.arrow} ${e}`).join("\n"), "Next steps");
|
|
3232
3482
|
}
|
|
3233
|
-
function
|
|
3234
|
-
|
|
3483
|
+
function Z() {
|
|
3484
|
+
a.cancel(L.muted("Operation cancelled.")), process.exit(0);
|
|
3235
3485
|
}
|
|
3236
3486
|
//#endregion
|
|
3237
|
-
//#region src/
|
|
3238
|
-
async function
|
|
3239
|
-
let
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
if (!r) {
|
|
3260
|
-
let e = Object.entries(i.apps), n = Object.entries(i.packages);
|
|
3261
|
-
if (e.length > 0) {
|
|
3262
|
-
t.log.info(I.bold("Detected apps:"));
|
|
3263
|
-
for (let [n, r] of e) t.log.message(` ${L.arrow} ${I.highlight(n)} ${I.muted(`→ ${r}`)}`);
|
|
3264
|
-
}
|
|
3265
|
-
if (n.length > 0) {
|
|
3266
|
-
t.log.info(I.bold("Detected packages:"));
|
|
3267
|
-
for (let [e, r] of n) t.log.message(` ${L.arrow} ${I.highlight(e)} ${I.muted(`→ ${r}`)}`);
|
|
3268
|
-
}
|
|
3269
|
-
e.length === 0 && n.length === 0 && t.log.warn("No apps or packages detected in the workspace.");
|
|
3487
|
+
//#region src/core/clone.ts
|
|
3488
|
+
async function Qi(e) {
|
|
3489
|
+
let t = await f(C, {
|
|
3490
|
+
dir: e,
|
|
3491
|
+
force: !0
|
|
3492
|
+
});
|
|
3493
|
+
return {
|
|
3494
|
+
dir: t.dir,
|
|
3495
|
+
source: t.source
|
|
3496
|
+
};
|
|
3497
|
+
}
|
|
3498
|
+
//#endregion
|
|
3499
|
+
//#region src/core/apply-theme.ts
|
|
3500
|
+
function $i(e, t) {
|
|
3501
|
+
let n = e.indexOf(t);
|
|
3502
|
+
if (n === -1) return null;
|
|
3503
|
+
let r = e.indexOf("{", n);
|
|
3504
|
+
if (r === -1) return null;
|
|
3505
|
+
let i = 1, a = r + 1;
|
|
3506
|
+
for (; a < e.length && i > 0;) {
|
|
3507
|
+
let t = e[a];
|
|
3508
|
+
t === "{" ? i++ : t === "}" && i--, a++;
|
|
3270
3509
|
}
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3510
|
+
return i === 0 ? {
|
|
3511
|
+
bodyStart: r + 1,
|
|
3512
|
+
bodyEnd: a - 1
|
|
3513
|
+
} : null;
|
|
3514
|
+
}
|
|
3515
|
+
function ea(e, t) {
|
|
3516
|
+
let n = e;
|
|
3517
|
+
for (let [e, r] of Object.entries(t)) {
|
|
3518
|
+
let t = RegExp(`(^[ \\t]*--${ta(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3519
|
+
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3279
3520
|
}
|
|
3280
|
-
|
|
3521
|
+
return n;
|
|
3281
3522
|
}
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
cwd: e,
|
|
3285
|
-
silent: !1
|
|
3286
|
-
}));
|
|
3523
|
+
function ta(e) {
|
|
3524
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3287
3525
|
}
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
let i = await Jn(r);
|
|
3294
|
-
i || (t.cancel("Could not load stack.json. Run 'hype-stack init' first."), process.exit(1)), i.paths || (t.cancel("stack.json is missing `paths`. Run 'hype-stack init' again to regenerate it."), process.exit(1));
|
|
3295
|
-
let a = t.spinner();
|
|
3296
|
-
a.start("Loading packs...");
|
|
3297
|
-
let o;
|
|
3298
|
-
try {
|
|
3299
|
-
o = await or();
|
|
3300
|
-
} catch (e) {
|
|
3301
|
-
a.stop("Failed to load packs"), t.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${xi(e)}`), process.exit(1);
|
|
3302
|
-
}
|
|
3303
|
-
a.stop("Packs loaded");
|
|
3304
|
-
let s = i.installedPacks ?? [], c = new Set(s), l = new Map(o.map((e) => [e.name, e])), u = e.licenseKey ?? process.env.HYPE_STACK_LICENSE_KEY ?? i.licenseKey ?? null, d = (await kn(k()))?.token ?? null, f = await Si(o, c, {
|
|
3305
|
-
token: d,
|
|
3306
|
-
key: u
|
|
3307
|
-
}), p = (e) => {
|
|
3308
|
-
let t = l.get(e);
|
|
3309
|
-
return !t || t.tier === "free" ? "free" : f[e]?.owned ? "owned" : "locked";
|
|
3310
|
-
}, m = (e) => !c.has(e) && p(e) === "locked", h = await wi({
|
|
3311
|
-
packs: o,
|
|
3312
|
-
installedSet: c,
|
|
3313
|
-
stateOf: p,
|
|
3314
|
-
options: e
|
|
3315
|
-
});
|
|
3316
|
-
if (h === null && (t.cancel("Cancelled."), process.exit(0)), h.length === 0) {
|
|
3317
|
-
t.outro(I.muted("No packs selected. Nothing to do."));
|
|
3318
|
-
return;
|
|
3526
|
+
function na(e, t) {
|
|
3527
|
+
let n = $i(e, ":root"), r = $i(e, ".dark"), i = e;
|
|
3528
|
+
if (n) {
|
|
3529
|
+
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3530
|
+
i = e + ea(r, t.light) + a;
|
|
3319
3531
|
}
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3532
|
+
if (r) {
|
|
3533
|
+
let e = $i(i, ".dark");
|
|
3534
|
+
if (e) {
|
|
3535
|
+
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3536
|
+
i = n + ea(r, t.dark) + a;
|
|
3537
|
+
}
|
|
3325
3538
|
}
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3539
|
+
return i;
|
|
3540
|
+
}
|
|
3541
|
+
var ra = "assets/styles.css";
|
|
3542
|
+
async function ia(e, t) {
|
|
3543
|
+
let n = l.resolve(e, ra), r;
|
|
3544
|
+
try {
|
|
3545
|
+
r = await o.readFile(n, "utf-8");
|
|
3546
|
+
} catch {
|
|
3547
|
+
return !1;
|
|
3329
3548
|
}
|
|
3330
|
-
let
|
|
3331
|
-
|
|
3332
|
-
graph: g,
|
|
3333
|
-
isLocked: m,
|
|
3334
|
-
installed: s
|
|
3335
|
-
});
|
|
3336
|
-
if (v.blocked.length > 0 && !d && !u) {
|
|
3337
|
-
let e = await zn();
|
|
3338
|
-
e && (d = e, f = await Si(o, c, {
|
|
3339
|
-
token: d,
|
|
3340
|
-
key: u
|
|
3341
|
-
}), v = fi({
|
|
3342
|
-
order: _.order,
|
|
3343
|
-
graph: g,
|
|
3344
|
-
isLocked: m,
|
|
3345
|
-
installed: s
|
|
3346
|
-
}));
|
|
3347
|
-
}
|
|
3348
|
-
if (v.blocked.length > 0 && await Ti(v.blocked, m, l), v.installable.length === 0) {
|
|
3349
|
-
t.outro(I.muted("Nothing left to install once locked packs are removed."));
|
|
3350
|
-
return;
|
|
3351
|
-
}
|
|
3352
|
-
if (Ei(v.installable, l), !e.yes) {
|
|
3353
|
-
let e = await t.confirm({ message: `Install ${v.installable.length} pack${v.installable.length === 1 ? "" : "s"}?` });
|
|
3354
|
-
(t.isCancel(e) || !e) && (t.cancel("Installation cancelled."), process.exit(0));
|
|
3355
|
-
}
|
|
3356
|
-
a.start("Downloading packs...");
|
|
3357
|
-
let y;
|
|
3358
|
-
try {
|
|
3359
|
-
y = await Di(v.installable, {
|
|
3360
|
-
token: d,
|
|
3361
|
-
key: u
|
|
3362
|
-
});
|
|
3363
|
-
} catch (e) {
|
|
3364
|
-
a.stop("Download failed"), t.cancel(xi(e)), process.exit(1);
|
|
3365
|
-
}
|
|
3366
|
-
a.stop(`Downloaded ${y.length} pack${y.length === 1 ? "" : "s"}`);
|
|
3367
|
-
try {
|
|
3368
|
-
a.start("Installing pack files...");
|
|
3369
|
-
let n = await ii({
|
|
3370
|
-
packs: y,
|
|
3371
|
-
config: i,
|
|
3372
|
-
projectRoot: r,
|
|
3373
|
-
force: e.force ?? !1
|
|
3374
|
-
});
|
|
3375
|
-
if (n.aborted) {
|
|
3376
|
-
a.stop("Installation aborted");
|
|
3377
|
-
for (let e of n.errors) t.log.error(e);
|
|
3378
|
-
t.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
3379
|
-
}
|
|
3380
|
-
a.stop("Files installed"), n.installed.length > 0 && t.log.success(`${I.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && t.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`);
|
|
3381
|
-
for (let e of n.errors) t.log.error(e);
|
|
3382
|
-
await Oi({
|
|
3383
|
-
prepared: y,
|
|
3384
|
-
paths: i.paths,
|
|
3385
|
-
cwd: r,
|
|
3386
|
-
spinner: a
|
|
3387
|
-
}), await qn({
|
|
3388
|
-
projectRoot: r,
|
|
3389
|
-
paths: i.paths,
|
|
3390
|
-
skipPrompts: e.yes ?? !1
|
|
3391
|
-
}), ki(y), t.outro(I.brand(`Installed ${n.appliedPacks.join(", ")}.`));
|
|
3392
|
-
} finally {
|
|
3393
|
-
await Promise.all(y.map((e) => n.rm(e.packDir, {
|
|
3394
|
-
recursive: !0,
|
|
3395
|
-
force: !0
|
|
3396
|
-
})));
|
|
3397
|
-
}
|
|
3398
|
-
}
|
|
3399
|
-
function xi(e) {
|
|
3400
|
-
return e instanceof Error ? e.message : String(e);
|
|
3401
|
-
}
|
|
3402
|
-
async function Si(e, t, n) {
|
|
3403
|
-
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
3404
|
-
return r.length === 0 ? {} : sr(r, n).catch(() => ({}));
|
|
3405
|
-
}
|
|
3406
|
-
function Ci(e, t) {
|
|
3407
|
-
return e === "free" ? I.success("free") : e === "owned" ? I.accent("owned") : `${I.highlight(`$${t}`)} ${I.muted("locked")}`;
|
|
3408
|
-
}
|
|
3409
|
-
async function wi(e) {
|
|
3410
|
-
let { packs: n, installedSet: r, stateOf: i, options: a } = e;
|
|
3411
|
-
if (a.packs && a.packs.length > 0) {
|
|
3412
|
-
let e = a.packs.filter((e) => !n.some((t) => t.name === e));
|
|
3413
|
-
return e.length > 0 && (t.cancel(`Unknown pack${e.length === 1 ? "" : "s"}: ${e.join(", ")}`), process.exit(1)), a.packs;
|
|
3414
|
-
}
|
|
3415
|
-
let o = n.filter((e) => r.has(e.name));
|
|
3416
|
-
o.length > 0 && t.note(o.map((e) => ` ${I.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
3417
|
-
let s = n.filter((e) => !r.has(e.name));
|
|
3418
|
-
if (s.length === 0) return t.outro(I.muted("Every available pack is already installed.")), [];
|
|
3419
|
-
let c = await t.multiselect({
|
|
3420
|
-
message: "Select packs to add (free packs install without an account)",
|
|
3421
|
-
options: s.map((e) => {
|
|
3422
|
-
let t = i(e.name);
|
|
3423
|
-
return {
|
|
3424
|
-
value: e.name,
|
|
3425
|
-
label: `${e.displayName} ${Ci(t, e.price)}`,
|
|
3426
|
-
hint: e.description
|
|
3427
|
-
};
|
|
3428
|
-
}),
|
|
3429
|
-
required: !1
|
|
3430
|
-
});
|
|
3431
|
-
return t.isCancel(c) ? null : c;
|
|
3432
|
-
}
|
|
3433
|
-
async function Ti(e, n, r) {
|
|
3434
|
-
let i = e.filter((e) => n(e)), a = e.filter((e) => !n(e));
|
|
3435
|
-
a.length > 0 && t.log.warning(`Skipping ${a.join(", ")} because ${a.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await Bn(i.map((e) => r.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
3436
|
-
name: e.name,
|
|
3437
|
-
displayName: e.displayName,
|
|
3438
|
-
price: e.price
|
|
3439
|
-
})));
|
|
3440
|
-
}
|
|
3441
|
-
function Ei(e, n) {
|
|
3442
|
-
let r = e.map((e, t) => {
|
|
3443
|
-
let r = n.get(e), i = r ? r.displayName : e;
|
|
3444
|
-
return ` ${I.muted(`${t + 1}.`)} ${I.brand(i)}`;
|
|
3445
|
-
});
|
|
3446
|
-
t.note([
|
|
3447
|
-
"These packs will be installed, in order:",
|
|
3448
|
-
"",
|
|
3449
|
-
...r
|
|
3450
|
-
].join("\n"), "Install Plan");
|
|
3451
|
-
}
|
|
3452
|
-
async function Di(e, t) {
|
|
3453
|
-
let n = [];
|
|
3454
|
-
for (let r of e) {
|
|
3455
|
-
let e = await tr(r), i = await nr(r, t);
|
|
3456
|
-
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'hype-stack login' or check your license.`);
|
|
3457
|
-
n.push({
|
|
3458
|
-
manifest: e,
|
|
3459
|
-
packDir: i.packDir
|
|
3460
|
-
});
|
|
3461
|
-
}
|
|
3462
|
-
return n;
|
|
3463
|
-
}
|
|
3464
|
-
async function Oi(e) {
|
|
3465
|
-
let { prepared: n, paths: r, cwd: i, spinner: a } = e, o = oi(si(n.map((e) => e.manifest.dependencies_npm)), r);
|
|
3466
|
-
if (o.errors.length > 0) {
|
|
3467
|
-
for (let e of o.errors) t.log.error(e);
|
|
3468
|
-
return;
|
|
3469
|
-
}
|
|
3470
|
-
if (o.operations.length === 0) return;
|
|
3471
|
-
a.start("Installing npm dependencies...");
|
|
3472
|
-
let s = await ci(o.operations, i);
|
|
3473
|
-
if (a.stop(s.ok ? "npm dependencies installed" : "npm dependency installation failed"), !s.ok) for (let e of s.errors) t.log.error(e);
|
|
3474
|
-
}
|
|
3475
|
-
function ki(e) {
|
|
3476
|
-
let n = e.flatMap((e) => e.manifest.postInstall ?? []), r = [...new Set(n)];
|
|
3477
|
-
r.length !== 0 && t.note(r.map((e) => ` ${I.muted("→")} ${e}`).join("\n"), "Next Steps");
|
|
3478
|
-
}
|
|
3479
|
-
//#endregion
|
|
3480
|
-
//#region src/core/clone.ts
|
|
3481
|
-
async function Ai(e) {
|
|
3482
|
-
let t = await c(y, {
|
|
3483
|
-
dir: e,
|
|
3484
|
-
force: !0
|
|
3485
|
-
});
|
|
3486
|
-
return {
|
|
3487
|
-
dir: t.dir,
|
|
3488
|
-
source: t.source
|
|
3489
|
-
};
|
|
3549
|
+
let i = na(r, t);
|
|
3550
|
+
return i === r || await o.writeFile(n, i, "utf-8"), !0;
|
|
3490
3551
|
}
|
|
3491
3552
|
//#endregion
|
|
3492
3553
|
//#region src/core/editor-config.ts
|
|
3493
|
-
function
|
|
3554
|
+
function aa(e) {
|
|
3494
3555
|
let t = {
|
|
3495
3556
|
globs: [],
|
|
3496
3557
|
alwaysApply: !1
|
|
@@ -3525,10 +3586,10 @@ function ji(e) {
|
|
|
3525
3586
|
content: i
|
|
3526
3587
|
};
|
|
3527
3588
|
}
|
|
3528
|
-
function
|
|
3589
|
+
function oa(e) {
|
|
3529
3590
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
3530
3591
|
}
|
|
3531
|
-
function
|
|
3592
|
+
function sa(e) {
|
|
3532
3593
|
let t;
|
|
3533
3594
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
3534
3595
|
let n = [`trigger: ${t}`];
|
|
@@ -3538,164 +3599,164 @@ function Ni(e) {
|
|
|
3538
3599
|
}
|
|
3539
3600
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
3540
3601
|
}
|
|
3541
|
-
function
|
|
3602
|
+
function ca(e) {
|
|
3542
3603
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
3543
3604
|
}
|
|
3544
|
-
var
|
|
3605
|
+
var la = {
|
|
3545
3606
|
claude: {
|
|
3546
3607
|
rulesDir: ".claude/rules",
|
|
3547
3608
|
extension: ".md",
|
|
3548
|
-
convert:
|
|
3609
|
+
convert: oa
|
|
3549
3610
|
},
|
|
3550
3611
|
windsurf: {
|
|
3551
3612
|
rulesDir: ".windsurf/rules",
|
|
3552
3613
|
extension: ".md",
|
|
3553
|
-
convert:
|
|
3614
|
+
convert: sa
|
|
3554
3615
|
},
|
|
3555
3616
|
copilot: {
|
|
3556
3617
|
rulesDir: ".github/instructions",
|
|
3557
3618
|
extension: ".instructions.md",
|
|
3558
|
-
convert:
|
|
3619
|
+
convert: ca
|
|
3559
3620
|
}
|
|
3560
3621
|
};
|
|
3561
|
-
async function
|
|
3562
|
-
let t =
|
|
3563
|
-
return await Promise.all(
|
|
3564
|
-
let
|
|
3622
|
+
async function ua(e) {
|
|
3623
|
+
let t = l.join(e, A), n = (await o.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
3624
|
+
return await Promise.all(n.map(async (e) => {
|
|
3625
|
+
let n = l.join(t, e.name), { frontmatter: r, content: i } = aa(await o.readFile(n, "utf-8"));
|
|
3565
3626
|
return {
|
|
3566
|
-
frontmatter:
|
|
3567
|
-
content:
|
|
3627
|
+
frontmatter: r,
|
|
3628
|
+
content: i,
|
|
3568
3629
|
filename: e.name
|
|
3569
3630
|
};
|
|
3570
3631
|
}));
|
|
3571
3632
|
}
|
|
3572
|
-
async function
|
|
3633
|
+
async function da(e, t) {
|
|
3573
3634
|
if (t === "cursor") return;
|
|
3574
|
-
let
|
|
3575
|
-
await
|
|
3576
|
-
let t =
|
|
3577
|
-
return
|
|
3578
|
-
})), await
|
|
3635
|
+
let n = la[t], r = await ua(e), i = l.join(e, n.rulesDir);
|
|
3636
|
+
await o.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
3637
|
+
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3638
|
+
return o.writeFile(l.join(i, r), t, "utf-8");
|
|
3639
|
+
})), await $n(l.join(e, j)), await $n(l.join(e, te));
|
|
3579
3640
|
}
|
|
3580
3641
|
//#endregion
|
|
3581
3642
|
//#region src/core/env-files.ts
|
|
3582
|
-
var
|
|
3643
|
+
var fa = [
|
|
3583
3644
|
"apps",
|
|
3584
3645
|
"packages",
|
|
3585
3646
|
"libs",
|
|
3586
3647
|
"shared"
|
|
3587
3648
|
];
|
|
3588
|
-
async function
|
|
3589
|
-
let t = await
|
|
3649
|
+
async function pa(e) {
|
|
3650
|
+
let t = await ma(e);
|
|
3590
3651
|
return (await Promise.all(t.map(async (t) => {
|
|
3591
|
-
let
|
|
3592
|
-
return await
|
|
3652
|
+
let n = l.join(l.dirname(t), ".env");
|
|
3653
|
+
return await J(n) ? null : (await o.copyFile(t, n), l.relative(e, n));
|
|
3593
3654
|
}))).filter((e) => e !== null).sort();
|
|
3594
3655
|
}
|
|
3595
|
-
async function
|
|
3596
|
-
let t = [
|
|
3597
|
-
let
|
|
3598
|
-
return (await
|
|
3656
|
+
async function ma(e) {
|
|
3657
|
+
let t = [l.join(e, ".env.example")], n = await Promise.all(fa.map(async (t) => {
|
|
3658
|
+
let n = l.join(e, t);
|
|
3659
|
+
return (await o.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => l.join(n, e.name, ".env.example"));
|
|
3599
3660
|
}));
|
|
3600
|
-
return t.push(...
|
|
3661
|
+
return t.push(...n.flat()), (await Promise.all(t.map(async (e) => await J(e) ? e : null))).filter((e) => e !== null);
|
|
3601
3662
|
}
|
|
3602
3663
|
//#endregion
|
|
3603
3664
|
//#region src/core/post-clone.ts
|
|
3604
|
-
var
|
|
3605
|
-
async function
|
|
3606
|
-
await
|
|
3665
|
+
var Q = "@hype-stack/", ha = "hype-stack";
|
|
3666
|
+
async function ga(e) {
|
|
3667
|
+
await $n(l.join(e, ".git"));
|
|
3607
3668
|
}
|
|
3608
|
-
async function
|
|
3609
|
-
await
|
|
3669
|
+
async function _a(e) {
|
|
3670
|
+
await q("git", ["init"], { cwd: e }), await q("git", ["add", "."], { cwd: e }), await q("git", [
|
|
3610
3671
|
"-c",
|
|
3611
3672
|
"user.name=Hype Stack CLI",
|
|
3612
3673
|
"-c",
|
|
3613
|
-
"user.email=cli@
|
|
3674
|
+
"user.email=cli@hype-stack.dev",
|
|
3614
3675
|
"commit",
|
|
3615
3676
|
"-m",
|
|
3616
3677
|
"Initial commit from Hype Stack CLI"
|
|
3617
3678
|
], { cwd: e });
|
|
3618
3679
|
}
|
|
3619
|
-
async function
|
|
3620
|
-
let
|
|
3621
|
-
for (let e of
|
|
3622
|
-
let t = await
|
|
3680
|
+
async function va(e, t) {
|
|
3681
|
+
let n = `@${t}/`, r = await Sa(e);
|
|
3682
|
+
for (let e of r) {
|
|
3683
|
+
let t = await Xn(e);
|
|
3623
3684
|
if (!t) continue;
|
|
3624
|
-
let
|
|
3625
|
-
t.name?.startsWith(
|
|
3626
|
-
let
|
|
3627
|
-
if (
|
|
3628
|
-
let t =
|
|
3629
|
-
await
|
|
3630
|
-
} else
|
|
3685
|
+
let r = !1;
|
|
3686
|
+
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0), ya(t.dependencies, n) && (r = !0), ya(t.devDependencies, n) && (r = !0), t.nx && ba(t.nx, n) && (r = !0);
|
|
3687
|
+
let i = await o.readFile(e, "utf-8");
|
|
3688
|
+
if (i.includes(Q)) {
|
|
3689
|
+
let t = i.replaceAll(Q, n);
|
|
3690
|
+
await o.writeFile(e, t, "utf-8");
|
|
3691
|
+
} else r && await Zn(e, t);
|
|
3631
3692
|
}
|
|
3632
|
-
await
|
|
3693
|
+
await pi(e, t), await xa(e, t);
|
|
3633
3694
|
}
|
|
3634
|
-
function
|
|
3695
|
+
function ya(e, t) {
|
|
3635
3696
|
if (!e) return !1;
|
|
3636
3697
|
let n = !1;
|
|
3637
|
-
for (let r of Object.keys(e)) if (r.startsWith(
|
|
3638
|
-
let i = r.replace(
|
|
3698
|
+
for (let r of Object.keys(e)) if (r.startsWith(Q)) {
|
|
3699
|
+
let i = r.replace(Q, t);
|
|
3639
3700
|
e[i] = e[r], delete e[r], n = !0;
|
|
3640
3701
|
}
|
|
3641
3702
|
return n;
|
|
3642
3703
|
}
|
|
3643
|
-
function
|
|
3704
|
+
function ba(e, t) {
|
|
3644
3705
|
if (!e) return !1;
|
|
3645
3706
|
let n = !1;
|
|
3646
|
-
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(
|
|
3647
|
-
for (let r of Object.values(e.targets)) if (r.buildTarget?.includes(
|
|
3707
|
+
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Q) ? (n = !0, e.replace(Q, t)) : e), e.targets) {
|
|
3708
|
+
for (let r of Object.values(e.targets)) if (r.buildTarget?.includes(Q) && (r.buildTarget = r.buildTarget.replaceAll(Q, t), n = !0), r.dependsOn &&= r.dependsOn.map((e) => e.includes(Q) ? (n = !0, e.replaceAll(Q, t)) : e), r.configurations) for (let e of Object.values(r.configurations)) e.buildTarget?.includes(Q) && (e.buildTarget = e.buildTarget.replaceAll(Q, t), n = !0);
|
|
3648
3709
|
}
|
|
3649
3710
|
return n;
|
|
3650
3711
|
}
|
|
3651
|
-
async function
|
|
3652
|
-
let
|
|
3653
|
-
if (!
|
|
3654
|
-
let
|
|
3655
|
-
await
|
|
3712
|
+
async function xa(e, t) {
|
|
3713
|
+
let n = l.join(e, "packages/enums/src/app/index.ts"), r = await o.readFile(n, "utf-8").catch(() => null);
|
|
3714
|
+
if (!r) return;
|
|
3715
|
+
let i = t.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" "), a = r.replaceAll(`id: "${ha}"`, `id: "${t}"`).replaceAll(`name: "${ha}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
|
|
3716
|
+
await o.writeFile(n, a, "utf-8");
|
|
3656
3717
|
}
|
|
3657
|
-
async function
|
|
3658
|
-
let t = [],
|
|
3659
|
-
(await
|
|
3660
|
-
for (let
|
|
3718
|
+
async function Sa(e) {
|
|
3719
|
+
let t = [], n = l.join(e, "package.json");
|
|
3720
|
+
(await o.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
3721
|
+
for (let n of [
|
|
3661
3722
|
"apps",
|
|
3662
3723
|
"packages",
|
|
3663
3724
|
"libs",
|
|
3664
3725
|
"shared"
|
|
3665
3726
|
]) {
|
|
3666
|
-
let
|
|
3667
|
-
for (let e of
|
|
3727
|
+
let r = l.join(e, n), i = await o.readdir(r, { withFileTypes: !0 }).catch(() => []);
|
|
3728
|
+
for (let e of i) {
|
|
3668
3729
|
if (!e.isDirectory()) continue;
|
|
3669
|
-
let
|
|
3670
|
-
(await
|
|
3730
|
+
let n = l.join(r, e.name, "package.json");
|
|
3731
|
+
(await o.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
3671
3732
|
}
|
|
3672
3733
|
}
|
|
3673
3734
|
return t;
|
|
3674
3735
|
}
|
|
3675
3736
|
//#endregion
|
|
3676
3737
|
//#region src/core/post-setup.ts
|
|
3677
|
-
async function
|
|
3678
|
-
return (await
|
|
3738
|
+
async function Ca() {
|
|
3739
|
+
return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3679
3740
|
}
|
|
3680
|
-
async function
|
|
3681
|
-
return
|
|
3741
|
+
async function wa(e) {
|
|
3742
|
+
return J(`${e}/apps/backend/.env`);
|
|
3682
3743
|
}
|
|
3683
|
-
async function
|
|
3684
|
-
let
|
|
3685
|
-
message:
|
|
3744
|
+
async function Ta(e, t, n) {
|
|
3745
|
+
let r = n ? `Start services with ${L.command("docker compose up -d")}?` : `Docker is not running. Start services with ${L.command("docker compose up -d")}?`, i = t ? !0 : await a.confirm({
|
|
3746
|
+
message: r,
|
|
3686
3747
|
initialValue: !0
|
|
3687
3748
|
});
|
|
3688
|
-
if (
|
|
3689
|
-
let o =
|
|
3690
|
-
return o.start("Starting Docker services..."), (await
|
|
3749
|
+
if (a.isCancel(i) && Z(), !i) return a.log.info(L.muted("Skipping Docker services and database migrations.")), !1;
|
|
3750
|
+
let o = a.spinner();
|
|
3751
|
+
return o.start("Starting Docker services..."), (await q("docker", [
|
|
3691
3752
|
"compose",
|
|
3692
3753
|
"up",
|
|
3693
3754
|
"-d"
|
|
3694
|
-
], { cwd: `${e}/apps/backend` })).exitCode === 0 ? (o.stop(
|
|
3755
|
+
], { cwd: `${e}/apps/backend` })).exitCode === 0 ? (o.stop(L.success("Docker services started")), !0) : (o.stop(L.warning("Failed to start Docker services")), a.log.warn(L.muted("Run `docker compose up -d` in apps/backend manually to start services.")), a.log.info(L.muted("Skipping database migrations.")), !1);
|
|
3695
3756
|
}
|
|
3696
|
-
async function
|
|
3757
|
+
async function Ea(e, t = 15, n = 2e3) {
|
|
3697
3758
|
for (let r = 0; r < t; r++) {
|
|
3698
|
-
if ((await
|
|
3759
|
+
if ((await q("docker", [
|
|
3699
3760
|
"compose",
|
|
3700
3761
|
"exec",
|
|
3701
3762
|
"-T",
|
|
@@ -3708,50 +3769,50 @@ async function Qi(e, t = 15, n = 2e3) {
|
|
|
3708
3769
|
}
|
|
3709
3770
|
return !1;
|
|
3710
3771
|
}
|
|
3711
|
-
async function
|
|
3712
|
-
if (!await
|
|
3713
|
-
|
|
3772
|
+
async function Da(e, t, n = {}) {
|
|
3773
|
+
if (!await wa(e)) {
|
|
3774
|
+
a.log.warn(`${L.path(".env")} not found in ${L.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3714
3775
|
return;
|
|
3715
3776
|
}
|
|
3716
|
-
if (!await
|
|
3717
|
-
let
|
|
3718
|
-
if (
|
|
3719
|
-
|
|
3777
|
+
if (!await Ta(e, t, await Ca())) return;
|
|
3778
|
+
let r = a.spinner();
|
|
3779
|
+
if (r.start("Waiting for Postgres to be ready..."), !await Ea(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3)) {
|
|
3780
|
+
r.stop(L.warning("Postgres health check timed out")), a.log.warn(L.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest"));
|
|
3720
3781
|
return;
|
|
3721
3782
|
}
|
|
3722
|
-
|
|
3723
|
-
let
|
|
3724
|
-
message: `Run database migrations with ${
|
|
3783
|
+
r.stop(L.success("Postgres is ready"));
|
|
3784
|
+
let i = t ? !0 : await a.confirm({
|
|
3785
|
+
message: `Run database migrations with ${L.command("prisma migrate deploy")}?`,
|
|
3725
3786
|
initialValue: !0
|
|
3726
3787
|
});
|
|
3727
|
-
if (
|
|
3728
|
-
|
|
3788
|
+
if (a.isCancel(i) && Z(), !i) {
|
|
3789
|
+
a.log.info(L.muted("Skipping database migrations."));
|
|
3729
3790
|
return;
|
|
3730
3791
|
}
|
|
3731
|
-
let o =
|
|
3732
|
-
if (o.start("Running database migrations..."), (await
|
|
3792
|
+
let o = a.spinner();
|
|
3793
|
+
if (o.start("Running database migrations..."), (await q("pnpm", [
|
|
3733
3794
|
"--filter",
|
|
3734
3795
|
"@internal/backend",
|
|
3735
3796
|
"migration:latest"
|
|
3736
3797
|
], { cwd: e })).exitCode !== 0) {
|
|
3737
|
-
o.stop(
|
|
3798
|
+
o.stop(L.warning("Migrations failed")), a.log.warn(L.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations."));
|
|
3738
3799
|
return;
|
|
3739
3800
|
}
|
|
3740
|
-
o.stop(
|
|
3741
|
-
let s =
|
|
3742
|
-
if (s.start("Generating Prisma client..."), (await
|
|
3801
|
+
o.stop(L.success("Database migrations applied"));
|
|
3802
|
+
let s = a.spinner();
|
|
3803
|
+
if (s.start("Generating Prisma client..."), (await q("pnpm", [
|
|
3743
3804
|
"--filter",
|
|
3744
3805
|
"@internal/backend",
|
|
3745
3806
|
"generate"
|
|
3746
3807
|
], { cwd: e })).exitCode !== 0) {
|
|
3747
|
-
s.stop(
|
|
3808
|
+
s.stop(L.warning("Prisma client generation failed")), a.log.warn(L.muted("Run `pnpm --filter @internal/backend generate` manually."));
|
|
3748
3809
|
return;
|
|
3749
3810
|
}
|
|
3750
|
-
s.stop(
|
|
3811
|
+
s.stop(L.success("Prisma client generated"));
|
|
3751
3812
|
}
|
|
3752
3813
|
//#endregion
|
|
3753
3814
|
//#region src/core/readme.ts
|
|
3754
|
-
var
|
|
3815
|
+
var Oa = {
|
|
3755
3816
|
cursor: {
|
|
3756
3817
|
label: "Cursor",
|
|
3757
3818
|
rulesDir: ".cursor/rules"
|
|
@@ -3768,28 +3829,28 @@ var ea = {
|
|
|
3768
3829
|
label: "GitHub Copilot",
|
|
3769
3830
|
rulesDir: ".github/instructions"
|
|
3770
3831
|
}
|
|
3771
|
-
},
|
|
3832
|
+
}, ka = {
|
|
3772
3833
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
3773
3834
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
3774
|
-
},
|
|
3835
|
+
}, Aa = {
|
|
3775
3836
|
enums: "Shared enums and app config used across apps",
|
|
3776
3837
|
cli: "Project tooling and code generators"
|
|
3777
3838
|
};
|
|
3778
|
-
function
|
|
3839
|
+
function ja(e) {
|
|
3779
3840
|
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3780
3841
|
}
|
|
3781
|
-
function
|
|
3842
|
+
function Ma(e, t) {
|
|
3782
3843
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
3783
3844
|
let r = t[e];
|
|
3784
3845
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
3785
3846
|
});
|
|
3786
3847
|
}
|
|
3787
|
-
function
|
|
3788
|
-
let { projectName: t, editor: n, workspace: r } = e, i =
|
|
3848
|
+
function Na(e) {
|
|
3849
|
+
let { projectName: t, editor: n, workspace: r } = e, i = ja(t), a = Oa[n], o = !!r.apps.backend, s = Ma(r.apps, ka), c = Ma(r.packages, Aa), l = [];
|
|
3789
3850
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
3790
3851
|
let u = [];
|
|
3791
3852
|
u.push(`# ${i}`), u.push([
|
|
3792
|
-
`${i} is built on [Hype Stack](https://
|
|
3853
|
+
`${i} is built on [Hype Stack](https://hype-stack.dev), a typed full stack template.`,
|
|
3793
3854
|
"The backend runs on Hono with Postgres, Prisma, and Kysely. The frontend is React + Vite and",
|
|
3794
3855
|
"talks to the API through a fully typed SDK, so types flow end to end with no manual wiring."
|
|
3795
3856
|
].join(" ")), u.push([
|
|
@@ -3893,164 +3954,892 @@ function aa(e) {
|
|
|
3893
3954
|
"stays useful."
|
|
3894
3955
|
].join("\n")), u.join("\n\n") + "\n";
|
|
3895
3956
|
}
|
|
3896
|
-
async function
|
|
3897
|
-
let
|
|
3898
|
-
await
|
|
3957
|
+
async function Pa(e, t) {
|
|
3958
|
+
let n = l.join(e, "README.md");
|
|
3959
|
+
await o.writeFile(n, Na(t), "utf-8");
|
|
3960
|
+
}
|
|
3961
|
+
//#endregion
|
|
3962
|
+
//#region src/core/tracking.ts
|
|
3963
|
+
async function Fa(e) {
|
|
3964
|
+
try {
|
|
3965
|
+
let t = {
|
|
3966
|
+
"X-Device-Id": Bn(),
|
|
3967
|
+
"X-Client-Info": Vn()
|
|
3968
|
+
}, n = await In(M()).catch(() => null);
|
|
3969
|
+
n?.token && (t.Authorization = `Bearer ${n.token}`), await K.createRequest()({
|
|
3970
|
+
endpoint: "/cli/track",
|
|
3971
|
+
method: "POST"
|
|
3972
|
+
}).setPayload({ event: e }).setHeaders(t).send();
|
|
3973
|
+
} catch {}
|
|
3899
3974
|
}
|
|
3900
3975
|
//#endregion
|
|
3901
3976
|
//#region src/utils/validate.ts
|
|
3902
|
-
function
|
|
3977
|
+
function Ia(e) {
|
|
3903
3978
|
if (!e.trim()) return "Project name cannot be empty";
|
|
3904
|
-
if (!
|
|
3979
|
+
if (!O.test(e)) return "Project name must be lowercase, alphanumeric, and may contain hyphens, dots, or underscores";
|
|
3905
3980
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
3906
3981
|
}
|
|
3907
3982
|
//#endregion
|
|
3908
3983
|
//#region src/commands/create.ts
|
|
3909
|
-
async function
|
|
3910
|
-
|
|
3911
|
-
let
|
|
3912
|
-
if (
|
|
3913
|
-
let
|
|
3914
|
-
|
|
3984
|
+
async function La(i) {
|
|
3985
|
+
Xi(), a.intro(L.brandBold("Create a new Hype Stack project"));
|
|
3986
|
+
let o = i.yes === !0, s;
|
|
3987
|
+
if (o && i.name) {
|
|
3988
|
+
let e = Ia(i.name);
|
|
3989
|
+
e && (a.log.error(e), Z()), s = i.name;
|
|
3915
3990
|
} else {
|
|
3916
|
-
let
|
|
3991
|
+
let e = await a.text({
|
|
3917
3992
|
message: "What is your project named?",
|
|
3918
3993
|
placeholder: "my-app",
|
|
3919
|
-
initialValue:
|
|
3920
|
-
validate: (e) =>
|
|
3994
|
+
initialValue: i.name ?? "",
|
|
3995
|
+
validate: (e) => Ia(e ?? "")
|
|
3921
3996
|
});
|
|
3922
|
-
|
|
3997
|
+
a.isCancel(e) && Z(), s = e;
|
|
3923
3998
|
}
|
|
3924
|
-
let
|
|
3925
|
-
if (
|
|
3999
|
+
let c;
|
|
4000
|
+
if (o) c = i.directory ?? `./${s}`;
|
|
3926
4001
|
else {
|
|
3927
|
-
let
|
|
4002
|
+
let e = await a.text({
|
|
3928
4003
|
message: "Where should we create it?",
|
|
3929
|
-
placeholder: `./${
|
|
3930
|
-
initialValue:
|
|
4004
|
+
placeholder: `./${s}`,
|
|
4005
|
+
initialValue: i.directory ?? `./${s}`
|
|
3931
4006
|
});
|
|
3932
|
-
|
|
4007
|
+
a.isCancel(e) && Z(), c = e;
|
|
3933
4008
|
}
|
|
3934
|
-
let
|
|
3935
|
-
if (
|
|
3936
|
-
else if (
|
|
4009
|
+
let u = i.editor && ee.includes(i.editor) ? i.editor : null, d;
|
|
4010
|
+
if (u) d = u;
|
|
4011
|
+
else if (o) d = "cursor";
|
|
3937
4012
|
else {
|
|
3938
|
-
let e = await
|
|
4013
|
+
let e = await a.select({
|
|
3939
4014
|
message: "Which code editor do you use?",
|
|
3940
|
-
options:
|
|
4015
|
+
options: k.map((e) => ({
|
|
3941
4016
|
value: e.value,
|
|
3942
4017
|
label: e.label,
|
|
3943
4018
|
hint: "hint" in e ? e.hint : void 0
|
|
3944
4019
|
})),
|
|
3945
4020
|
initialValue: "cursor"
|
|
3946
4021
|
});
|
|
3947
|
-
|
|
4022
|
+
a.isCancel(e) && Z(), d = e;
|
|
3948
4023
|
}
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
4024
|
+
let f = i.theme !== void 0 && r(i.theme), p;
|
|
4025
|
+
if (f) p = i.theme;
|
|
4026
|
+
else if (o) p = e;
|
|
4027
|
+
else {
|
|
4028
|
+
let n = await a.select({
|
|
4029
|
+
message: "Pick a color theme",
|
|
4030
|
+
options: t,
|
|
4031
|
+
initialValue: e
|
|
4032
|
+
});
|
|
4033
|
+
a.isCancel(n) && Z(), p = n;
|
|
4034
|
+
}
|
|
4035
|
+
if (!o) {
|
|
4036
|
+
let e = k.find((e) => e.value === d)?.label ?? d, n = t.find((e) => e.value === p)?.label ?? p, r = await a.confirm({ message: `Create ${L.highlight(s)} in ${L.path(c)} with ${L.highlight(e)} config and the ${L.highlight(n)} theme?` });
|
|
4037
|
+
(a.isCancel(r) || !r) && Z();
|
|
3952
4038
|
}
|
|
3953
|
-
let
|
|
3954
|
-
if (await
|
|
3955
|
-
let e = await
|
|
3956
|
-
message: `Directory ${
|
|
4039
|
+
let m = l.resolve(c);
|
|
4040
|
+
if (await Jn(m) && !await Yn(m)) {
|
|
4041
|
+
let e = await a.confirm({
|
|
4042
|
+
message: `Directory ${L.path(m)} is not empty. Continue anyway?`,
|
|
3957
4043
|
initialValue: !1
|
|
3958
4044
|
});
|
|
3959
|
-
(
|
|
3960
|
-
}
|
|
3961
|
-
let
|
|
3962
|
-
|
|
3963
|
-
let
|
|
3964
|
-
|
|
3965
|
-
let
|
|
3966
|
-
await
|
|
3967
|
-
projectName:
|
|
3968
|
-
editor:
|
|
3969
|
-
workspace:
|
|
3970
|
-
}),
|
|
3971
|
-
let
|
|
3972
|
-
|
|
3973
|
-
let
|
|
3974
|
-
|
|
3975
|
-
let
|
|
3976
|
-
|
|
3977
|
-
let
|
|
3978
|
-
if (
|
|
3979
|
-
let e =
|
|
3980
|
-
|
|
3981
|
-
} else
|
|
3982
|
-
|
|
3983
|
-
let
|
|
3984
|
-
|
|
3985
|
-
let
|
|
4045
|
+
(a.isCancel(e) || !e) && Z();
|
|
4046
|
+
}
|
|
4047
|
+
let h = a.spinner();
|
|
4048
|
+
h.start("Cloning Hype Stack template..."), await Qi(m), h.stop(L.success("Template cloned"));
|
|
4049
|
+
let g = a.spinner();
|
|
4050
|
+
g.start("Setting up project..."), await ga(m), await va(m, s), await da(m, d);
|
|
4051
|
+
let _ = await ar(m), v = sr(s, _);
|
|
4052
|
+
await ir(m, v), await Pa(m, {
|
|
4053
|
+
projectName: s,
|
|
4054
|
+
editor: d,
|
|
4055
|
+
workspace: _
|
|
4056
|
+
}), r(p) && (await ia(l.resolve(m, v.paths?.frontend.root ?? "apps/frontend"), n(p)) || a.log.warn(L.muted(`Could not find ${L.path("assets/styles.css")} to apply the ${p} theme`))), g.stop(L.success("Project configured"));
|
|
4057
|
+
let y = a.spinner();
|
|
4058
|
+
y.start("Installing dependencies..."), (await q("pnpm", ["install"], { cwd: m })).exitCode === 0 ? y.stop(L.success("Dependencies installed")) : (y.stop(L.warning("Dependencies installed with warnings")), a.log.warn(L.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4059
|
+
let b = a.spinner();
|
|
4060
|
+
b.start("Initializing git repository..."), await _a(m), b.stop(L.success("Git repository initialized with clean history"));
|
|
4061
|
+
let x = a.spinner();
|
|
4062
|
+
x.start("Creating .env files from examples...");
|
|
4063
|
+
let S = await pa(m);
|
|
4064
|
+
if (S.length > 0) {
|
|
4065
|
+
let e = S.length;
|
|
4066
|
+
x.stop(L.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4067
|
+
} else x.stop(L.muted("No .env.example files to copy"));
|
|
4068
|
+
a.log.success(`${L.brandBold("Hype Stack")} project ${L.highlight(s)} is ready!`);
|
|
4069
|
+
let C = l.relative(process.cwd(), m) || ".", w = [`${L.command(`cd ${C}`)}`];
|
|
4070
|
+
S.length > 0 ? w.push(`Review your ${L.path(".env")} files and fill in any secrets`) : w.push(`Copy ${L.path(".env.example")} to ${L.path(".env")} and configure`), Zi(w);
|
|
4071
|
+
let T = i.setup !== !1 && (o || await a.confirm({
|
|
3986
4072
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
3987
4073
|
initialValue: !0
|
|
4074
|
+
}));
|
|
4075
|
+
a.isCancel(T) && Z(), T ? await Da(m, o) : (a.log.info(L.muted("You can start services later:")), Zi([
|
|
4076
|
+
`${L.command("docker compose up -d")} ${L.muted("(in apps/backend - start Postgres, Valkey, RustFS)")}`,
|
|
4077
|
+
`${L.command("pnpm --filter @internal/backend migration:latest")} ${L.muted("(apply migrations)")}`,
|
|
4078
|
+
`${L.command("pnpm run generate")} ${L.muted("(generate Prisma client)")}`
|
|
4079
|
+
])), Zi([`${L.command("pnpm dev")} ${L.muted("(start frontend + backend)")}`]), await Fa("project_create"), a.outro(L.muted("Happy building!"));
|
|
4080
|
+
}
|
|
4081
|
+
//#endregion
|
|
4082
|
+
//#region src/commands/init.ts
|
|
4083
|
+
async function Ra(e) {
|
|
4084
|
+
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4085
|
+
if (n || (X(), a.intro(L.brandBold("Initialize Hype Stack configuration"))), !await cr(t)) {
|
|
4086
|
+
a.log.error(`This doesn't look like a Hype Stack project. ${L.muted("Expected apps/ directory and package.json")}`), a.outro(L.muted(`Run ${L.command("hype-stack create")} to scaffold a new project.`));
|
|
4087
|
+
return;
|
|
4088
|
+
}
|
|
4089
|
+
if (await rr(t)) {
|
|
4090
|
+
let e = await nr(t);
|
|
4091
|
+
if (e && !n) {
|
|
4092
|
+
a.log.info(`Found existing ${L.path("stack.json")} for project ${L.highlight(e.name)}`);
|
|
4093
|
+
let t = await a.confirm({
|
|
4094
|
+
message: "Overwrite existing configuration?",
|
|
4095
|
+
initialValue: !1
|
|
4096
|
+
});
|
|
4097
|
+
if (a.isCancel(t) || !t) {
|
|
4098
|
+
a.outro(L.muted("Keeping existing configuration."));
|
|
4099
|
+
return;
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
}
|
|
4103
|
+
let r = await ar(t);
|
|
4104
|
+
if (!n) {
|
|
4105
|
+
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4106
|
+
if (e.length > 0) {
|
|
4107
|
+
a.log.info(L.bold("Detected apps:"));
|
|
4108
|
+
for (let [t, n] of e) a.log.message(` ${R.arrow} ${L.highlight(t)} ${L.muted(`→ ${n}`)}`);
|
|
4109
|
+
}
|
|
4110
|
+
if (t.length > 0) {
|
|
4111
|
+
a.log.info(L.bold("Detected packages:"));
|
|
4112
|
+
for (let [e, n] of t) a.log.message(` ${R.arrow} ${L.highlight(e)} ${L.muted(`→ ${n}`)}`);
|
|
4113
|
+
}
|
|
4114
|
+
e.length === 0 && t.length === 0 && a.log.warn("No apps or packages detected in the workspace.");
|
|
4115
|
+
}
|
|
4116
|
+
let i = (await Xn(l.join(t, "package.json")))?.name?.replace(/^@/, "").replace(/\/source$/, "") ?? "my-app", o = i;
|
|
4117
|
+
if (!n) {
|
|
4118
|
+
let e = await a.text({
|
|
4119
|
+
message: "Project name for stack.json?",
|
|
4120
|
+
placeholder: i,
|
|
4121
|
+
initialValue: i
|
|
4122
|
+
});
|
|
4123
|
+
a.isCancel(e) && Z(), o = e;
|
|
4124
|
+
}
|
|
4125
|
+
await ir(t, sr(o, r)), n || (a.log.success(`${L.path("stack.json")} written successfully`), a.outro(L.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
|
|
4126
|
+
}
|
|
4127
|
+
async function za(e, t = {}) {
|
|
4128
|
+
if (await rr(e)) return !0;
|
|
4129
|
+
let n = t.runInit ?? ((e) => Ra({
|
|
4130
|
+
cwd: e,
|
|
4131
|
+
silent: !0
|
|
4132
|
+
})), r = t.runCreate ?? ((e) => La({ directory: e }));
|
|
4133
|
+
if (await cr(e)) {
|
|
4134
|
+
a.log.warn(`No ${L.path("stack.json")} found in ${L.path(e)}.`);
|
|
4135
|
+
let t = await a.confirm({
|
|
4136
|
+
message: `Create ${L.path("stack.json")} now?`,
|
|
4137
|
+
initialValue: !0
|
|
4138
|
+
});
|
|
4139
|
+
if (a.isCancel(t) || !t) return !1;
|
|
4140
|
+
await n(e);
|
|
4141
|
+
let r = await rr(e);
|
|
4142
|
+
return r && a.log.success(`${L.path("stack.json")} created`), r;
|
|
4143
|
+
}
|
|
4144
|
+
a.log.warn(`This doesn't look like a Hype Stack project, and there's no ${L.path("stack.json")} here.`);
|
|
4145
|
+
let i = await a.confirm({
|
|
4146
|
+
message: `Is ${L.path(e)} where you want to work?`,
|
|
4147
|
+
initialValue: !0
|
|
3988
4148
|
});
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
4149
|
+
if (a.isCancel(i) || !i) return !1;
|
|
4150
|
+
let o = await a.confirm({
|
|
4151
|
+
message: "Create a new Hype Stack project here?",
|
|
4152
|
+
initialValue: !0
|
|
4153
|
+
});
|
|
4154
|
+
return a.isCancel(o) || !o ? !1 : (await r(e), await rr(e));
|
|
4155
|
+
}
|
|
4156
|
+
//#endregion
|
|
4157
|
+
//#region src/core/npm-deps.ts
|
|
4158
|
+
function Ba(e, t) {
|
|
4159
|
+
let n = [], r = [];
|
|
4160
|
+
if (!e) return {
|
|
4161
|
+
errors: n,
|
|
4162
|
+
operations: r
|
|
4163
|
+
};
|
|
4164
|
+
for (let [i, a] of Object.entries(e)) {
|
|
4165
|
+
let e = t[i];
|
|
4166
|
+
if (!e?.root) {
|
|
4167
|
+
n.push(`Unknown stack app "${i}" for dependencies_npm - no paths.${i}.root in stack.json.`);
|
|
4168
|
+
continue;
|
|
4169
|
+
}
|
|
4170
|
+
let o = [];
|
|
4171
|
+
for (let [e, t] of Object.entries(a)) {
|
|
4172
|
+
let r = t.trim();
|
|
4173
|
+
if (!r) {
|
|
4174
|
+
n.push(`Empty version range for npm package "${e}" under dependencies_npm.${i}.`);
|
|
4175
|
+
continue;
|
|
4176
|
+
}
|
|
4177
|
+
o.push(`${e}@${r}`);
|
|
4178
|
+
}
|
|
4179
|
+
o.length > 0 && r.push({
|
|
4180
|
+
relativeDir: e.root,
|
|
4181
|
+
specs: o
|
|
4182
|
+
});
|
|
4183
|
+
}
|
|
4184
|
+
return {
|
|
4185
|
+
errors: n,
|
|
4186
|
+
operations: r
|
|
4187
|
+
};
|
|
4188
|
+
}
|
|
4189
|
+
function Va(e) {
|
|
4190
|
+
let t = {};
|
|
4191
|
+
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4192
|
+
...t[e],
|
|
4193
|
+
...r
|
|
4194
|
+
};
|
|
4195
|
+
return t;
|
|
4196
|
+
}
|
|
4197
|
+
async function Ha(e, t, n = q) {
|
|
4198
|
+
let r = [];
|
|
4199
|
+
for (let i of e) {
|
|
4200
|
+
let e = l.join(t, i.relativeDir);
|
|
4201
|
+
if (!await J(l.join(e, "package.json"))) {
|
|
4202
|
+
r.push(`Cannot install npm dependencies under "${i.relativeDir}": package.json not found.`);
|
|
4203
|
+
continue;
|
|
4204
|
+
}
|
|
4205
|
+
let a = l.normalize(i.relativeDir), o;
|
|
4206
|
+
try {
|
|
4207
|
+
o = await n("pnpm", [
|
|
4208
|
+
"add",
|
|
4209
|
+
...i.specs,
|
|
4210
|
+
"--dir",
|
|
4211
|
+
a
|
|
4212
|
+
], { cwd: t });
|
|
4213
|
+
} catch (e) {
|
|
4214
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
4215
|
+
r.push(`pnpm add failed for "${i.relativeDir}": ${t}`);
|
|
4216
|
+
continue;
|
|
4217
|
+
}
|
|
4218
|
+
if (o.exitCode !== 0) {
|
|
4219
|
+
let e = o.stderr.trim() || o.stdout.trim() || `(exit ${String(o.exitCode)})`;
|
|
4220
|
+
r.push(`pnpm add failed for "${i.relativeDir}": ${e}`);
|
|
4221
|
+
}
|
|
4222
|
+
}
|
|
4223
|
+
return {
|
|
4224
|
+
ok: r.length === 0,
|
|
4225
|
+
errors: r
|
|
4226
|
+
};
|
|
4227
|
+
}
|
|
4228
|
+
//#endregion
|
|
4229
|
+
//#region src/commands/install-helpers.ts
|
|
4230
|
+
function $(e) {
|
|
4231
|
+
return e instanceof Error ? e.message : String(e);
|
|
4232
|
+
}
|
|
4233
|
+
async function Ua(e, t, n) {
|
|
4234
|
+
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4235
|
+
return r.length === 0 ? {} : hr(r, n).catch(() => ({}));
|
|
4236
|
+
}
|
|
4237
|
+
function Wa(e, t) {
|
|
4238
|
+
return e === "free" ? L.success("free") : e === "owned" ? L.accent("owned") : `${L.highlight(`$${t}`)} ${L.muted("locked")}`;
|
|
4239
|
+
}
|
|
4240
|
+
async function Ga(e, t, n) {
|
|
4241
|
+
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4242
|
+
i.length > 0 && a.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await qn(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4243
|
+
name: e.name,
|
|
4244
|
+
displayName: e.displayName,
|
|
4245
|
+
price: e.price
|
|
4246
|
+
})));
|
|
4247
|
+
}
|
|
4248
|
+
function Ka(e, t) {
|
|
4249
|
+
let n = e.map((e, n) => {
|
|
4250
|
+
let r = t.get(e), i = r ? r.displayName : e;
|
|
4251
|
+
return ` ${L.muted(`${n + 1}.`)} ${L.brand(i)}`;
|
|
4252
|
+
});
|
|
4253
|
+
a.note([
|
|
4254
|
+
"These packs will be installed, in order:",
|
|
4255
|
+
"",
|
|
4256
|
+
...n
|
|
4257
|
+
].join("\n"), "Install Plan");
|
|
4258
|
+
}
|
|
4259
|
+
async function qa(e, t) {
|
|
4260
|
+
let n = [];
|
|
4261
|
+
for (let r of e) {
|
|
4262
|
+
let e = await lr(r), i = await ur(r, t);
|
|
4263
|
+
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'hype-stack login' or check your license.`);
|
|
4264
|
+
n.push({
|
|
4265
|
+
manifest: e,
|
|
4266
|
+
packDir: i.packDir
|
|
4267
|
+
});
|
|
4268
|
+
}
|
|
4269
|
+
return n;
|
|
4270
|
+
}
|
|
4271
|
+
async function Ja(e) {
|
|
4272
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, o = Ba(Va(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4273
|
+
if (o.errors.length > 0) {
|
|
4274
|
+
for (let e of o.errors) a.log.error(e);
|
|
4275
|
+
return;
|
|
4276
|
+
}
|
|
4277
|
+
if (o.operations.length === 0) return;
|
|
4278
|
+
i.start("Installing npm dependencies...");
|
|
4279
|
+
let s = await Ha(o.operations, r);
|
|
4280
|
+
if (i.stop(s.ok ? "npm dependencies installed" : "npm dependency installation failed"), !s.ok) for (let e of s.errors) a.log.error(e);
|
|
4281
|
+
}
|
|
4282
|
+
function Ya(e) {
|
|
4283
|
+
let t = e.flatMap((e) => e.manifest.postInstall ?? []), n = [...new Set(t)];
|
|
4284
|
+
n.length !== 0 && a.note(n.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Next Steps");
|
|
4285
|
+
}
|
|
4286
|
+
async function Xa(e) {
|
|
4287
|
+
let { prepared: t, config: n, cwd: r, force: i, yes: o, slotsByPack: s } = e, c = /* @__PURE__ */ new Set();
|
|
4288
|
+
if (i) return c;
|
|
4289
|
+
let u = await xi({
|
|
4290
|
+
packs: t,
|
|
4291
|
+
config: n,
|
|
4292
|
+
projectRoot: r,
|
|
4293
|
+
slotsByPack: s
|
|
4294
|
+
});
|
|
4295
|
+
if (u.length === 0) return c;
|
|
4296
|
+
if (o) return a.log.warning(`${u.length} existing file${u.length === 1 ? "" : "s"} kept. Pass ${L.command("--force")} to overwrite.`), c;
|
|
4297
|
+
a.log.warning(`${u.length} file${u.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4298
|
+
for (let e of u) {
|
|
4299
|
+
let t = l.relative(r, e.targetPath) || e.target, n = await a.confirm({
|
|
4300
|
+
message: `Overwrite ${L.path(t)}? ${L.muted(`(${e.packName})`)}`,
|
|
4301
|
+
initialValue: !1
|
|
4302
|
+
});
|
|
4303
|
+
a.isCancel(n) && (a.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
|
|
4304
|
+
}
|
|
4305
|
+
return c;
|
|
4306
|
+
}
|
|
4307
|
+
//#endregion
|
|
4308
|
+
//#region src/commands/compose.ts
|
|
4309
|
+
async function Za(e = {}) {
|
|
4310
|
+
let t = e.cwd ?? process.cwd();
|
|
4311
|
+
X();
|
|
4312
|
+
let n = await za(t), r;
|
|
4313
|
+
try {
|
|
4314
|
+
r = await nr(t);
|
|
4315
|
+
} catch (e) {
|
|
4316
|
+
a.cancel(`Could not parse ${L.path("stack.json")}: ${$(e)} Run 'hype-stack init' to regenerate it.`), process.exit(1);
|
|
4317
|
+
}
|
|
4318
|
+
r || (a.cancel(n ? `Could not read ${L.path("stack.json")}. Run 'hype-stack init' to regenerate it, then run 'hype-stack compose' again.` : `No ${L.path("stack.json")}. Run 'hype-stack init' first, then 'hype-stack compose'.`), process.exit(1)), r.paths || (a.cancel(`${L.path("stack.json")} is missing ${L.path("paths")}. Run 'hype-stack init' again to regenerate it.`), process.exit(1)), a.intro(L.brandBold("Compose your stack"));
|
|
4319
|
+
let i = a.spinner();
|
|
4320
|
+
i.start("Loading packs...");
|
|
4321
|
+
let s;
|
|
4322
|
+
try {
|
|
4323
|
+
s = await mr();
|
|
4324
|
+
} catch (e) {
|
|
4325
|
+
i.stop("Failed to load packs"), a.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4326
|
+
}
|
|
4327
|
+
i.stop("Packs loaded");
|
|
4328
|
+
let c = r.installedPacks ?? [], l = new Set(c), u = new Map(s.map((e) => [e.name, e])), d = e.licenseKey ?? r.licenseKey ?? null, f = (await In(M()))?.token ?? null, p = await Ua(s, l, {
|
|
4329
|
+
token: f,
|
|
4330
|
+
key: d
|
|
4331
|
+
}), m = (e) => {
|
|
4332
|
+
let t = u.get(e);
|
|
4333
|
+
return !t || t.tier === "free" ? "free" : p[e]?.owned ? "owned" : "locked";
|
|
4334
|
+
}, h = (e) => !l.has(e) && m(e) === "locked", g = await Qa({
|
|
4335
|
+
packs: s,
|
|
4336
|
+
installedSet: l,
|
|
4337
|
+
stateOf: m,
|
|
4338
|
+
options: e,
|
|
4339
|
+
adminAvailable: !!r.apps.admin
|
|
4340
|
+
});
|
|
4341
|
+
if (g === null && (a.cancel("Cancelled."), process.exit(0)), g.length === 0) {
|
|
4342
|
+
a.outro(L.muted("No packs selected. Nothing to do."));
|
|
4343
|
+
return;
|
|
4344
|
+
}
|
|
4345
|
+
let _ = to(g), v = no(g), y = Bi(s, _), b = Ni(Vi(s, y)), x;
|
|
4346
|
+
try {
|
|
4347
|
+
x = Fi(_, b, c);
|
|
4348
|
+
} catch (e) {
|
|
4349
|
+
a.cancel($(e)), process.exit(1);
|
|
4350
|
+
}
|
|
4351
|
+
if (x.order.length === 0) {
|
|
4352
|
+
a.note(`${x.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), a.outro(L.muted("Your selection is already part of the project."));
|
|
4353
|
+
return;
|
|
4354
|
+
}
|
|
4355
|
+
let S = Ii({
|
|
4356
|
+
order: x.order,
|
|
4357
|
+
graph: b,
|
|
4358
|
+
isLocked: h,
|
|
4359
|
+
installed: c
|
|
4360
|
+
});
|
|
4361
|
+
if (S.blocked.length > 0 && !f && !d) {
|
|
4362
|
+
let e = await Kn();
|
|
4363
|
+
e && (f = e, p = await Ua(s, l, {
|
|
4364
|
+
token: f,
|
|
4365
|
+
key: d
|
|
4366
|
+
}), S = Ii({
|
|
4367
|
+
order: x.order,
|
|
4368
|
+
graph: b,
|
|
4369
|
+
isLocked: h,
|
|
4370
|
+
installed: c
|
|
4371
|
+
}));
|
|
4372
|
+
}
|
|
4373
|
+
if (S.blocked.length > 0 && await Ga(S.blocked, h, u), S.installable.length === 0) {
|
|
4374
|
+
a.outro(L.muted("Nothing left to install once locked packs are removed."));
|
|
4375
|
+
return;
|
|
4376
|
+
}
|
|
4377
|
+
if (Ka(S.installable, u), !e.yes) {
|
|
4378
|
+
let e = await a.confirm({ message: `Install ${S.installable.length} pack${S.installable.length === 1 ? "" : "s"}?` });
|
|
4379
|
+
(a.isCancel(e) || !e) && (a.cancel("Installation cancelled."), process.exit(0));
|
|
4380
|
+
}
|
|
4381
|
+
i.start("Downloading packs...");
|
|
4382
|
+
let C;
|
|
4383
|
+
try {
|
|
4384
|
+
C = await qa(S.installable, {
|
|
4385
|
+
token: f,
|
|
4386
|
+
key: d
|
|
4387
|
+
});
|
|
4388
|
+
} catch (e) {
|
|
4389
|
+
i.stop("Download failed"), a.cancel($(e)), process.exit(1);
|
|
4390
|
+
}
|
|
4391
|
+
i.stop(`Downloaded ${C.length} pack${C.length === 1 ? "" : "s"}`);
|
|
4392
|
+
let w = await Xa({
|
|
4393
|
+
prepared: C,
|
|
4394
|
+
config: r,
|
|
4395
|
+
cwd: t,
|
|
4396
|
+
force: e.force ?? !1,
|
|
4397
|
+
yes: e.yes ?? !1,
|
|
4398
|
+
slotsByPack: v
|
|
4399
|
+
});
|
|
4400
|
+
try {
|
|
4401
|
+
i.start("Installing pack files...");
|
|
4402
|
+
let n = await wi({
|
|
4403
|
+
packs: C,
|
|
4404
|
+
config: r,
|
|
4405
|
+
projectRoot: t,
|
|
4406
|
+
force: e.force ?? !1,
|
|
4407
|
+
overwrite: w,
|
|
4408
|
+
slotsByPack: v
|
|
4409
|
+
});
|
|
4410
|
+
if (n.aborted) {
|
|
4411
|
+
i.stop("Installation aborted");
|
|
4412
|
+
for (let e of n.errors) a.log.error(e);
|
|
4413
|
+
a.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4414
|
+
}
|
|
4415
|
+
i.stop("Files installed"), n.installed.length > 0 && a.log.success(`${L.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && a.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`);
|
|
4416
|
+
for (let e of n.errors) a.log.error(e);
|
|
4417
|
+
await Ja({
|
|
4418
|
+
prepared: C,
|
|
4419
|
+
paths: r.paths,
|
|
4420
|
+
cwd: t,
|
|
4421
|
+
spinner: i
|
|
4422
|
+
}), await tr({
|
|
4423
|
+
projectRoot: t,
|
|
4424
|
+
paths: r.paths,
|
|
4425
|
+
skipPrompts: e.yes ?? !1
|
|
4426
|
+
}), Ya(C), a.outro(L.brand(`Installed ${n.appliedPacks.join(", ")}.`));
|
|
4427
|
+
} finally {
|
|
4428
|
+
await Promise.all(C.map((e) => o.rm(e.packDir, {
|
|
4429
|
+
recursive: !0,
|
|
4430
|
+
force: !0
|
|
4431
|
+
})));
|
|
4432
|
+
}
|
|
4433
|
+
}
|
|
4434
|
+
async function Qa(e) {
|
|
4435
|
+
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: o } = e;
|
|
4436
|
+
if (i.packs && i.packs.length > 0) {
|
|
4437
|
+
let e = i.packs.map(eo), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4438
|
+
return n.length > 0 && (a.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4439
|
+
}
|
|
4440
|
+
let s = t.filter((e) => n.has(e.name));
|
|
4441
|
+
s.length > 0 && a.note(s.map((e) => ` ${L.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4442
|
+
let c = t.filter((e) => !n.has(e.name));
|
|
4443
|
+
if (c.length === 0) return a.outro(L.muted("Every available pack is already installed.")), [];
|
|
4444
|
+
let l = ji(c, { adminAvailable: o }), u = [];
|
|
4445
|
+
for (let e of l) {
|
|
4446
|
+
let t = e.packs.map((e) => {
|
|
4447
|
+
let t = r(e.name);
|
|
4448
|
+
return {
|
|
4449
|
+
value: e.name,
|
|
4450
|
+
label: `${e.displayName} ${Wa(t, e.price)}`,
|
|
4451
|
+
hint: e.description
|
|
4452
|
+
};
|
|
4453
|
+
});
|
|
4454
|
+
if (e.mode === "single") {
|
|
4455
|
+
let n = await a.select({
|
|
4456
|
+
message: `Choose a ${e.label.toLowerCase()}`,
|
|
4457
|
+
options: t,
|
|
4458
|
+
initialValue: e.preselect ?? e.packs[0].name
|
|
4459
|
+
});
|
|
4460
|
+
if (a.isCancel(n)) return null;
|
|
4461
|
+
u.push({
|
|
4462
|
+
name: n,
|
|
4463
|
+
slot: e.slot
|
|
4464
|
+
});
|
|
4465
|
+
continue;
|
|
4466
|
+
}
|
|
4467
|
+
let n = await a.multiselect({
|
|
4468
|
+
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4469
|
+
options: t,
|
|
4470
|
+
required: !1
|
|
4471
|
+
});
|
|
4472
|
+
if (a.isCancel(n)) return null;
|
|
4473
|
+
for (let e of n) u.push({ name: e });
|
|
4474
|
+
}
|
|
4475
|
+
return u;
|
|
4476
|
+
}
|
|
4477
|
+
var $a = /@(frontend|admin)$/;
|
|
4478
|
+
function eo(e) {
|
|
4479
|
+
let t = e.match($a);
|
|
4480
|
+
return t ? {
|
|
4481
|
+
name: e.slice(0, -t[0].length),
|
|
4482
|
+
slot: t[1]
|
|
4483
|
+
} : { name: e };
|
|
4484
|
+
}
|
|
4485
|
+
function to(e) {
|
|
4486
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4487
|
+
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4488
|
+
return n;
|
|
4489
|
+
}
|
|
4490
|
+
function no(e) {
|
|
4491
|
+
let t = /* @__PURE__ */ new Map();
|
|
4492
|
+
for (let n of e) {
|
|
4493
|
+
if (!n.slot) continue;
|
|
4494
|
+
let e = t.get(n.name);
|
|
4495
|
+
e && !e.includes(n.slot) ? e.push(n.slot) : e || t.set(n.name, [n.slot]);
|
|
4496
|
+
}
|
|
4497
|
+
return t;
|
|
3994
4498
|
}
|
|
3995
4499
|
//#endregion
|
|
3996
4500
|
//#region src/commands/login.ts
|
|
3997
|
-
async function
|
|
3998
|
-
|
|
4501
|
+
async function ro() {
|
|
4502
|
+
X(), a.intro(L.brandBold("Log in to Hype Stack")), a.log.step("Opening your browser to sign in...");
|
|
3999
4503
|
let e;
|
|
4000
4504
|
try {
|
|
4001
|
-
e = await
|
|
4002
|
-
|
|
4505
|
+
e = await Gn({ onUrl: (e) => {
|
|
4506
|
+
a.log.info(`If your browser didn't open, visit:\n ${L.path(e)}`);
|
|
4003
4507
|
} });
|
|
4004
4508
|
} catch (e) {
|
|
4005
|
-
|
|
4509
|
+
a.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
|
|
4006
4510
|
}
|
|
4007
|
-
|
|
4511
|
+
a.outro(L.brand(e.email ? `Logged in as ${e.email}. You can now install packs your organization owns.` : "Logged in. You can now install packs your organization owns."));
|
|
4008
4512
|
}
|
|
4009
4513
|
//#endregion
|
|
4010
4514
|
//#region src/commands/logout.ts
|
|
4011
|
-
async function
|
|
4012
|
-
|
|
4013
|
-
let e =
|
|
4014
|
-
if (!
|
|
4015
|
-
|
|
4515
|
+
async function io() {
|
|
4516
|
+
X(), a.intro(L.brandBold("Log out of Hype Stack"));
|
|
4517
|
+
let e = M(), t = await In(e);
|
|
4518
|
+
if (!t) {
|
|
4519
|
+
a.outro(L.muted("You're not logged in."));
|
|
4016
4520
|
return;
|
|
4017
4521
|
}
|
|
4018
|
-
await
|
|
4522
|
+
await On(t.token).catch(() => null), await Rn(e), a.outro(L.brand("Logged out."));
|
|
4523
|
+
}
|
|
4524
|
+
//#endregion
|
|
4525
|
+
//#region src/core/templates.ts
|
|
4526
|
+
var ao = K.createRequest()({
|
|
4527
|
+
endpoint: "/templates/list",
|
|
4528
|
+
method: "GET"
|
|
4529
|
+
});
|
|
4530
|
+
async function oo() {
|
|
4531
|
+
let { data: e, error: t } = await ao.send();
|
|
4532
|
+
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
4533
|
+
return e.templates;
|
|
4534
|
+
}
|
|
4535
|
+
async function so(e) {
|
|
4536
|
+
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
4537
|
+
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
4538
|
+
method: "GET"
|
|
4539
|
+
}).send();
|
|
4540
|
+
if (r === 404) throw Error(`Template "${e}" not found`);
|
|
4541
|
+
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
4542
|
+
return t;
|
|
4543
|
+
}
|
|
4544
|
+
async function co(e, t = {}) {
|
|
4545
|
+
let n = K.createRequest()({
|
|
4546
|
+
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
4547
|
+
method: "POST"
|
|
4548
|
+
}), r = {
|
|
4549
|
+
"X-Device-Id": Bn(),
|
|
4550
|
+
"X-Client-Info": Vn()
|
|
4551
|
+
};
|
|
4552
|
+
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
4553
|
+
let { data: i, error: a, success: s } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
4554
|
+
if (!s || !i) throw Error(`Failed to download template "${e}": ${String(a)}`);
|
|
4555
|
+
if (!i.ok) return {
|
|
4556
|
+
status: "denied",
|
|
4557
|
+
reason: i.reason,
|
|
4558
|
+
packs: i.packs ?? [],
|
|
4559
|
+
expiresAt: i.expiresAt ?? null
|
|
4560
|
+
};
|
|
4561
|
+
let u = await o.mkdtemp(l.join(c.tmpdir(), `hype-stack-template-${e}-`));
|
|
4562
|
+
return await Promise.all(i.files.map(async (e) => {
|
|
4563
|
+
let t = l.join(u, ...e.path.split("/"));
|
|
4564
|
+
await o.mkdir(l.dirname(t), { recursive: !0 }), await o.writeFile(t, Buffer.from(e.content, "base64"));
|
|
4565
|
+
})), {
|
|
4566
|
+
status: "ok",
|
|
4567
|
+
templateDir: u
|
|
4568
|
+
};
|
|
4569
|
+
}
|
|
4570
|
+
//#endregion
|
|
4571
|
+
//#region src/commands/template.ts
|
|
4572
|
+
async function lo(e = {}) {
|
|
4573
|
+
let t = e.cwd ?? process.cwd();
|
|
4574
|
+
X();
|
|
4575
|
+
let i = await za(t), s;
|
|
4576
|
+
try {
|
|
4577
|
+
s = await nr(t);
|
|
4578
|
+
} catch (e) {
|
|
4579
|
+
a.cancel(`Could not parse ${L.path("stack.json")}: ${$(e)} Run 'hype-stack init' to regenerate it.`), process.exit(1);
|
|
4580
|
+
}
|
|
4581
|
+
s || (a.cancel(i ? `Could not read ${L.path("stack.json")}. Run 'hype-stack init' to regenerate it, then run 'hype-stack template' again.` : `No ${L.path("stack.json")}. Run 'hype-stack init' first, then 'hype-stack template'.`), process.exit(1)), s.paths || (a.cancel(`${L.path("stack.json")} is missing ${L.path("paths")}. Run 'hype-stack init' again to regenerate it.`), process.exit(1)), a.intro(L.brandBold("Install a template"));
|
|
4582
|
+
let c = a.spinner();
|
|
4583
|
+
c.start("Loading packs...");
|
|
4584
|
+
let u;
|
|
4585
|
+
try {
|
|
4586
|
+
u = await mr();
|
|
4587
|
+
} catch (e) {
|
|
4588
|
+
c.stop("Failed to load packs"), a.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4589
|
+
}
|
|
4590
|
+
c.stop("Packs loaded");
|
|
4591
|
+
let d = s.installedPacks ?? [], f = new Set(d), p = new Map(u.map((e) => [e.name, e])), m = e.licenseKey ?? s.licenseKey ?? null, h = (await In(M()))?.token ?? null;
|
|
4592
|
+
c.start("Loading templates...");
|
|
4593
|
+
let g;
|
|
4594
|
+
try {
|
|
4595
|
+
g = await oo();
|
|
4596
|
+
} catch (e) {
|
|
4597
|
+
c.stop("Failed to load templates"), a.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4598
|
+
}
|
|
4599
|
+
let _ = e.templateId;
|
|
4600
|
+
if (!_) {
|
|
4601
|
+
e.yes && (c.stop("Template id required"), a.cancel("Pass a template id with `hype-stack template <id>` (required in --yes mode)."), process.exit(1)), g.length === 0 && (c.stop("No templates available"), a.cancel("No templates are available yet. Check back later."), process.exit(1)), c.stop("Templates loaded");
|
|
4602
|
+
let t = await a.select({
|
|
4603
|
+
message: "Choose a template",
|
|
4604
|
+
options: g.map((e) => ({
|
|
4605
|
+
value: e.id,
|
|
4606
|
+
label: e.name,
|
|
4607
|
+
hint: e.description
|
|
4608
|
+
}))
|
|
4609
|
+
});
|
|
4610
|
+
a.isCancel(t) && (a.cancel("Cancelled."), process.exit(0)), _ = t;
|
|
4611
|
+
}
|
|
4612
|
+
let v = g.find((e) => e.id === _);
|
|
4613
|
+
v || (c.stop("Template not found"), a.cancel(`Template "${_}" not found. Available: ${g.map((e) => e.id).join(", ") || "(none)"}`), process.exit(1)), c.stop(`Template: ${v.name}`);
|
|
4614
|
+
let y = await uo(v, e.variants, e.yes ?? !1), b = Li(v.slots, y), x = Ri(v.slots, v.packs, b), S = await fo({
|
|
4615
|
+
packs: u,
|
|
4616
|
+
templatePacks: x,
|
|
4617
|
+
installedSet: f,
|
|
4618
|
+
options: e
|
|
4619
|
+
}), C = [...x, ...S.filter((e) => !x.includes(e))], w = C.filter((e) => !p.has(e));
|
|
4620
|
+
w.length > 0 && (a.cancel(`Unknown pack${w.length === 1 ? "" : "s"}: ${w.join(", ")}`), process.exit(1));
|
|
4621
|
+
let T = Vi(u, b), E = Ni(T), D;
|
|
4622
|
+
try {
|
|
4623
|
+
D = Fi(C, E, d);
|
|
4624
|
+
} catch (e) {
|
|
4625
|
+
a.cancel($(e)), process.exit(1);
|
|
4626
|
+
}
|
|
4627
|
+
if (D.order.length === 0) {
|
|
4628
|
+
a.outro(L.muted("Every pack in this template is already installed."));
|
|
4629
|
+
return;
|
|
4630
|
+
}
|
|
4631
|
+
let O = await Ua(T, f, {
|
|
4632
|
+
token: h,
|
|
4633
|
+
key: m
|
|
4634
|
+
}), k = (e) => {
|
|
4635
|
+
let t = p.get(e);
|
|
4636
|
+
return !t || t.tier === "free" ? "free" : O[e]?.owned ? "owned" : "locked";
|
|
4637
|
+
}, ee = (e) => !f.has(e) && k(e) === "locked", A = Ii({
|
|
4638
|
+
order: D.order,
|
|
4639
|
+
graph: E,
|
|
4640
|
+
isLocked: ee,
|
|
4641
|
+
installed: d
|
|
4642
|
+
});
|
|
4643
|
+
if (A.blocked.length > 0 && !h && !m) {
|
|
4644
|
+
let e = await Kn();
|
|
4645
|
+
e && (h = e, O = await Ua(T, f, {
|
|
4646
|
+
token: h,
|
|
4647
|
+
key: m
|
|
4648
|
+
}), A = Ii({
|
|
4649
|
+
order: D.order,
|
|
4650
|
+
graph: E,
|
|
4651
|
+
isLocked: ee,
|
|
4652
|
+
installed: d
|
|
4653
|
+
}));
|
|
4654
|
+
}
|
|
4655
|
+
if (A.blocked.length > 0 && await Ga(A.blocked, ee, p), A.installable.length === 0) {
|
|
4656
|
+
a.outro(L.muted("Nothing left to install once locked packs are removed."));
|
|
4657
|
+
return;
|
|
4658
|
+
}
|
|
4659
|
+
if (Ka(A.installable, p), !e.yes) {
|
|
4660
|
+
let e = await a.confirm({ message: `Install template ${L.brandBold(v.name)} (${A.installable.length} pack${A.installable.length === 1 ? "" : "s"})?` });
|
|
4661
|
+
(a.isCancel(e) || !e) && (a.cancel("Installation cancelled."), process.exit(0));
|
|
4662
|
+
}
|
|
4663
|
+
c.start("Downloading packs...");
|
|
4664
|
+
let j;
|
|
4665
|
+
try {
|
|
4666
|
+
j = await qa(A.installable, {
|
|
4667
|
+
token: h,
|
|
4668
|
+
key: m
|
|
4669
|
+
});
|
|
4670
|
+
} catch (e) {
|
|
4671
|
+
c.stop("Download failed"), a.cancel($(e)), process.exit(1);
|
|
4672
|
+
}
|
|
4673
|
+
c.stop(`Downloaded ${j.length} pack${j.length === 1 ? "" : "s"}`);
|
|
4674
|
+
let te = await Xa({
|
|
4675
|
+
prepared: j,
|
|
4676
|
+
config: s,
|
|
4677
|
+
cwd: t,
|
|
4678
|
+
force: e.force ?? !1,
|
|
4679
|
+
yes: e.yes ?? !1
|
|
4680
|
+
}), N = null;
|
|
4681
|
+
try {
|
|
4682
|
+
c.start("Installing pack files...");
|
|
4683
|
+
let i = await wi({
|
|
4684
|
+
packs: j,
|
|
4685
|
+
config: s,
|
|
4686
|
+
projectRoot: t,
|
|
4687
|
+
force: e.force ?? !1,
|
|
4688
|
+
overwrite: te
|
|
4689
|
+
});
|
|
4690
|
+
if (i.aborted) {
|
|
4691
|
+
c.stop("Installation aborted");
|
|
4692
|
+
for (let e of i.errors) a.log.error(e);
|
|
4693
|
+
a.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4694
|
+
}
|
|
4695
|
+
c.stop("Files installed"), i.installed.length > 0 && a.log.success(`${L.highlight(String(i.installed.length))} files installed`), i.skipped.length > 0 && a.log.warning(`${i.skipped.length} files skipped (use --force to overwrite)`);
|
|
4696
|
+
for (let e of i.errors) a.log.error(e);
|
|
4697
|
+
c.start("Applying template overrides...");
|
|
4698
|
+
let o = await so(v.id), u = await co(v.id, {
|
|
4699
|
+
token: h,
|
|
4700
|
+
licenseKey: m
|
|
4701
|
+
});
|
|
4702
|
+
u.status === "denied" && (c.stop("Template download denied"), a.cancel(`Access to template "${v.id}" was denied (${u.reason}). Try 'hype-stack login' or check your license.`), process.exit(1)), N = u.templateDir;
|
|
4703
|
+
let d = await Ei({
|
|
4704
|
+
manifest: o,
|
|
4705
|
+
config: s,
|
|
4706
|
+
projectRoot: t,
|
|
4707
|
+
templateDir: N
|
|
4708
|
+
});
|
|
4709
|
+
c.stop("Template overrides applied"), d.installed.length > 0 && a.log.success(`${d.installed.length} template file${d.installed.length === 1 ? "" : "s"} applied`);
|
|
4710
|
+
for (let e of d.errors) a.log.error(e);
|
|
4711
|
+
let f = o.theme ?? "zinc-mono";
|
|
4712
|
+
r(f) && (await ia(l.resolve(t, s.paths?.frontend.root ?? "apps/frontend"), n(f)) ? a.log.success(`Applied the ${n(f).label} theme`) : a.log.warning(L.muted(`Could not find ${L.path("assets/styles.css")} to apply the theme`))), await po({
|
|
4713
|
+
prepared: j,
|
|
4714
|
+
templateNpm: o.dependencies_npm,
|
|
4715
|
+
paths: s.paths,
|
|
4716
|
+
cwd: t,
|
|
4717
|
+
spinner: c
|
|
4718
|
+
}), await tr({
|
|
4719
|
+
projectRoot: t,
|
|
4720
|
+
paths: s.paths,
|
|
4721
|
+
skipPrompts: e.yes ?? !1
|
|
4722
|
+
}), Ya(j), o.postInstall && o.postInstall.length > 0 && a.note(o.postInstall.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Template Next Steps"), a.outro(L.brand(`Installed template ${v.name}.`));
|
|
4723
|
+
} finally {
|
|
4724
|
+
await Promise.all(j.map((e) => o.rm(e.packDir, {
|
|
4725
|
+
recursive: !0,
|
|
4726
|
+
force: !0
|
|
4727
|
+
}))), N && await o.rm(N, {
|
|
4728
|
+
recursive: !0,
|
|
4729
|
+
force: !0
|
|
4730
|
+
});
|
|
4731
|
+
}
|
|
4732
|
+
}
|
|
4733
|
+
async function uo(e, t, n) {
|
|
4734
|
+
let r = {};
|
|
4735
|
+
for (let i of e.slots) {
|
|
4736
|
+
if (t?.[i.family]) {
|
|
4737
|
+
r[i.family] = t[i.family];
|
|
4738
|
+
continue;
|
|
4739
|
+
}
|
|
4740
|
+
if (i.variants.length <= 1 || n) {
|
|
4741
|
+
r[i.family] = i.default;
|
|
4742
|
+
continue;
|
|
4743
|
+
}
|
|
4744
|
+
let e = i.variants.map((e) => ({
|
|
4745
|
+
value: e,
|
|
4746
|
+
label: e,
|
|
4747
|
+
hint: e === i.default ? "default" : void 0
|
|
4748
|
+
})), o = await a.select({
|
|
4749
|
+
message: `Choose a ${i.family}`,
|
|
4750
|
+
options: e,
|
|
4751
|
+
initialValue: i.default
|
|
4752
|
+
});
|
|
4753
|
+
a.isCancel(o) && (a.cancel("Cancelled."), process.exit(0)), r[i.family] = o;
|
|
4754
|
+
}
|
|
4755
|
+
return r;
|
|
4756
|
+
}
|
|
4757
|
+
async function fo(e) {
|
|
4758
|
+
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, o = new Set(n);
|
|
4759
|
+
if (i.packs && i.packs.length > 0) {
|
|
4760
|
+
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
4761
|
+
return e.length > 0 && (a.cancel(`Unknown pack${e.length === 1 ? "" : "s"}: ${e.join(", ")}`), process.exit(1)), i.packs.filter((e) => !o.has(e));
|
|
4762
|
+
}
|
|
4763
|
+
if (i.yes) return [];
|
|
4764
|
+
let s = t.filter((e) => e.category === "feature" && !o.has(e.name) && !r.has(e.name));
|
|
4765
|
+
if (s.length === 0) return [];
|
|
4766
|
+
let c = await a.multiselect({
|
|
4767
|
+
message: "Add extra packs on top of the template (optional)",
|
|
4768
|
+
options: s.map((e) => ({
|
|
4769
|
+
value: e.name,
|
|
4770
|
+
label: e.displayName,
|
|
4771
|
+
hint: e.description
|
|
4772
|
+
})),
|
|
4773
|
+
required: !1
|
|
4774
|
+
});
|
|
4775
|
+
return a.isCancel(c) && (a.cancel("Cancelled."), process.exit(0)), c;
|
|
4776
|
+
}
|
|
4777
|
+
async function po(e) {
|
|
4778
|
+
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: o } = e, s = Va(t.map((e) => e.manifest.dependencies_npm)), c = Ba(n ? Va([s, n]) : s, r);
|
|
4779
|
+
if (c.errors.length > 0) {
|
|
4780
|
+
for (let e of c.errors) a.log.error(e);
|
|
4781
|
+
return;
|
|
4782
|
+
}
|
|
4783
|
+
if (c.operations.length === 0) return;
|
|
4784
|
+
o.start("Installing npm dependencies...");
|
|
4785
|
+
let l = await Ha(c.operations, i);
|
|
4786
|
+
if (o.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) a.log.error(e);
|
|
4019
4787
|
}
|
|
4020
4788
|
//#endregion
|
|
4021
4789
|
//#region src/cli.ts
|
|
4022
|
-
function
|
|
4790
|
+
function mo(e) {
|
|
4023
4791
|
if (!e) return;
|
|
4024
4792
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
4025
4793
|
return t.length > 0 ? t : void 0;
|
|
4026
4794
|
}
|
|
4027
|
-
function
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4795
|
+
function ho(e) {
|
|
4796
|
+
if (!e) return;
|
|
4797
|
+
let t = {};
|
|
4798
|
+
for (let n of e.split(",")) {
|
|
4799
|
+
let [e, r] = n.split("=").map((e) => e?.trim());
|
|
4800
|
+
e && r && (t[e] = r);
|
|
4801
|
+
}
|
|
4802
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
4803
|
+
}
|
|
4804
|
+
function go() {
|
|
4805
|
+
let e = new i();
|
|
4806
|
+
return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(S, "-v, --version"), e.command("create").description("Create a new Hype Stack project").option("-n, --name <name>", "Project name").option("-d, --directory <path>", "Target directory").option("-e, --editor <editor>", "Code editor (cursor, claude, windsurf, copilot)").option("-t, --theme <theme>", "Color theme (default, slate, rose, emerald, violet, amber, ocean, zinc-mono, crimson, midnight)").option("--no-install", "Skip dependency installation").option("--no-setup", "Skip Docker services and database migrations after create").option("-y, --yes", "Skip confirmation prompts (requires --name)").action(async (e) => {
|
|
4807
|
+
await La({
|
|
4031
4808
|
name: e.name,
|
|
4032
4809
|
directory: e.directory,
|
|
4033
4810
|
install: e.install,
|
|
4034
4811
|
editor: e.editor,
|
|
4035
|
-
|
|
4812
|
+
theme: e.theme,
|
|
4813
|
+
yes: e.yes,
|
|
4814
|
+
setup: e.setup
|
|
4036
4815
|
});
|
|
4037
|
-
}),
|
|
4038
|
-
await
|
|
4039
|
-
}),
|
|
4040
|
-
await
|
|
4041
|
-
packs:
|
|
4816
|
+
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
4817
|
+
await Ra({});
|
|
4818
|
+
}), e.command("compose").description("Choose feature packs to add to your project").option("--packs <list>", "Comma-separated pack names (non-interactive). Append @frontend or @admin to a layout pack to target that app shell, e.g. layout-basic@frontend,layout-native-app-shell@admin").option("--force", "Overwrite existing files").option("-y, --yes", "Skip confirmation prompts").option("-k, --key <key>", "License key").option("--license-key <key>", "License key (alias for --key)").option("--cwd <path>", "Working directory").action(async (e) => {
|
|
4819
|
+
await Za({
|
|
4820
|
+
packs: mo(e.packs),
|
|
4042
4821
|
force: e.force,
|
|
4043
4822
|
yes: e.yes,
|
|
4044
4823
|
licenseKey: e.key ?? e.licenseKey,
|
|
4045
4824
|
cwd: e.cwd
|
|
4046
4825
|
});
|
|
4047
|
-
}),
|
|
4048
|
-
await
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4826
|
+
}), e.command("template <id>").description("Install a template by id, with starter/layout variant swaps and extra packs on top").argument("[id]", "Template id (omit to pick interactively)").option("--variants <map>", "Preselect slot variants, e.g. starter-saas=starter-saas-better-auth,layout=layout-basic").option("--packs <list>", "Extra packs to add on top of the template (comma-separated)").option("--force", "Overwrite existing files").option("-y, --yes", "Skip confirmation prompts (requires <id>)").option("-k, --key <key>", "License key").option("--license-key <key>", "License key (alias for --key)").option("--cwd <path>", "Working directory").action(async (e, t) => {
|
|
4827
|
+
await lo({
|
|
4828
|
+
templateId: e,
|
|
4829
|
+
variants: ho(t.variants),
|
|
4830
|
+
packs: mo(t.packs),
|
|
4831
|
+
force: t.force,
|
|
4832
|
+
yes: t.yes,
|
|
4833
|
+
licenseKey: t.key ?? t.licenseKey,
|
|
4834
|
+
cwd: t.cwd
|
|
4835
|
+
});
|
|
4836
|
+
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
4837
|
+
await ro();
|
|
4838
|
+
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
4839
|
+
await io();
|
|
4840
|
+
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
4841
|
+
await ro();
|
|
4842
|
+
}), e;
|
|
4054
4843
|
}
|
|
4055
4844
|
//#endregion
|
|
4056
|
-
export {
|
|
4845
|
+
export { za as a, Za as i, io as n, Ra as o, ro as r, La as s, go as t };
|