-
Notifications
You must be signed in to change notification settings - Fork 9
Fix/check for stable release #235
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
Conversation
WalkthroughThe script Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Script
participant NPM
User->>Script: Execute check-release-type.sh
Script->>NPM: Check current version with PACKAGE_VERSION
NPM-->>Script: Return available versions
Script->>Script: Determine release type
Script-->>User: Output release type
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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: 0
🧹 Outside diff range and nitpick comments (1)
scripts/check-release-type.sh (1)
Line range hint
1-19: Add error handling and input validationThe script could benefit from some essential improvements to make it more robust:
#!/usr/bin/env bash +set -eo pipefail # This script checks if we need a stable or next release -PACKAGE_VERSION="$(node -p -e "require('./package.json').version")" -PACKAGE_NAME="$(node -p -e "require('./package.json').name")" +PACKAGE_VERSION="$(node -p -e "require('./package.json').version")" || exit 1 +PACKAGE_NAME="$(node -p -e "require('./package.json').name")" || exit 1 + +# Validate inputs +if [ -z "$PACKAGE_VERSION" ] || [ -z "$PACKAGE_NAME" ]; then + echo "Error: Failed to read package information" >&2 + exit 1 +fi # Check if current version exists in npm -FOUND_VERSION=$(npm view $PACKAGE_NAME versions | grep "'$PACKAGE_VERSION'") +VERSIONS=$(npm view "$PACKAGE_NAME" versions) || { + echo "Error: Failed to fetch versions from npm" >&2 + exit 1 +} +FOUND_VERSION=$(echo "$VERSIONS" | grep -F "$PACKAGE_VERSION")Changes:
- Added
set -eo pipefailfor better error handling- Added validation for package.json values
- Added error handling for npm command
- Improved variable quoting
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
scripts/check-release-type.sh(1 hunks)
🔇 Additional comments (1)
scripts/check-release-type.sh (1)
8-8:
Critical: Version detection may fail due to quote matching
The addition of single quotes around $PACKAGE_VERSION in the grep pattern could cause the script to fail to detect existing versions, as npm's version listing might not include these quotes. This could incorrectly trigger stable releases for versions that already exist.
Let's verify the actual npm view output format:
Suggested fix:
-FOUND_VERSION=$(npm view $PACKAGE_NAME versions | grep "'$PACKAGE_VERSION'")
+FOUND_VERSION=$(npm view $PACKAGE_NAME versions | grep -F "$PACKAGE_VERSION")The fix:
- Removes problematic quotes
- Adds
-Fflag to treat the version as a fixed string - Uses double quotes to properly handle the variable expansion
Fix broken stable release check
grep was finding next releases so script was thinking that there was already a stable release