Skip to content

Commit ee7c02f

Browse files
committed
chore: add example project
1 parent e548700 commit ee7c02f

File tree

104 files changed

+18346
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+18346
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ Add the build cache provider to your `app.json` or `app.config.js`:
5454
{
5555
"expo": {
5656
"experiments": {
57-
"buildCacheProvider": {
58-
"plugin": "@eggl-js/expo-github-cache",
59-
"options": {
60-
"owner": "your-github-username",
61-
"repo": "your-repo-name"
57+
"remoteBuildCache": {
58+
"provider": {
59+
"plugin": "@eggl-js/expo-github-cache",
60+
"options": {
61+
"owner": "demo-org",
62+
"repo": "demo-repo",
63+
}
64+
}
6265
}
63-
}
6466
}
6567
}
6668
}

example/.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
6+
# Expo
7+
.expo/
8+
dist/
9+
web-build/
10+
expo-env.d.ts
11+
12+
# Native
13+
.kotlin/
14+
*.orig.*
15+
*.jks
16+
*.p8
17+
*.p12
18+
*.key
19+
*.mobileprovision
20+
21+
# Metro
22+
.metro-health-check*
23+
24+
# debug
25+
npm-debug.*
26+
yarn-debug.*
27+
yarn-error.*
28+
29+
# macOS
30+
.DS_Store
31+
*.pem
32+
33+
# local env files
34+
.env*.local
35+
36+
# typescript
37+
*.tsbuildinfo
38+
39+
app-example

example/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Expo GitHub Cache Example
2+
3+
This is a basic example of how to use the Expo GitHub Cache plugin in your Expo project. This plugin allows you to cache your build artifacts on GitHub, which can significantly speed up your build times by reusing previously built artifacts.
4+
5+
> [!NOTE]
6+
> Obviously this plugin does not support Expo Go, as it requires a custom build process. It is designed to work with the `expo run:ios` and `expo run:android` commands.
7+
8+
## Get Started
9+
The app.json defines the configuration for the Expo GitHub Cache plugin. It specifies a demo organization and repository where the build cache will be stored. The `owner` and `repo` fields should be replaced with your actual GitHub organization and repository names.
10+
11+
```json
12+
{
13+
"expo": {
14+
"experiments": {
15+
"remoteBuildCache": {
16+
"provider": {
17+
"plugin": "@eggl-js/expo-github-cache",
18+
"options": {
19+
"owner": "demo-org",
20+
"repo": "demo-repo"
21+
}
22+
}
23+
}
24+
}
25+
}
26+
}
27+
```
28+
29+
Also make sure to set the `GITHUB_TOKEN` environment variable with your GitHub Personal Access Token. This token should have the necessary permissions to read and write to the specified repository.
30+
31+
```bash
32+
export GITHUB_TOKEN=your_github_token_here
33+
```
34+
35+
Now start the Expo project using the following command, as the build cache will be automatically used during the build process:
36+
37+
```bash
38+
npx expo run:ios
39+
npx expo run:android
40+
```

example/android/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Android/IntelliJ
6+
#
7+
build/
8+
.idea
9+
.gradle
10+
local.properties
11+
*.iml
12+
*.hprof
13+
.cxx/
14+
15+
# Bundle artifacts
16+
*.jsbundle

example/android/app/build.gradle

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
apply plugin: "com.android.application"
2+
apply plugin: "org.jetbrains.kotlin.android"
3+
apply plugin: "com.facebook.react"
4+
5+
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
6+
7+
/**
8+
* This is the configuration block to customize your React Native Android app.
9+
* By default you don't need to apply any configuration, just uncomment the lines you need.
10+
*/
11+
react {
12+
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
13+
reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
14+
hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc"
15+
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
16+
17+
enableBundleCompression = (findProperty('android.enableBundleCompression') ?: false).toBoolean()
18+
// Use Expo CLI to bundle the app, this ensures the Metro config
19+
// works correctly with Expo projects.
20+
cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim())
21+
bundleCommand = "export:embed"
22+
23+
/* Folders */
24+
// The root of your project, i.e. where "package.json" lives. Default is '../..'
25+
// root = file("../../")
26+
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
27+
// reactNativeDir = file("../../node_modules/react-native")
28+
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
29+
// codegenDir = file("../../node_modules/@react-native/codegen")
30+
31+
/* Variants */
32+
// The list of variants to that are debuggable. For those we're going to
33+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
34+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
35+
// debuggableVariants = ["liteDebug", "prodDebug"]
36+
37+
/* Bundling */
38+
// A list containing the node command and its flags. Default is just 'node'.
39+
// nodeExecutableAndArgs = ["node"]
40+
41+
//
42+
// The path to the CLI configuration file. Default is empty.
43+
// bundleConfig = file(../rn-cli.config.js)
44+
//
45+
// The name of the generated asset file containing your JS bundle
46+
// bundleAssetName = "MyApplication.android.bundle"
47+
//
48+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
49+
// entryFile = file("../js/MyApplication.android.js")
50+
//
51+
// A list of extra flags to pass to the 'bundle' commands.
52+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
53+
// extraPackagerArgs = []
54+
55+
/* Hermes Commands */
56+
// The hermes compiler command to run. By default it is 'hermesc'
57+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
58+
//
59+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
60+
// hermesFlags = ["-O", "-output-source-map"]
61+
62+
/* Autolinking */
63+
autolinkLibrariesWithApp()
64+
}
65+
66+
/**
67+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
68+
*/
69+
def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInReleaseBuilds') ?: false).toBoolean()
70+
71+
/**
72+
* The preferred build flavor of JavaScriptCore (JSC)
73+
*
74+
* For example, to use the international variant, you can use:
75+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
76+
*
77+
* The international variant includes ICU i18n library and necessary data
78+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
79+
* give correct results when using with locales other than en-US. Note that
80+
* this variant is about 6MiB larger per architecture than default.
81+
*/
82+
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
83+
84+
android {
85+
ndkVersion rootProject.ext.ndkVersion
86+
87+
buildToolsVersion rootProject.ext.buildToolsVersion
88+
compileSdk rootProject.ext.compileSdkVersion
89+
90+
namespace 'com.roberteggl.example'
91+
defaultConfig {
92+
applicationId 'com.roberteggl.example'
93+
minSdkVersion rootProject.ext.minSdkVersion
94+
targetSdkVersion rootProject.ext.targetSdkVersion
95+
versionCode 1
96+
versionName "1.0.0"
97+
}
98+
signingConfigs {
99+
debug {
100+
storeFile file('debug.keystore')
101+
storePassword 'android'
102+
keyAlias 'androiddebugkey'
103+
keyPassword 'android'
104+
}
105+
}
106+
buildTypes {
107+
debug {
108+
signingConfig signingConfigs.debug
109+
}
110+
release {
111+
// Caution! In production, you need to generate your own keystore file.
112+
// see https://reactnative.dev/docs/signed-apk-android.
113+
signingConfig signingConfigs.debug
114+
shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false)
115+
minifyEnabled enableProguardInReleaseBuilds
116+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
117+
crunchPngs (findProperty('android.enablePngCrunchInReleaseBuilds')?.toBoolean() ?: true)
118+
}
119+
}
120+
packagingOptions {
121+
jniLibs {
122+
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
123+
}
124+
}
125+
androidResources {
126+
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
127+
}
128+
}
129+
130+
// Apply static values from `gradle.properties` to the `android.packagingOptions`
131+
// Accepts values in comma delimited lists, example:
132+
// android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini
133+
["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
134+
// Split option: 'foo,bar' -> ['foo', 'bar']
135+
def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
136+
// Trim all elements in place.
137+
for (i in 0..<options.size()) options[i] = options[i].trim();
138+
// `[] - ""` is essentially `[""].filter(Boolean)` removing all empty strings.
139+
options -= ""
140+
141+
if (options.length > 0) {
142+
println "android.packagingOptions.$prop += $options ($options.length)"
143+
// Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
144+
options.each {
145+
android.packagingOptions[prop] += it
146+
}
147+
}
148+
}
149+
150+
dependencies {
151+
// The version of react-native is set by the React Native Gradle Plugin
152+
implementation("com.facebook.react:react-android")
153+
154+
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
155+
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
156+
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
157+
158+
if (isGifEnabled) {
159+
// For animated gif support
160+
implementation("com.facebook.fresco:animated-gif:${expoLibs.versions.fresco.get()}")
161+
}
162+
163+
if (isWebpEnabled) {
164+
// For webp support
165+
implementation("com.facebook.fresco:webpsupport:${expoLibs.versions.fresco.get()}")
166+
if (isWebpAnimatedEnabled) {
167+
// Animated webp support
168+
implementation("com.facebook.fresco:animated-webp:${expoLibs.versions.fresco.get()}")
169+
}
170+
}
171+
172+
if (hermesEnabled.toBoolean()) {
173+
implementation("com.facebook.react:hermes-android")
174+
} else {
175+
implementation jscFlavor
176+
}
177+
}

