mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-31 22:32:28 +00:00
feat: tfcode
This commit is contained in:
@@ -109,15 +109,29 @@ async function createMainPackage() {
|
||||
await Bun.file(`./dist/tfcode/postinstall.mjs`).write(await Bun.file("./script/postinstall-tfcode.mjs").text())
|
||||
await Bun.file(`./dist/tfcode/LICENSE`).write(await Bun.file("../../LICENSE").text())
|
||||
|
||||
// Copy the current platform's binary to the main package
|
||||
// This makes installation faster (no need to download or copy from optionalDependencies)
|
||||
const currentPlatform = process.platform === "darwin" ? "darwin" : process.platform === "linux" ? "linux" : "windows"
|
||||
const currentArch = process.arch
|
||||
const platformBinDir = `./dist/tfcode-${currentPlatform}-${currentArch}/bin`
|
||||
const binaryName = process.platform === "win32" ? "tfcode.exe" : "tfcode"
|
||||
|
||||
if (fs.existsSync(`${platformBinDir}/${binaryName}`)) {
|
||||
console.log(`Including ${currentPlatform}-${currentArch} binary in main package`)
|
||||
await $`cp ${platformBinDir}/${binaryName} ./dist/tfcode/bin/`
|
||||
} else {
|
||||
console.log(`Warning: No binary found for current platform (${currentPlatform}-${currentArch})`)
|
||||
console.log(`The postinstall script will need to download or copy from optionalDependencies`)
|
||||
}
|
||||
|
||||
// Create a simple wrapper script that runs the installed binary
|
||||
const wrapper = `#!/usr/bin/env node
|
||||
const { spawn } = require('child_process')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
const binDir = path.join(__dirname, 'bin')
|
||||
const binary = process.platform === 'win32' ? 'tfcode.exe' : 'tfcode'
|
||||
const binaryPath = path.join(binDir, binary)
|
||||
const binaryPath = path.join(__dirname, binary)
|
||||
|
||||
if (!fs.existsSync(binaryPath)) {
|
||||
console.error('tfcode binary not found. Run: npm install @toothfairyai/tfcode')
|
||||
|
||||
Reference in New Issue
Block a user