Skip to content

Commit 2ba5dc2

Browse files
committed
fix: fix pnpm related errors when on 0.76
1 parent 856c4a0 commit 2ba5dc2

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

Diff for: ios/test_app.rb

+10-4
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ def apply_config_plugins(project_root, target_platform)
2929
raise 'Failed to apply config plugins' unless result
3030
end
3131

32-
def autolink_script_path(project_root, target_platform)
33-
react_native = react_native_path(project_root, target_platform)
34-
package_path = resolve_module('@react-native-community/cli-platform-ios', react_native)
32+
def autolink_script_path(project_root, target_platform, react_native_version)
33+
start_dir = if react_native_version >= v(0, 76, 0)
34+
project_root
35+
else
36+
react_native_path(project_root, target_platform)
37+
end
38+
package_path = resolve_module('@react-native-community/cli-platform-ios', start_dir)
3539
File.join(package_path, 'native_modules')
3640
end
3741

@@ -356,7 +360,9 @@ def use_test_app_internal!(target_platform, options)
356360
install! 'cocoapods', :deterministic_uuids => false
357361
end
358362

359-
require_relative(autolink_script_path(project_root, target_platform))
363+
require_relative(autolink_script_path(project_root,
364+
target_platform,
365+
project_target[:react_native_version]))
360366

361367
begin
362368
platform :ios, platforms[:ios] if target_platform == :ios

Diff for: scripts/configure-projects.js

+26-12
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ const {
3131
*/
3232
const getRNPackageVersion = (() => {
3333
const isTesting = "NODE_TEST_CONTEXT" in process.env;
34+
3435
/** @type {Record<string, number>} */
3536
let versions = {};
37+
3638
/** @type {(packageName: string) => number} */
3739
return (packageName, fs = nodefs) => {
3840
if (isTesting || !versions[packageName]) {
@@ -49,7 +51,12 @@ const getRNPackageVersion = (() => {
4951
* @returns {number}
5052
*/
5153
function cliPlatformIOSVersion() {
52-
return getRNPackageVersion("@react-native-community/cli-platform-ios");
54+
try {
55+
return getRNPackageVersion("@react-native-community/cli-platform-ios");
56+
} catch (_) {
57+
// The returned value doesn't matter when we're on 0.76 or later
58+
return Number.MAX_SAFE_INTEGER;
59+
}
5360
}
5461

5562
/**
@@ -61,17 +68,24 @@ function getAndroidPackageName(manifestPath, fs = nodefs) {
6168
return undefined;
6269
}
6370

64-
const rncliAndroidVersion = getRNPackageVersion(
65-
"@react-native-community/cli-platform-android",
66-
fs
67-
);
68-
if (rncliAndroidVersion < v(12, 3, 7)) {
69-
// TODO: This block can be removed when we drop support for 0.72
70-
return undefined;
71-
}
72-
if (rncliAndroidVersion >= v(13, 0, 0) && rncliAndroidVersion < v(13, 6, 9)) {
73-
// TODO: This block can be removed when we drop support for 0.73
74-
return undefined;
71+
try {
72+
const rncliAndroidVersion = getRNPackageVersion(
73+
"@react-native-community/cli-platform-android",
74+
fs
75+
);
76+
if (rncliAndroidVersion < v(12, 3, 7)) {
77+
// TODO: This block can be removed when we drop support for 0.72
78+
return undefined;
79+
}
80+
if (
81+
rncliAndroidVersion >= v(13, 0, 0) &&
82+
rncliAndroidVersion < v(13, 6, 9)
83+
) {
84+
// TODO: This block can be removed when we drop support for 0.73
85+
return undefined;
86+
}
87+
} catch (_) {
88+
// We're on 0.76 or later
7589
}
7690

7791
/** @type {{ android?: { package?: string }}} */

0 commit comments

Comments
 (0)