From b5252faad7d9316ba52a6fb79db5c7d6c7edd682 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 28 Oct 2018 23:59:15 +0100 Subject: [PATCH] Updated and simplified build scripts --- files.php | 4 +- package-lock.json | 34 +++++++++---- package.json | 11 ++--- scripts/build_declarations.sh | 11 +++-- scripts/build_web.sh | 25 ---------- scripts/build_web_release.sh | 31 ------------ scripts/package_web_release.sh | 35 -------------- scripts/resolve_commands.sh | 26 ++++++++++ scripts/web_build.sh | 84 +++++++++++++++++++++++++++++++++ scripts/web_package.sh | 55 +++++++++++++++++++++ shared/generate_packed.sh | 6 ++- web/generate_packed.sh | 3 +- web/tsconfig/tsdeclaration.json | 2 +- 13 files changed, 209 insertions(+), 118 deletions(-) delete mode 100755 scripts/build_web.sh delete mode 100755 scripts/build_web_release.sh delete mode 100755 scripts/package_web_release.sh create mode 100755 scripts/resolve_commands.sh create mode 100755 scripts/web_build.sh create mode 100755 scripts/web_package.sh diff --git a/files.php b/files.php index 756de6ea..58f26234 100644 --- a/files.php +++ b/files.php @@ -245,7 +245,7 @@ $flagset = 0b00; $environment = ""; $type = "dev"; - if($_SERVER["argv"][3] == "dev") { + if($_SERVER["argv"][3] == "dev" || $_SERVER["argv"][3] == "development") { if ($_SERVER["argv"][2] == "web") { $flagset = 0b01; $environment = "web/environment/development"; @@ -256,7 +256,7 @@ error_log("Invalid type!"); goto help; } - } else if($_SERVER["argv"][3] == "rel") { + } else if($_SERVER["argv"][3] == "rel" || $_SERVER["argv"][3] == "release") { $type = "rel"; if ($_SERVER["argv"][2] == "web") { $flagset = 0b01; diff --git a/package-lock.json b/package-lock.json index 36b27c38..cf1c8e5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "client", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -29,6 +29,7 @@ "version": "2.13.0", "resolved": "https://registry.npmjs.org/@types/moment/-/moment-2.13.0.tgz", "integrity": "sha1-YE69GJvDvDShVIaJQE5hoqSqyJY=", + "dev": true, "requires": { "moment": "*" } @@ -943,12 +944,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -963,17 +966,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -1090,7 +1096,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -1102,6 +1109,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -1116,6 +1124,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1123,12 +1132,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -1147,6 +1158,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -1227,7 +1239,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -1239,6 +1252,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -1360,6 +1374,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -1961,7 +1976,8 @@ "moment": { "version": "2.22.2", "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": { "version": "2.1.1", diff --git a/package.json b/package.json index fd67ad3b..bcde631c 100644 --- a/package.json +++ b/package.json @@ -6,15 +6,13 @@ "directories": {}, "scripts": { "compile-sass": "sass --update .:.", - "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" + "build-worker": "tsc -p shared/js/workers/tsconfig_worker_codec.json" }, "author": "TeaSpeak (WolverinDEV)", "license": "ISC", "devDependencies": { "@types/emscripten": "0.0.31", + "@types/moment": "^2.13.0", "@types/jquery": "3.3.5", "@types/node": "^9.4.6", "@types/websocket": "0.0.38", @@ -22,9 +20,6 @@ "sass": "^1.14.1", "typescript": "^3.1.1" }, - "dependencies": { - "@types/moment": "^2.13.0" - }, "repository": { "type": "git", "url": "git+https://github.com/TeaSpeak/TeaWeb/TeaWeb.git" @@ -32,5 +27,5 @@ "bugs": { "url": "https://github.com/TeaSpeak/TeaWeb/issues" }, - "homepage": "https://github.com/TeaSpeak/TeaWeb/TeaWeb#readme" + "homepage": "https://www.teaspeak.de" } diff --git a/scripts/build_declarations.sh b/scripts/build_declarations.sh index a793ab9c..dd2795bb 100755 --- a/scripts/build_declarations.sh +++ b/scripts/build_declarations.sh @@ -1,8 +1,11 @@ #!/usr/bin/env bash +BASEDIR=$(dirname "$0") +source "${BASEDIR}/resolve_commands.sh" + function generate_link() { - if [ ! -L $2 ] || [ ${BASH_ARGV[0]} == "force" ]; then - if [ -e $2 ]; then + if [ ! -L $2 ] || [ "${BASH_ARGV[0]}" == "force" ]; then + if [ -e $2 ] || [ -L $2 ]; then rm $2 fi ln -rs $1 $2 @@ -17,11 +20,11 @@ cd "$BASEDIR/../" #Note: For the client we have to use the given file #Web -tsc -p web/tsconfig/tsdeclaration.json +execute_tsc -p web/tsconfig/tsdeclaration.json echo "Generated web declarations" #Shared -tsc -p shared/tsconfig/tsdeclaration.json +execute_tsc -p shared/tsconfig/tsdeclaration.json echo "Generated shared declarations" #Now build the merged declaration for the shared project diff --git a/scripts/build_web.sh b/scripts/build_web.sh deleted file mode 100755 index ee37dda5..00000000 --- a/scripts/build_web.sh +++ /dev/null @@ -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!" \ No newline at end of file diff --git a/scripts/build_web_release.sh b/scripts/build_web_release.sh deleted file mode 100755 index 597b9267..00000000 --- a/scripts/build_web_release.sh +++ /dev/null @@ -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!" \ No newline at end of file diff --git a/scripts/package_web_release.sh b/scripts/package_web_release.sh deleted file mode 100755 index f31a98a3..00000000 --- a/scripts/package_web_release.sh +++ /dev/null @@ -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}" \ No newline at end of file diff --git a/scripts/resolve_commands.sh b/scripts/resolve_commands.sh new file mode 100755 index 00000000..0750d0a3 --- /dev/null +++ b/scripts/resolve_commands.sh @@ -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} $@ +} \ No newline at end of file diff --git a/scripts/web_build.sh b/scripts/web_build.sh new file mode 100755 index 00000000..89280f17 --- /dev/null +++ b/scripts/web_build.sh @@ -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!" \ No newline at end of file diff --git a/scripts/web_package.sh b/scripts/web_package.sh new file mode 100755 index 00000000..d34a7822 --- /dev/null +++ b/scripts/web_package.sh @@ -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}" \ No newline at end of file diff --git a/shared/generate_packed.sh b/shared/generate_packed.sh index 380d5059..0e0a9bcc 100755 --- a/shared/generate_packed.sh +++ b/shared/generate_packed.sh @@ -2,6 +2,7 @@ BASEDIR=$(dirname "$0") cd "$BASEDIR" +source ../scripts/resolve_commands.sh #Generate the loader definitions first 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!" 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 echo "Failed to generate definitions" + echo "$result" exit 1 fi -tsc -p tsconfig/tsconfig_packed.json +execute_tsc -p tsconfig/tsconfig_packed.json if [ $? -ne 0 ]; then echo "Failed to generate packed file!" exit 1 diff --git a/web/generate_packed.sh b/web/generate_packed.sh index bba98380..982bb616 100755 --- a/web/generate_packed.sh +++ b/web/generate_packed.sh @@ -2,6 +2,7 @@ BASEDIR=$(dirname "$0") cd "$BASEDIR" +source ../scripts/resolve_commands.sh if [ ! -e declarations/imports_shared.d.ts ]; then echo "generate the declarations first!" @@ -15,7 +16,7 @@ if [ ! -e ../shared/generated/shared.js ]; then exit 1 fi -tsc -p tsconfig/tsconfig_packed.json +execute_tsc -p tsconfig/tsconfig_packed.json if [ $? -ne 0 ]; then echo "Failed to build file" exit 1 diff --git a/web/tsconfig/tsdeclaration.json b/web/tsconfig/tsdeclaration.json index d6f8d093..db04a6f1 100644 --- a/web/tsconfig/tsdeclaration.json +++ b/web/tsconfig/tsdeclaration.json @@ -11,6 +11,6 @@ "outFile": "declarations/exports" }, "include": [ - "js/**/*.ts" + "../js/**/*.ts" ] } \ No newline at end of file