refakts
Version:
TypeScript refactoring tool built for AI coding agents to perform precise refactoring operations via command line instead of requiring complete code regeneration.
64 lines • 3.47 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentationUpdater = void 0;
const HelpContentExtractor_1 = require("./HelpContentExtractor");
const QualityChecksExtractor_1 = require("./QualityChecksExtractor");
const SectionReplacer_1 = require("./SectionReplacer");
const FileManager_1 = require("./FileManager");
const ClaudeFormatter_1 = require("./formatters/ClaudeFormatter");
const ReadmeFormatter_1 = require("./formatters/ReadmeFormatter");
class DocumentationUpdater {
constructor() {
this.helpExtractor = new HelpContentExtractor_1.HelpContentExtractor();
this.qualityExtractor = new QualityChecksExtractor_1.QualityChecksExtractor();
this.sectionReplacer = new SectionReplacer_1.SectionReplacer();
this.fileManager = new FileManager_1.FileManager();
this.claudeFormatter = new ClaudeFormatter_1.ClaudeFormatter();
this.readmeFormatter = new ReadmeFormatter_1.ReadmeFormatter();
}
async updateClaudeFile(filePath) {
const helpCommands = await this.helpExtractor.extractHelpContent();
const content = this.fileManager.readFile(filePath);
const formattedHelp = this.claudeFormatter.formatHelpSection(helpCommands);
const updatedContent = this.replaceHelpSection(content, formattedHelp);
this.fileManager.writeFile(filePath, updatedContent);
}
replaceHelpSection(content, formattedHelp) {
return this.sectionReplacer.replaceSection(content, '<!-- AUTO-GENERATED HELP START -->', '<!-- AUTO-GENERATED HELP END -->', formattedHelp);
}
async updateReadmeFile(filePath) {
const content = await this.extractAndFormatContent(filePath);
const updatedContent = this.replaceBothSections(content);
this.fileManager.writeFile(filePath, updatedContent.updatedContent);
}
async extractAndFormatContent(filePath) {
const rawContent = await this.extractRawContent(filePath);
return this.formatContentForReadme(rawContent);
}
async extractRawContent(filePath) {
const helpCommands = await this.helpExtractor.extractHelpContent();
const qualityChecks = this.qualityExtractor.extractQualityChecksContent();
const content = this.fileManager.readFile(filePath);
return { helpCommands, qualityChecks, content };
}
formatContentForReadme(rawContent) {
return {
content: rawContent.content,
formattedHelp: this.readmeFormatter.formatHelpSection(rawContent.helpCommands),
formattedQuality: this.readmeFormatter.formatQualitySection(rawContent.qualityChecks)
};
}
replaceBothSections(data) {
let updatedContent = this.replaceHelpSectionInReadme(data.content, data.formattedHelp);
updatedContent = this.replaceQualitySection(updatedContent, data.formattedQuality);
return { updatedContent };
}
replaceHelpSectionInReadme(content, formattedHelp) {
return this.sectionReplacer.replaceSection(content, '<!-- AUTO-GENERATED HELP START -->', '<!-- AUTO-GENERATED HELP END -->', formattedHelp);
}
replaceQualitySection(content, formattedQuality) {
return this.sectionReplacer.replaceSection(content, '<!-- AUTO-GENERATED QUALITY-CHECKS START -->', '<!-- AUTO-GENERATED QUALITY-CHECKS END -->', formattedQuality);
}
}
exports.DocumentationUpdater = DocumentationUpdater;
//# sourceMappingURL=DocumentationUpdater.js.map