Created
March 4, 2024 11:37
-
-
Save whchi/d9f677feea1aac6476b3bd1b208518b2 to your computer and use it in GitHub Desktop.
upgrade all poetry packages to latest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| UPDATE_TYPE=${1:-all} | |
| DEV_LIBS=$(poetry show --only=dev -o -T |awk '{print $1}') | |
| MAIN_LIBS=$(poetry show --only=main -o -T |awk '{print $1}') | |
| if [ "$UPDATE_TYPE" = "main" ]; then | |
| LIBS=$(poetry show --only=main -o -T |awk '{print $1}') | |
| elif [ "$UPDATE_TYPE" = "dev" ]; then | |
| LIBS=$(poetry show --only=dev -o -T |awk '{print $1}') | |
| elif [ "$UPDATE_TYPE" = "all" ]; then | |
| LIBS=$(poetry show -o -T |awk '{print $1}') | |
| else | |
| echo "Invalid update type: $UPDATE_TYPE" | |
| exit 1 | |
| fi | |
| echo "Upgrading $UPDATE_TYPE packages" | |
| for pkg in $LIBS | |
| do | |
| if echo $DEV_LIBS | grep -q $pkg; then | |
| EXTRA_OPTS="-G dev" | |
| else | |
| EXTRA_OPTS="" | |
| fi | |
| echo "[begin].....$pkg" | |
| poetry add $pkg@latest $EXTRA_OPTS | |
| echo "[end].......$pkg\n" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment