import fs from 'node:fs'; import path from 'node:path'; import {fileURLToPath} from 'node:url'; export function format(receipt) { if(typeof receipt.changed!=='string'||!receipt.changed.trim())throw new Error('Receipt needs changed.'); const lines=['# CHLOE//OS ยท build notes','',receipt.changed.trim(),'']; for(const [key,label]of [['tested','Checked'],['untested','Still to check'],['source','Edit here'],['next','Try next']]){ const items=Array.isArray(receipt[key])?receipt[key]:receipt[key]?[receipt[key]]:[]; if(items.length)lines.push(`**${label}**`,...items.map(s=>'- '+String(s).replace(/\n/g,' ')),''); } if(receipt.screenshot)lines.push(`![Actual device screenshot](${receipt.screenshot})`,''); if(receipt.blocker)lines.push('**Needs:** '+receipt.blocker,''); return lines.join('\n'); } if(process.argv[1]&&fs.realpathSync(process.argv[1])===fileURLToPath(import.meta.url)){ process.stdout.write(format(JSON.parse(fs.readFileSync(process.argv[2],'utf8')))); }