Quick Reference Guide
Get started with Scaffoldfy in minutes! This guide provides quick examples and essential commands to help you understand and use the library without reading all the documentation.
Table of Contents
Basic Usage
🚀 Quick Start with npx (No Installation Required)
# With custom tasks file
npx @pixpilot/scaffoldfy --config ./config.json
# Preview changes first (recommended)
npx @pixpilot/scaffoldfy --config ./config.json --dry-run
# With TypeScript tasks file
npx @pixpilot/scaffoldfy --config ./my-tasks.ts
CLI
Installation (Optional)
Optional: You can use npx (above) without installing anything. Or install for repeated use:
# Or install locally in your project
npm install --save-dev @pixpilot/scaffoldfy
# With custom tasks file
scaffoldfy --config ./config.json
# Preview changes without applying (dry-run mode)
scaffoldfy --config ./config.json --dry-run
# With TypeScript task file
scaffoldfy --config ./my-tasks.ts
Programmatic API
import { runWithTasks } from '@pixpilot/scaffoldfy';
// Run tasks
await runWithTasks(tasks, {
dryRun: false,
force: false,
configFilePath: './config.json',
});
Essential Task Types
1. Write Files - Create or overwrite files
{
"id": "create-readme",
"name": "Create README",
"type": "write",
"config": {
"file": "README.md",
"template": "# \n\nAuthor: "
}
}
2. Update JSON - Modify JSON files (merge or set values)
{
"id": "update-package",
"name": "Update package.json",
"type": "update-json",
"config": {
"file": "package.json",
"updates": {
"name": "",
"version": "1.0.0",
"author": ""
}
}
}
3. Copy Files - Copy files or directories
{
"id": "copy-template",
"name": "Copy template files",
"type": "copy",
"config": {
"source": "templates/",
"destination": "src/",
"overwrite": true
}
}
4. Execute Commands - Run shell commands
{
"id": "install-deps",
"name": "Install dependencies",
"type": "exec",
"config": {
"command": "npm install"
}
}
5. Delete Files - Remove files or directories
{
"id": "cleanup",
"name": "Remove temp files",
"type": "delete",
"config": {
"paths": ["temp/", "*.log"]
}
}
Quick Prompt Examples
Text Input
{
"id": "projectName",
"type": "input",
"message": "Project name",
"required": true,
"default": "my-project"
}
Confirmation (Yes/No)
{
"id": "useTypeScript",
"type": "confirm",
"message": "Use TypeScript?",
"default": true
}
Single Selection
{
"id": "framework",
"type": "select",
"message": "Choose a framework",
"choices": ["React", "Vue", "Angular", "Svelte"]
}
Multiple Selection
{
"id": "features",
"type": "multiselect",
"message": "Select features",
"choices": ["ESLint", "Prettier", "Jest", "Husky"]
}
Dynamic Default from Command
{
"id": "author",
"type": "input",
"message": "Author name",
"default": {
"type": "exec",
"value": "git config --get user.name"
}
}
Common Patterns
Complete Minimal Config
{
"$schema": "https://unpkg.com/@pixpilot/scaffoldfy/schema",
"prompts": [
{
"id": "projectName",
"type": "input",
"message": "Project name",
"required": true
}
],
"tasks": [
{
"id": "create-readme",
"name": "Create README",
"type": "write",
"config": {
"file": "README.md",
"template": "# \n\nA new project."
}
},
{
"id": "init-git",
"name": "Initialize Git",
"type": "git-init"
}
]
}
Conditional Task Execution
{
"id": "setup-typescript",
"name": "Setup TypeScript",
"type": "write",
"enabled": {
"type": "condition",
"value": "useTypeScript === true"
},
"config": {
"file": "tsconfig.json",
"template": "{\"compilerOptions\": {\"strict\": true}}"
}
}
Alternative formats:
{
"enabled": {
"type": "exec",
"value": "git rev-parse --is-inside-work-tree" // Execute command
}
}
Task with Dependencies
{
"id": "install-deps",
"name": "Install dependencies",
"type": "exec",
"dependencies": ["update-package"],
"config": {
"command": "npm install"
}
}
Using Variables (No User Input)
{
"variables": [
{
"id": "currentYear",
"value": {
"type": "exec",
"value": "date +%Y"
}
}
],
"tasks": [
{
"id": "add-license",
"name": "Add LICENSE",
"type": "write",
"config": {
"file": "LICENSE",
"template": "Copyright "
}
}
]
}
# Run with default config
scaffoldfy
# With custom config file
scaffoldfy --config ./config.json
# Dry run (preview changes)
scaffoldfy --dry-run
# Show version
scaffoldfy --version
# Show help
scaffoldfy --help
Options
--config <path> # Path to config file (JSON or TypeScript, default: ./configs-tasks.json)
--dry-run # Preview changes without applying them
--no-validate # Skip schema validation
--force # Force execution even if checks fail
Programmatic API
Basic Usage
import { runWithTasks } from '@pixpilot/scaffoldfy';
// Run with tasks array
await runWithTasks(tasks, {
dryRun: false,
force: false,
configFilePath: './configs-tasks.json',
});
With Options
await runWithTasks(tasks, {
dryRun: true, // Preview mode
force: false, // Don't force execution
configFilePath: './config.json',
variables: [], // Optional global variables
prompts: [], // Optional global prompts
});
Error Handling
import { runWithTasks } from '@pixpilot/scaffoldfy';
try {
await runWithTasks(tasks, {
dryRun: false,
configFilePath: './configs-tasks.json',
});
console.log('✅ Tasks completed successfully!');
} catch (error) {
console.error('❌ Task execution failed:', error.message);
}
Quick Tips
💡 Best Practices
- Always use
--dry-runfirst to preview changes - Use descriptive task IDs for better error messages
- Set
required: falsefor optional tasks, or use conditionalrequiredwith{ "type": "condition", "value": "expression" }for dynamic behavior - Use the typed format for
enabledandrequiredfields:{ "type": "condition"|"exec", "value": "..." } - Use dependencies to ensure tasks run in the correct order
- Validate your configuration with the JSON schema for IntelliSense
🔥 Common Gotchas
- Template syntax: Use `` not
${variableName} - File paths: Always use forward slashes
/even on Windows - JSON escaping: Escape quotes in JSON:
\"or use template files - Task order: Tasks run in array order unless dependencies specified
- Prompt IDs: Must be unique across all prompts
📦 Configurations File Formats
Scaffoldfy supports multiple formats:
- JSON:
.jsonfiles (most common) - TypeScript:
.tsfiles (for dynamic configurations) - Remote URLs: HTTP/HTTPS URLs (for shared configurations)
Next Steps
Learn More
- Getting Started Guide - Detailed installation and setup
- Task Types Reference - Complete list of all task types
- Interactive Prompts - Detailed prompt configuration
- Advanced Features - Conditional execution, Handlebars, etc.
Example Configurations
Check the examples/ directory for complete working configurations:
base-node-configuration.json- Basic Node.js projectconfiguration-tasks-with-handlebars.json- Using Handlebars configurationsconfiguration-tasks-with-inheritance.json- Configuration compositionconfiguration-tasks-with-plugin.json- Custom plugin example
Need Help?
- 📖 Full Documentation - Complete guides and references
- 🐛 Report Issues - Found a bug?
- 💬 GitHub Discussions - Ask questions
Ready to start? Run your first template:
scaffoldfy --config scaffoldfy.json --dry-run