-
Notifications
You must be signed in to change notification settings - Fork 5
/
create-project.bat
147 lines (124 loc) · 4.01 KB
/
create-project.bat
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
@echo off
echo Checking if SpaceWarp.Template is installed...
for /f "tokens=*" %%i in ('dotnet new --list ^| findstr /i "SpaceWarp"') do set template=%%i
if not defined template (
echo SpaceWarp.Template is not installed.
choice /c yn /m "Do you want to install it?"
echo.
if errorlevel 2 goto end
echo Installing SpaceWarp.Template...
dotnet new install SpaceWarp.Template
goto update
) else (
echo SpaceWarp.Template is installed.
)
echo Checking for updates...
for /f "tokens=*" %%i in ('dotnet new update --check-only ^| findstr /i "SpaceWarp.Template"') do set update=%%i
if defined update (
echo Updates are available for SpaceWarp.Template.
choice /c yn /m "Do you want to update it?"
echo.
if errorlevel 2 goto skipupdate
echo Updating SpaceWarp.Template...
dotnet new install SpaceWarp.Template
goto update
) else (
echo No updates are available for SpaceWarp.Template.
goto skipupdate
)
:update
cls
(
echo @echo off
echo echo Updating the create-project.bat script...
echo timeout /t 1 /nobreak ^>nul
echo curl -s -L -o create-project-temp.bat https://raw.githubusercontent.com/SpaceWarpDev/SpaceWarp.Template/main/create-project.bat
echo if %%errorlevel%% neq 0 ^(
echo echo Failed to download the script.
echo pause
echo ^) else ^(
echo echo The script has been updated to the latest version.
echo echo Restarting the script...
echo move /y create-project-temp.bat create-project.bat ^> NUL
echo cls
echo start "" create-project.bat ^> NUL
echo del /f /q update-create-project.bat ^> NUL
echo ^)
) > update-create-project.bat
echo Starting the update script...
start "" update-create-project.bat
exit /b
:skipupdate
cls
echo This script will create a new SpaceWarp mod project.
echo.
echo Choose the template you want to use:
echo 1. General mod (with example code)
echo 2. General mod with UI
echo 3. Empty mod
echo 4. Library mod
echo.
choice /c 1234 /n /m "Choice [1-4]: "
if %errorlevel% == 0 goto error
if %errorlevel% == 255 goto error
set choice=%errorlevel%
echo.
echo Fill in the following information:
echo (Parameters marked with (*) are required, the rest are optional.)
echo.
:project_name
set /p "ProjectName=(*)Project name (e.g. MyMod): "
if "%ProjectName%" == "" (
echo Project name is required.
goto project_name
)
:mod_name
set /p "ModName=(*)Mod name (e.g. My Mod): "
if "%ModName%" == "" (
echo Mod name is required.
goto mod_name
)
:author
set /p "Author=(*)Authors (e.g. John Doe;Jane Doe): "
if "%Author%" == "" (
echo Authors are required.
goto author
)
set "Description="
set /p "Description=Description (default is empty): "
set "Source="
set /p "Source=Source repository URL (default is empty): "
set "Version=1.0.0"
set /p "Version=Version (default is 1.0.0): "
set "CheckVersion="
set /p "CheckVersion=Version check URL (default is empty): "
if %choice% == 1 goto general
if %choice% == 2 goto ui
if %choice% == 3 goto empty
if %choice% == 4 goto library
:error
echo Invalid choice.
goto end
:general
echo Creating general mod project...
dotnet new spacewarpmod-general -n "%ProjectName%" -M "%ModName%" -A "%Author%" -D "%Description%" -S "%Source%" -V "%Version%" -C "%CheckVersion%"
goto setup
:ui
echo Creating UI mod project...
dotnet new spacewarpmod-ui -n "%ProjectName%" -M "%ModName%" -A "%Author%" -D "%Description%" -S "%Source%" -V "%Version%" -C "%CheckVersion%"
goto setup
:empty
echo Creating empty mod project...
dotnet new spacewarpmod-empty -n "%ProjectName%" -M "%ModName%" -A "%Author%" -D "%Description%" -S "%Source%" -V "%Version%" -C "%CheckVersion%"
goto setup
:library
set /p "LicenseUrl=License URL (default is empty): "
echo Creating library mod project...
dotnet new spacewarpmod-library -n "%ProjectName%" -M "%ModName%" -A "%Author%" -D "%Description%" -S "%Source%" -V "%Version%" -C "%CheckVersion%" -L "%LicenseUrl%"
goto setup
:setup
cd "%ProjectName%"
echo.
echo Running setup script...
call "scripts\setup.bat"
:end