mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-02-01 16:08:17 +00:00
build.bat
This commit is contained in:
parent
1fd0327a82
commit
c101f38998
66
scripts/build.bat
Normal file
66
scripts/build.bat
Normal file
@ -0,0 +1,66 @@
|
||||
:: Copyright 2017-2020 The ShadowEditor Authors. All rights reserved.
|
||||
:: Use of this source code is governed by a MIT-style
|
||||
:: license that can be found in the LICENSE file.
|
||||
::
|
||||
:: For more information, please visit: https://github.com/tengge1/ShadowEditor
|
||||
:: You can also visit: https://gitee.com/tengge1/ShadowEditor
|
||||
::
|
||||
:: Build both the server and the web client.
|
||||
|
||||
@echo off
|
||||
|
||||
:: Save current dir.
|
||||
echo "save current work directory"
|
||||
pushd
|
||||
|
||||
:: The ROOT_DIR is the parent directory of the `.bat` file.
|
||||
for %%I in ("%~dp0.") do for %%J in ("%%~dpI.") do set ROOT_DIR=%%~dpnxJ
|
||||
:: The SERVER_DIR is the golang server dir.
|
||||
set SERVER_DIR=%ROOT_DIR%\server
|
||||
:: The WEB_DIR is the web dir.
|
||||
set WEB_DIR=%ROOT_DIR%\web
|
||||
set BUILD_DIR=%ROOT_DIR%\build
|
||||
|
||||
:: Print the dir information.
|
||||
echo "root dir:" %ROOT_DIR%
|
||||
echo "server dir:" %SERVER_DIR%
|
||||
echo "web dir:" %WEB_DIR%
|
||||
|
||||
:: Create build dir if it does not exist.
|
||||
if not exist %BUILD_DIR% (
|
||||
cd %ROOT_DIR%
|
||||
echo "enter" %ROOT_DIR%
|
||||
mkdir %BUILD_DIR%
|
||||
)
|
||||
|
||||
:: Build the golang server.
|
||||
echo "enter" %SERVER_DIR%
|
||||
cd %SERVER_DIR%
|
||||
echo "build server..."
|
||||
go env -w GO111MODULE=on
|
||||
go build -o ../build/ShadowEditor.exe
|
||||
echo "copy config.toml to the build directory"
|
||||
copy .\config.toml ..\build
|
||||
|
||||
:: Copy files to the build folder.
|
||||
echo 'enter' %WEB_DIR%
|
||||
cd %WEB_DIR%
|
||||
echo "copy files..."
|
||||
xcopy /e /q /y %WEB_DIR%\assets %BUILD_DIR%\public\assets\
|
||||
xcopy /e /q /y %WEB_DIR%\locales %BUILD_DIR%\public\locales\
|
||||
copy favicon.ico ..\build\public\favicon.ico
|
||||
copy index.html ..\build\public\index.html
|
||||
copy manifest.json ..\build\public\manifest.json
|
||||
copy sw.js ..\build\public\sw.js
|
||||
copy view.html ..\build\public\view.html
|
||||
|
||||
:: Build the nodejs web client.
|
||||
echo "build web client..."
|
||||
call npm run build
|
||||
|
||||
:: Restore current dir.
|
||||
echo "restore current work directory"
|
||||
popd
|
||||
|
||||
:: Pause to see if there are some errors.
|
||||
pause
|
||||
@ -38,8 +38,11 @@ go install
|
||||
echo "enter" %WEB_DIR%
|
||||
cd %WEB_DIR%
|
||||
echo "run `npm install`"
|
||||
npm install
|
||||
call npm install
|
||||
|
||||
:: Restore current dir.
|
||||
echo "restore current work directory"
|
||||
popd
|
||||
popd
|
||||
|
||||
:: Pause to see if there are some errors.
|
||||
pause
|
||||
Loading…
x
Reference in New Issue
Block a user