-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
382 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
open_collective: react-native-iap | ||
buy_me_a_coffee: dooboolab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./plugin/build/withIAP'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
const appBuildGradleWithoutIAP = ` | ||
apply plugin: "com.android.application" | ||
import com.android.build.OutputFile | ||
def reactNativeArchitectures() { | ||
def value = project.getProperties().get("reactNativeArchitectures") | ||
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] | ||
} | ||
android { | ||
ndkVersion rootProject.ext.ndkVersion | ||
compileSdkVersion rootProject.ext.compileSdkVersion | ||
defaultConfig { | ||
applicationId 'com.test.withIAP' | ||
minSdkVersion rootProject.ext.minSdkVersion | ||
targetSdkVersion rootProject.ext.targetSdkVersion | ||
versionCode 34 | ||
versionName "1.16.2" | ||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()`; | ||
|
||
const appBuildGradleWithPlayStoreIAP = ` | ||
apply plugin: "com.android.application" | ||
import com.android.build.OutputFile | ||
def reactNativeArchitectures() { | ||
def value = project.getProperties().get("reactNativeArchitectures") | ||
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] | ||
} | ||
android { | ||
ndkVersion rootProject.ext.ndkVersion | ||
compileSdkVersion rootProject.ext.compileSdkVersion | ||
defaultConfig { | ||
missingDimensionStrategy "store", "play" | ||
applicationId 'com.test.withIAP' | ||
minSdkVersion rootProject.ext.minSdkVersion | ||
targetSdkVersion rootProject.ext.targetSdkVersion | ||
versionCode 34 | ||
versionName "1.16.2" | ||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()`; | ||
|
||
const appBuildGradleWithAmazonStoreIAP = ` | ||
apply plugin: "com.android.application" | ||
import com.android.build.OutputFile | ||
def reactNativeArchitectures() { | ||
def value = project.getProperties().get("reactNativeArchitectures") | ||
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] | ||
} | ||
android { | ||
ndkVersion rootProject.ext.ndkVersion | ||
compileSdkVersion rootProject.ext.compileSdkVersion | ||
defaultConfig { | ||
missingDimensionStrategy "store", "amazon" | ||
applicationId 'com.test.withIAP' | ||
minSdkVersion rootProject.ext.minSdkVersion | ||
targetSdkVersion rootProject.ext.targetSdkVersion | ||
versionCode 34 | ||
versionName "1.16.2" | ||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()`; | ||
|
||
const appBuildGradleWithBothIAP = ` | ||
apply plugin: "com.android.application" | ||
import com.android.build.OutputFile | ||
def reactNativeArchitectures() { | ||
def value = project.getProperties().get("reactNativeArchitectures") | ||
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] | ||
} | ||
android { | ||
ndkVersion rootProject.ext.ndkVersion | ||
compileSdkVersion rootProject.ext.compileSdkVersion | ||
flavorDimensions "appstore" | ||
productFlavors { | ||
googlePlay { | ||
dimension "appstore" | ||
missingDimensionStrategy "store", "play" | ||
} | ||
amazon { | ||
dimension "appstore" | ||
missingDimensionStrategy "store", "amazon" | ||
} | ||
} | ||
defaultConfig { | ||
applicationId 'com.test.withIAP' | ||
minSdkVersion rootProject.ext.minSdkVersion | ||
targetSdkVersion rootProject.ext.targetSdkVersion | ||
versionCode 34 | ||
versionName "1.16.2" | ||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()`; | ||
|
||
const projectBuildGradleWithoutIAP = ` | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
buildscript { | ||
ext { | ||
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0' | ||
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21') | ||
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31') | ||
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31') | ||
if (findProperty('android.kotlinVersion')) { | ||
kotlinVersion = findProperty('android.kotlinVersion') | ||
} | ||
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0' | ||
if (System.properties['os.arch'] == 'aarch64') { | ||
// For M1 Users we need to use the NDK 24 which added support for aarch64 | ||
ndkVersion = '24.0.8215888' | ||
} else { | ||
// Otherwise we default to the side-by-side NDK version from AGP. | ||
ndkVersion = '21.4.7075529' | ||
} | ||
} | ||
}`; | ||
|
||
const projectBuildGradleWithIAP = ` | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
buildscript { | ||
ext { | ||
supportLibVersion = "28.0.0" | ||
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0' | ||
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21') | ||
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31') | ||
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31') | ||
if (findProperty('android.kotlinVersion')) { | ||
kotlinVersion = findProperty('android.kotlinVersion') | ||
} | ||
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0' | ||
if (System.properties['os.arch'] == 'aarch64') { | ||
// For M1 Users we need to use the NDK 24 which added support for aarch64 | ||
ndkVersion = '24.0.8215888' | ||
} else { | ||
// Otherwise we default to the side-by-side NDK version from AGP. | ||
ndkVersion = '21.4.7075529' | ||
} | ||
} | ||
}`; | ||
|
||
export { | ||
appBuildGradleWithAmazonStoreIAP, | ||
appBuildGradleWithBothIAP, | ||
appBuildGradleWithoutIAP, | ||
appBuildGradleWithPlayStoreIAP, | ||
projectBuildGradleWithIAP, | ||
projectBuildGradleWithoutIAP, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import {modifyAppBuildGradle, modifyProjectBuildGradle} from '../src/withIAP'; | ||
|
||
import { | ||
appBuildGradleWithAmazonStoreIAP, | ||
appBuildGradleWithBothIAP, | ||
appBuildGradleWithoutIAP, | ||
appBuildGradleWithPlayStoreIAP, | ||
projectBuildGradleWithIAP, | ||
projectBuildGradleWithoutIAP, | ||
} from './fixtures/buildGradleFiles'; | ||
|
||
jest.mock('expo/config-plugins', () => { | ||
const plugins = jest.requireActual('expo/config-plugins'); | ||
|
||
return { | ||
...plugins, | ||
WarningAggregator: {addWarningAndroid: jest.fn()}, | ||
}; | ||
}); | ||
|
||
describe('Configures Android native project correctly', () => { | ||
it(`Add supportLibVersion to android/build.gradle if it is not present`, () => { | ||
expect(modifyProjectBuildGradle(projectBuildGradleWithoutIAP)).toMatch( | ||
projectBuildGradleWithIAP, | ||
); | ||
}); | ||
|
||
it(`Add play store missingDimenstionStrategy to android/app/build.gradle if is not present`, () => { | ||
expect( | ||
modifyAppBuildGradle(appBuildGradleWithoutIAP, 'Play Store'), | ||
).toMatch(appBuildGradleWithPlayStoreIAP); | ||
}); | ||
|
||
it(`Add amazon store missingDimenstionStrategy to android/app/build.gradle if is not present`, () => { | ||
expect( | ||
modifyAppBuildGradle(appBuildGradleWithoutIAP, 'Amazon AppStore'), | ||
).toMatch(appBuildGradleWithAmazonStoreIAP); | ||
}); | ||
|
||
it(`Add play store and amazon payment providers to android/app/build.gradle if is not present`, () => { | ||
expect(modifyAppBuildGradle(appBuildGradleWithoutIAP, 'both')).toMatch( | ||
appBuildGradleWithBothIAP, | ||
); | ||
}); | ||
it(`Doesn't modify android/build.gradle if supportLibVersion already configured`, () => { | ||
expect(modifyProjectBuildGradle(projectBuildGradleWithIAP)).toMatch( | ||
projectBuildGradleWithIAP, | ||
); | ||
}); | ||
|
||
it(`Doesn't modify android/app/build.gradle if missingDimensionStrategy already configured`, () => { | ||
expect( | ||
modifyAppBuildGradle(appBuildGradleWithPlayStoreIAP, 'Play Store'), | ||
).toMatch(appBuildGradleWithPlayStoreIAP); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// In documentation there is `preset: expo-module-scripts`, but it runs tests for every platform (ios, android, web, node) | ||
// We need only node tests right now | ||
module.exports = { | ||
preset: 'jest-expo/node', | ||
}; |
Oops, something went wrong.