@oalacea/daemon 0.7.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/prompts/DEPS_EFFICIENCY.md +558 -0
- package/dist/prompts/E2E.md +491 -0
- package/dist/prompts/EXECUTE.md +1060 -0
- package/dist/prompts/INTEGRATION_API.md +484 -0
- package/dist/prompts/INTEGRATION_DB.md +425 -0
- package/dist/prompts/PERF_API.md +433 -0
- package/dist/prompts/PERF_DB.md +430 -0
- package/dist/prompts/PERF_FRONT.md +357 -0
- package/dist/prompts/REMEDIATION.md +482 -0
- package/dist/prompts/UNIT.md +260 -0
- package/dist/templates/README.md +221 -0
- package/dist/templates/k6/load-test.js +54 -0
- package/dist/templates/nestjs/controller.spec.ts +203 -0
- package/dist/templates/nestjs/e2e/api.e2e-spec.ts +451 -0
- package/dist/templates/nestjs/e2e/auth.e2e-spec.ts +533 -0
- package/dist/templates/nestjs/fixtures/test-module.ts +311 -0
- package/dist/templates/nestjs/guard.spec.ts +314 -0
- package/dist/templates/nestjs/interceptor.spec.ts +458 -0
- package/dist/templates/nestjs/module.spec.ts +173 -0
- package/dist/templates/nestjs/pipe.spec.ts +474 -0
- package/dist/templates/nestjs/service.spec.ts +296 -0
- package/dist/templates/playwright/e2e.spec.ts +61 -0
- package/dist/templates/rust/Cargo.toml +72 -0
- package/dist/templates/rust/actix-controller.test.rs +114 -0
- package/dist/templates/rust/axum-handler.test.rs +117 -0
- package/dist/templates/rust/integration.test.rs +63 -0
- package/dist/templates/rust/rocket-route.test.rs +106 -0
- package/dist/templates/rust/unit.test.rs +38 -0
- package/dist/templates/vitest/angular-component.test.ts +38 -0
- package/dist/templates/vitest/api.test.ts +51 -0
- package/dist/templates/vitest/component.test.ts +27 -0
- package/dist/templates/vitest/hook.test.ts +36 -0
- package/dist/templates/vitest/solid-component.test.ts +34 -0
- package/dist/templates/vitest/svelte-component.test.ts +33 -0
- package/dist/templates/vitest/vue-component.test.ts +39 -0
- package/package.json +2 -2
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
# Frontend Performance Testing Guide (Lighthouse)
|
|
2
|
+
|
|
3
|
+
This prompt provides guidance for frontend performance analysis using Google Lighthouse.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Lighthouse analyzes web apps and web pages, collecting modern performance metrics and insights on developer best practices.
|
|
10
|
+
|
|
11
|
+
## Core Web Vitals
|
|
12
|
+
|
|
13
|
+
| Metric | Good | Needs Improvement | Poor |
|
|
14
|
+
|--------|------|-------------------|------|
|
|
15
|
+
| **LCP** (Largest Contentful Paint) | <2.5s | 2.5s - 4s | >4s |
|
|
16
|
+
| **FID** (First Input Delay) | <100ms | 100ms - 300ms | >300ms |
|
|
17
|
+
| **CLS** (Cumulative Layout Shift) | <0.1 | 0.1 - 0.25 | >0.25 |
|
|
18
|
+
|
|
19
|
+
## Running Lighthouse
|
|
20
|
+
|
|
21
|
+
### Quick Performance Audit
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000 --output=json --output=html --chrome-flags="--headless"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Mobile Audit
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000 --form-factor=mobile --screen-emulation=mobile --output=json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Desktop Audit
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000 --form-factor=desktop --output=json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Performance Only (Faster)
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000 --only-categories=performance --output=json
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### All Categories
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000 --only-categories=performance,accessibility,best-practices,seo --output=json
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### With Custom Output
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000 --output=json --output-path=/app/reports/lighthouse-$(date +%s).json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Reading Lighthouse Results
|
|
60
|
+
|
|
61
|
+
### Score Interpretation
|
|
62
|
+
|
|
63
|
+
- **90-100**: Green (Good)
|
|
64
|
+
- **50-89**: Orange (Needs Improvement)
|
|
65
|
+
- **0-49**: Red (Poor)
|
|
66
|
+
|
|
67
|
+
### Key Metrics
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
{
|
|
71
|
+
"categories": {
|
|
72
|
+
"performance": { "score": 0.85 }, // 85/100
|
|
73
|
+
"accessibility": { "score": 0.92 },
|
|
74
|
+
"best-practices": { "score": 0.90 },
|
|
75
|
+
"seo": { "score": 0.95 }
|
|
76
|
+
},
|
|
77
|
+
"audits": {
|
|
78
|
+
"largest-contentful-paint": {
|
|
79
|
+
"displayValue": "2.1 s",
|
|
80
|
+
"score": 0.92
|
|
81
|
+
},
|
|
82
|
+
"cumulative-layout-shift": {
|
|
83
|
+
"displayValue": "0.05",
|
|
84
|
+
"score": 1
|
|
85
|
+
},
|
|
86
|
+
"max-potential-fid": {
|
|
87
|
+
"displayValue": "56 ms",
|
|
88
|
+
"score": 1
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Common Performance Issues & Fixes
|
|
97
|
+
|
|
98
|
+
### 1. Render-Blocking Resources
|
|
99
|
+
|
|
100
|
+
**Issue**: CSS/JavaScript blocks page rendering
|
|
101
|
+
|
|
102
|
+
**Detection**: `render-blocking-resources` audit
|
|
103
|
+
|
|
104
|
+
**Fix**:
|
|
105
|
+
```html
|
|
106
|
+
<!-- Defer non-critical CSS -->
|
|
107
|
+
<link rel="preload" href="styles.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
|
|
108
|
+
|
|
109
|
+
<!-- Defer JavaScript -->
|
|
110
|
+
<script src="app.js" defer></script>
|
|
111
|
+
<script src="analytics.js" async></script>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 2. Unoptimized Images
|
|
115
|
+
|
|
116
|
+
**Issue**: Large images slow down LCP
|
|
117
|
+
|
|
118
|
+
**Detection**: `modern-image-formats`, `offscreen-images`, `scaled-images`
|
|
119
|
+
|
|
120
|
+
**Fix**:
|
|
121
|
+
```typescript
|
|
122
|
+
// Next.js
|
|
123
|
+
import Image from 'next/image';
|
|
124
|
+
|
|
125
|
+
<Image
|
|
126
|
+
src="/hero.jpg"
|
|
127
|
+
width={1920}
|
|
128
|
+
height={1080}
|
|
129
|
+
priority // For above-fold images
|
|
130
|
+
placeholder="blur"
|
|
131
|
+
/>
|
|
132
|
+
|
|
133
|
+
// Or use WebP/AVIF formats
|
|
134
|
+
<picture>
|
|
135
|
+
<source srcset="hero.webp" type="image/webp">
|
|
136
|
+
<img src="hero.jpg" alt="Hero" loading="lazy">
|
|
137
|
+
</picture>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 3. Unused JavaScript
|
|
141
|
+
|
|
142
|
+
**Issue**: Too much JS parsed/executed
|
|
143
|
+
|
|
144
|
+
**Detection**: `unused-javascript`
|
|
145
|
+
|
|
146
|
+
**Fix**:
|
|
147
|
+
- Code splitting: `import()` for routes
|
|
148
|
+
- Tree shaking: Remove unused exports
|
|
149
|
+
- Dynamic imports: Load heavy libs on demand
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
// Before
|
|
153
|
+
import { HeavyChart } from 'chart-library';
|
|
154
|
+
|
|
155
|
+
// After
|
|
156
|
+
const HeavyChart = lazy(() => import('chart-library'));
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 4. Unused CSS
|
|
160
|
+
|
|
161
|
+
**Issue**: Large CSS bundles
|
|
162
|
+
|
|
163
|
+
**Detection**: `unused-css-rules`
|
|
164
|
+
|
|
165
|
+
**Fix**:
|
|
166
|
+
- PurgeCSS/Tailwind purge
|
|
167
|
+
- CSS modules
|
|
168
|
+
- Critical CSS extraction
|
|
169
|
+
|
|
170
|
+
### 5. High CLS
|
|
171
|
+
|
|
172
|
+
**Issue**: Layout shifts during load
|
|
173
|
+
|
|
174
|
+
**Detection**: `cumulative-layout-shift`
|
|
175
|
+
|
|
176
|
+
**Fix**:
|
|
177
|
+
```css
|
|
178
|
+
/* Reserve space for images/ads */
|
|
179
|
+
.banner {
|
|
180
|
+
min-height: 250px;
|
|
181
|
+
position: relative;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* Skeleton loading */
|
|
185
|
+
.skeleton {
|
|
186
|
+
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
|
|
187
|
+
background-size: 200% 100%;
|
|
188
|
+
animation: shimmer 1.5s infinite;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 6. Text Compression
|
|
193
|
+
|
|
194
|
+
**Issue**: Assets not compressed
|
|
195
|
+
|
|
196
|
+
**Detection**: `text-compression`
|
|
197
|
+
|
|
198
|
+
**Fix**:
|
|
199
|
+
```nginx
|
|
200
|
+
# nginx.conf
|
|
201
|
+
gzip on;
|
|
202
|
+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
|
|
203
|
+
gzip_min_length 1000;
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Performance Budgets
|
|
209
|
+
|
|
210
|
+
Set budgets in `lighthouse.config.js`:
|
|
211
|
+
|
|
212
|
+
```javascript
|
|
213
|
+
module.exports = {
|
|
214
|
+
budgets: [
|
|
215
|
+
{
|
|
216
|
+
path: '/*.js',
|
|
217
|
+
maxSize: 200 * 1024, // 200 KB
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
path: '/*.css',
|
|
221
|
+
maxSize: 50 * 1024, // 50 KB
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
path: '/img/*',
|
|
225
|
+
maxSize: 300 * 1024, // 300 KB
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
};
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Run with config:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000 --config-path=/app/lighthouse.config.js
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## CI/CD Integration
|
|
240
|
+
|
|
241
|
+
### GitHub Actions Example
|
|
242
|
+
|
|
243
|
+
```yaml
|
|
244
|
+
name: Lighthouse CI
|
|
245
|
+
|
|
246
|
+
on: [push, pull_request]
|
|
247
|
+
|
|
248
|
+
jobs:
|
|
249
|
+
lighthouse:
|
|
250
|
+
runs-on: ubuntu-latest
|
|
251
|
+
steps:
|
|
252
|
+
- uses: actions/checkout@v3
|
|
253
|
+
- name: Run Lighthouse
|
|
254
|
+
run: |
|
|
255
|
+
npx lighthouse https://your-app.com --output=json --output=html --chrome-flags="--headless"
|
|
256
|
+
- name: Upload Report
|
|
257
|
+
uses: actions/upload-artifact@v3
|
|
258
|
+
with:
|
|
259
|
+
name: lighthouse-report
|
|
260
|
+
path: './*.html'
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Assert Scores
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
# Fail if performance score < 90
|
|
267
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000 --assertions.performance=0.9
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Multi-Page Testing
|
|
273
|
+
|
|
274
|
+
Test multiple routes:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Home
|
|
278
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000 --output=json --output-path=reports/home.json
|
|
279
|
+
|
|
280
|
+
# Product page
|
|
281
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000/products --output=json --output-path=reports/products.json
|
|
282
|
+
|
|
283
|
+
# Checkout
|
|
284
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000/checkout --output=json --output-path=reports/checkout.json
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## Troubleshooting
|
|
290
|
+
|
|
291
|
+
### Container Access Issues
|
|
292
|
+
|
|
293
|
+
If Lighthouse can't reach localhost:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# Use host.docker.internal (Mac/Windows) or host network (Linux)
|
|
297
|
+
docker exec daemon-tools npx lighthouse http://host.docker.internal:3000
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Timeout Errors
|
|
301
|
+
|
|
302
|
+
Increase timeout for slow apps:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000 --max-wait-for-load=45000
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Chrome Flags
|
|
309
|
+
|
|
310
|
+
For problematic environments:
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
docker exec daemon-tools npx lighthouse http://localhost:3000 --chrome-flags="--headless --no-sandbox --disable-gpu --disable-dev-shm-usage"
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Example Test Session
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
# 1. Ensure app is running locally
|
|
322
|
+
npm run dev
|
|
323
|
+
|
|
324
|
+
# 2. Run Lighthouse audit
|
|
325
|
+
docker exec daemon-tools npx lighthouse http://host.docker.internal:3000 --output=json --output=html
|
|
326
|
+
|
|
327
|
+
# 3. Check the report
|
|
328
|
+
cat lighthouse-report.json | jq '.categories'
|
|
329
|
+
|
|
330
|
+
# 4. View HTML report
|
|
331
|
+
open lighthouse-report.html # Mac
|
|
332
|
+
xdg-open lighthouse-report.html # Linux
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## Expected Output
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
Lighthouse Scores:
|
|
341
|
+
Performance: 85/100 ✓
|
|
342
|
+
Accessibility: 92/100 ✓
|
|
343
|
+
Best Practices: 90/100 ✓
|
|
344
|
+
SEO: 95/100 ✓
|
|
345
|
+
|
|
346
|
+
Core Web Vitals:
|
|
347
|
+
LCP: 2.1s ✓ (target: <2.5s)
|
|
348
|
+
FID: 56ms ✓ (target: <100ms)
|
|
349
|
+
CLS: 0.05 ✓ (target: <0.1)
|
|
350
|
+
|
|
351
|
+
Top Opportunities:
|
|
352
|
+
1. Serve images in next-gen formats (WebP/AVIF)
|
|
353
|
+
2. Eliminate render-blocking resources
|
|
354
|
+
3. Reduce unused JavaScript
|
|
355
|
+
4. Minify CSS
|
|
356
|
+
5. Enable text compression
|
|
357
|
+
```
|