-npm doctor
-nvm list
-current node
-current npm
This commit is contained in:
2018-09-02 09:25:59 +02:00
parent 0960dd6ee4
commit da6fa49f71
5 changed files with 185 additions and 7 deletions

View File

View File

@@ -22,6 +22,8 @@ echo ""
brew_outdated=$(brew outdated) brew_outdated=$(brew outdated)
upd3=$(echo "$brew_outdated" | awk '{print $1}') upd3=$(echo "$brew_outdated" | awk '{print $1}')
#nb=$(echo $upd3 | wc -w)
if [ -n "$upd3" ]; then if [ -n "$upd3" ]; then
if [ "$display_info" = true ]; then if [ "$display_info" = true ]; then

42
_npm.sh
View File

@@ -19,15 +19,34 @@
# No distract mode # No distract mode
no_distract=false no_distract=false
doctor=false
local_path=/Users/bruno/Sites/node_modules/ local_path=/Users/bruno/Sites/node_modules/
echo -e "\033[1m🌿 npm \033[0m" echo -e "\033[1m🌿 npm \033[0m"
echo "" echo ""
# version courante de node.js
node_v=$(node -v)
echo -e "\033[4m🌿 node.js\033[0m (current version): $node_v"
# version courante de npm
npm_v=$(npm -v)
echo -e "\033[4m🌿 npm\033[0m (current version): $npm_v"
# versions installées de node.js
nvm_installed=$(brew info nvm | grep Cellar)
if [ -n "$nvm_installed" ]; then
source $(brew --prefix nvm)/nvm.sh
node_install=$(nvm list)
echo -e "\033[4m🌿 node.js\033[0m (installed versions): \n$node_install"
fi
echo
# Local packages # Local packages
#cd /Users/bruno/Sites/node_modules/ #cd /Users/bruno/Sites/node_modules/
cd $local_path cd $local_path
echo -e "\033[4mLocal installed scripts:\033[0m" echo -e "\033[4m🌿 Local installed scripts:\033[0m"
npm ls npm ls
outdated=$(npm outdated) outdated=$(npm outdated)
if [ -n "$outdated" ]; then if [ -n "$outdated" ]; then
@@ -40,22 +59,33 @@ fi
echo "" echo ""
# Global packages # Global packages
echo -e "\033[4mGlobal installed scripts:\033[0m" echo -e "\033[4m🌿 Global installed scripts:\033[0m"
npm list -g --depth=0 npm list -g --depth=0
g_outdated=$(npm outdated -g --depth=0) g_outdated=$(npm outdated -g)
# update -> wanted ; install -> latest
if [ -n "$g_outdated" ]; then if [ -n "$g_outdated" ]; then
if [ "$no_distract" = false ]; then if [ "$no_distract" = false ]; then
echo "$g_outdated" echo "$g_outdated"
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 install -g
echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -p -n 1 npm update -g
else 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 install -g
echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -n 1 npm update -g
fi fi
else else
echo -e "\033[4mNo global packages updates.\033[0m" echo -e "\033[4mNo global packages updates.\033[0m"
fi fi
echo
# Maintenance
if [ "$doctor" = true ]; then
echo "🌿 The Doc is checking that everything is ok."
npm doctor
fi
if [[ $1 == "--npm_cleanup" ]]; then if [[ $1 == "--npm_cleanup" ]]; then
echo "🌬 Cleaning npm cache" echo "🌿 Cleaning npm cache"
npm cache clean npm cache clean
echo "" echo ""
fi fi

View File

@@ -10,7 +10,7 @@ user=""
# No distract mode # No distract mode
no_distract=false no_distract=false
#add module to do_not_update array #add module to do_not_update array
declare -a do_not_update=( "tornado","urllib3") declare -a do_not_update=()
if [[ $1 == "--nodistract" ]]; then if [[ $1 == "--nodistract" ]]; then
no_distract=true no_distract=true

146
wp.sh Executable file
View File

@@ -0,0 +1,146 @@
#!/usr/bin/env bash
# wp-cli plugin for KYMSU
# https://github.com/welcoMattic/kymsu
# https://make.wordpress.org/cli/handbook/
#version: pip ou pip3
#version=pip3
#user: "" or "--user"
#user=""
# Répertoire WordPress
rep_wordpress=/Users/bruno/Sites/wordpress
# No distract mode
no_distract=false
#add module to do_not_update array
declare -a do_not_update=()
if [[ $1 == "--nodistract" ]]; then
no_distract=true
fi
if ! [ -x "$(command -v wp)" ]; then
echo "Error: wp-cli is not installed." >&2
exit 1
fi
echo -e "\033[1mWP wp-cli \033[0m"
echo ""
cd $rep_wordpress
#echo $(pwd)
# *** plugins ***
if [ "$no_distract" = false ]; then
# *** core update ***
echo "Search for core update..."
core_cu=$(wp core check-update)
if ! [[ $core_cu = *"latest version"* ]]; then
echo "New version available!"
z=$(echo -e "Do you wanna \033[1m upgrade WordPress\033[0m? (y/n)")
read -p "$z" choice
case "$choice" in
y|Y ) wp core update && wp core update-db ;;
n|N ) echo "Ok, let's continue";;
* ) echo "invalid";;
esac
# pas testé
else
echo "WordPress is up to date!"
# test ok
fi
echo ""
# *** plugins ***
echo "Search for all plugins update..."
plugin_cu_all=$(wp plugin update --all --dry-run)
a=$(echo "$plugin_cu_all" | sed '1,2d' | awk '{print $1}')
if [ -z "$a" ]; then
echo "No plugins update available !"
else
echo "$a" | awk '{print $1}' | xargs -p -n 1 wp plugin update --dry-run
fi
# test ok
echo ""
# *** themes ***
echo "Search for all themes update..."
theme_cu_all=$(wp theme update --all --dry-run)
b=$(echo "$theme_cu_all" | sed '1,2d' | awk '{print $1}')
if [ -z "$b" ]; then
echo "No themes update available !"
else
echo "$b" | awk '{print $1}' | xargs -p -n 1 wp theme update --dry-run
fi
echo "pas testé"
# pas testé
echo ""
# *** languages core ***
echo "Search for languages core update..."
list_lang_core_upd=$(wp language core list --update=available --all --format=csv)
c=$(echo "$list_lang_core_upd" | sed '1d' | awk '{print $1}')
if [ -z "$c" ]; then
echo "No languages core update available !"
else
echo "$c"
fi
echo ""
# *** languages plugin ***
echo "Search for languages plugins update..."
list_lang_plugin_upd=$(wp language plugin list --update=available --all --format=csv)
d=$(echo "$list_lang_plugin_upd" | sed '1d' | awk '{print $1}')
if [ -z "$d" ]; then
echo "No languages plugins update available !"
else
echo "$d"
fi
echo ""
# *** languages theme ***
echo "Search for languages themes update..."
list_lang_theme_upd=$(wp language theme list --update=available --all --format=csv)
e=$(echo "$list_lang_theme_upd" | sed '1d' | awk '{print $1}')
if [ -z "$e" ]; then
echo "No languages themes update available !"
else
echo "$e"
fi
else
echo "No distract"
# *** core update ***
#wp core update
#wp core update-db
# *** plugins ***
#wp plugin update --all
# *** themes ***
#wp theme update --all
# *** languages core ***
#wp language core update
# *** languages plugin ***
#wp language plugin update --all
# *** languages theme ***
# wp language theme update --all
fi
echo ""