cloudaxe-opencode/packages/plugin/script/publish.ts

23 lines
772 B
TypeScript
Raw Normal View History

2025-08-02 22:50:19 +00:00
#!/usr/bin/env bun
2025-10-15 23:53:14 +00:00
import { Script } from "@opencode-ai/script"
import { $ } from "bun"
import { fileURLToPath } from "url"
2025-08-02 22:50:19 +00:00
const dir = fileURLToPath(new URL("..", import.meta.url))
2025-08-02 22:50:19 +00:00
process.chdir(dir)
await $`bun tsc`
2025-09-29 05:06:12 +00:00
const pkg = await import("../package.json").then((m) => m.default)
2025-09-29 05:22:39 +00:00
const original = JSON.parse(JSON.stringify(pkg))
2025-09-27 08:10:56 +00:00
for (const [key, value] of Object.entries(pkg.exports)) {
2025-09-29 05:22:39 +00:00
const file = value.replace("./src/", "./dist/").replace(".ts", "")
2025-10-15 23:53:14 +00:00
// @ts-ignore
2025-09-27 08:10:56 +00:00
pkg.exports[key] = {
import: file + ".js",
types: file + ".d.ts",
}
}
2025-09-29 05:22:39 +00:00
await Bun.write("package.json", JSON.stringify(pkg, null, 2))
2025-12-10 02:06:57 +00:00
await $`bun pm pack && npm publish *.tgz --tag ${Script.channel} --access public`
2025-09-29 05:22:39 +00:00
await Bun.write("package.json", JSON.stringify(original, null, 2))