@hype-stack/cli 0.5.6 → 0.5.8
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-BOykXnFK.js → cli-BkQLqKas.js} +974 -920
- package/dist/commands/onboard.d.ts.map +1 -1
- package/dist/config/bin.js +1 -1
- package/dist/core/apply-theme.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/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.8", j = "gh:BetterTyped/hype-stack", M = "stack.json", te = "/schema/stack.json", N = "https://api.hype-stack.dev", P = "HYPE_STACK_API_URL", F = "https://www.hype-stack.dev", ne = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, I = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -31,109 +31,109 @@ var A = "0.5.6", j = "gh:BetterTyped/hype-stack", te = "stack.json", ne = "/sche
|
|
|
31
31
|
value: "copilot",
|
|
32
32
|
label: "GitHub Copilot"
|
|
33
33
|
}
|
|
34
|
-
],
|
|
35
|
-
function
|
|
34
|
+
], re = I.map((e) => e.value), ie = ".cursor/rules", ae = ".cursor", oe = ".agents";
|
|
35
|
+
function L() {
|
|
36
36
|
let e = process.env.HYPE_STACK_API_URL;
|
|
37
|
-
return e ? (
|
|
37
|
+
return e ? (ce(e), e.replace(/\/+$/, "")) : N;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function se() {
|
|
40
40
|
let e = process.env.HYPE_STACK_WEB_URL;
|
|
41
|
-
return e ? (
|
|
41
|
+
return e ? (ce(e), e.replace(/\/+$/, "")) : F;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function ce(e) {
|
|
44
44
|
try {
|
|
45
45
|
let t = new URL(e);
|
|
46
|
-
if (!t.protocol.startsWith("http")) throw Error(`${
|
|
46
|
+
if (!t.protocol.startsWith("http")) throw Error(`${P} must use http or https protocol, got "${t.protocol}"`);
|
|
47
47
|
} catch (t) {
|
|
48
|
-
throw t instanceof TypeError ? Error(`${
|
|
48
|
+
throw t instanceof TypeError ? Error(`${P} is not a valid URL: "${e}"`, { cause: t }) : t;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return `${
|
|
51
|
+
function le() {
|
|
52
|
+
return `${L()}${te}`;
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/ui/theme.ts
|
|
56
|
-
var
|
|
57
|
-
orange:
|
|
58
|
-
orangeBright:
|
|
59
|
-
amber:
|
|
60
|
-
deepBlue:
|
|
61
|
-
skyBlue:
|
|
62
|
-
lightBlue:
|
|
63
|
-
},
|
|
64
|
-
brand: (e) =>
|
|
65
|
-
brandBold: (e) => b.bold(
|
|
66
|
-
accent: (e) =>
|
|
67
|
-
accentBold: (e) => b.bold(
|
|
56
|
+
var ue = (e) => `\x1b[38;5;208m${e}\x1b[39m`, de = (e) => `\x1b[38;5;214m${e}\x1b[39m`, R = (e) => `\x1b[38;5;220m${e}\x1b[39m`, fe = (e) => `\x1b[38;5;33m${e}\x1b[39m`, z = (e) => `\x1b[38;5;39m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;81m${e}\x1b[39m`, me = {
|
|
57
|
+
orange: ue,
|
|
58
|
+
orangeBright: de,
|
|
59
|
+
amber: R,
|
|
60
|
+
deepBlue: fe,
|
|
61
|
+
skyBlue: z,
|
|
62
|
+
lightBlue: pe
|
|
63
|
+
}, B = {
|
|
64
|
+
brand: (e) => ue(e),
|
|
65
|
+
brandBold: (e) => b.bold(ue(e)),
|
|
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(
|
|
75
|
-
command: (e) => b.bold(
|
|
74
|
+
path: (e) => b.underline(z(e)),
|
|
75
|
+
command: (e) => b.bold(R(e)),
|
|
76
76
|
label: (e) => b.dim(b.bold(e))
|
|
77
77
|
};
|
|
78
|
-
function
|
|
79
|
-
return `\x1b]8;;${e}\x07${
|
|
80
|
-
}
|
|
81
|
-
var
|
|
82
|
-
arrow:
|
|
83
|
-
bullet:
|
|
84
|
-
dash:
|
|
85
|
-
corner:
|
|
86
|
-
pipe:
|
|
87
|
-
dot:
|
|
88
|
-
spark:
|
|
89
|
-
sparkSmall:
|
|
90
|
-
bolt:
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
fe,
|
|
78
|
+
function he(e, t = e) {
|
|
79
|
+
return `\x1b]8;;${e}\x07${z(t)}\x1b]8;;\x07`;
|
|
80
|
+
}
|
|
81
|
+
var V = {
|
|
82
|
+
arrow: ue("›"),
|
|
83
|
+
bullet: B.muted("·"),
|
|
84
|
+
dash: B.muted("─"),
|
|
85
|
+
corner: B.muted("╰"),
|
|
86
|
+
pipe: B.muted("│"),
|
|
87
|
+
dot: B.muted("•"),
|
|
88
|
+
spark: R("✦"),
|
|
89
|
+
sparkSmall: de("✧"),
|
|
90
|
+
bolt: R("⚡")
|
|
91
|
+
}, ge = [
|
|
92
|
+
R,
|
|
93
|
+
R,
|
|
95
94
|
de,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
ue,
|
|
96
|
+
fe,
|
|
97
|
+
z,
|
|
98
|
+
pe,
|
|
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
|
|
123
|
-
return `${
|
|
122
|
+
function be(e) {
|
|
123
|
+
return `${se()}/packs/${e}`;
|
|
124
124
|
}
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region ../../node_modules/.pnpm/@hyper-fetch+core@8.1.1/node_modules/@hyper-fetch/core/dist/index.mjs
|
|
127
|
-
var
|
|
128
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i =
|
|
127
|
+
var 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 Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
308
308
|
});
|
|
309
309
|
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
310
310
|
}
|
|
311
|
-
})))()),
|
|
311
|
+
})))()), 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 Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
320
320
|
onEmit = (e) => (this.emitCallbacks?.push(e), () => {
|
|
321
321
|
this.emitCallbacks = this.emitCallbacks?.filter((t) => t !== e);
|
|
322
322
|
});
|
|
323
|
-
onListener = (e, t) => (super.on(
|
|
324
|
-
super.off(
|
|
323
|
+
onListener = (e, t) => (super.on(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 Ce = Object.create, we = Object.defineProperty, Te = Object.getOwnPropertyDe
|
|
|
354
354
|
setOnline = (e) => {
|
|
355
355
|
this.isOnline = e, e ? this.events.emitOnline() : this.events.emitOffline();
|
|
356
356
|
};
|
|
357
|
-
},
|
|
357
|
+
}, 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 Ce = Object.create, we = Object.defineProperty, Te = 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 Ce = Object.create, we = Object.defineProperty, Te = 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
581
|
}, Nt = (e) => {
|
|
582
|
-
let t =
|
|
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
|
-
}, Pt = (e) =>
|
|
584
|
+
}, Pt = (e) => Fe() && e instanceof FormData ? e : Mt(e), Ft = [
|
|
585
585
|
"onBeforeSent",
|
|
586
586
|
"onRequestStart",
|
|
587
587
|
"onResponseStart",
|
|
@@ -748,7 +748,7 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
748
748
|
data: null,
|
|
749
749
|
status: null,
|
|
750
750
|
success: !1,
|
|
751
|
-
error:
|
|
751
|
+
error: jt("deleted"),
|
|
752
752
|
extra: e.client.adapter.defaultExtra,
|
|
753
753
|
requestTimestamp: +/* @__PURE__ */ new Date(),
|
|
754
754
|
responseTimestamp: +/* @__PURE__ */ new Date()
|
|
@@ -1074,14 +1074,14 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1074
1074
|
total: e.total || p,
|
|
1075
1075
|
loaded: e.loaded || 0
|
|
1076
1076
|
}), t;
|
|
1077
|
-
},
|
|
1077
|
+
}, M = () => {
|
|
1078
1078
|
u ||= +/* @__PURE__ */ new Date();
|
|
1079
1079
|
let e = +/* @__PURE__ */ new Date();
|
|
1080
1080
|
return E(u, e, {
|
|
1081
1081
|
total: p,
|
|
1082
1082
|
loaded: p
|
|
1083
1083
|
}), e;
|
|
1084
|
-
},
|
|
1084
|
+
}, te = async ({ data: e, error: r, status: i, extra: a }) => {
|
|
1085
1085
|
let o = {
|
|
1086
1086
|
data: e,
|
|
1087
1087
|
error: r ?? null,
|
|
@@ -1106,50 +1106,50 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1106
1106
|
response: o
|
|
1107
1107
|
}
|
|
1108
1108
|
}), o;
|
|
1109
|
-
},
|
|
1109
|
+
}, N = Xt({
|
|
1110
1110
|
request: d,
|
|
1111
1111
|
requestId: t,
|
|
1112
1112
|
startTime: x,
|
|
1113
1113
|
logger: c,
|
|
1114
1114
|
resolve: n
|
|
1115
|
-
}),
|
|
1115
|
+
}), P = ({ status: e, extra: n }) => (c.error({
|
|
1116
1116
|
title: "Abort error",
|
|
1117
1117
|
type: "request",
|
|
1118
1118
|
extra: {
|
|
1119
1119
|
request: d,
|
|
1120
1120
|
requestId: t
|
|
1121
1121
|
}
|
|
1122
|
-
}),
|
|
1123
|
-
error: i(
|
|
1122
|
+
}), N({
|
|
1123
|
+
error: i(jt("abort")),
|
|
1124
1124
|
status: e,
|
|
1125
1125
|
extra: n
|
|
1126
|
-
})),
|
|
1126
|
+
})), F = ({ status: e, extra: n }) => (c.error({
|
|
1127
1127
|
title: "Timeout error",
|
|
1128
1128
|
type: "request",
|
|
1129
1129
|
extra: {
|
|
1130
1130
|
request: d,
|
|
1131
1131
|
requestId: t
|
|
1132
1132
|
}
|
|
1133
|
-
}),
|
|
1134
|
-
error:
|
|
1133
|
+
}), N({
|
|
1134
|
+
error: jt("timeout"),
|
|
1135
1135
|
status: e,
|
|
1136
1136
|
extra: n
|
|
1137
|
-
})),
|
|
1137
|
+
})), ne = ({ status: e, extra: n }) => (c.error({
|
|
1138
1138
|
title: "Unexpected error",
|
|
1139
1139
|
type: "request",
|
|
1140
1140
|
extra: {
|
|
1141
1141
|
request: d,
|
|
1142
1142
|
requestId: t
|
|
1143
1143
|
}
|
|
1144
|
-
}),
|
|
1145
|
-
error:
|
|
1144
|
+
}), N({
|
|
1145
|
+
error: jt(),
|
|
1146
1146
|
status: e,
|
|
1147
1147
|
extra: n
|
|
1148
|
-
})),
|
|
1149
|
-
let i =
|
|
1150
|
-
if (!i) throw new
|
|
1148
|
+
})), I = () => a.getAbortController(v, t), re = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1149
|
+
let i = I();
|
|
1150
|
+
if (!i) throw new kt("Controller is not found");
|
|
1151
1151
|
let o = () => {
|
|
1152
|
-
|
|
1152
|
+
P({
|
|
1153
1153
|
status: e,
|
|
1154
1154
|
extra: n
|
|
1155
1155
|
}), r(), a.events.emitAbort({
|
|
@@ -1169,33 +1169,33 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1169
1169
|
adapterOptions: b
|
|
1170
1170
|
}
|
|
1171
1171
|
});
|
|
1172
|
-
let
|
|
1172
|
+
let ie = e.client.adapter.unstable_queryParamsMapper(d.queryParams), ae = e.client.adapter.unstable_endpointMapper(d.endpoint), oe = e.client.adapter.unstable_headerMapper(d), { url: L } = e.client;
|
|
1173
1173
|
return {
|
|
1174
1174
|
request: d,
|
|
1175
1175
|
requestId: t,
|
|
1176
|
-
url:
|
|
1177
|
-
endpoint:
|
|
1178
|
-
queryParams:
|
|
1176
|
+
url: L,
|
|
1177
|
+
endpoint: ae,
|
|
1178
|
+
queryParams: ie,
|
|
1179
1179
|
payload: y,
|
|
1180
|
-
headers:
|
|
1180
|
+
headers: oe,
|
|
1181
1181
|
adapter: e.client.adapter,
|
|
1182
1182
|
adapterOptions: b,
|
|
1183
|
-
getAbortController:
|
|
1183
|
+
getAbortController: I,
|
|
1184
1184
|
getRequestStartTimestamp: S,
|
|
1185
1185
|
getResponseStartTimestamp: C,
|
|
1186
|
-
createAbortListener:
|
|
1186
|
+
createAbortListener: re,
|
|
1187
1187
|
onBeforeRequest: D,
|
|
1188
1188
|
onRequestStart: O,
|
|
1189
1189
|
onRequestProgress: k,
|
|
1190
1190
|
onRequestEnd: ee,
|
|
1191
1191
|
onResponseStart: A,
|
|
1192
1192
|
onResponseProgress: j,
|
|
1193
|
-
onResponseEnd:
|
|
1194
|
-
onSuccess:
|
|
1195
|
-
onAbortError:
|
|
1196
|
-
onTimeoutError:
|
|
1197
|
-
onUnexpectedError:
|
|
1198
|
-
onError:
|
|
1193
|
+
onResponseEnd: M,
|
|
1194
|
+
onSuccess: te,
|
|
1195
|
+
onAbortError: P,
|
|
1196
|
+
onTimeoutError: F,
|
|
1197
|
+
onUnexpectedError: ne,
|
|
1198
|
+
onError: N
|
|
1199
1199
|
};
|
|
1200
1200
|
};
|
|
1201
1201
|
function Xt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
@@ -1228,7 +1228,7 @@ function Xt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
|
1228
1228
|
};
|
|
1229
1229
|
}
|
|
1230
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
|
|
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
|
|
@@ -1321,8 +1321,8 @@ var Zt = 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,
|
|
@@ -1362,7 +1362,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1362
1362
|
} catch {
|
|
1363
1363
|
return e;
|
|
1364
1364
|
}
|
|
1365
|
-
}, tn = (e) => e ? en(e) :
|
|
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
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) => {
|
|
@@ -1492,7 +1492,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1492
1492
|
});
|
|
1493
1493
|
}
|
|
1494
1494
|
}), un = () => ln(), dn = class {
|
|
1495
|
-
emitter = new
|
|
1495
|
+
emitter = new Ne();
|
|
1496
1496
|
events;
|
|
1497
1497
|
storage;
|
|
1498
1498
|
lazyStorage;
|
|
@@ -1697,7 +1697,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1697
1697
|
onQueueChange: (t) => (e.on(En(), t), () => e.removeListener(En(), t)),
|
|
1698
1698
|
onQueueChangeByKey: (t, n) => (e.on(Dn(t), n), () => e.removeListener(Dn(t), n))
|
|
1699
1699
|
}), xn = class {
|
|
1700
|
-
emitter = new
|
|
1700
|
+
emitter = new Ne();
|
|
1701
1701
|
events = bn(this.emitter);
|
|
1702
1702
|
storage = /* @__PURE__ */ new Map();
|
|
1703
1703
|
requestCount = /* @__PURE__ */ new Map();
|
|
@@ -1940,7 +1940,7 @@ var Zt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1940
1940
|
}), this.incrementQueueRequestCount(l), f.addAbortController(u, n);
|
|
1941
1941
|
let b = await d.fetch(t, n);
|
|
1942
1942
|
e.resolved = !0, f.removeAbortController(u, n);
|
|
1943
|
-
let x = !m.isOnline, S =
|
|
1943
|
+
let x = !m.isOnline, S = 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,
|
|
@@ -2082,8 +2082,8 @@ var Mn = 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;
|
|
@@ -2094,12 +2094,12 @@ var Mn = async (e, t) => {
|
|
|
2094
2094
|
unstable_abortKeyMapper = Ht;
|
|
2095
2095
|
unstable_cacheKeyMapper = Ut;
|
|
2096
2096
|
unstable_queryKeyMapper = Ut;
|
|
2097
|
-
unstable_requestIdMapper =
|
|
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 = jn(o), this.adapter = un(), this.appManager = n?.() || new
|
|
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);
|
|
@@ -2136,7 +2136,7 @@ var Mn = async (e, t) => {
|
|
|
2136
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 dn(), this.appManager = e?.() || 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) => {
|
|
@@ -2183,7 +2183,7 @@ function In(e) {
|
|
|
2183
2183
|
}
|
|
2184
2184
|
//#endregion
|
|
2185
2185
|
//#region src/core/client.ts
|
|
2186
|
-
var K = In({ url:
|
|
2186
|
+
var K = In({ url: L() });
|
|
2187
2187
|
//#endregion
|
|
2188
2188
|
//#region src/core/auth-api.ts
|
|
2189
2189
|
async function Ln(e) {
|
|
@@ -2269,7 +2269,7 @@ function Qn(e) {
|
|
|
2269
2269
|
//#region src/core/login.ts
|
|
2270
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
2271
|
async function tr(e = {}) {
|
|
2272
|
-
let t = S(16).toString("hex"), n =
|
|
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);
|
|
@@ -2301,7 +2301,7 @@ async function tr(e = {}) {
|
|
|
2301
2301
|
}), r.on("error", (e) => {
|
|
2302
2302
|
o(), i(e);
|
|
2303
2303
|
}), r.listen(0, "127.0.0.1", () => {
|
|
2304
|
-
let { port: n } = r.address(), i = encodeURIComponent(Zn()), a = `${
|
|
2304
|
+
let { port: n } = r.address(), i = encodeURIComponent(Zn()), a = `${se()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
|
|
2305
2305
|
e.onUrl?.(a), Qn(a);
|
|
2306
2306
|
});
|
|
2307
2307
|
}), a = await Ln(i).catch(() => null), o = {
|
|
@@ -2319,7 +2319,7 @@ async function nr() {
|
|
|
2319
2319
|
s.log.step("Opening your browser to sign in...");
|
|
2320
2320
|
try {
|
|
2321
2321
|
let e = await tr({ onUrl: (e) => {
|
|
2322
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
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) {
|
|
@@ -2331,18 +2331,18 @@ async function rr(e) {
|
|
|
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) Qn(
|
|
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
|
|
@@ -2430,24 +2430,24 @@ 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
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
2442
|
if (!r) {
|
|
2443
|
-
s.log.step(
|
|
2443
|
+
s.log.step(B.muted(`Generating Prisma client (${B.command("prisma generate")})...`));
|
|
2444
2444
|
let e = await o("pnpm", [
|
|
2445
2445
|
"exec",
|
|
2446
2446
|
"prisma",
|
|
2447
2447
|
"generate"
|
|
2448
2448
|
], { cwd: l });
|
|
2449
2449
|
if (e.exitCode !== 0) {
|
|
2450
|
-
s.log.error(
|
|
2450
|
+
s.log.error(B.muted("prisma generate failed. See the output above, or finish setup manually:")), mr(e), fr(c);
|
|
2451
2451
|
return;
|
|
2452
2452
|
}
|
|
2453
2453
|
s.log.success("Prisma client generated");
|
|
@@ -2457,14 +2457,14 @@ async function pr(e) {
|
|
|
2457
2457
|
return;
|
|
2458
2458
|
}
|
|
2459
2459
|
let u = await s.confirm({
|
|
2460
|
-
message: `Run database setup now? (${
|
|
2460
|
+
message: `Run database setup now? (${B.command("prisma migrate dev")})`,
|
|
2461
2461
|
initialValue: !0
|
|
2462
2462
|
});
|
|
2463
2463
|
if (s.isCancel(u) || !u) {
|
|
2464
2464
|
fr(c);
|
|
2465
2465
|
return;
|
|
2466
2466
|
}
|
|
2467
|
-
s.log.step(
|
|
2467
|
+
s.log.step(B.muted(`Running ${B.command("prisma migrate dev --name add-packs")}...`));
|
|
2468
2468
|
let d = await o("pnpm", [
|
|
2469
2469
|
"exec",
|
|
2470
2470
|
"prisma",
|
|
@@ -2479,7 +2479,7 @@ async function pr(e) {
|
|
|
2479
2479
|
initialValue: !0
|
|
2480
2480
|
});
|
|
2481
2481
|
if (!s.isCancel(e) && e) {
|
|
2482
|
-
s.log.step(
|
|
2482
|
+
s.log.step(B.muted(`Resetting dev database (${B.command("prisma migrate reset --force")})...`));
|
|
2483
2483
|
let e = await o("pnpm", [
|
|
2484
2484
|
"exec",
|
|
2485
2485
|
"prisma",
|
|
@@ -2487,7 +2487,7 @@ async function pr(e) {
|
|
|
2487
2487
|
"reset",
|
|
2488
2488
|
"--force"
|
|
2489
2489
|
], { cwd: l });
|
|
2490
|
-
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", [
|
|
2491
2491
|
"exec",
|
|
2492
2492
|
"prisma",
|
|
2493
2493
|
"migrate",
|
|
@@ -2496,40 +2496,149 @@ async function pr(e) {
|
|
|
2496
2496
|
"add-packs"
|
|
2497
2497
|
], { cwd: l });
|
|
2498
2498
|
else {
|
|
2499
|
-
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);
|
|
2500
2500
|
return;
|
|
2501
2501
|
}
|
|
2502
2502
|
}
|
|
2503
2503
|
}
|
|
2504
2504
|
if (d.exitCode !== 0) {
|
|
2505
|
-
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);
|
|
2506
2506
|
return;
|
|
2507
2507
|
}
|
|
2508
2508
|
s.log.success("Database schema applied");
|
|
2509
2509
|
}
|
|
2510
2510
|
function mr(e) {
|
|
2511
2511
|
let t = (e.stderr || e.stdout).trim();
|
|
2512
|
-
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;
|
|
2513
2622
|
}
|
|
2514
2623
|
//#endregion
|
|
2515
2624
|
//#region src/core/stack-config.ts
|
|
2516
|
-
async function
|
|
2517
|
-
return sr(T.join(e,
|
|
2625
|
+
async function Or(e) {
|
|
2626
|
+
return sr(T.join(e, M));
|
|
2518
2627
|
}
|
|
2519
|
-
async function
|
|
2520
|
-
return J(T.join(e,
|
|
2628
|
+
async function kr(e) {
|
|
2629
|
+
return J(T.join(e, M));
|
|
2521
2630
|
}
|
|
2522
|
-
async function
|
|
2523
|
-
await cr(T.join(e,
|
|
2631
|
+
async function Ar(e, t) {
|
|
2632
|
+
await cr(T.join(e, M), t);
|
|
2524
2633
|
}
|
|
2525
|
-
async function
|
|
2634
|
+
async function jr(e) {
|
|
2526
2635
|
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([lr(t), lr(n)]);
|
|
2527
2636
|
return {
|
|
2528
2637
|
apps: r,
|
|
2529
2638
|
packages: i
|
|
2530
2639
|
};
|
|
2531
2640
|
}
|
|
2532
|
-
function
|
|
2641
|
+
function Mr(e) {
|
|
2533
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";
|
|
2534
2643
|
return {
|
|
2535
2644
|
backend: {
|
|
@@ -2563,23 +2672,23 @@ function yr(e) {
|
|
|
2563
2672
|
}
|
|
2564
2673
|
};
|
|
2565
2674
|
}
|
|
2566
|
-
function
|
|
2675
|
+
function Nr(e, t) {
|
|
2567
2676
|
return {
|
|
2568
|
-
$schema:
|
|
2677
|
+
$schema: le(),
|
|
2569
2678
|
version: 1,
|
|
2570
2679
|
name: e,
|
|
2571
2680
|
apps: t.apps,
|
|
2572
2681
|
packages: t.packages,
|
|
2573
|
-
paths:
|
|
2682
|
+
paths: Mr(t),
|
|
2574
2683
|
installedPacks: [],
|
|
2575
2684
|
licenseKey: null
|
|
2576
2685
|
};
|
|
2577
2686
|
}
|
|
2578
|
-
async function
|
|
2687
|
+
async function Pr(e) {
|
|
2579
2688
|
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t), ar(n)]);
|
|
2580
2689
|
return r && i;
|
|
2581
2690
|
}
|
|
2582
|
-
function
|
|
2691
|
+
function X(e, t) {
|
|
2583
2692
|
return e.replace(/\{\{(\w+)\.(\w+)\}\}/g, (n, r, i) => {
|
|
2584
2693
|
let a = t[r];
|
|
2585
2694
|
if (!a) throw Error(`Unknown app "${r}" in path template "${e}"`);
|
|
@@ -2590,7 +2699,7 @@ function Y(e, t) {
|
|
|
2590
2699
|
}
|
|
2591
2700
|
//#endregion
|
|
2592
2701
|
//#region src/core/registry.ts
|
|
2593
|
-
async function
|
|
2702
|
+
async function Fr(e) {
|
|
2594
2703
|
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
2595
2704
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2596
2705
|
method: "GET"
|
|
@@ -2599,7 +2708,7 @@ async function Sr(e) {
|
|
|
2599
2708
|
if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
|
|
2600
2709
|
return t;
|
|
2601
2710
|
}
|
|
2602
|
-
async function
|
|
2711
|
+
async function Ir(e, t = {}) {
|
|
2603
2712
|
let n = K.createRequest()({
|
|
2604
2713
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2605
2714
|
method: "POST"
|
|
@@ -2625,23 +2734,23 @@ async function Cr(e, t = {}) {
|
|
|
2625
2734
|
packDir: s
|
|
2626
2735
|
};
|
|
2627
2736
|
}
|
|
2628
|
-
function
|
|
2629
|
-
let r =
|
|
2737
|
+
function Lr(e, t, n) {
|
|
2738
|
+
let r = X(e, t);
|
|
2630
2739
|
return T.resolve(n, r);
|
|
2631
2740
|
}
|
|
2632
|
-
function
|
|
2741
|
+
function Rr(e, t) {
|
|
2633
2742
|
return T.join(t, e);
|
|
2634
2743
|
}
|
|
2635
|
-
var
|
|
2744
|
+
var zr = K.createRequest()({
|
|
2636
2745
|
endpoint: "/packs/list",
|
|
2637
2746
|
method: "GET"
|
|
2638
2747
|
});
|
|
2639
|
-
async function
|
|
2640
|
-
let { data: e, error: t } = await
|
|
2748
|
+
async function Br() {
|
|
2749
|
+
let { data: e, error: t } = await zr.send();
|
|
2641
2750
|
if (t || !e) throw Error(`Failed to fetch pack list: ${String(t)}`);
|
|
2642
2751
|
return e.packs;
|
|
2643
2752
|
}
|
|
2644
|
-
async function
|
|
2753
|
+
async function Vr(e, t = {}) {
|
|
2645
2754
|
if (e.length === 0) return {};
|
|
2646
2755
|
let n = K.createRequest()({
|
|
2647
2756
|
endpoint: "/packs/authorize",
|
|
@@ -2657,35 +2766,35 @@ async function Or(e, t = {}) {
|
|
|
2657
2766
|
}
|
|
2658
2767
|
//#endregion
|
|
2659
2768
|
//#region src/core/codemods.ts
|
|
2660
|
-
var
|
|
2661
|
-
function
|
|
2662
|
-
return
|
|
2769
|
+
var Hr = "@hype-stack/";
|
|
2770
|
+
function Ur(e, t) {
|
|
2771
|
+
return X(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
|
|
2663
2772
|
}
|
|
2664
|
-
async function
|
|
2665
|
-
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");
|
|
2666
2775
|
if (await J(i)) {
|
|
2667
2776
|
let t = await y.readFile(i, "utf-8");
|
|
2668
|
-
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));
|
|
2669
2778
|
await y.writeFile(i, t, "utf-8");
|
|
2670
2779
|
}
|
|
2671
2780
|
if (await J(a)) {
|
|
2672
2781
|
let t = await y.readFile(a, "utf-8");
|
|
2673
|
-
for (let n of e) t =
|
|
2782
|
+
for (let n of e) t = qr(t, n);
|
|
2674
2783
|
await y.writeFile(a, t, "utf-8");
|
|
2675
2784
|
}
|
|
2676
2785
|
if (await J(o)) {
|
|
2677
2786
|
let t = await y.readFile(o, "utf-8");
|
|
2678
|
-
for (let n of e) t =
|
|
2787
|
+
for (let n of e) t = Jr(t, n);
|
|
2679
2788
|
await y.writeFile(o, t, "utf-8");
|
|
2680
2789
|
}
|
|
2681
2790
|
}
|
|
2682
|
-
function
|
|
2791
|
+
function Gr(e, t) {
|
|
2683
2792
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2684
2793
|
if (r === -1) return n + "\n" + e;
|
|
2685
2794
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2686
2795
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2687
2796
|
}
|
|
2688
|
-
function
|
|
2797
|
+
function Kr(e, t) {
|
|
2689
2798
|
let n = `.extend(${t.import}.shape)`;
|
|
2690
2799
|
if (e.includes(n)) return e;
|
|
2691
2800
|
let r = e.indexOf("export const envSchema = z.object({");
|
|
@@ -2700,27 +2809,27 @@ function Nr(e, t) {
|
|
|
2700
2809
|
let o = a + 2;
|
|
2701
2810
|
return e.slice(0, o) + n + e.slice(o);
|
|
2702
2811
|
}
|
|
2703
|
-
function
|
|
2812
|
+
function qr(e, t) {
|
|
2704
2813
|
for (let n of Object.keys(t.envExample.vars)) if (e.includes(`${n}=`)) return e;
|
|
2705
2814
|
let n = [];
|
|
2706
|
-
n.push(""), n.push(`# ${t.envExample.section}`);
|
|
2815
|
+
n.push(""), n.push(`# ${hr[t.envExample.section]}`);
|
|
2707
2816
|
for (let [e, r] of Object.entries(t.envExample.vars)) n.push(`${e}=${r}`);
|
|
2708
2817
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2709
2818
|
}
|
|
2710
|
-
function
|
|
2819
|
+
function Jr(e, t) {
|
|
2711
2820
|
for (let n of Object.keys(t.envTest)) if (e.includes(`${n}=`)) return e;
|
|
2712
2821
|
let n = [""];
|
|
2713
2822
|
for (let [e, r] of Object.entries(t.envTest)) n.push(`${e}=${r}`);
|
|
2714
2823
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2715
2824
|
}
|
|
2716
|
-
async function
|
|
2717
|
-
let r = T.resolve(n,
|
|
2825
|
+
async function Yr(e, t, n) {
|
|
2826
|
+
let r = T.resolve(n, X("{{backend.routes}}", t), "index.ts");
|
|
2718
2827
|
if (!await J(r)) return;
|
|
2719
2828
|
let i = await y.readFile(r, "utf-8");
|
|
2720
|
-
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));
|
|
2721
2830
|
await y.writeFile(r, i, "utf-8");
|
|
2722
2831
|
}
|
|
2723
|
-
function
|
|
2832
|
+
function Xr(e, t) {
|
|
2724
2833
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2725
2834
|
if (r !== -1) {
|
|
2726
2835
|
let t = e.indexOf("\n", r);
|
|
@@ -2729,7 +2838,7 @@ function Lr(e, t) {
|
|
|
2729
2838
|
let i = e.indexOf("export const registerRoutes");
|
|
2730
2839
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2731
2840
|
}
|
|
2732
|
-
function
|
|
2841
|
+
function Zr(e, t) {
|
|
2733
2842
|
let n = `.route("${t.prefix}", ${t.import})`, r = e.match(/\.route\([^)]+\);/g);
|
|
2734
2843
|
if (r) {
|
|
2735
2844
|
let t = r[r.length - 1], i = e.lastIndexOf(t) + t.length - 1;
|
|
@@ -2737,14 +2846,14 @@ function Rr(e, t) {
|
|
|
2737
2846
|
}
|
|
2738
2847
|
return e.replace("return app;", `return app\n ${n};`);
|
|
2739
2848
|
}
|
|
2740
|
-
async function
|
|
2741
|
-
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");
|
|
2742
2851
|
if (!await J(r)) return;
|
|
2743
2852
|
let i = await y.readFile(r, "utf-8");
|
|
2744
|
-
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));
|
|
2745
2854
|
await y.writeFile(r, i, "utf-8");
|
|
2746
2855
|
}
|
|
2747
|
-
function
|
|
2856
|
+
function $r(e, t) {
|
|
2748
2857
|
let n = `import { ${t.typeImport.name} } from "${t.typeImport.from}";`;
|
|
2749
2858
|
if (e.includes(`from "${t.typeImport.from}"`)) return e;
|
|
2750
2859
|
let r = e.lastIndexOf("import ");
|
|
@@ -2752,7 +2861,7 @@ function Br(e, t) {
|
|
|
2752
2861
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2753
2862
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2754
2863
|
}
|
|
2755
|
-
function
|
|
2864
|
+
function ei(e, t) {
|
|
2756
2865
|
let n = `export let ${t.export}: ${t.type};`, r = e.lastIndexOf("export let ");
|
|
2757
2866
|
if (r === -1) {
|
|
2758
2867
|
let t = e.indexOf("export const setupContext");
|
|
@@ -2761,15 +2870,15 @@ function Vr(e, t) {
|
|
|
2761
2870
|
let i = e.indexOf("\n", r);
|
|
2762
2871
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2763
2872
|
}
|
|
2764
|
-
function
|
|
2873
|
+
function ti(e, t) {
|
|
2765
2874
|
let n = ` ${t.export} = ${t.init};`, r = e.match(/export const setupContext\s*=\s*async\s*\([^)]*\)\s*=>\s*\{/);
|
|
2766
2875
|
if (!r) return e;
|
|
2767
2876
|
let i = e.indexOf("{", e.indexOf(r[0]));
|
|
2768
2877
|
if (i === -1) return e;
|
|
2769
|
-
let a =
|
|
2878
|
+
let a = ni(e, i);
|
|
2770
2879
|
return a === -1 ? e : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2771
2880
|
}
|
|
2772
|
-
function
|
|
2881
|
+
function ni(e, t) {
|
|
2773
2882
|
let n = 0;
|
|
2774
2883
|
for (let r = t; r < e.length; r++) {
|
|
2775
2884
|
let t = e[r];
|
|
@@ -2778,20 +2887,20 @@ function Ur(e, t) {
|
|
|
2778
2887
|
}
|
|
2779
2888
|
return -1;
|
|
2780
2889
|
}
|
|
2781
|
-
function
|
|
2890
|
+
function ri(e, t) {
|
|
2782
2891
|
let n = ` ${t.export}: ${t.type};`, r = e.indexOf("export type ContextVariables = {");
|
|
2783
2892
|
if (r === -1) return e;
|
|
2784
2893
|
let i = e.indexOf("};", r);
|
|
2785
2894
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2786
2895
|
}
|
|
2787
|
-
async function
|
|
2788
|
-
let r = T.resolve(n,
|
|
2896
|
+
async function ii(e, t, n) {
|
|
2897
|
+
let r = T.resolve(n, X("{{enums.src}}", t), "index.ts");
|
|
2789
2898
|
if (!await J(r)) return;
|
|
2790
2899
|
let i = await y.readFile(r, "utf-8");
|
|
2791
|
-
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));
|
|
2792
2901
|
await y.writeFile(r, i, "utf-8");
|
|
2793
2902
|
}
|
|
2794
|
-
function
|
|
2903
|
+
function ai(e, t) {
|
|
2795
2904
|
let n = `export * from "${t.from}";`, r = e.lastIndexOf("export * from");
|
|
2796
2905
|
if (r !== -1) {
|
|
2797
2906
|
let t = e.indexOf("\n", r);
|
|
@@ -2799,14 +2908,14 @@ function Kr(e, t) {
|
|
|
2799
2908
|
}
|
|
2800
2909
|
return e.trim() === "" ? n + "\n" : e.trimEnd() + "\n" + n + "\n";
|
|
2801
2910
|
}
|
|
2802
|
-
async function
|
|
2803
|
-
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");
|
|
2804
2913
|
if (!await J(i)) return;
|
|
2805
2914
|
let a = await y.readFile(i, "utf-8");
|
|
2806
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2807
|
-
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");
|
|
2808
2917
|
}
|
|
2809
|
-
function
|
|
2918
|
+
function si(e, t) {
|
|
2810
2919
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2811
2920
|
if (r !== -1) {
|
|
2812
2921
|
let t = e.indexOf("\n", r);
|
|
@@ -2815,7 +2924,7 @@ function Jr(e, t) {
|
|
|
2815
2924
|
let i = e.indexOf("const sockets");
|
|
2816
2925
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2817
2926
|
}
|
|
2818
|
-
function
|
|
2927
|
+
function ci(e, t) {
|
|
2819
2928
|
let n = `.socket("${t.prefix}", ${t.import})`, r = e.indexOf("const sockets");
|
|
2820
2929
|
if (r === -1) return e;
|
|
2821
2930
|
let i = e.indexOf("new SocketRouter", r);
|
|
@@ -2829,7 +2938,7 @@ function Yr(e, t) {
|
|
|
2829
2938
|
}
|
|
2830
2939
|
return e;
|
|
2831
2940
|
}
|
|
2832
|
-
function
|
|
2941
|
+
function li(e) {
|
|
2833
2942
|
if (e.includes("wsAuthenticate")) return e;
|
|
2834
2943
|
let t = e.indexOf("from \"@backend/libs/websocket/socket-router\""), n = e;
|
|
2835
2944
|
if (t !== -1) {
|
|
@@ -2838,14 +2947,14 @@ function Xr(e) {
|
|
|
2838
2947
|
}
|
|
2839
2948
|
return n.replace("new SocketRouter()", "new SocketRouter({ authenticate: wsAuthenticate })");
|
|
2840
2949
|
}
|
|
2841
|
-
async function
|
|
2842
|
-
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");
|
|
2843
2952
|
if (!await J(i)) return;
|
|
2844
2953
|
let a = await y.readFile(i, "utf-8");
|
|
2845
|
-
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));
|
|
2846
2955
|
await y.writeFile(i, a, "utf-8");
|
|
2847
2956
|
}
|
|
2848
|
-
function
|
|
2957
|
+
function di(e, t) {
|
|
2849
2958
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2850
2959
|
if (e.includes(n)) return e;
|
|
2851
2960
|
let r = e.lastIndexOf("from \"./");
|
|
@@ -2856,20 +2965,20 @@ function Qr(e, t) {
|
|
|
2856
2965
|
let i = e.indexOf("export const sdk");
|
|
2857
2966
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2858
2967
|
}
|
|
2859
|
-
function
|
|
2968
|
+
function fi(e, t) {
|
|
2860
2969
|
let n = `.$configure(${t.import})`, r = e.indexOf("export const sdk");
|
|
2861
2970
|
if (r === -1) return e;
|
|
2862
2971
|
let i = e.indexOf(";", r);
|
|
2863
2972
|
return i === -1 ? e : e.slice(0, i) + "\n " + n + e.slice(i);
|
|
2864
2973
|
}
|
|
2865
|
-
async function
|
|
2866
|
-
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");
|
|
2867
2976
|
if (!await J(r)) return;
|
|
2868
2977
|
let i = await y.readFile(r, "utf-8");
|
|
2869
|
-
for (let t of e) i.includes(`"${t.path}"`) || (i =
|
|
2978
|
+
for (let t of e) i.includes(`"${t.path}"`) || (i = mi(i, t));
|
|
2870
2979
|
await y.writeFile(r, i, "utf-8");
|
|
2871
2980
|
}
|
|
2872
|
-
function
|
|
2981
|
+
function mi(e, t) {
|
|
2873
2982
|
let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
|
|
2874
2983
|
if (r === -1) return e;
|
|
2875
2984
|
let i = e.indexOf("{", r);
|
|
@@ -2885,38 +2994,38 @@ function ti(e, t) {
|
|
|
2885
2994
|
}
|
|
2886
2995
|
return o === -1 ? e : e.slice(0, o) + n + "\n" + e.slice(o);
|
|
2887
2996
|
}
|
|
2888
|
-
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 = {
|
|
2889
2998
|
primary: "primaryNav",
|
|
2890
2999
|
secondary: "secondaryNav",
|
|
2891
3000
|
tertiary: "tertiaryNav",
|
|
2892
3001
|
settings: "settingsNav"
|
|
2893
3002
|
};
|
|
2894
|
-
async function
|
|
2895
|
-
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2896
|
-
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s =
|
|
2897
|
-
for (let e of t) s.includes(`label: "${e.label}"`) || (s =
|
|
2898
|
-
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));
|
|
2899
3008
|
await y.writeFile(o, s, "utf-8");
|
|
2900
3009
|
}
|
|
2901
|
-
async function
|
|
2902
|
-
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");
|
|
2903
3012
|
if (!await J(o)) return;
|
|
2904
3013
|
let s = await y.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
|
|
2905
3014
|
if (!c.test(s)) return;
|
|
2906
3015
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
2907
3016
|
await y.writeFile(o, l, "utf-8");
|
|
2908
3017
|
}
|
|
2909
|
-
function
|
|
3018
|
+
function yi(e) {
|
|
2910
3019
|
let t = [e.icon];
|
|
2911
3020
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
2912
3021
|
return t;
|
|
2913
3022
|
}
|
|
2914
|
-
function
|
|
2915
|
-
let n =
|
|
2916
|
-
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);
|
|
2917
3026
|
return r;
|
|
2918
3027
|
}
|
|
2919
|
-
function
|
|
3028
|
+
function xi(e, t) {
|
|
2920
3029
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
2921
3030
|
if (!n) return e;
|
|
2922
3031
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -2924,21 +3033,21 @@ function ci(e, t) {
|
|
|
2924
3033
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
2925
3034
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
2926
3035
|
}
|
|
2927
|
-
function
|
|
2928
|
-
let n =
|
|
3036
|
+
function Si(e, t) {
|
|
3037
|
+
let n = gi[t.group];
|
|
2929
3038
|
if (!n) return e;
|
|
2930
|
-
let r =
|
|
3039
|
+
let r = wi(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
|
|
2931
3040
|
if (!a) return e;
|
|
2932
|
-
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);
|
|
2933
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);
|
|
2934
3043
|
}
|
|
2935
|
-
function
|
|
3044
|
+
function Ci(e, t) {
|
|
2936
3045
|
let n = 0;
|
|
2937
3046
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2938
3047
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2939
3048
|
return -1;
|
|
2940
3049
|
}
|
|
2941
|
-
function
|
|
3050
|
+
function wi(e) {
|
|
2942
3051
|
let t = [];
|
|
2943
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) {
|
|
2944
3053
|
t.push(" items: [");
|
|
@@ -2954,14 +3063,14 @@ function di(e) {
|
|
|
2954
3063
|
} else t.push(" items: [],");
|
|
2955
3064
|
return t.push(" },"), t.join("\n");
|
|
2956
3065
|
}
|
|
2957
|
-
async function
|
|
2958
|
-
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");
|
|
2959
3068
|
if (!await J(i)) return;
|
|
2960
3069
|
let a = await y.readFile(i, "utf-8");
|
|
2961
|
-
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));
|
|
2962
3071
|
await y.writeFile(i, a, "utf-8");
|
|
2963
3072
|
}
|
|
2964
|
-
function
|
|
3073
|
+
function Ei(e, t) {
|
|
2965
3074
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2966
3075
|
if (r !== -1) {
|
|
2967
3076
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -2969,38 +3078,38 @@ function pi(e, t) {
|
|
|
2969
3078
|
}
|
|
2970
3079
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
2971
3080
|
}
|
|
2972
|
-
function
|
|
3081
|
+
function Di(e, t) {
|
|
2973
3082
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
2974
3083
|
if (!r) return e;
|
|
2975
|
-
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);
|
|
2976
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);
|
|
2977
3086
|
}
|
|
2978
|
-
function
|
|
3087
|
+
function Oi(e, t) {
|
|
2979
3088
|
let n = 0;
|
|
2980
3089
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2981
3090
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2982
3091
|
return -1;
|
|
2983
3092
|
}
|
|
2984
|
-
var
|
|
2985
|
-
async function
|
|
2986
|
-
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({
|
|
2987
3096
|
...e,
|
|
2988
3097
|
arrayName: "navbarActions"
|
|
2989
3098
|
});
|
|
2990
3099
|
}
|
|
2991
|
-
async function
|
|
2992
|
-
await
|
|
3100
|
+
async function ji(e) {
|
|
3101
|
+
await Mi({
|
|
2993
3102
|
...e,
|
|
2994
3103
|
arrayName: "userMenuActions"
|
|
2995
3104
|
});
|
|
2996
3105
|
}
|
|
2997
|
-
async function
|
|
2998
|
-
let a =
|
|
2999
|
-
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s =
|
|
3000
|
-
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);
|
|
3001
3110
|
await y.writeFile(o, s, "utf-8");
|
|
3002
3111
|
}
|
|
3003
|
-
function
|
|
3112
|
+
function Ni(e, t) {
|
|
3004
3113
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
3005
3114
|
if (e.includes(n)) return e;
|
|
3006
3115
|
let r = e.lastIndexOf("import ");
|
|
@@ -3008,38 +3117,38 @@ function bi(e, t) {
|
|
|
3008
3117
|
let i = e.indexOf("\n", r);
|
|
3009
3118
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
3010
3119
|
}
|
|
3011
|
-
function
|
|
3120
|
+
function Pi(e, t, n) {
|
|
3012
3121
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
3013
3122
|
if (!r) return e;
|
|
3014
|
-
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);
|
|
3015
3124
|
if (a === -1) return e;
|
|
3016
3125
|
let o = e.slice(i, a);
|
|
3017
3126
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
3018
3127
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
3019
3128
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
3020
3129
|
}
|
|
3021
|
-
function
|
|
3130
|
+
function Fi(e, t) {
|
|
3022
3131
|
let n = 0;
|
|
3023
3132
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
3024
3133
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
3025
3134
|
return -1;
|
|
3026
3135
|
}
|
|
3027
|
-
var
|
|
3136
|
+
var Ii = new Set([
|
|
3028
3137
|
".ts",
|
|
3029
3138
|
".tsx",
|
|
3030
3139
|
".js",
|
|
3031
3140
|
".jsx"
|
|
3032
3141
|
]);
|
|
3033
|
-
async function
|
|
3142
|
+
async function Li(e) {
|
|
3034
3143
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
3035
3144
|
if (i === "hype-stack") return;
|
|
3036
3145
|
let a = `@${i}/`;
|
|
3037
3146
|
await Promise.all(t.map(async (e) => {
|
|
3038
|
-
let t =
|
|
3039
|
-
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);
|
|
3040
3149
|
}));
|
|
3041
3150
|
}
|
|
3042
|
-
var
|
|
3151
|
+
var Ri = new Set([
|
|
3043
3152
|
".git",
|
|
3044
3153
|
"node_modules",
|
|
3045
3154
|
"dist",
|
|
@@ -3048,43 +3157,43 @@ var Ti = new Set([
|
|
|
3048
3157
|
".next",
|
|
3049
3158
|
"coverage"
|
|
3050
3159
|
]);
|
|
3051
|
-
async function
|
|
3052
|
-
t !== "hype-stack" && await
|
|
3160
|
+
async function zi(e, t) {
|
|
3161
|
+
t !== "hype-stack" && await Bi(e, `@${t}/`);
|
|
3053
3162
|
}
|
|
3054
|
-
async function
|
|
3163
|
+
async function Bi(e, t) {
|
|
3055
3164
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3056
3165
|
await Promise.all(n.map(async (n) => {
|
|
3057
3166
|
let r = T.join(e, n.name);
|
|
3058
3167
|
if (n.isDirectory()) {
|
|
3059
|
-
if (
|
|
3060
|
-
await
|
|
3061
|
-
} 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);
|
|
3062
3171
|
}));
|
|
3063
3172
|
}
|
|
3064
|
-
async function
|
|
3173
|
+
async function Vi(e, t) {
|
|
3065
3174
|
let n = await y.readFile(e, "utf-8");
|
|
3066
|
-
if (!n.includes(
|
|
3067
|
-
let r = n.replaceAll(
|
|
3175
|
+
if (!n.includes(Hr)) return;
|
|
3176
|
+
let r = n.replaceAll(Hr, t);
|
|
3068
3177
|
await y.writeFile(e, r, "utf-8");
|
|
3069
3178
|
}
|
|
3070
3179
|
//#endregion
|
|
3071
3180
|
//#region src/core/installer.ts
|
|
3072
|
-
function
|
|
3181
|
+
function Hi(e, t) {
|
|
3073
3182
|
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3074
3183
|
}
|
|
3075
|
-
async function
|
|
3184
|
+
async function Ui(e, t) {
|
|
3076
3185
|
if ((await y.stat(e)).isDirectory()) {
|
|
3077
3186
|
await y.mkdir(t, { recursive: !0 });
|
|
3078
3187
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3079
|
-
for (let r of n) await
|
|
3188
|
+
for (let r of n) await Ui(T.join(e, r.name), T.join(t, r.name));
|
|
3080
3189
|
} else await y.mkdir(T.dirname(t), { recursive: !0 }), await y.copyFile(e, t);
|
|
3081
3190
|
}
|
|
3082
|
-
async function
|
|
3191
|
+
async function Wi(e) {
|
|
3083
3192
|
let { src: t, dest: n, projectRoot: r, skip: i } = e;
|
|
3084
3193
|
if ((await y.stat(t)).isDirectory()) {
|
|
3085
3194
|
await y.mkdir(n, { recursive: !0 });
|
|
3086
3195
|
let e = await y.readdir(t, { withFileTypes: !0 });
|
|
3087
|
-
return (await Promise.all(e.map((e) =>
|
|
3196
|
+
return (await Promise.all(e.map((e) => Wi({
|
|
3088
3197
|
src: T.join(t, e.name),
|
|
3089
3198
|
dest: T.join(n, e.name),
|
|
3090
3199
|
projectRoot: r,
|
|
@@ -3093,8 +3202,8 @@ async function ji(e) {
|
|
|
3093
3202
|
}
|
|
3094
3203
|
return i.has(t) ? [] : (await y.mkdir(T.dirname(n), { recursive: !0 }), await y.copyFile(t, n), [T.relative(r, n)]);
|
|
3095
3204
|
}
|
|
3096
|
-
async function
|
|
3097
|
-
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);
|
|
3098
3207
|
return {
|
|
3099
3208
|
sourcePath: a,
|
|
3100
3209
|
targetPath: o,
|
|
@@ -3102,8 +3211,8 @@ async function Mi(e) {
|
|
|
3102
3211
|
targetExists: await J(o) || await ar(o)
|
|
3103
3212
|
};
|
|
3104
3213
|
}
|
|
3105
|
-
async function
|
|
3106
|
-
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({
|
|
3107
3216
|
file: t,
|
|
3108
3217
|
packDir: n,
|
|
3109
3218
|
paths: r,
|
|
@@ -3118,8 +3227,8 @@ async function Ni(e) {
|
|
|
3118
3227
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3119
3228
|
}
|
|
3120
3229
|
}
|
|
3121
|
-
async function
|
|
3122
|
-
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({
|
|
3123
3232
|
file: t,
|
|
3124
3233
|
packDir: n,
|
|
3125
3234
|
paths: r,
|
|
@@ -3137,7 +3246,7 @@ async function Pi(e) {
|
|
|
3137
3246
|
status: "skipped",
|
|
3138
3247
|
path: t.target,
|
|
3139
3248
|
reason: "Already exists"
|
|
3140
|
-
} : (await
|
|
3249
|
+
} : (await Ui(s, c), {
|
|
3141
3250
|
status: "installed",
|
|
3142
3251
|
path: t.target
|
|
3143
3252
|
});
|
|
@@ -3146,16 +3255,16 @@ async function Pi(e) {
|
|
|
3146
3255
|
status: "skipped",
|
|
3147
3256
|
path: t.target,
|
|
3148
3257
|
reason: "Already exists (skip-if-exists)"
|
|
3149
|
-
} : (await
|
|
3258
|
+
} : (await Ui(s, c), {
|
|
3150
3259
|
status: "installed",
|
|
3151
3260
|
path: t.target
|
|
3152
3261
|
});
|
|
3153
|
-
case "override": return await
|
|
3262
|
+
case "override": return await Ui(s, c), {
|
|
3154
3263
|
status: "installed",
|
|
3155
3264
|
path: t.target
|
|
3156
3265
|
};
|
|
3157
3266
|
case "merge": {
|
|
3158
|
-
if (!u) return await
|
|
3267
|
+
if (!u) return await Ui(s, c), {
|
|
3159
3268
|
status: "installed",
|
|
3160
3269
|
path: t.target
|
|
3161
3270
|
};
|
|
@@ -3185,15 +3294,15 @@ async function Pi(e) {
|
|
|
3185
3294
|
};
|
|
3186
3295
|
}
|
|
3187
3296
|
}
|
|
3188
|
-
async function
|
|
3297
|
+
async function Ji(e) {
|
|
3189
3298
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3190
3299
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3191
3300
|
let o = [], s = /* @__PURE__ */ new Set();
|
|
3192
3301
|
for (let e of t) {
|
|
3193
3302
|
let t = i?.get(e.manifest.name);
|
|
3194
3303
|
for (let n of e.manifest.files) {
|
|
3195
|
-
if (n.strategy !== "create" || !
|
|
3196
|
-
let { targetPath: i, targetExists: c } = await
|
|
3304
|
+
if (n.strategy !== "create" || !Hi(n, t)) continue;
|
|
3305
|
+
let { targetPath: i, targetExists: c } = await Gi({
|
|
3197
3306
|
file: n,
|
|
3198
3307
|
packDir: e.packDir,
|
|
3199
3308
|
paths: a,
|
|
@@ -3208,13 +3317,13 @@ async function Fi(e) {
|
|
|
3208
3317
|
}
|
|
3209
3318
|
return o;
|
|
3210
3319
|
}
|
|
3211
|
-
async function
|
|
3320
|
+
async function Yi(e) {
|
|
3212
3321
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3213
3322
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3214
3323
|
let c = [];
|
|
3215
3324
|
for (let e of t.files) {
|
|
3216
|
-
if (!
|
|
3217
|
-
let t = await
|
|
3325
|
+
if (!Hi(e, o)) continue;
|
|
3326
|
+
let t = await Ki({
|
|
3218
3327
|
file: e,
|
|
3219
3328
|
packDir: a,
|
|
3220
3329
|
paths: s,
|
|
@@ -3225,16 +3334,16 @@ async function Ii(e) {
|
|
|
3225
3334
|
}
|
|
3226
3335
|
return c;
|
|
3227
3336
|
}
|
|
3228
|
-
async function
|
|
3337
|
+
async function Xi(e) {
|
|
3229
3338
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3230
3339
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3231
3340
|
let l = {
|
|
3232
3341
|
installed: [],
|
|
3233
3342
|
skipped: [],
|
|
3234
3343
|
errors: []
|
|
3235
|
-
}, u = t.files.filter((e) =>
|
|
3344
|
+
}, u = t.files.filter((e) => Hi(e, s));
|
|
3236
3345
|
for (let e of u) {
|
|
3237
|
-
let t = await
|
|
3346
|
+
let t = await qi({
|
|
3238
3347
|
file: e,
|
|
3239
3348
|
packDir: o,
|
|
3240
3349
|
paths: c,
|
|
@@ -3254,40 +3363,40 @@ async function Li(e) {
|
|
|
3254
3363
|
break;
|
|
3255
3364
|
}
|
|
3256
3365
|
}
|
|
3257
|
-
await
|
|
3366
|
+
await Li({
|
|
3258
3367
|
files: u,
|
|
3259
3368
|
paths: c,
|
|
3260
3369
|
projectRoot: r,
|
|
3261
3370
|
projectName: n.name
|
|
3262
|
-
}), 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);
|
|
3263
3372
|
let d = s && s.length > 0 ? s : ["frontend"];
|
|
3264
|
-
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({
|
|
3265
3374
|
entries: t.nav,
|
|
3266
3375
|
paths: c,
|
|
3267
3376
|
projectRoot: r,
|
|
3268
3377
|
slot: e
|
|
3269
|
-
}), t.navbarActions && t.navbarActions.length > 0 && await
|
|
3378
|
+
}), t.navbarActions && t.navbarActions.length > 0 && await Ai({
|
|
3270
3379
|
actions: t.navbarActions,
|
|
3271
3380
|
paths: c,
|
|
3272
3381
|
projectRoot: r,
|
|
3273
3382
|
slot: e
|
|
3274
|
-
}), t.userMenuActions && t.userMenuActions.length > 0 && await
|
|
3383
|
+
}), t.userMenuActions && t.userMenuActions.length > 0 && await ji({
|
|
3275
3384
|
actions: t.userMenuActions,
|
|
3276
3385
|
paths: c,
|
|
3277
3386
|
projectRoot: r,
|
|
3278
3387
|
slot: e
|
|
3279
3388
|
});
|
|
3280
|
-
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({
|
|
3281
3390
|
postLoginRedirect: t.postLoginRedirect,
|
|
3282
3391
|
paths: c,
|
|
3283
3392
|
projectRoot: r,
|
|
3284
3393
|
slot: d[0]
|
|
3285
3394
|
}), l;
|
|
3286
3395
|
}
|
|
3287
|
-
async function
|
|
3396
|
+
async function Zi(e) {
|
|
3288
3397
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3289
3398
|
for (let e of t) {
|
|
3290
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3399
|
+
let t = o?.get(e.manifest.name), a = await Yi({
|
|
3291
3400
|
manifest: e.manifest,
|
|
3292
3401
|
config: n,
|
|
3293
3402
|
projectRoot: r,
|
|
@@ -3307,7 +3416,7 @@ async function Ri(e) {
|
|
|
3307
3416
|
};
|
|
3308
3417
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3309
3418
|
for (let e of t) {
|
|
3310
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3419
|
+
let t = o?.get(e.manifest.name), n = await Xi({
|
|
3311
3420
|
manifest: e.manifest,
|
|
3312
3421
|
config: f,
|
|
3313
3422
|
projectRoot: r,
|
|
@@ -3316,7 +3425,7 @@ async function Ri(e) {
|
|
|
3316
3425
|
packDir: e.packDir,
|
|
3317
3426
|
slots: t
|
|
3318
3427
|
});
|
|
3319
|
-
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);
|
|
3320
3429
|
}
|
|
3321
3430
|
return {
|
|
3322
3431
|
installed: c,
|
|
@@ -3327,24 +3436,28 @@ async function Ri(e) {
|
|
|
3327
3436
|
config: f
|
|
3328
3437
|
};
|
|
3329
3438
|
}
|
|
3330
|
-
async function
|
|
3331
|
-
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 = {
|
|
3332
3441
|
...e,
|
|
3333
|
-
installedPacks: [...e.installedPacks ?? [],
|
|
3442
|
+
installedPacks: [...e.installedPacks ?? [], r],
|
|
3443
|
+
onboarding: {
|
|
3444
|
+
...e.onboarding,
|
|
3445
|
+
envSections: a
|
|
3446
|
+
}
|
|
3334
3447
|
};
|
|
3335
|
-
return await
|
|
3448
|
+
return await Ar(n, o), o;
|
|
3336
3449
|
}
|
|
3337
|
-
async function
|
|
3450
|
+
async function $i(e) {
|
|
3338
3451
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3339
3452
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3340
|
-
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) =>
|
|
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");
|
|
3341
3454
|
if (await ar(u)) {
|
|
3342
3455
|
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3343
3456
|
for (let t of e) {
|
|
3344
3457
|
if (!t.isDirectory()) continue;
|
|
3345
3458
|
let e = a[t.name]?.root;
|
|
3346
3459
|
if (!e) continue;
|
|
3347
|
-
let n = await
|
|
3460
|
+
let n = await Wi({
|
|
3348
3461
|
src: T.join(u, t.name),
|
|
3349
3462
|
dest: T.resolve(r, e),
|
|
3350
3463
|
projectRoot: r,
|
|
@@ -3354,7 +3467,7 @@ async function Bi(e) {
|
|
|
3354
3467
|
}
|
|
3355
3468
|
}
|
|
3356
3469
|
for (let e of c) {
|
|
3357
|
-
let t = await
|
|
3470
|
+
let t = await qi({
|
|
3358
3471
|
file: e,
|
|
3359
3472
|
packDir: i,
|
|
3360
3473
|
paths: a,
|
|
@@ -3364,12 +3477,12 @@ async function Bi(e) {
|
|
|
3364
3477
|
});
|
|
3365
3478
|
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3366
3479
|
}
|
|
3367
|
-
let d = T.join(
|
|
3368
|
-
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({
|
|
3369
3482
|
entries: t.nav,
|
|
3370
3483
|
paths: a,
|
|
3371
3484
|
projectRoot: r
|
|
3372
|
-
}), t.postLoginRedirect && await
|
|
3485
|
+
}), t.postLoginRedirect && await vi({
|
|
3373
3486
|
postLoginRedirect: t.postLoginRedirect,
|
|
3374
3487
|
paths: a,
|
|
3375
3488
|
projectRoot: r
|
|
@@ -3380,32 +3493,32 @@ async function Bi(e) {
|
|
|
3380
3493
|
}
|
|
3381
3494
|
//#endregion
|
|
3382
3495
|
//#region src/core/pack-categories.ts
|
|
3383
|
-
var
|
|
3496
|
+
var ea = [
|
|
3384
3497
|
"starter",
|
|
3385
3498
|
"layout",
|
|
3386
3499
|
"feature"
|
|
3387
|
-
],
|
|
3500
|
+
], ta = {
|
|
3388
3501
|
starter: "Starter",
|
|
3389
3502
|
layout: "Layout",
|
|
3390
3503
|
feature: "Features"
|
|
3391
|
-
},
|
|
3392
|
-
function
|
|
3504
|
+
}, na = new Set(["starter", "layout"]), ra = "starter-saas-betterauth", ia = "layout-basic";
|
|
3505
|
+
function aa(e, t = {}) {
|
|
3393
3506
|
let n = [];
|
|
3394
|
-
for (let r of
|
|
3507
|
+
for (let r of ea) {
|
|
3395
3508
|
let i = e.filter((e) => e.category === r);
|
|
3396
3509
|
if (i.length === 0) continue;
|
|
3397
|
-
let a =
|
|
3510
|
+
let a = na.has(r) ? "single" : "multiple";
|
|
3398
3511
|
if (r === "layout") {
|
|
3399
|
-
n.push(
|
|
3512
|
+
n.push(sa("frontend", i)), t.adminAvailable && n.push(sa("admin", i));
|
|
3400
3513
|
continue;
|
|
3401
3514
|
}
|
|
3402
3515
|
if (r === "starter") {
|
|
3403
|
-
n.push(
|
|
3516
|
+
n.push(oa(i));
|
|
3404
3517
|
continue;
|
|
3405
3518
|
}
|
|
3406
3519
|
n.push({
|
|
3407
3520
|
category: r,
|
|
3408
|
-
label:
|
|
3521
|
+
label: ta[r],
|
|
3409
3522
|
mode: a,
|
|
3410
3523
|
packs: i,
|
|
3411
3524
|
preselect: null
|
|
@@ -3413,49 +3526,49 @@ function Ki(e, t = {}) {
|
|
|
3413
3526
|
}
|
|
3414
3527
|
return n;
|
|
3415
3528
|
}
|
|
3416
|
-
function
|
|
3417
|
-
let t = e.some((e) => e.name ===
|
|
3529
|
+
function oa(e) {
|
|
3530
|
+
let t = e.some((e) => e.name === ra);
|
|
3418
3531
|
return {
|
|
3419
3532
|
category: "starter",
|
|
3420
|
-
label:
|
|
3533
|
+
label: ta.starter,
|
|
3421
3534
|
mode: "single",
|
|
3422
3535
|
packs: e,
|
|
3423
|
-
preselect: t ?
|
|
3536
|
+
preselect: t ? ra : null
|
|
3424
3537
|
};
|
|
3425
3538
|
}
|
|
3426
|
-
function
|
|
3427
|
-
let n = t.some((e) => e.name ===
|
|
3539
|
+
function sa(e, t) {
|
|
3540
|
+
let n = t.some((e) => e.name === ia);
|
|
3428
3541
|
return {
|
|
3429
3542
|
category: "layout",
|
|
3430
3543
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3431
3544
|
mode: "single",
|
|
3432
3545
|
packs: t,
|
|
3433
|
-
preselect: n ?
|
|
3546
|
+
preselect: n ? ia : null,
|
|
3434
3547
|
slot: e
|
|
3435
3548
|
};
|
|
3436
3549
|
}
|
|
3437
3550
|
//#endregion
|
|
3438
3551
|
//#region src/ui/logger.ts
|
|
3439
|
-
function
|
|
3440
|
-
s.note(e.map((e) => `${
|
|
3552
|
+
function ca(e) {
|
|
3553
|
+
s.note(e.map((e) => `${V.arrow} ${e}`).join("\n"), "Next steps");
|
|
3441
3554
|
}
|
|
3442
|
-
function
|
|
3443
|
-
s.cancel(
|
|
3555
|
+
function Z() {
|
|
3556
|
+
s.cancel(B.muted("Operation cancelled.")), process.exit(0);
|
|
3444
3557
|
}
|
|
3445
3558
|
//#endregion
|
|
3446
3559
|
//#region src/core/post-setup.ts
|
|
3447
|
-
async function
|
|
3560
|
+
async function la() {
|
|
3448
3561
|
return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3449
3562
|
}
|
|
3450
|
-
async function
|
|
3563
|
+
async function ua(e) {
|
|
3451
3564
|
return J(`${e}/apps/backend/.env`);
|
|
3452
3565
|
}
|
|
3453
|
-
async function
|
|
3454
|
-
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({
|
|
3455
3568
|
message: r,
|
|
3456
3569
|
initialValue: !0
|
|
3457
3570
|
});
|
|
3458
|
-
if (s.isCancel(i) &&
|
|
3571
|
+
if (s.isCancel(i) && Z(), !i) return s.log.info(B.muted("Skipping Docker services and database migrations.")), !1;
|
|
3459
3572
|
let a = s.spinner();
|
|
3460
3573
|
a.start("Starting Docker services...");
|
|
3461
3574
|
let o = await q("docker", [
|
|
@@ -3463,13 +3576,13 @@ async function Qi(e, t, n) {
|
|
|
3463
3576
|
"up",
|
|
3464
3577
|
"-d"
|
|
3465
3578
|
], { cwd: `${e}/apps/backend` });
|
|
3466
|
-
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);
|
|
3467
3580
|
}
|
|
3468
|
-
function
|
|
3581
|
+
function fa(e) {
|
|
3469
3582
|
let t = (e.stderr || e.stdout).trim();
|
|
3470
|
-
t && s.log.warn(
|
|
3583
|
+
t && s.log.warn(B.muted(t));
|
|
3471
3584
|
}
|
|
3472
|
-
async function
|
|
3585
|
+
async function pa(e, t = 15, n = 2e3) {
|
|
3473
3586
|
for (let r = 0; r < t; r++) {
|
|
3474
3587
|
if ((await q("docker", [
|
|
3475
3588
|
"compose",
|
|
@@ -3484,8 +3597,8 @@ async function ea(e, t = 15, n = 2e3) {
|
|
|
3484
3597
|
}
|
|
3485
3598
|
return !1;
|
|
3486
3599
|
}
|
|
3487
|
-
var
|
|
3488
|
-
async function
|
|
3600
|
+
var ma = "Database schema is up to date";
|
|
3601
|
+
async function ha(e) {
|
|
3489
3602
|
let t = await q("pnpm", [
|
|
3490
3603
|
"--filter",
|
|
3491
3604
|
"@internal/backend",
|
|
@@ -3494,9 +3607,9 @@ async function na(e) {
|
|
|
3494
3607
|
"migrate",
|
|
3495
3608
|
"status"
|
|
3496
3609
|
], { cwd: e });
|
|
3497
|
-
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(
|
|
3610
|
+
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(ma) : !1;
|
|
3498
3611
|
}
|
|
3499
|
-
async function
|
|
3612
|
+
async function ga(e) {
|
|
3500
3613
|
let t = s.spinner();
|
|
3501
3614
|
t.start("Running database migrations...");
|
|
3502
3615
|
let n = await q("pnpm", [
|
|
@@ -3504,38 +3617,38 @@ async function ra(e) {
|
|
|
3504
3617
|
"@internal/backend",
|
|
3505
3618
|
"migration:latest"
|
|
3506
3619
|
], { cwd: e });
|
|
3507
|
-
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);
|
|
3508
3621
|
}
|
|
3509
|
-
async function
|
|
3510
|
-
if (!await
|
|
3622
|
+
async function _a(e, t, n = {}) {
|
|
3623
|
+
if (!await da(e, t, await la())) return !1;
|
|
3511
3624
|
let r = s.spinner();
|
|
3512
|
-
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);
|
|
3513
3626
|
}
|
|
3514
|
-
async function
|
|
3515
|
-
if (!await
|
|
3627
|
+
async function va(e, t, n = {}) {
|
|
3628
|
+
if (!await _a(e, t, n)) return;
|
|
3516
3629
|
let r = t ? !0 : await s.confirm({
|
|
3517
|
-
message: `Run database migrations with ${
|
|
3630
|
+
message: `Run database migrations with ${B.command("prisma migrate deploy")}?`,
|
|
3518
3631
|
initialValue: !0
|
|
3519
3632
|
});
|
|
3520
|
-
if (s.isCancel(r) &&
|
|
3521
|
-
s.log.info(
|
|
3633
|
+
if (s.isCancel(r) && Z(), !r) {
|
|
3634
|
+
s.log.info(B.muted("Skipping database migrations."));
|
|
3522
3635
|
return;
|
|
3523
3636
|
}
|
|
3524
|
-
await
|
|
3637
|
+
await ga(e);
|
|
3525
3638
|
}
|
|
3526
|
-
async function
|
|
3527
|
-
if (!await
|
|
3528
|
-
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.`);
|
|
3529
3642
|
return;
|
|
3530
3643
|
}
|
|
3531
|
-
await
|
|
3644
|
+
await va(e, t, n);
|
|
3532
3645
|
}
|
|
3533
|
-
async function
|
|
3534
|
-
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);
|
|
3535
3648
|
}
|
|
3536
3649
|
//#endregion
|
|
3537
3650
|
//#region src/core/resolve.ts
|
|
3538
|
-
function
|
|
3651
|
+
function xa(e) {
|
|
3539
3652
|
let t = /* @__PURE__ */ new Map();
|
|
3540
3653
|
for (let n of e) t.set(n.name, {
|
|
3541
3654
|
name: n.name,
|
|
@@ -3543,7 +3656,7 @@ function ca(e) {
|
|
|
3543
3656
|
});
|
|
3544
3657
|
return t;
|
|
3545
3658
|
}
|
|
3546
|
-
function
|
|
3659
|
+
function Sa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3547
3660
|
let r = /* @__PURE__ */ new Set();
|
|
3548
3661
|
function i(e) {
|
|
3549
3662
|
if (n.has(e)) return [];
|
|
@@ -3557,10 +3670,10 @@ function la(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3557
3670
|
}
|
|
3558
3671
|
return i(e);
|
|
3559
3672
|
}
|
|
3560
|
-
function
|
|
3673
|
+
function Ca(e, t, n = []) {
|
|
3561
3674
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3562
3675
|
for (let n of e) {
|
|
3563
|
-
let e =
|
|
3676
|
+
let e = Sa(n, t, new Set(i));
|
|
3564
3677
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3565
3678
|
}
|
|
3566
3679
|
return {
|
|
@@ -3568,7 +3681,7 @@ function ua(e, t, n = []) {
|
|
|
3568
3681
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3569
3682
|
};
|
|
3570
3683
|
}
|
|
3571
|
-
function
|
|
3684
|
+
function wa(e) {
|
|
3572
3685
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3573
3686
|
for (let e of t) {
|
|
3574
3687
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3581,7 +3694,7 @@ function da(e) {
|
|
|
3581
3694
|
}
|
|
3582
3695
|
//#endregion
|
|
3583
3696
|
//#region src/core/variants.ts
|
|
3584
|
-
function
|
|
3697
|
+
function Ta(e, t = {}) {
|
|
3585
3698
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3586
3699
|
for (let i of e) {
|
|
3587
3700
|
let e = t[i.family] ?? i.default;
|
|
@@ -3593,14 +3706,14 @@ function fa(e, t = {}) {
|
|
|
3593
3706
|
familyOf: r
|
|
3594
3707
|
};
|
|
3595
3708
|
}
|
|
3596
|
-
function
|
|
3709
|
+
function Ea(e, t, n) {
|
|
3597
3710
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3598
3711
|
}
|
|
3599
|
-
function
|
|
3712
|
+
function Da(e, t) {
|
|
3600
3713
|
let n = t.familyOf.get(e);
|
|
3601
3714
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3602
3715
|
}
|
|
3603
|
-
function
|
|
3716
|
+
function Oa(e, t) {
|
|
3604
3717
|
let n = /* @__PURE__ */ new Map();
|
|
3605
3718
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3606
3719
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3616,65 +3729,65 @@ function ha(e, t) {
|
|
|
3616
3729
|
familyOf: n
|
|
3617
3730
|
};
|
|
3618
3731
|
}
|
|
3619
|
-
function
|
|
3732
|
+
function ka(e, t) {
|
|
3620
3733
|
return e.map((e) => ({
|
|
3621
3734
|
...e,
|
|
3622
|
-
dependencies: e.dependencies.map((e) =>
|
|
3735
|
+
dependencies: e.dependencies.map((e) => Da(e, t))
|
|
3623
3736
|
}));
|
|
3624
3737
|
}
|
|
3625
3738
|
//#endregion
|
|
3626
3739
|
//#region src/ui/banner.ts
|
|
3627
|
-
var
|
|
3740
|
+
var Aa = [
|
|
3628
3741
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3629
3742
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3630
3743
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3631
3744
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3632
3745
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3633
3746
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3634
|
-
],
|
|
3747
|
+
], ja = [
|
|
3635
3748
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3636
3749
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3637
3750
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3638
3751
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3639
3752
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3640
3753
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3641
|
-
],
|
|
3754
|
+
], Ma = [
|
|
3642
3755
|
253,
|
|
3643
3756
|
176,
|
|
3644
3757
|
21
|
|
3645
|
-
],
|
|
3758
|
+
], Na = [
|
|
3646
3759
|
245,
|
|
3647
3760
|
76,
|
|
3648
3761
|
2
|
|
3649
|
-
],
|
|
3762
|
+
], Pa = 5, Fa = [
|
|
3650
3763
|
17,
|
|
3651
3764
|
103,
|
|
3652
3765
|
248
|
|
3653
|
-
],
|
|
3766
|
+
], Ia = [
|
|
3654
3767
|
42,
|
|
3655
3768
|
160,
|
|
3656
3769
|
250
|
|
3657
|
-
],
|
|
3658
|
-
function
|
|
3770
|
+
], La = .2;
|
|
3771
|
+
function Ra() {
|
|
3659
3772
|
console.log();
|
|
3660
|
-
for (let e of
|
|
3661
|
-
start:
|
|
3662
|
-
end:
|
|
3663
|
-
angle:
|
|
3773
|
+
for (let e of ye(Aa, {
|
|
3774
|
+
start: Ma,
|
|
3775
|
+
end: Na,
|
|
3776
|
+
angle: Pa
|
|
3664
3777
|
})) console.log(b.bold(e));
|
|
3665
|
-
for (let e of
|
|
3666
|
-
start:
|
|
3667
|
-
end:
|
|
3668
|
-
angle:
|
|
3778
|
+
for (let e of ye(ja, {
|
|
3779
|
+
start: Fa,
|
|
3780
|
+
end: Ia,
|
|
3781
|
+
angle: La
|
|
3669
3782
|
})) console.log(b.bold(e));
|
|
3670
|
-
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();
|
|
3671
3784
|
}
|
|
3672
|
-
function
|
|
3673
|
-
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();
|
|
3674
3787
|
}
|
|
3675
3788
|
//#endregion
|
|
3676
3789
|
//#region src/ui/pack-multiselect.ts
|
|
3677
|
-
var
|
|
3790
|
+
var Ba = class extends O {
|
|
3678
3791
|
options;
|
|
3679
3792
|
cursor = 0;
|
|
3680
3793
|
selected;
|
|
@@ -3778,98 +3891,106 @@ var Da = class extends O {
|
|
|
3778
3891
|
}
|
|
3779
3892
|
}
|
|
3780
3893
|
};
|
|
3781
|
-
function
|
|
3782
|
-
return new
|
|
3894
|
+
function Va(e) {
|
|
3895
|
+
return new Ba(e).prompt();
|
|
3783
3896
|
}
|
|
3784
3897
|
//#endregion
|
|
3785
3898
|
//#region src/utils/naming.ts
|
|
3786
|
-
function
|
|
3899
|
+
function Ha(e) {
|
|
3787
3900
|
return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3788
3901
|
}
|
|
3789
|
-
function
|
|
3902
|
+
function Ua(e) {
|
|
3790
3903
|
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3791
3904
|
}
|
|
3792
3905
|
//#endregion
|
|
3793
3906
|
//#region src/utils/validate.ts
|
|
3794
|
-
function
|
|
3907
|
+
function Wa(e) {
|
|
3795
3908
|
if (!e.trim()) return "Project name cannot be empty";
|
|
3796
3909
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
3797
|
-
let t =
|
|
3798
|
-
if (!
|
|
3910
|
+
let t = Ha(e);
|
|
3911
|
+
if (!ne.test(t)) return "Project name must contain at least one letter or number";
|
|
3799
3912
|
}
|
|
3800
3913
|
//#endregion
|
|
3801
3914
|
//#region src/core/apply-mode.ts
|
|
3802
|
-
var
|
|
3803
|
-
function
|
|
3804
|
-
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}`);
|
|
3805
3918
|
}
|
|
3806
|
-
async function
|
|
3807
|
-
let n = T.resolve(e,
|
|
3919
|
+
async function Ja(e, t) {
|
|
3920
|
+
let n = T.resolve(e, Ga), r;
|
|
3808
3921
|
try {
|
|
3809
3922
|
r = await y.readFile(n, "utf-8");
|
|
3810
3923
|
} catch {
|
|
3811
3924
|
return !1;
|
|
3812
3925
|
}
|
|
3813
|
-
let i =
|
|
3926
|
+
let i = qa(r, t);
|
|
3814
3927
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3815
3928
|
}
|
|
3816
3929
|
//#endregion
|
|
3817
3930
|
//#region src/core/apply-theme.ts
|
|
3818
|
-
function
|
|
3819
|
-
let n =
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3931
|
+
function Ya(e, t) {
|
|
3932
|
+
let n = 0;
|
|
3933
|
+
for (; n < e.length;) {
|
|
3934
|
+
let r = e.indexOf(t, n);
|
|
3935
|
+
if (r === -1) return null;
|
|
3936
|
+
let i = e.indexOf("{", r);
|
|
3937
|
+
if (i === -1) return null;
|
|
3938
|
+
if (e.slice(r + t.length, i).trim() !== "") {
|
|
3939
|
+
n = r + t.length;
|
|
3940
|
+
continue;
|
|
3941
|
+
}
|
|
3942
|
+
let a = 1, o = i + 1;
|
|
3943
|
+
for (; o < e.length && a > 0;) {
|
|
3944
|
+
let t = e[o];
|
|
3945
|
+
t === "{" ? a++ : t === "}" && a--, o++;
|
|
3946
|
+
}
|
|
3947
|
+
return a === 0 ? {
|
|
3948
|
+
bodyStart: i + 1,
|
|
3949
|
+
bodyEnd: o - 1
|
|
3950
|
+
} : null;
|
|
3827
3951
|
}
|
|
3828
|
-
return
|
|
3829
|
-
bodyStart: r + 1,
|
|
3830
|
-
bodyEnd: a - 1
|
|
3831
|
-
} : null;
|
|
3952
|
+
return null;
|
|
3832
3953
|
}
|
|
3833
|
-
function
|
|
3954
|
+
function Xa(e, t) {
|
|
3834
3955
|
let n = e;
|
|
3835
3956
|
for (let [e, r] of Object.entries(t)) {
|
|
3836
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3957
|
+
let t = RegExp(`(^[ \\t]*--${Za(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3837
3958
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3838
3959
|
}
|
|
3839
3960
|
return n;
|
|
3840
3961
|
}
|
|
3841
|
-
function
|
|
3962
|
+
function Za(e) {
|
|
3842
3963
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3843
3964
|
}
|
|
3844
|
-
function
|
|
3845
|
-
let n =
|
|
3965
|
+
function Qa(e, t) {
|
|
3966
|
+
let n = Ya(e, ":root"), r = Ya(e, ".dark"), i = e;
|
|
3846
3967
|
if (n) {
|
|
3847
3968
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3848
|
-
i = e +
|
|
3969
|
+
i = e + Xa(r, t.light) + a;
|
|
3849
3970
|
}
|
|
3850
3971
|
if (r) {
|
|
3851
|
-
let e =
|
|
3972
|
+
let e = Ya(i, ".dark");
|
|
3852
3973
|
if (e) {
|
|
3853
3974
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3854
|
-
i = n +
|
|
3975
|
+
i = n + Xa(r, t.dark) + a;
|
|
3855
3976
|
}
|
|
3856
3977
|
}
|
|
3857
3978
|
return i;
|
|
3858
3979
|
}
|
|
3859
|
-
var
|
|
3860
|
-
async function
|
|
3861
|
-
let n = T.resolve(e,
|
|
3980
|
+
var $a = "assets/styles.css";
|
|
3981
|
+
async function eo(e, t) {
|
|
3982
|
+
let n = T.resolve(e, $a), r;
|
|
3862
3983
|
try {
|
|
3863
3984
|
r = await y.readFile(n, "utf-8");
|
|
3864
3985
|
} catch {
|
|
3865
3986
|
return !1;
|
|
3866
3987
|
}
|
|
3867
|
-
let i =
|
|
3988
|
+
let i = Qa(r, t);
|
|
3868
3989
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3869
3990
|
}
|
|
3870
3991
|
//#endregion
|
|
3871
3992
|
//#region src/core/clone.ts
|
|
3872
|
-
async function
|
|
3993
|
+
async function to(e) {
|
|
3873
3994
|
let t = await ee(j, {
|
|
3874
3995
|
dir: e,
|
|
3875
3996
|
force: !0
|
|
@@ -3881,7 +4002,7 @@ async function Ha(e) {
|
|
|
3881
4002
|
}
|
|
3882
4003
|
//#endregion
|
|
3883
4004
|
//#region src/core/editor-config.ts
|
|
3884
|
-
function
|
|
4005
|
+
function no(e) {
|
|
3885
4006
|
let t = {
|
|
3886
4007
|
globs: [],
|
|
3887
4008
|
alwaysApply: !1
|
|
@@ -3916,10 +4037,10 @@ function Ua(e) {
|
|
|
3916
4037
|
content: i
|
|
3917
4038
|
};
|
|
3918
4039
|
}
|
|
3919
|
-
function
|
|
4040
|
+
function ro(e) {
|
|
3920
4041
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
3921
4042
|
}
|
|
3922
|
-
function
|
|
4043
|
+
function io(e) {
|
|
3923
4044
|
let t;
|
|
3924
4045
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
3925
4046
|
let n = [`trigger: ${t}`];
|
|
@@ -3929,30 +4050,30 @@ function Ga(e) {
|
|
|
3929
4050
|
}
|
|
3930
4051
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
3931
4052
|
}
|
|
3932
|
-
function
|
|
4053
|
+
function ao(e) {
|
|
3933
4054
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
3934
4055
|
}
|
|
3935
|
-
var
|
|
4056
|
+
var oo = {
|
|
3936
4057
|
claude: {
|
|
3937
4058
|
rulesDir: ".claude/rules",
|
|
3938
4059
|
extension: ".md",
|
|
3939
|
-
convert:
|
|
4060
|
+
convert: ro
|
|
3940
4061
|
},
|
|
3941
4062
|
windsurf: {
|
|
3942
4063
|
rulesDir: ".windsurf/rules",
|
|
3943
4064
|
extension: ".md",
|
|
3944
|
-
convert:
|
|
4065
|
+
convert: io
|
|
3945
4066
|
},
|
|
3946
4067
|
copilot: {
|
|
3947
4068
|
rulesDir: ".github/instructions",
|
|
3948
4069
|
extension: ".instructions.md",
|
|
3949
|
-
convert:
|
|
4070
|
+
convert: ao
|
|
3950
4071
|
}
|
|
3951
4072
|
};
|
|
3952
|
-
async function
|
|
3953
|
-
let t = T.join(e,
|
|
4073
|
+
async function so(e) {
|
|
4074
|
+
let t = T.join(e, ie), n = (await y.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
3954
4075
|
return await Promise.all(n.map(async (e) => {
|
|
3955
|
-
let n = T.join(t, e.name), { frontmatter: r, content: i } =
|
|
4076
|
+
let n = T.join(t, e.name), { frontmatter: r, content: i } = no(await y.readFile(n, "utf-8"));
|
|
3956
4077
|
return {
|
|
3957
4078
|
frontmatter: r,
|
|
3958
4079
|
content: i,
|
|
@@ -3960,31 +4081,31 @@ async function Ja(e) {
|
|
|
3960
4081
|
};
|
|
3961
4082
|
}));
|
|
3962
4083
|
}
|
|
3963
|
-
async function
|
|
4084
|
+
async function co(e, t) {
|
|
3964
4085
|
if (t === "cursor") return;
|
|
3965
|
-
let n =
|
|
4086
|
+
let n = oo[t], r = await so(e), i = T.join(e, n.rulesDir);
|
|
3966
4087
|
await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
3967
4088
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3968
4089
|
return y.writeFile(T.join(i, r), t, "utf-8");
|
|
3969
|
-
})), await ur(T.join(e,
|
|
4090
|
+
})), await ur(T.join(e, ae)), await ur(T.join(e, oe));
|
|
3970
4091
|
}
|
|
3971
4092
|
//#endregion
|
|
3972
4093
|
//#region src/core/env-files.ts
|
|
3973
|
-
var
|
|
4094
|
+
var lo = [
|
|
3974
4095
|
"apps",
|
|
3975
4096
|
"packages",
|
|
3976
4097
|
"libs",
|
|
3977
4098
|
"shared"
|
|
3978
4099
|
];
|
|
3979
|
-
async function
|
|
3980
|
-
let t = await
|
|
4100
|
+
async function uo(e) {
|
|
4101
|
+
let t = await fo(e);
|
|
3981
4102
|
return (await Promise.all(t.map(async (t) => {
|
|
3982
4103
|
let n = T.join(T.dirname(t), ".env");
|
|
3983
4104
|
return await J(n) ? null : (await y.copyFile(t, n), T.relative(e, n));
|
|
3984
4105
|
}))).filter((e) => e !== null).sort();
|
|
3985
4106
|
}
|
|
3986
|
-
async function
|
|
3987
|
-
let t = [T.join(e, ".env.example")], n = await Promise.all(
|
|
4107
|
+
async function fo(e) {
|
|
4108
|
+
let t = [T.join(e, ".env.example")], n = await Promise.all(lo.map(async (t) => {
|
|
3988
4109
|
let n = T.join(e, t);
|
|
3989
4110
|
return (await y.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => T.join(n, e.name, ".env.example"));
|
|
3990
4111
|
}));
|
|
@@ -3992,11 +4113,11 @@ async function Qa(e) {
|
|
|
3992
4113
|
}
|
|
3993
4114
|
//#endregion
|
|
3994
4115
|
//#region src/core/post-clone.ts
|
|
3995
|
-
var
|
|
3996
|
-
async function
|
|
4116
|
+
var Q = "@hype-stack/", po = "hype-stack";
|
|
4117
|
+
async function mo(e) {
|
|
3997
4118
|
await ur(T.join(e, ".git"));
|
|
3998
4119
|
}
|
|
3999
|
-
async function
|
|
4120
|
+
async function ho(e) {
|
|
4000
4121
|
await q("git", ["init"], { cwd: e }), await q("git", ["add", "."], { cwd: e }), await q("git", [
|
|
4001
4122
|
"-c",
|
|
4002
4123
|
"user.name=Hype Stack CLI",
|
|
@@ -4007,22 +4128,22 @@ async function to(e) {
|
|
|
4007
4128
|
"Initial commit from Hype Stack CLI"
|
|
4008
4129
|
], { cwd: e });
|
|
4009
4130
|
}
|
|
4010
|
-
async function
|
|
4011
|
-
let n = `@${t}/`, r = await
|
|
4131
|
+
async function go(e, t) {
|
|
4132
|
+
let n = `@${t}/`, r = await wo(e);
|
|
4012
4133
|
for (let e of r) {
|
|
4013
4134
|
let t = await sr(e);
|
|
4014
4135
|
if (!t) continue;
|
|
4015
4136
|
let r = !1;
|
|
4016
|
-
t.name?.startsWith(
|
|
4137
|
+
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);
|
|
4017
4138
|
let i = await y.readFile(e, "utf-8");
|
|
4018
|
-
if (i.includes(
|
|
4019
|
-
let t = i.replaceAll(
|
|
4139
|
+
if (i.includes(Q)) {
|
|
4140
|
+
let t = i.replaceAll(Q, n);
|
|
4020
4141
|
await y.writeFile(e, t, "utf-8");
|
|
4021
4142
|
} else r && await cr(e, t);
|
|
4022
4143
|
}
|
|
4023
|
-
await
|
|
4144
|
+
await zi(e, t), await yo(e, t), await Co(e, t);
|
|
4024
4145
|
}
|
|
4025
|
-
var
|
|
4146
|
+
var _o = new Set([
|
|
4026
4147
|
".git",
|
|
4027
4148
|
"node_modules",
|
|
4028
4149
|
"dist",
|
|
@@ -4030,10 +4151,10 @@ var ro = new Set([
|
|
|
4030
4151
|
".nx",
|
|
4031
4152
|
".next",
|
|
4032
4153
|
"coverage"
|
|
4033
|
-
]),
|
|
4034
|
-
async function
|
|
4035
|
-
if (t ===
|
|
4036
|
-
let n = await
|
|
4154
|
+
]), vo = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
|
|
4155
|
+
async function yo(e, t) {
|
|
4156
|
+
if (t === po) return;
|
|
4157
|
+
let n = await bo(e);
|
|
4037
4158
|
await Promise.all(n.map(async (e) => {
|
|
4038
4159
|
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
4039
4160
|
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
@@ -4041,37 +4162,37 @@ async function ao(e, t) {
|
|
|
4041
4162
|
await y.writeFile(e, r, "utf-8");
|
|
4042
4163
|
}));
|
|
4043
4164
|
}
|
|
4044
|
-
async function
|
|
4165
|
+
async function bo(e) {
|
|
4045
4166
|
let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
4046
4167
|
return (await Promise.all(t.map(async (t) => {
|
|
4047
4168
|
let n = T.join(e, t.name);
|
|
4048
|
-
return t.isDirectory() ?
|
|
4169
|
+
return t.isDirectory() ? _o.has(t.name) ? [] : bo(n) : t.isFile() && vo.test(t.name) ? [n] : [];
|
|
4049
4170
|
}))).flat();
|
|
4050
4171
|
}
|
|
4051
|
-
function
|
|
4172
|
+
function xo(e, t) {
|
|
4052
4173
|
if (!e) return !1;
|
|
4053
4174
|
let n = !1;
|
|
4054
|
-
for (let r of Object.keys(e)) if (r.startsWith(
|
|
4055
|
-
let i = r.replace(
|
|
4175
|
+
for (let r of Object.keys(e)) if (r.startsWith(Q)) {
|
|
4176
|
+
let i = r.replace(Q, t);
|
|
4056
4177
|
e[i] = e[r], delete e[r], n = !0;
|
|
4057
4178
|
}
|
|
4058
4179
|
return n;
|
|
4059
4180
|
}
|
|
4060
|
-
function
|
|
4181
|
+
function So(e, t) {
|
|
4061
4182
|
if (!e) return !1;
|
|
4062
4183
|
let n = !1;
|
|
4063
|
-
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(
|
|
4064
|
-
for (let r of Object.values(e.targets)) if (r.buildTarget?.includes(
|
|
4184
|
+
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Q) ? (n = !0, e.replace(Q, t)) : e), e.targets) {
|
|
4185
|
+
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);
|
|
4065
4186
|
}
|
|
4066
4187
|
return n;
|
|
4067
4188
|
}
|
|
4068
|
-
async function
|
|
4189
|
+
async function Co(e, t) {
|
|
4069
4190
|
let n = T.join(e, "packages/enums/src/app/index.ts"), r = await y.readFile(n, "utf-8").catch(() => null);
|
|
4070
4191
|
if (!r) return;
|
|
4071
|
-
let i =
|
|
4192
|
+
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"`);
|
|
4072
4193
|
await y.writeFile(n, a, "utf-8");
|
|
4073
4194
|
}
|
|
4074
|
-
async function
|
|
4195
|
+
async function wo(e) {
|
|
4075
4196
|
let t = [], n = T.join(e, "package.json");
|
|
4076
4197
|
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
4077
4198
|
for (let n of [
|
|
@@ -4091,7 +4212,7 @@ async function uo(e) {
|
|
|
4091
4212
|
}
|
|
4092
4213
|
//#endregion
|
|
4093
4214
|
//#region src/core/readme.ts
|
|
4094
|
-
var
|
|
4215
|
+
var To = {
|
|
4095
4216
|
cursor: {
|
|
4096
4217
|
label: "Cursor",
|
|
4097
4218
|
rulesDir: ".cursor/rules"
|
|
@@ -4108,21 +4229,21 @@ var fo = {
|
|
|
4108
4229
|
label: "GitHub Copilot",
|
|
4109
4230
|
rulesDir: ".github/instructions"
|
|
4110
4231
|
}
|
|
4111
|
-
},
|
|
4232
|
+
}, Eo = {
|
|
4112
4233
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
4113
4234
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
4114
|
-
},
|
|
4235
|
+
}, Do = {
|
|
4115
4236
|
enums: "Shared enums and app config used across apps",
|
|
4116
4237
|
cli: "Project tooling and code generators"
|
|
4117
4238
|
};
|
|
4118
|
-
function
|
|
4239
|
+
function Oo(e, t) {
|
|
4119
4240
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
4120
4241
|
let r = t[e];
|
|
4121
4242
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4122
4243
|
});
|
|
4123
4244
|
}
|
|
4124
|
-
function
|
|
4125
|
-
let { projectName: t, editor: n, workspace: r } = e, i =
|
|
4245
|
+
function ko(e) {
|
|
4246
|
+
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 = [];
|
|
4126
4247
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
4127
4248
|
let u = [];
|
|
4128
4249
|
u.push(`# ${i}`), u.push([
|
|
@@ -4225,18 +4346,18 @@ function go(e) {
|
|
|
4225
4346
|
"stays useful."
|
|
4226
4347
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4227
4348
|
}
|
|
4228
|
-
async function
|
|
4349
|
+
async function Ao(e, t) {
|
|
4229
4350
|
let n = T.join(e, "README.md");
|
|
4230
|
-
await y.writeFile(n,
|
|
4351
|
+
await y.writeFile(n, ko(t), "utf-8");
|
|
4231
4352
|
}
|
|
4232
4353
|
//#endregion
|
|
4233
4354
|
//#region src/core/tracking.ts
|
|
4234
|
-
async function
|
|
4355
|
+
async function jo(e) {
|
|
4235
4356
|
try {
|
|
4236
4357
|
let t = {
|
|
4237
4358
|
"X-Device-Id": Xn(),
|
|
4238
4359
|
"X-Client-Info": Zn()
|
|
4239
|
-
}, n = await Kn(
|
|
4360
|
+
}, n = await Kn(L()).catch(() => null);
|
|
4240
4361
|
n?.token && (t.Authorization = `Bearer ${n.token}`), await K.createRequest()({
|
|
4241
4362
|
endpoint: "/cli/track",
|
|
4242
4363
|
method: "POST"
|
|
@@ -4245,7 +4366,7 @@ async function vo(e) {
|
|
|
4245
4366
|
}
|
|
4246
4367
|
//#endregion
|
|
4247
4368
|
//#region src/core/npm-deps.ts
|
|
4248
|
-
function
|
|
4369
|
+
function Mo(e, t) {
|
|
4249
4370
|
let n = [], r = [];
|
|
4250
4371
|
if (!e) return {
|
|
4251
4372
|
errors: n,
|
|
@@ -4276,7 +4397,7 @@ function yo(e, t) {
|
|
|
4276
4397
|
operations: r
|
|
4277
4398
|
};
|
|
4278
4399
|
}
|
|
4279
|
-
function
|
|
4400
|
+
function No(e) {
|
|
4280
4401
|
let t = {};
|
|
4281
4402
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4282
4403
|
...t[e],
|
|
@@ -4284,7 +4405,7 @@ function bo(e) {
|
|
|
4284
4405
|
};
|
|
4285
4406
|
return t;
|
|
4286
4407
|
}
|
|
4287
|
-
async function
|
|
4408
|
+
async function Po(e, t, n = q) {
|
|
4288
4409
|
let r = [];
|
|
4289
4410
|
for (let i of e) {
|
|
4290
4411
|
let e = T.join(t, i.relativeDir);
|
|
@@ -4317,17 +4438,17 @@ async function xo(e, t, n = q) {
|
|
|
4317
4438
|
}
|
|
4318
4439
|
//#endregion
|
|
4319
4440
|
//#region src/commands/install-helpers.ts
|
|
4320
|
-
function
|
|
4441
|
+
function $(e) {
|
|
4321
4442
|
return e instanceof Error ? e.message : String(e);
|
|
4322
4443
|
}
|
|
4323
|
-
async function
|
|
4444
|
+
async function Fo(e, t, n) {
|
|
4324
4445
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4325
|
-
return r.length === 0 ? {} :
|
|
4446
|
+
return r.length === 0 ? {} : Vr(r, n).catch(() => ({}));
|
|
4326
4447
|
}
|
|
4327
|
-
function
|
|
4328
|
-
return e === "free" ?
|
|
4448
|
+
function Io(e, t) {
|
|
4449
|
+
return e === "free" ? B.success("free") : e === "owned" ? B.accent("owned") : `${B.highlight(`$${t}`)} ${B.muted("locked")}`;
|
|
4329
4450
|
}
|
|
4330
|
-
async function
|
|
4451
|
+
async function Lo(e, t, n) {
|
|
4331
4452
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4332
4453
|
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) => ({
|
|
4333
4454
|
name: e.name,
|
|
@@ -4335,10 +4456,10 @@ async function wo(e, t, n) {
|
|
|
4335
4456
|
price: e.price
|
|
4336
4457
|
})));
|
|
4337
4458
|
}
|
|
4338
|
-
function
|
|
4459
|
+
function Ro(e, t) {
|
|
4339
4460
|
let n = e.map((e, n) => {
|
|
4340
4461
|
let r = t.get(e), i = r ? r.displayName : e;
|
|
4341
|
-
return ` ${
|
|
4462
|
+
return ` ${B.muted(`${n + 1}.`)} ${B.brand(i)}`;
|
|
4342
4463
|
});
|
|
4343
4464
|
s.note([
|
|
4344
4465
|
"These packs will be installed, in order:",
|
|
@@ -4346,10 +4467,10 @@ function To(e, t) {
|
|
|
4346
4467
|
...n
|
|
4347
4468
|
].join("\n"), "Install Plan");
|
|
4348
4469
|
}
|
|
4349
|
-
async function
|
|
4470
|
+
async function zo(e, t) {
|
|
4350
4471
|
let n = [];
|
|
4351
4472
|
for (let r of e) {
|
|
4352
|
-
let e = await
|
|
4473
|
+
let e = await Fr(r), i = await Ir(r, t);
|
|
4353
4474
|
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'npx @hype-stack/cli login' or check your license.`);
|
|
4354
4475
|
n.push({
|
|
4355
4476
|
manifest: e,
|
|
@@ -4358,32 +4479,32 @@ async function Eo(e, t) {
|
|
|
4358
4479
|
}
|
|
4359
4480
|
return n;
|
|
4360
4481
|
}
|
|
4361
|
-
async function
|
|
4362
|
-
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a =
|
|
4482
|
+
async function Bo(e) {
|
|
4483
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = Mo(No(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4363
4484
|
if (a.errors.length > 0) {
|
|
4364
4485
|
for (let e of a.errors) s.log.error(e);
|
|
4365
4486
|
return;
|
|
4366
4487
|
}
|
|
4367
4488
|
if (a.operations.length === 0) return;
|
|
4368
4489
|
i.start("Installing npm dependencies...");
|
|
4369
|
-
let o = await
|
|
4490
|
+
let o = await Po(a.operations, r);
|
|
4370
4491
|
if (i.stop(o.ok ? "npm dependencies installed" : "npm dependency installation failed"), !o.ok) for (let e of o.errors) s.log.error(e);
|
|
4371
4492
|
}
|
|
4372
|
-
function
|
|
4373
|
-
s.note([` ${
|
|
4493
|
+
function Vo() {
|
|
4494
|
+
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");
|
|
4374
4495
|
}
|
|
4375
|
-
function
|
|
4496
|
+
function Ho(e) {
|
|
4376
4497
|
if (e.length === 0) return;
|
|
4377
4498
|
let t = e.map((e) => {
|
|
4378
4499
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
4379
|
-
return ` ${
|
|
4500
|
+
return ` ${B.muted("•")} ${B.path(t)}`;
|
|
4380
4501
|
});
|
|
4381
4502
|
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4382
4503
|
}
|
|
4383
|
-
async function
|
|
4504
|
+
async function Uo(e) {
|
|
4384
4505
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
|
|
4385
4506
|
if (i) return c;
|
|
4386
|
-
let l = await
|
|
4507
|
+
let l = await Ji({
|
|
4387
4508
|
packs: t,
|
|
4388
4509
|
config: n,
|
|
4389
4510
|
projectRoot: r,
|
|
@@ -4391,17 +4512,17 @@ async function Ao(e) {
|
|
|
4391
4512
|
});
|
|
4392
4513
|
if (l.length === 0) return c;
|
|
4393
4514
|
if (a) {
|
|
4394
|
-
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${
|
|
4515
|
+
s.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${B.command("--force")} to overwrite.`);
|
|
4395
4516
|
let e = l.map((e) => {
|
|
4396
4517
|
let t = T.relative(r, e.targetPath) || e.target;
|
|
4397
|
-
return ` ${
|
|
4518
|
+
return ` ${B.muted("•")} ${B.path(t)} ${B.muted(`(${e.packName})`)}`;
|
|
4398
4519
|
});
|
|
4399
4520
|
return s.note(e.join("\n"), "Kept existing files"), c;
|
|
4400
4521
|
}
|
|
4401
4522
|
s.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4402
4523
|
for (let e of l) {
|
|
4403
4524
|
let t = T.relative(r, e.targetPath) || e.target, n = await s.confirm({
|
|
4404
|
-
message: `Overwrite ${
|
|
4525
|
+
message: `Overwrite ${B.path(t)}? ${B.muted(`(${e.packName})`)}`,
|
|
4405
4526
|
initialValue: !1
|
|
4406
4527
|
});
|
|
4407
4528
|
s.isCancel(n) && (s.cancel("Installation cancelled."), process.exit(0)), n && c.add(e.targetPath);
|
|
@@ -4410,7 +4531,7 @@ async function Ao(e) {
|
|
|
4410
4531
|
}
|
|
4411
4532
|
//#endregion
|
|
4412
4533
|
//#region src/ui/swatch.ts
|
|
4413
|
-
function
|
|
4534
|
+
function Wo(e) {
|
|
4414
4535
|
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4415
4536
|
if (!t) return null;
|
|
4416
4537
|
let n = t[1].trim().split(/\s+/);
|
|
@@ -4429,58 +4550,58 @@ function jo(e) {
|
|
|
4429
4550
|
h: a
|
|
4430
4551
|
};
|
|
4431
4552
|
}
|
|
4432
|
-
function
|
|
4553
|
+
function Go(e) {
|
|
4433
4554
|
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4434
4555
|
}
|
|
4435
|
-
function
|
|
4556
|
+
function Ko(e) {
|
|
4436
4557
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4437
4558
|
}
|
|
4438
|
-
function
|
|
4559
|
+
function qo({ l: e, c: t, h: n }) {
|
|
4439
4560
|
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;
|
|
4440
4561
|
return [
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4562
|
+
Go(Ko(f) * 255),
|
|
4563
|
+
Go(Ko(p) * 255),
|
|
4564
|
+
Go(Ko(m) * 255)
|
|
4444
4565
|
];
|
|
4445
4566
|
}
|
|
4446
|
-
var
|
|
4447
|
-
function
|
|
4567
|
+
var Jo = "\x1B[49m";
|
|
4568
|
+
function Yo(e, t) {
|
|
4448
4569
|
let n = e[t];
|
|
4449
4570
|
if (!n) return b.dim(" ");
|
|
4450
|
-
let r =
|
|
4571
|
+
let r = Wo(n);
|
|
4451
4572
|
if (!r) return b.dim(" ");
|
|
4452
|
-
let [i, a, o] =
|
|
4453
|
-
return `\x1b[48;2;${i};${a};${o}m ${
|
|
4573
|
+
let [i, a, o] = qo(r);
|
|
4574
|
+
return `\x1b[48;2;${i};${a};${o}m ${Jo}`;
|
|
4454
4575
|
}
|
|
4455
|
-
var
|
|
4576
|
+
var Xo = [
|
|
4456
4577
|
"primary",
|
|
4457
4578
|
"secondary",
|
|
4458
4579
|
"accent"
|
|
4459
4580
|
];
|
|
4460
|
-
function
|
|
4461
|
-
return
|
|
4581
|
+
function Zo(e) {
|
|
4582
|
+
return Xo.map((t) => Yo(e, t)).join("");
|
|
4462
4583
|
}
|
|
4463
|
-
function
|
|
4464
|
-
return `${
|
|
4584
|
+
function Qo(e) {
|
|
4585
|
+
return `${Zo(e.light)} ${b.dim("·")} ${Zo(e.dark)}`;
|
|
4465
4586
|
}
|
|
4466
4587
|
//#endregion
|
|
4467
4588
|
//#region src/commands/create.ts
|
|
4468
|
-
async function
|
|
4469
|
-
e.skipBanner ||
|
|
4589
|
+
async function $o(e) {
|
|
4590
|
+
e.skipBanner || Ra(), s.intro(B.brandBold("Create a new Hype Stack project"));
|
|
4470
4591
|
let o = e.yes === !0, c, l;
|
|
4471
4592
|
if (o && e.name) {
|
|
4472
|
-
let t =
|
|
4473
|
-
t && (s.log.error(t),
|
|
4593
|
+
let t = Wa(e.name);
|
|
4594
|
+
t && (s.log.error(t), Z()), l = e.name, c = Ha(e.name);
|
|
4474
4595
|
} else {
|
|
4475
4596
|
let t = await s.text({
|
|
4476
4597
|
message: "What is your project named?",
|
|
4477
4598
|
placeholder: "my-app",
|
|
4478
4599
|
initialValue: e.name ?? "",
|
|
4479
|
-
validate: (e) =>
|
|
4600
|
+
validate: (e) => Wa(e ?? "")
|
|
4480
4601
|
});
|
|
4481
|
-
s.isCancel(t) &&
|
|
4602
|
+
s.isCancel(t) && Z(), l = t, c = Ha(l);
|
|
4482
4603
|
}
|
|
4483
|
-
l.trim() !== c && s.log.info(
|
|
4604
|
+
l.trim() !== c && s.log.info(B.muted(`Using "${B.highlight(c)}" as the project name`));
|
|
4484
4605
|
let u;
|
|
4485
4606
|
if (e.directory !== void 0) u = e.directory;
|
|
4486
4607
|
else {
|
|
@@ -4493,26 +4614,26 @@ async function Bo(e) {
|
|
|
4493
4614
|
placeholder: ".",
|
|
4494
4615
|
initialValue: "."
|
|
4495
4616
|
});
|
|
4496
|
-
s.isCancel(e) &&
|
|
4617
|
+
s.isCancel(e) && Z(), t = e;
|
|
4497
4618
|
}
|
|
4498
4619
|
u = dr(t, c);
|
|
4499
4620
|
}
|
|
4500
4621
|
let d = T.resolve(u);
|
|
4501
|
-
o || s.note(
|
|
4502
|
-
let f = e.editor &&
|
|
4622
|
+
o || s.note(B.path(d), "Project will be created at");
|
|
4623
|
+
let f = e.editor && re.includes(e.editor) ? e.editor : null, p;
|
|
4503
4624
|
if (f) p = f;
|
|
4504
4625
|
else if (o) p = "cursor";
|
|
4505
4626
|
else {
|
|
4506
4627
|
let e = await s.select({
|
|
4507
4628
|
message: "Which code editor do you use?",
|
|
4508
|
-
options:
|
|
4629
|
+
options: I.map((e) => ({
|
|
4509
4630
|
value: e.value,
|
|
4510
4631
|
label: e.label,
|
|
4511
4632
|
hint: "hint" in e ? e.hint : void 0
|
|
4512
4633
|
})),
|
|
4513
4634
|
initialValue: "cursor"
|
|
4514
4635
|
});
|
|
4515
|
-
s.isCancel(e) &&
|
|
4636
|
+
s.isCancel(e) && Z(), p = e;
|
|
4516
4637
|
}
|
|
4517
4638
|
let m = e.theme !== void 0 && a(e.theme), h = e.defaultTheme !== void 0 && a(e.defaultTheme) ? e.defaultTheme : t, g;
|
|
4518
4639
|
if (m) g = e.theme;
|
|
@@ -4522,92 +4643,92 @@ async function Bo(e) {
|
|
|
4522
4643
|
message: "Pick a color theme",
|
|
4523
4644
|
options: r.map((e) => ({
|
|
4524
4645
|
value: e.name,
|
|
4525
|
-
label: `${
|
|
4646
|
+
label: `${Qo(e)} ${e.label}`
|
|
4526
4647
|
})),
|
|
4527
4648
|
initialValue: h
|
|
4528
4649
|
});
|
|
4529
|
-
s.isCancel(e) &&
|
|
4650
|
+
s.isCancel(e) && Z(), g = e;
|
|
4530
4651
|
}
|
|
4531
4652
|
if (!o) {
|
|
4532
|
-
let e =
|
|
4533
|
-
(s.isCancel(r) || !r) &&
|
|
4653
|
+
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?` });
|
|
4654
|
+
(s.isCancel(r) || !r) && Z();
|
|
4534
4655
|
}
|
|
4535
4656
|
if (await ar(d) && !await or(d)) {
|
|
4536
4657
|
let e = await s.confirm({
|
|
4537
|
-
message: `Directory ${
|
|
4658
|
+
message: `Directory ${B.path(d)} is not empty. Continue anyway?`,
|
|
4538
4659
|
initialValue: !1
|
|
4539
4660
|
});
|
|
4540
|
-
(s.isCancel(e) || !e) &&
|
|
4661
|
+
(s.isCancel(e) || !e) && Z();
|
|
4541
4662
|
}
|
|
4542
4663
|
let _ = s.spinner();
|
|
4543
|
-
_.start("Cloning Hype Stack template..."), await
|
|
4664
|
+
_.start("Cloning Hype Stack template..."), await to(d), _.stop(B.success("Template cloned"));
|
|
4544
4665
|
let v = s.spinner();
|
|
4545
|
-
v.start("Setting up project..."), await
|
|
4546
|
-
let y = await
|
|
4547
|
-
await
|
|
4666
|
+
v.start("Setting up project..."), await mo(d), await go(d, c), await co(d, p);
|
|
4667
|
+
let y = await jr(d), b = Nr(c, y);
|
|
4668
|
+
await Ar(d, b), await Ao(d, {
|
|
4548
4669
|
projectName: c,
|
|
4549
4670
|
editor: p,
|
|
4550
4671
|
workspace: y
|
|
4551
4672
|
});
|
|
4552
4673
|
let x = T.resolve(d, b.paths?.frontend.root ?? "apps/frontend");
|
|
4553
|
-
a(g) && (await
|
|
4674
|
+
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"));
|
|
4554
4675
|
let S = s.spinner();
|
|
4555
|
-
S.start("Installing dependencies..."), (await q("pnpm", ["install"], { cwd: d })).exitCode === 0 ? S.stop(
|
|
4676
|
+
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.")));
|
|
4556
4677
|
let C = s.spinner();
|
|
4557
|
-
C.start("Initializing git repository..."), await
|
|
4678
|
+
C.start("Initializing git repository..."), await ho(d), C.stop(B.success("Git repository initialized with clean history"));
|
|
4558
4679
|
let w = s.spinner();
|
|
4559
4680
|
w.start("Creating .env files from examples...");
|
|
4560
|
-
let E = await
|
|
4681
|
+
let E = await uo(d);
|
|
4561
4682
|
if (E.length > 0) {
|
|
4562
4683
|
let e = E.length;
|
|
4563
|
-
w.stop(
|
|
4564
|
-
} else w.stop(
|
|
4565
|
-
s.log.success(`${
|
|
4566
|
-
let D = T.relative(process.cwd(), d) || ".", O = [`${
|
|
4567
|
-
E.length > 0 ? O.push(`Review your ${
|
|
4684
|
+
w.stop(B.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4685
|
+
} else w.stop(B.muted("No .env.example files to copy"));
|
|
4686
|
+
s.log.success(`${B.brandBold("Hype Stack")} project ${B.highlight(c)} is ready!`);
|
|
4687
|
+
let D = T.relative(process.cwd(), d) || ".", O = [`${B.command(`cd ${D}`)}`];
|
|
4688
|
+
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);
|
|
4568
4689
|
let k = e.setup === !1;
|
|
4569
|
-
if (e.deferSetup) s.log.info(
|
|
4690
|
+
if (e.deferSetup) s.log.info(B.muted("Docker and migrations will run after your packs are installed."));
|
|
4570
4691
|
else {
|
|
4571
4692
|
let e = !k && (o || await s.confirm({
|
|
4572
4693
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
4573
4694
|
initialValue: !0
|
|
4574
4695
|
}));
|
|
4575
|
-
s.isCancel(e) &&
|
|
4696
|
+
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();
|
|
4576
4697
|
}
|
|
4577
|
-
return await
|
|
4698
|
+
return await jo("project_create"), s.outro(B.muted("Happy building!")), d;
|
|
4578
4699
|
}
|
|
4579
4700
|
//#endregion
|
|
4580
4701
|
//#region src/commands/init.ts
|
|
4581
|
-
async function
|
|
4702
|
+
async function es(e) {
|
|
4582
4703
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4583
|
-
if (n || (
|
|
4584
|
-
s.log.error(`This doesn't look like a Hype Stack project. ${
|
|
4704
|
+
if (n || (za(), s.intro(B.brandBold("Initialize Hype Stack configuration"))), !await Pr(t)) {
|
|
4705
|
+
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.`));
|
|
4585
4706
|
return;
|
|
4586
4707
|
}
|
|
4587
|
-
if (await
|
|
4588
|
-
let e = await
|
|
4708
|
+
if (await kr(t)) {
|
|
4709
|
+
let e = await Or(t);
|
|
4589
4710
|
if (e && !n) {
|
|
4590
|
-
s.log.info(`Found existing ${
|
|
4711
|
+
s.log.info(`Found existing ${B.path("stack.json")} for project ${B.highlight(e.name)}`);
|
|
4591
4712
|
let t = await s.confirm({
|
|
4592
4713
|
message: "Overwrite existing configuration?",
|
|
4593
4714
|
initialValue: !1
|
|
4594
4715
|
});
|
|
4595
4716
|
if (s.isCancel(t) || !t) {
|
|
4596
|
-
s.outro(
|
|
4717
|
+
s.outro(B.muted("Keeping existing configuration."));
|
|
4597
4718
|
return;
|
|
4598
4719
|
}
|
|
4599
4720
|
}
|
|
4600
4721
|
}
|
|
4601
|
-
let r = await
|
|
4722
|
+
let r = await jr(t);
|
|
4602
4723
|
if (!n) {
|
|
4603
4724
|
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4604
4725
|
if (e.length > 0) {
|
|
4605
|
-
s.log.info(
|
|
4606
|
-
for (let [t, n] of e) s.log.message(` ${
|
|
4726
|
+
s.log.info(B.bold("Detected apps:"));
|
|
4727
|
+
for (let [t, n] of e) s.log.message(` ${V.arrow} ${B.highlight(t)} ${B.muted(`→ ${n}`)}`);
|
|
4607
4728
|
}
|
|
4608
4729
|
if (t.length > 0) {
|
|
4609
|
-
s.log.info(
|
|
4610
|
-
for (let [e, n] of t) s.log.message(` ${
|
|
4730
|
+
s.log.info(B.bold("Detected packages:"));
|
|
4731
|
+
for (let [e, n] of t) s.log.message(` ${V.arrow} ${B.highlight(e)} ${B.muted(`→ ${n}`)}`);
|
|
4611
4732
|
}
|
|
4612
4733
|
e.length === 0 && t.length === 0 && s.log.warn("No apps or packages detected in the workspace.");
|
|
4613
4734
|
}
|
|
@@ -4617,44 +4738,44 @@ async function Vo(e) {
|
|
|
4617
4738
|
message: "Project name for stack.json?",
|
|
4618
4739
|
placeholder: i,
|
|
4619
4740
|
initialValue: i,
|
|
4620
|
-
validate: (e) =>
|
|
4741
|
+
validate: (e) => Wa(e ?? "")
|
|
4621
4742
|
});
|
|
4622
|
-
s.isCancel(e) &&
|
|
4743
|
+
s.isCancel(e) && Z(), a = Ha(e);
|
|
4623
4744
|
}
|
|
4624
|
-
await
|
|
4745
|
+
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.")));
|
|
4625
4746
|
}
|
|
4626
|
-
async function
|
|
4627
|
-
if (await
|
|
4747
|
+
async function ts(e, t = {}, n) {
|
|
4748
|
+
if (await kr(e)) return {
|
|
4628
4749
|
projectRoot: e,
|
|
4629
4750
|
scaffolded: !1
|
|
4630
4751
|
};
|
|
4631
|
-
let r = t.runInit ?? ((e) =>
|
|
4752
|
+
let r = t.runInit ?? ((e) => es({
|
|
4632
4753
|
cwd: e,
|
|
4633
4754
|
silent: !0
|
|
4634
|
-
})), i = t.runCreate ?? ((e, t) =>
|
|
4755
|
+
})), i = t.runCreate ?? ((e, t) => $o({
|
|
4635
4756
|
parentDirectory: e,
|
|
4636
4757
|
deferSetup: !0,
|
|
4637
4758
|
skipBanner: !0,
|
|
4638
4759
|
defaultTheme: t?.defaultTheme,
|
|
4639
4760
|
defaultMode: t?.defaultMode
|
|
4640
4761
|
}));
|
|
4641
|
-
if (await
|
|
4642
|
-
s.log.warn(`No ${
|
|
4762
|
+
if (await Pr(e)) {
|
|
4763
|
+
s.log.warn(`No ${B.path("stack.json")} found in ${B.path(e)}.`);
|
|
4643
4764
|
let t = await s.confirm({
|
|
4644
|
-
message: `Create ${
|
|
4765
|
+
message: `Create ${B.path("stack.json")} now?`,
|
|
4645
4766
|
initialValue: !0
|
|
4646
4767
|
});
|
|
4647
4768
|
if (s.isCancel(t) || !t) return null;
|
|
4648
4769
|
await r(e);
|
|
4649
|
-
let n = await
|
|
4650
|
-
return n && s.log.success(`${
|
|
4770
|
+
let n = await kr(e);
|
|
4771
|
+
return n && s.log.success(`${B.path("stack.json")} created`), n ? {
|
|
4651
4772
|
projectRoot: e,
|
|
4652
4773
|
scaffolded: !1
|
|
4653
4774
|
} : null;
|
|
4654
4775
|
}
|
|
4655
|
-
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${
|
|
4776
|
+
s.log.warn(`This doesn't look like a Hype Stack project, and there's no ${B.path("stack.json")} here.`);
|
|
4656
4777
|
let a = await s.confirm({
|
|
4657
|
-
message: `Is ${
|
|
4778
|
+
message: `Is ${B.path(e)} where you want to work?`,
|
|
4658
4779
|
initialValue: !0
|
|
4659
4780
|
});
|
|
4660
4781
|
if (s.isCancel(a) || !a) return null;
|
|
@@ -4664,41 +4785,41 @@ async function Ho(e, t = {}, n) {
|
|
|
4664
4785
|
});
|
|
4665
4786
|
if (s.isCancel(o) || !o) return null;
|
|
4666
4787
|
let c = await i(e, n);
|
|
4667
|
-
return await
|
|
4788
|
+
return await kr(c) ? {
|
|
4668
4789
|
projectRoot: c,
|
|
4669
4790
|
scaffolded: !0
|
|
4670
4791
|
} : null;
|
|
4671
4792
|
}
|
|
4672
4793
|
//#endregion
|
|
4673
4794
|
//#region src/commands/compose.ts
|
|
4674
|
-
async function
|
|
4795
|
+
async function ns(e = {}) {
|
|
4675
4796
|
let t = e.cwd ?? process.cwd();
|
|
4676
|
-
|
|
4677
|
-
let n = await
|
|
4797
|
+
Ra();
|
|
4798
|
+
let n = await ts(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4678
4799
|
try {
|
|
4679
|
-
a = await
|
|
4800
|
+
a = await Or(r ?? t);
|
|
4680
4801
|
} catch (e) {
|
|
4681
|
-
s.cancel(`Could not parse ${
|
|
4802
|
+
s.cancel(`Could not parse ${B.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4682
4803
|
}
|
|
4683
|
-
a || (s.cancel(r ? `Could not read ${
|
|
4804
|
+
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));
|
|
4684
4805
|
let o = r ?? t;
|
|
4685
|
-
s.intro(
|
|
4806
|
+
s.intro(B.brandBold("Compose your stack"));
|
|
4686
4807
|
let c = s.spinner();
|
|
4687
4808
|
c.start("Loading packs...");
|
|
4688
4809
|
let l;
|
|
4689
4810
|
try {
|
|
4690
|
-
l = await
|
|
4811
|
+
l = await Br();
|
|
4691
4812
|
} catch (e) {
|
|
4692
|
-
c.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${
|
|
4813
|
+
c.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4693
4814
|
}
|
|
4694
4815
|
c.stop("Packs loaded");
|
|
4695
|
-
let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await Kn(
|
|
4816
|
+
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, {
|
|
4696
4817
|
token: m,
|
|
4697
4818
|
key: p
|
|
4698
4819
|
}), g = (e) => {
|
|
4699
4820
|
let t = f.get(e);
|
|
4700
4821
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4701
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await
|
|
4822
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await rs({
|
|
4702
4823
|
packs: l,
|
|
4703
4824
|
installedSet: d,
|
|
4704
4825
|
stateOf: g,
|
|
@@ -4706,20 +4827,20 @@ async function Uo(e = {}) {
|
|
|
4706
4827
|
adminAvailable: !!a.apps.admin
|
|
4707
4828
|
});
|
|
4708
4829
|
if (v === null && (s.cancel("Cancelled."), process.exit(0)), v.length === 0) {
|
|
4709
|
-
s.outro(
|
|
4830
|
+
s.outro(B.muted("No packs selected. Nothing to do."));
|
|
4710
4831
|
return;
|
|
4711
4832
|
}
|
|
4712
|
-
let b =
|
|
4833
|
+
let b = os(v), x = ss(v), S = Oa(l, b), C = xa(ka(l, S)), w;
|
|
4713
4834
|
try {
|
|
4714
|
-
w =
|
|
4835
|
+
w = Ca(b, C, u);
|
|
4715
4836
|
} catch (e) {
|
|
4716
|
-
s.cancel(
|
|
4837
|
+
s.cancel($(e)), process.exit(1);
|
|
4717
4838
|
}
|
|
4718
4839
|
if (w.order.length === 0) {
|
|
4719
|
-
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(
|
|
4840
|
+
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(B.muted("Your selection is already part of the project."));
|
|
4720
4841
|
return;
|
|
4721
4842
|
}
|
|
4722
|
-
let T =
|
|
4843
|
+
let T = wa({
|
|
4723
4844
|
order: w.order,
|
|
4724
4845
|
graph: C,
|
|
4725
4846
|
isLocked: _,
|
|
@@ -4727,36 +4848,36 @@ async function Uo(e = {}) {
|
|
|
4727
4848
|
});
|
|
4728
4849
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4729
4850
|
let e = await nr();
|
|
4730
|
-
e && (m = e, h = await
|
|
4851
|
+
e && (m = e, h = await Fo(l, d, {
|
|
4731
4852
|
token: m,
|
|
4732
4853
|
key: p
|
|
4733
|
-
}), T =
|
|
4854
|
+
}), T = wa({
|
|
4734
4855
|
order: w.order,
|
|
4735
4856
|
graph: C,
|
|
4736
4857
|
isLocked: _,
|
|
4737
4858
|
installed: u
|
|
4738
4859
|
}));
|
|
4739
4860
|
}
|
|
4740
|
-
if (T.blocked.length > 0 && await
|
|
4741
|
-
s.outro(
|
|
4861
|
+
if (T.blocked.length > 0 && await Lo(T.blocked, _, f), T.installable.length === 0) {
|
|
4862
|
+
s.outro(B.muted("Nothing left to install once locked packs are removed."));
|
|
4742
4863
|
return;
|
|
4743
4864
|
}
|
|
4744
|
-
if (
|
|
4865
|
+
if (Ro(T.installable, f), !e.yes) {
|
|
4745
4866
|
let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4746
4867
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
4747
4868
|
}
|
|
4748
4869
|
c.start("Downloading packs...");
|
|
4749
4870
|
let E;
|
|
4750
4871
|
try {
|
|
4751
|
-
E = await
|
|
4872
|
+
E = await zo(T.installable, {
|
|
4752
4873
|
token: m,
|
|
4753
4874
|
key: p
|
|
4754
4875
|
});
|
|
4755
4876
|
} catch (e) {
|
|
4756
|
-
c.stop("Download failed"), s.cancel(
|
|
4877
|
+
c.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
4757
4878
|
}
|
|
4758
4879
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4759
|
-
let D = await
|
|
4880
|
+
let D = await Uo({
|
|
4760
4881
|
prepared: E,
|
|
4761
4882
|
config: a,
|
|
4762
4883
|
cwd: o,
|
|
@@ -4766,7 +4887,7 @@ async function Uo(e = {}) {
|
|
|
4766
4887
|
});
|
|
4767
4888
|
try {
|
|
4768
4889
|
c.start("Installing pack files...");
|
|
4769
|
-
let t = await
|
|
4890
|
+
let t = await Zi({
|
|
4770
4891
|
packs: E,
|
|
4771
4892
|
config: a,
|
|
4772
4893
|
projectRoot: o,
|
|
@@ -4779,22 +4900,22 @@ async function Uo(e = {}) {
|
|
|
4779
4900
|
for (let e of t.errors) s.log.error(e);
|
|
4780
4901
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4781
4902
|
}
|
|
4782
|
-
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${
|
|
4903
|
+
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));
|
|
4783
4904
|
for (let e of t.errors) s.log.error(e);
|
|
4784
|
-
await
|
|
4905
|
+
await Bo({
|
|
4785
4906
|
prepared: E,
|
|
4786
4907
|
paths: a.paths,
|
|
4787
4908
|
cwd: o,
|
|
4788
4909
|
spinner: c
|
|
4789
4910
|
});
|
|
4790
4911
|
let n;
|
|
4791
|
-
i && (n = await
|
|
4912
|
+
i && (n = await ba(o, e.yes ?? !1)), await pr({
|
|
4792
4913
|
projectRoot: o,
|
|
4793
4914
|
paths: a.paths,
|
|
4794
4915
|
skipPrompts: e.yes ?? !1,
|
|
4795
4916
|
dbReady: n,
|
|
4796
4917
|
freshScaffold: i
|
|
4797
|
-
}),
|
|
4918
|
+
}), Vo(), s.outro(B.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4798
4919
|
} finally {
|
|
4799
4920
|
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
4800
4921
|
recursive: !0,
|
|
@@ -4802,25 +4923,25 @@ async function Uo(e = {}) {
|
|
|
4802
4923
|
})));
|
|
4803
4924
|
}
|
|
4804
4925
|
}
|
|
4805
|
-
async function
|
|
4926
|
+
async function rs(e) {
|
|
4806
4927
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4807
4928
|
if (i.packs && i.packs.length > 0) {
|
|
4808
|
-
let e = i.packs.map(
|
|
4929
|
+
let e = i.packs.map(as), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4809
4930
|
return n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4810
4931
|
}
|
|
4811
4932
|
let o = t.filter((e) => n.has(e.name));
|
|
4812
|
-
o.length > 0 && s.note(o.map((e) => ` ${
|
|
4933
|
+
o.length > 0 && s.note(o.map((e) => ` ${B.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4813
4934
|
let c = t.filter((e) => !n.has(e.name));
|
|
4814
|
-
if (c.length === 0) return s.outro(
|
|
4815
|
-
let l =
|
|
4816
|
-
s.note(c.map((e) => ` ${
|
|
4817
|
-
let u =
|
|
4935
|
+
if (c.length === 0) return s.outro(B.muted("Every available pack is already installed.")), [];
|
|
4936
|
+
let l = se();
|
|
4937
|
+
s.note(c.map((e) => ` ${V.arrow} ${B.highlight(e.displayName)} ${he(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4938
|
+
let u = aa(c, { adminAvailable: a }), d = [];
|
|
4818
4939
|
for (let e of u) {
|
|
4819
4940
|
let t = e.packs.map((e) => {
|
|
4820
4941
|
let t = r(e.name);
|
|
4821
4942
|
return {
|
|
4822
4943
|
value: e.name,
|
|
4823
|
-
label: `${e.displayName} ${
|
|
4944
|
+
label: `${e.displayName} ${Io(t, e.price)}`,
|
|
4824
4945
|
hint: e.description
|
|
4825
4946
|
};
|
|
4826
4947
|
});
|
|
@@ -4837,7 +4958,7 @@ async function Wo(e) {
|
|
|
4837
4958
|
});
|
|
4838
4959
|
continue;
|
|
4839
4960
|
}
|
|
4840
|
-
let n = await
|
|
4961
|
+
let n = await Va({
|
|
4841
4962
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4842
4963
|
options: t,
|
|
4843
4964
|
required: !1
|
|
@@ -4847,20 +4968,20 @@ async function Wo(e) {
|
|
|
4847
4968
|
}
|
|
4848
4969
|
return d;
|
|
4849
4970
|
}
|
|
4850
|
-
var
|
|
4851
|
-
function
|
|
4852
|
-
let t = e.match(
|
|
4971
|
+
var is = /@(frontend|admin)$/;
|
|
4972
|
+
function as(e) {
|
|
4973
|
+
let t = e.match(is);
|
|
4853
4974
|
return t ? {
|
|
4854
4975
|
name: e.slice(0, -t[0].length),
|
|
4855
4976
|
slot: t[1]
|
|
4856
4977
|
} : { name: e };
|
|
4857
4978
|
}
|
|
4858
|
-
function
|
|
4979
|
+
function os(e) {
|
|
4859
4980
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4860
4981
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4861
4982
|
return n;
|
|
4862
4983
|
}
|
|
4863
|
-
function
|
|
4984
|
+
function ss(e) {
|
|
4864
4985
|
let t = /* @__PURE__ */ new Map();
|
|
4865
4986
|
for (let n of e) {
|
|
4866
4987
|
if (!n.slot) continue;
|
|
@@ -4871,109 +4992,32 @@ function Jo(e) {
|
|
|
4871
4992
|
}
|
|
4872
4993
|
//#endregion
|
|
4873
4994
|
//#region src/commands/login.ts
|
|
4874
|
-
async function
|
|
4875
|
-
|
|
4995
|
+
async function cs() {
|
|
4996
|
+
za(), s.intro(B.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
4876
4997
|
let e;
|
|
4877
4998
|
try {
|
|
4878
4999
|
e = await tr({ onUrl: (e) => {
|
|
4879
|
-
s.log.info(`If your browser didn't open, visit:\n ${
|
|
5000
|
+
s.log.info(`If your browser didn't open, visit:\n ${B.path(e)}`);
|
|
4880
5001
|
} });
|
|
4881
5002
|
} catch (e) {
|
|
4882
5003
|
s.cancel(e instanceof Error ? e.message : String(e)), process.exit(1);
|
|
4883
5004
|
}
|
|
4884
|
-
s.outro(
|
|
5005
|
+
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."));
|
|
4885
5006
|
}
|
|
4886
5007
|
//#endregion
|
|
4887
5008
|
//#region src/commands/logout.ts
|
|
4888
|
-
async function
|
|
4889
|
-
|
|
4890
|
-
let e =
|
|
5009
|
+
async function ls() {
|
|
5010
|
+
za(), s.intro(B.brandBold("Log out of Hype Stack"));
|
|
5011
|
+
let e = L(), t = await Kn(e);
|
|
4891
5012
|
if (!t) {
|
|
4892
|
-
s.outro(
|
|
5013
|
+
s.outro(B.muted("You're not logged in."));
|
|
4893
5014
|
return;
|
|
4894
5015
|
}
|
|
4895
|
-
await Rn(t.token).catch(() => null), await Jn(e), s.outro(
|
|
4896
|
-
}
|
|
4897
|
-
//#endregion
|
|
4898
|
-
//#region src/core/onboard-catalog.ts
|
|
4899
|
-
var $ = {
|
|
4900
|
-
Config: "config",
|
|
4901
|
-
Databases: "databases",
|
|
4902
|
-
Workos: "workos",
|
|
4903
|
-
BetterAuth: "betterauth",
|
|
4904
|
-
Stripe: "stripe",
|
|
4905
|
-
Polar: "polar",
|
|
4906
|
-
Resend: "resend",
|
|
4907
|
-
IpLocate: "iplocate",
|
|
4908
|
-
Sentry: "sentry"
|
|
4909
|
-
}, Zo = new Set(Object.values($));
|
|
4910
|
-
function Qo(e) {
|
|
4911
|
-
return e.toLowerCase().replace(/[^a-z0-9]+/g, "").trim();
|
|
4912
|
-
}
|
|
4913
|
-
function $o(e) {
|
|
4914
|
-
let t = Qo(e);
|
|
4915
|
-
return Zo.has(t) ? t : void 0;
|
|
4916
|
-
}
|
|
4917
|
-
var es = {
|
|
4918
|
-
[$.Config]: { hint: "App URLs. Defaults work for local dev." },
|
|
4919
|
-
[$.Databases]: { hint: "Credentials for the local Docker Postgres and Valkey containers." },
|
|
4920
|
-
[$.Workos]: {
|
|
4921
|
-
link: "https://dashboard.workos.com/api-keys",
|
|
4922
|
-
hint: "Copy your API Key and Client ID from the WorkOS dashboard."
|
|
4923
|
-
},
|
|
4924
|
-
[$.BetterAuth]: {
|
|
4925
|
-
link: "https://www.better-auth.com/docs/installation#set-environment-variables",
|
|
4926
|
-
hint: "Generate a long random secret, set the app URL, add Google OAuth creds if you use Google."
|
|
4927
|
-
},
|
|
4928
|
-
[$.Stripe]: {
|
|
4929
|
-
link: "https://dashboard.stripe.com/apikeys",
|
|
4930
|
-
hint: "Copy your secret and publishable keys from the Stripe dashboard.",
|
|
4931
|
-
serviceChecklist: [
|
|
4932
|
-
"Recurring prices for Pro and Premier power checkout (set STRIPE_PRICE_PRO and STRIPE_PRICE_PREMIER).",
|
|
4933
|
-
"A webhook at /checkout/webhook keeps subscriptions in sync (subscription events plus invoice.payment_succeeded).",
|
|
4934
|
-
"Enable the Stripe billing portal so Manage Billing and invoices work.",
|
|
4935
|
-
"Enable 'Limit customers to one subscription' to prevent double-checkout races.",
|
|
4936
|
-
"Optional: disable Cash App Pay if you see a high checkout cancel rate."
|
|
4937
|
-
]
|
|
4938
|
-
},
|
|
4939
|
-
[$.Polar]: {
|
|
4940
|
-
link: "https://polar.sh",
|
|
4941
|
-
hint: "From your Polar org: access token, webhook secret, organization id, and the checkout product id."
|
|
4942
|
-
},
|
|
4943
|
-
[$.Resend]: {
|
|
4944
|
-
link: "https://resend.com/api-keys",
|
|
4945
|
-
hint: "Create an API key in Resend."
|
|
4946
|
-
},
|
|
4947
|
-
[$.IpLocate]: {
|
|
4948
|
-
link: "https://iplocate.io",
|
|
4949
|
-
hint: "Grab your API key from IP Locate."
|
|
4950
|
-
},
|
|
4951
|
-
[$.Sentry]: {
|
|
4952
|
-
link: "https://sentry.io",
|
|
4953
|
-
hint: "Your project DSN. Leave blank to skip Sentry for now."
|
|
4954
|
-
}
|
|
4955
|
-
}, ts = { hint: "Add your value, or press Enter to leave it blank." };
|
|
4956
|
-
function ns(e) {
|
|
4957
|
-
let t = $o(e);
|
|
4958
|
-
return t ? es[t] : ts;
|
|
4959
|
-
}
|
|
4960
|
-
var rs = {
|
|
4961
|
-
"starter-saas-workos": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4962
|
-
"starter-saas-betterauth": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4963
|
-
"pack-notifications": ["Notifications push over the `appChannel` socket channel; register it in your server startup to go live."],
|
|
4964
|
-
"pack-collaboration": ["Team and TeamMember are available as CASL subjects; project member and team management reuse the existing `Project` subject."]
|
|
4965
|
-
};
|
|
4966
|
-
function is(e) {
|
|
4967
|
-
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4968
|
-
for (let r of e) {
|
|
4969
|
-
let e = rs[r];
|
|
4970
|
-
if (e) for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
4971
|
-
}
|
|
4972
|
-
return n;
|
|
5016
|
+
await Rn(t.token).catch(() => null), await Jn(e), s.outro(B.brand("Logged out."));
|
|
4973
5017
|
}
|
|
4974
5018
|
//#endregion
|
|
4975
5019
|
//#region src/core/onboard-env.ts
|
|
4976
|
-
function
|
|
5020
|
+
function us(e) {
|
|
4977
5021
|
let t = [], n = "";
|
|
4978
5022
|
for (let r of e.split(/\r?\n/)) {
|
|
4979
5023
|
let e = r.trim();
|
|
@@ -4999,19 +5043,19 @@ function as(e) {
|
|
|
4999
5043
|
}
|
|
5000
5044
|
return t;
|
|
5001
5045
|
}
|
|
5002
|
-
var
|
|
5046
|
+
var ds = [
|
|
5003
5047
|
"replace-with",
|
|
5004
5048
|
"examplepublickey",
|
|
5005
5049
|
"change-me",
|
|
5006
5050
|
"your-key-here"
|
|
5007
5051
|
];
|
|
5008
|
-
function
|
|
5052
|
+
function fs(e) {
|
|
5009
5053
|
let t = e.trim();
|
|
5010
5054
|
if (t === "") return !0;
|
|
5011
5055
|
let n = t.toLowerCase();
|
|
5012
|
-
return
|
|
5056
|
+
return ds.some((e) => n.includes(e));
|
|
5013
5057
|
}
|
|
5014
|
-
function
|
|
5058
|
+
function ps(e, t, n) {
|
|
5015
5059
|
let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
|
|
5016
5060
|
if (i) return e;
|
|
5017
5061
|
let r = e.trim();
|
|
@@ -5021,108 +5065,118 @@ function cs(e, t, n) {
|
|
|
5021
5065
|
});
|
|
5022
5066
|
return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
|
|
5023
5067
|
}
|
|
5024
|
-
async function
|
|
5068
|
+
async function ms(e) {
|
|
5025
5069
|
return await J(e) ? y.readFile(e, "utf-8") : "";
|
|
5026
5070
|
}
|
|
5027
|
-
async function
|
|
5071
|
+
async function hs(e) {
|
|
5028
5072
|
let t = T.join(T.dirname(e), ".env");
|
|
5029
5073
|
return await J(t) || await y.copyFile(e, t), t;
|
|
5030
5074
|
}
|
|
5031
|
-
async function
|
|
5032
|
-
let r =
|
|
5075
|
+
async function gs(e, t, n) {
|
|
5076
|
+
let r = ps(await ms(e), t, n);
|
|
5033
5077
|
await y.writeFile(e, r, "utf-8");
|
|
5034
5078
|
}
|
|
5035
5079
|
//#endregion
|
|
5036
5080
|
//#region src/commands/onboard.ts
|
|
5037
|
-
async function
|
|
5081
|
+
async function _s(e = {}) {
|
|
5038
5082
|
let t = e.cwd ?? process.cwd();
|
|
5039
|
-
|
|
5083
|
+
Ra(), s.intro(B.brandBold("Onboard your stack"));
|
|
5040
5084
|
let n;
|
|
5041
5085
|
try {
|
|
5042
|
-
n = await
|
|
5086
|
+
n = await Or(t);
|
|
5043
5087
|
} catch {
|
|
5044
5088
|
n = null;
|
|
5045
5089
|
}
|
|
5046
|
-
n || (s.cancel(`${
|
|
5047
|
-
let r = await
|
|
5048
|
-
|
|
5049
|
-
for (let n of
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5090
|
+
n || (s.cancel(`${B.path("stack.json")} not found. Run ${B.command("npx @hype-stack/cli init")} first.`), process.exit(1));
|
|
5091
|
+
let r = n.installedPacks ?? [], i = n.onboarding?.envSections ?? [], a = await fo(t);
|
|
5092
|
+
a.length === 0 && s.log.warn(B.muted("No .env.example files found; skipping env setup."));
|
|
5093
|
+
for (let n of a) await vs({
|
|
5094
|
+
examplePath: n,
|
|
5095
|
+
projectRoot: t,
|
|
5096
|
+
skipPrompts: e.yes ?? !1,
|
|
5097
|
+
installedEnvSections: i
|
|
5098
|
+
});
|
|
5099
|
+
let o = Dr(r);
|
|
5100
|
+
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.`));
|
|
5101
|
+
}
|
|
5102
|
+
async function vs(e) {
|
|
5103
|
+
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);
|
|
5104
|
+
s.log.step(`Env: ${u}`);
|
|
5105
|
+
for (let e of l) {
|
|
5106
|
+
let t = e.vars.filter((e) => fs(e.value));
|
|
5058
5107
|
if (t.length === 0) continue;
|
|
5059
|
-
|
|
5060
|
-
|
|
5108
|
+
if (!Cr(e.section, i)) {
|
|
5109
|
+
let t = e.section ? B.bold(e.section) : B.bold("Variables");
|
|
5110
|
+
s.log.info(`${t} ${B.muted("skipped (pack not installed)")}`);
|
|
5111
|
+
continue;
|
|
5112
|
+
}
|
|
5113
|
+
let n = xr(e.section), a = e.section ? B.bold(e.section) : B.bold("Variables");
|
|
5114
|
+
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));
|
|
5061
5115
|
for (let e of t) {
|
|
5062
|
-
if (
|
|
5063
|
-
s.log.info(`${
|
|
5116
|
+
if (r) {
|
|
5117
|
+
s.log.info(`${B.label(e.key)} ${B.muted("skipped (non-interactive)")}`);
|
|
5064
5118
|
continue;
|
|
5065
5119
|
}
|
|
5066
|
-
let t =
|
|
5067
|
-
message: `${
|
|
5068
|
-
placeholder: t ||
|
|
5120
|
+
let t = ys(c, e.key), i = await s.text({
|
|
5121
|
+
message: `${B.label(e.key)}`,
|
|
5122
|
+
placeholder: t || n.hint
|
|
5069
5123
|
});
|
|
5070
|
-
s.isCancel(
|
|
5071
|
-
let
|
|
5072
|
-
if (
|
|
5073
|
-
s.log.warn(
|
|
5124
|
+
s.isCancel(i) && Z();
|
|
5125
|
+
let a = (i ?? "").trim();
|
|
5126
|
+
if (a === "") {
|
|
5127
|
+
s.log.warn(B.muted(`${e.key} left blank.`));
|
|
5074
5128
|
continue;
|
|
5075
5129
|
}
|
|
5076
|
-
await
|
|
5130
|
+
await gs(o, e.key, a), s.log.success(`${e.key} saved`);
|
|
5077
5131
|
}
|
|
5078
5132
|
}
|
|
5079
5133
|
}
|
|
5080
|
-
function
|
|
5134
|
+
function ys(e, t) {
|
|
5081
5135
|
for (let n of e.split(/\r?\n/)) {
|
|
5082
|
-
let e = n.match(RegExp(`^${
|
|
5136
|
+
let e = n.match(RegExp(`^${bs(t)}\\s*=\\s*(.*)$`));
|
|
5083
5137
|
if (e) return e[1].trim();
|
|
5084
5138
|
}
|
|
5085
5139
|
return "";
|
|
5086
5140
|
}
|
|
5087
|
-
function
|
|
5141
|
+
function bs(e) {
|
|
5088
5142
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5089
5143
|
}
|
|
5090
|
-
async function
|
|
5091
|
-
if (!await
|
|
5092
|
-
s.log.info(
|
|
5144
|
+
async function xs(e, t) {
|
|
5145
|
+
if (!await la() && !await da(e, t, !1)) {
|
|
5146
|
+
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")}.`));
|
|
5093
5147
|
return;
|
|
5094
5148
|
}
|
|
5095
5149
|
let n = s.spinner();
|
|
5096
|
-
if (n.start("Waiting for Postgres to be ready..."), !await
|
|
5097
|
-
n.error("Postgres health check timed out"), s.log.warn(
|
|
5150
|
+
if (n.start("Waiting for Postgres to be ready..."), !await pa(e)) {
|
|
5151
|
+
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")}`));
|
|
5098
5152
|
return;
|
|
5099
5153
|
}
|
|
5100
|
-
if (n.stop(
|
|
5101
|
-
s.log.info(
|
|
5154
|
+
if (n.stop(B.success("Postgres is ready")), await ha(e)) {
|
|
5155
|
+
s.log.info(B.muted("Migrations already applied, skipping."));
|
|
5102
5156
|
return;
|
|
5103
5157
|
}
|
|
5104
5158
|
let r = t ? !0 : await s.confirm({
|
|
5105
|
-
message: `Run database migrations with ${
|
|
5159
|
+
message: `Run database migrations with ${B.command("prisma migrate deploy")}?`,
|
|
5106
5160
|
initialValue: !0
|
|
5107
5161
|
});
|
|
5108
|
-
if (s.isCancel(r) &&
|
|
5109
|
-
s.log.info(
|
|
5162
|
+
if (s.isCancel(r) && Z(), !r) {
|
|
5163
|
+
s.log.info(B.muted("Skipping database migrations."));
|
|
5110
5164
|
return;
|
|
5111
5165
|
}
|
|
5112
|
-
await
|
|
5166
|
+
await ga(e);
|
|
5113
5167
|
}
|
|
5114
5168
|
//#endregion
|
|
5115
5169
|
//#region src/core/templates.ts
|
|
5116
|
-
var
|
|
5170
|
+
var Ss = K.createRequest()({
|
|
5117
5171
|
endpoint: "/templates/list",
|
|
5118
5172
|
method: "GET"
|
|
5119
5173
|
});
|
|
5120
|
-
async function
|
|
5121
|
-
let { data: e, error: t } = await
|
|
5174
|
+
async function Cs() {
|
|
5175
|
+
let { data: e, error: t } = await Ss.send();
|
|
5122
5176
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
5123
5177
|
return e.templates;
|
|
5124
5178
|
}
|
|
5125
|
-
async function
|
|
5179
|
+
async function ws(e) {
|
|
5126
5180
|
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
5127
5181
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
5128
5182
|
method: "GET"
|
|
@@ -5131,7 +5185,7 @@ async function ys(e) {
|
|
|
5131
5185
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
5132
5186
|
return t;
|
|
5133
5187
|
}
|
|
5134
|
-
async function
|
|
5188
|
+
async function Ts(e, t = {}) {
|
|
5135
5189
|
let n = K.createRequest()({
|
|
5136
5190
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
5137
5191
|
method: "POST"
|
|
@@ -5159,29 +5213,29 @@ async function bs(e, t = {}) {
|
|
|
5159
5213
|
}
|
|
5160
5214
|
//#endregion
|
|
5161
5215
|
//#region src/commands/template.ts
|
|
5162
|
-
async function
|
|
5216
|
+
async function Es(t = {}) {
|
|
5163
5217
|
let n = t.cwd ?? process.cwd();
|
|
5164
|
-
|
|
5218
|
+
Ra();
|
|
5165
5219
|
let r = s.spinner();
|
|
5166
5220
|
r.start("Loading packs...");
|
|
5167
5221
|
let o;
|
|
5168
5222
|
try {
|
|
5169
|
-
o = await
|
|
5223
|
+
o = await Br();
|
|
5170
5224
|
} catch (e) {
|
|
5171
|
-
r.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${
|
|
5225
|
+
r.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
5172
5226
|
}
|
|
5173
5227
|
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
5174
5228
|
let c;
|
|
5175
5229
|
try {
|
|
5176
|
-
c = await
|
|
5230
|
+
c = await Cs();
|
|
5177
5231
|
} catch (e) {
|
|
5178
|
-
r.stop("Failed to load templates"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${
|
|
5232
|
+
r.stop("Failed to load templates"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
5179
5233
|
}
|
|
5180
5234
|
let l = t.templateId;
|
|
5181
5235
|
if (!l) {
|
|
5182
5236
|
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");
|
|
5183
|
-
let e =
|
|
5184
|
-
s.note(c.map((t) => ` ${
|
|
5237
|
+
let e = se();
|
|
5238
|
+
s.note(c.map((t) => ` ${V.arrow} ${B.highlight(t.name)} ${he(`${e}/templates/${t.id}`)}`).join("\n"), "Browse templates");
|
|
5185
5239
|
let n = await s.select({
|
|
5186
5240
|
message: "Choose a template",
|
|
5187
5241
|
options: c.map((e) => ({
|
|
@@ -5196,151 +5250,151 @@ async function xs(t = {}) {
|
|
|
5196
5250
|
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}`);
|
|
5197
5251
|
let d;
|
|
5198
5252
|
try {
|
|
5199
|
-
d = await
|
|
5253
|
+
d = await ws(u.id);
|
|
5200
5254
|
} catch (e) {
|
|
5201
|
-
s.cancel(
|
|
5255
|
+
s.cancel($(e)), process.exit(1);
|
|
5202
5256
|
}
|
|
5203
|
-
let f = await
|
|
5257
|
+
let f = await ts(n, {}, {
|
|
5204
5258
|
defaultTheme: d.theme,
|
|
5205
5259
|
defaultMode: d.defaultMode
|
|
5206
5260
|
}), p = f?.projectRoot ?? null, m = f?.scaffolded ?? !1, h;
|
|
5207
5261
|
try {
|
|
5208
|
-
h = await
|
|
5262
|
+
h = await Or(p ?? n);
|
|
5209
5263
|
} catch (e) {
|
|
5210
|
-
s.cancel(`Could not parse ${
|
|
5264
|
+
s.cancel(`Could not parse ${B.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
5211
5265
|
}
|
|
5212
|
-
h || (s.cancel(p ? `Could not read ${
|
|
5266
|
+
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));
|
|
5213
5267
|
let g = p ?? n;
|
|
5214
|
-
s.intro(
|
|
5215
|
-
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await Kn(
|
|
5268
|
+
s.intro(B.brandBold("Install a template"));
|
|
5269
|
+
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({
|
|
5216
5270
|
packs: o,
|
|
5217
5271
|
templatePacks: E,
|
|
5218
5272
|
installedSet: v,
|
|
5219
5273
|
options: t
|
|
5220
5274
|
}), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
|
|
5221
5275
|
k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
|
|
5222
|
-
let ee =
|
|
5276
|
+
let ee = ka(o, w), A = xa(ee), j;
|
|
5223
5277
|
try {
|
|
5224
|
-
j =
|
|
5278
|
+
j = Ca(O, A, _);
|
|
5225
5279
|
} catch (e) {
|
|
5226
|
-
s.cancel(
|
|
5280
|
+
s.cancel($(e)), process.exit(1);
|
|
5227
5281
|
}
|
|
5228
5282
|
if (j.order.length === 0) {
|
|
5229
|
-
s.outro(
|
|
5283
|
+
s.outro(B.muted("Every pack in this template is already installed."));
|
|
5230
5284
|
return;
|
|
5231
5285
|
}
|
|
5232
|
-
let
|
|
5286
|
+
let M = await Fo(ee, v, {
|
|
5233
5287
|
token: S,
|
|
5234
5288
|
key: x
|
|
5235
|
-
}),
|
|
5289
|
+
}), te = (e) => {
|
|
5236
5290
|
let t = b.get(e);
|
|
5237
|
-
return !t || t.tier === "free" ? "free" :
|
|
5238
|
-
},
|
|
5291
|
+
return !t || t.tier === "free" ? "free" : M[e]?.owned ? "owned" : "locked";
|
|
5292
|
+
}, N = (e) => !v.has(e) && te(e) === "locked", P = wa({
|
|
5239
5293
|
order: j.order,
|
|
5240
5294
|
graph: A,
|
|
5241
|
-
isLocked:
|
|
5295
|
+
isLocked: N,
|
|
5242
5296
|
installed: _
|
|
5243
5297
|
});
|
|
5244
|
-
if (
|
|
5298
|
+
if (P.blocked.length > 0 && !S && !x) {
|
|
5245
5299
|
let e = await nr();
|
|
5246
|
-
e && (S = e,
|
|
5300
|
+
e && (S = e, M = await Fo(ee, v, {
|
|
5247
5301
|
token: S,
|
|
5248
5302
|
key: x
|
|
5249
|
-
}),
|
|
5303
|
+
}), P = wa({
|
|
5250
5304
|
order: j.order,
|
|
5251
5305
|
graph: A,
|
|
5252
|
-
isLocked:
|
|
5306
|
+
isLocked: N,
|
|
5253
5307
|
installed: _
|
|
5254
5308
|
}));
|
|
5255
5309
|
}
|
|
5256
|
-
if (
|
|
5257
|
-
s.outro(
|
|
5310
|
+
if (P.blocked.length > 0 && await Lo(P.blocked, N, b), P.installable.length === 0) {
|
|
5311
|
+
s.outro(B.muted("Nothing left to install once locked packs are removed."));
|
|
5258
5312
|
return;
|
|
5259
5313
|
}
|
|
5260
|
-
if (
|
|
5261
|
-
let e = await s.confirm({ message: `Install template ${
|
|
5314
|
+
if (Ro(P.installable, b), !t.yes) {
|
|
5315
|
+
let e = await s.confirm({ message: `Install template ${B.brandBold(u.name)} (${P.installable.length} pack${P.installable.length === 1 ? "" : "s"})?` });
|
|
5262
5316
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5263
5317
|
}
|
|
5264
5318
|
r.start("Downloading packs...");
|
|
5265
|
-
let
|
|
5319
|
+
let F;
|
|
5266
5320
|
try {
|
|
5267
|
-
|
|
5321
|
+
F = await zo(P.installable, {
|
|
5268
5322
|
token: S,
|
|
5269
5323
|
key: x
|
|
5270
5324
|
});
|
|
5271
5325
|
} catch (e) {
|
|
5272
|
-
r.stop("Download failed"), s.cancel(
|
|
5326
|
+
r.stop("Download failed"), s.cancel($(e)), process.exit(1);
|
|
5273
5327
|
}
|
|
5274
|
-
r.stop(`Downloaded ${
|
|
5275
|
-
let
|
|
5276
|
-
prepared:
|
|
5328
|
+
r.stop(`Downloaded ${F.length} pack${F.length === 1 ? "" : "s"}`);
|
|
5329
|
+
let ne = await Uo({
|
|
5330
|
+
prepared: F,
|
|
5277
5331
|
config: h,
|
|
5278
5332
|
cwd: g,
|
|
5279
5333
|
force: t.force ?? !1,
|
|
5280
5334
|
yes: t.yes ?? !1
|
|
5281
|
-
}),
|
|
5335
|
+
}), I = null;
|
|
5282
5336
|
try {
|
|
5283
5337
|
r.start("Installing pack files...");
|
|
5284
|
-
let n = await
|
|
5285
|
-
packs:
|
|
5338
|
+
let n = await Zi({
|
|
5339
|
+
packs: F,
|
|
5286
5340
|
config: h,
|
|
5287
5341
|
projectRoot: g,
|
|
5288
5342
|
force: t.force ?? !1,
|
|
5289
|
-
overwrite:
|
|
5343
|
+
overwrite: ne
|
|
5290
5344
|
});
|
|
5291
5345
|
if (n.aborted) {
|
|
5292
5346
|
r.stop("Installation aborted");
|
|
5293
5347
|
for (let e of n.errors) s.log.error(e);
|
|
5294
5348
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5295
5349
|
}
|
|
5296
|
-
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${
|
|
5350
|
+
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));
|
|
5297
5351
|
for (let e of n.errors) s.log.error(e);
|
|
5298
5352
|
r.start("Applying template overrides...");
|
|
5299
|
-
let o = await
|
|
5353
|
+
let o = await Ts(u.id, {
|
|
5300
5354
|
token: S,
|
|
5301
5355
|
licenseKey: x
|
|
5302
5356
|
});
|
|
5303
|
-
o.status === "denied" && (r.stop("Template download denied"), s.cancel(`Access to template "${u.id}" was denied (${o.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)),
|
|
5304
|
-
let c = await
|
|
5357
|
+
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;
|
|
5358
|
+
let c = await $i({
|
|
5305
5359
|
manifest: d,
|
|
5306
5360
|
config: h,
|
|
5307
5361
|
projectRoot: g,
|
|
5308
|
-
templateDir:
|
|
5362
|
+
templateDir: I
|
|
5309
5363
|
});
|
|
5310
5364
|
r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
|
|
5311
5365
|
for (let e of c.errors) s.log.error(e);
|
|
5312
5366
|
if (!m) {
|
|
5313
5367
|
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5314
|
-
a(n) && (await
|
|
5368
|
+
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`)));
|
|
5315
5369
|
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5316
|
-
await
|
|
5370
|
+
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`));
|
|
5317
5371
|
}
|
|
5318
|
-
await
|
|
5319
|
-
prepared:
|
|
5372
|
+
await ks({
|
|
5373
|
+
prepared: F,
|
|
5320
5374
|
templateNpm: d.dependencies_npm,
|
|
5321
5375
|
paths: h.paths,
|
|
5322
5376
|
cwd: g,
|
|
5323
5377
|
spinner: r
|
|
5324
5378
|
});
|
|
5325
5379
|
let l;
|
|
5326
|
-
m && (l = await
|
|
5380
|
+
m && (l = await ba(g, t.yes ?? !1)), await pr({
|
|
5327
5381
|
projectRoot: g,
|
|
5328
5382
|
paths: h.paths,
|
|
5329
5383
|
skipPrompts: t.yes ?? !1,
|
|
5330
5384
|
dbReady: l,
|
|
5331
5385
|
freshScaffold: m
|
|
5332
|
-
}),
|
|
5386
|
+
}), Vo(), s.outro(B.brand(`Installed template ${u.name}.`));
|
|
5333
5387
|
} finally {
|
|
5334
|
-
await Promise.all(
|
|
5388
|
+
await Promise.all(F.map((e) => y.rm(e.packDir, {
|
|
5335
5389
|
recursive: !0,
|
|
5336
5390
|
force: !0
|
|
5337
|
-
}))),
|
|
5391
|
+
}))), I && await y.rm(I, {
|
|
5338
5392
|
recursive: !0,
|
|
5339
5393
|
force: !0
|
|
5340
5394
|
});
|
|
5341
5395
|
}
|
|
5342
5396
|
}
|
|
5343
|
-
async function
|
|
5397
|
+
async function Ds(e, t, n) {
|
|
5344
5398
|
let r = {};
|
|
5345
5399
|
for (let i of e.slots) {
|
|
5346
5400
|
if (t?.[i.family]) {
|
|
@@ -5364,7 +5418,7 @@ async function Ss(e, t, n) {
|
|
|
5364
5418
|
}
|
|
5365
5419
|
return r;
|
|
5366
5420
|
}
|
|
5367
|
-
async function
|
|
5421
|
+
async function Os(e) {
|
|
5368
5422
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5369
5423
|
if (i.packs && i.packs.length > 0) {
|
|
5370
5424
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -5373,9 +5427,9 @@ async function Cs(e) {
|
|
|
5373
5427
|
if (i.yes) return [];
|
|
5374
5428
|
let o = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
|
|
5375
5429
|
if (o.length === 0) return [];
|
|
5376
|
-
let c =
|
|
5377
|
-
s.note(o.map((e) => ` ${
|
|
5378
|
-
let l = await
|
|
5430
|
+
let c = se();
|
|
5431
|
+
s.note(o.map((e) => ` ${V.arrow} ${B.highlight(e.displayName)} ${he(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5432
|
+
let l = await Va({
|
|
5379
5433
|
message: "Add extra packs on top of the template (optional)",
|
|
5380
5434
|
options: o.map((e) => ({
|
|
5381
5435
|
value: e.name,
|
|
@@ -5386,25 +5440,25 @@ async function Cs(e) {
|
|
|
5386
5440
|
});
|
|
5387
5441
|
return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
|
|
5388
5442
|
}
|
|
5389
|
-
async function
|
|
5390
|
-
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o =
|
|
5443
|
+
async function ks(e) {
|
|
5444
|
+
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);
|
|
5391
5445
|
if (c.errors.length > 0) {
|
|
5392
5446
|
for (let e of c.errors) s.log.error(e);
|
|
5393
5447
|
return;
|
|
5394
5448
|
}
|
|
5395
5449
|
if (c.operations.length === 0) return;
|
|
5396
5450
|
a.start("Installing npm dependencies...");
|
|
5397
|
-
let l = await
|
|
5451
|
+
let l = await Po(c.operations, i);
|
|
5398
5452
|
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) s.log.error(e);
|
|
5399
5453
|
}
|
|
5400
5454
|
//#endregion
|
|
5401
5455
|
//#region src/cli.ts
|
|
5402
|
-
function
|
|
5456
|
+
function As(e) {
|
|
5403
5457
|
if (!e) return;
|
|
5404
5458
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5405
5459
|
return t.length > 0 ? t : void 0;
|
|
5406
5460
|
}
|
|
5407
|
-
function
|
|
5461
|
+
function js(e) {
|
|
5408
5462
|
if (!e) return;
|
|
5409
5463
|
let t = {};
|
|
5410
5464
|
for (let n of e.split(",")) {
|
|
@@ -5413,10 +5467,10 @@ function Es(e) {
|
|
|
5413
5467
|
}
|
|
5414
5468
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5415
5469
|
}
|
|
5416
|
-
function
|
|
5470
|
+
function Ms() {
|
|
5417
5471
|
let e = new o();
|
|
5418
5472
|
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) => {
|
|
5419
|
-
await
|
|
5473
|
+
await $o({
|
|
5420
5474
|
name: e.name,
|
|
5421
5475
|
directory: e.directory,
|
|
5422
5476
|
install: e.install,
|
|
@@ -5426,38 +5480,38 @@ function Ds() {
|
|
|
5426
5480
|
setup: e.setup
|
|
5427
5481
|
});
|
|
5428
5482
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5429
|
-
await
|
|
5483
|
+
await es({});
|
|
5430
5484
|
}), 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) => {
|
|
5431
|
-
await
|
|
5485
|
+
await _s({
|
|
5432
5486
|
cwd: e.cwd,
|
|
5433
5487
|
yes: e.yes,
|
|
5434
5488
|
skipMigrations: e.skipMigrations
|
|
5435
5489
|
});
|
|
5436
5490
|
}), 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) => {
|
|
5437
|
-
await
|
|
5438
|
-
packs:
|
|
5491
|
+
await ns({
|
|
5492
|
+
packs: As(e.packs),
|
|
5439
5493
|
force: e.force,
|
|
5440
5494
|
yes: e.yes,
|
|
5441
5495
|
licenseKey: e.key ?? e.licenseKey,
|
|
5442
5496
|
cwd: e.cwd
|
|
5443
5497
|
});
|
|
5444
5498
|
}), 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) => {
|
|
5445
|
-
await
|
|
5499
|
+
await Es({
|
|
5446
5500
|
templateId: e,
|
|
5447
|
-
variants:
|
|
5448
|
-
packs:
|
|
5501
|
+
variants: js(t.variants),
|
|
5502
|
+
packs: As(t.packs),
|
|
5449
5503
|
force: t.force,
|
|
5450
5504
|
yes: t.yes,
|
|
5451
5505
|
licenseKey: t.key ?? t.licenseKey,
|
|
5452
5506
|
cwd: t.cwd
|
|
5453
5507
|
});
|
|
5454
5508
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5455
|
-
await
|
|
5509
|
+
await cs();
|
|
5456
5510
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5457
|
-
await
|
|
5511
|
+
await ls();
|
|
5458
5512
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5459
|
-
await
|
|
5513
|
+
await cs();
|
|
5460
5514
|
}), e;
|
|
5461
5515
|
}
|
|
5462
5516
|
//#endregion
|
|
5463
|
-
export {
|
|
5517
|
+
export { ts as a, ns as i, ls as n, es as o, cs as r, $o as s, Ms as t };
|