@tscircuit/cli 0.1.116 → 0.1.117

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 +2 -0
  2. package/dist/main.js +37 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -50,9 +50,11 @@ Commands:
50
50
  logout Logout from tscircuit registry
51
51
  config Manage tscircuit CLI configuration
52
52
  export [options] <file> Export tscircuit code to various formats
53
+ build [file] Run tscircuit eval and output circuit json
53
54
  add <component> Add a tscircuit component package to your project
54
55
  remove <component> Remove a tscircuit component package from your
55
56
  project
57
+ snapshot [options] Generate schematic and PCB snapshots
56
58
  upgrade Upgrade CLI to the latest version
57
59
  search <query> Search for packages in the tscircuit registry
58
60
  version Print CLI version
package/dist/main.js CHANGED
@@ -437163,7 +437163,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
437163
437163
  import { execSync as execSync2 } from "node:child_process";
437164
437164
  var import_semver = __toESM2(require_semver2(), 1);
437165
437165
  // package.json
437166
- var version = "0.1.115";
437166
+ var version = "0.1.116";
437167
437167
  var package_default = {
437168
437168
  name: "@tscircuit/cli",
437169
437169
  version,
@@ -486040,7 +486040,8 @@ async function generateCircuitJson({
486040
486040
  })
486041
486041
  };
486042
486042
  await runner.executeWithFsMap({
486043
- fsMap
486043
+ fsMap,
486044
+ mainComponentPath: relativeComponentPath
486044
486045
  });
486045
486046
  await runner.renderUntilSettled();
486046
486047
  const circuitJson = await runner.getCircuitJson();
@@ -486310,9 +486311,32 @@ var registerRemove = (program3) => {
486310
486311
  });
486311
486312
  };
486312
486313
 
486313
- // lib/shared/snapshot-project.ts
486314
- import fs23 from "node:fs";
486314
+ // cli/build/register.ts
486315
486315
  import path23 from "node:path";
486316
+ import fs23 from "node:fs";
486317
+ var registerBuild = (program3) => {
486318
+ program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").action(async (file) => {
486319
+ const entrypoint = await getEntrypoint({ filePath: file });
486320
+ if (!entrypoint)
486321
+ return process.exit(1);
486322
+ const projectDir = path23.dirname(entrypoint);
486323
+ const distDir = path23.join(projectDir, "dist");
486324
+ const outputPath = path23.join(distDir, "circuit.json");
486325
+ fs23.mkdirSync(distDir, { recursive: true });
486326
+ try {
486327
+ const result = await generateCircuitJson({ filePath: entrypoint });
486328
+ fs23.writeFileSync(outputPath, JSON.stringify(result.circuitJson, null, 2));
486329
+ console.log(`Circuit JSON written to ${path23.relative(projectDir, outputPath)}`);
486330
+ } catch (err) {
486331
+ console.error(`Build failed: ${err}`);
486332
+ return process.exit(1);
486333
+ }
486334
+ });
486335
+ };
486336
+
486337
+ // lib/shared/snapshot-project.ts
486338
+ import fs24 from "node:fs";
486339
+ import path24 from "node:path";
486316
486340
  init_dist4();
486317
486341
  var snapshotProject = async ({
486318
486342
  update = false,
@@ -486327,7 +486351,7 @@ var snapshotProject = async ({
486327
486351
  ...ignored.map(normalizeIgnorePattern)
486328
486352
  ];
486329
486353
  const boardFiles = globbySync("**/*.board.tsx", { cwd: projectDir, ignore });
486330
- let files = boardFiles.map((f) => path23.join(projectDir, f));
486354
+ let files = boardFiles.map((f) => path24.join(projectDir, f));
486331
486355
  if (files.length === 0) {
486332
486356
  const entry = await getEntrypoint({
486333
486357
  projectDir,
@@ -486343,18 +486367,18 @@ var snapshotProject = async ({
486343
486367
  const { circuitJson } = await generateCircuitJson({ filePath: file });
486344
486368
  const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson);
486345
486369
  const schSvg = convertCircuitJsonToSchematicSvg(circuitJson);
486346
- const snapDir = path23.join(path23.dirname(file), "__snapshots__");
486347
- fs23.mkdirSync(snapDir, { recursive: true });
486348
- const base = path23.basename(file).replace(/\.tsx$/, "");
486370
+ const snapDir = path24.join(path24.dirname(file), "__snapshots__");
486371
+ fs24.mkdirSync(snapDir, { recursive: true });
486372
+ const base = path24.basename(file).replace(/\.tsx$/, "");
486349
486373
  for (const [type, svg] of [
486350
486374
  ["pcb", pcbSvg],
486351
486375
  ["schematic", schSvg]
486352
486376
  ]) {
486353
- const snapPath = path23.join(snapDir, `${base}-${type}.snap.svg`);
486354
- if (update || !fs23.existsSync(snapPath)) {
486355
- fs23.writeFileSync(snapPath, svg);
486377
+ const snapPath = path24.join(snapDir, `${base}-${type}.snap.svg`);
486378
+ if (update || !fs24.existsSync(snapPath)) {
486379
+ fs24.writeFileSync(snapPath, svg);
486356
486380
  } else {
486357
- const existing = fs23.readFileSync(snapPath, "utf-8");
486381
+ const existing = fs24.readFileSync(snapPath, "utf-8");
486358
486382
  if (existing !== svg)
486359
486383
  mismatches.push(snapPath);
486360
486384
  }
@@ -486402,6 +486426,7 @@ registerConfig(program2);
486402
486426
  registerConfigPrint(program2);
486403
486427
  registerConfigSet(program2);
486404
486428
  registerExport(program2);
486429
+ registerBuild(program2);
486405
486430
  registerAdd(program2);
486406
486431
  registerRemove(program2);
486407
486432
  registerSnapshot(program2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.116",
3
+ "version": "0.1.117",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",