From 5d5290ceda6520597830286ad6d36d2adeaa627a Mon Sep 17 00:00:00 2001 From: Braden Wong <13159333+braden-w@users.noreply.github.com> Date: Tue, 7 Apr 2026 22:11:19 +0800 Subject: [PATCH] fix(cli): add Node-compatible bin wrapper for npm publish npm strips .ts files from bin entries. Added a .mjs wrapper that: - Runs directly when invoked by Bun (imports src/bin.ts) - Re-execs itself with Bun when invoked by Node - Prints install instructions if Bun is not available Pattern follows trekker, t1code, and other Bun-first CLIs. --- packages/cli/bin/epicenter.mjs | 30 ++++++++++++++++++++++++++++++ packages/cli/package.json | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 packages/cli/bin/epicenter.mjs diff --git a/packages/cli/bin/epicenter.mjs b/packages/cli/bin/epicenter.mjs new file mode 100644 index 0000000000..a83ab40fc3 --- /dev/null +++ b/packages/cli/bin/epicenter.mjs @@ -0,0 +1,30 @@ +#!/usr/bin/env node + +import { spawnSync } from "node:child_process"; +import { fileURLToPath } from "node:url"; + +const isBun = typeof Bun !== "undefined"; + +if (!isBun) { + const bunCheck = spawnSync("bun", ["--version"], { stdio: "ignore" }); + + if (bunCheck.status === 0) { + const result = spawnSync( + "bun", + [fileURLToPath(import.meta.url), ...process.argv.slice(2)], + { stdio: "inherit" }, + ); + process.exit(result.status ?? 1); + } + + console.error(`Epicenter CLI requires Bun. + +Install it: + + curl -fsSL https://bun.sh/install | bash + +Then run this command again. Learn more: https://bun.sh`); + process.exit(1); +} + +await import("../src/bin.ts"); diff --git a/packages/cli/package.json b/packages/cli/package.json index d74aecdd18..573649cbb3 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -21,7 +21,7 @@ "main": "./src/index.ts", "types": "./src/index.ts", "bin": { - "epicenter": "./src/bin.ts" + "epicenter": "./bin/epicenter.mjs" }, "dependencies": { "@epicenter/workspace": "workspace:*",