Spaces:
Paused
Paused
File size: 5,659 Bytes
21cac8a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | # UX Analyst CLI
A command-line interface for AI-powered UX analysis of websites.
## Installation
### Option 1: NPM Package (Recommended)
```bash
# Install globally
npm install -g ux-analyst-cli
# Or run directly with npx
npx ux-analyst-cli https://example.com
```
### Option 2: Local Development
```bash
# Clone and install dependencies
cd ux-analyst-ai/cli
npm install
# Link for global use
npm link
# Or run directly
node bin/ux-analyze.js https://example.com
```
## Quick Start
```bash
# Basic analysis
ux-analyze https://example.com
# Interactive mode
ux-analyze interactive
# Quick analysis with code generation
ux-analyze https://example.com --quick --code
# Full analysis with custom output
ux-analyze https://example.com --format html --output ./my-analysis
```
## Commands
### `ux-analyze <url> [options]`
Analyze a website and generate UX recommendations.
**Arguments:**
- `<url>` - Website URL to analyze
**Options:**
- `-o, --output <dir>` - Output directory (default: `./ux-analysis`)
- `-f, --format <format>` - Output format: `json`, `html`, `markdown` (default: `json`)
- `-v, --viewports <list>` - Comma-separated viewports (default: `desktop,tablet,mobile`)
- `--quick` - Run quick analysis (faster, less detailed)
- `--code` - Generate implementation code
- `--accessibility` - Include accessibility analysis
- `--config <file>` - Configuration file path
- `--api-key <key>` - Gemini API key
**Examples:**
```bash
# Comprehensive analysis
ux-analyze https://mysite.com --format html --code --accessibility
# Quick mobile-only analysis
ux-analyze https://mysite.com --quick --viewports mobile
# Custom output location
ux-analyze https://mysite.com --output /path/to/results
```
### `ux-analyze interactive`
Interactive mode with guided prompts.
```bash
ux-analyze interactive
# or
ux-analyze i
```
### `ux-analyze config`
Configure CLI settings (API key, defaults).
```bash
ux-analyze config
```
## Configuration
### Environment Variables
```bash
# Required: Gemini API key
export GEMINI_API_KEY="your-api-key-here"
```
### Configuration File
Create a `ux-config.json` file:
```json
{
"ai": {
"geminiApiKey": "your-api-key"
},
"defaults": {
"viewports": ["desktop", "tablet", "mobile"],
"outputFormat": "html",
"includeCode": true,
"includeAccessibility": true
}
}
```
Use with: `ux-analyze https://example.com --config ux-config.json`
## Output Formats
### JSON (Machine-readable)
```bash
ux-analyze https://example.com --format json
```
- Raw analysis data
- Perfect for CI/CD integration
- Parseable by other tools
### HTML (Human-readable)
```bash
ux-analyze https://example.com --format html
```
- Beautiful visual reports
- Screenshots included
- Implementation code embedded
### Markdown (Documentation-friendly)
```bash
ux-analyze https://example.com --format markdown
```
- README-compatible format
- Great for documentation
- Version control friendly
## Integration Examples
### CI/CD Pipeline
```yaml
# GitHub Actions example
- name: UX Analysis
run: |
npx ux-analyst-cli https://my-staging-site.com \
--format json \
--output ./ux-reports \
--quick
# Upload results as artifacts
- uses: actions/upload-artifact@v3
with:
name: ux-analysis
path: ./ux-reports
```
### NPM Scripts
```json
{
"scripts": {
"ux-check": "ux-analyze https://localhost:3000 --quick",
"ux-full": "ux-analyze https://localhost:3000 --code --accessibility",
"ux-mobile": "ux-analyze https://localhost:3000 --viewports mobile --quick"
}
}
```
### Automated Reports
```bash
#!/bin/bash
# analyze-sites.sh
sites=(
"https://example.com"
"https://staging.example.com"
"https://dev.example.com"
)
for site in "${sites[@]}"; do
echo "Analyzing $site..."
ux-analyze "$site" --format html --output "./reports/$(basename $site)"
done
```
## Features
### π **Fast Analysis**
- Quick mode for CI/CD pipelines
- Progressive analysis with real-time updates
### π― **Comprehensive Reports**
- UX recommendations with AI insights
- Accessibility compliance checking
- Multi-viewport screenshot capture
### π» **Implementation Ready**
- Generate HTML, CSS, JavaScript fixes
- Step-by-step implementation guides
- Copy-paste ready code snippets
### π§ **Developer Friendly**
- Multiple output formats
- Easy CI/CD integration
- Configurable analysis options
### π **Multiple Viewports**
- Desktop, tablet, mobile analysis
- Responsive design insights
- Cross-device compatibility checking
## API Integration
The CLI can also be used programmatically:
```javascript
const { UXAnalyzer } = require('ux-analyst-cli');
const analyzer = new UXAnalyzer({
ai: { geminiApiKey: process.env.GEMINI_API_KEY }
});
const result = await analyzer.analyze('https://example.com', {
viewports: ['desktop', 'mobile'],
includeCodeGeneration: true
});
console.log('UX Score:', result.report.summary.uxScore);
```
## Troubleshooting
### Common Issues
**"API key is required"**
```bash
# Set environment variable
export GEMINI_API_KEY="your-key"
# Or use --api-key flag
ux-analyze https://example.com --api-key "your-key"
```
**"Analysis timeout"**
```bash
# Use quick mode for faster analysis
ux-analyze https://example.com --quick
# Or increase timeout in config
```
**"Permission denied"**
```bash
# Make sure the CLI is executable
chmod +x bin/ux-analyze.js
# Or run with node directly
node bin/ux-analyze.js https://example.com
```
## Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request
## License
MIT License - see LICENSE file for details. |