bash spaghetti because flutter expects certain files to be in place not just for the platform we want to build

This commit is contained in:
julian 2024-05-23 18:50:05 -06:00
parent dca3c8face
commit 4b5f1c2bf7
7 changed files with 110 additions and 68 deletions

View file

@ -2,29 +2,21 @@
set -x -e
F0="android/app/build.gradle"
F1="android/app/src/debug/AndroidManifest.xml"
F2="android/app/src/profile/AndroidManifest.xml"
F3="android/app/src/main/AndroidManifest.xml"
F4="android/app/src/main/profile/AndroidManifest.xml"
F5="android/app/src/main/kotlin/com/cypherstack/stackwallet/MainActivity.kt"
TEMPLATES="${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates"
for (( i=0; i<=5; i++ )); do
VAR="F${i}"
VAR="ANDROID_TF_${i}"
FILE="${APP_PROJECT_ROOT_DIR}/${!VAR}"
if [ -f "${FILE}" ]; then
TEMPLATE="${TEMPLATES_DIR}/${!VAR}"
if cmp -s "${TEMPLATE}" "${FILE}"; then
rm "${FILE}"
cp -rp "${TEMPLATE}" "${FILE}"
fi
cp "${TEMPLATES}/${!VAR}" "${FILE}"
done
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${F0}"
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${F1}"
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${F2}"
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${F3}"
sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${F3}"
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${F4}"
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${F5}"
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_0}"
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_1}"
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_2}"
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_3}"
sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_3}"
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_4}"
sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_5}"

View file

@ -2,20 +2,16 @@
set -x -e
F0="ios/Runner/Info.plist"
F1="ios/Runner.xcodeproj/project.pbxproj"
TEMPLATES="${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates"
for (( i=0; i<=1; i++ )); do
VAR="F${i}"
VAR="IOS_TF_${i}"
FILE="${APP_PROJECT_ROOT_DIR}/${!VAR}"
if [ -f "${FILE}" ]; then
TEMPLATE="${TEMPLATES_DIR}/${!VAR}"
if cmp -s "${TEMPLATE}" "${FILE}"; then
rm "${FILE}"
cp -rp "${TEMPLATE}" "${FILE}"
fi
cp "${TEMPLATES}/${!VAR}" "${FILE}"
done
# Configure ios for Duo.
sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${F0}"
sed -i '' "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${F1}"
sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${IOS_TF_0}"
sed -i '' "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${IOS_TF_1}"

View file

@ -2,20 +2,16 @@
set -x -e
F0="linux/CMakeLists.txt"
F1="linux/my_application.cc"
TEMPLATES="${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates"
for (( i=0; i<=1; i++ )); do
VAR="F${i}"
VAR="LINUX_TF_${i}"
FILE="${APP_PROJECT_ROOT_DIR}/${!VAR}"
if [ -f "${FILE}" ]; then
TEMPLATE="${TEMPLATES_DIR}/${!VAR}"
if cmp -s "${TEMPLATE}" "${FILE}"; then
rm "${FILE}"
cp -rp "${TEMPLATE}" "${FILE}"
fi
cp "${TEMPLATES}/${!VAR}" "${FILE}"
done
# Configure Linux for Duo.
sed -i "s/${APP_BASIC_NAME_PLACEHOLDER}/${NEW_BASIC_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${F0}"
sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${F1}"
sed -i "s/${APP_BASIC_NAME_PLACEHOLDER}/${NEW_BASIC_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${LINUX_TF_0}"
sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${LINUX_TF_1}"

View file

