opencode/packages/sdk/js/script/publish.ts

25 lines
752 B
TypeScript
Raw Normal View History

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