gitlify
Version:
A powerful CLI tool to analyze uncommitted git changes with detailed reports, function detection, and beautiful terminal output
47 lines (38 loc) • 1.48 kB
JavaScript
const GitAnalyzer = require('./git-analyzer.js');
const DiffParser = require('./diff-parser.js');
const CodeAnalyzer = require('./code-analyzer.js');
const Formatter = require('./formatter.js');
class GitLify {
constructor() {
this.gitAnalyzer = new GitAnalyzer();
this.diffParser = new DiffParser();
this.codeAnalyzer = new CodeAnalyzer();
this.formatter = new Formatter();
}
async analyze(options = {}) {
try {
// Check if we're in a git repository
const isGitRepo = await this.gitAnalyzer.isGitRepository();
if (!isGitRepo) {
throw new Error('Not a git repository. Please run this command from a git repository.');
}
// Get git status
const status = await this.gitAnalyzer.getStatus();
if (!status.hasChanges) {
console.log('✨ No uncommitted changes found.');
return;
}
// Get detailed diff information
const diffData = await this.gitAnalyzer.getDiff();
// Parse diff data
const parsedFiles = this.diffParser.parseDiff(diffData);
// Analyze code for function information
const analyzedFiles = await this.codeAnalyzer.analyzeFiles(parsedFiles);
// Format and display results
this.formatter.display(analyzedFiles, options);
} catch (error) {
throw new Error(`Analysis failed: ${error.message}`);
}
}
}
module.exports = { GitLify };