117 lines
3.2 KiB
Bash
Executable file
117 lines
3.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# update.sh - Unzips a new NavidromePlayer.zip and replaces all project files
|
|
# while preserving your .git history.
|
|
#
|
|
# Usage: Place this script in your NavidromePlayer/ root directory.
|
|
# Drop the new NavidromePlayer.zip in the SAME directory.
|
|
# Ensure your custom 1024.png is in the SAME directory.
|
|
# Then run: ./update.sh
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
ZIP_FILE="NavidromePlayer.zip"
|
|
ICON_FILE="AppIcon.png"
|
|
|
|
# Check zip exists
|
|
if [ ! -f "$ZIP_FILE" ]; then
|
|
echo "❌ $ZIP_FILE not found in $(pwd)"
|
|
echo " Drop the zip file here and run again."
|
|
exit 1
|
|
fi
|
|
|
|
# Check we're in a git repo
|
|
if [ ! -d ".git" ]; then
|
|
echo "❌ No .git directory found. Run this from your NavidromePlayer repo root."
|
|
exit 1
|
|
fi
|
|
|
|
echo "📦 Updating NavidromePlayer from $ZIP_FILE"
|
|
echo ""
|
|
|
|
# Step 1: Auto-commit any uncommitted work
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
echo "💾 Committing your uncommitted changes first..."
|
|
git add -A
|
|
git commit -m "Auto-commit before update ($(date '+%Y-%m-%d %H:%M'))"
|
|
echo ""
|
|
fi
|
|
|
|
# Step 2: Delete everything except .git, scripts, zip, and the custom icon
|
|
echo "🗑 Removing old project files..."
|
|
find . -maxdepth 1 \
|
|
-not -name '.' \
|
|
-not -name '.git' \
|
|
-not -name "$ZIP_FILE" \
|
|
-not -name 'update.sh' \
|
|
-not -name "$ICON_FILE" \
|
|
-exec rm -rf {} \;
|
|
|
|
# Step 3: Unzip
|
|
echo "📂 Extracting $ZIP_FILE..."
|
|
unzip -q -o "$ZIP_FILE"
|
|
|
|
# Move files out of the NavidromePlayer/ wrapper folder
|
|
if [ -d "NavidromePlayer" ]; then
|
|
# Use rsync to handle dotfiles properly
|
|
shopt -s dotglob
|
|
mv NavidromePlayer/* . 2>/dev/null || true
|
|
shopt -u dotglob
|
|
rmdir NavidromePlayer 2>/dev/null || rm -rf NavidromePlayer
|
|
fi
|
|
|
|
# Step 4: Copy custom app icon into the newly extracted targets
|
|
if [ -f "$ICON_FILE" ]; then
|
|
echo "🖼 Applying $ICON_FILE to iOS and watchOS AppIcon sets..."
|
|
|
|
IOS_ICON_DIR="iOS/Resources/Assets.xcassets/AppIcon.appiconset"
|
|
WATCH_ICON_DIR="watchOS/Resources/Assets.xcassets/AppIcon.appiconset"
|
|
|
|
if [ -d "$IOS_ICON_DIR" ]; then
|
|
cp "$ICON_FILE" "$IOS_ICON_DIR/"
|
|
fi
|
|
|
|
if [ -d "$WATCH_ICON_DIR" ]; then
|
|
cp "$ICON_FILE" "$WATCH_ICON_DIR/"
|
|
fi
|
|
else
|
|
echo "⚠️ $ICON_FILE not found in root directory. Skipping icon copy."
|
|
fi
|
|
|
|
# Step 5: Show diff
|
|
echo ""
|
|
echo "📊 Changes:"
|
|
git add -A
|
|
git diff --cached --stat
|
|
echo ""
|
|
|
|
# Step 6: Count changes and prompt for commit message
|
|
CHANGED=$(git diff --cached --numstat | wc -l | tr -d ' ')
|
|
|
|
if [ "$CHANGED" -eq "0" ]; then
|
|
echo "✅ No changes - you're already up to date."
|
|
git reset HEAD . > /dev/null 2>&1
|
|
else
|
|
# Prompt user for a commit message
|
|
echo "📝 Enter a commit message for these $CHANGED changed files."
|
|
read -p " (Or press Enter to use the default message): " CUSTOM_MSG
|
|
echo ""
|
|
|
|
# If the user pressed enter without typing anything, use the default
|
|
if [ -z "$CUSTOM_MSG" ]; then
|
|
CUSTOM_MSG="Update from NavidromePlayer.zip ($(date '+%Y-%m-%d %H:%M'))"
|
|
fi
|
|
|
|
# Commit
|
|
echo "💾 Committing..."
|
|
git commit -m "$CUSTOM_MSG"
|
|
echo ""
|
|
echo "✅ Done! Latest commits:"
|
|
git log --oneline -5
|
|
fi
|
|
|
|
echo ""
|
|
echo "🔨 Don't forget to run: ./generate.sh"
|