-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.bat
More file actions
183 lines (160 loc) · 6.39 KB
/
deploy.bat
File metadata and controls
183 lines (160 loc) · 6.39 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
@echo off
REM ============================================================================
REM deploy.bat - Deploy glyph plugin as an MO2 mod
REM ============================================================================
REM This script:
REM 1. Verifies the build and MO2 paths exist
REM 2. Stages files and creates a zip archive
REM 3. Installs the archive to MO2 mods directory
REM 4. Enables the mod in MO2's modlist.txt
REM ============================================================================
setlocal enabledelayedexpansion
echo ============================================================================
echo GLYPH DEPLOY SCRIPT
echo ============================================================================
echo.
:: Deprecation warning for old env var
if defined GLYPH_DEPLOY_PATH (
echo WARNING: GLYPH_DEPLOY_PATH is deprecated. Use GLYPH_MO2_MODS and
echo GLYPH_MO2_PROFILE instead.
echo.
)
:: MO2 mods directory
if defined GLYPH_MO2_MODS (
set "MO2_MODS=%GLYPH_MO2_MODS%"
) else (
set "MO2_MODS=D:\Nolvus\Instance\MODS\mods"
)
:: MO2 active profile directory
if defined GLYPH_MO2_PROFILE (
set "MO2_PROFILE=%GLYPH_MO2_PROFILE%"
) else (
set "MO2_PROFILE=D:\Nolvus\Instance\MODS\profiles\Nolvus Awakening"
)
:: Read version from vcpkg.json
for /f "usebackq delims=" %%V in (`powershell -NoProfile -Command "(Get-Content 'vcpkg.json' | ConvertFrom-Json).'version-string'"`) do (
set "VERSION=%%V"
)
if not defined VERSION (
echo ERROR: Could not read version from vcpkg.json
exit /b 1
)
set "MOD_NAME=glyph-dev-%VERSION%"
REM ============================================================================
REM STEP 1: Verify Prerequisites
REM ============================================================================
echo [1/4] Verifying prerequisites...
echo ----------------------------------------------------------------------------
if not exist "build\Release\glyph.dll" (
echo ERROR: build\Release\glyph.dll not found
echo Run build.bat first
exit /b 1
)
echo Found: build\Release\glyph.dll
if not exist "%MO2_MODS%" (
echo ERROR: MO2 mods directory not found: %MO2_MODS%
echo Set GLYPH_MO2_MODS to your MO2 mods directory
exit /b 1
)
echo Found: %MO2_MODS%
if not exist "%MO2_PROFILE%\modlist.txt" (
echo ERROR: modlist.txt not found: %MO2_PROFILE%\modlist.txt
echo Set GLYPH_MO2_PROFILE to your active MO2 profile directory
exit /b 1
)
echo Found: %MO2_PROFILE%\modlist.txt
echo.
REM ============================================================================
REM STEP 2: Create Archive
REM ============================================================================
echo [2/4] Creating archive...
echo ----------------------------------------------------------------------------
:: Clean previous staging
if exist "build\staging" rmdir /S /Q "build\staging"
mkdir "build\staging\SKSE\Plugins\glyph"
:: Stage files
copy /Y "build\Release\glyph.dll" "build\staging\SKSE\Plugins\glyph.dll" >nul
copy /Y "skse\plugins\glyph.ini" "build\staging\SKSE\Plugins\glyph.ini" >nul
xcopy /E /I /Y "skse\plugins\glyph" "build\staging\SKSE\Plugins\glyph" >nul
:: Create zip (remove old one first)
if exist "build\glyph-dev.zip" del /Q "build\glyph-dev.zip"
powershell -NoProfile -Command "Compress-Archive -Path 'build\staging\*' -DestinationPath 'build\glyph-dev.zip'"
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to create archive
exit /b %ERRORLEVEL%
)
echo Created: build\glyph-dev.zip
:: Clean staging
rmdir /S /Q "build\staging"
echo.
REM ============================================================================
REM STEP 3: Install to MO2
REM ============================================================================
echo [3/4] Installing to MO2...
echo ----------------------------------------------------------------------------
:: Remove previous installation
if exist "%MO2_MODS%\!MOD_NAME!" (
rmdir /S /Q "%MO2_MODS%\!MOD_NAME!"
echo Removed previous: %MO2_MODS%\!MOD_NAME!
)
:: Extract archive
powershell -NoProfile -Command "Expand-Archive -Path 'build\glyph-dev.zip' -DestinationPath '%MO2_MODS%\!MOD_NAME!'"
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to extract archive
exit /b %ERRORLEVEL%
)
echo Installed: %MO2_MODS%\!MOD_NAME!
echo.
REM ============================================================================
REM STEP 4: Update modlist.txt
REM ============================================================================
echo [4/4] Updating modlist.txt...
echo ----------------------------------------------------------------------------
powershell -NoProfile -Command ^
"$modName = '!MOD_NAME!';" ^
"$modlist = '%MO2_PROFILE%\modlist.txt';" ^
"$lines = [System.IO.File]::ReadAllLines($modlist);" ^
"$found = $false;" ^
"for ($i = 0; $i -lt $lines.Length; $i++) {" ^
" if ($lines[$i] -eq \"+$modName\") {" ^
" $found = $true;" ^
" break;" ^
" }" ^
" if ($lines[$i] -eq \"-$modName\") {" ^
" $lines[$i] = \"+$modName\";" ^
" $found = $true;" ^
" break;" ^
" }" ^
"}" ^
"if (-not $found) {" ^
" $newLines = @($lines[0], \"+$modName\") + $lines[1..($lines.Length-1)];" ^
" $lines = $newLines;" ^
"}" ^
"[System.IO.File]::WriteAllLines($modlist, $lines);"
if %ERRORLEVEL% neq 0 (
echo ERROR: Failed to update modlist.txt
exit /b %ERRORLEVEL%
)
echo Enabled: +!MOD_NAME! in modlist.txt
echo.
REM ============================================================================
REM SUMMARY
REM ============================================================================
echo ============================================================================
echo DEPLOY COMPLETE
echo ============================================================================
echo.
echo Archive: build\glyph-dev.zip
echo Mod: %MO2_MODS%\!MOD_NAME!
echo Profile: %MO2_PROFILE%\modlist.txt
echo.
echo Installed Files:
echo - SKSE\Plugins\glyph.dll
echo - SKSE\Plugins\glyph.ini
echo - SKSE\Plugins\glyph\ (assets)
echo.
echo *** Launch Skyrim through MO2 to test the plugin ***
echo.
echo ============================================================================
endlocal
pause