-add a do_not_update option
This commit is contained in:
2023-01-05 16:55:18 +01:00
parent 02ed39943b
commit feab0bb267
2 changed files with 61 additions and 26 deletions

View File

@@ -21,6 +21,7 @@ homebrew and pecl plugins notifie you if apache/php configuration files have bee
- **perl** (Perl modules ([cpan](https://metacpan.org)))
- **pip** ([Python Package index](https://pypi.org)) (pip or pip3)
- **pipx** ([Python Apps in Isolated Environments](https://pypa.github.io/pipx/))
- **rust** ([Rust](https://www.rust-lang.org))
- **venv** ([Environnement virtuel Python](https://docs.python.org/3/library/venv.html))
- **wp** (WordPress [wp-cli](https://wp-cli.org/fr/)) <u>(for testing only)</u>
@@ -77,7 +78,7 @@ Prefix plugin with a _ to ignore it:
There is a <u>settings section</u> on top of each plug-in:
- *[homebrew-pip]* don't update a module, package...: add it to the `do_not_update` array on the top.
- *[homebrew-pip-nodejs]* don't update a module, package...: add it to the `do_not_update` array on the top.
```bash
$ nano homebrew.sh
@@ -85,9 +86,9 @@ declare -a do_not_update=('virtualbox,virtualbox-extension-pack')
```
- *[homebrew]* display info on updated pakages: `display_info=true`
- *[homebrew-npm-pecl-pip]* no distract mode (no user interaction): `no_distract=false`
- *[homebrew-nodejs-pecl-pip]* no distract mode (no user interaction): `no_distract=false`
*If running Homebrew plug-in in no_distract mode, Casks with 'latest' version number won't be updated.*
- *[npm]* run npm maintenance tools: `doctor=true`
- *[nodejs]* run npm maintenance tools: `doctor=true`
- *[pip]* `version=pip or pip3` `user="" or "--user"`

View File

@@ -30,6 +30,11 @@ update_node=false
# run 'npm init' in local_path to create package.json
local_path=$HOME/Sites/
# Add module to the do_not_update array for prevent to update.
#declare -a do_not_update=()
#declare -a do_not_update=("parso" "asgiref")
declare -a do_not_update=("@squoosh/cli")
#########################################
: <<'END_COMMENT'
@@ -44,6 +49,8 @@ red="\033[1;31m"
bold="\033[1m"
bold_ita="\033[1;3m"
box="\033[1;41m"
redbold="\033[1;31m"
redbox="\033[1;41m"
reset="\033[0m"
upd_nvm() {(
@@ -142,6 +149,19 @@ echo -e "You need to run \"nvm install 10.18.0\" to install it before using it.$
echo ""
# Do not update packages
if (( ${#do_not_update[@]} )); then
nbp=${#do_not_update[*]}
echo -e "${underline}🌿 List of${reset} ${redbox} $nbp ${reset} ${underline}'do not update' packages:${reset}"
echo -e "${redbold}${do_not_update[*]}${reset}"
echo -e "To remove package from this list, you need to edit the ${italic}do_not_update${reset} array."
echo ""
fi
##################
# Local packages #
##################
@@ -203,6 +223,8 @@ if find "$local_path/node_modules" -mindepth 1 -maxdepth 1 | read; then
j=$(echo "$current" | awk -F "." '{print $1}')
k=$(echo "$latest" | awk -F "." '{print $1}')
if [[ ! " ${do_not_update[@]} " =~ " ${package} " ]]; then
# Update major version 1.x.y to 2.x.y
if [ $current = $wanted ] && [ "$j" -lt "$k" ]; then
if [ "$no_distract" = false ]; then
@@ -220,6 +242,10 @@ if find "$local_path/node_modules" -mindepth 1 -maxdepth 1 | read; then
fi
fi
else
echo -e "${redbold}$package is pinned to version $current !${reset} Don't update !"
fi
done <<< "$outdated"
else
@@ -287,9 +313,12 @@ if [ -n "$glong_outdated" ]; then
while IFS= read -r line
do
pkg=$(echo "$line" | awk '{print $1}')
curr=$(echo "$line" | awk '{print $2}')
vers=$(echo "$line" | awk '{print $4}')
outdated="$pkg@$vers"
if [[ ! " ${do_not_update[@]} " =~ " ${pkg} " ]]; then
# TEST
#version=$(echo "$line" | awk '{print $1 "@" $4}')
#echo "$version"
@@ -303,6 +332,11 @@ if [ -n "$glong_outdated" ]; then
echo ""
fi
else
echo -e "${redbold}$pkg is pinned to version $curr !${reset} Don't update !"
fi
done <<< "$glong_outdated"
else