abse/museair-usb

USB-C–powered ESP32-C3 controller board with AP63203 buck conversion, AP2112K 3.3V regulation, I²C SEN62 sensor interface, status LED, buttons, UART/I²C headers, and extensive decoupling.

Version
0.5.7
License
unset
Stars
0

scripts/export-order.mjs

// Run after npm run build / verify. Requires KiCad CLI and KiCad's pcbnew Python.
import {spawnSync} from 'node:child_process'
import fs from 'node:fs'
import path from 'node:path'
import {fileURLToPath} from 'node:url'
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..')
const cli=process.env.KICAD_CLI??'/Applications/KiCad/KiCad.app/Contents/MacOS/kicad-cli'
const py=process.env.KICAD_PYTHON??'/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/bin/python3.9'
const run=(cmd,args)=>{const r=spawnSync(cmd,args,{cwd:root,encoding:'utf8'});if(r.status!==0){process.stdout.write(r.stdout??'');process.stderr.write(r.stderr??'');throw new Error(`${cmd} failed: ${r.status}`)};console.log(path.basename(cmd),args.slice(0,3).join(' '),'OK')}
const raw=path.join(root,'dist/index/raw.kicad_pcb')
const board=path.join(root,'fabrication-review/museair-usb.kicad_pcb')
fs.mkdirSync(path.join(root,'order/gerbers'),{recursive:true})
run('tsci',['export','dist/index/circuit.json','-f','kicad_pcb','-o',raw])
run(py,['scripts/prepare-kicad.py','dist/index/circuit.json',raw,board,'validation/export-repairs.json'])
run(cli,['pcb','drc',board,'--format','json','--output','validation/kicad-drc.json'])
run(cli,['pcb','export','gerbers',board,'--output','order/gerbers/','--layers','F.Cu,B.Cu,F.Mask,B.Mask,F.Silkscreen,B.Silkscreen,F.Paste,B.Paste,Edge.Cuts','--use-drill-file-origin','--subtract-soldermask','--exclude-refdes','--exclude-value'])
run(cli,['pcb','export','drill',board,'--output','order/gerbers/','--drill-origin','plot','--excellon-separate-th','--excellon-oval-format','route','--generate-report','--report-path','validation/drill-report.txt'])
for(const side of ['top','bottom'])run(cli,['pcb','export','svg',board,'--output',`preview/fabrication-${side}.svg`,'--layers',side==='top'?'F.Cu,F.Silkscreen,Edge.Cuts':'B.Cu,B.Silkscreen,Edge.Cuts','--mode-single','--page-size-mode','2','--exclude-drawing-sheet','--subtract-soldermask',...(side==='bottom'?['--mirror']:[])])
run(process.execPath,['scripts/make-preview.mjs'])
run(py,['scripts/verify-production.py'])
console.log('Production package exported and independently audited')