@tscircuit/cli 0.1.602 → 0.1.603

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 +62 -28
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -72453,7 +72453,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
72453
72453
  import { execSync as execSync2 } from "node:child_process";
72454
72454
  var import_semver2 = __toESM2(require_semver2(), 1);
72455
72455
  // package.json
72456
- var version = "0.1.591";
72456
+ var version = "0.1.602";
72457
72457
  var package_default = {
72458
72458
  name: "@tscircuit/cli",
72459
72459
  version,
@@ -77442,10 +77442,8 @@ function resolveNodeModuleImport({
77442
77442
  return [];
77443
77443
  }
77444
77444
  const packageJsonPath = path20.join(packageDir, "package.json");
77445
- if (!fs19.existsSync(packageJsonPath)) {
77446
- return [];
77447
- }
77448
- const packageJson = JSON.parse(fs19.readFileSync(packageJsonPath, "utf-8"));
77445
+ const hasPackageJson = fs19.existsSync(packageJsonPath);
77446
+ const packageJson = hasPackageJson ? JSON.parse(fs19.readFileSync(packageJsonPath, "utf-8")) : null;
77449
77447
  const resolvedFiles = [];
77450
77448
  if (importPath !== packageName) {
77451
77449
  const subpath = importPath.slice(packageName.length + 1);
@@ -77467,6 +77465,9 @@ function resolveNodeModuleImport({
77467
77465
  }
77468
77466
  }
77469
77467
  }
77468
+ if (!hasPackageJson) {
77469
+ return resolvedFiles;
77470
+ }
77470
77471
  const resolveExportValue = (value) => {
77471
77472
  if (typeof value === "string")
77472
77473
  return value;
@@ -77701,24 +77702,36 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
77701
77702
  if (resolvedFiles.length > 0) {
77702
77703
  const firstResolvedFile = resolvedFiles[0];
77703
77704
  let packageDir = path20.dirname(firstResolvedFile);
77705
+ let hasPackageJson = false;
77704
77706
  while (packageDir.includes("node_modules")) {
77705
77707
  const packageJsonPath = path20.join(packageDir, "package.json");
77706
77708
  if (fs19.existsSync(packageJsonPath)) {
77707
77709
  try {
77708
77710
  const pkgJson = JSON.parse(fs19.readFileSync(packageJsonPath, "utf-8"));
77709
77711
  if (pkgJson.name === packageName) {
77712
+ hasPackageJson = true;
77710
77713
  break;
77711
77714
  }
77712
77715
  } catch {}
77713
77716
  }
77717
+ const expectedPackagePath = packageName.startsWith("@") ? `node_modules/${packageName}` : `node_modules/${packageName}`;
77718
+ if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g, path20.sep))) {
77719
+ break;
77720
+ }
77714
77721
  const parentDir = path20.dirname(packageDir);
77715
77722
  if (parentDir === packageDir)
77716
77723
  break;
77717
77724
  packageDir = parentDir;
77718
77725
  }
77719
77726
  if (fs19.existsSync(packageDir)) {
77720
- const packageFiles = collectLocalPackageFiles(packageDir);
77721
- packageFiles.forEach((file) => allFiles.add(file));
77727
+ if (hasPackageJson) {
77728
+ const packageFiles = collectLocalPackageFiles(packageDir);
77729
+ packageFiles.forEach((file) => allFiles.add(file));
77730
+ } else {
77731
+ for (const file of resolvedFiles) {
77732
+ allFiles.add(file);
77733
+ }
77734
+ }
77722
77735
  }
77723
77736
  }
77724
77737
  }
@@ -120741,7 +120754,7 @@ var require_condense_newlines = __commonJS2({
120741
120754
  var typeOf = require_kind_of();
120742
120755
  module2.exports = function(str, options) {
120743
120756
  var opts = extend2({}, options);
120744
- var sep2 = opts.sep || `
120757
+ var sep3 = opts.sep || `
120745
120758
 
120746
120759
  `;
120747
120760
  var min = opts.min;
@@ -120760,7 +120773,7 @@ var require_condense_newlines = __commonJS2({
120760
120773
  `);
120761
120774
  }
120762
120775
  str = trailingNewline(str, opts);
120763
- return str.replace(re2, sep2);
120776
+ return str.replace(re2, sep3);
120764
120777
  };
