@tscircuit/cli 0.1.1109 → 0.1.1111

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/README.md CHANGED
@@ -65,7 +65,7 @@ Commands:
65
65
  convert [options] <file> Convert a .kicad_mod footprint to a tscircuit
66
66
  component
67
67
  simulate Run a simulation
68
- version Print CLI version
68
+ version [options] Print CLI version
69
69
  help [command] display help for command
70
70
  ```
71
71
  <!-- END_HELP_OUTPUT -->
package/dist/cli/main.js CHANGED
@@ -97682,7 +97682,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
97682
97682
  // lib/getVersion.ts
97683
97683
  import { createRequire as createRequire2 } from "node:module";
97684
97684
  // package.json
97685
- var version = "0.1.1108";
97685
+ var version = "0.1.1109";
97686
97686
  var package_default = {
97687
97687
  name: "@tscircuit/cli",
97688
97688
  version,
@@ -220615,6 +220615,19 @@ var registerRegistryPackagesCreate = (program3) => {
220615
220615
  };
220616
220616
 
220617
220617
  // cli/registry/packages/update/register.ts
220618
+ import fs60 from "node:fs";
220619
+ import path63 from "node:path";
220620
+ var getCurrentDirectoryPackageName = () => {
220621
+ const packageJsonPath = path63.join(process.cwd(), "package.json");
220622
+ if (!fs60.existsSync(packageJsonPath))
220623
+ return;
220624
+ try {
220625
+ const packageJson = JSON.parse(fs60.readFileSync(packageJsonPath, "utf8"));
220626
+ return typeof packageJson.name === "string" ? packageJson.name : undefined;
220627
+ } catch {
220628
+ return;
220629
+ }
220630
+ };
220618
220631
  var getPublicDistEnabledFromOptions = ({
220619
220632
  enablePublicDist,
220620
220633
  disablePublicDist
@@ -220626,7 +220639,15 @@ var getPublicDistEnabledFromOptions = ({
220626
220639
  return;
220627
220640
  };
220628
220641
  var registerRegistryPackagesUpdate = (program3) => {
220629
- program3.commands.find((command) => command.name() === "registry").commands.find((command) => command.name() === "packages").command("update").description("Update a package in the tscircuit registry").requiredOption("--package-name <packageName>", "Package name to update").option("--enable-public-dist", "Enable public dist").option("--disable-public-dist", "Disable public dist").action(async (opts) => {
220642
+ program3.commands.find((command) => command.name() === "registry").commands.find((command) => command.name() === "packages").command("update").description("Update a package in the tscircuit registry").option("--package-name <packageName>", "Package name to update").option("--enable-public-dist", "Enable public dist").option("--disable-public-dist", "Disable public dist").action(async (opts) => {
220643
+ const packageName = opts.packageName ?? getCurrentDirectoryPackageName();
220644
+ if (!opts.packageName && packageName) {
220645
+ console.warn("No package specified, using package in current directory...");
220646
+ }
220647
+ if (!packageName) {
220648
+ console.error("No package specified and no package name found in current directory package.json");
220649
+ process.exit(1);
220650
+ }
220630
220651
  if (opts.enablePublicDist && opts.disablePublicDist) {
220631
220652
  console.error("Cannot use both --enable-public-dist and --disable-public-dist");
220632
220653
  process.exit(1);
@@ -220643,11 +220664,11 @@ var registerRegistryPackagesUpdate = (program3) => {
220643
220664
  const ky3 = getRegistryApiKy();
220644
220665
  await ky3.post("packages/update", {
220645
220666
  json: {
220646
- package_name: opts.packageName,
220667
+ package_name: packageName,
220647
220668
  public_dist_enabled: publicDistEnabled
220648
220669
  }
220649
220670
  });
220650
- console.log(kleur_default.green(`Updated package ${opts.packageName}`));
220671
+ console.log(kleur_default.green(`Updated package ${packageName}`));
220651
220672
  } catch (error) {
220652
220673
  console.error(error instanceof Error ? error.message : String(error));
220653
220674
  process.exit(1);
@@ -220737,14 +220758,14 @@ class KeyStore {
220737
220758
  }
220738
220759
  }
220739
220760
  function createKey(key) {
220740
- let path63 = null;
220761
+ let path64 = null;
220741
220762
  let id2 = null;
220742
220763
  let src = null;
220743
220764
  let weight = 1;
220744
220765
  let getFn = null;
220745
220766
  if (isString2(key) || isArray(key)) {
220746
220767
  src = key;
220747
- path63 = createKeyPath(key);
220768
+ path64 = createKeyPath(key);
220748
220769
  id2 = createKeyId(key);
220749
220770
  } else {
220750
220771
  if (!hasOwn.call(key, "name")) {
@@ -220758,11 +220779,11 @@ function createKey(key) {
220758
220779
  throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
220759
220780
  }
220760
220781
  }
220761
- path63 = createKeyPath(name);
220782
+ path64 = createKeyPath(name);
220762
220783
  id2 = createKeyId(name);
220763
220784
  getFn = key.getFn;
220764
220785
  }
220765
- return { path: path63, id: id2, weight, src, getFn };
220786
+ return { path: path64, id: id2, weight, src, getFn };
220766
220787
  }
220767
220788
  function createKeyPath(key) {
220768
220789
  return isArray(key) ? key : key.split(".");
@@ -220770,34 +220791,34 @@ function createKeyPath(key) {
220770
220791
  function createKeyId(key) {
220771
220792
  return isArray(key) ? key.join(".") : key;
220772
220793
  }
220773
- function get(obj, path63) {
220794
+ function get(obj, path64) {
220774
220795
  let list = [];
220775
220796
  let arr = false;
220776
- const deepGet = (obj2, path64, index) => {
220797
+ const deepGet = (obj2, path65, index) => {
220777
220798
  if (!isDefined(obj2)) {
220778
220799
  return;
220779
220800
  }
220780
- if (!path64[index]) {
220801
+ if (!path65[index]) {
220781
220802
  list.push(obj2);
220782
220803
  } else {
220783
- let key = path64[index];
220804
+ let key = path65[index];
220784
220805
  const value = obj2[key];
220785
220806
  if (!isDefined(value)) {
220786
220807
  return;
220787
220808
  }
220788
- if (index === path64.length - 1 && (isString2(value) || isNumber2(value) || isBoolean(value))) {
220809
+ if (index === path65.length - 1 && (isString2(value) || isNumber2(value) || isBoolean(value))) {
220789
220810
  list.push(toString2(value));
220790
220811
  } else if (isArray(value)) {
220791
220812
  arr = true;
220792
220813
  for (let i2 = 0, len = value.length;i2 < len; i2 += 1) {
220793
- deepGet(value[i2], path64, index + 1);
220814
+ deepGet(value[i2], path65, index + 1);
220794
220815
  }
220795
- } else if (path64.length) {
220796
- deepGet(value, path64, index + 1);
220816
+ } else if (path65.length) {
220817
+ deepGet(value, path65, index + 1);
220797
220818
  }
220798
220819
  }
220799
220820
  };
220800
- deepGet(obj, isString2(path63) ? path63.split(".") : path63, 0);
220821
+ deepGet(obj, isString2(path64) ? path64.split(".") : path64, 0);
220801
220822
  return arr ? list : list[0];
220802
220823
  }
220803
220824
  var MatchOptions = {
@@ -221993,9 +222014,9 @@ var registerSearch = (program3) => {
221993
222014
  }
221994
222015
  if (opts.json) {
221995
222016
  const unifiedResults = [
221996
- ...kicadResults.map((path63) => ({
222017
+ ...kicadResults.map((path64) => ({
221997
222018
  source: "kicad",
221998
- path: path63
222019
+ path: path64
221999
222020
  })),
222000
222021
  ...results.packages.map((pkg) => ({
222001
222022
  source: "tscircuit",
@@ -222023,8 +222044,8 @@ var registerSearch = (program3) => {
222023
222044
  }
222024
222045
  if (kicadResults.length) {
222025
222046
  console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
222026
- kicadResults.forEach((path63, idx) => {
222027
- console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path63.replace(".kicad_mod", "").replace(".pretty", "")}`);
222047
+ kicadResults.forEach((path64, idx) => {
222048
+ console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path64.replace(".kicad_mod", "").replace(".pretty", "")}`);
222028
222049
  });
222029
222050
  }
222030
222051
  if (results.packages.length) {
@@ -222048,22 +222069,22 @@ var registerSearch = (program3) => {
222048
222069
  };
222049
222070
 
222050
222071
  // lib/shared/setup-github-actions.ts
222051
- import fs60 from "node:fs";
222052
- import path63 from "node:path";
222072
+ import fs61 from "node:fs";
222073
+ import path64 from "node:path";
222053
222074
  var setupGithubActions = (projectDir = process.cwd()) => {
222054
222075
  const findGitRoot = (startDir) => {
222055
- let dir = path63.resolve(startDir);
222056
- while (dir !== path63.parse(dir).root) {
222057
- if (fs60.existsSync(path63.join(dir, ".git"))) {
222076
+ let dir = path64.resolve(startDir);
222077
+ while (dir !== path64.parse(dir).root) {
222078
+ if (fs61.existsSync(path64.join(dir, ".git"))) {
222058
222079
  return dir;
222059
222080
  }
222060
- dir = path63.dirname(dir);
222081
+ dir = path64.dirname(dir);
222061
222082
  }
222062
222083
  return null;
222063
222084
  };
222064
222085
  const gitRoot = findGitRoot(projectDir) ?? projectDir;
222065
- const workflowsDir = path63.join(gitRoot, ".github", "workflows");
222066
- fs60.mkdirSync(workflowsDir, { recursive: true });
222086
+ const workflowsDir = path64.join(gitRoot, ".github", "workflows");
222087
+ fs61.mkdirSync(workflowsDir, { recursive: true });
222067
222088
  const buildWorkflow = `name: tscircuit Build
222068
222089
 
222069
222090
  on:
@@ -222102,8 +222123,8 @@ jobs:
222102
222123
  - run: bun install
222103
222124
  - run: bunx tsci snapshot
222104
222125
  `;
222105
- writeFileIfNotExists(path63.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
222106
- writeFileIfNotExists(path63.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
222126
+ writeFileIfNotExists(path64.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
222127
+ writeFileIfNotExists(path64.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
222107
222128
  };
222108
222129
 
222109
222130
  // cli/setup/register.ts
@@ -222270,22 +222291,22 @@ function applyCameraPreset(preset, cam) {
222270
222291
  }
222271
222292
 
222272
222293
  // lib/shared/snapshot-project.ts
222273
- import fs64 from "node:fs";
222274
- import path66 from "node:path";
222294
+ import fs65 from "node:fs";
222295
+ import path67 from "node:path";
222275
222296
 
222276
222297
  // cli/snapshot/worker-pool.ts
222277
- import fs61 from "node:fs";
222278
- import path64 from "node:path";
222298
+ import fs62 from "node:fs";
222299
+ import path65 from "node:path";
222279
222300
  var getWorkerEntrypointPath2 = () => {
222280
- const tsPath = path64.join(import.meta.dir, "snapshot.worker.ts");
222281
- if (fs61.existsSync(tsPath)) {
222301
+ const tsPath = path65.join(import.meta.dir, "snapshot.worker.ts");
222302
+ if (fs62.existsSync(tsPath)) {
222282
222303
  return tsPath;
222283
222304
  }
222284
- const jsBundledPath = path64.join(import.meta.dir, "snapshot", "snapshot.worker.js");
222285
- if (fs61.existsSync(jsBundledPath)) {
222305
+ const jsBundledPath = path65.join(import.meta.dir, "snapshot", "snapshot.worker.js");
222306
+ if (fs62.existsSync(jsBundledPath)) {
222286
222307
  return jsBundledPath;
222287
222308
  }
222288
- return path64.join(import.meta.dir, "snapshot.worker.js");
222309
+ return path65.join(import.meta.dir, "snapshot.worker.js");
222289
222310
  };
222290
222311
  var snapshotFilesWithWorkerPool = async (options) => {
222291
222312
  const cancellationError = new Error("Snapshot cancelled due to file failure");
@@ -222352,8 +222373,8 @@ var snapshotFilesWithWorkerPool = async (options) => {
222352
222373
  };
222353
222374
 
222354
222375
  // lib/shared/process-snapshot-file.ts
222355
- import fs63 from "node:fs";
222356
- import path65 from "node:path";
222376
+ import fs64 from "node:fs";
222377
+ import path66 from "node:path";
222357
222378
  import {
222358
222379
  convertCircuitJsonToGltf as convertCircuitJsonToGltf5,
222359
222380
  getBestCameraPosition
@@ -222366,7 +222387,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
222366
222387
 
222367
222388
  // lib/shared/compare-images.ts
222368
222389
  import looksSame from "looks-same";
222369
- import fs62 from "node:fs/promises";
222390
+ import fs63 from "node:fs/promises";
222370
222391
  var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true) => {
222371
222392
  const { equal: equal2 } = await looksSame(buffer1, buffer2, {
222372
222393
  strict: false,
@@ -222382,7 +222403,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true)
222382
222403
  tolerance: 2
222383
222404
  });
222384
222405
  } else {
222385
- await fs62.writeFile(diffPath, buffer2);
222406
+ await fs63.writeFile(diffPath, buffer2);
222386
222407
  }
222387
222408
  }
222388
222409
  return { equal: equal2 };
@@ -222402,7 +222423,7 @@ var processSnapshotFile = async ({
222402
222423
  createDiff,
222403
222424
  cameraPreset
222404
222425
  }) => {
222405
- const relativeFilePath = path65.relative(projectDir, file);
222426
+ const relativeFilePath = path66.relative(projectDir, file);
222406
222427
  const successPaths = [];
222407
222428
  const warningMessages = [];
222408
222429
  const mismatches = [];
@@ -222412,7 +222433,7 @@ var processSnapshotFile = async ({
222412
222433
  let schSvg;
222413
222434
  try {
222414
222435
  if (isCircuitJsonFile(file)) {
222415
- const parsed = JSON.parse(fs63.readFileSync(file, "utf-8"));
222436
+ const parsed = JSON.parse(fs64.readFileSync(file, "utf-8"));
222416
222437
  circuitJson = Array.isArray(parsed) ? parsed : [];
222417
222438
  } else {
222418
222439
  const completePlatformConfig = getCompletePlatformConfig(platformConfig2);
@@ -222483,12 +222504,12 @@ var processSnapshotFile = async ({
222483
222504
  } catch (error) {
222484
222505
  const errorMessage = error instanceof Error ? error.message : String(error);
222485
222506
  if (errorMessage.includes("No pcb_board found in circuit JSON")) {
222486
- const fileDir = path65.dirname(file);
222487
- const relativeDir = path65.relative(projectDir, fileDir);
222488
- const snapDir2 = snapshotsDirName ? path65.join(projectDir, snapshotsDirName, relativeDir) : path65.join(fileDir, "__snapshots__");
222489
- const base2 = path65.basename(file).replace(/\.[^.]+$/, "");
222490
- const snap3dPath = path65.join(snapDir2, `${base2}-3d.snap.png`);
222491
- const existing3dSnapshot = fs63.existsSync(snap3dPath);
222507
+ const fileDir = path66.dirname(file);
222508
+ const relativeDir = path66.relative(projectDir, fileDir);
222509
+ const snapDir2 = snapshotsDirName ? path66.join(projectDir, snapshotsDirName, relativeDir) : path66.join(fileDir, "__snapshots__");
222510
+ const base2 = path66.basename(file).replace(/\.[^.]+$/, "");
222511
+ const snap3dPath = path66.join(snapDir2, `${base2}-3d.snap.png`);
222512
+ const existing3dSnapshot = fs64.existsSync(snap3dPath);
222492
222513
  if (existing3dSnapshot) {
222493
222514
  return {
222494
222515
  ok: false,
@@ -222499,7 +222520,7 @@ var processSnapshotFile = async ({
222499
222520
  errorMessage: kleur_default.red(`
222500
222521
  ❌ Failed to generate 3D snapshot for ${relativeFilePath}:
222501
222522
  `) + kleur_default.red(` No pcb_board found in circuit JSON
222502
- `) + kleur_default.red(` Existing snapshot: ${path65.relative(projectDir, snap3dPath)}
222523
+ `) + kleur_default.red(` Existing snapshot: ${path66.relative(projectDir, snap3dPath)}
222503
222524
  `)
222504
222525
  };
222505
222526
  }
@@ -222520,9 +222541,9 @@ var processSnapshotFile = async ({
222520
222541
  }
222521
222542
  }
222522
222543
  }
222523
- const snapDir = snapshotsDirName ? path65.join(projectDir, snapshotsDirName, path65.relative(projectDir, path65.dirname(file))) : path65.join(path65.dirname(file), "__snapshots__");
222524
- fs63.mkdirSync(snapDir, { recursive: true });
222525
- const base = path65.basename(file).replace(/\.[^.]+$/, "");
222544
+ const snapDir = snapshotsDirName ? path66.join(projectDir, snapshotsDirName, path66.relative(projectDir, path66.dirname(file))) : path66.join(path66.dirname(file), "__snapshots__");
222545
+ fs64.mkdirSync(snapDir, { recursive: true });
222546
+ const base = path66.basename(file).replace(/\.[^.]+$/, "");
222526
222547
  const snapshots = [];
222527
222548
  if (pcbOnly || !schematicOnly) {
222528
222549
  snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
@@ -222536,31 +222557,31 @@ var processSnapshotFile = async ({
222536
222557
  for (const snapshot of snapshots) {
222537
222558
  const { type } = snapshot;
222538
222559
  const is3d = type === "3d";
222539
- const snapPath = path65.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
222540
- const existing = fs63.existsSync(snapPath);
222560
+ const snapPath = path66.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
222561
+ const existing = fs64.existsSync(snapPath);
222541
222562
  const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
222542
222563
  const newContentForFile = snapshot.content;
222543
222564
  if (!existing) {
222544
- fs63.writeFileSync(snapPath, newContentForFile);
222545
- successPaths.push(path65.relative(projectDir, snapPath));
222565
+ fs64.writeFileSync(snapPath, newContentForFile);
222566
+ successPaths.push(path66.relative(projectDir, snapPath));
222546
222567
  didUpdate = true;
222547
222568
  continue;
222548
222569
  }
222549
- const oldContentBuffer = fs63.readFileSync(snapPath);
222570
+ const oldContentBuffer = fs64.readFileSync(snapPath);
222550
222571
  const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
222551
222572
  const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath, createDiff);
222552
222573
  if (update) {
222553
222574
  if (!forceUpdate && equal2) {
222554
- successPaths.push(path65.relative(projectDir, snapPath));
222575
+ successPaths.push(path66.relative(projectDir, snapPath));
222555
222576
  } else {
222556
- fs63.writeFileSync(snapPath, newContentForFile);
222557
- successPaths.push(path65.relative(projectDir, snapPath));
222577
+ fs64.writeFileSync(snapPath, newContentForFile);
222578
+ successPaths.push(path66.relative(projectDir, snapPath));
222558
222579
  didUpdate = true;
222559
222580
  }
222560
222581
  } else if (!equal2) {
222561
222582
  mismatches.push(createDiff ? `${snapPath} (diff: ${diffPath})` : snapPath);
222562
222583
  } else {
222563
- successPaths.push(path65.relative(projectDir, snapPath));
222584
+ successPaths.push(path66.relative(projectDir, snapPath));
222564
222585
  }
222565
222586
  }
222566
222587
  return {
@@ -222602,12 +222623,12 @@ var snapshotProject = async ({
222602
222623
  ...DEFAULT_IGNORED_PATTERNS,
222603
222624
  ...ignored.map(normalizeIgnorePattern)
222604
222625
  ];
222605
- const resolvedPaths = filePaths.map((f2) => path66.resolve(projectDir, f2));
222626
+ const resolvedPaths = filePaths.map((f2) => path67.resolve(projectDir, f2));
222606
222627
  const explicitDirectoryTarget = resolvedPaths.find((resolvedPath) => {
222607
- if (!fs64.existsSync(resolvedPath)) {
222628
+ if (!fs65.existsSync(resolvedPath)) {
222608
222629
  return false;
222609
222630
  }
222610
- return fs64.statSync(resolvedPath).isDirectory();
222631
+ return fs65.statSync(resolvedPath).isDirectory();
222611
222632
  });
222612
222633
  const boardFiles = findBoardFiles({
222613
222634
  projectDir,
@@ -222616,7 +222637,7 @@ var snapshotProject = async ({
222616
222637
  });
222617
222638
  if (boardFiles.length === 0) {
222618
222639
  if (explicitDirectoryTarget) {
222619
- const relativeDirectory = path66.relative(projectDir, explicitDirectoryTarget) || ".";
222640
+ const relativeDirectory = path67.relative(projectDir, explicitDirectoryTarget) || ".";
222620
222641
  const includeBoardFilePatterns = getBoardFilePatterns(projectDir);
222621
222642
  const patternSourceMessage = hasConfiguredIncludeBoardFiles(projectDir) ? "Searched using tscircuit.config.json includeBoardFiles" : "Searched using default includeBoardFiles";
222622
222643
  onError([
@@ -222749,7 +222770,7 @@ var registerSnapshot = (program3) => {
222749
222770
  };
222750
222771
 
222751
222772
  // cli/transpile/register.ts
222752
- import path67 from "node:path";
222773
+ import path68 from "node:path";
222753
222774
  var registerTranspile = (program3) => {
222754
222775
  program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
222755
222776
  try {
@@ -222757,7 +222778,7 @@ var registerTranspile = (program3) => {
222757
222778
  fileOrDir: file,
222758
222779
  includeBoardFiles: false
222759
222780
  });
222760
- const distDir = path67.join(projectDir, "dist");
222781
+ const distDir = path68.join(projectDir, "dist");
222761
222782
  validateMainInDist(projectDir, distDir);
222762
222783
  console.log("Transpiling entry file...");
222763
222784
  const entryFile = mainEntrypoint || circuitFiles[0];
package/dist/lib/index.js CHANGED
@@ -60445,7 +60445,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
60445
60445
  }));
60446
60446
  };
60447
60447
  // package.json
60448
- var version = "0.1.1108";
60448
+ var version = "0.1.1109";
60449
60449
  var package_default = {
60450
60450
  name: "@tscircuit/cli",
60451
60451
  version,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.1109",
3
+ "version": "0.1.1111",
4
4
  "main": "dist/cli/main.js",
5
5
  "exports": {
6
6
  ".": "./dist/cli/main.js",