Skip to content
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

Add MacOS support for typescript model build script #1457

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions build/typescript-model/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@

set -e

SCRIPT_DIR=`dirname $( readlink -m $( type -p ${0} ))`
SHORT_NAME="$(uname -s)"
if [ "$(uname)" == "Darwin" ]; then
SCRIPT_DIR=`dirname $( realpath $( type -p ${0} ))`
else
SCRIPT_DIR=`dirname $( readlink -m $( type -p ${0} ))`
fi
WORK_DIR=${SCRIPT_DIR}/workdir
echo "[INFO] Using the following folder to store all build files ${SCRIPT_DIR}/workdir"
mkdir -p $WORK_DIR
Expand Down Expand Up @@ -48,11 +53,12 @@ EOF
export OPENAPI_GENERATOR_COMMIT="v6.3.0"
bash $WORK_DIR/gen/openapi/typescript.sh $WORK_DIR/typescript-models $WORK_DIR/config.sh

sed -i 's/\"name\": \".*\"/"name": "@devfile\/api"/g' $WORK_DIR/typescript-models/package.json
sed -i 's/\"description\": \".*\"/"description": "Typescript types for devfile api"/g' $WORK_DIR/typescript-models/package.json
sed -i 's/\"repository\": \".*\"/"repository": "devfile\/api"/g' $WORK_DIR/typescript-models/package.json
sed -i 's/\"license\": \".*\"/"license": "Apache-2.0"/g' $WORK_DIR/typescript-models/package.json
sed -i 's/\"@types\/bluebird\": \".*\"/"@types\/bluebird": "3.5.21"/g' $WORK_DIR/typescript-models/package.json
apply_sed 's/\"name\": \".*\"/"name": "@devfile\/api"/g' $WORK_DIR/typescript-models/package.json
apply_sed 's/\"description\": \".*\"/"description": "Typescript types for devfile api"/g' $WORK_DIR/typescript-models/package.json
apply_sed 's/\"repository\": \".*\"/"repository": "devfile\/api"/g' $WORK_DIR/typescript-models/package.json
apply_sed 's/\"license\": \".*\"/"license": "Apache-2.0"/g' $WORK_DIR/typescript-models/package.json
apply_sed 's/\"@types\/bluebird\": \".*\"/"@types\/bluebird": "3.5.21"/g' $WORK_DIR/typescript-models/package.json

echo "" > $WORK_DIR/typescript-models/.npmignore
echo "[INFO] Generated typescript model which now is available in $WORK_DIR/typescript-models"
}
Expand Down Expand Up @@ -80,6 +86,14 @@ build_typescript_model() {
echo "[INFO] Done."
}

apply_sed(){
if [ "$(uname)" == "Darwin" ]; then
sed -i '' "$@"
else
sed -i "$@"
fi
}

generate_swagger_json
k8s_client_gen
generate_typescript_metadata
Expand Down
Loading