-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-electron.sh
More file actions
executable file
Ā·200 lines (167 loc) Ā· 4.8 KB
/
build-electron.sh
File metadata and controls
executable file
Ā·200 lines (167 loc) Ā· 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
# Flake Wire Electron Build Script
# This script builds the complete Electron application for distribution
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Build configuration
BUILD_DIR="dist"
CLIENT_BUILD_DIR="client/dist"
CLIENT_BUILD_FALLBACK="client/build"
echo -e "${BLUE}š¬ Flake Wire Electron Build Script${NC}"
echo "=================================="
# Function to print status messages
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Pre-build checks
print_status "Starting pre-build checks..."
# Check Node.js and npm
if ! command_exists node; then
print_error "Node.js is not installed. Please install Node.js first."
exit 1
fi
if ! command_exists npm; then
print_error "npm is not installed. Please install npm first."
exit 1
fi
# Check if required directories exist
if [ ! -d "server" ]; then
print_error "Server directory not found!"
exit 1
fi
if [ ! -d "client" ]; then
print_error "New client interface directory not found!"
exit 1
fi
if [ ! -d "electron" ]; then
print_error "Electron directory not found!"
exit 1
fi
# Check if ffmpeg-static is installed in server
if [ ! -d "server/node_modules/ffmpeg-static" ]; then
print_warning "ffmpeg-static not found. Installing now..."
cd server && npm install ffmpeg-static && cd ..
fi
# Clean previous builds
print_status "Cleaning previous builds..."
rm -rf "$BUILD_DIR"
rm -rf "$CLIENT_BUILD_DIR"
rm -rf "$CLIENT_BUILD_FALLBACK"
# Install dependencies
print_status "Installing dependencies..."
npm install
cd client && npm install && cd ..
cd server && npm install && cd ..
# Build the new client interface
print_status "Building the new client interface..."
cd client
npm run build
if [ ! -d "dist" ]; then
print_error "Client build failed! No dist directory created."
exit 1
fi
print_status "Client build completed successfully!"
cd ..
# Build server (transpile if needed)
print_status "Preparing server files..."
# Server files are already in JavaScript format, no transpilation needed
# Create Electron build configuration
print_status "Preparing Electron build..."
# Set environment variables for build
export NODE_ENV=production
export ELECTRON_TRANSCODE=true
# Determine platform
PLATFORM=$(uname -s)
case $PLATFORM in
Linux*)
TARGET_PLATFORM="linux"
print_status "Building for Linux..."
;;
Darwin*)
TARGET_PLATFORM="mac"
print_status "Building for macOS..."
;;
CYGWIN*|MINGW*|MSYS*)
TARGET_PLATFORM="win"
print_status "Building for Windows..."
;;
*)
print_warning "Unknown platform: $PLATFORM. Building for all platforms..."
TARGET_PLATFORM="all"
;;
esac
# Build Electron app
print_status "Building Electron application..."
if [ "$TARGET_PLATFORM" = "all" ]; then
npm run electron:pack
elif [ "$TARGET_PLATFORM" = "linux" ]; then
npx electron-builder --linux
elif [ "$TARGET_PLATFORM" = "mac" ]; then
npx electron-builder --mac
elif [ "$TARGET_PLATFORM" = "win" ]; then
npx electron-builder --win
else
npm run electron:pack
fi
# Check if build was successful
if [ ! -d "$BUILD_DIR" ]; then
print_error "Electron build failed! No dist directory created."
exit 1
fi
# List build artifacts
print_status "Build completed successfully! š"
echo ""
echo -e "${GREEN}Build artifacts:${NC}"
ls -la "$BUILD_DIR"/
# Get the size of build artifacts
if command_exists du; then
echo ""
print_status "Build sizes:"
du -h "$BUILD_DIR"/* 2>/dev/null || true
fi
# Instructions for running
echo ""
echo -e "${BLUE}š To run the Electron application:${NC}"
echo ""
echo "Development mode:"
echo " npm run electron:dev"
echo ""
echo "Production mode (from built package):"
case $PLATFORM in
Linux*)
echo " ./$BUILD_DIR/Flake-Wire.AppImage"
echo " # or: dpkg -i $BUILD_DIR/flake-wire_*.deb"
;;
Darwin*)
echo " open $BUILD_DIR/Flake-Wire.dmg"
;;
CYGWIN*|MINGW*|MSYS*)
echo " $BUILD_DIR/Flake-Wire-Setup.exe"
;;
*)
echo " Check the $BUILD_DIR directory for your platform's installer"
;;
esac
echo ""
echo -e "${GREEN}ā
Electron build process completed successfully!${NC}"
echo ""
echo -e "${YELLOW}Notes:${NC}"
echo "- The application includes an embedded ffmpeg for MKV support"
echo "- MKV files will be automatically processed for compatibility"
echo "- The built application includes both server and client components"
echo "- No external server setup required for the built application"