forked from GShenLin/AgentPark
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.bat
More file actions
68 lines (61 loc) · 1.91 KB
/
Copy pathpackage.bat
File metadata and controls
68 lines (61 loc) · 1.91 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
@echo off
setlocal
cd /d "%~dp0"
set PYTHONHOME=
set PYTHONPATH=
set "PYTHON_EXE=%LocalAppData%\Programs\Python\Python314\python.exe"
if not exist "%PYTHON_EXE%" set "PYTHON_EXE=python"
echo [INFO] Building WebUI...
pushd webui
if not exist "node_modules" (
call npm.cmd install
if errorlevel 1 goto :fail_webui
)
call npm.cmd run build
if errorlevel 1 goto :fail_webui
popd
echo [INFO] Packaging server executable...
if exist "dist\AITools.exe" del /f /q "dist\AITools.exe" >nul 2>nul
"%PYTHON_EXE%" -m PyInstaller --noconfirm --onefile --name AITools --add-data "webui\dist;webui\dist" --collect-submodules src --collect-submodules fastapi --collect-submodules uvicorn --exclude-module flask src\fast_api.py
if errorlevel 1 goto :fail
if not exist "dist\AITools.exe" goto :fail
call :mirror_dir "config" "dist\config"
if errorlevel 1 goto :fail
call :mirror_dir "functions" "dist\functions"
if errorlevel 1 goto :fail
call :mirror_dir "nodes" "dist\nodes"
if errorlevel 1 goto :fail
call :mirror_dir "skills" "dist\skills"
if errorlevel 1 goto :fail
call :mirror_dir "plugins" "dist\plugins"
if errorlevel 1 goto :fail
call :mirror_dir "docs" "dist\docs"
if errorlevel 1 goto :fail
echo [INFO] Package complete: dist\AITools.exe
echo [INFO] Offline doctor: dist\AITools.exe doctor --json
endlocal
exit /b 0
:mirror_dir
set "SRC=%~1"
set "DST=%~2"
if not exist "%SRC%" (
echo [ERROR] Missing source directory: %SRC%
exit /b 1
)
echo [INFO] Copying %SRC% to %DST%...
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"$src = Resolve-Path '%SRC%';" ^
"$dst = '%DST%';" ^
"if (Test-Path $dst) { Remove-Item -Recurse -Force $dst };" ^
"New-Item -ItemType Directory -Force -Path $dst | Out-Null;" ^
"Copy-Item -Path (Join-Path $src '*') -Destination $dst -Recurse -Force -Exclude '__pycache__','*.pyc'"
if errorlevel 1 (
echo [ERROR] Failed to copy %SRC% to %DST%
exit /b 1
)
exit /b 0
:fail_webui
popd
:fail
endlocal
exit /b 1