@tscircuit/cli 0.1.117 → 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.
package/README.md CHANGED
@@ -50,7 +50,7 @@ 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
+ build [options] [file] Run tscircuit eval and output circuit json
54
54
  add <component> Add a tscircuit component package to your project
55
55
  remove <component> Remove a tscircuit component package from your
56
56
  project
@@ -62,6 +62,11 @@ Commands:
62
62
  ```
63
63
  <!-- END_HELP_OUTPUT -->
64
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
+
65
70
  ## Development
66
71
 
67
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.116";
437166
+ var version = "0.1.117";
437167
437167
  var package_default = {
437168
437168
  name: "@tscircuit/cli",
437169
437169
  version,
@@ -486314,8 +486314,32 @@ var registerRemove = (program3) => {
486314
486314
  // cli/build/register.ts
486315
486315
  import path23 from "node:path";
486316
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
486317
486341
  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) => {
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) => {
486319
486343
  const entrypoint = await getEntrypoint({ filePath: file });
486320
486344
  if (!entrypoint)
486321
486345
  return process.exit(1);
@@ -486327,6 +486351,22 @@ var registerBuild = (program3) => {
486327
486351
  const result = await generateCircuitJson({ filePath: entrypoint });
486328
486352
  fs23.writeFileSync(outputPath, JSON.stringify(result.circuitJson, null, 2));
486329
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
+ }
486330
486370
  } catch (err) {
486331
486371
  console.error(`Build failed: ${err}`);
486332
486372
  return process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.117",
3
+ "version": "0.1.118",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",