UNPKG

mak3r-hub

Version:

Universal Claude Code force multiplier for website development

141 lines (116 loc) 3.73 kB
#!/usr/bin/env node const { execSync, spawn } = require('child_process'); const fs = require('fs-extra'); const path = require('path'); const os = require('os'); const chalk = require('chalk'); class CSharpBuilder { constructor() { this.projectPath = path.join(__dirname, '..', 'src-csharp', 'MAK3R.Core'); this.isWindows = os.platform() === 'win32'; } async checkDotNet() { try { const version = execSync('dotnet --version', { encoding: 'utf8' }).trim(); console.log(chalk.green(`✅ .NET ${version} found`)); return true; } catch (error) { console.log(chalk.red('❌ .NET runtime not found')); console.log(chalk.yellow(' Install from: https://dotnet.microsoft.com/download')); return false; } } async buildDebug() { if (!this.isWindows) { console.log(chalk.gray('ℹ️ Skipping C# build on non-Windows platform')); return true; } console.log(chalk.blue('🔧 Building C# automation engine (Debug)...')); try { execSync('dotnet build', { cwd: this.projectPath, stdio: 'inherit' }); console.log(chalk.green('✅ Debug build complete')); return true; } catch (error) { console.log(chalk.red('❌ Debug build failed')); return false; } } async buildProduction() { if (!this.isWindows) { console.log(chalk.gray('ℹ️ Skipping C# build on non-Windows platform')); return true; } console.log(chalk.blue('🚀 Building C# automation engine (Production)...')); try { execSync('dotnet publish -c Release --self-contained -r win-x64 -o publish-win-x64 -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true -p:DebugType=None -p:DebugSymbols=false', { cwd: this.projectPath, stdio: 'inherit' }); console.log(chalk.green('✅ Production build complete')); return true; } catch (error) { console.log(chalk.red('❌ Production build failed')); return false; } } async ensureEngine() { if (!this.isWindows) { return true; // Skip on non-Windows } const enginePath = path.join(this.projectPath, 'bin', 'Debug', 'net9.0', 'win-x64', 'MAK3R.Core.exe'); if (fs.existsSync(enginePath)) { console.log(chalk.green('✅ C# automation engine already available')); return true; } console.log(chalk.yellow('🔧 C# automation engine not found, building...')); if (!(await this.checkDotNet())) { return false; } return await this.buildDebug(); } getExecutablePath() { if (!this.isWindows) { return null; } // Try production build first const productionPath = path.join(this.projectPath, 'publish-win-x64', 'MAK3R.Core.exe'); if (fs.existsSync(productionPath)) { return productionPath; } // Fall back to debug build const debugPath = path.join(this.projectPath, 'bin', 'Debug', 'net9.0', 'win-x64', 'MAK3R.Core.exe'); if (fs.existsSync(debugPath)) { return debugPath; } return null; } } // CLI usage async function main() { const builder = new CSharpBuilder(); const command = process.argv[2]; switch (command) { case 'debug': await builder.buildDebug(); break; case 'production': await builder.buildProduction(); break; case 'ensure': await builder.ensureEngine(); break; case 'path': console.log(builder.getExecutablePath() || 'Not available'); break; default: await builder.ensureEngine(); } } // Run if executed directly if (require.main === module) { main().catch(console.error); } module.exports = { CSharpBuilder };