| 
									
										
										
										
											2024-11-12 12:34:20 +01:00
										 |  |  | #! /bin/bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Copy all necessary files from the 'dist' directory into dist full | 
					
						
							|  |  |  | # To be executed from the `MapComplete` repo root | 
					
						
							| 
									
										
										
										
											2024-12-19 13:49:14 +01:00
										 |  |  | nvm use | 
					
						
							|  |  |  | if [[ ! -f bookcases.html ]] | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |   npm run generate:layouts | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2025-06-30 14:27:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-12 10:59:08 +02:00
										 |  |  | if [ ! -f "needed_assets.csv" ] | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |     echo "NEEDED ASSETS is missing!" | 
					
						
							|  |  |  |    exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-26 22:39:05 +02:00
										 |  |  | if [ $? -ne 0 ] | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |   echo "config.json file is invalid, exiting now" | 
					
						
							|  |  |  |   tput bel | 
					
						
							|  |  |  |   exit 0 | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2025-07-09 02:04:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-11 21:21:54 +02:00
										 |  |  | # We don't bundle studio, test and statistics; as it is not suited for small screens anyway | 
					
						
							| 
									
										
										
										
											2025-07-09 02:04:41 +02:00
										 |  |  | mv studio.html studiohtml | 
					
						
							| 
									
										
										
										
											2025-07-11 21:21:54 +02:00
										 |  |  | mv test.html testhtml | 
					
						
							|  |  |  | mv statistics.html statisticshtml | 
					
						
							| 
									
										
										
										
											2024-12-19 13:49:14 +01:00
										 |  |  | npm run build | 
					
						
							| 
									
										
										
										
											2025-07-11 21:21:54 +02:00
										 |  |  | mv statisticshtml statistics.html | 
					
						
							|  |  |  | mv testhtml test.html | 
					
						
							| 
									
										
										
										
											2025-07-09 02:04:41 +02:00
										 |  |  | mv studiohtml studio.html | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-12 12:34:20 +01:00
										 |  |  | echo ''' | 
					
						
							|  |  |  | import type { CapacitorConfig } from "@capacitor/cli"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const config: CapacitorConfig = { | 
					
						
							|  |  |  |   appId: "org.mapcomplete", | 
					
						
							|  |  |  |   appName: "MapComplete", | 
					
						
							|  |  |  |   webDir: "dist-full" | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default config; | 
					
						
							|  |  |  | ''' > capacitor.config.ts | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-08 18:56:13 +02:00
										 |  |  | # clean distribution directory in android, it contains the older version | 
					
						
							| 
									
										
										
										
											2025-07-08 18:55:52 +02:00
										 |  |  | rm -rf android/app/src/main/assets/public | 
					
						
							| 
									
										
										
										
											2025-04-26 22:39:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-12 01:53:58 +01:00
										 |  |  | # copy distribution files | 
					
						
							| 
									
										
										
										
											2024-11-12 12:34:20 +01:00
										 |  |  | 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 | 
					
						
							| 
									
										
										
										
											2025-01-21 21:06:50 +01:00
										 |  |  | mkdir dist-full/assets/generated | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-12 12:34:20 +01:00
										 |  |  | 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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-21 21:06:50 +01:00
										 |  |  | 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/ | 
					
						
							| 
									
										
										
										
											2025-07-10 22:18:18 +02:00
										 |  |  | # 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 | 
					
						
							| 
									
										
										
										
											2025-07-09 02:04:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-11 21:21:54 +02:00
										 |  |  | cp dist/assets/layers/questions/*.svg dist-full/assets/layers/questions/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-21 21:06:50 +01:00
										 |  |  | 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/ | 
					
						
							| 
									
										
										
										
											2025-05-03 21:48:24 +02:00
										 |  |  | # cp dist/assets/*.js.map dist-full/assets/ | 
					
						
							| 
									
										
										
										
											2025-04-26 22:39:05 +02:00
										 |  |  | rm -rf dist-full/assets/data/nsi | 
					
						
							| 
									
										
										
										
											2025-05-03 21:48:24 +02:00
										 |  |  | rm dist-full/assets/layers/*/*.json | 
					
						
							| 
									
										
										
										
											2025-07-09 02:04:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | # The license info file is compiled in | 
					
						
							| 
									
										
										
										
											2025-05-03 21:48:24 +02:00
										 |  |  | rm dist-full/assets/*/*/*.license | 
					
						
							| 
									
										
										
										
											2025-07-09 02:04:41 +02:00
										 |  |  | 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 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-26 22:39:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-12 12:34:20 +01:00
										 |  |  | # mkdir dist-full/assets/generated | 
					
						
							| 
									
										
										
										
											2024-12-31 19:55:08 +01:00
										 |  |  | nvm use | 
					
						
							| 
									
										
										
										
											2024-11-12 12:34:20 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | # 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 | 
					
						
							| 
									
										
										
										
											2025-04-26 22:39:05 +02:00
										 |  |  | npm run clean | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-26 03:13:12 +02:00
										 |  |  | # Monkey patch version numbers to make everything work | 
					
						
							|  |  |  | cd android | 
					
						
							| 
									
										
										
										
											2025-07-07 01:28:40 +02:00
										 |  |  | sed "s/\.\.\/node_modules\///" -i capacitor.settings.gradle | 
					
						
							| 
									
										
										
										
											2025-06-26 03:13:12 +02:00
										 |  |  | cd capacitor | 
					
						
							|  |  |  | sed "s/'com.android.tools.build:gradle:8.2.1'/'com.android.tools.build:gradle:8.10'/" -i build.gradle | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-22 18:19:48 +01:00
										 |  |  | tput bel | 
					
						
							| 
									
										
										
										
											2025-05-03 18:06:32 +02:00
										 |  |  | tput bel # Note: tput doesn't work in the runners and may not be the last command, otherwise, it'll fail. | 
					
						
							| 
									
										
										
										
											2025-05-03 16:24:13 +02:00
										 |  |  | echo "All done! Don't forget to click 'gradle sync files' in Android Studio" |