Refactor tools
This commit is contained in:
parent
ace89713d7
commit
1698f3ce87
@ -19,11 +19,12 @@ get_parameter() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Usage: sol_chess_build_web debug|release target_dir [archive_dir]
|
# Usage: build_web debug|release target_dir [archive_dir]
|
||||||
# Build profile location to place files location to place compressed archive
|
# Build profile location to place files location to place compressed archive
|
||||||
sol_chess_build_web() {
|
build_web() {
|
||||||
rootd
|
rootd
|
||||||
|
|
||||||
|
local BINARY_NAME="sol_chess"
|
||||||
local BUILD_PROFILE="debug"
|
local BUILD_PROFILE="debug"
|
||||||
local BUILD_PROFILE_SWITCH=""
|
local BUILD_PROFILE_SWITCH=""
|
||||||
if [ -n "${1}" ]; then
|
if [ -n "${1}" ]; then
|
||||||
@ -49,14 +50,14 @@ sol_chess_build_web() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf ${TARGET_DIR} && mkdir -p ${TARGET_DIR} && mv ./target/wasm32-unknown-unknown/${BUILD_PROFILE}/sol_chess.wasm ${TARGET_DIR}/sol_chess.wasm && cp ./tools/web/index.html ${TARGET_DIR}/index.html
|
rm -rf ${TARGET_DIR} && mkdir -p ${TARGET_DIR} && mv ./target/wasm32-unknown-unknown/${BUILD_PROFILE}/${BINARY_NAME}.wasm ${TARGET_DIR}/${BINARY_NAME}.wasm && cp ./tools/web/index.html ${TARGET_DIR}/index.html
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to assemble the build in ${TARGET_DIR}"
|
echo "Failed to assemble the build in ${TARGET_DIR}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${ARCHIVE_DIR}" ]; then
|
if [ -n "${ARCHIVE_DIR}" ]; then
|
||||||
local TAR_NAME="${ARCHIVE_DIR}/sol_chess.tar.gz"
|
local TAR_NAME="${ARCHIVE_DIR}/${BINARY_NAME}.tar.gz"
|
||||||
set -x
|
set -x
|
||||||
tar -czvf ${TAR_NAME} -C ${TARGET_DIR} . && echo "Created ${TAR_NAME}"
|
tar -czvf ${TAR_NAME} -C ${TARGET_DIR} . && echo "Created ${TAR_NAME}"
|
||||||
set +x
|
set +x
|
||||||
@ -65,12 +66,12 @@ sol_chess_build_web() {
|
|||||||
restored
|
restored
|
||||||
}
|
}
|
||||||
|
|
||||||
sol_chess_web_local() {
|
run_web() {
|
||||||
rootd
|
rootd
|
||||||
|
|
||||||
local TARGET_DIR=$(get_parameter "./target/dist" ${1})
|
local TARGET_DIR=$(get_parameter "./target/dist" ${1})
|
||||||
echo "Building web app in ${TARGET_DIR}"
|
echo "Building web app in ${TARGET_DIR}"
|
||||||
sol_chess_build_web "debug" $TARGET_DIR
|
build_web "debug" $TARGET_DIR
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to build the web app"
|
echo "Failed to build the web app"
|
||||||
return 1
|
return 1
|
||||||
@ -81,7 +82,7 @@ sol_chess_web_local() {
|
|||||||
restored
|
restored
|
||||||
}
|
}
|
||||||
|
|
||||||
sol_chess_dev() {
|
run_dev() {
|
||||||
rootd
|
rootd
|
||||||
|
|
||||||
TESTING=1 cargo run
|
TESTING=1 cargo run
|
||||||
@ -89,11 +90,12 @@ sol_chess_dev() {
|
|||||||
restored
|
restored
|
||||||
}
|
}
|
||||||
|
|
||||||
sol_chess_deploy() {
|
deploy() {
|
||||||
rootd
|
rootd
|
||||||
|
|
||||||
|
local BINARY_NAME="sol_chess"
|
||||||
if [ $# -ne 1 ]; then
|
if [ $# -ne 1 ]; then
|
||||||
echo "Usage: sol_chess_deploy <serve_root>"
|
echo "Usage: deploy <serve_root>"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -103,21 +105,21 @@ sol_chess_deploy() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local serve_root=$1
|
local serve_root=$1
|
||||||
sol_chess_build_web "release" "./target/dist" "./target"
|
build_web "release" "./target/dist" "./target"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to build the web app"
|
echo "Failed to build the web app"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo mv ./target/sol_chess.tar.gz $serve_root/sol_chess.tar.gz && \
|
sudo mv ./target/${BINARY_NAME}.tar.gz $serve_root/${BINARY_NAME}.tar.gz && \
|
||||||
sudo tar -xzvf $serve_root/sol_chess.tar.gz -C $serve_root && \
|
sudo tar -xzvf $serve_root/${BINARY_NAME}.tar.gz -C $serve_root && \
|
||||||
sudo rm $serve_root/sol_chess.tar.gz
|
sudo rm $serve_root/${BINARY_NAME}.tar.gz
|
||||||
echo "Deployment complete"
|
echo "Deployment complete"
|
||||||
|
|
||||||
restored
|
restored
|
||||||
}
|
}
|
||||||
|
|
||||||
sol_chess_clean() {
|
clean() {
|
||||||
rootd
|
rootd
|
||||||
|
|
||||||
rm -rf ./target
|
rm -rf ./target
|
||||||
|
Loading…
x
Reference in New Issue
Block a user