@tscircuit/cli 0.1.799 → 0.1.801

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 CHANGED
@@ -73386,6 +73386,7 @@ var projectConfigSchema = z.object({
73386
73386
  prebuildCommand: z.string().optional(),
73387
73387
  buildCommand: z.string().optional(),
73388
73388
  kicadLibraryEntrypointPath: z.string().optional(),
73389
+ kicadLibraryName: z.string().optional(),
73389
73390
  alwaysUseLatestTscircuitOnCloud: z.boolean().optional(),
73390
73391
  build: z.object({
73391
73392
  circuitJson: z.boolean().optional(),
@@ -74266,7 +74267,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
74266
74267
  import { execSync as execSync2 } from "node:child_process";
74267
74268
  var import_semver2 = __toESM2(require_semver2(), 1);
74268
74269
  // package.json
74269
- var version = "0.1.798";
74270
+ var version = "0.1.800";
74270
74271
  var package_default = {
74271
74272
  name: "@tscircuit/cli",
74272
74273
  version,
@@ -86895,29 +86896,36 @@ Fuse.config = Config;
86895
86896
 
86896
86897
  // cli/search/register.ts
86897
86898
  var registerSearch = (program3) => {
86898
- program3.command("search").description("Search for footprints, CAD models or packages in the tscircuit ecosystem").argument("<query>", "Search query (e.g. keyword, author, or package name)").option("--kicad", "Only search KiCad footprints").action(async (query, opts) => {
86899
- const onlyKicad = opts.kicad;
86899
+ program3.command("search").description("Search for footprints, CAD models or packages in the tscircuit ecosystem").argument("<query>", "Search query (e.g. keyword, author, or package name)").option("--kicad", "Search KiCad footprints").option("--jlcpcb", "Search JLCPCB components").option("--lcsc", "Alias for --jlcpcb").option("--tscircuit", "Search tscircuit registry packages").action(async (query, opts) => {
86900
+ const hasFilters = opts.kicad || opts.jlcpcb || opts.lcsc || opts.tscircuit;
86901
+ const searchKicad = opts.kicad || !hasFilters;
86902
+ const searchJlc = opts.jlcpcb || opts.lcsc || !hasFilters;
86903
+ const searchTscircuit = opts.tscircuit || !hasFilters;
86900
86904
  let results = { packages: [] };
86901
86905
  let jlcResults = [];
86902
86906
  let kicadResults = [];
86903
86907
  try {
86904
- if (!onlyKicad) {
86908
+ if (searchTscircuit) {
86905
86909
  const ky2 = getRegistryApiKy();
86906
86910
  results = await ky2.post("packages/search", {
86907
86911
  json: { query }
86908
86912
  }).json();
86913
+ }
86914
+ if (searchJlc) {
86909
86915
  const jlcSearchUrl = "https://jlcsearch.tscircuit.com/api/search?limit=10&q=" + encodeURIComponent(query);
86910
86916
  const jlcResponse = await fetch(jlcSearchUrl).then((r) => r.json());
86911
86917
  jlcResults = jlcResponse?.components ?? [];
86912
86918
  }
86913
- const kicadFiles = await fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then((r) => r.json());
86914
- const fuse = new Fuse(kicadFiles);
86915
- kicadResults = fuse.search(query).slice(0, 10).map((r) => r.item);
86919
+ if (searchKicad) {
86920
+ const kicadFiles = await fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then((r) => r.json());
86921
+ const fuse = new Fuse(kicadFiles);
86922
+ kicadResults = fuse.search(query).slice(0, 10).map((r) => r.item);
86923
+ }
86916
86924
  } catch (error) {
86917
86925
  console.error(kleur_default.red("Failed to search registry:"), error instanceof Error ? error.message : error);
86918
86926
  process.exit(1);
86919
86927
  }
86920
- if (!kicadResults.length && (!results.packages.length && !jlcResults.length || onlyKicad)) {
86928
+ if (!kicadResults.length && !results.packages.length && !jlcResults.length) {
86921
86929
  console.log(kleur_default.yellow("No results found matching your query."));
86922
86930
  return;
86923
86931
  }
@@ -86927,7 +86935,7 @@ var registerSearch = (program3) => {
86927
86935
  console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path35.replace(".kicad_mod", "").replace(".pretty", "")}`);
86928
86936
  });
86929
86937
  }
86930
- if (!onlyKicad && results.packages.length) {
86938
+ if (results.packages.length) {
86931
86939
  console.log(kleur_default.bold().underline(`Found ${results.packages.length} package(s) in the tscircuit registry:`));
86932
86940
  results.packages.forEach((pkg, idx) => {
86933
86941
  const star = pkg.star_count ?? 0;
@@ -86935,7 +86943,7 @@ var registerSearch = (program3) => {
86935
86943
  console.log(`${idx + 1}. ${pkg.name}${versionStr} - Stars: ${star}${pkg.description ? ` - ${pkg.description}` : ""}`);
86936
86944
  });
86937
86945
  }
86938
- if (!onlyKicad && jlcResults.length) {
86946
+ if (jlcResults.length) {
86939
86947
  console.log();
86940
86948
  console.log(kleur_default.bold().underline(`Found ${jlcResults.length} component(s) in JLC search:`));
86941
86949
  jlcResults.forEach((comp, idx) => {
@@ -172819,8 +172827,8 @@ var registerRemove = (program3) => {
172819
172827
  };
172820
172828
 
172821
172829
  // cli/build/register.ts
172822
- import path49 from "node:path";
172823
- import fs49 from "node:fs";
172830
+ import path50 from "node:path";
172831
+ import fs50 from "node:fs";
172824
172832
 
172825
172833
  // cli/build/build-file.ts
172826
172834
  import path36 from "node:path";
@@ -173549,8 +173557,8 @@ var generateKicadProject = async ({
173549
173557
  };
173550
173558
 
173551
173559
  // cli/build/build-kicad-pcm.ts
173552
- import path44 from "node:path";
173553
- import fs44 from "node:fs";
173560
+ import path45 from "node:path";
173561
+ import fs45 from "node:fs";
173554
173562
 
173555
173563
  // lib/shared/generate-pcm-assets.ts
173556
173564
  var import_jszip3 = __toESM2(require_lib4(), 1);
@@ -173562,19 +173570,20 @@ async function generatePcmAssets(options) {
173562
173570
  packageName,
173563
173571
  version: version2,
173564
173572
  author,
173565
- description = `${packageName} - tscircuit component`,
173566
- descriptionFull = `A tscircuit component exported for use in KiCad. Visit https://tscircuit.com/${author}/${packageName} for more information.`,
173573
+ description = "",
173574
+ descriptionFull = `Visit https://tscircuit.com/${author}/${packageName} for more information.`,
173567
173575
  license = "MIT",
173568
173576
  kicadLibraryPath,
173569
173577
  outputDir,
173570
- baseUrl
173578
+ baseUrl,
173579
+ displayName = `${author}/${packageName}`
173571
173580
  } = options;
173572
173581
  const identifier = `com.tscircuit.${author}.${packageName}`.toLowerCase().replace(/[^a-z0-9.-]/g, "-").slice(0, 50);
173573
173582
  fs43.mkdirSync(outputDir, { recursive: true });
173574
173583
  console.log("Creating metadata.json...");
173575
173584
  const metadata = {
173576
173585
  $schema: "https://go.kicad.org/pcm/schemas/v1",
173577
- name: `tscircuit ${packageName}`,
173586
+ name: displayName,
173578
173587
  description: description.slice(0, 500),
173579
173588
  description_full: descriptionFull.slice(0, 5000),
173580
173589
  identifier,
@@ -173610,7 +173619,7 @@ async function generatePcmAssets(options) {
173610
173619
  packages: [
173611
173620
  {
173612
173621
  identifier,
173613
- name: `tscircuit ${packageName}`,
173622
+ name: displayName,
173614
173623
  description: description.slice(0, 500),
173615
173624
  description_full: descriptionFull.slice(0, 5000),
173616
173625
  type: "library",
@@ -173643,7 +173652,7 @@ async function generatePcmAssets(options) {
173643
173652
  const packagesJsonUrl = baseUrl ? `${baseUrl}/pcm/packages.json` : "./packages.json";
173644
173653
  const repositoryJson = {
173645
173654
  $schema: "https://go.kicad.org/pcm/schemas/v1",
173646
- name: `tscircuit ${author}/${packageName}`,
173655
+ name: displayName,
173647
173656
  maintainer: {
173648
173657
  name: author,
173649
173658
  contact: {
@@ -173709,24 +173718,46 @@ async function createPcmZip(options) {
173709
173718
  fs43.writeFileSync(outputPath, zipBuffer);
173710
173719
  }
173711
173720
 
173721
+ // lib/utils/resolve-kicad-library-name.ts
173722
+ import path44 from "node:path";
173723
+ import fs44 from "node:fs";
173724
+ function resolveKicadLibraryName({
173725
+ projectDir
173726
+ }) {
173727
+ const projectConfig2 = loadProjectConfig(projectDir);
173728
+ if (projectConfig2?.kicadLibraryName) {
173729
+ return projectConfig2.kicadLibraryName;
173730
+ }
173731
+ const packageJsonPath = path44.join(projectDir, "package.json");
173732
+ if (fs44.existsSync(packageJsonPath)) {
173733
+ const packageJson = JSON.parse(fs44.readFileSync(packageJsonPath, "utf-8"));
173734
+ const unscopedName = getUnscopedPackageName(packageJson.name || "");
173735
+ if (unscopedName) {
173736
+ return unscopedName.replace("@tsci/", "").replace(/\./g, "-");
173737
+ }
173738
+ }
173739
+ throw new Error(`Couldn't resolve KiCad library name. Please set kicadLibraryName in tscircuit.config.json or add the "name" field to package.json`);
173740
+ }
173741
+
173712
173742
  // cli/build/build-kicad-pcm.ts
173713
173743
  async function buildKicadPcm({
173714
173744
  entryFile,
173715
173745
  projectDir,
173716
173746
  distDir
173717
173747
  }) {
173718
- const packageJsonPath = path44.join(projectDir, "package.json");
173719
- if (!fs44.existsSync(packageJsonPath)) {
173748
+ const packageJsonPath = path45.join(projectDir, "package.json");
173749
+ if (!fs45.existsSync(packageJsonPath)) {
173720
173750
  throw new Error("No package.json found for KiCad PCM generation");
173721
173751
  }
173722
- const packageJson = JSON.parse(fs44.readFileSync(packageJsonPath, "utf-8"));
173723
- const packageName = packageJson.name?.split("/").pop()?.split(".").pop() || path44.basename(projectDir);
173752
+ const packageJson = JSON.parse(fs45.readFileSync(packageJsonPath, "utf-8"));
173753
+ const projectConfig2 = loadProjectConfig(projectDir);
173754
+ const packageName = packageJson.name?.split("/").pop()?.split(".").pop() || path45.basename(projectDir);
173724
173755
  const version2 = packageJson.version || "1.0.0";
173725
173756
  const author = getPackageAuthor(packageJson.name || "") || "tscircuit";
173726
173757
  const description = packageJson.description || "";
173727
- const libraryName = path44.basename(projectDir);
173728
- const kicadLibOutputDir = path44.join(distDir, "kicad-library");
173729
- if (!fs44.existsSync(kicadLibOutputDir)) {
173758
+ const libraryName = resolveKicadLibraryName({ projectDir });
173759
+ const kicadLibOutputDir = path45.join(distDir, "kicad-library");
173760
+ if (!fs45.existsSync(kicadLibOutputDir)) {
173730
173761
  console.log("Converting to KiCad library...");
173731
173762
  await convertToKicadLibrary({
173732
173763
  filePath: entryFile,
@@ -173734,7 +173765,7 @@ async function buildKicadPcm({
173734
173765
  outputDir: kicadLibOutputDir
173735
173766
  });
173736
173767
  }
173737
- const pcmOutputDir = path44.join(distDir, "pcm");
173768
+ const pcmOutputDir = path45.join(distDir, "pcm");
173738
173769
  const envDeploymentUrl = process.env.TSCIRCUIT_DEPLOYMENT_URL?.replace(/\/+$/, "");
173739
173770
  const baseUrl = envDeploymentUrl ?? `https://${author}--${packageName}.tscircuit.app`;
173740
173771
  console.log("Generating PCM assets...");
@@ -173745,15 +173776,16 @@ async function buildKicadPcm({
173745
173776
  description,
173746
173777
  kicadLibraryPath: kicadLibOutputDir,
173747
173778
  outputDir: pcmOutputDir,
173748
- baseUrl
173779
+ baseUrl,
173780
+ displayName: projectConfig2?.kicadLibraryName || undefined
173749
173781
  });
173750
- console.log(` KiCad PCM assets generated at ${kleur_default.dim(path44.relative(process.cwd(), pcmOutputDir))}`);
173782
+ console.log(` KiCad PCM assets generated at ${kleur_default.dim(path45.relative(process.cwd(), pcmOutputDir))}`);
173751
173783
  console.log(` Repository URL: ${kleur_default.cyan(`${baseUrl}/pcm/repository.json`)}`);
173752
173784
  }
173753
173785
 
173754
173786
  // cli/build/transpile/index.ts
173755
- import path46 from "node:path";
173756
- import fs46 from "node:fs";
173787
+ import path47 from "node:path";
173788
+ import fs47 from "node:fs";
173757
173789
  import { rollup } from "rollup";
173758
173790
  import typescript from "@rollup/plugin-typescript";
173759
173791
  import resolve11 from "@rollup/plugin-node-resolve";
@@ -173762,11 +173794,11 @@ import json from "@rollup/plugin-json";
173762
173794
  import dts from "rollup-plugin-dts";
173763
173795
 
173764
173796
  // cli/build/transpile/static-asset-plugin.ts
173765
- import fs45 from "node:fs";
173766
- import path45 from "node:path";
173797
+ import fs46 from "node:fs";
173798
+ import path46 from "node:path";
173767
173799
  import { createHash } from "node:crypto";
173768
173800
  function normalizePathSeparators(filePath) {
173769
- return filePath.split(path45.sep).join("/");
173801
+ return filePath.split(path46.sep).join("/");
173770
173802
  }
173771
173803
  var STATIC_ASSET_EXTENSIONS = new Set([
173772
173804
  ".glb",
@@ -173797,24 +173829,24 @@ var createStaticAssetPlugin = ({
173797
173829
  return {
173798
173830
  name: "tsci-static-assets",
173799
173831
  resolveId(source, importer) {
173800
- const ext = path45.extname(source).toLowerCase();
173832
+ const ext = path46.extname(source).toLowerCase();
173801
173833
  if (!STATIC_ASSET_EXTENSIONS.has(ext))
173802
173834
  return null;
173803
- if (path45.isAbsolute(source)) {
173804
- return fs45.existsSync(source) ? { id: normalizePathSeparators(source), external: true } : null;
173835
+ if (path46.isAbsolute(source)) {
173836
+ return fs46.existsSync(source) ? { id: normalizePathSeparators(source), external: true } : null;
173805
173837
  }
173806
173838
  if (importer) {
173807
- const importerNative = importer.split("/").join(path45.sep);
173808
- const resolvedFromImporter = path45.resolve(path45.dirname(importerNative), source);
173809
- if (fs45.existsSync(resolvedFromImporter)) {
173839
+ const importerNative = importer.split("/").join(path46.sep);
173840
+ const resolvedFromImporter = path46.resolve(path46.dirname(importerNative), source);
173841
+ if (fs46.existsSync(resolvedFromImporter)) {
173810
173842
  return {
173811
173843
  id: normalizePathSeparators(resolvedFromImporter),
173812
173844
  external: true
173813
173845
  };
173814
173846
  }
173815
173847
  }
173816
- const resolvedFromProject = path45.resolve(resolvedBaseUrl, source);
173817
- if (fs45.existsSync(resolvedFromProject)) {
173848
+ const resolvedFromProject = path46.resolve(resolvedBaseUrl, source);
173849
+ if (fs46.existsSync(resolvedFromProject)) {
173818
173850
  return {
173819
173851
  id: normalizePathSeparators(resolvedFromProject),
173820
173852
  external: true
@@ -173827,8 +173859,8 @@ var createStaticAssetPlugin = ({
173827
173859
  const wildcard = isWildcard ? source.slice(patternPrefix.length) : "";
173828
173860
  for (const target of targets) {
173829
173861
  const targetPath = isWildcard ? target.replace("*", wildcard) : target;
173830
- const resolvedTarget = path45.resolve(resolvedBaseUrl, targetPath);
173831
- if (fs45.existsSync(resolvedTarget)) {
173862
+ const resolvedTarget = path46.resolve(resolvedBaseUrl, targetPath);
173863
+ if (fs46.existsSync(resolvedTarget)) {
173832
173864
  return {
173833
173865
  id: normalizePathSeparators(resolvedTarget),
173834
173866
  external: true
@@ -173854,18 +173886,18 @@ var createStaticAssetPlugin = ({
173854
173886
  if (chunk.type !== "chunk")
173855
173887
  continue;
173856
173888
  for (const importedId of chunk.imports) {
173857
- const ext = path45.extname(importedId).toLowerCase();
173889
+ const ext = path46.extname(importedId).toLowerCase();
173858
173890
  if (!STATIC_ASSET_EXTENSIONS.has(ext))
173859
173891
  continue;
173860
173892
  if (!copiedAssets.has(importedId)) {
173861
- const assetDir = path45.join(outputDir, "assets");
173862
- fs45.mkdirSync(assetDir, { recursive: true });
173863
- const nativePath = importedId.split("/").join(path45.sep);
173864
- const fileBuffer = fs45.readFileSync(nativePath);
173893
+ const assetDir = path46.join(outputDir, "assets");
173894
+ fs46.mkdirSync(assetDir, { recursive: true });
173895
+ const nativePath = importedId.split("/").join(path46.sep);
173896
+ const fileBuffer = fs46.readFileSync(nativePath);
173865
173897
  const hash = createHash("sha1").update(fileBuffer).digest("hex").slice(0, 8);
173866
- const fileName = `${path45.basename(importedId, ext)}-${hash}${ext}`;
173867
- const outputFilePath = path45.join(assetDir, fileName);
173868
- fs45.writeFileSync(outputFilePath, fileBuffer);
173898
+ const fileName = `${path46.basename(importedId, ext)}-${hash}${ext}`;
173899
+ const outputFilePath = path46.join(assetDir, fileName);
173900
+ fs46.writeFileSync(outputFilePath, fileBuffer);
173869
173901
  copiedAssets.set(importedId, `./assets/${fileName}`);
173870
173902
  assetIdToOutputPath.set(importedId, `./assets/${fileName}`);
173871
173903
  }
@@ -173887,17 +173919,17 @@ function escapeRegExp(string) {
173887
173919
 
173888
173920
  // cli/build/transpile/index.ts
173889
173921
  var createExternalFunction = (projectDir, tsconfigPath) => (id) => {
173890
- if (id.startsWith(".") || id.startsWith("/") || path46.isAbsolute(id)) {
173922
+ if (id.startsWith(".") || id.startsWith("/") || path47.isAbsolute(id)) {
173891
173923
  return false;
173892
173924
  }
173893
173925
  let baseUrl = projectDir;
173894
173926
  let pathMappings = {};
173895
- if (tsconfigPath && fs46.existsSync(tsconfigPath)) {
173927
+ if (tsconfigPath && fs47.existsSync(tsconfigPath)) {
173896
173928
  try {
173897
- const tsconfigContent = fs46.readFileSync(tsconfigPath, "utf-8");
173929
+ const tsconfigContent = fs47.readFileSync(tsconfigPath, "utf-8");
173898
173930
  const tsconfig = JSON.parse(tsconfigContent);
173899
173931
  if (tsconfig.compilerOptions?.baseUrl) {
173900
- baseUrl = path46.resolve(path46.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
173932
+ baseUrl = path47.resolve(path47.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
173901
173933
  }
173902
173934
  if (tsconfig.compilerOptions?.paths) {
173903
173935
  pathMappings = tsconfig.compilerOptions.paths;
@@ -173911,17 +173943,17 @@ var createExternalFunction = (projectDir, tsconfigPath) => (id) => {
173911
173943
  }
173912
173944
  }
173913
173945
  const potentialPaths = [
173914
- path46.join(baseUrl, id),
173915
- path46.join(baseUrl, `${id}.ts`),
173916
- path46.join(baseUrl, `${id}.tsx`),
173917
- path46.join(baseUrl, `${id}.js`),
173918
- path46.join(baseUrl, `${id}.jsx`),
173919
- path46.join(baseUrl, id, "index.ts"),
173920
- path46.join(baseUrl, id, "index.tsx"),
173921
- path46.join(baseUrl, id, "index.js"),
173922
- path46.join(baseUrl, id, "index.jsx")
173946
+ path47.join(baseUrl, id),
173947
+ path47.join(baseUrl, `${id}.ts`),
173948
+ path47.join(baseUrl, `${id}.tsx`),
173949
+ path47.join(baseUrl, `${id}.js`),
173950
+ path47.join(baseUrl, `${id}.jsx`),
173951
+ path47.join(baseUrl, id, "index.ts"),
173952
+ path47.join(baseUrl, id, "index.tsx"),
173953
+ path47.join(baseUrl, id, "index.js"),
173954
+ path47.join(baseUrl, id, "index.jsx")
173923
173955
  ];
173924
- if (potentialPaths.some((p4) => fs46.existsSync(p4))) {
173956
+ if (potentialPaths.some((p4) => fs47.existsSync(p4))) {
173925
173957
  return false;
173926
173958
  }
173927
173959
  return true;
@@ -173932,17 +173964,17 @@ var transpileFile = async ({
173932
173964
  projectDir
173933
173965
  }) => {
173934
173966
  try {
173935
- fs46.mkdirSync(outputDir, { recursive: true });
173936
- const tsconfigPath = path46.join(projectDir, "tsconfig.json");
173937
- const hasTsConfig = fs46.existsSync(tsconfigPath);
173967
+ fs47.mkdirSync(outputDir, { recursive: true });
173968
+ const tsconfigPath = path47.join(projectDir, "tsconfig.json");
173969
+ const hasTsConfig = fs47.existsSync(tsconfigPath);
173938
173970
  let tsconfigBaseUrl = projectDir;
173939
173971
  let tsconfigPathMappings;
173940
173972
  if (hasTsConfig) {
173941
173973
  try {
173942
- const tsconfigContent = fs46.readFileSync(tsconfigPath, "utf-8");
173974
+ const tsconfigContent = fs47.readFileSync(tsconfigPath, "utf-8");
173943
173975
  const tsconfig = JSON.parse(tsconfigContent);
173944
173976
  if (tsconfig.compilerOptions?.baseUrl) {
173945
- tsconfigBaseUrl = path46.resolve(path46.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
173977
+ tsconfigBaseUrl = path47.resolve(path47.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
173946
173978
  }
173947
173979
  if (tsconfig.compilerOptions?.paths) {
173948
173980
  tsconfigPathMappings = tsconfig.compilerOptions.paths;
@@ -173997,27 +174029,27 @@ var transpileFile = async ({
173997
174029
  external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
173998
174030
  plugins: getPlugins()
173999
174031
  });
174000
- const esmOutputPath = path46.join(outputDir, "index.js");
174032
+ const esmOutputPath = path47.join(outputDir, "index.js");
174001
174033
  await esmBundle.write({
174002
174034
  file: esmOutputPath,
174003
174035
  format: "es",
174004
174036
  sourcemap: false
174005
174037
  });
174006
- console.log(`ESM bundle written to ${path46.relative(projectDir, esmOutputPath)}`);
174038
+ console.log(`ESM bundle written to ${path47.relative(projectDir, esmOutputPath)}`);
174007
174039
  console.log("Building CommonJS bundle...");
174008
174040
  const cjsBundle = await rollup({
174009
174041
  input,
174010
174042
  external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
174011
174043
  plugins: getPlugins()
174012
174044
  });
174013
- const cjsOutputPath = path46.join(outputDir, "index.cjs");
174045
+ const cjsOutputPath = path47.join(outputDir, "index.cjs");
174014
174046
  console.log("Writing CJS bundle to:", cjsOutputPath);
174015
174047
  await cjsBundle.write({
174016
174048
  file: cjsOutputPath,
174017
174049
  format: "cjs",
174018
174050
  sourcemap: false
174019
174051
  });
174020
- console.log(`CommonJS bundle written to ${path46.relative(projectDir, cjsOutputPath)}`);
174052
+ console.log(`CommonJS bundle written to ${path47.relative(projectDir, cjsOutputPath)}`);
174021
174053
  console.log("Generating type declarations...");
174022
174054
  const dtsBundle = await rollup({
174023
174055
  input,
@@ -174042,9 +174074,9 @@ var transpileFile = async ({
174042
174074
  dtsContent = dtsContent.replace(/import \* as [\w_]+ from ['"]react\/jsx-runtime['"];?\s*\n?/g, "");
174043
174075
  dtsContent = dtsContent.replace(/[\w_]+\.JSX\.Element/g, "any");
174044
174076
  dtsContent = dtsContent.replace(/export\s*{\s*};\s*$/gm, "").trim();
174045
- const dtsOutputPath = path46.join(outputDir, "index.d.ts");
174046
- fs46.writeFileSync(dtsOutputPath, dtsContent);
174047
- console.log(`Type declarations written to ${path46.relative(projectDir, dtsOutputPath)}`);
174077
+ const dtsOutputPath = path47.join(outputDir, "index.d.ts");
174078
+ fs47.writeFileSync(dtsOutputPath, dtsContent);
174079
+ console.log(`Type declarations written to ${path47.relative(projectDir, dtsOutputPath)}`);
174048
174080
  console.log(kleur_default.green("Transpilation complete!"));
174049
174081
  return true;
174050
174082
  } catch (err) {
@@ -174057,17 +174089,17 @@ var transpileFile = async ({
174057
174089
  };
174058
174090
 
174059
174091
  // cli/utils/validate-main-in-dist.ts
174060
- import fs47 from "node:fs";
174061
- import path47 from "node:path";
174092
+ import fs48 from "node:fs";
174093
+ import path48 from "node:path";
174062
174094
  var validateMainInDist = (projectDir, distDir) => {
174063
- const packageJsonPath = path47.join(projectDir, "package.json");
174064
- if (!fs47.existsSync(packageJsonPath))
174095
+ const packageJsonPath = path48.join(projectDir, "package.json");
174096
+ if (!fs48.existsSync(packageJsonPath))
174065
174097
  return;
174066
- const packageJson = JSON.parse(fs47.readFileSync(packageJsonPath, "utf-8"));
174098
+ const packageJson = JSON.parse(fs48.readFileSync(packageJsonPath, "utf-8"));
174067
174099
  if (typeof packageJson.main !== "string")
174068
174100
  return;
174069
- const resolvedMainPath = path47.resolve(projectDir, packageJson.main);
174070
- const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${path47.sep}`);
174101
+ const resolvedMainPath = path48.resolve(projectDir, packageJson.main);
174102
+ const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${path48.sep}`);
174071
174103
  if (!isMainInDist) {
174072
174104
  console.warn('When using transpilation, your package\'s "main" field should point inside the `dist/*` directory, usually to "dist/index.js"');
174073
174105
  }
@@ -174089,19 +174121,19 @@ async function getLatestTscircuitCdnUrl() {
174089
174121
  }
174090
174122
 
174091
174123
  // cli/build/worker-pool.ts
174092
- import path48 from "node:path";
174093
- import fs48 from "node:fs";
174124
+ import path49 from "node:path";
174125
+ import fs49 from "node:fs";
174094
174126
  import { Worker } from "node:worker_threads";
174095
174127
  var getWorkerEntrypointPath = () => {
174096
- const tsPath = path48.join(import.meta.dir, "build-worker-entrypoint.ts");
174097
- if (fs48.existsSync(tsPath)) {
174128
+ const tsPath = path49.join(import.meta.dir, "build-worker-entrypoint.ts");
174129
+ if (fs49.existsSync(tsPath)) {
174098
174130
  return tsPath;
174099
174131
  }
174100
- const jsBundledPath = path48.join(import.meta.dir, "build", "build-worker-entrypoint.js");
174101
- if (fs48.existsSync(jsBundledPath)) {
174132
+ const jsBundledPath = path49.join(import.meta.dir, "build", "build-worker-entrypoint.js");
174133
+ if (fs49.existsSync(jsBundledPath)) {
174102
174134
  return jsBundledPath;
174103
174135
  }
174104
- return path48.join(import.meta.dir, "build-worker-entrypoint.js");
174136
+ return path49.join(import.meta.dir, "build-worker-entrypoint.js");
174105
174137
  };
174106
174138
 
174107
174139
  class WorkerPool {
@@ -174257,7 +174289,7 @@ async function buildFilesWithWorkerPool(options) {
174257
174289
  }
174258
174290
 
174259
174291
  // cli/build/register.ts
174260
- var normalizeRelativePath = (projectDir, targetPath) => path49.relative(projectDir, targetPath).split(path49.sep).join("/");
174292
+ var normalizeRelativePath = (projectDir, targetPath) => path50.relative(projectDir, targetPath).split(path50.sep).join("/");
174261
174293
  var registerBuild = (program3) => {
174262
174294
  program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ci", "Run install and optional prebuild/build commands (or default CI build)").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("--transpile", "Transpile the entry file to JavaScript").option("--preview-images", "Generate preview images in the dist directory").option("--all-images", "Generate preview images for every successful build output").option("--kicad", "Generate KiCad project directories for each successful build output").option("--preview-gltf", "Generate a GLTF file from the preview entrypoint").option("--kicad-pcm", "Generate KiCad PCM (Plugin and Content Manager) assets in dist/pcm").option("--use-cdn-javascript", "Use CDN-hosted JavaScript instead of bundled standalone file for --site").option("--concurrency <number>", "Number of files to build in parallel (default: 1)", "1").action(async (file, options) => {
174263
174295
  try {
@@ -174290,8 +174322,8 @@ var registerBuild = (program3) => {
174290
174322
  }
174291
174323
  return config;
174292
174324
  })();
174293
- const distDir = path49.join(projectDir, "dist");
174294
- fs49.mkdirSync(distDir, { recursive: true });
174325
+ const distDir = path50.join(projectDir, "dist");
174326
+ fs50.mkdirSync(distDir, { recursive: true });
174295
174327
  const concurrencyValue = Math.max(1, Number.parseInt(resolvedOptions?.concurrency || "1", 10));
174296
174328
  if (concurrencyValue > 1) {
174297
174329
  console.log(`Building ${circuitFiles.length} file(s) with concurrency ${concurrencyValue}...`);
@@ -174309,7 +174341,7 @@ var registerBuild = (program3) => {
174309
174341
  platformConfig: platformConfig2
174310
174342
  };
174311
174343
  const processBuildResult = async (filePath, outputPath, buildOutcome) => {
174312
- const relative10 = path49.relative(projectDir, filePath);
174344
+ const relative10 = path50.relative(projectDir, filePath);
174313
174345
  const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
174314
174346
  builtFiles.push({
174315
174347
  sourcePath: filePath,
@@ -174319,9 +174351,9 @@ var registerBuild = (program3) => {
174319
174351
  if (!buildOutcome.ok) {
174320
174352
  hasErrors = true;
174321
174353
  } else if (resolvedOptions?.site) {
174322
- const normalizedSourcePath = relative10.split(path49.sep).join("/");
174323
- const relativeOutputPath = path49.join(outputDirName, "circuit.json");
174324
- const normalizedOutputPath = relativeOutputPath.split(path49.sep).join("/");
174354
+ const normalizedSourcePath = relative10.split(path50.sep).join("/");
174355
+ const relativeOutputPath = path50.join(outputDirName, "circuit.json");
174356
+ const normalizedOutputPath = relativeOutputPath.split(path50.sep).join("/");
174325
174357
  staticFileReferences.push({
174326
174358
  filePath: normalizedSourcePath,
174327
174359
  fileStaticAssetUrl: `./${normalizedOutputPath}`
@@ -174329,12 +174361,12 @@ var registerBuild = (program3) => {
174329
174361
  }
174330
174362
  if (buildOutcome.ok && shouldGenerateKicad) {
174331
174363
  let circuitJson = buildOutcome.circuitJson;
174332
- if (!circuitJson && fs49.existsSync(outputPath)) {
174333
- circuitJson = JSON.parse(fs49.readFileSync(outputPath, "utf-8"));
174364
+ if (!circuitJson && fs50.existsSync(outputPath)) {
174365
+ circuitJson = JSON.parse(fs50.readFileSync(outputPath, "utf-8"));
174334
174366
  }
174335
174367
  if (circuitJson) {
174336
- const projectOutputDir = path49.join(distDir, outputDirName, "kicad");
174337
- const projectName = path49.basename(outputDirName);
174368
+ const projectOutputDir = path50.join(distDir, outputDirName, "kicad");
174369
+ const projectName = path50.basename(outputDirName);
174338
174370
  const project = await generateKicadProject({
174339
174371
  circuitJson,
174340
174372
  outputDir: projectOutputDir,
@@ -174350,19 +174382,19 @@ var registerBuild = (program3) => {
174350
174382
  };
174351
174383
  const buildSequentially = async () => {
174352
174384
  for (const filePath of circuitFiles) {
174353
- const relative10 = path49.relative(projectDir, filePath);
174385
+ const relative10 = path50.relative(projectDir, filePath);
174354
174386
  console.log(`Building ${relative10}...`);
174355
174387
  const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
174356
- const outputPath = path49.join(distDir, outputDirName, "circuit.json");
174388
+ const outputPath = path50.join(distDir, outputDirName, "circuit.json");
174357
174389
  const buildOutcome = await buildFile(filePath, outputPath, projectDir, buildOptions);
174358
174390
  await processBuildResult(filePath, outputPath, buildOutcome);
174359
174391
  }
174360
174392
  };
174361
174393
  const buildWithWorkers = async () => {
174362
174394
  const filesToBuild = circuitFiles.map((filePath) => {
174363
- const relative10 = path49.relative(projectDir, filePath);
174395
+ const relative10 = path50.relative(projectDir, filePath);
174364
174396
  const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
174365
- const outputPath = path49.join(distDir, outputDirName, "circuit.json");
174397
+ const outputPath = path50.join(distDir, outputDirName, "circuit.json");
174366
174398
  return { filePath, outputPath };
174367
174399
  });
174368
174400
  await buildFilesWithWorkerPool({
@@ -174376,7 +174408,7 @@ var registerBuild = (program3) => {
174376
174408
  }
174377
174409
  },
174378
174410
  onJobComplete: async (result) => {
174379
- const relative10 = path49.relative(projectDir, result.filePath);
174411
+ const relative10 = path50.relative(projectDir, result.filePath);
174380
174412
  if (result.ok) {
174381
174413
  console.log(kleur_default.green(`✓ ${relative10}`));
174382
174414
  } else {
@@ -174446,14 +174478,14 @@ var registerBuild = (program3) => {
174446
174478
  if (resolvedOptions?.useCdnJavascript) {
174447
174479
  standaloneScriptSrc = await getLatestTscircuitCdnUrl();
174448
174480
  } else {
174449
- fs49.writeFileSync(path49.join(distDir, "standalone.min.js"), standalone_min_default);
174481
+ fs50.writeFileSync(path50.join(distDir, "standalone.min.js"), standalone_min_default);
174450
174482
  }
174451
174483
  const indexHtml = getStaticIndexHtmlFile({
174452
174484
  files: staticFileReferences,
174453
174485
  standaloneScriptSrc,
174454
174486
  defaultMainComponentPath: siteDefaultComponentPath ? normalizeRelativePath(projectDir, siteDefaultComponentPath) : undefined
174455
174487
  });
174456
- fs49.writeFileSync(path49.join(distDir, "index.html"), indexHtml);
174488
+ fs50.writeFileSync(path50.join(distDir, "index.html"), indexHtml);
174457
174489
  }
174458
174490
  if (resolvedOptions?.kicadFootprintLibrary) {
174459
174491
  console.log("Generating KiCad footprint library...");
@@ -174472,15 +174504,15 @@ var registerBuild = (program3) => {
174472
174504
  process.exit(1);
174473
174505
  }
174474
174506
  } else {
174475
- const libraryName = path49.basename(projectDir);
174476
- const kicadLibOutputDir = path49.join(distDir, "kicad-library");
174507
+ const libraryName = resolveKicadLibraryName({ projectDir });
174508
+ const kicadLibOutputDir = path50.join(distDir, "kicad-library");
174477
174509
  try {
174478
174510
  await convertToKicadLibrary({
174479
174511
  filePath: entryFile,
174480
174512
  libraryName,
174481
174513
  outputDir: kicadLibOutputDir
174482
174514
  });
174483
- console.log(` KiCad library generated at ${kleur_default.dim(path49.relative(process.cwd(), kicadLibOutputDir))}`);
174515
+ console.log(` KiCad library generated at ${kleur_default.dim(path50.relative(process.cwd(), kicadLibOutputDir))}`);
174484
174516
  } catch (err) {
174485
174517
  console.error(`Error generating KiCad library: ${err instanceof Error ? err.message : err}`);
174486
174518
  if (!resolvedOptions?.ignoreErrors) {
@@ -174538,7 +174570,7 @@ var registerBuild = (program3) => {
174538
174570
  if (enabledOpts.length > 0) {
174539
174571
  console.log(` Options ${kleur_default.cyan(enabledOpts.join(", "))}`);
174540
174572
  }
174541
- console.log(` Output ${kleur_default.dim(path49.relative(process.cwd(), distDir) || "dist")}`);
174573
+ console.log(` Output ${kleur_default.dim(path50.relative(process.cwd(), distDir) || "dist")}`);
174542
174574
  console.log(hasErrors ? kleur_default.yellow(`
174543
174575
  ⚠ Build completed with errors`) : kleur_default.green(`
174544
174576
  ✓ Done`));
@@ -174552,8 +174584,8 @@ var registerBuild = (program3) => {
174552
174584
  };
174553
174585
 
174554
174586
  // lib/shared/snapshot-project.ts
174555
- import fs51 from "node:fs";
174556
- import path50 from "node:path";
174587
+ import fs52 from "node:fs";
174588
+ import path51 from "node:path";
174557
174589
  import looksSame2 from "looks-same";
174558
174590
  import {
174559
174591
  convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
@@ -174564,7 +174596,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
174564
174596
 
174565
174597
  // lib/shared/compare-images.ts
174566
174598
  import looksSame from "looks-same";
174567
- import fs50 from "node:fs/promises";
174599
+ import fs51 from "node:fs/promises";
174568
174600
  var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
174569
174601
  const { equal: equal2 } = await looksSame(buffer1, buffer2, {
174570
174602
  strict: false,
@@ -174580,7 +174612,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
174580
174612
  tolerance: 2
174581
174613
  });
174582
174614
  } else {
174583
- await fs50.writeFile(diffPath, buffer2);
174615
+ await fs51.writeFile(diffPath, buffer2);
174584
174616
  }
174585
174617
  }
174586
174618
  return { equal: equal2 };
@@ -174605,7 +174637,7 @@ var snapshotProject = async ({
174605
174637
  ...DEFAULT_IGNORED_PATTERNS,
174606
174638
  ...ignored.map(normalizeIgnorePattern)
174607
174639
  ];
174608
- const resolvedPaths = filePaths.map((f2) => path50.resolve(projectDir, f2));
174640
+ const resolvedPaths = filePaths.map((f2) => path51.resolve(projectDir, f2));
174609
174641
  const boardFiles = findBoardFiles({
174610
174642
  projectDir,
174611
174643
  ignore,
@@ -174619,7 +174651,7 @@ var snapshotProject = async ({
174619
174651
  const mismatches = [];
174620
174652
  let didUpdate = false;
174621
174653
  for (const file of boardFiles) {
174622
- const relativeFilePath = path50.relative(projectDir, file);
174654
+ const relativeFilePath = path51.relative(projectDir, file);
174623
174655
  let circuitJson;
174624
174656
  let pcbSvg;
174625
174657
  let schSvg;
@@ -174674,17 +174706,17 @@ var snapshotProject = async ({
174674
174706
  } catch (error) {
174675
174707
  const errorMessage = error instanceof Error ? error.message : String(error);
174676
174708
  if (errorMessage.includes("No pcb_board found in circuit JSON")) {
174677
- const fileDir = path50.dirname(file);
174678
- const relativeDir = path50.relative(projectDir, fileDir);
174679
- const snapDir2 = snapshotsDirName ? path50.join(projectDir, snapshotsDirName, relativeDir) : path50.join(fileDir, "__snapshots__");
174680
- const base2 = path50.basename(file).replace(/\.tsx$/, "");
174681
- const snap3dPath = path50.join(snapDir2, `${base2}-3d.snap.png`);
174682
- const existing3dSnapshot = fs51.existsSync(snap3dPath);
174709
+ const fileDir = path51.dirname(file);
174710
+ const relativeDir = path51.relative(projectDir, fileDir);
174711
+ const snapDir2 = snapshotsDirName ? path51.join(projectDir, snapshotsDirName, relativeDir) : path51.join(fileDir, "__snapshots__");
174712
+ const base2 = path51.basename(file).replace(/\.tsx$/, "");
174713
+ const snap3dPath = path51.join(snapDir2, `${base2}-3d.snap.png`);
174714
+ const existing3dSnapshot = fs52.existsSync(snap3dPath);
174683
174715
  if (existing3dSnapshot) {
174684
174716
  onError(kleur_default.red(`
174685
174717
  ❌ Failed to generate 3D snapshot for ${relativeFilePath}:
174686
174718
  `) + kleur_default.red(` No pcb_board found in circuit JSON
174687
- `) + kleur_default.red(` Existing snapshot: ${path50.relative(projectDir, snap3dPath)}
174719
+ `) + kleur_default.red(` Existing snapshot: ${path51.relative(projectDir, snap3dPath)}
174688
174720
  `));
174689
174721
  return onExit2(1);
174690
174722
  } else {
@@ -174700,9 +174732,9 @@ var snapshotProject = async ({
174700
174732
  }
174701
174733
  }
174702
174734
  }
174703
- const snapDir = snapshotsDirName ? path50.join(projectDir, snapshotsDirName, path50.relative(projectDir, path50.dirname(file))) : path50.join(path50.dirname(file), "__snapshots__");
174704
- fs51.mkdirSync(snapDir, { recursive: true });
174705
- const base = path50.basename(file).replace(/\.tsx$/, "");
174735
+ const snapDir = snapshotsDirName ? path51.join(projectDir, snapshotsDirName, path51.relative(projectDir, path51.dirname(file))) : path51.join(path51.dirname(file), "__snapshots__");
174736
+ fs52.mkdirSync(snapDir, { recursive: true });
174737
+ const base = path51.basename(file).replace(/\.tsx$/, "");
174706
174738
  const snapshots = [];
174707
174739
  if (pcbOnly || !schematicOnly) {
174708
174740
  snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
@@ -174720,31 +174752,31 @@ var snapshotProject = async ({
174720
174752
  for (const snapshot of snapshots) {
174721
174753
  const { type } = snapshot;
174722
174754
  const is3d = type === "3d";
174723
- const snapPath = path50.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
174724
- const existing = fs51.existsSync(snapPath);
174755
+ const snapPath = path51.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
174756
+ const existing = fs52.existsSync(snapPath);
174725
174757
  const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
174726
174758
  const newContentForFile = snapshot.content;
174727
174759
  if (!existing) {
174728
- fs51.writeFileSync(snapPath, newContentForFile);
174729
- console.log("✅", kleur_default.gray(path50.relative(projectDir, snapPath)));
174760
+ fs52.writeFileSync(snapPath, newContentForFile);
174761
+ console.log("✅", kleur_default.gray(path51.relative(projectDir, snapPath)));
174730
174762
  didUpdate = true;
174731
174763
  continue;
174732
174764
  }
174733
- const oldContentBuffer = fs51.readFileSync(snapPath);
174765
+ const oldContentBuffer = fs52.readFileSync(snapPath);
174734
174766
  const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
174735
174767
  const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
174736
174768
  if (update) {
174737
174769
  if (!forceUpdate && equal2) {
174738
- console.log("✅", kleur_default.gray(path50.relative(projectDir, snapPath)));
174770
+ console.log("✅", kleur_default.gray(path51.relative(projectDir, snapPath)));
174739
174771
  } else {
174740
- fs51.writeFileSync(snapPath, newContentForFile);
174741
- console.log("✅", kleur_default.gray(path50.relative(projectDir, snapPath)));
174772
+ fs52.writeFileSync(snapPath, newContentForFile);
174773
+ console.log("✅", kleur_default.gray(path51.relative(projectDir, snapPath)));
174742
174774
  didUpdate = true;
174743
174775
  }
174744
174776
  } else if (!equal2) {
174745
174777
  mismatches.push(`${snapPath} (diff: ${diffPath})`);
174746
174778
  } else {
174747
- console.log("✅", kleur_default.gray(path50.relative(projectDir, snapPath)));
174779
+ console.log("✅", kleur_default.gray(path51.relative(projectDir, snapPath)));
174748
174780
  }
174749
174781
  }
174750
174782
  }
@@ -174783,22 +174815,22 @@ var registerSnapshot = (program3) => {
174783
174815
  };
174784
174816
 
174785
174817
  // lib/shared/setup-github-actions.ts
174786
- import fs52 from "node:fs";
174787
- import path51 from "node:path";
174818
+ import fs53 from "node:fs";
174819
+ import path52 from "node:path";
174788
174820
  var setupGithubActions = (projectDir = process.cwd()) => {
174789
174821
  const findGitRoot = (startDir) => {
174790
- let dir = path51.resolve(startDir);
174791
- while (dir !== path51.parse(dir).root) {
174792
- if (fs52.existsSync(path51.join(dir, ".git"))) {
174822
+ let dir = path52.resolve(startDir);
174823
+ while (dir !== path52.parse(dir).root) {
174824
+ if (fs53.existsSync(path52.join(dir, ".git"))) {
174793
174825
  return dir;
174794
174826
  }
174795
- dir = path51.dirname(dir);
174827
+ dir = path52.dirname(dir);
174796
174828
  }
174797
174829
  return null;
174798
174830
  };
174799
174831
  const gitRoot = findGitRoot(projectDir) ?? projectDir;
174800
- const workflowsDir = path51.join(gitRoot, ".github", "workflows");
174801
- fs52.mkdirSync(workflowsDir, { recursive: true });
174832
+ const workflowsDir = path52.join(gitRoot, ".github", "workflows");
174833
+ fs53.mkdirSync(workflowsDir, { recursive: true });
174802
174834
  const buildWorkflow = `name: tscircuit Build
174803
174835
 
174804
174836
  on:
@@ -174837,8 +174869,8 @@ jobs:
174837
174869
  - run: bun install
174838
174870
  - run: bunx tsci snapshot
174839
174871
  `;
174840
- writeFileIfNotExists(path51.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
174841
- writeFileIfNotExists(path51.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
174872
+ writeFileIfNotExists(path52.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
174873
+ writeFileIfNotExists(path52.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
174842
174874
  };
174843
174875
 
174844
174876
  // cli/setup/register.ts
@@ -174876,8 +174908,8 @@ function registerAuthSetupNpmrc(program3) {
174876
174908
  }
174877
174909
 
174878
174910
  // cli/convert/register.ts
174879
- import fs53 from "node:fs/promises";
174880
- import path52 from "node:path";
174911
+ import fs54 from "node:fs/promises";
174912
+ import path53 from "node:path";
174881
174913
  import { parseKicadModToCircuitJson } from "kicad-component-converter";
174882
174914
 
174883
174915
  // node_modules/@tscircuit/mm/dist/index.js
@@ -174998,15 +175030,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
174998
175030
  var registerConvert = (program3) => {
174999
175031
  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) => {
175000
175032
  try {
175001
- const inputPath = path52.resolve(file);
175002
- const modContent = await fs53.readFile(inputPath, "utf-8");
175033
+ const inputPath = path53.resolve(file);
175034
+ const modContent = await fs54.readFile(inputPath, "utf-8");
175003
175035
  const circuitJson = await parseKicadModToCircuitJson(modContent);
175004
- const componentName = options.name ?? path52.basename(inputPath, ".kicad_mod");
175036
+ const componentName = options.name ?? path53.basename(inputPath, ".kicad_mod");
175005
175037
  const tsx = convertCircuitJsonToTscircuit(circuitJson, {
175006
175038
  componentName
175007
175039
  });
175008
- const outputPath = options.output ? path52.resolve(options.output) : path52.join(path52.dirname(inputPath), `${componentName}.tsx`);
175009
- await fs53.writeFile(outputPath, tsx);
175040
+ const outputPath = options.output ? path53.resolve(options.output) : path53.join(path53.dirname(inputPath), `${componentName}.tsx`);
175041
+ await fs54.writeFile(outputPath, tsx);
175010
175042
  console.log(kleur_default.green(`Converted ${outputPath}`));
175011
175043
  } catch (error) {
175012
175044
  console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
@@ -175122,7 +175154,7 @@ var registerInstall = (program3) => {
175122
175154
  };
175123
175155
 
175124
175156
  // cli/transpile/register.ts
175125
- import path53 from "node:path";
175157
+ import path54 from "node:path";
175126
175158
  var registerTranspile = (program3) => {
175127
175159
  program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
175128
175160
  try {
@@ -175130,7 +175162,7 @@ var registerTranspile = (program3) => {
175130
175162
  fileOrDir: file,
175131
175163
  includeBoardFiles: false
175132
175164
  });
175133
- const distDir = path53.join(projectDir, "dist");
175165
+ const distDir = path54.join(projectDir, "dist");
175134
175166
  validateMainInDist(projectDir, distDir);
175135
175167
  console.log("Transpiling entry file...");
175136
175168
  const entryFile = mainEntrypoint || circuitFiles[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.799",
3
+ "version": "0.1.801",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",
@@ -52,6 +52,10 @@
52
52
  "type": "string",
53
53
  "description": "Entry file for KiCad footprint library generation."
54
54
  },
55
+ "kicadLibraryName": {
56
+ "type": "string",
57
+ "description": "Name for the generated KiCad library. Falls back to package.json name, then directory name."
58
+ },
55
59
  "alwaysUseLatestTscircuitOnCloud": {
56
60
  "type": "boolean",
57
61
  "description": "Always use the latest TSCircuit version when building on the cloud."