shibosoftwaredev/f1c100s-linux-nema17-stepper-controller

A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.

Version
0.4.56
License
unset
Stars
0

scripts/check-review-warning-regression.mjs

import fs from "node:fs"
import assert from "node:assert/strict"
import crypto from "node:crypto"
const read = p => JSON.parse(fs.readFileSync(p, "utf8"))
const before = read(process.env.BASELINE_CIRCUIT ?? "../../checkpoints/nema17-before-rishabh-review-v053-DuFOGi/restore-verified/dist/index/circuit.json")
const after = read("dist/index/circuit.json")
const warnings = c => c.filter(e => e.type.endsWith("_warning"))
const key = w => `${w.type}:${w.source_trace_id ?? w.source_component_id ?? w.pcb_component_id ?? ""}`
const old = new Map(warnings(before).map(w => [key(w), w]))
const width = w => w.message?.match(/requested: ([\d.]+)mm, actual: ([\d.]+)mm/)
// Debug-only renderer instance numbers change when schematic notes are added.
// Keep the source component ID and every other part of the warning intact.
const stableMessage = w => w.message?.replace(/(<testpoint)#\d+(?= name=)/g, "$1#INSTANCE")
const regressions = []
for (const w of warnings(after)) {
  const b = old.get(key(w)), aWidth = width(w), bWidth = b && width(b)
  if (!b) regressions.push({ kind: "new_warning", warning: w })
  else if (aWidth && bWidth) {
    if (Math.abs(Number(aWidth[1])-Number(bWidth[1])) > 1e-6 || Number(aWidth[2])+1e-6 < Number(bWidth[2]))
      regressions.push({ kind: "narrower_than_published", before: b, after: w })
  } else if (stableMessage(w) !== stableMessage(b)) regressions.push({ kind: "changed_warning", before: b, after: w })
}
const errors = after.filter(e => e.type.endsWith("_error"))
const report = { circuitSha256: crypto.createHash("sha256").update(fs.readFileSync("dist/index/circuit.json")).digest("hex"),
  baselineWarnings: warnings(before).length, currentWarnings: warnings(after).length, errors, regressions }
fs.writeFileSync("reports/review-warning-regression.json", JSON.stringify(report, null, 2) + "\n")
console.log(JSON.stringify(report))
assert.deepEqual(errors, [])
assert.deepEqual(regressions, [])