From a710f9a81eaab4056a76bb16e5abcf64521bb7a5 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Tue, 23 May 2017 16:05:52 -0700 Subject: [PATCH] Move packager launcher scripts outside of `packager/` Summary: in order to prepare open sourcing React Native Packager, we have to move scripts specific to React Native to a directory that will continue to exist. Reviewed By: javache Differential Revision: D5112193 fbshipit-source-id: eac77d0d981aecef7ee52365a6856340420a5638 --- README.md | 2 +- RNTester/README.md | 4 ++-- RNTester/RNTester.xcodeproj/project.pbxproj | 4 ++-- RNTester/RNTesterLegacy.xcodeproj/project.pbxproj | 4 ++-- React/React.xcodeproj/project.pbxproj | 4 ++-- React/ReactLegacy.xcodeproj/project.pbxproj | 4 ++-- docs/IntegrationWithExistingApps.md | 4 ++-- local-cli/core/__fixtures__/files/project.pbxproj | 2 +- local-cli/link/__fixtures__/project.pbxproj | 2 +- local-cli/runAndroid/runAndroid.js | 6 +++--- .../HelloWorld/ios/HelloWorld.xcodeproj/project.pbxproj | 4 ++-- package.json | 6 +++++- {packager => scripts}/launchPackager.bat | 0 {packager => scripts}/launchPackager.command | 4 +--- scripts/objc-test.sh | 6 +++--- {packager => scripts}/packager.sh | 0 {packager => scripts}/react-native-xcode.sh | 0 17 files changed, 29 insertions(+), 27 deletions(-) rename {packager => scripts}/launchPackager.bat (100%) rename {packager => scripts}/launchPackager.command (90%) rename {packager => scripts}/packager.sh (100%) rename {packager => scripts}/react-native-xcode.sh (100%) diff --git a/README.md b/README.md index 640d4149fd26c5..1bf112f1292596 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Note that you'll need the Android NDK installed, see [prerequisites](https://git ```bash ./gradlew :Examples:Movies:android:app:installDebug # Start the packager in a separate shell (make sure you ran npm install): -./packager/packager.sh +./scripts/packager.sh # Open the Movies app in your emulator ``` diff --git a/RNTester/README.md b/RNTester/README.md index 95493ae95ab905..2b5642852f2e4d 100644 --- a/RNTester/README.md +++ b/RNTester/README.md @@ -27,7 +27,7 @@ Start an Android emulator ([Genymotion](https://www.genymotion.com) is recommend cd react-native ./gradlew :RNTester:android:app:installDebug - ./packager/packager.sh + ./scripts/packager.sh _Note: Building for the first time can take a while._ @@ -46,7 +46,7 @@ Run the following commands from the react-native folder: ./gradlew :ReactAndroid:packageReactNdkLibsForBuck buck fetch rntester buck install -r rntester - ./packager/packager.sh + ./scripts/packager.sh _Note: The native libs are still built using gradle. Full build with buck is coming soon(tm)._ diff --git a/RNTester/RNTester.xcodeproj/project.pbxproj b/RNTester/RNTester.xcodeproj/project.pbxproj index f6d299921af894..5962d20ca80775 100644 --- a/RNTester/RNTester.xcodeproj/project.pbxproj +++ b/RNTester/RNTester.xcodeproj/project.pbxproj @@ -1439,7 +1439,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n$SRCROOT/../packager/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js"; + shellScript = "export NODE_BINARY=node\n$SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js"; }; 68CD48B71D2BCB2C007E06A9 /* Run Script */ = { isa = PBXShellScriptBuildPhase; @@ -1453,7 +1453,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n$SRCROOT/../packager/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js"; + shellScript = "export NODE_BINARY=node\n$SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/RNTester/RNTesterLegacy.xcodeproj/project.pbxproj b/RNTester/RNTesterLegacy.xcodeproj/project.pbxproj index 6cb641de7d3e7a..fa2fa7c34a9c62 100644 --- a/RNTester/RNTesterLegacy.xcodeproj/project.pbxproj +++ b/RNTester/RNTesterLegacy.xcodeproj/project.pbxproj @@ -1432,7 +1432,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n$SRCROOT/../packager/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js"; + shellScript = "export NODE_BINARY=node\n$SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js"; }; 68CD48B71D2BCB2C007E06A9 /* Run Script */ = { isa = PBXShellScriptBuildPhase; @@ -1446,7 +1446,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n$SRCROOT/../packager/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js"; + shellScript = "export NODE_BINARY=node\n$SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index cba41a935f2934..853664f84f7b8b 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -3335,7 +3335,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost 8081 ; then\n if ! curl -s \"http://localhost:8081/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port 8081 already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../packager/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi"; + shellScript = "if [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost 8081 ; then\n if ! curl -s \"http://localhost:8081/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port 8081 already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi"; showEnvVarsInLog = 0; }; 142C4F7F1B582EA6001F0B58 /* Include RCTJSCProfiler */ = { @@ -3394,7 +3394,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\nif nc -w 5 -z localhost 8081 ; then\nif ! curl -s \"http://localhost:8081/status\" | grep -q \"packager-status:running\" ; then\necho \"Port 8081 already in use, packager is either not running or not running correctly\"\nexit 2\nfi\nelse\nopen \"$SRCROOT/../packager/launchPackager.command\" || echo \"Can't start packager automatically\"\nfi\nfi"; + shellScript = "if [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\nif nc -w 5 -z localhost 8081 ; then\nif ! curl -s \"http://localhost:8081/status\" | grep -q \"packager-status:running\" ; then\necho \"Port 8081 already in use, packager is either not running or not running correctly\"\nexit 2\nfi\nelse\nopen \"$SRCROOT/../scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\nfi\nfi"; showEnvVarsInLog = 0; }; 3D383D3E1EBD27B9005632C8 /* Install Third Party */ = { diff --git a/React/ReactLegacy.xcodeproj/project.pbxproj b/React/ReactLegacy.xcodeproj/project.pbxproj index dc1a49e7bd3210..8d3b1622129220 100644 --- a/React/ReactLegacy.xcodeproj/project.pbxproj +++ b/React/ReactLegacy.xcodeproj/project.pbxproj @@ -2398,7 +2398,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost 8081 ; then\n if ! curl -s \"http://localhost:8081/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port 8081 already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../packager/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi"; + shellScript = "if [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost 8081 ; then\n if ! curl -s \"http://localhost:8081/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port 8081 already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi"; showEnvVarsInLog = 0; }; 142C4F7F1B582EA6001F0B58 /* Include RCTJSCProfiler */ = { @@ -2443,7 +2443,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\nif nc -w 5 -z localhost 8081 ; then\nif ! curl -s \"http://localhost:8081/status\" | grep -q \"packager-status:running\" ; then\necho \"Port 8081 already in use, packager is either not running or not running correctly\"\nexit 2\nfi\nelse\nopen \"$SRCROOT/../packager/launchPackager.command\" || echo \"Can't start packager automatically\"\nfi\nfi"; + shellScript = "if [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\nif nc -w 5 -z localhost 8081 ; then\nif ! curl -s \"http://localhost:8081/status\" | grep -q \"packager-status:running\" ; then\necho \"Port 8081 already in use, packager is either not running or not running correctly\"\nexit 2\nfi\nelse\nopen \"$SRCROOT/../scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\nfi\nfi"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ diff --git a/docs/IntegrationWithExistingApps.md b/docs/IntegrationWithExistingApps.md index c35a410564a838..dcfd39fed2580d 100644 --- a/docs/IntegrationWithExistingApps.md +++ b/docs/IntegrationWithExistingApps.md @@ -454,11 +454,11 @@ import React -> When moving your app to production, the `NSURL` can point to a pre-bundled file on disk via something like `[[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];`. You can use the `react-native-xcode.sh` script in `node_modules/react-native/packager/` to generate that pre-bundled file. +> When moving your app to production, the `NSURL` can point to a pre-bundled file on disk via something like `[[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];`. You can use the `react-native-xcode.sh` script in `node_modules/react-native/scripts/` to generate that pre-bundled file. -> When moving your app to production, the `NSURL` can point to a pre-bundled file on disk via something like `let mainBundle = NSBundle(URLForResource: "main" withExtension:"jsbundle")`. You can use the `react-native-xcode.sh` script in `node_modules/react-native/packager/` to generate that pre-bundled file. +> When moving your app to production, the `NSURL` can point to a pre-bundled file on disk via something like `let mainBundle = NSBundle(URLForResource: "main" withExtension:"jsbundle")`. You can use the `react-native-xcode.sh` script in `node_modules/react-native/scripts/` to generate that pre-bundled file. diff --git a/local-cli/core/__fixtures__/files/project.pbxproj b/local-cli/core/__fixtures__/files/project.pbxproj index b9828751d9c1e5..004cee72bc27d7 100644 --- a/local-cli/core/__fixtures__/files/project.pbxproj +++ b/local-cli/core/__fixtures__/files/project.pbxproj @@ -539,7 +539,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "../node_modules/react-native/packager/react-native-xcode.sh"; + shellScript = "../node_modules/react-native/scripts/react-native-xcode.sh"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/local-cli/link/__fixtures__/project.pbxproj b/local-cli/link/__fixtures__/project.pbxproj index c6e8641aa8a8a3..306e9666af8f34 100644 --- a/local-cli/link/__fixtures__/project.pbxproj +++ b/local-cli/link/__fixtures__/project.pbxproj @@ -782,7 +782,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh"; + shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/local-cli/runAndroid/runAndroid.js b/local-cli/runAndroid/runAndroid.js index e7fa0790caea0a..d985333178fa0b 100644 --- a/local-cli/runAndroid/runAndroid.js +++ b/local-cli/runAndroid/runAndroid.js @@ -247,9 +247,9 @@ function startServerInNewWindow() { const scriptFile = /^win/.test(process.platform) ? 'launchPackager.bat' : 'launchPackager.command'; - const packagerDir = path.resolve(__dirname, '..', '..', 'packager'); - const launchPackagerScript = path.resolve(packagerDir, scriptFile); - const procConfig = {cwd: packagerDir}; + const scriptsDir = path.resolve(__dirname, '..', '..', 'scripts'); + const launchPackagerScript = path.resolve(scriptsDir, scriptFile); + const procConfig = {cwd: scriptsDir}; if (process.platform === 'darwin') { if (yargV.open) { diff --git a/local-cli/templates/HelloWorld/ios/HelloWorld.xcodeproj/project.pbxproj b/local-cli/templates/HelloWorld/ios/HelloWorld.xcodeproj/project.pbxproj index 7bae4668540746..e4471789dbd729 100644 --- a/local-cli/templates/HelloWorld/ios/HelloWorld.xcodeproj/project.pbxproj +++ b/local-cli/templates/HelloWorld/ios/HelloWorld.xcodeproj/project.pbxproj @@ -874,7 +874,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh"; + shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh"; }; 2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = { isa = PBXShellScriptBuildPhase; @@ -888,7 +888,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh"; + shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/package.json b/package.json index f944f67543237d..08984e4c0cb154 100644 --- a/package.json +++ b/package.json @@ -93,6 +93,10 @@ "init.sh", "scripts/ios-configure-glog.sh", "scripts/ios-install-third-party.sh", + "scripts/launchPackager.bat", + "scripts/launchPackager.command", + "scripts/packager.sh", + "scripts/react-native-xcode.sh", "jest-preset.json", "jest", "lib", @@ -114,7 +118,7 @@ "test": "jest", "flow": "flow", "lint": "eslint RNTester/ Libraries/", - "start": "/usr/bin/env bash -c './packager/packager.sh \"$@\" || true' --", + "start": "/usr/bin/env bash -c './scripts/packager.sh \"$@\" || true' --", "test-android-setup": "docker pull containership/android-base:latest", "test-android-build": "docker build -t react/android -f ContainerShip/Dockerfile.android .", "test-android-run-instrumentation": "docker run --cap-add=SYS_ADMIN -it react/android bash ContainerShip/scripts/run-android-docker-instrumentation-tests.sh", diff --git a/packager/launchPackager.bat b/scripts/launchPackager.bat similarity index 100% rename from packager/launchPackager.bat rename to scripts/launchPackager.bat diff --git a/packager/launchPackager.command b/scripts/launchPackager.command similarity index 90% rename from packager/launchPackager.command rename to scripts/launchPackager.command index 9e12272a6156d4..a81dd2d04f96b3 100755 --- a/packager/launchPackager.command +++ b/scripts/launchPackager.command @@ -12,9 +12,7 @@ echo -en "\033]0;React Packager\a" clear THIS_DIR=$(dirname "$0") -pushd "$THIS_DIR/.." -. packager/packager.sh -popd +. "$THIS_DIR/packager.sh" echo "Process terminated. Press to close the window" read diff --git a/scripts/objc-test.sh b/scripts/objc-test.sh index 019da0a2ac5f6a..15d26dff7e69f8 100755 --- a/scripts/objc-test.sh +++ b/scripts/objc-test.sh @@ -36,8 +36,8 @@ trap cleanup EXIT if [ "$1" = "test" ]; then -# Start the packager -open "./packager/launchPackager.command" || echo "Can't start packager automatically" +# Start the packager +open "./scripts/launchPackager.command" || echo "Can't start packager automatically" # Start the WebSocket test server open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically" @@ -73,6 +73,6 @@ xcodebuild \ -project "RNTester/RNTester.xcodeproj" \ -scheme $SCHEME \ -sdk $SDK \ - build + build fi diff --git a/packager/packager.sh b/scripts/packager.sh similarity index 100% rename from packager/packager.sh rename to scripts/packager.sh diff --git a/packager/react-native-xcode.sh b/scripts/react-native-xcode.sh similarity index 100% rename from packager/react-native-xcode.sh rename to scripts/react-native-xcode.sh