imrishabh18/nema-23-stepper-controller

A four-layer NEMA23 stepper motor controller PCB featuring an RP2040 MCU, DRV8452 dual-phase driver, USB‑C PD power input/protection, current and temperature sensing, status LED/buzzer, and optional magnetic encoder.

Version
1.3.2
License
unset
Stars
1

scripts/check-schematic-style.mjs

import {readFileSync,writeFileSync,mkdirSync} from 'node:fs'
import {createHash} from 'node:crypto'
import assert from 'node:assert/strict'
import {createSchematicPlacementIssueArtifacts} from './vendor/schematic-style-analyzer.mjs'

// Use the same analyzer as the schematic viewer, pinned for reproducibility.
const tool=JSON.parse(readFileSync('engineering/schematic-style-analyzer.json'))
assert.equal(createHash('sha256').update(readFileSync('scripts/vendor/schematic-style-analyzer.mjs')).digest('hex'),tool.sha256)
const file=process.argv[2]??'dist/index/circuit.json'
const data=readFileSync(file)
const artifacts=createSchematicPlacementIssueArtifacts(JSON.parse(data))
mkdirSync('checks/schematic-style',{recursive:true})
for(const artifact of artifacts)writeFileSync(`checks/schematic-style/${artifact.fileName}`,artifact.content)
const issues=artifacts.map(({content,...artifact})=>artifact)
writeFileSync('checks/schematic-style.json',JSON.stringify({analyzer:tool,circuitJsonSha256:createHash('sha256').update(data).digest('hex'),issueCount:issues.length,issues},null,2)+'\n')
if(issues.length)throw new Error(JSON.stringify(issues.map(a=>a.descriptionXml),null,2))
console.log(`PASS: zero schematic style issues across all sheets (analyzer ${tool.version}).`)