chiwaa 0.1.15 → 0.1.17

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.
Files changed (2) hide show
  1. package/bin/chiwaa.js +34 -7
  2. package/package.json +1 -1
package/bin/chiwaa.js CHANGED
@@ -92,11 +92,12 @@ function parseArgs(argv) {
92
92
  if (a.startsWith("--")) {
93
93
  const [k, v] = a.slice(2).split("=", 2);
94
94
  if (v !== undefined) out[k] = v;
95
- else if (["name", "token", "dir", "read", "write", "page", "days", "lines"].includes(k) && argv[i + 1] && !argv[i + 1].startsWith("-")) out[k] = argv[++i];
95
+ else if (["name", "token", "dir", "read", "write", "page", "days", "lines", "branch"].includes(k) && argv[i + 1] && !argv[i + 1].startsWith("-")) out[k] = argv[++i];
96
96
  else out[k] = true;
97
97
  } else if (a === "-y") out.yes = true;
98
98
  else if (a === "-h") out.help = true;
99
99
  else if (a === "-v") out.version = true;
100
+ else if (a === "-f") out.f = true;
100
101
  else out._.push(a);
101
102
  }
102
103
  return out;
@@ -327,8 +328,9 @@ function checkNext(dir) {
327
328
  const server = nextServerFeatures(dir);
328
329
  if (server.length) {
329
330
  const shown = server.slice(0, 4).join(", ") + (server.length > 4 ? ` 등 ${server.length}곳` : "");
330
- fail(`이 Next.js 앱은 서버에서 돌아가는 기능을 씁니다(${shown}). chiwaa 는 화면 파일(HTML·JS)을 올리는 곳이라 이대로는 열리지 않습니다.\n` +
331
- `AI 에게 「이 Next.js 앱을 chiwaa 에 올릴 수 있게 output: 'export' 정적 사이트로 바꾸고, API·middleware 같은 서버 기능은 맨 위 api/ 폴더의 chiwaa 서버 함수로 옮겨 줘. ${AI_GUIDE}」라고 말해 보세요.`);
331
+ fail(`이 Next.js 앱은 서버에서 돌아가는 기능을 씁니다(${shown}). CLI 로는 아직 서버 코드를 올릴 수 없습니다.\n` +
332
+ `· 그대로 돌리려면: 깃허브 저장소를 chiwaa.kr 에 연결하세요. 서버 기능이 있는 Next.js 를 컨테이너로 실행합니다(https://chiwaa.kr/help).\n` +
333
+ `· CLI 로 올리려면: AI 에게 「이 Next.js 앱을 output: 'export' 정적 사이트로 바꾸고, 서버 기능은 맨 위 api/ 폴더의 chiwaa 서버 함수로 옮겨 줘. ${AI_GUIDE}」라고 말해 보세요.`);
332
334
  }
333
335
  }
334
336
 
