How It Works
Understanding how the CLI scaffolds your project.
Architecture Overview
Section titled “Architecture Overview”User runs CLI │ ▼Interactive wizard collects preferences │ ▼Downloads FULL Velocity repo from GitHub (via giget) │ ▼Applies local template overlays (i18n, base) │ ▼Configures based on wizard answers (or flags) │ ▼Installs dependenciesThe CLI guides you through an interactive wizard, then downloads the complete Velocity repository at runtime and applies configuration overlays based on your selections.
8-Step Scaffolding Process
Section titled “8-Step Scaffolding Process”-
Download template
Fetches Velocity from GitHub via
giget, ensuring you get the latest version. -
Configure components
Filters components based on your
--componentsselection. Removes unused component files. -
Apply i18n overlay
If
--i18nis enabled, adds locale routing, translations, and language switcher. -
Remove demo content
If
--demo=false, strips demo landing page and sample blog posts. -
Generate pages
If
--pagesis enabled, creates starter pages based on your interactive selections. -
Update package.json
Sets project name and removes CLI-specific metadata.
-
Initialize git
Creates a new git repository with an initial commit.
-
Install dependencies
Runs your package manager’s install command.
Template Overlay System
Section titled “Template Overlay System”The CLI uses a template overlay approach where files are applied in layers:
Base Velocity
Section titled “Base Velocity”Downloaded from GitHub. Contains all components, layouts, and features.
i18n Overlay
Section titled “i18n Overlay”When --i18n is enabled, overlays:
- Locale-prefixed route structure
- Translation configuration
- Language switcher component
- i18n-aware layouts
Base Template
Section titled “Base Template”For non-demo projects, provides minimal pages:
- Homepage
- About page
- Contact page
- 404 page
Overlays are applied in order, with later files overwriting earlier ones.
Component Registry
Section titled “Component Registry”Components are managed via component-registry.json in the Velocity repository:
{ "components": { "Button": { "files": ["src/components/ui/Button.astro"], "category": "ui", "dependencies": [] }, "ContactForm": { "files": ["src/components/patterns/ContactForm.astro"], "category": "patterns", "dependencies": ["Button", "Input", "Textarea"] } }}Registry Structure
Section titled “Registry Structure”| Field | Description |
|---|---|
files | Component file paths |
category | Category grouping (ui, patterns, hero) |
dependencies | Required components |
Dependency Resolution
Section titled “Dependency Resolution”When you select a category, the CLI:
- Identifies all components in that category
- Resolves dependencies recursively
- Includes required utility files (like
cn.ts) - Removes unused components
File Operations
Section titled “File Operations”Kept Always
Section titled “Kept Always”These files are never removed:
src/layouts/— All layoutssrc/components/layout/— Header, Footer, ThemeTogglesrc/components/seo/— SEO, JsonLd, Breadcrumbssrc/lib/— Utility functionssrc/styles/— Global styles and tokenssrc/config/— Configuration files
Conditionally Removed
Section titled “Conditionally Removed”Based on your selections:
- Demo landing page (if
--demo=false) - Sample blog posts (if
--demo=false) - Component categories (based on
--components) - i18n files (if
--i18n=false)
Package Manager Detection
Section titled “Package Manager Detection”The CLI automatically detects your package manager:
# Detects based on lock filespnpm-lock.yaml → pnpmyarn.lock → yarnpackage-lock.json → npmbun.lockb → bun
# Or from the command usedpnpm create velocity-astro → pnpmnpm create velocity-astro → npm