imrishabh18/rp2040-motor-controller

This circuit incorporates a USB-C Power Delivery (PD) interface with a CH224K controller, a WJ500V-5.08-04P motor output connector, multiple power conditioning components including capacitors, resistors, diodes, and an RP2040 microcontroller, to manage motor control, signal routing, and power management for a USB-powered stepper motor system.

Version
1.0.14
License
unset
Stars
0

scripts/validate-build.ts

import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
import { createHash } from "node:crypto";
import { runAllRoutingChecks } from "@tscircuit/checks";
import type { CircuitJson } from "circuit-json";
import { assertCommonGround } from "../tests/helpers/assertCommonGround";

const file = process.argv[2] ?? "dist/index/circuit.json";
const raw = readFileSync(file, "utf8");
const json: CircuitJson = JSON.parse(raw);
const ground = assertCommonGround(json);
const embeddedErrors = json.filter(e => e.type.endsWith("_error"));
const routingErrors = (await runAllRoutingChecks(structuredClone(json)))
  .filter(e => e.type.endsWith("_error"));
const warnings: Record<string, number> = {};
for (const e of json) if (e.type.endsWith("_warning")) warnings[e.type] = (warnings[e.type] ?? 0) + 1;
const versions = Object.fromEntries([
  "tscircuit", "@tscircuit/core", "@tscircuit/cli", "@tscircuit/common",
  "@tscircuit/capacity-autorouter", "@tscircuit/checks", "circuit-json", "circuit-to-svg",
].map(name => [name, JSON.parse(readFileSync(`node_modules/${name}/package.json`, "utf8")).version]));
const report = {
  generatedAt: new Date().toISOString(), input: file,
  sha256: createHash("sha256").update(raw).digest("hex"), versions,
  commonGround: ground, embeddedErrors, routingErrors, warnings,
};
mkdirSync("reports", { recursive: true });
writeFileSync("reports/validation.json", JSON.stringify(report, null, 2) + "\n");
console.log(JSON.stringify(report, null, 2));
if (embeddedErrors.length || routingErrors.length) process.exitCode = 1;