@energy8platform/golem 0.1.0 → 0.1.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/lib/cli.js
CHANGED
|
@@ -5383,6 +5383,11 @@ data: ${JSON.stringify({ version: v })}
|
|
|
5383
5383
|
res.end("not found");
|
|
5384
5384
|
}
|
|
5385
5385
|
} catch (e) {
|
|
5386
|
+
if (res.headersSent) {
|
|
5387
|
+
console.error(`editor: ${req.method} ${req.url}: ${e.message}`);
|
|
5388
|
+
res.end();
|
|
5389
|
+
return;
|
|
5390
|
+
}
|
|
5386
5391
|
json(res, 500, { isError: true, text: `ERROR: ${e.message}` });
|
|
5387
5392
|
}
|
|
5388
5393
|
});
|
|
@@ -5402,11 +5407,12 @@ data: ${JSON.stringify({ version: v })}
|
|
|
5402
5407
|
res.writeHead(403);
|
|
5403
5408
|
return res.end();
|
|
5404
5409
|
}
|
|
5410
|
+
if (!await stat3(abs).then(() => true, () => false)) return json(res, 404, { isError: true, text: `ERROR: ${url.searchParams.get("rig")} does not exist under ${root3}` });
|
|
5411
|
+
ensureWatch(abs);
|
|
5405
5412
|
res.writeHead(200, { "content-type": "text/event-stream", "cache-control": "no-cache", connection: "keep-alive" });
|
|
5406
5413
|
res.write(`: connected
|
|
5407
5414
|
|
|
5408
5415
|
`);
|
|
5409
|
-
ensureWatch(abs);
|
|
5410
5416
|
(clients.get(abs) ?? clients.set(abs, /* @__PURE__ */ new Set()).get(abs)).add(res);
|
|
5411
5417
|
const hb = setInterval(() => res.write(": hb\n\n"), 15e3);
|
|
5412
5418
|
req.on("close", () => {
|
|
@@ -5514,7 +5520,8 @@ if (!Number.isInteger(port) || port < 0 || port > 65535) {
|
|
|
5514
5520
|
}
|
|
5515
5521
|
var root2 = resolve3(flag("--root") ?? ".");
|
|
5516
5522
|
var s = await startEditorServer({ root: root2, port });
|
|
5517
|
-
|
|
5523
|
+
var rigs = await (await fetch(`${s.url}/api/rigs`)).json();
|
|
5524
|
+
console.log(`golem editor: ${s.url}/editor.html${rigs[0] ? `?rig=${encodeURIComponent(rigs[0].rig)}` : ""} (${rigs.length} rig(s) under ${root2})`);
|
|
5518
5525
|
for (const sig of ["SIGINT", "SIGTERM"]) process.once(sig, () => {
|
|
5519
5526
|
void Promise.all([s.close(), closeTools()]).finally(() => process.exit(0));
|
|
5520
5527
|
});
|