astra/pd-power-supply
USB-PD Power Supply with RP2040 controller
- Version
- 1.1.6
- License
- unset
- Stars
- 0
scripts/verify-revision.cjs
const fs=require('node:fs'),assert=require('node:assert/strict');
const selections=JSON.parse(fs.readFileSync('parts.json'));
const stock=JSON.parse(fs.readFileSync('stock-snapshot.json')).parts;
const stockByCode=new Map(stock.map(p=>[p.code,p]));
for(const entry of ['board','index']){
const data=JSON.parse(fs.readFileSync(`dist/${entry}/circuit.json`));
const errors=data.filter(p=>p.type.includes('error'));
assert.equal(errors.length,0,`${entry}: ${errors.map(e=>e.message).join('\n')}`);
const vias=data.filter(p=>p.type==='pcb_via');assert.ok(vias.length>0);
for(const via of vias){
assert.ok(Math.abs(via.hole_diameter-.3)<1e-9,`${entry}: ${via.pcb_via_id} drill`);
assert.ok(via.outer_diameter>=.6,`${entry}: inadequate via annulus`);
}
for(const [ref,code] of Object.entries(selections)){
const component=data.find(p=>p.type==='source_component'&&p.name===ref);
assert.ok(component,`Missing fitted component ${ref}`);
assert.deepEqual(component.supplier_part_numbers?.jlcpcb,[code],`${ref}: supplier selection changed`);
const row=stockByCode.get(code);assert.ok(row,`${code}: stock not checked`);
assert.ok(row.overseasStockCount>=row.quantity_per_board,`${code}: insufficient stock for one board`);
assert.ok(row.canPresaleNumber>=row.quantity_per_board,`${code}: insufficient preorder availability for one board`);
if(ref.startsWith('RV_')) assert.equal(component.manufacturer_part_number,'RK09K1110AAR');
}
const board=data.find(p=>p.type==='pcb_board');assert.equal(board.width,80);assert.equal(board.height,45);
assert.equal(board.num_layers,4);
console.log(`PASS ${entry}: ${vias.length} vias, all 0.3 mm drill, pads >=0.6 mm; 80 fitted parts / 43 stock-checked codes; zero DRC errors.`);
}
assert.ok(!fs.readFileSync('build.log','utf8').includes('Async effect error'),'Incomplete async DRC');