Merge pull request #12340 from eileenmcnaughton/merge_cleanup
[civicrm-core.git] / bin / setup.sh
index 482dee63332e65f4801c88ec33ed24e1a24a90e3..fc59804214d07d7a9af6066d29b578543388f105 100755 (executable)
@@ -151,14 +151,24 @@ if [ -n "$DO_DOWNLOAD" ]; then
     fi
 
     BOWER=$(pickcmd node_modules/bower/bin/bower bower)
-    BOWER_HARD_RESET_TIME=1422672905
-    if [ -d bower_components -a $( stat bower_components -c%W ) -lt $BOWER_HARD_RESET_TIME ]; then
-      ## If you make a breaking change to bower.json, then update BOWER_HARD_RESET_TIME.
-      ## Ex: If bower.json newly declares a dependency which had been loaded transitively,
-      ## then bower may fail to update the dependency, so should bump BOWER_HARD_RESET_TIME.
-      rm -rf bower_components
+    if [ -f "$BOWER" ]; then
+      NODE=$(pickcmd node nodejs)
+      BOWER="$NODE $BOWER"
     fi
-    $BOWER install
+    # Without the force flag, bower may not check for new versions or verify that installed software matches version specified in bower.json
+    # With the force flag, bower will ignore all caches and download all deps.
+    if [ -n "$OFFLINE" ]; then
+      BOWER_OPT=
+    elif [ ! -f "bower_components/.setupsh.ts" ]; then
+      ## First run -- or cleanup from failed run
+      BOWER_OPT=-f
+    elif [ "bower.json" -nt "bower_components/.setupsh.ts" ]; then
+      ## Bower.json has changed since last run
+      BOWER_OPT=-f
+    fi
+    [ -f "bower_components/.setupsh.ts" ] && rm -f "bower_components/.setupsh.ts"
+    $BOWER install $BOWER_OPT
+    touch bower_components/.setupsh.ts
   popd
 fi
 
@@ -218,9 +228,6 @@ fi
 
 if [ -n "$DO_FLUSH" ]; then
   pushd "$CALLEDPATH/.."
-    # run the cli script to build the menu and the triggers
-    "$PHP5PATH"php bin/cli.php -e System -a flush --triggers 1 --session 1
-
     # reset config_backend and userFrameworkResourceURL which gets set
     # when config object is initialized
     $MYSQLCMD -e "UPDATE civicrm_domain SET config_backend = NULL; UPDATE civicrm_setting SET value = NULL WHERE name = 'userFrameworkResourceURL';"