-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Example - PurchaseTester TypeScript #320
Changes from 34 commits
b5165d3
7d74043
64df393
bfbf128
e29289a
2d8685e
c3a1f54
cc86f42
e88abde
b69a88a
4e052af
2239b1d
42ef1b7
1cd69fc
60735a0
f238ce8
9f7b4d9
84226f7
f2505ba
13c11ad
2ac8df6
ccd9151
23919bb
0549cf0
6264551
92a68bf
e656e8d
4ad51cc
03b5b48
55e8ee2
fb32dab
d45adc2
f9b5e97
74810a5
422a4f2
8843578
01e36e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,7 @@ | ||
version: 2.1 | ||
orbs: | ||
rn: react-native-community/react-native@6.0.1 | ||
rn: react-native-community/react-native@6.1.0 | ||
commands: | ||
yarn_install_example: | ||
steps: | ||
- run: | ||
command: > | ||
mkdir -p ~/.tmp/checksumfiles | ||
|
||
find . -type f -name 'package.json' -not -path "*node_modules*" -exec | ||
cat {} + >> ~/.tmp/checksumfiles/package.json | ||
|
||
find . -type f -name 'yarn.lock' -not -path "*node_modules*" -exec cat | ||
{} + >> ~/.tmp/checksumfiles/yarn.lock | ||
name: Create cache checksum file | ||
|
||
# Commented out because something is up with the permissions of the cache folder in the machines. | ||
# There's an open issue here: react-native-community/react-native-circleci-orb#66 | ||
|
||
# - restore_cache: | ||
# keys: | ||
# - >- | ||
# yarn-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/package.json" | ||
# }}-{{ checksum "~/.tmp/checksumfiles/yarn.lock" }}-{{ | ||
# .Environment.CACHE_VERSION }} | ||
- run: | ||
command: >- | ||
yarn --cwd examples/purchaseTester && yarn install --non-interactive --cache-folder /tmp/yarn | ||
name: Yarn Install | ||
# - save_cache: | ||
# key: > | ||
# yarn-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/package.json" | ||
# }}-{{ checksum "~/.tmp/checksumfiles/yarn.lock" }}-{{ | ||
# .Environment.CACHE_VERSION }} | ||
# paths: | ||
# - /tmp/yarn | ||
|
||
install_pods: | ||
steps: | ||
- restore_cache: | ||
keys: | ||
- cache-pods-{{ checksum "examples/purchaseTester/ios/Podfile.lock" }}-{{ .Environment.CACHE_VERSION }} | ||
- cache-pods- | ||
- run: | ||
command: yarn pods | ||
name: Pod install | ||
- save_cache: | ||
paths: | ||
- examples/purchaseTester/ios/Pods | ||
key: cache-pods-{{ checksum "examples/purchaseTester/ios/Podfile.lock" }}-{{ .Environment.CACHE_VERSION }} | ||
|
||
jobs: | ||
analyse_js: | ||
|
@@ -57,7 +10,15 @@ jobs: | |
node_version: '12' | ||
steps: | ||
- checkout | ||
- yarn_install_example | ||
- rn/yarn_install: | ||
yarn_install_directory: examples/purchaseTester | ||
cache_folder: ~/.cache/yarn | ||
- rn/yarn_install: | ||
yarn_install_directory: examples/purchaseTesterTypescript | ||
cache_folder: ~/.cache/yarn | ||
- run: | ||
name: Yarn Install | ||
command: yarn install --non-interactive --cache-folder /tmp/yarn | ||
- run: | ||
name: Tests | ||
command: yarn test | ||
|
@@ -68,9 +29,14 @@ jobs: | |
executor: rn/linux_android | ||
steps: | ||
- checkout | ||
- yarn_install_example | ||
- rn/yarn_install: | ||
yarn_install_directory: examples/purchaseTester | ||
cache_folder: ~/.cache/yarn | ||
- rn/yarn_install: | ||
yarn_install_directory: examples/purchaseTesterTypescript | ||
cache_folder: ~/.cache/yarn | ||
- rn/android_build: | ||
project_path: examples/purchaseTester/android | ||
project_path: examples/purchaseTesterTypescript/android | ||
ios: | ||
executor: | ||
name: rn/macos | ||
|
@@ -79,15 +45,23 @@ jobs: | |
- checkout | ||
- rn/ios_simulator_start: | ||
device: iPhone 11 Pro | ||
- yarn_install_example | ||
- install_pods | ||
- rn/yarn_install: | ||
yarn_install_directory: examples/purchaseTester | ||
cache_folder: ~/.cache/yarn | ||
- rn/yarn_install: | ||
yarn_install_directory: examples/purchaseTesterTypescript | ||
cache_folder: ~/.cache/yarn | ||
- rn/pod_install: | ||
pod_install_directory: examples/purchaseTester/ios | ||
- rn/pod_install: | ||
pod_install_directory: examples/purchaseTesterTypescript/ios | ||
- rn/ios_build: | ||
build_configuration: Release | ||
device: iPhone 11 Pro | ||
derived_data_path: ~/DerivedData | ||
project_type: workspace | ||
project_path: examples/purchaseTester/ios/ReactNativeSample.xcworkspace | ||
scheme: ReactNativeSample | ||
project_path: examples/purchaseTesterTypescript/ios/PurchaseTester.xcworkspace | ||
scheme: PurchaseTester | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we need to build both apps. Running one takes already very long. I am all for just doing one, preferably the new one you just created. Also, I understand we want to keep both tester apps because one is JS and the other one is TS, but the JS one is so bad... maybe we could just simplify it even more than it is now and keep it as a barebones app where we can test the API. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah yeah, this takes super long 😱 I agree that running the typescript one probably makes the most sense. I think more issues could come out of that one than the javascript one.
Are you referring to the javascript one? ☝️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vegaro do you mean turning the javascript app into an API tester? |
||
|
||
workflows: | ||
test: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ node_modules/ | |
npm-debug.log | ||
yarn-error.log | ||
**/yarn.lock | ||
**/package-lock.json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥 |
||
|
||
# Xcode | ||
# | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idk if this kinda file is common knowledge for RN developers (and maybe ignore me if so), but could we add a comment on what this does for us? |
||
[android] | ||
target = Google Inc.:Google APIs:23 | ||
|
||
[maven_repositories] | ||
central = https://repo1.maven.org/maven2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Windows files | ||
[*.bat] | ||
end_of_line = crlf |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
root: true, | ||
extends: '@react-native-community', | ||
rules: { | ||
"no-shadow": "off", | ||
"@typescript-eslint/no-shadow": ["error"], | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Windows files should use crlf line endings | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
*.bat text eol=crlf |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
|
||
# Android/IntelliJ | ||
# | ||
build/ | ||
.idea | ||
.gradle | ||
local.properties | ||
*.iml | ||
*.hprof | ||
|
||
# node.js | ||
# | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
# BUCK | ||
buck-out/ | ||
\.buckd/ | ||
*.keystore | ||
!debug.keystore | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the | ||
# screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://docs.fastlane.tools/best-practices/source-control/ | ||
|
||
*/fastlane/report.xml | ||
*/fastlane/Preview.html | ||
*/fastlane/screenshots | ||
|
||
# Bundle artifact | ||
*.jsbundle | ||
|
||
# CocoaPods | ||
/ios/Pods/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
bracketSpacing: false, | ||
jsxBracketSameLine: true, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
arrowParens: 'avoid', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Sample React Native App | ||
* https://github.com/facebook/react-native | ||
* | ||
* Generated with the TypeScript template | ||
* https://github.com/react-native-community/react-native-template-typescript | ||
* | ||
* @format | ||
*/ | ||
|
||
import React, { useEffect } from 'react'; | ||
|
||
import { Platform, Text } from 'react-native'; | ||
import { NavigationContainer } from '@react-navigation/native'; | ||
import { createNativeStackNavigator } from '@react-navigation/native-stack'; | ||
|
||
import Purchases from 'react-native-purchases'; | ||
|
||
import HomeScreen from './app/screens/HomeScreen'; | ||
import CustomerInfoScreen from './app/screens/CustomerInfoScreen'; | ||
import OfferingDetailScreen from './app/screens/OfferingDetailScreen'; | ||
|
||
import APIKeys from './app/APIKeys'; | ||
import { SafeAreaView } from 'react-native-safe-area-context'; | ||
|
||
const Stack = createNativeStackNavigator(); | ||
|
||
const App = () => { | ||
const isSetup = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is nitpicky, but could we rename to something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a much better name 😊 Love it! |
||
return APIKeys.apple.length > 0 || APIKeys.google.length > 0; | ||
} | ||
|
||
useEffect(() => { | ||
if (!isSetup()) { return } | ||
|
||
Purchases.setDebugLogsEnabled(true); | ||
if (Platform.OS == "android") { | ||
Purchases.setup(APIKeys.google); | ||
} else { | ||
Purchases.setup(APIKeys.apple); | ||
} | ||
}, []); | ||
|
||
return !isSetup() ? ( | ||
<SafeAreaView> | ||
<Text style={{margin: 20, textAlign: 'center'}}> | ||
Update RevenueCat API Keys in APIKeys.tsx | ||
</Text> | ||
</SafeAreaView> | ||
) : ( | ||
<NavigationContainer> | ||
<Stack.Navigator initialRouteName="Home"> | ||
<Stack.Screen | ||
name="Home" | ||
component={HomeScreen} | ||
options={{ title: 'PurchaseTester' }} | ||
/> | ||
<Stack.Screen name="CustomerInfo" component={CustomerInfoScreen} /> | ||
<Stack.Screen name="OfferingDetail" component={OfferingDetailScreen} /> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i love this, we should definitely consider in the other platforms. of course well get a configuration error, but if you can't view debug logs you might not know |
||
); | ||
}; | ||
|
||
export default App; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @format | ||
*/ | ||
|
||
import 'react-native'; | ||
import React from 'react'; | ||
import App from '../App'; | ||
|
||
// Note: test renderer must be required after react-native. | ||
import renderer from 'react-test-renderer'; | ||
|
||
it('renders correctly', () => { | ||
renderer.create(<App />); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we rename this now that it's not just js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started to rename this to just
analyse
but it then made it unclear what layer it was analyzing 🤔 Even though its not 100% correct and TypeScript is a superset of JavaScript, I think it feels less worse this way 😅There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about
analyze_ts_and_js
oranalyze_ts_js
? I usually go overly explicit even if it becomes verbose