-
Notifications
You must be signed in to change notification settings - Fork 22
/
buildPbCli.ts
61 lines (58 loc) · 1.51 KB
/
buildPbCli.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { ensureDir } from "https://deno.land/std@0.175.0/fs/mod.ts";
import { build } from "https://deno.land/x/dnt@0.39.0/mod.ts";
import { BuildConfig, NameAndVersion } from "./index.ts";
if (import.meta.main) {
buildPbCli({
name: "@pbkit/pb-cli",
version: "0.0.0",
dist: "tmp/npm/pb-cli",
});
}
export default async function buildPbCli(config: BuildConfig) {
const packageJson = getPackageJson(config);
await ensureDir(config.dist);
await build({
entryPoints: [{ kind: "bin", name: "pb", path: "cli/pb/entrypoint.ts" }],
outDir: config.dist,
shims: {
deno: true,
custom: [{
package: {
name: "web-streams-polyfill",
version: "^3.2.0",
subPath: "dist/ponyfill.mjs",
},
globalNames: ["ReadableStream"],
}, {
package: {
name: "undici",
version: "^4.15.1",
subPath: "lib/fetch/headers.js",
},
globalNames: ["Headers"],
}],
},
package: packageJson,
typeCheck: false,
declaration: false,
test: false,
scriptModule: false,
});
}
export function getPackageJson(config: NameAndVersion) {
const { name, version } = config;
return {
name,
version,
description: "Protobuf schema compiler",
author: "JongChan Choi <jong@chan.moe>",
license: "(MIT OR Apache-2.0)",
repository: {
type: "git",
url: "git+https://github.com/pbkit/pbkit.git",
},
bugs: {
url: "https://github.com/pbkit/pbkit/issues",
},
};
}