Skip to content

Add gh extensions outdated command + indicate outdated extensions in gh extensions list and similar #8327

Open

Description

@0xdevalias

Describe the feature or problem you’d like to solve

Currently we can sort of check for outdated gh extensions by using gh extensions upgrade --all --dry-run:

⇒ gh extension upgrade -h
Upgrade installed extensions

USAGE
  gh extension upgrade {<name> | --all} [flags]

FLAGS
  --all       Upgrade all extensions
  --dry-run   Only display upgrades
  --force     Force upgrade extension

INHERITED FLAGS
  --help   Show help for command

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual

That's ok.. but it's not as intuitive/nice to view/parse/etc as something like npm outdated:

⇒ npm outdated -h
Check for outdated packages

Usage:
npm outdated [<package-spec> ...]

Options:
[-a|--all] [--json] [-l|--long] [-p|--parseable] [-g|--global]
[-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]

Run "npm help outdated" for more info

Proposed solution

It would be cool if the gh CLI supported a command such as gh extensions outdated or similar, that would show all of our outdated extensions, link to their repo releases/changelog/etc for us to review the changes, etc.

If the 'extension outdated' version info was cached somewhere locally, then this could also potentially be shown within the gh extension list or similar areas as well.

This could also tie in well with the feature being discussed in:

Particularly as there seems to be discussion about where to cache the version information, eg:

Additional context

I wrote a bit of a hacky gh alias wrapper function to implement a prototype of this this morning:

    outdated: |
      !gh_extensions_outdated() {
        if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ $# -ne 0 ]; then
          echo "Usage: gh outdated"
          echo "Check for outdated GitHub CLI extensions and the gh CLI tool itself."
          echo ""
          echo "This command performs the following actions:"
          echo "  - Lists all installed gh extensions."
          echo "  - Checks if any installed extensions have updates available."
          echo "  - Offers to upgrade individual extensions if updates are available."
          echo "  - Checks if the gh CLI tool is up to date and offers to upgrade it if not."
          echo ""
          echo "Options:"
          echo "  -h, --help     Show this help message and exit."
          return 0
        fi

        gh extension list

        echo

        echo "Release notes:"
        (gh extension list | awk '{print $3}' | sed 's#^#  https://github.com/#' | sed 's#$#/releases#')

        echo

        echo "Checking for outdated extensions..."
        outdated_extensions=$(gh extension upgrade --all --dry-run)
        outdated_found=false

        while read -r line; do
          if [[ $line == *"would have upgraded from"* ]]; then
            outdated_found=true
            extension_name=$(echo "$line" | awk '{print $1}' | tr -d '[]:')
            current_version=$(echo "$line" | awk '{print $(NF-2)}')
            new_version=$(echo "$line" | awk '{print $NF}')

            echo "  Extension $extension_name is outdated (Current: $current_version, Available: $new_version)"

            # echo "Do you want to upgrade $extension_name? [y/N]"
            # read -r upgrade_extension
            # if [ "$upgrade_extension" = "y" ]; then
            #   gh extension upgrade "$extension_name"
            # fi
          fi
        done <<< "$outdated_extensions"

        if [[ $outdated_found == true ]]; then
          echo "Do you want to upgrade all outdated extensions? [y/N]"
          read -r answer
          if [ "$answer" = "y" ]; then
            gh extension upgrade --all
          fi
        else
          echo "  All extensions are up to date!"
        fi

        echo

        echo "Checking to see if gh is up to date..."
        if brew outdated gh | grep -q 'gh'; then
          echo "gh is outdated. Do you want to upgrade? [y/N]"
          read -r upgrade_gh
          if [ "$upgrade_gh" = "y" ]; then
            brew upgrade gh
          fi
        else
          echo "  gh is up to date!"
        fi
      }; gh_extensions_outdated $@

When no extensions are outdated, this looks similar to the following:

⇒ gh outdated
NAME              REPO                      VERSION
gh actions-cache  actions/gh-actions-cache  v1.0.4
gh copilot        github/gh-copilot         v0.5.3-beta

Release notes:
  https://github.com/actions/gh-actions-cache/releases
  https://github.com/github/gh-copilot/releases

Checking for outdated extensions...
  All extensions are up to date!

Checking to see if gh is up to date...
  gh is up to date!

Or when an outdated extension exists, it looks like this:

⇒ gh outdated
NAME              REPO                      VERSION
gh actions-cache  actions/gh-actions-cache  v1.0.4
gh copilot        github/gh-copilot         v0.5.3-beta

Release notes:
  https://github.com/actions/gh-actions-cache/releases
  https://github.com/github/gh-copilot/releases

Checking for outdated extensions...
  Extension gh-copilot is outdated (Current: v0.5.3-beta, Available: v0.13.37)
Do you want to upgrade all outdated extensions? [y/N] y

# Output for the upgrade process is not shown in this example.

Checking to see if gh is up to date...
  gh is up to date!

Activity

  1. changed the title [-]Add `gh extensions outdated` command[/-] [+]Add `gh extensions outdated` command + indicate outdated extensions in `gh extensions list` and similar[/+] on Nov 14, 2023
  2. samcoe commented on Nov 14, 2023

    @samcoe
    Contributor

    @0xdevalias Thanks for the feature request and the impressive alias you created! For some historical context, the extension list command used to include a check for the latest version and output if it was outdated. Unfortunately it was very slow, and #4220 was created. After multiple attempts at speeding it up we decided to pivot to the current approach of having a --dry-run flag for the extension upgrade command. I think now would be a great time to revive this functionality. I think that having a dedicated extension outdated command would alleviate the original concerns of extension list being slow and provide a UX that is used in other package managers. As for the information and structure of the output for this new command, I think that is open for discussion. @williammartin @andyfeller do you have any thoughts on it?

  3. added
    needs-designAn engineering task needs design to proceed
    more-info-neededMore info needed from user/contributor
    gh-extensionrelating to the gh extension command
    and removed on Nov 14, 2023
  4. andyfeller commented on Nov 16, 2023

    @andyfeller
    Contributor

    I think giving users a way to explicitly check for outdated content knowing it'll be slow is 🧑‍🍳 💋.

    My initial thought was this being an optional flag on gh extension list like --outdated that would provide the same experience but add in the additional information in line with the extensions and call out which were outdated. I prefer this because it follows the existing noun + verb flow better for me personally.

  5. samcoe commented on Jan 16, 2024

    @samcoe
    Contributor

    I would be onboard with gh extension list --outdated.

  6. removed their assignment
    on Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIgh-extensionrelating to the gh extension commandneeds-designAn engineering task needs design to proceed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions