@tscircuit/cli 0.1.116 → 0.1.118

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 +7 -0
  2. package/dist/main.js +77 -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 [options] [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
@@ -60,6 +62,11 @@ Commands:
60
62
  ```
61
63
  <!-- END_HELP_OUTPUT -->
62
64
 
65
+ The `build` command also accepts the following options:
66
+
67
+ - `--ignore-errors` - continue build even if circuit JSON contains errors
68
+ - `--ignore-warnings` - suppress warning output
69
+
63
70
  ## Development
64
71
 
65
72
  This command will open the `index.tsx` file for editing.
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.117";
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,72 @@ 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
+
486318
+ // lib/shared/circuit-json-diagnostics.ts
486319
+ function analyzeCircuitJson(circuitJson) {
486320
+ const errors = [];
486321
+ const warnings = [];
486322
+ for (const item of circuitJson) {
486323
+ if (!item || typeof item !== "object")
486324
+ continue;
486325
+ const t2 = item.type;
486326
+ if (typeof t2 === "string") {
486327
+ if (t2.endsWith("_error"))
486328
+ errors.push(item);
486329
+ else if (t2.endsWith("_warning"))
486330
+ warnings.push(item);
486331
+ }
486332
+ if ("error_type" in item)
486333
+ errors.push(item);
486334
+ if ("warning_type" in item)
486335
+ warnings.push(item);
486336
+ }
486337
+ return { errors, warnings };
486338
+ }
486339
+
486340
+ // cli/build/register.ts
486341
+ var registerBuild = (program3) => {
486342
+ program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").action(async (file, options) => {
486343
+ const entrypoint = await getEntrypoint({ filePath: file });
486344
+ if (!entrypoint)
486345
+ return process.exit(1);
486346
+ const projectDir = path23.dirname(entrypoint);
486347
+ const distDir = path23.join(projectDir, "dist");
486348
+ const outputPath = path23.join(distDir, "circuit.json");
486349
+ fs23.mkdirSync(distDir, { recursive: true });
486350
+ try {
486351
+ const result = await generateCircuitJson({ filePath: entrypoint });
486352
+ fs23.writeFileSync(outputPath, JSON.stringify(result.circuitJson, null, 2));
486353
+ console.log(`Circuit JSON written to ${path23.relative(projectDir, outputPath)}`);
486354
+ const { errors, warnings } = analyzeCircuitJson(result.circuitJson);
486355
+ if (!options?.ignoreWarnings) {
486356
+ for (const warn of warnings) {
486357
+ const msg = warn.message || JSON.stringify(warn);
486358
+ console.log(kleur_default.yellow(msg));
486359
+ }
486360
+ }
486361
+ if (!options?.ignoreErrors) {
486362
+ for (const err of errors) {
486363
+ const msg = err.message || JSON.stringify(err);
486364
+ console.error(kleur_default.red(msg));
486365
+ }
486366
+ }
486367
+ if (errors.length > 0 && !options?.ignoreErrors) {
486368
+ return process.exit(1);
486369
+ }
486370
+ } catch (err) {
486371
+ console.error(`Build failed: ${err}`);
486372
+ return process.exit(1);
486373
+ }
486374
+ });
486375
+ };
486376
+
486377
+ // lib/shared/snapshot-project.ts
486378
+ import fs24 from "node:fs";
486379
+ import path24 from "node:path";
486316
486380
  init_dist4();
486317
486381
  var snapshotProject = async ({
486318
486382
  update = false,
@@ -486327,7 +486391,7 @@ var snapshotProject = async ({
486327
486391
  ...ignored.map(normalizeIgnorePattern)
486328
486392
  ];
486329
486393
  const boardFiles = globbySync("**/*.board.tsx", { cwd: projectDir, ignore });
486330
- let files = boardFiles.map((f) => path23.join(projectDir, f));
486394
+ let files = boardFiles.map((f) => path24.join(projectDir, f));
486331
486395
  if (files.length === 0) {
486332
486396
  const entry = await getEntrypoint({
486333
486397
  projectDir,
@@ -486343,18 +486407,18 @@ var snapshotProject = async ({
486343
486407
  const { circuitJson } = await generateCircuitJson({ filePath: file });
486344
486408
  const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson);
486345
486409
  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$/, "");
486410
+ const snapDir = path24.join(path24.dirname(file), "__snapshots__");
486411
+ fs24.mkdirSync(snapDir, { recursive: true });
486412
+ const base = path24.basename(file).replace(/\.tsx$/, "");
486349
486413
  for (const [type, svg] of [
486350
486414
  ["pcb", pcbSvg],
486351
486415
  ["schematic", schSvg]
486352
486416
  ]) {
486353
- const snapPath = path23.join(snapDir, `${base}-${type}.snap.svg`);
486354
- if (update || !fs23.existsSync(snapPath)) {
486355
- fs23.writeFileSync(snapPath, svg);
486417
+ const snapPath = path24.join(snapDir, `${base}-${type}.snap.svg`);
486418
+ if (update || !fs24.existsSync(snapPath)) {
486419
+ fs24.writeFileSync(snapPath, svg);
486356
486420
  } else {
486357
- const existing = fs23.readFileSync(snapPath, "utf-8");
486421
+ const existing = fs24.readFileSync(snapPath, "utf-8");
486358
486422
  if (existing !== svg)
486359
486423
  mismatches.push(snapPath);
486360
486424
  }
@@ -486402,6 +486466,7 @@ registerConfig(program2);
486402
486466
  registerConfigPrint(program2);
486403
486467
  registerConfigSet(program2);
486404
486468
  registerExport(program2);
486469
+ registerBuild(program2);
486405
486470
  registerAdd(program2);
486406
486471
  registerRemove(program2);
486407
486472
  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.118",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",