@digitoimistodude/code-quality-checks 2.0.3 → 2.1.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 CHANGED
@@ -2,7 +2,7 @@
2
2
  # Ref: DEV-177, DEV-373, DEV-623
3
3
 
4
4
  # Version:
5
- VERSION="2.0.2 (2025-12-04)"
5
+ VERSION="2.1.1 (2026-01-09)"
6
6
 
7
7
  # Load configuration
8
8
  # First check for local project config, then fall back to package default
@@ -169,49 +169,109 @@ if [ ! -d ".github/workflows" ]; then
169
169
  fi
170
170
  echo "${GREEN}${CHECK} OK${NC}"
171
171
 
172
- # Check for gulpfile.js - location depends on context
172
+ # Detect build system: Parcel or Gulp
173
+ detect_build_system() {
174
+ local pkg_json="$1"
175
+ if [ -f "$pkg_json" ]; then
176
+ if grep -q '"parcel"' "$pkg_json"; then
177
+ echo "parcel"
178
+ elif grep -q '"gulp"' "$pkg_json"; then
179
+ echo "gulp"
180
+ else
181
+ echo "unknown"
182
+ fi
183
+ else
184
+ echo "unknown"
185
+ fi
186
+ }
187
+
188
+ # Check build system configuration - location depends on context
173
189
  if [ "$CONTEXT" = "dudestack" ]; then
174
- # In dudestack, gulpfile.js is in themes
190
+ # In dudestack, build files are in themes
175
191
  # Skip check if no themes exist yet (fresh dudestack template)
176
192
  theme_count=$(find content/themes -maxdepth 1 -mindepth 1 -type d 2>/dev/null | wc -l | tr -d ' ')
177
193
  if [ "$theme_count" -gt 0 ]; then
