mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
feat: improve version update handling for Windows and Docker
This commit is contained in:
parent
5fe85f7233
commit
62c89f60bf
2 changed files with 34 additions and 25 deletions
|
@ -302,7 +302,7 @@ def touch_file(fname):
|
|||
return False
|
||||
|
||||
|
||||
def check_pip_install_extra(io, module, prompt, pip_install_cmd):
|
||||
def check_pip_install_extra(io, module, prompt, pip_install_cmd, self_update=False):
|
||||
if module:
|
||||
try:
|
||||
__import__(module)
|
||||
|
@ -315,6 +315,11 @@ def check_pip_install_extra(io, module, prompt, pip_install_cmd):
|
|||
if prompt:
|
||||
io.tool_error(prompt)
|
||||
|
||||
if self_update and platform.system() == "Windows":
|
||||
io.tool_output("Run this command to update:")
|
||||
io.tool_output(printable_shell_command(cmd))
|
||||
return
|
||||
|
||||
if not io.confirm_ask("Run pip install?", default="y", subject=printable_shell_command(cmd)):
|
||||
return
|
||||
|
||||
|
|
|
@ -22,20 +22,44 @@ def install_from_main_branch(io):
|
|||
None,
|
||||
"Install the development version of aider from the main branch?",
|
||||
["--upgrade", "git+https://github.com/paul-gauthier/aider.git"],
|
||||
self_update=True,
|
||||
)
|
||||
|
||||
|
||||
def install_upgrade(io):
|
||||
def install_upgrade(io, latest_version=None):
|
||||
"""
|
||||
Install the latest version of aider from PyPI.
|
||||
"""
|
||||
return utils.check_pip_install_extra(
|
||||
|
||||
if latest_version:
|
||||
new_ver_text = f"Newer aider version v{latest_version} is available."
|
||||
else:
|
||||
new_ver_text = f"Install latest version of aider from PyPI?"
|
||||
|
||||
docker_image = os.environ.get("AIDER_DOCKER_IMAGE")
|
||||
if docker_image:
|
||||
text = f"""
|
||||
{new_ver_text} To upgrade, run:
|
||||
|
||||
docker pull {docker_image}
|
||||
"""
|
||||
io.tool_error(text)
|
||||
return True
|
||||
|
||||
success = utils.check_pip_install_extra(
|
||||
io,
|
||||
None,
|
||||
"Install the latest version of aider from PyPI?",
|
||||
new_ver_text,
|
||||
["--upgrade", "aider-chat"],
|
||||
self_update=True,
|
||||
)
|
||||
|
||||
if success:
|
||||
io.tool_output("Re-run aider to use new version.")
|
||||
sys.exit()
|
||||
|
||||
return
|
||||
|
||||
|
||||
def check_version(io, just_check=False, verbose=False):
|
||||
if not just_check and VERSION_CHECK_FNAME.exists():
|
||||
|
@ -85,25 +109,5 @@ def check_version(io, just_check=False, verbose=False):
|
|||
if not is_update_available:
|
||||
return False
|
||||
|
||||
docker_image = os.environ.get("AIDER_DOCKER_IMAGE")
|
||||
if docker_image:
|
||||
text = f"""
|
||||
Newer aider version v{latest_version} is available. To upgrade, run:
|
||||
|
||||
docker pull {docker_image}
|
||||
"""
|
||||
io.tool_error(text)
|
||||
return True
|
||||
|
||||
success = utils.check_pip_install_extra(
|
||||
io,
|
||||
None,
|
||||
f"Newer aider version v{latest_version} is available.",
|
||||
["--upgrade", "aider-chat"],
|
||||
)
|
||||
|
||||
if success:
|
||||
io.tool_output("Re-run aider to use new version.")
|
||||
sys.exit()
|
||||
|
||||
install_upgrade(io, latest_version)
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue