Skip to content

Commit

Permalink
Merge pull request #22 from apolopena/development
Browse files Browse the repository at this point in the history
Feature #20: optional installs of react, vue and bootstrap
  • Loading branch information
apolopena authored Feb 4, 2021
2 parents 28568d1 + caab7e6 commit 5c709a9
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN sudo bash -c ". /tmp/update-composer.sh" && rm /tmp/update-composer.sh

# gitpod trick to bypass the docker caching mechanism for all lines below this one
# just increment the value each time you want to bypass the cache system
ENV INVALIDATE_CACHE=119
ENV INVALIDATE_CACHE=120

COPY --chown=gitpod:gitpod bash/utils.sh /tmp
COPY --chown=gitpod:gitpod starter.ini /tmp
Expand Down
3 changes: 2 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ tasks:
stop_spinner $? &&
bash bash/init-gitpod.sh &&
source ~/.bash_profile &&
url=$(gp url 8000); sed -i'' "s#^APP_URL=http://localhost*#APP_URL=$url\nASSET_URL=$url#g" .env
url=$(gp url 8000); sed -i'' "s#^APP_URL=http://localhost*#APP_URL=$url\nASSET_URL=$url#g" .env &&
. bash/init-optional-scaffolding.sh
name: Init
- openMode: split-left
command: |
Expand Down
144 changes: 144 additions & 0 deletions bash/init-optional-scaffolding.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/bin/bash

# install-optional-scaffoliding.sh
# Description:
# Installs various packages according to the configuration set in starter.ini

# BEGIN: Parse starter.ini
install_react=$(. /tmp/utils.sh parse_ini_value starter.ini react install)
install_vue=$(. /tmp/utils.sh parse_ini_value starter.ini vue install)
install_bootstrap=$(. /tmp/utils.sh parse_ini_value starter.ini bootstrap install)
# END: Parse starter.ini

# BEGIN: Install Laravel ui if needed
if [[ $install_react == 1 || $install_bootstrap == 1 ]]; then
echo "Optional installations that require laravel/ui scaffolding were found."
echo "Installing laravel/ui scaffolding..."
composer require laravel/ui:^3.2.0
err_code=$?
if [ $err_code == 0 ]; then
echo "SUCCESS: laravel/ui scaffolding installed."
echo "Compiling fresh scaffolding and running Laravel Mix."
yarn install && yarn run dev
#echo "current working dir is: $(pwd)"
else
>&2 echo "ERROR $err_code: There was a problem installing laravel/ui"
fi
fi
# END: Install Laravel ui if needed

# BEGIN: Optional react and react-dom install
if [ "$install_react" == 1 ]; then
version=$(. /tmp/utils.sh parse_ini_value starter.ini react version)
auth=$(. /tmp/utils.sh parse_ini_value starter.ini react auth)

[ -z "$version" ] && version_msg='' || version_msg=" version $version"
[ "$auth" != 1 ] && auth_msg='' || auth_msg=' with --auth'

echo "React/React DOM install directive found in starter.ini"
echo "Installing React and React DOM..."
sleep 3

if [ "$auth" == 1 ]; then
php artisan ui react --auth
else
php artisan ui react
fi
err_code=$?
if [ $err_code == 0 ]; then
echo "SUCCESS: React and React DOM$version_msg$auth_msg has been installed"
echo "Compiling fresh scaffolding and running Laravel Mix"
yarn install && yarn run dev && sleep 1 && yarn run dev

if [ ! -z "$version" ]; then
echo "Setting react and react-dom to$version_msg"
# TODO: validate semver and valid version for the package so users cant pass in junk
yarn upgrade react@$version react-dom@$version
fi

[ "$install_bootstrap" == 1 ] && echo "Bootstrap install directive found but ignored. Already installed."
[ "$install_vue" == 1 ] && echo "Vue install directive found but ignored. The install of react superceded this."
else
>&2 echo "ERROR $err_code: There was a problem installing React/React DOM$version_msg$auth_msg"
fi
fi
# END: Optional react and react-dom install

