@tscircuit/cli 0.1.121 → 0.1.123

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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/main.js +142 -20
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -55,6 +55,7 @@ Commands:
55
55
  remove <component> Remove a tscircuit component package from your
56
56
  project
57
57
  snapshot [options] Generate schematic and PCB snapshots
58
+ setup Setup utilities like GitHub Actions
58
59
  upgrade Upgrade CLI to the latest version
59
60
  search <query> Search for packages in the tscircuit registry
60
61
  version Print CLI version
package/dist/main.js CHANGED
@@ -233386,6 +233386,7 @@ __export2(exports_dist, {
233386
233386
  schematic_net_label: () => schematic_net_label2,
233387
233387
  schematic_manual_edit_conflict_warning: () => schematic_manual_edit_conflict_warning2,
233388
233388
  schematic_line: () => schematic_line2,
233389
+ schematic_layout_error: () => schematic_layout_error,
233389
233390
  schematic_group: () => schematic_group,
233390
233391
  schematic_error: () => schematic_error2,
233391
233392
  schematic_debug_rect: () => schematic_debug_rect2,
@@ -233519,7 +233520,7 @@ var unitMappings2, unitMappingAndVariantSuffixes2, si_prefix_multiplier2, parseA
233519
233520
  };
233520
233521
  }, resistance2, capacitance2, inductance2, voltage2, length2, frequency2, distance3, current2, time2, rotation2, battery_capacity2, point2, position2, point32, position32, size2, getZodPrefixedIdWithDefault2 = (prefix) => {
233521
233522
  return z.string().optional().default(() => `${prefix}_${nanoid2(10)}`);
233522
- }, supplier_name2, expectTypesMatch2 = (shouldBe) => {}, expectStringUnionsMatch2 = (shouldBe) => {}, source_component_base2, source_simple_capacitor2, source_simple_resistor2, source_simple_diode2, source_simple_led, source_simple_ground2, source_simple_bug2, source_simple_chip2, source_led2, source_simple_power_source2, source_simple_fuse, source_simple_battery2, source_simple_inductor2, source_simple_push_button2, source_simple_potentiometer2, source_simple_crystal2, source_simple_pin_header2, source_simple_resonator2, source_simple_transistor2, source_simple_mosfet2, source_simple_switch2, source_project_metadata2, source_missing_property_error2, source_failed_to_create_component_error2, any_source_component2, source_port2, source_trace2, source_group2, source_net2, schematic_box2, schematic_path2, schematic_pin_styles2, schematic_component_port_arrangement_by_size2, schematic_component_port_arrangement_by_sides2, port_arrangement2, schematic_component2, schematic_line2, schematic_trace2, ninePointAnchor2, fivePointAnchor2, schematic_text2, schematic_port2, schematic_net_label2, schematic_error2, schematic_debug_object_base2, schematic_debug_rect2, schematic_debug_line2, schematic_debug_point2, schematic_debug_object2, schematic_voltage_probe2, schematic_manual_edit_conflict_warning2, schematic_group, all_layers2, layer_string2, layer_ref2, visible_layer2, pcb_route_hint2, pcb_route_hints2, route_hint_point2, pcb_component2, pcb_hole_circle_or_square2, pcb_hole_circle_or_square_shape2, pcb_hole_oval2, pcb_hole_oval_shape2, pcb_hole2, pcb_plated_hole_circle2, pcb_plated_hole_oval2, pcb_circular_hole_with_rect_pad2, pcb_pill_hole_with_rect_pad2, pcb_plated_hole2, pcb_port2, pcb_smtpad_circle2, pcb_smtpad_rect2, pcb_smtpad_rotated_rect2, pcb_smtpad_pill2, pcb_smtpad2, pcb_solder_paste_circle2, pcb_solder_paste_rect2, pcb_solder_paste_pill2, pcb_solder_paste_rotated_rect2, pcb_solder_paste_oval2, pcb_solder_paste2, pcb_text2, pcb_trace_route_point_wire2, pcb_trace_route_point_via2, pcb_trace_route_point2, pcb_trace2, pcb_trace_error2, pcb_port_not_matched_error2, pcb_via2, pcb_board2, pcb_placement_error2, pcb_trace_hint2, pcb_silkscreen_line2, pcb_silkscreen_path2, pcb_silkscreen_text2, pcb_silkscreen_rect2, pcb_silkscreen_circle2, pcb_silkscreen_oval2, pcb_fabrication_note_text2, pcb_fabrication_note_path2, pcb_keepout2, pcb_cutout_base, pcb_cutout_rect, pcb_cutout_circle, pcb_cutout_polygon, pcb_cutout, pcb_missing_footprint_error2, pcb_group2, pcb_autorouting_error2, pcb_manual_edit_conflict_warning2, cad_component2, any_circuit_element2, any_soup_element2;
233523
+ }, supplier_name2, expectTypesMatch2 = (shouldBe) => {}, expectStringUnionsMatch2 = (shouldBe) => {}, source_component_base2, source_simple_capacitor2, source_simple_resistor2, source_simple_diode2, source_simple_led, source_simple_ground2, source_simple_bug2, source_simple_chip2, source_led2, source_simple_power_source2, source_simple_fuse, source_simple_battery2, source_simple_inductor2, source_simple_push_button2, source_simple_potentiometer2, source_simple_crystal2, source_simple_pin_header2, source_simple_resonator2, source_simple_transistor2, source_simple_mosfet2, source_simple_switch2, source_project_metadata2, source_missing_property_error2, source_failed_to_create_component_error2, any_source_component2, source_port2, source_trace2, source_group2, source_net2, schematic_box2, schematic_path2, schematic_pin_styles2, schematic_component_port_arrangement_by_size2, schematic_component_port_arrangement_by_sides2, port_arrangement2, schematic_component2, schematic_line2, schematic_trace2, ninePointAnchor2, fivePointAnchor2, schematic_text2, schematic_port2, schematic_net_label2, schematic_error2, schematic_layout_error, schematic_debug_object_base2, schematic_debug_rect2, schematic_debug_line2, schematic_debug_point2, schematic_debug_object2, schematic_voltage_probe2, schematic_manual_edit_conflict_warning2, schematic_group, all_layers2, layer_string2, layer_ref2, visible_layer2, pcb_route_hint2, pcb_route_hints2, route_hint_point2, pcb_component2, pcb_hole_circle_or_square2, pcb_hole_circle_or_square_shape2, pcb_hole_oval2, pcb_hole_oval_shape2, pcb_hole2, pcb_plated_hole_circle2, pcb_plated_hole_oval2, pcb_circular_hole_with_rect_pad2, pcb_pill_hole_with_rect_pad2, pcb_plated_hole2, pcb_port2, pcb_smtpad_circle2, pcb_smtpad_rect2, pcb_smtpad_rotated_rect2, pcb_smtpad_pill2, pcb_smtpad2, pcb_solder_paste_circle2, pcb_solder_paste_rect2, pcb_solder_paste_pill2, pcb_solder_paste_rotated_rect2, pcb_solder_paste_oval2, pcb_solder_paste2, pcb_text2, pcb_trace_route_point_wire2, pcb_trace_route_point_via2, pcb_trace_route_point2, pcb_trace2, pcb_trace_error2, pcb_port_not_matched_error2, pcb_via2, pcb_board2, pcb_placement_error2, pcb_trace_hint2, pcb_silkscreen_line2, pcb_silkscreen_path2, pcb_silkscreen_text2, pcb_silkscreen_rect2, pcb_silkscreen_circle2, pcb_silkscreen_oval2, pcb_fabrication_note_text2, pcb_fabrication_note_path2, pcb_keepout2, pcb_cutout_base, pcb_cutout_rect, pcb_cutout_circle, pcb_cutout_polygon, pcb_cutout, pcb_missing_footprint_error2, pcb_group2, pcb_autorouting_error2, pcb_manual_edit_conflict_warning2, cad_component2, any_circuit_element2, any_soup_element2;
233523
233524
  var init_dist = __esm(() => {
233524
233525
  init_lib();
233525
233526
  init_lib();
@@ -233605,6 +233606,7 @@ var init_dist = __esm(() => {
233605
233606
  init_lib();
233606
233607
  init_lib();
233607
233608
  init_lib();
233609
+ init_lib();
233608
233610
  unitMappings2 = {
233609
233611
  Hz: {
233610
233612
  baseUnit: "Hz",
@@ -233985,7 +233987,8 @@ var init_dist = __esm(() => {
233985
233987
  name: z.string(),
233986
233988
  source_port_id: z.string(),
233987
233989
  source_component_id: z.string(),
233988
- subcircuit_id: z.string().optional()
233990
+ subcircuit_id: z.string().optional(),
233991
+ subcircuit_connectivity_map_key: z.string().optional()
233989
233992
  });
233990
233993
  expectTypesMatch2(true);
233991
233994
  source_trace2 = z.object({
@@ -234018,7 +234021,8 @@ var init_dist = __esm(() => {
234018
234021
  is_digital_signal: z.boolean().optional(),
234019
234022
  is_analog_signal: z.boolean().optional(),
234020
234023
  trace_width: z.number().optional(),
234021
- subcircuit_id: z.string().optional()
234024
+ subcircuit_id: z.string().optional(),
234025
+ subcircuit_connectivity_map_key: z.string().optional()
234022
234026
  });
234023
234027
  schematic_box2 = z.object({
234024
234028
  type: z.literal("schematic_box"),
@@ -234190,6 +234194,14 @@ var init_dist = __esm(() => {
234190
234194
  message: z.string()
234191
234195
  }).describe("Defines a schematic error on the schematic");
234192
234196
  expectTypesMatch2(true);
234197
+ schematic_layout_error = z.object({
234198
+ type: z.literal("schematic_layout_error"),
234199
+ schematic_layout_error_id: getZodPrefixedIdWithDefault2("schematic_layout_error"),
234200
+ message: z.string(),
234201
+ source_group_id: z.string(),
234202
+ schematic_group_id: z.string()
234203
+ }).describe("Error emitted when schematic layout fails for a group");
234204
+ expectTypesMatch2(true);
234193
234205
  schematic_debug_object_base2 = z.object({
234194
234206
  type: z.literal("schematic_debug_object"),
234195
234207
  label: z.string().optional()
@@ -234728,7 +234740,10 @@ var init_dist = __esm(() => {
234728
234740
  width: length2,
234729
234741
  height: length2,
234730
234742
  layer: layer_ref2,
234731
- stroke_width: length2.default("1mm")
234743
+ stroke_width: length2.default("1mm"),
234744
+ is_filled: z.boolean().default(true).optional(),
234745
+ has_stroke: z.boolean().optional(),
234746
+ is_stroke_dashed: z.boolean().optional()
234732
234747
  }).describe("Defines a silkscreen rect on the PCB");
234733
234748
  expectTypesMatch2(true);
234734
234749
  pcb_silkscreen_circle2 = z.object({
@@ -234949,6 +234964,7 @@ var init_dist = __esm(() => {
234949
234964
  schematic_trace2,
234950
234965
  schematic_path2,
234951
234966
  schematic_error2,
234967
+ schematic_layout_error,
234952
234968
  schematic_net_label2,
234953
234969
  schematic_debug_object2,
234954
234970
  schematic_voltage_probe2,
@@ -439676,7 +439692,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
439676
439692
  import { execSync as execSync2 } from "node:child_process";
439677
439693
  var import_semver2 = __toESM2(require_semver2(), 1);
439678
439694
  // package.json
439679
- var version = "0.1.119";
439695
+ var version = "0.1.122";
439680
439696
  var package_default = {
439681
439697
  name: "@tscircuit/cli",
439682
439698
  version,
@@ -439719,6 +439735,7 @@ var package_default = {
439719
439735
  semver: "^7.6.3",
439720
439736
  tempy: "^3.1.0",
439721
439737
  tscircuit: "^0.0.485",
439738
+ "@tscircuit/circuit-json-util": "^0.0.47",
439722
439739
  "typed-ky": "^0.0.4"
439723
439740
  },
439724
439741
  peerDependencies: {
@@ -443832,6 +443849,7 @@ var getPackageFilePaths = (projectDir, ignored = []) => {
443832
443849
  cwd: projectDir,
443833
443850
  ignore: ignorePatterns
443834
443851
  });
443852
+ fileNames.sort();
443835
443853
  return fileNames.map((fileName) => path15.join(projectDir, fileName));
443836
443854
  };
443837
443855
 
@@ -444045,6 +444063,7 @@ var pushSnippet = async ({
444045
444063
  `https://tscircuit.com/${scopedPackageName}`
444046
444064
  ].join(`
444047
444065
  `));
444066
+ return onExit(0);
444048
444067
  };
444049
444068
 
444050
444069
  // lib/shared/add-package.ts
@@ -478958,7 +478977,8 @@ var cju = (soup, options = {}) => {
478958
478977
  let internalStore = soup._internal_store;
478959
478978
  if (!internalStore) {
478960
478979
  internalStore = {
478961
- counts: {}
478980
+ counts: {},
478981
+ editCount: 0
478962
478982
  };
478963
478983
  soup._internal_store = internalStore;
478964
478984
  for (const elm of soup) {
@@ -478973,10 +478993,17 @@ var cju = (soup, options = {}) => {
478973
478993
  }
478974
478994
  }
478975
478995
  const su22 = new Proxy({}, {
478976
- get: (proxy_target, component_type) => {
478977
- if (component_type === "toArray") {
478978
- return () => soup;
478996
+ get: (proxy_target, prop) => {
478997
+ if (prop === "toArray") {
478998
+ return () => {
478999
+ soup.editCount = internalStore.editCount;
479000
+ return soup;
479001
+ };
478979
479002
  }
479003
+ if (prop === "editCount") {
479004
+ return internalStore.editCount;
479005
+ }
479006
+ const component_type = prop;
478980
479007
  return {
478981
479008
  get: (id) => soup.find((e) => e.type === component_type && e[`${component_type}_id`] === id),
478982
479009
  getUsing: (using) => {
@@ -479013,6 +479040,7 @@ var cju = (soup, options = {}) => {
479013
479040
  parser.parse(newElm);
479014
479041
  }
479015
479042
  soup.push(newElm);
479043
+ internalStore.editCount++;
479016
479044
  return newElm;
479017
479045
  },
479018
479046
  delete: (id) => {
@@ -479020,12 +479048,14 @@ var cju = (soup, options = {}) => {
479020
479048
  if (!elm)
479021
479049
  return;
479022
479050
  soup.splice(soup.indexOf(elm), 1);
479051
+ internalStore.editCount++;
479023
479052
  },
479024
479053
  update: (id, newProps) => {
479025
479054
  const elm = soup.find((e) => e.type === component_type && e[`${component_type}_id`] === id);
479026
479055
  if (!elm)
479027
- return;
479056
+ return null;
479028
479057
  Object.assign(elm, newProps);
479058
+ internalStore.editCount++;
479029
479059
  return elm;
479030
479060
  },
479031
479061
  select: (selector) => {
@@ -479065,6 +479095,7 @@ var cjuIndexed = (soup, options = {}) => {
479065
479095
  if (!internalStore) {
479066
479096
  internalStore = {
479067
479097
  counts: {},
479098
+ editCount: 0,
479068
479099
  indexes: {}
479069
479100
  };
479070
479101
  for (const elm of soup) {
@@ -479145,10 +479176,17 @@ var cjuIndexed = (soup, options = {}) => {
479145
479176
  soup._internal_store_indexed = internalStore;
479146
479177
  }
479147
479178
  const suIndexed = new Proxy({}, {
479148
- get: (proxy_target, component_type) => {
479149
- if (component_type === "toArray") {
479150
- return () => soup;
479179
+ get: (proxy_target, prop) => {
479180
+ if (prop === "toArray") {
479181
+ return () => {
479182
+ soup.editCount = internalStore.editCount;
479183
+ return soup;
479184
+ };
479151
479185
  }
479186
+ if (prop === "editCount") {
479187
+ return internalStore.editCount;
479188
+ }
479189
+ const component_type = prop;
479152
479190
  return {
479153
479191
  get: (id) => {
479154
479192
  const indexConfig = options.indexConfig || {};
@@ -479251,6 +479289,7 @@ var cjuIndexed = (soup, options = {}) => {
479251
479289
  parser.parse(newElm);
479252
479290
  }
479253
479291
  soup.push(newElm);
479292
+ internalStore.editCount++;
479254
479293
  const indexConfig = options.indexConfig || {};
479255
479294
  if (indexConfig.byId && internalStore.indexes.byId) {
479256
479295
  const idKey = createIdKey(newElm);
@@ -479313,6 +479352,7 @@ var cjuIndexed = (soup, options = {}) => {
479313
479352
  const elmIndex = soup.indexOf(elm);
479314
479353
  if (elmIndex >= 0) {
479315
479354
  soup.splice(elmIndex, 1);
479355
+ internalStore.editCount++;
479316
479356
  }
479317
479357
  if (indexConfig.byId && internalStore.indexes.byId) {
479318
479358
  const idKey = createIdKey(elm);
@@ -479426,6 +479466,7 @@ var cjuIndexed = (soup, options = {}) => {
479426
479466
  }
479427
479467
  }
479428
479468
  Object.assign(elm, newProps);
479469
+ internalStore.editCount++;
479429
479470
  if (indexConfig.byRelation && internalStore.indexes.byRelation) {
479430
479471
  const elementEntries = Object.entries(elm);
479431
479472
  for (const [key, value2] of elementEntries) {
@@ -479641,10 +479682,22 @@ var getBoundsOfPcbElements = (elements) => {
479641
479682
  continue;
479642
479683
  let centerX;
479643
479684
  let centerY;
479685
+ let width;
479686
+ let height;
479644
479687
  if ("x" in elm && "y" in elm) {
479645
479688
  centerX = elm.x;
479646
479689
  centerY = elm.y;
479647
479690
  }
479691
+ if ("outer_diameter" in elm) {
479692
+ width = elm.outer_diameter;
479693
+ height = elm.outer_diameter;
479694
+ }
479695
+ if ("width" in elm) {
479696
+ width = elm.width;
479697
+ }
479698
+ if ("height" in elm) {
479699
+ height = elm.height;
479700
+ }
479648
479701
  if ("center" in elm) {
479649
479702
  centerX = elm.center.x;
479650
479703
  centerY = elm.center.y;
@@ -479654,13 +479707,11 @@ var getBoundsOfPcbElements = (elements) => {
479654
479707
  minY = Math.min(minY, centerY);
479655
479708
  maxX = Math.max(maxX, centerX);
479656
479709
  maxY = Math.max(maxY, centerY);
479657
- if ("width" in elm) {
479658
- maxX = Math.max(maxX, centerX + elm.width / 2);
479659
- minX = Math.min(minX, centerX - elm.width / 2);
479660
- }
479661
- if ("height" in elm) {
479662
- maxY = Math.max(maxY, centerY + elm.height / 2);
479663
- minY = Math.min(minY, centerY - elm.height / 2);
479710
+ if (width !== undefined && height !== undefined) {
479711
+ minX = Math.min(minX, centerX - width / 2);
479712
+ minY = Math.min(minY, centerY - height / 2);
479713
+ maxX = Math.max(maxX, centerX + width / 2);
479714
+ maxY = Math.max(maxY, centerY + height / 2);
479664
479715
  }
479665
479716
  if ("radius" in elm) {
479666
479717
  minX = Math.min(minX, centerX - elm.radius);
@@ -489980,6 +490031,76 @@ var registerSnapshot = (program3) => {
489980
490031
  });
489981
490032
  };
489982
490033
 
490034
+ // lib/shared/setup-github-actions.ts
490035
+ import fs25 from "node:fs";
490036
+ import path25 from "node:path";
490037
+ var setupGithubActions = (projectDir = process.cwd()) => {
490038
+ const workflowsDir = path25.join(projectDir, ".github", "workflows");
490039
+ fs25.mkdirSync(workflowsDir, { recursive: true });
490040
+ const buildWorkflow = `name: tscircuit Build
490041
+
490042
+ on:
490043
+ push:
490044
+ branches: [main]
490045
+ pull_request:
490046
+
490047
+ jobs:
490048
+ build:
490049
+ runs-on: ubuntu-latest
490050
+ steps:
490051
+ - uses: actions/checkout@v4
490052
+ - uses: oven-sh/setup-bun@v2
490053
+ - run: bun install
490054
+ - run: bunx tsci build
490055
+ `;
490056
+ const snapshotWorkflow = `name: tscircuit Snapshot
490057
+
490058
+ on:
490059
+ push:
490060
+ branches: [main]
490061
+
490062
+ jobs:
490063
+ snapshot:
490064
+ runs-on: ubuntu-latest
490065
+ steps:
490066
+ - uses: actions/checkout@v4
490067
+ - uses: oven-sh/setup-bun@v2
490068
+ - run: bun install
490069
+ - run: bunx tsci snapshot --update
490070
+ - name: Commit snapshots
490071
+ run: |
490072
+ git config --global user.name "github-actions[bot]"
490073
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
490074
+ git add .
490075
+ git commit -m "Update snapshots" || echo "No changes to commit"
490076
+ git push
490077
+ `;
490078
+ writeFileIfNotExists(path25.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
490079
+ writeFileIfNotExists(path25.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
490080
+ };
490081
+
490082
+ // cli/setup/register.ts
490083
+ var registerSetup = (program3) => {
490084
+ program3.command("setup").description("Setup utilities like GitHub Actions").action(async () => {
490085
+ const { option } = await prompts({
490086
+ type: "select",
490087
+ name: "option",
490088
+ message: "Select setup option",
490089
+ choices: [
490090
+ {
490091
+ title: "GitHub Action",
490092
+ value: "github-action",
490093
+ description: "Automatically build, check and commit snapshots to the main branch",
490094
+ selected: true
490095
+ }
490096
+ ]
490097
+ });
490098
+ if (option === "github-action") {
490099
+ setupGithubActions();
490100
+ }
490101
+ });
490102
+ };
490103
+
489983
490104
  // cli/main.ts
489984
490105
  var program2 = new Command;
489985
490106
  program2.name("tsci").description("CLI for developing tscircuit packages");
@@ -490000,6 +490121,7 @@ registerBuild(program2);
490000
490121
  registerAdd(program2);
490001
490122
  registerRemove(program2);
490002
490123
  registerSnapshot(program2);
490124
+ registerSetup(program2);
490003
490125
  registerUpgradeCommand(program2);
490004
490126
  registerSearch(program2);
490005
490127
  if (process.argv.includes("--version") || process.argv.includes("-v") || process.argv.includes("-V")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.121",
3
+ "version": "0.1.123",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",
@@ -40,6 +40,7 @@
40
40
  "semver": "^7.6.3",
41
41
  "tempy": "^3.1.0",
42
42
  "tscircuit": "^0.0.485",
43
+ "@tscircuit/circuit-json-util": "^0.0.47",
43
44
  "typed-ky": "^0.0.4"
44
45
  },
45
46
  "peerDependencies": {