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