mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-15 13:14:35 +00:00
- Rename packages/opencode → packages/tfcode (directory only) - Rename bin/opencode → bin/tfcode (CLI binary) - Rename .opencode → .tfcode (config directory) - Update package.json name and bin field - Update config directory path references (.tfcode) - Keep internal code references as 'opencode' for easy upstream sync - Keep @opencode-ai/* workspace package names This minimal branding approach allows clean merges from upstream opencode repository while providing tfcode branding for users.
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import semver from "semver"
|
|
import { Log } from "../util/log"
|
|
import { Process } from "../util/process"
|
|
|
|
export namespace PackageRegistry {
|
|
const log = Log.create({ service: "bun" })
|
|
|
|
function which() {
|
|
return process.execPath
|
|
}
|
|
|
|
export async function info(pkg: string, field: string, cwd?: string): Promise<string | null> {
|
|
const { code, stdout, stderr } = await Process.run([which(), "info", pkg, field], {
|
|
cwd,
|
|
env: {
|
|
...process.env,
|
|
BUN_BE_BUN: "1",
|
|
},
|
|
nothrow: true,
|
|
})
|
|
|
|
if (code !== 0) {
|
|
log.warn("bun info failed", { pkg, field, code, stderr: stderr.toString() })
|
|
return null
|
|
}
|
|
|
|
const value = stdout.toString().trim()
|
|
if (!value) return null
|
|
return value
|
|
}
|
|
|
|
export async function isOutdated(pkg: string, cachedVersion: string, cwd?: string): Promise<boolean> {
|
|
const latestVersion = await info(pkg, "version", cwd)
|
|
if (!latestVersion) {
|
|
log.warn("Failed to resolve latest version, using cached", { pkg, cachedVersion })
|
|
return false
|
|
}
|
|
|
|
const isRange = /[\s^~*xX<>|=]/.test(cachedVersion)
|
|
if (isRange) return !semver.satisfies(latestVersion, cachedVersion)
|
|
|
|
return semver.lt(cachedVersion, latestVersion)
|
|
}
|
|
}
|