178
- printf " ${ARROW} Checking for gulpfile.js in themes... "
179
- gulpfile_found=false
180
194
  for theme_dir in content/themes/*/; do
181
- if [ -f "${theme_dir}gulpfile.js" ]; then
182
- gulpfile_found=true
183
- break
195
+ if [ -f "${theme_dir}package.json" ]; then
196
+ BUILD_SYSTEM=$(detect_build_system "${theme_dir}package.json")
197
+ theme_name=$(basename "$theme_dir")
198
+
199
+ if [ "$BUILD_SYSTEM" = "parcel" ]; then
200
+ printf " ${ARROW} Checking Parcel config in theme '${theme_name}'... "
201
+ if [ -f "${theme_dir}.parcelrc" ] || [ -f "${theme_dir}parcel.config.js" ]; then
202
+ echo "${GREEN}${CHECK} OK${NC}"
203
+ else
204
+ echo "${RED}${CROSS} FAILED${NC}"
205
+ echo " ${RED}.parcelrc is missing from theme directory${NC}"
206
+ echo " ${YELLOW}Please ensure Parcel is properly configured${NC}"
207
+ exit 1
208
+ fi
209
+ elif [ "$BUILD_SYSTEM" = "gulp" ]; then
210
+ printf " ${ARROW} Checking gulpfile.js in theme '${theme_name}'... "
211
+ if [ -f "${theme_dir}gulpfile.js" ]; then
212
+ echo "${GREEN}${CHECK} OK${NC}"
213
+ else
214
+ echo "${RED}${CROSS} FAILED${NC}"
215
+ echo " ${RED}gulpfile.js is missing from theme directory${NC}"
216
+ echo " ${YELLOW}Please ensure Gulp is properly set up${NC}"
217
+ exit 1
218
+ fi
219
+ fi
184
220
  fi
185
221
  done
186
- if [ "$gulpfile_found" = false ]; then
222
+ fi
223
+ else
224
+ # Standalone theme - check root
225
+ BUILD_SYSTEM=$(detect_build_system "package.json")
226
+
227
+ if [ "$BUILD_SYSTEM" = "parcel" ]; then
228
+ printf " ${ARROW} Checking for Parcel configuration... "
229
+ if [ -f ".parcelrc" ] || [ -f "parcel.config.js" ]; then
230
+ echo "${GREEN}${CHECK} OK${NC}"
231
+ else
232
+ echo "${RED}${CROSS} FAILED${NC}"
233
+ echo " ${RED}.parcelrc is missing from root directory${NC}"
234
+ echo " ${YELLOW}Please ensure Parcel is properly configured${NC}"
235
+ exit 1
236
+ fi
237
+
238
+ printf " ${ARROW} Checking for parcel in package.json... "
239
+ if [ -f "package.json" ] && ! npm list parcel >/dev/null 2>&1; then
187
240
  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}"
241
+ echo " ${RED}Parcel is not installed${NC}"
242
+ echo " ${YELLOW}Please install Parcel:${NC}"
243
+ echo " ${BLUE}nvm use${NC}"
244
+ echo " ${BLUE}npm install parcel --save-dev${NC}"
190
245
  exit 1
191
246
  fi
192
247
  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}"
204
248
 
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
249
+ elif [ "$BUILD_SYSTEM" = "gulp" ]; then
250
+ printf " ${ARROW} Checking for gulpfile.js... "
251
+ if [ ! -f "gulpfile.js" ]; then
252
+ echo "${RED}${CROSS} FAILED${NC}"
253
+ echo " ${RED}gulpfile.js is missing from root directory${NC}"
254
+ echo " ${YELLOW}Please ensure Gulp is properly set up${NC}"
255
+ exit 1
256
+ fi
257
+ echo "${GREEN}${CHECK} OK${NC}"
258
+
259
+ printf " ${ARROW} Checking for gulp in package.json... "
260
+ if [ -f "package.json" ] && ! npm list gulp >/dev/null 2>&1; then
261
+ echo "${RED}${CROSS} FAILED${NC}"
262
+ echo " ${RED}Gulp is not installed${NC}"
263
+ echo " ${YELLOW}Please install Gulp:${NC}"
264
+ echo " ${BLUE}nvm use${NC}"
265
+ echo " ${BLUE}npm install gulp --save-dev${NC}"
266
+ exit 1
267
+ fi
268
+ echo "${GREEN}${CHECK} OK${NC}"
269
+
270
+ else
271
+ printf " ${ARROW} Checking for build system... "
272
+ echo "${YELLOW}⚠️ UNKNOWN${NC}"
273
+ echo " ${YELLOW}No Parcel or Gulp found in package.json${NC}"
213
274
  fi
214
- echo "${GREEN}${CHECK} OK${NC}"
215
275
  fi
216
276
 
217
277
  printf " ${ARROW} Checking for root CHANGELOG.md... "
@@ -617,16 +677,19 @@ scss_files=$(git diff --cached --name-only --diff-filter=ACM | grep '\.scss$' |
617
677
  if [ -n "$scss_files" ]; then
618
678
  printf " ${ARROW} Running stylelint on changed SCSS files... "
619
679
 
620
- # Find stylelint config
680
+ # Find stylelint config and binary
621
681
  stylelint_config=""
682
+ stylelint_bin=""
622
683
  if [ "$CONTEXT" = "dudestack" ]; then
623
- # Find stylelint config in theme directories
684
+ # Find stylelint config and binary in theme directories
624
685
  for theme_dir in content/themes/*/; do
625
686
  if [ -f "${theme_dir}.stylelintrc" ]; then
626
687
  stylelint_config="${theme_dir}.stylelintrc"
688
+ stylelint_bin="${theme_dir}node_modules/.bin/stylelint"
627
689
  break
628
690
  elif [ -f "${theme_dir}.stylelintrc.json" ]; then
629
691
  stylelint_config="${theme_dir}.stylelintrc.json"
692
+ stylelint_bin="${theme_dir}node_modules/.bin/stylelint"
630
693
  break
631
694
  fi
632
695
  done
@@ -641,10 +704,18 @@ if [ -n "$scss_files" ]; then
641
704
  elif [ -f ".stylelintrc.yml" ]; then
642
705
  stylelint_config=".stylelintrc.yml"
