Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
064ae0ecf0
|
|||
|
cb0a07339d
|
|||
|
560bb5e13b
|
|||
|
64264174b4
|
|||
|
6b4dfb2abb
|
|||
|
1d2a6b5e3b
|
|||
|
f337e0c62b
|
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,33 +7,34 @@
|
||||
#
|
||||
# Settings:
|
||||
|
||||
# Display info on updated pakages
|
||||
# Display info on updated pakages / casks
|
||||
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=("xld" "webpquicklook")
|
||||
declare -a cask_to_not_update=()
|
||||
|
||||
# No distract mode (no user interaction)(Casks with 'latest' version number won't be updated)
|
||||
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
|
||||
#
|
||||
###############################################################################################
|
||||
#
|
||||
# Recommended software (brew install):
|
||||
# Require software (brew install):
|
||||
# -jq (Lightweight and flexible command-line JSON processor)
|
||||
#
|
||||
# Recommended software (brew install):
|
||||
# -terminal-notifier (Send macOS User Notifications from the command-line)
|
||||
#
|
||||
###############################################################################################
|
||||
|
||||
: <<'END_COMMENT'
|
||||
blabla
|
||||
END_COMMENT
|
||||
|
||||
|
||||
italic="\033[3m"
|
||||
underline="\033[4m"
|
||||
ita_under="\033[3;4m"
|
||||
@@ -43,6 +44,9 @@ bold="\033[1m"
|
||||
box="\033[1;41m"
|
||||
reset="\033[0m"
|
||||
|
||||
command -v terminal-notifier >/dev/null 2>&1 || { echo -e "You shoud intall ${bold}terminal-notifier${reset} for notification ${italic}(brew install terminal-notifier)${reset}.\n"; }
|
||||
command -v jq >/dev/null 2>&1 || { echo -e "${bold}kymsu2${reset} require ${bold}jq${reset} but it's not installed.\nRun ${italic}(brew install jq)${reset}\nAborting..." >&2; exit 1; }
|
||||
|
||||
notification() {
|
||||
sound="Basso"
|
||||
title="Homebrew"
|
||||
@@ -58,10 +62,73 @@ notification() {
|
||||
if [[ $1 == "--nodistract" ]]; then no_distract=true; fi
|
||||
if [[ $1 == "--latest" ]]; then latest=true; fi
|
||||
|
||||
get_info_cask() {
|
||||
info="$1"
|
||||
app="$2"
|
||||
l1=""
|
||||
|
||||
token=$(echo "$info" | jq -r '.[] | select(.token == "'${app}'") | (.token)')
|
||||
name=$(echo "$info" | jq -r '.[] | select(.token == "'${app}'") | (.name)' | jq -r '.[0]')
|
||||
homepage=$(echo "$info" | jq -r '.[] | select(.token == "'${app}'") | (.homepage)')
|
||||
url=$(echo "$info" | jq -r '.[] | select(.token == "'${app}'") | (.url)')
|
||||
desc=$(echo "$info" | jq -r '.[] | select(.token == "'${app}'") | (.desc)')
|
||||
version=$(echo "$info" | jq -r '.[] | select(.token == "'${app}'") | (.version)')
|
||||
#auto_updates=$(echo "$info" | jq -r '.[] | select(.token == "'${app}'") | (.auto_updates)')
|
||||
#caveats=$(echo "$info" | jq -r '.[] | select(.token == "'${app}'") | (.caveats)')
|
||||
|
||||
installed_versions=$(echo "$upd_cask" | jq -r '.[] | select(.name == "'${app}'") | (.installed_versions)')
|
||||
current_version=$(echo "$upd_cask" | jq -r '.[] | select(.name == "'${app}'") | (.current_version)')
|
||||
|
||||
[[ "$desc" = "null" ]] && desc="${italic}No description${reset}"
|
||||
|
||||
if [[ ! " ${casks_not_pinned} " =~ " ${token} " ]] && [[ ! " ${casks_latest_not_pinned} " =~ " ${token} " ]]; then
|
||||
l1+="${red}$name ($token): installed: $installed_versions current: $current_version [Do not update]${reset}\n"
|
||||
else
|
||||
l1+="${bold}$name ($token): installed: $installed_versions current: $current_version${reset}\n"
|
||||
fi
|
||||
l1+="$desc\n"
|
||||
l1+="$homepage"
|
||||
|
||||
echo -e "$l1\n"
|
||||
}
|
||||
|
||||
get_info_pkg() {
|
||||
info="$1"
|
||||
pkg="$2"
|
||||
l1=""
|
||||
|
||||
name=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.name)')
|
||||
full_name=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.full_name)')
|
||||
desc=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.desc)')
|
||||
homepage=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.homepage)')
|
||||
|
||||
#urls=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.urls)' | jq -r '.stable | .url')
|
||||
keg_only=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.keg_only)')
|
||||
caveats=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.caveats)')
|
||||
stable=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.versions)' | jq -r '.stable')
|
||||
installed=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.installed)' | jq -r '.[].version')
|
||||
pinned=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.pinned)')
|
||||
|
||||
if [ "$pinned" = "true" ]; then
|
||||
pinned_v=$(echo "$upd_package" | jq -r '.[] | select(.name == "'${pkg}'") | (.pinned_version)')
|
||||
|
||||
l1+="${red}$name: installed: $installed stable: $stable [pinned at $pinned_v]"
|
||||
[ "$keg_only" = true ] && l1+=" [keg-only]"
|
||||
l1+="${reset}\n"
|
||||
else
|
||||
l1+="${bold}$name: installed: $installed stable: $stable"
|
||||
[ "$keg_only" = true ] && l1+=" [keg-only]"
|
||||
l1+="${reset}\n"
|
||||
fi
|
||||
if [ "$desc" != "null" ]; then l1+="$desc\n"; fi;
|
||||
l1+="$homepage"
|
||||
|
||||
echo -e "$l1\n"
|
||||
}
|
||||
|
||||
echo -e "${bold}🍺 Homebrew ${reset}"
|
||||
|
||||
echo -e "\n🍺 ${underline}Updating brew...${reset}"
|
||||
echo -e "\n🍺 ${underline}Updating brew...${reset}\n"
|
||||
#brew update
|
||||
|
||||
echo ""
|
||||
@@ -69,7 +136,6 @@ brew_outdated=$(brew outdated --greedy --json=v2)
|
||||
|
||||
#echo "\nSearch for brew update...\n"
|
||||
upd_json=$(echo "$brew_outdated")
|
||||
#echo "$upd_json"
|
||||
|
||||
################
|
||||
### Packages ###
|
||||
@@ -78,7 +144,6 @@ upd_json=$(echo "$brew_outdated")
|
||||
# Packages update:
|
||||
echo -e "\n🍺 ${underline}Search for packages update...${reset}\n"
|
||||
upd_package=$(echo "$brew_outdated" | jq '{formulae} | .[]')
|
||||
#echo "$upd_package"
|
||||
|
||||
for row in $(jq -c '.[]' <<< "$upd_package");
|
||||
do
|
||||
@@ -86,24 +151,38 @@ do
|
||||
installed_versions=$(echo "$row" | jq -j '.installed_versions' | jq -r '.[]')
|
||||
current_version=$(echo "$row" | jq -j '.current_version')
|
||||
pinned=$(echo "$row" | jq -j '.pinned')
|
||||
pinned_version=$(echo "$row" | jq -j '.pinned_version')
|
||||
|
||||
echo "$name - $installed_versions - $current_version - $pinned - $pinned_version"
|
||||
#pinned_version=$(echo "$row" | jq -j '.pinned_version')
|
||||
|
||||
upd_pkgs+="$name "
|
||||
if [ "$pinned" = true ]; then
|
||||
upd_pkg_pinned+="$name "
|
||||
elif [ "$pinned" = false ]; then
|
||||
upd_pkg_notpinned+="$name "
|
||||
fi
|
||||
|
||||
fi
|
||||
done
|
||||
upd_pkgs=$(echo "$upd_pkgs" | sed 's/.$//')
|
||||
upd_pkg_pinned=$(echo "$upd_pkg_pinned" | sed 's/.$//')
|
||||
upd_pkg_notpinned=$(echo "$upd_pkg_notpinned" | sed 's/.$//')
|
||||
|
||||
# Find infos about updated packages
|
||||
nb_pkg_upd=$(echo "$upd_pkgs" | wc -w | xargs)
|
||||
if [ "$nb_pkg_upd" -gt 0 ]; then
|
||||
a="available package update"
|
||||
array=($a)
|
||||
if [ "$display_info" = true ]; then
|
||||
[ "$nb_pkg_upd" -gt 1 ] && echo -e "${box} $nb_pkg_upd ${reset} ${array[@]/%/s}:\n" || echo -e "${box} $nb_pkg_upd ${reset} ${array[@]}:\n"
|
||||
upd_pkgs_info=$(brew info --json=v2 $upd_pkgs | jq '{formulae} | .[]')
|
||||
for row in $upd_pkgs;
|
||||
do
|
||||
get_info_pkg "$upd_pkgs_info" "$row"
|
||||
done
|
||||
else
|
||||
[ "$nb_pkg_upd" -gt 1 ] && echo -e "${box} $nb_pkg_upd ${reset} ${array[@]/%/s}: ${bold}$upd_pkgs${reset}" || echo -e "${box} $nb_pkg_upd ${reset} ${array[@]}: ${bold}$upd_pkgs${reset}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Pinned packages
|
||||
pkg_pinned=$(brew list --formulae --pinned | xargs)
|
||||
pkg_pinned=$(brew list --pinned | xargs)
|
||||
if [ -n "$pkg_pinned" ]; then
|
||||
|
||||
nbp=$(echo "$pkg_pinned" | wc -w | xargs)
|
||||
@@ -133,9 +212,9 @@ if [ -n "$upd_pkg_notpinned" ]; then
|
||||
for i in $upd_pkg_notpinned;
|
||||
do
|
||||
if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then
|
||||
echo "$i"
|
||||
echo "$i" | xargs -p -n 1 brew upgrade
|
||||
elif [ "$choice" == "a" ] || [ "$choice" == "A" ]; then
|
||||
echo "$i"
|
||||
echo "$i" | xargs -n 1 brew upgrade
|
||||
fi
|
||||
done
|
||||
else
|
||||
@@ -151,32 +230,27 @@ else
|
||||
echo -e "\n${italic}No update package available...${reset}\n"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
#############
|
||||
### Casks ###
|
||||
#############
|
||||
|
||||
#Casks update
|
||||
echo -e "\n🍺 ${underline}Search for casks update...${reset}\n"
|
||||
echo -e "\n🍺 ${underline}Casks...${reset}\n"
|
||||
upd_cask=$(echo "$brew_outdated" | jq '{casks} | .[]')
|
||||
#echo "$upd_cask"
|
||||
|
||||
#i=0
|
||||
for row in $(jq -c '.[]' <<< "$upd_cask");
|
||||
do
|
||||
name=$(echo "$row" | jq -j '.name')
|
||||
installed_versions=$(echo "$row" | jq -j '.installed_versions')
|
||||
current_version=$(echo "$row" | jq -j '.current_version')
|
||||
|
||||
#upd_casks+="$name "
|
||||
echo "$name - $installed_versions - $current_version"
|
||||
|
||||
if [ "$current_version" != "latest" ]; then
|
||||
upd_casks+="$name "
|
||||
|
||||
elif [ "$current_version" == "latest" ]; then
|
||||
upd_casks_latest+="$name "
|
||||
fi
|
||||
|
||||
done
|
||||
upd_casks=$(echo "$upd_casks" | sed 's/.$//')
|
||||
upd_casks_latest=$(echo "$upd_casks_latest" | sed 's/.$//')
|
||||
@@ -188,17 +262,15 @@ if (( ${#cask_to_not_update[@]} )); then
|
||||
|
||||
nbp=${#cask_to_not_update[*]}
|
||||
|
||||
echo -e "\n${underline}List of${reset} ${box} $nbp ${reset} ${underline}'do not update' packages:${reset}"
|
||||
echo -e "${underline}List of${reset} ${box} $nbp ${reset} ${underline}'do not update' packages:${reset}"
|
||||
echo -e "${red}${cask_to_not_update[*]}${reset}"
|
||||
echo -e "To remove package from this list, you need to edit the do_not_update array."
|
||||
echo -e "To remove package from this list, you need to edit the ${italic}do_not_update${reset} array."
|
||||
echo ""
|
||||
|
||||
casks_not_pinned=""
|
||||
for i in $upd_casks
|
||||
do
|
||||
#echo "$i"
|
||||
if [[ ! " ${cask_to_not_update[@]} " =~ " ${i} " ]]; then
|
||||
#echo "$i"
|
||||
casks_not_pinned+="$i "
|
||||
fi
|
||||
done
|
||||
@@ -207,9 +279,7 @@ if (( ${#cask_to_not_update[@]} )); then
|
||||
casks_latest_not_pinned=""
|
||||
for i in $upd_casks_latest
|
||||
do
|
||||
#echo "$i"
|
||||
if [[ ! " ${cask_to_not_update[@]} " =~ " ${i} " ]]; then
|
||||
#echo "$i"
|
||||
casks_latest_not_pinned+="$i "
|
||||
fi
|
||||
done
|
||||
@@ -220,9 +290,33 @@ else
|
||||
casks_latest_not_pinned=$upd_casks_latest
|
||||
fi
|
||||
|
||||
#Casks update
|
||||
echo -e "🍺 ${underline}Search for casks update...${reset}\n"
|
||||
|
||||
# Find infos about updated casks
|
||||
nb_casks_upd=$(echo "$upd_casks" | wc -w | xargs)
|
||||
if [ "$nb_casks_upd" -gt 0 ]; then
|
||||
a="available cask update"
|
||||
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 --cask --json=v2 $upd_casks | jq '{casks} | .[]')
|
||||
for row in $upd_casks;
|
||||
do
|
||||
get_info_cask "$upd_casks_info" "$row"
|
||||
done
|
||||
else
|
||||
[ "$nb_casks_upd" -gt 1 ] && echo -e "${box} $nb_casks_upd ${reset} ${array[@]/%/s}: ${bold}$upd_casks${reset}" || echo -e "${box} $nb_casks_upd ${reset} ${array[@]}: ${bold}$upd_casks${reset}"
|
||||
fi
|
||||
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"
|
||||
|
||||
|
||||
if [ -n "$casks_not_pinned" ]; then
|
||||
|
||||
@@ -232,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 --dry-run
|
||||
# --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
|
||||
@@ -246,8 +342,7 @@ if [ -n "$casks_not_pinned" ]; then
|
||||
echo -e "OK, let's continue..."
|
||||
fi
|
||||
else
|
||||
#echo "No distract"
|
||||
echo "$casks_not_pinned" | xargs -n 1 brew upgrade --dry-run
|
||||
echo "$casks_not_pinned" | xargs -n 1 brew upgrade --cask
|
||||
fi
|
||||
|
||||
else
|
||||
@@ -258,22 +353,42 @@ fi
|
||||
# Updating casks latest
|
||||
if [ -n "$casks_latest_not_pinned" ] && [ "$latest" == true ]; then
|
||||
echo -e "\n🍺 ${underline}Updating casks with 'latest' as version...${reset}\n"
|
||||
echo -e "Some Casks have ${italic}auto_updates true${reset} or ${italic}version :latest${reset}. Homebrew Cask cannot track versions of those apps."
|
||||
echo -e "Here you can force Homebrew to upgrade those apps.\n"
|
||||
#echo -e "Some Casks have ${italic}auto_updates true${reset} or ${italic}version :latest${reset}. Homebrew Cask cannot track versions of those apps."
|
||||
#echo -e "Here you can force Homebrew to upgrade those apps.\n"
|
||||
|
||||
# Find infos about updated casks
|
||||
nb_casks_latest_upd=$(echo "$upd_casks_latest" | wc -w | xargs)
|
||||
if [ "$nb_casks_latest_upd" -gt 0 ]; then
|
||||
a="available cask update"
|
||||
array=($a)
|
||||
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 --cask --json=v2 $upd_casks_latest | jq '{casks} | .[]')
|
||||
for row in $upd_casks_latest;
|
||||
do
|
||||
get_info_cask "$upd_casks_latest_info" "$row"
|
||||
done
|
||||
|
||||
else
|
||||
[ "$nb_casks_latest_upd" -gt 1 ] && echo -e "${box} $nb_casks_latest_upd ${reset} ${array[@]/%/s}: ${bold}$upd_casks_latest${reset}" || echo -e "${box} $nb_casks_upd ${reset} ${array[@]}: ${bold}$upd_casks_latest${reset}"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ "$no_distract" = false ]; then
|
||||
q=$(echo -e "Do you wanna run ${bold}brew upgrade $casks_latest_not_pinned${reset} ? (y/n/a) ")
|
||||
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 "$i" | xargs -p -n 1 brew upgrade --dry-run
|
||||
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
|
||||
@@ -283,19 +398,59 @@ if [ -n "$casks_latest_not_pinned" ] && [ "$latest" == true ]; then
|
||||
fi
|
||||
|
||||
else
|
||||
#echo "No distract"
|
||||
echo -e "Running ${bold}brew upgrade $casks_latest_not_pinned${reset}..."
|
||||
echo "$casks_latest_not_pinned" | xargs -n 1 brew upgrade --dry-run
|
||||
echo "$casks_latest_not_pinned" | xargs -n 1 brew upgrade
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
###############################################################
|
||||
### Test if Apache conf file has been modified by Homebrew ###
|
||||
### (Apache, PHP or Python updates) ###
|
||||
###############################################################
|
||||
|
||||
v_apa=$(httpd -V | grep 'SERVER_CONFIG_FILE')
|
||||
conf_apa=$(echo "$v_apa" | awk -F "\"" '{print $2}')
|
||||
dir=$(dirname $conf_apa)
|
||||
name=$(basename $conf_apa)
|
||||
notif1="$dir has been modified in the last 5 minutes"
|
||||
|
||||
test=$(find $dir -name "$name" -mmin -5 -maxdepth 1)
|
||||
|
||||
echo "$test"
|
||||
|
||||
[ ! -z $test ] && echo -e "\033[1;31m❗️ ️$notif1\033[0m"
|
||||
[ ! -z $test ] && notification "$notif1"
|
||||
|
||||
# Test if PHP.ini file has been modified by Homebrew (PECL)
|
||||
|
||||
php_versions=$(ls /usr/local/etc/php/)
|
||||
for php in $php_versions
|
||||
do
|
||||
if [ -n "$upd_pkg" ]; then
|
||||
|
||||
# file modified since it was last read
|
||||
php_modified=$(find /usr/local/etc/php/$php/ -name php.ini -newer /tmp/checkpoint)
|
||||
php_ini=/usr/local/etc/php/$php/php.ini
|
||||
notif2="$php_ini has been modified"
|
||||
|
||||
echo "$php_modified"
|
||||
|
||||
[ ! -z $php_modified ] && echo -e "\033[1;31m❗️ ️$notif2\033[0m"
|
||||
[ ! -z $php_modified ] && notification "$notif2"
|
||||
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
|
||||
|
||||
##############
|
||||
### Doctor ###
|
||||
##############
|
||||
|
||||
echo -e "\n🍺 ${underline}The Doc is checking that everything is ok...${reset}\n"
|
||||
|
||||
#brew doctor
|
||||
brew doctor
|
||||
|
||||
brew missing
|
||||
status=$?
|
||||
|
||||
@@ -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