forked from adeyahya/prisma-typebox-generator
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.ts
43 lines (38 loc) · 966 Bytes
/
build.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
import { copyFile, exists, rm, writeFile } from "node:fs/promises";
import { build } from "esbuild";
import packagejson from "./package.json";
if (await exists("./dist")) {
await rm("./dist", { force: true, recursive: true });
}
const output = await build({
entryPoints: ["./src/cli.ts"],
outdir: "./dist",
platform: "node",
format: "cjs",
sourcemap: "external",
minify: true,
bundle: true,
external: [
...Object.keys(packagejson.dependencies),
...Object.keys(packagejson.devDependencies),
],
});
if (output.errors) {
console.error(output.errors);
} else {
console.info("Built successfully!");
}
let version = process.env.REF_NAME ?? packagejson.version;
if (!version) {
version = "0.0.1";
}
await copyFile("./README.md", "./dist/README.md");
await copyFile("./LICENSE", "./dist/LICENSE");
await writeFile(
"./dist/package.json",
JSON.stringify({
...packagejson,
version,
bin: { prismabox: "cli.js" },
}),
);