Skip to main content

Command Overview

pb-cli provides six primary commands for managing the complete development lifecycle:

Default

Build frontend + start dev server

--install

Install dependencies + build + run

--build-only

Build frontend + generate specs

--run-only

Start server without building

--production

Full production build to dist/

--test-only

Run tests with coverage reports

Default Mode (Development)

What It Does

  1. Validates system requirements (Go, Node.js, npm)
  2. Builds frontend assets (npm run build)
  3. Copies build output to pb_public/
  4. Prepares server environment
  5. Starts development server (go run ./cmd/server --dev serve)

Use Cases

Use this as your primary development command. It ensures frontend changes are built before the server starts.
Server runs at http://127.0.0.1:8090 by default.
  • Admin panel: /_/
  • pb-ext dashboard: /_/_
When cloning a repository for the first time, use --install instead:

Output

In development mode, OpenAPI specs are generated at runtime via AST parsing—no disk files needed.

—install

What It Does

  1. Installs Go dependencies (go mod tidy, go mod download)
  2. Installs npm dependencies (npm ci or npm install)
  3. Builds frontend assets
  4. Starts development server

Use Cases

First command to run after cloning a repository:
When package.json or go.mod changes:
Reset dependencies after corruption or conflicts:

Dependency Installation Logic

Go Dependencies:
npm Dependencies (if package.json exists):

—build-only

What It Does

  1. Validates system requirements
  2. Builds frontend assets
  3. Generates OpenAPI specs (--generate-specs-dir)
  4. Validates OpenAPI specs (--validate-specs-dir)
  5. Exits without starting server

Use Cases

Build and validate assets in continuous integration:
Rebuild frontend after changes without restarting the server:Terminal 1:
Terminal 2 (when frontend changes):
Refresh browser to see changes.
Validate builds before committing:

OpenAPI Spec Generation

This command generates versioned OpenAPI JSON files:
Output:

—run-only

What It Does

  1. Validates system requirements
  2. Validates server setup (checks cmd/server/main.go)
  3. Prepares server environment (creates pb_public/ if missing)
  4. Starts development server without building frontend

Use Cases

When working exclusively on Go code:
No frontend build overhead—server starts immediately.
During debugging when frontend hasn’t changed:
Use with external frontend dev server:Terminal 1 (frontend dev server):
Terminal 2 (backend server):
Ensure pb_public/ contains valid frontend assets before using --run-only. If empty, your app may not load correctly.

—production

What It Does

  1. Cleans and creates dist/ directory
  2. Validates system requirements
  3. Installs dependencies (if --install also specified)
  4. Builds frontend for production
  5. Generates and validates OpenAPI specs
  6. Compiles optimized server binary
  7. Copies all assets to dist/
  8. Runs test suite with coverage
  9. Creates production archive (.tar.gz)

Use Cases

Create production-ready artifacts for deployment:
Deploy the dist/ directory to your server.
Automated release builds in CI/CD:
Specify a different output directory:
Output: release/ instead of dist/

Production Build Output

Binary Optimization

The production binary is compiled with:
Flags:
  • -s: Strip symbol table (reduces debugging info)
  • -w: Strip DWARF debugging information
Result: 30-50% smaller binary size
For deployment automation, see the pb-deployer project.

—test-only

What It Does

  1. Validates system requirements
  2. Auto-discovers test packages (walks project directory)
  3. Runs tests with coverage tracking
  4. 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

Use Cases

Verify all tests pass before committing:
Add to pre-commit hook:
Automated testing in continuous integration:
Generate detailed coverage reports:

Test Discovery

pb-cli automatically discovers test packages by:
  1. Walking the project directory
  2. Finding all *_test.go files
  3. Extracting unique package paths
  4. Skipping: vendor/, node_modules/, dist/, pb_data/, pb_public/, frontend/

Output Example

Report Formats

test-summary.txt:
test-report.json:
coverage.html:
Interactive HTML report with line-by-line coverage visualization

—help

Displays usage information and available commands:

Combining Flags

Install + Default

Installs dependencies, builds frontend, and starts server.

Production + Custom Output

Creates production build in release/ instead of dist/.

Troubleshooting

Problem: pb-cli: command not foundSolution: Ensure $GOPATH/bin is in your PATH:
Or use local execution:
Problem: npm run build failedSolution:
  1. Check package.json exists in frontend/
  2. Run npm install manually to check for errors
  3. Verify Node.js version: node --version
  4. Check build script exists in package.json:
Problem: go build failedSolution:
  1. Run go mod tidy to resolve dependencies
  2. Verify cmd/server/main.go exists
  3. Check Go version: go version (requires 1.19+)
  4. Review compiler errors for missing imports
Problem: permission denied when writing to pb_public/ or dist/Solution:
Problem: Tests pass locally but fail in CI pipelineSolution:
  1. Check for environment-specific dependencies
  2. Ensure CI uses same Go/Node versions:
  3. Review test isolation (check for shared state)

Next Steps

Build Pipeline

Deep dive into build orchestration internals

pb-cli Overview

Return to pb-cli overview

Quick Start

Get started with pb-ext development

Deployment

Deploy your production build