Skip to content

Commit 6242c86

Browse files
committed
Add Modern PWA build support
1 parent 808b10f commit 6242c86

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

application/console/views/cron/scripts/upload/default/build.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,23 @@ build_pwa() {
254254
APPDEF_PACKAGE_NAME=""
255255
}
256256

257+
build_modern_pwa() {
258+
echo "Build Modern PWA"
259+
echo "OUTPUT_DIR=${OUTPUT_DIR}"
260+
cd "$PROJECT_DIR" || exit 1
261+
262+
PWA_OUTPUT_DIR=/tmp/output/pwa
263+
mkdir -p "${PWA_OUTPUT_DIR}"
264+
265+
# shellcheck disable=SC2086
266+
$APP_BUILDER_SCRIPT_PATH -load build.appDef -no-save -build-modern-pwa -fp pwa.output="${PWA_OUTPUT_DIR}" ${SCRIPT_OPT}
267+
pushd "${PWA_OUTPUT_DIR}/${APPDEF_PACKAGE_NAME}/build"
268+
zip -r "${OUTPUT_DIR}/pwa.zip" .
269+
popd
270+
VERSION_CODE=""
271+
APPDEF_PACKAGE_NAME=""
272+
}
273+
257274
set_default_asset_package() {
258275
ASSET_FILENAME="${APPDEF_PACKAGE_NAME}.zip"
259276
echo "Updating ipa-app-type=assets"
@@ -554,6 +571,25 @@ prepare_appbuilder_project() {
554571
fi
555572
fi
556573

574+
# If modern-pwa, then use the subdirectory configuration for the rclone publish path if not defined
575+
for target in $TARGETS; do
576+
if [ "$target" = "modern-pwa" ]; then
577+
PUBLISH_TMP=$(mktemp)
578+
INPUT_PUBLISH_PROPERTIES=$PUBLISH_PROPERTIES
579+
if [ -f "${OUTPUT_PUBLISH_PROPERTIES}" ]; then
580+
INPUT_PUBLISH_PROPERTIES=$OUTPUT_PUBLISH_PROPERTIES
581+
fi
582+
if jq -e '.PUBLISH_CLOUD_REMOTE_PATH' "${INPUT_PUBLISH_PROPERTIES}" >/dev/null; then
583+
echo "PUBLISH_CLOUD_REMOTE_PATH exists."
584+
else
585+
echo "PUBLISH_CLOUD_REMOTE_PATH set to PWA SUBDIR."
586+
PWA_SUBDIR=$(xmllint --xpath "/app-definition/pwa-manifest/pwa-sub-directory/text()" build.appDef)
587+
jq -cM ".PUBLISH_CLOUD_REMOTE_PATH += \"${PWA_SUBDIR}\"" "${INPUT_PUBLISH_PROPERTIES}" > "${PUBLISH_TMP}"
588+
cp "${PUBLISH_TMP}" "${OUTPUT_PUBLISH_PROPERTIES}"
589+
fi
590+
fi
591+
done
592+
557593
if [ ! -f "${OUTPUT_PUBLISH_PROPERTIES}" ]; then
558594
# if no Scripture Earth record, then copy straight as normal
559595
cp "${PUBLISH_PROPERTIES}" "${OUTPUT_PUBLISH_PROPERTIES}"
@@ -612,6 +648,7 @@ do
612648
"play-listing") build_play_listing ;;
613649
"html") build_html ;;
614650
"pwa") build_pwa ;;
651+
"modern-pwa") build_modern_pwa ;;
615652
*) build_gradle "$target" ;;
616653
esac
617654
done

application/console/views/cron/scripts/upload/default/publish.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ publish_rclone() {
211211
mkdir "${ARTIFACTS_DIR}/pwa"
212212
unzip "${ARTIFACTS_DIR}/pwa.zip" -d "${ARTIFACTS_DIR}/pwa"
213213
PUBLISH_CLOUD_SOURCE_PATH="${ARTIFACTS_DIR}/pwa"
214-
PUBLISH_FILE="index.html"
214+
PUBLISH_FILE=""
215215
elif [[ -f "${ARTIFACTS_DIR}/html.zip" ]]; then
216216
# html: unzip the files to a directory and push the directory
217217
mkdir "${ARTIFACTS_DIR}/html"
@@ -307,6 +307,10 @@ publish_rclone() {
307307
if [[ "${PUBLISH_SERVER_PATH_ROOT}" != "null" ]]; then
308308
PUBLISH_REMOTE_PATH=${PUBLISH_REMOTE_PATH//$PUBLISH_SERVER_PATH_ROOT\//}
309309
fi
310+
if [[ "${PUBLISH_REMOTE_PATH}" == /* ]]; then
311+
# If PUBLISH_REMOTE_PATH starts with a slash, remove it to avoid double slashes in the URL
312+
PUBLISH_REMOTE_PATH="${PUBLISH_REMOTE_PATH:1}"
313+
fi
310314
PUBLISH_URL="${PUBLISH_BASE_URL}/${PUBLISH_REMOTE_PATH}/${PUBLISH_FILE}"
311315
echo "${PUBLISH_URL}" > "${OUTPUT_DIR}/publish_url.txt"
312316
}

0 commit comments

Comments
 (0)