wunderio/lando-drupal

Add update check

Opened this issue · 0 comments

I don't see people updating this package all the time so in that sense if most of the package will be out-dated then it might be nice to have auto update feature.

This is example script:

services-appserver-run-check-version.sh

#!/bin/bash

cd /app

source vendor/wunderio/lando-drupal/scripts/_common.sh

setup_yq

# Define the package name you're interested in
package_name="wunderio/lando-drupal"

# Extract the installed version of the package from composer.lock
installed_version=$(jq -r --arg pkg "$package_name" '.packages[] | select(.name == $pkg) | .version' < composer.lock)

# Use Composer's `composer show` command to get the latest version of the package
latest_version=$(composer show --latest "$package_name" | awk '/^latest/{print $NF}')

# Compare the installed version with the latest version
if [[ "$installed_version" != "$latest_version" ]]; then
    # Prompt the user to install the newer version
    read -p "A newer version of $package_name is available ($latest_version). Do you want to update it? [Y/n] " choice
    case "$choice" in
        y|Y|'') composer require "$package_name:^$latest_version" ;;
        n|N) echo "Skipping update." ;;
        *) echo "Invalid choice. Skipping update." ;;
    esac
else
    echo "No updates available for $package_name."
fi