@hype-stack/cli 0.5.2 → 0.5.3
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-cPE06mGY.js → cli-NswFvMgQ.js} +629 -606
- package/dist/commands/compose.d.ts.map +1 -1
- package/dist/commands/template.d.ts.map +1 -1
- package/dist/config/bin.js +1 -1
- package/dist/core/codegen.d.ts +2 -0
- package/dist/core/codegen.d.ts.map +1 -1
- package/dist/core/post-setup.d.ts +10 -0
- package/dist/core/post-setup.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/exec.d.ts +10 -0
- package/dist/utils/exec.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.3", j = "gh:BetterTyped/hype-stack", te = "stack.json", ne = "/schema/stack.json", M = "https://api.hype-stack.dev", N = "HYPE_STACK_API_URL", P = "https://www.hype-stack.dev", re = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, F = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -31,38 +31,38 @@ var A = "0.5.2", te = "gh:BetterTyped/hype-stack", ne = "stack.json", re = "/sch
|
|
|
31
31
|
value: "copilot",
|
|
32
32
|
label: "GitHub Copilot"
|
|
33
33
|
}
|
|
34
|
-
],
|
|
35
|
-
function
|
|
34
|
+
], ie = F.map((e) => e.value), ae = ".cursor/rules", oe = ".cursor", se = ".agents";
|
|
35
|
+
function I() {
|
|
36
36
|
let e = process.env.HYPE_STACK_API_URL;
|
|
37
|
-
return e ? (
|
|
37
|
+
return e ? (le(e), e.replace(/\/+$/, "")) : M;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function ce() {
|
|
40
40
|
let e = process.env.HYPE_STACK_WEB_URL;
|
|
41
|
-
return e ? (
|
|
41
|
+
return e ? (le(e), e.replace(/\/+$/, "")) : P;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function le(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(`${N} 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(`${N} is not a valid URL: "${e}"`, { cause: t }) : t;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return `${
|
|
51
|
+
function ue() {
|
|
52
|
+
return `${I()}${ne}`;
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/ui/theme.ts
|
|
56
|
-
var
|
|
57
|
-
orange:
|
|
58
|
-
orangeBright:
|
|
59
|
-
amber:
|
|
56
|
+
var de = (e) => `\x1b[38;5;208m${e}\x1b[39m`, fe = (e) => `\x1b[38;5;214m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;220m${e}\x1b[39m`, me = (e) => `\x1b[38;5;33m${e}\x1b[39m`, L = (e) => `\x1b[38;5;39m${e}\x1b[39m`, he = (e) => `\x1b[38;5;81m${e}\x1b[39m`, ge = {
|
|
57
|
+
orange: de,
|
|
58
|
+
orangeBright: fe,
|
|
59
|
+
amber: pe,
|
|
60
60
|
deepBlue: me,
|
|
61
61
|
skyBlue: L,
|
|
62
62
|
lightBlue: he
|
|
63
63
|
}, R = {
|
|
64
|
-
brand: (e) =>
|
|
65
|
-
brandBold: (e) => b.bold(
|
|
64
|
+
brand: (e) => de(e),
|
|
65
|
+
brandBold: (e) => b.bold(de(e)),
|
|
66
66
|
accent: (e) => L(e),
|
|
67
67
|
accentBold: (e) => b.bold(L(e)),
|
|
68
68
|
success: (e) => b.green(e),
|
|
@@ -72,27 +72,27 @@ var fe = (e) => `\x1b[38;5;208m${e}\x1b[39m`, pe = (e) => `\x1b[38;5;214m${e}\x1
|
|
|
72
72
|
bold: (e) => b.bold(e),
|
|
73
73
|
highlight: (e) => b.bold(b.white(e)),
|
|
74
74
|
path: (e) => b.underline(L(e)),
|
|
75
|
-
command: (e) => b.bold(
|
|
75
|
+
command: (e) => b.bold(pe(e)),
|
|
76
76
|
label: (e) => b.dim(b.bold(e))
|
|
77
77
|
};
|
|
78
78
|
function _e(e, t = e) {
|
|
79
79
|
return `\x1b]8;;${e}\x07${L(t)}\x1b]8;;\x07`;
|
|
80
80
|
}
|
|
81
81
|
var z = {
|
|
82
|
-
arrow:
|
|
82
|
+
arrow: de("›"),
|
|
83
83
|
bullet: R.muted("·"),
|
|
84
84
|
dash: R.muted("─"),
|
|
85
85
|
corner: R.muted("╰"),
|
|
86
86
|
pipe: R.muted("│"),
|
|
87
87
|
dot: R.muted("•"),
|
|
88
|
-
spark:
|
|
89
|
-
sparkSmall:
|
|
90
|
-
bolt:
|
|
88
|
+
spark: pe("✦"),
|
|
89
|
+
sparkSmall: fe("✧"),
|
|
90
|
+
bolt: pe("⚡")
|
|
91
91
|
}, ve = [
|
|
92
|
-
|
|
93
|
-
I,
|
|
92
|
+
pe,
|
|
94
93
|
pe,
|
|
95
94
|
fe,
|
|
95
|
+
de,
|
|
96
96
|
me,
|
|
97
97
|
L,
|
|
98
98
|
he,
|
|
@@ -120,7 +120,7 @@ function xe(e, t) {
|
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/core/license.ts
|
|
122
122
|
function Se(e) {
|
|
123
|
-
return `${
|
|
123
|
+
return `${ce()}/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
|
|
@@ -1067,21 +1067,21 @@ var Lt = /* @__PURE__ */ function(e) {
|
|
|
1067
1067
|
requestId: t,
|
|
1068
1068
|
request: d
|
|
1069
1069
|
}), u;
|
|
1070
|
-
},
|
|
1070
|
+
}, j = (e) => {
|
|
1071
1071
|
u ||= +/* @__PURE__ */ new Date();
|
|
1072
1072
|
let t = +/* @__PURE__ */ new Date();
|
|
1073
1073
|
return p = w(p, e), E(u, t, {
|
|
1074
1074
|
total: e.total || p,
|
|
1075
1075
|
loaded: e.loaded || 0
|
|
1076
1076
|
}), t;
|
|
1077
|
-
},
|
|
1077
|
+
}, te = () => {
|
|
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
|
+
}, ne = 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
|
+
}, M = Xt({
|
|
1110
1110
|
request: d,
|
|
1111
1111
|
requestId: t,
|
|
1112
1112
|
startTime: x,
|
|
1113
1113
|
logger: c,
|
|
1114
1114
|
resolve: n
|
|
1115
|
-
}),
|
|
1115
|
+
}), N = ({ 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
|
-
}),
|
|
1122
|
+
}), M({
|
|
1123
1123
|
error: i(H("abort")),
|
|
1124
1124
|
status: e,
|
|
1125
1125
|
extra: n
|
|
1126
|
-
})),
|
|
1126
|
+
})), P = ({ 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
|
-
}),
|
|
1133
|
+
}), M({
|
|
1134
1134
|
error: H("timeout"),
|
|
1135
1135
|
status: e,
|
|
1136
1136
|
extra: n
|
|
1137
|
-
})),
|
|
1137
|
+
})), re = ({ 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
|
-
}),
|
|
1144
|
+
}), M({
|
|
1145
1145
|
error: H(),
|
|
1146
1146
|
status: e,
|
|
1147
1147
|
extra: n
|
|
1148
|
-
})),
|
|
1149
|
-
let i =
|
|
1148
|
+
})), F = () => a.getAbortController(v, t), ie = ({ status: e, extra: n, onAbort: r = () => {} }) => {
|
|
1149
|
+
let i = F();
|
|
1150
1150
|
if (!i) throw new At("Controller is not found");
|
|
1151
1151
|
let o = () => {
|
|
1152
|
-
|
|
1152
|
+
N({
|
|
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 ae = e.client.adapter.unstable_queryParamsMapper(d.queryParams), oe = e.client.adapter.unstable_endpointMapper(d.endpoint), se = e.client.adapter.unstable_headerMapper(d), { url: I } = e.client;
|
|
1173
1173
|
return {
|
|
1174
1174
|
request: d,
|
|
1175
1175
|
requestId: t,
|
|
1176
|
-
url:
|
|
1177
|
-
endpoint:
|
|
1178
|
-
queryParams:
|
|
1176
|
+
url: I,
|
|
1177
|
+
endpoint: oe,
|
|
1178
|
+
queryParams: ae,
|
|
1179
1179
|
payload: y,
|
|
1180
|
-
headers:
|
|
1180
|
+
headers: se,
|
|
1181
1181
|
adapter: e.client.adapter,
|
|
1182
1182
|
adapterOptions: b,
|
|
1183
|
-
getAbortController:
|
|
1183
|
+
getAbortController: F,
|
|
1184
1184
|
getRequestStartTimestamp: S,
|
|
1185
1185
|
getResponseStartTimestamp: C,
|
|
1186
|
-
createAbortListener:
|
|
1186
|
+
createAbortListener: ie,
|
|
1187
1187
|
onBeforeRequest: D,
|
|
1188
1188
|
onRequestStart: O,
|
|
1189
1189
|
onRequestProgress: k,
|
|
1190
1190
|
onRequestEnd: ee,
|
|
1191
1191
|
onResponseStart: A,
|
|
1192
|
-
onResponseProgress:
|
|
1193
|
-
onResponseEnd:
|
|
1194
|
-
onSuccess:
|
|
1195
|
-
onAbortError:
|
|
1196
|
-
onTimeoutError:
|
|
1197
|
-
onUnexpectedError:
|
|
1198
|
-
onError:
|
|
1192
|
+
onResponseProgress: j,
|
|
1193
|
+
onResponseEnd: te,
|
|
1194
|
+
onSuccess: ne,
|
|
1195
|
+
onAbortError: N,
|
|
1196
|
+
onTimeoutError: P,
|
|
1197
|
+
onUnexpectedError: re,
|
|
1198
|
+
onError: M
|
|
1199
1199
|
};
|
|
1200
1200
|
};
|
|
1201
1201
|
function Xt({ request: e, requestId: t, startTime: n, resolve: r, logger: i }) {
|
|
@@ -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: I() });
|
|
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 = I(), 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 = `${ce()}/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 = {
|
|
@@ -2378,103 +2378,117 @@ function q(e, t, n) {
|
|
|
2378
2378
|
});
|
|
2379
2379
|
});
|
|
2380
2380
|
}
|
|
2381
|
+
function ir(e, t, n) {
|
|
2382
|
+
return new Promise((r, i) => {
|
|
2383
|
+
let a = D(e, t, {
|
|
2384
|
+
cwd: n.cwd,
|
|
2385
|
+
stdio: "inherit"
|
|
2386
|
+
});
|
|
2387
|
+
a.on("error", i), a.on("close", (e) => {
|
|
2388
|
+
r({
|
|
2389
|
+
exitCode: e ?? 1,
|
|
2390
|
+
stdout: "",
|
|
2391
|
+
stderr: ""
|
|
2392
|
+
});
|
|
2393
|
+
});
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2381
2396
|
//#endregion
|
|
2382
2397
|
//#region src/utils/fs.ts
|
|
2383
|
-
async function
|
|
2398
|
+
async function ar(e) {
|
|
2384
2399
|
return (await y.stat(e).catch(() => null))?.isDirectory() ?? !1;
|
|
2385
2400
|
}
|
|
2386
2401
|
async function J(e) {
|
|
2387
2402
|
return (await y.stat(e).catch(() => null))?.isFile() ?? !1;
|
|
2388
2403
|
}
|
|
2389
|
-
async function
|
|
2404
|
+
async function or(e) {
|
|
2390
2405
|
return (await y.readdir(e).catch(() => [])).length === 0;
|
|
2391
2406
|
}
|
|
2392
|
-
async function
|
|
2407
|
+
async function sr(e) {
|
|
2393
2408
|
let t = await y.readFile(e, "utf-8").catch(() => null);
|
|
2394
2409
|
return t ? JSON.parse(t) : null;
|
|
2395
2410
|
}
|
|
2396
|
-
async function
|
|
2411
|
+
async function cr(e, t) {
|
|
2397
2412
|
await y.writeFile(e, JSON.stringify(t, null, 2) + "\n", "utf-8");
|
|
2398
2413
|
}
|
|
2399
|
-
async function
|
|
2414
|
+
async function lr(e) {
|
|
2400
2415
|
let t = {};
|
|
2401
|
-
if (!await
|
|
2416
|
+
if (!await ar(e)) return t;
|
|
2402
2417
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
2403
2418
|
for (let r of n) r.isDirectory() && await J(T.join(e, r.name, "package.json")) && (t[r.name] = T.relative(T.dirname(e), T.join(e, r.name)));
|
|
2404
2419
|
return t;
|
|
2405
2420
|
}
|
|
2406
|
-
async function
|
|
2421
|
+
async function ur(e) {
|
|
2407
2422
|
await y.rm(e, {
|
|
2408
2423
|
recursive: !0,
|
|
2409
2424
|
force: !0
|
|
2410
2425
|
});
|
|
2411
2426
|
}
|
|
2412
|
-
function
|
|
2427
|
+
function dr(e, t) {
|
|
2413
2428
|
return T.basename(e) === t ? e : T.join(e, t);
|
|
2414
2429
|
}
|
|
2415
2430
|
//#endregion
|
|
2416
2431
|
//#region src/core/codegen.ts
|
|
2417
|
-
function
|
|
2432
|
+
function fr(e) {
|
|
2418
2433
|
s.log.info(R.muted("Run database setup yourself when ready:")), s.note([
|
|
2419
2434
|
`${R.command(`cd ${e}`)}`,
|
|
2420
2435
|
`${R.command("pnpm exec prisma generate")} ${R.muted("(regenerate the Prisma client)")}`,
|
|
2421
2436
|
`${R.command("pnpm exec prisma migrate dev")} ${R.muted("(create + apply tables for new packs)")}`
|
|
2422
2437
|
].join("\n"), "Database Setup");
|
|
2423
2438
|
}
|
|
2424
|
-
async function
|
|
2425
|
-
let { projectRoot: t, paths: n, skipPrompts: r,
|
|
2426
|
-
if (!await J(T.join(
|
|
2427
|
-
if (r) {
|
|
2428
|
-
|
|
2439
|
+
async function pr(e) {
|
|
2440
|
+
let { projectRoot: t, paths: n, skipPrompts: r, dbReady: i, runCommand: a = ir } = e, o = n.backend.root, c = T.join(t, o);
|
|
2441
|
+
if (!await J(T.join(c, "package.json"))) return;
|
|
2442
|
+
if (r || i === !1) {
|
|
2443
|
+
fr(o);
|
|
2429
2444
|
return;
|
|
2430
2445
|
}
|
|
2431
|
-
let
|
|
2446
|
+
let l = await s.confirm({
|
|
2432
2447
|
message: `Run database setup now? (${R.command("prisma migrate dev")})`,
|
|
2433
2448
|
initialValue: !0
|
|
2434
2449
|
});
|
|
2435
|
-
if (s.isCancel(
|
|
2436
|
-
|
|
2450
|
+
if (s.isCancel(l) || !l) {
|
|
2451
|
+
fr(o);
|
|
2437
2452
|
return;
|
|
2438
2453
|
}
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
let u = await i("pnpm", [
|
|
2454
|
+
s.log.step(R.muted(`Running ${R.command("prisma migrate dev --name add-packs")}...`));
|
|
2455
|
+
let u = await a("pnpm", [
|
|
2442
2456
|
"exec",
|
|
2443
2457
|
"prisma",
|
|
2444
2458
|
"migrate",
|
|
2445
2459
|
"dev",
|
|
2446
2460
|
"--name",
|
|
2447
2461
|
"add-packs"
|
|
2448
|
-
], { cwd:
|
|
2462
|
+
], { cwd: c });
|
|
2449
2463
|
if (u.exitCode !== 0) {
|
|
2450
|
-
|
|
2464
|
+
s.log.error(R.muted("prisma migrate dev did not complete. See the output above, or finish setup manually:")), mr(u), fr(o);
|
|
2451
2465
|
return;
|
|
2452
2466
|
}
|
|
2453
|
-
|
|
2467
|
+
s.log.success("Database schema applied");
|
|
2454
2468
|
}
|
|
2455
|
-
function
|
|
2469
|
+
function mr(e) {
|
|
2456
2470
|
let t = (e.stderr || e.stdout).trim();
|
|
2457
2471
|
t && s.log.warn(R.muted(t));
|
|
2458
2472
|
}
|
|
2459
2473
|
//#endregion
|
|
2460
2474
|
//#region src/core/stack-config.ts
|
|
2461
|
-
async function mr(e) {
|
|
2462
|
-
return or(T.join(e, ne));
|
|
2463
|
-
}
|
|
2464
2475
|
async function hr(e) {
|
|
2465
|
-
return
|
|
2476
|
+
return sr(T.join(e, te));
|
|
2477
|
+
}
|
|
2478
|
+
async function gr(e) {
|
|
2479
|
+
return J(T.join(e, te));
|
|
2466
2480
|
}
|
|
2467
|
-
async function
|
|
2468
|
-
await
|
|
2481
|
+
async function _r(e, t) {
|
|
2482
|
+
await cr(T.join(e, te), t);
|
|
2469
2483
|
}
|
|
2470
|
-
async function
|
|
2471
|
-
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([
|
|
2484
|
+
async function vr(e) {
|
|
2485
|
+
let t = T.join(e, "apps"), n = T.join(e, "packages"), [r, i] = await Promise.all([lr(t), lr(n)]);
|
|
2472
2486
|
return {
|
|
2473
2487
|
apps: r,
|
|
2474
2488
|
packages: i
|
|
2475
2489
|
};
|
|
2476
2490
|
}
|
|
2477
|
-
function
|
|
2491
|
+
function yr(e) {
|
|
2478
2492
|
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";
|
|
2479
2493
|
return {
|
|
2480
2494
|
backend: {
|
|
@@ -2508,20 +2522,20 @@ function vr(e) {
|
|
|
2508
2522
|
}
|
|
2509
2523
|
};
|
|
2510
2524
|
}
|
|
2511
|
-
function
|
|
2525
|
+
function br(e, t) {
|
|
2512
2526
|
return {
|
|
2513
|
-
$schema:
|
|
2527
|
+
$schema: ue(),
|
|
2514
2528
|
version: 1,
|
|
2515
2529
|
name: e,
|
|
2516
2530
|
apps: t.apps,
|
|
2517
2531
|
packages: t.packages,
|
|
2518
|
-
paths:
|
|
2532
|
+
paths: yr(t),
|
|
2519
2533
|
installedPacks: [],
|
|
2520
2534
|
licenseKey: null
|
|
2521
2535
|
};
|
|
2522
2536
|
}
|
|
2523
|
-
async function
|
|
2524
|
-
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t),
|
|
2537
|
+
async function xr(e) {
|
|
2538
|
+
let t = T.join(e, "package.json"), n = T.join(e, "apps"), [r, i] = await Promise.all([J(t), ar(n)]);
|
|
2525
2539
|
return r && i;
|
|
2526
2540
|
}
|
|
2527
2541
|
function Y(e, t) {
|
|
@@ -2535,7 +2549,7 @@ function Y(e, t) {
|
|
|
2535
2549
|
}
|
|
2536
2550
|
//#endregion
|
|
2537
2551
|
//#region src/core/registry.ts
|
|
2538
|
-
async function
|
|
2552
|
+
async function Sr(e) {
|
|
2539
2553
|
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
2540
2554
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2541
2555
|
method: "GET"
|
|
@@ -2544,7 +2558,7 @@ async function xr(e) {
|
|
|
2544
2558
|
if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
|
|
2545
2559
|
return t;
|
|
2546
2560
|
}
|
|
2547
|
-
async function
|
|
2561
|
+
async function Cr(e, t = {}) {
|
|
2548
2562
|
let n = K.createRequest()({
|
|
2549
2563
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2550
2564
|
method: "POST"
|
|
@@ -2570,23 +2584,23 @@ async function Sr(e, t = {}) {
|
|
|
2570
2584
|
packDir: s
|
|
2571
2585
|
};
|
|
2572
2586
|
}
|
|
2573
|
-
function
|
|
2587
|
+
function wr(e, t, n) {
|
|
2574
2588
|
let r = Y(e, t);
|
|
2575
2589
|
return T.resolve(n, r);
|
|
2576
2590
|
}
|
|
2577
|
-
function
|
|
2591
|
+
function Tr(e, t) {
|
|
2578
2592
|
return T.join(t, e);
|
|
2579
2593
|
}
|
|
2580
|
-
var
|
|
2594
|
+
var Er = K.createRequest()({
|
|
2581
2595
|
endpoint: "/packs/list",
|
|
2582
2596
|
method: "GET"
|
|
2583
2597
|
});
|
|
2584
|
-
async function
|
|
2585
|
-
let { data: e, error: t } = await
|
|
2598
|
+
async function Dr() {
|
|
2599
|
+
let { data: e, error: t } = await Er.send();
|
|
2586
2600
|
if (t || !e) throw Error(`Failed to fetch pack list: ${String(t)}`);
|
|
2587
2601
|
return e.packs;
|
|
2588
2602
|
}
|
|
2589
|
-
async function
|
|
2603
|
+
async function Or(e, t = {}) {
|
|
2590
2604
|
if (e.length === 0) return {};
|
|
2591
2605
|
let n = K.createRequest()({
|
|
2592
2606
|
endpoint: "/packs/authorize",
|
|
@@ -2602,35 +2616,35 @@ async function Dr(e, t = {}) {
|
|
|
2602
2616
|
}
|
|
2603
2617
|
//#endregion
|
|
2604
2618
|
//#region src/core/codemods.ts
|
|
2605
|
-
var
|
|
2606
|
-
function
|
|
2619
|
+
var kr = "@hype-stack/";
|
|
2620
|
+
function Ar(e, t) {
|
|
2607
2621
|
return Y(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
|
|
2608
2622
|
}
|
|
2609
|
-
async function
|
|
2623
|
+
async function jr(e, t, n) {
|
|
2610
2624
|
let r = Y("{{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");
|
|
2611
2625
|
if (await J(i)) {
|
|
2612
2626
|
let t = await y.readFile(i, "utf-8");
|
|
2613
|
-
for (let n of e) t.includes(`from "${n.from}"`) || (t =
|
|
2627
|
+
for (let n of e) t.includes(`from "${n.from}"`) || (t = Mr(t, n), t = Nr(t, n));
|
|
2614
2628
|
await y.writeFile(i, t, "utf-8");
|
|
2615
2629
|
}
|
|
2616
2630
|
if (await J(a)) {
|
|
2617
2631
|
let t = await y.readFile(a, "utf-8");
|
|
2618
|
-
for (let n of e) t =
|
|
2632
|
+
for (let n of e) t = Pr(t, n);
|
|
2619
2633
|
await y.writeFile(a, t, "utf-8");
|
|
2620
2634
|
}
|
|
2621
2635
|
if (await J(o)) {
|
|
2622
2636
|
let t = await y.readFile(o, "utf-8");
|
|
2623
|
-
for (let n of e) t =
|
|
2637
|
+
for (let n of e) t = Fr(t, n);
|
|
2624
2638
|
await y.writeFile(o, t, "utf-8");
|
|
2625
2639
|
}
|
|
2626
2640
|
}
|
|
2627
|
-
function
|
|
2641
|
+
function Mr(e, t) {
|
|
2628
2642
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2629
2643
|
if (r === -1) return n + "\n" + e;
|
|
2630
2644
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2631
2645
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2632
2646
|
}
|
|
2633
|
-
function
|
|
2647
|
+
function Nr(e, t) {
|
|
2634
2648
|
let n = `.extend(${t.import}.shape)`;
|
|
2635
2649
|
if (e.includes(n)) return e;
|
|
2636
2650
|
let r = e.indexOf("export const envSchema = z.object({");
|
|
@@ -2645,27 +2659,27 @@ function Mr(e, t) {
|
|
|
2645
2659
|
let o = a + 2;
|
|
2646
2660
|
return e.slice(0, o) + n + e.slice(o);
|
|
2647
2661
|
}
|
|
2648
|
-
function
|
|
2662
|
+
function Pr(e, t) {
|
|
2649
2663
|
for (let n of Object.keys(t.envExample.vars)) if (e.includes(`${n}=`)) return e;
|
|
2650
2664
|
let n = [];
|
|
2651
2665
|
n.push(""), n.push(`# ${t.envExample.section}`);
|
|
2652
2666
|
for (let [e, r] of Object.entries(t.envExample.vars)) n.push(`${e}=${r}`);
|
|
2653
2667
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2654
2668
|
}
|
|
2655
|
-
function
|
|
2669
|
+
function Fr(e, t) {
|
|
2656
2670
|
for (let n of Object.keys(t.envTest)) if (e.includes(`${n}=`)) return e;
|
|
2657
2671
|
let n = [""];
|
|
2658
2672
|
for (let [e, r] of Object.entries(t.envTest)) n.push(`${e}=${r}`);
|
|
2659
2673
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2660
2674
|
}
|
|
2661
|
-
async function
|
|
2675
|
+
async function Ir(e, t, n) {
|
|
2662
2676
|
let r = T.resolve(n, Y("{{backend.routes}}", t), "index.ts");
|
|
2663
2677
|
if (!await J(r)) return;
|
|
2664
2678
|
let i = await y.readFile(r, "utf-8");
|
|
2665
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2679
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Lr(i, t), i = Rr(i, t));
|
|
2666
2680
|
await y.writeFile(r, i, "utf-8");
|
|
2667
2681
|
}
|
|
2668
|
-
function
|
|
2682
|
+
function Lr(e, t) {
|
|
2669
2683
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2670
2684
|
if (r !== -1) {
|
|
2671
2685
|
let t = e.indexOf("\n", r);
|
|
@@ -2674,7 +2688,7 @@ function Ir(e, t) {
|
|
|
2674
2688
|
let i = e.indexOf("export const registerRoutes");
|
|
2675
2689
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2676
2690
|
}
|
|
2677
|
-
function
|
|
2691
|
+
function Rr(e, t) {
|
|
2678
2692
|
let n = `.route("${t.prefix}", ${t.import})`, r = e.match(/\.route\([^)]+\);/g);
|
|
2679
2693
|
if (r) {
|
|
2680
2694
|
let t = r[r.length - 1], i = e.lastIndexOf(t) + t.length - 1;
|
|
@@ -2682,14 +2696,14 @@ function Lr(e, t) {
|
|
|
2682
2696
|
}
|
|
2683
2697
|
return e.replace("return app;", `return app\n ${n};`);
|
|
2684
2698
|
}
|
|
2685
|
-
async function
|
|
2699
|
+
async function zr(e, t, n) {
|
|
2686
2700
|
let r = T.resolve(n, Y("{{backend.root}}", t), "src/context.ts");
|
|
2687
2701
|
if (!await J(r)) return;
|
|
2688
2702
|
let i = await y.readFile(r, "utf-8");
|
|
2689
|
-
for (let t of e) i.includes(`export let ${t.export}`) || (i =
|
|
2703
|
+
for (let t of e) i.includes(`export let ${t.export}`) || (i = Br(i, t), i = Vr(i, t), i = Hr(i, t), i = Wr(i, t));
|
|
2690
2704
|
await y.writeFile(r, i, "utf-8");
|
|
2691
2705
|
}
|
|
2692
|
-
function
|
|
2706
|
+
function Br(e, t) {
|
|
2693
2707
|
let n = `import { ${t.typeImport.name} } from "${t.typeImport.from}";`;
|
|
2694
2708
|
if (e.includes(`from "${t.typeImport.from}"`)) return e;
|
|
2695
2709
|
let r = e.lastIndexOf("import ");
|
|
@@ -2697,7 +2711,7 @@ function zr(e, t) {
|
|
|
2697
2711
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2698
2712
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2699
2713
|
}
|
|
2700
|
-
function
|
|
2714
|
+
function Vr(e, t) {
|
|
2701
2715
|
let n = `export let ${t.export}: ${t.type};`, r = e.lastIndexOf("export let ");
|
|
2702
2716
|
if (r === -1) {
|
|
2703
2717
|
let t = e.indexOf("export const setupContext");
|
|
@@ -2706,15 +2720,15 @@ function Br(e, t) {
|
|
|
2706
2720
|
let i = e.indexOf("\n", r);
|
|
2707
2721
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2708
2722
|
}
|
|
2709
|
-
function
|
|
2723
|
+
function Hr(e, t) {
|
|
2710
2724
|
let n = ` ${t.export} = ${t.init};`, r = e.match(/export const setupContext\s*=\s*async\s*\([^)]*\)\s*=>\s*\{/);
|
|
2711
2725
|
if (!r) return e;
|
|
2712
2726
|
let i = e.indexOf("{", e.indexOf(r[0]));
|
|
2713
2727
|
if (i === -1) return e;
|
|
2714
|
-
let a =
|
|
2728
|
+
let a = Ur(e, i);
|
|
2715
2729
|
return a === -1 ? e : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2716
2730
|
}
|
|
2717
|
-
function
|
|
2731
|
+
function Ur(e, t) {
|
|
2718
2732
|
let n = 0;
|
|
2719
2733
|
for (let r = t; r < e.length; r++) {
|
|
2720
2734
|
let t = e[r];
|
|
@@ -2723,20 +2737,20 @@ function Hr(e, t) {
|
|
|
2723
2737
|
}
|
|
2724
2738
|
return -1;
|
|
2725
2739
|
}
|
|
2726
|
-
function
|
|
2740
|
+
function Wr(e, t) {
|
|
2727
2741
|
let n = ` ${t.export}: ${t.type};`, r = e.indexOf("export type ContextVariables = {");
|
|
2728
2742
|
if (r === -1) return e;
|
|
2729
2743
|
let i = e.indexOf("};", r);
|
|
2730
2744
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2731
2745
|
}
|
|
2732
|
-
async function
|
|
2746
|
+
async function Gr(e, t, n) {
|
|
2733
2747
|
let r = T.resolve(n, Y("{{enums.src}}", t), "index.ts");
|
|
2734
2748
|
if (!await J(r)) return;
|
|
2735
2749
|
let i = await y.readFile(r, "utf-8");
|
|
2736
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2750
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Kr(i, t));
|
|
2737
2751
|
await y.writeFile(r, i, "utf-8");
|
|
2738
2752
|
}
|
|
2739
|
-
function
|
|
2753
|
+
function Kr(e, t) {
|
|
2740
2754
|
let n = `export * from "${t.from}";`, r = e.lastIndexOf("export * from");
|
|
2741
2755
|
if (r !== -1) {
|
|
2742
2756
|
let t = e.indexOf("\n", r);
|
|
@@ -2744,14 +2758,14 @@ function Gr(e, t) {
|
|
|
2744
2758
|
}
|
|
2745
2759
|
return e.trim() === "" ? n + "\n" : e.trimEnd() + "\n" + n + "\n";
|
|
2746
2760
|
}
|
|
2747
|
-
async function
|
|
2761
|
+
async function qr(e, t, n) {
|
|
2748
2762
|
let r = Y("{{backend.root}}", t), i = T.resolve(n, r, "src/sockets/index.ts");
|
|
2749
2763
|
if (!await J(i)) return;
|
|
2750
2764
|
let a = await y.readFile(i, "utf-8");
|
|
2751
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2752
|
-
await J(T.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a =
|
|
2765
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = Jr(a, t), a = Yr(a, t));
|
|
2766
|
+
await J(T.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a = Xr(a)), await y.writeFile(i, a, "utf-8");
|
|
2753
2767
|
}
|
|
2754
|
-
function
|
|
2768
|
+
function Jr(e, t) {
|
|
2755
2769
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2756
2770
|
if (r !== -1) {
|
|
2757
2771
|
let t = e.indexOf("\n", r);
|
|
@@ -2760,7 +2774,7 @@ function qr(e, t) {
|
|
|
2760
2774
|
let i = e.indexOf("const sockets");
|
|
2761
2775
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2762
2776
|
}
|
|
2763
|
-
function
|
|
2777
|
+
function Yr(e, t) {
|
|
2764
2778
|
let n = `.socket("${t.prefix}", ${t.import})`, r = e.indexOf("const sockets");
|
|
2765
2779
|
if (r === -1) return e;
|
|
2766
2780
|
let i = e.indexOf("new SocketRouter", r);
|
|
@@ -2774,7 +2788,7 @@ function Jr(e, t) {
|
|
|
2774
2788
|
}
|
|
2775
2789
|
return e;
|
|
2776
2790
|
}
|
|
2777
|
-
function
|
|
2791
|
+
function Xr(e) {
|
|
2778
2792
|
if (e.includes("wsAuthenticate")) return e;
|
|
2779
2793
|
let t = e.indexOf("from \"@backend/libs/websocket/socket-router\""), n = e;
|
|
2780
2794
|
if (t !== -1) {
|
|
@@ -2783,14 +2797,14 @@ function Yr(e) {
|
|
|
2783
2797
|
}
|
|
2784
2798
|
return n.replace("new SocketRouter()", "new SocketRouter({ authenticate: wsAuthenticate })");
|
|
2785
2799
|
}
|
|
2786
|
-
async function
|
|
2800
|
+
async function Zr(e, t, n) {
|
|
2787
2801
|
let r = Y("{{frontend.root}}", t), i = T.resolve(n, r, "src/api/sdk.ts");
|
|
2788
2802
|
if (!await J(i)) return;
|
|
2789
2803
|
let a = await y.readFile(i, "utf-8");
|
|
2790
|
-
for (let t of e) a.includes(`.$configure(${t.import})`) || (a =
|
|
2804
|
+
for (let t of e) a.includes(`.$configure(${t.import})`) || (a = Qr(a, t), a = $r(a, t));
|
|
2791
2805
|
await y.writeFile(i, a, "utf-8");
|
|
2792
2806
|
}
|
|
2793
|
-
function
|
|
2807
|
+
function Qr(e, t) {
|
|
2794
2808
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2795
2809
|
if (e.includes(n)) return e;
|
|
2796
2810
|
let r = e.lastIndexOf("from \"./");
|
|
@@ -2801,20 +2815,20 @@ function Zr(e, t) {
|
|
|
2801
2815
|
let i = e.indexOf("export const sdk");
|
|
2802
2816
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2803
2817
|
}
|
|
2804
|
-
function
|
|
2818
|
+
function $r(e, t) {
|
|
2805
2819
|
let n = `.$configure(${t.import})`, r = e.indexOf("export const sdk");
|
|
2806
2820
|
if (r === -1) return e;
|
|
2807
2821
|
let i = e.indexOf(";", r);
|
|
2808
2822
|
return i === -1 ? e : e.slice(0, i) + "\n " + n + e.slice(i);
|
|
2809
2823
|
}
|
|
2810
|
-
async function
|
|
2824
|
+
async function ei(e, t, n) {
|
|
2811
2825
|
let r = T.resolve(n, Y("{{backend.utils}}", t), "frontend-url/frontend-url.ts");
|
|
2812
2826
|
if (!await J(r)) return;
|
|
2813
2827
|
let i = await y.readFile(r, "utf-8");
|
|
2814
|
-
for (let t of e) i.includes(`"${t.path}"`) || (i =
|
|
2828
|
+
for (let t of e) i.includes(`"${t.path}"`) || (i = ti(i, t));
|
|
2815
2829
|
await y.writeFile(r, i, "utf-8");
|
|
2816
2830
|
}
|
|
2817
|
-
function
|
|
2831
|
+
function ti(e, t) {
|
|
2818
2832
|
let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
|
|
2819
2833
|
if (r === -1) return e;
|
|
2820
2834
|
let i = e.indexOf("{", r);
|
|
@@ -2830,38 +2844,38 @@ function ei(e, t) {
|
|
|
2830
2844
|
}
|
|
2831
2845
|
return o === -1 ? e : e.slice(0, o) + n + "\n" + e.slice(o);
|
|
2832
2846
|
}
|
|
2833
|
-
var
|
|
2847
|
+
var ni = "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", ri = {
|
|
2834
2848
|
primary: "primaryNav",
|
|
2835
2849
|
secondary: "secondaryNav",
|
|
2836
2850
|
tertiary: "tertiaryNav",
|
|
2837
2851
|
settings: "settingsNav"
|
|
2838
2852
|
};
|
|
2839
|
-
async function
|
|
2840
|
-
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2841
|
-
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s =
|
|
2842
|
-
for (let e of t) s.includes(`label: "${e.label}"`) || (s =
|
|
2843
|
-
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s =
|
|
2853
|
+
async function ii(e) {
|
|
2854
|
+
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Ar(i, n), o = T.resolve(r, a, "src/constants/nav.constants.ts"), s;
|
|
2855
|
+
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = ni);
|
|
2856
|
+
for (let e of t) s.includes(`label: "${e.label}"`) || (s = si(s, e));
|
|
2857
|
+
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s = li(s, e));
|
|
2844
2858
|
await y.writeFile(o, s, "utf-8");
|
|
2845
2859
|
}
|
|
2846
|
-
async function
|
|
2847
|
-
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2860
|
+
async function ai(e) {
|
|
2861
|
+
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Ar(i, n), o = T.resolve(r, a, "src/features/auth/constants/auth.constants.ts");
|
|
2848
2862
|
if (!await J(o)) return;
|
|
2849
2863
|
let s = await y.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
|
|
2850
2864
|
if (!c.test(s)) return;
|
|
2851
2865
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
2852
2866
|
await y.writeFile(o, l, "utf-8");
|
|
2853
2867
|
}
|
|
2854
|
-
function
|
|
2868
|
+
function oi(e) {
|
|
2855
2869
|
let t = [e.icon];
|
|
2856
2870
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
2857
2871
|
return t;
|
|
2858
2872
|
}
|
|
2859
|
-
function
|
|
2860
|
-
let n =
|
|
2861
|
-
for (let e of n) r =
|
|
2873
|
+
function si(e, t) {
|
|
2874
|
+
let n = oi(t), r = e;
|
|
2875
|
+
for (let e of n) r = ci(r, e);
|
|
2862
2876
|
return r;
|
|
2863
2877
|
}
|
|
2864
|
-
function
|
|
2878
|
+
function ci(e, t) {
|
|
2865
2879
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
2866
2880
|
if (!n) return e;
|
|
2867
2881
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -2869,21 +2883,21 @@ function si(e, t) {
|
|
|
2869
2883
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
2870
2884
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
2871
2885
|
}
|
|
2872
|
-
function
|
|
2873
|
-
let n =
|
|
2886
|
+
function li(e, t) {
|
|
2887
|
+
let n = ri[t.group];
|
|
2874
2888
|
if (!n) return e;
|
|
2875
|
-
let r =
|
|
2889
|
+
let r = di(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
|
|
2876
2890
|
if (!a) return e;
|
|
2877
|
-
let o = e.indexOf(a[0]) + a[0].length, s =
|
|
2891
|
+
let o = e.indexOf(a[0]) + a[0].length, s = ui(e, o - 1);
|
|
2878
2892
|
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);
|
|
2879
2893
|
}
|
|
2880
|
-
function
|
|
2894
|
+
function ui(e, t) {
|
|
2881
2895
|
let n = 0;
|
|
2882
2896
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2883
2897
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2884
2898
|
return -1;
|
|
2885
2899
|
}
|
|
2886
|
-
function
|
|
2900
|
+
function di(e) {
|
|
2887
2901
|
let t = [];
|
|
2888
2902
|
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) {
|
|
2889
2903
|
t.push(" items: [");
|
|
@@ -2899,14 +2913,14 @@ function ui(e) {
|
|
|
2899
2913
|
} else t.push(" items: [],");
|
|
2900
2914
|
return t.push(" },"), t.join("\n");
|
|
2901
2915
|
}
|
|
2902
|
-
async function
|
|
2916
|
+
async function fi(e, t, n) {
|
|
2903
2917
|
let r = Y("{{backend.features}}", t), i = T.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
|
|
2904
2918
|
if (!await J(i)) return;
|
|
2905
2919
|
let a = await y.readFile(i, "utf-8");
|
|
2906
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2920
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = pi(a, t), a = mi(a, t));
|
|
2907
2921
|
await y.writeFile(i, a, "utf-8");
|
|
2908
2922
|
}
|
|
2909
|
-
function
|
|
2923
|
+
function pi(e, t) {
|
|
2910
2924
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2911
2925
|
if (r !== -1) {
|
|
2912
2926
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -2914,38 +2928,38 @@ function fi(e, t) {
|
|
|
2914
2928
|
}
|
|
2915
2929
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
2916
2930
|
}
|
|
2917
|
-
function
|
|
2931
|
+
function mi(e, t) {
|
|
2918
2932
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
2919
2933
|
if (!r) return e;
|
|
2920
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2934
|
+
let i = e.indexOf(r[0]) + r[0].length, a = hi(e, i - 1);
|
|
2921
2935
|
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);
|
|
2922
2936
|
}
|
|
2923
|
-
function
|
|
2937
|
+
function hi(e, t) {
|
|
2924
2938
|
let n = 0;
|
|
2925
2939
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2926
2940
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2927
2941
|
return -1;
|
|
2928
2942
|
}
|
|
2929
|
-
var
|
|
2930
|
-
async function
|
|
2931
|
-
await
|
|
2943
|
+
var gi = "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";
|
|
2944
|
+
async function _i(e) {
|
|
2945
|
+
await yi({
|
|
2932
2946
|
...e,
|
|
2933
2947
|
arrayName: "navbarActions"
|
|
2934
2948
|
});
|
|
2935
2949
|
}
|
|
2936
|
-
async function
|
|
2937
|
-
await
|
|
2950
|
+
async function vi(e) {
|
|
2951
|
+
await yi({
|
|
2938
2952
|
...e,
|
|
2939
2953
|
arrayName: "userMenuActions"
|
|
2940
2954
|
});
|
|
2941
2955
|
}
|
|
2942
|
-
async function
|
|
2943
|
-
let a =
|
|
2944
|
-
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s =
|
|
2945
|
-
for (let n of e) s =
|
|
2956
|
+
async function yi({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
|
|
2957
|
+
let a = Ar(i, n), o = T.resolve(r, a, "src/constants/navbar-actions.tsx"), s;
|
|
2958
|
+
await J(o) ? s = await y.readFile(o, "utf-8") : (await y.mkdir(T.dirname(o), { recursive: !0 }), s = gi);
|
|
2959
|
+
for (let n of e) s = bi(s, n), s = xi(s, n, t);
|
|
2946
2960
|
await y.writeFile(o, s, "utf-8");
|
|
2947
2961
|
}
|
|
2948
|
-
function
|
|
2962
|
+
function bi(e, t) {
|
|
2949
2963
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2950
2964
|
if (e.includes(n)) return e;
|
|
2951
2965
|
let r = e.lastIndexOf("import ");
|
|
@@ -2953,38 +2967,38 @@ function yi(e, t) {
|
|
|
2953
2967
|
let i = e.indexOf("\n", r);
|
|
2954
2968
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2955
2969
|
}
|
|
2956
|
-
function
|
|
2970
|
+
function xi(e, t, n) {
|
|
2957
2971
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
2958
2972
|
if (!r) return e;
|
|
2959
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2973
|
+
let i = e.indexOf(r[0]) + r[0].length, a = Si(e, i - 1);
|
|
2960
2974
|
if (a === -1) return e;
|
|
2961
2975
|
let o = e.slice(i, a);
|
|
2962
2976
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
2963
2977
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
2964
2978
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
2965
2979
|
}
|
|
2966
|
-
function
|
|
2980
|
+
function Si(e, t) {
|
|
2967
2981
|
let n = 0;
|
|
2968
2982
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2969
2983
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2970
2984
|
return -1;
|
|
2971
2985
|
}
|
|
2972
|
-
var
|
|
2986
|
+
var Ci = new Set([
|
|
2973
2987
|
".ts",
|
|
2974
2988
|
".tsx",
|
|
2975
2989
|
".js",
|
|
2976
2990
|
".jsx"
|
|
2977
2991
|
]);
|
|
2978
|
-
async function
|
|
2992
|
+
async function wi(e) {
|
|
2979
2993
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
2980
2994
|
if (i === "hype-stack") return;
|
|
2981
2995
|
let a = `@${i}/`;
|
|
2982
2996
|
await Promise.all(t.map(async (e) => {
|
|
2983
|
-
let t =
|
|
2984
|
-
i?.isDirectory() ? await
|
|
2997
|
+
let t = wr(e.target, n, r), i = await y.stat(t).catch(() => null);
|
|
2998
|
+
i?.isDirectory() ? await Di(t, a) : i?.isFile() && Ci.has(T.extname(t)) && await Oi(t, a);
|
|
2985
2999
|
}));
|
|
2986
3000
|
}
|
|
2987
|
-
var
|
|
3001
|
+
var Ti = new Set([
|
|
2988
3002
|
".git",
|
|
2989
3003
|
"node_modules",
|
|
2990
3004
|
"dist",
|
|
@@ -2993,43 +3007,43 @@ var wi = new Set([
|
|
|
2993
3007
|
".next",
|
|
2994
3008
|
"coverage"
|
|
2995
3009
|
]);
|
|
2996
|
-
async function Ti(e, t) {
|
|
2997
|
-
t !== "hype-stack" && await Ei(e, `@${t}/`);
|
|
2998
|
-
}
|
|
2999
3010
|
async function Ei(e, t) {
|
|
3011
|
+
t !== "hype-stack" && await Di(e, `@${t}/`);
|
|
3012
|
+
}
|
|
3013
|
+
async function Di(e, t) {
|
|
3000
3014
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3001
3015
|
await Promise.all(n.map(async (n) => {
|
|
3002
3016
|
let r = T.join(e, n.name);
|
|
3003
3017
|
if (n.isDirectory()) {
|
|
3004
|
-
if (
|
|
3005
|
-
await
|
|
3006
|
-
} else n.isFile() &&
|
|
3018
|
+
if (Ti.has(n.name)) return;
|
|
3019
|
+
await Di(r, t);
|
|
3020
|
+
} else n.isFile() && Ci.has(T.extname(n.name)) && await Oi(r, t);
|
|
3007
3021
|
}));
|
|
3008
3022
|
}
|
|
3009
|
-
async function
|
|
3023
|
+
async function Oi(e, t) {
|
|
3010
3024
|
let n = await y.readFile(e, "utf-8");
|
|
3011
|
-
if (!n.includes(
|
|
3012
|
-
let r = n.replaceAll(
|
|
3025
|
+
if (!n.includes(kr)) return;
|
|
3026
|
+
let r = n.replaceAll(kr, t);
|
|
3013
3027
|
await y.writeFile(e, r, "utf-8");
|
|
3014
3028
|
}
|
|
3015
3029
|
//#endregion
|
|
3016
3030
|
//#region src/core/installer.ts
|
|
3017
|
-
function
|
|
3031
|
+
function ki(e, t) {
|
|
3018
3032
|
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3019
3033
|
}
|
|
3020
|
-
async function
|
|
3034
|
+
async function Ai(e, t) {
|
|
3021
3035
|
if ((await y.stat(e)).isDirectory()) {
|
|
3022
3036
|
await y.mkdir(t, { recursive: !0 });
|
|
3023
3037
|
let n = await y.readdir(e, { withFileTypes: !0 });
|
|
3024
|
-
for (let r of n) await
|
|
3038
|
+
for (let r of n) await Ai(T.join(e, r.name), T.join(t, r.name));
|
|
3025
3039
|
} else await y.mkdir(T.dirname(t), { recursive: !0 }), await y.copyFile(e, t);
|
|
3026
3040
|
}
|
|
3027
|
-
async function
|
|
3041
|
+
async function ji(e) {
|
|
3028
3042
|
let { src: t, dest: n, projectRoot: r, skip: i } = e;
|
|
3029
3043
|
if ((await y.stat(t)).isDirectory()) {
|
|
3030
3044
|
await y.mkdir(n, { recursive: !0 });
|
|
3031
3045
|
let e = await y.readdir(t, { withFileTypes: !0 });
|
|
3032
|
-
return (await Promise.all(e.map((e) =>
|
|
3046
|
+
return (await Promise.all(e.map((e) => ji({
|
|
3033
3047
|
src: T.join(t, e.name),
|
|
3034
3048
|
dest: T.join(n, e.name),
|
|
3035
3049
|
projectRoot: r,
|
|
@@ -3038,17 +3052,17 @@ async function Ai(e) {
|
|
|
3038
3052
|
}
|
|
3039
3053
|
return i.has(t) ? [] : (await y.mkdir(T.dirname(n), { recursive: !0 }), await y.copyFile(t, n), [T.relative(r, n)]);
|
|
3040
3054
|
}
|
|
3041
|
-
async function
|
|
3042
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a =
|
|
3055
|
+
async function Mi(e) {
|
|
3056
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = Tr(t.source, n), o = wr(t.target, r, i);
|
|
3043
3057
|
return {
|
|
3044
3058
|
sourcePath: a,
|
|
3045
3059
|
targetPath: o,
|
|
3046
|
-
sourceExists: await J(a) || await
|
|
3047
|
-
targetExists: await J(o) || await
|
|
3060
|
+
sourceExists: await J(a) || await ar(a),
|
|
3061
|
+
targetExists: await J(o) || await ar(o)
|
|
3048
3062
|
};
|
|
3049
3063
|
}
|
|
3050
|
-
async function
|
|
3051
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await
|
|
3064
|
+
async function Ni(e) {
|
|
3065
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await Mi({
|
|
3052
3066
|
file: t,
|
|
3053
3067
|
packDir: n,
|
|
3054
3068
|
paths: r,
|
|
@@ -3063,8 +3077,8 @@ async function Mi(e) {
|
|
|
3063
3077
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3064
3078
|
}
|
|
3065
3079
|
}
|
|
3066
|
-
async function
|
|
3067
|
-
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await
|
|
3080
|
+
async function Pi(e) {
|
|
3081
|
+
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await Mi({
|
|
3068
3082
|
file: t,
|
|
3069
3083
|
packDir: n,
|
|
3070
3084
|
paths: r,
|
|
@@ -3082,7 +3096,7 @@ async function Ni(e) {
|
|
|
3082
3096
|
status: "skipped",
|
|
3083
3097
|
path: t.target,
|
|
3084
3098
|
reason: "Already exists"
|
|
3085
|
-
} : (await
|
|
3099
|
+
} : (await Ai(s, c), {
|
|
3086
3100
|
status: "installed",
|
|
3087
3101
|
path: t.target
|
|
3088
3102
|
});
|
|
@@ -3091,16 +3105,16 @@ async function Ni(e) {
|
|
|
3091
3105
|
status: "skipped",
|
|
3092
3106
|
path: t.target,
|
|
3093
3107
|
reason: "Already exists (skip-if-exists)"
|
|
3094
|
-
} : (await
|
|
3108
|
+
} : (await Ai(s, c), {
|
|
3095
3109
|
status: "installed",
|
|
3096
3110
|
path: t.target
|
|
3097
3111
|
});
|
|
3098
|
-
case "override": return await
|
|
3112
|
+
case "override": return await Ai(s, c), {
|
|
3099
3113
|
status: "installed",
|
|
3100
3114
|
path: t.target
|
|
3101
3115
|
};
|
|
3102
3116
|
case "merge": {
|
|
3103
|
-
if (!u) return await
|
|
3117
|
+
if (!u) return await Ai(s, c), {
|
|
3104
3118
|
status: "installed",
|
|
3105
3119
|
path: t.target
|
|
3106
3120
|
};
|
|
@@ -3130,15 +3144,15 @@ async function Ni(e) {
|
|
|
3130
3144
|
};
|
|
3131
3145
|
}
|
|
3132
3146
|
}
|
|
3133
|
-
async function
|
|
3147
|
+
async function Fi(e) {
|
|
3134
3148
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3135
3149
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3136
3150
|
let o = [], s = /* @__PURE__ */ new Set();
|
|
3137
3151
|
for (let e of t) {
|
|
3138
3152
|
let t = i?.get(e.manifest.name);
|
|
3139
3153
|
for (let n of e.manifest.files) {
|
|
3140
|
-
if (n.strategy !== "create" || !
|
|
3141
|
-
let { targetPath: i, targetExists: c } = await
|
|
3154
|
+
if (n.strategy !== "create" || !ki(n, t)) continue;
|
|
3155
|
+
let { targetPath: i, targetExists: c } = await Mi({
|
|
3142
3156
|
file: n,
|
|
3143
3157
|
packDir: e.packDir,
|
|
3144
3158
|
paths: a,
|
|
@@ -3153,13 +3167,13 @@ async function Pi(e) {
|
|
|
3153
3167
|
}
|
|
3154
3168
|
return o;
|
|
3155
3169
|
}
|
|
3156
|
-
async function
|
|
3170
|
+
async function Ii(e) {
|
|
3157
3171
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3158
3172
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3159
3173
|
let c = [];
|
|
3160
3174
|
for (let e of t.files) {
|
|
3161
|
-
if (!
|
|
3162
|
-
let t = await
|
|
3175
|
+
if (!ki(e, o)) continue;
|
|
3176
|
+
let t = await Ni({
|
|
3163
3177
|
file: e,
|
|
3164
3178
|
packDir: a,
|
|
3165
3179
|
paths: s,
|
|
@@ -3170,16 +3184,16 @@ async function Fi(e) {
|
|
|
3170
3184
|
}
|
|
3171
3185
|
return c;
|
|
3172
3186
|
}
|
|
3173
|
-
async function
|
|
3187
|
+
async function Li(e) {
|
|
3174
3188
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3175
3189
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3176
3190
|
let l = {
|
|
3177
3191
|
installed: [],
|
|
3178
3192
|
skipped: [],
|
|
3179
3193
|
errors: []
|
|
3180
|
-
}, u = t.files.filter((e) =>
|
|
3194
|
+
}, u = t.files.filter((e) => ki(e, s));
|
|
3181
3195
|
for (let e of u) {
|
|
3182
|
-
let t = await
|
|
3196
|
+
let t = await Pi({
|
|
3183
3197
|
file: e,
|
|
3184
3198
|
packDir: o,
|
|
3185
3199
|
paths: c,
|
|
@@ -3199,40 +3213,40 @@ async function Ii(e) {
|
|
|
3199
3213
|
break;
|
|
3200
3214
|
}
|
|
3201
3215
|
}
|
|
3202
|
-
await
|
|
3216
|
+
await wi({
|
|
3203
3217
|
files: u,
|
|
3204
3218
|
paths: c,
|
|
3205
3219
|
projectRoot: r,
|
|
3206
3220
|
projectName: n.name
|
|
3207
|
-
}), t.env && t.env.length > 0 && await
|
|
3221
|
+
}), t.env && t.env.length > 0 && await jr(t.env, c, r), t.routes && t.routes.length > 0 && await Ir(t.routes, c, r), t.context && t.context.length > 0 && await zr(t.context, c, r), t.sockets && t.sockets.length > 0 && await qr(t.sockets, c, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await Zr(t.sdkConfigurations, c, r), t.enums && t.enums.length > 0 && await Gr(t.enums, c, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await ei(t.frontendRoutes, c, r);
|
|
3208
3222
|
let d = s && s.length > 0 ? s : ["frontend"];
|
|
3209
|
-
for (let e of d) t.nav && t.nav.length > 0 && await
|
|
3223
|
+
for (let e of d) t.nav && t.nav.length > 0 && await ii({
|
|
3210
3224
|
entries: t.nav,
|
|
3211
3225
|
paths: c,
|
|
3212
3226
|
projectRoot: r,
|
|
3213
3227
|
slot: e
|
|
3214
|
-
}), t.navbarActions && t.navbarActions.length > 0 && await
|
|
3228
|
+
}), t.navbarActions && t.navbarActions.length > 0 && await _i({
|
|
3215
3229
|
actions: t.navbarActions,
|
|
3216
3230
|
paths: c,
|
|
3217
3231
|
projectRoot: r,
|
|
3218
3232
|
slot: e
|
|
3219
|
-
}), t.userMenuActions && t.userMenuActions.length > 0 && await
|
|
3233
|
+
}), t.userMenuActions && t.userMenuActions.length > 0 && await vi({
|
|
3220
3234
|
actions: t.userMenuActions,
|
|
3221
3235
|
paths: c,
|
|
3222
3236
|
projectRoot: r,
|
|
3223
3237
|
slot: e
|
|
3224
3238
|
});
|
|
3225
|
-
return t.onboardingSteps && t.onboardingSteps.length > 0 && await
|
|
3239
|
+
return t.onboardingSteps && t.onboardingSteps.length > 0 && await fi(t.onboardingSteps, c, r), t.postLoginRedirect && await ai({
|
|
3226
3240
|
postLoginRedirect: t.postLoginRedirect,
|
|
3227
3241
|
paths: c,
|
|
3228
3242
|
projectRoot: r,
|
|
3229
3243
|
slot: d[0]
|
|
3230
3244
|
}), l;
|
|
3231
3245
|
}
|
|
3232
|
-
async function
|
|
3246
|
+
async function Ri(e) {
|
|
3233
3247
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3234
3248
|
for (let e of t) {
|
|
3235
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3249
|
+
let t = o?.get(e.manifest.name), a = await Ii({
|
|
3236
3250
|
manifest: e.manifest,
|
|
3237
3251
|
config: n,
|
|
3238
3252
|
projectRoot: r,
|
|
@@ -3252,7 +3266,7 @@ async function Li(e) {
|
|
|
3252
3266
|
};
|
|
3253
3267
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3254
3268
|
for (let e of t) {
|
|
3255
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3269
|
+
let t = o?.get(e.manifest.name), n = await Li({
|
|
3256
3270
|
manifest: e.manifest,
|
|
3257
3271
|
config: f,
|
|
3258
3272
|
projectRoot: r,
|
|
@@ -3261,7 +3275,7 @@ async function Li(e) {
|
|
|
3261
3275
|
packDir: e.packDir,
|
|
3262
3276
|
slots: t
|
|
3263
3277
|
});
|
|
3264
|
-
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await
|
|
3278
|
+
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await zi(f, e.manifest.name, r), d.push(e.manifest.name);
|
|
3265
3279
|
}
|
|
3266
3280
|
return {
|
|
3267
3281
|
installed: c,
|
|
@@ -3272,24 +3286,24 @@ async function Li(e) {
|
|
|
3272
3286
|
config: f
|
|
3273
3287
|
};
|
|
3274
3288
|
}
|
|
3275
|
-
async function
|
|
3289
|
+
async function zi(e, t, n) {
|
|
3276
3290
|
let r = {
|
|
3277
3291
|
...e,
|
|
3278
3292
|
installedPacks: [...e.installedPacks ?? [], t]
|
|
3279
3293
|
};
|
|
3280
|
-
return await
|
|
3294
|
+
return await _r(n, r), r;
|
|
3281
3295
|
}
|
|
3282
|
-
async function
|
|
3296
|
+
async function Bi(e) {
|
|
3283
3297
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3284
3298
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3285
|
-
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) =>
|
|
3286
|
-
if (await
|
|
3299
|
+
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) => Tr(e.source, i))), u = T.join(i, "files");
|
|
3300
|
+
if (await ar(u)) {
|
|
3287
3301
|
let e = await y.readdir(u, { withFileTypes: !0 });
|
|
3288
3302
|
for (let t of e) {
|
|
3289
3303
|
if (!t.isDirectory()) continue;
|
|
3290
3304
|
let e = a[t.name]?.root;
|
|
3291
3305
|
if (!e) continue;
|
|
3292
|
-
let n = await
|
|
3306
|
+
let n = await ji({
|
|
3293
3307
|
src: T.join(u, t.name),
|
|
3294
3308
|
dest: T.resolve(r, e),
|
|
3295
3309
|
projectRoot: r,
|
|
@@ -3299,7 +3313,7 @@ async function zi(e) {
|
|
|
3299
3313
|
}
|
|
3300
3314
|
}
|
|
3301
3315
|
for (let e of c) {
|
|
3302
|
-
let t = await
|
|
3316
|
+
let t = await Pi({
|
|
3303
3317
|
file: e,
|
|
3304
3318
|
packDir: i,
|
|
3305
3319
|
paths: a,
|
|
@@ -3309,12 +3323,12 @@ async function zi(e) {
|
|
|
3309
3323
|
});
|
|
3310
3324
|
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3311
3325
|
}
|
|
3312
|
-
let d = T.join(
|
|
3313
|
-
return await J(f) && await J(p) && await y.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await
|
|
3326
|
+
let d = T.join(wr("{{frontend.root}}", a, r), "src", "routes"), f = T.join(d, "(public)", "index.tsx"), p = T.join(d, "(private)", "index.tsx");
|
|
3327
|
+
return await J(f) && await J(p) && await y.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await ei(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await ii({
|
|
3314
3328
|
entries: t.nav,
|
|
3315
3329
|
paths: a,
|
|
3316
3330
|
projectRoot: r
|
|
3317
|
-
}), t.postLoginRedirect && await
|
|
3331
|
+
}), t.postLoginRedirect && await ai({
|
|
3318
3332
|
postLoginRedirect: t.postLoginRedirect,
|
|
3319
3333
|
paths: a,
|
|
3320
3334
|
projectRoot: r
|
|
@@ -3325,28 +3339,28 @@ async function zi(e) {
|
|
|
3325
3339
|
}
|
|
3326
3340
|
//#endregion
|
|
3327
3341
|
//#region src/core/pack-categories.ts
|
|
3328
|
-
var
|
|
3342
|
+
var Vi = [
|
|
3329
3343
|
"starter",
|
|
3330
3344
|
"layout",
|
|
3331
3345
|
"feature"
|
|
3332
|
-
],
|
|
3346
|
+
], Hi = {
|
|
3333
3347
|
starter: "Starter",
|
|
3334
3348
|
layout: "Layout",
|
|
3335
3349
|
feature: "Features"
|
|
3336
|
-
},
|
|
3337
|
-
function
|
|
3350
|
+
}, Ui = new Set(["starter", "layout"]), Wi = "layout-basic";
|
|
3351
|
+
function Gi(e, t = {}) {
|
|
3338
3352
|
let n = [];
|
|
3339
|
-
for (let r of
|
|
3353
|
+
for (let r of Vi) {
|
|
3340
3354
|
let i = e.filter((e) => e.category === r);
|
|
3341
3355
|
if (i.length === 0) continue;
|
|
3342
|
-
let a =
|
|
3356
|
+
let a = Ui.has(r) ? "single" : "multiple";
|
|
3343
3357
|
if (r === "layout") {
|
|
3344
|
-
n.push(
|
|
3358
|
+
n.push(Ki("frontend", i)), t.adminAvailable && n.push(Ki("admin", i));
|
|
3345
3359
|
continue;
|
|
3346
3360
|
}
|
|
3347
3361
|
n.push({
|
|
3348
3362
|
category: r,
|
|
3349
|
-
label:
|
|
3363
|
+
label: Hi[r],
|
|
3350
3364
|
mode: a,
|
|
3351
3365
|
packs: i,
|
|
3352
3366
|
preselect: null
|
|
@@ -3354,20 +3368,20 @@ function Wi(e, t = {}) {
|
|
|
3354
3368
|
}
|
|
3355
3369
|
return n;
|
|
3356
3370
|
}
|
|
3357
|
-
function
|
|
3358
|
-
let n = t.some((e) => e.name ===
|
|
3371
|
+
function Ki(e, t) {
|
|
3372
|
+
let n = t.some((e) => e.name === Wi);
|
|
3359
3373
|
return {
|
|
3360
3374
|
category: "layout",
|
|
3361
3375
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3362
3376
|
mode: "single",
|
|
3363
3377
|
packs: t,
|
|
3364
|
-
preselect: n ?
|
|
3378
|
+
preselect: n ? Wi : null,
|
|
3365
3379
|
slot: e
|
|
3366
3380
|
};
|
|
3367
3381
|
}
|
|
3368
3382
|
//#endregion
|
|
3369
3383
|
//#region src/ui/logger.ts
|
|
3370
|
-
function
|
|
3384
|
+
function qi(e) {
|
|
3371
3385
|
s.note(e.map((e) => `${z.arrow} ${e}`).join("\n"), "Next steps");
|
|
3372
3386
|
}
|
|
3373
3387
|
function X() {
|
|
@@ -3375,13 +3389,13 @@ function X() {
|
|
|
3375
3389
|
}
|
|
3376
3390
|
//#endregion
|
|
3377
3391
|
//#region src/core/post-setup.ts
|
|
3378
|
-
async function
|
|
3392
|
+
async function Ji() {
|
|
3379
3393
|
return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3380
3394
|
}
|
|
3381
|
-
async function
|
|
3395
|
+
async function Yi(e) {
|
|
3382
3396
|
return J(`${e}/apps/backend/.env`);
|
|
3383
3397
|
}
|
|
3384
|
-
async function
|
|
3398
|
+
async function Xi(e, t, n) {
|
|
3385
3399
|
let r = n ? `Start services with ${R.command("docker compose up -d")}?` : `Docker is not running. Start services with ${R.command("docker compose up -d")}?`, i = t ? !0 : await s.confirm({
|
|
3386
3400
|
message: r,
|
|
3387
3401
|
initialValue: !0
|
|
@@ -3394,13 +3408,13 @@ async function Yi(e, t, n) {
|
|
|
3394
3408
|
"up",
|
|
3395
3409
|
"-d"
|
|
3396
3410
|
], { cwd: `${e}/apps/backend` });
|
|
3397
|
-
return o.exitCode === 0 ? (a.stop(R.success("Docker services started")), !0) : (a.error("Failed to start Docker services"),
|
|
3411
|
+
return o.exitCode === 0 ? (a.stop(R.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), Zi(o), !1);
|
|
3398
3412
|
}
|
|
3399
|
-
function
|
|
3413
|
+
function Zi(e) {
|
|
3400
3414
|
let t = (e.stderr || e.stdout).trim();
|
|
3401
3415
|
t && s.log.warn(R.muted(t));
|
|
3402
3416
|
}
|
|
3403
|
-
async function
|
|
3417
|
+
async function Qi(e, t = 15, n = 2e3) {
|
|
3404
3418
|
for (let r = 0; r < t; r++) {
|
|
3405
3419
|
if ((await q("docker", [
|
|
3406
3420
|
"compose",
|
|
@@ -3415,8 +3429,8 @@ async function Zi(e, t = 15, n = 2e3) {
|
|
|
3415
3429
|
}
|
|
3416
3430
|
return !1;
|
|
3417
3431
|
}
|
|
3418
|
-
var
|
|
3419
|
-
async function
|
|
3432
|
+
var $i = "Database schema is up to date";
|
|
3433
|
+
async function ea(e) {
|
|
3420
3434
|
let t = await q("pnpm", [
|
|
3421
3435
|
"--filter",
|
|
3422
3436
|
"@internal/backend",
|
|
@@ -3425,9 +3439,9 @@ async function $i(e) {
|
|
|
3425
3439
|
"migrate",
|
|
3426
3440
|
"status"
|
|
3427
3441
|
], { cwd: e });
|
|
3428
|
-
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes(
|
|
3442
|
+
return t.exitCode === 0 ? `${t.stdout}\n${t.stderr}`.includes($i) : !1;
|
|
3429
3443
|
}
|
|
3430
|
-
async function
|
|
3444
|
+
async function ta(e) {
|
|
3431
3445
|
let t = s.spinner();
|
|
3432
3446
|
t.start("Running database migrations...");
|
|
3433
3447
|
let n = await q("pnpm", [
|
|
@@ -3435,15 +3449,15 @@ async function ea(e) {
|
|
|
3435
3449
|
"@internal/backend",
|
|
3436
3450
|
"migration:latest"
|
|
3437
3451
|
], { cwd: e });
|
|
3438
|
-
return n.exitCode === 0 ? (t.stop(R.success("Database migrations applied")), !0) : (t.error("Migrations failed"),
|
|
3452
|
+
return n.exitCode === 0 ? (t.stop(R.success("Database migrations applied")), !0) : (t.error("Migrations failed"), Zi(n), s.log.warn(R.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations.")), !1);
|
|
3439
3453
|
}
|
|
3440
|
-
async function
|
|
3441
|
-
if (!await
|
|
3454
|
+
async function na(e, t, n = {}) {
|
|
3455
|
+
if (!await Xi(e, t, await Ji())) return !1;
|
|
3442
3456
|
let r = s.spinner();
|
|
3443
|
-
return r.start("Waiting for Postgres to be ready..."), await
|
|
3457
|
+
return r.start("Waiting for Postgres to be ready..."), await Qi(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3) ? (r.stop(R.success("Postgres is ready")), !0) : (r.error("Postgres health check timed out"), s.log.warn(R.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest")), !1);
|
|
3444
3458
|
}
|
|
3445
|
-
async function
|
|
3446
|
-
if (!await
|
|
3459
|
+
async function ra(e, t, n = {}) {
|
|
3460
|
+
if (!await na(e, t, n)) return;
|
|
3447
3461
|
let r = t ? !0 : await s.confirm({
|
|
3448
3462
|
message: `Run database migrations with ${R.command("prisma migrate deploy")}?`,
|
|
3449
3463
|
initialValue: !0
|
|
@@ -3452,18 +3466,21 @@ async function na(e, t, n = {}) {
|
|
|
3452
3466
|
s.log.info(R.muted("Skipping database migrations."));
|
|
3453
3467
|
return;
|
|
3454
3468
|
}
|
|
3455
|
-
await
|
|
3469
|
+
await ta(e);
|
|
3456
3470
|
}
|
|
3457
|
-
async function
|
|
3458
|
-
if (!await
|
|
3471
|
+
async function ia(e, t, n = {}) {
|
|
3472
|
+
if (!await Yi(e)) {
|
|
3459
3473
|
s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3460
3474
|
return;
|
|
3461
3475
|
}
|
|
3462
|
-
await
|
|
3476
|
+
await ra(e, t, n);
|
|
3477
|
+
}
|
|
3478
|
+
async function aa(e, t, n = {}) {
|
|
3479
|
+
return await Yi(e) ? na(e, t, n) : (s.log.warn(`${R.path(".env")} not found in ${R.path("apps/backend")}. Skipping Docker - configure it first.`), !1);
|
|
3463
3480
|
}
|
|
3464
3481
|
//#endregion
|
|
3465
3482
|
//#region src/core/resolve.ts
|
|
3466
|
-
function
|
|
3483
|
+
function oa(e) {
|
|
3467
3484
|
let t = /* @__PURE__ */ new Map();
|
|
3468
3485
|
for (let n of e) t.set(n.name, {
|
|
3469
3486
|
name: n.name,
|
|
@@ -3471,7 +3488,7 @@ function ia(e) {
|
|
|
3471
3488
|
});
|
|
3472
3489
|
return t;
|
|
3473
3490
|
}
|
|
3474
|
-
function
|
|
3491
|
+
function sa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3475
3492
|
let r = /* @__PURE__ */ new Set();
|
|
3476
3493
|
function i(e) {
|
|
3477
3494
|
if (n.has(e)) return [];
|
|
@@ -3485,10 +3502,10 @@ function aa(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3485
3502
|
}
|
|
3486
3503
|
return i(e);
|
|
3487
3504
|
}
|
|
3488
|
-
function
|
|
3505
|
+
function ca(e, t, n = []) {
|
|
3489
3506
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3490
3507
|
for (let n of e) {
|
|
3491
|
-
let e =
|
|
3508
|
+
let e = sa(n, t, new Set(i));
|
|
3492
3509
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3493
3510
|
}
|
|
3494
3511
|
return {
|
|
@@ -3496,7 +3513,7 @@ function oa(e, t, n = []) {
|
|
|
3496
3513
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3497
3514
|
};
|
|
3498
3515
|
}
|
|
3499
|
-
function
|
|
3516
|
+
function la(e) {
|
|
3500
3517
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3501
3518
|
for (let e of t) {
|
|
3502
3519
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3509,7 +3526,7 @@ function sa(e) {
|
|
|
3509
3526
|
}
|
|
3510
3527
|
//#endregion
|
|
3511
3528
|
//#region src/core/variants.ts
|
|
3512
|
-
function
|
|
3529
|
+
function ua(e, t = {}) {
|
|
3513
3530
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3514
3531
|
for (let i of e) {
|
|
3515
3532
|
let e = t[i.family] ?? i.default;
|
|
@@ -3521,14 +3538,14 @@ function ca(e, t = {}) {
|
|
|
3521
3538
|
familyOf: r
|
|
3522
3539
|
};
|
|
3523
3540
|
}
|
|
3524
|
-
function
|
|
3541
|
+
function da(e, t, n) {
|
|
3525
3542
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3526
3543
|
}
|
|
3527
|
-
function
|
|
3544
|
+
function fa(e, t) {
|
|
3528
3545
|
let n = t.familyOf.get(e);
|
|
3529
3546
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3530
3547
|
}
|
|
3531
|
-
function
|
|
3548
|
+
function pa(e, t) {
|
|
3532
3549
|
let n = /* @__PURE__ */ new Map();
|
|
3533
3550
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3534
3551
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3544,65 +3561,65 @@ function da(e, t) {
|
|
|
3544
3561
|
familyOf: n
|
|
3545
3562
|
};
|
|
3546
3563
|
}
|
|
3547
|
-
function
|
|
3564
|
+
function ma(e, t) {
|
|
3548
3565
|
return e.map((e) => ({
|
|
3549
3566
|
...e,
|
|
3550
|
-
dependencies: e.dependencies.map((e) =>
|
|
3567
|
+
dependencies: e.dependencies.map((e) => fa(e, t))
|
|
3551
3568
|
}));
|
|
3552
3569
|
}
|
|
3553
3570
|
//#endregion
|
|
3554
3571
|
//#region src/ui/banner.ts
|
|
3555
|
-
var
|
|
3572
|
+
var ha = [
|
|
3556
3573
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3557
3574
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3558
3575
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3559
3576
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3560
3577
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3561
3578
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3562
|
-
],
|
|
3579
|
+
], ga = [
|
|
3563
3580
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3564
3581
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3565
3582
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3566
3583
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3567
3584
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3568
3585
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3569
|
-
],
|
|
3586
|
+
], _a = [
|
|
3570
3587
|
253,
|
|
3571
3588
|
176,
|
|
3572
3589
|
21
|
|
3573
|
-
],
|
|
3590
|
+
], va = [
|
|
3574
3591
|
245,
|
|
3575
3592
|
76,
|
|
3576
3593
|
2
|
|
3577
|
-
],
|
|
3594
|
+
], ya = 5, ba = [
|
|
3578
3595
|
17,
|
|
3579
3596
|
103,
|
|
3580
3597
|
248
|
|
3581
|
-
],
|
|
3598
|
+
], xa = [
|
|
3582
3599
|
42,
|
|
3583
3600
|
160,
|
|
3584
3601
|
250
|
|
3585
|
-
],
|
|
3586
|
-
function
|
|
3602
|
+
], Sa = .2;
|
|
3603
|
+
function Ca() {
|
|
3587
3604
|
console.log();
|
|
3588
|
-
for (let e of xe(
|
|
3589
|
-
start:
|
|
3590
|
-
end:
|
|
3591
|
-
angle:
|
|
3605
|
+
for (let e of xe(ha, {
|
|
3606
|
+
start: _a,
|
|
3607
|
+
end: va,
|
|
3608
|
+
angle: ya
|
|
3592
3609
|
})) console.log(b.bold(e));
|
|
3593
|
-
for (let e of xe(
|
|
3594
|
-
start:
|
|
3595
|
-
end:
|
|
3596
|
-
angle:
|
|
3610
|
+
for (let e of xe(ga, {
|
|
3611
|
+
start: ba,
|
|
3612
|
+
end: xa,
|
|
3613
|
+
angle: Sa
|
|
3597
3614
|
})) console.log(b.bold(e));
|
|
3598
3615
|
console.log(), console.log(` ${z.spark} ${b.dim("v" + A)} ${b.dim("·")} ${ye("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3599
3616
|
}
|
|
3600
|
-
function
|
|
3617
|
+
function wa() {
|
|
3601
3618
|
console.log(), console.log(` ${z.bolt} ${ge.orange("Hype")}${ge.skyBlue("Stack")} ${b.dim("v" + A)}`), console.log();
|
|
3602
3619
|
}
|
|
3603
3620
|
//#endregion
|
|
3604
3621
|
//#region src/ui/pack-multiselect.ts
|
|
3605
|
-
var
|
|
3622
|
+
var Ta = class extends O {
|
|
3606
3623
|
options;
|
|
3607
3624
|
cursor = 0;
|
|
3608
3625
|
selected;
|
|
@@ -3706,44 +3723,44 @@ var Ca = class extends O {
|
|
|
3706
3723
|
}
|
|
3707
3724
|
}
|
|
3708
3725
|
};
|
|
3709
|
-
function
|
|
3710
|
-
return new
|
|
3726
|
+
function Ea(e) {
|
|
3727
|
+
return new Ta(e).prompt();
|
|
3711
3728
|
}
|
|
3712
3729
|
//#endregion
|
|
3713
3730
|
//#region src/utils/naming.ts
|
|
3714
|
-
function
|
|
3731
|
+
function Da(e) {
|
|
3715
3732
|
return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3716
3733
|
}
|
|
3717
|
-
function
|
|
3734
|
+
function Oa(e) {
|
|
3718
3735
|
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3719
3736
|
}
|
|
3720
3737
|
//#endregion
|
|
3721
3738
|
//#region src/utils/validate.ts
|
|
3722
|
-
function
|
|
3739
|
+
function ka(e) {
|
|
3723
3740
|
if (!e.trim()) return "Project name cannot be empty";
|
|
3724
3741
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
3725
|
-
let t =
|
|
3726
|
-
if (!
|
|
3742
|
+
let t = Da(e);
|
|
3743
|
+
if (!re.test(t)) return "Project name must contain at least one letter or number";
|
|
3727
3744
|
}
|
|
3728
3745
|
//#endregion
|
|
3729
3746
|
//#region src/core/apply-mode.ts
|
|
3730
|
-
var
|
|
3731
|
-
function
|
|
3732
|
-
return e.replace(
|
|
3747
|
+
var Aa = "src/hooks/use-theme.ts", ja = /(\bexport\s+const\s+defaultTheme\s*=\s*)(["'])(?:light|dark)\2/;
|
|
3748
|
+
function Ma(e, t) {
|
|
3749
|
+
return e.replace(ja, (e, n, r) => `${n}${r}${t}${r}`);
|
|
3733
3750
|
}
|
|
3734
|
-
async function
|
|
3735
|
-
let n = T.resolve(e,
|
|
3751
|
+
async function Na(e, t) {
|
|
3752
|
+
let n = T.resolve(e, Aa), r;
|
|
3736
3753
|
try {
|
|
3737
3754
|
r = await y.readFile(n, "utf-8");
|
|
3738
3755
|
} catch {
|
|
3739
3756
|
return !1;
|
|
3740
3757
|
}
|
|
3741
|
-
let i =
|
|
3758
|
+
let i = Ma(r, t);
|
|
3742
3759
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3743
3760
|
}
|
|
3744
3761
|
//#endregion
|
|
3745
3762
|
//#region src/core/apply-theme.ts
|
|
3746
|
-
function
|
|
3763
|
+
function Pa(e, t) {
|
|
3747
3764
|
let n = e.indexOf(t);
|
|
3748
3765
|
if (n === -1) return null;
|
|
3749
3766
|
let r = e.indexOf("{", n);
|
|
@@ -3758,47 +3775,47 @@ function Ma(e, t) {
|
|
|
3758
3775
|
bodyEnd: a - 1
|
|
3759
3776
|
} : null;
|
|
3760
3777
|
}
|
|
3761
|
-
function
|
|
3778
|
+
function Fa(e, t) {
|
|
3762
3779
|
let n = e;
|
|
3763
3780
|
for (let [e, r] of Object.entries(t)) {
|
|
3764
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3781
|
+
let t = RegExp(`(^[ \\t]*--${Ia(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3765
3782
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3766
3783
|
}
|
|
3767
3784
|
return n;
|
|
3768
3785
|
}
|
|
3769
|
-
function
|
|
3786
|
+
function Ia(e) {
|
|
3770
3787
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3771
3788
|
}
|
|
3772
|
-
function
|
|
3773
|
-
let n =
|
|
3789
|
+
function La(e, t) {
|
|
3790
|
+
let n = Pa(e, ":root"), r = Pa(e, ".dark"), i = e;
|
|
3774
3791
|
if (n) {
|
|
3775
3792
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3776
|
-
i = e +
|
|
3793
|
+
i = e + Fa(r, t.light) + a;
|
|
3777
3794
|
}
|
|
3778
3795
|
if (r) {
|
|
3779
|
-
let e =
|
|
3796
|
+
let e = Pa(i, ".dark");
|
|
3780
3797
|
if (e) {
|
|
3781
3798
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3782
|
-
i = n +
|
|
3799
|
+
i = n + Fa(r, t.dark) + a;
|
|
3783
3800
|
}
|
|
3784
3801
|
}
|
|
3785
3802
|
return i;
|
|
3786
3803
|
}
|
|
3787
|
-
var
|
|
3788
|
-
async function
|
|
3789
|
-
let n = T.resolve(e,
|
|
3804
|
+
var Ra = "assets/styles.css";
|
|
3805
|
+
async function za(e, t) {
|
|
3806
|
+
let n = T.resolve(e, Ra), r;
|
|
3790
3807
|
try {
|
|
3791
3808
|
r = await y.readFile(n, "utf-8");
|
|
3792
3809
|
} catch {
|
|
3793
3810
|
return !1;
|
|
3794
3811
|
}
|
|
3795
|
-
let i =
|
|
3812
|
+
let i = La(r, t);
|
|
3796
3813
|
return i === r || await y.writeFile(n, i, "utf-8"), !0;
|
|
3797
3814
|
}
|
|
3798
3815
|
//#endregion
|
|
3799
3816
|
//#region src/core/clone.ts
|
|
3800
|
-
async function
|
|
3801
|
-
let t = await ee(
|
|
3817
|
+
async function Ba(e) {
|
|
3818
|
+
let t = await ee(j, {
|
|
3802
3819
|
dir: e,
|
|
3803
3820
|
force: !0
|
|
3804
3821
|
});
|
|
@@ -3809,7 +3826,7 @@ async function Ra(e) {
|
|
|
3809
3826
|
}
|
|
3810
3827
|
//#endregion
|
|
3811
3828
|
//#region src/core/editor-config.ts
|
|
3812
|
-
function
|
|
3829
|
+
function Va(e) {
|
|
3813
3830
|
let t = {
|
|
3814
3831
|
globs: [],
|
|
3815
3832
|
alwaysApply: !1
|
|
@@ -3844,10 +3861,10 @@ function za(e) {
|
|
|
3844
3861
|
content: i
|
|
3845
3862
|
};
|
|
3846
3863
|
}
|
|
3847
|
-
function
|
|
3864
|
+
function Ha(e) {
|
|
3848
3865
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
3849
3866
|
}
|
|
3850
|
-
function
|
|
3867
|
+
function Ua(e) {
|
|
3851
3868
|
let t;
|
|
3852
3869
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
3853
3870
|
let n = [`trigger: ${t}`];
|
|
@@ -3857,30 +3874,30 @@ function Va(e) {
|
|
|
3857
3874
|
}
|
|
3858
3875
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
3859
3876
|
}
|
|
3860
|
-
function
|
|
3877
|
+
function Wa(e) {
|
|
3861
3878
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
3862
3879
|
}
|
|
3863
|
-
var
|
|
3880
|
+
var Ga = {
|
|
3864
3881
|
claude: {
|
|
3865
3882
|
rulesDir: ".claude/rules",
|
|
3866
3883
|
extension: ".md",
|
|
3867
|
-
convert:
|
|
3884
|
+
convert: Ha
|
|
3868
3885
|
},
|
|
3869
3886
|
windsurf: {
|
|
3870
3887
|
rulesDir: ".windsurf/rules",
|
|
3871
3888
|
extension: ".md",
|
|
3872
|
-
convert:
|
|
3889
|
+
convert: Ua
|
|
3873
3890
|
},
|
|
3874
3891
|
copilot: {
|
|
3875
3892
|
rulesDir: ".github/instructions",
|
|
3876
3893
|
extension: ".instructions.md",
|
|
3877
|
-
convert:
|
|
3894
|
+
convert: Wa
|
|
3878
3895
|
}
|
|
3879
3896
|
};
|
|
3880
|
-
async function
|
|
3881
|
-
let t = T.join(e,
|
|
3897
|
+
async function Ka(e) {
|
|
3898
|
+
let t = T.join(e, ae), n = (await y.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
3882
3899
|
return await Promise.all(n.map(async (e) => {
|
|
3883
|
-
let n = T.join(t, e.name), { frontmatter: r, content: i } =
|
|
3900
|
+
let n = T.join(t, e.name), { frontmatter: r, content: i } = Va(await y.readFile(n, "utf-8"));
|
|
3884
3901
|
return {
|
|
3885
3902
|
frontmatter: r,
|
|
3886
3903
|
content: i,
|
|
@@ -3888,31 +3905,31 @@ async function Wa(e) {
|
|
|
3888
3905
|
};
|
|
3889
3906
|
}));
|
|
3890
3907
|
}
|
|
3891
|
-
async function
|
|
3908
|
+
async function qa(e, t) {
|
|
3892
3909
|
if (t === "cursor") return;
|
|
3893
|
-
let n =
|
|
3910
|
+
let n = Ga[t], r = await Ka(e), i = T.join(e, n.rulesDir);
|
|
3894
3911
|
await y.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
3895
3912
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3896
3913
|
return y.writeFile(T.join(i, r), t, "utf-8");
|
|
3897
|
-
})), await
|
|
3914
|
+
})), await ur(T.join(e, oe)), await ur(T.join(e, se));
|
|
3898
3915
|
}
|
|
3899
3916
|
//#endregion
|
|
3900
3917
|
//#region src/core/env-files.ts
|
|
3901
|
-
var
|
|
3918
|
+
var Ja = [
|
|
3902
3919
|
"apps",
|
|
3903
3920
|
"packages",
|
|
3904
3921
|
"libs",
|
|
3905
3922
|
"shared"
|
|
3906
3923
|
];
|
|
3907
|
-
async function
|
|
3908
|
-
let t = await
|
|
3924
|
+
async function Ya(e) {
|
|
3925
|
+
let t = await Xa(e);
|
|
3909
3926
|
return (await Promise.all(t.map(async (t) => {
|
|
3910
3927
|
let n = T.join(T.dirname(t), ".env");
|
|
3911
3928
|
return await J(n) ? null : (await y.copyFile(t, n), T.relative(e, n));
|
|
3912
3929
|
}))).filter((e) => e !== null).sort();
|
|
3913
3930
|
}
|
|
3914
|
-
async function
|
|
3915
|
-
let t = [T.join(e, ".env.example")], n = await Promise.all(
|
|
3931
|
+
async function Xa(e) {
|
|
3932
|
+
let t = [T.join(e, ".env.example")], n = await Promise.all(Ja.map(async (t) => {
|
|
3916
3933
|
let n = T.join(e, t);
|
|
3917
3934
|
return (await y.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => T.join(n, e.name, ".env.example"));
|
|
3918
3935
|
}));
|
|
@@ -3920,11 +3937,11 @@ async function Ja(e) {
|
|
|
3920
3937
|
}
|
|
3921
3938
|
//#endregion
|
|
3922
3939
|
//#region src/core/post-clone.ts
|
|
3923
|
-
var Z = "@hype-stack/",
|
|
3924
|
-
async function
|
|
3925
|
-
await
|
|
3940
|
+
var Z = "@hype-stack/", Za = "hype-stack";
|
|
3941
|
+
async function Qa(e) {
|
|
3942
|
+
await ur(T.join(e, ".git"));
|
|
3926
3943
|
}
|
|
3927
|
-
async function
|
|
3944
|
+
async function $a(e) {
|
|
3928
3945
|
await q("git", ["init"], { cwd: e }), await q("git", ["add", "."], { cwd: e }), await q("git", [
|
|
3929
3946
|
"-c",
|
|
3930
3947
|
"user.name=Hype Stack CLI",
|
|
@@ -3935,22 +3952,22 @@ async function Za(e) {
|
|
|
3935
3952
|
"Initial commit from Hype Stack CLI"
|
|
3936
3953
|
], { cwd: e });
|
|
3937
3954
|
}
|
|
3938
|
-
async function
|
|
3939
|
-
let n = `@${t}/`, r = await
|
|
3955
|
+
async function eo(e, t) {
|
|
3956
|
+
let n = `@${t}/`, r = await co(e);
|
|
3940
3957
|
for (let e of r) {
|
|
3941
|
-
let t = await
|
|
3958
|
+
let t = await sr(e);
|
|
3942
3959
|
if (!t) continue;
|
|
3943
3960
|
let r = !1;
|
|
3944
|
-
t.name?.startsWith(Z) && (t.name = t.name.replace(Z, n), r = !0),
|
|
3961
|
+
t.name?.startsWith(Z) && (t.name = t.name.replace(Z, n), r = !0), ao(t.dependencies, n) && (r = !0), ao(t.devDependencies, n) && (r = !0), t.nx && oo(t.nx, n) && (r = !0);
|
|
3945
3962
|
let i = await y.readFile(e, "utf-8");
|
|
3946
3963
|
if (i.includes(Z)) {
|
|
3947
3964
|
let t = i.replaceAll(Z, n);
|
|
3948
3965
|
await y.writeFile(e, t, "utf-8");
|
|
3949
|
-
} else r && await
|
|
3966
|
+
} else r && await cr(e, t);
|
|
3950
3967
|
}
|
|
3951
|
-
await
|
|
3968
|
+
await Ei(e, t), await ro(e, t), await so(e, t);
|
|
3952
3969
|
}
|
|
3953
|
-
var
|
|
3970
|
+
var to = new Set([
|
|
3954
3971
|
".git",
|
|
3955
3972
|
"node_modules",
|
|
3956
3973
|
"dist",
|
|
@@ -3958,10 +3975,10 @@ var $a = new Set([
|
|
|
3958
3975
|
".nx",
|
|
3959
3976
|
".next",
|
|
3960
3977
|
"coverage"
|
|
3961
|
-
]),
|
|
3962
|
-
async function
|
|
3963
|
-
if (t ===
|
|
3964
|
-
let n = await
|
|
3978
|
+
]), no = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
|
|
3979
|
+
async function ro(e, t) {
|
|
3980
|
+
if (t === Za) return;
|
|
3981
|
+
let n = await io(e);
|
|
3965
3982
|
await Promise.all(n.map(async (e) => {
|
|
3966
3983
|
let n = await y.readFile(e, "utf-8").catch(() => null);
|
|
3967
3984
|
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
@@ -3969,14 +3986,14 @@ async function to(e, t) {
|
|
|
3969
3986
|
await y.writeFile(e, r, "utf-8");
|
|
3970
3987
|
}));
|
|
3971
3988
|
}
|
|
3972
|
-
async function
|
|
3989
|
+
async function io(e) {
|
|
3973
3990
|
let t = await y.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
3974
3991
|
return (await Promise.all(t.map(async (t) => {
|
|
3975
3992
|
let n = T.join(e, t.name);
|
|
3976
|
-
return t.isDirectory() ?
|
|
3993
|
+
return t.isDirectory() ? to.has(t.name) ? [] : io(n) : t.isFile() && no.test(t.name) ? [n] : [];
|
|
3977
3994
|
}))).flat();
|
|
3978
3995
|
}
|
|
3979
|
-
function
|
|
3996
|
+
function ao(e, t) {
|
|
3980
3997
|
if (!e) return !1;
|
|
3981
3998
|
let n = !1;
|
|
3982
3999
|
for (let r of Object.keys(e)) if (r.startsWith(Z)) {
|
|
@@ -3985,7 +4002,7 @@ function ro(e, t) {
|
|
|
3985
4002
|
}
|
|
3986
4003
|
return n;
|
|
3987
4004
|
}
|
|
3988
|
-
function
|
|
4005
|
+
function oo(e, t) {
|
|
3989
4006
|
if (!e) return !1;
|
|
3990
4007
|
let n = !1;
|
|
3991
4008
|
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Z) ? (n = !0, e.replace(Z, t)) : e), e.targets) {
|
|
@@ -3993,13 +4010,13 @@ function io(e, t) {
|
|
|
3993
4010
|
}
|
|
3994
4011
|
return n;
|
|
3995
4012
|
}
|
|
3996
|
-
async function
|
|
4013
|
+
async function so(e, t) {
|
|
3997
4014
|
let n = T.join(e, "packages/enums/src/app/index.ts"), r = await y.readFile(n, "utf-8").catch(() => null);
|
|
3998
4015
|
if (!r) return;
|
|
3999
|
-
let i =
|
|
4016
|
+
let i = Oa(t), a = r.replaceAll(`id: "${Za}"`, `id: "${t}"`).replaceAll(`name: "${Za}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
|
|
4000
4017
|
await y.writeFile(n, a, "utf-8");
|
|
4001
4018
|
}
|
|
4002
|
-
async function
|
|
4019
|
+
async function co(e) {
|
|
4003
4020
|
let t = [], n = T.join(e, "package.json");
|
|
4004
4021
|
(await y.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
4005
4022
|
for (let n of [
|
|
@@ -4019,7 +4036,7 @@ async function oo(e) {
|
|
|
4019
4036
|
}
|
|
4020
4037
|
//#endregion
|
|
4021
4038
|
//#region src/core/readme.ts
|
|
4022
|
-
var
|
|
4039
|
+
var lo = {
|
|
4023
4040
|
cursor: {
|
|
4024
4041
|
label: "Cursor",
|
|
4025
4042
|
rulesDir: ".cursor/rules"
|
|
@@ -4036,21 +4053,21 @@ var so = {
|
|
|
4036
4053
|
label: "GitHub Copilot",
|
|
4037
4054
|
rulesDir: ".github/instructions"
|
|
4038
4055
|
}
|
|
4039
|
-
},
|
|
4056
|
+
}, uo = {
|
|
4040
4057
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
4041
4058
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
4042
|
-
},
|
|
4059
|
+
}, fo = {
|
|
4043
4060
|
enums: "Shared enums and app config used across apps",
|
|
4044
4061
|
cli: "Project tooling and code generators"
|
|
4045
4062
|
};
|
|
4046
|
-
function
|
|
4063
|
+
function po(e, t) {
|
|
4047
4064
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
4048
4065
|
let r = t[e];
|
|
4049
4066
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4050
4067
|
});
|
|
4051
4068
|
}
|
|
4052
|
-
function
|
|
4053
|
-
let { projectName: t, editor: n, workspace: r } = e, i =
|
|
4069
|
+
function mo(e) {
|
|
4070
|
+
let { projectName: t, editor: n, workspace: r } = e, i = Oa(t), a = lo[n], o = !!r.apps.backend, s = po(r.apps, uo), c = po(r.packages, fo), l = [];
|
|
4054
4071
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
4055
4072
|
let u = [];
|
|
4056
4073
|
u.push(`# ${i}`), u.push([
|
|
@@ -4158,18 +4175,18 @@ function fo(e) {
|
|
|
4158
4175
|
"stays useful."
|
|
4159
4176
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4160
4177
|
}
|
|
4161
|
-
async function
|
|
4178
|
+
async function ho(e, t) {
|
|
4162
4179
|
let n = T.join(e, "README.md");
|
|
4163
|
-
await y.writeFile(n,
|
|
4180
|
+
await y.writeFile(n, mo(t), "utf-8");
|
|
4164
4181
|
}
|
|
4165
4182
|
//#endregion
|
|
4166
4183
|
//#region src/core/tracking.ts
|
|
4167
|
-
async function
|
|
4184
|
+
async function go(e) {
|
|
4168
4185
|
try {
|
|
4169
4186
|
let t = {
|
|
4170
4187
|
"X-Device-Id": Xn(),
|
|
4171
4188
|
"X-Client-Info": Zn()
|
|
4172
|
-
}, n = await Kn(
|
|
4189
|
+
}, n = await Kn(I()).catch(() => null);
|
|
4173
4190
|
n?.token && (t.Authorization = `Bearer ${n.token}`), await K.createRequest()({
|
|
4174
4191
|
endpoint: "/cli/track",
|
|
4175
4192
|
method: "POST"
|
|
@@ -4178,7 +4195,7 @@ async function mo(e) {
|
|
|
4178
4195
|
}
|
|
4179
4196
|
//#endregion
|
|
4180
4197
|
//#region src/core/npm-deps.ts
|
|
4181
|
-
function
|
|
4198
|
+
function _o(e, t) {
|
|
4182
4199
|
let n = [], r = [];
|
|
4183
4200
|
if (!e) return {
|
|
4184
4201
|
errors: n,
|
|
@@ -4209,7 +4226,7 @@ function ho(e, t) {
|
|
|
4209
4226
|
operations: r
|
|
4210
4227
|
};
|
|
4211
4228
|
}
|
|
4212
|
-
function
|
|
4229
|
+
function vo(e) {
|
|
4213
4230
|
let t = {};
|
|
4214
4231
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4215
4232
|
...t[e],
|
|
@@ -4217,7 +4234,7 @@ function go(e) {
|
|
|
4217
4234
|
};
|
|
4218
4235
|
return t;
|
|
4219
4236
|
}
|
|
4220
|
-
async function
|
|
4237
|
+
async function yo(e, t, n = q) {
|
|
4221
4238
|
let r = [];
|
|
4222
4239
|
for (let i of e) {
|
|
4223
4240
|
let e = T.join(t, i.relativeDir);
|
|
@@ -4253,14 +4270,14 @@ async function _o(e, t, n = q) {
|
|
|
4253
4270
|
function Q(e) {
|
|
4254
4271
|
return e instanceof Error ? e.message : String(e);
|
|
4255
4272
|
}
|
|
4256
|
-
async function
|
|
4273
|
+
async function bo(e, t, n) {
|
|
4257
4274
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4258
|
-
return r.length === 0 ? {} :
|
|
4275
|
+
return r.length === 0 ? {} : Or(r, n).catch(() => ({}));
|
|
4259
4276
|
}
|
|
4260
|
-
function
|
|
4277
|
+
function xo(e, t) {
|
|
4261
4278
|
return e === "free" ? R.success("free") : e === "owned" ? R.accent("owned") : `${R.highlight(`$${t}`)} ${R.muted("locked")}`;
|
|
4262
4279
|
}
|
|
4263
|
-
async function
|
|
4280
|
+
async function So(e, t, n) {
|
|
4264
4281
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4265
4282
|
i.length > 0 && s.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await rr(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4266
4283
|
name: e.name,
|
|
@@ -4268,7 +4285,7 @@ async function bo(e, t, n) {
|
|
|
4268
4285
|
price: e.price
|
|
4269
4286
|
})));
|
|
4270
4287
|
}
|
|
4271
|
-
function
|
|
4288
|
+
function Co(e, t) {
|
|
4272
4289
|
let n = e.map((e, n) => {
|
|
4273
4290
|
let r = t.get(e), i = r ? r.displayName : e;
|
|
4274
4291
|
return ` ${R.muted(`${n + 1}.`)} ${R.brand(i)}`;
|
|
@@ -4279,10 +4296,10 @@ function xo(e, t) {
|
|
|
4279
4296
|
...n
|
|
4280
4297
|
].join("\n"), "Install Plan");
|
|
4281
4298
|
}
|
|
4282
|
-
async function
|
|
4299
|
+
async function wo(e, t) {
|
|
4283
4300
|
let n = [];
|
|
4284
4301
|
for (let r of e) {
|
|
4285
|
-
let e = await
|
|
4302
|
+
let e = await Sr(r), i = await Cr(r, t);
|
|
4286
4303
|
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'npx @hype-stack/cli login' or check your license.`);
|
|
4287
4304
|
n.push({
|
|
4288
4305
|
manifest: e,
|
|
@@ -4291,21 +4308,21 @@ async function So(e, t) {
|
|
|
4291
4308
|
}
|
|
4292
4309
|
return n;
|
|
4293
4310
|
}
|
|
4294
|
-
async function
|
|
4295
|
-
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a =
|
|
4311
|
+
async function To(e) {
|
|
4312
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = _o(vo(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4296
4313
|
if (a.errors.length > 0) {
|
|
4297
4314
|
for (let e of a.errors) s.log.error(e);
|
|
4298
4315
|
return;
|
|
4299
4316
|
}
|
|
4300
4317
|
if (a.operations.length === 0) return;
|
|
4301
4318
|
i.start("Installing npm dependencies...");
|
|
4302
|
-
let o = await
|
|
4319
|
+
let o = await yo(a.operations, r);
|
|
4303
4320
|
if (i.stop(o.ok ? "npm dependencies installed" : "npm dependency installation failed"), !o.ok) for (let e of o.errors) s.log.error(e);
|
|
4304
4321
|
}
|
|
4305
|
-
function
|
|
4322
|
+
function Eo() {
|
|
4306
4323
|
s.note([` ${R.command("1. npx @hype-stack/cli onboard")} ${R.muted("(set up env vars + run migrations)")}`, ` ${R.command("2. pnpm dev")} ${R.muted("(start frontend + backend)")}`].join("\n"), "Next steps");
|
|
4307
4324
|
}
|
|
4308
|
-
function
|
|
4325
|
+
function Do(e) {
|
|
4309
4326
|
if (e.length === 0) return;
|
|
4310
4327
|
let t = e.map((e) => {
|
|
4311
4328
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
@@ -4313,10 +4330,10 @@ function To(e) {
|
|
|
4313
4330
|
});
|
|
4314
4331
|
s.note(t.join("\n"), "Skipped (already exist)");
|
|
4315
4332
|
}
|
|
4316
|
-
async function
|
|
4333
|
+
async function Oo(e) {
|
|
4317
4334
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: o } = e, c = /* @__PURE__ */ new Set();
|
|
4318
4335
|
if (i) return c;
|
|
4319
|
-
let l = await
|
|
4336
|
+
let l = await Fi({
|
|
4320
4337
|
packs: t,
|
|
4321
4338
|
config: n,
|
|
4322
4339
|
projectRoot: r,
|
|
@@ -4343,7 +4360,7 @@ async function Eo(e) {
|
|
|
4343
4360
|
}
|
|
4344
4361
|
//#endregion
|
|
4345
4362
|
//#region src/ui/swatch.ts
|
|
4346
|
-
function
|
|
4363
|
+
function ko(e) {
|
|
4347
4364
|
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4348
4365
|
if (!t) return null;
|
|
4349
4366
|
let n = t[1].trim().split(/\s+/);
|
|
@@ -4362,56 +4379,56 @@ function Do(e) {
|
|
|
4362
4379
|
h: a
|
|
4363
4380
|
};
|
|
4364
4381
|
}
|
|
4365
|
-
function
|
|
4382
|
+
function Ao(e) {
|
|
4366
4383
|
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4367
4384
|
}
|
|
4368
|
-
function
|
|
4385
|
+
function jo(e) {
|
|
4369
4386
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4370
4387
|
}
|
|
4371
|
-
function
|
|
4388
|
+
function Mo({ l: e, c: t, h: n }) {
|
|
4372
4389
|
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;
|
|
4373
4390
|
return [
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4391
|
+
Ao(jo(f) * 255),
|
|
4392
|
+
Ao(jo(p) * 255),
|
|
4393
|
+
Ao(jo(m) * 255)
|
|
4377
4394
|
];
|
|
4378
4395
|
}
|
|
4379
|
-
var
|
|
4380
|
-
function
|
|
4396
|
+
var No = "\x1B[49m";
|
|
4397
|
+
function Po(e, t) {
|
|
4381
4398
|
let n = e[t];
|
|
4382
4399
|
if (!n) return b.dim(" ");
|
|
4383
|
-
let r =
|
|
4400
|
+
let r = ko(n);
|
|
4384
4401
|
if (!r) return b.dim(" ");
|
|
4385
|
-
let [i, a, o] =
|
|
4386
|
-
return `\x1b[48;2;${i};${a};${o}m ${
|
|
4402
|
+
let [i, a, o] = Mo(r);
|
|
4403
|
+
return `\x1b[48;2;${i};${a};${o}m ${No}`;
|
|
4387
4404
|
}
|
|
4388
|
-
var
|
|
4405
|
+
var Fo = [
|
|
4389
4406
|
"primary",
|
|
4390
4407
|
"secondary",
|
|
4391
4408
|
"accent"
|
|
4392
4409
|
];
|
|
4393
|
-
function
|
|
4394
|
-
return
|
|
4410
|
+
function Io(e) {
|
|
4411
|
+
return Fo.map((t) => Po(e, t)).join("");
|
|
4395
4412
|
}
|
|
4396
|
-
function
|
|
4397
|
-
return `${
|
|
4413
|
+
function Lo(e) {
|
|
4414
|
+
return `${Io(e.light)} ${b.dim("·")} ${Io(e.dark)}`;
|
|
4398
4415
|
}
|
|
4399
4416
|
//#endregion
|
|
4400
4417
|
//#region src/commands/create.ts
|
|
4401
|
-
async function
|
|
4402
|
-
e.skipBanner ||
|
|
4418
|
+
async function Ro(e) {
|
|
4419
|
+
e.skipBanner || Ca(), s.intro(R.brandBold("Create a new Hype Stack project"));
|
|
4403
4420
|
let o = e.yes === !0, c, l;
|
|
4404
4421
|
if (o && e.name) {
|
|
4405
|
-
let t =
|
|
4406
|
-
t && (s.log.error(t), X()), l = e.name, c =
|
|
4422
|
+
let t = ka(e.name);
|
|
4423
|
+
t && (s.log.error(t), X()), l = e.name, c = Da(e.name);
|
|
4407
4424
|
} else {
|
|
4408
4425
|
let t = await s.text({
|
|
4409
4426
|
message: "What is your project named?",
|
|
4410
4427
|
placeholder: "my-app",
|
|
4411
4428
|
initialValue: e.name ?? "",
|
|
4412
|
-
validate: (e) =>
|
|
4429
|
+
validate: (e) => ka(e ?? "")
|
|
4413
4430
|
});
|
|
4414
|
-
s.isCancel(t) && X(), l = t, c =
|
|
4431
|
+
s.isCancel(t) && X(), l = t, c = Da(l);
|
|
4415
4432
|
}
|
|
4416
4433
|
l.trim() !== c && s.log.info(R.muted(`Using "${R.highlight(c)}" as the project name`));
|
|
4417
4434
|
let u;
|
|
@@ -4428,17 +4445,17 @@ async function Io(e) {
|
|
|
4428
4445
|
});
|
|
4429
4446
|
s.isCancel(e) && X(), t = e;
|
|
4430
4447
|
}
|
|
4431
|
-
u =
|
|
4448
|
+
u = dr(t, c);
|
|
4432
4449
|
}
|
|
4433
4450
|
let d = T.resolve(u);
|
|
4434
4451
|
o || s.note(R.path(d), "Project will be created at");
|
|
4435
|
-
let f = e.editor &&
|
|
4452
|
+
let f = e.editor && ie.includes(e.editor) ? e.editor : null, p;
|
|
4436
4453
|
if (f) p = f;
|
|
4437
4454
|
else if (o) p = "cursor";
|
|
4438
4455
|
else {
|
|
4439
4456
|
let e = await s.select({
|
|
4440
4457
|
message: "Which code editor do you use?",
|
|
4441
|
-
options:
|
|
4458
|
+
options: F.map((e) => ({
|
|
4442
4459
|
value: e.value,
|
|
4443
4460
|
label: e.label,
|
|
4444
4461
|
hint: "hint" in e ? e.hint : void 0
|
|
@@ -4455,17 +4472,17 @@ async function Io(e) {
|
|
|
4455
4472
|
message: "Pick a color theme",
|
|
4456
4473
|
options: r.map((e) => ({
|
|
4457
4474
|
value: e.name,
|
|
4458
|
-
label: `${
|
|
4475
|
+
label: `${Lo(e)} ${e.label}`
|
|
4459
4476
|
})),
|
|
4460
4477
|
initialValue: h
|
|
4461
4478
|
});
|
|
4462
4479
|
s.isCancel(e) && X(), g = e;
|
|
4463
4480
|
}
|
|
4464
4481
|
if (!o) {
|
|
4465
|
-
let e =
|
|
4482
|
+
let e = F.find((e) => e.value === p)?.label ?? p, t = n.find((e) => e.value === g)?.label ?? g, r = await s.confirm({ message: `Create ${R.highlight(c)} in ${R.path(d)} with ${R.highlight(e)} config and the ${R.highlight(t)} theme?` });
|
|
4466
4483
|
(s.isCancel(r) || !r) && X();
|
|
4467
4484
|
}
|
|
4468
|
-
if (await
|
|
4485
|
+
if (await ar(d) && !await or(d)) {
|
|
4469
4486
|
let e = await s.confirm({
|
|
4470
4487
|
message: `Directory ${R.path(d)} is not empty. Continue anyway?`,
|
|
4471
4488
|
initialValue: !1
|
|
@@ -4473,31 +4490,31 @@ async function Io(e) {
|
|
|
4473
4490
|
(s.isCancel(e) || !e) && X();
|
|
4474
4491
|
}
|
|
4475
4492
|
let _ = s.spinner();
|
|
4476
|
-
_.start("Cloning Hype Stack template..."), await
|
|
4493
|
+
_.start("Cloning Hype Stack template..."), await Ba(d), _.stop(R.success("Template cloned"));
|
|
4477
4494
|
let v = s.spinner();
|
|
4478
|
-
v.start("Setting up project..."), await
|
|
4479
|
-
let y = await
|
|
4480
|
-
await
|
|
4495
|
+
v.start("Setting up project..."), await Qa(d), await eo(d, c), await qa(d, p);
|
|
4496
|
+
let y = await vr(d), b = br(c, y);
|
|
4497
|
+
await _r(d, b), await ho(d, {
|
|
4481
4498
|
projectName: c,
|
|
4482
4499
|
editor: p,
|
|
4483
4500
|
workspace: y
|
|
4484
4501
|
});
|
|
4485
4502
|
let x = T.resolve(d, b.paths?.frontend.root ?? "apps/frontend");
|
|
4486
|
-
a(g) && (await
|
|
4503
|
+
a(g) && (await za(x, i(g)) || s.log.warn(R.muted(`Could not find ${R.path("assets/styles.css")} to apply the ${g} theme`))), await Na(x, e.defaultMode === "dark" || e.defaultMode === "light" ? e.defaultMode : "light") || s.log.warn(R.muted(`Could not find ${R.path("src/hooks/use-theme.ts")} to set the default color mode`)), v.stop(R.success("Project configured"));
|
|
4487
4504
|
let S = s.spinner();
|
|
4488
4505
|
S.start("Installing dependencies..."), (await q("pnpm", ["install"], { cwd: d })).exitCode === 0 ? S.stop(R.success("Dependencies installed")) : (S.stop(R.warning("Dependencies installed with warnings")), s.log.warn(R.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4489
4506
|
let C = s.spinner();
|
|
4490
|
-
C.start("Initializing git repository..."), await
|
|
4507
|
+
C.start("Initializing git repository..."), await $a(d), C.stop(R.success("Git repository initialized with clean history"));
|
|
4491
4508
|
let w = s.spinner();
|
|
4492
4509
|
w.start("Creating .env files from examples...");
|
|
4493
|
-
let E = await
|
|
4510
|
+
let E = await Ya(d);
|
|
4494
4511
|
if (E.length > 0) {
|
|
4495
4512
|
let e = E.length;
|
|
4496
4513
|
w.stop(R.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4497
4514
|
} else w.stop(R.muted("No .env.example files to copy"));
|
|
4498
4515
|
s.log.success(`${R.brandBold("Hype Stack")} project ${R.highlight(c)} is ready!`);
|
|
4499
4516
|
let D = T.relative(process.cwd(), d) || ".", O = [`${R.command(`cd ${D}`)}`];
|
|
4500
|
-
E.length > 0 ? O.push(`Review your ${R.path(".env")} files and fill in any secrets`) : O.push(`Copy ${R.path(".env.example")} to ${R.path(".env")} and configure`),
|
|
4517
|
+
E.length > 0 ? O.push(`Review your ${R.path(".env")} files and fill in any secrets`) : O.push(`Copy ${R.path(".env.example")} to ${R.path(".env")} and configure`), qi(O);
|
|
4501
4518
|
let k = e.setup === !1;
|
|
4502
4519
|
if (e.deferSetup) s.log.info(R.muted("Docker and migrations will run after your packs are installed."));
|
|
4503
4520
|
else {
|
|
@@ -4505,20 +4522,20 @@ async function Io(e) {
|
|
|
4505
4522
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
4506
4523
|
initialValue: !0
|
|
4507
4524
|
}));
|
|
4508
|
-
s.isCancel(e) && X(), e ? await
|
|
4525
|
+
s.isCancel(e) && X(), e ? await ia(d, o) : s.log.info(R.muted("Docker and migrations can run later via `npx @hype-stack/cli onboard`.")), Eo();
|
|
4509
4526
|
}
|
|
4510
|
-
return await
|
|
4527
|
+
return await go("project_create"), s.outro(R.muted("Happy building!")), d;
|
|
4511
4528
|
}
|
|
4512
4529
|
//#endregion
|
|
4513
4530
|
//#region src/commands/init.ts
|
|
4514
|
-
async function
|
|
4531
|
+
async function zo(e) {
|
|
4515
4532
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4516
|
-
if (n || (
|
|
4533
|
+
if (n || (wa(), s.intro(R.brandBold("Initialize Hype Stack configuration"))), !await xr(t)) {
|
|
4517
4534
|
s.log.error(`This doesn't look like a Hype Stack project. ${R.muted("Expected apps/ directory and package.json")}`), s.outro(R.muted(`Run ${R.command("npx @hype-stack/cli create")} to scaffold a new project.`));
|
|
4518
4535
|
return;
|
|
4519
4536
|
}
|
|
4520
|
-
if (await
|
|
4521
|
-
let e = await
|
|
4537
|
+
if (await gr(t)) {
|
|
4538
|
+
let e = await hr(t);
|
|
4522
4539
|
if (e && !n) {
|
|
4523
4540
|
s.log.info(`Found existing ${R.path("stack.json")} for project ${R.highlight(e.name)}`);
|
|
4524
4541
|
let t = await s.confirm({
|
|
@@ -4531,7 +4548,7 @@ async function Lo(e) {
|
|
|
4531
4548
|
}
|
|
4532
4549
|
}
|
|
4533
4550
|
}
|
|
4534
|
-
let r = await
|
|
4551
|
+
let r = await vr(t);
|
|
4535
4552
|
if (!n) {
|
|
4536
4553
|
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4537
4554
|
if (e.length > 0) {
|
|
@@ -4544,34 +4561,34 @@ async function Lo(e) {
|
|
|
4544
4561
|
}
|
|
4545
4562
|
e.length === 0 && t.length === 0 && s.log.warn("No apps or packages detected in the workspace.");
|
|
4546
4563
|
}
|
|
4547
|
-
let i = (await
|
|
4564
|
+
let i = (await sr(T.join(t, "package.json")))?.name?.replace(/^@/, "").replace(/\/source$/, "") ?? "my-app", a = i;
|
|
4548
4565
|
if (!n) {
|
|
4549
4566
|
let e = await s.text({
|
|
4550
4567
|
message: "Project name for stack.json?",
|
|
4551
4568
|
placeholder: i,
|
|
4552
4569
|
initialValue: i,
|
|
4553
|
-
validate: (e) =>
|
|
4570
|
+
validate: (e) => ka(e ?? "")
|
|
4554
4571
|
});
|
|
4555
|
-
s.isCancel(e) && X(), a =
|
|
4572
|
+
s.isCancel(e) && X(), a = Da(e);
|
|
4556
4573
|
}
|
|
4557
|
-
await
|
|
4574
|
+
await _r(t, br(a, r)), n || (s.log.success(`${R.path("stack.json")} written successfully`), s.outro(R.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
|
|
4558
4575
|
}
|
|
4559
|
-
async function
|
|
4560
|
-
if (await
|
|
4576
|
+
async function Bo(e, t = {}, n) {
|
|
4577
|
+
if (await gr(e)) return {
|
|
4561
4578
|
projectRoot: e,
|
|
4562
4579
|
scaffolded: !1
|
|
4563
4580
|
};
|
|
4564
|
-
let r = t.runInit ?? ((e) =>
|
|
4581
|
+
let r = t.runInit ?? ((e) => zo({
|
|
4565
4582
|
cwd: e,
|
|
4566
4583
|
silent: !0
|
|
4567
|
-
})), i = t.runCreate ?? ((e, t) =>
|
|
4584
|
+
})), i = t.runCreate ?? ((e, t) => Ro({
|
|
4568
4585
|
parentDirectory: e,
|
|
4569
4586
|
deferSetup: !0,
|
|
4570
4587
|
skipBanner: !0,
|
|
4571
4588
|
defaultTheme: t?.defaultTheme,
|
|
4572
4589
|
defaultMode: t?.defaultMode
|
|
4573
4590
|
}));
|
|
4574
|
-
if (await
|
|
4591
|
+
if (await xr(e)) {
|
|
4575
4592
|
s.log.warn(`No ${R.path("stack.json")} found in ${R.path(e)}.`);
|
|
4576
4593
|
let t = await s.confirm({
|
|
4577
4594
|
message: `Create ${R.path("stack.json")} now?`,
|
|
@@ -4579,7 +4596,7 @@ async function Ro(e, t = {}, n) {
|
|
|
4579
4596
|
});
|
|
4580
4597
|
if (s.isCancel(t) || !t) return null;
|
|
4581
4598
|
await r(e);
|
|
4582
|
-
let n = await
|
|
4599
|
+
let n = await gr(e);
|
|
4583
4600
|
return n && s.log.success(`${R.path("stack.json")} created`), n ? {
|
|
4584
4601
|
projectRoot: e,
|
|
4585
4602
|
scaffolded: !1
|
|
@@ -4597,19 +4614,19 @@ async function Ro(e, t = {}, n) {
|
|
|
4597
4614
|
});
|
|
4598
4615
|
if (s.isCancel(o) || !o) return null;
|
|
4599
4616
|
let c = await i(e, n);
|
|
4600
|
-
return await
|
|
4617
|
+
return await gr(c) ? {
|
|
4601
4618
|
projectRoot: c,
|
|
4602
4619
|
scaffolded: !0
|
|
4603
4620
|
} : null;
|
|
4604
4621
|
}
|
|
4605
4622
|
//#endregion
|
|
4606
4623
|
//#region src/commands/compose.ts
|
|
4607
|
-
async function
|
|
4624
|
+
async function Vo(e = {}) {
|
|
4608
4625
|
let t = e.cwd ?? process.cwd();
|
|
4609
|
-
|
|
4610
|
-
let n = await
|
|
4626
|
+
Ca();
|
|
4627
|
+
let n = await Bo(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4611
4628
|
try {
|
|
4612
|
-
a = await
|
|
4629
|
+
a = await hr(r ?? t);
|
|
4613
4630
|
} catch (e) {
|
|
4614
4631
|
s.cancel(`Could not parse ${R.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4615
4632
|
}
|
|
@@ -4620,18 +4637,18 @@ async function zo(e = {}) {
|
|
|
4620
4637
|
c.start("Loading packs...");
|
|
4621
4638
|
let l;
|
|
4622
4639
|
try {
|
|
4623
|
-
l = await
|
|
4640
|
+
l = await Dr();
|
|
4624
4641
|
} catch (e) {
|
|
4625
4642
|
c.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${Q(e)}`), process.exit(1);
|
|
4626
4643
|
}
|
|
4627
4644
|
c.stop("Packs loaded");
|
|
4628
|
-
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(
|
|
4645
|
+
let u = a.installedPacks ?? [], d = new Set(u), f = new Map(l.map((e) => [e.name, e])), p = e.licenseKey ?? a.licenseKey ?? null, m = (await Kn(I()))?.token ?? null, h = await bo(l, d, {
|
|
4629
4646
|
token: m,
|
|
4630
4647
|
key: p
|
|
4631
4648
|
}), g = (e) => {
|
|
4632
4649
|
let t = f.get(e);
|
|
4633
4650
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4634
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await
|
|
4651
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", v = await Ho({
|
|
4635
4652
|
packs: l,
|
|
4636
4653
|
installedSet: d,
|
|
4637
4654
|
stateOf: g,
|
|
@@ -4642,9 +4659,9 @@ async function zo(e = {}) {
|
|
|
4642
4659
|
s.outro(R.muted("No packs selected. Nothing to do."));
|
|
4643
4660
|
return;
|
|
4644
4661
|
}
|
|
4645
|
-
let b =
|
|
4662
|
+
let b = Go(v), x = Ko(v), S = pa(l, b), C = oa(ma(l, S)), w;
|
|
4646
4663
|
try {
|
|
4647
|
-
w =
|
|
4664
|
+
w = ca(b, C, u);
|
|
4648
4665
|
} catch (e) {
|
|
4649
4666
|
s.cancel(Q(e)), process.exit(1);
|
|
4650
4667
|
}
|
|
@@ -4652,7 +4669,7 @@ async function zo(e = {}) {
|
|
|
4652
4669
|
s.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), s.outro(R.muted("Your selection is already part of the project."));
|
|
4653
4670
|
return;
|
|
4654
4671
|
}
|
|
4655
|
-
let T =
|
|
4672
|
+
let T = la({
|
|
4656
4673
|
order: w.order,
|
|
4657
4674
|
graph: C,
|
|
4658
4675
|
isLocked: _,
|
|
@@ -4660,28 +4677,28 @@ async function zo(e = {}) {
|
|
|
4660
4677
|
});
|
|
4661
4678
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4662
4679
|
let e = await nr();
|
|
4663
|
-
e && (m = e, h = await
|
|
4680
|
+
e && (m = e, h = await bo(l, d, {
|
|
4664
4681
|
token: m,
|
|
4665
4682
|
key: p
|
|
4666
|
-
}), T =
|
|
4683
|
+
}), T = la({
|
|
4667
4684
|
order: w.order,
|
|
4668
4685
|
graph: C,
|
|
4669
4686
|
isLocked: _,
|
|
4670
4687
|
installed: u
|
|
4671
4688
|
}));
|
|
4672
4689
|
}
|
|
4673
|
-
if (T.blocked.length > 0 && await
|
|
4690
|
+
if (T.blocked.length > 0 && await So(T.blocked, _, f), T.installable.length === 0) {
|
|
4674
4691
|
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
4675
4692
|
return;
|
|
4676
4693
|
}
|
|
4677
|
-
if (
|
|
4694
|
+
if (Co(T.installable, f), !e.yes) {
|
|
4678
4695
|
let e = await s.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4679
4696
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
4680
4697
|
}
|
|
4681
4698
|
c.start("Downloading packs...");
|
|
4682
4699
|
let E;
|
|
4683
4700
|
try {
|
|
4684
|
-
E = await
|
|
4701
|
+
E = await wo(T.installable, {
|
|
4685
4702
|
token: m,
|
|
4686
4703
|
key: p
|
|
4687
4704
|
});
|
|
@@ -4689,7 +4706,7 @@ async function zo(e = {}) {
|
|
|
4689
4706
|
c.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
|
|
4690
4707
|
}
|
|
4691
4708
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4692
|
-
let D = await
|
|
4709
|
+
let D = await Oo({
|
|
4693
4710
|
prepared: E,
|
|
4694
4711
|
config: a,
|
|
4695
4712
|
cwd: o,
|
|
@@ -4699,7 +4716,7 @@ async function zo(e = {}) {
|
|
|
4699
4716
|
});
|
|
4700
4717
|
try {
|
|
4701
4718
|
c.start("Installing pack files...");
|
|
4702
|
-
let t = await
|
|
4719
|
+
let t = await Ri({
|
|
4703
4720
|
packs: E,
|
|
4704
4721
|
config: a,
|
|
4705
4722
|
projectRoot: o,
|
|
@@ -4712,18 +4729,21 @@ async function zo(e = {}) {
|
|
|
4712
4729
|
for (let e of t.errors) s.log.error(e);
|
|
4713
4730
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4714
4731
|
}
|
|
4715
|
-
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${R.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (s.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`),
|
|
4732
|
+
c.stop("Files installed"), t.installed.length > 0 && s.log.success(`${R.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (s.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`), Do(t.skipped));
|
|
4716
4733
|
for (let e of t.errors) s.log.error(e);
|
|
4717
|
-
await
|
|
4734
|
+
await To({
|
|
4718
4735
|
prepared: E,
|
|
4719
4736
|
paths: a.paths,
|
|
4720
4737
|
cwd: o,
|
|
4721
4738
|
spinner: c
|
|
4722
|
-
})
|
|
4739
|
+
});
|
|
4740
|
+
let n;
|
|
4741
|
+
i && (n = await aa(o, e.yes ?? !1)), await pr({
|
|
4723
4742
|
projectRoot: o,
|
|
4724
4743
|
paths: a.paths,
|
|
4725
|
-
skipPrompts: e.yes ?? !1
|
|
4726
|
-
|
|
4744
|
+
skipPrompts: e.yes ?? !1,
|
|
4745
|
+
dbReady: n
|
|
4746
|
+
}), Eo(), s.outro(R.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4727
4747
|
} finally {
|
|
4728
4748
|
await Promise.all(E.map((e) => y.rm(e.packDir, {
|
|
4729
4749
|
recursive: !0,
|
|
@@ -4731,25 +4751,25 @@ async function zo(e = {}) {
|
|
|
4731
4751
|
})));
|
|
4732
4752
|
}
|
|
4733
4753
|
}
|
|
4734
|
-
async function
|
|
4754
|
+
async function Ho(e) {
|
|
4735
4755
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4736
4756
|
if (i.packs && i.packs.length > 0) {
|
|
4737
|
-
let e = i.packs.map(
|
|
4757
|
+
let e = i.packs.map(Wo), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4738
4758
|
return n.length > 0 && (s.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4739
4759
|
}
|
|
4740
4760
|
let o = t.filter((e) => n.has(e.name));
|
|
4741
4761
|
o.length > 0 && s.note(o.map((e) => ` ${R.muted("✓")} ${e.displayName}`).join("\n"), "Already Installed");
|
|
4742
4762
|
let c = t.filter((e) => !n.has(e.name));
|
|
4743
4763
|
if (c.length === 0) return s.outro(R.muted("Every available pack is already installed.")), [];
|
|
4744
|
-
let l =
|
|
4764
|
+
let l = ce();
|
|
4745
4765
|
s.note(c.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4746
|
-
let u =
|
|
4766
|
+
let u = Gi(c, { adminAvailable: a }), d = [];
|
|
4747
4767
|
for (let e of u) {
|
|
4748
4768
|
let t = e.packs.map((e) => {
|
|
4749
4769
|
let t = r(e.name);
|
|
4750
4770
|
return {
|
|
4751
4771
|
value: e.name,
|
|
4752
|
-
label: `${e.displayName} ${
|
|
4772
|
+
label: `${e.displayName} ${xo(t, e.price)}`,
|
|
4753
4773
|
hint: e.description
|
|
4754
4774
|
};
|
|
4755
4775
|
});
|
|
@@ -4766,7 +4786,7 @@ async function Bo(e) {
|
|
|
4766
4786
|
});
|
|
4767
4787
|
continue;
|
|
4768
4788
|
}
|
|
4769
|
-
let n = await
|
|
4789
|
+
let n = await Ea({
|
|
4770
4790
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4771
4791
|
options: t,
|
|
4772
4792
|
required: !1
|
|
@@ -4776,20 +4796,20 @@ async function Bo(e) {
|
|
|
4776
4796
|
}
|
|
4777
4797
|
return d;
|
|
4778
4798
|
}
|
|
4779
|
-
var
|
|
4780
|
-
function
|
|
4781
|
-
let t = e.match(
|
|
4799
|
+
var Uo = /@(frontend|admin)$/;
|
|
4800
|
+
function Wo(e) {
|
|
4801
|
+
let t = e.match(Uo);
|
|
4782
4802
|
return t ? {
|
|
4783
4803
|
name: e.slice(0, -t[0].length),
|
|
4784
4804
|
slot: t[1]
|
|
4785
4805
|
} : { name: e };
|
|
4786
4806
|
}
|
|
4787
|
-
function
|
|
4807
|
+
function Go(e) {
|
|
4788
4808
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4789
4809
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4790
4810
|
return n;
|
|
4791
4811
|
}
|
|
4792
|
-
function
|
|
4812
|
+
function Ko(e) {
|
|
4793
4813
|
let t = /* @__PURE__ */ new Map();
|
|
4794
4814
|
for (let n of e) {
|
|
4795
4815
|
if (!n.slot) continue;
|
|
@@ -4800,8 +4820,8 @@ function Wo(e) {
|
|
|
4800
4820
|
}
|
|
4801
4821
|
//#endregion
|
|
4802
4822
|
//#region src/commands/login.ts
|
|
4803
|
-
async function
|
|
4804
|
-
|
|
4823
|
+
async function qo() {
|
|
4824
|
+
wa(), s.intro(R.brandBold("Log in to Hype Stack")), s.log.step("Opening your browser to sign in...");
|
|
4805
4825
|
let e;
|
|
4806
4826
|
try {
|
|
4807
4827
|
e = await tr({ onUrl: (e) => {
|
|
@@ -4814,9 +4834,9 @@ async function Go() {
|
|
|
4814
4834
|
}
|
|
4815
4835
|
//#endregion
|
|
4816
4836
|
//#region src/commands/logout.ts
|
|
4817
|
-
async function
|
|
4818
|
-
|
|
4819
|
-
let e =
|
|
4837
|
+
async function Jo() {
|
|
4838
|
+
wa(), s.intro(R.brandBold("Log out of Hype Stack"));
|
|
4839
|
+
let e = I(), t = await Kn(e);
|
|
4820
4840
|
if (!t) {
|
|
4821
4841
|
s.outro(R.muted("You're not logged in."));
|
|
4822
4842
|
return;
|
|
@@ -4835,15 +4855,15 @@ var $ = {
|
|
|
4835
4855
|
Resend: "resend",
|
|
4836
4856
|
IpLocate: "iplocate",
|
|
4837
4857
|
Sentry: "sentry"
|
|
4838
|
-
},
|
|
4839
|
-
function
|
|
4858
|
+
}, Yo = new Set(Object.values($));
|
|
4859
|
+
function Xo(e) {
|
|
4840
4860
|
return e.toLowerCase().replace(/[^a-z0-9]+/g, "").trim();
|
|
4841
4861
|
}
|
|
4842
|
-
function
|
|
4843
|
-
let t =
|
|
4844
|
-
return
|
|
4862
|
+
function Zo(e) {
|
|
4863
|
+
let t = Xo(e);
|
|
4864
|
+
return Yo.has(t) ? t : void 0;
|
|
4845
4865
|
}
|
|
4846
|
-
var
|
|
4866
|
+
var Qo = {
|
|
4847
4867
|
[$.Config]: { hint: "App URLs. Defaults work for local dev." },
|
|
4848
4868
|
[$.Databases]: { hint: "Credentials for the local Docker Postgres and Valkey containers." },
|
|
4849
4869
|
[$.Workos]: {
|
|
@@ -4881,28 +4901,28 @@ var Xo = {
|
|
|
4881
4901
|
link: "https://sentry.io",
|
|
4882
4902
|
hint: "Your project DSN. Leave blank to skip Sentry for now."
|
|
4883
4903
|
}
|
|
4884
|
-
},
|
|
4885
|
-
function
|
|
4886
|
-
let t =
|
|
4887
|
-
return t ?
|
|
4904
|
+
}, $o = { hint: "Add your value, or press Enter to leave it blank." };
|
|
4905
|
+
function es(e) {
|
|
4906
|
+
let t = Zo(e);
|
|
4907
|
+
return t ? Qo[t] : $o;
|
|
4888
4908
|
}
|
|
4889
|
-
var
|
|
4909
|
+
var ts = {
|
|
4890
4910
|
"starter-saas-workos": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4891
4911
|
"starter-saas-betterauth": ["Your WebSocket upgrades can be authenticated with `authenticateWsUpgrade` from `@backend/middleware/auth/ws-auth` via `sockets.routes(authenticateWsUpgrade)`."],
|
|
4892
4912
|
"pack-notifications": ["Notifications push over the `appChannel` socket channel; register it in your server startup to go live."],
|
|
4893
4913
|
"pack-collaboration": ["Team and TeamMember are available as CASL subjects; project member and team management reuse the existing `Project` subject."]
|
|
4894
4914
|
};
|
|
4895
|
-
function
|
|
4915
|
+
function ns(e) {
|
|
4896
4916
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4897
4917
|
for (let r of e) {
|
|
4898
|
-
let e =
|
|
4918
|
+
let e = ts[r];
|
|
4899
4919
|
if (e) for (let r of e) t.has(r) || (t.add(r), n.push(r));
|
|
4900
4920
|
}
|
|
4901
4921
|
return n;
|
|
4902
4922
|
}
|
|
4903
4923
|
//#endregion
|
|
4904
4924
|
//#region src/core/onboard-env.ts
|
|
4905
|
-
function
|
|
4925
|
+
function rs(e) {
|
|
4906
4926
|
let t = [], n = "";
|
|
4907
4927
|
for (let r of e.split(/\r?\n/)) {
|
|
4908
4928
|
let e = r.trim();
|
|
@@ -4928,19 +4948,19 @@ function ts(e) {
|
|
|
4928
4948
|
}
|
|
4929
4949
|
return t;
|
|
4930
4950
|
}
|
|
4931
|
-
var
|
|
4951
|
+
var is = [
|
|
4932
4952
|
"replace-with",
|
|
4933
4953
|
"examplepublickey",
|
|
4934
4954
|
"change-me",
|
|
4935
4955
|
"your-key-here"
|
|
4936
4956
|
];
|
|
4937
|
-
function
|
|
4957
|
+
function as(e) {
|
|
4938
4958
|
let t = e.trim();
|
|
4939
4959
|
if (t === "") return !0;
|
|
4940
4960
|
let n = t.toLowerCase();
|
|
4941
|
-
return
|
|
4961
|
+
return is.some((e) => n.includes(e));
|
|
4942
4962
|
}
|
|
4943
|
-
function
|
|
4963
|
+
function os(e, t, n) {
|
|
4944
4964
|
let r = e.split(/\r?\n/), i = !1, a = r.map((e) => {
|
|
4945
4965
|
if (i) return e;
|
|
4946
4966
|
let r = e.trim();
|
|
@@ -4950,49 +4970,49 @@ function is(e, t, n) {
|
|
|
4950
4970
|
});
|
|
4951
4971
|
return i ? a.join("\n") : e + `${e.length > 0 && !e.endsWith("\n") ? "\n" : ""}${t}=${n}\n`;
|
|
4952
4972
|
}
|
|
4953
|
-
async function
|
|
4973
|
+
async function ss(e) {
|
|
4954
4974
|
return await J(e) ? y.readFile(e, "utf-8") : "";
|
|
4955
4975
|
}
|
|
4956
|
-
async function
|
|
4976
|
+
async function cs(e) {
|
|
4957
4977
|
let t = T.join(T.dirname(e), ".env");
|
|
4958
4978
|
return await J(t) || await y.copyFile(e, t), t;
|
|
4959
4979
|
}
|
|
4960
|
-
async function
|
|
4961
|
-
let r =
|
|
4980
|
+
async function ls(e, t, n) {
|
|
4981
|
+
let r = os(await ss(e), t, n);
|
|
4962
4982
|
await y.writeFile(e, r, "utf-8");
|
|
4963
4983
|
}
|
|
4964
4984
|
//#endregion
|
|
4965
4985
|
//#region src/commands/onboard.ts
|
|
4966
|
-
async function
|
|
4986
|
+
async function us(e = {}) {
|
|
4967
4987
|
let t = e.cwd ?? process.cwd();
|
|
4968
|
-
|
|
4988
|
+
Ca(), s.intro(R.brandBold("Onboard your stack"));
|
|
4969
4989
|
let n;
|
|
4970
4990
|
try {
|
|
4971
|
-
n = await
|
|
4991
|
+
n = await hr(t);
|
|
4972
4992
|
} catch {
|
|
4973
4993
|
n = null;
|
|
4974
4994
|
}
|
|
4975
4995
|
n || (s.cancel(`${R.path("stack.json")} not found. Run ${R.command("npx @hype-stack/cli init")} first.`), process.exit(1));
|
|
4976
|
-
let r = await
|
|
4996
|
+
let r = await Xa(t);
|
|
4977
4997
|
r.length === 0 && s.log.warn(R.muted("No .env.example files found; skipping env setup."));
|
|
4978
|
-
for (let n of r) await
|
|
4979
|
-
let i =
|
|
4980
|
-
i.length > 0 && s.note(i.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await
|
|
4998
|
+
for (let n of r) await ds(n, t, e.yes ?? !1);
|
|
4999
|
+
let i = ns(n.installedPacks ?? []);
|
|
5000
|
+
i.length > 0 && s.note(i.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Tips"), e.skipMigrations || await ms(t, e.yes ?? !1), s.outro(R.brand(`All set. Run ${R.command("pnpm dev")} to start your app.`));
|
|
4981
5001
|
}
|
|
4982
|
-
async function
|
|
4983
|
-
let r = T.relative(t, e) || e, i = await
|
|
5002
|
+
async function ds(e, t, n) {
|
|
5003
|
+
let r = T.relative(t, e) || e, i = await cs(e), a = await ss(i), o = rs(await y.readFile(e, "utf-8")), c = R.path(r);
|
|
4984
5004
|
s.log.step(`Env: ${c}`);
|
|
4985
5005
|
for (let e of o) {
|
|
4986
|
-
let t = e.vars.filter((e) =>
|
|
5006
|
+
let t = e.vars.filter((e) => as(e.value));
|
|
4987
5007
|
if (t.length === 0) continue;
|
|
4988
|
-
let r =
|
|
5008
|
+
let r = es(e.section), o = e.section ? R.bold(e.section) : R.bold("Variables");
|
|
4989
5009
|
s.log.step(o), r.link && (s.log.info(`${R.muted("Get your values:")} ${_e(r.link)}`), r.serviceChecklist && r.serviceChecklist.length > 0 && s.note(r.serviceChecklist.map((e) => ` ${R.muted("·")} ${e}`).join("\n"), "Setup")), s.log.info(R.muted(r.hint));
|
|
4990
5010
|
for (let e of t) {
|
|
4991
5011
|
if (n) {
|
|
4992
5012
|
s.log.info(`${R.label(e.key)} ${R.muted("skipped (non-interactive)")}`);
|
|
4993
5013
|
continue;
|
|
4994
5014
|
}
|
|
4995
|
-
let t =
|
|
5015
|
+
let t = fs(a, e.key), o = await s.text({
|
|
4996
5016
|
message: `${R.label(e.key)}`,
|
|
4997
5017
|
placeholder: t || r.hint
|
|
4998
5018
|
});
|
|
@@ -5002,31 +5022,31 @@ async function ls(e, t, n) {
|
|
|
5002
5022
|
s.log.warn(R.muted(`${e.key} left blank.`));
|
|
5003
5023
|
continue;
|
|
5004
5024
|
}
|
|
5005
|
-
await
|
|
5025
|
+
await ls(i, e.key, c), s.log.success(`${e.key} saved`);
|
|
5006
5026
|
}
|
|
5007
5027
|
}
|
|
5008
5028
|
}
|
|
5009
|
-
function
|
|
5029
|
+
function fs(e, t) {
|
|
5010
5030
|
for (let n of e.split(/\r?\n/)) {
|
|
5011
|
-
let e = n.match(RegExp(`^${
|
|
5031
|
+
let e = n.match(RegExp(`^${ps(t)}\\s*=\\s*(.*)$`));
|
|
5012
5032
|
if (e) return e[1].trim();
|
|
5013
5033
|
}
|
|
5014
5034
|
return "";
|
|
5015
5035
|
}
|
|
5016
|
-
function
|
|
5036
|
+
function ps(e) {
|
|
5017
5037
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5018
5038
|
}
|
|
5019
|
-
async function
|
|
5020
|
-
if (!await
|
|
5039
|
+
async function ms(e, t) {
|
|
5040
|
+
if (!await Ji() && !await Xi(e, t, !1)) {
|
|
5021
5041
|
s.log.info(R.muted(`Start services later with ${R.command("docker compose up -d")} (in apps/backend), then ${R.command("pnpm --filter @internal/backend migration:latest")}.`));
|
|
5022
5042
|
return;
|
|
5023
5043
|
}
|
|
5024
5044
|
let n = s.spinner();
|
|
5025
|
-
if (n.start("Waiting for Postgres to be ready..."), !await
|
|
5045
|
+
if (n.start("Waiting for Postgres to be ready..."), !await Qi(e)) {
|
|
5026
5046
|
n.error("Postgres health check timed out"), s.log.warn(R.muted(`Run migrations manually once Postgres is ready: ${R.command("pnpm --filter @internal/backend migration:latest")}`));
|
|
5027
5047
|
return;
|
|
5028
5048
|
}
|
|
5029
|
-
if (n.stop(R.success("Postgres is ready")), await
|
|
5049
|
+
if (n.stop(R.success("Postgres is ready")), await ea(e)) {
|
|
5030
5050
|
s.log.info(R.muted("Migrations already applied, skipping."));
|
|
5031
5051
|
return;
|
|
5032
5052
|
}
|
|
@@ -5038,20 +5058,20 @@ async function fs(e, t) {
|
|
|
5038
5058
|
s.log.info(R.muted("Skipping database migrations."));
|
|
5039
5059
|
return;
|
|
5040
5060
|
}
|
|
5041
|
-
await
|
|
5061
|
+
await ta(e);
|
|
5042
5062
|
}
|
|
5043
5063
|
//#endregion
|
|
5044
5064
|
//#region src/core/templates.ts
|
|
5045
|
-
var
|
|
5065
|
+
var hs = K.createRequest()({
|
|
5046
5066
|
endpoint: "/templates/list",
|
|
5047
5067
|
method: "GET"
|
|
5048
5068
|
});
|
|
5049
|
-
async function
|
|
5050
|
-
let { data: e, error: t } = await
|
|
5069
|
+
async function gs() {
|
|
5070
|
+
let { data: e, error: t } = await hs.send();
|
|
5051
5071
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
5052
5072
|
return e.templates;
|
|
5053
5073
|
}
|
|
5054
|
-
async function
|
|
5074
|
+
async function _s(e) {
|
|
5055
5075
|
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
5056
5076
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
5057
5077
|
method: "GET"
|
|
@@ -5060,7 +5080,7 @@ async function hs(e) {
|
|
|
5060
5080
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
5061
5081
|
return t;
|
|
5062
5082
|
}
|
|
5063
|
-
async function
|
|
5083
|
+
async function vs(e, t = {}) {
|
|
5064
5084
|
let n = K.createRequest()({
|
|
5065
5085
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
5066
5086
|
method: "POST"
|
|
@@ -5088,28 +5108,28 @@ async function gs(e, t = {}) {
|
|
|
5088
5108
|
}
|
|
5089
5109
|
//#endregion
|
|
5090
5110
|
//#region src/commands/template.ts
|
|
5091
|
-
async function
|
|
5111
|
+
async function ys(t = {}) {
|
|
5092
5112
|
let n = t.cwd ?? process.cwd();
|
|
5093
|
-
|
|
5113
|
+
Ca();
|
|
5094
5114
|
let r = s.spinner();
|
|
5095
5115
|
r.start("Loading packs...");
|
|
5096
5116
|
let o;
|
|
5097
5117
|
try {
|
|
5098
|
-
o = await
|
|
5118
|
+
o = await Dr();
|
|
5099
5119
|
} catch (e) {
|
|
5100
5120
|
r.stop("Failed to load packs"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${Q(e)}`), process.exit(1);
|
|
5101
5121
|
}
|
|
5102
5122
|
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
5103
5123
|
let c;
|
|
5104
5124
|
try {
|
|
5105
|
-
c = await
|
|
5125
|
+
c = await gs();
|
|
5106
5126
|
} catch (e) {
|
|
5107
5127
|
r.stop("Failed to load templates"), s.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${Q(e)}`), process.exit(1);
|
|
5108
5128
|
}
|
|
5109
5129
|
let l = t.templateId;
|
|
5110
5130
|
if (!l) {
|
|
5111
5131
|
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");
|
|
5112
|
-
let e =
|
|
5132
|
+
let e = ce();
|
|
5113
5133
|
s.note(c.map((t) => ` ${z.arrow} ${R.highlight(t.name)} ${_e(`${e}/templates/${t.id}`)}`).join("\n"), "Browse templates");
|
|
5114
5134
|
let n = await s.select({
|
|
5115
5135
|
message: "Choose a template",
|
|
@@ -5125,147 +5145,150 @@ async function _s(t = {}) {
|
|
|
5125
5145
|
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}`);
|
|
5126
5146
|
let d;
|
|
5127
5147
|
try {
|
|
5128
|
-
d = await
|
|
5148
|
+
d = await _s(u.id);
|
|
5129
5149
|
} catch (e) {
|
|
5130
5150
|
s.cancel(Q(e)), process.exit(1);
|
|
5131
5151
|
}
|
|
5132
|
-
let f = await
|
|
5152
|
+
let f = await Bo(n, {}, {
|
|
5133
5153
|
defaultTheme: d.theme,
|
|
5134
5154
|
defaultMode: d.defaultMode
|
|
5135
5155
|
}), p = f?.projectRoot ?? null, m = f?.scaffolded ?? !1, h;
|
|
5136
5156
|
try {
|
|
5137
|
-
h = await
|
|
5157
|
+
h = await hr(p ?? n);
|
|
5138
5158
|
} catch (e) {
|
|
5139
5159
|
s.cancel(`Could not parse ${R.path("stack.json")}: ${Q(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
5140
5160
|
}
|
|
5141
5161
|
h || (s.cancel(p ? `Could not read ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${R.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), process.exit(1)), h.paths || (s.cancel(`${R.path("stack.json")} is missing ${R.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`), process.exit(1));
|
|
5142
5162
|
let g = p ?? n;
|
|
5143
5163
|
s.intro(R.brandBold("Install a template"));
|
|
5144
|
-
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await Kn(
|
|
5164
|
+
let _ = h.installedPacks ?? [], v = new Set(_), b = new Map(o.map((e) => [e.name, e])), x = t.licenseKey ?? h.licenseKey ?? null, S = (await Kn(I()))?.token ?? null, C = await bs(u, t.variants, t.yes ?? !1), w = ua(u.slots, C), E = da(u.slots, u.packs, w), D = await xs({
|
|
5145
5165
|
packs: o,
|
|
5146
5166
|
templatePacks: E,
|
|
5147
5167
|
installedSet: v,
|
|
5148
5168
|
options: t
|
|
5149
5169
|
}), O = [...E, ...D.filter((e) => !E.includes(e))], k = O.filter((e) => !b.has(e));
|
|
5150
5170
|
k.length > 0 && (s.cancel(`Unknown pack${k.length === 1 ? "" : "s"}: ${k.join(", ")}`), process.exit(1));
|
|
5151
|
-
let ee =
|
|
5171
|
+
let ee = ma(o, w), A = oa(ee), j;
|
|
5152
5172
|
try {
|
|
5153
|
-
|
|
5173
|
+
j = ca(O, A, _);
|
|
5154
5174
|
} catch (e) {
|
|
5155
5175
|
s.cancel(Q(e)), process.exit(1);
|
|
5156
5176
|
}
|
|
5157
|
-
if (
|
|
5177
|
+
if (j.order.length === 0) {
|
|
5158
5178
|
s.outro(R.muted("Every pack in this template is already installed."));
|
|
5159
5179
|
return;
|
|
5160
5180
|
}
|
|
5161
|
-
let
|
|
5181
|
+
let te = await bo(ee, v, {
|
|
5162
5182
|
token: S,
|
|
5163
5183
|
key: x
|
|
5164
|
-
}),
|
|
5184
|
+
}), ne = (e) => {
|
|
5165
5185
|
let t = b.get(e);
|
|
5166
|
-
return !t || t.tier === "free" ? "free" :
|
|
5167
|
-
},
|
|
5168
|
-
order:
|
|
5186
|
+
return !t || t.tier === "free" ? "free" : te[e]?.owned ? "owned" : "locked";
|
|
5187
|
+
}, M = (e) => !v.has(e) && ne(e) === "locked", N = la({
|
|
5188
|
+
order: j.order,
|
|
5169
5189
|
graph: A,
|
|
5170
|
-
isLocked:
|
|
5190
|
+
isLocked: M,
|
|
5171
5191
|
installed: _
|
|
5172
5192
|
});
|
|
5173
|
-
if (
|
|
5193
|
+
if (N.blocked.length > 0 && !S && !x) {
|
|
5174
5194
|
let e = await nr();
|
|
5175
|
-
e && (S = e,
|
|
5195
|
+
e && (S = e, te = await bo(ee, v, {
|
|
5176
5196
|
token: S,
|
|
5177
5197
|
key: x
|
|
5178
|
-
}),
|
|
5179
|
-
order:
|
|
5198
|
+
}), N = la({
|
|
5199
|
+
order: j.order,
|
|
5180
5200
|
graph: A,
|
|
5181
|
-
isLocked:
|
|
5201
|
+
isLocked: M,
|
|
5182
5202
|
installed: _
|
|
5183
5203
|
}));
|
|
5184
5204
|
}
|
|
5185
|
-
if (
|
|
5205
|
+
if (N.blocked.length > 0 && await So(N.blocked, M, b), N.installable.length === 0) {
|
|
5186
5206
|
s.outro(R.muted("Nothing left to install once locked packs are removed."));
|
|
5187
5207
|
return;
|
|
5188
5208
|
}
|
|
5189
|
-
if (
|
|
5190
|
-
let e = await s.confirm({ message: `Install template ${R.brandBold(u.name)} (${
|
|
5209
|
+
if (Co(N.installable, b), !t.yes) {
|
|
5210
|
+
let e = await s.confirm({ message: `Install template ${R.brandBold(u.name)} (${N.installable.length} pack${N.installable.length === 1 ? "" : "s"})?` });
|
|
5191
5211
|
(s.isCancel(e) || !e) && (s.cancel("Installation cancelled."), process.exit(0));
|
|
5192
5212
|
}
|
|
5193
5213
|
r.start("Downloading packs...");
|
|
5194
|
-
let
|
|
5214
|
+
let P;
|
|
5195
5215
|
try {
|
|
5196
|
-
|
|
5216
|
+
P = await wo(N.installable, {
|
|
5197
5217
|
token: S,
|
|
5198
5218
|
key: x
|
|
5199
5219
|
});
|
|
5200
5220
|
} catch (e) {
|
|
5201
5221
|
r.stop("Download failed"), s.cancel(Q(e)), process.exit(1);
|
|
5202
5222
|
}
|
|
5203
|
-
r.stop(`Downloaded ${
|
|
5204
|
-
let
|
|
5205
|
-
prepared:
|
|
5223
|
+
r.stop(`Downloaded ${P.length} pack${P.length === 1 ? "" : "s"}`);
|
|
5224
|
+
let re = await Oo({
|
|
5225
|
+
prepared: P,
|
|
5206
5226
|
config: h,
|
|
5207
5227
|
cwd: g,
|
|
5208
5228
|
force: t.force ?? !1,
|
|
5209
5229
|
yes: t.yes ?? !1
|
|
5210
|
-
}),
|
|
5230
|
+
}), F = null;
|
|
5211
5231
|
try {
|
|
5212
5232
|
r.start("Installing pack files...");
|
|
5213
|
-
let n = await
|
|
5214
|
-
packs:
|
|
5233
|
+
let n = await Ri({
|
|
5234
|
+
packs: P,
|
|
5215
5235
|
config: h,
|
|
5216
5236
|
projectRoot: g,
|
|
5217
5237
|
force: t.force ?? !1,
|
|
5218
|
-
overwrite:
|
|
5238
|
+
overwrite: re
|
|
5219
5239
|
});
|
|
5220
5240
|
if (n.aborted) {
|
|
5221
5241
|
r.stop("Installation aborted");
|
|
5222
5242
|
for (let e of n.errors) s.log.error(e);
|
|
5223
5243
|
s.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
5224
5244
|
}
|
|
5225
|
-
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${R.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && (s.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`),
|
|
5245
|
+
r.stop("Files installed"), n.installed.length > 0 && s.log.success(`${R.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && (s.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`), Do(n.skipped));
|
|
5226
5246
|
for (let e of n.errors) s.log.error(e);
|
|
5227
5247
|
r.start("Applying template overrides...");
|
|
5228
|
-
let o = await
|
|
5248
|
+
let o = await vs(u.id, {
|
|
5229
5249
|
token: S,
|
|
5230
5250
|
licenseKey: x
|
|
5231
5251
|
});
|
|
5232
|
-
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)),
|
|
5233
|
-
let c = await
|
|
5252
|
+
o.status === "denied" && (r.stop("Template download denied"), s.cancel(`Access to template "${u.id}" was denied (${o.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)), F = o.templateDir;
|
|
5253
|
+
let c = await Bi({
|
|
5234
5254
|
manifest: d,
|
|
5235
5255
|
config: h,
|
|
5236
5256
|
projectRoot: g,
|
|
5237
|
-
templateDir:
|
|
5257
|
+
templateDir: F
|
|
5238
5258
|
});
|
|
5239
5259
|
r.stop("Template overrides applied"), c.installed.length > 0 && s.log.success(`${c.installed.length} template file${c.installed.length === 1 ? "" : "s"} applied`);
|
|
5240
5260
|
for (let e of c.errors) s.log.error(e);
|
|
5241
5261
|
if (!m) {
|
|
5242
5262
|
let t = T.resolve(g, h.paths?.frontend.root ?? "apps/frontend"), n = d.theme ?? "zinc-mono";
|
|
5243
|
-
a(n) && (await
|
|
5263
|
+
a(n) && (await za(t, i(n)) ? s.log.success(`Applied the ${i(n).label} theme`) : s.log.warning(R.muted(`Could not find ${R.path("assets/styles.css")} to apply the theme`)));
|
|
5244
5264
|
let r = d.defaultMode === "dark" || d.defaultMode === "light" ? d.defaultMode : e;
|
|
5245
|
-
await
|
|
5265
|
+
await Na(t, r) ? s.log.success(`Default color mode set to ${r}`) : s.log.warning(R.muted(`Could not find ${R.path("src/hooks/use-theme.ts")} to set the default color mode`));
|
|
5246
5266
|
}
|
|
5247
|
-
await
|
|
5248
|
-
prepared:
|
|
5267
|
+
await Ss({
|
|
5268
|
+
prepared: P,
|
|
5249
5269
|
templateNpm: d.dependencies_npm,
|
|
5250
5270
|
paths: h.paths,
|
|
5251
5271
|
cwd: g,
|
|
5252
5272
|
spinner: r
|
|
5253
|
-
})
|
|
5273
|
+
});
|
|
5274
|
+
let l;
|
|
5275
|
+
m && (l = await aa(g, t.yes ?? !1)), await pr({
|
|
5254
5276
|
projectRoot: g,
|
|
5255
5277
|
paths: h.paths,
|
|
5256
|
-
skipPrompts: t.yes ?? !1
|
|
5257
|
-
|
|
5278
|
+
skipPrompts: t.yes ?? !1,
|
|
5279
|
+
dbReady: l
|
|
5280
|
+
}), Eo(), s.outro(R.brand(`Installed template ${u.name}.`));
|
|
5258
5281
|
} finally {
|
|
5259
|
-
await Promise.all(
|
|
5282
|
+
await Promise.all(P.map((e) => y.rm(e.packDir, {
|
|
5260
5283
|
recursive: !0,
|
|
5261
5284
|
force: !0
|
|
5262
|
-
}))),
|
|
5285
|
+
}))), F && await y.rm(F, {
|
|
5263
5286
|
recursive: !0,
|
|
5264
5287
|
force: !0
|
|
5265
5288
|
});
|
|
5266
5289
|
}
|
|
5267
5290
|
}
|
|
5268
|
-
async function
|
|
5291
|
+
async function bs(e, t, n) {
|
|
5269
5292
|
let r = {};
|
|
5270
5293
|
for (let i of e.slots) {
|
|
5271
5294
|
if (t?.[i.family]) {
|
|
@@ -5289,7 +5312,7 @@ async function vs(e, t, n) {
|
|
|
5289
5312
|
}
|
|
5290
5313
|
return r;
|
|
5291
5314
|
}
|
|
5292
|
-
async function
|
|
5315
|
+
async function xs(e) {
|
|
5293
5316
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5294
5317
|
if (i.packs && i.packs.length > 0) {
|
|
5295
5318
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -5298,9 +5321,9 @@ async function ys(e) {
|
|
|
5298
5321
|
if (i.yes) return [];
|
|
5299
5322
|
let o = t.filter((e) => e.category === "feature" && !a.has(e.name) && !r.has(e.name));
|
|
5300
5323
|
if (o.length === 0) return [];
|
|
5301
|
-
let c =
|
|
5324
|
+
let c = ce();
|
|
5302
5325
|
s.note(o.map((e) => ` ${z.arrow} ${R.highlight(e.displayName)} ${_e(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5303
|
-
let l = await
|
|
5326
|
+
let l = await Ea({
|
|
5304
5327
|
message: "Add extra packs on top of the template (optional)",
|
|
5305
5328
|
options: o.map((e) => ({
|
|
5306
5329
|
value: e.name,
|
|
@@ -5311,25 +5334,25 @@ async function ys(e) {
|
|
|
5311
5334
|
});
|
|
5312
5335
|
return m(l) && (s.cancel("Cancelled."), process.exit(0)), l;
|
|
5313
5336
|
}
|
|
5314
|
-
async function
|
|
5315
|
-
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o =
|
|
5337
|
+
async function Ss(e) {
|
|
5338
|
+
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o = vo(t.map((e) => e.manifest.dependencies_npm)), c = _o(n ? vo([o, n]) : o, r);
|
|
5316
5339
|
if (c.errors.length > 0) {
|
|
5317
5340
|
for (let e of c.errors) s.log.error(e);
|
|
5318
5341
|
return;
|
|
5319
5342
|
}
|
|
5320
5343
|
if (c.operations.length === 0) return;
|
|
5321
5344
|
a.start("Installing npm dependencies...");
|
|
5322
|
-
let l = await
|
|
5345
|
+
let l = await yo(c.operations, i);
|
|
5323
5346
|
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) s.log.error(e);
|
|
5324
5347
|
}
|
|
5325
5348
|
//#endregion
|
|
5326
5349
|
//#region src/cli.ts
|
|
5327
|
-
function
|
|
5350
|
+
function Cs(e) {
|
|
5328
5351
|
if (!e) return;
|
|
5329
5352
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5330
5353
|
return t.length > 0 ? t : void 0;
|
|
5331
5354
|
}
|
|
5332
|
-
function
|
|
5355
|
+
function ws(e) {
|
|
5333
5356
|
if (!e) return;
|
|
5334
5357
|
let t = {};
|
|
5335
5358
|
for (let n of e.split(",")) {
|
|
@@ -5338,10 +5361,10 @@ function Ss(e) {
|
|
|
5338
5361
|
}
|
|
5339
5362
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5340
5363
|
}
|
|
5341
|
-
function
|
|
5364
|
+
function Ts() {
|
|
5342
5365
|
let e = new o();
|
|
5343
5366
|
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) => {
|
|
5344
|
-
await
|
|
5367
|
+
await Ro({
|
|
5345
5368
|
name: e.name,
|
|
5346
5369
|
directory: e.directory,
|
|
5347
5370
|
install: e.install,
|
|
@@ -5351,38 +5374,38 @@ function Cs() {
|
|
|
5351
5374
|
setup: e.setup
|
|
5352
5375
|
});
|
|
5353
5376
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5354
|
-
await
|
|
5377
|
+
await zo({});
|
|
5355
5378
|
}), 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) => {
|
|
5356
|
-
await
|
|
5379
|
+
await us({
|
|
5357
5380
|
cwd: e.cwd,
|
|
5358
5381
|
yes: e.yes,
|
|
5359
5382
|
skipMigrations: e.skipMigrations
|
|
5360
5383
|
});
|
|
5361
5384
|
}), 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) => {
|
|
5362
|
-
await
|
|
5363
|
-
packs:
|
|
5385
|
+
await Vo({
|
|
5386
|
+
packs: Cs(e.packs),
|
|
5364
5387
|
force: e.force,
|
|
5365
5388
|
yes: e.yes,
|
|
5366
5389
|
licenseKey: e.key ?? e.licenseKey,
|
|
5367
5390
|
cwd: e.cwd
|
|
5368
5391
|
});
|
|
5369
5392
|
}), 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) => {
|
|
5370
|
-
await
|
|
5393
|
+
await ys({
|
|
5371
5394
|
templateId: e,
|
|
5372
|
-
variants:
|
|
5373
|
-
packs:
|
|
5395
|
+
variants: ws(t.variants),
|
|
5396
|
+
packs: Cs(t.packs),
|
|
5374
5397
|
force: t.force,
|
|
5375
5398
|
yes: t.yes,
|
|
5376
5399
|
licenseKey: t.key ?? t.licenseKey,
|
|
5377
5400
|
cwd: t.cwd
|
|
5378
5401
|
});
|
|
5379
5402
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5380
|
-
await
|
|
5403
|
+
await qo();
|
|
5381
5404
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5382
|
-
await
|
|
5405
|
+
await Jo();
|
|
5383
5406
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5384
|
-
await
|
|
5407
|
+
await qo();
|
|
5385
5408
|
}), e;
|
|
5386
5409
|
}
|
|
5387
5410
|
//#endregion
|
|
5388
|
-
export {
|
|
5411
|
+
export { Bo as a, Vo as i, Jo as n, zo as o, qo as r, Ro as s, Ts as t };
|