Update arch checm (#32)
This commit is contained in:
committed by
GitHub
parent
3081ab3866
commit
7817a4fc9e
@@ -4,164 +4,123 @@ const { execSync, spawn } = require("child_process");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
// Detect platform and architecture
|
||||
// Detect true CPU arch on macOS (handles Rosetta)
|
||||
function getUnderlyingArch() {
|
||||
const platform = process.platform;
|
||||
const nodeArch = process.arch;
|
||||
|
||||
if (platform !== "darwin") {
|
||||
return nodeArch;
|
||||
}
|
||||
|
||||
// If Node itself is arm64, we’re natively on Apple silicon
|
||||
if (nodeArch === "arm64") {
|
||||
return "arm64";
|
||||
}
|
||||
|
||||
// Otherwise check for Rosetta translation
|
||||
try {
|
||||
const translated = execSync("sysctl -in sysctl.proc_translated", {
|
||||
encoding: "utf8",
|
||||
}).trim();
|
||||
if (translated === "1") {
|
||||
return "arm64";
|
||||
}
|
||||
} catch {
|
||||
// sysctl key not present → assume true Intel
|
||||
}
|
||||
|
||||
return "x64";
|
||||
}
|
||||
|
||||
const platform = process.platform;
|
||||
const arch = process.arch;
|
||||
const arch = getUnderlyingArch();
|
||||
|
||||
// Map to our build target names
|
||||
function getPlatformDir() {
|
||||
if (platform === "linux" && arch === "x64") {
|
||||
return "linux-x64";
|
||||
} else if (platform === "linux" && arch === "arm64") {
|
||||
return "linux-arm64";
|
||||
} else if (platform === "win32" && arch === "x64") {
|
||||
return "windows-x64";
|
||||
} else if (platform === "win32" && arch === "arm64") {
|
||||
return "windows-arm64";
|
||||
} else if (platform === "darwin" && arch === "x64") {
|
||||
return "macos-x64";
|
||||
} else if (platform === "darwin" && arch === "arm64") {
|
||||
return "macos-arm64";
|
||||
} else {
|
||||
console.error(`❌ Unsupported platform: ${platform}-${arch}`);
|
||||
console.error("Supported platforms:");
|
||||
console.error(" - Linux x64");
|
||||
console.error(" - Linux ARM64");
|
||||
console.error(" - Windows x64");
|
||||
console.error(" - Windows ARM64");
|
||||
console.error(" - macOS x64 (Intel)");
|
||||
console.error(" - macOS ARM64 (Apple Silicon)");
|
||||
process.exit(1);
|
||||
}
|
||||
if (platform === "linux" && arch === "x64") return "linux-x64";
|
||||
if (platform === "linux" && arch === "arm64") return "linux-arm64";
|
||||
if (platform === "win32" && arch === "x64") return "windows-x64";
|
||||
if (platform === "win32" && arch === "arm64") return "windows-arm64";
|
||||
if (platform === "darwin" && arch === "x64") return "macos-x64";
|
||||
if (platform === "darwin" && arch === "arm64") return "macos-arm64";
|
||||
|
||||
console.error(`❌ Unsupported platform: ${platform}-${arch}`);
|
||||
console.error("Supported platforms:");
|
||||
console.error(" - Linux x64");
|
||||
console.error(" - Linux ARM64");
|
||||
console.error(" - Windows x64");
|
||||
console.error(" - Windows ARM64");
|
||||
console.error(" - macOS x64 (Intel)");
|
||||
console.error(" - macOS ARM64 (Apple Silicon)");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function getBinaryName(base_name) {
|
||||
return platform === "win32" ? `${base_name}.exe` : base_name;
|
||||
function getBinaryName(base) {
|
||||
return platform === "win32" ? `${base}.exe` : base;
|
||||
}
|
||||
|
||||
const platformDir = getPlatformDir();
|
||||
const extractDir = path.join(__dirname, "..", "dist", platformDir);
|
||||
|
||||
const isMcpMode = process.argv.includes("--mcp");
|
||||
|
||||
if (!fs.existsSync(extractDir)) {
|
||||
fs.mkdirSync(extractDir, { recursive: true });
|
||||
}
|
||||
// ensure output dir
|
||||
fs.mkdirSync(extractDir, { recursive: true });
|
||||
|
||||
if (isMcpMode) {
|
||||
const baseName = "vibe-kanban-mcp";
|
||||
const binaryName = getBinaryName(baseName);
|
||||
const binaryPath = path.join(extractDir, binaryName);
|
||||
function extractAndRun(baseName, launch) {
|
||||
const binName = getBinaryName(baseName);
|
||||
const binPath = path.join(extractDir, binName);
|
||||
const zipName = `${baseName}.zip`;
|
||||
const zipPath = path.join(extractDir, zipName);
|
||||
|
||||
// Check if binary exists, delete if it does
|
||||
if (fs.existsSync(binaryPath)) {
|
||||
fs.unlinkSync(binaryPath);
|
||||
}
|
||||
|
||||
// Check if zip file exists
|
||||
if (!fs.existsSync(zipPath)) {
|
||||
// console.error(`❌ ${zipName} not found at: ${zipPath}`);
|
||||
// console.error(`Current platform: ${platform}-${arch} (${platformDir})`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Unzip the file
|
||||
// console.log(`📦 Extracting ${baseName}...`);
|
||||
if (platform === "win32") {
|
||||
// Use PowerShell on Windows
|
||||
execSync(
|
||||
`powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${extractDir}' -Force"`,
|
||||
{ stdio: "inherit" }
|
||||
);
|
||||
} else {
|
||||
// Use unzip on Unix-like systems
|
||||
execSync(`unzip -qq -o "${zipPath}" -d "${extractDir}"`, {
|
||||
stdio: "inherit",
|
||||
});
|
||||
}
|
||||
|
||||
// Make sure it's executable
|
||||
try {
|
||||
fs.chmodSync(binaryPath, 0o755);
|
||||
} catch (error) {
|
||||
// console.error(
|
||||
// "⚠️ Warning: Could not set executable permissions:",
|
||||
// error.message
|
||||
// );
|
||||
}
|
||||
|
||||
// Launch MCP server
|
||||
// console.error(`🚀 Starting ${baseName}...`);
|
||||
|
||||
const mcpProcess = spawn(binaryPath, [], {
|
||||
stdio: ["pipe", "pipe", "inherit"], // stdin/stdout for MCP, stderr for logs
|
||||
});
|
||||
|
||||
// Forward stdin to MCP server
|
||||
process.stdin.pipe(mcpProcess.stdin);
|
||||
|
||||
// Forward MCP server stdout to our stdout
|
||||
mcpProcess.stdout.pipe(process.stdout);
|
||||
|
||||
// Handle process termination
|
||||
mcpProcess.on("exit", (code) => {
|
||||
process.exit(code || 0);
|
||||
});
|
||||
|
||||
mcpProcess.on("error", (error) => {
|
||||
console.error("❌ MCP server error:", error.message);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// Handle Ctrl+C
|
||||
process.on("SIGINT", () => {
|
||||
console.error("\n🛑 Shutting down MCP server...");
|
||||
mcpProcess.kill("SIGINT");
|
||||
});
|
||||
|
||||
process.on("SIGTERM", () => {
|
||||
mcpProcess.kill("SIGTERM");
|
||||
});
|
||||
} else {
|
||||
const baseName = "vibe-kanban";
|
||||
const binaryName = getBinaryName(baseName);
|
||||
const binaryPath = path.join(extractDir, binaryName);
|
||||
const zipName = `${baseName}.zip`;
|
||||
const zipPath = path.join(extractDir, zipName);
|
||||
|
||||
// Check if binary exists, delete if it does
|
||||
if (fs.existsSync(binaryPath)) {
|
||||
fs.unlinkSync(binaryPath);
|
||||
}
|
||||
|
||||
// Check if zip file exists
|
||||
// clean old binary
|
||||
if (fs.existsSync(binPath)) fs.unlinkSync(binPath);
|
||||
if (!fs.existsSync(zipPath)) {
|
||||
console.error(`❌ ${zipName} not found at: ${zipPath}`);
|
||||
console.error(`Current platform: ${platform}-${arch} (${platformDir})`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Unzip the file
|
||||
console.log(`📦 Extracting ${baseName}...`);
|
||||
if (platform === "win32") {
|
||||
// Use PowerShell on Windows
|
||||
execSync(
|
||||
`powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${extractDir}' -Force"`,
|
||||
{ stdio: "inherit" }
|
||||
);
|
||||
} else {
|
||||
// Use unzip on Unix-like systems
|
||||
execSync(`unzip -o "${zipPath}" -d "${extractDir}"`, { stdio: "inherit" });
|
||||
}
|
||||
// extract
|
||||
const unzipCmd =
|
||||
platform === "win32"
|
||||
? `powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${extractDir}' -Force"`
|
||||
: `unzip -qq -o "${zipPath}" -d "${extractDir}"`;
|
||||
execSync(unzipCmd, { stdio: "inherit" });
|
||||
|
||||
console.log(`🚀 Launching ${baseName}...`);
|
||||
if (platform === "win32") {
|
||||
execSync(`"${binaryPath}"`, { stdio: "inherit" });
|
||||
} else {
|
||||
// Make sure binary is executable on Unix-like systems
|
||||
execSync(`chmod +x "${binaryPath}"`);
|
||||
execSync(`"${binaryPath}"`, { stdio: "inherit" });
|
||||
// perms & launch
|
||||
if (platform !== "win32") {
|
||||
try {
|
||||
fs.chmodSync(binPath, 0o755);
|
||||
} catch {}
|
||||
}
|
||||
return launch(binPath);
|
||||
}
|
||||
|
||||
if (isMcpMode) {
|
||||
extractAndRun("vibe-kanban-mcp", (bin) => {
|
||||
const proc = spawn(bin, [], { stdio: ["pipe", "pipe", "inherit"] });
|
||||
process.stdin.pipe(proc.stdin);
|
||||
proc.stdout.pipe(process.stdout);
|
||||
proc.on("exit", (c) => process.exit(c || 0));
|
||||
proc.on("error", (e) => {
|
||||
console.error("❌ MCP server error:", e.message);
|
||||
process.exit(1);
|
||||
});
|
||||
process.on("SIGINT", () => {
|
||||
console.error("\n🛑 Shutting down MCP server...");
|
||||
proc.kill("SIGINT");
|
||||
});
|
||||
process.on("SIGTERM", () => proc.kill("SIGTERM"));
|
||||
});
|
||||
} else {
|
||||
console.log(`📦 Extracting vibe-kanban...`);
|
||||
extractAndRun("vibe-kanban", (bin) => {
|
||||
console.log(`🚀 Launching vibe-kanban...`);
|
||||
if (platform === "win32") {
|
||||
execSync(`"${bin}"`, { stdio: "inherit" });
|
||||
} else {
|
||||
execSync(`"${bin}"`, { stdio: "inherit" });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vibe-kanban",
|
||||
"private": false,
|
||||
"version": "0.0.27",
|
||||
"version": "0.0.28",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"vibe-kanban": "bin/cli.js"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vibe-kanban",
|
||||
"version": "0.0.27",
|
||||
"version": "0.0.28",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "concurrently \"cargo watch -w backend -x 'run --manifest-path backend/Cargo.toml'\" \"npm run frontend:dev\"",
|
||||
|
||||
Reference in New Issue
Block a user