@rehpic/vcli 0.1.0-beta.40.1 → 0.1.0-beta.41.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/index.js +65 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1386,7 +1386,7 @@ function installLaunchAgent(vcliPath) {
|
|
|
1386
1386
|
<array>
|
|
1387
1387
|
<string>${vcliPath}</string>
|
|
1388
1388
|
<string>service</string>
|
|
1389
|
-
<string>
|
|
1389
|
+
<string>run</string>
|
|
1390
1390
|
</array>
|
|
1391
1391
|
<key>RunAtLoad</key>
|
|
1392
1392
|
<true/>
|
|
@@ -1466,6 +1466,25 @@ function uninstallLaunchAgent() {
|
|
|
1466
1466
|
} catch {
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
1469
|
+
async function launchMenuBar() {
|
|
1470
|
+
if (platform() !== "darwin") return;
|
|
1471
|
+
const candidates = [
|
|
1472
|
+
join(CONFIG_DIR, "VectorMenuBar"),
|
|
1473
|
+
"/usr/local/bin/VectorMenuBar",
|
|
1474
|
+
join(homedir2(), ".local", "bin", "VectorMenuBar")
|
|
1475
|
+
];
|
|
1476
|
+
const binary = candidates.find((p) => existsSync(p));
|
|
1477
|
+
if (!binary) {
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
try {
|
|
1481
|
+
const { spawn: spawnProcess } = await import("child_process");
|
|
1482
|
+
const child = spawnProcess(binary, [], { detached: true, stdio: "ignore" });
|
|
1483
|
+
child.unref();
|
|
1484
|
+
console.log("Menu bar started.");
|
|
1485
|
+
} catch {
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1469
1488
|
function getBridgeStatus() {
|
|
1470
1489
|
const config = loadBridgeConfig();
|
|
1471
1490
|
if (!config) return { configured: false, running: false };
|
|
@@ -3489,7 +3508,46 @@ folderCommand.command("delete <folderId>").action(async (folderId, _options, com
|
|
|
3489
3508
|
printOutput(result, runtime.json);
|
|
3490
3509
|
});
|
|
3491
3510
|
var serviceCommand = program.command("service").description("Manage the local bridge service");
|
|
3492
|
-
serviceCommand.command("start").description("
|
|
3511
|
+
serviceCommand.command("start").description("Start the bridge service via LaunchAgent (macOS) or foreground").action(async (_options, command) => {
|
|
3512
|
+
const existing = getBridgeStatus();
|
|
3513
|
+
if (existing.running) {
|
|
3514
|
+
console.log(`Bridge is already running (PID ${existing.pid}).`);
|
|
3515
|
+
return;
|
|
3516
|
+
}
|
|
3517
|
+
let config = loadBridgeConfig();
|
|
3518
|
+
if (!config) {
|
|
3519
|
+
const runtime = await getRuntime(command);
|
|
3520
|
+
const session = requireSession(runtime);
|
|
3521
|
+
const client = await createConvexClient(
|
|
3522
|
+
session,
|
|
3523
|
+
runtime.appUrl,
|
|
3524
|
+
runtime.convexUrl
|
|
3525
|
+
);
|
|
3526
|
+
const user = await runQuery(client, api.users.currentUser);
|
|
3527
|
+
if (!user) throw new Error("Not logged in. Run `vcli auth login` first.");
|
|
3528
|
+
config = await setupBridgeDevice(runtime.convexUrl, user._id);
|
|
3529
|
+
console.log(
|
|
3530
|
+
`Device registered: ${config.displayName} (${config.deviceId})`
|
|
3531
|
+
);
|
|
3532
|
+
}
|
|
3533
|
+
if (osPlatform() === "darwin") {
|
|
3534
|
+
const vcliPath = process.argv[1] ?? "vcli";
|
|
3535
|
+
installLaunchAgent(vcliPath);
|
|
3536
|
+
loadLaunchAgent();
|
|
3537
|
+
await launchMenuBar();
|
|
3538
|
+
console.log("Bridge service started.");
|
|
3539
|
+
console.log("");
|
|
3540
|
+
console.log("Run `vcli service status` to check.");
|
|
3541
|
+
console.log("Run `vcli service stop` to stop.");
|
|
3542
|
+
} else {
|
|
3543
|
+
console.log(
|
|
3544
|
+
"Starting bridge in foreground (use systemd for background)..."
|
|
3545
|
+
);
|
|
3546
|
+
const bridge = new BridgeService(config);
|
|
3547
|
+
await bridge.run();
|
|
3548
|
+
}
|
|
3549
|
+
});
|
|
3550
|
+
serviceCommand.command("run").description("Run the bridge service in the foreground (used by LaunchAgent)").action(async (_options, command) => {
|
|
3493
3551
|
let config = loadBridgeConfig();
|
|
3494
3552
|
if (!config) {
|
|
3495
3553
|
const runtime = await getRuntime(command);
|
|
@@ -3502,15 +3560,17 @@ serviceCommand.command("start").description("Run the bridge service in the foreg
|
|
|
3502
3560
|
const user = await runQuery(client, api.users.currentUser);
|
|
3503
3561
|
if (!user) throw new Error("Not logged in. Run `vcli auth login` first.");
|
|
3504
3562
|
config = await setupBridgeDevice(runtime.convexUrl, user._id);
|
|
3505
|
-
console.log(`Device registered: ${config.deviceId}`);
|
|
3506
3563
|
}
|
|
3507
3564
|
const bridge = new BridgeService(config);
|
|
3508
3565
|
await bridge.run();
|
|
3509
3566
|
});
|
|
3510
|
-
serviceCommand.command("stop").description("Stop the
|
|
3567
|
+
serviceCommand.command("stop").description("Stop the bridge service and menu bar").action(() => {
|
|
3568
|
+
if (osPlatform() === "darwin") {
|
|
3569
|
+
unloadLaunchAgent();
|
|
3570
|
+
}
|
|
3511
3571
|
if (stopBridge()) {
|
|
3512
3572
|
console.log("Bridge stopped.");
|
|
3513
|
-
} else {
|
|
3573
|
+
} else if (osPlatform() !== "darwin") {
|
|
3514
3574
|
console.log("Bridge is not running.");
|
|
3515
3575
|
}
|
|
3516
3576
|
});
|