Skip to content

Commit

Permalink
🐛 FIX: #79
Browse files Browse the repository at this point in the history
  • Loading branch information
apolopena committed Mar 30, 2021
1 parent a1ec1e3 commit accd997
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 6 deletions.
27 changes: 21 additions & 6 deletions bash/init-optional-scaffolding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,25 @@ install_react=$(eval $parse react install)
install_vue=$(eval $parse vue install)
install_bootstrap=$(eval $parse bootstrap install)

# BEGIN: optional frontend scaffolding installations
installed_phpmyadmin=$(eval $parse starter.ini phpmyadmin install)
install_react_router_dom=$(eval $parse react-router-dom install)
rrd_ver=$(eval $parse react-router-dom version)

# BEGIN: Examples, supercede starter.ini

# Any value for EXAMPLE will build the react/phpmyadmin questions and answers demo
# into the starter, thus superceding some directives in starter.ini
if [ ! -z $EXAMPLE ]; then
install_react=1
installed_phpmyadmin=1
install_react_router_dom
rrd_ver='^5.2.0'
fi


# END: Examples, supercede starter.ini

# phpmyadmin
installed_phpmyadmin=$(bash bash/utils.sh parse_ini_value starter.ini phpmyadmin install)
[ "$installed_phpmyadmin" == 1 ] && . bash/init-phpmyadmin.sh

# BEGIN: Install Laravel ui if needed
Expand All @@ -61,7 +76,7 @@ if [[ $has_frontend_scaffolding_install == 1 ]]; then
fi
# END: Install Laravel ui if needed

# BEGIN: Optional react and react-dom install
# BEGIN: Optional react, react-dom and react-router-dom installs
if [ "$install_react" == 1 ]; then
version=$(eval $parse react version)
auth=$(eval $parse react auth)
Expand All @@ -81,9 +96,7 @@ if [ "$install_react" == 1 ]; then
err_code=$?
if [ $err_code == 0 ]; then
log "SUCCESS: React and React DOM$auth_msg have been installed"
install_react_router_dom=$(eval $parse react-router-dom install)
if [ $install_react_router_dom == 1 ]; then
rrd_ver=$(eval $parse react-router-dom version)
if [ -z "$rrd_ver" ]; then
sub_msg="Installing react-router-dom to the latest version"
log "$sub_msg"
Expand Down Expand Up @@ -114,7 +127,7 @@ if [ "$install_react" == 1 ]; then
fi
fi
fi
# END: Optional react and react-dom install
# END: Optional react, react-dom and react-router-dom installs

# BEGIN: Optional vue install
if [[ "$install_vue" == 1 && "$install_react" == 0 ]]; then
Expand Down Expand Up @@ -190,3 +203,5 @@ fi
# END: Optional bootstrap install
# END: optional frontend scaffolding installations

# Initialize optional example
[ ! -z $EXAMPLE ] && . init-react-example.sh
47 changes: 47 additions & 0 deletions bash/init-react-example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Log to the console and a file
log () {
if [ -z "$2" ]; then
bash bash/utils.sh log "$1" /var/log/workspace-init.log
else
bash bash/utils.sh log "$1" /var/log/workspace-init.log -e
fi
}

# Log only to a file
log_silent () {
if [ -z "$2" ]; then
bash bash/utils.sh log_silent "$1" /var/log/workspace-init.log
else
bash bash/utils.sh log_silent "$1" /var/log/workspace-init.log -e
fi
}

declare -a exit_codes=()
all_zeros='^0$|^0*0$'
task_msg="Setting up React example: Questions and Answers"

log "$task_msg"
curl -LJO https://github.com/apolopena/QnA-demo-skeleton/archive/refs/tags/1.0.0.tar.gz
exit_codes+=($?)
tar -xvzf QnA-demo-skeleton-1.0.0.tar.gz --strip-components=1
exit_codes+=($?)
rm QnA-demo-skeleton-1.0.0.tar.gz
exit_codes+=($?)
php artisan migrate
exit_codes+=($?)
php artisan db:seed
exit_codes+=($?)
yarn run mix
exit_codes+=($?)

if [[ $(echo ${exit_codes[@]} | tr -d '[:space:]') =~ $all_zeros ]]; then
log "SUCCESS: $task_msg"
else
log "ERROR: $task_msg"
fi




0 comments on commit accd997

Please sign in to comment.