Skip to content

CLI upgrade changelog reference#367

Open
gregnazario wants to merge 3 commits intomainfrom
cursor/cli-upgrade-changelog-reference-db04
Open

CLI upgrade changelog reference#367
gregnazario wants to merge 3 commits intomainfrom
cursor/cli-upgrade-changelog-reference-db04

Conversation

@gregnazario
Copy link
Collaborator

Add major version upgrade warnings and a --undo option to the CLI installation scripts.

The --undo option allows users to easily revert to the previous CLI version if an upgrade introduces issues, by backing up the existing binary before an upgrade. The major version warning informs users of potential breaking changes and directs them to the CHANGELOG.


Open in Cursor Open in Web

Added a major version upgrade warning to all three CLI installation
scripts (shell, PowerShell, and Python). When the installed CLI version
has a different major version than the target version, the scripts now
display a warning message and point users to the CHANGELOG in aptos-core:
https://github.com/aptos-labs/aptos-core/blob/main/crates/aptos/CHANGELOG.md

The warning is placed at every upgrade code path in each script:
- Shell: binary install, source install with version, source install latest
- PowerShell: binary install path
- Python: get_version(), run_from_source(), install_from_source()
Before overwriting the CLI binary during an upgrade, the install scripts
now back up the current binary to <binary>.backup (e.g., aptos.backup).
Only one backup copy is kept at a time (overwrites any previous backup).

A new --undo flag restores the backup as the current binary:
  Shell:      curl ... | sh -s -- --undo
  PowerShell: ... --undo
  Python:     python install_cli.py --undo

The undo operation is lightweight - no network calls, package installs,
or builds are needed. After restoring, the script reports the version
that was restored to.

Changes across all three scripts (shell, PowerShell, Python):
- backup_current_binary / Backup-CurrentBinary / _backup_current_binary
- undo_upgrade / Undo-Upgrade / _undo_upgrade
- --undo flag in argument parsing
- Backup called right before the binary is overwritten in both the
  binary download and build-from-source install paths
@cursor
Copy link

cursor bot commented Feb 9, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vercel
Copy link

vercel bot commented Feb 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
aptos-docs Ready Ready Preview, Comment Feb 9, 2026 2:11pm

Request Review

@gregnazario gregnazario marked this pull request as ready for review February 9, 2026 14:03
Copilot AI review requested due to automatic review settings February 9, 2026 14:03
Added comprehensive --help output to all three install scripts:

Shell (install_cli.sh):
- New show_usage() function with full options reference
- -h/--help flag in argument parser
- Improved error message for unknown options to mention --help

PowerShell (install_cli.ps1):
- New Show-Usage function with full options reference
- -h/--help handling in argument parser
- Improved error message for unknown options to mention --help

Python (install_cli.py):
- Enhanced argparse description and added epilog section
- RawDescriptionHelpFormatter for clean formatting of epilog
- Improved all individual help strings for clarity and consistency

All three help outputs document:
- Every available flag with descriptions
- The automatic backup behavior during upgrades
- The major version upgrade warning and CHANGELOG link
- The --undo rollback mechanism
- Usage examples
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the Aptos CLI installation scripts (sh/py/ps1) to improve upgrade safety and user awareness by adding a one-step rollback mechanism and warning users when crossing major versions (with a link to the CLI changelog).

Changes:

  • Add --undo support that restores the previously installed CLI binary from a .backup copy.
  • Backup the currently installed CLI binary before overwriting it during installation.
  • Warn users when installing a CLI version whose major version differs from the currently installed one, and link to the CLI CHANGELOG.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
public/scripts/install_cli.sh Adds major-version warning, backup-before-overwrite, and --undo restore path.
public/scripts/install_cli.py Adds backup/undo support, major-version warning, and CLI arg wiring for --undo.
public/scripts/install_cli.ps1 Adds major-version warning, backup-before-overwrite, and --undo restore path for Windows.
Comments suppressed due to low confidence (4)

public/scripts/install_cli.sh:432

  • Because this warning is only reached inside the non---force branch, a user performing a forced install over an existing CLI won’t see the major-version warning. If the warning is meant to apply to any overwrite, consider detecting the currently installed version and calling warn_major_upgrade even when --force is set.
                ;;
            --generic-linux)
                GENERIC_LINUX=true
                shift
                ;;

public/scripts/install_cli.ps1:67

  • The major-version warning triggers on any difference in major version, including downgrades, but the message always says “major version upgrade”. Consider changing wording to “major version change” or detecting direction so the message is accurate.
function Write-ColorMessage {
    param(
        [string]$Color,
        [string]$Message
    )

public/scripts/install_cli.ps1:225

  • This major-version warning is inside a -not $FORCE guard, so a user doing a forced overwrite won’t see the warning. If the warning is meant to apply whenever an existing CLI is being replaced, consider running the version check and Test-MajorVersionUpgrade even when --force is specified.
                    $VERSION = $args[$i + 1]
                    $i++

public/scripts/install_cli.sh:126

  • The warning triggers on any major-version difference, including downgrades (e.g., v2.x.x -> v1.x.x), but the message always says “major version upgrade”. Consider either (a) changing wording to “major version change” or (b) detecting direction and saying “upgrade” vs “downgrade” accordingly.
    if command_exists curl; then
        retry_command curl -s "$UNIVERSAL_INSTALLER_URL" -o /tmp/install_pkg.sh || die "Failed to download universal installer"
    elif command_exists wget; then
        retry_command wget -q "$UNIVERSAL_INSTALLER_URL" -O /tmp/install_pkg.sh || die "Failed to download universal installer"
    else

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 449 to +453
done

# Handle undo (no packages or network needed)
if [ "$UNDO" = true ]; then
undo_upgrade
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: the major-version warning is skipped when --force is used because this check only runs in the FORCE=false path. If you want the warning to always show on overwrite, move the warning logic out of the FORCE=false guard and handle equality checks separately.

Copilot uses AI. Check for mistakes.
Comment on lines +512 to +516
self._write(
colorize(
"warning",
f"WARNING: This is a major version upgrade (v{current_major}.x.x -> v{new_major}.x.x).",
)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning message says “major version upgrade”, but the check only tests inequality of major components, so it will also fire for major downgrades. Consider adjusting wording to “major version change” or computing direction (upgrade vs downgrade) for a more accurate message.

Copilot uses AI. Check for mistakes.
Comment on lines +575 to 577
if current_version:
self._warn_major_upgrade(current_version, version_to_install)
self._write(f"Installing {colorize('b', version_to_install)}")
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--force returns early from get_version() without determining current_version, which means the new major-version warning will never be shown for forced installs. If the warning is intended whenever an existing CLI is being overwritten, consider still probing the current version (best-effort) and calling _warn_major_upgrade even in the --force path.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants