mohan-bee/tscircuit-robot-vacuum
A tscircuit package created by mohan-bee.
- Version
- 1.0.0
- License
- unset
- Stars
- 0
scripts/verify.ts
import fs from "node:fs/promises"
import assert from "node:assert/strict"
const records: any[] = JSON.parse(await fs.readFile("dist/circuit.json", "utf8"))
const list = (type: string) => records.filter((e) => e.type === type)
const boards = list("pcb_board")
assert.equal(boards.length, 1, "one custom PCB")
assert.equal(boards[0].num_layers, 4)
assert.equal(boards[0].width, 160)
assert.equal(boards[0].height, 130)
assert.equal(boards[0].thickness, 1.6)
assert.deepEqual(list("pcb_hole").map((e) => [e.x, e.y]).sort(), [[-72,-52],[-72,52],[72,-52],[72,52]].sort())
assert.equal(list("schematic_sheet").length, 8)
const sources = list("source_component")
assert.equal(sources.filter((e) => e.ftype === "printedpart").length, 15)
assert.equal(sources.filter((e) => /DRV8876/.test(e.manufacturer_part_number ?? "")).length, 4)
assert.equal(list("cad_explosion_stage").length, 3)
assert.equal(list("cad_reference_surface").length, 1)
const errors = records.filter((e) => /error$/.test(e.type))
assert.equal(errors.length, 0, JSON.stringify(errors))
const warnings = records.filter((e) => /warning$/.test(e.type))
const manifest = JSON.parse(await fs.readFile("dist/printed-parts/manifest.json", "utf8"))
assert.equal(manifest.parts.length, 15)
for (const p of manifest.parts) {
assert(p.triangleCount > 0)
assert.equal(p.meshChecks.boundaryEdges, 0, p.name)
assert.equal(p.meshChecks.nonManifoldEdges, 0, p.name)
assert.equal(p.meshChecks.inconsistentEdges, 0, p.name)
assert.equal(p.meshChecks.degenerateTriangles, 0, p.name)
}
const collision = list("cad_explosion_collision_check_warning")
assert.equal(collision.length, 1, "known incomplete PCB geometry check must stay visible")
assert.equal(collision[0].reason, "unsupported_geometry")
assert.deepEqual(collision[0].pcb_board_ids, [boards[0].pcb_board_id])
assert.equal(collision[0].cad_component_ids.length, 0, "all authored component meshes should be checkable")
const result = {
passed: true,
checks: ["one correctly sized four-layer board", "PCB hole coordinates", "eight shared-net schematic sheets", "four DRV8876 channels", "fifteen native printed parts", "three native explosion stages", "native mounting reference", "no native error records", "fifteen closed oriented STL meshes", "known PCB collision coverage warning retained"],
warnings: Object.fromEntries([...new Set(warnings.map((e) => e.type))].map((type) => [type, warnings.filter((e) => e.type === type).length])),
fabricationReady: false,
routingStatus: "disabled; no final PCB traces",
collisionCoverage: "incomplete: PCB excluded by reproduced native plated-hole parser defect",
}
await fs.writeFile("dist/verification.json", JSON.stringify(result, null, 2))
console.log(JSON.stringify(result, null, 2))