643
706
  fi
707
+ stylelint_bin="./node_modules/.bin/stylelint"
644
708
  fi
645
709
 
646
710
  if [ -n "$stylelint_config" ]; then
647
- if ! npx stylelint --config "$stylelint_config" $scss_files 2>/dev/null; then
711
+ # Use local stylelint if available, fall back to npx
712
+ if [ -x "$stylelint_bin" ]; then
713
+ stylelint_cmd="$stylelint_bin"
714
+ else
715
+ stylelint_cmd="npx stylelint"
716
+ fi
717
+
718
+ if ! $stylelint_cmd --config "$stylelint_config" $scss_files 2>/dev/null; then
648
719
  echo "${RED}${CROSS} FAILED${NC}"
649
720
  echo " ${RED}Stylelint found errors in SCSS files${NC}"
650
721
  echo " ${YELLOW}Please fix the following files:${NC}"
@@ -652,7 +723,7 @@ if [ -n "$scss_files" ]; then
652
723
  echo " ${YELLOW}• $file${NC}"
653
724
  done
654
725
  echo " ${YELLOW}To see detailed errors:${NC}"
655
- echo " ${BLUE}npx stylelint --config \"$stylelint_config\" $scss_files${NC}"
726
+ echo " ${BLUE}$stylelint_cmd --config \"$stylelint_config\" $scss_files${NC}"
656
727
  exit 1
657
728
  fi
658
729
  echo "${GREEN}${CHECK} OK${NC}"
package/README.md CHANGED
@@ -7,10 +7,11 @@ Dude's comprehensive code quality definitions and pre-commit hooks for WordPress
7
7
  ## Features
8
8
 
9
9
  * Pre-commit hooks with comprehensive code quality checks
10
- * Automatic context detection (standalone theme vs Bedrock project)
10
+ * Automatic context detection (standalone theme vs dudestack project)
11
+ * Build system detection (Parcel or Gulp)
11
12
  * PHP CodeSniffer validation
12
13
  * Stylelint for SCSS files
13
- * WordPress version checks (Bedrock mode)
14
+ * WordPress version checks (dudestack mode)
14
15
  * Dependency validation for Composer and npm
15
16
  * Merge conflict and scissor mark detection
16
17
  * Commit message validation with Linear integration
@@ -53,10 +54,10 @@ chmod +x .husky/pre-commit .husky/commit-msg
53
54
 
54
55
  The hooks automatically detect whether they're running in:
55
56
 
56
- * **Bedrock project**: Has `content/themes/` directory and `composer.json`
57
+ * **dudestack project**: Has `content/themes/` directory and `composer.json`
57
58
  * **Standalone theme**: Everything else
58
59
 
59
- ### Bedrock mode checks
60
+ ### dudestack mode checks
60
61
 
61
62
  * WordPress version in composer.json
62
63
  * Composer dependencies
@@ -67,7 +68,8 @@ The hooks automatically detect whether they're running in:
67
68
 
68
69
  ### Standalone mode checks
69
70
 
70
- * Basic file requirements (.nvmrc, phpcs.xml, gulpfile.js)
71
+ * Basic file requirements (.nvmrc, phpcs.xml)
72
+ * Build system config (Parcel: .parcelrc or Gulp: gulpfile.js)
71
73
  * npm dependencies
72
74
  * Stylelint config in current directory
73
75
  * PHP syntax validation
@@ -95,7 +97,7 @@ CHECK_CHANGED_ONLY=true
95
97
 
96
98
  * Node.js >= 18.0.0
97
99
  * PHP >= 8.1
98
- * Composer (for Bedrock projects)
100
+ * Composer (for dudestack projects)
99
101
  * husky >= 9.1.7
100
102
 
101
103
  ## Updating
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitoimistodude/code-quality-checks",
3
- "version": "2.0.3",
3
+ "version": "2.1.1",
4
4
  "description": "Code quality definitions and Husky pre-commit hooks for Dude WordPress projects",
5
5
  "main": "index.js",
6
6
  "files": [