Skip to content

Commit

Permalink
Metro Bundler -> Metro
Browse files Browse the repository at this point in the history
Summary: This bothers me, we renamed the project to drop the "Metro" a while ago.

Reviewed By: rubennorte

Differential Revision: D16831281

fbshipit-source-id: bb6de412eccda61b617580f3660e3e635f2d2815
  • Loading branch information
cpojer authored and facebook-github-bot committed Aug 16, 2019
1 parent bb625e5 commit 88d0ac1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 40 deletions.
2 changes: 1 addition & 1 deletion RNTester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ When developing E2E tests, you may want to run in development mode, so that chan
detox build -c ios.sim.debug
detox test -c ios.sim.debug

You will also need to have Metro Bundler running in another terminal. Note that if you've previously run the E2E tests in release mode, you may need to delete the `RNTester/build` folder before rerunning `detox build`.
You will also need to have Metro running in another terminal. Note that if you've previously run the E2E tests in release mode, you may need to delete the `RNTester/build` folder before rerunning `detox build`.

## Building from source

Expand Down
71 changes: 35 additions & 36 deletions React/DevSupport/RCTInspectorDevServerHelper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#if RCT_DEV && !TARGET_OS_UIKITFORMAC

#import <UIKit/UIKit.h>
#import <React/RCTLog.h>
#import <UIKit/UIKit.h>

#import <React/RCTDefines.h>
#import <React/RCTInspectorPackagerConnection.h>
Expand Down Expand Up @@ -37,12 +37,14 @@
if (inspectorProxyPortStr && [inspectorProxyPortStr length] > 0) {
inspectorProxyPort = [NSNumber numberWithInt:[inspectorProxyPortStr intValue]];
}
NSString *escapedDeviceName = [[[UIDevice currentDevice] name] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
NSString *escapedDeviceName = [[[UIDevice currentDevice] name]
stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier]
stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/inspector/device?name=%@&app=%@",
getServerHost(bundleURL, inspectorProxyPort),
escapedDeviceName,
escapedAppName]];
getServerHost(bundleURL, inspectorProxyPort),
escapedDeviceName,
escapedAppName]];
}

static NSURL *getAttachDeviceUrl(NSURL *bundleURL, NSString *title)
Expand All @@ -52,18 +54,20 @@
if (metroBundlerPortStr && [metroBundlerPortStr length] > 0) {
metroBundlerPort = [NSNumber numberWithInt:[metroBundlerPortStr intValue]];
}
NSString *escapedDeviceName = [[[UIDevice currentDevice] name] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
NSString *escapedDeviceName = [[[UIDevice currentDevice] name]
stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier]
stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/attach-debugger-nuclide?title=%@&device=%@&app=%@",
getServerHost(bundleURL, metroBundlerPort),
title,
escapedDeviceName,
escapedAppName]];
getServerHost(bundleURL, metroBundlerPort),
title,
escapedDeviceName,
escapedAppName]];
}

@implementation RCTInspectorDevServerHelper

RCT_NOT_IMPLEMENTED(- (instancetype)init)
RCT_NOT_IMPLEMENTED(-(instancetype)init)

static NSMutableDictionary<NSString *, RCTInspectorPackagerConnection *> *socketConnections = nil;

Expand All @@ -74,39 +78,34 @@ static void sendEventToAllConnections(NSString *event)
}
}

static void displayErrorAlert(UIViewController *view, NSString *message) {
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:nil
message:message
preferredStyle:UIAlertControllerStyleAlert];
static void displayErrorAlert(UIViewController *view, NSString *message)
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
message:message
preferredStyle:UIAlertControllerStyleAlert];
[view presentViewController:alert animated:YES completion:nil];
dispatch_after(
dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * 2.5),
dispatch_get_main_queue(),
^{
[alert dismissViewControllerAnimated:YES completion:nil];
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * 2.5), dispatch_get_main_queue(), ^{
[alert dismissViewControllerAnimated:YES completion:nil];
});
}

+ (void)attachDebugger:(NSString *)owner
withBundleURL:(NSURL *)bundleURL
withView:(UIViewController *)view
+ (void)attachDebugger:(NSString *)owner withBundleURL:(NSURL *)bundleURL withView:(UIViewController *)view
{
NSURL *url = getAttachDeviceUrl(bundleURL, owner);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"GET"];

__weak UIViewController *viewCapture = view;
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:
^(__unused NSData *_Nullable data,
__unused NSURLResponse *_Nullable response,
NSError *_Nullable error) {
UIViewController *viewCaptureStrong = viewCapture;
if (error != nullptr && viewCaptureStrong != nullptr) {
displayErrorAlert(viewCaptureStrong, @"The request to attach Nuclide couldn't reach Metro Bundler!");
}
}] resume];
[[[NSURLSession sharedSession]
dataTaskWithRequest:request
completionHandler:^(
__unused NSData *_Nullable data, __unused NSURLResponse *_Nullable response, NSError *_Nullable error) {
UIViewController *viewCaptureStrong = viewCapture;
if (error != nullptr && viewCaptureStrong != nullptr) {
displayErrorAlert(viewCaptureStrong, @"The request to attach Nuclide couldn't reach Metro!");
}
}] resume];
}

+ (void)disableDebugger
Expand Down
2 changes: 1 addition & 1 deletion scripts/launchPackager.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:: LICENSE file in the root directory of this source tree.

@echo off
title Metro Bundler
title Metro
call .packager.bat
cd ../../../
node "%~dp0..\cli.js" start
Expand Down
2 changes: 1 addition & 1 deletion scripts/launchPackager.command
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# LICENSE file in the root directory of this source tree.

# Set terminal title
echo -en "\\033]0;Metro Bundler\\a"
echo -en "\\033]0;Metro\\a"
clear

THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
Expand Down
2 changes: 1 addition & 1 deletion scripts/react-native-xcode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
set -x
DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH

# Enables iOS devices to get the IP address of the machine running Metro Bundler
# Enables iOS devices to get the IP address of the machine running Metro
if [[ "$CONFIGURATION" = *Debug* && ! "$PLATFORM_NAME" == *simulator ]]; then
IP=$(ipconfig getifaddr en0)
if [ -z "$IP" ]; then
Expand Down

0 comments on commit 88d0ac1

Please sign in to comment.