diff --git a/.gitignore b/.gitignore index 8275e625..931929ff 100644 --- a/.gitignore +++ b/.gitignore @@ -19,11 +19,7 @@ yarn-error.log # macOS .DS_Store - -.env.development -.env.production -.env.staging -.env.qa +*.apk # @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb # The following patterns were generated by expo-cli diff --git a/README-project.md b/README-project.md index 53206e9d..f1ba3ba9 100644 --- a/README-project.md +++ b/README-project.md @@ -37,6 +37,10 @@ To run the app on Android pnpm android ``` +To build your app locally you can run any of the build scripts with --local. + +`pnpm build:development:ios --local` + ### SonarQube setup SonarQube is an open-source platform for continuous inspection of code quality. It performs automatic reviews to detect bugs, code smells, and security vulnerabilities. Rootstrap has a SonarQube instance to improve the quality of the software we develop. On each PR, a GitHub Action is triggered to perform the analysis. To set up SonarQube correctly, you need to add the `SONAR_TOKEN`, `SONAR_URL`, and `SONAR_PROJECT` secrets to the repository. Additionally, you must select the quality gate named `ReactNativeTemplate` for your project on SonarQube. In case you're using this project outside Rootstrap and you're not planning to use SonarQube the sonar scanner [workflow](.github/workflows/sonar.yml) should be deleted. diff --git a/app.config.ts b/app.config.ts index fdcc490c..afb5003a 100644 --- a/app.config.ts +++ b/app.config.ts @@ -21,6 +21,10 @@ export default ({ config }: ConfigContext): ExpoConfig => ({ }, updates: { fallbackToCacheTimeout: 0, + url: 'https://u.expo.dev/72fdf440-59f1-493d-96e3-4afad8d7a045', + }, + runtimeVersion: { + policy: 'appVersion', }, assetBundlePatterns: ['**/*'], ios: { diff --git a/eas.json b/eas.json index 77ff0aa2..6bc57001 100644 --- a/eas.json +++ b/eas.json @@ -64,7 +64,8 @@ "prebuildCommand": "prebuild --skip-dependency-update react", "cache": { "key": "eas-1" - } + }, + "channel": "development" }, "simulator": { "ios": { @@ -82,7 +83,8 @@ "prebuildCommand": "prebuild --skip-dependency-update react", "cache": { "key": "eas-1" - } + }, + "channel": "simulator" } }, "submit": { diff --git a/env.js b/env.js index b7326c6f..26c8c695 100644 --- a/env.js +++ b/env.js @@ -28,7 +28,7 @@ require('dotenv').config({ * Such as: bundle id, package name, app name. * * You can add them to the .env file but we think it's better to keep them here as as we use prefix to generate this values based on the APP_ENV - * for example: if the APP_ENV is staging, the bundle id will be com.myexpoapp.staging + * for example: if the APP_ENV is staging, the bundle id will be com.rootstrap.staging */ // TODO: Replace these values with your own diff --git a/package.json b/package.json index 14984096..00fb5747 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "main": "expo-router/entry", "scripts": { + "eas-build-pre-install": "./source_env_local.sh", "start": "cross-env EXPO_NO_DOTENV=1 expo start", "prebuild": "cross-env EXPO_NO_DOTENV=1 pnpm expo prebuild", "android": "cross-env EXPO_NO_DOTENV=1 expo run:android", @@ -59,6 +60,7 @@ "expo-splash-screen": "0.27.5", "expo-status-bar": "~1.12.1", "expo-system-ui": "~3.0.7", + "expo-updates": "~0.25.21", "i18next": "^22.5.1", "lodash.memoize": "^4.1.2", "moti": "^0.28.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5c4e7df7..7f57859a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -74,6 +74,9 @@ importers: expo-system-ui: specifier: ~3.0.7 version: 3.0.7(expo@51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5))) + expo-updates: + specifier: ~0.25.21 + version: 0.25.21(expo@51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5))) i18next: specifier: ^22.5.1 version: 22.5.1 @@ -1199,6 +1202,10 @@ packages: '@expo/env@0.3.0': resolution: {integrity: sha512-OtB9XVHWaXidLbHvrVDeeXa09yvTl3+IQN884sO6PhIi2/StXfgSH/9zC7IvzrDB8kW3EBJ1PPLuCUJ2hxAT7Q==} + '@expo/fingerprint@0.10.2': + resolution: {integrity: sha512-q75zb4AeB08efofCnEJIddS7kCe0TX8YjHSat204mq1RLUJjv2JAN1Zgyk5HW/4i8b/sMYst0HX+BLCtszb+2A==} + hasBin: true + '@expo/image-utils@0.5.1': resolution: {integrity: sha512-U/GsFfFox88lXULmFJ9Shfl2aQGcwoKPF7fawSCLixIKtMCpsI+1r0h+5i0nQnmt9tHuzXZDL8+Dg1z6OhkI9A==} @@ -2329,6 +2336,9 @@ packages: application-config-path@0.1.1: resolution: {integrity: sha512-zy9cHePtMP0YhwG+CfHm0bgwdnga2X3gZexpdCwEj//dpb+TKajtiC8REEUJUSq6Ab4f9cgNy2l8ObXzCXFkEw==} + arg@4.1.0: + resolution: {integrity: sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg==} + arg@4.1.3: resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} @@ -3572,6 +3582,9 @@ packages: peerDependencies: expo: '*' + expo-eas-client@0.12.0: + resolution: {integrity: sha512-Jkww9Cwpv0z7DdLYiRX0r4fqBEcI9cKqTn7cHx63S09JaZ2rcwEE4zYHgrXwjahO+tU2VW8zqH+AJl6RhhW4zA==} + expo-file-system@17.0.1: resolution: {integrity: sha512-dYpnZJqTGj6HCYJyXAgpFkQWsiCH3HY1ek2cFZVHFoEc5tLz9gmdEgTF6nFHurvmvfmXqxi7a5CXyVm0aFYJBw==} peerDependencies: @@ -3643,6 +3656,9 @@ packages: expo-status-bar@1.12.1: resolution: {integrity: sha512-/t3xdbS8KB0prj5KG5w7z+wZPFlPtkgs95BsmrP/E7Q0xHXTcDcQ6Cu2FkFuRM+PKTb17cJDnLkawyS5vDLxMA==} + expo-structured-headers@3.8.0: + resolution: {integrity: sha512-R+gFGn0x5CWl4OVlk2j1bJTJIz4KO8mPoCHpRHmfqMjmrMvrOM0qQSY3V5NHXwp1yT/L2v8aUmFQsBRIdvi1XA==} + expo-system-ui@3.0.7: resolution: {integrity: sha512-KAs72F5JKhdIfPR9ZNVlRubTPK9uUuevPy5oYEp12xNEzSQcjZKvypH5NpwJuNWkXzrp3n3vZ+3pXsudA7J3KA==} peerDependencies: @@ -3653,6 +3669,12 @@ packages: peerDependencies: expo: '*' + expo-updates@0.25.21: + resolution: {integrity: sha512-eNElrzLFHky2au0H8MqdAJdqh40412PHCdANdXtB/P/XIS1xVte74T9rUf053iPswnLLuQfCUpZYSfRKTcsDlg==} + hasBin: true + peerDependencies: + expo: '*' + expo@51.0.24: resolution: {integrity: sha512-HoOuNIWXzS6Gxifcb0N+qRt5K6iR9YitQaWIVNB8elyupvQdyI566IMgMBiO45NgpO5es0sfFNNBasxBHLkbUw==} hasBin: true @@ -8878,6 +8900,19 @@ snapshots: transitivePeerDependencies: - supports-color + '@expo/fingerprint@0.10.2': + dependencies: + '@expo/spawn-async': 1.7.2 + chalk: 4.1.2 + debug: 4.3.4 + find-up: 5.0.0 + minimatch: 3.1.2 + p-limit: 3.1.0 + resolve-from: 5.0.0 + semver: 7.6.2 + transitivePeerDependencies: + - supports-color + '@expo/image-utils@0.5.1': dependencies: '@expo/spawn-async': 1.7.2 @@ -10527,6 +10562,8 @@ snapshots: application-config-path@0.1.1: {} + arg@4.1.0: {} + arg@4.1.3: {} arg@5.0.2: {} @@ -12008,6 +12045,8 @@ snapshots: expo-dev-menu-interface: 1.8.3(expo@51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5))) semver: 7.6.2 + expo-eas-client@0.12.0: {} + expo-file-system@17.0.1(expo@51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5))): dependencies: expo: 51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5)) @@ -12098,6 +12137,8 @@ snapshots: expo-status-bar@1.12.1: {} + expo-structured-headers@3.8.0: {} + expo-system-ui@3.0.7(expo@51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5))): dependencies: '@react-native/normalize-colors': 0.74.85 @@ -12110,6 +12151,28 @@ snapshots: dependencies: expo: 51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5)) + expo-updates@0.25.21(expo@51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5))): + dependencies: + '@expo/code-signing-certificates': 0.0.5 + '@expo/config': 9.0.3 + '@expo/config-plugins': 8.0.8 + '@expo/fingerprint': 0.10.2 + '@expo/spawn-async': 1.7.2 + arg: 4.1.0 + chalk: 4.1.2 + expo: 51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5)) + expo-eas-client: 0.12.0 + expo-manifests: 0.14.3(expo@51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5))) + expo-structured-headers: 3.8.0 + expo-updates-interface: 0.16.2(expo@51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5))) + fast-glob: 3.3.2 + fbemitter: 3.0.0 + ignore: 5.3.1 + resolve-from: 5.0.0 + transitivePeerDependencies: + - encoding + - supports-color + expo@51.0.24(@babel/core@7.24.5)(@babel/preset-env@7.24.5(@babel/core@7.24.5)): dependencies: '@babel/runtime': 7.24.5 diff --git a/source_env_local.sh b/source_env_local.sh new file mode 100755 index 00000000..dbc6e2a6 --- /dev/null +++ b/source_env_local.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Determine the env file based on the APP_ENV variable +case "$APP_ENV" in + development) + ENV_FILE=".env.development" + ;; + staging) + ENV_FILE=".env.staging" + ;; + production) + ENV_FILE=".env.production" + ;; + *) + echo "Error: Unknown APP_ENV value: $APP_ENV" + exit 1 + ;; +esac + +# Check if .env file exists +if [ ! -f "$ENV_FILE" ]; then + echo "Error: $ENV_FILE file does not exist." + exit 1 +fi + +echo "I am loading $ENV_FILE" + +# Read .env file line by line +while IFS= read -r line; do + # Skip empty lines and lines starting with # (comments) + if [[ -z "$line" || "$line" =~ ^# ]]; then + continue + fi + + # Use regex to extract env variable KEY and VALUE + if [[ "$line" =~ ^([^=]+)=(.*) ]]; then + key="${BASH_REMATCH[1]}" + value="${BASH_REMATCH[2]}" + + # Use set-env binary to set the environment variable + set-env "$key" "$value" + if [ $? -ne 0 ]; then + echo "Failed to set $key" + else + echo "Set $key" + fi + fi +done < "$ENV_FILE"