-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathbuild_frontend.bat
More file actions
109 lines (94 loc) · 2.8 KB
/
build_frontend.bat
File metadata and controls
109 lines (94 loc) · 2.8 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
@echo off
setlocal
chcp 65001 >nul 2>&1
rem Build all frontend projects.
set "ROOT_DIR=%~dp0"
if "%ROOT_DIR:~-1%"=="\" set "ROOT_DIR=%ROOT_DIR:~0,-1%"
set "FAIL=0"
rem --- 0. yui-origin Live2D model (unpack from assets/) ---
set "YUI_ARCHIVE=%ROOT_DIR%\assets\yui-origin.tar.gz"
set "YUI_DIR=%ROOT_DIR%\static\yui-origin"
set "YUI_MARKER=%YUI_DIR%\yui-origin.moc3"
if not exist "%YUI_ARCHIVE%" (
echo [build_frontend] yui-origin archive missing: %YUI_ARCHIVE%
exit /b 1
)
set "YUI_NEED_EXTRACT=0"
if not exist "%YUI_MARKER%" (
set "YUI_NEED_EXTRACT=1"
) else (
for /f %%I in ('powershell -NoProfile -Command "if ((Get-Item -LiteralPath $env:YUI_ARCHIVE).LastWriteTime -gt (Get-Item -LiteralPath $env:YUI_MARKER).LastWriteTime) {1} else {0}"') do set "YUI_NEED_EXTRACT=%%I"
)
if "%YUI_NEED_EXTRACT%"=="1" (
echo [build_frontend] unpacking yui-origin...
if exist "%YUI_DIR%" rmdir /s /q "%YUI_DIR%"
tar -xzmf "%YUI_ARCHIVE%" -C "%ROOT_DIR%\static"
if errorlevel 1 (
echo [build_frontend] yui-origin unpack failed
exit /b 1
)
if not exist "%YUI_MARKER%" (
echo [build_frontend] yui-origin marker missing after unpack: %YUI_MARKER%
exit /b 1
)
echo [build_frontend] yui-origin done: %YUI_DIR%
) else (
echo [build_frontend] yui-origin up to date, skip
)
rem --- 1. Plugin Manager (Vue) ---
set "PM_DIR=%ROOT_DIR%\frontend\plugin-manager"
set "PM_DIST=%PM_DIR%\dist"
if not exist "%PM_DIR%" (
echo [build_frontend] plugin-manager dir not found: %PM_DIR%
exit /b 1
)
echo [build_frontend] building plugin-manager...
pushd "%PM_DIR%" >nul
call npm ci
if errorlevel 1 (
popd >nul
echo [build_frontend] npm ci failed for plugin-manager
exit /b 1
)
call npm run build-only
if errorlevel 1 (
popd >nul
echo [build_frontend] build failed for plugin-manager
exit /b 1
)
popd >nul
if not exist "%PM_DIST%\index.html" (
echo [build_frontend] plugin-manager build output missing: %PM_DIST%\index.html
exit /b 1
)
echo [build_frontend] plugin-manager done: %PM_DIST%
rem --- 2. React Neko Chat ---
set "RC_DIR=%ROOT_DIR%\frontend\react-neko-chat"
set "RC_DIST=%ROOT_DIR%\static\react\neko-chat"
if not exist "%RC_DIR%" (
echo [build_frontend] react-neko-chat dir not found: %RC_DIR%
exit /b 1
)
echo [build_frontend] building react-neko-chat...
pushd "%RC_DIR%" >nul
call npm ci
if errorlevel 1 (
popd >nul
echo [build_frontend] npm ci failed for react-neko-chat
exit /b 1
)
call npm run build
if errorlevel 1 (
popd >nul
echo [build_frontend] build failed for react-neko-chat
exit /b 1
)
popd >nul
if not exist "%RC_DIST%\neko-chat-window.iife.js" (
echo [build_frontend] react-neko-chat build output missing: %RC_DIST%\neko-chat-window.iife.js
exit /b 1
)
echo [build_frontend] react-neko-chat done: %RC_DIST%
echo.
echo [build_frontend] all frontend projects built successfully.
exit /b 0