| 
									
										
										
										
											2022-06-28 02:02:21 +02:00
										 |  |  | #! /usr/bin/env bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-08 19:15:56 +01:00
										 |  |  | echo "Starting build" | 
					
						
							| 
									
										
										
										
											2021-12-22 01:53:58 +01:00
										 |  |  | # The build script; we build the application step by step as building everything at once takes too much RAM | 
					
						
							|  |  |  | # Should be run from the repository root | 
					
						
							| 
									
										
										
										
											2022-01-08 19:15:56 +01:00
										 |  |  | # This is the main deployment script | 
					
						
							| 
									
										
										
										
											2021-12-22 01:53:58 +01:00
										 |  |  | rm -rf dist/* | 
					
						
							|  |  |  | rm -rf .cache | 
					
						
							|  |  |  | mkdir dist 2> /dev/null | 
					
						
							| 
									
										
										
										
											2021-12-22 02:10:02 +01:00
										 |  |  | mkdir dist/assets 2> /dev/null | 
					
						
							| 
									
										
										
										
											2023-10-11 03:03:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-22 01:53:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-02 03:17:40 +01:00
										 |  |  | export NODE_OPTIONS="--max-old-space-size=16384" | 
					
						
							| 
									
										
										
										
											2023-02-10 15:02:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-08 22:11:24 +01:00
										 |  |  | # This script ends every line with '&&' to chain everything. A failure will thus stop the build | 
					
						
							| 
									
										
										
										
											2023-12-06 03:08:57 +01:00
										 |  |  | npm run generate:editor-layer-index && | 
					
						
							| 
									
										
										
										
											2023-12-06 12:19:14 +01:00
										 |  |  | npm run prep:layeroverview && | 
					
						
							|  |  |  | npm run generate && # includes a single "refresh:layeroverview". Resetting the files is unnecessary as they are not in there in the first place | 
					
						
							| 
									
										
										
										
											2023-12-06 12:35:17 +01:00
										 |  |  | npm run refresh:layeroverview && # run refresh:layeroverview a second time to propagate all calls | 
					
						
							| 
									
										
										
										
											2023-12-08 18:41:08 +01:00
										 |  |  | npm run refresh:layeroverview && # run refresh:layeroverview a third time to fix some issues with the favourite layer all calls | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-06 12:35:17 +01:00
										 |  |  | npm run generate:layouts | 
					
						
							| 
									
										
										
										
											2021-12-22 23:50:43 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-11 10:55:17 +01:00
										 |  |  | if [ $? -ne 0 ]; then | 
					
						
							| 
									
										
										
										
											2022-01-18 18:12:24 +01:00
										 |  |  |     echo "ERROR - stopping the build" | 
					
						
							| 
									
										
										
										
											2022-01-08 22:11:24 +01:00
										 |  |  |     exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2022-01-08 19:15:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-17 03:37:26 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BRANCH=`git rev-parse --abbrev-ref HEAD` | 
					
						
							|  |  |  | echo "The branch name is $BRANCH" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-29 10:02:17 +02:00
										 |  |  | if [ $BRANCH = "master" ] || [ $BRANCH = "develop" ] | 
					
						
							| 
									
										
										
										
											2023-01-29 17:43:38 +01:00
										 |  |  | then | 
					
						
							|  |  |  |     ASSET_URL="./" | 
					
						
							|  |  |  |     export ASSET_URL | 
					
						
							|  |  |  |     echo "$ASSET_URL" | 
					
						
							|  |  |  | else | 
					
						
							| 
									
										
										
										
											2023-09-27 22:21:35 +02:00
										 |  |  |   # ASSET_URL="$BRANCH" | 
					
						
							|  |  |  |   ASSET_URL="./" | 
					
						
							| 
									
										
										
										
											2023-01-29 17:43:38 +01:00
										 |  |  |   export ASSET_URL | 
					
						
							|  |  |  |   echo "$ASSET_URL" | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-13 15:22:23 +01:00
										 |  |  | # sanity check | 
					
						
							|  |  |  | if [[ -f "bookcases.html" ]] | 
					
						
							|  |  |  | then | 
					
						
							| 
									
										
										
										
											2023-11-13 15:44:32 +01:00
										 |  |  |   echo "Bookcases exists" | 
					
						
							| 
									
										
										
										
											2023-11-13 15:22:23 +01:00
										 |  |  | else | 
					
						
							|  |  |  |   echo "Bookcases.html does not exist - aborting" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-02 03:17:40 +01:00
										 |  |  | export NODE_OPTIONS=--max-old-space-size=16000 | 
					
						
							| 
									
										
										
										
											2023-10-30 13:45:44 +01:00
										 |  |  | which vite | 
					
						
							| 
									
										
										
										
											2023-12-06 02:36:36 +01:00
										 |  |  | vite --version | 
					
						
							|  |  |  | vite build # --sourcemap  | 
					
						
							| 
									
										
										
										
											2021-12-22 01:53:58 +01:00
										 |  |  | # Copy the layer files, as these might contain assets (e.g. svgs) | 
					
						
							|  |  |  | cp -r assets/layers/ dist/assets/layers/ | 
					
						
							|  |  |  | cp -r assets/themes/ dist/assets/themes/ | 
					
						
							|  |  |  | cp -r assets/svg/ dist/assets/svg/ | 
					
						
							| 
									
										
										
										
											2023-10-11 03:47:23 +02:00
										 |  |  | mkdir dist/assets/langs | 
					
						
							|  |  |  | mkdir dist/assets/langs/layers | 
					
						
							| 
									
										
										
										
											2023-10-11 04:09:18 +02:00
										 |  |  | cp -r langs/layers/ dist/assets/langs/ | 
					
						
							| 
									
										
										
										
											2023-10-11 01:53:39 +02:00
										 |  |  | ls dist/assets/langs/layers/ | 
					
						
							| 
									
										
										
										
											2023-02-16 18:18:40 +01:00
										 |  |  | export NODE_OPTIONS="" |