chiwaa 0.1.4 → 0.1.5

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/README.md CHANGED
@@ -20,6 +20,7 @@ npx chiwaa deploy
20
20
  | `chiwaa rollback [버전]` | 한 단계 전 또는 지정 버전으로 되돌리기 |
21
21
  | `chiwaa db` · `db on` · `db create <표>` · `db rows <표>` | 사이트 DB(문의·방명록 등 글 저장) — 켜기·표 만들기·글 보기 |
22
22
  | `chiwaa domains` · `search` · `buy` · `add` · `check` | x-y.net 도메인 찾기·사기(결제는 x-y.net 결제창에서 직접)·붙이기 |
23
+ | `chiwaa stats` | 방문자 통계(오늘·최근 7일·많이 본 페이지·들어온 곳) |
23
24
  | `chiwaa agent` | AI 도구용 안내(AGENTS.md·CLAUDE.md) 만들기 — 처음 deploy 때 자동 |
24
25
  | `chiwaa whoami` / `logout` | 계정 확인 / 로그아웃 |
25
26
 
package/bin/chiwaa.js CHANGED
@@ -92,7 +92,7 @@ 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"].includes(k) && argv[i + 1] && !argv[i + 1].startsWith("-")) out[k] = argv[++i];
95
+ else if (["name", "token", "dir", "read", "write", "page", "days"].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;
@@ -633,6 +633,33 @@ async function domains(args) {
633
633
  fail(`모르는 domains 명령입니다: ${sub}\n 쓸 수 있는 것: (없음=상태) · search · buy · add · check · remove`);
634
634
  }
635
635
 
636
+ // ---------- stats (방문자 통계) ----------
637
+ async function stats(args) {
638
+ const name = await siteName(args);
639
+ const days = Math.min(Math.max(parseInt(args.days, 10) || 7, 1), 90);
640
+ const r = await api("GET", `/api/v1/sites/${encodeURIComponent(name)}/stats?days=${days}`);
641
+ if (r.status !== 200) fail(r.data.error || "통계를 받지 못했습니다.");
642
+ const s = r.data;
643
+ const n = (x) => Number(x).toLocaleString("ko-KR");
644
+ console.log(c.bold(`${s.site} 방문자`), c.dim(`(최근 ${days}일 · 10분마다 갱신 · 로봇 제외)`));
645
+ console.log(` 오늘 방문자 ${c.bold(n(s.today.visitors))}명 · 보기 ${n(s.today.views)}회`);
646
+ console.log(` ${days}일 합계 방문자 ${n(s.total.visitors)}명 · 보기 ${n(s.total.views)}회 · 휴대폰 ${s.mobile_pct}%\n`);
647
+ const top = Math.max(1, ...s.days.map((d) => d.visitors));
648
+ for (const d of s.days.slice(-14)) {
649
+ const bar = "█".repeat(Math.round((d.visitors / top) * 30)) || (d.visitors ? "▏" : "");
650
+ console.log(` ${d.date.slice(5)} ${String(d.visitors).padStart(6)}명 ${c.cyan(bar)}`);
651
+ }
652
+ const list = (title, obj) => {
653
+ const e = Object.entries(obj || {});
654
+ if (!e.length) return;
655
+ console.log(`\n ${title}`);
656
+ for (const [k, v] of e.slice(0, 5)) console.log(` ${String(v).padStart(6)} ${k}`);
657
+ };
658
+ list("많이 본 페이지", s.pages);
659
+ list("들어온 곳", s.refs);
660
+ if (!s.total.views) console.log(c.dim("\n 아직 집계된 방문이 없습니다."));
661
+ }
662
+
636
663
  async function whoami() {
637
664
  const r = await api("GET", "/api/v1/me");
638
665
  if (r.status !== 200) fail(r.data.error || "로그인 정보를 받지 못했습니다.");
@@ -669,6 +696,7 @@ const HELP = `chiwaa ${VERSION} — chiwaa.kr 에 사이트를 바로 올립니
669
696
  chiwaa domains buy <도메인> x-y.net 신청·결제 화면 열기(결제는 직접)
670
697
  chiwaa domains add <도메인> 도메인 붙이기(x-y.net 도메인은 바로, 다른 곳 도메인은 넣을 DNS 레코드 안내)
671
698
  chiwaa domains check 연결됐는지 확인 · domains remove -y 로 연결 끊기
699
+ chiwaa stats 방문자 통계(오늘·최근 7일, 많이 본 페이지, 들어온 곳) --days 30
672
700
  chiwaa agent AI 도구용 안내(AGENTS.md·CLAUDE.md)를 만들거나 새로 고침
673
701
  (처음 deploy 할 때 자동으로 만든다)
674
702
  chiwaa whoami 로그인한 계정
@@ -682,7 +710,7 @@ async function main() {
682
710
  const cmd = args._[0];
683
711
  if (args.version) return console.log(VERSION);
684
712
  if (args.help || !cmd || cmd === "help") return console.log(HELP);
685
- const cmds = { deploy, login, list, ls: list, versions, rollback, db, domains, domain: domains, agent, whoami, logout };
713
+ const cmds = { deploy, login, list, ls: list, versions, rollback, db, domains, domain: domains, stats, agent, whoami, logout };
686
714
  if (!cmds[cmd]) fail(`모르는 명령입니다: ${cmd}\n\n${HELP}`);
687
715
  await cmds[cmd](args);
688
716
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chiwaa",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "chiwaa.kr 에 사이트를 터미널에서 바로 올리는 도구",
5
5
  "bin": {
6
6
  "chiwaa": "bin/chiwaa.js"