@digitoimistodude/code-quality-checks 2.0.2 → 2.1.0
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/commit-msg +1 -1
- package/.husky/pre-commit +91 -31
- package/README.md +9 -7
- package/package.json +1 -1
package/.husky/commit-msg
CHANGED
|
@@ -92,7 +92,7 @@ if [ -f "$commit_msg_file" ]; then
|
|
|
92
92
|
changelog_first_line=$(head -n 1 CHANGELOG.md)
|
|
93
93
|
current_date=$(date +%Y-%m-%d)
|
|
94
94
|
if ! echo "$changelog_first_line" | grep -q "$current_date"; then
|
|
95
|
-
echo "${GREEN}║${NC} ${GREEN}• Consider updating changelog date to $current_date${NC}$(printf '%*s'
|
|
95
|
+
echo "${GREEN}║${NC} ${GREEN}• Consider updating changelog date to $current_date${NC}$(printf '%*s' 9 '')${GREEN}║${NC}"
|
|
96
96
|
fi
|
|
97
97
|
fi
|
|
98
98
|
|
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.1.0 (2026-01-08)"
|
|
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
|
-
#
|
|
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,
|
|
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}
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
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
|
|
187
232
|
echo "${RED}${CROSS} FAILED${NC}"
|
|
188
|
-
echo " ${RED}
|
|
189
|
-
echo " ${YELLOW}Please ensure
|
|
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
|
|
240
|
+
echo "${RED}${CROSS} FAILED${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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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... "
|
package/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
# Code quality checks
|
|
2
2
|
|
|
3
|
-
[](#)
|
|
3
|
+
[](#) [](https://www.npmjs.com/package/@digitoimistodude/code-quality-checks)
|
|
4
4
|
|
|
5
5
|
Dude's comprehensive code quality definitions and pre-commit hooks for WordPress projects.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
* Pre-commit hooks with comprehensive code quality checks
|
|
10
|
-
* Automatic context detection (standalone theme vs
|
|
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 (
|
|
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
|
-
* **
|
|
57
|
+
* **dudestack project**: Has `content/themes/` directory and `composer.json`
|
|
57
58
|
* **Standalone theme**: Everything else
|
|
58
59
|
|
|
59
|
-
###
|
|
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
|
|
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
|
|
100
|
+
* Composer (for dudestack projects)
|
|
99
101
|
* husky >= 9.1.7
|
|
100
102
|
|
|
101
103
|
## Updating
|