# BEGIN: Optional vue install
if [[ "$install_vue" == 1 && "$install_react" == 0 ]]; then
version=$(. /tmp/utils.sh parse_ini_value starter.ini vue version)
auth=$(. /tmp/utils.sh parse_ini_value starter.ini vue auth)

[ -z "$version" ] && version_msg='' || version_msg=" version $version"
[ "$auth" != 1 ] && auth_msg='' || auth_msg=' with --auth'

echo "Vue install directive found in starter.ini"
echo "Installing Vue..."

if [ "$auth" == 1 ]; then
php artisan ui vue --auth
else
php artisan ui vue
fi
err_code=$?
if [ $err_code == 0 ]; then
echo "SUCCESS: Vue$version_msg$auth_msg has been installed."
echo "Compiling fresh scaffolding and running Laravel Mix."
yarn install && yarn run dev && sleep 1 && yarn run dev

if [ ! -z "$version" ]; then
echo "Setting vue to$version_msg"
# TODO: validate semver and valid version for the package so users cant pass in junk
yarn upgrade vue@$version
fi

[ "$install_bootstrap" == 1 ] && echo "Bootstrap install directive found but ignored. Already installed."
else
>&2 echo "ERROR $err_code: There was a problem installing Vue$version_msg$auth_msg"
fi
fi
# END: Optional vue install

# BEGIN: Optional bootstrap install
if [[ $install_bootstrap == 1 && $install_react == 0 && $install_vue == 0 ]]; then
version=$(. /tmp/utils.sh parse_ini_value starter.ini bootstrap version)
auth=$(. /tmp/utils.sh parse_ini_value starter.ini bootstrap auth)

[ -z "$version" ] && version_msg='' || version_msg=" version $version"
[ "$auth" != 1 ] && auth_msg='' || auth_msg=' with --auth'

echo "Bootstrap install directive found in starter.ini"
echo "Installing Bootstrap..."

if [ "$auth" == 1 ]; then
php artisan ui bootstrap --auth
else
php artisan ui bootstrap
fi
err_code=$?
if [ $err_code == 0 ]; then
echo "SUCCESS: Bootstrap$version_msg$auth_msg has been installed."
echo "Compiling fresh scaffolding and running Laravel Mix."
yarn install && yarn run dev && sleep 1 && yarn run dev

if [ ! -z "$version" ]; then
echo "Setting bootstrap to$version_msg"
# TODO: validate semver and valid version for the package so users cant pass in junk
yarn upgrade bootstrap@$version
fi
else
>&2 echo "ERROR $err_code: There was a problem installing Bootstrap$version_msg$auth_msg"
fi
else
version=$(. /tmp/utils.sh parse_ini_value starter.ini bootstrap version)
[ -z "$version" ] && version_msg='' || version_msg=" version $version"
if [[ ! -z $version && $install_bootstrap == 1 ]]; then
echo "Setting bootstrap to$version_msg"
yarn upgrade bootstrap@$version
fi
fi
# END: Optional bootstrap install




35 changes: 31 additions & 4 deletions starter.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
####################
# starter.ini
# Configuration for gitpod to build your stack as you like it
# Note: Boolean values should always be set to 1 (true) or 0 (false)
# Additional Note: Version numbers for node packages support semantic versioning or can be left blank
####################

[development]
# Valid values: apache, php
default_server=apache
# 1 = show (no browser auto refresh), 1 = hide (browser auto refresh)
show_debug_session_query_param=0

[phpmyadmin]
# 1 = install phpmyadmin, 0 = do not install phpmyadmin
install=1
# This install happens in .gitpod.Dockerfile so it can get cached one way or the other,
# force a build of the image workspace (see .gitpod.Dockerfile) to get your desired results.
install=1

[react]
# An install of react also installs and upgrades react-dom to the same version set below
# if install = 1 then vue will not be installed if its install value is also set to 1
install=0
auth=0
version=

[vue]
# An install of react will supercede an install of vue, choose one or the other
install=0
auth=0
version=

[bootstrap]
# Installs of either react or vue have bootstrap already so this section will be superceded in those cases
install=0
# auth only appies here when react or vue are not installed.
auth=0
version=

0 comments on commit 5c709a9

Please sign in to comment.