UNPKG

@sun-asterisk/sunlint

Version:

☀️ SunLint - Multi-language static analysis tool for code quality and security | Sun* Engineering Standards

79 lines (64 loc) 2.15 kB
/** * Copy architecture-detection dist to engines/arch-detect * This script is run during build to bundle architecture detection */ const fs = require('fs'); const path = require('path'); const SOURCE = path.resolve(__dirname, '../../../../architecture-detection/dist'); const DEST = path.resolve(__dirname, '../engines/arch-detect'); function copyDir(src, dest) { if (!fs.existsSync(src)) { console.log('⚠️ architecture-detection/dist not found. Run "npm run build" in architecture-detection first.'); return false; } // Clean destination if (fs.existsSync(dest)) { fs.rmSync(dest, { recursive: true }); } fs.mkdirSync(dest, { recursive: true }); // Copy files recursively const entries = fs.readdirSync(src, { withFileTypes: true }); for (const entry of entries) { const srcPath = path.join(src, entry.name); const destPath = path.join(dest, entry.name); // Skip source maps and declaration files if (entry.name.endsWith('.map') || entry.name.endsWith('.d.ts')) { continue; } // Skip CLI and LLM folders if (entry.name === 'cli.js' || entry.name === 'llm' || entry.name === 'llm-primary') { continue; } if (entry.isDirectory()) { copyDir(srcPath, destPath); } else { fs.copyFileSync(srcPath, destPath); } } return true; } console.log('📦 Copying architecture-detection...'); if (copyDir(SOURCE, DEST)) { const size = getTotalSize(DEST); console.log(`✅ Copied to engines/arch-detect (${formatSize(size)})`); } else { console.log('⚠️ Skipped architecture-detection copy'); } function getTotalSize(dir) { let size = 0; const entries = fs.readdirSync(dir, { withFileTypes: true }); for (const entry of entries) { const fullPath = path.join(dir, entry.name); if (entry.isDirectory()) { size += getTotalSize(fullPath); } else { size += fs.statSync(fullPath).size; } } return size; } function formatSize(bytes) { if (bytes < 1024) return bytes + ' B'; if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'; return (bytes / (1024 * 1024)).toFixed(1) + ' MB'; }