@digitoimistodude/code-quality-checks 2.0.0 → 2.0.2
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/.husky/pre-commit +63 -38
- package/package.json +1 -1
package/.husky/pre-commit
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Ref: DEV-177, DEV-373, DEV-623
|
|
3
3
|
|
|
4
4
|
# Version:
|
|
5
|
-
VERSION="2.0.
|
|
5
|
+
VERSION="2.0.2 (2025-12-04)"
|
|
6
6
|
|
|
7
7
|
# Load configuration
|
|
8
8
|
# First check for local project config, then fall back to package default
|
|
@@ -19,11 +19,11 @@ else
|
|
|
19
19
|
CHECK_CHANGED_ONLY=true
|
|
20
20
|
fi
|
|
21
21
|
|
|
22
|
-
# Detect context: standalone theme or
|
|
23
|
-
#
|
|
22
|
+
# Detect context: standalone theme or dudestack project
|
|
23
|
+
# Dudestack projects have content/themes/ directory structure
|
|
24
24
|
detect_context() {
|
|
25
25
|
if [ -d "content/themes" ] && [ -f "composer.json" ]; then
|
|
26
|
-
echo "
|
|
26
|
+
echo "dudestack"
|
|
27
27
|
else
|
|
28
28
|
echo "standalone"
|
|
29
29
|
fi
|
|
@@ -112,10 +112,10 @@ print_logo
|
|
|
112
112
|
|
|
113
113
|
echo ""
|
|
114
114
|
echo "${MINT}Dude's husky quality control config v. ${VERSION}${NC}"
|
|
115
|
-
if [ "$CONTEXT" = "
|
|
116
|
-
echo "${MINT}${GEAR} Running pre-commit checks (
|
|
115
|
+
if [ "$CONTEXT" = "dudestack" ]; then
|
|
116
|
+
echo "${MINT}${GEAR} Running pre-commit checks (dudestack project)...${NC}"
|
|
117
117
|
else
|
|
118
|
-
echo "${MINT}${GEAR} Running pre-commit checks (
|
|
118
|
+
echo "${MINT}${GEAR} Running pre-commit checks (standalone theme)...${NC}"
|
|
119
119
|
fi
|
|
120
120
|
echo ""
|
|
121
121
|
|
|
@@ -143,8 +143,8 @@ if [ ! -f "phpcs.xml" ]; then
|
|
|
143
143
|
fi
|
|
144
144
|
echo "${GREEN}${CHECK} OK${NC}"
|
|
145
145
|
|
|
146
|
-
#
|
|
147
|
-
if [ "$CONTEXT" = "
|
|
146
|
+
# Dudestack-specific: Check that stylelintrc is NOT in root (should be in themes)
|
|
147
|
+
if [ "$CONTEXT" = "dudestack" ]; then
|
|
148
148
|
printf " ${ARROW} Checking for .stylelintrc in root (should not exist)... "
|
|
149
149
|
if [ -f ".stylelintrc" ] || [ -f ".stylelintrc.json" ] || [ -f ".stylelintrc.js" ] || [ -f ".stylelintrc.yml" ]; then
|
|
150
150
|
echo "${RED}${CROSS} FAILED${NC}"
|
|
@@ -169,25 +169,50 @@ if [ ! -d ".github/workflows" ]; then
|
|
|
169
169
|
fi
|
|
170
170
|
echo "${GREEN}${CHECK} OK${NC}"
|
|
171
171
|
|
|
172
|
-
|
|
173
|
-
if [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
172
|
+
# Check for gulpfile.js - location depends on context
|
|
173
|
+
if [ "$CONTEXT" = "dudestack" ]; then
|
|
174
|
+
# In dudestack, gulpfile.js is in themes
|
|
175
|
+
# Skip check if no themes exist yet (fresh dudestack template)
|
|
176
|
+
theme_count=$(find content/themes -maxdepth 1 -mindepth 1 -type d 2>/dev/null | wc -l | tr -d ' ')
|
|
177
|
+
if [ "$theme_count" -gt 0 ]; then
|
|
178
|
+
printf " ${ARROW} Checking for gulpfile.js in themes... "
|
|
179
|
+
gulpfile_found=false
|
|
180
|
+
for theme_dir in content/themes/*/; do
|
|
181
|
+
if [ -f "${theme_dir}gulpfile.js" ]; then
|
|
182
|
+
gulpfile_found=true
|
|
183
|
+
break
|
|
184
|
+
fi
|
|
185
|
+
done
|
|
186
|
+
if [ "$gulpfile_found" = false ]; then
|
|
187
|
+
echo "${RED}${CROSS} FAILED${NC}"
|
|
188
|
+
echo " ${RED}gulpfile.js is missing from theme directories${NC}"
|
|
189
|
+
echo " ${YELLOW}Please ensure Gulp is properly set up in your theme${NC}"
|
|
190
|
+
exit 1
|
|
191
|
+
fi
|
|
192
|
+
echo "${GREEN}${CHECK} OK${NC}"
|
|
193
|
+
fi
|
|
194
|
+
else
|
|
195
|
+
# In standalone theme, gulpfile.js is in root
|
|
196
|
+
printf " ${ARROW} Checking for gulpfile.js... "
|
|
197
|
+
if [ ! -f "gulpfile.js" ]; then
|
|
198
|
+
echo "${RED}${CROSS} FAILED${NC}"
|
|
199
|
+
echo " ${RED}gulpfile.js is missing from root directory${NC}"
|
|
200
|
+
echo " ${YELLOW}Please ensure Gulp is properly set up${NC}"
|
|
201
|
+
exit 1
|
|
202
|
+
fi
|
|
203
|
+
echo "${GREEN}${CHECK} OK${NC}"
|
|
180
204
|
|
|
181
|
-
printf " ${ARROW} Checking for gulp in package.json... "
|
|
182
|
-
if [ -f "package.json" ] && ! npm list gulp >/dev/null 2>&1; then
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
205
|
+
printf " ${ARROW} Checking for gulp in package.json... "
|
|
206
|
+
if [ -f "package.json" ] && ! npm list gulp >/dev/null 2>&1; then
|
|
207
|
+
echo "${RED}${CROSS} FAILED${NC}"
|
|
208
|
+
echo " ${RED}Gulp is not installed${NC}"
|
|
209
|
+
echo " ${YELLOW}Please install Gulp:${NC}"
|
|
210
|
+
echo " ${BLUE}nvm use${NC}"
|
|
211
|
+
echo " ${BLUE}npm install gulp --save-dev${NC}"
|
|
212
|
+
exit 1
|
|
213
|
+
fi
|
|
214
|
+
echo "${GREEN}${CHECK} OK${NC}"
|
|
189
215
|
fi
|
|
190
|
-
echo "${GREEN}${CHECK} OK${NC}"
|
|
191
216
|
|
|
192
217
|
printf " ${ARROW} Checking for root CHANGELOG.md... "
|
|
193
218
|
if [ ! -f "CHANGELOG.md" ]; then
|
|
@@ -199,8 +224,8 @@ if [ ! -f "CHANGELOG.md" ]; then
|
|
|
199
224
|
fi
|
|
200
225
|
echo "${GREEN}${CHECK} OK${NC}"
|
|
201
226
|
|
|
202
|
-
#
|
|
203
|
-
if [ "$CONTEXT" = "
|
|
227
|
+
# Dudestack-specific: Check CHANGELOG.md format and freshness
|
|
228
|
+
if [ "$CONTEXT" = "dudestack" ]; then
|
|
204
229
|
printf " ${ARROW} Checking CHANGELOG.md format and freshness... "
|
|
205
230
|
# Check CHANGELOG.md format and date
|
|
206
231
|
if [ -f "CHANGELOG.md" ]; then
|
|
@@ -355,8 +380,8 @@ if [ "$CONTEXT" = "bedrock" ]; then
|
|
|
355
380
|
done
|
|
356
381
|
fi
|
|
357
382
|
|
|
358
|
-
#
|
|
359
|
-
if [ "$CONTEXT" = "
|
|
383
|
+
# Dudestack-specific: Check WordPress version
|
|
384
|
+
if [ "$CONTEXT" = "dudestack" ]; then
|
|
360
385
|
echo ""
|
|
361
386
|
# Check WordPress version
|
|
362
387
|
echo "${CYAN}${PACKAGE} Checking WordPress version...${NC}"
|
|
@@ -401,8 +426,8 @@ echo ""
|
|
|
401
426
|
# Check if dependencies are up to date
|
|
402
427
|
echo "${CYAN}${PACKAGE} Checking dependencies...${NC}"
|
|
403
428
|
|
|
404
|
-
#
|
|
405
|
-
if [ "$CONTEXT" = "
|
|
429
|
+
# Dudestack-specific: Check root composer.json
|
|
430
|
+
if [ "$CONTEXT" = "dudestack" ] && [ -f "composer.json" ]; then
|
|
406
431
|
printf " ${ARROW} Checking root composer dependencies... "
|
|
407
432
|
if [ ! -f "composer.lock" ]; then
|
|
408
433
|
echo "${RED}${CROSS} FAILED${NC}"
|
|
@@ -451,8 +476,8 @@ if [ -f "package.json" ]; then
|
|
|
451
476
|
echo "${GREEN}${CHECK} OK${NC}"
|
|
452
477
|
fi
|
|
453
478
|
|
|
454
|
-
#
|
|
455
|
-
if [ "$CONTEXT" = "
|
|
479
|
+
# Dudestack-specific: Check all themes with package.json
|
|
480
|
+
if [ "$CONTEXT" = "dudestack" ] && [ -d "content/themes" ]; then
|
|
456
481
|
for theme_dir in content/themes/*/; do
|
|
457
482
|
if [ -f "${theme_dir}package.json" ]; then
|
|
458
483
|
theme_name=$(basename "$theme_dir")
|
|
@@ -594,7 +619,7 @@ if [ -n "$scss_files" ]; then
|
|
|
594
619
|
|
|
595
620
|
# Find stylelint config
|
|
596
621
|
stylelint_config=""
|
|
597
|
-
if [ "$CONTEXT" = "
|
|
622
|
+
if [ "$CONTEXT" = "dudestack" ]; then
|
|
598
623
|
# Find stylelint config in theme directories
|
|
599
624
|
for theme_dir in content/themes/*/; do
|
|
600
625
|
if [ -f "${theme_dir}.stylelintrc" ]; then
|
|
@@ -680,7 +705,7 @@ if [ "$CHECK_CHANGED_ONLY" = "true" ]; then
|
|
|
680
705
|
else
|
|
681
706
|
# Check entire codebase (original behavior)
|
|
682
707
|
printf " ${ARROW} Checking PHP 8.3 compatibility on entire codebase... "
|
|
683
|
-
if [ "$CONTEXT" = "
|
|
708
|
+
if [ "$CONTEXT" = "dudestack" ]; then
|
|
684
709
|
php_syntax_output=$(find -L . -name '*.php' -not -path "./vendor/*" -not -path "./node_modules/*" -not -path "./src/*" -not -path "./js/*" -not -path "./css/*" -not -path "./sass/*" -not -path "./plugin-update-checker/*" -not -path "./content/themes/*" -not -path "./content/plugins/*" -not -path "./content/uploads/*" -not -path "./content/languages/*" -not -path "./content-mu-plugins/*" -not -path "./media/*" -not -path "./wp/*" -exec php -l {} \; 2>&1)
|
|
685
710
|
else
|
|
686
711
|
php_syntax_output=$(find -L . -name '*.php' -not -path "./vendor/*" -not -path "./node_modules/*" -exec php -l {} \; 2>&1)
|
|
@@ -735,8 +760,8 @@ else
|
|
|
735
760
|
fi
|
|
736
761
|
|
|
737
762
|
|
|
738
|
-
#
|
|
739
|
-
if [ "$CONTEXT" = "
|
|
763
|
+
# Dudestack-specific: Check PHP files with PHPCS on entire codebase
|
|
764
|
+
if [ "$CONTEXT" = "dudestack" ] && [ -f "phpcs.xml" ] && [ -f "./vendor/bin/phpcs" ]; then
|
|
740
765
|
echo " ${ARROW} Running PHP CodeSniffer on entire codebase..."
|
|
741
766
|
# Use the same pattern as your GitHub Actions workflow
|
|
742
767
|
if ./vendor/bin/phpcs -p . --extensions=php --ignore=vendor,content/themes,content/plugins,content/uploads,node_modules,src,js,css,sass,plugin-update-checker,wp,mu-plugins/air-blocks-acf-example-data,content/languages,scripts/Roots/Bedrock/Installer.php,index.php,content/mu-plugins --standard=phpcs.xml; then
|