AnasSarkiz/usb-c-pd-brushed-motor
USB-C PD-powered motor controller with protected input, selectable 5/9/12 V buck supply, MCU qualification, PWM H-bridge drive, overvoltage sensing, regenerative energy-dump resistors, and safety interlocks.
- Version
- 0.0.1-a48-cloud-pipeline9-unrouted-c41d79a-305b1e7a
- License
- unset
- Stars
- 0
scripts/check-routed-board.ts
import { readFile, writeFile } from "node:fs/promises"
import { createHash } from "node:crypto"
import { any_circuit_element } from "circuit-json"
import { z } from "zod"
import { runAllRoutingChecks } from "@tscircuit/checks"
const artifact = await readFile("dist/index/circuit.json", "utf8")
const artifactSha256 = createHash("sha256").update(artifact).digest("hex")
const elements = z.array(any_circuit_element).parse(JSON.parse(artifact))
const purchased = elements.filter((e) => e.type === "source_component").length
const traces = elements.filter((e) => e.type === "pcb_trace").length
if (
purchased !== 140 ||
!elements.some((e) => e.type === "pcb_component") ||
!traces
)
throw new Error(
"Routed checks require the complete140-part PCB and actual traces",
)
const checks = await runAllRoutingChecks(elements)
await writeFile(
"evidence/native-routed-checks-A22.json",
JSON.stringify({ artifactSha256, purchased, traces, checks }, null, 2) + "\n",
)
console.log(
JSON.stringify(
{
purchased,
traces,
diagnostics: checks.length,
types: [...new Set(checks.map((check) => check.type))],
},
null,
2,
),
)
if (checks.length) process.exitCode = 1