forked from unimatrix/web
Make additive resource JSON reproducible across checkouts
This commit is contained in:
parent
9096b05cc5
commit
c487dc6030
2 changed files with 15 additions and 1 deletions
|
|
@ -31,7 +31,7 @@ export function mergePackAssets(base,sources){
|
|||
if(!/^assets\/[a-z0-9_.-]+\/[a-z0-9_./-]+$/.test(name)||name.split('/').some(part=>!part||part==='.'||part==='..'))
|
||||
throw Error('Invalid resource asset path: '+name);
|
||||
if(!merged.has(name)){
|
||||
merged.set(name,bytes);
|
||||
merged.set(name,name.endsWith('.json')?Buffer.from(bytes.toString('utf8').replace(/\r\n/g,'\n')):bytes);
|
||||
continue;
|
||||
}
|
||||
const mapping=/^assets\/[^/]+\/(?:lang\/[^/]+\.json|sounds\.json)$/.test(name);
|
||||
|
|
|
|||
|
|
@ -196,6 +196,20 @@ test('identical imperial atlas artwork shares a texture while retaining both spr
|
|||
assert(centralPackEntries(direct,()=>new Map()).has(oldFile));
|
||||
});
|
||||
|
||||
test('new JSON assets generate identical ZIP bytes across checkout line endings',()=>{
|
||||
const font='assets/dunerealms/font/menu.json';
|
||||
const inherited='assets/dunerealms/font/production.json';
|
||||
const texture='assets/dunerealms/textures/item/coin.png';
|
||||
const base=new Map([[inherited,Buffer.from('{\r\n "providers": []\r\n}\r\n')]]);
|
||||
const png=Buffer.from([137,80,78,71,13,10]);
|
||||
const source=eol=>new Map([[font,Buffer.from(['{',' "providers": []','}', ''].join(eol))],[texture,png]]);
|
||||
const windows=mergePackAssets(base,[source('\r\n')]);
|
||||
const linux=mergePackAssets(base,[source('\n')]);
|
||||
assert.deepEqual(zip(windows),zip(linux));
|
||||
assert.deepEqual(windows.get(inherited),base.get(inherited));
|
||||
assert.deepEqual(windows.get(texture),png);
|
||||
});
|
||||
|
||||
test('every official Dunemark piece has a complete central-pack model and texture',()=>{
|
||||
const root=new URL('../network/resource-pack/shared/assets/dunerealms/',import.meta.url);
|
||||
const ids=[...NOTE_SERIES.map(([value])=>'note_'+value),...COIN_SERIES.map(([id])=>'coin_'+id.replaceAll('-','_')),
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff