@marsdevs-com/git-workreport
Version:
A powerful GitHub plugin that generates AI-powered work reports from Git commit history for specified dates. Perfect for DevOps teams and development companies to track and validate work progress with intelligent summaries.
170 lines • 6.67 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReportGenerator = void 0;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
class ReportGenerator {
/**
* Generate report in the specified format
*/
generateReport(report, options = {}) {
const format = options.format || 'text';
switch (format.toLowerCase()) {
case 'json':
return this.generateJsonReport(report);
case 'markdown':
return this.generateMarkdownReport(report, options);
case 'text':
default:
return this.generateTextReport(report, options);
}
}
/**
* Generate JSON format report
*/
generateJsonReport(report) {
return JSON.stringify(report, null, 2);
}
/**
* Generate text format report
*/
generateTextReport(report, options) {
const lines = [];
// Header
lines.push('='.repeat(80));
lines.push(`GIT WORK REPORT - ${report.date}`);
lines.push('='.repeat(80));
lines.push('');
// Summary
lines.push('SUMMARY:');
lines.push(` Date: ${report.date}`);
lines.push(` Total Commits: ${report.totalCommits}`);
lines.push(` Total Lines Changed: ${report.totalLinesChanged}`);
lines.push(` Authors: ${report.authors.join(', ')}`);
lines.push('');
// AI Summary
lines.push('AI-GENERATED SUMMARY:');
if (!options.anthropicApiKey) {
lines.push(` ${report.aiSummary}`);
lines.push(` Note: No Anthropic API key provided. For AI-powered summaries, use --anthropic-key YOUR_API_KEY`);
}
else {
lines.push(` ${report.aiSummary}`);
}
lines.push('');
if (options.includeStats !== false) {
lines.push('STATISTICS:');
lines.push(` Insertions: ${report.totalInsertions} lines`);
lines.push(` Deletions: ${report.totalDeletions} lines`);
lines.push(` Net Changes: ${report.totalInsertions - report.totalDeletions} lines`);
lines.push(` Average Commits per Author: ${(report.totalCommits / report.authors.length).toFixed(2)}`);
lines.push('');
}
if (report.totalCommits === 0) {
lines.push('No commits found for the specified date.');
}
lines.push('='.repeat(80));
lines.push(`Report generated on ${new Date().toLocaleString()}`);
return lines.join('\n');
}
/**
* Generate markdown format report
*/
generateMarkdownReport(report, options) {
const lines = [];
// Header
lines.push(`# Git Work Report - ${report.date}`);
lines.push('');
lines.push(`**Generated:** ${new Date().toLocaleString()}`);
lines.push('');
// Summary
lines.push('## Summary');
lines.push('');
lines.push('| Metric | Value |');
lines.push('|--------|-------|');
lines.push(`| Date | ${report.date} |`);
lines.push(`| Total Commits | ${report.totalCommits} |`);
lines.push(`| Total Lines Changed | ${report.totalLinesChanged} |`);
lines.push(`| Authors | ${report.authors.join(', ')} |`);
lines.push('');
// AI Summary
lines.push('## AI-Generated Summary');
lines.push('');
if (!options.anthropicApiKey) {
lines.push(`> ${report.aiSummary}`);
lines.push('');
lines.push('> **Note:** No Anthropic API key provided. For AI-powered summaries, use `--anthropic-key YOUR_API_KEY`');
}
else {
lines.push(`> ${report.aiSummary}`);
}
lines.push('');
if (options.includeStats !== false) {
lines.push('## Statistics');
lines.push('');
lines.push(`- **Insertions:** ${report.totalInsertions} lines`);
lines.push(`- **Deletions:** ${report.totalDeletions} lines`);
lines.push(`- **Net Changes:** ${report.totalInsertions - report.totalDeletions} lines`);
lines.push(`- **Average Commits per Author:** ${(report.totalCommits / report.authors.length).toFixed(2)}`);
lines.push('');
}
if (report.totalCommits === 0) {
lines.push('## No Commits Found');
lines.push('');
lines.push('No commits were found for the specified date.');
}
return lines.join('\n');
}
/**
* Save report to file
*/
saveReport(content, outputPath, format) {
if (!outputPath) {
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
const ext = format === 'json' ? 'json' : format === 'markdown' ? 'md' : 'txt';
outputPath = `work-report-${timestamp}.${ext}`;
}
// Ensure directory exists
const dir = path.dirname(outputPath);
if (dir !== '.' && !fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
fs.writeFileSync(outputPath, content, 'utf8');
return outputPath;
}
}
exports.ReportGenerator = ReportGenerator;
//# sourceMappingURL=report-generator.js.map
;