diff --git a/README.md b/README.md index cb0b6ff08..9aa39f217 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,6 @@ Commands: the tscircuit ecosystem import [options] Search JLCPCB or the tscircuit registry and import a component - convert [options] Convert a .kicad_mod footprint to a tscircuit - component simulate Run a simulation version [options] Print CLI version help [command] display help for command diff --git a/bun.lock b/bun.lock index 801421a1f..1db0028b4 100644 --- a/bun.lock +++ b/bun.lock @@ -37,7 +37,6 @@ "circuit-json-to-readable-netlist": "^0.0.15", "circuit-json-to-spice": "^0.0.10", "circuit-json-to-step": "^0.0.33", - "circuit-json-to-tscircuit": "^0.0.9", "circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8", "commander": "^14.0.0", "conf": "^13.1.0", @@ -54,7 +53,6 @@ "jsonwebtoken": "^9.0.2", "jszip": "^3.10.1", "jwt-decode": "^4.0.0", - "kicad-component-converter": "^0.1.40", "kicad-to-circuit-json": "^0.0.59", "kicadts": "^0.0.35", "kleur": "^4.1.5", @@ -366,7 +364,7 @@ "@tscircuit/circuit-json-routing-analysis": ["@tscircuit/circuit-json-routing-analysis@0.0.1", "", { "dependencies": { "flatbush": "^4.5.1" }, "peerDependencies": { "typescript": "^5" } }, "sha512-vxXM5Vo92R4GjqYSuGrgRTU8jh3An8tUt4yvBvBALwkAswMWSXJIJFnA/n7wlV9S0uzv9uOvIwizKtbyUgNBpA=="], - "@tscircuit/circuit-json-schematic-placement-analysis": ["@tscircuit/circuit-json-schematic-placement-analysis@github:tscircuit/circuit-json-schematic-placement-analysis#b6d5fe6", { "dependencies": { "@tscircuit/circuit-json-util": "^0.0.94" }, "peerDependencies": { "circuit-json": "*", "typescript": "^5" } }, "tscircuit-circuit-json-schematic-placement-analysis-b6d5fe6", "sha512-+4c9n3cdvfRJtCWd+GH9/05N/kEDlhxg7wVeJpMB0zed1JINMAOQvN6/g36e5KjaBO09KDfeql5HV9xSwighNQ=="], + "@tscircuit/circuit-json-schematic-placement-analysis": ["@tscircuit/circuit-json-schematic-placement-analysis@github:tscircuit/circuit-json-schematic-placement-analysis#b6d5fe6", { "dependencies": { "@tscircuit/circuit-json-util": "^0.0.94" }, "peerDependencies": { "circuit-json": "*", "typescript": "^5" } }, "tscircuit-circuit-json-schematic-placement-analysis-b6d5fe6"], "@tscircuit/circuit-json-util": ["@tscircuit/circuit-json-util@0.0.94", "", { "dependencies": { "parsel-js": "^1.1.2" }, "peerDependencies": { "circuit-json": "*", "transformation-matrix": "*", "zod": "3" } }, "sha512-kEYV6LzcZbRuw43IxsZ1cZL2pUx4nF07MYAHHhY9s90UzKYaIYfZ1q11s+F2wNwKecCcSyTUoAwWeqazLQEyVQ=="], @@ -556,9 +554,7 @@ "circuit-json-to-step": ["circuit-json-to-step@0.0.33", "", { "dependencies": { "circuit-json-to-connectivity-map": "^0.0.22", "circuit-json-to-gltf": "^0.0.101", "circuit-to-svg": "^0.0.345", "schematic-symbols": "^0.0.202", "stepts": "^0.0.4" }, "peerDependencies": { "@tscircuit/circuit-json-util": "*", "typescript": "^5" } }, "sha512-KYDsY+2flOFMwyhbYKSpJM7Qouq9WnrQtLyq9iXiqNCAIiv2oiQ7Jx1b7Dc0yifhvaB8vEUM1kXRcwSBBa04WQ=="], - "circuit-json-to-tscircuit": ["circuit-json-to-tscircuit@0.0.9", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-2B4E3kOU9zFbJ6SyCKcp9ktlay/Xf2gbLuGcWE8rBL3uuypJU3uX4MFjHVfwx8cbvB/0LTF5v3gHTYbxpiZMOg=="], - - "circuit-json-trace-length-analysis": ["circuit-json-trace-length-analysis@github:tscircuit/circuit-json-trace-length-analysis#2b44792", { "peerDependencies": { "typescript": "^5" } }, "tscircuit-circuit-json-trace-length-analysis-2b44792", "sha512-CTFqTc+F66tflCKmXC+Ge7kD1K2rrEH4Z5vHhUJa0OxmtKh6L1gM80xCJL1YtAL+9f2p7i26U9fO+Pq22NEypQ=="], + "circuit-json-trace-length-analysis": ["circuit-json-trace-length-analysis@github:tscircuit/circuit-json-trace-length-analysis#2b44792", { "peerDependencies": { "typescript": "^5" } }, "tscircuit-circuit-json-trace-length-analysis-2b44792"], "circuit-to-svg": ["circuit-to-svg@0.0.345", "", { "dependencies": { "@types/node": "^22.5.5", "bun-types": "^1.1.40", "calculate-elbow": "0.0.12", "debug": "^4.4.3", "svg-path-commander": "^2.1.11", "svgson": "^5.3.1", "transformation-matrix": "^2.16.1" }, "peerDependencies": { "@tscircuit/alphabet": "*" } }, "sha512-d+P+AFJhWlt9Bdpk9/0zdBBjPxIRgnJaFsGqW/4CG0vEAY2QNqK/OqSl8i0zpFpM4+tiQdeR0n8h1tsvMMhvkA=="], diff --git a/cli/convert/register.ts b/cli/convert/register.ts deleted file mode 100644 index cedb4c98c..000000000 --- a/cli/convert/register.ts +++ /dev/null @@ -1,40 +0,0 @@ -import type { Command } from "commander" -import fs from "node:fs/promises" -import path from "node:path" -import kleur from "kleur" -import { parseKicadModToCircuitJson } from "kicad-component-converter" -import { convertCircuitJsonToTscircuit } from "circuit-json-to-tscircuit" - -export const registerConvert = (program: Command) => { - program - .command("convert") - .description("Convert a .kicad_mod footprint to a tscircuit component") - .argument("", "Path to the .kicad_mod file") - .option("-o, --output ", "Output TSX file path") - .option("-n, --name ", "Component name for export") - .action( - async (file: string, options: { output?: string; name?: string }) => { - try { - const inputPath = path.resolve(file) - const modContent = await fs.readFile(inputPath, "utf-8") - const circuitJson = await parseKicadModToCircuitJson(modContent) - const componentName = - options.name ?? path.basename(inputPath, ".kicad_mod") - const tsx = convertCircuitJsonToTscircuit(circuitJson, { - componentName, - }) - const outputPath = options.output - ? path.resolve(options.output) - : path.join(path.dirname(inputPath), `${componentName}.tsx`) - await fs.writeFile(outputPath, tsx) - console.log(kleur.green(`Converted ${outputPath}`)) - } catch (error) { - console.error( - kleur.red("Failed to convert footprint:"), - error instanceof Error ? error.message : error, - ) - process.exit(1) - } - }, - ) -} diff --git a/cli/main.ts b/cli/main.ts index a03780bdd..45a638160 100644 --- a/cli/main.ts +++ b/cli/main.ts @@ -23,7 +23,6 @@ import { registerClone } from "./clone/register" import { registerConfigPrint } from "./config/print/register" import { registerConfig } from "./config/register" import { registerConfigSet } from "./config/set/register" -import { registerConvert } from "./convert/register" import { registerDev } from "./dev/register" import { registerDoctor } from "./doctor/register" import { registerExport } from "./export/register" @@ -94,7 +93,6 @@ registerRegistryPackagesUpdate(program) registerSearch(program) registerImport(program) -registerConvert(program) registerSimulate(program) // Manually handle --version, -v, and -V flags diff --git a/package.json b/package.json index d69dd376e..c50257a39 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "circuit-json-to-readable-netlist": "^0.0.15", "circuit-json-to-spice": "^0.0.10", "circuit-json-to-step": "^0.0.33", - "circuit-json-to-tscircuit": "^0.0.9", "circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8", "commander": "^14.0.0", "conf": "^13.1.0", @@ -56,7 +55,6 @@ "jsonwebtoken": "^9.0.2", "jszip": "^3.10.1", "jwt-decode": "^4.0.0", - "kicad-component-converter": "^0.1.40", "kicad-to-circuit-json": "^0.0.59", "kicadts": "^0.0.35", "kleur": "^4.1.5", diff --git a/tests/cli/convert/convert-kicad-mod.test.ts b/tests/cli/convert/convert-kicad-mod.test.ts deleted file mode 100644 index f3a1745ac..000000000 --- a/tests/cli/convert/convert-kicad-mod.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { getCliTestFixture } from "../../fixtures/get-cli-test-fixture" -import { test, expect } from "bun:test" -import { writeFile, readFile } from "node:fs/promises" -import path from "node:path" - -const kicadMod = ` -(module R_0402_1005Metric (layer F.Cu) (tedit 5F68FEEE) - (descr "Resistor SMD 0402 (1005 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: IPC-SM-782 page 72, https://www.pcb-3d.com/wordpress/wp-content/uploads/ipc-sm-782a_amendment_1_and_2.pdf), generated with kicad-footprint-generator") - (tags resistor) - (attr smd) - (fp_text reference REF** (at 0 -1.17) (layer F.SilkS) - (effects (font (size 1 1) (thickness 0.15))) - ) - (fp_text value R_0402_1005Metric (at 0 1.17) (layer F.Fab) - (effects (font (size 1 1) (thickness 0.15))) - ) - (fp_line (start -0.525 0.27) (end -0.525 -0.27) (layer F.Fab) (width 0.1)) - (fp_line (start -0.525 -0.27) (end 0.525 -0.27) (layer F.Fab) (width 0.1)) - (fp_line (start 0.525 -0.27) (end 0.525 0.27) (layer F.Fab) (width 0.1)) - (fp_line (start 0.525 0.27) (end -0.525 0.27) (layer F.Fab) (width 0.1)) - (fp_line (start -0.153641 -0.38) (end 0.153641 -0.38) (layer F.SilkS) (width 0.12)) - (fp_line (start -0.153641 0.38) (end 0.153641 0.38) (layer F.SilkS) (width 0.12)) - (fp_line (start -0.93 0.47) (end -0.93 -0.47) (layer F.CrtYd) (width 0.05)) - (fp_line (start -0.93 -0.47) (end 0.93 -0.47) (layer F.CrtYd) (width 0.05)) - (fp_line (start 0.93 -0.47) (end 0.93 0.47) (layer F.CrtYd) (width 0.05)) - (fp_line (start 0.93 0.47) (end -0.93 0.47) (layer F.CrtYd) (width 0.05)) - (pad 1 smd roundrect (at -0.51 0) (size 0.54 0.64) (layers F.Cu F.Mask F.Paste) (roundrect_rratio 0.25)) - (pad 2 smd roundrect (at 0.51 0) (size 0.54 0.64) (layers F.Cu F.Mask F.Paste) (roundrect_rratio 0.25)) - (fp_text user %R (at 0 0) (layer F.Fab) - (effects (font (size 0.26 0.26) (thickness 0.04))) - ) - (model \${KISYS3DMOD}/Resistor_SMD.3dshapes/R_0402_1005Metric.wrl - (at (xyz 0 0 0)) - (scale (xyz 1 1 1)) - (rotate (xyz 0 0 0)) - ) -) -` - -test("convert kicad_mod to tsx", async () => { - const { tmpDir, runCommand } = await getCliTestFixture() - const modPath = path.join(tmpDir, "R_0402_1005Metric.kicad_mod") - await writeFile(modPath, kicadMod) - - const { stdout, stderr } = await runCommand(`tsci convert ${modPath}`) - expect(stderr).toBe("") - expect(stdout).toContain("Converted") - - const tsxPath = path.join(tmpDir, "R_0402_1005Metric.tsx") - const tsx = await readFile(tsxPath, "utf-8") - expect(tsx).toContain("export const R_0402_1005Metric") -})