Skip to content

Commit bc10a28

Browse files
huntiefacebook-github-bot
authored andcommitted
Upgrade CLI and Metro, update status check refs
Summary: Update `cli-commands` package to reflect latest source `react-native-community/cli-plugin-metro` changes. - react-native-community/cli#2043 - react-native-community/cli#2021 - react-native-community/cli#2024 Changelog: [Internal] Differential Revision: D48311214 fbshipit-source-id: c415984bbac10cc4b4e0c6031d80eb0f2db95eb0
1 parent e44fdfe commit bc10a28

File tree

9 files changed

+237
-311
lines changed

9 files changed

+237
-311
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
"jest": "^29.2.1",
8989
"jest-junit": "^10.0.0",
9090
"jscodeshift": "^0.14.0",
91-
"metro-babel-register": "0.77.0",
92-
"metro-memory-fs": "0.77.0",
91+
"metro-babel-register": "0.78.0",
92+
"metro-memory-fs": "0.78.0",
9393
"micromatch": "^4.0.4",
9494
"mkdirp": "^0.5.1",
9595
"mock-fs": "^5.1.4",

packages/community-cli-plugin/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@
2424
"launchPackager.command"
2525
],
2626
"dependencies": {
27-
"@react-native-community/cli-server-api": "12.0.0-alpha.7",
28-
"@react-native-community/cli-tools": "12.0.0-alpha.7",
27+
"@react-native-community/cli-server-api": "12.0.0-alpha.9",
28+
"@react-native-community/cli-tools": "12.0.0-alpha.9",
2929
"@react-native/metro-babel-transformer": "^0.73.11",
3030
"chalk": "^4.0.0",
3131
"execa": "^5.1.1",
32-
"metro": "0.77.0",
33-
"metro-config": "0.77.0",
34-
"metro-core": "0.77.0",
35-
"metro-resolver": "0.77.0",
32+
"metro": "0.78.0",
33+
"metro-config": "0.78.0",
34+
"metro-core": "0.78.0",
3635
"readline": "^1.3.0"
3736
},
37+
"devDependencies": {
38+
"metro-resolver": "0.78.0"
39+
},
3840
"engines": {
3941
"node": ">=18"
4042
}

packages/metro-config/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"dependencies": {
1919
"@react-native/metro-babel-transformer": "^0.73.11",
2020
"@react-native/js-polyfills": "^0.73.0",
21-
"metro-config": "0.77.0",
22-
"metro-runtime": "0.77.0"
21+
"metro-config": "0.78.0",
22+
"metro-runtime": "0.78.0"
2323
}
2424
}

packages/react-native/React/Base/RCTBundleURLProvider.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ + (BOOL)isPackagerRunning:(NSString *)hostPort scheme:(NSString *)scheme
107107
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
108108

109109
NSString *status = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
110+
111+
// TODO(huntie): Temporary string match in JSON response. We will revert this
112+
// endpoint back to "packager-status:running" in the next CLI alpha.
113+
if ([status containsString:@"\"status\":\"running\""]) {
114+
return true;
115+
}
116+
110117
return [status isEqualToString:@"packager-status:running"];
111118
}
112119

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PackagerStatusCheck.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ public void onResponse(Call call, Response response) throws IOException {
8181
String bodyString =
8282
body.string(); // cannot call body.string() twice, stored it into variable.
8383
// https://github.com/square/okhttp/issues/1240#issuecomment-68142603
84+
85+
// TODO(huntie): Temporary string match in JSON response. We
86+
// will revert this endpoint back to "packager-status:running"
87+
// in the next CLI alpha.
88+
if (bodyString.contains("\"status\":\"running\"")) {
89+
callback.onPackagerStatusFetched(true);
90+
return;
91+
}
92+
8493
if (!PACKAGER_OK_STATUS.equals(bodyString)) {
8594
FLog.e(
8695
ReactConstants.TAG,

packages/react-native/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@
9292
},
9393
"dependencies": {
9494
"@jest/create-cache-key-function": "^29.2.1",
95-
"@react-native-community/cli": "12.0.0-alpha.7",
96-
"@react-native-community/cli-platform-android": "12.0.0-alpha.7",
97-
"@react-native-community/cli-platform-ios": "12.0.0-alpha.7",
95+
"@react-native-community/cli": "12.0.0-alpha.9",
96+
"@react-native-community/cli-platform-android": "12.0.0-alpha.9",
97+
"@react-native-community/cli-platform-ios": "12.0.0-alpha.9",
9898
"@react-native/assets-registry": "^0.73.0",
9999
"@react-native/codegen": "^0.73.0",
100100
"@react-native/gradle-plugin": "^0.73.0",
@@ -112,8 +112,8 @@
112112
"jest-environment-node": "^29.2.1",
113113
"jsc-android": "^250231.0.0",
114114
"memoize-one": "^5.0.0",
115-
"metro-runtime": "0.76.7",
116-
"metro-source-map": "0.76.7",
115+
"metro-runtime": "0.78.0",
116+
"metro-source-map": "0.78.0",
117117
"mkdirp": "^0.5.1",
118118
"nullthrows": "^1.1.1",
119119
"pretty-format": "^26.5.2",

scripts/objc-test.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ waitForWebSocketServer() {
7373
echo "WebSocket Server is ready!"
7474
}
7575

76+
waitForPackagerAlt() {
77+
local -i max_attempts=60
78+
local -i attempt_num=1
79+
80+
# TODO(huntie): Temporary string match in JSON response. We will revert
81+
# this endpoint back to "packager-status:running" in the next CLI alpha.
82+
until curl -s http://localhost:8081/status | grep "\"status\":\"running\"" -q; do
83+
if (( attempt_num == max_attempts )); then
84+
echo "Packager did not respond in time. No more attempts left."
85+
exit 1
86+
else
87+
(( attempt_num++ ))
88+
echo "Packager did not respond. Retrying for attempt number $attempt_num..."
89+
sleep 1
90+
fi
91+
done
92+
93+
echo "Packager is ready!"
94+
}
95+
7696
runTests() {
7797
# shellcheck disable=SC1091
7898
source "$ROOT/scripts/.tests.env"
@@ -131,7 +151,7 @@ main() {
131151

132152
# Start the packager
133153
yarn start --max-workers=1 || echo "Can't start packager automatically" &
134-
waitForPackager
154+
waitForPackagerAlt
135155
preloadBundlesRNTester
136156
preloadBundlesRNIntegrationTests
137157

scripts/testing-utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ function isPackagerRunning(
117117
silent: true,
118118
}).stdout;
119119

120+
// TODO(huntie): Temporary string match in JSON response. We will revert
121+
// this endpoint back to "packager-status:running" in the next CLI alpha.
122+
if (status.includes('"status":"running"')) {
123+
return 'running';
124+
}
125+
120126
return status === 'packager-status:running' ? 'running' : 'unrecognized';
121127
} catch (_error) {
122128
return 'not_running';

0 commit comments

Comments
 (0)