@rehpic/vcli 0.1.0-beta.41.1 → 0.1.0-beta.42.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 +45 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1466,6 +1466,48 @@ function uninstallLaunchAgent() {
|
|
|
1466
1466
|
} catch {
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
1469
|
+
async function compileMenuBar() {
|
|
1470
|
+
if (platform() !== "darwin") return null;
|
|
1471
|
+
const binaryPath = join(CONFIG_DIR, "VectorMenuBar");
|
|
1472
|
+
if (existsSync(binaryPath)) return binaryPath;
|
|
1473
|
+
const sourceCandidates = [
|
|
1474
|
+
join(CONFIG_DIR, "VectorMenuBar.swift"),
|
|
1475
|
+
// In the repo checkout (dev mode)
|
|
1476
|
+
join(process.cwd(), "cli", "macos", "VectorMenuBar.swift")
|
|
1477
|
+
];
|
|
1478
|
+
const source = sourceCandidates.find((p) => existsSync(p));
|
|
1479
|
+
if (!source) return null;
|
|
1480
|
+
try {
|
|
1481
|
+
execSync("which swiftc", { stdio: "pipe" });
|
|
1482
|
+
} catch {
|
|
1483
|
+
return null;
|
|
1484
|
+
}
|
|
1485
|
+
try {
|
|
1486
|
+
console.log("Compiling menu bar app...");
|
|
1487
|
+
execSync(`swiftc -o "${binaryPath}" "${source}" -framework AppKit`, {
|
|
1488
|
+
stdio: "pipe",
|
|
1489
|
+
timeout: 3e4
|
|
1490
|
+
});
|
|
1491
|
+
const sourceDir = join(source, "..", "assets");
|
|
1492
|
+
const destDir = join(CONFIG_DIR, "assets");
|
|
1493
|
+
if (existsSync(sourceDir)) {
|
|
1494
|
+
mkdirSync(destDir, { recursive: true });
|
|
1495
|
+
for (const f of ["vector-menubar.png", "vector-menubar@2x.png"]) {
|
|
1496
|
+
const src = join(sourceDir, f);
|
|
1497
|
+
if (existsSync(src)) {
|
|
1498
|
+
writeFileSync(join(destDir, f), readFileSync(src));
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
console.log("Menu bar app compiled.");
|
|
1503
|
+
return binaryPath;
|
|
1504
|
+
} catch {
|
|
1505
|
+
console.error(
|
|
1506
|
+
"Failed to compile menu bar app (Xcode CLI tools may be needed)."
|
|
1507
|
+
);
|
|
1508
|
+
return null;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1469
1511
|
async function launchMenuBar() {
|
|
1470
1512
|
if (platform() !== "darwin") return;
|
|
1471
1513
|
const candidates = [
|
|
@@ -1473,10 +1515,11 @@ async function launchMenuBar() {
|
|
|
1473
1515
|
"/usr/local/bin/VectorMenuBar",
|
|
1474
1516
|
join(homedir2(), ".local", "bin", "VectorMenuBar")
|
|
1475
1517
|
];
|
|
1476
|
-
|
|
1518
|
+
let binary = candidates.find((p) => existsSync(p));
|
|
1477
1519
|
if (!binary) {
|
|
1478
|
-
|
|
1520
|
+
binary = await compileMenuBar() ?? void 0;
|
|
1479
1521
|
}
|
|
1522
|
+
if (!binary) return;
|
|
1480
1523
|
try {
|
|
1481
1524
|
const { spawn: spawnProcess } = await import("child_process");
|
|
1482
1525
|
const child = spawnProcess(binary, [], { detached: true, stdio: "ignore" });
|