Skip to content

Commit ac301ed

Browse files
committed
feat: add gitpkg sdk packaging
Signed-off-by: yuguorui <yuguorui@pku.edu.cn>
1 parent 5e4445a commit ac301ed

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

script/gitpkg.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bun
2+
3+
const dir = new URL("..", import.meta.url).pathname
4+
process.chdir(dir)
5+
6+
const pkg = await import("../package.json").then((m) => m.default)
7+
const next = JSON.parse(JSON.stringify(pkg))
8+
9+
const items = Object.entries(next.exports)
10+
for (const item of items) {
11+
const key = item[0]
12+
const value = item[1]
13+
const data =
14+
typeof value === "object" && value !== null && "import" in value
15+
? (value as { import?: unknown }).import
16+
: undefined
17+
const text = typeof value === "string" ? value : data
18+
if (typeof text !== "string") continue
19+
const file = text.replace("./src/", "./dist/").replace(".ts", "")
20+
next.exports[key] = {
21+
import: file + ".js",
22+
types: file + ".d.ts",
23+
}
24+
}
25+
26+
await Bun.write("package.json", JSON.stringify(next, null, 2))

0 commit comments

Comments
 (0)