UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

68 lines (53 loc) â€ĸ 2.36 kB
#!/usr/bin/env node /** * Postinstall script that copies the correct prebuilt binary for the current platform */ const fs = require('fs'); const path = require('path'); const os = require('os'); console.log('🔧 Setting up better-sqlite3...'); try { // Detect current platform const platform = process.platform; // 'darwin', 'linux', 'win32' const arch = process.arch; // 'x64', 'arm64' const platformDir = `${platform}-${arch}`; console.log(`đŸ“Ļ Platform: ${platformDir}`); // Find better-sqlite3 const possiblePaths = [ path.join(__dirname, '..', 'node_modules', 'better-sqlite3'), path.join(__dirname, '..', '..', 'better-sqlite3'), path.join(__dirname, '..', '..', '..', 'node_modules', 'better-sqlite3') ]; let betterSqlitePath; for (const p of possiblePaths) { if (fs.existsSync(path.join(p, 'package.json'))) { betterSqlitePath = p; break; } } if (!betterSqlitePath) { console.log('âš ī¸ better-sqlite3 not found. It will work when imported.'); process.exit(0); } // Check if we have the binary for this platform const ourBinaryPath = path.join(__dirname, '..', 'prebuilds', platformDir, 'better-sqlite3.node'); if (!fs.existsSync(ourBinaryPath)) { console.log(`âš ī¸ No prebuilt binary for ${platformDir}. Will compile on first use.`); process.exit(0); } // Copy our binary to better-sqlite3's expected location // Option 1: Copy to build/Release (where better-sqlite3 looks first) const targetBuildDir = path.join(betterSqlitePath, 'build', 'Release'); fs.mkdirSync(targetBuildDir, { recursive: true }); const targetBinaryPath = path.join(targetBuildDir, 'better_sqlite3.node'); fs.copyFileSync(ourBinaryPath, targetBinaryPath); // Option 2: Also copy entire prebuilds structure (for node-gyp-build compatibility) const targetPrebuilds = path.join(betterSqlitePath, 'prebuilds', platformDir); fs.mkdirSync(targetPrebuilds, { recursive: true }); fs.copyFileSync(ourBinaryPath, path.join(targetPrebuilds, 'better-sqlite3.node')); console.log(`✅ Installed prebuilt binary for ${platformDir}!`); } catch (error) { // Never fail installation console.log('â„šī¸ Setup completed with warnings:', error.message); } process.exit(0);