Skip to content

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:

bash
bun install --global @bunito/cli

Run it without a global install through bunx:

bash
bunx @bunito/cli --help

Project 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:

bash
bunito start

Start selected workspace apps, or include the root app with a selected set:

bash
bunito start simple-controller
bunito start json-middleware multiple-apis
bunito start simple-controller --root

Useful start flags:

bash
bunito start --watch
bunito start --prod
bunito start --label name

Build every discovered app, selected workspace apps, or selected apps plus the root app:

bash
bunito build
bunito build simple-controller --disable minify --disable sourcemap
bunito build simple-controller --root

Generate files:

bash
bunito init my-app
bunito init my-workspace --app api --app admin
bunito generate app worker
bunito generate lib shared-auth

Use --cwd when running the CLI from outside the project directory:

bash
bunito --cwd examples/http start simple-controller

Package Scripts

Each example workspace keeps scripts small:

json
{
  "scripts": {
    "cli": "bunito",
    "build": "bunito build",
    "start": "bunito start"
  }
}

Run all discovered apps in a multi-app example:

bash
cd examples/http
bun run start

Run one example app:

bash
cd examples/http
bun run start json-middleware

Build the examples:

bash
cd examples/http
bun run build

Repository Examples

The repository keeps examples as separate workspaces:

text
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: