-
Notifications
You must be signed in to change notification settings - Fork 190
Platform scripts audit #567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
820ed74
Limited the bash script to build cjs
mcottontensor 8ead9b3
Added a cjs build target
mcottontensor 63c8326
Updating bash script to be a little more friendly with builds.
mcottontensor 78953fa
Added rebuild options to bash script
mcottontensor a180038
Updating windows batch script to be inline with bash script.
mcottontensor 9efc923
Cleaned up arguments further for the bash script
mcottontensor 64df9ca
Tweaking build behaviour. Updating args
mcottontensor 1bb21da
Sorting out webpack configs
mcottontensor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,15 +16,18 @@ function print_usage() { | |||||
| --publicip Define public ip address (using default port) for turn server, syntax: --publicip ; it is used for | ||||||
| Default value: Retrieved from 'curl https://api.ipify.org' or if unsuccessful then set to 127.0.0.1. It is the IP address of the server and the default IP address of the TURN server | ||||||
| --turn TURN server to be used, syntax: --turn 127.0.0.1:19303 | ||||||
| Default value: as above, IP address downloaded from https://api.ipify.org; in case if download failure it is set to 127.0.0.1 | ||||||
| Default value: Retrieved from 'curl https://api.ipify.org' or if unsuccessful then set to 127.0.0.1. | ||||||
| --turn-user Sets the turn username when using a turn server. | ||||||
| --turn-pass Sets the turn password when using a turn server. | ||||||
| --start-turn Will launch the turnserver process. | ||||||
| --stun STUN server to be used, syntax: --stun stun.l.google.com:19302 | ||||||
| Default value as above | ||||||
| --build Force a rebuild of the typescript frontend even if it already exists | ||||||
| Default value: stun.l.google.com:19302 | ||||||
| --frontend-dir Sets the output path for the fontend build | ||||||
| --dev Dev mode. (forces build of wilbur and its dependencies) | ||||||
| --build Force a rebuild of the typescript frontend even if it already exists | ||||||
| --rebuild Force a rebuild of everything | ||||||
| --build-libraries Force a rebuild of shared libraries | ||||||
| --build-wilbur Force build of wilbur | ||||||
| --deps Force reinstall of dependencies | ||||||
|
|
||||||
| Other options: stored and passed to the server. All parameters printed once the script values are set. | ||||||
| Command line options might be omitted to run with defaults and it is a good practice to omit specific ones when just starting the TURN or the STUN server alone, not the whole set of scripts. | ||||||
|
|
@@ -42,29 +45,27 @@ function parse_args() { | |||||
| IS_DEBUG=0 | ||||||
| NO_SUDO=0 | ||||||
| VERBOSE=0 | ||||||
| FORCE_BUILD=0 | ||||||
| DEFAULT_STUN=0 | ||||||
| DEFAULT_TURN=0 | ||||||
| BUILD_LIBRARIES=0 | ||||||
| BUILD_FRONTEND=0 | ||||||
| BUILD_WILBUR=0 | ||||||
| if [[ ! -d "${SCRIPT_DIR}/../../dist/" ]]; then | ||||||
| BUILD_WILBUR=1 | ||||||
| fi | ||||||
| INSTALL_DEPS=0 | ||||||
| while(($#)) ; do | ||||||
| case "$1" in | ||||||
| --debug ) IS_DEBUG=1; shift;; | ||||||
| --nosudo ) NO_SUDO=1; shift;; | ||||||
| --verbose ) VERBOSE=1; shift;; | ||||||
| --build ) FORCE_BUILD=1; shift;; | ||||||
| --default-stun ) DEFAULT_STUN=1; shift;; | ||||||
| --default-turn ) DEFAULT_TURN=1; shift;; | ||||||
| --build ) BUILD_FRONTEND=1; shift;; | ||||||
| --rebuild ) BUILD_LIBRARIES=1; BUILD_FRONTEND=1; BUILD_WILBUR=1; shift;; | ||||||
| --stun ) STUN_SERVER="$2"; shift 2;; | ||||||
| --turn ) TURN_SERVER="$2"; shift 2;; | ||||||
| --turn-user ) TURN_USER="$2"; shift 2;; | ||||||
| --turn-pass ) TURN_PASS="$2"; shift 2;; | ||||||
| --start-turn ) START_TURN=1; shift;; | ||||||
| --publicip ) PUBLIC_IP="$2"; shift 2;; | ||||||
| --frontend-dir ) FRONTEND_DIR="$(realpath "$2")"; shift 2;; | ||||||
| --dev ) BUILD_WILBUR=1; shift;; | ||||||
| --build-wilbur ) BUILD_WILBUR=1; shift;; | ||||||
| --build-libraries ) BUILD_LIBRARIES=1; shift;; | ||||||
| --deps ) INSTALL_DEPS=1; shift;; | ||||||
| --help ) print_usage;; | ||||||
| * ) SERVER_ARGS+=" $1"; shift;; | ||||||
| esac | ||||||
|
|
@@ -130,6 +131,7 @@ function check_and_install() { #dep_name #get_version_string #version_min #insta | |||||
| if [ "$?" -lt 2 ]; then | ||||||
| echo "$1 is installed." | ||||||
| is_installed=1 | ||||||
| return 0 | ||||||
| else | ||||||
| echo "Required install of $1 not found installing" | ||||||
| fi | ||||||
|
|
@@ -142,8 +144,11 @@ function check_and_install() { #dep_name #get_version_string #version_min #insta | |||||
|
|
||||||
| if [ $? -ge 1 ]; then | ||||||
| echo "Installation of $1 failed try running 'export VERBOSE=1' then run this script again for more details" | ||||||
| return -1 | ||||||
| fi | ||||||
| fi | ||||||
|
|
||||||
| return 1 | ||||||
| } | ||||||
|
|
||||||
| function setup_node() { | ||||||
|
|
@@ -161,7 +166,7 @@ function setup_node() { | |||||
| popd > /dev/null | ||||||
|
|
||||||
| # navigate to project root | ||||||
| pushd "${SCRIPT_DIR}/../.." > /dev/null | ||||||
| pushd "${SCRIPT_DIR}/../../.." > /dev/null | ||||||
|
|
||||||
| node_version="" | ||||||
| if [[ -f "${SCRIPT_DIR}/node/bin/node" ]]; then | ||||||
|
|
@@ -187,11 +192,35 @@ function setup_node() { | |||||
| && rm node.tar.xz | ||||||
| && mv node-v*-*-* \"${SCRIPT_DIR}/node\"" | ||||||
|
|
||||||
| PATH="${SCRIPT_DIR}/node/bin:$PATH" | ||||||
| if [ $? -eq 1 ] || [ "$INSTALL_DEPS" == "1" ]; then | ||||||
| echo "Installing dependencies..." | ||||||
| PATH="${SCRIPT_DIR}/node/bin:$PATH" | ||||||
| "${NPM}" install | ||||||
| fi | ||||||
|
|
||||||
| popd > /dev/null | ||||||
| } | ||||||
|
|
||||||
| function setup_libraries() { | ||||||
| set -e | ||||||
|
|
||||||
| if [ ! -d "${SCRIPT_DIR}/../../../Common/dist/" ] || [ "$BUILD_LIBRARIES" == "1" ]; then | ||||||
| pushd "${SCRIPT_DIR}/../../../Common" > /dev/null | ||||||
| echo "Building common library." | ||||||
| "${NPM}" run build:cjs | ||||||
| popd > /dev/null | ||||||
| fi | ||||||
|
|
||||||
| if [ ! -d "${SCRIPT_DIR}/../../../Signalling/dist/" ] || [ "$BUILD_LIBRARIES" == "1" ]; then | ||||||
| pushd "${SCRIPT_DIR}/../../../Signalling" > /dev/null | ||||||
| echo "Building signalling library." | ||||||
| "${NPM}" run build:cjs | ||||||
| popd > /dev/null | ||||||
| fi | ||||||
|
|
||||||
| set +e | ||||||
| } | ||||||
|
|
||||||
| function setup_frontend() { | ||||||
| set -e | ||||||
|
|
||||||
|
|
@@ -204,35 +233,25 @@ function setup_frontend() { | |||||
|
|
||||||
| # navigate to root | ||||||
| pushd "${SCRIPT_DIR}/../../.." > /dev/null | ||||||
| OLDPATH=$PATH | ||||||
| export PATH="${SCRIPT_DIR}/node/bin:$PATH" | ||||||
|
|
||||||
| # If player.html doesn't exist, or --build passed as arg, rebuild the frontend | ||||||
| echo Testing ${WEBPACK_OUTPUT_PATH}/player.html | ||||||
| if [ ! -f "${WEBPACK_OUTPUT_PATH}/player.html" ] || [ "$FORCE_BUILD" == "1" ] ; then | ||||||
| echo Testing ${WEBPACK_OUTPUT_PATH} | ||||||
| if [ ! -d "${WEBPACK_OUTPUT_PATH}" ] || [ "$BUILD_FRONTEND" == "1" ] ; then | ||||||
| echo "Building Typescript Frontend." | ||||||
| # Using our bundled NodeJS, build the web frontend files | ||||||
| pushd "${SCRIPT_DIR}/../../../Common" > /dev/null | ||||||
| "${SCRIPT_DIR}/node/bin/npm" install | ||||||
| "${SCRIPT_DIR}/node/bin/npm" run build | ||||||
| popd > /dev/null | ||||||
| pushd "${SCRIPT_DIR}/../../../Frontend/library" > /dev/null | ||||||
| "${SCRIPT_DIR}/node/bin/npm" install | ||||||
| "${SCRIPT_DIR}/node/bin/npm" run build | ||||||
| "${NPM}" run build:cjs | ||||||
| popd > /dev/null | ||||||
| pushd "${SCRIPT_DIR}/../../../Frontend/ui-library" > /dev/null | ||||||
| "${SCRIPT_DIR}/node/bin/npm" install | ||||||
| "${SCRIPT_DIR}/node/bin/npm" run build | ||||||
| "${NPM}" run build:cjs | ||||||
| popd > /dev/null | ||||||
| pushd "${SCRIPT_DIR}/../../../Frontend/implementations/typescript" > /dev/null | ||||||
| "${SCRIPT_DIR}/node/bin/npm" install | ||||||
| "${SCRIPT_DIR}/node/bin/npm" run build | ||||||
| "${NPM}" run build:cjs | ||||||
|
||||||
| "${NPM}" run build:cjs | |
| "${NPM}" run build:dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a funny one actually on closer inspection.
We have the following webpack build configs for the reference frontend:
webpack.common.js- This is the base config used by bothwebpack.dev.jsandwebpack.prod.js- but perhaps confusingly named is not actually configuring webpack to buildcommonjs, but ratherumd(which is correct considering you can't run cjs in the browser and webpack transforms thecjsdeps into browser compatibleumdfor us). One solution to avoid this confusion is to rename this filewebpack.base.js. Of additional note, because thewebpack.common.jsconfiguration does not specify a mode (developmentorproduction) webpack emits some warnings saying falling back to development etc, so this config should probably never be called directly.webpack.dev.js- The dev configuration of theumdbuild (with inline source maps). This is probably the one we want thestart.batscript to use.webpack.prod.js- The prod configuration of theumdbuild that does minification etc so you end up with a smaller bundle.webpack.esmodule.js- A completely different configuration that bundles into anesmmodule. Which could also be interesting for some usecases (like if someone is an all ESM codebase), but probablyumdis the one we and most users will want to use.