Skip to content

Commit 4f00a30

Browse files
committed
Autogenerate manifest from env, update intents
1 parent 0e5b26e commit 4f00a30

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,6 @@ sample/vendor
103103
!.yarn/releases
104104
!.yarn/sdks
105105
!.yarn/versions
106+
107+
# Sample app
108+
sample/**/AndroidManifest.xml

sample/android/app/src/main/AndroidManifest.xml renamed to sample/android/app/src/main/AndroidManifest.xml.template

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
22

33
<uses-permission android:name="android.permission.INTERNET" />
4+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
5+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
46

57
<application
68
android:name=".MainApplication"
@@ -17,9 +19,21 @@
1719
android:launchMode="singleTask"
1820
android:windowSoftInputMode="adjustResize"
1921
android:exported="true">
22+
23+
<!-- This action signifies that the activity is the entry point of the application -->
2024
<intent-filter>
2125
<action android:name="android.intent.action.MAIN" />
2226
<category android:name="android.intent.category.LAUNCHER" />
27+
</intent-filter>
28+
29+
<!-- Configuration for app linking -->
30+
<intent-filter>
31+
<action android:name="android.intent.action.VIEW" />
32+
<category android:name="android.intent.category.DEFAULT" />
33+
<category android:name="android.intent.category.BROWSABLE" />
34+
35+
<!-- Note: the host here will be replaced on application start -->
36+
<data android:scheme="https" android:host="{STOREFRONT_DOMAIN}" />
2337
</intent-filter>
2438
</activity>
2539
</application>

sample/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"build:ios": "sh ./scripts/build_ios",
1212
"lint": "yarn typecheck && eslint .",
1313
"ios": "react-native run-ios --simulator 'iPhone 15 Pro'",
14-
"start": "react-native start -- --simulator 'iPhone 15 Pro'",
14+
"start": "./scripts/prestart && react-native start -- --simulator 'iPhone 15 Pro' --reset-cache",
1515
"typecheck": "tsc --noEmit",
1616
"test:ios": "sh ./scripts/test_ios",
1717
"test:android": "sh ./scripts/test_android"

sample/scripts/generate_manifest

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
DIR=android/app/src/main
6+
MANIFEST=AndroidManifest.xml
7+
8+
# Ensure env exists
9+
if [ ! -f .env ]; then
10+
echo "sample/.env file not found!" >&2
11+
exit 1
12+
fi
13+
14+
# Read env file
15+
source .env
16+
17+
# Ensure STOREFRONT_DOMAIN is set
18+
if [ -z "$STOREFRONT_DOMAIN" ]; then
19+
echo "Error: STOREFRONT_DOMAIN is not set in the .env file!" >&2
20+
exit 1
21+
fi
22+
23+
# Check if manifest already exists
24+
if [ -f "$DIR/$MANIFEST" ]; then
25+
echo "\"$MANIFEST\" already exists. Skipping template replacement."
26+
exit 0
27+
else
28+
cp "$DIR/$MANIFEST.template" "$DIR/$MANIFEST" || { echo "Failed to copy template!" >&2; exit 1; }
29+
30+
# Replace STOREFRONT_DOMAIN value with the value from .env
31+
sed -i '' "s|{STOREFRONT_DOMAIN}|$STOREFRONT_DOMAIN|g" "$DIR/$MANIFEST" || { echo "Failed to generate $MANIFEST from template" >&2; exit 1; }
32+
echo "✅ Generated \"$DIR/$MANIFEST\""
33+
fi

sample/scripts/prestart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
./scripts/generate_manifest

0 commit comments

Comments
 (0)