forked from Tomobobo710/SimpleChatJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-electron.sh
More file actions
76 lines (68 loc) · 2.24 KB
/
Copy pathbuild-electron.sh
File metadata and controls
76 lines (68 loc) · 2.24 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
#!/bin/bash
echo "Building SimpleChatJS Electron App (Clean Pipeline)..."
echo "===================================="
echo ""
# Ensure we're in the right directory
if [ ! -f "package.json" ]; then
echo "Error: package.json not found. Run this script from the SimpleChatJS root directory."
exit 1
fi
# Install main app dependencies first
echo "[1/4] Installing main app dependencies..."
npm install --no-audit --no-fund
if [ $? -ne 0 ]; then
echo "Failed to install main dependencies"
exit 1
fi
# Backup original package.json and use build version
echo "[2/4] Switching to build configuration..."
cp "package.json" "package.json.backup"
if [ ! -f "package-build.json" ]; then
echo "Error: package-build.json not found. This file is required for building."
rm -f "package.json.backup"
exit 1
fi
cp "package-build.json" "package.json"
# Install build dependencies
echo "[3/4] Installing build dependencies and building..."
npm install electron@^28.0.0 electron-builder@^24.9.1 --save-dev --no-audit --no-fund
if [ $? -ne 0 ]; then
echo "Failed to install build dependencies"
mv "package.json.backup" "package.json"
exit 1
fi
# Build the app
rm -rf "dist-electron" 2>/dev/null
export CSC_IDENTITY_AUTO_DISCOVERY=false
npm run build
if [ $? -ne 0 ]; then
echo "Build failed"
mv "package.json.backup" "package.json"
exit 1
fi
# Restore original package.json and clean install
echo "[4/4] Restoring clean development environment..."
mv "package.json.backup" "package.json"
rm -rf "node_modules" 2>/dev/null
npm install --no-audit --no-fund
if [ $? -ne 0 ]; then
echo "Warning: Failed to restore clean dependencies, but build completed"
fi
echo ""
echo "===================================="
echo "BUILD COMPLETE!"
echo "===================================="
echo ""
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Electron app: dist-electron/mac/SimpleChatJS.app"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Electron app: dist-electron/linux-unpacked/SimpleChatJS"
else
echo "Electron app: check dist-electron/ directory"
fi
echo ""
echo "✓ Build completed successfully"
echo "✓ Development environment restored (no Electron deps)"
echo "✓ npm start will work normally"
echo "✓ package-build.json preserved"
echo ""