forked from unimatrix/web
DUNE-002: add validated patchnote publishing system
This commit is contained in:
parent
89acb004d3
commit
d955e8beb8
7 changed files with 155 additions and 25 deletions
13
website/scripts/build-patchnotes.mjs
Normal file
13
website/scripts/build-patchnotes.mjs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import {readFileSync,writeFileSync,readdirSync} from 'node:fs';import {validatePatchnotes,releaseFile} from './patchnote-policy.mjs';
|
||||
const scripts=new URL('./',import.meta.url),web=new URL('../web/',import.meta.url),read=name=>JSON.parse(readFileSync(new URL(name,scripts),'utf8')),pending=read('pending-patchnotes.json'),releases=read('changelog.json'),register=read('task-register.json');validatePatchnotes(register,pending,releases);
|
||||
const esc=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
||||
const urgent=releases.filter(r=>r.kind==='bugfix').slice(0,3);const urgentCards=urgent.length?'<section class="urgent-bugfix-news" aria-label="Urgent development bugfixes"><h2>Urgent bugfix reports</h2><div>'+urgent.map(r=>'<article><img src="assets/bugfix-seal.svg" alt=""><p>BUGFIX · '+esc(r.version)+'</p><h3><a href="'+releaseFile(r.version)+'">'+esc(r.title)+'</a></h3><p>'+esc(r.synopsis)+'</p><a href="'+releaseFile(r.version)+'">Problem, repair & verification →</a></article>').join('')+'</div></section>':'';
|
||||
for(const file of readdirSync(web).filter(x=>x.endsWith('.html'))){let text=readFileSync(new URL(file,web),'utf8');text=text.replace(/<section class="urgent-bugfix-news"[\s\S]*?<\/section>/g,'');if(urgentCards&&['news.html','index.html'].includes(file))text=text.replace(/(<nav id="realm-menu"[\s\S]*?<\/nav>)/,'$1'+urgentCards);text=text.replace(/<footer>[\s\S]*?<\/footer>/,footer=>footer.includes('href="patch-notes.html"')?footer:footer.replace('<a href="staff.html">','<a href="patch-notes.html">Patch notes →</a><a href="staff.html">'));if(file==='news.html'&&!text.includes('class="development-news-link"'))text=text.replace(/(<nav id="realm-menu"[\s\S]*?<\/nav>)/,'$1<aside class="development-news-link"><a class="button gold" href="patch-notes.html">Website & plugin patch notes →</a><p>Game dispatches appear below. Development releases have their own register.</p></aside>');writeFileSync(new URL(file,web),text)}
|
||||
const base=readFileSync(new URL('index.html',web),'utf8'),header=base.match(/<header>[\s\S]*?<\/header>/)[0].replace(/ aria-current="page"/g,''),menu=base.match(/<nav id="realm-menu"[\s\S]*?<\/nav>/)[0],footer=base.match(/<footer>[\s\S]*?<\/footer>/)[0];
|
||||
function shell(title,body){return '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>'+esc(title)+' — Project Dune</title><meta name="description" content="Project Dune development releases, urgent bugfix reports and pending feature bundles."><link rel="icon" href="assets/favicon.svg">'+['styles','pages','minecraft','lore','patchnotes'].map(x=>'<link rel="stylesheet" href="'+x+'.css">').join('')+'<script src="pages.js" defer></script><script src="patchnotes.js" defer></script></head><body><a class="skip" href="#patchnotes-content">Skip to content</a>'+header+'<main><section class="page-intro intro-patchnotes"><p class="eyebrow">PROJECT DUNE / GUILD CHANGE REGISTER</p><h1>'+esc(title)+'</h1><p>Traceable changes to the website and plugin. Completed work, published bundles and urgent repairs.</p></section>'+menu+'<div id="patchnotes-content" class="patchnotes-content">'+body+'</div></main>'+footer+'<div class="toast" role="status" aria-live="polite"></div></body></html>'}
|
||||
const stats='<section class="patch-stats"><div><strong>'+releases.filter(x=>x.kind==='normal').length+'</strong><span>Published bundles</span></div><div><strong>'+releases.filter(x=>x.kind==='bugfix').length+'</strong><span>Urgent bugfix reports</span></div><div><strong>'+pending.completed.length+' / 5</strong><span>Completed tasks toward next bundle</span></div></section>';
|
||||
const cards=releases.map(r=>'<article class="patch-card kind-'+r.kind+'" data-kind="'+r.kind+'"><p class="patch-kind">'+(r.kind==='bugfix'?'URGENT BUGFIX':'BUNDLED PRODUCT UPDATE')+' · '+esc(r.version)+'</p><h3><a href="'+releaseFile(r.version)+'">'+esc(r.title)+'</a></h3><p>'+esc(r.synopsis)+'</p><small>'+esc(r.date)+' · '+r.tasks.length+' product '+(r.tasks.length===1?'task':'tasks')+'</small><a href="'+releaseFile(r.version)+'">Read full patch note →</a></article>').join('');
|
||||
const waiting=pending.completed.map(t=>'<article class="pending-task"><p class="patch-kind">'+t.promptIds.map(esc).join(' · ')+' / '+esc(t.priority)+'</p><h3>'+esc(t.title)+'</h3><ul>'+t.changes.map(c=>'<li>'+esc(c)+'</li>').join('')+'</ul><small>Completed '+esc(t.completedAt)+' · awaiting a normal bundle</small></article>').join('');
|
||||
writeFileSync(new URL('patch-notes.html',web),shell('Patch Notes',stats+'<section class="patch-register"><div class="patch-toolbar"><h2>Published register</h2><label>Type<select id="patch-kind"><option value="all">All releases</option><option value="normal">Product bundles</option><option value="bugfix">Urgent bugfixes</option></select></label></div><div id="patch-releases" class="patch-grid">'+cards+'</div><div id="patch-empty" class="patch-empty"'+(cards?' hidden':'')+'><h3>'+(cards?'No matching releases':'The first bundle is being assembled')+'</h3><p>Normal patchnotes collect 5–10 completed product tasks. Individual features can already be live while their release note is waiting for enough completed work.</p></div></section><section class="patch-pending"><p class="eyebrow">COMPLETED WORK / NOT YET A RELEASE NOTE</p><h2>Next normal bundle</h2><p>'+pending.completed.length+' completed product tasks are recorded. '+Math.max(0,5-pending.completed.length)+' more are needed before a normal bundle can be written. Workflow agreements do not count toward the threshold.</p><div class="patch-grid">'+waiting+'</div></section><aside class="patch-policy"><h3>How this register works</h3><p>Normal updates group 5–10 genuine completed product tasks, retaining their DUNE ticket IDs. Urgent bugfixes are published separately with the problem, repair and verification; they do not wait for a feature bundle. A deployment is not automatically a new patchnote.</p><p>This register starts with the new system. Earlier development remains in the repository and <a href="staff.html">contribution record</a>; no historical releases have been invented. <a href="news.html">Live game news</a> remains separate.</p><a href="tickets.html">Report a problem through support tickets →</a></aside>'));
|
||||
for(const r of releases){const details=r.tasks.map(t=>'<section class="release-task"><p class="patch-kind">'+t.promptIds.map(esc).join(' · ')+'</p><h3>'+esc(t.title)+'</h3><ul>'+t.changes.map(c=>'<li>'+esc(c)+'</li>').join('')+'</ul>'+((t.checks||[]).length?'<h4>Verification</h4><ul>'+t.checks.map(c=>'<li>'+esc(c)+'</li>').join('')+'</ul>':'')+'</section>').join('');writeFileSync(new URL(releaseFile(r.version),web),shell(r.kind==='bugfix'?'Urgent Bugfix':'Product Update','<article class="patch-detail"><a href="patch-notes.html">← Patchnote archive</a><p class="patch-kind">'+esc(r.version)+' · '+esc(r.date)+'</p><h2>'+esc(r.title)+'</h2><p>'+esc(r.synopsis)+'</p>'+(r.kind==='bugfix'?'<div class="bugfix-report"><h3>Problem</h3><p>'+esc(r.problem)+'</p><h3>Repair</h3><p>'+esc(r.fix)+'</p><h3>Checks</h3><ul>'+r.checks.map(x=>'<li>'+esc(x)+'</li>').join('')+'</ul></div>':'')+details+'</article>'))}
|
||||
console.log('Built patchnote register:',releases.length,'releases;',pending.completed.length,'normal tasks pending');
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import './build-prophecy.mjs';
|
||||
import './build-staff.mjs';
|
||||
import './build-patchnotes.mjs';
|
||||
import {readFileSync,writeFileSync,readdirSync,statSync,mkdirSync,existsSync,rmSync,cpSync} from 'node:fs';import path from 'node:path';import {fileURLToPath} from 'node:url';
|
||||
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..'),web=path.join(root,'web'),dist=path.join(root,'dist');
|
||||
const assets={};const types={'.html':'text/html; charset=utf-8','.css':'text/css; charset=utf-8','.js':'text/javascript; charset=utf-8','.json':'application/json; charset=utf-8','.webp':'image/webp','.svg':'image/svg+xml'};
|
||||
|
|
|
|||
1
website/scripts/changelog.json
Normal file
1
website/scripts/changelog.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
4
website/scripts/manage-patchnotes.mjs
Normal file
4
website/scripts/manage-patchnotes.mjs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
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}
|
||||
26
website/scripts/patchnote-policy.mjs
Normal file
26
website/scripts/patchnote-policy.mjs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
export const priorityOrder=['BUGFIX','P0','P1','P2','P3','PARKEREN'];
|
||||
const fail=message=>{throw Error(message)};
|
||||
export function releaseFile(version){if(typeof version!=='string'||!(/^[A-Za-z0-9][A-Za-z0-9._-]{0,48}$/).test(version))fail('Invalid version');return 'patch-note-'+version.toLowerCase().replace(/[._]/g,'-')+'.html'}
|
||||
export function validatePatchnotes(register,pending,releases){
|
||||
if(register.format!==1||!Array.isArray(register.tasks)||!Array.isArray(releases)||!Array.isArray(pending.completed))fail('Invalid register structure');
|
||||
if(pending.minimumTasks!==5||pending.maximumTasks!==10)fail('Normal bundles must contain 5–10 product tasks');
|
||||
const tasks=new Map();for(const t of register.tasks){if(!/^DUNE-\d{3,}$/.test(t.id)||tasks.has(t.id))fail('Duplicate or invalid task ID');if(!priorityOrder.includes(t.priority)||!['product','workflow'].includes(t.kind))fail('Invalid task metadata');tasks.set(t.id,t)}
|
||||
const completed=new Map(),claimed=new Set(),files=new Set(),items=new Set();
|
||||
function validateItem(item,kind){if(!item.id||items.has(item.id))fail('A product task occurs more than once');items.add(item.id);if(!item.title||!Array.isArray(item.promptIds)||!item.promptIds.length||!Array.isArray(item.changes)||!item.changes.length)fail('Invalid product record');for(const id of item.promptIds){const task=tasks.get(id);if(!task||task.kind!=='product'||task.status!=='done')fail('Only completed product tasks can enter patchnotes');if(claimed.has(id))fail('A prompt ID occurs more than once');claimed.add(id);if(kind==='bugfix'&&task.priority!=='BUGFIX')fail('Urgent bugfix entries require BUGFIX tasks');if(kind==='normal'&&task.priority==='BUGFIX')fail('BUGFIX must be published separately') }if(kind==='normal'&&item.priority==='BUGFIX')fail('BUGFIX must be separate')}
|
||||
for(const r of releases){const file=releaseFile(r.version);if(files.has(file))fail('Duplicate or colliding release version');files.add(file);if(!r.title||!r.synopsis||!/^\d{4}-\d{2}-\d{2}$/.test(r.date)||!['normal','bugfix'].includes(r.kind)||!Array.isArray(r.tasks))fail('Invalid release metadata');if(r.kind==='normal'&&(r.tasks.length<5||r.tasks.length>10))fail('Normal release requires 5–10 product tasks');if(r.kind==='bugfix'&&(!r.tasks.length||!r.problem||!r.fix||!Array.isArray(r.checks)||!r.checks.length))fail('Bugfix needs problem, fix and checks');for(const item of r.tasks)validateItem(item,r.kind)}
|
||||
for(const item of pending.completed){validateItem(item,item.priority==='BUGFIX'?'bugfix':'normal');if(item.priority==='BUGFIX')fail('BUGFIX cannot wait in the normal queue');completed.set(item.id,item)}
|
||||
return {completed,tasks,files};
|
||||
}
|
||||
export function makeRelease(register,pending,releases,input){
|
||||
const checked=validatePatchnotes(register,pending,releases);const file=releaseFile(input.version);if(checked.files.has(file))fail('Release version already exists');
|
||||
const ids=input.taskIds;if(!Array.isArray(ids)||new Set(ids).size!==ids.length||!ids.length)fail('Select unique product task IDs');
|
||||
const selected=ids.map(id=>checked.completed.get(id)||fail('Task is not in the completed pending queue'));
|
||||
if(selected.length<5||selected.length>10)fail('Select 5–10 completed product tasks for a normal release');
|
||||
const release={version:input.version,date:input.date,title:input.title,synopsis:input.synopsis,kind:'normal',tasks:selected};
|
||||
const nextPending={...pending,completed:pending.completed.filter(x=>!ids.includes(x.id))},nextRegister={...register,tasks:register.tasks.map(t=>selected.some(x=>x.promptIds.includes(t.id))?{...t,release:input.version}:t)},nextReleases=[release,...releases];validatePatchnotes(nextRegister,nextPending,nextReleases);return {register:nextRegister,pending:nextPending,releases:nextReleases,release};
|
||||
}
|
||||
export function makeBugfix(register,pending,releases,input){
|
||||
const checked=validatePatchnotes(register,pending,releases);if(checked.files.has(releaseFile(input.version)))fail('Release version already exists');
|
||||
const release={version:input.version,date:input.date,title:input.title,synopsis:input.synopsis,kind:'bugfix',problem:input.problem,fix:input.fix,checks:input.checks,tasks:input.tasks};
|
||||
const nextRegister={...register,tasks:register.tasks.map(t=>input.tasks?.some(x=>x.promptIds?.includes(t.id))?{...t,release:input.version}:t)},nextReleases=[release,...releases];validatePatchnotes(nextRegister,pending,nextReleases);return {register:nextRegister,pending,releases:nextReleases,release};
|
||||
}
|
||||
8
website/scripts/pending-patchnotes.json
Normal file
8
website/scripts/pending-patchnotes.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"minimumTasks":5,
|
||||
"maximumTasks":10,
|
||||
"completed":[
|
||||
{"id":"staff-page","promptIds":["DUNE-001"],"priority":"P2","completedAt":"2026-10-14","title":"Staff & Contributors page","changes":["Dedicated Dune-styled staff directory, private support links and site-wide footer navigation.","Clearly separate AI contribution plaque for 2 of 14, with a project medal and traceable contribution record. Human roster remains empty until public staff details are confirmed."],"checks":["25 existing website tests passed.","Local page links, artwork assets, support routes and AI-versus-staff labelling checked."]},
|
||||
{"id":"patchnote-system","promptIds":["DUNE-002"],"priority":"P2","completedAt":"2026-10-14","title":"Traceable patchnote register","changes":["Public patchnote archive, pending feature queue and separate urgent bugfix treatment.","Source-driven release pages with permanent task IDs, a 5–10 product-task gate, unique versions and release-to-task traceability. Development patchnotes remain separate from live game news."],"checks":["Release policy boundary and data validation tests.","Website build and generated link checks."]}
|
||||
]
|
||||
}
|
||||
10
website/scripts/task-register.json
Normal file
10
website/scripts/task-register.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"format": 1,
|
||||
"priorityOrder": ["BUGFIX", "P0", "P1", "P2", "P3", "PARKEREN"],
|
||||
"tasks": [
|
||||
{"id":"DUNE-001","priority":"P2","receiptOrder":1,"title":"Staff & Contributors page","kind":"product","status":"done","completedAt":"2026-10-14","commit":"89acb00"},
|
||||
{"id":"DUNE-002","priority":"P2","receiptOrder":2,"title":"Patchnote system and colleague consultation","kind":"product","status":"done","completedAt":"2026-10-14"},
|
||||
{"id":"DUNE-003","priority":"P0","receiptOrder":3,"title":"Persist priority rules and apply them in colleague consultation","kind":"workflow","status":"done","completedAt":"2026-10-14","commit":"40efbff"},
|
||||
{"id":"DUNE-004","priority":"P2","receiptOrder":4,"title":"End every colleague message with einde prompt","kind":"workflow","status":"done","completedAt":"2026-10-14","commit":"89acb00"}
|
||||
]
|
||||
}
|
||||
Loading…
Reference in a new issue

Staff