Barodoc CLI
The barodoc CLI provides commands for development, building, and project management.
Installation
# Global install
npm install -g barodoc
# Or use via npx
npx barodoc serve
Quick mode vs full Astro project
- Quick mode: a folder with Markdown and
barodoc.config.jsononly (noastro.config.mjs). The CLI uses<dir>/.barodoc/as the Astro app root, runsnpm installthere on first run or when the dependency set changes, then startsastro dev/astro build. You need npm onPATHand network access for that install. - Full project: the directory contains
astro.config.mjs— Barodoc runs Astro against that project directly without the.barodoc/temp layout.
Commands
serve - Development Server
Start a development server with hot reload.
barodoc serve [dir] [options]
Arguments:
dir- Project directory (default:.)
Options:
| Option | Description | Default |
|---|---|---|
-p, --port <port> |
Port to listen on | 4321 |
-h, --host |
Expose to network | false |
-c, --config <file> |
Config file path | auto-detect |
Examples:
# Current directory
barodoc serve
# Specific directory
barodoc serve docs
# Custom port
barodoc serve --port 3000
# Expose to network
barodoc serve --host
build - Production Build
Build static files for deployment.
barodoc build [dir] [options]
Arguments:
dir- Project directory (default:.)
Options:
| Option | Description | Default |
|---|---|---|
-o, --output <dir> |
Output directory | dist |
-c, --config <file> |
Config file path | auto-detect |
Examples:
# Build current directory
barodoc build
# Build specific directory
barodoc build docs
# Custom output
barodoc build --output build
Output:
- Static HTML/CSS/JS in output directory
- Pagefind search index generated automatically
preview - Preview Build
Serve the production build locally for testing.
barodoc preview [dir] [options]
Arguments:
dir- Project directory (default:.)
Options:
| Option | Description | Default |
|---|---|---|
-p, --port <port> |
Port to listen on | 4321 |
-o, --output <dir> |
Build output directory | dist |
Example:
barodoc build && barodoc preview
create - New Project
Scaffold a new Barodoc documentation project.
barodoc create <name>
Arguments:
name- Project name (creates directory)
Example:
barodoc create my-docs
cd my-docs
barodoc serve
Generated structure:
my-docs/
├── barodoc.config.json
├── docs/
│ └── en/
│ ├── introduction.md
│ ├── quickstart.md
│ └── example-slides.md
├── public/
│ └── logo.svg
└── .gitignore
Auto-Detection
The CLI automatically detects project type:
| File Present | Mode | Behavior |
|---|---|---|
astro.config.mjs |
Full Custom | Runs astro dev/build directly |
| No astro config | Quick Mode | Creates temp Astro project in .barodoc/ |
Development Workflow
In Monorepo (Local Development)
# Run CLI with tsx (no build required)
pnpm barodoc serve docs
# With explicit path
pnpm barodoc build docs --output docs/dist
The monorepo root package.json has:
{
"scripts": {
"barodoc": "tsx packages/barodoc/src/cli.ts"
}
}
Published Package
# After npm install -g barodoc
barodoc serve
barodoc build
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (config not found, build failed, etc.) |
Environment Variables
| Variable | Description |
|---|---|
PORT |
Default port (overridden by --port) |
HOST |
Default host binding |
Troubleshooting
"Config file not found"
Ensure barodoc.config.json exists in the target directory:
# Check current directory
ls barodoc.config.json
# Or specify explicitly
barodoc serve --config ./my-config.json
Port already in use
barodoc serve --port 4322
Build fails with missing dependencies
For Quick Mode, ensure you have Node.js 20+ installed. For Full Custom Mode, run:
pnpm install # or npm install
Converted and distributed by TomeVault — claim your Tome and manage your conversions.