Overview
pb-cli is the official build toolchain for pb-ext projects. It automates frontend builds, OpenAPI spec generation, server compilation, testing, and production deployments through a unified CLI interface.pb-cli handles the full development lifecycle from dependency installation to production-ready binaries.
Why pb-cli?
Manually coordinating frontend builds, Go compilation, OpenAPI spec generation, and test execution is error-prone and time-consuming. pb-cli provides:- Unified workflow: Single command for build + serve
- Smart detection: Auto-detects frontend type (npm, static, or none)
- OpenAPI automation: Generates and validates specs for production
- Production optimization: Stripped binaries with
-ldflags="-s -w" - Test automation: Full coverage reports with multiple formats
- CI/CD ready: Designed for automation pipelines
Installation
Global Installation (Recommended)
Install pb-cli as a global binary available anywhere on your system:Local Execution
Run directly from the pb-ext repository without installing:Programmatic Usage
Import as a package in your Go applications:Quick Start
Development Mode
Build frontend and start development server:- System validation (checks Go/Node/npm)
- Frontend build (
npm run build) - Assets deployment (copy to
pb_public/) - Server startup (
go run ./cmd/server --dev serve)
Install Dependencies
Install all project dependencies (Go modules + npm packages):Build Assets Only
Compile frontend and generate OpenAPI specs without starting the server:Start Server Only
Skip frontend build and start the development server immediately:Production Build
Create optimized production binary and assets:dist/ (customizable with --dist)
Run Tests
Execute test suite with coverage reports:System Requirements
Go
Version 1.19 or higher
Node.js
Version 16 or higher
npm
Version 8 or higher
Command Reference
For detailed command documentation, see:Commands
Complete command reference with examples and use cases
Build Pipeline
Deep dive into the build orchestration process
Key Features
Smart Frontend Detection
pb-cli automatically detects your frontend type:- npm-based: Runs
npm installandnpm run build, copies output topb_public/ - Static files: Directly copies files to
pb_public/ - No frontend: Skips frontend build steps
OpenAPI Spec Generation
For production builds, pb-cli:- Runs
go run ./cmd/server --generate-specs-dir ./core/server/api/specs - Validates generated specs with
--validate-specs-dir - Copies specs to
dist/specs/for disk-based loading
In development mode, specs are generated at runtime via AST parsing—no disk files needed.
Test Automation
When running tests (--test-only or during production builds):
- Auto-discovers test packages by walking the project directory
- Runs tests with structured output
- Generates multiple report formats:
test-summary.txt- Human-readable summarytest-report.json- Machine-readable JSONcoverage.html- Interactive HTML coverage reportcoverage-summary.txt- Function-level coverage breakdown
Production Optimization
Production builds (--production) create optimized binaries:
-s: Strip symbol table-w: Strip DWARF debugging info
Output Directories
Development Mode
Production Mode
Next Steps
Command Reference
Explore all available commands and flags
Build Pipeline
Understand the build orchestration internals
Quick Start Guide
Get started with pb-ext development
Deployment
Deploy your production build