Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .changeset/all-tigers-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@rock-js/plugin-brownfield-android': minor
'@rock-js/plugin-brownfield-ios': minor
'@rock-js/platform-android': minor
'@rock-js/welcome-screen': minor
'@rock-js/platform-ios': minor
'@rock-js/plugin-metro': minor
'rock-docs': minor
'rock': minor
'@rock-js/config': minor
'create-rock': minor
'@rock-js/platform-apple-helpers': minor
'@rock-js/platform-harmony': minor
'@rock-js/plugin-repack': minor
'@rock-js/provider-github': minor
'@rock-js/provider-s3': minor
'@rock-js/test-helpers': minor
'@rock-js/tools': minor
---

feat: upgrade templates to RN 0.82
36 changes: 1 addition & 35 deletions packages/platform-android/src/lib/paths.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { versionCompare } from '@rock-js/tools';

export function getAndroidSdkPath() {
const sdkRoot =
Expand Down Expand Up @@ -37,38 +38,3 @@ export function findAndroidBuildTool(toolName: string) {

return null;
}

export function versionCompare(first: string, second: string) {
const firstVersion = parseVersionString(first);
const secondVersion = parseVersionString(second);

if (!firstVersion || !secondVersion) {
return first.localeCompare(second);
}

if (firstVersion.major !== secondVersion.major) {
return firstVersion.major - secondVersion.major;
}
if (firstVersion.minor !== secondVersion.minor) {
return firstVersion.minor - secondVersion.minor;
}

return firstVersion.patch - secondVersion.patch;
}

function parseVersionString(version: string) {
if (!isVersionString(version)) {
return null;
}

const [major, minor, patch] = version.split('.').map(Number);
return {
major: Number(major),
minor: Number(minor),
patch: Number(patch),
};
}

function isVersionString(version: string) {
return /^[0-9]+\.[0-9]+\.[0-9]+$/.test(version);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="${usesCleartextTraffic}"
android:supportsRtl="true">
<activity
android:name=".MainActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
package com.helloworld
package com.rndiffapp

import android.app.Application
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactHost
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost

class MainApplication : Application(), ReactApplication {

override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
}

override fun getJSMainModuleName(): String = "index"

override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG

override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}

override val reactHost: ReactHost
get() = getDefaultReactHost(applicationContext, reactNativeHost)
override val reactHost: ReactHost by lazy {
getDefaultReactHost(
context = applicationContext,
packageList =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
},
)
}

