Cβ›ΊmpsiteJS
CLI Reference

Commands Reference

CLI Reference

Commands Reference

Detailed reference for all CampsiteJS CLI commands with examples and options.

Help & Version

camper --help / camper -h

Shows comprehensive help with all commands, examples, and descriptions.

camper --help

Output includes:

  • All available commands organized by category
  • Usage examples for each command
  • Command aliases and shortcuts
  • Tips for getting started

camper --version / camper -v

Displays the current version of basecampjs installed.

camper --version
# Output: 0.0.8

Project Initialization

camper init

Initializes Campsite in the current directory. This command sets up a minimal project structure for an existing directory.

camper init

What it creates:

  • src/pages/ - Directory for page content
  • src/layouts/ - Directory for layout templates
  • public/ - Directory for static assets
  • campsite.config.js - Configuration file
  • package.json - Node.js dependencies
  • .gitignore - Git ignore rules
  • Sample page and basic layout

Features:

  • Detects if already initialized and warns you
  • Creates sensible defaults based on detected template engine
  • Non-destructive (won’t overwrite existing files)

Example output:

πŸ•οΈ Initializing Campsite in current directory...
βœ… Created src/pages/
βœ… Created src/layouts/
βœ… Created public/
βœ… Created campsite.config.js
βœ… Created package.json
βœ… Created .gitignore
βœ… Created src/pages/index.njk
βœ… Created src/layouts/base.njk

🌲 Campsite initialized! Run 'camper dev' to start.

Development Commands

camper dev

Starts the development server with hot reloading. Watches src/ and public/ directories for changes.

camper dev

Features:

  • Hot module reloading
  • Auto-rebuild on file changes
  • Live browser refresh
  • Development-optimized builds (faster, unminified)
  • Detailed error messages

Default server:

  • URL: http://localhost:3000
  • Configurable port via config file

Example output:

πŸ•οΈ Starting Campsite dev server...
πŸ”₯ Watching for changes in src/ and public/
βœ… Dev server running at http://localhost:3000
🌲 Happy camping!

camper build

Creates an optimized production build. Outputs to dist/ (or configured outDir).

camper build

Production optimizations:

  • Minified HTML (if minifyHTML: true)
  • Minified CSS (if minifyCSS: true)
  • Cache-busted assets (if cacheBustAssets: true)
  • Optimized file structure
  • Static file copying

Example output:

πŸ•οΈ Building your Campsite...
πŸ“ Processing pages... (23 pages)
🎨 Processing layouts... (5 layouts)
🧩 Processing partials... (8 partials)
πŸ“¦ Processing collections... (3 collections)
βœ… Build complete! Output: ./dist/
🌲 Ready to deploy!

camper serve

Serves the built site from dist/ directory on http://localhost:4173.

camper serve

Use cases:

  • Preview production build locally
  • Test optimizations and minification
  • Verify cache-busting
  • Check relative paths

Example output:

πŸ•οΈ Serving built site from dist/
πŸ”₯ Server running at http://localhost:4173
πŸ—ΊοΈ Press Ctrl+C to stop

camper preview

Combines build + serve for quick production testing.

camper preview

Equivalent to:

camper build && camper serve

Utility Commands

camper clean

Removes the dist/ folder (or configured outDir) for fresh builds.

camper clean

Use cases:

  • Clean up before deployment
  • Resolve build caching issues
  • Free up disk space

Example output:

πŸ•οΈ Cleaning build directory...
βœ… Removed dist/
🌲 Fresh start ready!

camper check

Validates project structure, configuration, and dependencies.

camper check

Checks performed:

  • campsite.config.js exists and is valid
  • Required directories exist (src/pages, src/layouts)
  • Pages directory has content
  • Layouts directory has templates
  • package.json exists
  • Dependencies are installed

Example output:

πŸ•οΈ Checking Campsite project...
βœ… campsite.config.js found
βœ… src/pages/ directory exists (23 pages)
βœ… src/layouts/ directory exists (5 layouts)
βœ… package.json found
⚠️  Tip: Add src/partials/ for reusable components
βœ… Project structure looks good!
🌲 Happy camping!

camper list

Lists all content with counts organized by type.

camper list

Shows:

  • Pages (with file paths)
  • Layouts
  • Components
  • Partials
  • Collections
  • Data files

Example output:

πŸ•οΈ Campsite Content Overview

πŸ“ Pages (23):
  - src/pages/index.njk
  - src/pages/about.njk
  - src/pages/docs/index.md
  ...

🎨 Layouts (5):
  - src/layouts/base.njk
  - src/layouts/docs.njk
  ...

🧩 Partials (8):
  - src/partials/hero.njk
  - src/partials/navbar.njk
  ...

πŸ“¦ Collections (3):
  - src/collections/site.json
  - src/collections/navbar.json
  ...

🌲 Total: 39 files

camper upgrade

Updates basecampjs to the latest version.

camper upgrade

Process:

  1. Checks current version
  2. Fetches latest version from npm
  3. Runs npm install basecampjs@latest
  4. Shows new version

Example output:

πŸ•οΈ Checking for updates...
πŸ“¦ Current version: 0.0.7
πŸ“¦ Latest version: 0.0.8
⬆️ Upgrading basecampjs...
βœ… Successfully upgraded to 0.0.8
🌲 Enjoy the new features!

Next Steps


🧭 Quick Reference: Run camper --help anytime to see all commands!