-
Notifications
You must be signed in to change notification settings - Fork 8
Fetching latest version from the repository and showing an update message #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe installation script now dynamically retrieves the latest release version from the GitHub API when no version is specified, replacing the previous fixed default. The script also enhances user messaging by distinguishing between a fresh installation and an update, based on the presence of the target binary at the install location. Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
install.sh (2)
37-41
: Make the update detection more robust
Using-f
only catches regular files. If the existing binary is a symlink or has different file metadata, the script will still advertise a fresh install. Consider using-x
(executable) or-e
(exists) to more reliably detect an installed CLI.Example:
-if [ -f "$INSTALL_PATH" ]; then +if [ -x "$INSTALL_PATH" ]; then ACTION="update" else ACTION="install" fiOr, to detect any file type:
-if [ -f "$INSTALL_PATH" ]; then +if [ -e "$INSTALL_PATH" ]; then
43-43
: Use the official CLI name in messaging
For consistent branding, refer to the tool as “CodeCrafters CLI” instead of “codecrafters” in the user‐facing message.- echo "This script will automatically $ACTION codecrafters (${VERSION}) for you." + echo "This script will automatically $ACTION the CodeCrafters CLI (${VERSION}) for you."
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
install.sh (2)
11-14
: Enable robust failure detection for the version fetch
Since you’re using pipelines (curl | grep | sed
) underset -eu
, consider addingset -o pipefail
(or switching tobash
with#!/usr/bin/env bash
) so that any intermediate failures (e.g.,grep
not matching) cause the script to exit instead of silently producing an empty or malformed$VERSION
. Example diff:-#!/bin/sh +#!/usr/bin/env bash set -eu +set -o pipefail
56-56
: Capitalize tool name in user messaging
Minor nit: for consistency with branding, consider capitalizing “Codecrafters” (or “Codecrafters CLI”) in the message:-echo "This script will automatically $ACTION codecrafters (${VERSION}) for you." +echo "This script will automatically $ACTION Codecrafters CLI (${VERSION}) for you."
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
install.sh
(2 hunks)
🔇 Additional comments (3)
install.sh (3)
5-9
: Validate presence of curl before API fetch
Good catch adding an early check forcurl
to avoid cryptic failures. This ensures users get an immediate, clear error ifcurl
is missing.
15-19
: Early exit on empty version enhances reliability
The explicit check for an empty$VERSION
after fetching the GitHub tag is a solid way to catch API or parsing errors before proceeding.
50-54
: Correctly differentiate between install and update
Switching the action based on whether$INSTALL_PATH
already exists makes the UX clearer, and the implementation is straightforward and correct.
The title says most of what I have done.
I changed the install script so it fetches the latest version tag directly from GitHub, instead of defaulting to v35, which is now old.
As a bonus, I also changed the script so it says "updating Codecrafters" instead of "installing" if it finds that the INSTALL_DIR is already there.
Just a small little QOL fix, shouldn't conflict with anything you are doing.
Summary by CodeRabbit