diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ffb6306..255c0e14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,6 +87,7 @@ jobs: - name: Run Android tests run: | + echo "STOREFRONT_DOMAIN=\"myshopify.com\"" > sample/.env yarn module build yarn sample test:android --no-daemon diff --git a/.gitignore b/.gitignore index 5fddb681..86e3ab40 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,6 @@ sample/vendor !.yarn/releases !.yarn/sdks !.yarn/versions + +# Sample app +sample/**/AndroidManifest.xml diff --git a/sample/android/app/build.gradle b/sample/android/app/build.gradle index 3ba86a41..af6737ac 100644 --- a/sample/android/app/build.gradle +++ b/sample/android/app/build.gradle @@ -146,3 +146,21 @@ apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle") apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" + +def properties = loadProperties() +def storefrontDomain = properties.getProperty("STOREFRONT_DOMAIN") + +if (!storefrontDomain) { + println("**** Please add a .env file with STOREFRONT_DOMAIN set *****") +} + +task generateAndroidManifestFromTemplate { + doLast { + def templateFile = file('src/main/AndroidManifest.template.xml') + def outputFile = file('src/main/AndroidManifest.xml') + def content = templateFile.getText('UTF-8').replace('{{STOREFRONT_DOMAIN}}', "$storefrontDomain") + outputFile.write(content, 'UTF-8') + } +} + +preBuild.dependsOn(generateAndroidManifestFromTemplate) diff --git a/sample/android/app/src/main/AndroidManifest.xml b/sample/android/app/src/main/AndroidManifest.template.xml similarity index 58% rename from sample/android/app/src/main/AndroidManifest.xml rename to sample/android/app/src/main/AndroidManifest.template.xml index f9fabb24..518b9838 100644 --- a/sample/android/app/src/main/AndroidManifest.xml +++ b/sample/android/app/src/main/AndroidManifest.template.xml @@ -1,6 +1,8 @@ + + + + + + + + + + + + + + diff --git a/sample/android/build.gradle b/sample/android/build.gradle index 9b468431..9ace25d2 100644 --- a/sample/android/build.gradle +++ b/sample/android/build.gradle @@ -20,4 +20,12 @@ buildscript { } } +def loadProperties() { + def props = new Properties() + file('../.env').withInputStream { + props.load(it) + } + return props +} + apply plugin: "com.facebook.react.rootproject" diff --git a/sample/package.json b/sample/package.json index 603e87a9..7291591b 100644 --- a/sample/package.json +++ b/sample/package.json @@ -11,7 +11,7 @@ "build:ios": "sh ./scripts/build_ios", "lint": "yarn typecheck && eslint .", "ios": "react-native run-ios --simulator 'iPhone 15 Pro'", - "start": "react-native start -- --simulator 'iPhone 15 Pro'", + "start": "react-native start -- --simulator 'iPhone 15 Pro' --reset-cache", "typecheck": "tsc --noEmit", "test:ios": "sh ./scripts/test_ios", "test:android": "sh ./scripts/test_android"