@tscircuit/cli 0.1.761 → 0.1.762

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/dist/main.js CHANGED
@@ -73242,6 +73242,7 @@ import { z } from "zod";
73242
73242
  var projectConfigSchema = z.object({
73243
73243
  mainEntrypoint: z.string().optional(),
73244
73244
  previewComponentPath: z.string().optional(),
73245
+ siteDefaultComponentPath: z.string().optional(),
73245
73246
  ignoredFiles: z.array(z.string()).optional(),
73246
73247
  includeBoardFiles: z.array(z.string()).optional(),
73247
73248
  snapshotsDir: z.string().optional(),
@@ -74126,7 +74127,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
74126
74127
  import { execSync as execSync2 } from "node:child_process";
74127
74128
  var import_semver2 = __toESM2(require_semver2(), 1);
74128
74129
  // package.json
74129
- var version = "0.1.760";
74130
+ var version = "0.1.761";
74130
74131
  var package_default = {
74131
74132
  name: "@tscircuit/cli",
74132
74133
  version,
@@ -85169,12 +85170,13 @@ var availableGlobalConfigKeys = [
85169
85170
  var availableProjectConfigKeys = [
85170
85171
  "mainEntrypoint",
85171
85172
  "previewComponentPath",
85173
+ "siteDefaultComponentPath",
85172
85174
  "prebuildCommand",
85173
85175
  "buildCommand"
85174
85176
  ];
85175
85177
  var registerConfigSet = (program3) => {
85176
85178
  const configCommand = program3.commands.find((c) => c.name() === "config");
85177
- configCommand.command("set").description("Set a configuration value (global or project-specific)").argument("<key>", "Configuration key (e.g., alwaysCloneWithAuthorName, mainEntrypoint, previewComponentPath, prebuildCommand, buildCommand)").argument("<value>", "Value to set").action((key, value) => {
85179
+ configCommand.command("set").description("Set a configuration value (global or project-specific)").argument("<key>", "Configuration key (e.g., alwaysCloneWithAuthorName, mainEntrypoint, previewComponentPath, siteDefaultComponentPath, prebuildCommand, buildCommand)").argument("<value>", "Value to set").action((key, value) => {
85178
85180
  if (availableGlobalConfigKeys.some((k) => k === key)) {
85179
85181
  if (key === "alwaysCloneWithAuthorName") {
85180
85182
  const booleanValue = value.toLowerCase() === "true";
@@ -85183,7 +85185,7 @@ var registerConfigSet = (program3) => {
85183
85185
  }
85184
85186
  } else if (availableProjectConfigKeys.some((k) => k === key)) {
85185
85187
  const projectDir = process.cwd();
85186
- if (key === "mainEntrypoint" || key === "previewComponentPath" || key === "prebuildCommand" || key === "buildCommand") {
85188
+ if (key === "mainEntrypoint" || key === "previewComponentPath" || key === "siteDefaultComponentPath" || key === "prebuildCommand" || key === "buildCommand") {
85187
85189
  const projectConfig = loadProjectConfig(projectDir) ?? {};
85188
85190
  projectConfig[key] = value;
85189
85191
  if (saveProjectConfig(projectConfig, projectDir)) {
@@ -172742,12 +172744,14 @@ async function getBuildEntrypoints({
172742
172744
  const buildFromProjectDir = async () => {
172743
172745
  const projectConfig2 = loadProjectConfig(resolvedRoot);
172744
172746
  const resolvedPreviewComponentPath = projectConfig2?.previewComponentPath ? path38.resolve(resolvedRoot, projectConfig2.previewComponentPath) : undefined;
172747
+ const resolvedSiteDefaultComponentPath = projectConfig2?.siteDefaultComponentPath ? path38.resolve(resolvedRoot, projectConfig2.siteDefaultComponentPath) : undefined;
172745
172748
  if (includeBoardFiles) {
172746
172749
  const files = findBoardFiles({ projectDir: resolvedRoot });
172747
172750
  if (files.length > 0) {
172748
172751
  return {
172749
172752
  projectDir: resolvedRoot,
172750
172753
  previewComponentPath: resolvedPreviewComponentPath,
172754
+ siteDefaultComponentPath: resolvedSiteDefaultComponentPath,
172751
172755
  circuitFiles: files
172752
172756
  };
172753
172757
  }
@@ -172766,12 +172770,14 @@ async function getBuildEntrypoints({
172766
172770
  projectDir: resolvedRoot,
172767
172771
  mainEntrypoint,
172768
172772
  previewComponentPath: resolvedPreviewComponentPath,
172773
+ siteDefaultComponentPath: resolvedSiteDefaultComponentPath,
172769
172774
  circuitFiles: [mainEntrypoint]
172770
172775
  };
172771
172776
  }
172772
172777
  return {
172773
172778
  projectDir: resolvedRoot,
172774
172779
  previewComponentPath: resolvedPreviewComponentPath,
172780
+ siteDefaultComponentPath: resolvedSiteDefaultComponentPath,
172775
172781
  circuitFiles: []
172776
172782
  };
172777
172783
  };
@@ -172780,6 +172786,7 @@ async function getBuildEntrypoints({
172780
172786
  if (fs38.existsSync(resolved) && fs38.statSync(resolved).isDirectory()) {
172781
172787
  const projectConfig3 = loadProjectConfig(resolvedRoot);
172782
172788
  const resolvedPreviewComponentPath2 = projectConfig3?.previewComponentPath ? path38.resolve(resolvedRoot, projectConfig3.previewComponentPath) : undefined;
172789
+ const resolvedSiteDefaultComponentPath2 = projectConfig3?.siteDefaultComponentPath ? path38.resolve(resolvedRoot, projectConfig3.siteDefaultComponentPath) : undefined;
172783
172790
  if (includeBoardFiles) {
172784
172791
  const circuitFiles = findBoardFiles({
172785
172792
  projectDir: resolvedRoot,
@@ -172791,6 +172798,7 @@ async function getBuildEntrypoints({
172791
172798
  return {
172792
172799
  projectDir: resolvedRoot,
172793
172800
  previewComponentPath: resolvedPreviewComponentPath2,
172801
+ siteDefaultComponentPath: resolvedSiteDefaultComponentPath2,
172794
172802
  circuitFiles
172795
172803
  };
172796
172804
  }
@@ -172808,6 +172816,7 @@ async function getBuildEntrypoints({
172808
172816
  projectDir: projectDir2,
172809
172817
  mainEntrypoint: mainEntrypoint || undefined,
172810
172818
  previewComponentPath: resolvedPreviewComponentPath2,
172819
+ siteDefaultComponentPath: resolvedSiteDefaultComponentPath2,
172811
172820
  circuitFiles: mainEntrypoint ? [mainEntrypoint] : []
172812
172821
  };
172813
172822
  }
@@ -172815,9 +172824,11 @@ async function getBuildEntrypoints({
172815
172824
  const projectDir = findProjectRoot(fileDir);
172816
172825
  const projectConfig2 = loadProjectConfig(projectDir);
172817
172826
  const resolvedPreviewComponentPath = projectConfig2?.previewComponentPath ? path38.resolve(projectDir, projectConfig2.previewComponentPath) : undefined;
172827
+ const resolvedSiteDefaultComponentPath = projectConfig2?.siteDefaultComponentPath ? path38.resolve(projectDir, projectConfig2.siteDefaultComponentPath) : undefined;
172818
172828
  return {
172819
172829
  projectDir,
172820
172830
  previewComponentPath: resolvedPreviewComponentPath,
172831
+ siteDefaultComponentPath: resolvedSiteDefaultComponentPath,
172821
172832
  circuitFiles: [resolved]
172822
172833
  };
172823
172834
  }
@@ -172827,11 +172838,15 @@ async function getBuildEntrypoints({
172827
172838
  // lib/site/getStaticIndexHtmlFile.ts
172828
172839
  var getStaticIndexHtmlFile = ({
172829
172840
  files,
172830
- standaloneScriptSrc = "./standalone.min.js"
172841
+ standaloneScriptSrc = "./standalone.min.js",
172842
+ defaultMainComponentPath
172831
172843
  }) => {
172832
172844
  const scriptLines = [
172833
172845
  "window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI = false;",
172834
- `window.TSCIRCUIT_RUNFRAME_STATIC_FILE_LIST = ${JSON.stringify(files)};`
172846
+ `window.TSCIRCUIT_RUNFRAME_STATIC_FILE_LIST = ${JSON.stringify(files)};`,
172847
+ ...defaultMainComponentPath ? [
172848
+ `window.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH = ${JSON.stringify(defaultMainComponentPath)};`
172849
+ ] : []
172835
172850
  ];
172836
172851
  const scriptBlock = ` <script>
172837
172852
  ${scriptLines.join(`
@@ -173467,6 +173482,7 @@ async function getLatestTscircuitCdnUrl() {
173467
173482
  }
173468
173483
 
173469
173484
  // cli/build/register.ts
173485
+ var normalizeRelativePath = (projectDir, targetPath) => path45.relative(projectDir, targetPath).split(path45.sep).join("/");
173470
173486
  var registerBuild = (program3) => {
173471
173487
  program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ci", "Run install and optional prebuild/build commands (or default CI build)").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("--preview-gltf", "Generate a GLTF file from the preview entrypoint").option("--use-cdn-javascript", "Use CDN-hosted JavaScript instead of bundled standalone file for --site").action(async (file, options) => {
173472
173488
  try {
@@ -173474,7 +173490,8 @@ var registerBuild = (program3) => {
173474
173490
  projectDir,
173475
173491
  circuitFiles,
173476
173492
  mainEntrypoint,
173477
- previewComponentPath
173493
+ previewComponentPath,
173494
+ siteDefaultComponentPath
173478
173495
  } = await getBuildEntrypoints({
173479
173496
  fileOrDir: file
173480
173497
  });
@@ -173601,7 +173618,8 @@ var registerBuild = (program3) => {
173601
173618
  }
173602
173619
  const indexHtml = getStaticIndexHtmlFile({
173603
173620
  files: staticFileReferences,
173604
- standaloneScriptSrc
173621
+ standaloneScriptSrc,
173622
+ defaultMainComponentPath: siteDefaultComponentPath ? normalizeRelativePath(projectDir, siteDefaultComponentPath) : undefined
173605
173623
  });
173606
173624
  fs45.writeFileSync(path45.join(distDir, "index.html"), indexHtml);
173607
173625
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.761",
3
+ "version": "0.1.762",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",
@@ -18,6 +18,10 @@
18
18
  "type": "string",
19
19
  "description": "Optional component path used for previews."
20
20
  },
21
+ "siteDefaultComponentPath": {
22
+ "type": "string",
23
+ "description": "Default component path to show in generated static sites."
24
+ },
21
25
  "ignoredFiles": {
22
26
  "type": "array",
23
27
  "items": {