diff --git a/package.json b/package.json index 12da593d9c..e172e9bc4b 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,7 @@ "lint": "eslint --ext=ts .", "post:generate": "./scripts/post-gen/global.sh", "generate": "./scripts/multiplexer.sh ./scripts/generate.sh ${0:-all} ${1:-all} && yarn post:generate", - "playground:java": "mvn clean compile exec:java -f playground/java/pom.xml", - "playground:js:analytics": "yarn workspace javascript-playground start:analytics", - "playground:js:personalization": "yarn workspace javascript-playground start:personalization", - "playground:js:recommend": "yarn workspace javascript-playground start:recommend", - "playground:js:search": "yarn workspace javascript-playground start:search", + "playground": "./scripts/multiplexer.sh ./scripts/playground.sh ${0:-javascript} ${1:-search}", "specs:format": "yarn prettier --write specs", "specs:lint": "eslint --ext=yml specs/ .github/" }, diff --git a/scripts/multiplexer.sh b/scripts/multiplexer.sh index 3aefc643b6..fdff747776 100755 --- a/scripts/multiplexer.sh +++ b/scripts/multiplexer.sh @@ -19,6 +19,12 @@ CMD=$1 LANGUAGE=$2 CLIENT=$3 +if [[ $CMD == "./scripts/playground.sh" ]] && ([[ $LANGUAGE == "all" ]] || [[ $CLIENT == "all" ]]); then + echo "You cannot use 'all' when running the playground, please specify the language and client" + + exit 1 +fi + LANGUAGES=() CLIENTS=() diff --git a/scripts/playground.sh b/scripts/playground.sh new file mode 100755 index 0000000000..faee821068 --- /dev/null +++ b/scripts/playground.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Break on non-zero code +set -e + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +# Move to the root (easier to locate other scripts) +cd ${DIR}/.. + +lang=$1 +client=$2 + +# Run the pre generation script if it exists. +run_playground() { + if [[ $lang == 'javascript' ]]; then + yarn workspace javascript-playground start:$client + elif [[ $lang == 'java' ]]; then + mvn clean compile exec:java -f playground/java/pom.xml + fi +} + +run_playground