@hype-stack/cli 0.5.5 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-DKFOY4GJ.js → cli-puv4mFCS.js} +1101 -1028
- package/dist/commands/onboard.d.ts.map +1 -1
- package/dist/config/bin.js +1 -1
- package/dist/core/codegen.d.ts +10 -7
- package/dist/core/codegen.d.ts.map +1 -1
- package/dist/core/codemods.d.ts.map +1 -1
- package/dist/core/installer.d.ts +8 -1
- package/dist/core/installer.d.ts.map +1 -1
- package/dist/core/onboard-catalog.d.ts +47 -21
- package/dist/core/onboard-catalog.d.ts.map +1 -1
- package/dist/core/pack-categories.d.ts +5 -5
- package/dist/core/pack-categories.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/types.d.ts +21 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import { Prompt as O } from "@clack/core";
|
|
|
13
13
|
import { styleText as k } from "node:util";
|
|
14
14
|
import { downloadTemplate as ee } from "giget";
|
|
15
15
|
//#region src/constants/constants.ts
|
|
16
|
-
var A = "0.5.
|
|
16
|
+
var A = "0.5.7", j = "gh:BetterTyped/hype-stack", M = "stack.json", te = "/schema/stack.json", N = "https://api.hype-stack.dev", P = "HYPE_STACK_API_URL", F = "https://www.hype-stack.dev", ne = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, I = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -53,87 +53,87 @@ function le() {
|
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/ui/theme.ts
|
|
56
|
-
var ue = (e) => `\x1b[38;5;208m${e}\x1b[39m`, de = (e) => `\x1b[38;5;214m${e}\x1b[39m`, R = (e) => `\x1b[38;5;220m${e}\x1b[39m`, fe = (e) => `\x1b[38;5;33m${e}\x1b[39m`,
|
|
56
|
+
var ue = (e) => `\x1b[38;5;208m${e}\x1b[39m`, de = (e) => `\x1b[38;5;214m${e}\x1b[39m`, R = (e) => `\x1b[38;5;220m${e}\x1b[39m`, fe = (e) => `\x1b[38;5;33m${e}\x1b[39m`, z = (e) => `\x1b[38;5;39m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;81m${e}\x1b[39m`, me = {
|
|
57
57
|
orange: ue,
|
|
58
58
|
orangeBright: de,
|
|
59
59
|
amber: R,
|
|
60
60
|
deepBlue: fe,
|
|
61
|
-
skyBlue:
|
|
62
|
-
lightBlue:
|
|
63
|
-
},
|
|
61
|
+
skyBlue: z,
|
|
62
|
+
lightBlue: pe
|
|
63
|
+
}, B = {
|
|
64
64
|
brand: (e) => ue(e),
|
|
65
65
|
brandBold: (e) => b.bold(ue(e)),
|
|
66
|
-
accent: (e) =>
|
|
67
|
-
accentBold: (e) => b.bold(
|
|
66
|
+
accent: (e) => z(e),
|
|
67
|
+
accentBold: (e) => b.bold(z(e)),
|
|
68
68
|
success: (e) => b.green(e),
|
|
69
69
|
error: (e) => b.red(e),
|
|
70
70
|
warning: (e) => b.yellow(e),
|
|
71
71
|
muted: (e) => b.dim(e),
|
|
72
72
|
bold: (e) => b.bold(e),
|
|
73
73
|
highlight: (e) => b.bold(b.white(e)),
|
|
74
|
-
path: (e) => b.underline(
|
|
74
|
+
path: (e) => b.underline(z(e)),
|
|
75
75
|
command: (e) => b.bold(R(e)),
|
|
76
76
|
label: (e) => b.dim(b.bold(e))
|
|
77
77
|
};
|
|
78
|
-
function
|
|
79
|
-
return `\x1b]8;;${e}\x07${
|
|
78
|
+
function he(e, t = e) {
|
|
79
|
+
return `\x1b]8;;${e}\x07${z(t)}\x1b]8;;\x07`;
|
|
80
80
|
}
|
|
81
|
-
var
|
|
81
|
+
var V = {
|
|
82
82
|
arrow: ue("›"),
|
|
83
|
-
bullet:
|
|
84
|
-
dash:
|
|
85
|
-
corner:
|
|
86
|
-
pipe:
|
|
87
|
-
dot:
|
|
83
|
+
bullet: B.muted("·"),
|
|
84
|
+
dash: B.muted("─"),
|
|
85
|
+
corner: B.muted("╰"),
|
|
86
|
+
pipe: B.muted("│"),
|
|
87
|
+
dot: B.muted("•"),
|
|
88
88
|
spark: R("✦"),
|
|
89
89
|
sparkSmall: de("✧"),
|
|
90
90
|
bolt: R("⚡")
|
|
91
|
-
},
|
|
91
|
+
}, ge = [
|
|
92
92
|
R,
|
|
93
93
|
R,
|
|
94
94
|
de,
|
|
95
95
|
ue,
|
|
96
96
|
fe,
|
|
97
|
+
z,
|
|
97
98
|
pe,
|
|
98
|
-
|
|
99
|
-
me
|
|
99
|
+
pe
|
|
100
100
|
];
|
|
101
|
-
function
|
|
101
|
+
function _e(e) {
|
|
102
102
|
let t = [...e], n = t.length;
|
|
103
103
|
return t.map((e, t) => {
|
|
104
104
|
if (e === " " || e === "\n") return e;
|
|
105
105
|
let r = t / Math.max(n - 1, 1);
|
|
106
|
-
return
|
|
106
|
+
return ge[Math.min(Math.floor(r * ge.length), ge.length - 1)](e);
|
|
107
107
|
}).join("");
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function ve(e, t, n) {
|
|
110
110
|
return Math.round(e + (t - e) * n);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function ye(e, t) {
|
|
113
113
|
let { start: n, end: r, angle: i = 1 } = t, a = Math.max(...e.map((e) => e.length), 1), o = Math.max(e.length - 1, 1);
|
|
114
114
|
return e.map((e, t) => [...e].map((e, s) => {
|
|
115
115
|
if (e === " ") return e;
|
|
116
116
|
let c = s / Math.max(a - 1, 1), l = t / o, u = Math.min((c + l * i) / (1 + i), 1);
|
|
117
|
-
return `\x1b[38;2;${
|
|
117
|
+
return `\x1b[38;2;${ve(n[0], r[0], u)};${ve(n[1], r[1], u)};${ve(n[2], r[2], u)}m${e}\x1b[39m`;
|
|
118
118
|
}).join(""));
|
|
119
119
|
}
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/core/license.ts
|
|
122
|
-
function
|
|
122
|
+
function be(e) {
|
|
123
123
|
return `${se()}/packs/${e}`;
|
|
124
124
|
}
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region ../../node_modules/.pnpm/@hyper-fetch+core@8.1.1/node_modules/@hyper-fetch/core/dist/index.mjs
|
|
127
|
-
var
|
|
128
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i =
|
|
127
|
+
var xe = Object.create, Se = Object.defineProperty, Ce = Object.getOwnPropertyDescriptor, we = Object.getOwnPropertyNames, Te = Object.getPrototypeOf, Ee = Object.prototype.hasOwnProperty, De = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), Oe = (e, t, n, r) => {
|
|
128
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = we(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !Ee.call(e, s) && s !== n && Se(e, s, {
|
|
129
129
|
get: ((e) => t[e]).bind(null, s),
|
|
130
|
-
enumerable: !(r =
|
|
130
|
+
enumerable: !(r = Ce(t, s)) || r.enumerable
|
|
131
131
|
});
|
|
132
132
|
return e;
|
|
133
|
-
},
|
|
133
|
+
}, ke = (e, t, n) => (n = e == null ? {} : xe(Te(e)), Oe(t || !e || !e.__esModule ? Se(n, "default", {
|
|
134
134
|
value: e,
|
|
135
135
|
enumerable: !0
|
|
136
|
-
}) : n, e)),
|
|
136
|
+
}) : n, e)), Ae = (e) => `${e.queryKey}_${Date.now().toString(36)}_${Math.random().toString(36).substring(2)}`, je = /* @__PURE__ */ ke((/* @__PURE__ */ De(((e, t) => {
|
|
137
137
|
var n = typeof Reflect == "object" ? Reflect : null, r = n && typeof n.apply == "function" ? n.apply : function(e, t, n) {
|
|
138
138
|
return Function.prototype.apply.call(e, t, n);
|
|
139
139
|
}, i = n && typeof n.ownKeys == "function" ? n.ownKeys : Object.getOwnPropertySymbols ? function(e) {
|
|
@@ -308,7 +308,7 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
308
308
|
});
|
|
309
309
|
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
310
310
|
}
|
|
311
|
-
})))()),
|
|
311
|
+
})))()), Me = (e) => `listen_${String(e)}`, Ne = class extends je.default {
|
|
312
312
|
emitCallbacks = [];
|
|
313
313
|
constructor(e) {
|
|
314
314
|
super(e);
|
|
@@ -320,26 +320,26 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
320
320
|
onEmit = (e) => (this.emitCallbacks?.push(e), () => {
|
|
321
321
|
this.emitCallbacks = this.emitCallbacks?.filter((t) => t !== e);
|
|
322
322
|
});
|
|
323
|
-
onListener = (e, t) => (super.on(
|
|
324
|
-
super.off(
|
|
323
|
+
onListener = (e, t) => (super.on(Me(e), t), () => {
|
|
324
|
+
super.off(Me(e), t);
|
|
325
325
|
});
|
|
326
|
-
on = (e, t) => (super.on(e, t), super.emit(
|
|
327
|
-
off = (e, t) => (super.off(e, t), super.emit(
|
|
326
|
+
on = (e, t) => (super.on(e, t), super.emit(Me(e), super.listeners(e).length), this);
|
|
327
|
+
off = (e, t) => (super.off(e, t), super.emit(Me(e), super.listeners(e).length), this);
|
|
328
328
|
addListener = this.on;
|
|
329
329
|
removeListener = this.off;
|
|
330
|
-
},
|
|
331
|
-
emitter = new
|
|
332
|
-
events =
|
|
330
|
+
}, Pe = class {
|
|
331
|
+
emitter = new Ne();
|
|
332
|
+
events = ze(this.emitter);
|
|
333
333
|
isBrowser;
|
|
334
334
|
isOnline;
|
|
335
335
|
isFocused;
|
|
336
336
|
constructor(e) {
|
|
337
337
|
this.options = e, this.emitter?.setMaxListeners(1e3);
|
|
338
|
-
let { initiallyFocused: t =
|
|
339
|
-
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser =
|
|
338
|
+
let { initiallyFocused: t = Be.initiallyFocused, initiallyOnline: n = Be.initiallyOnline } = this.options || Be;
|
|
339
|
+
this.setInitialFocus(t), this.setInitialOnline(n), this.isBrowser = Ie();
|
|
340
340
|
}
|
|
341
341
|
initialize = () => {
|
|
342
|
-
let { focusEvent: e =
|
|
342
|
+
let { focusEvent: e = Be.focusEvent, onlineEvent: t = Be.onlineEvent } = this.options || Be;
|
|
343
343
|
e(this.setFocused), t(this.setOnline);
|
|
344
344
|
};
|
|
345
345
|
setInitialFocus = async (e) => {
|
|
@@ -354,51 +354,51 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
354
354
|
setOnline = (e) => {
|
|
355
355
|
this.isOnline = e, e ? this.events.emitOnline() : this.events.emitOffline();
|
|
356
356
|
};
|
|
357
|
-
},
|
|
357
|
+
}, Fe = () => {
|
|
358
358
|
try {
|
|
359
359
|
return !!(window && window.addEventListener);
|
|
360
360
|
} catch {
|
|
361
361
|
/* istanbul ignore next */
|
|
362
362
|
return !1;
|
|
363
363
|
}
|
|
364
|
-
},
|
|
364
|
+
}, Ie = () => {
|
|
365
365
|
try {
|
|
366
|
-
return !!(
|
|
366
|
+
return !!(Fe() && window.document && window.document.addEventListener);
|
|
367
367
|
} catch {
|
|
368
368
|
/* istanbul ignore next */
|
|
369
369
|
return !1;
|
|
370
370
|
}
|
|
371
|
-
},
|
|
371
|
+
}, Le = (e, t, n) => Fe() ? (window.addEventListener(e, t, n), () => window.removeEventListener(e, t, n)) : () => null, Re = (e, t, n) => Ie() ? (window.document.addEventListener(e, t, n), () => window.document.removeEventListener(e, t, n)) : () => null, ze = (e) => ({
|
|
372
372
|
emitFocus: () => {
|
|
373
|
-
e.emit(
|
|
373
|
+
e.emit(H.FOCUS);
|
|
374
374
|
},
|
|
375
375
|
emitBlur: () => {
|
|
376
|
-
e.emit(
|
|
376
|
+
e.emit(H.BLUR);
|
|
377
377
|
},
|
|
378
378
|
emitOnline: () => {
|
|
379
|
-
e.emit(
|
|
379
|
+
e.emit(H.ONLINE);
|
|
380
380
|
},
|
|
381
381
|
emitOffline: () => {
|
|
382
|
-
e.emit(
|
|
382
|
+
e.emit(H.OFFLINE);
|
|
383
383
|
},
|
|
384
|
-
onFocus: (t) => (e.on(
|
|
385
|
-
onBlur: (t) => (e.on(
|
|
386
|
-
onOnline: (t) => (e.on(
|
|
387
|
-
onOffline: (t) => (e.on(
|
|
388
|
-
}),
|
|
384
|
+
onFocus: (t) => (e.on(H.FOCUS, t), () => e.removeListener(H.FOCUS, t)),
|
|
385
|
+
onBlur: (t) => (e.on(H.BLUR, t), () => e.removeListener(H.BLUR, t)),
|
|
386
|
+
onOnline: (t) => (e.on(H.ONLINE, t), () => e.removeListener(H.ONLINE, t)),
|
|
387
|
+
onOffline: (t) => (e.on(H.OFFLINE, t), () => e.removeListener(H.OFFLINE, t))
|
|
388
|
+
}), H = /* @__PURE__ */ function(e) {
|
|
389
389
|
return e.FOCUS = "focus", e.BLUR = "blur", e.ONLINE = "online", e.OFFLINE = "offline", e;
|
|
390
|
-
}({}),
|
|
390
|
+
}({}), Be = {
|
|
391
391
|
initiallyFocused: !0,
|
|
392
392
|
initiallyOnline: !0,
|
|
393
393
|
focusEvent: (e) => {
|
|
394
|
-
|
|
394
|
+
Re("visibilitychange", () => e(!0)), Le("focus", () => e(!0)), Le("blur", () => e(!1));
|
|
395
395
|
},
|
|
396
396
|
onlineEvent: (e) => {
|
|
397
|
-
|
|
397
|
+
Le("online", () => e(!0)), Le("offline", () => e(!1));
|
|
398
398
|
}
|
|
399
|
-
},
|
|
400
|
-
emitter = new
|
|
401
|
-
events =
|
|
399
|
+
}, Ve = class {
|
|
400
|
+
emitter = new Ne();
|
|
401
|
+
events = _t(this.emitter);
|
|
402
402
|
constructor() {
|
|
403
403
|
this.emitter?.setMaxListeners(1e3);
|
|
404
404
|
}
|
|
@@ -435,71 +435,71 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
435
435
|
});
|
|
436
436
|
});
|
|
437
437
|
};
|
|
438
|
-
},
|
|
438
|
+
}, He = () => "loading-event-any", Ue = (e) => `${e}-loading-event`, We = (e) => `${e}-loading-cache-event`, Ge = (e) => `${e}-loading-event-by-id`, Ke = () => "remove-event-any", qe = (e) => `${e}-remove-event`, Je = (e) => `${e}-remove-event-by-id`, Ye = () => "request-abort-any", Xe = (e) => `${e}-request-abort`, Ze = (e) => `${e}-request-abort-by-id`, Qe = () => "response-any", $e = (e) => `${e}-response`, et = (e) => `${e}-response-by-id`, tt = () => "request-start-any", nt = (e) => `${e}-request-start`, rt = (e) => `${e}-request-start-by-id`, it = () => "response-start-any", at = (e) => `${e}-response-start`, ot = (e) => `${e}-response-start-by-id`, st = () => "request-progress-any", ct = (e) => `${e}-request-progress`, lt = (e) => `${e}-request-progress-by-id`, ut = () => "response-progress-any", dt = (e) => `${e}-response-progress`, ft = (e) => `${e}-response-progress-by-id`, pt = () => "request-deduplicated-any", mt = (e) => `${e}-query-request-deduplicated`, ht = (e) => `${e}-cache-request-deduplicated`, gt = (e) => `${e}-request-deduplicated-by-id`, _t = (e) => ({
|
|
439
439
|
emitDeduplicated: (t, n = !1) => {
|
|
440
|
-
e.emit(
|
|
440
|
+
e.emit(pt(), t, n), e.emit(gt(t.requestId), t, n), e.emit(ht(t.request.cacheKey), t, n), e.emit(mt(t.request.queryKey), t, n);
|
|
441
441
|
},
|
|
442
442
|
emitLoading: (t, n = !1) => {
|
|
443
|
-
e.emit(
|
|
443
|
+
e.emit(He(), t, n), e.emit(Ge(t.requestId), t, n), e.emit(We(t.request.cacheKey), t, n), e.emit(Ue(t.request.queryKey), t, n);
|
|
444
444
|
},
|
|
445
445
|
emitRequestStart: (t, n = !1) => {
|
|
446
|
-
e.emit(
|
|
446
|
+
e.emit(tt(), t, n), e.emit(rt(t.requestId), t, n), e.emit(nt(t.request.queryKey), t, n);
|
|
447
447
|
},
|
|
448
448
|
emitResponseStart: (t, n = !1) => {
|
|
449
|
-
e.emit(
|
|
449
|
+
e.emit(it(), t, n), e.emit(ot(t.requestId), t, n), e.emit(at(t.request.queryKey), t, n);
|
|
450
450
|
},
|
|
451
451
|
emitUploadProgress: (t, n = !1) => {
|
|
452
|
-
e.emit(
|
|
452
|
+
e.emit(st(), t, n), e.emit(lt(t.requestId), t, n), e.emit(ct(t.request.queryKey), t, n);
|
|
453
453
|
},
|
|
454
454
|
emitDownloadProgress: (t, n = !1) => {
|
|
455
|
-
e.emit(
|
|
455
|
+
e.emit(ut(), t, n), e.emit(ft(t.requestId), t, n), e.emit(dt(t.request.queryKey), t, n);
|
|
456
456
|
},
|
|
457
457
|
emitResponse: (t, n = !1) => {
|
|
458
|
-
e.emit(
|
|
458
|
+
e.emit(Qe(), t, n), e.emit(et(t.requestId), t, n), e.emit($e(t.request.cacheKey), t, n);
|
|
459
459
|
},
|
|
460
460
|
emitAbort: (t, n = !1) => {
|
|
461
|
-
e.emit(
|
|
461
|
+
e.emit(Ye(), t, n), e.emit(Ze(t.requestId), t, n), e.emit(Xe(t.request.abortKey), t, n);
|
|
462
462
|
},
|
|
463
463
|
emitRemove: (t, n = !1) => {
|
|
464
|
-
e.emit(
|
|
464
|
+
e.emit(Ke(), t, n), e.emit(Je(t.requestId), t, n), e.emit(qe(t.request.queryKey), t, n);
|
|
465
465
|
},
|
|
466
|
-
onDeduplicated: (t) => (e.on(
|
|
467
|
-
onDeduplicatedByQueue: (t, n) => (e.on(
|
|
468
|
-
onDeduplicatedByCache: (t, n) => (e.on(
|
|
469
|
-
onDeduplicatedById: (t, n) => (e.on(
|
|
470
|
-
onLoading: (t) => (e.on(
|
|
471
|
-
onLoadingByQueue: (t, n) => (e.on(
|
|
472
|
-
onLoadingByCache: (t, n) => (e.on(
|
|
473
|
-
onLoadingById: (t, n) => (e.on(
|
|
474
|
-
onRequestStart: (t) => (e.on(
|
|
475
|
-
onRequestStartByQueue: (t, n) => (e.on(
|
|
476
|
-
onRequestStartById: (t, n) => (e.on(
|
|
477
|
-
onResponseStart: (t) => (e.on(
|
|
478
|
-
onResponseStartByQueue: (t, n) => (e.on(
|
|
479
|
-
onResponseStartById: (t, n) => (e.on(
|
|
480
|
-
onUploadProgress: (t) => (e.on(
|
|
481
|
-
onUploadProgressByQueue: (t, n) => (e.on(
|
|
482
|
-
onUploadProgressById: (t, n) => (e.on(
|
|
483
|
-
onDownloadProgress: (t) => (e.on(
|
|
484
|
-
onDownloadProgressByQueue: (t, n) => (e.on(
|
|
485
|
-
onDownloadProgressById: (t, n) => (e.on(
|
|
486
|
-
onResponse: (t) => (e.on(
|
|
487
|
-
onResponseByCache: (t, n) => (e.on(
|
|
488
|
-
onResponseById: (t, n) => (e.on(
|
|
489
|
-
onAbort: (t) => (e.on(
|
|
490
|
-
onAbortByKey: (t, n) => (e.on(
|
|
491
|
-
onAbortById: (t, n) => (e.on(
|
|
492
|
-
onRemove: (t) => (e.on(
|
|
493
|
-
onRemoveByQueue: (t, n) => (e.on(
|
|
494
|
-
onRemoveById: (t, n) => (e.on(
|
|
495
|
-
}),
|
|
466
|
+
onDeduplicated: (t) => (e.on(pt(), t), () => e.removeListener(pt(), t)),
|
|
467
|
+
onDeduplicatedByQueue: (t, n) => (e.on(mt(t), n), () => e.removeListener(mt(t), n)),
|
|
468
|
+
onDeduplicatedByCache: (t, n) => (e.on(ht(t), n), () => e.removeListener(ht(t), n)),
|
|
469
|
+
onDeduplicatedById: (t, n) => (e.on(gt(t), n), () => e.removeListener(gt(t), n)),
|
|
470
|
+
onLoading: (t) => (e.on(He(), t), () => e.removeListener(He(), t)),
|
|
471
|
+
onLoadingByQueue: (t, n) => (e.on(Ue(t), n), () => e.removeListener(Ue(t), n)),
|
|
472
|
+
onLoadingByCache: (t, n) => (e.on(We(t), n), () => e.removeListener(We(t), n)),
|
|
473
|
+
onLoadingById: (t, n) => (e.on(Ge(t), n), () => e.removeListener(Ge(t), n)),
|
|
474
|
+
onRequestStart: (t) => (e.on(tt(), t), () => e.removeListener(tt(), t)),
|
|
475
|
+
onRequestStartByQueue: (t, n) => (e.on(nt(t), n), () => e.removeListener(nt(t), n)),
|
|
476
|
+
onRequestStartById: (t, n) => (e.on(rt(t), n), () => e.removeListener(rt(t), n)),
|
|
477
|
+
onResponseStart: (t) => (e.on(it(), t), () => e.removeListener(it(), t)),
|
|
478
|
+
onResponseStartByQueue: (t, n) => (e.on(at(t), n), () => e.removeListener(at(t), n)),
|
|
479
|
+
onResponseStartById: (t, n) => (e.on(ot(t), n), () => e.removeListener(ot(t), n)),
|
|
480
|
+
onUploadProgress: (t) => (e.on(st(), t), () => e.removeListener(st(), t)),
|
|
481
|
+
onUploadProgressByQueue: (t, n) => (e.on(ct(t), n), () => e.removeListener(ct(t), n)),
|
|
482
|
+
onUploadProgressById: (t, n) => (e.on(lt(t), n), () => e.removeListener(lt(t), n)),
|
|
483
|
+
onDownloadProgress: (t) => (e.on(ut(), t), () => e.removeListener(ut(), t)),
|
|
484
|
+
onDownloadProgressByQueue: (t, n) => (e.on(dt(t), n), () => e.removeListener(dt(t), n)),
|
|
485
|
+
onDownloadProgressById: (t, n) => (e.on(ft(t), n), () => e.removeListener(ft(t), n)),
|
|
486
|
+
onResponse: (t) => (e.on(Qe(), t), () => e.removeListener(Qe(), t)),
|
|
487
|
+
onResponseByCache: (t, n) => (e.on($e(t), n), () => e.removeListener($e(t), n)),
|
|
488
|
+
onResponseById: (t, n) => (e.on(et(t), n), () => e.removeListener(et(t), n)),
|
|
489
|
+
onAbort: (t) => (e.on(Ye(), t), () => e.removeListener(Ye(), t)),
|
|
490
|
+
onAbortByKey: (t, n) => (e.on(Xe(t), n), () => e.removeListener(Xe(t), n)),
|
|
491
|
+
onAbortById: (t, n) => (e.on(Ze(t), n), () => e.removeListener(Ze(t), n)),
|
|
492
|
+
onRemove: (t) => (e.on(Ke(), t), () => e.removeListener(Ke(), t)),
|
|
493
|
+
onRemoveByQueue: (t, n) => (e.on(qe(t), n), () => e.removeListener(qe(t), n)),
|
|
494
|
+
onRemoveById: (t, n) => (e.on(Je(t), n), () => e.removeListener(Je(t), n))
|
|
495
|
+
}), vt = class {
|
|
496
496
|
logger;
|
|
497
497
|
level;
|
|
498
498
|
modules;
|
|
499
|
-
emitter = new
|
|
499
|
+
emitter = new je.default();
|
|
500
500
|
client;
|
|
501
501
|
constructor(e) {
|
|
502
|
-
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger ||
|
|
502
|
+
this.options = e, this.emitter?.setMaxListeners(1e3), this.logger = this.options?.logger || xt, this.level = this.options?.level || "warning", this.modules = this.options?.modules;
|
|
503
503
|
}
|
|
504
504
|
setSeverity = (e) => {
|
|
505
505
|
this.level = e;
|
|
@@ -530,58 +530,58 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
530
530
|
})
|
|
531
531
|
});
|
|
532
532
|
log = (e) => {
|
|
533
|
-
this.client.debug && (
|
|
533
|
+
this.client.debug && (St.indexOf(this.level) <= St.indexOf(e.level) || this.modules && !this.modules.includes(e.module) || this.logger(e));
|
|
534
534
|
};
|
|
535
|
-
},
|
|
536
|
-
let t =
|
|
535
|
+
}, yt = () => `${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`, bt = (e) => e.type === "request" || e.type === "response" ? `${e.extra.request.endpoint}` : `[${e.module}]`, xt = (e) => {
|
|
536
|
+
let t = wt[e.level], n = Tt[e.level], r = `%c[${yt()}]%c${e.title}%c${bt(e)}`, i = `${t}${n}font-weight:600;border-radius: 4px 0 0 4px;`, a = `${t}${n}font-weight:600;`, o = `${t}font-weight:normal;border-radius: 0 4px 4px 0;`;
|
|
537
537
|
e.extra && Object.keys(e.extra)?.length ? (console.groupCollapsed(r, i, a, o), console.log(e.extra), console.groupEnd()) : console.log(r, t);
|
|
538
|
-
},
|
|
538
|
+
}, St = [
|
|
539
539
|
"error",
|
|
540
540
|
"warning",
|
|
541
541
|
"info",
|
|
542
542
|
"debug"
|
|
543
|
-
],
|
|
544
|
-
error: `${
|
|
545
|
-
warning: `${
|
|
546
|
-
info: `${
|
|
547
|
-
debug: `${
|
|
548
|
-
},
|
|
543
|
+
], Ct = "padding:2px 5px;", wt = {
|
|
544
|
+
error: `${Ct};background:#db252520;`,
|
|
545
|
+
warning: `${Ct};background:#e1941e20;`,
|
|
546
|
+
info: `${Ct};background:#1e74e120;`,
|
|
547
|
+
debug: `${Ct};background:#00000020;`
|
|
548
|
+
}, Tt = {
|
|
549
549
|
error: "color:#ff3737;",
|
|
550
550
|
warning: "color:#ffc107;",
|
|
551
551
|
info: "color:#34a8ff;",
|
|
552
552
|
debug: "color:#cccccc;"
|
|
553
|
-
},
|
|
553
|
+
}, Et = class extends Error {
|
|
554
554
|
constructor() {
|
|
555
555
|
super("Request timeout"), this.name = "TimeoutError";
|
|
556
556
|
}
|
|
557
|
-
},
|
|
557
|
+
}, Dt = class extends Error {
|
|
558
558
|
constructor() {
|
|
559
559
|
super("Request aborted"), this.name = "AbortError";
|
|
560
560
|
}
|
|
561
|
-
},
|
|
561
|
+
}, Ot = class extends Error {
|
|
562
562
|
constructor() {
|
|
563
563
|
super("Request deleted"), this.name = "DeletedError";
|
|
564
564
|
}
|
|
565
|
-
},
|
|
565
|
+
}, kt = class extends Error {
|
|
566
566
|
description;
|
|
567
567
|
constructor(e) {
|
|
568
568
|
super("Request processing error"), this.description = e, this.name = "RequestProcessingError";
|
|
569
569
|
}
|
|
570
|
-
},
|
|
570
|
+
}, At = class extends Error {
|
|
571
571
|
description;
|
|
572
572
|
constructor(e) {
|
|
573
573
|
super("Unexpected error"), this.description = e, this.name = "UnexpectedError";
|
|
574
574
|
}
|
|
575
|
-
},
|
|
575
|
+
}, jt = (e) => e === "timeout" ? new Et() : e === "abort" ? new Dt() : e === "deleted" ? new Ot() : e === "processing" ? new kt() : new At(), Mt = (e) => {
|
|
576
576
|
try {
|
|
577
577
|
return JSON.stringify(e);
|
|
578
578
|
} catch {
|
|
579
579
|
return "";
|
|
580
580
|
}
|
|
581
|
-
},
|
|
582
|
-
let t =
|
|
581
|
+
}, Nt = (e) => {
|
|
582
|
+
let t = Fe() && e.payload instanceof FormData, n = typeof e.payload == "object" && e.payload !== null, r = {};
|
|
583
583
|
return !t && n && (r["Content-Type"] = "application/json"), Object.assign(r, e.headers), r;
|
|
584
|
-
},
|
|
584
|
+
}, Pt = (e) => Fe() && e instanceof FormData ? e : Mt(e), Ft = [
|
|
585
585
|
"onBeforeSent",
|
|
586
586
|
"onRequestStart",
|
|
587
587
|
"onResponseStart",
|
|
@@ -590,7 +590,7 @@ var Se = Object.create, Ce = Object.defineProperty, we = Object.getOwnPropertyDe
|
|
|
590
590
|
"onResponse",
|
|
591
591
|
"onRemove"
|
|
592
592
|
];
|
|
593
|
-
function
|
|
593
|
+
function It(e) {
|
|
594
594
|
let t = {
|
|
595
595
|
onBeforeSent: [],
|
|
596
596
|
onRequestStart: [],
|
|
@@ -600,7 +600,7 @@ function Lt(e) {
|
|
|
600
600
|
onResponse: [],
|
|
601
601
|
onRemove: []
|
|
602
602
|
};
|
|
603
|
-
e &&
|
|
603
|
+
e && Ft.forEach((n) => {
|
|
604
604
|
t[n] = [...e[n]];
|
|
605
605
|
});
|
|
606
606
|
let n = (e) => (n) => (t[e].push(n), () => {
|
|
@@ -622,15 +622,15 @@ function Lt(e) {
|
|
|
622
622
|
},
|
|
623
623
|
__snapshot() {
|
|
624
624
|
let e = {};
|
|
625
|
-
return
|
|
625
|
+
return Ft.forEach((n) => {
|
|
626
626
|
e[n] = [...t[n]];
|
|
627
627
|
}), e;
|
|
628
628
|
}
|
|
629
629
|
};
|
|
630
630
|
}
|
|
631
|
-
var
|
|
631
|
+
var Lt = /* @__PURE__ */ function(e) {
|
|
632
632
|
return e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.PATCH = "PATCH", e.DELETE = "DELETE", e;
|
|
633
|
-
}({}),
|
|
633
|
+
}({}), U = (e, t) => t ? `${t}__${e}` : e, Rt = (e) => {
|
|
634
634
|
try {
|
|
635
635
|
if (typeof e == "string") return e;
|
|
636
636
|
if (e == null) return "";
|
|
@@ -640,13 +640,13 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
640
640
|
} catch {
|
|
641
641
|
return "";
|
|
642
642
|
}
|
|
643
|
-
},
|
|
643
|
+
}, zt = ({ loaded: e, total: t }) => !e || !t ? 0 : Number((e * 100 / t).toFixed(0)), Bt = (e, t, { total: n, loaded: r }) => {
|
|
644
644
|
let i = r / (t - +e || 1), a = Math.max(n, r), o = a - r, s = i ? o / i : null;
|
|
645
645
|
return {
|
|
646
646
|
timeLeft: a === r ? 0 : s,
|
|
647
647
|
sizeLeft: o
|
|
648
648
|
};
|
|
649
|
-
},
|
|
649
|
+
}, Vt = (e, t, n) => {
|
|
650
650
|
let { total: r, loaded: i } = n;
|
|
651
651
|
if (Number.isNaN(r) || Number.isNaN(i)) return {
|
|
652
652
|
progress: 0,
|
|
@@ -656,23 +656,23 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
656
656
|
loaded: 0,
|
|
657
657
|
startTimestamp: +e
|
|
658
658
|
};
|
|
659
|
-
let { timeLeft: a, sizeLeft: o } =
|
|
659
|
+
let { timeLeft: a, sizeLeft: o } = Bt(e, t, n);
|
|
660
660
|
return {
|
|
661
|
-
progress:
|
|
661
|
+
progress: zt(n),
|
|
662
662
|
timeLeft: a,
|
|
663
663
|
sizeLeft: o,
|
|
664
664
|
total: r,
|
|
665
665
|
loaded: i,
|
|
666
666
|
startTimestamp: +e
|
|
667
667
|
};
|
|
668
|
-
},
|
|
669
|
-
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method ===
|
|
668
|
+
}, Ht = (e) => `${e.method}_${e.requestOptions.endpoint}_${e.cancelable}`, Ut = (e, t) => `${Rt(e.method)}_${t ? e.requestOptions.endpoint : Rt(e.endpoint)}_${t ? "" : Rt(e.queryParams)}`, Wt = (e, t = "auto") => {
|
|
669
|
+
let { fetchDispatcher: n, submitDispatcher: r } = e.client, i = e.method === Lt.GET, a = t === "auto" && i || t === "fetch";
|
|
670
670
|
return [a ? n : r, a];
|
|
671
|
-
},
|
|
671
|
+
}, Gt = async (e, t) => {
|
|
672
672
|
let n = e.unstable_responseMapper?.(t);
|
|
673
673
|
return n instanceof Promise ? await n : n || t;
|
|
674
|
-
},
|
|
675
|
-
let { client: n } = e, { requestManager: r } = n, [i] =
|
|
674
|
+
}, Kt = async (e, t) => {
|
|
675
|
+
let { client: n } = e, { requestManager: r } = n, [i] = Wt(e, t?.dispatcherType), a;
|
|
676
676
|
if (e.optimistic) try {
|
|
677
677
|
a = await e.optimistic({
|
|
678
678
|
request: e,
|
|
@@ -748,7 +748,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
748
748
|
data: null,
|
|
749
749
|
status: null,
|
|
750
750
|
success: !1,
|
|
751
|
-
error:
|
|
751
|
+
error: jt("deleted"),
|
|
752
752
|
extra: e.client.adapter.defaultExtra,
|
|
753
753
|
requestTimestamp: +/* @__PURE__ */ new Date(),
|
|
754
754
|
responseTimestamp: +/* @__PURE__ */ new Date()
|
|
@@ -759,9 +759,9 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
759
759
|
u(), d(), f(), p(), m(), h();
|
|
760
760
|
}
|
|
761
761
|
});
|
|
762
|
-
},
|
|
762
|
+
}, qt = /* @__PURE__ */ function(e) {
|
|
763
763
|
return e[e.SEC = 1e3] = "SEC", e[e.MIN = 6e4] = "MIN", e[e.HOUR = 36e5] = "HOUR", e[e.DAY = 864e5] = "DAY", e[e.WEEK = 6048e5] = "WEEK", e[e.MONTH_30 = 2592e6] = "MONTH_30", e[e.MONTH_31 = 26784e5] = "MONTH_31", e[e.YEAR = 31536e6] = "YEAR", e[e.YEAR_LEAP = 316224e5] = "YEAR_LEAP", e;
|
|
764
|
-
}({}),
|
|
764
|
+
}({}), Jt = class e {
|
|
765
765
|
endpoint;
|
|
766
766
|
headers;
|
|
767
767
|
auth;
|
|
@@ -785,7 +785,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
785
785
|
deduplicate;
|
|
786
786
|
deduplicateTime;
|
|
787
787
|
scope;
|
|
788
|
-
$hooks =
|
|
788
|
+
$hooks = It();
|
|
789
789
|
isMockerEnabled = !1;
|
|
790
790
|
unstable_mock;
|
|
791
791
|
unstable_payloadMapper;
|
|
@@ -802,7 +802,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
802
802
|
updatedQueryKey;
|
|
803
803
|
constructor(e, t, n) {
|
|
804
804
|
this.client = e, this.requestOptions = t, this.initialRequestConfiguration = n;
|
|
805
|
-
let { endpoint: r, headers: i, auth: a = !0, method: o = e.adapter.defaultMethod, options: s, cancelable: c = !1, retry: l = 0, retryTime: u = 500, cacheTime: d =
|
|
805
|
+
let { endpoint: r, headers: i, auth: a = !0, method: o = e.adapter.defaultMethod, options: s, cancelable: c = !1, retry: l = 0, retryTime: u = 500, cacheTime: d = qt.MIN * 5, cache: f = !0, staleTime: p = qt.MIN * 5, queued: m = !1, offline: h = !0, abortKey: g, cacheKey: _, queryKey: v, deduplicate: y = !1, deduplicateTime: b = null } = {
|
|
806
806
|
...this.client.adapter.unstable_getRequestDefaults?.(t),
|
|
807
807
|
...t
|
|
808
808
|
};
|
|
@@ -912,11 +912,11 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
912
912
|
payload: t?.payload || this.payload,
|
|
913
913
|
params: t?.params || this.params
|
|
914
914
|
}, r = new e(this.client, this.requestOptions, n);
|
|
915
|
-
return r.unstable_payloadMapper = this.unstable_payloadMapper, r.unstable_responseMapper = this.unstable_responseMapper, r.unstable_requestMapper = this.unstable_requestMapper, r.retryOnError = this.retryOnError, r.unstable_mock = this.unstable_mock, r.isMockerEnabled = this.isMockerEnabled, r.optimistic = this.optimistic, r.$hooks =
|
|
915
|
+
return r.unstable_payloadMapper = this.unstable_payloadMapper, r.unstable_responseMapper = this.unstable_responseMapper, r.unstable_requestMapper = this.unstable_requestMapper, r.retryOnError = this.retryOnError, r.unstable_mock = this.unstable_mock, r.isMockerEnabled = this.isMockerEnabled, r.optimistic = this.optimistic, r.$hooks = It(this.$hooks.__snapshot()), r;
|
|
916
916
|
}
|
|
917
917
|
abort = () => {
|
|
918
918
|
let { requestManager: e } = this.client;
|
|
919
|
-
return e.abortByKey(
|
|
919
|
+
return e.abortByKey(U(this.abortKey, this.scope)), this.clone();
|
|
920
920
|
};
|
|
921
921
|
dehydrate = (e) => {
|
|
922
922
|
let { response: t, override: n = !0 } = e || {};
|
|
@@ -931,7 +931,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
931
931
|
cache: !0,
|
|
932
932
|
response: t
|
|
933
933
|
};
|
|
934
|
-
let r = this.client.cache.get(
|
|
934
|
+
let r = this.client.cache.get(U(this.cacheKey, this.scope));
|
|
935
935
|
if (r) return {
|
|
936
936
|
override: n,
|
|
937
937
|
cacheTime: this.cacheTime,
|
|
@@ -953,7 +953,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
953
953
|
};
|
|
954
954
|
};
|
|
955
955
|
read() {
|
|
956
|
-
let e = this.client.cache.get(
|
|
956
|
+
let e = this.client.cache.get(U(this.cacheKey, this.scope));
|
|
957
957
|
if (e) return {
|
|
958
958
|
data: e.data,
|
|
959
959
|
error: e.error,
|
|
@@ -965,7 +965,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
965
965
|
};
|
|
966
966
|
}
|
|
967
967
|
exec = async (e) => {
|
|
968
|
-
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a =
|
|
968
|
+
let { adapter: t, requestManager: n } = this.client, r = this.clone(e), i = this.client.unstable_requestIdMapper(this), a = U(this.abortKey, this.scope);
|
|
969
969
|
n.addAbortController(a, i);
|
|
970
970
|
let o = await t.fetch(r, i);
|
|
971
971
|
return n.removeAbortController(a, i), r.unstable_responseMapper ? r.unstable_responseMapper(o) : o;
|
|
@@ -975,17 +975,17 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
975
975
|
...e,
|
|
976
976
|
cachePolicy: void 0
|
|
977
977
|
};
|
|
978
|
-
if (n === "network-only") return
|
|
978
|
+
if (n === "network-only") return Kt(i, a);
|
|
979
979
|
let o = i.read();
|
|
980
|
-
if (n === "cache-first") return o ?
|
|
980
|
+
if (n === "cache-first") return o ? Gt(i, o) : Kt(i, a);
|
|
981
981
|
if (o) {
|
|
982
|
-
let e = await
|
|
983
|
-
return
|
|
982
|
+
let e = await Gt(i, o);
|
|
983
|
+
return Kt(i, a), e;
|
|
984
984
|
}
|
|
985
|
-
return
|
|
985
|
+
return Kt(i, a);
|
|
986
986
|
};
|
|
987
987
|
static fromJSON = (t, n) => new e(t, n.requestOptions, n);
|
|
988
|
-
},
|
|
988
|
+
}, Yt = async ({ request: e, requestId: t, resolve: n, onStartTime: r, internalErrorMapping: i }) => {
|
|
989
989
|
let { requestManager: a, loggerManager: o } = e.client, { unstable_payloadMapper: s } = e.client.adapter, c = o.initialize(e.client, "Adapter"), l = null, u = null, d = e, f = 1, p = 1, m = 0, h = 0;
|
|
990
990
|
c.debug({
|
|
991
991
|
title: "Running middleware callbacks",
|
|
@@ -995,7 +995,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
995
995
|
requestId: t
|
|
996
996
|
}
|
|
997
997
|
}), d = await d.client.unstable_modifyRequest(d), d.auth && (d = await d.client.unstable_modifyAuth(d)), d.unstable_requestMapper && (d = await d.unstable_requestMapper(d, t));
|
|
998
|
-
let { client: g, abortKey: _ } = d, v =
|
|
998
|
+
let { client: g, abortKey: _ } = d, v = U(_, d.scope), y = d.payload;
|
|
999
999
|
d.unstable_payloadMapper ? y = await d.unstable_payloadMapper(d.payload) : s && (y = await s(y));
|
|
1000
1000
|
let b = d.options, x = +/* @__PURE__ */ new Date();
|
|
1001
1001
|
r(x);
|
|
@@ -1004,14 +1004,14 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
1004
1004
|
let n = Number(t.total || 0), r = Number(t.loaded || 0);
|
|
1005
1005
|
return Math.max(n, r, e);
|
|
1006
1006
|
}, T = (e, n, r) => {
|
|
1007
|
-
let i =
|
|
1007
|
+
let i = Vt(new Date(e), new Date(n), r);
|
|
1008
1008
|
m !== 100 && (m = i.total, a.events.emitUploadProgress({
|
|
1009
1009
|
...i,
|
|
1010
1010
|
requestId: t,
|
|
1011
1011
|
request: d
|
|
1012
1012
|
}));
|
|
1013
1013
|
}, E = (e, n, r) => {
|
|
1014
|
-
let i =
|
|
1014
|
+
let i = Vt(new Date(e), new Date(n), r);
|
|
1015
1015
|
h !== 100 && (h = i.total, a.events.emitDownloadProgress({
|
|
1016
1016
|
...i,
|
|
1017
1017
|
requestId: t,
|
|
@@ -1106,7 +1106,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
1106
1106
|
response: o
|
|
1107
1107
|
}
|
|
1108
1108
|
}), o;
|
|
1109
|
-
}, N =
|
|
1109
|
+
}, N = Xt({
|
|
1110
1110
|
request: d,
|
|
1111
1111
|
requestId: t,
|
|
1112
1112
|
startTime: x,
|
|
@@ -1120,7 +1120,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
1120
1120
|
requestId: t
|
|
1121
1121
|
}
|
|
1122
1122
|
}), N({
|
|
1123
|
-
error: i(
|
|
1123
|
+
error: i(jt("abort")),
|
|
1124
1124
|
status: e,
|
|
1125
1125
|
extra: n
|
|
1126
1126
|
})), F = ({ status: e, extra: n }) => (c.error({
|
|
@@ -1131,7 +1131,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
1131
1131
|
requestId: t
|
|
1132
1132
|
}
|
|
1133
1133
|
}), N({
|
|
1134
|
-
error:
|
|
1134
|
+
error: jt("timeout"),
|
|
1135
1135
|
status: e,
|
|
1136
1136
|
extra: n
|
|
1137
1137
|
})), ne = ({ status: e, extra: n }) => (c.error({
|
|
@@ -1142,12 +1142,12 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
1142
1142
|
requestId: t
|
|
1143
1143
|
}
|
|
1144
1144
|
}), N({
|
|
1145
|
-
error:
|
|
1145
|
+
error: jt(),
|
|
1146
1146
|
status: e,
|
|
1147
1147
|
extra: n
|
|
1148
1148
|
})), I = () => a.getAbortController(v, t), re = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1149
1149
|
let i = I();
|
|
1150
|
-
if (!i) throw new
|
|
1150
|
+
if (!i) throw new kt("Controller is not found");
|
|
1151
1151
|
let o = () => {
|
|
1152
1152
|
P({
|
|
1153
1153
|
status: e,
|
|
@@ -1198,7 +1198,7 @@ var Rt = /* @__PURE__ */ function(e) {
|
|
|
1198
1198
|
onError: N
|
|
1199
1199
|
};
|
|
1200
1200
|
};
|
|
1201
|
-
function
|
|
1201
|
+
function Xt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
1202
1202
|
let { client: a } = e;
|
|
1203
1203
|
return async ({ error: o, status: s, extra: c }) => {
|
|
1204
1204
|
let l = {
|
|
@@ -1227,8 +1227,8 @@ function Zt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
|
1227
1227
|
}), l;
|
|
1228
1228
|
};
|
|
1229
1229
|
}
|
|
1230
|
-
var
|
|
1231
|
-
if (!e.unstable_mock) throw new
|
|
1230
|
+
var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTimeoutError: i, onRequestEnd: a, createAbortListener: o, onResponseProgress: s, onRequestProgress: c, onResponseStart: l, onBeforeRequest: u, onRequestStart: d, onSuccess: f, onAbortError: p, adapter: m }) => {
|
|
1231
|
+
if (!e.unstable_mock) throw new kt("Mock should be defined when calling mocker");
|
|
1232
1232
|
let h = !1, { requestTime: g = 20, responseTime: _ = 20, totalUploaded: v = 1e3, totalDownloaded: y = 1e3, timeout: b } = e.unstable_mock.config, { data: x, error: S, status: C, success: w = !0, extra: T = e.client.adapter.defaultExtra } = await e.unstable_mock.fn({
|
|
1233
1233
|
request: e,
|
|
1234
1234
|
requestId: t
|
|
@@ -1272,7 +1272,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1272
1272
|
status: C,
|
|
1273
1273
|
extra: T
|
|
1274
1274
|
}), h || r();
|
|
1275
|
-
},
|
|
1275
|
+
}, Qt = (e) => e, $t = class {
|
|
1276
1276
|
unstable_fetcher;
|
|
1277
1277
|
name;
|
|
1278
1278
|
defaultMethod;
|
|
@@ -1294,10 +1294,10 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1294
1294
|
initialize = (e) => (this.logger = e.loggerManager.initialize(e, "Adapter"), this.initialized = !0, this.client = e, this.unstable_onInitializeCallback?.({ client: e }), this);
|
|
1295
1295
|
onInitialize = (e) => (this.unstable_onInitializeCallback = e, this);
|
|
1296
1296
|
unstable_internalErrorMapping = (e) => e;
|
|
1297
|
-
unstable_headerMapper =
|
|
1298
|
-
unstable_payloadMapper =
|
|
1299
|
-
unstable_endpointMapper =
|
|
1300
|
-
unstable_queryParamsMapper =
|
|
1297
|
+
unstable_headerMapper = Nt;
|
|
1298
|
+
unstable_payloadMapper = Pt;
|
|
1299
|
+
unstable_endpointMapper = Qt;
|
|
1300
|
+
unstable_queryParamsMapper = Qt;
|
|
1301
1301
|
unstable_getAdapterDefaults;
|
|
1302
1302
|
unstable_getRequestDefaults;
|
|
1303
1303
|
unstable_devtoolsEndpointGetter = (e) => e;
|
|
@@ -1321,14 +1321,14 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1321
1321
|
async fetch(e, t) {
|
|
1322
1322
|
let n, r = async (r) => {
|
|
1323
1323
|
try {
|
|
1324
|
-
if (!this.initialized) throw new
|
|
1325
|
-
if (!this.unstable_fetcher) throw new
|
|
1324
|
+
if (!this.initialized) throw new kt(`Adapter ${this.options.name} is not initialized`);
|
|
1325
|
+
if (!this.unstable_fetcher) throw new kt(`Fetcher for ${this.options.name} adapter is not set`);
|
|
1326
1326
|
this.client.triggerPlugins("onAdapterFetch", {
|
|
1327
1327
|
adapter: this,
|
|
1328
1328
|
request: e,
|
|
1329
1329
|
requestId: t
|
|
1330
1330
|
});
|
|
1331
|
-
let i = await
|
|
1331
|
+
let i = await Yt({
|
|
1332
1332
|
request: e,
|
|
1333
1333
|
requestId: t,
|
|
1334
1334
|
resolve: r,
|
|
@@ -1337,9 +1337,9 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1337
1337
|
n = e;
|
|
1338
1338
|
}
|
|
1339
1339
|
});
|
|
1340
|
-
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await
|
|
1340
|
+
return e.unstable_mock && e.isMockerEnabled && e.client.isMockerEnabled ? await Zt(i) : this.unstable_fetcher(i);
|
|
1341
1341
|
} catch (i) {
|
|
1342
|
-
return
|
|
1342
|
+
return Xt({
|
|
1343
1343
|
request: e,
|
|
1344
1344
|
requestId: t,
|
|
1345
1345
|
startTime: n || Date.now(),
|
|
@@ -1356,66 +1356,66 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1356
1356
|
r(e);
|
|
1357
1357
|
});
|
|
1358
1358
|
}
|
|
1359
|
-
},
|
|
1359
|
+
}, en = (e) => {
|
|
1360
1360
|
try {
|
|
1361
1361
|
return JSON.parse(e);
|
|
1362
1362
|
} catch {
|
|
1363
1363
|
return e;
|
|
1364
1364
|
}
|
|
1365
|
-
},
|
|
1365
|
+
}, tn = (e) => e ? en(e) : jt(), nn = (e) => (t) => {
|
|
1366
1366
|
let { skipNull: n, skipEmptyString: r } = e;
|
|
1367
1367
|
return !(r && t === void 0 || r && t === "" || n && t === null);
|
|
1368
|
-
},
|
|
1369
|
-
let r = !
|
|
1370
|
-
return !e || r ? "" : `${
|
|
1371
|
-
},
|
|
1368
|
+
}, W = (e, { encode: t, strict: n }) => t && n ? encodeURIComponent(e).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`) : t ? encodeURIComponent(e) : e, rn = (e, t, n) => {
|
|
1369
|
+
let r = !nn(n)(t);
|
|
1370
|
+
return !e || r ? "" : `${W(e, n)}=${W(t instanceof Date ? n.dateParser?.(t) || t.toISOString() : typeof t == "object" && !Array.isArray(t) ? n.objectParser?.(t) || JSON.stringify(t) : String(t), n)}`;
|
|
1371
|
+
}, an = (e, t, n) => {
|
|
1372
1372
|
let { arrayFormat: r, arraySeparator: i } = n;
|
|
1373
|
-
return t.filter(
|
|
1373
|
+
return t.filter(nn(n)).reduce((t, a, o) => {
|
|
1374
1374
|
switch (r) {
|
|
1375
1375
|
case "index": {
|
|
1376
|
-
let r = `${
|
|
1377
|
-
t.push(`${r}${
|
|
1376
|
+
let r = `${W(e, n)}[${W(String(o), n)}]=`;
|
|
1377
|
+
t.push(`${r}${W(String(a), n)}`);
|
|
1378
1378
|
break;
|
|
1379
1379
|
}
|
|
1380
1380
|
case "bracket": {
|
|
1381
|
-
let r = `${
|
|
1382
|
-
t.push(`${r}${
|
|
1381
|
+
let r = `${W(e, n)}[]=`;
|
|
1382
|
+
t.push(`${r}${W(String(a), n)}`);
|
|
1383
1383
|
break;
|
|
1384
1384
|
}
|
|
1385
1385
|
case "comma": {
|
|
1386
|
-
let r = !t.length && `${
|
|
1387
|
-
return [[...t, `${r}${
|
|
1386
|
+
let r = !t.length && `${W(e, n)}=` || "";
|
|
1387
|
+
return [[...t, `${r}${W(String(a), n)}`].join(",")];
|
|
1388
1388
|
}
|
|
1389
1389
|
case "separator": {
|
|
1390
|
-
let r = !t.length && `${
|
|
1391
|
-
return [[...t, `${r}${
|
|
1390
|
+
let r = !t.length && `${W(e, n)}=` || "";
|
|
1391
|
+
return [[...t, `${r}${W(String(a), n)}`].join(i || "|")];
|
|
1392
1392
|
}
|
|
1393
1393
|
case "bracket-separator": {
|
|
1394
|
-
let r = !t.length && `${
|
|
1395
|
-
return [[...t, `${r}${
|
|
1394
|
+
let r = !t.length && `${W(e, n)}[]=` || "";
|
|
1395
|
+
return [[...t, `${r}${W(String(a), n)}`].join(i || "|")];
|
|
1396
1396
|
}
|
|
1397
1397
|
default: {
|
|
1398
|
-
let r = `${
|
|
1399
|
-
t.push(`${r}${
|
|
1398
|
+
let r = `${W(e, n)}=`;
|
|
1399
|
+
t.push(`${r}${W(String(a), n)}`);
|
|
1400
1400
|
}
|
|
1401
1401
|
}
|
|
1402
1402
|
return t;
|
|
1403
1403
|
}, []).join("&");
|
|
1404
|
-
},
|
|
1404
|
+
}, on = (e, t = Fn) => {
|
|
1405
1405
|
if (!e || !Object.keys(e).length) return "";
|
|
1406
1406
|
if (typeof e == "string") return e[0] === "?" ? e : `?${e}`;
|
|
1407
|
-
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ?
|
|
1407
|
+
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ? an(e, n, t) : rn(e, n, t)).filter(Boolean).join("&");
|
|
1408
1408
|
return n ? `?${n}` : "";
|
|
1409
|
-
},
|
|
1409
|
+
}, sn = qt.SEC * 5, cn = { headers: {} }, ln = () => new $t({
|
|
1410
1410
|
name: "http",
|
|
1411
|
-
defaultMethod:
|
|
1412
|
-
defaultExtra:
|
|
1411
|
+
defaultMethod: Lt.GET,
|
|
1412
|
+
defaultExtra: cn,
|
|
1413
1413
|
systemErrorStatus: 0,
|
|
1414
|
-
systemErrorExtra:
|
|
1415
|
-
}).setQueryParamsMapper(
|
|
1416
|
-
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ?
|
|
1414
|
+
systemErrorExtra: cn
|
|
1415
|
+
}).setQueryParamsMapper(on).setFetcher(async ({ request: e, adapterOptions: t, headers: n, payload: r, onError: i, onResponseEnd: a, onTimeoutError: o, onRequestEnd: s, createAbortListener: c, getAbortController: l, onResponseProgress: u, onResponseStart: d, onBeforeRequest: f, onRequestStart: p, onRequestProgress: m, onSuccess: h }) => {
|
|
1416
|
+
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ? on(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = sn, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
|
|
1417
1417
|
status: 0,
|
|
1418
|
-
extra:
|
|
1418
|
+
extra: cn
|
|
1419
1419
|
});
|
|
1420
1420
|
C > 0 && S && (D = setTimeout(() => {
|
|
1421
1421
|
E = !0, O(), S.abort();
|
|
@@ -1447,7 +1447,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1447
1447
|
status: l,
|
|
1448
1448
|
extra: c
|
|
1449
1449
|
}) : i({
|
|
1450
|
-
error:
|
|
1450
|
+
error: tn(await t.text()),
|
|
1451
1451
|
status: l,
|
|
1452
1452
|
extra: c
|
|
1453
1453
|
});
|
|
@@ -1468,11 +1468,11 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1468
1468
|
e = new TextDecoder().decode(o);
|
|
1469
1469
|
} else e = await t.text();
|
|
1470
1470
|
a(), O(), t.ok ? h({
|
|
1471
|
-
data:
|
|
1471
|
+
data: en(e),
|
|
1472
1472
|
status: l,
|
|
1473
1473
|
extra: c
|
|
1474
1474
|
}) : i({
|
|
1475
|
-
error:
|
|
1475
|
+
error: tn(e),
|
|
1476
1476
|
status: l,
|
|
1477
1477
|
extra: c
|
|
1478
1478
|
});
|
|
@@ -1481,18 +1481,18 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1481
1481
|
if (D && clearTimeout(D), O(), S?.signal?.aborted) {
|
|
1482
1482
|
E && o({
|
|
1483
1483
|
status: 0,
|
|
1484
|
-
extra:
|
|
1484
|
+
extra: cn
|
|
1485
1485
|
});
|
|
1486
1486
|
return;
|
|
1487
1487
|
}
|
|
1488
1488
|
i({
|
|
1489
1489
|
error: e,
|
|
1490
1490
|
status: 0,
|
|
1491
|
-
extra:
|
|
1491
|
+
extra: cn
|
|
1492
1492
|
});
|
|
1493
1493
|
}
|
|
1494
|
-
}),
|
|
1495
|
-
emitter = new
|
|
1494
|
+
}), un = () => ln(), dn = class {
|
|
1495
|
+
emitter = new Ne();
|
|
1496
1496
|
events;
|
|
1497
1497
|
storage;
|
|
1498
1498
|
lazyStorage;
|
|
@@ -1503,7 +1503,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1503
1503
|
constructor(e) {
|
|
1504
1504
|
this.options = e;
|
|
1505
1505
|
let { storage: t = /* @__PURE__ */ new Map(), lazyStorage: n, version: r = "0.0.1" } = e ?? {};
|
|
1506
|
-
this.emitter?.setMaxListeners(1e3), this.events =
|
|
1506
|
+
this.emitter?.setMaxListeners(1e3), this.events = yn(this.emitter), this.storage = t, this.version = r, this.lazyStorage = n;
|
|
1507
1507
|
}
|
|
1508
1508
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Cache"), e.appManager.events.onOnline(() => {
|
|
1509
1509
|
[...this.storage.keys()].forEach(this.scheduleGarbageCollector);
|
|
@@ -1517,7 +1517,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1517
1517
|
response: t
|
|
1518
1518
|
}
|
|
1519
1519
|
});
|
|
1520
|
-
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s =
|
|
1520
|
+
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = U(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u = fn(c, l), d = {
|
|
1521
1521
|
...u,
|
|
1522
1522
|
scope: o,
|
|
1523
1523
|
staleTime: i,
|
|
@@ -1563,7 +1563,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1563
1563
|
partialResponse: t
|
|
1564
1564
|
}
|
|
1565
1565
|
});
|
|
1566
|
-
let { cacheKey: n, scope: r } = e, i =
|
|
1566
|
+
let { cacheKey: n, scope: r } = e, i = U(n, r), a = this.storage.get(i), o = typeof t == "function" ? t(a || null) : t;
|
|
1567
1567
|
a && this.set(e, {
|
|
1568
1568
|
...a,
|
|
1569
1569
|
...o
|
|
@@ -1601,7 +1601,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1601
1601
|
cacheKey: t
|
|
1602
1602
|
}), this.events.emitInvalidation(t);
|
|
1603
1603
|
};
|
|
1604
|
-
e instanceof
|
|
1604
|
+
e instanceof Jt ? n(U(e.cacheKey, e.scope), e.cacheKey) : typeof e == "string" ? n(e) : t.length && t.forEach((t) => {
|
|
1605
1605
|
e.test(t) && n(t);
|
|
1606
1606
|
});
|
|
1607
1607
|
};
|
|
@@ -1656,49 +1656,49 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1656
1656
|
clear = async () => {
|
|
1657
1657
|
this.garbageCollectors.forEach((e) => clearTimeout(e)), this.storage.clear();
|
|
1658
1658
|
};
|
|
1659
|
-
},
|
|
1659
|
+
}, fn = (e, t) => {
|
|
1660
1660
|
let { data: n, success: r } = t, i = !r && e ? e.data : null, a = n || i;
|
|
1661
1661
|
return {
|
|
1662
1662
|
...t,
|
|
1663
1663
|
data: a
|
|
1664
1664
|
};
|
|
1665
|
-
},
|
|
1665
|
+
}, pn = () => "invalidate", mn = (e) => `${e}_invalidate`, hn = () => "delete", gn = (e) => `${e}_delete`, _n = (e) => `${e}_cache`, vn = () => "cache", yn = (e) => ({
|
|
1666
1666
|
emitCacheData: (t, n = !1) => {
|
|
1667
|
-
e.emit(
|
|
1667
|
+
e.emit(vn(), t, n), e.emit(_n(t.cacheKey), t, n);
|
|
1668
1668
|
},
|
|
1669
1669
|
emitInvalidation: (t, n = !1) => {
|
|
1670
|
-
e.emit(
|
|
1670
|
+
e.emit(pn(), t, n), e.emit(mn(t), n);
|
|
1671
1671
|
},
|
|
1672
1672
|
emitDelete: (t, n = !1) => {
|
|
1673
|
-
e.emit(
|
|
1673
|
+
e.emit(hn(), t, n), e.emit(gn(t), n);
|
|
1674
1674
|
},
|
|
1675
|
-
onData: (t) => (e.on(
|
|
1676
|
-
onDataByKey: (t, n) => (e.on(
|
|
1677
|
-
onInvalidate: (t) => (e.on(
|
|
1678
|
-
onInvalidateByKey: (t, n) => (e.on(
|
|
1679
|
-
onDelete: (t) => (e.on(
|
|
1680
|
-
onDeleteByKey: (t, n) => (e.on(
|
|
1681
|
-
}),
|
|
1675
|
+
onData: (t) => (e.on(vn(), t), () => e.removeListener(vn(), t)),
|
|
1676
|
+
onDataByKey: (t, n) => (e.on(_n(t), n), () => e.removeListener(_n(t), n)),
|
|
1677
|
+
onInvalidate: (t) => (e.on(pn(), t), () => e.removeListener(pn(), t)),
|
|
1678
|
+
onInvalidateByKey: (t, n) => (e.on(mn(t), n), () => e.removeListener(mn(t), n)),
|
|
1679
|
+
onDelete: (t) => (e.on(hn(), t), () => e.removeListener(hn(), t)),
|
|
1680
|
+
onDeleteByKey: (t, n) => (e.on(gn(t), n), () => e.removeListener(gn(t), n))
|
|
1681
|
+
}), G = /* @__PURE__ */ function(e) {
|
|
1682
1682
|
return e.ONE_BY_ONE = "one-by-one", e.ALL_AT_ONCE = "all-at-once", e.PREVIOUS_CANCELED = "previous-canceled", e.DEDUPLICATED = "deduplicated", e;
|
|
1683
|
-
}({}),
|
|
1683
|
+
}({}), bn = (e) => ({
|
|
1684
1684
|
emitDrained: (t, n) => {
|
|
1685
|
-
e.emit(
|
|
1685
|
+
e.emit(Sn(), t, n), e.emit(Cn(t.queryKey), t, n);
|
|
1686
1686
|
},
|
|
1687
1687
|
emitQueueStatusChanged: (t, n) => {
|
|
1688
|
-
e.emit(
|
|
1688
|
+
e.emit(wn(), t, n), e.emit(Tn(t.queryKey), t, n);
|
|
1689
1689
|
},
|
|
1690
1690
|
emitQueueChanged: (t, n) => {
|
|
1691
|
-
e.emit(
|
|
1691
|
+
e.emit(En(), t, n), e.emit(Dn(t.queryKey), t, n);
|
|
1692
1692
|
},
|
|
1693
|
-
onDrained: (t) => (e.on(
|
|
1694
|
-
onDrainedByKey: (t, n) => (e.on(
|
|
1695
|
-
onQueueStatusChange: (t) => (e.on(
|
|
1696
|
-
onQueueStatusChangeByKey: (t, n) => (e.on(
|
|
1697
|
-
onQueueChange: (t) => (e.on(
|
|
1698
|
-
onQueueChangeByKey: (t, n) => (e.on(
|
|
1699
|
-
}),
|
|
1700
|
-
emitter = new
|
|
1701
|
-
events =
|
|
1693
|
+
onDrained: (t) => (e.on(Sn(), t), () => e.removeListener(Sn(), t)),
|
|
1694
|
+
onDrainedByKey: (t, n) => (e.on(Cn(t), n), () => e.removeListener(Cn(t), n)),
|
|
1695
|
+
onQueueStatusChange: (t) => (e.on(wn(), t), () => e.removeListener(wn(), t)),
|
|
1696
|
+
onQueueStatusChangeByKey: (t, n) => (e.on(Tn(t), n), () => e.removeListener(Tn(t), n)),
|
|
1697
|
+
onQueueChange: (t) => (e.on(En(), t), () => e.removeListener(En(), t)),
|
|
1698
|
+
onQueueChangeByKey: (t, n) => (e.on(Dn(t), n), () => e.removeListener(Dn(t), n))
|
|
1699
|
+
}), xn = class {
|
|
1700
|
+
emitter = new Ne();
|
|
1701
|
+
events = bn(this.emitter);
|
|
1702
1702
|
storage = /* @__PURE__ */ new Map();
|
|
1703
1703
|
requestCount = /* @__PURE__ */ new Map();
|
|
1704
1704
|
runningRequests = /* @__PURE__ */ new Map();
|
|
@@ -1707,7 +1707,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1707
1707
|
constructor(e) {
|
|
1708
1708
|
this.options = e, this.emitter?.setMaxListeners(1e3), this.options?.storage && (this.storage = this.options.storage);
|
|
1709
1709
|
}
|
|
1710
|
-
isRequestJSON = (e) => !(e instanceof
|
|
1710
|
+
isRequestJSON = (e) => !(e instanceof Jt);
|
|
1711
1711
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Dispatcher"), this.client.appManager.events.onOnline(() => {
|
|
1712
1712
|
this.flush();
|
|
1713
1713
|
}), this);
|
|
@@ -1831,14 +1831,14 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1831
1831
|
hasRunningRequest = (e, t) => !!this.getRunningRequests(e).find((e) => e.requestId === t);
|
|
1832
1832
|
cancelRunningRequests = (e) => {
|
|
1833
1833
|
this.runningRequests.get(e)?.forEach((e) => {
|
|
1834
|
-
let t =
|
|
1834
|
+
let t = U(e.request.abortKey, e.request.scope);
|
|
1835
1835
|
this.client.requestManager.abortByRequestId(t, e.requestId);
|
|
1836
1836
|
}), this.deleteRunningRequests(e);
|
|
1837
1837
|
};
|
|
1838
1838
|
cancelRunningRequest = (e, t) => {
|
|
1839
1839
|
let n = this.getRunningRequests(e).filter((e) => {
|
|
1840
1840
|
if (e.requestId === t) {
|
|
1841
|
-
let t =
|
|
1841
|
+
let t = U(e.request.abortKey, e.request.scope);
|
|
1842
1842
|
return this.client.requestManager.abortByRequestId(t, e.requestId), !1;
|
|
1843
1843
|
}
|
|
1844
1844
|
return !0;
|
|
@@ -1866,7 +1866,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1866
1866
|
resolved: !1
|
|
1867
1867
|
});
|
|
1868
1868
|
add = (e) => {
|
|
1869
|
-
let t =
|
|
1869
|
+
let t = U(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = An(e, i);
|
|
1870
1870
|
switch (this.logger.debug({
|
|
1871
1871
|
title: "Adding request to queue",
|
|
1872
1872
|
type: "system",
|
|
@@ -1876,9 +1876,9 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1876
1876
|
requestId: r
|
|
1877
1877
|
}
|
|
1878
1878
|
}), a) {
|
|
1879
|
-
case
|
|
1880
|
-
case
|
|
1881
|
-
case
|
|
1879
|
+
case G.ONE_BY_ONE: return this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1880
|
+
case G.PREVIOUS_CANCELED: return this.cancelRunningRequests(t), this.clearQueue(t), this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1881
|
+
case G.DEDUPLICATED: return this.client.requestManager.events.emitDeduplicated({
|
|
1882
1882
|
request: i.request,
|
|
1883
1883
|
requestId: r,
|
|
1884
1884
|
deduplicatedRequest: e
|
|
@@ -1920,7 +1920,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1920
1920
|
requestId: n
|
|
1921
1921
|
}
|
|
1922
1922
|
});
|
|
1923
|
-
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l =
|
|
1923
|
+
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = U(a, c), u = U(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h = On(e.retries, r), g = !m.isOnline && s, _ = this.hasRunningRequest(l, n), v = e.stopped;
|
|
1924
1924
|
if (g || _ || v) return this.logger.warning({
|
|
1925
1925
|
title: "Unable to perform request",
|
|
1926
1926
|
type: "system",
|
|
@@ -1940,7 +1940,7 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1940
1940
|
}), this.incrementQueueRequestCount(l), f.addAbortController(u, n);
|
|
1941
1941
|
let b = await d.fetch(t, n);
|
|
1942
1942
|
e.resolved = !0, f.removeAbortController(u, n);
|
|
1943
|
-
let x = !m.isOnline, S =
|
|
1943
|
+
let x = !m.isOnline, S = jt("abort").message === b.error?.message, C = !this.hasRunningRequest(l, n) || S;
|
|
1944
1944
|
this.deleteRunningRequest(l, n);
|
|
1945
1945
|
let w = b.success || !h || !t.retryOnError || t.retryOnError(b), T = !b.success && h && w && !C && !x, E = {
|
|
1946
1946
|
isCanceled: C,
|
|
@@ -2054,26 +2054,26 @@ var Qt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
2054
2054
|
}
|
|
2055
2055
|
}), this.delete(l, n, u));
|
|
2056
2056
|
};
|
|
2057
|
-
},
|
|
2058
|
-
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ?
|
|
2059
|
-
return n ?
|
|
2057
|
+
}, Sn = () => "drained-event", Cn = (e) => `${e}-drained-event`, wn = () => "status-event", Tn = (e) => `${e}-status-event`, En = () => "change-event", Dn = (e) => `${e}-change-event`, On = (e, t) => !!(t && e < t), kn = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, An = (e, t) => {
|
|
2058
|
+
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? kn(e, t) : !1;
|
|
2059
|
+
return n ? G.ONE_BY_ONE : r ? G.PREVIOUS_CANCELED : a && i ? G.DEDUPLICATED : G.ALL_AT_ONCE;
|
|
2060
2060
|
};
|
|
2061
|
-
function
|
|
2061
|
+
function jn(e) {
|
|
2062
2062
|
return e === "client" || e === "server" ? e : typeof window < "u" && typeof document < "u" ? "client" : "server";
|
|
2063
2063
|
}
|
|
2064
|
-
var
|
|
2064
|
+
var Mn = async (e, t) => {
|
|
2065
2065
|
let n = t;
|
|
2066
2066
|
if (!t.requestOptions.disableRequestInterceptors) {
|
|
2067
2067
|
for (let r of e) if (n = await r(t), !n) throw Error("Request modifier must return request");
|
|
2068
2068
|
}
|
|
2069
2069
|
return n;
|
|
2070
|
-
},
|
|
2070
|
+
}, Nn = async (e, t, n) => {
|
|
2071
2071
|
let r = t;
|
|
2072
2072
|
if (!n.requestOptions.disableResponseInterceptors) {
|
|
2073
2073
|
for (let i of e) if (r = await i(t, n), !r) throw Error("Response modifier must return data");
|
|
2074
2074
|
}
|
|
2075
2075
|
return r;
|
|
2076
|
-
},
|
|
2076
|
+
}, Pn = class {
|
|
2077
2077
|
url;
|
|
2078
2078
|
mode;
|
|
2079
2079
|
debug;
|
|
@@ -2082,8 +2082,8 @@ var Nn = async (e, t) => {
|
|
|
2082
2082
|
unstable_onResponseCallbacks = [];
|
|
2083
2083
|
unstable_onAuthCallbacks = [];
|
|
2084
2084
|
unstable_onRequestCallbacks = [];
|
|
2085
|
-
loggerManager = new
|
|
2086
|
-
requestManager = new
|
|
2085
|
+
loggerManager = new vt();
|
|
2086
|
+
requestManager = new Ve();
|
|
2087
2087
|
appManager;
|
|
2088
2088
|
adapter;
|
|
2089
2089
|
cache;
|
|
@@ -2091,15 +2091,15 @@ var Nn = async (e, t) => {
|
|
|
2091
2091
|
submitDispatcher;
|
|
2092
2092
|
isMockerEnabled = !0;
|
|
2093
2093
|
plugins = [];
|
|
2094
|
-
unstable_abortKeyMapper =
|
|
2095
|
-
unstable_cacheKeyMapper =
|
|
2096
|
-
unstable_queryKeyMapper =
|
|
2097
|
-
unstable_requestIdMapper =
|
|
2094
|
+
unstable_abortKeyMapper = Ht;
|
|
2095
|
+
unstable_cacheKeyMapper = Ut;
|
|
2096
|
+
unstable_queryKeyMapper = Ut;
|
|
2097
|
+
unstable_requestIdMapper = Ae;
|
|
2098
2098
|
logger = this.loggerManager.initialize(this, "Client");
|
|
2099
2099
|
constructor(e) {
|
|
2100
2100
|
this.options = e;
|
|
2101
2101
|
let { url: t, appManager: n, cache: r, fetchDispatcher: i, submitDispatcher: a, mode: o } = this.options;
|
|
2102
|
-
this.url = t, this.mode =
|
|
2102
|
+
this.url = t, this.mode = jn(o), this.adapter = un(), this.appManager = n?.() || new Pe(), this.cache = r?.() || new dn(), this.fetchDispatcher = i?.() || new xn(), this.submitDispatcher = a?.() || new xn(), this.adapter.initialize(this), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2103
2103
|
}
|
|
2104
2104
|
setDebug = (e) => (this.debug = e, this);
|
|
2105
2105
|
setLogLevel = (e) => (this.loggerManager.setSeverity(e), this);
|
|
@@ -2128,15 +2128,15 @@ var Nn = async (e, t) => {
|
|
|
2128
2128
|
setCacheKeyMapper = (e) => (this.unstable_cacheKeyMapper = e, this);
|
|
2129
2129
|
setQueryKeyMapper = (e) => (this.unstable_queryKeyMapper = e, this);
|
|
2130
2130
|
setRequestIdMapper = (e) => (this.unstable_requestIdMapper = e, this);
|
|
2131
|
-
unstable_modifyAuth = async (e) =>
|
|
2132
|
-
unstable_modifyRequest = async (e) =>
|
|
2133
|
-
unstable_modifyErrorResponse = async (e, t) =>
|
|
2134
|
-
unstable_modifySuccessResponse = async (e, t) =>
|
|
2135
|
-
unstable_modifyResponse = async (e, t) =>
|
|
2136
|
-
fromJSON = (e) =>
|
|
2131
|
+
unstable_modifyAuth = async (e) => Mn(this.unstable_onAuthCallbacks, e);
|
|
2132
|
+
unstable_modifyRequest = async (e) => Mn(this.unstable_onRequestCallbacks, e);
|
|
2133
|
+
unstable_modifyErrorResponse = async (e, t) => Nn(this.unstable_onErrorCallbacks, e, t);
|
|
2134
|
+
unstable_modifySuccessResponse = async (e, t) => Nn(this.unstable_onSuccessCallbacks, e, t);
|
|
2135
|
+
unstable_modifyResponse = async (e, t) => Nn(this.unstable_onResponseCallbacks, e, t);
|
|
2136
|
+
fromJSON = (e) => Jt.fromJSON(this, e);
|
|
2137
2137
|
clear = () => {
|
|
2138
2138
|
let { appManager: e, cache: t, fetchDispatcher: n, submitDispatcher: r } = this.options;
|
|
2139
|
-
this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new
|
|
2139
|
+
this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new dn(), this.appManager = e?.() || new Pe(), this.fetchDispatcher = n?.() || new xn(), this.submitDispatcher = r?.() || new xn(), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2140
2140
|
};
|
|
2141
2141
|
hydrate = (e, t) => {
|
|
2142
2142
|
e?.forEach((e) => {
|
|
@@ -2153,8 +2153,8 @@ var Nn = async (e, t) => {
|
|
|
2153
2153
|
...a,
|
|
2154
2154
|
...t
|
|
2155
2155
|
};
|
|
2156
|
-
if (!s.override && this.cache.get(
|
|
2157
|
-
let c =
|
|
2156
|
+
if (!s.override && this.cache.get(U(n, r))) return;
|
|
2157
|
+
let c = en(i);
|
|
2158
2158
|
this.cache.set({
|
|
2159
2159
|
...s,
|
|
2160
2160
|
cacheKey: n,
|
|
@@ -2166,10 +2166,10 @@ var Nn = async (e, t) => {
|
|
|
2166
2166
|
let t = this.adapter.unstable_endpointMapper(e.endpoint), n = {
|
|
2167
2167
|
...e,
|
|
2168
2168
|
endpoint: String(t)
|
|
2169
|
-
}, r = new
|
|
2169
|
+
}, r = new Jt(this, n);
|
|
2170
2170
|
return this.plugins.forEach((e) => e.trigger("onRequestCreate", { request: r })), r;
|
|
2171
2171
|
};
|
|
2172
|
-
},
|
|
2172
|
+
}, Fn = {
|
|
2173
2173
|
strict: !0,
|
|
2174
2174
|
encode: !0,
|
|
2175
2175
|
arrayFormat: "bracket",
|
|
@@ -2178,101 +2178,101 @@ var Nn = async (e, t) => {
|
|
|
2178
2178
|
skipNull: !0,
|
|
2179
2179
|
skipEmptyString: !0
|
|
2180
2180
|
};
|
|
2181
|
-
function
|
|
2182
|
-
return new
|
|
2181
|
+
function In(e) {
|
|
2182
|
+
return new Pn(e);
|
|
2183
2183
|
}
|
|
2184
2184
|
//#endregion
|
|
2185
2185
|
//#region src/core/client.ts
|
|
2186
|
-
var
|
|
2186
|
+
var K = In({ url: L() });
|
|
2187
2187
|
//#endregion
|
|
2188
2188
|
//#region src/core/auth-api.ts
|
|
2189
|
-
async function
|
|
2190
|
-
let { data: t, success: n } = await
|
|
2189
|
+
async function Ln(e) {
|
|
2190
|
+
let { data: t, success: n } = await K.createRequest()({
|
|
2191
2191
|
endpoint: "/auth/cli/whoami",
|
|
2192
2192
|
method: "GET"
|
|
2193
2193
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2194
2194
|
return !n || !t ? null : t;
|
|
2195
2195
|
}
|
|
2196
|
-
async function
|
|
2197
|
-
await
|
|
2196
|
+
async function Rn(e) {
|
|
2197
|
+
await K.createRequest()({
|
|
2198
2198
|
endpoint: "/auth/cli/token",
|
|
2199
2199
|
method: "DELETE"
|
|
2200
2200
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2201
2201
|
}
|
|
2202
2202
|
//#endregion
|
|
2203
2203
|
//#region src/core/auth-store.ts
|
|
2204
|
-
var
|
|
2205
|
-
function
|
|
2204
|
+
var zn = 1, Bn = "hype-stack", Vn = "auth.json";
|
|
2205
|
+
function Hn() {
|
|
2206
2206
|
let e = process.env.HYPE_STACK_CONFIG_DIR;
|
|
2207
|
-
if (e) return T.join(e,
|
|
2207
|
+
if (e) return T.join(e, Bn);
|
|
2208
2208
|
let t = w.homedir();
|
|
2209
2209
|
if (process.platform === "win32") {
|
|
2210
2210
|
let e = process.env.APPDATA ?? T.join(t, "AppData", "Roaming");
|
|
2211
|
-
return T.join(e,
|
|
2211
|
+
return T.join(e, Bn);
|
|
2212
2212
|
}
|
|
2213
|
-
if (process.platform === "darwin") return T.join(t, "Library", "Application Support",
|
|
2213
|
+
if (process.platform === "darwin") return T.join(t, "Library", "Application Support", Bn);
|
|
2214
2214
|
let n = process.env.XDG_CONFIG_HOME ?? T.join(t, ".config");
|
|
2215
|
-
return T.join(n,
|
|
2215
|
+
return T.join(n, Bn);
|
|
2216
2216
|
}
|
|
2217
|
-
function
|
|
2218
|
-
return T.join(
|
|
2217
|
+
function Un() {
|
|
2218
|
+
return T.join(Hn(), Vn);
|
|
2219
2219
|
}
|
|
2220
|
-
async function
|
|
2221
|
-
let e = await y.readFile(
|
|
2220
|
+
async function Wn() {
|
|
2221
|
+
let e = await y.readFile(Un(), "utf-8").catch(() => null);
|
|
2222
2222
|
if (!e) return {
|
|
2223
|
-
version:
|
|
2223
|
+
version: zn,
|
|
2224
2224
|
tokens: {}
|
|
2225
2225
|
};
|
|
2226
2226
|
let t = JSON.parse(e);
|
|
2227
2227
|
return {
|
|
2228
|
-
version: t.version ??
|
|
2228
|
+
version: t.version ?? zn,
|
|
2229
2229
|
tokens: t.tokens ?? {}
|
|
2230
2230
|
};
|
|
2231
2231
|
}
|
|
2232
|
-
async function
|
|
2233
|
-
let t =
|
|
2234
|
-
await y.mkdir(t, { recursive: !0 }), await y.writeFile(
|
|
2232
|
+
async function Gn(e) {
|
|
2233
|
+
let t = Hn();
|
|
2234
|
+
await y.mkdir(t, { recursive: !0 }), await y.writeFile(Un(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2235
2235
|
}
|
|
2236
|
-
async function
|
|
2237
|
-
return (await
|
|
2236
|
+
async function Kn(e) {
|
|
2237
|
+
return (await Wn()).tokens[e] ?? null;
|
|
2238
2238
|
}
|
|
2239
|
-
async function
|
|
2240
|
-
let n = await
|
|
2241
|
-
n.tokens[e] = t, await
|
|
2239
|
+
async function qn(e, t) {
|
|
2240
|
+
let n = await Wn();
|
|
2241
|
+
n.tokens[e] = t, await Gn(n);
|
|
2242
2242
|
}
|
|
2243
|
-
async function
|
|
2244
|
-
let t = await
|
|
2245
|
-
e in t.tokens && (delete t.tokens[e], await
|
|
2243
|
+
async function Jn(e) {
|
|
2244
|
+
let t = await Wn();
|
|
2245
|
+
e in t.tokens && (delete t.tokens[e], await Gn(t));
|
|
2246
2246
|
}
|
|
2247
2247
|
//#endregion
|
|
2248
2248
|
//#region src/core/device.ts
|
|
2249
|
-
function
|
|
2249
|
+
function Yn() {
|
|
2250
2250
|
let e = w.networkInterfaces();
|
|
2251
2251
|
for (let t of Object.values(e)) if (t) {
|
|
2252
2252
|
for (let e of t) if (!e.internal && e.mac !== "00:00:00:00:00:00") return e.mac;
|
|
2253
2253
|
}
|
|
2254
2254
|
return "unknown";
|
|
2255
2255
|
}
|
|
2256
|
-
function
|
|
2257
|
-
let e = `${
|
|
2256
|
+
function Xn() {
|
|
2257
|
+
let e = `${Yn()}:${w.hostname()}:${w.platform()}:${w.arch()}`;
|
|
2258
2258
|
return x("sha256").update(e).digest("hex").slice(0, 16);
|
|
2259
2259
|
}
|
|
2260
|
-
function
|
|
2260
|
+
function Zn() {
|
|
2261
2261
|
return `hype-stack/${A} ${w.platform()} ${w.arch()} node/${process.version.slice(1)}`;
|
|
2262
2262
|
}
|
|
2263
2263
|
//#endregion
|
|
2264
2264
|
//#region src/core/open-browser.ts
|
|
2265
|
-
function
|
|
2265
|
+
function Qn(e) {
|
|
2266
2266
|
E(process.platform === "darwin" ? `open "${e}"` : process.platform === "win32" ? `start "" "${e}"` : `xdg-open "${e}"`);
|
|
2267
2267
|
}
|
|
2268
2268
|
//#endregion
|
|
2269
2269
|
//#region src/core/login.ts
|
|
2270
|
-
var
|
|
2271
|
-
async function
|
|
2270
|
+
var $n = 300 * 1e3, er = (e) => `<!doctype html><html><head><meta charset="utf-8"><title>Hype Stack CLI</title></head><body style="font-family:system-ui,sans-serif;text-align:center;padding-top:4rem;color:#111"><h2>${e}</h2><p>You can close this tab and return to your terminal.</p></body></html>`;
|
|
2271
|
+
async function tr(e = {}) {
|
|
2272
2272
|
let t = S(16).toString("hex"), n = L(), r = C.createServer(), i = await new Promise((n, i) => {
|
|
2273
2273
|
let a = setTimeout(() => {
|
|
2274
2274
|
o(), i(/* @__PURE__ */ Error("Login timed out. Run `npx @hype-stack/cli login` again."));
|
|
2275
|
-
},
|
|
2275
|
+
}, $n);
|
|
2276
2276
|
function o() {
|
|
2277
2277
|
clearTimeout(a), r.close(), r.closeAllConnections?.();
|
|
2278
2278
|
}
|
|
@@ -2286,7 +2286,7 @@ async function nr(e = {}) {
|
|
|
2286
2286
|
r.writeHead(200, {
|
|
2287
2287
|
"Content-Type": "text/html",
|
|
2288
2288
|
Connection: "close"
|
|
2289
|
-
}), r.end(
|
|
2289
|
+
}), r.end(er(e));
|
|
2290
2290
|
};
|
|
2291
2291
|
if (a.searchParams.get("state") !== t) {
|
|
2292
2292
|
s("Login failed."), o(), i(/* @__PURE__ */ Error("Login failed: state mismatch. Run `npx @hype-stack/cli login` again."));
|
|
@@ -2301,53 +2301,53 @@ async function nr(e = {}) {
|
|
|
2301
2301
|
}), r.on("error", (e) => {
|
|
2302
2302
|
o(), i(e);
|
|
2303
2303
|
}), r.listen(0, "127.0.0.1", () => {
|
|
2304
|
-
let { port: n } = r.address(), i = encodeURIComponent(
|
|
2305
|
-
e.onUrl?.(a),
|
|
2304
|
+
let { port: n } = r.address(), i = encodeURIComponent(Zn()), a = `${se()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
|
|
2305
|
+
e.onUrl?.(a), Qn(a);
|
|
2306
2306
|
});
|
|
2307
|
-
}), a = await
|
|
2307
|
+
}), a = await Ln(i).catch(() => null), o = {
|
|
2308
2308
|
token: i,
|
|
2309
2309
|
email: a?.email,
|
|
2310
2310
|
organizationId: a?.organizationId
|
|
2311
2311
|
};
|
|
2312
|
-
return await
|
|
2312
|
+
return await qn(n, o), o;
|
|
2313
2313
|
}
|
|
2314
2314
|
//#endregion
|
|
2315
2315
|
//#region src/core/access-prompts.ts
|
|
2316
|
-
async function
|
|
2316
|
+
async function nr() {
|
|
2317
2317
|
let e = await s.confirm({ message: "Log in to install packs your organization owns? (opens your browser)" });
|
|
2318
2318
|
if (s.isCancel(e) || !e) return null;
|
|
2319
2319
|
s.log.step("Opening your browser to sign in...");
|
|
2320
2320
|
try {
|
|
2321
|
-
let e = await
|
|
2322
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
2321
|
+
let e = await tr({ onUrl: (e) => {
|
|
2322
|
+
s.log.info(`If your browser didn't open, visit:\n ${B.path(e)}`);
|
|
2323
2323
|
} });
|
|
2324
2324
|
return s.log.success(e.email ? `Logged in as ${e.email}` : "Logged in"), e.token;
|
|
2325
2325
|
} catch (e) {
|
|
2326
2326
|
return s.log.error(e instanceof Error ? e.message : String(e)), null;
|
|
2327
2327
|
}
|
|
2328
2328
|
}
|
|
2329
|
-
async function
|
|
2329
|
+
async function rr(e) {
|
|
2330
2330
|
if (e.length === 0) return;
|
|
2331
2331
|
s.note([
|
|
2332
2332
|
"These packs need a purchase before they can be installed:",
|
|
2333
2333
|
"",
|
|
2334
|
-
...e.map((e) => ` ${
|
|
2334
|
+
...e.map((e) => ` ${B.brand(e.displayName)} ${B.highlight(`$${e.price}`)}`)
|
|
2335
2335
|
].join("\n"), "Locked Packs");
|
|
2336
2336
|
let t = await s.confirm({ message: `Open the purchase ${e.length === 1 ? "page" : "pages"} in your browser?` });
|
|
2337
2337
|
if (s.isCancel(t) || !t) {
|
|
2338
|
-
s.log.info(
|
|
2338
|
+
s.log.info(B.muted("Run 'npx @hype-stack/cli login' after purchasing, then 'npx @hype-stack/cli compose' again."));
|
|
2339
2339
|
return;
|
|
2340
2340
|
}
|
|
2341
|
-
for (let t of e)
|
|
2341
|
+
for (let t of e) Qn(be(t.name));
|
|
2342
2342
|
s.log.info([
|
|
2343
|
-
|
|
2344
|
-
` ${
|
|
2345
|
-
` ${
|
|
2343
|
+
B.muted("After purchasing, run:"),
|
|
2344
|
+
` ${B.highlight("npx @hype-stack/cli login")} ${B.muted("Save your access")}`,
|
|
2345
|
+
` ${B.highlight("npx @hype-stack/cli compose")} ${B.muted("Install the packs")}`
|
|
2346
2346
|
].join("\n"));
|
|
2347
2347
|
}
|
|
2348
2348
|
//#endregion
|
|
2349
2349
|
//#region src/utils/exec.ts
|
|
2350
|
-
function
|
|
2350
|
+
function q(e, t, n) {
|
|
2351
2351
|
return new Promise((r, i) => {
|
|
2352
2352
|
let a = D(e, t, {
|
|
2353
2353
|
cwd: n.cwd,
|
|
@@ -2378,7 +2378,7 @@ function K(e, t, n) {
|
|
|
2378
2378
|
});
|
|
2379
2379
|
});
|
|
2380
2380
|
}
|
|
2381
|
-
function
|
|
2381
|
+
function ir(e, t, n) {
|
|
2382
2382
|
return new Promise((r, i) => {
|
|
2383
2383
|
let a = D(e, t, {
|
|
2384
2384
|
cwd: n.cwd,
|
|
@@ -2395,7 +2395,7 @@ function ar(e, t, n) {
|
|
|
2395
2395
|
}
|
|
2396
2396
|
//#endregion
|
|
2397
2397
|
//#region src/utils/fs.ts
|
|
2398
|
-
async function
|
|
2398
|
+
async function ar(e) {
|
|
2399
2399
|
return (await y.stat(e).catch(() => null))?.isDirectory() ?? !1;
|
|
2400
2400
|
}
|
|
2401
2401
|
async function J(e) {
|
|
@@ -2413,7 +2413,7 @@ async function cr(e, t) {
|
|
|
2413
2413
|
}
|
|
2414
2414
|
async function lr(e) {
|
|
2415
2415
|
let t = {};
|
|
2416
|
-
if (!await
|
|
2416
|
+
if (!await ar(e)) return t;
|
|
2417
2417
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
2418
2418
|
for (let r of n) r.isDirectory() && await J(T.join(e, r.name, "package.json")) && (t[r.name] = T.relative(T.dirname(e), T.join(e, r.name)));
|
|
2419
2419
|
return t;
|
|
@@ -2430,28 +2430,41 @@ function dr(e, t) {
|
|
|
2430
2430
|
//#endregion
|
|
2431
2431
|
//#region src/core/codegen.ts
|
|
2432
2432
|
function fr(e) {
|
|
2433
|
-
s.log.info(
|
|
2434
|
-
`${
|
|
2435
|
-
`${
|
|
2436
|
-
`${
|
|
2433
|
+
s.log.info(B.muted("Run database setup yourself when ready:")), s.note([
|
|
2434
|
+
`${B.command(`cd ${e}`)}`,
|
|
2435
|
+
`${B.command("pnpm exec prisma generate")} ${B.muted("(regenerate the Prisma client)")}`,
|
|
2436
|
+
`${B.command("pnpm exec prisma migrate dev")} ${B.muted("(create + apply tables for new packs)")}`
|
|
2437
2437
|
].join("\n"), "Database Setup");
|
|
2438
2438
|
}
|
|
2439
2439
|
async function pr(e) {
|
|
2440
|
-
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, freshScaffold: a, runCommand: o =
|
|
2440
|
+
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, freshScaffold: a, runCommand: o = ir } = e, c = n.backend.root, l = T.join(t, c);
|
|
2441
2441
|
if (!await J(T.join(l, "package.json"))) return;
|
|
2442
|
+
if (!r) {
|
|
2443
|
+
s.log.step(B.muted(`Generating Prisma client (${B.command("prisma generate")})...`));
|
|
2444
|
+
let e = await o("pnpm", [
|
|
2445
|
+
"exec",
|
|
2446
|
+
"prisma",
|
|
2447
|
+
"generate"
|
|
2448
|
+
], { cwd: l });
|
|
2449
|
+
if (e.exitCode !== 0) {
|
|
2450
|
+
s.log.error(B.muted("prisma generate failed. See the output above, or finish setup manually:")), mr(e), fr(c);
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
s.log.success("Prisma client generated");
|
|
2454
|
+
}
|
|
2442
2455
|
if (r || i === !1) {
|
|
2443
2456
|
fr(c);
|
|
2444
2457
|
return;
|
|
2445
2458
|
}
|
|
2446
2459
|
let u = await s.confirm({
|
|
2447
|
-
message: `Run database setup now? (${
|
|
2460
|
+
message: `Run database setup now? (${B.command("prisma migrate dev")})`,
|
|
2448
2461
|
initialValue: !0
|
|
2449
2462
|
});
|
|
2450
2463
|
if (s.isCancel(u) || !u) {
|
|
2451
2464
|
fr(c);
|
|
2452
2465
|
return;
|
|
2453
2466
|
}
|
|
2454
|
-
s.log.step(
|
|
2467
|
+
s.log.step(B.muted(`Running ${B.command("prisma migrate dev --name add-packs")}...`));
|
|
2455
2468
|
let d = await o("pnpm", [
|
|
2456
2469
|
"exec",
|
|
2457
2470
|
"prisma",
|
|
@@ -2466,7 +2479,7 @@ async function pr(e) {
|
|
|
2466
2479
|
initialValue: !0
|
|
2467
2480
|
});
|
|
2468
2481
|
if (!s.isCancel(e) && e) {
|
|
2469
|
-
s.log.step(
|
|
2482
|
+
s.log.step(B.muted(`Resetting dev database (${B.command("prisma migrate reset --force")})...`));
|
|
2470
2483
|
let e = await o("pnpm", [
|
|
2471
2484
|
"exec",
|
|
2472
2485
|
"prisma",
|
|
@@ -2474,7 +2487,7 @@ async function pr(e) {
|
|
|
2474
2487
|
"reset",
|
|
2475
2488
|
"--force"
|
|
2476
2489
|
], { cwd: l });
|
|
2477
|
-
if (e.exitCode === 0) s.log.step(
|
|
2490
|
+
if (e.exitCode === 0) s.log.step(B.muted(`Running ${B.command("prisma migrate dev --name add-packs")}...`)), d = await o("pnpm", [
|
|
2478
2491
|
"exec",
|
|
2479
2492
|
"prisma",
|
|
2480
2493
|
"migrate",
|
|
@@ -2483,40 +2496,149 @@ async function pr(e) {
|
|
|
2483
2496
|
"add-packs"
|
|
2484
2497
|
], { cwd: l });
|
|
2485
2498
|
else {
|
|
2486
|
-
s.log.error(
|
|
2499
|
+
s.log.error(B.muted("prisma migrate reset did not complete. See the output above, or finish setup manually:")), mr(e), fr(c);
|
|
2487
2500
|
return;
|
|
2488
2501
|
}
|
|
2489
2502
|
}
|
|
2490
2503
|
}
|
|
2491
2504
|
if (d.exitCode !== 0) {
|
|
2492
|
-
s.log.error(
|
|
2505
|
+
s.log.error(B.muted("prisma migrate dev did not complete. See the output above, or finish setup manually:")), mr(d), fr(c);
|
|
2493
2506
|
return;
|
|
2494
2507
|
}
|
|
2495
2508
|
s.log.success("Database schema applied");
|
|
2496
2509
|
}
|
|
2497
2510
|
function mr(e) {
|
|
2498
2511
|
let t = (e.stderr || e.stdout).trim();
|
|
2499
|
-
t && s.log.warn(
|
|
2512
|
+
t && s.log.warn(B.muted(t));
|
|
2513
|
+
}
|
|
2514
|
+
//#endregion
|
|
2515
|
+
//#region src/core/onboard-catalog.ts
|
|
2516
|
+
var Y = {
|
|
2517
|
+
Config: "config",
|
|
2518
|
+
Databases: "databases",
|
|
2519
|
+
Workos: "workos",
|
|
2520
|
+
BetterAuth: "betterauth",
|
|
2521
|
+
Stripe: "stripe",
|
|
2522
|
+
Polar: "polar",
|
|
2523
|
+
Resend: "resend",
|
|
2524
|
+
IpLocate: "iplocate",
|
|
2525
|
+
Sentry: "sentry"
|
|
2526
|
+
}, hr = {
|
|
2527
|
+
[Y.Config]: "Config",
|
|
2528
|
+
[Y.Databases]: "Databases",
|
|
2529
|
+
[Y.Workos]: "WorkOS",
|
|
2530
|
+
[Y.BetterAuth]: "Better Auth",
|
|
2531
|
+
[Y.Stripe]: "Stripe",
|
|
2532
|
+
[Y.Polar]: "Polar",
|
|
2533
|
+
[Y.Resend]: "Resend",
|
|
2534
|
+
[Y.IpLocate]: "IP Locate",
|
|
2535
|
+
[Y.Sentry]: "Sentry"
|
|
2536
|
+
}, gr = new Set(Object.values(Y));
|
|
2537
|
+
function _r(e) {
|
|
2538
|
+
return e.toLowerCase().replace(/[^a-z0-9]+/g, "").trim();
|
|
2539
|
+
}
|
|
2540
|
+
function vr(e) {
|
|
2541
|
+
let t = _r(e);
|
|
2542
|
+
return gr.has(t) ? t : void 0;
|
|
2543
|
+
}
|
|
2544
|
+
var yr = {
|
|
2545
|
+
[Y.Config]: { hint: "App URLs. Defaults work for local dev." },
|
|
2546
|
+
[Y.Databases]: { hint: "Credentials for the local Docker Postgres and Valkey containers." },
|
|
2547
|
+
[Y.Workos]: {
|
|
2548
|
+
link: "https://dashboard.workos.com/api-keys",
|
|
2549
|
+
hint: "Copy your API Key and Client ID from the WorkOS dashboard."
|
|
2550
|
+
},
|
|
2551
|
+
[Y.BetterAuth]: {
|
|
2552
|
+
link: "https://www.better-auth.com/docs/installation#set-environment-variables",
|
|
2553
|
+
hint: "Generate a long random secret, set the app URL, add Google OAuth creds if you use Google."
|
|
2554
|
+
},
|
|
2555
|
+
[Y.Stripe]: {
|
|
2556
|
+
link: "https://dashboard.stripe.com/apikeys",
|
|
2557
|
+
hint: "Copy your secret and publishable keys from the Stripe dashboard.",
|
|
2558
|
+
serviceChecklist: [
|
|
2559
|
+
"Recurring prices for Pro and Premier power checkout (set STRIPE_PRICE_PRO and STRIPE_PRICE_PREMIER).",
|
|
2560
|
+
"A webhook at /checkout/webhook keeps subscriptions in sync (subscription events plus invoice.payment_succeeded).",
|
|
2561
|
+
"Enable the Stripe billing portal so Manage Billing and invoices work.",
|
|
2562
|
+
"Enable 'Limit customers to one subscription' to prevent double-checkout races.",
|
|
2563
|
+
"Optional: disable Cash App Pay if you see a high checkout cancel rate."
|
|
2564
|
+
]
|
|
2565
|
+
},
|
|
2566
|
+
[Y.Polar]: {
|
|
2567
|
+
link: "https://polar.sh",
|
|
2568
|
+
hint: "From your Polar org: access token, webhook secret, organization id, and the checkout product id."
|
|
2569
|
+
},
|
|
2570
|
+
[Y.Resend]: {
|
|
2571
|
+
link: "https://resend.com/api-keys",
|
|
2572
|
+
hint: "Create an API key in Resend."
|
|
2573
|
+
},
|
|
2574
|
+
[Y.IpLocate]: {
|
|
2575
|
+
link: "https://iplocate.io",
|
|
2576
|
+
hint: "Grab your API key from IP Locate."
|
|
2577
|
+
},
|
|
2578
|
+
[Y.Sentry]: {
|
|
2579
|
+
link: "https://sentry.io",
|
|
2580
|
+
hint: "Your project DSN. Leave blank to skip Sentry for now."
|
|
2581
|
+
}
|
|
2582
|
+
}, br = { hint: "Add your value, or press Enter to leave it blank." };
|
|
2583
|
+
function xr(e) {
|
|
2584
|
+
let t = vr(e);
|
|
2585
|
+
return t ? yr[t] : br;
|
|
2586
|
+
}
|
|
2587
|
+
var Sr = new Set([
|
|
2588
|
+
Y.Config,
|
|
2589
|
+
Y.Databases,
|
|
2590
|
+
Y.Sentry,
|
|
2591
|
+
Y.Resend
|
|
2592
|
+
]);
|
|
2593
|
+
function Cr(e, t) {
|
|
2594
|
+
let n = vr(e);
|
|
2595
|
+
return n && Sr.has(n) || t.length === 0 ? !0 : n ? t.includes(n) : !1;
|
|
2596
|
+
}
|
|
2597
|
+
function wr(e) {
|
|
2598
|
+
return e ? e.map((e) => {
|
|
2599
|
+
let t = vr(e.envExample.section);
|
|
2600
|
+
if (!t) throw Error(`Unknown onboarding env section "${e.envExample.section}". Known sections: ${Object.values(Y).join(", ")}.`);
|
|
2601
|
+
return t;
|
|
2602
|
+
}) : [];
|
|
2603
|
+
}
|
|
2604
|
+
function Tr(e) {
|
|
2605
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2606
|
+
for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
2607
|
+
return n;
|
|
2608
|
+
}
|
|
2609
|
+
var Er = {
|
|
2610
|
+
"starter-saas-workos": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
2611
|
+
"starter-saas-betterauth": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
2612
|
+
"pack-notifications": ["Notifications push over the `appChannel` socket channel; register it in your server startup to go live."],
|
|
2613
|
+
"pack-collaboration": ["Team and TeamMember are available as CASL subjects; project member and team management reuse the existing `Project` subject."]
|
|
2614
|
+
};
|
|
2615
|
+
function Dr(e) {
|
|
2616
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
2617
|
+
for (let r of e) {
|
|
2618
|
+
let e = Er[r];
|
|
2619
|
+
if (e) for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
2620
|
+
}
|
|
2621
|
+
return n;
|
|
2500
2622
|
}
|
|
2501
2623
|
//#endregion
|
|
2502
2624
|
//#region src/core/stack-config.ts
|
|
2503
|
-
async function
|
|
2625
|
+
async function Or(e) {
|
|
2504
2626
|
return sr(T.join(e, M));
|
|
2505
2627
|
}
|
|
2506
|
-
async function
|
|
2628
|
+
async function kr(e) {
|
|
2507
2629
|
return J(T.join(e, M));
|
|
2508
2630
|
}
|
|
2509
|
-
async function
|
|
2631
|
+
async function Ar(e, t) {
|
|
2510
2632
|
await cr(T.join(e, M), t);
|
|
2511
2633
|
}
|
|
2512
|
-
async function
|
|
2634
|
+
async function jr(e) {
|
|
2513
2635
|
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([lr(t), lr(n)]);
|
|
2514
2636
|
return {
|
|
2515
2637
|
apps: r,
|
|
2516
2638
|
packages: i
|
|
2517
2639
|
};
|
|
2518
2640
|
}
|
|
2519
|
-
function
|
|
2641
|
+
function Mr(e) {
|
|
2520
2642
|
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";
|
|
2521
2643
|
return {
|
|
2522
2644
|
backend: {
|
|
@@ -2550,23 +2672,23 @@ function yr(e) {
|
|
|
2550
2672
|
}
|
|
2551
2673
|
};
|
|
2552
2674
|
}
|
|
2553
|
-
function
|
|
2675
|
+
function Nr(e, t) {
|
|
2554
2676
|
return {
|
|
2555
2677
|
$schema: le(),
|
|
2556
2678
|
version: 1,
|
|
2557
2679
|
name: e,
|
|
2558
2680
|
apps: t.apps,
|
|
2559
2681
|
packages: t.packages,
|
|
2560
|
-
paths:
|
|
2682
|
+
paths: Mr(t),
|
|
2561
2683
|
installedPacks: [],
|
|
2562
2684
|
licenseKey: null
|
|
2563
2685
|
};
|
|
2564
2686
|
}
|
|
2565
|
-
async function
|
|
2566
|
-
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t),
|
|
2687
|
+
async function Pr(e) {
|
|
2688
|
+
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t), ar(n)]);
|
|
2567
2689
|
return r && i;
|
|
2568
2690
|
}
|
|
2569
|
-
function
|
|
2691
|
+
function X(e, t) {
|
|
2570
2692
|
return e.replace(/\{\{(\w+)\.(\w+)\}\}/g, (n, r, i) => {
|
|
2571
2693
|
let a = t[r];
|
|
2572
2694
|
if (!a) throw Error(`Unknown app "${r}" in path template "${e}"`);
|
|
@@ -2577,8 +2699,8 @@ function Y(e, t) {
|
|
|
2577
2699
|
}
|
|
2578
2700
|
//#endregion
|
|
2579
2701
|
//#region src/core/registry.ts
|
|
2580
|
-
async function
|
|
2581
|
-
let { data: t, error: n, status: r } = await
|
|
2702
|
+
async function Fr(e) {
|
|
2703
|
+
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
2582
2704
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2583
2705
|
method: "GET"
|
|
2584
2706
|
}).send();
|
|
@@ -2586,13 +2708,13 @@ async function Sr(e) {
|
|
|
2586
2708
|
if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
|
|
2587
2709
|
return t;
|
|
2588
2710
|
}
|
|
2589
|
-
async function
|
|
2590
|
-
let n =
|
|
2711
|
+
async function Ir(e, t = {}) {
|
|
2712
|
+
let n = K.createRequest()({
|
|
2591
2713
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2592
2714
|
method: "POST"
|
|
2593
2715
|
}), r = {
|
|
2594
|
-
"X-Device-Id":
|
|
2595
|
-
"X-Client-Info":
|
|
2716
|
+
"X-Device-Id": Xn(),
|
|
2717
|
+
"X-Client-Info": Zn()
|
|
2596
2718
|
};
|
|
2597
2719
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2598
2720
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -2612,25 +2734,25 @@ async function Cr(e, t = {}) {
|
|
|
2612
2734
|
packDir: s
|
|
2613
2735
|
};
|
|
2614
2736
|
}
|
|
2615
|
-
function
|
|
2616
|
-
let r =
|
|
2737
|
+
function Lr(e, t, n) {
|
|
2738
|
+
let r = X(e, t);
|
|
2617
2739
|
return T.resolve(n, r);
|
|
2618
2740
|
}
|
|
2619
|
-
function
|
|
2741
|
+
function Rr(e, t) {
|
|
2620
2742
|
return T.join(t, e);
|
|
2621
2743
|
}
|
|
2622
|
-
var
|
|
2744
|
+
var zr = K.createRequest()({
|
|
2623
2745
|
endpoint: "/packs/list",
|
|
2624
2746
|
method: "GET"
|
|
2625
2747
|
});
|
|
2626
|
-
async function
|
|
2627
|
-
let { data: e, error: t } = await
|
|
2748
|
+
async function Br() {
|
|
2749
|
+
let { data: e, error: t } = await zr.send();
|
|
2628
2750
|
if (t || !e) throw Error(`Failed to fetch pack list: ${String(t)}`);
|
|
2629
2751
|
return e.packs;
|
|
2630
2752
|
}
|
|
2631
|
-
async function
|
|
2753
|
+
async function Vr(e, t = {}) {
|
|
2632
2754
|
if (e.length === 0) return {};
|
|
2633
|
-
let n =
|
|
2755
|
+
let n = K.createRequest()({
|
|
2634
2756
|
endpoint: "/packs/authorize",
|
|
2635
2757
|
method: "POST"
|
|
2636
2758
|
}), r = {};
|
|
@@ -2644,35 +2766,35 @@ async function Or(e, t = {}) {
|
|
|
2644
2766
|
}
|
|
2645
2767
|
//#endregion
|
|
2646
2768
|
//#region src/core/codemods.ts
|
|
2647
|
-
var
|
|
2648
|
-
function
|
|
2649
|
-
return
|
|
2769
|
+
var Hr = "@hype-stack/";
|
|
2770
|
+
function Ur(e, t) {
|
|
2771
|
+
return X(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
|
|
2650
2772
|
}
|
|
2651
|
-
async function
|
|
2652
|
-
let r =
|
|
2773
|
+
async function Wr(e, t, n) {
|
|
2774
|
+
let r = X("{{backend.root}}", t), i = T.resolve(n, r, "src/config/env/env.config.ts"), a = T.resolve(n, r, ".env.example"), o = T.resolve(n, r, ".env.test");
|
|
2653
2775
|
if (await J(i)) {
|
|
2654
2776
|
let t = await y.readFile(i, "utf-8");
|
|
2655
|
-
for (let n of e) t.includes(`from "${n.from}"`) || (t =
|
|
2777
|
+
for (let n of e) t.includes(`from "${n.from}"`) || (t = Gr(t, n), t = Kr(t, n));
|
|
2656
2778
|
await y.writeFile(i, t, "utf-8");
|
|
2657
2779
|
}
|
|
2658
2780
|
if (await J(a)) {
|
|
2659
2781
|
let t = await y.readFile(a, "utf-8");
|
|
2660
|
-
for (let n of e) t =
|
|
2782
|
+
for (let n of e) t = qr(t, n);
|
|
2661
2783
|
await y.writeFile(a, t, "utf-8");
|
|
2662
2784
|
}
|
|
2663
2785
|
if (await J(o)) {
|
|
2664
2786
|
let t = await y.readFile(o, "utf-8");
|
|
2665
|
-
for (let n of e) t =
|
|
2787
|
+
for (let n of e) t = Jr(t, n);
|
|
2666
2788
|
await y.writeFile(o, t, "utf-8");
|
|
2667
2789
|
}
|
|
2668
2790
|
}
|
|
2669
|
-
function
|
|
2791
|
+
function Gr(e, t) {
|
|
2670
2792
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2671
2793
|
if (r === -1) return n + "\n" + e;
|
|
2672
2794
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2673
2795
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2674
2796
|
}
|
|
2675
|
-
function
|
|
2797
|
+
function Kr(e, t) {
|
|
2676
2798
|
let n = `.extend(${t.import}.shape)`;
|
|
2677
2799
|
if (e.includes(n)) return e;
|
|
2678
2800
|
let r = e.indexOf("export const envSchema = z.object({");
|
|
@@ -2687,27 +2809,27 @@ function Nr(e, t) {
|
|
|
2687
2809
|
let o = a + 2;
|
|
2688
2810
|
return e.slice(0, o) + n + e.slice(o);
|
|
2689
2811
|
}
|
|
2690
|
-
function
|
|
2812
|
+
function qr(e, t) {
|
|
2691
2813
|
for (let n of Object.keys(t.envExample.vars)) if (e.includes(`${n}=`)) return e;
|
|
2692
2814
|
let n = [];
|
|
2693
|
-
n.push(""), n.push(`# ${t.envExample.section}`);
|
|
2815
|
+
n.push(""), n.push(`# ${hr[t.envExample.section]}`);
|
|
2694
2816
|
for (let [e, r] of Object.entries(t.envExample.vars)) n.push(`${e}=${r}`);
|
|
2695
2817
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2696
2818
|
}
|
|
2697
|
-
function
|
|
2819
|
+
function Jr(e, t) {
|
|
2698
2820
|
for (let n of Object.keys(t.envTest)) if (e.includes(`${n}=`)) return e;
|
|
2699
2821
|
let n = [""];
|
|
2700
2822
|
for (let [e, r] of Object.entries(t.envTest)) n.push(`${e}=${r}`);
|
|
2701
2823
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2702
2824
|
}
|
|
2703
|
-
async function
|
|
2704
|
-
let r = T.resolve(n,
|
|
2825
|
+
async function Yr(e, t, n) {
|
|
2826
|
+
let r = T.resolve(n, X("{{backend.routes}}", t), "index.ts");
|
|
2705
2827
|
if (!await J(r)) return;
|
|
2706
2828
|
let i = await y.readFile(r, "utf-8");
|
|
2707
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2829
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Xr(i, t), i = Zr(i, t));
|
|
2708
2830
|
await y.writeFile(r, i, "utf-8");
|
|
2709
2831
|
}
|
|
2710
|
-
function
|
|
2832
|
+
function Xr(e, t) {
|
|
2711
2833
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2712
2834
|
if (r !== -1) {
|
|
2713
2835
|
let t = e.indexOf("\n", r);
|
|
@@ -2716,7 +2838,7 @@ function Lr(e, t) {
|
|
|
2716
2838
|
let i = e.indexOf("export const registerRoutes");
|
|
2717
2839
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2718
2840
|
}
|
|
2719
|
-
function
|
|
2841
|
+
function Zr(e, t) {
|
|
2720
2842
|
let n = `.route("${t.prefix}", ${t.import})`, r = e.match(/\.route\([^)]+\);/g);
|
|
2721
2843
|
if (r) {
|
|
2722
2844
|
let t = r[r.length - 1], i = e.lastIndexOf(t) + t.length - 1;
|
|
@@ -2724,14 +2846,14 @@ function Rr(e, t) {
|
|
|
2724
2846
|
}
|
|
2725
2847
|
return e.replace("return app;", `return app\n ${n};`);
|
|
2726
2848
|
}
|
|
2727
|
-
async function
|
|
2728
|
-
let r = T.resolve(n,
|
|
2849
|
+
async function Qr(e, t, n) {
|
|
2850
|
+
let r = T.resolve(n, X("{{backend.root}}", t), "src/context.ts");
|
|
2729
2851
|
if (!await J(r)) return;
|
|
2730
2852
|
let i = await y.readFile(r, "utf-8");
|
|
2731
|
-
for (let t of e) i.includes(`export let ${t.export}`) || (i =
|
|
2853
|
+
for (let t of e) i.includes(`export let ${t.export}`) || (i = $r(i, t), i = ei(i, t), i = ti(i, t), i = ri(i, t));
|
|
2732
2854
|
await y.writeFile(r, i, "utf-8");
|
|
2733
2855
|
}
|
|
2734
|
-
function
|
|
2856
|
+
function $r(e, t) {
|
|
2735
2857
|
let n = `import { ${t.typeImport.name} } from "${t.typeImport.from}";`;
|
|
2736
2858
|
if (e.includes(`from "${t.typeImport.from}"`)) return e;
|
|
2737
2859
|
let r = e.lastIndexOf("import ");
|
|
@@ -2739,7 +2861,7 @@ function Br(e, t) {
|
|
|
2739
2861
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2740
2862
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2741
2863
|
}
|
|
2742
|
-
function
|
|
2864
|
+
function ei(e, t) {
|
|
2743
2865
|
let n = `export let ${t.export}: ${t.type};`, r = e.lastIndexOf("export let ");
|
|
2744
2866
|
if (r === -1) {
|
|
2745
2867
|
let t = e.indexOf("export const setupContext");
|
|
@@ -2748,15 +2870,15 @@ function Vr(e, t) {
|
|
|
2748
2870
|
let i = e.indexOf("\n", r);
|
|
2749
2871
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2750
2872
|
}
|
|
2751
|
-
function
|
|
2873
|
+
function ti(e, t) {
|
|
2752
2874
|
let n = ` ${t.export} = ${t.init};`, r = e.match(/export const setupContext\s*=\s*async\s*\([^)]*\)\s*=>\s*\{/);
|
|
2753
2875
|
if (!r) return e;
|
|
2754
2876
|
let i = e.indexOf("{", e.indexOf(r[0]));
|
|
2755
2877
|
if (i === -1) return e;
|
|
2756
|
-
let a =
|
|
2878
|
+
let a = ni(e, i);
|
|
2757
2879
|
return a === -1 ? e : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2758
2880
|
}
|
|
2759
|
-
function
|
|
2881
|
+
function ni(e, t) {
|
|
2760
2882
|
let n = 0;
|
|
2761
2883
|
for (let r = t; r < e.length; r++) {
|
|
2762
2884
|
let t = e[r];
|
|
@@ -2765,20 +2887,20 @@ function Ur(e, t) {
|
|
|
2765
2887
|
}
|
|
2766
2888
|
return -1;
|
|
2767
2889
|
}
|
|
2768
|
-
function
|
|
2890
|
+
function ri(e, t) {
|
|
2769
2891
|
let n = ` ${t.export}: ${t.type};`, r = e.indexOf("export type ContextVariables = {");
|
|
2770
2892
|
if (r === -1) return e;
|
|
2771
2893
|
let i = e.indexOf("};", r);
|
|
2772
2894
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2773
2895
|
}
|
|
2774
|
-
async function
|
|
2775
|
-
let r = T.resolve(n,
|
|
2896
|
+
async function ii(e, t, n) {
|
|
2897
|
+
let r = T.resolve(n, X("{{enums.src}}", t), "index.ts");
|
|
2776
2898
|
if (!await J(r)) return;
|
|
2777
2899
|
let i = await y.readFile(r, "utf-8");
|
|
2778
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2900
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = ai(i, t));
|
|
2779
2901
|
await y.writeFile(r, i, "utf-8");
|
|
2780
2902
|
}
|
|
2781
|
-
function
|
|
2903
|
+
function ai(e, t) {
|
|
2782
2904
|
let n = `export * from "${t.from}";`, r = e.lastIndexOf("export * from");
|
|
2783
2905
|
if (r !== -1) {
|
|
2784
2906
|
let t = e.indexOf("\n", r);
|
|
@@ -2786,14 +2908,14 @@ function Kr(e, t) {
|
|
|
2786
2908
|
}
|
|
2787
2909
|
return e.trim() === "" ? n + "\n" : e.trimEnd() + "\n" + n + "\n";
|
|
2788
2910
|
}
|
|
2789
|
-
async function
|
|
2790
|
-
let r =
|
|
2911
|
+
async function oi(e, t, n) {
|
|
2912
|
+
let r = X("{{backend.root}}", t), i = T.resolve(n, r, "src/sockets/index.ts");
|
|
2791
2913
|
if (!await J(i)) return;
|
|
2792
2914
|
let a = await y.readFile(i, "utf-8");
|
|
2793
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2794
|
-
await J(T.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a =
|
|
2915
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = si(a, t), a = ci(a, t));
|
|
2916
|
+
await J(T.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a = li(a)), await y.writeFile(i, a, "utf-8");
|
|
2795
2917
|
}
|
|
2796
|
-
function
|
|
2918
|
+
function si(e, t) {
|
|
2797
2919
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2798
2920
|
if (r !== -1) {
|
|
2799
2921
|
let t = e.indexOf("\n", r);
|
|
@@ -2802,7 +2924,7 @@ function Jr(e, t) {
|
|
|
2802
2924
|
let i = e.indexOf("const sockets");
|
|
2803
2925
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2804
2926
|
}
|
|
2805
|
-
function
|
|
2927
|
+
function ci(e, t) {
|
|
2806
2928
|
let n = `.socket("${t.prefix}", ${t.import})`, r = e.indexOf("const sockets");
|
|
2807
2929
|
if (r === -1) return e;
|
|
2808
2930
|
let i = e.indexOf("new SocketRouter", r);
|
|
@@ -2816,7 +2938,7 @@ function Yr(e, t) {
|
|
|
2816
2938
|
}
|
|
2817
2939
|
return e;
|
|
2818
2940
|
}
|
|
2819
|
-
function
|
|
2941
|
+
function li(e) {
|
|
2820
2942
|
if (e.includes("wsAuthenticate")) return e;
|
|
2821
2943
|
let t = e.indexOf("from \"@backend/libs/websocket/socket-router\""), n = e;
|
|
2822
2944
|
if (t !== -1) {
|
|
@@ -2825,14 +2947,14 @@ function Xr(e) {
|
|
|
2825
2947
|
}
|
|
2826
2948
|
return n.replace("new SocketRouter()", "new SocketRouter({ authenticate: wsAuthenticate })");
|
|
2827
2949
|
}
|
|
2828
|
-
async function
|
|
2829
|
-
let r =
|
|
2950
|
+
async function ui(e, t, n) {
|
|
2951
|
+
let r = X("{{frontend.root}}", t), i = T.resolve(n, r, "src/api/sdk.ts");
|
|
2830
2952
|
if (!await J(i)) return;
|
|
2831
2953
|
let a = await y.readFile(i, "utf-8");
|
|
2832
|
-
for (let t of e) a.includes(`.$configure(${t.import})`) || (a =
|
|
2954
|
+
for (let t of e) a.includes(`.$configure(${t.import})`) || (a = di(a, t), a = fi(a, t));
|
|
2833
2955
|
await y.writeFile(i, a, "utf-8");
|
|
2834
2956
|
}
|
|
2835
|
-
function
|
|
2957
|
+
function di(e, t) {
|
|
2836
2958
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2837
2959
|
if (e.includes(n)) return e;
|
|
2838
2960
|
let r = e.lastIndexOf("from \"./");
|
|
@@ -2843,20 +2965,20 @@ function Qr(e, t) {
|
|
|
2843
2965
|
let i = e.indexOf("export const sdk");
|
|
2844
2966
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2845
2967
|
}
|
|
2846
|
-
function
|
|
2968
|
+
function fi(e, t) {
|
|
2847
2969
|
let n = `.$configure(${t.import})`, r = e.indexOf("export const sdk");
|
|
2848
2970
|
if (r === -1) return e;
|
|
2849
2971
|
let i = e.indexOf(";", r);
|
|
2850
2972
|
return i === -1 ? e : e.slice(0, i) + "\n " + n + e.slice(i);
|
|
2851
2973
|
}
|
|
2852
|
-
async function
|
|
2853
|
-
let r = T.resolve(n,
|
|
2974
|
+
async function pi(e, t, n) {
|
|
2975
|
+
let r = T.resolve(n, X("{{backend.utils}}", t), "frontend-url/frontend-url.ts");
|
|
2854
2976
|
if (!await J(r)) return;
|
|
2855
2977
|
let i = await y.readFile(r, "utf-8");
|
|
2856
|
-
for (let t of e) i.includes(`"${t.path}"`) || (i =
|
|
2978
|
+
for (let t of e) i.includes(`"${t.path}"`) || (i = mi(i, t));
|
|
2857
2979
|
await y.writeFile(r, i, "utf-8");
|
|
2858
2980
|
}
|
|
2859
|
-
function
|
|
2981
|
+
function mi(e, t) {
|
|
2860
2982
|
let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
|
|
2861
2983
|
if (r === -1) return e;
|
|
2862
2984
|
let i = e.indexOf("{", r);
|
|
@@ -2872,38 +2994,38 @@ function ti(e, t) {
|
|
|
2872
2994
|
}
|
|
2873
2995
|
return o === -1 ? e : e.slice(0, o) + n + "\n" + e.slice(o);
|
|
2874
2996
|
}
|
|
2875
|
-
var
|
|
2997
|
+
var hi = "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", gi = {
|
|
2876
2998
|
primary: "primaryNav",
|
|
2877
2999
|
secondary: "secondaryNav",
|
|
2878
3000
|
tertiary: "tertiaryNav",
|
|
2879
3001
|
settings: "settingsNav"
|
|
2880
3002
|
};
|
|
2881
|
-
async function
|
|
2882
|
-
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2883
|
-
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s =
|
|
2884
|
-
for (let e of t) s.includes(`label: "${e.label}"`) || (s =
|
|
2885
|
-
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s =
|
|
3003
|
+
async function _i(e) {
|
|
3004
|
+
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Ur(i, n), o = T.resolve(r, a, "src/constants/nav.constants.ts"), s;
|
|
3005
|
+
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = hi);
|
|
3006
|
+
for (let e of t) s.includes(`label: "${e.label}"`) || (s = bi(s, e));
|
|
3007
|
+
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s = Si(s, e));
|
|
2886
3008
|
await y.writeFile(o, s, "utf-8");
|
|
2887
3009
|
}
|
|
2888
|
-
async function
|
|
2889
|
-
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
3010
|
+
async function vi(e) {
|
|
3011
|
+
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Ur(i, n), o = T.resolve(r, a, "src/features/auth/constants/auth.constants.ts");
|
|
2890
3012
|
if (!await J(o)) return;
|
|
2891
3013
|
let s = await y.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
|
|
2892
3014
|
if (!c.test(s)) return;
|
|
2893
3015
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
2894
3016
|
await y.writeFile(o, l, "utf-8");
|
|
2895
3017
|
}
|
|
2896
|
-
function
|
|
3018
|
+
function yi(e) {
|
|
2897
3019
|
let t = [e.icon];
|
|
2898
3020
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
2899
3021
|
return t;
|
|
2900
3022
|
}
|
|
2901
|
-
function
|
|
2902
|
-
let n =
|
|
2903
|
-
for (let e of n) r =
|
|
3023
|
+
function bi(e, t) {
|
|
3024
|
+
let n = yi(t), r = e;
|
|
3025
|
+
for (let e of n) r = xi(r, e);
|
|
2904
3026
|
return r;
|
|
2905
3027
|
}
|
|
2906
|
-
function
|
|
3028
|
+
function xi(e, t) {
|
|
2907
3029
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
2908
3030
|
if (!n) return e;
|
|
2909
3031
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -2911,21 +3033,21 @@ function ci(e, t) {
|
|
|
2911
3033
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
2912
3034
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
2913
3035
|
}
|
|
2914
|
-
function
|
|
2915
|
-
let n =
|
|
3036
|
+
function Si(e, t) {
|
|
3037
|
+
let n = gi[t.group];
|
|
2916
3038
|
if (!n) return e;
|
|
2917
|
-
let r =
|
|
3039
|
+
let r = wi(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
|
|
2918
3040
|
if (!a) return e;
|
|
2919
|
-
let o = e.indexOf(a[0]) + a[0].length, s =
|
|
3041
|
+
let o = e.indexOf(a[0]) + a[0].length, s = Ci(e, o - 1);
|
|
2920
3042
|
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);
|
|
2921
3043
|
}
|
|
2922
|
-
function
|
|
3044
|
+
function Ci(e, t) {
|
|
2923
3045
|
let n = 0;
|
|
2924
3046
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2925
3047
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2926
3048
|
return -1;
|
|
2927
3049
|
}
|
|
2928
|
-
function
|
|
3050
|
+
function wi(e) {
|
|
2929
3051
|
let t = [];
|
|
2930
3052
|
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) {
|
|
2931
3053
|
t.push(" items: [");
|
|
@@ -2941,14 +3063,14 @@ function di(e) {
|
|
|
2941
3063
|
} else t.push(" items: [],");
|
|
2942
3064
|
return t.push(" },"), t.join("\n");
|
|
2943
3065
|
}
|
|
2944
|
-
async function
|
|
2945
|
-
let r =
|
|
3066
|
+
async function Ti(e, t, n) {
|
|
3067
|
+
let r = X("{{backend.features}}", t), i = T.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
|
|
2946
3068
|
if (!await J(i)) return;
|
|
2947
3069
|
let a = await y.readFile(i, "utf-8");
|
|
2948
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
3070
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = Ei(a, t), a = Di(a, t));
|
|
2949
3071
|
await y.writeFile(i, a, "utf-8");
|
|
2950
3072
|
}
|
|
2951
|
-
function
|
|
3073
|
+
function Ei(e, t) {
|
|
2952
3074
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2953
3075
|
if (r !== -1) {
|
|
2954
3076
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -2956,38 +3078,38 @@ function pi(e, t) {
|
|
|
2956
3078
|
}
|
|
2957
3079
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
2958
3080
|
}
|
|
2959
|
-
function
|
|
3081
|
+
function Di(e, t) {
|
|
2960
3082
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
2961
3083
|
if (!r) return e;
|
|
2962
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
3084
|
+
let i = e.indexOf(r[0]) + r[0].length, a = Oi(e, i - 1);
|
|
2963
3085
|
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);
|
|
2964
3086
|
}
|
|
2965
|
-
function
|
|
3087
|
+
function Oi(e, t) {
|
|
2966
3088
|
let n = 0;
|
|
2967
3089
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2968
3090
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2969
3091
|
return -1;
|
|
2970
3092
|
}
|
|
2971
|
-
var
|
|
2972
|
-
async function
|
|
2973
|
-
await
|
|
3093
|
+
var ki = "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";
|
|
3094
|
+
async function Ai(e) {
|
|
3095
|
+
await Mi({
|
|
2974
3096
|
...e,
|
|
2975
3097
|
arrayName: "navbarActions"
|
|
2976
3098
|
});
|
|
2977
3099
|
}
|
|
2978
|
-
async function
|
|
2979
|
-
await
|
|
3100
|
+
async function ji(e) {
|
|
3101
|
+
await Mi({
|
|
2980
3102
|
...e,
|
|
2981
3103
|
arrayName: "userMenuActions"
|
|
2982
3104
|
});
|
|
2983
3105
|
}
|
|
2984
|
-
async function
|
|
2985
|
-
let a =
|
|
2986
|
-
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s =
|
|
2987
|
-
for (let n of e) s =
|
|
3106
|
+
async function Mi({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
|
|
3107
|
+
let a = Ur(i, n), o = T.resolve(r, a, "src/constants/navbar-actions.tsx"), s;
|
|
3108
|
+
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = ki);
|
|
3109
|
+
for (let n of e) s = Ni(s, n), s = Pi(s, n, t);
|
|
2988
3110
|
await y.writeFile(o, s, "utf-8");
|
|
2989
3111
|
}
|
|
2990
|
-
function
|
|
3112
|
+
function Ni(e, t) {
|
|
2991
3113
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2992
3114
|
if (e.includes(n)) return e;
|
|
2993
3115
|
let r = e.lastIndexOf("import ");
|
|
@@ -2995,38 +3117,38 @@ function bi(e, t) {
|
|
|
2995
3117
|
let i = e.indexOf("\n", r);
|
|
2996
3118
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2997
3119
|
}
|
|
2998
|
-
function
|
|
3120
|
+
function Pi(e, t, n) {
|
|
2999
3121
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
3000
3122
|
if (!r) return e;
|
|
3001
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
3123
|
+
let i = e.indexOf(r[0]) + r[0].length, a = Fi(e, i - 1);
|
|
3002
3124
|
if (a === -1) return e;
|
|
3003
3125
|
let o = e.slice(i, a);
|
|
3004
3126
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
3005
3127
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
3006
3128
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
3007
3129
|
}
|
|
3008
|
-
function
|
|
3130
|
+
function Fi(e, t) {
|
|
3009
3131
|
let n = 0;
|
|
3010
3132
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3011
3133
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3012
3134
|
return -1;
|
|
3013
3135
|
}
|
|
3014
|
-
var
|
|
3136
|
+
var Ii = new Set([
|
|
3015
3137
|
".ts",
|
|
3016
3138
|
".tsx",
|
|
3017
3139
|
".js",
|
|
3018
3140
|
".jsx"
|
|
3019
3141
|
]);
|
|
3020
|
-
async function
|
|
3142
|
+
async function Li(e) {
|
|
3021
3143
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
3022
3144
|
if (i === "hype-stack") return;
|
|
3023
3145
|
let a = `@${i}/`;
|
|
3024
3146
|
await Promise.all(t.map(async (e) => {
|
|
3025
|
-
let t =
|
|
3026
|
-
i?.isDirectory() ? await
|
|
3147
|
+
let t = Lr(e.target, n, r), i = await y.stat(t).catch(() => null);
|
|
3148
|
+
i?.isDirectory() ? await Bi(t, a) : i?.isFile() && Ii.has(T.extname(t)) && await Vi(t, a);
|
|
3027
3149
|
}));
|
|
3028
3150
|
}
|
|
3029
|
-
var
|
|
3151
|
+
var Ri = new Set([
|
|
3030
3152
|
".git",
|
|
3031
3153
|
"node_modules",
|
|
3032
3154
|
"dist",
|
|
@@ -3035,43 +3157,43 @@ var Ti = new Set([
|
|
|
3035
3157
|
".next",
|
|
3036
3158
|
"coverage"
|
|
3037
3159
|
]);
|
|
3038
|
-
async function
|
|
3039
|
-
t !== "hype-stack" && await
|
|
3160
|
+
async function zi(e, t) {
|
|
3161
|
+
t !== "hype-stack" && await Bi(e, `@${t}/`);
|
|
3040
3162
|
}
|
|
3041
|
-
async function
|
|
3163
|
+
async function Bi(e, t) {
|
|
3042
3164
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3043
3165
|
await Promise.all(n.map(async (n) => {
|
|
3044
3166
|
let r = T.join(e, n.name);
|
|
3045
3167
|
if (n.isDirectory()) {
|
|
3046
|
-
if (
|
|
3047
|
-
await
|
|
3048
|
-
} else n.isFile() &&
|
|
3168
|
+
if (Ri.has(n.name)) return;
|
|
3169
|
+
await Bi(r, t);
|
|
3170
|
+
} else n.isFile() && Ii.has(T.extname(n.name)) && await Vi(r, t);
|
|
3049
3171
|
}));
|
|
3050
3172
|
}
|
|
3051
|
-
async function
|
|
3173
|
+
async function Vi(e, t) {
|
|
3052
3174
|
let n = await y.readFile(e, "utf-8");
|
|
3053
|
-
if (!n.includes(
|
|
3054
|
-
let r = n.replaceAll(
|
|
3175
|
+
if (!n.includes(Hr)) return;
|
|
3176
|
+
let r = n.replaceAll(Hr, t);
|
|
3055
3177
|
await y.writeFile(e, r, "utf-8");
|
|
3056
3178
|
}
|
|
3057
3179
|
//#endregion
|
|
3058
3180
|
//#region src/core/installer.ts
|
|
3059
|
-
function
|
|
3181
|
+
function Hi(e, t) {
|
|
3060
3182
|
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3061
3183
|
}
|
|
3062
|
-
async function
|
|
3184
|
+
async function Ui(e, t) {
|
|
3063
3185
|
if ((await y.stat(e)).isDirectory()) {
|
|
3064
3186
|
await y.mkdir(t, { recursive: !0 });
|
|
3065
3187
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3066
|
-
for (let r of n) await
|
|
3188
|
+
for (let r of n) await Ui(T.join(e, r.name), T.join(t, r.name));
|
|
3067
3189
|
} else await y.mkdir(T.dirname(t), { recursive: !0 }), await y.copyFile(e, t);
|
|
3068
3190
|
}
|
|
3069
|
-
async function
|
|
3191
|
+
async function Wi(e) {
|
|
3070
3192
|
let { src: t, dest: n, projectRoot: r, skip: i } = e;
|
|
3071
3193
|
if ((await y.stat(t)).isDirectory()) {
|
|
3072
3194
|
await y.mkdir(n, { recursive: !0 });
|
|
3073
3195
|
let e = await y.readdir(t, { withFileTypes: !0 });
|
|
3074
|
-
return (await Promise.all(e.map((e) =>
|
|
3196
|
+
return (await Promise.all(e.map((e) => Wi({
|
|
3075
3197
|
src: T.join(t, e.name),
|
|
3076
3198
|
dest: T.join(n, e.name),
|
|
3077
3199
|
projectRoot: r,
|
|
@@ -3080,17 +3202,17 @@ async function ji(e) {
|
|
|
3080
3202
|
}
|
|
3081
3203
|
return i.has(t) ? [] : (await y.mkdir(T.dirname(n), { recursive: !0 }), await y.copyFile(t, n), [T.relative(r, n)]);
|
|
3082
3204
|
}
|
|
3083
|
-
async function
|
|
3084
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a =
|
|
3205
|
+
async function Gi(e) {
|
|
3206
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = Rr(t.source, n), o = Lr(t.target, r, i);
|
|
3085
3207
|
return {
|
|
3086
3208
|
sourcePath: a,
|
|
3087
3209
|
targetPath: o,
|
|
3088
|
-
sourceExists: await J(a) || await
|
|
3089
|
-
targetExists: await J(o) || await
|
|
3210
|
+
sourceExists: await J(a) || await ar(a),
|
|
3211
|
+
targetExists: await J(o) || await ar(o)
|
|
3090
3212
|
};
|
|
3091
3213
|
}
|
|
3092
|
-
async function
|
|
3093
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await
|
|
3214
|
+
async function Ki(e) {
|
|
3215
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await Gi({
|
|
3094
3216
|
file: t,
|
|
3095
3217
|
packDir: n,
|
|
3096
3218
|
paths: r,
|
|
@@ -3105,8 +3227,8 @@ async function Ni(e) {
|
|
|
3105
3227
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3106
3228
|
}
|
|
3107
3229
|
}
|
|
3108
|
-
async function
|
|
3109
|
-
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await
|
|
3230
|
+
async function qi(e) {
|
|
3231
|
+
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await Gi({
|
|
3110
3232
|
file: t,
|
|
3111
3233
|
packDir: n,
|
|
3112
3234
|
paths: r,
|
|
@@ -3124,7 +3246,7 @@ async function Pi(e) {
|
|
|
3124
3246
|
status: "skipped",
|
|
3125
3247
|
path: t.target,
|
|
3126
3248
|
reason: "Already exists"
|
|
3127
|
-
} : (await
|
|
3249
|
+
} : (await Ui(s, c), {
|
|
3128
3250
|
status: "installed",
|
|
3129
3251
|
path: t.target
|
|
3130
3252
|
});
|
|
@@ -3133,16 +3255,16 @@ async function Pi(e) {
|
|
|
3133
3255
|
status: "skipped",
|
|
3134
3256
|
path: t.target,
|
|
3135
3257
|
reason: "Already exists (skip-if-exists)"
|
|
3136
|
-
} : (await
|
|
3258
|
+
} : (await Ui(s, c), {
|
|
3137
3259
|
status: "installed",
|
|
3138
3260
|
path: t.target
|
|
3139
3261
|
});
|
|
3140
|
-
case "override": return await
|
|
3262
|
+
case "override": return await Ui(s, c), {
|
|
3141
3263
|
status: "installed",
|
|
3142
3264
|
path: t.target
|
|
3143
3265
|
};
|
|
3144
3266
|
case "merge": {
|
|
3145
|
-
if (!u) return await
|
|
3267
|
+
if (!u) return await Ui(s, c), {
|
|
3146
3268
|
status: "installed",
|
|
3147
3269
|
path: t.target
|
|
3148
3270
|
};
|
|
@@ -3172,15 +3294,15 @@ async function Pi(e) {
|
|
|
3172
3294
|
};
|
|
3173
3295
|
}
|
|
3174
3296
|
}
|
|
3175
|
-
async function
|
|
3297
|
+
async function Ji(e) {
|
|
3176
3298
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3177
3299
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3178
3300
|
let o = [], s = /* @__PURE__ */ new Set();
|
|
3179
3301
|
for (let e of t) {
|
|
3180
3302
|
let t = i?.get(e.manifest.name);
|
|
3181
3303
|
for (let n of e.manifest.files) {
|
|
3182
|
-
if (n.strategy !== "create" || !
|
|
3183
|
-
let { targetPath: i, targetExists: c } = await
|
|
3304
|
+
if (n.strategy !== "create" || !Hi(n, t)) continue;
|
|
3305
|
+
let { targetPath: i, targetExists: c } = await Gi({
|
|
3184
3306
|
file: n,
|
|
3185
3307
|
packDir: e.packDir,
|
|
3186
3308
|
paths: a,
|
|
@@ -3195,13 +3317,13 @@ async function Fi(e) {
|
|
|
3195
3317
|
}
|
|
3196
3318
|
return o;
|
|
3197
3319
|
}
|
|
3198
|
-
async function
|
|
3320
|
+
async function Yi(e) {
|
|
3199
3321
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3200
3322
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3201
3323
|
let c = [];
|
|
3202
3324
|
for (let e of t.files) {
|
|
3203
|
-
if (!
|
|
3204
|
-
let t = await
|
|
3325
|
+
if (!Hi(e, o)) continue;
|
|
3326
|
+
let t = await Ki({
|
|
3205
3327
|
file: e,
|
|
3206
3328
|
packDir: a,
|
|
3207
3329
|
paths: s,
|
|
@@ -3212,16 +3334,16 @@ async function Ii(e) {
|
|
|
3212
3334
|
}
|
|
3213
3335
|
return c;
|
|
3214
3336
|
}
|
|
3215
|
-
async function
|
|
3337
|
+
async function Xi(e) {
|
|
3216
3338
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3217
3339
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3218
3340
|
let l = {
|
|
3219
3341
|
installed: [],
|
|
3220
3342
|
skipped: [],
|
|
3221
3343
|
errors: []
|
|
3222
|
-
}, u = t.files.filter((e) =>
|
|
3344
|
+
}, u = t.files.filter((e) => Hi(e, s));
|
|
3223
3345
|
for (let e of u) {
|
|
3224
|
-
let t = await
|
|
3346
|
+
let t = await qi({
|
|
3225
3347
|
file: e,
|
|
3226
3348
|
packDir: o,
|
|
3227
3349
|
paths: c,
|
|
@@ -3241,40 +3363,40 @@ async function Li(e) {
|
|
|
3241
3363
|
break;
|
|
3242
3364
|
}
|
|
3243
3365
|
}
|
|
3244
|
-
await
|
|
3366
|
+
await Li({
|
|
3245
3367
|
files: u,
|
|
3246
3368
|
paths: c,
|
|
3247
3369
|
projectRoot: r,
|
|
3248
3370
|
projectName: n.name
|
|
3249
|
-
}), t.env && t.env.length > 0 && await
|
|
3371
|
+
}), t.env && t.env.length > 0 && await Wr(t.env, c, r), t.routes && t.routes.length > 0 && await Yr(t.routes, c, r), t.context && t.context.length > 0 && await Qr(t.context, c, r), t.sockets && t.sockets.length > 0 && await oi(t.sockets, c, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await ui(t.sdkConfigurations, c, r), t.enums && t.enums.length > 0 && await ii(t.enums, c, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await pi(t.frontendRoutes, c, r);
|
|
3250
3372
|
let d = s && s.length > 0 ? s : ["frontend"];
|
|
3251
|
-
for (let e of d) t.nav && t.nav.length > 0 && await
|
|
3373
|
+
for (let e of d) t.nav && t.nav.length > 0 && await _i({
|
|
3252
3374
|
entries: t.nav,
|
|
3253
3375
|
paths: c,
|
|
3254
3376
|
projectRoot: r,
|
|
3255
3377
|
slot: e
|
|
3256
|
-
}), t.navbarActions && t.navbarActions.length > 0 && await
|
|
3378
|
+
}), t.navbarActions && t.navbarActions.length > 0 && await Ai({
|
|
3257
3379
|
actions: t.navbarActions,
|
|
3258
3380
|
paths: c,
|
|
3259
3381
|
projectRoot: r,
|
|
3260
3382
|
slot: e
|
|
3261
|
-
}), t.userMenuActions && t.userMenuActions.length > 0 && await
|
|
3383
|
+
}), t.userMenuActions && t.userMenuActions.length > 0 && await ji({
|
|
3262
3384
|
actions: t.userMenuActions,
|
|
3263
3385
|
paths: c,
|
|
3264
3386
|
projectRoot: r,
|
|
3265
3387
|
slot: e
|
|
3266
3388
|
});
|
|
3267
|
-
return t.onboardingSteps && t.onboardingSteps.length > 0 && await
|
|
3389
|
+
return t.onboardingSteps && t.onboardingSteps.length > 0 && await Ti(t.onboardingSteps, c, r), t.postLoginRedirect && await vi({
|
|
3268
3390
|
postLoginRedirect: t.postLoginRedirect,
|
|
3269
3391
|
paths: c,
|
|
3270
3392
|
projectRoot: r,
|
|
3271
3393
|
slot: d[0]
|
|
3272
3394
|
}), l;
|
|
3273
3395
|
}
|
|
3274
|
-
async function
|
|
3396
|
+
async function Zi(e) {
|
|
3275
3397
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3276
3398
|
for (let e of t) {
|
|
3277
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3399
|
+
let t = o?.get(e.manifest.name), a = await Yi({
|
|
3278
3400
|
manifest: e.manifest,
|
|
3279
3401
|
config: n,
|
|
3280
3402
|
projectRoot: r,
|
|
@@ -3294,7 +3416,7 @@ async function Ri(e) {
|
|
|
3294
3416
|
};
|
|
3295
3417
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3296
3418
|
for (let e of t) {
|
|
3297
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3419
|
+
let t = o?.get(e.manifest.name), n = await Xi({
|
|
3298
3420
|
manifest: e.manifest,
|
|
3299
3421
|
config: f,
|
|
3300
3422
|
projectRoot: r,
|
|
@@ -3303,7 +3425,7 @@ async function Ri(e) {
|
|
|
3303
3425
|
packDir: e.packDir,
|
|
3304
3426
|
slots: t
|
|
3305
3427
|
});
|
|
3306
|
-
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await
|
|
3428
|
+
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await Qi(f, e.manifest, r), d.push(e.manifest.name);
|
|
3307
3429
|
}
|
|
3308
3430
|
return {
|
|
3309
3431
|
installed: c,
|
|
@@ -3314,24 +3436,28 @@ async function Ri(e) {
|
|
|
3314
3436
|
config: f
|
|
3315
3437
|
};
|
|
3316
3438
|
}
|
|
3317
|
-
async function
|
|
3318
|
-
let r = {
|
|
3439
|
+
async function Qi(e, t, n) {
|
|
3440
|
+
let r = typeof t == "string" ? t : t.name, i = typeof t == "string" ? [] : wr(t.env), a = Tr([...e.onboarding?.envSections ?? [], ...i]), o = {
|
|
3319
3441
|
...e,
|
|
3320
|
-
installedPacks: [...e.installedPacks ?? [],
|
|
3442
|
+
installedPacks: [...e.installedPacks ?? [], r],
|
|
3443
|
+
onboarding: {
|
|
3444
|
+
...e.onboarding,
|
|
3445
|
+
envSections: a
|
|
3446
|
+
}
|
|
3321
3447
|
};
|
|
3322
|
-
return await
|
|
3448
|
+
return await Ar(n, o), o;
|
|
3323
3449
|
}
|
|
3324
|
-
async function
|
|
3450
|
+
async function $i(e) {
|
|
3325
3451
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3326
3452
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3327
|
-
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) =>
|
|
3328
|
-
if (await
|
|
3453
|
+
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) => Rr(e.source, i))), u = T.join(i, "files");
|
|
3454
|
+
if (await ar(u)) {
|
|
3329
3455
|
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3330
3456
|
for (let t of e) {
|
|
3331
3457
|
if (!t.isDirectory()) continue;
|
|
3332
3458
|
let e = a[t.name]?.root;
|
|
3333
3459
|
if (!e) continue;
|
|
3334
|
-
let n = await
|
|
3460
|
+
let n = await Wi({
|
|
3335
3461
|
src: T.join(u, t.name),
|
|
3336
3462
|
dest: T.resolve(r, e),
|
|
3337
3463
|
projectRoot: r,
|
|
@@ -3341,7 +3467,7 @@ async function Bi(e) {
|
|
|
3341
3467
|
}
|
|
3342
3468
|
}
|
|
3343
3469
|
for (let e of c) {
|
|
3344
|
-
let t = await
|
|
3470
|
+
let t = await qi({
|
|
3345
3471
|
file: e,
|
|
3346
3472
|
packDir: i,
|
|
3347
3473
|
paths: a,
|
|
@@ -3351,12 +3477,12 @@ async function Bi(e) {
|
|
|
3351
3477
|
});
|
|
3352
3478
|
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3353
3479
|
}
|
|
3354
|
-
let d = T.join(
|
|
3355
|
-
return await J(f) && await J(p) && await y.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await
|
|
3480
|
+
let d = T.join(Lr("{{frontend.root}}", a, r), "src", "routes"), f = T.join(d, "(public)", "index.tsx"), p = T.join(d, "(private)", "index.tsx");
|
|
3481
|
+
return await J(f) && await J(p) && await y.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await pi(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await _i({
|
|
3356
3482
|
entries: t.nav,
|
|
3357
3483
|
paths: a,
|
|
3358
3484
|
projectRoot: r
|
|
3359
|
-
}), t.postLoginRedirect && await
|
|
3485
|
+
}), t.postLoginRedirect && await vi({
|
|
3360
3486
|
postLoginRedirect: t.postLoginRedirect,
|
|
3361
3487
|
paths: a,
|
|
3362
3488
|
projectRoot: r
|
|
@@ -3367,28 +3493,32 @@ async function Bi(e) {
|
|
|
3367
3493
|
}
|
|
3368
3494
|
//#endregion
|
|
3369
3495
|
//#region src/core/pack-categories.ts
|
|
3370
|
-
var
|
|
3496
|
+
var ea = [
|
|
3371
3497
|
"starter",
|
|
3372
3498
|
"layout",
|
|
3373
3499
|
"feature"
|
|
3374
|
-
],
|
|
3500
|
+
], ta = {
|
|
3375
3501
|
starter: "Starter",
|
|
3376
3502
|
layout: "Layout",
|
|
3377
3503
|
feature: "Features"
|
|
3378
|
-
},
|
|
3379
|
-
function
|
|
3504
|
+
}, na = new Set(["starter", "layout"]), ra = "starter-saas-betterauth", ia = "layout-basic";
|
|
3505
|
+
function aa(e, t = {}) {
|
|
3380
3506
|
let n = [];
|
|
3381
|
-
for (let r of
|
|
3507
|
+
for (let r of ea) {
|
|
3382
3508
|
let i = e.filter((e) => e.category === r);
|
|
3383
3509
|
if (i.length === 0) continue;
|
|
3384
|
-
let a =
|
|
3510
|
+
let a = na.has(r) ? "single" : "multiple";
|
|
3385
3511
|
if (r === "layout") {
|
|
3386
|
-
n.push(
|
|
3512
|
+
n.push(sa("frontend", i)), t.adminAvailable && n.push(sa("admin", i));
|
|
3513
|
+
continue;
|
|
3514
|
+
}
|
|
3515
|
+
if (r === "starter") {
|
|
3516
|
+
n.push(oa(i));
|
|
3387
3517
|
continue;
|
|
3388
3518
|
}
|
|
3389
3519
|
n.push({
|
|
3390
3520
|
category: r,
|
|
3391
|
-
label:
|
|
3521
|
+
label: ta[r],
|
|
3392
3522
|
mode: a,
|
|
3393
3523
|
packs: i,
|
|
3394
3524
|
preselect: null
|
|
@@ -3396,55 +3526,65 @@ function Gi(e, t = {}) {
|
|
|
3396
3526
|
}
|
|
3397
3527
|
return n;
|
|
3398
3528
|
}
|
|
3399
|
-
function
|
|
3400
|
-
let
|
|
3529
|
+
function oa(e) {
|
|
3530
|
+
let t = e.some((e) => e.name === ra);
|
|
3531
|
+
return {
|
|
3532
|
+
category: "starter",
|
|
3533
|
+
label: ta.starter,
|
|
3534
|
+
mode: "single",
|
|
3535
|
+
packs: e,
|
|
3536
|
+
preselect: t ? ra : null
|
|
3537
|
+
};
|
|
3538
|
+
}
|
|
3539
|
+
function sa(e, t) {
|
|
3540
|
+
let n = t.some((e) => e.name === ia);
|
|
3401
3541
|
return {
|
|
3402
3542
|
category: "layout",
|
|
3403
3543
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3404
3544
|
mode: "single",
|
|
3405
3545
|
packs: t,
|
|
3406
|
-
preselect: n ?
|
|
3546
|
+
preselect: n ? ia : null,
|
|
3407
3547
|
slot: e
|
|
3408
3548
|
};
|
|
3409
3549
|
}
|
|
3410
3550
|
//#endregion
|
|
3411
3551
|
//#region src/ui/logger.ts
|
|
3412
|
-
function
|
|
3413
|
-
s.note(e.map((e) => `${
|
|
3552
|
+
function ca(e) {
|
|
3553
|
+
s.note(e.map((e) => `${V.arrow} ${e}`).join("\n"), "Next steps");
|
|
3414
3554
|
}
|
|
3415
|
-
function
|
|
3416
|
-
s.cancel(
|
|
3555
|
+
function Z() {
|
|
3556
|
+
s.cancel(B.muted("Operation cancelled.")), process.exit(0);
|
|
3417
3557
|
}
|
|
3418
3558
|
//#endregion
|
|
3419
3559
|
//#region src/core/post-setup.ts
|
|
3420
|
-
async function
|
|
3421
|
-
return (await
|
|
3560
|
+
async function la() {
|
|
3561
|
+
return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3422
3562
|
}
|
|
3423
|
-
async function
|
|
3563
|
+
async function ua(e) {
|
|
3424
3564
|
return J(`${e}/apps/backend/.env`);
|
|
3425
3565
|
}
|
|
3426
|
-
async function
|
|
3427
|
-
let r = n ? `Start services with ${
|
|
3566
|
+
async function da(e, t, n) {
|
|
3567
|
+
let r = n ? `Start services with ${B.command("docker compose up -d")}?` : `Docker is not running. Start services with ${B.command("docker compose up -d")}?`, i = t ? !0 : await s.confirm({
|
|
3428
3568
|
message: r,
|
|
3429
3569
|
initialValue: !0
|
|
3430
3570
|
});
|
|
3431
|
-
if (s.isCancel(i) &&
|
|
3571
|
+
if (s.isCancel(i) && Z(), !i) return s.log.info(B.muted("Skipping Docker services and database migrations.")), !1;
|
|
3432
3572
|
let a = s.spinner();
|
|
3433
3573
|
a.start("Starting Docker services...");
|
|
3434
|
-
let o = await
|
|
3574
|
+
let o = await q("docker", [
|
|
3435
3575
|
"compose",
|
|
3436
3576
|
"up",
|
|
3437
3577
|
"-d"
|
|
3438
3578
|
], { cwd: `${e}/apps/backend` });
|
|
3439
|
-
return o.exitCode === 0 ? (a.stop(
|
|
3579
|
+
return o.exitCode === 0 ? (a.stop(B.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), fa(o), !1);
|
|
3440
3580
|
}
|
|
3441
|
-
function
|
|
3581
|
+
function fa(e) {
|
|
3442
3582
|
let t = (e.stderr || e.stdout).trim();
|
|
3443
|
-
t && s.log.warn(
|
|
3583
|
+
t && s.log.warn(B.muted(t));
|
|
3444
3584
|
}
|
|
3445
|
-
async function
|
|
3585
|
+
async function pa(e, t = 15, n = 2e3) {
|
|
3446
3586
|
for (let r = 0; r < t; r++) {
|
|
3447
|
-
if ((await
|
|
3587
|
+
if ((await q("docker", [
|
|
3448
3588
|
"compose",
|
|
3449
3589
|
"exec",
|
|
3450
3590
|
"-T",
|
|
@@ -3457,9 +3597,9 @@ async function Qi(e, t = 15, n = 2e3) {
|
|
|
3457
3597
|
}
|
|
3458
3598
|
return !1;
|
|
3459
3599
|
}
|
|
3460
|
-
var
|
|
3461
|
-
async function
|
|
3462
|
-
let t = await
|
|
3600
|
+
var ma = "Database schema is up to date";
|
|
3601
|
+
async function ha(e) {
|
|
3602
|
+
let t = await q("pnpm", [
|
|
3463
3603
|
"--filter",
|
|
3464
3604
|
"@internal/backend",
|
|
3465
3605
|
"exec",
|
|
@@ -3467,48 +3607,48 @@ async function ea(e) {
|
|
|
3467
3607
|
"migrate",
|
|
3468
3608
|
"status"
|
|
3469
3609
|
], { cwd: e });
|
|
3470
|
-
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(
|
|
3610
|
+
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(ma) : !1;
|
|
3471
3611
|
}
|
|
3472
|
-
async function
|
|
3612
|
+
async function ga(e) {
|
|
3473
3613
|
let t = s.spinner();
|
|
3474
3614
|
t.start("Running database migrations...");
|
|
3475
|
-
let n = await
|
|
3615
|
+
let n = await q("pnpm", [
|
|
3476
3616
|
"--filter",
|
|
3477
3617
|
"@internal/backend",
|
|
3478
3618
|
"migration:latest"
|
|
3479
3619
|
], { cwd: e });
|
|
3480
|
-
return n.exitCode === 0 ? (t.stop(
|
|
3620
|
+
return n.exitCode === 0 ? (t.stop(B.success("Database migrations applied")), !0) : (t.error("Migrations failed"), fa(n), s.log.warn(B.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations.")), !1);
|
|
3481
3621
|
}
|
|
3482
|
-
async function
|
|
3483
|
-
if (!await
|
|
3622
|
+
async function _a(e, t, n = {}) {
|
|
3623
|
+
if (!await da(e, t, await la())) return !1;
|
|
3484
3624
|
let r = s.spinner();
|
|
3485
|
-
return r.start("Waiting for Postgres to be ready..."), await
|
|
3625
|
+
return r.start("Waiting for Postgres to be ready..."), await pa(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3) ? (r.stop(B.success("Postgres is ready")), !0) : (r.error("Postgres health check timed out"), s.log.warn(B.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest")), !1);
|
|
3486
3626
|
}
|
|
3487
|
-
async function
|
|
3488
|
-
if (!await
|
|
3627
|
+
async function va(e, t, n = {}) {
|
|
3628
|
+
if (!await _a(e, t, n)) return;
|
|
3489
3629
|
let r = t ? !0 : await s.confirm({
|
|
3490
|
-
message: `Run database migrations with ${
|
|
3630
|
+
message: `Run database migrations with ${B.command("prisma migrate deploy")}?`,
|
|
3491
3631
|
initialValue: !0
|
|
3492
3632
|
});
|
|
3493
|
-
if (s.isCancel(r) &&
|
|
3494
|
-
s.log.info(
|
|
3633
|
+
if (s.isCancel(r) && Z(), !r) {
|
|
3634
|
+
s.log.info(B.muted("Skipping database migrations."));
|
|
3495
3635
|
return;
|
|
3496
3636
|
}
|
|
3497
|
-
await
|
|
3637
|
+
await ga(e);
|
|
3498
3638
|
}
|
|
3499
|
-
async function
|
|
3500
|
-
if (!await
|
|
3501
|
-
s.log.warn(`${
|
|
3639
|
+
async function ya(e, t, n = {}) {
|
|
3640
|
+
if (!await ua(e)) {
|
|
3641
|
+
s.log.warn(`${B.path(".env")} not found in ${B.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3502
3642
|
return;
|
|
3503
3643
|
}
|
|
3504
|
-
await
|
|
3644
|
+
await va(e, t, n);
|
|
3505
3645
|
}
|
|
3506
|
-
async function
|
|
3507
|
-
return await
|
|
3646
|
+
async function ba(e, t, n = {}) {
|
|
3647
|
+
return await ua(e) ? _a(e, t, n) : (s.log.warn(`${B.path(".env")} not found in ${B.path("apps/backend")}. Skipping Docker - configure it first.`), !1);
|
|
3508
3648
|
}
|
|
3509
3649
|
//#endregion
|
|
3510
3650
|
//#region src/core/resolve.ts
|
|
3511
|
-
function
|
|
3651
|
+
function xa(e) {
|
|
3512
3652
|
let t = /* @__PURE__ */ new Map();
|
|
3513
3653
|
for (let n of e) t.set(n.name, {
|
|
3514
3654
|
name: n.name,
|
|
@@ -3516,7 +3656,7 @@ function oa(e) {
|
|
|
3516
3656
|
});
|
|
3517
3657
|
return t;
|
|
3518
3658
|
}
|
|
3519
|
-
function
|
|
3659
|
+
function Sa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3520
3660
|
let r = /* @__PURE__ */ new Set();
|
|
3521
3661
|
function i(e) {
|
|
3522
3662
|
if (n.has(e)) return [];
|
|
@@ -3530,10 +3670,10 @@ function sa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3530
3670
|
}
|
|
3531
3671
|
return i(e);
|
|
3532
3672
|
}
|
|
3533
|
-
function
|
|
3673
|
+
function Ca(e, t, n = []) {
|
|
3534
3674
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3535
3675
|
for (let n of e) {
|
|
3536
|
-
let e =
|
|
3676
|
+
let e = Sa(n, t, new Set(i));
|
|
3537
3677
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3538
3678
|
}
|
|
3539
3679
|
return {
|
|
@@ -3541,7 +3681,7 @@ function ca(e, t, n = []) {
|
|
|
3541
3681
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3542
3682
|
};
|
|
3543
3683
|
}
|
|
3544
|
-
function
|
|
3684
|
+
function wa(e) {
|
|
3545
3685
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3546
3686
|
for (let e of t) {
|
|
3547
3687
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3554,7 +3694,7 @@ function la(e) {
|
|
|
3554
3694
|
}
|
|
3555
3695
|
//#endregion
|
|
3556
3696
|
//#region src/core/variants.ts
|
|
3557
|
-
function
|
|
3697
|
+
function Ta(e, t = {}) {
|
|
3558
3698
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3559
3699
|
for (let i of e) {
|
|
3560
3700
|
let e = t[i.family] ?? i.default;
|
|
@@ -3566,14 +3706,14 @@ function ua(e, t = {}) {
|
|
|
3566
3706
|
familyOf: r
|
|
3567
3707
|
};
|
|
3568
3708
|
}
|
|
3569
|
-
function
|
|
3709
|
+
function Ea(e, t, n) {
|
|
3570
3710
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3571
3711
|
}
|
|
3572
|
-
function
|
|
3712
|
+
function Da(e, t) {
|
|
3573
3713
|
let n = t.familyOf.get(e);
|
|
3574
3714
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3575
3715
|
}
|
|
3576
|
-
function
|
|
3716
|
+
function Oa(e, t) {
|
|
3577
3717
|
let n = /* @__PURE__ */ new Map();
|
|
3578
3718
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3579
3719
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3589,65 +3729,65 @@ function pa(e, t) {
|
|
|
3589
3729
|
familyOf: n
|
|
3590
3730
|
};
|
|
3591
3731
|
}
|
|
3592
|
-
function
|
|
3732
|
+
function ka(e, t) {
|
|
3593
3733
|
return e.map((e) => ({
|
|
3594
3734
|
...e,
|
|
3595
|
-
dependencies: e.dependencies.map((e) =>
|
|
3735
|
+
dependencies: e.dependencies.map((e) => Da(e, t))
|
|
3596
3736
|
}));
|
|
3597
3737
|
}
|
|
3598
3738
|
//#endregion
|
|
3599
3739
|
//#region src/ui/banner.ts
|
|
3600
|
-
var
|
|
3740
|
+
var Aa = [
|
|
3601
3741
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3602
3742
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3603
3743
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3604
3744
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3605
3745
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3606
3746
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3607
|
-
],
|
|
3747
|
+
], ja = [
|
|
3608
3748
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3609
3749
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3610
3750
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3611
3751
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3612
3752
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3613
3753
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3614
|
-
],
|
|
3754
|
+
], Ma = [
|
|
3615
3755
|
253,
|
|
3616
3756
|
176,
|
|
3617
3757
|
21
|
|
3618
|
-
],
|
|
3758
|
+
], Na = [
|
|
3619
3759
|
245,
|
|
3620
3760
|
76,
|
|
3621
3761
|
2
|
|
3622
|
-
],
|
|
3762
|
+
], Pa = 5, Fa = [
|
|
3623
3763
|
17,
|
|
3624
3764
|
103,
|
|
3625
3765
|
248
|
|
3626
|
-
],
|
|
3766
|
+
], Ia = [
|
|
3627
3767
|
42,
|
|
3628
3768
|
160,
|
|
3629
3769
|
250
|
|
3630
|
-
],
|
|
3631
|
-
function
|
|
3770
|
+
], La = .2;
|
|
3771
|
+
function Ra() {
|
|
3632
3772
|
console.log();
|
|
3633
|
-
for (let e of
|
|
3634
|
-
start:
|
|
3635
|
-
end:
|
|
3636
|
-
angle:
|
|
3773
|
+
for (let e of ye(Aa, {
|
|
3774
|
+
start: Ma,
|
|
3775
|
+
end: Na,
|
|
3776
|
+
angle: Pa
|
|
3637
3777
|
})) console.log(b.bold(e));
|
|
3638
|
-
for (let e of
|
|
3639
|
-
start:
|
|
3640
|
-
end:
|
|
3641
|
-
angle:
|
|
3778
|
+
for (let e of ye(ja, {
|
|
3779
|
+
start: Fa,
|
|
3780
|
+
end: Ia,
|
|
3781
|
+
angle: La
|
|
3642
3782
|
})) console.log(b.bold(e));
|
|
3643
|
-
console.log(), console.log(` ${
|
|
3783
|
+
console.log(), console.log(` ${V.spark} ${b.dim("v" + A)} ${b.dim("·")} ${_e("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3644
3784
|
}
|
|
3645
|
-
function
|
|
3646
|
-
console.log(), console.log(` ${
|
|
3785
|
+
function za() {
|
|
3786
|
+
console.log(), console.log(` ${V.bolt} ${me.orange("Hype")}${me.skyBlue("Stack")} ${b.dim("v" + A)}`), console.log();
|
|
3647
3787
|
}
|
|
3648
3788
|
//#endregion
|
|
3649
3789
|
//#region src/ui/pack-multiselect.ts
|
|
3650
|
-
var
|
|
3790
|
+
var Ba = class extends O {
|
|
3651
3791
|
options;
|
|
3652
3792
|
cursor = 0;
|
|
3653
3793
|
selected;
|
|
@@ -3751,44 +3891,44 @@ var Ta = class extends O {
|
|
|
3751
3891
|
}
|
|
3752
3892
|
}
|
|
3753
3893
|
};
|
|
3754
|
-
function
|
|
3755
|
-
return new
|
|
3894
|
+
function Va(e) {
|
|
3895
|
+
return new Ba(e).prompt();
|
|
3756
3896
|
}
|
|
3757
3897
|
//#endregion
|
|
3758
3898
|
//#region src/utils/naming.ts
|
|
3759
|
-
function
|
|
3899
|
+
function Ha(e) {
|
|
3760
3900
|
return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3761
3901
|
}
|
|
3762
|
-
function
|
|
3902
|
+
function Ua(e) {
|
|
3763
3903
|
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3764
3904
|
}
|
|
3765
3905
|
//#endregion
|
|
3766
3906
|
//#region src/utils/validate.ts
|
|
3767
|
-
function
|
|
3907
|
+
function Wa(e) {
|
|
3768
3908
|
if (!e.trim()) return "Project name cannot be empty";
|
|
3769
3909
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
3770
|
-
let t =
|
|
3910
|
+
let t = Ha(e);
|
|
3771
3911
|
if (!ne.test(t)) return "Project name must contain at least one letter or number";
|
|
3772
3912
|
}
|
|
3773
3913
|
//#endregion
|
|
3774
3914
|
//#region src/core/apply-mode.ts
|
|
3775
|
-
var
|
|
3776
|
-
function
|
|
3777
|
-
return e.replace(
|
|
3915
|
+
var Ga = "src/hooks/use-theme.ts", Ka = /(\bexport\s+const\s+defaultTheme\s*=\s*)(["'])(?:light|dark)\2/;
|
|
3916
|
+
function qa(e, t) {
|
|
3917
|
+
return e.replace(Ka, (e, n, r) => `${n}${r}${t}${r}`);
|
|
3778
3918
|
}
|
|
3779
|
-
async function
|
|
3780
|
-
let n = T.resolve(e,
|
|
3919
|
+
async function Ja(e, t) {
|
|
3920
|
+
let n = T.resolve(e, Ga), r;
|
|
3781
3921
|
try {
|
|
3782
3922
|
r = await y.readFile(n, "utf-8");
|
|
3783
3923
|
} catch {
|
|
3784
3924
|
return !1;
|
|
3785
3925
|
}
|
|
3786
|
-
let i =
|
|
3926
|
+
let i = qa(r, t);
|
|
3787
3927
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3788
3928
|
}
|
|
3789
3929
|
//#endregion
|
|
3790
3930
|
//#region src/core/apply-theme.ts
|
|
3791
|
-
function
|
|
3931
|
+
function Ya(e, t) {
|
|
3792
3932
|
let n = e.indexOf(t);
|
|
3793
3933
|
if (n === -1) return null;
|
|
3794
3934
|
let r = e.indexOf("{", n);
|
|
@@ -3803,46 +3943,46 @@ function Pa(e, t) {
|
|
|
3803
3943
|
bodyEnd: a - 1
|
|
3804
3944
|
} : null;
|
|
3805
3945
|
}
|
|
3806
|
-
function
|
|
3946
|
+
function Xa(e, t) {
|
|
3807
3947
|
let n = e;
|
|
3808
3948
|
for (let [e, r] of Object.entries(t)) {
|
|
3809
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3949
|
+
let t = RegExp(`(^[ \\t]*--${Za(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3810
3950
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3811
3951
|
}
|
|
3812
3952
|
return n;
|
|
3813
3953
|
}
|
|
3814
|
-
function
|
|
3954
|
+
function Za(e) {
|
|
3815
3955
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3816
3956
|
}
|
|
3817
|
-
function
|
|
3818
|
-
let n =
|
|
3957
|
+
function Qa(e, t) {
|
|
3958
|
+
let n = Ya(e, ":root"), r = Ya(e, ".dark"), i = e;
|
|
3819
3959
|
if (n) {
|
|
3820
3960
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3821
|
-
i = e +
|
|
3961
|
+
i = e + Xa(r, t.light) + a;
|
|
3822
3962
|
}
|
|
3823
3963
|
if (r) {
|
|
3824
|
-
let e =
|
|
3964
|
+
let e = Ya(i, ".dark");
|
|
3825
3965
|
if (e) {
|
|
3826
3966
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3827
|
-
i = n +
|
|
3967
|
+
i = n + Xa(r, t.dark) + a;
|
|
3828
3968
|
}
|
|
3829
3969
|
}
|
|
3830
3970
|
return i;
|
|
3831
3971
|
}
|
|
3832
|
-
var
|
|
3833
|
-
async function
|
|
3834
|
-
let n = T.resolve(e,
|
|
3972
|
+
var $a = "assets/styles.css";
|
|
3973
|
+
async function eo(e, t) {
|
|
3974
|
+
let n = T.resolve(e, $a), r;
|
|
3835
3975
|
try {
|
|
3836
3976
|
r = await y.readFile(n, "utf-8");
|
|
3837
3977
|
} catch {
|
|
3838
3978
|
return !1;
|
|
3839
3979
|
}
|
|
3840
|
-
let i =
|
|
3980
|
+
let i = Qa(r, t);
|
|
3841
3981
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3842
3982
|
}
|
|
3843
3983
|
//#endregion
|
|
3844
3984
|
//#region src/core/clone.ts
|
|
3845
|
-
async function
|
|
3985
|
+
async function to(e) {
|
|
3846
3986
|
let t = await ee(j, {
|
|
3847
3987
|
dir: e,
|
|
3848
3988
|
force: !0
|
|
@@ -3854,7 +3994,7 @@ async function Ba(e) {
|
|
|
3854
3994
|
}
|
|
3855
3995
|
//#endregion
|
|
3856
3996
|
//#region src/core/editor-config.ts
|
|
3857
|
-
function
|
|
3997
|
+
function no(e) {
|
|
3858
3998
|
let t = {
|
|
3859
3999
|
globs: [],
|
|
3860
4000
|
alwaysApply: !1
|
|
@@ -3889,10 +4029,10 @@ function Va(e) {
|
|
|
3889
4029
|
content: i
|
|
3890
4030
|
};
|
|
3891
4031
|
}
|
|
3892
|
-
function
|
|
4032
|
+
function ro(e) {
|
|
3893
4033
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
3894
4034
|
}
|
|
3895
|
-
function
|
|
4035
|
+
function io(e) {
|
|
3896
4036
|
let t;
|
|
3897
4037
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
3898
4038
|
let n = [`trigger: ${t}`];
|
|
@@ -3902,30 +4042,30 @@ function Ua(e) {
|
|
|
3902
4042
|
}
|
|
3903
4043
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
3904
4044
|
}
|
|
3905
|
-
function
|
|
4045
|
+
function ao(e) {
|
|
3906
4046
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
3907
4047
|
}
|
|
3908
|
-
var
|
|
4048
|
+
var oo = {
|
|
3909
4049
|
claude: {
|
|
3910
4050
|
rulesDir: ".claude/rules",
|
|
3911
4051
|
extension: ".md",
|
|
3912
|
-
convert:
|
|
4052
|
+
convert: ro
|
|
3913
4053
|
},
|
|
3914
4054
|
windsurf: {
|
|
3915
4055
|
rulesDir: ".windsurf/rules",
|
|
3916
4056
|
extension: ".md",
|
|
3917
|
-
convert:
|
|
4057
|
+
convert: io
|
|
3918
4058
|
},
|
|
3919
4059
|
copilot: {
|
|
3920
4060
|
rulesDir: ".github/instructions",
|
|
3921
4061
|
extension: ".instructions.md",
|
|
3922
|
-
convert:
|
|
4062
|
+
convert: ao
|
|
3923
4063
|
}
|
|
3924
4064
|
};
|
|
3925
|
-
async function
|
|
4065
|
+
async function so(e) {
|
|
3926
4066
|
let t = T.join(e, ie), n = (await y.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
3927
4067
|
return await Promise.all(n.map(async (e) => {
|
|
3928
|
-
let n = T.join(t, e.name), { frontmatter: r, content: i } =
|
|
4068
|
+
let n = T.join(t, e.name), { frontmatter: r, content: i } = no(await y.readFile(n, "utf-8"));
|
|
3929
4069
|
return {
|
|
3930
4070
|
frontmatter: r,
|
|
3931
4071
|
content: i,
|
|
@@ -3933,9 +4073,9 @@ async function Ka(e) {
|
|
|
3933
4073
|
};
|
|
3934
4074
|
}));
|
|
3935
4075
|
}
|
|
3936
|
-
async function
|
|
4076
|
+
async function co(e, t) {
|
|
3937
4077
|
if (t === "cursor") return;
|
|
3938
|
-
let n =
|
|
4078
|
+
let n = oo[t], r = await so(e), i = T.join(e, n.rulesDir);
|
|
3939
4079
|
await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
3940
4080
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3941
4081
|
return y.writeFile(T.join(i, r), t, "utf-8");
|
|
@@ -3943,21 +4083,21 @@ async function qa(e, t) {
|
|
|
3943
4083
|
}
|
|
3944
4084
|
//#endregion
|
|
3945
4085
|
//#region src/core/env-files.ts
|
|
3946
|
-
var
|
|
4086
|
+
var lo = [
|
|
3947
4087
|
"apps",
|
|
3948
4088
|
"packages",
|
|
3949
4089
|
"libs",
|
|
3950
4090
|
"shared"
|
|
3951
4091
|
];
|
|
3952
|
-
async function
|
|
3953
|
-
let t = await
|
|
4092
|
+
async function uo(e) {
|
|
4093
|
+
let t = await fo(e);
|
|
3954
4094
|
return (await Promise.all(t.map(async (t) => {
|
|
3955
4095
|
let n = T.join(T.dirname(t), ".env");
|
|
3956
4096
|
return await J(n) ? null : (await y.copyFile(t, n), T.relative(e, n));
|
|
3957
4097
|
}))).filter((e) => e !== null).sort();
|
|
3958
4098
|
}
|
|
3959
|
-
async function
|
|
3960
|
-
let t = [T.join(e, ".env.example")], n = await Promise.all(
|
|
4099
|
+
async function fo(e) {
|
|
4100
|
+
let t = [T.join(e, ".env.example")], n = await Promise.all(lo.map(async (t) => {
|
|
3961
4101
|
let n = T.join(e, t);
|
|
3962
4102
|
return (await y.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => T.join(n, e.name, ".env.example"));
|
|
3963
4103
|
}));
|
|
@@ -3965,12 +4105,12 @@ async function Xa(e) {
|
|
|
3965
4105
|
}
|
|
3966
4106
|
//#endregion
|
|
3967
4107
|
//#region src/core/post-clone.ts
|
|
3968
|
-
var
|
|
3969
|
-
async function
|
|
4108
|
+
var Q = "@hype-stack/", po = "hype-stack";
|
|
4109
|
+
async function mo(e) {
|
|
3970
4110
|
await ur(T.join(e, ".git"));
|
|
3971
4111
|
}
|
|
3972
|
-
async function
|
|
3973
|
-
await
|
|
4112
|
+
async function ho(e) {
|
|
4113
|
+
await q("git", ["init"], { cwd: e }), await q("git", ["add", "."], { cwd: e }), await q("git", [
|
|
3974
4114
|
"-c",
|
|
3975
4115
|
"user.name=Hype Stack CLI",
|
|
3976
4116
|
"-c",
|
|
@@ -3980,22 +4120,22 @@ async function $a(e) {
|
|
|
3980
4120
|
"Initial commit from Hype Stack CLI"
|
|
3981
4121
|
], { cwd: e });
|
|
3982
4122
|
}
|
|
3983
|
-
async function
|
|
3984
|
-
let n = `@${t}/`, r = await
|
|
4123
|
+
async function go(e, t) {
|
|
4124
|
+
let n = `@${t}/`, r = await wo(e);
|
|
3985
4125
|
for (let e of r) {
|
|
3986
4126
|
let t = await sr(e);
|
|
3987
4127
|
if (!t) continue;
|
|
3988
4128
|
let r = !1;
|
|
3989
|
-
t.name?.startsWith(
|
|
4129
|
+
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0), xo(t.dependencies, n) && (r = !0), xo(t.devDependencies, n) && (r = !0), t.nx && So(t.nx, n) && (r = !0);
|
|
3990
4130
|
let i = await y.readFile(e, "utf-8");
|
|
3991
|
-
if (i.includes(
|
|
3992
|
-
let t = i.replaceAll(
|
|
4131
|
+
if (i.includes(Q)) {
|
|
4132
|
+
let t = i.replaceAll(Q, n);
|
|
3993
4133
|
await y.writeFile(e, t, "utf-8");
|
|
3994
4134
|
} else r && await cr(e, t);
|
|
3995
4135
|
}
|
|
3996
|
-
await
|
|
4136
|
+
await zi(e, t), await yo(e, t), await Co(e, t);
|
|
3997
4137
|
}
|
|
3998
|
-
var
|
|
4138
|
+
var _o = new Set([
|
|
3999
4139
|
".git",
|
|
4000
4140
|
"node_modules",
|
|
4001
4141
|
"dist",
|
|
@@ -4003,10 +4143,10 @@ var to = new Set([
|
|
|
4003
4143
|
".nx",
|
|
4004
4144
|
".next",
|
|
4005
4145
|
"coverage"
|
|
4006
|
-
]),
|
|
4007
|
-
async function
|
|
4008
|
-
if (t ===
|
|
4009
|
-
let n = await
|
|
4146
|
+
]), vo = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
|
|
4147
|
+
async function yo(e, t) {
|
|
4148
|
+
if (t === po) return;
|
|
4149
|
+
let n = await bo(e);
|
|
4010
4150
|
await Promise.all(n.map(async (e) => {
|
|
4011
4151
|
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
4012
4152
|
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
@@ -4014,37 +4154,37 @@ async function ro(e, t) {
|
|
|
4014
4154
|
await y.writeFile(e, r, "utf-8");
|
|
4015
4155
|
}));
|
|
4016
4156
|
}
|
|
4017
|
-
async function
|
|
4157
|
+
async function bo(e) {
|
|
4018
4158
|
let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
4019
4159
|
return (await Promise.all(t.map(async (t) => {
|
|
4020
4160
|
let n = T.join(e, t.name);
|
|
4021
|
-
return t.isDirectory() ?
|
|
4161
|
+
return t.isDirectory() ? _o.has(t.name) ? [] : bo(n) : t.isFile() && vo.test(t.name) ? [n] : [];
|
|
4022
4162
|
}))).flat();
|
|
4023
4163
|
}
|
|
4024
|
-
function
|
|
4164
|
+
function xo(e, t) {
|
|
4025
4165
|
if (!e) return !1;
|
|
4026
4166
|
let n = !1;
|
|
4027
|
-
for (let r of Object.keys(e)) if (r.startsWith(
|
|
4028
|
-
let i = r.replace(
|
|
4167
|
+
for (let r of Object.keys(e)) if (r.startsWith(Q)) {
|
|
4168
|
+
let i = r.replace(Q, t);
|
|
4029
4169
|
e[i] = e[r], delete e[r], n = !0;
|
|
4030
4170
|
}
|
|
4031
4171
|
return n;
|
|
4032
4172
|
}
|
|
4033
|
-
function
|
|
4173
|
+
function So(e, t) {
|
|
4034
4174
|
if (!e) return !1;
|
|
4035
4175
|
let n = !1;
|
|
4036
|
-
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(
|
|
4037
|
-
for (let r of Object.values(e.targets)) if (r.buildTarget?.includes(
|
|
4176
|
+
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Q) ? (n = !0, e.replace(Q, t)) : e), e.targets) {
|
|
4177
|
+
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);
|
|
4038
4178
|
}
|
|
4039
4179
|
return n;
|
|
4040
4180
|
}
|
|
4041
|
-
async function
|
|
4181
|
+
async function Co(e, t) {
|
|
4042
4182
|
let n = T.join(e, "packages/enums/src/app/index.ts"), r = await y.readFile(n, "utf-8").catch(() => null);
|
|
4043
4183
|
if (!r) return;
|
|
4044
|
-
let i =
|
|
4184
|
+
let i = Ua(t), a = r.replaceAll(`id: "${po}"`, `id: "${t}"`).replaceAll(`name: "${po}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
|
|
4045
4185
|
await y.writeFile(n, a, "utf-8");
|
|
4046
4186
|
}
|
|
4047
|
-
async function
|
|
4187
|
+
async function wo(e) {
|
|
4048
4188
|
let t = [], n = T.join(e, "package.json");
|
|
4049
4189
|
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
4050
4190
|
for (let n of [
|
|
@@ -4064,7 +4204,7 @@ async function co(e) {
|
|
|
4064
4204
|
}
|
|
4065
4205
|
//#endregion
|
|
4066
4206
|
//#region src/core/readme.ts
|
|
4067
|
-
var
|
|
4207
|
+
var To = {
|
|
4068
4208
|
cursor: {
|
|
4069
4209
|
label: "Cursor",
|
|
4070
4210
|
rulesDir: ".cursor/rules"
|
|
@@ -4081,21 +4221,21 @@ var lo = {
|
|
|
4081
4221
|
label: "GitHub Copilot",
|
|
4082
4222
|
rulesDir: ".github/instructions"
|
|
4083
4223
|
}
|
|
4084
|
-
},
|
|
4224
|
+
}, Eo = {
|
|
4085
4225
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
4086
4226
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
4087
|
-
},
|
|
4227
|
+
}, Do = {
|
|
4088
4228
|
enums: "Shared enums and app config used across apps",
|
|
4089
4229
|
cli: "Project tooling and code generators"
|
|
4090
4230
|
};
|
|
4091
|
-
function
|
|
4231
|
+
function Oo(e, t) {
|
|
4092
4232
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
4093
4233
|
let r = t[e];
|
|
4094
4234
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4095
4235
|
});
|
|
4096
4236
|
}
|
|
4097
|
-
function
|
|
4098
|
-
let { projectName: t, editor: n, workspace: r } = e, i =
|
|
4237
|
+
function ko(e) {
|
|
4238
|
+
let { projectName: t, editor: n, workspace: r } = e, i = Ua(t), a = To[n], o = !!r.apps.backend, s = Oo(r.apps, Eo), c = Oo(r.packages, Do), l = [];
|
|
4099
4239
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
4100
4240
|
let u = [];
|
|
4101
4241
|
u.push(`# ${i}`), u.push([
|
|
@@ -4198,19 +4338,19 @@ function mo(e) {
|
|
|
4198
4338
|
"stays useful."
|
|
4199
4339
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4200
4340
|
}
|
|
4201
|
-
async function
|
|
4341
|
+
async function Ao(e, t) {
|
|
4202
4342
|
let n = T.join(e, "README.md");
|
|
4203
|
-
await y.writeFile(n,
|
|
4343
|
+
await y.writeFile(n, ko(t), "utf-8");
|
|
4204
4344
|
}
|
|
4205
4345
|
//#endregion
|
|
4206
4346
|
//#region src/core/tracking.ts
|
|
4207
|
-
async function
|
|
4347
|
+
async function jo(e) {
|
|
4208
4348
|
try {
|
|
4209
4349
|
let t = {
|
|
4210
|
-
"X-Device-Id":
|
|
4211
|
-
"X-Client-Info":
|
|
4212
|
-
}, n = await
|
|
4213
|
-
n?.token && (t.Authorization = `Bearer ${n.token}`), await
|
|
4350
|
+
"X-Device-Id": Xn(),
|
|
4351
|
+
"X-Client-Info": Zn()
|
|
4352
|
+
}, n = await Kn(L()).catch(() => null);
|
|
4353
|
+
n?.token && (t.Authorization = `Bearer ${n.token}`), await K.createRequest()({
|
|
4214
4354
|
endpoint: "/cli/track",
|
|
4215
4355
|
method: "POST"
|
|
4216
4356
|
}).setPayload({ event: e }).setHeaders(t).send();
|
|
@@ -4218,7 +4358,7 @@ async function go(e) {
|
|
|
4218
4358
|
}
|
|
4219
4359
|
//#endregion
|
|
4220
4360
|
//#region src/core/npm-deps.ts
|
|
4221
|
-
function
|
|
4361
|
+
function Mo(e, t) {
|
|
4222
4362
|
let n = [], r = [];
|
|
4223
4363
|
if (!e) return {
|
|
4224
4364
|
errors: n,
|
|
@@ -4249,7 +4389,7 @@ function _o(e, t) {
|
|
|
4249
4389
|
operations: r
|
|
4250
4390
|
};
|
|
4251
4391
|
}
|
|
4252
|
-
function
|
|
4392
|
+
function No(e) {
|
|
4253
4393
|
let t = {};
|
|
4254
4394
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4255
4395
|
...t[e],
|
|
@@ -4257,7 +4397,7 @@ function vo(e) {
|
|
|
4257
4397
|
};
|
|
4258
4398
|
return t;
|
|
4259
4399
|
}
|
|
4260
|
-
async function
|
|
4400
|
+
async function Po(e, t, n = q) {
|
|
4261
4401
|
let r = [];
|
|
4262
4402
|
for (let i of e) {
|
|
4263
4403
|
let e = T.join(t, i.relativeDir);
|
|
@@ -4290,28 +4430,28 @@ async function yo(e, t, n = K) {
|
|
|
4290
4430
|
}
|
|
4291
4431
|
//#endregion
|
|
4292
4432
|
//#region src/commands/install-helpers.ts
|
|
4293
|
-
function
|
|
4433
|
+
function $(e) {
|
|
4294
4434
|
return e instanceof Error ? e.message : String(e);
|
|
4295
4435
|
}
|
|
4296
|
-
async function
|
|
4436
|
+
async function Fo(e, t, n) {
|
|
4297
4437
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4298
|
-
return r.length === 0 ? {} :
|
|
4438
|
+
return r.length === 0 ? {} : Vr(r, n).catch(() => ({}));
|
|
4299
4439
|
}
|
|
4300
|
-
function
|
|
4301
|
-
return e === "free" ?
|
|
4440
|
+
function Io(e, t) {
|
|
4441
|
+
return e === "free" ? B.success("free") : e === "owned" ? B.accent("owned") : `${B.highlight(`$${t}`)} ${B.muted("locked")}`;
|
|
4302
4442
|
}
|
|
4303
|
-
async function
|
|
4443
|
+
async function Lo(e, t, n) {
|
|
4304
4444
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4305
|
-
i.length > 0 && s.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await
|
|
4445
|
+
i.length > 0 && s.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await rr(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4306
4446
|
name: e.name,
|
|
4307
4447
|
displayName: e.displayName,
|
|
4308
4448
|
price: e.price
|
|
4309
4449
|
})));
|
|
4310
4450
|
}
|
|
4311
|
-
function
|
|
4451
|
+
function Ro(e, t) {
|
|
4312
4452
|
let n = e.map((e, n) => {
|
|
4313
4453
|
let r = t.get(e), i = r ? r.displayName : e;
|
|
4314
|
-
return ` ${
|
|
4454
|
+
return ` ${B.muted(`${n + 1}.`)} ${B.brand(i)}`;
|
|
4315
4455
|
});
|
|
4316
4456
|
s.note([
|
|
4317
4457
|
"These packs will be installed, in order:",
|
|
@@ -4319,10 +4459,10 @@ function Co(e, t) {
|
|
|
4319
4459
|
...n
|
|
4320
4460
|
].join("\n"), "Install Plan");
|
|
4321
4461
|
}
|
|
4322
|
-
async function
|
|
4462
|
+
async function zo(e, t) {
|
|
4323
4463
|
let n = [];
|
|
4324
4464
|
for (let r of e) {
|
|
4325
|
-
let e = await
|
|
4465
|
+
let e = await Fr(r), i = await Ir(r, t);
|
|
4326
4466
|
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'npx @hype-stack/cli login' or check your license.`);
|
|
4327
4467
|
n.push({
|
|
4328
4468
|
manifest: e,
|
|
@@ -4331,32 +4471,32 @@ async function wo(e, t) {
|
|
|
4331
4471
|
}
|
|
4332
4472
|
return n;
|
|
4333
4473
|
}
|
|
4334
|
-
async function
|
|
4335
|
-
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a =
|
|
4474
|
+
async function Bo(e) {
|
|
4475
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = Mo(No(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4336
4476
|
if (a.errors.length > 0) {
|
|
4337
4477
|
for (let e of a.errors) s.log.error(e);
|
|
4338
4478
|
return;
|
|
4339
4479
|
}
|
|
4340
4480
|
if (a.operations.length === 0) return;
|
|
4341
4481
|
i.start("Installing npm dependencies...");
|
|
4342
|
-
let o = await
|
|
4482
|
+
let o = await Po(a.operations, r);
|
|
4343
4483
|
if (i.stop(o.ok ? "npm dependencies installed" : "npm dependency installation failed"), !o.ok) for (let e of o.errors) s.log.error(e);
|
|
4344
4484
|
}
|
|
4345
|
-
function
|
|
4346
|
-
s.note([` ${
|
|
4485
|
+
function Vo() {
|
|
4486
|
+
s.note([` ${B.command("1. npx @hype-stack/cli onboard")} ${B.muted("(set up env vars + run migrations)")}`, ` ${B.command("2. pnpm dev")} ${B.muted("(start frontend + backend)")}`].join("\n"), "Next steps");
|
|
4347
4487
|
}
|
|
4348
|
-
function
|
|
4488
|
+
function Ho(e) {
|
|
4349
4489
|
if (e.length === 0) return;
|
|
4350
4490
|
let t = e.map((e) => {
|
|
4351
4491
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
4352
|
-
return ` ${
|
|
4492
|
+
return ` ${B.muted("•")} ${B.path(t)}`;
|
|
4353
4493
|
});
|
|
4354
4494
|
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4355
4495
|
}
|
|
4356
|
-
async function
|
|
4496
|
+
async function Uo(e) {
|
|
4357
4497
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
|
|
4358
4498
|
if (i) return c;
|
|
4359
|
-
let l = await
|
|
4499
|
+
let l = await Ji({
|
|
4360
4500
|
packs: t,
|
|
4361
4501
|
config: n,
|
|
4362
4502
|
projectRoot: r,
|
|
@@ -4364,17 +4504,17 @@ async function Oo(e) {
|
|
|
4364
4504
|
});
|
|
4365
4505
|
if (l.length === 0) return c;
|
|
4366
4506
|
if (a) {
|
|
4367
|
-
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${
|
|
4507
|
+
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${B.command("--force")} to overwrite.`);
|
|
4368
4508
|
let e = l.map((e) => {
|
|
4369
4509
|
let t = T.relative(r, e.targetPath) || e.target;
|
|
4370
|
-
return ` ${
|
|
4510
|
+
return ` ${B.muted("•")} ${B.path(t)} ${B.muted(`(${e.packName})`)}`;
|
|
4371
4511
|
});
|
|
4372
4512
|
return s.note(e.join("\n"), "Kept existing files"), c;
|
|
4373
4513
|
}
|
|
4374
4514
|
s.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4375
4515
|
for (let e of l) {
|
|
4376
4516
|
let t = T.relative(r, e.targetPath) || e.target, n = await s.confirm({
|
|
4377
|
-
message: `Overwrite ${
|
|
4517
|
+
message: `Overwrite ${B.path(t)}? ${B.muted(`(${e.packName})`)}`,
|
|
4378
4518
|
initialValue: !1
|
|
4379
4519
|
});
|
|
4380
4520
|
s.isCancel(n) && (s.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
|
|
@@ -4383,7 +4523,7 @@ async function Oo(e) {
|
|
|
4383
4523
|
}
|
|
4384
4524
|
//#endregion
|
|
4385
4525
|
//#region src/ui/swatch.ts
|
|
4386
|
-
function
|
|
4526
|
+
function Wo(e) {
|
|
4387
4527
|
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4388
4528
|
if (!t) return null;
|
|
4389
4529
|
let n = t[1].trim().split(/\s+/);
|
|
@@ -4402,58 +4542,58 @@ function ko(e) {
|
|
|
4402
4542
|
h: a
|
|
4403
4543
|
};
|
|
4404
4544
|
}
|
|
4405
|
-
function
|
|
4545
|
+
function Go(e) {
|
|
4406
4546
|
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4407
4547
|
}
|
|
4408
|
-
function
|
|
4548
|
+
function Ko(e) {
|
|
4409
4549
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4410
4550
|
}
|
|
4411
|
-
function
|
|
4551
|
+
function qo({ l: e, c: t, h: n }) {
|
|
4412
4552
|
let r = n * Math.PI / 180, i = t * Math.cos(r), a = t * Math.sin(r), o = e + .3963377774 * i + .2158037573 * a, s = e - .1055613458 * i - .0638541728 * a, c = e - .0894841775 * i - 1.291485548 * a, l = o ** 3, u = s ** 3, d = c ** 3, f = 4.0767416621 * l - 3.3077115913 * u + .2309699292 * d, p = -1.2684380042 * l + 2.6097570613 * u - .3413193965 * d, m = -.0041960863 * l - .7034186147 * u + 1.7076146937 * d;
|
|
4413
4553
|
return [
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4554
|
+
Go(Ko(f) * 255),
|
|
4555
|
+
Go(Ko(p) * 255),
|
|
4556
|
+
Go(Ko(m) * 255)
|
|
4417
4557
|
];
|
|
4418
4558
|
}
|
|
4419
|
-
var
|
|
4420
|
-
function
|
|
4559
|
+
var Jo = "\x1B[49m";
|
|
4560
|
+
function Yo(e, t) {
|
|
4421
4561
|
let n = e[t];
|
|
4422
4562
|
if (!n) return b.dim(" ");
|
|
4423
|
-
let r =
|
|
4563
|
+
let r = Wo(n);
|
|
4424
4564
|
if (!r) return b.dim(" ");
|
|
4425
|
-
let [i, a, o] =
|
|
4426
|
-
return `\x1b[48;2;${i};${a};${o}m ${
|
|
4565
|
+
let [i, a, o] = qo(r);
|
|
4566
|
+
return `\x1b[48;2;${i};${a};${o}m ${Jo}`;
|
|
4427
4567
|
}
|
|
4428
|
-
var
|
|
4568
|
+
var Xo = [
|
|
4429
4569
|
"primary",
|
|
4430
4570
|
"secondary",
|
|
4431
4571
|
"accent"
|
|
4432
4572
|
];
|
|
4433
|
-
function
|
|
4434
|
-
return
|
|
4573
|
+
function Zo(e) {
|
|
4574
|
+
return Xo.map((t) => Yo(e, t)).join("");
|
|
4435
4575
|
}
|
|
4436
|
-
function
|
|
4437
|
-
return `${
|
|
4576
|
+
function Qo(e) {
|
|
4577
|
+
return `${Zo(e.light)} ${b.dim("·")} ${Zo(e.dark)}`;
|
|
4438
4578
|
}
|
|
4439
4579
|
//#endregion
|
|
4440
4580
|
//#region src/commands/create.ts
|
|
4441
|
-
async function
|
|
4442
|
-
e.skipBanner ||
|
|
4581
|
+
async function $o(e) {
|
|
4582
|
+
e.skipBanner || Ra(), s.intro(B.brandBold("Create a new Hype Stack project"));
|
|
4443
4583
|
let o = e.yes === !0, c, l;
|
|
4444
4584
|
if (o && e.name) {
|
|
4445
|
-
let t =
|
|
4446
|
-
t && (s.log.error(t),
|
|
4585
|
+
let t = Wa(e.name);
|
|
4586
|
+
t && (s.log.error(t), Z()), l = e.name, c = Ha(e.name);
|
|
4447
4587
|
} else {
|
|
4448
4588
|
let t = await s.text({
|
|
4449
4589
|
message: "What is your project named?",
|
|
4450
4590
|
placeholder: "my-app",
|
|
4451
4591
|
initialValue: e.name ?? "",
|
|
4452
|
-
validate: (e) =>
|
|
4592
|
+
validate: (e) => Wa(e ?? "")
|
|
4453
4593
|
});
|
|
4454
|
-
s.isCancel(t) &&
|
|
4594
|
+
s.isCancel(t) && Z(), l = t, c = Ha(l);
|
|
4455
4595
|
}
|
|
4456
|
-
l.trim() !== c && s.log.info(
|
|
4596
|
+
l.trim() !== c && s.log.info(B.muted(`Using "${B.highlight(c)}" as the project name`));
|
|
4457
4597
|
let u;
|
|
4458
4598
|
if (e.directory !== void 0) u = e.directory;
|
|
4459
4599
|
else {
|
|
@@ -4466,12 +4606,12 @@ async function Ro(e) {
|
|
|
4466
4606
|
placeholder: ".",
|
|
4467
4607
|
initialValue: "."
|
|
4468
4608
|
});
|
|
4469
|
-
s.isCancel(e) &&
|
|
4609
|
+
s.isCancel(e) && Z(), t = e;
|
|
4470
4610
|
}
|
|
4471
4611
|
u = dr(t, c);
|
|
4472
4612
|
}
|
|
4473
4613
|
let d = T.resolve(u);
|
|
4474
|
-
o || s.note(
|
|
4614
|
+
o || s.note(B.path(d), "Project will be created at");
|
|
4475
4615
|
let f = e.editor && re.includes(e.editor) ? e.editor : null, p;
|
|
4476
4616
|
if (f) p = f;
|
|
4477
4617
|
else if (o) p = "cursor";
|
|
@@ -4485,7 +4625,7 @@ async function Ro(e) {
|
|
|
4485
4625
|
})),
|
|
4486
4626
|
initialValue: "cursor"
|
|
4487
4627
|
});
|
|
4488
|
-
s.isCancel(e) &&
|
|
4628
|
+
s.isCancel(e) && Z(), p = e;
|
|
4489
4629
|
}
|
|
4490
4630
|
let m = e.theme !== void 0 && a(e.theme), h = e.defaultTheme !== void 0 && a(e.defaultTheme) ? e.defaultTheme : t, g;
|
|
4491
4631
|
if (m) g = e.theme;
|
|
@@ -4495,92 +4635,92 @@ async function Ro(e) {
|
|
|
4495
4635
|
message: "Pick a color theme",
|
|
4496
4636
|
options: r.map((e) => ({
|
|
4497
4637
|
value: e.name,
|
|
4498
|
-
label: `${
|
|
4638
|
+
label: `${Qo(e)} ${e.label}`
|
|
4499
4639
|
})),
|
|
4500
4640
|
initialValue: h
|
|
4501
4641
|
});
|
|
4502
|
-
s.isCancel(e) &&
|
|
4642
|
+
s.isCancel(e) && Z(), g = e;
|
|
4503
4643
|
}
|
|
4504
4644
|
if (!o) {
|
|
4505
|
-
let e = I.find((e) => e.value === p)?.label ?? p, t = n.find((e) => e.value === g)?.label ?? g, r = await s.confirm({ message: `Create ${
|
|
4506
|
-
(s.isCancel(r) || !r) &&
|
|
4645
|
+
let e = I.find((e) => e.value === p)?.label ?? p, t = n.find((e) => e.value === g)?.label ?? g, r = await s.confirm({ message: `Create ${B.highlight(c)} in ${B.path(d)} with ${B.highlight(e)} config and the ${B.highlight(t)} theme?` });
|
|
4646
|
+
(s.isCancel(r) || !r) && Z();
|
|
4507
4647
|
}
|
|
4508
|
-
if (await
|
|
4648
|
+
if (await ar(d) && !await or(d)) {
|
|
4509
4649
|
let e = await s.confirm({
|
|
4510
|
-
message: `Directory ${
|
|
4650
|
+
message: `Directory ${B.path(d)} is not empty. Continue anyway?`,
|
|
4511
4651
|
initialValue: !1
|
|
4512
4652
|
});
|
|
4513
|
-
(s.isCancel(e) || !e) &&
|
|
4653
|
+
(s.isCancel(e) || !e) && Z();
|
|
4514
4654
|
}
|
|
4515
4655
|
let _ = s.spinner();
|
|
4516
|
-
_.start("Cloning Hype Stack template..."), await
|
|
4656
|
+
_.start("Cloning Hype Stack template..."), await to(d), _.stop(B.success("Template cloned"));
|
|
4517
4657
|
let v = s.spinner();
|
|
4518
|
-
v.start("Setting up project..."), await
|
|
4519
|
-
let y = await
|
|
4520
|
-
await
|
|
4658
|
+
v.start("Setting up project..."), await mo(d), await go(d, c), await co(d, p);
|
|
4659
|
+
let y = await jr(d), b = Nr(c, y);
|
|
4660
|
+
await Ar(d, b), await Ao(d, {
|
|
4521
4661
|
projectName: c,
|
|
4522
4662
|
editor: p,
|
|
4523
4663
|
workspace: y
|
|
4524
4664
|
});
|
|
4525
4665
|
let x = T.resolve(d, b.paths?.frontend.root ?? "apps/frontend");
|
|
4526
|
-
a(g) && (await
|
|
4666
|
+
a(g) && (await eo(x, i(g)) || s.log.warn(B.muted(`Could not find ${B.path("assets/styles.css")} to apply the ${g} theme`))), await Ja(x, e.defaultMode === "dark" || e.defaultMode === "light" ? e.defaultMode : "light") || s.log.warn(B.muted(`Could not find ${B.path("src/hooks/use-theme.ts")} to set the default color mode`)), v.stop(B.success("Project configured"));
|
|
4527
4667
|
let S = s.spinner();
|
|
4528
|
-
S.start("Installing dependencies..."), (await
|
|
4668
|
+
S.start("Installing dependencies..."), (await q("pnpm", ["install"], { cwd: d })).exitCode === 0 ? S.stop(B.success("Dependencies installed")) : (S.stop(B.warning("Dependencies installed with warnings")), s.log.warn(B.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4529
4669
|
let C = s.spinner();
|
|
4530
|
-
C.start("Initializing git repository..."), await
|
|
4670
|
+
C.start("Initializing git repository..."), await ho(d), C.stop(B.success("Git repository initialized with clean history"));
|
|
4531
4671
|
let w = s.spinner();
|
|
4532
4672
|
w.start("Creating .env files from examples...");
|
|
4533
|
-
let E = await
|
|
4673
|
+
let E = await uo(d);
|
|
4534
4674
|
if (E.length > 0) {
|
|
4535
4675
|
let e = E.length;
|
|
4536
|
-
w.stop(
|
|
4537
|
-
} else w.stop(
|
|
4538
|
-
s.log.success(`${
|
|
4539
|
-
let D = T.relative(process.cwd(), d) || ".", O = [`${
|
|
4540
|
-
E.length > 0 ? O.push(`Review your ${
|
|
4676
|
+
w.stop(B.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4677
|
+
} else w.stop(B.muted("No .env.example files to copy"));
|
|
4678
|
+
s.log.success(`${B.brandBold("Hype Stack")} project ${B.highlight(c)} is ready!`);
|
|
4679
|
+
let D = T.relative(process.cwd(), d) || ".", O = [`${B.command(`cd ${D}`)}`];
|
|
4680
|
+
E.length > 0 ? O.push(`Review your ${B.path(".env")} files and fill in any secrets`) : O.push(`Copy ${B.path(".env.example")} to ${B.path(".env")} and configure`), ca(O);
|
|
4541
4681
|
let k = e.setup === !1;
|
|
4542
|
-
if (e.deferSetup) s.log.info(
|
|
4682
|
+
if (e.deferSetup) s.log.info(B.muted("Docker and migrations will run after your packs are installed."));
|
|
4543
4683
|
else {
|
|
4544
4684
|
let e = !k && (o || await s.confirm({
|
|
4545
4685
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
4546
4686
|
initialValue: !0
|
|
4547
4687
|
}));
|
|
4548
|
-
s.isCancel(e) &&
|
|
4688
|
+
s.isCancel(e) && Z(), e ? await ya(d, o) : s.log.info(B.muted("Docker and migrations can run later via `npx @hype-stack/cli onboard`.")), Vo();
|
|
4549
4689
|
}
|
|
4550
|
-
return await
|
|
4690
|
+
return await jo("project_create"), s.outro(B.muted("Happy building!")), d;
|
|
4551
4691
|
}
|
|
4552
4692
|
//#endregion
|
|
4553
4693
|
//#region src/commands/init.ts
|
|
4554
|
-
async function
|
|
4694
|
+
async function es(e) {
|
|
4555
4695
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4556
|
-
if (n || (
|
|
4557
|
-
s.log.error(`This doesn't look like a Hype Stack project. ${
|
|
4696
|
+
if (n || (za(), s.intro(B.brandBold("Initialize Hype Stack configuration"))), !await Pr(t)) {
|
|
4697
|
+
s.log.error(`This doesn't look like a Hype Stack project. ${B.muted("Expected apps/ directory and package.json")}`), s.outro(B.muted(`Run ${B.command("npx @hype-stack/cli create")} to scaffold a new project.`));
|
|
4558
4698
|
return;
|
|
4559
4699
|
}
|
|
4560
|
-
if (await
|
|
4561
|
-
let e = await
|
|
4700
|
+
if (await kr(t)) {
|
|
4701
|
+
let e = await Or(t);
|
|
4562
4702
|
if (e && !n) {
|
|
4563
|
-
s.log.info(`Found existing ${
|
|
4703
|
+
s.log.info(`Found existing ${B.path("stack.json")} for project ${B.highlight(e.name)}`);
|
|
4564
4704
|
let t = await s.confirm({
|
|
4565
4705
|
message: "Overwrite existing configuration?",
|
|
4566
4706
|
initialValue: !1
|
|
4567
4707
|
});
|
|
4568
4708
|
if (s.isCancel(t) || !t) {
|
|
4569
|
-
s.outro(
|
|
4709
|
+
s.outro(B.muted("Keeping existing configuration."));
|
|
4570
4710
|
return;
|
|
4571
4711
|
}
|
|
4572
4712
|
}
|
|
4573
4713
|
}
|
|
4574
|
-
let r = await
|
|
4714
|
+
let r = await jr(t);
|
|
4575
4715
|
if (!n) {
|
|
4576
4716
|
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4577
4717
|
if (e.length > 0) {
|
|
4578
|
-
s.log.info(
|
|
4579
|
-
for (let [t, n] of e) s.log.message(` ${
|
|
4718
|
+
s.log.info(B.bold("Detected apps:"));
|
|
4719
|
+
for (let [t, n] of e) s.log.message(` ${V.arrow} ${B.highlight(t)} ${B.muted(`→ ${n}`)}`);
|
|
4580
4720
|
}
|
|
4581
4721
|
if (t.length > 0) {
|
|
4582
|
-
s.log.info(
|
|
4583
|
-
for (let [e, n] of t) s.log.message(` ${
|
|
4722
|
+
s.log.info(B.bold("Detected packages:"));
|
|
4723
|
+
for (let [e, n] of t) s.log.message(` ${V.arrow} ${B.highlight(e)} ${B.muted(`→ ${n}`)}`);
|
|
4584
4724
|
}
|
|
4585
4725
|
e.length === 0 && t.length === 0 && s.log.warn("No apps or packages detected in the workspace.");
|
|
4586
4726
|
}
|
|
@@ -4590,44 +4730,44 @@ async function zo(e) {
|
|
|
4590
4730
|
message: "Project name for stack.json?",
|
|
4591
4731
|
placeholder: i,
|
|
4592
4732
|
initialValue: i,
|
|
4593
|
-
validate: (e) =>
|
|
4733
|
+
validate: (e) => Wa(e ?? "")
|
|
4594
4734
|
});
|
|
4595
|
-
s.isCancel(e) &&
|
|
4735
|
+
s.isCancel(e) && Z(), a = Ha(e);
|
|
4596
4736
|
}
|
|
4597
|
-
await
|
|
4737
|
+
await Ar(t, Nr(a, r)), n || (s.log.success(`${B.path("stack.json")} written successfully`), s.outro(B.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
|
|
4598
4738
|
}
|
|
4599
|
-
async function
|
|
4600
|
-
if (await
|
|
4739
|
+
async function ts(e, t = {}, n) {
|
|
4740
|
+
if (await kr(e)) return {
|
|
4601
4741
|
projectRoot: e,
|
|
4602
4742
|
scaffolded: !1
|
|
4603
4743
|
};
|
|
4604
|
-
let r = t.runInit ?? ((e) =>
|
|
4744
|
+
let r = t.runInit ?? ((e) => es({
|
|
4605
4745
|
cwd: e,
|
|
4606
4746
|
silent: !0
|
|
4607
|
-
})), i = t.runCreate ?? ((e, t) =>
|
|
4747
|
+
})), i = t.runCreate ?? ((e, t) => $o({
|
|
4608
4748
|
parentDirectory: e,
|
|
4609
4749
|
deferSetup: !0,
|
|
4610
4750
|
skipBanner: !0,
|
|
4611
4751
|
defaultTheme: t?.defaultTheme,
|
|
4612
4752
|
defaultMode: t?.defaultMode
|
|
4613
4753
|
}));
|
|
4614
|
-
if (await
|
|
4615
|
-
s.log.warn(`No ${
|
|
4754
|
+
if (await Pr(e)) {
|
|
4755
|
+
s.log.warn(`No ${B.path("stack.json")} found in ${B.path(e)}.`);
|
|
4616
4756
|
let t = await s.confirm({
|
|
4617
|
-
message: `Create ${
|
|
4757
|
+
message: `Create ${B.path("stack.json")} now?`,
|
|
4618
4758
|
initialValue: !0
|
|
4619
4759
|
});
|
|
4620
4760
|
if (s.isCancel(t) || !t) return null;
|
|
4621
4761
|
await r(e);
|
|
4622
|
-
let n = await
|
|
4623
|
-
return n && s.log.success(`${
|
|
4762
|
+
let n = await kr(e);
|
|
4763
|
+
return n && s.log.success(`${B.path("stack.json")} created`), n ? {
|
|
4624
4764
|
projectRoot: e,
|
|
4625
4765
|
scaffolded: !1
|
|
4626
4766
|
} : null;
|
|
4627
4767
|
}
|
|
4628
|
-
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${
|
|
4768
|
+
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${B.path("stack.json")} here.`);
|
|
4629
4769
|
let a = await s.confirm({
|
|
4630
|
-
message: `Is ${
|
|
4770
|
+
message: `Is ${B.path(e)} where you want to work?`,
|
|
4631
4771
|
initialValue: !0
|
|
4632
4772
|
});
|
|
4633
4773
|
if (s.isCancel(a) || !a) return null;
|
|
@@ -4637,41 +4777,41 @@ async function Bo(e, t = {}, n) {
|
|
|
4637
4777
|
});
|
|
4638
4778
|
if (s.isCancel(o) || !o) return null;
|
|
4639
4779
|
let c = await i(e, n);
|
|
4640
|
-
return await
|
|
4780
|
+
return await kr(c) ? {
|
|
4641
4781
|
projectRoot: c,
|
|
4642
4782
|
scaffolded: !0
|
|
4643
4783
|
} : null;
|
|
4644
4784
|
}
|
|
4645
4785
|
//#endregion
|
|
4646
4786
|
//#region src/commands/compose.ts
|
|
4647
|
-
async function
|
|
4787
|
+
async function ns(e = {}) {
|
|
4648
4788
|
let t = e.cwd ?? process.cwd();
|
|
4649
|
-
|
|
4650
|
-
let n = await
|
|
4789
|
+
Ra();
|
|
4790
|
+
let n = await ts(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4651
4791
|
try {
|
|
4652
|
-
a = await
|
|
4792
|
+
a = await Or(r ?? t);
|
|
4653
4793
|
} catch (e) {
|
|
4654
|
-
s.cancel(`Could not parse ${
|
|
4794
|
+
s.cancel(`Could not parse ${B.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4655
4795
|
}
|
|
4656
|
-
a || (s.cancel(r ? `Could not read ${
|
|
4796
|
+
a || (s.cancel(r ? `Could not read ${B.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli compose' again.` : `No ${B.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli compose'.`), process.exit(1)), a.paths || (s.cancel(`${B.path("stack.json")} is missing ${B.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
4657
4797
|
let o = r ?? t;
|
|
4658
|
-
s.intro(
|
|
4798
|
+
s.intro(B.brandBold("Compose your stack"));
|
|
4659
4799
|
let c = s.spinner();
|
|
4660
4800
|
c.start("Loading packs...");
|
|
4661
4801
|
let l;
|
|
4662
4802
|
try {
|
|
4663
|
-
l = await
|
|
4803
|
+
l = await Br();
|
|
4664
4804
|
} catch (e) {
|
|
4665
|
-
c.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${
|
|
4805
|
+
c.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4666
4806
|
}
|
|
4667
4807
|
c.stop("Packs loaded");
|
|
4668
|
-
let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await
|
|
4808
|
+
let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await Kn(L()))?.token ?? null, h = await Fo(l, d, {
|
|
4669
4809
|
token: m,
|
|
4670
4810
|
key: p
|
|
4671
4811
|
}), g = (e) => {
|
|
4672
4812
|
let t = f.get(e);
|
|
4673
4813
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4674
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await
|
|
4814
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await rs({
|
|
4675
4815
|
packs: l,
|
|
4676
4816
|
installedSet: d,
|
|
4677
4817
|
stateOf: g,
|
|
@@ -4679,57 +4819,57 @@ async function Vo(e = {}) {
|
|
|
4679
4819
|
adminAvailable: !!a.apps.admin
|
|
4680
4820
|
});
|
|
4681
4821
|
if (v === null && (s.cancel("Cancelled."), process.exit(0)), v.length === 0) {
|
|
4682
|
-
s.outro(
|
|
4822
|
+
s.outro(B.muted("No packs selected. Nothing to do."));
|
|
4683
4823
|
return;
|
|
4684
4824
|
}
|
|
4685
|
-
let b =
|
|
4825
|
+
let b = os(v), x = ss(v), S = Oa(l, b), C = xa(ka(l, S)), w;
|
|
4686
4826
|
try {
|
|
4687
|
-
w =
|
|
4827
|
+
w = Ca(b, C, u);
|
|
4688
4828
|
} catch (e) {
|
|
4689
|
-
s.cancel(
|
|
4829
|
+
s.cancel($(e)), process.exit(1);
|
|
4690
4830
|
}
|
|
4691
4831
|
if (w.order.length === 0) {
|
|
4692
|
-
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(
|
|
4832
|
+
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(B.muted("Your selection is already part of the project."));
|
|
4693
4833
|
return;
|
|
4694
4834
|
}
|
|
4695
|
-
let T =
|
|
4835
|
+
let T = wa({
|
|
4696
4836
|
order: w.order,
|
|
4697
4837
|
graph: C,
|
|
4698
4838
|
isLocked: _,
|
|
4699
4839
|
installed: u
|
|
4700
4840
|
});
|
|
4701
4841
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4702
|
-
let e = await
|
|
4703
|
-
e && (m = e, h = await
|
|
4842
|
+
let e = await nr();
|
|
4843
|
+
e && (m = e, h = await Fo(l, d, {
|
|
4704
4844
|
token: m,
|
|
4705
4845
|
key: p
|
|
4706
|
-
}), T =
|
|
4846
|
+
}), T = wa({
|
|
4707
4847
|
order: w.order,
|
|
4708
4848
|
graph: C,
|
|
4709
4849
|
isLocked: _,
|
|
4710
4850
|
installed: u
|
|
4711
4851
|
}));
|
|
4712
4852
|
}
|
|
4713
|
-
if (T.blocked.length > 0 && await
|
|
4714
|
-
s.outro(
|
|
4853
|
+
if (T.blocked.length > 0 && await Lo(T.blocked, _, f), T.installable.length === 0) {
|
|
4854
|
+
s.outro(B.muted("Nothing left to install once locked packs are removed."));
|
|
4715
4855
|
return;
|
|
4716
4856
|
}
|
|
4717
|
-
if (
|
|
4857
|
+
if (Ro(T.installable, f), !e.yes) {
|
|
4718
4858
|
let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4719
4859
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
4720
4860
|
}
|
|
4721
4861
|
c.start("Downloading packs...");
|
|
4722
4862
|
let E;
|
|
4723
4863
|
try {
|
|
4724
|
-
E = await
|
|
4864
|
+
E = await zo(T.installable, {
|
|
4725
4865
|
token: m,
|
|
4726
4866
|
key: p
|
|
4727
4867
|
});
|
|
4728
4868
|
} catch (e) {
|
|
4729
|
-
c.stop("Download failed"), s.cancel(
|
|
4869
|
+
c.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
4730
4870
|
}
|
|
4731
4871
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4732
|
-
let D = await
|
|
4872
|
+
let D = await Uo({
|
|
4733
4873
|
prepared: E,
|
|
4734
4874
|
config: a,
|
|
4735
4875
|
cwd: o,
|
|
@@ -4739,7 +4879,7 @@ async function Vo(e = {}) {
|
|
|
4739
4879
|
});
|
|
4740
4880
|
try {
|
|
4741
4881
|
c.start("Installing pack files...");
|
|
4742
|
-
let t = await
|
|
4882
|
+
let t = await Zi({
|
|
4743
4883
|
packs: E,
|
|
4744
4884
|
config: a,
|
|
4745
4885
|
projectRoot: o,
|
|
@@ -4752,22 +4892,22 @@ async function Vo(e = {}) {
|
|
|
4752
4892
|
for (let e of t.errors) s.log.error(e);
|
|
4753
4893
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4754
4894
|
}
|
|
4755
|
-
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${
|
|
4895
|
+
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${B.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (s.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`), Ho(t.skipped));
|
|
4756
4896
|
for (let e of t.errors) s.log.error(e);
|
|
4757
|
-
await
|
|
4897
|
+
await Bo({
|
|
4758
4898
|
prepared: E,
|
|
4759
4899
|
paths: a.paths,
|
|
4760
4900
|
cwd: o,
|
|
4761
4901
|
spinner: c
|
|
4762
4902
|
});
|
|
4763
4903
|
let n;
|
|
4764
|
-
i && (n = await
|
|
4904
|
+
i && (n = await ba(o, e.yes ?? !1)), await pr({
|
|
4765
4905
|
projectRoot: o,
|
|
4766
4906
|
paths: a.paths,
|
|
4767
4907
|
skipPrompts: e.yes ?? !1,
|
|
4768
4908
|
dbReady: n,
|
|
4769
4909
|
freshScaffold: i
|
|
4770
|
-
}),
|
|
4910
|
+
}), Vo(), s.outro(B.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4771
4911
|
} finally {
|
|
4772
4912
|
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
4773
4913
|
recursive: !0,
|
|
@@ -4775,25 +4915,25 @@ async function Vo(e = {}) {
|
|
|
4775
4915
|
})));
|
|
4776
4916
|
}
|
|
4777
4917
|
}
|
|
4778
|
-
async function
|
|
4918
|
+
async function rs(e) {
|
|
4779
4919
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4780
4920
|
if (i.packs && i.packs.length > 0) {
|
|
4781
|
-
let e = i.packs.map(
|
|
4921
|
+
let e = i.packs.map(as), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4782
4922
|
return n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4783
4923
|
}
|
|
4784
4924
|
let o = t.filter((e) => n.has(e.name));
|
|
4785
|
-
o.length > 0 && s.note(o.map((e) => ` ${
|
|
4925
|
+
o.length > 0 && s.note(o.map((e) => ` ${B.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4786
4926
|
let c = t.filter((e) => !n.has(e.name));
|
|
4787
|
-
if (c.length === 0) return s.outro(
|
|
4927
|
+
if (c.length === 0) return s.outro(B.muted("Every available pack is already installed.")), [];
|
|
4788
4928
|
let l = se();
|
|
4789
|
-
s.note(c.map((e) => ` ${
|
|
4790
|
-
let u =
|
|
4929
|
+
s.note(c.map((e) => ` ${V.arrow} ${B.highlight(e.displayName)} ${he(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4930
|
+
let u = aa(c, { adminAvailable: a }), d = [];
|
|
4791
4931
|
for (let e of u) {
|
|
4792
4932
|
let t = e.packs.map((e) => {
|
|
4793
4933
|
let t = r(e.name);
|
|
4794
4934
|
return {
|
|
4795
4935
|
value: e.name,
|
|
4796
|
-
label: `${e.displayName} ${
|
|
4936
|
+
label: `${e.displayName} ${Io(t, e.price)}`,
|
|
4797
4937
|
hint: e.description
|
|
4798
4938
|
};
|
|
4799
4939
|
});
|
|
@@ -4810,7 +4950,7 @@ async function Ho(e) {
|
|
|
4810
4950
|
});
|
|
4811
4951
|
continue;
|
|
4812
4952
|
}
|
|
4813
|
-
let n = await
|
|
4953
|
+
let n = await Va({
|
|
4814
4954
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4815
4955
|
options: t,
|
|
4816
4956
|
required: !1
|
|
@@ -4820,20 +4960,20 @@ async function Ho(e) {
|
|
|
4820
4960
|
}
|
|
4821
4961
|
return d;
|
|
4822
4962
|
}
|
|
4823
|
-
var
|
|
4824
|
-
function
|
|
4825
|
-
let t = e.match(
|
|
4963
|
+
var is = /@(frontend|admin)$/;
|
|
4964
|
+
function as(e) {
|
|
4965
|
+
let t = e.match(is);
|
|
4826
4966
|
return t ? {
|
|
4827
4967
|
name: e.slice(0, -t[0].length),
|
|
4828
4968
|
slot: t[1]
|
|
4829
4969
|
} : { name: e };
|
|
4830
4970
|
}
|
|
4831
|
-
function
|
|
4971
|
+
function os(e) {
|
|
4832
4972
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4833
4973
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4834
4974
|
return n;
|
|
4835
4975
|
}
|
|
4836
|
-
function
|
|
4976
|
+
function ss(e) {
|
|
4837
4977
|
let t = /* @__PURE__ */ new Map();
|
|
4838
4978
|
for (let n of e) {
|
|
4839
4979
|
if (!n.slot) continue;
|
|
@@ -4844,109 +4984,32 @@ function Ko(e) {
|
|
|
4844
4984
|
}
|
|
4845
4985
|
//#endregion
|
|
4846
4986
|
//#region src/commands/login.ts
|
|
4847
|
-
async function
|
|
4848
|
-
|
|
4987
|
+
async function cs() {
|
|
4988
|
+
za(), s.intro(B.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
4849
4989
|
let e;
|
|
4850
4990
|
try {
|
|
4851
|
-
e = await
|
|
4852
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
4991
|
+
e = await tr({ onUrl: (e) => {
|
|
4992
|
+
s.log.info(`If your browser didn't open, visit:\n ${B.path(e)}`);
|
|
4853
4993
|
} });
|
|
4854
4994
|
} catch (e) {
|
|
4855
4995
|
s.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
|
|
4856
4996
|
}
|
|
4857
|
-
s.outro(
|
|
4997
|
+
s.outro(B.brand(e.email ? `Logged in as ${e.email}. You can now install packs your organization owns.` : "Logged in. You can now install packs your organization owns."));
|
|
4858
4998
|
}
|
|
4859
4999
|
//#endregion
|
|
4860
5000
|
//#region src/commands/logout.ts
|
|
4861
|
-
async function
|
|
4862
|
-
|
|
4863
|
-
let e = L(), t = await
|
|
5001
|
+
async function ls() {
|
|
5002
|
+
za(), s.intro(B.brandBold("Log out of Hype Stack"));
|
|
5003
|
+
let e = L(), t = await Kn(e);
|
|
4864
5004
|
if (!t) {
|
|
4865
|
-
s.outro(
|
|
5005
|
+
s.outro(B.muted("You're not logged in."));
|
|
4866
5006
|
return;
|
|
4867
5007
|
}
|
|
4868
|
-
await
|
|
4869
|
-
}
|
|
4870
|
-
//#endregion
|
|
4871
|
-
//#region src/core/onboard-catalog.ts
|
|
4872
|
-
var $ = {
|
|
4873
|
-
Config: "config",
|
|
4874
|
-
Databases: "databases",
|
|
4875
|
-
Workos: "workos",
|
|
4876
|
-
BetterAuth: "betterauth",
|
|
4877
|
-
Stripe: "stripe",
|
|
4878
|
-
Polar: "polar",
|
|
4879
|
-
Resend: "resend",
|
|
4880
|
-
IpLocate: "iplocate",
|
|
4881
|
-
Sentry: "sentry"
|
|
4882
|
-
}, Yo = new Set(Object.values($));
|
|
4883
|
-
function Xo(e) {
|
|
4884
|
-
return e.toLowerCase().replace(/[^a-z0-9]+/g, "").trim();
|
|
4885
|
-
}
|
|
4886
|
-
function Zo(e) {
|
|
4887
|
-
let t = Xo(e);
|
|
4888
|
-
return Yo.has(t) ? t : void 0;
|
|
4889
|
-
}
|
|
4890
|
-
var Qo = {
|
|
4891
|
-
[$.Config]: { hint: "App URLs. Defaults work for local dev." },
|
|
4892
|
-
[$.Databases]: { hint: "Credentials for the local Docker Postgres and Valkey containers." },
|
|
4893
|
-
[$.Workos]: {
|
|
4894
|
-
link: "https://dashboard.workos.com/api-keys",
|
|
4895
|
-
hint: "Copy your API Key and Client ID from the WorkOS dashboard."
|
|
4896
|
-
},
|
|
4897
|
-
[$.BetterAuth]: {
|
|
4898
|
-
link: "https://www.better-auth.com/docs/installation#set-environment-variables",
|
|
4899
|
-
hint: "Generate a long random secret, set the app URL, add Google OAuth creds if you use Google."
|
|
4900
|
-
},
|
|
4901
|
-
[$.Stripe]: {
|
|
4902
|
-
link: "https://dashboard.stripe.com/apikeys",
|
|
4903
|
-
hint: "Copy your secret and publishable keys from the Stripe dashboard.",
|
|
4904
|
-
serviceChecklist: [
|
|
4905
|
-
"Recurring prices for Pro and Premier power checkout (set STRIPE_PRICE_PRO and STRIPE_PRICE_PREMIER).",
|
|
4906
|
-
"A webhook at /checkout/webhook keeps subscriptions in sync (subscription events plus invoice.payment_succeeded).",
|
|
4907
|
-
"Enable the Stripe billing portal so Manage Billing and invoices work.",
|
|
4908
|
-
"Enable 'Limit customers to one subscription' to prevent double-checkout races.",
|
|
4909
|
-
"Optional: disable Cash App Pay if you see a high checkout cancel rate."
|
|
4910
|
-
]
|
|
4911
|
-
},
|
|
4912
|
-
[$.Polar]: {
|
|
4913
|
-
link: "https://polar.sh",
|
|
4914
|
-
hint: "From your Polar org: access token, webhook secret, organization id, and the checkout product id."
|
|
4915
|
-
},
|
|
4916
|
-
[$.Resend]: {
|
|
4917
|
-
link: "https://resend.com/api-keys",
|
|
4918
|
-
hint: "Create an API key in Resend."
|
|
4919
|
-
},
|
|
4920
|
-
[$.IpLocate]: {
|
|
4921
|
-
link: "https://iplocate.io",
|
|
4922
|
-
hint: "Grab your API key from IP Locate."
|
|
4923
|
-
},
|
|
4924
|
-
[$.Sentry]: {
|
|
4925
|
-
link: "https://sentry.io",
|
|
4926
|
-
hint: "Your project DSN. Leave blank to skip Sentry for now."
|
|
4927
|
-
}
|
|
4928
|
-
}, $o = { hint: "Add your value, or press Enter to leave it blank." };
|
|
4929
|
-
function es(e) {
|
|
4930
|
-
let t = Zo(e);
|
|
4931
|
-
return t ? Qo[t] : $o;
|
|
4932
|
-
}
|
|
4933
|
-
var ts = {
|
|
4934
|
-
"starter-saas-workos": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4935
|
-
"starter-saas-betterauth": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4936
|
-
"pack-notifications": ["Notifications push over the `appChannel` socket channel; register it in your server startup to go live."],
|
|
4937
|
-
"pack-collaboration": ["Team and TeamMember are available as CASL subjects; project member and team management reuse the existing `Project` subject."]
|
|
4938
|
-
};
|
|
4939
|
-
function ns(e) {
|
|
4940
|
-
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4941
|
-
for (let r of e) {
|
|
4942
|
-
let e = ts[r];
|
|
4943
|
-
if (e) for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
4944
|
-
}
|
|
4945
|
-
return n;
|
|
5008
|
+
await Rn(t.token).catch(() => null), await Jn(e), s.outro(B.brand("Logged out."));
|
|
4946
5009
|
}
|
|
4947
5010
|
//#endregion
|
|
4948
5011
|
//#region src/core/onboard-env.ts
|
|
4949
|
-
function
|
|
5012
|
+
function us(e) {
|
|
4950
5013
|
let t = [], n = "";
|
|
4951
5014
|
for (let r of e.split(/\r?\n/)) {
|
|
4952
5015
|
let e = r.trim();
|
|
@@ -4972,19 +5035,19 @@ function rs(e) {
|
|
|
4972
5035
|
}
|
|
4973
5036
|
return t;
|
|
4974
5037
|
}
|
|
4975
|
-
var
|
|
5038
|
+
var ds = [
|
|
4976
5039
|
"replace-with",
|
|
4977
5040
|
"examplepublickey",
|
|
4978
5041
|
"change-me",
|
|
4979
5042
|
"your-key-here"
|
|
4980
5043
|
];
|
|
4981
|
-
function
|
|
5044
|
+
function fs(e) {
|
|
4982
5045
|
let t = e.trim();
|
|
4983
5046
|
if (t === "") return !0;
|
|
4984
5047
|
let n = t.toLowerCase();
|
|
4985
|
-
return
|
|
5048
|
+
return ds.some((e) => n.includes(e));
|
|
4986
5049
|
}
|
|
4987
|
-
function
|
|
5050
|
+
function ps(e, t, n) {
|
|
4988
5051
|
let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
|
|
4989
5052
|
if (i) return e;
|
|
4990
5053
|
let r = e.trim();
|
|
@@ -4994,109 +5057,119 @@ function os(e, t, n) {
|
|
|
4994
5057
|
});
|
|
4995
5058
|
return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
|
|
4996
5059
|
}
|
|
4997
|
-
async function
|
|
5060
|
+
async function ms(e) {
|
|
4998
5061
|
return await J(e) ? y.readFile(e, "utf-8") : "";
|
|
4999
5062
|
}
|
|
5000
|
-
async function
|
|
5063
|
+
async function hs(e) {
|
|
5001
5064
|
let t = T.join(T.dirname(e), ".env");
|
|
5002
5065
|
return await J(t) || await y.copyFile(e, t), t;
|
|
5003
5066
|
}
|
|
5004
|
-
async function
|
|
5005
|
-
let r =
|
|
5067
|
+
async function gs(e, t, n) {
|
|
5068
|
+
let r = ps(await ms(e), t, n);
|
|
5006
5069
|
await y.writeFile(e, r, "utf-8");
|
|
5007
5070
|
}
|
|
5008
5071
|
//#endregion
|
|
5009
5072
|
//#region src/commands/onboard.ts
|
|
5010
|
-
async function
|
|
5073
|
+
async function _s(e = {}) {
|
|
5011
5074
|
let t = e.cwd ?? process.cwd();
|
|
5012
|
-
|
|
5075
|
+
Ra(), s.intro(B.brandBold("Onboard your stack"));
|
|
5013
5076
|
let n;
|
|
5014
5077
|
try {
|
|
5015
|
-
n = await
|
|
5078
|
+
n = await Or(t);
|
|
5016
5079
|
} catch {
|
|
5017
5080
|
n = null;
|
|
5018
5081
|
}
|
|
5019
|
-
n || (s.cancel(`${
|
|
5020
|
-
let r = await
|
|
5021
|
-
|
|
5022
|
-
for (let n of
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5082
|
+
n || (s.cancel(`${B.path("stack.json")} not found. Run ${B.command("npx @hype-stack/cli init")} first.`), process.exit(1));
|
|
5083
|
+
let r = n.installedPacks ?? [], i = n.onboarding?.envSections ?? [], a = await fo(t);
|
|
5084
|
+
a.length === 0 && s.log.warn(B.muted("No .env.example files found; skipping env setup."));
|
|
5085
|
+
for (let n of a) await vs({
|
|
5086
|
+
examplePath: n,
|
|
5087
|
+
projectRoot: t,
|
|
5088
|
+
skipPrompts: e.yes ?? !1,
|
|
5089
|
+
installedEnvSections: i
|
|
5090
|
+
});
|
|
5091
|
+
let o = Dr(r);
|
|
5092
|
+
o.length > 0 && s.note(o.map((e) => ` ${B.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await xs(t, e.yes ?? !1), s.outro(B.brand(`All set. Run ${B.command("pnpm dev")} to start your app.`));
|
|
5093
|
+
}
|
|
5094
|
+
async function vs(e) {
|
|
5095
|
+
let { examplePath: t, projectRoot: n, skipPrompts: r, installedEnvSections: i } = e, a = T.relative(n, t) || t, o = await hs(t), c = await ms(o), l = us(await y.readFile(t, "utf-8")), u = B.path(a);
|
|
5096
|
+
s.log.step(`Env: ${u}`);
|
|
5097
|
+
for (let e of l) {
|
|
5098
|
+
let t = e.vars.filter((e) => fs(e.value));
|
|
5031
5099
|
if (t.length === 0) continue;
|
|
5032
|
-
|
|
5033
|
-
|
|
5100
|
+
if (!Cr(e.section, i)) {
|
|
5101
|
+
let t = e.section ? B.bold(e.section) : B.bold("Variables");
|
|
5102
|
+
s.log.info(`${t} ${B.muted("skipped (pack not installed)")}`);
|
|
5103
|
+
continue;
|
|
5104
|
+
}
|
|
5105
|
+
let n = xr(e.section), a = e.section ? B.bold(e.section) : B.bold("Variables");
|
|
5106
|
+
s.log.step(a), n.link && (s.log.info(`${B.muted("Get your values:")} ${he(n.link)}`), n.serviceChecklist && n.serviceChecklist.length > 0 && s.note(n.serviceChecklist.map((e) => ` ${B.muted("·")} ${e}`).join("\n"), "Setup")), s.log.info(B.muted(n.hint));
|
|
5034
5107
|
for (let e of t) {
|
|
5035
|
-
if (
|
|
5036
|
-
s.log.info(`${
|
|
5108
|
+
if (r) {
|
|
5109
|
+
s.log.info(`${B.label(e.key)} ${B.muted("skipped (non-interactive)")}`);
|
|
5037
5110
|
continue;
|
|
5038
5111
|
}
|
|
5039
|
-
let t =
|
|
5040
|
-
message: `${
|
|
5041
|
-
placeholder: t ||
|
|
5112
|
+
let t = ys(c, e.key), i = await s.text({
|
|
5113
|
+
message: `${B.label(e.key)}`,
|
|
5114
|
+
placeholder: t || n.hint
|
|
5042
5115
|
});
|
|
5043
|
-
s.isCancel(
|
|
5044
|
-
let
|
|
5045
|
-
if (
|
|
5046
|
-
s.log.warn(
|
|
5116
|
+
s.isCancel(i) && Z();
|
|
5117
|
+
let a = (i ?? "").trim();
|
|
5118
|
+
if (a === "") {
|
|
5119
|
+
s.log.warn(B.muted(`${e.key} left blank.`));
|
|
5047
5120
|
continue;
|
|
5048
5121
|
}
|
|
5049
|
-
await
|
|
5122
|
+
await gs(o, e.key, a), s.log.success(`${e.key} saved`);
|
|
5050
5123
|
}
|
|
5051
5124
|
}
|
|
5052
5125
|
}
|
|
5053
|
-
function
|
|
5126
|
+
function ys(e, t) {
|
|
5054
5127
|
for (let n of e.split(/\r?\n/)) {
|
|
5055
|
-
let e = n.match(RegExp(`^${
|
|
5128
|
+
let e = n.match(RegExp(`^${bs(t)}\\s*=\\s*(.*)$`));
|
|
5056
5129
|
if (e) return e[1].trim();
|
|
5057
5130
|
}
|
|
5058
5131
|
return "";
|
|
5059
5132
|
}
|
|
5060
|
-
function
|
|
5133
|
+
function bs(e) {
|
|
5061
5134
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5062
5135
|
}
|
|
5063
|
-
async function
|
|
5064
|
-
if (!await
|
|
5065
|
-
s.log.info(
|
|
5136
|
+
async function xs(e, t) {
|
|
5137
|
+
if (!await la() && !await da(e, t, !1)) {
|
|
5138
|
+
s.log.info(B.muted(`Start services later with ${B.command("docker compose up -d")} (in apps/backend), then ${B.command("pnpm --filter @internal/backend migration:latest")}.`));
|
|
5066
5139
|
return;
|
|
5067
5140
|
}
|
|
5068
5141
|
let n = s.spinner();
|
|
5069
|
-
if (n.start("Waiting for Postgres to be ready..."), !await
|
|
5070
|
-
n.error("Postgres health check timed out"), s.log.warn(
|
|
5142
|
+
if (n.start("Waiting for Postgres to be ready..."), !await pa(e)) {
|
|
5143
|
+
n.error("Postgres health check timed out"), s.log.warn(B.muted(`Run migrations manually once Postgres is ready: ${B.command("pnpm --filter @internal/backend migration:latest")}`));
|
|
5071
5144
|
return;
|
|
5072
5145
|
}
|
|
5073
|
-
if (n.stop(
|
|
5074
|
-
s.log.info(
|
|
5146
|
+
if (n.stop(B.success("Postgres is ready")), await ha(e)) {
|
|
5147
|
+
s.log.info(B.muted("Migrations already applied, skipping."));
|
|
5075
5148
|
return;
|
|
5076
5149
|
}
|
|
5077
5150
|
let r = t ? !0 : await s.confirm({
|
|
5078
|
-
message: `Run database migrations with ${
|
|
5151
|
+
message: `Run database migrations with ${B.command("prisma migrate deploy")}?`,
|
|
5079
5152
|
initialValue: !0
|
|
5080
5153
|
});
|
|
5081
|
-
if (s.isCancel(r) &&
|
|
5082
|
-
s.log.info(
|
|
5154
|
+
if (s.isCancel(r) && Z(), !r) {
|
|
5155
|
+
s.log.info(B.muted("Skipping database migrations."));
|
|
5083
5156
|
return;
|
|
5084
5157
|
}
|
|
5085
|
-
await
|
|
5158
|
+
await ga(e);
|
|
5086
5159
|
}
|
|
5087
5160
|
//#endregion
|
|
5088
5161
|
//#region src/core/templates.ts
|
|
5089
|
-
var
|
|
5162
|
+
var Ss = K.createRequest()({
|
|
5090
5163
|
endpoint: "/templates/list",
|
|
5091
5164
|
method: "GET"
|
|
5092
5165
|
});
|
|
5093
|
-
async function
|
|
5094
|
-
let { data: e, error: t } = await
|
|
5166
|
+
async function Cs() {
|
|
5167
|
+
let { data: e, error: t } = await Ss.send();
|
|
5095
5168
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
5096
5169
|
return e.templates;
|
|
5097
5170
|
}
|
|
5098
|
-
async function
|
|
5099
|
-
let { data: t, error: n, status: r } = await
|
|
5171
|
+
async function ws(e) {
|
|
5172
|
+
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
5100
5173
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
5101
5174
|
method: "GET"
|
|
5102
5175
|
}).send();
|
|
@@ -5104,13 +5177,13 @@ async function _s(e) {
|
|
|
5104
5177
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
5105
5178
|
return t;
|
|
5106
5179
|
}
|
|
5107
|
-
async function
|
|
5108
|
-
let n =
|
|
5180
|
+
async function Ts(e, t = {}) {
|
|
5181
|
+
let n = K.createRequest()({
|
|
5109
5182
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
5110
5183
|
method: "POST"
|
|
5111
5184
|
}), r = {
|
|
5112
|
-
"X-Device-Id":
|
|
5113
|
-
"X-Client-Info":
|
|
5185
|
+
"X-Device-Id": Xn(),
|
|
5186
|
+
"X-Client-Info": Zn()
|
|
5114
5187
|
};
|
|
5115
5188
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
5116
5189
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -5132,29 +5205,29 @@ async function vs(e, t = {}) {
|
|
|
5132
5205
|
}
|
|
5133
5206
|
//#endregion
|
|
5134
5207
|
//#region src/commands/template.ts
|
|
5135
|
-
async function
|
|
5208
|
+
async function Es(t = {}) {
|
|
5136
5209
|
let n = t.cwd ?? process.cwd();
|
|
5137
|
-
|
|
5210
|
+
Ra();
|
|
5138
5211
|
let r = s.spinner();
|
|
5139
5212
|
r.start("Loading packs...");
|
|
5140
5213
|
let o;
|
|
5141
5214
|
try {
|
|
5142
|
-
o = await
|
|
5215
|
+
o = await Br();
|
|
5143
5216
|
} catch (e) {
|
|
5144
|
-
r.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${
|
|
5217
|
+
r.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
5145
5218
|
}
|
|
5146
5219
|
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
5147
5220
|
let c;
|
|
5148
5221
|
try {
|
|
5149
|
-
c = await
|
|
5222
|
+
c = await Cs();
|
|
5150
5223
|
} catch (e) {
|
|
5151
|
-
r.stop("Failed to load templates"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${
|
|
5224
|
+
r.stop("Failed to load templates"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
5152
5225
|
}
|
|
5153
5226
|
let l = t.templateId;
|
|
5154
5227
|
if (!l) {
|
|
5155
5228
|
t.yes && (r.stop("Template id required"), s.cancel("Pass a template id with `npx @hype-stack/cli template <id>` (required in --yes mode)."), process.exit(1)), c.length === 0 && (r.stop("No templates available"), s.cancel("No templates are available yet. Check back later."), process.exit(1)), r.stop("Templates loaded");
|
|
5156
5229
|
let e = se();
|
|
5157
|
-
s.note(c.map((t) => ` ${
|
|
5230
|
+
s.note(c.map((t) => ` ${V.arrow} ${B.highlight(t.name)} ${he(`${e}/templates/${t.id}`)}`).join("\n"), "Browse templates");
|
|
5158
5231
|
let n = await s.select({
|
|
5159
5232
|
message: "Choose a template",
|
|
5160
5233
|
options: c.map((e) => ({
|
|
@@ -5169,83 +5242,83 @@ async function ys(t = {}) {
|
|
|
5169
5242
|
u || (r.stop("Template not found"), s.cancel(`Template "${l}" not found. Available: ${c.map((e) => e.id).join(", ") || "(none)"}`), process.exit(1)), r.stop(`Template: ${u.name}`);
|
|
5170
5243
|
let d;
|
|
5171
5244
|
try {
|
|
5172
|
-
d = await
|
|
5245
|
+
d = await ws(u.id);
|
|
5173
5246
|
} catch (e) {
|
|
5174
|
-
s.cancel(
|
|
5247
|
+
s.cancel($(e)), process.exit(1);
|
|
5175
5248
|
}
|
|
5176
|
-
let f = await
|
|
5249
|
+
let f = await ts(n, {}, {
|
|
5177
5250
|
defaultTheme: d.theme,
|
|
5178
5251
|
defaultMode: d.defaultMode
|
|
5179
5252
|
}), p = f?.projectRoot ?? null, m = f?.scaffolded ?? !1, h;
|
|
5180
5253
|
try {
|
|
5181
|
-
h = await
|
|
5254
|
+
h = await Or(p ?? n);
|
|
5182
5255
|
} catch (e) {
|
|
5183
|
-
s.cancel(`Could not parse ${
|
|
5256
|
+
s.cancel(`Could not parse ${B.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
5184
5257
|
}
|
|
5185
|
-
h || (s.cancel(p ? `Could not read ${
|
|
5258
|
+
h || (s.cancel(p ? `Could not read ${B.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${B.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), process.exit(1)), h.paths || (s.cancel(`${B.path("stack.json")} is missing ${B.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
5186
5259
|
let g = p ?? n;
|
|
5187
|
-
s.intro(
|
|
5188
|
-
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await
|
|
5260
|
+
s.intro(B.brandBold("Install a template"));
|
|
5261
|
+
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await Kn(L()))?.token ?? null, C = await Ds(u, t.variants, t.yes ?? !1), w = Ta(u.slots, C), E = Ea(u.slots, u.packs, w), D = await Os({
|
|
5189
5262
|
packs: o,
|
|
5190
5263
|
templatePacks: E,
|
|
5191
5264
|
installedSet: v,
|
|
5192
5265
|
options: t
|
|
5193
5266
|
}), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
|
|
5194
5267
|
k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
|
|
5195
|
-
let ee =
|
|
5268
|
+
let ee = ka(o, w), A = xa(ee), j;
|
|
5196
5269
|
try {
|
|
5197
|
-
j =
|
|
5270
|
+
j = Ca(O, A, _);
|
|
5198
5271
|
} catch (e) {
|
|
5199
|
-
s.cancel(
|
|
5272
|
+
s.cancel($(e)), process.exit(1);
|
|
5200
5273
|
}
|
|
5201
5274
|
if (j.order.length === 0) {
|
|
5202
|
-
s.outro(
|
|
5275
|
+
s.outro(B.muted("Every pack in this template is already installed."));
|
|
5203
5276
|
return;
|
|
5204
5277
|
}
|
|
5205
|
-
let M = await
|
|
5278
|
+
let M = await Fo(ee, v, {
|
|
5206
5279
|
token: S,
|
|
5207
5280
|
key: x
|
|
5208
5281
|
}), te = (e) => {
|
|
5209
5282
|
let t = b.get(e);
|
|
5210
5283
|
return !t || t.tier === "free" ? "free" : M[e]?.owned ? "owned" : "locked";
|
|
5211
|
-
}, N = (e) => !v.has(e) && te(e) === "locked", P =
|
|
5284
|
+
}, N = (e) => !v.has(e) && te(e) === "locked", P = wa({
|
|
5212
5285
|
order: j.order,
|
|
5213
5286
|
graph: A,
|
|
5214
5287
|
isLocked: N,
|
|
5215
5288
|
installed: _
|
|
5216
5289
|
});
|
|
5217
5290
|
if (P.blocked.length > 0 && !S && !x) {
|
|
5218
|
-
let e = await
|
|
5219
|
-
e && (S = e, M = await
|
|
5291
|
+
let e = await nr();
|
|
5292
|
+
e && (S = e, M = await Fo(ee, v, {
|
|
5220
5293
|
token: S,
|
|
5221
5294
|
key: x
|
|
5222
|
-
}), P =
|
|
5295
|
+
}), P = wa({
|
|
5223
5296
|
order: j.order,
|
|
5224
5297
|
graph: A,
|
|
5225
5298
|
isLocked: N,
|
|
5226
5299
|
installed: _
|
|
5227
5300
|
}));
|
|
5228
5301
|
}
|
|
5229
|
-
if (P.blocked.length > 0 && await
|
|
5230
|
-
s.outro(
|
|
5302
|
+
if (P.blocked.length > 0 && await Lo(P.blocked, N, b), P.installable.length === 0) {
|
|
5303
|
+
s.outro(B.muted("Nothing left to install once locked packs are removed."));
|
|
5231
5304
|
return;
|
|
5232
5305
|
}
|
|
5233
|
-
if (
|
|
5234
|
-
let e = await s.confirm({ message: `Install template ${
|
|
5306
|
+
if (Ro(P.installable, b), !t.yes) {
|
|
5307
|
+
let e = await s.confirm({ message: `Install template ${B.brandBold(u.name)} (${P.installable.length} pack${P.installable.length === 1 ? "" : "s"})?` });
|
|
5235
5308
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5236
5309
|
}
|
|
5237
5310
|
r.start("Downloading packs...");
|
|
5238
5311
|
let F;
|
|
5239
5312
|
try {
|
|
5240
|
-
F = await
|
|
5313
|
+
F = await zo(P.installable, {
|
|
5241
5314
|
token: S,
|
|
5242
5315
|
key: x
|
|
5243
5316
|
});
|
|
5244
5317
|
} catch (e) {
|
|
5245
|
-
r.stop("Download failed"), s.cancel(
|
|
5318
|
+
r.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
5246
5319
|
}
|
|
5247
5320
|
r.stop(`Downloaded ${F.length} pack${F.length === 1 ? "" : "s"}`);
|
|
5248
|
-
let ne = await
|
|
5321
|
+
let ne = await Uo({
|
|
5249
5322
|
prepared: F,
|
|
5250
5323
|
config: h,
|
|
5251
5324
|
cwd: g,
|
|
@@ -5254,7 +5327,7 @@ async function ys(t = {}) {
|
|
|
5254
5327
|
}), I = null;
|
|
5255
5328
|
try {
|
|
5256
5329
|
r.start("Installing pack files...");
|
|
5257
|
-
let n = await
|
|
5330
|
+
let n = await Zi({
|
|
5258
5331
|
packs: F,
|
|
5259
5332
|
config: h,
|
|
5260
5333
|
projectRoot: g,
|
|
@@ -5266,15 +5339,15 @@ async function ys(t = {}) {
|
|
|
5266
5339
|
for (let e of n.errors) s.log.error(e);
|
|
5267
5340
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5268
5341
|
}
|
|
5269
|
-
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${
|
|
5342
|
+
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${B.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && (s.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`), Ho(n.skipped));
|
|
5270
5343
|
for (let e of n.errors) s.log.error(e);
|
|
5271
5344
|
r.start("Applying template overrides...");
|
|
5272
|
-
let o = await
|
|
5345
|
+
let o = await Ts(u.id, {
|
|
5273
5346
|
token: S,
|
|
5274
5347
|
licenseKey: x
|
|
5275
5348
|
});
|
|
5276
5349
|
o.status === "denied" && (r.stop("Template download denied"), s.cancel(`Access to template "${u.id}" was denied (${o.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)), I = o.templateDir;
|
|
5277
|
-
let c = await
|
|
5350
|
+
let c = await $i({
|
|
5278
5351
|
manifest: d,
|
|
5279
5352
|
config: h,
|
|
5280
5353
|
projectRoot: g,
|
|
@@ -5284,11 +5357,11 @@ async function ys(t = {}) {
|
|
|
5284
5357
|
for (let e of c.errors) s.log.error(e);
|
|
5285
5358
|
if (!m) {
|
|
5286
5359
|
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5287
|
-
a(n) && (await
|
|
5360
|
+
a(n) && (await eo(t, i(n)) ? s.log.success(`Applied the ${i(n).label} theme`) : s.log.warning(B.muted(`Could not find ${B.path("assets/styles.css")} to apply the theme`)));
|
|
5288
5361
|
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5289
|
-
await
|
|
5362
|
+
await Ja(t, r) ? s.log.success(`Default color mode set to ${r}`) : s.log.warning(B.muted(`Could not find ${B.path("src/hooks/use-theme.ts")} to set the default color mode`));
|
|
5290
5363
|
}
|
|
5291
|
-
await
|
|
5364
|
+
await ks({
|
|
5292
5365
|
prepared: F,
|
|
5293
5366
|
templateNpm: d.dependencies_npm,
|
|
5294
5367
|
paths: h.paths,
|
|
@@ -5296,13 +5369,13 @@ async function ys(t = {}) {
|
|
|
5296
5369
|
spinner: r
|
|
5297
5370
|
});
|
|
5298
5371
|
let l;
|
|
5299
|
-
m && (l = await
|
|
5372
|
+
m && (l = await ba(g, t.yes ?? !1)), await pr({
|
|
5300
5373
|
projectRoot: g,
|
|
5301
5374
|
paths: h.paths,
|
|
5302
5375
|
skipPrompts: t.yes ?? !1,
|
|
5303
5376
|
dbReady: l,
|
|
5304
5377
|
freshScaffold: m
|
|
5305
|
-
}),
|
|
5378
|
+
}), Vo(), s.outro(B.brand(`Installed template ${u.name}.`));
|
|
5306
5379
|
} finally {
|
|
5307
5380
|
await Promise.all(F.map((e) => y.rm(e.packDir, {
|
|
5308
5381
|
recursive: !0,
|
|
@@ -5313,7 +5386,7 @@ async function ys(t = {}) {
|
|
|
5313
5386
|
});
|
|
5314
5387
|
}
|
|
5315
5388
|
}
|
|
5316
|
-
async function
|
|
5389
|
+
async function Ds(e, t, n) {
|
|
5317
5390
|
let r = {};
|
|
5318
5391
|
for (let i of e.slots) {
|
|
5319
5392
|
if (t?.[i.family]) {
|
|
@@ -5337,7 +5410,7 @@ async function bs(e, t, n) {
|
|
|
5337
5410
|
}
|
|
5338
5411
|
return r;
|
|
5339
5412
|
}
|
|
5340
|
-
async function
|
|
5413
|
+
async function Os(e) {
|
|
5341
5414
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5342
5415
|
if (i.packs && i.packs.length > 0) {
|
|
5343
5416
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -5347,8 +5420,8 @@ async function xs(e) {
|
|
|
5347
5420
|
let o = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
|
|
5348
5421
|
if (o.length === 0) return [];
|
|
5349
5422
|
let c = se();
|
|
5350
|
-
s.note(o.map((e) => ` ${
|
|
5351
|
-
let l = await
|
|
5423
|
+
s.note(o.map((e) => ` ${V.arrow} ${B.highlight(e.displayName)} ${he(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5424
|
+
let l = await Va({
|
|
5352
5425
|
message: "Add extra packs on top of the template (optional)",
|
|
5353
5426
|
options: o.map((e) => ({
|
|
5354
5427
|
value: e.name,
|
|
@@ -5359,25 +5432,25 @@ async function xs(e) {
|
|
|
5359
5432
|
});
|
|
5360
5433
|
return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
|
|
5361
5434
|
}
|
|
5362
|
-
async function
|
|
5363
|
-
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o =
|
|
5435
|
+
async function ks(e) {
|
|
5436
|
+
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o = No(t.map((e) => e.manifest.dependencies_npm)), c = Mo(n ? No([o, n]) : o, r);
|
|
5364
5437
|
if (c.errors.length > 0) {
|
|
5365
5438
|
for (let e of c.errors) s.log.error(e);
|
|
5366
5439
|
return;
|
|
5367
5440
|
}
|
|
5368
5441
|
if (c.operations.length === 0) return;
|
|
5369
5442
|
a.start("Installing npm dependencies...");
|
|
5370
|
-
let l = await
|
|
5443
|
+
let l = await Po(c.operations, i);
|
|
5371
5444
|
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) s.log.error(e);
|
|
5372
5445
|
}
|
|
5373
5446
|
//#endregion
|
|
5374
5447
|
//#region src/cli.ts
|
|
5375
|
-
function
|
|
5448
|
+
function As(e) {
|
|
5376
5449
|
if (!e) return;
|
|
5377
5450
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5378
5451
|
return t.length > 0 ? t : void 0;
|
|
5379
5452
|
}
|
|
5380
|
-
function
|
|
5453
|
+
function js(e) {
|
|
5381
5454
|
if (!e) return;
|
|
5382
5455
|
let t = {};
|
|
5383
5456
|
for (let n of e.split(",")) {
|
|
@@ -5386,10 +5459,10 @@ function ws(e) {
|
|
|
5386
5459
|
}
|
|
5387
5460
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5388
5461
|
}
|
|
5389
|
-
function
|
|
5462
|
+
function Ms() {
|
|
5390
5463
|
let e = new o();
|
|
5391
5464
|
return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(A, "-v, --version"), e.command("create").description("Create a new Hype Stack project").option("-n, --name <name>", "Project name").option("-d, --directory <path>", "Target directory").option("-e, --editor <editor>", "Code editor (cursor, claude, windsurf, copilot)").option("-t, --theme <theme>", "Color theme (default, slate, rose, emerald, violet, amber, ocean, zinc-mono, crimson, midnight)").option("--no-install", "Skip dependency installation").option("--no-setup", "Skip Docker services and database migrations after create").option("-y, --yes", "Skip confirmation prompts (requires --name)").action(async (e) => {
|
|
5392
|
-
await
|
|
5465
|
+
await $o({
|
|
5393
5466
|
name: e.name,
|
|
5394
5467
|
directory: e.directory,
|
|
5395
5468
|
install: e.install,
|
|
@@ -5399,38 +5472,38 @@ function Ts() {
|
|
|
5399
5472
|
setup: e.setup
|
|
5400
5473
|
});
|
|
5401
5474
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5402
|
-
await
|
|
5475
|
+
await es({});
|
|
5403
5476
|
}), e.command("onboard").description("Set up env vars, run migrations, and get the start command").option("-y, --yes", "Skip prompts, accept defaults").option("--skip-migrations", "Skip Docker services and database migrations").option("--cwd <path>", "Working directory").action(async (e) => {
|
|
5404
|
-
await
|
|
5477
|
+
await _s({
|
|
5405
5478
|
cwd: e.cwd,
|
|
5406
5479
|
yes: e.yes,
|
|
5407
5480
|
skipMigrations: e.skipMigrations
|
|
5408
5481
|
});
|
|
5409
5482
|
}), e.command("compose").description("Choose feature packs to add to your project").option("--packs <list>", "Comma-separated pack names (non-interactive). Append @frontend or @admin to a layout pack to target that app shell, e.g. layout-basic@frontend,layout-native-app-shell@admin").option("--force", "Overwrite existing files").option("-y, --yes", "Skip confirmation prompts").option("-k, --key <key>", "License key").option("--license-key <key>", "License key (alias for --key)").option("--cwd <path>", "Working directory").action(async (e) => {
|
|
5410
|
-
await
|
|
5411
|
-
packs:
|
|
5483
|
+
await ns({
|
|
5484
|
+
packs: As(e.packs),
|
|
5412
5485
|
force: e.force,
|
|
5413
5486
|
yes: e.yes,
|
|
5414
5487
|
licenseKey: e.key ?? e.licenseKey,
|
|
5415
5488
|
cwd: e.cwd
|
|
5416
5489
|
});
|
|
5417
5490
|
}), e.command("template").description("Install a template by id, with starter/layout variant swaps and extra packs on top").argument("[id]", "Template id (omit to pick interactively)").option("--variants <map>", "Preselect slot variants, e.g. starter-saas=starter-saas-better-auth,layout=layout-basic").option("--packs <list>", "Extra packs to add on top of the template (comma-separated)").option("--force", "Overwrite existing files").option("-y, --yes", "Skip confirmation prompts (requires <id>)").option("-k, --key <key>", "License key").option("--license-key <key>", "License key (alias for --key)").option("--cwd <path>", "Working directory").action(async (e, t) => {
|
|
5418
|
-
await
|
|
5491
|
+
await Es({
|
|
5419
5492
|
templateId: e,
|
|
5420
|
-
variants:
|
|
5421
|
-
packs:
|
|
5493
|
+
variants: js(t.variants),
|
|
5494
|
+
packs: As(t.packs),
|
|
5422
5495
|
force: t.force,
|
|
5423
5496
|
yes: t.yes,
|
|
5424
5497
|
licenseKey: t.key ?? t.licenseKey,
|
|
5425
5498
|
cwd: t.cwd
|
|
5426
5499
|
});
|
|
5427
5500
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5428
|
-
await
|
|
5501
|
+
await cs();
|
|
5429
5502
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5430
|
-
await
|
|
5503
|
+
await ls();
|
|
5431
5504
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5432
|
-
await
|
|
5505
|
+
await cs();
|
|
5433
5506
|
}), e;
|
|
5434
5507
|
}
|
|
5435
5508
|
//#endregion
|
|
5436
|
-
export {
|
|
5509
|
+
export { ts as a, ns as i, ls as n, es as o, cs as r, $o as s, Ms as t };
|