AnasSarkiz/usb-c-pwm-pa25

A component library defining an AO3400A N-channel MOSFET, 47 µF polarized capacitor, 3-pin through-hole connector, and 9.1 V Zener diode with PCB footprints and 3D CAD models.

Version
0.1.0-prototype.2
License
unset
Stars
0

evidence/official-routing-difficulty.ts.txt

import { analyzeRouting } from "@tscircuit/circuit-json-routing-analysis"
import type { PlatformConfig } from "@tscircuit/props"
import type { Command } from "commander"
import path from "node:path"
import { getCircuitJsonForCheck, resolveCheckInputFilePath } from "../shared"

export const checkRoutingDifficulty = async (file?: string) => {
  const resolvedInputFilePath = await resolveCheckInputFilePath(file)
  const circuitJson = await getCircuitJsonForCheck({
    filePath: resolvedInputFilePath,
    platformConfig: {
      pcbDisabled: false,
      routingDisabled: true,
    } satisfies PlatformConfig,
    allowPrebuiltCircuitJson: true,
  })

  const analysis = await analyzeRouting(circuitJson)
  const result = analysis.getString()
  if (!result) {
    return `No congested regions in ${path.basename(resolvedInputFilePath)}`
  }
  return result
}

export const registerCheckRoutingDifficulty = (program: Command) => {
  program.commands
    .find((c) => c.name() === "check")!
    .command("routing-difficulty")
    .description("Analyze routing difficulty")
    .argument("[file]", "Path to the entry file")
    .action(async (file?: string) => {
      try {
        const output = await checkRoutingDifficulty(file)
        console.log(output)
      } catch (error) {
        console.error(error instanceof Error ? error.message : String(error))
        process.exit(1)
      }
    })
}