feat: packages

This commit is contained in:
Gab
2026-03-30 00:11:43 +11:00
parent 493b0f924f
commit 478d930c4a
3 changed files with 66 additions and 2 deletions

View File

@@ -381,7 +381,7 @@
},
"packages/tfcode": {
"name": "@toothfairyai/tfcode",
"version": "1.0.21",
"version": "1.0.22",
"bin": {
"tfcode": "./bin/tfcode",
},

View File

@@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/package.json",
"version": "1.0.21",
"version": "1.0.22",
"name": "@toothfairyai/tfcode",
"type": "module",
"license": "MIT",

View File

@@ -0,0 +1,64 @@
#!/usr/bin/env bun
import { $ } from "bun"
import fs from "fs"
import path from "path"
import { fileURLToPath } from "url"
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const dir = path.resolve(__dirname, "..")
process.chdir(dir)
const NPM_TAG = process.env.NPM_TAG || "latest"
// Get binaries from dist
const binaries: Record<string, string> = {}
for (const filepath of new Bun.Glob("*/package.json").scanSync({ cwd: "./dist" })) {
const pkg = await Bun.file(`./dist/${filepath}`).json()
if (pkg.name.startsWith("@toothfairyai/tfcode-")) {
binaries[pkg.name] = pkg.version
}
}
console.log("Binaries:", binaries)
// Check which ones are already published
const toPublish: string[] = []
for (const [name, version] of Object.entries(binaries)) {
try {
const publishedVersion = await $`npm view ${name} version`
.quiet()
.text()
.then((t) => t.trim())
if (publishedVersion === version) {
console.log(`${name} already published at ${version}`)
} else {
console.log(`${name} needs publishing: local ${version}, npm ${publishedVersion}`)
toPublish.push(name)
}
} catch (error) {
console.log(`${name} not published yet`)
toPublish.push(name)
}
}
// Publish remaining
for (const name of toPublish) {
console.log(`Publishing ${name}...`)
const dirName = name.replace("@toothfairyai/", "")
try {
await $`cd ./dist/${dirName} && bun pm pack && npm publish *.tgz --access public --tag ${NPM_TAG}`
console.log(`✓ Published ${name}`)
} catch (error) {
console.error(`Failed to publish ${name}:`, error)
}
}
// Publish main package
console.log("Publishing main package...")
try {
await $`cd ./dist/tfcode && bun pm pack && npm publish *.tgz --access public --tag ${NPM_TAG}`
console.log("✓ Published main package")
} catch (error) {
console.error("Failed to publish main package:", error)
}