@tscircuit/cli 0.1.570 → 0.1.571
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 +84 -13
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -67456,7 +67456,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
|
|
|
67456
67456
|
function maybeCallback(cb) {
|
|
67457
67457
|
return typeof cb === "function" ? cb : rethrow();
|
|
67458
67458
|
}
|
|
67459
|
-
var
|
|
67459
|
+
var normalize4 = pathModule.normalize;
|
|
67460
67460
|
if (isWindows2) {
|
|
67461
67461
|
nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
|
|
67462
67462
|
} else {
|
|
@@ -72387,7 +72387,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
72387
72387
|
import { execSync as execSync2 } from "node:child_process";
|
|
72388
72388
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
72389
72389
|
// package.json
|
|
72390
|
-
var version = "0.1.
|
|
72390
|
+
var version = "0.1.570";
|
|
72391
72391
|
var package_default = {
|
|
72392
72392
|
name: "@tscircuit/cli",
|
|
72393
72393
|
version,
|
|
@@ -77272,10 +77272,37 @@ function getPackageNameFromImport(importPath) {
|
|
|
77272
77272
|
}
|
|
77273
77273
|
return importPath.split("/")[0];
|
|
77274
77274
|
}
|
|
77275
|
-
function resolveNodeModuleImport(
|
|
77275
|
+
function resolveNodeModuleImport({
|
|
77276
|
+
importPath,
|
|
77277
|
+
projectDir,
|
|
77278
|
+
searchFromDir
|
|
77279
|
+
}) {
|
|
77276
77280
|
const packageName = getPackageNameFromImport(importPath);
|
|
77277
|
-
const
|
|
77278
|
-
|
|
77281
|
+
const searchPaths = [
|
|
77282
|
+
path19.join(projectDir, "node_modules", packageName)
|
|
77283
|
+
];
|
|
77284
|
+
if (searchFromDir) {
|
|
77285
|
+
let currentDir = path19.dirname(searchFromDir);
|
|
77286
|
+
const projectDirNormalized = path19.normalize(projectDir);
|
|
77287
|
+
while (currentDir.startsWith(projectDirNormalized)) {
|
|
77288
|
+
const candidatePath = path19.join(currentDir, "node_modules", packageName);
|
|
77289
|
+
if (!searchPaths.includes(candidatePath)) {
|
|
77290
|
+
searchPaths.push(candidatePath);
|
|
77291
|
+
}
|
|
77292
|
+
const parentDir = path19.dirname(currentDir);
|
|
77293
|
+
if (parentDir === currentDir)
|
|
77294
|
+
break;
|
|
77295
|
+
currentDir = parentDir;
|
|
77296
|
+
}
|
|
77297
|
+
}
|
|
77298
|
+
let packageDir;
|
|
77299
|
+
for (const candidatePath of searchPaths) {
|
|
77300
|
+
if (fs19.existsSync(candidatePath)) {
|
|
77301
|
+
packageDir = candidatePath;
|
|
77302
|
+
break;
|
|
77303
|
+
}
|
|
77304
|
+
}
|
|
77305
|
+
if (!packageDir) {
|
|
77279
77306
|
return [];
|
|
77280
77307
|
}
|
|
77281
77308
|
const packageJsonPath = path19.join(packageDir, "package.json");
|
|
@@ -77349,7 +77376,11 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
77349
77376
|
const imports = getNodeModuleImports(filePath);
|
|
77350
77377
|
for (const importPath of imports) {
|
|
77351
77378
|
if (!nodeModuleFiles.has(importPath)) {
|
|
77352
|
-
const resolvedFiles = resolveNodeModuleImport(
|
|
77379
|
+
const resolvedFiles = resolveNodeModuleImport({
|
|
77380
|
+
importPath,
|
|
77381
|
+
projectDir,
|
|
77382
|
+
searchFromDir: filePath
|
|
77383
|
+
});
|
|
77353
77384
|
if (resolvedFiles.length > 0) {
|
|
77354
77385
|
nodeModuleFiles.set(importPath, resolvedFiles);
|
|
77355
77386
|
for (const resolvedFile of resolvedFiles) {
|
|
@@ -77461,6 +77492,25 @@ function walkDirectory(dir, excludedDirs) {
|
|
|
77461
77492
|
}
|
|
77462
77493
|
return files;
|
|
77463
77494
|
}
|
|
77495
|
+
var RUNTIME_PROVIDED_PACKAGES = new Set([
|
|
77496
|
+
"react",
|
|
77497
|
+
"react-dom",
|
|
77498
|
+
"react/jsx-runtime",
|
|
77499
|
+
"tscircuit",
|
|
77500
|
+
"@tscircuit/core",
|
|
77501
|
+
"@tscircuit/props"
|
|
77502
|
+
]);
|
|
77503
|
+
function isRuntimeProvidedPackage(packageName) {
|
|
77504
|
+
if (RUNTIME_PROVIDED_PACKAGES.has(packageName)) {
|
|
77505
|
+
return true;
|
|
77506
|
+
}
|
|
77507
|
+
for (const runtimePkg of RUNTIME_PROVIDED_PACKAGES) {
|
|
77508
|
+
if (packageName.startsWith(`${runtimePkg}/`)) {
|
|
77509
|
+
return true;
|
|
77510
|
+
}
|
|
77511
|
+
}
|
|
77512
|
+
return false;
|
|
77513
|
+
}
|
|
77464
77514
|
function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
77465
77515
|
const localPackages = getLocalPackages(projectDir);
|
|
77466
77516
|
if (localPackages.size === 0) {
|
|
@@ -77469,16 +77519,37 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
77469
77519
|
const dependencies2 = collectAllNodeModuleDependencies(entryFilePath, projectDir);
|
|
77470
77520
|
const processedPackages = new Set;
|
|
77471
77521
|
const allFiles = new Set;
|
|
77472
|
-
for (const [importPath] of dependencies2.entries()) {
|
|
77522
|
+
for (const [importPath, resolvedFiles] of dependencies2.entries()) {
|
|
77473
77523
|
const packageName = getPackageNameFromImport(importPath);
|
|
77474
|
-
|
|
77524
|
+
const isLocalPackage = localPackages.has(packageName);
|
|
77525
|
+
if (isRuntimeProvidedPackage(packageName) && !isLocalPackage) {
|
|
77475
77526
|
continue;
|
|
77476
77527
|
}
|
|
77477
|
-
processedPackages.
|
|
77478
|
-
|
|
77479
|
-
|
|
77480
|
-
|
|
77481
|
-
|
|
77528
|
+
if (!processedPackages.has(packageName)) {
|
|
77529
|
+
processedPackages.add(packageName);
|
|
77530
|
+
if (resolvedFiles.length > 0) {
|
|
77531
|
+
const firstResolvedFile = resolvedFiles[0];
|
|
77532
|
+
let packageDir = path19.dirname(firstResolvedFile);
|
|
77533
|
+
while (packageDir.includes("node_modules")) {
|
|
77534
|
+
const packageJsonPath = path19.join(packageDir, "package.json");
|
|
77535
|
+
if (fs19.existsSync(packageJsonPath)) {
|
|
77536
|
+
try {
|
|
77537
|
+
const pkgJson = JSON.parse(fs19.readFileSync(packageJsonPath, "utf-8"));
|
|
77538
|
+
if (pkgJson.name === packageName) {
|
|
77539
|
+
break;
|
|
77540
|
+
}
|
|
77541
|
+
} catch {}
|
|
77542
|
+
}
|
|
77543
|
+
const parentDir = path19.dirname(packageDir);
|
|
77544
|
+
if (parentDir === packageDir)
|
|
77545
|
+
break;
|
|
77546
|
+
packageDir = parentDir;
|
|
77547
|
+
}
|
|
77548
|
+
if (fs19.existsSync(packageDir)) {
|
|
77549
|
+
const packageFiles = collectLocalPackageFiles(packageDir);
|
|
77550
|
+
packageFiles.forEach((file) => allFiles.add(file));
|
|
77551
|
+
}
|
|
77552
|
+
}
|
|
77482
77553
|
}
|
|
77483
77554
|
}
|
|
77484
77555
|
return Array.from(allFiles);
|