120765
120778
  function trailingNewline(str, options) {
120766
120779
  var val = options.trailingNewline;
@@ -172547,9 +172560,9 @@ var preprocessSelector = (selector) => {
172547
172560
  const netName = match ? match[1] : "";
172548
172561
  throw new Error(`Net name "${netName}" cannot start with a number, try using a prefix like "VBUS1"`);
172549
172562
  }
172550
- return selector.replace(/ pin(?=[\d.])/g, " port").replace(/ subcircuit\./g, " group[isSubcircuit=true]").replace(/([^ ])\>([^ ])/g, "$1 > $2").replace(/(^|[ >])(?!pin\.)(?!port\.)(?!net\.)([A-Z][A-Za-z0-9_-]*)\.([A-Za-z0-9_-]+)/g, (_, sep2, name, pin) => {
172563
+ return selector.replace(/ pin(?=[\d.])/g, " port").replace(/ subcircuit\./g, " group[isSubcircuit=true]").replace(/([^ ])\>([^ ])/g, "$1 > $2").replace(/(^|[ >])(?!pin\.)(?!port\.)(?!net\.)([A-Z][A-Za-z0-9_-]*)\.([A-Za-z0-9_-]+)/g, (_, sep3, name, pin) => {
172551
172564
  const pinPart = /^\d+$/.test(pin) ? `pin${pin}` : pin;
172552
- return `${sep2}.${name} > .${pinPart}`;
172565
+ return `${sep3}.${name} > .${pinPart}`;
172553
172566
  }).trim();
172554
172567
  };
172555
172568
  var cssSelectOptionsInsideSubcircuit = {
@@ -183076,17 +183089,20 @@ var findProjectRoot = (startDir) => {
183076
183089
  };
183077
183090
  async function getBuildEntrypoints({
183078
183091
  fileOrDir,
183079
- rootDir = process.cwd()
183092
+ rootDir = process.cwd(),
183093
+ includeBoardFiles = true
183080
183094
  }) {
183081
183095
  const resolvedRoot = path33.resolve(rootDir);
183082
- const includeBoardFiles = getBoardFilePatterns(resolvedRoot);
183096
+ const includeBoardFilePatterns = includeBoardFiles ? getBoardFilePatterns(resolvedRoot) : [];
183083
183097
  const buildFromProjectDir = async () => {
183084
- const files = findBoardFiles({ projectDir: resolvedRoot });
183085
- if (files.length > 0) {
183086
- return {
183087
- projectDir: resolvedRoot,
183088
- circuitFiles: files
183089
- };
183098
+ if (includeBoardFiles) {
183099
+ const files = findBoardFiles({ projectDir: resolvedRoot });
183100
+ if (files.length > 0) {
183101
+ return {
183102
+ projectDir: resolvedRoot,
183103
+ circuitFiles: files
183104
+ };
183105
+ }
183090
183106
  }
183091
183107
  const mainEntrypoint = await getEntrypoint({
183092
183108
  projectDir: resolvedRoot,
@@ -183112,16 +183128,33 @@ async function getBuildEntrypoints({
183112
183128
  if (fileOrDir) {
183113
183129
  const resolved = path33.resolve(resolvedRoot, fileOrDir);
183114
183130
  if (fs33.existsSync(resolved) && fs33.statSync(resolved).isDirectory()) {
183115
- const circuitFiles = findBoardFiles({
183116
- projectDir: resolvedRoot,
183117
- filePaths: [resolved]
183118
- }).filter((file) => isSubPath2(file, resolved));
183119
- if (circuitFiles.length === 0) {
183120
- throw new Error(`There were no files to build found matching the includeBoardFiles globs: ${JSON.stringify(includeBoardFiles)}`);
183131
+ if (includeBoardFiles) {
183132
+ const circuitFiles = findBoardFiles({
183133
+ projectDir: resolvedRoot,
183134
+ filePaths: [resolved]
183135
+ }).filter((file) => isSubPath2(file, resolved));
183136
+ if (circuitFiles.length === 0) {
183137
+ throw new Error(`There were no files to build found matching the includeBoardFiles globs: ${JSON.stringify(includeBoardFilePatterns)}`);
183138
+ }
183139
+ return {
183140
+ projectDir: resolvedRoot,
183141
+ circuitFiles
183142
+ };
183121
183143
  }
183144
+ const projectDir2 = findProjectRoot(resolved);
183145
+ const mainEntrypoint = await getEntrypoint({
183146
+ projectDir: projectDir2,
183147
+ onSuccess: () => {
183148
+ return;
183149
+ },
183150
+ onError: () => {
183151
+ return;
183152
+ }
183153
+ });
183122
183154
  return {
183123
- projectDir: resolvedRoot,
183124
- circuitFiles
183155
+ projectDir: projectDir2,
183156
+ mainEntrypoint: mainEntrypoint || undefined,
183157
+ circuitFiles: mainEntrypoint ? [mainEntrypoint] : []
183125
183158
  };
183126
183159
  }
183127
183160
  const fileDir = path33.dirname(resolved);
@@ -184544,7 +184577,8 @@ var registerTranspile = (program3) => {
184544
184577
  program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
184545
184578
  try {
184546
184579
  const { projectDir, circuitFiles, mainEntrypoint } = await getBuildEntrypoints({
184547
- fileOrDir: file
184580
+ fileOrDir: file,
184581
+ includeBoardFiles: false
184548
184582
  });
184549
184583
  const distDir = path46.join(projectDir, "dist");
184550
184584
  validateMainInDist(projectDir, distDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.602",
3
+ "version": "0.1.603",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",