Skip to content
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

Merged
merged 37 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b5165d3
Initial commit of purchaseTester typescript example
Dec 15, 2021
7d74043
Made things a little prettier for offering detail
joshdholtz Dec 28, 2021
64df393
Removed console log
joshdholtz Dec 28, 2021
bfbf128
Typescript example using local RNPurchases pod
joshdholtz Dec 28, 2021
e29289a
Fix some things were states weren't updating
joshdholtz Dec 28, 2021
2d8685e
Trying to fix CircleCI
joshdholtz Dec 28, 2021
c3a1f54
This is it
joshdholtz Dec 28, 2021
cc86f42
name isn't a thing for the RN builds
joshdholtz Dec 28, 2021
e88abde
name also isn't a thing for iOS RN builds
joshdholtz Dec 28, 2021
b69a88a
Add set attributes which isnt really working yet
joshdholtz Dec 29, 2021
4e052af
Fix broken test
joshdholtz Dec 29, 2021
2239b1d
Fix broken test... again
joshdholtz Dec 29, 2021
42ef1b7
Ignore package-lock.json, try using rn/yarn_install on circleci, move…
joshdholtz Jan 3, 2022
1cd69fc
Trying to get yarn_install to run in the example directory
joshdholtz Jan 3, 2022
60735a0
Change yarn cache folder
joshdholtz Jan 3, 2022
f238ce8
Try bringing in the yarn install from the orb for testing
joshdholtz Jan 3, 2022
9f7b4d9
Try yarn cwd before calling rn/yarn_install
joshdholtz Jan 3, 2022
84226f7
That didn't work
joshdholtz Jan 3, 2022
f2505ba
This should fix android
joshdholtz Jan 3, 2022
13c11ad
This should fix macos symlink issue
joshdholtz Jan 3, 2022
2ac8df6
Reset cache to see if fix worked
joshdholtz Jan 3, 2022
ccd9151
Lets start over on circleci
joshdholtz Jan 3, 2022
23919bb
Add path for yarn pod
joshdholtz Jan 3, 2022
0549cf0
Experimenting
joshdholtz Jan 3, 2022
6264551
This should do it
joshdholtz Jan 3, 2022
92a68bf
--cwd doesnt work with yarn pods
joshdholtz Jan 3, 2022
e656e8d
Need to warn install both examples
joshdholtz Jan 3, 2022
4ad51cc
Try with rn/yarn_install but copied over with path param
joshdholtz Jan 3, 2022
03b5b48
Forgot to replace cache path
joshdholtz Jan 3, 2022
55e8ee2
Cleanup because things works :)
joshdholtz Jan 3, 2022
fb32dab
Need to put path to ios directory
joshdholtz Jan 3, 2022
d45adc2
Use conditional logic and use --cwd if not empty string
joshdholtz Jan 3, 2022
f9b5e97
Rename to use standard revenuecat tester package and bundle id
joshdholtz Jan 3, 2022
74810a5
Bump to react-native-community/[email protected]
joshdholtz Jan 4, 2022
422a4f2
Rename isSetup to hasKeys
joshdholtz Jan 5, 2022
8843578
Setup local testing for PurchaseTester Typescript (#326)
joshdholtz Jan 11, 2022
01e36e9
Rename storekit config file and add second target that does not use s…
joshdholtz Jan 11, 2022
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
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
pod_install_directory: examples/purchaseTester/ios
- rn/pod_install:
pod_install_directory: examples/purchaseTesterTypescript/ios
- rn/yarn_install:
cache_folder: ~/.cache/yarn
- rn/ios_build:
build_configuration: Release
device: iPhone 11 Pro
Expand Down
4 changes: 3 additions & 1 deletion examples/purchaseTesterTypescript/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
rootProject.name = 'PurchaseTester'

include ':react-native-purchases'
project(':react-native-purchases').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-purchases/android')
project(':react-native-purchases').projectDir = new File(rootProject.projectDir, '../../../android')

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
7 changes: 5 additions & 2 deletions examples/purchaseTesterTypescript/app/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ const HomeScreen: React.FC<Props> = ({
// currently passing fetchData to components and screens
// so everything can be refreshed
Purchases.addPurchaserInfoUpdateListener(fetchData);
fetchData();

// Oddly the cleanest way to call an async function
// from a non-asyn function
setTimeout(fetchData, 1)
}, []);

// Gets purchaser info, app user id, if user is anonymous, and offerings
Expand Down Expand Up @@ -213,4 +216,4 @@ const styles = StyleSheet.create({
}
});

export default HomeScreen;
export default HomeScreen;
5 changes: 1 addition & 4 deletions examples/purchaseTesterTypescript/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
platform :ios, '11.0'

target 'PurchaseTester' do
# Pods for ReactNativeSample
pod 'RNPurchases', :path => '../../../'

config = use_native_modules!

use_react_native!(
Expand All @@ -31,4 +28,4 @@ target 'PurchaseTester' do
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
end
6 changes: 3 additions & 3 deletions examples/purchaseTesterTypescript/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ DEPENDENCIES:
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- RNPurchases (from `../../../`)
- RNPurchases (from `../../..`)
- RNScreens (from `../node_modules/react-native-screens`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

Expand Down Expand Up @@ -494,7 +494,7 @@ EXTERNAL SOURCES:
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
RNPurchases:
:path: "../../../"
:path: "../../.."
RNScreens:
:path: "../node_modules/react-native-screens"
Yoga:
Expand Down Expand Up @@ -552,6 +552,6 @@ SPEC CHECKSUMS:
Yoga: e7dc4e71caba6472ff48ad7d234389b91dadc280
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 33ed4a8d19e916379fff8d32a64e33f1b80d7738
PODFILE CHECKSUM: cd6af7a9d5d8dd302a106b9b100d159909f7f592

COCOAPODS: 1.11.2
43 changes: 33 additions & 10 deletions examples/purchaseTesterTypescript/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,36 @@
* @format
*/

module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};
// IMPORTANT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mind updating our notion docs here once this is merged?

// Make sure `npm install` is run in this referenced package's directory
// This package will be looking for node_modules in its own directory
const packagePath = require('path').resolve('../../');

module.exports = {
resolver: {
// Tells metro to look at for `react-native-purchases`
// This fixes issues with referencing file in package.json which
// creates a symlink and metro can't handle symlinks
nodeModulesPaths: [packagePath],

// Tells metro to first look in the package.json's source,then react-native then main
// This is needed so that metro uses the 'source' for `react-native-purchases` and
// not the 'dist'
resolverMainFields: ['source', 'react-native', 'main'], // will first look the source then main
},

// Metro will automatically update when something is changed in this path
watchFolders: [
packagePath
],

transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};

1 change: 0 additions & 1 deletion examples/purchaseTesterTypescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"@react-navigation/native-stack": "^6.2.5",
"react": "17.0.2",
"react-native": "0.66.4",
"react-native-purchases": "^4.5.0",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "^3.10.1"
},
Expand Down
10 changes: 10 additions & 0 deletions examples/purchaseTesterTypescript/react-native.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
dependencies: {
// This is used for auto linking because `react-native link <dep>` will
// soon be deprecated
// This is essentiallly an auto linking definition for local dependencies
'react-native-purchases': {
root: require('path').resolve("../../../")
},
},
};