@tscircuit/cli 0.1.662 → 0.1.663

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 (2) hide show
  1. package/dist/main.js +35 -10
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -73243,6 +73243,7 @@ import * as path9 from "node:path";
73243
73243
  import { z } from "zod";
73244
73244
  var projectConfigSchema = z.object({
73245
73245
  mainEntrypoint: z.string().optional(),
73246
+ previewComponentPath: z.string().optional(),
73246
73247
  ignoredFiles: z.array(z.string()).optional(),
73247
73248
  includeBoardFiles: z.array(z.string()).optional(),
73248
73249
  snapshotsDir: z.string().optional()
@@ -74112,7 +74113,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
74112
74113
  import { execSync as execSync2 } from "node:child_process";
74113
74114
  var import_semver2 = __toESM2(require_semver2(), 1);
74114
74115
  // package.json
74115
- var version = "0.1.661";
74116
+ var version = "0.1.662";
74116
74117
  var package_default = {
74117
74118
  name: "@tscircuit/cli",
74118
74119
  version,
@@ -84497,11 +84498,12 @@ var availableGlobalConfigKeys = [
84497
84498
  "alwaysCloneWithAuthorName"
84498
84499
  ];
84499
84500
  var availableProjectConfigKeys = [
84500
- "mainEntrypoint"
84501
+ "mainEntrypoint",
84502
+ "previewComponentPath"
84501
84503
  ];
84502
84504
  var registerConfigSet = (program3) => {
84503
84505
  const configCommand = program3.commands.find((c) => c.name() === "config");
84504
- configCommand.command("set").description("Set a configuration value (global or project-specific)").argument("<key>", "Configuration key (e.g., alwaysCloneWithAuthorName, mainEntrypoint)").argument("<value>", "Value to set").action((key, value) => {
84506
+ configCommand.command("set").description("Set a configuration value (global or project-specific)").argument("<key>", "Configuration key (e.g., alwaysCloneWithAuthorName, mainEntrypoint, previewComponentPath)").argument("<value>", "Value to set").action((key, value) => {
84505
84507
  if (availableGlobalConfigKeys.some((k) => k === key)) {
84506
84508
  if (key === "alwaysCloneWithAuthorName") {
84507
84509
  const booleanValue = value.toLowerCase() === "true";
@@ -84510,9 +84512,9 @@ var registerConfigSet = (program3) => {
84510
84512
  }
84511
84513
  } else if (availableProjectConfigKeys.some((k) => k === key)) {
84512
84514
  const projectDir = process.cwd();
84513
- if (key === "mainEntrypoint") {
84515
+ if (key === "mainEntrypoint" || key === "previewComponentPath") {
84514
84516
  const projectConfig = loadProjectConfig(projectDir) ?? {};
84515
- projectConfig.mainEntrypoint = value;
84517
+ projectConfig[key] = value;
84516
84518
  if (saveProjectConfig(projectConfig, projectDir)) {
84517
84519
  console.log(kleur_default.cyan(`Set project config ${kleur_default.yellow(key)} to ${kleur_default.yellow(value)} successfully in ${kleur_default.bold(CONFIG_FILENAME)}.`));
84518
84520
  } else {
@@ -187117,11 +187119,14 @@ async function getBuildEntrypoints({
187117
187119
  const resolvedRoot = path35.resolve(rootDir);
187118
187120
  const includeBoardFilePatterns = includeBoardFiles ? getBoardFilePatterns(resolvedRoot) : [];
187119
187121
  const buildFromProjectDir = async () => {
187122
+ const projectConfig = loadProjectConfig(resolvedRoot);
187123
+ const resolvedPreviewComponentPath = projectConfig?.previewComponentPath ? path35.resolve(resolvedRoot, projectConfig.previewComponentPath) : undefined;
187120
187124
  if (includeBoardFiles) {
187121
187125
  const files = findBoardFiles({ projectDir: resolvedRoot });
187122
187126
  if (files.length > 0) {
187123
187127
  return {
187124
187128
  projectDir: resolvedRoot,
187129
+ previewComponentPath: resolvedPreviewComponentPath,
187125
187130
  circuitFiles: files
187126
187131
  };
187127
187132
  }
@@ -187139,17 +187144,21 @@ async function getBuildEntrypoints({
187139
187144
  return {
187140
187145
  projectDir: resolvedRoot,
187141
187146
  mainEntrypoint,
187147
+ previewComponentPath: resolvedPreviewComponentPath,
187142
187148
  circuitFiles: [mainEntrypoint]
187143
187149
  };
187144
187150
  }
187145
187151
  return {
187146
187152
  projectDir: resolvedRoot,
187153
+ previewComponentPath: resolvedPreviewComponentPath,
187147
187154
  circuitFiles: []
187148
187155
  };
187149
187156
  };
187150
187157
  if (fileOrDir) {
187151
187158
  const resolved = path35.resolve(resolvedRoot, fileOrDir);
187152
187159
  if (fs34.existsSync(resolved) && fs34.statSync(resolved).isDirectory()) {
187160
+ const projectConfig2 = loadProjectConfig(resolvedRoot);
187161
+ const resolvedPreviewComponentPath2 = projectConfig2?.previewComponentPath ? path35.resolve(resolvedRoot, projectConfig2.previewComponentPath) : undefined;
187153
187162
  if (includeBoardFiles) {
187154
187163
  const circuitFiles = findBoardFiles({
187155
187164
  projectDir: resolvedRoot,
@@ -187160,6 +187169,7 @@ async function getBuildEntrypoints({
187160
187169
  }
187161
187170
  return {
187162
187171
  projectDir: resolvedRoot,
187172
+ previewComponentPath: resolvedPreviewComponentPath2,
187163
187173
  circuitFiles
187164
187174
  };
187165
187175
  }
@@ -187176,12 +187186,19 @@ async function getBuildEntrypoints({
187176
187186
  return {
187177
187187
  projectDir: projectDir2,
187178
187188
  mainEntrypoint: mainEntrypoint || undefined,
187189
+ previewComponentPath: resolvedPreviewComponentPath2,
187179
187190
  circuitFiles: mainEntrypoint ? [mainEntrypoint] : []
187180
187191
  };
187181
187192
  }
187182
187193
  const fileDir = path35.dirname(resolved);
187183
187194
  const projectDir = findProjectRoot(fileDir);
187184
- return { projectDir, circuitFiles: [resolved] };
187195
+ const projectConfig = loadProjectConfig(projectDir);
187196
+ const resolvedPreviewComponentPath = projectConfig?.previewComponentPath ? path35.resolve(projectDir, projectConfig.previewComponentPath) : undefined;
187197
+ return {
187198
+ projectDir,
187199
+ previewComponentPath: resolvedPreviewComponentPath,
187200
+ circuitFiles: [resolved]
187201
+ };
187185
187202
  }
187186
187203
  return buildFromProjectDir();
187187
187204
  }
@@ -187339,10 +187356,12 @@ var buildPreviewImages = async ({
187339
187356
  builtFiles,
187340
187357
  distDir,
187341
187358
  mainEntrypoint,
187359
+ previewComponentPath,
187342
187360
  allImages
187343
187361
  }) => {
187344
187362
  const successfulBuilds = builtFiles.filter((file) => file.ok);
187345
- const normalizedMainEntrypoint = mainEntrypoint ? path36.resolve(mainEntrypoint) : undefined;
187363
+ const previewEntrypoint = previewComponentPath || mainEntrypoint;
187364
+ const resolvedPreviewEntrypoint = previewEntrypoint ? path36.resolve(previewEntrypoint) : undefined;
187346
187365
  if (allImages) {
187347
187366
  if (successfulBuilds.length === 0) {
187348
187367
  console.warn("No successful build output available for preview image generation.");
@@ -187359,8 +187378,8 @@ var buildPreviewImages = async ({
187359
187378
  return;
187360
187379
  }
187361
187380
  const previewBuild = (() => {
187362
- if (normalizedMainEntrypoint) {
187363
- const match = successfulBuilds.find((built) => path36.resolve(built.sourcePath) === normalizedMainEntrypoint);
187381
+ if (resolvedPreviewEntrypoint) {
187382
+ const match = successfulBuilds.find((built) => path36.resolve(built.sourcePath) === resolvedPreviewEntrypoint);
187364
187383
  if (match)
187365
187384
  return match;
187366
187385
  }
@@ -187759,7 +187778,12 @@ var validateMainInDist = (projectDir, distDir) => {
187759
187778
  var registerBuild = (program3) => {
187760
187779
  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").option("--disable-pcb", "Disable PCB outputs").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").option("--transpile", "Transpile the entry file to JavaScript").option("--preview-images", "Generate preview images in the dist directory").option("--all-images", "Generate preview images for every successful build output").option("--kicad", "Generate KiCad project directories for each successful build output").option("--kicad-footprint-library", "Generate a KiCad footprint library from all successful build outputs").action(async (file, options) => {
187761
187780
  try {
187762
- const { projectDir, circuitFiles, mainEntrypoint } = await getBuildEntrypoints({
187781
+ const {
187782
+ projectDir,
187783
+ circuitFiles,
187784
+ mainEntrypoint,
187785
+ previewComponentPath
187786
+ } = await getBuildEntrypoints({
187763
187787
  fileOrDir: file
187764
187788
  });
187765
187789
  const platformConfig2 = (() => {
@@ -187833,6 +187857,7 @@ var registerBuild = (program3) => {
187833
187857
  builtFiles,
187834
187858
  distDir,
187835
187859
  mainEntrypoint,
187860
+ previewComponentPath,
187836
187861
  allImages: options?.allImages
187837
187862
  });
187838
187863
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.662",
3
+ "version": "0.1.663",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",