Skip to content

Commit

Permalink
use .env for server address in example app (#51)
Browse files Browse the repository at this point in the history
android emu specific url
  • Loading branch information
jdivock-stripe authored Feb 1, 2022
1 parent 12b783e commit 0f161e6
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 18 deletions.
19 changes: 12 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ executors:
linux_js:
docker:
- image: circleci/node:14.15.0
resource_class: medium
resource_class: medium+
environment:
PATH: '/opt/yarn/yarn-v1.5.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

Expand Down Expand Up @@ -69,7 +69,7 @@ commands:
source $BASH_ENV
- restore_cache:
key: |
brew-cache-{{ arch }}-v1
brew-cache-{{ arch }}-v1-3
- run:
name: Install node@<<parameters.node_version>>
command: |
Expand All @@ -91,6 +91,13 @@ commands:
HOMEBREW_NO_AUTO_UPDATE=1 brew install android-commandlinetools >/dev/null
touch .watchmanconfig
node -v
- save_cache:
paths:
- ~/Library/Caches/Homebrew
- /usr/local/Homebrew/Library/Taps
- /usr/local/Homebrew/Library/Homebrew/vendor/
key: |
brew-cache-{{ arch }}-v1-3
android_emulator_start:
parameters:
device_name:
Expand Down Expand Up @@ -211,9 +218,6 @@ jobs:
executor: macos_custom

steps:
- attach_workspace:
at: .

- setup_macos_executor

- ios_simulator_start
Expand All @@ -227,24 +231,25 @@ jobs:
- run:
command: yarn e2e:build:ios:release
name: build for detox

- run:
command: yarn e2e:test:ios:release
name: test detox

- store_artifacts:
path: ./artifacts

e2e-android:
executor:
name: macos_custom
steps:
- attach_workspace:
at: .
- setup_macos_executor

- run:
command: yarn install --frozen-lockfile
name: yarn install
- android_emulator_start

- run:
command: yarn e2e:build:android:release
name: build for detox
Expand Down
12 changes: 9 additions & 3 deletions example/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
API_URL_ANDROID=http://10.0.2.2:3002
API_URL_IOS=http://localhost:3002

# Fill in your private TEST API key below
STRIPE_PRIVATE_KEY=sk_test_xxx

# Backend API URL
API_URL=http://127.0.0.1:3002

# Android Backend API URL.
# The example app will default to API_URL if no specific API_URL_ANDROID is defined
# This is helpful when you're working with the android emulator as it remaps the localhost
# ip value (default is 10.0.2.2)
API_URL_ANDROID=http://10.0.2.2:3002
1 change: 1 addition & 0 deletions example/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const pak = require('../package.json');
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
['module:react-native-dotenv'],
[
'module-resolver',
{
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,11 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: a7c83b31436843459a1961bfd74b96033dc77234
DoubleConversion: cde416483dac037923206447da6e1454df403714
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
FBLazyVector: de148e8310b8b878db304ceea2fec13f2c02e3a0
FBReactNativeSpec: 6192956c9e346013d5f1809ba049af720b11c6a4
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
glog: 5337263514dd6f09803962437687240c5dc39aa4
RCT-Folly: a21c126816d8025b547704b777a2ba552f3d9fa9
RCTRequired: 59d2b744d8c2bf2d9bc7032a9f654809adcf7d50
RCTTypeSafety: d0aaf7ccae5c70a4aaa3a5c3e9e0db97efae760e
Expand Down Expand Up @@ -490,6 +490,6 @@ SPEC CHECKSUMS:
StripeTerminal: da566fa62a4e7bbf0510dd27614f3087293cd79e
Yoga: 32a18c0e845e185f4a2a66ec76e1fd1f958f22fa

PODFILE CHECKSUM: 4f0873ca93c8515b2736ed78b61a035f42aa658c
PODFILE CHECKSUM: 84b73709c1edcf5ac7a2639adb1bd9760a58aef7

COCOAPODS: 1.10.1
COCOAPODS: 1.11.2
6 changes: 5 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"ios": "react-native run-ios",
"start": "react-native start",
"build:server": "babel server --out-dir dist --extensions '.ts,.tsx' --ignore '**/__tests__/**' --source-maps --copy-files --delete-dir-on-start",
"start:server": "nodemon --exec ts-node server/index.ts",
"start:server": "ts-node server/index.ts",
"start:server:ci": "ts-node server/index.ts &",
"watch:server": "nodemon --exec ts-node server/index.ts",
"postinstall": "scripts/fixRN.sh"
},
"dependencies": {
Expand All @@ -17,11 +19,13 @@
"@react-navigation/native": "^5.x",
"@react-navigation/stack": "^5.x",
"@types/jest": "^27.0.2",
"@types/react-native-dotenv": "^0.2.0",
"dotenv": "^10.0.0",
"jest": "^27.3.1",
"react": "17.0.2",
"react-native": "0.66.3",
"react-native-config": "^1.4.5",
"react-native-dotenv": "^3.3.1",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "2.3.0",
"react-native-safe-area-context": "^3.3.2",
Expand Down
7 changes: 6 additions & 1 deletion example/src/Config.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export const API_URL = 'https://stripe-backend-danwaters.herokuapp.com';
// @ts-ignore
import { API_URL as defaultURL, API_URL_ANDROID as androidURL } from '@env';
import { Platform } from 'react-native';

export const API_URL: string =
Platform.OS === 'android' && androidURL ? androidURL : defaultURL;
12 changes: 12 additions & 0 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,11 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc"
integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==

"@types/react-native-dotenv@^0.2.0":
version "0.2.0"
resolved "https://registry.npmjs.org/@types/react-native-dotenv/-/react-native-dotenv-0.2.0.tgz#32c58422a422c1adf68acce363ed791314d5a8e7"
integrity sha512-ZxX+dU/yoQc0jTk+/NWttkiuXceJyN5FpOSqDl0WynN5GDzxwH7OMruQ47qcY8llo2RD3irjvzJ9BwC8gDiq0A==

"@types/serve-static@*":
version "1.13.10"
resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.10.tgz#f5e0ce8797d2d7cc5ebeda48a52c96c4fa47a8d9"
Expand Down Expand Up @@ -5755,6 +5760,13 @@ react-native-config@^1.4.5:
resolved "https://registry.yarnpkg.com/react-native-config/-/react-native-config-1.4.5.tgz#6fe5895410b75e44fe4f4bf00caaf894a0981f3a"
integrity sha512-5oiAsoW88SOYDg/0cleJ2vJDqv98FJUbFQYEnH4sdMtEn3AAT3lb7BkTGW8HO/t3Vk9VOruwxUUnO4tzuxzCsw==

react-native-dotenv@^3.3.1:
version "3.3.1"
resolved "https://registry.npmjs.org/react-native-dotenv/-/react-native-dotenv-3.3.1.tgz#8f399cf28ca77d860d8e7f7323e439fa60a8ca0b"
integrity sha512-gAKXout1XCwCqJ3QPGoQAF2eRzOHgOnwg3x19z+ssow8bDIksJeKBqvoHDyGziVilAIP1J0bEC9Jf+VF8nFang==
dependencies:
dotenv "^10.0.0"

react-native-gesture-handler@^1.10.3:
version "1.10.3"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.10.3.tgz#942bbf2963bbf49fa79593600ee9d7b5dab3cfc0"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"e2e:test:ios": "detox test --configuration ios --take-screenshots failing --loglevel verbose",
"e2e:build:android:release": "detox build --configuration android.emu.release",
"e2e:build:ios:release": "detox build --configuration ios.sim.release",
"e2e:test:android:release": "yarn get:testbutler && detox test --configuration android.emu.release --headless --take-screenshots failing --record-logs all",
"e2e:test:ios:release": "detox test --configuration ios.sim.release --take-screenshots failing",
"e2e:test:android:release": "yarn --cwd example start:server:ci && yarn get:testbutler && detox test --configuration android.emu.release --headless --take-screenshots failing --record-logs all",
"e2e:test:ios:release": "yarn --cwd example start:server:ci && detox test --configuration ios.sim.release --take-screenshots failing",
"get:testbutler": "curl -f -o ./test-butler-app.apk https://repo1.maven.org/maven2/com/linkedin/testbutler/test-butler-app/2.2.1/test-butler-app-2.2.1.apk",
"docs": "npx typedoc ./src/index.tsx --out ./docs/api-reference --tsconfig ./tsconfig.json --theme minimal --theme ./docs/stripe-theme"
},
Expand Down

0 comments on commit 0f161e6

Please sign in to comment.