UNPKG

aem-component-generator

Version:

AI-powered AEM component generator that creates React components, Sling models, dialogs, and comprehensive test suites using Google Gemini AI

136 lines (103 loc) โ€ข 3.83 kB
# AEM Component Generator ๐Ÿš€ **AI-powered AEM component generator** that creates complete Adobe Experience Manager components with React/TypeScript frontend, Java Sling models, AEM dialogs, and comprehensive test suites using Google Gemini AI. ## Features โœจ **Complete Component Generation:** - React/TypeScript components with SCSS styling - Java Sling Models with proper annotations - AEM Touch UI dialogs - HTL (HTML Template Language) templates ๐Ÿงช **Comprehensive Testing:** - Frontend unit tests (Jest + React Testing Library) - Storybook stories for interactive documentation - Backend unit tests (JUnit 5 + Mockito) - Integration tests with AEM Testing Client ๐Ÿค– **AI-Powered:** - Uses Google Gemini AI to intelligently parse component requirements - Generates appropriate field types and validation - Creates realistic test data and scenarios ## Installation ### Global Installation (Recommended) ```bash npm install -g aem-component-generator ``` ### Local Installation ```bash npm install aem-component-generator npx aem-component-generator "your component description" ``` ## Prerequisites 1. **Google Gemini API Key** - Get one from [Google AI Studio](https://makersuite.google.com/app/apikey) 2. **Node.js 16+** 3. **AEM Project** - Works with AEM Maven Archetype projects ## Quick Start 1. **Set your Gemini API Key:** ```bash # Windows PowerShell $env:GEMINI_API_KEY="your-api-key-here" # macOS/Linux export GEMINI_API_KEY="your-api-key-here" ``` 2. **Generate a component:** ```bash aem-gen "Hero Banner with title, subtitle, background image, and CTA button" ``` 3. **View generated files:** ``` ui.frontend/src/main/webpack/components/heroBanner/ ui.apps/src/main/content/jcr_root/apps/myproject/components/heroBanner/ core/src/main/java/com/myproject/core/models/ # ... plus comprehensive test files ``` ## Examples ### Simple Components ```bash # Product card aem-gen "Product Card with image, title, price, and description" # Contact form aem-gen "Contact Form with name, email, phone, and message fields" ``` ### Complex Components ```bash # News article with rich content aem-gen "News Article with title, author, publish date, content, featured image, and tags" # User profile with avatar aem-gen "User Profile Card with avatar, name, email, role, bio, and social links" ``` ## Generated Structure The generator creates a complete AEM component following Maven archetype standards: ``` your-aem-project/ โ”œโ”€โ”€ ui.frontend/src/ โ”‚ โ”œโ”€โ”€ main/webpack/components/{componentName}/ โ”‚ โ”‚ โ”œโ”€โ”€ {ComponentName}.tsx # React component โ”‚ โ”‚ โ””โ”€โ”€ {ComponentName}.scss # Styles โ”‚ โ””โ”€โ”€ test/components/{componentName}/ โ”‚ โ”œโ”€โ”€ {ComponentName}.test.tsx # Unit tests โ”‚ โ””โ”€โ”€ {ComponentName}.stories.tsx # Storybook stories โ”œโ”€โ”€ ui.apps/src/main/content/jcr_root/apps/myproject/components/{componentName}/ โ”‚ โ”œโ”€โ”€ _cq_dialog/.content.xml # AEM dialog โ”‚ โ””โ”€โ”€ {componentName}.html # HTL template โ”œโ”€โ”€ core/src/ โ”‚ โ”œโ”€โ”€ main/java/{package}/{ComponentName}.java # Sling model โ”‚ โ””โ”€โ”€ test/java/{package}/{ComponentName}Test.java # Unit tests โ””โ”€โ”€ it.tests/src/main/java/{package}/it/{ComponentName}IT.java # Integration tests ``` ## Troubleshooting ### Common Issues **API Key Not Set** ``` Error: GEMINI_API_KEY environment variable is not set. ``` Solution: Set your Gemini API key as shown in Quick Start. **Network/SSL Issues** ``` TypeError: fetch failed ``` Solution: For corporate networks, set `NODE_TLS_REJECT_UNAUTHORIZED=0` **API Rate Limiting** ``` The model is overloaded. Please try again later. ``` Solution: Wait a moment and retry, or try during off-peak hours. ## License MIT