- .markdownlint.json: enforce MD004 asterisk style to match project conventions
- .wiki/Contributing.md: convert all dash list markers to asterisks (MD004)
- .wiki/Coding-Standards.md: fix PHPDoc bullet wording (add missing preposition)
- build.sh: add set -euo pipefail for strict error handling
- build.sh: fix SC2115 (use ${var:?} to prevent rm -rf /)
- build.sh: fix SC2164 (cd build || exit 1)
- build.sh: fix SC2028 (use printf instead of echo for escape sequences)
- build.sh: fix SC2035 (use ./*.php glob to avoid dash-named files)
Closes #46
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"MD004": {
|
||||||
|
"style": "asterisk"
|
||||||
|
},
|
||||||
"MD012": false,
|
"MD012": false,
|
||||||
"MD022": false,
|
"MD022": false,
|
||||||
"MD031": false,
|
"MD031": false,
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ if ($condition) {
|
|||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
* All classes, methods, and functions should be documented using PHPDoc
|
* All classes, methods, and functions should be documented using PHPDoc
|
||||||
* Include a description, parameters, return values, and exceptions
|
* Include a description of the parameters, return values, and possible exceptions
|
||||||
|
|
||||||
```php
|
```php
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ Thank you for considering contributing to this project! This document provides g
|
|||||||
|
|
||||||
By participating in this project, you agree to abide by our code of conduct:
|
By participating in this project, you agree to abide by our code of conduct:
|
||||||
|
|
||||||
- Be respectful and inclusive
|
* Be respectful and inclusive
|
||||||
- Be patient and welcoming
|
* Be patient and welcoming
|
||||||
- Be considerate
|
* Be considerate
|
||||||
- Be collaborative
|
* Be collaborative
|
||||||
- Be open-minded
|
* Be open-minded
|
||||||
|
|
||||||
## How to Contribute
|
## How to Contribute
|
||||||
|
|
||||||
@@ -26,12 +26,12 @@ If you find a bug, please report it by creating an issue on GitHub:
|
|||||||
|
|
||||||
Please include:
|
Please include:
|
||||||
|
|
||||||
- A clear, descriptive title
|
* A clear, descriptive title
|
||||||
- Steps to reproduce the bug
|
* Steps to reproduce the bug
|
||||||
- Expected behavior
|
* Expected behavior
|
||||||
- Actual behavior
|
* Actual behavior
|
||||||
- Screenshots (if applicable)
|
* Screenshots (if applicable)
|
||||||
- Your environment (WordPress version, PHP version, browser, etc.)
|
* Your environment (WordPress version, PHP version, browser, etc.)
|
||||||
|
|
||||||
### Suggesting Enhancements
|
### Suggesting Enhancements
|
||||||
|
|
||||||
@@ -45,10 +45,10 @@ If you have an idea for an enhancement:
|
|||||||
|
|
||||||
Please include:
|
Please include:
|
||||||
|
|
||||||
- A clear, descriptive title
|
* A clear, descriptive title
|
||||||
- A detailed description of the enhancement
|
* A detailed description of the enhancement
|
||||||
- Why this enhancement would be useful
|
* Why this enhancement would be useful
|
||||||
- Any relevant examples or mockups
|
* Any relevant examples or mockups
|
||||||
|
|
||||||
### Pull Requests
|
### Pull Requests
|
||||||
|
|
||||||
@@ -72,33 +72,33 @@ If you want to contribute code:
|
|||||||
|
|
||||||
#### Pull Request Guidelines
|
#### Pull Request Guidelines
|
||||||
|
|
||||||
- Follow the coding standards (see [Coding Standards](Coding-Standards))
|
* Follow the coding standards (see [Coding Standards](Coding-Standards))
|
||||||
- Write tests for your changes
|
* Write tests for your changes
|
||||||
- Update documentation as needed
|
* Update documentation as needed
|
||||||
- Keep pull requests focused on a single change
|
* Keep pull requests focused on a single change
|
||||||
- Write a clear, descriptive title and description
|
* Write a clear, descriptive title and description
|
||||||
- Reference any related issues
|
* Reference any related issues
|
||||||
- Ensure your code passes the automated code quality checks (see below)
|
* Ensure your code passes the automated code quality checks (see below)
|
||||||
|
|
||||||
#### Code Quality Tools
|
#### Code Quality Tools
|
||||||
|
|
||||||
This project uses several automated code quality tools to ensure high standards. These tools are free for public repositories and will automatically analyze your code when you create a pull request:
|
This project uses several automated code quality tools to ensure high standards. These tools are free for public repositories and will automatically analyze your code when you create a pull request:
|
||||||
|
|
||||||
1. **CodeRabbit**: AI-powered code review tool
|
1. **CodeRabbit**: AI-powered code review tool
|
||||||
- [Website](https://www.coderabbit.ai/)
|
* [Website](https://www.coderabbit.ai/)
|
||||||
- Provides automated feedback on pull requests
|
* Provides automated feedback on pull requests
|
||||||
|
|
||||||
2. **CodeFactor**: Continuous code quality monitoring
|
2. **CodeFactor**: Continuous code quality monitoring
|
||||||
- [Website](https://www.codefactor.io/)
|
* [Website](https://www.codefactor.io/)
|
||||||
- Provides a grade for your codebase
|
* Provides a grade for your codebase
|
||||||
|
|
||||||
3. **Codacy**: Code quality and static analysis
|
3. **Codacy**: Code quality and static analysis
|
||||||
- [Website](https://www.codacy.com/)
|
* [Website](https://www.codacy.com/)
|
||||||
- Identifies issues related to code style, security, and performance
|
* Identifies issues related to code style, security, and performance
|
||||||
|
|
||||||
4. **SonarCloud**: Code quality and security analysis
|
4. **SonarCloud**: Code quality and security analysis
|
||||||
- [Website](https://sonarcloud.io/)
|
* [Website](https://sonarcloud.io/)
|
||||||
- Provides detailed analysis of code quality and security
|
* Provides detailed analysis of code quality and security
|
||||||
|
|
||||||
#### Using AI Assistants with Code Quality Tools
|
#### Using AI Assistants with Code Quality Tools
|
||||||
|
|
||||||
|
|||||||
79
build.sh
79
build.sh
@@ -1,13 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
# WordPress Plugin Build Script
|
# WordPress Plugin Build Script
|
||||||
# This script creates a clean build of the plugin for distribution
|
# This script creates a clean build of the plugin for distribution
|
||||||
|
|
||||||
# Check if version is provided
|
# Check if version is provided
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "❌ Error: Version number is required"
|
echo "❌ Error: Version number is required"
|
||||||
echo "Usage: ./build.sh <version>"
|
echo "Usage: ./build.sh <version>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
@@ -22,15 +23,15 @@ mkdir -p "$BUILD_DIR"
|
|||||||
|
|
||||||
# Run code quality checks
|
# Run code quality checks
|
||||||
echo "Running code quality checks..."
|
echo "Running code quality checks..."
|
||||||
if command -v composer &> /dev/null; then
|
if command -v composer &>/dev/null; then
|
||||||
echo "Running PHPCS..."
|
echo "Running PHPCS..."
|
||||||
composer run phpcs || { echo "⚠️ PHPCS found issues. Consider running 'composer run phpcbf' to fix them."; }
|
composer run phpcs || { echo "⚠️ PHPCS found issues. Consider running 'composer run phpcbf' to fix them."; }
|
||||||
|
|
||||||
# Uncomment the following line to automatically fix coding standards issues
|
# Uncomment the following line to automatically fix coding standards issues
|
||||||
# echo "Running PHPCBF..."
|
# echo "Running PHPCBF..."
|
||||||
# composer run phpcbf
|
# composer run phpcbf
|
||||||
else
|
else
|
||||||
echo "⚠️ Composer not found, skipping code quality checks"
|
echo "⚠️ Composer not found, skipping code quality checks"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install composer dependencies
|
# Install composer dependencies
|
||||||
@@ -39,7 +40,7 @@ composer install --no-dev --optimize-autoloader
|
|||||||
|
|
||||||
# Copy plugin files to build directory
|
# Copy plugin files to build directory
|
||||||
echo "Copying plugin files..."
|
echo "Copying plugin files..."
|
||||||
cp -R *.php "$BUILD_DIR/"
|
cp -R ./*.php "$BUILD_DIR/"
|
||||||
cp -R README.md LICENSE CHANGELOG.md readme.txt composer.json "$BUILD_DIR/"
|
cp -R README.md LICENSE CHANGELOG.md readme.txt composer.json "$BUILD_DIR/"
|
||||||
|
|
||||||
# Copy directories
|
# Copy directories
|
||||||
@@ -54,57 +55,57 @@ mkdir -p "$BUILD_DIR/assets/banner" "$BUILD_DIR/assets/icon" "$BUILD_DIR/assets/
|
|||||||
|
|
||||||
# Copy assets if they exist
|
# Copy assets if they exist
|
||||||
if [ -d "assets/banner" ]; then
|
if [ -d "assets/banner" ]; then
|
||||||
cp -R assets/banner/* "$BUILD_DIR/assets/banner/"
|
cp -R assets/banner/* "$BUILD_DIR/assets/banner/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "assets/icon" ]; then
|
if [ -d "assets/icon" ]; then
|
||||||
cp -R assets/icon/* "$BUILD_DIR/assets/icon/"
|
cp -R assets/icon/* "$BUILD_DIR/assets/icon/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "assets/screenshots" ]; then
|
if [ -d "assets/screenshots" ]; then
|
||||||
cp -R assets/screenshots/* "$BUILD_DIR/assets/screenshots/"
|
cp -R assets/screenshots/* "$BUILD_DIR/assets/screenshots/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy vendor directory if it exists
|
# Copy vendor directory if it exists
|
||||||
if [ -d "vendor" ]; then
|
if [ -d "vendor" ]; then
|
||||||
cp -R vendor "$BUILD_DIR/"
|
cp -R vendor "$BUILD_DIR/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create ZIP file
|
# Create ZIP file
|
||||||
echo "Creating ZIP file..."
|
echo "Creating ZIP file..."
|
||||||
cd build
|
cd build || exit 1
|
||||||
zip -r "../$ZIP_FILE" "$PLUGIN_SLUG" -x "*.DS_Store" -x "*.git*" -x "*.github*"
|
zip -r "../$ZIP_FILE" "$PLUGIN_SLUG" -x "*.DS_Store" -x "*.git*" -x "*.github*"
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Check if ZIP file was created successfully
|
# Check if ZIP file was created successfully
|
||||||
if [ -f "$ZIP_FILE" ]; then
|
if [ -f "$ZIP_FILE" ]; then
|
||||||
echo "✅ Build successful: $ZIP_FILE created"
|
echo "✅ Build successful: $ZIP_FILE created"
|
||||||
echo "File path: $(pwd)/$ZIP_FILE"
|
echo "File path: $(pwd)/$ZIP_FILE"
|
||||||
|
|
||||||
# Deploy to local WordPress installation if environment variable is set
|
# Deploy to local WordPress installation if environment variable is set
|
||||||
if [ -n "$WP_LOCAL_PLUGIN_DIR" ]; then
|
if [ -n "$WP_LOCAL_PLUGIN_DIR" ]; then
|
||||||
echo "\nDeploying to local WordPress installation..."
|
printf '\nDeploying to local WordPress installation...\n'
|
||||||
echo "Deploying to local WordPress installation..."
|
echo "Deploying to local WordPress installation..."
|
||||||
|
|
||||||
# Remove existing plugin directory
|
# Remove existing plugin directory
|
||||||
rm -rf "$WP_LOCAL_PLUGIN_DIR/$PLUGIN_SLUG"
|
rm -rf "${WP_LOCAL_PLUGIN_DIR:?}/$PLUGIN_SLUG"
|
||||||
|
|
||||||
# Copy files to local WordPress installation
|
# Copy files to local WordPress installation
|
||||||
rsync -av --exclude=".git" --exclude=".github" --exclude=".DS_Store" \
|
rsync -av --exclude=".git" --exclude=".github" --exclude=".DS_Store" \
|
||||||
"$BUILD_DIR/" "$WP_LOCAL_PLUGIN_DIR/$PLUGIN_SLUG"
|
"$BUILD_DIR/" "$WP_LOCAL_PLUGIN_DIR/$PLUGIN_SLUG"
|
||||||
|
|
||||||
# Clear WordPress transients if WP-CLI is available
|
# Clear WordPress transients if WP-CLI is available
|
||||||
if command -v wp &> /dev/null; then
|
if command -v wp &>/dev/null; then
|
||||||
echo "Clearing WordPress transients..."
|
echo "Clearing WordPress transients..."
|
||||||
wp transient delete --all --path="$WP_LOCAL_PLUGIN_DIR/../.."
|
wp transient delete --all --path="$WP_LOCAL_PLUGIN_DIR/../.."
|
||||||
else
|
else
|
||||||
echo "⚠️ WP-CLI not found, skipping transient clearing"
|
echo "⚠️ WP-CLI not found, skipping transient clearing"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "✅ Local deployment successful!"
|
echo "✅ Local deployment successful!"
|
||||||
echo "Plugin deployed to: $WP_LOCAL_PLUGIN_DIR/$PLUGIN_SLUG"
|
echo "Plugin deployed to: $WP_LOCAL_PLUGIN_DIR/$PLUGIN_SLUG"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "❌ Build failed: ZIP file was not created"
|
echo "❌ Build failed: ZIP file was not created"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user