Updated and simplified build scripts

This commit is contained in:
WolverinDEV 2018-10-28 23:59:15 +01:00
parent 5cbaa747ba
commit b5252faad7
13 changed files with 209 additions and 118 deletions

View file

@ -245,7 +245,7 @@
$flagset = 0b00; $flagset = 0b00;
$environment = ""; $environment = "";
$type = "dev"; $type = "dev";
if($_SERVER["argv"][3] == "dev") { if($_SERVER["argv"][3] == "dev" || $_SERVER["argv"][3] == "development") {
if ($_SERVER["argv"][2] == "web") { if ($_SERVER["argv"][2] == "web") {
$flagset = 0b01; $flagset = 0b01;
$environment = "web/environment/development"; $environment = "web/environment/development";
@ -256,7 +256,7 @@
error_log("Invalid type!"); error_log("Invalid type!");
goto help; goto help;
} }
} else if($_SERVER["argv"][3] == "rel") { } else if($_SERVER["argv"][3] == "rel" || $_SERVER["argv"][3] == "release") {
$type = "rel"; $type = "rel";
if ($_SERVER["argv"][2] == "web") { if ($_SERVER["argv"][2] == "web") {
$flagset = 0b01; $flagset = 0b01;

34
package-lock.json generated
View file

@ -1,6 +1,6 @@
{ {
"name": "client", "name": "client",
"version": "1.0.0", "version": "1.0.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -29,6 +29,7 @@
"version": "2.13.0", "version": "2.13.0",
"resolved": "https://registry.npmjs.org/@types/moment/-/moment-2.13.0.tgz", "resolved": "https://registry.npmjs.org/@types/moment/-/moment-2.13.0.tgz",
"integrity": "sha1-YE69GJvDvDShVIaJQE5hoqSqyJY=", "integrity": "sha1-YE69GJvDvDShVIaJQE5hoqSqyJY=",
"dev": true,
"requires": { "requires": {
"moment": "*" "moment": "*"
} }
@ -943,12 +944,14 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -963,17 +966,20 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -1090,7 +1096,8 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -1102,6 +1109,7 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -1116,6 +1124,7 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -1123,12 +1132,14 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -1147,6 +1158,7 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -1227,7 +1239,8 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -1239,6 +1252,7 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -1360,6 +1374,7 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -1961,7 +1976,8 @@
"moment": { "moment": {
"version": "2.22.2", "version": "2.22.2",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz",
"integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=",
"dev": true
}, },
"ms": { "ms": {
"version": "2.1.1", "version": "2.1.1",

View file

@ -6,15 +6,13 @@
"directories": {}, "directories": {},
"scripts": { "scripts": {
"compile-sass": "sass --update .:.", "compile-sass": "sass --update .:.",
"build-worker": "tsc -p shared/js/workers/tsconfig_worker_codec.json", "build-worker": "tsc -p shared/js/workers/tsconfig_worker_codec.json"
"build-web-app": "tsc -p tsconfig/tsconfig_web_app.json",
"build-web-app-release": "tsc -p tsconfig/tsconfig_web_app_packaged.json",
"build-web-preload": "tsc -p tsconfig/tsconfig_web_preload.json"
}, },
"author": "TeaSpeak (WolverinDEV)", "author": "TeaSpeak (WolverinDEV)",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@types/emscripten": "0.0.31", "@types/emscripten": "0.0.31",
"@types/moment": "^2.13.0",
"@types/jquery": "3.3.5", "@types/jquery": "3.3.5",
"@types/node": "^9.4.6", "@types/node": "^9.4.6",
"@types/websocket": "0.0.38", "@types/websocket": "0.0.38",
@ -22,9 +20,6 @@
"sass": "^1.14.1", "sass": "^1.14.1",
"typescript": "^3.1.1" "typescript": "^3.1.1"
}, },
"dependencies": {
"@types/moment": "^2.13.0"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/TeaSpeak/TeaWeb/TeaWeb.git" "url": "git+https://github.com/TeaSpeak/TeaWeb/TeaWeb.git"
@ -32,5 +27,5 @@
"bugs": { "bugs": {
"url": "https://github.com/TeaSpeak/TeaWeb/issues" "url": "https://github.com/TeaSpeak/TeaWeb/issues"
}, },
"homepage": "https://github.com/TeaSpeak/TeaWeb/TeaWeb#readme" "homepage": "https://www.teaspeak.de"
} }

View file

@ -1,8 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
BASEDIR=$(dirname "$0")
source "${BASEDIR}/resolve_commands.sh"
function generate_link() { function generate_link() {
if [ ! -L $2 ] || [ ${BASH_ARGV[0]} == "force" ]; then if [ ! -L $2 ] || [ "${BASH_ARGV[0]}" == "force" ]; then
if [ -e $2 ]; then if [ -e $2 ] || [ -L $2 ]; then
rm $2 rm $2
fi fi
ln -rs $1 $2 ln -rs $1 $2
@ -17,11 +20,11 @@ cd "$BASEDIR/../"
#Note: For the client we have to use the given file #Note: For the client we have to use the given file
#Web #Web
tsc -p web/tsconfig/tsdeclaration.json execute_tsc -p web/tsconfig/tsdeclaration.json
echo "Generated web declarations" echo "Generated web declarations"
#Shared #Shared
tsc -p shared/tsconfig/tsdeclaration.json execute_tsc -p shared/tsconfig/tsdeclaration.json
echo "Generated shared declarations" echo "Generated shared declarations"
#Now build the merged declaration for the shared project #Now build the merged declaration for the shared project

View file

@ -1,25 +0,0 @@
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
cd "$BASEDIR/../"
npm run "build-web-app"
if [ $? -ne 0 ]; then
echo "Failed to compile app!"
exit 0
fi
npm run "build-web-preload"
if [ $? -ne 0 ]; then
echo "Failed to compile app-preloader!"
exit 0
fi
php files.php generate web dev
if [ $? -ne 0 ]; then
echo "Failed to setup environment!"
exit 0
fi
echo "Development environment successfully generated!"
echo "Note: Do not forget to recompile the typescript files when edited!"

View file

@ -1,31 +0,0 @@
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
cd "$BASEDIR/../"
#Cleanup stuff
rm -r generated &> /dev/null
if [ -e generated ]; then
echo "Failed to remove generated directory!"
exit 1
fi
npm run "build-web-app-release"
if [ $? -ne 0 ]; then
echo "Failed to compile app!"
exit 0
fi
npm run "build-web-preload"
if [ $? -ne 0 ]; then
echo "Failed to compile app-preloader!"
exit 0
fi
php files.php generate web rel
if [ $? -ne 0 ]; then
echo "Failed to setup environment!"
exit 0
fi
echo "Release environment successfully generated!"

View file

@ -1,35 +0,0 @@
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
cd "$BASEDIR/../"
if [ ! -d web/rel-environment ]; then
echo "Please generate first the release environment!"
exit 1
fi
git diff-index HEAD -- . ':!asm/libraries/'
if [ $? -ne 0 ]; then
echo "You're using a private modified build!"
echo "Cant assign git hash!"
NAME="TeaWeb.zip"
else
NAME="TeaWeb-$(git rev-parse --short HEAD).zip"
fi
if [ -e ${NAME} ]; then
echo "Deleting old file"
rm -r ${NAME}
fi
cd web/rel-environment
zip -9 -r ${NAME} *
if [ $? -ne 0 ]; then
echo "Failed to package environment!"
fi
mv ${NAME} ../../
cd ../../
echo "Release package successfully packaged!"
echo "Target file: ${NAME}"

26
scripts/resolve_commands.sh Executable file
View file

@ -0,0 +1,26 @@
#!/usr/bin/env bash
function execute_tsc() {
if [ "$command_tsc" == "" ]; then
if [ "$node_bin" == "" ]; then
node_bin=$(npm bin)
fi
if [ ! -e "${node_bin}/tsc" ]; then
echo "Could not find tsc command"
echo "May type npm install"
exit 1
fi
command_tsc="${node_bin}/tsc"
output=$(${command_tsc} -v)
if [ $? -ne 0 ]; then
echo "Failed to execute a simple tsc command!"
echo "$output"
exit 1
fi
fi
${command_tsc} $@
}

84
scripts/web_build.sh Executable file
View file

@ -0,0 +1,84 @@
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
cd "$BASEDIR/../"
source ./scripts/resolve_commands.sh
if [ "$1" == "development" ] || [ "$1" == "dev" ]; then
source_path="web/environment/development"
type="development"
elif [ "$1" == "release" ] || [ "$1" == "rel" ]; then
source_path="web/environment/release"
type="release"
else
if [ $# -lt 1 ]; then
echo "Invalid argument count!"
else
echo "Invalid option $1"
fi
echo 'Available options are: "development" or "dev", "release" or "rel"'
exit 1
fi
echo "Generating style files"
npm run compile-sass
if [ $? -ne 0 ]; then
echo "Failed to generate style files"
exit 1
fi
echo "Generating web workers"
npm run build-worker
if [ $? -ne 0 ]; then
echo "Failed to build web workers"
exit 1
fi
#Now lets build the declarations
echo "Building declarations"
./scripts/build_declarations.sh
if [ $? -ne 0 ]; then
echo "Failed to generate declarations"
exit 1
fi
if [ "$type" == "release" ]; then #Compile everything for release mode
#Compile the shared source first
echo "Building shared source"
./shared/generate_packed.sh
if [ $? -ne 0 ]; then
echo "Failed to build shared source"
exit 1
fi
#Now compile the web client itself
echo "Building web client"
./web/generate_packed.sh
if [ $? -ne 0 ]; then
echo "Failed to build web client"
exit 1
fi
elif [ "$type" == "development" ]; then
echo "Building shared source"
execute_tsc -p ./shared/tsconfig/tsconfig.json
if [ $? -ne 0 ]; then
echo "Failed to compile shared sources"
exit 1
fi
echo "Building web client source"
execute_tsc -p ./web/tsconfig/tsconfig.json
if [ $? -ne 0 ]; then
echo "Failed to compile web sources"
exit 1
fi
fi
echo "Generating environment"
php files.php generate web ${type}
if [ $? -ne 0 ]; then
echo "Failed to generate environment"
exit 1
fi
echo "Successfully build!"

55
scripts/web_package.sh Executable file
View file

@ -0,0 +1,55 @@
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
cd "$BASEDIR/../"
if [ "$1" == "development" ] || [ "$1" == "dev" ]; then
source_path="web/environment/development"
type="development"
elif [ "$1" == "release" ] || [ "$1" == "rel" ]; then
source_path="web/environment/release"
type="release"
else
if [ $# -lt 1 ]; then
echo "Invalid argument count!"
else
echo "Invalid option $1"
fi
echo 'Available options are: "development" or "dev", "release" or "rel"'
exit 1
fi
if [ ! -d "$source_path" ]; then
echo "Could not find environment! ($source_path)"
echo "Please generate it first!"
exit 1
fi
response=$(git diff-index HEAD -- . ':!asm/libraries/' ':!package-lock.json' ':!vendor/')
if [ "$response" != "" ]; then
echo "You're using a private modified build!"
echo "Cant assign git hash!"
NAME="TeaWeb.zip"
else
NAME="TeaWeb-$(git rev-parse --short HEAD).zip"
fi
if [ -e ${NAME} ]; then
echo "Found old file. Deleting it."
rm -r ${NAME}
fi
current_path=$(pwd)
cd "$source_path"
zip -9 -r ${NAME} *
if [ $? -ne 0 ]; then
echo "Failed to package environment!"
exit 1
fi
cd "$current_path"
mv "${source_path}/${NAME}" .
echo "Release package successfully packaged!"
echo "Target file: ${NAME}"

View file

@ -2,6 +2,7 @@
BASEDIR=$(dirname "$0") BASEDIR=$(dirname "$0")
cd "$BASEDIR" cd "$BASEDIR"
source ../scripts/resolve_commands.sh
#Generate the loader definitions first #Generate the loader definitions first
LOADER_FILE="declarations/exports_loader.d.ts" LOADER_FILE="declarations/exports_loader.d.ts"
@ -11,13 +12,14 @@ if [ -e ${LOADER_FILE} ]; then
echo "Failed to remove loader file!\nThis could be critical later!" echo "Failed to remove loader file!\nThis could be critical later!"
fi fi
fi fi
tsc -p tsconfig/tsdeclaration_loader.json &> /dev/null #We dont want the output! result=$(execute_tsc -p tsconfig/tsdeclaration_loader.json)
if [ ! -e ${LOADER_FILE} ]; then if [ ! -e ${LOADER_FILE} ]; then
echo "Failed to generate definitions" echo "Failed to generate definitions"
echo "$result"
exit 1 exit 1
fi fi
tsc -p tsconfig/tsconfig_packed.json execute_tsc -p tsconfig/tsconfig_packed.json
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to generate packed file!" echo "Failed to generate packed file!"
exit 1 exit 1

View file

@ -2,6 +2,7 @@
BASEDIR=$(dirname "$0") BASEDIR=$(dirname "$0")
cd "$BASEDIR" cd "$BASEDIR"
source ../scripts/resolve_commands.sh
if [ ! -e declarations/imports_shared.d.ts ]; then if [ ! -e declarations/imports_shared.d.ts ]; then
echo "generate the declarations first!" echo "generate the declarations first!"
@ -15,7 +16,7 @@ if [ ! -e ../shared/generated/shared.js ]; then
exit 1 exit 1
fi fi
tsc -p tsconfig/tsconfig_packed.json execute_tsc -p tsconfig/tsconfig_packed.json
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to build file" echo "Failed to build file"
exit 1 exit 1

View file

@ -11,6 +11,6 @@
"outFile": "declarations/exports" "outFile": "declarations/exports"
}, },
"include": [ "include": [
"js/**/*.ts" "../js/**/*.ts"
] ]
} }