@bunary/cli
v0.4.6
Published
Bunary CLI: project scaffolding, make:* generators and a runner for app and package commands
Maintainers
Readme
@bunary/cli
Command-line interface for the Bunary framework: project scaffolding (init), make:* generators (make:route, make:middleware, make:command, make:provider) and a runner for your app's own commands and for commands contributed by installed @bunary/* packages. Migrations are delegated to drizzle-kit. Full reference: docs/index.md.
Installation
Globally, so bunary is on your PATH:
bun add -g @bunary/cli@^0.4.0Or per project, run with bunx bunary:
bun add @bunary/cli@^0.4.0Or use directly with bunx:
bunx @bunary/cli@^0.4.0 init my-appFrom source
npm may lag behind main. To run the current source:
git clone https://github.com/bunary-dev/cli.git && cd cli
bun install
bun run build # writes dist/
bun link # puts `bunary` on your PATH (via ~/.bun/bin)Standalone binary
A single executable with Bun and the stubs embedded, no node_modules needed:
bun build ./src/bin.ts --compile --outfile bunary
mv bunary ~/.local/bin/ # or anywhere on your PATHIf bunary still runs an old version, check which -a bunary: a global
bun add -g @bunary/cli in ~/.bun/bin can shadow it.
Quick start
bunary init my-app
cd my-app
bun install
bun run devRun bunary init with no name (or with -i) in a terminal to be prompted for the name and auth type. With Basic or JWT auth: bunary init my-app --auth basic or --auth jwt makes everything under /api (including GET /api/me) require credentials and answer 401 otherwise, while / and /health stay public; to protect more, put routes in a group with middleware: [basicMiddleware] (or jwtMiddleware). With --auth it also writes a .env.example (BASIC_AUTH_USER and BASIC_AUTH_PASSWORD, or JWT_SECRET of at least 32 characters, e.g. from openssl rand -base64 32): run cp .env.example .env and fill them in before bun run dev, or the app refuses to start. Every project gets a .gitignore that ignores .env. Adding auth to an existing project with bunary make:middleware basic or jwt creates or extends .env.example (only the missing keys) and .gitignore the same way, and prints the same cp .env.example .env step. init refuses to overwrite existing files (use --force to override), and every scaffolding command accepts --dry-run. For all commands, options, and generated file examples, see docs/index.md.
Database
The CLI ships no migration commands. With @bunary/orm installed, it contributes make:model and the db:* commands (thin wrappers over drizzle-kit), which then appear in bunary --help. Without it, use drizzle-kit directly: bunx drizzle-kit generate, bunx drizzle-kit migrate, bunx drizzle-kit studio.
Declaring flags in project commands
A flag in a CommandFlag definition is a boolean switch unless it takes a value: it never consumes the next argument, and --flag=value is rejected with an error. @bunary/core's CommandFlag has no takesValue, so declare a free-text flag with a value placeholder in its name, e.g. { name: "out <dir>", description: "Output directory" } for --out <dir>, or list the accepted values. See docs/index.md.
Requirements
- Bun ≥ 1.4.0
Contributing
See CONTRIBUTING.md.
License
MIT
