@zoer7788/mcp-nexus-node 0.1.3 → 0.1.4
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.js +20 -0
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -403,6 +403,25 @@ function patchProject(name, body) {
|
|
|
403
403
|
return { ...projectStatus(project), config: cfg, restart_required: true };
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
+
function renameProject(name, body) {
|
|
407
|
+
const newName = String(body.name || "").trim();
|
|
408
|
+
if (!newName) throw new Error("new name is required");
|
|
409
|
+
const items = projects();
|
|
410
|
+
const project = items.find((p) => p.name === name);
|
|
411
|
+
if (!project) throw new Error(`project not found: ${name}`);
|
|
412
|
+
if (items.some((p) => p.name === newName)) throw new Error(`project already exists: ${newName}`);
|
|
413
|
+
project.name = newName;
|
|
414
|
+
saveProjects(items);
|
|
415
|
+
for (const suffix of [".out", "-cloudflared.out"]) {
|
|
416
|
+
const oldPath = join(logDir, `${name}${suffix}`);
|
|
417
|
+
const newPath = join(logDir, `${newName}${suffix}`);
|
|
418
|
+
if (existsSync(oldPath) && !existsSync(newPath)) {
|
|
419
|
+
try { writeFileSync(newPath, readFileSync(oldPath)); } catch {}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return projectStatus(project);
|
|
423
|
+
}
|
|
424
|
+
|
|
406
425
|
function deleteProject(name) {
|
|
407
426
|
stopProject(name);
|
|
408
427
|
saveProjects(projects().filter((p) => p.name !== name));
|
|
@@ -433,6 +452,7 @@ function serve() {
|
|
|
433
452
|
const name = decodeURIComponent(match[1]);
|
|
434
453
|
const action = match[2] || "";
|
|
435
454
|
if (req.method === "PATCH" && action === "config") return json(res, 200, patchProject(name, await readJson(req)));
|
|
455
|
+
if (req.method === "PATCH" && action === "name") return json(res, 200, renameProject(name, await readJson(req)));
|
|
436
456
|
if (req.method === "POST" && action === "start") return json(res, 200, startProject(name));
|
|
437
457
|
if (req.method === "POST" && action === "stop") return json(res, 200, stopProject(name));
|
|
438
458
|
if (req.method === "POST" && action === "restart") { stopProject(name); return json(res, 200, startProject(name)); }
|