Created
March 1, 2025 11:12
-
-
Save zerkalica/b3c2209e8445067cd03e44efb3948ffd to your computer and use it in GitHub Desktop.
mam-build.sh
This file contains 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
#!/bin/sh | |
: "${SRC_PATH:=$(pwd)}" | |
: "${PROJECT_NAME:="mssc-inspection"}" | |
MAM_DIR="$SRC_PATH/.ci/mam" | |
# replace - in project name to / | |
APP_PATH="$(echo "${PROJECT_NAME}" | sed 's/-/\//g')" | |
symlink_list() { | |
for i in "${SRC_PATH}/.ci"/* ; do | |
[ ! -d "${i}" ] && continue | |
[ "${i}" == "mam" ] && continue | |
[ "${i}" == "ci" ] && continue | |
# replace mol-icon to mol/icon, etc | |
name="$(basename "${i}" | sed 's/-/\//g')" | |
echo "${i} ${MAM_DIR}/${name}" | |
done | |
# node require cant find node_modules if script inside symlinked directory | |
# echo "${MAM_DIR}/node_modules ${SRC_PATH}/.ci/node_modules" | |
echo "${MAM_DIR}/node_modules ${SRC_PATH}/node_modules" | |
echo "${SRC_PATH} ${MAM_DIR}/${APP_PATH}" | |
} | |
dirs_link() { | |
symlink_list | sort | while read from to; do | |
echo "link $from -> $to" | |
[ -e "${to}" ] || ln -s "${from}" "${to}" | |
done | |
} | |
dirs_unlink() { | |
symlink_list | sort | while read from to; do | |
echo "unlink $to" | |
[ -L "${to}" ] && unlink "${to}" | |
done | |
} | |
check_mam_app() { | |
if [ ! -e "$SRC_PATH/app/app.view.tree" ] ; then | |
echo "$PROJECT_NAME not a mam application, not found $SRC_PATH/app/app.view.tree" | |
exit 1 | |
fi | |
} | |
check_mam_app \ | |
&& echo "Install npm" \ | |
&& npm install --ignore-scripts \ | |
&& dirs_link \ | |
&& echo "Build app ${MAM_DIR}/${APP_PATH}/app" \ | |
&& cd "${MAM_DIR}" \ | |
&& MAM_PULL_DISABLED=1 npm exec mam "${APP_PATH}/app" || { | |
dirs_unlink | |
exit 1 | |
} | |
dirs_unlink | |
echo "Build in ${SRC_PATH}/app/-" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment