mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-31 14:22:27 +00:00
feat: releases
This commit is contained in:
@@ -6,22 +6,34 @@ import os from "os"
|
||||
import { spawnSync } from "child_process"
|
||||
|
||||
const GITEA_HOST = process.env.TFCODE_GITEA_HOST || "gitea.toothfairyai.com"
|
||||
const GITEA_REPO = process.env.TFCODE_GITEA_REPO || "ToothFairyAI/tfcode"
|
||||
const GITEA_REPO = process.env.TFCODE_GITEA_REPO || "ToothFairyAI/tf_code"
|
||||
|
||||
function detectPlatform() {
|
||||
let platform
|
||||
switch (os.platform()) {
|
||||
case "darwin": platform = "darwin"; break
|
||||
case "linux": platform = "linux"; break
|
||||
case "win32": platform = "windows"; break
|
||||
default: platform = os.platform()
|
||||
case "darwin":
|
||||
platform = "darwin"
|
||||
break
|
||||
case "linux":
|
||||
platform = "linux"
|
||||
break
|
||||
case "win32":
|
||||
platform = "windows"
|
||||
break
|
||||
default:
|
||||
platform = os.platform()
|
||||
}
|
||||
|
||||
let arch
|
||||
switch (os.arch()) {
|
||||
case "x64": arch = "x64"; break
|
||||
case "arm64": arch = "arm64"; break
|
||||
default: arch = os.arch()
|
||||
case "x64":
|
||||
arch = "x64"
|
||||
break
|
||||
case "arm64":
|
||||
arch = "arm64"
|
||||
break
|
||||
default:
|
||||
arch = os.arch()
|
||||
}
|
||||
|
||||
// Check for AVX2 on x64
|
||||
@@ -94,7 +106,7 @@ async function downloadBinary() {
|
||||
if (curlResult.status !== 0) {
|
||||
console.error(`Failed to download from ${url}`)
|
||||
console.error("Trying npm package fallback...")
|
||||
|
||||
|
||||
// Fallback to npm optionalDependencies
|
||||
try {
|
||||
const pkgName = `@toothfairyai/${target}`
|
||||
@@ -102,13 +114,13 @@ async function downloadBinary() {
|
||||
const pkgDir = path.dirname(pkgPath)
|
||||
const binaryName = platform === "windows" ? "tfcode.exe" : "tfcode"
|
||||
const binaryPath = path.join(pkgDir, "bin", binaryName)
|
||||
|
||||
|
||||
if (fs.existsSync(binaryPath)) {
|
||||
setupBinary(binaryPath, platform)
|
||||
return
|
||||
}
|
||||
} catch {}
|
||||
|
||||
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
@@ -167,13 +179,17 @@ async function main() {
|
||||
const result = spawnSync("python3", ["--version"], { encoding: "utf8" })
|
||||
if (result.status === 0) {
|
||||
console.log(`✓ Found ${result.stdout.trim()}`)
|
||||
|
||||
|
||||
// Install Python SDK
|
||||
console.log("Installing ToothFairyAI Python SDK...")
|
||||
const pipResult = spawnSync("python3", ["-m", "pip", "install", "--user", "--break-system-packages", "toothfairyai", "pydantic", "httpx", "rich"], {
|
||||
stdio: "inherit"
|
||||
})
|
||||
|
||||
const pipResult = spawnSync(
|
||||
"python3",
|
||||
["-m", "pip", "install", "--user", "--break-system-packages", "toothfairyai", "pydantic", "httpx", "rich"],
|
||||
{
|
||||
stdio: "inherit",
|
||||
},
|
||||
)
|
||||
|
||||
if (pipResult.status === 0) {
|
||||
console.log("✓ Python SDK installed")
|
||||
} else {
|
||||
@@ -197,8 +213,8 @@ async function main() {
|
||||
console.log("Quick Start:")
|
||||
console.log("")
|
||||
console.log(" 1. Set credentials:")
|
||||
console.log(" export TF_WORKSPACE_ID=\"your-workspace-id\"")
|
||||
console.log(" export TF_API_KEY=\"your-api-key\"")
|
||||
console.log(' export TF_WORKSPACE_ID="your-workspace-id"')
|
||||
console.log(' export TF_API_KEY="your-api-key"')
|
||||
console.log("")
|
||||
console.log(" 2. Validate:")
|
||||
console.log(" tfcode validate")
|
||||
@@ -213,4 +229,4 @@ async function main() {
|
||||
console.log("")
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
main().catch(console.error)
|
||||
|
||||
Reference in New Issue
Block a user