@tscircuit/cli 0.1.2371 → 0.1.2373

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/cli/main.js CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/cli/main.js
3
- size: 46949501 bytes
4
- sha256: 1c4a78cfcc460f7db8131969afc3e3c563f23f355eb0c489349a70591fa49651
3
+ size: 46951130 bytes
4
+ sha256: 7f0d1c6ae9572d5bfb510f1606d5e4f75c4dccfaf186e1258acf21b60b62cce3
package/dist/lib/index.js CHANGED
@@ -69121,7 +69121,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
69121
69121
  }));
69122
69122
  };
69123
69123
  // package.json
69124
- var version = "0.1.2368";
69124
+ var version = "0.1.2371";
69125
69125
  var package_default = {
69126
69126
  name: "@tscircuit/cli",
69127
69127
  version,
@@ -69144,7 +69144,7 @@ var package_default = {
69144
69144
  "@tscircuit/circuit-json-schematic-placement-analysis": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/0.0.68.tgz",
69145
69145
  "@tscircuit/circuit-json-util": "^0.0.121",
69146
69146
  "@tscircuit/eval": "0.0.1619",
69147
- "@tscircuit/fake-snippets": "^0.0.182",
69147
+ "@tscircuit/fake-snippets": "^0.0.226",
69148
69148
  "@tscircuit/file-server": "^0.0.32",
69149
69149
  "@tscircuit/footprinter": "^0.0.438",
69150
69150
  "@tscircuit/image-utils": "^0.0.8",
@@ -69175,7 +69175,7 @@ var package_default = {
69175
69175
  "circuit-json-to-fdm-component-box": "^0.0.2",
69176
69176
  "circuit-json-to-footprinter": "^0.0.59",
69177
69177
  "circuit-json-to-gerber": "^0.0.112",
69178
- "circuit-json-to-kicad": "0.0.236",
69178
+ "circuit-json-to-kicad": "0.0.241",
69179
69179
  "circuit-json-to-pnp-csv": "^0.0.18",
69180
69180
  "circuit-json-to-readable-netlist": "^0.0.15",
69181
69181
  "circuit-json-to-spice": "^0.0.45",
@@ -69205,6 +69205,7 @@ var package_default = {
69205
69205
  ky: "^1.7.4",
69206
69206
  "make-vfs": "^1.0.15",
69207
69207
  md5: "^2.3.0",
69208
+ "mime-types": "^3.0.2",
69208
69209
  "pdf-lib": "^1.17.1",
69209
69210
  "perfect-cli": "^1.0.21",
69210
69211
  playwright: "^1.57.0",
@@ -71923,7 +71924,8 @@ import {
71923
71924
  LibSymbols,
71924
71925
  SchematicSymbol as SchematicSymbol4,
71925
71926
  SymbolPinNames,
71926
- SymbolPinNumbers
71927
+ SymbolPinNumbers,
71928
+ SymbolPower
71927
71929
  } from "kicadts";
71928
71930
  import { symbols as symbols3 } from "schematic-symbols";
71929
71931
  import { symbols } from "schematic-symbols";
@@ -73997,21 +73999,19 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
73997
73999
  }
73998
74000
  }
73999
74001
  const netLabels = db.schematic_net_label?.list?.() || [];
74002
+ const railLibraryIds = /* @__PURE__ */ new Set;
74000
74003
  for (const netLabel of netLabels) {
74001
- if (netLabel.symbol_name) {
74002
- const isPower = netLabel.source_net_id ? db.source_net.get(netLabel.source_net_id)?.is_power : false;
74003
- const isGround = netLabel.source_net_id ? db.source_net.get(netLabel.source_net_id)?.is_ground : false;
74004
- const isPowerOrGround = isPower || isGround;
74005
- if (isPowerOrGround) {
74006
- const libSymbol = this.createLibrarySymbolForNetLabel({
74007
- netLabel,
74008
- isPower: isPower ?? false,
74009
- isGround: isGround ?? false
74010
- });
74011
- if (libSymbol) {
74012
- librarySymbols.push(libSymbol);
74013
- }
74014
- }
74004
+ if (!netLabel.symbol_name || railLibraryIds.has(netLabel.symbol_name))
74005
+ continue;
74006
+ const sourceNet = netLabel.source_net_id ? db.source_net.get(netLabel.source_net_id) : undefined;
74007
+ const libSymbol = this.createLibrarySymbolForNetLabel({
74008
+ netLabel,
74009
+ isPower: sourceNet?.is_power ?? false,
74010
+ isGround: sourceNet?.is_ground ?? false
74011
+ });
74012
+ if (libSymbol) {
74013
+ librarySymbols.push(libSymbol);
74014
+ railLibraryIds.add(netLabel.symbol_name);
74015
74015
  }
74016
74016
  }
74017
74017
  libSymbols.symbols = librarySymbols;
@@ -74168,7 +74168,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
74168
74168
  if (!symbolData)
74169
74169
  return null;
74170
74170
  const libId = `Custom:${symbolName}`;
74171
- return this.createLibrarySymbol({
74171
+ const symbol = this.createLibrarySymbol({
74172
74172
  libId,
74173
74173
  symbolData,
74174
74174
  isChip: false,
@@ -74176,9 +74176,17 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
74176
74176
  description: isPower ? "Power net label" : isGround ? "Ground net label" : "Net symbol",
74177
74177
  keywords: isPower ? "power net" : isGround ? "ground net" : "net",
74178
74178
  fpFilters: "",
74179
- referencePrefix: libId.split(":")[1]?.[0] || "U",
74179
+ referencePrefix: "#PWR",
74180
74180
  symbolScale: this.ctx.kicadSchematicScaleFactor
74181
74181
  });
74182
+ symbol._sxPower = new SymbolPower("global");
74183
+ symbol.inBom = false;
74184
+ symbol.onBoard = false;
74185
+ for (const unit of symbol.subSymbols) {
74186
+ for (const pin of unit.pins)
74187
+ pin.pinElectricalType = "power_in";
74188
+ }
74189
+ return symbol;
74182
74190
  }
74183
74191
  getSymbolData(symbolName, schematicComponent) {
74184
74192
  if (symbolName.startsWith("generic_chip_")) {
@@ -74560,13 +74568,14 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
74560
74568
  x -= pinPosition.x;
74561
74569
  y += pinPosition.y;
74562
74570
  }
74571
+ const reference = `#PWR${netLabel.schematic_net_label_id}`;
74563
74572
  const uuid = crypto.randomUUID();
74564
74573
  const symbol = new SchematicSymbol5({
74565
74574
  at: [x, y, 0],
74566
74575
  unit: 1,
74567
74576
  excludeFromSim: false,
74568
- inBom: true,
74569
- onBoard: true,
74577
+ inBom: false,
74578
+ onBoard: false,
74570
74579
  dnp: false,
74571
74580
  uuid,
74572
74581
  fieldsAutoplaced: false
@@ -74576,20 +74585,19 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
74576
74585
  symbol._sxLibId = symLibId;
74577
74586
  const isUpSymbol = symbolName.includes("_up") || symbolName.toLowerCase().includes("vcc");
74578
74587
  const referenceOffset = isUpSymbol ? -4 : 4;
74579
- const valueOffset = isUpSymbol ? -6 : 6;
74580
74588
  const referenceProperty = new SymbolProperty2({
74581
74589
  key: "Reference",
74582
- value: labelText,
74590
+ value: reference,
74583
74591
  id: 0,
74584
74592
  at: [x, y + referenceOffset, 0],
74585
- effects: this.createTextEffects(1.27, false)
74593
+ effects: this.createTextEffects(1.27, true)
74586
74594
  });
74587
74595
  const valueProperty = new SymbolProperty2({
74588
74596
  key: "Value",
74589
74597
  value: labelText,
74590
74598
  id: 1,
74591
- at: [x, y + valueOffset, 0],
74592
- effects: this.createTextEffects(1.27, true)
74599
+ at: [x, y + referenceOffset, 0],
74600
+ effects: this.createTextEffects(1.27, false)
74593
74601
  });
74594
74602
  const footprintProperty = new SymbolProperty2({
74595
74603
  key: "Footprint",
@@ -74622,7 +74630,7 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
74622
74630
  const project = new SymbolInstancesProject("");
74623
74631
  const instancePathPrefix = this.ctx.symbolInstancePathPrefix ?? `/${kicadSch?.uuid?.value || ""}`;
74624
74632
  const path = new SymbolInstancePath(instancePathPrefix);
74625
- path.reference = labelText;
74633
+ path.reference = reference;
74626
74634
  path.unit = 1;
74627
74635
  project.paths.push(path);
74628
74636
  instances.projects.push(project);
@@ -77549,6 +77557,7 @@ var AddTracesStage = class extends ConverterStage {
77549
77557
  constructor(input, ctx) {
77550
77558
  super(input, ctx);
77551
77559
  this.pcbTraces = this.ctx.db.pcb_trace.list();
77560
+ this.MAX_ITERATIONS = Math.max(this.MAX_ITERATIONS, this.pcbTraces.length + 1);
77552
77561
  }
77553
77562
  getRoutePointPosition(point, pointRoleInSegment) {
77554
77563
  if ("x" in point && "y" in point) {
@@ -84765,19 +84774,19 @@ var findPushProject = async ({
84765
84774
  }) ?? undefined;
84766
84775
  return { snippetFilePath, packageJsonPath, projectDir };
84767
84776
  };
84768
- var getArchivePayload = (filePaths, projectDir, packageNameWithVersion) => {
84769
- const files = filePaths.map((fullFilePath) => {
84770
- const relativeFilePath = path28.relative(projectDir, fullFilePath);
84771
- const fileBuffer = fs24.readFileSync(fullFilePath);
84772
- const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
84773
- return isBinary ? {
84774
- file_path: relativeFilePath,
84775
- content_base64: fileBuffer.toString("base64")
84776
- } : {
84777
- file_path: relativeFilePath,
84778
- content_text: fileBuffer.toString("utf8")
84779
- };
84780
- });
84777
+ var getUploadFiles = (filePaths, projectDir) => filePaths.map((fullFilePath) => {
84778
+ const relativeFilePath = path28.relative(projectDir, fullFilePath).split(path28.sep).join("/");
84779
+ const fileBuffer = fs24.readFileSync(fullFilePath);
84780
+ const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
84781
+ return isBinary ? {
84782
+ file_path: relativeFilePath,
84783
+ content_base64: fileBuffer.toString("base64")
84784
+ } : {
84785
+ file_path: relativeFilePath,
84786
+ content_text: fileBuffer.toString("utf8")
84787
+ };
84788
+ });
84789
+ var createArchivePayload = (files, packageNameWithVersion) => {
84781
84790
  const archive = gzipSync(JSON.stringify({ files }), { level: 9 });
84782
84791
  return {
84783
84792
  package_name_with_version: packageNameWithVersion,
@@ -84984,53 +84993,79 @@ var pushSnippet = async ({
84984
84993
  const filePaths = getPackageFilePaths(projectDir, includeDist ? [] : ["**/dist/**"]);
84985
84994
  const uploadResults = { succeeded: [], failed: [] };
84986
84995
  const packageNameWithVersion = `${scopedPackageName}@${releaseVersion}`;
84996
+ const files = getUploadFiles(filePaths, projectDir);
84997
+ let filesToUpload = files;
84987
84998
  if (compress) {
84988
84999
  log(kleur_default.gray("Uploading package archive..."));
84989
85000
  try {
84990
- const archivePayload = getArchivePayload(filePaths, projectDir, packageNameWithVersion);
85001
+ const archivePayload = createArchivePayload(files, packageNameWithVersion);
84991
85002
  await ky.post("package_files/upload_archive", {
84992
85003
  json: archivePayload
84993
85004
  });
84994
- for (const fullFilePath of filePaths) {
84995
- const relativeFilePath = path28.relative(projectDir, fullFilePath);
84996
- uploadResults.succeeded.push(relativeFilePath);
85005
+ for (const file of files) {
85006
+ uploadResults.succeeded.push(file.file_path);
84997
85007
  }
85008
+ filesToUpload = [];
84998
85009
  log(kleur_default.gray(`\uD83D\uDCE6 Uploaded archive with ${filePaths.length} files`));
84999
85010
  } catch (error) {
85000
- log(kleur_default.yellow(`Archive upload failed, falling back to file-by-file upload: ${error}`));
85001
- }
85002
- }
85003
- if (uploadResults.succeeded.length === 0) {
85004
- for (const fullFilePath of filePaths) {
85005
- const relativeFilePath = path28.relative(projectDir, fullFilePath);
85006
- const fileBuffer = fs24.readFileSync(fullFilePath);
85007
- const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
85008
- const payload = {
85009
- file_path: relativeFilePath,
85010
- package_name_with_version: packageNameWithVersion
85011
- };
85012
- if (isBinary) {
85013
- payload.content_base64 = fileBuffer.toString("base64");
85011
+ const status = error?.response?.status;
85012
+ if (status === undefined || status === 408 || status >= 500) {
85013
+ log(kleur_default.yellow(`Archive upload outcome unknown, checking release files: ${error}`));
85014
+ try {
85015
+ const { package_files: remoteFiles } = await ky.get("package_files/list", {
85016
+ searchParams: {
85017
+ package_name_with_version: packageNameWithVersion
85018
+ }
85019
+ }).json();
85020
+ const remoteIds = new Map(remoteFiles.map((file) => [file.file_path, file.package_file_id]));
85021
+ filesToUpload = [];
85022
+ for (const file of files) {
85023
+ const remoteId = remoteIds.get(file.file_path);
85024
+ if (remoteId) {
85025
+ const remoteContent = await ky.get("package_files/download", {
85026
+ searchParams: { package_file_id: remoteId }
85027
+ }).arrayBuffer();
85028
+ const localContent = file.content_base64 !== undefined ? Buffer.from(file.content_base64, "base64") : Buffer.from(file.content_text, "utf8");
85029
+ if (localContent.equals(Buffer.from(remoteContent))) {
85030
+ uploadResults.succeeded.push(file.file_path);
85031
+ continue;
85032
+ }
85033
+ }
85034
+ filesToUpload.push(file);
85035
+ }
85036
+ log(kleur_default.gray(`Verified ${uploadResults.succeeded.length} archive files; ${filesToUpload.length} files still need uploading`));
85037
+ } catch (verificationError) {
85038
+ onError(`Could not verify archive upload outcome: ${verificationError}. No files were retransmitted; check ${packageNameWithVersion} before retrying.`);
85039
+ return onExit(1);
85040
+ }
85014
85041
  } else {
85015
- payload.content_text = fileBuffer.toString("utf-8");
85042
+ log(kleur_default.yellow(`Archive upload failed, falling back to file-by-file upload: ${error}`));
85016
85043
  }
85017
- await ky.post("package_files/create", {
85018
- json: payload
85019
- }).then(() => {
85020
- const icon = isBinary ? "\uD83D\uDCE6" : "⬆︎";
85021
- console.log(kleur_default.gray(`${icon} ${relativeFilePath}`));
85022
- uploadResults.succeeded.push(relativeFilePath);
85023
- }).catch(async (error) => {
85024
- const errorDetails = String(error)?.split(`
85044
+ }
85045
+ }
85046
+ for (const file of filesToUpload) {
85047
+ const relativeFilePath = file.file_path;
85048
+ const isBinary = file.content_base64 !== undefined;
85049
+ const payload = {
85050
+ ...file,
85051
+ package_name_with_version: packageNameWithVersion
85052
+ };
85053
+ await ky.post("package_files/create", {
85054
+ json: payload
85055
+ }).then(() => {
85056
+ const icon = isBinary ? "\uD83D\uDCE6" : "⬆︎";
85057
+ console.log(kleur_default.gray(`${icon} ${relativeFilePath}`));
85058
+ uploadResults.succeeded.push(relativeFilePath);
85059
+ }).catch(async (error) => {
85060
+ const errorDetails = String(error)?.split(`
85025
85061
 
85026
85062
  Request Body:`)?.[0];
85027
- console.log(kleur_default.red(` ${relativeFilePath} - failed`));
85028
- uploadResults.failed.push({
85029
- file: relativeFilePath,
85030
- error: errorDetails
85031
- });
85063
+ console.log(kleur_default.red(` ${relativeFilePath} - failed`));
85064
+ uploadResults.failed.push({
85065
+ file: relativeFilePath,
85066
+ error: errorDetails
85032
85067
  });
85033
- }
85068
+ });
85034
85069
  }
85035
85070
  log(`
85036
85071
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.2371",
3
+ "version": "0.1.2373",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/tscircuit/cli"
@@ -20,7 +20,7 @@
20
20
  "@tscircuit/circuit-json-schematic-placement-analysis": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/0.0.68.tgz",
21
21
  "@tscircuit/circuit-json-util": "^0.0.121",
22
22
  "@tscircuit/eval": "0.0.1619",
23
- "@tscircuit/fake-snippets": "^0.0.182",
23
+ "@tscircuit/fake-snippets": "^0.0.226",
24
24
  "@tscircuit/file-server": "^0.0.32",
25
25
  "@tscircuit/footprinter": "^0.0.438",
26
26
  "@tscircuit/image-utils": "^0.0.8",
@@ -51,7 +51,7 @@
51
51
  "circuit-json-to-fdm-component-box": "^0.0.2",
52
52
  "circuit-json-to-footprinter": "^0.0.59",
53
53
  "circuit-json-to-gerber": "^0.0.112",
54
- "circuit-json-to-kicad": "0.0.236",
54
+ "circuit-json-to-kicad": "0.0.241",
55
55
  "circuit-json-to-pnp-csv": "^0.0.18",
56
56
  "circuit-json-to-readable-netlist": "^0.0.15",
57
57
  "circuit-json-to-spice": "^0.0.45",
@@ -81,6 +81,7 @@
81
81
  "ky": "^1.7.4",
82
82
  "make-vfs": "^1.0.15",
83
83
  "md5": "^2.3.0",
84
+ "mime-types": "^3.0.2",
84
85
  "pdf-lib": "^1.17.1",
85
86
  "perfect-cli": "^1.0.21",
86
87
  "playwright": "^1.57.0",