Skip to content

Commit 03df750

Browse files
committed
fix(tui): fix build script
1 parent 6e85eac commit 03df750

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

apps/tui/scripts/build.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ const appRoot = fileURLToPath(new URL("../", import.meta.url));
4444
const nodeModulesRoot = fileURLToPath(
4545
new URL("../../../node_modules/", import.meta.url)
4646
);
47+
const localNodeModulesRoot = fileURLToPath(
48+
new URL("../node_modules/", import.meta.url)
49+
);
4750

4851
async function pathExists(path: string) {
4952
try {
@@ -54,18 +57,38 @@ async function pathExists(path: string) {
5457
}
5558
}
5659

60+
async function findPackageJson(packagePath: string): Promise<string | null> {
61+
// Try root node_modules first (for npm/yarn)
62+
const rootPath = join(nodeModulesRoot, packagePath, "package.json");
63+
if (await pathExists(rootPath)) {
64+
return rootPath;
65+
}
66+
67+
// Try local node_modules (for pnpm)
68+
const localPath = join(localNodeModulesRoot, packagePath, "package.json");
69+
if (await pathExists(localPath)) {
70+
return localPath;
71+
}
72+
73+
return null;
74+
}
75+
5776
async function ensureOpenTuiCorePackage(packageName: string) {
5877
const packageJsonPath = join(nodeModulesRoot, packageName, "package.json");
5978
if (await pathExists(packageJsonPath)) {
6079
return;
6180
}
6281

63-
const corePackageJsonPath = join(
64-
nodeModulesRoot,
65-
"@opentui",
66-
"core",
67-
"package.json"
68-
);
82+
// Try to find @opentui/core package.json in multiple locations
83+
const corePackageJsonPath = await findPackageJson("@opentui/core");
84+
if (!corePackageJsonPath) {
85+
throw new Error(
86+
`Could not find @opentui/core package.json. Checked:\n` +
87+
` - ${join(nodeModulesRoot, "@opentui/core", "package.json")}\n` +
88+
` - ${join(localNodeModulesRoot, "@opentui/core", "package.json")}`
89+
);
90+
}
91+
6992
const corePackage = JSON.parse(
7093
await readFile(corePackageJsonPath, "utf8")
7194
) as {

0 commit comments

Comments
 (0)