@ -2,24 +2,19 @@
set -x -e
F0="macos/Runner.xcodeproj/project.pbxproj"
F1="macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme"
F2="macos/Runner/Configs/AppInfo.xcconfig"
TEMPLATES="${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates"
for (( i=0; i<=2; i++ )); do
VAR="F${i}"
VAR="MAC_TF_${i}"
FILE="${APP_PROJECT_ROOT_DIR}/${!VAR}"
if [ -f "${FILE}" ]; then
TEMPLATE="${TEMPLATES_DIR}/${!VAR}"
if cmp -s "${TEMPLATE}" "${FILE}"; then
rm "${FILE}"
cp -rp "${TEMPLATE}" "${FILE}"
fi
cp "${TEMPLATES}/${!VAR}" "${FILE}"
done
# Configure macOS for Duo.
sed -i '' "s/${APP_ID_PLACEHOLDER_CAMEL}/${NEW_APP_ID_CAMEL}/g" "${APP_PROJECT_ROOT_DIR}/${F0}"
sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${F0}"
sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${F1}"
sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${F2}"
sed -i '' "s/${APP_ID_PLACEHOLDER_SNAKE}/${NEW_APP_ID_SNAKE}/g" "${APP_PROJECT_ROOT_DIR}/${F2}"
sed -i '' "s/${APP_ID_PLACEHOLDER_CAMEL}/${NEW_APP_ID_CAMEL}/g" "${APP_PROJECT_ROOT_DIR}/${MAC_TF_0}"
sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${MAC_TF_0}"
sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${MAC_TF_1}"
sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${MAC_TF_2}"
sed -i '' "s/${APP_ID_PLACEHOLDER_SNAKE}/${NEW_APP_ID_SNAKE}/g" "${APP_PROJECT_ROOT_DIR}/${MAC_TF_2}"

View file

@ -2,22 +2,17 @@
set -x -e
F0="windows/runner/Runner.rc"
F1="windows/runner/main.cpp"
F2="windows/CMakeLists.txt"
TEMPLATES="${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates"
for (( i=0; i<=2; i++ )); do
VAR="F${i}"
VAR="WIN_TF_${i}"
FILE="${APP_PROJECT_ROOT_DIR}/${!VAR}"
if [ -f "${FILE}" ]; then
TEMPLATE="${TEMPLATES_DIR}/${!VAR}"
if cmp -s "${TEMPLATE}" "${FILE}"; then
rm "${FILE}"
cp -rp "${TEMPLATE}" "${FILE}"
fi
cp "${TEMPLATES}/${!VAR}" "${FILE}"
done
# Configure Windows for Duo.
sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${F0}"
sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${F1}"
sed -i "s/${APP_BASIC_NAME_PLACEHOLDER}/${NEW_BASIC_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${F2}"
sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${WIN_TF_0}"
sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${WIN_TF_1}"
sed -i "s/${APP_BASIC_NAME_PLACEHOLDER}/${NEW_BASIC_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${WIN_TF_2}"

View file

