Skip to content

Commit 7108aa7

Browse files
hoxyqfacebook-github-bot
authored andcommitted
| RN Monorepo | Migrate to package (#36434)
Summary: Pull Request resolved: facebook/react-native#36434 Changelog: [Internal] This is a squashed stack of 18 commits, starting from D43202126 allow-large-files Reviewed By: cortinico Differential Revision: D43977381 fbshipit-source-id: 0da552ddb85f2f61a0be0ef071915b35f3f8555c Original-Commit: facebook/react-native@714b502
1 parent 65bdf83 commit 7108aa7

Some content is hidden

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

57 files changed

+2267
-0
lines changed

template/App.tsx

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
*/
7+
8+
import React from 'react';
9+
import type {PropsWithChildren} from 'react';
10+
import {
11+
SafeAreaView,
12+
ScrollView,
13+
StatusBar,
14+
StyleSheet,
15+
Text,
16+
useColorScheme,
17+
View,
18+
} from 'react-native';
19+
20+
import {
21+
Colors,
22+
DebugInstructions,
23+
Header,
24+
LearnMoreLinks,
25+
ReloadInstructions,
26+
} from 'react-native/Libraries/NewAppScreen';
27+
28+
type SectionProps = PropsWithChildren<{
29+
title: string;
30+
}>;
31+
32+
function Section({children, title}: SectionProps): JSX.Element {
33+
const isDarkMode = useColorScheme() === 'dark';
34+
return (
35+
<View style={styles.sectionContainer}>
36+
<Text
37+
style={[
38+
styles.sectionTitle,
39+
{
40+
color: isDarkMode ? Colors.white : Colors.black,
41+
},
42+
]}>
43+
{title}
44+
</Text>
45+
<Text
46+
style={[
47+
styles.sectionDescription,
48+
{
49+
color: isDarkMode ? Colors.light : Colors.dark,
50+
},
51+
]}>
52+
{children}
53+
</Text>
54+
</View>
55+
);
56+
}
57+
58+
function App(): JSX.Element {
59+
const isDarkMode = useColorScheme() === 'dark';
60+
61+
const backgroundStyle = {
62+
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
63+
};
64+
65+
return (
66+
<SafeAreaView style={backgroundStyle}>
67+
<StatusBar
68+
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
69+
backgroundColor={backgroundStyle.backgroundColor}
70+
/>
71+
<ScrollView
72+
contentInsetAdjustmentBehavior="automatic"
73+
style={backgroundStyle}>
74+
<Header />
75+
<View
76+
style={{
77+
backgroundColor: isDarkMode ? Colors.black : Colors.white,
78+
}}>
79+
<Section title="Step One">
80+
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
81+
screen and then come back to see your edits.
82+
</Section>
83+
<Section title="See Your Changes">
84+
<ReloadInstructions />
85+
</Section>
86+
<Section title="Debug">
87+
<DebugInstructions />
88+
</Section>
89+
<Section title="Learn More">
90+
Read the docs to discover what to do next:
91+
</Section>
92+
<LearnMoreLinks />
93+
</View>
94+
</ScrollView>
95+
</SafeAreaView>
96+
);
97+
}
98+
99+
const styles = StyleSheet.create({
100+
sectionContainer: {
101+
marginTop: 32,
102+
paddingHorizontal: 24,
103+
},
104+
sectionTitle: {
105+
fontSize: 24,
106+
fontWeight: '600',
107+
},
108+
sectionDescription: {
109+
marginTop: 8,
110+
fontSize: 18,
111+
fontWeight: '400',
112+
},
113+
highlight: {
114+
fontWeight: '700',
115+
},
116+
});
117+
118+
export default App;

template/Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby ">= 2.6.10"
5+
6+
gem 'cocoapods', '~> 1.12'

template/__tests__/App.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import App from '../App';
8+
9+
// Note: import explicitly to use the types shiped with jest.
10+
import {it} from '@jest/globals';
11+
12+
// Note: test renderer must be required after react-native.
13+
import renderer from 'react-test-renderer';
14+
15+
it('renders correctly', () => {
16+
renderer.create(<App />);
17+
});

template/_bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

template/_eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native',
4+
};

template/_gitignore

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
ios/.xcode.env.local
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
*.hprof
33+
.cxx/
34+
*.keystore
35+
!debug.keystore
36+
37+
# node.js
38+
#
39+
node_modules/
40+
npm-debug.log
41+
yarn-error.log
42+
43+
# fastlane
44+
#
45+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
46+
# screenshots whenever they are needed.
47+
# For more information about the recommended setup visit:
48+
# https://docs.fastlane.tools/best-practices/source-control/
49+
50+
**/fastlane/report.xml
51+
**/fastlane/Preview.html
52+
**/fastlane/screenshots
53+
**/fastlane/test_output
54+
55+
# Bundle artifact
56+
*.jsbundle
57+
58+
# Ruby / CocoaPods
59+
/ios/Pods/
60+
/vendor/bundle/
61+
62+
# Temporary files created by Metro to check the health of the file watcher
63+
.metro-health-check*
64+
65+
# testing
66+
/coverage

