Package Exports
- create-precast-app
- create-precast-app/package.json
Readme
Create Precast App - Modern CLI Architecture
A powerful, extensible CLI for scaffolding modern web applications with a template-based architecture.
โจ Features
- ๐ฏ Template-Based Generation - Handlebars templates for maintainable code generation
- ๐ Plugin System - Extensible architecture with lifecycle hooks
- โ Smart Validation - Configuration compatibility checking with helpful errors
- ๐จ Beautiful CLI - Modern prompts with progress indicators
- ๐ณ Docker Support - Optional containerization for databases and apps
- ๐งช Comprehensive Testing - Test suite for all configuration combinations
๐ Quick Start
# Interactive mode
npx create-precast-app
# With options
npx create-precast-app my-app --framework react --backend express --database postgres
# Skip all prompts
npx create-precast-app my-app -y
๐ Available Options
Frameworks
react
- React with Vitevue
- Vue 3 (coming soon)angular
- Angular (coming soon)next
- Next.js (coming soon)nuxt
- Nuxt 3 (coming soon)svelte
- SvelteKit (coming soon)solid
- SolidJS (coming soon)astro
- Astro (coming soon)
Backends
express
- Express.js serverfastify
- Fastify serverhono
- Hono servernone
- Frontend only
Databases
postgres
- PostgreSQLmysql
- MySQLmongodb
- MongoDBsqlite
- SQLitesupabase
- Supabasefirebase
- Firebasenone
- No database
ORMs
prisma
- Prisma ORM (SQL databases + MongoDB)drizzle
- Drizzle ORM (SQL databases)mongoose
- Mongoose (MongoDB only)none
- No ORM
Styling
tailwind
- Tailwind CSScss
- Plain CSSscss
- SCSS/Sassstyled-components
- Styled Components
Additional Options
--typescript
/--no-typescript
- TypeScript support (default: true)--git
/--no-git
- Initialize git repository (default: true)--docker
- Include Docker configuration--install
- Install dependencies after creation--pm <manager>
- Package manager (npm, yarn, pnpm, bun)
๐ Security Features
- Automatic vulnerability scanning - Runs security audits after dependency installation
- Auto-fix vulnerabilities - Attempts to fix security issues automatically
- Secure dependency versions - All templates use the latest secure versions
- esbuild vulnerability mitigation - Automatic overrides for CVE-2024-23334
- Weekly dependency updates - Automated PRs for security updates
- Build-time security checks - Security audit runs during build process
See SECURITY.md for more details.
๐๏ธ Architecture
packages/cli/
โโโ src/
โ โโโ core/ # Core systems
โ โ โโโ template-engine.ts # Handlebars template processor
โ โ โโโ plugin-manager.ts # Plugin lifecycle management
โ โ โโโ config-validator.ts # Configuration validation
โ โโโ templates/ # Template files
โ โ โโโ frameworks/ # Framework-specific templates
โ โ โ โโโ react/ # React templates
โ โ โโโ features/ # Feature templates
โ โ โ โโโ auth/ # Authentication
โ โ โ โโโ testing/ # Testing setup
โ โ โ โโโ database/ # Database configs
โ โ โโโ base/ # Common templates
โ โโโ generators/ # Template generators
โ โโโ commands/ # CLI commands
โ โโโ plugins/ # Built-in plugins
๐๏ธ Database Configuration
How It Works
When you select a database, the CLI:
- Validates ORM compatibility
- Generates connection configuration in
.env.example
- Adds required dependencies
- Creates configuration files (Prisma schema, Drizzle config, etc.)
- Sets up Docker Compose (if Docker enabled)
PostgreSQL Example
When you select PostgreSQL with Prisma:
Generated .env.example
:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/myapp
Generated docker-compose.yml
:
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: myapp
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
Generated Scripts in package.json
:
{
"scripts": {
"db:generate": "prisma generate",
"db:migrate": "prisma migrate dev",
"db:push": "prisma db push",
"db:studio": "prisma studio"
}
}
Setting Up Your Database
Using Docker (Recommended):
# Start database docker-compose up -d # Run migrations npm run db:migrate
Using Local Database:
- Install PostgreSQL/MySQL/MongoDB
- Update DATABASE_URL in
.env
- Run migrations
๐งช Testing
Running Tests
# Build the CLI
npm run build
# Run all tests
npm test
# Run specific test
npm test -- --grep "PostgreSQL"
Test Coverage
The test suite covers:
- โ All framework combinations
- โ All database + ORM combinations
- โ TypeScript/JavaScript generation
- โ All styling options
- โ Docker configuration
- โ Git initialization
- โ Validation rules
๐ง Extending the CLI
See EXPANSION-GUIDE.md for detailed instructions on:
- Adding new frameworks
- Creating feature templates
- Writing plugins
- Testing new options
Quick Example: Adding a Feature
Create template structure:
src/templates/features/auth/ โโโ react/ โ โโโ src/ โ โ โโโ components/ โ โ โ โโโ LoginForm.tsx.hbs โ โ โโโ hooks/ โ โ โโโ useAuth.ts.hbs โ โโโ package.json.hbs
Update generator to use templates:
await templateEngine.processConditionalTemplates([ { condition: config.auth === true, sourceDir: "features/auth/react", destDir: "src", } ], projectPath, config);
๐ Template System
Handlebars Helpers
{{#if typescript}}
// TypeScript code
{{else}}
// JavaScript code
{{/if}}
{{#if (eq database "postgres")}}
DATABASE_URL=postgresql://...
{{/if}}
{{#ifAny (eq backend "express") (eq backend "fastify")}}
// Server code
{{/ifAny}}
Available Helpers
eq
- Equality checkand
,or
,not
- Logical operatorsincludes
- Array includesifAny
,ifAll
- Multiple conditionscapitalize
- Capitalize stringkebabCase
- Convert to kebab-case
๐ค Contributing
- Fork the repository
- Create your feature branch
- Add tests for new features
- Ensure all tests pass
- Submit a pull request
๐ License
MIT
Comparison with Original
Old Approach (String-based)
function generatePackageJson(config) {
return JSON.stringify({
name: config.name,
dependencies: {
react: "^18.2.0",
...(config.styling === "tailwind" && {
tailwindcss: "^3.0.0"
})
}
}, null, 2);
}
New Approach (Template-based)
{
"name": "{{name}}",
"dependencies": {
"react": "^18.3.1"
{{#if (eq styling "tailwind")}}
,"tailwindcss": "^3.4.0"
{{/if}}
}
}
Benefits
- โ Easier to maintain
- โ Version control friendly
- โ No string escaping issues
- โ Better IDE support
- โ Reusable templates