Skip to content
This repository was archived by the owner on Jan 7, 2026. It is now read-only.

Commit 99e20cc

Browse files
committed
init
1 parent 1a4240a commit 99e20cc

File tree

367 files changed

+5211
-24039
lines changed

Some content is hidden

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

367 files changed

+5211
-24039
lines changed

README.md

Lines changed: 4 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -4,122 +4,12 @@
44

55
### Create Nitro Module
66

7-
> **Important**: Avoid generating a new `node_modules` folder. All dependencies should be managed from the monorepo root to avoid conflicts and ensure proper workspace linking.
8-
9-
10-
1. Create project with `npx create-react-native-library@latest` then select turbo module or turbo view
11-
12-
2. Remove `packageManager` field from `package.json` in the new library, then run `yarn` to install dependencies
13-
14-
3. Generate Nitro module code. Run the following command in the module directory to generate `./nitrogen/generated` files, which are required by both iOS and Android.
15-
16-
4. Modify the `react-native.config.js` file in the example directory of the current project to configure the module dependency.
17-
18-
```Javascript
19-
const path = require('path');
20-
const pkg = require('../package.json');
21-
const baseConfig = require('../../../react-native.base.config');
22-
23-
module.exports = {
24-
...baseConfig,
25-
dependencies: {
26-
[pkg.name]: {
27-
root: path.join(__dirname, '..'),
28-
platforms: {
29-
// Codegen script incorrectly fails without this
30-
// So we explicitly specify the platforms with empty object
31-
ios: {},
32-
android: {},
33-
},
34-
},
35-
},
36-
};
37-
```
38-
5. Run `pod install` in the `example/ios` directory of the current module to install dependencies.
39-
40-
6. Now you can start the example app in iOS Simulator to test the module.
41-
42-
7. Modify the `metro.config.js` file in the example directory to configure the monorepo setup:
43-
44-
```
45-
const path = require('path');
46-
const { getDefaultConfig } = require('@react-native/metro-config');
47-
const { withMetroConfig } = require('react-native-monorepo-config');
48-
49-
const root = path.resolve(__dirname, '..');
50-
51-
/**
52-
* Metro configuration
53-
* https://facebook.github.io/metro/docs/configuration
54-
*
55-
* @type {import('metro-config').MetroConfig}
56-
*/
57-
const workspaceRoot = path.resolve(__dirname, '../../../');
58-
const metroConfig = withMetroConfig(getDefaultConfig(__dirname), {
59-
root,
60-
dirname: __dirname,
61-
});
62-
63-
metroConfig.watchFolders = [workspaceRoot];
64-
65-
metroConfig.resolver.nodeModulesPaths = [
66-
path.resolve(root, 'node_modules'),
67-
path.resolve(workspaceRoot, 'node_modules'),
68-
];
69-
70-
module.exports = metroConfig;
71-
72-
```
73-
74-
8. start metro server in `example` folder with `yarn start`
75-
76-
9. Let's talk about Android now. Change `new-library/example/android/settings.gradle`:
77-
78-
```
79-
pluginManagement {
80-
def reactNativeGradlePlugin = new File(
81-
providers.exec {
82-
workingDir(rootDir)
83-
commandLine("node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })")
84-
}.standardOutput.asText.get().trim()
85-
).getParentFile().absolutePath
86-
includeBuild(reactNativeGradlePlugin)
87-
}
88-
plugins { id("com.facebook.react.settings") }
89-
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
90-
rootProject.name = 'onekeyfe.reactnativecheckbiometricauthchanged.example'
91-
include ':app'
92-
93-
def reactNativeGradlePlugin = new File(
94-
providers.exec {
95-
workingDir(rootDir)
96-
commandLine("node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })")
97-
}.standardOutput.asText.get().trim()
98-
).getParentFile().absolutePath
99-
includeBuild(reactNativeGradlePlugin)
100-
```
101-
102-
10. Add the following variables at the top of the react block in `new-library/example/android/app/build.gradle`:
103-
104-
```
105-
react {
106-
reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
107-
hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc"
108-
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
109-
enableBundleCompression = (findProperty('android.enableBundleCompression') ?: false).toBoolean()
110-
/* Folders */
111-
// The root of your project, i.e. where "package.json" lives. Default is '../..'
112-
// root = file("../../")
113-
// ...
114-
}
7+
```shell
8+
npx create-react-native-library@latest new-lib
1159
```
11610

117-
11. Now you can build and run the Android version.
118-
119-
12. add release script in `package.json`
120-
121-
```json
122-
"release": "yarn nitrogen && yarn prepare && release-it --only-version"
11+
```shell
12+
yarn package:setup new-lib
12313
```
12414

