refactor: restructure into Bun workspace monorepo [1/4] - #43
Conversation
Convert the single-package repo into a Bun workspace monorepo: - packages/cli-core/ — all CLI source code, commands, tests - packages/cli/ — lightweight npm wrapper for platform binary resolution Includes .ts extension fixes in imports, test isolation improvements, updated CI workflow, and new package scaffolding.
📝 WalkthroughWalkthroughThis pull request restructures the repository from a single-package CLI into a Bun workspace monorepo. The main CLI source code moves to 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
Summary
Today the CLI is distributed as a bundled JS file (
bun build → dist/cli.js) that runs under Node. This works for development but doesn't support distributing a standalonenpx clerkbinary -- users would need Bun installed, and we can't cross-compile or ship platform-specific native executables.This PR restructures the repo into a Bun workspace monorepo to enable that:
packages/cli-core/-- all CLI source code, commands, and tests (moved fromsrc/). Compiled viabun build --compileinto a standalone native binary per platform.packages/cli/-- theclerknpm package users install vianpx clerkornpm install -g clerk. Contains a lightweight Node shim (bin/clerk) that:process.platform,process.arch, and libc variant (glibc vs musl)@clerk/cli-darwin-arm64,@clerk/cli-linux-x64, etc.)This is the same pattern used by esbuild, SWC, Turbopack, and other tools that ship native binaries through npm -- a thin wrapper package with
optionalDependencieson per-platform packages, sonpm installonly downloads the binary for the user's OS.Other changes
.tsextension fixes in imports and test isolation improvementsMerge instructions
This is PR 1 of a 4-PR stack. After squash-merging this PR:
Then merge PR 2, and repeat for the rest of the stack.
Test plan
bun install,format:check,lint,build,testbun run devlaunches the CLI from the new workspace pathbun run build:compileproduces a working binary