Skip to content

Commit

Permalink
Add MacOS support for typescript model build script (#1457)
Browse files Browse the repository at this point in the history
* add mac os support for build

Signed-off-by: Jordan Dubrick <[email protected]>

* update readlink typo

Signed-off-by: Jordan Dubrick <[email protected]>

---------

Signed-off-by: Jordan Dubrick <[email protected]>
  • Loading branch information
Jdubrick authored Feb 28, 2024
1 parent ee044f7 commit 3263277
Showing 1 changed file with 20 additions and 6 deletions.
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

0 comments on commit 3263277

Please sign in to comment.