#! /bin/bash # Copy all necessary files from the 'dist' directory into dist full # To be executed from the `MapComplete` repo root nvm use if [[ ! -f bookcases.html ]] then npm run generate:layouts fi if [ ! -f "needed_assets.csv" ] then echo "NEEDED ASSETS is missing!" exit 1 fi if [ $? -ne 0 ] then echo "config.json file is invalid, exiting now" tput bel exit 0 fi # We don't bundle studio, test and statistics; as it is not suited for small screens anyway mv studio.html studiohtml mv test.html testhtml mv statistics.html statisticshtml npm run build mv statisticshtml statistics.html mv testhtml test.html mv studiohtml studio.html echo ''' import type { CapacitorConfig } from "@capacitor/cli"; const config: CapacitorConfig = { appId: "org.mapcomplete", appName: "MapComplete", webDir: "dist-full" }; export default config; ''' > capacitor.config.ts # clean distribution directory in android, it contains the older version rm -rf android/app/src/main/assets/public # copy distribution files rm -rf dist-full mkdir dist-full cp dist/*.html dist-full/ cp dist/*.css dist-full/ # cp dist/*.webmanifest dist-full/ # Not needed cp -r dist/css dist-full/ mkdir dist-full/assets mkdir dist-full/assets/generated cp dist/assets/*.js dist-full/assets cp dist/assets/*.svg dist-full/assets cp dist/assets/*.woff dist-full/assets cp dist/assets/*.ttf dist-full/assets cp dist/assets/*.png dist-full/assets cp dist/assets/*.json dist-full/assets cp dist/assets/*.css dist-full/assets cp -r dist/assets/data dist-full/assets/ cp -r dist/assets/docs dist-full/assets/ cp -r dist/assets/fonts dist-full/assets/ cp -r dist/assets/langs dist-full/assets/ # We need the assets for files, we copy them from "needed_assets" # cp -r dist/assets/layers dist-full/assets/ # cp -r dist/assets/themes dist-full/assets/ while IFS= read -r file; do [[ $file == ./assets/* ]] || continue dest="dist-full/${file#./}" mkdir -p "$(dirname "$dest")" cp "$file" "$dest" # echo "Copying $file to $dest" done < needed_assets.csv cp dist/assets/layers/questions/*.svg dist-full/assets/layers/questions/ cp -r dist/assets/png dist-full/assets/ cp -r dist/assets/svg dist-full/assets/ cp -r dist/assets/templates dist-full/assets/ cp -r dist/assets/generated/themes/ dist-full/assets/generated/ # cp dist/assets/*.js.map dist-full/assets/ rm -rf dist-full/assets/data/nsi rm dist-full/assets/layers/*/*.json # The license info file is compiled in rm dist-full/assets/*/*/*.license rm dist-full/**/license_info.json # We need the assets in the layers, but not the actual layer files, which can take quite a bit of space rm dist-full/assets/layers/*/*.json rm dist-full/assets/generated/themes/* # Needed for studio, but it is not included rm -rf dist-full/assets/docs # mkdir dist-full/assets/generated nvm use # assets/icon-only.png will be used as the app icon # See https://capacitorjs.com/docs/guides/splash-screens-and-icons npx capacitor-assets generate npx cap sync npm run clean # Monkey patch version numbers to make everything work cd android sed "s/\.\.\/node_modules\///" -i capacitor.settings.gradle cd capacitor sed "s/'com.android.tools.build:gradle:8.2.1'/'com.android.tools.build:gradle:8.10'/" -i build.gradle tput bel tput bel # Note: tput doesn't work in the runners and may not be the last command, otherwise, it'll fail. echo "All done! Don't forget to click 'gradle sync files' in Android Studio"