Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .env

This file was deleted.

1 change: 0 additions & 1 deletion .env.production

This file was deleted.

1 change: 0 additions & 1 deletion .env.qa

This file was deleted.

1 change: 0 additions & 1 deletion .env.staging

This file was deleted.

6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ dist/
/ios

google-services.json
GoogleService-Info.plist
GoogleService-Info.plist

scripts/doppler_variables.sh
.env
env.json
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,23 @@ Start the expo server
yarn start
```

## Adding jotai as state management tool
Environment variables instruction:

This starter doesn't go with any state management tool, but we have created separate branch with jotai setup, maybe in the future we will add more tools support.
1. Create empty file `scripts/doppler_variables.sh` and add this script to new created file.

To use jotai with this starter you can check docs: **[Jotai docs](./documentation/docs/tutorials/JOTAI.md)**
- run `yarn prepare:env_file` - this will copy template and plase it in `scripts/doppler_variables.sh`

2. Add correct values to variables (ask one of the developers for that), example:

```bash
export DOPPLER_TOKEN_DEVELOPMENT=dp.st.alpha.XXXXxxxxXXXXxxxxXXXXxxxx
```

Start the expo server

```bash
yarn start
```

## License

Expand Down
27 changes: 12 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
"author": "BinarApps",
"license": "MIT",
"scripts": {
"eas-build-pre-install": "base64 --help && echo $ANDROID_FIREBASE_CONFIG | base64 --decode > google-services.json && cat google-services.json && echo $IOS_FIREBASE_CONFIG | base64 --decode > GoogleService-Info.plist && cat GoogleService-Info.plist",
"android:dev-client": "IS_DEV=1 npx expo run:android",
"android": "expo run:android",
"bootstrap:new_app": "yarn && node ./scripts/bootstrap.js",
"build:production:android": "yarn prepare:production && eas build --platform android --profile production",
"build:production:ios": "yarn prepare:production && eas build --platform ios --profile production",
Expand All @@ -45,30 +43,29 @@
"deploy:staging:android": "yarn prepare:staging && eas build --platform android --profile staging --auto-submit --non-interactive",
"deploy:staging:ios": "yarn prepare:staging && eas build --platform ios --profile staging --auto-submit --non-interactive",
"deploy:staging": "yarn prepare:staging && eas build --platform all --profile staging --auto-submit --non-interactive",
"eject": "expo eject",
"generate:query": "yarn orval --config ./orval.config.ts",
"eas-build-pre-install": "base64 --help && echo $ANDROID_FIREBASE_CONFIG | base64 --decode > google-services.json && cat google-services.json && echo $IOS_FIREBASE_CONFIG | base64 --decode > GoogleService-Info.plist && cat GoogleService-Info.plist",
"generate:component": "node ./scripts/create_new_component.js && yarn eslint src --fix && yarn tsc",
"generate:env:production": "scripts/generate_dotenv.sh production",
"generate:env:qa": "scripts/generate_dotenv.sh qa",
"generate:env:staging": "scripts/generate_dotenv.sh staging",
"generate:icon:types": "node ./scripts/generate_icon_types.js",
"generate:google-services-config": "./scripts/generate_firebase_config.sh",
"generate:icon:types": "node ./scripts/generate_icon_types.js",
"generate:query": "yarn orval --config ./orval.config.ts",
"generate:screen": "node ./scripts/create_new_screen.js && yarn eslint src --fix && yarn tsc",
"ios": "expo run:ios",
"lint": "eslint src && yarn tsc",
"lint:fix": "eslint src --fix",
"login": "expo login",
"logout": "expo logout",
"lint": "eslint src && yarn tsc",
"postinstall": "patch-package",
"prebuild:android": "IS_DEV=1 npx expo prebuild --clean -p android",
"prepare:production": "yarn generate:env:production && BASH_ENV=./.env scripts/upload_env.sh",
"prepare:qa": "yarn generate:env:qa && BASH_ENV=./.env scripts/upload_env.sh",
"prepare:staging": "yarn generate:env:staging && BASH_ENV=./.env scripts/upload_env.sh",
"prebuild:ios": "IS_DEV=1 npx expo prebuild --clean -p ios",
"prepare:env_file": "cp ./templates/doppler_variables_template.sh ./scripts/doppler_variables.sh",
"prepare:production": "yarn && yarn generate:env:production && yarn generate:google-services-config",
"prepare:qa": "yarn && yarn generate:env:qa && yarn generate:google-services-config",
"prepare:staging": "yarn && yarn generate:env:staging && yarn generate:google-services-config",
"prepare": "husky install",
"prettier:write": "prettier --write ./src",
"register": "expo register",
"start:fast": "EXPO_USE_EXOTIC=1 expo start --clear",
"start": "cross-env IS_DEV=1 expo start -c -g",
"start:prod": "yarn generate:env:production && IS_DEV=1 IS_EXPO_GO=1 expo start -c -g",
"start:staging": "yarn generate:env:staging && IS_DEV=1 IS_EXPO_GO=1 expo start -c -g",
"start": "yarn generate:env:qa && cross-env IS_DEV=1 IS_EXPO_GO=1 expo start -c -g",
"test:debug": "jest -o --watch --coverage=false",
"test:final": "jest",
"test": "jest --watch --coverage=false --changedSince=origin/main",
Expand Down
59 changes: 56 additions & 3 deletions scripts/generate_dotenv.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,58 @@
#!/usr/bin/env bash
ENVIRONMENT=$1
echo $ENVIRONMENT
source ./scripts/doppler_variables.sh

cp .env.$ENVIRONMENT .env
# Global colors
normal=$'\e[0m' # (works better sometimes)
bold=$(tput bold) # make colors bold/bright
red="$bold$(tput setaf 1)" # bright red text
green=$(tput setaf 2) # dim green text
fawn=$(tput setaf 3); beige="$fawn" # dark yellow text
darkblue=$(tput setaf 4) # dim blue text
blue="$bold$darkblue" # bright blue text
purple=$(tput setaf 5); magenta="$purple" # magenta text
pink="$bold$purple" # bright magenta text
darkcyan=$(tput setaf 6) # dim cyan text
gray=$(tput setaf 7) # dim white text
darkgray="$bold"$(tput setaf 0) # bold black = dark gray text


# Global variables
ENVIRONMENT_NAME=$1
function install_doppler {
(curl -Ls --tlsv1.2 --proto "=https" --retry 3 https://cli.doppler.com/install.sh || wget -t 3 -qO- https://cli.doppler.com/install.sh) | sh || echo "${pink}There was some problem with installing doppler, and it's needed to get environment varialbes, please download it manually - https://docs.doppler.com/docs/cli"
# When using this on windows try this commands
# scoop bucket add doppler https://github.com/DopplerHQ/scoop-doppler.git
# scoop install doppler
}

if command -v doppler >/dev/null 2>&1 ;
then echo "${green}[START WORK] Setting Doppler token for Baca App | ${red}$ENVIRONMENT_NAME ${normal}"
echo Now setting token and printing env for env: $ENVIRONMENT_NAME
if [ $ENVIRONMENT_NAME = "qa" ]; then
doppler setup --config=qa --token=$DOPPLER_TOKEN_DEVELOPMENT --no-interactive
doppler secrets download --config=qa --token=$DOPPLER_TOKEN_DEVELOPMENT --no-file --format=env-no-quotes > .env
doppler secrets download --config=qa --token=$DOPPLER_TOKEN_DEVELOPMENT --no-file > env.json
fi
if [ $ENVIRONMENT_NAME = "staging" ]; then
doppler setup --config=stg --token=$DOPPLER_TOKEN_STAGING --no-interactive
doppler secrets download --config=stg --token=$DOPPLER_TOKEN_STAGING --no-file --format=env-no-quotes > .env
doppler secrets download --config=stg --token=$DOPPLER_TOKEN_STAGING --no-file > env.json
fi
if [ $ENVIRONMENT_NAME = "production" ]; then
doppler setup --config=prd --token=$DOPPLER_TOKEN_PROD --no-interactive
doppler secrets download --config=prd --token=$DOPPLER_TOKEN_PROD --no-file --format=env-no-quotes > .env
doppler secrets download --config=prd --token=$DOPPLER_TOKEN_PROD --no-file > env.json
fi
echo Created envs for env: $ENVIRONMENT_NAME
else
read -p "${green}We require Doppler CLI, but it's not installed. Do you wish to install it? (y/n)${normal} " answer
case ${answer:0:1} in
y|Y )
install_doppler
./scripts/generate_dotenv.sh $ENVIRONMENT_NAME
;;
* )
echo "We need doppler to set environement variables, you can download it manually - https://docs.doppler.com/docs/cli"
;;
esac
fi
2 changes: 1 addition & 1 deletion src/constants/env.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Constants from 'expo-constants'

export const ENV = {
API_URL: 'https://api.binarapps.online/', // TODO: create env for dev/staging/prod and keep it there
API_URL: Constants?.expoConfig?.extra?.API_URL,
ENVIRONMENT: Constants?.expoConfig?.extra?.ENVIRONMENT,
}
15 changes: 15 additions & 0 deletions templates/doppler_variables_template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# --- Define doppler variables ---
export DOPPLER_TOKEN_DEVELOPMENT=
export DOPPLER_TOKEN_STAGING=
export DOPPLER_TOKEN_PROD=
# --- End Definitions Section ---

# check if we are being sourced by another script or shell
[[ "${#BASH_SOURCE[@]}" -gt "1" ]] && { return 0; }

# --- Begin Code Execution Section ---
echo $DOPPLER_TOKEN_DEVELOPMENT
echo $DOPPLER_TOKEN_STAGING
echo $DOPPLER_TOKEN_PROD