opencode_offline/packages/plugin/script/publish.ts

30 lines
782 B
TypeScript
Raw Normal View History

2025-08-03 06:50:19 +08:00
#!/usr/bin/env bun
const dir = new URL("..", import.meta.url).pathname
process.chdir(dir)
import { $ } from "bun"
await $`bun tsc`
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-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-09-27 16:10:56 +08:00
const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true"
2025-08-03 06:50:19 +08:00
if (snapshot) {
2025-09-29 13:38:53 +08:00
await $`bun publish --tag snapshot --access public`
2025-08-03 06:50:19 +08:00
}
if (!snapshot) {
2025-09-29 13:38:53 +08:00
await $`bun publish --access public`
2025-08-03 06:50:19 +08:00
}
2025-09-29 13:22:39 +08:00
await Bun.write("package.json", JSON.stringify(original, null, 2))