override fun onCreate() {
super.onCreate()
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion packages/platform-android/template/android/gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
6 changes: 2 additions & 4 deletions packages/platform-apple-helpers/src/lib/utils/pods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
RockError,
spawn,
spinner,
versionCompare,
} from '@rock-js/tools';
import type { ApplePlatform } from '../types/index.js';
import runCodegen from './codegen.js';
Expand Down Expand Up @@ -120,10 +121,7 @@ async function runPodInstall(options: {
loader.start('Installing CocoaPods dependencies');
const reactNativeVersion = await getReactNativeVersion(options.projectRoot);
const isReactNative81OrHigher =
reactNativeVersion.localeCompare('0.81.0', undefined, {
numeric: true,
sensitivity: 'base',
}) >= 0;
versionCompare('0.81.0', reactNativeVersion) >= 0;
const usePrebuiltReactNative = !options.brownfield && isReactNative81OrHigher;
const command = options.useBundler ? 'bundle' : 'pod';
const args = options.useBundler ? ['exec', 'pod', 'install'] : ['install'];
Expand Down
1 change: 0 additions & 1 deletion packages/platform-ios/template/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ target 'HelloWorld' do
)

post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
config[:reactNativePath],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ publishing {
}

dependencies {
api("com.facebook.react:react-android:0.81.1")
api("com.facebook.react:hermes-android:0.81.1")
api("com.facebook.react:react-android:0.82.0")
api("com.facebook.react:hermes-android:0.82.0")
}

val moduleBuildDir: Directory = layout.buildDirectory.get()
Expand Down
16 changes: 11 additions & 5 deletions packages/plugin-brownfield-ios/src/lib/copyHermesXcframework.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import fs, { existsSync } from 'node:fs';
import path from 'node:path';
import { color, logger, spinner } from '@rock-js/tools';
import { color, logger, spinner, versionCompare } from '@rock-js/tools';

export function copyHermesXcframework({
sourceDir,
destinationDir,
reactNativeVersion,
}: {
sourceDir: string;
destinationDir: string;
reactNativeVersion: string;
}) {
const loader = spinner();
const hermesFrameworkName =
versionCompare('0.82.0', reactNativeVersion) >= 0
? 'hermesvm.xcframework'
: 'hermes.xcframework';

loader.start(`Copying ${color.bold('hermes.xcframework')}`);
const hermesDestination = path.join(destinationDir, 'hermes.xcframework');
loader.start(`Copying ${color.bold(hermesFrameworkName)}`);
const hermesDestination = path.join(destinationDir, hermesFrameworkName);

if (existsSync(hermesDestination)) {
logger.debug(`Removing old hermes copy`);
Expand All @@ -22,11 +28,11 @@ export function copyHermesXcframework({
fs.cpSync(
path.join(
sourceDir,
'Pods/hermes-engine/destroot/Library/Frameworks/universal/hermes.xcframework',
`Pods/hermes-engine/destroot/Library/Frameworks/universal/${hermesFrameworkName}`,
),
hermesDestination,
{ recursive: true, force: true },
);

loader.stop(`Copied ${color.bold('hermes.xcframework')}`);
loader.stop(`Copied ${color.bold(hermesFrameworkName)}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const pluginBrownfieldIos =
copyHermesXcframework({
sourceDir,
destinationDir: frameworkTargetOutputDir,
reactNativeVersion: api.getReactNativeVersion(),
});

// 5) Inform the user
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-brownfield-ios/template/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ target 'HelloWorld' do
end

post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
config[:reactNativePath],
Expand Down
12 changes: 6 additions & 6 deletions packages/plugin-metro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
"dependencies": {
"@react-native-community/cli-server-api": "^20.0.0",
"@rock-js/tools": "^0.11.6",
"metro": "^0.83.1",
"metro-config": "^0.83.1",
"metro-core": "^0.83.1",
"metro-resolver": "^0.83.1",
"metro": "^0.83.3",
"metro-config": "^0.83.3",
"metro-core": "^0.83.3",
"metro-resolver": "^0.83.3",
"tslib": "^2.3.0"
},
"devDependencies": {
"@react-native/dev-middleware": "^0.81.1",
"@react-native/community-cli-plugin": "0.81.1",
"@react-native/dev-middleware": "^0.82.0",
"@react-native/community-cli-plugin": "0.82.0",
"@rock-js/config": "^0.11.6"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-metro/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "rock-plugin-metro-template",
"devDependencies": {
"@rock-js/plugin-metro": "^0.11.6",
"@react-native/metro-config": "0.81.1"
"@react-native/metro-config": "0.82.0"
}
}
1 change: 1 addition & 0 deletions packages/tools/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ export {
} from './lib/build-cache/fetchCachedBuild.js';
export { getInfoPlist } from './lib/getInfoPlist.js';
export { getReactNativeVersion } from './lib/getReactNativeVersion.js';
export { versionCompare } from './lib/versionCompare.js';
34 changes: 34 additions & 0 deletions packages/tools/src/lib/versionCompare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export function versionCompare(first: string, second: string) {
const firstVersion = parseVersionString(first);
const secondVersion = parseVersionString(second);

if (!firstVersion || !secondVersion) {
return first.localeCompare(second);
}

if (firstVersion.major !== secondVersion.major) {
return firstVersion.major - secondVersion.major;
}
if (firstVersion.minor !== secondVersion.minor) {
return firstVersion.minor - secondVersion.minor;
}

return firstVersion.patch - secondVersion.patch;
}

function parseVersionString(version: string) {
if (!isVersionString(version)) {
return null;
}

const [major, minor, patch] = version.split('.').map(Number);
return {
major: Number(major),
minor: Number(minor),
patch: Number(patch),
};
}

function isVersionString(version: string) {
return /^[0-9]+\.[0-9]+\.[0-9]+$/.test(version);
}
6 changes: 3 additions & 3 deletions packages/welcome-screen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"react-native": "*"
},
"devDependencies": {
"@types/react": "^19.1.0",
"react": "19.1.0",
"react-native": "0.81.1"
"@types/react": "^19.1.1",
"react": "19.1.1",
"react-native": "0.82.0"
},
"publishConfig": {
"access": "public"
Expand Down
Loading
Loading