@hype-stack/cli 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-DaiPw0YU.js → cli-Bbv5yflm.js} +1081 -769
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/onboard.d.ts +9 -4
- package/dist/commands/onboard.d.ts.map +1 -1
- package/dist/config/bin.js +1 -1
- package/dist/deploy/assets.d.ts +22 -0
- package/dist/deploy/assets.d.ts.map +1 -1
- package/dist/deploy/catalog.d.ts +8 -4
- package/dist/deploy/catalog.d.ts.map +1 -1
- package/dist/deploy/env-plan.d.ts +4 -0
- package/dist/deploy/env-plan.d.ts.map +1 -1
- package/dist/deploy/orchestrate.d.ts.map +1 -1
- package/dist/deploy/providers/railway.d.ts +55 -1
- package/dist/deploy/providers/railway.d.ts.map +1 -1
- package/dist/deploy/providers/types.d.ts +14 -0
- package/dist/deploy/providers/types.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/ui/env-prompt.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ import { McpServer as ce } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
18
18
|
import { StdioServerTransport as le } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
19
19
|
import { Writable as ue } from "node:stream";
|
|
20
20
|
//#region src/constants/constants.ts
|
|
21
|
-
var de = "1.3.
|
|
21
|
+
var de = "1.3.3", fe = "gh:BetterTyped/hype-stack", pe = "stack.json", me = "/schema/stack.json", he = "https://api.hype-stack.dev", ge = "HYPE_STACK_API_URL", _e = "https://www.hype-stack.dev", ve = /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/, ye = [
|
|
22
22
|
{
|
|
23
23
|
value: "cursor",
|
|
24
24
|
label: "Cursor",
|
|
@@ -6675,14 +6675,30 @@ async function fd(e, t, n) {
|
|
|
6675
6675
|
port: $u
|
|
6676
6676
|
};
|
|
6677
6677
|
}
|
|
6678
|
-
async function pd(e
|
|
6678
|
+
async function pd(e) {
|
|
6679
|
+
let { projectRoot: t, target: n, contentDir: r, dryRun: i } = e, a = T.posix.join(Qu, `static-${n.target}`);
|
|
6680
|
+
if (i) return a;
|
|
6681
|
+
let o = T.join(t, Qu, `static-${n.target}`);
|
|
6682
|
+
return await C.rm(o, {
|
|
6683
|
+
recursive: !0,
|
|
6684
|
+
force: !0
|
|
6685
|
+
}), await C.mkdir(o, { recursive: !0 }), await C.writeFile(T.join(o, "nginx.conf"), ud($u), "utf-8"), await C.writeFile(T.join(o, "Dockerfile"), dd({
|
|
6686
|
+
contentDir: "dist",
|
|
6687
|
+
configPath: "nginx.conf",
|
|
6688
|
+
port: $u
|
|
6689
|
+
}), "utf-8"), await C.writeFile(T.join(o, nd), id({
|
|
6690
|
+
dockerfilePath: "Dockerfile",
|
|
6691
|
+
healthcheckPath: n.spec.healthcheckPath
|
|
6692
|
+
}), "utf-8"), await C.cp(T.join(t, r), T.join(o, "dist"), { recursive: !0 }), a;
|
|
6693
|
+
}
|
|
6694
|
+
async function md(e, t) {
|
|
6679
6695
|
let n = T.join(t.root, "Dockerfile");
|
|
6680
|
-
return await G(n) ?
|
|
6696
|
+
return await G(n) ? hd(e, n) : null;
|
|
6681
6697
|
}
|
|
6682
|
-
function
|
|
6698
|
+
function hd(e, t) {
|
|
6683
6699
|
return T.relative(e, t).split(T.sep).join("/");
|
|
6684
6700
|
}
|
|
6685
|
-
async function
|
|
6701
|
+
async function gd(e) {
|
|
6686
6702
|
let t = T.join(e, ".gitignore"), n = `${Qu}/`, r = await C.readFile(t, "utf-8").catch(() => null);
|
|
6687
6703
|
if (r === null) {
|
|
6688
6704
|
await C.writeFile(t, `${n}\n`, "utf-8");
|
|
@@ -6694,19 +6710,19 @@ async function hd(e) {
|
|
|
6694
6710
|
}
|
|
6695
6711
|
//#endregion
|
|
6696
6712
|
//#region src/deploy/catalog.ts
|
|
6697
|
-
var X = pe,
|
|
6698
|
-
function
|
|
6699
|
-
return [
|
|
6713
|
+
var X = pe, _d = "deploy";
|
|
6714
|
+
function vd(...e) {
|
|
6715
|
+
return [_d, ...e].join(".");
|
|
6700
6716
|
}
|
|
6701
|
-
var
|
|
6717
|
+
var yd = "production", bd = [
|
|
6702
6718
|
"backend",
|
|
6703
6719
|
"frontend",
|
|
6704
6720
|
"admin"
|
|
6705
|
-
],
|
|
6721
|
+
], xd = [
|
|
6706
6722
|
"postgres",
|
|
6707
6723
|
"valkey",
|
|
6708
6724
|
"bucket"
|
|
6709
|
-
],
|
|
6725
|
+
], Sd = ["railway", "fly"], Cd = {
|
|
6710
6726
|
backend: {
|
|
6711
6727
|
target: "backend",
|
|
6712
6728
|
label: "Backend API",
|
|
@@ -6739,7 +6755,7 @@ var vd = "production", yd = [
|
|
|
6739
6755
|
port: 3e3,
|
|
6740
6756
|
healthcheckPath: "/"
|
|
6741
6757
|
}
|
|
6742
|
-
},
|
|
6758
|
+
}, wd = {
|
|
6743
6759
|
postgres: {
|
|
6744
6760
|
service: "postgres",
|
|
6745
6761
|
label: "Postgres",
|
|
@@ -6760,7 +6776,7 @@ var vd = "production", yd = [
|
|
|
6760
6776
|
"BUCKET_NAME"
|
|
6761
6777
|
]
|
|
6762
6778
|
}
|
|
6763
|
-
},
|
|
6779
|
+
}, Td = {
|
|
6764
6780
|
railway: {
|
|
6765
6781
|
id: "railway",
|
|
6766
6782
|
label: "Railway",
|
|
@@ -6784,34 +6800,42 @@ var vd = "production", yd = [
|
|
|
6784
6800
|
tokenUrl: "https://fly.io/user/personal_access_tokens"
|
|
6785
6801
|
}
|
|
6786
6802
|
};
|
|
6787
|
-
function Td(e) {
|
|
6788
|
-
return yd.includes(e);
|
|
6789
|
-
}
|
|
6790
6803
|
function Ed(e) {
|
|
6791
|
-
return
|
|
6792
|
-
}
|
|
6793
|
-
function Z(e) {
|
|
6794
|
-
return Td(e) ? Sd[e].label : Cd[e].label;
|
|
6804
|
+
return bd.includes(e);
|
|
6795
6805
|
}
|
|
6796
6806
|
function Dd(e) {
|
|
6797
|
-
return
|
|
6807
|
+
return Sd.includes(e);
|
|
6798
6808
|
}
|
|
6799
|
-
function
|
|
6800
|
-
return
|
|
6809
|
+
function Z(e) {
|
|
6810
|
+
return Ed(e) ? Cd[e].label : wd[e].label;
|
|
6801
6811
|
}
|
|
6802
|
-
function
|
|
6803
|
-
return
|
|
6812
|
+
function Od(e) {
|
|
6813
|
+
return Td[e].label;
|
|
6814
|
+
}
|
|
6815
|
+
function kd(e) {
|
|
6816
|
+
return Sd;
|
|
6817
|
+
}
|
|
6818
|
+
var Ad = {
|
|
6819
|
+
frontend: "frontend",
|
|
6820
|
+
admin: "admin",
|
|
6821
|
+
backend: "backend",
|
|
6822
|
+
postgres: "Postgres",
|
|
6823
|
+
valkey: "Valkey",
|
|
6824
|
+
bucket: "Media Bucket"
|
|
6825
|
+
};
|
|
6826
|
+
function jd(e, t, n) {
|
|
6827
|
+
return n === "railway" ? Ad[t] : `${e}-${t}`;
|
|
6804
6828
|
}
|
|
6805
6829
|
//#endregion
|
|
6806
6830
|
//#region src/deploy/assign.ts
|
|
6807
|
-
function
|
|
6808
|
-
let { config: t, defaultProvider: n, overrides: r = {}, availableTargets: i } = e, a = n ?? t.defaultProvider, o =
|
|
6831
|
+
function Md(e) {
|
|
6832
|
+
let { config: t, defaultProvider: n, overrides: r = {}, availableTargets: i } = e, a = n ?? t.defaultProvider, o = Nd(i, e.only), s = {};
|
|
6809
6833
|
for (let e of o) {
|
|
6810
6834
|
let n = r[e] ?? t.targets[e]?.provider ?? a;
|
|
6811
6835
|
n && (s[e] = n);
|
|
6812
6836
|
}
|
|
6813
6837
|
let c = {};
|
|
6814
|
-
for (let e of
|
|
6838
|
+
for (let e of xd) {
|
|
6815
6839
|
let n = r[e] ?? t.services[e]?.provider ?? a;
|
|
6816
6840
|
n && (c[e] = n);
|
|
6817
6841
|
}
|
|
@@ -6820,11 +6844,11 @@ function Ad(e) {
|
|
|
6820
6844
|
services: c
|
|
6821
6845
|
};
|
|
6822
6846
|
}
|
|
6823
|
-
function
|
|
6824
|
-
let n =
|
|
6847
|
+
function Nd(e, t) {
|
|
6848
|
+
let n = bd.filter((t) => e.includes(t));
|
|
6825
6849
|
return !t || t.length === 0 ? n : n.filter((e) => t.includes(e));
|
|
6826
6850
|
}
|
|
6827
|
-
function
|
|
6851
|
+
function Pd(e) {
|
|
6828
6852
|
let { assignment: t, availableTargets: n, requestedTargets: r = [], serveModes: i = {} } = e, a = [];
|
|
6829
6853
|
for (let e of r) n.includes(e) || a.push({
|
|
6830
6854
|
resource: e,
|
|
@@ -6832,35 +6856,35 @@ function Md(e) {
|
|
|
6832
6856
|
message: `This project has no ${Z(e)} app, so it cannot be deployed.`,
|
|
6833
6857
|
fix: `Drop ${e} from --only, or check that apps/${e} exists and is listed in stack.json.`
|
|
6834
6858
|
});
|
|
6835
|
-
for (let e of
|
|
6859
|
+
for (let e of bd) {
|
|
6836
6860
|
let n = t.targets[e];
|
|
6837
6861
|
!n || i[e] !== null || a.push({
|
|
6838
6862
|
resource: e,
|
|
6839
6863
|
provider: n,
|
|
6840
6864
|
code: "unsupported-serve-mode",
|
|
6841
|
-
message:
|
|
6842
|
-
fix: `Add a Dockerfile at ${
|
|
6865
|
+
message: Fd(e),
|
|
6866
|
+
fix: `Add a Dockerfile at ${Cd[e].defaultRoot}/Dockerfile, which is what ${Od(n)} builds.`
|
|
6843
6867
|
});
|
|
6844
6868
|
}
|
|
6845
|
-
for (let e of
|
|
6869
|
+
for (let e of Nd(n, r.length > 0 ? r : void 0)) t.targets[e] || a.push({
|
|
6846
6870
|
resource: e,
|
|
6847
6871
|
code: "unassigned",
|
|
6848
6872
|
message: `No provider assigned for the ${Z(e)}.`,
|
|
6849
|
-
fix: `Pass --provider <${
|
|
6873
|
+
fix: `Pass --provider <${kd(e).join("|")}> or --${e} <provider>.`
|
|
6850
6874
|
});
|
|
6851
|
-
if (t.targets.backend) for (let e of
|
|
6875
|
+
if (t.targets.backend) for (let e of xd) t.services[e] || a.push({
|
|
6852
6876
|
resource: e,
|
|
6853
6877
|
code: "unassigned",
|
|
6854
6878
|
message: `No provider assigned for ${Z(e)}, which the backend needs.`,
|
|
6855
|
-
fix: `Pass --provider <${
|
|
6879
|
+
fix: `Pass --provider <${kd(e).join("|")}> or --${e} <provider>.`
|
|
6856
6880
|
});
|
|
6857
6881
|
return a;
|
|
6858
6882
|
}
|
|
6859
|
-
function
|
|
6883
|
+
function Fd(e) {
|
|
6860
6884
|
let t = Z(e);
|
|
6861
|
-
return
|
|
6885
|
+
return Cd[e].serveMode === "node" ? `The ${t} runs as a container and there is no Dockerfile at ${Cd[e].defaultRoot}/Dockerfile to build it from.` : `The ${t} has neither a Dockerfile to build as a container nor a build script that emits static files, so there is nothing to deploy.`;
|
|
6862
6886
|
}
|
|
6863
|
-
function
|
|
6887
|
+
function Id(e) {
|
|
6864
6888
|
return e.map((e) => {
|
|
6865
6889
|
let t = e.fix ? `\n ${e.fix}` : "";
|
|
6866
6890
|
return `${e.message}${t}`;
|
|
@@ -6877,14 +6901,14 @@ function Q(e) {
|
|
|
6877
6901
|
}
|
|
6878
6902
|
//#endregion
|
|
6879
6903
|
//#region src/deploy/build.ts
|
|
6880
|
-
var
|
|
6881
|
-
async function
|
|
6904
|
+
var Ld = ["build:web", "build"];
|
|
6905
|
+
async function Rd(e) {
|
|
6882
6906
|
let t = (await oi(T.join(e, "package.json")).catch(() => null))?.scripts ?? {};
|
|
6883
|
-
return
|
|
6907
|
+
return Ld.find((e) => typeof t[e] == "string") ?? null;
|
|
6884
6908
|
}
|
|
6885
|
-
async function
|
|
6886
|
-
let { target: n, env: r, secrets: i } = t, a = await
|
|
6887
|
-
if (!a) throw Error(`No build script found in ${
|
|
6909
|
+
async function zd(e, t) {
|
|
6910
|
+
let { target: n, env: r, secrets: i } = t, a = await Rd(n.root);
|
|
6911
|
+
if (!a) throw Error(`No build script found in ${hd(e.cwd, n.root)}/package.json. Add a "build" script that writes the bundle to ${n.spec.staticDir ?? "dist"}.`);
|
|
6888
6912
|
e.log?.(`Building ${n.spec.label} with the production env`), await e.runner.run({
|
|
6889
6913
|
command: "pnpm",
|
|
6890
6914
|
args: ["run", a],
|
|
@@ -6894,19 +6918,19 @@ async function Ld(e, t) {
|
|
|
6894
6918
|
label: `build ${n.target}`
|
|
6895
6919
|
});
|
|
6896
6920
|
let o = n.spec.staticDir ?? "dist", s = T.join(n.root, o);
|
|
6897
|
-
if (!e.runner.dryRun && !await ri(s)) throw Error(`"pnpm run ${a}" finished but ${
|
|
6921
|
+
if (!e.runner.dryRun && !await ri(s)) throw Error(`"pnpm run ${a}" finished but ${hd(e.cwd, s)} does not exist. Set the target's static directory in stack.json or fix the build output path.`);
|
|
6898
6922
|
return {
|
|
6899
6923
|
script: a,
|
|
6900
|
-
outputDir:
|
|
6924
|
+
outputDir: hd(e.cwd, s)
|
|
6901
6925
|
};
|
|
6902
6926
|
}
|
|
6903
6927
|
//#endregion
|
|
6904
6928
|
//#region src/deploy/providers/fly.ts
|
|
6905
|
-
var
|
|
6906
|
-
function
|
|
6929
|
+
var Bd = /already (?:exists|been taken)|name has already/i;
|
|
6930
|
+
function Vd(e) {
|
|
6907
6931
|
return `https://${e}.fly.dev`;
|
|
6908
6932
|
}
|
|
6909
|
-
function
|
|
6933
|
+
function Hd(e) {
|
|
6910
6934
|
let t = Q(e);
|
|
6911
6935
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
6912
6936
|
if (typeof e != "object" || !e) return [];
|
|
@@ -6914,7 +6938,7 @@ function Bd(e) {
|
|
|
6914
6938
|
return typeof n == "string" ? [n] : [];
|
|
6915
6939
|
}) : typeof t == "object" && t ? Object.values(t).filter((e) => typeof e == "string") : [];
|
|
6916
6940
|
}
|
|
6917
|
-
async function
|
|
6941
|
+
async function Ud(e) {
|
|
6918
6942
|
let t = await e.runner.run({
|
|
6919
6943
|
command: "fly",
|
|
6920
6944
|
args: [
|
|
@@ -6926,21 +6950,21 @@ async function Vd(e) {
|
|
|
6926
6950
|
allowFailure: !0,
|
|
6927
6951
|
label: "find your Fly organization"
|
|
6928
6952
|
});
|
|
6929
|
-
return t.exitCode === 0 ?
|
|
6953
|
+
return t.exitCode === 0 ? Hd(t.stdout) : [];
|
|
6930
6954
|
}
|
|
6931
|
-
async function
|
|
6955
|
+
async function Wd(e) {
|
|
6932
6956
|
if (e.plan.fly.org) return e.plan.fly.org;
|
|
6933
|
-
let t = await
|
|
6957
|
+
let t = await Ud(e);
|
|
6934
6958
|
if (t.length !== 0) {
|
|
6935
6959
|
if (t.length > 1) throw Error(`Your Fly account belongs to ${t.length} organizations (${t.join(", ")}). Pass --fly-org <slug> so the deploy creates everything in the right one.`);
|
|
6936
6960
|
return e.plan.fly.org = t[0], t[0];
|
|
6937
6961
|
}
|
|
6938
6962
|
}
|
|
6939
|
-
async function
|
|
6940
|
-
let t = await
|
|
6963
|
+
async function Gd(e) {
|
|
6964
|
+
let t = await Wd(e);
|
|
6941
6965
|
return t ? ["--org", t] : [];
|
|
6942
6966
|
}
|
|
6943
|
-
function
|
|
6967
|
+
function Kd(e) {
|
|
6944
6968
|
let t = {};
|
|
6945
6969
|
for (let n of e.split(/\r?\n/)) {
|
|
6946
6970
|
let e = n.match(/^\s*([A-Za-z][A-Za-z0-9_ ]*?)\s*[:=]\s*(\S.*?)\s*$/);
|
|
@@ -6950,19 +6974,19 @@ function Wd(e) {
|
|
|
6950
6974
|
}
|
|
6951
6975
|
return t;
|
|
6952
6976
|
}
|
|
6953
|
-
function
|
|
6977
|
+
function qd(e) {
|
|
6954
6978
|
let t = e.match(/\brediss?:\/\/\S+/);
|
|
6955
6979
|
return t ? t[0].replace(/[.,)]+$/, "") : null;
|
|
6956
6980
|
}
|
|
6957
|
-
function
|
|
6981
|
+
function Jd(e) {
|
|
6958
6982
|
let t = e.match(/^\w+:\/\/[^/@:]*:([^@]+)@/);
|
|
6959
6983
|
return t ? decodeURIComponent(t[1]) : null;
|
|
6960
6984
|
}
|
|
6961
|
-
function
|
|
6985
|
+
function Yd(e) {
|
|
6962
6986
|
let t = e.match(/\bpostgres(?:ql)?:\/\/\S+/);
|
|
6963
6987
|
return t ? t[0].replace(/[.,)]+$/, "") : null;
|
|
6964
6988
|
}
|
|
6965
|
-
function
|
|
6989
|
+
function Xd(e, t) {
|
|
6966
6990
|
let n = Q(e);
|
|
6967
6991
|
if (!Array.isArray(n)) return null;
|
|
6968
6992
|
for (let e of n) {
|
|
@@ -6975,7 +6999,7 @@ function Jd(e, t) {
|
|
|
6975
6999
|
}
|
|
6976
7000
|
return null;
|
|
6977
7001
|
}
|
|
6978
|
-
function
|
|
7002
|
+
function Zd(e) {
|
|
6979
7003
|
let t = Q(e);
|
|
6980
7004
|
if (typeof t != "object" || !t) return null;
|
|
6981
7005
|
let n = t.credentials;
|
|
@@ -6987,7 +7011,7 @@ function Yd(e) {
|
|
|
6987
7011
|
}
|
|
6988
7012
|
return null;
|
|
6989
7013
|
}
|
|
6990
|
-
var
|
|
7014
|
+
var Qd = {
|
|
6991
7015
|
id: "fly",
|
|
6992
7016
|
async checkAuth(e) {
|
|
6993
7017
|
let t = await e.runner.run({
|
|
@@ -7007,7 +7031,7 @@ var Xd = {
|
|
|
7007
7031
|
scope: {
|
|
7008
7032
|
label: "organization",
|
|
7009
7033
|
flag: "--fly-org",
|
|
7010
|
-
list:
|
|
7034
|
+
list: Ud,
|
|
7011
7035
|
current: (e) => e.fly.org,
|
|
7012
7036
|
pin: (e, t) => {
|
|
7013
7037
|
e.fly.org = t;
|
|
@@ -7021,21 +7045,21 @@ var Xd = {
|
|
|
7021
7045
|
"create",
|
|
7022
7046
|
t.app,
|
|
7023
7047
|
"--json",
|
|
7024
|
-
...await
|
|
7048
|
+
...await Gd(e)
|
|
7025
7049
|
],
|
|
7026
7050
|
cwd: e.cwd,
|
|
7027
7051
|
allowFailure: !0,
|
|
7028
7052
|
label: `create fly app ${t.app}`
|
|
7029
7053
|
});
|
|
7030
|
-
if (n.exitCode !== 0 && !
|
|
7031
|
-
return t.url ??
|
|
7054
|
+
if (n.exitCode !== 0 && !Bd.test(n.stderr + n.stdout)) throw Error(`Could not create the Fly app "${t.app}":\n${n.stderr.trim() || n.stdout.trim()}`);
|
|
7055
|
+
return t.url ?? Vd(t.app);
|
|
7032
7056
|
},
|
|
7033
7057
|
async provisionService(e, t) {
|
|
7034
7058
|
let { service: n } = t;
|
|
7035
7059
|
return n.external ? {
|
|
7036
7060
|
outputs: n.external,
|
|
7037
7061
|
note: "using the external values from stack.json"
|
|
7038
|
-
} : n.service === "postgres" ?
|
|
7062
|
+
} : n.service === "postgres" ? $d(e, t) : n.service === "valkey" ? rf(e, t) : of(e, t);
|
|
7039
7063
|
},
|
|
7040
7064
|
async setEnv(e, t) {
|
|
7041
7065
|
let n = Object.entries(t.env);
|
|
@@ -7057,10 +7081,10 @@ var Xd = {
|
|
|
7057
7081
|
async deployTarget(e, t) {
|
|
7058
7082
|
let { target: n } = t, r = n.spec.serveMode === "static", i, a;
|
|
7059
7083
|
if (r) {
|
|
7060
|
-
let r = await
|
|
7084
|
+
let r = await zd(e, t);
|
|
7061
7085
|
i = (await fd(e.cwd, n, r.outputDir ?? "dist")).dockerfile, a = $u;
|
|
7062
7086
|
} else {
|
|
7063
|
-
let t = await
|
|
7087
|
+
let t = await md(e.cwd, n);
|
|
7064
7088
|
if (!t) throw Error(`Fly builds the ${n.spec.label} from a Dockerfile, but there is none at ${n.spec.defaultRoot}/Dockerfile. Add one, or host this app on a provider that builds from source.`);
|
|
7065
7089
|
i = t, a = n.spec.port ?? 3e3;
|
|
7066
7090
|
}
|
|
@@ -7088,7 +7112,7 @@ var Xd = {
|
|
|
7088
7112
|
cwd: e.cwd,
|
|
7089
7113
|
secrets: t.secrets,
|
|
7090
7114
|
label: `deploy ${n.target} to fly`
|
|
7091
|
-
})).stdout.match(/https:\/\/[a-z0-9-]+\.fly\.dev/i)?.[0] ??
|
|
7115
|
+
})).stdout.match(/https:\/\/[a-z0-9-]+\.fly\.dev/i)?.[0] ?? Vd(n.app),
|
|
7092
7116
|
releaseRan: o !== void 0
|
|
7093
7117
|
};
|
|
7094
7118
|
},
|
|
@@ -7113,10 +7137,10 @@ var Xd = {
|
|
|
7113
7137
|
};
|
|
7114
7138
|
}
|
|
7115
7139
|
};
|
|
7116
|
-
async function
|
|
7117
|
-
let { service: n, backend: r, crossProvider: i } = t, a = await
|
|
7140
|
+
async function $d(e, t) {
|
|
7141
|
+
let { service: n, backend: r, crossProvider: i } = t, a = await ef(e, n.name), o = a ?? await tf(e, t);
|
|
7118
7142
|
if (i || !r) {
|
|
7119
|
-
let t = await
|
|
7143
|
+
let t = await nf(e, o);
|
|
7120
7144
|
if (!t) throw Error(`The Fly Postgres cluster "${n.name}" exists, but Fly did not return its connection string. Run \`fly mpg status ${o.id} --json\` and set deploy.services.postgres.external.DATABASE_URL in stack.json.`);
|
|
7121
7145
|
return {
|
|
7122
7146
|
outputs: { DATABASE_URL: t },
|
|
@@ -7141,34 +7165,34 @@ async function Zd(e, t) {
|
|
|
7141
7165
|
providedByProvider: ["DATABASE_URL"],
|
|
7142
7166
|
note: `attached to ${r.app}, which sets DATABASE_URL directly`
|
|
7143
7167
|
};
|
|
7144
|
-
if (
|
|
7168
|
+
if (Bd.test(s.stderr + s.stdout)) return {
|
|
7145
7169
|
outputs: {},
|
|
7146
7170
|
providedByProvider: ["DATABASE_URL"],
|
|
7147
7171
|
note: `already attached to ${r.app}`
|
|
7148
7172
|
};
|
|
7149
|
-
let c = await
|
|
7173
|
+
let c = await nf(e, o);
|
|
7150
7174
|
if (!c) throw Error(`Could not attach the Fly Postgres cluster "${n.name}" to ${r.app}, and could not read its connection string either:\n${s.stderr.trim() || s.stdout.trim()}`);
|
|
7151
7175
|
return {
|
|
7152
7176
|
outputs: { DATABASE_URL: c },
|
|
7153
7177
|
note: "attach failed, wired the connection string instead"
|
|
7154
7178
|
};
|
|
7155
7179
|
}
|
|
7156
|
-
async function
|
|
7180
|
+
async function ef(e, t) {
|
|
7157
7181
|
let n = await e.runner.run({
|
|
7158
7182
|
command: "fly",
|
|
7159
7183
|
args: [
|
|
7160
7184
|
"mpg",
|
|
7161
7185
|
"list",
|
|
7162
7186
|
"--json",
|
|
7163
|
-
...await
|
|
7187
|
+
...await Gd(e)
|
|
7164
7188
|
],
|
|
7165
7189
|
cwd: e.cwd,
|
|
7166
7190
|
allowFailure: !0,
|
|
7167
7191
|
label: "look for an existing postgres cluster"
|
|
7168
7192
|
});
|
|
7169
|
-
return n.exitCode === 0 ?
|
|
7193
|
+
return n.exitCode === 0 ? Xd(n.stdout, t) : null;
|
|
7170
7194
|
}
|
|
7171
|
-
async function
|
|
7195
|
+
async function tf(e, t) {
|
|
7172
7196
|
let { service: n } = t, r = await e.runner.run({
|
|
7173
7197
|
command: "fly",
|
|
7174
7198
|
args: [
|
|
@@ -7180,23 +7204,23 @@ async function $d(e, t) {
|
|
|
7180
7204
|
n.region ?? "iad",
|
|
7181
7205
|
"--plan",
|
|
7182
7206
|
e.plan.fly?.postgresPlan ?? "basic",
|
|
7183
|
-
...await
|
|
7207
|
+
...await Gd(e)
|
|
7184
7208
|
],
|
|
7185
7209
|
cwd: e.cwd,
|
|
7186
7210
|
allowFailure: !0,
|
|
7187
7211
|
label: `create managed postgres ${n.name}`
|
|
7188
7212
|
});
|
|
7189
|
-
if (r.exitCode !== 0 && !
|
|
7213
|
+
if (r.exitCode !== 0 && !Bd.test(r.stderr + r.stdout)) throw Error(`Could not create the Fly Postgres cluster "${n.name}":\n${r.stderr.trim() || r.stdout.trim()}`);
|
|
7190
7214
|
let i = r.stdout.match(/^\s*ID:\s*(\S+)\s*$/m)?.[1];
|
|
7191
7215
|
if (i) return {
|
|
7192
7216
|
id: i,
|
|
7193
7217
|
name: n.name
|
|
7194
7218
|
};
|
|
7195
|
-
let a = await
|
|
7219
|
+
let a = await ef(e, n.name);
|
|
7196
7220
|
if (a) return a;
|
|
7197
7221
|
throw Error(`Fly reported that the Postgres cluster "${n.name}" was created, but it is not in \`fly mpg list\`. Check https://fly.io/dashboard and run deploy again.`);
|
|
7198
7222
|
}
|
|
7199
|
-
async function
|
|
7223
|
+
async function nf(e, t) {
|
|
7200
7224
|
let n = await e.runner.run({
|
|
7201
7225
|
command: "fly",
|
|
7202
7226
|
args: [
|
|
@@ -7209,9 +7233,9 @@ async function ef(e, t) {
|
|
|
7209
7233
|
allowFailure: !0,
|
|
7210
7234
|
label: `read postgres status ${t.name}`
|
|
7211
7235
|
});
|
|
7212
|
-
return
|
|
7236
|
+
return Zd(n.stdout) ?? Yd(n.stdout);
|
|
7213
7237
|
}
|
|
7214
|
-
async function
|
|
7238
|
+
async function rf(e, t) {
|
|
7215
7239
|
let { service: n } = t, r = await e.runner.run({
|
|
7216
7240
|
command: "fly",
|
|
7217
7241
|
args: [
|
|
@@ -7222,9 +7246,9 @@ async function tf(e, t) {
|
|
|
7222
7246
|
cwd: e.cwd,
|
|
7223
7247
|
allowFailure: !0,
|
|
7224
7248
|
label: `look for an existing valkey ${n.name}`
|
|
7225
|
-
}), i = r.exitCode === 0 ?
|
|
7249
|
+
}), i = r.exitCode === 0 ? qd(r.stdout + r.stderr) : null;
|
|
7226
7250
|
if (i) return {
|
|
7227
|
-
outputs:
|
|
7251
|
+
outputs: af(i),
|
|
7228
7252
|
note: "reusing the existing database"
|
|
7229
7253
|
};
|
|
7230
7254
|
let a = await e.runner.run({
|
|
@@ -7239,23 +7263,23 @@ async function tf(e, t) {
|
|
|
7239
7263
|
"--no-replicas",
|
|
7240
7264
|
"--enable-eviction",
|
|
7241
7265
|
"--enable-prodpack=false",
|
|
7242
|
-
...await
|
|
7266
|
+
...await Gd(e)
|
|
7243
7267
|
],
|
|
7244
7268
|
cwd: e.cwd,
|
|
7245
7269
|
allowFailure: !0,
|
|
7246
7270
|
label: `create valkey ${n.name}`
|
|
7247
|
-
}), o =
|
|
7271
|
+
}), o = qd(a.stdout + a.stderr);
|
|
7248
7272
|
if (!o) throw Error(`Could not read the connection URL for the Fly Redis database "${n.name}":\n${a.stderr.trim() || a.stdout.trim()}\nRun \`fly redis status ${n.name}\` and set deploy.services.valkey.external.VALKEY_URL in stack.json.`);
|
|
7249
|
-
return { outputs:
|
|
7273
|
+
return { outputs: af(o) };
|
|
7250
7274
|
}
|
|
7251
|
-
function
|
|
7252
|
-
let t =
|
|
7275
|
+
function af(e) {
|
|
7276
|
+
let t = Jd(e);
|
|
7253
7277
|
return {
|
|
7254
7278
|
VALKEY_URL: e,
|
|
7255
7279
|
...t ? { VALKEY_PASSWORD: t } : {}
|
|
7256
7280
|
};
|
|
7257
7281
|
}
|
|
7258
|
-
async function
|
|
7282
|
+
async function of(e, t) {
|
|
7259
7283
|
let { service: n, backend: r, crossProvider: i } = t, a = n.name, o = await e.runner.run({
|
|
7260
7284
|
command: "fly",
|
|
7261
7285
|
args: [
|
|
@@ -7264,28 +7288,28 @@ async function rf(e, t) {
|
|
|
7264
7288
|
"--name",
|
|
7265
7289
|
a,
|
|
7266
7290
|
"--yes",
|
|
7267
|
-
...await
|
|
7291
|
+
...await Gd(e)
|
|
7268
7292
|
],
|
|
7269
7293
|
cwd: e.cwd,
|
|
7270
7294
|
allowFailure: !0,
|
|
7271
7295
|
label: `create tigris bucket ${a}`
|
|
7272
|
-
}), s =
|
|
7296
|
+
}), s = uf(Kd(o.stdout + o.stderr), a);
|
|
7273
7297
|
if (s) return { outputs: s };
|
|
7274
|
-
if (!
|
|
7275
|
-
if (!i && r && await
|
|
7298
|
+
if (!Bd.test(o.stderr + o.stdout)) throw Error(`Could not read the Tigris credentials for "${a}":\n${o.stderr.trim() || o.stdout.trim()}\nRun \`fly storage create --name ${a}\` yourself and copy the credentials into deploy.services.bucket.external in stack.json.`);
|
|
7299
|
+
if (!i && r && await lf(e, r.app)) return {
|
|
7276
7300
|
outputs: {},
|
|
7277
|
-
providedByProvider: [...
|
|
7301
|
+
providedByProvider: [...sf],
|
|
7278
7302
|
note: `already set on ${r.app} by an earlier deploy`
|
|
7279
7303
|
};
|
|
7280
7304
|
throw Error(`The Tigris bucket "${a}" already exists and Fly will not show its keys again, and ${r ? `${r.app} does not have them set` : "there is no Fly app here holding them"}. Copy them into deploy.services.bucket.external in stack.json, or pick a different name with deploy.services.bucket.name.`);
|
|
7281
7305
|
}
|
|
7282
|
-
var
|
|
7306
|
+
var sf = [
|
|
7283
7307
|
"RUSTFS_ENDPOINT",
|
|
7284
7308
|
"RUSTFS_ACCESS_KEY",
|
|
7285
7309
|
"RUSTFS_SECRET_KEY",
|
|
7286
7310
|
"BUCKET_NAME"
|
|
7287
7311
|
];
|
|
7288
|
-
function
|
|
7312
|
+
function cf(e) {
|
|
7289
7313
|
let t = Q(e);
|
|
7290
7314
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
7291
7315
|
if (typeof e != "object" || !e) return [];
|
|
@@ -7293,7 +7317,7 @@ function of(e) {
|
|
|
7293
7317
|
return typeof n == "string" ? [n] : [];
|
|
7294
7318
|
}) : [];
|
|
7295
7319
|
}
|
|
7296
|
-
async function
|
|
7320
|
+
async function lf(e, t) {
|
|
7297
7321
|
let n = await e.runner.run({
|
|
7298
7322
|
command: "fly",
|
|
7299
7323
|
args: [
|
|
@@ -7308,10 +7332,10 @@ async function sf(e, t) {
|
|
|
7308
7332
|
label: `check the storage keys already on ${t}`
|
|
7309
7333
|
});
|
|
7310
7334
|
if (n.exitCode !== 0) return !1;
|
|
7311
|
-
let r = new Set(
|
|
7312
|
-
return
|
|
7335
|
+
let r = new Set(cf(n.stdout));
|
|
7336
|
+
return sf.every((e) => r.has(e));
|
|
7313
7337
|
}
|
|
7314
|
-
function
|
|
7338
|
+
function uf(e, t) {
|
|
7315
7339
|
let n = e.AWS_ACCESS_KEY_ID, r = e.AWS_SECRET_ACCESS_KEY;
|
|
7316
7340
|
return !n || !r ? null : {
|
|
7317
7341
|
RUSTFS_ENDPOINT: e.AWS_ENDPOINT_URL_S3 ?? "https://t3.storage.dev",
|
|
@@ -7321,42 +7345,107 @@ function cf(e, t) {
|
|
|
7321
7345
|
};
|
|
7322
7346
|
}
|
|
7323
7347
|
//#endregion
|
|
7348
|
+
//#region src/deploy/runner.ts
|
|
7349
|
+
var df = class extends Error {
|
|
7350
|
+
spec;
|
|
7351
|
+
result;
|
|
7352
|
+
constructor(e, t) {
|
|
7353
|
+
let n = (t.stderr.trim() || t.stdout.trim()).split("\n").slice(-8).join("\n");
|
|
7354
|
+
super(`${ff(e)} exited with ${t.exitCode}${n ? `\n${n}` : ""}`), this.name = "CommandFailedError", this.spec = e, this.result = t;
|
|
7355
|
+
}
|
|
7356
|
+
};
|
|
7357
|
+
function ff(e) {
|
|
7358
|
+
let t = [e.command, ...e.args].map(mf).join(" ");
|
|
7359
|
+
return pf(e.stdin === void 0 ? t : `${t} < (stdin)`, e.secrets ?? []);
|
|
7360
|
+
}
|
|
7361
|
+
function pf(e, t) {
|
|
7362
|
+
let n = e;
|
|
7363
|
+
for (let e of t) !e || e.length < 4 || (n = n.split(e).join("***"));
|
|
7364
|
+
return n;
|
|
7365
|
+
}
|
|
7366
|
+
function mf(e) {
|
|
7367
|
+
return e === "" ? "\"\"" : /[\s"'$`\\]/.test(e) ? `"${e.replace(/(["\\$`])/g, "\\$1")}"` : e;
|
|
7368
|
+
}
|
|
7369
|
+
function hf(e = {}) {
|
|
7370
|
+
let t = [];
|
|
7371
|
+
return {
|
|
7372
|
+
transcript: t,
|
|
7373
|
+
async run(n) {
|
|
7374
|
+
let r = ff(n);
|
|
7375
|
+
t.push(r), e.onCommand?.(r);
|
|
7376
|
+
let i = e.env || n.env ? {
|
|
7377
|
+
...e.env,
|
|
7378
|
+
...n.env
|
|
7379
|
+
} : void 0, a = await W(n.command, n.args, {
|
|
7380
|
+
cwd: n.cwd,
|
|
7381
|
+
stdin: n.stdin,
|
|
7382
|
+
env: i,
|
|
7383
|
+
onData: e.onOutput ? (t) => e.onOutput?.(pf(t, n.secrets ?? [])) : void 0
|
|
7384
|
+
});
|
|
7385
|
+
if (a.exitCode !== 0 && !n.allowFailure) throw new df(n, a);
|
|
7386
|
+
return a;
|
|
7387
|
+
}
|
|
7388
|
+
};
|
|
7389
|
+
}
|
|
7390
|
+
function gf(e = {}) {
|
|
7391
|
+
let t = [];
|
|
7392
|
+
return {
|
|
7393
|
+
transcript: t,
|
|
7394
|
+
dryRun: !0,
|
|
7395
|
+
run(n) {
|
|
7396
|
+
let r = ff(n);
|
|
7397
|
+
t.push(r), e.onCommand?.(r);
|
|
7398
|
+
let i = e.responses?.find((e) => r.includes(e.match)), a = typeof i?.stdout == "function" ? i.stdout(n) : i?.stdout ?? "";
|
|
7399
|
+
return Promise.resolve({
|
|
7400
|
+
exitCode: i?.exitCode ?? 0,
|
|
7401
|
+
stdout: a,
|
|
7402
|
+
stderr: ""
|
|
7403
|
+
});
|
|
7404
|
+
}
|
|
7405
|
+
};
|
|
7406
|
+
}
|
|
7407
|
+
//#endregion
|
|
7324
7408
|
//#region src/deploy/providers/railway.ts
|
|
7325
|
-
var
|
|
7409
|
+
var _f = "Postgres", vf = "valkey/valkey:latest", yf = 6379, bf = "/data", xf = "/bin/sh -c \"exec docker-entrypoint.sh valkey-server --port ${VALKEY_PORT} --requirepass ${VALKEY_PASSWORD} --appendonly yes\"", Sf = 12e4, Cf = 3e3, wf = 20 * 6e4, Tf = 1e4, Ef = new Set(["SUCCESS", "SLEEPING"]), Df = new Set([
|
|
7410
|
+
"FAILED",
|
|
7411
|
+
"CRASHED",
|
|
7412
|
+
"REMOVED",
|
|
7413
|
+
"SKIPPED"
|
|
7414
|
+
]), Of = "query Deployments($input: DeploymentListInput!) { deployments(input: $input, first: 1) { edges { node { id status } } } }", kf = "query BuildLogs($deploymentId: String!, $limit: Int) { buildLogs(deploymentId: $deploymentId, limit: $limit) { message } }", Af = "query DeploymentLogs($deploymentId: String!, $limit: Int) { deploymentLogs(deploymentId: $deploymentId, limit: $limit) { message } }", jf = [
|
|
7326
7415
|
"sjc",
|
|
7327
7416
|
"iad",
|
|
7328
7417
|
"ams",
|
|
7329
7418
|
"sin"
|
|
7330
|
-
],
|
|
7331
|
-
function
|
|
7419
|
+
], Mf = "iad", Nf = "rustfs/rustfs:latest", Pf = 9e3, Ff = "/data", If = /already exists|duplicate|is already/i, Lf = /unrecognized subcommand|unknown subcommand|unexpected argument|not a valid subcommand/i;
|
|
7420
|
+
function Rf(e) {
|
|
7332
7421
|
let t = e.trim();
|
|
7333
7422
|
if (t.startsWith("{") || t.startsWith("[")) {
|
|
7334
|
-
let e = Q(t), n = e === null ? null :
|
|
7335
|
-
if (n) return
|
|
7423
|
+
let e = Q(t), n = e === null ? null : Bf(e);
|
|
7424
|
+
if (n) return zf(n);
|
|
7336
7425
|
}
|
|
7337
7426
|
let n = t.match(/[a-z0-9-]+(?:\.[a-z0-9-]+)*\.(?:up\.railway\.app|railway\.app)/i);
|
|
7338
|
-
return n ?
|
|
7427
|
+
return n ? zf(n[0]) : null;
|
|
7339
7428
|
}
|
|
7340
|
-
function
|
|
7429
|
+
function zf(e) {
|
|
7341
7430
|
return `https://${e.replace(/^https?:\/\//i, "").replace(/\/+$/, "")}`;
|
|
7342
7431
|
}
|
|
7343
|
-
function
|
|
7432
|
+
function Bf(e) {
|
|
7344
7433
|
if (typeof e == "string") return /\.railway\.app/i.test(e) ? e : null;
|
|
7345
7434
|
if (Array.isArray(e)) {
|
|
7346
7435
|
for (let t of e) {
|
|
7347
|
-
let e =
|
|
7436
|
+
let e = Bf(t);
|
|
7348
7437
|
if (e) return e;
|
|
7349
7438
|
}
|
|
7350
7439
|
return null;
|
|
7351
7440
|
}
|
|
7352
7441
|
if (typeof e == "object" && e) for (let [t, n] of Object.entries(e)) {
|
|
7353
7442
|
if ((t === "domain" || t === "url" || t === "host") && typeof n == "string" && n.length > 0) return n;
|
|
7354
|
-
let e =
|
|
7443
|
+
let e = Bf(n);
|
|
7355
7444
|
if (e) return e;
|
|
7356
7445
|
}
|
|
7357
7446
|
return null;
|
|
7358
7447
|
}
|
|
7359
|
-
function
|
|
7448
|
+
function Vf(e) {
|
|
7360
7449
|
let t = Q(e.trim());
|
|
7361
7450
|
if (!Array.isArray(t)) return [];
|
|
7362
7451
|
let n = [];
|
|
@@ -7370,7 +7459,7 @@ function wf(e) {
|
|
|
7370
7459
|
}
|
|
7371
7460
|
return n;
|
|
7372
7461
|
}
|
|
7373
|
-
function
|
|
7462
|
+
function Hf(e) {
|
|
7374
7463
|
let t = Q(e.trim());
|
|
7375
7464
|
if (typeof t != "object" || !t || Array.isArray(t)) return null;
|
|
7376
7465
|
let n = t, r = n.id;
|
|
@@ -7379,7 +7468,7 @@ function Tf(e) {
|
|
|
7379
7468
|
name: typeof n.name == "string" ? n.name : ""
|
|
7380
7469
|
};
|
|
7381
7470
|
}
|
|
7382
|
-
function
|
|
7471
|
+
function Uf(e) {
|
|
7383
7472
|
let t = e.trim();
|
|
7384
7473
|
if (t.startsWith("{")) {
|
|
7385
7474
|
let e = Q(t);
|
|
@@ -7396,7 +7485,7 @@ function Ef(e) {
|
|
|
7396
7485
|
}
|
|
7397
7486
|
return n;
|
|
7398
7487
|
}
|
|
7399
|
-
var
|
|
7488
|
+
var Wf = {
|
|
7400
7489
|
id: "railway",
|
|
7401
7490
|
async checkAuth(e) {
|
|
7402
7491
|
let t = await e.runner.run({
|
|
@@ -7416,16 +7505,16 @@ var Df = {
|
|
|
7416
7505
|
scope: {
|
|
7417
7506
|
label: "workspace",
|
|
7418
7507
|
flag: "--railway-workspace",
|
|
7419
|
-
list:
|
|
7508
|
+
list: ep,
|
|
7420
7509
|
current: (e) => e.railway.workspace,
|
|
7421
7510
|
pin: (e, t) => {
|
|
7422
7511
|
e.railway.workspace = t;
|
|
7423
7512
|
}
|
|
7424
7513
|
},
|
|
7425
7514
|
async reserveTarget(e, t) {
|
|
7426
|
-
await
|
|
7515
|
+
await Zf(e);
|
|
7427
7516
|
let n = t.spec.serveMode === "static" ? $u : t.spec.port ?? 3e3;
|
|
7428
|
-
if (!await
|
|
7517
|
+
if (!await rp(e, t.app)) {
|
|
7429
7518
|
let r = await e.runner.run({
|
|
7430
7519
|
command: "railway",
|
|
7431
7520
|
args: [
|
|
@@ -7440,7 +7529,7 @@ var Df = {
|
|
|
7440
7529
|
allowFailure: !0,
|
|
7441
7530
|
label: `create railway service ${t.app}`
|
|
7442
7531
|
});
|
|
7443
|
-
if (r.exitCode !== 0 && !
|
|
7532
|
+
if (r.exitCode !== 0 && !If.test(r.stderr + r.stdout)) throw Error(`Could not create the Railway service "${t.app}":\n${r.stderr.trim() || r.stdout.trim()}`);
|
|
7444
7533
|
}
|
|
7445
7534
|
if (t.url) return t.url;
|
|
7446
7535
|
let r = await e.runner.run({
|
|
@@ -7456,7 +7545,7 @@ var Df = {
|
|
|
7456
7545
|
cwd: e.cwd,
|
|
7457
7546
|
allowFailure: !0,
|
|
7458
7547
|
label: `generate domain for ${t.app}`
|
|
7459
|
-
}), i =
|
|
7548
|
+
}), i = Rf(r.stdout + r.stderr);
|
|
7460
7549
|
if (!i) throw Error(`Railway did not return a domain for "${t.app}". Run \`railway domain --service ${t.app}\` and set deploy.targets.${t.target}.url in stack.json.`);
|
|
7461
7550
|
return i;
|
|
7462
7551
|
},
|
|
@@ -7465,7 +7554,7 @@ var Df = {
|
|
|
7465
7554
|
return n.external ? {
|
|
7466
7555
|
outputs: n.external,
|
|
7467
7556
|
note: "using the external values from stack.json"
|
|
7468
|
-
} : (await
|
|
7557
|
+
} : (await Zf(e), n.service === "postgres" ? cp(e, t.crossProvider) : n.service === "valkey" ? fp(e, t) : Op(e, t));
|
|
7469
7558
|
},
|
|
7470
7559
|
async setEnv(e, t) {
|
|
7471
7560
|
for (let [n, r] of Object.entries(t.env)) await e.runner.run({
|
|
@@ -7486,52 +7575,40 @@ var Df = {
|
|
|
7486
7575
|
});
|
|
7487
7576
|
},
|
|
7488
7577
|
async deployTarget(e, t) {
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
"--skip-deploys"
|
|
7507
|
-
],
|
|
7508
|
-
cwd: e.cwd,
|
|
7509
|
-
label: `point ${n.app} at ${r}`
|
|
7510
|
-
});
|
|
7511
|
-
let i = await Of(e, {
|
|
7512
|
-
dockerfile: r,
|
|
7513
|
-
target: n,
|
|
7514
|
-
releaseCommand: t.releaseCommand
|
|
7578
|
+
return t.target.spec.serveMode === "static" ? Gf(e, t) : Kf(e, t);
|
|
7579
|
+
},
|
|
7580
|
+
async awaitTarget(e, t) {
|
|
7581
|
+
if (e.runner.dryRun) return {
|
|
7582
|
+
ok: !0,
|
|
7583
|
+
detail: "not checked on a dry run"
|
|
7584
|
+
};
|
|
7585
|
+
let n = await np(e, t.app);
|
|
7586
|
+
if (!n) return {
|
|
7587
|
+
ok: !0,
|
|
7588
|
+
detail: `could not find the service "${t.app}" to check on it, so look at the Railway dashboard`
|
|
7589
|
+
};
|
|
7590
|
+
let r = await yp(e, {
|
|
7591
|
+
name: t.app,
|
|
7592
|
+
serviceId: n.id,
|
|
7593
|
+
timeoutMs: wf,
|
|
7594
|
+
pollIntervalMs: Tf
|
|
7515
7595
|
});
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
} finally {
|
|
7533
|
-
i.written && await sd(e.cwd);
|
|
7534
|
-
}
|
|
7596
|
+
if (r.ok) return {
|
|
7597
|
+
ok: !0,
|
|
7598
|
+
detail: r.status === null ? r.note : "live"
|
|
7599
|
+
};
|
|
7600
|
+
let i = r.deploymentId && r.status ? await xp(e, {
|
|
7601
|
+
id: r.deploymentId,
|
|
7602
|
+
status: r.status
|
|
7603
|
+
}) : null, a = r.note ?? `the deployment ${r.status === "CRASHED" ? "crashed after starting" : "failed"}`;
|
|
7604
|
+
return {
|
|
7605
|
+
ok: !1,
|
|
7606
|
+
detail: [
|
|
7607
|
+
`${t.app} did not come up: ${a}.`,
|
|
7608
|
+
i,
|
|
7609
|
+
`Fix it and run deploy again. \`railway logs --service ${t.app}\` has the full log.`
|
|
7610
|
+
].filter(Boolean).join("\n")
|
|
7611
|
+
};
|
|
7535
7612
|
},
|
|
7536
7613
|
async runRemote(e, t, n) {
|
|
7537
7614
|
let r = await e.runner.run({
|
|
@@ -7553,7 +7630,111 @@ var Df = {
|
|
|
7553
7630
|
};
|
|
7554
7631
|
}
|
|
7555
7632
|
};
|
|
7556
|
-
async function
|
|
7633
|
+
async function Gf(e, t) {
|
|
7634
|
+
let { target: n } = t, r = await zd(e, t), i = await pd({
|
|
7635
|
+
projectRoot: e.cwd,
|
|
7636
|
+
target: n,
|
|
7637
|
+
contentDir: r.outputDir ?? "dist",
|
|
7638
|
+
dryRun: e.runner.dryRun
|
|
7639
|
+
});
|
|
7640
|
+
return await e.runner.run({
|
|
7641
|
+
command: "railway",
|
|
7642
|
+
args: [
|
|
7643
|
+
"variable",
|
|
7644
|
+
"set",
|
|
7645
|
+
"RAILWAY_DOCKERFILE_PATH=Dockerfile",
|
|
7646
|
+
"--service",
|
|
7647
|
+
n.app,
|
|
7648
|
+
"--skip-deploys"
|
|
7649
|
+
],
|
|
7650
|
+
cwd: e.cwd,
|
|
7651
|
+
label: `point ${n.app} at the bundled Dockerfile`
|
|
7652
|
+
}), {
|
|
7653
|
+
url: Rf((await qf(e, t, [
|
|
7654
|
+
i,
|
|
7655
|
+
"--path-as-root",
|
|
7656
|
+
"--no-gitignore"
|
|
7657
|
+
])).stdout) ?? n.url,
|
|
7658
|
+
releaseRan: !1
|
|
7659
|
+
};
|
|
7660
|
+
}
|
|
7661
|
+
async function Kf(e, t) {
|
|
7662
|
+
let { target: n } = t, r = await md(e.cwd, n);
|
|
7663
|
+
if (!r) throw Error(`Railway builds the ${n.spec.label} from a Dockerfile, but there is none at ${n.spec.defaultRoot}/Dockerfile. Add one and run deploy again.`);
|
|
7664
|
+
await e.runner.run({
|
|
7665
|
+
command: "railway",
|
|
7666
|
+
args: [
|
|
7667
|
+
"variable",
|
|
7668
|
+
"set",
|
|
7669
|
+
`RAILWAY_DOCKERFILE_PATH=${r}`,
|
|
7670
|
+
"--service",
|
|
7671
|
+
n.app,
|
|
7672
|
+
"--skip-deploys"
|
|
7673
|
+
],
|
|
7674
|
+
cwd: e.cwd,
|
|
7675
|
+
label: `point ${n.app} at ${r}`
|
|
7676
|
+
});
|
|
7677
|
+
let i = await Yf(e, {
|
|
7678
|
+
dockerfile: r,
|
|
7679
|
+
target: n,
|
|
7680
|
+
releaseCommand: t.releaseCommand
|
|
7681
|
+
});
|
|
7682
|
+
try {
|
|
7683
|
+
return {
|
|
7684
|
+
url: Rf((await qf(e, t, [])).stdout) ?? n.url,
|
|
7685
|
+
releaseRan: i.preDeployRan
|
|
7686
|
+
};
|
|
7687
|
+
} finally {
|
|
7688
|
+
i.written && await sd(e.cwd);
|
|
7689
|
+
}
|
|
7690
|
+
}
|
|
7691
|
+
async function qf(e, t, n) {
|
|
7692
|
+
let r = {
|
|
7693
|
+
command: "railway",
|
|
7694
|
+
args: [
|
|
7695
|
+
"up",
|
|
7696
|
+
...n,
|
|
7697
|
+
"--service",
|
|
7698
|
+
t.target.app,
|
|
7699
|
+
"--detach"
|
|
7700
|
+
],
|
|
7701
|
+
cwd: e.cwd,
|
|
7702
|
+
secrets: t.secrets,
|
|
7703
|
+
allowFailure: !0,
|
|
7704
|
+
label: `deploy ${t.target.target} to railway`
|
|
7705
|
+
}, i = await e.runner.run(r);
|
|
7706
|
+
if (i.exitCode === 0) return i;
|
|
7707
|
+
let a = new df(r, i), o = await Jf(e, t.target, i.stdout + i.stderr);
|
|
7708
|
+
throw o ? /* @__PURE__ */ Error(`${a.message}\n\n${o}`) : a;
|
|
7709
|
+
}
|
|
7710
|
+
async function Jf(e, t, n) {
|
|
7711
|
+
let r = n.match(/Could not load ([\w@./-]+)/)?.[1];
|
|
7712
|
+
if (!r) return null;
|
|
7713
|
+
let i = [
|
|
7714
|
+
"",
|
|
7715
|
+
".ts",
|
|
7716
|
+
".tsx",
|
|
7717
|
+
".js",
|
|
7718
|
+
".jsx",
|
|
7719
|
+
".mts",
|
|
7720
|
+
"/index.ts",
|
|
7721
|
+
"/index.tsx"
|
|
7722
|
+
].map((e) => `${r}${e}`), a = (await Promise.all(i.map(async (e) => await G(T.join(t.root, e)) ? e : null))).find((e) => e !== null);
|
|
7723
|
+
if (!a) return null;
|
|
7724
|
+
let o = hd(e.cwd, T.join(t.root, a));
|
|
7725
|
+
return (await e.runner.run({
|
|
7726
|
+
command: "git",
|
|
7727
|
+
args: [
|
|
7728
|
+
"check-ignore",
|
|
7729
|
+
"-q",
|
|
7730
|
+
o
|
|
7731
|
+
],
|
|
7732
|
+
cwd: e.cwd,
|
|
7733
|
+
allowFailure: !0,
|
|
7734
|
+
label: `check whether ${o} is gitignored`
|
|
7735
|
+
})).exitCode === 0 ? `${o} exists here but is in .gitignore, and \`railway up\` only uploads what git would track, so the build on Railway cannot see it. Take it out of .gitignore (moving any secrets in it into environment variables first) and deploy again.` : null;
|
|
7736
|
+
}
|
|
7737
|
+
async function Yf(e, t) {
|
|
7557
7738
|
let { dockerfile: n, target: r, releaseCommand: i } = t;
|
|
7558
7739
|
if (await ad(e.cwd)) return e.log?.(`Keeping your ${nd}, so ${r.app} uses the settings in it`), {
|
|
7559
7740
|
written: !1,
|
|
@@ -7572,11 +7753,11 @@ async function Of(e, t) {
|
|
|
7572
7753
|
preDeployRan: o
|
|
7573
7754
|
});
|
|
7574
7755
|
}
|
|
7575
|
-
var
|
|
7576
|
-
async function
|
|
7577
|
-
|
|
7756
|
+
var Xf = /* @__PURE__ */ new WeakSet();
|
|
7757
|
+
async function Zf(e) {
|
|
7758
|
+
Xf.has(e) || (await Qf(e), Xf.add(e));
|
|
7578
7759
|
}
|
|
7579
|
-
async function
|
|
7760
|
+
async function Qf(e) {
|
|
7580
7761
|
if ((await e.runner.run({
|
|
7581
7762
|
command: "railway",
|
|
7582
7763
|
args: ["status", "--json"],
|
|
@@ -7584,7 +7765,7 @@ async function jf(e) {
|
|
|
7584
7765
|
allowFailure: !0,
|
|
7585
7766
|
label: "check railway project link"
|
|
7586
7767
|
})).exitCode === 0) return;
|
|
7587
|
-
let t = await
|
|
7768
|
+
let t = await tp(e);
|
|
7588
7769
|
await e.runner.run({
|
|
7589
7770
|
command: "railway",
|
|
7590
7771
|
args: [
|
|
@@ -7597,7 +7778,7 @@ async function jf(e) {
|
|
|
7597
7778
|
label: `create railway project ${e.plan.projectName}`
|
|
7598
7779
|
});
|
|
7599
7780
|
}
|
|
7600
|
-
function
|
|
7781
|
+
function $f(e) {
|
|
7601
7782
|
let t = Q(e);
|
|
7602
7783
|
if (typeof t != "object" || !t) return [];
|
|
7603
7784
|
let n = t.workspaces;
|
|
@@ -7607,7 +7788,7 @@ function Mf(e) {
|
|
|
7607
7788
|
return typeof n == "string" ? [n] : [];
|
|
7608
7789
|
}) : [];
|
|
7609
7790
|
}
|
|
7610
|
-
async function
|
|
7791
|
+
async function ep(e) {
|
|
7611
7792
|
let t = await e.runner.run({
|
|
7612
7793
|
command: "railway",
|
|
7613
7794
|
args: ["whoami", "--json"],
|
|
@@ -7615,17 +7796,17 @@ async function Nf(e) {
|
|
|
7615
7796
|
allowFailure: !0,
|
|
7616
7797
|
label: "find your Railway workspace"
|
|
7617
7798
|
});
|
|
7618
|
-
return t.exitCode === 0 ?
|
|
7799
|
+
return t.exitCode === 0 ? $f(t.stdout) : [];
|
|
7619
7800
|
}
|
|
7620
|
-
async function
|
|
7801
|
+
async function tp(e) {
|
|
7621
7802
|
if (e.plan.railway.workspace) return e.plan.railway.workspace;
|
|
7622
|
-
let t = await
|
|
7803
|
+
let t = await ep(e);
|
|
7623
7804
|
if (t.length !== 0) {
|
|
7624
7805
|
if (t.length > 1) throw Error(`Your Railway account belongs to ${t.length} workspaces (${t.join(", ")}). Pass --railway-workspace <name> so the project is created in the right one.`);
|
|
7625
7806
|
return e.plan.railway.workspace = t[0], t[0];
|
|
7626
7807
|
}
|
|
7627
7808
|
}
|
|
7628
|
-
async function
|
|
7809
|
+
async function np(e, t) {
|
|
7629
7810
|
let n = await e.runner.run({
|
|
7630
7811
|
command: "railway",
|
|
7631
7812
|
args: [
|
|
@@ -7637,15 +7818,18 @@ async function Ff(e, t) {
|
|
|
7637
7818
|
allowFailure: !0,
|
|
7638
7819
|
label: "list railway services"
|
|
7639
7820
|
});
|
|
7640
|
-
return n.exitCode === 0 ?
|
|
7821
|
+
return n.exitCode === 0 ? Vf(n.stdout).find((e) => e.name === t) ?? null : null;
|
|
7641
7822
|
}
|
|
7642
|
-
async function
|
|
7643
|
-
return await
|
|
7823
|
+
async function rp(e, t) {
|
|
7824
|
+
return await np(e, t) !== null;
|
|
7644
7825
|
}
|
|
7645
|
-
function
|
|
7646
|
-
return `\${{${e}.${t}}}`;
|
|
7826
|
+
function ip(e, t) {
|
|
7827
|
+
return `\${{${/^[\w-]+$/.test(e) ? e : `"${e}"`}.${t}}}`;
|
|
7647
7828
|
}
|
|
7648
|
-
|
|
7829
|
+
function ap(e) {
|
|
7830
|
+
return `https://${ip(e, "RAILWAY_PUBLIC_DOMAIN")}`;
|
|
7831
|
+
}
|
|
7832
|
+
async function op(e, t) {
|
|
7649
7833
|
let n = await e.runner.run({
|
|
7650
7834
|
command: "railway",
|
|
7651
7835
|
args: [
|
|
@@ -7659,9 +7843,9 @@ async function Rf(e, t) {
|
|
|
7659
7843
|
allowFailure: !0,
|
|
7660
7844
|
label: `read ${t} connection details`
|
|
7661
7845
|
});
|
|
7662
|
-
return n.exitCode === 0 ?
|
|
7846
|
+
return n.exitCode === 0 ? Uf(n.stdout) : {};
|
|
7663
7847
|
}
|
|
7664
|
-
var
|
|
7848
|
+
var sp = {
|
|
7665
7849
|
DATABASE_URL: "DATABASE_URL",
|
|
7666
7850
|
POSTGRES_DB: "PGDATABASE",
|
|
7667
7851
|
POSTGRES_HOST: "PGHOST",
|
|
@@ -7669,8 +7853,8 @@ var zf = {
|
|
|
7669
7853
|
POSTGRES_USER: "PGUSER",
|
|
7670
7854
|
POSTGRES_PASSWORD: "PGPASSWORD"
|
|
7671
7855
|
};
|
|
7672
|
-
async function
|
|
7673
|
-
if (!await
|
|
7856
|
+
async function cp(e, t) {
|
|
7857
|
+
if (!await rp(e, "Postgres")) {
|
|
7674
7858
|
let t = await e.runner.run({
|
|
7675
7859
|
command: "railway",
|
|
7676
7860
|
args: [
|
|
@@ -7683,28 +7867,28 @@ async function Bf(e, t) {
|
|
|
7683
7867
|
allowFailure: !0,
|
|
7684
7868
|
label: "add railway postgres"
|
|
7685
7869
|
});
|
|
7686
|
-
if (t.exitCode !== 0 && !
|
|
7870
|
+
if (t.exitCode !== 0 && !If.test(t.stderr + t.stdout)) throw Error(`Could not add a Railway postgres database:\n${t.stderr.trim()}`);
|
|
7687
7871
|
}
|
|
7688
7872
|
if (!t) {
|
|
7689
7873
|
let e = {};
|
|
7690
|
-
for (let [t, n] of Object.entries(
|
|
7874
|
+
for (let [t, n] of Object.entries(sp)) e[t] = ip(_f, n);
|
|
7691
7875
|
return {
|
|
7692
7876
|
outputs: e,
|
|
7693
|
-
note: `wired as Railway references to ${
|
|
7877
|
+
note: `wired as Railway references to ${_f}`
|
|
7694
7878
|
};
|
|
7695
7879
|
}
|
|
7696
|
-
let n = await
|
|
7697
|
-
if (!r) throw Error(`Could not read DATABASE_PUBLIC_URL from the Railway ${
|
|
7880
|
+
let n = await op(e, _f), r = n.DATABASE_PUBLIC_URL ?? n.DATABASE_URL;
|
|
7881
|
+
if (!r) throw Error(`Could not read DATABASE_PUBLIC_URL from the Railway ${_f} service. Enable a public proxy on it, or set ${vd("services", "postgres", "external")} in ${X}.`);
|
|
7698
7882
|
return { outputs: {
|
|
7699
7883
|
DATABASE_URL: r,
|
|
7700
|
-
...
|
|
7884
|
+
...lp(r)
|
|
7701
7885
|
} };
|
|
7702
7886
|
}
|
|
7703
|
-
function
|
|
7704
|
-
let t =
|
|
7887
|
+
function lp(e) {
|
|
7888
|
+
let t = up(e);
|
|
7705
7889
|
if (!t) return {};
|
|
7706
7890
|
let n = decodeURIComponent(t.pathname.replace(/^\//, ""));
|
|
7707
|
-
return
|
|
7891
|
+
return dp({
|
|
7708
7892
|
POSTGRES_HOST: t.hostname,
|
|
7709
7893
|
POSTGRES_PORT: t.port,
|
|
7710
7894
|
POSTGRES_USER: decodeURIComponent(t.username),
|
|
@@ -7712,43 +7896,43 @@ function Vf(e) {
|
|
|
7712
7896
|
POSTGRES_DB: n
|
|
7713
7897
|
});
|
|
7714
7898
|
}
|
|
7715
|
-
function
|
|
7899
|
+
function up(e) {
|
|
7716
7900
|
try {
|
|
7717
7901
|
return new URL(e);
|
|
7718
7902
|
} catch {
|
|
7719
7903
|
return null;
|
|
7720
7904
|
}
|
|
7721
7905
|
}
|
|
7722
|
-
function
|
|
7906
|
+
function dp(e) {
|
|
7723
7907
|
return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== ""));
|
|
7724
7908
|
}
|
|
7725
|
-
async function
|
|
7726
|
-
let n = t.service.name, r = await
|
|
7727
|
-
if (r || await
|
|
7909
|
+
async function fp(e, t) {
|
|
7910
|
+
let n = t.service.name, r = await np(e, n);
|
|
7911
|
+
if (r || await pp(e, n), !t.crossProvider) return {
|
|
7728
7912
|
outputs: {
|
|
7729
|
-
VALKEY_URL:
|
|
7730
|
-
VALKEY_PASSWORD:
|
|
7913
|
+
VALKEY_URL: ip(n, "VALKEY_URL"),
|
|
7914
|
+
VALKEY_PASSWORD: ip(n, "VALKEY_PASSWORD")
|
|
7731
7915
|
},
|
|
7732
|
-
note: r ? "reusing the Valkey service already in the project" : `${
|
|
7916
|
+
note: r ? "reusing the Valkey service already in the project" : `${vf} with a volume and a password`
|
|
7733
7917
|
};
|
|
7734
|
-
let i = await
|
|
7735
|
-
if (!a) throw Error(`Could not read VALKEY_PUBLIC_URL from the Railway Valkey service "${n}". Run \`railway tcp-proxy create --port ${
|
|
7736
|
-
return { outputs:
|
|
7918
|
+
let i = await op(e, n), a = i.VALKEY_PUBLIC_URL ?? i.VALKEY_URL;
|
|
7919
|
+
if (!a) throw Error(`Could not read VALKEY_PUBLIC_URL from the Railway Valkey service "${n}". Run \`railway tcp-proxy create --port ${yf} --service ${n}\`, or set ${vd("services", "valkey", "external")} in ${X}.`);
|
|
7920
|
+
return { outputs: dp({
|
|
7737
7921
|
VALKEY_URL: a,
|
|
7738
7922
|
VALKEY_PASSWORD: i.VALKEY_PASSWORD ?? ""
|
|
7739
7923
|
}) };
|
|
7740
7924
|
}
|
|
7741
|
-
async function
|
|
7925
|
+
async function pp(e, t) {
|
|
7742
7926
|
let n = O(24).toString("base64url"), r = await e.runner.run({
|
|
7743
7927
|
command: "railway",
|
|
7744
7928
|
args: [
|
|
7745
7929
|
"add",
|
|
7746
7930
|
"--image",
|
|
7747
|
-
|
|
7931
|
+
vf,
|
|
7748
7932
|
"--service",
|
|
7749
7933
|
t,
|
|
7750
7934
|
"--variables",
|
|
7751
|
-
`VALKEY_PORT=${
|
|
7935
|
+
`VALKEY_PORT=${yf}`,
|
|
7752
7936
|
"--variables",
|
|
7753
7937
|
`VALKEY_PASSWORD=${n}`,
|
|
7754
7938
|
"--variables",
|
|
@@ -7763,38 +7947,175 @@ async function Gf(e, t) {
|
|
|
7763
7947
|
label: `create valkey service ${t}`
|
|
7764
7948
|
});
|
|
7765
7949
|
if (r.exitCode !== 0) throw Error(`Could not create the Railway Valkey service "${t}":\n${r.stderr.trim()}`);
|
|
7766
|
-
let i =
|
|
7767
|
-
if (!i) throw Error(`Railway created the Valkey service "${t}" but did not report its id, which is needed to mount its volume and set its start command. Run \`railway service list --json\`, finish it from the dashboard, or set ${
|
|
7768
|
-
await
|
|
7950
|
+
let i = Hf(r.stdout)?.id;
|
|
7951
|
+
if (!i) throw Error(`Railway created the Valkey service "${t}" but did not report its id, which is needed to mount its volume and set its start command. Run \`railway service list --json\`, finish it from the dashboard, or set ${vd("services", "valkey", "external")} in ${X}.`);
|
|
7952
|
+
await Sp(e, {
|
|
7769
7953
|
name: t,
|
|
7770
7954
|
serviceId: i,
|
|
7771
|
-
command:
|
|
7772
|
-
}), await
|
|
7955
|
+
command: xf
|
|
7956
|
+
}), await Fp(e, {
|
|
7773
7957
|
name: t,
|
|
7774
7958
|
serviceId: i,
|
|
7775
|
-
mountPath:
|
|
7959
|
+
mountPath: bf,
|
|
7776
7960
|
consequence: "everything cached in it would be lost on the next restart"
|
|
7777
|
-
}), await
|
|
7961
|
+
}), await Ep(e, {
|
|
7962
|
+
name: t,
|
|
7963
|
+
port: yf
|
|
7964
|
+
}), await mp(e, {
|
|
7778
7965
|
name: t,
|
|
7779
|
-
|
|
7966
|
+
serviceId: i
|
|
7967
|
+
}), e.log?.(`Waiting for ${t} to come up`);
|
|
7968
|
+
let a = await yp(e, {
|
|
7969
|
+
name: t,
|
|
7970
|
+
serviceId: i,
|
|
7971
|
+
timeoutMs: Sf,
|
|
7972
|
+
pollIntervalMs: Cf
|
|
7780
7973
|
});
|
|
7781
|
-
|
|
7974
|
+
if (!a.ok) {
|
|
7975
|
+
let n = a.deploymentId && a.status ? await xp(e, {
|
|
7976
|
+
id: a.deploymentId,
|
|
7977
|
+
status: a.status
|
|
7978
|
+
}) : null;
|
|
7979
|
+
throw Error([
|
|
7980
|
+
`The Railway Valkey service "${t}" was deployed but has not come up (${a.note ?? a.status?.toLowerCase() ?? "unknown status"}), and the backend cannot reach its cache until it does.`,
|
|
7981
|
+
n,
|
|
7982
|
+
"Check it in the Railway dashboard and run deploy again."
|
|
7983
|
+
].filter(Boolean).join("\n"));
|
|
7984
|
+
}
|
|
7985
|
+
}
|
|
7986
|
+
async function mp(e, t) {
|
|
7987
|
+
let n = await wp(e), r = await e.runner.run({
|
|
7782
7988
|
command: "railway",
|
|
7783
7989
|
args: [
|
|
7784
|
-
"
|
|
7785
|
-
"
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7990
|
+
"api",
|
|
7991
|
+
"mutation DeployServiceInstance($serviceId: String!, $environmentId: String!) { serviceInstanceDeployV2(serviceId: $serviceId, environmentId: $environmentId) }",
|
|
7992
|
+
"--variables",
|
|
7993
|
+
JSON.stringify({
|
|
7994
|
+
serviceId: t.serviceId,
|
|
7995
|
+
environmentId: n
|
|
7996
|
+
}),
|
|
7997
|
+
"--compact"
|
|
7789
7998
|
],
|
|
7790
7999
|
cwd: e.cwd,
|
|
7791
8000
|
allowFailure: !0,
|
|
7792
|
-
label: `
|
|
8001
|
+
label: `deploy ${t.name}`
|
|
7793
8002
|
});
|
|
7794
|
-
if (
|
|
8003
|
+
if (r.exitCode !== 0) throw Error(`The Railway service "${t.name}" is configured but its first deployment could not be started, so nothing is running yet:\n${r.stderr.trim() || r.stdout.trim()}\nDeploy it from the Railway dashboard and run deploy again.`);
|
|
7795
8004
|
}
|
|
7796
|
-
|
|
7797
|
-
let
|
|
8005
|
+
function hp(e) {
|
|
8006
|
+
let t = Q(e.trim());
|
|
8007
|
+
return t === null ? null : gp(t);
|
|
8008
|
+
}
|
|
8009
|
+
function gp(e) {
|
|
8010
|
+
if (Array.isArray(e)) {
|
|
8011
|
+
for (let t of e) {
|
|
8012
|
+
let e = gp(t);
|
|
8013
|
+
if (e) return e;
|
|
8014
|
+
}
|
|
8015
|
+
return null;
|
|
8016
|
+
}
|
|
8017
|
+
if (typeof e == "object" && e) {
|
|
8018
|
+
let t = e, { id: n, status: r } = t;
|
|
8019
|
+
if (typeof n == "string" && typeof r == "string" && /^[A-Z_]+$/.test(r)) return {
|
|
8020
|
+
id: n,
|
|
8021
|
+
status: r
|
|
8022
|
+
};
|
|
8023
|
+
for (let e of Object.values(t)) {
|
|
8024
|
+
let t = gp(e);
|
|
8025
|
+
if (t) return t;
|
|
8026
|
+
}
|
|
8027
|
+
}
|
|
8028
|
+
return null;
|
|
8029
|
+
}
|
|
8030
|
+
function _p(e) {
|
|
8031
|
+
let t = [];
|
|
8032
|
+
return vp(Q(e.trim()), t), t;
|
|
8033
|
+
}
|
|
8034
|
+
function vp(e, t) {
|
|
8035
|
+
if (Array.isArray(e)) {
|
|
8036
|
+
for (let n of e) vp(n, t);
|
|
8037
|
+
return;
|
|
8038
|
+
}
|
|
8039
|
+
if (typeof e == "object" && e) {
|
|
8040
|
+
let n = e;
|
|
8041
|
+
typeof n.message == "string" && n.message.length > 0 && t.push(n.message);
|
|
8042
|
+
for (let [e, r] of Object.entries(n)) e !== "message" && vp(r, t);
|
|
8043
|
+
}
|
|
8044
|
+
}
|
|
8045
|
+
async function yp(e, t) {
|
|
8046
|
+
let n = await wp(e), r = Date.now() + t.timeoutMs;
|
|
8047
|
+
for (;;) {
|
|
8048
|
+
let i = await e.runner.run({
|
|
8049
|
+
command: "railway",
|
|
8050
|
+
args: [
|
|
8051
|
+
"api",
|
|
8052
|
+
Of,
|
|
8053
|
+
"--variables",
|
|
8054
|
+
JSON.stringify({ input: {
|
|
8055
|
+
serviceId: t.serviceId,
|
|
8056
|
+
environmentId: n
|
|
8057
|
+
} }),
|
|
8058
|
+
"--compact"
|
|
8059
|
+
],
|
|
8060
|
+
cwd: e.cwd,
|
|
8061
|
+
allowFailure: !0,
|
|
8062
|
+
label: `check the ${t.name} deployment`
|
|
8063
|
+
});
|
|
8064
|
+
if (e.runner.dryRun) return {
|
|
8065
|
+
ok: !0,
|
|
8066
|
+
status: null
|
|
8067
|
+
};
|
|
8068
|
+
let a = i.exitCode === 0 ? hp(i.stdout) : null;
|
|
8069
|
+
if (!a) return {
|
|
8070
|
+
ok: !0,
|
|
8071
|
+
status: null,
|
|
8072
|
+
note: `could not read the deployment status of ${t.name}, so check it in the Railway dashboard`
|
|
8073
|
+
};
|
|
8074
|
+
if (Ef.has(a.status)) return {
|
|
8075
|
+
ok: !0,
|
|
8076
|
+
status: a.status,
|
|
8077
|
+
deploymentId: a.id
|
|
8078
|
+
};
|
|
8079
|
+
if (Df.has(a.status)) return {
|
|
8080
|
+
ok: !1,
|
|
8081
|
+
status: a.status,
|
|
8082
|
+
deploymentId: a.id
|
|
8083
|
+
};
|
|
8084
|
+
if (Date.now() >= r) return {
|
|
8085
|
+
ok: !1,
|
|
8086
|
+
status: a.status,
|
|
8087
|
+
deploymentId: a.id,
|
|
8088
|
+
note: `still ${a.status.toLowerCase()} after ${Math.round(t.timeoutMs / 6e4)} minutes`
|
|
8089
|
+
};
|
|
8090
|
+
e.log?.(`${t.name} is ${a.status.toLowerCase()}`), await bp(t.pollIntervalMs);
|
|
8091
|
+
}
|
|
8092
|
+
}
|
|
8093
|
+
function bp(e) {
|
|
8094
|
+
return new Promise((t) => setTimeout(t, e));
|
|
8095
|
+
}
|
|
8096
|
+
async function xp(e, t) {
|
|
8097
|
+
let n = t.status === "CRASHED" ? Af : kf, r = await e.runner.run({
|
|
8098
|
+
command: "railway",
|
|
8099
|
+
args: [
|
|
8100
|
+
"api",
|
|
8101
|
+
n,
|
|
8102
|
+
"--variables",
|
|
8103
|
+
JSON.stringify({
|
|
8104
|
+
deploymentId: t.id,
|
|
8105
|
+
limit: 50
|
|
8106
|
+
}),
|
|
8107
|
+
"--compact"
|
|
8108
|
+
],
|
|
8109
|
+
cwd: e.cwd,
|
|
8110
|
+
allowFailure: !0,
|
|
8111
|
+
label: "read the failed deployment's logs"
|
|
8112
|
+
});
|
|
8113
|
+
if (r.exitCode !== 0) return null;
|
|
8114
|
+
let i = _p(r.stdout);
|
|
8115
|
+
return i.length === 0 ? null : i.slice(-15).join("\n");
|
|
8116
|
+
}
|
|
8117
|
+
async function Sp(e, t) {
|
|
8118
|
+
let n = await wp(e), r = await e.runner.run({
|
|
7798
8119
|
command: "railway",
|
|
7799
8120
|
args: [
|
|
7800
8121
|
"api",
|
|
@@ -7812,15 +8133,15 @@ async function Kf(e, t) {
|
|
|
7812
8133
|
label: `set the start command on ${t.name}`
|
|
7813
8134
|
});
|
|
7814
8135
|
if (r.exitCode !== 0) {
|
|
7815
|
-
let e = r.stderr.trim() || r.stdout.trim(), n =
|
|
8136
|
+
let e = r.stderr.trim() || r.stdout.trim(), n = Lf.test(e) ? "Your Railway CLI is too old for `railway api`. Update it with `npm i -g @railway/cli` and run deploy again." : `Set the start command on ${t.name} from the Railway dashboard: ${t.command}`;
|
|
7816
8137
|
throw Error(`Could not set the start command on the Railway service "${t.name}":\n${e}\n${n}`);
|
|
7817
8138
|
}
|
|
7818
8139
|
}
|
|
7819
|
-
var
|
|
7820
|
-
async function
|
|
7821
|
-
let t =
|
|
8140
|
+
var Cp = /* @__PURE__ */ new WeakMap();
|
|
8141
|
+
async function wp(e) {
|
|
8142
|
+
let t = Cp.get(e);
|
|
7822
8143
|
if (t) return t;
|
|
7823
|
-
let n =
|
|
8144
|
+
let n = Tp((await e.runner.run({
|
|
7824
8145
|
command: "railway",
|
|
7825
8146
|
args: ["status", "--json"],
|
|
7826
8147
|
cwd: e.cwd,
|
|
@@ -7828,9 +8149,9 @@ async function Jf(e) {
|
|
|
7828
8149
|
label: "read the linked railway environment"
|
|
7829
8150
|
})).stdout, e.plan.environment);
|
|
7830
8151
|
if (!n) throw Error(`Could not find the Railway environment "${e.plan.environment}" in the linked project. Run \`railway status\` to check what is linked.`);
|
|
7831
|
-
return
|
|
8152
|
+
return Cp.set(e, n), n;
|
|
7832
8153
|
}
|
|
7833
|
-
function
|
|
8154
|
+
function Tp(e, t) {
|
|
7834
8155
|
let n = Q(e.trim());
|
|
7835
8156
|
if (typeof n != "object" || !n) return null;
|
|
7836
8157
|
let r = n.environments, i = typeof r == "object" && r ? r.edges : void 0;
|
|
@@ -7849,7 +8170,7 @@ function Yf(e, t) {
|
|
|
7849
8170
|
let o = a.find((e) => e.name === t);
|
|
7850
8171
|
return o ? o.id : a.length === 1 ? a[0].id : null;
|
|
7851
8172
|
}
|
|
7852
|
-
async function
|
|
8173
|
+
async function Ep(e, t) {
|
|
7853
8174
|
let n = await e.runner.run({
|
|
7854
8175
|
command: "railway",
|
|
7855
8176
|
args: [
|
|
@@ -7865,15 +8186,15 @@ async function Xf(e, t) {
|
|
|
7865
8186
|
allowFailure: !0,
|
|
7866
8187
|
label: `expose ${t.name} on a tcp proxy`
|
|
7867
8188
|
});
|
|
7868
|
-
n.exitCode !== 0 && !
|
|
8189
|
+
n.exitCode !== 0 && !If.test(n.stderr + n.stdout) && e.log?.(`Could not open a TCP proxy on ${t.name}, so it is only reachable from inside the Railway project: ${n.stderr.trim() || n.stdout.trim()}`);
|
|
7869
8190
|
}
|
|
7870
|
-
var
|
|
8191
|
+
var Dp = {
|
|
7871
8192
|
RUSTFS_ENDPOINT: "ENDPOINT",
|
|
7872
8193
|
RUSTFS_ACCESS_KEY: "ACCESS_KEY_ID",
|
|
7873
8194
|
RUSTFS_SECRET_KEY: "SECRET_ACCESS_KEY",
|
|
7874
8195
|
BUCKET_NAME: "BUCKET"
|
|
7875
8196
|
};
|
|
7876
|
-
async function
|
|
8197
|
+
async function Op(e, t) {
|
|
7877
8198
|
let { service: n, crossProvider: r } = t, i = n.name, a = await e.runner.run({
|
|
7878
8199
|
command: "railway",
|
|
7879
8200
|
args: [
|
|
@@ -7886,14 +8207,14 @@ async function Qf(e, t) {
|
|
|
7886
8207
|
label: "list railway buckets"
|
|
7887
8208
|
});
|
|
7888
8209
|
if (a.exitCode !== 0) {
|
|
7889
|
-
if (!
|
|
7890
|
-
return e.log?.("This Railway CLI has no `bucket` command, so storage runs as a RustFS service instead"),
|
|
8210
|
+
if (!Lf.test(a.stderr + a.stdout)) throw Error(`Could not list the Railway buckets in this project:\n${a.stderr.trim()}`);
|
|
8211
|
+
return e.log?.("This Railway CLI has no `bucket` command, so storage runs as a RustFS service instead"), Pp(e, n);
|
|
7891
8212
|
}
|
|
7892
|
-
|
|
7893
|
-
let o = await
|
|
8213
|
+
jp(a.stdout).some((e) => e.name === i) || await kp(e, n);
|
|
8214
|
+
let o = await np(e, i) !== null;
|
|
7894
8215
|
if (!r && !o) {
|
|
7895
8216
|
let e = {};
|
|
7896
|
-
for (let [t, n] of Object.entries(
|
|
8217
|
+
for (let [t, n] of Object.entries(Dp)) e[t] = ip(i, n);
|
|
7897
8218
|
return {
|
|
7898
8219
|
outputs: e,
|
|
7899
8220
|
note: `wired as Railway references to the ${i} bucket`
|
|
@@ -7911,14 +8232,14 @@ async function Qf(e, t) {
|
|
|
7911
8232
|
cwd: e.cwd,
|
|
7912
8233
|
allowFailure: !0,
|
|
7913
8234
|
label: `read the ${i} bucket credentials`
|
|
7914
|
-
}), c =
|
|
7915
|
-
if (!c) throw Error(`Could not read the credentials for the Railway bucket "${i}":\n${s.stderr.trim() || s.stdout.trim()}\nRun \`railway bucket credentials --bucket ${i}\` and set ${
|
|
8235
|
+
}), c = Np(s.stdout);
|
|
8236
|
+
if (!c) throw Error(`Could not read the credentials for the Railway bucket "${i}":\n${s.stderr.trim() || s.stdout.trim()}\nRun \`railway bucket credentials --bucket ${i}\` and set ${vd("services", "bucket", "external")} in ${X}.`);
|
|
7916
8237
|
return {
|
|
7917
8238
|
outputs: c,
|
|
7918
8239
|
note: o ? `set as values, because the service "${i}" shares the bucket's name. Delete it with \`railway service delete --service ${i}\` to switch to references` : "read from the bucket, since a Railway reference does not resolve off Railway"
|
|
7919
8240
|
};
|
|
7920
8241
|
}
|
|
7921
|
-
async function
|
|
8242
|
+
async function kp(e, t) {
|
|
7922
8243
|
let n = await e.runner.run({
|
|
7923
8244
|
command: "railway",
|
|
7924
8245
|
args: [
|
|
@@ -7926,20 +8247,20 @@ async function $f(e, t) {
|
|
|
7926
8247
|
"create",
|
|
7927
8248
|
t.name,
|
|
7928
8249
|
"--region",
|
|
7929
|
-
|
|
8250
|
+
Ap(t.region),
|
|
7930
8251
|
"--json"
|
|
7931
8252
|
],
|
|
7932
8253
|
cwd: e.cwd,
|
|
7933
8254
|
allowFailure: !0,
|
|
7934
8255
|
label: `create the ${t.name} bucket`
|
|
7935
8256
|
});
|
|
7936
|
-
if (n.exitCode !== 0 && !
|
|
7937
|
-
if (
|
|
8257
|
+
if (n.exitCode !== 0 && !If.test(n.stderr + n.stdout)) throw Error(`Could not create the Railway bucket "${t.name}":\n${n.stderr.trim()}`);
|
|
8258
|
+
if (Mp(n.stdout)) throw Error(`The Railway bucket "${t.name}" was created but staged rather than deployed, because the environment has uncommitted changes. Commit them in the Railway dashboard and run deploy again.`);
|
|
7938
8259
|
}
|
|
7939
|
-
function
|
|
7940
|
-
return e &&
|
|
8260
|
+
function Ap(e) {
|
|
8261
|
+
return e && jf.includes(e) ? e : Mf;
|
|
7941
8262
|
}
|
|
7942
|
-
function
|
|
8263
|
+
function jp(e) {
|
|
7943
8264
|
let t = Q(e.trim());
|
|
7944
8265
|
if (!Array.isArray(t)) return [];
|
|
7945
8266
|
let n = [];
|
|
@@ -7953,11 +8274,11 @@ function tp(e) {
|
|
|
7953
8274
|
}
|
|
7954
8275
|
return n;
|
|
7955
8276
|
}
|
|
7956
|
-
function
|
|
8277
|
+
function Mp(e) {
|
|
7957
8278
|
let t = Q(e.trim());
|
|
7958
8279
|
return typeof t != "object" || !t ? !1 : t.staged === !0;
|
|
7959
8280
|
}
|
|
7960
|
-
function
|
|
8281
|
+
function Np(e) {
|
|
7961
8282
|
let t = Q(e.trim());
|
|
7962
8283
|
if (typeof t != "object" || !t) return null;
|
|
7963
8284
|
let n = t, r = (e) => typeof n[e] == "string" ? n[e] : "", i = r("endpoint"), a = r("accessKeyId"), o = r("secretAccessKey");
|
|
@@ -7968,15 +8289,15 @@ function rp(e) {
|
|
|
7968
8289
|
BUCKET_NAME: r("bucketName")
|
|
7969
8290
|
};
|
|
7970
8291
|
}
|
|
7971
|
-
async function
|
|
7972
|
-
let n = t.name, r = await
|
|
8292
|
+
async function Pp(e, t) {
|
|
8293
|
+
let n = t.name, r = await np(e, n), i = r ? await Ip(e, n) : null, a = i?.accessKey ?? `hs${O(8).toString("hex")}`, o = i?.secretKey ?? O(24).toString("base64url"), s = r?.id;
|
|
7973
8294
|
if (!i) {
|
|
7974
8295
|
let t = await e.runner.run({
|
|
7975
8296
|
command: "railway",
|
|
7976
8297
|
args: [
|
|
7977
8298
|
"add",
|
|
7978
8299
|
"--image",
|
|
7979
|
-
|
|
8300
|
+
Nf,
|
|
7980
8301
|
"--service",
|
|
7981
8302
|
n,
|
|
7982
8303
|
"--variables",
|
|
@@ -7984,7 +8305,7 @@ async function ip(e, t) {
|
|
|
7984
8305
|
"--variables",
|
|
7985
8306
|
`RUSTFS_SECRET_KEY=${o}`,
|
|
7986
8307
|
"--variables",
|
|
7987
|
-
`RUSTFS_ADDRESS=:${
|
|
8308
|
+
`RUSTFS_ADDRESS=:${Pf}`,
|
|
7988
8309
|
"--json"
|
|
7989
8310
|
],
|
|
7990
8311
|
cwd: e.cwd,
|
|
@@ -7992,14 +8313,14 @@ async function ip(e, t) {
|
|
|
7992
8313
|
secrets: [o],
|
|
7993
8314
|
label: `create object storage service ${n}`
|
|
7994
8315
|
});
|
|
7995
|
-
if (t.exitCode !== 0) throw
|
|
7996
|
-
s =
|
|
8316
|
+
if (t.exitCode !== 0) throw If.test(t.stderr + t.stdout) ? Error(`The Railway storage service "${n}" already exists, but its access keys could not be read back. Copy them from the dashboard into ${vd("services", "bucket", "external")} in ${X}.`) : Error(`Could not create the Railway storage service "${n}":\n${t.stderr.trim()}`);
|
|
8317
|
+
s = Hf(t.stdout)?.id ?? s;
|
|
7997
8318
|
}
|
|
7998
|
-
if (!s) throw Error(`Could not find the id of the Railway storage service "${n}", which is what \`railway volume\` needs to mount a volume on it. Run \`railway service list --json\` to check the project, or set ${
|
|
7999
|
-
await
|
|
8319
|
+
if (!s) throw Error(`Could not find the id of the Railway storage service "${n}", which is what \`railway volume\` needs to mount a volume on it. Run \`railway service list --json\` to check the project, or set ${vd("services", "bucket", "external")} in ${X} to use storage you run yourself.`);
|
|
8320
|
+
await Fp(e, {
|
|
8000
8321
|
name: n,
|
|
8001
8322
|
serviceId: s,
|
|
8002
|
-
mountPath:
|
|
8323
|
+
mountPath: Ff,
|
|
8003
8324
|
consequence: "anything uploaded to it would be lost on the next restart"
|
|
8004
8325
|
});
|
|
8005
8326
|
let c = await e.runner.run({
|
|
@@ -8009,14 +8330,14 @@ async function ip(e, t) {
|
|
|
8009
8330
|
"--service",
|
|
8010
8331
|
n,
|
|
8011
8332
|
"--port",
|
|
8012
|
-
String(
|
|
8333
|
+
String(Pf),
|
|
8013
8334
|
"--json"
|
|
8014
8335
|
],
|
|
8015
8336
|
cwd: e.cwd,
|
|
8016
8337
|
allowFailure: !0,
|
|
8017
8338
|
label: `expose ${n}`
|
|
8018
|
-
}), l =
|
|
8019
|
-
if (!l) throw Error(`Could not get a public endpoint for the Railway storage service "${n}". Run \`railway domain --service ${n} --port ${
|
|
8339
|
+
}), l = Rf(c.stdout + c.stderr);
|
|
8340
|
+
if (!l) throw Error(`Could not get a public endpoint for the Railway storage service "${n}". Run \`railway domain --service ${n} --port ${Pf}\` and set ${vd("services", "bucket", "external")} in ${X}.`);
|
|
8020
8341
|
return {
|
|
8021
8342
|
outputs: {
|
|
8022
8343
|
RUSTFS_ENDPOINT: l,
|
|
@@ -8024,10 +8345,10 @@ async function ip(e, t) {
|
|
|
8024
8345
|
RUSTFS_SECRET_KEY: o,
|
|
8025
8346
|
BUCKET_NAME: n
|
|
8026
8347
|
},
|
|
8027
|
-
note: i ? "reusing the existing RustFS service and its keys" : `RustFS on Railway, with a volume mounted at ${
|
|
8348
|
+
note: i ? "reusing the existing RustFS service and its keys" : `RustFS on Railway, with a volume mounted at ${Ff}`
|
|
8028
8349
|
};
|
|
8029
8350
|
}
|
|
8030
|
-
async function
|
|
8351
|
+
async function Fp(e, t) {
|
|
8031
8352
|
let n = await e.runner.run({
|
|
8032
8353
|
command: "railway",
|
|
8033
8354
|
args: [
|
|
@@ -8043,10 +8364,10 @@ async function ap(e, t) {
|
|
|
8043
8364
|
allowFailure: !0,
|
|
8044
8365
|
label: `attach a volume to ${t.name}`
|
|
8045
8366
|
});
|
|
8046
|
-
if (n.exitCode !== 0 && !
|
|
8367
|
+
if (n.exitCode !== 0 && !If.test(n.stderr + n.stdout)) throw Error(`The Railway service "${t.name}" has no persistent volume at ${t.mountPath}, so ${t.consequence}:\n${n.stderr.trim() || n.stdout.trim()}`);
|
|
8047
8368
|
}
|
|
8048
|
-
async function
|
|
8049
|
-
let n = await
|
|
8369
|
+
async function Ip(e, t) {
|
|
8370
|
+
let n = await op(e, t), r = n.RUSTFS_ACCESS_KEY, i = n.RUSTFS_SECRET_KEY;
|
|
8050
8371
|
return r && i ? {
|
|
8051
8372
|
accessKey: r,
|
|
8052
8373
|
secretKey: i
|
|
@@ -8054,101 +8375,41 @@ async function op(e, t) {
|
|
|
8054
8375
|
}
|
|
8055
8376
|
//#endregion
|
|
8056
8377
|
//#region src/deploy/providers/index.ts
|
|
8057
|
-
var
|
|
8058
|
-
railway:
|
|
8059
|
-
fly:
|
|
8378
|
+
var Lp = {
|
|
8379
|
+
railway: Wf,
|
|
8380
|
+
fly: Qd
|
|
8060
8381
|
};
|
|
8061
|
-
function
|
|
8062
|
-
return
|
|
8063
|
-
}
|
|
8064
|
-
//#endregion
|
|
8065
|
-
//#region src/deploy/runner.ts
|
|
8066
|
-
var lp = class extends Error {
|
|
8067
|
-
spec;
|
|
8068
|
-
result;
|
|
8069
|
-
constructor(e, t) {
|
|
8070
|
-
let n = (t.stderr.trim() || t.stdout.trim()).split("\n").slice(-8).join("\n");
|
|
8071
|
-
super(`${up(e)} exited with ${t.exitCode}${n ? `\n${n}` : ""}`), this.name = "CommandFailedError", this.spec = e, this.result = t;
|
|
8072
|
-
}
|
|
8073
|
-
};
|
|
8074
|
-
function up(e) {
|
|
8075
|
-
let t = [e.command, ...e.args].map(fp).join(" ");
|
|
8076
|
-
return dp(e.stdin === void 0 ? t : `${t} < (stdin)`, e.secrets ?? []);
|
|
8077
|
-
}
|
|
8078
|
-
function dp(e, t) {
|
|
8079
|
-
let n = e;
|
|
8080
|
-
for (let e of t) !e || e.length < 4 || (n = n.split(e).join("***"));
|
|
8081
|
-
return n;
|
|
8082
|
-
}
|
|
8083
|
-
function fp(e) {
|
|
8084
|
-
return e === "" ? "\"\"" : /[\s"'$`\\]/.test(e) ? `"${e.replace(/(["\\$`])/g, "\\$1")}"` : e;
|
|
8085
|
-
}
|
|
8086
|
-
function pp(e = {}) {
|
|
8087
|
-
let t = [];
|
|
8088
|
-
return {
|
|
8089
|
-
transcript: t,
|
|
8090
|
-
async run(n) {
|
|
8091
|
-
let r = up(n);
|
|
8092
|
-
t.push(r), e.onCommand?.(r);
|
|
8093
|
-
let i = e.env || n.env ? {
|
|
8094
|
-
...e.env,
|
|
8095
|
-
...n.env
|
|
8096
|
-
} : void 0, a = await W(n.command, n.args, {
|
|
8097
|
-
cwd: n.cwd,
|
|
8098
|
-
stdin: n.stdin,
|
|
8099
|
-
env: i,
|
|
8100
|
-
onData: e.onOutput ? (t) => e.onOutput?.(dp(t, n.secrets ?? [])) : void 0
|
|
8101
|
-
});
|
|
8102
|
-
if (a.exitCode !== 0 && !n.allowFailure) throw new lp(n, a);
|
|
8103
|
-
return a;
|
|
8104
|
-
}
|
|
8105
|
-
};
|
|
8106
|
-
}
|
|
8107
|
-
function mp(e = {}) {
|
|
8108
|
-
let t = [];
|
|
8109
|
-
return {
|
|
8110
|
-
transcript: t,
|
|
8111
|
-
dryRun: !0,
|
|
8112
|
-
run(n) {
|
|
8113
|
-
let r = up(n);
|
|
8114
|
-
t.push(r), e.onCommand?.(r);
|
|
8115
|
-
let i = e.responses?.find((e) => r.includes(e.match)), a = typeof i?.stdout == "function" ? i.stdout(n) : i?.stdout ?? "";
|
|
8116
|
-
return Promise.resolve({
|
|
8117
|
-
exitCode: i?.exitCode ?? 0,
|
|
8118
|
-
stdout: a,
|
|
8119
|
-
stderr: ""
|
|
8120
|
-
});
|
|
8121
|
-
}
|
|
8122
|
-
};
|
|
8382
|
+
function Rp(e) {
|
|
8383
|
+
return Lp[e];
|
|
8123
8384
|
}
|
|
8124
8385
|
//#endregion
|
|
8125
8386
|
//#region src/deploy/auth.ts
|
|
8126
|
-
function
|
|
8387
|
+
function zp() {
|
|
8127
8388
|
return {
|
|
8128
|
-
createRunner: (e) =>
|
|
8389
|
+
createRunner: (e) => hf({ env: e }),
|
|
8129
8390
|
runInteractive: async (e, t, n) => (await ni(e, t, { cwd: n })).exitCode,
|
|
8130
|
-
confirmInstall:
|
|
8131
|
-
chooseMethod:
|
|
8132
|
-
readToken:
|
|
8133
|
-
chooseScope:
|
|
8391
|
+
confirmInstall: Xp,
|
|
8392
|
+
chooseMethod: Zp,
|
|
8393
|
+
readToken: $p,
|
|
8394
|
+
chooseScope: Qp
|
|
8134
8395
|
};
|
|
8135
8396
|
}
|
|
8136
|
-
async function
|
|
8137
|
-
let t = e.io ??
|
|
8397
|
+
async function Bp(e) {
|
|
8398
|
+
let t = e.io ?? zp(), n = {}, r = {};
|
|
8138
8399
|
for (let i of e.providers) {
|
|
8139
|
-
let a =
|
|
8400
|
+
let a = Td[i], o = e.adapters?.[i] ?? Rp(i), s = {
|
|
8140
8401
|
io: t,
|
|
8141
8402
|
spec: a,
|
|
8142
8403
|
plan: e.plan,
|
|
8143
8404
|
skipPrompts: e.skipPrompts,
|
|
8144
8405
|
env: r
|
|
8145
8406
|
};
|
|
8146
|
-
await
|
|
8147
|
-
let c = await
|
|
8407
|
+
await Vp(s);
|
|
8408
|
+
let c = await Gp({
|
|
8148
8409
|
...s,
|
|
8149
8410
|
adapter: o
|
|
8150
8411
|
});
|
|
8151
|
-
r = c.env, c.account && (n[i] = c.account), await
|
|
8412
|
+
r = c.env, c.account && (n[i] = c.account), await Kp({
|
|
8152
8413
|
...s,
|
|
8153
8414
|
env: r,
|
|
8154
8415
|
adapter: o
|
|
@@ -8159,16 +8420,16 @@ async function gp(e) {
|
|
|
8159
8420
|
accounts: n
|
|
8160
8421
|
};
|
|
8161
8422
|
}
|
|
8162
|
-
async function
|
|
8423
|
+
async function Vp(e) {
|
|
8163
8424
|
let { io: t, spec: n, plan: r, skipPrompts: i } = e;
|
|
8164
|
-
if (await
|
|
8425
|
+
if (await Hp(e)) return;
|
|
8165
8426
|
let a = `The ${n.label} CLI is not on your PATH. Install it with ${F.command(n.install)} and run deploy again. ${I(n.docs)}`;
|
|
8166
|
-
(i || !
|
|
8427
|
+
(i || !Up()) && z(a, { reason: "input_required" }), rt({
|
|
8167
8428
|
reason: "input_required",
|
|
8168
8429
|
message: a
|
|
8169
|
-
}), await t.confirmInstall(n) || z(a, { reason: "input_required" }), await t.runInteractive("sh", ["-c", n.install], r.projectRoot), await
|
|
8430
|
+
}), await t.confirmInstall(n) || z(a, { reason: "input_required" }), await t.runInteractive("sh", ["-c", n.install], r.projectRoot), await Hp(e) || z(`That did not put ${F.command(n.bin)} on your PATH. ${a}`, { reason: "input_required" });
|
|
8170
8431
|
}
|
|
8171
|
-
async function
|
|
8432
|
+
async function Hp(e) {
|
|
8172
8433
|
let t = await e.io.createRunner(e.env).run({
|
|
8173
8434
|
command: e.spec.bin,
|
|
8174
8435
|
args: ["--version"],
|
|
@@ -8177,11 +8438,11 @@ async function vp(e) {
|
|
|
8177
8438
|
}).catch(() => null);
|
|
8178
8439
|
return t !== null && t.exitCode === 0;
|
|
8179
8440
|
}
|
|
8180
|
-
function
|
|
8441
|
+
function Up() {
|
|
8181
8442
|
return process.platform !== "win32";
|
|
8182
8443
|
}
|
|
8183
|
-
var
|
|
8184
|
-
async function
|
|
8444
|
+
var Wp = 3;
|
|
8445
|
+
async function Gp(e) {
|
|
8185
8446
|
let { io: t, spec: n, plan: r, skipPrompts: i, adapter: a } = e, o = { ...e.env }, s = 0;
|
|
8186
8447
|
for (;;) {
|
|
8187
8448
|
let e = {
|
|
@@ -8193,26 +8454,26 @@ async function xp(e) {
|
|
|
8193
8454
|
account: c.account,
|
|
8194
8455
|
env: o
|
|
8195
8456
|
};
|
|
8196
|
-
let l =
|
|
8457
|
+
let l = qp(n, o);
|
|
8197
8458
|
if (l) {
|
|
8198
8459
|
Object.assign(o, l);
|
|
8199
8460
|
continue;
|
|
8200
8461
|
}
|
|
8201
|
-
i && z(
|
|
8462
|
+
i && z(Yp(n), { reason: "auth_required" }), rt({
|
|
8202
8463
|
reason: "auth_required",
|
|
8203
|
-
message:
|
|
8204
|
-
}), s >=
|
|
8464
|
+
message: Yp(n)
|
|
8465
|
+
}), s >= Wp && z(`${n.label} still does not know who you are. ${Yp(n)}`, { reason: "auth_required" }), s += 1;
|
|
8205
8466
|
let u = await t.chooseMethod(n);
|
|
8206
8467
|
if (u === "token") {
|
|
8207
8468
|
let e = await t.readToken(n);
|
|
8208
|
-
Object.assign(o,
|
|
8469
|
+
Object.assign(o, Jp(n.conflictingTokenEnv), { [n.tokenEnv]: e });
|
|
8209
8470
|
continue;
|
|
8210
8471
|
}
|
|
8211
8472
|
let d = u === "browserless" ? n.browserlessLoginArgs ?? n.loginArgs : n.loginArgs;
|
|
8212
8473
|
await t.runInteractive(n.bin, d, r.projectRoot);
|
|
8213
8474
|
}
|
|
8214
8475
|
}
|
|
8215
|
-
async function
|
|
8476
|
+
async function Kp(e) {
|
|
8216
8477
|
let { io: t, spec: n, plan: r, skipPrompts: i, env: a, adapter: o } = e, { scope: s } = o;
|
|
8217
8478
|
if (!s || s.current(r)) return;
|
|
8218
8479
|
let c = await s.list({
|
|
@@ -8230,27 +8491,27 @@ async function Sp(e) {
|
|
|
8230
8491
|
message: l
|
|
8231
8492
|
}), s.pin(r, await t.chooseScope(n, s, c));
|
|
8232
8493
|
}
|
|
8233
|
-
function
|
|
8494
|
+
function qp(e, t) {
|
|
8234
8495
|
let n = (e.conflictingTokenEnv ?? []).filter((e) => !(e in t) && process.env[e] !== void 0);
|
|
8235
8496
|
if (n.length === 0) return null;
|
|
8236
8497
|
for (let t of n) _t(`${F.label(t)} is set in your shell, but it cannot create a ${e.label} project. Ignoring it for this run.`);
|
|
8237
|
-
return
|
|
8498
|
+
return Jp(n);
|
|
8238
8499
|
}
|
|
8239
|
-
function
|
|
8500
|
+
function Jp(e = []) {
|
|
8240
8501
|
return Object.fromEntries(e.map((e) => [e, void 0]));
|
|
8241
8502
|
}
|
|
8242
|
-
function
|
|
8503
|
+
function Yp(e) {
|
|
8243
8504
|
let t = F.command(`${e.bin} ${e.loginArgs.join(" ")}`);
|
|
8244
8505
|
return `Not signed in to ${e.label}. Run ${t}, or set ${F.label(e.tokenEnv)} to a token from ${I(e.tokenUrl)}.`;
|
|
8245
8506
|
}
|
|
8246
|
-
async function
|
|
8507
|
+
async function Xp(e) {
|
|
8247
8508
|
let t = await c.confirm({
|
|
8248
8509
|
message: `Deploying needs the ${F.highlight(e.label)} CLI. Install it with ${F.command(e.install)}?`,
|
|
8249
8510
|
initialValue: !0
|
|
8250
8511
|
});
|
|
8251
8512
|
return c.isCancel(t) && B(), t;
|
|
8252
8513
|
}
|
|
8253
|
-
async function
|
|
8514
|
+
async function Zp(e) {
|
|
8254
8515
|
let t = [{
|
|
8255
8516
|
value: "browser",
|
|
8256
8517
|
label: "Log in through the browser",
|
|
@@ -8272,7 +8533,7 @@ async function Dp(e) {
|
|
|
8272
8533
|
});
|
|
8273
8534
|
return c.isCancel(n) && B(), n;
|
|
8274
8535
|
}
|
|
8275
|
-
async function
|
|
8536
|
+
async function Qp(e, t, n) {
|
|
8276
8537
|
let r = await c.select({
|
|
8277
8538
|
message: `Which ${F.highlight(e.label)} ${t.label} should this project live in?`,
|
|
8278
8539
|
options: n.map((e) => ({
|
|
@@ -8283,7 +8544,7 @@ async function Op(e, t, n) {
|
|
|
8283
8544
|
});
|
|
8284
8545
|
return c.isCancel(r) && B(), r;
|
|
8285
8546
|
}
|
|
8286
|
-
async function
|
|
8547
|
+
async function $p(e) {
|
|
8287
8548
|
c.log.info(`Create one at ${I(e.tokenUrl)}. Give it the workspace this project should live in, not a single project.`);
|
|
8288
8549
|
let t = await c.password({
|
|
8289
8550
|
message: `Paste your ${e.label} token`,
|
|
@@ -8293,59 +8554,59 @@ async function kp(e) {
|
|
|
8293
8554
|
}
|
|
8294
8555
|
//#endregion
|
|
8295
8556
|
//#region src/deploy/config.ts
|
|
8296
|
-
var
|
|
8297
|
-
provider:
|
|
8557
|
+
var em = j.enum(Sd), tm = j.object({
|
|
8558
|
+
provider: em,
|
|
8298
8559
|
app: j.string().min(1).optional(),
|
|
8299
8560
|
region: j.string().min(1).optional(),
|
|
8300
8561
|
url: j.string().url().optional()
|
|
8301
|
-
}),
|
|
8302
|
-
provider:
|
|
8562
|
+
}), nm = j.object({
|
|
8563
|
+
provider: em,
|
|
8303
8564
|
name: j.string().min(1).optional(),
|
|
8304
8565
|
region: j.string().min(1).optional(),
|
|
8305
8566
|
external: j.record(j.string(), j.string()).optional()
|
|
8306
|
-
}),
|
|
8567
|
+
}), rm = j.object({
|
|
8307
8568
|
org: j.string().min(1).optional(),
|
|
8308
8569
|
postgresPlan: j.string().min(1).optional()
|
|
8309
|
-
}),
|
|
8570
|
+
}), im = j.object({ workspace: j.string().min(1).optional() }), am = j.object({
|
|
8310
8571
|
version: j.number().int().positive(),
|
|
8311
8572
|
projectName: j.string().min(1),
|
|
8312
8573
|
environment: j.string().min(1),
|
|
8313
|
-
defaultProvider:
|
|
8574
|
+
defaultProvider: em.optional(),
|
|
8314
8575
|
targets: j.object({
|
|
8315
|
-
backend:
|
|
8316
|
-
frontend:
|
|
8317
|
-
admin:
|
|
8576
|
+
backend: tm.optional(),
|
|
8577
|
+
frontend: tm.optional(),
|
|
8578
|
+
admin: tm.optional()
|
|
8318
8579
|
}).default({}),
|
|
8319
8580
|
services: j.object({
|
|
8320
|
-
postgres:
|
|
8321
|
-
valkey:
|
|
8322
|
-
bucket:
|
|
8581
|
+
postgres: nm.optional(),
|
|
8582
|
+
valkey: nm.optional(),
|
|
8583
|
+
bucket: nm.optional()
|
|
8323
8584
|
}).default({}),
|
|
8324
|
-
fly:
|
|
8325
|
-
railway:
|
|
8585
|
+
fly: rm.optional(),
|
|
8586
|
+
railway: im.optional()
|
|
8326
8587
|
});
|
|
8327
|
-
async function
|
|
8588
|
+
async function om(e) {
|
|
8328
8589
|
let t = await q(e).catch((e) => {
|
|
8329
8590
|
throw Error(`Could not read ${X}: ${e instanceof Error ? e.message : String(e)}. Fix it, then run deploy again.`);
|
|
8330
8591
|
});
|
|
8331
8592
|
if (!t) throw Error(`No ${X} in this project, so there is nothing to deploy. Run "hype-stack init" to create one, or deploy from the root of a project made with "hype-stack create".`);
|
|
8332
8593
|
return t;
|
|
8333
8594
|
}
|
|
8334
|
-
async function
|
|
8335
|
-
let t = (await
|
|
8595
|
+
async function sm(e) {
|
|
8596
|
+
let t = (await om(e))[_d];
|
|
8336
8597
|
if (t === void 0) return null;
|
|
8337
|
-
let n =
|
|
8338
|
-
if (!n.success) throw Error(`Invalid "${
|
|
8339
|
-
if (n.data.version > 1) throw Error(`The "${
|
|
8598
|
+
let n = am.safeParse(t);
|
|
8599
|
+
if (!n.success) throw Error(`Invalid "${_d}" block in ${X}:\n ${j.prettifyError(n.error)}`);
|
|
8600
|
+
if (n.data.version > 1) throw Error(`The "${_d}" block in ${X} was written by a newer CLI (version ${n.data.version}, this CLI understands 1). Upgrade with "npm i -g @hype-stack/cli".`);
|
|
8340
8601
|
return n.data;
|
|
8341
8602
|
}
|
|
8342
|
-
async function
|
|
8603
|
+
async function cm(e, t) {
|
|
8343
8604
|
await Vi(e, {
|
|
8344
|
-
...await
|
|
8345
|
-
[
|
|
8605
|
+
...await om(e),
|
|
8606
|
+
[_d]: um(t)
|
|
8346
8607
|
});
|
|
8347
8608
|
}
|
|
8348
|
-
function
|
|
8609
|
+
function lm(e, t = yd) {
|
|
8349
8610
|
return {
|
|
8350
8611
|
version: 1,
|
|
8351
8612
|
projectName: e,
|
|
@@ -8354,7 +8615,7 @@ function zp(e, t = vd) {
|
|
|
8354
8615
|
services: {}
|
|
8355
8616
|
};
|
|
8356
8617
|
}
|
|
8357
|
-
function
|
|
8618
|
+
function um(e) {
|
|
8358
8619
|
let t = {
|
|
8359
8620
|
version: e.version,
|
|
8360
8621
|
projectName: e.projectName,
|
|
@@ -8384,7 +8645,7 @@ function Bp(e) {
|
|
|
8384
8645
|
}
|
|
8385
8646
|
//#endregion
|
|
8386
8647
|
//#region src/deploy/detect.ts
|
|
8387
|
-
var
|
|
8648
|
+
var dm = [
|
|
8388
8649
|
"@hono/node-server",
|
|
8389
8650
|
"@tanstack/react-start",
|
|
8390
8651
|
"@tanstack/start",
|
|
@@ -8392,41 +8653,41 @@ var Vp = [
|
|
|
8392
8653
|
"express",
|
|
8393
8654
|
"fastify"
|
|
8394
8655
|
];
|
|
8395
|
-
function
|
|
8396
|
-
let r =
|
|
8656
|
+
function fm(e, t, n) {
|
|
8657
|
+
let r = Cd[t], i = n?.paths?.[r.pathKey]?.root, a = n?.apps?.[t];
|
|
8397
8658
|
return T.resolve(e, i ?? a ?? r.defaultRoot);
|
|
8398
8659
|
}
|
|
8399
|
-
async function
|
|
8400
|
-
return (await Promise.all(
|
|
8401
|
-
let r =
|
|
8660
|
+
async function pm(e, t) {
|
|
8661
|
+
return (await Promise.all(bd.map(async (n) => {
|
|
8662
|
+
let r = fm(e, n, t);
|
|
8402
8663
|
return await G(T.join(r, "package.json")) ? n : null;
|
|
8403
8664
|
}))).filter((e) => e !== null);
|
|
8404
8665
|
}
|
|
8405
|
-
var
|
|
8406
|
-
async function
|
|
8666
|
+
var mm = ["build:web", "build"];
|
|
8667
|
+
async function hm(e, t) {
|
|
8407
8668
|
let [n, r] = await Promise.all([G(T.join(e, "Dockerfile")), oi(T.join(e, "package.json")).catch(() => null)]);
|
|
8408
8669
|
if (n) return "node";
|
|
8409
|
-
if (
|
|
8670
|
+
if (Cd[t].serveMode === "node") return null;
|
|
8410
8671
|
let i = r?.scripts ?? {}, a = {
|
|
8411
8672
|
...r?.dependencies,
|
|
8412
8673
|
...r?.devDependencies
|
|
8413
|
-
}, o =
|
|
8674
|
+
}, o = mm.some((e) => i[e] !== void 0), s = dm.some((e) => a[e] !== void 0);
|
|
8414
8675
|
return o || !s ? "static" : null;
|
|
8415
8676
|
}
|
|
8416
|
-
async function
|
|
8417
|
-
let r = await Promise.all(t.map(async (t) => [t, await
|
|
8677
|
+
async function gm(e, t, n) {
|
|
8678
|
+
let r = await Promise.all(t.map(async (t) => [t, await hm(fm(e, t, n), t)]));
|
|
8418
8679
|
return Object.fromEntries(r);
|
|
8419
8680
|
}
|
|
8420
|
-
function
|
|
8681
|
+
function _m(e) {
|
|
8421
8682
|
let t = {};
|
|
8422
|
-
for (let n of
|
|
8683
|
+
for (let n of bd) {
|
|
8423
8684
|
let r = e[n];
|
|
8424
8685
|
r && (t[n] = r);
|
|
8425
8686
|
}
|
|
8426
8687
|
return t;
|
|
8427
8688
|
}
|
|
8428
|
-
async function
|
|
8429
|
-
let n =
|
|
8689
|
+
async function vm(e, t) {
|
|
8690
|
+
let n = Cd[t].staticDir ?? "dist", r = [
|
|
8430
8691
|
n,
|
|
8431
8692
|
"dist",
|
|
8432
8693
|
".output/public",
|
|
@@ -8438,11 +8699,11 @@ async function Jp(e, t) {
|
|
|
8438
8699
|
//#endregion
|
|
8439
8700
|
//#region src/deploy/dry-run.ts
|
|
8440
8701
|
var $ = "dry-run-placeholder";
|
|
8441
|
-
function
|
|
8702
|
+
function ym(e, t) {
|
|
8442
8703
|
let n = e.args.indexOf(t);
|
|
8443
8704
|
return n === -1 ? "app" : e.args[n + 1] ?? "app";
|
|
8444
8705
|
}
|
|
8445
|
-
var
|
|
8706
|
+
var bm = "dryrun00cluster", xm = "dryrun00service", Sm = [
|
|
8446
8707
|
{
|
|
8447
8708
|
match: "fly orgs list",
|
|
8448
8709
|
stdout: JSON.stringify([{
|
|
@@ -8460,13 +8721,13 @@ var Xp = "dryrun00cluster", Zp = "dryrun00service", Qp = [
|
|
|
8460
8721
|
},
|
|
8461
8722
|
{
|
|
8462
8723
|
match: "fly mpg create",
|
|
8463
|
-
stdout: `Managed Postgres cluster created successfully!\n ID: ${
|
|
8724
|
+
stdout: `Managed Postgres cluster created successfully!\n ID: ${bm}\n Connection string: postgres://hype:${$}@example.flympg.net:5432/postgres`
|
|
8464
8725
|
},
|
|
8465
8726
|
{
|
|
8466
8727
|
match: "fly mpg status",
|
|
8467
8728
|
stdout: JSON.stringify({
|
|
8468
8729
|
data: {
|
|
8469
|
-
id:
|
|
8730
|
+
id: bm,
|
|
8470
8731
|
status: "ready"
|
|
8471
8732
|
},
|
|
8472
8733
|
credentials: { pgbouncer_uri: `postgres://hype:${$}@example.flympg.net:5432/postgres` }
|
|
@@ -8483,7 +8744,7 @@ var Xp = "dryrun00cluster", Zp = "dryrun00service", Qp = [
|
|
|
8483
8744
|
{
|
|
8484
8745
|
match: "fly storage create",
|
|
8485
8746
|
stdout: (e) => [
|
|
8486
|
-
`BUCKET_NAME: ${
|
|
8747
|
+
`BUCKET_NAME: ${ym(e, "--name")}`,
|
|
8487
8748
|
"AWS_ENDPOINT_URL_S3: https://fly.storage.tigris.dev",
|
|
8488
8749
|
`AWS_ACCESS_KEY_ID: ${$}`,
|
|
8489
8750
|
`AWS_SECRET_ACCESS_KEY: ${$}`
|
|
@@ -8504,8 +8765,8 @@ var Xp = "dryrun00cluster", Zp = "dryrun00service", Qp = [
|
|
|
8504
8765
|
{
|
|
8505
8766
|
match: "railway add",
|
|
8506
8767
|
stdout: (e) => JSON.stringify({
|
|
8507
|
-
id:
|
|
8508
|
-
name:
|
|
8768
|
+
id: xm,
|
|
8769
|
+
name: ym(e, "--service")
|
|
8509
8770
|
})
|
|
8510
8771
|
},
|
|
8511
8772
|
{
|
|
@@ -8520,7 +8781,7 @@ var Xp = "dryrun00cluster", Zp = "dryrun00service", Qp = [
|
|
|
8520
8781
|
},
|
|
8521
8782
|
{
|
|
8522
8783
|
match: "railway domain",
|
|
8523
|
-
stdout: (e) => JSON.stringify({ domain: `${
|
|
8784
|
+
stdout: (e) => JSON.stringify({ domain: `${ym(e, "--service")}-production.up.railway.app` })
|
|
8524
8785
|
},
|
|
8525
8786
|
{
|
|
8526
8787
|
match: "railway variable list",
|
|
@@ -8539,7 +8800,7 @@ var Xp = "dryrun00cluster", Zp = "dryrun00service", Qp = [
|
|
|
8539
8800
|
stdout: (e) => JSON.stringify({
|
|
8540
8801
|
id: "dryrun00bucket",
|
|
8541
8802
|
name: e.args[2] ?? "bucket",
|
|
8542
|
-
region:
|
|
8803
|
+
region: ym(e, "--region"),
|
|
8543
8804
|
staged: !1,
|
|
8544
8805
|
committed: !0
|
|
8545
8806
|
})
|
|
@@ -8559,7 +8820,7 @@ var Xp = "dryrun00cluster", Zp = "dryrun00service", Qp = [
|
|
|
8559
8820
|
match: "railway api",
|
|
8560
8821
|
stdout: JSON.stringify({ data: { serviceInstanceUpdate: !0 } })
|
|
8561
8822
|
}
|
|
8562
|
-
],
|
|
8823
|
+
], Cm = {
|
|
8563
8824
|
backend: [
|
|
8564
8825
|
"NODE_ENV",
|
|
8565
8826
|
"APP_ENV",
|
|
@@ -8587,55 +8848,60 @@ var Xp = "dryrun00cluster", Zp = "dryrun00service", Qp = [
|
|
|
8587
8848
|
"VITE_APP_TYPE",
|
|
8588
8849
|
"VITE_ENVIRONMENT"
|
|
8589
8850
|
]
|
|
8590
|
-
},
|
|
8851
|
+
}, wm = new Set([
|
|
8591
8852
|
"VITE_SENTRY_AUTH_TOKEN",
|
|
8592
8853
|
"POSTGRES_USER",
|
|
8593
8854
|
"POSTGRES_PASSWORD",
|
|
8594
8855
|
"POSTGRES_DB",
|
|
8595
8856
|
"POSTGRES_HOST",
|
|
8596
8857
|
"POSTGRES_PORT"
|
|
8597
|
-
]),
|
|
8598
|
-
function
|
|
8858
|
+
]), Tm = /(?:^|\/\/|@)(?:localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.internal)(?::\d+)?(?:\/|$)/i;
|
|
8859
|
+
function Em(e) {
|
|
8599
8860
|
let { plan: t, serviceOutputs: n, urls: r, localEnv: i = {}, declaredKeys: a = {}, exampleEnv: o = {}, externallyProvided: s = {} } = e;
|
|
8600
8861
|
return t.targets.map((e) => {
|
|
8601
|
-
let c =
|
|
8862
|
+
let c = Dm(e, t, r), l = Nm({
|
|
8602
8863
|
target: e.target,
|
|
8603
8864
|
environment: t.environment,
|
|
8604
8865
|
port: e.spec.port,
|
|
8605
8866
|
serviceOutputs: n,
|
|
8606
|
-
urls:
|
|
8607
|
-
}),
|
|
8608
|
-
declared:
|
|
8609
|
-
local:
|
|
8610
|
-
managed:
|
|
8611
|
-
origin:
|
|
8867
|
+
urls: c
|
|
8868
|
+
}), u = a[e.target] ?? [], d = i[e.target] ?? {}, f = c[e.target], { forwarded: p, rehosted: m, skippedLocal: h } = Fm({
|
|
8869
|
+
declared: u,
|
|
8870
|
+
local: d,
|
|
8871
|
+
managed: l,
|
|
8872
|
+
origin: f,
|
|
8612
8873
|
target: e.target
|
|
8613
|
-
}),
|
|
8614
|
-
keys:
|
|
8874
|
+
}), g = new Set(s[e.target] ?? []), _ = u.filter((e) => l[e] === void 0 && p[e] === void 0 && !wm.has(e) && !g.has(e)), { seeded: v, seededRehosted: y } = Om({
|
|
8875
|
+
keys: _,
|
|
8615
8876
|
example: o[e.target] ?? {},
|
|
8616
|
-
origin:
|
|
8617
|
-
}),
|
|
8877
|
+
origin: f
|
|
8878
|
+
}), b = _.filter((e) => v[e] === void 0);
|
|
8618
8879
|
return {
|
|
8619
8880
|
target: e.target,
|
|
8620
|
-
managed:
|
|
8621
|
-
forwarded:
|
|
8622
|
-
seeded:
|
|
8623
|
-
rehosted: [...
|
|
8624
|
-
missing:
|
|
8625
|
-
skippedLocal:
|
|
8881
|
+
managed: l,
|
|
8882
|
+
forwarded: p,
|
|
8883
|
+
seeded: v,
|
|
8884
|
+
rehosted: [...m, ...y],
|
|
8885
|
+
missing: b,
|
|
8886
|
+
skippedLocal: h
|
|
8626
8887
|
};
|
|
8627
8888
|
});
|
|
8628
8889
|
}
|
|
8629
|
-
function
|
|
8890
|
+
function Dm(e, t, n) {
|
|
8891
|
+
let r = e.provider === "railway" && e.spec.serveMode !== "static", i = {};
|
|
8892
|
+
for (let e of t.targets) i[e.target] = r && e.provider === "railway" ? ap(e.app) : n[e.target];
|
|
8893
|
+
return i;
|
|
8894
|
+
}
|
|
8895
|
+
function Om(e) {
|
|
8630
8896
|
let t = {}, n = [];
|
|
8631
8897
|
for (let r of e.keys) {
|
|
8632
8898
|
let i = e.example[r];
|
|
8633
8899
|
if (i === void 0 || i.trim() === "" || i.includes("${")) continue;
|
|
8634
|
-
if (!
|
|
8900
|
+
if (!Tm.test(i)) {
|
|
8635
8901
|
t[r] = i;
|
|
8636
8902
|
continue;
|
|
8637
8903
|
}
|
|
8638
|
-
let a =
|
|
8904
|
+
let a = km(i, e.origin);
|
|
8639
8905
|
a && (t[r] = a, n.push(r));
|
|
8640
8906
|
}
|
|
8641
8907
|
return {
|
|
@@ -8643,24 +8909,23 @@ function rm(e) {
|
|
|
8643
8909
|
seededRehosted: n
|
|
8644
8910
|
};
|
|
8645
8911
|
}
|
|
8646
|
-
function
|
|
8912
|
+
function km(e, t) {
|
|
8647
8913
|
if (!t) return null;
|
|
8914
|
+
let n;
|
|
8648
8915
|
try {
|
|
8649
|
-
|
|
8650
|
-
if (!/^https?:$/.test(n.protocol)) return null;
|
|
8651
|
-
let r = new URL(t);
|
|
8652
|
-
return r.pathname = n.pathname, r.search = n.search, r.hash = n.hash, n.pathname === "/" && !e.trimEnd().endsWith("/") ? r.toString().replace(/\/$/, "") : r.toString();
|
|
8916
|
+
n = new URL(e);
|
|
8653
8917
|
} catch {
|
|
8654
8918
|
return null;
|
|
8655
8919
|
}
|
|
8920
|
+
return /^https?:$/.test(n.protocol) ? `${t.replace(/\/+$/, "")}${n.pathname === "/" && !e.trimEnd().endsWith("/") ? "" : n.pathname}${n.search}${n.hash}` : null;
|
|
8656
8921
|
}
|
|
8657
|
-
var
|
|
8658
|
-
function
|
|
8922
|
+
var Am = "(pending)", jm = "https://pending.invalid";
|
|
8923
|
+
function Mm(e) {
|
|
8659
8924
|
let { plan: t, localEnv: n, declaredKeys: r, exampleEnv: i } = e, a = {};
|
|
8660
|
-
for (let e of t.targets) a[e.target] = e.url ??
|
|
8925
|
+
for (let e of t.targets) a[e.target] = e.url ?? jm;
|
|
8661
8926
|
let o = {};
|
|
8662
|
-
for (let e of t.services) o[e.service] = e.external ?? Object.fromEntries(e.spec.provides.map((e) => [e,
|
|
8663
|
-
return
|
|
8927
|
+
for (let e of t.services) o[e.service] = e.external ?? Object.fromEntries(e.spec.provides.map((e) => [e, Am]));
|
|
8928
|
+
return Em({
|
|
8664
8929
|
plan: t,
|
|
8665
8930
|
serviceOutputs: o,
|
|
8666
8931
|
urls: a,
|
|
@@ -8669,14 +8934,14 @@ function sm(e) {
|
|
|
8669
8934
|
exampleEnv: i
|
|
8670
8935
|
});
|
|
8671
8936
|
}
|
|
8672
|
-
function
|
|
8937
|
+
function Nm(e) {
|
|
8673
8938
|
let { target: t, environment: n, port: r, serviceOutputs: i, urls: a } = e;
|
|
8674
|
-
return t === "backend" ?
|
|
8939
|
+
return t === "backend" ? Pm({
|
|
8675
8940
|
environment: n,
|
|
8676
8941
|
port: r,
|
|
8677
8942
|
serviceOutputs: i,
|
|
8678
8943
|
urls: a
|
|
8679
|
-
}) :
|
|
8944
|
+
}) : Lm(t === "frontend" ? {
|
|
8680
8945
|
VITE_API_BASE_URL: a.backend,
|
|
8681
8946
|
VITE_ADMIN_URL: a.admin,
|
|
8682
8947
|
VITE_PUBLIC_SITE_URL: a.frontend,
|
|
@@ -8688,9 +8953,9 @@ function cm(e) {
|
|
|
8688
8953
|
VITE_ENVIRONMENT: n
|
|
8689
8954
|
});
|
|
8690
8955
|
}
|
|
8691
|
-
function
|
|
8956
|
+
function Pm(e) {
|
|
8692
8957
|
let { environment: t, port: n, serviceOutputs: r, urls: i } = e;
|
|
8693
|
-
return
|
|
8958
|
+
return Lm({
|
|
8694
8959
|
NODE_ENV: "production",
|
|
8695
8960
|
APP_ENV: t,
|
|
8696
8961
|
PORT: n === void 0 ? void 0 : String(n),
|
|
@@ -8702,14 +8967,14 @@ function lm(e) {
|
|
|
8702
8967
|
SERVER_URL: i.backend
|
|
8703
8968
|
});
|
|
8704
8969
|
}
|
|
8705
|
-
function
|
|
8706
|
-
let { declared: t, local: n, managed: r, origin: i, target: a } = e, o = new Set(
|
|
8970
|
+
function Fm(e) {
|
|
8971
|
+
let { declared: t, local: n, managed: r, origin: i, target: a } = e, o = new Set(Cm[a]), s = {}, c = [], l = [];
|
|
8707
8972
|
for (let e of t) {
|
|
8708
|
-
if (o.has(e) || r[e] !== void 0 ||
|
|
8973
|
+
if (o.has(e) || r[e] !== void 0 || wm.has(e)) continue;
|
|
8709
8974
|
let t = n[e];
|
|
8710
8975
|
if (!(t === void 0 || t.trim() === "") && !t.includes("${")) {
|
|
8711
|
-
if (
|
|
8712
|
-
let n =
|
|
8976
|
+
if (Tm.test(t)) {
|
|
8977
|
+
let n = km(t, i);
|
|
8713
8978
|
if (!n) {
|
|
8714
8979
|
l.push(e);
|
|
8715
8980
|
continue;
|
|
@@ -8726,19 +8991,19 @@ function um(e) {
|
|
|
8726
8991
|
skippedLocal: l
|
|
8727
8992
|
};
|
|
8728
8993
|
}
|
|
8729
|
-
function
|
|
8994
|
+
function Im(e) {
|
|
8730
8995
|
return {
|
|
8731
8996
|
...e.seeded,
|
|
8732
8997
|
...e.forwarded,
|
|
8733
8998
|
...e.managed
|
|
8734
8999
|
};
|
|
8735
9000
|
}
|
|
8736
|
-
function
|
|
9001
|
+
function Lm(e) {
|
|
8737
9002
|
let t = {};
|
|
8738
9003
|
for (let [n, r] of Object.entries(e)) r !== void 0 && r !== "" && (t[n] = r);
|
|
8739
9004
|
return t;
|
|
8740
9005
|
}
|
|
8741
|
-
function
|
|
9006
|
+
function Rm(e) {
|
|
8742
9007
|
let t = {};
|
|
8743
9008
|
for (let n of e.split(/\r?\n/)) {
|
|
8744
9009
|
let e = n.trim();
|
|
@@ -8746,27 +9011,27 @@ function pm(e) {
|
|
|
8746
9011
|
let r = e.startsWith("export ") ? e.slice(7).trim() : e, i = r.indexOf("=");
|
|
8747
9012
|
if (i <= 0) continue;
|
|
8748
9013
|
let a = r.slice(0, i).trim();
|
|
8749
|
-
/^[A-Za-z_][A-Za-z0-9_]*$/.test(a) && (t[a] =
|
|
9014
|
+
/^[A-Za-z_][A-Za-z0-9_]*$/.test(a) && (t[a] = zm(r.slice(i + 1).trim()));
|
|
8750
9015
|
}
|
|
8751
9016
|
return t;
|
|
8752
9017
|
}
|
|
8753
|
-
function
|
|
9018
|
+
function zm(e) {
|
|
8754
9019
|
if (e.length >= 2 && (e.startsWith("\"") && e.endsWith("\"") || e.startsWith("'") && e.endsWith("'"))) return e.slice(1, -1);
|
|
8755
9020
|
let t = e.indexOf(" #");
|
|
8756
9021
|
return t === -1 ? e : e.slice(0, t).trim();
|
|
8757
9022
|
}
|
|
8758
|
-
function
|
|
8759
|
-
return [...new Set(Object.keys(
|
|
9023
|
+
function Bm(e) {
|
|
9024
|
+
return [...new Set(Object.keys(Rm(e)))];
|
|
8760
9025
|
}
|
|
8761
9026
|
//#endregion
|
|
8762
9027
|
//#region src/deploy/migrations.ts
|
|
8763
|
-
var
|
|
9028
|
+
var Vm = [
|
|
8764
9029
|
"migration:latest",
|
|
8765
9030
|
"migrate:deploy",
|
|
8766
9031
|
"db:migrate:deploy"
|
|
8767
9032
|
];
|
|
8768
|
-
async function
|
|
8769
|
-
let n = await oi(T.join(e, "package.json")).catch(() => null), r =
|
|
9033
|
+
async function Hm(e, t) {
|
|
9034
|
+
let n = await oi(T.join(e, "package.json")).catch(() => null), r = Vm.find((e) => typeof n?.scripts?.[e] == "string");
|
|
8770
9035
|
if (r && n?.name) return [
|
|
8771
9036
|
"pnpm",
|
|
8772
9037
|
"--filter",
|
|
@@ -8779,7 +9044,7 @@ async function _m(e, t) {
|
|
|
8779
9044
|
"run",
|
|
8780
9045
|
r
|
|
8781
9046
|
];
|
|
8782
|
-
let i = await
|
|
9047
|
+
let i = await Um(e);
|
|
8783
9048
|
return [
|
|
8784
9049
|
"npx",
|
|
8785
9050
|
"prisma",
|
|
@@ -8789,7 +9054,7 @@ async function _m(e, t) {
|
|
|
8789
9054
|
T.relative(t, i).split(T.sep).join("/")
|
|
8790
9055
|
];
|
|
8791
9056
|
}
|
|
8792
|
-
async function
|
|
9057
|
+
async function Um(e) {
|
|
8793
9058
|
let t = T.join(e, "prisma"), n = T.join(t, "schema");
|
|
8794
9059
|
if (await ri(n)) return n;
|
|
8795
9060
|
let r = T.join(t, "schema.prisma");
|
|
@@ -8797,16 +9062,16 @@ async function vm(e) {
|
|
|
8797
9062
|
}
|
|
8798
9063
|
//#endregion
|
|
8799
9064
|
//#region src/deploy/orchestrate.ts
|
|
8800
|
-
async function
|
|
9065
|
+
async function Wm(e) {
|
|
8801
9066
|
let { plan: t, runner: n, log: r } = e, i = [], a = {}, o = { ...e.knownServiceOutputs }, s = {}, c = [], l = {
|
|
8802
9067
|
runner: n,
|
|
8803
9068
|
plan: t,
|
|
8804
9069
|
cwd: t.projectRoot,
|
|
8805
9070
|
log: r
|
|
8806
|
-
}, u = (t) => e.adapters?.[t] ??
|
|
9071
|
+
}, u = (t) => e.adapters?.[t] ?? Rp(t), d = (e, n) => (i.push({
|
|
8807
9072
|
...e,
|
|
8808
9073
|
status: "failed",
|
|
8809
|
-
detail:
|
|
9074
|
+
detail: Xm(n)
|
|
8810
9075
|
}), {
|
|
8811
9076
|
plan: t,
|
|
8812
9077
|
steps: i,
|
|
@@ -8815,7 +9080,7 @@ async function ym(e) {
|
|
|
8815
9080
|
envPlans: c,
|
|
8816
9081
|
ok: !1
|
|
8817
9082
|
});
|
|
8818
|
-
if (!e.skipAuthCheck) for (let n of
|
|
9083
|
+
if (!e.skipAuthCheck) for (let n of qm(t)) {
|
|
8819
9084
|
let t = {
|
|
8820
9085
|
id: `auth:${n}`,
|
|
8821
9086
|
label: `Check ${n} login`
|
|
@@ -8880,13 +9145,13 @@ async function ym(e) {
|
|
|
8880
9145
|
}, e.providedByProvider && f && (s[f.target] = [...s[f.target] ?? [], ...e.providedByProvider]), i.push({
|
|
8881
9146
|
...t,
|
|
8882
9147
|
status: "ok",
|
|
8883
|
-
detail: e.note ??
|
|
9148
|
+
detail: e.note ?? Ym(e.outputs)
|
|
8884
9149
|
});
|
|
8885
9150
|
} catch (e) {
|
|
8886
9151
|
return d(t, e);
|
|
8887
9152
|
}
|
|
8888
9153
|
}
|
|
8889
|
-
c =
|
|
9154
|
+
c = Em({
|
|
8890
9155
|
plan: t,
|
|
8891
9156
|
serviceOutputs: o,
|
|
8892
9157
|
urls: a,
|
|
@@ -8895,9 +9160,9 @@ async function ym(e) {
|
|
|
8895
9160
|
exampleEnv: e.exampleEnv,
|
|
8896
9161
|
externallyProvided: s
|
|
8897
9162
|
});
|
|
8898
|
-
let p = new Map(c.map((e) => [e.target, e])), m = f && !e.skipMigrations ? await
|
|
9163
|
+
let p = new Map(c.map((e) => [e.target, e])), m = f && !e.skipMigrations ? await Hm(f.root, t.projectRoot) : void 0, h = !1, g = /* @__PURE__ */ new Set();
|
|
8899
9164
|
for (let e of t.targets) {
|
|
8900
|
-
let t = p.get(e.target), n = t ?
|
|
9165
|
+
let t = p.get(e.target), n = t ? Im(t) : {}, o = Jm(n), s = u(e.provider), c = {
|
|
8901
9166
|
id: `env:${e.target}`,
|
|
8902
9167
|
label: `Configure ${e.spec.label} env`
|
|
8903
9168
|
};
|
|
@@ -8911,10 +9176,15 @@ async function ym(e) {
|
|
|
8911
9176
|
status: "ok",
|
|
8912
9177
|
detail: `${Object.keys(n).length} variables`
|
|
8913
9178
|
});
|
|
8914
|
-
} catch (
|
|
8915
|
-
|
|
9179
|
+
} catch (t) {
|
|
9180
|
+
i.push({
|
|
9181
|
+
...c,
|
|
9182
|
+
status: "failed",
|
|
9183
|
+
detail: Xm(t)
|
|
9184
|
+
}), g.add(e.target);
|
|
9185
|
+
continue;
|
|
8916
9186
|
}
|
|
8917
|
-
let
|
|
9187
|
+
let d = {
|
|
8918
9188
|
id: `deploy:${e.target}`,
|
|
8919
9189
|
label: `Deploy ${e.spec.label}`
|
|
8920
9190
|
};
|
|
@@ -8927,12 +9197,40 @@ async function ym(e) {
|
|
|
8927
9197
|
releaseCommand: e === f ? m : void 0
|
|
8928
9198
|
});
|
|
8929
9199
|
t.url && (a[e.target] = t.url), t.releaseRan && (h = !0), i.push({
|
|
8930
|
-
...
|
|
9200
|
+
...d,
|
|
8931
9201
|
status: "ok",
|
|
8932
9202
|
detail: t.url ?? t.note
|
|
8933
9203
|
});
|
|
8934
|
-
} catch (
|
|
8935
|
-
|
|
9204
|
+
} catch (t) {
|
|
9205
|
+
i.push({
|
|
9206
|
+
...d,
|
|
9207
|
+
status: "failed",
|
|
9208
|
+
detail: Xm(t)
|
|
9209
|
+
}), g.add(e.target);
|
|
9210
|
+
}
|
|
9211
|
+
}
|
|
9212
|
+
for (let e of t.targets) {
|
|
9213
|
+
if (g.has(e.target)) continue;
|
|
9214
|
+
let t = u(e.provider);
|
|
9215
|
+
if (!t.awaitTarget) continue;
|
|
9216
|
+
let n = {
|
|
9217
|
+
id: `verify:${e.target}`,
|
|
9218
|
+
label: `Verify ${e.spec.label}`
|
|
9219
|
+
};
|
|
9220
|
+
try {
|
|
9221
|
+
r?.(`Waiting for ${e.spec.label} to come up`);
|
|
9222
|
+
let a = await t.awaitTarget(l, e);
|
|
9223
|
+
i.push({
|
|
9224
|
+
...n,
|
|
9225
|
+
status: a.ok ? "ok" : "failed",
|
|
9226
|
+
detail: a.detail
|
|
9227
|
+
}), a.ok || g.add(e.target);
|
|
9228
|
+
} catch (t) {
|
|
9229
|
+
i.push({
|
|
9230
|
+
...n,
|
|
9231
|
+
status: "failed",
|
|
9232
|
+
detail: Xm(t)
|
|
9233
|
+
}), g.add(e.target);
|
|
8936
9234
|
}
|
|
8937
9235
|
}
|
|
8938
9236
|
if (f) {
|
|
@@ -8940,7 +9238,12 @@ async function ym(e) {
|
|
|
8940
9238
|
id: "migrate",
|
|
8941
9239
|
label: "Apply database migrations"
|
|
8942
9240
|
};
|
|
8943
|
-
if (
|
|
9241
|
+
if (g.has(f.target)) i.push({
|
|
9242
|
+
...t,
|
|
9243
|
+
status: "skipped",
|
|
9244
|
+
detail: `not run because the ${f.spec.label} deploy failed`
|
|
9245
|
+
});
|
|
9246
|
+
else if (e.skipMigrations || !m) i.push({
|
|
8944
9247
|
...t,
|
|
8945
9248
|
status: "skipped",
|
|
8946
9249
|
detail: "--skip-migrations"
|
|
@@ -8951,7 +9254,7 @@ async function ym(e) {
|
|
|
8951
9254
|
detail: `${m.join(" ")} (ran with the release)`
|
|
8952
9255
|
});
|
|
8953
9256
|
else {
|
|
8954
|
-
let e = await
|
|
9257
|
+
let e = await Gm({
|
|
8955
9258
|
ctx: l,
|
|
8956
9259
|
adapter: u(f.provider),
|
|
8957
9260
|
backend: f,
|
|
@@ -8972,7 +9275,7 @@ async function ym(e) {
|
|
|
8972
9275
|
ok: i.every((e) => e.status !== "failed")
|
|
8973
9276
|
};
|
|
8974
9277
|
}
|
|
8975
|
-
async function
|
|
9278
|
+
async function Gm(e) {
|
|
8976
9279
|
let { ctx: t, adapter: n, backend: r, command: i } = e;
|
|
8977
9280
|
if (!n.runRemote) return {
|
|
8978
9281
|
status: "skipped",
|
|
@@ -8984,38 +9287,38 @@ async function bm(e) {
|
|
|
8984
9287
|
status: "ok",
|
|
8985
9288
|
detail: i.join(" ")
|
|
8986
9289
|
};
|
|
8987
|
-
let o =
|
|
9290
|
+
let o = Km(a.output);
|
|
8988
9291
|
return {
|
|
8989
9292
|
status: "skipped",
|
|
8990
9293
|
detail: `Could not run migrations remotely${o ? ` (${o})` : ""}. Run "${i.join(" ")}" against ${r.app}.`
|
|
8991
9294
|
};
|
|
8992
9295
|
}
|
|
8993
|
-
function
|
|
9296
|
+
function Km(e) {
|
|
8994
9297
|
let t = e.split(/\r?\n/).map((e) => e.trim()).find((e) => e.length > 0);
|
|
8995
9298
|
if (t) return t.length > 160 ? `${t.slice(0, 157)}...` : t;
|
|
8996
9299
|
}
|
|
8997
|
-
function
|
|
9300
|
+
function qm(e) {
|
|
8998
9301
|
let t = /* @__PURE__ */ new Set();
|
|
8999
9302
|
for (let n of e.targets) t.add(n.provider);
|
|
9000
9303
|
for (let n of e.services) n.external || t.add(n.provider);
|
|
9001
9304
|
return [...t];
|
|
9002
9305
|
}
|
|
9003
|
-
function
|
|
9306
|
+
function Jm(e) {
|
|
9004
9307
|
return Object.entries(e).filter(([e, t]) => t.length >= 8 && !e.startsWith("VITE_") && !/^https?:\/\//.test(t)).map(([, e]) => e);
|
|
9005
9308
|
}
|
|
9006
|
-
function
|
|
9309
|
+
function Ym(e) {
|
|
9007
9310
|
let t = Object.keys(e);
|
|
9008
9311
|
return t.length === 0 ? void 0 : `set ${t.join(", ")}`;
|
|
9009
9312
|
}
|
|
9010
|
-
function
|
|
9313
|
+
function Xm(e) {
|
|
9011
9314
|
return e instanceof Error ? e.message : String(e);
|
|
9012
9315
|
}
|
|
9013
9316
|
//#endregion
|
|
9014
9317
|
//#region src/deploy/plan.ts
|
|
9015
|
-
function
|
|
9318
|
+
function Zm(e) {
|
|
9016
9319
|
let { projectRoot: t, config: n, assignment: r, stackConfig: i, serveModes: a = {}, staticDirs: o = {} } = e, s = [];
|
|
9017
|
-
for (let [e, c] of
|
|
9018
|
-
let r = n.targets[e], l =
|
|
9320
|
+
for (let [e, c] of $m(r)) {
|
|
9321
|
+
let r = n.targets[e], l = Cd[e];
|
|
9019
9322
|
s.push({
|
|
9020
9323
|
target: e,
|
|
9021
9324
|
spec: {
|
|
@@ -9024,22 +9327,22 @@ function Em(e) {
|
|
|
9024
9327
|
staticDir: o[e] ?? l.staticDir
|
|
9025
9328
|
},
|
|
9026
9329
|
provider: c,
|
|
9027
|
-
app: r?.app ??
|
|
9330
|
+
app: r?.app ?? jd(n.projectName, e, c),
|
|
9028
9331
|
region: r?.region,
|
|
9029
9332
|
url: r?.url,
|
|
9030
|
-
root:
|
|
9333
|
+
root: fm(t, e, i)
|
|
9031
9334
|
});
|
|
9032
9335
|
}
|
|
9033
9336
|
let c = [];
|
|
9034
|
-
if (r.targets.backend) for (let e of
|
|
9337
|
+
if (r.targets.backend) for (let e of xd) {
|
|
9035
9338
|
let t = r.services[e];
|
|
9036
9339
|
if (!t) continue;
|
|
9037
9340
|
let i = n.services[e];
|
|
9038
9341
|
c.push({
|
|
9039
9342
|
service: e,
|
|
9040
|
-
spec:
|
|
9343
|
+
spec: wd[e],
|
|
9041
9344
|
provider: t,
|
|
9042
|
-
name: i?.name ??
|
|
9345
|
+
name: i?.name ?? jd(n.projectName, e, t),
|
|
9043
9346
|
region: i?.region,
|
|
9044
9347
|
external: i?.external
|
|
9045
9348
|
});
|
|
@@ -9054,20 +9357,20 @@ function Em(e) {
|
|
|
9054
9357
|
railway: n.railway ?? {}
|
|
9055
9358
|
};
|
|
9056
9359
|
}
|
|
9057
|
-
var
|
|
9360
|
+
var Qm = [
|
|
9058
9361
|
"frontend",
|
|
9059
9362
|
"admin",
|
|
9060
9363
|
"backend"
|
|
9061
9364
|
];
|
|
9062
|
-
function
|
|
9365
|
+
function $m(e) {
|
|
9063
9366
|
let t = [];
|
|
9064
|
-
for (let n of
|
|
9367
|
+
for (let n of Qm) {
|
|
9065
9368
|
let r = e.targets[n];
|
|
9066
9369
|
r && t.push([n, r]);
|
|
9067
9370
|
}
|
|
9068
9371
|
return t;
|
|
9069
9372
|
}
|
|
9070
|
-
function
|
|
9373
|
+
function eh(e, t) {
|
|
9071
9374
|
let n = {
|
|
9072
9375
|
...e,
|
|
9073
9376
|
environment: t.environment,
|
|
@@ -9097,20 +9400,20 @@ function km(e, t) {
|
|
|
9097
9400
|
}
|
|
9098
9401
|
//#endregion
|
|
9099
9402
|
//#region src/deploy/project-env.ts
|
|
9100
|
-
async function
|
|
9403
|
+
async function th(e) {
|
|
9101
9404
|
return await G(e) ? C.readFile(e, "utf-8") : null;
|
|
9102
9405
|
}
|
|
9103
|
-
async function
|
|
9104
|
-
let n =
|
|
9105
|
-
let [t, r] = await Promise.all([
|
|
9406
|
+
async function nh(e, t) {
|
|
9407
|
+
let n = Rm(await th(T.join(e, ".env")) ?? ""), r = await Promise.all(t.map(async (e) => {
|
|
9408
|
+
let [t, r] = await Promise.all([th(T.join(e.root, ".env")), th(T.join(e.root, ".env.example"))]);
|
|
9106
9409
|
return {
|
|
9107
9410
|
target: e.target,
|
|
9108
9411
|
local: {
|
|
9109
9412
|
...n,
|
|
9110
|
-
...
|
|
9413
|
+
...Rm(t ?? "")
|
|
9111
9414
|
},
|
|
9112
|
-
declared:
|
|
9113
|
-
example:
|
|
9415
|
+
declared: Bm(r ?? ""),
|
|
9416
|
+
example: Rm(r ?? "")
|
|
9114
9417
|
};
|
|
9115
9418
|
})), i = {}, a = {}, o = {};
|
|
9116
9419
|
for (let e of r) i[e.target] = e.local, a[e.target] = e.declared, o[e.target] = e.example;
|
|
@@ -9122,23 +9425,23 @@ async function jm(e, t) {
|
|
|
9122
9425
|
}
|
|
9123
9426
|
//#endregion
|
|
9124
9427
|
//#region src/deploy/report.ts
|
|
9125
|
-
function
|
|
9428
|
+
function rh(e) {
|
|
9126
9429
|
let t = [];
|
|
9127
9430
|
t.push(`${F.label("Project")} ${F.highlight(e.projectName)}`), t.push(`${F.label("Env")} ${F.highlight(e.environment)}`), t.push(""), t.push(F.bold("Apps"));
|
|
9128
9431
|
for (let n of e.targets) {
|
|
9129
|
-
let e = F.accent(
|
|
9432
|
+
let e = F.accent(Od(n.provider)), r = F.muted(n.spec.serveMode === "static" ? "static bundle" : "node server"), i = n.url ? ` ${F.muted(n.url)}` : "";
|
|
9130
9433
|
t.push(` ${L.arrow} ${n.spec.label} ${F.muted("->")} ${e} ${F.muted(`(${n.app})`)} ${r}${i}`);
|
|
9131
9434
|
}
|
|
9132
9435
|
if (e.services.length > 0) {
|
|
9133
9436
|
t.push(""), t.push(F.bold("Services"));
|
|
9134
9437
|
for (let n of e.services) {
|
|
9135
|
-
let e = n.external ? F.muted("external (from stack.json)") : F.accent(
|
|
9438
|
+
let e = n.external ? F.muted("external (from stack.json)") : F.accent(Od(n.provider));
|
|
9136
9439
|
t.push(` ${L.arrow} ${n.spec.label} ${F.muted("->")} ${e} ${F.muted(`(${n.name})`)}`);
|
|
9137
9440
|
}
|
|
9138
9441
|
}
|
|
9139
9442
|
return t.join("\n");
|
|
9140
9443
|
}
|
|
9141
|
-
function
|
|
9444
|
+
function ih(e) {
|
|
9142
9445
|
let t = [];
|
|
9143
9446
|
for (let n of e) {
|
|
9144
9447
|
let e = Object.keys(n.managed).length, r = Object.keys(n.forwarded).length;
|
|
@@ -9148,19 +9451,19 @@ function Nm(e) {
|
|
|
9148
9451
|
}
|
|
9149
9452
|
return t.join("\n");
|
|
9150
9453
|
}
|
|
9151
|
-
function
|
|
9454
|
+
function ah(e) {
|
|
9152
9455
|
return e.steps.map((e) => {
|
|
9153
9456
|
let t = e.status === "ok" ? F.success("✓") : e.status === "skipped" ? F.warning("-") : F.error("✗"), n = e.detail ? ` ${F.muted(e.detail)}` : "";
|
|
9154
9457
|
return `${t} ${e.label}${n}`;
|
|
9155
9458
|
}).join("\n");
|
|
9156
9459
|
}
|
|
9157
|
-
function
|
|
9460
|
+
function oh(e) {
|
|
9158
9461
|
return e.plan.targets.map((t) => {
|
|
9159
9462
|
let n = e.urls[t.target];
|
|
9160
9463
|
return n ? `${F.label(t.spec.label)} ${I(n)}` : `${F.label(t.spec.label)} ${F.muted("no public URL")}`;
|
|
9161
9464
|
}).join("\n");
|
|
9162
9465
|
}
|
|
9163
|
-
function
|
|
9466
|
+
function sh(e) {
|
|
9164
9467
|
let t = [];
|
|
9165
9468
|
for (let n of e.envPlans) {
|
|
9166
9469
|
n.missing.length > 0 && t.push(`${Z(n.target)} is missing ${n.missing.join(", ")}. The app will boot only once those are set.`);
|
|
@@ -9172,44 +9475,44 @@ function Im(e) {
|
|
|
9172
9475
|
}
|
|
9173
9476
|
//#endregion
|
|
9174
9477
|
//#region src/commands/deploy.ts
|
|
9175
|
-
async function
|
|
9478
|
+
async function ch(e = {}) {
|
|
9176
9479
|
let t = T.resolve(e.cwd ?? process.cwd()), n = e.yes === !0;
|
|
9177
9480
|
ll(), c.intro(F.brandBold("Deploy your stack")), await Gi(t) || z(`${F.path(t)} doesn't look like a Hype Stack project. Run this from the project root.`, { reason: "not_a_project" }), await Bi(t) || z(`${F.path(t)} has no ${F.path(pe)}, so it is not a Hype Stack project this CLI can deploy. Run "hype-stack init" here first, or deploy a project made with "hype-stack create".`, { reason: "not_a_project" });
|
|
9178
|
-
let r = await q(t).catch(() => null), i = await
|
|
9179
|
-
i ||=
|
|
9481
|
+
let r = await q(t).catch(() => null), i = await lh(t);
|
|
9482
|
+
i ||= lm(_i(r?.name ?? T.basename(t))), e.environment && (i.environment = e.environment), e.flyOrg && (i.fly = {
|
|
9180
9483
|
...i.fly,
|
|
9181
9484
|
org: e.flyOrg
|
|
9182
9485
|
}), e.railwayWorkspace && (i.railway = {
|
|
9183
9486
|
...i.railway,
|
|
9184
9487
|
workspace: e.railwayWorkspace
|
|
9185
9488
|
});
|
|
9186
|
-
let a = await
|
|
9489
|
+
let a = await pm(t, r);
|
|
9187
9490
|
a.length === 0 && z("Found no deployable apps. Expected at least one of apps/backend, apps/frontend, or apps/admin.");
|
|
9188
|
-
let o = e.only ?? [], s =
|
|
9491
|
+
let o = e.only ?? [], s = dh(e.assign), l = uh(e.provider, "--provider"), u = Md({
|
|
9189
9492
|
config: i,
|
|
9190
9493
|
defaultProvider: l,
|
|
9191
9494
|
overrides: s,
|
|
9192
9495
|
availableTargets: a,
|
|
9193
9496
|
only: o
|
|
9194
|
-
}), d = await
|
|
9195
|
-
n || (u = await
|
|
9497
|
+
}), d = await gm(t, Nd(a, o), r);
|
|
9498
|
+
n || (u = await ph({
|
|
9196
9499
|
assignment: u,
|
|
9197
9500
|
availableTargets: a,
|
|
9198
9501
|
requestedTargets: o
|
|
9199
9502
|
}));
|
|
9200
|
-
let f =
|
|
9503
|
+
let f = Pd({
|
|
9201
9504
|
assignment: u,
|
|
9202
9505
|
availableTargets: a,
|
|
9203
9506
|
requestedTargets: o,
|
|
9204
9507
|
serveModes: d
|
|
9205
9508
|
});
|
|
9206
|
-
f.length > 0 && (R(
|
|
9207
|
-
let p =
|
|
9509
|
+
f.length > 0 && (R(Id(f), "Cannot deploy yet"), z("Fix the assignments above and run deploy again.", { reason: "input_required" }));
|
|
9510
|
+
let p = _m(d), m = await _h({
|
|
9208
9511
|
cwd: t,
|
|
9209
9512
|
targets: u.targets,
|
|
9210
9513
|
serveModes: p,
|
|
9211
9514
|
stackConfig: r
|
|
9212
|
-
}), h =
|
|
9515
|
+
}), h = Zm({
|
|
9213
9516
|
projectRoot: t,
|
|
9214
9517
|
config: i,
|
|
9215
9518
|
assignment: u,
|
|
@@ -9217,13 +9520,13 @@ async function Lm(e = {}) {
|
|
|
9217
9520
|
serveModes: p,
|
|
9218
9521
|
staticDirs: m
|
|
9219
9522
|
});
|
|
9220
|
-
R(
|
|
9523
|
+
R(rh(h), e.dryRun ? "Deployment plan (dry run)" : "Deployment plan");
|
|
9221
9524
|
let g = e.dryRun ? {
|
|
9222
9525
|
env: {},
|
|
9223
9526
|
accounts: {}
|
|
9224
|
-
} : await
|
|
9527
|
+
} : await Bp({
|
|
9225
9528
|
plan: h,
|
|
9226
|
-
providers:
|
|
9529
|
+
providers: qm(h),
|
|
9227
9530
|
skipPrompts: n
|
|
9228
9531
|
});
|
|
9229
9532
|
if (!n && !e.dryRun) {
|
|
@@ -9232,27 +9535,27 @@ async function Lm(e = {}) {
|
|
|
9232
9535
|
message: "Deploying creates billable infrastructure. Re-run with --yes to confirm non-interactively."
|
|
9233
9536
|
});
|
|
9234
9537
|
let e = await c.confirm({
|
|
9235
|
-
message: `Create and deploy this on ${
|
|
9538
|
+
message: `Create and deploy this on ${vh(h.targets.map((e) => e.provider))}?`,
|
|
9236
9539
|
initialValue: !0
|
|
9237
9540
|
});
|
|
9238
9541
|
(c.isCancel(e) || !e) && B();
|
|
9239
9542
|
}
|
|
9240
|
-
let _ = await
|
|
9241
|
-
R(
|
|
9543
|
+
let _ = await nh(t, h.targets);
|
|
9544
|
+
R(ih(Mm({
|
|
9242
9545
|
plan: h,
|
|
9243
9546
|
localEnv: _.local,
|
|
9244
9547
|
declaredKeys: _.declared,
|
|
9245
9548
|
exampleEnv: _.example
|
|
9246
|
-
})), "Environment"), await
|
|
9247
|
-
let v = St(), y = [], b = e.dryRun ?
|
|
9549
|
+
})), "Environment"), await gd(t).catch(() => null);
|
|
9550
|
+
let v = St(), y = [], b = e.dryRun ? gf({
|
|
9248
9551
|
onCommand: (e) => y.push(e),
|
|
9249
|
-
responses:
|
|
9250
|
-
}) :
|
|
9552
|
+
responses: Sm
|
|
9553
|
+
}) : hf({
|
|
9251
9554
|
onCommand: (e) => y.push(e),
|
|
9252
9555
|
env: g.env
|
|
9253
9556
|
});
|
|
9254
9557
|
v.start(e.dryRun ? "Walking the plan" : "Deploying");
|
|
9255
|
-
let x = await
|
|
9558
|
+
let x = await Wm({
|
|
9256
9559
|
plan: h,
|
|
9257
9560
|
runner: b,
|
|
9258
9561
|
localEnv: _.local,
|
|
@@ -9264,101 +9567,101 @@ async function Lm(e = {}) {
|
|
|
9264
9567
|
knownAccounts: g.accounts,
|
|
9265
9568
|
log: (e) => v.message(e)
|
|
9266
9569
|
});
|
|
9267
|
-
if (v.stop(x.ok ? F.success("Deploy finished") : F.error("Deploy stopped")), R(
|
|
9570
|
+
if (v.stop(x.ok ? F.success("Deploy finished") : F.error("Deploy stopped")), R(ah(x), "Steps"), e.dryRun) {
|
|
9268
9571
|
R(y.map((e) => F.command(e)).join("\n"), "Commands that would run"), c.outro(F.muted("Dry run only. No infrastructure was created."));
|
|
9269
9572
|
return;
|
|
9270
9573
|
}
|
|
9271
|
-
if (await
|
|
9272
|
-
let e = x.steps.
|
|
9273
|
-
R(`${e
|
|
9574
|
+
if (await cm(t, eh(i, x.plan)), !x.ok) {
|
|
9575
|
+
let e = x.steps.filter((e) => e.status === "failed");
|
|
9576
|
+
R(`${e.length > 0 ? e.map((e) => `${e.label} failed.${e.detail ? `\n${e.detail}` : ""}`).join("\n\n") : "A step failed."}\n\nWhat succeeded is saved in ${F.path(X)}, so re-running picks up from here.`, "Deploy failed"), z("Deploy did not finish.");
|
|
9274
9577
|
}
|
|
9275
|
-
R(
|
|
9276
|
-
let S =
|
|
9578
|
+
R(oh(x), "Live");
|
|
9579
|
+
let S = sh(x);
|
|
9277
9580
|
S.length > 0 && R(S.map((e) => `${F.warning("!")} ${e}`).join("\n\n"), "Still to do"), c.outro(F.brand("Shipped."));
|
|
9278
9581
|
}
|
|
9279
|
-
async function
|
|
9582
|
+
async function lh(e) {
|
|
9280
9583
|
try {
|
|
9281
|
-
return await
|
|
9584
|
+
return await sm(e);
|
|
9282
9585
|
} catch (e) {
|
|
9283
9586
|
z(e instanceof Error ? e.message : String(e));
|
|
9284
9587
|
}
|
|
9285
9588
|
}
|
|
9286
|
-
function
|
|
9287
|
-
if (e) return
|
|
9589
|
+
function uh(e, t) {
|
|
9590
|
+
if (e) return Dd(e) || z(`Unknown provider "${e}" for ${t}. Pick one of ${Object.keys(Td).join(", ")}.`), e;
|
|
9288
9591
|
}
|
|
9289
|
-
function
|
|
9592
|
+
function dh(e) {
|
|
9290
9593
|
let t = {};
|
|
9291
9594
|
for (let [n, r] of Object.entries(e ?? {})) {
|
|
9292
|
-
let e =
|
|
9595
|
+
let e = uh(r, `--${n}`);
|
|
9293
9596
|
e && (t[n] = e);
|
|
9294
9597
|
}
|
|
9295
9598
|
return t;
|
|
9296
9599
|
}
|
|
9297
|
-
function
|
|
9298
|
-
let { assignment: t, availableTargets: n, requestedTargets: r } = e, i =
|
|
9600
|
+
function fh(e) {
|
|
9601
|
+
let { assignment: t, availableTargets: n, requestedTargets: r } = e, i = Nd(n, r).filter((e) => !t.targets[e]);
|
|
9299
9602
|
return {
|
|
9300
9603
|
targets: i,
|
|
9301
|
-
services: t.targets.backend !== void 0 || i.includes("backend") ?
|
|
9604
|
+
services: t.targets.backend !== void 0 || i.includes("backend") ? xd.filter((e) => !t.services[e]) : []
|
|
9302
9605
|
};
|
|
9303
9606
|
}
|
|
9304
|
-
async function
|
|
9607
|
+
async function ph(e) {
|
|
9305
9608
|
let t = {
|
|
9306
9609
|
targets: { ...e.assignment.targets },
|
|
9307
9610
|
services: { ...e.assignment.services }
|
|
9308
|
-
}, { targets: n, services: r } =
|
|
9611
|
+
}, { targets: n, services: r } = fh(e);
|
|
9309
9612
|
if (n.length + r.length > 1) {
|
|
9310
|
-
let e = await
|
|
9613
|
+
let e = await mh();
|
|
9311
9614
|
if (e) {
|
|
9312
9615
|
for (let r of n) t.targets[r] = e;
|
|
9313
9616
|
for (let n of r) t.services[n] = e;
|
|
9314
9617
|
return t;
|
|
9315
9618
|
}
|
|
9316
9619
|
}
|
|
9317
|
-
for (let e of n) t.targets[e] = await
|
|
9318
|
-
for (let e of r) t.services[e] = await
|
|
9620
|
+
for (let e of n) t.targets[e] = await gh(e, kd(e));
|
|
9621
|
+
for (let e of r) t.services[e] = await gh(e, kd(e));
|
|
9319
9622
|
return t;
|
|
9320
9623
|
}
|
|
9321
|
-
async function
|
|
9624
|
+
async function mh() {
|
|
9322
9625
|
let e = await c.select({
|
|
9323
9626
|
message: `Where should ${F.highlight("your stack")} live?`,
|
|
9324
|
-
options: [...
|
|
9627
|
+
options: [...Sd.map((e) => ({
|
|
9325
9628
|
value: e,
|
|
9326
|
-
label:
|
|
9327
|
-
hint: `everything on ${
|
|
9629
|
+
label: Od(e),
|
|
9630
|
+
hint: `everything on ${Td[e].bin}`
|
|
9328
9631
|
})), {
|
|
9329
|
-
value:
|
|
9632
|
+
value: hh,
|
|
9330
9633
|
label: "Mix providers",
|
|
9331
9634
|
hint: "choose for each app and service"
|
|
9332
9635
|
}],
|
|
9333
|
-
initialValue:
|
|
9636
|
+
initialValue: Sd[0]
|
|
9334
9637
|
});
|
|
9335
|
-
return c.isCancel(e) && B(), e ===
|
|
9638
|
+
return c.isCancel(e) && B(), e === hh ? void 0 : e;
|
|
9336
9639
|
}
|
|
9337
|
-
var
|
|
9338
|
-
async function
|
|
9339
|
-
if (t.length === 0 && z(`Nothing in this CLI can host ${Z(e)}. Provision it yourself and add it to the "${
|
|
9640
|
+
var hh = "__mixed__";
|
|
9641
|
+
async function gh(e, t) {
|
|
9642
|
+
if (t.length === 0 && z(`Nothing in this CLI can host ${Z(e)}. Provision it yourself and add it to the "${_d}" block of ${X}.`), t.length === 1) return t[0];
|
|
9340
9643
|
let n = await c.select({
|
|
9341
9644
|
message: `Where should ${F.highlight(Z(e))} live?`,
|
|
9342
9645
|
options: t.map((e) => ({
|
|
9343
9646
|
value: e,
|
|
9344
|
-
label:
|
|
9345
|
-
hint:
|
|
9647
|
+
label: Od(e),
|
|
9648
|
+
hint: Td[e].bin
|
|
9346
9649
|
})),
|
|
9347
9650
|
initialValue: t[0]
|
|
9348
9651
|
});
|
|
9349
9652
|
return c.isCancel(n) && B(), n;
|
|
9350
9653
|
}
|
|
9351
|
-
async function
|
|
9352
|
-
let { cwd: t, targets: n, serveModes: r, stackConfig: i } = e, a = Object.keys(n).filter((e) =>
|
|
9654
|
+
async function _h(e) {
|
|
9655
|
+
let { cwd: t, targets: n, serveModes: r, stackConfig: i } = e, a = Object.keys(n).filter((e) => Ed(e) && r[e] === "static"), o = await Promise.all(a.map(async (e) => [e, await vm(fm(t, e, i), e)]));
|
|
9353
9656
|
return Object.fromEntries(o);
|
|
9354
9657
|
}
|
|
9355
|
-
function
|
|
9356
|
-
let t = [...new Set(e)].map(
|
|
9658
|
+
function vh(e) {
|
|
9659
|
+
let t = [...new Set(e)].map(Od);
|
|
9357
9660
|
return t.length <= 1 ? t[0] ?? "your provider" : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
|
|
9358
9661
|
}
|
|
9359
9662
|
//#endregion
|
|
9360
9663
|
//#region src/commands/login.ts
|
|
9361
|
-
async function
|
|
9664
|
+
async function yh() {
|
|
9362
9665
|
ul(), c.intro(F.brandBold("Log in to Hype Stack")), Ue() && c.log.warn(`${N} is set and takes priority over this login. Unset it to use the browser session.`), c.log.step("Opening your browser to sign in...");
|
|
9363
9666
|
let e;
|
|
9364
9667
|
try {
|
|
@@ -9372,7 +9675,7 @@ async function Jm() {
|
|
|
9372
9675
|
}
|
|
9373
9676
|
//#endregion
|
|
9374
9677
|
//#region src/commands/logout.ts
|
|
9375
|
-
async function
|
|
9678
|
+
async function bh() {
|
|
9376
9679
|
ul(), c.intro(F.brandBold("Log out of Hype Stack"));
|
|
9377
9680
|
let e = M(), t = await We(e);
|
|
9378
9681
|
if (!t) {
|
|
@@ -9383,8 +9686,8 @@ async function Ym() {
|
|
|
9383
9686
|
}
|
|
9384
9687
|
//#endregion
|
|
9385
9688
|
//#region src/commands/mcp.ts
|
|
9386
|
-
async function
|
|
9387
|
-
let t =
|
|
9689
|
+
async function xh(e = {}) {
|
|
9690
|
+
let t = Ch(e.editor), n = nu(t), r = wh(e.scope, t, n), i = Sh(e.token);
|
|
9388
9691
|
if (e.print) {
|
|
9389
9692
|
process.stdout.write(au(t, i));
|
|
9390
9693
|
return;
|
|
@@ -9398,19 +9701,19 @@ async function Xm(e = {}) {
|
|
|
9398
9701
|
});
|
|
9399
9702
|
a.changed ? c.log.success(`Wrote ${F.path(a.configPath)}`) : c.log.info(F.muted(`${F.path(a.configPath)} is already up to date.`)), i && c.log.warn(F.muted(`${N} is stored in plain text. Keep this file out of version control.`)), c.outro(F.muted("Restart your editor to pick up the server."));
|
|
9400
9703
|
}
|
|
9401
|
-
function
|
|
9704
|
+
function Sh(e) {
|
|
9402
9705
|
return e?.trim() || void 0;
|
|
9403
9706
|
}
|
|
9404
|
-
function
|
|
9707
|
+
function Ch(e) {
|
|
9405
9708
|
return e ? ($l(e) || z(`Unknown editor "${e}". Expected one of: ${Xl.join(", ")}.`), e) : "cursor";
|
|
9406
9709
|
}
|
|
9407
|
-
function
|
|
9710
|
+
function wh(e, t, n) {
|
|
9408
9711
|
let r = e ?? n[0];
|
|
9409
9712
|
return r !== "global" && r !== "project" && z(`Unknown scope "${r}". Expected global or project.`), n.includes(r) || z(`${t} does not support ${r} scope. Supported: ${n.join(", ")}.`), r;
|
|
9410
9713
|
}
|
|
9411
9714
|
//#endregion
|
|
9412
9715
|
//#region src/ui/env-prompt.ts
|
|
9413
|
-
var
|
|
9716
|
+
var Th = S("✔", "√"), Eh = S("✘", "x"), Dh = "\x1B[7m \x1B[27m", Oh = class extends ie {
|
|
9414
9717
|
constructor(e) {
|
|
9415
9718
|
super({
|
|
9416
9719
|
input: e.input,
|
|
@@ -9425,29 +9728,29 @@ var eh = S("✔", "√"), th = S("✘", "x"), nh = class extends ie {
|
|
|
9425
9728
|
let { key: e, section: t, linkUrl: n, hint: r, checklist: i, currentMasked: a, progress: o } = this.promptOptions, s = y.withGuide, c = s ? `${A("gray", l)}\n` : "";
|
|
9426
9729
|
if (this.state === "submit") {
|
|
9427
9730
|
let t = (this.value ?? "").trim(), n = t ? F.muted(ds(t)) : a ? F.muted(`kept ${a}`) : F.muted("left empty");
|
|
9428
|
-
return `${c}${A("green",
|
|
9731
|
+
return `${c}${A("green", Th)} ${F.bold(e)} ${n}`;
|
|
9429
9732
|
}
|
|
9430
|
-
if (this.state === "cancel") return `${c}${A("red",
|
|
9733
|
+
if (this.state === "cancel") return `${c}${A("red", Eh)} ${A(["strikethrough", "dim"], e)}`;
|
|
9431
9734
|
let d = x(this.state), f = s ? `${d} ` : "", p = b(this.state), m = o ? ` ${F.muted(o)}` : "", h = `${c}${p} ${F.bold(e)}${m}`, g = [];
|
|
9432
9735
|
if (t) {
|
|
9433
9736
|
let e = n ? ` ${I(n)}` : "";
|
|
9434
9737
|
g.push(`${f}${F.description(t)}${e}`);
|
|
9435
9738
|
}
|
|
9436
|
-
if (i && i.length > 0) for (let e of i) g.push(`${f}${L.bullet} ${F.
|
|
9437
|
-
r && g.push(`${f}${F.
|
|
9438
|
-
let _ = this.userInput
|
|
9439
|
-
g.push(
|
|
9440
|
-
let
|
|
9441
|
-
return `${h}\n${g.join("\n")}\n${
|
|
9739
|
+
if (i && i.length > 0) for (let e of i) g.push(`${f}${L.bullet} ${F.description(e)}`);
|
|
9740
|
+
r && g.push(`${f}${F.description(r)}`);
|
|
9741
|
+
let _ = this.userInput !== "", v = a ? `${a} (Enter keeps this)` : "type a value, or Enter to skip", S = _ ? `${f}${L.arrow} ${this.userInputWithCursor}` : `${f}${L.arrow} ${Dh} ${F.muted(v)}`;
|
|
9742
|
+
g.push(S), this.state === "error" && g.push(`${f}${A("yellow", this.error)}`);
|
|
9743
|
+
let C = s ? this.state === "error" ? A("yellow", u) : A("cyan", u) : "";
|
|
9744
|
+
return `${h}\n${g.join("\n")}\n${C}`;
|
|
9442
9745
|
}
|
|
9443
9746
|
};
|
|
9444
|
-
async function
|
|
9445
|
-
let t = await new
|
|
9747
|
+
async function kh(e) {
|
|
9748
|
+
let t = await new Oh(e).prompt();
|
|
9446
9749
|
return g(t) || typeof t == "string" ? t : "";
|
|
9447
9750
|
}
|
|
9448
9751
|
//#endregion
|
|
9449
9752
|
//#region src/commands/onboard.ts
|
|
9450
|
-
async function
|
|
9753
|
+
async function Ah(e = {}) {
|
|
9451
9754
|
let t = e.cwd ?? process.cwd();
|
|
9452
9755
|
e.skipBanner || ll(), c.intro(F.brandBold("Onboard your stack"));
|
|
9453
9756
|
let n;
|
|
@@ -9462,12 +9765,12 @@ async function ih(e = {}) {
|
|
|
9462
9765
|
for (let e of r) await ms(e);
|
|
9463
9766
|
let i = await gs(t, n);
|
|
9464
9767
|
i.length > 0 && c.log.success(`Generated ${F.highlight(String(i.length))} secrets: ${i.map((e) => e.key).join(", ")}`);
|
|
9465
|
-
let a = await
|
|
9466
|
-
e.yes ? u.push(...o, ...l.filter((e) => !e.isSet)) : (await
|
|
9768
|
+
let a = await jh(t, n, r), o = a.filter((e) => e.setup.setup === "required" && !e.isSet), s = a.filter((e) => e.setup.setup === "required" && e.isSet), l = a.filter((e) => e.setup.setup === "optional"), u = [];
|
|
9769
|
+
e.yes ? u.push(...o, ...l.filter((e) => !e.isSet)) : (u.push(...await Mh(o)), u.push(...await Nh(l)), await Ph(s)), zh(u, t);
|
|
9467
9770
|
let d = Ai(n.installedPacks ?? []);
|
|
9468
9771
|
d.length > 0 && R(d.map((e) => ` ${F.muted("·")} ${e}`).join("\n"), "Tips"), c.outro(F.brand(`All set. Run ${F.command("pnpm dev")} to start your app.`));
|
|
9469
9772
|
}
|
|
9470
|
-
async function
|
|
9773
|
+
async function jh(e, t, n) {
|
|
9471
9774
|
let r = t.onboarding?.envVars ?? [], i = t.onboarding?.envSections ?? [], a = [];
|
|
9472
9775
|
for (let e of n) {
|
|
9473
9776
|
let t = T.join(T.dirname(e), ".env"), [n, o] = await Promise.all([C.readFile(e, "utf-8"), ps(t)]);
|
|
@@ -9487,31 +9790,40 @@ async function ah(e, t, n) {
|
|
|
9487
9790
|
}
|
|
9488
9791
|
return a;
|
|
9489
9792
|
}
|
|
9490
|
-
async function
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9793
|
+
async function Mh(e) {
|
|
9794
|
+
let t = [], n = Fh(e);
|
|
9795
|
+
if (n.size === 0) return t;
|
|
9796
|
+
let r = [...n.entries()].map(([e, t]) => `${F.bold(e)} ${F.muted(`(${t.length})`)}`).join(", ");
|
|
9797
|
+
c.log.step(`Keys needed for: ${r}`);
|
|
9798
|
+
for (let [e, r] of n) {
|
|
9799
|
+
let n = `${r.length} value${r.length === 1 ? "" : "s"}`;
|
|
9800
|
+
if (!await Ih(`Set up ${F.bold(e)} now? ${F.muted(`(${n})`)}`, !0)) {
|
|
9801
|
+
t.push(...r);
|
|
9802
|
+
continue;
|
|
9803
|
+
}
|
|
9804
|
+
await Lh(r);
|
|
9494
9805
|
}
|
|
9806
|
+
return t;
|
|
9495
9807
|
}
|
|
9496
|
-
async function
|
|
9808
|
+
async function Nh(e) {
|
|
9497
9809
|
let t = [];
|
|
9498
|
-
for (let [n, r] of
|
|
9810
|
+
for (let [n, r] of Fh(e)) {
|
|
9499
9811
|
let e = r.every((e) => e.isSet), i = `${r.length} value${r.length === 1 ? "" : "s"}`;
|
|
9500
|
-
if (!await
|
|
9812
|
+
if (!await Ih(e ? `Update ${F.bold(n)}? ${F.muted(`(${i}, already set)`)}` : `Set up ${F.bold(n)} now? ${F.muted(`(${i}, optional)`)}`)) {
|
|
9501
9813
|
t.push(...r.filter((e) => !e.isSet));
|
|
9502
9814
|
continue;
|
|
9503
9815
|
}
|
|
9504
|
-
await
|
|
9816
|
+
await Lh(r);
|
|
9505
9817
|
}
|
|
9506
9818
|
return t;
|
|
9507
9819
|
}
|
|
9508
|
-
async function
|
|
9509
|
-
for (let [t, n] of
|
|
9820
|
+
async function Ph(e) {
|
|
9821
|
+
for (let [t, n] of Fh(e)) {
|
|
9510
9822
|
let e = `${n.length} value${n.length === 1 ? "" : "s"}`;
|
|
9511
|
-
await
|
|
9823
|
+
await Ih(`Update ${F.bold(t)}? ${F.muted(`(${e}, already set)`)}`) && await Lh(n);
|
|
9512
9824
|
}
|
|
9513
9825
|
}
|
|
9514
|
-
function
|
|
9826
|
+
function Fh(e) {
|
|
9515
9827
|
let t = /* @__PURE__ */ new Map();
|
|
9516
9828
|
for (let n of e) {
|
|
9517
9829
|
let e = n.setup.group ?? n.section, r = t.get(e);
|
|
@@ -9519,20 +9831,20 @@ function lh(e) {
|
|
|
9519
9831
|
}
|
|
9520
9832
|
return t;
|
|
9521
9833
|
}
|
|
9522
|
-
async function
|
|
9523
|
-
let
|
|
9834
|
+
async function Ih(e, t = !1) {
|
|
9835
|
+
let n = await c.confirm({
|
|
9524
9836
|
message: e,
|
|
9525
|
-
initialValue:
|
|
9837
|
+
initialValue: t
|
|
9526
9838
|
});
|
|
9527
|
-
return c.isCancel(
|
|
9839
|
+
return c.isCancel(n) && B(), n === !0;
|
|
9528
9840
|
}
|
|
9529
|
-
async function
|
|
9841
|
+
async function Lh(e) {
|
|
9530
9842
|
let t = Ti(e[0].section);
|
|
9531
9843
|
t.link && c.log.info(F.muted(t.link));
|
|
9532
|
-
for (let [t, n] of e.entries()) await
|
|
9844
|
+
for (let [t, n] of e.entries()) await Rh(n, `${t + 1}/${e.length}`);
|
|
9533
9845
|
}
|
|
9534
|
-
async function
|
|
9535
|
-
let n = Ti(e.section), r = await
|
|
9846
|
+
async function Rh(e, t) {
|
|
9847
|
+
let n = Ti(e.section), r = await kh({
|
|
9536
9848
|
key: e.key,
|
|
9537
9849
|
section: e.section,
|
|
9538
9850
|
linkUrl: n.link,
|
|
@@ -9545,7 +9857,7 @@ async function fh(e, t) {
|
|
|
9545
9857
|
let i = (typeof r == "string" ? r : "").trim();
|
|
9546
9858
|
i !== "" && await hs(e.envPath, e.key, i);
|
|
9547
9859
|
}
|
|
9548
|
-
function
|
|
9860
|
+
function zh(e, t) {
|
|
9549
9861
|
if (e.length === 0) return;
|
|
9550
9862
|
let n = /* @__PURE__ */ new Map();
|
|
9551
9863
|
for (let t of e) {
|
|
@@ -9565,16 +9877,16 @@ function ph(e, t) {
|
|
|
9565
9877
|
}
|
|
9566
9878
|
//#endregion
|
|
9567
9879
|
//#region src/core/templates.ts
|
|
9568
|
-
var
|
|
9880
|
+
var Bh = Vr.createRequest()({
|
|
9569
9881
|
endpoint: "/templates/list",
|
|
9570
9882
|
method: "GET"
|
|
9571
9883
|
});
|
|
9572
|
-
async function
|
|
9573
|
-
let { data: e, error: t } = await
|
|
9884
|
+
async function Vh() {
|
|
9885
|
+
let { data: e, error: t } = await Bh.send();
|
|
9574
9886
|
if (t || !e) throw Error(`Failed to fetch template list: ${String(t)}`);
|
|
9575
9887
|
return e.templates;
|
|
9576
9888
|
}
|
|
9577
|
-
async function
|
|
9889
|
+
async function Hh(e) {
|
|
9578
9890
|
let { data: t, error: n, status: r } = await Vr.createRequest()({
|
|
9579
9891
|
endpoint: `/templates/${encodeURIComponent(e)}/manifest`,
|
|
9580
9892
|
method: "GET"
|
|
@@ -9583,7 +9895,7 @@ async function gh(e) {
|
|
|
9583
9895
|
if (n || !t) throw Error(`Failed to load manifest for template "${e}": ${String(n)}`);
|
|
9584
9896
|
return t;
|
|
9585
9897
|
}
|
|
9586
|
-
async function
|
|
9898
|
+
async function Uh(e, t = {}) {
|
|
9587
9899
|
let n = Vr.createRequest()({
|
|
9588
9900
|
endpoint: `/templates/${encodeURIComponent(e)}/download`,
|
|
9589
9901
|
method: "POST"
|
|
@@ -9619,7 +9931,7 @@ async function _h(e, t = {}) {
|
|
|
9619
9931
|
}
|
|
9620
9932
|
//#endregion
|
|
9621
9933
|
//#region src/commands/template.ts
|
|
9622
|
-
async function
|
|
9934
|
+
async function Wh(t = {}) {
|
|
9623
9935
|
let n = t.cwd ?? process.cwd();
|
|
9624
9936
|
ll(), await Gc();
|
|
9625
9937
|
let r = c.spinner();
|
|
@@ -9633,7 +9945,7 @@ async function vh(t = {}) {
|
|
|
9633
9945
|
r.stop("Packs loaded"), r.start("Loading templates...");
|
|
9634
9946
|
let a;
|
|
9635
9947
|
try {
|
|
9636
|
-
a = await
|
|
9948
|
+
a = await Vh();
|
|
9637
9949
|
} catch (e) {
|
|
9638
9950
|
r.stop("Failed to load templates"), z(`Could not reach Hype Stack. Check your connection and try again.\n${ju(e)}`);
|
|
9639
9951
|
}
|
|
@@ -9656,7 +9968,7 @@ async function vh(t = {}) {
|
|
|
9656
9968
|
s || (r.stop("Template not found"), z(`Template "${o}" not found. Available: ${a.map((e) => e.id).join(", ") || "(none)"}`)), r.stop(`Template: ${s.name}`);
|
|
9657
9969
|
let l;
|
|
9658
9970
|
try {
|
|
9659
|
-
l = await
|
|
9971
|
+
l = await Hh(s.id);
|
|
9660
9972
|
} catch (e) {
|
|
9661
9973
|
z(ju(e));
|
|
9662
9974
|
}
|
|
@@ -9678,7 +9990,7 @@ async function vh(t = {}) {
|
|
|
9678
9990
|
p || z(d ? `Could not read ${F.path("stack.json")}. Run 'npx @hype-stack/cli init' to regenerate it, then run 'npx @hype-stack/cli template' again.` : `No ${F.path("stack.json")}. Run 'npx @hype-stack/cli init' first, then 'npx @hype-stack/cli template'.`), p.paths || z(`${F.path("stack.json")} is missing ${F.path("paths")}. Run 'npx @hype-stack/cli init' again to regenerate it.`);
|
|
9679
9991
|
let m = d ?? n;
|
|
9680
9992
|
c.intro(F.brandBold("Install a template"));
|
|
9681
|
-
let h = p.installedPacks ?? [], g = new Set(h), v = new Map(i.map((e) => [e.name, e])), y = (await He(M()))?.token ?? null, b = await
|
|
9993
|
+
let h = p.installedPacks ?? [], g = new Set(h), v = new Map(i.map((e) => [e.name, e])), y = (await He(M()))?.token ?? null, b = await Gh(s, t.variants, t.yes ?? !1), x = Xc(s.slots, b), S = Zc(s.slots, s.packs, x), w = await Kh({
|
|
9682
9994
|
packs: i,
|
|
9683
9995
|
templatePacks: S,
|
|
9684
9996
|
installedSet: g,
|
|
@@ -9753,7 +10065,7 @@ async function vh(t = {}) {
|
|
|
9753
10065
|
r.stop("Files installed"), n.installed.length > 0 && c.log.success(`${F.highlight(String(n.installed.length))} files installed`), n.skipped.length > 0 && (c.log.warning(`${n.skipped.length} files skipped (use --force to overwrite)`), Bu(n.skipped));
|
|
9754
10066
|
for (let e of n.errors) c.log.error(e);
|
|
9755
10067
|
r.start("Applying template overrides...");
|
|
9756
|
-
let i = await
|
|
10068
|
+
let i = await Uh(s.id, { token: y });
|
|
9757
10069
|
i.status === "denied" && (r.stop("Template download denied"), z(Iu(s.id, i.reason))), oe = i.templateDir;
|
|
9758
10070
|
let a = await _c({
|
|
9759
10071
|
manifest: l,
|
|
@@ -9784,7 +10096,7 @@ async function vh(t = {}) {
|
|
|
9784
10096
|
customization: n
|
|
9785
10097
|
}), c.log.success(`Applied the ${Xs(n.theme)} theme, ${e(n.radius)} corners, and ${n.mode} mode`);
|
|
9786
10098
|
}
|
|
9787
|
-
await
|
|
10099
|
+
await qh({
|
|
9788
10100
|
prepared: ie,
|
|
9789
10101
|
templateNpm: l.dependencies_npm,
|
|
9790
10102
|
paths: p.paths,
|
|
@@ -9811,7 +10123,7 @@ async function vh(t = {}) {
|
|
|
9811
10123
|
});
|
|
9812
10124
|
}
|
|
9813
10125
|
}
|
|
9814
|
-
async function
|
|
10126
|
+
async function Gh(e, t, n) {
|
|
9815
10127
|
let r = {};
|
|
9816
10128
|
for (let i of e.slots) {
|
|
9817
10129
|
if (t?.[i.family]) {
|
|
@@ -9835,7 +10147,7 @@ async function yh(e, t, n) {
|
|
|
9835
10147
|
}
|
|
9836
10148
|
return r;
|
|
9837
10149
|
}
|
|
9838
|
-
async function
|
|
10150
|
+
async function Kh(e) {
|
|
9839
10151
|
let { packs: t, templatePacks: n, installedSet: r, options: i } = e, a = new Set(n);
|
|
9840
10152
|
if (i.packs && i.packs.length > 0) {
|
|
9841
10153
|
let e = i.packs.filter((e) => !t.some((t) => t.name === e));
|
|
@@ -9857,7 +10169,7 @@ async function bh(e) {
|
|
|
9857
10169
|
});
|
|
9858
10170
|
return _(c) && z("Cancelled.", { code: 0 }), c;
|
|
9859
10171
|
}
|
|
9860
|
-
async function
|
|
10172
|
+
async function qh(e) {
|
|
9861
10173
|
let { prepared: t, templateNpm: n, paths: r, cwd: i, spinner: a } = e, o = ku(t.map((e) => e.manifest.dependencies_npm)), s = Ou(n ? ku([o, n]) : o, r);
|
|
9862
10174
|
if (s.errors.length > 0) {
|
|
9863
10175
|
for (let e of s.errors) c.log.error(e);
|
|
@@ -9870,9 +10182,9 @@ async function xh(e) {
|
|
|
9870
10182
|
}
|
|
9871
10183
|
//#endregion
|
|
9872
10184
|
//#region src/mcp/guard.ts
|
|
9873
|
-
var
|
|
9874
|
-
function
|
|
9875
|
-
if (
|
|
10185
|
+
var Jh = null;
|
|
10186
|
+
function Yh() {
|
|
10187
|
+
if (Jh) return Jh.protocolStream;
|
|
9876
10188
|
let e = process.stdout.write.bind(process.stdout), t = process.stdout.write, n = console.log, r = console.info, i = console.debug, a = console.dir, o = new ue({
|
|
9877
10189
|
write(t, n, r) {
|
|
9878
10190
|
e(t, (e) => r(e ?? null));
|
|
@@ -9881,7 +10193,7 @@ function Ch() {
|
|
|
9881
10193
|
e();
|
|
9882
10194
|
}
|
|
9883
10195
|
}), s = ((e, t, n) => typeof t == "function" ? process.stderr.write(e, t) : process.stderr.write(e, t, n));
|
|
9884
|
-
return process.stdout.write = s, console.log = console.error, console.info = console.error, console.debug = console.error, console.dir = console.error,
|
|
10196
|
+
return process.stdout.write = s, console.log = console.error, console.info = console.error, console.debug = console.error, console.dir = console.error, Jh = {
|
|
9885
10197
|
protocolStream: o,
|
|
9886
10198
|
restore: () => {
|
|
9887
10199
|
process.stdout.write = t, console.log = n, console.info = r, console.debug = i, console.dir = a;
|
|
@@ -9890,22 +10202,22 @@ function Ch() {
|
|
|
9890
10202
|
}
|
|
9891
10203
|
//#endregion
|
|
9892
10204
|
//#region src/mcp/result.ts
|
|
9893
|
-
async function
|
|
10205
|
+
async function Xh(e) {
|
|
9894
10206
|
$e();
|
|
9895
10207
|
try {
|
|
9896
|
-
return
|
|
10208
|
+
return Zh({
|
|
9897
10209
|
...await e(),
|
|
9898
10210
|
ok: !0,
|
|
9899
10211
|
logs: et()
|
|
9900
10212
|
}, !1);
|
|
9901
10213
|
} catch (e) {
|
|
9902
|
-
return nt(e) ?
|
|
10214
|
+
return nt(e) ? Zh({
|
|
9903
10215
|
ok: !1,
|
|
9904
10216
|
reason: e.reason,
|
|
9905
10217
|
message: e.message,
|
|
9906
10218
|
details: e.details,
|
|
9907
10219
|
logs: et()
|
|
9908
|
-
}, !1) :
|
|
10220
|
+
}, !1) : Zh({
|
|
9909
10221
|
ok: !1,
|
|
9910
10222
|
reason: "failed",
|
|
9911
10223
|
message: e instanceof Error ? e.message : String(e),
|
|
@@ -9914,7 +10226,7 @@ async function wh(e) {
|
|
|
9914
10226
|
}, !0);
|
|
9915
10227
|
}
|
|
9916
10228
|
}
|
|
9917
|
-
function
|
|
10229
|
+
function Zh(e, t) {
|
|
9918
10230
|
return {
|
|
9919
10231
|
content: [{
|
|
9920
10232
|
type: "text",
|
|
@@ -9926,7 +10238,7 @@ function Th(e, t) {
|
|
|
9926
10238
|
}
|
|
9927
10239
|
//#endregion
|
|
9928
10240
|
//#region src/mcp/tools/context.ts
|
|
9929
|
-
async function
|
|
10241
|
+
async function Qh() {
|
|
9930
10242
|
let e = await He(M());
|
|
9931
10243
|
return e ? {
|
|
9932
10244
|
token: e.token,
|
|
@@ -9936,26 +10248,26 @@ async function Eh() {
|
|
|
9936
10248
|
source: "none"
|
|
9937
10249
|
};
|
|
9938
10250
|
}
|
|
9939
|
-
function
|
|
10251
|
+
function $h(e) {
|
|
9940
10252
|
return T.resolve(e ?? process.cwd());
|
|
9941
10253
|
}
|
|
9942
|
-
var
|
|
10254
|
+
var eg = {
|
|
9943
10255
|
envVar: N,
|
|
9944
10256
|
loginCommand: "npx @hype-stack/cli login"
|
|
9945
|
-
},
|
|
10257
|
+
}, tg = {
|
|
9946
10258
|
packs: j.array(j.string()).min(1).describe("Pack names to install. Append @frontend or @admin to a layout pack to target one shell."),
|
|
9947
10259
|
cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in."),
|
|
9948
10260
|
onConflict: j.enum(["keep", "overwrite"]).default("keep").describe("What to do with files that already exist: keep them, or let the pack overwrite them")
|
|
9949
10261
|
};
|
|
9950
|
-
async function
|
|
9951
|
-
let t =
|
|
10262
|
+
async function ng(e) {
|
|
10263
|
+
let t = $h(e.cwd), n = await rg(t);
|
|
9952
10264
|
await Gu({
|
|
9953
10265
|
cwd: t,
|
|
9954
10266
|
packs: e.packs,
|
|
9955
10267
|
force: e.onConflict === "overwrite",
|
|
9956
10268
|
yes: !0
|
|
9957
10269
|
});
|
|
9958
|
-
let r = await
|
|
10270
|
+
let r = await rg(t), i = r.filter((e) => !n.includes(e));
|
|
9959
10271
|
return {
|
|
9960
10272
|
cwd: t,
|
|
9961
10273
|
installed: i,
|
|
@@ -9963,21 +10275,21 @@ async function Ah(e) {
|
|
|
9963
10275
|
followUp: i.length > 0 ? [...Ec, "npx @hype-stack/cli onboard"] : []
|
|
9964
10276
|
};
|
|
9965
10277
|
}
|
|
9966
|
-
async function
|
|
10278
|
+
async function rg(e) {
|
|
9967
10279
|
return (await q(e).catch(() => null))?.installedPacks ?? [];
|
|
9968
10280
|
}
|
|
9969
10281
|
//#endregion
|
|
9970
10282
|
//#region src/mcp/tools/apply-template.ts
|
|
9971
|
-
var
|
|
10283
|
+
var ig = {
|
|
9972
10284
|
templateId: j.string().min(1).describe("Template id, e.g. vault. Use search_catalog to find one."),
|
|
9973
10285
|
cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in."),
|
|
9974
10286
|
variants: j.record(j.string(), j.string()).optional().describe("Slot overrides keyed by family, e.g. { \"starter-saas\": \"starter-saas-better-auth\" }"),
|
|
9975
10287
|
packs: j.array(j.string()).optional().describe("Extra packs to install on top of the template"),
|
|
9976
10288
|
onConflict: j.enum(["keep", "overwrite"]).default("keep").describe("What to do with files that already exist: keep them, or let the template overwrite them")
|
|
9977
10289
|
};
|
|
9978
|
-
async function
|
|
9979
|
-
let t =
|
|
9980
|
-
await
|
|
10290
|
+
async function ag(e) {
|
|
10291
|
+
let t = $h(e.cwd), n = await og(t);
|
|
10292
|
+
await Wh({
|
|
9981
10293
|
cwd: t,
|
|
9982
10294
|
templateId: e.templateId,
|
|
9983
10295
|
variants: e.variants,
|
|
@@ -9985,7 +10297,7 @@ async function Nh(e) {
|
|
|
9985
10297
|
force: e.onConflict === "overwrite",
|
|
9986
10298
|
yes: !0
|
|
9987
10299
|
});
|
|
9988
|
-
let r = await
|
|
10300
|
+
let r = await og(t);
|
|
9989
10301
|
return {
|
|
9990
10302
|
cwd: t,
|
|
9991
10303
|
templateId: e.templateId,
|
|
@@ -9994,21 +10306,21 @@ async function Nh(e) {
|
|
|
9994
10306
|
followUp: [...Ec, "npx @hype-stack/cli onboard"]
|
|
9995
10307
|
};
|
|
9996
10308
|
}
|
|
9997
|
-
async function
|
|
10309
|
+
async function og(e) {
|
|
9998
10310
|
return (await q(e).catch(() => null))?.installedPacks ?? [];
|
|
9999
10311
|
}
|
|
10000
10312
|
//#endregion
|
|
10001
10313
|
//#region src/mcp/tools/auth-status.ts
|
|
10002
|
-
var
|
|
10003
|
-
async function
|
|
10004
|
-
let { token: e, source: t } = await
|
|
10314
|
+
var sg = {};
|
|
10315
|
+
async function cg() {
|
|
10316
|
+
let { token: e, source: t } = await Qh();
|
|
10005
10317
|
if (!e) return {
|
|
10006
10318
|
authenticated: !1,
|
|
10007
10319
|
tokenSource: "none",
|
|
10008
10320
|
apiUrl: M(),
|
|
10009
|
-
hint: `Run '${
|
|
10321
|
+
hint: `Run '${eg.loginCommand}' in your terminal, or add ${eg.envVar} to this server's env block in your editor's MCP config.`,
|
|
10010
10322
|
apiKeysUrl: `${Me()}/api-keys`,
|
|
10011
|
-
...
|
|
10323
|
+
...eg
|
|
10012
10324
|
};
|
|
10013
10325
|
let n = await Hr(e);
|
|
10014
10326
|
return n ? {
|
|
@@ -10021,14 +10333,14 @@ async function Ih() {
|
|
|
10021
10333
|
authenticated: !1,
|
|
10022
10334
|
tokenSource: t,
|
|
10023
10335
|
apiUrl: M(),
|
|
10024
|
-
hint: t === "env" ? `The token in ${
|
|
10336
|
+
hint: t === "env" ? `The token in ${eg.envVar} was rejected. It may be expired or revoked; mint a new one.` : `Your saved login was rejected. Run '${eg.loginCommand}' again.`,
|
|
10025
10337
|
apiKeysUrl: `${Me()}/api-keys`,
|
|
10026
|
-
...
|
|
10338
|
+
...eg
|
|
10027
10339
|
};
|
|
10028
10340
|
}
|
|
10029
10341
|
//#endregion
|
|
10030
10342
|
//#region src/mcp/tools/create-application.ts
|
|
10031
|
-
var
|
|
10343
|
+
var lg = {
|
|
10032
10344
|
name: j.string().min(1).describe("Application name. Becomes the folder name and the package scope."),
|
|
10033
10345
|
directory: j.string().optional().describe("Parent folder to create the app inside. Defaults to the current workspace."),
|
|
10034
10346
|
editors: j.array(j.enum(be)).optional().describe("AI editors to ship rule formats for. Pass every editor the team uses, they coexist. Defaults to cursor."),
|
|
@@ -10039,8 +10351,8 @@ var Lh = {
|
|
|
10039
10351
|
adminRadius: j.string().optional().describe("Admin corner radius. Defaults to the frontend radius."),
|
|
10040
10352
|
mode: j.enum(["light", "dark"]).optional().describe("Color mode the app boots in")
|
|
10041
10353
|
};
|
|
10042
|
-
async function
|
|
10043
|
-
let t =
|
|
10354
|
+
async function ug(e) {
|
|
10355
|
+
let t = $h(e.directory), n = dg(e), r = await Hu({
|
|
10044
10356
|
name: e.name,
|
|
10045
10357
|
parentDirectory: t,
|
|
10046
10358
|
editors: n,
|
|
@@ -10056,19 +10368,19 @@ async function Rh(e) {
|
|
|
10056
10368
|
return {
|
|
10057
10369
|
projectRoot: r,
|
|
10058
10370
|
editors: n,
|
|
10059
|
-
mcpConfigPaths:
|
|
10371
|
+
mcpConfigPaths: fg(n, r),
|
|
10060
10372
|
followUp: [`cd ${r}`, ...Ec]
|
|
10061
10373
|
};
|
|
10062
10374
|
}
|
|
10063
|
-
function
|
|
10375
|
+
function dg(e) {
|
|
10064
10376
|
let { editors: t, unknown: n } = we([...e.editors ?? [], ...e.editor ? [e.editor] : []]);
|
|
10065
10377
|
if (n.length > 0) throw Error(`Unknown editor "${n.join(", ")}". Expected one of: ${be.join(", ")}.`);
|
|
10066
10378
|
return t.length > 0 ? t : [xe];
|
|
10067
10379
|
}
|
|
10068
|
-
function
|
|
10069
|
-
return tu(e).map((e) =>
|
|
10380
|
+
function fg(e, t) {
|
|
10381
|
+
return tu(e).map((e) => pg(e, t)).filter((e) => e !== null);
|
|
10070
10382
|
}
|
|
10071
|
-
function
|
|
10383
|
+
function pg(e, t) {
|
|
10072
10384
|
try {
|
|
10073
10385
|
return ru({
|
|
10074
10386
|
editor: e,
|
|
@@ -10081,8 +10393,8 @@ function Vh(e, t) {
|
|
|
10081
10393
|
}
|
|
10082
10394
|
//#endregion
|
|
10083
10395
|
//#region src/core/env-status.ts
|
|
10084
|
-
async function
|
|
10085
|
-
let n = t?.onboarding?.envSections ?? [], r = t?.onboarding?.envVars ?? [], i = await cs(e), a = await Promise.all(i.map((t) =>
|
|
10396
|
+
async function mg(e, t) {
|
|
10397
|
+
let n = t?.onboarding?.envSections ?? [], r = t?.onboarding?.envVars ?? [], i = await cs(e), a = await Promise.all(i.map((t) => hg({
|
|
10086
10398
|
examplePath: t,
|
|
10087
10399
|
projectRoot: e,
|
|
10088
10400
|
installedEnvSections: n,
|
|
@@ -10093,7 +10405,7 @@ async function Hh(e, t) {
|
|
|
10093
10405
|
missingCount: a.reduce((e, t) => e + t.sections.filter((e) => e.relevant).reduce((e, t) => e + t.vars.filter((e) => e.setup === "required" && e.state !== "filled").length, 0), 0)
|
|
10094
10406
|
};
|
|
10095
10407
|
}
|
|
10096
|
-
async function
|
|
10408
|
+
async function hg(e) {
|
|
10097
10409
|
let { examplePath: t, projectRoot: n, installedEnvSections: r, recorded: i } = e, a = T.join(T.dirname(t), ".env"), o = await C.readFile(t, "utf-8"), s = await ps(a), c = ls(o).map((e) => {
|
|
10098
10410
|
let t = Ti(e.section);
|
|
10099
10411
|
return {
|
|
@@ -10104,7 +10416,7 @@ async function Uh(e) {
|
|
|
10104
10416
|
let t = Li(e.key, i, r);
|
|
10105
10417
|
return {
|
|
10106
10418
|
key: e.key,
|
|
10107
|
-
state:
|
|
10419
|
+
state: gg(us(s, e.key), e.value),
|
|
10108
10420
|
setup: t?.setup ?? null,
|
|
10109
10421
|
...t?.group ? { group: t.group } : {}
|
|
10110
10422
|
};
|
|
@@ -10118,20 +10430,20 @@ async function Uh(e) {
|
|
|
10118
10430
|
sections: c
|
|
10119
10431
|
};
|
|
10120
10432
|
}
|
|
10121
|
-
function
|
|
10433
|
+
function gg(e, t) {
|
|
10122
10434
|
return e === "" ? "missing" : e === t.trim() ? "default" : "filled";
|
|
10123
10435
|
}
|
|
10124
10436
|
//#endregion
|
|
10125
10437
|
//#region src/mcp/tools/env-status.ts
|
|
10126
|
-
var
|
|
10127
|
-
async function
|
|
10128
|
-
let t =
|
|
10438
|
+
var _g = { cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
|
|
10439
|
+
async function vg(e) {
|
|
10440
|
+
let t = $h(e.cwd), n = await q(t).catch(() => null);
|
|
10129
10441
|
if (!n) throw new tt({
|
|
10130
10442
|
reason: "not_a_project",
|
|
10131
10443
|
message: `${t} has no stack.json, so there is nothing to check.`,
|
|
10132
10444
|
details: { cwd: t }
|
|
10133
10445
|
});
|
|
10134
|
-
let r = await
|
|
10446
|
+
let r = await mg(t, n);
|
|
10135
10447
|
return {
|
|
10136
10448
|
cwd: t,
|
|
10137
10449
|
missingCount: r.missingCount,
|
|
@@ -10141,9 +10453,9 @@ async function Kh(e) {
|
|
|
10141
10453
|
}
|
|
10142
10454
|
//#endregion
|
|
10143
10455
|
//#region src/mcp/tools/inspect-stack.ts
|
|
10144
|
-
var
|
|
10145
|
-
async function
|
|
10146
|
-
let t =
|
|
10456
|
+
var yg = { cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in.") };
|
|
10457
|
+
async function bg(e) {
|
|
10458
|
+
let t = $h(e.cwd), n = await q(t).catch(() => null);
|
|
10147
10459
|
if (!n) throw new tt({
|
|
10148
10460
|
reason: "not_a_project",
|
|
10149
10461
|
message: await Gi(t) ? `${t} is a Hype Stack project but has no stack.json. Run 'npx @hype-stack/cli init' in it.` : `${t} is not a Hype Stack project.`,
|
|
@@ -10170,12 +10482,12 @@ async function Jh(e) {
|
|
|
10170
10482
|
}
|
|
10171
10483
|
//#endregion
|
|
10172
10484
|
//#region src/mcp/tools/plan-install.ts
|
|
10173
|
-
var
|
|
10485
|
+
var xg = {
|
|
10174
10486
|
packs: j.array(j.string()).min(1).describe("Pack names to plan an install for"),
|
|
10175
10487
|
cwd: j.string().optional().describe("Project directory. Defaults to the workspace the server was started in.")
|
|
10176
10488
|
};
|
|
10177
|
-
async function
|
|
10178
|
-
let t =
|
|
10489
|
+
async function Sg(e) {
|
|
10490
|
+
let t = $h(e.cwd), { token: n, source: r } = await Qh(), i = await q(t).catch(() => null), a = i?.installedPacks ?? [], o = await Zi(), s = new Map(o.map((e) => [e.name, e])), c = e.packs.filter((e) => !s.has(e));
|
|
10179
10491
|
if (c.length > 0) throw Error(`Unknown pack${c.length === 1 ? "" : "s"}: ${c.join(", ")}`);
|
|
10180
10492
|
let l = Kc(o), u = Jc(e.packs, l, a), d = await Mu(u.order.map((e) => s.get(e)).filter((e) => e !== void 0), new Set(a), { token: n }), f = (e) => {
|
|
10181
10493
|
let t = s.get(e);
|
|
@@ -10204,12 +10516,12 @@ async function Xh(e) {
|
|
|
10204
10516
|
purchaseUrl: n ? Ct(e) : null
|
|
10205
10517
|
};
|
|
10206
10518
|
}),
|
|
10207
|
-
...n === null ? { authHint:
|
|
10519
|
+
...n === null ? { authHint: eg } : {}
|
|
10208
10520
|
};
|
|
10209
10521
|
}
|
|
10210
10522
|
//#endregion
|
|
10211
10523
|
//#region src/mcp/tools/search-catalog.ts
|
|
10212
|
-
var
|
|
10524
|
+
var Cg = {
|
|
10213
10525
|
query: j.string().optional().describe("Free text matched against name, display name, and description"),
|
|
10214
10526
|
kind: j.enum([
|
|
10215
10527
|
"pack",
|
|
@@ -10222,31 +10534,31 @@ var Zh = {
|
|
|
10222
10534
|
"paid",
|
|
10223
10535
|
"all"
|
|
10224
10536
|
]).default("all").describe("Restrict packs by price tier")
|
|
10225
|
-
},
|
|
10537
|
+
}, wg = (e, t) => {
|
|
10226
10538
|
let n = t.trim().toLowerCase();
|
|
10227
10539
|
return n === "" ? !0 : e.some((e) => e.toLowerCase().includes(n));
|
|
10228
10540
|
};
|
|
10229
|
-
function
|
|
10541
|
+
function Tg(e, t) {
|
|
10230
10542
|
let { query: n = "", category: r, tier: i = "all" } = t;
|
|
10231
|
-
return e.filter((e) => r && e.category !== r || i !== "all" && e.tier !== i ? !1 :
|
|
10543
|
+
return e.filter((e) => r && e.category !== r || i !== "all" && e.tier !== i ? !1 : wg([
|
|
10232
10544
|
e.name,
|
|
10233
10545
|
e.displayName,
|
|
10234
10546
|
e.description
|
|
10235
10547
|
], n));
|
|
10236
10548
|
}
|
|
10237
|
-
function
|
|
10549
|
+
function Eg(e, t) {
|
|
10238
10550
|
let { query: n = "", category: r } = t;
|
|
10239
|
-
return e.filter((e) => r && e.category !== r ? !1 :
|
|
10551
|
+
return e.filter((e) => r && e.category !== r ? !1 : wg([
|
|
10240
10552
|
e.id,
|
|
10241
10553
|
e.name,
|
|
10242
10554
|
e.description,
|
|
10243
10555
|
...e.tags
|
|
10244
10556
|
], n));
|
|
10245
10557
|
}
|
|
10246
|
-
async function
|
|
10247
|
-
let t = e.kind ?? "all", [n, r] = await Promise.all([t === "template" ? Promise.resolve([]) : Zi(), t === "pack" ? Promise.resolve([]) :
|
|
10558
|
+
async function Dg(e) {
|
|
10559
|
+
let t = e.kind ?? "all", [n, r] = await Promise.all([t === "template" ? Promise.resolve([]) : Zi(), t === "pack" ? Promise.resolve([]) : Vh()]);
|
|
10248
10560
|
return {
|
|
10249
|
-
packs:
|
|
10561
|
+
packs: Tg(n, e).map((e) => ({
|
|
10250
10562
|
name: e.name,
|
|
10251
10563
|
displayName: e.displayName,
|
|
10252
10564
|
description: e.description,
|
|
@@ -10255,7 +10567,7 @@ async function tg(e) {
|
|
|
10255
10567
|
price: e.price,
|
|
10256
10568
|
dependencies: e.dependencies
|
|
10257
10569
|
})),
|
|
10258
|
-
templates:
|
|
10570
|
+
templates: Eg(r, e).map((e) => ({
|
|
10259
10571
|
id: e.id,
|
|
10260
10572
|
name: e.name,
|
|
10261
10573
|
description: e.description,
|
|
@@ -10272,117 +10584,117 @@ async function tg(e) {
|
|
|
10272
10584
|
}
|
|
10273
10585
|
//#endregion
|
|
10274
10586
|
//#region src/mcp/server.ts
|
|
10275
|
-
var
|
|
10276
|
-
function
|
|
10587
|
+
var Og = "hype-stack";
|
|
10588
|
+
function kg() {
|
|
10277
10589
|
let e = new ce({
|
|
10278
|
-
name:
|
|
10590
|
+
name: Og,
|
|
10279
10591
|
version: de
|
|
10280
10592
|
}, {
|
|
10281
10593
|
capabilities: { tools: {} },
|
|
10282
|
-
instructions:
|
|
10594
|
+
instructions: Ag
|
|
10283
10595
|
});
|
|
10284
10596
|
return e.registerTool("search_catalog", {
|
|
10285
10597
|
title: "Search the Hype Stack catalog",
|
|
10286
10598
|
description: "Find feature packs and project templates by keyword, category, or price tier. Read-only. Start here when the user asks what is available.",
|
|
10287
|
-
inputSchema:
|
|
10599
|
+
inputSchema: Cg,
|
|
10288
10600
|
annotations: {
|
|
10289
10601
|
readOnlyHint: !0,
|
|
10290
10602
|
openWorldHint: !0
|
|
10291
10603
|
}
|
|
10292
|
-
}, (e) =>
|
|
10604
|
+
}, (e) => Xh(() => Dg(e))), e.registerTool("plan_install", {
|
|
10293
10605
|
title: "Plan a pack install",
|
|
10294
10606
|
description: "Work out what installing a set of packs would do without writing anything: dependency order, packs already present, and which ones the current license does not cover. Call this before add_packs.",
|
|
10295
|
-
inputSchema:
|
|
10607
|
+
inputSchema: xg,
|
|
10296
10608
|
annotations: {
|
|
10297
10609
|
readOnlyHint: !0,
|
|
10298
10610
|
openWorldHint: !0
|
|
10299
10611
|
}
|
|
10300
|
-
}, (e) =>
|
|
10612
|
+
}, (e) => Xh(() => Sg(e))), e.registerTool("create_application", {
|
|
10301
10613
|
title: "Create a Hype Stack application",
|
|
10302
10614
|
description: "Scaffold a new application into a folder. Runs the clone and dependency install; Docker and database migrations are returned as follow-up commands for the user to run.",
|
|
10303
|
-
inputSchema:
|
|
10615
|
+
inputSchema: lg,
|
|
10304
10616
|
annotations: {
|
|
10305
10617
|
readOnlyHint: !1,
|
|
10306
10618
|
destructiveHint: !1,
|
|
10307
10619
|
openWorldHint: !0
|
|
10308
10620
|
}
|
|
10309
|
-
}, (e) =>
|
|
10621
|
+
}, (e) => Xh(() => ug(e))), e.registerTool("add_packs", {
|
|
10310
10622
|
title: "Add feature packs",
|
|
10311
10623
|
description: "Install packs into an existing project. Requires an explicit onConflict policy because there is no prompt to fall back on.",
|
|
10312
|
-
inputSchema:
|
|
10624
|
+
inputSchema: tg,
|
|
10313
10625
|
annotations: {
|
|
10314
10626
|
readOnlyHint: !1,
|
|
10315
10627
|
destructiveHint: !0,
|
|
10316
10628
|
openWorldHint: !0
|
|
10317
10629
|
}
|
|
10318
|
-
}, (e) =>
|
|
10630
|
+
}, (e) => Xh(() => ng(e))), e.registerTool("apply_template", {
|
|
10319
10631
|
title: "Apply a project template",
|
|
10320
10632
|
description: "Install a template: its starter, layout, fixed packs, and frontend overrides. Pass variants to swap a slot away from the template default.",
|
|
10321
|
-
inputSchema:
|
|
10633
|
+
inputSchema: ig,
|
|
10322
10634
|
annotations: {
|
|
10323
10635
|
readOnlyHint: !1,
|
|
10324
10636
|
destructiveHint: !0,
|
|
10325
10637
|
openWorldHint: !0
|
|
10326
10638
|
}
|
|
10327
|
-
}, (e) =>
|
|
10639
|
+
}, (e) => Xh(() => ag(e))), e.registerTool("inspect_stack", {
|
|
10328
10640
|
title: "Inspect the project stack",
|
|
10329
10641
|
description: "Read stack.json and the detected workspace layout: installed packs, app paths, and whether this is a Hype Stack project at all.",
|
|
10330
|
-
inputSchema:
|
|
10642
|
+
inputSchema: yg,
|
|
10331
10643
|
annotations: {
|
|
10332
10644
|
readOnlyHint: !0,
|
|
10333
10645
|
openWorldHint: !1
|
|
10334
10646
|
}
|
|
10335
|
-
}, (e) =>
|
|
10647
|
+
}, (e) => Xh(() => bg(e))), e.registerTool("env_status", {
|
|
10336
10648
|
title: "Check environment variables",
|
|
10337
10649
|
description: "Report which env vars the installed packs still need. Read-only; filling them in belongs in the user's own terminal via `hype-stack onboard`.",
|
|
10338
|
-
inputSchema:
|
|
10650
|
+
inputSchema: _g,
|
|
10339
10651
|
annotations: {
|
|
10340
10652
|
readOnlyHint: !0,
|
|
10341
10653
|
openWorldHint: !1
|
|
10342
10654
|
}
|
|
10343
|
-
}, (e) =>
|
|
10655
|
+
}, (e) => Xh(() => vg(e))), e.registerTool("auth_status", {
|
|
10344
10656
|
title: "Check Hype Stack authentication",
|
|
10345
10657
|
description: "Who this server is authenticated as, and how to fix it when the answer is nobody. Call this whenever another tool fails with auth_required.",
|
|
10346
|
-
inputSchema:
|
|
10658
|
+
inputSchema: sg,
|
|
10347
10659
|
annotations: {
|
|
10348
10660
|
readOnlyHint: !0,
|
|
10349
10661
|
openWorldHint: !0
|
|
10350
10662
|
}
|
|
10351
|
-
}, () =>
|
|
10663
|
+
}, () => Xh(() => cg())), e;
|
|
10352
10664
|
}
|
|
10353
|
-
var
|
|
10354
|
-
async function
|
|
10665
|
+
var Ag = "Tools for building with Hype Stack, a full-stack template you install feature packs into.\n\nThis server cannot prompt. When a tool returns ok: false, read the \"reason\" field and tell the user what to do:\n- auth_required: they need to run 'npx @hype-stack/cli login' in their own terminal, or set HYPE_STACK_TOKEN in this server's env block.\n- not_owned: the pack is paid and their organization does not have a license. The result carries a purchase URL.\n- not_a_project: run create_application first, or point the tool at the right directory with cwd.\n- conflicts: files already exist. Retry with onConflict set once the user has decided.\n\nInstalls never start Docker or touch a database. Anything the user has to run themselves comes back in \"followUp\".";
|
|
10666
|
+
async function jg() {
|
|
10355
10667
|
Je("mcp");
|
|
10356
|
-
let e =
|
|
10357
|
-
await
|
|
10668
|
+
let e = Yh();
|
|
10669
|
+
await kg().connect(new le(process.stdin, e));
|
|
10358
10670
|
}
|
|
10359
10671
|
//#endregion
|
|
10360
10672
|
//#region src/cli.ts
|
|
10361
|
-
function
|
|
10673
|
+
function Mg(e) {
|
|
10362
10674
|
if (!e) return;
|
|
10363
10675
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
10364
10676
|
return t.length > 0 ? t : void 0;
|
|
10365
10677
|
}
|
|
10366
|
-
function
|
|
10678
|
+
function Ng(e, t) {
|
|
10367
10679
|
let n = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
10368
10680
|
return [...t ?? [], ...n];
|
|
10369
10681
|
}
|
|
10370
|
-
function
|
|
10682
|
+
function Pg(e) {
|
|
10371
10683
|
return e === "light" || e === "dark" ? e : void 0;
|
|
10372
10684
|
}
|
|
10373
|
-
function
|
|
10685
|
+
function Fg(e) {
|
|
10374
10686
|
return e.option("-t, --theme <theme>", `Frontend color theme (${i.join(", ")})`).option("--admin-theme <theme>", "Admin app color theme (defaults to --theme)").option("--radius <value>", `Frontend corner radius, a CSS length (e.g. ${t.map((e) => e.value).join(", ")})`).option("--admin-radius <value>", "Admin app corner radius (defaults to --radius)").option("--mode <mode>", "Color mode the app boots in (light, dark)");
|
|
10375
10687
|
}
|
|
10376
|
-
function
|
|
10688
|
+
function Ig(e) {
|
|
10377
10689
|
return {
|
|
10378
10690
|
theme: e.theme,
|
|
10379
10691
|
adminTheme: e.adminTheme,
|
|
10380
10692
|
radius: e.radius,
|
|
10381
10693
|
adminRadius: e.adminRadius,
|
|
10382
|
-
mode:
|
|
10694
|
+
mode: Pg(e.mode)
|
|
10383
10695
|
};
|
|
10384
10696
|
}
|
|
10385
|
-
function
|
|
10697
|
+
function Lg(e) {
|
|
10386
10698
|
if (!e) return;
|
|
10387
10699
|
let t = {};
|
|
10388
10700
|
for (let n of e.split(",")) {
|
|
@@ -10391,23 +10703,23 @@ function dg(e) {
|
|
|
10391
10703
|
}
|
|
10392
10704
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
10393
10705
|
}
|
|
10394
|
-
function
|
|
10706
|
+
function Rg(e) {
|
|
10395
10707
|
if (!e) return;
|
|
10396
10708
|
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
10397
10709
|
return t.length > 0 ? t : void 0;
|
|
10398
10710
|
}
|
|
10399
|
-
function
|
|
10711
|
+
function zg(e) {
|
|
10400
10712
|
let t = {};
|
|
10401
|
-
for (let n of [...
|
|
10713
|
+
for (let n of [...bd, ...xd]) {
|
|
10402
10714
|
let r = e[n];
|
|
10403
10715
|
typeof r == "string" && (t[n] = r);
|
|
10404
10716
|
}
|
|
10405
10717
|
return t;
|
|
10406
10718
|
}
|
|
10407
|
-
function
|
|
10719
|
+
function Bg() {
|
|
10408
10720
|
let e = new s();
|
|
10409
|
-
e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(de, "-v, --version"),
|
|
10410
|
-
let t =
|
|
10721
|
+
e.name("hype-stack").description("Build with Hype Stack -- templates, components, modules, and more").version(de, "-v, --version"), Fg(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 <editors>", `AI editors to ship rules for, comma-separated or repeated (${be.join(", ")})`, Ng)).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) => {
|
|
10722
|
+
let t = Ig(e);
|
|
10411
10723
|
await Hu({
|
|
10412
10724
|
name: e.name,
|
|
10413
10725
|
directory: e.directory,
|
|
@@ -10424,34 +10736,34 @@ function mg() {
|
|
|
10424
10736
|
}), e.command("init").description("Initialize stack.json in the current project").action(async () => {
|
|
10425
10737
|
await Uu({});
|
|
10426
10738
|
}), e.command("onboard").description("Set up env vars and get the start command").option("-y, --yes", "Skip prompts, accept defaults").option("--cwd <path>", "Working directory").action(async (e) => {
|
|
10427
|
-
await
|
|
10739
|
+
await Ah({
|
|
10428
10740
|
cwd: e.cwd,
|
|
10429
10741
|
yes: e.yes
|
|
10430
10742
|
});
|
|
10431
|
-
}),
|
|
10743
|
+
}), Fg(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("--cwd <path>", "Working directory").action(async (e) => {
|
|
10432
10744
|
await Gu({
|
|
10433
|
-
packs:
|
|
10745
|
+
packs: Mg(e.packs),
|
|
10434
10746
|
force: e.force,
|
|
10435
10747
|
yes: e.yes,
|
|
10436
10748
|
cwd: e.cwd,
|
|
10437
|
-
...
|
|
10749
|
+
...Ig(e)
|
|
10438
10750
|
});
|
|
10439
|
-
}),
|
|
10440
|
-
await
|
|
10751
|
+
}), Fg(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("--cwd <path>", "Working directory").action(async (e, t) => {
|
|
10752
|
+
await Wh({
|
|
10441
10753
|
templateId: e,
|
|
10442
|
-
variants:
|
|
10443
|
-
packs:
|
|
10754
|
+
variants: Lg(t.variants),
|
|
10755
|
+
packs: Mg(t.packs),
|
|
10444
10756
|
force: t.force,
|
|
10445
10757
|
yes: t.yes,
|
|
10446
10758
|
cwd: t.cwd,
|
|
10447
|
-
...
|
|
10759
|
+
...Ig(t)
|
|
10448
10760
|
});
|
|
10449
|
-
}), e.command("deploy").description("Deploy the frontend, admin, and backend, and provision Postgres, Valkey, and a bucket").option("-p, --provider <provider>", `Provider for everything not assigned separately (${
|
|
10450
|
-
await
|
|
10761
|
+
}), e.command("deploy").description("Deploy the frontend, admin, and backend, and provision Postgres, Valkey, and a bucket").option("-p, --provider <provider>", `Provider for everything not assigned separately (${Sd.join(", ")})`).option("--backend <provider>", "Provider hosting the backend API").option("--frontend <provider>", "Provider hosting the frontend").option("--admin <provider>", "Provider hosting the admin app").option("--postgres <provider>", "Provider for the Postgres database").option("--valkey <provider>", "Provider for the Valkey cache").option("--bucket <provider>", "Provider for object storage").option("--only <targets>", `Deploy just these apps, comma-separated (${bd.join(", ")})`).option("-e, --environment <name>", "Deployment environment name (default: production)").option("--fly-org <org>", "Fly organization slug, skips the picker when you belong to several").option("--railway-workspace <workspace>", "Railway workspace, skips the picker when you belong to several").option("--dry-run", "Print every command that would run without creating anything").option("--skip-provision", "Assume Postgres, Valkey, and the bucket already exist").option("--skip-migrations", "Do not run database migrations after the backend deploys").option("-y, --yes", "Skip confirmation prompts").option("--cwd <path>", "Project directory").action(async (e) => {
|
|
10762
|
+
await ch({
|
|
10451
10763
|
cwd: e.cwd,
|
|
10452
10764
|
provider: e.provider,
|
|
10453
|
-
assign:
|
|
10454
|
-
only:
|
|
10765
|
+
assign: zg(e),
|
|
10766
|
+
only: Rg(e.only),
|
|
10455
10767
|
environment: e.environment,
|
|
10456
10768
|
flyOrg: e.flyOrg,
|
|
10457
10769
|
railwayWorkspace: e.railwayWorkspace,
|
|
@@ -10463,9 +10775,9 @@ function mg() {
|
|
|
10463
10775
|
});
|
|
10464
10776
|
let t = e.command("mcp").description("Run the Model Context Protocol server for AI editors");
|
|
10465
10777
|
return t.action(async () => {
|
|
10466
|
-
await
|
|
10778
|
+
await jg();
|
|
10467
10779
|
}), t.command("install").description("Register the MCP server in your editor's config").option("-e, --editor <editor>", `Editor (${Xl.join(", ")})`, "cursor").option("-s, --scope <scope>", "global or project (defaults to global where supported)").option("--cwd <path>", "Project directory, for project scope").option("--token <token>", "API key to store in the config (optional, defaults to your saved login)").option("--print", "Print the JSON block instead of writing a file").action(async (e) => {
|
|
10468
|
-
await
|
|
10780
|
+
await xh({
|
|
10469
10781
|
editor: e.editor,
|
|
10470
10782
|
scope: e.scope,
|
|
10471
10783
|
cwd: e.cwd,
|
|
@@ -10473,12 +10785,12 @@ function mg() {
|
|
|
10473
10785
|
print: e.print
|
|
10474
10786
|
});
|
|
10475
10787
|
}), e.command("login").description("Log in via your browser to install packs your organization owns").action(async () => {
|
|
10476
|
-
await
|
|
10788
|
+
await yh();
|
|
10477
10789
|
}), e.command("logout").description("Log out and remove the saved CLI token").action(async () => {
|
|
10478
|
-
await
|
|
10790
|
+
await bh();
|
|
10479
10791
|
}), e.command("auth").description("Alias for `login`").action(async () => {
|
|
10480
|
-
await
|
|
10792
|
+
await yh();
|
|
10481
10793
|
}), e;
|
|
10482
10794
|
}
|
|
10483
10795
|
//#endregion
|
|
10484
|
-
export {
|
|
10796
|
+
export { ch as a, Uu as c, de as d, yh as i, Hu as l, Yh as n, Gu as o, bh as r, Wu as s, Bg as t, Je as u };
|