AnasSarkiz/NEMA14_RP2040
A NEMA motor assembly concept with a controller board, four proposed M3 screws and spacers, motor lead splices, and a JST 4-pin connector harness.
- Version
- 1.13.0
- License
- ISC
- Stars
- 0
scripts/build.tsx
import { normalizeMetadata } from "./normalize-metadata"
import React from "react"
import { classifySource } from "./classify-source"
import { prepareSchematic } from "./prepare-schematic"
import { Circuit } from "tscircuit"
import { convertCircuitJsonToPcbSvg, convertCircuitJsonToSchematicSvg } from "circuit-to-svg"
import { mkdirSync, writeFileSync } from "node:fs"
import Nema14Controller from "../index.circuit"
import { normalizeAssembly } from "./normalize-assembly"
const circuit = new Circuit()
circuit.add(<Nema14Controller routingDisabled={process.argv.includes("--unrouted")} />)
console.log('Rendering NEMA14 RP2040 with tscircuit local autorouter…')
await circuit.renderUntilSettled()
const raw = normalizeMetadata(classifySource(normalizeAssembly(circuit.getCircuitJson())))
mkdirSync('artifacts/top-assembly',{recursive:true})
writeFileSync('artifacts/top-assembly/raw-source.circuit.json',JSON.stringify(raw,null,2)+'\n')
const json = prepareSchematic(raw)
mkdirSync('artifacts', {recursive:true})
writeFileSync(process.argv.includes('--unrouted') ? 'artifacts/final-source.circuit.json' : 'artifacts/autorouted.circuit.json', JSON.stringify(json,null,2)+'\n')
if(!process.argv.includes('--unrouted')) {
writeFileSync('artifacts/autorouted-top.svg', convertCircuitJsonToPcbSvg(json,{layer:'top'}))
writeFileSync('artifacts/autorouted-bottom.svg', convertCircuitJsonToPcbSvg(json,{layer:'bottom'}))
}
writeFileSync('artifacts/schematic.svg', convertCircuitJsonToSchematicSvg(json))
console.log(JSON.stringify({elements:json.length,traces:json.filter(e=>e.type==='pcb_trace').length,errors:json.filter(e=>e.type.endsWith('_error')).map(e=>({type:e.type,message:(e as any).message}))},null,2))
if(json.some(e=>e.type.endsWith('_error'))) process.exitCode=1