diff --git a/packages/tfcode/package.json b/packages/tfcode/package.json index 24438fac6..10094cf6a 100644 --- a/packages/tfcode/package.json +++ b/packages/tfcode/package.json @@ -1,6 +1,6 @@ { "$schema": "https://json.schemastore.org/package.json", - "version": "1.0.37", + "version": "1.0.38", "name": "@toothfairyai/tfcode", "type": "module", "license": "MIT", diff --git a/packages/tfcode/script/postinstall-tfcode.mjs b/packages/tfcode/script/postinstall-tfcode.mjs index e95ca380d..b1bc685fe 100644 --- a/packages/tfcode/script/postinstall-tfcode.mjs +++ b/packages/tfcode/script/postinstall-tfcode.mjs @@ -93,6 +93,25 @@ async function downloadBinary() { if (fs.existsSync(existingBinary)) { console.log(`✓ Binary already exists at ${existingBinary}`) + // Still need to copy app dir from platform package if missing + const targetAppDir = path.join(binDir, "app") + if (!fs.existsSync(path.join(targetAppDir, "dist", "index.html"))) { + let target = `tfcode-${platform}-${arch}` + if (needsBaseline) target += "-baseline" + if (abi) target += `-${abi}` + const pkgName = `@toothfairyai/${target}` + try { + const pkgUrl = import.meta.resolve(`${pkgName}/package.json`) + const pkgDir = path.dirname(fileURLToPath(pkgUrl)) + const srcAppDir = path.join(pkgDir, "bin", "app") + if (fs.existsSync(path.join(srcAppDir, "dist", "index.html"))) { + fs.cpSync(srcAppDir, targetAppDir, { recursive: true }) + console.log("✓ Web app copied from platform package") + } + } catch (e) { + console.log(`! Could not copy web app: ${e.message}`) + } + } return }