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.

78 lines 3.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RoadmapService = void 0; const roadmap_storage_1 = require("./roadmap-storage"); class RoadmapService { constructor() { this.storage = new roadmap_storage_1.RoadmapStorage(); } vote(featureName) { const data = this.storage.loadRoadmap(); const feature = this.findFeature(data, featureName); feature.score += 1; this.storage.saveRoadmap(data); process.stdout.write(`✅ Voted for '${featureName}' (now ${feature.score} votes)\n`); } add(featureName, description, why) { const data = this.storage.loadRoadmap(); this.validateFeatureDoesNotExist(data, featureName); this.addFeatureToRoadmap(data, featureName, description, why); this.storage.saveRoadmap(data); process.stdout.write(`✅ Added feature '${featureName}' to roadmap\n`); } remove(featureName) { const data = this.storage.loadRoadmap(); const updatedData = this.removeFeatureFromData(data, featureName); this.storage.saveRoadmap(updatedData); process.stdout.write(`✅ Removed feature '${featureName}' from roadmap\n`); } removeFeatureFromData(data, featureName) { const initialCount = data.features.length; data.features = data.features.filter(f => f.name !== featureName); if (data.features.length === initialCount) { this.handleFeatureNotFound(featureName); } return data; } handleFeatureNotFound(featureName) { process.stderr.write(`❌ Feature '${featureName}' not found. Use 'npm run roadmap:status' to see available features.\n`); process.exit(1); } getRoadmapData() { const data = this.storage.loadRoadmap(); this.removeCompletedFeatures(data); return data; } removeCompletedFeatures(data) { const initialCount = data.features.length; data.features = data.features.filter(f => f.status !== 'completed'); if (data.features.length < initialCount) { this.storage.saveRoadmap(data); } } findFeature(data, featureName) { const feature = data.features.find(f => f.name === featureName); if (!feature) { process.stderr.write(`❌ Feature '${featureName}' not found. Use 'npm run roadmap:status' to see available features.\n`); process.exit(1); } return feature; } validateFeatureDoesNotExist(data, featureName) { if (data.features.find(f => f.name === featureName)) { process.stderr.write(`❌ Feature '${featureName}' already exists.\n`); process.exit(1); } } addFeatureToRoadmap(data, featureName, description, why) { data.features.push({ name: featureName, description, why, score: 0, status: 'proposed' }); } } exports.RoadmapService = RoadmapService; //# sourceMappingURL=roadmap-service.js.map