mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-23 00:54:43 +00:00
feat: packages
This commit is contained in:
2
bun.lock
2
bun.lock
@@ -381,7 +381,7 @@
|
|||||||
},
|
},
|
||||||
"packages/tfcode": {
|
"packages/tfcode": {
|
||||||
"name": "@toothfairyai/tfcode",
|
"name": "@toothfairyai/tfcode",
|
||||||
"version": "1.0.21",
|
"version": "1.0.22",
|
||||||
"bin": {
|
"bin": {
|
||||||
"tfcode": "./bin/tfcode",
|
"tfcode": "./bin/tfcode",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/package.json",
|
"$schema": "https://json.schemastore.org/package.json",
|
||||||
"version": "1.0.21",
|
"version": "1.0.22",
|
||||||
"name": "@toothfairyai/tfcode",
|
"name": "@toothfairyai/tfcode",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
64
packages/tfcode/script/publish-remaining.ts
Normal file
64
packages/tfcode/script/publish-remaining.ts
Normal 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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user