@hype-stack/cli 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-C34Wgnjr.js → cli-B_dUEkkB.js} +632 -567
- package/dist/commands/compose.d.ts.map +1 -1
- package/dist/commands/install-helpers.d.ts +7 -0
- package/dist/commands/install-helpers.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.map +1 -1
- package/dist/core/codemods.d.ts.map +1 -1
- package/dist/core/installer.d.ts +18 -6
- package/dist/core/installer.d.ts.map +1 -1
- package/dist/core/post-setup.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import { Prompt as D } from "@clack/core";
|
|
|
13
13
|
import { styleText as O } from "node:util";
|
|
14
14
|
import { downloadTemplate as ee } from "giget";
|
|
15
15
|
//#region src/constants/constants.ts
|
|
16
|
-
var k = "0.
|
|
16
|
+
var k = "0.5.1", te = "gh:BetterTyped/hype-stack", ne = "stack.json", re = "/schema/stack.json", A = "https://api.hype-stack.dev", j = "HYPE_STACK_API_URL", ie = "https://www.hype-stack.dev", M = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, ae = [
|
|
17
17
|
{
|
|
18
18
|
value: "cursor",
|
|
19
19
|
label: "Cursor",
|
|
@@ -1401,21 +1401,21 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1401
1401
|
}
|
|
1402
1402
|
return t;
|
|
1403
1403
|
}, []).join("&");
|
|
1404
|
-
}, an = (e, t =
|
|
1404
|
+
}, an = (e, t = Pn) => {
|
|
1405
1405
|
if (!e || !Object.keys(e).length) return "";
|
|
1406
1406
|
if (typeof e == "string") return e[0] === "?" ? e : `?${e}`;
|
|
1407
1407
|
let n = Object.entries(e).map(([e, n]) => Array.isArray(n) ? rn(e, n, t) : nn(e, n, t)).filter(Boolean).join("&");
|
|
1408
1408
|
return n ? `?${n}` : "";
|
|
1409
|
-
}, on = Kt.SEC * 5,
|
|
1409
|
+
}, on = Kt.SEC * 5, sn = { headers: {} }, cn = () => new Qt({
|
|
1410
1410
|
name: "http",
|
|
1411
1411
|
defaultMethod: It.GET,
|
|
1412
|
-
defaultExtra:
|
|
1412
|
+
defaultExtra: sn,
|
|
1413
1413
|
systemErrorStatus: 0,
|
|
1414
|
-
systemErrorExtra:
|
|
1414
|
+
systemErrorExtra: sn
|
|
1415
1415
|
}).setQueryParamsMapper(an).setFetcher(async ({ request: e, adapterOptions: t, headers: n, payload: r, onError: i, onResponseEnd: a, onTimeoutError: o, onRequestEnd: s, createAbortListener: c, getAbortController: l, onResponseProgress: u, onResponseStart: d, onBeforeRequest: f, onRequestStart: p, onRequestProgress: m, onSuccess: h }) => {
|
|
1416
1416
|
let { method: g, client: _, endpoint: v, queryParams: y } = e, b = y ? an(y) : "", x = `${_.url}${v}${b}`, S = l(), { timeout: C = on, streaming: w = !1, ...T } = t || {}, E = !1, D, O = c({
|
|
1417
1417
|
status: 0,
|
|
1418
|
-
extra:
|
|
1418
|
+
extra: sn
|
|
1419
1419
|
});
|
|
1420
1420
|
C > 0 && S && (D = setTimeout(() => {
|
|
1421
1421
|
E = !0, O(), S.abort();
|
|
@@ -1481,17 +1481,17 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1481
1481
|
if (D && clearTimeout(D), O(), S?.signal?.aborted) {
|
|
1482
1482
|
E && o({
|
|
1483
1483
|
status: 0,
|
|
1484
|
-
extra:
|
|
1484
|
+
extra: sn
|
|
1485
1485
|
});
|
|
1486
1486
|
return;
|
|
1487
1487
|
}
|
|
1488
1488
|
i({
|
|
1489
1489
|
error: e,
|
|
1490
1490
|
status: 0,
|
|
1491
|
-
extra:
|
|
1491
|
+
extra: sn
|
|
1492
1492
|
});
|
|
1493
1493
|
}
|
|
1494
|
-
}),
|
|
1494
|
+
}), ln = () => cn(), un = class {
|
|
1495
1495
|
emitter = new Fe();
|
|
1496
1496
|
events;
|
|
1497
1497
|
storage;
|
|
@@ -1503,7 +1503,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1503
1503
|
constructor(e) {
|
|
1504
1504
|
this.options = e;
|
|
1505
1505
|
let { storage: t = /* @__PURE__ */ new Map(), lazyStorage: n, version: r = "0.0.1" } = e ?? {};
|
|
1506
|
-
this.emitter?.setMaxListeners(1e3), this.events =
|
|
1506
|
+
this.emitter?.setMaxListeners(1e3), this.events = vn(this.emitter), this.storage = t, this.version = r, this.lazyStorage = n;
|
|
1507
1507
|
}
|
|
1508
1508
|
initialize = (e) => (this.client = e, this.logger = e.loggerManager.initialize(e, "Cache"), e.appManager.events.onOnline(() => {
|
|
1509
1509
|
[...this.storage.keys()].forEach(this.scheduleGarbageCollector);
|
|
@@ -1517,7 +1517,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1517
1517
|
response: t
|
|
1518
1518
|
}
|
|
1519
1519
|
});
|
|
1520
|
-
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = U(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u =
|
|
1520
|
+
let { cacheKey: n, cache: r, staleTime: i, cacheTime: a, scope: o } = e, s = U(n, o), c = this.storage.get(s), l = typeof t == "function" ? t(c || null) : t, u = dn(c, l), d = {
|
|
1521
1521
|
...u,
|
|
1522
1522
|
scope: o,
|
|
1523
1523
|
staleTime: i,
|
|
@@ -1656,49 +1656,49 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1656
1656
|
clear = async () => {
|
|
1657
1657
|
this.garbageCollectors.forEach((e) => clearTimeout(e)), this.storage.clear();
|
|
1658
1658
|
};
|
|
1659
|
-
},
|
|
1659
|
+
}, dn = (e, t) => {
|
|
1660
1660
|
let { data: n, success: r } = t, i = !r && e ? e.data : null, a = n || i;
|
|
1661
1661
|
return {
|
|
1662
1662
|
...t,
|
|
1663
1663
|
data: a
|
|
1664
1664
|
};
|
|
1665
|
-
},
|
|
1665
|
+
}, fn = () => "invalidate", pn = (e) => `${e}_invalidate`, mn = () => "delete", hn = (e) => `${e}_delete`, gn = (e) => `${e}_cache`, _n = () => "cache", vn = (e) => ({
|
|
1666
1666
|
emitCacheData: (t, n = !1) => {
|
|
1667
|
-
e.emit(
|
|
1667
|
+
e.emit(_n(), t, n), e.emit(gn(t.cacheKey), t, n);
|
|
1668
1668
|
},
|
|
1669
1669
|
emitInvalidation: (t, n = !1) => {
|
|
1670
|
-
e.emit(
|
|
1670
|
+
e.emit(fn(), t, n), e.emit(pn(t), n);
|
|
1671
1671
|
},
|
|
1672
1672
|
emitDelete: (t, n = !1) => {
|
|
1673
|
-
e.emit(
|
|
1673
|
+
e.emit(mn(), t, n), e.emit(hn(t), n);
|
|
1674
1674
|
},
|
|
1675
|
-
onData: (t) => (e.on(
|
|
1676
|
-
onDataByKey: (t, n) => (e.on(
|
|
1677
|
-
onInvalidate: (t) => (e.on(
|
|
1678
|
-
onInvalidateByKey: (t, n) => (e.on(
|
|
1679
|
-
onDelete: (t) => (e.on(
|
|
1680
|
-
onDeleteByKey: (t, n) => (e.on(
|
|
1681
|
-
}),
|
|
1675
|
+
onData: (t) => (e.on(_n(), t), () => e.removeListener(_n(), t)),
|
|
1676
|
+
onDataByKey: (t, n) => (e.on(gn(t), n), () => e.removeListener(gn(t), n)),
|
|
1677
|
+
onInvalidate: (t) => (e.on(fn(), t), () => e.removeListener(fn(), t)),
|
|
1678
|
+
onInvalidateByKey: (t, n) => (e.on(pn(t), n), () => e.removeListener(pn(t), n)),
|
|
1679
|
+
onDelete: (t) => (e.on(mn(), t), () => e.removeListener(mn(), t)),
|
|
1680
|
+
onDeleteByKey: (t, n) => (e.on(hn(t), n), () => e.removeListener(hn(t), n))
|
|
1681
|
+
}), G = /* @__PURE__ */ function(e) {
|
|
1682
1682
|
return e.ONE_BY_ONE = "one-by-one", e.ALL_AT_ONCE = "all-at-once", e.PREVIOUS_CANCELED = "previous-canceled", e.DEDUPLICATED = "deduplicated", e;
|
|
1683
|
-
}({}),
|
|
1683
|
+
}({}), yn = (e) => ({
|
|
1684
1684
|
emitDrained: (t, n) => {
|
|
1685
|
-
e.emit(
|
|
1685
|
+
e.emit(xn(), t, n), e.emit(Sn(t.queryKey), t, n);
|
|
1686
1686
|
},
|
|
1687
1687
|
emitQueueStatusChanged: (t, n) => {
|
|
1688
|
-
e.emit(
|
|
1688
|
+
e.emit(Cn(), t, n), e.emit(wn(t.queryKey), t, n);
|
|
1689
1689
|
},
|
|
1690
1690
|
emitQueueChanged: (t, n) => {
|
|
1691
|
-
e.emit(
|
|
1691
|
+
e.emit(Tn(), t, n), e.emit(En(t.queryKey), t, n);
|
|
1692
1692
|
},
|
|
1693
|
-
onDrained: (t) => (e.on(
|
|
1694
|
-
onDrainedByKey: (t, n) => (e.on(
|
|
1695
|
-
onQueueStatusChange: (t) => (e.on(
|
|
1696
|
-
onQueueStatusChangeByKey: (t, n) => (e.on(
|
|
1697
|
-
onQueueChange: (t) => (e.on(
|
|
1698
|
-
onQueueChangeByKey: (t, n) => (e.on(
|
|
1699
|
-
}),
|
|
1693
|
+
onDrained: (t) => (e.on(xn(), t), () => e.removeListener(xn(), t)),
|
|
1694
|
+
onDrainedByKey: (t, n) => (e.on(Sn(t), n), () => e.removeListener(Sn(t), n)),
|
|
1695
|
+
onQueueStatusChange: (t) => (e.on(Cn(), t), () => e.removeListener(Cn(), t)),
|
|
1696
|
+
onQueueStatusChangeByKey: (t, n) => (e.on(wn(t), n), () => e.removeListener(wn(t), n)),
|
|
1697
|
+
onQueueChange: (t) => (e.on(Tn(), t), () => e.removeListener(Tn(), t)),
|
|
1698
|
+
onQueueChangeByKey: (t, n) => (e.on(En(t), n), () => e.removeListener(En(t), n))
|
|
1699
|
+
}), bn = class {
|
|
1700
1700
|
emitter = new Fe();
|
|
1701
|
-
events =
|
|
1701
|
+
events = yn(this.emitter);
|
|
1702
1702
|
storage = /* @__PURE__ */ new Map();
|
|
1703
1703
|
requestCount = /* @__PURE__ */ new Map();
|
|
1704
1704
|
runningRequests = /* @__PURE__ */ new Map();
|
|
@@ -1866,7 +1866,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1866
1866
|
resolved: !1
|
|
1867
1867
|
});
|
|
1868
1868
|
add = (e) => {
|
|
1869
|
-
let t = U(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a =
|
|
1869
|
+
let t = U(e.queryKey, e.scope), n = this.createStorageItem(e), { requestId: r } = n, [i] = this.getQueue(t).requests.slice(-1), a = kn(e, i);
|
|
1870
1870
|
switch (this.logger.debug({
|
|
1871
1871
|
title: "Adding request to queue",
|
|
1872
1872
|
type: "system",
|
|
@@ -1876,9 +1876,9 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1876
1876
|
requestId: r
|
|
1877
1877
|
}
|
|
1878
1878
|
}), a) {
|
|
1879
|
-
case
|
|
1880
|
-
case
|
|
1881
|
-
case
|
|
1879
|
+
case G.ONE_BY_ONE: return this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1880
|
+
case G.PREVIOUS_CANCELED: return this.cancelRunningRequests(t), this.clearQueue(t), this.addQueueItem(t, n), this.flushQueue(t), r;
|
|
1881
|
+
case G.DEDUPLICATED: return this.client.requestManager.events.emitDeduplicated({
|
|
1882
1882
|
request: i.request,
|
|
1883
1883
|
requestId: r,
|
|
1884
1884
|
deduplicatedRequest: e
|
|
@@ -1920,7 +1920,7 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
1920
1920
|
requestId: n
|
|
1921
1921
|
}
|
|
1922
1922
|
});
|
|
1923
|
-
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = U(a, c), u = U(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h =
|
|
1923
|
+
let { retry: r, retryTime: i, queryKey: a, abortKey: o, offline: s, scope: c } = t, l = U(a, c), u = U(o, c), { adapter: d, requestManager: f, cache: p, appManager: m } = this.client, h = Dn(e.retries, r), g = !m.isOnline && s, _ = this.hasRunningRequest(l, n), v = e.stopped;
|
|
1924
1924
|
if (g || _ || v) return this.logger.warning({
|
|
1925
1925
|
title: "Unable to perform request",
|
|
1926
1926
|
type: "system",
|
|
@@ -2054,26 +2054,26 @@ var Xt = async ({ request: e, requestId: t, onError: n, onResponseEnd: r, onTime
|
|
|
2054
2054
|
}
|
|
2055
2055
|
}), this.delete(l, n, u));
|
|
2056
2056
|
};
|
|
2057
|
-
},
|
|
2058
|
-
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ?
|
|
2059
|
-
return n ?
|
|
2057
|
+
}, xn = () => "drained-event", Sn = (e) => `${e}-drained-event`, Cn = () => "status-event", wn = (e) => `${e}-status-event`, Tn = () => "change-event", En = (e) => `${e}-change-event`, Dn = (e, t) => !!(t && e < t), On = (e, t) => e.deduplicateTime ? +/* @__PURE__ */ new Date() - t.timestamp <= e.deduplicateTime : !0, kn = (e, t) => {
|
|
2058
|
+
let { queued: n, cancelable: r, deduplicate: i } = e, a = t ? On(e, t) : !1;
|
|
2059
|
+
return n ? G.ONE_BY_ONE : r ? G.PREVIOUS_CANCELED : a && i ? G.DEDUPLICATED : G.ALL_AT_ONCE;
|
|
2060
2060
|
};
|
|
2061
|
-
function
|
|
2061
|
+
function An(e) {
|
|
2062
2062
|
return e === "client" || e === "server" ? e : typeof window < "u" && typeof document < "u" ? "client" : "server";
|
|
2063
2063
|
}
|
|
2064
|
-
var
|
|
2064
|
+
var jn = async (e, t) => {
|
|
2065
2065
|
let n = t;
|
|
2066
2066
|
if (!t.requestOptions.disableRequestInterceptors) {
|
|
2067
2067
|
for (let r of e) if (n = await r(t), !n) throw Error("Request modifier must return request");
|
|
2068
2068
|
}
|
|
2069
2069
|
return n;
|
|
2070
|
-
},
|
|
2070
|
+
}, Mn = async (e, t, n) => {
|
|
2071
2071
|
let r = t;
|
|
2072
2072
|
if (!n.requestOptions.disableResponseInterceptors) {
|
|
2073
2073
|
for (let i of e) if (r = await i(t, n), !r) throw Error("Response modifier must return data");
|
|
2074
2074
|
}
|
|
2075
2075
|
return r;
|
|
2076
|
-
},
|
|
2076
|
+
}, Nn = class {
|
|
2077
2077
|
url;
|
|
2078
2078
|
mode;
|
|
2079
2079
|
debug;
|
|
@@ -2099,7 +2099,7 @@ var An = async (e, t) => {
|
|
|
2099
2099
|
constructor(e) {
|
|
2100
2100
|
this.options = e;
|
|
2101
2101
|
let { url: t, appManager: n, cache: r, fetchDispatcher: i, submitDispatcher: a, mode: o } = this.options;
|
|
2102
|
-
this.url = t, this.mode =
|
|
2102
|
+
this.url = t, this.mode = An(o), this.adapter = ln(), this.appManager = n?.() || new Ie(), this.cache = r?.() || new un(), this.fetchDispatcher = i?.() || new bn(), this.submitDispatcher = a?.() || new bn(), this.adapter.initialize(this), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2103
2103
|
}
|
|
2104
2104
|
setDebug = (e) => (this.debug = e, this);
|
|
2105
2105
|
setLogLevel = (e) => (this.loggerManager.setSeverity(e), this);
|
|
@@ -2128,15 +2128,15 @@ var An = async (e, t) => {
|
|
|
2128
2128
|
setCacheKeyMapper = (e) => (this.unstable_cacheKeyMapper = e, this);
|
|
2129
2129
|
setQueryKeyMapper = (e) => (this.unstable_queryKeyMapper = e, this);
|
|
2130
2130
|
setRequestIdMapper = (e) => (this.unstable_requestIdMapper = e, this);
|
|
2131
|
-
unstable_modifyAuth = async (e) =>
|
|
2132
|
-
unstable_modifyRequest = async (e) =>
|
|
2133
|
-
unstable_modifyErrorResponse = async (e, t) =>
|
|
2134
|
-
unstable_modifySuccessResponse = async (e, t) =>
|
|
2135
|
-
unstable_modifyResponse = async (e, t) =>
|
|
2131
|
+
unstable_modifyAuth = async (e) => jn(this.unstable_onAuthCallbacks, e);
|
|
2132
|
+
unstable_modifyRequest = async (e) => jn(this.unstable_onRequestCallbacks, e);
|
|
2133
|
+
unstable_modifyErrorResponse = async (e, t) => Mn(this.unstable_onErrorCallbacks, e, t);
|
|
2134
|
+
unstable_modifySuccessResponse = async (e, t) => Mn(this.unstable_onSuccessCallbacks, e, t);
|
|
2135
|
+
unstable_modifyResponse = async (e, t) => Mn(this.unstable_onResponseCallbacks, e, t);
|
|
2136
2136
|
fromJSON = (e) => qt.fromJSON(this, e);
|
|
2137
2137
|
clear = () => {
|
|
2138
2138
|
let { appManager: e, cache: t, fetchDispatcher: n, submitDispatcher: r } = this.options;
|
|
2139
|
-
this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new
|
|
2139
|
+
this.requestManager.abortControllers.clear(), this.fetchDispatcher.clear(), this.submitDispatcher.clear(), this.cache.clear(), this.requestManager.emitter.removeAllListeners(), this.fetchDispatcher.emitter.removeAllListeners(), this.submitDispatcher.emitter.removeAllListeners(), this.cache.emitter.removeAllListeners(), this.cache = t?.() || new un(), this.appManager = e?.() || new Ie(), this.fetchDispatcher = n?.() || new bn(), this.submitDispatcher = r?.() || new bn(), this.appManager.initialize(), this.cache.initialize(this), this.fetchDispatcher.initialize(this), this.submitDispatcher.initialize(this);
|
|
2140
2140
|
};
|
|
2141
2141
|
hydrate = (e, t) => {
|
|
2142
2142
|
e?.forEach((e) => {
|
|
@@ -2169,7 +2169,7 @@ var An = async (e, t) => {
|
|
|
2169
2169
|
}, r = new qt(this, n);
|
|
2170
2170
|
return this.plugins.forEach((e) => e.trigger("onRequestCreate", { request: r })), r;
|
|
2171
2171
|
};
|
|
2172
|
-
},
|
|
2172
|
+
}, Pn = {
|
|
2173
2173
|
strict: !0,
|
|
2174
2174
|
encode: !0,
|
|
2175
2175
|
arrayFormat: "bracket",
|
|
@@ -2178,101 +2178,101 @@ var An = async (e, t) => {
|
|
|
2178
2178
|
skipNull: !0,
|
|
2179
2179
|
skipEmptyString: !0
|
|
2180
2180
|
};
|
|
2181
|
-
function
|
|
2182
|
-
return new
|
|
2181
|
+
function Fn(e) {
|
|
2182
|
+
return new Nn(e);
|
|
2183
2183
|
}
|
|
2184
2184
|
//#endregion
|
|
2185
2185
|
//#region src/core/client.ts
|
|
2186
|
-
var
|
|
2186
|
+
var K = Fn({ url: N() });
|
|
2187
2187
|
//#endregion
|
|
2188
2188
|
//#region src/core/auth-api.ts
|
|
2189
|
-
async function
|
|
2190
|
-
let { data: t, success: n } = await
|
|
2189
|
+
async function In(e) {
|
|
2190
|
+
let { data: t, success: n } = await K.createRequest()({
|
|
2191
2191
|
endpoint: "/auth/cli/whoami",
|
|
2192
2192
|
method: "GET"
|
|
2193
2193
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2194
2194
|
return !n || !t ? null : t;
|
|
2195
2195
|
}
|
|
2196
|
-
async function
|
|
2197
|
-
await
|
|
2196
|
+
async function Ln(e) {
|
|
2197
|
+
await K.createRequest()({
|
|
2198
2198
|
endpoint: "/auth/cli/token",
|
|
2199
2199
|
method: "DELETE"
|
|
2200
2200
|
}).setHeaders({ Authorization: `Bearer ${e}` }).send();
|
|
2201
2201
|
}
|
|
2202
2202
|
//#endregion
|
|
2203
2203
|
//#region src/core/auth-store.ts
|
|
2204
|
-
var
|
|
2205
|
-
function
|
|
2204
|
+
var Rn = 1, zn = "hype-stack", Bn = "auth.json";
|
|
2205
|
+
function Vn() {
|
|
2206
2206
|
let e = process.env.HYPE_STACK_CONFIG_DIR;
|
|
2207
|
-
if (e) return w.join(e,
|
|
2207
|
+
if (e) return w.join(e, zn);
|
|
2208
2208
|
let t = C.homedir();
|
|
2209
2209
|
if (process.platform === "win32") {
|
|
2210
2210
|
let e = process.env.APPDATA ?? w.join(t, "AppData", "Roaming");
|
|
2211
|
-
return w.join(e,
|
|
2211
|
+
return w.join(e, zn);
|
|
2212
2212
|
}
|
|
2213
|
-
if (process.platform === "darwin") return w.join(t, "Library", "Application Support",
|
|
2213
|
+
if (process.platform === "darwin") return w.join(t, "Library", "Application Support", zn);
|
|
2214
2214
|
let n = process.env.XDG_CONFIG_HOME ?? w.join(t, ".config");
|
|
2215
|
-
return w.join(n,
|
|
2215
|
+
return w.join(n, zn);
|
|
2216
2216
|
}
|
|
2217
|
-
function
|
|
2218
|
-
return w.join(
|
|
2217
|
+
function Hn() {
|
|
2218
|
+
return w.join(Vn(), Bn);
|
|
2219
2219
|
}
|
|
2220
|
-
async function
|
|
2221
|
-
let e = await v.readFile(
|
|
2220
|
+
async function Un() {
|
|
2221
|
+
let e = await v.readFile(Hn(), "utf-8").catch(() => null);
|
|
2222
2222
|
if (!e) return {
|
|
2223
|
-
version:
|
|
2223
|
+
version: Rn,
|
|
2224
2224
|
tokens: {}
|
|
2225
2225
|
};
|
|
2226
2226
|
let t = JSON.parse(e);
|
|
2227
2227
|
return {
|
|
2228
|
-
version: t.version ??
|
|
2228
|
+
version: t.version ?? Rn,
|
|
2229
2229
|
tokens: t.tokens ?? {}
|
|
2230
2230
|
};
|
|
2231
2231
|
}
|
|
2232
|
-
async function Un(e) {
|
|
2233
|
-
let t = Bn();
|
|
2234
|
-
await v.mkdir(t, { recursive: !0 }), await v.writeFile(Vn(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2235
|
-
}
|
|
2236
2232
|
async function Wn(e) {
|
|
2237
|
-
|
|
2233
|
+
let t = Vn();
|
|
2234
|
+
await v.mkdir(t, { recursive: !0 }), await v.writeFile(Hn(), `${JSON.stringify(e, null, 2)}\n`, { mode: 384 });
|
|
2235
|
+
}
|
|
2236
|
+
async function Gn(e) {
|
|
2237
|
+
return (await Un()).tokens[e] ?? null;
|
|
2238
2238
|
}
|
|
2239
|
-
async function
|
|
2240
|
-
let n = await
|
|
2241
|
-
n.tokens[e] = t, await
|
|
2239
|
+
async function Kn(e, t) {
|
|
2240
|
+
let n = await Un();
|
|
2241
|
+
n.tokens[e] = t, await Wn(n);
|
|
2242
2242
|
}
|
|
2243
|
-
async function
|
|
2244
|
-
let t = await
|
|
2245
|
-
e in t.tokens && (delete t.tokens[e], await
|
|
2243
|
+
async function qn(e) {
|
|
2244
|
+
let t = await Un();
|
|
2245
|
+
e in t.tokens && (delete t.tokens[e], await Wn(t));
|
|
2246
2246
|
}
|
|
2247
2247
|
//#endregion
|
|
2248
2248
|
//#region src/core/device.ts
|
|
2249
|
-
function
|
|
2249
|
+
function Jn() {
|
|
2250
2250
|
let e = C.networkInterfaces();
|
|
2251
2251
|
for (let t of Object.values(e)) if (t) {
|
|
2252
2252
|
for (let e of t) if (!e.internal && e.mac !== "00:00:00:00:00:00") return e.mac;
|
|
2253
2253
|
}
|
|
2254
2254
|
return "unknown";
|
|
2255
2255
|
}
|
|
2256
|
-
function
|
|
2257
|
-
let e = `${
|
|
2256
|
+
function Yn() {
|
|
2257
|
+
let e = `${Jn()}:${C.hostname()}:${C.platform()}:${C.arch()}`;
|
|
2258
2258
|
return b("sha256").update(e).digest("hex").slice(0, 16);
|
|
2259
2259
|
}
|
|
2260
|
-
function
|
|
2260
|
+
function Xn() {
|
|
2261
2261
|
return `hype-stack/${k} ${C.platform()} ${C.arch()} node/${process.version.slice(1)}`;
|
|
2262
2262
|
}
|
|
2263
2263
|
//#endregion
|
|
2264
2264
|
//#region src/core/open-browser.ts
|
|
2265
|
-
function
|
|
2265
|
+
function Zn(e) {
|
|
2266
2266
|
T(process.platform === "darwin" ? `open "${e}"` : process.platform === "win32" ? `start "" "${e}"` : `xdg-open "${e}"`);
|
|
2267
2267
|
}
|
|
2268
2268
|
//#endregion
|
|
2269
2269
|
//#region src/core/login.ts
|
|
2270
|
-
var
|
|
2271
|
-
async function
|
|
2270
|
+
var Qn = 300 * 1e3, $n = (e) => `<!doctype html><html><head><meta charset="utf-8"><title>Hype Stack CLI</title></head><body style="font-family:system-ui,sans-serif;text-align:center;padding-top:4rem;color:#111"><h2>${e}</h2><p>You can close this tab and return to your terminal.</p></body></html>`;
|
|
2271
|
+
async function er(e = {}) {
|
|
2272
2272
|
let t = x(16).toString("hex"), n = N(), r = S.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
|
+
}, Qn);
|
|
2276
2276
|
function o() {
|
|
2277
2277
|
clearTimeout(a), r.close(), r.closeAllConnections?.();
|
|
2278
2278
|
}
|
|
@@ -2286,7 +2286,7 @@ async function $n(e = {}) {
|
|
|
2286
2286
|
r.writeHead(200, {
|
|
2287
2287
|
"Content-Type": "text/html",
|
|
2288
2288
|
Connection: "close"
|
|
2289
|
-
}), r.end(
|
|
2289
|
+
}), r.end($n(e));
|
|
2290
2290
|
};
|
|
2291
2291
|
if (a.searchParams.get("state") !== t) {
|
|
2292
2292
|
s("Login failed."), o(), i(/* @__PURE__ */ Error("Login failed: state mismatch. Run `npx @hype-stack/cli login` again."));
|
|
@@ -2301,24 +2301,24 @@ async function $n(e = {}) {
|
|
|
2301
2301
|
}), r.on("error", (e) => {
|
|
2302
2302
|
o(), i(e);
|
|
2303
2303
|
}), r.listen(0, "127.0.0.1", () => {
|
|
2304
|
-
let { port: n } = r.address(), i = encodeURIComponent(
|
|
2305
|
-
e.onUrl?.(a),
|
|
2304
|
+
let { port: n } = r.address(), i = encodeURIComponent(Xn()), a = `${P()}/cli/authorize?port=${n}&state=${t}&label=${i}`;
|
|
2305
|
+
e.onUrl?.(a), Zn(a);
|
|
2306
2306
|
});
|
|
2307
|
-
}), a = await
|
|
2307
|
+
}), a = await In(i).catch(() => null), o = {
|
|
2308
2308
|
token: i,
|
|
2309
2309
|
email: a?.email,
|
|
2310
2310
|
organizationId: a?.organizationId
|
|
2311
2311
|
};
|
|
2312
|
-
return await
|
|
2312
|
+
return await Kn(n, o), o;
|
|
2313
2313
|
}
|
|
2314
2314
|
//#endregion
|
|
2315
2315
|
//#region src/core/access-prompts.ts
|
|
2316
|
-
async function
|
|
2316
|
+
async function tr() {
|
|
2317
2317
|
let e = await o.confirm({ message: "Log in to install packs your organization owns? (opens your browser)" });
|
|
2318
2318
|
if (o.isCancel(e) || !e) return null;
|
|
2319
2319
|
o.log.step("Opening your browser to sign in...");
|
|
2320
2320
|
try {
|
|
2321
|
-
let e = await
|
|
2321
|
+
let e = await er({ onUrl: (e) => {
|
|
2322
2322
|
o.log.info(`If your browser didn't open, visit:\n ${L.path(e)}`);
|
|
2323
2323
|
} });
|
|
2324
2324
|
return o.log.success(e.email ? `Logged in as ${e.email}` : "Logged in"), e.token;
|
|
@@ -2326,7 +2326,7 @@ async function er() {
|
|
|
2326
2326
|
return o.log.error(e instanceof Error ? e.message : String(e)), null;
|
|
2327
2327
|
}
|
|
2328
2328
|
}
|
|
2329
|
-
async function
|
|
2329
|
+
async function nr(e) {
|
|
2330
2330
|
if (e.length === 0) return;
|
|
2331
2331
|
o.note([
|
|
2332
2332
|
"These packs need a purchase before they can be installed:",
|
|
@@ -2338,7 +2338,7 @@ async function tr(e) {
|
|
|
2338
2338
|
o.log.info(L.muted("Run 'npx @hype-stack/cli login' after purchasing, then 'npx @hype-stack/cli compose' again."));
|
|
2339
2339
|
return;
|
|
2340
2340
|
}
|
|
2341
|
-
for (let t of e)
|
|
2341
|
+
for (let t of e) Zn(Se(t.name));
|
|
2342
2342
|
o.log.info([
|
|
2343
2343
|
L.muted("After purchasing, run:"),
|
|
2344
2344
|
` ${L.highlight("npx @hype-stack/cli login")} ${L.muted("Save your access")}`,
|
|
@@ -2347,7 +2347,7 @@ async function tr(e) {
|
|
|
2347
2347
|
}
|
|
2348
2348
|
//#endregion
|
|
2349
2349
|
//#region src/utils/exec.ts
|
|
2350
|
-
function
|
|
2350
|
+
function q(e, t, n) {
|
|
2351
2351
|
return new Promise((r, i) => {
|
|
2352
2352
|
let a = E(e, t, {
|
|
2353
2353
|
cwd: n.cwd,
|
|
@@ -2380,7 +2380,7 @@ function J(e, t, n) {
|
|
|
2380
2380
|
}
|
|
2381
2381
|
//#endregion
|
|
2382
2382
|
//#region src/utils/fs.ts
|
|
2383
|
-
async function
|
|
2383
|
+
async function J(e) {
|
|
2384
2384
|
return (await v.stat(e).catch(() => null))?.isDirectory() ?? !1;
|
|
2385
2385
|
}
|
|
2386
2386
|
async function Y(e) {
|
|
@@ -2398,7 +2398,7 @@ async function ar(e, t) {
|
|
|
2398
2398
|
}
|
|
2399
2399
|
async function or(e) {
|
|
2400
2400
|
let t = {};
|
|
2401
|
-
if (!await
|
|
2401
|
+
if (!await J(e)) return t;
|
|
2402
2402
|
let n = await v.readdir(e, { withFileTypes: !0 });
|
|
2403
2403
|
for (let r of n) r.isDirectory() && await Y(w.join(e, r.name, "package.json")) && (t[r.name] = w.relative(w.dirname(e), w.join(e, r.name)));
|
|
2404
2404
|
return t;
|
|
@@ -2422,7 +2422,7 @@ function lr(e) {
|
|
|
2422
2422
|
].join("\n"), "Database Setup");
|
|
2423
2423
|
}
|
|
2424
2424
|
async function ur(e) {
|
|
2425
|
-
let { projectRoot: t, paths: n, skipPrompts: r, runCommand: i =
|
|
2425
|
+
let { projectRoot: t, paths: n, skipPrompts: r, runCommand: i = q } = e, a = n.backend.root, s = w.join(t, a);
|
|
2426
2426
|
if (!await Y(w.join(s, "package.json"))) return;
|
|
2427
2427
|
if (r) {
|
|
2428
2428
|
lr(a);
|
|
@@ -2437,48 +2437,56 @@ async function ur(e) {
|
|
|
2437
2437
|
return;
|
|
2438
2438
|
}
|
|
2439
2439
|
let l = o.spinner();
|
|
2440
|
-
|
|
2440
|
+
l.start("Generating Prisma client...");
|
|
2441
|
+
let u = await i("pnpm", [
|
|
2441
2442
|
"exec",
|
|
2442
2443
|
"prisma",
|
|
2443
2444
|
"generate"
|
|
2444
|
-
], { cwd: s })
|
|
2445
|
-
|
|
2445
|
+
], { cwd: s });
|
|
2446
|
+
if (u.exitCode !== 0) {
|
|
2447
|
+
l.error("Prisma client generation failed"), dr(u), lr(a);
|
|
2446
2448
|
return;
|
|
2447
2449
|
}
|
|
2448
2450
|
l.stop(L.success("Prisma client generated"));
|
|
2449
|
-
let
|
|
2450
|
-
|
|
2451
|
+
let d = o.spinner();
|
|
2452
|
+
d.start("Applying database schema...");
|
|
2453
|
+
let f = await i("pnpm", [
|
|
2451
2454
|
"exec",
|
|
2452
2455
|
"prisma",
|
|
2453
2456
|
"migrate",
|
|
2454
2457
|
"dev",
|
|
2455
2458
|
"--name",
|
|
2456
2459
|
"add-packs"
|
|
2457
|
-
], { cwd: s })
|
|
2458
|
-
|
|
2460
|
+
], { cwd: s });
|
|
2461
|
+
if (f.exitCode !== 0) {
|
|
2462
|
+
d.error("Database migration failed (is your database running?)"), dr(f), lr(a);
|
|
2459
2463
|
return;
|
|
2460
2464
|
}
|
|
2461
|
-
|
|
2465
|
+
d.stop(L.success("Database schema applied"));
|
|
2466
|
+
}
|
|
2467
|
+
function dr(e) {
|
|
2468
|
+
let t = (e.stderr || e.stdout).trim();
|
|
2469
|
+
t && o.log.warn(L.muted(t));
|
|
2462
2470
|
}
|
|
2463
2471
|
//#endregion
|
|
2464
2472
|
//#region src/core/stack-config.ts
|
|
2465
|
-
async function
|
|
2473
|
+
async function fr(e) {
|
|
2466
2474
|
return ir(w.join(e, ne));
|
|
2467
2475
|
}
|
|
2468
|
-
async function
|
|
2476
|
+
async function pr(e) {
|
|
2469
2477
|
return Y(w.join(e, ne));
|
|
2470
2478
|
}
|
|
2471
|
-
async function
|
|
2479
|
+
async function mr(e, t) {
|
|
2472
2480
|
await ar(w.join(e, ne), t);
|
|
2473
2481
|
}
|
|
2474
|
-
async function
|
|
2482
|
+
async function hr(e) {
|
|
2475
2483
|
let t = w.join(e, "apps"), n = w.join(e, "packages"), [r, i] = await Promise.all([or(t), or(n)]);
|
|
2476
2484
|
return {
|
|
2477
2485
|
apps: r,
|
|
2478
2486
|
packages: i
|
|
2479
2487
|
};
|
|
2480
2488
|
}
|
|
2481
|
-
function
|
|
2489
|
+
function gr(e) {
|
|
2482
2490
|
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";
|
|
2483
2491
|
return {
|
|
2484
2492
|
backend: {
|
|
@@ -2512,20 +2520,20 @@ function hr(e) {
|
|
|
2512
2520
|
}
|
|
2513
2521
|
};
|
|
2514
2522
|
}
|
|
2515
|
-
function
|
|
2523
|
+
function _r(e, t) {
|
|
2516
2524
|
return {
|
|
2517
2525
|
$schema: de(),
|
|
2518
2526
|
version: 1,
|
|
2519
2527
|
name: e,
|
|
2520
2528
|
apps: t.apps,
|
|
2521
2529
|
packages: t.packages,
|
|
2522
|
-
paths:
|
|
2530
|
+
paths: gr(t),
|
|
2523
2531
|
installedPacks: [],
|
|
2524
2532
|
licenseKey: null
|
|
2525
2533
|
};
|
|
2526
2534
|
}
|
|
2527
|
-
async function
|
|
2528
|
-
let t = w.join(e, "package.json"), n = w.join(e, "apps"), [r, i] = await Promise.all([Y(t),
|
|
2535
|
+
async function vr(e) {
|
|
2536
|
+
let t = w.join(e, "package.json"), n = w.join(e, "apps"), [r, i] = await Promise.all([Y(t), J(n)]);
|
|
2529
2537
|
return r && i;
|
|
2530
2538
|
}
|
|
2531
2539
|
function X(e, t) {
|
|
@@ -2539,8 +2547,8 @@ function X(e, t) {
|
|
|
2539
2547
|
}
|
|
2540
2548
|
//#endregion
|
|
2541
2549
|
//#region src/core/registry.ts
|
|
2542
|
-
async function
|
|
2543
|
-
let { data: t, error: n, status: r } = await
|
|
2550
|
+
async function yr(e) {
|
|
2551
|
+
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
2544
2552
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2545
2553
|
method: "GET"
|
|
2546
2554
|
}).send();
|
|
@@ -2548,13 +2556,13 @@ async function vr(e) {
|
|
|
2548
2556
|
if (n || !t) throw Error(`Failed to load manifest for "${e}": ${String(n)}`);
|
|
2549
2557
|
return t;
|
|
2550
2558
|
}
|
|
2551
|
-
async function
|
|
2552
|
-
let n =
|
|
2559
|
+
async function br(e, t = {}) {
|
|
2560
|
+
let n = K.createRequest()({
|
|
2553
2561
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2554
2562
|
method: "POST"
|
|
2555
2563
|
}), r = {
|
|
2556
|
-
"X-Device-Id":
|
|
2557
|
-
"X-Client-Info":
|
|
2564
|
+
"X-Device-Id": Yn(),
|
|
2565
|
+
"X-Client-Info": Xn()
|
|
2558
2566
|
};
|
|
2559
2567
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2560
2568
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -2574,25 +2582,25 @@ async function yr(e, t = {}) {
|
|
|
2574
2582
|
packDir: s
|
|
2575
2583
|
};
|
|
2576
2584
|
}
|
|
2577
|
-
function
|
|
2585
|
+
function xr(e, t, n) {
|
|
2578
2586
|
let r = X(e, t);
|
|
2579
2587
|
return w.resolve(n, r);
|
|
2580
2588
|
}
|
|
2581
|
-
function
|
|
2589
|
+
function Sr(e, t) {
|
|
2582
2590
|
return w.join(t, e);
|
|
2583
2591
|
}
|
|
2584
|
-
var
|
|
2592
|
+
var Cr = K.createRequest()({
|
|
2585
2593
|
endpoint: "/packs/list",
|
|
2586
2594
|
method: "GET"
|
|
2587
2595
|
});
|
|
2588
|
-
async function
|
|
2589
|
-
let { data: e, error: t } = await
|
|
2596
|
+
async function wr() {
|
|
2597
|
+
let { data: e, error: t } = await Cr.send();
|
|
2590
2598
|
if (t || !e) throw Error(`Failed to fetch pack list: ${String(t)}`);
|
|
2591
2599
|
return e.packs;
|
|
2592
2600
|
}
|
|
2593
|
-
async function
|
|
2601
|
+
async function Tr(e, t = {}) {
|
|
2594
2602
|
if (e.length === 0) return {};
|
|
2595
|
-
let n =
|
|
2603
|
+
let n = K.createRequest()({
|
|
2596
2604
|
endpoint: "/packs/authorize",
|
|
2597
2605
|
method: "POST"
|
|
2598
2606
|
}), r = {};
|
|
@@ -2606,35 +2614,35 @@ async function wr(e, t = {}) {
|
|
|
2606
2614
|
}
|
|
2607
2615
|
//#endregion
|
|
2608
2616
|
//#region src/core/codemods.ts
|
|
2609
|
-
var
|
|
2610
|
-
function
|
|
2617
|
+
var Er = "@hype-stack/";
|
|
2618
|
+
function Dr(e, t) {
|
|
2611
2619
|
return X(e === "admin" ? "{{admin.root}}" : "{{frontend.root}}", t);
|
|
2612
2620
|
}
|
|
2613
|
-
async function
|
|
2621
|
+
async function Or(e, t, n) {
|
|
2614
2622
|
let r = X("{{backend.root}}", t), i = w.resolve(n, r, "src/config/env/env.config.ts"), a = w.resolve(n, r, ".env.example"), o = w.resolve(n, r, ".env.test");
|
|
2615
2623
|
if (await Y(i)) {
|
|
2616
2624
|
let t = await v.readFile(i, "utf-8");
|
|
2617
|
-
for (let n of e) t.includes(`from "${n.from}"`) || (t =
|
|
2625
|
+
for (let n of e) t.includes(`from "${n.from}"`) || (t = kr(t, n), t = Ar(t, n));
|
|
2618
2626
|
await v.writeFile(i, t, "utf-8");
|
|
2619
2627
|
}
|
|
2620
2628
|
if (await Y(a)) {
|
|
2621
2629
|
let t = await v.readFile(a, "utf-8");
|
|
2622
|
-
for (let n of e) t =
|
|
2630
|
+
for (let n of e) t = jr(t, n);
|
|
2623
2631
|
await v.writeFile(a, t, "utf-8");
|
|
2624
2632
|
}
|
|
2625
2633
|
if (await Y(o)) {
|
|
2626
2634
|
let t = await v.readFile(o, "utf-8");
|
|
2627
|
-
for (let n of e) t =
|
|
2635
|
+
for (let n of e) t = Mr(t, n);
|
|
2628
2636
|
await v.writeFile(o, t, "utf-8");
|
|
2629
2637
|
}
|
|
2630
2638
|
}
|
|
2631
|
-
function
|
|
2639
|
+
function kr(e, t) {
|
|
2632
2640
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2633
2641
|
if (r === -1) return n + "\n" + e;
|
|
2634
2642
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2635
2643
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2636
2644
|
}
|
|
2637
|
-
function
|
|
2645
|
+
function Ar(e, t) {
|
|
2638
2646
|
let n = `.extend(${t.import}.shape)`;
|
|
2639
2647
|
if (e.includes(n)) return e;
|
|
2640
2648
|
let r = e.indexOf("export const envSchema = z.object({");
|
|
@@ -2649,27 +2657,27 @@ function kr(e, t) {
|
|
|
2649
2657
|
let o = a + 2;
|
|
2650
2658
|
return e.slice(0, o) + n + e.slice(o);
|
|
2651
2659
|
}
|
|
2652
|
-
function
|
|
2660
|
+
function jr(e, t) {
|
|
2653
2661
|
for (let n of Object.keys(t.envExample.vars)) if (e.includes(`${n}=`)) return e;
|
|
2654
2662
|
let n = [];
|
|
2655
2663
|
n.push(""), n.push(`# ${t.envExample.section}`);
|
|
2656
2664
|
for (let [e, r] of Object.entries(t.envExample.vars)) n.push(`${e}=${r}`);
|
|
2657
2665
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2658
2666
|
}
|
|
2659
|
-
function
|
|
2667
|
+
function Mr(e, t) {
|
|
2660
2668
|
for (let n of Object.keys(t.envTest)) if (e.includes(`${n}=`)) return e;
|
|
2661
2669
|
let n = [""];
|
|
2662
2670
|
for (let [e, r] of Object.entries(t.envTest)) n.push(`${e}=${r}`);
|
|
2663
2671
|
return e.trimEnd() + "\n" + n.join("\n") + "\n";
|
|
2664
2672
|
}
|
|
2665
|
-
async function
|
|
2673
|
+
async function Nr(e, t, n) {
|
|
2666
2674
|
let r = w.resolve(n, X("{{backend.routes}}", t), "index.ts");
|
|
2667
2675
|
if (!await Y(r)) return;
|
|
2668
2676
|
let i = await v.readFile(r, "utf-8");
|
|
2669
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2677
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Pr(i, t), i = Fr(i, t));
|
|
2670
2678
|
await v.writeFile(r, i, "utf-8");
|
|
2671
2679
|
}
|
|
2672
|
-
function
|
|
2680
|
+
function Pr(e, t) {
|
|
2673
2681
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2674
2682
|
if (r !== -1) {
|
|
2675
2683
|
let t = e.indexOf("\n", r);
|
|
@@ -2678,7 +2686,7 @@ function Nr(e, t) {
|
|
|
2678
2686
|
let i = e.indexOf("export const registerRoutes");
|
|
2679
2687
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2680
2688
|
}
|
|
2681
|
-
function
|
|
2689
|
+
function Fr(e, t) {
|
|
2682
2690
|
let n = `.route("${t.prefix}", ${t.import})`, r = e.match(/\.route\([^)]+\);/g);
|
|
2683
2691
|
if (r) {
|
|
2684
2692
|
let t = r[r.length - 1], i = e.lastIndexOf(t) + t.length - 1;
|
|
@@ -2686,14 +2694,14 @@ function Pr(e, t) {
|
|
|
2686
2694
|
}
|
|
2687
2695
|
return e.replace("return app;", `return app\n ${n};`);
|
|
2688
2696
|
}
|
|
2689
|
-
async function
|
|
2697
|
+
async function Ir(e, t, n) {
|
|
2690
2698
|
let r = w.resolve(n, X("{{backend.root}}", t), "src/context.ts");
|
|
2691
2699
|
if (!await Y(r)) return;
|
|
2692
2700
|
let i = await v.readFile(r, "utf-8");
|
|
2693
|
-
for (let t of e) i.includes(`export let ${t.export}`) || (i =
|
|
2701
|
+
for (let t of e) i.includes(`export let ${t.export}`) || (i = Lr(i, t), i = Rr(i, t), i = zr(i, t), i = Vr(i, t));
|
|
2694
2702
|
await v.writeFile(r, i, "utf-8");
|
|
2695
2703
|
}
|
|
2696
|
-
function
|
|
2704
|
+
function Lr(e, t) {
|
|
2697
2705
|
let n = `import { ${t.typeImport.name} } from "${t.typeImport.from}";`;
|
|
2698
2706
|
if (e.includes(`from "${t.typeImport.from}"`)) return e;
|
|
2699
2707
|
let r = e.lastIndexOf("import ");
|
|
@@ -2701,7 +2709,7 @@ function Ir(e, t) {
|
|
|
2701
2709
|
let i = e.indexOf("\n", e.indexOf(";", r));
|
|
2702
2710
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2703
2711
|
}
|
|
2704
|
-
function
|
|
2712
|
+
function Rr(e, t) {
|
|
2705
2713
|
let n = `export let ${t.export}: ${t.type};`, r = e.lastIndexOf("export let ");
|
|
2706
2714
|
if (r === -1) {
|
|
2707
2715
|
let t = e.indexOf("export const setupContext");
|
|
@@ -2710,15 +2718,15 @@ function Lr(e, t) {
|
|
|
2710
2718
|
let i = e.indexOf("\n", r);
|
|
2711
2719
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2712
2720
|
}
|
|
2713
|
-
function
|
|
2721
|
+
function zr(e, t) {
|
|
2714
2722
|
let n = ` ${t.export} = ${t.init};`, r = e.match(/export const setupContext\s*=\s*async\s*\([^)]*\)\s*=>\s*\{/);
|
|
2715
2723
|
if (!r) return e;
|
|
2716
2724
|
let i = e.indexOf("{", e.indexOf(r[0]));
|
|
2717
2725
|
if (i === -1) return e;
|
|
2718
|
-
let a =
|
|
2726
|
+
let a = Br(e, i);
|
|
2719
2727
|
return a === -1 ? e : e.slice(0, a) + n + "\n" + e.slice(a);
|
|
2720
2728
|
}
|
|
2721
|
-
function
|
|
2729
|
+
function Br(e, t) {
|
|
2722
2730
|
let n = 0;
|
|
2723
2731
|
for (let r = t; r < e.length; r++) {
|
|
2724
2732
|
let t = e[r];
|
|
@@ -2727,20 +2735,20 @@ function zr(e, t) {
|
|
|
2727
2735
|
}
|
|
2728
2736
|
return -1;
|
|
2729
2737
|
}
|
|
2730
|
-
function
|
|
2738
|
+
function Vr(e, t) {
|
|
2731
2739
|
let n = ` ${t.export}: ${t.type};`, r = e.indexOf("export type ContextVariables = {");
|
|
2732
2740
|
if (r === -1) return e;
|
|
2733
2741
|
let i = e.indexOf("};", r);
|
|
2734
2742
|
return i === -1 ? e : e.slice(0, i) + n + "\n" + e.slice(i);
|
|
2735
2743
|
}
|
|
2736
|
-
async function
|
|
2744
|
+
async function Hr(e, t, n) {
|
|
2737
2745
|
let r = w.resolve(n, X("{{enums.src}}", t), "index.ts");
|
|
2738
2746
|
if (!await Y(r)) return;
|
|
2739
2747
|
let i = await v.readFile(r, "utf-8");
|
|
2740
|
-
for (let t of e) i.includes(`from "${t.from}"`) || (i =
|
|
2748
|
+
for (let t of e) i.includes(`from "${t.from}"`) || (i = Ur(i, t));
|
|
2741
2749
|
await v.writeFile(r, i, "utf-8");
|
|
2742
2750
|
}
|
|
2743
|
-
function
|
|
2751
|
+
function Ur(e, t) {
|
|
2744
2752
|
let n = `export * from "${t.from}";`, r = e.lastIndexOf("export * from");
|
|
2745
2753
|
if (r !== -1) {
|
|
2746
2754
|
let t = e.indexOf("\n", r);
|
|
@@ -2748,14 +2756,14 @@ function Hr(e, t) {
|
|
|
2748
2756
|
}
|
|
2749
2757
|
return e.trim() === "" ? n + "\n" : e.trimEnd() + "\n" + n + "\n";
|
|
2750
2758
|
}
|
|
2751
|
-
async function
|
|
2759
|
+
async function Wr(e, t, n) {
|
|
2752
2760
|
let r = X("{{backend.root}}", t), i = w.resolve(n, r, "src/sockets/index.ts");
|
|
2753
2761
|
if (!await Y(i)) return;
|
|
2754
2762
|
let a = await v.readFile(i, "utf-8");
|
|
2755
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2756
|
-
await Y(w.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a =
|
|
2763
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = Gr(a, t), a = Kr(a, t));
|
|
2764
|
+
await Y(w.resolve(n, r, "src/libs/websocket/ws-authenticate.ts")) && (a = qr(a)), await v.writeFile(i, a, "utf-8");
|
|
2757
2765
|
}
|
|
2758
|
-
function
|
|
2766
|
+
function Gr(e, t) {
|
|
2759
2767
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("from \"./");
|
|
2760
2768
|
if (r !== -1) {
|
|
2761
2769
|
let t = e.indexOf("\n", r);
|
|
@@ -2764,7 +2772,7 @@ function Wr(e, t) {
|
|
|
2764
2772
|
let i = e.indexOf("const sockets");
|
|
2765
2773
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2766
2774
|
}
|
|
2767
|
-
function
|
|
2775
|
+
function Kr(e, t) {
|
|
2768
2776
|
let n = `.socket("${t.prefix}", ${t.import})`, r = e.indexOf("const sockets");
|
|
2769
2777
|
if (r === -1) return e;
|
|
2770
2778
|
let i = e.indexOf("new SocketRouter", r);
|
|
@@ -2778,7 +2786,7 @@ function Gr(e, t) {
|
|
|
2778
2786
|
}
|
|
2779
2787
|
return e;
|
|
2780
2788
|
}
|
|
2781
|
-
function
|
|
2789
|
+
function qr(e) {
|
|
2782
2790
|
if (e.includes("wsAuthenticate")) return e;
|
|
2783
2791
|
let t = e.indexOf("from \"@backend/libs/websocket/socket-router\""), n = e;
|
|
2784
2792
|
if (t !== -1) {
|
|
@@ -2787,14 +2795,14 @@ function Kr(e) {
|
|
|
2787
2795
|
}
|
|
2788
2796
|
return n.replace("new SocketRouter()", "new SocketRouter({ authenticate: wsAuthenticate })");
|
|
2789
2797
|
}
|
|
2790
|
-
async function
|
|
2798
|
+
async function Jr(e, t, n) {
|
|
2791
2799
|
let r = X("{{frontend.root}}", t), i = w.resolve(n, r, "src/api/sdk.ts");
|
|
2792
2800
|
if (!await Y(i)) return;
|
|
2793
2801
|
let a = await v.readFile(i, "utf-8");
|
|
2794
|
-
for (let t of e) a.includes(`.$configure(${t.import})`) || (a =
|
|
2802
|
+
for (let t of e) a.includes(`.$configure(${t.import})`) || (a = Yr(a, t), a = Xr(a, t));
|
|
2795
2803
|
await v.writeFile(i, a, "utf-8");
|
|
2796
2804
|
}
|
|
2797
|
-
function
|
|
2805
|
+
function Yr(e, t) {
|
|
2798
2806
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2799
2807
|
if (e.includes(n)) return e;
|
|
2800
2808
|
let r = e.lastIndexOf("from \"./");
|
|
@@ -2805,57 +2813,67 @@ function Jr(e, t) {
|
|
|
2805
2813
|
let i = e.indexOf("export const sdk");
|
|
2806
2814
|
return i === -1 ? e : e.slice(0, i) + n + "\n\n" + e.slice(i);
|
|
2807
2815
|
}
|
|
2808
|
-
function
|
|
2816
|
+
function Xr(e, t) {
|
|
2809
2817
|
let n = `.$configure(${t.import})`, r = e.indexOf("export const sdk");
|
|
2810
2818
|
if (r === -1) return e;
|
|
2811
2819
|
let i = e.indexOf(";", r);
|
|
2812
2820
|
return i === -1 ? e : e.slice(0, i) + "\n " + n + e.slice(i);
|
|
2813
2821
|
}
|
|
2814
|
-
async function
|
|
2822
|
+
async function Zr(e, t, n) {
|
|
2815
2823
|
let r = w.resolve(n, X("{{backend.utils}}", t), "frontend-url/frontend-url.ts");
|
|
2816
2824
|
if (!await Y(r)) return;
|
|
2817
2825
|
let i = await v.readFile(r, "utf-8");
|
|
2818
|
-
for (let t of e) i.includes(`"${t.path}"`) || (i =
|
|
2826
|
+
for (let t of e) i.includes(`"${t.path}"`) || (i = Qr(i, t));
|
|
2819
2827
|
await v.writeFile(r, i, "utf-8");
|
|
2820
2828
|
}
|
|
2821
|
-
function
|
|
2829
|
+
function Qr(e, t) {
|
|
2822
2830
|
let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
|
|
2823
2831
|
if (r === -1) return e;
|
|
2824
|
-
let i = e.indexOf("
|
|
2825
|
-
|
|
2832
|
+
let i = e.indexOf("{", r);
|
|
2833
|
+
if (i === -1) return e;
|
|
2834
|
+
let a = 0, o = -1;
|
|
2835
|
+
for (let t = i; t < e.length; t++) {
|
|
2836
|
+
let n = e[t];
|
|
2837
|
+
if (n === "{") a += 1;
|
|
2838
|
+
else if (n === "}" && (--a, a === 0)) {
|
|
2839
|
+
o = t;
|
|
2840
|
+
break;
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
return o === -1 ? e : e.slice(0, o) + n + "\n" + e.slice(o);
|
|
2826
2844
|
}
|
|
2827
|
-
var
|
|
2845
|
+
var $r = "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", ei = {
|
|
2828
2846
|
primary: "primaryNav",
|
|
2829
2847
|
secondary: "secondaryNav",
|
|
2830
2848
|
tertiary: "tertiaryNav",
|
|
2831
2849
|
settings: "settingsNav"
|
|
2832
2850
|
};
|
|
2833
|
-
async function
|
|
2834
|
-
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2835
|
-
await Y(o) ? s = await v.readFile(o, "utf-8") : (await v.mkdir(w.dirname(o), { recursive: !0 }), s =
|
|
2836
|
-
for (let e of t) s.includes(`label: "${e.label}"`) || (s =
|
|
2837
|
-
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s =
|
|
2851
|
+
async function ti(e) {
|
|
2852
|
+
let { entries: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Dr(i, n), o = w.resolve(r, a, "src/constants/nav.constants.ts"), s;
|
|
2853
|
+
await Y(o) ? s = await v.readFile(o, "utf-8") : (await v.mkdir(w.dirname(o), { recursive: !0 }), s = $r);
|
|
2854
|
+
for (let e of t) s.includes(`label: "${e.label}"`) || (s = ii(s, e));
|
|
2855
|
+
for (let e of t.toReversed()) s.includes(`label: "${e.label}"`) || (s = oi(s, e));
|
|
2838
2856
|
await v.writeFile(o, s, "utf-8");
|
|
2839
2857
|
}
|
|
2840
|
-
async function
|
|
2841
|
-
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a =
|
|
2858
|
+
async function ni(e) {
|
|
2859
|
+
let { postLoginRedirect: t, paths: n, projectRoot: r, slot: i = "frontend" } = e, a = Dr(i, n), o = w.resolve(r, a, "src/features/auth/constants/auth.constants.ts");
|
|
2842
2860
|
if (!await Y(o)) return;
|
|
2843
2861
|
let s = await v.readFile(o, "utf-8"), c = /export const POST_LOGIN_REDIRECT_PATH = "[^"]*";/;
|
|
2844
2862
|
if (!c.test(s)) return;
|
|
2845
2863
|
let l = s.replace(c, `export const POST_LOGIN_REDIRECT_PATH = "${t}";`);
|
|
2846
2864
|
await v.writeFile(o, l, "utf-8");
|
|
2847
2865
|
}
|
|
2848
|
-
function
|
|
2866
|
+
function ri(e) {
|
|
2849
2867
|
let t = [e.icon];
|
|
2850
2868
|
if (e.items) for (let n of e.items) t.includes(n.icon) || t.push(n.icon);
|
|
2851
2869
|
return t;
|
|
2852
2870
|
}
|
|
2853
|
-
function
|
|
2854
|
-
let n =
|
|
2855
|
-
for (let e of n) r =
|
|
2871
|
+
function ii(e, t) {
|
|
2872
|
+
let n = ri(t), r = e;
|
|
2873
|
+
for (let e of n) r = ai(r, e);
|
|
2856
2874
|
return r;
|
|
2857
2875
|
}
|
|
2858
|
-
function
|
|
2876
|
+
function ai(e, t) {
|
|
2859
2877
|
let n = e.match(/import \{([^}]+)\} from "lucide-react";/);
|
|
2860
2878
|
if (!n) return e;
|
|
2861
2879
|
let r = n[1].split(",").map((e) => e.trim()).filter(Boolean);
|
|
@@ -2863,21 +2881,21 @@ function ii(e, t) {
|
|
|
2863
2881
|
let i = r.findIndex((e) => e.startsWith("type "));
|
|
2864
2882
|
return i === -1 ? r.push(t) : r.splice(i, 0, t), e.replace(n[0], `import { ${r.join(", ")} } from "lucide-react";`);
|
|
2865
2883
|
}
|
|
2866
|
-
function
|
|
2867
|
-
let n =
|
|
2884
|
+
function oi(e, t) {
|
|
2885
|
+
let n = ei[t.group];
|
|
2868
2886
|
if (!n) return e;
|
|
2869
|
-
let r =
|
|
2887
|
+
let r = ci(t), i = RegExp(`export const ${n}: NavEntry\\[\\] = \\[`), a = e.match(i);
|
|
2870
2888
|
if (!a) return e;
|
|
2871
|
-
let o = e.indexOf(a[0]) + a[0].length, s =
|
|
2889
|
+
let o = e.indexOf(a[0]) + a[0].length, s = si(e, o - 1);
|
|
2872
2890
|
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);
|
|
2873
2891
|
}
|
|
2874
|
-
function
|
|
2892
|
+
function si(e, t) {
|
|
2875
2893
|
let n = 0;
|
|
2876
2894
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2877
2895
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2878
2896
|
return -1;
|
|
2879
2897
|
}
|
|
2880
|
-
function
|
|
2898
|
+
function ci(e) {
|
|
2881
2899
|
let t = [];
|
|
2882
2900
|
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) {
|
|
2883
2901
|
t.push(" items: [");
|
|
@@ -2893,14 +2911,14 @@ function si(e) {
|
|
|
2893
2911
|
} else t.push(" items: [],");
|
|
2894
2912
|
return t.push(" },"), t.join("\n");
|
|
2895
2913
|
}
|
|
2896
|
-
async function
|
|
2914
|
+
async function li(e, t, n) {
|
|
2897
2915
|
let r = X("{{backend.features}}", t), i = w.resolve(n, r, "organizations/modules/setup-organization/steps/index.ts");
|
|
2898
2916
|
if (!await Y(i)) return;
|
|
2899
2917
|
let a = await v.readFile(i, "utf-8");
|
|
2900
|
-
for (let t of e) a.includes(`from "${t.from}"`) || (a =
|
|
2918
|
+
for (let t of e) a.includes(`from "${t.from}"`) || (a = ui(a, t), a = di(a, t));
|
|
2901
2919
|
await v.writeFile(i, a, "utf-8");
|
|
2902
2920
|
}
|
|
2903
|
-
function
|
|
2921
|
+
function ui(e, t) {
|
|
2904
2922
|
let n = `import { ${t.import} } from "${t.from}";`, r = e.lastIndexOf("import ");
|
|
2905
2923
|
if (r !== -1) {
|
|
2906
2924
|
let t = e.indexOf("\n", e.indexOf(";", r));
|
|
@@ -2908,38 +2926,38 @@ function li(e, t) {
|
|
|
2908
2926
|
}
|
|
2909
2927
|
return e.indexOf("type "), n + "\n\n" + e;
|
|
2910
2928
|
}
|
|
2911
|
-
function
|
|
2929
|
+
function di(e, t) {
|
|
2912
2930
|
let n = ` { id: "${t.id}", execute: (ctx) => ${t.import}(ctx) },`, r = e.match(/export const steps:\s*Step\[\]\s*=\s*\[/);
|
|
2913
2931
|
if (!r) return e;
|
|
2914
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2932
|
+
let i = e.indexOf(r[0]) + r[0].length, a = fi(e, i - 1);
|
|
2915
2933
|
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);
|
|
2916
2934
|
}
|
|
2917
|
-
function
|
|
2935
|
+
function fi(e, t) {
|
|
2918
2936
|
let n = 0;
|
|
2919
2937
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2920
2938
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2921
2939
|
return -1;
|
|
2922
2940
|
}
|
|
2923
|
-
var
|
|
2924
|
-
async function
|
|
2925
|
-
await
|
|
2941
|
+
var pi = "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";
|
|
2942
|
+
async function mi(e) {
|
|
2943
|
+
await gi({
|
|
2926
2944
|
...e,
|
|
2927
2945
|
arrayName: "navbarActions"
|
|
2928
2946
|
});
|
|
2929
2947
|
}
|
|
2930
|
-
async function
|
|
2931
|
-
await
|
|
2948
|
+
async function hi(e) {
|
|
2949
|
+
await gi({
|
|
2932
2950
|
...e,
|
|
2933
2951
|
arrayName: "userMenuActions"
|
|
2934
2952
|
});
|
|
2935
2953
|
}
|
|
2936
|
-
async function
|
|
2937
|
-
let a =
|
|
2938
|
-
await Y(o) ? s = await v.readFile(o, "utf-8") : (await v.mkdir(w.dirname(o), { recursive: !0 }), s =
|
|
2939
|
-
for (let n of e) s =
|
|
2954
|
+
async function gi({ actions: e, arrayName: t, paths: n, projectRoot: r, slot: i }) {
|
|
2955
|
+
let a = Dr(i, n), o = w.resolve(r, a, "src/constants/navbar-actions.tsx"), s;
|
|
2956
|
+
await Y(o) ? s = await v.readFile(o, "utf-8") : (await v.mkdir(w.dirname(o), { recursive: !0 }), s = pi);
|
|
2957
|
+
for (let n of e) s = _i(s, n), s = vi(s, n, t);
|
|
2940
2958
|
await v.writeFile(o, s, "utf-8");
|
|
2941
2959
|
}
|
|
2942
|
-
function
|
|
2960
|
+
function _i(e, t) {
|
|
2943
2961
|
let n = `import { ${t.import} } from "${t.from}";`;
|
|
2944
2962
|
if (e.includes(n)) return e;
|
|
2945
2963
|
let r = e.lastIndexOf("import ");
|
|
@@ -2947,38 +2965,38 @@ function gi(e, t) {
|
|
|
2947
2965
|
let i = e.indexOf("\n", r);
|
|
2948
2966
|
return i === -1 ? e + "\n" + n : e.slice(0, i + 1) + n + "\n" + e.slice(i + 1);
|
|
2949
2967
|
}
|
|
2950
|
-
function
|
|
2968
|
+
function vi(e, t, n) {
|
|
2951
2969
|
let r = e.match(RegExp(`export const ${n}:\\s*NavbarAction\\[\\]\\s*=\\s*\\[`));
|
|
2952
2970
|
if (!r) return e;
|
|
2953
|
-
let i = e.indexOf(r[0]) + r[0].length, a =
|
|
2971
|
+
let i = e.indexOf(r[0]) + r[0].length, a = yi(e, i - 1);
|
|
2954
2972
|
if (a === -1) return e;
|
|
2955
2973
|
let o = e.slice(i, a);
|
|
2956
2974
|
if (o.includes(`id: "${t.id}"`)) return e;
|
|
2957
2975
|
let s = ` { id: "${t.id}", component: ${t.import} },`;
|
|
2958
2976
|
return o.trim() === "" ? e.slice(0, a) + "\n" + s + "\n" + e.slice(a) : e.slice(0, a) + s + "\n" + e.slice(a);
|
|
2959
2977
|
}
|
|
2960
|
-
function
|
|
2978
|
+
function yi(e, t) {
|
|
2961
2979
|
let n = 0;
|
|
2962
2980
|
for (let r = t; r < e.length; r++) if (e[r] === "[") n++;
|
|
2963
2981
|
else if (e[r] === "]" && (n--, n === 0)) return r;
|
|
2964
2982
|
return -1;
|
|
2965
2983
|
}
|
|
2966
|
-
var
|
|
2984
|
+
var bi = new Set([
|
|
2967
2985
|
".ts",
|
|
2968
2986
|
".tsx",
|
|
2969
2987
|
".js",
|
|
2970
2988
|
".jsx"
|
|
2971
2989
|
]);
|
|
2972
|
-
async function
|
|
2990
|
+
async function xi(e) {
|
|
2973
2991
|
let { files: t, paths: n, projectRoot: r, projectName: i } = e;
|
|
2974
2992
|
if (i === "hype-stack") return;
|
|
2975
2993
|
let a = `@${i}/`;
|
|
2976
2994
|
await Promise.all(t.map(async (e) => {
|
|
2977
|
-
let t =
|
|
2978
|
-
i?.isDirectory() ? await
|
|
2995
|
+
let t = xr(e.target, n, r), i = await v.stat(t).catch(() => null);
|
|
2996
|
+
i?.isDirectory() ? await wi(t, a) : i?.isFile() && bi.has(w.extname(t)) && await Ti(t, a);
|
|
2979
2997
|
}));
|
|
2980
2998
|
}
|
|
2981
|
-
var
|
|
2999
|
+
var Si = new Set([
|
|
2982
3000
|
".git",
|
|
2983
3001
|
"node_modules",
|
|
2984
3002
|
"dist",
|
|
@@ -2987,48 +3005,62 @@ var xi = new Set([
|
|
|
2987
3005
|
".next",
|
|
2988
3006
|
"coverage"
|
|
2989
3007
|
]);
|
|
2990
|
-
async function Si(e, t) {
|
|
2991
|
-
t !== "hype-stack" && await Ci(e, `@${t}/`);
|
|
2992
|
-
}
|
|
2993
3008
|
async function Ci(e, t) {
|
|
3009
|
+
t !== "hype-stack" && await wi(e, `@${t}/`);
|
|
3010
|
+
}
|
|
3011
|
+
async function wi(e, t) {
|
|
2994
3012
|
let n = await v.readdir(e, { withFileTypes: !0 });
|
|
2995
3013
|
await Promise.all(n.map(async (n) => {
|
|
2996
3014
|
let r = w.join(e, n.name);
|
|
2997
3015
|
if (n.isDirectory()) {
|
|
2998
|
-
if (
|
|
2999
|
-
await
|
|
3000
|
-
} else n.isFile() &&
|
|
3016
|
+
if (Si.has(n.name)) return;
|
|
3017
|
+
await wi(r, t);
|
|
3018
|
+
} else n.isFile() && bi.has(w.extname(n.name)) && await Ti(r, t);
|
|
3001
3019
|
}));
|
|
3002
3020
|
}
|
|
3003
|
-
async function
|
|
3021
|
+
async function Ti(e, t) {
|
|
3004
3022
|
let n = await v.readFile(e, "utf-8");
|
|
3005
|
-
if (!n.includes(
|
|
3006
|
-
let r = n.replaceAll(
|
|
3023
|
+
if (!n.includes(Er)) return;
|
|
3024
|
+
let r = n.replaceAll(Er, t);
|
|
3007
3025
|
await v.writeFile(e, r, "utf-8");
|
|
3008
3026
|
}
|
|
3009
3027
|
//#endregion
|
|
3010
3028
|
//#region src/core/installer.ts
|
|
3011
|
-
function
|
|
3029
|
+
function Ei(e, t) {
|
|
3012
3030
|
return e.slot ? t ? t.includes(e.slot) : e.slot === "frontend" : !0;
|
|
3013
3031
|
}
|
|
3014
|
-
async function
|
|
3032
|
+
async function Di(e, t) {
|
|
3015
3033
|
if ((await v.stat(e)).isDirectory()) {
|
|
3016
3034
|
await v.mkdir(t, { recursive: !0 });
|
|
3017
3035
|
let n = await v.readdir(e, { withFileTypes: !0 });
|
|
3018
|
-
for (let r of n) await
|
|
3036
|
+
for (let r of n) await Di(w.join(e, r.name), w.join(t, r.name));
|
|
3019
3037
|
} else await v.mkdir(w.dirname(t), { recursive: !0 }), await v.copyFile(e, t);
|
|
3020
3038
|
}
|
|
3021
|
-
async function
|
|
3022
|
-
let {
|
|
3039
|
+
async function Oi(e) {
|
|
3040
|
+
let { src: t, dest: n, projectRoot: r, skip: i } = e;
|
|
3041
|
+
if ((await v.stat(t)).isDirectory()) {
|
|
3042
|
+
await v.mkdir(n, { recursive: !0 });
|
|
3043
|
+
let e = await v.readdir(t, { withFileTypes: !0 });
|
|
3044
|
+
return (await Promise.all(e.map((e) => Oi({
|
|
3045
|
+
src: w.join(t, e.name),
|
|
3046
|
+
dest: w.join(n, e.name),
|
|
3047
|
+
projectRoot: r,
|
|
3048
|
+
skip: i
|
|
3049
|
+
})))).flat();
|
|
3050
|
+
}
|
|
3051
|
+
return i.has(t) ? [] : (await v.mkdir(w.dirname(n), { recursive: !0 }), await v.copyFile(t, n), [w.relative(r, n)]);
|
|
3052
|
+
}
|
|
3053
|
+
async function ki(e) {
|
|
3054
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = Sr(t.source, n), o = xr(t.target, r, i);
|
|
3023
3055
|
return {
|
|
3024
3056
|
sourcePath: a,
|
|
3025
3057
|
targetPath: o,
|
|
3026
|
-
sourceExists: await Y(a) || await
|
|
3027
|
-
targetExists: await Y(o) || await
|
|
3058
|
+
sourceExists: await Y(a) || await J(a),
|
|
3059
|
+
targetExists: await Y(o) || await J(o)
|
|
3028
3060
|
};
|
|
3029
3061
|
}
|
|
3030
|
-
async function
|
|
3031
|
-
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await
|
|
3062
|
+
async function Ai(e) {
|
|
3063
|
+
let { file: t, packDir: n, paths: r, projectRoot: i } = e, { sourcePath: a, targetPath: o, sourceExists: s, targetExists: c } = await ki({
|
|
3032
3064
|
file: t,
|
|
3033
3065
|
packDir: n,
|
|
3034
3066
|
paths: r,
|
|
@@ -3043,8 +3075,8 @@ async function Oi(e) {
|
|
|
3043
3075
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3044
3076
|
}
|
|
3045
3077
|
}
|
|
3046
|
-
async function
|
|
3047
|
-
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await
|
|
3078
|
+
async function ji(e) {
|
|
3079
|
+
let { file: t, packDir: n, paths: r, projectRoot: i, force: a, overwrite: o } = e, { sourcePath: s, targetPath: c, sourceExists: l, targetExists: u } = await ki({
|
|
3048
3080
|
file: t,
|
|
3049
3081
|
packDir: n,
|
|
3050
3082
|
paths: r,
|
|
@@ -3062,7 +3094,7 @@ async function ki(e) {
|
|
|
3062
3094
|
status: "skipped",
|
|
3063
3095
|
path: t.target,
|
|
3064
3096
|
reason: "Already exists"
|
|
3065
|
-
} : (await
|
|
3097
|
+
} : (await Di(s, c), {
|
|
3066
3098
|
status: "installed",
|
|
3067
3099
|
path: t.target
|
|
3068
3100
|
});
|
|
@@ -3071,16 +3103,16 @@ async function ki(e) {
|
|
|
3071
3103
|
status: "skipped",
|
|
3072
3104
|
path: t.target,
|
|
3073
3105
|
reason: "Already exists (skip-if-exists)"
|
|
3074
|
-
} : (await
|
|
3106
|
+
} : (await Di(s, c), {
|
|
3075
3107
|
status: "installed",
|
|
3076
3108
|
path: t.target
|
|
3077
3109
|
});
|
|
3078
|
-
case "override": return await
|
|
3110
|
+
case "override": return await Di(s, c), {
|
|
3079
3111
|
status: "installed",
|
|
3080
3112
|
path: t.target
|
|
3081
3113
|
};
|
|
3082
3114
|
case "merge": {
|
|
3083
|
-
if (!u) return await
|
|
3115
|
+
if (!u) return await Di(s, c), {
|
|
3084
3116
|
status: "installed",
|
|
3085
3117
|
path: t.target
|
|
3086
3118
|
};
|
|
@@ -3110,15 +3142,15 @@ async function ki(e) {
|
|
|
3110
3142
|
};
|
|
3111
3143
|
}
|
|
3112
3144
|
}
|
|
3113
|
-
async function
|
|
3145
|
+
async function Mi(e) {
|
|
3114
3146
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3115
3147
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3116
3148
|
let o = [], s = /* @__PURE__ */ new Set();
|
|
3117
3149
|
for (let e of t) {
|
|
3118
3150
|
let t = i?.get(e.manifest.name);
|
|
3119
3151
|
for (let n of e.manifest.files) {
|
|
3120
|
-
if (n.strategy !== "create" || !
|
|
3121
|
-
let { targetPath: i, targetExists: c } = await
|
|
3152
|
+
if (n.strategy !== "create" || !Ei(n, t)) continue;
|
|
3153
|
+
let { targetPath: i, targetExists: c } = await ki({
|
|
3122
3154
|
file: n,
|
|
3123
3155
|
packDir: e.packDir,
|
|
3124
3156
|
paths: a,
|
|
@@ -3133,13 +3165,13 @@ async function Ai(e) {
|
|
|
3133
3165
|
}
|
|
3134
3166
|
return o;
|
|
3135
3167
|
}
|
|
3136
|
-
async function
|
|
3168
|
+
async function Ni(e) {
|
|
3137
3169
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3138
3170
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3139
3171
|
let c = [];
|
|
3140
3172
|
for (let e of t.files) {
|
|
3141
|
-
if (!
|
|
3142
|
-
let t = await
|
|
3173
|
+
if (!Ei(e, o)) continue;
|
|
3174
|
+
let t = await Ai({
|
|
3143
3175
|
file: e,
|
|
3144
3176
|
packDir: a,
|
|
3145
3177
|
paths: s,
|
|
@@ -3150,16 +3182,16 @@ async function ji(e) {
|
|
|
3150
3182
|
}
|
|
3151
3183
|
return c;
|
|
3152
3184
|
}
|
|
3153
|
-
async function
|
|
3185
|
+
async function Pi(e) {
|
|
3154
3186
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3155
3187
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3156
3188
|
let l = {
|
|
3157
3189
|
installed: [],
|
|
3158
3190
|
skipped: [],
|
|
3159
3191
|
errors: []
|
|
3160
|
-
}, u = t.files.filter((e) =>
|
|
3192
|
+
}, u = t.files.filter((e) => Ei(e, s));
|
|
3161
3193
|
for (let e of u) {
|
|
3162
|
-
let t = await
|
|
3194
|
+
let t = await ji({
|
|
3163
3195
|
file: e,
|
|
3164
3196
|
packDir: o,
|
|
3165
3197
|
paths: c,
|
|
@@ -3179,40 +3211,40 @@ async function Mi(e) {
|
|
|
3179
3211
|
break;
|
|
3180
3212
|
}
|
|
3181
3213
|
}
|
|
3182
|
-
await
|
|
3214
|
+
await xi({
|
|
3183
3215
|
files: u,
|
|
3184
3216
|
paths: c,
|
|
3185
3217
|
projectRoot: r,
|
|
3186
3218
|
projectName: n.name
|
|
3187
|
-
}), t.env && t.env.length > 0 && await
|
|
3219
|
+
}), t.env && t.env.length > 0 && await Or(t.env, c, r), t.routes && t.routes.length > 0 && await Nr(t.routes, c, r), t.context && t.context.length > 0 && await Ir(t.context, c, r), t.sockets && t.sockets.length > 0 && await Wr(t.sockets, c, r), t.sdkConfigurations && t.sdkConfigurations.length > 0 && await Jr(t.sdkConfigurations, c, r), t.enums && t.enums.length > 0 && await Hr(t.enums, c, r), t.frontendRoutes && t.frontendRoutes.length > 0 && await Zr(t.frontendRoutes, c, r);
|
|
3188
3220
|
let d = s && s.length > 0 ? s : ["frontend"];
|
|
3189
|
-
for (let e of d) t.nav && t.nav.length > 0 && await
|
|
3221
|
+
for (let e of d) t.nav && t.nav.length > 0 && await ti({
|
|
3190
3222
|
entries: t.nav,
|
|
3191
3223
|
paths: c,
|
|
3192
3224
|
projectRoot: r,
|
|
3193
3225
|
slot: e
|
|
3194
|
-
}), t.navbarActions && t.navbarActions.length > 0 && await
|
|
3226
|
+
}), t.navbarActions && t.navbarActions.length > 0 && await mi({
|
|
3195
3227
|
actions: t.navbarActions,
|
|
3196
3228
|
paths: c,
|
|
3197
3229
|
projectRoot: r,
|
|
3198
3230
|
slot: e
|
|
3199
|
-
}), t.userMenuActions && t.userMenuActions.length > 0 && await
|
|
3231
|
+
}), t.userMenuActions && t.userMenuActions.length > 0 && await hi({
|
|
3200
3232
|
actions: t.userMenuActions,
|
|
3201
3233
|
paths: c,
|
|
3202
3234
|
projectRoot: r,
|
|
3203
3235
|
slot: e
|
|
3204
3236
|
});
|
|
3205
|
-
return t.onboardingSteps && t.onboardingSteps.length > 0 && await
|
|
3237
|
+
return t.onboardingSteps && t.onboardingSteps.length > 0 && await li(t.onboardingSteps, c, r), t.postLoginRedirect && await ni({
|
|
3206
3238
|
postLoginRedirect: t.postLoginRedirect,
|
|
3207
3239
|
paths: c,
|
|
3208
3240
|
projectRoot: r,
|
|
3209
3241
|
slot: d[0]
|
|
3210
3242
|
}), l;
|
|
3211
3243
|
}
|
|
3212
|
-
async function
|
|
3244
|
+
async function Fi(e) {
|
|
3213
3245
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3214
3246
|
for (let e of t) {
|
|
3215
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3247
|
+
let t = o?.get(e.manifest.name), a = await Ni({
|
|
3216
3248
|
manifest: e.manifest,
|
|
3217
3249
|
config: n,
|
|
3218
3250
|
projectRoot: r,
|
|
@@ -3232,7 +3264,7 @@ async function Ni(e) {
|
|
|
3232
3264
|
};
|
|
3233
3265
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3234
3266
|
for (let e of t) {
|
|
3235
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3267
|
+
let t = o?.get(e.manifest.name), n = await Pi({
|
|
3236
3268
|
manifest: e.manifest,
|
|
3237
3269
|
config: f,
|
|
3238
3270
|
projectRoot: r,
|
|
@@ -3241,7 +3273,7 @@ async function Ni(e) {
|
|
|
3241
3273
|
packDir: e.packDir,
|
|
3242
3274
|
slots: t
|
|
3243
3275
|
});
|
|
3244
|
-
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await
|
|
3276
|
+
c.push(...n.installed), l.push(...n.skipped), u.push(...n.errors), f = await Ii(f, e.manifest.name, r), d.push(e.manifest.name);
|
|
3245
3277
|
}
|
|
3246
3278
|
return {
|
|
3247
3279
|
installed: c,
|
|
@@ -3252,19 +3284,34 @@ async function Ni(e) {
|
|
|
3252
3284
|
config: f
|
|
3253
3285
|
};
|
|
3254
3286
|
}
|
|
3255
|
-
async function
|
|
3287
|
+
async function Ii(e, t, n) {
|
|
3256
3288
|
let r = {
|
|
3257
3289
|
...e,
|
|
3258
3290
|
installedPacks: [...e.installedPacks ?? [], t]
|
|
3259
3291
|
};
|
|
3260
|
-
return await
|
|
3292
|
+
return await mr(n, r), r;
|
|
3261
3293
|
}
|
|
3262
|
-
async function
|
|
3294
|
+
async function Li(e) {
|
|
3263
3295
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3264
3296
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3265
|
-
let o = [], s = [];
|
|
3266
|
-
|
|
3267
|
-
let
|
|
3297
|
+
let o = [], s = [], c = t.files.filter((e) => e.strategy === "merge"), l = new Set(c.map((e) => Sr(e.source, i))), u = w.join(i, "files");
|
|
3298
|
+
if (await J(u)) {
|
|
3299
|
+
let e = await v.readdir(u, { withFileTypes: !0 });
|
|
3300
|
+
for (let t of e) {
|
|
3301
|
+
if (!t.isDirectory()) continue;
|
|
3302
|
+
let e = a[t.name]?.root;
|
|
3303
|
+
if (!e) continue;
|
|
3304
|
+
let n = await Oi({
|
|
3305
|
+
src: w.join(u, t.name),
|
|
3306
|
+
dest: w.resolve(r, e),
|
|
3307
|
+
projectRoot: r,
|
|
3308
|
+
skip: l
|
|
3309
|
+
});
|
|
3310
|
+
o.push(...n);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
for (let e of c) {
|
|
3314
|
+
let t = await ji({
|
|
3268
3315
|
file: e,
|
|
3269
3316
|
packDir: i,
|
|
3270
3317
|
paths: a,
|
|
@@ -3272,21 +3319,14 @@ async function Fi(e) {
|
|
|
3272
3319
|
force: !0,
|
|
3273
3320
|
overwrite: /* @__PURE__ */ new Set()
|
|
3274
3321
|
});
|
|
3275
|
-
|
|
3276
|
-
case "installed":
|
|
3277
|
-
o.push(t.path);
|
|
3278
|
-
break;
|
|
3279
|
-
case "error":
|
|
3280
|
-
s.push(`${t.path}: ${t.reason}`);
|
|
3281
|
-
break;
|
|
3282
|
-
case "skipped": break;
|
|
3283
|
-
}
|
|
3322
|
+
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3284
3323
|
}
|
|
3285
|
-
|
|
3324
|
+
let d = w.join(xr("{{frontend.root}}", a, r), "src", "routes"), f = w.join(d, "(public)", "index.tsx"), p = w.join(d, "(private)", "index.tsx");
|
|
3325
|
+
return await Y(f) && await Y(p) && await v.rm(p, { force: !0 }), t.frontendRoutes && t.frontendRoutes.length > 0 && await Zr(t.frontendRoutes, a, r), t.nav && t.nav.length > 0 && await ti({
|
|
3286
3326
|
entries: t.nav,
|
|
3287
3327
|
paths: a,
|
|
3288
3328
|
projectRoot: r
|
|
3289
|
-
}), t.postLoginRedirect && await
|
|
3329
|
+
}), t.postLoginRedirect && await ni({
|
|
3290
3330
|
postLoginRedirect: t.postLoginRedirect,
|
|
3291
3331
|
paths: a,
|
|
3292
3332
|
projectRoot: r
|
|
@@ -3297,28 +3337,28 @@ async function Fi(e) {
|
|
|
3297
3337
|
}
|
|
3298
3338
|
//#endregion
|
|
3299
3339
|
//#region src/core/pack-categories.ts
|
|
3300
|
-
var
|
|
3340
|
+
var Ri = [
|
|
3301
3341
|
"starter",
|
|
3302
3342
|
"layout",
|
|
3303
3343
|
"feature"
|
|
3304
|
-
],
|
|
3344
|
+
], zi = {
|
|
3305
3345
|
starter: "Starter",
|
|
3306
3346
|
layout: "Layout",
|
|
3307
3347
|
feature: "Features"
|
|
3308
|
-
},
|
|
3309
|
-
function
|
|
3348
|
+
}, Bi = new Set(["starter", "layout"]), Vi = "layout-basic";
|
|
3349
|
+
function Hi(e, t = {}) {
|
|
3310
3350
|
let n = [];
|
|
3311
|
-
for (let r of
|
|
3351
|
+
for (let r of Ri) {
|
|
3312
3352
|
let i = e.filter((e) => e.category === r);
|
|
3313
3353
|
if (i.length === 0) continue;
|
|
3314
|
-
let a =
|
|
3354
|
+
let a = Bi.has(r) ? "single" : "multiple";
|
|
3315
3355
|
if (r === "layout") {
|
|
3316
|
-
n.push(
|
|
3356
|
+
n.push(Ui("frontend", i)), t.adminAvailable && n.push(Ui("admin", i));
|
|
3317
3357
|
continue;
|
|
3318
3358
|
}
|
|
3319
3359
|
n.push({
|
|
3320
3360
|
category: r,
|
|
3321
|
-
label:
|
|
3361
|
+
label: zi[r],
|
|
3322
3362
|
mode: a,
|
|
3323
3363
|
packs: i,
|
|
3324
3364
|
preselect: null
|
|
@@ -3326,20 +3366,20 @@ function Bi(e, t = {}) {
|
|
|
3326
3366
|
}
|
|
3327
3367
|
return n;
|
|
3328
3368
|
}
|
|
3329
|
-
function
|
|
3330
|
-
let n = t.some((e) => e.name ===
|
|
3369
|
+
function Ui(e, t) {
|
|
3370
|
+
let n = t.some((e) => e.name === Vi);
|
|
3331
3371
|
return {
|
|
3332
3372
|
category: "layout",
|
|
3333
3373
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3334
3374
|
mode: "single",
|
|
3335
3375
|
packs: t,
|
|
3336
|
-
preselect: n ?
|
|
3376
|
+
preselect: n ? Vi : null,
|
|
3337
3377
|
slot: e
|
|
3338
3378
|
};
|
|
3339
3379
|
}
|
|
3340
3380
|
//#endregion
|
|
3341
3381
|
//#region src/ui/logger.ts
|
|
3342
|
-
function
|
|
3382
|
+
function Wi(e) {
|
|
3343
3383
|
o.note(e.map((e) => `${R.arrow} ${e}`).join("\n"), "Next steps");
|
|
3344
3384
|
}
|
|
3345
3385
|
function Z() {
|
|
@@ -3347,28 +3387,34 @@ function Z() {
|
|
|
3347
3387
|
}
|
|
3348
3388
|
//#endregion
|
|
3349
3389
|
//#region src/core/post-setup.ts
|
|
3350
|
-
async function
|
|
3351
|
-
return (await
|
|
3390
|
+
async function Gi() {
|
|
3391
|
+
return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3352
3392
|
}
|
|
3353
|
-
async function
|
|
3393
|
+
async function Ki(e) {
|
|
3354
3394
|
return Y(`${e}/apps/backend/.env`);
|
|
3355
3395
|
}
|
|
3356
|
-
async function
|
|
3396
|
+
async function qi(e, t, n) {
|
|
3357
3397
|
let r = n ? `Start services with ${L.command("docker compose up -d")}?` : `Docker is not running. Start services with ${L.command("docker compose up -d")}?`, i = t ? !0 : await o.confirm({
|
|
3358
3398
|
message: r,
|
|
3359
3399
|
initialValue: !0
|
|
3360
3400
|
});
|
|
3361
3401
|
if (o.isCancel(i) && Z(), !i) return o.log.info(L.muted("Skipping Docker services and database migrations.")), !1;
|
|
3362
3402
|
let a = o.spinner();
|
|
3363
|
-
|
|
3403
|
+
a.start("Starting Docker services...");
|
|
3404
|
+
let s = await q("docker", [
|
|
3364
3405
|
"compose",
|
|
3365
3406
|
"up",
|
|
3366
3407
|
"-d"
|
|
3367
|
-
], { cwd: `${e}/apps/backend` })
|
|
3408
|
+
], { cwd: `${e}/apps/backend` });
|
|
3409
|
+
return s.exitCode === 0 ? (a.stop(L.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), Ji(s), !1);
|
|
3410
|
+
}
|
|
3411
|
+
function Ji(e) {
|
|
3412
|
+
let t = (e.stderr || e.stdout).trim();
|
|
3413
|
+
t && o.log.warn(L.muted(t));
|
|
3368
3414
|
}
|
|
3369
|
-
async function
|
|
3415
|
+
async function Yi(e, t = 15, n = 2e3) {
|
|
3370
3416
|
for (let r = 0; r < t; r++) {
|
|
3371
|
-
if ((await
|
|
3417
|
+
if ((await q("docker", [
|
|
3372
3418
|
"compose",
|
|
3373
3419
|
"exec",
|
|
3374
3420
|
"-T",
|
|
@@ -3381,15 +3427,15 @@ async function Ki(e, t = 15, n = 2e3) {
|
|
|
3381
3427
|
}
|
|
3382
3428
|
return !1;
|
|
3383
3429
|
}
|
|
3384
|
-
async function
|
|
3385
|
-
if (!await
|
|
3430
|
+
async function Xi(e, t, n = {}) {
|
|
3431
|
+
if (!await Ki(e)) {
|
|
3386
3432
|
o.log.warn(`${L.path(".env")} not found in ${L.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3387
3433
|
return;
|
|
3388
3434
|
}
|
|
3389
|
-
if (!await
|
|
3435
|
+
if (!await qi(e, t, await Gi())) return;
|
|
3390
3436
|
let r = o.spinner();
|
|
3391
|
-
if (r.start("Waiting for Postgres to be ready..."), !await
|
|
3392
|
-
r.
|
|
3437
|
+
if (r.start("Waiting for Postgres to be ready..."), !await Yi(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3)) {
|
|
3438
|
+
r.error("Postgres health check timed out"), o.log.warn(L.muted("Run migrations manually once Postgres is ready: pnpm --filter @internal/backend migration:latest"));
|
|
3393
3439
|
return;
|
|
3394
3440
|
}
|
|
3395
3441
|
r.stop(L.success("Postgres is ready"));
|
|
@@ -3402,29 +3448,33 @@ async function qi(e, t, n = {}) {
|
|
|
3402
3448
|
return;
|
|
3403
3449
|
}
|
|
3404
3450
|
let a = o.spinner();
|
|
3405
|
-
|
|
3451
|
+
a.start("Running database migrations...");
|
|
3452
|
+
let s = await q("pnpm", [
|
|
3406
3453
|
"--filter",
|
|
3407
3454
|
"@internal/backend",
|
|
3408
3455
|
"migration:latest"
|
|
3409
|
-
], { cwd: e })
|
|
3410
|
-
|
|
3456
|
+
], { cwd: e });
|
|
3457
|
+
if (s.exitCode !== 0) {
|
|
3458
|
+
a.error("Migrations failed"), Ji(s), o.log.warn(L.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations."));
|
|
3411
3459
|
return;
|
|
3412
3460
|
}
|
|
3413
3461
|
a.stop(L.success("Database migrations applied"));
|
|
3414
|
-
let
|
|
3415
|
-
|
|
3462
|
+
let c = o.spinner();
|
|
3463
|
+
c.start("Generating Prisma client...");
|
|
3464
|
+
let l = await q("pnpm", [
|
|
3416
3465
|
"--filter",
|
|
3417
3466
|
"@internal/backend",
|
|
3418
3467
|
"generate"
|
|
3419
|
-
], { cwd: e })
|
|
3420
|
-
|
|
3468
|
+
], { cwd: e });
|
|
3469
|
+
if (l.exitCode !== 0) {
|
|
3470
|
+
c.error("Prisma client generation failed"), Ji(l), o.log.warn(L.muted("Run `pnpm --filter @internal/backend generate` manually."));
|
|
3421
3471
|
return;
|
|
3422
3472
|
}
|
|
3423
|
-
|
|
3473
|
+
c.stop(L.success("Prisma client generated"));
|
|
3424
3474
|
}
|
|
3425
3475
|
//#endregion
|
|
3426
3476
|
//#region src/core/resolve.ts
|
|
3427
|
-
function
|
|
3477
|
+
function Zi(e) {
|
|
3428
3478
|
let t = /* @__PURE__ */ new Map();
|
|
3429
3479
|
for (let n of e) t.set(n.name, {
|
|
3430
3480
|
name: n.name,
|
|
@@ -3432,7 +3482,7 @@ function Ji(e) {
|
|
|
3432
3482
|
});
|
|
3433
3483
|
return t;
|
|
3434
3484
|
}
|
|
3435
|
-
function
|
|
3485
|
+
function Qi(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3436
3486
|
let r = /* @__PURE__ */ new Set();
|
|
3437
3487
|
function i(e) {
|
|
3438
3488
|
if (n.has(e)) return [];
|
|
@@ -3446,10 +3496,10 @@ function Yi(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3446
3496
|
}
|
|
3447
3497
|
return i(e);
|
|
3448
3498
|
}
|
|
3449
|
-
function
|
|
3499
|
+
function $i(e, t, n = []) {
|
|
3450
3500
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3451
3501
|
for (let n of e) {
|
|
3452
|
-
let e =
|
|
3502
|
+
let e = Qi(n, t, new Set(i));
|
|
3453
3503
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3454
3504
|
}
|
|
3455
3505
|
return {
|
|
@@ -3457,7 +3507,7 @@ function Xi(e, t, n = []) {
|
|
|
3457
3507
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3458
3508
|
};
|
|
3459
3509
|
}
|
|
3460
|
-
function
|
|
3510
|
+
function ea(e) {
|
|
3461
3511
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3462
3512
|
for (let e of t) {
|
|
3463
3513
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3470,7 +3520,7 @@ function Zi(e) {
|
|
|
3470
3520
|
}
|
|
3471
3521
|
//#endregion
|
|
3472
3522
|
//#region src/core/variants.ts
|
|
3473
|
-
function
|
|
3523
|
+
function ta(e, t = {}) {
|
|
3474
3524
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3475
3525
|
for (let i of e) {
|
|
3476
3526
|
let e = t[i.family] ?? i.default;
|
|
@@ -3482,14 +3532,14 @@ function Qi(e, t = {}) {
|
|
|
3482
3532
|
familyOf: r
|
|
3483
3533
|
};
|
|
3484
3534
|
}
|
|
3485
|
-
function
|
|
3535
|
+
function na(e, t, n) {
|
|
3486
3536
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3487
3537
|
}
|
|
3488
|
-
function
|
|
3538
|
+
function ra(e, t) {
|
|
3489
3539
|
let n = t.familyOf.get(e);
|
|
3490
3540
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3491
3541
|
}
|
|
3492
|
-
function
|
|
3542
|
+
function ia(e, t) {
|
|
3493
3543
|
let n = /* @__PURE__ */ new Map();
|
|
3494
3544
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3495
3545
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3505,65 +3555,65 @@ function ta(e, t) {
|
|
|
3505
3555
|
familyOf: n
|
|
3506
3556
|
};
|
|
3507
3557
|
}
|
|
3508
|
-
function
|
|
3558
|
+
function aa(e, t) {
|
|
3509
3559
|
return e.map((e) => ({
|
|
3510
3560
|
...e,
|
|
3511
|
-
dependencies: e.dependencies.map((e) =>
|
|
3561
|
+
dependencies: e.dependencies.map((e) => ra(e, t))
|
|
3512
3562
|
}));
|
|
3513
3563
|
}
|
|
3514
3564
|
//#endregion
|
|
3515
3565
|
//#region src/ui/banner.ts
|
|
3516
|
-
var
|
|
3566
|
+
var oa = [
|
|
3517
3567
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3518
3568
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3519
3569
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3520
3570
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3521
3571
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3522
3572
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3523
|
-
],
|
|
3573
|
+
], sa = [
|
|
3524
3574
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3525
3575
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3526
3576
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3527
3577
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3528
3578
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3529
3579
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3530
|
-
],
|
|
3580
|
+
], ca = [
|
|
3531
3581
|
253,
|
|
3532
3582
|
176,
|
|
3533
3583
|
21
|
|
3534
|
-
],
|
|
3584
|
+
], la = [
|
|
3535
3585
|
245,
|
|
3536
3586
|
76,
|
|
3537
3587
|
2
|
|
3538
|
-
],
|
|
3588
|
+
], ua = 5, da = [
|
|
3539
3589
|
17,
|
|
3540
3590
|
103,
|
|
3541
3591
|
248
|
|
3542
|
-
],
|
|
3592
|
+
], fa = [
|
|
3543
3593
|
42,
|
|
3544
3594
|
160,
|
|
3545
3595
|
250
|
|
3546
|
-
],
|
|
3547
|
-
function
|
|
3596
|
+
], pa = .2;
|
|
3597
|
+
function ma() {
|
|
3548
3598
|
console.log();
|
|
3549
|
-
for (let e of xe(
|
|
3550
|
-
start: aa,
|
|
3551
|
-
end: oa,
|
|
3552
|
-
angle: sa
|
|
3553
|
-
})) console.log(y.bold(e));
|
|
3554
|
-
for (let e of xe(ia, {
|
|
3599
|
+
for (let e of xe(oa, {
|
|
3555
3600
|
start: ca,
|
|
3556
3601
|
end: la,
|
|
3557
3602
|
angle: ua
|
|
3558
3603
|
})) console.log(y.bold(e));
|
|
3604
|
+
for (let e of xe(sa, {
|
|
3605
|
+
start: da,
|
|
3606
|
+
end: fa,
|
|
3607
|
+
angle: pa
|
|
3608
|
+
})) console.log(y.bold(e));
|
|
3559
3609
|
console.log(), console.log(` ${R.spark} ${y.dim("v" + k)} ${y.dim("·")} ${ye("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3560
3610
|
}
|
|
3561
|
-
function
|
|
3611
|
+
function ha() {
|
|
3562
3612
|
console.log(), console.log(` ${R.bolt} ${ge.orange("Hype")}${ge.skyBlue("Stack")} ${y.dim("v" + k)}`), console.log();
|
|
3563
3613
|
}
|
|
3564
3614
|
//#endregion
|
|
3565
3615
|
//#region src/ui/pack-multiselect.ts
|
|
3566
|
-
var
|
|
3616
|
+
var ga = class extends D {
|
|
3567
3617
|
options;
|
|
3568
3618
|
cursor = 0;
|
|
3569
3619
|
selected;
|
|
@@ -3667,12 +3717,12 @@ var pa = class extends D {
|
|
|
3667
3717
|
}
|
|
3668
3718
|
}
|
|
3669
3719
|
};
|
|
3670
|
-
function
|
|
3671
|
-
return new
|
|
3720
|
+
function _a(e) {
|
|
3721
|
+
return new ga(e).prompt();
|
|
3672
3722
|
}
|
|
3673
3723
|
//#endregion
|
|
3674
3724
|
//#region src/core/apply-theme.ts
|
|
3675
|
-
function
|
|
3725
|
+
function va(e, t) {
|
|
3676
3726
|
let n = e.indexOf(t);
|
|
3677
3727
|
if (n === -1) return null;
|
|
3678
3728
|
let r = e.indexOf("{", n);
|
|
@@ -3687,46 +3737,46 @@ function ha(e, t) {
|
|
|
3687
3737
|
bodyEnd: a - 1
|
|
3688
3738
|
} : null;
|
|
3689
3739
|
}
|
|
3690
|
-
function
|
|
3740
|
+
function ya(e, t) {
|
|
3691
3741
|
let n = e;
|
|
3692
3742
|
for (let [e, r] of Object.entries(t)) {
|
|
3693
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3743
|
+
let t = RegExp(`(^[ \\t]*--${ba(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3694
3744
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3695
3745
|
}
|
|
3696
3746
|
return n;
|
|
3697
3747
|
}
|
|
3698
|
-
function
|
|
3748
|
+
function ba(e) {
|
|
3699
3749
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3700
3750
|
}
|
|
3701
|
-
function
|
|
3702
|
-
let n =
|
|
3751
|
+
function xa(e, t) {
|
|
3752
|
+
let n = va(e, ":root"), r = va(e, ".dark"), i = e;
|
|
3703
3753
|
if (n) {
|
|
3704
3754
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3705
|
-
i = e +
|
|
3755
|
+
i = e + ya(r, t.light) + a;
|
|
3706
3756
|
}
|
|
3707
3757
|
if (r) {
|
|
3708
|
-
let e =
|
|
3758
|
+
let e = va(i, ".dark");
|
|
3709
3759
|
if (e) {
|
|
3710
3760
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3711
|
-
i = n +
|
|
3761
|
+
i = n + ya(r, t.dark) + a;
|
|
3712
3762
|
}
|
|
3713
3763
|
}
|
|
3714
3764
|
return i;
|
|
3715
3765
|
}
|
|
3716
|
-
var
|
|
3717
|
-
async function
|
|
3718
|
-
let n = w.resolve(e,
|
|
3766
|
+
var Sa = "assets/styles.css";
|
|
3767
|
+
async function Ca(e, t) {
|
|
3768
|
+
let n = w.resolve(e, Sa), r;
|
|
3719
3769
|
try {
|
|
3720
3770
|
r = await v.readFile(n, "utf-8");
|
|
3721
3771
|
} catch {
|
|
3722
3772
|
return !1;
|
|
3723
3773
|
}
|
|
3724
|
-
let i =
|
|
3774
|
+
let i = xa(r, t);
|
|
3725
3775
|
return i === r || await v.writeFile(n, i, "utf-8"), !0;
|
|
3726
3776
|
}
|
|
3727
3777
|
//#endregion
|
|
3728
3778
|
//#region src/core/clone.ts
|
|
3729
|
-
async function
|
|
3779
|
+
async function wa(e) {
|
|
3730
3780
|
let t = await ee(te, {
|
|
3731
3781
|
dir: e,
|
|
3732
3782
|
force: !0
|
|
@@ -3738,7 +3788,7 @@ async function xa(e) {
|
|
|
3738
3788
|
}
|
|
3739
3789
|
//#endregion
|
|
3740
3790
|
//#region src/core/editor-config.ts
|
|
3741
|
-
function
|
|
3791
|
+
function Ta(e) {
|
|
3742
3792
|
let t = {
|
|
3743
3793
|
globs: [],
|
|
3744
3794
|
alwaysApply: !1
|
|
@@ -3773,10 +3823,10 @@ function Sa(e) {
|
|
|
3773
3823
|
content: i
|
|
3774
3824
|
};
|
|
3775
3825
|
}
|
|
3776
|
-
function
|
|
3826
|
+
function Ea(e) {
|
|
3777
3827
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
3778
3828
|
}
|
|
3779
|
-
function
|
|
3829
|
+
function Da(e) {
|
|
3780
3830
|
let t;
|
|
3781
3831
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
3782
3832
|
let n = [`trigger: ${t}`];
|
|
@@ -3786,30 +3836,30 @@ function wa(e) {
|
|
|
3786
3836
|
}
|
|
3787
3837
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
3788
3838
|
}
|
|
3789
|
-
function
|
|
3839
|
+
function Oa(e) {
|
|
3790
3840
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
3791
3841
|
}
|
|
3792
|
-
var
|
|
3842
|
+
var ka = {
|
|
3793
3843
|
claude: {
|
|
3794
3844
|
rulesDir: ".claude/rules",
|
|
3795
3845
|
extension: ".md",
|
|
3796
|
-
convert:
|
|
3846
|
+
convert: Ea
|
|
3797
3847
|
},
|
|
3798
3848
|
windsurf: {
|
|
3799
3849
|
rulesDir: ".windsurf/rules",
|
|
3800
3850
|
extension: ".md",
|
|
3801
|
-
convert:
|
|
3851
|
+
convert: Da
|
|
3802
3852
|
},
|
|
3803
3853
|
copilot: {
|
|
3804
3854
|
rulesDir: ".github/instructions",
|
|
3805
3855
|
extension: ".instructions.md",
|
|
3806
|
-
convert:
|
|
3856
|
+
convert: Oa
|
|
3807
3857
|
}
|
|
3808
3858
|
};
|
|
3809
|
-
async function
|
|
3859
|
+
async function Aa(e) {
|
|
3810
3860
|
let t = w.join(e, se), n = (await v.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
3811
3861
|
return await Promise.all(n.map(async (e) => {
|
|
3812
|
-
let n = w.join(t, e.name), { frontmatter: r, content: i } =
|
|
3862
|
+
let n = w.join(t, e.name), { frontmatter: r, content: i } = Ta(await v.readFile(n, "utf-8"));
|
|
3813
3863
|
return {
|
|
3814
3864
|
frontmatter: r,
|
|
3815
3865
|
content: i,
|
|
@@ -3817,9 +3867,9 @@ async function Da(e) {
|
|
|
3817
3867
|
};
|
|
3818
3868
|
}));
|
|
3819
3869
|
}
|
|
3820
|
-
async function
|
|
3870
|
+
async function ja(e, t) {
|
|
3821
3871
|
if (t === "cursor") return;
|
|
3822
|
-
let n =
|
|
3872
|
+
let n = ka[t], r = await Aa(e), i = w.join(e, n.rulesDir);
|
|
3823
3873
|
await v.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
3824
3874
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3825
3875
|
return v.writeFile(w.join(i, r), t, "utf-8");
|
|
@@ -3827,21 +3877,21 @@ async function Oa(e, t) {
|
|
|
3827
3877
|
}
|
|
3828
3878
|
//#endregion
|
|
3829
3879
|
//#region src/core/env-files.ts
|
|
3830
|
-
var
|
|
3880
|
+
var Ma = [
|
|
3831
3881
|
"apps",
|
|
3832
3882
|
"packages",
|
|
3833
3883
|
"libs",
|
|
3834
3884
|
"shared"
|
|
3835
3885
|
];
|
|
3836
|
-
async function
|
|
3837
|
-
let t = await
|
|
3886
|
+
async function Na(e) {
|
|
3887
|
+
let t = await Pa(e);
|
|
3838
3888
|
return (await Promise.all(t.map(async (t) => {
|
|
3839
3889
|
let n = w.join(w.dirname(t), ".env");
|
|
3840
3890
|
return await Y(n) ? null : (await v.copyFile(t, n), w.relative(e, n));
|
|
3841
3891
|
}))).filter((e) => e !== null).sort();
|
|
3842
3892
|
}
|
|
3843
|
-
async function
|
|
3844
|
-
let t = [w.join(e, ".env.example")], n = await Promise.all(
|
|
3893
|
+
async function Pa(e) {
|
|
3894
|
+
let t = [w.join(e, ".env.example")], n = await Promise.all(Ma.map(async (t) => {
|
|
3845
3895
|
let n = w.join(e, t);
|
|
3846
3896
|
return (await v.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => w.join(n, e.name, ".env.example"));
|
|
3847
3897
|
}));
|
|
@@ -3849,12 +3899,12 @@ async function ja(e) {
|
|
|
3849
3899
|
}
|
|
3850
3900
|
//#endregion
|
|
3851
3901
|
//#region src/core/post-clone.ts
|
|
3852
|
-
var Q = "@hype-stack/",
|
|
3853
|
-
async function
|
|
3902
|
+
var Q = "@hype-stack/", Fa = "hype-stack";
|
|
3903
|
+
async function Ia(e) {
|
|
3854
3904
|
await sr(w.join(e, ".git"));
|
|
3855
3905
|
}
|
|
3856
|
-
async function
|
|
3857
|
-
await
|
|
3906
|
+
async function La(e) {
|
|
3907
|
+
await q("git", ["init"], { cwd: e }), await q("git", ["add", "."], { cwd: e }), await q("git", [
|
|
3858
3908
|
"-c",
|
|
3859
3909
|
"user.name=Hype Stack CLI",
|
|
3860
3910
|
"-c",
|
|
@@ -3864,22 +3914,22 @@ async function Pa(e) {
|
|
|
3864
3914
|
"Initial commit from Hype Stack CLI"
|
|
3865
3915
|
], { cwd: e });
|
|
3866
3916
|
}
|
|
3867
|
-
async function
|
|
3868
|
-
let n = `@${t}/`, r = await
|
|
3917
|
+
async function Ra(e, t) {
|
|
3918
|
+
let n = `@${t}/`, r = await Ka(e);
|
|
3869
3919
|
for (let e of r) {
|
|
3870
3920
|
let t = await ir(e);
|
|
3871
3921
|
if (!t) continue;
|
|
3872
3922
|
let r = !1;
|
|
3873
|
-
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0),
|
|
3923
|
+
t.name?.startsWith(Q) && (t.name = t.name.replace(Q, n), r = !0), Ua(t.dependencies, n) && (r = !0), Ua(t.devDependencies, n) && (r = !0), t.nx && Wa(t.nx, n) && (r = !0);
|
|
3874
3924
|
let i = await v.readFile(e, "utf-8");
|
|
3875
3925
|
if (i.includes(Q)) {
|
|
3876
3926
|
let t = i.replaceAll(Q, n);
|
|
3877
3927
|
await v.writeFile(e, t, "utf-8");
|
|
3878
3928
|
} else r && await ar(e, t);
|
|
3879
3929
|
}
|
|
3880
|
-
await
|
|
3930
|
+
await Ci(e, t), await Va(e, t), await Ga(e, t);
|
|
3881
3931
|
}
|
|
3882
|
-
var
|
|
3932
|
+
var za = new Set([
|
|
3883
3933
|
".git",
|
|
3884
3934
|
"node_modules",
|
|
3885
3935
|
"dist",
|
|
@@ -3887,10 +3937,10 @@ var Ia = new Set([
|
|
|
3887
3937
|
".nx",
|
|
3888
3938
|
".next",
|
|
3889
3939
|
"coverage"
|
|
3890
|
-
]),
|
|
3891
|
-
async function
|
|
3892
|
-
if (t ===
|
|
3893
|
-
let n = await
|
|
3940
|
+
]), Ba = /^(docker-compose|compose)(\.[\w.-]+)?\.ya?ml$/;
|
|
3941
|
+
async function Va(e, t) {
|
|
3942
|
+
if (t === Fa) return;
|
|
3943
|
+
let n = await Ha(e);
|
|
3894
3944
|
await Promise.all(n.map(async (e) => {
|
|
3895
3945
|
let n = await v.readFile(e, "utf-8").catch(() => null);
|
|
3896
3946
|
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
@@ -3898,14 +3948,14 @@ async function Ra(e, t) {
|
|
|
3898
3948
|
await v.writeFile(e, r, "utf-8");
|
|
3899
3949
|
}));
|
|
3900
3950
|
}
|
|
3901
|
-
async function
|
|
3951
|
+
async function Ha(e) {
|
|
3902
3952
|
let t = await v.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
3903
3953
|
return (await Promise.all(t.map(async (t) => {
|
|
3904
3954
|
let n = w.join(e, t.name);
|
|
3905
|
-
return t.isDirectory() ?
|
|
3955
|
+
return t.isDirectory() ? za.has(t.name) ? [] : Ha(n) : t.isFile() && Ba.test(t.name) ? [n] : [];
|
|
3906
3956
|
}))).flat();
|
|
3907
3957
|
}
|
|
3908
|
-
function
|
|
3958
|
+
function Ua(e, t) {
|
|
3909
3959
|
if (!e) return !1;
|
|
3910
3960
|
let n = !1;
|
|
3911
3961
|
for (let r of Object.keys(e)) if (r.startsWith(Q)) {
|
|
@@ -3914,7 +3964,7 @@ function Ba(e, t) {
|
|
|
3914
3964
|
}
|
|
3915
3965
|
return n;
|
|
3916
3966
|
}
|
|
3917
|
-
function
|
|
3967
|
+
function Wa(e, t) {
|
|
3918
3968
|
if (!e) return !1;
|
|
3919
3969
|
let n = !1;
|
|
3920
3970
|
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Q) ? (n = !0, e.replace(Q, t)) : e), e.targets) {
|
|
@@ -3922,13 +3972,13 @@ function Va(e, t) {
|
|
|
3922
3972
|
}
|
|
3923
3973
|
return n;
|
|
3924
3974
|
}
|
|
3925
|
-
async function
|
|
3975
|
+
async function Ga(e, t) {
|
|
3926
3976
|
let n = w.join(e, "packages/enums/src/app/index.ts"), r = await v.readFile(n, "utf-8").catch(() => null);
|
|
3927
3977
|
if (!r) return;
|
|
3928
|
-
let i = t.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" "), a = r.replaceAll(`id: "${
|
|
3978
|
+
let i = t.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" "), a = r.replaceAll(`id: "${Fa}"`, `id: "${t}"`).replaceAll(`name: "${Fa}"`, `name: "${t}"`).replace(/name: "Hype Stack"/, `name: "${i}"`).replace(/description: ".*?"/, `description: "${i} application"`);
|
|
3929
3979
|
await v.writeFile(n, a, "utf-8");
|
|
3930
3980
|
}
|
|
3931
|
-
async function
|
|
3981
|
+
async function Ka(e) {
|
|
3932
3982
|
let t = [], n = w.join(e, "package.json");
|
|
3933
3983
|
(await v.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
3934
3984
|
for (let n of [
|
|
@@ -3948,7 +3998,7 @@ async function Ua(e) {
|
|
|
3948
3998
|
}
|
|
3949
3999
|
//#endregion
|
|
3950
4000
|
//#region src/core/readme.ts
|
|
3951
|
-
var
|
|
4001
|
+
var qa = {
|
|
3952
4002
|
cursor: {
|
|
3953
4003
|
label: "Cursor",
|
|
3954
4004
|
rulesDir: ".cursor/rules"
|
|
@@ -3965,24 +4015,24 @@ var Wa = {
|
|
|
3965
4015
|
label: "GitHub Copilot",
|
|
3966
4016
|
rulesDir: ".github/instructions"
|
|
3967
4017
|
}
|
|
3968
|
-
},
|
|
4018
|
+
}, Ja = {
|
|
3969
4019
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
3970
4020
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
3971
|
-
},
|
|
4021
|
+
}, Ya = {
|
|
3972
4022
|
enums: "Shared enums and app config used across apps",
|
|
3973
4023
|
cli: "Project tooling and code generators"
|
|
3974
4024
|
};
|
|
3975
|
-
function
|
|
4025
|
+
function Xa(e) {
|
|
3976
4026
|
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3977
4027
|
}
|
|
3978
|
-
function
|
|
4028
|
+
function Za(e, t) {
|
|
3979
4029
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
3980
4030
|
let r = t[e];
|
|
3981
4031
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
3982
4032
|
});
|
|
3983
4033
|
}
|
|
3984
|
-
function
|
|
3985
|
-
let { projectName: t, editor: n, workspace: r } = e, i =
|
|
4034
|
+
function Qa(e) {
|
|
4035
|
+
let { projectName: t, editor: n, workspace: r } = e, i = Xa(t), a = qa[n], o = !!r.apps.backend, s = Za(r.apps, Ja), c = Za(r.packages, Ya), l = [];
|
|
3986
4036
|
s.length > 0 && l.push(...s), c.length > 0 && l.push(...c), l.push("- `stack.json` - Hype Stack workspace config (apps, paths, installed packs)");
|
|
3987
4037
|
let u = [];
|
|
3988
4038
|
u.push(`# ${i}`), u.push([
|
|
@@ -4090,19 +4140,19 @@ function Ya(e) {
|
|
|
4090
4140
|
"stays useful."
|
|
4091
4141
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4092
4142
|
}
|
|
4093
|
-
async function
|
|
4143
|
+
async function $a(e, t) {
|
|
4094
4144
|
let n = w.join(e, "README.md");
|
|
4095
|
-
await v.writeFile(n,
|
|
4145
|
+
await v.writeFile(n, Qa(t), "utf-8");
|
|
4096
4146
|
}
|
|
4097
4147
|
//#endregion
|
|
4098
4148
|
//#region src/core/tracking.ts
|
|
4099
|
-
async function
|
|
4149
|
+
async function eo(e) {
|
|
4100
4150
|
try {
|
|
4101
4151
|
let t = {
|
|
4102
|
-
"X-Device-Id":
|
|
4103
|
-
"X-Client-Info":
|
|
4104
|
-
}, n = await
|
|
4105
|
-
n?.token && (t.Authorization = `Bearer ${n.token}`), await
|
|
4152
|
+
"X-Device-Id": Yn(),
|
|
4153
|
+
"X-Client-Info": Xn()
|
|
4154
|
+
}, n = await Gn(N()).catch(() => null);
|
|
4155
|
+
n?.token && (t.Authorization = `Bearer ${n.token}`), await K.createRequest()({
|
|
4106
4156
|
endpoint: "/cli/track",
|
|
4107
4157
|
method: "POST"
|
|
4108
4158
|
}).setPayload({ event: e }).setHeaders(t).send();
|
|
@@ -4110,7 +4160,7 @@ async function Za(e) {
|
|
|
4110
4160
|
}
|
|
4111
4161
|
//#endregion
|
|
4112
4162
|
//#region src/ui/swatch.ts
|
|
4113
|
-
function
|
|
4163
|
+
function to(e) {
|
|
4114
4164
|
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4115
4165
|
if (!t) return null;
|
|
4116
4166
|
let n = t[1].trim().split(/\s+/);
|
|
@@ -4129,61 +4179,61 @@ function Qa(e) {
|
|
|
4129
4179
|
h: a
|
|
4130
4180
|
};
|
|
4131
4181
|
}
|
|
4132
|
-
function
|
|
4182
|
+
function no(e) {
|
|
4133
4183
|
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4134
4184
|
}
|
|
4135
|
-
function
|
|
4185
|
+
function ro(e) {
|
|
4136
4186
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4137
4187
|
}
|
|
4138
|
-
function
|
|
4188
|
+
function io({ l: e, c: t, h: n }) {
|
|
4139
4189
|
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;
|
|
4140
4190
|
return [
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4191
|
+
no(ro(f) * 255),
|
|
4192
|
+
no(ro(p) * 255),
|
|
4193
|
+
no(ro(m) * 255)
|
|
4144
4194
|
];
|
|
4145
4195
|
}
|
|
4146
|
-
var
|
|
4147
|
-
function
|
|
4196
|
+
var ao = "\x1B[49m";
|
|
4197
|
+
function oo(e, t) {
|
|
4148
4198
|
let n = e[t];
|
|
4149
4199
|
if (!n) return y.dim(" ");
|
|
4150
|
-
let r =
|
|
4200
|
+
let r = to(n);
|
|
4151
4201
|
if (!r) return y.dim(" ");
|
|
4152
|
-
let [i, a, o] =
|
|
4153
|
-
return `\x1b[48;2;${i};${a};${o}m ${
|
|
4202
|
+
let [i, a, o] = io(r);
|
|
4203
|
+
return `\x1b[48;2;${i};${a};${o}m ${ao}`;
|
|
4154
4204
|
}
|
|
4155
|
-
var
|
|
4205
|
+
var so = [
|
|
4156
4206
|
"primary",
|
|
4157
4207
|
"secondary",
|
|
4158
4208
|
"accent"
|
|
4159
4209
|
];
|
|
4160
|
-
function
|
|
4161
|
-
return
|
|
4210
|
+
function co(e) {
|
|
4211
|
+
return so.map((t) => oo(e, t)).join("");
|
|
4162
4212
|
}
|
|
4163
|
-
function
|
|
4164
|
-
return `${
|
|
4213
|
+
function lo(e) {
|
|
4214
|
+
return `${co(e.light)} ${y.dim("·")} ${co(e.dark)}`;
|
|
4165
4215
|
}
|
|
4166
4216
|
//#endregion
|
|
4167
4217
|
//#region src/utils/validate.ts
|
|
4168
|
-
function
|
|
4218
|
+
function uo(e) {
|
|
4169
4219
|
if (!e.trim()) return "Project name cannot be empty";
|
|
4170
4220
|
if (!M.test(e)) return "Project name must be lowercase, alphanumeric, and may contain hyphens, dots, or underscores";
|
|
4171
4221
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
4172
4222
|
}
|
|
4173
4223
|
//#endregion
|
|
4174
4224
|
//#region src/commands/create.ts
|
|
4175
|
-
async function
|
|
4176
|
-
a.skipBanner ||
|
|
4225
|
+
async function fo(a) {
|
|
4226
|
+
a.skipBanner || ma(), o.intro(L.brandBold("Create a new Hype Stack project"));
|
|
4177
4227
|
let s = a.yes === !0, c;
|
|
4178
4228
|
if (s && a.name) {
|
|
4179
|
-
let e =
|
|
4229
|
+
let e = uo(a.name);
|
|
4180
4230
|
e && (o.log.error(e), Z()), c = a.name;
|
|
4181
4231
|
} else {
|
|
4182
4232
|
let e = await o.text({
|
|
4183
4233
|
message: "What is your project named?",
|
|
4184
4234
|
placeholder: "my-app",
|
|
4185
4235
|
initialValue: a.name ?? "",
|
|
4186
|
-
validate: (e) =>
|
|
4236
|
+
validate: (e) => uo(e ?? "")
|
|
4187
4237
|
});
|
|
4188
4238
|
o.isCancel(e) && Z(), c = e;
|
|
4189
4239
|
}
|
|
@@ -4228,7 +4278,7 @@ async function co(a) {
|
|
|
4228
4278
|
message: "Pick a color theme",
|
|
4229
4279
|
options: n.map((e) => ({
|
|
4230
4280
|
value: e.name,
|
|
4231
|
-
label: `${
|
|
4281
|
+
label: `${lo(e)} ${e.label}`
|
|
4232
4282
|
})),
|
|
4233
4283
|
initialValue: e
|
|
4234
4284
|
});
|
|
@@ -4238,7 +4288,7 @@ async function co(a) {
|
|
|
4238
4288
|
let e = ae.find((e) => e.value === f)?.label ?? f, n = t.find((e) => e.value === m)?.label ?? m, r = await o.confirm({ message: `Create ${L.highlight(c)} in ${L.path(u)} with ${L.highlight(e)} config and the ${L.highlight(n)} theme?` });
|
|
4239
4289
|
(o.isCancel(r) || !r) && Z();
|
|
4240
4290
|
}
|
|
4241
|
-
if (await
|
|
4291
|
+
if (await J(u) && !await rr(u)) {
|
|
4242
4292
|
let e = await o.confirm({
|
|
4243
4293
|
message: `Directory ${L.path(u)} is not empty. Continue anyway?`,
|
|
4244
4294
|
initialValue: !1
|
|
@@ -4246,29 +4296,29 @@ async function co(a) {
|
|
|
4246
4296
|
(o.isCancel(e) || !e) && Z();
|
|
4247
4297
|
}
|
|
4248
4298
|
let h = o.spinner();
|
|
4249
|
-
h.start("Cloning Hype Stack template..."), await
|
|
4299
|
+
h.start("Cloning Hype Stack template..."), await wa(u), h.stop(L.success("Template cloned"));
|
|
4250
4300
|
let g = o.spinner();
|
|
4251
|
-
g.start("Setting up project..."), await
|
|
4252
|
-
let _ = await
|
|
4253
|
-
await
|
|
4301
|
+
g.start("Setting up project..."), await Ia(u), await Ra(u, c), await ja(u, f);
|
|
4302
|
+
let _ = await hr(u), v = _r(c, _);
|
|
4303
|
+
await mr(u, v), await $a(u, {
|
|
4254
4304
|
projectName: c,
|
|
4255
4305
|
editor: f,
|
|
4256
4306
|
workspace: _
|
|
4257
|
-
}), i(m) && (await
|
|
4307
|
+
}), i(m) && (await Ca(w.resolve(u, v.paths?.frontend.root ?? "apps/frontend"), r(m)) || o.log.warn(L.muted(`Could not find ${L.path("assets/styles.css")} to apply the ${m} theme`))), g.stop(L.success("Project configured"));
|
|
4258
4308
|
let y = o.spinner();
|
|
4259
|
-
y.start("Installing dependencies..."), (await
|
|
4309
|
+
y.start("Installing dependencies..."), (await q("pnpm", ["install"], { cwd: u })).exitCode === 0 ? y.stop(L.success("Dependencies installed")) : (y.stop(L.warning("Dependencies installed with warnings")), o.log.warn(L.muted("You may need to run `pnpm install` manually to resolve issues.")));
|
|
4260
4310
|
let b = o.spinner();
|
|
4261
|
-
b.start("Initializing git repository..."), await
|
|
4311
|
+
b.start("Initializing git repository..."), await La(u), b.stop(L.success("Git repository initialized with clean history"));
|
|
4262
4312
|
let x = o.spinner();
|
|
4263
4313
|
x.start("Creating .env files from examples...");
|
|
4264
|
-
let S = await
|
|
4314
|
+
let S = await Na(u);
|
|
4265
4315
|
if (S.length > 0) {
|
|
4266
4316
|
let e = S.length;
|
|
4267
4317
|
x.stop(L.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4268
4318
|
} else x.stop(L.muted("No .env.example files to copy"));
|
|
4269
4319
|
o.log.success(`${L.brandBold("Hype Stack")} project ${L.highlight(c)} is ready!`);
|
|
4270
4320
|
let C = w.relative(process.cwd(), u) || ".", T = [`${L.command(`cd ${C}`)}`];
|
|
4271
|
-
S.length > 0 ? T.push(`Review your ${L.path(".env")} files and fill in any secrets`) : T.push(`Copy ${L.path(".env.example")} to ${L.path(".env")} and configure`),
|
|
4321
|
+
S.length > 0 ? T.push(`Review your ${L.path(".env")} files and fill in any secrets`) : T.push(`Copy ${L.path(".env.example")} to ${L.path(".env")} and configure`), Wi(T);
|
|
4272
4322
|
let E = a.setup === !1;
|
|
4273
4323
|
if (a.deferSetup) o.log.info(L.muted("Docker and migrations will run after your packs are installed."));
|
|
4274
4324
|
else {
|
|
@@ -4276,24 +4326,24 @@ async function co(a) {
|
|
|
4276
4326
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
4277
4327
|
initialValue: !0
|
|
4278
4328
|
}));
|
|
4279
|
-
o.isCancel(e) && Z(), e ? await
|
|
4329
|
+
o.isCancel(e) && Z(), e ? await Xi(u, s) : (o.log.info(L.muted("You can start services later:")), Wi([
|
|
4280
4330
|
`${L.command("docker compose up -d")} ${L.muted("(in apps/backend - start Postgres, Valkey, RustFS)")}`,
|
|
4281
4331
|
`${L.command("pnpm --filter @internal/backend migration:latest")} ${L.muted("(apply migrations)")}`,
|
|
4282
4332
|
`${L.command("pnpm run generate")} ${L.muted("(generate Prisma client)")}`
|
|
4283
|
-
])),
|
|
4333
|
+
])), Wi([`${L.command("pnpm dev")} ${L.muted("(start frontend + backend)")}`]);
|
|
4284
4334
|
}
|
|
4285
|
-
return await
|
|
4335
|
+
return await eo("project_create"), o.outro(L.muted("Happy building!")), u;
|
|
4286
4336
|
}
|
|
4287
4337
|
//#endregion
|
|
4288
4338
|
//#region src/commands/init.ts
|
|
4289
|
-
async function
|
|
4339
|
+
async function po(e) {
|
|
4290
4340
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4291
|
-
if (n || (
|
|
4341
|
+
if (n || (ha(), o.intro(L.brandBold("Initialize Hype Stack configuration"))), !await vr(t)) {
|
|
4292
4342
|
o.log.error(`This doesn't look like a Hype Stack project. ${L.muted("Expected apps/ directory and package.json")}`), o.outro(L.muted(`Run ${L.command("npx @hype-stack/cli create")} to scaffold a new project.`));
|
|
4293
4343
|
return;
|
|
4294
4344
|
}
|
|
4295
|
-
if (await
|
|
4296
|
-
let e = await
|
|
4345
|
+
if (await pr(t)) {
|
|
4346
|
+
let e = await fr(t);
|
|
4297
4347
|
if (e && !n) {
|
|
4298
4348
|
o.log.info(`Found existing ${L.path("stack.json")} for project ${L.highlight(e.name)}`);
|
|
4299
4349
|
let t = await o.confirm({
|
|
@@ -4306,7 +4356,7 @@ async function lo(e) {
|
|
|
4306
4356
|
}
|
|
4307
4357
|
}
|
|
4308
4358
|
}
|
|
4309
|
-
let r = await
|
|
4359
|
+
let r = await hr(t);
|
|
4310
4360
|
if (!n) {
|
|
4311
4361
|
let e = Object.entries(r.apps), t = Object.entries(r.packages);
|
|
4312
4362
|
if (e.length > 0) {
|
|
@@ -4328,22 +4378,22 @@ async function lo(e) {
|
|
|
4328
4378
|
});
|
|
4329
4379
|
o.isCancel(e) && Z(), a = e;
|
|
4330
4380
|
}
|
|
4331
|
-
await
|
|
4381
|
+
await mr(t, _r(a, r)), n || (o.log.success(`${L.path("stack.json")} written successfully`), o.outro(L.muted("Your project is mapped and ready for Hype Stack CLI commands.")));
|
|
4332
4382
|
}
|
|
4333
|
-
async function
|
|
4334
|
-
if (await
|
|
4383
|
+
async function mo(e, t = {}) {
|
|
4384
|
+
if (await pr(e)) return {
|
|
4335
4385
|
projectRoot: e,
|
|
4336
4386
|
scaffolded: !1
|
|
4337
4387
|
};
|
|
4338
|
-
let n = t.runInit ?? ((e) =>
|
|
4388
|
+
let n = t.runInit ?? ((e) => po({
|
|
4339
4389
|
cwd: e,
|
|
4340
4390
|
silent: !0
|
|
4341
|
-
})), r = t.runCreate ?? ((e) =>
|
|
4391
|
+
})), r = t.runCreate ?? ((e) => fo({
|
|
4342
4392
|
parentDirectory: e,
|
|
4343
4393
|
deferSetup: !0,
|
|
4344
4394
|
skipBanner: !0
|
|
4345
4395
|
}));
|
|
4346
|
-
if (await
|
|
4396
|
+
if (await vr(e)) {
|
|
4347
4397
|
o.log.warn(`No ${L.path("stack.json")} found in ${L.path(e)}.`);
|
|
4348
4398
|
let t = await o.confirm({
|
|
4349
4399
|
message: `Create ${L.path("stack.json")} now?`,
|
|
@@ -4351,7 +4401,7 @@ async function uo(e, t = {}) {
|
|
|
4351
4401
|
});
|
|
4352
4402
|
if (o.isCancel(t) || !t) return null;
|
|
4353
4403
|
await n(e);
|
|
4354
|
-
let r = await
|
|
4404
|
+
let r = await pr(e);
|
|
4355
4405
|
return r && o.log.success(`${L.path("stack.json")} created`), r ? {
|
|
4356
4406
|
projectRoot: e,
|
|
4357
4407
|
scaffolded: !1
|
|
@@ -4369,14 +4419,14 @@ async function uo(e, t = {}) {
|
|
|
4369
4419
|
});
|
|
4370
4420
|
if (o.isCancel(a) || !a) return null;
|
|
4371
4421
|
let s = await r(e);
|
|
4372
|
-
return await
|
|
4422
|
+
return await pr(s) ? {
|
|
4373
4423
|
projectRoot: s,
|
|
4374
4424
|
scaffolded: !0
|
|
4375
4425
|
} : null;
|
|
4376
4426
|
}
|
|
4377
4427
|
//#endregion
|
|
4378
4428
|
//#region src/core/npm-deps.ts
|
|
4379
|
-
function
|
|
4429
|
+
function ho(e, t) {
|
|
4380
4430
|
let n = [], r = [];
|
|
4381
4431
|
if (!e) return {
|
|
4382
4432
|
errors: n,
|
|
@@ -4407,7 +4457,7 @@ function fo(e, t) {
|
|
|
4407
4457
|
operations: r
|
|
4408
4458
|
};
|
|
4409
4459
|
}
|
|
4410
|
-
function
|
|
4460
|
+
function go(e) {
|
|
4411
4461
|
let t = {};
|
|
4412
4462
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4413
4463
|
...t[e],
|
|
@@ -4415,7 +4465,7 @@ function po(e) {
|
|
|
4415
4465
|
};
|
|
4416
4466
|
return t;
|
|
4417
4467
|
}
|
|
4418
|
-
async function
|
|
4468
|
+
async function _o(e, t, n = q) {
|
|
4419
4469
|
let r = [];
|
|
4420
4470
|
for (let i of e) {
|
|
4421
4471
|
let e = w.join(t, i.relativeDir);
|
|
@@ -4451,22 +4501,22 @@ async function mo(e, t, n = J) {
|
|
|
4451
4501
|
function $(e) {
|
|
4452
4502
|
return e instanceof Error ? e.message : String(e);
|
|
4453
4503
|
}
|
|
4454
|
-
async function
|
|
4504
|
+
async function vo(e, t, n) {
|
|
4455
4505
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4456
|
-
return r.length === 0 ? {} :
|
|
4506
|
+
return r.length === 0 ? {} : Tr(r, n).catch(() => ({}));
|
|
4457
4507
|
}
|
|
4458
|
-
function
|
|
4508
|
+
function yo(e, t) {
|
|
4459
4509
|
return e === "free" ? L.success("free") : e === "owned" ? L.accent("owned") : `${L.highlight(`$${t}`)} ${L.muted("locked")}`;
|
|
4460
4510
|
}
|
|
4461
|
-
async function
|
|
4511
|
+
async function bo(e, t, n) {
|
|
4462
4512
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4463
|
-
i.length > 0 && o.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await
|
|
4513
|
+
i.length > 0 && o.log.warning(`Skipping ${i.join(", ")} because ${i.length === 1 ? "it depends" : "they depend"} on a pack you don't own yet.`), await nr(r.map((e) => n.get(e)).filter((e) => e !== void 0).map((e) => ({
|
|
4464
4514
|
name: e.name,
|
|
4465
4515
|
displayName: e.displayName,
|
|
4466
4516
|
price: e.price
|
|
4467
4517
|
})));
|
|
4468
4518
|
}
|
|
4469
|
-
function
|
|
4519
|
+
function xo(e, t) {
|
|
4470
4520
|
let n = e.map((e, n) => {
|
|
4471
4521
|
let r = t.get(e), i = r ? r.displayName : e;
|
|
4472
4522
|
return ` ${L.muted(`${n + 1}.`)} ${L.brand(i)}`;
|
|
@@ -4477,10 +4527,10 @@ function vo(e, t) {
|
|
|
4477
4527
|
...n
|
|
4478
4528
|
].join("\n"), "Install Plan");
|
|
4479
4529
|
}
|
|
4480
|
-
async function
|
|
4530
|
+
async function So(e, t) {
|
|
4481
4531
|
let n = [];
|
|
4482
4532
|
for (let r of e) {
|
|
4483
|
-
let e = await
|
|
4533
|
+
let e = await yr(r), i = await br(r, t);
|
|
4484
4534
|
if (i.status === "denied") throw Error(`Access to "${r}" was denied (${i.reason}). Try 'npx @hype-stack/cli login' or check your license.`);
|
|
4485
4535
|
n.push({
|
|
4486
4536
|
manifest: e,
|
|
@@ -4489,32 +4539,47 @@ async function yo(e, t) {
|
|
|
4489
4539
|
}
|
|
4490
4540
|
return n;
|
|
4491
4541
|
}
|
|
4492
|
-
async function
|
|
4493
|
-
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a =
|
|
4542
|
+
async function Co(e) {
|
|
4543
|
+
let { prepared: t, paths: n, cwd: r, spinner: i } = e, a = ho(go(t.map((e) => e.manifest.dependencies_npm)), n);
|
|
4494
4544
|
if (a.errors.length > 0) {
|
|
4495
4545
|
for (let e of a.errors) o.log.error(e);
|
|
4496
4546
|
return;
|
|
4497
4547
|
}
|
|
4498
4548
|
if (a.operations.length === 0) return;
|
|
4499
4549
|
i.start("Installing npm dependencies...");
|
|
4500
|
-
let s = await
|
|
4550
|
+
let s = await _o(a.operations, r);
|
|
4501
4551
|
if (i.stop(s.ok ? "npm dependencies installed" : "npm dependency installation failed"), !s.ok) for (let e of s.errors) o.log.error(e);
|
|
4502
4552
|
}
|
|
4503
|
-
function
|
|
4553
|
+
function wo(e) {
|
|
4504
4554
|
let t = e.flatMap((e) => e.manifest.postInstall ?? []), n = [...new Set(t)];
|
|
4505
4555
|
n.length !== 0 && o.note(n.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Next Steps");
|
|
4506
4556
|
}
|
|
4507
|
-
|
|
4557
|
+
function To(e) {
|
|
4558
|
+
if (e.length === 0) return;
|
|
4559
|
+
let t = e.map((e) => {
|
|
4560
|
+
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
4561
|
+
return ` ${L.muted("•")} ${L.path(t)}`;
|
|
4562
|
+
});
|
|
4563
|
+
o.note(t.join("\n"), "Skipped (already exist)");
|
|
4564
|
+
}
|
|
4565
|
+
async function Eo(e) {
|
|
4508
4566
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: s } = e, c = /* @__PURE__ */ new Set();
|
|
4509
4567
|
if (i) return c;
|
|
4510
|
-
let l = await
|
|
4568
|
+
let l = await Mi({
|
|
4511
4569
|
packs: t,
|
|
4512
4570
|
config: n,
|
|
4513
4571
|
projectRoot: r,
|
|
4514
4572
|
slotsByPack: s
|
|
4515
4573
|
});
|
|
4516
4574
|
if (l.length === 0) return c;
|
|
4517
|
-
if (a)
|
|
4575
|
+
if (a) {
|
|
4576
|
+
o.log.warning(`${l.length} existing file${l.length === 1 ? "" : "s"} kept. Pass ${L.command("--force")} to overwrite.`);
|
|
4577
|
+
let e = l.map((e) => {
|
|
4578
|
+
let t = w.relative(r, e.targetPath) || e.target;
|
|
4579
|
+
return ` ${L.muted("•")} ${L.path(t)} ${L.muted(`(${e.packName})`)}`;
|
|
4580
|
+
});
|
|
4581
|
+
return o.note(e.join("\n"), "Kept existing files"), c;
|
|
4582
|
+
}
|
|
4518
4583
|
o.log.warning(`${l.length} file${l.length === 1 ? "" : "s"} already exist in your project.`);
|
|
4519
4584
|
for (let e of l) {
|
|
4520
4585
|
let t = w.relative(r, e.targetPath) || e.target, n = await o.confirm({
|
|
@@ -4527,12 +4592,12 @@ async function So(e) {
|
|
|
4527
4592
|
}
|
|
4528
4593
|
//#endregion
|
|
4529
4594
|
//#region src/commands/compose.ts
|
|
4530
|
-
async function
|
|
4595
|
+
async function Do(e = {}) {
|
|
4531
4596
|
let t = e.cwd ?? process.cwd();
|
|
4532
|
-
|
|
4533
|
-
let n = await
|
|
4597
|
+
ma();
|
|
4598
|
+
let n = await mo(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4534
4599
|
try {
|
|
4535
|
-
a = await
|
|
4600
|
+
a = await fr(r ?? t);
|
|
4536
4601
|
} catch (e) {
|
|
4537
4602
|
o.cancel(`Could not parse ${L.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4538
4603
|
}
|
|
@@ -4543,18 +4608,18 @@ async function Co(e = {}) {
|
|
|
4543
4608
|
c.start("Loading packs...");
|
|
4544
4609
|
let l;
|
|
4545
4610
|
try {
|
|
4546
|
-
l = await
|
|
4611
|
+
l = await wr();
|
|
4547
4612
|
} catch (e) {
|
|
4548
4613
|
c.stop("Failed to load packs"), o.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4549
4614
|
}
|
|
4550
4615
|
c.stop("Packs loaded");
|
|
4551
|
-
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
|
|
4616
|
+
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 Gn(N()))?.token ?? null, h = await vo(l, d, {
|
|
4552
4617
|
token: m,
|
|
4553
4618
|
key: p
|
|
4554
4619
|
}), g = (e) => {
|
|
4555
4620
|
let t = f.get(e);
|
|
4556
4621
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4557
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked", y = await
|
|
4622
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", y = await Oo({
|
|
4558
4623
|
packs: l,
|
|
4559
4624
|
installedSet: d,
|
|
4560
4625
|
stateOf: g,
|
|
@@ -4565,9 +4630,9 @@ async function Co(e = {}) {
|
|
|
4565
4630
|
o.outro(L.muted("No packs selected. Nothing to do."));
|
|
4566
4631
|
return;
|
|
4567
4632
|
}
|
|
4568
|
-
let b =
|
|
4633
|
+
let b = jo(y), x = Mo(y), S = ia(l, b), C = Zi(aa(l, S)), w;
|
|
4569
4634
|
try {
|
|
4570
|
-
w =
|
|
4635
|
+
w = $i(b, C, u);
|
|
4571
4636
|
} catch (e) {
|
|
4572
4637
|
o.cancel($(e)), process.exit(1);
|
|
4573
4638
|
}
|
|
@@ -4575,36 +4640,36 @@ async function Co(e = {}) {
|
|
|
4575
4640
|
o.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), o.outro(L.muted("Your selection is already part of the project."));
|
|
4576
4641
|
return;
|
|
4577
4642
|
}
|
|
4578
|
-
let T =
|
|
4643
|
+
let T = ea({
|
|
4579
4644
|
order: w.order,
|
|
4580
4645
|
graph: C,
|
|
4581
4646
|
isLocked: _,
|
|
4582
4647
|
installed: u
|
|
4583
4648
|
});
|
|
4584
4649
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4585
|
-
let e = await
|
|
4586
|
-
e && (m = e, h = await
|
|
4650
|
+
let e = await tr();
|
|
4651
|
+
e && (m = e, h = await vo(l, d, {
|
|
4587
4652
|
token: m,
|
|
4588
4653
|
key: p
|
|
4589
|
-
}), T =
|
|
4654
|
+
}), T = ea({
|
|
4590
4655
|
order: w.order,
|
|
4591
4656
|
graph: C,
|
|
4592
4657
|
isLocked: _,
|
|
4593
4658
|
installed: u
|
|
4594
4659
|
}));
|
|
4595
4660
|
}
|
|
4596
|
-
if (T.blocked.length > 0 && await
|
|
4661
|
+
if (T.blocked.length > 0 && await bo(T.blocked, _, f), T.installable.length === 0) {
|
|
4597
4662
|
o.outro(L.muted("Nothing left to install once locked packs are removed."));
|
|
4598
4663
|
return;
|
|
4599
4664
|
}
|
|
4600
|
-
if (
|
|
4665
|
+
if (xo(T.installable, f), !e.yes) {
|
|
4601
4666
|
let e = await o.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4602
4667
|
(o.isCancel(e) || !e) && (o.cancel("Installation cancelled."), process.exit(0));
|
|
4603
4668
|
}
|
|
4604
4669
|
c.start("Downloading packs...");
|
|
4605
4670
|
let E;
|
|
4606
4671
|
try {
|
|
4607
|
-
E = await
|
|
4672
|
+
E = await So(T.installable, {
|
|
4608
4673
|
token: m,
|
|
4609
4674
|
key: p
|
|
4610
4675
|
});
|
|
@@ -4612,7 +4677,7 @@ async function Co(e = {}) {
|
|
|
4612
4677
|
c.stop("Download failed"), o.cancel($(e)), process.exit(1);
|
|
4613
4678
|
}
|
|
4614
4679
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4615
|
-
let D = await
|
|
4680
|
+
let D = await Eo({
|
|
4616
4681
|
prepared: E,
|
|
4617
4682
|
config: a,
|
|
4618
4683
|
cwd: s,
|
|
@@ -4622,7 +4687,7 @@ async function Co(e = {}) {
|
|
|
4622
4687
|
});
|
|
4623
4688
|
try {
|
|
4624
4689
|
c.start("Installing pack files...");
|
|
4625
|
-
let t = await
|
|
4690
|
+
let t = await Fi({
|
|
4626
4691
|
packs: E,
|
|
4627
4692
|
config: a,
|
|
4628
4693
|
projectRoot: s,
|
|
@@ -4635,18 +4700,18 @@ async function Co(e = {}) {
|
|
|
4635
4700
|
for (let e of t.errors) o.log.error(e);
|
|
4636
4701
|
o.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4637
4702
|
}
|
|
4638
|
-
c.stop("Files installed"), t.installed.length > 0 && o.log.success(`${L.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && o.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`);
|
|
4703
|
+
c.stop("Files installed"), t.installed.length > 0 && o.log.success(`${L.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (o.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`), To(t.skipped));
|
|
4639
4704
|
for (let e of t.errors) o.log.error(e);
|
|
4640
|
-
await
|
|
4705
|
+
await Co({
|
|
4641
4706
|
prepared: E,
|
|
4642
4707
|
paths: a.paths,
|
|
4643
4708
|
cwd: s,
|
|
4644
4709
|
spinner: c
|
|
4645
|
-
}), i && await
|
|
4710
|
+
}), i && await Xi(s, e.yes ?? !1), await ur({
|
|
4646
4711
|
projectRoot: s,
|
|
4647
4712
|
paths: a.paths,
|
|
4648
4713
|
skipPrompts: e.yes ?? !1
|
|
4649
|
-
}),
|
|
4714
|
+
}), wo(E), o.outro(L.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4650
4715
|
} finally {
|
|
4651
4716
|
await Promise.all(E.map((e) => v.rm(e.packDir, {
|
|
4652
4717
|
recursive: !0,
|
|
@@ -4654,10 +4719,10 @@ async function Co(e = {}) {
|
|
|
4654
4719
|
})));
|
|
4655
4720
|
}
|
|
4656
4721
|
}
|
|
4657
|
-
async function
|
|
4722
|
+
async function Oo(e) {
|
|
4658
4723
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4659
4724
|
if (i.packs && i.packs.length > 0) {
|
|
4660
|
-
let e = i.packs.map(
|
|
4725
|
+
let e = i.packs.map(Ao), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4661
4726
|
return n.length > 0 && (o.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4662
4727
|
}
|
|
4663
4728
|
let s = t.filter((e) => n.has(e.name));
|
|
@@ -4666,13 +4731,13 @@ async function wo(e) {
|
|
|
4666
4731
|
if (c.length === 0) return o.outro(L.muted("Every available pack is already installed.")), [];
|
|
4667
4732
|
let l = P();
|
|
4668
4733
|
o.note(c.map((e) => ` ${R.arrow} ${L.highlight(e.displayName)} ${_e(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4669
|
-
let u =
|
|
4734
|
+
let u = Hi(c, { adminAvailable: a }), d = [];
|
|
4670
4735
|
for (let e of u) {
|
|
4671
4736
|
let t = e.packs.map((e) => {
|
|
4672
4737
|
let t = r(e.name);
|
|
4673
4738
|
return {
|
|
4674
4739
|
value: e.name,
|
|
4675
|
-
label: `${e.displayName} ${
|
|
4740
|
+
label: `${e.displayName} ${yo(t, e.price)}`,
|
|
4676
4741
|
hint: e.description
|
|
4677
4742
|
};
|
|
4678
4743
|
});
|
|
@@ -4689,7 +4754,7 @@ async function wo(e) {
|
|
|
4689
4754
|
});
|
|
4690
4755
|
continue;
|
|
4691
4756
|
}
|
|
4692
|
-
let n = await
|
|
4757
|
+
let n = await _a({
|
|
4693
4758
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4694
4759
|
options: t,
|
|
4695
4760
|
required: !1
|
|
@@ -4699,20 +4764,20 @@ async function wo(e) {
|
|
|
4699
4764
|
}
|
|
4700
4765
|
return d;
|
|
4701
4766
|
}
|
|
4702
|
-
var
|
|
4703
|
-
function
|
|
4704
|
-
let t = e.match(
|
|
4767
|
+
var ko = /@(frontend|admin)$/;
|
|
4768
|
+
function Ao(e) {
|
|
4769
|
+
let t = e.match(ko);
|
|
4705
4770
|
return t ? {
|
|
4706
4771
|
name: e.slice(0, -t[0].length),
|
|
4707
4772
|
slot: t[1]
|
|
4708
4773
|
} : { name: e };
|
|
4709
4774
|
}
|
|
4710
|
-
function
|
|
4775
|
+
function jo(e) {
|
|
4711
4776
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4712
4777
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4713
4778
|
return n;
|
|
4714
4779
|
}
|
|
4715
|
-
function
|
|
4780
|
+
function Mo(e) {
|
|
4716
4781
|
let t = /* @__PURE__ */ new Map();
|
|
4717
4782
|
for (let n of e) {
|
|
4718
4783
|
if (!n.slot) continue;
|
|
@@ -4723,11 +4788,11 @@ function Oo(e) {
|
|
|
4723
4788
|
}
|
|
4724
4789
|
//#endregion
|
|
4725
4790
|
//#region src/commands/login.ts
|
|
4726
|
-
async function
|
|
4727
|
-
|
|
4791
|
+
async function No() {
|
|
4792
|
+
ha(), o.intro(L.brandBold("Log in to Hype Stack")), o.log.step("Opening your browser to sign in...");
|
|
4728
4793
|
let e;
|
|
4729
4794
|
try {
|
|
4730
|
-
e = await
|
|
4795
|
+
e = await er({ onUrl: (e) => {
|
|
4731
4796
|
o.log.info(`If your browser didn't open, visit:\n ${L.path(e)}`);
|
|
4732
4797
|
} });
|
|
4733
4798
|
} catch (e) {
|
|
@@ -4737,28 +4802,28 @@ async function ko() {
|
|
|
4737
4802
|
}
|
|
4738
4803
|
//#endregion
|
|
4739
4804
|
//#region src/commands/logout.ts
|
|
4740
|
-
async function
|
|
4741
|
-
|
|
4742
|
-
let e = N(), t = await
|
|
4805
|
+
async function Po() {
|
|
4806
|
+
ha(), o.intro(L.brandBold("Log out of Hype Stack"));
|
|
4807
|
+
let e = N(), t = await Gn(e);
|
|
4743
4808
|
if (!t) {
|
|
4744
4809
|
o.outro(L.muted("You're not logged in."));
|
|
4745
4810
|
return;
|
|
4746
4811
|
}
|
|
4747
|
-
await
|
|
4812
|
+
await Ln(t.token).catch(() => null), await qn(e), o.outro(L.brand("Logged out."));
|
|
4748
4813
|
}
|
|
4749
4814
|
//#endregion
|
|
4750
4815
|
//#region src/core/templates.ts
|
|
4751
|
-
var
|
|
4816
|
+
var Fo = K.createRequest()({
|
|
4752
4817
|
endpoint: "/templates/list",
|
|
4753
4818
|
method: "GET"
|
|
4754
4819
|
});
|
|
4755
|
-
async function
|
|
4756
|
-
let { data: e, error: t } = await
|
|
4820
|
+
async function Io() {
|
|
4821
|
+
let { data: e, error: t } = await Fo.send();
|
|
4757
4822
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
4758
4823
|
return e.templates;
|
|
4759
4824
|
}
|
|
4760
|
-
async function
|
|
4761
|
-
let { data: t, error: n, status: r } = await
|
|
4825
|
+
async function Lo(e) {
|
|
4826
|
+
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
4762
4827
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
4763
4828
|
method: "GET"
|
|
4764
4829
|
}).send();
|
|
@@ -4766,13 +4831,13 @@ async function No(e) {
|
|
|
4766
4831
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
4767
4832
|
return t;
|
|
4768
4833
|
}
|
|
4769
|
-
async function
|
|
4770
|
-
let n =
|
|
4834
|
+
async function Ro(e, t = {}) {
|
|
4835
|
+
let n = K.createRequest()({
|
|
4771
4836
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
4772
4837
|
method: "POST"
|
|
4773
4838
|
}), r = {
|
|
4774
|
-
"X-Device-Id":
|
|
4775
|
-
"X-Client-Info":
|
|
4839
|
+
"X-Device-Id": Yn(),
|
|
4840
|
+
"X-Client-Info": Xn()
|
|
4776
4841
|
};
|
|
4777
4842
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
4778
4843
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -4794,12 +4859,12 @@ async function Po(e, t = {}) {
|
|
|
4794
4859
|
}
|
|
4795
4860
|
//#endregion
|
|
4796
4861
|
//#region src/commands/template.ts
|
|
4797
|
-
async function
|
|
4862
|
+
async function zo(e = {}) {
|
|
4798
4863
|
let t = e.cwd ?? process.cwd();
|
|
4799
|
-
|
|
4800
|
-
let n = await
|
|
4864
|
+
ma();
|
|
4865
|
+
let n = await mo(t), a = n?.projectRoot ?? null, s = n?.scaffolded ?? !1, c;
|
|
4801
4866
|
try {
|
|
4802
|
-
c = await
|
|
4867
|
+
c = await fr(a ?? t);
|
|
4803
4868
|
} catch (e) {
|
|
4804
4869
|
o.cancel(`Could not parse ${L.path("stack.json")}: ${$(e)} Run 'npx @hype-stack/cli init' to regenerate it.`), process.exit(1);
|
|
4805
4870
|
}
|
|
@@ -4810,16 +4875,16 @@ async function Fo(e = {}) {
|
|
|
4810
4875
|
u.start("Loading packs...");
|
|
4811
4876
|
let d;
|
|
4812
4877
|
try {
|
|
4813
|
-
d = await
|
|
4878
|
+
d = await wr();
|
|
4814
4879
|
} catch (e) {
|
|
4815
4880
|
u.stop("Failed to load packs"), o.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4816
4881
|
}
|
|
4817
4882
|
u.stop("Packs loaded");
|
|
4818
|
-
let f = c.installedPacks ?? [], p = new Set(f), m = new Map(d.map((e) => [e.name, e])), h = e.licenseKey ?? c.licenseKey ?? null, g = (await
|
|
4883
|
+
let f = c.installedPacks ?? [], p = new Set(f), m = new Map(d.map((e) => [e.name, e])), h = e.licenseKey ?? c.licenseKey ?? null, g = (await Gn(N()))?.token ?? null;
|
|
4819
4884
|
u.start("Loading templates...");
|
|
4820
4885
|
let _;
|
|
4821
4886
|
try {
|
|
4822
|
-
_ = await
|
|
4887
|
+
_ = await Io();
|
|
4823
4888
|
} catch (e) {
|
|
4824
4889
|
u.stop("Failed to load templates"), o.cancel(`Could not reach Hype Stack. Check your connection and try again.\n${$(e)}`), process.exit(1);
|
|
4825
4890
|
}
|
|
@@ -4840,16 +4905,16 @@ async function Fo(e = {}) {
|
|
|
4840
4905
|
}
|
|
4841
4906
|
let b = _.find((e) => e.id === y);
|
|
4842
4907
|
b || (u.stop("Template not found"), o.cancel(`Template "${y}" not found. Available: ${_.map((e) => e.id).join(", ") || "(none)"}`), process.exit(1)), u.stop(`Template: ${b.name}`);
|
|
4843
|
-
let x = await
|
|
4908
|
+
let x = await Bo(b, e.variants, e.yes ?? !1), S = ta(b.slots, x), C = na(b.slots, b.packs, S), T = await Vo({
|
|
4844
4909
|
packs: d,
|
|
4845
4910
|
templatePacks: C,
|
|
4846
4911
|
installedSet: p,
|
|
4847
4912
|
options: e
|
|
4848
4913
|
}), E = [...C, ...T.filter((e) => !C.includes(e))], D = E.filter((e) => !m.has(e));
|
|
4849
4914
|
D.length > 0 && (o.cancel(`Unknown pack${D.length === 1 ? "" : "s"}: ${D.join(", ")}`), process.exit(1));
|
|
4850
|
-
let O =
|
|
4915
|
+
let O = aa(d, S), ee = Zi(O), k;
|
|
4851
4916
|
try {
|
|
4852
|
-
k =
|
|
4917
|
+
k = $i(E, ee, f);
|
|
4853
4918
|
} catch (e) {
|
|
4854
4919
|
o.cancel($(e)), process.exit(1);
|
|
4855
4920
|
}
|
|
@@ -4857,42 +4922,42 @@ async function Fo(e = {}) {
|
|
|
4857
4922
|
o.outro(L.muted("Every pack in this template is already installed."));
|
|
4858
4923
|
return;
|
|
4859
4924
|
}
|
|
4860
|
-
let te = await
|
|
4925
|
+
let te = await vo(O, p, {
|
|
4861
4926
|
token: g,
|
|
4862
4927
|
key: h
|
|
4863
4928
|
}), ne = (e) => {
|
|
4864
4929
|
let t = m.get(e);
|
|
4865
4930
|
return !t || t.tier === "free" ? "free" : te[e]?.owned ? "owned" : "locked";
|
|
4866
|
-
}, re = (e) => !p.has(e) && ne(e) === "locked", A =
|
|
4931
|
+
}, re = (e) => !p.has(e) && ne(e) === "locked", A = ea({
|
|
4867
4932
|
order: k.order,
|
|
4868
4933
|
graph: ee,
|
|
4869
4934
|
isLocked: re,
|
|
4870
4935
|
installed: f
|
|
4871
4936
|
});
|
|
4872
4937
|
if (A.blocked.length > 0 && !g && !h) {
|
|
4873
|
-
let e = await
|
|
4874
|
-
e && (g = e, te = await
|
|
4938
|
+
let e = await tr();
|
|
4939
|
+
e && (g = e, te = await vo(O, p, {
|
|
4875
4940
|
token: g,
|
|
4876
4941
|
key: h
|
|
4877
|
-
}), A =
|
|
4942
|
+
}), A = ea({
|
|
4878
4943
|
order: k.order,
|
|
4879
4944
|
graph: ee,
|
|
4880
4945
|
isLocked: re,
|
|
4881
4946
|
installed: f
|
|
4882
4947
|
}));
|
|
4883
4948
|
}
|
|
4884
|
-
if (A.blocked.length > 0 && await
|
|
4949
|
+
if (A.blocked.length > 0 && await bo(A.blocked, re, m), A.installable.length === 0) {
|
|
4885
4950
|
o.outro(L.muted("Nothing left to install once locked packs are removed."));
|
|
4886
4951
|
return;
|
|
4887
4952
|
}
|
|
4888
|
-
if (
|
|
4953
|
+
if (xo(A.installable, m), !e.yes) {
|
|
4889
4954
|
let e = await o.confirm({ message: `Install template ${L.brandBold(b.name)} (${A.installable.length} pack${A.installable.length === 1 ? "" : "s"})?` });
|
|
4890
4955
|
(o.isCancel(e) || !e) && (o.cancel("Installation cancelled."), process.exit(0));
|
|
4891
4956
|
}
|
|
4892
4957
|
u.start("Downloading packs...");
|
|
4893
4958
|
let j;
|
|
4894
4959
|
try {
|
|
4895
|
-
j = await
|
|
4960
|
+
j = await So(A.installable, {
|
|
4896
4961
|
token: g,
|
|
4897
4962
|
key: h
|
|
4898
4963
|
});
|
|
@@ -4900,7 +4965,7 @@ async function Fo(e = {}) {
|
|
|
4900
4965
|
u.stop("Download failed"), o.cancel($(e)), process.exit(1);
|
|
4901
4966
|
}
|
|
4902
4967
|
u.stop(`Downloaded ${j.length} pack${j.length === 1 ? "" : "s"}`);
|
|
4903
|
-
let ie = await
|
|
4968
|
+
let ie = await Eo({
|
|
4904
4969
|
prepared: j,
|
|
4905
4970
|
config: c,
|
|
4906
4971
|
cwd: l,
|
|
@@ -4909,7 +4974,7 @@ async function Fo(e = {}) {
|
|
|
4909
4974
|
}), M = null;
|
|
4910
4975
|
try {
|
|
4911
4976
|
u.start("Installing pack files...");
|
|
4912
|
-
let t = await
|
|
4977
|
+
let t = await Fi({
|
|
4913
4978
|
packs: j,
|
|
4914
4979
|
config: c,
|
|
4915
4980
|
projectRoot: l,
|
|
@@ -4921,15 +4986,15 @@ async function Fo(e = {}) {
|
|
|
4921
4986
|
for (let e of t.errors) o.log.error(e);
|
|
4922
4987
|
o.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4923
4988
|
}
|
|
4924
|
-
u.stop("Files installed"), t.installed.length > 0 && o.log.success(`${L.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && o.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`);
|
|
4989
|
+
u.stop("Files installed"), t.installed.length > 0 && o.log.success(`${L.highlight(String(t.installed.length))} files installed`), t.skipped.length > 0 && (o.log.warning(`${t.skipped.length} files skipped (use --force to overwrite)`), To(t.skipped));
|
|
4925
4990
|
for (let e of t.errors) o.log.error(e);
|
|
4926
4991
|
u.start("Applying template overrides...");
|
|
4927
|
-
let n = await
|
|
4992
|
+
let n = await Lo(b.id), a = await Ro(b.id, {
|
|
4928
4993
|
token: g,
|
|
4929
4994
|
licenseKey: h
|
|
4930
4995
|
});
|
|
4931
4996
|
a.status === "denied" && (u.stop("Template download denied"), o.cancel(`Access to template "${b.id}" was denied (${a.reason}). Try 'npx @hype-stack/cli login' or check your license.`), process.exit(1)), M = a.templateDir;
|
|
4932
|
-
let d = await
|
|
4997
|
+
let d = await Li({
|
|
4933
4998
|
manifest: n,
|
|
4934
4999
|
config: c,
|
|
4935
5000
|
projectRoot: l,
|
|
@@ -4938,17 +5003,17 @@ async function Fo(e = {}) {
|
|
|
4938
5003
|
u.stop("Template overrides applied"), d.installed.length > 0 && o.log.success(`${d.installed.length} template file${d.installed.length === 1 ? "" : "s"} applied`);
|
|
4939
5004
|
for (let e of d.errors) o.log.error(e);
|
|
4940
5005
|
let f = n.theme ?? "zinc-mono";
|
|
4941
|
-
i(f) && (await
|
|
5006
|
+
i(f) && (await Ca(w.resolve(l, c.paths?.frontend.root ?? "apps/frontend"), r(f)) ? o.log.success(`Applied the ${r(f).label} theme`) : o.log.warning(L.muted(`Could not find ${L.path("assets/styles.css")} to apply the theme`))), await Ho({
|
|
4942
5007
|
prepared: j,
|
|
4943
5008
|
templateNpm: n.dependencies_npm,
|
|
4944
5009
|
paths: c.paths,
|
|
4945
5010
|
cwd: l,
|
|
4946
5011
|
spinner: u
|
|
4947
|
-
}), s && await
|
|
5012
|
+
}), s && await Xi(l, e.yes ?? !1), await ur({
|
|
4948
5013
|
projectRoot: l,
|
|
4949
5014
|
paths: c.paths,
|
|
4950
5015
|
skipPrompts: e.yes ?? !1
|
|
4951
|
-
}),
|
|
5016
|
+
}), wo(j), n.postInstall && n.postInstall.length > 0 && o.note(n.postInstall.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Template Next Steps"), o.outro(L.brand(`Installed template ${b.name}.`));
|
|
4952
5017
|
} finally {
|
|
4953
5018
|
await Promise.all(j.map((e) => v.rm(e.packDir, {
|
|
4954
5019
|
recursive: !0,
|
|
@@ -4959,7 +5024,7 @@ async function Fo(e = {}) {
|
|
|
4959
5024
|
});
|
|
4960
5025
|
}
|
|
4961
5026
|
}
|
|
4962
|
-
async function
|
|
5027
|
+
async function Bo(e, t, n) {
|
|
4963
5028
|
let r = {};
|
|
4964
5029
|
for (let i of e.slots) {
|
|
4965
5030
|
if (t?.[i.family]) {
|
|
@@ -4983,7 +5048,7 @@ async function Io(e, t, n) {
|
|
|
4983
5048
|
}
|
|
4984
5049
|
return r;
|
|
4985
5050
|
}
|
|
4986
|
-
async function
|
|
5051
|
+
async function Vo(e) {
|
|
4987
5052
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
4988
5053
|
if (i.packs && i.packs.length > 0) {
|
|
4989
5054
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -4994,7 +5059,7 @@ async function Lo(e) {
|
|
|
4994
5059
|
if (s.length === 0) return [];
|
|
4995
5060
|
let c = P();
|
|
4996
5061
|
o.note(s.map((e) => ` ${R.arrow} ${L.highlight(e.displayName)} ${_e(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4997
|
-
let l = await
|
|
5062
|
+
let l = await _a({
|
|
4998
5063
|
message: "Add extra packs on top of the template (optional)",
|
|
4999
5064
|
options: s.map((e) => ({
|
|
5000
5065
|
value: e.name,
|
|
@@ -5005,25 +5070,25 @@ async function Lo(e) {
|
|
|
5005
5070
|
});
|
|
5006
5071
|
return p(l) && (o.cancel("Cancelled."), process.exit(0)), l;
|
|
5007
5072
|
}
|
|
5008
|
-
async function
|
|
5009
|
-
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, s =
|
|
5073
|
+
async function Ho(e) {
|
|
5074
|
+
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, s = go(t.map((e) => e.manifest.dependencies_npm)), c = ho(n ? go([s, n]) : s, r);
|
|
5010
5075
|
if (c.errors.length > 0) {
|
|
5011
5076
|
for (let e of c.errors) o.log.error(e);
|
|
5012
5077
|
return;
|
|
5013
5078
|
}
|
|
5014
5079
|
if (c.operations.length === 0) return;
|
|
5015
5080
|
a.start("Installing npm dependencies...");
|
|
5016
|
-
let l = await
|
|
5081
|
+
let l = await _o(c.operations, i);
|
|
5017
5082
|
if (a.stop(l.ok ? "npm dependencies installed" : "npm dependency installation failed"), !l.ok) for (let e of l.errors) o.log.error(e);
|
|
5018
5083
|
}
|
|
5019
5084
|
//#endregion
|
|
5020
5085
|
//#region src/cli.ts
|
|
5021
|
-
function
|
|
5086
|
+
function Uo(e) {
|
|
5022
5087
|
if (!e) return;
|
|
5023
5088
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5024
5089
|
return t.length > 0 ? t : void 0;
|
|
5025
5090
|
}
|
|
5026
|
-
function
|
|
5091
|
+
function Wo(e) {
|
|
5027
5092
|
if (!e) return;
|
|
5028
5093
|
let t = {};
|
|
5029
5094
|
for (let n of e.split(",")) {
|
|
@@ -5032,10 +5097,10 @@ function Bo(e) {
|
|
|
5032
5097
|
}
|
|
5033
5098
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5034
5099
|
}
|
|
5035
|
-
function
|
|
5100
|
+
function Go() {
|
|
5036
5101
|
let e = new a();
|
|
5037
5102
|
return e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(k, "-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) => {
|
|
5038
|
-
await
|
|
5103
|
+
await fo({
|
|
5039
5104
|
name: e.name,
|
|
5040
5105
|
directory: e.directory,
|
|
5041
5106
|
install: e.install,
|
|
@@ -5045,32 +5110,32 @@ function Vo() {
|
|
|
5045
5110
|
setup: e.setup
|
|
5046
5111
|
});
|
|
5047
5112
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5048
|
-
await
|
|
5113
|
+
await po({});
|
|
5049
5114
|
}), 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) => {
|
|
5050
|
-
await
|
|
5051
|
-
packs:
|
|
5115
|
+
await Do({
|
|
5116
|
+
packs: Uo(e.packs),
|
|
5052
5117
|
force: e.force,
|
|
5053
5118
|
yes: e.yes,
|
|
5054
5119
|
licenseKey: e.key ?? e.licenseKey,
|
|
5055
5120
|
cwd: e.cwd
|
|
5056
5121
|
});
|
|
5057
5122
|
}), 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) => {
|
|
5058
|
-
await
|
|
5123
|
+
await zo({
|
|
5059
5124
|
templateId: e,
|
|
5060
|
-
variants:
|
|
5061
|
-
packs:
|
|
5125
|
+
variants: Wo(t.variants),
|
|
5126
|
+
packs: Uo(t.packs),
|
|
5062
5127
|
force: t.force,
|
|
5063
5128
|
yes: t.yes,
|
|
5064
5129
|
licenseKey: t.key ?? t.licenseKey,
|
|
5065
5130
|
cwd: t.cwd
|
|
5066
5131
|
});
|
|
5067
5132
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5068
|
-
await
|
|
5133
|
+
await No();
|
|
5069
5134
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5070
|
-
await
|
|
5135
|
+
await Po();
|
|
5071
5136
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5072
|
-
await
|
|
5137
|
+
await No();
|
|
5073
5138
|
}), e;
|
|
5074
5139
|
}
|
|
5075
5140
|
//#endregion
|
|
5076
|
-
export {
|
|
5141
|
+
export { mo as a, Do as i, Po as n, po as o, No as r, fo as s, Go as t };
|