@tscircuit/cli 0.1.231 → 0.1.233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +158 -82
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -63256,7 +63256,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
63256
63256
|
import { execSync as execSync2 } from "node:child_process";
|
|
63257
63257
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
63258
63258
|
// package.json
|
|
63259
|
-
var version = "0.1.
|
|
63259
|
+
var version = "0.1.231";
|
|
63260
63260
|
var package_default = {
|
|
63261
63261
|
name: "@tscircuit/cli",
|
|
63262
63262
|
version,
|
|
@@ -173655,8 +173655,8 @@ var registerRemove = (program3) => {
|
|
|
173655
173655
|
};
|
|
173656
173656
|
|
|
173657
173657
|
// cli/build/register.ts
|
|
173658
|
-
import
|
|
173659
|
-
import
|
|
173658
|
+
import path29 from "node:path";
|
|
173659
|
+
import fs30 from "node:fs";
|
|
173660
173660
|
|
|
173661
173661
|
// cli/build/build-file.ts
|
|
173662
173662
|
import path26 from "node:path";
|
|
@@ -173728,30 +173728,48 @@ async function getBuildEntrypoints({
|
|
|
173728
173728
|
rootDir = process.cwd()
|
|
173729
173729
|
}) {
|
|
173730
173730
|
const resolvedRoot = path27.resolve(rootDir);
|
|
173731
|
+
const buildFromProjectDir = async (projectDir2) => {
|
|
173732
|
+
const files = globbySync(["**/*.board.tsx", "**/*.circuit.tsx"], {
|
|
173733
|
+
cwd: projectDir2,
|
|
173734
|
+
ignore: DEFAULT_IGNORED_PATTERNS
|
|
173735
|
+
});
|
|
173736
|
+
if (files.length > 0) {
|
|
173737
|
+
return {
|
|
173738
|
+
projectDir: projectDir2,
|
|
173739
|
+
circuitFiles: files.map((f) => path27.join(projectDir2, f))
|
|
173740
|
+
};
|
|
173741
|
+
}
|
|
173742
|
+
const mainEntrypoint = await getEntrypoint({
|
|
173743
|
+
projectDir: projectDir2,
|
|
173744
|
+
onSuccess: () => {
|
|
173745
|
+
return;
|
|
173746
|
+
},
|
|
173747
|
+
onError: () => {
|
|
173748
|
+
return;
|
|
173749
|
+
}
|
|
173750
|
+
});
|
|
173751
|
+
if (mainEntrypoint) {
|
|
173752
|
+
return {
|
|
173753
|
+
projectDir: projectDir2,
|
|
173754
|
+
mainEntrypoint,
|
|
173755
|
+
circuitFiles: [mainEntrypoint]
|
|
173756
|
+
};
|
|
173757
|
+
}
|
|
173758
|
+
return {
|
|
173759
|
+
projectDir: projectDir2,
|
|
173760
|
+
circuitFiles: []
|
|
173761
|
+
};
|
|
173762
|
+
};
|
|
173731
173763
|
if (fileOrDir) {
|
|
173732
173764
|
const resolved = path27.resolve(resolvedRoot, fileOrDir);
|
|
173733
173765
|
if (fs28.existsSync(resolved) && fs28.statSync(resolved).isDirectory()) {
|
|
173734
173766
|
const projectDir2 = resolved;
|
|
173735
|
-
|
|
173736
|
-
cwd: projectDir2,
|
|
173737
|
-
ignore: DEFAULT_IGNORED_PATTERNS
|
|
173738
|
-
});
|
|
173739
|
-
return {
|
|
173740
|
-
projectDir: projectDir2,
|
|
173741
|
-
circuitFiles: files2.map((f) => path27.join(projectDir2, f))
|
|
173742
|
-
};
|
|
173767
|
+
return buildFromProjectDir(projectDir2);
|
|
173743
173768
|
}
|
|
173744
173769
|
return { projectDir: path27.dirname(resolved), circuitFiles: [resolved] };
|
|
173745
173770
|
}
|
|
173746
173771
|
const projectDir = resolvedRoot;
|
|
173747
|
-
|
|
173748
|
-
cwd: projectDir,
|
|
173749
|
-
ignore: DEFAULT_IGNORED_PATTERNS
|
|
173750
|
-
});
|
|
173751
|
-
return {
|
|
173752
|
-
projectDir,
|
|
173753
|
-
circuitFiles: files.map((f) => path27.join(projectDir, f))
|
|
173754
|
-
};
|
|
173772
|
+
return buildFromProjectDir(projectDir);
|
|
173755
173773
|
}
|
|
173756
173774
|
|
|
173757
173775
|
// lib/site/getStaticIndexHtmlFile.ts
|
|
@@ -173782,10 +173800,55 @@ ${scriptBlock} <script src="https://cdn.tailwindcss.com"></script>
|
|
|
173782
173800
|
</html>`;
|
|
173783
173801
|
};
|
|
173784
173802
|
|
|
173803
|
+
// cli/build/build-preview-images.ts
|
|
173804
|
+
import fs29 from "node:fs";
|
|
173805
|
+
import path28 from "node:path";
|
|
173806
|
+
import {
|
|
173807
|
+
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
|
|
173808
|
+
convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg2
|
|
173809
|
+
} from "circuit-to-svg";
|
|
173810
|
+
import { convertCircuitJsonToSimple3dSvg } from "circuit-json-to-simple-3d";
|
|
173811
|
+
import sharp from "sharp";
|
|
173812
|
+
var buildPreviewImages = async ({
|
|
173813
|
+
builtFiles,
|
|
173814
|
+
distDir,
|
|
173815
|
+
mainEntrypoint
|
|
173816
|
+
}) => {
|
|
173817
|
+
const successfulBuilds = builtFiles.filter((file) => file.ok);
|
|
173818
|
+
const normalizedMainEntrypoint = mainEntrypoint ? path28.resolve(mainEntrypoint) : undefined;
|
|
173819
|
+
const previewBuild = (() => {
|
|
173820
|
+
if (normalizedMainEntrypoint) {
|
|
173821
|
+
const match = successfulBuilds.find((built) => path28.resolve(built.sourcePath) === normalizedMainEntrypoint);
|
|
173822
|
+
if (match)
|
|
173823
|
+
return match;
|
|
173824
|
+
}
|
|
173825
|
+
return successfulBuilds[0];
|
|
173826
|
+
})();
|
|
173827
|
+
if (!previewBuild) {
|
|
173828
|
+
console.warn("No successful build output available for preview image generation.");
|
|
173829
|
+
return;
|
|
173830
|
+
}
|
|
173831
|
+
try {
|
|
173832
|
+
const circuitJsonRaw = fs29.readFileSync(previewBuild.outputPath, "utf-8");
|
|
173833
|
+
const circuitJson = JSON.parse(circuitJsonRaw);
|
|
173834
|
+
const pcbSvg = convertCircuitJsonToPcbSvg3(circuitJson);
|
|
173835
|
+
const schematicSvg = convertCircuitJsonToSchematicSvg2(circuitJson);
|
|
173836
|
+
const simple3dSvg = await convertCircuitJsonToSimple3dSvg(circuitJson);
|
|
173837
|
+
fs29.writeFileSync(path28.join(distDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
173838
|
+
fs29.writeFileSync(path28.join(distDir, "schematic.svg"), schematicSvg, "utf-8");
|
|
173839
|
+
if (simple3dSvg) {
|
|
173840
|
+
const pngBuffer = await sharp(Buffer.from(simple3dSvg)).png().toBuffer();
|
|
173841
|
+
fs29.writeFileSync(path28.join(distDir, "3d.png"), pngBuffer);
|
|
173842
|
+
}
|
|
173843
|
+
} catch (error) {
|
|
173844
|
+
console.error("Failed to generate preview images:", error);
|
|
173845
|
+
}
|
|
173846
|
+
};
|
|
173847
|
+
|
|
173785
173848
|
// cli/build/register.ts
|
|
173786
173849
|
var registerBuild = (program3) => {
|
|
173787
|
-
program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--disable-pcb", "Disable PCB outputs").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").action(async (file, options) => {
|
|
173788
|
-
const { projectDir, circuitFiles } = await getBuildEntrypoints({
|
|
173850
|
+
program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--disable-pcb", "Disable PCB outputs").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").option("--preview-images", "Generate preview images in the dist directory").action(async (file, options) => {
|
|
173851
|
+
const { projectDir, circuitFiles, mainEntrypoint } = await getBuildEntrypoints({
|
|
173789
173852
|
fileOrDir: file
|
|
173790
173853
|
});
|
|
173791
173854
|
const platformConfig2 = (() => {
|
|
@@ -173800,25 +173863,31 @@ var registerBuild = (program3) => {
|
|
|
173800
173863
|
}
|
|
173801
173864
|
return config;
|
|
173802
173865
|
})();
|
|
173803
|
-
const distDir =
|
|
173804
|
-
|
|
173866
|
+
const distDir = path29.join(projectDir, "dist");
|
|
173867
|
+
fs30.mkdirSync(distDir, { recursive: true });
|
|
173805
173868
|
let hasErrors = false;
|
|
173806
173869
|
const staticFileReferences = [];
|
|
173870
|
+
const builtFiles = [];
|
|
173807
173871
|
for (const filePath of circuitFiles) {
|
|
173808
|
-
const relative9 =
|
|
173872
|
+
const relative9 = path29.relative(projectDir, filePath);
|
|
173809
173873
|
const outputDirName = relative9.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
173810
|
-
const outputPath =
|
|
173874
|
+
const outputPath = path29.join(distDir, outputDirName, "circuit.json");
|
|
173811
173875
|
const ok = await buildFile(filePath, outputPath, projectDir, {
|
|
173812
173876
|
ignoreErrors: options?.ignoreErrors,
|
|
173813
173877
|
ignoreWarnings: options?.ignoreWarnings,
|
|
173814
173878
|
platformConfig: platformConfig2
|
|
173815
173879
|
});
|
|
173880
|
+
builtFiles.push({
|
|
173881
|
+
sourcePath: filePath,
|
|
173882
|
+
outputPath,
|
|
173883
|
+
ok
|
|
173884
|
+
});
|
|
173816
173885
|
if (!ok) {
|
|
173817
173886
|
hasErrors = true;
|
|
173818
173887
|
} else if (options?.site) {
|
|
173819
|
-
const normalizedSourcePath = relative9.split(
|
|
173820
|
-
const relativeOutputPath =
|
|
173821
|
-
const normalizedOutputPath = relativeOutputPath.split(
|
|
173888
|
+
const normalizedSourcePath = relative9.split(path29.sep).join("/");
|
|
173889
|
+
const relativeOutputPath = path29.join(outputDirName, "circuit.json");
|
|
173890
|
+
const normalizedOutputPath = relativeOutputPath.split(path29.sep).join("/");
|
|
173822
173891
|
staticFileReferences.push({
|
|
173823
173892
|
filePath: normalizedSourcePath,
|
|
173824
173893
|
fileStaticAssetUrl: `./${normalizedOutputPath}`
|
|
@@ -173828,31 +173897,38 @@ var registerBuild = (program3) => {
|
|
|
173828
173897
|
if (hasErrors && !options?.ignoreErrors) {
|
|
173829
173898
|
process.exit(1);
|
|
173830
173899
|
}
|
|
173900
|
+
if (options?.previewImages) {
|
|
173901
|
+
await buildPreviewImages({
|
|
173902
|
+
builtFiles,
|
|
173903
|
+
distDir,
|
|
173904
|
+
mainEntrypoint
|
|
173905
|
+
});
|
|
173906
|
+
}
|
|
173831
173907
|
if (options?.site) {
|
|
173832
173908
|
const indexHtml = getStaticIndexHtmlFile({
|
|
173833
173909
|
files: staticFileReferences,
|
|
173834
173910
|
standaloneScriptSrc: "./standalone.min.js"
|
|
173835
173911
|
});
|
|
173836
|
-
|
|
173837
|
-
|
|
173912
|
+
fs30.writeFileSync(path29.join(distDir, "index.html"), indexHtml);
|
|
173913
|
+
fs30.writeFileSync(path29.join(distDir, "standalone.min.js"), standalone_min_default);
|
|
173838
173914
|
}
|
|
173839
173915
|
});
|
|
173840
173916
|
};
|
|
173841
173917
|
|
|
173842
173918
|
// lib/shared/snapshot-project.ts
|
|
173843
|
-
import
|
|
173844
|
-
import
|
|
173919
|
+
import fs32 from "node:fs";
|
|
173920
|
+
import path30 from "node:path";
|
|
173845
173921
|
import looksSame2 from "looks-same";
|
|
173846
|
-
import
|
|
173922
|
+
import sharp2 from "sharp";
|
|
173847
173923
|
import {
|
|
173848
|
-
convertCircuitJsonToPcbSvg as
|
|
173849
|
-
convertCircuitJsonToSchematicSvg as
|
|
173924
|
+
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg4,
|
|
173925
|
+
convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg3
|
|
173850
173926
|
} from "circuit-to-svg";
|
|
173851
|
-
import { convertCircuitJsonToSimple3dSvg } from "circuit-json-to-simple-3d";
|
|
173927
|
+
import { convertCircuitJsonToSimple3dSvg as convertCircuitJsonToSimple3dSvg2 } from "circuit-json-to-simple-3d";
|
|
173852
173928
|
|
|
173853
173929
|
// lib/shared/compare-images.ts
|
|
173854
173930
|
import looksSame from "looks-same";
|
|
173855
|
-
import
|
|
173931
|
+
import fs31 from "node:fs/promises";
|
|
173856
173932
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
173857
173933
|
const { equal: equal2 } = await looksSame(buffer1, buffer2, {
|
|
173858
173934
|
strict: false,
|
|
@@ -173868,7 +173944,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
|
173868
173944
|
tolerance: 2
|
|
173869
173945
|
});
|
|
173870
173946
|
} else {
|
|
173871
|
-
await
|
|
173947
|
+
await fs31.writeFile(diffPath, buffer2);
|
|
173872
173948
|
}
|
|
173873
173949
|
}
|
|
173874
173950
|
return { equal: equal2 };
|
|
@@ -173893,19 +173969,19 @@ var snapshotProject = async ({
|
|
|
173893
173969
|
...DEFAULT_IGNORED_PATTERNS,
|
|
173894
173970
|
...ignored.map(normalizeIgnorePattern)
|
|
173895
173971
|
];
|
|
173896
|
-
const resolvedPaths = filePaths.map((f) =>
|
|
173972
|
+
const resolvedPaths = filePaths.map((f) => path30.resolve(projectDir, f));
|
|
173897
173973
|
const boardFiles = resolvedPaths.length > 0 ? resolvedPaths.flatMap((p) => {
|
|
173898
|
-
if (
|
|
173974
|
+
if (fs32.existsSync(p) && fs32.statSync(p).isDirectory()) {
|
|
173899
173975
|
return globbySync(["**/*.board.tsx", "**/*.circuit.tsx"], {
|
|
173900
173976
|
cwd: p,
|
|
173901
173977
|
ignore
|
|
173902
|
-
}).map((f) =>
|
|
173978
|
+
}).map((f) => path30.join(p, f));
|
|
173903
173979
|
}
|
|
173904
173980
|
return [p];
|
|
173905
173981
|
}) : globbySync(["**/*.board.tsx", "**/*.circuit.tsx"], {
|
|
173906
173982
|
cwd: projectDir,
|
|
173907
173983
|
ignore
|
|
173908
|
-
}).map((f) =>
|
|
173984
|
+
}).map((f) => path30.join(projectDir, f));
|
|
173909
173985
|
if (boardFiles.length === 0) {
|
|
173910
173986
|
console.log("No entrypoint found. Run 'tsci init' to bootstrap a project or specify a file with 'tsci snapshot <file>'");
|
|
173911
173987
|
return onExit(0);
|
|
@@ -173917,12 +173993,12 @@ var snapshotProject = async ({
|
|
|
173917
173993
|
filePath: file,
|
|
173918
173994
|
platformConfig: platformConfig2
|
|
173919
173995
|
});
|
|
173920
|
-
const pcbSvg =
|
|
173921
|
-
const schSvg =
|
|
173922
|
-
const svg3d = threeD ? await
|
|
173923
|
-
const snapDir =
|
|
173924
|
-
|
|
173925
|
-
const base =
|
|
173996
|
+
const pcbSvg = convertCircuitJsonToPcbSvg4(circuitJson);
|
|
173997
|
+
const schSvg = convertCircuitJsonToSchematicSvg3(circuitJson);
|
|
173998
|
+
const svg3d = threeD ? await convertCircuitJsonToSimple3dSvg2(circuitJson) : null;
|
|
173999
|
+
const snapDir = path30.join(path30.dirname(file), "__snapshots__");
|
|
174000
|
+
fs32.mkdirSync(snapDir, { recursive: true });
|
|
174001
|
+
const base = path30.basename(file).replace(/\.tsx$/, "");
|
|
173926
174002
|
const pairs3 = [];
|
|
173927
174003
|
if (pcbOnly || !schematicOnly)
|
|
173928
174004
|
pairs3.push(["pcb", pcbSvg]);
|
|
@@ -173936,31 +174012,31 @@ var snapshotProject = async ({
|
|
|
173936
174012
|
}
|
|
173937
174013
|
for (const [type, newSvg] of pairs3) {
|
|
173938
174014
|
const is3d = type === "3d";
|
|
173939
|
-
const snapPath =
|
|
173940
|
-
const existing =
|
|
173941
|
-
const newContentBuffer = is3d ? await
|
|
174015
|
+
const snapPath = path30.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
174016
|
+
const existing = fs32.existsSync(snapPath);
|
|
174017
|
+
const newContentBuffer = is3d ? await sharp2(Buffer.from(newSvg)).png().toBuffer() : Buffer.from(newSvg, "utf8");
|
|
173942
174018
|
const newContentForFile = is3d ? newContentBuffer : newSvg;
|
|
173943
174019
|
if (!existing) {
|
|
173944
|
-
|
|
173945
|
-
console.log("✅", kleur_default.gray(
|
|
174020
|
+
fs32.writeFileSync(snapPath, newContentForFile);
|
|
174021
|
+
console.log("✅", kleur_default.gray(path30.relative(projectDir, snapPath)));
|
|
173946
174022
|
didUpdate = true;
|
|
173947
174023
|
continue;
|
|
173948
174024
|
}
|
|
173949
|
-
const oldContentBuffer =
|
|
174025
|
+
const oldContentBuffer = fs32.readFileSync(snapPath);
|
|
173950
174026
|
const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
173951
174027
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
|
|
173952
174028
|
if (update) {
|
|
173953
174029
|
if (!forceUpdate && equal2) {
|
|
173954
|
-
console.log("✅", kleur_default.gray(
|
|
174030
|
+
console.log("✅", kleur_default.gray(path30.relative(projectDir, snapPath)));
|
|
173955
174031
|
} else {
|
|
173956
|
-
|
|
173957
|
-
console.log("✅", kleur_default.gray(
|
|
174032
|
+
fs32.writeFileSync(snapPath, newContentForFile);
|
|
174033
|
+
console.log("✅", kleur_default.gray(path30.relative(projectDir, snapPath)));
|
|
173958
174034
|
didUpdate = true;
|
|
173959
174035
|
}
|
|
173960
174036
|
} else if (!equal2) {
|
|
173961
174037
|
mismatches.push(`${snapPath} (diff: ${diffPath})`);
|
|
173962
174038
|
} else {
|
|
173963
|
-
console.log("✅", kleur_default.gray(
|
|
174039
|
+
console.log("✅", kleur_default.gray(path30.relative(projectDir, snapPath)));
|
|
173964
174040
|
}
|
|
173965
174041
|
}
|
|
173966
174042
|
}
|
|
@@ -173999,22 +174075,22 @@ var registerSnapshot = (program3) => {
|
|
|
173999
174075
|
};
|
|
174000
174076
|
|
|
174001
174077
|
// lib/shared/setup-github-actions.ts
|
|
174002
|
-
import
|
|
174003
|
-
import
|
|
174078
|
+
import fs33 from "node:fs";
|
|
174079
|
+
import path31 from "node:path";
|
|
174004
174080
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
174005
174081
|
const findGitRoot = (startDir) => {
|
|
174006
|
-
let dir =
|
|
174007
|
-
while (dir !==
|
|
174008
|
-
if (
|
|
174082
|
+
let dir = path31.resolve(startDir);
|
|
174083
|
+
while (dir !== path31.parse(dir).root) {
|
|
174084
|
+
if (fs33.existsSync(path31.join(dir, ".git"))) {
|
|
174009
174085
|
return dir;
|
|
174010
174086
|
}
|
|
174011
|
-
dir =
|
|
174087
|
+
dir = path31.dirname(dir);
|
|
174012
174088
|
}
|
|
174013
174089
|
return null;
|
|
174014
174090
|
};
|
|
174015
174091
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
174016
|
-
const workflowsDir =
|
|
174017
|
-
|
|
174092
|
+
const workflowsDir = path31.join(gitRoot, ".github", "workflows");
|
|
174093
|
+
fs33.mkdirSync(workflowsDir, { recursive: true });
|
|
174018
174094
|
const buildWorkflow = `name: tscircuit Build
|
|
174019
174095
|
|
|
174020
174096
|
on:
|
|
@@ -174053,8 +174129,8 @@ jobs:
|
|
|
174053
174129
|
- run: bun install
|
|
174054
174130
|
- run: bunx tsci snapshot
|
|
174055
174131
|
`;
|
|
174056
|
-
writeFileIfNotExists(
|
|
174057
|
-
writeFileIfNotExists(
|
|
174132
|
+
writeFileIfNotExists(path31.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
174133
|
+
writeFileIfNotExists(path31.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
174058
174134
|
};
|
|
174059
174135
|
|
|
174060
174136
|
// cli/setup/register.ts
|
|
@@ -174080,8 +174156,8 @@ var registerSetup = (program3) => {
|
|
|
174080
174156
|
};
|
|
174081
174157
|
|
|
174082
174158
|
// cli/convert/register.ts
|
|
174083
|
-
import
|
|
174084
|
-
import
|
|
174159
|
+
import fs34 from "node:fs/promises";
|
|
174160
|
+
import path32 from "node:path";
|
|
174085
174161
|
|
|
174086
174162
|
// node_modules/kicad-component-converter/dist/index.js
|
|
174087
174163
|
var __create4 = Object.create;
|
|
@@ -175393,8 +175469,8 @@ function getErrorMap() {
|
|
|
175393
175469
|
return overrideErrorMap;
|
|
175394
175470
|
}
|
|
175395
175471
|
var makeIssue = (params2) => {
|
|
175396
|
-
const { data, path:
|
|
175397
|
-
const fullPath = [...
|
|
175472
|
+
const { data, path: path32, errorMaps, issueData } = params2;
|
|
175473
|
+
const fullPath = [...path32, ...issueData.path || []];
|
|
175398
175474
|
const fullIssue = {
|
|
175399
175475
|
...issueData,
|
|
175400
175476
|
path: fullPath
|
|
@@ -175502,11 +175578,11 @@ var errorUtil;
|
|
|
175502
175578
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
175503
175579
|
})(errorUtil || (errorUtil = {}));
|
|
175504
175580
|
var ParseInputLazyPath = class {
|
|
175505
|
-
constructor(parent, value,
|
|
175581
|
+
constructor(parent, value, path32, key) {
|
|
175506
175582
|
this._cachedPath = [];
|
|
175507
175583
|
this.parent = parent;
|
|
175508
175584
|
this.data = value;
|
|
175509
|
-
this._path =
|
|
175585
|
+
this._path = path32;
|
|
175510
175586
|
this._key = key;
|
|
175511
175587
|
}
|
|
175512
175588
|
get path() {
|
|
@@ -179295,14 +179371,14 @@ function generateArcPath(start, mid, end, numPoints) {
|
|
|
179295
179371
|
if (angleDelta < 0) {
|
|
179296
179372
|
angleDelta += 2 * Math.PI;
|
|
179297
179373
|
}
|
|
179298
|
-
const
|
|
179374
|
+
const path32 = [];
|
|
179299
179375
|
for (let i = 0;i <= numPoints; i++) {
|
|
179300
179376
|
const angle = angleStart + i / numPoints * angleDelta;
|
|
179301
179377
|
const x = center2.x + radius * Math.cos(angle);
|
|
179302
179378
|
const y = center2.y + radius * Math.sin(angle);
|
|
179303
|
-
|
|
179379
|
+
path32.push({ x, y });
|
|
179304
179380
|
}
|
|
179305
|
-
return
|
|
179381
|
+
return path32;
|
|
179306
179382
|
}
|
|
179307
179383
|
var makePoint = (p) => {
|
|
179308
179384
|
if (Array.isArray(p)) {
|
|
@@ -179746,15 +179822,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
179746
179822
|
var registerConvert = (program3) => {
|
|
179747
179823
|
program3.command("convert").description("Convert a .kicad_mod footprint to a tscircuit component").argument("<file>", "Path to the .kicad_mod file").option("-o, --output <path>", "Output TSX file path").option("-n, --name <component>", "Component name for export").action(async (file, options) => {
|
|
179748
179824
|
try {
|
|
179749
|
-
const inputPath =
|
|
179750
|
-
const modContent = await
|
|
179825
|
+
const inputPath = path32.resolve(file);
|
|
179826
|
+
const modContent = await fs34.readFile(inputPath, "utf-8");
|
|
179751
179827
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
179752
|
-
const componentName = options.name ??
|
|
179828
|
+
const componentName = options.name ?? path32.basename(inputPath, ".kicad_mod");
|
|
179753
179829
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
179754
179830
|
componentName
|
|
179755
179831
|
});
|
|
179756
|
-
const outputPath = options.output ?
|
|
179757
|
-
await
|
|
179832
|
+
const outputPath = options.output ? path32.resolve(options.output) : path32.join(path32.dirname(inputPath), `${componentName}.tsx`);
|
|
179833
|
+
await fs34.writeFile(outputPath, tsx);
|
|
179758
179834
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
179759
179835
|
} catch (error) {
|
|
179760
179836
|
console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
|