template/_prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
bracketSameLine: true,
4+
bracketSpacing: false,
5+
singleQuote: true,
6+
trailingComma: 'all',
7+
};

template/_watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

template/android/app/build.gradle

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
apply plugin: "com.android.application"
2+
apply plugin: "com.facebook.react"
3+
4+
/**
5+
* This is the configuration block to customize your React Native Android app.
6+
* By default you don't need to apply any configuration, just uncomment the lines you need.
7+
*/
8+
react {
9+
/* Folders */
10+
// The root of your project, i.e. where "package.json" lives. Default is '..'
11+
// root = file("../")
12+
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
13+
// reactNativeDir = file("../node_modules/react-native")
14+
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
15+
// codegenDir = file("../node_modules/@react-native/codegen")
16+
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
17+
// cliFile = file("../node_modules/react-native/cli.js")
18+
19+
/* Variants */
20+
// The list of variants to that are debuggable. For those we're going to
21+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
22+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
23+
// debuggableVariants = ["liteDebug", "prodDebug"]
24+
25+
/* Bundling */
26+
// A list containing the node command and its flags. Default is just 'node'.
27+
// nodeExecutableAndArgs = ["node"]
28+
//
29+
// The command to run when bundling. By default is 'bundle'
30+
// bundleCommand = "ram-bundle"
31+
//
32+
// The path to the CLI configuration file. Default is empty.
33+
// bundleConfig = file(../rn-cli.config.js)
34+
//
35+
// The name of the generated asset file containing your JS bundle
36+
// bundleAssetName = "MyApplication.android.bundle"
37+
//
38+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
39+
// entryFile = file("../js/MyApplication.android.js")
40+
//
41+
// A list of extra flags to pass to the 'bundle' commands.
42+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
43+
// extraPackagerArgs = []
44+
45+
/* Hermes Commands */
46+
// The hermes compiler command to run. By default it is 'hermesc'
47+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
48+
//
49+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
50+
// hermesFlags = ["-O", "-output-source-map"]
51+
}
52+
53+
/**
54+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
55+
*/
56+
def enableProguardInReleaseBuilds = false
57+
58+
/**
59+
* The preferred build flavor of JavaScriptCore (JSC)
60+
*
61+
* For example, to use the international variant, you can use:
62+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
63+
*
64+
* The international variant includes ICU i18n library and necessary data
65+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
66+
* give correct results when using with locales other than en-US. Note that
67+
* this variant is about 6MiB larger per architecture than default.
68+
*/
69+
def jscFlavor = 'org.webkit:android-jsc:+'
70+
71+
android {
72+
ndkVersion rootProject.ext.ndkVersion
73+
74+
compileSdkVersion rootProject.ext.compileSdkVersion
75+
76+
namespace "com.helloworld"
77+
defaultConfig {
78+
applicationId "com.helloworld"
79+
minSdkVersion rootProject.ext.minSdkVersion
80+
targetSdkVersion rootProject.ext.targetSdkVersion
81+
versionCode 1
82+
versionName "1.0"
83+
}
84+
signingConfigs {
85+
debug {
86+
storeFile file('debug.keystore')
87+
storePassword 'android'
88+
keyAlias 'androiddebugkey'
89+
keyPassword 'android'
90+
}
91+
}
92+
buildTypes {
93+
debug {
94+
signingConfig signingConfigs.debug
95+
}
96+
release {
97+
// Caution! In production, you need to generate your own keystore file.
98+
// see https://reactnative.dev/docs/signed-apk-android.
99+
signingConfig signingConfigs.debug
100+
minifyEnabled enableProguardInReleaseBuilds
101+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
102+
}
103+
}
104+
}
105+
106+
dependencies {
107+
// The version of react-native is set by the React Native Gradle Plugin
108+
implementation("com.facebook.react:react-android")
109+
110+
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
111+
112+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
113+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
114+
exclude group:'com.squareup.okhttp3', module:'okhttp'
115+
}
116+
117+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
118+
if (hermesEnabled.toBoolean()) {
119+
implementation("com.facebook.react:hermes-android")
120+
} else {
121+
implementation jscFlavor
122+
}
123+
}
124+
125+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
2.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)