From 478d930c4a8eff9e10bd341f146e21a989dcd147 Mon Sep 17 00:00:00 2001 From: Gab Date: Mon, 30 Mar 2026 00:11:43 +1100 Subject: [PATCH] feat: packages --- bun.lock | 2 +- packages/tfcode/package.json | 2 +- packages/tfcode/script/publish-remaining.ts | 64 +++++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 packages/tfcode/script/publish-remaining.ts diff --git a/bun.lock b/bun.lock index 779e85fe1..70e142747 100644 --- a/bun.lock +++ b/bun.lock @@ -381,7 +381,7 @@ }, "packages/tfcode": { "name": "@toothfairyai/tfcode", - "version": "1.0.21", + "version": "1.0.22", "bin": { "tfcode": "./bin/tfcode", }, diff --git a/packages/tfcode/package.json b/packages/tfcode/package.json index 918ad3d83..d28f7ebc5 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.21", + "version": "1.0.22", "name": "@toothfairyai/tfcode", "type": "module", "license": "MIT", diff --git a/packages/tfcode/script/publish-remaining.ts b/packages/tfcode/script/publish-remaining.ts new file mode 100644 index 000000000..134c82def --- /dev/null +++ b/packages/tfcode/script/publish-remaining.ts @@ -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 = {} +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) +}