11#! /bin/bash
2- set -e
2+
3+ # ===== Required Tools and Rulesets Check =====
4+
5+ # CLI tools
6+ REQUIRED_TOOLS=(phpcs phpcbf stylelint)
7+ for tool in " ${REQUIRED_TOOLS[@]} " ; do
8+ if ! command -v " $tool " & > /dev/null; then
9+ echo " ❌ Required tool '$tool ' is not installed or not in PATH."
10+ missing_any=1
11+ else
12+ echo " ✅ Found '$tool '"
13+ fi
14+ done
15+
16+ # PHP_CodeSniffer standards
17+ if command -v phpcs & > /dev/null; then
18+ phpcs_standards=$( phpcs -i | sed ' s/.*: //; s/, /\n/g' )
19+ for standard in PHPCompatibilityWP WordPress; do
20+ if ! grep -q " ^$standard $" <<< " $phpcs_standards" ; then
21+ echo " ❌ phpcs standard '$standard ' is missing."
22+ missing_any=1
23+ else
24+ echo " ✅ phpcs standard '$standard ' is available."
25+ fi
26+ done
27+ fi
28+
29+ # Stylelint config standard: Try a dry run
30+ if command -v stylelint & > /dev/null; then
31+ # Check for Stylelint config file
32+ if ! ls .stylelintrc* stylelint.config.* package.json 2> /dev/null | grep -q . ; then
33+ echo " ❌ No Stylelint config file (.stylelintrc, stylelint.config.js, etc) found in this directory."
34+ missing_any=1
35+ elif ! stylelint --print-config . 1> /dev/null 2>&1 ; then
36+ echo " ❌ stylelint-config-standard is installed but not available to Stylelint in this directory."
37+ echo " Check your NODE_PATH or ensure your config extends 'stylelint-config-standard'."
38+ echo " If using Arch, you may need to set: export NODE_PATH=/usr/lib/node_modules"
39+ missing_any=1
40+ else
41+ echo " ✅ stylelint-config-standard is available to stylelint."
42+ fi
43+ fi
44+
45+ # Final check
46+ if [[ $missing_any == 1 ]]; then
47+ echo
48+ echo " One or more required tools or rulesets are missing."
49+ echo " Please install them by your preferred means (package manager, npm, composer, etc)."
50+ echo " After installation, ensure all tools and rulesets are available in your PATH and project."
51+ exit 1
52+ else
53+ echo
54+ echo " All required tools and rulesets are available."
55+ fi
56+
57+ # ===== End Required Tools and Rulesets Check =====
358
459# Update readme.txt.
560# $1 lineMatch value.
@@ -8,7 +63,7 @@ updateReadme() {
863 sed -i " /$1 */c $1 $2 " ./readme.txt
964}
1065
11- # Update readme.txt .
66+ # Update cloudflare-stream.php .
1267# $1 lineMatch value.
1368# $2 new value/version.
1469updateCloudflareStreamPHP () {
@@ -18,22 +73,10 @@ updateCloudflareStreamPHP() {
1873# Test PHP version compatibility
1974versions=(7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4)
2075
21- # Check for phpcs
22- if ! command -v phpcs & > /dev/null; then
23- echo " Error: phpcs is not installed or not in your PATH."
24- exit 1
25- fi
26-
27- if ! phpcs -i | grep -q ' PHPCompatibilityWP' ; then
28- echo " Error: PHPCompatibilityWP standard is not installed for phpcs."
29- exit 1
30- fi
31-
3276incompatible_versions=()
3377compatible_versions=()
3478fatal_error_detected=0
3579
36- # Test compatibility against versions specified in $versions
3780for version in " ${versions[@]} " ; do
3881 echo " ------------------------------------------"
3982 echo " Testing PHP compatibility: $version +"
@@ -94,7 +137,8 @@ if [[ $pluginVer =~ [0-9] ]]; then
94137 echo " Updating plugin version from $currentVer to $pluginVer ."
95138 updateReadme " $lineMatch " " $pluginVer "
96139 updateCloudflareStreamPHP " $lineMatch " " $pluginVer "
97- # Update version in package.json and package-lock.json using sed
140+
141+ # Update package.json and package-lock.json to match
98142 sed -i " s/\" version\" : \" .*\" /\" version\" : \" $pluginVer \" /" package.json
99143 sed -i " s/\" version\" : \" .*\" /\" version\" : \" $pluginVer \" /" package-lock.json
100144else
@@ -137,4 +181,11 @@ if [[ "$jsStandard" == [Yy]* ]]; then
137181fi
138182
139183# CSS Linting
140-
184+ read -p " Lint CSS with Stylelint against stylelint-config-standard? [y/n]: " cssStandard
185+ if [[ " $cssStandard " == [Yy]* ]]; then
186+ # You may want to adjust the path pattern as needed (e.g., 'src/**/*.css' or just '*.css')
187+ stylelint " **/*.css"
188+ # Optionally, prompt for listing outstanding issues (stylelint outputs all by default)
189+ else
190+ echo " Skipping CSS linting..."
191+ fi
0 commit comments