UNPKG

@vibe-dev-kit/cli

Version:

Advanced Command-line toolkit that analyzes your codebase and deploys project-aware rules, memories, commands and agents to any AI coding assistant - VDK is the world's first Vibe Development Kit

118 lines (96 loc) 2.98 kB
#!/usr/bin/env node /** * VibeKit VDK Health Check * Simple validation script to ensure VDK is working correctly */ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const projectRoot = path.join(__dirname, '../..'); const colors = { green: '\x1b[32m', red: '\x1b[31m', yellow: '\x1b[33m', blue: '\x1b[36m', reset: '\x1b[0m', }; function log(message, color = 'reset') { console.log(`${colors[color]}${message}${colors.reset}`); } async function checkNodeVersion() { const version = process.version; const majorVersion = parseInt(version.slice(1).split('.')[0]); if (majorVersion >= 14) { log(`✅ Node.js version: ${version}`, 'green'); return true; } log(`❌ Node.js version ${version} is too old. Requires Node.js 14+`, 'red'); return false; } function checkProjectStructure() { const requiredFiles = [ 'cli.js', 'package.json', 'src/scanner/index.js', 'src/scanner/core/ProjectScanner.js', 'templates/rule-template.md', ]; let allGood = true; for (const file of requiredFiles) { const filePath = path.join(projectRoot, file); if (fs.existsSync(filePath)) { log(`✅ Found: ${file}`, 'green'); } else { log(`❌ Missing: ${file}`, 'red'); allGood = false; } } return allGood; } function checkTemplates() { const templatesDir = path.join(projectRoot, 'src/scanner/templates'); if (!fs.existsSync(templatesDir)) { log(`❌ Templates directory not found: ${templatesDir}`, 'red'); return false; } const templates = fs .readdirSync(templatesDir, { recursive: true }) .filter((file) => file.endsWith('.mdc')); // Using .mdc template format if (templates.length > 0) { log(`✅ Found ${templates.length} template files`, 'green'); return true; } log(`❌ No template files found in ${templatesDir}`, 'red'); return false; } export async function runHealthCheck() { log('🔍 Running VibeKit VDK Health Check...', 'blue'); log(''); const checks = [ { name: 'Node.js Version', fn: checkNodeVersion }, { name: 'Project Structure', fn: checkProjectStructure }, { name: 'Templates', fn: checkTemplates }, ]; let allPassed = true; for (const check of checks) { log(`Checking ${check.name}...`, 'yellow'); const passed = await check.fn(); if (!passed) allPassed = false; log(''); } if (allPassed) { log('🎉 All health checks passed! VDK is ready to use.', 'green'); process.exit(0); } else { log('⚠️ Some health checks failed. Please review the issues above.', 'red'); process.exit(1); } } // Run health check only if this file is executed directly if (import.meta.url === `file://${process.argv[1]}`) { runHealthCheck().catch((error) => { log(`❌ Health check failed with error: ${error.message}`, 'red'); process.exit(1); }); }