-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_photopea.bat
More file actions
152 lines (138 loc) · 4.84 KB
/
Copy pathbuild_photopea.bat
File metadata and controls
152 lines (138 loc) · 4.84 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
@echo off
title Photopea Desktop Builder
setlocal EnableDelayedExpansion
REM ==================================================
REM Fix working directory
REM ==================================================
cd /d "%~dp0"
echo ==========================================
echo Photopea Desktop App Builder
echo ==========================================
echo.
REM ==================================================
REM STEP 1: Check Node.js
REM ==================================================
where node >nul 2>nul
if %errorlevel% neq 0 (
echo Node.js not found. Please install Node.js from https://nodejs.org/
pause
exit /b
)
REM ==================================================
REM STEP 2: Initialize npm project if missing
REM ==================================================
if not exist package.json (
echo Initializing npm project...
call npm init -y
if !errorlevel! neq 0 (
echo Failed to initialize npm project.
pause
exit /b
)
)
REM ==================================================
REM STEP 3: Install Electron
REM ==================================================
echo Installing Electron...
call npm install electron --save-dev
if !errorlevel! neq 0 (
echo Failed to install Electron.
pause
exit /b
)
REM ==================================================
REM STEP 4: Create index.js if missing
REM ==================================================
if not exist index.js (
echo Creating index.js...
(
echo const { app, BrowserWindow } = require^('electron'^);
echo const path = require^('path'^);
echo.
echo function createWindow^(^) {
echo const win = new BrowserWindow^({
echo width: 1280,
echo height: 800,
echo webPreferences: {
echo nodeIntegration: false,
echo contextIsolation: true
echo }
echo }^);
echo win.loadFile^(path.join^(__dirname, 'index.html'^)^);
echo win.setMenuBarVisibility^(false^);
echo }
echo.
echo app.whenReady^(^).then^(createWindow^);
echo.
echo app.on^('window-all-closed', ^(^) =^> {
echo if ^(process.platform !== 'darwin'^) app.quit^(^);
echo }^);
) > index.js
)
REM ==================================================
REM STEP 5: Configure package.json
REM ==================================================
echo Configuring package.json...
node -e "let f=require('fs');let p=JSON.parse(f.readFileSync('package.json'));p.main='index.js';p.scripts={start:'electron .'};f.writeFileSync('package.json',JSON.stringify(p,null,2));"
if !errorlevel! neq 0 (
echo Failed to configure package.json.
pause
exit /b
)
REM ==================================================
REM STEP 6: Ask for icon (optional)
REM ==================================================
echo.
set "ICON_PATH="
set /p ICON_PATH="Enter full path to your icon (.ico) [Press Enter to skip]: "
set "ICON_OPTION="
if defined ICON_PATH (
if not exist "!ICON_PATH!" (
echo Icon not found at: !ICON_PATH!
echo Continuing without custom icon...
) else (
echo Copying icon to project folder...
copy "!ICON_PATH!" "%cd%\icon.ico" >nul
set "ICON_OPTION=--icon=icon.ico"
)
) else (
echo No icon provided. Using default Electron icon.
)
REM ==================================================
REM STEP 7: Install packager and build EXE
REM ==================================================
echo Installing Electron Packager...
call npm install electron-packager --save-dev
if !errorlevel! neq 0 (
echo Failed to install electron-packager.
pause
exit /b
)
echo Building Windows EXE...
if defined ICON_OPTION (
call npx electron-packager . Photopea --platform=win32 --arch=x64 --out=dist --overwrite !ICON_OPTION! --prune=true --asar
) else (
call npx electron-packager . Photopea --platform=win32 --arch=x64 --out=dist --overwrite --prune=true --asar
)
REM ==================================================
REM STEP 8: Launch final message in new window
REM ==================================================
set "BUILD_PATH=%cd%\dist\Photopea-win32-x64\Photopea.exe"
echo.
if exist "!BUILD_PATH!" (
echo ==========================================
echo Build complete!
echo Your EXE is ready at:
echo !BUILD_PATH!
echo ==========================================
echo.
start "" explorer /select,"!BUILD_PATH!"
) else (
echo ==========================================
echo Build failed!
echo Please check the logs above for errors.
echo ==========================================
)
echo.
echo Press any key to exit...
pause >nul