burnboard-cli 0.2.2 → 0.3.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.
- package/cli.mjs +17 -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();
|