@equt/clis 0.1.14 → 0.1.16
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/komari/client.d.ts +5 -0
- package/dist/komari/client.d.ts.map +1 -0
- package/dist/komari/client.js +35 -0
- package/dist/komari/client.js.map +1 -0
- package/dist/komari/commands/exec.d.ts +3 -0
- package/dist/komari/commands/exec.d.ts.map +1 -0
- package/dist/komari/commands/exec.js +47 -0
- package/dist/komari/commands/exec.js.map +1 -0
- package/dist/komari/commands/logs.d.ts +3 -0
- package/dist/komari/commands/logs.d.ts.map +1 -0
- package/dist/komari/commands/logs.js +30 -0
- package/dist/komari/commands/logs.js.map +1 -0
- package/dist/komari/commands/nodes.d.ts +3 -0
- package/dist/komari/commands/nodes.d.ts.map +1 -0
- package/dist/komari/commands/nodes.js +26 -0
- package/dist/komari/commands/nodes.js.map +1 -0
- package/dist/komari/commands/ping.d.ts +3 -0
- package/dist/komari/commands/ping.d.ts.map +1 -0
- package/dist/komari/commands/ping.js +32 -0
- package/dist/komari/commands/ping.js.map +1 -0
- package/dist/komari/commands/records.d.ts +3 -0
- package/dist/komari/commands/records.d.ts.map +1 -0
- package/dist/komari/commands/records.js +34 -0
- package/dist/komari/commands/records.js.map +1 -0
- package/dist/komari/commands/status.d.ts +3 -0
- package/dist/komari/commands/status.d.ts.map +1 -0
- package/dist/komari/commands/status.js +44 -0
- package/dist/komari/commands/status.js.map +1 -0
- package/dist/komari/commands/tasks.d.ts +3 -0
- package/dist/komari/commands/tasks.d.ts.map +1 -0
- package/dist/komari/commands/tasks.js +52 -0
- package/dist/komari/commands/tasks.js.map +1 -0
- package/dist/komari/index.d.ts +3 -0
- package/dist/komari/index.d.ts.map +1 -0
- package/dist/komari/index.js +31 -0
- package/dist/komari/index.js.map +1 -0
- package/dist/komari/output.d.ts +7 -0
- package/dist/komari/output.d.ts.map +1 -0
- package/dist/komari/output.js +39 -0
- package/dist/komari/output.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function getApiKey(): string;
|
|
2
|
+
export declare function request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
3
|
+
export declare function get<T>(path: string): Promise<T>;
|
|
4
|
+
export declare function post<T>(path: string, body?: unknown): Promise<T>;
|
|
5
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/komari/client.ts"],"names":[],"mappings":"AAIA,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED,wBAAsB,OAAO,CAAC,CAAC,EAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAAC,CAAC,CAAC,CAoBZ;AAED,wBAAsB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAErD;AAED,wBAAsB,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAEtE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
const BASE_URL = 'https://komari.equt.services';
|
|
3
|
+
export function getApiKey() {
|
|
4
|
+
const key = process.env.KOMARI_API_KEY;
|
|
5
|
+
if (!key) {
|
|
6
|
+
console.error('KOMARI_API_KEY environment variable is not set');
|
|
7
|
+
process.exit(1);
|
|
8
|
+
}
|
|
9
|
+
return key;
|
|
10
|
+
}
|
|
11
|
+
export async function request(method, path, body) {
|
|
12
|
+
const url = `${BASE_URL}${path}`;
|
|
13
|
+
const key = getApiKey();
|
|
14
|
+
const res = await fetch(url, {
|
|
15
|
+
method,
|
|
16
|
+
headers: {
|
|
17
|
+
'Authorization': `Bearer ${key}`,
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
},
|
|
20
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
21
|
+
});
|
|
22
|
+
if (!res.ok) {
|
|
23
|
+
const text = await res.text().catch(() => '');
|
|
24
|
+
throw new Error(`Komari API error ${res.status}: ${text || res.statusText}`);
|
|
25
|
+
}
|
|
26
|
+
const json = await res.json();
|
|
27
|
+
return json.data;
|
|
28
|
+
}
|
|
29
|
+
export async function get(path) {
|
|
30
|
+
return request('GET', path);
|
|
31
|
+
}
|
|
32
|
+
export async function post(path, body) {
|
|
33
|
+
return request('POST', path, body);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/komari/client.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC,MAAM,QAAQ,GAAG,8BAA8B,CAAA;AAE/C,MAAM,UAAU,SAAS;IACvB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAA;IACtC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAA;QAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,MAAc,EACd,IAAY,EACZ,IAAc;IAEd,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,IAAI,EAAE,CAAA;IAChC,MAAM,GAAG,GAAG,SAAS,EAAE,CAAA;IAEvB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAC3B,MAAM;QACN,OAAO,EAAE;YACP,eAAe,EAAE,UAAU,GAAG,EAAE;YAChC,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KAC9C,CAAC,CAAA;IAEF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;QAC7C,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,CAAC,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAA;IAC9E,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAkD,CAAA;IAC7E,OAAO,IAAI,CAAC,IAAI,CAAA;AAClB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,GAAG,CAAI,IAAY;IACvC,OAAO,OAAO,CAAI,KAAK,EAAE,IAAI,CAAC,CAAA;AAChC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAI,IAAY,EAAE,IAAc;IACxD,OAAO,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../src/komari/commands/exec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAiBxC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8CnD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { get, post } from '../client.js';
|
|
3
|
+
import { renderJson } from '../output.js';
|
|
4
|
+
export function registerExec(program) {
|
|
5
|
+
program
|
|
6
|
+
.command('exec')
|
|
7
|
+
.description('Execute a command on a remote server')
|
|
8
|
+
.argument('<uuid>', 'Server UUID')
|
|
9
|
+
.argument('<command...>', 'Command to execute')
|
|
10
|
+
.option('--timeout <ms>', 'Timeout in milliseconds for polling result', '30000')
|
|
11
|
+
.action(async (uuid, command, opts) => {
|
|
12
|
+
const json = program.opts().json;
|
|
13
|
+
const cmd = command.join(' ');
|
|
14
|
+
const timeout = Number.parseInt(opts.timeout, 10);
|
|
15
|
+
const { task_id } = await post('/api/admin/exec', {
|
|
16
|
+
command: cmd,
|
|
17
|
+
clients: [uuid],
|
|
18
|
+
});
|
|
19
|
+
console.error(`Task created: ${task_id}`);
|
|
20
|
+
const start = Date.now();
|
|
21
|
+
while (Date.now() - start < timeout) {
|
|
22
|
+
const results = await get(`/api/admin/task/${task_id}/result`);
|
|
23
|
+
if (results?.length) {
|
|
24
|
+
const result = results[0];
|
|
25
|
+
if (json) {
|
|
26
|
+
renderJson(result);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
if (result.result) {
|
|
30
|
+
process.stdout.write(result.result);
|
|
31
|
+
if (!result.result.endsWith('\n')) {
|
|
32
|
+
process.stdout.write('\n');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (result.exit_code !== 0) {
|
|
36
|
+
console.error(`Exit code: ${result.exit_code}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
process.exit(result.exit_code);
|
|
40
|
+
}
|
|
41
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
42
|
+
}
|
|
43
|
+
console.error(`Timeout waiting for task ${task_id} result`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../src/komari/commands/exec.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAczC,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,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AAC,CAAA;wBACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;4BAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;wBAC5B,CAAC;oBACH,CAAC;oBACD,IAAI,MAAM,CAAC,SAAS,KAAK,CAAC,EAAE,CAAC;wBAC3B,OAAO,CAAC,KAAK,CAAC,cAAc,MAAM,CAAC,SAAS,EAAE,CAAC,CAAA;oBACjD,CAAC;gBACH,CAAC;gBACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YAChC,CAAC;YACD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;QACzD,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,4BAA4B,OAAO,SAAS,CAAC,CAAA;QAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../src/komari/commands/logs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAcxC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+BnD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { get } from '../client.js';
|
|
3
|
+
import { renderJson, renderTable } from '../output.js';
|
|
4
|
+
export function registerLogs(program) {
|
|
5
|
+
program
|
|
6
|
+
.command('logs')
|
|
7
|
+
.description('Show audit logs')
|
|
8
|
+
.option('-l, --limit <n>', 'Number of entries', '20')
|
|
9
|
+
.option('-p, --page <n>', 'Page number', '1')
|
|
10
|
+
.action(async (opts) => {
|
|
11
|
+
const json = program.opts().json;
|
|
12
|
+
const params = new URLSearchParams({ limit: opts.limit, page: opts.page });
|
|
13
|
+
const logs = await get(`/api/admin/logs?${params}`);
|
|
14
|
+
if (json) {
|
|
15
|
+
renderJson(logs);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!logs?.length) {
|
|
19
|
+
process.stdout.write('No logs found.\n');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
renderTable(['Time', 'Severity', 'Description', 'IP'], logs.map(l => [
|
|
23
|
+
l.created_at,
|
|
24
|
+
l.severity,
|
|
25
|
+
l.description,
|
|
26
|
+
l.ip,
|
|
27
|
+
]));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../../src/komari/commands/logs.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAWtD,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,iBAAiB,CAAC;SAC9B,MAAM,CAAC,iBAAiB,EAAE,mBAAmB,EAAE,IAAI,CAAC;SACpD,MAAM,CAAC,gBAAgB,EAAE,aAAa,EAAE,GAAG,CAAC;SAC5C,MAAM,CAAC,KAAK,EAAE,IAAqC,EAAE,EAAE;QACtD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAqB,CAAC,IAAI,CAAA;QACnD,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAC1E,MAAM,IAAI,GAAG,MAAM,GAAG,CAAa,mBAAmB,MAAM,EAAE,CAAC,CAAA;QAE/D,IAAI,IAAI,EAAE,CAAC;YACT,UAAU,CAAC,IAAI,CAAC,CAAA;YAChB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;YAClB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;YACxC,OAAM;QACR,CAAC;QAED,WAAW,CACT,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,CAAC,EACzC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACZ,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,WAAW;YACb,CAAC,CAAC,EAAE;SACL,CAAC,CACH,CAAA;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../src/komari/commands/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAmBxC,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0BpD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { get } from '../client.js';
|
|
2
|
+
import { formatBytes, renderJson, renderTable } from '../output.js';
|
|
3
|
+
export function registerNodes(program) {
|
|
4
|
+
program
|
|
5
|
+
.command('nodes')
|
|
6
|
+
.description('List all monitored servers')
|
|
7
|
+
.action(async () => {
|
|
8
|
+
const json = program.opts().json;
|
|
9
|
+
const nodes = await get('/api/nodes');
|
|
10
|
+
if (json) {
|
|
11
|
+
renderJson(nodes);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
renderTable(['Name', 'UUID', 'Status', 'OS', 'Region', 'Memory', 'IP'], nodes.map(n => [
|
|
15
|
+
n.name,
|
|
16
|
+
n.uuid.slice(0, 8),
|
|
17
|
+
n.online ? 'online' : 'offline',
|
|
18
|
+
n.os,
|
|
19
|
+
n.region,
|
|
20
|
+
formatBytes(n.memory_total),
|
|
21
|
+
n.ipv4 || n.ipv6 || '-',
|
|
22
|
+
]));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/komari/commands/nodes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAiBnE,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,4BAA4B,CAAC;SACzC,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAqB,CAAC,IAAI,CAAA;QACnD,MAAM,KAAK,GAAG,MAAM,GAAG,CAAS,YAAY,CAAC,CAAA;QAE7C,IAAI,IAAI,EAAE,CAAC;YACT,UAAU,CAAC,KAAK,CAAC,CAAA;QACnB,CAAC;aACI,CAAC;YACJ,WAAW,CACT,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,EAC1D,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACb,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;gBAClB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;gBAC/B,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,MAAM;gBACR,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;gBAC3B,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,GAAG;aACxB,CAAC,CACH,CAAA;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../../src/komari/commands/ping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAkBxC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiCnD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { get } from '../client.js';
|
|
3
|
+
import { renderJson, renderTable } from '../output.js';
|
|
4
|
+
export function registerPing(program) {
|
|
5
|
+
program
|
|
6
|
+
.command('ping')
|
|
7
|
+
.description('Show ping test results')
|
|
8
|
+
.action(async () => {
|
|
9
|
+
const json = program.opts().json;
|
|
10
|
+
const data = await get('/api/records/ping');
|
|
11
|
+
if (json) {
|
|
12
|
+
renderJson(data);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (!data?.length) {
|
|
16
|
+
process.stdout.write('No ping results found.\n');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
for (const task of data) {
|
|
20
|
+
process.stdout.write(`\nTask: ${task.task_name} (${task.target})\n`);
|
|
21
|
+
if (task.results?.length) {
|
|
22
|
+
renderTable(['Client', 'Loss', 'Min (ms)', 'Max (ms)'], task.results.map(r => [
|
|
23
|
+
r.client_name,
|
|
24
|
+
`${(r.loss * 100).toFixed(1)}%`,
|
|
25
|
+
String(r.latency_min),
|
|
26
|
+
String(r.latency_max),
|
|
27
|
+
]));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=ping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping.js","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C,WAAW,CAAC;iBACtB,CAAC,CACH,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../src/komari/commands/records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAYxC,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoCtD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { get } from '../client.js';
|
|
3
|
+
import { renderJson, renderTable } from '../output.js';
|
|
4
|
+
const VALID_TYPES = ['cpu', 'ram', 'swap', 'disk', 'network', 'load', 'temp', 'process', 'connections', 'gpu'];
|
|
5
|
+
export function registerRecords(program) {
|
|
6
|
+
program
|
|
7
|
+
.command('records')
|
|
8
|
+
.description('Show historical monitoring records')
|
|
9
|
+
.argument('<uuid>', 'Server UUID')
|
|
10
|
+
.option('-t, --type <type>', `Record type (${VALID_TYPES.join(', ')})`, 'cpu')
|
|
11
|
+
.action(async (uuid, opts) => {
|
|
12
|
+
const json = program.opts().json;
|
|
13
|
+
if (!VALID_TYPES.includes(opts.type)) {
|
|
14
|
+
console.error(`Invalid type: ${opts.type}. Valid types: ${VALID_TYPES.join(', ')}`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
const params = new URLSearchParams({ uuid, type: opts.type });
|
|
18
|
+
const records = await get(`/api/records/load?${params}`);
|
|
19
|
+
if (json) {
|
|
20
|
+
renderJson(records);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!records?.length) {
|
|
24
|
+
process.stdout.write('No records found.\n');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const keys = Object.keys(records[0]).filter(k => k !== 'timestamp');
|
|
28
|
+
renderTable(['Timestamp', ...keys], records.map(r => [
|
|
29
|
+
r.timestamp,
|
|
30
|
+
...keys.map(k => String(r[k] ?? '-')),
|
|
31
|
+
]));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../../src/komari/commands/records.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAEtD,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,CAAU,CAAA;AAOvH,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,oCAAoC,CAAC;SACjD,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;SACjC,MAAM,CAAC,mBAAmB,EAAE,gBAAgB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC;SAC7E,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,IAAsB,EAAE,EAAE;QACrD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAqB,CAAC,IAAI,CAAA;QAEnD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAkC,CAAC,EAAE,CAAC;YACnE,OAAO,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,IAAI,kBAAkB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAC7D,MAAM,OAAO,GAAG,MAAM,GAAG,CAAgB,qBAAqB,MAAM,EAAE,CAAC,CAAA;QAEvE,IAAI,IAAI,EAAE,CAAC;YACT,UAAU,CAAC,OAAO,CAAC,CAAA;YACnB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;YAC3C,OAAM;QACR,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,CAAC,CAAA;QACnE,WAAW,CACT,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,EACtB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACf,CAAC,CAAC,SAAS;YACX,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;SACtC,CAAC,CACH,CAAA;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/komari/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAyBxC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+CrD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { get } from '../client.js';
|
|
2
|
+
import { formatBytes, formatPercent, formatUptime, renderJson, renderKeyValue, } from '../output.js';
|
|
3
|
+
export function registerStatus(program) {
|
|
4
|
+
program
|
|
5
|
+
.command('status')
|
|
6
|
+
.description('Show current status of a server')
|
|
7
|
+
.argument('<uuid>', 'Server UUID')
|
|
8
|
+
.action(async (uuid) => {
|
|
9
|
+
const json = program.opts().json;
|
|
10
|
+
const report = await get(`/api/recent/${uuid}`);
|
|
11
|
+
if (json) {
|
|
12
|
+
renderJson(report);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const diskTotal = report.disk?.reduce((s, d) => s + d.total, 0) ?? 0;
|
|
16
|
+
const diskUsed = report.disk?.reduce((s, d) => s + d.used, 0) ?? 0;
|
|
17
|
+
const netUp = report.network?.reduce((s, n) => s + n.upload, 0) ?? 0;
|
|
18
|
+
const netDown = report.network?.reduce((s, n) => s + n.download, 0) ?? 0;
|
|
19
|
+
const pairs = [
|
|
20
|
+
['CPU', formatPercent(report.cpu?.usage ?? 0)],
|
|
21
|
+
['Memory', `${formatBytes(report.memory?.used ?? 0)} / ${formatBytes(report.memory?.total ?? 0)}`],
|
|
22
|
+
['Swap', `${formatBytes(report.swap?.used ?? 0)} / ${formatBytes(report.swap?.total ?? 0)}`],
|
|
23
|
+
['Disk', `${formatBytes(diskUsed)} / ${formatBytes(diskTotal)}`],
|
|
24
|
+
['Load', report.load_avg?.join(', ') ?? '-'],
|
|
25
|
+
['Network', `up ${formatBytes(netUp)}/s down ${formatBytes(netDown)}/s`],
|
|
26
|
+
['Connections', String(report.tcp_conn_count ?? 0)],
|
|
27
|
+
['Processes', String(report.process_count ?? 0)],
|
|
28
|
+
['Uptime', formatUptime(report.uptime ?? 0)],
|
|
29
|
+
];
|
|
30
|
+
if (report.temperature) {
|
|
31
|
+
pairs.push(['Temperature', `${report.temperature}°C`]);
|
|
32
|
+
}
|
|
33
|
+
if (report.gpu?.length) {
|
|
34
|
+
for (const [i, g] of report.gpu.entries()) {
|
|
35
|
+
pairs.push([`GPU ${i}`, `${formatPercent(g.usage)} | VRAM ${formatBytes(g.vram_used)}/${formatBytes(g.vram_total)} | ${g.temperature}°C`]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (report.updated_at) {
|
|
39
|
+
pairs.push(['Updated', report.updated_at]);
|
|
40
|
+
}
|
|
41
|
+
renderKeyValue(pairs);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/komari/commands/status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,EACL,WAAW,EACX,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,GACf,MAAM,cAAc,CAAA;AAiBrB,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,iCAAiC,CAAC;SAC9C,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;SACjC,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;QAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAqB,CAAC,IAAI,CAAA;QACnD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAe,eAAe,IAAI,EAAE,CAAC,CAAA;QAE7D,IAAI,IAAI,EAAE,CAAC;YACT,UAAU,CAAC,MAAM,CAAC,CAAA;YAClB,OAAM;QACR,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAA;QACpE,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAA;QAClE,MAAM,KAAK,GAAG,MAAM,CAAC,OAA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C,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;SAC7C,CAAA;QAED,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACvB,KAAK,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,GAAG,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,CAAA;QACxD,CAAC;QAED,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC;YACvB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC1C,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,CAAA;YAC5I,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAA;QAC5C,CAAC;QAED,cAAc,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../../src/komari/commands/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAoBxC,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6DpD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { get } from '../client.js';
|
|
3
|
+
import { renderJson, renderTable } from '../output.js';
|
|
4
|
+
export function registerTasks(program) {
|
|
5
|
+
const tasks = program
|
|
6
|
+
.command('tasks')
|
|
7
|
+
.description('Manage execution tasks');
|
|
8
|
+
tasks
|
|
9
|
+
.command('list', { isDefault: true })
|
|
10
|
+
.description('List all tasks')
|
|
11
|
+
.action(async () => {
|
|
12
|
+
const json = program.opts().json;
|
|
13
|
+
const data = await get('/api/admin/task');
|
|
14
|
+
if (json) {
|
|
15
|
+
renderJson(data);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!data?.length) {
|
|
19
|
+
process.stdout.write('No tasks found.\n');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
renderTable(['ID', 'Command', 'Created', 'Clients'], data.map(t => [
|
|
23
|
+
t.id,
|
|
24
|
+
t.command,
|
|
25
|
+
t.created_at,
|
|
26
|
+
String(t.clients?.length ?? 0),
|
|
27
|
+
]));
|
|
28
|
+
});
|
|
29
|
+
tasks
|
|
30
|
+
.command('result')
|
|
31
|
+
.description('Show task execution results')
|
|
32
|
+
.argument('<id>', 'Task ID')
|
|
33
|
+
.action(async (id) => {
|
|
34
|
+
const json = program.opts().json;
|
|
35
|
+
const results = await get(`/api/admin/task/${id}/result`);
|
|
36
|
+
if (json) {
|
|
37
|
+
renderJson(results);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!results?.length) {
|
|
41
|
+
process.stdout.write('No results found.\n');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
renderTable(['Client', 'Exit Code', 'Finished', 'Output'], results.map(r => [
|
|
45
|
+
r.client_name,
|
|
46
|
+
String(r.exit_code),
|
|
47
|
+
r.finished_at,
|
|
48
|
+
r.result?.slice(0, 80) ?? '',
|
|
49
|
+
]));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=tasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../src/komari/commands/tasks.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,cAAc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AC3B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAqB,CAAC,IAAI,CAAA;QACnD,MAAM,OAAO,GAAG,MAAM,GAAG,CAAe,mBAAmB,EAAE,SAAS,CAAC,CAAA;QAEvE,IAAI,IAAI,EAAE,CAAC;YACT,UAAU,CAAC,OAAO,CAAC,CAAA;YACnB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;YAC3C,OAAM;QACR,CAAC;QAED,WAAW,CACT,CAAC,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAC,EAC7C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACf,CAAC,CAAC,WAAW;YACb,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;YACnB,CAAC,CAAC,WAAW;YACb,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE;SAC7B,CAAC,CACH,CAAA;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/komari/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import { registerExec } from './commands/exec.js';
|
|
5
|
+
import { registerLogs } from './commands/logs.js';
|
|
6
|
+
import { registerNodes } from './commands/nodes.js';
|
|
7
|
+
import { registerPing } from './commands/ping.js';
|
|
8
|
+
import { registerRecords } from './commands/records.js';
|
|
9
|
+
import { registerStatus } from './commands/status.js';
|
|
10
|
+
import { registerTasks } from './commands/tasks.js';
|
|
11
|
+
program
|
|
12
|
+
.name('komari')
|
|
13
|
+
.description('Komari server monitor CLI')
|
|
14
|
+
.option('--json', 'Emit JSON output');
|
|
15
|
+
registerNodes(program);
|
|
16
|
+
registerStatus(program);
|
|
17
|
+
registerRecords(program);
|
|
18
|
+
registerPing(program);
|
|
19
|
+
registerExec(program);
|
|
20
|
+
registerTasks(program);
|
|
21
|
+
registerLogs(program);
|
|
22
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
23
|
+
if (err instanceof Error) {
|
|
24
|
+
console.error(err.message);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
console.error(String(err));
|
|
28
|
+
}
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/komari/index.ts"],"names":[],"mappings":";AACA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,2BAA2B,CAAC;KACxC,MAAM,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAA;AAEvC,aAAa,CAAC,OAAO,CAAC,CAAA;AACtB,cAAc,CAAC,OAAO,CAAC,CAAA;AACvB,eAAe,CAAC,OAAO,CAAC,CAAA;AACxB,YAAY,CAAC,OAAO,CAAC,CAAA;AACrB,YAAY,CAAC,OAAO,CAAC,CAAA;AACrB,aAAa,CAAC,OAAO,CAAC,CAAA;AACtB,YAAY,CAAC,OAAO,CAAC,CAAA;AAErB,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC7C,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;SACI,CAAC;QACJ,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IAC5B,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function renderTable(headers: string[], rows: string[][]): void;
|
|
2
|
+
export declare function renderJson(data: unknown): void;
|
|
3
|
+
export declare function renderKeyValue(pairs: [string, string][]): void;
|
|
4
|
+
export declare function formatBytes(bytes: number): string;
|
|
5
|
+
export declare function formatUptime(seconds: number): string;
|
|
6
|
+
export declare function formatPercent(value: number): string;
|
|
7
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/komari/output.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,CAMrE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAE9C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI,CAK9D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CASpD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import Table from 'cli-table3';
|
|
3
|
+
export function renderTable(headers, rows) {
|
|
4
|
+
const table = new Table({ head: headers });
|
|
5
|
+
for (const row of rows) {
|
|
6
|
+
table.push(row);
|
|
7
|
+
}
|
|
8
|
+
process.stdout.write(`${table.toString()}\n`);
|
|
9
|
+
}
|
|
10
|
+
export function renderJson(data) {
|
|
11
|
+
process.stdout.write(`${JSON.stringify(data, null, 2)}\n`);
|
|
12
|
+
}
|
|
13
|
+
export function renderKeyValue(pairs) {
|
|
14
|
+
const maxKeyLen = Math.max(...pairs.map(([k]) => k.length));
|
|
15
|
+
for (const [key, value] of pairs) {
|
|
16
|
+
process.stdout.write(`${key.padEnd(maxKeyLen)} ${value}\n`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function formatBytes(bytes) {
|
|
20
|
+
if (bytes === 0)
|
|
21
|
+
return '0 B';
|
|
22
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
23
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
24
|
+
return `${(bytes / 1024 ** i).toFixed(1)} ${units[i]}`;
|
|
25
|
+
}
|
|
26
|
+
export function formatUptime(seconds) {
|
|
27
|
+
const days = Math.floor(seconds / 86400);
|
|
28
|
+
const hours = Math.floor((seconds % 86400) / 3600);
|
|
29
|
+
const mins = Math.floor((seconds % 3600) / 60);
|
|
30
|
+
if (days > 0)
|
|
31
|
+
return `${days}d ${hours}h ${mins}m`;
|
|
32
|
+
if (hours > 0)
|
|
33
|
+
return `${hours}h ${mins}m`;
|
|
34
|
+
return `${mins}m`;
|
|
35
|
+
}
|
|
36
|
+
export function formatPercent(value) {
|
|
37
|
+
return `${value.toFixed(1)}%`;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=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E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IAC3C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;IACtD,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AACxD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,CAAA;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;IAClD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IAC9C,IAAI,IAAI,GAAG,CAAC;QACV,OAAO,GAAG,IAAI,KAAK,KAAK,KAAK,IAAI,GAAG,CAAA;IACtC,IAAI,KAAK,GAAG,CAAC;QACX,OAAO,GAAG,KAAK,KAAK,IAAI,GAAG,CAAA;IAC7B,OAAO,GAAG,IAAI,GAAG,CAAA;AACnB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA;AAC/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equt/clis",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.16",
|
|
5
5
|
"packageManager": "bun@1.3.10",
|
|
6
6
|
"bin": {
|
|
7
|
-
"bookkeeping": "./dist/bookkeeping/index.js"
|
|
7
|
+
"bookkeeping": "./dist/bookkeeping/index.js",
|
|
8
|
+
"komari": "./dist/komari/index.js"
|
|
8
9
|
},
|
|
9
10
|
"publishConfig": {
|
|
10
11
|
"access": "public"
|