Last active
February 21, 2017 11:56
-
-
Save zorbash/98afb51cb7287ff7fe3b2b9a3331dc5f to your computer and use it in GitHub Desktop.
Kitto Core Widgets Updater
This file contains hidden or 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
main() { | |
set -e | |
github_base_url=https://raw.githubusercontent.com/kittoframework/kitto/master | |
print_banner | |
ask_continue | |
update_widgets | |
print_outro | |
} | |
print_banner() { | |
cat <<EOF | |
╔═══════════════╗ | |
║ Kitto Updater ║ | |
╚═══════════════╝ | |
╔═════════════════════════════════════════════════════════════════════════════════════╗ | |
║ ║ | |
║ The core widgets will be updated ║ | |
║ ║ | |
║ Please backup your sources or use version control, since files will be overwritten ║ | |
║ or removed. ║ | |
║ ║ | |
╚═════════════════════════════════════════════════════════════════════════════════════╝ | |
EOF | |
} | |
ask_continue() { | |
cat <<EOF | |
╔══════════════════════════════════════════╗ | |
║ Are you sure you wish to continue? (y/n) ║ | |
╚══════════════════════════════════════════╝ | |
EOF | |
read answer | |
if echo "$answer" | grep -iq "^y" ;then | |
echo Yes | |
else | |
echo No | |
exit 1 | |
fi | |
} | |
print_outro() { | |
echo "Update has been completed." | |
} | |
update_widgets() { | |
local widgets=" | |
clock | |
graph | |
image | |
list | |
meter | |
number | |
text | |
" | |
for widget in $widgets | |
do | |
echo "Updating: $widget" | |
install -d widgets/$widget | |
local url="$github_base_url/installer/templates/new/widgets/$widget/$widget.js" | |
local style_url="$github_base_url/installer/templates/new/widgets/$widget/$widget.scss" | |
curl -# $url > "widgets/$widget/$widget.js" | |
curl -# $style_url > "widgets/$widget/$widget.scss" | |
done | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment