Skip to main content

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

Install pb-cli as a global binary available anywhere on your system:
Verify installation:
Ensure $GOPATH/bin or $HOME/go/bin is in your PATH:

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:
This runs:
  1. System validation (checks Go/Node/npm)
  2. Frontend build (npm run build)
  3. Assets deployment (copy to pb_public/)
  4. 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:
Output directory: 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
pb-cli automatically validates system requirements before executing operations.

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 install and npm run build, copies output to pb_public/
  • Static files: Directly copies files to pb_public/
  • No frontend: Skips frontend build steps

OpenAPI Spec Generation

For production builds, pb-cli:
  1. Runs go run ./cmd/server --generate-specs-dir ./core/server/api/specs
  2. Validates generated specs with --validate-specs-dir
  3. 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 summary
    • test-report.json - Machine-readable JSON
    • coverage.html - Interactive HTML coverage report
    • coverage-summary.txt - Function-level coverage breakdown

Production Optimization

Production builds (--production) create optimized binaries:
Flags:
  • -s: Strip symbol table
  • -w: Strip DWARF debugging info
Result: Significantly smaller binary size

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