@hype-stack/cli 0.5.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.
|
@@ -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.5.
|
|
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);
|
|
@@ -2533,7 +2533,7 @@ function _r(e, t) {
|
|
|
2533
2533
|
};
|
|
2534
2534
|
}
|
|
2535
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),
|
|
2536
|
+
let t = w.join(e, "package.json"), n = w.join(e, "apps"), [r, i] = await Promise.all([Y(t), J(n)]);
|
|
2537
2537
|
return r && i;
|
|
2538
2538
|
}
|
|
2539
2539
|
function X(e, t) {
|
|
@@ -2548,7 +2548,7 @@ function X(e, t) {
|
|
|
2548
2548
|
//#endregion
|
|
2549
2549
|
//#region src/core/registry.ts
|
|
2550
2550
|
async function yr(e) {
|
|
2551
|
-
let { data: t, error: n, status: r } = await
|
|
2551
|
+
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
2552
2552
|
endpoint: `/packs/${encodeURIComponent(e)}/manifest`,
|
|
2553
2553
|
method: "GET"
|
|
2554
2554
|
}).send();
|
|
@@ -2557,12 +2557,12 @@ async function yr(e) {
|
|
|
2557
2557
|
return t;
|
|
2558
2558
|
}
|
|
2559
2559
|
async function br(e, t = {}) {
|
|
2560
|
-
let n =
|
|
2560
|
+
let n = K.createRequest()({
|
|
2561
2561
|
endpoint: `/packs/${encodeURIComponent(e)}/download`,
|
|
2562
2562
|
method: "POST"
|
|
2563
2563
|
}), r = {
|
|
2564
|
-
"X-Device-Id":
|
|
2565
|
-
"X-Client-Info":
|
|
2564
|
+
"X-Device-Id": Yn(),
|
|
2565
|
+
"X-Client-Info": Xn()
|
|
2566
2566
|
};
|
|
2567
2567
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
2568
2568
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -2589,7 +2589,7 @@ function xr(e, t, n) {
|
|
|
2589
2589
|
function Sr(e, t) {
|
|
2590
2590
|
return w.join(t, e);
|
|
2591
2591
|
}
|
|
2592
|
-
var Cr =
|
|
2592
|
+
var Cr = K.createRequest()({
|
|
2593
2593
|
endpoint: "/packs/list",
|
|
2594
2594
|
method: "GET"
|
|
2595
2595
|
});
|
|
@@ -2600,7 +2600,7 @@ async function wr() {
|
|
|
2600
2600
|
}
|
|
2601
2601
|
async function Tr(e, t = {}) {
|
|
2602
2602
|
if (e.length === 0) return {};
|
|
2603
|
-
let n =
|
|
2603
|
+
let n = K.createRequest()({
|
|
2604
2604
|
endpoint: "/packs/authorize",
|
|
2605
2605
|
method: "POST"
|
|
2606
2606
|
}), r = {};
|
|
@@ -2829,8 +2829,18 @@ async function Zr(e, t, n) {
|
|
|
2829
2829
|
function Qr(e, t) {
|
|
2830
2830
|
let n = ` "${t.path}": ${t.search};`, r = e.indexOf("type RouteDefinitions = {");
|
|
2831
2831
|
if (r === -1) return e;
|
|
2832
|
-
let i = e.indexOf("
|
|
2833
|
-
|
|
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);
|
|
2834
2844
|
}
|
|
2835
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 = {
|
|
2836
2846
|
primary: "primaryNav",
|
|
@@ -3027,16 +3037,30 @@ async function Di(e, t) {
|
|
|
3027
3037
|
} else await v.mkdir(w.dirname(t), { recursive: !0 }), await v.copyFile(e, t);
|
|
3028
3038
|
}
|
|
3029
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) {
|
|
3030
3054
|
let { file: t, packDir: n, paths: r, projectRoot: i } = e, a = Sr(t.source, n), o = xr(t.target, r, i);
|
|
3031
3055
|
return {
|
|
3032
3056
|
sourcePath: a,
|
|
3033
3057
|
targetPath: o,
|
|
3034
|
-
sourceExists: await Y(a) || await
|
|
3035
|
-
targetExists: await Y(o) || await
|
|
3058
|
+
sourceExists: await Y(a) || await J(a),
|
|
3059
|
+
targetExists: await Y(o) || await J(o)
|
|
3036
3060
|
};
|
|
3037
3061
|
}
|
|
3038
|
-
async function
|
|
3039
|
-
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({
|
|
3040
3064
|
file: t,
|
|
3041
3065
|
packDir: n,
|
|
3042
3066
|
paths: r,
|
|
@@ -3051,8 +3075,8 @@ async function ki(e) {
|
|
|
3051
3075
|
default: return `${t.target}: Unknown strategy: ${String(t.strategy)}`;
|
|
3052
3076
|
}
|
|
3053
3077
|
}
|
|
3054
|
-
async function
|
|
3055
|
-
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({
|
|
3056
3080
|
file: t,
|
|
3057
3081
|
packDir: n,
|
|
3058
3082
|
paths: r,
|
|
@@ -3118,7 +3142,7 @@ async function Ai(e) {
|
|
|
3118
3142
|
};
|
|
3119
3143
|
}
|
|
3120
3144
|
}
|
|
3121
|
-
async function
|
|
3145
|
+
async function Mi(e) {
|
|
3122
3146
|
let { packs: t, config: n, projectRoot: r, slotsByPack: i } = e, a = n.paths;
|
|
3123
3147
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3124
3148
|
let o = [], s = /* @__PURE__ */ new Set();
|
|
@@ -3126,7 +3150,7 @@ async function ji(e) {
|
|
|
3126
3150
|
let t = i?.get(e.manifest.name);
|
|
3127
3151
|
for (let n of e.manifest.files) {
|
|
3128
3152
|
if (n.strategy !== "create" || !Ei(n, t)) continue;
|
|
3129
|
-
let { targetPath: i, targetExists: c } = await
|
|
3153
|
+
let { targetPath: i, targetExists: c } = await ki({
|
|
3130
3154
|
file: n,
|
|
3131
3155
|
packDir: e.packDir,
|
|
3132
3156
|
paths: a,
|
|
@@ -3141,13 +3165,13 @@ async function ji(e) {
|
|
|
3141
3165
|
}
|
|
3142
3166
|
return o;
|
|
3143
3167
|
}
|
|
3144
|
-
async function
|
|
3168
|
+
async function Ni(e) {
|
|
3145
3169
|
let { manifest: t, config: n, projectRoot: r, force: i, packDir: a, slots: o } = e, s = n.paths;
|
|
3146
3170
|
if (!s) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3147
3171
|
let c = [];
|
|
3148
3172
|
for (let e of t.files) {
|
|
3149
3173
|
if (!Ei(e, o)) continue;
|
|
3150
|
-
let t = await
|
|
3174
|
+
let t = await Ai({
|
|
3151
3175
|
file: e,
|
|
3152
3176
|
packDir: a,
|
|
3153
3177
|
paths: s,
|
|
@@ -3158,7 +3182,7 @@ async function Mi(e) {
|
|
|
3158
3182
|
}
|
|
3159
3183
|
return c;
|
|
3160
3184
|
}
|
|
3161
|
-
async function
|
|
3185
|
+
async function Pi(e) {
|
|
3162
3186
|
let { manifest: t, config: n, projectRoot: r, force: i, overwrite: a, packDir: o, slots: s } = e, c = n.paths;
|
|
3163
3187
|
if (!c) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3164
3188
|
let l = {
|
|
@@ -3167,7 +3191,7 @@ async function Ni(e) {
|
|
|
3167
3191
|
errors: []
|
|
3168
3192
|
}, u = t.files.filter((e) => Ei(e, s));
|
|
3169
3193
|
for (let e of u) {
|
|
3170
|
-
let t = await
|
|
3194
|
+
let t = await ji({
|
|
3171
3195
|
file: e,
|
|
3172
3196
|
packDir: o,
|
|
3173
3197
|
paths: c,
|
|
@@ -3217,10 +3241,10 @@ async function Ni(e) {
|
|
|
3217
3241
|
slot: d[0]
|
|
3218
3242
|
}), l;
|
|
3219
3243
|
}
|
|
3220
|
-
async function
|
|
3244
|
+
async function Fi(e) {
|
|
3221
3245
|
let { packs: t, config: n, projectRoot: r, force: i, overwrite: a, slotsByPack: o } = e, s = [];
|
|
3222
3246
|
for (let e of t) {
|
|
3223
|
-
let t = o?.get(e.manifest.name), a = await
|
|
3247
|
+
let t = o?.get(e.manifest.name), a = await Ni({
|
|
3224
3248
|
manifest: e.manifest,
|
|
3225
3249
|
config: n,
|
|
3226
3250
|
projectRoot: r,
|
|
@@ -3240,7 +3264,7 @@ async function Pi(e) {
|
|
|
3240
3264
|
};
|
|
3241
3265
|
let c = [], l = [], u = [], d = [], f = n;
|
|
3242
3266
|
for (let e of t) {
|
|
3243
|
-
let t = o?.get(e.manifest.name), n = await
|
|
3267
|
+
let t = o?.get(e.manifest.name), n = await Pi({
|
|
3244
3268
|
manifest: e.manifest,
|
|
3245
3269
|
config: f,
|
|
3246
3270
|
projectRoot: r,
|
|
@@ -3249,7 +3273,7 @@ async function Pi(e) {
|
|
|
3249
3273
|
packDir: e.packDir,
|
|
3250
3274
|
slots: t
|
|
3251
3275
|
});
|
|
3252
|
-
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);
|
|
3253
3277
|
}
|
|
3254
3278
|
return {
|
|
3255
3279
|
installed: c,
|
|
@@ -3260,19 +3284,34 @@ async function Pi(e) {
|
|
|
3260
3284
|
config: f
|
|
3261
3285
|
};
|
|
3262
3286
|
}
|
|
3263
|
-
async function
|
|
3287
|
+
async function Ii(e, t, n) {
|
|
3264
3288
|
let r = {
|
|
3265
3289
|
...e,
|
|
3266
3290
|
installedPacks: [...e.installedPacks ?? [], t]
|
|
3267
3291
|
};
|
|
3268
3292
|
return await mr(n, r), r;
|
|
3269
3293
|
}
|
|
3270
|
-
async function
|
|
3294
|
+
async function Li(e) {
|
|
3271
3295
|
let { manifest: t, config: n, projectRoot: r, templateDir: i } = e, a = n.paths;
|
|
3272
3296
|
if (!a) throw Error("stack.json is missing 'paths' configuration. Run 'npx @hype-stack/cli init' to set it up.");
|
|
3273
|
-
let o = [], s = [];
|
|
3274
|
-
|
|
3275
|
-
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({
|
|
3276
3315
|
file: e,
|
|
3277
3316
|
packDir: i,
|
|
3278
3317
|
paths: a,
|
|
@@ -3280,17 +3319,10 @@ async function Ii(e) {
|
|
|
3280
3319
|
force: !0,
|
|
3281
3320
|
overwrite: /* @__PURE__ */ new Set()
|
|
3282
3321
|
});
|
|
3283
|
-
|
|
3284
|
-
case "installed":
|
|
3285
|
-
o.push(t.path);
|
|
3286
|
-
break;
|
|
3287
|
-
case "error":
|
|
3288
|
-
s.push(`${t.path}: ${t.reason}`);
|
|
3289
|
-
break;
|
|
3290
|
-
case "skipped": break;
|
|
3291
|
-
}
|
|
3322
|
+
t.status === "installed" ? o.push(t.path) : t.status === "error" && s.push(`${t.path}: ${t.reason}`);
|
|
3292
3323
|
}
|
|
3293
|
-
|
|
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({
|
|
3294
3326
|
entries: t.nav,
|
|
3295
3327
|
paths: a,
|
|
3296
3328
|
projectRoot: r
|
|
@@ -3305,28 +3337,28 @@ async function Ii(e) {
|
|
|
3305
3337
|
}
|
|
3306
3338
|
//#endregion
|
|
3307
3339
|
//#region src/core/pack-categories.ts
|
|
3308
|
-
var
|
|
3340
|
+
var Ri = [
|
|
3309
3341
|
"starter",
|
|
3310
3342
|
"layout",
|
|
3311
3343
|
"feature"
|
|
3312
|
-
],
|
|
3344
|
+
], zi = {
|
|
3313
3345
|
starter: "Starter",
|
|
3314
3346
|
layout: "Layout",
|
|
3315
3347
|
feature: "Features"
|
|
3316
|
-
},
|
|
3317
|
-
function
|
|
3348
|
+
}, Bi = new Set(["starter", "layout"]), Vi = "layout-basic";
|
|
3349
|
+
function Hi(e, t = {}) {
|
|
3318
3350
|
let n = [];
|
|
3319
|
-
for (let r of
|
|
3351
|
+
for (let r of Ri) {
|
|
3320
3352
|
let i = e.filter((e) => e.category === r);
|
|
3321
3353
|
if (i.length === 0) continue;
|
|
3322
|
-
let a =
|
|
3354
|
+
let a = Bi.has(r) ? "single" : "multiple";
|
|
3323
3355
|
if (r === "layout") {
|
|
3324
|
-
n.push(
|
|
3356
|
+
n.push(Ui("frontend", i)), t.adminAvailable && n.push(Ui("admin", i));
|
|
3325
3357
|
continue;
|
|
3326
3358
|
}
|
|
3327
3359
|
n.push({
|
|
3328
3360
|
category: r,
|
|
3329
|
-
label:
|
|
3361
|
+
label: zi[r],
|
|
3330
3362
|
mode: a,
|
|
3331
3363
|
packs: i,
|
|
3332
3364
|
preselect: null
|
|
@@ -3334,20 +3366,20 @@ function Vi(e, t = {}) {
|
|
|
3334
3366
|
}
|
|
3335
3367
|
return n;
|
|
3336
3368
|
}
|
|
3337
|
-
function
|
|
3338
|
-
let n = t.some((e) => e.name ===
|
|
3369
|
+
function Ui(e, t) {
|
|
3370
|
+
let n = t.some((e) => e.name === Vi);
|
|
3339
3371
|
return {
|
|
3340
3372
|
category: "layout",
|
|
3341
3373
|
label: e === "admin" ? "Admin Layout" : "Layout",
|
|
3342
3374
|
mode: "single",
|
|
3343
3375
|
packs: t,
|
|
3344
|
-
preselect: n ?
|
|
3376
|
+
preselect: n ? Vi : null,
|
|
3345
3377
|
slot: e
|
|
3346
3378
|
};
|
|
3347
3379
|
}
|
|
3348
3380
|
//#endregion
|
|
3349
3381
|
//#region src/ui/logger.ts
|
|
3350
|
-
function
|
|
3382
|
+
function Wi(e) {
|
|
3351
3383
|
o.note(e.map((e) => `${R.arrow} ${e}`).join("\n"), "Next steps");
|
|
3352
3384
|
}
|
|
3353
3385
|
function Z() {
|
|
@@ -3355,13 +3387,13 @@ function Z() {
|
|
|
3355
3387
|
}
|
|
3356
3388
|
//#endregion
|
|
3357
3389
|
//#region src/core/post-setup.ts
|
|
3358
|
-
async function
|
|
3359
|
-
return (await
|
|
3390
|
+
async function Gi() {
|
|
3391
|
+
return (await q("docker", ["info"], { cwd: process.cwd() })).exitCode === 0;
|
|
3360
3392
|
}
|
|
3361
|
-
async function
|
|
3393
|
+
async function Ki(e) {
|
|
3362
3394
|
return Y(`${e}/apps/backend/.env`);
|
|
3363
3395
|
}
|
|
3364
|
-
async function
|
|
3396
|
+
async function qi(e, t, n) {
|
|
3365
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({
|
|
3366
3398
|
message: r,
|
|
3367
3399
|
initialValue: !0
|
|
@@ -3369,20 +3401,20 @@ async function Ki(e, t, n) {
|
|
|
3369
3401
|
if (o.isCancel(i) && Z(), !i) return o.log.info(L.muted("Skipping Docker services and database migrations.")), !1;
|
|
3370
3402
|
let a = o.spinner();
|
|
3371
3403
|
a.start("Starting Docker services...");
|
|
3372
|
-
let s = await
|
|
3404
|
+
let s = await q("docker", [
|
|
3373
3405
|
"compose",
|
|
3374
3406
|
"up",
|
|
3375
3407
|
"-d"
|
|
3376
3408
|
], { cwd: `${e}/apps/backend` });
|
|
3377
|
-
return s.exitCode === 0 ? (a.stop(L.success("Docker services started")), !0) : (a.error("Failed to start Docker services"),
|
|
3409
|
+
return s.exitCode === 0 ? (a.stop(L.success("Docker services started")), !0) : (a.error("Failed to start Docker services"), Ji(s), !1);
|
|
3378
3410
|
}
|
|
3379
|
-
function
|
|
3411
|
+
function Ji(e) {
|
|
3380
3412
|
let t = (e.stderr || e.stdout).trim();
|
|
3381
3413
|
t && o.log.warn(L.muted(t));
|
|
3382
3414
|
}
|
|
3383
|
-
async function
|
|
3415
|
+
async function Yi(e, t = 15, n = 2e3) {
|
|
3384
3416
|
for (let r = 0; r < t; r++) {
|
|
3385
|
-
if ((await
|
|
3417
|
+
if ((await q("docker", [
|
|
3386
3418
|
"compose",
|
|
3387
3419
|
"exec",
|
|
3388
3420
|
"-T",
|
|
@@ -3395,14 +3427,14 @@ async function Ji(e, t = 15, n = 2e3) {
|
|
|
3395
3427
|
}
|
|
3396
3428
|
return !1;
|
|
3397
3429
|
}
|
|
3398
|
-
async function
|
|
3399
|
-
if (!await
|
|
3430
|
+
async function Xi(e, t, n = {}) {
|
|
3431
|
+
if (!await Ki(e)) {
|
|
3400
3432
|
o.log.warn(`${L.path(".env")} not found in ${L.path("apps/backend")}. Skipping Docker and migrations - configure it first.`);
|
|
3401
3433
|
return;
|
|
3402
3434
|
}
|
|
3403
|
-
if (!await
|
|
3435
|
+
if (!await qi(e, t, await Gi())) return;
|
|
3404
3436
|
let r = o.spinner();
|
|
3405
|
-
if (r.start("Waiting for Postgres to be ready..."), !await
|
|
3437
|
+
if (r.start("Waiting for Postgres to be ready..."), !await Yi(e, n.postgresMaxAttempts ?? 15, n.postgresCheckIntervalMs ?? 2e3)) {
|
|
3406
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"));
|
|
3407
3439
|
return;
|
|
3408
3440
|
}
|
|
@@ -3417,32 +3449,32 @@ async function Yi(e, t, n = {}) {
|
|
|
3417
3449
|
}
|
|
3418
3450
|
let a = o.spinner();
|
|
3419
3451
|
a.start("Running database migrations...");
|
|
3420
|
-
let s = await
|
|
3452
|
+
let s = await q("pnpm", [
|
|
3421
3453
|
"--filter",
|
|
3422
3454
|
"@internal/backend",
|
|
3423
3455
|
"migration:latest"
|
|
3424
3456
|
], { cwd: e });
|
|
3425
3457
|
if (s.exitCode !== 0) {
|
|
3426
|
-
a.error("Migrations failed"),
|
|
3458
|
+
a.error("Migrations failed"), Ji(s), o.log.warn(L.muted("Run `pnpm --filter @internal/backend migration:latest` manually to apply migrations."));
|
|
3427
3459
|
return;
|
|
3428
3460
|
}
|
|
3429
3461
|
a.stop(L.success("Database migrations applied"));
|
|
3430
3462
|
let c = o.spinner();
|
|
3431
3463
|
c.start("Generating Prisma client...");
|
|
3432
|
-
let l = await
|
|
3464
|
+
let l = await q("pnpm", [
|
|
3433
3465
|
"--filter",
|
|
3434
3466
|
"@internal/backend",
|
|
3435
3467
|
"generate"
|
|
3436
3468
|
], { cwd: e });
|
|
3437
3469
|
if (l.exitCode !== 0) {
|
|
3438
|
-
c.error("Prisma client generation failed"),
|
|
3470
|
+
c.error("Prisma client generation failed"), Ji(l), o.log.warn(L.muted("Run `pnpm --filter @internal/backend generate` manually."));
|
|
3439
3471
|
return;
|
|
3440
3472
|
}
|
|
3441
3473
|
c.stop(L.success("Prisma client generated"));
|
|
3442
3474
|
}
|
|
3443
3475
|
//#endregion
|
|
3444
3476
|
//#region src/core/resolve.ts
|
|
3445
|
-
function
|
|
3477
|
+
function Zi(e) {
|
|
3446
3478
|
let t = /* @__PURE__ */ new Map();
|
|
3447
3479
|
for (let n of e) t.set(n.name, {
|
|
3448
3480
|
name: n.name,
|
|
@@ -3450,7 +3482,7 @@ function Xi(e) {
|
|
|
3450
3482
|
});
|
|
3451
3483
|
return t;
|
|
3452
3484
|
}
|
|
3453
|
-
function
|
|
3485
|
+
function Qi(e, t, n = /* @__PURE__ */ new Set()) {
|
|
3454
3486
|
let r = /* @__PURE__ */ new Set();
|
|
3455
3487
|
function i(e) {
|
|
3456
3488
|
if (n.has(e)) return [];
|
|
@@ -3464,10 +3496,10 @@ function Zi(e, t, n = /* @__PURE__ */ new Set()) {
|
|
|
3464
3496
|
}
|
|
3465
3497
|
return i(e);
|
|
3466
3498
|
}
|
|
3467
|
-
function
|
|
3499
|
+
function $i(e, t, n = []) {
|
|
3468
3500
|
let r = new Set(n), i = new Set(n), a = [];
|
|
3469
3501
|
for (let n of e) {
|
|
3470
|
-
let e =
|
|
3502
|
+
let e = Qi(n, t, new Set(i));
|
|
3471
3503
|
for (let t of e) i.has(t) || (i.add(t), a.push(t));
|
|
3472
3504
|
}
|
|
3473
3505
|
return {
|
|
@@ -3475,7 +3507,7 @@ function Qi(e, t, n = []) {
|
|
|
3475
3507
|
alreadyInstalled: e.filter((e) => r.has(e))
|
|
3476
3508
|
};
|
|
3477
3509
|
}
|
|
3478
|
-
function
|
|
3510
|
+
function ea(e) {
|
|
3479
3511
|
let { order: t, graph: n, isLocked: r, installed: i = [] } = e, a = new Set(i), o = /* @__PURE__ */ new Set();
|
|
3480
3512
|
for (let e of t) {
|
|
3481
3513
|
let t = n.get(e)?.dependencies.some((e) => !a.has(e) && o.has(e)) ?? !1;
|
|
@@ -3488,7 +3520,7 @@ function $i(e) {
|
|
|
3488
3520
|
}
|
|
3489
3521
|
//#endregion
|
|
3490
3522
|
//#region src/core/variants.ts
|
|
3491
|
-
function
|
|
3523
|
+
function ta(e, t = {}) {
|
|
3492
3524
|
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
3493
3525
|
for (let i of e) {
|
|
3494
3526
|
let e = t[i.family] ?? i.default;
|
|
@@ -3500,14 +3532,14 @@ function ea(e, t = {}) {
|
|
|
3500
3532
|
familyOf: r
|
|
3501
3533
|
};
|
|
3502
3534
|
}
|
|
3503
|
-
function
|
|
3535
|
+
function na(e, t, n) {
|
|
3504
3536
|
return [...e.map((e) => n.chosen.get(e.family) ?? e.default), ...t];
|
|
3505
3537
|
}
|
|
3506
|
-
function
|
|
3538
|
+
function ra(e, t) {
|
|
3507
3539
|
let n = t.familyOf.get(e);
|
|
3508
3540
|
return n ? t.chosen.get(n) ?? e : e;
|
|
3509
3541
|
}
|
|
3510
|
-
function
|
|
3542
|
+
function ia(e, t) {
|
|
3511
3543
|
let n = /* @__PURE__ */ new Map();
|
|
3512
3544
|
for (let t of e) t.family && n.set(t.name, t.family);
|
|
3513
3545
|
let r = new Set(t), i = /* @__PURE__ */ new Map();
|
|
@@ -3523,65 +3555,65 @@ function ra(e, t) {
|
|
|
3523
3555
|
familyOf: n
|
|
3524
3556
|
};
|
|
3525
3557
|
}
|
|
3526
|
-
function
|
|
3558
|
+
function aa(e, t) {
|
|
3527
3559
|
return e.map((e) => ({
|
|
3528
3560
|
...e,
|
|
3529
|
-
dependencies: e.dependencies.map((e) =>
|
|
3561
|
+
dependencies: e.dependencies.map((e) => ra(e, t))
|
|
3530
3562
|
}));
|
|
3531
3563
|
}
|
|
3532
3564
|
//#endregion
|
|
3533
3565
|
//#region src/ui/banner.ts
|
|
3534
|
-
var
|
|
3566
|
+
var oa = [
|
|
3535
3567
|
" ██╗ ██╗ ██╗ ██╗ ██████╗ ███████╗",
|
|
3536
3568
|
" ██║ ██║ ╚██╗ ██╔╝ ██╔══██╗ ██╔════╝",
|
|
3537
3569
|
" ███████║ ╚████╔╝ ██████╔╝ █████╗ ",
|
|
3538
3570
|
" ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══╝ ",
|
|
3539
3571
|
" ██║ ██║ ██║ ██║ ███████╗",
|
|
3540
3572
|
" ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝"
|
|
3541
|
-
],
|
|
3573
|
+
], sa = [
|
|
3542
3574
|
" ███████╗ ████████╗ █████╗ ██████╗ ██╗ ██╗",
|
|
3543
3575
|
" ██╔════╝ ╚══██╔══╝ ██╔══██╗ ██╔════╝ ██║ ██╔╝",
|
|
3544
3576
|
" ███████╗ ██║ ███████║ ██║ █████╔╝ ",
|
|
3545
3577
|
" ╚════██║ ██║ ██╔══██║ ██║ ██╔═██╗ ",
|
|
3546
3578
|
" ███████║ ██║ ██║ ██║ ╚██████╗ ██║ ██╗",
|
|
3547
3579
|
" ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
3548
|
-
],
|
|
3580
|
+
], ca = [
|
|
3549
3581
|
253,
|
|
3550
3582
|
176,
|
|
3551
3583
|
21
|
|
3552
|
-
],
|
|
3584
|
+
], la = [
|
|
3553
3585
|
245,
|
|
3554
3586
|
76,
|
|
3555
3587
|
2
|
|
3556
|
-
],
|
|
3588
|
+
], ua = 5, da = [
|
|
3557
3589
|
17,
|
|
3558
3590
|
103,
|
|
3559
3591
|
248
|
|
3560
|
-
],
|
|
3592
|
+
], fa = [
|
|
3561
3593
|
42,
|
|
3562
3594
|
160,
|
|
3563
3595
|
250
|
|
3564
|
-
],
|
|
3565
|
-
function
|
|
3596
|
+
], pa = .2;
|
|
3597
|
+
function ma() {
|
|
3566
3598
|
console.log();
|
|
3567
|
-
for (let e of xe(aa, {
|
|
3568
|
-
start: sa,
|
|
3569
|
-
end: ca,
|
|
3570
|
-
angle: la
|
|
3571
|
-
})) console.log(y.bold(e));
|
|
3572
3599
|
for (let e of xe(oa, {
|
|
3573
|
-
start:
|
|
3574
|
-
end:
|
|
3575
|
-
angle:
|
|
3600
|
+
start: ca,
|
|
3601
|
+
end: la,
|
|
3602
|
+
angle: ua
|
|
3603
|
+
})) console.log(y.bold(e));
|
|
3604
|
+
for (let e of xe(sa, {
|
|
3605
|
+
start: da,
|
|
3606
|
+
end: fa,
|
|
3607
|
+
angle: pa
|
|
3576
3608
|
})) console.log(y.bold(e));
|
|
3577
3609
|
console.log(), console.log(` ${R.spark} ${y.dim("v" + k)} ${y.dim("·")} ${ye("Ship web + desktop apps from one codebase")}`), console.log();
|
|
3578
3610
|
}
|
|
3579
|
-
function
|
|
3611
|
+
function ha() {
|
|
3580
3612
|
console.log(), console.log(` ${R.bolt} ${ge.orange("Hype")}${ge.skyBlue("Stack")} ${y.dim("v" + k)}`), console.log();
|
|
3581
3613
|
}
|
|
3582
3614
|
//#endregion
|
|
3583
3615
|
//#region src/ui/pack-multiselect.ts
|
|
3584
|
-
var
|
|
3616
|
+
var ga = class extends D {
|
|
3585
3617
|
options;
|
|
3586
3618
|
cursor = 0;
|
|
3587
3619
|
selected;
|
|
@@ -3685,12 +3717,12 @@ var ha = class extends D {
|
|
|
3685
3717
|
}
|
|
3686
3718
|
}
|
|
3687
3719
|
};
|
|
3688
|
-
function
|
|
3689
|
-
return new
|
|
3720
|
+
function _a(e) {
|
|
3721
|
+
return new ga(e).prompt();
|
|
3690
3722
|
}
|
|
3691
3723
|
//#endregion
|
|
3692
3724
|
//#region src/core/apply-theme.ts
|
|
3693
|
-
function
|
|
3725
|
+
function va(e, t) {
|
|
3694
3726
|
let n = e.indexOf(t);
|
|
3695
3727
|
if (n === -1) return null;
|
|
3696
3728
|
let r = e.indexOf("{", n);
|
|
@@ -3705,46 +3737,46 @@ function _a(e, t) {
|
|
|
3705
3737
|
bodyEnd: a - 1
|
|
3706
3738
|
} : null;
|
|
3707
3739
|
}
|
|
3708
|
-
function
|
|
3740
|
+
function ya(e, t) {
|
|
3709
3741
|
let n = e;
|
|
3710
3742
|
for (let [e, r] of Object.entries(t)) {
|
|
3711
|
-
let t = RegExp(`(^[ \\t]*--${
|
|
3743
|
+
let t = RegExp(`(^[ \\t]*--${ba(e)}[ \\t]*:[ \\t]*)([^;\\n]*);`, "m");
|
|
3712
3744
|
n = n.replace(t, (e, t) => `${t}${r};`);
|
|
3713
3745
|
}
|
|
3714
3746
|
return n;
|
|
3715
3747
|
}
|
|
3716
|
-
function
|
|
3748
|
+
function ba(e) {
|
|
3717
3749
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3718
3750
|
}
|
|
3719
|
-
function
|
|
3720
|
-
let n =
|
|
3751
|
+
function xa(e, t) {
|
|
3752
|
+
let n = va(e, ":root"), r = va(e, ".dark"), i = e;
|
|
3721
3753
|
if (n) {
|
|
3722
3754
|
let e = i.slice(0, n.bodyStart), r = i.slice(n.bodyStart, n.bodyEnd), a = i.slice(n.bodyEnd);
|
|
3723
|
-
i = e +
|
|
3755
|
+
i = e + ya(r, t.light) + a;
|
|
3724
3756
|
}
|
|
3725
3757
|
if (r) {
|
|
3726
|
-
let e =
|
|
3758
|
+
let e = va(i, ".dark");
|
|
3727
3759
|
if (e) {
|
|
3728
3760
|
let n = i.slice(0, e.bodyStart), r = i.slice(e.bodyStart, e.bodyEnd), a = i.slice(e.bodyEnd);
|
|
3729
|
-
i = n +
|
|
3761
|
+
i = n + ya(r, t.dark) + a;
|
|
3730
3762
|
}
|
|
3731
3763
|
}
|
|
3732
3764
|
return i;
|
|
3733
3765
|
}
|
|
3734
|
-
var
|
|
3735
|
-
async function
|
|
3736
|
-
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;
|
|
3737
3769
|
try {
|
|
3738
3770
|
r = await v.readFile(n, "utf-8");
|
|
3739
3771
|
} catch {
|
|
3740
3772
|
return !1;
|
|
3741
3773
|
}
|
|
3742
|
-
let i =
|
|
3774
|
+
let i = xa(r, t);
|
|
3743
3775
|
return i === r || await v.writeFile(n, i, "utf-8"), !0;
|
|
3744
3776
|
}
|
|
3745
3777
|
//#endregion
|
|
3746
3778
|
//#region src/core/clone.ts
|
|
3747
|
-
async function
|
|
3779
|
+
async function wa(e) {
|
|
3748
3780
|
let t = await ee(te, {
|
|
3749
3781
|
dir: e,
|
|
3750
3782
|
force: !0
|
|
@@ -3756,7 +3788,7 @@ async function Ca(e) {
|
|
|
3756
3788
|
}
|
|
3757
3789
|
//#endregion
|
|
3758
3790
|
//#region src/core/editor-config.ts
|
|
3759
|
-
function
|
|
3791
|
+
function Ta(e) {
|
|
3760
3792
|
let t = {
|
|
3761
3793
|
globs: [],
|
|
3762
3794
|
alwaysApply: !1
|
|
@@ -3791,10 +3823,10 @@ function wa(e) {
|
|
|
3791
3823
|
content: i
|
|
3792
3824
|
};
|
|
3793
3825
|
}
|
|
3794
|
-
function
|
|
3826
|
+
function Ea(e) {
|
|
3795
3827
|
return e.frontmatter.globs.length > 0 ? `---\npaths:\n${e.frontmatter.globs.map((e) => ` - "${e}"`).join("\n")}\n---\n\n${e.content}` : e.content;
|
|
3796
3828
|
}
|
|
3797
|
-
function
|
|
3829
|
+
function Da(e) {
|
|
3798
3830
|
let t;
|
|
3799
3831
|
t = e.frontmatter.alwaysApply ? "always_on" : e.frontmatter.globs.length > 0 ? "glob" : "model_decision";
|
|
3800
3832
|
let n = [`trigger: ${t}`];
|
|
@@ -3804,30 +3836,30 @@ function Ea(e) {
|
|
|
3804
3836
|
}
|
|
3805
3837
|
return e.frontmatter.description && n.push(`description: ${e.frontmatter.description}`), `---\n${n.join("\n")}\n---\n\n${e.content}`;
|
|
3806
3838
|
}
|
|
3807
|
-
function
|
|
3839
|
+
function Oa(e) {
|
|
3808
3840
|
return e.frontmatter.globs.length > 0 ? `---\napplyTo: "${e.frontmatter.globs.join(", ")}"\n---\n\n${e.content}` : e.content;
|
|
3809
3841
|
}
|
|
3810
|
-
var
|
|
3842
|
+
var ka = {
|
|
3811
3843
|
claude: {
|
|
3812
3844
|
rulesDir: ".claude/rules",
|
|
3813
3845
|
extension: ".md",
|
|
3814
|
-
convert:
|
|
3846
|
+
convert: Ea
|
|
3815
3847
|
},
|
|
3816
3848
|
windsurf: {
|
|
3817
3849
|
rulesDir: ".windsurf/rules",
|
|
3818
3850
|
extension: ".md",
|
|
3819
|
-
convert:
|
|
3851
|
+
convert: Da
|
|
3820
3852
|
},
|
|
3821
3853
|
copilot: {
|
|
3822
3854
|
rulesDir: ".github/instructions",
|
|
3823
3855
|
extension: ".instructions.md",
|
|
3824
|
-
convert:
|
|
3856
|
+
convert: Oa
|
|
3825
3857
|
}
|
|
3826
3858
|
};
|
|
3827
|
-
async function
|
|
3859
|
+
async function Aa(e) {
|
|
3828
3860
|
let t = w.join(e, se), n = (await v.readdir(t, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isFile() && e.name.endsWith(".mdc"));
|
|
3829
3861
|
return await Promise.all(n.map(async (e) => {
|
|
3830
|
-
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"));
|
|
3831
3863
|
return {
|
|
3832
3864
|
frontmatter: r,
|
|
3833
3865
|
content: i,
|
|
@@ -3835,9 +3867,9 @@ async function ka(e) {
|
|
|
3835
3867
|
};
|
|
3836
3868
|
}));
|
|
3837
3869
|
}
|
|
3838
|
-
async function
|
|
3870
|
+
async function ja(e, t) {
|
|
3839
3871
|
if (t === "cursor") return;
|
|
3840
|
-
let n =
|
|
3872
|
+
let n = ka[t], r = await Aa(e), i = w.join(e, n.rulesDir);
|
|
3841
3873
|
await v.mkdir(i, { recursive: !0 }), await Promise.all(r.map((e) => {
|
|
3842
3874
|
let t = n.convert(e), r = e.filename.replace(/\.mdc$/, n.extension);
|
|
3843
3875
|
return v.writeFile(w.join(i, r), t, "utf-8");
|
|
@@ -3845,21 +3877,21 @@ async function Aa(e, t) {
|
|
|
3845
3877
|
}
|
|
3846
3878
|
//#endregion
|
|
3847
3879
|
//#region src/core/env-files.ts
|
|
3848
|
-
var
|
|
3880
|
+
var Ma = [
|
|
3849
3881
|
"apps",
|
|
3850
3882
|
"packages",
|
|
3851
3883
|
"libs",
|
|
3852
3884
|
"shared"
|
|
3853
3885
|
];
|
|
3854
|
-
async function
|
|
3855
|
-
let t = await
|
|
3886
|
+
async function Na(e) {
|
|
3887
|
+
let t = await Pa(e);
|
|
3856
3888
|
return (await Promise.all(t.map(async (t) => {
|
|
3857
3889
|
let n = w.join(w.dirname(t), ".env");
|
|
3858
3890
|
return await Y(n) ? null : (await v.copyFile(t, n), w.relative(e, n));
|
|
3859
3891
|
}))).filter((e) => e !== null).sort();
|
|
3860
3892
|
}
|
|
3861
|
-
async function
|
|
3862
|
-
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) => {
|
|
3863
3895
|
let n = w.join(e, t);
|
|
3864
3896
|
return (await v.readdir(n, { withFileTypes: !0 }).catch(() => [])).filter((e) => e.isDirectory()).map((e) => w.join(n, e.name, ".env.example"));
|
|
3865
3897
|
}));
|
|
@@ -3867,12 +3899,12 @@ async function Na(e) {
|
|
|
3867
3899
|
}
|
|
3868
3900
|
//#endregion
|
|
3869
3901
|
//#region src/core/post-clone.ts
|
|
3870
|
-
var Q = "@hype-stack/",
|
|
3871
|
-
async function
|
|
3902
|
+
var Q = "@hype-stack/", Fa = "hype-stack";
|
|
3903
|
+
async function Ia(e) {
|
|
3872
3904
|
await sr(w.join(e, ".git"));
|
|
3873
3905
|
}
|
|
3874
|
-
async function
|
|
3875
|
-
await
|
|
3906
|
+
async function La(e) {
|
|
3907
|
+
await q("git", ["init"], { cwd: e }), await q("git", ["add", "."], { cwd: e }), await q("git", [
|
|
3876
3908
|
"-c",
|
|
3877
3909
|
"user.name=Hype Stack CLI",
|
|
3878
3910
|
"-c",
|
|
@@ -3882,22 +3914,22 @@ async function Ia(e) {
|
|
|
3882
3914
|
"Initial commit from Hype Stack CLI"
|
|
3883
3915
|
], { cwd: e });
|
|
3884
3916
|
}
|
|
3885
|
-
async function
|
|
3886
|
-
let n = `@${t}/`, r = await
|
|
3917
|
+
async function Ra(e, t) {
|
|
3918
|
+
let n = `@${t}/`, r = await Ka(e);
|
|
3887
3919
|
for (let e of r) {
|
|
3888
3920
|
let t = await ir(e);
|
|
3889
3921
|
if (!t) continue;
|
|
3890
3922
|
let r = !1;
|
|
3891
|
-
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);
|
|
3892
3924
|
let i = await v.readFile(e, "utf-8");
|
|
3893
3925
|
if (i.includes(Q)) {
|
|
3894
3926
|
let t = i.replaceAll(Q, n);
|
|
3895
3927
|
await v.writeFile(e, t, "utf-8");
|
|
3896
3928
|
} else r && await ar(e, t);
|
|
3897
3929
|
}
|
|
3898
|
-
await Ci(e, t), await
|
|
3930
|
+
await Ci(e, t), await Va(e, t), await Ga(e, t);
|
|
3899
3931
|
}
|
|
3900
|
-
var
|
|
3932
|
+
var za = new Set([
|
|
3901
3933
|
".git",
|
|
3902
3934
|
"node_modules",
|
|
3903
3935
|
"dist",
|
|
@@ -3905,10 +3937,10 @@ var Ra = new Set([
|
|
|
3905
3937
|
".nx",
|
|
3906
3938
|
".next",
|
|
3907
3939
|
"coverage"
|
|
3908
|
-
]),
|
|
3909
|
-
async function
|
|
3910
|
-
if (t ===
|
|
3911
|
-
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);
|
|
3912
3944
|
await Promise.all(n.map(async (e) => {
|
|
3913
3945
|
let n = await v.readFile(e, "utf-8").catch(() => null);
|
|
3914
3946
|
if (!n || !/^name:[ \t]*hype-stack/m.test(n)) return;
|
|
@@ -3916,14 +3948,14 @@ async function Ba(e, t) {
|
|
|
3916
3948
|
await v.writeFile(e, r, "utf-8");
|
|
3917
3949
|
}));
|
|
3918
3950
|
}
|
|
3919
|
-
async function
|
|
3951
|
+
async function Ha(e) {
|
|
3920
3952
|
let t = await v.readdir(e, { withFileTypes: !0 }).catch(() => []);
|
|
3921
3953
|
return (await Promise.all(t.map(async (t) => {
|
|
3922
3954
|
let n = w.join(e, t.name);
|
|
3923
|
-
return t.isDirectory() ?
|
|
3955
|
+
return t.isDirectory() ? za.has(t.name) ? [] : Ha(n) : t.isFile() && Ba.test(t.name) ? [n] : [];
|
|
3924
3956
|
}))).flat();
|
|
3925
3957
|
}
|
|
3926
|
-
function
|
|
3958
|
+
function Ua(e, t) {
|
|
3927
3959
|
if (!e) return !1;
|
|
3928
3960
|
let n = !1;
|
|
3929
3961
|
for (let r of Object.keys(e)) if (r.startsWith(Q)) {
|
|
@@ -3932,7 +3964,7 @@ function Ha(e, t) {
|
|
|
3932
3964
|
}
|
|
3933
3965
|
return n;
|
|
3934
3966
|
}
|
|
3935
|
-
function
|
|
3967
|
+
function Wa(e, t) {
|
|
3936
3968
|
if (!e) return !1;
|
|
3937
3969
|
let n = !1;
|
|
3938
3970
|
if (e.implicitDependencies &&= e.implicitDependencies.map((e) => e.startsWith(Q) ? (n = !0, e.replace(Q, t)) : e), e.targets) {
|
|
@@ -3940,13 +3972,13 @@ function Ua(e, t) {
|
|
|
3940
3972
|
}
|
|
3941
3973
|
return n;
|
|
3942
3974
|
}
|
|
3943
|
-
async function
|
|
3975
|
+
async function Ga(e, t) {
|
|
3944
3976
|
let n = w.join(e, "packages/enums/src/app/index.ts"), r = await v.readFile(n, "utf-8").catch(() => null);
|
|
3945
3977
|
if (!r) return;
|
|
3946
|
-
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"`);
|
|
3947
3979
|
await v.writeFile(n, a, "utf-8");
|
|
3948
3980
|
}
|
|
3949
|
-
async function
|
|
3981
|
+
async function Ka(e) {
|
|
3950
3982
|
let t = [], n = w.join(e, "package.json");
|
|
3951
3983
|
(await v.stat(n).catch(() => null))?.isFile() && t.push(n);
|
|
3952
3984
|
for (let n of [
|
|
@@ -3966,7 +3998,7 @@ async function Ga(e) {
|
|
|
3966
3998
|
}
|
|
3967
3999
|
//#endregion
|
|
3968
4000
|
//#region src/core/readme.ts
|
|
3969
|
-
var
|
|
4001
|
+
var qa = {
|
|
3970
4002
|
cursor: {
|
|
3971
4003
|
label: "Cursor",
|
|
3972
4004
|
rulesDir: ".cursor/rules"
|
|
@@ -3983,24 +4015,24 @@ var Ka = {
|
|
|
3983
4015
|
label: "GitHub Copilot",
|
|
3984
4016
|
rulesDir: ".github/instructions"
|
|
3985
4017
|
}
|
|
3986
|
-
},
|
|
4018
|
+
}, Ja = {
|
|
3987
4019
|
backend: "Hono API server (Postgres, Prisma, Kysely, Valkey cache, WorkOS auth)",
|
|
3988
4020
|
frontend: "React + Vite app talking to the backend through the typed HyperFetch SDK"
|
|
3989
|
-
},
|
|
4021
|
+
}, Ya = {
|
|
3990
4022
|
enums: "Shared enums and app config used across apps",
|
|
3991
4023
|
cli: "Project tooling and code generators"
|
|
3992
4024
|
};
|
|
3993
|
-
function
|
|
4025
|
+
function Xa(e) {
|
|
3994
4026
|
return e.split(/[-_]/).filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
3995
4027
|
}
|
|
3996
|
-
function
|
|
4028
|
+
function Za(e, t) {
|
|
3997
4029
|
return Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
|
|
3998
4030
|
let r = t[e];
|
|
3999
4031
|
return r ? `- \`${n}\` - ${r}` : `- \`${n}\``;
|
|
4000
4032
|
});
|
|
4001
4033
|
}
|
|
4002
|
-
function
|
|
4003
|
-
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 = [];
|
|
4004
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)");
|
|
4005
4037
|
let u = [];
|
|
4006
4038
|
u.push(`# ${i}`), u.push([
|
|
@@ -4108,19 +4140,19 @@ function Za(e) {
|
|
|
4108
4140
|
"stays useful."
|
|
4109
4141
|
].join("\n")), u.join("\n\n") + "\n";
|
|
4110
4142
|
}
|
|
4111
|
-
async function
|
|
4143
|
+
async function $a(e, t) {
|
|
4112
4144
|
let n = w.join(e, "README.md");
|
|
4113
|
-
await v.writeFile(n,
|
|
4145
|
+
await v.writeFile(n, Qa(t), "utf-8");
|
|
4114
4146
|
}
|
|
4115
4147
|
//#endregion
|
|
4116
4148
|
//#region src/core/tracking.ts
|
|
4117
|
-
async function
|
|
4149
|
+
async function eo(e) {
|
|
4118
4150
|
try {
|
|
4119
4151
|
let t = {
|
|
4120
|
-
"X-Device-Id":
|
|
4121
|
-
"X-Client-Info":
|
|
4122
|
-
}, n = await
|
|
4123
|
-
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()({
|
|
4124
4156
|
endpoint: "/cli/track",
|
|
4125
4157
|
method: "POST"
|
|
4126
4158
|
}).setPayload({ event: e }).setHeaders(t).send();
|
|
@@ -4128,7 +4160,7 @@ async function $a(e) {
|
|
|
4128
4160
|
}
|
|
4129
4161
|
//#endregion
|
|
4130
4162
|
//#region src/ui/swatch.ts
|
|
4131
|
-
function
|
|
4163
|
+
function to(e) {
|
|
4132
4164
|
let t = e.trim().match(/^oklch\(([^)]+)\)$/i);
|
|
4133
4165
|
if (!t) return null;
|
|
4134
4166
|
let n = t[1].trim().split(/\s+/);
|
|
@@ -4147,61 +4179,61 @@ function eo(e) {
|
|
|
4147
4179
|
h: a
|
|
4148
4180
|
};
|
|
4149
4181
|
}
|
|
4150
|
-
function
|
|
4182
|
+
function no(e) {
|
|
4151
4183
|
return Math.min(255, Math.max(0, Math.round(e)));
|
|
4152
4184
|
}
|
|
4153
|
-
function
|
|
4185
|
+
function ro(e) {
|
|
4154
4186
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
4155
4187
|
}
|
|
4156
|
-
function
|
|
4188
|
+
function io({ l: e, c: t, h: n }) {
|
|
4157
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;
|
|
4158
4190
|
return [
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4191
|
+
no(ro(f) * 255),
|
|
4192
|
+
no(ro(p) * 255),
|
|
4193
|
+
no(ro(m) * 255)
|
|
4162
4194
|
];
|
|
4163
4195
|
}
|
|
4164
|
-
var
|
|
4165
|
-
function
|
|
4196
|
+
var ao = "\x1B[49m";
|
|
4197
|
+
function oo(e, t) {
|
|
4166
4198
|
let n = e[t];
|
|
4167
4199
|
if (!n) return y.dim(" ");
|
|
4168
|
-
let r =
|
|
4200
|
+
let r = to(n);
|
|
4169
4201
|
if (!r) return y.dim(" ");
|
|
4170
|
-
let [i, a, o] =
|
|
4171
|
-
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}`;
|
|
4172
4204
|
}
|
|
4173
|
-
var
|
|
4205
|
+
var so = [
|
|
4174
4206
|
"primary",
|
|
4175
4207
|
"secondary",
|
|
4176
4208
|
"accent"
|
|
4177
4209
|
];
|
|
4178
|
-
function so(e) {
|
|
4179
|
-
return oo.map((t) => ao(e, t)).join("");
|
|
4180
|
-
}
|
|
4181
4210
|
function co(e) {
|
|
4182
|
-
return
|
|
4211
|
+
return so.map((t) => oo(e, t)).join("");
|
|
4212
|
+
}
|
|
4213
|
+
function lo(e) {
|
|
4214
|
+
return `${co(e.light)} ${y.dim("·")} ${co(e.dark)}`;
|
|
4183
4215
|
}
|
|
4184
4216
|
//#endregion
|
|
4185
4217
|
//#region src/utils/validate.ts
|
|
4186
|
-
function
|
|
4218
|
+
function uo(e) {
|
|
4187
4219
|
if (!e.trim()) return "Project name cannot be empty";
|
|
4188
4220
|
if (!M.test(e)) return "Project name must be lowercase, alphanumeric, and may contain hyphens, dots, or underscores";
|
|
4189
4221
|
if (e.length > 214) return "Project name is too long (max 214 characters)";
|
|
4190
4222
|
}
|
|
4191
4223
|
//#endregion
|
|
4192
4224
|
//#region src/commands/create.ts
|
|
4193
|
-
async function
|
|
4194
|
-
a.skipBanner ||
|
|
4225
|
+
async function fo(a) {
|
|
4226
|
+
a.skipBanner || ma(), o.intro(L.brandBold("Create a new Hype Stack project"));
|
|
4195
4227
|
let s = a.yes === !0, c;
|
|
4196
4228
|
if (s && a.name) {
|
|
4197
|
-
let e =
|
|
4229
|
+
let e = uo(a.name);
|
|
4198
4230
|
e && (o.log.error(e), Z()), c = a.name;
|
|
4199
4231
|
} else {
|
|
4200
4232
|
let e = await o.text({
|
|
4201
4233
|
message: "What is your project named?",
|
|
4202
4234
|
placeholder: "my-app",
|
|
4203
4235
|
initialValue: a.name ?? "",
|
|
4204
|
-
validate: (e) =>
|
|
4236
|
+
validate: (e) => uo(e ?? "")
|
|
4205
4237
|
});
|
|
4206
4238
|
o.isCancel(e) && Z(), c = e;
|
|
4207
4239
|
}
|
|
@@ -4246,7 +4278,7 @@ async function uo(a) {
|
|
|
4246
4278
|
message: "Pick a color theme",
|
|
4247
4279
|
options: n.map((e) => ({
|
|
4248
4280
|
value: e.name,
|
|
4249
|
-
label: `${
|
|
4281
|
+
label: `${lo(e)} ${e.label}`
|
|
4250
4282
|
})),
|
|
4251
4283
|
initialValue: e
|
|
4252
4284
|
});
|
|
@@ -4256,7 +4288,7 @@ async function uo(a) {
|
|
|
4256
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?` });
|
|
4257
4289
|
(o.isCancel(r) || !r) && Z();
|
|
4258
4290
|
}
|
|
4259
|
-
if (await
|
|
4291
|
+
if (await J(u) && !await rr(u)) {
|
|
4260
4292
|
let e = await o.confirm({
|
|
4261
4293
|
message: `Directory ${L.path(u)} is not empty. Continue anyway?`,
|
|
4262
4294
|
initialValue: !1
|
|
@@ -4264,29 +4296,29 @@ async function uo(a) {
|
|
|
4264
4296
|
(o.isCancel(e) || !e) && Z();
|
|
4265
4297
|
}
|
|
4266
4298
|
let h = o.spinner();
|
|
4267
|
-
h.start("Cloning Hype Stack template..."), await
|
|
4299
|
+
h.start("Cloning Hype Stack template..."), await wa(u), h.stop(L.success("Template cloned"));
|
|
4268
4300
|
let g = o.spinner();
|
|
4269
|
-
g.start("Setting up project..."), await
|
|
4301
|
+
g.start("Setting up project..."), await Ia(u), await Ra(u, c), await ja(u, f);
|
|
4270
4302
|
let _ = await hr(u), v = _r(c, _);
|
|
4271
|
-
await mr(u, v), await
|
|
4303
|
+
await mr(u, v), await $a(u, {
|
|
4272
4304
|
projectName: c,
|
|
4273
4305
|
editor: f,
|
|
4274
4306
|
workspace: _
|
|
4275
|
-
}), 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"));
|
|
4276
4308
|
let y = o.spinner();
|
|
4277
|
-
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.")));
|
|
4278
4310
|
let b = o.spinner();
|
|
4279
|
-
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"));
|
|
4280
4312
|
let x = o.spinner();
|
|
4281
4313
|
x.start("Creating .env files from examples...");
|
|
4282
|
-
let S = await
|
|
4314
|
+
let S = await Na(u);
|
|
4283
4315
|
if (S.length > 0) {
|
|
4284
4316
|
let e = S.length;
|
|
4285
4317
|
x.stop(L.success(`Created ${e} .env file${e === 1 ? "" : "s"} from examples`));
|
|
4286
4318
|
} else x.stop(L.muted("No .env.example files to copy"));
|
|
4287
4319
|
o.log.success(`${L.brandBold("Hype Stack")} project ${L.highlight(c)} is ready!`);
|
|
4288
4320
|
let C = w.relative(process.cwd(), u) || ".", T = [`${L.command(`cd ${C}`)}`];
|
|
4289
|
-
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);
|
|
4290
4322
|
let E = a.setup === !1;
|
|
4291
4323
|
if (a.deferSetup) o.log.info(L.muted("Docker and migrations will run after your packs are installed."));
|
|
4292
4324
|
else {
|
|
@@ -4294,19 +4326,19 @@ async function uo(a) {
|
|
|
4294
4326
|
message: "Would you like to start Docker services and run database migrations now?",
|
|
4295
4327
|
initialValue: !0
|
|
4296
4328
|
}));
|
|
4297
|
-
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([
|
|
4298
4330
|
`${L.command("docker compose up -d")} ${L.muted("(in apps/backend - start Postgres, Valkey, RustFS)")}`,
|
|
4299
4331
|
`${L.command("pnpm --filter @internal/backend migration:latest")} ${L.muted("(apply migrations)")}`,
|
|
4300
4332
|
`${L.command("pnpm run generate")} ${L.muted("(generate Prisma client)")}`
|
|
4301
|
-
])),
|
|
4333
|
+
])), Wi([`${L.command("pnpm dev")} ${L.muted("(start frontend + backend)")}`]);
|
|
4302
4334
|
}
|
|
4303
|
-
return await
|
|
4335
|
+
return await eo("project_create"), o.outro(L.muted("Happy building!")), u;
|
|
4304
4336
|
}
|
|
4305
4337
|
//#endregion
|
|
4306
4338
|
//#region src/commands/init.ts
|
|
4307
|
-
async function
|
|
4339
|
+
async function po(e) {
|
|
4308
4340
|
let t = e.cwd ?? process.cwd(), n = e.silent ?? !1;
|
|
4309
|
-
if (n || (
|
|
4341
|
+
if (n || (ha(), o.intro(L.brandBold("Initialize Hype Stack configuration"))), !await vr(t)) {
|
|
4310
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.`));
|
|
4311
4343
|
return;
|
|
4312
4344
|
}
|
|
@@ -4348,15 +4380,15 @@ async function fo(e) {
|
|
|
4348
4380
|
}
|
|
4349
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.")));
|
|
4350
4382
|
}
|
|
4351
|
-
async function
|
|
4383
|
+
async function mo(e, t = {}) {
|
|
4352
4384
|
if (await pr(e)) return {
|
|
4353
4385
|
projectRoot: e,
|
|
4354
4386
|
scaffolded: !1
|
|
4355
4387
|
};
|
|
4356
|
-
let n = t.runInit ?? ((e) =>
|
|
4388
|
+
let n = t.runInit ?? ((e) => po({
|
|
4357
4389
|
cwd: e,
|
|
4358
4390
|
silent: !0
|
|
4359
|
-
})), r = t.runCreate ?? ((e) =>
|
|
4391
|
+
})), r = t.runCreate ?? ((e) => fo({
|
|
4360
4392
|
parentDirectory: e,
|
|
4361
4393
|
deferSetup: !0,
|
|
4362
4394
|
skipBanner: !0
|
|
@@ -4394,7 +4426,7 @@ async function po(e, t = {}) {
|
|
|
4394
4426
|
}
|
|
4395
4427
|
//#endregion
|
|
4396
4428
|
//#region src/core/npm-deps.ts
|
|
4397
|
-
function
|
|
4429
|
+
function ho(e, t) {
|
|
4398
4430
|
let n = [], r = [];
|
|
4399
4431
|
if (!e) return {
|
|
4400
4432
|
errors: n,
|
|
@@ -4425,7 +4457,7 @@ function mo(e, t) {
|
|
|
4425
4457
|
operations: r
|
|
4426
4458
|
};
|
|
4427
4459
|
}
|
|
4428
|
-
function
|
|
4460
|
+
function go(e) {
|
|
4429
4461
|
let t = {};
|
|
4430
4462
|
for (let n of e) if (n) for (let [e, r] of Object.entries(n)) t[e] = {
|
|
4431
4463
|
...t[e],
|
|
@@ -4433,7 +4465,7 @@ function ho(e) {
|
|
|
4433
4465
|
};
|
|
4434
4466
|
return t;
|
|
4435
4467
|
}
|
|
4436
|
-
async function
|
|
4468
|
+
async function _o(e, t, n = q) {
|
|
4437
4469
|
let r = [];
|
|
4438
4470
|
for (let i of e) {
|
|
4439
4471
|
let e = w.join(t, i.relativeDir);
|
|
@@ -4469,22 +4501,22 @@ async function go(e, t, n = J) {
|
|
|
4469
4501
|
function $(e) {
|
|
4470
4502
|
return e instanceof Error ? e.message : String(e);
|
|
4471
4503
|
}
|
|
4472
|
-
async function
|
|
4504
|
+
async function vo(e, t, n) {
|
|
4473
4505
|
let r = e.filter((e) => e.tier === "paid" && !t.has(e.name)).map((e) => e.name);
|
|
4474
4506
|
return r.length === 0 ? {} : Tr(r, n).catch(() => ({}));
|
|
4475
4507
|
}
|
|
4476
|
-
function
|
|
4508
|
+
function yo(e, t) {
|
|
4477
4509
|
return e === "free" ? L.success("free") : e === "owned" ? L.accent("owned") : `${L.highlight(`$${t}`)} ${L.muted("locked")}`;
|
|
4478
4510
|
}
|
|
4479
|
-
async function
|
|
4511
|
+
async function bo(e, t, n) {
|
|
4480
4512
|
let r = e.filter((e) => t(e)), i = e.filter((e) => !t(e));
|
|
4481
|
-
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) => ({
|
|
4482
4514
|
name: e.name,
|
|
4483
4515
|
displayName: e.displayName,
|
|
4484
4516
|
price: e.price
|
|
4485
4517
|
})));
|
|
4486
4518
|
}
|
|
4487
|
-
function
|
|
4519
|
+
function xo(e, t) {
|
|
4488
4520
|
let n = e.map((e, n) => {
|
|
4489
4521
|
let r = t.get(e), i = r ? r.displayName : e;
|
|
4490
4522
|
return ` ${L.muted(`${n + 1}.`)} ${L.brand(i)}`;
|
|
@@ -4495,7 +4527,7 @@ function bo(e, t) {
|
|
|
4495
4527
|
...n
|
|
4496
4528
|
].join("\n"), "Install Plan");
|
|
4497
4529
|
}
|
|
4498
|
-
async function
|
|
4530
|
+
async function So(e, t) {
|
|
4499
4531
|
let n = [];
|
|
4500
4532
|
for (let r of e) {
|
|
4501
4533
|
let e = await yr(r), i = await br(r, t);
|
|
@@ -4507,22 +4539,22 @@ async function xo(e, t) {
|
|
|
4507
4539
|
}
|
|
4508
4540
|
return n;
|
|
4509
4541
|
}
|
|
4510
|
-
async function
|
|
4511
|
-
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);
|
|
4512
4544
|
if (a.errors.length > 0) {
|
|
4513
4545
|
for (let e of a.errors) o.log.error(e);
|
|
4514
4546
|
return;
|
|
4515
4547
|
}
|
|
4516
4548
|
if (a.operations.length === 0) return;
|
|
4517
4549
|
i.start("Installing npm dependencies...");
|
|
4518
|
-
let s = await
|
|
4550
|
+
let s = await _o(a.operations, r);
|
|
4519
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);
|
|
4520
4552
|
}
|
|
4521
|
-
function
|
|
4553
|
+
function wo(e) {
|
|
4522
4554
|
let t = e.flatMap((e) => e.manifest.postInstall ?? []), n = [...new Set(t)];
|
|
4523
4555
|
n.length !== 0 && o.note(n.map((e) => ` ${L.muted("→")} ${e}`).join("\n"), "Next Steps");
|
|
4524
4556
|
}
|
|
4525
|
-
function
|
|
4557
|
+
function To(e) {
|
|
4526
4558
|
if (e.length === 0) return;
|
|
4527
4559
|
let t = e.map((e) => {
|
|
4528
4560
|
let t = e.replace(/^\{\{[^}]+\}\}\//, "");
|
|
@@ -4530,10 +4562,10 @@ function wo(e) {
|
|
|
4530
4562
|
});
|
|
4531
4563
|
o.note(t.join("\n"), "Skipped (already exist)");
|
|
4532
4564
|
}
|
|
4533
|
-
async function
|
|
4565
|
+
async function Eo(e) {
|
|
4534
4566
|
let { prepared: t, config: n, cwd: r, force: i, yes: a, slotsByPack: s } = e, c = /* @__PURE__ */ new Set();
|
|
4535
4567
|
if (i) return c;
|
|
4536
|
-
let l = await
|
|
4568
|
+
let l = await Mi({
|
|
4537
4569
|
packs: t,
|
|
4538
4570
|
config: n,
|
|
4539
4571
|
projectRoot: r,
|
|
@@ -4560,10 +4592,10 @@ async function To(e) {
|
|
|
4560
4592
|
}
|
|
4561
4593
|
//#endregion
|
|
4562
4594
|
//#region src/commands/compose.ts
|
|
4563
|
-
async function
|
|
4595
|
+
async function Do(e = {}) {
|
|
4564
4596
|
let t = e.cwd ?? process.cwd();
|
|
4565
|
-
|
|
4566
|
-
let n = await
|
|
4597
|
+
ma();
|
|
4598
|
+
let n = await mo(t), r = n?.projectRoot ?? null, i = n?.scaffolded ?? !1, a;
|
|
4567
4599
|
try {
|
|
4568
4600
|
a = await fr(r ?? t);
|
|
4569
4601
|
} catch (e) {
|
|
@@ -4581,13 +4613,13 @@ async function Eo(e = {}) {
|
|
|
4581
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);
|
|
4582
4614
|
}
|
|
4583
4615
|
c.stop("Packs loaded");
|
|
4584
|
-
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, {
|
|
4585
4617
|
token: m,
|
|
4586
4618
|
key: p
|
|
4587
4619
|
}), g = (e) => {
|
|
4588
4620
|
let t = f.get(e);
|
|
4589
4621
|
return !t || t.tier === "free" ? "free" : h[e]?.owned ? "owned" : "locked";
|
|
4590
|
-
}, _ = (e) => !d.has(e) && g(e) === "locked", y = await
|
|
4622
|
+
}, _ = (e) => !d.has(e) && g(e) === "locked", y = await Oo({
|
|
4591
4623
|
packs: l,
|
|
4592
4624
|
installedSet: d,
|
|
4593
4625
|
stateOf: g,
|
|
@@ -4598,9 +4630,9 @@ async function Eo(e = {}) {
|
|
|
4598
4630
|
o.outro(L.muted("No packs selected. Nothing to do."));
|
|
4599
4631
|
return;
|
|
4600
4632
|
}
|
|
4601
|
-
let b =
|
|
4633
|
+
let b = jo(y), x = Mo(y), S = ia(l, b), C = Zi(aa(l, S)), w;
|
|
4602
4634
|
try {
|
|
4603
|
-
w =
|
|
4635
|
+
w = $i(b, C, u);
|
|
4604
4636
|
} catch (e) {
|
|
4605
4637
|
o.cancel($(e)), process.exit(1);
|
|
4606
4638
|
}
|
|
@@ -4608,36 +4640,36 @@ async function Eo(e = {}) {
|
|
|
4608
4640
|
o.note(`${w.alreadyInstalled.join(", ")} already installed.`, "Nothing to do"), o.outro(L.muted("Your selection is already part of the project."));
|
|
4609
4641
|
return;
|
|
4610
4642
|
}
|
|
4611
|
-
let T =
|
|
4643
|
+
let T = ea({
|
|
4612
4644
|
order: w.order,
|
|
4613
4645
|
graph: C,
|
|
4614
4646
|
isLocked: _,
|
|
4615
4647
|
installed: u
|
|
4616
4648
|
});
|
|
4617
4649
|
if (T.blocked.length > 0 && !m && !p) {
|
|
4618
|
-
let e = await
|
|
4619
|
-
e && (m = e, h = await
|
|
4650
|
+
let e = await tr();
|
|
4651
|
+
e && (m = e, h = await vo(l, d, {
|
|
4620
4652
|
token: m,
|
|
4621
4653
|
key: p
|
|
4622
|
-
}), T =
|
|
4654
|
+
}), T = ea({
|
|
4623
4655
|
order: w.order,
|
|
4624
4656
|
graph: C,
|
|
4625
4657
|
isLocked: _,
|
|
4626
4658
|
installed: u
|
|
4627
4659
|
}));
|
|
4628
4660
|
}
|
|
4629
|
-
if (T.blocked.length > 0 && await
|
|
4661
|
+
if (T.blocked.length > 0 && await bo(T.blocked, _, f), T.installable.length === 0) {
|
|
4630
4662
|
o.outro(L.muted("Nothing left to install once locked packs are removed."));
|
|
4631
4663
|
return;
|
|
4632
4664
|
}
|
|
4633
|
-
if (
|
|
4665
|
+
if (xo(T.installable, f), !e.yes) {
|
|
4634
4666
|
let e = await o.confirm({ message: `Install ${T.installable.length} pack${T.installable.length === 1 ? "" : "s"}?` });
|
|
4635
4667
|
(o.isCancel(e) || !e) && (o.cancel("Installation cancelled."), process.exit(0));
|
|
4636
4668
|
}
|
|
4637
4669
|
c.start("Downloading packs...");
|
|
4638
4670
|
let E;
|
|
4639
4671
|
try {
|
|
4640
|
-
E = await
|
|
4672
|
+
E = await So(T.installable, {
|
|
4641
4673
|
token: m,
|
|
4642
4674
|
key: p
|
|
4643
4675
|
});
|
|
@@ -4645,7 +4677,7 @@ async function Eo(e = {}) {
|
|
|
4645
4677
|
c.stop("Download failed"), o.cancel($(e)), process.exit(1);
|
|
4646
4678
|
}
|
|
4647
4679
|
c.stop(`Downloaded ${E.length} pack${E.length === 1 ? "" : "s"}`);
|
|
4648
|
-
let D = await
|
|
4680
|
+
let D = await Eo({
|
|
4649
4681
|
prepared: E,
|
|
4650
4682
|
config: a,
|
|
4651
4683
|
cwd: s,
|
|
@@ -4655,7 +4687,7 @@ async function Eo(e = {}) {
|
|
|
4655
4687
|
});
|
|
4656
4688
|
try {
|
|
4657
4689
|
c.start("Installing pack files...");
|
|
4658
|
-
let t = await
|
|
4690
|
+
let t = await Fi({
|
|
4659
4691
|
packs: E,
|
|
4660
4692
|
config: a,
|
|
4661
4693
|
projectRoot: s,
|
|
@@ -4668,18 +4700,18 @@ async function Eo(e = {}) {
|
|
|
4668
4700
|
for (let e of t.errors) o.log.error(e);
|
|
4669
4701
|
o.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4670
4702
|
}
|
|
4671
|
-
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));
|
|
4672
4704
|
for (let e of t.errors) o.log.error(e);
|
|
4673
|
-
await
|
|
4705
|
+
await Co({
|
|
4674
4706
|
prepared: E,
|
|
4675
4707
|
paths: a.paths,
|
|
4676
4708
|
cwd: s,
|
|
4677
4709
|
spinner: c
|
|
4678
|
-
}), i && await
|
|
4710
|
+
}), i && await Xi(s, e.yes ?? !1), await ur({
|
|
4679
4711
|
projectRoot: s,
|
|
4680
4712
|
paths: a.paths,
|
|
4681
4713
|
skipPrompts: e.yes ?? !1
|
|
4682
|
-
}),
|
|
4714
|
+
}), wo(E), o.outro(L.brand(`Installed ${t.appliedPacks.join(", ")}.`));
|
|
4683
4715
|
} finally {
|
|
4684
4716
|
await Promise.all(E.map((e) => v.rm(e.packDir, {
|
|
4685
4717
|
recursive: !0,
|
|
@@ -4687,10 +4719,10 @@ async function Eo(e = {}) {
|
|
|
4687
4719
|
})));
|
|
4688
4720
|
}
|
|
4689
4721
|
}
|
|
4690
|
-
async function
|
|
4722
|
+
async function Oo(e) {
|
|
4691
4723
|
let { packs: t, installedSet: n, stateOf: r, options: i, adminAvailable: a } = e;
|
|
4692
4724
|
if (i.packs && i.packs.length > 0) {
|
|
4693
|
-
let e = i.packs.map(
|
|
4725
|
+
let e = i.packs.map(Ao), n = e.filter((e) => !t.some((t) => t.name === e.name));
|
|
4694
4726
|
return n.length > 0 && (o.cancel(`Unknown pack${n.length === 1 ? "" : "s"}: ${n.map((e) => e.name).join(", ")}`), process.exit(1)), e;
|
|
4695
4727
|
}
|
|
4696
4728
|
let s = t.filter((e) => n.has(e.name));
|
|
@@ -4699,13 +4731,13 @@ async function Do(e) {
|
|
|
4699
4731
|
if (c.length === 0) return o.outro(L.muted("Every available pack is already installed.")), [];
|
|
4700
4732
|
let l = P();
|
|
4701
4733
|
o.note(c.map((e) => ` ${R.arrow} ${L.highlight(e.displayName)} ${_e(`${l}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
4702
|
-
let u =
|
|
4734
|
+
let u = Hi(c, { adminAvailable: a }), d = [];
|
|
4703
4735
|
for (let e of u) {
|
|
4704
4736
|
let t = e.packs.map((e) => {
|
|
4705
4737
|
let t = r(e.name);
|
|
4706
4738
|
return {
|
|
4707
4739
|
value: e.name,
|
|
4708
|
-
label: `${e.displayName} ${
|
|
4740
|
+
label: `${e.displayName} ${yo(t, e.price)}`,
|
|
4709
4741
|
hint: e.description
|
|
4710
4742
|
};
|
|
4711
4743
|
});
|
|
@@ -4722,7 +4754,7 @@ async function Do(e) {
|
|
|
4722
4754
|
});
|
|
4723
4755
|
continue;
|
|
4724
4756
|
}
|
|
4725
|
-
let n = await
|
|
4757
|
+
let n = await _a({
|
|
4726
4758
|
message: `Select ${e.label.toLowerCase()} to add (optional)`,
|
|
4727
4759
|
options: t,
|
|
4728
4760
|
required: !1
|
|
@@ -4732,20 +4764,20 @@ async function Do(e) {
|
|
|
4732
4764
|
}
|
|
4733
4765
|
return d;
|
|
4734
4766
|
}
|
|
4735
|
-
var
|
|
4736
|
-
function
|
|
4737
|
-
let t = e.match(
|
|
4767
|
+
var ko = /@(frontend|admin)$/;
|
|
4768
|
+
function Ao(e) {
|
|
4769
|
+
let t = e.match(ko);
|
|
4738
4770
|
return t ? {
|
|
4739
4771
|
name: e.slice(0, -t[0].length),
|
|
4740
4772
|
slot: t[1]
|
|
4741
4773
|
} : { name: e };
|
|
4742
4774
|
}
|
|
4743
|
-
function
|
|
4775
|
+
function jo(e) {
|
|
4744
4776
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
4745
4777
|
for (let r of e) t.has(r.name) || (t.add(r.name), n.push(r.name));
|
|
4746
4778
|
return n;
|
|
4747
4779
|
}
|
|
4748
|
-
function
|
|
4780
|
+
function Mo(e) {
|
|
4749
4781
|
let t = /* @__PURE__ */ new Map();
|
|
4750
4782
|
for (let n of e) {
|
|
4751
4783
|
if (!n.slot) continue;
|
|
@@ -4756,11 +4788,11 @@ function jo(e) {
|
|
|
4756
4788
|
}
|
|
4757
4789
|
//#endregion
|
|
4758
4790
|
//#region src/commands/login.ts
|
|
4759
|
-
async function
|
|
4760
|
-
|
|
4791
|
+
async function No() {
|
|
4792
|
+
ha(), o.intro(L.brandBold("Log in to Hype Stack")), o.log.step("Opening your browser to sign in...");
|
|
4761
4793
|
let e;
|
|
4762
4794
|
try {
|
|
4763
|
-
e = await
|
|
4795
|
+
e = await er({ onUrl: (e) => {
|
|
4764
4796
|
o.log.info(`If your browser didn't open, visit:\n ${L.path(e)}`);
|
|
4765
4797
|
} });
|
|
4766
4798
|
} catch (e) {
|
|
@@ -4770,28 +4802,28 @@ async function Mo() {
|
|
|
4770
4802
|
}
|
|
4771
4803
|
//#endregion
|
|
4772
4804
|
//#region src/commands/logout.ts
|
|
4773
|
-
async function
|
|
4774
|
-
|
|
4775
|
-
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);
|
|
4776
4808
|
if (!t) {
|
|
4777
4809
|
o.outro(L.muted("You're not logged in."));
|
|
4778
4810
|
return;
|
|
4779
4811
|
}
|
|
4780
|
-
await
|
|
4812
|
+
await Ln(t.token).catch(() => null), await qn(e), o.outro(L.brand("Logged out."));
|
|
4781
4813
|
}
|
|
4782
4814
|
//#endregion
|
|
4783
4815
|
//#region src/core/templates.ts
|
|
4784
|
-
var
|
|
4816
|
+
var Fo = K.createRequest()({
|
|
4785
4817
|
endpoint: "/templates/list",
|
|
4786
4818
|
method: "GET"
|
|
4787
4819
|
});
|
|
4788
|
-
async function
|
|
4789
|
-
let { data: e, error: t } = await
|
|
4820
|
+
async function Io() {
|
|
4821
|
+
let { data: e, error: t } = await Fo.send();
|
|
4790
4822
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
4791
4823
|
return e.templates;
|
|
4792
4824
|
}
|
|
4793
|
-
async function
|
|
4794
|
-
let { data: t, error: n, status: r } = await
|
|
4825
|
+
async function Lo(e) {
|
|
4826
|
+
let { data: t, error: n, status: r } = await K.createRequest()({
|
|
4795
4827
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
4796
4828
|
method: "GET"
|
|
4797
4829
|
}).send();
|
|
@@ -4799,13 +4831,13 @@ async function Io(e) {
|
|
|
4799
4831
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
4800
4832
|
return t;
|
|
4801
4833
|
}
|
|
4802
|
-
async function
|
|
4803
|
-
let n =
|
|
4834
|
+
async function Ro(e, t = {}) {
|
|
4835
|
+
let n = K.createRequest()({
|
|
4804
4836
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
4805
4837
|
method: "POST"
|
|
4806
4838
|
}), r = {
|
|
4807
|
-
"X-Device-Id":
|
|
4808
|
-
"X-Client-Info":
|
|
4839
|
+
"X-Device-Id": Yn(),
|
|
4840
|
+
"X-Client-Info": Xn()
|
|
4809
4841
|
};
|
|
4810
4842
|
t.token && (r.Authorization = `Bearer ${t.token}`);
|
|
4811
4843
|
let { data: i, error: a, success: o } = await n.setPayload({ key: t.licenseKey ?? void 0 }).setHeaders(r).send();
|
|
@@ -4827,10 +4859,10 @@ async function Lo(e, t = {}) {
|
|
|
4827
4859
|
}
|
|
4828
4860
|
//#endregion
|
|
4829
4861
|
//#region src/commands/template.ts
|
|
4830
|
-
async function
|
|
4862
|
+
async function zo(e = {}) {
|
|
4831
4863
|
let t = e.cwd ?? process.cwd();
|
|
4832
|
-
|
|
4833
|
-
let n = await
|
|
4864
|
+
ma();
|
|
4865
|
+
let n = await mo(t), a = n?.projectRoot ?? null, s = n?.scaffolded ?? !1, c;
|
|
4834
4866
|
try {
|
|
4835
4867
|
c = await fr(a ?? t);
|
|
4836
4868
|
} catch (e) {
|
|
@@ -4848,11 +4880,11 @@ async function Ro(e = {}) {
|
|
|
4848
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);
|
|
4849
4881
|
}
|
|
4850
4882
|
u.stop("Packs loaded");
|
|
4851
|
-
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;
|
|
4852
4884
|
u.start("Loading templates...");
|
|
4853
4885
|
let _;
|
|
4854
4886
|
try {
|
|
4855
|
-
_ = await
|
|
4887
|
+
_ = await Io();
|
|
4856
4888
|
} catch (e) {
|
|
4857
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);
|
|
4858
4890
|
}
|
|
@@ -4873,16 +4905,16 @@ async function Ro(e = {}) {
|
|
|
4873
4905
|
}
|
|
4874
4906
|
let b = _.find((e) => e.id === y);
|
|
4875
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}`);
|
|
4876
|
-
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({
|
|
4877
4909
|
packs: d,
|
|
4878
4910
|
templatePacks: C,
|
|
4879
4911
|
installedSet: p,
|
|
4880
4912
|
options: e
|
|
4881
4913
|
}), E = [...C, ...T.filter((e) => !C.includes(e))], D = E.filter((e) => !m.has(e));
|
|
4882
4914
|
D.length > 0 && (o.cancel(`Unknown pack${D.length === 1 ? "" : "s"}: ${D.join(", ")}`), process.exit(1));
|
|
4883
|
-
let O =
|
|
4915
|
+
let O = aa(d, S), ee = Zi(O), k;
|
|
4884
4916
|
try {
|
|
4885
|
-
k =
|
|
4917
|
+
k = $i(E, ee, f);
|
|
4886
4918
|
} catch (e) {
|
|
4887
4919
|
o.cancel($(e)), process.exit(1);
|
|
4888
4920
|
}
|
|
@@ -4890,42 +4922,42 @@ async function Ro(e = {}) {
|
|
|
4890
4922
|
o.outro(L.muted("Every pack in this template is already installed."));
|
|
4891
4923
|
return;
|
|
4892
4924
|
}
|
|
4893
|
-
let te = await
|
|
4925
|
+
let te = await vo(O, p, {
|
|
4894
4926
|
token: g,
|
|
4895
4927
|
key: h
|
|
4896
4928
|
}), ne = (e) => {
|
|
4897
4929
|
let t = m.get(e);
|
|
4898
4930
|
return !t || t.tier === "free" ? "free" : te[e]?.owned ? "owned" : "locked";
|
|
4899
|
-
}, re = (e) => !p.has(e) && ne(e) === "locked", A =
|
|
4931
|
+
}, re = (e) => !p.has(e) && ne(e) === "locked", A = ea({
|
|
4900
4932
|
order: k.order,
|
|
4901
4933
|
graph: ee,
|
|
4902
4934
|
isLocked: re,
|
|
4903
4935
|
installed: f
|
|
4904
4936
|
});
|
|
4905
4937
|
if (A.blocked.length > 0 && !g && !h) {
|
|
4906
|
-
let e = await
|
|
4907
|
-
e && (g = e, te = await
|
|
4938
|
+
let e = await tr();
|
|
4939
|
+
e && (g = e, te = await vo(O, p, {
|
|
4908
4940
|
token: g,
|
|
4909
4941
|
key: h
|
|
4910
|
-
}), A =
|
|
4942
|
+
}), A = ea({
|
|
4911
4943
|
order: k.order,
|
|
4912
4944
|
graph: ee,
|
|
4913
4945
|
isLocked: re,
|
|
4914
4946
|
installed: f
|
|
4915
4947
|
}));
|
|
4916
4948
|
}
|
|
4917
|
-
if (A.blocked.length > 0 && await
|
|
4949
|
+
if (A.blocked.length > 0 && await bo(A.blocked, re, m), A.installable.length === 0) {
|
|
4918
4950
|
o.outro(L.muted("Nothing left to install once locked packs are removed."));
|
|
4919
4951
|
return;
|
|
4920
4952
|
}
|
|
4921
|
-
if (
|
|
4953
|
+
if (xo(A.installable, m), !e.yes) {
|
|
4922
4954
|
let e = await o.confirm({ message: `Install template ${L.brandBold(b.name)} (${A.installable.length} pack${A.installable.length === 1 ? "" : "s"})?` });
|
|
4923
4955
|
(o.isCancel(e) || !e) && (o.cancel("Installation cancelled."), process.exit(0));
|
|
4924
4956
|
}
|
|
4925
4957
|
u.start("Downloading packs...");
|
|
4926
4958
|
let j;
|
|
4927
4959
|
try {
|
|
4928
|
-
j = await
|
|
4960
|
+
j = await So(A.installable, {
|
|
4929
4961
|
token: g,
|
|
4930
4962
|
key: h
|
|
4931
4963
|
});
|
|
@@ -4933,7 +4965,7 @@ async function Ro(e = {}) {
|
|
|
4933
4965
|
u.stop("Download failed"), o.cancel($(e)), process.exit(1);
|
|
4934
4966
|
}
|
|
4935
4967
|
u.stop(`Downloaded ${j.length} pack${j.length === 1 ? "" : "s"}`);
|
|
4936
|
-
let ie = await
|
|
4968
|
+
let ie = await Eo({
|
|
4937
4969
|
prepared: j,
|
|
4938
4970
|
config: c,
|
|
4939
4971
|
cwd: l,
|
|
@@ -4942,7 +4974,7 @@ async function Ro(e = {}) {
|
|
|
4942
4974
|
}), M = null;
|
|
4943
4975
|
try {
|
|
4944
4976
|
u.start("Installing pack files...");
|
|
4945
|
-
let t = await
|
|
4977
|
+
let t = await Fi({
|
|
4946
4978
|
packs: j,
|
|
4947
4979
|
config: c,
|
|
4948
4980
|
projectRoot: l,
|
|
@@ -4954,15 +4986,15 @@ async function Ro(e = {}) {
|
|
|
4954
4986
|
for (let e of t.errors) o.log.error(e);
|
|
4955
4987
|
o.cancel("No files were written. Fix the errors above (or pass --force for existing files) and try again."), process.exit(1);
|
|
4956
4988
|
}
|
|
4957
|
-
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));
|
|
4958
4990
|
for (let e of t.errors) o.log.error(e);
|
|
4959
4991
|
u.start("Applying template overrides...");
|
|
4960
|
-
let n = await
|
|
4992
|
+
let n = await Lo(b.id), a = await Ro(b.id, {
|
|
4961
4993
|
token: g,
|
|
4962
4994
|
licenseKey: h
|
|
4963
4995
|
});
|
|
4964
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;
|
|
4965
|
-
let d = await
|
|
4997
|
+
let d = await Li({
|
|
4966
4998
|
manifest: n,
|
|
4967
4999
|
config: c,
|
|
4968
5000
|
projectRoot: l,
|
|
@@ -4971,17 +5003,17 @@ async function Ro(e = {}) {
|
|
|
4971
5003
|
u.stop("Template overrides applied"), d.installed.length > 0 && o.log.success(`${d.installed.length} template file${d.installed.length === 1 ? "" : "s"} applied`);
|
|
4972
5004
|
for (let e of d.errors) o.log.error(e);
|
|
4973
5005
|
let f = n.theme ?? "zinc-mono";
|
|
4974
|
-
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({
|
|
4975
5007
|
prepared: j,
|
|
4976
5008
|
templateNpm: n.dependencies_npm,
|
|
4977
5009
|
paths: c.paths,
|
|
4978
5010
|
cwd: l,
|
|
4979
5011
|
spinner: u
|
|
4980
|
-
}), s && await
|
|
5012
|
+
}), s && await Xi(l, e.yes ?? !1), await ur({
|
|
4981
5013
|
projectRoot: l,
|
|
4982
5014
|
paths: c.paths,
|
|
4983
5015
|
skipPrompts: e.yes ?? !1
|
|
4984
|
-
}),
|
|
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}.`));
|
|
4985
5017
|
} finally {
|
|
4986
5018
|
await Promise.all(j.map((e) => v.rm(e.packDir, {
|
|
4987
5019
|
recursive: !0,
|
|
@@ -4992,7 +5024,7 @@ async function Ro(e = {}) {
|
|
|
4992
5024
|
});
|
|
4993
5025
|
}
|
|
4994
5026
|
}
|
|
4995
|
-
async function
|
|
5027
|
+
async function Bo(e, t, n) {
|
|
4996
5028
|
let r = {};
|
|
4997
5029
|
for (let i of e.slots) {
|
|
4998
5030
|
if (t?.[i.family]) {
|
|
@@ -5016,7 +5048,7 @@ async function zo(e, t, n) {
|
|
|
5016
5048
|
}
|
|
5017
5049
|
return r;
|
|
5018
5050
|
}
|
|
5019
|
-
async function
|
|
5051
|
+
async function Vo(e) {
|
|
5020
5052
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
5021
5053
|
if (i.packs && i.packs.length > 0) {
|
|
5022
5054
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -5027,7 +5059,7 @@ async function Bo(e) {
|
|
|
5027
5059
|
if (s.length === 0) return [];
|
|
5028
5060
|
let c = P();
|
|
5029
5061
|
o.note(s.map((e) => ` ${R.arrow} ${L.highlight(e.displayName)} ${_e(`${c}/packs/${e.name}`)}`).join("\n"), "Browse packs");
|
|
5030
|
-
let l = await
|
|
5062
|
+
let l = await _a({
|
|
5031
5063
|
message: "Add extra packs on top of the template (optional)",
|
|
5032
5064
|
options: s.map((e) => ({
|
|
5033
5065
|
value: e.name,
|
|
@@ -5038,25 +5070,25 @@ async function Bo(e) {
|
|
|
5038
5070
|
});
|
|
5039
5071
|
return p(l) && (o.cancel("Cancelled."), process.exit(0)), l;
|
|
5040
5072
|
}
|
|
5041
|
-
async function
|
|
5042
|
-
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);
|
|
5043
5075
|
if (c.errors.length > 0) {
|
|
5044
5076
|
for (let e of c.errors) o.log.error(e);
|
|
5045
5077
|
return;
|
|
5046
5078
|
}
|
|
5047
5079
|
if (c.operations.length === 0) return;
|
|
5048
5080
|
a.start("Installing npm dependencies...");
|
|
5049
|
-
let l = await
|
|
5081
|
+
let l = await _o(c.operations, i);
|
|
5050
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);
|
|
5051
5083
|
}
|
|
5052
5084
|
//#endregion
|
|
5053
5085
|
//#region src/cli.ts
|
|
5054
|
-
function
|
|
5086
|
+
function Uo(e) {
|
|
5055
5087
|
if (!e) return;
|
|
5056
5088
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
5057
5089
|
return t.length > 0 ? t : void 0;
|
|
5058
5090
|
}
|
|
5059
|
-
function
|
|
5091
|
+
function Wo(e) {
|
|
5060
5092
|
if (!e) return;
|
|
5061
5093
|
let t = {};
|
|
5062
5094
|
for (let n of e.split(",")) {
|
|
@@ -5065,10 +5097,10 @@ function Uo(e) {
|
|
|
5065
5097
|
}
|
|
5066
5098
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
5067
5099
|
}
|
|
5068
|
-
function
|
|
5100
|
+
function Go() {
|
|
5069
5101
|
let e = new a();
|
|
5070
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) => {
|
|
5071
|
-
await
|
|
5103
|
+
await fo({
|
|
5072
5104
|
name: e.name,
|
|
5073
5105
|
directory: e.directory,
|
|
5074
5106
|
install: e.install,
|
|
@@ -5078,32 +5110,32 @@ function Wo() {
|
|
|
5078
5110
|
setup: e.setup
|
|
5079
5111
|
});
|
|
5080
5112
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
5081
|
-
await
|
|
5113
|
+
await po({});
|
|
5082
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) => {
|
|
5083
|
-
await
|
|
5084
|
-
packs:
|
|
5115
|
+
await Do({
|
|
5116
|
+
packs: Uo(e.packs),
|
|
5085
5117
|
force: e.force,
|
|
5086
5118
|
yes: e.yes,
|
|
5087
5119
|
licenseKey: e.key ?? e.licenseKey,
|
|
5088
5120
|
cwd: e.cwd
|
|
5089
5121
|
});
|
|
5090
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) => {
|
|
5091
|
-
await
|
|
5123
|
+
await zo({
|
|
5092
5124
|
templateId: e,
|
|
5093
|
-
variants:
|
|
5094
|
-
packs:
|
|
5125
|
+
variants: Wo(t.variants),
|
|
5126
|
+
packs: Uo(t.packs),
|
|
5095
5127
|
force: t.force,
|
|
5096
5128
|
yes: t.yes,
|
|
5097
5129
|
licenseKey: t.key ?? t.licenseKey,
|
|
5098
5130
|
cwd: t.cwd
|
|
5099
5131
|
});
|
|
5100
5132
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
5101
|
-
await Mo();
|
|
5102
|
-
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5103
5133
|
await No();
|
|
5134
|
+
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
5135
|
+
await Po();
|
|
5104
5136
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
5105
|
-
await
|
|
5137
|
+
await No();
|
|
5106
5138
|
}), e;
|
|
5107
5139
|
}
|
|
5108
5140
|
//#endregion
|
|
5109
|
-
export {
|
|
5141
|
+
export { mo as a, Do as i, Po as n, po as o, No as r, fo as s, Go as t };
|