UNPKG

@thecodingwhale/cv-processor

Version:

CV Processor to extract structured data from PDF resumes using TypeScript

50 lines (49 loc) 2.52 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = registerMergeReportsCommand; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const renderCharts_1 = require("../utils/renderCharts"); const reportMerger_1 = require("../utils/reportMerger"); function registerMergeReportsCommand(program) { program .command('merge-reports') .description('Merge multiple report.md files into a single report') .argument('<outputDir>', 'Directory containing the report.md files') .option('-o, --output <file>', 'Output file name', 'merged-report.md') .option('-c, --charts', 'Render Mermaid charts to images') .option('--html', 'Generate HTML report with embedded charts') .action(async (outputDir, options) => { try { console.log(`Merging reports from ${outputDir}...`); const reportContent = await (0, reportMerger_1.mergeReports)(outputDir); // Write the merged markdown report const outputFile = options.output || 'merged-report.md'; const outputPath = path_1.default.join(process.cwd(), outputFile); fs_1.default.writeFileSync(outputPath, reportContent); console.log(`Merged report written to ${outputPath}`); // Render charts if requested if (options.charts || options.html) { console.log('Rendering Mermaid charts...'); const chartsDir = path_1.default.join(path_1.default.dirname(outputPath), 'charts'); if (options.html) { // Generate HTML report with embedded charts const htmlPath = await (0, renderCharts_1.createHtmlReport)(outputPath, chartsDir); console.log(`HTML report with embedded charts created at: ${htmlPath}`); } else if (options.charts) { // Just render the chart images const chartPaths = await (0, renderCharts_1.renderChartsFromReport)(outputPath, chartsDir); console.log(`Rendered ${chartPaths.length} charts to ${chartsDir}`); } } } catch (error) { console.error('Error merging reports:', error); process.exit(1); } }); }