plugins/website/scripts/manage-patchnotes.mjs
2026-11-27 23:43:05 +00:00

4 lines
1.2 KiB
JavaScript

import {readFileSync,writeFileSync} from 'node:fs';import {makeRelease,makeBugfix,validatePatchnotes} from './patchnote-policy.mjs';
const root=new URL('./',import.meta.url),read=name=>JSON.parse(readFileSync(new URL(name,root),'utf8'));
const register=read('task-register.json'),pending=read('pending-patchnotes.json'),releases=read('changelog.json'),action=process.argv[2]||'validate';
try{if(action==='validate'){validatePatchnotes(register,pending,releases);console.log('Patchnote registry valid. '+pending.completed.length+'/5 normal tasks pending; '+releases.length+' releases.')}else{if(!['publish','bugfix'].includes(action))throw Error('Use validate, publish or bugfix');const input=JSON.parse(readFileSync(0,'utf8'));const next=action==='publish'?makeRelease(register,pending,releases,input):makeBugfix(register,pending,releases,input);for(const [file,data]of [['task-register.json',next.register],['pending-patchnotes.json',next.pending],['changelog.json',next.releases]])writeFileSync(new URL(file,root),JSON.stringify(data,null,2)+'\n');console.log('Release recorded: '+next.release.version+'. Run the website build and normal publication workflow.')}}catch(error){console.error(error.message);process.exitCode=1}