UNPKG

@syntropysoft/praetorian

Version:

Praetorian CLI – A universal multi-environment configuration validator for DevSecOps teams. Validate, compare, and secure YAML/ENV files with ease.

155 lines • 5.38 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.runCheck = runCheck; const chalk_1 = __importDefault(require("chalk")); async function runCheck(options = {}) { console.log(chalk_1.default.blue('\nšŸ” Checking SyntropyLog Components...\n')); try { const checks = []; if (options.brokers) checks.push('brokers'); if (options.http) checks.push('http'); if (options.redis) checks.push('redis'); if (options.logging) checks.push('logging'); // If no specific component, check all if (checks.length === 0) { checks.push('brokers', 'http', 'redis', 'logging'); } console.log(chalk_1.default.gray(`Checking components: ${checks.join(', ')}`)); const results = []; // Check brokers if (checks.includes('brokers')) { results.push(await checkBrokers()); } // Check HTTP adapters if (checks.includes('http')) { results.push(await checkHttp()); } // Check Redis if (checks.includes('redis')) { results.push(await checkRedis()); } // Check logging if (checks.includes('logging')) { results.push(await checkLogging()); } // Display results displayCheckResults(results); } catch (error) { console.error(chalk_1.default.red('\nāŒ Check failed:')); console.error(error instanceof Error ? error.message : error); process.exit(1); } } async function checkBrokers() { console.log(chalk_1.default.blue('šŸ”Œ Checking Broker Configuration...')); // TODO: Implement actual broker checks // For now, return mock results return { component: 'brokers', status: 'warning', message: 'Broker configuration check not implemented yet', details: [ 'NATS broker configuration', 'Message broker adapters', 'Connection settings' ] }; } async function checkHttp() { console.log(chalk_1.default.blue('🌐 Checking HTTP Adapters...')); return { component: 'http', status: 'warning', message: 'HTTP adapter check not implemented yet', details: [ 'HTTP client configuration', 'Request/response interceptors', 'Error handling' ] }; } async function checkRedis() { console.log(chalk_1.default.blue('šŸ”“ Checking Redis Configuration...')); return { component: 'redis', status: 'warning', message: 'Redis configuration check not implemented yet', details: [ 'Redis connection settings', 'Beacon configuration', 'Connection pooling' ] }; } async function checkLogging() { console.log(chalk_1.default.blue('šŸ“ Checking Logging Configuration...')); return { component: 'logging', status: 'warning', message: 'Logging configuration check not implemented yet', details: [ 'Log levels', 'Transport configuration', 'Formatter settings' ] }; } function displayCheckResults(results) { console.log(chalk_1.default.blue('\nšŸ“Š Check Results:\n')); let allPassed = true; results.forEach(result => { const statusIcon = getStatusIcon(result.status); const statusColor = getStatusColor(result.status); console.log(`${statusIcon} ${statusColor(result.component.toUpperCase())}`); console.log(` ${result.message}`); if (result.details && result.details.length > 0) { console.log(chalk_1.default.gray(' Details:')); result.details.forEach((detail) => { console.log(chalk_1.default.gray(` • ${detail}`)); }); } if (result.status === 'error') { allPassed = false; } console.log(''); }); // Summary console.log(chalk_1.default.blue('šŸ“ˆ Summary:')); const passed = results.filter(r => r.status === 'success').length; const warnings = results.filter(r => r.status === 'warning').length; const errors = results.filter(r => r.status === 'error').length; console.log(` • Passed: ${chalk_1.default.green(passed)}`); console.log(` • Warnings: ${chalk_1.default.yellow(warnings)}`); console.log(` • Errors: ${chalk_1.default.red(errors)}`); if (!allPassed) { console.log(chalk_1.default.yellow('\nāš ļø Some checks have warnings or errors.')); } else { console.log(chalk_1.default.green('\nāœ… All checks passed!')); } } function getStatusIcon(status) { switch (status) { case 'success': return 'āœ…'; case 'warning': return 'āš ļø'; case 'error': return 'āŒ'; default: return 'ā“'; } } function getStatusColor(status) { switch (status) { case 'success': return chalk_1.default.green; case 'warning': return chalk_1.default.yellow; case 'error': return chalk_1.default.red; default: return chalk_1.default.gray; } } //# sourceMappingURL=check.js.map