Files
plainleaf/build/build_cli.ts
T
Zef Hemel c04d7c332f First pass at "Remote API" (see docs)
Note: this is highly experimental and will likely change in the future.
2026-03-17 09:57:08 +01:00

35 lines
875 B
TypeScript

import { mkdir } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import * as esbuild from "esbuild";
export async function buildCli(): Promise<void> {
await mkdir("dist", { recursive: true });
const result = await esbuild.build({
entryPoints: ["./bin/silverbullet-cli.ts"],
outfile: "dist/silverbullet-cli.js",
format: "esm",
banner: {
js: "#!/usr/bin/env node",
},
platform: "node",
absWorkingDir: process.cwd(),
bundle: true,
metafile: false,
treeShaking: true,
logLevel: "error",
minify: false,
external: ["commander"],
});
if (result.metafile) {
const text = await esbuild.analyzeMetafile(result.metafile!);
console.log("Bundle info", text);
}
}
const isMain = process.argv[1] === fileURLToPath(import.meta.url);
if (isMain) {
await buildCli();
await esbuild.stop();
}