@@ -462,7 +464,7 @@ function agentSection(name) {
462
464
 
463
465
  - 배포: \`npx chiwaa deploy -y\` — 끝나면 주소가 나온다. 잘못 올렸으면 \`npx chiwaa rollback\`.
464
466
  - 이 폴더는 \`.chiwaa.json\` 으로 사이트가 정해져 있다. 다른 이름(--name)으로 올리지 않는다.
465
- - 정적 사이트만 된다(HTML·CSS·JS, Vite·React·Vue·Astro·Next export 빌드). PHP·Express 같은 서버 코드는 안 된다.
467
+ - CLI 로는 정적 사이트만 된다(HTML·CSS·JS, Vite·React·Vue·Astro·Next export 빌드) + 서버 함수(api/). Next.js SSR·Express·Dockerfile 같은 서버 코드는 깃허브 저장소를 연결하면 컨테이너로 돈다. PHP 는 안 된다.
466
468
  - 글 저장(문의·방명록·게시판)은 사이트 DB: \`npx chiwaa db on\` → \`npx chiwaa db create <표> --read public|owner --write public|owner\`.
467
469
  - 문의·신청서처럼 개인정보가 든 표는 반드시 \`--read owner\`. 사이트에서 안 읽힌다고 public 으로 바꾸지 않는다.
468
470
  - 방문자 글은 화면에 \`textContent\` 로만 넣는다. 비밀번호는 \`<input type="password">\` 로 받는다.
@@ -838,10 +840,12 @@ async function stats(args) {
838
840
  // ---------- logs (서버 함수 기록) ----------
839
841
  async function logs(args) {
840
842
  const name = await siteName(args);
841
- const n = Math.min(Math.max(parseInt(args.lines, 10) || 30, 1), 500);
842
- const r = await api("GET", `/api/v1/sites/${encodeURIComponent(name)}/logs?lines=${n}${args.preview ? "&preview=1" : ""}`);
843
+ const n = Math.min(Math.max(parseInt(args.lines, 10) || 30, 1), 2000);
844
+ const q = `${args.preview ? "&preview=1" : ""}${args.branch ? `&branch=${encodeURIComponent(args.branch)}` : ""}`;
845
+ const r = await api("GET", `/api/v1/sites/${encodeURIComponent(name)}/logs?lines=${n}${q}`);
843
846
  if (r.status !== 200) fail(r.data.error || "기록을 받지 못했습니다.");
844
847
  const d = r.data;
848
+ if (d.kind === "container") return containerLogs(name, n, q, d, args.f || args.follow);
845
849
  console.log(c.bold(`${d.site} 서버 함수 기록`), c.dim(`(최근 ${n}건 · 1분쯤 늦을 수 있음)`));
846
850
  if (d.functions.length) console.log(c.dim(` 함수: ${d.functions.map((f) => "/api/" + f).join(" ")}`));
847
851
  if (!d.entries.length) return console.log(c.dim(" 아직 기록이 없습니다. 오류가 나거나 console.log 를 쓰면 여기에 남습니다."));
@@ -855,6 +859,29 @@ async function logs(args) {
855
859
  }
856
860
  }
857
861
 
862
+ // 컨테이너 앱 기록: 상태 한 줄 + 기록. -f 면 3초마다 새 줄만 이어서 보여 준다(Ctrl+C 로 끝).
863
+ async function containerLogs(name, n, q, d, follow) {
864
+ const st = d.status || {};
865
+ const state = st.error ? "상태 모름" : st.running ? `실행 중 · 메모리 ${st.memory_used || "?"} / ${st.memory_mb}MB` : "잠듦(다음 요청에서 깨어남)";
866
+ console.log(c.bold(`${d.site} 앱 기록`), c.dim(`(${state})`));
867
+ const print = (text, seen) => {
868
+ const lines = String(text || "").split("\n").filter((l) => l.trim());
869
+ let start = 0;
870
+ if (seen) { const i = lines.lastIndexOf(seen); start = i >= 0 ? i + 1 : 0; }
871
+ for (const l of lines.slice(start)) console.log(l.replace(/^(\S+)Z /, (m, t) => c.dim(t.slice(5, 19).replace("T", " ") + " ")));
872
+ return lines.length ? lines[lines.length - 1] : seen;
873
+ };
874
+ let last = print(d.text, null);
875
+ if (!d.text || !String(d.text).trim()) console.log(c.dim(" 아직 기록이 없습니다. 앱이 console.log·print 로 쓰거나 오류가 나면 여기에 남습니다."));
876
+ if (!follow) return;
877
+ console.log(c.dim("— 이어서 봅니다(Ctrl+C 로 끝)"));
878
+ for (;;) {
879
+ await new Promise((res) => setTimeout(res, 3000));
880
+ const r = await api("GET", `/api/v1/sites/${encodeURIComponent(name)}/logs?lines=200${q}`);
881
+ if (r.status === 200 && r.data.kind === "container") last = print(r.data.text, last);
882
+ }
883
+ }
884
+
858
885
  // ---------- env (서버 함수 비밀값) ----------
859
886
  async function env(args) {
860
887
  const sub = args._[1] || "ls";
@@ -1041,7 +1068,7 @@ const HELP = `chiwaa ${VERSION} — chiwaa.kr 에 사이트를 바로 올립니
1041
1068
  chiwaa domains check 연결됐는지 확인 · domains remove -y 로 연결 끊기
1042
1069
  chiwaa stats 방문자 통계(오늘·최근 7일, 많이 본 페이지, 들어온 곳) --days 30
1043
1070
  chiwaa files 사진 목록·용량 · files put 사진.jpg(주인 사진 올리기) · files on|off(방문자 사진 올리기)
1044
- chiwaa logs 서버 함수 기록(오류·console.log) --lines 100, --preview
1071
+ chiwaa logs 컨테이너 앱 기록(-f 이어서 보기, --branch <브랜치>) 또는 서버 함수 기록 --lines 100, --preview
1045
1072
  chiwaa env 서버 함수 비밀값 목록 · env set 이름(값은 안 보이게 입력) · env rm 이름
1046
1073
  chiwaa lock / unlock 사이트 비밀번호 잠금(아이디 chiwaa) / 풀기 — 공개 전 나만 보기
1047
1074
  chiwaa open 관리 화면 열기 (--site 는 사이트 열기)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chiwaa",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "chiwaa.kr 에 사이트를 터미널에서 바로 올리는 도구",
5
5
  "bin": {
6
6
  "chiwaa": "bin/chiwaa.js"