pixalynx/pixal-gps

These files define two separate printed circuit boards: a small, two-layer battery cartridge with protection circuitry and contact pads for a pouch cell, and a larger, two-layer wireless charging dock featuring USB-C input, a resonant coil, and wireless power transmission components.

Version
0.1.2
License
unset
Stars
0

scripts/build.ts

export {}
/** Build all three boards (Circuit JSON, PCB/schematic SVG + PNG), run the design assertions and
 * the copper audit, and write dist/report.json. `bun scripts/build.ts [tracker|battery-pack|dock]`. */
const boards = process.argv.slice(2).length ? process.argv.slice(2) : ["tracker", "battery-pack", "dock"]
const run = async (cmd: string[]) => { const p = Bun.spawn(cmd, { stdout: "pipe", stderr: "pipe" }); const [out, err, code] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text(), p.exited]); return { out: out + err, code } }
const report: Record<string, any> = {}
for (const b of boards) {
  const t0 = Date.now()
  const r = await run(["bunx", "tsci", "build", `${b}.circuit.tsx`, "--pcb-svgs", "--schematic-svgs", "--pngs"])
  await Bun.write(`dist/${b}-build.log`, r.out)
  const audit = await run(["python3", "scripts/audit-copper.py", `dist/${b}/circuit.json`])
  report[b] = { exit: r.code, seconds: Math.round((Date.now() - t0) / 1000), audit: audit.out.trim().split("\n") }
  console.log(`${b}: tsci exit ${r.code} in ${report[b].seconds}s\n${audit.out}`)
}
const v = await run(["bun", "scripts/validate.ts"])
report.validate = { exit: v.code, out: v.out.trim().split("\n") }
console.log(v.out)
await Bun.write("dist/report.json", JSON.stringify(report, null, 1))
if (v.code !== 0) process.exitCode = 1