Skip to content

Commit 0ed8e43

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

File tree

13 files changed

+1413
-1504
lines changed

13 files changed

+1413
-1504
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: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,6 @@ 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

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ SPEC CHECKSUMS:
18891889
React-logger: 9a0c4e1e41cd640ac49d69aacadab783f7e0096b
18901890
React-Mapbuffer: 6993c785c22a170c02489bc78ed207814cbd700f
18911891
React-microtasksnativemodule: 19230cd0933df6f6dc1336c9a9edc382d62638ae
1892-
react-native-orientation-director: c0dab0122a86a4b9fb062cd71b6d1c1fc10a42ae
1892+
react-native-orientation-director: 93fcddefcbbc2bb2e26fea97ae81991c44060346
18931893
react-native-safe-area-context: 6b85173d2cee963d5232ac2fd260e8ebd63273dc
18941894
React-nativeconfig: cd0fbb40987a9658c24dab5812c14e5522a64929
18951895
React-NativeModulesApple: 45187d13c68d47250a7416b18ff082c7cc07bff7

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
}

react-native-orientation-director.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Pod::Spec.new do |s|
1414
s.platforms = { :ios => min_ios_version_supported }
1515
s.source = { :git => "https://github.com/gladiuscode/react-native-orientation-director.git", :tag => "#{s.version}" }
1616

17-
s.source_files = "ios/**/*.{h,m,mm,swift}"
17+
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
18+
s.private_header_files = "ios/generated/**/*.h"
1819

1920
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
2021
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.

tsconfig.build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "./tsconfig",
3-
"exclude": ["example"]
3+
"exclude": ["example", "lib"]
44
}

0 commit comments

Comments
 (0)