mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 06:06:02 +09:00
- Updated postinstall scripts to not fail on errors - Added .npmrc to handle optional dependency failures - Improved install-arm64.js error handling - Ensures claude-flow works in environments without build tools (Codespaces, Docker, etc.) - Falls back to in-memory storage when SQLite unavailable
83 lines
2.4 KiB
JavaScript
83 lines
2.4 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import os from 'node:os';
|
|
import { spawn } from 'node:child_process';
|
|
|
|
// Check if SQLite bindings are working
|
|
async function checkSqliteBindings() {
|
|
try {
|
|
const Database = await import('better-sqlite3');
|
|
const db = new Database.default(':memory:');
|
|
db.close();
|
|
return true;
|
|
} catch (error) {
|
|
// Silently fail - this is expected when better-sqlite3 doesn't compile
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Attempt to rebuild better-sqlite3 for ARM64
|
|
async function rebuildSqlite() {
|
|
console.log('🔧 Rebuilding better-sqlite3 for ARM64...');
|
|
|
|
return new Promise((resolve) => {
|
|
const rebuild = spawn('npm', ['rebuild', 'better-sqlite3'], {
|
|
stdio: 'inherit',
|
|
shell: true
|
|
});
|
|
|
|
rebuild.on('close', (code) => {
|
|
if (code === 0) {
|
|
console.log('✅ Successfully rebuilt better-sqlite3 for ARM64');
|
|
resolve(true);
|
|
} else {
|
|
console.log('⚠️ Failed to rebuild better-sqlite3');
|
|
resolve(false);
|
|
}
|
|
});
|
|
|
|
rebuild.on('error', () => {
|
|
console.log('⚠️ Failed to rebuild better-sqlite3');
|
|
resolve(false);
|
|
});
|
|
});
|
|
}
|
|
|
|
// Main installation logic
|
|
async function main() {
|
|
const platform = os.platform();
|
|
const arch = os.arch();
|
|
|
|
// Only run on ARM64 macOS
|
|
if (platform === 'darwin' && arch === 'arm64') {
|
|
console.log('🍎 Detected Apple Silicon (ARM64) Mac');
|
|
|
|
const bindingsWork = await checkSqliteBindings();
|
|
|
|
if (!bindingsWork) {
|
|
console.log('⚠️ SQLite bindings not working for ARM64');
|
|
const rebuildSuccess = await rebuildSqlite();
|
|
|
|
if (!rebuildSuccess) {
|
|
console.log('');
|
|
console.log('⚠️ Unable to rebuild SQLite bindings for ARM64');
|
|
console.log('📝 Claude-Flow will fall back to in-memory storage');
|
|
console.log('');
|
|
console.log('To fix this issue, you can try:');
|
|
console.log('1. Install Xcode Command Line Tools: xcode-select --install');
|
|
console.log('2. Manually rebuild: cd node_modules/better-sqlite3 && npm run build-release');
|
|
console.log('3. Use Rosetta 2: arch -x86_64 npm install');
|
|
console.log('');
|
|
}
|
|
} else {
|
|
console.log('✅ SQLite bindings are working correctly');
|
|
}
|
|
}
|
|
}
|
|
|
|
// Run the installation enhancement
|
|
// Exit with 0 even if there are errors - this is a best-effort script
|
|
main().catch(() => {
|
|
// Silently ignore errors - better-sqlite3 is optional
|
|
process.exit(0);
|
|
}); |