import type { PatchesUpdate } from './tracker.js'
function formatBytes(bytes: number): string {
const units = ['B', 'KiB', 'MiB', 'GiB']
let size = bytes
let unitIndex = 0
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024
unitIndex++
}
return `${size.toFixed(1)} ${units[unitIndex]}`
}
export function formatPatchesUpdate(update: PatchesUpdate): string {
const { patchline, version, previousVersion, patchId, patchSize } = update
const emoji = patchline === 'release' ? '🎮' : '🧪'
return `${emoji} Hytale Game Patch Update
Patchline: ${patchline}
New version: ${version}
${previousVersion !== 'unknown' ? `Previous: ${previousVersion}` : ''}
${patchId ? `Patch ID: ${patchId}` : ''}
${patchSize ? `Size: ~${formatBytes(patchSize)}` : ''}`
}