-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathstart.bat
More file actions
57 lines (46 loc) · 1.22 KB
/
Copy pathstart.bat
File metadata and controls
57 lines (46 loc) · 1.22 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
@echo off
chcp 65001 >nul
setlocal
pushd "%~dp0"
set "APP=%CD%\aistudio2api.exe"
set "EXIT_CODE=0"
if exist "%APP%" goto ready
where node >nul 2>nul
if errorlevel 1 goto missing_tools
where npm >nul 2>nul
if errorlevel 1 goto missing_tools
where go >nul 2>nul
if errorlevel 1 goto missing_tools
if not exist "web\package-lock.json" goto missing_source
pushd "web"
call npm ci
if errorlevel 1 goto frontend_failed
call npm run build
if errorlevel 1 goto frontend_failed
popd
go build -o "%APP%" ./cmd/aistudio2api
if errorlevel 1 goto failed
:ready
if not defined CAMOUFOX_PATH if not exist "%CD%\runtime\camoufox\camoufox.exe" if not exist "%LOCALAPPDATA%\camoufox\camoufox\Cache\camoufox.exe" echo Camoufox will be downloaded automatically on first launch
"%APP%" %*
set "EXIT_CODE=%ERRORLEVEL%"
goto finished
:frontend_failed
set "EXIT_CODE=%ERRORLEVEL%"
popd
goto finished
:missing_tools
echo Source build requires Node.js, npm, and Go, or a Release executable
set "EXIT_CODE=1"
goto finished
:missing_source
echo Source build requires web\package-lock.json
set "EXIT_CODE=1"
goto finished
:failed
set "EXIT_CODE=%ERRORLEVEL%"
if "%EXIT_CODE%"=="0" set "EXIT_CODE=1"
:finished
popd
if not "%EXIT_CODE%"=="0" pause
exit /b %EXIT_CODE%