You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

71 lines
1.8 KiB

#! /bin/bash
# Exit on any error
set -e
# Function to check if a command exists
check_command() {
if ! command -v $1 &> /dev/null; then
echo "Error: $1 is required but not installed."
exit 1
fi
}
# Check required commands
check_command node
check_command npm
mkdir -p ~/.local/share/TimeSafari/timesafari
# Clean up previous builds
echo "Cleaning previous builds..."
rm -rf dist*
# Set environment variables for the build
echo "Setting up environment variables..."
export VITE_PLATFORM=electron
export VITE_PWA_ENABLED=false
export VITE_DISABLE_PWA=true
# Ensure TypeScript is installed
echo "Checking TypeScript installation..."
if [ ! -f "./node_modules/.bin/tsc" ]; then
echo "Installing TypeScript..."
npm install --save-dev typescript@~5.2.2
# Verify installation
if [ ! -f "./node_modules/.bin/tsc" ]; then
echo "TypeScript installation failed!"
exit 1
fi
fi
# Get git hash for versioning
GIT_HASH=$(git log -1 --pretty=format:%h)
# Build web assets
echo "Building web assets..."
VITE_GIT_HASH=$GIT_HASH npx vite build --config vite.config.app.electron.mts --mode electron
# TypeScript compilation
echo "Running TypeScript compilation..."
if ! ./node_modules/.bin/tsc -p tsconfig.electron.json; then
echo "TypeScript compilation failed!"
exit 1
fi
# Build electron main process
echo "Building electron main process..."
VITE_GIT_HASH=$GIT_HASH npx vite build --config vite.config.electron.mts --mode electron
# Organize files
echo "Organizing build files..."
mkdir -p dist-electron/www
cp -r dist/* dist-electron/www/
mkdir -p dist-electron/resources
cp src/electron/preload.js dist-electron/resources/preload.js
# Build the AppImage
echo "Building AppImage..."
npx electron-builder --linux AppImage
echo "Build completed successfully!"