1+ #! /bin/bash
2+
3+ PROJECTS_DIR=" $HOME /projects/liberu"
4+ BOILERPLATE_DIR=" $PROJECTS_DIR /boilerplate-laravel"
5+ LOG_FILE=" $HOME /update-projects.log"
6+ TIMESTAMP=$( date " +%Y-%m-%d %H:%M:%S" )
7+
8+ echo " ===== Starting update: $TIMESTAMP =====" | tee -a " $LOG_FILE "
9+
10+ # List of repos to update
11+ REPOS=(
12+ " ecommerce-laravel"
13+ " browser-game-laravel"
14+ " real-estate-laravel"
15+ " accounting-laravel"
16+ " cms-laravel"
17+ " maintenance-laravel"
18+ " social-network-laravel"
19+ " automation-laravel"
20+ " control-panel-laravel"
21+ " genealogy-laravel"
22+ " billing-laravel"
23+ " crm-laravel"
24+ " liberu-website"
25+ " ofie"
26+ " floralgo"
27+ )
28+
29+ for repo in " ${REPOS[@]} " ; do
30+ TARGET_DIR=" $PROJECTS_DIR /$repo "
31+
32+ if [ -d " $TARGET_DIR /.git" ]; then
33+ echo " ----- Processing $repo -----" | tee -a " $LOG_FILE "
34+ cd " $TARGET_DIR " || { echo " Failed to enter $TARGET_DIR " | tee -a " $LOG_FILE " ; continue ; }
35+
36+ {
37+ echo " Pulling latest changes from origin..."
38+ git pull || { echo " git pull failed in $repo " ; continue ; }
39+
40+ # --- Composer updates ---
41+ if [ -f composer.json ]; then
42+ echo " Running composer update..."
43+ composer update || { echo " composer update failed in $repo " ; continue ; }
44+ fi
45+
46+ # --- NPM updates ---
47+ if [ -f package.json ]; then
48+ echo " Running npm install..."
49+ npm install || { echo " npm install failed in $repo " ; continue ; }
50+
51+ echo " Running npm upgrade..."
52+ npm upgrade || { echo " npm upgrade failed in $repo " ; continue ; }
53+
54+ echo " Running npm audit fix..."
55+ npm audit fix --force || { echo " npm audit fix failed in $repo " ; continue ; }
56+
57+ echo " Running npm run build..."
58+ npm run build || { echo " npm run build failed in $repo " ; continue ; }
59+ fi
60+
61+ # --- Placeholder for custom updates ---
62+ # Example: Copy boilerplate files
63+ # cp -r "$PROJECTS_DIR/boilerplate-laravel/app/." "$TARGET_DIR/app/"
64+ # cp -r "$PROJECTS_DIR/boilerplate-laravel/config/." "$TARGET_DIR/config/"
65+
66+ # --- Commit any automatic changes ---
67+ if ! git diff --quiet || ! git diff --cached --quiet; then
68+ echo " Committing and pushing changes..."
69+ git add -A
70+ git commit -m " Update dependencies and boilerplate changes" || true
71+ git push || { echo " git push failed in $repo " ; continue ; }
72+ else
73+ echo " No changes to commit"
74+ fi
75+
76+ } 2>&1 | tee -a " $LOG_FILE "
77+
78+ else
79+ echo " Skipping $repo - not a git repo" | tee -a " $LOG_FILE "
80+ fi
81+ done
82+
83+ echo " ===== Update completed: $( date " +%Y-%m-%d %H:%M:%S" ) =====" | tee -a " $LOG_FILE "
0 commit comments