-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_installer_simple.py
More file actions
256 lines (212 loc) Β· 7.69 KB
/
build_installer_simple.py
File metadata and controls
256 lines (212 loc) Β· 7.69 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#!/usr/bin/env python3
"""
FlowGenius Simple Installer Builder
Interactive script to build FlowGenius installers without command-line arguments.
Just run: python build_installer_simple.py
"""
import os
import sys
import subprocess
import json
import time
from pathlib import Path
import platform
def print_header():
"""Print the application header"""
print("\n" + "="*50)
print("π FlowGenius Installer Builder")
print("="*50)
print()
def print_success(message):
"""Print success message"""
print(f"β
{message}")
def print_error(message):
"""Print error message"""
print(f"β {message}")
def print_info(message):
"""Print info message"""
print(f"βΉοΈ {message}")
def check_prerequisites():
"""Check if prerequisites are met"""
print_info("Checking prerequisites...")
# Check Python
print_success(f"Python version: {sys.version.split()[0]}")
# Check Node.js/npm
try:
result = subprocess.run(['npm', '--version'], capture_output=True, text=True, check=True)
print_success(f"npm version: {result.stdout.strip()}")
except (subprocess.CalledProcessError, FileNotFoundError):
print_error("npm not found. Please install Node.js from https://nodejs.org/")
return False
# Check package.json
if not Path("package.json").exists():
print_error("package.json not found. Make sure you're in the FlowGenius directory.")
return False
# Check node_modules
if not Path("node_modules").exists():
print_info("node_modules not found. Installing dependencies...")
if not run_command(['npm', 'install'], "Installing dependencies"):
return False
print_success("All prerequisites met!")
return True
def run_command(command, description):
"""Run a command and return success status"""
print_info(f"Running: {description}")
try:
result = subprocess.run(command, check=True, capture_output=True, shell=True, encoding='utf-8', errors='ignore')
print_success(f"Completed: {description}")
return True
except subprocess.CalledProcessError as e:
print_error(f"Failed: {description}")
if e.stderr:
print(f"Error: {e.stderr}")
return False
def show_menu():
"""Display the main menu"""
print("Select build option:")
print()
print("1. πͺ Windows installer only (recommended)")
print("2. π All platforms")
print("3. π§Ή Clean build + Windows installer")
print("4. π§Ή Clean build + All platforms")
print("5. β Help")
print("6. πͺ Exit")
print()
def clean_build():
"""Clean previous build artifacts"""
print_info("Cleaning previous build artifacts...")
dirs_to_clean = ["out", "dist", ".webpack"]
for dir_name in dirs_to_clean:
dir_path = Path(dir_name)
if dir_path.exists():
import shutil
shutil.rmtree(dir_path)
print_success(f"Removed {dir_name}/")
return True
def build_app():
"""Build the application"""
return run_command(['npm', 'run', 'build'], "Building application")
def create_windows_installer():
"""Create Windows installer"""
return run_command(['npm', 'run', 'make:win'], "Creating Windows installer")
def create_all_installers():
"""Create installers for all platforms"""
success = True
# Windows
if not run_command(['npm', 'run', 'make:win'], "Creating Windows installer"):
success = False
# macOS (may fail on non-Mac systems, that's OK)
print_info("Attempting macOS build (may fail on non-Mac systems)...")
try:
subprocess.run(['npm', 'run', 'make:mac'], check=True, capture_output=True, text=True)
print_success("macOS installer created")
except subprocess.CalledProcessError:
print_info("macOS build skipped (requires macOS)")
# Linux
if not run_command(['npm', 'run', 'make:linux'], "Creating Linux installer"):
success = False
return success
def show_build_results():
"""Show the generated build artifacts"""
out_dir = Path("out")
if out_dir.exists():
print()
print_success("Build completed! Generated files:")
installers = list(out_dir.rglob("*.exe")) + list(out_dir.rglob("*.dmg")) + list(out_dir.rglob("*.AppImage"))
if installers:
for installer in installers:
size_mb = installer.stat().st_size / (1024 * 1024)
print(f" π¦ {installer.name} ({size_mb:.1f} MB)")
print(f" Path: {installer}")
else:
print_info("No installer files found in out/ directory")
print()
print_info(f"All files are in the 'out' directory: {out_dir.absolute()}")
else:
print_error("No 'out' directory found. Build may have failed.")
def show_help():
"""Show help information"""
print()
print("FlowGenius Installer Builder Help")
print("="*35)
print()
print("This script builds installers for FlowGenius.")
print()
print("Build Options:")
print("β’ Windows only: Creates a .exe installer for Windows")
print("β’ All platforms: Creates installers for Windows, macOS, and Linux")
print("β’ Clean build: Removes previous build files first")
print()
print("Requirements:")
print("β’ Python 3.6+")
print("β’ Node.js and npm")
print("β’ Run from FlowGenius root directory")
print()
print("Output files will be in the 'out/' directory.")
print()
def main():
"""Main application loop"""
print_header()
# Check prerequisites
if not check_prerequisites():
print()
input("Press Enter to exit...")
sys.exit(1)
while True:
print()
show_menu()
try:
choice = input("Enter your choice (1-6): ").strip()
except KeyboardInterrupt:
print()
print("Goodbye! π")
sys.exit(0)
start_time = time.time()
success = False
if choice == "1":
print()
print_info("Building Windows installer...")
if build_app() and create_windows_installer():
success = True
elif choice == "2":
print()
print_info("Building for all platforms...")
if build_app() and create_all_installers():
success = True
elif choice == "3":
print()
print_info("Clean build for Windows...")
if clean_build() and build_app() and create_windows_installer():
success = True
elif choice == "4":
print()
print_info("Clean build for all platforms...")
if clean_build() and build_app() and create_all_installers():
success = True
elif choice == "5":
show_help()
continue
elif choice == "6":
print()
print("Goodbye! π")
sys.exit(0)
else:
print_error("Invalid choice. Please enter 1-6.")
continue
# Show results
build_time = time.time() - start_time
print()
print("="*50)
if success:
print_success(f"Build completed in {build_time:.1f} seconds! π")
show_build_results()
else:
print_error("Build failed. Check the errors above.")
print("="*50)
print()
continue_choice = input("Build another? (y/n): ").strip().lower()
if continue_choice not in ['y', 'yes']:
print("Goodbye! π")
break
if __name__ == "__main__":
main()