@ -0,0 +1,66 @@
#!/usr/bin/env bash
set -x -e
export TEMPLATES_DIR="${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates"
export T_PUBSPEC="${TEMPLATES_DIR}/pubspec.template"
export ACTUAL_PUBSPEC="${APP_PROJECT_ROOT_DIR}/pubspec.yaml"
export ANDROID_TF_0="android/app/build.gradle"
export ANDROID_TF_1="android/app/src/debug/AndroidManifest.xml"
export ANDROID_TF_2="android/app/src/profile/AndroidManifest.xml"
export ANDROID_TF_3="android/app/src/main/AndroidManifest.xml"
export ANDROID_TF_4="android/app/src/main/profile/AndroidManifest.xml"
export ANDROID_TF_5="android/app/src/main/kotlin/com/cypherstack/stackwallet/MainActivity.kt"
export IOS_TF_0="ios/Runner/Info.plist"
export IOS_TF_1="ios/Runner.xcodeproj/project.pbxproj"
export LINUX_TF_0="linux/CMakeLists.txt"
export LINUX_TF_1="linux/my_application.cc"
export MAC_TF_0="macos/Runner.xcodeproj/project.pbxproj"
export MAC_TF_1="macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme"
export MAC_TF_2="macos/Runner/Configs/AppInfo.xcconfig"
export WIN_TF_0="windows/runner/Runner.rc"
export WIN_TF_1="windows/runner/main.cpp"
export WIN_TF_2="windows/CMakeLists.txt"
mkdir -p "${APP_PROJECT_ROOT_DIR}/android/app/src/debug"
mkdir -p "${APP_PROJECT_ROOT_DIR}/android/app/src/profile"
mkdir -p "${APP_PROJECT_ROOT_DIR}/android/app/src/main/profile"
mkdir -p "${APP_PROJECT_ROOT_DIR}/android/app/src/main/kotlin/com/cypherstack/stackwallet"
mkdir -p "${APP_PROJECT_ROOT_DIR}/ios/Runner"
mkdir -p "${APP_PROJECT_ROOT_DIR}/ios/Runner.xcodeproj"
mkdir -p "${APP_PROJECT_ROOT_DIR}/macos/Runner.xcodeproj"
mkdir -p "${APP_PROJECT_ROOT_DIR}/macos/Runner.xcodeproj/xcshareddata/xcschemes"
mkdir -p "${APP_PROJECT_ROOT_DIR}/macos/Runner/Configs"
mkdir -p "${APP_PROJECT_ROOT_DIR}/windows/runner"
TEMPLATE_FILES=(
"${ANDROID_TF_0}"
"${ANDROID_TF_1}"
"${ANDROID_TF_2}"
"${ANDROID_TF_3}"
"${ANDROID_TF_4}"
"${ANDROID_TF_5}"
"${IOS_TF_0}"
"${IOS_TF_1}"
"${LINUX_TF_0}"
"${LINUX_TF_1}"
"${MAC_TF_0}"
"${MAC_TF_1}"
"${MAC_TF_2}"
"${WIN_TF_0}"
"${WIN_TF_1}"
"${WIN_TF_2}"
)
if [ ! -f "${ACTUAL_PUBSPEC}" ]; then
cp "${T_PUBSPEC}" "${ACTUAL_PUBSPEC}"
fi
for TF in "${TEMPLATE_FILES[@]}"; do
FILE="${APP_PROJECT_ROOT_DIR}/${TF}"
if [ ! -f "${FILE}" ]; then
cp -rp "${TEMPLATES_DIR}/${TF}" "${FILE}"
fi
done

View file

@ -69,6 +69,8 @@ fi
confirmDisclaimer
set -x
source "${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates/configure_template_files.sh"
# checks for the correct platform dir and pushes it for later
if printf '%s\0' "${APP_PLATFORMS[@]}" | grep -Fxqz -- "${APP_BUILD_PLATFORM}"; then
pushd "${APP_PROJECT_ROOT_DIR}/scripts/${APP_BUILD_PLATFORM}"
@ -79,10 +81,10 @@ fi
# apply config project wide change changes
if printf '%s\0' "${APP_NAMED_IDS[@]}" | grep -Fxqz -- "${APP_NAMED_ID}"; then
if [ -f "${APP_PROJECT_ROOT_DIR}/pubspec.yaml" ]; then
rm "${APP_PROJECT_ROOT_DIR}/pubspec.yaml"
if cmp -s "${ACTUAL_PUBSPEC}" "${T_PUBSPEC}"; then
rm "${ACTUAL_PUBSPEC}"
cp "${T_PUBSPEC}" "${ACTUAL_PUBSPEC}"
fi
cp "${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates/pubspec.template" "${APP_PROJECT_ROOT_DIR}/pubspec.yaml"
"${APP_PROJECT_ROOT_DIR}/scripts/app_config/shared/update_version.sh" -v "${APP_VERSION_STRING}" -b "${APP_BUILD_NUMBER}"
"${APP_PROJECT_ROOT_DIR}/scripts/app_config/shared/link_assets.sh" "${APP_NAMED_ID}"
# shellcheck disable=SC1090