Skip to content

Commit

Permalink
Create an up to date example project targeting React Native 0.64
Browse files Browse the repository at this point in the history
  • Loading branch information
levibuzolic committed May 18, 2021
1 parent c25bfae commit 1ede470
Show file tree
Hide file tree
Showing 70 changed files with 8,869 additions and 1,536 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

name: Android Build

# Controls when the action will run.
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
Expand All @@ -19,18 +19,14 @@ jobs:
steps:
- name: Checkout the code
uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: '14'

- uses: c-hive/gha-yarn-cache@v1

- name: Change directory
run: cd ExampleProject/

- uses: c-hive/gha-yarn-cache@v1
- name: Yarn
run: yarn install
run: cd ExampleProject && yarn install

- name: Cache Gradle Wrapper
uses: actions/cache@v2
Expand All @@ -47,8 +43,8 @@ jobs:
${{ runner.os }}-gradle-caches-
- name: Make Gradlew Executable
run: cd android && chmod +x ./gradlew
run: cd ExampleProject/android && chmod +x ./gradlew

- name: Build Android App Bundle
run: |
cd android && ./gradlew bundleRelease --no-daemon
cd ExampleProject/android && ./gradlew bundleRelease --no-daemon
3 changes: 3 additions & 0 deletions ExampleProject/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Windows files
[*.bat]
end_of_line = crlf
4 changes: 4 additions & 0 deletions ExampleProject/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
};
80 changes: 44 additions & 36 deletions ExampleProject/.flowconfig
Original file line number Diff line number Diff line change
@@ -1,58 +1,66 @@
[ignore]

# We fork some components by platform.
; We fork some components by platform
.*/*[.]android.js

# Ignore templates with `@flow` in header
.*/local-cli/generator.*

# Ignore malformed json
.*/node_modules/y18n/test/.*\.json

# Ignore the website subdir
<PROJECT_ROOT>/website/.*

# Ignore BUCK generated dirs
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

# Ignore unexpected extra @providesModule
.*/node_modules/commoner/test/source/widget/share.js
; Ignore polyfills
node_modules/react-native/Libraries/polyfills/.*

# Ignore duplicate module providers
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js
.*/node_modules/jest-runtime/build/__tests__/.*
; Flow doesn't support platforms
.*/Libraries/Utilities/LoadingView.js

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow
flow/
node_modules/react-native/interface.js
node_modules/react-native/flow/

[options]
module.system=haste
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
exact_by_default=true

experimental.strict_type_args=true
module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js

munge_underscores=true

module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-2]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-2]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy

unsafe.enable_getters_and_setters=true
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
sketchy-number=warn
untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
unnecessary-invariant=warn
signature-verification-failure=warn

[strict]
deprecated-type
nonstrict-import
sketchy-null
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

[version]
^0.32.0
^0.137.0
3 changes: 3 additions & 0 deletions ExampleProject/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Windows files should use crlf line endings
# https://help.github.com/articles/dealing-with-line-endings/
*.bat text eol=crlf
28 changes: 23 additions & 5 deletions ExampleProject/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,40 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IJ
# Android/IntelliJ
#
*.iml
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/
7 changes: 7 additions & 0 deletions ExampleProject/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'avoid',
};
101 changes: 101 additions & 0 deletions ExampleProject/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/

import * as React from 'react';
import {SafeAreaView, ScrollView, View, StyleSheet, Text} from 'react-native';
import JailMonkey from 'jail-monkey';

/*
const JailMonkey: {
isJailBroken: () => boolean;
hookDetected: () => boolean;
isDebuggedMode: () => Promise<boolean>;
canMockLocation: () => boolean;
trustFall: () => boolean;
isOnExternalStorage: () => boolean;
AdbEnabled: () => boolean;
isDevelopmentSettingsMode: () => Promise<boolean>;
}
*/

export default function App() {
const [isDevelopmentSettingsMode, setIsDevelopmentSettingsMode] =
React.useState();
const [isDebuggedMode, setIsDebuggedMode] = React.useState();

React.useEffect(() => {
JailMonkey.isDevelopmentSettingsMode()
.then(value => {
setIsDevelopmentSettingsMode(value);
})
.catch(console.warn);
}, []);

React.useEffect(() => {
JailMonkey.isDebuggedMode()
.then(value => {
setIsDebuggedMode(value);
})
.catch(console.warn);
}, []);

return (
<SafeAreaView style={styles.root}>
<View style={styles.content} accessible={false} accessibilityLabel="">
<Row label="isJailBroken" value={JailMonkey.isJailBroken()} />
<Row label="canMockLocation" value={JailMonkey.canMockLocation()} />
<Row label="trustFall" value={JailMonkey.trustFall()} />
<Row label="hookDetected" value={JailMonkey.hookDetected()} />
<Row
label="isOnExternalStorage"
value={JailMonkey.isOnExternalStorage()}
/>
<Row label="AdbEnabled" value={JailMonkey.AdbEnabled()} />
<Row
label="isDevelopmentSettingsMode"
value={isDevelopmentSettingsMode}
/>
<Row label="isDebuggedMode" value={isDebuggedMode} />
</View>
</SafeAreaView>
);
}

function Row({label, value}) {
return (
<View
style={styles.row}
accessibilityLabel={`${label}: ${value?.toString() ?? 'unknown'}`}>
<Text style={styles.label}>{label}:</Text>
<Text style={styles.value}>{value?.toString() ?? 'unknown'}</Text>
</View>
);
}

const styles = StyleSheet.create({
root: {
flex: 1,
},
content: {
padding: 20,
},
row: {
flexDirection: 'row',
marginBottom: 5,
},
label: {
fontSize: 16,
color: 'black',
fontWeight: '700',
marginRight: 10,
},
value: {
fontSize: 16,
color: 'black',
},
});
14 changes: 14 additions & 0 deletions ExampleProject/__tests__/App-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @format
*/

import 'react-native';
import React from 'react';
import App from '../App';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
renderer.create(<App />);
});
66 changes: 0 additions & 66 deletions ExampleProject/android/app/BUCK

This file was deleted.

Loading

0 comments on commit 1ede470

Please sign in to comment.