Project Scaffolding
Understand AgileBuilder's project generation capabilities
Overview
Project generation is AgileBuilder's core capability. Based on templates and variables, it generates standardized, reproducible project skeletons with a single command.
Core principle: Same template + Same parameters = Same project structure — reproducible every time.
Basic Usage
Generate Command
agilebuilder generate <template-name> <project-name>
Examples
# Generate a project using the react-starter template
agilebuilder generate react-starter my-app
# Specify output directory
agilebuilder generate react-starter ./projects/my-app
Generation with Variables
Command-line Variables
Use the --var flag to specify variable values:
agilebuilder generate react-starter my-app \
--var projectName=my-app \
--var useTypeScript=true \
--var packageManager=npm
Interactive Generation
Without variables, the command enters interactive问答 mode:
agilebuilder generate react-starter my-app
# Interactive prompts:
# ? Project name: my-app
# ? Use TypeScript: Yes
# ? Select package manager: npm
Generation Options
| Option | Description |
|---|---|
--var <key=value> | Specify variable value, can be used multiple times |
-y, --yes | Skip confirmation prompts |
--no-hooks | Skip hook execution |
--force | Force overwrite of existing directory |
Generation Flow
Project generation goes through these steps:
1. Parse template configuration
└── Read agilebuilder.json
└── Validate variable definitions
2. Collect variable values
└── Command-line arguments
└── Interactive input
└── Default values
3. Render template files
└── Variable substitution
└── Conditional rendering
└── Loop rendering
4. Execute pre-generate hooks
└── Validate environment
└── Prepare workspace
5. Output project files
└── Write to target directory
6. Execute post-generate hooks
└── Install dependencies
└── Initialize Git
└── Other initialization
Hooks Automation
After project generation, you can automatically execute initialization:
{
"hooks": {
"post-generate": [
"@agilebuilder/install-deps",
"@agilebuilder/git-init"
]
}
}
Common hooks:
@agilebuilder/install-deps- Automatically install dependencies@agilebuilder/git-init- Initialize a Git repository
Output Example
$ agilebuilder generate react-starter my-app
🚀 Generating project...
✓ Parsed template configuration
✓ Collected variable values
✓ Rendered template files (12 files)
✓ Executed pre-generate hooks
✓ Output project files
✓ Executed post-generate hooks
📦 Project generated: ./my-app
📦 Installing dependencies...
✓ Dependencies installed
✓ Git repository initialized
🎉 Project ready!
Next steps:
cd my-app
npm run dev
Next Steps
- Template System - Learn about complete template configuration
- Variable Reference - See all variable types
- Template Getting Started - Create your first template