tanuki-telemetry 1.2.0 → 1.3.1
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/cli.js +88 -10
- package/dist/setup.d.ts +1 -0
- package/dist/setup.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,86 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { setup } from "./setup.js";
|
|
3
3
|
import { start, stop, status } from "./commands.js";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { execSync } from "node:child_process";
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
async function getLocalVersion() {
|
|
10
|
+
const pkg = JSON.parse(await readFile(join(__dirname, "..", "package.json"), "utf-8"));
|
|
11
|
+
return pkg.version;
|
|
12
|
+
}
|
|
13
|
+
async function getLatestVersion() {
|
|
14
|
+
try {
|
|
15
|
+
const result = execSync("npm view tanuki-telemetry version 2>/dev/null", {
|
|
16
|
+
encoding: "utf-8",
|
|
17
|
+
timeout: 5000,
|
|
18
|
+
}).trim();
|
|
19
|
+
return result || null;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function checkForUpdates() {
|
|
26
|
+
const [local, latest] = await Promise.all([getLocalVersion(), getLatestVersion()]);
|
|
27
|
+
if (!latest)
|
|
28
|
+
return; // Can't reach registry, skip silently
|
|
29
|
+
if (local !== latest) {
|
|
30
|
+
console.log(`\n ⬆ Update available: ${local} → ${latest}`);
|
|
31
|
+
console.log(` Run: npx tanuki-telemetry@latest setup\n`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function update() {
|
|
35
|
+
const local = await getLocalVersion();
|
|
36
|
+
const latest = await getLatestVersion();
|
|
37
|
+
console.log(`\ntanuki-telemetry update`);
|
|
38
|
+
console.log(` Local: ${local}`);
|
|
39
|
+
console.log(` Latest: ${latest ?? "unknown"}\n`);
|
|
40
|
+
if (latest && local === latest) {
|
|
41
|
+
console.log(" Already up to date.\n");
|
|
42
|
+
}
|
|
43
|
+
// 1. Update command templates
|
|
44
|
+
console.log(" Updating command templates...");
|
|
45
|
+
const { installAllTemplateCommands } = await import("./setup.js");
|
|
46
|
+
if (typeof installAllTemplateCommands === "function") {
|
|
47
|
+
await installAllTemplateCommands();
|
|
48
|
+
}
|
|
49
|
+
// 2. Stop existing container
|
|
50
|
+
console.log(" Stopping existing dashboard...");
|
|
51
|
+
try {
|
|
52
|
+
execSync("docker compose -f ~/.claude/mcp-servers/telemetry/docker-compose.yml down 2>&1", { stdio: "inherit", timeout: 30000 });
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// May not be running, that's fine
|
|
56
|
+
}
|
|
57
|
+
// 3. Rebuild Docker image
|
|
58
|
+
console.log(" Rebuilding Docker image...");
|
|
59
|
+
try {
|
|
60
|
+
execSync("docker compose -f ~/.claude/mcp-servers/telemetry/docker-compose.yml build --no-cache 2>&1", { stdio: "inherit", timeout: 300000 });
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
console.log(" Docker rebuild failed — is Docker running?");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// 4. Start fresh container
|
|
67
|
+
console.log(" Starting dashboard...");
|
|
68
|
+
try {
|
|
69
|
+
execSync("docker compose -f ~/.claude/mcp-servers/telemetry/docker-compose.yml up dashboard -d 2>&1", { stdio: "inherit", timeout: 60000 });
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
console.log(" Start failed — try manually: docker compose up dashboard -d");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
console.log("\n Update complete! Dashboard at http://localhost:3333\n");
|
|
76
|
+
}
|
|
4
77
|
const command = process.argv[2];
|
|
5
78
|
const commands = {
|
|
6
79
|
setup: () => setup(),
|
|
7
80
|
start: () => start(),
|
|
8
81
|
stop: () => stop(),
|
|
9
82
|
status: () => status(),
|
|
83
|
+
update: () => update(),
|
|
10
84
|
};
|
|
11
85
|
const handler = commands[command];
|
|
12
86
|
if (handler) {
|
|
@@ -16,17 +90,21 @@ if (handler) {
|
|
|
16
90
|
});
|
|
17
91
|
}
|
|
18
92
|
else {
|
|
19
|
-
|
|
20
|
-
|
|
93
|
+
// Show help + version check
|
|
94
|
+
checkForUpdates().then(() => {
|
|
95
|
+
console.log(`
|
|
96
|
+
tanuki-telemetry — Telemetry MCP for Claude Code
|
|
21
97
|
|
|
22
98
|
Usage:
|
|
23
|
-
npx
|
|
24
|
-
npx
|
|
25
|
-
npx
|
|
26
|
-
npx
|
|
99
|
+
npx tanuki-telemetry setup Interactive setup wizard
|
|
100
|
+
npx tanuki-telemetry start Start the dashboard
|
|
101
|
+
npx tanuki-telemetry stop Stop the dashboard
|
|
102
|
+
npx tanuki-telemetry status Check container health
|
|
103
|
+
npx tanuki-telemetry update Update templates + rebuild Docker
|
|
27
104
|
`);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
105
|
+
if (command && command !== "--help" && command !== "-h") {
|
|
106
|
+
console.error(`Unknown command: ${command}`);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
32
110
|
}
|
package/dist/setup.d.ts
CHANGED
package/dist/setup.js
CHANGED
|
@@ -259,7 +259,7 @@ async function installCompareImageCommand() {
|
|
|
259
259
|
await writeFile(destPath, template);
|
|
260
260
|
console.log(" /compare-image command installed");
|
|
261
261
|
}
|
|
262
|
-
async function installAllTemplateCommands() {
|
|
262
|
+
export async function installAllTemplateCommands() {
|
|
263
263
|
await mkdir(COMMANDS_DIR, { recursive: true });
|
|
264
264
|
const templatesDir = join(__dirname, "..", "templates");
|
|
265
265
|
// Commands already handled by dedicated installers
|