@digitoimistodude/code-quality-checks 2.0.0 → 2.0.1
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 +59 -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.1 (2025-12-03)"
|
|
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,46 @@ 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
|
+
printf " ${ARROW} Checking for gulpfile.js in themes... "
|
|
176
|
+
gulpfile_found=false
|
|
177
|
+
for theme_dir in content/themes/*/; do
|
|
178
|
+
if [ -f "${theme_dir}gulpfile.js" ]; then
|
|
179
|
+
gulpfile_found=true
|
|
180
|
+
break
|
|
181
|
+
fi
|
|
182
|
+
done
|
|
183
|
+
if [ "$gulpfile_found" = false ]; then
|
|
184
|
+
echo "${RED}${CROSS} FAILED${NC}"
|
|
185
|
+
echo " ${RED}gulpfile.js is missing from theme directories${NC}"
|
|
186
|
+
echo " ${YELLOW}Please ensure Gulp is properly set up in your theme${NC}"
|
|
187
|
+
exit 1
|
|
188
|
+
fi
|
|
189
|
+
echo "${GREEN}${CHECK} OK${NC}"
|
|
190
|
+
else
|
|
191
|
+
# In standalone theme, gulpfile.js is in root
|
|
192
|
+
printf " ${ARROW} Checking for gulpfile.js... "
|
|
193
|
+
if [ ! -f "gulpfile.js" ]; then
|
|
194
|
+
echo "${RED}${CROSS} FAILED${NC}"
|
|
195
|
+
echo " ${RED}gulpfile.js is missing from root directory${NC}"
|
|
196
|
+
echo " ${YELLOW}Please ensure Gulp is properly set up${NC}"
|
|
197
|
+
exit 1
|
|
198
|
+
fi
|
|
199
|
+
echo "${GREEN}${CHECK} OK${NC}"
|
|
180
200
|
|
|
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
|
-
|
|
201
|
+
printf " ${ARROW} Checking for gulp in package.json... "
|
|
202
|
+
if [ -f "package.json" ] && ! npm list gulp >/dev/null 2>&1; then
|
|
203
|
+
echo "${RED}${CROSS} FAILED${NC}"
|
|
204
|
+
echo " ${RED}Gulp is not installed${NC}"
|
|
205
|
+
echo " ${YELLOW}Please install Gulp:${NC}"
|
|
206
|
+
echo " ${BLUE}nvm use${NC}"
|
|
207
|
+
echo " ${BLUE}npm install gulp --save-dev${NC}"
|
|
208
|
+
exit 1
|
|
209
|
+
fi
|
|
210
|
+
echo "${GREEN}${CHECK} OK${NC}"
|
|
189
211
|
fi
|
|
190
|
-
echo "${GREEN}${CHECK} OK${NC}"
|
|
191
212
|
|
|
192
213
|
printf " ${ARROW} Checking for root CHANGELOG.md... "
|
|
193
214
|
if [ ! -f "CHANGELOG.md" ]; then
|
|
@@ -199,8 +220,8 @@ if [ ! -f "CHANGELOG.md" ]; then
|
|
|
199
220
|
fi
|
|
200
221
|
echo "${GREEN}${CHECK} OK${NC}"
|
|
201
222
|
|
|
202
|
-
#
|
|
203
|
-
if [ "$CONTEXT" = "
|
|
223
|
+
# Dudestack-specific: Check CHANGELOG.md format and freshness
|
|
224
|
+
if [ "$CONTEXT" = "dudestack" ]; then
|
|
204
225
|
printf " ${ARROW} Checking CHANGELOG.md format and freshness... "
|
|
205
226
|
# Check CHANGELOG.md format and date
|
|
206
227
|
if [ -f "CHANGELOG.md" ]; then
|
|
@@ -355,8 +376,8 @@ if [ "$CONTEXT" = "bedrock" ]; then
|
|
|
355
376
|
done
|
|
356
377
|
fi
|
|
357
378
|
|
|
358
|
-
#
|
|
359
|
-
if [ "$CONTEXT" = "
|
|
379
|
+
# Dudestack-specific: Check WordPress version
|
|
380
|
+
if [ "$CONTEXT" = "dudestack" ]; then
|
|
360
381
|
echo ""
|
|
361
382
|
# Check WordPress version
|
|
362
383
|
echo "${CYAN}${PACKAGE} Checking WordPress version...${NC}"
|
|
@@ -401,8 +422,8 @@ echo ""
|
|
|
401
422
|
# Check if dependencies are up to date
|
|
402
423
|
echo "${CYAN}${PACKAGE} Checking dependencies...${NC}"
|
|
403
424
|
|
|
404
|
-
#
|
|
405
|
-
if [ "$CONTEXT" = "
|
|
425
|
+
# Dudestack-specific: Check root composer.json
|
|
426
|
+
if [ "$CONTEXT" = "dudestack" ] && [ -f "composer.json" ]; then
|
|
406
427
|
printf " ${ARROW} Checking root composer dependencies... "
|
|
407
428
|
if [ ! -f "composer.lock" ]; then
|
|
408
429
|
echo "${RED}${CROSS} FAILED${NC}"
|
|
@@ -451,8 +472,8 @@ if [ -f "package.json" ]; then
|
|
|
451
472
|
echo "${GREEN}${CHECK} OK${NC}"
|
|
452
473
|
fi
|
|
453
474
|
|
|
454
|
-
#
|
|
455
|
-
if [ "$CONTEXT" = "
|
|
475
|
+
# Dudestack-specific: Check all themes with package.json
|
|
476
|
+
if [ "$CONTEXT" = "dudestack" ] && [ -d "content/themes" ]; then
|
|
456
477
|
for theme_dir in content/themes/*/; do
|
|
457
478
|
if [ -f "${theme_dir}package.json" ]; then
|
|
458
479
|
theme_name=$(basename "$theme_dir")
|
|
@@ -594,7 +615,7 @@ if [ -n "$scss_files" ]; then
|
|
|
594
615
|
|
|
595
616
|
# Find stylelint config
|
|
596
617
|
stylelint_config=""
|
|
597
|
-
if [ "$CONTEXT" = "
|
|
618
|
+
if [ "$CONTEXT" = "dudestack" ]; then
|
|
598
619
|
# Find stylelint config in theme directories
|
|
599
620
|
for theme_dir in content/themes/*/; do
|
|
600
621
|
if [ -f "${theme_dir}.stylelintrc" ]; then
|
|
@@ -680,7 +701,7 @@ if [ "$CHECK_CHANGED_ONLY" = "true" ]; then
|
|
|
680
701
|
else
|
|
681
702
|
# Check entire codebase (original behavior)
|
|
682
703
|
printf " ${ARROW} Checking PHP 8.3 compatibility on entire codebase... "
|
|
683
|
-
if [ "$CONTEXT" = "
|
|
704
|
+
if [ "$CONTEXT" = "dudestack" ]; then
|
|
684
705
|
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
706
|
else
|
|
686
707
|
php_syntax_output=$(find -L . -name '*.php' -not -path "./vendor/*" -not -path "./node_modules/*" -exec php -l {} \; 2>&1)
|
|
@@ -735,8 +756,8 @@ else
|
|
|
735
756
|
fi
|
|
736
757
|
|
|
737
758
|
|
|
738
|
-
#
|
|
739
|
-
if [ "$CONTEXT" = "
|
|
759
|
+
# Dudestack-specific: Check PHP files with PHPCS on entire codebase
|
|
760
|
+
if [ "$CONTEXT" = "dudestack" ] && [ -f "phpcs.xml" ] && [ -f "./vendor/bin/phpcs" ]; then
|
|
740
761
|
echo " ${ARROW} Running PHP CodeSniffer on entire codebase..."
|
|
741
762
|
# Use the same pattern as your GitHub Actions workflow
|
|
742
763
|
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
|