Skip to content

Commit

Permalink
Allow installing specific version of CLI with installation script (#770)
Browse files Browse the repository at this point in the history
Co-authored-by: Greg Nazario <[email protected]>
  • Loading branch information
banool and gregnazario authored Jan 18, 2025
1 parent e5a457e commit 17b8e82
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions apps/nextra/public/scripts/install_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,15 @@ def display_post_message_unix(self, version: str) -> None:
)

def get_version(self):
latest_version = self.latest_release_info["tag_name"].split("-v")[-1]
self._write(colorize("info", "Latest CLI release: {}".format(latest_version)))
if self._version:
version_to_install = self._version
self._write(colorize("info", "Installing CLI version: {}".format(version_to_install)))
else:
version_to_install = self.latest_release_info["tag_name"].split("-v")[-1]
self._write(colorize("info", "Latest CLI release: {}".format(version_to_install)))

if self._force:
return latest_version, None
return version_to_install, None

binary_path = self.bin_path
try:
Expand All @@ -433,18 +437,22 @@ def get_version(self):
if (
Version is not None
and current_version
and Version(current_version) >= Version(latest_version)
and Version(current_version) >= Version(version_to_install)
):
self._write("")
self._write(
f'The latest version ({colorize("b", latest_version)}) is already installed.'
f'The latest version ({colorize("b", current_version)}) is already installed.'
)
if Version(version_to_install) < Version(current_version):
self._write(
f"The version you are trying to install ({colorize('b', version_to_install)}) is older than the currently installed version ({colorize('b', current_version)}). Use --force to bypass."
)

return None, current_version
else:
self._write(f"Installing {colorize('b', latest_version)}")
self._write(f"Installing {colorize('b', version_to_install)}")

return latest_version, current_version
return version_to_install, current_version

# Given the OS and CPU architecture, determine the "target" to download.
def get_target(self):
Expand Down Expand Up @@ -537,13 +545,18 @@ def main():
"--bin-dir",
help="If given, the CLI binary will be downloaded here instead",
)
parser.add_argument(
"--cli-version",
help="If given, the CLI version to install",
)

args = parser.parse_args()

installer = Installer(
force=args.force,
accept_all=args.accept_all or not is_interactive(),
bin_dir=args.bin_dir,
version=args.cli_version,
)

try:
Expand Down

0 comments on commit 17b8e82

Please sign in to comment.