example/android/app/debug.keystore

2.2 KB
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# react-native-reanimated
11+
-keep class com.swmansion.reanimated.** { *; }
12+
-keep class com.facebook.react.turbomodule.** { *; }
13+
14+
# Add any project specific keep options here:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools">
3+
4+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
5+
6+
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" tools:replace="android:usesCleartextTraffic" />
7+
</manifest>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<uses-permission android:name="android.permission.INTERNET"/>
3+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
4+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
5+
<uses-permission android:name="android.permission.VIBRATE"/>
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
7+
<queries>
8+
<intent>
9+
<action android:name="android.intent.action.VIEW"/>
10+
<category android:name="android.intent.category.BROWSABLE"/>
11+
<data android:scheme="https"/>
12+
</intent>
13+
</queries>
14+
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:supportsRtl="true">
15+
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
16+
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
17+
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
18+
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN"/>
21+
<category android:name="android.intent.category.LAUNCHER"/>
22+
</intent-filter>
23+
<intent-filter>
24+
<action android:name="android.intent.action.VIEW"/>
25+
<category android:name="android.intent.category.DEFAULT"/>
26+
<category android:name="android.intent.category.BROWSABLE"/>
27+
<data android:scheme="example"/>
28+
</intent-filter>
29+
</activity>
30+
</application>
31+
</manifest>

0 commit comments

Comments
 (0)