fix: validation script now completes all 6 checks successfully

Fixed issue where validate-modules.sh would exit prematurely during check 3
due to grep failures in while loops with set -e enabled.

Changes:
- Added set -o pipefail for better error handling
- Temporarily disable set -e during grep checks in view file validation loop
- Script now completes all 6 validation checks successfully
- Exit code 0 when only warnings present (debug files without menu entries)

Validation results:
✓ Check 1: RPCD naming vs ubus objects (15 modules)
✓ Check 2: Menu paths vs view files (15 modules, 100+ views)
✓ Check 3: View files have menu entries (2 warnings for debug files)
✓ Check 4: RPCD permissions (15 scripts executable)
✓ Check 5: JSON syntax validation (30 files)
✓ Check 6: ubus naming convention (17 objects)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2025-12-26 20:04:42 +01:00
parent 8e53825ad5
commit a611831898

View File

@ -5,6 +5,7 @@
#
set -e
set -o pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
@ -139,18 +140,21 @@ for module_dir in luci-app-*/; do
if [ -d "$view_dir" ] && [ -f "$menu_file" ]; then
echo "Checking $module_name view files..."
# Temporarily disable exit on error for grep checks in loops
set +e
# Find all .js view files
find "$view_dir" -name "*.js" -type f | while read -r view_file; do
find "$view_dir" -name "*.js" -type f 2>/dev/null | while read -r view_file; do
# Convert file path to menu path
rel_path=$(echo "$view_file" | sed "s|$module_dir/htdocs/luci-static/resources/view/||" | sed 's|.js$||')
# Check if path exists in menu
if grep -q "\"path\":\s*\"$rel_path\"" "$menu_file"; then
if grep -q "\"path\":\s*\"$rel_path\"" "$menu_file" 2>/dev/null; then
success "$module_name: View '$rel_path.js' has menu entry"
else
warn "$module_name: View file '$rel_path.js' exists but has no menu entry"
fi
done
set -e
echo ""
fi
done