-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 👌 IMPROVE: #138 Add -<port number> and --help options to op command * 🤖 TEST: force docker * 💡 UPDATE COMMENTS: fix inacurate info in the header * ➕ ADD: download react typescript skeleton * ➕ ADD: react typescript example * 🐛 FIX: tar --overwrite * 🐛 FIX: all zeros not working * 🤖 TEST: run laravel mix to avoid saas warnings * 🤖 TEST: remove previous test * 🤖 TEST: disable typescript example init * 🐛 FIX: temp workaround for third party saas bug: #140 * ✏️ FIX TYPO: sass not saas * 🐛 FIX: workaround tthird party bug #140 * 🐛 FIX: workaround third party bug #140 * 🐛 FIX: workaround third party bug #140 * 🐛 FIX: #140 * 👌 IMPROVE: hotfix #140 * ✏️ FIX TYPO: 140 not 130 * 🐛 FIX: #141 * 🐛 FIX: #142 * ♻️ REFACTOR: improve all_zeros regexp * 🐛 FIX: hard coded version bump for upcomming release * 🐛 FIX: #142 * 🐛 FIX: #142 * 🤖 TEST: fix vue material dashboard example: reload after login triggers runtime error * 🐛 FIX: restore code from previous test * 🐛 FIX: #142 * 📖 DOC: #139 and #142
- Loading branch information
Showing
15 changed files
with
320 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#!/bin/bash | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# Copyright © 2021 Apolo Pena | ||
# | ||
# change-passwords.sh | ||
# Description: | ||
# Changes passwords for phpmyadmin from the defaults in version control to the values set in .starter.env | ||
# | ||
# Notes: | ||
# This script should be always run at least once by the user as an mandatory additional layer of security | ||
# This script requires the file .starter.env to exist along will all the key value pairs set. | ||
# | ||
# See: | ||
# example.starter.ini | ||
|
||
# Load spinner | ||
. .gp/bash/spinner.sh | ||
|
||
phpmyadmin() { | ||
[ ! -d public/phpmyadmin ] && echo "No installation of phpmyadmin was found. Process aborted. " && exit 1 | ||
# Keep keys in sequence. Add new keys to the end of the array | ||
local keys=(PHPMYADMIN_SUPERUSER_PW PHPMYADMIN_CONTROLUSER_PW) | ||
|
||
local name="change-passwords.sh phpmyadmin" | ||
local err="$name ERROR:" | ||
local config_file="public/phpmyadmin/config.inc.php" | ||
local all_zeros='^[0]+$' | ||
local exit_codes | ||
local values | ||
|
||
for key in "${keys[@]}"; do | ||
local value | ||
value="$(bash .gp/bash/helpers.sh get_starter_env_val "$key")" | ||
values+=("$(bash .gp/bash/helpers.sh get_starter_env_val "$key")") | ||
local code=$? | ||
exit_codes+=$code | ||
# show error message of called function | ||
[ $code != 0 ] && echo "$value" | ||
done | ||
|
||
if [[ ! $(echo "${exit_codes[@]}" | tr -d '[:space:]') =~ $all_zeros ]]; then | ||
echo "$err retrieving values, no passwords were changed." | ||
exit 1 | ||
fi | ||
|
||
# Values have been set and there are no errors so far so change passwords | ||
i=0 | ||
for key in "${keys[@]}"; do | ||
case $key in | ||
"${keys[0]}") | ||
msg="Changing password for phpmyadmin user 'pmasu' to the value found in .starter.env" | ||
start_spinner "$msg" | ||
mysql -e "ALTER USER 'pmasu'@'%' IDENTIFIED BY '${values[$i]}'; FLUSH PRIVILEGES;" | ||
stop_spinner $? | ||
;; | ||
"${keys[1]}") | ||
msg="Changing password for phpmyadmin user 'pma' to the value found in .starter.env" | ||
start_spinner "$msg" | ||
mysql -e "ALTER USER 'pma'@'localhost' IDENTIFIED BY '${values[$i]}'; FLUSH PRIVILEGES;" | ||
err_code=$? | ||
stop_spinner $err_code | ||
if [ $err_code == 0 ]; then | ||
msg="Updating control user password in $config_file" | ||
line="\$cfg['Servers'][\$i]['controlpass'] =" | ||
_edit="\$cfg['Servers'][\$i]['controlpass'] = '${values[$i]}';" | ||
start_spinner "$msg" | ||
# The shellcheck SC2026 was not designed for awk so bypass it | ||
# shellcheck disable=2026 | ||
# Match the line where the password for the controluser is set | ||
line_num=$(awk '/^\$cfg.*'controlpass'.*=.*;$/ {print FNR}' $config_file) | ||
if [ -z "$line_num" ]; then | ||
stop_spinner 1 | ||
echo -e "ERROR: No line found beginning with: $line \n\tin the file: $config_file" | ||
echo "You will need to manually update the control user password in $config_file" | ||
else | ||
sed -i "$line_num c\\$_edit" $config_file | ||
err_code=$? | ||
stop_spinner $err_code | ||
unset _edit | ||
[ $err_code == 0 ] && | ||
echo -e "\e[38;5;171mPROCESS COMPLETE\e[0m" && | ||
echo -e "\e[1;33mCheck the console output for any possible failures.\e[0m" && | ||
echo -en "\e[1;36m" && | ||
echo "If you are logged into phpmyadmin, log out and log back in." && | ||
echo "For additional security you can delete .starter.env" && | ||
echo "Just make sure you remember your passwords from that file." && | ||
echo "If you ever loose your passwords you may always set them again" && | ||
echo "using this script and new values set in .starter.env" && | ||
echo -e "\e[0m" | ||
fi | ||
fi | ||
;; | ||
*) | ||
echo "$err unidentified key $value" | ||
;; | ||
esac | ||
((i++)) | ||
done | ||
} | ||
|
||
# Call functions from this script gracefully | ||
if declare -f "$1" > /dev/null | ||
then | ||
# call arguments verbatim | ||
"$@" | ||
else | ||
echo "utils.sh: '$1' is not a known function name." >&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# Copyright © 2021 Apolo Pena | ||
# | ||
# init-react-typescript-example.sh | ||
# Description: | ||
# Initial setup for the gitpod-laravel-starter React Typescript example. | ||
|
||
# Load logger | ||
. .gp/bash/workspace-init-logger.sh | ||
|
||
declare -a exit_codes=() | ||
|
||
task_msg="Downloading React Typescript example: Questions and Answers" | ||
|
||
log "$task_msg" | ||
curl -LJO https://github.com/apolopena/qna-typescript-demo-skeleton/archive/refs/tags/1.1.0.tar.gz | ||
exit_codes+=($?) | ||
tar --overwrite -xvzf qna-typescript-demo-skeleton-1.1.0.tar.gz --strip-components=1 | ||
exit_codes+=($?) | ||
rm qna-typescript-demo-skeleton-1.1.0.tar.gz | ||
exit_codes+=($?) | ||
|
||
if [[ $(echo "${exit_codes[@]}" | tr -d '[:space:]') =~ ^[0]+$ ]]; then | ||
log "SUCCESS: $task_msg" | ||
else | ||
log -e "ERROR: $task_msg" | ||
fi | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,21 @@ | |
# Load spinner | ||
. .gp/bash/spinner.sh | ||
|
||
# Workaround third party sass bug: https://github.com/apolopena/gitpod-laravel-starter/issues/140 | ||
hotfix140 () { | ||
local exit_code msg="Applying hotfix 140" | ||
log_silent "$msg..." && start_spinner "$msg" | ||
yes | npx add-dependencies [email protected] --dev 2> >(grep -v warning 1>&2) > /dev/null 2>&1 | ||
exit_code=$? | ||
if [[ $exit_code == 0 ]]; then | ||
stop_spinner 0 | ||
log_silent "SUCCESS: $msg" | ||
else | ||
stop_spinner 1 | ||
log_silent -e "ERROR: $msg" | ||
fi | ||
} | ||
|
||
parse="bash .gp/bash/utils.sh parse_ini_value starter.ini" | ||
|
||
install_react=$(eval "$parse" react install) | ||
|
@@ -49,6 +64,22 @@ if [[ -n $EXAMPLE ]]; then | |
install_react_router_dom=1 | ||
rrd_ver='^5.2.0' | ||
;; | ||
3) | ||
example_title="React Typescript Example with phpMyAdmin - Questions and Answers" | ||
init_react_typescript_example=".gp/bash/examples/init-react-typescript-example.sh" | ||
install_react=1 | ||
install_phpmyadmin=1 | ||
install_react_router_dom=1 | ||
rrd_ver='^5.2.0' | ||
;; | ||
4) | ||
example_title="React Typescript Example without phpMyAdmin - Questions and Answers" | ||
init_react_typescript_example=".gp/bash/examples/init-react-typescript-example.sh" | ||
install_react=1 | ||
install_phpmyadmin=0 | ||
install_react_router_dom=1 | ||
rrd_ver='^5.2.0' | ||
;; | ||
10) | ||
example_title="Vue Example with phpMyAdmin and extras - Material Dashboard" | ||
init_vue_example=".gp/bash/examples/init-vue-example.sh" | ||
|
@@ -118,6 +149,7 @@ fi # end check laravel/ui already in vcs but needs composer install | |
# Cleanup (since we use yarn) | ||
[ -f package-lock.json ] && rm package-lock.json | ||
# END: Install Laravel ui if needed | ||
|
||
# BEGIN: Optional react, react-dom and react-router-dom installs | ||
if [ $install_react == 1 ]; then | ||
version=$(eval "$parse" react version) | ||
|
@@ -154,6 +186,7 @@ if [ $install_react == 1 ]; then | |
log -e "ERROR: $sub_msg" | ||
fi | ||
fi | ||
hotfix140 | ||
log " --> Installing node modules and running Laravel Mix" | ||
yarn install && npm run dev | ||
npm run dev | ||
|
@@ -187,6 +220,7 @@ if [[ $install_vue == 1 && $install_react != 1 ]]; then | |
fi | ||
err_code=$? | ||
if [[ $err_code == 0 ]]; then | ||
hotfix140 | ||
log "SUCCESS: Vue$auth_msg has been installed" | ||
log " --> Installing node modules and running Laravel Mix" | ||
yarn install && npm run dev | ||
|
@@ -212,6 +246,7 @@ if [[ $install_bootstrap == 1 && $install_react != 1 && $install_vue != 1 ]]; th | |
fi | ||
err_code=$? | ||
if [[ $err_code == 0 ]]; then | ||
hotfix140 | ||
log "SUCCESS: Bootstrap$version_msg$auth_msg has been installed" | ||
log " --> Installing node modules and running Laravel Mix" | ||
yarn install && npm run dev | ||
|
@@ -233,6 +268,7 @@ else | |
fi | ||
# END: Optional bootstrap install | ||
# END: optional frontend scaffolding installations | ||
|
||
# BEGIN: optional example setup | ||
# Initialize optional react example project | ||
if [[ -n $init_react_example ]];then | ||
|
@@ -244,6 +280,16 @@ if [[ -n $init_react_example ]];then | |
. "$init_react_example" 2>/dev/null || log_silent -e "ERROR: $(. $init_react_example 2>&1 1>/dev/null)" | ||
exit | ||
fi | ||
# Initialize optional react typescript example project | ||
if [[ -n $init_react_typescript_example ]];then | ||
[[ $laravel_major_ver -ne 8 ]] \ | ||
&& log -e "WARNING: React examples are only supported by Laravel version 8. Your Laravel version is $laravel_major_ver" \ | ||
&& log -e "WARNING: Ignoring the example requested: $example_title" \ | ||
&& exit | ||
# shellcheck source=.gp/bash/examples/init-react-example.sh | ||
. "$init_react_typescript_example" 2>/dev/null || log_silent -e "ERROR: $(. $init_react_typescript_example 2>&1 1>/dev/null)" | ||
exit | ||
fi | ||
# Initialize optional vue example project | ||
if [[ -n $init_vue_example ]];then | ||
# shellcheck source=.gp/bash/examples/init-vue-example.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.