#!/usr/bin/env bun /** * Generate static HTML pages for License and Privacy from .txt files * This ensures a single source of truth for legal documents */ import { readFileSync, writeFileSync } from 'fs'; import { join } from 'path'; const ROOT_DIR = join(import.meta.dir, '..'); const WEBPAGE_DIR = join(ROOT_DIR, 'webpage'); function escapeHtml(text: string): string { return text .replace(/&/g, '&') .replace(//g, '>'); } function generateHtmlPage(title: string, content: string): string { return ` ${title} - Dockhand
Dockhand ← Back to home

${title}

${escapeHtml(content)}
`; } // Read the source files const licenseContent = readFileSync(join(ROOT_DIR, 'LICENSE.txt'), 'utf-8'); const privacyContent = readFileSync(join(ROOT_DIR, 'PRIVACY.txt'), 'utf-8'); // Generate HTML pages const licenseHtml = generateHtmlPage('License Terms and Conditions', licenseContent); const privacyHtml = generateHtmlPage('Privacy Policy', privacyContent); // Write to webpage directory writeFileSync(join(WEBPAGE_DIR, 'license.html'), licenseHtml); writeFileSync(join(WEBPAGE_DIR, 'privacy.html'), privacyHtml); console.log('Generated legal pages:'); console.log(' - webpage/license.html'); console.log(' - webpage/privacy.html');