burnboard-cli 0.2.2 → 0.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/cli.mjs +17 -2
- package/install/burnboard-setup.sh +72 -2
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -43,6 +43,19 @@ function setup(nameOverride) {
|
|
|
43
43
|
return status;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
async function connect() {
|
|
47
|
+
const code = option("--code", args.find((value) => !value.startsWith("-")));
|
|
48
|
+
const server = option("--server", "https://burnboard-public.vercel.app");
|
|
49
|
+
if (!code || code.startsWith("--")) throw new Error("A connection code is required. Copy the command shown on your BurnBoard profile.");
|
|
50
|
+
console.log("Connecting this computer to BurnBoard...");
|
|
51
|
+
const response = await fetch(`${server}/api/connect`, { method:"POST", headers:{"content-type":"application/json"}, body:JSON.stringify({ code, deviceName:os.hostname(), platform:process.platform, cliVersion }) });
|
|
52
|
+
const body = await response.json().catch(() => ({}));
|
|
53
|
+
if (!response.ok) throw new Error(body.error || "The connection code could not be used.");
|
|
54
|
+
fs.mkdirSync(burnboardRoot, { recursive:true });
|
|
55
|
+
fs.writeFileSync(path.join(burnboardRoot, "config.json"), `${JSON.stringify({ serverUrl:server, token:body.token, profileUrl:body.profileUrl }, null, 2)}\n`);
|
|
56
|
+
if (setup("Connected BurnBoard User") !== 0) throw new Error("Connected, but the local tracker could not be installed. Run the same command again to repair it.");
|
|
57
|
+
}
|
|
58
|
+
|
|
46
59
|
function update() {
|
|
47
60
|
const configPath = path.join(burnboardRoot, "config.json");
|
|
48
61
|
if (!fs.existsSync(configPath)) throw new Error("BurnBoard is not installed. Run the setup command first.");
|
|
@@ -85,14 +98,16 @@ function status() {
|
|
|
85
98
|
function help() {
|
|
86
99
|
console.log(`BurnBoard CLI
|
|
87
100
|
|
|
88
|
-
burnboard
|
|
101
|
+
burnboard connect --code BB-... Connect this computer from your profile
|
|
102
|
+
burnboard setup --name "Your Name" Repair an existing installation
|
|
89
103
|
burnboard sync Sync usage now
|
|
90
104
|
burnboard update Update tracker and scheduling now
|
|
91
105
|
burnboard status Check the local installation`);
|
|
92
106
|
}
|
|
93
107
|
|
|
94
108
|
try {
|
|
95
|
-
if (command === "
|
|
109
|
+
if (command === "connect") await connect();
|
|
110
|
+
else if (command === "setup") setup();
|
|
96
111
|
else if (command === "sync") sync();
|
|
97
112
|
else if (command === "update") update();
|
|
98
113
|
else if (command === "status") status();
|
|
@@ -16,10 +16,80 @@ node -e 'require("fs").writeFileSync(process.argv[1],JSON.stringify({serverUrl:p
|
|
|
16
16
|
node - "$HOME/.claude/settings.json" <<'NODE'
|
|
17
17
|
const fs=require('fs'),file=process.argv[2],current=fs.existsSync(file)?JSON.parse(fs.readFileSync(file,'utf8')):{};current.env=current.env||{};for(const key of ['CLAUDE_CODE_ENABLE_TELEMETRY','OTEL_METRICS_EXPORTER','OTEL_LOGS_EXPORTER','OTEL_EXPORTER_OTLP_METRICS_PROTOCOL','OTEL_EXPORTER_OTLP_METRICS_ENDPOINT','OTEL_EXPORTER_OTLP_METRICS_HEADERS','OTEL_METRIC_EXPORT_INTERVAL','OTEL_METRICS_INCLUDE_SESSION_ID'])delete current.env[key];fs.writeFileSync(file,JSON.stringify(current,null,2)+"\n");
|
|
18
18
|
NODE
|
|
19
|
-
printf '[3/5] Scheduling automatic sync...\n'
|
|
19
|
+
printf '[3/5] Scheduling automatic sync...\n'
|
|
20
|
+
NODE_BIN="$(command -v node)"; NPX_BIN="$(command -v npx)"
|
|
21
|
+
if command -v crontab >/dev/null 2>&1; then
|
|
22
|
+
(crontab -l 2>/dev/null|grep -Ev 'burnboard/agent.mjs|burnboard-cli@latest update'||true;echo "*/5 * * * * $NODE_BIN $INSTALL_DIR/agent.mjs >/dev/null 2>&1";echo "0 4 * * * $NPX_BIN --yes --prefer-online burnboard-cli@latest update >/dev/null 2>&1";echo "@reboot sleep 180 && $NPX_BIN --yes --prefer-online burnboard-cli@latest update >/dev/null 2>&1")|crontab -
|
|
23
|
+
SCHEDULER="cron"
|
|
24
|
+
elif command -v systemctl >/dev/null 2>&1 && systemctl --user show-environment >/dev/null 2>&1; then
|
|
25
|
+
UNIT_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"; mkdir -p "$UNIT_DIR"
|
|
26
|
+
cat >"$UNIT_DIR/burnboard-sync.service" <<EOF
|
|
27
|
+
[Unit]
|
|
28
|
+
Description=BurnBoard token sync
|
|
29
|
+
[Service]
|
|
30
|
+
Type=oneshot
|
|
31
|
+
ExecStart=$NODE_BIN %h/.burnboard/agent.mjs
|
|
32
|
+
EOF
|
|
33
|
+
cat >"$UNIT_DIR/burnboard-sync.timer" <<'EOF'
|
|
34
|
+
[Unit]
|
|
35
|
+
Description=Sync BurnBoard usage every five minutes
|
|
36
|
+
[Timer]
|
|
37
|
+
OnBootSec=2min
|
|
38
|
+
OnUnitActiveSec=5min
|
|
39
|
+
AccuracySec=30s
|
|
40
|
+
Persistent=true
|
|
41
|
+
[Install]
|
|
42
|
+
WantedBy=timers.target
|
|
43
|
+
EOF
|
|
44
|
+
cat >"$UNIT_DIR/burnboard-update.service" <<EOF
|
|
45
|
+
[Unit]
|
|
46
|
+
Description=Update BurnBoard tracker
|
|
47
|
+
[Service]
|
|
48
|
+
Type=oneshot
|
|
49
|
+
ExecStart=$NPX_BIN --yes --prefer-online burnboard-cli@latest update
|
|
50
|
+
EOF
|
|
51
|
+
cat >"$UNIT_DIR/burnboard-update.timer" <<'EOF'
|
|
52
|
+
[Unit]
|
|
53
|
+
Description=Check for BurnBoard updates daily
|
|
54
|
+
[Timer]
|
|
55
|
+
OnBootSec=3min
|
|
56
|
+
OnUnitActiveSec=1d
|
|
57
|
+
AccuracySec=10min
|
|
58
|
+
Persistent=true
|
|
59
|
+
[Install]
|
|
60
|
+
WantedBy=timers.target
|
|
61
|
+
EOF
|
|
62
|
+
systemctl --user daemon-reload
|
|
63
|
+
systemctl --user enable --now burnboard-sync.timer burnboard-update.timer >/dev/null
|
|
64
|
+
SCHEDULER="systemd user timers"
|
|
65
|
+
else
|
|
66
|
+
LOOP="$INSTALL_DIR/run-loop.sh"
|
|
67
|
+
cat >"$LOOP" <<EOF
|
|
68
|
+
#!/usr/bin/env sh
|
|
69
|
+
while :; do
|
|
70
|
+
"$NODE_BIN" "$INSTALL_DIR/agent.mjs" >/dev/null 2>&1
|
|
71
|
+
now=\$(date +%s); last=0; [ -f "$INSTALL_DIR/last-loop-update" ] && last=\$(cat "$INSTALL_DIR/last-loop-update" 2>/dev/null || echo 0)
|
|
72
|
+
if [ \$((now-last)) -ge 86400 ]; then "$NPX_BIN" --yes --prefer-online burnboard-cli@latest update >/dev/null 2>&1 && printf '%s' "\$now" >"$INSTALL_DIR/last-loop-update"; fi
|
|
73
|
+
sleep 300
|
|
74
|
+
done
|
|
75
|
+
EOF
|
|
76
|
+
chmod 700 "$LOOP"
|
|
77
|
+
if [[ -f "$INSTALL_DIR/loop.pid" ]]; then OLD_PID="$(cat "$INSTALL_DIR/loop.pid" 2>/dev/null || true)"; if [[ -n "$OLD_PID" && -r "/proc/$OLD_PID/cmdline" ]] && tr '\0' ' ' <"/proc/$OLD_PID/cmdline" | grep -q 'run-loop.sh'; then kill "$OLD_PID" 2>/dev/null || true; fi; fi
|
|
78
|
+
nohup "$LOOP" </dev/null >"$INSTALL_DIR/loop.log" 2>&1 & echo $! >"$INSTALL_DIR/loop.pid"
|
|
79
|
+
AUTOSTART_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/autostart"; mkdir -p "$AUTOSTART_DIR"
|
|
80
|
+
cat >"$AUTOSTART_DIR/burnboard.desktop" <<EOF
|
|
81
|
+
[Desktop Entry]
|
|
82
|
+
Type=Application
|
|
83
|
+
Name=BurnBoard Sync
|
|
84
|
+
Exec=$LOOP
|
|
85
|
+
Terminal=false
|
|
86
|
+
X-GNOME-Autostart-enabled=true
|
|
87
|
+
EOF
|
|
88
|
+
SCHEDULER="portable background service"
|
|
89
|
+
fi
|
|
20
90
|
if [[ "$(uname -s)" == "Darwin" ]] && ! pgrep -x Antigravity >/dev/null 2>&1 && [[ -d "/Applications/Antigravity.app" ]]; then open -a Antigravity; sleep 8; fi
|
|
21
91
|
printf '[4/5] Counting and uploading local history'; OUT="$INSTALL_DIR/setup-sync.out"; ERR="$INSTALL_DIR/setup-sync.err"; node "$INSTALL_DIR/agent.mjs" >"$OUT" 2>"$ERR" & PID=$!
|
|
22
92
|
while kill -0 "$PID" 2>/dev/null; do printf '.'; sleep 1; done
|
|
23
93
|
if ! wait "$PID"; then printf '\n'; cat "$ERR" >&2; rm -f "$OUT" "$ERR"; exit 1; fi
|
|
24
94
|
printf '\n[5/5] Complete\n'; cat "$OUT"; rm -f "$OUT" "$ERR"
|
|
25
|
-
echo "Burnboard is connected: $SERVER_URL$PROFILE"; echo "Codex, Claude Code, Cursor, and both supported Antigravity installations sync every 5 minutes. Burnboard checks for updates daily."
|
|
95
|
+
echo "Burnboard is connected: $SERVER_URL$PROFILE"; echo "Codex, Claude Code, Cursor, and both supported Antigravity installations sync every 5 minutes using $SCHEDULER. Burnboard checks for updates daily."
|