Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
064ae0ecf0
|
|||
|
cb0a07339d
|
@@ -25,13 +25,13 @@ homebrew and pecl plugins notifie you if apache/php configuration files have bee
|
||||
## Requirements
|
||||
|
||||
- [Homebrew](https://brew.sh/)
|
||||
- [jq](https://github.com/stedolan/jq) *(brew install jq)* for processing JSON data (homebrew plugin)
|
||||
|
||||
Optionnal:
|
||||
|
||||
- [pipdeptree](https://pypi.python.org/pypi/pipdeptree) *(pip install pipdeptree)* for checking dependancies (pip plugin)
|
||||
- [jq](https://github.com/stedolan/jq) *(brew install jq)* for processing JSON data (homebrew plugin)
|
||||
- [terminal-notifier](https://github.com/julienXX/terminal-notifier) *(brew install terminal-notifier)* for sending macOS notification (all plugins)
|
||||
- [Bash 5](https://www.gnu.org/software/bash/) *(brew install bash)* for associative array (homebrew plugin)
|
||||
- ~~[Bash 5](https://www.gnu.org/software/bash/) *(brew install bash)* for associative array (homebrew plugin)~~ (homebrew plugin 2.0)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
display_info=true
|
||||
|
||||
# Casks don't have pinned cask. So add Cask to the do_not_update array for prevent to update.
|
||||
# Also add package for prevent to update whitout pin it.
|
||||
# declare -a do_not_update=("xnconvert" "yate")
|
||||
declare -a cask_to_not_update=()
|
||||
|
||||
@@ -20,7 +19,7 @@ no_distract=false
|
||||
|
||||
# Some Casks have auto_updates true or version :latest. Homebrew Cask cannot track versions of those apps.
|
||||
# 'latest=true' force Homebrew to update those apps.
|
||||
latest=true
|
||||
latest=false
|
||||
#
|
||||
###############################################################################################
|
||||
#
|
||||
@@ -130,7 +129,7 @@ get_info_pkg() {
|
||||
echo -e "${bold}🍺 Homebrew ${reset}"
|
||||
|
||||
echo -e "\n🍺 ${underline}Updating brew...${reset}\n"
|
||||
brew update
|
||||
#brew update
|
||||
|
||||
echo ""
|
||||
brew_outdated=$(brew outdated --greedy --json=v2)
|
||||
@@ -231,6 +230,8 @@ else
|
||||
echo -e "\n${italic}No update package available...${reset}\n"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
#############
|
||||
### Casks ###
|
||||
#############
|
||||
@@ -299,7 +300,7 @@ if [ "$nb_casks_upd" -gt 0 ]; then
|
||||
array=($a)
|
||||
if [ "$display_info" = true ]; then
|
||||
[ "$nb_casks_upd" -gt 1 ] && echo -e "${box} $nb_casks_upd ${reset} ${array[@]/%/s}:\n" || echo -e "${box} $nb_casks_upd ${reset} ${array[@]}:\n"
|
||||
upd_casks_info=$(brew info --json=v2 $upd_casks | jq '{casks} | .[]')
|
||||
upd_casks_info=$(brew info --cask --json=v2 $upd_casks | jq '{casks} | .[]')
|
||||
for row in $upd_casks;
|
||||
do
|
||||
get_info_cask "$upd_casks_info" "$row"
|
||||
@@ -311,7 +312,8 @@ fi
|
||||
|
||||
# Updating casks
|
||||
echo -e "\n🍺 ${underline}Updating casks...${reset}\n"
|
||||
[ -n "$casks_not_pinned" ] && echo -e "${red}Do not update: ${cask_to_not_update[@]} . It won't be updated!'${reset}\n"
|
||||
|
||||
[ "${#cask_to_not_update[@]}" -gt 0 ] && echo -e "${red}Do not update: ${cask_to_not_update[@]} . It won't be updated!'${reset}\n"
|
||||
[ -n "$casks_latest_not_pinned" ] && echo -e "Some Casks have ${italic}auto_updates true${reset} or ${italic}version :latest${reset}. Homebrew Cask cannot track versions of those apps."
|
||||
[ -n "$casks_latest_not_pinned" ] && echo -e "Edit this script and change the setting ${italic}latest=false${reset} to ${italic}true${reset}\n"
|
||||
|
||||
@@ -324,13 +326,15 @@ if [ -n "$casks_not_pinned" ]; then
|
||||
read -p "$a" choice
|
||||
|
||||
if [ "$choice" == "y" ] || [ "$choice" == "Y" ] || [ "$choice" == "a" ] || [ "$choice" == "A" ]; then
|
||||
echo ""
|
||||
for i in $casks_not_pinned;
|
||||
do
|
||||
if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then
|
||||
echo "$i" | xargs -p -n 1 brew upgrade
|
||||
# --cask required for Cask like 'docker'. It can be a formula or a cask.
|
||||
echo "$i" | xargs -p -n 1 brew upgrade --cask
|
||||
echo ""
|
||||
elif [ "$choice" == "a" ] || [ "$choice" == "A" ]; then
|
||||
echo "$i" | xargs -n 1 brew upgrade --dry-run
|
||||
echo "$i" | xargs -n 1 brew upgrade --cask
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
@@ -338,7 +342,7 @@ if [ -n "$casks_not_pinned" ]; then
|
||||
echo -e "OK, let's continue..."
|
||||
fi
|
||||
else
|
||||
echo "$casks_not_pinned" | xargs -n 1 brew upgrade --dry-run
|
||||
echo "$casks_not_pinned" | xargs -n 1 brew upgrade --cask
|
||||
fi
|
||||
|
||||
else
|
||||
@@ -360,7 +364,7 @@ if [ -n "$casks_latest_not_pinned" ] && [ "$latest" == true ]; then
|
||||
if [ "$display_info" = true ]; then
|
||||
[ "$nb_casks_latest_upd" -gt 1 ] && echo -e "${box} $nb_casks_latest_upd ${reset} ${array[@]/%/s}:\n" || echo -e "${box} $nb_casks_latest_upd ${reset} ${array[@]}:\n"
|
||||
|
||||
upd_casks_latest_info=$(brew info --json=v2 $upd_casks_latest | jq '{casks} | .[]')
|
||||
upd_casks_latest_info=$(brew info --cask --json=v2 $upd_casks_latest | jq '{casks} | .[]')
|
||||
for row in $upd_casks_latest;
|
||||
do
|
||||
get_info_cask "$upd_casks_latest_info" "$row"
|
||||
@@ -377,14 +381,14 @@ if [ -n "$casks_latest_not_pinned" ] && [ "$latest" == true ]; then
|
||||
read -p "$q" choice
|
||||
|
||||
if [ "$choice" == "y" ] || [ "$choice" == "Y" ] || [ "$choice" == "a" ] || [ "$choice" == "A" ]; then
|
||||
|
||||
echo ""
|
||||
for i in $casks_latest_not_pinned
|
||||
do
|
||||
if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then
|
||||
echo "\n$i" | xargs -p -n 1 brew upgrade
|
||||
echo "$i" | xargs -p -n 1 brew upgrade --cask
|
||||
echo ""
|
||||
elif [ "$choice" == "a" ] || [ "$choice" == "A" ]; then
|
||||
echo "\n$i" | xargs -n 1 brew upgrade
|
||||
echo "$i" | xargs -n 1 brew upgrade --cask
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -3,29 +3,16 @@
|
||||
# npm plugin for KYMSU (install local package)
|
||||
# https://github.com/welcoMattic/kymsu
|
||||
|
||||
# Fixing npm On Mac OS X for Homebrew Users
|
||||
# https://gist.github.com/rcugut/c7abd2a425bb65da3c61d8341cd4b02d
|
||||
# https://gist.github.com/DanHerbert/9520689
|
||||
|
||||
# brew install node
|
||||
# node -v => 9.11.1
|
||||
# npm -v => 5.6.0
|
||||
|
||||
# npm install -g npm
|
||||
# npm -v => 5.8.0
|
||||
|
||||
# https://github.com/npm/npm/issues/17744
|
||||
|
||||
#########################################
|
||||
#
|
||||
# Settings:
|
||||
|
||||
# No distract mode (no user interaction)
|
||||
no_distract=false
|
||||
# Display info on updated pakages / casks
|
||||
display_info=true
|
||||
|
||||
if [[ $1 == "--nodistract" ]]; then
|
||||
no_distract=true
|
||||
fi
|
||||
# No distract mode (no user interaction)
|
||||
|
||||
[[ $1 == "--nodistract" ]] && no_distract=true || no_distract=false
|
||||
|
||||
# Set ls_color to '' for output nvm list in default colors, else '--no-colors'
|
||||
# ls_color='--no-colors'
|
||||
@@ -40,31 +27,60 @@ local_path=$HOME/Sites/node_modules/
|
||||
|
||||
#########################################
|
||||
|
||||
echo -e "\033[1m🌿 npm \033[0m"
|
||||
: <<'END_COMMENT'
|
||||
blabla
|
||||
END_COMMENT
|
||||
|
||||
italic="\033[3m"
|
||||
underline="\033[4m"
|
||||
ita_under="\033[3;4m"
|
||||
bgd="\033[1;4;31m"
|
||||
red="\033[1;31m"
|
||||
bold="\033[1m"
|
||||
bold_ita="\033[1;3m"
|
||||
box="\033[1;41m"
|
||||
reset="\033[0m"
|
||||
|
||||
upd_nvm() {(
|
||||
cd "$NVM_DIR"
|
||||
git fetch --tags origin
|
||||
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
|
||||
) && \. "$NVM_DIR/nvm.sh"
|
||||
}
|
||||
|
||||
|
||||
echo -e "${bold}🌿 npm ${reset}"
|
||||
echo ""
|
||||
|
||||
# version courante de node.js
|
||||
node_v=$(node -v)
|
||||
echo -e "\033[4m🌿 node.js\033[0m (current version): $node_v"
|
||||
node_ins=$(which node)
|
||||
echo -e "${underline}🌿 node.js:${reset}"
|
||||
echo -e " - current version: ${italic}$node_v${reset}"
|
||||
echo -e " - install path: ${italic}$node_ins${reset}"
|
||||
|
||||
# version courante de npm
|
||||
npm_v=$(npm -v)
|
||||
echo -e "\033[4m🌿 npm\033[0m (current version): $npm_v"
|
||||
npm_ins=$(which npm)
|
||||
echo -e "\n${underline}🌿 npm:${reset}"
|
||||
echo -e " - current version: ${italic}$npm_v${reset}"
|
||||
echo -e " - install path: ${italic}$npm_ins${reset}"
|
||||
|
||||
# version installée de nvm par Homebrew
|
||||
nvm_installed=$(brew info nvm | grep Cellar)
|
||||
# nvm_installed=$(brew info nvm | grep Cellar)
|
||||
|
||||
# version actuelle de nvm sur GitHub
|
||||
version_nvm=$(git ls-remote --tags --refs --sort="v:refname" git://github.com/nvm-sh/nvm.git | tail -n1 | sed 's/.*\///' | sed 's/v//')
|
||||
|
||||
# github
|
||||
# nvm from github
|
||||
if [ -f "$NVM_DIR/nvm.sh" ]; then
|
||||
source $NVM_DIR/nvm.sh
|
||||
|
||||
# version courante de nvm
|
||||
nvm_v=$(nvm --version)
|
||||
#echo "$nvm_v,$version_nvm" | tr ',' '\n' | sort -V
|
||||
|
||||
echo -e "\033[4m🌿 nvm install is:\033[0m $NVM_DIR/nvm.sh"
|
||||
echo "nvm $nvm_v is installed from https://github.com/nvm-sh/nvm"
|
||||
|
||||
echo -e "\n${underline}🌿 nvm install is:${reset} $NVM_DIR/nvm.sh"
|
||||
echo " - nvm $nvm_v is installed from https://github.com/nvm-sh/nvm"
|
||||
|
||||
if [ "$nvm_v" != "$version_nvm" ]; then
|
||||
echo "Current nvm version on GitHub: $version_nvm"
|
||||
@@ -76,6 +92,7 @@ if [ -f "$NVM_DIR/nvm.sh" ]; then
|
||||
echo "Updating nvm from GitHub..."
|
||||
#curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v"$version_nvm"/install.sh | bash
|
||||
|
||||
upd_nvm
|
||||
#curl: native on Catalina, wget installed by homebrew
|
||||
#wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
|
||||
#curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
|
||||
@@ -83,14 +100,16 @@ if [ -f "$NVM_DIR/nvm.sh" ]; then
|
||||
fi
|
||||
|
||||
node_install=$(nvm list "$ls_color")
|
||||
echo -e "\033[4m🌿 node.js\033[0m (installed versions): \n$node_install"
|
||||
echo -e "\n${underline}🌿 node.js${reset} (installed versions): \n$node_install"
|
||||
|
||||
# homebrew
|
||||
# nvm from homebrew
|
||||
elif [ -f "/usr/local/opt/nvm/nvm.sh" ]; then
|
||||
source $(brew --prefix nvm)/nvm.sh
|
||||
|
||||
# version courante de nvm
|
||||
nvm_v=$(nvm --version)
|
||||
echo -e "\033[4m🌿 nvm install is:\033[0m /usr/local/opt/nvm/nvm.sh"
|
||||
|
||||
echo -e "\n${underline}🌿 nvm install is:${reset} /usr/local/opt/nvm/nvm.sh"
|
||||
echo "nvm $nvm_v is installed from homebrew"
|
||||
|
||||
if [ "$nvm_v" != "$version_nvm" ]; then
|
||||
@@ -98,11 +117,11 @@ elif [ -f "/usr/local/opt/nvm/nvm.sh" ]; then
|
||||
echo "Current nvm installed version: $nvm_v"
|
||||
|
||||
echo -e "nvm is outdated ! You should run \033[1;3mbrew update && brew upgrade nvm\033[0m"
|
||||
echo -e "or run \033[1;3mKymsu's homebrew.sh script\033[0m."
|
||||
echo -e "or run \033[1;3mKymsu's homebrew.sh script.${reset}"
|
||||
fi
|
||||
|
||||
node_install=$(nvm list "$ls_color")
|
||||
echo -e "\033[4m🌿 node.js\033[0m (installed versions): \n$node_install"
|
||||
echo -e "\n${underline}🌿 node.js${reset} (installed versions): \n$node_install"
|
||||
|
||||
fi
|
||||
|
||||
@@ -110,57 +129,94 @@ echo -e "\033[3mNote:"
|
||||
echo -e "N/A: version \"10.18.0 -> N/A\" is not yet installed."
|
||||
echo -e "You need to run \"nvm install 10.18.0\" to install it before using it.\033[0m"
|
||||
|
||||
echo
|
||||
echo ""
|
||||
|
||||
##################
|
||||
# Local packages #
|
||||
##################
|
||||
|
||||
# Local packages
|
||||
if [ -d "$local_path" ]; then
|
||||
cd "$local_path" || return
|
||||
echo -e "\033[4m🌿 Local installed scripts:\033[0m"
|
||||
npm ls
|
||||
echo -e "${underline}🌿 Local installed scripts:${reset}"
|
||||
|
||||
if [ "$display_info" = true ]; then
|
||||
ll=$(npm ls --long | grep -v 'git$')
|
||||
|
||||
while IFS= read -r line
|
||||
do
|
||||
if [[ "${line}" =~ "──" ]] || [[ "${line}" =~ "─┬" ]]; then
|
||||
echo -e "${bold}${line}${reset}"
|
||||
else
|
||||
echo -e "${line}"
|
||||
fi
|
||||
done <<< "$ll"
|
||||
else
|
||||
npm ls
|
||||
fi
|
||||
|
||||
|
||||
outdated=$(npm outdated)
|
||||
if [ -n "$outdated" ]; then
|
||||
echo "$outdated"
|
||||
echo "$outdated" | awk '{print $1}' | xargs npm update
|
||||
if [ "$no_distract" = false ]; then
|
||||
#echo "$outdated"
|
||||
echo "$outdated" | awk '{print $1}' | xargs -p -n 1 npm update
|
||||
else
|
||||
#echo "$outdated"
|
||||
echo "$outdated" | awk '{print $1}' | xargs -n 1 npm update
|
||||
fi
|
||||
|
||||
else
|
||||
echo -e "\033[4mNo local packages updates.\033[0m"
|
||||
echo -e "\n${underline}No local packages updates.${reset}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Global packages
|
||||
echo -e "\033[4m🌿 Global installed scripts:\033[0m"
|
||||
npm list -g --depth=0
|
||||
###################
|
||||
# Global packages #
|
||||
###################
|
||||
|
||||
echo -e "${underline}🌿 Global installed scripts:${reset}"
|
||||
|
||||
if [ "$display_info" = true ]; then
|
||||
lg=$(npm list -g --depth=0 --long | grep -v 'git$')
|
||||
|
||||
while IFS= read -r line
|
||||
do
|
||||
if [[ "${line}" =~ "──" ]]; then
|
||||
echo -e "${bold}${line}${reset}"
|
||||
else
|
||||
echo -e "${line}"
|
||||
fi
|
||||
done <<< "$lg"
|
||||
else
|
||||
npm list -g --depth=0
|
||||
fi
|
||||
|
||||
# ========================================================================
|
||||
# Tester npm outdated -g --long
|
||||
|
||||
#g_outdated=$(npm outdated -g)
|
||||
g_outdated=$(npm outdated -g --parseable=true)
|
||||
|
||||
# => 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
|
||||
echo "$g_outdated"
|
||||
|
||||
# update -> wanted ; install -> latest
|
||||
if [ -n "$g_outdated" ]; then
|
||||
if [ "$no_distract" = false ]; then
|
||||
#echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -p -n 1 npm install -g
|
||||
#echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -p -n 1 npm update -g --verbose
|
||||
# npm verb outdated not updating @angular/cli because it's currently at the maximum version that matches its specified semver range
|
||||
|
||||
echo "$g_outdated" | cut -d : -f 4 | xargs -p -n 1 npm -g install
|
||||
|
||||
else
|
||||
#echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -n 1 npm install -g
|
||||
#echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -n 1 npm update -g
|
||||
|
||||
echo "$g_outdated" | cut -d : -f 4 | xargs -n 1 npm -g install
|
||||
fi
|
||||
else
|
||||
echo -e "\033[4mNo global packages updates.\033[0m"
|
||||
echo -e "${underline}No global packages updates.${reset}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Maintenance
|
||||
###############
|
||||
# Maintenance #
|
||||
###############
|
||||
|
||||
if [ "$doctor" = true ]; then
|
||||
echo "🌿 The Doc is checking that everything is ok."
|
||||
npm doctor
|
||||
@@ -171,23 +227,4 @@ if [ "$doctor" = true ]; then
|
||||
echo ""
|
||||
fi
|
||||
|
||||
#if [[ $1 == "--npm_cleanup" ]]; then
|
||||
if [[ $1 == "--cleanup" ]]; then
|
||||
echo "npm cache clean"
|
||||
# As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid.
|
||||
# If you want to make sure everything is consistent, use 'npm cache verify' instead.
|
||||
# On the other hand, if you're debugging an issue with the installer, you can use `npm install --cache /tmp/empty-cache` to use a temporary cache instead of nuking the actual one.
|
||||
# If you're sure you want to delete the entire cache, rerun this command with --force.
|
||||
|
||||
if printf '%s\n%s\n' "$(npm --version)" 5.0.0 | sort --version-sort --check=silent; then
|
||||
echo "🌿 Cleaning npm cache"
|
||||
npm cache clean
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user