-
Notifications
You must be signed in to change notification settings - Fork 3
/
build_npm.ts
32 lines (26 loc) · 854 Bytes
/
build_npm.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
import { build, emptyDir } from "https://deno.land/x/[email protected]/mod.ts";
import pkg from "./package.json" assert { type: "json" };
const tag = Deno.env.get("GITHUB_REF");
const version = tag ? tag.slice(11) : Deno.env.get("VERSION");
if (!version)
throw new Error("VERSION environment variable not found. Use similar to `VERSION=0.1.0 deno run -A build_npm.ts`");
await emptyDir("./.npm");
// @ts-ignore
delete pkg.main, delete pkg.types, delete pkg.scripts;
await build({
entryPoints: ["./mod.ts"],
outDir: "./.npm",
shims: {},
test: false,
mappings: {
"https://deno.land/x/[email protected]/message.ts": {
name: "@telegraf/types",
version: "^7.0.1",
},
},
esModule: false,
package: { ...pkg, version },
});
// post build steps
Deno.copyFileSync("LICENSE", ".npm/LICENSE");
Deno.copyFileSync("README.md", ".npm/README.md");