Skip to content

Commit 88369c4

Browse files
committed
add local expo-cli for simulator.sh script
1 parent 3ff8b7d commit 88369c4

File tree

4 files changed

+2032
-81
lines changed

4 files changed

+2032
-81
lines changed

README.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,13 @@
44
[![Maintainability](https://api.codeclimate.com/v1/badges/8bb29bcea21bb5dda316/maintainability)](https://codeclimate.com/github/rootstrap/react-native-base/maintainability)
55
[![Test Coverage](https://api.codeclimate.com/v1/badges/8bb29bcea21bb5dda316/test_coverage)](https://codeclimate.com/github/rootstrap/react-native-base/test_coverage)
66

7-
## Commands
8-
9-
1. **Start the app**: `yarn android:{env}` or `yarn ios:{env}` (envs: `dev`, `staging`, and `prod`)
10-
2. **Start metro bundler**: `yarn start`
11-
3. **Lint the app**: `yarn lint`
12-
4. **Test the app**: `yarn test`
13-
147
## Getting started
158

169
1. Install dependencies: `yarn`
1710
2. Create a `.env` file in the root directory of the project, based on the `.env.defaults` sample file and the extra constants that you may need. This will be your development env.
1811

19-
You can also create `.env.prod`, `.env.staging`, and `.env.qa` to define environment variables for production and staging.
20-
21-
1. Rename your new project using `yarn rename` or `npm run rename`
22-
2. Start on android or ios: `yarn android:{env}` or `yarn ios:{env}` (envs: `dev`,`qa`, `staging`, and `prod`)
12+
2.1 You can also create `.env.prod`, `.env.staging`, and `.env.qa` to define environment variables for production and staging.
13+
3. Rename your new project using `yarn rename` or `npm run rename`
2314

2415
### Steps for Android development
2516

@@ -29,27 +20,36 @@ None
2920

3021
1. Run the following command to install iOS pods
3122

32-
```
23+
```bash
3324
npx pod-install
3425
```
3526

27+
## Commands
28+
29+
1. **Start metro bundler**: `yarn start`
30+
2. **Start the app**: `yarn android:{env}` or `yarn ios:{env}` (envs: `dev`, `staging`, and `prod`)
31+
3. **Lint the app**: `yarn lint`
32+
4. **Test the app**: `yarn test`
33+
34+
**Note: by default we use Expo CLI for iOS if you want to use react-native CLI you must append the following flag to the command:**
35+
36+
```bash
37+
USE_RN_CLI=true yarn ios:{env}
38+
```
39+
3640
## Continuous Integration
3741

3842
The repo includes configuration for using GitHub Actions to run unit tests and code analysis: `.github/workflows/test.yml`. This can be adapted as needed for specifics of each project. Both CodeClimate and Sonarqube integrations are included in the workflow and their required environment settings should be retrieved from the repo Secrets.
3943

4044
## Using folders template
4145

42-
There's a folder named .fttemplates where you'll find a template you can use to create new components for your app, keeping the same folder conventions for all your components.
46+
There's a folder named .fttemplates where you'll find a template you can use to create new components for your app, keeping the same folder conventions for all your components.
4347

4448
You must install Folder Templates extensions in Visual Studio Code to use this feature. You'll find it [here](https://marketplace.visualstudio.com/items?itemName=Huuums.vscode-fast-folder-structure).
4549

4650
If you install the extension you can create your components folder using the template by clicking on Create new templated folder button in the context menu.
4751

48-
49-
https://user-images.githubusercontent.com/11773865/216385411-9e152929-e6f7-41a2-a22c-5312509acbd4.mov
50-
51-
52-
52+
<https://user-images.githubusercontent.com/11773865/216385411-9e152929-e6f7-41a2-a22c-5312509acbd4.mov>
5353

5454
## Configuring Code Climate
5555

@@ -66,6 +66,7 @@ https://user-images.githubusercontent.com/11773865/216385411-9e152929-e6f7-41a2-
6666
### Usage
6767

6868
```
69+
6970
sonar-scanner \
7071
-Dsonar.qualitygate.wait=true \
7172
-Dsonar.host.url=$SONAR_URL \
@@ -78,7 +79,8 @@ sonar-scanner \
7879
-Dsonar.sources=. \
7980
-Dsonar.projectBaseDir=. \
8081
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
81-
-Dsonar.coverage.exclusions=**/spec.js,**/__mocks__/**,**/**.spec.js,**/**.config.js,**/rnbv.js,**/android/**,**/ios/**,**/**.styles.js,**/tests/**,**/__mocks__/**,**/httpClient/**,**/jest-setup.js,**/constants/**,**/assets/**,**/node_modules/**,**/coverage/**
82+
-Dsonar.coverage.exclusions=**/spec.js,**/**mocks**/**,**/**.spec.js,**/**.config.js,**/rnbv.js,**/android/**,**/ios/**,**/**.styles.js,**/tests/**,**/**mocks**/**,**/httpClient/**,**/jest-setup.js,**/constants/**,**/assets/**,**/node_modules/**,**/coverage/**
83+
8284
```
8385

8486
## Build Android Release
@@ -114,11 +116,13 @@ If you want to add a new env here are the steps to follow:
114116
3. Scroll down to the `flavors` section and add a new flavor with the following format:
115117

116118
```
119+
117120
{name} {
118121
applicationIdSuffix '.{name}'
119122
minSdkVersion rootProject.ext.minSdkVersion
120123
targetSdkVersion rootProject.ext.targetSdkVersion
121124
}
125+
122126
```
123127

124128
4. Inside `android/app/src` copy one of the existing env folders like `staging` and rename it with the name of your new flavor.
@@ -134,10 +138,13 @@ We have in place a validation that will check if the env file exists and has all
134138
Variables are defined in `src/@types/env` and the validation is done in `scripts/validation-env.ts`.
135139

136140
```
141+
137142
APP_ENV={dev | prod | staging | qa} react-native run-{android | ios}
143+
138144
```
139145

140146
Note: For iOS the validation occurs within the `scripts/simulator.sh` script. For Android it occurs as an inline command in the `package.json` scripts
147+
141148
### iOS
142149

143150
#### Using different schemes
@@ -159,7 +166,9 @@ To add a new build target do as follows:
159166
If you are looking for something quick and easy in the short term, there is one more way you can run the app with a custom env file, just run:
160167

161168
```
169+
162170
ENVFILE=.env.{env} react-native run-ios
171+
163172
```
164173

165174
### Adding App Icons for each env

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"eslint-plugin-react-hooks": "^4.6.0",
9393
"eslint-plugin-react-native": "^4.0.0",
9494
"eslint-plugin-react-native-a11y": "^3.2.1",
95+
"expo": "^49.0.13",
9596
"jest": "^29.2.1",
9697
"lefthook": "^1.2.8",
9798
"metro-react-native-babel-preset": "^0.76.8",

scripts/simulator.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/sh
22

33
if [[ $# = 0 ]]; then
4-
echo "Usage: $0 Scheme-Name Debug/Release"
5-
exit 1
4+
echo "Usage: $0 Scheme-Name Debug/Release"
5+
exit 1
66
fi
77

88
TS_FILE="./scripts/validate-env.ts"
@@ -25,8 +25,18 @@ if [ $EXIT_CODE -ne 0 ]; then
2525
exit 1
2626
fi
2727

28-
if which npx >/dev/null; then
29-
npx expo run:ios --scheme $1 --configuration $2 ${@:3}
28+
if [[ $USE_RN_CLI = true ]]; then
29+
echo "Using react-native-cli"
30+
react-native run-ios --scheme $1 --mode $2 ${@:3}
31+
exit 0
3032
else
31-
react-native run-ios --scheme $1 --configuration $2 ${@:3}
32-
fi
33+
# check if expo is in node_modules
34+
if [ ! -d "./node_modules/expo" ]; then
35+
echo "expo not found. Installing expo locally..."
36+
yarn add -D expo
37+
fi
38+
39+
echo "Using expo-cli"
40+
expo run:ios --scheme $1 --configuration $2 ${@:3}
41+
exit 0
42+
fi

0 commit comments

Comments
 (0)