@blackasteroid/kuma-cli 0.1.0

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 (3) hide show
  1. package/README.md +147 -0
  2. package/dist/index.js +30742 -0
  3. package/package.json +49 -0
package/README.md ADDED
@@ -0,0 +1,147 @@
1
+ # kuma-cli
2
+
3
+ > CLI for managing [Uptime Kuma](https://github.com/louislam/uptime-kuma) via its native Socket.IO API.
4
+
5
+ No more clicking through the web panel — manage monitors, status pages, and heartbeats directly from your terminal.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install -g @blackasteroid/kuma-cli
11
+ ```
12
+
13
+ Or use without installing:
14
+
15
+ ```bash
16
+ npx @blackasteroid/kuma-cli login https://kuma.example.com
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```bash
22
+ # 1. Authenticate
23
+ kuma login https://kuma.example.com
24
+
25
+ # 2. List monitors
26
+ kuma monitors list
27
+
28
+ # 3. Add a monitor
29
+ kuma monitors add --name "My API" --type http --url https://api.example.com
30
+ ```
31
+
32
+ ## Commands
33
+
34
+ ### Auth
35
+
36
+ | Command | Description |
37
+ |---------|-------------|
38
+ | `kuma login <url>` | Authenticate with Uptime Kuma and save session |
39
+ | `kuma logout` | Clear saved session credentials |
40
+ | `kuma status` | Show current connection config |
41
+
42
+ ### Monitors
43
+
44
+ | Command | Description |
45
+ |---------|-------------|
46
+ | `kuma monitors list` | List all monitors with status + uptime |
47
+ | `kuma monitors list --json` | Output raw JSON (for scripting) |
48
+ | `kuma monitors add` | Add a monitor interactively |
49
+ | `kuma monitors add --name <n> --type http --url <url>` | Add non-interactively |
50
+ | `kuma monitors update <id>` | Update name/url/interval of a monitor |
51
+ | `kuma monitors delete <id>` | Delete a monitor (with confirmation) |
52
+ | `kuma monitors delete <id> --force` | Delete without confirmation prompt |
53
+ | `kuma monitors pause <id>` | Pause a monitor |
54
+ | `kuma monitors resume <id>` | Resume a paused monitor |
55
+
56
+ #### `monitors add` flags
57
+
58
+ | Flag | Description | Default |
59
+ |------|-------------|---------|
60
+ | `--name <name>` | Monitor name | (prompted) |
61
+ | `--type <type>` | Monitor type: `http`, `tcp`, `ping`, `dns`, `push`, ... | (prompted) |
62
+ | `--url <url>` | URL or hostname to monitor | (prompted) |
63
+ | `--interval <seconds>` | Check interval | `60` |
64
+
65
+ #### `monitors update` flags
66
+
67
+ | Flag | Description |
68
+ |------|-------------|
69
+ | `--name <name>` | New monitor name |
70
+ | `--url <url>` | New URL or hostname |
71
+ | `--interval <seconds>` | New check interval |
72
+
73
+ ### Heartbeats
74
+
75
+ | Command | Description |
76
+ |---------|-------------|
77
+ | `kuma heartbeat <monitor-id>` | View last 20 heartbeats for a monitor |
78
+ | `kuma heartbeat <monitor-id> --limit 50` | Show last N heartbeats |
79
+ | `kuma heartbeat <monitor-id> --json` | Output raw JSON |
80
+
81
+ ### Status Pages
82
+
83
+ | Command | Description |
84
+ |---------|-------------|
85
+ | `kuma status-pages list` | List all status pages |
86
+ | `kuma status-pages list --json` | Output raw JSON |
87
+
88
+ ## Config
89
+
90
+ Session is persisted automatically after login:
91
+
92
+ ```
93
+ ~/.config/kuma-cli-nodejs/config.json (Linux/macOS)
94
+ %APPDATA%\kuma-cli-nodejs\Config (Windows)
95
+ ```
96
+
97
+ ```json
98
+ {
99
+ "url": "https://kuma.example.com",
100
+ "token": "<session-token>"
101
+ }
102
+ ```
103
+
104
+ Run `kuma status` to see the config path on your system.
105
+
106
+ ## Architecture
107
+
108
+ Uses Uptime Kuma's native **Socket.IO API** — no REST API, no hacks. The same protocol the web UI uses.
109
+
110
+ ```
111
+ kuma login → socket.emit("login") → receives token
112
+ kuma * → socket.emit("loginByToken") → authenticated session
113
+ ```
114
+
115
+ ## Development
116
+
117
+ ```bash
118
+ git clone https://github.com/BlackAsteroid/kuma-cli
119
+ cd kuma-cli
120
+ npm install
121
+
122
+ npm run dev # watch mode (tsup)
123
+ npm run build # compile to dist/
124
+ npm run typecheck # tsc --noEmit
125
+ ```
126
+
127
+ ### Directory Structure
128
+
129
+ ```
130
+ src/
131
+ ├── index.ts # Entry point, CLI setup
132
+ ├── client.ts # Socket.IO connection + auth
133
+ ├── config.ts # ~/.kuma-cli.json persistence
134
+ ├── commands/
135
+ │ ├── login.ts
136
+ │ ├── logout.ts
137
+ │ ├── monitors.ts
138
+ │ ├── status-pages.ts
139
+ │ └── heartbeat.ts
140
+ └── utils/
141
+ ├── output.ts # Table rendering, chalk helpers
142
+ └── errors.ts # Error formatting + exit codes
143
+ ```
144
+
145
+ ## License
146
+
147
+ MIT — [Black Asteroid](https://blackasteroid.com.ar)