From d11632d44b740ab8b78ec27544afb480f406a9d5 Mon Sep 17 00:00:00 2001 From: Soccera1 <129828376+Soccera1@users.noreply.github.com> Date: Thu, 6 Aug 2026 01:58:10 +1000 Subject: Automatically publish to npm --- scripts/build.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 scripts/build.js (limited to 'scripts') diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 0000000..8adcc3c --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,46 @@ +import { readdir, rm } from "node:fs/promises"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +const root = dirname(dirname(fileURLToPath(import.meta.url))); +const dist = join(root, "dist"); +const commandsSource = join(root, "src/commands"); + +await rm(dist, { recursive: true, force: true }); + +const commandEntrypoints = (await readdir(commandsSource)) + .filter((name) => name.endsWith(".js")) + .map((name) => join(commandsSource, name)); + +const commonOptions = { + target: "bun", + minify: true, + sourcemap: "none", +}; + +const npmLauncher = await Bun.build({ + entrypoints: [join(root, "bin/npm.js")], + outdir: join(dist, "bin"), + target: "node", + minify: true, + sourcemap: "none", +}); + +const runtimeLauncher = await Bun.build({ + ...commonOptions, + entrypoints: [join(root, "bin/bnu.js")], + outdir: join(dist, "runtime"), +}); + +const commands = await Bun.build({ + ...commonOptions, + entrypoints: commandEntrypoints, + outdir: join(dist, "commands"), + root: commandsSource, + splitting: false, +}); + +if (!npmLauncher.success || !runtimeLauncher.success || !commands.success) { + for (const log of [...npmLauncher.logs, ...runtimeLauncher.logs, ...commands.logs]) console.error(log); + process.exit(1); +} -- cgit v1.3