Fix update functionality and improve documentation
- Fixed update detection in install scripts - Added Git availability checks to update system - Improved error handling for update endpoint - Added detailed Git requirements to README - Added troubleshooting section for update issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Regular → Executable
+36
-2
@@ -38,8 +38,42 @@ function create_directories() {
|
||||
function create_config_files() {
|
||||
echo -e "${YELLOW}Creating configuration files...${NC}"
|
||||
|
||||
# Create initial config.json
|
||||
echo "Creating config.json..."
|
||||
# Check if we're updating an existing installation
|
||||
if [ "$IS_UPDATE" = "true" ] && [ -n "$CONFIG_FILE" ] && [ -f "$CONFIG_FILE" ]; then
|
||||
log "INFO" "Preserving existing configuration file: $CONFIG_FILE"
|
||||
|
||||
# Get version from package.json dynamically
|
||||
VERSION=$(grep -oP '"version": "\K[^"]+' "${SCRIPT_DIR}/package.json" 2>/dev/null || echo "2.0.9")
|
||||
|
||||
# Update only the version number in the config file
|
||||
if [ -f "$CONFIG_FILE" ]; then
|
||||
# Save a backup of the config file
|
||||
BACKUP_FILE="${CONFIG_FILE}.bak.$(date +%Y%m%d%H%M%S)"
|
||||
cp "$CONFIG_FILE" "$BACKUP_FILE"
|
||||
log "INFO" "Backed up config to: $BACKUP_FILE"
|
||||
|
||||
# Update version field only
|
||||
if command -v jq &> /dev/null; then
|
||||
# If jq is available, use it to safely update the version
|
||||
jq ".version = \"$VERSION\"" "$CONFIG_FILE" > "${CONFIG_FILE}.new"
|
||||
if [ $? -eq 0 ]; then
|
||||
mv "${CONFIG_FILE}.new" "$CONFIG_FILE"
|
||||
log "INFO" "Updated config version to: $VERSION"
|
||||
else
|
||||
log "WARN" "Failed to update version with jq, keeping original config unchanged"
|
||||
rm -f "${CONFIG_FILE}.new"
|
||||
fi
|
||||
else
|
||||
log "INFO" "jq not available, keeping original config file"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Return early - no need to create a new config
|
||||
return 0
|
||||
fi
|
||||
|
||||
# For fresh installations, create initial config.json
|
||||
echo "Creating new config.json..."
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
|
||||
# Get version from package.json dynamically
|
||||
|
||||
Reference in New Issue
Block a user