12515

example/react-native/.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+
};

example/react-native/.gitignore

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
**/.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+
.kotlin/
37+
38+
# node.js
39+
#
40+
node_modules/
41+
npm-debug.log
42+
yarn-error.log
43+
44+
# fastlane
45+
#
46+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47+
# screenshots whenever they are needed.
48+
# For more information about the recommended setup visit:
49+
# https://docs.fastlane.tools/best-practices/source-control/
50+
51+
**/fastlane/report.xml
52+
**/fastlane/Preview.html
53+
**/fastlane/screenshots
54+
**/fastlane/test_output
55+
56+
# Bundle artifact
57+
*.jsbundle
58+
59+
# Ruby / CocoaPods
60+
**/Pods/
61+
/vendor/bundle/
62+
63+
# Temporary files created by Metro to check the health of the file watcher
64+
.metro-health-check*
65+
66+
# testing
67+
/coverage
68+
69+
# Yarn
70+
.yarn/*
71+
!.yarn/patches
72+
!.yarn/plugins
73+
!.yarn/releases
74+
!.yarn/sdks
75+
!.yarn/versions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
singleQuote: true,
4+
trailingComma: 'all',
5+
};

native-modules/react-native-background-thread/example/.watchmanconfig renamed to example/react-native/.watchmanconfig

File renamed without changes.

example/react-native/App.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
*/
7+
8+
import { StatusBar, StyleSheet, useColorScheme, View } from 'react-native';
9+
import {
10+
SafeAreaProvider,
11+
useSafeAreaInsets,
12+
} from 'react-native-safe-area-context';
13+
import { Router } from './route';
14+
15+
function App() {
16+
const isDarkMode = useColorScheme() === 'dark';
17+
18+
return (
19+
<SafeAreaProvider>
20+
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
21+
<AppContent />
22+
</SafeAreaProvider>
23+
);
24+
}
25+
26+
function AppContent() {
27+
const safeAreaInsets = useSafeAreaInsets();
28+
29+
return (
30+
<View style={styles.container}>
31+
<Router safeAreaInsets={safeAreaInsets} />
32+
</View>
33+
);
34+
}
35+
36+
const styles = StyleSheet.create({
37+
container: {
38+
flex: 1,
39+
},
40+
});
41+
42+
export default App;

native-modules/react-native-background-thread/example/Gemfile renamed to example/react-native/Gemfile

File renamed without changes.

native-modules/react-native-background-thread/example/README.md renamed to example/react-native/README.md

File renamed without changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import React from 'react';
6+
import ReactTestRenderer from 'react-test-renderer';
7+
import App from '../App';
8+
9+
test('renders correctly', async () => {
10+
await ReactTestRenderer.act(() => {
11+
ReactTestRenderer.create(<App />);
12+
});
13+
});

native-modules/react-native-cloud-kit-module/example/android/app/build.gradle renamed to example/react-native/android/app/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ react {
1111
hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc"
1212
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
1313
enableBundleCompression = (findProperty('android.enableBundleCompression') ?: false).toBoolean()
14-
1514
/* Folders */
1615
// The root of your project, i.e. where "package.json" lives. Default is '../..'
1716
// root = file("../../")
@@ -82,9 +81,9 @@ android {
8281
buildToolsVersion rootProject.ext.buildToolsVersion
8382
compileSdk rootProject.ext.compileSdkVersion
8483

85-
namespace "cloudkitmodule.example"
84+
namespace "com.example"
8685
defaultConfig {
87-
applicationId "cloudkitmodule.example"
86+
applicationId "com.example"
8887
minSdkVersion rootProject.ext.minSdkVersion
8988
targetSdkVersion rootProject.ext.targetSdkVersion
9089
versionCode 1

0 commit comments

Comments
 (0)