dev-booster 1.0.0
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/README.md +203 -0
- package/bin/dev-booster.js +4 -0
- package/package.json +41 -0
- package/src/index.js +78 -0
- package/src/sync-template.js +55 -0
- package/template/.devbooster/MANIFEST.md +177 -0
- package/template/.devbooster/boosters/accessibility.md +63 -0
- package/template/.devbooster/boosters/advisor.md +68 -0
- package/template/.devbooster/boosters/atomic.md +58 -0
- package/template/.devbooster/boosters/backend.md +75 -0
- package/template/.devbooster/boosters/changelog.md +126 -0
- package/template/.devbooster/boosters/create.md +85 -0
- package/template/.devbooster/boosters/debug.md +55 -0
- package/template/.devbooster/boosters/deploy.md +11 -0
- package/template/.devbooster/boosters/design.md +56 -0
- package/template/.devbooster/boosters/discovery.md +75 -0
- package/template/.devbooster/boosters/documentation.md +106 -0
- package/template/.devbooster/boosters/frontend.md +82 -0
- package/template/.devbooster/boosters/i18n.md +63 -0
- package/template/.devbooster/boosters/implementation.md +82 -0
- package/template/.devbooster/boosters/investigation.md +96 -0
- package/template/.devbooster/boosters/mobile.md +56 -0
- package/template/.devbooster/boosters/performance.md +70 -0
- package/template/.devbooster/boosters/planning.md +92 -0
- package/template/.devbooster/boosters/refactor.md +17 -0
- package/template/.devbooster/boosters/review.md +88 -0
- package/template/.devbooster/boosters/security.md +60 -0
- package/template/.devbooster/boosters/seo.md +59 -0
- package/template/.devbooster/boosters/templates/implementation_heavy.md +130 -0
- package/template/.devbooster/boosters/templates/implementation_simple.md +109 -0
- package/template/.devbooster/boosters/templates/implementation_standard.md +134 -0
- package/template/.devbooster/boosters/testing.md +76 -0
- package/template/.devbooster/hub/personas/agent_backend-specialist.md +263 -0
- package/template/.devbooster/hub/personas/agent_code-archaeologist.md +106 -0
- package/template/.devbooster/hub/personas/agent_database-architect.md +226 -0
- package/template/.devbooster/hub/personas/agent_debugger.md +225 -0
- package/template/.devbooster/hub/personas/agent_devops-engineer.md +242 -0
- package/template/.devbooster/hub/personas/agent_documentation-writer.md +104 -0
- package/template/.devbooster/hub/personas/agent_explorer-agent.md +73 -0
- package/template/.devbooster/hub/personas/agent_frontend-specialist.md +593 -0
- package/template/.devbooster/hub/personas/agent_game-developer.md +162 -0
- package/template/.devbooster/hub/personas/agent_mobile-developer.md +377 -0
- package/template/.devbooster/hub/personas/agent_orchestrator.md +416 -0
- package/template/.devbooster/hub/personas/agent_penetration-tester.md +188 -0
- package/template/.devbooster/hub/personas/agent_performance-optimizer.md +187 -0
- package/template/.devbooster/hub/personas/agent_product-manager.md +112 -0
- package/template/.devbooster/hub/personas/agent_product-owner.md +95 -0
- package/template/.devbooster/hub/personas/agent_project-planner.md +406 -0
- package/template/.devbooster/hub/personas/agent_qa-automation-engineer.md +103 -0
- package/template/.devbooster/hub/personas/agent_security-auditor.md +170 -0
- package/template/.devbooster/hub/personas/agent_seo-specialist.md +111 -0
- package/template/.devbooster/hub/personas/agent_test-engineer.md +158 -0
- package/template/.devbooster/hub/personas/backend-specialist.md +263 -0
- package/template/.devbooster/hub/personas/brainstorm.md +113 -0
- package/template/.devbooster/hub/personas/code-archaeologist.md +106 -0
- package/template/.devbooster/hub/personas/create.md +59 -0
- package/template/.devbooster/hub/personas/database-architect.md +226 -0
- package/template/.devbooster/hub/personas/debug.md +103 -0
- package/template/.devbooster/hub/personas/debugger.md +225 -0
- package/template/.devbooster/hub/personas/deploy.md +176 -0
- package/template/.devbooster/hub/personas/devops-engineer.md +242 -0
- package/template/.devbooster/hub/personas/documentation-writer.md +104 -0
- package/template/.devbooster/hub/personas/enhance.md +63 -0
- package/template/.devbooster/hub/personas/explorer-agent.md +73 -0
- package/template/.devbooster/hub/personas/frontend-specialist.md +593 -0
- package/template/.devbooster/hub/personas/game-developer.md +162 -0
- package/template/.devbooster/hub/personas/mobile-developer.md +377 -0
- package/template/.devbooster/hub/personas/orchestrate.md +237 -0
- package/template/.devbooster/hub/personas/orchestrator.md +416 -0
- package/template/.devbooster/hub/personas/penetration-tester.md +188 -0
- package/template/.devbooster/hub/personas/performance-optimizer.md +187 -0
- package/template/.devbooster/hub/personas/plan.md +89 -0
- package/template/.devbooster/hub/personas/preview.md +81 -0
- package/template/.devbooster/hub/personas/product-manager.md +112 -0
- package/template/.devbooster/hub/personas/product-owner.md +95 -0
- package/template/.devbooster/hub/personas/project-planner.md +406 -0
- package/template/.devbooster/hub/personas/qa-automation-engineer.md +103 -0
- package/template/.devbooster/hub/personas/security-auditor.md +170 -0
- package/template/.devbooster/hub/personas/seo-specialist.md +111 -0
- package/template/.devbooster/hub/personas/skill_api-patterns.md +567 -0
- package/template/.devbooster/hub/personas/skill_app-builder.md +1855 -0
- package/template/.devbooster/hub/personas/skill_architecture.md +417 -0
- package/template/.devbooster/hub/personas/skill_bash-linux.md +199 -0
- package/template/.devbooster/hub/personas/skill_behavioral-modes.md +242 -0
- package/template/.devbooster/hub/personas/skill_brainstorming.md +519 -0
- package/template/.devbooster/hub/personas/skill_clean-code.md +201 -0
- package/template/.devbooster/hub/personas/skill_code-review-checklist.md +109 -0
- package/template/.devbooster/hub/personas/skill_database-design.md +340 -0
- package/template/.devbooster/hub/personas/skill_deployment-procedures.md +241 -0
- package/template/.devbooster/hub/personas/skill_doc.md +177 -0
- package/template/.devbooster/hub/personas/skill_documentation-templates.md +194 -0
- package/template/.devbooster/hub/personas/skill_frontend-design.md +3670 -0
- package/template/.devbooster/hub/personas/skill_game-development.md +167 -0
- package/template/.devbooster/hub/personas/skill_geo-fundamentals.md +156 -0
- package/template/.devbooster/hub/personas/skill_i18n-localization.md +154 -0
- package/template/.devbooster/hub/personas/skill_intelligent-routing.md +335 -0
- package/template/.devbooster/hub/personas/skill_lint-and-validate.md +45 -0
- package/template/.devbooster/hub/personas/skill_mcp-builder.md +176 -0
- package/template/.devbooster/hub/personas/skill_mobile-design.md +6150 -0
- package/template/.devbooster/hub/personas/skill_nextjs-react-expert.md +3487 -0
- package/template/.devbooster/hub/personas/skill_nodejs-best-practices.md +333 -0
- package/template/.devbooster/hub/personas/skill_parallel-agents.md +175 -0
- package/template/.devbooster/hub/personas/skill_performance-profiling.md +143 -0
- package/template/.devbooster/hub/personas/skill_plan-writing.md +152 -0
- package/template/.devbooster/hub/personas/skill_powershell-windows.md +167 -0
- package/template/.devbooster/hub/personas/skill_python-patterns.md +441 -0
- package/template/.devbooster/hub/personas/skill_red-team-tactics.md +199 -0
- package/template/.devbooster/hub/personas/skill_rust-pro.md +176 -0
- package/template/.devbooster/hub/personas/skill_seo-fundamentals.md +129 -0
- package/template/.devbooster/hub/personas/skill_server-management.md +161 -0
- package/template/.devbooster/hub/personas/skill_systematic-debugging.md +109 -0
- package/template/.devbooster/hub/personas/skill_tailwind-patterns.md +269 -0
- package/template/.devbooster/hub/personas/skill_tdd-workflow.md +149 -0
- package/template/.devbooster/hub/personas/skill_testing-patterns.md +178 -0
- package/template/.devbooster/hub/personas/skill_vulnerability-scanner.md +403 -0
- package/template/.devbooster/hub/personas/skill_web-design-guidelines.md +57 -0
- package/template/.devbooster/hub/personas/skill_webapp-testing.md +187 -0
- package/template/.devbooster/hub/personas/status.md +86 -0
- package/template/.devbooster/hub/personas/test-engineer.md +158 -0
- package/template/.devbooster/hub/personas/test.md +144 -0
- package/template/.devbooster/hub/personas/ui-ux-pro-max.md +296 -0
- package/template/.devbooster/hub/scripts/accessibility_checker.py +183 -0
- package/template/.devbooster/hub/scripts/api_validator.py +211 -0
- package/template/.devbooster/hub/scripts/auto_preview.py +148 -0
- package/template/.devbooster/hub/scripts/checklist.py +217 -0
- package/template/.devbooster/hub/scripts/convert_rules.py +222 -0
- package/template/.devbooster/hub/scripts/geo_checker.py +289 -0
- package/template/.devbooster/hub/scripts/i18n_checker.py +241 -0
- package/template/.devbooster/hub/scripts/lighthouse_audit.py +76 -0
- package/template/.devbooster/hub/scripts/lint_runner.py +184 -0
- package/template/.devbooster/hub/scripts/mobile_audit.py +670 -0
- package/template/.devbooster/hub/scripts/playwright_runner.py +173 -0
- package/template/.devbooster/hub/scripts/react_performance_checker.py +252 -0
- package/template/.devbooster/hub/scripts/schema_validator.py +172 -0
- package/template/.devbooster/hub/scripts/security_scan.py +458 -0
- package/template/.devbooster/hub/scripts/seo_checker.py +219 -0
- package/template/.devbooster/hub/scripts/session_manager.py +120 -0
- package/template/.devbooster/hub/scripts/test_runner.py +219 -0
- package/template/.devbooster/hub/scripts/type_coverage.py +173 -0
- package/template/.devbooster/hub/scripts/ux_audit.py +722 -0
- package/template/.devbooster/hub/scripts/verify_all.py +327 -0
- package/template/.devbooster/hub/skills/api-patterns/SKILL.md +81 -0
- package/template/.devbooster/hub/skills/api-patterns/api-style.md +42 -0
- package/template/.devbooster/hub/skills/api-patterns/auth.md +24 -0
- package/template/.devbooster/hub/skills/api-patterns/documentation.md +26 -0
- package/template/.devbooster/hub/skills/api-patterns/graphql.md +41 -0
- package/template/.devbooster/hub/skills/api-patterns/rate-limiting.md +31 -0
- package/template/.devbooster/hub/skills/api-patterns/response.md +37 -0
- package/template/.devbooster/hub/skills/api-patterns/rest.md +40 -0
- package/template/.devbooster/hub/skills/api-patterns/scripts/api_validator.py +211 -0
- package/template/.devbooster/hub/skills/api-patterns/security-testing.md +122 -0
- package/template/.devbooster/hub/skills/api-patterns/trpc.md +41 -0
- package/template/.devbooster/hub/skills/api-patterns/versioning.md +22 -0
- package/template/.devbooster/hub/skills/app-builder/SKILL.md +75 -0
- package/template/.devbooster/hub/skills/app-builder/agent-coordination.md +71 -0
- package/template/.devbooster/hub/skills/app-builder/feature-building.md +53 -0
- package/template/.devbooster/hub/skills/app-builder/project-detection.md +34 -0
- package/template/.devbooster/hub/skills/app-builder/scaffolding.md +118 -0
- package/template/.devbooster/hub/skills/app-builder/tech-stack.md +40 -0
- package/template/.devbooster/hub/skills/app-builder/templates/SKILL.md +39 -0
- package/template/.devbooster/hub/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/template/.devbooster/hub/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/template/.devbooster/hub/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/template/.devbooster/hub/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/template/.devbooster/hub/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/template/.devbooster/hub/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/template/.devbooster/hub/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/template/.devbooster/hub/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/template/.devbooster/hub/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/template/.devbooster/hub/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/template/.devbooster/hub/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/template/.devbooster/hub/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/template/.devbooster/hub/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/template/.devbooster/hub/skills/architecture/SKILL.md +55 -0
- package/template/.devbooster/hub/skills/architecture/context-discovery.md +43 -0
- package/template/.devbooster/hub/skills/architecture/examples.md +94 -0
- package/template/.devbooster/hub/skills/architecture/pattern-selection.md +68 -0
- package/template/.devbooster/hub/skills/architecture/patterns-reference.md +50 -0
- package/template/.devbooster/hub/skills/architecture/trade-off-analysis.md +77 -0
- package/template/.devbooster/hub/skills/bash-linux/SKILL.md +199 -0
- package/template/.devbooster/hub/skills/behavioral-modes/SKILL.md +242 -0
- package/template/.devbooster/hub/skills/brainstorming/SKILL.md +163 -0
- package/template/.devbooster/hub/skills/brainstorming/dynamic-questioning.md +350 -0
- package/template/.devbooster/hub/skills/clean-code/SKILL.md +201 -0
- package/template/.devbooster/hub/skills/code-review-checklist/SKILL.md +109 -0
- package/template/.devbooster/hub/skills/database-design/SKILL.md +52 -0
- package/template/.devbooster/hub/skills/database-design/database-selection.md +43 -0
- package/template/.devbooster/hub/skills/database-design/indexing.md +39 -0
- package/template/.devbooster/hub/skills/database-design/migrations.md +48 -0
- package/template/.devbooster/hub/skills/database-design/optimization.md +36 -0
- package/template/.devbooster/hub/skills/database-design/orm-selection.md +30 -0
- package/template/.devbooster/hub/skills/database-design/schema-design.md +56 -0
- package/template/.devbooster/hub/skills/database-design/scripts/schema_validator.py +172 -0
- package/template/.devbooster/hub/skills/deployment-procedures/SKILL.md +241 -0
- package/template/.devbooster/hub/skills/doc.md +177 -0
- package/template/.devbooster/hub/skills/documentation-templates/SKILL.md +194 -0
- package/template/.devbooster/hub/skills/frontend-design/SKILL.md +418 -0
- package/template/.devbooster/hub/skills/frontend-design/animation-guide.md +331 -0
- package/template/.devbooster/hub/skills/frontend-design/anti-generic-guide.md +252 -0
- package/template/.devbooster/hub/skills/frontend-design/color-system.md +311 -0
- package/template/.devbooster/hub/skills/frontend-design/decision-trees.md +418 -0
- package/template/.devbooster/hub/skills/frontend-design/motion-graphics.md +306 -0
- package/template/.devbooster/hub/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/template/.devbooster/hub/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/template/.devbooster/hub/skills/frontend-design/typography-system.md +345 -0
- package/template/.devbooster/hub/skills/frontend-design/ux-psychology.md +1116 -0
- package/template/.devbooster/hub/skills/frontend-design/visual-effects.md +383 -0
- package/template/.devbooster/hub/skills/game-development/2d-games/SKILL.md +119 -0
- package/template/.devbooster/hub/skills/game-development/3d-games/SKILL.md +135 -0
- package/template/.devbooster/hub/skills/game-development/SKILL.md +167 -0
- package/template/.devbooster/hub/skills/game-development/game-art/SKILL.md +185 -0
- package/template/.devbooster/hub/skills/game-development/game-audio/SKILL.md +190 -0
- package/template/.devbooster/hub/skills/game-development/game-design/SKILL.md +129 -0
- package/template/.devbooster/hub/skills/game-development/mobile-games/SKILL.md +108 -0
- package/template/.devbooster/hub/skills/game-development/multiplayer/SKILL.md +132 -0
- package/template/.devbooster/hub/skills/game-development/pc-games/SKILL.md +144 -0
- package/template/.devbooster/hub/skills/game-development/vr-ar/SKILL.md +123 -0
- package/template/.devbooster/hub/skills/game-development/web-games/SKILL.md +150 -0
- package/template/.devbooster/hub/skills/geo-fundamentals/SKILL.md +156 -0
- package/template/.devbooster/hub/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/template/.devbooster/hub/skills/i18n-localization/SKILL.md +154 -0
- package/template/.devbooster/hub/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/template/.devbooster/hub/skills/intelligent-routing/SKILL.md +335 -0
- package/template/.devbooster/hub/skills/lint-and-validate/SKILL.md +45 -0
- package/template/.devbooster/hub/skills/lint-and-validate/scripts/lint_runner.py +184 -0
- package/template/.devbooster/hub/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/template/.devbooster/hub/skills/mcp-builder/SKILL.md +176 -0
- package/template/.devbooster/hub/skills/mobile-design/SKILL.md +394 -0
- package/template/.devbooster/hub/skills/mobile-design/decision-trees.md +516 -0
- package/template/.devbooster/hub/skills/mobile-design/mobile-backend.md +491 -0
- package/template/.devbooster/hub/skills/mobile-design/mobile-color-system.md +420 -0
- package/template/.devbooster/hub/skills/mobile-design/mobile-debugging.md +122 -0
- package/template/.devbooster/hub/skills/mobile-design/mobile-design-thinking.md +357 -0
- package/template/.devbooster/hub/skills/mobile-design/mobile-navigation.md +458 -0
- package/template/.devbooster/hub/skills/mobile-design/mobile-performance.md +767 -0
- package/template/.devbooster/hub/skills/mobile-design/mobile-testing.md +356 -0
- package/template/.devbooster/hub/skills/mobile-design/mobile-typography.md +433 -0
- package/template/.devbooster/hub/skills/mobile-design/platform-android.md +666 -0
- package/template/.devbooster/hub/skills/mobile-design/platform-ios.md +561 -0
- package/template/.devbooster/hub/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/template/.devbooster/hub/skills/mobile-design/touch-psychology.md +537 -0
- package/template/.devbooster/hub/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +312 -0
- package/template/.devbooster/hub/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/template/.devbooster/hub/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/template/.devbooster/hub/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/template/.devbooster/hub/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/template/.devbooster/hub/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/template/.devbooster/hub/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/template/.devbooster/hub/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/template/.devbooster/hub/skills/nextjs-react-expert/SKILL.md +286 -0
- package/template/.devbooster/hub/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/template/.devbooster/hub/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/template/.devbooster/hub/skills/nodejs-best-practices/SKILL.md +333 -0
- package/template/.devbooster/hub/skills/parallel-agents/SKILL.md +175 -0
- package/template/.devbooster/hub/skills/performance-profiling/SKILL.md +143 -0
- package/template/.devbooster/hub/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/template/.devbooster/hub/skills/plan-writing/SKILL.md +152 -0
- package/template/.devbooster/hub/skills/powershell-windows/SKILL.md +167 -0
- package/template/.devbooster/hub/skills/python-patterns/SKILL.md +441 -0
- package/template/.devbooster/hub/skills/red-team-tactics/SKILL.md +199 -0
- package/template/.devbooster/hub/skills/rust-pro/SKILL.md +176 -0
- package/template/.devbooster/hub/skills/seo-fundamentals/SKILL.md +129 -0
- package/template/.devbooster/hub/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/template/.devbooster/hub/skills/server-management/SKILL.md +161 -0
- package/template/.devbooster/hub/skills/systematic-debugging/SKILL.md +109 -0
- package/template/.devbooster/hub/skills/tailwind-patterns/SKILL.md +269 -0
- package/template/.devbooster/hub/skills/tdd-workflow/SKILL.md +149 -0
- package/template/.devbooster/hub/skills/testing-patterns/SKILL.md +178 -0
- package/template/.devbooster/hub/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/template/.devbooster/hub/skills/vulnerability-scanner/SKILL.md +276 -0
- package/template/.devbooster/hub/skills/vulnerability-scanner/checklists.md +121 -0
- package/template/.devbooster/hub/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/template/.devbooster/hub/skills/web-design-guidelines/SKILL.md +57 -0
- package/template/.devbooster/hub/skills/webapp-testing/SKILL.md +187 -0
- package/template/.devbooster/hub/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/template/.devbooster/hub/workflows/brainstorm.md +113 -0
- package/template/.devbooster/hub/workflows/create.md +59 -0
- package/template/.devbooster/hub/workflows/debug.md +103 -0
- package/template/.devbooster/hub/workflows/deploy.md +176 -0
- package/template/.devbooster/hub/workflows/enhance.md +63 -0
- package/template/.devbooster/hub/workflows/orchestrate.md +237 -0
- package/template/.devbooster/hub/workflows/plan.md +89 -0
- package/template/.devbooster/hub/workflows/preview.md +81 -0
- package/template/.devbooster/hub/workflows/status.md +86 -0
- package/template/.devbooster/hub/workflows/test.md +144 -0
- package/template/.devbooster/hub/workflows/ui-ux-pro-max.md +296 -0
- package/template/.devbooster/rules/BACKEND.md +72 -0
- package/template/.devbooster/rules/COMERCIAL.md +69 -0
- package/template/.devbooster/rules/FRONTEND.md +76 -0
- package/template/.devbooster/rules/GUIDE.md +111 -0
- package/template/.devbooster/rules/PROJECT.md +83 -0
- package/template/.devbooster/rules/PROTOCOL.md +42 -0
- package/template/.devbooster/rules/USER_PREFERENCES.md +33 -0
- package/template/DEVBOOSTER_INIT.md +42 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Skill: webapp-testing
|
|
4
|
+
Script: playwright_runner.py
|
|
5
|
+
Purpose: Run basic Playwright browser tests
|
|
6
|
+
Usage: python playwright_runner.py <url> [--screenshot]
|
|
7
|
+
Output: JSON with page info, health status, and optional screenshot path
|
|
8
|
+
Note: Requires playwright (pip install playwright && playwright install chromium)
|
|
9
|
+
Screenshots: Saved to system temp directory (auto-cleaned by OS)
|
|
10
|
+
"""
|
|
11
|
+
import sys
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import tempfile
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
|
|
17
|
+
# Fix Windows console encoding for Unicode output
|
|
18
|
+
try:
|
|
19
|
+
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
20
|
+
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
|
|
21
|
+
except AttributeError:
|
|
22
|
+
pass # Python < 3.7
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
from playwright.sync_api import sync_playwright
|
|
26
|
+
PLAYWRIGHT_AVAILABLE = True
|
|
27
|
+
except ImportError:
|
|
28
|
+
PLAYWRIGHT_AVAILABLE = False
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def run_basic_test(url: str, take_screenshot: bool = False) -> dict:
|
|
32
|
+
"""Run basic browser test on URL."""
|
|
33
|
+
if not PLAYWRIGHT_AVAILABLE:
|
|
34
|
+
return {
|
|
35
|
+
"error": "Playwright not installed",
|
|
36
|
+
"fix": "pip install playwright && playwright install chromium"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
result = {
|
|
40
|
+
"url": url,
|
|
41
|
+
"timestamp": datetime.now().isoformat(),
|
|
42
|
+
"status": "pending"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
with sync_playwright() as p:
|
|
47
|
+
browser = p.chromium.launch(headless=True)
|
|
48
|
+
context = browser.new_context(
|
|
49
|
+
viewport={"width": 1280, "height": 720},
|
|
50
|
+
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
|
51
|
+
)
|
|
52
|
+
page = context.new_page()
|
|
53
|
+
|
|
54
|
+
# Navigate
|
|
55
|
+
response = page.goto(url, wait_until="networkidle", timeout=30000)
|
|
56
|
+
|
|
57
|
+
# Basic info
|
|
58
|
+
result["page"] = {
|
|
59
|
+
"title": page.title(),
|
|
60
|
+
"url": page.url,
|
|
61
|
+
"status_code": response.status if response else None
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# Health checks
|
|
65
|
+
result["health"] = {
|
|
66
|
+
"loaded": response.ok if response else False,
|
|
67
|
+
"has_title": bool(page.title()),
|
|
68
|
+
"has_h1": page.locator("h1").count() > 0,
|
|
69
|
+
"has_links": page.locator("a").count() > 0,
|
|
70
|
+
"has_images": page.locator("img").count() > 0
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# Console errors
|
|
74
|
+
console_errors = []
|
|
75
|
+
page.on("console", lambda msg: console_errors.append(msg.text) if msg.type == "error" else None)
|
|
76
|
+
|
|
77
|
+
# Performance metrics
|
|
78
|
+
result["performance"] = {
|
|
79
|
+
"dom_content_loaded": page.evaluate("window.performance.timing.domContentLoadedEventEnd - window.performance.timing.navigationStart"),
|
|
80
|
+
"load_complete": page.evaluate("window.performance.timing.loadEventEnd - window.performance.timing.navigationStart")
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# Screenshot - uses system temp directory (cross-platform, auto-cleaned)
|
|
84
|
+
if take_screenshot:
|
|
85
|
+
# Cross-platform: Windows=%TEMP%, Linux/macOS=/tmp
|
|
86
|
+
screenshot_dir = os.path.join(tempfile.gettempdir(), "maestro_screenshots")
|
|
87
|
+
os.makedirs(screenshot_dir, exist_ok=True)
|
|
88
|
+
screenshot_path = os.path.join(screenshot_dir, f"screenshot_{datetime.now().strftime('%Y%m%d_%H%M%S')}.png")
|
|
89
|
+
page.screenshot(path=screenshot_path, full_page=True)
|
|
90
|
+
result["screenshot"] = screenshot_path
|
|
91
|
+
result["screenshot_note"] = "Saved to temp directory (auto-cleaned by OS)"
|
|
92
|
+
|
|
93
|
+
# Element counts
|
|
94
|
+
result["elements"] = {
|
|
95
|
+
"links": page.locator("a").count(),
|
|
96
|
+
"buttons": page.locator("button").count(),
|
|
97
|
+
"inputs": page.locator("input").count(),
|
|
98
|
+
"images": page.locator("img").count(),
|
|
99
|
+
"forms": page.locator("form").count()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
browser.close()
|
|
103
|
+
|
|
104
|
+
result["status"] = "success" if result["health"]["loaded"] else "failed"
|
|
105
|
+
result["summary"] = "[OK] Page loaded successfully" if result["status"] == "success" else "[X] Page failed to load"
|
|
106
|
+
|
|
107
|
+
except Exception as e:
|
|
108
|
+
result["status"] = "error"
|
|
109
|
+
result["error"] = str(e)
|
|
110
|
+
result["summary"] = f"[X] Error: {str(e)[:100]}"
|
|
111
|
+
|
|
112
|
+
return result
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def run_accessibility_check(url: str) -> dict:
|
|
116
|
+
"""Run basic accessibility check."""
|
|
117
|
+
if not PLAYWRIGHT_AVAILABLE:
|
|
118
|
+
return {"error": "Playwright not installed"}
|
|
119
|
+
|
|
120
|
+
result = {"url": url, "accessibility": {}}
|
|
121
|
+
|
|
122
|
+
try:
|
|
123
|
+
with sync_playwright() as p:
|
|
124
|
+
browser = p.chromium.launch(headless=True)
|
|
125
|
+
page = browser.new_page()
|
|
126
|
+
page.goto(url, wait_until="networkidle", timeout=30000)
|
|
127
|
+
|
|
128
|
+
# Basic a11y checks
|
|
129
|
+
result["accessibility"] = {
|
|
130
|
+
"images_with_alt": page.locator("img[alt]").count(),
|
|
131
|
+
"images_without_alt": page.locator("img:not([alt])").count(),
|
|
132
|
+
"buttons_with_label": page.locator("button[aria-label], button:has-text('')").count(),
|
|
133
|
+
"links_with_text": page.locator("a:has-text('')").count(),
|
|
134
|
+
"form_labels": page.locator("label").count(),
|
|
135
|
+
"headings": {
|
|
136
|
+
"h1": page.locator("h1").count(),
|
|
137
|
+
"h2": page.locator("h2").count(),
|
|
138
|
+
"h3": page.locator("h3").count()
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
browser.close()
|
|
143
|
+
result["status"] = "success"
|
|
144
|
+
|
|
145
|
+
except Exception as e:
|
|
146
|
+
result["status"] = "error"
|
|
147
|
+
result["error"] = str(e)
|
|
148
|
+
|
|
149
|
+
return result
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
if __name__ == "__main__":
|
|
153
|
+
if len(sys.argv) < 2:
|
|
154
|
+
print(json.dumps({
|
|
155
|
+
"error": "Usage: python playwright_runner.py <url> [--screenshot] [--a11y]",
|
|
156
|
+
"examples": [
|
|
157
|
+
"python playwright_runner.py https://example.com",
|
|
158
|
+
"python playwright_runner.py https://example.com --screenshot",
|
|
159
|
+
"python playwright_runner.py https://example.com --a11y"
|
|
160
|
+
]
|
|
161
|
+
}, indent=2))
|
|
162
|
+
sys.exit(1)
|
|
163
|
+
|
|
164
|
+
url = sys.argv[1]
|
|
165
|
+
take_screenshot = "--screenshot" in sys.argv
|
|
166
|
+
check_a11y = "--a11y" in sys.argv
|
|
167
|
+
|
|
168
|
+
if check_a11y:
|
|
169
|
+
result = run_accessibility_check(url)
|
|
170
|
+
else:
|
|
171
|
+
result = run_basic_test(url, take_screenshot)
|
|
172
|
+
|
|
173
|
+
print(json.dumps(result, indent=2))
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
React Performance Checker
|
|
4
|
+
Automated performance audit for React/Next.js projects
|
|
5
|
+
Based on Vercel Engineering best practices
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
import json
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import List, Dict, Tuple
|
|
13
|
+
|
|
14
|
+
class PerformanceChecker:
|
|
15
|
+
def __init__(self, project_path: str):
|
|
16
|
+
self.project_path = Path(project_path)
|
|
17
|
+
self.issues = []
|
|
18
|
+
self.warnings = []
|
|
19
|
+
self.passed = []
|
|
20
|
+
|
|
21
|
+
def check_waterfalls(self):
|
|
22
|
+
"""Check for sequential await patterns (Section 1)"""
|
|
23
|
+
print("\n[*] Checking for waterfalls (sequential awaits)...")
|
|
24
|
+
|
|
25
|
+
for filepath in self.project_path.rglob('*.{ts,tsx,js,jsx}'):
|
|
26
|
+
if 'node_modules' in str(filepath):
|
|
27
|
+
continue
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
content = filepath.read_text(encoding='utf-8')
|
|
31
|
+
|
|
32
|
+
# Pattern: multiple awaits in sequence without Promise.all
|
|
33
|
+
sequential_awaits = re.findall(r'await\s+\w+.*?\n\s*await\s+\w+', content)
|
|
34
|
+
|
|
35
|
+
if sequential_awaits:
|
|
36
|
+
self.issues.append({
|
|
37
|
+
'file': str(filepath.relative_to(self.project_path)),
|
|
38
|
+
'type': 'CRITICAL',
|
|
39
|
+
'issue': 'Sequential awaits detected (waterfall)',
|
|
40
|
+
'fix': 'Use Promise.all() for parallel fetching',
|
|
41
|
+
'section': '1-async-eliminating-waterfalls.md'
|
|
42
|
+
})
|
|
43
|
+
except Exception as e:
|
|
44
|
+
continue
|
|
45
|
+
|
|
46
|
+
def check_barrel_imports(self):
|
|
47
|
+
"""Check for barrel imports (Section 2)"""
|
|
48
|
+
print("[*] Checking for barrel imports...")
|
|
49
|
+
|
|
50
|
+
for filepath in self.project_path.rglob('*.{ts,tsx,js,jsx}'):
|
|
51
|
+
if 'node_modules' in str(filepath):
|
|
52
|
+
continue
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
content = filepath.read_text(encoding='utf-8')
|
|
56
|
+
|
|
57
|
+
# Pattern: import from index files or barrel exports
|
|
58
|
+
barrel_imports = re.findall(r"import.*from\s+['\"](@/.*?)/index['\"]", content)
|
|
59
|
+
barrel_imports += re.findall(r"import.*from\s+['\"]\.\.?/.*?['\"](?!.*?\.tsx?)", content)
|
|
60
|
+
|
|
61
|
+
if barrel_imports:
|
|
62
|
+
self.warnings.append({
|
|
63
|
+
'file': str(filepath.relative_to(self.project_path)),
|
|
64
|
+
'type': 'CRITICAL',
|
|
65
|
+
'issue': 'Potential barrel imports detected',
|
|
66
|
+
'fix': 'Import directly from specific files',
|
|
67
|
+
'section': '2-bundle-bundle-size-optimization.md'
|
|
68
|
+
})
|
|
69
|
+
except Exception as e:
|
|
70
|
+
continue
|
|
71
|
+
|
|
72
|
+
def check_dynamic_imports(self):
|
|
73
|
+
"""Check if large components use dynamic imports (Section 2)"""
|
|
74
|
+
print("[*] Checking for missing dynamic imports...")
|
|
75
|
+
|
|
76
|
+
for filepath in self.project_path.rglob('*.{ts,tsx}'):
|
|
77
|
+
if 'node_modules' in str(filepath):
|
|
78
|
+
continue
|
|
79
|
+
|
|
80
|
+
try:
|
|
81
|
+
content = filepath.read_text(encoding='utf-8')
|
|
82
|
+
|
|
83
|
+
# Check file size - if > 10KB, should probably use dynamic import
|
|
84
|
+
if len(content) > 10000:
|
|
85
|
+
# Check if it's imported statically somewhere
|
|
86
|
+
filename = filepath.stem
|
|
87
|
+
|
|
88
|
+
# Search for static imports of this component
|
|
89
|
+
for check_file in self.project_path.rglob('*.{ts,tsx}'):
|
|
90
|
+
if check_file == filepath or 'node_modules' in str(check_file):
|
|
91
|
+
continue
|
|
92
|
+
|
|
93
|
+
check_content = check_file.read_text(encoding='utf-8')
|
|
94
|
+
if f"import {filename}" in check_content or f"import {{ {filename}" in check_content:
|
|
95
|
+
if 'dynamic(' not in check_content:
|
|
96
|
+
self.warnings.append({
|
|
97
|
+
'file': str(check_file.relative_to(self.project_path)),
|
|
98
|
+
'type': 'CRITICAL',
|
|
99
|
+
'issue': f'Large component {filename} imported statically',
|
|
100
|
+
'fix': 'Use dynamic() for code splitting',
|
|
101
|
+
'section': '2-bundle-bundle-size-optimization.md'
|
|
102
|
+
})
|
|
103
|
+
break
|
|
104
|
+
except Exception as e:
|
|
105
|
+
continue
|
|
106
|
+
|
|
107
|
+
def check_useEffect_fetching(self):
|
|
108
|
+
"""Check for data fetching in useEffect (Section 4)"""
|
|
109
|
+
print("[*] Checking for useEffect data fetching...")
|
|
110
|
+
|
|
111
|
+
for filepath in self.project_path.rglob('*.{ts,tsx}'):
|
|
112
|
+
if 'node_modules' in str(filepath):
|
|
113
|
+
continue
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
content = filepath.read_text(encoding='utf-8')
|
|
117
|
+
|
|
118
|
+
# Pattern: fetch or axios in useEffect
|
|
119
|
+
if 'useEffect' in content:
|
|
120
|
+
if re.search(r'useEffect.*?fetch\(', content, re.DOTALL):
|
|
121
|
+
self.warnings.append({
|
|
122
|
+
'file': str(filepath.relative_to(self.project_path)),
|
|
123
|
+
'type': 'MEDIUM-HIGH',
|
|
124
|
+
'issue': 'Data fetching in useEffect',
|
|
125
|
+
'fix': 'Consider using SWR or React Query for deduplication',
|
|
126
|
+
'section': '4-client-client-side-data-fetching.md'
|
|
127
|
+
})
|
|
128
|
+
except Exception as e:
|
|
129
|
+
continue
|
|
130
|
+
|
|
131
|
+
def check_missing_memoization(self):
|
|
132
|
+
"""Check for missing React.memo, useMemo, useCallback (Section 5)"""
|
|
133
|
+
print("[*] Checking for missing memoization...")
|
|
134
|
+
|
|
135
|
+
for filepath in self.project_path.rglob('*.{tsx}'):
|
|
136
|
+
if 'node_modules' in str(filepath):
|
|
137
|
+
continue
|
|
138
|
+
|
|
139
|
+
try:
|
|
140
|
+
content = filepath.read_text(encoding='utf-8')
|
|
141
|
+
|
|
142
|
+
# Check for component definitions without memo
|
|
143
|
+
components = re.findall(r'(?:export\s+)?(?:const|function)\s+([A-Z]\w+)', content)
|
|
144
|
+
|
|
145
|
+
if components and 'React.memo' not in content and 'memo(' not in content:
|
|
146
|
+
# Check if component receives props
|
|
147
|
+
if 'props:' in content or 'Props>' in content:
|
|
148
|
+
self.warnings.append({
|
|
149
|
+
'file': str(filepath.relative_to(self.project_path)),
|
|
150
|
+
'type': 'MEDIUM',
|
|
151
|
+
'issue': 'Component with props not memoized',
|
|
152
|
+
'fix': 'Consider using React.memo if props are stable',
|
|
153
|
+
'section': '5-rerender-re-render-optimization.md'
|
|
154
|
+
})
|
|
155
|
+
except Exception as e:
|
|
156
|
+
continue
|
|
157
|
+
|
|
158
|
+
def check_image_optimization(self):
|
|
159
|
+
"""Check for unoptimized images (Section 6)"""
|
|
160
|
+
print("[*] Checking for image optimization...")
|
|
161
|
+
|
|
162
|
+
for filepath in self.project_path.rglob('*.{ts,tsx,js,jsx}'):
|
|
163
|
+
if 'node_modules' in str(filepath):
|
|
164
|
+
continue
|
|
165
|
+
|
|
166
|
+
try:
|
|
167
|
+
content = filepath.read_text(encoding='utf-8')
|
|
168
|
+
|
|
169
|
+
# Check for <img> tags instead of next/image
|
|
170
|
+
if '<img' in content and 'next/image' not in content:
|
|
171
|
+
self.warnings.append({
|
|
172
|
+
'file': str(filepath.relative_to(self.project_path)),
|
|
173
|
+
'type': 'MEDIUM',
|
|
174
|
+
'issue': 'Using <img> instead of next/image',
|
|
175
|
+
'fix': 'Use next/image for automatic optimization',
|
|
176
|
+
'section': '6-rendering-rendering-performance.md'
|
|
177
|
+
})
|
|
178
|
+
except Exception as e:
|
|
179
|
+
continue
|
|
180
|
+
|
|
181
|
+
def generate_report(self):
|
|
182
|
+
"""Generate final report"""
|
|
183
|
+
print("\n" + "="*60)
|
|
184
|
+
print("REACT PERFORMANCE AUDIT REPORT")
|
|
185
|
+
print("="*60)
|
|
186
|
+
|
|
187
|
+
print(f"\n[CRITICAL ISSUES] ({len([i for i in self.issues if i['type'] == 'CRITICAL'])})")
|
|
188
|
+
for issue in self.issues:
|
|
189
|
+
if issue['type'] == 'CRITICAL':
|
|
190
|
+
print(f" - {issue['file']}")
|
|
191
|
+
print(f" Issue: {issue['issue']}")
|
|
192
|
+
print(f" Fix: {issue['fix']}")
|
|
193
|
+
print(f" Reference: {issue['section']}\n")
|
|
194
|
+
|
|
195
|
+
print(f"\n[WARNINGS] ({len(self.warnings)})")
|
|
196
|
+
for warning in self.warnings[:10]: # Show first 10
|
|
197
|
+
print(f" - {warning['file']}")
|
|
198
|
+
print(f" Issue: {warning['issue']}")
|
|
199
|
+
print(f" Fix: {warning['fix']}")
|
|
200
|
+
print(f" Reference: {warning['section']}\n")
|
|
201
|
+
|
|
202
|
+
if len(self.warnings) > 10:
|
|
203
|
+
print(f" ... and {len(self.warnings) - 10} more warnings")
|
|
204
|
+
|
|
205
|
+
print("\n" + "="*60)
|
|
206
|
+
print(f"SUMMARY:")
|
|
207
|
+
print(f" Critical Issues: {len([i for i in self.issues if i['type'] == 'CRITICAL'])}")
|
|
208
|
+
print(f" Warnings: {len(self.warnings)}")
|
|
209
|
+
print("="*60)
|
|
210
|
+
|
|
211
|
+
if len(self.issues) == 0 and len(self.warnings) == 0:
|
|
212
|
+
print("\n[SUCCESS] No major performance issues detected!")
|
|
213
|
+
else:
|
|
214
|
+
print("\n[ACTION REQUIRED] Review and fix issues above")
|
|
215
|
+
print("Priority: CRITICAL > HIGH > MEDIUM > LOW")
|
|
216
|
+
|
|
217
|
+
def run(self):
|
|
218
|
+
"""Run all checks"""
|
|
219
|
+
print("="*60)
|
|
220
|
+
print("React Performance Checker (Vercel Engineering)")
|
|
221
|
+
print("="*60)
|
|
222
|
+
print(f"Scanning: {self.project_path}")
|
|
223
|
+
|
|
224
|
+
self.check_waterfalls()
|
|
225
|
+
self.check_barrel_imports()
|
|
226
|
+
self.check_dynamic_imports()
|
|
227
|
+
self.check_useEffect_fetching()
|
|
228
|
+
self.check_missing_memoization()
|
|
229
|
+
self.check_image_optimization()
|
|
230
|
+
|
|
231
|
+
self.generate_report()
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def main():
|
|
235
|
+
import sys
|
|
236
|
+
|
|
237
|
+
if len(sys.argv) < 2:
|
|
238
|
+
print("Usage: python react_performance_checker.py <project_path>")
|
|
239
|
+
sys.exit(1)
|
|
240
|
+
|
|
241
|
+
project_path = sys.argv[1]
|
|
242
|
+
|
|
243
|
+
if not os.path.exists(project_path):
|
|
244
|
+
print(f"[ERROR] Path not found: {project_path}")
|
|
245
|
+
sys.exit(1)
|
|
246
|
+
|
|
247
|
+
checker = PerformanceChecker(project_path)
|
|
248
|
+
checker.run()
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
if __name__ == '__main__':
|
|
252
|
+
main()
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Schema Validator - Database schema validation
|
|
4
|
+
Validates Prisma schemas and checks for common issues.
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
python schema_validator.py <project_path>
|
|
8
|
+
|
|
9
|
+
Checks:
|
|
10
|
+
- Prisma schema syntax
|
|
11
|
+
- Missing relations
|
|
12
|
+
- Index recommendations
|
|
13
|
+
- Naming conventions
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import sys
|
|
17
|
+
import json
|
|
18
|
+
import re
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from datetime import datetime
|
|
21
|
+
|
|
22
|
+
# Fix Windows console encoding
|
|
23
|
+
try:
|
|
24
|
+
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
25
|
+
except:
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def find_schema_files(project_path: Path) -> list:
|
|
30
|
+
"""Find database schema files."""
|
|
31
|
+
schemas = []
|
|
32
|
+
|
|
33
|
+
# Prisma schema
|
|
34
|
+
prisma_files = list(project_path.glob('**/prisma/schema.prisma'))
|
|
35
|
+
schemas.extend([('prisma', f) for f in prisma_files])
|
|
36
|
+
|
|
37
|
+
# Drizzle schema files
|
|
38
|
+
drizzle_files = list(project_path.glob('**/drizzle/*.ts'))
|
|
39
|
+
drizzle_files.extend(project_path.glob('**/schema/*.ts'))
|
|
40
|
+
for f in drizzle_files:
|
|
41
|
+
if 'schema' in f.name.lower() or 'table' in f.name.lower():
|
|
42
|
+
schemas.append(('drizzle', f))
|
|
43
|
+
|
|
44
|
+
return schemas[:10] # Limit
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def validate_prisma_schema(file_path: Path) -> list:
|
|
48
|
+
"""Validate Prisma schema file."""
|
|
49
|
+
issues = []
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
content = file_path.read_text(encoding='utf-8', errors='ignore')
|
|
53
|
+
|
|
54
|
+
# Find all models
|
|
55
|
+
models = re.findall(r'model\s+(\w+)\s*{([^}]+)}', content, re.DOTALL)
|
|
56
|
+
|
|
57
|
+
for model_name, model_body in models:
|
|
58
|
+
# Check naming convention (PascalCase)
|
|
59
|
+
if not model_name[0].isupper():
|
|
60
|
+
issues.append(f"Model '{model_name}' should be PascalCase")
|
|
61
|
+
|
|
62
|
+
# Check for id field
|
|
63
|
+
if '@id' not in model_body and 'id' not in model_body.lower():
|
|
64
|
+
issues.append(f"Model '{model_name}' might be missing @id field")
|
|
65
|
+
|
|
66
|
+
# Check for createdAt/updatedAt
|
|
67
|
+
if 'createdAt' not in model_body and 'created_at' not in model_body:
|
|
68
|
+
issues.append(f"Model '{model_name}' missing createdAt field (recommended)")
|
|
69
|
+
|
|
70
|
+
# Check for @relation without fields
|
|
71
|
+
relations = re.findall(r'@relation\([^)]*\)', model_body)
|
|
72
|
+
for rel in relations:
|
|
73
|
+
if 'fields:' not in rel and 'references:' not in rel:
|
|
74
|
+
pass # Implicit relation, ok
|
|
75
|
+
|
|
76
|
+
# Check for @@index suggestions
|
|
77
|
+
foreign_keys = re.findall(r'(\w+Id)\s+\w+', model_body)
|
|
78
|
+
for fk in foreign_keys:
|
|
79
|
+
if f'@@index([{fk}])' not in content and f'@@index(["{fk}"])' not in content:
|
|
80
|
+
issues.append(f"Consider adding @@index([{fk}]) for better query performance in {model_name}")
|
|
81
|
+
|
|
82
|
+
# Check for enum definitions
|
|
83
|
+
enums = re.findall(r'enum\s+(\w+)\s*{', content)
|
|
84
|
+
for enum_name in enums:
|
|
85
|
+
if not enum_name[0].isupper():
|
|
86
|
+
issues.append(f"Enum '{enum_name}' should be PascalCase")
|
|
87
|
+
|
|
88
|
+
except Exception as e:
|
|
89
|
+
issues.append(f"Error reading schema: {str(e)[:50]}")
|
|
90
|
+
|
|
91
|
+
return issues
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def main():
|
|
95
|
+
project_path = Path(sys.argv[1] if len(sys.argv) > 1 else ".").resolve()
|
|
96
|
+
|
|
97
|
+
print(f"\n{'='*60}")
|
|
98
|
+
print(f"[SCHEMA VALIDATOR] Database Schema Validation")
|
|
99
|
+
print(f"{'='*60}")
|
|
100
|
+
print(f"Project: {project_path}")
|
|
101
|
+
print(f"Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
|
102
|
+
print("-"*60)
|
|
103
|
+
|
|
104
|
+
# Find schema files
|
|
105
|
+
schemas = find_schema_files(project_path)
|
|
106
|
+
print(f"Found {len(schemas)} schema files")
|
|
107
|
+
|
|
108
|
+
if not schemas:
|
|
109
|
+
output = {
|
|
110
|
+
"script": "schema_validator",
|
|
111
|
+
"project": str(project_path),
|
|
112
|
+
"schemas_checked": 0,
|
|
113
|
+
"issues_found": 0,
|
|
114
|
+
"passed": True,
|
|
115
|
+
"message": "No schema files found"
|
|
116
|
+
}
|
|
117
|
+
print(json.dumps(output, indent=2))
|
|
118
|
+
sys.exit(0)
|
|
119
|
+
|
|
120
|
+
# Validate each schema
|
|
121
|
+
all_issues = []
|
|
122
|
+
|
|
123
|
+
for schema_type, file_path in schemas:
|
|
124
|
+
print(f"\nValidating: {file_path.name} ({schema_type})")
|
|
125
|
+
|
|
126
|
+
if schema_type == 'prisma':
|
|
127
|
+
issues = validate_prisma_schema(file_path)
|
|
128
|
+
else:
|
|
129
|
+
issues = [] # Drizzle validation could be added
|
|
130
|
+
|
|
131
|
+
if issues:
|
|
132
|
+
all_issues.append({
|
|
133
|
+
"file": str(file_path.name),
|
|
134
|
+
"type": schema_type,
|
|
135
|
+
"issues": issues
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
# Summary
|
|
139
|
+
print("\n" + "="*60)
|
|
140
|
+
print("SCHEMA ISSUES")
|
|
141
|
+
print("="*60)
|
|
142
|
+
|
|
143
|
+
if all_issues:
|
|
144
|
+
for item in all_issues:
|
|
145
|
+
print(f"\n{item['file']} ({item['type']}):")
|
|
146
|
+
for issue in item["issues"][:5]: # Limit per file
|
|
147
|
+
print(f" - {issue}")
|
|
148
|
+
if len(item["issues"]) > 5:
|
|
149
|
+
print(f" ... and {len(item['issues']) - 5} more issues")
|
|
150
|
+
else:
|
|
151
|
+
print("No schema issues found!")
|
|
152
|
+
|
|
153
|
+
total_issues = sum(len(item["issues"]) for item in all_issues)
|
|
154
|
+
# Schema issues are warnings, not failures
|
|
155
|
+
passed = True
|
|
156
|
+
|
|
157
|
+
output = {
|
|
158
|
+
"script": "schema_validator",
|
|
159
|
+
"project": str(project_path),
|
|
160
|
+
"schemas_checked": len(schemas),
|
|
161
|
+
"issues_found": total_issues,
|
|
162
|
+
"passed": passed,
|
|
163
|
+
"issues": all_issues
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
print("\n" + json.dumps(output, indent=2))
|
|
167
|
+
|
|
168
|
+
sys.exit(0)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if __name__ == "__main__":
|
|
172
|
+
main()
|