Skip to content

Commit

Permalink
Upgrade CLI and Metro, update status check refs
Browse files Browse the repository at this point in the history
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: 4d8c3d9cb98a300587b98c3d81d07f544ffa314e
  • Loading branch information
huntie authored and facebook-github-bot committed Aug 15, 2023
1 parent 857bc05 commit 468dbc3
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 311 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
"jest": "^29.2.1",
"jest-junit": "^10.0.0",
"jscodeshift": "^0.14.0",
"metro-babel-register": "0.77.0",
"metro-memory-fs": "0.77.0",
"metro-babel-register": "0.78.0",
"metro-memory-fs": "0.78.0",
"micromatch": "^4.0.4",
"mkdirp": "^0.5.1",
"mock-fs": "^5.1.4",
Expand Down
14 changes: 8 additions & 6 deletions packages/community-cli-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@
"launchPackager.command"
],
"dependencies": {
"@react-native-community/cli-server-api": "12.0.0-alpha.7",
"@react-native-community/cli-tools": "12.0.0-alpha.7",
"@react-native-community/cli-server-api": "12.0.0-alpha.9",
"@react-native-community/cli-tools": "12.0.0-alpha.9",
"@react-native/metro-babel-transformer": "^0.73.11",
"chalk": "^4.0.0",
"execa": "^5.1.1",
"metro": "0.77.0",
"metro-config": "0.77.0",
"metro-core": "0.77.0",
"metro-resolver": "0.77.0",
"metro": "0.78.0",
"metro-config": "0.78.0",
"metro-core": "0.78.0",
"readline": "^1.3.0"
},
"devDependencies": {
"metro-resolver": "0.78.0"
},
"engines": {
"node": ">=18"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/metro-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@react-native/metro-babel-transformer": "^0.73.11",
"@react-native/js-polyfills": "^0.73.0",
"metro-config": "0.77.0",
"metro-runtime": "0.77.0"
"metro-config": "0.78.0",
"metro-runtime": "0.78.0"
}
}
7 changes: 7 additions & 0 deletions packages/react-native/React/Base/RCTBundleURLProvider.mm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ + (BOOL)isPackagerRunning:(NSString *)hostPort scheme:(NSString *)scheme
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);

NSString *status = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

// TODO(huntie): Temporary string match in JSON response. We will revert this
// endpoint back to "packager-status:running" in the next CLI alpha.
if ([status containsString:@"\"status\":\"running\""]) {
return true;
}

return [status isEqualToString:@"packager-status:running"];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ public void onResponse(Call call, Response response) throws IOException {
String bodyString =
body.string(); // cannot call body.string() twice, stored it into variable.
// https://github.com/square/okhttp/issues/1240#issuecomment-68142603

// TODO(huntie): Temporary string match in JSON response. We
// will revert this endpoint back to "packager-status:running"
// in the next CLI alpha.
if (bodyString.contains("\"status\":\"running\"")) {
callback.onPackagerStatusFetched(true);
return;
}

if (!PACKAGER_OK_STATUS.equals(bodyString)) {
FLog.e(
ReactConstants.TAG,
Expand Down
10 changes: 5 additions & 5 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@
},
"dependencies": {
"@jest/create-cache-key-function": "^29.2.1",
"@react-native-community/cli": "12.0.0-alpha.7",
"@react-native-community/cli-platform-android": "12.0.0-alpha.7",
"@react-native-community/cli-platform-ios": "12.0.0-alpha.7",
"@react-native-community/cli": "12.0.0-alpha.9",
"@react-native-community/cli-platform-android": "12.0.0-alpha.9",
"@react-native-community/cli-platform-ios": "12.0.0-alpha.9",
"@react-native/assets-registry": "^0.73.0",
"@react-native/codegen": "^0.73.0",
"@react-native/gradle-plugin": "^0.73.0",
Expand All @@ -112,8 +112,8 @@
"jest-environment-node": "^29.2.1",
"jsc-android": "^250231.0.0",
"memoize-one": "^5.0.0",
"metro-runtime": "0.76.7",
"metro-source-map": "0.76.7",
"metro-runtime": "0.78.0",
"metro-source-map": "0.78.0",
"mkdirp": "^0.5.1",
"nullthrows": "^1.1.1",
"pretty-format": "^26.5.2",
Expand Down
22 changes: 21 additions & 1 deletion scripts/objc-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ waitForWebSocketServer() {
echo "WebSocket Server is ready!"
}

waitForPackagerAlt() {
local -i max_attempts=60
local -i attempt_num=1

# TODO(huntie): Temporary string match in JSON response. We will revert
# this endpoint back to "packager-status:running" in the next CLI alpha.
until curl -s http://localhost:8081/status | grep "\"status\":\"running\"" -q; do
if (( attempt_num == max_attempts )); then
echo "Packager did not respond in time. No more attempts left."
exit 1
else
(( attempt_num++ ))
echo "Packager did not respond. Retrying for attempt number $attempt_num..."
sleep 1
fi
done

echo "Packager is ready!"
}

runTests() {
# shellcheck disable=SC1091
source "$ROOT/scripts/.tests.env"
Expand Down Expand Up @@ -131,7 +151,7 @@ main() {

# Start the packager
yarn start --max-workers=1 || echo "Can't start packager automatically" &
waitForPackager
waitForPackagerAlt
preloadBundlesRNTester
preloadBundlesRNIntegrationTests

Expand Down
6 changes: 6 additions & 0 deletions scripts/testing-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ function isPackagerRunning(
silent: true,
}).stdout;

// TODO(huntie): Temporary string match in JSON response. We will revert
// this endpoint back to "packager-status:running" in the next CLI alpha.
if (status.includes('"status":"running"')) {
return 'running';
}

return status === 'packager-status:running' ? 'running' : 'unrecognized';
} catch (_error) {
return 'not_running';
Expand Down
Loading

0 comments on commit 468dbc3

Please sign in to comment.