Files
feeddeck/app/run.sh
Rico Berger 3afbe5674b [core] Add Development Setup for Neovim (#63)
Add some stuff to make the development with Neovim easier:

- Add a "deno.json" file, which is required by the Deno language server,
  when working in Neovim to detect the "import_map.json" file.
- Add a "run.sh" script to easily run the Flutter app from the command
  line.
- Add the "run.sh" script and an example for Neovim to the contributing
  guide.
2023-11-04 11:47:53 +01:00

56 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
if [[ "$#" -lt 1 ]]; then
echo "$(basename "$0") -- program to run the app
where:
-e|--environment set the environment on which the app should be run, e.g. -e=local
-d|--device set the device on which the app should be run, e.g. -d=chrome"
exit
fi
for arg in "$@"
do
case ${arg} in
-e=*|--environment=*)
environment="${arg#*=}"
shift
;;
-d=*|--device=*)
device="${arg#*=}"
shift
;;
*)
;;
esac
done
if [ -z "${environment}" ] || [ -z "${device}" ]; then
echo "You have to provide an environment and a device"
echo "Example: $0 -e=local -d=chrome"
exit 1
fi
# Load the environment variables from the corresponding ".env" file in the
# "supabase" directory.
set -o allexport && source "../supabase/.env.${environment}" && set +o allexport
# When the local environment is used, we have to adjust the Supabase URL to the
# local Supabase instance, since the environment variable set by the .env file
# uses the Docker address of the Supabase instance.
supabase_url=$FEEDDECK_SUPABASE_URL
if [ "${environment}" == "local" ]; then
supabase_url="http://localhost:54321"
fi
# If the selected device is "chrome" we have to add some additional flags to the
# "flutter run" command, since we want to run the app always on the same port
# and we want to disable the web security.
additional_flags=""
if [ "${device}" == "chrome" ]; then
additional_flags="--web-port 3000 --web-browser-flag=--disable-web-security"
fi
# Run the app on the provided device and environment.
flutter run -d ${device} ${additional_flags} --dart-define SUPABASE_URL=${supabase_url} --dart-define SUPABASE_ANON_KEY=${FEEDDECK_SUPABASE_ANON_KEY} --dart-define SUPABASE_SITE_URL=${FEEDDECK_SUPABASE_SITE_URL} --dart-define GOOGLE_CLIENT_ID=${FEEDDECK_GOOGLE_CLIENT_ID}