From e29dbb808d4eab023e3bafec6d421257e99144f2 Mon Sep 17 00:00:00 2001 From: Bruno 21 Date: Sat, 10 Aug 2019 09:03:04 +0200 Subject: [PATCH] Update Update following original kymsu --- LICENSE | 21 +++++++++++ README.md | 39 ++++++++++++--------- README2.md | 32 +++++++++++++++++ _mas.sh | 44 ----------------------- install.sh | 14 ++++++++ kymsu2.sh | 40 +++++++++++++++++++++ plugins.d/00-kymsu.sh | 6 ++++ wp.sh => plugins.d/_wp.sh | 0 _atom.sh => plugins.d/atom.sh | 1 + _homebrew.sh => plugins.d/homebrew.sh | 4 +-- plugins.d/mas.sh | 50 +++++++++++++++++++++++++++ _npm.sh => plugins.d/npm.sh | 5 ++- _pecl.sh => plugins.d/pecl.sh | 2 +- _pip.sh => plugins.d/pip.sh | 10 ++++++ uninstall.sh | 6 ++++ 15 files changed, 210 insertions(+), 64 deletions(-) create mode 100644 LICENSE create mode 100644 README2.md delete mode 100755 _mas.sh create mode 100755 install.sh create mode 100755 kymsu2.sh create mode 100755 plugins.d/00-kymsu.sh rename wp.sh => plugins.d/_wp.sh (100%) rename _atom.sh => plugins.d/atom.sh (99%) rename _homebrew.sh => plugins.d/homebrew.sh (96%) create mode 100755 plugins.d/mas.sh rename _npm.sh => plugins.d/npm.sh (95%) rename _pecl.sh => plugins.d/pecl.sh (97%) rename _pip.sh => plugins.d/pip.sh (89%) create mode 100755 uninstall.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9e592f3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Mathieu Santo Stefano--Féron + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index ace69fe..f35bc8b 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,39 @@ -# Plugins KYMSU -Plugins KYMSU (Keep Your macOs Stuff Updated) -https://github.com/welcoMattic/kymsu +# KYMSU +Keep Your macOs Stuff Updated (KYMSU) +> Get your Homebrew, Mac App Store, Atom Package Manager (apm), npm, yarn, composer, rustup ... stuff updated. +## Requirements -- **npm** (javascript package) plugin for KYMSU (install local package) -- **mas** (Mac Appstore) plugin for KYMSU -- **Homebrew** plugin for KYMSU - brew and cask -- **pip** (Python Package index) plugin for KYMSU - pip or pip3 +- [Homebrew](https://brew.sh) +## Installation +`$ git clone git@github.com:welcoMattic/kymsu.git && cd kymsu && ./install.sh` -### Requirements +## Usage -- [KYMSU](https://github.com/welcoMattic/kymsu) -- [pipdeptree](https://pypi.python.org/pypi/pipdeptree) for checking dependancies (pip plugin) +Only update all the things +`$ kymsu` +With cleanup after updates +`$ kymsu cleanup` +## Plugins system -### Installation +All default plugins are placed in `~/.kymsu/plugins.d`, feel free to delete those you don't use, and/or add new ones. +Don't forget to share them here with a shiny pull request! ✨ -Copy the plugins in `~/.kymsu/plugins.d` +## Auto-update +KYMSU will auto-update itself each time you run `kymsu` command. +## Credits -### License +* [All contributors](https://github.com/welcomattic/kymsu/graphs/contributors) +* Thanks to [@waxzce](https://github.com/waxzce) for his [article](https://medium.com/@waxzce/keeping-macos-clean-this-is-my-osx-brew-update-cli-command-6c8f12dc1731) about keeping macOs clean! -Same as KYMSU +## License +KYMSU is licensed under the MIT License - see the [LICENSE](LICENSE) file +for details. diff --git a/README2.md b/README2.md new file mode 100644 index 0000000..ace69fe --- /dev/null +++ b/README2.md @@ -0,0 +1,32 @@ +# Plugins KYMSU +Plugins KYMSU (Keep Your macOs Stuff Updated) +https://github.com/welcoMattic/kymsu + + + +- **npm** (javascript package) plugin for KYMSU (install local package) +- **mas** (Mac Appstore) plugin for KYMSU +- **Homebrew** plugin for KYMSU + brew and cask +- **pip** (Python Package index) plugin for KYMSU + pip or pip3 + + + +### Requirements + +- [KYMSU](https://github.com/welcoMattic/kymsu) +- [pipdeptree](https://pypi.python.org/pypi/pipdeptree) for checking dependancies (pip plugin) + + + +### Installation + +Copy the plugins in `~/.kymsu/plugins.d` + + + +### License + +Same as KYMSU + diff --git a/_mas.sh b/_mas.sh deleted file mode 100755 index dd24efa..0000000 --- a/_mas.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -# Mac Appstore plugin for KYMSU -# https://github.com/welcoMattic/kymsu - -echo -e "\033[1m🍏 Mac App Store updates come fast as lightning \033[0m" - -# No distract mode (Casks with 'latest' version number won't be updated) -no_distract=false - -if [[ $1 == "--nodistract" ]]; then - no_distract=true -fi - -#mas outdated -massy=`mas outdated` -echo "" - -if [ -n "$massy" ]; then -#if [ "$massy" != 0 ]; then - echo -e "\033[4mAvailables updates:\033[0m" - echo "$massy" | cut -d " " -f2-5 - echo "" - - if [ "$no_distract" = false ]; then - - a=$(echo -e "Do you wanna run \033[1mmas upgrade\033[0m ? (y/n)") - read -p "$a" choice - case "$choice" in - y|Y|o ) mas upgrade;; - n|N ) echo "Ok, let's continue";; - * ) echo "invalid";; - esac - - else - mas upgrade - fi - -else - echo -e "\033[4mNo availables mas updates.\033[0m" -fi - -echo "" -echo "" diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..93cd35b --- /dev/null +++ b/install.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +KYMSU_PATH=`pwd` + +# Make Kymsu accessible in PATH +ln -fs "${KYMSU_PATH}"/kymsu2.sh /usr/local/bin/kymsu2 + +# Store Kymsu stuff in home directory +mkdir -p ~/.kymsu && echo "${KYMSU_PATH}" > ~/.kymsu/path +cp -R "${KYMSU_PATH}/plugins.d" ~/.kymsu + +echo "KYMSU2 has been installed. Run kymsu2 command!" +echo "It's a fork from https://github.com/welcoMattic/kymsu" +echo "All credits to welcoMattic" diff --git a/kymsu2.sh b/kymsu2.sh new file mode 100755 index 0000000..402b001 --- /dev/null +++ b/kymsu2.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +if [[ "$1" == "-h" || "$1" == "--help" ]]; then + echo -e "\033[93m\033[1mkymsu2\033[0m" + echo "" + echo "Keep Your macOs Stuff Updated 2" + echo "a fork from kymsu https://github.com/welcoMattic/kymsu" + echo + echo "USAGE: kymsu2" + echo + echo "Commandes: " + echo " -h, --help display this help" + echo " --nodistract no distract mode (no user interaction)" + echo " --cleanup removing any older versions of installed formulae and clearing old downloads from the Homebrew download-cache" + echo " --npm_cleanup cleaning npm cache" + echo + echo "Tips:" + echo " -prefix the plugin with _ to ignore it" + echo + exit 0 +fi + +echo "Please, grab a ☕️, KYMSU keep your working environment up to date!" + +SCRIPTS_DIR=$HOME/.kymsu/plugins.d +#SCRIPTS_DIR=$(cat ~/.kymsu/path)/plugins.d + +cd "$SCRIPTS_DIR" + +# On boucle sur tous les fichiers du répertoire +# (seuls les fichiers commençant par '_' ou '0' sont pris en compte) +#for script in $(find . -name '[_0]*' -maxdepth 1 | sort); do +for script in $(find . ! -name _\*.sh -maxdepth 1 | sort); do + # si le fichier est exécutable et n'est pas un dossier + if [ -x "$SCRIPTS_DIR/$script" ] && [ -f "$SCRIPTS_DIR/$script" ]; then + # on l’exécute ; le $@ permet de passer à chaque + # script les arguments passés à *ce* script + $SCRIPTS_DIR/$script $@ + fi +done \ No newline at end of file diff --git a/plugins.d/00-kymsu.sh b/plugins.d/00-kymsu.sh new file mode 100755 index 0000000..515fb7b --- /dev/null +++ b/plugins.d/00-kymsu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +echo "🦄 KYMSU self update" +pushd "$(cat ~/.kymsu/path)" > /dev/null +git pull +popd > /dev/null +echo "" diff --git a/wp.sh b/plugins.d/_wp.sh similarity index 100% rename from wp.sh rename to plugins.d/_wp.sh diff --git a/_atom.sh b/plugins.d/atom.sh similarity index 99% rename from _atom.sh rename to plugins.d/atom.sh index 5f96bfa..e1de6ce 100755 --- a/_atom.sh +++ b/plugins.d/atom.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash + echo -e "\033[1m⚛️ Atom editor will be shiny when you'll be back from your coffee/tea break! \033[0m" if hash apm-beta 2>/dev/null; then diff --git a/_homebrew.sh b/plugins.d/homebrew.sh similarity index 96% rename from _homebrew.sh rename to plugins.d/homebrew.sh index f624f59..3ee5461 100755 --- a/_homebrew.sh +++ b/plugins.d/homebrew.sh @@ -13,9 +13,9 @@ display_info=true #add module to do_not_update array -declare -a do_not_update=('') +declare -a do_not_update=('virtualbox,virtualbox-extension-pack') -# No distract mode (Casks with 'latest' version number won't be updated) +# No distract mode (no user interaction)(Casks with 'latest' version number won't be updated) no_distract=false if [[ $1 == "--nodistract" ]]; then diff --git a/plugins.d/mas.sh b/plugins.d/mas.sh new file mode 100755 index 0000000..8ca1e85 --- /dev/null +++ b/plugins.d/mas.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# Mac Appstore plugin for KYMSU +# https://github.com/welcoMattic/kymsu + +echo -e "\033[1m🍏 Mac App Store updates come fast as lightning \033[0m" + +# No distract mode (no user interaction) +no_distract=false + +if [[ $1 == "--nodistract" ]]; then + no_distract=true +fi + +# On teste si mas est installé +if hash mas 2>/dev/null; then + + massy=$(mas outdated) + echo "" + echo "$massy" + + #if [ -n "$massy" ]; then + if [ ! -z "$(mas outdated)" ]; then + echo -e "\033[4mAvailables updates:\033[0m" + echo "$massy" | cut -d " " -f2-5 + echo "" + + if [ "$no_distract" = false ]; then + + a=$(echo -e "Do you wanna run \033[1mmas upgrade\033[0m ? (y/n)") + read -p "$a" choice + case "$choice" in + y|Y|o ) mas upgrade;; + n|N ) echo "Ok, let's continue";; + * ) echo "invalid";; + esac + + else + mas upgrade + fi + + else + echo -e "\033[4mNo availables mas updates.\033[0m" + fi +else + echo "Please install mas: brew install mas" +fi + +echo "" +echo "" diff --git a/_npm.sh b/plugins.d/npm.sh similarity index 95% rename from _npm.sh rename to plugins.d/npm.sh index e0bd10b..2a26638 100755 --- a/_npm.sh +++ b/plugins.d/npm.sh @@ -22,7 +22,7 @@ no_distract=false doctor=false # Local install -local_path=/Users/bruno/Sites/node_modules/ +local_path=$HOME/Sites/node_modules/ echo -e "\033[1m🌿 npm \033[0m" echo "" @@ -81,9 +81,12 @@ echo "" # Global packages echo -e "\033[4m🌿 Global installed scripts:\033[0m" npm list -g --depth=0 + g_outdated=$(npm outdated -g) # => npm ERR! Cannot read property 'length' of undefined -> https://stackoverflow.com/questions/55172700/npm-outdated-g-error-cannot-read-property-length-of-undefined +# /Users/bruno/.nvm/versions/node/v10.16.2/lib/node_modules/npm/lib/outdated.js +# /usr/local/lib/node_modules/npm/lib/outdated.js # update -> wanted ; install -> latest if [ -n "$g_outdated" ]; then diff --git a/_pecl.sh b/plugins.d/pecl.sh similarity index 97% rename from _pecl.sh rename to plugins.d/pecl.sh index 684b33f..9e66cc3 100755 --- a/_pecl.sh +++ b/plugins.d/pecl.sh @@ -5,7 +5,7 @@ # https://pecl.php.net -# No distract mode +# No distract mode (no user interaction) no_distract=false echo -e "\033[1m🐘 pecl \033[0m" diff --git a/_pip.sh b/plugins.d/pip.sh similarity index 89% rename from _pip.sh rename to plugins.d/pip.sh index cda12b3..2f15bcd 100755 --- a/_pip.sh +++ b/plugins.d/pip.sh @@ -71,6 +71,16 @@ if [ -n "$upd" ]; then z=$((z+1)) fi done <<< "$dependencies" + + else + c=$(echo -e "Do you want to install pipdeptree to check dependancies ? (y/n)") + read -p "$c" choice + case "$choice" in + y|Y|o ) $version install $user pipdeptree ;; + n|N ) echo "Ok, let's continue";; + * ) echo "invalid";; + esac + fi # If the update is not in the do_not_update array, we install it. diff --git a/uninstall.sh b/uninstall.sh new file mode 100755 index 0000000..4a675d2 --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +rm -rf $(which kymsu2) +rm -rf ~/.kymsu + +echo "KYMSU2 has been uninstalled."