diff --git a/setup/upgrade.sh b/setup/upgrade.sh index 527e91f4b..fe9d74801 100644 --- a/setup/upgrade.sh +++ b/setup/upgrade.sh @@ -6,8 +6,11 @@ parseparams() SCRIPTS=() ENVIRONMENTS=() PREPROCESSING=() - while getopts "hyt:s:p:c:e:" opt; do + while getopts "hyit:s:p:c:e:" opt; do case "${opt}" in + i) + IGNORE=true + ;; y) Y=true ;; @@ -173,20 +176,17 @@ version_check() VERSION=$(docker-compose exec -T "$SERVICE" cat package.json | jq -r '.version') fi target_version - if [ "$TARGET" = 'custom' ]; then return; fi + if [ "$TARGET" = 'custom' ] || [ "$IGNORE" = "true" ]; then return; fi - if verlt "$VERSION" 2.8.3 && verlt 2.8.3 "$TARGET"; then - version_error "v2.8.3 first" - elif verlt "$VERSION" 3.1.2 && verlt 3.1.2 "$TARGET"; then - version_error "v3.1.2 first" - elif verlt "$VERSION" 4.0.4 && verlt 4.0.4 "$TARGET"; then - version_error "v4.0.4 first" - elif verlt "$VERSION" 4.4.6 && verlt 4.4.6 "$TARGET"; then - version_error "v4.4.6 first" - elif verlt "$VERSION" 4.7.14 && verlt 4.7.14 "$TARGET"; then - version_error "v4.7.14 first" - elif verlt "$TARGET" "$VERSION"; then - version_error "a version > $VERSION" + HTTP_CODE=$(curl -I -s -w "%{http_code}\n" -o /dev/null "https://hub.fab-manager.com/api/versions/check?version=$VERSION") + if [ "$HTTP_CODE" != 200 ]; then + printf "\n\n\e[91m[ ❌ ] Unable to check the next step version. Please check your internet connection or restart this script providing the \e[1m-i\e[0m\e[91m option\n\e[39m" + exit 3 + fi + STEP=$(\curl -sSL "https://hub.fab-manager.com/api/versions/latest" | jq -r '.upgrade_to.semver') + + if verlt "$VERSION" "$STEP" && verlt "$STEP" "$TARGET"; then + version_error "$STEP first" fi } @@ -262,7 +262,10 @@ restore_tag() upgrade() { - [[ "$YES_ALL" = "true" ]] && confirm="y" || read -rp ":: Proceed with upgrading to version $TARGET ? (Y/n) " confirm Force the upgrade to target the specified version -p Run the preprocessing command (TODO DEPLOY) -c Provides additional upgrade command, run in the context of the app (TODO DEPLOY)