/* eslint-disable no-console */ import fs from 'fs'; import path from 'path'; export class TemplateService { static createFallbackTemplates(templatesDir: string): void { try { fs.mkdirSync(templatesDir, { recursive: true }); const templates = { 'scan-results.html': this.getBasicScanTemplate(), 'crawl-results.html': this.getBasicCrawlTemplate(), 'test-results.html': this.getBasicTestTemplate(), 'test-multiple-results.html': this.getBasicTestMultipleTemplate(), }; for (const [filename, content] of Object.entries(templates)) { const filePath = path.join(templatesDir, filename); if (!fs.existsSync(filePath)) { fs.writeFileSync(filePath, content, 'utf8'); } } console.log(`✅ Created fallback templates in ${templatesDir}`); } catch (error) { console.error(`❌ Failed to create fallback templates: ${error}`); } } private static getBasicScanTemplate(): string { return `
Scan completed at: {{SCAN_TIME}}
{{TOTAL_PAGES}}
{{PASSED_CHECKS}}
{{VIOLATIONS}}
Crawl completed at: {{CRAWL_TIME}}
Test completed at: {{TEST_TIME}}
Tests completed at: {{TEST_TIME}}