chiwaa 0.1.18 → 0.1.19
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/bin/chiwaa.js +29 -1
- package/package.json +1 -1
package/bin/chiwaa.js
CHANGED
|
@@ -1073,6 +1073,33 @@ async function open(args) {
|
|
|
1073
1073
|
if (!args["no-browser"]) openBrowser(url);
|
|
1074
1074
|
}
|
|
1075
1075
|
|
|
1076
|
+
// ---------- pg (관리형 Postgres) ----------
|
|
1077
|
+
async function pg(args) {
|
|
1078
|
+
const sub = args._[1] || "status";
|
|
1079
|
+
const name = await siteName(args);
|
|
1080
|
+
const base = `/api/v1/sites/${encodeURIComponent(name)}/pg`;
|
|
1081
|
+
if (sub === "create") {
|
|
1082
|
+
const r = await api("POST", base);
|
|
1083
|
+
if (r.status !== 200) fail(r.data.error || "Postgres 를 만들지 못했습니다.");
|
|
1084
|
+
console.log(c.green("✓"), r.data.message);
|
|
1085
|
+
return console.log(c.dim("앱에서는 process.env.DATABASE_URL(또는 CHIWAA_PG_URL). 컨테이너 앱에서만 접속됩니다. 다시 배포: npx chiwaa deploy"));
|
|
1086
|
+
}
|
|
1087
|
+
if (sub === "password") {
|
|
1088
|
+
const r = await api("POST", `${base}/password`);
|
|
1089
|
+
if (r.status !== 200) fail(r.data.error || "비밀번호를 바꾸지 못했습니다.");
|
|
1090
|
+
return console.log(c.green("✓"), r.data.message);
|
|
1091
|
+
}
|
|
1092
|
+
if (sub !== "status") fail("쓰는 법: chiwaa pg [status|create|password]");
|
|
1093
|
+
const r = await api("GET", base);
|
|
1094
|
+
if (r.status !== 200) fail(r.data.error || "상태를 받지 못했습니다.");
|
|
1095
|
+
const d = r.data;
|
|
1096
|
+
const lim = d.limit_mb >= 1024 ? `${d.limit_mb / 1024}GB` : `${d.limit_mb}MB`;
|
|
1097
|
+
if (!d.exists) return console.log(`Postgres 없음 — ${c.bold("npx chiwaa pg create")} 로 만듭니다(${lim} · 동시 연결 ${d.conn_limit}개 · 매일 백업).`);
|
|
1098
|
+
if (d.error) fail(d.error);
|
|
1099
|
+
console.log(`${c.bold(d.name)} · 사용 ${(d.bytes / 1048576).toFixed(1)}MB / ${lim} · 연결 ${d.connections}/${d.conn_limit}${d.readonly ? c.red(" · 용량을 넘어 읽기 전용") : ""}`);
|
|
1100
|
+
console.log(c.dim("컨테이너에 CHIWAA_PG_URL 로 들어갑니다(설정값에 DATABASE_URL 이 없으면 DATABASE_URL 로도)."));
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1076
1103
|
async function usage() {
|
|
1077
1104
|
const r = await api("GET", "/api/v1/usage");
|
|
1078
1105
|
if (r.status !== 200) fail(r.data.error || "사용량을 받지 못했습니다.");
|
|
@@ -1135,6 +1162,7 @@ const HELP = `chiwaa ${VERSION} — chiwaa.kr 에 사이트를 바로 올립니
|
|
|
1135
1162
|
chiwaa domains check 연결됐는지 확인 · domains remove -y 로 연결 끊기
|
|
1136
1163
|
chiwaa stats 방문자 통계(오늘·최근 7일, 많이 본 페이지, 들어온 곳) --days 30
|
|
1137
1164
|
chiwaa files 사진 목록·용량 · files put 사진.jpg(주인 사진 올리기) · files on|off(방문자 사진 올리기)
|
|
1165
|
+
chiwaa pg [create|password] 관리형 Postgres(컨테이너 앱의 DATABASE_URL) 상태·만들기·비밀번호 새로
|
|
1138
1166
|
chiwaa logs 컨테이너 앱 기록(-f 이어서 보기, --branch <브랜치>) 또는 서버 함수 기록 --lines 100, --preview
|
|
1139
1167
|
chiwaa env 서버 함수 비밀값 목록 · env set 이름(값은 안 보이게 입력) · env rm 이름
|
|
1140
1168
|
chiwaa lock / unlock 사이트 비밀번호 잠금(아이디 chiwaa) / 풀기 — 공개 전 나만 보기
|
|
@@ -1153,7 +1181,7 @@ async function main() {
|
|
|
1153
1181
|
const cmd = args._[0];
|
|
1154
1182
|
if (args.version) return console.log(VERSION);
|
|
1155
1183
|
if (args.help || !cmd || cmd === "help") return console.log(HELP);
|
|
1156
|
-
const cmds = { deploy, login, list, ls: list, versions, rollback, db, files, domains, domain: domains, stats, env, logs, lock, unlock, open, usage, agent, whoami, logout };
|
|
1184
|
+
const cmds = { deploy, login, list, ls: list, versions, rollback, db, files, domains, domain: domains, stats, env, logs, lock, unlock, open, usage, agent, whoami, logout, pg };
|
|
1157
1185
|
if (!cmds[cmd]) fail(`모르는 명령입니다: ${cmd}\n\n${HELP}`);
|
|
1158
1186
|
if (cmd !== "login" && cmd !== "logout") await resumePendingLogin();
|
|
1159
1187
|
await cmds[cmd](args);
|