This directory contains utility scripts for the WDS Block Theme project.
This script automatically extracts the PHP version from composer.json and updates the Cursor rules files in the .cursor/rules/ directory to ensure Cursor uses the correct PHP version for code analysis and suggestions.
- Automatic PHP Version Detection: Uses
jqto parsecomposer.jsonand extract the PHP version - Multiple Version Sources: Checks multiple locations in composer.json:
config.platform.php(preferred)require-dev.phprequire.php
- Version String Cleaning: Removes version constraints (>=, ^, ~, etc.) to get the base version
- Modern Cursor Rules Structure: Creates separate
.mdcfiles in.cursor/rules/directory:dependency-management.mdc- PHP version and package managementdevelopment-workflow.mdc- Project structure and workflowjavascript-standards.mdc- Frontend development standardsphp-code-standards.mdc- Comprehensive PHP coding standardstheme-development.mdc- WordPress theme development guidelines
jqmust be installed on your system- macOS:
brew install jq - Ubuntu/Debian:
sudo apt-get install jq - Windows: Download from https://stedolan.github.io/jq/download/
- macOS:
./scripts/update-cursorrules.shnpm run update-cursorrulesThe script runs automatically after:
npm install(via postinstall script)composer install(via post-install-cmd script)
The script creates/updates files in .cursor/rules/ directory:
.cursor/rules/
├── dependency-management.mdc # PHP version and package management
├── development-workflow.mdc # Project structure and workflow
├── javascript-standards.mdc # Frontend development standards
├── php-code-standards.mdc # Comprehensive PHP coding standards
└── theme-development.mdc # WordPress theme development guidelines
Each file contains specific guidelines for different aspects of development:
- PHP version configuration (automatically updated)
- Package management guidelines
- Development environment setup
- Build process instructions
- Project structure overview
- Code standards and quality assurance
- Testing and error handling
- Performance optimization
- Modern JavaScript (ES6+) standards
- Block development guidelines
- Code style and documentation
- Testing and build processes
- WordPress PHP Coding Standards (WPCS)
- Code style and naming conventions
- Security and performance guidelines
- Testing and error handling
- Database best practices
- WordPress block theme standards
- Theme structure and setup
- Block patterns and templates
- Internationalization and accessibility
- Performance optimization
The script includes comprehensive error handling:
- Checks for
jqinstallation - Validates
composer.jsonexists - Provides helpful error messages if PHP version cannot be extracted
- Uses colored output for better readability
This script is integrated into the project's build process:
- NPM Integration: Added to
package.jsonpostinstall script - Composer Integration: Added to
composer.jsonpost-install-cmd script - Manual Script: Available as
npm run update-cursorrules
- Consistent PHP Version: Ensures Cursor always uses the correct PHP version
- Organized Rules: Separates concerns into focused rule files
- Automatic Updates: No manual intervention required
- Project-Specific Rules: Tailored to WordPress block theme development
- Modern PHP Features: Leverages PHP 8.2+ features in suggestions
- WordPress Standards: Includes WordPress-specific coding guidelines
- Comprehensive Coverage: Covers all aspects of theme development
Runs Lighthouse against the theme site and writes an HTML report for performance, accessibility, best practices, and SEO. Behavior matches the a11y script: use the current local site (with optional auto-detect) or pass a URL in the terminal.
# Prompt for URL, or leave blank to auto-detect via WordPress REST API (wds-bt.local)
npm run lighthouse
# Pass URL directly (no prompt)
npm run lighthouse -- https://mysite.localRuns Lighthouse twice (mobile and desktop). The four category scores (Performance, Accessibility, Best Practices, SEO) are printed for each. No report files are written.
- Site must be reachable (local or deployed)
- Chrome/Chromium (Lighthouse uses it headless via
npx lighthouse)
This script is used to test the extraction and update logic for the Cursor rules automation.