UNPKG

refakts

Version:

TypeScript refactoring tool built for AI coding agents to perform precise refactoring operations via command line instead of requiring complete code regeneration.

49 lines • 2.43 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const plugin_loader_1 = require("./plugin-loader"); const quality_reporter_1 = require("./quality-reporter"); const runQualityChecks = async (sourceDir) => { const checks = (0, plugin_loader_1.loadQualityChecks)(); const allIssues = await Promise.all(checks.map(check => check.check(sourceDir))); return allIssues.flat(); }; const getCurrentTolerance = () => { return 0; }; const shouldFailOnLinterIssues = (linterIssues) => { const tolerance = getCurrentTolerance(); const linterViolationCount = linterIssues.filter(issue => issue.type === 'linter-violation').length; if (linterViolationCount <= tolerance) { if (tolerance > 0 && linterViolationCount > 0) { process.stdout.write(`\nšŸ“Š Linter status: ${linterViolationCount}/${tolerance} violations allowed (${tolerance - linterViolationCount} buffer remaining)\n`); } else if (linterViolationCount === 0) { process.stdout.write(`\nāœ… No linter violations found!\n`); } return false; } process.stdout.write(`\nāŒ Linter violations exceed tolerance: ${linterViolationCount} violations found, only ${tolerance} allowed\n`); if (tolerance === 0) { process.stdout.write('šŸŽÆ Zero tolerance reached! All linter violations must be fixed.\n'); } return true; }; const main = async () => { const issues = await runQualityChecks('src'); const linterIssues = issues.filter(issue => issue.type === 'linter-violation' || issue.type === 'linter-error'); const otherIssues = issues.filter(issue => issue.type !== 'linter-violation' && issue.type !== 'linter-error'); const shouldFailOnLinter = shouldFailOnLinterIssues(linterIssues); const reportIssues = shouldFailOnLinter ? issues : otherIssues.concat(linterIssues.filter(issue => issue.type === 'linter-error')); const report = (0, quality_reporter_1.generateReport)(reportIssues); process.stdout.write(report + '\n'); const shouldFailOnOther = otherIssues.length > 0 || linterIssues.some(issue => issue.type === 'linter-error'); process.exit((shouldFailOnOther || shouldFailOnLinter) ? 1 : 0); }; if (require.main === module) { main().catch(error => { process.stderr.write(`Error: ${error}\n`); process.exit(1); }); } //# sourceMappingURL=quality-runner.js.map