@tscircuit/cli 0.1.602 → 0.1.604
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 +64 -29
- 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.
|
|
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
|
-
|
|
77446
|
-
|
|
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
|
-
|
|
77721
|
-
|
|
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
|
}
|
|
@@ -83090,7 +83103,8 @@ var registerSearch = (program3) => {
|
|
|
83090
83103
|
console.log(kleur_default.bold().underline(`Found ${results.packages.length} package(s) in the tscircuit registry:`));
|
|
83091
83104
|
results.packages.forEach((pkg, idx) => {
|
|
83092
83105
|
const star = pkg.star_count ?? 0;
|
|
83093
|
-
|
|
83106
|
+
const versionStr = pkg.version ? ` (v${pkg.version})` : "";
|
|
83107
|
+
console.log(`${idx + 1}. ${pkg.name}${versionStr} - Stars: ${star}${pkg.description ? ` - ${pkg.description}` : ""}`);
|
|
83094
83108
|
});
|
|
83095
83109
|
}
|
|
83096
83110
|
if (!onlyKicad && jlcResults.length) {
|
|
@@ -120741,7 +120755,7 @@ var require_condense_newlines = __commonJS2({
|
|
|
120741
120755
|
var typeOf = require_kind_of();
|
|
120742
120756
|
module2.exports = function(str, options) {
|
|
120743
120757
|
var opts = extend2({}, options);
|
|
120744
|
-
var
|
|
120758
|
+
var sep3 = opts.sep || `
|
|
120745
120759
|
|
|
120746
120760
|
`;
|
|
120747
120761
|
var min = opts.min;
|
|
@@ -120760,7 +120774,7 @@ var require_condense_newlines = __commonJS2({
|
|
|
120760
120774
|
`);
|
|
120761
120775
|
}
|
|
120762
120776
|
str = trailingNewline(str, opts);
|
|
120763
|
-
return str.replace(re2,
|
|
120777
|
+
return str.replace(re2, sep3);
|
|
120764
120778
|
};
|
|
120765
120779
|
function trailingNewline(str, options) {
|
|
120766
120780
|
var val = options.trailingNewline;
|
|
@@ -172547,9 +172561,9 @@ var preprocessSelector = (selector) => {
|
|
|
172547
172561
|
const netName = match ? match[1] : "";
|
|
172548
172562
|
throw new Error(`Net name "${netName}" cannot start with a number, try using a prefix like "VBUS1"`);
|
|
172549
172563
|
}
|
|
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, (_,
|
|
172564
|
+
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
172565
|
const pinPart = /^\d+$/.test(pin) ? `pin${pin}` : pin;
|
|
172552
|
-
return `${
|
|
172566
|
+
return `${sep3}.${name} > .${pinPart}`;
|
|
172553
172567
|
}).trim();
|
|
172554
172568
|
};
|
|
172555
172569
|
var cssSelectOptionsInsideSubcircuit = {
|
|
@@ -183076,17 +183090,20 @@ var findProjectRoot = (startDir) => {
|
|
|
183076
183090
|
};
|
|
183077
183091
|
async function getBuildEntrypoints({
|
|
183078
183092
|
fileOrDir,
|
|
183079
|
-
rootDir = process.cwd()
|
|
183093
|
+
rootDir = process.cwd(),
|
|
183094
|
+
includeBoardFiles = true
|
|
183080
183095
|
}) {
|
|
183081
183096
|
const resolvedRoot = path33.resolve(rootDir);
|
|
183082
|
-
const
|
|
183097
|
+
const includeBoardFilePatterns = includeBoardFiles ? getBoardFilePatterns(resolvedRoot) : [];
|
|
183083
183098
|
const buildFromProjectDir = async () => {
|
|
183084
|
-
|
|
183085
|
-
|
|
183086
|
-
|
|
183087
|
-
|
|
183088
|
-
|
|
183089
|
-
|
|
183099
|
+
if (includeBoardFiles) {
|
|
183100
|
+
const files = findBoardFiles({ projectDir: resolvedRoot });
|
|
183101
|
+
if (files.length > 0) {
|
|
183102
|
+
return {
|
|
183103
|
+
projectDir: resolvedRoot,
|
|
183104
|
+
circuitFiles: files
|
|
183105
|
+
};
|
|
183106
|
+
}
|
|
183090
183107
|
}
|
|
183091
183108
|
const mainEntrypoint = await getEntrypoint({
|
|
183092
183109
|
projectDir: resolvedRoot,
|
|
@@ -183112,16 +183129,33 @@ async function getBuildEntrypoints({
|
|
|
183112
183129
|
if (fileOrDir) {
|
|
183113
183130
|
const resolved = path33.resolve(resolvedRoot, fileOrDir);
|
|
183114
183131
|
if (fs33.existsSync(resolved) && fs33.statSync(resolved).isDirectory()) {
|
|
183115
|
-
|
|
183116
|
-
|
|
183117
|
-
|
|
183118
|
-
|
|
183119
|
-
|
|
183120
|
-
|
|
183132
|
+
if (includeBoardFiles) {
|
|
183133
|
+
const circuitFiles = findBoardFiles({
|
|
183134
|
+
projectDir: resolvedRoot,
|
|
183135
|
+
filePaths: [resolved]
|
|
183136
|
+
}).filter((file) => isSubPath2(file, resolved));
|
|
183137
|
+
if (circuitFiles.length === 0) {
|
|
183138
|
+
throw new Error(`There were no files to build found matching the includeBoardFiles globs: ${JSON.stringify(includeBoardFilePatterns)}`);
|
|
183139
|
+
}
|
|
183140
|
+
return {
|
|
183141
|
+
projectDir: resolvedRoot,
|
|
183142
|
+
circuitFiles
|
|
183143
|
+
};
|
|
183121
183144
|
}
|
|
183145
|
+
const projectDir2 = findProjectRoot(resolved);
|
|
183146
|
+
const mainEntrypoint = await getEntrypoint({
|
|
183147
|
+
projectDir: projectDir2,
|
|
183148
|
+
onSuccess: () => {
|
|
183149
|
+
return;
|
|
183150
|
+
},
|
|
183151
|
+
onError: () => {
|
|
183152
|
+
return;
|
|
183153
|
+
}
|
|
183154
|
+
});
|
|
183122
183155
|
return {
|
|
183123
|
-
projectDir:
|
|
183124
|
-
|
|
183156
|
+
projectDir: projectDir2,
|
|
183157
|
+
mainEntrypoint: mainEntrypoint || undefined,
|
|
183158
|
+
circuitFiles: mainEntrypoint ? [mainEntrypoint] : []
|
|
183125
183159
|
};
|
|
183126
183160
|
}
|
|
183127
183161
|
const fileDir = path33.dirname(resolved);
|
|
@@ -184544,7 +184578,8 @@ var registerTranspile = (program3) => {
|
|
|
184544
184578
|
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
184579
|
try {
|
|
184546
184580
|
const { projectDir, circuitFiles, mainEntrypoint } = await getBuildEntrypoints({
|
|
184547
|
-
fileOrDir: file
|
|
184581
|
+
fileOrDir: file,
|
|
184582
|
+
includeBoardFiles: false
|
|
184548
184583
|
});
|
|
184549
184584
|
const distDir = path46.join(projectDir, "dist");
|
|
184550
184585
|
validateMainInDist(projectDir, distDir);
|