-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts: add info message coloration
* adds more info and colors for `scripts/bootstrap` scripts * adds more info and colors for `scripts/setup` scripts * adds more info and colors for `run-tests.sh` scripts Co-Authored-by: Olivier DOSSMANN <[email protected]>
- Loading branch information
1 parent
fca4ea8
commit 3781ff7
Showing
3 changed files
with
181 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,47 @@ | |
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
NC='\033[0m' # Default color | ||
COLORED='\033[1;97;44m' # Bold + white + blue background | ||
NC='\033[0m' # Default color | ||
INFO_COLOR='\033[1;97;44m' # Bold + white + blue background | ||
SUCCESS_COLOR='\033[1;97;42m' # Bold + white + green background | ||
ERROR_COLOR='\033[1;97;41m' # Bold + white + red background | ||
|
||
PROGRAM=`basename $0` | ||
|
||
set -e | ||
|
||
# MESSAGES | ||
msg() { | ||
echo -e "${COLORED}${EMPHASIS}[INFO]${NC}${COLORED}: ${1}${NC}" 1>&2 | ||
echo -e "${1}" 1>&2 | ||
} | ||
# Display a colored message | ||
# More info: https://misc.flogisoft.com/bash/tip_colors_and_formatting | ||
# $1: choosen color | ||
# $2: title | ||
# $3: the message | ||
colored_msg() { | ||
msg "${1}[${2}]: ${3}${NC}" | ||
} | ||
|
||
info_msg() { | ||
colored_msg "${INFO_COLOR}" "INFO" "${1}" | ||
} | ||
|
||
error_msg() { | ||
colored_msg "${ERROR_COLOR}" "ERROR" "${1}" | ||
} | ||
|
||
error_msg+exit() { | ||
error_msg "${1}" && exit 1 | ||
} | ||
|
||
success_msg() { | ||
colored_msg "${SUCCESS_COLOR}" "SUCCESS" "${1}" | ||
} | ||
|
||
# Displays program name | ||
msg "PROGRAM: ${PROGRAM}" | ||
|
||
# The real bootstrap script starts 20 lines below ;-) | ||
flags=() | ||
deploy=false | ||
|
@@ -64,37 +96,41 @@ fi | |
# pipenv --rm; pipenv install --sequential | ||
|
||
# install the application and all the dependencies | ||
msg "Install with command: ${cmd} ${flags[@]}" | ||
info_msg "Install with command: ${cmd} ${flags[@]}" | ||
${cmd} ${flags[@]} | ||
|
||
# to avoid IPython dependency problem on Mac OS X | ||
if [ "$(uname -s)" == "Darwin" ]; then | ||
msg "Install 'appnope' for Mac OS X" | ||
info_msg "Install 'appnope' for Mac OS X" | ||
pipenv run pip install appnope | ||
fi | ||
|
||
# install assets utils | ||
virtualenv_path=`pipenv --venv` | ||
msg "Install npm assets utils in: ${virtualenv_path}" | ||
info_msg "Install npm assets utils in: ${virtualenv_path}" | ||
pipenv run npm i npm@latest -g --prefix "${virtualenv_path}" && pipenv run npm install --prefix "${virtualenv_path}" --silent -g [email protected] [email protected] [email protected] [email protected] @angular/[email protected] yarn | ||
|
||
# collect static files and compile html/css assets | ||
|
||
# ------------------------------------------------ | ||
# install the npm dependencies | ||
msg "Install npm dependencies" | ||
info_msg "Install npm dependencies" | ||
pipenv run invenio npm | ||
msg "Search static folder location" | ||
info_msg "Search static folder location" | ||
static_folder=$(pipenv run invenio shell --no-term-title -c "print('static_folder:%s' % app.static_folder)"|grep static_folder| cut -d: -f2-) | ||
msg "Install static folder npm dependencies in: ${static_folder}" | ||
info_msg "Install static folder npm dependencies in: ${static_folder}" | ||
pipenv run npm install --prefix "${static_folder}" | ||
|
||
# build the web assets | ||
msg "Build web assets: collect" | ||
info_msg "Build web assets: collect" | ||
pipenv run invenio collect -v | ||
msg "Build web assets: check (build command)" | ||
info_msg "Build web assets: check (build command)" | ||
pipenv run invenio assets build | ||
|
||
# compile json files (resolve $ref) | ||
info_msg "Compile JSON files to resolve \$ref" | ||
echo | ||
pipenv run invenio utils compile_json ./rero_ils/modules/documents/jsonschemas/documents/document-minimal-v0.0.1_src.json -o ./rero_ils/modules/documents/jsonschemas/documents/document-minimal-v0.0.1.json | ||
pipenv run invenio utils compile_json ./rero_ils/modules/documents/jsonschemas/documents/document-v0.0.1_src.json -o ./rero_ils/modules/documents/jsonschemas/documents/document-v0.0.1.json | ||
|
||
success_msg "${PROGRAM} finished!" | ||
exit 0 |
Oops, something went wrong.