MVP Build
This commit is contained in:
95
scripts/generate-feature-capsule.sh
Executable file
95
scripts/generate-feature-capsule.sh
Executable file
@@ -0,0 +1,95 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Color codes for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
FEATURE_NAME=$1
|
||||
if [ -z "$FEATURE_NAME" ]; then
|
||||
echo -e "${RED}Error: Feature name is required${NC}"
|
||||
echo "Usage: $0 <feature-name>"
|
||||
echo "Example: $0 user-settings"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Convert kebab-case to PascalCase and camelCase
|
||||
FEATURE_PASCAL=$(echo $FEATURE_NAME | sed -r 's/(^|-)([a-z])/\U\2/g')
|
||||
FEATURE_CAMEL=$(echo $FEATURE_PASCAL | sed 's/^./\l&/')
|
||||
|
||||
echo -e "${GREEN}Creating Modified Feature Capsule: $FEATURE_NAME${NC}"
|
||||
|
||||
# Backend Feature Capsule
|
||||
BACKEND_DIR="backend/src/features/$FEATURE_NAME"
|
||||
mkdir -p "$BACKEND_DIR"/{api,domain,data,migrations,external,events,tests/{unit,integration,fixtures},docs}
|
||||
|
||||
# Create Feature README
|
||||
cat > "$BACKEND_DIR/README.md" << EOF
|
||||
# $FEATURE_PASCAL Feature Capsule
|
||||
|
||||
## Quick Summary (50 tokens)
|
||||
[AI: Complete feature description, main operations, dependencies, caching strategy]
|
||||
|
||||
## API Endpoints
|
||||
- GET /api/$FEATURE_NAME - List all $FEATURE_NAME
|
||||
- GET /api/$FEATURE_NAME/:id - Get specific $FEATURE_CAMEL
|
||||
- POST /api/$FEATURE_NAME - Create new $FEATURE_CAMEL
|
||||
- PUT /api/$FEATURE_NAME/:id - Update $FEATURE_CAMEL
|
||||
- DELETE /api/$FEATURE_NAME/:id - Delete $FEATURE_CAMEL
|
||||
|
||||
## Structure
|
||||
- **api/** - HTTP endpoints, routes, validators
|
||||
- **domain/** - Business logic, types, rules
|
||||
- **data/** - Repository, database queries
|
||||
- **migrations/** - Feature-specific schema
|
||||
- **external/** - External API integrations
|
||||
- **events/** - Event handlers
|
||||
- **tests/** - All feature tests
|
||||
- **docs/** - Detailed documentation
|
||||
|
||||
## Dependencies
|
||||
- Internal: core/auth, core/cache
|
||||
- External: [List any external APIs]
|
||||
- Database: $FEATURE_NAME table
|
||||
|
||||
## Quick Commands
|
||||
\`\`\`bash
|
||||
# Run feature tests
|
||||
npm test -- features/$FEATURE_NAME
|
||||
|
||||
# Run feature migrations
|
||||
npm run migrate:feature $FEATURE_NAME
|
||||
\`\`\`
|
||||
EOF
|
||||
|
||||
# Create index.ts (Public API)
|
||||
cat > "$BACKEND_DIR/index.ts" << EOF
|
||||
/**
|
||||
* @ai-summary Public API for $FEATURE_NAME feature capsule
|
||||
* @ai-note This is the ONLY file other features should import from
|
||||
*/
|
||||
|
||||
// Export service for use by other features
|
||||
export { ${FEATURE_PASCAL}Service } from './domain/${FEATURE_CAMEL}.service';
|
||||
|
||||
// Export types needed by other features
|
||||
export type {
|
||||
${FEATURE_PASCAL},
|
||||
Create${FEATURE_PASCAL}Request,
|
||||
Update${FEATURE_PASCAL}Request,
|
||||
${FEATURE_PASCAL}Response
|
||||
} from './domain/${FEATURE_CAMEL}.types';
|
||||
|
||||
// Internal: Register routes with Express app
|
||||
export { register${FEATURE_PASCAL}Routes } from './api/${FEATURE_CAMEL}.routes';
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✅ Feature capsule created: $FEATURE_NAME${NC}"
|
||||
echo -e "${YELLOW}Next steps:${NC}"
|
||||
echo "1. Implement business logic in domain/${FEATURE_CAMEL}.service.ts"
|
||||
echo "2. Add database columns to migrations/"
|
||||
echo "3. Implement API validation"
|
||||
echo "4. Add tests"
|
||||
echo "5. Register routes in backend/src/app.ts"
|
||||
Reference in New Issue
Block a user