From 644a57cb24c531bc4dda9f7c1463e1c46d65a9a0 Mon Sep 17 00:00:00 2001 From: Padmanabha Das <82430454+chayan-1906@users.noreply.github.com> Date: Thu, 2 Jul 2026 14:15:56 +0530 Subject: [PATCH 1/3] fix: pass { rawEasy } to convertRawEasyToTsx in CLI tsx conversion convertRawEasyToTsx expects an object with a rawEasy property, but the CLI passed the raw EasyEDA JSON directly, so rawEasy destructured to undefined and EasyEdaJsonSchema.parse crashed for every part when converting to .tsx/.ts output. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_018TPt9rFF6Uo76scbFcoyZ4 --- lib/convert-easyeda-json-to-various-formats.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/convert-easyeda-json-to-various-formats.ts b/lib/convert-easyeda-json-to-various-formats.ts index 744cace6..6f073a6b 100644 --- a/lib/convert-easyeda-json-to-various-formats.ts +++ b/lib/convert-easyeda-json-to-various-formats.ts @@ -84,7 +84,7 @@ export const convertEasyEdaJsonToVariousFormats = async ({ outputFilename.endsWith(".tsx") || outputFilename.endsWith(".ts") ) { - const tsComp = await convertRawEasyToTsx(rawEasyEdaJson) + const tsComp = await convertRawEasyToTsx({ rawEasy: rawEasyEdaJson }) await fs.writeFile(outputFilename, tsComp) console.log( `[${jlcpcbPartNumberOrFilepath}] Saved TypeScript component: ${outputFilename}`, From 735f6947d880b303c4728edcf3203186cc79fa5b Mon Sep 17 00:00:00 2001 From: Padmanabha Das <82430454+chayan-1906@users.noreply.github.com> Date: Thu, 2 Jul 2026 14:16:52 +0530 Subject: [PATCH 2/3] test: add regression test for converting a local raweasy.json to tsx Exercises the .tsx output path of convertEasyEdaJsonToVariousFormats using a local test asset (no network). Fails on main with the "expected object, received undefined" ZodError and passes with the fix. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_018TPt9rFF6Uo76scbFcoyZ4 --- ...rt-easyeda-json-to-various-formats.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/convert-easyeda-json-to-various-formats.test.ts diff --git a/tests/convert-easyeda-json-to-various-formats.test.ts b/tests/convert-easyeda-json-to-various-formats.test.ts new file mode 100644 index 00000000..ae5c2151 --- /dev/null +++ b/tests/convert-easyeda-json-to-various-formats.test.ts @@ -0,0 +1,23 @@ +import { expect, test } from "bun:test" +import fs from "node:fs/promises" +import os from "node:os" +import path from "node:path" +import { convertEasyEdaJsonToVariousFormats } from "lib/convert-easyeda-json-to-various-formats" + +test("converts a local raweasy.json file to a tsx component file", async () => { + const inputPath = path.join(import.meta.dir, "assets/C46749.raweasy.json") + const outputDir = await fs.mkdtemp( + path.join(os.tmpdir(), "easyeda-cli-test-"), + ) + const outputPath = path.join(outputDir, "C46749.tsx") + + await convertEasyEdaJsonToVariousFormats({ + jlcpcbPartNumberOrFilepath: inputPath, + outputFilename: outputPath, + outputFormat: "tsx", + }) + + const output = await fs.readFile(outputPath, "utf-8") + expect(output).toContain(" Date: Thu, 2 Jul 2026 14:17:38 +0530 Subject: [PATCH 3/3] docs: update convertRawEasyEdaToTs examples to the { rawEasy } signature The library examples still showed the old direct-argument call, which fails the same way as the CLI did. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_018TPt9rFF6Uo76scbFcoyZ4 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0f3525f5..89a325a0 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ const soupJson = convertEasyEdaJsonToCircuitJson(rawEasyJson) import { convertRawEasyEdaToTs } from "easyeda" // Convert to TypeScript React component -const tsxComponent = await convertRawEasyEdaToTs(rawEasyJson) +const tsxComponent = await convertRawEasyEdaToTs({ rawEasy: rawEasyJson }) ``` ### Full Example: Fetching and Converting to TSX @@ -36,7 +36,7 @@ import { fetchEasyEDAComponent, convertRawEasyEdaToTs } from "easyeda" async function convertPartNumberToTsx(partNumber: string) { const rawEasyJson = await fetchEasyEDAComponent(partNumber) - const tsxComponent = await convertRawEasyEdaToTs(rawEasyJson) + const tsxComponent = await convertRawEasyEdaToTs({ rawEasy: rawEasyJson }) return tsxComponent }