Skip to content

Commit ef20f4c

Browse files
committed
feat: upgrade react-native-create-library to latest
1 parent b7513bd commit ef20f4c

File tree

13 files changed

+1421
-1599
lines changed

13 files changed

+1421
-1599
lines changed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ DerivedData
2828
*.ipa
2929
*.xcuserstate
3030
project.xcworkspace
31-
example/ios/.xcode.env.local
31+
**/.xcode.env.local
3232

3333
# Android/IJ
3434
#
@@ -77,3 +77,10 @@ android/keystores/debug.keystore
7777

7878
# generated by bob
7979
lib/
80+
81+
# React Native Codegen
82+
ios/generated
83+
android/generated
84+
85+
# React Native Nitro Modules
86+
nitrogen/

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18
1+
v20

CONTRIBUTING.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ The [example app](/example/) demonstrates usage of the library. You need to run
2323

2424
It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.
2525

26-
If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/OrientationDirectorExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-orientation-director`.
26+
If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/TestLibraryExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-test-library`.
2727

28-
To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-orientation-director` under `Android`.
28+
To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-test-library` under `Android`.
2929

3030
You can use various commands from the root directory to work with the project.
3131

@@ -47,33 +47,10 @@ To run the example app on iOS:
4747
yarn example ios
4848
```
4949

50-
By default, the example is configured to build with the old architecture. To run the example with the new architecture, you can do the following:
51-
52-
1. For Android, run:
53-
54-
```sh
55-
ORG_GRADLE_PROJECT_newArchEnabled=true yarn example android
56-
```
57-
58-
2. For iOS, run:
59-
60-
```sh
61-
cd example/ios
62-
RCT_NEW_ARCH_ENABLED=1 pod install
63-
cd -
64-
yarn example ios
65-
```
66-
67-
If you are building for a different architecture than your previous build, make sure to remove the build folders first. You can run the following command to cleanup all build folders:
68-
69-
```sh
70-
yarn clean
71-
```
72-
7350
To confirm that the app is running with the new architecture, you can check the Metro logs for a message like this:
7451

7552
```sh
76-
Running "OrientationDirectorExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
53+
Running "TestLibraryExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
7754
```
7855

7956
Note the `"fabric":true` and `"concurrentRoot":true` properties.

android/build.gradle

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
buildscript {
2-
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
3-
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["OrientationDirector_kotlinVersion"]
2+
ext.getExtOrDefault = {name ->
3+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['OrientationDirector_' + name]
4+
}
45

56
repositories {
67
google()
78
mavenCentral()
89
}
910

1011
dependencies {
11-
classpath "com.android.tools.build:gradle:7.2.1"
12+
classpath "com.android.tools.build:gradle:8.7.2"
1213
// noinspection DifferentKotlinGradleVersion
13-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
1415
}
1516
}
1617

18+
1719
def isNewArchitectureEnabled() {
1820
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
1921
}
@@ -25,10 +27,6 @@ if (isNewArchitectureEnabled()) {
2527
apply plugin: "com.facebook.react"
2628
}
2729

28-
def getExtOrDefault(name) {
29-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["OrientationDirector_" + name]
30-
}
31-
3230
def getExtOrIntegerDefault(name) {
3331
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["OrientationDirector_" + name]).toInteger()
3432
}
@@ -111,10 +109,7 @@ def robolectric_version = getDefault("robolectricVersion")
111109
def mockito_core_version = getDefault("mockitoCoreVersion")
112110

113111
dependencies {
114-
// For < 0.71, this will be from the local maven repo
115-
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
116-
//noinspection GradleDynamicVersion
117-
implementation "com.facebook.react:react-native:+"
112+
implementation "com.facebook.react:react-android"
118113
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
119114

120115
testImplementation "junit:junit:$junit_version"

android/src/main/java/com/orientationdirector/OrientationDirectorPackage.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.orientationdirector
22

3-
import com.facebook.react.TurboReactPackage
3+
import com.facebook.react.BaseReactPackage
44
import com.facebook.react.bridge.ReactApplicationContext
55
import com.facebook.react.bridge.NativeModule
66
import com.facebook.react.module.model.ReactModuleInfoProvider
77
import com.facebook.react.module.model.ReactModuleInfo
88
import com.orientationdirector.implementation.OrientationDirectorModuleImpl
99
import java.util.HashMap
1010

11-
class OrientationDirectorPackage : TurboReactPackage() {
11+
class OrientationDirectorPackage : BaseReactPackage() {
1212
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
1313
return if (name == OrientationDirectorModuleImpl.NAME) {
1414
OrientationDirectorModule(reactContext)
@@ -26,7 +26,6 @@ class OrientationDirectorPackage : TurboReactPackage() {
2626
OrientationDirectorModuleImpl.NAME,
2727
false, // canOverrideExistingModule
2828
false, // needsEagerInit
29-
true, // hasConstants
3029
false, // isCxxModule
3130
isTurboModule // isTurboModule
3231
)

example/ios/Podfile.lock

Lines changed: 6 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,71 +1232,7 @@ PODS:
12321232
- ReactCommon/turbomodule/core
12331233
- Yoga
12341234
- react-native-safe-area-context (5.1.0):
1235-
- DoubleConversion
1236-
- glog
1237-
- hermes-engine
1238-
- RCT-Folly (= 2024.11.18.00)
1239-
- RCTRequired
1240-
- RCTTypeSafety
1241-
- React-Core
1242-
- React-debug
1243-
- React-Fabric
1244-
- React-featureflags
1245-
- React-graphics
1246-
- React-ImageManager
1247-
- react-native-safe-area-context/common (= 5.1.0)
1248-
- react-native-safe-area-context/fabric (= 5.1.0)
1249-
- React-NativeModulesApple
1250-
- React-RCTFabric
1251-
- React-rendererdebug
1252-
- React-utils
1253-
- ReactCodegen
1254-
- ReactCommon/turbomodule/bridging
1255-
- ReactCommon/turbomodule/core
1256-
- Yoga
1257-
- react-native-safe-area-context/common (5.1.0):
1258-
- DoubleConversion
1259-
- glog
1260-
- hermes-engine
1261-
- RCT-Folly (= 2024.11.18.00)
1262-
- RCTRequired
1263-
- RCTTypeSafety
1264-
- React-Core
1265-
- React-debug
1266-
- React-Fabric
1267-
- React-featureflags
1268-
- React-graphics
1269-
- React-ImageManager
1270-
- React-NativeModulesApple
1271-
- React-RCTFabric
1272-
- React-rendererdebug
1273-
- React-utils
1274-
- ReactCodegen
1275-
- ReactCommon/turbomodule/bridging
1276-
- ReactCommon/turbomodule/core
1277-
- Yoga
1278-
- react-native-safe-area-context/fabric (5.1.0):
1279-
- DoubleConversion
1280-
- glog
1281-
- hermes-engine
1282-
- RCT-Folly (= 2024.11.18.00)
1283-
- RCTRequired
1284-
- RCTTypeSafety
12851235
- React-Core
1286-
- React-debug
1287-
- React-Fabric
1288-
- React-featureflags
1289-
- React-graphics
1290-
- React-ImageManager
1291-
- react-native-safe-area-context/common
1292-
- React-NativeModulesApple
1293-
- React-RCTFabric
1294-
- React-rendererdebug
1295-
- React-utils
1296-
- ReactCodegen
1297-
- ReactCommon/turbomodule/bridging
1298-
- ReactCommon/turbomodule/core
1299-
- Yoga
13001236
- React-nativeconfig (0.77.0)
13011237
- React-NativeModulesApple (0.77.0):
13021238
- glog
@@ -1587,29 +1523,6 @@ PODS:
15871523
- React-perflogger (= 0.77.0)
15881524
- React-utils (= 0.77.0)
15891525
- RNScreens (4.6.0):
1590-
- DoubleConversion
1591-
- glog
1592-
- hermes-engine
1593-
- RCT-Folly (= 2024.11.18.00)
1594-
- RCTRequired
1595-
- RCTTypeSafety
1596-
- React-Core
1597-
- React-debug
1598-
- React-Fabric
1599-
- React-featureflags
1600-
- React-graphics
1601-
- React-ImageManager
1602-
- React-NativeModulesApple
1603-
- React-RCTFabric
1604-
- React-RCTImage
1605-
- React-rendererdebug
1606-
- React-utils
1607-
- ReactCodegen
1608-
- ReactCommon/turbomodule/bridging
1609-
- ReactCommon/turbomodule/core
1610-
- RNScreens/common (= 4.6.0)
1611-
- Yoga
1612-
- RNScreens/common (4.6.0):
16131526
- DoubleConversion
16141527
- glog
16151528
- hermes-engine
@@ -1889,18 +1802,18 @@ SPEC CHECKSUMS:
18891802
React-logger: 9a0c4e1e41cd640ac49d69aacadab783f7e0096b
18901803
React-Mapbuffer: 6993c785c22a170c02489bc78ed207814cbd700f
18911804
React-microtasksnativemodule: 19230cd0933df6f6dc1336c9a9edc382d62638ae
1892-
react-native-orientation-director: c0dab0122a86a4b9fb062cd71b6d1c1fc10a42ae
1893-
react-native-safe-area-context: 6b85173d2cee963d5232ac2fd260e8ebd63273dc
1805+
react-native-orientation-director: 086449584dc7102a363aa9c6684bc6824a015a16
1806+
react-native-safe-area-context: 04803a01f39f31cc6605a5531280b477b48f8a88
18941807
React-nativeconfig: cd0fbb40987a9658c24dab5812c14e5522a64929
18951808
React-NativeModulesApple: 45187d13c68d47250a7416b18ff082c7cc07bff7
18961809
React-perflogger: 15a7bcb6c46eae8a981f7add8c9f4172e2372324
18971810
React-performancetimeline: 631ef8ac4246bca49c07b88cd1ad85ce460b97bf
18981811
React-RCTActionSheet: 25eb72eabade4095bfaf6cd9c5c965c76865daa8
18991812
React-RCTAnimation: 04c987fa858fa16169f543d29edb4140bd35afa9
1900-
React-RCTAppDelegate: b2707904e4f8ad92fd052e62684bf0c3b88381cc
1813+
React-RCTAppDelegate: 874e34651ed9fdf7b66d02970de16910791b3738
19011814
React-RCTBlob: 1f214a7211632515805dd1f1b81fac70d12f812d
1902-
React-RCTFabric: 10f8b1ceac3c2feb3ddbede8a70c3410c68d79fe
1903-
React-RCTFBReactNativeSpec: 60d72b45a150ca35748b9a77028674b1e56a2e43
1815+
React-RCTFabric: a7e90eb2d21d3019f7d7f2fc9190211623f183b1
1816+
React-RCTFBReactNativeSpec: 7bc548f75e94467352380681dc9d5384eacb91b8
19041817
React-RCTImage: e516d72739797fb7c1dac5c691f02a0f5445c290
19051818
React-RCTLinking: 1e5554afe4f959696ad3285738c1510f2592f220
19061819
React-RCTNetwork: 65e1e52c8614dcab342fa1eaec750ca818160e74
@@ -1920,7 +1833,7 @@ SPEC CHECKSUMS:
19201833
ReactAppDependencyProvider: 3d947e9d62f351c06c71497e1be897e6006dc303
19211834
ReactCodegen: 1baa534318b19e95fb0f02db0a1ae1e3c271944d
19221835
ReactCommon: 6014af4276bb2debc350e2620ef1bd856b4d981c
1923-
RNScreens: c8c0b69f667891d474ad1229054d514f06778772
1836+
RNScreens: e9bb7c3063237983e75d01bb45ce591cc4e7afc2
19241837
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
19251838
Yoga: 78d74e245ed67bb94275a1316cdc170b9b7fe884
19261839

lefthook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pre-commit:
66
run: npx eslint {staged_files}
77
types:
88
glob: "*.{js,ts, jsx, tsx}"
9-
run: npx tsc --noEmit
9+
run: npx tsc
1010
commit-msg:
1111
parallel: true
1212
commands:

package.json

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22
"name": "react-native-orientation-director",
33
"version": "2.2.0",
44
"description": "A Modern React Native library that allows you to access orientation",
5-
"main": "lib/commonjs/index",
6-
"module": "lib/module/index",
7-
"types": "lib/typescript/src/index.d.ts",
8-
"react-native": "src/index",
9-
"source": "src/index",
5+
"source": "./src/index.tsx",
6+
"main": "./lib/commonjs/index.js",
7+
"module": "./lib/module/index.js",
8+
"exports": {
9+
".": {
10+
"import": {
11+
"types": "./lib/typescript/module/src/index.d.ts",
12+
"default": "./lib/module/index.js"
13+
},
14+
"require": {
15+
"types": "./lib/typescript/commonjs/src/index.d.ts",
16+
"default": "./lib/commonjs/index.js"
17+
}
18+
}
19+
},
1020
"files": [
1121
"src",
1222
"lib",
@@ -28,7 +38,7 @@
2838
"scripts": {
2939
"example": "yarn workspace react-native-orientation-director-example",
3040
"test": "jest",
31-
"typecheck": "tsc --noEmit",
41+
"typecheck": "tsc",
3242
"lint": "eslint \"**/*.{js,ts,tsx}\"",
3343
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
3444
"prepare": "bob build",
@@ -56,7 +66,7 @@
5666
"@commitlint/config-conventional": "^17.0.2",
5767
"@evilmartians/lefthook": "^1.5.0",
5868
"@react-native/eslint-config": "^0.73.1",
59-
"@release-it/conventional-changelog": "^5.0.0",
69+
"@release-it/conventional-changelog": "^9.0.2",
6070
"@types/jest": "^29.5.5",
6171
"@types/react": "^18.2.44",
6272
"commitlint": "^17.0.2",
@@ -68,8 +78,8 @@
6878
"prettier": "^3.0.3",
6979
"react": "18.3.1",
7080
"react-native": "0.77.0",
71-
"react-native-builder-bob": "^0.23.2",
72-
"release-it": "^15.0.0",
81+
"react-native-builder-bob": "^0.36.0",
82+
"release-it": "^17.10.0",
7383
"turbo": "^1.10.7",
7484
"typescript": "^5.2.2"
7585
},
@@ -133,6 +143,7 @@
133143
"prettier"
134144
],
135145
"rules": {
146+
"react/react-in-jsx-scope": "off",
136147
"prettier/prettier": [
137148
"error",
138149
{
@@ -160,19 +171,38 @@
160171
"source": "src",
161172
"output": "lib",
162173
"targets": [
163-
"commonjs",
164-
"module",
174+
[
175+
"commonjs",
176+
{
177+
"esm": true
178+
}
179+
],
180+
[
181+
"module",
182+
{
183+
"esm": true
184+
}
185+
],
165186
[
166187
"typescript",
167188
{
168-
"project": "tsconfig.build.json"
189+
"project": "tsconfig.build.json",
190+
"esm": true
169191
}
170192
]
171193
]
172194
},
173195
"codegenConfig": {
174196
"name": "RNOrientationDirectorSpec",
175197
"type": "modules",
176-
"jsSrcsDir": "src"
198+
"jsSrcsDir": "src",
199+
"android": {
200+
"javaPackageName": "com.orientationdirector"
201+
}
202+
},
203+
"create-react-native-library": {
204+
"type": "turbo-module",
205+
"languages": "kotlin-objc",
206+
"version": "0.48.0"
177207
}
178208
}

0 commit comments

Comments
 (0)