CLI
The bunito CLI runs, builds, and generates bunito projects. It discovers project shape from the filesystem instead of a project config file.
Install it globally if you want the bunito binary available everywhere:
bun install --global @bunito/cliRun it without a global install through bunx:
bunx @bunito/cli --helpProject Discovery
A bunito project is any directory, or parent directory, whose package.json depends on @bunito/bunito.
The CLI supports one root app and optional workspace apps:
- root app:
src/main.ts - workspace apps:
apps/<name>/src/main.ts - shared libraries:
libs/<name>/src/index.ts
Optional environment files are discovered automatically:
- root app:
.env - workspace apps:
apps/<name>/.env
Commands
Start every discovered app:
bunito startStart selected workspace apps, or include the root app with a selected set:
bunito start simple-controller
bunito start json-middleware multiple-apis
bunito start simple-controller --rootUseful start flags:
bunito start --watch
bunito start --prod
bunito start --label nameBuild every discovered app, selected workspace apps, or selected apps plus the root app:
bunito build
bunito build simple-controller --disable minify --disable sourcemap
bunito build simple-controller --rootGenerate files:
bunito init my-app
bunito init my-workspace --app api --app admin
bunito generate app worker
bunito generate lib shared-authUse --cwd when running the CLI from outside the project directory:
bunito --cwd examples/http start simple-controllerPackage Scripts
Each example workspace keeps scripts small:
{
"scripts": {
"cli": "bunito",
"build": "bunito build",
"start": "bunito start"
}
}Run all discovered apps in a multi-app example:
cd examples/http
bun run startRun one example app:
cd examples/http
bun run start json-middlewareBuild the examples:
cd examples/http
bun run buildRepository Examples
The repository keeps examples as separate workspaces:
examples/
basics/
src/main.ts
http/
apps/
json-middleware/
.env
src/main.ts
multiple-apis/
.env
src/main.ts
simple-controller/
.env
src/main.ts
cors-support/
.env
src/main.ts
microservices/
src/main.ts
apps/
foo/
.env
src/main.ts
bar/
.env
src/main.ts
monorepo/
src/main.ts
apps/
first/
src/main.ts
second/
src/main.ts
libs/
example/
src/index.ts.env files are app-local. For example, examples/http/apps/json-middleware/.env sets the port for only the json-middleware app. The CLI always passes the matching .env file when it starts an app.
The tutorials explain those apps step by step:
