mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-12 06:19:11 +00:00
cd34a2bb2c
Installation Script Improvements: - Add tarball download and extraction functions - Prefer tarballs over git clone for version tag installations - Maintain git clone fallback for reliability and branch installations - Add intelligent CSS/dependency detection to skip builds when present - Fix non-interactive mode to handle fresh installations Release Script Improvements: - Include pre-built CSS and build configuration files - Add production npm dependencies to tarballs - Add verification for essential files in releases - Update instructions to promote automated installation - Ensure compatibility with tarball installation approach Benefits: - Faster installations (no npm install/CSS build required) - More reliable in constrained network environments - Backward compatible with existing workflows - Maintains full functionality for development branches 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
139 lines
5.5 KiB
Bash
Executable File
139 lines
5.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e # Exit immediately if a command exits with a non-zero status.
|
|
|
|
# --- Configuration ---
|
|
# Attempt to get version from package.json
|
|
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
# Suggest a release version by stripping common pre-release suffixes like -dev.X or -alpha.X etc.
|
|
SUGGESTED_RELEASE_VERSION=$(echo "$PACKAGE_VERSION" | sed -E 's/-(dev|alpha|beta|rc|pre)[-.0-9]*$//')
|
|
|
|
# --- User Input for Version ---
|
|
echo "Current version in package.json: $PACKAGE_VERSION"
|
|
read -p "Enter release version (default: $SUGGESTED_RELEASE_VERSION): " USER_VERSION
|
|
RELEASE_VERSION=${USER_VERSION:-$SUGGESTED_RELEASE_VERSION}
|
|
|
|
if [[ -z "$RELEASE_VERSION" ]]; then
|
|
echo "Error: Release version cannot be empty."
|
|
exit 1
|
|
fi
|
|
echo "Creating release for version: v$RELEASE_VERSION"
|
|
|
|
# --- Definitions ---
|
|
APP_NAME="pulse" # Or derive from package.json if preferred
|
|
RELEASE_DIR_NAME="${APP_NAME}-v${RELEASE_VERSION}"
|
|
STAGING_PARENT_DIR="pulse-release-staging" # Temporary parent for the release content
|
|
STAGING_FULL_PATH="$STAGING_PARENT_DIR/$RELEASE_DIR_NAME"
|
|
TARBALL_NAME="${RELEASE_DIR_NAME}.tar.gz"
|
|
|
|
# --- Cleanup Previous Attempts ---
|
|
echo "Cleaning up previous attempts..."
|
|
rm -rf "$STAGING_PARENT_DIR"
|
|
rm -f "$TARBALL_NAME"
|
|
mkdir -p "$STAGING_FULL_PATH"
|
|
|
|
# --- Build Step ---
|
|
echo "Building CSS..."
|
|
npm run build:css
|
|
if [ ! -f "src/index.css" ]; then
|
|
echo "Error: src/index.css not found after build. Aborting."
|
|
exit 1
|
|
fi
|
|
|
|
# --- Copy Application Files ---
|
|
echo "Copying application files to $STAGING_FULL_PATH..."
|
|
|
|
# Server files (excluding tests)
|
|
echo "Copying server files..."
|
|
rsync -av --progress server/ "$STAGING_FULL_PATH/server/" --exclude 'tests/'
|
|
|
|
# Source files (including built CSS, Tailwind config, and public assets)
|
|
echo "Copying source files..."
|
|
mkdir -p "$STAGING_FULL_PATH/src" # Ensure parent directory exists
|
|
rsync -av --progress src/public/ "$STAGING_FULL_PATH/src/public/"
|
|
|
|
# Copy CSS build files and config
|
|
cp src/index.css "$STAGING_FULL_PATH/src/" 2>/dev/null || echo "Warning: src/index.css not found"
|
|
cp src/tailwind.config.js "$STAGING_FULL_PATH/src/" 2>/dev/null || echo "Warning: src/tailwind.config.js not found"
|
|
cp src/postcss.config.js "$STAGING_FULL_PATH/src/" 2>/dev/null || echo "Warning: src/postcss.config.js not found"
|
|
|
|
# Root files
|
|
echo "Copying root files..."
|
|
cp package.json "$STAGING_FULL_PATH/"
|
|
cp package-lock.json "$STAGING_FULL_PATH/"
|
|
cp README.md "$STAGING_FULL_PATH/"
|
|
cp LICENSE "$STAGING_FULL_PATH/"
|
|
cp CHANGELOG.md "$STAGING_FULL_PATH/"
|
|
cp .env.example "$STAGING_FULL_PATH/.env.example" # Essential for user configuration
|
|
|
|
# Scripts (e.g., install-pulse.sh, if intended for end-user)
|
|
if [ -d "scripts" ]; then
|
|
echo "Copying scripts..."
|
|
mkdir -p "$STAGING_FULL_PATH/scripts/"
|
|
if [ -f "scripts/install-pulse.sh" ]; then
|
|
cp scripts/install-pulse.sh "$STAGING_FULL_PATH/scripts/"
|
|
fi
|
|
# Add other scripts if they are part of the release
|
|
fi
|
|
|
|
# Docs
|
|
if [ -d "docs" ]; then
|
|
echo "Copying docs..."
|
|
rsync -av --progress docs/ "$STAGING_FULL_PATH/docs/"
|
|
fi
|
|
|
|
# --- Install Production Dependencies ---
|
|
echo "Installing production dependencies in $STAGING_FULL_PATH..."
|
|
(cd "$STAGING_FULL_PATH" && npm install --omit=dev --ignore-scripts)
|
|
# --ignore-scripts prevents any package's own postinstall scripts from running during this build phase.
|
|
# If your production dependencies have essential postinstall scripts, you might remove --ignore-scripts.
|
|
|
|
# --- Verify Essential Files ---
|
|
echo "Verifying essential files for tarball installation..."
|
|
MISSING_FILES=""
|
|
[ ! -f "$STAGING_FULL_PATH/package.json" ] && MISSING_FILES="$MISSING_FILES package.json"
|
|
[ ! -f "$STAGING_FULL_PATH/.env.example" ] && MISSING_FILES="$MISSING_FILES .env.example"
|
|
[ ! -f "$STAGING_FULL_PATH/server/index.js" ] && MISSING_FILES="$MISSING_FILES server/index.js"
|
|
[ ! -f "$STAGING_FULL_PATH/src/index.css" ] && MISSING_FILES="$MISSING_FILES src/index.css"
|
|
[ ! -d "$STAGING_FULL_PATH/node_modules" ] && MISSING_FILES="$MISSING_FILES node_modules/"
|
|
|
|
if [ -n "$MISSING_FILES" ]; then
|
|
echo "Error: Missing essential files for tarball installation:$MISSING_FILES"
|
|
echo "The install script expects these files to be present in the tarball."
|
|
exit 1
|
|
fi
|
|
echo "✅ All essential files verified for tarball installation."
|
|
|
|
# --- Create Tarball ---
|
|
echo "Creating tarball: $TARBALL_NAME..."
|
|
# Go into the parent of the directory to be tarred to avoid leading paths in tarball
|
|
(cd "$STAGING_PARENT_DIR" && tar -czf "../$TARBALL_NAME" "$RELEASE_DIR_NAME")
|
|
|
|
# --- Cleanup ---
|
|
echo "Cleaning up staging directory ($STAGING_PARENT_DIR)..."
|
|
rm -rf "$STAGING_PARENT_DIR"
|
|
|
|
echo ""
|
|
echo "----------------------------------------------------"
|
|
echo "Release tarball created: $TARBALL_NAME"
|
|
echo "----------------------------------------------------"
|
|
echo "📦 This tarball includes:"
|
|
echo " ✅ Pre-built CSS assets"
|
|
echo " ✅ Production npm dependencies"
|
|
echo " ✅ All server and client files"
|
|
echo " ✅ Installation scripts"
|
|
echo ""
|
|
echo "🚀 Installation options:"
|
|
echo "1. RECOMMENDED: Use the install script (faster, automated):"
|
|
echo " curl -sLO https://raw.githubusercontent.com/rcourtman/Pulse/main/scripts/install-pulse.sh"
|
|
echo " chmod +x install-pulse.sh"
|
|
echo " sudo ./install-pulse.sh"
|
|
echo " (The script will automatically use this tarball for faster installation)"
|
|
echo ""
|
|
echo "2. Manual installation:"
|
|
echo " - Copy $TARBALL_NAME to target server"
|
|
echo " - Extract: tar -xzf $TARBALL_NAME"
|
|
echo " - Navigate: cd $RELEASE_DIR_NAME"
|
|
echo " - Configure: cp .env.example .env && edit .env"
|
|
echo " - Start: npm start"
|
|
echo "----------------------------------------------------"
|